Commit cba85ab2119fcde212ed831f1085127b6a5e4323

Authored by jiangchaobing
1 parent 5beb4058

T3212:add camera(gc6133) drv

... ... @@ -5593,7 +5593,7 @@ TOPWELL_HW_KEYMAP_EXT4_FUNCTION = NONE
5593 5593 # 扩展键4
5594 5594 # NONE, ....
5595 5595
5596   -TOPWELL_HW_SENSOR = SING_CAM : GC6123_SERIAL GC6113_SERIAL SP0829_SERIAL
  5596 +TOPWELL_HW_SENSOR = SING_CAM : GC6123_SERIAL GC6133_SERIAL GC6113_SERIAL SP0829_SERIAL
5597 5597 # TOPWELL 摄像头兼容
5598 5598 # 请根据实际按固定方式填写
5599 5599
... ...
  1 +/*****************************************************************************
  2 +* Copyright Statement:
  3 +* --------------------
  4 +* This software is protected by Copyright and the information contained
  5 +* herein is confidential. The software may not be copied and the information
  6 +* contained herein may not be used or disclosed except with the written
  7 +* permission of MediaTek Inc. (C) 2010
  8 +*
  9 +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10 +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11 +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12 +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13 +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14 +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15 +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16 +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17 +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18 +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19 +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20 +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21 +*
  22 +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23 +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24 +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25 +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26 +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27 +*
  28 +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29 +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30 +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31 +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32 +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33 +*
  34 +*****************************************************************************/
  35 +
  36 +/*****************************************************************************
  37 + *
  38 + * Filename:
  39 + * ---------
  40 + * image_sensor_GC6133_SERIAL.h
  41 + *
  42 + * Project:
  43 + * --------
  44 + * MAUI_sw
  45 + *
  46 + * Description:
  47 + * ------------
  48 + * CMOS sensor header file
  49 + *
  50 + * Author:
  51 + * -------
  52 + * Mormo_Hui
  53 + *
  54 + *============================================================================
  55 + * HISTORY
  56 + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  57 + *------------------------------------------------------------------------------
  58 + * $Revision:$1.0.0
  59 + *
  60 + * $Modtime:$2011/08/25
  61 + *
  62 + * $Log:$
  63 + * 2011/08/25 Firstly Released By Mormo.
  64 + *
  65 + * Initial revision.
  66 + *------------------------------------------------------------------------------
  67 + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  68 + *============================================================================
  69 + ****************************************************************************/
  70 +#ifndef _IMAGE_SENSOR_GC6133_SERIAL_H
  71 +#define _IMAGE_SENSOR_GC6133_SERIAL_H
  72 +
  73 +#include "sensor_comm_def.h"
  74 +
  75 +/* This used for debug phase use only, to speed up the initial setting modify,
  76 + NOTICE: It need to be marked when MP release version, or else it will effect the enter
  77 + camera time and waste some ram. */
  78 +//#define GC6133_SERIAL_LOAD_FROM_T_FLASH
  79 +
  80 +/* DEBUG USE ONLY */
  81 +//#define __GC6133_SERIAL_DEBUG_TRACE__
  82 +
  83 +#ifdef __GC6133_SERIAL_DEBUG_TRACE__
  84 +#include "kal_trace.h"
  85 +
  86 +#define GC6133_SERIAL_TRACE(...) kal_print_string_trace(MOD_ENG, TRACE_INFO, "[GC6133_SERIAL]"__VA_ARGS__)
  87 +#else
  88 +#define GC6133_SERIAL_TRACE(...)
  89 +#endif
  90 +
  91 +/* SENSOR MASTER CLOCK */
  92 +#define GC6133_SERIAL_MCLK 24000000
  93 +
  94 +// TODO: modify sensor dependent macro value here
  95 +
  96 +/* SENSOR I2C WRITE ID */
  97 +#define GC6133_SERIAL_WRITE_ID_0 (0x80)
  98 +#define GC6133_SERIAL_WRITE_ID_1 (0xFF)
  99 +#define GC6133_SERIAL_WRITE_ID_2 (0xFF)
  100 +#define GC6133_SERIAL_WRITE_ID_3 (0xFF)
  101 +
  102 +/* SENSOR I2C ADDR/DATA WIDTH */
  103 +#define GC6133_SERIAL_I2C_ADDR_BITS CAMERA_SCCB_8BIT /* CAMERA_SCCB_8BIT / CAMERA_SCCB_16BIT */
  104 +#define GC6133_SERIAL_I2C_DATA_BITS CAMERA_SCCB_8BIT /* CAMERA_SCCB_8BIT / CAMERA_SCCB_16BIT */
  105 +
  106 +/* SENSOR PREVIEW SIZE (5M:1296x972 or 640x480, 3M: 1024x768 or 640x480, 2M: 800x600, 1.3M: 640x512, VGA: 640x480, CIF: 352x288) */
  107 +#define GC6133_SERIAL_IMAGE_SENSOR_PV_WIDTH (240)
  108 +#define GC6133_SERIAL_IMAGE_SENSOR_PV_HEIGHT (320)
  109 +/* SENSOR CAPTURE SIZE (5M: 2592x1944, 3M: 2048x1536, 2M: 1600x1200, 1.3M: 1280x1024, VGA: 640x480, CIF: 352x288) */
  110 +#define GC6133_SERIAL_IMAGE_SENSOR_FULL_WIDTH (240)
  111 +#define GC6133_SERIAL_IMAGE_SENSOR_FULL_HEIGHT (320)
  112 +
  113 +/* SENSOR PIXEL/LINE NUMBERS IN ONE PERIOD */
  114 +#define GC6133_SERIAL_PV_PERIOD_PIXEL_NUMS (240)
  115 +#define GC6133_SERIAL_PV_PERIOD_LINE_NUMS (320)
  116 +#define GC6133_SERIAL_FULL_PERIOD_PIXEL_NUMS (240)
  117 +#define GC6133_SERIAL_FULL_PERIOD_LINE_NUMS (320)
  118 +
  119 +/* SENSOR LINELENGTH&FRAMELENGTH LIMITATION */
  120 +#define GC6133_SERIAL_MAX_PV_LINELENGTH (4095 + 694) /* register limitation */
  121 +#define GC6133_SERIAL_MAX_PV_FRAMELENGTH (4095 + 488) /* register limitation */
  122 +#define GC6133_SERIAL_MAX_CAP_LINELENGTH (GC6133_SERIAL_MAX_PV_LINELENGTH) /* register limitation */
  123 +#define GC6133_SERIAL_MAX_CAP_FRAMELENGTH (GC6133_SERIAL_MAX_PV_FRAMELENGTH) /* register limitation */
  124 +
  125 +/* SENSOR SHUTTER MARGIN */
  126 +#define GC6133_SERIAL_SHUTTER_MARGIN (1)
  127 +
  128 +/* SENSOR DELAY FRAME */
  129 +#define GC6133_SERIAL_FIRST_PREVIEW_DELAY_FRAME (5)//3
  130 +#define GC6133_SERIAL_PREVIEW_DELAY_FRAME (3)
  131 +#define GC6133_SERIAL_CAPTURE_DELAY_FRAME (2)
  132 +
  133 +/* SENSOR PREVIEW/CAPTURE INTERNAL CLOCK */
  134 +#if GC6133_SERIAL_MCLK == 24000000
  135 + #if (defined(DRV_ISP_6276_SERIES) || defined(DRV_ISP_MT6236_HW_SUPPORT))
  136 + /* pclk limitation is 96MHz, preview pclk = min(pclk@30fps,96MHz), capture pclk = min(pclk@15fps,96MHz) */
  137 + #define GC6133_SERIAL_PV_INTERNAL_CLK 12000000
  138 + #define GC6133_SERIAL_CAP_INTERNAL_CLK 12000000
  139 + #elif (defined(DRV_ISP_MT6268_HW_SUPPORT))
  140 + /* pclk limitation is 52MHz, preview pclk = min(pclk@30fps,52MHz), capture pclk = min(pclk@15fps,52MHz) */
  141 + #define GC6133_SERIAL_PV_INTERNAL_CLK 12000000
  142 + #define GC6133_SERIAL_CAP_INTERNAL_CLK 12000000
  143 + #else
  144 + /* pclk limitation is 48MHz, preview pclk = min(pclk@30fps,48MHz), capture pclk = min(pclk@15fps,48MHz) */
  145 + #define GC6133_SERIAL_PV_INTERNAL_CLK 12000000
  146 + #define GC6133_SERIAL_CAP_INTERNAL_CLK 12000000
  147 + #endif
  148 +#else
  149 + #if (defined(DRV_ISP_6276_SERIES) || defined(DRV_ISP_MT6236_HW_SUPPORT))
  150 + /* pclk limitation is 96MHz, preview pclk = min(pclk@30fps,96MHz), capture pclk = min(pclk@15fps,96MHz) */
  151 + #define GC6133_SERIAL_PV_INTERNAL_CLK 13000000
  152 + #define GC6133_SERIAL_CAP_INTERNAL_CLK 13000000
  153 + #elif (defined(DRV_ISP_MT6268_HW_SUPPORT))
  154 + /* pclk limitation is 52MHz, preview pclk = min(pclk@30fps,52MHz), capture pclk = min(pclk@15fps,52MHz) */
  155 + #define GC6133_SERIAL_PV_INTERNAL_CLK 13000000
  156 + #define GC6133_SERIAL_CAP_INTERNAL_CLK 13000000
  157 + #else
  158 + /* pclk limitation is 48MHz, preview pclk = min(pclk@30fps,48MHz), capture pclk = min(pclk@15fps,48MHz) */
  159 + #define GC6133_SERIAL_PV_INTERNAL_CLK 13000000
  160 + #define GC6133_SERIAL_CAP_INTERNAL_CLK 13000000
  161 + #endif
  162 +#endif
  163 +
  164 +/* ===============================================================================
  165 + ========================= No Changing The Macro Below =========================
  166 + ===============================================================================
  167 +*/
  168 +
  169 +/* CONFIG THE ISP GRAB START X & START Y, CONFIG THE ISP GRAB WIDTH & HEIGHT */
  170 +#define GC6133_SERIAL_PV_GRAB_START_X (0)
  171 +#define GC6133_SERIAL_PV_GRAB_START_Y (1)
  172 +#define GC6133_SERIAL_FULL_GRAB_START_X (0)
  173 +#define GC6133_SERIAL_FULL_GRAB_START_Y (1)
  174 +#define GC6133_SERIAL_PV_GRAB_WIDTH (GC6133_SERIAL_IMAGE_SENSOR_PV_WIDTH - 2)
  175 +#define GC6133_SERIAL_PV_GRAB_HEIGHT (GC6133_SERIAL_IMAGE_SENSOR_PV_HEIGHT - 2)
  176 +#define GC6133_SERIAL_FULL_GRAB_WIDTH (GC6133_SERIAL_IMAGE_SENSOR_FULL_WIDTH - 2)
  177 +#define GC6133_SERIAL_FULL_GRAB_HEIGHT (GC6133_SERIAL_IMAGE_SENSOR_FULL_HEIGHT - 2)
  178 +
  179 +/* FLICKER OF FREQUENCY */
  180 +#define GC6133_SERIAL_50HZ 100
  181 +#define GC6133_SERIAL_60HZ 120
  182 +
  183 +/* RESET/POWER DOWN PIN CONTROL */
  184 +#define GC6133_SERIAL_SET_RST_LOW CamRstPinCtrl(GC6133_SERIALSensor.SensorIdx, 0)
  185 +#define GC6133_SERIAL_SET_RST_HIGH CamRstPinCtrl(GC6133_SERIALSensor.SensorIdx, 1)
  186 +#define GC6133_SERIAL_SET_PDN_LOW CamPdnPinCtrl(GC6133_SERIALSensor.SensorIdx, 0)
  187 +#define GC6133_SERIAL_SET_PDN_HIGH CamPdnPinCtrl(GC6133_SERIALSensor.SensorIdx, 1)
  188 +
  189 +/* HW I2C SPEED */
  190 +#define GC6133_SERIAL_HW_I2C_SPEED 100 /* Kbps */
  191 +
  192 +/* FRAME RATE UNIT */
  193 +#define GC6133_SERIAL_FPS(x) ((kal_uint32)(10 * (x)))
  194 +
  195 +/* --------------------------------- common eara --------------------------------- */
  196 +/* EXPORT FUNC */
  197 +MM_ERROR_CODE_ENUM GC6133_SERIALSensorFunc(P_IMAGE_SENSOR_FUNCTION_STRUCT *pfSensorFunc);
  198 +
  199 +/* IMPORT FUNC */
  200 +MM_ERROR_CODE_ENUM GC6133_SERIALWebcamFeatureCtrl(kal_uint32 Id, void *In, void *Out, kal_uint32 OutLen, kal_uint32 *RealOutLen);
  201 +
  202 +#endif
  203 +
... ...
  1 +/*****************************************************************************
  2 +* Copyright Statement:
  3 +* --------------------
  4 +* This software is protected by Copyright and the information contained
  5 +* herein is confidential. The software may not be copied and the information
  6 +* contained herein may not be used or disclosed except with the written
  7 +* permission of MediaTek Inc. (C) 2010
  8 +*
  9 +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10 +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11 +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12 +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13 +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14 +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15 +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16 +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17 +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18 +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19 +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20 +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21 +*
  22 +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23 +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24 +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25 +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26 +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27 +*
  28 +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29 +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30 +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31 +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32 +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33 +*
  34 +*****************************************************************************/
  35 +
  36 +/*****************************************************************************
  37 + *
  38 + * Filename:
  39 + * ---------
  40 + * image_sensor_GC6133_SERIAL.c
  41 + *
  42 + * Project:
  43 + * --------
  44 + * Maui_sw
  45 + *
  46 + * Description:
  47 + * ------------
  48 + * Image sensor driver function_11A&11B
  49 + *
  50 + * Author:
  51 + * -------
  52 + * Mormo_Hui
  53 + *
  54 + *============================================================================
  55 + * HISTORY
  56 + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  57 + *------------------------------------------------------------------------------
  58 + * $Revision:$1.0.0
  59 + *
  60 + * $Modtime:$2012/11/15
  61 + *
  62 + * $Log:$
  63 + * 2012/11/15 Fristly Released By Mormo.
  64 + *
  65 + *
  66 + *------------------------------------------------------------------------------
  67 + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  68 + *============================================================================
  69 + ****************************************************************************/
  70 +#include "drv_comm.h"
  71 +#include "isp_comm_if.h"
  72 +#include "camera_sccb.h"
  73 +#include "image_sensor.h"
  74 +#include "cal_comm_def.h"
  75 +#include "isp_if.h"
  76 +
  77 +#if defined(__TOPWELL_SENSOR_GC6133_SERIAL__) && (defined(__TOPWELL_T3212__))
  78 +
  79 +static struct
  80 +{
  81 + kal_bool BypassAe;
  82 + kal_bool BypassAwb;
  83 + kal_bool CapState; /* KAL_TRUE: in capture state, else in preview state */
  84 + kal_bool PvMode; /* KAL_TRUE: preview size output, else full size output */
  85 + kal_bool sccb_opened;
  86 + kal_bool VideoMode; /* KAL_TRUE: video mode, else preview mode */
  87 + kal_bool NightMode;/*KAL_TRUE:work in night mode, else normal mode*/
  88 + kal_uint8 BandingFreq; /* GC6133_SERIAL_50HZ or GC6133_SERIAL_60HZ for 50Hz/60Hz */
  89 + kal_uint32 InternalClock; /* internal clock which using process pixel(for exposure) */
  90 + kal_uint32 Pclk; /* output clock which output to baseband */
  91 + kal_uint32 Gain; /* base on 0x40 */
  92 + kal_uint32 Shutter; /* unit is (linelength / internal clock) s */
  93 + kal_uint32 FrameLength; /* total line numbers in one frame(include dummy line) */
  94 + kal_uint32 LineLength; /* total pixel numbers in one line(include dummy pixel) */
  95 + IMAGE_SENSOR_INDEX_ENUM SensorIdx;
  96 + sensor_data_struct *NvramData;
  97 +} GC6133_SERIALSensor;
  98 +
  99 +#define GC6133_SERIAL_SET_PAGE0 CamWriteCmosSensor(0xfe , 0x00)
  100 +#define GC6133_SERIAL_SET_PAGE1 CamWriteCmosSensor(0xfe , 0x01)
  101 +#define GC6133_SERIAL_SET_PAGE2 CamWriteCmosSensor(0xfe , 0x02)
  102 +kal_bool GC6133_SERIAL_CAM_BANDING_50HZ = KAL_FALSE;
  103 +
  104 +#ifdef GC6133_SERIAL_LOAD_FROM_T_FLASH
  105 +/*************************************************************************
  106 +* FUNCTION
  107 +* GC6133_SERIAL_Initialize_from_T_Flash
  108 +*
  109 +* DESCRIPTION
  110 +* Read the initialize setting from t-flash or user disk to speed up image quality tuning.
  111 +*
  112 +* PARAMETERS
  113 +* None
  114 +*
  115 +* RETURNS
  116 +* kal_uint8 - 0 : Load setting fail, 1 : Load setting successfully.
  117 +*
  118 +*************************************************************************/
  119 +static kal_uint8 GC6133_SERIAL_Initialize_from_T_Flash()
  120 +{
  121 +#include <stdlib.h>
  122 +#include "med_utility.h"
  123 +#include "fs_type.h"
  124 +
  125 +#if GC6133_SERIAL_I2C_ADDR_BITS == CAMERA_SCCB_16BIT
  126 + #define GC6133_SERIAL_REG_SKIP 0x08
  127 +#else
  128 + #define GC6133_SERIAL_REG_SKIP 0x03
  129 +#endif
  130 +#if GC6133_SERIAL_I2C_DATA_BITS == CAMERA_SCCB_16BIT
  131 + #define GC6133_SERIAL_VAL_SKIP 0x08
  132 +#else
  133 + #define GC6133_SERIAL_VAL_SKIP 0x03
  134 +#endif
  135 +
  136 + /* 0 - Initial value, 1 - Register, 2 - Delay, 3 - End of setting. */
  137 + #define GC6133_SERIAL_OP_CODE_INI 0x00 /* Initial value. */
  138 + #define GC6133_SERIAL_OP_CODE_REG 0x01 /* Register */
  139 + #define GC6133_SERIAL_OP_CODE_DLY 0x02 /* Delay */
  140 + #define GC6133_SERIAL_OP_CODE_END 0x03 /* End of initial setting. */
  141 +
  142 + typedef struct
  143 + {
  144 + kal_uint16 init_reg;
  145 + kal_uint16 init_val; /* Save the register value and delay tick */
  146 + kal_uint8 op_code; /* 0 - Initial value, 1 - Register, 2 - Delay, 3 - End of setting. */
  147 + } GC6133_SERIAL_initial_set_struct;
  148 +
  149 + static GC6133_SERIAL_initial_set_struct GC6133_SERIAL_Init_Reg[1000];
  150 + static WCHAR GC6133_SERIAL_set_file_name[256] = {0};
  151 + FS_HANDLE fp = -1; /* Default, no file opened. */
  152 + kal_uint8 *data_buff = NULL;
  153 + kal_uint8 *curr_ptr = NULL;
  154 + kal_uint32 file_size = 0;
  155 + kal_uint32 bytes_read = 0;
  156 + kal_uint32 i = 0, j = 0;
  157 + kal_uint8 func_ind[3] = {0}; /* REG or DLY */
  158 +
  159 + kal_mem_cpy(GC6133_SERIAL_set_file_name, L"C:\\GC6133_SERIAL_Initialize_Setting.Bin", sizeof(L"C:\\GC6133_SERIAL_Initialize_Setting.Bin"));
  160 +
  161 + /* Search the setting file in all of the user disk. */
  162 + curr_ptr = (kal_uint8 *)GC6133_SERIAL_set_file_name;
  163 + while (fp < 0)
  164 + {
  165 + if ((*curr_ptr >= 'c' && *curr_ptr <= 'z') || (*curr_ptr >= 'C' && *curr_ptr <= 'Z'))
  166 + {
  167 + fp = FS_Open(GC6133_SERIAL_set_file_name, FS_READ_ONLY);
  168 + if (fp >= 0)
  169 + {
  170 + break; /* Find the setting file. */
  171 + }
  172 + *curr_ptr = *curr_ptr + 1;
  173 + }
  174 + else
  175 + {
  176 + break ;
  177 + }
  178 + }
  179 + if (fp < 0) /* Error handle */
  180 + {
  181 + GC6133_SERIAL_TRACE("!!! Warning, Can't find the initial setting file!!!");
  182 + return 0;
  183 + }
  184 +
  185 + FS_GetFileSize(fp, &file_size);
  186 + if (file_size < 20)
  187 + {
  188 + GC6133_SERIAL_TRACE("!!! Warning, Invalid setting file!!!");
  189 + return 0; /* Invalid setting file. */
  190 + }
  191 +
  192 + data_buff = med_alloc_ext_mem(file_size);
  193 + if (data_buff == NULL)
  194 + {
  195 + GC6133_SERIAL_TRACE("!!! Warning, Memory not enoughed...");
  196 + return 0; /* Memory not enough */
  197 + }
  198 + FS_Read(fp, data_buff, file_size, &bytes_read);
  199 +
  200 + /* Start parse the setting witch read from t-flash. */
  201 + curr_ptr = data_buff;
  202 + while (curr_ptr < (data_buff + file_size))
  203 + {
  204 + while ((*curr_ptr == ' ') || (*curr_ptr == '\t'))/* Skip the Space & TAB */
  205 + curr_ptr++;
  206 + if (((*curr_ptr) == '/') && ((*(curr_ptr + 1)) == '*'))
  207 + {
  208 + while (!(((*curr_ptr) == '*') && ((*(curr_ptr + 1)) == '/')))
  209 + {
  210 + curr_ptr++; /* Skip block comment code. */
  211 + }
  212 + while (!((*curr_ptr == 0x0D) && (*(curr_ptr+1) == 0x0A)))
  213 + {
  214 + curr_ptr++;
  215 + }
  216 + curr_ptr += 2; /* Skip the enter line */
  217 + continue ;
  218 + }
  219 +
  220 + if (((*curr_ptr) == '/') || ((*curr_ptr) == '{') || ((*curr_ptr) == '}')) /* Comment line, skip it. */
  221 + {
  222 + while (!((*curr_ptr == 0x0D) && (*(curr_ptr+1) == 0x0A)))
  223 + {
  224 + curr_ptr++;
  225 + }
  226 +
  227 + curr_ptr += 2; /* Skip the enter line */
  228 +
  229 + continue ;
  230 + }
  231 + /* This just content one enter line. */
  232 + if (((*curr_ptr) == 0x0D) && ((*(curr_ptr + 1)) == 0x0A))
  233 + {
  234 + curr_ptr += 2;
  235 + continue ;
  236 + }
  237 +
  238 + kal_mem_cpy(func_ind, curr_ptr, 3);
  239 + curr_ptr += 4; /* Skip "REG(" or "DLY(" */
  240 + if (strcmp((const char *)func_ind, "REG") == 0) /* REG */
  241 + {
  242 + GC6133_SERIAL_Init_Reg[i].op_code = GC6133_SERIAL_OP_CODE_REG;
  243 +
  244 + GC6133_SERIAL_Init_Reg[i].init_reg = strtol((const char *)curr_ptr, NULL, 16);
  245 + curr_ptr += GC6133_SERIAL_REG_SKIP; /* Skip "0x0000, " */
  246 +
  247 + GC6133_SERIAL_Init_Reg[i].init_val = strtol((const char *)curr_ptr, NULL, 16);
  248 + // curr_ptr += GC6133_SERIAL_VAL_SKIP; /* Skip "0x0000);" */
  249 + }
  250 + else /* DLY */
  251 + {
  252 + /* Need add delay for this setting. */
  253 + GC6133_SERIAL_Init_Reg[i].op_code = GC6133_SERIAL_OP_CODE_DLY;
  254 +
  255 + GC6133_SERIAL_Init_Reg[i].init_reg = 0xFF;
  256 + GC6133_SERIAL_Init_Reg[i].init_val = strtol((const char *)curr_ptr, NULL, 10); /* Get the delay ticks, the delay should less then 50 */
  257 + }
  258 + i++;
  259 +
  260 + /* Skip to next line directly. */
  261 + while (!((*curr_ptr == 0x0D) && (*(curr_ptr+1) == 0x0A)))
  262 + {
  263 + curr_ptr++;
  264 + }
  265 + curr_ptr += 2;
  266 + }
  267 +
  268 + /* (0xFFFF, 0xFFFF) means the end of initial setting. */
  269 + GC6133_SERIAL_Init_Reg[i].op_code = GC6133_SERIAL_OP_CODE_END;
  270 + GC6133_SERIAL_Init_Reg[i].init_reg = 0xFF;
  271 + GC6133_SERIAL_Init_Reg[i].init_val = 0xFF;
  272 + i++;
  273 +
  274 + GC6133_SERIAL_TRACE("%d register read...", i - 1);
  275 + med_free_ext_mem((void **)&data_buff);
  276 + FS_Close(fp);
  277 +
  278 + GC6133_SERIAL_TRACE("Start apply initialize setting.");
  279 + /* Start apply the initial setting to sensor. */
  280 + for (j=0; j<i; j++)
  281 + {
  282 + if (GC6133_SERIAL_Init_Reg[j].op_code == GC6133_SERIAL_OP_CODE_END) /* End of the setting. */
  283 + {
  284 + break ;
  285 + }
  286 + else if (GC6133_SERIAL_Init_Reg[j].op_code == GC6133_SERIAL_OP_CODE_DLY)
  287 + {
  288 + kal_sleep_task(GC6133_SERIAL_Init_Reg[j].init_val); /* Delay */
  289 + }
  290 + else if (GC6133_SERIAL_Init_Reg[j].op_code == GC6133_SERIAL_OP_CODE_REG)
  291 + {
  292 + CamWriteCmosSensor(GC6133_SERIAL_Init_Reg[j].init_reg, GC6133_SERIAL_Init_Reg[j].init_val);
  293 + }
  294 + else
  295 + {
  296 + ASSERT(0);
  297 + }
  298 + }
  299 + GC6133_SERIAL_TRACE("%d register applied...", j);
  300 + return 1;
  301 +}
  302 +#endif
  303 +
  304 +/*************************************************************************
  305 +* FUNCTION
  306 +* GC6133_SERIALSetMirror
  307 +*
  308 +* DESCRIPTION
  309 +* This function set the mirror to the CMOS sensor
  310 +* IMPORTANT NOTICE:
  311 +* the color should be normal when mirror or flip
  312 +*
  313 +* PARAMETERS
  314 +* Mirror
  315 +*
  316 +* RETURNS
  317 +* None
  318 +*
  319 +* LOCAL AFFECTED
  320 +*
  321 +*************************************************************************/
  322 +static void GC6133_SERIALSetMirror(kal_uint8 Mirror)
  323 +{
  324 + // TODO: set mirror&flip here
  325 + CamWriteCmosSensor(0xfe, 0x00);
  326 + switch (Mirror)
  327 + {
  328 + case IMAGE_SENSOR_MIRROR_H:
  329 + CamWriteCmosSensor(0x14, 0x55);
  330 + CamWriteCmosSensor(0x16, 0x08);
  331 + CamWriteCmosSensor(0x37, 0x46); //[4:0]blk_select_row
  332 + break;
  333 + case IMAGE_SENSOR_MIRROR_V:
  334 + CamWriteCmosSensor(0x14, 0x5e);
  335 + CamWriteCmosSensor(0x16, 0x04);
  336 + CamWriteCmosSensor(0x37, 0x30); //[4:0]blk_select_row
  337 + break;
  338 + case IMAGE_SENSOR_MIRROR_HV:
  339 + CamWriteCmosSensor(0x14, 0x5f);
  340 + CamWriteCmosSensor(0x16, 0x08);
  341 + CamWriteCmosSensor(0x37, 0x30); //[4:0]blk_select_row
  342 + break;
  343 + default:
  344 + CamWriteCmosSensor(0x14, 0x54);
  345 + CamWriteCmosSensor(0x16, 0x04);
  346 + CamWriteCmosSensor(0x37, 0x46); //[4:0]blk_select_row
  347 + break;
  348 + }
  349 +}
  350 +
  351 +/*************************************************************************
  352 +* FUNCTION
  353 +* GC6133_SERIALSetClock
  354 +*
  355 +* DESCRIPTION
  356 +* This function set sensor internal clock and output clock
  357 +*
  358 +* PARAMETERS
  359 +* Clk: internal clock
  360 +*
  361 +* RETURNS
  362 +* None
  363 +*
  364 +* LOCAL AFFECTED
  365 +*
  366 +*************************************************************************/
  367 +static void GC6133_SERIALSetClock(kal_uint32 InternalClock)
  368 +{
  369 + if (GC6133_SERIALSensor.InternalClock == InternalClock)
  370 + {
  371 + return;
  372 + }
  373 + GC6133_SERIALSensor.InternalClock = InternalClock;
  374 + // TODO: set internal clock(use process pixel) and output clock(ouput to baseband) here
  375 + {
  376 + kal_uint8 ClkDiv;
  377 + /* add PLL comment here */
  378 + switch (InternalClock)
  379 + {
  380 + case GC6133_SERIAL_MCLK / 2:
  381 + ClkDiv = 0x00;
  382 + break; /* pclk = mclk */
  383 + case GC6133_SERIAL_MCLK / 4:
  384 + ClkDiv = 0x11;
  385 + break; /* pclk = mclk / 2 */
  386 + case GC6133_SERIAL_MCLK / 8:
  387 + ClkDiv = 0x32;
  388 + break; /* pclk = mclk / 4 */
  389 + default: ASSERT(0);
  390 + }
  391 + CamWriteCmosSensor(0xfa, ClkDiv);
  392 + }
  393 +}
  394 +
  395 +/*************************************************************************
  396 +* FUNCTION
  397 +* GC6133_SERIALWriteShutter
  398 +*
  399 +* DESCRIPTION
  400 +* This function apply shutter to sensor
  401 +*
  402 +* PARAMETERS
  403 +* Shutter: integration time, unit: (linelength / internal clock) s
  404 +*
  405 +* RETURNS
  406 +* None
  407 +*
  408 +* LOCAL AFFECTED
  409 +*
  410 +*************************************************************************/
  411 +static void GC6133_SERIALWriteShutter(kal_uint32 Shutter)
  412 +{
  413 + // TODO: set integration time here
  414 + CamWriteCmosSensor(0x03, Shutter >> 8);
  415 + CamWriteCmosSensor(0x04, Shutter);
  416 +}
  417 +
  418 +/*************************************************************************
  419 +* FUNCTION
  420 +* GC6133_SERIALReadShutter
  421 +*
  422 +* DESCRIPTION
  423 +* This function get shutter from sensor
  424 +*
  425 +* PARAMETERS
  426 +* None
  427 +*
  428 +* RETURNS
  429 +* Shutter: integration time, unit: (linelength / internal clock) s
  430 +*
  431 +* LOCAL AFFECTED
  432 +*
  433 +*************************************************************************/
  434 +static kal_uint32 GC6133_SERIALReadShutter(void)
  435 +{
  436 + // TODO: read integration time here
  437 + return (CamReadCmosSensor(0x03) << 8)|CamReadCmosSensor(0x04);
  438 +}
  439 +
  440 +/*************************************************************************
  441 +* FUNCTION
  442 +* GC6133_SERIALWriteGain
  443 +*
  444 +* DESCRIPTION
  445 +* This function apply global gain to sensor
  446 +*
  447 +* PARAMETERS
  448 +* Gain: base on 0x40
  449 +*
  450 +* RETURNS
  451 +* None
  452 +*
  453 +* LOCAL AFFECTED
  454 +*
  455 +*************************************************************************/
  456 +static void GC6133_SERIALWriteGain(kal_uint32 Gain)
  457 +{
  458 + // TODO: set global gain here
  459 +
  460 +}
  461 +
  462 +/*************************************************************************
  463 +* FUNCTION
  464 +* GC6133_SERIALReadGain
  465 +*
  466 +* DESCRIPTION
  467 +* This function get global gain from sensor
  468 +*
  469 +* PARAMETERS
  470 +* None
  471 +*
  472 +* RETURNS
  473 +* Gain: base on 0x40
  474 +*
  475 +* LOCAL AFFECTED
  476 +*
  477 +*************************************************************************/
  478 +static kal_uint32 GC6133_SERIALReadGain(void)
  479 +{
  480 + // TODO: read global gain here
  481 +
  482 + return 0x40;
  483 +}
  484 +
  485 +/*************************************************************************
  486 +* FUNCTION
  487 +* GC6133_SERIALAeEnable
  488 +*
  489 +* DESCRIPTION
  490 +* disable/enable AE
  491 +*
  492 +* PARAMETERS
  493 +* Enable
  494 +*
  495 +* RETURNS
  496 +* None
  497 +*
  498 +* LOCAL AFFECTED
  499 +*
  500 +*************************************************************************/
  501 +static void GC6133_SERIALAeEnable(kal_bool Enable)
  502 +{
  503 + kal_uint16 temp_ae_reg;
  504 + if (GC6133_SERIALSensor.BypassAe)
  505 + {
  506 + Enable = KAL_FALSE;
  507 + }
  508 +
  509 + // TODO: enable or disable AE here
  510 + {
  511 + CamWriteCmosSensor(0xfe, 0x00);
  512 + temp_ae_reg = CamReadCmosSensor(0xa4);
  513 + if (Enable)
  514 + {
  515 + CamWriteCmosSensor(0xa4, (temp_ae_reg | 0x01));
  516 + }
  517 + else
  518 + {
  519 + CamWriteCmosSensor(0xa4, (temp_ae_reg & (~0x01))); /* Turn OFF AEC/AGC*/
  520 + }
  521 + }
  522 +}
  523 +
  524 +/*************************************************************************
  525 +* FUNCTION
  526 +* GC6133_SERIALAwbEnable
  527 +*
  528 +* DESCRIPTION
  529 +* disable/enable awb
  530 +*
  531 +* PARAMETERS
  532 +* Enable
  533 +*
  534 +* RETURNS
  535 +* None
  536 +*
  537 +* LOCAL AFFECTED
  538 +*
  539 +*************************************************************************/
  540 +static void GC6133_SERIALAwbEnable(kal_bool Enable)
  541 +{
  542 + kal_uint16 temp_awb_reg;
  543 + if (GC6133_SERIALSensor.BypassAwb)
  544 + {
  545 + Enable = KAL_FALSE;
  546 + }
  547 +
  548 + // TODO: enable or disable AWB here
  549 + {
  550 + CamWriteCmosSensor(0xfe, 0x00);
  551 + temp_awb_reg = CamReadCmosSensor(0x22);
  552 + if (Enable)
  553 + {
  554 + CamWriteCmosSensor(0x22, (temp_awb_reg | 0x60));
  555 + }
  556 + else
  557 + {
  558 + CamWriteCmosSensor(0x22, (temp_awb_reg & (~0x60))); /* Turn OFF AWB*/
  559 + }
  560 + }
  561 +}
  562 +
  563 +/*************************************************************************
  564 +* FUNCTION
  565 +* GC6133_SERIALSetBandingStep
  566 +*
  567 +* DESCRIPTION
  568 +* This function set base shutter or banding step to the CMOS sensor
  569 +*
  570 +* PARAMETERS
  571 +* None
  572 +*
  573 +* RETURNS
  574 +* None
  575 +*
  576 +* LOCAL AFFECTED
  577 +*
  578 +*************************************************************************/
  579 +static void GC6133_SERIALSetBandingStep(void)
  580 +{
  581 + // TODO: set banding step here
  582 +
  583 +}
  584 +
  585 +/*************************************************************************
  586 +* FUNCTION
  587 +* GC6133_SERIALSetDummy
  588 +*
  589 +* DESCRIPTION
  590 +* This function set the dummy pixels(Horizontal Blanking) & dummy lines(Vertical Blanking), it can be
  591 +* used to adjust the frame rate or gain more time for back-end process.
  592 +*
  593 +* PARAMETERS
  594 +* DummyPixel
  595 +* DummyLine
  596 +*
  597 +* RETURNS
  598 +* None
  599 +*
  600 +* LOCAL AFFECTED
  601 +*
  602 +*************************************************************************/
  603 +static void GC6133_SERIALSetDummy(kal_uint32 DummyPixel, kal_uint32 DummyLine)
  604 +{
  605 + kal_uint32 LineLength, FrameLength;
  606 +
  607 + if (GC6133_SERIALSensor.PvMode) /* preview size output mode */
  608 + {
  609 + LineLength = DummyPixel + GC6133_SERIAL_PV_PERIOD_PIXEL_NUMS;
  610 + FrameLength = DummyLine + GC6133_SERIAL_PV_PERIOD_LINE_NUMS;
  611 + }
  612 + else
  613 + {
  614 + LineLength = DummyPixel + GC6133_SERIAL_FULL_PERIOD_PIXEL_NUMS;
  615 + FrameLength = DummyLine + GC6133_SERIAL_FULL_PERIOD_LINE_NUMS;
  616 + }
  617 +
  618 + // TODO: set linelength/framelength or dummy pixel/line and return right value here
  619 + {
  620 +
  621 + }
  622 +
  623 + /* config banding step or base shutter */
  624 + if (GC6133_SERIALSensor.PvMode) /* preview size output mode */
  625 + {
  626 + GC6133_SERIALSetBandingStep();
  627 + }
  628 +}
  629 +
  630 +/*************************************************************************
  631 +* FUNCTION
  632 +* GC6133_SERIALSetMinFps
  633 +*
  634 +* DESCRIPTION
  635 +* This function calculate & set min frame rate
  636 +*
  637 +* PARAMETERS
  638 +* Fps: min frame rate, base on GC6133_SERIAL_FPS(x)
  639 +*
  640 +* RETURNS
  641 +* None
  642 +*
  643 +* LOCAL AFFECTED
  644 +*
  645 +*************************************************************************/
  646 +static void GC6133_SERIALSetMinFps(kal_uint16 Fps)
  647 +{
  648 + // TODO: set max exposure time or max AE index here
  649 +
  650 +}
  651 +
  652 +/*************************************************************************
  653 +* FUNCTION
  654 +* GC6133_SERIALSetMaxFps
  655 +*
  656 +* DESCRIPTION
  657 +* This function calculate & set max frame rate
  658 +*
  659 +* PARAMETERS
  660 +* Fps: max frame rate, base on GC6133_SERIAL_FPS(x)
  661 +*
  662 +* RETURNS
  663 +* None
  664 +*
  665 +* LOCAL AFFECTED
  666 +*
  667 +*************************************************************************/
  668 +static void GC6133_SERIALSetMaxFps(kal_uint16 Fps)
  669 +{
  670 + kal_uint32 LineLength, FrameLength;
  671 +
  672 + /* get max line length */
  673 + LineLength = GC6133_SERIALSensor.InternalClock * GC6133_SERIAL_FPS(1) / (Fps * GC6133_SERIAL_PV_PERIOD_LINE_NUMS);
  674 + if (LineLength > GC6133_SERIAL_MAX_PV_LINELENGTH) /* overflow check */
  675 + {
  676 + LineLength = GC6133_SERIAL_MAX_PV_LINELENGTH;
  677 + }
  678 + if (LineLength < GC6133_SERIAL_PV_PERIOD_PIXEL_NUMS)
  679 + {
  680 + LineLength = GC6133_SERIAL_PV_PERIOD_PIXEL_NUMS;
  681 + }
  682 +
  683 + /* get frame height */
  684 + FrameLength = GC6133_SERIALSensor.InternalClock * GC6133_SERIAL_FPS(1) / (Fps * LineLength);
  685 + if (FrameLength > GC6133_SERIAL_MAX_PV_FRAMELENGTH) /* overflow check */
  686 + {
  687 + FrameLength = GC6133_SERIAL_MAX_PV_FRAMELENGTH;
  688 + }
  689 + if (FrameLength < GC6133_SERIAL_PV_PERIOD_LINE_NUMS)
  690 + {
  691 + FrameLength = GC6133_SERIAL_PV_PERIOD_LINE_NUMS;
  692 + }
  693 +
  694 + /* limit max frame rate to Fps specified */
  695 + GC6133_SERIALSetDummy(LineLength - GC6133_SERIAL_PV_PERIOD_PIXEL_NUMS, FrameLength - GC6133_SERIAL_PV_PERIOD_LINE_NUMS);
  696 +}
  697 +
  698 +/*************************************************************************
  699 +* FUNCTION
  700 +* GC6133_SERIALSetVideoFps
  701 +*
  702 +* DESCRIPTION
  703 +* This function calculate & fix frame rate in video mode
  704 +*
  705 +* PARAMETERS
  706 +* Fps: target frame rate to fixed, base on GC6133_SERIAL_FPS(x)
  707 +*
  708 +* RETURNS
  709 +* None
  710 +*
  711 +* LOCAL AFFECTED
  712 +*
  713 +*************************************************************************/
  714 +static void GC6133_SERIALSetVideoFps(kal_uint16 Fps)
  715 +{
  716 + /* limit max frame rate */
  717 + GC6133_SERIALSetMaxFps(Fps);
  718 +
  719 + // TODO: fix, set max exposure time or max AE index here
  720 + {
  721 +
  722 + }
  723 +}
  724 +
  725 +/*************************************************************************
  726 +* FUNCTION
  727 +* GC6133_SERIALNightMode
  728 +*
  729 +* DESCRIPTION
  730 +* This function set night mode to sensor.
  731 +*
  732 +* PARAMETERS
  733 +* Enable
  734 +*
  735 +* RETURNS
  736 +* None
  737 +*
  738 +* LOCAL AFFECTED
  739 +*
  740 +*************************************************************************/
  741 +static void GC6133_SERIALNightMode(kal_bool Enable)
  742 +{
  743 + // TODO: set night mode here
  744 +
  745 +}
  746 +
  747 +/*************************************************************************
  748 +* FUNCTION
  749 +* GC6133_SERIALEv
  750 +*
  751 +* DESCRIPTION
  752 +* Exposure setting.
  753 +*
  754 +* PARAMETERS
  755 +* In, Out
  756 +*
  757 +* RETURNS
  758 +* Error code
  759 +*
  760 +* LOCAL AFFECTED
  761 +*
  762 +*************************************************************************/
  763 +static MM_ERROR_CODE_ENUM GC6133_SERIALEv(P_CAL_FEATURE_CTRL_STRUCT In, P_CAL_FEATURE_CTRL_STRUCT Out)
  764 +{
  765 + if (CAL_FEATURE_QUERY_OPERATION == In->FeatureCtrlCode)
  766 + {
  767 + const P_CAL_FEATURE_TYPE_ENUM_STRUCT Exposure = &Out->FeatureInfo.FeatureEnum;
  768 +
  769 + Out->FeatureType = CAL_FEATURE_TYPE_ENUMERATE;
  770 + Out->FeatureOperationSupport = CAL_FEATURE_SET_OPERATION|CAL_FEATURE_QUERY_OPERATION;
  771 + Out->FeatureModeSupport = CAL_FEATURE_CAMERA_VIDEO_SUPPORT;
  772 + // TODO: add supported EV enum here
  773 + Exposure->IsSupport = KAL_TRUE;
  774 + Exposure->ItemCount = 9;
  775 + Exposure->SupportItem[0] = CAM_EV_NEG_4_3;
  776 + Exposure->SupportItem[1] = CAM_EV_NEG_3_3;
  777 + Exposure->SupportItem[2] = CAM_EV_NEG_2_3;
  778 + Exposure->SupportItem[3] = CAM_EV_NEG_1_3;
  779 + Exposure->SupportItem[4] = CAM_EV_ZERO;
  780 + Exposure->SupportItem[5] = CAM_EV_POS_1_3;
  781 + Exposure->SupportItem[6] = CAM_EV_POS_2_3;
  782 + Exposure->SupportItem[7] = CAM_EV_POS_3_3;
  783 + Exposure->SupportItem[8] = CAM_EV_POS_4_3;
  784 + }
  785 + else if (CAL_FEATURE_SET_OPERATION == In->FeatureCtrlCode)
  786 + {
  787 + // TODO: adjust brightness here
  788 +
  789 +#if defined(GC6133_SERIAL_LOAD_FROM_T_FLASH)
  790 + return MM_ERROR_NONE;
  791 +#endif
  792 + CamWriteCmosSensor(0xfe, 0x00);
  793 + switch (In->FeatureSetValue)
  794 + {
  795 + case CAM_EV_NEG_4_3: /* EV -2 */
  796 + CamWriteCmosSensor(0x92, 0x28);
  797 + CamWriteCmosSensor(0x85, 0xc0);
  798 + break;
  799 + case CAM_EV_NEG_3_3: /* EV -1.5 */
  800 + CamWriteCmosSensor(0x92, 0x30);
  801 + CamWriteCmosSensor(0x85, 0xd0);
  802 + break;
  803 + case CAM_EV_NEG_2_3: /* EV -1 */
  804 + CamWriteCmosSensor(0x92, 0x38);
  805 + CamWriteCmosSensor(0x85, 0xe0);
  806 + break;
  807 + case CAM_EV_NEG_1_3: /* EV -0.5 */
  808 + CamWriteCmosSensor(0x92, 0x40);
  809 + CamWriteCmosSensor(0x85, 0xf0);
  810 + break;
  811 + case CAM_EV_ZERO:
  812 + CamWriteCmosSensor(0x92, 0x48);//50
  813 + CamWriteCmosSensor(0x85, 0x06);
  814 + break;
  815 + case CAM_EV_POS_1_3: /* EV +0.5 */
  816 + CamWriteCmosSensor(0x92, 0x50);
  817 + CamWriteCmosSensor(0x85, 0x10);
  818 + break;
  819 + case CAM_EV_POS_2_3: /* EV +1 */
  820 + CamWriteCmosSensor(0x92, 0x58);
  821 + CamWriteCmosSensor(0x85, 0x20);
  822 + break;
  823 + case CAM_EV_POS_3_3: /* EV +1.5 */
  824 + CamWriteCmosSensor(0x92, 0x60);
  825 + CamWriteCmosSensor(0x85, 0x30);
  826 + break;
  827 + case CAM_EV_POS_4_3: /* EV +2 */
  828 + CamWriteCmosSensor(0x92, 0x68);
  829 + CamWriteCmosSensor(0x85, 0x40);
  830 + break;
  831 + default:
  832 + return MM_ERROR_SENSOR_FEATURE_NOT_SUPPORT;
  833 + }
  834 + }
  835 + return MM_ERROR_NONE;
  836 +}
  837 +
  838 +/*************************************************************************
  839 +* FUNCTION
  840 +* GC6133_SERIALContrast
  841 +*
  842 +* DESCRIPTION
  843 +* Contrast setting.
  844 +*
  845 +* PARAMETERS
  846 +* In, Out
  847 +*
  848 +* RETURNS
  849 +* Error code
  850 +*
  851 +* LOCAL AFFECTED
  852 +*
  853 +*************************************************************************/
  854 +static MM_ERROR_CODE_ENUM GC6133_SERIALContrast(P_CAL_FEATURE_CTRL_STRUCT In, P_CAL_FEATURE_CTRL_STRUCT Out)
  855 +{
  856 + if (CAL_FEATURE_QUERY_OPERATION == In->FeatureCtrlCode)
  857 + {
  858 + const P_CAL_FEATURE_TYPE_ENUM_STRUCT Contrast = &Out->FeatureInfo.FeatureEnum;
  859 +
  860 + Out->FeatureType = CAL_FEATURE_TYPE_ENUMERATE;
  861 + Out->FeatureOperationSupport = CAL_FEATURE_SET_OPERATION|CAL_FEATURE_QUERY_OPERATION;
  862 + Out->FeatureModeSupport = CAL_FEATURE_CAMERA_VIDEO_SUPPORT;
  863 + // TODO: add supported contrast enum here
  864 + Contrast->IsSupport = KAL_TRUE;
  865 + Contrast->ItemCount = 3;
  866 + Contrast->SupportItem[0] = CAM_CONTRAST_HIGH;
  867 + Contrast->SupportItem[1] = CAM_CONTRAST_MEDIUM;
  868 + Contrast->SupportItem[2] = CAM_CONTRAST_LOW;
  869 + }
  870 + else if (CAL_FEATURE_SET_OPERATION == In->FeatureCtrlCode)
  871 + {
  872 + #if defined(GC6133_SERIAL_LOAD_FROM_T_FLASH)
  873 + return MM_ERROR_NONE;
  874 + #endif
  875 + // TODO: adjust contrast here
  876 + CamWriteCmosSensor(0xfe, 0x00);
  877 + switch (In->FeatureSetValue)
  878 + {
  879 + case CAM_CONTRAST_HIGH:
  880 + CamWriteCmosSensor(0x83, 0x56);
  881 + break;
  882 + case CAM_CONTRAST_MEDIUM:
  883 + CamWriteCmosSensor(0x83, 0x4a);
  884 + break;
  885 + case CAM_CONTRAST_LOW:
  886 + CamWriteCmosSensor(0x83, 0x38);
  887 + break;
  888 + default:
  889 + return MM_ERROR_SENSOR_FEATURE_NOT_SUPPORT;
  890 + }
  891 + }
  892 + return MM_ERROR_NONE;
  893 +}
  894 +
  895 +/*************************************************************************
  896 +* FUNCTION
  897 +* GC6133_SERIALSaturation
  898 +*
  899 +* DESCRIPTION
  900 +* Saturation setting.
  901 +*
  902 +* PARAMETERS
  903 +* In, Out
  904 +*
  905 +* RETURNS
  906 +* Error code
  907 +*
  908 +* LOCAL AFFECTED
  909 +*
  910 +*************************************************************************/
  911 +static MM_ERROR_CODE_ENUM GC6133_SERIALSaturation(P_CAL_FEATURE_CTRL_STRUCT In, P_CAL_FEATURE_CTRL_STRUCT Out)
  912 +{
  913 + if (CAL_FEATURE_QUERY_OPERATION == In->FeatureCtrlCode)
  914 + {
  915 + const P_CAL_FEATURE_TYPE_ENUM_STRUCT Saturation = &Out->FeatureInfo.FeatureEnum;
  916 +
  917 + Out->FeatureType = CAL_FEATURE_TYPE_ENUMERATE;
  918 + Out->FeatureOperationSupport = CAL_FEATURE_SET_OPERATION|CAL_FEATURE_QUERY_OPERATION;
  919 + Out->FeatureModeSupport = CAL_FEATURE_CAMERA_VIDEO_SUPPORT;
  920 + // TODO: add supported saturation enum here
  921 + Saturation->IsSupport = KAL_FALSE;
  922 + //Saturation->ItemCount = 3;
  923 + //Saturation->SupportItem[0] = CAM_SATURATION_HIGH;
  924 + //Saturation->SupportItem[1] = CAM_SATURATION_MEDIUM;
  925 + //Saturation->SupportItem[2] = CAM_SATURATION_LOW;
  926 + }
  927 + else if (CAL_FEATURE_SET_OPERATION == In->FeatureCtrlCode)
  928 + {
  929 + // TODO: adjust saturation here
  930 + //switch (In->FeatureSetValue)
  931 + //{
  932 + //case CAM_SATURATION_HIGH:
  933 + /* add setting here */
  934 + // break;
  935 + //case CAM_SATURATION_MEDIUM:
  936 + /* add setting here */
  937 + // break;
  938 + //case CAM_SATURATION_LOW:
  939 + /* add setting here */
  940 + // break;
  941 + //default:
  942 + // return MM_ERROR_SENSOR_FEATURE_NOT_SUPPORT;
  943 + //}
  944 + }
  945 + return MM_ERROR_NONE;
  946 +}
  947 +
  948 +/*************************************************************************
  949 +* FUNCTION
  950 +* GC6133_SERIALSharpness
  951 +*
  952 +* DESCRIPTION
  953 +* Sharpness setting.
  954 +*
  955 +* PARAMETERS
  956 +* In, Out
  957 +*
  958 +* RETURNS
  959 +* Error code
  960 +*
  961 +* LOCAL AFFECTED
  962 +*
  963 +*************************************************************************/
  964 +static MM_ERROR_CODE_ENUM GC6133_SERIALSharpness(P_CAL_FEATURE_CTRL_STRUCT In, P_CAL_FEATURE_CTRL_STRUCT Out)
  965 +{
  966 + if (CAL_FEATURE_QUERY_OPERATION == In->FeatureCtrlCode)
  967 + {
  968 + const P_CAL_FEATURE_TYPE_ENUM_STRUCT Sharpness = &Out->FeatureInfo.FeatureEnum;
  969 +
  970 + Out->FeatureType = CAL_FEATURE_TYPE_ENUMERATE;
  971 + Out->FeatureOperationSupport = CAL_FEATURE_SET_OPERATION|CAL_FEATURE_QUERY_OPERATION;
  972 + Out->FeatureModeSupport = CAL_FEATURE_CAMERA_VIDEO_SUPPORT;
  973 + // TODO: add supported sharpness enum here
  974 + Sharpness->IsSupport = KAL_FALSE;
  975 + //Sharpness->ItemCount = 3;
  976 + //Sharpness->SupportItem[0] = CAM_SHARPNESS_HIGH;
  977 + //Sharpness->SupportItem[1] = CAM_SHARPNESS_MEDIUM;
  978 + //Sharpness->SupportItem[2] = CAM_SHARPNESS_LOW;
  979 + }
  980 + else if (CAL_FEATURE_SET_OPERATION == In->FeatureCtrlCode)
  981 + {
  982 + // TODO: adjust sharpness here
  983 + //switch (In->FeatureSetValue)
  984 + //{
  985 + //case CAM_SHARPNESS_HIGH:
  986 + /* add setting here */
  987 + // break;
  988 + //case CAM_SHARPNESS_MEDIUM:
  989 + /* add setting here */
  990 + // break;
  991 + //case CAM_SHARPNESS_LOW:
  992 + /* add setting here */
  993 + // break;
  994 + //default:
  995 + // return MM_ERROR_SENSOR_FEATURE_NOT_SUPPORT;
  996 + //}
  997 + }
  998 + return MM_ERROR_NONE;
  999 +}
  1000 +
  1001 +/*************************************************************************
  1002 +* FUNCTION
  1003 +* GC6133_SERIALWb
  1004 +*
  1005 +* DESCRIPTION
  1006 +* Wb setting.
  1007 +*
  1008 +* PARAMETERS
  1009 +* In, Out
  1010 +*
  1011 +* RETURNS
  1012 +* Error code
  1013 +*
  1014 +* LOCAL AFFECTED
  1015 +*
  1016 +*************************************************************************/
  1017 +static MM_ERROR_CODE_ENUM GC6133_SERIALWb(P_CAL_FEATURE_CTRL_STRUCT In, P_CAL_FEATURE_CTRL_STRUCT Out)
  1018 +{
  1019 + if (CAL_FEATURE_QUERY_OPERATION == In->FeatureCtrlCode)
  1020 + {
  1021 + const P_CAL_FEATURE_TYPE_ENUM_STRUCT Wb = &Out->FeatureInfo.FeatureEnum;
  1022 +
  1023 + Out->FeatureType = CAL_FEATURE_TYPE_ENUMERATE;
  1024 + Out->FeatureOperationSupport = CAL_FEATURE_SET_OPERATION|CAL_FEATURE_QUERY_OPERATION;
  1025 + Out->FeatureModeSupport = CAL_FEATURE_CAMERA_VIDEO_SUPPORT;
  1026 + // TODO: add supported manual WB enum here
  1027 + Wb->IsSupport = KAL_TRUE;
  1028 + Wb->ItemCount = 6;
  1029 + Wb->SupportItem[0] = CAM_WB_AUTO;
  1030 + Wb->SupportItem[1] = CAM_WB_CLOUD;
  1031 + Wb->SupportItem[2] = CAM_WB_DAYLIGHT;
  1032 + Wb->SupportItem[3] = CAM_WB_INCANDESCENCE;
  1033 + Wb->SupportItem[4] = CAM_WB_FLUORESCENT;
  1034 + Wb->SupportItem[5] = CAM_WB_TUNGSTEN;
  1035 + }
  1036 + else if (CAL_FEATURE_SET_OPERATION == In->FeatureCtrlCode)
  1037 + {
  1038 +#ifdef GC6133_SERIAL_LOAD_FROM_T_FLASH
  1039 + return MM_ERROR_NONE;
  1040 +#endif
  1041 + // TODO: adjust manual WB here
  1042 + switch (In->FeatureSetValue)
  1043 + {
  1044 + case CAM_WB_AUTO:
  1045 + GC6133_SERIALAwbEnable(KAL_TRUE);
  1046 + break;
  1047 + case CAM_WB_CLOUD:
  1048 + GC6133_SERIALAwbEnable(KAL_FALSE);
  1049 + CamWriteCmosSensor(0x49,0x8c);
  1050 + CamWriteCmosSensor(0x4a,0x50);
  1051 + CamWriteCmosSensor(0x4b,0x40);
  1052 + break;
  1053 + case CAM_WB_DAYLIGHT:
  1054 + GC6133_SERIALAwbEnable(KAL_FALSE);
  1055 + CamWriteCmosSensor(0x49,0x74);
  1056 + CamWriteCmosSensor(0x4a,0x52);
  1057 + CamWriteCmosSensor(0x4b,0x40);
  1058 + break;
  1059 + case CAM_WB_INCANDESCENCE:
  1060 + GC6133_SERIALAwbEnable(KAL_FALSE);
  1061 + CamWriteCmosSensor(0x49,0x48);
  1062 + CamWriteCmosSensor(0x4a,0x40);
  1063 + CamWriteCmosSensor(0x4b,0x5c);
  1064 + break;
  1065 + case CAM_WB_FLUORESCENT:
  1066 + GC6133_SERIALAwbEnable(KAL_FALSE);
  1067 + CamWriteCmosSensor(0x49,0x40);
  1068 + CamWriteCmosSensor(0x4a,0x42);
  1069 + CamWriteCmosSensor(0x4b,0x50);
  1070 + break;
  1071 + case CAM_WB_TUNGSTEN:
  1072 + GC6133_SERIALAwbEnable(KAL_FALSE);
  1073 + CamWriteCmosSensor(0x49,0x40);
  1074 + CamWriteCmosSensor(0x4a,0x54);
  1075 + CamWriteCmosSensor(0x4b,0x70);
  1076 + break;
  1077 + default:
  1078 + return MM_ERROR_SENSOR_FEATURE_NOT_SUPPORT;
  1079 + }
  1080 + }
  1081 + return MM_ERROR_NONE;
  1082 +}
  1083 +
  1084 +/*************************************************************************
  1085 +* FUNCTION
  1086 +* GC6133_SERIALEffect
  1087 +*
  1088 +* DESCRIPTION
  1089 +* Effect setting.
  1090 +*
  1091 +* PARAMETERS
  1092 +* In, Out
  1093 +*
  1094 +* RETURNS
  1095 +* Error code
  1096 +*
  1097 +* LOCAL AFFECTED
  1098 +*
  1099 +*************************************************************************/
  1100 +static MM_ERROR_CODE_ENUM GC6133_SERIALEffect(P_CAL_FEATURE_CTRL_STRUCT In, P_CAL_FEATURE_CTRL_STRUCT Out)
  1101 +{
  1102 + if (CAL_FEATURE_QUERY_OPERATION == In->FeatureCtrlCode)
  1103 + {
  1104 + const P_CAL_FEATURE_TYPE_ENUM_STRUCT Effect = &Out->FeatureInfo.FeatureEnum;
  1105 +
  1106 + Out->FeatureType = CAL_FEATURE_TYPE_ENUMERATE;
  1107 + Out->FeatureOperationSupport = CAL_FEATURE_SET_OPERATION|CAL_FEATURE_QUERY_OPERATION;
  1108 + Out->FeatureModeSupport = CAL_FEATURE_CAMERA_VIDEO_SUPPORT;
  1109 + // TODO: add supported effect enum here
  1110 + Effect->IsSupport = KAL_TRUE;
  1111 + Effect->ItemCount = 6;
  1112 + Effect->SupportItem[0] = CAM_EFFECT_ENC_NORMAL;
  1113 + Effect->SupportItem[1] = CAM_EFFECT_ENC_GRAYSCALE;
  1114 + Effect->SupportItem[2] = CAM_EFFECT_ENC_SEPIA;
  1115 + Effect->SupportItem[3] = CAM_EFFECT_ENC_SEPIAGREEN;
  1116 + Effect->SupportItem[4] = CAM_EFFECT_ENC_SEPIABLUE;
  1117 + Effect->SupportItem[5] = CAM_EFFECT_ENC_COLORINV;
  1118 + }
  1119 + else if (CAL_FEATURE_SET_OPERATION == In->FeatureCtrlCode)
  1120 + {
  1121 +#ifdef GC6133_SERIAL_LOAD_FROM_T_FLASH
  1122 + return MM_ERROR_NONE;
  1123 +#endif
  1124 + // TODO: adjust effect here
  1125 + switch (In->FeatureSetValue)
  1126 + {
  1127 + case CAM_EFFECT_ENC_NORMAL:
  1128 + CamWriteCmosSensor(0x23, 0x00);
  1129 + CamWriteCmosSensor(0x8a, 0x00);
  1130 + CamWriteCmosSensor(0x8b, 0x00);
  1131 + break;
  1132 + case CAM_EFFECT_ENC_GRAYSCALE:
  1133 + CamWriteCmosSensor(0x23, 0x02);
  1134 + CamWriteCmosSensor(0x8a, 0x00);
  1135 + CamWriteCmosSensor(0x8b, 0x00);
  1136 + break;
  1137 + case CAM_EFFECT_ENC_SEPIA:
  1138 + CamWriteCmosSensor(0x23, 0x02);
  1139 + CamWriteCmosSensor(0x8a, 0xd0);
  1140 + CamWriteCmosSensor(0x8b, 0x28);
  1141 + break;
  1142 + case CAM_EFFECT_ENC_SEPIAGREEN:
  1143 + CamWriteCmosSensor(0x23, 0x02);
  1144 + CamWriteCmosSensor(0x8a, 0xc0);
  1145 + CamWriteCmosSensor(0x8b, 0xc0);
  1146 + break;
  1147 + case CAM_EFFECT_ENC_SEPIABLUE:
  1148 + CamWriteCmosSensor(0x23, 0x02);
  1149 + CamWriteCmosSensor(0x8a, 0x50);
  1150 + CamWriteCmosSensor(0x8b, 0xe0);
  1151 + break;
  1152 + case CAM_EFFECT_ENC_COLORINV:
  1153 + CamWriteCmosSensor(0x23, 0x01);
  1154 + CamWriteCmosSensor(0x8a, 0x00);
  1155 + CamWriteCmosSensor(0x8b, 0x00);
  1156 + break;
  1157 + default:
  1158 + return MM_ERROR_SENSOR_FEATURE_NOT_SUPPORT;
  1159 + }
  1160 + }
  1161 + return MM_ERROR_NONE;
  1162 +}
  1163 +
  1164 +/*************************************************************************
  1165 +* FUNCTION
  1166 +* GC6133_SERIALStillCaptureSize
  1167 +*
  1168 +* DESCRIPTION
  1169 +* This function get capture size
  1170 +*
  1171 +* PARAMETERS
  1172 +* In, Out
  1173 +*
  1174 +* RETURNS
  1175 +* Error code
  1176 +*
  1177 +* LOCAL AFFECTED
  1178 +*
  1179 +*************************************************************************/
  1180 +MM_ERROR_CODE_ENUM GC6133_SERIALStillCaptureSize(P_CAL_FEATURE_CTRL_STRUCT In, P_CAL_FEATURE_CTRL_STRUCT Out)
  1181 +{
  1182 + const P_CAL_FEATURE_TYPE_ENUM_STRUCT CapSize = &Out->FeatureInfo.FeatureEnum;
  1183 +
  1184 + if (CAL_FEATURE_QUERY_OPERATION == In->FeatureCtrlCode)
  1185 + {
  1186 + Out->FeatureType = CAL_FEATURE_TYPE_ENUMERATE;
  1187 + Out->FeatureOperationSupport = CAL_FEATURE_QUERY_OPERATION;
  1188 + Out->FeatureModeSupport = CAL_FEATURE_CAMERA_SUPPORT;
  1189 + CapSize->IsSupport = KAL_TRUE;
  1190 + // TODO: add supported capture size enum here
  1191 + CapSize->ItemCount = 3;
  1192 + CapSize->SupportItem[0] = CAM_IMAGE_SIZE_WALLPAPER;
  1193 + CapSize->SupportItem[1] = CAM_IMAGE_SIZE_QVGA;
  1194 + CapSize->SupportItem[2] = CAM_IMAGE_SIZE_VGA;
  1195 + }
  1196 + return MM_ERROR_NONE;
  1197 +}
  1198 +
  1199 +/*************************************************************************
  1200 +* FUNCTION
  1201 +* GC6133_SERIALBanding
  1202 +*
  1203 +* DESCRIPTION
  1204 +* This function get banding setting
  1205 +*
  1206 +* PARAMETERS
  1207 +* In, Out
  1208 +*
  1209 +* RETURNS
  1210 +* Error code
  1211 +*
  1212 +* LOCAL AFFECTED
  1213 +*
  1214 +*************************************************************************/
  1215 +static MM_ERROR_CODE_ENUM GC6133_SERIALBanding(P_CAL_FEATURE_CTRL_STRUCT In, P_CAL_FEATURE_CTRL_STRUCT Out)
  1216 +{
  1217 + const P_CAL_FEATURE_TYPE_ENUM_STRUCT Banding = &Out->FeatureInfo.FeatureEnum;
  1218 +
  1219 + if (CAL_FEATURE_QUERY_OPERATION == In->FeatureCtrlCode)
  1220 + {
  1221 + Out->FeatureType = CAL_FEATURE_TYPE_ENUMERATE;
  1222 + Out->FeatureOperationSupport = CAL_FEATURE_SET_OPERATION|CAL_FEATURE_QUERY_OPERATION;
  1223 + Out->FeatureModeSupport = CAL_FEATURE_CAMERA_VIDEO_SUPPORT;
  1224 + Banding->IsSupport = KAL_TRUE;
  1225 + Banding->ItemCount = 2;
  1226 + Banding->SupportItem[0] = CAM_BANDING_50HZ;
  1227 + Banding->SupportItem[1] = CAM_BANDING_60HZ;
  1228 + }
  1229 + else if (CAL_FEATURE_SET_OPERATION == In->FeatureCtrlCode)
  1230 + {
  1231 + GC6133_SERIALSensor.BandingFreq = (CAM_BANDING_50HZ == In->FeatureSetValue ? GC6133_SERIAL_50HZ : GC6133_SERIAL_60HZ);
  1232 + #if defined(GC6133_SERIAL_LOAD_FROM_T_FLASH)
  1233 + return MM_ERROR_NONE;
  1234 + #endif
  1235 +
  1236 +
  1237 + // TODO: set manual banding here
  1238 + GC6133_SERIAL_SET_PAGE0;
  1239 + if (CAM_BANDING_50HZ == In->FeatureSetValue)
  1240 + {
  1241 + CamWriteCmosSensor(0xfe, 0x00);
  1242 + CamWriteCmosSensor(0x01, 0x41); //hb
  1243 + CamWriteCmosSensor(0x02, 0x12); //vb
  1244 + CamWriteCmosSensor(0x0f, 0x01);
  1245 + CamWriteCmosSensor(0x9d, 0x32); //step
  1246 + CamWriteCmosSensor(0x9e, 0x62); //[7:4]margin 10fps
  1247 + CamWriteCmosSensor(0x9f, 0x58); //1f4
  1248 + GC6133_SERIAL_CAM_BANDING_50HZ = KAL_TRUE;
  1249 + }
  1250 + else
  1251 + {
  1252 + CamWriteCmosSensor(0xfe, 0x00);
  1253 + CamWriteCmosSensor(0x01, 0x3c); //hb
  1254 + CamWriteCmosSensor(0x02, 0x04); //vb
  1255 + CamWriteCmosSensor(0x0f, 0x01);
  1256 + CamWriteCmosSensor(0x9d, 0x2a); //step
  1257 + CamWriteCmosSensor(0x9e, 0x61); //[7:4]margin 10fps
  1258 + CamWriteCmosSensor(0x9f, 0xce);
  1259 +
  1260 + GC6133_SERIAL_CAM_BANDING_50HZ = KAL_FALSE;
  1261 + }
  1262 +
  1263 +
  1264 + }
  1265 +
  1266 + return MM_ERROR_NONE;
  1267 +}
  1268 +
  1269 +
  1270 +/*************************************************************************
  1271 +* FUNCTION
  1272 +* GC6133_SERIALSceneMode
  1273 +*
  1274 +* DESCRIPTION
  1275 +* This function get/set scene mode of sensor.
  1276 +*
  1277 +* PARAMETERS
  1278 +* IsCam: camera scene mode or not
  1279 +* In, Out
  1280 +*
  1281 +* RETURNS
  1282 +* None
  1283 +*
  1284 +* LOCAL AFFECTED
  1285 +*
  1286 +*************************************************************************/
  1287 +static MM_ERROR_CODE_ENUM GC6133_SERIALSceneMode(kal_bool IsCam, P_CAL_FEATURE_CTRL_STRUCT In, P_CAL_FEATURE_CTRL_STRUCT Out)
  1288 +{
  1289 + if (CAL_FEATURE_QUERY_OPERATION == In->FeatureCtrlCode)
  1290 + {
  1291 + const P_CAL_FEATURE_TYPE_ENUM_STRUCT SceneMode = &Out->FeatureInfo.FeatureEnum;
  1292 +
  1293 + Out->FeatureType = CAL_FEATURE_TYPE_ENUMERATE;
  1294 + Out->FeatureOperationSupport = CAL_FEATURE_SET_OPERATION|CAL_FEATURE_QUERY_OPERATION;
  1295 + Out->FeatureModeSupport = CAL_FEATURE_CAMERA_SUPPORT;
  1296 + SceneMode->IsSupport = KAL_TRUE;
  1297 + SceneMode->ItemCount = 2;
  1298 + if (IsCam)
  1299 + {
  1300 + SceneMode->SupportItem[0] = CAM_AUTO_DSC;
  1301 + SceneMode->SupportItem[1] = CAM_NIGHTSCENE;
  1302 + }
  1303 + else
  1304 + {
  1305 + SceneMode->SupportItem[0] = CAM_VIDEO_AUTO;
  1306 + SceneMode->SupportItem[1] = CAM_VIDEO_NIGHT;
  1307 + }
  1308 + }
  1309 + return MM_ERROR_NONE;
  1310 +}
  1311 +
  1312 +
  1313 +
  1314 +/*************************************************************************
  1315 +* FUNCTION
  1316 +* GC6133_SERIALInitialSetting
  1317 +*
  1318 +* DESCRIPTION
  1319 +* This function initialize the registers of CMOS sensor
  1320 +* IMPORTANT NOTICE:
  1321 +* the output format should be YUV422, order: YUYV
  1322 +* data output should be at pclk falling edge
  1323 +* VSYNC should be low active
  1324 +* HSYNC should be hight active
  1325 +*
  1326 +* PARAMETERS
  1327 +* None
  1328 +*
  1329 +* RETURNS
  1330 +* None
  1331 +*
  1332 +* LOCAL AFFECTED
  1333 +*
  1334 +*************************************************************************/
  1335 +#if defined(__TOPWELL_T3189_C45__)
  1336 +static void GC6133_SERIALInitialSetting(void)
  1337 +{
  1338 + /////////////////////////////////////////////////////
  1339 + ////////////////////// SYS //////////////////////
  1340 + /////////////////////////////////////////////////////
  1341 + CamWriteCmosSensor(0xfe, 0xa0);
  1342 + CamWriteCmosSensor(0xfe, 0xa0);
  1343 + CamWriteCmosSensor(0xfe, 0xa0);
  1344 +
  1345 + CamWriteCmosSensor(0xf6, 0x00);
  1346 + CamWriteCmosSensor(0xfa, 0x11);
  1347 + CamWriteCmosSensor(0xfc, 0x12); //clock enable
  1348 +
  1349 + GC6133_SERIAL_SET_PAGE0; //Page select
  1350 + CamWriteCmosSensor(0x49, 0x70); //AWB r gain
  1351 + CamWriteCmosSensor(0x4a, 0x40); //AWB g gain
  1352 + CamWriteCmosSensor(0x4b, 0x5d); //AWB b gain
  1353 + /////////////////////////////////////////////////////
  1354 + //////////////// ANALOG & CISCTL ////////////////
  1355 + /////////////////////////////////////////////////////
  1356 + CamWriteCmosSensor(0x03, 0x00);
  1357 + CamWriteCmosSensor(0x04, 0xfa);
  1358 + CamWriteCmosSensor(0x01, 0x41); //hb
  1359 + CamWriteCmosSensor(0x02, 0x12); //vb
  1360 + CamWriteCmosSensor(0x0f, 0x01);
  1361 + CamWriteCmosSensor(0x0d, 0x30);
  1362 + CamWriteCmosSensor(0x12, 0xc8);
  1363 + CamWriteCmosSensor(0x14, 0x54); //dark CFA
  1364 + CamWriteCmosSensor(0x15, 0x32); //1:sdark 0:ndark
  1365 + CamWriteCmosSensor(0x16, 0x04);
  1366 + CamWriteCmosSensor(0x17, 0x19);
  1367 + CamWriteCmosSensor(0x1d, 0xb9);
  1368 + CamWriteCmosSensor(0x1f, 0x15); //PAD_drv
  1369 + CamWriteCmosSensor(0x7a, 0x00);
  1370 + CamWriteCmosSensor(0x7b, 0x14);
  1371 + CamWriteCmosSensor(0x7d, 0x36);
  1372 + CamWriteCmosSensor(0xfe, 0x10); //add by 20160217 CISCTL rst [4]
  1373 + /////////////////////////////////////////////////////
  1374 + ////////////////////// ISP //////////////////////
  1375 + /////////////////////////////////////////////////////
  1376 + CamWriteCmosSensor(0x20, 0x7e);
  1377 + CamWriteCmosSensor(0x22, 0xb8);
  1378 + CamWriteCmosSensor(0x24, 0x54); //output_format
  1379 + CamWriteCmosSensor(0x26, 0x87); //[5]Y_switch [4]UV_switch [2]skin_en
  1380 + //CamWriteCmosSensor(0x29, 0x10);// disable isp quiet mode
  1381 +
  1382 + CamWriteCmosSensor(0x39, 0x00); //crop window
  1383 + CamWriteCmosSensor(0x3a, 0x80);
  1384 + CamWriteCmosSensor(0x3b, 0x01); //width
  1385 + CamWriteCmosSensor(0x3c, 0x40);
  1386 + CamWriteCmosSensor(0x3e, 0xf0); //height
  1387 + /////////////////////////////////////////////////////
  1388 + ////////////////////// BLK //////////////////////
  1389 + /////////////////////////////////////////////////////
  1390 + CamWriteCmosSensor(0x2a, 0x2f);
  1391 + CamWriteCmosSensor(0x37, 0x46); //[4:0]blk_select_row
  1392 +
  1393 + /////////////////////////////////////////////////////
  1394 + ////////////////////// GAIN /////////////////////
  1395 + /////////////////////////////////////////////////////
  1396 + CamWriteCmosSensor(0x3f, 0x18); //global gain 20160901
  1397 +
  1398 +
  1399 + /////////////////////////////////////////////////////
  1400 + ////////////////////// DNDD /////////////////////
  1401 + /////////////////////////////////////////////////////
  1402 + CamWriteCmosSensor(0x50, 0x3c);
  1403 + CamWriteCmosSensor(0x52, 0x48);//4f
  1404 + CamWriteCmosSensor(0x53, 0x81);
  1405 + CamWriteCmosSensor(0x54, 0x43);
  1406 + CamWriteCmosSensor(0x56, 0x78);
  1407 + CamWriteCmosSensor(0x57, 0xaa);//20160901
  1408 + CamWriteCmosSensor(0x58, 0xff);//20160901
  1409 +
  1410 + /////////////////////////////////////////////////////
  1411 + ////////////////////// ASDE /////////////////////
  1412 + /////////////////////////////////////////////////////
  1413 + CamWriteCmosSensor(0x5b, 0x60); //dd&ee th
  1414 + CamWriteCmosSensor(0x5c, 0x80); //60/OT_th
  1415 + CamWriteCmosSensor(0xab, 0x28);
  1416 + CamWriteCmosSensor(0xac, 0xb5);
  1417 +
  1418 + /////////////////////////////////////////////////////
  1419 + ///////////////////// INTPEE ////////////////////
  1420 + /////////////////////////////////////////////////////
  1421 + CamWriteCmosSensor(0x60, 0x45);
  1422 + CamWriteCmosSensor(0x62, 0x68); //20160901
  1423 + CamWriteCmosSensor(0x63, 0x13); //edge effect
  1424 + CamWriteCmosSensor(0x64, 0x43);
  1425 +
  1426 + /////////////////////////////////////////////////////
  1427 + ////////////////////// CC ///////////////////////
  1428 + /////////////////////////////////////////////////////
  1429 + CamWriteCmosSensor(0x65, 0x13); //Y
  1430 + CamWriteCmosSensor(0x66, 0x26);
  1431 + CamWriteCmosSensor(0x67, 0x07);
  1432 + CamWriteCmosSensor(0x68, 0xf5); //Cb
  1433 + CamWriteCmosSensor(0x69, 0xea);
  1434 + CamWriteCmosSensor(0x6a, 0x21);
  1435 + CamWriteCmosSensor(0x6b, 0x21); //Cr
  1436 + CamWriteCmosSensor(0x6c, 0xe4);
  1437 + CamWriteCmosSensor(0x6d, 0xfb);
  1438 +
  1439 + /////////////////////////////////////////////////////
  1440 + ////////////////////// YCP //////////////////////
  1441 + /////////////////////////////////////////////////////
  1442 + CamWriteCmosSensor(0x81, 0x2e); //cb 30
  1443 + CamWriteCmosSensor(0x82, 0x2e); //cr 30
  1444 + CamWriteCmosSensor(0x83, 0x4a); //luma contrast 4a
  1445 + CamWriteCmosSensor(0x85, 0x06); //luma offset
  1446 + CamWriteCmosSensor(0x8d, 0x78); //edge dec sa
  1447 + CamWriteCmosSensor(0x8e, 0x25); //autogray
  1448 +
  1449 + /////////////////////////////////////////////////////
  1450 + ////////////////////// AEC //////////////////////
  1451 + /////////////////////////////////////////////////////
  1452 + CamWriteCmosSensor(0x90, 0x38);//20160901
  1453 + CamWriteCmosSensor(0x92, 0x48); //target 50
  1454 + CamWriteCmosSensor(0x9d, 0x32);//STEP
  1455 + CamWriteCmosSensor(0x9e, 0x62);//[7:4]margin 10fps 1f4
  1456 + CamWriteCmosSensor(0x9f, 0x58);
  1457 + CamWriteCmosSensor(0xa3, 0x28); //pregain
  1458 + CamWriteCmosSensor(0xa4, 0x01);
  1459 +
  1460 + /////////////////////////////////////////////////////
  1461 + ////////////////////// AWB //////////////////////
  1462 + /////////////////////////////////////////////////////
  1463 + CamWriteCmosSensor(0xb1, 0x1e); //Y_to_C_diff
  1464 + CamWriteCmosSensor(0xb3, 0x20); //C_max
  1465 + CamWriteCmosSensor(0xbd, 0x70); //R_limit
  1466 + CamWriteCmosSensor(0xbe, 0x58); //G_limit
  1467 + CamWriteCmosSensor(0xbf, 0xa0); //B_limit
  1468 +
  1469 + CamWriteCmosSensor(0xfe, 0x00); //20160901 update for AWB
  1470 + CamWriteCmosSensor(0x43, 0xa8);
  1471 + CamWriteCmosSensor(0xb0, 0xf2);
  1472 + CamWriteCmosSensor(0xb5, 0x40);
  1473 + CamWriteCmosSensor(0xb8, 0x05);
  1474 + CamWriteCmosSensor(0xba, 0x60);
  1475 +
  1476 + /////////////////////////////////////////////////////
  1477 + //////////////////// Banding ////////////////////
  1478 + /////////////////////////////////////////////////////
  1479 + //CamWriteCmosSensor(0x01, 0x41); //hb
  1480 + //CamWriteCmosSensor(0x02, 0x12); //vb
  1481 + //CamWriteCmosSensor(0x0f, 0x01);
  1482 + //CamWriteCmosSensor(0x9d, 0x32); //step
  1483 + //CamWriteCmosSensor(0x9e, 0x61); //[7:4]margin 10fps
  1484 + //CamWriteCmosSensor(0x9f, 0xf4);
  1485 + /////////////////////////////////////////////////////
  1486 + ////////////////////// SPI //////////////////////
  1487 + /////////////////////////////////////////////////////
  1488 + GC6133_SERIAL_SET_PAGE2;
  1489 + CamWriteCmosSensor(0x01, 0x01); //spi enable
  1490 + CamWriteCmosSensor(0x02, 0x02); //LSB & Falling edge sample; ddr disable
  1491 + CamWriteCmosSensor(0x03, 0x20); //1-wire
  1492 + CamWriteCmosSensor(0x04, 0x20); //[4] master_outformat
  1493 + CamWriteCmosSensor(0x0a, 0x00); //Data ID, 0x00-YUV422, 0x01-RGB565
  1494 + CamWriteCmosSensor(0x13, 0x10);
  1495 + CamWriteCmosSensor(0x24, 0x00); //[1]sck_always [0]BT656
  1496 + CamWriteCmosSensor(0x28, 0x03); //clock_div_spi
  1497 + GC6133_SERIAL_SET_PAGE0;
  1498 + ////////////////////////////////////////////////////
  1499 + ///////////////////////output//////////////////////
  1500 + ///////////////////////////////////////////////////
  1501 + CamWriteCmosSensor(0x22, 0xf8); //open awb
  1502 + CamWriteCmosSensor(0xf1, 0x03); //output enable
  1503 +}
  1504 +#else
  1505 +static void GC6133_SERIALInitialSetting(void)
  1506 +{
  1507 + /////////////////////////////////////////////////////
  1508 + ////////////////////// SYS //////////////////////
  1509 + /////////////////////////////////////////////////////
  1510 + CamWriteCmosSensor(0xfe, 0xa0);
  1511 + CamWriteCmosSensor(0xfe, 0xa0);
  1512 + CamWriteCmosSensor(0xfe, 0xa0);
  1513 +
  1514 + CamWriteCmosSensor(0xf6, 0x00);
  1515 + CamWriteCmosSensor(0xfa, 0x11);
  1516 + CamWriteCmosSensor(0xfc, 0x12); //clock enable
  1517 +
  1518 + GC6133_SERIAL_SET_PAGE0; //Page select
  1519 + CamWriteCmosSensor(0x49, 0x70); //AWB r gain
  1520 + CamWriteCmosSensor(0x4a, 0x40); //AWB g gain
  1521 + CamWriteCmosSensor(0x4b, 0x5d); //AWB b gain
  1522 + /////////////////////////////////////////////////////
  1523 + //////////////// ANALOG & CISCTL ////////////////
  1524 + /////////////////////////////////////////////////////
  1525 + CamWriteCmosSensor(0x03, 0x00);
  1526 + CamWriteCmosSensor(0x04, 0xfa);
  1527 + CamWriteCmosSensor(0x01, 0x41); //hb
  1528 + CamWriteCmosSensor(0x02, 0x12); //vb
  1529 + CamWriteCmosSensor(0x0f, 0x01);
  1530 + CamWriteCmosSensor(0x0d, 0x30);
  1531 + CamWriteCmosSensor(0x12, 0xc8);
  1532 + CamWriteCmosSensor(0x14, 0x54); //dark CFA
  1533 + CamWriteCmosSensor(0x15, 0x32); //1:sdark 0:ndark
  1534 + CamWriteCmosSensor(0x16, 0x04);
  1535 + CamWriteCmosSensor(0x17, 0x19);
  1536 + CamWriteCmosSensor(0x1d, 0xb9);
  1537 + CamWriteCmosSensor(0x1f, 0x15); //PAD_drv
  1538 + CamWriteCmosSensor(0x7a, 0x00);
  1539 + CamWriteCmosSensor(0x7b, 0x14);
  1540 + CamWriteCmosSensor(0x7d, 0x36);
  1541 + CamWriteCmosSensor(0xfe, 0x10); //add by 20160217 CISCTL rst [4]
  1542 + /////////////////////////////////////////////////////
  1543 + ////////////////////// ISP //////////////////////
  1544 + /////////////////////////////////////////////////////
  1545 + CamWriteCmosSensor(0x20, 0x7e);
  1546 + CamWriteCmosSensor(0x22, 0xb8);
  1547 + CamWriteCmosSensor(0x24, 0x54); //output_format
  1548 + CamWriteCmosSensor(0x26, 0x87); //[5]Y_switch [4]UV_switch [2]skin_en
  1549 + CamWriteCmosSensor(0x29, 0x10);// disable isp quiet mode
  1550 +
  1551 + CamWriteCmosSensor(0x39, 0x00); //crop window
  1552 + CamWriteCmosSensor(0x3a, 0x80);
  1553 + CamWriteCmosSensor(0x3b, 0x01); //width
  1554 + CamWriteCmosSensor(0x3c, 0x40);
  1555 + CamWriteCmosSensor(0x3e, 0xf0); //height
  1556 + /////////////////////////////////////////////////////
  1557 + ////////////////////// BLK //////////////////////
  1558 + /////////////////////////////////////////////////////
  1559 + CamWriteCmosSensor(0x2a, 0x2f);
  1560 + CamWriteCmosSensor(0x37, 0x46); //[4:0]blk_select_row
  1561 +
  1562 + /////////////////////////////////////////////////////
  1563 + ////////////////////// GAIN /////////////////////
  1564 + /////////////////////////////////////////////////////
  1565 + CamWriteCmosSensor(0x3f, 0x10); //global gain
  1566 +
  1567 +
  1568 + /////////////////////////////////////////////////////
  1569 + ////////////////////// DNDD /////////////////////
  1570 + /////////////////////////////////////////////////////
  1571 + CamWriteCmosSensor(0x52, 0x4f);
  1572 + CamWriteCmosSensor(0x53, 0x81);
  1573 + CamWriteCmosSensor(0x54, 0x43);
  1574 + CamWriteCmosSensor(0x56, 0x78);
  1575 +
  1576 + /////////////////////////////////////////////////////
  1577 + ////////////////////// ASDE /////////////////////
  1578 + /////////////////////////////////////////////////////
  1579 + CamWriteCmosSensor(0x5b, 0x60); //dd&ee th
  1580 + CamWriteCmosSensor(0x5c, 0x80); //60/OT_th
  1581 + CamWriteCmosSensor(0xab, 0x28);
  1582 + CamWriteCmosSensor(0xac, 0xb5);
  1583 +
  1584 + /////////////////////////////////////////////////////
  1585 + ///////////////////// INTPEE ////////////////////
  1586 + /////////////////////////////////////////////////////
  1587 + CamWriteCmosSensor(0x60, 0x45);
  1588 + CamWriteCmosSensor(0x63, 0x13); //edge effect 13
  1589 + CamWriteCmosSensor(0x64, 0x32); //43
  1590 +
  1591 + /////////////////////////////////////////////////////
  1592 + ////////////////////// CC ///////////////////////
  1593 + /////////////////////////////////////////////////////
  1594 + CamWriteCmosSensor(0x65, 0x13); //Y
  1595 + CamWriteCmosSensor(0x66, 0x26);
  1596 + CamWriteCmosSensor(0x67, 0x07);
  1597 + CamWriteCmosSensor(0x68, 0xf5); //Cb
  1598 + CamWriteCmosSensor(0x69, 0xea);
  1599 + CamWriteCmosSensor(0x6a, 0x21);
  1600 + CamWriteCmosSensor(0x6b, 0x21); //Cr
  1601 + CamWriteCmosSensor(0x6c, 0xe4);
  1602 + CamWriteCmosSensor(0x6d, 0xfb);
  1603 +
  1604 + /////////////////////////////////////////////////////
  1605 + ////////////////////// YCP //////////////////////
  1606 + /////////////////////////////////////////////////////
  1607 + CamWriteCmosSensor(0x81, 0x2a); //cb//30
  1608 + CamWriteCmosSensor(0x82, 0x2a); //cr//30
  1609 + CamWriteCmosSensor(0x83, 0x4f); //luma contrast//4a
  1610 + CamWriteCmosSensor(0x85, 0x06); //luma offset
  1611 + CamWriteCmosSensor(0x8d, 0x78); //edge dec sa
  1612 + CamWriteCmosSensor(0x8e, 0x25); //autogray
  1613 +
  1614 + /////////////////////////////////////////////////////
  1615 + ////////////////////// AEC //////////////////////
  1616 + /////////////////////////////////////////////////////
  1617 + CamWriteCmosSensor(0x90, 0x3a);
  1618 + CamWriteCmosSensor(0x92, 0x48); //target//50
  1619 + CamWriteCmosSensor(0x9d, 0x32);//STEP
  1620 + CamWriteCmosSensor(0x9e, 0x63);//[7:4]margin 10fps
  1621 + CamWriteCmosSensor(0x9f, 0x52);//1f4
  1622 + CamWriteCmosSensor(0xa3, 0x28); //pregain
  1623 + CamWriteCmosSensor(0xa4, 0x01);
  1624 +
  1625 + /////////////////////////////////////////////////////
  1626 + ////////////////////// AWB //////////////////////
  1627 + /////////////////////////////////////////////////////
  1628 + CamWriteCmosSensor(0xb1, 0x1e); //Y_to_C_diff
  1629 + CamWriteCmosSensor(0xb3, 0x20); //C_max
  1630 + CamWriteCmosSensor(0xbd, 0x70); //R_limit
  1631 + CamWriteCmosSensor(0xbe, 0x58); //G_limit
  1632 + CamWriteCmosSensor(0xbf, 0xa0); //B_limit
  1633 +
  1634 + CamWriteCmosSensor(0xfe, 0x00); //20160901 update for AWB
  1635 + CamWriteCmosSensor(0x43, 0xa8);
  1636 + CamWriteCmosSensor(0xb0, 0xf2);
  1637 + CamWriteCmosSensor(0xb5, 0x40);
  1638 + CamWriteCmosSensor(0xb8, 0x05);
  1639 + CamWriteCmosSensor(0xba, 0x60);
  1640 + CamWriteCmosSensor(0xfe, 0x00);
  1641 +
  1642 + /////////////////////////////////////////////////////
  1643 + //////////////////// Banding ////////////////////
  1644 + /////////////////////////////////////////////////////
  1645 + //CamWriteCmosSensor(0x01, 0x41); //hb
  1646 + //CamWriteCmosSensor(0x02, 0x12); //vb
  1647 + //CamWriteCmosSensor(0x0f, 0x01);
  1648 + //CamWriteCmosSensor(0x9d, 0x32); //step
  1649 + //CamWriteCmosSensor(0x9e, 0x61); //[7:4]margin 10fps
  1650 + //CamWriteCmosSensor(0x9f, 0xf4);
  1651 + /////////////////////////////////////////////////////
  1652 + ////////////////////// SPI //////////////////////
  1653 + /////////////////////////////////////////////////////
  1654 + GC6133_SERIAL_SET_PAGE2;
  1655 + CamWriteCmosSensor(0x01, 0x01); //spi enable
  1656 + CamWriteCmosSensor(0x02, 0x02); //LSB & Falling edge sample; ddr disable
  1657 + CamWriteCmosSensor(0x03, 0x20); //1-wire
  1658 + CamWriteCmosSensor(0x04, 0x20); //[4] master_outformat
  1659 + CamWriteCmosSensor(0x0a, 0x00); //Data ID, 0x00-YUV422, 0x01-RGB565
  1660 + CamWriteCmosSensor(0x13, 0x10);
  1661 + CamWriteCmosSensor(0x24, 0x00); //[1]sck_always [0]BT656
  1662 + CamWriteCmosSensor(0x28, 0x03); //clock_div_spi
  1663 + GC6133_SERIAL_SET_PAGE0;
  1664 + ////////////////////////////////////////////////////
  1665 + ///////////////////////output//////////////////////
  1666 + ///////////////////////////////////////////////////
  1667 + CamWriteCmosSensor(0x22, 0xf8); //open awb
  1668 + CamWriteCmosSensor(0xf1, 0x03); //output enable
  1669 +}
  1670 +#endif
  1671 +
  1672 +/*************************************************************************
  1673 +* FUNCTION
  1674 +* GC6133_SERIAL_Write_More_Registers
  1675 +*
  1676 +* DESCRIPTION
  1677 +* This function is served for FAE to modify the necessary Init Regs. Do not modify the regs
  1678 +* in init_GC6133_SERIAL() directly.
  1679 +*
  1680 +* PARAMETERS
  1681 +* None
  1682 +*
  1683 +* RETURNS
  1684 +* None
  1685 +*
  1686 +* GLOBALS AFFECTED
  1687 +*
  1688 +*************************************************************************/
  1689 +void GC6133_SERIALMoreSetting(void)
  1690 +{
  1691 +
  1692 +}
  1693 +
  1694 +/*************************************************************************
  1695 +* FUNCTION
  1696 +* GC6133_SERIALPvSetting
  1697 +*
  1698 +* DESCRIPTION
  1699 +* This function apply the preview mode setting, normal the preview size is 1/4 of full size.
  1700 +* Ex. 2M (1600 x 1200)
  1701 +* Preview: 800 x 600 (use sub-sample or binning to acheive it)
  1702 +* Full Size: 1600 x 1200 (output every effective pixels.)
  1703 +*
  1704 +* PARAMETERS
  1705 +* None
  1706 +*
  1707 +* RETURNS
  1708 +* None
  1709 +*
  1710 +* LOCAL AFFECTED
  1711 +*
  1712 +*************************************************************************/
  1713 +static void GC6133_SERIALPvSetting(void)
  1714 +{
  1715 + // TODO: add preview setting here
  1716 +
  1717 +}
  1718 +
  1719 +/*************************************************************************
  1720 +* FUNCTION
  1721 +* GC6133_SERIALCapSetting
  1722 +*
  1723 +* DESCRIPTION
  1724 +* This function config capture settting to sensor
  1725 +*
  1726 +* PARAMETERS
  1727 +* None
  1728 +*
  1729 +* RETURNS
  1730 +* None
  1731 +*
  1732 +* LOCAL AFFECTED
  1733 +*
  1734 +*************************************************************************/
  1735 +static void GC6133_SERIALCapSetting(void)
  1736 +{
  1737 + // TODO: add capture setting here
  1738 +
  1739 +}
  1740 +
  1741 +/*************************************************************************
  1742 +* FUNCTION
  1743 +* GC6133_SERIALGetSensorInfo
  1744 +*
  1745 +* DESCRIPTION
  1746 +* This function set sensor infomation
  1747 +*
  1748 +* PARAMETERS
  1749 +* Info
  1750 +*
  1751 +* RETURNS
  1752 +* None
  1753 +*
  1754 +* LOCAL AFFECTED
  1755 +*
  1756 +*************************************************************************/
  1757 +static void GC6133_SERIALGetSensorInfo(P_IMAGE_SENSOR_GET_SENSOR_INFO_STRUCT Info)
  1758 +{
  1759 + Info->SensorId = GC6133_SERIAL_SENSOR_ID;
  1760 + Info->SensorIf = IMAGE_SENSOR_IF_SERIAL;
  1761 +
  1762 + /* data format */
  1763 + Info->PreviewNormalDataFormat = IMAGE_SENSOR_DATA_OUT_FORMAT_UYVY;
  1764 + Info->PreviewHMirrorDataFormat = IMAGE_SENSOR_DATA_OUT_FORMAT_UYVY;
  1765 + Info->PreviewVMirrorDataFormat = IMAGE_SENSOR_DATA_OUT_FORMAT_UYVY;
  1766 + Info->PreviewHVMirrorDataFormat = IMAGE_SENSOR_DATA_OUT_FORMAT_UYVY;
  1767 + Info->CaptureDataFormat = IMAGE_SENSOR_DATA_OUT_FORMAT_UYVY;
  1768 +
  1769 + Info->PreviewMclkFreq = 24000000;
  1770 + Info->CaptureMclkFreq = 24000000;
  1771 + Info->VideoMclkFreq = 24000000;
  1772 +
  1773 + Info->PreviewWidth = GC6133_SERIAL_IMAGE_SENSOR_PV_WIDTH;
  1774 + Info->PreviewHeight = GC6133_SERIAL_IMAGE_SENSOR_PV_HEIGHT;
  1775 + Info->FullWidth = GC6133_SERIAL_IMAGE_SENSOR_FULL_WIDTH;
  1776 + Info->FullHeight = GC6133_SERIAL_IMAGE_SENSOR_FULL_HEIGHT;
  1777 + Info->SensorAfSupport = KAL_FALSE;
  1778 + Info->SensorFlashSupport = KAL_FALSE;
  1779 + Info->PixelClkPolarity = POLARITY_LOW;
  1780 +
  1781 + /* HSYNC/VSYNC polarity */
  1782 + Info->HsyncPolarity = POLARITY_LOW; /* actually high active when set POLARITY_LOW */
  1783 + Info->VsyncPolarity = POLARITY_LOW;
  1784 +
  1785 + // TODO: set isp pclk invert here if needed
  1786 + /* isp pclk invert switch */
  1787 + Info->PixelClkInv = KAL_FALSE;
  1788 +}
  1789 +
  1790 +
  1791 +/*************************************************************************
  1792 +* FUNCTION
  1793 +* GC6133SerialSensorFeatureCtrl
  1794 +*
  1795 +* DESCRIPTION
  1796 +* This function set sensor feature mode
  1797 +*
  1798 +* PARAMETERS
  1799 +* id: scenario id
  1800 +*
  1801 +* RETURNS
  1802 +* error code
  1803 +*
  1804 +* LOCAL AFFECTED
  1805 +*
  1806 +*************************************************************************/
  1807 +MM_ERROR_CODE_ENUM GC6133_SERIALGetSerialSensorInfo(P_SERIAL_SENSOR_INFO_IN_STRUCT In,P_SERIAL_SENSOR_INFO_OUT_STRUCT Out)
  1808 +{
  1809 + if (In->ScenarioId == CAL_SCENARIO_CAMERA_STILL_CAPTURE)
  1810 + {
  1811 + Out->para_1 = KAL_TRUE; /* SCK clock inverse */
  1812 + Out->para_2 = 4; /* Cycle */
  1813 + Out->para_3 = GC6133_SERIAL_IMAGE_SENSOR_PV_WIDTH; /* Sensor capture data valid width */
  1814 + Out->para_4 = GC6133_SERIAL_IMAGE_SENSOR_PV_HEIGHT; /* Sensor capture data valid height */
  1815 + }
  1816 + else
  1817 + {
  1818 + Out->para_1 = KAL_TRUE; /* SCK clock inverse */
  1819 + Out->para_2 = 4; /* Cycle */
  1820 + Out->para_3 = GC6133_SERIAL_IMAGE_SENSOR_FULL_WIDTH; /* Sensor preview data valid width */
  1821 + Out->para_4 = GC6133_SERIAL_IMAGE_SENSOR_FULL_HEIGHT; /* Sensor preview data valid height */
  1822 + }
  1823 + Out->para_5 = 1;//lane number
  1824 + return MM_ERROR_NONE;
  1825 +}
  1826 +
  1827 +
  1828 +/*************************************************************************
  1829 +* FUNCTION
  1830 +* GC6133_SERIALPowerOn
  1831 +*
  1832 +* DESCRIPTION
  1833 +* This function apply the power on sequence and read the sensor ID to check if the I2C
  1834 +* communication can work or not.
  1835 +*
  1836 +* PARAMETERS
  1837 +* None
  1838 +*
  1839 +* RETURNS
  1840 +* Sensor id
  1841 +*
  1842 +* LOCAL AFFECTED
  1843 +*
  1844 +*************************************************************************/
  1845 +static kal_uint32 GC6133_SERIALPowerOn(void)
  1846 +{
  1847 + static kal_uint8 GC6133_SERIALI2cAddr[] = {GC6133_SERIAL_WRITE_ID_0,
  1848 +#if (GC6133_SERIAL_WRITE_ID_1 != 0xFF)
  1849 + GC6133_SERIAL_WRITE_ID_1,
  1850 +#endif
  1851 +#if (GC6133_SERIAL_WRITE_ID_2 != 0xFF)
  1852 + GC6133_SERIAL_WRITE_ID_2,
  1853 +#endif
  1854 +#if (GC6133_SERIAL_WRITE_ID_3 != 0xFF)
  1855 + GC6133_SERIAL_WRITE_ID_3,
  1856 +#endif
  1857 + };
  1858 + kal_uint32 SensorId;
  1859 + kal_uint8 i;
  1860 +
  1861 +
  1862 + CisModulePowerOn(GC6133_SERIALSensor.SensorIdx, KAL_TRUE);
  1863 + GC6133_SERIALSensor.sccb_opened = KAL_TRUE; // lanking 20120423
  1864 + CameraSccbOpen(CAMERA_SCCB_SENSOR, GC6133_SERIAL_WRITE_ID_0,
  1865 + GC6133_SERIAL_I2C_ADDR_BITS, GC6133_SERIAL_I2C_DATA_BITS, GC6133_SERIAL_HW_I2C_SPEED);
  1866 + /* add under line if sensor I2C do not support repeat start */
  1867 + //CameraSccbDisWR(CAMERA_SCCB_SENSOR);
  1868 + ENABLE_CAMERA_CLOCK_OUTPUT_TO_CMOS;
  1869 + kal_sleep_task(2);
  1870 + // TODO: add hardware reset by spec here
  1871 + {
  1872 + GC6133_SERIAL_SET_PDN_LOW;
  1873 + kal_sleep_task(2);
  1874 + GC6133_SERIAL_SET_PDN_HIGH;
  1875 + kal_sleep_task(5);
  1876 + GC6133_SERIAL_SET_PDN_LOW;
  1877 + kal_sleep_task(1);
  1878 +
  1879 + GC6133_SERIAL_SET_RST_HIGH;
  1880 + kal_sleep_task(1);
  1881 + GC6133_SERIAL_SET_RST_LOW;
  1882 + kal_sleep_task(1);
  1883 + GC6133_SERIAL_SET_RST_HIGH;
  1884 + kal_sleep_task(1);
  1885 + }
  1886 +
  1887 + //for SPI
  1888 +
  1889 + GPIO_ModeSetup(27, 1);// CMCSD0
  1890 + GPIO_ModeSetup(28, 1);// CMCSD1
  1891 + GPIO_ModeSetup(29, 1);// CMMCLK
  1892 + GPIO_ModeSetup(30, 1);//CMCSK
  1893 + //GPIO_ModeSetup(25, 0);// CMRST
  1894 + //GPIO_ModeSetup(26, 0);// CMPDN
  1895 +
  1896 + for (i = 0; i < sizeof(GC6133_SERIALI2cAddr) / sizeof(GC6133_SERIALI2cAddr[0]); i++)
  1897 + {
  1898 + CameraSccbSetAddr(CAMERA_SCCB_SENSOR, GC6133_SERIALI2cAddr[i]);
  1899 +
  1900 + // TODO: read sensor id here
  1901 + {
  1902 +
  1903 + kal_sleep_task(1);
  1904 + SensorId = CamReadCmosSensor(0xf0);
  1905 + }
  1906 + if (GC6133_SERIAL_SENSOR_ID == SensorId)
  1907 + {
  1908 + kal_uint8 Temp;
  1909 +
  1910 + /* swap the correct i2c address to first one, it will speed up next time read sensor ID */
  1911 + Temp = GC6133_SERIALI2cAddr[0];
  1912 + GC6133_SERIALI2cAddr[0] = GC6133_SERIALI2cAddr[i];
  1913 + GC6133_SERIALI2cAddr[i] = Temp;
  1914 + break;
  1915 + }
  1916 + }
  1917 + GC6133_SERIAL_TRACE("SENSOR ID: %x", SensorId);
  1918 +
  1919 + /*
  1920 + If dual camera , get current ID here,
  1921 + if back camera, continue;
  1922 + if front camera, reture 0;
  1923 + */
  1924 +
  1925 + return SensorId;
  1926 +}
  1927 +
  1928 +/*************************************************************************
  1929 +* FUNCTION
  1930 +* GC6133_SERIALPowerDown
  1931 +*
  1932 +* DESCRIPTION
  1933 +* This function power down the cmos sensor
  1934 +* IMPORTANT NOTICE:
  1935 +* data[7:0]/HSYNC/VSYNC/PCLK pin should be in High-Z state after executed this function
  1936 +*
  1937 +* PARAMETERS
  1938 +* None
  1939 +*
  1940 +* RETURNS
  1941 +* None
  1942 +*
  1943 +* LOCAL AFFECTED
  1944 +*
  1945 +*************************************************************************/
  1946 +static void GC6133_SERIALPowerDown(void)
  1947 +{
  1948 + // TODO: power down sensor by spec here
  1949 + if(GC6133_SERIALSensor.sccb_opened == KAL_TRUE)
  1950 + {
  1951 +
  1952 + CamWriteCmosSensor(0xfc, 0x01);
  1953 + CamWriteCmosSensor(0xf1, 0x00);
  1954 + }
  1955 + GC6133_SERIAL_SET_RST_LOW;
  1956 + kal_sleep_task(1);
  1957 + //GC6133_SERIAL_SET_PDN_LOW;
  1958 + GC6133_SERIAL_SET_PDN_HIGH;
  1959 +}
  1960 +
  1961 +/*************************************************************************
  1962 +* FUNCTION
  1963 +* GC6133_SERIALPreview
  1964 +*
  1965 +* DESCRIPTION
  1966 +* This function is the most important functions of (Init, Preview & Capture).
  1967 +* 1. Apply preview setting, make sensor output preview resolution, e.g. 800x600 for 2M sensor.
  1968 +* 2. Record video resolution, and set mode based on the isp operation mode.
  1969 +* 3. Configure the grab window.
  1970 +*
  1971 +* PARAMETERS
  1972 +* Id, In, Out
  1973 +*
  1974 +* RETURNS
  1975 +* None
  1976 +*
  1977 +* LOCAL AFFECTED
  1978 +*
  1979 +*************************************************************************/
  1980 +static void GC6133_SERIALPreview(CAL_SCENARIO_ENUM Id, P_IMAGE_SENSOR_SCENARIO_PARA_IN_STRUCT In, P_IMAGE_SENSOR_SCENARIO_PARA_OUT_STRUCT Out)
  1981 +{
  1982 + GC6133_SERIALSensor.BandingFreq = (CAM_BANDING_50HZ == In->BandingFreq ? GC6133_SERIAL_50HZ : GC6133_SERIAL_60HZ);
  1983 +
  1984 + GC6133_SERIALSensor.NightMode = In->NightMode;
  1985 + /* change to preview size output */
  1986 + GC6133_SERIALSensor.PvMode = KAL_TRUE;
  1987 + GC6133_SERIALPvSetting();
  1988 + //GC6133_SERIALSetClock(GC6133_SERIAL_PV_INTERNAL_CLK);
  1989 +
  1990 + /* set preview frame rate range */
  1991 + switch (Id)
  1992 + {
  1993 + case CAL_SCENARIO_VIDEO:
  1994 + GC6133_SERIALSensor.VideoMode = KAL_TRUE;
  1995 + //GC6133_SERIALSetVideoFps(In->MaxVideoFrameRate);
  1996 +
  1997 + break;
  1998 + default:
  1999 + GC6133_SERIALSensor.VideoMode = KAL_FALSE;
  2000 + //GC6133_SERIALSetMaxFps(GC6133_SERIAL_FPS(30));
  2001 + //GC6133_SERIALSetMinFps(In->NightMode ? GC6133_SERIAL_FPS(5) : GC6133_SERIAL_FPS(10));
  2002 +/* if(In->NightMode)
  2003 + {
  2004 +
  2005 + }
  2006 + else
  2007 + {
  2008 +
  2009 + }*/
  2010 + /* roll back shutter&gain from capture state */
  2011 + if (GC6133_SERIALSensor.CapState)
  2012 + {
  2013 + GC6133_SERIALWriteShutter(GC6133_SERIALSensor.Shutter);
  2014 + GC6133_SERIALWriteGain(GC6133_SERIALSensor.Gain);
  2015 + }
  2016 + }
  2017 +
  2018 + /* misc setting */
  2019 + GC6133_SERIALSetMirror(In->ImageMirror);
  2020 +
  2021 + /* change to preview state */
  2022 + GC6133_SERIALSensor.CapState = KAL_FALSE;
  2023 +
  2024 + /* enable ae/awb */
  2025 + GC6133_SERIALAeEnable(KAL_TRUE);
  2026 + GC6133_SERIALAwbEnable(KAL_TRUE);
  2027 +
  2028 + /* set grab window */
  2029 + Out->WaitStableFrameNum = 0;
  2030 + Out->GrabStartX = GC6133_SERIAL_PV_GRAB_START_X;
  2031 + Out->GrabStartY = GC6133_SERIAL_PV_GRAB_START_Y;
  2032 + Out->ExposureWindowWidth = GC6133_SERIAL_PV_GRAB_WIDTH;
  2033 + Out->ExposureWindowHeight = GC6133_SERIAL_PV_GRAB_HEIGHT;
  2034 +}
  2035 +
  2036 +/*************************************************************************
  2037 +* FUNCTION
  2038 +* GC6133_SERIALCapture
  2039 +*
  2040 +* DESCRIPTION
  2041 +* This function is the most important functions of (Init, Preview & Capture).
  2042 +* 1. Apply capture setting when capture size greatter then preview size, make sensor output
  2043 +* full size, e.g. 1600x1200 for 2M sensor.
  2044 +* 2. Increase the dummy pixels or derease pixel clock based on the digital zoom factor and
  2045 +* interpolation times.
  2046 +* 3. Re-Calculate the shutter and sensor gain, to make the exposure value is same with preview
  2047 +* 4. Configure the grab window based on sensor output.
  2048 +*
  2049 +* PARAMETERS
  2050 +* Id, In, Out
  2051 +*
  2052 +* RETURNS
  2053 +* None
  2054 +*
  2055 +* LOCAL AFFECTED
  2056 +*
  2057 +*************************************************************************/
  2058 +static void GC6133_SERIALCapture(CAL_SCENARIO_ENUM Id, P_IMAGE_SENSOR_SCENARIO_PARA_IN_STRUCT In, P_IMAGE_SENSOR_SCENARIO_PARA_OUT_STRUCT Out)
  2059 +{
  2060 + kal_uint32 PvClk, PvLineLength, CapShutter, CapLineLength, DummyPixel = 0;
  2061 +
  2062 + /* back up preview clock/linelength/shutter */
  2063 + PvClk = GC6133_SERIALSensor.InternalClock;
  2064 + PvLineLength = GC6133_SERIALSensor.LineLength;
  2065 + GC6133_SERIALSensor.Shutter = GC6133_SERIALReadShutter();
  2066 + //GC6133_SERIALSensor.Gain = GC6133_SERIALReadGain();
  2067 +
  2068 + /* change to capture state */
  2069 + GC6133_SERIALSensor.CapState = KAL_TRUE;
  2070 + if (In->ImageTargetWidth <= GC6133_SERIAL_IMAGE_SENSOR_PV_WIDTH && In->ImageTargetHeight <= GC6133_SERIAL_IMAGE_SENSOR_PV_HEIGHT)
  2071 + {
  2072 + // TODO: add dummy pixel or reduce pclk until capture success
  2073 + {
  2074 +#if (defined(DRV_ISP_YUV_BURST_MODE_SUPPORT) || defined(DRV_ISP_6276_SERIES)) /* MT6253/76 */
  2075 + /* no need reduce frame rate */
  2076 +#elif (defined(DRV_ISP_MT6236_HW_SUPPORT)) /* MT6236 */
  2077 + if (In->ZoomFactor > 400) /* (4, 8]x zoom */
  2078 + {
  2079 + DummyPixel = 0;
  2080 + /* please reduce pclk if dummy pixel overflow */
  2081 + /* GC6133_SERIALSetClock(~); */
  2082 + }
  2083 + else if (In->ZoomFactor > 200) /* (2, 4]x zoom */
  2084 + {
  2085 + DummyPixel = 0;
  2086 + /* please reduce pclk if dummy pixel overflow */
  2087 + /* GC6133_SERIALSetClock(~); */
  2088 + }
  2089 + else if (In->ZoomFactor > 100) /* (1, 2]x zoom */
  2090 + {
  2091 + DummyPixel = 0;
  2092 + /* please reduce pclk if dummy pixel overflow */
  2093 + /* GC6133_SERIALSetClock(~); */
  2094 + }
  2095 +#elif (defined(DRV_ISP_6238_SERIES))
  2096 + if (In->ZoomFactor > 400) /* (4, 8]x zoom */
  2097 + {
  2098 + DummyPixel = 0;
  2099 + /* please reduce pclk if dummy pixel overflow */
  2100 + /* GC6133_SERIALSetClock(~); */
  2101 + }
  2102 + else if (In->ZoomFactor > 200) /* (2, 4]x zoom */
  2103 + {
  2104 + DummyPixel = 0;
  2105 + /* please reduce pclk if dummy pixel overflow */
  2106 + /* GC6133_SERIALSetClock(~); */
  2107 + }
  2108 + else if (In->ZoomFactor > 100) /* (1, 2]x zoom */
  2109 + {
  2110 + DummyPixel = 0;
  2111 + /* please reduce pclk if dummy pixel overflow */
  2112 + /* GC6133_SERIALSetClock(~); */
  2113 + }
  2114 +#elif (defined(DRV_ISP_6235_SERIES)) /* MT6235 */
  2115 + if (In->ZoomFactor > 400) /* (4, 8]x zoom */
  2116 + {
  2117 + DummyPixel = 0;
  2118 + /* please reduce pclk if dummy pixel overflow */
  2119 + /* GC6133_SERIALSetClock(~); */
  2120 + }
  2121 + else if (In->ZoomFactor > 200) /* (2, 4]x zoom */
  2122 + {
  2123 + DummyPixel = 0;
  2124 + /* please reduce pclk if dummy pixel overflow */
  2125 + /* GC6133_SERIALSetClock(~); */
  2126 + }
  2127 + else if (In->ZoomFactor > 100) /* (1, 2]x zoom */
  2128 + {
  2129 + DummyPixel = 0;
  2130 + /* please reduce pclk if dummy pixel overflow */
  2131 + /* GC6133_SERIALSetClock(~); */
  2132 + }
  2133 +#else
  2134 +#error not verify yet
  2135 +#endif
  2136 + }
  2137 +
  2138 + if (DummyPixel)
  2139 + {
  2140 + /* disable ae/awb */
  2141 + GC6133_SERIALAeEnable(KAL_FALSE);
  2142 + GC6133_SERIALAwbEnable(KAL_FALSE);
  2143 +
  2144 + #if 0
  2145 + /* set dummy pixel */
  2146 + if (PvLineLength - GC6133_SERIAL_PV_PERIOD_PIXEL_NUMS > DummyPixel)
  2147 + {
  2148 + DummyPixel = PvLineLength - GC6133_SERIAL_PV_PERIOD_PIXEL_NUMS;
  2149 + }
  2150 + GC6133_SERIALSetDummy(DummyPixel, 0);
  2151 +
  2152 + /* shutter translation, GC6133_SERIALSensor.InternalClock >> 14 & PvClk >> 14 to avoid data overflow */
  2153 + CapShutter = (GC6133_SERIALSensor.Shutter * (GC6133_SERIALSensor.InternalClock >> 14) + (PvClk >> 15)) / (PvClk >> 14);
  2154 + CapShutter = (CapShutter * PvLineLength + (GC6133_SERIALSensor.LineLength >> 1)) / GC6133_SERIALSensor.LineLength;
  2155 +
  2156 + /* write shutter */
  2157 + GC6133_SERIALWriteShutter(CapShutter);
  2158 + #endif
  2159 +
  2160 + Out->WaitStableFrameNum = GC6133_SERIAL_CAPTURE_DELAY_FRAME;
  2161 + }
  2162 + else
  2163 + {
  2164 + Out->WaitStableFrameNum = 0;
  2165 + }
  2166 +
  2167 + /* set grab window */
  2168 + Out->GrabStartX = GC6133_SERIAL_PV_GRAB_START_X;
  2169 + Out->GrabStartY = GC6133_SERIAL_PV_GRAB_START_Y;
  2170 + Out->ExposureWindowWidth = GC6133_SERIAL_PV_GRAB_WIDTH;
  2171 + Out->ExposureWindowHeight = GC6133_SERIAL_PV_GRAB_HEIGHT;
  2172 + }
  2173 + else
  2174 + {
  2175 + /* disable ae/awb */
  2176 + GC6133_SERIALAeEnable(KAL_FALSE);
  2177 + GC6133_SERIALAwbEnable(KAL_FALSE);
  2178 +
  2179 + /* change to full size output */
  2180 + GC6133_SERIALSensor.PvMode = KAL_FALSE;
  2181 + //GC6133_SERIALCapSetting();
  2182 + //GC6133_SERIALSetClock(GC6133_SERIAL_CAP_INTERNAL_CLK);
  2183 +
  2184 + // TODO: add dummy pixel or reduce pclk until capture success
  2185 + {
  2186 +#if (defined(DRV_ISP_YUV_BURST_MODE_SUPPORT) || defined(DRV_ISP_6276_SERIES)) /* MT6253/76 */
  2187 + /* no need reduce frame rate */
  2188 +#elif (defined(DRV_ISP_MT6236_HW_SUPPORT)) /* MT6236 */
  2189 + if (In->ZoomFactor > 400) /* (4, 8]x zoom */
  2190 + {
  2191 + DummyPixel = 0;
  2192 + /* please reduce pclk if dummy pixel overflow */
  2193 + /* GC6133_SERIALSetClock(~); */
  2194 + }
  2195 + else if (In->ZoomFactor > 200) /* (2, 4]x zoom */
  2196 + {
  2197 + DummyPixel = 0;
  2198 + /* please reduce pclk if dummy pixel overflow */
  2199 + /* GC6133_SERIALSetClock(~); */
  2200 + }
  2201 + else if (In->ZoomFactor > 100) /* (1, 2]x zoom */
  2202 + {
  2203 + DummyPixel = 0;
  2204 + /* please reduce pclk if dummy pixel overflow */
  2205 + /* GC6133_SERIALSetClock(~); */
  2206 + }
  2207 +#elif (defined(DRV_ISP_6238_SERIES))
  2208 + if (In->ZoomFactor > 400) /* (4, 8]x zoom */
  2209 + {
  2210 + DummyPixel = 0;
  2211 + /* please reduce pclk if dummy pixel overflow */
  2212 + /* GC6133_SERIALSetClock(~); */
  2213 + }
  2214 + else if (In->ZoomFactor > 200) /* (2, 4]x zoom */
  2215 + {
  2216 + DummyPixel = 0;
  2217 + /* please reduce pclk if dummy pixel overflow */
  2218 + /* GC6133_SERIALSetClock(~); */
  2219 + }
  2220 + else if (In->ZoomFactor > 100) /* (1, 2]x zoom */
  2221 + {
  2222 + DummyPixel = 0;
  2223 + /* please reduce pclk if dummy pixel overflow */
  2224 + /* GC6133_SERIALSetClock(~); */
  2225 + }
  2226 +#elif (defined(DRV_ISP_6235_SERIES)) /* MT6235 */
  2227 + if (In->ZoomFactor > 400) /* (4, 8]x zoom */
  2228 + {
  2229 + DummyPixel = 0;
  2230 + /* please reduce pclk if dummy pixel overflow */
  2231 + /* GC6133_SERIALSetClock(~); */
  2232 + }
  2233 + else if (In->ZoomFactor > 200) /* (2, 4]x zoom */
  2234 + {
  2235 + DummyPixel = 0;
  2236 + /* please reduce pclk if dummy pixel overflow */
  2237 + /* GC6133_SERIALSetClock(~); */
  2238 + }
  2239 + else if (In->ZoomFactor > 100) /* (1, 2]x zoom */
  2240 + {
  2241 + DummyPixel = 0;
  2242 + /* please reduce pclk if dummy pixel overflow */
  2243 + /* GC6133_SERIALSetClock(~); */
  2244 + }
  2245 +#else
  2246 +#error not verify yet
  2247 +#endif
  2248 + }
  2249 +
  2250 + #if 0
  2251 + /* set dummy pixel */
  2252 + CapLineLength = GC6133_SERIALSensor.InternalClock * GC6133_SERIAL_FPS(1) / (GC6133_SERIAL_FULL_PERIOD_LINE_NUMS * In->MaxVideoFrameRate);
  2253 + if (CapLineLength < GC6133_SERIAL_FULL_PERIOD_PIXEL_NUMS)
  2254 + {
  2255 + CapLineLength = GC6133_SERIAL_FULL_PERIOD_PIXEL_NUMS;
  2256 + }
  2257 + if (CapLineLength > GC6133_SERIAL_MAX_CAP_LINELENGTH) /* register limitation */
  2258 + {
  2259 + GC6133_SERIAL_TRACE("caplinelength: %d, capframerate: %d overflow!!!", CapLineLength, In->MaxVideoFrameRate);
  2260 + CapLineLength = GC6133_SERIAL_MAX_CAP_LINELENGTH;
  2261 + }
  2262 + if (CapLineLength - GC6133_SERIAL_FULL_PERIOD_PIXEL_NUMS > DummyPixel)
  2263 + {
  2264 + DummyPixel = CapLineLength - GC6133_SERIAL_FULL_PERIOD_PIXEL_NUMS;
  2265 + }
  2266 + GC6133_SERIALSetDummy(DummyPixel, 0);
  2267 +
  2268 + /* shutter translation, GC6133_SERIALSensor.InternalClock >> 14 & PvClk >> 14 to avoid data overflow */
  2269 + CapShutter = (GC6133_SERIALSensor.Shutter * (GC6133_SERIALSensor.InternalClock >> 14) + (PvClk >> 15)) / (PvClk >> 14);
  2270 + CapShutter = (CapShutter * PvLineLength + (GC6133_SERIALSensor.LineLength >> 1)) / GC6133_SERIALSensor.LineLength;
  2271 +
  2272 + /* write shutter */
  2273 + GC6133_SERIALWriteShutter(CapShutter);
  2274 + #endif
  2275 +
  2276 + /* set grab window */
  2277 + Out->WaitStableFrameNum = GC6133_SERIAL_CAPTURE_DELAY_FRAME;
  2278 + Out->GrabStartX = GC6133_SERIAL_FULL_GRAB_START_X;
  2279 + Out->GrabStartY = GC6133_SERIAL_FULL_GRAB_START_Y;
  2280 + Out->ExposureWindowWidth = GC6133_SERIAL_FULL_GRAB_WIDTH;
  2281 + Out->ExposureWindowHeight = GC6133_SERIAL_FULL_GRAB_HEIGHT;
  2282 + }
  2283 +}
  2284 +
  2285 +/*************************************************************************
  2286 +* FUNCTION
  2287 +* GC6133_SERIALDetectSensorId
  2288 +*
  2289 +* DESCRIPTION
  2290 +* This function detect sensor id
  2291 +*
  2292 +* PARAMETERS
  2293 +* None
  2294 +*
  2295 +* RETURNS
  2296 +* Sensor id
  2297 +*
  2298 +* LOCAL AFFECTED
  2299 +*
  2300 +*************************************************************************/
  2301 +kal_uint32 GC6133_SERIALDetectSensorId(void)
  2302 +{
  2303 + MM_ERROR_CODE_ENUM GC6133_SERIALSensorClose(void);
  2304 + kal_uint32 SensorId;
  2305 + IMAGE_SENSOR_INDEX_ENUM InvIdx;
  2306 + kal_int8 i, j;
  2307 +
  2308 + switch (GC6133_SERIALSensor.SensorIdx)
  2309 + {
  2310 + case IMAGE_SENSOR_MAIN:
  2311 + case IMAGE_SENSOR_BAK1:
  2312 + InvIdx = IMAGE_SENSOR_SUB;
  2313 + break;
  2314 + default:
  2315 + InvIdx = IMAGE_SENSOR_MAIN;
  2316 + break;
  2317 + }
  2318 + for (i = 1; i >= 0; i--)
  2319 + {
  2320 + for (j = 1; j >= 0; j--)
  2321 + {
  2322 + //CamRstPinCtrl(InvIdx, i);
  2323 + //CamPdnPinCtrl(InvIdx, j);
  2324 + CamRstPinCtrl(InvIdx, 0);
  2325 + CamPdnPinCtrl(InvIdx, 1);
  2326 + SensorId = GC6133_SERIALPowerOn();
  2327 + GC6133_SERIALSensorClose();
  2328 + if (GC6133_SERIAL_SENSOR_ID == SensorId)
  2329 + {
  2330 + return GC6133_SERIAL_SENSOR_ID;
  2331 + }
  2332 + }
  2333 + }
  2334 + return MM_ERROR_SENSOR_READ_ID_FAIL;
  2335 +}
  2336 +
  2337 +/*************************************************************************
  2338 +* FUNCTION
  2339 +* GC6133_SERIALInitOperationPara
  2340 +*
  2341 +* DESCRIPTION
  2342 +* This function set sensor operation para
  2343 +*
  2344 +* PARAMETERS
  2345 +* Para
  2346 +*
  2347 +* RETURNS
  2348 +* None
  2349 +*
  2350 +* LOCAL AFFECTED
  2351 +*
  2352 +*************************************************************************/
  2353 +static void GC6133_SERIALInitOperationPara(P_IMAGE_SENSOR_GET_INIT_OPERATION_PARA_STRUCT Para)
  2354 +{
  2355 + Para->CaptureDelayFrame = 0; /* use WaitStableFrameNum instead of this */
  2356 + Para->PreviewDelayFrame = GC6133_SERIAL_PREVIEW_DELAY_FRAME;
  2357 + Para->PreviewDisplayWaitFrame = GC6133_SERIAL_FIRST_PREVIEW_DELAY_FRAME;
  2358 +}
  2359 +
  2360 +/*************************************************************************
  2361 +* FUNCTION
  2362 +* GC6133_SERIALSensorOpen
  2363 +*
  2364 +* DESCRIPTION
  2365 +* This function read sensor id and init sensor
  2366 +*
  2367 +* PARAMETERS
  2368 +* None
  2369 +*
  2370 +* RETURNS
  2371 +* Error code
  2372 +*
  2373 +* LOCAL AFFECTED
  2374 +*
  2375 +*************************************************************************/
  2376 +static MM_ERROR_CODE_ENUM GC6133_SERIALSensorOpen(void)
  2377 +{
  2378 + if (GC6133_SERIALPowerOn() != GC6133_SERIAL_SENSOR_ID)
  2379 + {
  2380 + return MM_ERROR_SENSOR_READ_ID_FAIL;
  2381 + }
  2382 +
  2383 + {
  2384 + GC6133_SERIALInitialSetting(); /* apply the sensor initial setting */
  2385 + GC6133_SERIALMoreSetting();
  2386 + }
  2387 +#ifdef GC6133_SERIAL_LOAD_FROM_T_FLASH
  2388 + GC6133_SERIAL_Initialize_from_T_Flash(); /* for debug use. */
  2389 +#endif
  2390 +
  2391 + /* default setting */
  2392 + GC6133_SERIALSensor.BypassAe = KAL_FALSE; /* for panorama view */
  2393 + GC6133_SERIALSensor.BypassAwb = KAL_FALSE; /* for panorama view */
  2394 + GC6133_SERIALSensor.CapState = KAL_FALSE; /* preview state */
  2395 + GC6133_SERIALSensor.PvMode = KAL_TRUE; /* preview size output mode */
  2396 + GC6133_SERIALSensor.VideoMode = KAL_FALSE; /* KAL_TRUE: video mode, else preview mode */
  2397 + GC6133_SERIALSensor.NightMode = KAL_FALSE;/*KAL_TRUE:work in night mode, else normal mode*/
  2398 + GC6133_SERIALSensor.BandingFreq = GC6133_SERIAL_50HZ;
  2399 + GC6133_SERIALSensor.InternalClock = 1; /* will be update by setclock function */
  2400 + GC6133_SERIALSensor.Shutter = 1; /* default shutter 1 avoid divide by 0 */
  2401 + GC6133_SERIALSensor.Gain = 0x40; /* default gain 1x */
  2402 + //GC6133_SERIALSensor.FrameLength = GC6133_SERIAL_PV_PERIOD_LINE_NUMS; /* will be update by setdummy function */
  2403 + //GC6133_SERIALSensor.LineLength = GC6133_SERIAL_PV_PERIOD_PIXEL_NUMS; /* will be update by setdummy function */
  2404 +
  2405 + return MM_ERROR_NONE;
  2406 +}
  2407 +
  2408 +/*************************************************************************
  2409 +* FUNCTION
  2410 +* GC6133_SERIALSensorFeatureCtrl
  2411 +*
  2412 +* DESCRIPTION
  2413 +* This function set sensor feature mode
  2414 +*
  2415 +* PARAMETERS
  2416 +* Id: scenario id
  2417 +* In: input parameter
  2418 +* Out: output parameter
  2419 +* OutLen: output parameter length
  2420 +* RealOutLen: real output parameter length
  2421 +*
  2422 +* RETURNS
  2423 +* Error code
  2424 +*
  2425 +* LOCAL AFFECTED
  2426 +*
  2427 +*************************************************************************/
  2428 +static MM_ERROR_CODE_ENUM GC6133_SERIALSensorFeatureCtrl(kal_uint32 Id, void *In, void *Out, kal_uint32 OutLen, kal_uint32 *RealOutLen)
  2429 +{
  2430 + MM_ERROR_CODE_ENUM ErrCode = MM_ERROR_NONE;
  2431 +
  2432 + if (Id >= CAL_FEATURE_WEBCAM_BEGIN && Id <= CAL_FEATURE_WEBCAM_END)
  2433 + {
  2434 + return GC6133_SERIALWebcamFeatureCtrl(Id, In, Out, OutLen, RealOutLen);
  2435 + }
  2436 + switch (Id)
  2437 + {
  2438 + /* query and set series */
  2439 + case CAL_FEATURE_CAMERA_BRIGHTNESS:
  2440 + case CAL_FEATURE_CAMERA_EV_VALUE:
  2441 + ErrCode = GC6133_SERIALEv(In, Out);
  2442 + break;
  2443 + case CAL_FEATURE_CAMERA_CONTRAST:
  2444 + ErrCode = GC6133_SERIALContrast(In, Out);
  2445 + break;
  2446 + case CAL_FEATURE_CAMERA_SATURATION:
  2447 + ErrCode = GC6133_SERIALSaturation(In, Out);
  2448 + break;
  2449 + case CAL_FEATURE_CAMERA_SHARPNESS:
  2450 + ErrCode = GC6133_SERIALSharpness(In, Out);
  2451 + break;
  2452 + case CAL_FEATURE_CAMERA_WB:
  2453 + ErrCode = GC6133_SERIALWb(In, Out);
  2454 + break;
  2455 + case CAL_FEATURE_CAMERA_IMAGE_EFFECT:
  2456 + ErrCode = GC6133_SERIALEffect(In, Out);
  2457 + break;
  2458 + case CAL_FEATURE_CAMERA_STILL_CAPTURE_SIZE:
  2459 + ErrCode = GC6133_SERIALStillCaptureSize(In, Out);
  2460 + break;
  2461 + case CAL_FEATURE_CAMERA_BANDING_FREQ:
  2462 + ErrCode = GC6133_SERIALBanding(In, Out);
  2463 + break;
  2464 + case CAL_FEATURE_CAMERA_SCENE_MODE:
  2465 + ErrCode = GC6133_SERIALSceneMode(KAL_TRUE, In, Out);
  2466 + break;
  2467 + case CAL_FEATURE_CAMERA_VIDEO_SCENE_MODE:
  2468 + ErrCode = GC6133_SERIALSceneMode(KAL_FALSE, In, Out);
  2469 + break;
  2470 + case CAL_FEATURE_CAMERA_FLASH_MODE:
  2471 + case CAL_FEATURE_CAMERA_HUE:
  2472 + case CAL_FEATURE_CAMERA_GAMMA:
  2473 + ErrCode = MM_ERROR_SENSOR_FEATURE_NOT_SUPPORT;
  2474 + break;
  2475 +
  2476 + /* get info series */
  2477 + case IMAGE_SENSOR_FEATURE_GET_SENSOR_INFO:
  2478 + GC6133_SERIALGetSensorInfo(Out);
  2479 + break;
  2480 + case IMAGE_SENSOR_FEATURE_GET_SENSOR_ID:
  2481 + ((P_IMAGE_SENSOR_COMM_DATA_STRUCT)Out)->FeatureValue = GC6133_SERIALDetectSensorId();
  2482 + break;
  2483 + case IMAGE_SENSOR_FEATURE_GET_SENSOR_FRAME_RATE:
  2484 + ((P_IMAGE_SENSOR_COMM_DATA_STRUCT)Out)->FeatureValue = \
  2485 + GC6133_SERIALSensor.InternalClock * GC6133_SERIAL_FPS(1) / (GC6133_SERIALSensor.LineLength * GC6133_SERIALSensor.FrameLength);
  2486 + break;
  2487 + case IMAGE_SENSOR_FEATURE_GET_INIT_OPERATION_PARA:
  2488 + GC6133_SERIALInitOperationPara(Out);
  2489 + break;
  2490 + case IMAGE_SENSOR_FEATURE_GET_HW_DEPENDENT_SETTING:
  2491 + CamGetHWInfo(GC6133_SERIALSensor.SensorIdx, Out);
  2492 + break;
  2493 +
  2494 + /* set para series */
  2495 + case IMAGE_SENSOR_FEATURE_SET_SENSOR_POWER_DOWN:
  2496 + GC6133_SERIALPowerDown();
  2497 + break;
  2498 + case IMAGE_SENSOR_FEATURE_SET_NVRAM_SENSOR_INFO:
  2499 + GC6133_SERIALSensor.NvramData = &(((nvram_camera_para_struct *)In)->SENSOR);
  2500 + break;
  2501 + case IMAGE_SENSOR_FEATURE_SET_CAMERA_SOURCE:
  2502 + GC6133_SERIALSensor.SensorIdx = ((P_IMAGE_SENSOR_SET_CAMERA_SOURCE_STRUCT)In)->ImageSensorIdx;
  2503 + break;
  2504 + case IMAGE_SENSOR_FEATURE_CTRL_NIGHTMODE: /* move to preview */
  2505 +
  2506 + break;
  2507 + case IMAGE_SENSOR_FEATURE_SET_AE_BYPASS:
  2508 + GC6133_SERIALSensor.BypassAe = (kal_bool)((P_IMAGE_SENSOR_COMM_DATA_STRUCT)In)->FeatureValue;
  2509 + GC6133_SERIALAeEnable(GC6133_SERIALSensor.BypassAe ? KAL_FALSE : KAL_TRUE);
  2510 + break;
  2511 + case IMAGE_SENSOR_FEATURE_SET_AWB_BYPASS:
  2512 + GC6133_SERIALSensor.BypassAwb = (kal_bool)((P_IMAGE_SENSOR_COMM_DATA_STRUCT)In)->FeatureValue;
  2513 + GC6133_SERIALAwbEnable(GC6133_SERIALSensor.BypassAwb ? KAL_FALSE : KAL_TRUE);
  2514 + break;
  2515 + case IMAGE_SENSOR_FEATURE_GET_SERIAL_SENSOR_INFO:
  2516 + GC6133_SERIALGetSerialSensorInfo(In, Out);
  2517 + break;
  2518 + default:
  2519 + ErrCode = MM_ERROR_SENSOR_FEATURE_NOT_SUPPORT;
  2520 + break;
  2521 + }
  2522 + return ErrCode;
  2523 +}
  2524 +
  2525 +/*************************************************************************
  2526 +* FUNCTION
  2527 +* GC6133_SERIALSensorCtrl
  2528 +*
  2529 +* DESCRIPTION
  2530 +* This function set sensor scenario mode
  2531 +*
  2532 +* PARAMETERS
  2533 +* Id: scenario id
  2534 +* In/Out: parameter
  2535 +* OutLen: out parameter length
  2536 +* RealOutLen: real out parameter length
  2537 +*
  2538 +* RETURNS
  2539 +* Error code
  2540 +*
  2541 +* LOCAL AFFECTED
  2542 +*
  2543 +*************************************************************************/
  2544 +static MM_ERROR_CODE_ENUM GC6133_SERIALSensorCtrl(CAL_SCENARIO_ENUM Id, void *In, void *Out, kal_uint32 OutLen, kal_uint32 *RealOutLen)
  2545 +{
  2546 + switch (Id)
  2547 + {
  2548 + case CAL_SCENARIO_CAMERA_PREVIEW:
  2549 + case CAL_SCENARIO_VIDEO:
  2550 + case CAL_SCENARIO_WEBCAM_PREVIEW:
  2551 + case CAL_SCENARIO_WEBCAM_CAPTURE:
  2552 + GC6133_SERIALPreview(Id, In, Out);
  2553 + break;
  2554 + case CAL_SCENARIO_CAMERA_STILL_CAPTURE:
  2555 + GC6133_SERIALCapture(Id, In, Out);
  2556 + break;
  2557 + default:
  2558 + break;
  2559 + }
  2560 + return MM_ERROR_NONE;
  2561 +}
  2562 +
  2563 +/*************************************************************************
  2564 +* FUNCTION
  2565 +* GC6133_SERIALSensorClose
  2566 +*
  2567 +* DESCRIPTION
  2568 +* This function is to turn off sensor module power.
  2569 +*
  2570 +* PARAMETERS
  2571 +* None
  2572 +*
  2573 +* RETURNS
  2574 +* Error code
  2575 +*
  2576 +* LOCAL AFFECTED
  2577 +*
  2578 +*************************************************************************/
  2579 +static MM_ERROR_CODE_ENUM GC6133_SERIALSensorClose(void)
  2580 +{
  2581 + GC6133_SERIALPowerDown();
  2582 + GC6133_SERIALSensor.sccb_opened = KAL_FALSE; // lanking 20120423
  2583 + CisModulePowerOn(GC6133_SERIALSensor.SensorIdx, KAL_FALSE);
  2584 + CameraSccbClose(CAMERA_SCCB_SENSOR);
  2585 +/*
  2586 + //Resume
  2587 + #if defined(MT6250)
  2588 + GPIO_ModeSetup(52, 1);
  2589 + GPIO_ModeSetup(64, 1);
  2590 + #else // MT6252
  2591 + GPIO_ModeSetup(47, 1);
  2592 + GPIO_ModeSetup(59, 1);
  2593 + #endif
  2594 +
  2595 +*/
  2596 + return MM_ERROR_NONE;
  2597 +}
  2598 +
  2599 +/*************************************************************************
  2600 +* FUNCTION
  2601 +* GC6133_SERIALSensorFunc
  2602 +*
  2603 +* DESCRIPTION
  2604 +* This function get sensor function pointer
  2605 +*
  2606 +* PARAMETERS
  2607 +* Sensor function pointer
  2608 +*
  2609 +* RETURNS
  2610 +* Error code
  2611 +*
  2612 +* GLOBALS AFFECTED
  2613 +*
  2614 +*************************************************************************/
  2615 +IMAGE_SENSOR_FUNCTION_STRUCT ImageSensorFuncGC6133_SERIAL =
  2616 + {
  2617 + GC6133_SERIALSensorOpen,
  2618 + GC6133_SERIALSensorFeatureCtrl,
  2619 + GC6133_SERIALSensorCtrl,
  2620 + GC6133_SERIALSensorClose,
  2621 + };
  2622 +extern void TOPWELL_SERIALSensorFunc(P_IMAGE_SENSOR_FUNCTION_STRUCT *pfSensorFunc);
  2623 +
  2624 +MM_ERROR_CODE_ENUM GC6133_SERIALSensorFunc(P_IMAGE_SENSOR_FUNCTION_STRUCT *pfSensorFunc)
  2625 +{
  2626 +
  2627 +
  2628 + *pfSensorFunc = &ImageSensorFuncGC6133_SERIAL;
  2629 + //TOPWELL_SERIALSensorFunc(pfSensorFunc);
  2630 +
  2631 + return MM_ERROR_NONE;
  2632 +}
  2633 +
  2634 +#ifdef __GC6133_SERIAL_DEBUG_TRACE__
  2635 +static kal_bool GC6133_SERIALAtGetValue(char *Str, kal_uint32 *Data)
  2636 +{
  2637 + extern int isdigit(int c);
  2638 + extern int isxdigit(int c);
  2639 + extern int tolower(int c);
  2640 + char CmdName[15];
  2641 + kal_uint8 TmpIdx = 0, Index = 3;
  2642 + kal_uint32 Value;
  2643 +
  2644 + while (Str[Index] != '=' && Str[Index] != 13)
  2645 + {
  2646 + CmdName[TmpIdx++] = Str[Index++];
  2647 + }
  2648 + CmdName[TmpIdx] = '\0';
  2649 +
  2650 + if (strcmp(CmdName, "DO"))
  2651 + {
  2652 + return KAL_FALSE;
  2653 + }
  2654 + Value = Data[0] = 0;
  2655 + while (1)
  2656 + {
  2657 + TmpIdx = Str[++Index];
  2658 + switch (TmpIdx)
  2659 + {
  2660 + case 13:
  2661 + case ',':
  2662 + Data[++Data[0]] = Value;
  2663 + if (Data[0] == 9 || TmpIdx == 13)
  2664 + {
  2665 + return KAL_TRUE;
  2666 + }
  2667 + Value = 0;
  2668 + break;
  2669 + default:
  2670 + if (isdigit(TmpIdx))
  2671 + {
  2672 + Value = Value * 16 + TmpIdx - '0';
  2673 + }
  2674 + else if (isxdigit(TmpIdx))
  2675 + {
  2676 + Value = Value * 16 + tolower(TmpIdx) - 'a' + 10;
  2677 + }
  2678 + else
  2679 + {
  2680 + return KAL_TRUE;
  2681 + }
  2682 + break;
  2683 + }
  2684 + }
  2685 +}
  2686 +
  2687 +kal_bool AtFuncTest(kal_char *Str)
  2688 +{
  2689 + kal_uint32 Data[10];
  2690 +
  2691 + if (!GC6133_SERIALAtGetValue(Str, Data))
  2692 + {
  2693 + return KAL_FALSE;
  2694 + }
  2695 + if (!Data[0])
  2696 + {
  2697 + return KAL_TRUE;
  2698 + }
  2699 + switch (Data[1])
  2700 + {
  2701 + case 0x00:
  2702 + {
  2703 + extern kal_uint32 IspCurrentFrameRate;
  2704 +
  2705 + GC6133_SERIAL_TRACE("Current Frame Rate: %d.%d fps", IspCurrentFrameRate / 10, IspCurrentFrameRate % 10);
  2706 + }
  2707 + break;
  2708 + case 0x02:
  2709 + GC6133_SERIAL_TRACE("Read BB Reg[%x] = %x", Data[2], DRV_Reg32(Data[2]));
  2710 + break;
  2711 + case 0x03:
  2712 + DRV_Reg32(Data[2]) = Data[3];
  2713 + GC6133_SERIAL_TRACE("Write BB Reg[%x] = %x", Data[2], DRV_Reg32(Data[2]));
  2714 + break;
  2715 + case 0x04:
  2716 + GC6133_SERIAL_TRACE("Read Sensor Reg[%x] = %x", Data[2], CamReadCmosSensor(Data[2]));
  2717 + break;
  2718 + case 0x05:
  2719 + CamWriteCmosSensor(Data[2], Data[3]);
  2720 + GC6133_SERIAL_TRACE("Write Sensor Reg[%x] = %x", Data[2], CamReadCmosSensor(Data[2]));
  2721 + break;
  2722 + case 0x06:
  2723 + CamWriteCmosSensor(Data[2], Data[3]);
  2724 + GC6133_SERIAL_TRACE("Read Sensor Reg[%x:%x] = %x", Data[3], Data[4], CamReadCmosSensor(Data[4]));
  2725 + break;
  2726 + case 0x07:
  2727 + CamWriteCmosSensor(Data[2], Data[3]);
  2728 + CamWriteCmosSensor(Data[4], Data[5]);
  2729 + CamWriteCmosSensor(Data[2], Data[3]);
  2730 + GC6133_SERIAL_TRACE("Write Sensor Reg[%x:%x] = %x", Data[3], Data[4], CamReadCmosSensor(Data[4]));
  2731 + break;
  2732 + case 0x09:
  2733 + //Data[4] = t[Data[2]];
  2734 + //t[Data[2]] = Data[3];
  2735 + //kal_print_string_trace(MOD_ENG, TRACE_INFO, "t[%d]: %d -> %d", Data[2], Data[4], t[Data[2]]);
  2736 + break;
  2737 + case 0x0A:
  2738 + {
  2739 + kal_uint32 i;
  2740 +
  2741 + for (i = 0; i < Data[3]; i++)
  2742 + {
  2743 + GC6133_SERIAL_TRACE("Read Sensor Reg[%x] = %x", Data[2] + i, CamReadCmosSensor(Data[2] + i));
  2744 + if (!(i % 200))
  2745 + {
  2746 + kal_sleep_task(30);
  2747 + }
  2748 + }
  2749 + }
  2750 + break;
  2751 + case 0x0B:
  2752 + {
  2753 + kal_uint32 i;
  2754 +
  2755 + for (i = 0; i < Data[3]; i++)
  2756 + {
  2757 + GC6133_SERIAL_TRACE("Read BB Reg[%x] = %x", Data[2] + i * 4, DRV_Reg32(Data[2] + i * 4));
  2758 + if (!(i % 200))
  2759 + {
  2760 + kal_sleep_task(30);
  2761 + }
  2762 + }
  2763 + }
  2764 + break;
  2765 + default:
  2766 + break;
  2767 + }
  2768 + return KAL_TRUE;
  2769 +}
  2770 +#endif
  2771 +
  2772 +#endif
  2773 +
... ...
... ... @@ -17,6 +17,10 @@ extern topwell_temp_id;
17 17 extern kal_uint32 HM0155_SERIALDetectSensorId(void);
18 18 extern IMAGE_SENSOR_FUNCTION_STRUCT ImageSensorFuncHM0155_SERIAL;
19 19 #endif
  20 +#if defined(__TOPWELL_SENSOR_GC6133_SERIAL__)
  21 +extern kal_uint32 GC6133_SERIALDetectSensorId(void);
  22 +extern IMAGE_SENSOR_FUNCTION_STRUCT ImageSensorFuncGC6133_SERIAL;
  23 +#endif
20 24 #if defined(__TOPWELL_SENSOR_GC6123_SERIAL__)
21 25 extern kal_uint32 GC6123_SERIALDetectSensorId(void);
22 26 extern IMAGE_SENSOR_FUNCTION_STRUCT ImageSensorFuncGC6123_SERIAL;
... ... @@ -69,6 +73,12 @@ void TOPWELL_SERIALSensorFunc(P_IMAGE_SENSOR_FUNCTION_STRUCT *pfSensorFunc)
69 73 *pfSensorFunc=&ImageSensorFuncBF3A01_SERIAL;
70 74 }else
71 75 #endif
  76 +#if defined(__TOPWELL_SENSOR_GC6133_SERIAL__)
  77 + if(topwell_temp_id==GC6133_SERIAL_SENSOR_ID)
  78 + {
  79 + *pfSensorFunc=&ImageSensorFuncGC6133_SERIAL;
  80 + }else
  81 +#endif
72 82 #if defined(__TOPWELL_SENSOR_GC6123_SERIAL__)
73 83 if(topwell_temp_id==GC6123_SERIAL_SENSOR_ID)
74 84 {
... ... @@ -137,6 +147,12 @@ void Topwell_Search_SensorID(void)
137 147 topwell_temp_id=GC0310_SERIAL_SENSOR_ID;
138 148 }else
139 149 #endif
  150 +#if defined(__TOPWELL_SENSOR_GC6133_SERIAL__)
  151 + if(GC6133_SERIAL_SENSOR_ID==GC6133_SERIALDetectSensorId())
  152 + {
  153 + topwell_temp_id=GC6133_SERIAL_SENSOR_ID;
  154 + }else
  155 +#endif
140 156
141 157 #if defined(__TOPWELL_SENSOR_GC6123_SERIAL__)
142 158 if(GC6123_SERIAL_SENSOR_ID==GC6123_SERIALDetectSensorId())
... ... @@ -202,6 +218,9 @@ void Get_AllCAM_ID_String(U8 *get_buf)
202 218 #if defined(__TOPWELL_SENSOR_HM0155_SERIAL__)
203 219 mmi_ucs2cat((CHAR*) get_buf, (const CHAR*)L"HM0155\n");
204 220 #endif
  221 +#if defined(__TOPWELL_SENSOR_GC6133_SERIAL__)
  222 + mmi_ucs2cat((CHAR*) get_buf, (const CHAR*)L"GC6133\n");
  223 +#endif
205 224 #if defined(__TOPWELL_SENSOR_GC6123_SERIAL__)
206 225 mmi_ucs2cat((CHAR*) get_buf, (const CHAR*)L"GC6123\n");
207 226 #endif
... ... @@ -270,6 +289,10 @@ kal_uint8* Get_CAM_ID_String(kal_uint32 index)
270 289 #if defined(__TOPWELL_SENSOR_HM0155_SERIAL__)
271 290 case HM0155_SERIAL_SENSOR_ID:
272 291 return "HM0155";
  292 + #if defined(__TOPWELL_SENSOR_GC6133_SERIAL__)
  293 + case GC6133_SERIAL_SENSOR_ID:
  294 + return "GC6133";
  295 + #endif
273 296 #endif
274 297 #if defined(__TOPWELL_SENSOR_GC6123_SERIAL__)
275 298 case GC6123_SERIAL_SENSOR_ID:
... ...
  1 +/*****************************************************************************
  2 +* Copyright Statement:
  3 +* --------------------
  4 +* This software is protected by Copyright and the information contained
  5 +* herein is confidential. The software may not be copied and the information
  6 +* contained herein may not be used or disclosed except with the written
  7 +* permission of MediaTek Inc. (C) 2010
  8 +*
  9 +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10 +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11 +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12 +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13 +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14 +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15 +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16 +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17 +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18 +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19 +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20 +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21 +*
  22 +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23 +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24 +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25 +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26 +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27 +*
  28 +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29 +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30 +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31 +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32 +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33 +*
  34 +*****************************************************************************/
  35 +
  36 +/*****************************************************************************
  37 + *
  38 + * Filename:
  39 + * ---------
  40 + * usbvideo_attr_GC6133_SERIAL.c
  41 + *
  42 + * Project:
  43 + * --------
  44 + * Maui_sw
  45 + *
  46 + * Description:
  47 + * ------------
  48 + * Image sensor webcam driver function
  49 + *
  50 + * Author:
  51 + * -------
  52 + * Mormo_hui
  53 + *
  54 + *============================================================================
  55 + * HISTORY
  56 + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  57 + *------------------------------------------------------------------------------
  58 + * $Revision:$1.0.0
  59 + *
  60 + * $Modtime:$2011/08/04
  61 + *
  62 + * $Log:$
  63 + * 2011/08/04 Firstly Released By Mormo.
  64 + *
  65 + * Initial revision.
  66 + *------------------------------------------------------------------------------
  67 + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  68 + *============================================================================
  69 + ****************************************************************************/
  70 +#include "drv_comm.h"
  71 +#include "stdio.h"
  72 +#include "isp_if.h"
  73 +#include "image_sensor.h"
  74 +#include "mm_comm_def.h"
  75 +#include "sensor_comm_def.h"
  76 +#include "usbvideo_custom.h"
  77 +#include "jpeg_enum.h"
  78 +
  79 +#if (defined(WEBCAM_SUPPORT))
  80 +MM_ERROR_CODE_ENUM GC6133_SERIALWebcamFeatureCtrl(kal_uint32 Id, void *In, void *Out, kal_uint32 OutLen, kal_uint32 *RealOutLen)
  81 +{
  82 + /* supported feature list */
  83 + static const USBVideo_Attr_Info GC6133_SERIAL_ATTR_INFO[] =
  84 + {
  85 + {USBVIDEO_ATTRIBUTE_BRIGHTNESS, KAL_TRUE, KAL_TRUE},
  86 + {USBVIDEO_ATTRIBUTE_CONTRAST, KAL_TRUE, KAL_TRUE},
  87 + {USBVIDEO_ATTRIBUTE_HUE, KAL_FALSE, KAL_FALSE},
  88 + {USBVIDEO_ATTRIBUTE_HUE_AUTO, KAL_FALSE, KAL_FALSE},
  89 + {USBVIDEO_ATTRIBUTE_SATURATION, KAL_FALSE, KAL_FALSE},
  90 + {USBVIDEO_ATTRIBUTE_POWER_LINE_FREQUENCY, KAL_TRUE, KAL_TRUE},
  91 + {USBVIDEO_ATTRIBUTE_SHARPNESS, KAL_FALSE, KAL_FALSE},
  92 + {USBVIDEO_ATTRIBUTE_BACKLIGHT_COMPENSATION, KAL_FALSE, KAL_FALSE},
  93 + {USBVIDEO_ATTRIBUTE_GAMMA, KAL_FALSE, KAL_FALSE},
  94 + {USBVIDEO_ATTRIBUTE_WHITE_BALANCE_TMP, KAL_TRUE, KAL_TRUE},
  95 + {USBVIDEO_ATTRIBUTE_WHITE_BALANCE_TMP_AUTO, KAL_TRUE, KAL_TRUE},
  96 + };
  97 + /* supported video size list */
  98 + static const USBVideo_Video_Size_Info GC6133_SERIAL_VIDEO_SIZE[] =
  99 + {
  100 + {USBVIDEO_VIDEO_SIZE_1, 160, 120, 0xC000, 912382, 38012, 500000, 500000, 500000, 0},
  101 + {USBVIDEO_VIDEO_SIZE_2, 320, 240, 0xC000, 912384, 38016, 500000, 500000, 500000, 0},
  102 +#if (defined(__JPEG_HW_SUPPORTED__))
  103 + {USBVIDEO_VIDEO_SIZE_3, 640, 480, 0x18000, 912384, 38016, 500000, 500000, 500000, 0},
  104 +#else
  105 + {USBVIDEO_VIDEO_SIZE_3, 640, 480, 0xC000, 912384, 38016, 500000, 500000, 500000, 0},
  106 +#endif
  107 + };
  108 + /* supported still image size list */
  109 + static const USBVideo_Still_Size_Info GC6133_SERIAL_STILL_SIZE[] =
  110 + {
  111 + {USBVIDEO_STILL_SIZE_1, 160, 120, 0xC000},
  112 + {USBVIDEO_STILL_SIZE_2, 320, 240, 0xC000},
  113 +#if (defined(__JPEG_HW_SUPPORTED__))
  114 + {USBVIDEO_STILL_SIZE_3, 640, 480, 0x18000},
  115 +#else
  116 + {USBVIDEO_STILL_SIZE_3, 640, 480, 0xC000},
  117 +#endif
  118 + };
  119 + /* supported compression type list*/
  120 + static const USBVideo_Compression_Info GC6133_SERIAL_STILL_COMPRESSION[] =
  121 + {
  122 + /* {USBVIDEO_COMPRESSION_1, JPEG_ENCODE_QUALITY_GOOD}, */
  123 + {USBVIDEO_COMPRESSION_1, JPEG_ENCODE_QUALITY_LOW},
  124 + {USBVIDEO_COMPRESSION_2, JPEG_ENCODE_QUALITY_FAIR}
  125 + };
  126 + static const USBVIDEO_VIDEO_SIZE_TYPE GC6133_SERIAL_g_default_video_size = USBVIDEO_VIDEO_SIZE_1;
  127 + static const USBVIDEO_STILL_SIZE_TYPE GC6133_SERIAL_g_default_still_size = USBVIDEO_STILL_SIZE_1;
  128 + static const USBVIDEO_COMPRESSION_TYPE GC6133_SERIAL_g_default_compression = USBVIDEO_COMPRESSION_1;
  129 + static const usbvideo_attr_struct GC6133_SERIALWebcamAttrPara =
  130 + {
  131 + /* min,max,res,def */
  132 + {
  133 + {0, 4, 1, 0 }, /*0 USBVIDEO_ATTRIBUTE_BACKLIGHT_COMPENSATION*/
  134 + {0, 8, 1, 4 }, /*1 USBVIDEO_ATTRIBUTE_BRIGHTNESS*/
  135 + {0, 2, 1, 1 }, /*2 USBVIDEO_ATTRIBUTE_CONTRAST*/
  136 + {0, 255, 1, 127 }, /*3 USBVIDEO_ATTRIBUTE_GAIN*/
  137 + {0, 2, 1, 1 }, /*4 USBVIDEO_ATTRIBUTE_POWER_LINE_FREQUENCY, 0:Disable, 1:50, 2:60*/
  138 + {0, 360, 1 , 0 }, /*5 USBVIDEO_ATTRIBUTE_HUE*/
  139 + {0, 255, 1, 64 }, /*6 USBVIDEO_ATTRIBUTE_SATURATION*/
  140 + {0, 15, 1, 0 }, /*7 USBVIDEO_ATTRIBUTE_SHARPNESS*/
  141 + {100, 220, 60, 160 }, /*8 USBVIDEO_ATTRIBUTE_GAMMA*/
  142 + {2500, 6500, 500, 5500}, /*9 USBVIDEO_ATTRIBUTE_WHITE_BALANCE_TMP*/
  143 + {0, 1, 1, 1 }, /*10 USBVIDEO_ATTRIBUTE_WHITE_BALANCE_TMP_AUTO*/
  144 + {0, 0, 0, 0 }, /*11 USBVIDEO_ATTRIBUTE_WHITE_BALANCE_COMP, NOT SUPPORT*/
  145 + {0, 1, 1, 1 }, /*12 USBVIDEO_ATTRIBUTE_WHITE_BALANCE_COMP_AUTO*/
  146 + {0, 0, 1, 0 }, /*13 USBVIDEO_ATTRIBUTE_DIGITAL_MULTIPLIER, NOT SUPPORT*/
  147 + {0, 0, 1, 0 }, /*14 USBVIDEO_ATTRIBUTE_DIGITAL_MULTIPLIER_LIMIT, NOT SUPPORT*/
  148 + {0, 1, 1, 0 }, /*15 USBVIDEO_ATTRIBUTE_HUE_AUTO*/
  149 + {0, 0, 0, 0 } /*16 USBVIDEO_ATTRIBUTE_MAX_MULTIPLIER, NOT SUPPORT*/
  150 + }
  151 + };
  152 + MM_ERROR_CODE_ENUM ErrCode = MM_ERROR_NONE;
  153 +
  154 + switch(Id)
  155 + {
  156 + case CAL_FEATURE_WEBCAM_GET_ATTR:
  157 + {
  158 + USBVideo_Attr_Value *pWebCamAttr = (USBVideo_Attr_Value *)Out;
  159 + USBVIDEO_ATTRIBUTE_TYPE AttrType = pWebCamAttr->type;
  160 +
  161 + if (AttrType <= USBVIDEO_ATTRIBUTE_CT_MAX)
  162 + {
  163 + pWebCamAttr->value = 0; /* CT currently is not support */
  164 + }
  165 + else
  166 + {
  167 + if (AttrType >= ATTR_PU_START)
  168 + {
  169 + switch(pWebCamAttr->req_type)
  170 + {
  171 + case USBVIDEO_REQUEST_GET_CUR:
  172 + ASSERT(0); /* current value is maintained in ISP driver */
  173 + break;
  174 + case USBVIDEO_REQUEST_GET_MIN:
  175 + pWebCamAttr->value = GC6133_SERIALWebcamAttrPara.attr_info[GET_ATTR_PU_IDX(AttrType)].min;
  176 + break;
  177 + case USBVIDEO_REQUEST_GET_MAX:
  178 + pWebCamAttr->value = GC6133_SERIALWebcamAttrPara.attr_info[GET_ATTR_PU_IDX(AttrType)].max;
  179 + break;
  180 + case USBVIDEO_REQUEST_GET_DEF:
  181 + pWebCamAttr->value = GC6133_SERIALWebcamAttrPara.attr_info[GET_ATTR_PU_IDX(AttrType)].def;
  182 + break;
  183 + case USBVIDEO_REQUEST_GET_RES:
  184 + pWebCamAttr->value = GC6133_SERIALWebcamAttrPara.attr_info[GET_ATTR_PU_IDX(AttrType)].res;
  185 + break;
  186 + default:
  187 + EXT_ASSERT(0, (kal_uint32)pWebCamAttr->req_type, 0, 0);
  188 + break;
  189 + }
  190 + }
  191 + else
  192 + {
  193 + ASSERT(0);
  194 + }
  195 + }
  196 + }
  197 + break;
  198 + case CAL_FEATURE_WEBCAM_SET_ATTR:
  199 + {
  200 + const USBVIDEO_ATTRIBUTE_TYPE AttrType = ((USBVideo_Attr_Value *)In)->type;
  201 + const kal_uint32 AttrValue = ((USBVideo_Attr_Value *)In)->value;
  202 + CAL_FEATURE_CTRL_STRUCT FeatureCtrlPara;
  203 + P_IMAGE_SENSOR_FUNCTION_STRUCT pfSensorFunc;
  204 +
  205 + /* Sensor Attributes Set */
  206 + /* update attr PU current value */
  207 + /* usbvideo_attr_PU_value_list[GET_ATTR_PU_IDX(AttrType)] = AttrValue; */
  208 + GC6133_SERIALSensorFunc(&pfSensorFunc);
  209 + FeatureCtrlPara.FeatureCtrlCode = CAL_FEATURE_SET_OPERATION;
  210 + switch(AttrType)
  211 + {
  212 + case USBVIDEO_ATTRIBUTE_POWER_LINE_FREQUENCY:
  213 + FeatureCtrlPara.FeatureSetValue = (1 == AttrValue ? CAM_BANDING_50HZ : CAM_BANDING_60HZ);
  214 + ErrCode = pfSensorFunc->SensorFeatureCtrl(CAL_FEATURE_CAMERA_BANDING_FREQ, &FeatureCtrlPara, NULL, 0, NULL);
  215 + break;
  216 + case USBVIDEO_ATTRIBUTE_BRIGHTNESS:
  217 + FeatureCtrlPara.FeatureSetValue = AttrValue;
  218 + ErrCode = pfSensorFunc->SensorFeatureCtrl(CAL_FEATURE_CAMERA_EV_VALUE, &FeatureCtrlPara, NULL, 0, NULL);
  219 + break;
  220 + case USBVIDEO_ATTRIBUTE_CONTRAST:
  221 + FeatureCtrlPara.FeatureSetValue = AttrValue;
  222 + ErrCode = pfSensorFunc->SensorFeatureCtrl(CAL_FEATURE_CAMERA_CONTRAST, &FeatureCtrlPara, NULL, 0, NULL);
  223 + break;
  224 + case USBVIDEO_ATTRIBUTE_WHITE_BALANCE_TMP_AUTO:
  225 + if (AttrValue > 0) /* auto */
  226 + {
  227 + FeatureCtrlPara.FeatureSetValue = CAM_WB_AUTO;
  228 + ErrCode = pfSensorFunc->SensorFeatureCtrl(CAL_FEATURE_CAMERA_WB, &FeatureCtrlPara, NULL, 0, NULL);
  229 + }
  230 + else
  231 + {
  232 + /* Bin: dothing, because will set by USBVIDEO_ATTRIBUTE_WHITE_BALANCE_TMP */
  233 + }
  234 + break;
  235 + case USBVIDEO_ATTRIBUTE_WHITE_BALANCE_TMP:
  236 + if (AttrValue > 5800)
  237 + {
  238 + FeatureCtrlPara.FeatureSetValue = CAM_WB_DAYLIGHT;
  239 + }
  240 + else if (AttrValue >= 4800)
  241 + {
  242 + FeatureCtrlPara.FeatureSetValue = CAM_WB_INCANDESCENCE;
  243 + }
  244 + else if (AttrValue >= 3800)
  245 + {
  246 + FeatureCtrlPara.FeatureSetValue = CAM_WB_FLUORESCENT;
  247 + }
  248 + else /* if (AttrValue >= 2800) */
  249 + {
  250 + FeatureCtrlPara.FeatureSetValue = CAM_WB_TUNGSTEN;
  251 + }
  252 + ErrCode = pfSensorFunc->SensorFeatureCtrl(CAL_FEATURE_CAMERA_WB, &FeatureCtrlPara, NULL, 0, NULL);
  253 + break;
  254 + default:
  255 + break;
  256 + }
  257 + }
  258 + break;
  259 + case CAL_FEATURE_WEBCAM_GET_ATTR_INFO:
  260 + ((P_CAL_FEATURE_WEBCAM_GET_ATTR_INFO_STRUCT)Out)->pWebCamAttrInfo = GC6133_SERIAL_ATTR_INFO;
  261 + ((P_CAL_FEATURE_WEBCAM_GET_ATTR_INFO_STRUCT)Out)->WebCamAttrInfoNum = sizeof(GC6133_SERIAL_ATTR_INFO) / sizeof(GC6133_SERIAL_ATTR_INFO[0]);
  262 + break;
  263 + case CAL_FEATURE_WEBCAM_GET_VIDEO_SIZE:
  264 + ((P_CAL_FEATURE_WEBCAM_GET_VIDEO_SIZE_STRUCT)Out)->pWebCamVideoSizeInfo = GC6133_SERIAL_VIDEO_SIZE;
  265 + ((P_CAL_FEATURE_WEBCAM_GET_VIDEO_SIZE_STRUCT)Out)->WebCamVideoSizeInfoNum = sizeof(GC6133_SERIAL_VIDEO_SIZE) / sizeof(GC6133_SERIAL_VIDEO_SIZE[0]);
  266 + break;
  267 + case CAL_FEATURE_WEBCAM_GET_STILL_SIZE:
  268 + ((P_CAL_FEATURE_WEBCAM_GET_STILL_SIZE_STRUCT)Out)->pWebCamStillSizeInfo = GC6133_SERIAL_STILL_SIZE;
  269 + ((P_CAL_FEATURE_WEBCAM_GET_STILL_SIZE_STRUCT)Out)->WebCamStillSizeInfoNum = sizeof(GC6133_SERIAL_STILL_SIZE) / sizeof(GC6133_SERIAL_STILL_SIZE[0]);
  270 + break;
  271 + case CAL_FEATURE_WEBCAM_GET_COMPRESSION:
  272 + ((P_CAL_FEATURE_WEBCAM_GET_COMPRESSION_STRUCT)Out)->pWebCamCompressionInfo = GC6133_SERIAL_STILL_COMPRESSION;
  273 + ((P_CAL_FEATURE_WEBCAM_GET_COMPRESSION_STRUCT)Out)->WebCamCompressionInfoNum = sizeof(GC6133_SERIAL_STILL_COMPRESSION) / sizeof(GC6133_SERIAL_STILL_COMPRESSION[0]);
  274 + break;
  275 + case CAL_FEATURE_WEBCAM_GET_DEFAULT_IDX:
  276 + ((P_CAL_FEATURE_WEBCAM_GET_DEFAULT_IDX_STRUCT)Out)->WebCamVideoSizeIdx = GC6133_SERIAL_g_default_video_size;
  277 + ((P_CAL_FEATURE_WEBCAM_GET_DEFAULT_IDX_STRUCT)Out)->WebCamStillSizeIdx = GC6133_SERIAL_g_default_still_size;
  278 + ((P_CAL_FEATURE_WEBCAM_GET_DEFAULT_IDX_STRUCT)Out)->WebCamCompressionIdx = GC6133_SERIAL_g_default_compression;
  279 + break;
  280 + default:
  281 + ErrCode = MM_ERROR_INVALID_PARAMETER;
  282 + break;
  283 + }
  284 + return ErrCode;
  285 +}
  286 +
  287 +#else
  288 +MM_ERROR_CODE_ENUM GC6133_SERIALWebcamFeatureCtrl(kal_uint32 Id, void *In, void *Out, kal_uint32 OutLen, kal_uint32 *RealOutLen)
  289 +{
  290 + return MM_ERROR_NONE;
  291 +}
  292 +#endif
  293 +
... ...
... ... @@ -1075,6 +1075,9 @@ IMAGE_SENSOR_LIST_STRUCT SensorList[MAX_SENSOR_SUPPORT_NUMBER + 1] =
1075 1075 #if defined(__TOPWELL_SENSOR_SP0829_SERIAL__)
1076 1076 ADD_SENSOR(SP0829_SERIAL_SENSOR_ID,SP0829_SERIAL,IMAGE_SENSOR_MAIN),
1077 1077 #endif
  1078 +#if defined(__TOPWELL_SENSOR_GC6133_SERIAL__)
  1079 + ADD_SENSOR(GC6133_SERIAL_SENSOR_ID,GC6133_SERIAL,IMAGE_SENSOR_MAIN),
  1080 +#endif
1078 1081 ADD_SENSOR(GC6123_SERIAL_SENSOR_ID,GC6123_SERIAL,IMAGE_SENSOR_MAIN),
1079 1082 #endif
1080 1083 #if(defined(GC6123_SERIAL_YUV_SUB))
... ...
... ... @@ -370,6 +370,9 @@
370 370 #if defined(__TOPWELL_SENSOR_SP0829_SERIAL__)
371 371 #include "image_sensor_SP0829_SERIAL.h"
372 372 #endif
  373 +#if defined(__TOPWELL_SENSOR_GC6133_SERIAL__)
  374 +#include "image_sensor_GC6133_SERIAL.h"
  375 +#endif
373 376 #include "image_sensor_GC6123_SERIAL.h"
374 377 #endif
375 378 #if (defined(GC0311_YUV))
... ... @@ -501,6 +504,7 @@
501 504 #define PAS6180_SERIAL_SENSOR_ID 0x6179
502 505 #define HIQD1_SERIAL_SENSOR_ID 0x00B2
503 506 #define SP0838_SENSOR_ID 0x0027
  507 +#define GC6133_SERIAL_SENSOR_ID 0x00BA
504 508 #define GC6123_SERIAL_SENSOR_ID 0x00B9
505 509 #define GC0310_SERIAL_SENSOR_ID 0xA310
506 510
... ...
... ... @@ -249,6 +249,9 @@ endif
249 249 ifneq ($(filter HM0155_SERIAL, $(TOPWELL_HW_SENSOR)),)
250 250 COM_DEFS += __TOPWELL_SENSOR_HM0155_SERIAL__
251 251 endif
  252 + ifneq ($(filter GC6133_SERIAL, $(TOPWELL_HW_SENSOR)),)
  253 + COM_DEFS += __TOPWELL_SENSOR_GC6133_SERIAL__
  254 + endif
252 255 ifneq ($(filter GC6123_SERIAL, $(TOPWELL_HW_SENSOR)),)
253 256 COM_DEFS += __TOPWELL_SENSOR_GC6123_SERIAL__
254 257 endif
... ...
Please register or login to post a comment