Audio support for codec Philips UDA1380
Hi all,
I want to contribute code to support audio codec Philips UDA1380. Download from: "http://www.mandarinlogiq.org/PXA2xx i2Sound/"
Clean write for ALSA and kernel 2.6 with full power optimizations at subchip level, enabling hw blocks on need. Looking around in the kernel, this seems to be a novelty among sound drivers, that run commonly in an all-always-powered-up manner.
See h2200_audio (also on the site) for a sample glue module, that support the audio of an iPAQ h2200 handheld, using it together with a complementary module for the Intel PXA2xx I2S audio.
I wish to know whether there are other similar works in development.
Giorgio
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
Quoted 2 lines · Giorgio Padrin
Hi all,
Hi !
Quoted 12 lines
I want to contribute code to support audio codec Philips UDA1380. Download from: "http://www.mandarinlogiq.org/PXA2xx i2Sound/"
Clean write for ALSA and kernel 2.6 with full power optimizations at subchip level, enabling hw blocks on need. Looking around in the kernel, this seems to be a novelty among sound drivers, that run commonly in an all-always-powered-up manner.
See
h2200_audio(also on the site) for a sample glue module, that support the audio of an iPAQ h2200 handheld, using it together with a complementary module for the Intel PXA2xx I2S audio.
So, the uda1380 module is generic enough to be used on non PXA boards ?
Quoted 1 line
I wish to know whether there are other similar works in development.
uda1380 with i2s support was on my todo list but I think I will remove it as you've done it :)
Do you plan to send it to the ALSA folks ?
Regards,
Arnaud
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
Alle 13:43, venerdì 4 novembre 2005, Arnaud Patard ha scritto:
Quoted 5 lines
Quoted 3 lines
See
h2200_audio(also on the site) for a sample glue module, that support the audio of an iPAQ h2200 handheld, using it together with a complementary module for the Intel PXA2xx I2S audio.So, the uda1380 module is generic enough to be used on non PXA boards ?
Yes. It's so intended.
Giorgio
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
Quoted 8 lines · Giorgio Padrin
Alle 13:43, venerdì 4 novembre 2005, Arnaud Patard ha scritto:
Quoted 5 lines
Quoted 3 lines
See
h2200_audio(also on the site) for a sample glue module, that support the audio of an iPAQ h2200 handheld, using it together with a complementary module for the Intel PXA2xx I2S audio.So, the uda1380 module is generic enough to be used on non PXA boards ?
Yes. It's so intended.
okay.. so you may safely remove the pxa header :)
I've done a test build and it doesn't build because the I2C_DRIVERID_UDA1380 symbol is lacking is linux/i2c-id.h.
Arnaud.
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
Hi Arnaud,
Thank you very much.
Alle 21:13, lunedì 7 novembre 2005, Arnaud Patard ha scritto:
Quoted 1 line
okay.. so you may safely remove the pxa header :)
Removed.
Quoted 2 lines
I've done a test build and it doesn't build because the
I2C_DRIVERID_UDA1380symbol is lacking islinux/i2c-id.h.
Removed also. Optional in I2C subsystem, no more present in last docs; no use. No need to apply for an ID allocated in include/linux/i2c-id.h .
Giorgio
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
Hi,
Quoted 3 lines
I want to contribute code to support audio codec Philips UDA1380. Download from: "http://www.mandarinlogiq.org/PXA2xx i2Sound/"
This URL is broken and needs to be fixed. :)
s/ /%20/
Quoted 5 lines
Clean write for ALSA and kernel 2.6 with full power optimizations at subchip level, enabling hw blocks on need. Looking around in the kernel, this seems to be a novelty among sound drivers, that run commonly in an all-always-powered-up manner.
Is there any reason why you didn't use the pxa2xx-pcm code (sound/arm/pxa2xx-pcm.c) which is already working perfectly with AC97 and can be used for I2S without any change.
Some comments on your code (see attached patch):
- The register cache for the UDA1380 is defined in uda1380.h as 0x24 words in size, but the highest register number accessed is 0x28, which makes up for a perfect buffer overflow due to missing array bounds checking.
- The cache flush routines unecessarily always write registers from the start of a section instead of flushing only registers that have really been modified.
- The INV_RANGE() macro is off by one.
- __BIG_ENDIAN is undefined on little endian machines, thus '#if __BIG_ENDIAN' gives a compiler warning.
- The macro 'flag_stream()' in pxa2xx-i2sound.c is missing parentheses around the expression
- There are lots of bogus spaces or tabs at line endings.
Lothar Wassmann
pxa2xx-i2sound.c +108 -108
@@ -11,7 +11,7 @@* * 2005-03 Initial release; Audio engine ((c) 2004) derived from pxa-uda1380.c * -- Giorgio Padrin -* 2005-06 Power management -- Giorgio Padrin +* 2005-06 Power management -- Giorgio Padrin * 2005-10 Some finishing -- Giorgio Padrin */
@@ -39,27 +39,27 @@typedef struct snd_pxa2xx_i2sound_engine snd_pxa2xx_i2sound_engine_t ;typedef struct snd_pxa2xx_i2sound_stream { -int id;/* SNDRV_PCM_STREAM_(PLAYBACK|CAPTURE) */ - +int id;/* SNDRV_PCM_STREAM_(PLAYBACK|CAPTURE) */ +snd_pxa2xx_i2sound_engine_t *engine; - +int dma_ch;/* DMA channel */ - +dma_addr_t buffer;/* buffer (physical address) */ size_t buffer_size; - +size_t period_size; - +pxa_dma_desc *dma_dring;/* DMA descriptors ring */ char *dma_dring_store;/* storage space for DMA descriptors ring */ dma_addr_t dma_dring_p;/* (physical address) */ dma_addr_t dma_dring_store_p; -size_t dma_dring_size; - +size_t dma_dring_size; +volatile int dma_running;/* DMA running? */ - +snd_pcm_substream_t *asubs;/* attached ALSA substream */ - +snd_pcm_hardware_t ahw;/* ALSA hw description */ }snd_pxa2xx_i2sound_stream_t ;
@@ -67,7 +67,7 @@unsigned int rate;/* sample rate */ unsigned int rate_in_use;spinlock_t rate_lock; - +snd_pxa2xx_i2sound_stream_t streams[2 ]; };
@@ -80,23 +80,23 @@typedef struct snd_pxa2xx_i2sound_card {const char *name; - +snd_pxa2xx_i2sound_engine_t engine;struct snd_pxa2xx_i2sound_i2slink i2slink; - +snd_pxa2xx_i2sound_board_t *board; - +snd_card_t *acard;/* ALSA card */ snd_pcm_t *apcm;/* ALSA pcm */ - +struct device_driver device_driver;struct platform_device pdev; }snd_pxa2xx_i2sound_card_t ;static snd_pxa2xx_i2sound_card_t card; -#define flag_stream (s) 1 << s->id +#define flag_stream (s) (1 << s->id)#define info_clock_from_pxa ((card.board->info & SND_PXA2xx_I2SOUND_INFO_CLOCK_FROM_PXA) ? 1 : 0)#define info_can_capture ((card.board->info & SND_PXA2xx_I2SOUND_INFO_CAN_CAPTURE) ? 1 : 0)
@@ -106,17 +106,17 @@PXA21x and PXA26x belong to the PXA 25x kind */ static inline int pxa_25x_kind (void ) {return ((read_cpuid (CPUID_ID ) &0x3f0 ) !=0x110 ); -} +}/* begin {{ Audio Engine }} */ #define MAX_DMA_XFER_SIZE 4096 -#define MAX_BUFFER_SIZE 65536 +#define MAX_BUFFER_SIZE 65536static int snd_pxa2xx_i2sound_ngn_init (void ) {spin_lock_init (&card.engine.rate_lock); - +/* preallocate buffer */ return snd_pcm_lib_preallocate_pages_for_all(card.apcm, SNDRV_DMA_TYPE_DEV, NULL, MAX_BUFFER_SIZE,
@@ -124,7 +124,7 @@ }static void snd_pxa2xx_i2sound_ngn_free (void ) { -/* ALSA takes care of deallocate preallocated buffer */ +/* ALSA takes care of deallocate preallocated buffer */ }/* Constraint: buffer_size integer multiple of period_size
@@ -141,40 +141,40 @@static snd_pcm_hw_constraint_list_t cnstr_buffer_sizes = { .count =ARRAY_SIZE (buffer_sizes), .list = buffer_sizes, - }; + };static snd_pcm_hw_constraint_list_t cnstr_rates;static void snd_pxa2xx_i2sound_ngn_free_buffer (snd_pxa2xx_i2sound_stream_t *s); - +static int snd_pxa2xx_i2sound_ngn_init_buffer (snd_pxa2xx_i2sound_stream_t *s,size_t buffer_size,size_t period_size) {int ret; - +unsigned int dma_dpp;/* dma descriptors per period */ unsigned int periods;unsigned int i, j, di;dma_addr_t p, d_buf;size_t d_size =sizeof (pxa_dma_desc); - +size_t dma_xfer_size = (period_size >=MAX_DMA_XFER_SIZE ) ?MAX_DMA_XFER_SIZE : period_size; dma_dpp = (period_size -1 ) / dma_xfer_size +1 ; periods = buffer_size / period_size; - +/* free old buffer in case */ if (s->buffer)snd_pxa2xx_i2sound_ngn_free_buffer (s); - +/* allocate buffer */ ret =snd_pcm_lib_malloc_pages (s->asubs, buffer_size);if (ret <0 )return ret; - + s->buffer = s->asubs->runtime->dma_addr;/* ---- allocate and setup DMA descriptors ring ---- */ - +/* allocate storage space for descriptors ring (alignment issue) */ s->dma_dring_size = periods * dma_dpp * d_size; s->dma_dring_store = dma_alloc_coherent(NULL, s->dma_dring_size + 15,
@@ -183,21 +183,21 @@ s->dma_dring_size =0 ;snd_pxa2xx_i2sound_ngn_free_buffer (s);return -ENOMEM ; - } - + } +/* setup the descriptors ring pointer, aligned on a 16 bytes boundary */ s->dma_dring = ((dma_addr_t ) s->dma_dring_store &0xf ) ? (pxa_dma_desc *) (((dma_addr_t ) s->dma_dring_store & ~0xf ) +16 ) : (pxa_dma_desc *) s->dma_dring_store; s->dma_dring_p = s->dma_dring_store_p + (dma_addr_t ) s->dma_dring - (dma_addr_t ) s->dma_dring_store; - +/* fill the descriptors ring */ di =0 ;/* current descriptor index */ p = s->buffer;/* p: current period (address in buffer) */ /* iterate over periods */ for (i =0 ; i < periods; i++, p += period_size) { - d_buf = p;/* d_buf: address in buffer for current dma descriptor */ + d_buf = p;/* d_buf: address in buffer for current dma descriptor */ /* iterate over dma descriptors in a period */ for (j =0 ; j < dma_dpp; j++, di++, d_buf += dma_xfer_size) {/* link to next descriptor */
@@ -219,7 +219,7 @@ s->dma_dring[di -1 ].dcmd |=DCMD_ENDIRQEN ;/* period irq */ } s->dma_dring[di -1 ].ddadr = s->dma_dring_p;/* close the ring */ - +return 0 ; }
@@ -236,23 +236,23 @@if (s->buffer) {snd_pcm_lib_free_pages (s->asubs); s->buffer =0 ; - } + } } -#define RATE_IN_USE_BY (s) +#define RATE_IN_USE_BY (s)static int snd_pxa2xx_i2sound_ngn_set_rate (unsigned int rate);static int snd_pxa2xx_i2sound_ngn_request_rate (snd_pxa2xx_i2sound_stream_t *s,unsigned int rate) {spin_lock (&card.engine.rate_lock); - + card.engine.rate_in_use &= ~flag_stream (s);if (rate != card.engine.rate) {if (!card.engine.rate_in_use) {if (snd_pxa2xx_i2sound_ngn_set_rate (rate) ==0 ) card.engine.rate = rate;else goto error; - } + }else goto error; } card.engine.rate_in_use |=flag_stream (s);
@@ -260,7 +260,7 @@return 0 ; error:spin_unlock (&card.engine.rate_lock); -return -EINVAL ; +return -EINVAL ; }static void snd_pxa2xx_i2sound_ngn_free_rate (snd_pxa2xx_i2sound_stream_t *s) {
@@ -285,7 +285,7 @@ {snd_pxa2xx_i2sound_stream_t *s = (snd_pxa2xx_i2sound_stream_t *) data;u32 dcsr; - + dcsr =DCSR (ch);DCSR (ch) = dcsr & ~DCSR_STOPIRQEN ;
@@ -313,11 +313,11 @@ }static int snd_pxa2xx_i2sound_ngn_request_dma_channel (snd_pxa2xx_i2sound_stream_t *s) { -int ret; +int ret;char *name = (s->id ==SNDRV_PCM_STREAM_PLAYBACK ) ?"i2s out" : -"i2s in" ; - +"i2s in" ; + ret =pxa_request_dma (name,DMA_PRIO_LOW , snd_pxa2xx_i2sound_ngn_dma_irq, s);if (ret <0 )return ret; s->dma_ch = ret;
@@ -333,12 +333,12 @@static int snd_pxa2xx_i2sound_ngn_attach_asubs (snd_pcm_substream_t *asubs) {snd_pxa2xx_i2sound_stream_t *s = &card.engine.streams[asubs->stream];int ret; - + asubs->private_data = (void *) s; s->asubs = asubs; - -if ((ret =snd_pxa2xx_i2sound_ngn_request_dma_channel (s)) <0 )return ret; - + +if ((ret =snd_pxa2xx_i2sound_ngn_request_dma_channel (s)) <0 )return ret; +/* ALSA hw description */ asubs->runtime->hw = s->ahw;
@@ -355,19 +355,19 @@snd_pcm_hw_constraint_list (asubs->runtime,0 ,SNDRV_PCM_HW_PARAM_RATE , &cnstr_rates); } - +/* more board specific constraints? */ if (card.board->add_hw_constraints) card.board->add_hw_constraints (asubs); - -return 0 ; + +return 0 ; }static void snd_pxa2xx_i2sound_ngn_detach_asubs (snd_pcm_substream_t *asubs) {snd_pxa2xx_i2sound_stream_t *s = &card.engine.streams[asubs->stream]; - +snd_pxa2xx_i2sound_ngn_free_dma_channel (s); - + asubs->private_data =NULL ; s->asubs =NULL ; }
@@ -375,23 +375,23 @@static int snd_pxa2xx_i2sound_ngn_on (snd_pxa2xx_i2sound_stream_t *s,unsigned int rate,size_t buffer_size,size_t period_size) {int ret; - +/* request sample rate */ ret =snd_pxa2xx_i2sound_ngn_request_rate (s, rate);if (ret)return ret; - +/* init buffer */ ret =snd_pxa2xx_i2sound_ngn_init_buffer (s, buffer_size, period_size);if (ret) {snd_pxa2xx_i2sound_ngn_free_rate (s);return ret; } - + s->buffer_size = buffer_size; s->period_size = period_size; - +return 0 ; -} +}static void snd_pxa2xx_i2sound_ngn_off (snd_pxa2xx_i2sound_stream_t *s) {snd_pxa2xx_i2sound_ngn_free_rate (s);
@@ -411,12 +411,12 @@unsigned int timeout =100 ;/* safety timeout */ DCSR (s->dma_ch) =DCSR_STOPIRQEN ; - +while (!(DCSR (s->dma_ch) &DCSR_STOPSTATE ) && timeout >0 ) {udelay (10 ); timeout--; } - + s->dma_running =0 ;return 0 ; }
@@ -461,7 +461,7 @@pxa_gpio_mode (GPIO30_SDATA_OUT_I2S_MD );if (info_can_capture)pxa_gpio_mode (GPIO29_SDATA_IN_I2S_MD );pxa_gpio_mode (GPIO31_SYNC_I2S_MD ); - +pxa_set_cken (CKEN8_I2S ,1 );SACR0 =SACR0_RST ;if (info_clock_from_pxa) {
@@ -470,13 +470,13 @@ }else {SACR0 =SACR0_ENB |SACR0_RFTH (8 ) |SACR0_TFTH (8 ); - } + } }static void snd_pxa2xx_i2sound_i2slink_off (void ) {SACR0 =SACR0_RST ;pxa_set_cken (CKEN8_I2S ,0 ); - +if (info_clock_from_pxa) {pxa_gpio_mode (GPIO28_BITCLK |GPIO_OUT |GPIO_DFLT_LOW );if (pxa_25x_kind ())pxa_gpio_mode (GPIO32_SYSCLK |GPIO_OUT |GPIO_DFLT_LOW );
@@ -494,7 +494,7 @@spin_lock (&card.i2slink.lock);if (card.i2slink.usage_count++ ==0 && !card.i2slink.suspended) -snd_pxa2xx_i2sound_i2slink_on (); +snd_pxa2xx_i2sound_i2slink_on ();spin_unlock (&card.i2slink.lock); }
@@ -502,7 +502,7 @@spin_lock (&card.i2slink.lock);if (--card.i2slink.usage_count ==0 && !card.i2slink.suspended) -snd_pxa2xx_i2sound_i2slink_off (); +snd_pxa2xx_i2sound_i2slink_off ();spin_unlock (&card.i2slink.lock); }
@@ -511,14 +511,14 @@spin_lock (&card.i2slink.lock); card.i2slink.suspended =1 ;if (card.i2slink.usage_count ==0 ) -snd_pxa2xx_i2sound_i2slink_off (); +snd_pxa2xx_i2sound_i2slink_off ();spin_unlock (&card.i2slink.lock); }void snd_pxa2xx_i2sound_i2slink_resume (void ) {spin_lock (&card.i2slink.lock);if (card.i2slink.usage_count >0 ) -snd_pxa2xx_i2sound_i2slink_on (); +snd_pxa2xx_i2sound_i2slink_on (); card.i2slink.suspended =0 ;spin_unlock (&card.i2slink.lock); }
@@ -531,7 +531,7 @@SADIV = card.i2slink.sadiv =576000 / rate;spin_unlock (&card.i2slink.lock);return 0 ; -default :return -EINVAL ; +default :return -EINVAL ; } }
@@ -556,7 +556,7 @@static int snd_pxa2xx_i2sound_pcm_prepare (snd_pcm_substream_t *asubs) {return 0 ; }static int snd_pxa2xx_i2sound_pcm_trigger (snd_pcm_substream_t *asubs,int cmd) { -snd_pxa2xx_i2sound_stream_t * s = (snd_pxa2xx_i2sound_stream_t *) asubs->private_data; +snd_pxa2xx_i2sound_stream_t * s = (snd_pxa2xx_i2sound_stream_t *) asubs->private_data;switch (cmd) {case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_RESUME :
@@ -620,7 +620,7 @@if (card.acard->power_state == SNDRV_CTL_POWER_D3hot)return 0 ; card.acard->pm_suspend (card.acard,PMSG_SUSPEND );snd_power_change_state (card.acard, SNDRV_CTL_POWER_D3hot); -return 0 ; +return 0 ; }static int snd_pxa2xx_i2sound_dev_resume (struct device *dev,u32 level) {
@@ -636,16 +636,16 @@static int snd_pxa2xx_i2sound_dev_register (void ) {int ret =0 ; - +/* device driver */ card.device_driver.name = card.name; card.device_driver.bus = &platform_bus_type; -#ifdef CONFIG_PM +#ifdef CONFIG_PM card.device_driver.suspend = snd_pxa2xx_i2sound_dev_suspend; card.device_driver.resume = snd_pxa2xx_i2sound_dev_resume; -#endif +#endif if ((ret =driver_register (&card.device_driver)))return ret; - +/* platform device */ card.pdev.name = card.name; card.pdev.id =-1 ;
@@ -672,21 +672,21 @@int s_id;snd_pxa2xx_i2sound_stream_t * s;snd_pxa2xx_i2sound_board_stream_hw_t * board_s_hw; - + ret =snd_pcm_new (card.acard, card.board->acard_id,0 ,1 , (info_can_capture) ?1 :0 , &card.apcm);if (ret <0 )return ret; - + ret =snd_pxa2xx_i2sound_ngn_init ();if (ret <0 )return ret; - + card.apcm->info_flags = info_half_duplex ?SNDRV_PCM_INFO_HALF_DUPLEX :SNDRV_PCM_INFO_JOINT_DUPLEX ;strlcpy (card.apcm->name, card.name,sizeof (card.apcm->name)); - +for (s_id =0 ; s_id <2 ; s_id++) {if (s_id ==SNDRV_PCM_STREAM_CAPTURE && !info_can_capture)continue ;
@@ -700,7 +700,7 @@ s->ahw.formats =SNDRV_PCM_FMTBIT_S16_LE ; s->ahw.channels_min =2 ; s->ahw.channels_max =2 ; - s->ahw.buffer_bytes_max =MAX_BUFFER_SIZE ; + s->ahw.buffer_bytes_max =MAX_BUFFER_SIZE ; s->ahw.period_bytes_min =512 ; s->ahw.period_bytes_max =MAX_BUFFER_SIZE /2 ; s->ahw.periods_min =2 ;
@@ -720,21 +720,21 @@ }snd_pcm_set_ops (card.apcm, s->id, &snd_pxa2xx_i2sound_pcm_ops); } - + card.apcm->private_free = snd_pxa2xx_i2sound_card_free_pcm; - -return 0 ; + +return 0 ; }static void snd_pxa2xx_i2sound_card_free_pcm (snd_pcm_t * apcm) {int s_id;snd_pxa2xx_i2sound_stream_t * s; - +for (s_id =0 ; s_id <2 ; s_id++) {if (s_id ==SNDRV_PCM_STREAM_CAPTURE && !info_can_capture)continue ; s = &card.engine.streams[s_id]; -memset (s,0 ,sizeof (snd_pxa2xx_i2sound_stream_t)); +memset (s,0 ,sizeof (snd_pxa2xx_i2sound_stream_t)); }snd_pxa2xx_i2sound_ngn_free (); card.apcm =NULL ;
@@ -742,7 +742,7 @@static int snd_pxa2xx_i2sound_board_activate (void ) {int ret =0 ; - +if (card.board->activate) {if (info_clock_from_pxa)snd_pxa2xx_i2sound_i2slink_get (); ret = card.board->activate ();
@@ -762,54 +762,54 @@#ifdef CONFIG_PM static int snd_pxa2xx_i2sound_card_suspend (snd_card_t *acard,pm_message_t state) {int s_id; - +snd_pcm_suspend_all (card.apcm); - +for (s_id =0 ; s_id <2 ; s_id++) {if (s_id ==SNDRV_PCM_STREAM_CAPTURE && !info_can_capture)continue ;snd_pxa2xx_i2sound_ngn_suspend (&card.engine.streams[s_id]); } - +if (info_clock_from_pxa)snd_pxa2xx_i2sound_i2slink_get (); card.board->suspend (state);if (info_clock_from_pxa)snd_pxa2xx_i2sound_i2slink_free (); - +snd_pxa2xx_i2sound_i2slink_suspend (); - +return 0 ; }static int snd_pxa2xx_i2sound_card_resume (snd_card_t *acard) {int s_id; - +snd_pxa2xx_i2sound_i2slink_resume (); - +if (info_clock_from_pxa)snd_pxa2xx_i2sound_i2slink_get (); card.board->resume ();if (info_clock_from_pxa)snd_pxa2xx_i2sound_i2slink_free (); - +for (s_id =0 ; s_id <2 ; s_id++) {if (s_id ==SNDRV_PCM_STREAM_CAPTURE && !info_can_capture)continue ;snd_pxa2xx_i2sound_ngn_resume (&card.engine.streams[s_id]); } - -return 0 ; + +return 0 ; }#endif int snd_pxa2xx_i2sound_card_activate (snd_pxa2xx_i2sound_board_t *board) {int ret =0 ; - +if (board ==NULL )return -EINVAL ; card.board = board; card.name = card.board->name; - +snd_pxa2xx_i2sound_i2slink_init (); - +if ((ret =snd_pxa2xx_i2sound_board_activate ()) <0 ) goto failed_activate_board; - +/* new ALSA card */ if ((card.acard =snd_card_new (-1 , card.board->acard_id,THIS_MODULE ,0 )) ==NULL ) { card.acard =NULL ;
@@ -820,36 +820,36 @@strlcpy (card.acard->driver, card.board->acard_id,sizeof (card.acard->driver));strlcpy (card.acard->shortname, card.name,sizeof (card.acard->shortname));strlcpy (card.acard->longname, card.board->desc,sizeof (card.acard->longname)); - +/* mixer */ if ((ret = board->add_mixer_controls (card.acard)) <0 ) goto failed_create_acard; - +/* PCM */ if ((ret =snd_pxa2xx_i2sound_card_create_pcm ()) <0 ) goto failed_create_acard; -#ifdef CONFIG_PM +#ifdef CONFIG_PM /* PM */ snd_card_set_pm_callback (card.acard, snd_pxa2xx_i2sound_card_suspend, snd_pxa2xx_i2sound_card_resume,NULL ); -#endif - +#endif +/* register the card */ if ((ret =snd_card_register (card.acard)) <0 ) goto failed_create_acard; - +if ((ret =snd_pxa2xx_i2sound_dev_register ()) <0 ) goto failed_register_dev; - +snd_printk (KERN_INFO "PXA2xx i2Sound: %s activated\n" , card.name); - +return 0 ; - + failed_register_dev: failed_create_acard:snd_card_free (card.acard); - card.acard =NULL ; + card.acard =NULL ; failed_new_acard:snd_pxa2xx_i2sound_board_deactivate (); failed_activate_board:
pxa2xx-i2sound.h +13 -13
@@ -12,49 +12,49 @@* 2005-03 Giorgio Padrin Initial release * 2005-05-02 Giorgio Padrin added event() to board plugins interface * 2005-05-14 Giorgio Padrin Splitted event() -*/ +*/ #include <sound/driver.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/initval.h> - -typedef struct snd_pxa2xx_i2sound_board_stream_hw { + +typedef struct snd_pxa2xx_i2sound_board_stream_hw {unsigned int rates;/* SNDRV_PCM_RATE_* */ unsigned int rate_min;/* min rate */ unsigned int rate_max;/* max rate */ unsigned int *rates_table;/* in case the field rates is not enough */ unsigned int rates_num;/* size of rates_table */ }snd_pxa2xx_i2sound_board_stream_hw_t ; - +typedef struct snd_pxa2xx_i2sound_board {char *name;char *desc;/* short description */ char *acard_id;/* ALSA card id */ unsigned int info; - +snd_pxa2xx_i2sound_board_stream_hw_t streams_hw[2 ]; - +int (*activate)(void );void (*deactivate)(void ); - +int (*set_rate)(unsigned int rate); - +int (*open_stream)(int stream);void (*close_stream)(int stream); - +/* ALSA mixer */ int (*add_mixer_controls)(snd_card_t *acard); - +/* tune ALSA hw params space at substream opening */ int (*add_hw_constraints)(snd_pcm_substream_t *asubs); - -#ifdef CONFIG_PM + +#ifdef CONFIG_PM /* Power Management */ int (*suspend) (pm_message_t state);int (*resume) (void ); -#endif +#endif }snd_pxa2xx_i2sound_board_t ;#define SND_PXA2xx_I2SOUND_INFO_CLOCK_FROM_PXA 1 << 0
uda1380.c +111 -106
551 lines not on this page · raw message
uda1380.h +13 -13
@@ -4,7 +4,7 @@* 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. -* +* * Copyright (c) 2005 Giorgio Padrin <[email protected]> */
@@ -12,12 +12,12 @@enum snd_uda1380_capture_source {SND_UDA1380_CAP_SOURCE_LINE_IN ,SND_UDA1380_CAP_SOURCE_MIC }; - +struct snd_uda1380 {struct semaphore sem; - -u16 regs[0x24 ];/* registers cache */ - + +u16 regs[0x29 ];/* registers cache */ +unsigned int powered_on:1 , playback_on:1,
@@ -28,15 +28,15 @@ capture_switch_ureq:1, capture_clock_on:1, capture_stream_opened:1; - +/* -- configuration (to fill before activation) -- */ unsigned int line_in_connected:1, mic_connected:1, hp_connected:1, hp_or_line_out; -enum snd_uda1380_capture_source capture_source; - +enum snd_uda1380_capture_source capture_source; +void (*power_on_chip)(int on);void (*reset_pin)(int on);void (*line_out_on)(int on);
@@ -44,13 +44,13 @@void (*mic_on)(int on);struct i2c_client i2c_client;/* to fill .adapter and .addr */ -/* ----------------------------------------------- */ - -struct { +/* ----------------------------------------------- */ + +struct {u8 start_reg;unsigned int count; - } cache_dirty[3 ]; - + } cache_dirty[3 ]; +struct {int detected;struct workqueue_struct *wq;
Hi Lothar,
Thanks very much for your contribution.
For clearness, I'd have prefered your email splitted for the two independent threads and codes, PXA2xx i2Sound and UDA1380.
Alle 11:56, venerdì 11 novembre 2005, Lothar Wassmann ha scritto:
Quoted 3 lines
Quoted 1 line
Download from: "http://www.mandarinlogiq.org/PXA2xx i2Sound/"
This URL is broken and needs to be fixed. :)
s/ /%20/
... In case your app refuses to do it for you :)
Quoted 8 lines
Quoted 4 lines
Clean write for ALSA and kernel 2.6 with full power optimizations at subchip level, enabling hw blocks on need. Looking around in the kernel, this seems to be a novelty among sound drivers, that run commonly in an all-always-powered-up manner.
Is there any reason why you didn't use the pxa2xx-pcm code (
sound/arm/pxa2xx-pcm.c) which is already working perfectly with AC97 and can be used for I2S without any change.
For clearness: You cited lines from this tread, then speaking of the other. Now answering: A matter of PXA2xx i2Sound's evolutive history, as now.
Giorgio
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php