Extend the audio HAL interface to support get/set master mute

(cherry picked from commit d245968b7ef0be5c776c9aefff3eca9e293d1b35)

> Extend the audio HAL interface to support get/set master mute
>
> Hand merge from ics-aah
>
> > Extend the audio HAL interface to support get/set master mute: DO NOT MERGE
> >
> > Extend the audio HAL interface to allow HALs to optionally support HW
> > level master mute.  This follows the same pattern as master volume and
> > is part of the fix for bug 6828363.  Because of the divergences
> > between ICS and master, this change will need to be merged by hand.
> >
> > Signed-off-by: John Grossman <johngro@google.com>
> > Change-Id: Ica6f5e37e13d13dde60463966f41f271ffa104fd
>
> Change-Id: I5e7aea6d7da0012dcc077281f9077fc04cfb9889
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: I2011cc5bc41ca7081ce255a4bfba65f36f899bc4
Signed-off-by: John Grossman <johngro@google.com>
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 0a917e2..26e9ea9 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -352,7 +352,7 @@
      * master volume control.  AudioFlinger will query this value from the
      * primary audio HAL when the service starts and use the value for setting
      * the initial master volume across all HALs.  HALs which do not support
-     * this method should may leave it set to NULL.
+     * this method may leave it set to NULL.
      */
     int (*get_master_volume)(struct audio_hw_device *dev, float *volume);
 
@@ -407,6 +407,21 @@
 
     /** This method dumps the state of the audio hardware */
     int (*dump)(const struct audio_hw_device *dev, int fd);
+
+    /**
+     * set the audio mute status for all audio activities.  If any value other
+     * than 0 is returned, the software mixer will emulate this capability.
+     */
+    int (*set_master_mute)(struct audio_hw_device *dev, bool mute);
+
+    /**
+     * Get the current master mute status for the HAL, if the HAL supports
+     * master mute control.  AudioFlinger will query this value from the primary
+     * audio HAL when the service starts and use the value for setting the
+     * initial master mute across all HALs.  HALs which do not support this
+     * method may leave it set to NULL.
+     */
+    int (*get_master_mute)(struct audio_hw_device *dev, bool *mute);
 };
 typedef struct audio_hw_device audio_hw_device_t;
 
diff --git a/modules/audio/audio_hw.c b/modules/audio/audio_hw.c
index 15e9920..e4fb711 100644
--- a/modules/audio/audio_hw.c
+++ b/modules/audio/audio_hw.c
@@ -287,8 +287,17 @@
     return -ENOSYS;
 }
 
-static int adev_get_master_volume(struct audio_hw_device *dev,
-                                  float *volume)
+static int adev_get_master_volume(struct audio_hw_device *dev, float *volume)
+{
+    return -ENOSYS;
+}
+
+static int adev_set_master_mute(struct audio_hw_device *dev, bool muted)
+{
+    return -ENOSYS;
+}
+
+static int adev_get_master_mute(struct audio_hw_device *dev, bool *muted)
 {
     return -ENOSYS;
 }
@@ -416,6 +425,8 @@
     adev->device.set_voice_volume = adev_set_voice_volume;
     adev->device.set_master_volume = adev_set_master_volume;
     adev->device.get_master_volume = adev_get_master_volume;
+    adev->device.set_master_mute = adev_set_master_mute;
+    adev->device.get_master_mute = adev_get_master_mute;
     adev->device.set_mode = adev_set_mode;
     adev->device.set_mic_mute = adev_set_mic_mute;
     adev->device.get_mic_mute = adev_get_mic_mute;