ALSA: ASoC for Au1000/1500/1100
v2 cover ALSA: ASoC for Au1000/1500/1100
Hello,
These 2 patches implement ASoC drivers for the AC97 and I2S controllers found on early Alchemy chips. They are largely based on the old mips/au1x00.c driver which they replace.
AC97 Tested on a Db1500 development board; I2S untested since none of the testboards I have actually have an I2S codec (just testpoints).
Changes since V1:
- added untested I2S controller driver for completeness, removed the audio defines from the au1000 header.
Manuel Lauss (2):
ALSA: Alchemy AC97C/I2SC audio support
ALSA: delete MIPS au1x00 driver
arch/mips/alchemy/devboards/db1x00/platform.c | 37 ++ arch/mips/include/asm/mach-au1x00/au1000.h | 61 --- sound/mips/Kconfig | 8 - sound/mips/Makefile | 2 - sound/mips/au1x00.c | 695 ------------------------- sound/soc/au1x/Kconfig | 28 + sound/soc/au1x/Makefile | 10 + sound/soc/au1x/ac97c.c | 398 ++++++++++++++ sound/soc/au1x/db1000.c | 75 +++ sound/soc/au1x/dma.c | 470 +++++++++++++++++ sound/soc/au1x/i2sc.c | 353 +++++++++++++ sound/soc/au1x/psc.h | 31 +- 12 files changed, 1393 insertions(+), 775 deletions(-) delete mode 100644 sound/mips/au1x00.c create mode 100644 sound/soc/au1x/ac97c.c create mode 100644 sound/soc/au1x/db1000.c create mode 100644 sound/soc/au1x/dma.c create mode 100644 sound/soc/au1x/i2sc.c
Signature · 1 line
1.7.6
PATCH v2 1/2 ALSA: Alchemy AC97C/I2SC audio support
This patch adds ASoC support for the AC97 and I2S controllers on the old Au1000/Au1500/Au1100 chips and a universal machine driver for the Db1000/Db1500/Db1100 boards.
AC97 Tested on a Db1500. I2S untested since none of the boards actually have and I2S codec wired up.
---
V2: added untested I2S controller driver for completeness, removed the audio
defines from the au1000 header as well.
arch/mips/alchemy/devboards/db1x00/platform.c | 37 ++ arch/mips/include/asm/mach-au1x00/au1000.h | 61 ---- sound/soc/au1x/Kconfig | 28 ++ sound/soc/au1x/Makefile | 10 + sound/soc/au1x/ac97c.c | 398 +++++++++++++++++++++ sound/soc/au1x/db1000.c | 75 ++++ sound/soc/au1x/dma.c | 470 +++++++++++++++++++++++++ sound/soc/au1x/i2sc.c | 353 +++++++++++++++++++ sound/soc/au1x/psc.h | 31 ++- 9 files changed, 1393 insertions(+), 70 deletions(-) create mode 100644 sound/soc/au1x/ac97c.c create mode 100644 sound/soc/au1x/db1000.c create mode 100644 sound/soc/au1x/dma.c create mode 100644 sound/soc/au1x/i2sc.c
arch/mips/alchemy/devboards/db1x00/platform.c +37 -0
@@ -19,8 +19,11 @@*/ #include <linux/init.h> +#include <linux/interrupt.h> #include <linux/platform_device.h> +#include <asm/mach-au1x00/au1000.h> +#include <asm/mach-au1x00/au1000_dma.h> #include <asm/mach-au1x00/au1xxx.h> #include <asm/mach-db1x00/bcsr.h> #include "../platform.h"
@@ -85,6 +88,36 @@#endif #endif +static struct resource alchemy_ac97c_res[] = { + [0 ] = { + .start =AU1000_AC97_PHYS_ADDR , + .end =AU1000_AC97_PHYS_ADDR +0xfff , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =DMA_ID_AC97C_TX , + .end =DMA_ID_AC97C_TX , + .flags =IORESOURCE_DMA , + }, + [2 ] = { + .start =DMA_ID_AC97C_RX , + .end =DMA_ID_AC97C_RX , + .flags =IORESOURCE_DMA , + }, +}; + +static struct platform_device alchemy_ac97c_dev = { + .name ="alchemy-ac97c" , + .id =-1 , + .resource = alchemy_ac97c_res, + .num_resources =ARRAY_SIZE (alchemy_ac97c_res), +}; + +static struct platform_device db1x00_codec_dev = { + .name ="ac97-codec" , + .id =-1 , +}; +static int __init db1xxx_dev_init (void ) {#ifdef DB1XXX_HAS_PCMCIA
@@ -113,6 +146,10 @@ static int __init db1xxx_dev_init(void) 1);#endif db1x_register_norflash (BOARD_FLASH_SIZE ,BOARD_FLASH_WIDTH ,F_SWAPPED ); + +platform_device_register (&db1x00_codec_dev); +platform_device_register (&alchemy_ac97c_dev); +return 0 ; }device_initcall (db1xxx_dev_init);
arch/mips/include/asm/mach-au1x00/au1000.h +0 -61
73 lines not on this page · raw message
sound/soc/au1x/Kconfig +28 -0
@@ -18,10 +18,38 @@ config SND_SOC_AU1XPSC_AC97 select SND_AC97_CODEC select SND_SOC_AC97_BUS +## +## Au1000/1500/1100 DMA + AC97C/I2SC +## +config SND_SOC_AU1XAUDIO + tristate "SoC Audio for Au1000/Au1500/Au1100" + depends on MIPS_ALCHEMY + help + This is a driver set for the AC97 unit and the + old DMA controller as found on the Au1000/Au1500/Au1100 chips. + +config SND_SOC_AU1XAC97C + tristate + select AC97_BUS + select SND_AC97_CODEC + select SND_SOC_AC97_BUS + +config SND_SOC_AU1XI2SC + tristate + ## ## Boards ## +config SND_SOC_DB1000 + tristate "DB1000 Audio support" + depends on SND_SOC_AU1XAUDIO + select SND_SOC_AU1XAC97C + select SND_SOC_AC97_CODEC + help + Select this option to enable AC97 audio on the early DB1x00 series + of boards (DB1000/DB1500/DB1100). + config SND_SOC_DB1200 tristate "DB1200 AC97+I2S audio support" depends on SND_SOC_AU1XPSC
sound/soc/au1x/Makefile +10 -0
@@ -3,11 +3,21 @@ snd-soc-au1xpsc-dbdma-objs := dbdma2.o snd-soc-au1xpsc-i2s-objs := psc-i2s.o snd-soc-au1xpsc-ac97-objs := psc-ac97.o +# Au1000/1500/1100 Audio units +snd-soc-au1x-dma-objs := dma.o +snd-soc-au1x-ac97c-objs := ac97c.o +snd-soc-au1x-i2sc-objs := i2sc.o + obj-$(CONFIG_SND_SOC_AU1XPSC) += snd-soc-au1xpsc-dbdma.o obj-$(CONFIG_SND_SOC_AU1XPSC_I2S) += snd-soc-au1xpsc-i2s.o obj-$(CONFIG_SND_SOC_AU1XPSC_AC97) += snd-soc-au1xpsc-ac97.o +obj-$(CONFIG_SND_SOC_AU1XAUDIO) += snd-soc-au1x-dma.o +obj-$(CONFIG_SND_SOC_AU1XAC97C) += snd-soc-au1x-ac97c.o +obj-$(CONFIG_SND_SOC_AU1XI2SC) += snd-soc-au1x-i2sc.o # Boards +snd-soc-db1000-objs := db1000.o snd-soc-db1200-objs := db1200.o +obj-$(CONFIG_SND_SOC_DB1000) += snd-soc-db1000.o obj-$(CONFIG_SND_SOC_DB1200) += snd-soc-db1200.o
sound/soc/au1x/ac97c.c new file +398 -0
398 lines not on this page · raw message
sound/soc/au1x/db1000.c new file +75 -0
75 lines not on this page · raw message
sound/soc/au1x/dma.c new file +470 -0
470 lines not on this page · raw message
sound/soc/au1x/i2sc.c new file +353 -0
353 lines not on this page · raw message
sound/soc/au1x/psc.h +22 -9
@@ -1,7 +1,7 @@/* -* Au12x0/Au1550 PSC ALSA ASoC audio support. +* Alchemy ALSA ASoC audio support. * -* (c) 2007-2008 MSC Vertriebsges.m.b.H., +* (c) 2007-2011 MSC Vertriebsges.m.b.H., * Manuel Lauss <[email protected]> * * This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,26 @@#ifndef _AU1X_PCM_H#define _AU1X_PCM_H -/* DBDMA helpers */ +#define PCM_TX 0 +#define PCM_RX 1 + +#define SUBSTREAM_TYPE (substream) \ + ((substream)->stream == SNDRV_PCM_STREAM_PLAYBACK ? PCM_TX : PCM_RX) + + +/* AC97C/I2SC DMA helpers */ +extern struct platform_device *alchemy_pcm_add (struct platform_device *pdev, +int type); +extern void alchemy_pcm_destroy (struct platform_device *dmapd); + +/* Au1000 AC97C/I2SC DAI names. Required to get at correct DMA instance */ +#define AC97C_DAINAME "alchemy-ac97c" +#define I2SC_DAINAME "alchemy-i2sc" +#define AC97C_DMANAME "alchemy-pcm-ac97" +#define I2SC_DMANAME "alchemy-pcm-i2s" + + +/* PSC/DBDMA helpers */ extern struct platform_device *au1xpsc_pcm_add (struct platform_device *pdev);extern void au1xpsc_pcm_destroy (struct platform_device *dmapd);
@@ -30,12 +49,6 @@ struct au1xpsc_audio_data {struct platform_device *dmapd; }; -#define PCM_TX 0 -#define PCM_RX 1 - -#define SUBSTREAM_TYPE (substream) \ - ((substream)->stream == SNDRV_PCM_STREAM_PLAYBACK ? PCM_TX : PCM_RX) -/* easy access macros */ #define PSC_CTRL (x) ((unsigned long)((x)->mmio) + PSC_CTRL_OFFSET)#define PSC_SEL (x) ((unsigned long)((x)->mmio) + PSC_SEL_OFFSET)
Signature · 1 line
1.7.6
PATCH v2 2/2 ALSA: delete MIPS au1x00 driver
In reply to Manuel LaussSince there's now an ASOC replacement.
---
V2: no changes
sound/mips/Kconfig | 8 - sound/mips/Makefile | 2 - sound/mips/au1x00.c | 695 --------------------------------------------------- 3 files changed, 0 insertions(+), 705 deletions(-) delete mode 100644 sound/mips/au1x00.c
sound/mips/Kconfig +0 -8
@@ -22,13 +22,5 @@ config SND_SGI_HAL2 Sound support for the SGI Indy and Indigo2 Workstation. -config SND_AU1X00 - tristate "Au1x00 AC97 Port Driver" - depends on SOC_AU1000 || SOC_AU1100 || SOC_AU1500 - select SND_PCM - select SND_AC97_CODEC - help - ALSA Sound driver for the Au1x00's AC97 port. - endif # SND_MIPS
sound/mips/Makefile +0 -2
@@ -2,11 +2,9 @@ # Makefile for ALSA # -snd-au1x00-objs := au1x00.o snd-sgi-o2-objs := sgio2audio.o ad1843.o snd-sgi-hal2-objs := hal2.o # Toplevel Module Dependency -obj-$(CONFIG_SND_AU1X00) += snd-au1x00.o obj-$(CONFIG_SND_SGI_O2) += snd-sgi-o2.o obj-$(CONFIG_SND_SGI_HAL2) += snd-sgi-hal2.o
sound/mips/au1x00.c deleted +0 -695
695 lines not on this page · raw message
Signature · 1 line
1.7.6
At Thu, 21 Jul 2011 18:34:08 +0200,
Quoted 6 lines · Manuel Lauss
Hello,
These 2 patches implement ASoC drivers for the AC97 and I2S controllers found on early Alchemy chips. They are largely based on the old
mips/au1x00.cdriver which they replace.
In general, dropping an old driver happens a bit later after the new driver comes in. You can make the old one as deprecated at first.
thanks,
Takashi
Quoted 11 lines · Takashi Iwai
At Thu, 21 Jul 2011 18:34:08 +0200,
Quoted 6 lines · Manuel Lauss
Hello,
These 2 patches implement ASoC drivers for the AC97 and I2S controllers found on early Alchemy chips. They are largely based on the old
mips/au1x00.cdriver which they replace.In general, dropping an old driver happens a bit later after the new driver comes in. You can make the old one as deprecated at first.
Makes sense, just ignore patch 2 then ;)
Thanks,
Manuel Lauss
Re: [PATCH V2 1/2] ALSA: Alchemy AC97C/I2SC audio support
In reply to Manuel LaussYou should always Cc Mark and Liam on ASoC patch. Also the proper commit title prefix is ASoC.
Quoted 12 lines · Manuel Lauss
This patch adds ASoC support for the AC97 and I2S controllers on the old Au1000/Au1500/Au1100 chips and a universal machine driver for the Db1000/Db1500/Db1100 boards.
AC97 Tested on a Db1500. I2S untested since none of the boards actually have and I2S codec wired up.
Signed-off-by Manuel Lauss <[email protected]>---
V2: added untested I2S controller driver for completeness, removed the audio
defines from the au1000 header as well.
Quoted 14 lines
arch/mips/alchemy/devboards/db1x00/platform.c | 37 ++ arch/mips/include/asm/mach-au1x00/au1000.h | 61 ---- sound/soc/au1x/Kconfig | 28 ++ sound/soc/au1x/Makefile | 10 + sound/soc/au1x/ac97c.c | 398 +++++++++++++++++++++ sound/soc/au1x/db1000.c | 75 ++++ sound/soc/au1x/dma.c | 470 +++++++++++++++++++++++++ sound/soc/au1x/i2sc.c | 353 +++++++++++++++++++ sound/soc/au1x/psc.h | 31 ++- 9 files changed, 1393 insertions(+), 70 deletions(-) create mode 100644 sound/soc/au1x/ac97c.c create mode 100644 sound/soc/au1x/db1000.c create mode 100644 sound/soc/au1x/dma.c create mode 100644 sound/soc/au1x/i2sc.c
It might make sense to split this into multiple patches. Especially the platform part should be put in a seperate patch, since there isn't really any compile time dependency to the other parts it could go via the MIPS tree.
Quoted 24 lines
sound/soc/au1x/ac97c.c new file +18
-0@@ -0,0 +1,398 @@ +/* +* Au1000/Au1500/Au1100 AC97C controller driver for ASoC +* +* (c) 2011 Manuel Lauss <[email protected]> +* +* based on the old ALSA driver by Charles Eidsness. +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/device.h> +#include <linux/delay.h> +#include <linux/mutex.h> +#include <linux/platform_device.h> +#include <linux/suspend.h> +#include <sound/core.h> +#include <sound/pcm.h>
sound/soc/au1x/ac97c.c line 28
Quoted 10 lines
sound/soc/au1x/ac97c.c new file +10
-0+#include <sound/initval.h> +#include <sound/soc.h> +#include <asm/mach-au1x00/au1000.h> +#include <asm/mach-au1x00/au1xxx_psc.h> + +#include "psc.h" + +/*#define AC_DEBUG*/ + +#define MSG(x...) printk(KERN_ERR "ac97c: " x)
dev_err or pr_err
sound/soc/au1x/ac97c.c line 33
Quoted 5 lines
sound/soc/au1x/ac97c.c new file +5
-0+#ifdef AC_DEBUG +#define DBG(x...) MSG(x) +#else +#define DBG(x...) do {} while (0) +#endif
dev_dbg or pr_dbg
sound/soc/au1x/ac97c.c line 69
Quoted 7 lines
[...]
sound/soc/au1x/ac97c.c new file +6
-0+ +/* how often to retry failed codec register reads/writes */ +#define AC97_RW_RETRIES 5 + +#define AC97_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE)
Unused
Quoted 5 lines
[...]
sound/soc/au1x/ac97c.c new file +4
-0+ +static int au1xac97c_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *dai)
sound/soc/au1x/ac97c.c line 234
Quoted 10 lines
sound/soc/au1x/ac97c.c new file +10
-0+{ +return 0 ; +} + +static int au1xac97c_trigger (struct snd_pcm_substream *substream, +int cmd,struct snd_soc_dai *dai) +{ +return 0 ; +} +
If you don't want to do anything in the callbacks just leave them out.
sound/soc/au1x/ac97c.c line 240
Quoted 6 lines
sound/soc/au1x/ac97c.c new file +6
-0+static int au1xac97c_dai_probe (struct snd_soc_dai *dai) +{ +return ac97c_workdata ?0 : -ENODEV ; +} + +static struct snd_soc_dai_ops au1xac97c_dai_ops = {
const
Quoted 8 lines
sound/soc/au1x/ac97c.c new file +4
-0+ .trigger = au1xac97c_trigger, + .hw_params = au1xac97c_hw_params, +}; +sound/soc/au1x/db1000.c new file +0
-0
sound/soc/au1x/db1000.c line 50
Quoted 10 lines
sound/soc/au1x/db1000.c new file +9
-0+static int __init db1000_audio_load (void ) +{ +int ret, id; + +/* impostor check */ + id =BCSR_WHOAMI_BOARD (bcsr_read (BCSR_WHOAMI )); + + ret = -ENOMEM ; + db1000_asoc97_dev =platform_device_alloc ("soc-audio" ,0 );
New drivers shouldn't user soc-audio anymore, just register a normal platform device driver.
Quoted 40 lines
sound/soc/au1x/db1000.c new file +25
-0+if (!db1000_asoc97_dev) + goto out; + +platform_set_drvdata (db1000_asoc97_dev, &db1000_ac97_machine); + ret =platform_device_add (db1000_asoc97_dev); + +if (ret) { +platform_device_put (db1000_asoc97_dev); + db1000_asoc97_dev =NULL ; + } +out: +return ret; +} + +static void __exit db1000_audio_unload(void) +{ +platform_device_unregister (db1000_asoc97_dev); +} + +module_init (db1000_audio_load); +module_exit (db1000_audio_unload); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("DB1000/DB1500/DB1100 ASoC audio support" ); +MODULE_AUTHOR ("Manuel Lauss" );sound/soc/au1x/dma.c new file +8
-0@@ -0,0 +1,470 @@ + +static struct platform_driver alchemy_ac97pcm_driver = { + .driver = { + .name =AC97C_DMANAME , + .owner =THIS_MODULE , + }, + .probe = alchemy_pcm_drvprobe, + .remove =__devexit_p (alchemy_pcm_drvremove),
sound/soc/au1x/dma.c line 397
Quoted 10 lines
sound/soc/au1x/dma.c new file +10
-0+}; + +static struct platform_driver alchemy_i2spcm_driver = { + .driver = { + .name =I2SC_DMANAME , + .owner =THIS_MODULE , + }, + .probe = alchemy_pcm_drvprobe, + .remove =__devexit_p (alchemy_pcm_drvremove), +};
You shouldn't really have to register two identical drivers for this. If you really want to be able to instantiate the driver with two different names use platform_device_id. But in my opinion it should be enough to just have one generic name, since there is nothing AC97 or I2S specific in this driver.
sound/soc/au1x/dma.c line 416
Quoted 4 lines
[...]
sound/soc/au1x/dma.c new file +3
-0+ +struct platform_device *alchemy_pcm_add (struct platform_device *pdev,int type) +{
+ struct resource *res, *r;
+ struct platform_device *pd;
+ char *pdevname;
+ int id[2];
+ int ret;
+
+ r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
+ if (!r)
+ return NULL;
+ id[0] = r->start;
+
+ r = platform_get_resource(pdev, IORESOURCE_DMA, 1);
+ if (!r)
+ return NULL;
+ id[1] = r->start;
+
+ res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+ if (!res)
+ return NULL;
+
+ res[0].start = res[0].end = id[0];
+ res[1].start = res[1].end = id[1];
+ res[0].flags = res[1].flags = IORESOURCE_DMA;
+
+ /* "alchemy-pcm-ac97" or "alchemy-pcm-i2s" */
+ pdevname = (type == 0) ? AC97C_DMANAME : I2SC_DMANAME;
+ pd = platform_device_alloc(pdevname, -1);
+ if (!pd)
+ goto out;
+
+ pd->resource = res;
+ pd->num_resources = 2;
+
+ ret = platform_device_add(pd);
+ if (!ret)
+ return pd;
+
+ platform_device_put(pd);
+out:
+ kfree(res);
+ return NULL;
Quoted 1 line
+}
This function looks a bit fishy. The pcm driver should be registered by the platform code file as well. If you need different DMA regions for I2C and AC97 use snd_soc_dai_set_dma_data and snd_soc_dai_get_dma_data to pass them to the PCM driver from the I2S or AC97 driver.
sound/soc/au1x/i2sc.c line 56
Quoted 13 lines
[...]
sound/soc/au1x/i2sc.c new file +5
-0@@ -0,0 +1,353 @@ + +/* supported I2S DAI hardware formats */ +#define AU1XI2SC_DAIFMT \ + (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J | \ + SND_SOC_DAIFMT_NB_NF)
Unused
sound/soc/au1x/i2sc.c line 60
Quoted 4 lines
sound/soc/au1x/i2sc.c new file +4
-0+ +/* supported I2S direction */ +#define AU1XI2SC_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE)
Unused
Quoted 14 lines
sound/soc/au1x/i2sc.c new file +13
-0+ +#define AU1XI2SC_RATES \ + SNDRV_PCM_RATE_8000_192000 + +#define AU1XI2SC_FMTS \ + SNDRV_PCM_FMTBIT_S16_LE + +struct i2sc_ctx { +void __iomem *mmio; +unsigned long cfg, rate; +struct platform_device *dmapd; +}; +
sound/soc/au1x/i2sc.c line 184
Quoted 10 lines
sound/soc/au1x/i2sc.c new file +10
-0+ +static int au1xi2s_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *dai) +{ +struct i2sc_ctx *ctx =snd_soc_dai_get_drvdata (dai); +unsigned long stat, v; + + v =msbits_to_reg (params->msbits); +/* check if the PSC is already streaming data */
Use .symmetric_rates = 1 in your dai_driver struct for this.
Quoted 10 lines
sound/soc/au1x/i2sc.c new file +10
-0+ stat =RD (ctx,I2S_CONFIG ); +if (stat & (CFG_TN |CFG_RN )) { +/* reject parameters not currently set up in hardware */ +if ((ctx->rate !=params_rate (params)) || + ((stat &CFG_SZ_MASK ) != v)) +return -EINVAL ; + }else { +/* set sample bitdepth */ + ctx->cfg &= ~CFG_SZ_MASK ; +if (v)
sound/soc/au1x/i2sc.c line 204
Quoted 10 lines
sound/soc/au1x/i2sc.c new file +10
-0+ ctx->cfg |= v; + else + return -EINVAL; +/* remember current rate for other stream */ + ctx->rate =params_rate (params); + } +return 0 ; +} + +static struct snd_soc_dai_ops au1xi2s_dai_ops = {
const
Quoted 6 lines
sound/soc/au1x/i2sc.c new file +5
-0+ .trigger = au1xi2s_trigger, + .hw_params = au1xi2s_hw_params, + .set_fmt = au1xi2s_set_fmt, +}; +
Re: [PATCH V2 1/2] ALSA: Alchemy AC97C/I2SC audio support
Quoted 6 lines · Lars-Peter Clausen
sound/soc/au1x/db1000.c line 50
Quoted 3 lines
sound/soc/au1x/db1000.c +2
-0+ ret = -ENOMEM; + db1000_asoc97_dev = platform_device_alloc("soc-audio", 0);New drivers shouldn't user soc-audio anymore, just register a normal platform device driver.
Can you point to an example of the new way?
Quoted 22 lines
Quoted 22 lines
sound/soc/au1x/dma.c new file +15
-0@@ -0,0 +1,470 @@ + +static struct platform_driver alchemy_ac97pcm_driver = { + .driver = { + .name = AC97C_DMANAME, + .owner = THIS_MODULE, + }, + .probe = alchemy_pcm_drvprobe, + .remove = __devexit_p(alchemy_pcm_drvremove), +}; + +static struct platform_driver alchemy_i2spcm_driver = { + .driver = { + .name = I2SC_DMANAME, + .owner = THIS_MODULE, + },
Quoted 8 lines
Quoted 3 lines
+ .probe =
alchemy_pcm_drvprobe,
+ .remove =__devexit_p(alchemy_pcm_drvremove), +};You shouldn't really have to register two identical drivers for this. If you really want to be able to instantiate the driver with two different names use
platform_device_id. But in my opinion it should be enough to just have one generic name, since there is nothing AC97 or I2S specific in this driver.
I need a unique name for the DMA device in soc_dai_link. This was the easiest way. Especially since both ac97 and i2s can be active at runtime.
Quoted 47 lines
sound/soc/au1x/dma.c line 416
Quoted 4 lines
[...]
sound/soc/au1x/dma.c new file +3
-0+ +struct platform_device *alchemy_pcm_add (struct platform_device *pdev,int type) +{+ struct resource *res, *r;
+ structplatform_device*pd;
+ char *pdevname;
+ int id[2];
+ int ret;sound/soc/au1x/dma.c new file +36
-0+ + r = platform_get_resource(pdev, IORESOURCE_DMA, 0); + if (!r) + return NULL; + id[0] = r->start; + + r = platform_get_resource(pdev, IORESOURCE_DMA, 1); + if (!r) + return NULL; + id[1] = r->start; + + res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); + if (!res) + return NULL; + + res[0].start = res[0].end = id[0]; + res[1].start = res[1].end = id[1]; + res[0].flags = res[1].flags = IORESOURCE_DMA; + + /* "alchemy-pcm-ac97" or "alchemy-pcm-i2s" */ + pdevname = (type == 0) ? AC97C_DMANAME : I2SC_DMANAME; + pd = platform_device_alloc(pdevname, -1); + if (!pd) + goto out; + + pd->resource = res; + pd->num_resources = 2; + + ret = platform_device_add(pd); + if (!ret) + return pd; + + platform_device_put(pd); +out: + kfree(res); + return NULL;Quoted 1 line
+}
Quoted 4 lines
This function looks a bit fishy. The pcm driver should be registered by the platform code file as well. If you need different DMA regions for I2C and AC97 use
snd_soc_dai_set_dma_dataandsnd_soc_dai_get_dma_datato pass them to the PCM driver from the I2S or AC97 driver.
I like to pass the DMA id's along with the ac97/i2s resource information (since they
belong together anyway). As an added benefit I get a sensibly named dma device with the correct DMA information, all by simply registering the ac97 platform device.
I'll think about a way to change it.
Thank you!
Manuel Lauss
Re: [PATCH V2 1/2] ALSA: Alchemy AC97C/I2SC audio support
Quoted 10 lines · Manuel Lauss
Quoted 6 lines · Lars-Peter Clausen
sound/soc/au1x/db1000.c line 50
Quoted 3 lines
sound/soc/au1x/db1000.c +2
-0+ ret = -ENOMEM ; + db1000_asoc97_dev =platform_device_alloc ("soc-audio" ,0 );New drivers shouldn't user soc-audio anymore, just register a normal platform device driver.
Can you point to an example of the new way?
sound/soc/samsung/speyside.c
Quoted 32 lines
Quoted 23 lines
Quoted 23 lines
sound/soc/au1x/dma.c new file +15
-0@@ -0,0 +1,470 @@ + +static struct platform_driver alchemy_ac97pcm_driver = { + .driver = { + .name =AC97C_DMANAME , + .owner =THIS_MODULE , + }, + .probe = alchemy_pcm_drvprobe, + .remove =__devexit_p (alchemy_pcm_drvremove), +}; + +static struct platform_driver alchemy_i2spcm_driver = { + .driver = { + .name =I2SC_DMANAME , + .owner =THIS_MODULE , + },Quoted 8 lines
sound/soc/au1x/dma.c line 388
Quoted 3 lines
sound/soc/au1x/dma.c new file +3
-0+ .probe = alchemy_pcm_drvprobe, + .remove = __devexit_p(alchemy_pcm_drvremove), +};You shouldn't really have to register two identical drivers for this. If you really want to be able to instantiate the driver with two different names use
platform_device_id. But in my opinion it should be enough to just have one generic name, since there is nothing AC97 or I2S specific in this driver.
Quoted 3 lines
I need a unique name for the DMA device in
soc_dai_link. This was the easiest way. Especially since both ac97 and i2s can be active at runtime.
If you want to instantiate two pcm drivers you can just give the devices different ids. As there is nothing I2C or AC97 specific in the pcm driver it should not matter which one is used for what, if two devices are active at the same time.
Right now you need to know which one is which, because you instantiate the driver with either the I2C or AC97 DMA addresses, but if you use snd_soc_dai_get_dma_data as described below and pass the DMA address at runtime this issue will go away.
Quoted 54 lines
Quoted 49 lines
Quoted 6 lines
[...]
sound/soc/au1x/dma.c new file +3
-0+ +struct platform_device *alchemy_pcm_add (struct platform_device *pdev,int type) +{sound/soc/au1x/dma.c new file +41
-0+struct resource *res, *r; +struct platform_device *pd; +char *pdevname; +int id[2 ]; +int ret; + + r =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); +if (!r) +return NULL ; + id[0 ] = r->start; + + r =platform_get_resource (pdev,IORESOURCE_DMA ,1 ); +if (!r) +return NULL ; + id[1 ] = r->start; + + res =kzalloc (sizeof (struct resource ) *2 ,GFP_KERNEL ); +if (!res) +return NULL ; + + res[0 ].start = res[0 ].end = id[0 ]; + res[1 ].start = res[1 ].end = id[1 ]; + res[0 ].flags = res[1 ].flags =IORESOURCE_DMA ; + +/* "alchemy-pcm-ac97" or "alchemy-pcm-i2s" */ + pdevname = (type ==0 ) ?AC97C_DMANAME :I2SC_DMANAME ; + pd =platform_device_alloc (pdevname,-1 ); +if (!pd) + goto out; + + pd->resource = res; + pd->num_resources =2 ; + + ret =platform_device_add (pd); +if (!ret) +return pd; + +platform_device_put (pd); +out: +kfree (res); +return NULL ;Quoted 1 line
+}
Quoted 4 lines
This function looks a bit fishy. The pcm driver should be registered by the platform code file as well. If you need different DMA regions for I2C and AC97 use
snd_soc_dai_set_dma_dataandsnd_soc_dai_get_dma_datato pass them to the PCM driver from the I2S or AC97 driver.
Quoted 5 lines
I like to pass the DMA id's along with the ac97/i2s resource information (since they
belong together anyway). As an added benefit I get a sensibly named dma device with the correct DMA information, all by simply registering the ac97 platform device.
There is nothing wrong with passing the DMA ids along with the other AC97/I2C resources. At least for the AC97 and I2C driver. But the PCM driver should use snd_soc_dai_get_dma_data to get the DMA addresses at runtime rather then during device instantiation. Take a look at how other platforms handle this.
- Lars
Re: [PATCH V2 1/2] ALSA: Alchemy AC97C/I2SC audio support
Quoted 9 lines · Lars-Peter Clausen
Quoted 8 lines · Manuel Lauss
Quoted 6 lines · Lars-Peter Clausen
sound/soc/au1x/db1000.c line 50
Quoted 3 lines
sound/soc/au1x/db1000.c +2
-0+ ret = -ENOMEM; + db1000_asoc97_dev = platform_device_alloc("soc-audio", 0);New drivers shouldn't user soc-audio anymore, just register a normal platform device driver.
Quoted 4 lines
Quoted 2 lines
Can you point to an example of the new way?
sound/soc/samsung/speyside.c
Thanks,
Quoted 35 lines
Quoted 31 lines
Quoted 22 lines
Quoted 22 lines
sound/soc/au1x/dma.c new file +15
-0@@ -0,0 +1,470 @@ + +static struct platform_driver alchemy_ac97pcm_driver = { + .driver = { + .name = AC97C_DMANAME, + .owner = THIS_MODULE, + }, + .probe = alchemy_pcm_drvprobe, + .remove = __devexit_p(alchemy_pcm_drvremove), +}; + +static struct platform_driver alchemy_i2spcm_driver = { + .driver = { + .name = I2SC_DMANAME, + .owner = THIS_MODULE, + },Quoted 8 lines
Quoted 3 lines
+ .probe =
alchemy_pcm_drvprobe,
+ .remove =__devexit_p(alchemy_pcm_drvremove), +};You shouldn't really have to register two identical drivers for this. If you really want to be able to instantiate the driver with two different names use
platform_device_id. But in my opinion it should be enough to just have one generic name, since there is nothing AC97 or I2S specific in this driver.Quoted 3 lines
I need a unique name for the DMA device in
soc_dai_link. This was the easiest way. Especially since both ac97 and i2s can be active at runtime.
Quoted 8 lines
If you want to instantiate two pcm drivers you can just give the devices different ids. As there is nothing I2C or AC97 specific in the pcm driver it should not matter which one is used for what, if two devices are active at the same time.
Right now you need to know which one is which, because you instantiate the driver with either the I2C or AC97 DMA addresses, but if you usesnd_soc_dai_get_dma_dataas described below and pass the DMA address at runtime this issue will go away.
so instead of "alchemy-pcm-{ac97|i2s}" i'd have "alchemy-pcm.[01]". Not really much clearer in my book. And I still need to know the correct suffix for dai link.
Or am I missing something fundamentally?
Quoted 58 lines
Quoted 52 lines
Quoted 47 lines
sound/soc/au1x/dma.c line 416
Quoted 4 lines
[...]
sound/soc/au1x/dma.c new file +3
-0+ +struct platform_device *alchemy_pcm_add (struct platform_device *pdev,int type) +{+ struct resource *res, *r;
+ structplatform_device*pd;
+ char *pdevname;
+ int id[2];
+ int ret;sound/soc/au1x/dma.c new file +36
-0+ + r = platform_get_resource(pdev, IORESOURCE_DMA, 0); + if (!r) + return NULL; + id[0] = r->start; + + r = platform_get_resource(pdev, IORESOURCE_DMA, 1); + if (!r) + return NULL; + id[1] = r->start; + + res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); + if (!res) + return NULL; + + res[0].start = res[0].end = id[0]; + res[1].start = res[1].end = id[1]; + res[0].flags = res[1].flags = IORESOURCE_DMA; + + /* "alchemy-pcm-ac97" or "alchemy-pcm-i2s" */ + pdevname = (type == 0) ? AC97C_DMANAME : I2SC_DMANAME; + pd = platform_device_alloc(pdevname, -1); + if (!pd) + goto out; + + pd->resource = res; + pd->num_resources = 2; + + ret = platform_device_add(pd); + if (!ret) + return pd; + + platform_device_put(pd); +out: + kfree(res); + return NULL;Quoted 1 line
+}
Quoted 4 lines
This function looks a bit fishy. The pcm driver should be registered by the platform code file as well. If you need different DMA regions for I2C and AC97 use
snd_soc_dai_set_dma_dataandsnd_soc_dai_get_dma_datato pass them to the PCM driver from the I2S or AC97 driver.Quoted 5 lines
I like to pass the DMA id's along with the ac97/i2s resource information (since they
belong together anyway). As an added benefit I get a sensibly named dma device with the correct DMA information, all by simply registering the ac97 platform device.
Quoted 4 lines
There is nothing wrong with passing the DMA ids along with the other AC97/I2C resources. At least for the AC97 and I2C driver. But the PCM driver should use
snd_soc_dai_get_dma_datato get the DMA addresses at runtime rather then during device instantiation. Take a look at how other platforms handle this.
The ac97/i2s units know they need dma and therefore register the device themselves.
Having the board code register an "empty" dma device along with the ac97/i2s devices
seems like a waste of code and a source of potential bugs. I'll change my code.
Thank you!
Manuel Lauss
Re: [PATCH V2 1/2] ALSA: Alchemy AC97C/I2SC audio support
Quoted 47 lines · Manuel Lauss
Quoted 37 lines · Lars-Peter Clausen
Quoted 32 lines · Manuel Lauss
Quoted 22 lines · Lars-Peter Clausen
Quoted 22 lines
sound/soc/au1x/dma.c new file +15
-0@@ -0,0 +1,470 @@ + +static struct platform_driver alchemy_ac97pcm_driver = { + .driver = { + .name =AC97C_DMANAME , + .owner =THIS_MODULE , + }, + .probe = alchemy_pcm_drvprobe, + .remove =__devexit_p (alchemy_pcm_drvremove), +}; + +static struct platform_driver alchemy_i2spcm_driver = { + .driver = { + .name =I2SC_DMANAME , + .owner =THIS_MODULE , + },Quoted 8 lines
sound/soc/au1x/dma.c line 388
Quoted 3 lines
sound/soc/au1x/dma.c new file +3
-0+ .probe = alchemy_pcm_drvprobe, + .remove = __devexit_p(alchemy_pcm_drvremove), +};You shouldn't really have to register two identical drivers for this. If you really want to be able to instantiate the driver with two different names use
platform_device_id. But in my opinion it should be enough to just have one generic name, since there is nothing AC97 or I2S specific in this driver.Quoted 3 lines
I need a unique name for the DMA device in
soc_dai_link. This was the easiest way. Especially since both ac97 and i2s can be active at runtime.Quoted 8 lines
If you want to instantiate two pcm drivers you can just give the devices different ids. As there is nothing I2C or AC97 specific in the pcm driver it should not matter which one is used for what, if two devices are active at the same time.
Right now you need to know which one is which, because you instantiate the driver with either the I2C or AC97 DMA addresses, but if you usesnd_soc_dai_get_dma_dataas described below and pass the DMA address at runtime this issue will go away.
Quoted 4 lines
so instead of "alchemy-pcm-{ac97|i2s}" i'd have "alchemy-pcm.[01]". Not really much clearer in my book. And I still need to know the correct suffix for dai link.
Since there is nothing I2S or AC97 specific in the PCM driver it doesn't really make much sense to put it in the pcm driver name in my opinion.
I would suspect that the common case is, that an board use either AC97 or I2S audio, but not both. So in this case you'd always just have alchemy-pcm.0 in your dai link regardless of whether the board uses AC97 or I2S.
Quoted 65 lines
Quoted 59 lines
Quoted 53 lines
Quoted 48 lines
Quoted 5 lines
[...]
sound/soc/au1x/dma.c new file +3
-0+ +struct platform_device *alchemy_pcm_add (struct platform_device *pdev,int type) +{sound/soc/au1x/dma.c new file +41
-0+struct resource *res, *r; +struct platform_device *pd; +char *pdevname; +int id[2 ]; +int ret; + + r =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); +if (!r) +return NULL ; + id[0 ] = r->start; + + r =platform_get_resource (pdev,IORESOURCE_DMA ,1 ); +if (!r) +return NULL ; + id[1 ] = r->start; + + res =kzalloc (sizeof (struct resource ) *2 ,GFP_KERNEL ); +if (!res) +return NULL ; + + res[0 ].start = res[0 ].end = id[0 ]; + res[1 ].start = res[1 ].end = id[1 ]; + res[0 ].flags = res[1 ].flags =IORESOURCE_DMA ; + +/* "alchemy-pcm-ac97" or "alchemy-pcm-i2s" */ + pdevname = (type ==0 ) ?AC97C_DMANAME :I2SC_DMANAME ; + pd =platform_device_alloc (pdevname,-1 ); +if (!pd) + goto out; + + pd->resource = res; + pd->num_resources =2 ; + + ret =platform_device_add (pd); +if (!ret) +return pd; + +platform_device_put (pd); +out: +kfree (res); +return NULL ;Quoted 1 line
+}
Quoted 4 lines
This function looks a bit fishy. The pcm driver should be registered by the platform code file as well. If you need different DMA regions for I2C and AC97 use
snd_soc_dai_set_dma_dataandsnd_soc_dai_get_dma_datato pass them to the PCM driver from the I2S or AC97 driver.Quoted 5 lines
I like to pass the DMA id's along with the ac97/i2s resource information (since they
belong together anyway). As an added benefit I get a sensibly named dma device with the correct DMA information, all by simply registering the ac97 platform device.Quoted 4 lines
There is nothing wrong with passing the DMA ids along with the other AC97/I2C resources. At least for the AC97 and I2C driver. But the PCM driver should use
snd_soc_dai_get_dma_datato get the DMA addresses at runtime rather then during device instantiation. Take a look at how other platforms handle this.
Quoted 5 lines
The ac97/i2s units know they need dma and therefore register the device themselves.
Having the board code register an "empty" dma device along with the ac97/i2s devices
seems like a waste of code and a source of potential bugs. I'll change my code.
If you are worried somebody might forget to register the pcm device when registering the ac97/i2s device provide a helper function which registers both.
- Lars