Commit 3fd63658 authored by Cezary Rojewski's avatar Cezary Rojewski Committed by Takashi Iwai
Browse files

ASoC: Intel: Drop hdac_ext usage for codec device creation



To make snd_hda_codec_device_init() the only constructor for struct
hda_codec instances remaining tasks are:

1) no struct may wrap struct hda_codec as its base type
2) bus drivers (skylake and sof) which are the current hdac_ext users
   need to be adjusted to make use of newly added codec init and exit
   routines instead
3) as bus drivers (skylake and sof) are to be responsible for creating
   codec device and assigning it to hdac_hda_priv->codec,
   hdac_hda_dev_probe() has to be freed of that job

To keep git bisect happy, all of these in made in one-go.

Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Acked-by: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220816111727.3218543-4-cezary.rojewski@intel.com


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 829c6731
Loading
Loading
Loading
Loading
+10 −16
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
		return -EINVAL;

	hda_stream = &pcm->stream[substream->stream];
	snd_hda_codec_cleanup(&hda_pvt->codec, hda_stream, substream);
	snd_hda_codec_cleanup(hda_pvt->codec, hda_stream, substream);

	return 0;
}
@@ -264,7 +264,7 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
	int ret = 0;

	hda_pvt = snd_soc_component_get_drvdata(component);
	hdev = &hda_pvt->codec.core;
	hdev = &hda_pvt->codec->core;
	pcm = snd_soc_find_pcm_from_dai(hda_pvt, dai);
	if (!pcm)
		return -EINVAL;
@@ -274,7 +274,7 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
	stream = hda_pvt->pcm[dai->id].stream_tag[substream->stream];
	format_val = hda_pvt->pcm[dai->id].format_val[substream->stream];

	ret = snd_hda_codec_prepare(&hda_pvt->codec, hda_stream,
	ret = snd_hda_codec_prepare(hda_pvt->codec, hda_stream,
				    stream, format_val, substream);
	if (ret < 0)
		dev_err(&hdev->dev, "codec prepare failed %d\n", ret);
@@ -299,7 +299,7 @@ static int hdac_hda_dai_open(struct snd_pcm_substream *substream,

	hda_stream = &pcm->stream[substream->stream];

	return hda_stream->ops.open(hda_stream, &hda_pvt->codec, substream);
	return hda_stream->ops.open(hda_stream, hda_pvt->codec, substream);
}

static void hdac_hda_dai_close(struct snd_pcm_substream *substream,
@@ -317,7 +317,7 @@ static void hdac_hda_dai_close(struct snd_pcm_substream *substream,

	hda_stream = &pcm->stream[substream->stream];

	hda_stream->ops.close(hda_stream, &hda_pvt->codec, substream);
	hda_stream->ops.close(hda_stream, hda_pvt->codec, substream);

	snd_hda_codec_pcm_put(pcm);
}
@@ -325,7 +325,7 @@ static void hdac_hda_dai_close(struct snd_pcm_substream *substream,
static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,
						 struct snd_soc_dai *dai)
{
	struct hda_codec *hcodec = &hda_pvt->codec;
	struct hda_codec *hcodec = hda_pvt->codec;
	struct hda_pcm *cpcm;
	const char *pcm_name;

@@ -394,8 +394,8 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
			snd_soc_component_get_drvdata(component);
	struct snd_soc_dapm_context *dapm =
			snd_soc_component_get_dapm(component);
	struct hdac_device *hdev = &hda_pvt->codec.core;
	struct hda_codec *hcodec = &hda_pvt->codec;
	struct hdac_device *hdev = &hda_pvt->codec->core;
	struct hda_codec *hcodec = hda_pvt->codec;
	struct hdac_ext_link *hlink;
	hda_codec_patch_t patch;
	int ret;
@@ -515,8 +515,8 @@ static void hdac_hda_codec_remove(struct snd_soc_component *component)
{
	struct hdac_hda_priv *hda_pvt =
		      snd_soc_component_get_drvdata(component);
	struct hdac_device *hdev = &hda_pvt->codec.core;
	struct hda_codec *codec = &hda_pvt->codec;
	struct hdac_device *hdev = &hda_pvt->codec->core;
	struct hda_codec *codec = hda_pvt->codec;
	struct hdac_ext_link *hlink = NULL;

	hlink = snd_hdac_ext_bus_get_link(hdev->bus, dev_name(&hdev->dev));
@@ -584,7 +584,6 @@ static const struct snd_soc_component_driver hdac_hda_codec = {
static int hdac_hda_dev_probe(struct hdac_device *hdev)
{
	struct hdac_ext_link *hlink;
	struct hdac_hda_priv *hda_pvt;
	int ret;

	/* hold the ref while we probe */
@@ -595,10 +594,6 @@ static int hdac_hda_dev_probe(struct hdac_device *hdev)
	}
	snd_hdac_ext_bus_link_get(hdev->bus, hlink);

	hda_pvt = hdac_to_hda_priv(hdev);
	if (!hda_pvt)
		return -ENOMEM;

	/* ASoC specific initialization */
	ret = devm_snd_soc_register_component(&hdev->dev,
					 &hdac_hda_codec, hdac_hda_dais,
@@ -608,7 +603,6 @@ static int hdac_hda_dev_probe(struct hdac_device *hdev)
		return ret;
	}

	dev_set_drvdata(&hdev->dev, hda_pvt);
	snd_hdac_ext_bus_link_put(hdev->bus, hlink);

	return ret;
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ struct hdac_hda_pcm {
};

struct hdac_hda_priv {
	struct hda_codec codec;
	struct hda_codec *codec;
	struct hdac_hda_pcm pcm[HDAC_LAST_DAI_ID];
	bool need_display_power;
};
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ int hda_dsp_hdmi_build_controls(struct snd_soc_card *card,
		return -EINVAL;

	hda_pvt = snd_soc_component_get_drvdata(comp);
	hcodec = &hda_pvt->codec;
	hcodec = hda_pvt->codec;

	list_for_each_entry(hpcm, &hcodec->pcm_list_head, list) {
		spcm = hda_dsp_hdmi_pcm_handle(card, i);
+1 −1
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ static void skl_set_hda_codec_autosuspend_delay(struct snd_soc_card *card)
			 * all codecs are on the same bus, so it's sufficient
			 * to look up only the first one
			 */
			snd_hda_set_power_save(hda_pvt->codec.bus,
			snd_hda_set_power_save(hda_pvt->codec->bus,
					       HDA_CODEC_AUTOSUSPEND_DELAY_MS);
			break;
		}
+11 −15
Original line number Diff line number Diff line
@@ -694,7 +694,7 @@ static void skl_codec_device_exit(struct device *dev)
	snd_hdac_device_exit(dev_to_hdac_dev(dev));
}

static __maybe_unused struct hda_codec *skl_codec_device_init(struct hdac_bus *bus, int addr)
static struct hda_codec *skl_codec_device_init(struct hdac_bus *bus, int addr)
{
	struct hda_codec *codec;
	int ret;
@@ -729,9 +729,8 @@ static int probe_codec(struct hdac_bus *bus, int addr)
	struct skl_dev *skl = bus_to_skl(bus);
#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
	struct hdac_hda_priv *hda_codec;
	int err;
#endif
	struct hdac_device *hdev;
	struct hda_codec *codec;

	mutex_lock(&bus->cmd_mutex);
	snd_hdac_bus_send_cmd(bus, cmd);
@@ -747,25 +746,22 @@ static int probe_codec(struct hdac_bus *bus, int addr)
	if (!hda_codec)
		return -ENOMEM;

	hda_codec->codec.bus = skl_to_hbus(skl);
	hdev = &hda_codec->codec.core;
	codec = skl_codec_device_init(bus, addr);
	if (IS_ERR(codec))
		return PTR_ERR(codec);

	err = snd_hdac_ext_bus_device_init(bus, addr, hdev, HDA_DEV_ASOC);
	if (err < 0)
		return err;
	hda_codec->codec = codec;
	dev_set_drvdata(&codec->core.dev, hda_codec);

	/* use legacy bus only for HDA codecs, idisp uses ext bus */
	if ((res & 0xFFFF0000) != IDISP_INTEL_VENDOR_ID) {
		hdev->type = HDA_DEV_LEGACY;
		load_codec_module(&hda_codec->codec);
		codec->core.type = HDA_DEV_LEGACY;
		load_codec_module(hda_codec->codec);
	}
	return 0;
#else
	hdev = devm_kzalloc(&skl->pci->dev, sizeof(*hdev), GFP_KERNEL);
	if (!hdev)
		return -ENOMEM;

	return snd_hdac_ext_bus_device_init(bus, addr, hdev, HDA_DEV_ASOC);
	codec = skl_codec_device_init(bus, addr);
	return PTR_ERR_OR_ZERO(codec);
#endif /* CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC */
}

Loading