Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASoC: SOF: Intel: Refactor code for HDA stream creation #4511

Merged
Merged
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
68 changes: 8 additions & 60 deletions sound/soc/sof/intel/hda-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,8 @@ int hda_dsp_stream_init(struct snd_sof_dev *sdev)
return -ENOMEM;
}

/* create capture streams */
for (i = 0; i < num_capture; i++) {
/* create capture and playback streams */
for (i = 0; i < num_total; i++) {
struct sof_intel_hda_stream *hda_stream;

hda_stream = devm_kzalloc(sdev->dev, sizeof(*hda_stream),
Expand Down Expand Up @@ -909,69 +909,17 @@ int hda_dsp_stream_init(struct snd_sof_dev *sdev)
hstream->index = i;
sd_offset = SOF_STREAM_SD_OFFSET(hstream);
hstream->sd_addr = sdev->bar[HDA_DSP_HDA_BAR] + sd_offset;
hstream->stream_tag = i + 1;
hstream->opened = false;
hstream->running = false;
hstream->direction = SNDRV_PCM_STREAM_CAPTURE;

/* memory alloc for stream BDL */
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,
HDA_DSP_BDL_SIZE, &hstream->bdl);
if (ret < 0) {
dev_err(sdev->dev, "error: stream bdl dma alloc failed\n");
return -ENOMEM;
}
hstream->posbuf = (__le32 *)(bus->posbuf.area +
(hstream->index) * 8);

list_add_tail(&hstream->list, &bus->stream_list);
}

/* create playback streams */
for (i = num_capture; i < num_total; i++) {
struct sof_intel_hda_stream *hda_stream;

hda_stream = devm_kzalloc(sdev->dev, sizeof(*hda_stream),
GFP_KERNEL);
if (!hda_stream)
return -ENOMEM;

hda_stream->sdev = sdev;

hext_stream = &hda_stream->hext_stream;

if (sdev->bar[HDA_DSP_PP_BAR]) {
hext_stream->pphc_addr = sdev->bar[HDA_DSP_PP_BAR] +
SOF_HDA_PPHC_BASE + SOF_HDA_PPHC_INTERVAL * i;

hext_stream->pplc_addr = sdev->bar[HDA_DSP_PP_BAR] +
SOF_HDA_PPLC_BASE + SOF_HDA_PPLC_MULTI * num_total +
SOF_HDA_PPLC_INTERVAL * i;
}

hstream = &hext_stream->hstream;

/* do we support SPIB */
if (sdev->bar[HDA_DSP_SPIB_BAR]) {
hstream->spib_addr = sdev->bar[HDA_DSP_SPIB_BAR] +
SOF_HDA_SPIB_BASE + SOF_HDA_SPIB_INTERVAL * i +
SOF_HDA_SPIB_SPIB;

hstream->fifo_addr = sdev->bar[HDA_DSP_SPIB_BAR] +
SOF_HDA_SPIB_BASE + SOF_HDA_SPIB_INTERVAL * i +
SOF_HDA_SPIB_MAXFIFO;
if (i < num_capture) {
hstream->stream_tag = i + 1;
hstream->direction = SNDRV_PCM_STREAM_CAPTURE;
} else {
hstream->stream_tag = i - num_capture + 1;
hstream->direction = SNDRV_PCM_STREAM_PLAYBACK;
}

hstream->bus = bus;
hstream->sd_int_sta_mask = 1 << i;
hstream->index = i;
sd_offset = SOF_STREAM_SD_OFFSET(hstream);
hstream->sd_addr = sdev->bar[HDA_DSP_HDA_BAR] + sd_offset;
hstream->stream_tag = i - num_capture + 1;
hstream->opened = false;
hstream->running = false;
hstream->direction = SNDRV_PCM_STREAM_PLAYBACK;

/* mem alloc for stream BDL */
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,
HDA_DSP_BDL_SIZE, &hstream->bdl);
Expand Down