diff options
-rw-r--r-- | sound/pci/asihpi/asihpi.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 3444bd7d3268..f2b35e1bdc90 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c | |||
@@ -1487,11 +1487,48 @@ static int snd_asihpi_volume_put(struct snd_kcontrol *kcontrol, | |||
1487 | 1487 | ||
1488 | static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0); | 1488 | static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0); |
1489 | 1489 | ||
1490 | static int snd_asihpi_volume_mute_info(struct snd_kcontrol *kcontrol, | ||
1491 | struct snd_ctl_elem_info *uinfo) | ||
1492 | { | ||
1493 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
1494 | uinfo->count = 1; | ||
1495 | uinfo->value.integer.min = 0; | ||
1496 | uinfo->value.integer.max = 1; | ||
1497 | return 0; | ||
1498 | } | ||
1499 | |||
1500 | static int snd_asihpi_volume_mute_get(struct snd_kcontrol *kcontrol, | ||
1501 | struct snd_ctl_elem_value *ucontrol) | ||
1502 | { | ||
1503 | u32 h_control = kcontrol->private_value; | ||
1504 | u32 mute; | ||
1505 | |||
1506 | hpi_handle_error(hpi_volume_get_mute(h_control, &mute)); | ||
1507 | ucontrol->value.integer.value[0] = mute ? 0 : 1; | ||
1508 | |||
1509 | return 0; | ||
1510 | } | ||
1511 | |||
1512 | static int snd_asihpi_volume_mute_put(struct snd_kcontrol *kcontrol, | ||
1513 | struct snd_ctl_elem_value *ucontrol) | ||
1514 | { | ||
1515 | u32 h_control = kcontrol->private_value; | ||
1516 | int change = 1; | ||
1517 | /* HPI currently only supports all or none muting of multichannel volume | ||
1518 | ALSA Switch element has opposite sense to HPI mute: on==unmuted, off=muted | ||
1519 | */ | ||
1520 | int mute = ucontrol->value.integer.value[0] ? 0 : HPI_BITMASK_ALL_CHANNELS; | ||
1521 | hpi_handle_error(hpi_volume_set_mute(h_control, mute)); | ||
1522 | return change; | ||
1523 | } | ||
1524 | |||
1490 | static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, | 1525 | static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, |
1491 | struct hpi_control *hpi_ctl) | 1526 | struct hpi_control *hpi_ctl) |
1492 | { | 1527 | { |
1493 | struct snd_card *card = asihpi->card; | 1528 | struct snd_card *card = asihpi->card; |
1494 | struct snd_kcontrol_new snd_control; | 1529 | struct snd_kcontrol_new snd_control; |
1530 | int err; | ||
1531 | u32 mute; | ||
1495 | 1532 | ||
1496 | asihpi_ctl_init(&snd_control, hpi_ctl, "Volume"); | 1533 | asihpi_ctl_init(&snd_control, hpi_ctl, "Volume"); |
1497 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 1534 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
@@ -1501,7 +1538,19 @@ static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, | |||
1501 | snd_control.put = snd_asihpi_volume_put; | 1538 | snd_control.put = snd_asihpi_volume_put; |
1502 | snd_control.tlv.p = db_scale_100; | 1539 | snd_control.tlv.p = db_scale_100; |
1503 | 1540 | ||
1504 | return ctl_add(card, &snd_control, asihpi); | 1541 | err = ctl_add(card, &snd_control, asihpi); |
1542 | if (err) | ||
1543 | return err; | ||
1544 | |||
1545 | if (hpi_volume_get_mute(hpi_ctl->h_control, &mute) == 0) { | ||
1546 | asihpi_ctl_init(&snd_control, hpi_ctl, "Switch"); | ||
1547 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; | ||
1548 | snd_control.info = snd_asihpi_volume_mute_info; | ||
1549 | snd_control.get = snd_asihpi_volume_mute_get; | ||
1550 | snd_control.put = snd_asihpi_volume_mute_put; | ||
1551 | err = ctl_add(card, &snd_control, asihpi); | ||
1552 | } | ||
1553 | return err; | ||
1505 | } | 1554 | } |
1506 | 1555 | ||
1507 | /*------------------------------------------------------------ | 1556 | /*------------------------------------------------------------ |