/*
-o* Driver for MT9M001 CMOS Image Sensor from Micron
+ * Driver for OV5642 CMOS Image Sensor from OmniVision
*
* Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
*
#include <media/v4l2-chip-ident.h>
#include <media/soc_camera.h>
#include <mach/rk29_camera.h>
+#include "ov5642.h"
#define _CONS(a,b) a##b
#define CONS(a,b) _CONS(a,b)
#define CONFIG_SENSOR_Effect 1
#define CONFIG_SENSOR_Scene 1
#define CONFIG_SENSOR_DigitalZoom 0
-#define CONFIG_SENSOR_Focus 1
-#if CONFIG_SENSOR_Focus
-#define CONFIG_SENSOR_AutoFocus 0
-#else
-#undef CONFIG_SENSOR_AutoFocus
-#endif
#define CONFIG_SENSOR_Exposure 0
#define CONFIG_SENSOR_Flash 0
#define CONFIG_SENSOR_Mirror 0
#define CONFIG_SENSOR_Flip 0
+#ifdef CONFIG_OV5642_AUTOFOCUS
+#define CONFIG_SENSOR_Focus 1
+#include "ov5642_af_firmware.c"
+#else
+#define CONFIG_SENSOR_Focus 0
+#endif
#define CONFIG_SENSOR_I2C_SPEED 300000 /* Hz */
#define SENSOR_AF_IS_ERR (0x00<<0)
#define SENSOR_AF_IS_OK (0x01<<0)
-#if (CONFIG_SENSOR_Focus == 1)
+#if CONFIG_SENSOR_Focus
/* ov5642 VCM Command and Status Registers */
#define CMD_MAIN_Reg 0x3024
#define CMD_TAG_Reg 0x3025
#define SingleFocus_Cmd 0x03
#define ConstFocus_Cmd 0x04
#define StepMode_Cmd 0x05
+#define PauseFocus_Cmd 0x06
#define ReturnIdle_Cmd 0x08
#define SetZone_Cmd 0x10
#define UpdateZone_Cmd 0x12
#define StepFocus_Spec_Tag 0x10
#endif
-struct reginfo
-{
- u16 reg;
- u8 val;
-};
-
/* init 640X480 SVGA */
static struct reginfo sensor_init_data[] =
{
{0x370b , 0x40},
{0x370d , 0x02},
{0x3620 , 0x52},
+
{0X0000, 0X00}
};
/* 2592X1944 QSXGA */
static struct reginfo sensor_qsxga[] =
{
- {0x3000 ,0x00}, //F8
- {0x3001 ,0x00}, //48
- {0x3002 ,0x00}, //5C
- {0x3003 ,0x00}, //02
- {0x3005 ,0xff}, //b7
- {0x3006 ,0xff}, //43
- {0x3007 ,0x3f}, //37
- {0x350c ,0x07}, //08
- {0x350d ,0xd0}, //30
- {0x3602 ,0xe4}, //FC ?
- {0x3612 ,0xac}, //FF ?
- {0x3613 ,0x44}, //00 ?
- {0x3621 ,0x27}, //C7
- {0x3622 ,0x08}, //00 ?
- {0x3623 ,0x22}, //01 ?
- {0x3604 ,0x60}, //40 ?
- {0x3705 ,0xda}, //DB ?
- {0x370a ,0x80}, //81 ?
- {0x3801 ,0x8a}, //50
- {0x3803 ,0x0a}, //08
- {0x3804 ,0x0a}, //05
- {0x3805 ,0x20}, //00
- {0x3806 ,0x07}, //03
- {0x3807 ,0x98}, //C0
- {0x3808 ,0x0a}, //02
- {0x3809 ,0x20}, //80
- {0x380a ,0x07}, //01
- {0x380b ,0x98}, //E0
- {0x380c ,0x0c},
- {0x380d ,0x80},
- {0x380e ,0x07}, //03
- {0x380f ,0xd0}, //E8
- {0x3810 ,0xc2}, //C0
- {0x3815 ,0x44}, //04
- {0x3818 ,0xc0}, //0xc8}, //C1
- {0x3824 ,0x01}, //11
- {0x3827 ,0x0a}, //08
- {0x3a00 ,0x78}, //7C night mode close
- {0x3a0d ,0x10}, //08
- {0x3a0e ,0x0d}, //06
- {0x3a10 ,0x32}, //72
- {0x3a1b ,0x3c}, //80
- {0x3a1e ,0x32}, //70
- {0x3a11 ,0x80}, //D0
- {0x3a1f ,0x20}, //40
- {0x3a00 ,0x78}, //7C night mode close
- {0x460b ,0x35}, //37
- {0x471d ,0x00}, //05
- {0x4713 ,0x03}, //02
- {0x471c ,0x50}, //D0
- {0x5682 ,0x0a}, //05
- {0x5683 ,0x20}, //00
- {0x5686 ,0x07}, //03
- {0x5687 ,0x98}, //C0
- {0x5001 ,0x4f}, //FF
- {0x589b ,0x00}, //04
- {0x589a ,0xc0}, //C5
- {0x4407 ,0x04}, //0C
- {0x589b ,0x00}, //04
- {0x589a ,0xc0}, //C5
- {0x3002 ,0x0c}, //5C
- {0x3002 ,0x00}, //5C
- {0x3012, 0x02},
-
- {0x460c ,0x00}, //jpeg mode change to YUV mode
- {0x460b ,0x37},
- {0x471c ,0xd0},
- {0x471d ,0x05},
- {0x3815 ,0x01},
- {0x3818 ,0xc0},
- {0x501f ,0x00},
- {0x4300 ,0x32},
- {0x3002 ,0x1c},
- {0x0000 ,0x00}
+ {0x0000 ,0x00}
};
/* 2048*1536 QXGA */
static struct reginfo sensor_qxga[] =
{
- {0x3012, 0x02},
- {0x3800 ,0x1 },
- {0x3801 ,0x8A},
- {0x3802 ,0x0 },
- {0x3803 ,0xA },
- {0x3804 ,0xA },
- {0x3805 ,0x20},
- {0x3806 ,0x7 },
- {0x3807 ,0x98},
- {0x3808 ,0x8 },
- {0x3809 ,0x0 },
- {0x380a ,0x6 },
- {0x380b ,0x0 },
- {0x380c ,0xc },
- {0x380d ,0x80},
- {0x380e ,0x7 },
- {0x380f ,0xd0},
- {0x5001 ,0x7f},
- {0x5680 ,0x0 },
- {0x5681 ,0x0 },
- {0x5682 ,0xA },
- {0x5683 ,0x20},
- {0x5684 ,0x0 },
- {0x5685 ,0x0 },
- {0x5686 ,0x7 },
- {0x5687 ,0x98},
{0x0000 ,0x00}
};
/* 1600X1200 UXGA */
static struct reginfo sensor_uxga[] =
{
- {0x3012, 0x02},
- {0x3800 ,0x1 },
- {0x3801 ,0x8A},
- {0x3802 ,0x0 },
- {0x3803 ,0xA },
- {0x3804 ,0xA },
- {0x3805 ,0x20},
- {0x3806 ,0x7 },
- {0x3807 ,0x98},
- {0x3808 ,0x6 },
- {0x3809 ,0x40},
- {0x380a ,0x4 },
- {0x380b ,0xb0},
- {0x380c ,0xc },
- {0x380d ,0x80},
- {0x380e ,0x7 },
- {0x380f ,0xd0},
- {0x5001 ,0x7f},
- {0x5680 ,0x0 },
- {0x5681 ,0x0 },
- {0x5682 ,0xA },
- {0x5683 ,0x20},
- {0x5684 ,0x0 },
- {0x5685 ,0x0 },
- {0x5686 ,0x7 },
- {0x5687 ,0x98},
{0x0000 ,0x00}
};
/* 1280X1024 SXGA */
static struct reginfo sensor_sxga[] =
{
- {0x300E, 0x34},
- {0x3011, 0x01},
- {0x3012, 0x00},
- {0x302a, 0x05},
- {0x302b, 0xCB},
- {0x306f, 0x54},
- {0x3362, 0x80},
-
- {0x3070, 0x5d},
- {0x3072, 0x5d},
- {0x301c, 0x0f},
- {0x301d, 0x0f},
-
- {0x3020, 0x01},
- {0x3021, 0x18},
- {0x3022, 0x00},
- {0x3023, 0x0A},
- {0x3024, 0x06},
- {0x3025, 0x58},
- {0x3026, 0x04},
- {0x3027, 0xbc},
- {0x3088, 0x05},
- {0x3089, 0x00},
- {0x308A, 0x04},
- {0x308B, 0x00},
- {0x3316, 0x64},
- {0x3317, 0x4B},
- {0x3318, 0x00},
- {0x3319, 0x6C},
- {0x331A, 0x50},
- {0x331B, 0x40},
- {0x331C, 0x00},
- {0x331D, 0x6C},
- {0x3302, 0x11},
{0x0000,0x00}
};
/* 800X600 SVGA*/
static struct reginfo sensor_svga[] =
{
- {0x300E, 0x34},
- {0x3011, 0x01},
- {0x3012, 0x10},
- {0x302a, 0x02},
- {0x302b, 0xE6},
- {0x306f, 0x14},
- {0x3362, 0x90},
-
- {0x3070, 0x5d},
- {0x3072, 0x5d},
- {0x301c, 0x07},
- {0x301d, 0x07},
-
- {0x3020, 0x01},
- {0x3021, 0x18},
- {0x3022, 0x00},
- {0x3023, 0x06},
- {0x3024, 0x06},
- {0x3025, 0x58},
- {0x3026, 0x02},
- {0x3027, 0x5E},
- {0x3088, 0x03},
- {0x3089, 0x20},
- {0x308A, 0x02},
- {0x308B, 0x58},
- {0x3316, 0x64},
- {0x3317, 0x25},
- {0x3318, 0x80},
- {0x3319, 0x08},
- {0x331A, 0x64},
- {0x331B, 0x4B},
- {0x331C, 0x00},
- {0x331D, 0x38},
- {0x3302, 0x11},
+ {0x3800 ,0x1 },
+ {0x3801 ,0x50},
+ {0x3802 ,0x0 },
+ {0x3803 ,0x8 },
+ {0x3804 ,0x5 },
+ {0x3805 ,0x0 },
+ {0x3806 ,0x3 },
+ {0x3807 ,0xc0},
+ {0x3808 ,0x3 },
+ {0x3809 ,0x20},
+ {0x380a ,0x2 },
+ {0x380b ,0x58},
+ {0x380c ,0xc },
+ {0x380d ,0x80},
+ {0x380e ,0x3 },
+ {0x380f ,0xe8},
+ {0x5001 ,0x7f},
+ {0x5680 ,0x0 },
+ {0x5681 ,0x0 },
+ {0x5682 ,0x5 },
+ {0x5683 ,0x0 },
+ {0x5684 ,0x0 },
+ {0x5685 ,0x0 },
+ {0x5686 ,0x3 },
+ {0x5687 ,0xc0},
+ {0x5687 ,0xc0},
+ {0x3815 ,0x02},
{0x0000,0x00}
};
/* 640X480 VGA */
static struct reginfo sensor_vga[] =
{
-
- {0x3012, 0x00},
- {0x3800 ,0x1 },
- {0x3801 ,0x8A},
- {0x3802 ,0x0 },
- {0x3803 ,0xA },
- {0x3804 ,0xA },
- {0x3805 ,0x20},
- {0x3806 ,0x7 },
- {0x3807 ,0x98},
- {0x3808 ,0x2 },
- {0x3809 ,0x80},
- {0x380a ,0x1 },
- {0x380b ,0xe0},
- {0x380c ,0xc },
- {0x380d ,0x80},
- {0x380e ,0x7 },
- {0x380f ,0xd0},
- {0x5001 ,0x7f},
- {0x5680 ,0x0 },
- {0x5681 ,0x0 },
- {0x5682 ,0xA },
- {0x5683 ,0x20},
- {0x5684 ,0x0 },
- {0x5685 ,0x0 },
- {0x5686 ,0x7 },
- {0x5687 ,0x98},
{0x0000,0x00}
};
/* 352X288 CIF */
static struct reginfo sensor_cif[] =
{
- {0x3800 ,0x1 },
- {0x3801 ,0x50},
- {0x3802 ,0x0 },
- {0x3803 ,0x8 },
- {0x3804 ,0x4 },
- {0x3805 ,0x96},
- {0x3806 ,0x3 },
- {0x3807 ,0xc0},
- {0x3808 ,0x1 },
- {0x3809 ,0x60},
- {0x380a ,0x1 },
- {0x380b ,0x20},
- {0x380c ,0xc },
- {0x380d ,0x80},
- {0x380e ,0x3 },
- {0x380f ,0xe8},
- {0x5001 ,0x7f},
- {0x5680 ,0x0 },
- {0x5681 ,0x0 },
- {0x5682 ,0x4 },
- {0x5683 ,0x96},
- {0x5684 ,0x0 },
- {0x5685 ,0x0 },
- {0x5686 ,0x3 },
- {0x5687 ,0xc0},
+ {0x3800 ,0x1 },
+ {0x3801 ,0x50},
+ {0x3802 ,0x0 },
+ {0x3803 ,0x8 },
+ {0x3804 ,0x4 },
+ {0x3805 ,0x96},
+ {0x3806 ,0x3 },
+ {0x3807 ,0xc0},
+ {0x3808 ,0x1 },
+ {0x3809 ,0x60},
+ {0x380a ,0x1 },
+ {0x380b ,0x20},
+ {0x380c ,0xc },
+ {0x380d ,0x80},
+ {0x380e ,0x3 },
+ {0x380f ,0xe8},
+ {0x5001 ,0x7f},
+ {0x5680 ,0x0 },
+ {0x5681 ,0x0 },
+ {0x5682 ,0x4 },
+ {0x5683 ,0x96},
+ {0x5684 ,0x0 },
+ {0x5685 ,0x0 },
+ {0x5686 ,0x3 },
+ {0x5687 ,0xc0},
{0x0000,0x00}
};
/* 320*240 QVGA */
static struct reginfo sensor_qvga[] =
- {
-
- {0x300E, 0x34},
- {0x3011, 0x01},
- {0x3012, 0x10},
- {0x302a, 0x02},
- {0x302b, 0xE6},
- {0x306f, 0x14},
- {0x3362, 0x90},
-
- {0x3070, 0x5D},
- {0x3072, 0x5D},
- {0x301c, 0x07},
- {0x301d, 0x07},
-
- {0x3020, 0x01},
- {0x3021, 0x18},
- {0x3022, 0x00},
- {0x3023, 0x06},
- {0x3024, 0x06},
- {0x3025, 0x58},
- {0x3026, 0x02},
- {0x3027, 0x61},
- {0x3088, 0x01},
- {0x3089, 0x40},
- {0x308A, 0x00},
- {0x308B, 0xf0},
- {0x3316, 0x64},
- {0x3317, 0x25},
- {0x3318, 0x80},
- {0x3319, 0x08},
- {0x331A, 0x14},
- {0x331B, 0x0f},
- {0x331C, 0x00},
- {0x331D, 0x38},
- {0x3302, 0x11},
+{
{0x0000,0x00}
};
/* 176X144 QCIF*/
static struct reginfo sensor_qcif[] =
{
- {0x300E, 0x34},
- {0x3011, 0x01},
- {0x3012, 0x10},
- {0x302a, 0x02},
- {0x302b, 0xE6},
- {0x306f, 0x14},
- {0x3362, 0x90},
-
- {0x3070, 0x5d},
- {0x3072, 0x5d},
- {0x301c, 0x07},
- {0x301d, 0x07},
-
- {0x3020, 0x01},
- {0x3021, 0x18},
- {0x3022, 0x00},
- {0x3023, 0x06},
- {0x3024, 0x06},
- {0x3025, 0x58},
- {0x3026, 0x02},
- {0x3027, 0x61},
- {0x3088, 0x00},
- {0x3089, 0xa0},
- {0x308a, 0x00},
- {0x308b, 0x78},
- {0x3316, 0x64},
- {0x3317, 0x25},
- {0x3318, 0x80},
- {0x3319, 0x08},
- {0x331a, 0x0a},
- {0x331b, 0x07},
- {0x331c, 0x80},
- {0x331d, 0x38},
- {0x3100, 0x00},
- {0x3302, 0x11},
- {0x0000,0x00}
-};
-
-static struct reginfo sensor_af_firmware[] =
-{
+ {0x3800 ,0x1 },
+ {0x3801 ,0x50},
+ {0x3802 ,0x0 },
+ {0x3803 ,0x8 },
+ {0x3804 ,0x4 },
+ {0x3805 ,0x96},
+ {0x3806 ,0x3 },
+ {0x3807 ,0xc0},
+ {0x3808 ,0x0 },
+ {0x3809 ,0xb0},
+ {0x380a ,0x0 },
+ {0x380b ,0x90},
+ {0x380c ,0xc },
+ {0x380d ,0x80},
+ {0x380e ,0x3 },
+ {0x380f ,0xe8},
+ {0x5001 ,0x7f},
+ {0x5680 ,0x0 },
+ {0x5681 ,0x0 },
+ {0x5682 ,0x4 },
+ {0x5683 ,0x96},
+ {0x5684 ,0x0 },
+ {0x5685 ,0x0 },
+ {0x5686 ,0x3 },
+ {0x5687 ,0xc0},
{0x0000,0x00}
};
#if 0
},
#endif
- #if CONFIG_SENSOR_Focus
+ #ifdef CONFIG_SENSOR_Focus
{
.id = V4L2_CID_FOCUS_RELATIVE,
.type = V4L2_CTRL_TYPE_INTEGER,
.step = 1,
.default_value = 125,
},
- #if CONFIG_SENSOR_AutoFocus
{
.id = V4L2_CID_FOCUS_AUTO,
.type = V4L2_CTRL_TYPE_BOOLEAN,
.step = 1,
.default_value = 0,
},
- #endif
#endif
#if CONFIG_SENSOR_Flash
if (cmdinfo) {
if (cmdinfo->validate_bit & 0x80) {
if (sensor_write(client, CMD_TAG_Reg, cmdinfo->cmd_tag)) {
- SENSOR_TR("%s write CMD_TAG_Reg(cmd:0x%x) error!\n",SENSOR_NAME_STRING(),cmd_main);
+ SENSOR_TR("%s write CMD_TAG_Reg(main:0x%x tag:0x%x) error!\n",SENSOR_NAME_STRING(),cmd_main,cmdinfo->cmd_tag);
goto sensor_af_cmdset_err;
}
+ SENSOR_DG("%s write CMD_TAG_Reg(main:0x%x tag:0x%x) success!\n",SENSOR_NAME_STRING(),cmd_main,cmdinfo->cmd_tag);
}
for (i=0; i<4; i++) {
if (cmdinfo->validate_bit & (1<<i)) {
if (sensor_write(client, CMD_PARA0_Reg-i, cmdinfo->cmd_para[i])) {
- SENSOR_TR("%s write CMD_PARA_Reg(0x%x, cmd:0x%x) error!\n",SENSOR_NAME_STRING(),i,cmd_main);
+ SENSOR_TR("%s write CMD_PARA_Reg(main:0x%x para%d:0x%x) error!\n",SENSOR_NAME_STRING(),cmd_main,i,cmdinfo->cmd_para[i]);
goto sensor_af_cmdset_err;
}
+ SENSOR_TR("%s write CMD_PARA_Reg(main:0x%x para%d:0x%x) success!\n",SENSOR_NAME_STRING(),cmd_main,i,cmdinfo->cmd_para[i]);
}
}
+ } else {
+ if (sensor_write(client, CMD_TAG_Reg, 0xff)) {
+ SENSOR_TR("%s write CMD_TAG_Reg(main:0x%x no tag) error!\n",SENSOR_NAME_STRING(),cmd_main);
+ goto sensor_af_cmdset_err;
+ }
+ SENSOR_DG("%s write CMD_TAG_Reg(main:0x%x no tag) success!\n",SENSOR_NAME_STRING(),cmd_main);
}
if (sensor_write(client, CMD_MAIN_Reg, cmd_main)) {
- SENSOR_TR("%s write CMD_MAIN_Reg(cmd:0x%x) error!\n",SENSOR_NAME_STRING(),cmd_main);
+ SENSOR_TR("%s write CMD_MAIN_Reg(main:0x%x) error!\n",SENSOR_NAME_STRING(),cmd_main);
goto sensor_af_cmdset_err;
}
-
+ SENSOR_DG("%s write CMD_MAIN_Reg(main:0x%x) success!\n",SENSOR_NAME_STRING(),cmd_main);
return 0;
sensor_af_cmdset_err:
return -1;
static int sensor_af_single(struct i2c_client *client)
{
int ret = 0;
- struct sensor *sensor = to_sensor(client);
char state,cnt;
- if ((sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) == 0)
- return -EACCES;
-
if (sensor_af_cmdset(client, SingleFocus_Cmd, NULL)) {
SENSOR_TR("%s single focus mode set error!\n",SENSOR_NAME_STRING());
ret = -1;
sensor_af_single_end:
return ret;
}
-static int sensor_af_zoneupdate(struct i2c_client *client)
+
+static int sensor_af_const(struct i2c_client *client)
{
int ret = 0;
- struct sensor *sensor = to_sensor(client);
- if ((sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) == 0)
- return -EACCES;
+ if (sensor_af_cmdset(client, ConstFocus_Cmd, NULL)) {
+ SENSOR_TR("%s const focus mode set error!\n",SENSOR_NAME_STRING());
+ ret = -1;
+ goto sensor_af_const_end;
+ }
+sensor_af_const_end:
+ return ret;
+}
+static int sensor_af_pause2capture(struct i2c_client *client)
+{
+ int ret = 0;
+ char state,cnt;
+
+ if (sensor_af_cmdset(client, PauseFocus_Cmd, NULL)) {
+ SENSOR_TR("%s pause focus mode set error!\n",SENSOR_NAME_STRING());
+ ret = -1;
+ goto sensor_af_pause_end;
+ }
+
+ cnt = 0;
+ do
+ {
+ if (cnt != 0) {
+ msleep(1);
+ }
+ cnt++;
+ ret = sensor_read(client, STA_FOCUS_Reg, &state);
+ if (ret != 0){
+ SENSOR_TR("%s[%d] read focus_status failed\n",SENSOR_NAME_STRING(),__LINE__);
+ ret = -1;
+ goto sensor_af_pause_end;
+ }
+ }while((state != S_CAPTURE) && (cnt<100));
+
+ if (state != S_CAPTURE) {
+ SENSOR_TR("%s[%d] focus state(0x%x) is error!\n",SENSOR_NAME_STRING(),__LINE__,state);
+ ret = -1;
+ goto sensor_af_pause_end;
+ }
+sensor_af_pause_end:
+ return ret;
+}
+static int sensor_af_zoneupdate(struct i2c_client *client)
+{
+ int ret = 0;
if (sensor_af_cmdset(client, UpdateZone_Cmd, NULL)) {
SENSOR_TR("%s update zone fail!\n",SENSOR_NAME_STRING());
}
sensor_af_init_end:
+ SENSOR_DG("%s %s ret:0x%x \n",SENSOR_NAME_STRING(),__FUNCTION__,ret);
return ret;
}
#endif
int ret = 0;
qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
- if (qctrl_info)
+ if (!qctrl_info)
return -EINVAL;
if (sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) {
cmdinfo.cmd_para[0] = value;
cmdinfo.validate_bit = 0x81;
ret = sensor_af_cmdset(client, StepMode_Cmd, &cmdinfo);
- SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+ SENSOR_DG("%s..%s : %d ret:0x%x\n",SENSOR_NAME_STRING(),__FUNCTION__, value,ret);
} else {
ret = -EINVAL;
SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
int ret = 0;
qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_RELATIVE);
- if (qctrl_info)
+ if (!qctrl_info)
return -EINVAL;
if (sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) {
}
cmdinfo.validate_bit = 0x80;
ret = sensor_af_cmdset(client, StepMode_Cmd, &cmdinfo);
- SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
+ SENSOR_DG("%s..%s : %d ret:0x%x\n",SENSOR_NAME_STRING(),__FUNCTION__, value,ret);
} else {
ret = -EINVAL;
SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return ret;
}
-#if CONFIG_SENSOR_AutoFocus
+
static int sensor_set_focus_auto(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
struct sensor *sensor = to_sensor(client);
const struct v4l2_queryctrl *qctrl_info;
- struct af_cmdinfo cmdinfo;
int ret = 0;
qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_AUTO);
- if (qctrl_info)
+ if (!qctrl_info)
return -EINVAL;
if (sensor->info_priv.funmodule_state & SENSOR_AF_IS_OK) {
-
+ ret = sensor_af_const(client);
+ SENSOR_DG("%s..%s : %d ret:0x%x\n",SENSOR_NAME_STRING(),__FUNCTION__, value,ret);
} else {
ret = -EACCES;
SENSOR_TR("\n %s..%s AF module state is error!\n",SENSOR_NAME_STRING(),__FUNCTION__);
return ret;
}
-#endif
-
#endif
static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
if (!qctrl)
{
- SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
+ SENSOR_TR("\n %s ioctrl id = 0x%x is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
return -EINVAL;
}
if (!qctrl)
{
- SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
+ SENSOR_TR("\n %s ioctrl id = 0x%x is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
return -EINVAL;
}
if (!qctrl)
{
- SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
+ SENSOR_TR("\n %s ioctrl id = 0x%x is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
return -EINVAL;
}
if (!qctrl)
{
- SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
+ SENSOR_TR("\n %s ioctrl id = 0x%x is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
return -EINVAL;
}
if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
return -EINVAL;
- if (ext_ctrl->value != sensor->info_priv.focus) {
- sensor_set_focus_absolute(icd, qctrl,ext_ctrl->value);
- //val_offset = ext_ctrl->value -sensor->info_priv.focus;
- //sensor->info_priv.focus += val_offset;
- }
+ sensor_set_focus_absolute(icd, qctrl,ext_ctrl->value);
break;
}
case V4L2_CID_FOCUS_RELATIVE:
{
- if (ext_ctrl->value) {
- sensor_set_focus_relative(icd, qctrl,ext_ctrl->value);
- //sensor->info_priv.focus += ext_ctrl->value;
- //SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);
- }
+ if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
+ return -EINVAL;
+
+ sensor_set_focus_relative(icd, qctrl,ext_ctrl->value);
break;
}
+ case V4L2_CID_FOCUS_AUTO:
+ {
+ if (ext_ctrl->value != sensor->info_priv.auto_focus) {
+ if (sensor_set_focus_auto(icd, qctrl,ext_ctrl->value) != 0)
+ return -EINVAL;
+ sensor->info_priv.auto_focus = ext_ctrl->value;
+ }
+ break;
+ }
#endif
#if CONFIG_SENSOR_Flash
case V4L2_CID_FLASH:
struct soc_camera_device *icd = client->dev.platform_data;
int i, error_cnt=0, error_idx=-1;
-
for (i=0; i<ext_ctrl->count; i++) {
if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
error_cnt++;