Digital Audio related structures and functions are in include/pcm.h header file.
Variables from snd_pcm_t structure which must be filled:
Variables from snd_pcm_t structure which should be filled:
Variables from struct snd_stru_pcm_hardware which must be filled:
Variables from struct snd_stru_pcm_hardware which should be filled:
Functions list:
Functions for dma allocation:
Functions for allocation and registering:
static struct snd_stru_pcm_hardware snd_es1688_playback = {
NULL, /* private data */
NULL, /* private_free */
SND_PCM_HW_AUTODMA, /* flags */
SND_PCM_FMT_U8 | SND_PCM_FMT_S16_LE, /* formats */
0, /* align value */
6, /* minimal fragment */
4000, /* min. rate */
48000, /* max. rate */
2, /* max. voices */
snd_es1688_playback_open,
snd_es1688_playback_close,
snd_es1688_playback_compute_rate,
snd_es1688_playback_prepare,
snd_es1688_playback_trigger,
snd_es1688_playback_pointer,
snd_pcm_playback_dma_ulaw,
snd_pcm_dma_move,
snd_pcm_playback_dma_neutral
};
static struct snd_stru_pcm_hardware snd_es1688_record = {
NULL, /* private data */
NULL, /* private free */
SND_PCM_HW_AUTODMA, /* flags */
SND_PCM_FMT_U8 | SND_PCM_FMT_S16_LE, /* formats */
0, /* align value */
6, /* minimal fragment */
4000, /* min. rate */
48000, /* max. rate */
2, /* max. voices */
snd_es1688_record_open,
snd_es1688_record_close,
snd_es1688_record_compute_rate,
snd_es1688_record_prepare,
snd_es1688_record_trigger,
snd_es1688_record_pointer,
snd_pcm_record_dma_ulaw,
snd_pcm_dma_move,
NULL
};
static void snd_es1688_free( void *private_data )
{
snd_free( private_data, sizeof( es1688_t ) );
}
snd_pcm_t *snd_es1688_new_device( snd_card_t *card,
unsigned short port,
unsigned short mpu_port,
unsigned short irqnum,
unsigned short mpu_irqnum,
unsigned short dma8num,
unsigned short hardware )
{
snd_pcm_t *pcm;
es1688_t *codec;
pcm = snd_pcm_new_device( card, "ESx688" );
if ( !pcm ) return NULL;
codec = (es1688_t *)snd_malloc( sizeof( es1688_t ) );
if ( !codec ) return NULL;
memset( codec, 0, sizeof( es1688_t ) );
snd_spin_prepare( codec, reg );
snd_spin_prepare( codec, mixer );
codec -> pcm = pcm;
codec -> card = pcm -> card;
codec -> port = port;
codec -> mpu_port = mpu_port;
codec -> irqnum = irqnum;
codec -> irq = pcm -> card -> irqs[ irqnum ] -> irq;
codec -> mpu_irqnum = mpu_irqnum;
if ( mpu_irqnum != SND_IRQ_DISABLE )
codec -> mpu_irq = pcm -> card -> irqs[ mpu_irqnum ] -> irq;
codec -> dma8num = dma8num;
codec -> dma8 = pcm -> card -> dmas[ dma8num ] -> dma;
codec -> hardware = hardware;
memcpy( &pcm -> playback.hw, &snd_es1688_playback, sizeof( snd_es1688_playback ) );
memcpy( &pcm -> record.hw, &snd_es1688_record, sizeof( snd_es1688_record ) );
pcm -> private_data = codec;
pcm -> private_free = snd_es1688_free;
pcm -> info_flags = SND_PCM_INFO_CODEC | SND_PCM_INFO_MMAP |
SND_PCM_INFO_PLAYBACK | SND_PCM_INFO_RECORD;
sprintf( pcm -> name, "ES%s688 rev %i", codec -> hardware == ES1688_HW_688 ?"" : "1", codec -> version & 0x0f );
if ( snd_es1688_probe( pcm ) < 0 ) {
snd_pcm_free( pcm );
return NULL;
}
return pcm;
}
PCM device registering:
snd_card_t *card;
snd_pcm_t *pcm;
pcm = snd_es1688_new_device( card, port, mpu_port, irqnum, mpu_irqnum, dma8num, ES1688_HW_AUTO );
if ( !pcm ) return NULL;
...
if ( snd_pcm_register( pcm, 0 ) ) {
... unregister already registered devices ...
snd_pcm_free( pcm );
snd_card_free( card );
return -ENXIO;
}
...
snd_pcm_unregister( pcm );