Google
 

Open Sound System
The Hitchhiker's Guide to OSS 4.1 Internals

Do you have problems with sound/audio application development? Don't panic! Click here for help!

adrv_prepare_for_input

Audio driver method to prepare the device for recording

Usage

int (*adrv_prepare_for_input) (int dev, int fragsize, int nfrags);

Description

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 recording 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 read for the first time. It may also get called when an application calls SNDCTL_DSP_SETTRIGGER to start recording.

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_input the audio core will call adrv_start_input (if defined) and then adrv_trigger to finally trigger the device.

Parameters

ParameterDescription
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_in descriptor (audio_engines[dev]->dmap_in). The following fields of dmap_in are most useful.

FieldUsage
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).

Return value

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.

Referenced by

audio/oss_audio_core.cAudio core functionality of OSS
include/ossddk.hSource file oss-current/kernel/framework/include/ossddk/ossddk.h


Copyright (C) 4Front Technologies, 2007. All rights reserved.
Back to index OSS web site