Open Sound System |
Do you have problems with sound/audio application development? Don't panic! Click here for help! |
int (*adrv_prepare_for_output) (int dev, int fragsize, int nfrags);
The first paramater (dev
) is anways the audio engine number which is an index to the audio_engines table. The driver can use the audio_engines entry to find out some of the current parameters. In particular the devc, portc, portc_play and portc_record fields can be used to locate the driver defined structures for the audio engine.
Purpose of this audio driver method is to prepare the audio engine to be ready to start playback after a moment (however recording should not be started yet).
Audio core will call this function as the first action when the application has called write for the first time. It may also get called when an application calls SNDCTL_DSP_SETTRIGGER to start playback.
Typically this method initializes the device registers for sample rate, format and number of channels. In addition it should program the DMA related registers and set the interrupts to tick on fragment boundaries. If there are any problems with setting up the device this function can return negative error number (such as -EIO). Otherwise it should return 0.
After adrv_prepare_for_output the audio core will call adrv_output_block (if defined) and then adrv_trigger to finally trigger the device.
Parameter | Description |
fragsize | Fragment size in bytes. |
nfrags | Number of fragments to transfer |
In addition to the above parameters this method may use fields of the adev_t structure (audio_engines[dev]
) and in particular the dmap_out descriptor (audio_engines[dev]->dmap_out). The following fields of dmap_out are most useful.
Field | Usage |
dmabuf_phys | Program the DMA start address register to point to this address. |
fragment_size | Size of one buffer fragment (in bytes). Program the device raise an interrupt on every fragment boundary. |
bytes_in_use | Number of bytes used from the DMA buffer. Parts of the allocated DMA buffer may be unused if the application has requested smalled buffer than the default. The driver should program this value to the DMA transfer size register (if the device has one). |
Audio driver entry point should return 0 if the call was successful. Negative return value (-errno) means that an error has occurred. However some of the functions have void type and they don't return any value.
audio/oss_audio_core.c | Audio core functionality of OSS |
include/ossddk.h | Source file oss-current/kernel/framework/include/ossddk/ossddk.h |
remux/oss_remux.c | Multi channel playback support for devices with multiple stereo engines. |