summaryrefslogtreecommitdiffstats
path: root/audio_hw.c
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2012-10-13 12:13:58 +0200
committerPaul Kocialkowski <contact@paulk.fr>2012-10-13 12:13:58 +0200
commit9b78c141abe0dcac335e5423f5ebdd05b481d1cc (patch)
tree1918be6c1c44afebf94ea4629a9350b57cc050b8 /audio_hw.c
parent8aed9f23e589576d5bcc156f1f7d7544825fe5c2 (diff)
downloadhardware_tinyalsa-audio-9b78c141abe0dcac335e5423f5ebdd05b481d1cc.zip
hardware_tinyalsa-audio-9b78c141abe0dcac335e5423f5ebdd05b481d1cc.tar.gz
hardware_tinyalsa-audio-9b78c141abe0dcac335e5423f5ebdd05b481d1cc.tar.bz2
Volume and mic mute control handling
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'audio_hw.c')
-rw-r--r--audio_hw.c89
1 files changed, 78 insertions, 11 deletions
diff --git a/audio_hw.c b/audio_hw.c
index 954c6ea..e2cb1c3 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -36,33 +36,33 @@
static uint32_t audio_hw_get_supported_devices(const struct audio_hw_device *dev)
{
- struct tinyalsa_audio_device *tinyalsa_audio_device;
+ struct tinyalsa_audio_device *device;
LOGD("%s(%p)", __func__, dev);
if(dev == NULL)
return -1;
- tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
+ device = (struct tinyalsa_audio_device *) dev;
- if(tinyalsa_audio_device->mixer == NULL)
+ if(device->mixer == NULL)
return -1;
- return (uint32_t) tinyalsa_mixer_get_supported_devices(tinyalsa_audio_device->mixer);
+ return (uint32_t) tinyalsa_mixer_get_supported_devices(device->mixer);
}
static int audio_hw_init_check(const struct audio_hw_device *dev)
{
- struct tinyalsa_audio_device *tinyalsa_audio_device;
+ struct tinyalsa_audio_device *device;
LOGD("%s(%p)", __func__, dev);
if(dev == NULL)
return -1;
- tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
+ device = (struct tinyalsa_audio_device *) dev;
- if(tinyalsa_audio_device->mixer == NULL)
+ if(device->mixer == NULL)
return -1;
return 0;
@@ -70,37 +70,104 @@ static int audio_hw_init_check(const struct audio_hw_device *dev)
static int audio_hw_set_voice_volume(struct audio_hw_device *dev, float volume)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %f)", __func__, dev, volume);
- return -ENOSYS;
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ if(device->mixer == NULL)
+ return -1;
+
+ if(device->mode == AUDIO_MODE_IN_CALL) {
+ // FIXME: Select the device from ril interface
+ tinyalsa_mixer_set_voice_volume(device->mixer,
+ AUDIO_DEVICE_IN_DEFAULT, device->mode, volume);
+ }
+
+ return 0;
}
static int audio_hw_set_master_volume(struct audio_hw_device *dev, float volume)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %f)", __func__, dev, volume);
- return -ENOSYS;
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ if(device->mixer == NULL)
+ return -1;
+
+ tinyalsa_mixer_set_master_volume(device->mixer, volume);
+
+ return 0;
}
static int audio_hw_set_mode(struct audio_hw_device *dev, int mode)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %d)", __func__, dev, mode);
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ device->mode = mode;
+
+ // TODO: If mode changed, change routing
+
return 0;
}
static int audio_hw_set_mic_mute(struct audio_hw_device *dev, bool state)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %d)", __func__, dev, state);
- return -ENOSYS;
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ if(device->mixer == NULL)
+ return -1;
+
+ if(device->mic_mute != state) {
+ device->mic_mute = state;
+
+ // FIXME: Select the device from input if mode isn't in-call,
+ // select it from ril interface if mode is in-call
+ tinyalsa_mixer_set_mic_mute(device->mixer,
+ AUDIO_DEVICE_IN_DEFAULT, device->mode, state);
+ }
+
+ return 0;
}
static int audio_hw_get_mic_mute(const struct audio_hw_device *dev, bool *state)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %p)", __func__, dev, state);
- return -ENOSYS;
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ *state = device->mic_mute;
+
+ return 0;
}
static int audio_hw_set_parameters(struct audio_hw_device *dev,