ASoC: AMD: add AMD ASoC ACP-I2S driver
Subsystems (3)
PATCH v5 3/3 ASoC: AMD: add AMD ASoC ACP-I2S driver
From: Maruthi Srinivas Bayyavarapu <[email protected]>
ACP IP block consists of dedicated DMA and I2S blocks. The PCM driver provides the DMA and CPU DAI components to ALSA core.
---
v2: squash in Kconfig fix
v3: squash additional commits, convert to mfd, drop rt286 changes
v4: squash in naming fixes
v5: move patch versioning out of commit message
The module licensing follows the model used in the drm drivers.
sound/soc/Kconfig | 1 + sound/soc/Makefile | 1 + sound/soc/amd/Kconfig | 5 + sound/soc/amd/Makefile | 3 + sound/soc/amd/acp-pcm-dma.c | 676 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 686 insertions(+) create mode 100644 sound/soc/amd/Kconfig create mode 100644 sound/soc/amd/Makefile create mode 100644 sound/soc/amd/acp-pcm-dma.c
sound/soc/Kconfig +1 -0
@@ -32,6 +32,7 @@ config SND_SOC_GENERIC_DMAENGINE_PCM # All the supported SoCs source "sound/soc/adi/Kconfig" +source "sound/soc/amd/Kconfig" source "sound/soc/atmel/Kconfig" source "sound/soc/au1x/Kconfig" source "sound/soc/bcm/Kconfig"
sound/soc/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_SND_SOC) += snd-soc-core.o obj-$(CONFIG_SND_SOC) += codecs/ obj-$(CONFIG_SND_SOC) += generic/ obj-$(CONFIG_SND_SOC) += adi/ +obj-$(CONFIG_SND_SOC) += amd/ obj-$(CONFIG_SND_SOC) += atmel/ obj-$(CONFIG_SND_SOC) += au1x/ obj-$(CONFIG_SND_SOC) += bcm/
sound/soc/amd/Kconfig new file +5 -0
@@ -0,0 +1,5 @@ +config SND_SOC_AMD_ACP + tristate "AMD Audio Coprocessor support" + depends on MFD_CORE + help + This option enables ACP support (DMA,I2S) on AMD platforms.
sound/soc/amd/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +snd-soc-acp-pcm-objs := acp-pcm-dma.o + +obj-$(CONFIG_SND_SOC_AMD_ACP) += snd-soc-acp-pcm.o
sound/soc/amd/acp-pcm-dma.c new file +676 -0
676 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Mark Brown
maintainerQuoted 4 lines · Alex Deucher
From: Maruthi Srinivas Bayyavarapu <[email protected]>
ACP IP block consists of dedicated DMA and I2S blocks. The PCM driver provides the DMA and CPU DAI components to ALSA core.
This is flagged as patch 3/3 but appears to be sent as a single patch. Please don't do this, the purpose of numbering patches is to help people tell which order they are in. Numbering only makes sense when you send more than one patch, if you are sending a single patch there is no need to number.
sound/soc/amd/Kconfig line 3
Quoted 5 lines
+++ b/sound/soc/amd/Kconfig
sound/soc/amd/Kconfig new file +3
-0@@ -0,0 +1,5 @@ +config SND_SOC_AMD_ACP + tristate "AMD Audio Coprocessor support" + depends on MFD_CORE
What is the dependency on the MFD core?
Quoted 12 lines
sound/soc/amd/acp-pcm-dma.c new file +12
-0+/* +* AMD ALSA SoC PCM Driver +* +* Copyright 2014-2015 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +*
sound/soc/amd/acp-pcm-dma.c line 22
Quoted 10 lines
sound/soc/amd/acp-pcm-dma.c new file +10
-0+* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE.
Still not happy with the licensing.
sound/soc/amd/acp-pcm-dma.c line 111
Quoted 3 lines
sound/soc/amd/acp-pcm-dma.c new file +3
-0+static const struct snd_soc_component_driver dw_i2s_component = { + .name ="dw-i2s" , +};
We already have a driver for the DesignWare I2S controller. To repeat the concern I raised in a slightly different bit of the code last time:
| This doesn't appear to be a designware-i2s driver, we already have one | of those?
Like I say please stop ignoring review comments. The hw_params() certainly seems to bear more than a passing resemblance.
sound/soc/amd/acp-pcm-dma.c line 123
Quoted 11 lines
sound/soc/amd/acp-pcm-dma.c new file +11
-0+static void acp_pcm_period_elapsed (struct device *dev,u16 play_intr, +u16 capture_intr) +{ +struct snd_pcm_substream *substream; +struct audio_drv_data *irq_data =dev_get_drvdata (dev); + +/* Inform ALSA about the period elapsed (one out of two periods) */ +if (play_intr) + substream = irq_data->play_stream; +else + substream = irq_data->capture_stream;
So you've replaced the two if statements with an if/else which means subsstream is now guaranteed to be initialized but perhaps not in the way the caller intended... I did find the caller (which got moved into another patch in this version) and it appears that the two u16s are actually used to pass boolean flags. The whole interface here now seems odd, what is going on here?
sound/soc/amd/acp-pcm-dma.c line 193
Quoted 1 line
sound/soc/amd/acp-pcm-dma.c new file +1
-0+if (NULL != pg) {
We still normally write these checks more like (pg != NULL) or even just (pg).
Quoted 15 lines
sound/soc/amd/acp-pcm-dma.c new file +15
-0+/* Save for runtime private data */ + rtd->pg = pg; + rtd->order =get_order (size); + +/* Let ACP know the Allocated memory */ + num_of_pages =PAGE_ALIGN (size) >>PAGE_SHIFT ; + +/* Fill the page table entries in ACP SRAM */ + rtd->pg = pg; + rtd->size = size; + rtd->num_of_pages = num_of_pages; + rtd->direction = substream->stream; + + acp_dev->config_dma (acp_dev, rtd); + status =0 ;
sound/soc/amd/acp-pcm-dma.c line 218
Quoted 10 lines
sound/soc/amd/acp-pcm-dma.c new file +10
-0+ }else { + status = -ENOMEM ; + } +return status; +} + +static int acp_dma_hw_free (struct snd_pcm_substream *substream) +{ +return snd_pcm_lib_free_pages (substream); +}
hw_free() doesn't seem to undo everything that we did on allocation?
sound/soc/amd/acp-pcm-dma.c line 266
Quoted 6 lines
sound/soc/amd/acp-pcm-dma.c new file +6
-0+/* Now configure DMA to transfer only first half of System RAM +* buffer before playback is triggered. This will overwrite +* zero-ed second half of SRAM buffer */ + acp_dev->config_dma_channel (acp_dev,SYSRAM_TO_ACP_CH_NUM , +PLAYBACK_START_DMA_DESCR_CH12 , +1 ,0 );
| Why? The comments describe what's happening but it's not clear why it's | happening.
sound/soc/amd/acp-pcm-dma.c line 469
Quoted 5 lines
sound/soc/amd/acp-pcm-dma.c new file +5
-0+static struct snd_soc_dai_driver i2s_dai_driver = { + .playback = { + .stream_name ="I2S Playback" , + .channels_min =2 , + .channels_max =2 ,
Elsewhere support for 8 channels was declared and handled.
sound/soc/amd/acp-pcm-dma.c line 472
Quoted 3 lines
sound/soc/amd/acp-pcm-dma.c new file +3
-0+ .rates = SNDRV_PCM_RATE_8000_96000, + .formats =SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE,
Elsewhere there was 16 bit support declared and handled.
Review
Quoted 2 lines
(quoted diff) +2
-0+ pm_rts = pm_runtime_status_suspended(dev); + if (pm_rts == true) {
There seem to be a lot of variables in here that have only one assignment and one user immediately next to them. I'm not sure it's adding much.
Quoted 11 lines · Mark Brown
Quoted 4 lines · Alex Deucher
From: Maruthi Srinivas Bayyavarapu <[email protected]>
ACP IP block consists of dedicated DMA and I2S blocks. The PCM driver provides the DMA and CPU DAI components to ALSA core.
This is flagged as patch 3/3 but appears to be sent as a single patch. Please don't do this, the purpose of numbering patches is to help people tell which order they are in. Numbering only makes sense when you send more than one patch, if you are sending a single patch there is no need to number.
Sorry, I just saw this reply now. I just resent the patch with an improved change log. You an ignore that one.
Maruthi, can you comment on the points below and respin the patches as necessary?
Thanks,
Alex
Quoted 121 lines
sound/soc/amd/Kconfig line 3
Quoted 6 lines
+++ b/sound/soc/amd/Kconfig
sound/soc/amd/Kconfig new file +3
-0@@ -0,0 +1,5 @@ +config SND_SOC_AMD_ACP + tristate "AMD Audio Coprocessor support" + depends on MFD_COREWhat is the dependency on the MFD core?
Quoted 12 lines
sound/soc/amd/acp-pcm-dma.c new file +12
-0+/* +* AMD ALSA SoC PCM Driver +* +* Copyright 2014-2015 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* sound/soc/amd/acp-pcm-dma.c line 22
Quoted 10 lines
sound/soc/amd/acp-pcm-dma.c new file +10
-0+* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. Still not happy with the licensing.
sound/soc/amd/acp-pcm-dma.c line 111
Quoted 3 lines
sound/soc/amd/acp-pcm-dma.c new file +3
-0+static const struct snd_soc_component_driver dw_i2s_component = { + .name ="dw-i2s" , +};We already have a driver for the DesignWare I2S controller. To repeat the concern I raised in a slightly different bit of the code last time:
| This doesn't appear to be a designware-i2s driver, we already have one | of those?
Like I say please stop ignoring review comments. The
hw_params()certainly seems to bear more than a passing resemblance.sound/soc/amd/acp-pcm-dma.c line 123
Quoted 11 lines
sound/soc/amd/acp-pcm-dma.c new file +11
-0+static void acp_pcm_period_elapsed (struct device *dev,u16 play_intr, +u16 capture_intr) +{ +struct snd_pcm_substream *substream; +struct audio_drv_data *irq_data =dev_get_drvdata (dev); + +/* Inform ALSA about the period elapsed (one out of two periods) */ +if (play_intr) + substream = irq_data->play_stream; +else + substream = irq_data->capture_stream;So you've replaced the two if statements with an if/else which means subsstream is now guaranteed to be initialized but perhaps not in the way the caller intended... I did find the caller (which got moved into another patch in this version) and it appears that the two u16s are actually used to pass boolean flags. The whole interface here now seems odd, what is going on here?
Quoted 1 line
+ if (NULL != pg) {
We still normally write these checks more like (pg != NULL) or even just (pg).
Quoted 15 lines
sound/soc/amd/acp-pcm-dma.c new file +15
-0+/* Save for runtime private data */ + rtd->pg = pg; + rtd->order =get_order (size); + +/* Let ACP know the Allocated memory */ + num_of_pages =PAGE_ALIGN (size) >>PAGE_SHIFT ; + +/* Fill the page table entries in ACP SRAM */ + rtd->pg = pg; + rtd->size = size; + rtd->num_of_pages = num_of_pages; + rtd->direction = substream->stream; + + acp_dev->config_dma (acp_dev, rtd); + status =0 ;sound/soc/amd/acp-pcm-dma.c line 218
Quoted 10 lines
sound/soc/amd/acp-pcm-dma.c new file +10
-0+ }else { + status = -ENOMEM ; + } +return status; +} + +static int acp_dma_hw_free (struct snd_pcm_substream *substream) +{ +return snd_pcm_lib_free_pages (substream); +}
hw_free()doesn't seem to undo everything that we did on allocation?sound/soc/amd/acp-pcm-dma.c line 266
Quoted 6 lines
sound/soc/amd/acp-pcm-dma.c new file +6
-0+/* Now configure DMA to transfer only first half of System RAM +* buffer before playback is triggered. This will overwrite +* zero-ed second half of SRAM buffer */ + acp_dev->config_dma_channel (acp_dev,SYSRAM_TO_ACP_CH_NUM , +PLAYBACK_START_DMA_DESCR_CH12 , +1 ,0 );| Why? The comments describe what's happening but it's not clear why it's | happening.
sound/soc/amd/acp-pcm-dma.c line 469
Quoted 5 lines
sound/soc/amd/acp-pcm-dma.c new file +5
-0+static struct snd_soc_dai_driver i2s_dai_driver = { + .playback = { + .stream_name ="I2S Playback" , + .channels_min =2 , + .channels_max =2 ,Elsewhere support for 8 channels was declared and handled.
sound/soc/amd/acp-pcm-dma.c line 472
Quoted 3 lines
sound/soc/amd/acp-pcm-dma.c new file +3
-0+ .rates = SNDRV_PCM_RATE_8000_96000, + .formats =SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE,
Quoted 8 lines
Elsewhere there was 16 bit support declared and handled.
Review
Quoted 2 lines
(quoted diff) +2
-0+ pm_rts = pm_runtime_status_suspended(dev); + if (pm_rts == true) {There seem to be a lot of variables in here that have only one assignment and one user immediately next to them. I'm not sure it's adding much.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Mark Brown
Quoted 2 lines · Alex Deucher
From: Maruthi Srinivas Bayyavarapu <[email protected]>
Quoted 8 lines
Quoted 2 lines
ACP IP block consists of dedicated DMA and I2S blocks. The PCM driver provides the DMA and CPU DAI components to ALSA core.
This is flagged as patch 3/3 but appears to be sent as a single patch. Please don't do this, the purpose of numbering patches is to help people tell which order they are in. Numbering only makes sense when you send more than one patch, if you are sending a single patch there is no need to number.
Ok, sorry. I will be more careful next time. Actually, two patches are sent - one for
DRM and other ASoC. It should have been represented as 2/2.
Quoted 9 lines
sound/soc/amd/Kconfig line 3
Quoted 7 lines
+++ b/sound/soc/amd/Kconfig
sound/soc/amd/Kconfig new file +3
-0@@ -0,0 +1,5 @@ +config SND_SOC_AMD_ACP + tristate "AMD Audio Coprocessor support" + depends on MFD_COREWhat is the dependency on the MFD core?
None. Sorry, I forgot to remove this.
Actually, AMD DRM driver depends on MFD_CORE to create a platform device for ASoC. This is already present in DRM patch.
Quoted 25 lines
Quoted 14 lines
sound/soc/amd/acp-pcm-dma.c new file +12
-0+/* +* AMD ALSA SoC PCM Driver +* +* Copyright 2014-2015 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* sound/soc/amd/acp-pcm-dma.c line 22
Quoted 10 lines
sound/soc/amd/acp-pcm-dma.c new file +10
-0+* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE.
Quoted 1 line
Still not happy with the licensing.
I will contact our internal teams and get back on this.
Quoted 11 lines
sound/soc/amd/acp-pcm-dma.c line 111
Quoted 4 lines
sound/soc/amd/acp-pcm-dma.c new file +3
-0+static const struct snd_soc_component_driver dw_i2s_component = { + .name ="dw-i2s" , +};We already have a driver for the DesignWare I2S controller. To repeat the concern I raised in a slightly different bit of the code last time:
| This doesn't appear to be a designware-i2s driver, we already have one | of those?
Our IP block includes few AMD IPs along with DesignWare I2S IP. I have reused code from Designware I2S controller from sound/soc/dwc/designware_i2s.c and because
of the way IPs are coupled together, I couldn't use existing Designware I2S driver as is.
I have given credit to the original author in DRM patch copyright header, where register I2S read/writes
are made. Do I need to add the same header in ASoC driver too ?
Quoted 4 lines
Like I say please stop ignoring review comments. The
hw_params()certainly seems to bear more than a passing resemblance.
Iam sorry, this mistake won't be repeated.
Quoted 11 lines
Quoted 11 lines
sound/soc/amd/acp-pcm-dma.c new file +10
-0+static void acp_pcm_period_elapsed (struct device *dev,u16 play_intr, +u16 capture_intr) +{ +struct snd_pcm_substream *substream; +struct audio_drv_data *irq_data =dev_get_drvdata (dev); + +/* Inform ALSA about the period elapsed (one out of two periods) */ +if (play_intr) + substream = irq_data->play_stream; +else
Quoted 9 lines
Quoted 1 line
+ substream =
irq_data->capture_stream;So you've replaced the two if statements with an if/else which means subsstream is now guaranteed to be initialized but perhaps not in the way the caller intended... I did find the caller (which got moved into another patch in this version) and it appears that the two u16s are actually used to pass boolean flags. The whole interface here now seems odd, what is going on here?
Agreed. I will modify this interface to use a bool, in next revision
Quoted 6 lines
Quoted 2 lines
+ if (NULL != pg) {
We still normally write these checks more like (pg != NULL) or even just (pg).
Ok, will modify accordingly in next revision.
Quoted 20 lines
Quoted 20 lines
sound/soc/amd/acp-pcm-dma.c new file +19
-0+/* Save for runtime private data */ + rtd->pg = pg; + rtd->order =get_order (size); + +/* Let ACP know the Allocated memory */ + num_of_pages =PAGE_ALIGN (size) >>PAGE_SHIFT ; + +/* Fill the page table entries in ACP SRAM */ + rtd->pg = pg; + rtd->size = size; + rtd->num_of_pages = num_of_pages; + rtd->direction = substream->stream; + + acp_dev->config_dma (acp_dev, rtd); + status =0 ; + }else { + status = -ENOMEM ; + } +return status;
Quoted 8 lines
sound/soc/amd/acp-pcm-dma.c line 218
Quoted 6 lines
sound/soc/amd/acp-pcm-dma.c new file +6
-0+} + +static int acp_dma_hw_free (struct snd_pcm_substream *substream) +{ +return snd_pcm_lib_free_pages (substream); +}
hw_free()doesn't seem to undo everything that we did on allocation?
Oh! I freed in dma_close(), that were allocated in dma_open(). Rest of them used devm_*
Quoted 9 lines
sound/soc/amd/acp-pcm-dma.c line 266
Quoted 8 lines
sound/soc/amd/acp-pcm-dma.c new file +6
-0+/* Now configure DMA to transfer only first half of System RAM +* buffer before playback is triggered. This will overwrite +* zero-ed second half of SRAM buffer */ + acp_dev->config_dma_channel (acp_dev,SYSRAM_TO_ACP_CH_NUM , +PLAYBACK_START_DMA_DESCR_CH12 , +1 ,0 );
Quoted 3 lines
| Why? The comments describe what's happening but it's not clear why it's | happening.
|------------|----------|
| A | B | DRAM
|------------|----------|
\ /
\ /
\/ DMA
/\
|---------/-|-\--------|
| C / | \ D | SRAM ---DMA ---------> I2S
|-----------|----------|buffer in System memory(DRAM) is divided into 2 periods - say A,B. internal memory
inside ACP IP (SRAM) is also divided in similar way - say C,D. In hw_params() A and B
are filled with zeros. In prepare() , content of A and B are DMA'ed to D and C respectively
(as per DMA configuration). When ALSA core fills A and B with audio content (start threshold = A+B size), trigger() is called and content of A is transferred to D.
C still holds zeros by now. The internal buffer (SRAM) which holds C+D will be DMA'ed to
I2S in cyclic way starting from C.
At the end of C or D's DMA to I2S, irq is generated. In irq handler DMA is done from B to C
or A to D depending on C or D' DMA completion respectively and snd_pcm_period_elapsed()
is called.
The reason for doing this is : When C completes rendering, calls period_elapsed() and informs
ALSA core there is free space to fill new data to system memory. In the same irq handler, B is
DMA'ed to C to be ready by the time D completes rendering with prefetched data (in trigger()).
when D completes rendering, new data fetched by ALSA core can be DMA'ed from A to D and
rendering is continued with C. This is done cyclically.
If I don’t do A->D, B->C and instead do A->C, B->D, there would be timing problem to have new
data ready to be rendered. The alternate approach would be implement 'copy' callback of
'snd_pcm_ops' in pcm driver. In that callback, I can use copy_from_user() to get new data and
then only issue DMA transfers (A->C / B->D). This can solve the timing issue mentioned, but then
I can't handle MMAP based playback/capture. Existing design can handle non-mmap and mmap based
transfers, but the only issue(?) would be 1 period size of zeros will be played initially for any new
playback usecase.
Quoted 7 lines
sound/soc/amd/acp-pcm-dma.c line 469
Quoted 5 lines
sound/soc/amd/acp-pcm-dma.c new file +5
-0+static struct snd_soc_dai_driver i2s_dai_driver = { + .playback = { + .stream_name ="I2S Playback" , + .channels_min =2 , + .channels_max =2 ,Elsewhere support for 8 channels was declared and handled.
The board for which driver is developed, doesn't support more than 2 channels.
Quoted 6 lines
sound/soc/amd/acp-pcm-dma.c line 472
Quoted 4 lines
sound/soc/amd/acp-pcm-dma.c new file +3
-0+ .rates = SNDRV_PCM_RATE_8000_96000, + .formats =SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE,Elsewhere there was 16 bit support declared and handled.
There is a bug in our I2S IP, which wrongly handles 16 bit and lower resolutions.
So, I removed the support. All the players using the driver, will handle unsupported
formats with the help of pulseaudio conversions.
Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ pm_rts = pm_runtime_status_suspended(dev); + if (pm_rts == true) {There seem to be a lot of variables in here that have only one assignment and one user immediately next to them. I'm not sure it's adding much.
Ok, I will reuse variables, where required and remove extra ones in the next version.
Quoted 5 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Mark Brown
maintainerQuoted 5 lines · maruthi srinivas
Quoted 2 lines · Mark Brown
We already have a driver for the DesignWare I2S controller. To repeat the concern I raised in a slightly different bit of the code last time:
Quoted 8 lines
Quoted 2 lines
| This doesn't appear to be a designware-i2s driver, we already have one | of those?
Our IP block includes few AMD IPs along with DesignWare I2S IP. I have reused code from Designware I2S controller from
sound/soc/dwc/designware_i2s.cand because
of the way IPs are coupled together, I couldn't use existing Designware I2S driver as is.
Could you be more specific about the way in which the IPs are coupled and the problems this causes please?
Quoted 3 lines
I have given credit to the original author in DRM patch copyright header, where register I2S read/writes
are made. Do I need to add the same header in ASoC driver too ?
What I'm looking for is actual code sharing where we use the same code for the I2S controller block or a clear and documented understanding of why it is not possible to share things.
Quoted 2 lines
Oh! I freed in
dma_close(), that were allocated indma_open(). Rest of them used devm_*
OK.
Quoted 10 lines
Quoted 9 lines
sound/soc/amd/acp-pcm-dma.c line 266
Quoted 6 lines
sound/soc/amd/acp-pcm-dma.c new file +6
-0+/* Now configure DMA to transfer only first half of System RAM +* buffer before playback is triggered. This will overwrite +* zero-ed second half of SRAM buffer */ + acp_dev->config_dma_channel (acp_dev,SYSRAM_TO_ACP_CH_NUM , +PLAYBACK_START_DMA_DESCR_CH12 , +1 ,0 );| Why? The comments describe what's happening but it's not clear why it's | happening.
Quoted 9 lines
The reason for doing this is : When C completes rendering, calls
period_elapsed()and informs
ALSA core there is free space to fill new data to system memory. In the same irq handler, B is
DMA'ed to C to be ready by the time D completes rendering with prefetched data (intrigger()).
when D completes rendering, new data fetched by ALSA core can be DMA'ed from A to D and
rendering is continued with C. This is done cyclically.
My point here is that the internal documentation in the driver should be improved so that someone reading the code can tell why this is being done. It doesn't need to be this full explanation but at least enough for people to be aware of the general issue.
Quoted 9 lines
Quoted 7 lines
sound/soc/amd/acp-pcm-dma.c line 469
Quoted 5 lines
sound/soc/amd/acp-pcm-dma.c new file +5
-0+static struct snd_soc_dai_driver i2s_dai_driver = { + .playback = { + .stream_name ="I2S Playback" , + .channels_min =2 , + .channels_max =2 ,Elsewhere support for 8 channels was declared and handled.
The board for which driver is developed, doesn't support more than 2 channels.
This is a driver for the IP, not for the board - you may not be able to test everything but code should try to be as general as it can be.
Quoted 18 lines · Mark Brown
Quoted 5 lines · maruthi srinivas
Quoted 2 lines · Mark Brown
We already have a driver for the DesignWare I2S controller. To repeat the concern I raised in a slightly different bit of the code last time:
Quoted 8 lines
Quoted 2 lines
| This doesn't appear to be a designware-i2s driver, we already have one | of those?
Our IP block includes few AMD IPs along with DesignWare I2S IP. I have reused code from Designware I2S controller from
sound/soc/dwc/designware_i2s.cand because
of the way IPs are coupled together, I couldn't use existing Designware I2S driver as is.Could you be more specific about the way in which the IPs are coupled and the problems this causes please?
Quoted 8 lines
Quoted 3 lines
I have given credit to the original author in DRM patch copyright header, where register I2S read/writes
are made. Do I need to add the same header in ASoC driver too ?What I'm looking for is actual code sharing where we use the same code for the I2S controller block or a clear and documented understanding of why it is not possible to share things.
Maruthi can clarify further, but it's not possible to use the designware driver directly because:
1. The i2s registers are within the same MMIO aperture as our other GPU registers. Our GPU driver is designed in such a way that the specific IP modules don't have direct access to the MMIO aperture. They use functions provided by the core driver to access registers. Thus the ACP IP module within the GPU driver does not have direct access to the mmio base pointer in order to pass it on.
2. The designware driver depends on the CLKDEV framework which we don't currently support.
3. Our hardware does not support S16_LE
Alex
Quoted 36 lines
Quoted 2 lines
Oh! I freed in
dma_close(), that were allocated indma_open(). Rest of them used devm_*OK.
Quoted 10 lines
Quoted 9 lines
sound/soc/amd/acp-pcm-dma.c line 266
Quoted 6 lines
sound/soc/amd/acp-pcm-dma.c new file +6
-0+/* Now configure DMA to transfer only first half of System RAM +* buffer before playback is triggered. This will overwrite +* zero-ed second half of SRAM buffer */ + acp_dev->config_dma_channel (acp_dev,SYSRAM_TO_ACP_CH_NUM , +PLAYBACK_START_DMA_DESCR_CH12 , +1 ,0 );| Why? The comments describe what's happening but it's not clear why it's | happening.
Quoted 9 lines
The reason for doing this is : When C completes rendering, calls
period_elapsed()and informs
ALSA core there is free space to fill new data to system memory. In the same irq handler, B is
DMA'ed to C to be ready by the time D completes rendering with prefetched data (intrigger()).
when D completes rendering, new data fetched by ALSA core can be DMA'ed from A to D and
rendering is continued with C. This is done cyclically.My point here is that the internal documentation in the driver should be improved so that someone reading the code can tell why this is being done. It doesn't need to be this full explanation but at least enough for people to be aware of the general issue.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
sound/soc/amd/acp-pcm-dma.c new file +5
-0+static struct snd_soc_dai_driver i2s_dai_driver = { + .playback = { + .stream_name ="I2S Playback" , + .channels_min =2 , + .channels_max =2 ,
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Elsewhere support for 8 channels was declared and handled.
The board for which driver is developed, doesn't support more than 2 channels.
This is a driver for the IP, not for the board - you may not be able to test everything but code should try to be as general as it can be.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Mark Brown
maintainerQuoted 6 lines · Alex Deucher
Quoted 3 lines · Mark Brown
What I'm looking for is actual code sharing where we use the same code for the I2S controller block or a clear and documented understanding of why it is not possible to share things.
Quoted 8 lines
Maruthi can clarify further, but it's not possible to use the designware driver directly because:
1. The i2s registers are within the same MMIO aperture as our other GPU registers. Our GPU driver is designed in such a way that the specific IP modules don't have direct access to the MMIO aperture. They use functions provided by the core driver to access registers. Thus the ACP IP module within the GPU driver does not have direct access to the mmio base pointer in order to pass it on.
Please explain this in more detail, shared register ranges are very common and are the sort of things MFDs are supposed to help with.
Quoted 2 lines
2. The designware driver depends on the CLKDEV framework which we don't currently support.
You need to support the clock API, it's very easy to do so so there is no excuse for doing something custom here.
Quoted 1 line
3. Our hardware does not support
S16_LE
If you have modified the designware IP to remove this support (why would anyone do that?) it's a trivial quirk, if the restriction comes from some other part of the system like the DMA driver then the constraint will come from that part of the system.
Quoted 16 lines · Mark Brown
Quoted 6 lines · Alex Deucher
Quoted 3 lines · Mark Brown
What I'm looking for is actual code sharing where we use the same code for the I2S controller block or a clear and documented understanding of why it is not possible to share things.
Quoted 8 lines
Maruthi can clarify further, but it's not possible to use the designware driver directly because:
1. The i2s registers are within the same MMIO aperture as our other GPU registers. Our GPU driver is designed in such a way that the specific IP modules don't have direct access to the MMIO aperture. They use functions provided by the core driver to access registers. Thus the ACP IP module within the GPU driver does not have direct access to the mmio base pointer in order to pass it on.
Quoted 3 lines
Please explain this in more detail, shared register ranges are very common and are the sort of things MFDs are supposed to help with.
In our case, ACP I2S driver need not do a 'devm_ioremap_resource' to get mmio base.
ACP audio IP (DMA + I2S+ Others) registers can be accessed, using GPU's MMIO base.
During GPU driver design, it was decided that all the register access for entire GPU MMIO
aperture (includes ACP and others) to be done in GPU module only. This is implemented in another patch in this patch series using a abstraction layer.
A set of functions were defined for audio DMA and I2S functionality within GPU driver
module and those function pointers were passed as platform data to ALSA PCM driver to handle both DMA and I2S.
Quoted 6 lines
Quoted 2 lines
2. The designware driver depends on the CLKDEV framework which we don't currently support.
You need to support the clock API, it's very easy to do so so there is no excuse for doing something custom here.
Codec acts as master in our case to provide clock to i2s controller and there wasn't a need to use clock APIs unlike in existing designware i2s driver. There is no custom implementation.
Quoted 6 lines
Quoted 1 line
3. Our hardware does not support
S16_LEIf you have modified the designware IP to remove this support (why would anyone do that?) it's a trivial quirk, if the restriction comes from some other part of the system like the DMA driver then the constraint will come from that part of the system.
There is a bug in ACP SoC implementation (which combines internal DMA, designware I2S
and other blocks) for 16bit and lower resolution. I felt , it would be better to limit functionality
in I2S DAI capabilities. I will put this limitation in DMA driver capabilities, to represent overall
sound card capabilities, if you suggest.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Mark Brown
maintainerQuoted 7 lines · maruthi srinivas
Quoted 2 lines · Mark Brown
Please explain this in more detail, shared register ranges are very common and are the sort of things MFDs are supposed to help with.
In our case, ACP I2S driver need not do a '
devm_ioremap_resource' to get mmio base.
That sounds like a MFD type problem...
Quoted 7 lines
ACP audio IP (DMA + I2S+ Others) registers can be accessed, using GPU's MMIO base.
During GPU driver design, it was decided that all the register access for entire GPU MMIO
aperture (includes ACP and others) to be done in GPU module only. This is implemented in another patch in this patch series using a abstraction layer.
That sounds like converting the Designware driver to use regmap and providing a regmap would enable code sharing (you can provide a regmap for accessors if you don't use it in the main driver).
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
2. The designware driver depends on the CLKDEV framework which we don't currently support.
You need to support the clock API, it's very easy to do so so there is no excuse for doing something custom here.
Codec acts as master in our case to provide clock to i2s controller and there wasn't a need to use clock APIs unlike in existing designware i2s driver. There is no custom implementation.
So you just need to add slave mode support to the driver. Again not a reason to just copy the code.
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
3. Our hardware does not support
S16_LEIf you have modified the designware IP to remove this support (why would anyone do that?) it's a trivial quirk, if the restriction comes from some other part of the system like the DMA driver then the constraint will come from that part of the system.
Quoted 7 lines
There is a bug in ACP SoC implementation (which combines internal DMA, designware I2S
and other blocks) for 16bit and lower resolution. I felt , it would be better to limit functionality
in I2S DAI capabilities. I will put this limitation in DMA driver capabilities, to represent overall
sound card capabilities, if you suggest.
A quirk would also do the job.