diff options
author | Takashi Iwai <tiwai@suse.de> | 2019-08-07 14:50:50 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-08-08 10:38:12 -0400 |
commit | d4ff1b3917a529bdc75592af6b1504ad6c4029f7 (patch) | |
tree | ac68a812ac46218fe20c90cb0a16edfacd65c06e | |
parent | 19abfefd4c7604993d1c31e098a3f48bdafe334d (diff) |
ASoC: SOF: Intel: Initialize hdaudio bus properly
The SOF HD-audio bus has its house-made initialization code. It's
supposedly for making the code independent from HD-audio bus drivers.
However, this is error-prone, and above all, the SOF driver has
already dependency on HD-audio bus driver when CONFIG_SND_SOF_HDA is
set. That is, if this Kconfig is set, there is no reason to avoid the
call to the proper bus init function.
Also, the ext_ops that is set at bus initialization can be better
handled inside sof_hda_bus_init(). We don't need to refer this
outside the bus initialization.
So this patch addresses these issues:
- sof_hda_bus_init() calls nothing but snd_hdac_ext_bus_init()
when CONFIG_SND_SOF_HDA is set. Otherwise some fields are
initialized locally like before for avoiding the dependency.
- ext_ops is referred inside sof_hda_bus_init(). The ext_ops argument
of snd_hda_bus_init() is dropped.
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/soc/sof/intel/hda-bus.c | 31 | ||||
-rw-r--r-- | sound/soc/sof/intel/hda.c | 6 | ||||
-rw-r--r-- | sound/soc/sof/intel/hda.h | 3 |
3 files changed, 11 insertions, 29 deletions
diff --git a/sound/soc/sof/intel/hda-bus.c b/sound/soc/sof/intel/hda-bus.c index 438121c70f99..0caec3a070d3 100644 --- a/sound/soc/sof/intel/hda-bus.c +++ b/sound/soc/sof/intel/hda-bus.c | |||
@@ -12,28 +12,26 @@ | |||
12 | #include "../sof-priv.h" | 12 | #include "../sof-priv.h" |
13 | #include "hda.h" | 13 | #include "hda.h" |
14 | 14 | ||
15 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) | 15 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) |
16 | 16 | #define sof_hda_ext_ops snd_soc_hdac_hda_get_ops() | |
17 | static const struct hdac_bus_ops bus_ops = { | 17 | #else |
18 | .command = snd_hdac_bus_send_cmd, | 18 | #define sof_hda_ext_ops NULL |
19 | .get_response = snd_hdac_bus_get_response, | ||
20 | }; | ||
21 | |||
22 | #endif | 19 | #endif |
23 | 20 | ||
24 | /* | 21 | /* |
25 | * This can be used for both with/without hda link support. | 22 | * This can be used for both with/without hda link support. |
26 | */ | 23 | */ |
27 | void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev, | 24 | void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev) |
28 | const struct hdac_ext_bus_ops *ext_ops) | ||
29 | { | 25 | { |
26 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) | ||
27 | snd_hdac_ext_bus_init(bus, dev, NULL, sof_hda_ext_ops); | ||
28 | #else /* CONFIG_SND_SOC_SOF_HDA */ | ||
30 | memset(bus, 0, sizeof(*bus)); | 29 | memset(bus, 0, sizeof(*bus)); |
31 | bus->dev = dev; | 30 | bus->dev = dev; |
32 | 31 | ||
33 | INIT_LIST_HEAD(&bus->stream_list); | 32 | INIT_LIST_HEAD(&bus->stream_list); |
34 | 33 | ||
35 | bus->irq = -1; | 34 | bus->irq = -1; |
36 | bus->ext_ops = ext_ops; | ||
37 | 35 | ||
38 | /* | 36 | /* |
39 | * There is only one HDA bus atm. keep the index as 0. | 37 | * There is only one HDA bus atm. keep the index as 0. |
@@ -42,16 +40,5 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev, | |||
42 | bus->idx = 0; | 40 | bus->idx = 0; |
43 | 41 | ||
44 | spin_lock_init(&bus->reg_lock); | 42 | spin_lock_init(&bus->reg_lock); |
45 | 43 | #endif /* CONFIG_SND_SOC_SOF_HDA */ | |
46 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) | ||
47 | INIT_LIST_HEAD(&bus->codec_list); | ||
48 | INIT_LIST_HEAD(&bus->hlink_list); | ||
49 | |||
50 | mutex_init(&bus->cmd_mutex); | ||
51 | mutex_init(&bus->lock); | ||
52 | bus->ops = &bus_ops; | ||
53 | INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events); | ||
54 | bus->cmd_dma_state = true; | ||
55 | #endif | ||
56 | |||
57 | } | 44 | } |
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 7f665392618f..7ca27000c34d 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c | |||
@@ -236,7 +236,6 @@ static int hda_init(struct snd_sof_dev *sdev) | |||
236 | { | 236 | { |
237 | struct hda_bus *hbus; | 237 | struct hda_bus *hbus; |
238 | struct hdac_bus *bus; | 238 | struct hdac_bus *bus; |
239 | struct hdac_ext_bus_ops *ext_ops = NULL; | ||
240 | struct pci_dev *pci = to_pci_dev(sdev->dev); | 239 | struct pci_dev *pci = to_pci_dev(sdev->dev); |
241 | int ret; | 240 | int ret; |
242 | 241 | ||
@@ -244,10 +243,7 @@ static int hda_init(struct snd_sof_dev *sdev) | |||
244 | bus = sof_to_bus(sdev); | 243 | bus = sof_to_bus(sdev); |
245 | 244 | ||
246 | /* HDA bus init */ | 245 | /* HDA bus init */ |
247 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) | 246 | sof_hda_bus_init(bus, &pci->dev); |
248 | ext_ops = snd_soc_hdac_hda_get_ops(); | ||
249 | #endif | ||
250 | sof_hda_bus_init(bus, &pci->dev, ext_ops); | ||
251 | 247 | ||
252 | /* Workaround for a communication error on CFL (bko#199007) and CNL */ | 248 | /* Workaround for a communication error on CFL (bko#199007) and CNL */ |
253 | if (IS_CFL(pci) || IS_CNL(pci)) | 249 | if (IS_CFL(pci) || IS_CNL(pci)) |
diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index d9c17146200b..75b096050fa2 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h | |||
@@ -549,8 +549,7 @@ void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev); | |||
549 | /* | 549 | /* |
550 | * HDA bus operations. | 550 | * HDA bus operations. |
551 | */ | 551 | */ |
552 | void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev, | 552 | void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev); |
553 | const struct hdac_ext_bus_ops *ext_ops); | ||
554 | 553 | ||
555 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) | 554 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
556 | /* | 555 | /* |