diff options
Diffstat (limited to 'sound/pci/rme9652')
-rw-r--r-- | sound/pci/rme9652/hdsp.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 866d68461b83..4ebd283e56a3 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
@@ -1713,6 +1713,65 @@ static int snd_hdsp_put_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
1713 | return change; | 1713 | return change; |
1714 | } | 1714 | } |
1715 | 1715 | ||
1716 | #define HDSP_TOGGLE_SETTING(xname, xindex) \ | ||
1717 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1718 | .name = xname, \ | ||
1719 | .private_value = xindex, \ | ||
1720 | .info = snd_hdsp_info_toggle_setting, \ | ||
1721 | .get = snd_hdsp_get_toggle_setting, \ | ||
1722 | .put = snd_hdsp_put_toggle_setting \ | ||
1723 | } | ||
1724 | |||
1725 | static int hdsp_toggle_setting(struct hdsp *hdsp, u32 regmask) | ||
1726 | { | ||
1727 | return (hdsp->control_register & regmask) ? 1 : 0; | ||
1728 | } | ||
1729 | |||
1730 | static int hdsp_set_toggle_setting(struct hdsp *hdsp, u32 regmask, int out) | ||
1731 | { | ||
1732 | if (out) | ||
1733 | hdsp->control_register |= regmask; | ||
1734 | else | ||
1735 | hdsp->control_register &= ~regmask; | ||
1736 | hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); | ||
1737 | |||
1738 | return 0; | ||
1739 | } | ||
1740 | |||
1741 | #define snd_hdsp_info_toggle_setting snd_ctl_boolean_mono_info | ||
1742 | |||
1743 | static int snd_hdsp_get_toggle_setting(struct snd_kcontrol *kcontrol, | ||
1744 | struct snd_ctl_elem_value *ucontrol) | ||
1745 | { | ||
1746 | struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); | ||
1747 | u32 regmask = kcontrol->private_value; | ||
1748 | |||
1749 | spin_lock_irq(&hdsp->lock); | ||
1750 | ucontrol->value.integer.value[0] = hdsp_toggle_setting(hdsp, regmask); | ||
1751 | spin_unlock_irq(&hdsp->lock); | ||
1752 | return 0; | ||
1753 | } | ||
1754 | |||
1755 | static int snd_hdsp_put_toggle_setting(struct snd_kcontrol *kcontrol, | ||
1756 | struct snd_ctl_elem_value *ucontrol) | ||
1757 | { | ||
1758 | struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); | ||
1759 | u32 regmask = kcontrol->private_value; | ||
1760 | int change; | ||
1761 | unsigned int val; | ||
1762 | |||
1763 | if (!snd_hdsp_use_is_exclusive(hdsp)) | ||
1764 | return -EBUSY; | ||
1765 | val = ucontrol->value.integer.value[0] & 1; | ||
1766 | spin_lock_irq(&hdsp->lock); | ||
1767 | change = (int) val != hdsp_toggle_setting(hdsp, regmask); | ||
1768 | if (change) | ||
1769 | hdsp_set_toggle_setting(hdsp, regmask, val); | ||
1770 | spin_unlock_irq(&hdsp->lock); | ||
1771 | return change; | ||
1772 | } | ||
1773 | |||
1774 | |||
1716 | #define HDSP_SPDIF_OUT(xname, xindex) \ | 1775 | #define HDSP_SPDIF_OUT(xname, xindex) \ |
1717 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 1776 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
1718 | .info = snd_hdsp_info_spdif_bits, \ | 1777 | .info = snd_hdsp_info_spdif_bits, \ |