ASoC pxa2xx AC97 support
PATCH 3/8 ASoC pxa2xx AC97 support
This patch adds pxa2xx AC97 ASoC audio support. It's based on sound/arm/pxa-ac97 by Nicolas Pitre with the following differences.
o Modified driver structure to use ASoC core PCM callbacks.
o Removed AC97 configuration function (all handled in ASoC core)
o Added and exported ASoC DAI configuration table.
o Added DMA support for AUX DAC and Mic ADC
o Separated out AC97 reset into cold and warm reset functions.
soc/pxa/pxa2xx-ac97.c new file +434 -0
@@ -0,0 +1,434 @@ +/* +* linux/sound/pxa2xx-ac97.c -- AC97 support for the Intel PXA2xx chip. +* +* Author: Nicolas Pitre +* Created: Dec 02, 2004 +* Copyright: MontaVista Software Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/interrupt.h> +#include <linux/wait.h> +#include <linux/delay.h> + +#include <sound/driver.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/ac97_codec.h> +#include <sound/initval.h> +#include <sound/soc.h> + +#include <asm/irq.h> +#include <linux/mutex.h> +#include <asm/hardware.h> +#include <asm/arch/pxa-regs.h> +#include <asm/arch/audio.h> + +#include "pxa2xx-pcm.h" + +static DEFINE_MUTEX (car_mutex); +static DECLARE_WAIT_QUEUE_HEAD (gsr_wq); +static volatile long gsr_bits; + +#define AC97_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +#define AC97_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) + +/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + {0 ,0 ,SNDRV_PCM_FMTBIT_S16_LE ,AC97_RATES }, +}; + +/* +* Beware PXA27x bugs: +* +* o Slot 12 read from modem space will hang controller. +* o CDONE, SDONE interrupt fails after any slot 12 IO. +* +* We therefore have an hybrid approach for waiting on SDONE (interrupt or +* 1 jiffy timeout if interrupt never comes). +*/ + +static unsigned short pxa2xx_ac97_read (struct snd_ac97 *ac97, +unsigned short reg) +{ +unsigned short val =-1 ; +volatile u32 *reg_addr; + +mutex_lock (&car_mutex); + +/* set up primary or secondary codec/modem space */ +#ifdef CONFIG_PXA27x + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#else +if (reg ==AC97_GPIO_STATUS ) + reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE ; +else + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#endif + reg_addr += (reg >>1 ); + +#ifndef CONFIG_PXA27x +if (reg ==AC97_GPIO_STATUS ) { +/* read from controller cache */ + val = *reg_addr; + goto out; + } +#endif + +/* start read access across the ac97 link */ +GSR =GSR_CDONE |GSR_SDONE ; + gsr_bits =0 ; + val = *reg_addr; + +wait_event_timeout (gsr_wq, (GSR | gsr_bits) &GSR_SDONE ,1 ); +if (!((GSR | gsr_bits) &GSR_SDONE )) { +printk (KERN_ERR "%s: read error (ac97_reg=%x GSR=%#lx)\n" , + __FUNCTION__, reg,GSR | gsr_bits); + val =-1 ; + goto out; + } + +/* valid data now */ +GSR =GSR_CDONE |GSR_SDONE ; + gsr_bits =0 ; + val = *reg_addr; +/* but we've just started another cycle... */ +wait_event_timeout (gsr_wq, (GSR | gsr_bits) &GSR_SDONE ,1 ); + +out:mutex_unlock (&car_mutex); +return val; +} + +static void pxa2xx_ac97_write (struct snd_ac97 *ac97,unsigned short reg, +unsigned short val) +{ +volatile u32 *reg_addr; + +mutex_lock (&car_mutex); + +/* set up primary or secondary codec/modem space */ +#ifdef CONFIG_PXA27x + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#else +if (reg ==AC97_GPIO_STATUS ) + reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE ; +else + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#endif + reg_addr += (reg >>1 ); + +GSR =GSR_CDONE |GSR_SDONE ; + gsr_bits =0 ; + *reg_addr = val; +wait_event_timeout (gsr_wq, (GSR | gsr_bits) &GSR_CDONE ,1 ); +if (!((GSR | gsr_bits) &GSR_CDONE )) +printk (KERN_ERR "%s: write error (ac97_reg=%x GSR=%#lx)\n" , + __FUNCTION__, reg,GSR | gsr_bits); + +mutex_unlock (&car_mutex); +} + +static void pxa2xx_ac97_warm_reset (struct snd_ac97 *ac97) +{ + gsr_bits =0 ; + +#ifdef CONFIG_PXA27x +/* warm reset broken on Bulverde, +so manually keep AC97 reset high */ +pxa_gpio_mode (113 |GPIO_OUT |GPIO_DFLT_HIGH ); +udelay (10 ); +GCR |=GCR_WARM_RST ; +pxa_gpio_mode (113 |GPIO_ALT_FN_2_OUT ); +udelay (500 ); +#else +GCR |=GCR_WARM_RST |GCR_PRIRDY_IEN |GCR_SECRDY_IEN ; +wait_event_timeout (gsr_wq, gsr_bits & (GSR_PCR |GSR_SCR ),1 ); +#endif + +if (!((GSR | gsr_bits) & (GSR_PCR |GSR_SCR ))) +printk (KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n" , + __FUNCTION__, gsr_bits); + +GCR &= ~(GCR_PRIRDY_IEN |GCR_SECRDY_IEN ); +GCR |=GCR_SDONE_IE |GCR_CDONE_IE ; +} + +static void pxa2xx_ac97_cold_reset (struct snd_ac97 *ac97) +{ +GCR &=GCR_COLD_RST ;/* clear everything but nCRST */ +GCR &= ~GCR_COLD_RST ;/* then assert nCRST */ + + gsr_bits =0 ; +#ifdef CONFIG_PXA27x +/* PXA27x Developers Manual section 13.5.2.2.1 */ +pxa_set_cken (1 <<31 ,1 ); +udelay (5 ); +pxa_set_cken (1 <<31 ,0 ); +GCR =GCR_COLD_RST ; +udelay (50 ); +#else +GCR =GCR_COLD_RST ; +GCR |=GCR_CDONE_IE |GCR_SDONE_IE ; +wait_event_timeout (gsr_wq, gsr_bits & (GSR_PCR |GSR_SCR ),1 ); +#endif + +if (!((GSR | gsr_bits) & (GSR_PCR |GSR_SCR ))) +printk (KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n" , + __FUNCTION__, gsr_bits); + +GCR &= ~(GCR_PRIRDY_IEN |GCR_SECRDY_IEN ); +GCR |=GCR_SDONE_IE |GCR_CDONE_IE ; +} + +static irqreturn_t pxa2xx_ac97_irq (int irq,void *dev_id, +struct pt_regs *regs) +{ +long status; + + status =GSR ; +if (status) { +GSR = status; + gsr_bits |= status; +wake_up (&gsr_wq); + +#ifdef CONFIG_PXA27x +/* Although we don't use those we still need to clear them +since they tend to spuriously trigger when MMC is used +(hardware bug? go figure)... */ +MISR =MISR_EOC ; +PISR =PISR_EOC ; +MCSR =MCSR_EOC ; +#endif + +return IRQ_HANDLED ; + } + +return IRQ_NONE ; +} + +struct snd_ac97_bus_ops soc_ac97_ops = { + .read = pxa2xx_ac97_read, + .write = pxa2xx_ac97_write, + .warm_reset = pxa2xx_ac97_warm_reset, + .reset = pxa2xx_ac97_cold_reset, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_out = { + .name ="AC97 PCM Stereo out" , + .dev_addr =__PREG (PCDR ), + .drcmr = &DRCMRTXPCDR , + .dcmd =DCMD_INCSRCADDR |DCMD_FLOWTRG | +DCMD_BURST32 |DCMD_WIDTH4 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_in = { + .name ="AC97 PCM Stereo in" , + .dev_addr =__PREG (PCDR ), + .drcmr = &DRCMRRXPCDR , + .dcmd =DCMD_INCTRGADDR |DCMD_FLOWSRC | +DCMD_BURST32 |DCMD_WIDTH4 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_out = { + .name ="AC97 Aux PCM (Slot 5) Mono out" , + .dev_addr =__PREG (MODR ), + .drcmr = &DRCMRTXMODR , + .dcmd =DCMD_INCSRCADDR |DCMD_FLOWTRG | +DCMD_BURST16 |DCMD_WIDTH2 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_in = { + .name ="AC97 Aux PCM (Slot 5) Mono in" , + .dev_addr =__PREG (MODR ), + .drcmr = &DRCMRRXMODR , + .dcmd =DCMD_INCTRGADDR |DCMD_FLOWSRC | +DCMD_BURST16 |DCMD_WIDTH2 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_mic_mono_in = { + .name ="AC97 Mic PCM (Slot 6) Mono in" , + .dev_addr =__PREG (MCDR ), + .drcmr = &DRCMRRXMCDR , + .dcmd =DCMD_INCTRGADDR |DCMD_FLOWSRC | +DCMD_BURST16 |DCMD_WIDTH2 , +}; + +#ifdef CONFIG_PM +static int pxa2xx_ac97_suspend (struct platform_device *pdev, +struct snd_soc_cpu_dai *dai) +{ +GCR |=GCR_ACLINK_OFF ; +pxa_set_cken (CKEN2_AC97 ,0 ); +return 0 ; +} + +static int pxa2xx_ac97_resume (struct platform_device *pdev, +struct snd_soc_cpu_dai *dai) +{ +pxa_gpio_mode (GPIO31_SYNC_AC97_MD ); +pxa_gpio_mode (GPIO30_SDATA_OUT_AC97_MD ); +pxa_gpio_mode (GPIO28_BITCLK_AC97_MD ); +pxa_gpio_mode (GPIO29_SDATA_IN_AC97_MD ); +#ifdef CONFIG_PXA27x +/* Use GPIO 113 as AC97 Reset on Bulverde */ +pxa_gpio_mode (113 |GPIO_ALT_FN_2_OUT ); +#endif +pxa_set_cken (CKEN2_AC97 ,1 ); +return 0 ; +} + +#else +#define pxa2xx_ac97_suspend NULL +#define pxa2xx_ac97_resume NULL +#endif + +static int pxa2xx_ac97_probe (struct platform_device *pdev) +{ +int ret; + + ret =request_irq (IRQ_AC97 , pxa2xx_ac97_irq,0 ,"AC97" ,NULL ); +if (ret <0 ) + goto err; + +pxa_gpio_mode (GPIO31_SYNC_AC97_MD ); +pxa_gpio_mode (GPIO30_SDATA_OUT_AC97_MD ); +pxa_gpio_mode (GPIO28_BITCLK_AC97_MD ); +pxa_gpio_mode (GPIO29_SDATA_IN_AC97_MD ); +#ifdef CONFIG_PXA27x +/* Use GPIO 113 as AC97 Reset on Bulverde */ +pxa_gpio_mode (113 |GPIO_ALT_FN_2_OUT ); +#endif +pxa_set_cken (CKEN2_AC97 ,1 ); +return 0 ; + + err: +if (CKEN &CKEN2_AC97 ) { +GCR |=GCR_ACLINK_OFF ; +free_irq (IRQ_AC97 ,NULL ); +pxa_set_cken (CKEN2_AC97 ,0 ); + } +return ret; +} + +static void pxa2xx_ac97_remove (struct platform_device *pdev) +{ +GCR |=GCR_ACLINK_OFF ; +free_irq (IRQ_AC97 ,NULL ); +pxa_set_cken (CKEN2_AC97 ,0 ); +} + +static int pxa2xx_ac97_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_out; +else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_in; + +return 0 ; +} + +static int pxa2xx_ac97_hw_aux_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_out; +else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_in; + +return 0 ; +} + +static int pxa2xx_ac97_hw_mic_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +return -ENODEV ; +else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_mic_mono_in; + +return 0 ; +} + +/* +* There is only 1 physical AC97 interface for pxa2xx, but it +* has extra fifo's that can be used for aux DACs and ADCs. +*/ +struct snd_soc_cpu_dai pxa_ac97_dai[] = { +{ + .name ="pxa2xx-ac97" , + .id =0 , + .type =SND_SOC_DAI_AC97 , + .probe = pxa2xx_ac97_probe, + .remove = pxa2xx_ac97_remove, + .suspend = pxa2xx_ac97_suspend, + .resume = pxa2xx_ac97_resume, + .playback = { + .stream_name ="AC97 Playback" , + .channels_min =2 , + .channels_max =2 ,}, + .capture = { + .stream_name ="AC97 Capture" , + .channels_min =2 , + .channels_max =2 ,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_params,}, + .caps = { + .num_modes =ARRAY_SIZE (pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,}, +}, +{ + .name ="pxa2xx-ac97-aux" , + .id =1 , + .type =SND_SOC_DAI_AC97 , + .playback = { + .stream_name ="AC97 Aux Playback" , + .channels_min =1 , + .channels_max =1 ,}, + .capture = { + .stream_name ="AC97 Aux Capture" , + .channels_min =1 , + .channels_max =1 ,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_aux_params,}, + .caps = { + .num_modes =ARRAY_SIZE (pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,}, +}, +{ + .name ="pxa2xx-ac97-mic" , + .id =2 , + .type =SND_SOC_DAI_AC97 , + .capture = { + .stream_name ="AC97 Mic Capture" , + .channels_min =1 , + .channels_max =1 ,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_mic_params,}, + .caps = { + .num_modes =ARRAY_SIZE (pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,},}, +}; + +EXPORT_SYMBOL_GPL (pxa_ac97_dai); +EXPORT_SYMBOL_GPL (soc_ac97_ops); + +MODULE_AUTHOR ("Nicolas Pitre" ); +MODULE_DESCRIPTION ("AC97 driver for the Intel PXA2xx chip" ); +MODULE_LICENSE ("GPL" );
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
At Tue, 10 Oct 2006 17:19:36 +0100,
soc/pxa/pxa2xx-ac97.c line 48
Quoted 3 lines · Liam Girdwood
soc/pxa/pxa2xx-ac97.c new file +3
-0+/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + {0 ,0 ,SNDRV_PCM_FMTBIT_S16_LE ,AC97_RATES },
Better to use ".field = value" initialization.
soc/pxa/pxa2xx-ac97.c line 194
Quoted 2 lines
soc/pxa/pxa2xx-ac97.c new file +2
-0+static irqreturn_t pxa2xx_ac97_irq (int irq,void *dev_id, +struct pt_regs *regs)
Note that in the latest kernel code, the last struct pt_regs pointer is removed from irq handler. I already updated ALSA HG tree accordingly.
soc/pxa/pxa2xx-ac97.c line 299
Quoted 5 lines
soc/pxa/pxa2xx-ac97.c new file +5
-0+static int pxa2xx_ac97_probe (struct platform_device *pdev) +{ +int ret; + + ret =request_irq (IRQ_AC97 , pxa2xx_ac97_irq,0 ,"AC97" ,NULL );
Don't you need IRQF_DISABLED (former SA_INTERRUPT)?
Takashi
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 7 lines · Takashi Iwai
At Tue, 10 Oct 2006 17:19:36 +0100,
Review
Quoted 3 lines · Liam Girdwood
(quoted diff) +3
-0+/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + {0, 0, SNDRV_PCM_FMTBIT_S16_LE, AC97_RATES},Better to use ".field = value" initialization.
IMHO, this is a better style for the DAI capabilities field because it can grow quite large depending on the DAI.
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+static irqreturn_t pxa2xx_ac97_irq(int irq, void *dev_id, + struct pt_regs *regs)Note that in the latest kernel code, the last struct
pt_regspointer is removed from irq handler. I already updated ALSA HG tree accordingly.
Fixed.
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +5
-0+static int pxa2xx_ac97_probe(struct platform_device *pdev) +{ + int ret; + + ret = request_irq(IRQ_AC97, pxa2xx_ac97_irq, 0, "AC97", NULL);Don't you need
IRQF_DISABLED(formerSA_INTERRUPT)?
Fixed.
Thanks
Liam
soc/pxa/pxa2xx-ac97.c new file +433 -0
@@ -0,0 +1,433 @@ +/* +* linux/sound/pxa2xx-ac97.c -- AC97 support for the Intel PXA2xx chip. +* +* Author: Nicolas Pitre +* Created: Dec 02, 2004 +* Copyright: MontaVista Software Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/interrupt.h> +#include <linux/wait.h> +#include <linux/delay.h> + +#include <sound/driver.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/ac97_codec.h> +#include <sound/initval.h> +#include <sound/soc.h> + +#include <asm/irq.h> +#include <linux/mutex.h> +#include <asm/hardware.h> +#include <asm/arch/pxa-regs.h> +#include <asm/arch/audio.h> + +#include "pxa2xx-pcm.h" + +static DEFINE_MUTEX (car_mutex); +static DECLARE_WAIT_QUEUE_HEAD (gsr_wq); +static volatile long gsr_bits; + +#define AC97_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +#define AC97_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) + +/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + {0 ,0 ,SNDRV_PCM_FMTBIT_S16_LE ,AC97_RATES }, +}; + +/* +* Beware PXA27x bugs: +* +* o Slot 12 read from modem space will hang controller. +* o CDONE, SDONE interrupt fails after any slot 12 IO. +* +* We therefore have an hybrid approach for waiting on SDONE (interrupt or +* 1 jiffy timeout if interrupt never comes). +*/ + +static unsigned short pxa2xx_ac97_read (struct snd_ac97 *ac97, +unsigned short reg) +{ +unsigned short val =-1 ; +volatile u32 *reg_addr; + +mutex_lock (&car_mutex); + +/* set up primary or secondary codec/modem space */ +#ifdef CONFIG_PXA27x + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#else +if (reg ==AC97_GPIO_STATUS ) + reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE ; +else + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#endif + reg_addr += (reg >>1 ); + +#ifndef CONFIG_PXA27x +if (reg ==AC97_GPIO_STATUS ) { +/* read from controller cache */ + val = *reg_addr; + goto out; + } +#endif + +/* start read access across the ac97 link */ +GSR =GSR_CDONE |GSR_SDONE ; + gsr_bits =0 ; + val = *reg_addr; + +wait_event_timeout (gsr_wq, (GSR | gsr_bits) &GSR_SDONE ,1 ); +if (!((GSR | gsr_bits) &GSR_SDONE )) { +printk (KERN_ERR "%s: read error (ac97_reg=%x GSR=%#lx)\n" , + __FUNCTION__, reg,GSR | gsr_bits); + val =-1 ; + goto out; + } + +/* valid data now */ +GSR =GSR_CDONE |GSR_SDONE ; + gsr_bits =0 ; + val = *reg_addr; +/* but we've just started another cycle... */ +wait_event_timeout (gsr_wq, (GSR | gsr_bits) &GSR_SDONE ,1 ); + +out:mutex_unlock (&car_mutex); +return val; +} + +static void pxa2xx_ac97_write (struct snd_ac97 *ac97,unsigned short reg, +unsigned short val) +{ +volatile u32 *reg_addr; + +mutex_lock (&car_mutex); + +/* set up primary or secondary codec/modem space */ +#ifdef CONFIG_PXA27x + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#else +if (reg ==AC97_GPIO_STATUS ) + reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE ; +else + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#endif + reg_addr += (reg >>1 ); + +GSR =GSR_CDONE |GSR_SDONE ; + gsr_bits =0 ; + *reg_addr = val; +wait_event_timeout (gsr_wq, (GSR | gsr_bits) &GSR_CDONE ,1 ); +if (!((GSR | gsr_bits) &GSR_CDONE )) +printk (KERN_ERR "%s: write error (ac97_reg=%x GSR=%#lx)\n" , + __FUNCTION__, reg,GSR | gsr_bits); + +mutex_unlock (&car_mutex); +} + +static void pxa2xx_ac97_warm_reset (struct snd_ac97 *ac97) +{ + gsr_bits =0 ; + +#ifdef CONFIG_PXA27x +/* warm reset broken on Bulverde, +so manually keep AC97 reset high */ +pxa_gpio_mode (113 |GPIO_OUT |GPIO_DFLT_HIGH ); +udelay (10 ); +GCR |=GCR_WARM_RST ; +pxa_gpio_mode (113 |GPIO_ALT_FN_2_OUT ); +udelay (500 ); +#else +GCR |=GCR_WARM_RST |GCR_PRIRDY_IEN |GCR_SECRDY_IEN ; +wait_event_timeout (gsr_wq, gsr_bits & (GSR_PCR |GSR_SCR ),1 ); +#endif + +if (!((GSR | gsr_bits) & (GSR_PCR |GSR_SCR ))) +printk (KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n" , + __FUNCTION__, gsr_bits); + +GCR &= ~(GCR_PRIRDY_IEN |GCR_SECRDY_IEN ); +GCR |=GCR_SDONE_IE |GCR_CDONE_IE ; +} + +static void pxa2xx_ac97_cold_reset (struct snd_ac97 *ac97) +{ +GCR &=GCR_COLD_RST ;/* clear everything but nCRST */ +GCR &= ~GCR_COLD_RST ;/* then assert nCRST */ + + gsr_bits =0 ; +#ifdef CONFIG_PXA27x +/* PXA27x Developers Manual section 13.5.2.2.1 */ +pxa_set_cken (1 <<31 ,1 ); +udelay (5 ); +pxa_set_cken (1 <<31 ,0 ); +GCR =GCR_COLD_RST ; +udelay (50 ); +#else +GCR =GCR_COLD_RST ; +GCR |=GCR_CDONE_IE |GCR_SDONE_IE ; +wait_event_timeout (gsr_wq, gsr_bits & (GSR_PCR |GSR_SCR ),1 ); +#endif + +if (!((GSR | gsr_bits) & (GSR_PCR |GSR_SCR ))) +printk (KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n" , + __FUNCTION__, gsr_bits); + +GCR &= ~(GCR_PRIRDY_IEN |GCR_SECRDY_IEN ); +GCR |=GCR_SDONE_IE |GCR_CDONE_IE ; +} + +static irqreturn_t pxa2xx_ac97_irq (int irq,void *dev_id) +{ +long status; + + status =GSR ; +if (status) { +GSR = status; + gsr_bits |= status; +wake_up (&gsr_wq); + +#ifdef CONFIG_PXA27x +/* Although we don't use those we still need to clear them +since they tend to spuriously trigger when MMC is used +(hardware bug? go figure)... */ +MISR =MISR_EOC ; +PISR =PISR_EOC ; +MCSR =MCSR_EOC ; +#endif + +return IRQ_HANDLED ; + } + +return IRQ_NONE ; +} + +struct snd_ac97_bus_ops soc_ac97_ops = { + .read = pxa2xx_ac97_read, + .write = pxa2xx_ac97_write, + .warm_reset = pxa2xx_ac97_warm_reset, + .reset = pxa2xx_ac97_cold_reset, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_out = { + .name ="AC97 PCM Stereo out" , + .dev_addr =__PREG (PCDR ), + .drcmr = &DRCMRTXPCDR , + .dcmd =DCMD_INCSRCADDR |DCMD_FLOWTRG | +DCMD_BURST32 |DCMD_WIDTH4 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_in = { + .name ="AC97 PCM Stereo in" , + .dev_addr =__PREG (PCDR ), + .drcmr = &DRCMRRXPCDR , + .dcmd =DCMD_INCTRGADDR |DCMD_FLOWSRC | +DCMD_BURST32 |DCMD_WIDTH4 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_out = { + .name ="AC97 Aux PCM (Slot 5) Mono out" , + .dev_addr =__PREG (MODR ), + .drcmr = &DRCMRTXMODR , + .dcmd =DCMD_INCSRCADDR |DCMD_FLOWTRG | +DCMD_BURST16 |DCMD_WIDTH2 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_in = { + .name ="AC97 Aux PCM (Slot 5) Mono in" , + .dev_addr =__PREG (MODR ), + .drcmr = &DRCMRRXMODR , + .dcmd =DCMD_INCTRGADDR |DCMD_FLOWSRC | +DCMD_BURST16 |DCMD_WIDTH2 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_mic_mono_in = { + .name ="AC97 Mic PCM (Slot 6) Mono in" , + .dev_addr =__PREG (MCDR ), + .drcmr = &DRCMRRXMCDR , + .dcmd =DCMD_INCTRGADDR |DCMD_FLOWSRC | +DCMD_BURST16 |DCMD_WIDTH2 , +}; + +#ifdef CONFIG_PM +static int pxa2xx_ac97_suspend (struct platform_device *pdev, +struct snd_soc_cpu_dai *dai) +{ +GCR |=GCR_ACLINK_OFF ; +pxa_set_cken (CKEN2_AC97 ,0 ); +return 0 ; +} + +static int pxa2xx_ac97_resume (struct platform_device *pdev, +struct snd_soc_cpu_dai *dai) +{ +pxa_gpio_mode (GPIO31_SYNC_AC97_MD ); +pxa_gpio_mode (GPIO30_SDATA_OUT_AC97_MD ); +pxa_gpio_mode (GPIO28_BITCLK_AC97_MD ); +pxa_gpio_mode (GPIO29_SDATA_IN_AC97_MD ); +#ifdef CONFIG_PXA27x +/* Use GPIO 113 as AC97 Reset on Bulverde */ +pxa_gpio_mode (113 |GPIO_ALT_FN_2_OUT ); +#endif +pxa_set_cken (CKEN2_AC97 ,1 ); +return 0 ; +} + +#else +#define pxa2xx_ac97_suspend NULL +#define pxa2xx_ac97_resume NULL +#endif + +static int pxa2xx_ac97_probe (struct platform_device *pdev) +{ +int ret; + + ret =request_irq (IRQ_AC97 , pxa2xx_ac97_irq,IRQF_DISABLED ,"AC97" ,NULL ); +if (ret <0 ) + goto err; + +pxa_gpio_mode (GPIO31_SYNC_AC97_MD ); +pxa_gpio_mode (GPIO30_SDATA_OUT_AC97_MD ); +pxa_gpio_mode (GPIO28_BITCLK_AC97_MD ); +pxa_gpio_mode (GPIO29_SDATA_IN_AC97_MD ); +#ifdef CONFIG_PXA27x +/* Use GPIO 113 as AC97 Reset on Bulverde */ +pxa_gpio_mode (113 |GPIO_ALT_FN_2_OUT ); +#endif +pxa_set_cken (CKEN2_AC97 ,1 ); +return 0 ; + + err: +if (CKEN &CKEN2_AC97 ) { +GCR |=GCR_ACLINK_OFF ; +free_irq (IRQ_AC97 ,NULL ); +pxa_set_cken (CKEN2_AC97 ,0 ); + } +return ret; +} + +static void pxa2xx_ac97_remove (struct platform_device *pdev) +{ +GCR |=GCR_ACLINK_OFF ; +free_irq (IRQ_AC97 ,NULL ); +pxa_set_cken (CKEN2_AC97 ,0 ); +} + +static int pxa2xx_ac97_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_out; +else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_in; + +return 0 ; +} + +static int pxa2xx_ac97_hw_aux_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_out; +else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_in; + +return 0 ; +} + +static int pxa2xx_ac97_hw_mic_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +return -ENODEV ; +else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_mic_mono_in; + +return 0 ; +} + +/* +* There is only 1 physical AC97 interface for pxa2xx, but it +* has extra fifo's that can be used for aux DACs and ADCs. +*/ +struct snd_soc_cpu_dai pxa_ac97_dai[] = { +{ + .name ="pxa2xx-ac97" , + .id =0 , + .type =SND_SOC_DAI_AC97 , + .probe = pxa2xx_ac97_probe, + .remove = pxa2xx_ac97_remove, + .suspend = pxa2xx_ac97_suspend, + .resume = pxa2xx_ac97_resume, + .playback = { + .stream_name ="AC97 Playback" , + .channels_min =2 , + .channels_max =2 ,}, + .capture = { + .stream_name ="AC97 Capture" , + .channels_min =2 , + .channels_max =2 ,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_params,}, + .caps = { + .num_modes =ARRAY_SIZE (pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,}, +}, +{ + .name ="pxa2xx-ac97-aux" , + .id =1 , + .type =SND_SOC_DAI_AC97 , + .playback = { + .stream_name ="AC97 Aux Playback" , + .channels_min =1 , + .channels_max =1 ,}, + .capture = { + .stream_name ="AC97 Aux Capture" , + .channels_min =1 , + .channels_max =1 ,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_aux_params,}, + .caps = { + .num_modes =ARRAY_SIZE (pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,}, +}, +{ + .name ="pxa2xx-ac97-mic" , + .id =2 , + .type =SND_SOC_DAI_AC97 , + .capture = { + .stream_name ="AC97 Mic Capture" , + .channels_min =1 , + .channels_max =1 ,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_mic_params,}, + .caps = { + .num_modes =ARRAY_SIZE (pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,},}, +}; + +EXPORT_SYMBOL_GPL (pxa_ac97_dai); +EXPORT_SYMBOL_GPL (soc_ac97_ops); + +MODULE_AUTHOR ("Nicolas Pitre" ); +MODULE_DESCRIPTION ("AC97 driver for the Intel PXA2xx chip" ); +MODULE_LICENSE ("GPL" );
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
At Thu, 12 Oct 2006 11:27:19 +0100,
Quoted 4 lines · Liam Girdwood
Quoted 2 lines · Takashi Iwai
At Tue, 10 Oct 2006 17:19:36 +0100,
Liam Girdwood wrote:
Quoted 8 lines
Quoted 5 lines
soc/pxa/pxa2xx-ac97.c line 48
Quoted 3 lines
soc/pxa/pxa2xx-ac97.c new file +3
-0+/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + {0 ,0 ,SNDRV_PCM_FMTBIT_S16_LE ,AC97_RATES },Better to use ".field = value" initialization.
IMHO, this is a better style for the DAI capabilities field because it can grow quite large depending on the DAI.
On the contrary, it can reduce the size.
With .field=value style, you can ommit the above 0 initialization, for example. Ommitted fields are initialized to 0 as default.
And, the readability is of course much better with .field=value style :)
Takashi
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Quoted 15 lines · Takashi Iwai
At Thu, 12 Oct 2006 11:27:19 +0100,
Quoted 4 lines · Liam Girdwood
Quoted 2 lines · Takashi Iwai
At Tue, 10 Oct 2006 17:19:36 +0100,
Liam Girdwood wrote:Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + {0, 0, SNDRV_PCM_FMTBIT_S16_LE, AC97_RATES},Better to use ".field = value" initialization.
IMHO, this is a better style for the DAI capabilities field because it can grow quite large depending on the DAI.
Quoted 6 lines
On the contrary, it can reduce the size.
With .field=value style, you can ommit the above 0 initialization, for example. Ommitted fields are initialized to 0 as default.And, the readability is of course much better with .field=value style :)
Np, Fixed.
Thanks
Liam
soc/pxa/pxa2xx-ac97.c new file +437 -0
@@ -0,0 +1,437 @@ +/* +* linux/sound/pxa2xx-ac97.c -- AC97 support for the Intel PXA2xx chip. +* +* Author: Nicolas Pitre +* Created: Dec 02, 2004 +* Copyright: MontaVista Software Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/interrupt.h> +#include <linux/wait.h> +#include <linux/delay.h> + +#include <sound/driver.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/ac97_codec.h> +#include <sound/initval.h> +#include <sound/soc.h> + +#include <asm/irq.h> +#include <linux/mutex.h> +#include <asm/hardware.h> +#include <asm/arch/pxa-regs.h> +#include <asm/arch/audio.h> + +#include "pxa2xx-pcm.h" + +static DEFINE_MUTEX (car_mutex); +static DECLARE_WAIT_QUEUE_HEAD (gsr_wq); +static volatile long gsr_bits; + +#define AC97_DIR \ + (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) + +#define AC97_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) + +/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + { + .pcmfmt =SNDRV_PCM_FMTBIT_S16_LE , + .pcmrate =AC97_RATES , + .pcmdir =AC97_DIR , + }, +}; + +/* +* Beware PXA27x bugs: +* +* o Slot 12 read from modem space will hang controller. +* o CDONE, SDONE interrupt fails after any slot 12 IO. +* +* We therefore have an hybrid approach for waiting on SDONE (interrupt or +* 1 jiffy timeout if interrupt never comes). +*/ + +static unsigned short pxa2xx_ac97_read (struct snd_ac97 *ac97, +unsigned short reg) +{ +unsigned short val =-1 ; +volatile u32 *reg_addr; + +mutex_lock (&car_mutex); + +/* set up primary or secondary codec/modem space */ +#ifdef CONFIG_PXA27x + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#else +if (reg ==AC97_GPIO_STATUS ) + reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE ; +else + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#endif + reg_addr += (reg >>1 ); + +#ifndef CONFIG_PXA27x +if (reg ==AC97_GPIO_STATUS ) { +/* read from controller cache */ + val = *reg_addr; + goto out; + } +#endif + +/* start read access across the ac97 link */ +GSR =GSR_CDONE |GSR_SDONE ; + gsr_bits =0 ; + val = *reg_addr; + +wait_event_timeout (gsr_wq, (GSR | gsr_bits) &GSR_SDONE ,1 ); +if (!((GSR | gsr_bits) &GSR_SDONE )) { +printk (KERN_ERR "%s: read error (ac97_reg=%x GSR=%#lx)\n" , + __FUNCTION__, reg,GSR | gsr_bits); + val =-1 ; + goto out; + } + +/* valid data now */ +GSR =GSR_CDONE |GSR_SDONE ; + gsr_bits =0 ; + val = *reg_addr; +/* but we've just started another cycle... */ +wait_event_timeout (gsr_wq, (GSR | gsr_bits) &GSR_SDONE ,1 ); + +out:mutex_unlock (&car_mutex); +return val; +} + +static void pxa2xx_ac97_write (struct snd_ac97 *ac97,unsigned short reg, +unsigned short val) +{ +volatile u32 *reg_addr; + +mutex_lock (&car_mutex); + +/* set up primary or secondary codec/modem space */ +#ifdef CONFIG_PXA27x + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#else +if (reg ==AC97_GPIO_STATUS ) + reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE ; +else + reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE ; +#endif + reg_addr += (reg >>1 ); + +GSR =GSR_CDONE |GSR_SDONE ; + gsr_bits =0 ; + *reg_addr = val; +wait_event_timeout (gsr_wq, (GSR | gsr_bits) &GSR_CDONE ,1 ); +if (!((GSR | gsr_bits) &GSR_CDONE )) +printk (KERN_ERR "%s: write error (ac97_reg=%x GSR=%#lx)\n" , + __FUNCTION__, reg,GSR | gsr_bits); + +mutex_unlock (&car_mutex); +} + +static void pxa2xx_ac97_warm_reset (struct snd_ac97 *ac97) +{ + gsr_bits =0 ; + +#ifdef CONFIG_PXA27x +/* warm reset broken on Bulverde, +so manually keep AC97 reset high */ +pxa_gpio_mode (113 |GPIO_OUT |GPIO_DFLT_HIGH ); +udelay (10 ); +GCR |=GCR_WARM_RST ; +pxa_gpio_mode (113 |GPIO_ALT_FN_2_OUT ); +udelay (500 ); +#else +GCR |=GCR_WARM_RST |GCR_PRIRDY_IEN |GCR_SECRDY_IEN ; +wait_event_timeout (gsr_wq, gsr_bits & (GSR_PCR |GSR_SCR ),1 ); +#endif + +if (!((GSR | gsr_bits) & (GSR_PCR |GSR_SCR ))) +printk (KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n" , + __FUNCTION__, gsr_bits); + +GCR &= ~(GCR_PRIRDY_IEN |GCR_SECRDY_IEN ); +GCR |=GCR_SDONE_IE |GCR_CDONE_IE ; +} + +static void pxa2xx_ac97_cold_reset (struct snd_ac97 *ac97) +{ +GCR &=GCR_COLD_RST ;/* clear everything but nCRST */ +GCR &= ~GCR_COLD_RST ;/* then assert nCRST */ + + gsr_bits =0 ; +#ifdef CONFIG_PXA27x +/* PXA27x Developers Manual section 13.5.2.2.1 */ +pxa_set_cken (1 <<31 ,1 ); +udelay (5 ); +pxa_set_cken (1 <<31 ,0 ); +GCR =GCR_COLD_RST ; +udelay (50 ); +#else +GCR =GCR_COLD_RST ; +GCR |=GCR_CDONE_IE |GCR_SDONE_IE ; +wait_event_timeout (gsr_wq, gsr_bits & (GSR_PCR |GSR_SCR ),1 ); +#endif + +if (!((GSR | gsr_bits) & (GSR_PCR |GSR_SCR ))) +printk (KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n" , + __FUNCTION__, gsr_bits); + +GCR &= ~(GCR_PRIRDY_IEN |GCR_SECRDY_IEN ); +GCR |=GCR_SDONE_IE |GCR_CDONE_IE ; +} + +static irqreturn_t pxa2xx_ac97_irq (int irq,void *dev_id) +{ +long status; + + status =GSR ; +if (status) { +GSR = status; + gsr_bits |= status; +wake_up (&gsr_wq); + +#ifdef CONFIG_PXA27x +/* Although we don't use those we still need to clear them +since they tend to spuriously trigger when MMC is used +(hardware bug? go figure)... */ +MISR =MISR_EOC ; +PISR =PISR_EOC ; +MCSR =MCSR_EOC ; +#endif + +return IRQ_HANDLED ; + } + +return IRQ_NONE ; +} + +struct snd_ac97_bus_ops soc_ac97_ops = { + .read = pxa2xx_ac97_read, + .write = pxa2xx_ac97_write, + .warm_reset = pxa2xx_ac97_warm_reset, + .reset = pxa2xx_ac97_cold_reset, +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_out = { + .name ="AC97 PCM Stereo out" , + .dev_addr =__PREG (PCDR ), + .drcmr = &DRCMRTXPCDR , + .dcmd =DCMD_INCSRCADDR |DCMD_FLOWTRG | +DCMD_BURST32 |DCMD_WIDTH4 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_stereo_in = { + .name ="AC97 PCM Stereo in" , + .dev_addr =__PREG (PCDR ), + .drcmr = &DRCMRRXPCDR , + .dcmd =DCMD_INCTRGADDR |DCMD_FLOWSRC | +DCMD_BURST32 |DCMD_WIDTH4 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_out = { + .name ="AC97 Aux PCM (Slot 5) Mono out" , + .dev_addr =__PREG (MODR ), + .drcmr = &DRCMRTXMODR , + .dcmd =DCMD_INCSRCADDR |DCMD_FLOWTRG | +DCMD_BURST16 |DCMD_WIDTH2 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_aux_mono_in = { + .name ="AC97 Aux PCM (Slot 5) Mono in" , + .dev_addr =__PREG (MODR ), + .drcmr = &DRCMRRXMODR , + .dcmd =DCMD_INCTRGADDR |DCMD_FLOWSRC | +DCMD_BURST16 |DCMD_WIDTH2 , +}; + +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_mic_mono_in = { + .name ="AC97 Mic PCM (Slot 6) Mono in" , + .dev_addr =__PREG (MCDR ), + .drcmr = &DRCMRRXMCDR , + .dcmd =DCMD_INCTRGADDR |DCMD_FLOWSRC | +DCMD_BURST16 |DCMD_WIDTH2 , +}; + +#ifdef CONFIG_PM +static int pxa2xx_ac97_suspend (struct platform_device *pdev, +struct snd_soc_cpu_dai *dai) +{ +GCR |=GCR_ACLINK_OFF ; +pxa_set_cken (CKEN2_AC97 ,0 ); +return 0 ; +} + +static int pxa2xx_ac97_resume (struct platform_device *pdev, +struct snd_soc_cpu_dai *dai) +{ +pxa_gpio_mode (GPIO31_SYNC_AC97_MD ); +pxa_gpio_mode (GPIO30_SDATA_OUT_AC97_MD ); +pxa_gpio_mode (GPIO28_BITCLK_AC97_MD ); +pxa_gpio_mode (GPIO29_SDATA_IN_AC97_MD ); +#ifdef CONFIG_PXA27x +/* Use GPIO 113 as AC97 Reset on Bulverde */ +pxa_gpio_mode (113 |GPIO_ALT_FN_2_OUT ); +#endif +pxa_set_cken (CKEN2_AC97 ,1 ); +return 0 ; +} + +#else +#define pxa2xx_ac97_suspend NULL +#define pxa2xx_ac97_resume NULL +#endif + +static int pxa2xx_ac97_probe (struct platform_device *pdev) +{ +int ret; + + ret =request_irq (IRQ_AC97 , pxa2xx_ac97_irq,IRQF_DISABLED ,"AC97" ,NULL ); +if (ret <0 ) + goto err; + +pxa_gpio_mode (GPIO31_SYNC_AC97_MD ); +pxa_gpio_mode (GPIO30_SDATA_OUT_AC97_MD ); +pxa_gpio_mode (GPIO28_BITCLK_AC97_MD ); +pxa_gpio_mode (GPIO29_SDATA_IN_AC97_MD ); +#ifdef CONFIG_PXA27x +/* Use GPIO 113 as AC97 Reset on Bulverde */ +pxa_gpio_mode (113 |GPIO_ALT_FN_2_OUT ); +#endif +pxa_set_cken (CKEN2_AC97 ,1 ); +return 0 ; + + err: +if (CKEN &CKEN2_AC97 ) { +GCR |=GCR_ACLINK_OFF ; +free_irq (IRQ_AC97 ,NULL ); +pxa_set_cken (CKEN2_AC97 ,0 ); + } +return ret; +} + +static void pxa2xx_ac97_remove (struct platform_device *pdev) +{ +GCR |=GCR_ACLINK_OFF ; +free_irq (IRQ_AC97 ,NULL ); +pxa_set_cken (CKEN2_AC97 ,0 ); +} + +static int pxa2xx_ac97_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_out; +else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_in; + +return 0 ; +} + +static int pxa2xx_ac97_hw_aux_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_out; +else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_in; + +return 0 ; +} + +static int pxa2xx_ac97_hw_mic_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +return -ENODEV ; +else + rtd->cpu_dai->dma_data = &pxa2xx_ac97_pcm_mic_mono_in; + +return 0 ; +} + +/* +* There is only 1 physical AC97 interface for pxa2xx, but it +* has extra fifo's that can be used for aux DACs and ADCs. +*/ +struct snd_soc_cpu_dai pxa_ac97_dai[] = { +{ + .name ="pxa2xx-ac97" , + .id =0 , + .type =SND_SOC_DAI_AC97 , + .probe = pxa2xx_ac97_probe, + .remove = pxa2xx_ac97_remove, + .suspend = pxa2xx_ac97_suspend, + .resume = pxa2xx_ac97_resume, + .playback = { + .stream_name ="AC97 Playback" , + .channels_min =2 , + .channels_max =2 ,}, + .capture = { + .stream_name ="AC97 Capture" , + .channels_min =2 , + .channels_max =2 ,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_params,}, + .caps = { + .num_modes =ARRAY_SIZE (pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,}, +}, +{ + .name ="pxa2xx-ac97-aux" , + .id =1 , + .type =SND_SOC_DAI_AC97 , + .playback = { + .stream_name ="AC97 Aux Playback" , + .channels_min =1 , + .channels_max =1 ,}, + .capture = { + .stream_name ="AC97 Aux Capture" , + .channels_min =1 , + .channels_max =1 ,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_aux_params,}, + .caps = { + .num_modes =ARRAY_SIZE (pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,}, +}, +{ + .name ="pxa2xx-ac97-mic" , + .id =2 , + .type =SND_SOC_DAI_AC97 , + .capture = { + .stream_name ="AC97 Mic Capture" , + .channels_min =1 , + .channels_max =1 ,}, + .ops = { + .hw_params = pxa2xx_ac97_hw_mic_params,}, + .caps = { + .num_modes =ARRAY_SIZE (pxa2xx_ac97_modes), + .mode = pxa2xx_ac97_modes,},}, +}; + +EXPORT_SYMBOL_GPL (pxa_ac97_dai); +EXPORT_SYMBOL_GPL (soc_ac97_ops); + +MODULE_AUTHOR ("Nicolas Pitre" ); +MODULE_DESCRIPTION ("AC97 driver for the Intel PXA2xx chip" ); +MODULE_LICENSE ("GPL" );
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
At Thu, 12 Oct 2006 12:58:01 +0100,
Quoted 17 lines · Liam Girdwood
Quoted 15 lines · Takashi Iwai
At Thu, 12 Oct 2006 11:27:19 +0100,
Quoted 12 lines · Liam Girdwood
Quoted 7 lines · Takashi Iwai
At Tue, 10 Oct 2006 17:19:36 +0100,
soc/pxa/pxa2xx-ac97.c
Quoted 3 lines · Liam Girdwood
soc/pxa/pxa2xx-ac97.c new file +3
-0+/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + {0 ,0 ,SNDRV_PCM_FMTBIT_S16_LE ,AC97_RATES },Better to use ".field = value" initialization.
IMHO, this is a better style for the DAI capabilities field because it can grow quite large depending on the DAI.
Quoted 8 lines
Quoted 6 lines
On the contrary, it can reduce the size.
With .field=value style, you can ommit the above 0 initialization, for example. Ommitted fields are initialized to 0 as default.And, the readability is of course much better with .field=value style :)
Np, Fixed.
Thanks. Could you fix at91rm9200-i2s.c, too?
Takashi
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Quoted 23 lines · Takashi Iwai
At Thu, 12 Oct 2006 12:58:01 +0100,
Quoted 21 lines · Liam Girdwood
Quoted 19 lines · Takashi Iwai
At Thu, 12 Oct 2006 11:27:19 +0100,
Quoted 4 lines · Liam Girdwood
Quoted 2 lines · Takashi Iwai
At Tue, 10 Oct 2006 17:19:36 +0100,
Liam Girdwood wrote:Quoted 8 lines
Quoted 5 lines
soc/pxa/pxa2xx-ac97.c
Quoted 3 lines
soc/pxa/pxa2xx-ac97.c new file +3
-0+/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + {0 ,0 ,SNDRV_PCM_FMTBIT_S16_LE ,AC97_RATES },Better to use ".field = value" initialization.
IMHO, this is a better style for the DAI capabilities field because it can grow quite large depending on the DAI.
On the contrary, it can reduce the size.
With .field=value style, you can ommit the above 0 initialization, for example. Ommitted fields are initialized to 0 as default.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
And, the readability is of course much better with .field=value style :)
Np, Fixed.
Thanks. Could you fix
at91rm9200-i2s.c, too?
Ok, I'll also have to make changes to pxa2xx-i2s.c, wm8731.c and wm8750.c.
Liam
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
At Thu, 12 Oct 2006 13:28:04 +0100,
Quoted 28 lines · Liam Girdwood
Quoted 26 lines · Takashi Iwai
At Thu, 12 Oct 2006 12:58:01 +0100,
Quoted 24 lines · Liam Girdwood
Quoted 21 lines · Takashi Iwai
At Thu, 12 Oct 2006 11:27:19 +0100,
Quoted 4 lines · Liam Girdwood
Quoted 2 lines · Takashi Iwai
At Tue, 10 Oct 2006 17:19:36 +0100,
Liam Girdwood wrote:Quoted 8 lines
Quoted 5 lines
soc/pxa/pxa2xx-ac97.c
Quoted 3 lines
soc/pxa/pxa2xx-ac97.c new file +3
-0+/* may need to expand this */ +static struct snd_soc_dai_mode pxa2xx_ac97_modes[] = { + {0 ,0 ,SNDRV_PCM_FMTBIT_S16_LE ,AC97_RATES },Better to use ".field = value" initialization.
IMHO, this is a better style for the DAI capabilities field because it can grow quite large depending on the DAI.
On the contrary, it can reduce the size.
With .field=value style, you can ommit the above 0 initialization, for example. Ommitted fields are initialized to 0 as default.And, the readability is of course much better with .field=value style :)
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Np, Fixed.
Thanks. Could you fix
at91rm9200-i2s.c, too?Ok, I'll also have to make changes to
pxa2xx-i2s.c,wm8731.candwm8750.c.
Thanks.
I merged the pxa patches to ALSA HG tree now. Please check if nothing is missing.
Takashi
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642