aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/control.h2
-rw-r--r--sound/core/control.c46
2 files changed, 48 insertions, 0 deletions
diff --git a/include/sound/control.h b/include/sound/control.h
index 7715e6f00d38..e67db2869360 100644
--- a/include/sound/control.h
+++ b/include/sound/control.h
@@ -115,6 +115,8 @@ int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol);
115int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol); 115int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol);
116int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id); 116int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id);
117int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id); 117int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id);
118int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
119 int active);
118struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid); 120struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid);
119struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id); 121struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id);
120 122
diff --git a/sound/core/control.c b/sound/core/control.c
index 9ce00ed20fba..db51e4e64984 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -466,6 +466,52 @@ error:
466} 466}
467 467
468/** 468/**
469 * snd_ctl_activate_id - activate/inactivate the control of the given id
470 * @card: the card instance
471 * @id: the control id to activate/inactivate
472 * @active: non-zero to activate
473 *
474 * Finds the control instance with the given id, and activate or
475 * inactivate the control together with notification, if changed.
476 *
477 * Returns 0 if unchanged, 1 if changed, or a negative error code on failure.
478 */
479int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
480 int active)
481{
482 struct snd_kcontrol *kctl;
483 struct snd_kcontrol_volatile *vd;
484 unsigned int index_offset;
485 int ret;
486
487 down_write(&card->controls_rwsem);
488 kctl = snd_ctl_find_id(card, id);
489 if (kctl == NULL) {
490 ret = -ENOENT;
491 goto unlock;
492 }
493 index_offset = snd_ctl_get_ioff(kctl, &kctl->id);
494 vd = &kctl->vd[index_offset];
495 ret = 0;
496 if (active) {
497 if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE))
498 goto unlock;
499 vd->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
500 } else {
501 if (vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE)
502 goto unlock;
503 vd->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
504 }
505 ret = 1;
506 unlock:
507 up_write(&card->controls_rwsem);
508 if (ret > 0)
509 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, id);
510 return ret;
511}
512EXPORT_SYMBOL_GPL(snd_ctl_activate_id);
513
514/**
469 * snd_ctl_rename_id - replace the id of a control on the card 515 * snd_ctl_rename_id - replace the id of a control on the card
470 * @card: the card instance 516 * @card: the card instance
471 * @src_id: the old id 517 * @src_id: the old id