1 /* Copyright 2016 The Chromium OS Authors. All rights reserved. 2 * Use of this source code is governed by a BSD-style license that can be 3 * found in the LICENSE file. 4 */ 5 6 #ifndef _CRAS_ALSA_UCM_SECTION_H 7 #define _CRAS_ALSA_UCM_SECTION_H 8 9 #include "cras_types.h" 10 #include "cras_alsa_mixer_name.h" 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 /* Represents an ALSA UCM section. */ 17 struct ucm_section { 18 /* Section name. */ 19 const char *name; 20 /* Value of PlaybackPCM or CapturePCM. */ 21 const char *pcm_name; 22 /* Device PCM index. */ 23 int dev_idx; 24 /* Device PCM index to associate this section to. */ 25 int dependent_dev_idx; 26 /* Output or Input. */ 27 enum CRAS_STREAM_DIRECTION dir; 28 /* Associated jack's name. */ 29 const char *jack_name; 30 /* Associated jack's type. */ 31 const char *jack_type; 32 /* Switch number for jack from linux/input.h, or -1. */ 33 int jack_switch; 34 /* (Playback/Capture)MixerElem value. */ 35 const char *mixer_name; 36 /* CoupledMixers value. */ 37 struct mixer_name *coupled; 38 struct ucm_section *prev, *next; 39 }; 40 41 /* Create a single UCM section. 42 * 43 * Args: 44 * name - Section name (must not be NULL). 45 * pcm_name - PCM name used for snd_pcm_open. 46 * dev_idx - Section's device index (PCM number). 47 * dependent_dev_idx - Another ALSA device index (PCM number) under which 48 * we want to make this section a node. 49 * dir - Device direction: INPUT or OUTPUT. 50 * jack_name - Name of an associated jack (or NULL). 51 * jack_type - Type of the associated jack (or NULL). 52 * 53 * Returns: 54 * A valid pointer on success, NULL for memory allocation error. 55 */ 56 struct ucm_section *ucm_section_create(const char *name, const char *pcm_name, 57 int dev_idx, int dependent_dev_idx, 58 enum CRAS_STREAM_DIRECTION dir, 59 const char *jack_name, 60 const char *jack_type); 61 62 /* Sets the mixer_name value for the given section. 63 * 64 * Args: 65 * section - Section to manipulate. 66 * name - The name of the control. 67 * 68 * Returns: 69 * 0 for success, -EINVAL for invalid arguments, or -ENOMEM. 70 */ 71 int ucm_section_set_mixer_name(struct ucm_section *section, const char *name); 72 73 /* Add a single coupled control to this section. 74 * Control has the same direction as the section. 75 * 76 * Args: 77 * section - Section to manipulate. 78 * name - Coupled control name to add. 79 * type - The type of control. 80 * 81 * Returns: 82 * 0 for success, -EINVAL for invalid arguments, or -ENOMEM. 83 */ 84 int ucm_section_add_coupled(struct ucm_section *section, const char *name, 85 mixer_name_type type); 86 87 /* Concatenate a list of coupled controls to this section. 88 * 89 * Args: 90 * section - Section to manipulate. 91 * coupled - Coupled control names to add. 92 * 93 * Returns: 94 * 0 for success, -EINVAL for invalid arguments (NULL args). 95 */ 96 int ucm_section_concat_coupled(struct ucm_section *section, 97 struct mixer_name *coupled); 98 99 /* Frees a list of sections. 100 * 101 * Args: 102 * sections - List of sections to free. 103 */ 104 void ucm_section_free_list(struct ucm_section *sections); 105 106 /* Dump details on this section to syslog(LOG_DEBUG). 107 * 108 * Args: 109 * section - Section to dump. 110 */ 111 void ucm_section_dump(struct ucm_section *section); 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 #endif /* _CRAS_ALSA_MIXER_NAME_H */ 118