Create an identifier.
Free a string list.
Obtain a list of entries.
Get current - string.
Get current - integer.
Set new.
Open and initialise use case core for sound card.
Reload and re-parse use case configuration files for sound card.
Close use case manager.
Reset use case manager verb, device, modifier to deafult settings.
Parse control element identifier.
Parse mixer element identifier.
Detailed Description
The ALSA Use Case manager interface. See ALSA Use Case Interface page for more details.
ALSA Use Case Interface
The use case manager works by configuring the sound card ALSA kcontrols to change the hardware digital and analog audio routing to match the requested device use case. The use case manager kcontrol configurations are stored in easy to modify text files.An audio use case can be defined by a verb and device parameter. The verb describes the use case action i.e. a phone call, listening to music, recording a conversation etc. The device describes the physical audio capture and playback hardware i.e. headphones, phone handset, bluetooth headset, etc.It's intended clients will mostly only need to set the use case verb and device for each system use case change (as the verb and device parameters cover most audio use cases).However there are times when a use case has to be modified at runtime. e.g.
- Incoming phone call when the device is playing music
- Recording sections of a phone call
- Playing tones during a call.
In order to allow asynchronous runtime use case adaptations, we have a third optional modifier parameter that can be used to further configure the use case during live audio runtime.This interface allows clients to :-
- Query the supported use case verbs, devices and modifiers for the machine.
- Set and Get use case verbs, devices and modifiers for the machine.
- Get the ALSA PCM playback and capture device PCMs for use case verb, use case device and modifier.
- Get the TQ parameter for each use case verb, use case device and modifier.
- Get the ALSA master playback and capture volume/switch kcontrols or mixer elements for each use case.
Macro Definition Documentation
◆ SND_USE_CASE_DEV_BLUETOOTH
#define SND_USE_CASE_DEV_BLUETOOTH "Bluetooth"
◆ SND_USE_CASE_DEV_DIRECT
#define SND_USE_CASE_DEV_DIRECT "Direct"
Direct Device (no channel remapping), (e.g. ProAudio usage)
◆ SND_USE_CASE_DEV_EARPIECE
#define SND_USE_CASE_DEV_EARPIECE "Earpiece"
◆ SND_USE_CASE_DEV_HANDSET
#define SND_USE_CASE_DEV_HANDSET "Handset"
◆ SND_USE_CASE_DEV_HDMI
#define SND_USE_CASE_DEV_HDMI "HDMI"
HDMI / DisplayPort Device
◆ SND_USE_CASE_DEV_HEADPHONES
#define SND_USE_CASE_DEV_HEADPHONES "Headphones"
◆ SND_USE_CASE_DEV_HEADSET
#define SND_USE_CASE_DEV_HEADSET "Headset"
◆ SND_USE_CASE_DEV_LINE
#define SND_USE_CASE_DEV_LINE "Line"
◆ SND_USE_CASE_DEV_MIC
#define SND_USE_CASE_DEV_MIC "Mic"
◆ SND_USE_CASE_DEV_NONE
#define SND_USE_CASE_DEV_NONE "None"
◆ SND_USE_CASE_DEV_SPDIF
#define SND_USE_CASE_DEV_SPDIF "SPDIF"
◆ SND_USE_CASE_DEV_SPEAKER
#define SND_USE_CASE_DEV_SPEAKER "Speaker"
◆ SND_USE_CASE_DEV_USB
#define SND_USE_CASE_DEV_USB "USB"
USB Device (multifunctional)
◆ SND_USE_CASE_MOD_CAPTURE_MUSIC
#define SND_USE_CASE_MOD_CAPTURE_MUSIC "Capture Music"
◆ SND_USE_CASE_MOD_CAPTURE_VOICE
#define SND_USE_CASE_MOD_CAPTURE_VOICE "Capture Voice"
◆ SND_USE_CASE_MOD_ECHO_REF
#define SND_USE_CASE_MOD_ECHO_REF "Echo Reference"
◆ SND_USE_CASE_MOD_PLAY_MUSIC
#define SND_USE_CASE_MOD_PLAY_MUSIC "Play Music"
◆ SND_USE_CASE_MOD_PLAY_TONE
#define SND_USE_CASE_MOD_PLAY_TONE "Play Tone"
◆ SND_USE_CASE_MOD_PLAY_VOICE
#define SND_USE_CASE_MOD_PLAY_VOICE "Play Voice"
◆ SND_USE_CASE_TQ_MUSIC
#define SND_USE_CASE_TQ_MUSIC "Music"
TQ - Tone Quality
The interface allows clients to determine the audio TQ required for each use case verb and modifier. It's intended as an optional hint to the audio driver in order to lower power consumption. Music Tone Quality
◆ SND_USE_CASE_TQ_TONES
#define SND_USE_CASE_TQ_TONES "Tones"
◆ SND_USE_CASE_TQ_VOICE
#define SND_USE_CASE_TQ_VOICE "Voice"
◆ SND_USE_CASE_VERB_ANALOG_RADIO
#define SND_USE_CASE_VERB_ANALOG_RADIO "FM Analog Radio"
◆ SND_USE_CASE_VERB_DIGITAL_RADIO
#define SND_USE_CASE_VERB_DIGITAL_RADIO "FM Digital Radio"
◆ SND_USE_CASE_VERB_HIFI
#define SND_USE_CASE_VERB_HIFI "HiFi"
◆ SND_USE_CASE_VERB_HIFI_LOW_POWER
#define SND_USE_CASE_VERB_HIFI_LOW_POWER "HiFi Low Power"
◆ SND_USE_CASE_VERB_INACTIVE
#define SND_USE_CASE_VERB_INACTIVE "Inactive"
◆ SND_USE_CASE_VERB_IP_VOICECALL
#define SND_USE_CASE_VERB_IP_VOICECALL "Voice Call IP"
◆ SND_USE_CASE_VERB_VOICE
#define SND_USE_CASE_VERB_VOICE "Voice"
◆ SND_USE_CASE_VERB_VOICE_LOW_POWER
#define SND_USE_CASE_VERB_VOICE_LOW_POWER "Voice Low Power"
◆ SND_USE_CASE_VERB_VOICECALL
#define SND_USE_CASE_VERB_VOICECALL "Voice Call"
Typedef Documentation
◆ snd_use_case_mgr_t
Function Documentation
◆ snd_use_case_free_list()
int snd_use_case_free_list
(
const char * list[],
int items )
Free a string list.
- Parameters
-
list The string list to free
items Count of strings
- Returns
- Zero if success, otherwise a negative error code
◆ snd_use_case_get()
const char * identifier,
const char ** value )
Get current - string.
- Parameters
-
uc_mgr Use case manager
identifier
value Value pointer
- Returns
- Zero if success, otherwise a negative error code
Note: The returned string is dynamically allocated, use free() to deallocate this string. (Yes, the value parameter shouldn't be marked as "const", but it's too late to fix it, sorry about that.)
Known identifiers:
- NULL - return current card
- _verb - return current verb
- _file - return configuration file loaded for current card
- _alibcfg - return private alsa-lib's configuration for current card
- _alibpref - return private alsa-lib's configuration device prefix for current card
- [=]{NAME}[/[{modifier}|{/device}][/{verb}]]
- value identifier {NAME}
- Search starts at given modifier or device if any, else at a verb
- Search starts at given verb if any, else current verb
- Searches modifier/device, then verb, then defaults
- Specify a leading "=" to search only the exact device/modifier/verb specified, and not search through each object in turn.
- Examples:
- "PlaybackPCM/Play Music"
- "CapturePCM/SPDIF"
- From ValueDefaults only: "=Variable"
- From current active verb: "=Variable//"
- From verb "Verb": "=Variable//Verb"
- From "Modifier" in current active verb: "=Variable/Modifier/"
- From "Modifier" in "Verb": "=Variable/Modifier/Verb"
Recommended names for values:
- Linked
- value "True" or "1" (case insensitive)
- this is a linked UCM card
- don't use this UCM card, because the other UCM card refers devices
- valid only in the ValueDefaults section (query '=Linked')
- TQ
- Priority
- priority value (1-10000), higher value means higher priority
- valid only for verbs
- for devices - PlaybackPriority and CapturePriority
- PlaybackPCM
- full PCM playback device name
- PlaybackPCMIsDummy
- Valid values: "yes" and "no". If set to "yes", the PCM named by the PlaybackPCM value is a dummy device, meaning that opening it enables an audio path in the hardware, but writing to the PCM device has no effect.
- CapturePCM
- full PCM capture device name
- CapturePCMIsDummy
- Valid values: "yes" and "no". If set to "yes", the PCM named by the CapturePCM value is a dummy device, meaning that opening it enables an audio path in the hardware, but reading from the PCM device has no effect.
- PlaybackRate
- playback device sample rate
- PlaybackChannels
- playback device channel count
- PlaybackChannel#
- describe index of the logical channel in the PCM stream
- e.g. "PlaybackChannel0 2" - logical channel 0 is third channel in the PCM stream
- PlaybackChannelPos#
- describe sound position of the logical channel (ALSA chmap names)
- e.g. "PlaybackChannel0 FR" - logical channel 0 is at front left
- PlaybackCTL
- playback control device name
- PlaybackVolume
- PlaybackSwitch
- PlaybackPriority
- priority value (1-10000), higher value means higher priority
- CaptureRate
- capture device sample rate
- CaptureChannels
- capture device channel count
- CaptureChannel#
- describe index of the logical channel in the PCM stream
- e.g. "CaptureChannel0 2" - logical channel 0 is third channel in the PCM stream
- CaptureChannelPos#
- describe sound position of the logical channel (ALSA chmap names)
- e.g. "CaptureChannel0 FR" - logical channel 0 is at front left
- CaptureCTL
- capture control device name
- CaptureVolume
- CaptureSwitch
- CapturePriority
- priority value (1-10000), higher value means higher priority
- PlaybackMixer
- PlaybackMixerElem
- PlaybackMasterElem
- PlaybackMasterType
- type of the master volume control
- Valid values: "soft" (software attenuation)
- CaptureMixer
- CaptureMixerElem
- CaptureMasterElem
- CaptureMasterType
- type of the master volume control
- Valid values: "soft" (software attenuation)
- CaptureMicInfoFile
- json file with the microphone array placement and type description (e.g. output from nhlt-dmic-info)
- EDIDFile
- Path to EDID file for HDMI devices
- JackCTL
- JackControl
- jack control identificator
- can be parsed using snd_use_case_parse_ctl_elem_id()
- UCM configuration files should contain both JackControl and JackDev when possible, because applications are likely to support only one or the other
- JackDev
- the input device id of the jack (if the full input device path is /dev/input/by-id/foo, the JackDev value should be "foo")
- UCM configuration files should contain both JackControl and JackDev when possible, because applications are likely to support only one or the other
- JackHWMute If this value is set, it indicates that when the jack is plugged in, the hardware automatically mutes some other device(s). The value is a space-separated list of device names. If the device name contains space, it must be enclosed to ' or ", e.g.:
JackHWMute "'Dock Headphone' Headphone"
Note that JackHWMute should be used only when the hardware enforces
the automatic muting. If the hardware doesn't enforce any muting, it
may still be tempting to set JackHWMute to trick upper software layers
to e.g. automatically mute speakers when headphones are plugged in,
but that's application policy configuration that doesn't belong
to UCM configuration files.
- MinBufferLevel
- This is used on platform where reported buffer level is not accurate.
E.g. "512", which holds 512 samples in device buffer. Note: this will increase latency.
◆ snd_use_case_get_list()
const char * identifier,
const char ** list[] )
Obtain a list of entries.
- Parameters
-
uc_mgr Use case manager (may be NULL - card list)
identifier (may be NULL - card list)
list Returned allocated list
- Returns
- Number of list entries if success, otherwise a negative error code
Defined identifiers:
- NULL - get card list (in pair cardname+comment)
- _verbs - get verb list (in pair verb+comment)
- _devices[/{verb}] - get list of supported devices (in pair device+comment)
- _modifiers[/{verb}] - get list of supported modifiers (in pair modifier+comment)
- TQ[/{verb}] - get list of TQ identifiers
- _enadevs - get list of enabled devices
- _enamods - get list of enabled modifiers
- _identifiers/{modifier}|{device}[/{verb}] - list of value identifiers
- _supporteddevs/{modifier}|{device}[/{verb}] - list of supported devices
- _conflictingdevs/{modifier}|{device}[/{verb}] - list of conflicting devices
Note that at most one of the supported/conflicting devs lists has any entries, and when neither is present, all devices are supported.
◆ snd_use_case_geti()
const char * identifier,
long * value )
Get current - integer.
- Parameters
-
uc_mgr Use case manager
identifier
value result
- Returns
- Zero if success, otherwise a negative error code
Known identifiers:
- _devstatus/{device} - return status for given device
- _modstatus/{modifier} - return status for given modifier
◆ snd_use_case_identifier()
char * snd_use_case_identifier
(
const char * fmt,
... )
Create an identifier.
- Parameters
-
fmt Format (sprintf like)
... Optional arguments for sprintf like format
- Returns
- Allocated string identifier or NULL on error
◆ snd_use_case_mgr_close()
Close use case manager.
- Parameters
-
uc_mgr Use case manager
- Returns
- zero if success, otherwise a negative error code
◆ snd_use_case_mgr_open()
Open and initialise use case core for sound card.
- Parameters
-
uc_mgr Returned use case manager pointer
card_name Sound card name.
- Returns
- zero if success, otherwise a negative error code
By default only first card is used when the driver card name or long name is passed in the card_name argument.
The "strict:" prefix in the card_name defines that there is no driver name / long name matching. The straight configuration is used.
The "hw:" prefix in the card_name will load the configuration for the ALSA card specified by the card index (value) or the card string identificator.
The sound card might be also composed from several physical sound cards (for the default and strict card_name). The application cannot expect that the device names will refer only one ALSA sound card in this case.
◆ snd_use_case_mgr_reload()
Reload and re-parse use case configuration files for sound card.
- Parameters
-
uc_mgr Use case manager
- Returns
- zero if success, otherwise a negative error code
◆ snd_use_case_mgr_reset()
Reset use case manager verb, device, modifier to deafult settings.
- Parameters
-
uc_mgr Use case manager
- Returns
- zero if success, otherwise a negative error code
◆ snd_use_case_parse_ctl_elem_id()
int snd_use_case_parse_ctl_elem_id
(
snd_ctl_elem_id_t * dst,
const char * ucm_id,
const char * value )
Parse control element identifier.
- Parameters
-
dst Element identifier
ucm_id Use case identifier
value String value to be parsed
- Returns
- Zero if success, otherwise a negative error code
◆ snd_use_case_parse_selem_id()
int snd_use_case_parse_selem_id
(
snd_mixer_selem_id_t * dst,
const char * ucm_id,
const char * value )
Parse mixer element identifier.
- Parameters
-
dst Simple mixer element identifier
ucm_id Use case identifier
value String value to be parsed
- Returns
- Zero if success, otherwise a negative error code
◆ snd_use_case_set()
const char * identifier,
const char * value )
Set new.
- Parameters
-
uc_mgr Use case manager
identifier
value Value
- Returns
- Zero if success, otherwise a negative error code
Known identifiers:
- _fboot - execute the fixed boot sequence (value = NULL)
- _boot - execute the boot sequence (value = NULL)
- only when driver controls identifiers are changed (otherwise the old control values are restored)
- _defaults - execute the 'defaults' sequence (value = NULL)
- _verb - set current verb = value
- _enadev - enable given device = value
- _disdev - disable given device = value
- _swdev/{old_device} - new_device = value
- disable old_device and then enable new_device
- if old_device is not enabled just return
- check transmit sequence firstly
- _enamod - enable given modifier = value
- _dismod - disable given modifier = value
- _swmod/{old_modifier} - new_modifier = value
- disable old_modifier and then enable new_modifier
- if old_modifier is not enabled just return
- check transmit sequence firstly