diff --git a/sound/soc/sof/intel/hda-bus.c b/sound/soc/sof/intel/hda-bus.c index e7fd07f1f80d5b..de158dd7d0cf58 100644 --- a/sound/soc/sof/intel/hda-bus.c +++ b/sound/soc/sof/intel/hda-bus.c @@ -86,20 +86,22 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev, bus->io_ops = &io_ops; INIT_LIST_HEAD(&bus->stream_list); - INIT_LIST_HEAD(&bus->codec_list); -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) - bus->ops = &bus_ops; - INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events); -#endif - spin_lock_init(&bus->reg_lock); - mutex_init(&bus->cmd_mutex); bus->irq = -1; - bus->ext_ops = ext_ops; - INIT_LIST_HEAD(&bus->hlink_list); bus->idx = idx++; + spin_lock_init(&bus->reg_lock); + +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) + INIT_LIST_HEAD(&bus->codec_list); + INIT_LIST_HEAD(&bus->hlink_list); + + mutex_init(&bus->cmd_mutex); mutex_init(&bus->lock); + bus->ops = &bus_ops; + INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events); bus->cmd_dma_state = true; +#endif + } diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c index 9701aac357b3ea..cc4a537d0e8a6f 100644 --- a/sound/soc/sof/intel/hda-codec.c +++ b/sound/soc/sof/intel/hda-codec.c @@ -112,6 +112,8 @@ int hda_codec_probe_bus(struct snd_sof_dev *sdev) } EXPORT_SYMBOL(hda_codec_probe_bus); +#if IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI) + int hda_codec_i915_get(struct snd_sof_dev *sdev) { struct hdac_bus *bus = sof_to_bus(sdev); @@ -173,4 +175,6 @@ int hda_codec_i915_exit(struct snd_sof_dev *sdev) } EXPORT_SYMBOL(hda_codec_i915_exit); +#endif /* CONFIG_SND_SOC_HDAC_HDMI */ + MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/sof/intel/hda-ctrl.c b/sound/soc/sof/intel/hda-ctrl.c index 3414e50bf4fb7e..1f6cd07f8c756a 100644 --- a/sound/soc/sof/intel/hda-ctrl.c +++ b/sound/soc/sof/intel/hda-ctrl.c @@ -138,7 +138,9 @@ void hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable) */ int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable) { +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) struct hdac_bus *bus = sof_to_bus(sdev); +#endif u32 val; /* enable/disable audio dsp clock gating */ diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c index 9e1874f3f4d268..413e76a46b300b 100644 --- a/sound/soc/sof/intel/hda-dsp.c +++ b/sound/soc/sof/intel/hda-dsp.c @@ -259,7 +259,9 @@ int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev, static int hda_suspend(struct snd_sof_dev *sdev, int state) { const struct sof_intel_dsp_desc *chip = sdev->hda->desc; +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) struct hdac_bus *bus = sof_to_bus(sdev); +#endif int ret = 0; #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) @@ -302,8 +304,10 @@ static int hda_suspend(struct snd_sof_dev *sdev, int state) static int hda_resume(struct snd_sof_dev *sdev) { const struct sof_intel_dsp_desc *chip = sdev->hda->desc; +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) struct hdac_bus *bus = sof_to_bus(sdev); struct hdac_ext_link *hlink = NULL; +#endif int ret; /* @@ -379,12 +383,10 @@ int hda_dsp_resume(struct snd_sof_dev *sdev) int ret; /* turn display power on */ - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { - ret = hda_codec_i915_get(sdev); - if (ret < 0) { - dev_err(bus->dev, "Cannot turn on display power on i915 after resume\n"); - return ret; - } + ret = hda_codec_i915_get(sdev); + if (ret < 0) { + dev_err(bus->dev, "Cannot turn on display power on i915 after resume\n"); + return ret; } /* init hda controller and power dsp up */ @@ -416,12 +418,10 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev, int state) } /* turn display power off */ - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { - ret = hda_codec_i915_put(sdev); - if (ret < 0) { - dev_err(bus->dev, "Cannot turn OFF display power on i915 during suspend\n"); - return ret; - } + ret = hda_codec_i915_put(sdev); + if (ret < 0) { + dev_err(bus->dev, "Cannot turn OFF display power on i915 during suspend\n"); + return ret; } return 0; diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c index 49725fcd5590ed..880c7425c13172 100644 --- a/sound/soc/sof/intel/hda-stream.c +++ b/sound/soc/sof/intel/hda-stream.c @@ -522,6 +522,7 @@ int hda_dsp_stream_init(struct snd_sof_dev *sdev) return -ENOMEM; } +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) /* mem alloc for the CORB/RIRB ringbuffers */ ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, PAGE_SIZE, &bus->rb); @@ -529,6 +530,7 @@ int hda_dsp_stream_init(struct snd_sof_dev *sdev) dev_err(sdev->dev, "error: RB alloc failed\n"); return -ENOMEM; } +#endif /* create capture streams */ for (i = 0; i < num_capture; i++) { @@ -555,14 +557,6 @@ int hda_dsp_stream_init(struct snd_sof_dev *sdev) SOF_HDA_SPIB_MAXFIFO; } -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_DRSM) - /* FIXME: Remove? HDAC doesn't use DRSM so has no drsm_addr */ - /* do we support DRSM */ - if (sdev->bar[HDA_DSP_DRSM_BAR]) - stream->drsm_addr = sdev->bar[HDA_DSP_DRSM_BAR] + - SOF_HDA_DRSM_BASE + SOF_HDA_DRSM_INTERVAL * i; -#endif - hstream = &stream->hstream; hstream->bus = bus; hstream->sd_int_sta_mask = 1 << i; @@ -613,14 +607,6 @@ int hda_dsp_stream_init(struct snd_sof_dev *sdev) SOF_HDA_SPIB_MAXFIFO; } -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_DRSM) - /* FIXME: Remove? HDAC doesn't use DRSM so has no drsm_addr */ - /* do we support DRSM */ - if (sdev->bar[HDA_DSP_DRSM_BAR]) - stream->drsm_addr = sdev->bar[HDA_DSP_DRSM_BAR] + - SOF_HDA_DRSM_BASE + SOF_HDA_DRSM_INTERVAL * i; -#endif - hstream = &stream->hstream; hstream->bus = bus; hstream->sd_int_sta_mask = 1 << i; @@ -659,6 +645,12 @@ void hda_dsp_stream_free(struct snd_sof_dev *sdev) if (bus->posbuf.area) snd_dma_free_pages(&bus->posbuf); +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) + /* free position buffer */ + if (bus->rb.area) + snd_dma_free_pages(&bus->rb); +#endif + list_for_each_entry_safe(s, _s, &bus->stream_list, list) { /* TODO: decouple */ diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 192289fb734b4f..e0ba5c75f3a8f0 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -437,6 +437,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev) struct hdac_ext_link *hlink = NULL; struct snd_soc_acpi_mach_params *mach_params; int ret = 0; + int err; device_disable_async_suspend(bus->dev); @@ -448,22 +449,18 @@ static int hda_init_caps(struct snd_sof_dev *sdev) snd_hdac_ext_bus_get_ml_capabilities(bus); /* init i915 and HDMI codecs */ - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { - ret = hda_codec_i915_init(sdev); - if (ret < 0) { - dev_err(&pci->dev, "no HDMI audio devices found\n"); - return ret; - } + ret = hda_codec_i915_init(sdev); + if (ret < 0) { + dev_err(&pci->dev, "no HDMI audio devices found\n"); + return ret; } ret = hda_dsp_ctrl_init_chip(sdev, true); if (ret < 0) { dev_err(bus->dev, "Init chip failed with ret: %d\n", ret); - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { - ret = hda_codec_i915_put(sdev); - if (ret < 0) - return ret; - } + err = hda_codec_i915_put(sdev); + if (err < 0) + return err; return ret; } @@ -481,11 +478,9 @@ static int hda_init_caps(struct snd_sof_dev *sdev) /* create codec instances */ hda_codec_probe_bus(sdev); - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { - ret = hda_codec_i915_put(sdev); - if (ret < 0) - return ret; - } + ret = hda_codec_i915_put(sdev); + if (ret < 0) + return ret; /* * we are done probing so decrement link counts @@ -769,8 +764,7 @@ int hda_dsp_remove(struct snd_sof_dev *sdev) iounmap(sdev->bar[HDA_DSP_BAR]); iounmap(bus->remap_addr); - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) - hda_codec_i915_exit(sdev); + hda_codec_i915_exit(sdev); return 0; } diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 875af5e287dfc9..6cf4d84a88a396 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -513,14 +513,24 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev, */ int hda_codec_probe_bus(struct snd_sof_dev *sdev); -#if IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI) +#endif /* CONFIG_SND_SOC_SOF_HDA */ + +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) && IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI) + int hda_codec_i915_get(struct snd_sof_dev *sdev); int hda_codec_i915_put(struct snd_sof_dev *sdev); int hda_codec_i915_init(struct snd_sof_dev *sdev); int hda_codec_i915_exit(struct snd_sof_dev *sdev); -#endif /* CONFIG_SND_SOC_HDAC_HDMI */ -#endif /* CONFIG_SND_SOC_SOF_HDA */ +#else + +static inline int hda_codec_i915_get(struct snd_sof_dev *sdev) { return 0; } +static inline int hda_codec_i915_put(struct snd_sof_dev *sdev) { return 0; } +static inline int hda_codec_i915_init(struct snd_sof_dev *sdev) { return 0; } +static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; } + +#endif /* CONFIG_SND_SOC_SOF_HDA && CONFIG_SND_SOC_HDAC_HDMI */ + /* * Trace Control. */