ASoC: fsl: use snd_soc_register_card to register the card
Subsystems (4)
PATCH v3 1/5 ASoC: fsl: use snd_soc_register_card to register the card
Use snd_soc_register_card() instead of platform_device_alloc("soc-audio") to register the sound card from the machine drivers. The use of platform_device_alloc is deprecated.
Although several other drivers still use platform_device_alloc(), the Freescale drivers were not using it to pass driver data. Instead of fixing the driver data usage, it's better to replace the deprecated code.
--- sound/soc/fsl/mpc8610_hpcd.c | 32 +++++++------------------------- sound/soc/fsl/p1022_ds.c | 31 ++++++------------------------- 2 files changed, 13 insertions(+), 50 deletions(-)
sound/soc/fsl/mpc8610_hpcd.c +7 -25
@@ -192,7 +192,6 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) container_of(dev, struct platform_device, dev);struct device_node *np = ssi_pdev->dev.of_node;struct device_node *codec_np =NULL ; -struct platform_device *sound_device =NULL ;struct mpc8610_hpcd_data *machine_data;int ret = -ENODEV ;const char *sprop;
@@ -341,34 +340,22 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) machine_data->card.probe = mpc8610_hpcd_machine_probe; machine_data->card.remove = mpc8610_hpcd_machine_remove; machine_data->card.name = pdev->name;/* The platform driver name */ + machine_data->card.owner =THIS_MODULE ; + machine_data->card.dev = &pdev->dev; machine_data->card.num_links =2 ; machine_data->card.dai_link = machine_data->dai; -/* Allocate a new audio platform device structure */ - sound_device =platform_device_alloc ("soc-audio" ,-1 ); -if (!sound_device) { -dev_err (&pdev->dev,"platform device alloc failed\n" ); - ret = -ENOMEM ; - goto error; - } - -/* Associate the card data with the sound device */ -platform_set_drvdata (sound_device, &machine_data->card); -/* Register with ASoC */ - ret =platform_device_add (sound_device); + ret =snd_soc_register_card (&machine_data->card);if (ret) { -dev_err (&pdev->dev,"platform device add failed\n" ); - goto error_sound; +dev_err (&pdev->dev,"could not register card\n" ); + goto error; } -dev_set_drvdata (&pdev->dev, sound_device);of_node_put (codec_np);return 0 ; -error_sound: -platform_device_put (sound_device); error:kfree (machine_data); error_alloc:
@@ -383,17 +370,12 @@ error_alloc:*/ static int __devexit mpc8610_hpcd_remove(struct platform_device *pdev) { -struct platform_device *sound_device =dev_get_drvdata (&pdev->dev); -struct snd_soc_card *card =platform_get_drvdata (sound_device); +struct snd_soc_card *card =platform_get_drvdata (pdev);struct mpc8610_hpcd_data *machine_data = container_of(card, struct mpc8610_hpcd_data, card); -platform_device_unregister (sound_device); - +snd_soc_unregister_card (card);kfree (machine_data); - sound_device->dev.platform_data =NULL ; - -dev_set_drvdata (&pdev->dev,NULL );return 0 ; }
sound/soc/fsl/p1022_ds.c +6 -25
@@ -202,7 +202,6 @@ static int p1022_ds_probe(struct platform_device *pdev) container_of(dev, struct platform_device, dev);struct device_node *np = ssi_pdev->dev.of_node;struct device_node *codec_np =NULL ; -struct platform_device *sound_device =NULL ;struct machine_data *mdata;int ret = -ENODEV ;const char *sprop;
@@ -349,36 +348,23 @@ static int p1022_ds_probe(struct platform_device *pdev) mdata->card.probe = p1022_ds_machine_probe; mdata->card.remove = p1022_ds_machine_remove; mdata->card.name = pdev->name;/* The platform driver name */ + mdata->card.owner =THIS_MODULE ; + mdata->card.dev = &pdev->dev; mdata->card.num_links =2 ; mdata->card.dai_link = mdata->dai; -/* Allocate a new audio platform device structure */ - sound_device =platform_device_alloc ("soc-audio" ,-1 ); -if (!sound_device) { -dev_err (&pdev->dev,"platform device alloc failed\n" ); - ret = -ENOMEM ; - goto error; - } - -/* Associate the card data with the sound device */ -platform_set_drvdata (sound_device, &mdata->card); -/* Register with ASoC */ - ret =platform_device_add (sound_device); + ret =snd_soc_register_card (&mdata->card);if (ret) { -dev_err (&pdev->dev,"platform device add failed\n" ); +dev_err (&pdev->dev,"could not register card\n" ); goto error; } -dev_set_drvdata (&pdev->dev, sound_device);of_node_put (codec_np);return 0 ; error: -if (sound_device) -platform_device_put (sound_device); -kfree (mdata); error_put:of_node_put (codec_np);
@@ -392,17 +378,12 @@ error_put:*/ static int __devexit p1022_ds_remove(struct platform_device *pdev) { -struct platform_device *sound_device =dev_get_drvdata (&pdev->dev); -struct snd_soc_card *card =platform_get_drvdata (sound_device); +struct snd_soc_card *card =platform_get_drvdata (pdev);struct machine_data *mdata = container_of(card, struct machine_data, card); -platform_device_unregister (sound_device); - +snd_soc_unregister_card (card);kfree (mdata); - sound_device->dev.platform_data =NULL ; - -dev_set_drvdata (&pdev->dev,NULL );return 0 ; }
Signature · 1 line
1.7.3.4
PATCH 2/5 ASoC: fsl: move machine drivers to late_initcall()
Transition the module initialization to late_initcall(), so that the machine driver loads last. Although this is technically not necessary, it does avoid this error message at boot time:
ALSA device list:
No soundcards found.
--- sound/soc/fsl/mpc8610_hpcd.c | 2 +- sound/soc/fsl/p1022_ds.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/fsl/mpc8610_hpcd.c +1 -1
@@ -425,7 +425,7 @@ static void __exit mpc8610_hpcd_exit(void)platform_driver_unregister (&mpc8610_hpcd_driver); } -module_init (mpc8610_hpcd_init); +late_initcall (mpc8610_hpcd_init);module_exit (mpc8610_hpcd_exit);MODULE_AUTHOR ("Timur Tabi <[email protected]>" );
sound/soc/fsl/p1022_ds.c +1 -1
@@ -434,7 +434,7 @@ static void __exit p1022_ds_exit(void)platform_driver_unregister (&p1022_ds_driver); } -module_init (p1022_ds_init); +late_initcall (p1022_ds_init);module_exit (p1022_ds_exit);MODULE_AUTHOR ("Timur Tabi <[email protected]>" );
Signature · 1 line
1.7.3.4
Re: [PATCH 2/5] ASoC: fsl: move machine drivers to late_initcall()
Quoted 6 lines · Timur Tabi
Transition the module initialization to
late_initcall(), so that the machine driver loads last. Although this is technically not necessary, it does avoid this error message at boot time:ALSA device list:
No soundcards found.
As I said previously I think this needs a change that applies to all drivers, like I say removing the above print seems the most sensible one to me.
PATCH 3/5 ASoC: fsl: remove unnecessary call to dma_unmap_single
In reply to Timur TabiRemove a call to dma_unmap_single() from the PowerPC ASoC DMA driver. The buffer is allocated and not actually mapped, so the unmap call doesn't make sense. It was probably left over from some early version of the driver.
This bug was unnoticed for so long because the DMA mapping functions normally don't do anything on PowerPC.
--- sound/soc/fsl/fsl_dma.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
sound/soc/fsl/fsl_dma.c +0 -6
@@ -823,12 +823,6 @@ static int fsl_dma_close(struct snd_pcm_substream *substream)if (dma_private->irq)free_irq (dma_private->irq, dma_private); -if (dma_private->ld_buf_phys) { -dma_unmap_single (dev, dma_private->ld_buf_phys, -sizeof (dma_private->link), -DMA_TO_DEVICE ); - } -/* Deallocate the fsl_dma_private structure */ dma_free_coherent (dev,sizeof (struct fsl_dma_private ), dma_private, dma_private->ld_buf_phys);
Signature · 1 line
1.7.3.4
Mark Brown
AppliedRe: [PATCH 3/5] ASoC: fsl: remove unnecessary call to dma_unmap_single
Quoted 6 lines · Timur Tabi
Remove a call to
dma_unmap_single()from the PowerPC ASoC DMA driver. The buffer is allocated and not actually mapped, so the unmap call doesn't make sense. It was probably left over from some early version of the driver.This bug was unnoticed for so long because the DMA mapping functions normally don't do anything on PowerPC.
Applied, thanks.
PATCH 4/5 ASoC: wm8960: add support for big-endian audio samples
In reply to Timur TabiPowerPC ASoC drivers frequently use the _BE variants of the SNDRV_PCM_FORMAT macros, so we need to look for those as well.
--- sound/soc/codecs/wm8960.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
sound/soc/codecs/wm8960.c +8 -1
@@ -557,18 +557,25 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,struct snd_soc_codec *codec = dai->codec;struct wm8960_priv *wm8960 =snd_soc_codec_get_drvdata (codec);u16 iface =snd_soc_read (codec,WM8960_IFACE1 ) &0xfff3 ; +snd_pcm_format_t format =params_format (params);int i;/* bit size */ -switch (params_format (params)) { +switch (format) {case SNDRV_PCM_FORMAT_S16_LE : +case SNDRV_PCM_FORMAT_S16_BE :break ;case SNDRV_PCM_FORMAT_S20_3LE : +case SNDRV_PCM_FORMAT_S20_3BE : iface |=0x0004 ;break ;case SNDRV_PCM_FORMAT_S24_LE : +case SNDRV_PCM_FORMAT_S24_BE : iface |=0x0008 ;break ; +default : +dev_err (codec->dev,"unsupported format %i\n" , format); +return -EINVAL ; }/* Update filters for the new rate */
Signature · 1 line
1.7.3.4
Re: [PATCH 4/5] ASoC: wm8960: add support for big-endian audio samples
Quoted 2 lines · Timur Tabi
PowerPC ASoC drivers frequently use the
_BEvariants of theSNDRV_PCM_FORMATmacros, so we need to look for those as well.
Applied but...
sound/soc/codecs/wm8960.c static int wm8960_hw_params(struct snd_pcm_substream *substream, · line 564
Quoted 6 lines
sound/soc/codecs/wm8960.c +2
-1+snd_pcm_format_t format =params_format (params);int i;/* bit size */ -switch (params_format (params)) { +switch (format) {
...please don't introduce unrelated changes, especially ones you don't mention in the changelog.
Re: [PATCH 4/5] ASoC: wm8960: add support for big-endian audio samples
Quoted 8 lines · Mark Brown
Quoted 6 lines
sound/soc/codecs/wm8960.c static int wm8960_hw_params(struct snd_pcm_substream *substream, · line 564
Quoted 6 lines
sound/soc/codecs/wm8960.c +2
-1+snd_pcm_format_t format =params_format (params);int i;/* bit size */ -switch (params_format (params)) { +switch (format) {...please don't introduce unrelated changes, especially ones you don't mention in the changelog.
Well, the introduction of variable 'format' is for the default case in the switch statement:
+ default:
+ dev_err(codec->dev, "unsupported format %i\n", format);
+ return -EINVAL;
I would not call this change "unrelated".
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Re: [PATCH 4/5] ASoC: wm8960: add support for big-endian audio samples
Quoted 7 lines · On Wed, Sep 19, 2012 at 02:58:29AM +0000, Tabi Timur-B04825 wrote:
Quoted 2 lines · Mark Brown
...please don't introduce unrelated changes, especially ones you don't mention in the changelog.
Well, the introduction of variable 'format' is for the default case in the switch statement:
I saw that, that's why I didn't write "random stylistic changes" (as I had originally, I nearly discarded the patch before I read that far).
Quoted 5 lines
sound/soc/codecs/wm8960.c +3
-0+default : +dev_err (codec->dev,"unsupported format %i\n" , format); +return -EINVAL ;I would not call this change "unrelated".
It's not adding a new format, it's changing the error reporting. That's a sensible thing to do and could have been done as part of the same patch but it should've been mentioned in the changelog.
PATCH 5/5 ASoC: add support for the Freescale / iVeia P1022 RDK reference board
In reply to Timur TabiThis small reference boards has a Freescale P1022 dual-core PowerPC SOC and a Wolfson Microelectronics WM8960 codec.
--- sound/soc/fsl/Kconfig | 14 ++ sound/soc/fsl/Makefile | 4 + sound/soc/fsl/p1022_rdk.c | 455 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 473 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/p1022_rdk.c
sound/soc/fsl/Kconfig +14 -0
@@ -46,6 +46,20 @@ config SND_SOC_P1022_DS This will also include the Wolfson Microelectronics WM8776 codec driver. +config SND_SOC_P1022_RDK + tristate "ALSA SoC support for the Freescale / iVeia P1022 RDK board" + # I2C is necessary for the WM8960 driver + depends on P1022_RDK && I2C + select SND_SOC_FSL_SSI + select SND_SOC_FSL_UTILS + select SND_SOC_POWERPC_DMA + select SND_SOC_WM8960 + default y if P1022_RDK + help + Say Y if you want to enable audio on the Freescale / iVeia + P1022 RDK board. This will also include the Wolfson + Microelectronics WM8960 codec driver. + config SND_SOC_MPC5200_I2S tristate "Freescale MPC5200 PSC in I2S mode driver" depends on PPC_MPC52xx && PPC_BESTCOMM
sound/soc/fsl/Makefile +4 -0
@@ -6,6 +6,10 @@ obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += snd-soc-mpc8610-hpcd.o snd-soc-p1022-ds-objs := p1022_ds.o obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o +# P1022 RDK Machine Support +snd-soc-p1022-rdk-objs := p1022_rdk.o +obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o + # Freescale PowerPC SSI/DMA Platform Support snd-soc-fsl-ssi-objs := fsl_ssi.o snd-soc-fsl-utils-objs := fsl_utils.o
sound/soc/fsl/p1022_rdk.c new file +455 -0
455 lines not on this page · raw message
Signature · 1 line
1.7.3.4
Re: [PATCH 5/5] ASoC: add support for the Freescale / iVeia P1022 RDK reference board
Quoted 5 lines · Timur Tabi
sound/soc/fsl/Kconfig | 14 ++ sound/soc/fsl/Makefile | 4 + sound/soc/fsl/p1022_rdk.c | 455 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 473 insertions(+), 0 deletions(-) create mode 100644 sound/soc/fsl/p1022_rdk.c
This adds a new device tree binding so it should be documented.
sound/soc/fsl/p1022_rdk.c line 147
Quoted 6 lines
sound/soc/fsl/p1022_rdk.c new file +6
-0+/* Tell the codec driver what the serial protocol is. */ + ret =snd_soc_dai_set_fmt (rtd->codec_dai, mdata->dai_format); +if (ret <0 ) { +dev_err (dev,"could not set codec driver audio format\n" ); +return ret; + }
This should normally be done via the dai_fmt member of the dai_link structure.
sound/soc/fsl/p1022_rdk.c line 154
Quoted 6 lines
sound/soc/fsl/p1022_rdk.c new file +6
-0+ ret =snd_soc_dai_set_pll (rtd->codec_dai,0 ,0 , mdata->clk_frequency, + mdata->clk_frequency); +if (ret <0 ) { +dev_err (dev,"could not set codec PLL frequency\n" ); +return ret; + }
We never stop the PLL - normally you'd want to stop it when the audio stops. But..
sound/soc/fsl/p1022_rdk.c line 162
Quoted 7 lines
sound/soc/fsl/p1022_rdk.c new file +7
-0+/* Tell the WM8960 to set SYSCLK equal to MCLK input (bypass PLL) */ + ret =snd_soc_dai_set_clkdiv (rtd->codec_dai,WM8960_SYSCLKDIV , +WM8960_SYSCLK_MCLK |WM8960_SYSCLK_DIV_1 ); +if (ret <0 ) { +dev_err (dev,"could not set codec driver clock source\n" ); +return ret; + }
...we don't appear to use the PLL output anyway so why not just leave it off? As this is fixed it's better style to do the setup in late_init() or the init function for the DAI link.
Also we should log the return codes when we log failures.
sound/soc/fsl/p1022_rdk.c line 273
Quoted 13 lines
sound/soc/fsl/p1022_rdk.c new file +13
-0+/* Get the serial format and clock direction. */ + sprop =of_get_property (np,"fsl,mode" ,NULL ); +if (!sprop) { +dev_err (&pdev->dev,"fsl,mode property not found\n" ); + ret = -EINVAL ; + goto error; + } + +if (strcasecmp (sprop,"i2s-slave" ) ==0 ) { + mdata->dai_format =SND_SOC_DAIFMT_NB_NF | +SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_CBM_CFM ; + mdata->codec_clk_direction =SND_SOC_CLOCK_OUT ; + mdata->cpu_clk_direction =SND_SOC_CLOCK_IN ;
Why would this be something that individual systems would want to change, and if it is something it's useful to vary why not at runtime? I suspect the best thing here is just to pick a format and use it, if there is a reason to vary this it's probably a higher level thing.
sound/soc/fsl/p1022_rdk.c line 399
Quoted 2 lines
sound/soc/fsl/p1022_rdk.c new file +2
-0+snd_soc_unregister_card (card); +kfree (mdata);
devm_kzalloc().
Re: [PATCH 5/5] ASoC: add support for the Freescale / iVeia P1022 RDK reference board
Quoted 9 lines · Mark Brown
Quoted 5 lines · Timur Tabi
sound/soc/fsl/Kconfig | 14 ++ sound/soc/fsl/Makefile | 4 + sound/soc/fsl/p1022_rdk.c | 455 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 473 insertions(+), 0 deletions(-)create mode 100644
sound/soc/fsl/p1022_rdk.cThis adds a new device tree binding so it should be documented.
It does? Where? It uses the same binding as p1022_ds.c.
Quoted 9 lines
sound/soc/fsl/p1022_rdk.c line 147
Quoted 6 lines
sound/soc/fsl/p1022_rdk.c new file +6
-0+/* Tell the codec driver what the serial protocol is. */ + ret =snd_soc_dai_set_fmt (rtd->codec_dai, mdata->dai_format); +if (ret <0 ) { +dev_err (dev,"could not set codec driver audio format\n" ); +return ret; + }This should normally be done via the
dai_fmtmember of thedai_linkstructure.
Ok, that's new. The other PowerPC SSI drivers do it this way.
Quoted 10 lines
sound/soc/fsl/p1022_rdk.c line 154
Quoted 6 lines
sound/soc/fsl/p1022_rdk.c new file +6
-0+ ret =snd_soc_dai_set_pll (rtd->codec_dai,0 ,0 , mdata->clk_frequency, + mdata->clk_frequency); +if (ret <0 ) { +dev_err (dev,"could not set codec PLL frequency\n" ); +return ret; + }We never stop the PLL - normally you'd want to stop it when the audio stops. But..
Quoted 11 lines
sound/soc/fsl/p1022_rdk.c line 162
Quoted 7 lines
sound/soc/fsl/p1022_rdk.c new file +7
-0+/* Tell the WM8960 to set SYSCLK equal to MCLK input (bypass PLL) */ + ret =snd_soc_dai_set_clkdiv (rtd->codec_dai,WM8960_SYSCLKDIV , +WM8960_SYSCLK_MCLK |WM8960_SYSCLK_DIV_1 ); +if (ret <0 ) { +dev_err (dev,"could not set codec driver clock source\n" ); +return ret; + }...we don't appear to use the PLL output anyway so why not just leave it off? As this is fixed it's better style to do the setup in
late_init()or the init function for the DAI link.
I just copied this code from iVeia BSP. I'm not really sure what it does.
Quoted 1 line
Also we should log the return codes when we log failures.
You mean like this:
if (ret < 0) {
dev_err(dev, "could not set codec driver clock source (ret=%i)\n", ret);
return ret;
}I almost never do this, and there are plenty of cases in my existing code where I don't. Is this a new policy?
Quoted 10 lines
Quoted 10 lines
sound/soc/fsl/p1022_rdk.c new file +10
-0+/* Get the serial format and clock direction. */ + sprop =of_get_property (np,"fsl,mode" ,NULL ); +if (!sprop) { +dev_err (&pdev->dev,"fsl,mode property not found\n" ); + ret = -EINVAL ; + goto error; + } + +if (strcasecmp (sprop,"i2s-slave" ) ==0 ) { + mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
Quoted 8 lines
sound/soc/fsl/p1022_rdk.c line 273
Quoted 3 lines
sound/soc/fsl/p1022_rdk.c new file +3
-0+SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_CBM_CFM ; + mdata->codec_clk_direction =SND_SOC_CLOCK_OUT ; + mdata->cpu_clk_direction =SND_SOC_CLOCK_IN ;Why would this be something that individual systems would want to change, and if it is something it's useful to vary why not at runtime? I suspect the best thing here is just to pick a format and use it, if there is a reason to vary this it's probably a higher level thing.
This is the same code as my other two machine drivers that I've been using for years. It's part of the SSI binding. Do you want me to change the binding and drop the properties?
I understand what you're saying, and you're probably right that it's not really a configuration option. But it's a change in the binding, so I can't just drop it here. I have to fix the other two machine drivers.
Quoted 5 lines
sound/soc/fsl/p1022_rdk.c line 399
Quoted 3 lines
sound/soc/fsl/p1022_rdk.c new file +2
-0+snd_soc_unregister_card (card); +kfree (mdata);
devm_kzalloc().
Ok.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Re: [PATCH 5/5] ASoC: add support for the Freescale / iVeia P1022 RDK reference board
Quoted 9 lines · On Wed, Sep 19, 2012 at 02:47:48AM +0000, Tabi Timur-B04825 wrote:
Quoted 7 lines · Mark Brown
Quoted 5 lines · Timur Tabi
sound/soc/fsl/Kconfig | 14 ++ sound/soc/fsl/Makefile | 4 + sound/soc/fsl/p1022_rdk.c | 455 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 473 insertions(+), 0 deletions(-)create mode 100644
sound/soc/fsl/p1022_rdk.c
Quoted 3 lines
Quoted 1 line
This adds a new device tree binding so it should be documented.
It does? Where? It uses the same binding as
p1022_ds.c.
It's adding a new machine driver, that generally means a new binding. If it's really an identical binding then it ought to at least add a new compatible property to the existing binding (and extend the set of supported CODECs for that binding).
Personally given the thing with the interface formats and the fact that it's not sharing code with the other bindings for implementation of the binding I'd be inclined to just document it as a new binding and use it as the model going forwards, leaving the older bindings as legacy.
Quoted 12 lines
Quoted 11 lines
sound/soc/fsl/p1022_rdk.c line 162
Quoted 7 lines
sound/soc/fsl/p1022_rdk.c new file +7
-0+/* Tell the WM8960 to set SYSCLK equal to MCLK input (bypass PLL) */ + ret =snd_soc_dai_set_clkdiv (rtd->codec_dai,WM8960_SYSCLKDIV , +WM8960_SYSCLK_MCLK |WM8960_SYSCLK_DIV_1 ); +if (ret <0 ) { +dev_err (dev,"could not set codec driver clock source\n" ); +return ret; + }...we don't appear to use the PLL output anyway so why not just leave it off? As this is fixed it's better style to do the setup in
late_init()or the init function for the DAI link.
Quoted 1 line
I just copied this code from iVeia BSP. I'm not really sure what it does.
You should just be able to drop the call to set_pll(), I expect you'll find that all it does is consume extra power.
Quoted 8 lines
Quoted 1 line
Also we should log the return codes when we log failures.
You mean like this:
if (ret < 0) { dev_err(dev, "could not set codec driver clock source (ret=%i)\n", ret); return ret; }
Yes.
Quoted 2 lines
I almost never do this, and there are plenty of cases in my existing code where I don't. Is this a new policy?
It's not new, it's always been good practice - if something fails we should do as much as possible to tell the user why.
Quoted 11 lines
Quoted 10 lines
sound/soc/fsl/p1022_rdk.c line 273
Quoted 5 lines
sound/soc/fsl/p1022_rdk.c new file +5
-0+if (strcasecmp (sprop,"i2s-slave" ) ==0 ) { + mdata->dai_format =SND_SOC_DAIFMT_NB_NF | +SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_CBM_CFM ; + mdata->codec_clk_direction =SND_SOC_CLOCK_OUT ; + mdata->cpu_clk_direction =SND_SOC_CLOCK_IN ;Why would this be something that individual systems would want to change, and if it is something it's useful to vary why not at runtime? I suspect the best thing here is just to pick a format and use it, if there is a reason to vary this it's probably a higher level thing.
Quoted 3 lines
This is the same code as my other two machine drivers that I've been using for years. It's part of the SSI binding. Do you want me to change the binding and drop the properties?
Well, the existing bindings are out there so can't really be changed but we should do something better going forwards.
Quoted 3 lines
I understand what you're saying, and you're probably right that it's not really a configuration option. But it's a change in the binding, so I can't just drop it here. I have to fix the other two machine drivers.
Like I said above it looks awfully like a new binding to me.
Re: [PATCH 5/5] ASoC: add support for the Freescale / iVeia P1022 RDK reference board
Quoted 1 line · Mark Brown
It's adding a new machine driver, that generally means a new binding.
Not for the way I defined the SSI bindings. All of the information is stored in the SSI and codec nodes. That's why I did it that way. There is no binding for the machine driver.
Quoted 3 lines
If it's really an identical binding then it ought to at least add a new compatible property to the existing binding (and extend the set of supported CODECs for that binding).
Here's the device tree:
The only thing that's new is a node for the wm8960. I could create a binding for that. I asked you in a previous email about the binding for that codec, but you never replied.
Quoted 4 lines
Personally given the thing with the interface formats and the fact that it's not sharing code with the other bindings for implementation of the binding I'd be inclined to just document it as a new binding and use it as the model going forwards, leaving the older bindings as legacy.
Again, the only new binding is the codec.
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
sound/soc/fsl/p1022_rdk.c line 162
Quoted 7 lines
sound/soc/fsl/p1022_rdk.c new file +7
-0+/* Tell the WM8960 to set SYSCLK equal to MCLK input (bypass PLL) */ + ret =snd_soc_dai_set_clkdiv (rtd->codec_dai,WM8960_SYSCLKDIV , +WM8960_SYSCLK_MCLK |WM8960_SYSCLK_DIV_1 ); +if (ret <0 ) { +dev_err (dev,"could not set codec driver clock source\n" ); +return ret; + }...we don't appear to use the PLL output anyway so why not just leave it off? As this is fixed it's better style to do the setup in
late_init()or the init function for the DAI link.
Quoted 4 lines
Quoted 1 line
I just copied this code from iVeia BSP. I'm not really sure what it does.
You should just be able to drop the call to
set_pll(), I expect you'll find that all it does is consume extra power.
Ok, I'll try it. I have no way to measure power consumption, however.
Quoted 5 lines
Quoted 2 lines
I almost never do this, and there are plenty of cases in my existing code where I don't. Is this a new policy?
It's not new, it's always been good practice - if something fails we should do as much as possible to tell the user why.
Ok.
Quoted 6 lines
Quoted 3 lines
This is the same code as my other two machine drivers that I've been using for years. It's part of the SSI binding. Do you want me to change the binding and drop the properties?
Well, the existing bindings are out there so can't really be changed but we should do something better going forwards.
Fair enough. I created those bindings because, back then, I had no idea whether they would be needed or not. Now that I've created three boards that use the SSI, I see that it's not helpful. I can fix that.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Mark Brown
AppliedQuoted 3 lines · Timur Tabi
Use
snd_soc_register_card()instead ofplatform_device_alloc("soc-audio")to register the sound card from the machine drivers. The use ofplatform_device_allocis deprecated.
Applied, thanks.