API versions 0 and 1 are currently defined.
API version 0 is a simplistic version of the API, where most of the work is performed directly by the SoundDMA? module.
struct haldeviceaudio_audc
{
struct device;
struct haldeviceaudio_mixer *mixer;
unsigned int channels_out;
unsigned int channels_in;
}
mixer points to the mixer device associated with this sound output device. channels_out and channels_in contain the number of output and input channels supported by the device.
API version 1 extends the haldevice_audc struct, allowing the HAL device to implement all the device-specific functionality that was previously in SoundDMA.
struct haldevice_audc_1
{
/* Version 0 interface */
struct haldevice_audc dev;
/* 1.0 extension */
uint32_t dmaparams[5];
void (*PreEnable)(struct haldevice_audc_1 *, uint32_t dmabufsize);
void (*PostEnable)(struct haldevice_audc_1 *, uint32_t dmabufsize);
void (*PreDisable)(struct haldevice_audc_1 *);
void (*PostDisable)(struct haldevice_audc_1 *);
uint32_t (*IRQHandle)(struct haldevice_audc_1 *);
uint32_t numrates;
struct audioratetable *ratetable;
void (*SetRate)(struct haldevice_audc_1 *, uint32_t index);
};
The dmaparams array contains the values of R0, R1, R2, R3 and R7 to provide to DMA_RegisterChannel? when SoundDMA module registers itself with DMAManager?.
The PreEnable and PostEnable calls are made when audio is being enabled. They are both called with IRQs enabled, and with dmabufsize specifying the size of the DMA buffer that is in use (in bytes). The driver should use dmabufsize to program the controller as required, e.g. setting FIFO threshold levels. PreEnable will be called before DMA is enabled, and PostEnable will be called after DMA is enabled.
The PreDisable and PostDisable calls are made when audio is being disabled. As with the Enable calls, IRQs will be enabled, and PreDisable will be called before DMA is disabled, while PostDisable will be called after DMA has been disabled.
If the device specifies an IRQ device number, then IRQHandle will be called whenever an interrupt is received from the device, whether audio is currently enabled or not. The return code of IRQHandle indicates what action the SoundDMA module should take:
| Return code | Meaning |
|---|---|
| 0 | No action necessary |
| 1 | Audio reset required (i.e. turn audio off and then on again). This return code has no effect if audio is already off. |
| Other values | Reserved |
numrates specifies the number of entries in the sample rate table. The sample rate table, pointed to by ratetable is an array of audioratetable structures:
struct audioratetable
{
uint32_t frequency; // Frequency in Hz
uint8_t period; // Period in usec
uint8_t reserved[3]; // Reserved - can be used by audio device
};
The entries in the sample rate table must be in order of increasing frequency.
SetRate is used to set the current sample rate. The index parameter is a 0-based index into ratetable, indicating the sample rate to use. The sample rate will only be modified while audio is turned off.
The Sound0Trid version of the SoundDMA module only supports API version 0.×.
The Sound0HAL version of the SoundDMA module only supports API version 1.×.
| Device ID | Description | Implemented in |
|---|---|---|
| HALDeviceID_AudC_M5451 | Acer M5451 AC’97 controller | HAL.Tungsten.s.Audio |
| HALDeviceID_AudC_TPS65950 | TPS65950-compatible audio controller | HAL.OMAP3.s.Audio |