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_MIXER_NAME_H 7 #define _CRAS_ALSA_MIXER_NAME_H 8 9 #include "cras_types.h" 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 /* Type of mixer control. */ 16 typedef enum mixer_name_type { 17 MIXER_NAME_UNDEFINED, 18 MIXER_NAME_MAIN_VOLUME, 19 MIXER_NAME_VOLUME, 20 } mixer_name_type; 21 22 /* Represents a list of mixer names found in ALSA. */ 23 struct mixer_name { 24 const char *name; 25 enum CRAS_STREAM_DIRECTION dir; 26 mixer_name_type type; 27 struct mixer_name *prev, *next; 28 }; 29 30 /* Add a name to the list. 31 * 32 * Args: 33 * names - A list of controls (may be NULL). 34 * name - The name to add. 35 * dir - The direction for this control. 36 * type - The type control being added. 37 * 38 * Returns: 39 * Returns the new head of the list (which changes only 40 * when names is NULL). 41 */ 42 struct mixer_name *mixer_name_add(struct mixer_name *names, const char *name, 43 enum CRAS_STREAM_DIRECTION dir, 44 mixer_name_type type); 45 46 /* Add an array of name to the list. 47 * 48 * Args: 49 * names - A list of controls (may be NULL). 50 * name_array - The names to add. 51 * name_array_size - The size of name_array. 52 * dir - The direction for these controls. 53 * type - The type controls being added. 54 * 55 * Returns: 56 * Returns the new head of the list (which changes only 57 * when names is NULL). 58 */ 59 struct mixer_name *mixer_name_add_array(struct mixer_name *names, 60 const char *const *name_array, 61 size_t name_array_size, 62 enum CRAS_STREAM_DIRECTION dir, 63 mixer_name_type type); 64 65 /* Frees a list of names. 66 * 67 * Args: 68 * names - A list of names. 69 */ 70 void mixer_name_free(struct mixer_name *names); 71 72 /* Find the mixer_name for the given direction, name, and type. 73 * 74 * Args: 75 * names - A list of names (may be NULL). 76 * name - The name to find, or NULL to match by type. 77 78 * dir - The direction to match. 79 * type - The type to match, or MIXER_NAME_UNDEFINED to 80 * match by name only. 81 * 82 * Returns: 83 * Returns a pointer to the matching struct mixer_name or NULL if 84 * not found. 85 */ 86 struct mixer_name *mixer_name_find(struct mixer_name *names, const char *name, 87 enum CRAS_STREAM_DIRECTION dir, 88 mixer_name_type type); 89 90 /* Dump the list of mixer names to DEBUG logs. 91 * 92 * Args: 93 * names - A list of names to dump. 94 * message - A message to print beforehand. 95 */ 96 void mixer_name_dump(struct mixer_name *names, const char *message); 97 98 #ifdef __cplusplus 99 } 100 #endif 101 102 #endif /* _CRAS_ALSA_MIXER_NAME_H */ 103