Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Existing HDA stream creation is split into two
for loops for capture and playback, but most of
the code in the two for loops are duplicated.

This patch refactors HDA stream creation with a
single for loop, thus remove code duplication.

No functional change in this patch.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230814231519.79051-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Chao Song and committed by
Mark Brown
a942409c c5556d86

+8 -60
+8 -60
sound/soc/sof/intel/hda-stream.c
··· 869 869 return -ENOMEM; 870 870 } 871 871 872 - /* create capture streams */ 873 - for (i = 0; i < num_capture; i++) { 872 + /* create capture and playback streams */ 873 + for (i = 0; i < num_total; i++) { 874 874 struct sof_intel_hda_stream *hda_stream; 875 875 876 876 hda_stream = devm_kzalloc(sdev->dev, sizeof(*hda_stream), ··· 909 909 hstream->index = i; 910 910 sd_offset = SOF_STREAM_SD_OFFSET(hstream); 911 911 hstream->sd_addr = sdev->bar[HDA_DSP_HDA_BAR] + sd_offset; 912 - hstream->stream_tag = i + 1; 913 912 hstream->opened = false; 914 913 hstream->running = false; 915 - hstream->direction = SNDRV_PCM_STREAM_CAPTURE; 916 914 917 - /* memory alloc for stream BDL */ 918 - ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 919 - HDA_DSP_BDL_SIZE, &hstream->bdl); 920 - if (ret < 0) { 921 - dev_err(sdev->dev, "error: stream bdl dma alloc failed\n"); 922 - return -ENOMEM; 915 + if (i < num_capture) { 916 + hstream->stream_tag = i + 1; 917 + hstream->direction = SNDRV_PCM_STREAM_CAPTURE; 918 + } else { 919 + hstream->stream_tag = i - num_capture + 1; 920 + hstream->direction = SNDRV_PCM_STREAM_PLAYBACK; 923 921 } 924 - hstream->posbuf = (__le32 *)(bus->posbuf.area + 925 - (hstream->index) * 8); 926 - 927 - list_add_tail(&hstream->list, &bus->stream_list); 928 - } 929 - 930 - /* create playback streams */ 931 - for (i = num_capture; i < num_total; i++) { 932 - struct sof_intel_hda_stream *hda_stream; 933 - 934 - hda_stream = devm_kzalloc(sdev->dev, sizeof(*hda_stream), 935 - GFP_KERNEL); 936 - if (!hda_stream) 937 - return -ENOMEM; 938 - 939 - hda_stream->sdev = sdev; 940 - 941 - hext_stream = &hda_stream->hext_stream; 942 - 943 - if (sdev->bar[HDA_DSP_PP_BAR]) { 944 - hext_stream->pphc_addr = sdev->bar[HDA_DSP_PP_BAR] + 945 - SOF_HDA_PPHC_BASE + SOF_HDA_PPHC_INTERVAL * i; 946 - 947 - hext_stream->pplc_addr = sdev->bar[HDA_DSP_PP_BAR] + 948 - SOF_HDA_PPLC_BASE + SOF_HDA_PPLC_MULTI * num_total + 949 - SOF_HDA_PPLC_INTERVAL * i; 950 - } 951 - 952 - hstream = &hext_stream->hstream; 953 - 954 - /* do we support SPIB */ 955 - if (sdev->bar[HDA_DSP_SPIB_BAR]) { 956 - hstream->spib_addr = sdev->bar[HDA_DSP_SPIB_BAR] + 957 - SOF_HDA_SPIB_BASE + SOF_HDA_SPIB_INTERVAL * i + 958 - SOF_HDA_SPIB_SPIB; 959 - 960 - hstream->fifo_addr = sdev->bar[HDA_DSP_SPIB_BAR] + 961 - SOF_HDA_SPIB_BASE + SOF_HDA_SPIB_INTERVAL * i + 962 - SOF_HDA_SPIB_MAXFIFO; 963 - } 964 - 965 - hstream->bus = bus; 966 - hstream->sd_int_sta_mask = 1 << i; 967 - hstream->index = i; 968 - sd_offset = SOF_STREAM_SD_OFFSET(hstream); 969 - hstream->sd_addr = sdev->bar[HDA_DSP_HDA_BAR] + sd_offset; 970 - hstream->stream_tag = i - num_capture + 1; 971 - hstream->opened = false; 972 - hstream->running = false; 973 - hstream->direction = SNDRV_PCM_STREAM_PLAYBACK; 974 922 975 923 /* mem alloc for stream BDL */ 976 924 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,