mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
33e59e50ee
The static hda_soc_card might be modified during runtime which might cause issues on next time when the card is created. For example if the dmic_num was set with module parameter then removed for the next module loading then the card's components will still going to point to the previous boot's cfg-dmics:X string. There might be other places where devm allocated memory have been freed but the hda_soc_card still pointing to the now unallocated memory (the memory is freed when the platform device is removed). Fix this issue by moving the snd_soc_card into skl_hda_private and use it for the card registration to ensure that it is correctly initialized every time. Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20240426152123.36284-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright(c) 2015-18 Intel Corporation.
|
|
*/
|
|
|
|
/*
|
|
* This file defines data structures used in Machine Driver for Intel
|
|
* platforms with HDA Codecs.
|
|
*/
|
|
|
|
#ifndef __SKL_HDA_DSP_COMMON_H
|
|
#define __SKL_HDA_DSP_COMMON_H
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <sound/core.h>
|
|
#include <sound/jack.h>
|
|
#include <sound/hda_codec.h>
|
|
#include "../../codecs/hdac_hda.h"
|
|
#include "hda_dsp_common.h"
|
|
|
|
#define HDA_DSP_MAX_BE_DAI_LINKS 7
|
|
|
|
struct skl_hda_hdmi_pcm {
|
|
struct list_head head;
|
|
struct snd_soc_dai *codec_dai;
|
|
struct snd_soc_jack hdmi_jack;
|
|
int device;
|
|
};
|
|
|
|
struct skl_hda_private {
|
|
struct snd_soc_card card;
|
|
struct list_head hdmi_pcm_list;
|
|
int pcm_count;
|
|
int dai_index;
|
|
const char *platform_name;
|
|
bool common_hdmi_codec_drv;
|
|
bool idisp_codec;
|
|
};
|
|
|
|
extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];
|
|
int skl_hda_hdmi_jack_init(struct snd_soc_card *card);
|
|
int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device);
|
|
|
|
/*
|
|
* Search card topology and register HDMI PCM related controls
|
|
* to codec driver.
|
|
*/
|
|
static inline int skl_hda_hdmi_build_controls(struct snd_soc_card *card)
|
|
{
|
|
struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
|
|
struct snd_soc_component *component;
|
|
struct skl_hda_hdmi_pcm *pcm;
|
|
|
|
/* HDMI disabled, do not create controls */
|
|
if (list_empty(&ctx->hdmi_pcm_list))
|
|
return 0;
|
|
|
|
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct skl_hda_hdmi_pcm,
|
|
head);
|
|
component = pcm->codec_dai->component;
|
|
if (!component)
|
|
return -EINVAL;
|
|
|
|
return hda_dsp_hdmi_build_controls(card, component);
|
|
}
|
|
|
|
#endif /* __SOUND_SOC_HDA_DSP_COMMON_H */
|