#include <media/v4l2-common.h>
#include <media/v4l2-chip-ident.h>
#include <media/soc_camera.h>
-#include <mach/rk29_camera.h>
+#include <plat/rk_camera.h>
static int debug;
module_param(debug, int, S_IRUGO|S_IWUSR);
u8 val;
};
+//flash off in fixed time to prevent from too hot , zyc
+struct flash_timer{
+ struct soc_camera_device *icd;
+ struct hrtimer timer;
+};
+#if CONFIG_SENSOR_Flash
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer);
+#endif
+static struct flash_timer flash_off_timer;
+//for user defined if user want to customize the series , zyc
+#ifdef CONFIG_HI704_USER_DEFINED_SERIES
+#include "hi704_user_series.c"
+#else
/* init SVGA preview */
static struct reginfo sensor_init_data[] =
{
{0x01, 0xf3}, //PWRCTL(0x01[P0])Bit[1]:Software Reset.
{0x01, 0xf1},
{0x10, 0x00},//vga mode
-{0x11, 0x91}, //For No Fixed Framerate Bit[2]
+{0x11, 0x90}, //For No Fixed Framerate Bit[2]
{0x12, 0x04},
{0x20, 0x00},
{0x85, 0x4b},
{0x89, 0x48},
-{0x90, 0x0b},
-{0x91, 0x0b},
-{0x92, 0x48},
-{0x93, 0x48},
+{0x90, 0x0c},
+{0x91, 0x0c},
+{0x92, 0x78},
+{0x93, 0x70},
{0x98, 0x38},
{0x99, 0x40},
-{0xa0, 0x00},
+{0xa0, 0x40},
{0xa8, 0x40},
//PAGE 2
{0x11, 0x43},
{0x12, 0x30},
-{0x40, 0x10},//brightness +1
+{0x40, 0x00},//brightness +1
{0x41, 0x02},
{0x48, 0x98},//contrast level +1
{0x39,0xbd},
{0x3a,0xc8},
{0x3b,0xd9},
-{0x3c,0xe8},
+{0x3c,0xe5},
{0x3d,0xf5},
{0x3e,0xff},
//0930
{0x6A, 0x28},
{0x6B, 0xc8},
-{0x70, 0x42},//Y Target 42
+{0x70, 0x38},//Y Target 42
{0x76, 0x22}, //Unlock bnd1
{0x77, 0x02}, //Unlock bnd2 02->a2 _10_04_06 hhzin
{0x99, 0x23},
{0x9c, 0x0b}, //4shared limit_10_04_06 hhzin
-{0x9d, 0x3b}, // 0x06d3 --> 0x0b3b
+{0x9d, 0xb8}, // 0x06d3 --> 0x0b3b
{0x9e, 0x00}, //4shared Unit_10_04_06 hhzin
{0x9f, 0xfa}, // 0x01f4 --> 0xfa
{0xb1, 0x14},
-{0xb2, 0x50},
+{0xb2, 0x30},
{0xb4, 0x14},
{0xb5, 0x38},
{0xb6, 0x26},
{0x20, 0x00},
{0x21, 0x04},
-{0x40, 0x00}, //HBLANK: 0x70 = 112
-{0x41, 0x70},
+{0x40, 0x01}, //HBLANK: 0x70 = 112
+{0x41, 0x58},
{0x42, 0x00}, //VBLANK: 0x04 = 4
-{0x43, 0x40},
+{0x43, 0x64},
{0x03, 0x11},
{0x10, 0x25},
{0x03, 0x20},
{0x83, 0x00},
{0x84, 0xaf},
-{0x85, 0x80},
+{0x85, 0xc8},
{0x86, 0x00},
-{0x87, 0xc0},
+{0x87, 0xf0},
{0x8b, 0x3a},
-{0x8c, 0x80},
+{0x8c, 0x98},
{0x8d, 0x30},
-{0x8e, 0xc0},
+{0x8e, 0xd4},
-{0x9c, 0x08},
-{0x9d, 0xa0},
+{0x9c, 0x0b},
+{0x9d, 0xb8},
{0x9e, 0x00},
-{0x9f, 0xc0},
+{0x9f, 0xfa},
{END_REG, END_REG},
};
{0x40, 0x01}, //HBLANK: 0x0158 = 344
{0x41, 0x58},
{0x42, 0x00}, //VBLANK: 0x14 = 20
-{0x43, 0x14},
+{0x43, 0x64},
{0x03, 0x11}, //QVGA Fixframerate
{0x10, 0x21},
{0x8e, 0xd4},
{0x9c, 0x0b},
-{0x9d, 0x3b},
+{0x9d, 0xb8},
{0x9e, 0x00},
{0x9f, 0xfa},
{END_REG, END_REG},
{END_REG, END_REG},
};
-
+#endif
static struct reginfo sensor_ClrFmt_YUYV[]=
{
{
//00 level
{0x03, 0x10},
- {0x62, 0x90},
- {0x63, 0x90},
+ {0x62, 0x80},
+ {0x63, 0x80},
{END_REG, END_REG},
};
{
//Contrast 0
{0x03, 0x10},
- {0x48, 0x84},
+ {0x48, 0x80},
{END_REG, END_REG},
};
};
static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
#endif
-static const struct v4l2_querymenu sensor_menus[] =
+static struct v4l2_querymenu sensor_menus[] =
{
#if CONFIG_SENSOR_WhiteBalance
{ .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
#endif
};
-static const struct v4l2_queryctrl sensor_controls[] =
+static struct v4l2_queryctrl sensor_controls[] =
{
#if CONFIG_SENSOR_WhiteBalance
{
if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
+ if(on){
+ //flash off after 2 secs
+ hrtimer_cancel(&(flash_off_timer.timer));
+ hrtimer_start(&(flash_off_timer.timer),ktime_set(0, 800*1000*1000),HRTIMER_MODE_REL);
+ }
}
break;
}
sensor_power_end:
return ret;
}
+#if CONFIG_SENSOR_Flash
+static enum hrtimer_restart flash_off_func(struct hrtimer *timer){
+ struct flash_timer *fps_timer = container_of(timer, struct flash_timer, timer);
+ sensor_ioctrl(fps_timer->icd,Sensor_Flash,0);
+ SENSOR_DG("%s %s !!!!!!",SENSOR_NAME_STRING(),__FUNCTION__);
+ return 0;
+
+}
+#endif
static int sensor_init(struct v4l2_subdev *sd, u32 val)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
struct soc_camera_device *icd = client->dev.platform_data;
struct sensor *sensor = to_sensor(client);
const struct v4l2_queryctrl *qctrl;
qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
if (qctrl)
sensor->info_priv.flash = qctrl->default_value;
+ flash_off_timer.icd = icd;
+ flash_off_timer.timer.function = flash_off_func;
#endif
SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),((val == 0)?__FUNCTION__:"sensor_reinit"),icd->user_width,icd->user_height);
static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
struct soc_camera_device *icd = client->dev.platform_data;
struct sensor *sensor = to_sensor(client);
}
static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
struct sensor *sensor = to_sensor(client);
const struct sensor_datafmt *fmt;
const struct v4l2_queryctrl *qctrl;
static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
struct sensor *sensor = to_sensor(client);
const struct sensor_datafmt *fmt;
int ret = 0;
static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
return -EINVAL;
static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
struct sensor *sensor = to_sensor(client);
const struct v4l2_queryctrl *qctrl;
static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
struct sensor *sensor = to_sensor(client);
struct soc_camera_device *icd = client->dev.platform_data;
const struct v4l2_queryctrl *qctrl;
static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
struct soc_camera_device *icd = client->dev.platform_data;
int i, error_cnt=0, error_idx=-1;
static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
struct soc_camera_device *icd = client->dev.platform_data;
int i, error_cnt=0, error_idx=-1;
}
static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
{
- struct i2c_client *client = sd->priv;
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
struct soc_camera_device *icd = client->dev.platform_data;
struct sensor *sensor = to_sensor(client);
int ret = 0;
if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
for (i = 0; i < icd->ops->num_controls; i++) {
if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
- memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
+ //memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
+ sensor_controls[i].id=0xffff;
}
}
sensor->info_priv.flash = 0xff;
SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
+ }else{ //two cameras are the same,need to deal diffrently ,zyc
+ for (i = 0; i < icd->ops->num_controls; i++) {
+ if(0xffff == icd->ops->controls[i].id){
+ sensor_controls[i].id=V4L2_CID_FLASH;
+ }
+ }
}
}
#endif
kfree(sensor);
sensor = NULL;
}
+ hrtimer_init(&(flash_off_timer.timer), CLOCK_MONOTONIC, HRTIMER_MODE_REL);
SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
return ret;
}