• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 	const char *name;                /* Section name. */
19 	int dev_idx;                     /* Device PCM index. */
20 	enum CRAS_STREAM_DIRECTION dir;  /* Output or Input. */
21 	const char *jack_name;           /* Associated jack's name. */
22 	const char *jack_type;           /* Associated jack's type. */
23 	int jack_switch;                 /* Switch number for jack from
24 	                                  * linux/input.h, or -1. */
25 	const char *mixer_name;          /* MixerName value. */
26 	struct mixer_name *coupled;      /* CoupledMixers value. */
27 	struct ucm_section *prev, *next;
28 };
29 
30 /* Create a single UCM section.
31  *
32  * Args:
33  *    name - Section name (must not be NULL).
34  *    dev_idx - Section's device index (PCM number).
35  *    dir - Device direction: INPUT or OUTPUT.
36  *    jack_name - Name of an associated jack (or NULL).
37  *    jack_type - Type of the associated jack (or NULL).
38  *
39  * Returns:
40  *    A valid pointer on success, NULL for memory allocation error.
41  */
42 struct ucm_section *ucm_section_create(const char *name,
43 				       int dev_idx,
44 				       enum CRAS_STREAM_DIRECTION dir,
45 				       const char *jack_name,
46 				       const char *jack_type);
47 
48 /* Sets the mixer_name value for the given section.
49  *
50  * Args:
51  *    section - Section to manipulate.
52  *    name - The name of the control.
53  *
54  * Returns:
55  *    0 for success, -EINVAL for invalid arguments, or -ENOMEM.
56  */
57 int ucm_section_set_mixer_name(struct ucm_section *section,
58 			       const char *name);
59 
60 /* Add a single coupled control to this section.
61  * Control has the same direction as the section.
62  *
63  * Args:
64  *    section - Section to manipulate.
65  *    name - Coupled control name to add.
66  *    type - The type of control.
67  *
68  * Returns:
69  *    0 for success, -EINVAL for invalid arguments, or -ENOMEM.
70  */
71 int ucm_section_add_coupled(struct ucm_section *section,
72 			    const char *name,
73 			    mixer_name_type type);
74 
75 /* Concatenate a list of coupled controls to this section.
76  *
77  * Args:
78  *    section - Section to manipulate.
79  *    coupled - Coupled control names to add.
80  *
81  * Returns:
82  *    0 for success, -EINVAL for invalid arguments (NULL args).
83  */
84 int ucm_section_concat_coupled(struct ucm_section *section,
85 			       struct mixer_name *coupled);
86 
87 /* Frees a list of sections.
88  *
89  * Args:
90  *    sections - List of sections to free.
91  */
92 void ucm_section_free_list(struct ucm_section *sections);
93 
94 /* Dump details on this section to syslog(LOG_DEBUG).
95  *
96  * Args:
97  *    section - Section to dump.
98  */
99 void ucm_section_dump(struct ucm_section *section);
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif /* _CRAS_ALSA_MIXER_NAME_H */
106