audio: select camcorder snd device according to camera orientation
Add audio parameter indicating use of front or back camera to select
proper input path tuning in camcorder mode.
Also take device orientation for stereo channel swaping.
Bug: 118022272
Test: verified with camera service patch sending camera facing parameter
Change-Id: If24b47d922aeedaaa144f4a5f4cacddce2c9eeaf
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index cc1276b..8e04bf8 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -4717,20 +4717,24 @@
adev->screen_off = true;
}
-#ifndef MAXXAUDIO_QDSP_ENABLED
ret = str_parms_get_int(parms, "rotation", &val);
if (ret >= 0) {
bool reverse_speakers = false;
+ int camera_rotation = CAMERA_ROTATION_LANDSCAPE;
switch (val) {
// FIXME: note that the code below assumes that the speakers are in the correct placement
// relative to the user when the device is rotated 90deg from its default rotation. This
// assumption is device-specific, not platform-specific like this code.
case 270:
reverse_speakers = true;
+ camera_rotation = CAMERA_ROTATION_INVERT_LANDSCAPE;
break;
case 0:
- case 90:
case 180:
+ camera_rotation = CAMERA_ROTATION_PORTRAIT;
+ break;
+ case 90:
+ camera_rotation = CAMERA_ROTATION_LANDSCAPE;
break;
default:
ALOGE("%s: unexpected rotation of %d", __func__, val);
@@ -4740,10 +4744,13 @@
// check and set swap
// - check if orientation changed and speaker active
// - set rotation and cache the rotation value
+ adev->camera_orientation =
+ (adev->camera_orientation & ~CAMERA_ROTATION_MASK) | camera_rotation;
+#ifndef MAXXAUDIO_QDSP_ENABLED
platform_check_and_set_swap_lr_channels(adev, reverse_speakers);
+#endif
}
}
-#endif
ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_SCO_WB, value, sizeof(value));
if (ret >= 0) {
@@ -4812,6 +4819,32 @@
}
}
+ //FIXME: to be replaced by proper video capture properties API
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_CAMERA_FACING, value, sizeof(value));
+ if (ret >= 0) {
+ int camera_facing = CAMERA_FACING_BACK;
+ if (strcmp(value, AUDIO_PARAMETER_VALUE_FRONT) == 0)
+ camera_facing = CAMERA_FACING_FRONT;
+ else if (strcmp(value, AUDIO_PARAMETER_VALUE_BACK) == 0)
+ camera_facing = CAMERA_FACING_BACK;
+ else {
+ ALOGW("%s: invalid camera facing value: %s", __func__, value);
+ goto done;
+ }
+ adev->camera_orientation =
+ (adev->camera_orientation & ~CAMERA_FACING_MASK) | camera_facing;
+ struct audio_usecase *usecase;
+ struct listnode *node;
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ struct stream_in *in = usecase->stream.in;
+ if (usecase->type == PCM_CAPTURE && in != NULL &&
+ in->source == AUDIO_SOURCE_CAMCORDER && !in->standby) {
+ select_devices(adev, in->usecase);
+ }
+ }
+ }
+
done:
str_parms_destroy(parms);
pthread_mutex_unlock(&adev->lock);
@@ -5720,6 +5753,8 @@
adev->mic_break_enabled = property_get_bool("vendor.audio.mic_break", false);
+ adev->camera_orientation = CAMERA_DEFAULT;
+
// commented as full set of app type cfg is sent from platform
// audio_extn_utils_send_default_app_type_cfg(adev->platform, adev->mixer);
audio_device_ref_count++;