Lines Matching full:control

19 /* Represents an ALSA control element. Each device can have several of these,
22 * has_volume - non-zero indicates there is a volume control.
24 * max_volume_dB - the maximum volume for this control, or
26 * min_volume_dB - the minimum volume for this control, or
38 /* Represents an ALSA control element related to a specific input/output
43 * are separate control elements for left/right channels (for example),
49 * name - Name of the control (typicially this is the same as the name of the
52 * dir - Control direction, OUTPUT or INPUT only.
53 * elements - The mixer_control_elements that are driven by this control.
54 * has_volume - non-zero indicates there is a volume control.
56 * max_volume_dB - Maximum volume available in the volume control.
57 * min_volume_dB - Minimum volume available in the volume control.
176 static void mixer_control_destroy(struct mixer_control *control) { in mixer_control_destroy() argument
179 if (!control) in mixer_control_destroy()
182 DL_FOREACH(control->elements, elem) { in mixer_control_destroy()
183 DL_DELETE(control->elements, elem); in mixer_control_destroy()
186 if (control->name) in mixer_control_destroy()
187 free((void *)control->name); in mixer_control_destroy()
188 free(control); in mixer_control_destroy()
193 struct mixer_control *control; in mixer_control_destroy_list() local
196 DL_FOREACH(control_list, control) { in mixer_control_destroy_list()
197 DL_DELETE(control_list, control); in mixer_control_destroy_list()
198 mixer_control_destroy(control); in mixer_control_destroy_list()
202 static int mixer_control_add_element(struct mixer_control *control, in mixer_control_add_element() argument
207 if (!control) in mixer_control_add_element()
210 elem = mixer_control_element_create(snd_elem, control->dir); in mixer_control_add_element()
214 DL_APPEND(control->elements, elem); in mixer_control_add_element()
217 if (!control->has_volume) in mixer_control_add_element()
218 control->has_volume = 1; in mixer_control_add_element()
223 if (control->min_volume_dB == in mixer_control_add_element()
225 control->min_volume_dB = elem->min_volume_dB; in mixer_control_add_element()
226 control->max_volume_dB = elem->max_volume_dB; in mixer_control_add_element()
227 } else if (control->min_volume_dB != elem->min_volume_dB || in mixer_control_add_element()
228 control->max_volume_dB != elem->max_volume_dB) { in mixer_control_add_element()
230 "Element '%s' of control '%s' has different" in mixer_control_add_element()
233 control->name, in mixer_control_add_element()
235 control->min_volume_dB, control->max_volume_dB); in mixer_control_add_element()
239 if (elem->has_mute && !control->has_mute) in mixer_control_add_element()
240 control->has_mute = 1; in mixer_control_add_element()
244 static int mixer_control_create(struct mixer_control **control, in mixer_control_create() argument
252 if (!control) in mixer_control_create()
269 syslog(LOG_ERR, "Control does not have a name."); in mixer_control_create()
276 syslog(LOG_ERR, "No memory for control's name: %s", name); in mixer_control_create()
284 *control = c; in mixer_control_create()
289 *control = NULL; in mixer_control_create()
296 * control[out] - Storage for resulting pointer to mixer_control.
298 * name[in] - Optional name of the control. Input NULL to take the name of
300 * mixer_names[in] - Names of the ASLA mixer control elements. Must not
302 * dir[in] - Control direction: CRAS_STREAM_OUTPUT or CRAS_STREAM_INPUT.
304 * Returns 0 for success, negative error code otherwise. *control is
308 struct mixer_control **control, in mixer_control_create_by_name() argument
320 if (!control) in mixer_control_create_by_name()
322 *control = NULL; in mixer_control_create_by_name()
344 syslog(LOG_ERR, "Unable to find simple control %s, 0", in mixer_control_create_by_name()
357 *control = c; in mixer_control_create_by_name()
362 const struct mixer_control *control, long to_set) in mixer_control_set_dBFS() argument
366 if (!control) in mixer_control_set_dBFS()
368 DL_FOREACH(control->elements, elem) { in mixer_control_set_dBFS()
370 if (control->dir == CRAS_STREAM_OUTPUT) in mixer_control_set_dBFS()
373 else if (control->dir == CRAS_STREAM_INPUT) in mixer_control_set_dBFS()
379 control->name, in mixer_control_set_dBFS()
386 control->name, in mixer_control_set_dBFS()
393 const struct mixer_control *control, long *to_get) in mixer_control_get_dBFS() argument
397 if (!control || !to_get) in mixer_control_get_dBFS()
399 DL_FOREACH(control->elements, elem) { in mixer_control_get_dBFS()
401 if (control->dir == CRAS_STREAM_OUTPUT) in mixer_control_get_dBFS()
406 else if (control->dir == CRAS_STREAM_INPUT) in mixer_control_get_dBFS()
411 /* Assume all of the elements of this control have in mixer_control_get_dBFS()
418 control->name, in mixer_control_get_dBFS()
425 const struct mixer_control *control, int muted) in mixer_control_set_mute() argument
429 if (!control) in mixer_control_set_mute()
431 DL_FOREACH(control->elements, elem) { in mixer_control_set_mute()
433 if (control->dir == CRAS_STREAM_OUTPUT) in mixer_control_set_mute()
436 else if (control->dir == CRAS_STREAM_INPUT) in mixer_control_set_mute()
445 control->name, in mixer_control_set_mute()
451 /* Adds the main volume control to the list and grabs the first seen playback
474 syslog(LOG_DEBUG, "Add main volume control %s\n", c->name); in add_main_volume_control()
490 /* Adds the main capture control to the list and grabs the first seen capture
505 syslog(LOG_DEBUG, "Add main capture control %s\n", c->name); in add_main_capture_control()
521 /* Adds a control to the list. */
532 syslog(LOG_DEBUG, "Add %s control: %s,%d\n", in add_control_with_name()
541 syslog(LOG_DEBUG, "Control '%s' volume range: [%ld:%ld]", in add_control_with_name()
563 struct mixer_control *control; in list_controls() local
565 DL_FOREACH(control_list, control) in list_controls()
566 cb(control, cb_arg); in list_controls()
582 /* Creates a mixer_control with multiple control elements. */
596 syslog(LOG_DEBUG, "Add %s control: %s\n", in add_control_with_coupled_mixers()
602 syslog(LOG_DEBUG, "Control '%s' volume range: [%ld:%ld]", in add_control_with_coupled_mixers()
628 syslog(LOG_DEBUG, "Add %s control: %s\n", in add_control_by_name()
633 syslog(LOG_DEBUG, "Control '%s' volume range: [%ld:%ld]", in add_control_by_name()
727 struct mixer_name *control; in cras_alsa_mixer_add_controls_by_name_matching() local
734 /* Find a matching control. */ in cras_alsa_mixer_add_controls_by_name_matching()
735 control = mixer_name_find(default_controls, name, in cras_alsa_mixer_add_controls_by_name_matching()
743 control && control->type == MIXER_NAME_MAIN_VOLUME) in cras_alsa_mixer_add_controls_by_name_matching()
744 control = NULL; in cras_alsa_mixer_add_controls_by_name_matching()
748 if (!control) in cras_alsa_mixer_add_controls_by_name_matching()
749 control = mixer_name_find(extra_controls, name, in cras_alsa_mixer_add_controls_by_name_matching()
753 if (control) { in cras_alsa_mixer_add_controls_by_name_matching()
755 switch(control->type) { in cras_alsa_mixer_add_controls_by_name_matching()
770 "Failed to add mixer control '%s'" in cras_alsa_mixer_add_controls_by_name_matching()
772 control->name, control->type); in cras_alsa_mixer_add_controls_by_name_matching()
778 /* Find a matching input control. */ in cras_alsa_mixer_add_controls_by_name_matching()
779 control = mixer_name_find(default_controls, name, in cras_alsa_mixer_add_controls_by_name_matching()
785 if (!control) in cras_alsa_mixer_add_controls_by_name_matching()
786 control = mixer_name_find(extra_controls, name, in cras_alsa_mixer_add_controls_by_name_matching()
790 if (control) { in cras_alsa_mixer_add_controls_by_name_matching()
792 switch(control->type) { in cras_alsa_mixer_add_controls_by_name_matching()
806 "Failed to add mixer control '%s'" in cras_alsa_mixer_add_controls_by_name_matching()
808 control->name, control->type); in cras_alsa_mixer_add_controls_by_name_matching()
817 * control and the largest volume range. */ in cras_alsa_mixer_add_controls_by_name_matching()
843 /* If there is no volume control and output control found, in cras_alsa_mixer_add_controls_by_name_matching()
844 * use the volume control which has the largest volume range in cras_alsa_mixer_add_controls_by_name_matching()
845 * in the mixer as a main volume control. */ in cras_alsa_mixer_add_controls_by_name_matching()
850 syslog(LOG_ERR, "Could not add other volume control"); in cras_alsa_mixer_add_controls_by_name_matching()
883 syslog(LOG_ERR, "Could not add mixer control '%s': %s", in cras_alsa_mixer_add_controls_in_section()
894 syslog(LOG_ERR, "Could not add coupled control: %s", in cras_alsa_mixer_add_controls_in_section()
943 * entire volume can't be set on the current control, move on to the in cras_alsa_mixer_set_dBFS()
956 /* Apply the rest to the output-specific control. */ in cras_alsa_mixer_set_dBFS()
988 * be set on the current control, move on to the next one until we have in cras_alsa_mixer_set_capture_dBFS()
1001 /* Apply the reset to input specific control */ in cras_alsa_mixer_set_capture_dBFS()
1089 const struct mixer_control *control) in cras_alsa_mixer_get_control_name() argument
1091 if (!control) in cras_alsa_mixer_get_control_name()
1093 return control->name; in cras_alsa_mixer_get_control_name()
1117 /* TODO: Allowing creation of a new control is a workaround: we in cras_alsa_mixer_get_control_matching_name()
1157 /* TODO: Allowing creation of a new control is a workaround: we in cras_alsa_mixer_get_input_matching_name()