diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-03-16 12:38:41 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-03-16 12:38:41 -0400 |
commit | 27b92d4ff2be2359a21ff4acde5b63563ff720e2 (patch) | |
tree | 49691b22fe1318aa68d5ebdff74795f004f0cf8f /sound/core | |
parent | 5de0ee574be8f6922a6c33f2fbc7e9b130a2f626 (diff) | |
parent | e58a8947b0264ec1f43ce5deef563b72acf1284f (diff) |
Merge branch 'topic/asoc' into for-linus
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/control.c | 46 |
1 files changed, 46 insertions, 0 deletions
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 | */ | ||
479 | int 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 | } | ||
512 | EXPORT_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 |