Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions sound/soc/sof/intel/hda-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
4 changes: 4 additions & 0 deletions sound/soc/sof/intel/hda-codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
2 changes: 2 additions & 0 deletions sound/soc/sof/intel/hda-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
24 changes: 12 additions & 12 deletions sound/soc/sof/intel/hda-dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;

/*
Expand Down Expand Up @@ -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 */
Expand Down Expand 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;
Expand Down
24 changes: 8 additions & 16 deletions sound/soc/sof/intel/hda-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,13 +522,15 @@ 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);
if (ret < 0) {
dev_err(sdev->dev, "error: RB alloc failed\n");
return -ENOMEM;
}
#endif

/* create capture streams */
for (i = 0; i < num_capture; i++) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */

Expand Down
30 changes: 12 additions & 18 deletions sound/soc/sof/intel/hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
}

Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
16 changes: 13 additions & 3 deletions sound/soc/sof/intel/hda.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down