|
PebbleOS v4.47.0-1362-gd278268fe
|
Interface for audio drivers. More...
Data Structures | |
| struct | pbl_audio_dai_ops |
| DAI driver operations. More... | |
| struct | pbl_audio_codec_cfg |
| Codec configuration for a stream. More... | |
| struct | pbl_audio_codec_ops |
| Codec driver operations, called with the lock of the card held. More... | |
| struct | pbl_audio_codec |
| A codec: a separate chip converting between the link and the analog side. More... | |
| struct | pbl_audio_amp_ops |
| Amplifier driver operations, called with the lock of the card held. More... | |
| struct | pbl_audio_amp |
| An amplifier between the output and the speaker, on while playing. More... | |
| struct | pbl_audio_link |
| What a device is wired to. More... | |
| struct | pbl_audio_dai |
| A digital audio interface of the SoC, streaming one direction or both. More... | |
| struct | pbl_audio |
| An audio device: a card, a DAI and what it is wired to, streaming both directions. More... | |
Macros | |
| #define | PBL_AUDIO_CODEC_INIT(sym, _name, _init, _parent, _ops) |
| Initializer of a struct pbl_audio_codec. | |
| #define | PBL_AUDIO_AMP_INIT(sym, _name, _init, _parent, _ops) |
| Initializer of a struct pbl_audio_amp. | |
| #define | PBL_AUDIO_DAI_STATE_DEFINE(sym) |
| Define the class state of a DAI. | |
| #define | PBL_AUDIO_DAI_INIT(sym, _name, _parent, _ops) |
| Initializer for a struct pbl_audio_dai. | |
| #define | PBL_AUDIO_CARD_DEFINE(sym, _name, _dai, _codec, _amp, _fmt, _clocks) |
| Define a card. | |
Functions | |
| static const struct pbl_audio * | pbl_audio_dai_card (const struct pbl_audio_dai *dai) |
| Get the card of a DAI, for drivers. | |
| void | pbl_audio_period_elapsed (const struct pbl_audio *audio, enum pbl_audio_dir dir) |
| Report the end of the period the hardware was working on. | |
| void | pbl_audio_report_xrun (const struct pbl_audio *audio, enum pbl_audio_dir dir) |
| Report a hardware overrun or underrun, flagged in the next callback. | |
| void * | pbl_audio_period (const struct pbl_audio *audio, enum pbl_audio_dir dir, uint8_t idx) |
| Get a period of a running stream, for drivers. | |
| static const struct pbl_audio_stream * | pbl_audio_stream (const struct pbl_audio *audio, enum pbl_audio_dir dir) |
| Get a running stream, for drivers. | |
| static int32_t | pbl_audio_gain_to_step (int32_t gain_mdb, int32_t min_mdb, int32_t step_mdb) |
| Convert a gain in mdB to the register steps of a hardware gain stage. | |
Link formats | |
Flags of struct pbl_audio_link::fmt. | |
| #define | PBL_AUDIO_FMT_I2S PBL_BIT(0) |
| I2S framing. | |
| #define | PBL_AUDIO_FMT_CODEC_MASTER PBL_BIT(1) |
| The codec drives the bit and frame clocks. | |
| #define | PBL_AUDIO_FMT_PDM PBL_BIT(2) |
| PDM: the 1-bit stream of digital microphones. | |
Interface for audio drivers.
A DAI driver embeds a struct pbl_audio_dai in its instance, sets it up with PBL_AUDIO_DAI_STATE_DEFINE() and PBL_AUDIO_DAI_INIT(), implements the struct pbl_audio_dai_ops the class calls and reports each period with pbl_audio_period_elapsed(). Codec and amplifier drivers embed a struct pbl_audio_codec or struct pbl_audio_amp, set up with PBL_AUDIO_CODEC_INIT() or PBL_AUDIO_AMP_INIT(). PBL_AUDIO_CARD_DEFINE() links them into a card.
| struct pbl_audio_codec_cfg |
Codec configuration for a stream.
| Data Fields | ||
|---|---|---|
| uint8_t | channels | Channels per frame on the link. |
| enum pbl_audio_dir | dir | Direction of the stream, one of pbl_audio_dir. |
| uint32_t | fmt |
Link format, PBL_AUDIO_FMT_* flags. |
| int32_t | gain_mdb | Gain, in mdB. |
| bool | mute | Mute. |
| uint32_t | rate | Sample rate, in Hz. |
| uint8_t | streaming |
Directions already streaming, with their path enabled, as PBL_BIT() of each. |
| struct pbl_audio_codec |
A codec: a separate chip converting between the link and the analog side.
| Data Fields | ||
|---|---|---|
| struct pbl_device | dev | Device. |
| const struct pbl_audio_codec_ops * | ops | Driver operations. |
| struct pbl_audio_amp |
An amplifier between the output and the speaker, on while playing.
| Data Fields | ||
|---|---|---|
| struct pbl_device | dev | Device. |
| const struct pbl_audio_amp_ops * | ops | Driver operations. |
| struct pbl_audio_link |
What a device is wired to.
| Data Fields | ||
|---|---|---|
| const struct pbl_audio_amp * | amp | Amplifier, or NULL. |
| const struct pbl_audio_codec * | codec | Codec on the link, or NULL. |
| uint32_t | fmt |
Link format, PBL_AUDIO_FMT_* flags. |
| struct pbl_audio_dai |
A digital audio interface of the SoC, streaming one direction or both.
| Data Fields | ||
|---|---|---|
| struct pbl_device | dev | Device. |
| const struct pbl_audio_dai_ops * | ops | Driver operations. |
| struct pbl_audio_dai_state * | state | Runtime state. |
| struct pbl_audio |
An audio device: a card, a DAI and what it is wired to, streaming both directions.
| Data Fields | ||
|---|---|---|
| const struct pbl_audio_dai * | dai | DAI. |
| struct pbl_device | dev | Device. |
| const struct pbl_audio_link * | link | What the DAI is wired to. |
| struct pbl_audio_state * | state | Runtime state. |
| #define PBL_AUDIO_AMP_INIT | ( | sym, | |
| _name, | |||
| _init, | |||
| _parent, | |||
| _ops | |||
| ) |
Initializer of a struct pbl_audio_amp.
| sym | Symbol of the amplifier. |
| _name | Name. |
| _init | Init function, or NULL. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
| #define PBL_AUDIO_CARD_DEFINE | ( | sym, | |
| _name, | |||
| _dai, | |||
| _codec, | |||
| _amp, | |||
| _fmt, | |||
| _clocks | |||
| ) |
Define a card.
| sym | Symbol of the card, a struct pbl_audio. |
| _name | Device name. |
| _dai | DAI. |
| _codec | Codec on the link, or NULL. |
| _amp | Amplifier, or NULL. |
| _fmt | Link framing, PBL_AUDIO_FMT_I2S, PBL_AUDIO_FMT_PDM or 0. |
| _clocks | Who drives the clocks, PBL_AUDIO_FMT_CODEC_MASTER or 0. |
| #define PBL_AUDIO_CODEC_INIT | ( | sym, | |
| _name, | |||
| _init, | |||
| _parent, | |||
| _ops | |||
| ) |
Initializer of a struct pbl_audio_codec.
| sym | Symbol of the codec. |
| _name | Name. |
| _init | Init function, or NULL. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
| #define PBL_AUDIO_DAI_INIT | ( | sym, | |
| _name, | |||
| _parent, | |||
| _ops | |||
| ) |
Initializer for a struct pbl_audio_dai.
| sym | Symbol of the instance, as passed to PBL_AUDIO_DAI_STATE_DEFINE(). |
| _name | Device name. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
| #define PBL_AUDIO_DAI_STATE_DEFINE | ( | sym | ) |
Define the class state of a DAI.
| sym | Symbol of the instance. |
| #define PBL_AUDIO_FMT_CODEC_MASTER PBL_BIT(1) |
The codec drives the bit and frame clocks.
| #define PBL_AUDIO_FMT_I2S PBL_BIT(0) |
I2S framing.
| #define PBL_AUDIO_FMT_PDM PBL_BIT(2) |
PDM: the 1-bit stream of digital microphones.
|
inlinestatic |
Get the card of a DAI, for drivers.
| dai | DAI. |
References pbl_audio::dai, and pbl_audio_dai::state.
|
inlinestatic |
Convert a gain in mdB to the register steps of a hardware gain stage.
| gain_mdb | Gain in mdB. |
| min_mdb | Gain of step 0, in mdB. |
| step_mdb | Gain per step, in mdB. |
| void * pbl_audio_period | ( | const struct pbl_audio * | audio, |
| enum pbl_audio_dir | dir, | ||
| uint8_t | idx | ||
| ) |
Get a period of a running stream, for drivers.
| audio | Device. |
| dir | Direction, one of pbl_audio_dir. |
| idx | Period index, below the number of periods. |
| void pbl_audio_period_elapsed | ( | const struct pbl_audio * | audio, |
| enum pbl_audio_dir | dir | ||
| ) |
Report the end of the period the hardware was working on.
Called by drivers from their interrupt handler, once per period, in ring order.
| audio | Device. |
| dir | Direction, one of pbl_audio_dir. |
| void pbl_audio_report_xrun | ( | const struct pbl_audio * | audio, |
| enum pbl_audio_dir | dir | ||
| ) |
Report a hardware overrun or underrun, flagged in the next callback.
Called by drivers, from any context.
| audio | Device. |
| dir | Direction, one of pbl_audio_dir. |
|
inlinestatic |
Get a running stream, for drivers.
| audio | Device. |
| dir | Direction, one of pbl_audio_dir. |
References pbl_audio::state.