/home/hillier_g/checkout/most4linux/most-kernel/most-alsa.c File Reference

ALSA Driver for MOST. More...

Go to the source code of this file.

Defines

#define DRIVER_NAME   "most-alsa"
#define PR   DRIVER_NAME ": "
#define MOST_SYNC_DEV_TEMPLATE   "/dev/mostsync%d"

Functions

static int snd_most_playback_setup_sync_file (struct most_alsa_dev *alsa_dev, struct file **filp)
static int snd_most_playback_thread (void *data)
static int snd_most_playback_open (struct snd_pcm_substream *substream)
static int snd_most_playback_close (struct snd_pcm_substream *substream)
static int snd_most_playback_hw_params (struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params)
static int snd_most_playback_hw_free (struct snd_pcm_substream *substream)
static int snd_most_playback_prepare (struct snd_pcm_substream *substream)
static int snd_most_playback_trigger (struct snd_pcm_substream *substream, int cmd)
static snd_pcm_uframes_t snd_most_playback_pointer (struct snd_pcm_substream *substream)
static int snd_most_capture_setup_sync_file (struct most_alsa_dev *alsa_dev, struct file **filp)
static int snd_most_capture_thread (void *data)
static int snd_most_capture_open (struct snd_pcm_substream *substream)
static int snd_most_capture_close (struct snd_pcm_substream *substream)
static int snd_most_capture_hw_params (struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params)
static int snd_most_capture_hw_free (struct snd_pcm_substream *substream)
static int snd_most_capture_prepare (struct snd_pcm_substream *substream)
static int snd_most_capture_trigger (struct snd_pcm_substream *substream, int cmd)
static snd_pcm_uframes_t snd_most_capture_pointer (struct snd_pcm_substream *substream)
static int __devinit snd_most_new_pcm (struct most_alsa_dev *alsa_dev)
static void snd_most_free (struct snd_card *card)
static int __devinit snd_most_create (struct snd_card *card, struct most_dev *most_dev)
static int most_alsa_remove (struct most_dev *most_dev)
static int most_alsa_probe (struct most_dev *most_dev)
static void most_alsa_int_handler (struct most_dev *dev, unsigned int intstatus)
static int __init most_alsa_init (void)
static void __exit most_alsa_exit (void)

Variables

static char * version = "$Rev: 641 $"
most_alsa_devmost_alsa_devices [MOST_DEVICE_NUMBER]
static int index [SNDRV_CARDS] = SNDRV_DEFAULT_IDX
static char * id [SNDRV_CARDS] = SNDRV_DEFAULT_STR
static int enable [SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP
static int playback_offset [SNDRV_CARDS] = { [0 ... SNDRV_CARDS-1] = 0 }
static int capture_offset [SNDRV_CARDS] = { [0 ... SNDRV_CARDS-1] = 0 }
static struct snd_pcm_hardware snd_most_playback_hw
static struct snd_pcm_hardware snd_most_capture_hw
static struct snd_pcm_ops snd_most_playback_ops
static struct snd_pcm_ops snd_most_capture_ops
static struct most_high_driver most_alsa_high_driver


Detailed Description

ALSA Driver for MOST.

Definition in file most-alsa.c.


Define Documentation

#define DRIVER_NAME   "most-alsa"

The name of the driver.

Definition at line 51 of file most-alsa.c.

Referenced by most_alsa_exit(), most_alsa_init(), most_base_exit(), most_base_init(), most_nets_exit(), most_nets_init(), most_pci_exit(), most_pci_init(), most_sync_exit(), most_sync_init(), most_sync_rt_exit(), and most_sync_rt_init().

#define PR   DRIVER_NAME ": "

The prefix for printk outputs.

Definition at line 56 of file most-alsa.c.

Referenced by dma_allocate(), dma_deallocate(), get_license(), handle_interrupt(), intset(), ioctl_irq_reset(), ioctl_irq_set(), ioctl_read_int(), ioctl_read_regblock(), ioctl_read_register(), ioctl_write_regblock(), ioctl_write_register(), keyctrl_reset(), manage_usage(), most_alsa_exit(), most_alsa_init(), most_alsa_probe(), most_alsa_remove(), most_nets_open(), most_nets_release(), most_sync_do_open(), most_sync_do_release(), most_sync_int_handler(), most_sync_nrt_close(), most_sync_nrt_open(), most_sync_nrt_setup_rx(), most_sync_probe(), most_sync_read(), most_sync_remove(), most_sync_rt_interrupt_handler(), most_sync_rt_probe(), most_sync_rt_remove(), most_sync_write(), nets_probe(), nets_remove(), probe(), readreg_int(), revision(), rxbuf_alloc(), rxbuf_get(), rxbuf_put(), snd_most_capture_close(), snd_most_capture_hw_free(), snd_most_capture_hw_params(), snd_most_capture_open(), snd_most_capture_prepare(), snd_most_capture_setup_sync_file(), snd_most_capture_thread(), snd_most_capture_trigger(), snd_most_new_pcm(), snd_most_playback_close(), snd_most_playback_hw_free(), snd_most_playback_hw_params(), snd_most_playback_open(), snd_most_playback_prepare(), snd_most_playback_setup_sync_file(), snd_most_playback_thread(), snd_most_playback_trigger(), txbuf_alloc(), txbuf_get(), txbuf_put(), and writereg_int().

#define MOST_SYNC_DEV_TEMPLATE   "/dev/mostsync%d"

Template for a MOST synchronous file

Definition at line 61 of file most-alsa.c.

Referenced by snd_most_capture_setup_sync_file(), and snd_most_playback_setup_sync_file().


Function Documentation

static int snd_most_playback_setup_sync_file ( struct most_alsa_dev alsa_dev,
struct file **  filp 
) [static]

Sets up the MOST synchronous transmission for playback.

Parameters:
[in] alsa_dev the MOST ALSA device
[out] filp the struct file that is set to the newly created file pointer

Definition at line 147 of file most-alsa.c.

References most_alsa_dev::card, frame_part::count, most_alsa_dev::most_dev, MOST_DEV_CARDNUMBER, MOST_SYNC_DEV_TEMPLATE, most_sync_setup_tx(), frame_part::offset, playback_offset, PR, and rtnrt_warn.

Referenced by snd_most_playback_thread().

static int snd_most_playback_thread ( void *  data  )  [static]

Kernel thread that read the audio data from the ALSA buffer and calls most_sync_write(). It gets triggered from the interrupt handler

Parameters:
[in] data the struct most_alsa_dev

Definition at line 190 of file most-alsa.c.

References most_sync_write(), most_alsa_dev::p_buf_setup_sema, most_alsa_dev::p_buffer_mutex, most_alsa_dev::p_completion, most_alsa_dev::p_cur_period, most_alsa_dev::p_event, most_alsa_dev::p_silent, most_alsa_dev::p_substream, most_alsa_dev::p_thread_id, most_alsa_dev::p_thread_sema, PR, pr_alsa_debug, rtnrt_memmove(), rtnrt_warn, snd_most_playback_setup_sync_file(), and swap_bytes().

Referenced by snd_most_playback_open().

static int snd_most_playback_open ( struct snd_pcm_substream *  substream  )  [static]

Opens the playback stream. Initialises the snd_most_playback_hw structure and assigns it to the hw element of the runtime. Creates the kernel thread.

Parameters:
[in,out] substream the ALSA substream
Returns:
0 on success, an error code on failure

Definition at line 334 of file most-alsa.c.

References hw_tx_buffer_size, most_alsa_dev::p_buf_setup_sema, most_alsa_dev::p_buffer_mutex, most_alsa_dev::p_completion, most_alsa_dev::p_cur_period, most_alsa_dev::p_event, most_alsa_dev::p_silent, most_alsa_dev::p_substream, most_alsa_dev::p_thread_id, most_alsa_dev::p_thread_sema, PR, pr_alsa_debug, rtnrt_warn, snd_most_playback_hw, snd_most_playback_thread(), and sw_tx_buffer_size.

static int snd_most_playback_close ( struct snd_pcm_substream *  substream  )  [static]

Closes the substream. Kills the kernel thread.

Parameters:
[in] substream the ALSA substream
Returns:
0 on success, an error code on failure

Definition at line 393 of file most-alsa.c.

References most_alsa_dev::p_completion, most_alsa_dev::p_substream, most_alsa_dev::p_thread_id, PR, and pr_alsa_debug.

static int snd_most_playback_hw_params ( struct snd_pcm_substream *  substream,
struct snd_pcm_hw_params *  hw_params 
) [static]

Sets up the hardware. Triggers the mutex that signalises the kernel thread that the buffer has been setup initially.

Parameters:
[in] substream the ALSA substream
[in] hw_params the hardware parameters
Returns:
0 on success, an error code on failure

Definition at line 417 of file most-alsa.c.

References most_alsa_dev::most_dev, most_alsa_dev::p_buf_setup_sema, most_alsa_dev::p_buffer_mutex, most_alsa_dev::p_silent, PR, pr_alsa_debug, and rtnrt_warn.

static int snd_most_playback_hw_free ( struct snd_pcm_substream *  substream  )  [static]

Reverts the setup of the hardware. Frees the buffer.

Parameters:
[in] substream the ALSA substream
Returns:
0 on success, an error code on failure

Definition at line 453 of file most-alsa.c.

References most_alsa_dev::p_silent, PR, and pr_alsa_debug.

static int snd_most_playback_prepare ( struct snd_pcm_substream *  substream  )  [static]

Prepare handler. Only modifies the position pointer for the buffer.

Parameters:
[in] substream the ALSA substream
Returns:
0 on success, an error code on failure

Definition at line 470 of file most-alsa.c.

References most_alsa_dev::p_cur_period, PR, and pr_alsa_debug.

static int snd_most_playback_trigger ( struct snd_pcm_substream *  substream,
int  cmd 
) [static]

Trigger handler. Gets called on start and stop. Modifies the playback_silent member of the struct most_alsa_dev.

Parameters:
[in] substream the ALSA substream
[in] cmd the command -- either SNDRV_PCM_TRIGGER_START or SNDRV_PCM_TRIGGER_START
Returns:
0 on success, an error code on failure

Definition at line 501 of file most-alsa.c.

References most_alsa_dev::p_silent, PR, and pr_alsa_debug.

static snd_pcm_uframes_t snd_most_playback_pointer ( struct snd_pcm_substream *  substream  )  [static]

Pointer handler. Returns the current position of the buffer access in the kernel thread.

Parameters:
[in] substream the ALSA substream
Returns:
the current position

Definition at line 526 of file most-alsa.c.

References most_alsa_dev::p_cur_period.

static int snd_most_capture_setup_sync_file ( struct most_alsa_dev alsa_dev,
struct file **  filp 
) [static]

Sets up the MOST synchronous reception for capture.

Parameters:
[in] alsa_dev the MOST ALSA device
[out] filp the struct file that is set to the newly created file pointer

Definition at line 547 of file most-alsa.c.

References capture_offset, most_alsa_dev::card, frame_part::count, most_alsa_dev::most_dev, MOST_DEV_CARDNUMBER, MOST_SYNC_DEV_TEMPLATE, most_sync_setup_rx(), frame_part::offset, PR, and rtnrt_warn.

Referenced by snd_most_capture_thread().

static int snd_most_capture_thread ( void *  data  )  [static]

Kernel thread that read the audio data from the MOST buffer by calling most_sync_read() and writes it into the ALSA buffer. It gets triggered from the interrupt handler

Parameters:
[in] data the struct most_alsa_dev

Definition at line 590 of file most-alsa.c.

References most_alsa_dev::c_buf_setup_sema, most_alsa_dev::c_buffer_mutex, most_alsa_dev::c_completion, most_alsa_dev::c_cur_period, most_alsa_dev::c_silent, most_alsa_dev::c_substream, most_alsa_dev::c_thread_id, most_alsa_dev::c_thread_sema, most_sync_read(), PR, pr_alsa_debug, rtnrt_memmove(), snd_most_capture_setup_sync_file(), and swap_bytes().

Referenced by snd_most_capture_open().

static int snd_most_capture_open ( struct snd_pcm_substream *  substream  )  [static]

Opens the capture stream. Initialises the snd_most_capture_hw structure and assigns it to the hw element of the runtime. Creates the kernel thread.

Parameters:
[in,out] substream the ALSA substream
Returns:
0 on success, an error code on failure

Definition at line 706 of file most-alsa.c.

References most_alsa_dev::c_buf_setup_sema, most_alsa_dev::c_buffer_mutex, most_alsa_dev::c_completion, most_alsa_dev::c_cur_period, most_alsa_dev::c_silent, most_alsa_dev::c_substream, most_alsa_dev::c_thread_id, most_alsa_dev::c_thread_sema, hw_tx_buffer_size, PR, pr_alsa_debug, rtnrt_warn, snd_most_capture_thread(), and sw_tx_buffer_size.

static int snd_most_capture_close ( struct snd_pcm_substream *  substream  )  [static]

Closes the substream. Closes the MOST synchronous device.

Parameters:
[in] substream the ALSA substream
Returns:
0 on success, an error code on failure

Definition at line 764 of file most-alsa.c.

References most_alsa_dev::c_completion, most_alsa_dev::c_substream, most_alsa_dev::c_thread_id, PR, and pr_alsa_debug.

static int snd_most_capture_hw_params ( struct snd_pcm_substream *  substream,
struct snd_pcm_hw_params *  hw_params 
) [static]

Sets up the hardware. Triggers the mutex that signalises the kernel thread that the buffer has been setup initially.

Parameters:
[in] substream the ALSA substream
[in] hw_params the hardware parameters
Returns:
0 on success, an error code on failure

Definition at line 788 of file most-alsa.c.

References most_alsa_dev::c_buf_setup_sema, most_alsa_dev::c_buffer_mutex, most_alsa_dev::c_silent, most_alsa_dev::most_dev, PR, pr_alsa_debug, and rtnrt_warn.

static int snd_most_capture_hw_free ( struct snd_pcm_substream *  substream  )  [static]

Reverts the setup of the hardware. Frees the buffer.

Parameters:
[in] substream the ALSA substream
Returns:
0 on success, an error code on failure

Definition at line 824 of file most-alsa.c.

References most_alsa_dev::c_silent, PR, and pr_alsa_debug.

static int snd_most_capture_prepare ( struct snd_pcm_substream *  substream  )  [static]

Prepare handler. Only modifies the position pointer for the buffer.

Parameters:
[in] substream the ALSA substream
Returns:
0 on success, an error code on failure

Definition at line 841 of file most-alsa.c.

References most_alsa_dev::c_cur_period, PR, and pr_alsa_debug.

static int snd_most_capture_trigger ( struct snd_pcm_substream *  substream,
int  cmd 
) [static]

Trigger handler. Gets called on start and stop. Modifies the capture_silent member of the struct most_alsa_dev.

Parameters:
[in] substream the ALSA substream
[in] cmd the command -- either SNDRV_PCM_TRIGGER_START or SNDRV_PCM_TRIGGER_START
Returns:
0 on success, an error code on failure

Definition at line 872 of file most-alsa.c.

References most_alsa_dev::c_silent, PR, and pr_alsa_debug.

static snd_pcm_uframes_t snd_most_capture_pointer ( struct snd_pcm_substream *  substream  )  [static]

Pointer handler. Returns the current position of the buffer access in the kernel thread.

Parameters:
[in] substream the ALSA substream
Returns:
the current position

Definition at line 897 of file most-alsa.c.

References most_alsa_dev::c_cur_period.

static int __devinit snd_most_new_pcm ( struct most_alsa_dev alsa_dev  )  [static]

Sets up the PCM device in ALSA.

Parameters:
[in,out] alsa_dev the most_alsa_dev structure
Returns:
0 on success, an error code on failure

Definition at line 946 of file most-alsa.c.

References most_alsa_dev::card, hw_rx_buffer_size, hw_tx_buffer_size, most_alsa_dev::pcm, PR, and rtnrt_warn.

Referenced by most_alsa_probe().

static void snd_most_free ( struct snd_card *  card  )  [static]

Deinitialises the struct most_alsa_dev elements

Parameters:
card the sound card

Definition at line 992 of file most-alsa.c.

Referenced by snd_most_create().

static int __devinit snd_most_create ( struct snd_card *  card,
struct most_dev most_dev 
) [static]

Creates the ALSA MOST Device and stores the data.

Parameters:
card the soundcard
most_dev the MOST device

Definition at line 1004 of file most-alsa.c.

References ALSA_DEV, most_alsa_dev::card, most_alsa_dev::most_dev, and snd_most_free().

Referenced by most_alsa_probe().

static int most_alsa_remove ( struct most_dev most_dev  )  [static]

Gets called by the MOST Base driver when a MOST device was removed.

Parameters:
most_dev the most_dev that was discovered
Returns:
0 on success, an error code on failure

Definition at line 1025 of file most-alsa.c.

References most_alsa_dev::card, most_alsa_devices, most_alsa_dev::most_dev, MOST_DEV_CARDNUMBER, PR, and pr_alsa_debug.

static int most_alsa_probe ( struct most_dev most_dev  )  [static]

Gets called by the MOST driver when a new MOST device was discovered.

Parameters:
[in,out] most_dev the most_dev that was discovered
Returns:
0 on success, an error code on failure

Definition at line 1044 of file most-alsa.c.

References ALSA_DEV, most_dev::card_number, enable, index, most_alsa_devices, MOST_DEV_CARDNUMBER, PR, pr_alsa_debug, snd_most_create(), and snd_most_new_pcm().

static void most_alsa_int_handler ( struct most_dev dev,
unsigned int  intstatus 
) [static]

Interrupt handler. Wakes up the kernel thread. The reason why not the blocking facility of most_sync_write() is used is that the buffer is not filled entirely and the latency is kept small.

Parameters:
[in] dev the MOST device
[in] intstatus the interrupt status which is used to discriminiate between receive and transmit interrupts

Definition at line 1102 of file most-alsa.c.

References IESTX, most_alsa_devices, MOST_DEV_CARDNUMBER, most_alsa_dev::p_event, and most_alsa_dev::p_thread_id.

static int __init most_alsa_init ( void   )  [static]

This function gets called if the kernel loads this module.

Returns:
0 on success, an error code on failure

Definition at line 1139 of file most-alsa.c.

References DRIVER_NAME, most_alsa_high_driver, most_register_high_driver(), PR, rtnrt_info, and version.

static void __exit most_alsa_exit ( void   )  [static]

This function gets called if the Kernel removes this module.

Definition at line 1157 of file most-alsa.c.

References DRIVER_NAME, most_alsa_high_driver, most_deregister_high_driver(), PR, rtnrt_info, and version.


Variable Documentation

char* version = "$Rev: 641 $" [static]

Variable that holds the version.

Definition at line 70 of file most-alsa.c.

Referenced by most_alsa_exit(), most_alsa_init(), most_base_exit(), most_base_seq_start(), most_nets_exit(), most_nets_init(), most_pci_exit(), most_pci_init(), most_sync_exit(), most_sync_init(), most_sync_rt_exit(), and most_sync_rt_init().

struct most_alsa_dev* most_alsa_devices[MOST_DEVICE_NUMBER]

Array for each device.

Definition at line 75 of file most-alsa.c.

Referenced by most_alsa_int_handler(), most_alsa_probe(), and most_alsa_remove().

int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX [static]

Index value for the MOST sound device.

Definition at line 84 of file most-alsa.c.

Referenced by most_alsa_probe().

char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR [static]

IDs for the MOST sound card.

Definition at line 89 of file most-alsa.c.

int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP [static]

Whether the card should be enabled or not.

Definition at line 94 of file most-alsa.c.

Referenced by most_alsa_probe().

int playback_offset[SNDRV_CARDS] = { [0 ... SNDRV_CARDS-1] = 0 } [static]

The offset in bytes for accessing the buffer for the synchronous transfer in transmit direction.

See also:
MOST_SYNC_SETUP_TX

struct frame_part

Definition at line 103 of file most-alsa.c.

Referenced by snd_most_playback_setup_sync_file().

int capture_offset[SNDRV_CARDS] = { [0 ... SNDRV_CARDS-1] = 0 } [static]

The offset in bytes for accessing the buffer for the synchronous transfer in receive direction.

See also:
MOST_SYNC_SETUP_RX

struct frame_part

Definition at line 112 of file most-alsa.c.

Referenced by snd_most_capture_setup_sync_file().

struct snd_pcm_hardware snd_most_playback_hw [static]

Initial value:

 {
    .info               = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP),
    .formats            = SNDRV_PCM_FMTBIT_S16_LE,
    .rates              = SNDRV_PCM_RATE_44100,
    .rate_min           = 44100,
    .rate_max           = 44100,
    .channels_min       = 2,
    .channels_max       = 2,
    .periods_min        = 2,
    .periods_max        = 8
}
Hardware parameters for the playback device

Definition at line 314 of file most-alsa.c.

Referenced by snd_most_playback_open().

struct snd_pcm_hardware snd_most_capture_hw [static]

Initial value:

 {
    .info               = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP),
    .formats            = SNDRV_PCM_FMTBIT_S16_LE,
    .rates              = SNDRV_PCM_RATE_44100,
    .rate_min           = 44100,
    .rate_max           = 44100,
    .channels_min       = 2,
    .channels_max       = 2,
    .periods_min        = 2,
    .periods_max        = 8
}
Hardware parameters for the capture device

Definition at line 686 of file most-alsa.c.

struct snd_pcm_ops snd_most_playback_ops [static]

Initial value:

 {
    .open       = snd_most_playback_open,
    .close      = snd_most_playback_close,
    .ioctl      = snd_pcm_lib_ioctl,
    .hw_params  = snd_most_playback_hw_params,
    .hw_free    = snd_most_playback_hw_free,
    .prepare    = snd_most_playback_prepare,
    .trigger    = snd_most_playback_trigger,
    .pointer    = snd_most_playback_pointer,
}
Playback operations for the MOST PCM device

Definition at line 914 of file most-alsa.c.

struct snd_pcm_ops snd_most_capture_ops [static]

Initial value:

 {
    .open       = snd_most_capture_open,
    .close      = snd_most_capture_close,
    .ioctl      = snd_pcm_lib_ioctl,
    .hw_params  = snd_most_capture_hw_params,
    .hw_free    = snd_most_capture_hw_free,
    .prepare    = snd_most_capture_prepare,
    .trigger    = snd_most_capture_trigger,
    .pointer    = snd_most_capture_pointer,
}
Capture operations for the MOST PCM device

Definition at line 928 of file most-alsa.c.

struct most_high_driver most_alsa_high_driver [static]

Initial value:

 {
    .name               = "most-alsa",
    .sema_list          = LIST_HEAD_INIT(most_alsa_high_driver.sema_list),
    .spin_list          = LIST_HEAD_INIT(most_alsa_high_driver.spin_list),
    .probe              = most_alsa_probe,
    .remove             = most_alsa_remove,
    .int_handler        = most_alsa_int_handler,
    .interrupt_mask     = (IESTX | IESRX)
}
The structure for the MOST High driver that is registered by the MOST PCI driver. No interrupt handlers are needed in this driver.

Definition at line 1120 of file most-alsa.c.

Referenced by most_alsa_exit(), and most_alsa_init().


Generated on Fri Mar 9 14:48:58 2007 for MOST Linux Drivers (Linux and RTAI) by  doxygen 1.5.0