From 1abb19916d3824827e7cf6edc55da0e8a3fa45ee Mon Sep 17 00:00:00 2001 From: Francescodario Cuzzocrea Date: Mon, 6 Jan 2020 08:33:56 +0100 Subject: [PATCH] msm8226-common: camera: add support for galaxy tab4 devices Change-Id: I349ff302765a47d4b188d8deb0bfd88959da9c61 --- camera/CameraWrapper.cpp | 96 ++++++++++++++++++++++++++++++++++------ 1 file changed, 82 insertions(+), 14 deletions(-) diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp index 7b447f3..e30a133 100644 --- a/camera/CameraWrapper.cpp +++ b/camera/CameraWrapper.cpp @@ -27,6 +27,7 @@ #define LOG_TAG "CameraWrapper" #include +#include #include #include #include @@ -41,6 +42,18 @@ #define OPEN_RETRY_MSEC 40 using namespace android; +using android::base::GetProperty; + +enum { + UNKNOWN = -1, + S3VE3G, + KMINI3G, + MS01, + MATISSE, + MILLET, +}; + +static int product_device = UNKNOWN; const char KEY_SUPPORTED_ISO_MODES[] = "iso-values"; const char KEY_SAMSUNG_CAMERA_MODE[] = "cam_mode"; @@ -95,6 +108,43 @@ camera_module_t HAL_MODULE_INFO_SYM = { .reserved = {0}, /* remove compilation warnings */ }; +static int get_product_device() +{ + if (product_device != UNKNOWN) + return product_device; + + std::string device = GetProperty("ro.product.device", ""); + + if (device == "s3ve3gxx") + product_device = S3VE3G; + else if (device == "s3ve3gjv") + product_device = S3VE3G; + else if (device == "kmini3g") + product_device = KMINI3G; + else if (device == "ms013g") + product_device = MS01; + else if (device == "ms013lte") + product_device = MS01; + else if (device == "matissewifi") + product_device = MATISSE; + else if (device == "matisse3g") + product_device = MATISSE; + else if (device == "matisselte") + product_device = MATISSE; + else if (device == "milletwifi") + product_device = MILLET; + else if (device == "millet3g") + product_device = MILLET; + else if (device == "milletlte") + product_device = MILLET; + else if (device == "milletltetmo") + product_device = MILLET; + else + product_device = UNKNOWN; + + return product_device; +} + typedef struct wrapper_camera_device { camera_device_t base; int camera_released; @@ -166,27 +216,45 @@ static char* camera_fixup_getparams(int id, const char* settings) { #endif params.set(KEY_SUPPORTED_ISO_MODES, iso_values[id]); - params.set(CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO, "1280x720"); - params.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES, - "auto,asd,action,portrait,landscape,night,night-portrait,theatre,beach,snow,sunset," - "steadyphoto,fireworks,sports,party,candlelight,backlight,flowers,AR"); - + if (get_product_device() == S3VE3G || get_product_device() == MS01 || get_product_device() == KMINI3G) { + params.set(CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO, "1280x720"); + params.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES, + "auto,asd,action,portrait,landscape,night,night-portrait,theatre,beach,snow,sunset," + "steadyphoto,fireworks,sports,party,candlelight,backlight,flowers,AR"); + } + + if (( get_product_device() == MATISSE) || ( get_product_device() == MILLET)) { + params.set(CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO, "640x480" ); + } /* If the vendor has HFR values but doesn't also expose that * this can be turned off, fixup the params to tell the Camera * that it really is okay to turn it off. */ - const char *hfrModeValues = params.get(KEY_VIDEO_HFR_VALUES); - if (hfrModeValues && !strstr(hfrModeValues, "off")) { - char hfrModes[strlen(hfrModeValues) + 4 + 1]; - sprintf(hfrModes, "%s,off", hfrModeValues); - params.set(KEY_VIDEO_HFR_VALUES, hfrModes); + if (get_product_device() == S3VE3G || get_product_device() == MS01 || get_product_device() == KMINI3G) { + const char *hfrModeValues = params.get(KEY_VIDEO_HFR_VALUES); + if (hfrModeValues && !strstr(hfrModeValues, "off")) { + char hfrModes[strlen(hfrModeValues) + 4 + 1]; + sprintf(hfrModes, "%s,off", hfrModeValues); + params.set(KEY_VIDEO_HFR_VALUES, hfrModes); + } } - if (id == BACK_CAMERA_ID) { - params.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "auto,on,off,torch"); - params.set(KEY_SUPPORTED_HFR_SIZES, "1280x720,720x480"); - params.set(KEY_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, "60,off"); + if (( get_product_device() == MATISSE) || ( get_product_device() == MILLET)) { + params.set(KEY_VIDEO_HFR_VALUES, "off"); + } + if (id == BACK_CAMERA_ID) { + if (get_product_device() == S3VE3G || get_product_device() == MS01 || get_product_device() == KMINI3G) { + params.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "auto,on,off,torch"); + params.set(KEY_SUPPORTED_HFR_SIZES, "1280x720,720x480"); + params.set(KEY_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, "60,off"); + } + } + if (( get_product_device() == MATISSE) || ( get_product_device() == MILLET)) { + params.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5"); + params.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-4"); + params.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "4"); + params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, "640x360,640x480,352x288,320x240,176x144"); } #if !LOG_NDEBUG