ALSA: asihpi - Add volume mute control.
authorEliot Blennerhassett <eblennerhassett@audioscience.com>
Thu, 10 Feb 2011 04:26:11 +0000 (17:26 +1300)
committerTakashi Iwai <tiwai@suse.de>
Thu, 10 Feb 2011 17:49:32 +0000 (18:49 +0100)
Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/asihpi/hpi.h
sound/pci/asihpi/hpi_internal.h
sound/pci/asihpi/hpicmn.c
sound/pci/asihpi/hpifunc.c

index bef90d44361ed7b3ce46e5f83619209333f96b57..5ac978d07740da6f25c464cf1e151d14c55699f6 100644 (file)
@@ -645,6 +645,11 @@ enum HPI_SWITCH_STATES {
 */
 #define HPI_GAIN_OFF                    (-100 * HPI_UNITS_PER_dB)
 
+/** channel mask specifying all channels
+\ingroup volume
+*/
+#define HPI_BITMASK_ALL_CHANNELS        (0xFFFFFFFF)
+
 /** value returned for no signal
 \ingroup meter
 */
@@ -1312,6 +1317,10 @@ u16 hpi_volume_get_gain(u32 h_control,
        short an_gain0_01dB_out[HPI_MAX_CHANNELS]
        );
 
+u16 hpi_volume_set_mute(u32 h_control, u32 mute);
+
+u16 hpi_volume_get_mute(u32 h_control, u32 *mute);
+
 #define hpi_volume_get_range hpi_volume_query_range
 u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
        short *max_gain_01dB, short *step_gain_01dB);
index 10de7e0aff145ef3685b49206004d6071385a532..99081608556153c9af9ed194ca8848612fefab9f 100644 (file)
@@ -114,6 +114,18 @@ enum HPI_SUBSYS_OPTIONS {
        HPI_SUBSYS_OPT_NET_ADAPTER_ADDRESS_ADD = 262
 };
 
+/** Volume flags
+*/
+enum HPI_VOLUME_FLAGS {
+       /** Set if the volume control is muted */
+       HPI_VOLUME_FLAG_MUTED = (1 << 0),
+       /** Set if the volume control has a mute function */
+       HPI_VOLUME_FLAG_HAS_MUTE = (1 << 1),
+       /** Set if volume control can do autofading */
+       HPI_VOLUME_FLAG_HAS_AUTOFADE = (1 << 2)
+               /* Note Flags >= (1<<8) are for DSP internal use only */
+};
+
 /******************************************* CONTROL ATTRIBUTES ****/
 /* (in order of control type ID */
 
@@ -139,6 +151,8 @@ enum HPI_CONTROL_ATTRIBUTES {
 
        HPI_VOLUME_GAIN = HPI_CTL_ATTR(VOLUME, 1),
        HPI_VOLUME_AUTOFADE = HPI_CTL_ATTR(VOLUME, 2),
+       HPI_VOLUME_MUTE = HPI_CTL_ATTR(VOLUME, 3),
+       HPI_VOLUME_GAIN_AND_FLAGS = HPI_CTL_ATTR(VOLUME, 4),
        HPI_VOLUME_NUM_CHANNELS = HPI_CTL_ATTR(VOLUME, 6),
        HPI_VOLUME_RANGE = HPI_CTL_ATTR(VOLUME, 10),
 
@@ -1389,7 +1403,8 @@ struct hpi_control_cache_info {
 struct hpi_control_cache_vol {
        struct hpi_control_cache_info i;
        short an_log[2];
-       char temp_padding[4];
+       unsigned short flags;
+       char padding[2];
 };
 
 struct hpi_control_cache_meter {
index e0a08f61a34870209050bc7a38f448f7a00adadb..4b3f4761cba573ec77826e0e0efd270eb8f2c057 100644 (file)
@@ -347,8 +347,21 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
                if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
                        phr->u.c.an_log_value[0] = pC->u.vol.an_log[0];
                        phr->u.c.an_log_value[1] = pC->u.vol.an_log[1];
-               } else
+               } else if (phm->u.c.attribute == HPI_VOLUME_MUTE) {
+                       if (pC->u.vol.flags & HPI_VOLUME_FLAG_HAS_MUTE) {
+                               if (pC->u.vol.flags & HPI_VOLUME_FLAG_MUTED)
+                                       phr->u.c.param1 =
+                                               HPI_BITMASK_ALL_CHANNELS;
+                               else
+                                       phr->u.c.param1 = 0;
+                       } else {
+                               phr->error =
+                                       HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
+                               phr->u.c.param1 = 0;
+                       }
+               } else {
                        found = 0;
+               }
                break;
        case HPI_CONTROL_MULTIPLEXER:
                if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) {
@@ -544,6 +557,11 @@ void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *p_cache,
                if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
                        pC->u.vol.an_log[0] = phr->u.c.an_log_value[0];
                        pC->u.vol.an_log[1] = phr->u.c.an_log_value[1];
+               } else if (phm->u.c.attribute == HPI_VOLUME_MUTE) {
+                       if (phm->u.c.param1)
+                               pC->u.vol.flags |= HPI_VOLUME_FLAG_MUTED;
+                       else
+                               pC->u.vol.flags &= ~HPI_VOLUME_FLAG_MUTED;
                }
                break;
        case HPI_CONTROL_MULTIPLEXER:
index 53924e4941618110de38e8d4d5a9231ed095e645..b79eba1ee0f5d4e6ae89e4c1d0fc9349473ab0b4 100644 (file)
@@ -2888,6 +2888,16 @@ u16 hpi_volume_get_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
                &an_log_gain[0], &an_log_gain[1]);
 }
 
+u16 hpi_volume_set_mute(u32 h_control, u32 mute)
+{
+       return hpi_control_param_set(h_control, HPI_VOLUME_MUTE, mute, 0);
+}
+
+u16 hpi_volume_get_mute(u32 h_control, u32 *mute)
+{
+       return hpi_control_param1_get(h_control, HPI_VOLUME_MUTE, mute);
+}
+
 u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
        short *max_gain_01dB, short *step_gain_01dB)
 {