klte-common: camera: Set preview-format for 4k video recording
Change-Id: I31f21fb1e15511422798aca1dcde3f2f8e18a58d Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
This commit is contained in:
parent
245350b8d7
commit
9a2b3611ff
1 changed files with 26 additions and 1 deletions
|
@ -99,6 +99,17 @@ static int check_vendor_module()
|
|||
|
||||
#define KEY_VIDEO_HFR_VALUES "video-hfr-values"
|
||||
|
||||
// nv12-venus is needed for blobs, but
|
||||
// framework has no idea what it is
|
||||
#define PIXEL_FORMAT_NV12_VENUS "nv12-venus"
|
||||
|
||||
static bool is_4k_video(android::CameraParameters ¶ms) {
|
||||
int video_width, video_height;
|
||||
params.getVideoSize(&video_width, &video_height);
|
||||
ALOGV("%s : VideoSize is %x", __FUNCTION__, video_width * video_height);
|
||||
return video_width * video_height == 3840 * 2160;
|
||||
}
|
||||
|
||||
static char *camera_fixup_getparams(int __attribute__((unused)) id,
|
||||
const char *settings)
|
||||
{
|
||||
|
@ -110,6 +121,10 @@ static char *camera_fixup_getparams(int __attribute__((unused)) id,
|
|||
params.dump();
|
||||
#endif
|
||||
|
||||
//Hide nv12-venus from Android.
|
||||
if (strcmp (params.getPreviewFormat(), PIXEL_FORMAT_NV12_VENUS) == 0)
|
||||
params.setPreviewFormat(params.PIXEL_FORMAT_YUV420SP);
|
||||
|
||||
const char *videoSizeValues = params.get(
|
||||
android::CameraParameters::KEY_SUPPORTED_VIDEO_SIZES);
|
||||
if (videoSizeValues) {
|
||||
|
@ -182,7 +197,8 @@ static char *camera_fixup_setparams(int id, const char *settings)
|
|||
/*******************************************************************
|
||||
* implementation of camera_device_ops functions
|
||||
*******************************************************************/
|
||||
|
||||
static char *camera_get_parameters(struct camera_device *device);
|
||||
static int camera_set_parameters(struct camera_device *device, const char *params);
|
||||
static int camera_set_preview_window(struct camera_device *device,
|
||||
struct preview_stream_ops *window)
|
||||
{
|
||||
|
@ -300,6 +316,15 @@ static int camera_start_recording(struct camera_device *device)
|
|||
if (!device)
|
||||
return EINVAL;
|
||||
|
||||
android::CameraParameters parameters;
|
||||
parameters.unflatten(android::String8(camera_get_parameters(device)));
|
||||
|
||||
if (is_4k_video(parameters)) {
|
||||
ALOGV("%s : UHD detected, switching preview-format to nv12-venus", __FUNCTION__);
|
||||
parameters.setPreviewFormat(PIXEL_FORMAT_NV12_VENUS);
|
||||
camera_set_parameters(device, strdup(parameters.flatten().string()));
|
||||
}
|
||||
|
||||
return VENDOR_CALL(device, start_recording);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue