Device driver
[Developer Documentation]


Detailed Description

OSS device driver.


Modules

group  PCM conversion
 convert PCM from and to internal format.

group  Sub-devices
 Common to read/write opened device.


Data Structures

struct  _liso_t
 lisodsp info structure. More...


Init functions

int liso_device_init (liso_t *lisodsp)
 Init device driver.

int liso_device_shutdown (liso_t *lisodsp)
 Shutdown device driver.


Wake up functions

void liso_wakeup_writers (liso_t *lisodsp)
 Wake up sleepy writers.

void liso_wakeup_reader (liso_t *lisodsp)
 Wake up sleepy reader.


Timer functions

start/stop device timer.

The timer is used to simulate the device reader by flushing out PCM silently at a given rate. It allows user process to keep time synchronizing themself with the write() function by assuming it is blocking. The PCM-fragment size depends directly on Linux timer granularity (as defined by the HZ constant in linux source) in a manner that the time to play a fragment must be a multiple of the timer period (1/HZ second).

int liso_timer_start (liso_t *lisodsp, unsigned int offset, void(*task)(void *))
 Start the timer.

int liso_timer_stop (liso_t *lisodsp)
 Stop the timer.


Defines

#define LISO_MAX_SUBDEV   (sizeof(int)<<3)
 Maximum number of sub-device.

#define LISO_MAX_CHANNEL   (LISO_MAX_SUBDEV-1)
 Maximum number of mixed channel (device writer).

#define LISO_DEF_CHANNEL   8
 Default maximum number of mixed channel.

#define LISO_RD_CHANNEL   LISO_MAX_CHANNEL
 Channel id reserved for reader.

#define LISO_RD_MASK   (1<<LISO_RD_CHANNEL)
 Bit mask for reader.

#define LISO_DEF_SAMPLING   44100
 Maximal sampling rate.

#define LISO_MAX_SAMPLING   48000
 Maximal sampling rate.

#define LISO_MIN_SAMPLING   (LISO_MAX_SAMPLING/10)
 Minimal sampling rate.

#define LISO_DEF_FORMAT_STR   "S2WN"
 Default format string ([S]igned [2]-channel [W]ord [N]ative-endian).

#define LISO_MIXER_FIX   14
 Mixer scale factor fixed point bit.


Functions

int liso_device_update_active (liso_t *const lisodsp)
 Check active status for all sub-devices.

int liso_device_active_writers (const liso_t *const lisodsp)
 Get current active writers.


Variables

liso_t g_lisodsp
 The global lisodsp object.

int liso_volume []
 Attenuation factors.


Define Documentation

#define LISO_MAX_SUBDEV   (sizeof(int)<<3)
 

Maximum number of sub-device.

Because of the status bit implementation the very limit is fixed to the number of bit per integer.

#define LISO_MAX_CHANNEL   (LISO_MAX_SUBDEV-1)
 

Maximum number of mixed channel (device writer).

Since the last device is reserved for the unique reader the very maximum number of channel is fixed to LISO_MAX_SUBDEV-1.

#define LISO_MIXER_FIX   14
 

Mixer scale factor fixed point bit.

Note:
This value should prevent overflow for all integer width cases (at least 32 bit) because the number of voice is limited to the number of bit of an integer and the operations are done into integer variables.


Function Documentation

int liso_device_update_active liso_t *const  lisodsp  ) 
 

Check active status for all sub-devices.

This function updates the lisodsp::active_devices bitfield. Each bit weight match the status of the corresponding sub-devices with a 1 if this sub-device is active.

Parameters:
lisodsp pointer to lisodsp device.
Returns:
updated lisodsp::active_devices value.

int liso_device_active_writers const liso_t *const  lisodsp  )  [inline, static]
 

Get current active writers.

Parameters:
lisodsp pointer to lisodsp device.
Returns:
active writer bitfield
return lisodsp->active_devices & ~(1 << LISO_RD_CHANNEL);

void liso_wakeup_writers liso_t lisodsp  )  [inline, static]
 

Wake up sleepy writers.

Parameters:
lisodsp pointer to lisodsp device.
wake_up_interruptible(&lisodsp->wr_waitq);

void liso_wakeup_reader liso_t lisodsp  )  [inline, static]
 

Wake up sleepy reader.

Parameters:
lisodsp pointer to lisodsp device.
wake_up_interruptible(&lisodsp->rd_waitq);

int liso_timer_start liso_t lisodsp,
unsigned int  offset,
void(*  task)(void *)
 

Start the timer.

This function reset the timer and starts it at a virtual rate of sampling/frag_size Hz.

Parameters:
lisodsp lisodsp device
offset Number of jiffies between two timer interruptions. In other words the frequency of the timer is HZ/offset.
task Function to be queued by timer for delayed execution in the scheduler context. 0 for none.
Returns:
error-code
Return values:
-EINVAL Invalid offset value.
-EAGAIN Stopping previous timer has failed
-EINTR Locking interrupted

int liso_timer_stop liso_t lisodsp  ) 
 

Stop the timer.

Parameters:
lisodsp lisodsp device
Returns:
error-code
Return values:
-EAGAIN Stopping timer has failed
-EINTR Locking interrupted


Variable Documentation

liso_t g_lisodsp
 

The global lisodsp object.

Currently the only reason for having this variable in the global scope is that the Linux kernel function register_sound_dsp() does not allow to have a private data (or may be I just dunno how). Currently this module provides only one lisodsp device so more esthetic consideration than a real issue.

int liso_volume[]
 

Attenuation factors.

Table of attenuation factors for a given number of mixed channel. It is initialized at module startup with a very empiric formula which aims to prevent saturation when many channels are mixed but trying to keep each voice at a high enought level to prevent hearable attenuations.

Let:

  • F : the attenuation factor
  • C : the constant with 0 <= C <= 1 (currently 0.7)
  • N : the number of mixed channel with N an integer > 0

Attenuation factor is:

\[ F = C + (1-C) / \sqrt{N} \]


lisodsp logo lisodsp developer documentation
version 0.5.0
Generated on June 2004
by doxygen 1.3.7