* author: ddl@rock-chips.com
*****************************************************************************************/
#ifdef CONFIG_VIDEO_RK2818
-
-#define RK2818_CAM_POWER_PIN TCA6424_P03
-#define RK2818_CAM_RESET_PIN INVALID_GPIO
+#define SENSOR_NAME_0 RK28_CAM_SENSOR_NAME_OV9650
+#define SENSOR_IIC_ADDR_0 0x60
+#define SENSOR_IIC_ADAPTER_ID_0 1
+#define SENSOR_POWER_PIN_0 TCA6424_P03
+#define SENSOR_RESET_PIN_0 INVALID_GPIO
+#define SENSOR_POWERACTIVE_LEVEL_0 RK28_CAM_POWERACTIVE_L
+#define SENSOR_RESETACTIVE_LEVEL_0 RK28_CAM_RESETACTIVE_L
+
+
+#define SENSOR_NAME_1 NULL
+#define SENSOR_IIC_ADDR_1 0x00
+#define SENSOR_IIC_ADAPTER_ID_1 0xff
+#define SENSOR_POWER_PIN_1 INVALID_GPIO
+#define SENSOR_RESET_PIN_1 INVALID_GPIO
+#define SENSOR_POWERACTIVE_LEVEL_1 RK28_CAM_POWERACTIVE_L
+#define SENSOR_RESETACTIVE_LEVEL_1 RK28_CAM_RESETACTIVE_L
static int rk28_sensor_io_init(void);
static int rk28_sensor_io_deinit(void);
.io_deinit = rk28_sensor_io_deinit,
.gpio_res = {
{
- .gpio_reset = RK2818_CAM_RESET_PIN,
- .gpio_power = RK2818_CAM_POWER_PIN,
- .gpio_flag = (RK28_CAM_POWERACTIVE_L|RK28_CAM_RESETACTIVE_L),
- .dev_name = "ov9650"
+ .gpio_reset = SENSOR_RESET_PIN_0,
+ .gpio_power = SENSOR_POWER_PIN_0,
+ .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0),
+ .dev_name = SENSOR_NAME_0,
}, {
- .gpio_reset = INVALID_GPIO,
- .gpio_power = INVALID_GPIO,
- .dev_name = NULL
+ .gpio_reset = SENSOR_RESET_PIN_1,
+ .gpio_power = SENSOR_POWER_PIN_1,
+ .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1),
+ .dev_name = SENSOR_NAME_1,
}
}
};
if (camera_reset != INVALID_GPIO) {
gpio_set_value(camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
- //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev),camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+ //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
}
if (camera_power != INVALID_GPIO) {
if (on) {
gpio_set_value(camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
- //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
} else {
gpio_set_value(camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
- //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
}
}
if (camera_reset != INVALID_GPIO) {
msleep(3); /* delay 3 ms */
gpio_set_value(camera_reset,(((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
- //printk("\n%s..%s..ResetPin= %d..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_reset, (((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+ //printk("\n%s..%s..ResetPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_reset, (((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
}
return 0;
}
-#define OV9650_IIC_ADDR 0x60
static struct i2c_board_info rk2818_i2c_cam_info[] = {
-#ifdef CONFIG_SOC_CAMERA_OV9650
{
- I2C_BOARD_INFO("ov9650", OV9650_IIC_ADDR>>1)
+ I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
},
-#endif
};
struct soc_camera_link rk2818_iclink = {
.bus_id = RK28_CAM_PLATFORM_DEV_ID,
.power = rk28_sensor_power,
.board_info = &rk2818_i2c_cam_info[0],
- .i2c_adapter_id = 1,
-#ifdef CONFIG_SOC_CAMERA_OV9650
- .module_name = "ov9650",
-#endif
+ .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
+ .module_name = SENSOR_NAME_0,
+};
+
+/*platform_device : soc-camera need */
+struct platform_device rk2818_soc_camera_pdrv = {
+ .name = "soc-camera-pdrv",
+ .id = -1,
+ .dev = {
+ .init_name = SENSOR_NAME_0,
+ .platform_data = &rk2818_iclink,
+ },
};
#endif
* author: ddl@rock-chips.com
*****************************************************************************************/
#ifdef CONFIG_VIDEO_RK2818
-
-#define RK2818_CAM_POWER_PIN TCA6424_P16
-#define RK2818_CAM_RESET_PIN INVALID_GPIO
+#define SENSOR_NAME_0 RK28_CAM_SENSOR_NAME_OV2655
+#define SENSOR_IIC_ADDR_0 0x60
+#define SENSOR_IIC_ADAPTER_ID_0 1
+#define SENSOR_POWER_PIN_0 TCA6424_P16
+#define SENSOR_RESET_PIN_0 INVALID_GPIO
+#define SENSOR_POWERACTIVE_LEVEL_0 RK28_CAM_POWERACTIVE_L
+#define SENSOR_RESETACTIVE_LEVEL_0 RK28_CAM_RESETACTIVE_L
+
+
+#define SENSOR_NAME_1 NULL
+#define SENSOR_IIC_ADDR_1 0x00
+#define SENSOR_IIC_ADAPTER_ID_1 0xff
+#define SENSOR_POWER_PIN_1 INVALID_GPIO
+#define SENSOR_RESET_PIN_1 INVALID_GPIO
+#define SENSOR_POWERACTIVE_LEVEL_1 RK28_CAM_POWERACTIVE_L
+#define SENSOR_RESETACTIVE_LEVEL_1 RK28_CAM_RESETACTIVE_L
static int rk28_sensor_io_init(void);
static int rk28_sensor_io_deinit(void);
.io_deinit = rk28_sensor_io_deinit,
.gpio_res = {
{
- .gpio_reset = RK2818_CAM_RESET_PIN,
- .gpio_power = RK2818_CAM_POWER_PIN,
- .gpio_flag = (RK28_CAM_POWERACTIVE_L|RK28_CAM_RESETACTIVE_L),
- .dev_name = "ov2655"
+ .gpio_reset = SENSOR_RESET_PIN_0,
+ .gpio_power = SENSOR_POWER_PIN_0,
+ .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0),
+ .dev_name = SENSOR_NAME_0,
}, {
- .gpio_reset = INVALID_GPIO,
- .gpio_power = INVALID_GPIO,
- .dev_name = NULL
+ .gpio_reset = SENSOR_RESET_PIN_1,
+ .gpio_power = SENSOR_POWER_PIN_1,
+ .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1),
+ .dev_name = SENSOR_NAME_1,
}
}
};
if (camera_reset != INVALID_GPIO) {
gpio_set_value(camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
- //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev),camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+ //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
}
if (camera_power != INVALID_GPIO) {
if (on) {
gpio_set_value(camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
- //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
} else {
gpio_set_value(camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
- //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
}
}
if (camera_reset != INVALID_GPIO) {
msleep(3); /* delay 3 ms */
gpio_set_value(camera_reset,(((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
- //printk("\n%s..%s..ResetPin= %d..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_reset, (((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+ //printk("\n%s..%s..ResetPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_reset, (((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
}
return 0;
}
-
-#define OV2655_IIC_ADDR 0x60
static struct i2c_board_info rk2818_i2c_cam_info[] = {
-#ifdef CONFIG_SOC_CAMERA_OV2655
{
- I2C_BOARD_INFO("ov2655", OV2655_IIC_ADDR>>1)
+ I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
},
-#endif
};
struct soc_camera_link rk2818_iclink = {
.bus_id = RK28_CAM_PLATFORM_DEV_ID,
.power = rk28_sensor_power,
.board_info = &rk2818_i2c_cam_info[0],
- .i2c_adapter_id = 1,
-#ifdef CONFIG_SOC_CAMERA_OV2655
- .module_name = "ov2655",
-#endif
+ .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
+ .module_name = SENSOR_NAME_0,
+};
+
+/*platform_device : soc-camera need */
+struct platform_device rk2818_soc_camera_pdrv = {
+ .name = "soc-camera-pdrv",
+ .id = -1,
+ .dev = {
+ .init_name = SENSOR_NAME_0,
+ .platform_data = &rk2818_iclink,
+ },
};
#endif
* camera devices
* author: ddl@rock-chips.com
*****************************************************************************************/
-#define RK2818_CAM_POWER_PIN FPGA_PIO1_05//SPI_GPIO_P1_05
-#define RK2818_CAM_RESET_PIN FPGA_PIO1_14//SPI_GPIO_P1_14
+#ifdef CONFIG_VIDEO_RK2818
+/* Board-raho camera configuration */
+#define SENSOR_NAME_0 RK28_CAM_SENSOR_NAME_OV2655
+#define SENSOR_IIC_ADDR_0 0x60
+#define SENSOR_IIC_ADAPTER_ID_0 2
+#define SENSOR_POWER_PIN_0 FPGA_PIO1_05
+#define SENSOR_RESET_PIN_0 FPGA_PIO1_14
+#define SENSOR_POWERACTIVE_LEVEL_0 RK28_CAM_POWERACTIVE_L
+#define SENSOR_RESETACTIVE_LEVEL_0 RK28_CAM_RESETACTIVE_L
+
+
+#define SENSOR_NAME_1 NULL
+#define SENSOR_IIC_ADDR_1 0x00
+#define SENSOR_IIC_ADAPTER_ID_1 0xff
+#define SENSOR_POWER_PIN_1 INVALID_GPIO
+#define SENSOR_RESET_PIN_1 INVALID_GPIO
+#define SENSOR_POWERACTIVE_LEVEL_1 RK28_CAM_POWERACTIVE_L
+#define SENSOR_RESETACTIVE_LEVEL_1 RK28_CAM_RESETACTIVE_L
static int rk28_sensor_io_init(void);
static int rk28_sensor_io_deinit(void);
.io_deinit = rk28_sensor_io_deinit,
.gpio_res = {
{
- .gpio_reset = RK2818_CAM_RESET_PIN,
- .gpio_power = RK2818_CAM_POWER_PIN,
- .dev_name = "ov2655"
+ .gpio_reset = SENSOR_RESET_PIN_0,
+ .gpio_power = SENSOR_POWER_PIN_0,
+ .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0),
+ .dev_name = SENSOR_NAME_0,
}, {
- .gpio_reset = INVALID_GPIO,
- .gpio_power = INVALID_GPIO,
- .dev_name = NULL
+ .gpio_reset = SENSOR_RESET_PIN_1,
+ .gpio_power = SENSOR_POWER_PIN_1,
+ .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1),
+ .dev_name = SENSOR_NAME_1,
}
}
};
{
int ret = 0, i;
unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
+ unsigned int camera_ioflag;
+ //printk("\n%s....%d ******** ddl *********\n",__FUNCTION__,__LINE__);
- printk("\n%s....%d ******** ddl *********\n",__FUNCTION__,__LINE__);
-
- for (i=0; i<2; i++) {
+ for (i=0; i<2; i++) {
camera_reset = rk28_camera_platform_data.gpio_res[i].gpio_reset;
- camera_power = rk28_camera_platform_data.gpio_res[i].gpio_power;
-
- if (camera_power != INVALID_GPIO) {
+ camera_power = rk28_camera_platform_data.gpio_res[i].gpio_power;
+ camera_ioflag = rk28_camera_platform_data.gpio_res[i].gpio_flag;
+
+ if (camera_power != INVALID_GPIO) {
ret = gpio_request(camera_power, "camera power");
if (ret)
continue;
-
- gpio_set_value(camera_reset, 1);
- gpio_direction_output(camera_power, 0);
+
+ gpio_set_value(camera_reset, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+ gpio_direction_output(camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+
+ //printk("\n%s....%d %x ******** ddl *********\n",__FUNCTION__,__LINE__,(((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+
}
-
+
if (camera_reset != INVALID_GPIO) {
ret = gpio_request(camera_reset, "camera reset");
if (ret) {
- if (camera_power != INVALID_GPIO)
- gpio_free(camera_power);
+ if (camera_power != INVALID_GPIO)
+ gpio_free(camera_power);
continue;
}
- gpio_set_value(camera_reset, 0);
- gpio_direction_output(camera_reset, 0);
+ gpio_set_value(camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+ gpio_direction_output(camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+
+ //printk("\n%s....%d %x ******** ddl *********\n",__FUNCTION__,__LINE__,((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+
}
}
-
+
return 0;
}
unsigned int i;
unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
- printk("\n%s....%d ******** ddl *********\n",__FUNCTION__,__LINE__);
-
- for (i=0; i<2; i++) {
+ //printk("\n%s....%d ******** ddl *********\n",__FUNCTION__,__LINE__);
+
+ for (i=0; i<2; i++) {
camera_reset = rk28_camera_platform_data.gpio_res[i].gpio_reset;
- camera_power = rk28_camera_platform_data.gpio_res[i].gpio_power;
-
+ camera_power = rk28_camera_platform_data.gpio_res[i].gpio_power;
+
if (camera_power != INVALID_GPIO){
gpio_direction_input(camera_power);
- gpio_free(camera_power);
+ gpio_free(camera_power);
}
-
+
if (camera_reset != INVALID_GPIO) {
gpio_direction_input(camera_reset);
- gpio_free(camera_reset);
+ gpio_free(camera_reset);
}
}
static int rk28_sensor_power(struct device *dev, int on)
{
unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
-
+ unsigned int camera_ioflag;
+
if(rk28_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk28_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
camera_reset = rk28_camera_platform_data.gpio_res[0].gpio_reset;
camera_power = rk28_camera_platform_data.gpio_res[0].gpio_power;
+ camera_ioflag = rk28_camera_platform_data.gpio_res[0].gpio_flag;
} else if (rk28_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk28_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) {
camera_reset = rk28_camera_platform_data.gpio_res[1].gpio_reset;
camera_power = rk28_camera_platform_data.gpio_res[1].gpio_power;
+ camera_ioflag = rk28_camera_platform_data.gpio_res[1].gpio_flag;
}
if (camera_reset != INVALID_GPIO) {
- gpio_set_value(camera_reset, !on);
- //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev),camera_reset, on);
- }
- if (camera_power != INVALID_GPIO) {
- gpio_set_value(camera_power, !on);
- printk("\n%s..%s..PowerPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_power, !on);
+ gpio_set_value(camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+ //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_reset, ((camera_ioflag&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
}
+ if (camera_power != INVALID_GPIO) {
+ if (on) {
+ gpio_set_value(camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, ((camera_ioflag&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+ } else {
+ gpio_set_value(camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, (((~camera_ioflag)&RK28_CAM_POWERACTIVE_MASK)>>RK28_CAM_POWERACTIVE_BITPOS));
+ }
+ }
if (camera_reset != INVALID_GPIO) {
msleep(3); /* delay 3 ms */
- gpio_set_value(camera_reset,on);
- printk("\n%s..%s..ResetPin= %d..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_reset, on);
- }
+ gpio_set_value(camera_reset,(((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+ //printk("\n%s..%s..ResetPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_reset, (((~camera_ioflag)&RK28_CAM_RESETACTIVE_MASK)>>RK28_CAM_RESETACTIVE_BITPOS));
+ }
return 0;
}
-
-#define OV2655_IIC_ADDR 0x60
static struct i2c_board_info rk2818_i2c_cam_info[] = {
-#ifdef CONFIG_SOC_CAMERA_OV2655
{
- I2C_BOARD_INFO("ov2655", OV2655_IIC_ADDR>>1)
+ I2C_BOARD_INFO(SENSOR_NAME_0, SENSOR_IIC_ADDR_0>>1)
},
-#endif
};
struct soc_camera_link rk2818_iclink = {
.bus_id = RK28_CAM_PLATFORM_DEV_ID,
.power = rk28_sensor_power,
.board_info = &rk2818_i2c_cam_info[0],
- .i2c_adapter_id = 2,
-#ifdef CONFIG_SOC_CAMERA_OV2655
- .module_name = "ov2655",
-#endif
+ .i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
+ .module_name = SENSOR_NAME_0,
};
+/*platform_device : soc-camera need */
+struct platform_device rk2818_soc_camera_pdrv = {
+ .name = "soc-camera-pdrv",
+ .id = -1,
+ .dev = {
+ .init_name = SENSOR_NAME_0,
+ .platform_data = &rk2818_iclink,
+ },
+};
+#endif
/*****************************************************************************************
* battery devices
* author: lw@rock-chips.com
.platform_data = &rk28_camera_platform_data,
}
};
-
-/*platform_device : soc-camera need */
-struct platform_device rk2818_soc_camera_pdrv = {
- .name = "soc-camera-pdrv",
- .id = -1,
- .dev = {
- #ifdef CONFIG_SOC_CAMERA_OV9650
- .init_name = "ov9650",
- #endif
- #ifdef CONFIG_SOC_CAMERA_OV2655
- .init_name = "ov2655",
- #endif
- .platform_data = &rk2818_iclink,
- },
-};
-#endif
+extern struct platform_device rk2818_soc_camera_pdrv;
+#endif
/*ADC*/
static struct resource rk2818_adc_resource[] = {
#define RK28_CAM_DRV_NAME "rk2818-camera"
#define RK28_CAM_PLATFORM_DEV_ID 33
+#define RK28_CAM_SENSOR_NAME_OV9650 "ov9650"
+#define RK28_CAM_SENSOR_NAME_OV2655 "ov2655"
+#define RK28_CAM_SENSOR_NAME_OV3640 "ov3640"
+
#define RK28_CAM_POWERACTIVE_BITPOS 0x00
#define RK28_CAM_POWERACTIVE_MASK (1<<RK28_CAM_POWERACTIVE_BITPOS)
#define RK28_CAM_POWERACTIVE_H (0x01<<RK28_CAM_POWERACTIVE_BITPOS)
#include <media/v4l2-chip-ident.h>
#include <media/soc_camera.h>
+#define _CONS(a,b) a##b
+#define CONS(a,b) _CONS(a,b)
+
+#define __STR(x) #x
+#define _STR(x) __STR(x)
+#define STR(x) _STR(x)
+
+/* Sensor Driver Configuration */
+#define SENSOR_NAME ov2655
+#define SENSOR_V4L2_IDENT V4L2_IDENT_OV2655
+#define SENSOR_ID 0x2656
+#define SENSOR_MIN_WIDTH 176
+#define SENSOR_MIN_HEIGHT 144
+#define SENSOR_MAX_WIDTH 1600
+#define SENSOR_MAX_HEIGHT 1200
+#define SENSOR_INIT_WIDTH 352 /* Sensor pixel size for sensor_init_data array */
+#define SENSOR_INIT_HEIGHT 288
+#define SENSOR_INIT_WINSEQADR sensor_cif
+
+#define CONFIG_SENSOR_WhiteBalance 1
+#define CONFIG_SENSOR_Brightness 0
+#define CONFIG_SENSOR_Contrast 0
+#define CONFIG_SENSOR_Saturation 0
+#define CONFIG_SENSOR_Effect 1
+#define CONFIG_SENSOR_Scene 1
+#define CONFIG_SENSOR_DigitalZoom 0
+#define CONFIG_SENSOR_Focus 0
+#define CONFIG_SENSOR_Exposure 0
+#define CONFIG_SENSOR_Flash 0
+#define CONFIG_SENSOR_Mirror 0
+#define CONFIG_SENSOR_Flip 0
+
+#define CONFIG_SENSOR_TR 1
+#define CONFIG_SENSOR_DEBUG 1
+
+#define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
+#define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
+
+#define MIN(x,y) ((x<y) ? x: y)
+#define MAX(x,y) ((x>y) ? x: y)
+
+#if (CONFIG_SENSOR_TR)
+ #define SENSOR_TR(format, ...) printk(format, ## __VA_ARGS__)
+ #if (CONFIG_SENSOR_DEBUG)
+ #define SENSOR_DG(format, ...) printk(format, ## __VA_ARGS__)
+ #else
+ #define SENSOR_DG(format, ...)
+ #endif
+#else
+ #define SENSOR_TR(format, ...)
+#endif
+
+#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\
+ SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |\
+ SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ)
+
+#define COLOR_TEMPERATURE_CLOUDY_DN 6500
+#define COLOR_TEMPERATURE_CLOUDY_UP 8000
+#define COLOR_TEMPERATURE_CLEARDAY_DN 5000
+#define COLOR_TEMPERATURE_CLEARDAY_UP 6500
+#define COLOR_TEMPERATURE_OFFICE_DN 3500
+#define COLOR_TEMPERATURE_OFFICE_UP 5000
+#define COLOR_TEMPERATURE_HOME_DN 2500
+#define COLOR_TEMPERATURE_HOME_UP 3500
struct reginfo
{
u8 val;
};
-/* init 800X600 SVGA */
-static struct reginfo ov2655_init_data[] =
+/* init 352X288 SVGA */
+static struct reginfo sensor_init_data[] =
{
-#if 0
- {0x308c, 0x80},
- {0x308d, 0x0e},
- {0x360b, 0x00},
- {0x30b0, 0xff},
- {0x30b1, 0xff},
- {0x30b2, 0x24},
-
- {0x300e, 0x34},
- {0x300f, 0xa6},
- {0x3010, 0x81},
- {0x3082, 0x01},
- {0x30f4, 0x01},
- {0x3090, 0x3b},//0x33},
- {0x3091, 0xc0},
- {0x30ac, 0x42},
-
- {0x30d1, 0x08},
- {0x30a8, 0x56},
- {0x3015, 0x03},
- {0x3093, 0x00},
- {0x307e, 0xe5},
- {0x3079, 0x00},
- {0x30aa, 0x42},
- {0x3017, 0x40},
- {0x30f3, 0x82},
- {0x306a, 0x0c},
- {0x306d, 0x00},
- {0x336a, 0x3c},
- {0x3076, 0x6a},
- {0x30d9, 0x8c},
- {0x3016, 0x82},
- {0x3601, 0x30},
- {0x304e, 0x88},
- {0x30f1, 0x82},
- {0x306f, 0x14},
-
- {0x3012, 0x10},
- {0x3011, 0x01},
- {0x302A, 0x02},
- {0x302B, 0xE6},
- {0x3028, 0x07},
- {0x3029, 0x93},
-
- {0x3391, 0x06},
- {0x3394, 0x38},
- {0x3395, 0x38},
-
- {0x3015, 0x02},
- {0x302d, 0x00},
- {0x302e, 0x00},
-
- {0x3013, 0xf7},
- {0x3018, 0x80},
- {0x3019, 0x70},
- {0x301a, 0xd4},
-
- {0x30af, 0x00},
- {0x3048, 0x1f},
- {0x3049, 0x4e},
- {0x304a, 0x20},
- {0x304f, 0x20},
- {0x304b, 0x02},
- {0x304c, 0x00},
- {0x304d, 0x02},
- {0x304f, 0x20},
- {0x30a3, 0x10},
- {0x3013, 0xf7},
- {0x3014, 0x84},
- {0x3071, 0x00},
- {0x3070, 0x5d},
- {0x3073, 0x00},
- {0x3072, 0x5d},
- {0x301c, 0x07},
- {0x301d, 0x07},
- {0x304d, 0x42},
- {0x304a, 0x40},
- {0x304f, 0x40},
- {0x3095, 0x07},
- {0x3096, 0x16},
- {0x3097, 0x1d},
-
- {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},
- {0x3100, 0x00},
-
- {0x3320, 0xfa},
- {0x3321, 0x11},
- {0x3322, 0x92},
- {0x3323, 0x01},
- {0x3324, 0x97},
- {0x3325, 0x02},
- {0x3326, 0xff},
- {0x3327, 0x0c},
- {0x3328, 0x10},
- {0x3329, 0x10},
- {0x332a, 0x58},
- {0x332b, 0x56},
- {0x332c, 0xbe},
- {0x332d, 0xe1},
- {0x332e, 0x3a},
- {0x332f, 0x36},
- {0x3330, 0x4d},
- {0x3331, 0x44},
- {0x3332, 0xf8},
- {0x3333, 0x0a},
- {0x3334, 0xf0},
- {0x3335, 0xf0},
- {0x3336, 0xf0},
- {0x3337, 0x40},
- {0x3338, 0x40},
- {0x3339, 0x40},
- {0x333a, 0x00},
- {0x333b, 0x00},
-
- {0x3380, 0x28},
- {0x3381, 0x48},
- {0x3382, 0x10},
- {0x3383, 0x22},
- {0x3384, 0xc0},
- {0x3385, 0xe2},
- {0x3386, 0xe2},
- {0x3387, 0xf2},
- {0x3388, 0x10},
- {0x3389, 0x98},
- {0x338a, 0x00},
-
- {0x3340, 0x04},
- {0x3341, 0x07},
- {0x3342, 0x19},
- {0x3343, 0x34},
- {0x3344, 0x4a},
- {0x3345, 0x5a},
- {0x3346, 0x67},
- {0x3347, 0x71},
- {0x3348, 0x7c},
- {0x3349, 0x8c},
- {0x334a, 0x9b},
- {0x334b, 0xa9},
- {0x334c, 0xc0},
- {0x334d, 0xd5},
- {0x334e, 0xe8},
- {0x334f, 0x20},
-
- {0x3350, 0x37},//0x33},
- {0x3351, 0x27},//0x28},
- {0x3352, 0x00},
- {0x3353, 0x16},
- {0x3354, 0x00},
- {0x3355, 0x85},
- {0x3356, 0x35},
- {0x3357, 0x28},
- {0x3358, 0x00},
- {0x3359, 0x13},
- {0x335a, 0x00},
- {0x335b, 0x85},
- {0x335c, 0x37},//0x34},
- {0x335d, 0x28},
- {0x335e, 0x00},
- {0x335f, 0x13},
- {0x3360, 0x00},
- {0x3361, 0x85},
- {0x3363, 0x70},
- {0x3364, 0x7f},
- {0x3365, 0x00},
- {0x3366, 0x00},
- {0x3362, 0x90},
-
- {0x3301, 0xff},
- {0x338B, 0x11},
- {0x338c, 0x10},
- {0x338d, 0x40},
-
- {0x3370, 0xd0},
- {0x3371, 0x00},
- {0x3372, 0x00},
- {0x3373, 0x30},
- {0x3374, 0x10},
- {0x3375, 0x10},
- {0x3376, 0x04},
- {0x3377, 0x00},
- {0x3378, 0x04},
- {0x3379, 0x80},
-
- {0x3069, 0x84},
- {0x307c, 0x13},//0x10},
- {0x3087, 0x02},
-
- {0x3300, 0xfc},
- {0x3302, 0x11},
- {0x3400, 0x02},
- {0x3606, 0x20},
- {0x3601, 0x30},
- {0x30f3, 0x83},
- {0x304e, 0x88},
-
- {0x30aa, 0x72},
- {0x30a3, 0x80},
- {0x30a1, 0x41},
-
- {0x3086, 0x0f},
- {0x3086, 0x00},
-
- {0x0, 0x0}, //end flag
-#else
{0x308c, 0x80},
{0x308d, 0x0e},
{0x360b, 0x00},
{0x3086, 0x0f},
{0x3086, 0x00},
- {0x0, 0x0}, //end flag
-#endif
+ {0x0, 0x0} //end flag
};
/* 1600X1200 UXGA */
-static struct reginfo ov2655_uxga[] =
+static struct reginfo sensor_uxga[] =
{
{0x300E, 0x34},
};
/* 1280X1024 SXGA */
-static struct reginfo ov2655_sxga[] =
+static struct reginfo sensor_sxga[] =
{
-
{0x300E, 0x34},
{0x3011, 0x01},
{0x3012, 0x00},
};
/* 800X600 SVGA*/
-static struct reginfo ov2655_svga[] =
+static struct reginfo sensor_svga[] =
{
-
{0x300E, 0x34},
{0x3011, 0x01},
{0x3012, 0x10},
};
/* 640X480 VGA */
-static struct reginfo ov2655_vga[] =
+static struct reginfo sensor_vga[] =
{
-
{0x300E, 0x34},
{0x3011, 0x01},
{0x3012, 0x10},
};
/* 352X288 CIF */
-static struct reginfo ov2655_cif[] =
+static struct reginfo sensor_cif[] =
{
-
{0x300E, 0x34},
{0x3011, 0x01},
{0x3012, 0x10},
{0x3070, 0x5d},
{0x3072, 0x5d},
{0x301c, 0x07},
- {0x301d, 0x07},
+ {0x301d, 0x07},
{0x3020, 0x01},
{0x3021, 0x18},
{0x3022, 0x00},
{ 0x3024, 0x06},
{0x3025, 0x58},
{0x3026, 0x02},
- {0x3027, 0x61},
+ {0x3027, 0x61},
{0x3088, 0x01},
{0x3089, 0x68},
{0x308a, 0x01},
};
/* 320*240 QVGA */
-static struct reginfo ov2655_qvga[] =
+static struct reginfo sensor_qvga[] =
{
-
{0x300E, 0x34},
{0x3011, 0x01},
{0x3012, 0x10},
};
/* 176X144 QCIF*/
-static struct reginfo ov2655_qcif[] =
+static struct reginfo sensor_qcif[] =
{
{0x300E, 0x34},
{0x3011, 0x01},
};
#endif
-#define MIN(x,y) ((x<y) ? x: y)
-#define MAX(x,y) ((x>y) ? x: y)
-
-#define OV2655_MIN_WIDTH 176
-#define OV2655_MIN_HEIGHT 144
-#define OV2655_MAX_WIDTH 1600
-#define OV2655_MAX_HEIGHT 1200
-
-#define CONFIG_OV2655_TR 1
-#define CONFIG_OV2655_DEBUG 0
-#if (CONFIG_OV2655_TR)
- #define OV2655_TR(format, ...) printk(format, ## __VA_ARGS__)
- #if (CONFIG_OV2655_DEBUG)
- #define OV2655_DG(format, ...) printk(format, ## __VA_ARGS__)
- #else
- #define OV2655_DG(format, ...)
- #endif
-#else
- #define OV2655_TR(format, ...)
-#endif
-
-#define COL_FMT(_name, _depth, _fourcc, _colorspace) \
- { .name = _name, .depth = _depth, .fourcc = _fourcc, \
- .colorspace = _colorspace }
-
-#define JPG_FMT(_name, _depth, _fourcc) \
- COL_FMT(_name, _depth, _fourcc, V4L2_COLORSPACE_JPEG)
-
-static const struct soc_camera_data_format ov2655_colour_formats[] = {
- JPG_FMT("ov2655 UYVY", 16, V4L2_PIX_FMT_UYVY),
- JPG_FMT("ov2655 YUYV", 16, V4L2_PIX_FMT_YUYV),
-};
-
-typedef struct ov2655_info_priv_s
-{
- int whiteBalance;
- int brightness;
- int contrast;
- int saturation;
- int effect;
- int scene;
- int digitalzoom;
- int focus;
- int flash;
- int exposure;
- unsigned char mirror; /* HFLIP */
- unsigned char flip; /* VFLIP */
- unsigned int winseqe_cur_addr;
-
- unsigned int powerdown_pin;
-
-} ov2655_info_priv_t;
-
-struct ov2655
-{
- struct v4l2_subdev subdev;
- struct i2c_client *client;
- ov2655_info_priv_t info_priv;
- unsigned int pixfmt;
- int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
-};
-
-static const struct v4l2_queryctrl ov2655_controls[] =
-{
- {
- .id = V4L2_CID_DO_WHITE_BALANCE,
- .type = V4L2_CTRL_TYPE_MENU,
- .name = "White Balance Control",
- .minimum = 0,
- .maximum = 4,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_BRIGHTNESS,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Brightness Control",
- .minimum = -3,
- .maximum = 2,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_EFFECT,
- .type = V4L2_CTRL_TYPE_MENU,
- .name = "Effect Control",
- .minimum = 0,
- .maximum = 5,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_EXPOSURE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Exposure Control",
- .minimum = 0,
- .maximum = 6,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_SATURATION,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Saturation Control",
- .minimum = 0,
- .maximum = 2,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_CONTRAST,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Contrast Control",
- .minimum = -3,
- .maximum = 3,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_HFLIP,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Mirror Control",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 1,
- }, {
- .id = V4L2_CID_VFLIP,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Flip Control",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 1,
- }, {
- .id = V4L2_CID_SCENE,
- .type = V4L2_CTRL_TYPE_MENU,
- .name = "Scene Control",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_ZOOM_RELATIVE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "DigitalZoom Control",
- .minimum = -1,
- .maximum = 1,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_ZOOM_ABSOLUTE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "DigitalZoom Control",
- .minimum = 0,
- .maximum = 3,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_FOCUS_RELATIVE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Focus Control",
- .minimum = -1,
- .maximum = 1,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_FOCUS_ABSOLUTE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Focus Control",
- .minimum = 0,
- .maximum = 255,
- .step = 1,
- .default_value = 125,
- }, {
- .id = V4L2_CID_FLASH,
- .type = V4L2_CTRL_TYPE_MENU,
- .name = "Flash Control",
- .minimum = 0,
- .maximum = 3,
- .step = 1,
- .default_value = 0,
- }
-};
-
-static int ov2655_probe(struct i2c_client *client, const struct i2c_device_id *did);
-static int ov2655_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
-static int ov2655_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
-static int ov2655_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
-static int ov2655_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
-static int ov2655_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
-
-
-static struct ov2655* to_ov2655(const struct i2c_client *client)
-{
- return container_of(i2c_get_clientdata(client), struct ov2655, subdev);
-}
-
-/* ov2655 register write */
-static int ov2655_write(struct i2c_client *client, u16 reg, u8 val)
-{
- int err,cnt;
- u8 buf[3];
- struct i2c_msg msg[1];
-
- buf[0] = reg >> 8;
- buf[1] = reg & 0xFF;
- buf[2] = val;
-
- msg->addr = client->addr;
- msg->flags = client->flags;
- msg->buf = buf;
- msg->len = sizeof(buf);
- msg->scl_rate = 400*1000; /* ddl@rock-chips.com : 100kHz */
- msg->read_type = I2C_NORMAL;
-
- cnt = 3;
- err = -EAGAIN;
-
- while ((cnt--) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
- err = i2c_transfer(client->adapter, msg, 1);
-
- if (err >= 0) {
- return 0;
- } else {
- OV2655_TR("\n Write reg failed, write again!\n");
- udelay(10);
- }
- }
-
- return err;
-}
-
-/* ov2655 register read */
-static int ov2655_read(struct i2c_client *client, u16 reg, u8 *val)
-{
- int err,cnt;
- u8 buf[2];
- struct i2c_msg msg[2];
-
- buf[0] = reg >> 8;
- buf[1] = reg & 0xFF;
-
- msg[0].addr = client->addr;
- msg[0].flags = client->flags;
- msg[0].buf = buf;
- msg[0].len = sizeof(buf);
- msg[0].scl_rate = 400*1000; /* ddl@rock-chips.com : 100kHz */
- msg[0].read_type = I2C_NO_STOP; /* */
-
- msg[1].addr = client->addr;
- msg[1].flags = client->flags|I2C_M_RD;
- msg[1].buf = buf;
- msg[1].len = 1;
- msg[1].scl_rate = 100*1000; /* ddl@rock-chips.com : 100kHz */
- msg[1].read_type = I2C_NO_STOP; /* */
-
- cnt = 3;
- err = -EAGAIN;
- while ((cnt--) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
- err = i2c_transfer(client->adapter, msg, 2);
-
- if (err >= 0) {
- *val = buf[0];
- return 0;
- } else {
- udelay(10);
- }
- }
-
- return err;
-}
-
-/* write a array of registers */
-static int ov2655_write_array(struct i2c_client *client, struct reginfo *regarray)
-{
- int err;
- int i = 0;
-
- while (regarray[i].reg != 0)
- {
- err = ov2655_write(client, regarray[i].reg, regarray[i].val);
- if (err != 0)
- {
- OV2655_TR("write failed current i = %d\n", i);
- return err;
- }
- i++;
- }
- return 0;
-}
-
-static int ov2655_init(struct v4l2_subdev *sd, u32 val)
-{
- struct i2c_client *client = sd->priv;
- struct soc_camera_device *icd = client->dev.platform_data;
- struct ov2655 *ov2655 = to_ov2655(client);
- int ret;
-
- OV2655_DG("\n%s..%d.. *** ddl ***\n",__FUNCTION__,__LINE__);
-
- /* soft reset */
- ret = ov2655_write(client, 0x3012, 0x80);
- if (ret != 0)
- {
- OV2655_TR("soft reset ov2655 failed\n");
- return -ENODEV;
- }
-
- mdelay(5); //delay 5 microseconds
-
- ret = ov2655_write_array(client, ov2655_init_data);
- if (ret != 0)
- {
- OV2655_TR("error: ov2655 initial failed\n");
- return ret;
- }
-
- icd->user_width = 352;
- icd->user_height = 288;
-
- /* sensor ov2655 information for initialization */
- ov2655->info_priv.whiteBalance = ov2655_controls[0].default_value;
- ov2655->info_priv.brightness = ov2655_controls[1].default_value;
- ov2655->info_priv.effect = ov2655_controls[2].default_value;
- ov2655->info_priv.exposure = ov2655_controls[3].default_value;
- ov2655->info_priv.saturation = ov2655_controls[4].default_value;
- ov2655->info_priv.contrast = ov2655_controls[5].default_value;
- ov2655->info_priv.mirror = ov2655_controls[6].default_value;
- ov2655->info_priv.flip = ov2655_controls[7].default_value;
- ov2655->info_priv.scene = ov2655_controls[8].default_value;
- ov2655->info_priv.digitalzoom = ov2655_controls[10].default_value;
- ov2655->info_priv.winseqe_cur_addr = (int)ov2655_svga;
-
- /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
- //ov2655_set_focus();
- //ov2655_set_flash();
- ov2655->info_priv.focus = ov2655_controls[12].default_value;
- ov2655->info_priv.flash = ov2655_controls[13].default_value;
-
-
- OV2655_DG("\n%s..%d.. *** ddl *** icd->width = %d.. icd->height %d\n",__FUNCTION__,__LINE__,icd->user_width,icd->user_height);
-
- return 0;
-OV2655_INIT_ERR:
- return ret;
-}
-
-static struct reginfo ov2655_power_down_sequence[]=
-{
- {0x30ab, 0x00},
- {0x30ad, 0x0a},
- {0x30ae,0x27},
- {0x363b,0x01},
- {0x00,0x00}
-};
-static int ov2655_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
-{
- int ret;
- struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
- struct soc_camera_link *icl;
-
-
- if (pm_msg.event == PM_EVENT_SUSPEND)
- {
- OV2655_DG("\n ov2655 Enter Suspend. %x ******** ddl *********\n", __LINE__);
- ret = ov2655_write_array(client, ov2655_power_down_sequence) ;
- if (ret != 0)
- {
- OV2655_TR("\n OV2655 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
- return ret;
- }
- else
- {
- icl = to_soc_camera_link(icd);
- if (icl->power) {
- ret = icl->power(icd->pdev, 0);
- if (ret < 0)
- return -EINVAL;
- }
- }
- }
- else
- {
- OV2655_TR("\n Sov2655 cann't suppout Suspend. %x ******** ddl *********\n", __LINE__);
- return -EINVAL;
- }
- return 0;
-}
-
-static int ov2655_resume(struct soc_camera_device *icd)
-{
- struct soc_camera_link *icl;
- int ret;
-
- icl = to_soc_camera_link(icd);
- if (icl->power) {
- ret = icl->power(icd->pdev, 0);
- if (ret < 0)
- return -EINVAL;
- }
-
- return 0;
-
-}
-
-static int ov2655_set_bus_param(struct soc_camera_device *icd,
- unsigned long flags)
-{
-
- return 0;
-}
-
-static unsigned long ov2655_query_bus_param(struct soc_camera_device *icd)
-{
- struct soc_camera_link *icl = to_soc_camera_link(icd);
- unsigned long flags = SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |
- SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |
- SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ;
-
- return soc_camera_apply_sensor_flags(icl, flags);
-}
-
-static int ov2655_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
- struct i2c_client *client = sd->priv;
- struct soc_camera_device *icd = client->dev.platform_data;
- struct ov2655 *ov2655 = to_ov2655(client);
- struct v4l2_pix_format *pix = &f->fmt.pix;
-
- pix->width = icd->user_width;
- pix->height = icd->user_height;
- pix->pixelformat = ov2655->pixfmt;
- pix->field = V4L2_FIELD_NONE;
- pix->colorspace = V4L2_COLORSPACE_JPEG;
-
- return 0;
-}
-static int ov2655_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
- struct i2c_client *client = sd->priv;
- struct ov2655 *ov2655 = to_ov2655(client);
- struct v4l2_pix_format *pix = &f->fmt.pix;
- struct reginfo *winseqe_set_addr;
- int ret, set_w,set_h;
-
- set_w = pix->width;
- set_h = pix->height;
-
- if ((set_w <= 176) && (set_h <= 144))
- {
- winseqe_set_addr = ov2655_qcif;
- set_w = 176;
- set_h = 144;
- }
- else if ((set_w <= 320) && (set_h <= 240))
- {
- winseqe_set_addr = ov2655_qvga;
- set_w = 320;
- set_h = 240;
- }
- else if ((set_w <= 352) && (set_h<= 288))
- {
- winseqe_set_addr = ov2655_cif;
- set_w = 352;
- set_h = 288;
- }
- else if ((set_w <= 640) && (set_h <= 480))
- {
- winseqe_set_addr = ov2655_vga;
- set_w = 640;
- set_h = 480;
- }
- else if ((set_w <= 800) && (set_h <= 600))
- {
- winseqe_set_addr = ov2655_svga;
- set_w = 800;
- set_h = 600;
- }
- else if ((set_w <= 1280) && (set_h <= 1024))
- {
- winseqe_set_addr = ov2655_sxga;
- set_w = 1280;
- set_h = 1024;
- }
- else if ((set_w <= 1600) && (set_h <= 1200))
- {
- winseqe_set_addr = ov2655_uxga;
- set_w = 1600;
- set_h = 1200;
- }
- else
- {
- winseqe_set_addr = ov2655_qvga; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */
- set_w = 320;
- set_h = 240;
- }
-
- if ((int)winseqe_set_addr != ov2655->info_priv.winseqe_cur_addr)
- {
- ret = ov2655_write_array(client, winseqe_set_addr);
- if (ret != 0)
- {
- OV2655_TR("ov2655 set format capability failed\n");
- return ret;
- }
-
- ov2655->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
- mdelay(250);
-
- OV2655_DG("\n%s..%d *** ddl *** icd->width = %d.. icd->height %d\n",__FUNCTION__,__LINE__,set_w,set_h);
- }
- else
- {
- OV2655_TR("\n .. Current Format is validate *** ddl *** icd->width = %d.. icd->height %d\n",set_w,set_h);
- }
-
- return 0;
-}
-
-static int ov2655_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
- struct v4l2_pix_format *pix = &f->fmt.pix;
- bool bayer = pix->pixelformat == V4L2_PIX_FMT_UYVY ||
- pix->pixelformat == V4L2_PIX_FMT_YUYV;
-
- /*
- * With Bayer format enforce even side lengths, but let the user play
- * with the starting pixel
- */
-
- if (pix->height > OV2655_MAX_HEIGHT)
- pix->height = OV2655_MAX_HEIGHT;
- else if (pix->height < OV2655_MIN_HEIGHT)
- pix->height = OV2655_MIN_HEIGHT;
- else if (bayer)
- pix->height = ALIGN(pix->height, 2);
-
- if (pix->width > OV2655_MAX_WIDTH)
- pix->width = OV2655_MAX_WIDTH;
- else if (pix->width < OV2655_MIN_WIDTH)
- pix->width = OV2655_MIN_WIDTH;
- else if (bayer)
- pix->width = ALIGN(pix->width, 2);
-
- return 0;
-}
-
- static int ov2655_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
-{
- struct i2c_client *client = sd->priv;
-
- if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
- return -EINVAL;
-
- if (id->match.addr != client->addr)
- return -ENODEV;
-
- id->ident = V4L2_IDENT_OV2655; /* ddl@rock-chips.com : Return OV2655 identifier */
- id->revision = 0;
-
- return 0;
-}
-
-#define COLOR_TEMPERATURE_CLOUDY_DN 6500
-#define COLOR_TEMPERATURE_CLOUDY_UP 8000
-#define COLOR_TEMPERATURE_CLEARDAY_DN 5000
-#define COLOR_TEMPERATURE_CLEARDAY_UP 6500
-#define COLOR_TEMPERATURE_OFFICE_DN 3500
-#define COLOR_TEMPERATURE_OFFICE_UP 5000
-#define COLOR_TEMPERATURE_HOME_DN 2500
-#define COLOR_TEMPERATURE_HOME_UP 3500
-
-static struct reginfo ov2655_WhiteB_Auto[]=
+#if CONFIG_SENSOR_WhiteBalance
+static struct reginfo sensor_WhiteB_Auto[]=
{
{0x3306, 0x00}, //AWB auto, bit[1]:0,auto
{0x0000, 0x00}
};
/* Cloudy Colour Temperature : 6500K - 8000K */
-static struct reginfo ov2655_WhiteB_Cloudy[]=
+static struct reginfo sensor_WhiteB_Cloudy[]=
{
{0x3306, 0x82},
{0x3337, 0x68},
{0x0000, 0x00}
};
/* ClearDay Colour Temperature : 5000K - 6500K */
-static struct reginfo ov2655_WhiteB_ClearDay[]=
+static struct reginfo sensor_WhiteB_ClearDay[]=
{
//Sunny
{0x3306, 0x02}, //AWB off
{0x0000, 0x00}
};
/* Office Colour Temperature : 3500K - 5000K */
-static struct reginfo ov2655_WhiteB_TungstenLamp1[]=
+static struct reginfo sensor_WhiteB_TungstenLamp1[]=
{
//Office
{0x3306, 0x02},
};
/* Home Colour Temperature : 2500K - 3500K */
-static struct reginfo ov2655_WhiteB_TungstenLamp2[]=
+static struct reginfo sensor_WhiteB_TungstenLamp2[]=
{
//Home
{0x3306, 0x02},
{0x3339, 0x70},
{0x0000, 0x00}
};
+static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
+ sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
+};
+#endif
-static struct reginfo ov2655_Brightness0[]=
+#if CONFIG_SENSOR_Brightness
+static struct reginfo sensor_Brightness0[]=
{
// Brightness -2
{0x3301, 0xff},//bit[7]:1, enable SDE
{0x0000, 0x00}
};
-static struct reginfo ov2655_Brightness1[]=
+static struct reginfo sensor_Brightness1[]=
{
// Brightness -1
{0x3301, 0xff},//bit[7]:1, enable SDE
{0x0000, 0x00}
};
-static struct reginfo ov2655_Brightness2[]=
+static struct reginfo sensor_Brightness2[]=
{
// Brightness 0
{0x3301, 0xff},//bit[7]:1, enable SDE
{0x0000, 0x00}
};
-static struct reginfo ov2655_Brightness3[]=
+static struct reginfo sensor_Brightness3[]=
{
// Brightness +1
{0x3301, 0xff},//bit[7]:1, enable SDE
{0x0000, 0x00}
};
-static struct reginfo ov2655_Brightness4[]=
+static struct reginfo sensor_Brightness4[]=
+{
+ // Brightness +2
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x41},
+ {0x339a, 0x20},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Brightness5[]=
+{
+ // Brightness +3
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04}, //bit[2] enable
+ {0x3390, 0x41}, //bit[3] sign of brightness
+ {0x339a, 0x30},
+ {0x0000, 0x00}
+};
+static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
+ sensor_Brightness4, sensor_Brightness5,NULL,
+};
+
+#endif
+
+#if CONFIG_SENSOR_Effect
+static struct reginfo sensor_Effect_Normal[] =
+{
+ {0x3391, 0x00},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Effect_WandB[] =
+{
+ {0x3391, 0x20},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Effect_Sepia[] =
+{
+ {0x3391, 0x18},
+ {0x3396, 0x40},
+ {0x3397, 0xa6},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Effect_Negative[] =
+{
+ //Negative
+ {0x3391, 0x40}, //bit[6] negative
+ {0x0000, 0x00}
+};
+static struct reginfo sensor_Effect_Bluish[] =
+{
+ // Bluish
+ {0x3391, 0x18},
+ {0x3396, 0xa0},
+ {0x3397, 0x40},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Effect_Green[] =
+{
+ // Greenish
+ {0x3391, 0x18},
+ {0x3396, 0x60},
+ {0x3397, 0x60},
+ {0x0000, 0x00}
+};
+static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
+ sensor_Effect_Bluish, sensor_Effect_Green,NULL,
+};
+#endif
+#if CONFIG_SENSOR_Exposure
+static struct reginfo sensor_Exposure0[]=
+{
+ //-3
+ {0x3047, 0x05},
+ {0x3018, 0x40},
+ {0x3019, 0x30},
+ {0x301a, 0x71},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Exposure1[]=
+{
+ //-2
+ {0x3047, 0x05},
+ {0x3018, 0x5a},
+ {0x3019, 0x4a},
+ {0x301a, 0xc2},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Exposure2[]=
+{
+ //-0.3EV
+ {0x3047, 0x05},
+ {0x3018, 0x6a},
+ {0x3019, 0x5a},
+ {0x301a, 0xd4},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Exposure3[]=
+{
+ //default
+ {0x3047, 0x05},
+ {0x3018, 0x78},
+ {0x3019, 0x68},
+ {0x301a, 0xd4},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Exposure4[]=
+{
+ // 1
+ {0x3047, 0x05},
+ {0x3018, 0x88},
+ {0x3019, 0x78},
+ {0x301a, 0xd5},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Exposure5[]=
+{
+ // 2
+ {0x3047, 0x05},
+ {0x3018, 0xa8},
+ {0x3019, 0x98},
+ {0x301a, 0xe6},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Exposure6[]=
+{
+ // 3
+ {0x3047, 0x05},
+ {0x3018, 0xc8},
+ {0x3019, 0xb8},
+ {0x301a, 0xf7},
+ {0x0000, 0x00}
+};
+
+static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
+ sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
+};
+#endif
+#if CONFIG_SENSOR_Saturation
+static struct reginfo sensor_Saturation0[]=
+{
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x02},
+ {0x3394, 0x40},
+ {0x3395, 0x40},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Saturation1[]=
+{
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x02},
+ {0x3394, 0x50},
+ {0x3395, 0x50},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Saturation2[]=
+{
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x02}, //enable color saturation
+ {0x3394, 0x70},
+ {0x3395, 0x70},
+ {0x0000, 0x00}
+};
+static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
+
+#endif
+#if CONFIG_SENSOR_Contrast
+static struct reginfo sensor_Contrast0[]=
+{
+ //Contrast -3
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x45},
+ {0x3398, 0x18},
+ {0x3399, 0x18},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Contrast1[]=
+{
+ //Contrast -2
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x45},
+ {0x3398, 0x18},
+ {0x3399, 0x18},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Contrast2[]=
+{
+ // Contrast -1
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x45},
+ {0x3398, 0x1c},
+ {0x3399, 0x1c},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Contrast3[]=
+{
+ //Contrast 0
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x00},
+ {0x3390, 0x41},
+ {0x3398, 0x20},
+ {0x3399, 0x20},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Contrast4[]=
+{
+ //Contrast +1
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x45},
+ {0x3398, 0x24},
+ {0x3399, 0x24},
+ {0x0000, 0x00}
+};
+
+
+static struct reginfo sensor_Contrast5[]=
+{
+ //Contrast +2
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x45},
+ {0x3398, 0x28},
+ {0x3399, 0x28},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Contrast6[]=
+{
+ //Contrast +3
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04}, //bit[2] enable contrast/brightness
+ {0x3390, 0x45}, //bit[2] Yoffset sign
+ {0x3398, 0x2c},
+ {0x3399, 0x2c},
+ {0x0000, 0x00}
+};
+static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
+ sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
+};
+
+#endif
+#if CONFIG_SENSOR_Mirror
+static struct reginfo sensor_MirrorOn[]=
{
- // Brightness +2
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x04},
- {0x3390, 0x41},
- {0x339a, 0x20},
+ {0x3069, 0x84},
+ {0x307c, 0x13},
+ {0x3087, 0x02},
{0x0000, 0x00}
};
-static struct reginfo ov2655_Brightness5[]=
+static struct reginfo sensor_MirrorOff[]=
{
- // Brightness +3
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x04}, //bit[2] enable
- {0x3390, 0x41}, //bit[3] sign of brightness
- {0x339a, 0x30},
+ {0x3069, 0x84},
+ {0x307c, 0x10},
+ {0x3087, 0x02},
{0x0000, 0x00}
};
-
-static struct reginfo ov2655_Effect_Normal[] =
+static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
+#endif
+#if CONFIG_SENSOR_Flip
+static struct reginfo sensor_FlipOn[]=
{
- {0x3391, 0x00},
+ {0x300e, 0x34},
+ {0x300f, 0xa6},
+ {0x3010, 0x81},
+ {0x3082, 0x01},
+ {0x30f4, 0x01},
+ {0x3090, 0x3b},
+ {0x3091, 0xc0},
+ {0x30ac, 0x42},
{0x0000, 0x00}
};
-static struct reginfo ov2655_Effect_WandB[] =
+static struct reginfo sensor_FlipOff[]=
{
- {0x3391, 0x20},
+ {0x300e, 0x34},
+ {0x300f, 0xa6},
+ {0x3010, 0x81},
+ {0x3082, 0x01},
+ {0x30f4, 0x01},
+ {0x3090, 0x33},
+ {0x3091, 0xc0},
+ {0x30ac, 0x42},
{0x0000, 0x00}
};
+static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
-static struct reginfo ov2655_Effect_Sepia[] =
+#endif
+#if CONFIG_SENSOR_Scene
+static struct reginfo sensor_SceneAuto[] =
{
- {0x3391, 0x18},
- {0x3396, 0x40},
- {0x3397, 0xa6},
+#if 0 /* ddl@rock-chips.com : */
+ {0x3014, 0x04},
+ {0x3015, 0x00},
+ {0x302e, 0x00},
+ {0x302d, 0x00},
+ {0x0000, 0x00}
+#else
+ {0x3014, 0x84},
+ {0x3015, 0x02},
+ {0x302e, 0x00},
+ {0x302d, 0x00},
{0x0000, 0x00}
+#endif
};
-static struct reginfo ov2655_Effect_Negative[] =
+static struct reginfo sensor_SceneNight[] =
{
- //Negative
- {0x3391, 0x40}, //bit[6] negative
+#if 1
+ //30fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,36Mzh pclk
+ {0x300e, 0x34},
+ {0x3011, 0x00},
+ {0x302c, 0x00},
+ {0x3071, 0x00},
+ {0x3070, 0xb9},
+ {0x301c, 0x02},
+ {0x3073, 0x00},
+ {0x3072, 0x9a},
+ {0x301d, 0x03},
+ {0x3014, 0x0c},
+ {0x3015, 0x50},//add 5 dummy frame
+ {0x302e, 0x00},
+ {0x302d, 0x00},
{0x0000, 0x00}
+#else
+ //15fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,18Mhz pclk
+ {0x300e, 0x34},
+ {0x3011, 0x01},
+ {0x302c, 0x00},
+ {0x3071, 0x00},
+ {0x3070, 0x5d},
+ {0x301c, 0x05},
+ {0x3073, 0x00},
+ {0x3072, 0x4d},
+ {0x301d, 0x07},
+ {0x3014, 0x0c},
+ {0x3015, 0x50},
+ {0x302e, 0x00},
+ {0x302d, 0x00},
+#endif
};
-static struct reginfo ov2655_Effect_Bluish[] =
+static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
+
+#endif
+#if CONFIG_SENSOR_DigitalZoom
+static struct reginfo sensor_Zoom0[] =
{
- // Bluish
- {0x3391, 0x18},
- {0x3396, 0xa0},
- {0x3397, 0x40},
- {0x0000, 0x00}
+ {0x0, 0x0},
};
-static struct reginfo ov2655_Effect_Green[] =
+static struct reginfo sensor_Zoom1[] =
{
- // Greenish
- {0x3391, 0x18},
- {0x3396, 0x60},
- {0x3397, 0x60},
- {0x0000, 0x00}
+ {0x0, 0x0},
};
-static struct reginfo ov2655_Exposure0[]=
+
+static struct reginfo sensor_Zoom2[] =
{
- //-3
- {0x3047, 0x05},
- {0x3018, 0x40},
- {0x3019, 0x30},
- {0x301a, 0x71},
- {0x0000, 0x00}
+ {0x0, 0x0},
};
-static struct reginfo ov2655_Exposure1[]=
+
+static struct reginfo sensor_Zoom3[] =
{
- //-2
- {0x3047, 0x05},
- {0x3018, 0x5a},
- {0x3019, 0x4a},
- {0x301a, 0xc2},
- {0x0000, 0x00}
+ {0x0, 0x0},
};
-
-static struct reginfo ov2655_Exposure2[]=
+static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
+#endif
+static const struct v4l2_querymenu sensor_menus[] =
{
- //-0.3EV
- {0x3047, 0x05},
- {0x3018, 0x6a},
- {0x3019, 0x5a},
- {0x301a, 0xd4},
- {0x0000, 0x00}
+ #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,},
+ { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
+ { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
+ #endif
+
+ #if CONFIG_SENSOR_Effect
+ { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
+ { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
+ { .id = V4L2_CID_EFFECT, .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT, .index = 5, .name = "aqua", .reserved = 0,},
+ #endif
+
+ #if CONFIG_SENSOR_Scene
+ { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
+ #endif
+
+ #if CONFIG_SENSOR_Flash
+ { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
+ { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
+ #endif
};
-static struct reginfo ov2655_Exposure3[]=
+static const struct v4l2_queryctrl sensor_controls[] =
{
- //default
- {0x3047, 0x05},
- {0x3018, 0x78},
- {0x3019, 0x68},
- {0x301a, 0xd4},
- {0x0000, 0x00}
+ #if CONFIG_SENSOR_WhiteBalance
+ {
+ .id = V4L2_CID_DO_WHITE_BALANCE,
+ .type = V4L2_CTRL_TYPE_MENU,
+ .name = "White Balance Control",
+ .minimum = 0,
+ .maximum = 4,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Brightness
+ {
+ .id = V4L2_CID_BRIGHTNESS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Brightness Control",
+ .minimum = -3,
+ .maximum = 2,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Effect
+ {
+ .id = V4L2_CID_EFFECT,
+ .type = V4L2_CTRL_TYPE_MENU,
+ .name = "Effect Control",
+ .minimum = 0,
+ .maximum = 5,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Exposure
+ {
+ .id = V4L2_CID_EXPOSURE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Exposure Control",
+ .minimum = 0,
+ .maximum = 6,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Saturation
+ {
+ .id = V4L2_CID_SATURATION,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Saturation Control",
+ .minimum = 0,
+ .maximum = 2,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Contrast
+ {
+ .id = V4L2_CID_CONTRAST,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Contrast Control",
+ .minimum = -3,
+ .maximum = 3,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Mirror
+ {
+ .id = V4L2_CID_HFLIP,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "Mirror Control",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 1,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Flip
+ {
+ .id = V4L2_CID_VFLIP,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "Flip Control",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 1,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Scene
+ {
+ .id = V4L2_CID_SCENE,
+ .type = V4L2_CTRL_TYPE_MENU,
+ .name = "Scene Control",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_DigitalZoom
+ {
+ .id = V4L2_CID_ZOOM_RELATIVE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "DigitalZoom Control",
+ .minimum = -1,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ }, {
+ .id = V4L2_CID_ZOOM_ABSOLUTE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "DigitalZoom Control",
+ .minimum = 0,
+ .maximum = 3,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Focus
+ {
+ .id = V4L2_CID_FOCUS_RELATIVE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Focus Control",
+ .minimum = -1,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ }, {
+ .id = V4L2_CID_FOCUS_ABSOLUTE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Focus Control",
+ .minimum = 0,
+ .maximum = 255,
+ .step = 1,
+ .default_value = 125,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Flash
+ {
+ .id = V4L2_CID_FLASH,
+ .type = V4L2_CTRL_TYPE_MENU,
+ .name = "Flash Control",
+ .minimum = 0,
+ .maximum = 3,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
};
-static struct reginfo ov2655_Exposure4[]=
-{
- // 1
- {0x3047, 0x05},
- {0x3018, 0x88},
- {0x3019, 0x78},
- {0x301a, 0xd5},
- {0x0000, 0x00}
-};
+static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
+static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
+static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
+static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
+static int sensor_resume(struct soc_camera_device *icd);
+static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
-static struct reginfo ov2655_Exposure5[]=
+static struct soc_camera_ops sensor_ops =
{
- // 2
- {0x3047, 0x05},
- {0x3018, 0xa8},
- {0x3019, 0x98},
- {0x301a, 0xe6},
- {0x0000, 0x00}
+ .suspend = sensor_suspend,
+ .resume = sensor_resume,
+ .set_bus_param = sensor_set_bus_param,
+ .query_bus_param = sensor_query_bus_param,
+ .controls = sensor_controls,
+ .menus = sensor_menus,
+ .num_controls = ARRAY_SIZE(sensor_controls),
+ .num_menus = ARRAY_SIZE(sensor_menus),
};
-static struct reginfo ov2655_Exposure6[]=
-{
- // 3
- {0x3047, 0x05},
- {0x3018, 0xc8},
- {0x3019, 0xb8},
- {0x301a, 0xf7},
- {0x0000, 0x00}
-};
+#define COL_FMT(_name, _depth, _fourcc, _colorspace) \
+ { .name = _name, .depth = _depth, .fourcc = _fourcc, \
+ .colorspace = _colorspace }
-static struct reginfo ov2655_Saturation0[]=
-{
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x02},
- {0x3394, 0x40},
- {0x3395, 0x40},
- {0x0000, 0x00}
-};
+#define JPG_FMT(_name, _depth, _fourcc) \
+ COL_FMT(_name, _depth, _fourcc, V4L2_COLORSPACE_JPEG)
-static struct reginfo ov2655_Saturation1[]=
-{
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x02},
- {0x3394, 0x50},
- {0x3395, 0x50},
- {0x0000, 0x00}
+static const struct soc_camera_data_format sensor_colour_formats[] = {
+ JPG_FMT(SENSOR_NAME_STRING(UYVY), 16, V4L2_PIX_FMT_UYVY),
+ JPG_FMT(SENSOR_NAME_STRING(YUYV), 16, V4L2_PIX_FMT_YUYV),
};
-static struct reginfo ov2655_Saturation2[]=
+typedef struct sensor_info_priv_s
{
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x02}, //enable color saturation
- {0x3394, 0x70},
- {0x3395, 0x70},
- {0x0000, 0x00}
-};
+ int whiteBalance;
+ int brightness;
+ int contrast;
+ int saturation;
+ int effect;
+ int scene;
+ int digitalzoom;
+ int focus;
+ int flash;
+ int exposure;
+ unsigned char mirror; /* HFLIP */
+ unsigned char flip; /* VFLIP */
+ unsigned int winseqe_cur_addr;
+} sensor_info_priv_t;
-static struct reginfo ov2655_Contrast0[]=
+struct sensor
{
- //Contrast -3
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x04},
- {0x3390, 0x45},
- {0x3398, 0x18},
- {0x3399, 0x18},
- {0x0000, 0x00}
+ struct v4l2_subdev subdev;
+ struct i2c_client *client;
+ sensor_info_priv_t info_priv;
+ unsigned int pixfmt;
+ int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
};
-static struct reginfo ov2655_Contrast1[]=
+static struct sensor* to_sensor(const struct i2c_client *client)
{
- //Contrast -2
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x04},
- {0x3390, 0x45},
- {0x3398, 0x18},
- {0x3399, 0x18},
- {0x0000, 0x00}
-};
+ return container_of(i2c_get_clientdata(client), struct sensor, subdev);
+}
-static struct reginfo ov2655_Contrast2[]=
+/* sensor register write */
+static int sensor_write(struct i2c_client *client, u16 reg, u8 val)
{
- // Contrast -1
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x04},
- {0x3390, 0x45},
- {0x3398, 0x1c},
- {0x3399, 0x1c},
- {0x0000, 0x00}
-};
+ int err,cnt;
+ u8 buf[3];
+ struct i2c_msg msg[1];
-static struct reginfo ov2655_Contrast3[]=
-{
- //Contrast 0
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x00},
- {0x3390, 0x41},
- {0x3398, 0x20},
- {0x3399, 0x20},
- {0x0000, 0x00}
-};
+ buf[0] = reg >> 8;
+ buf[1] = reg & 0xFF;
+ buf[2] = val;
+
+ msg->addr = client->addr;
+ msg->flags = client->flags;
+ msg->buf = buf;
+ msg->len = sizeof(buf);
+ msg->scl_rate = 400*1000; /* ddl@rock-chips.com : 100kHz */
+ msg->read_type = I2C_NORMAL;
+
+ cnt = 3;
+ err = -EAGAIN;
+
+ while ((cnt--) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
+ err = i2c_transfer(client->adapter, msg, 1);
+
+ if (err >= 0) {
+ return 0;
+ } else {
+ SENSOR_TR("\n %s write reg failed, try to write again!\n",SENSOR_NAME_STRING());
+ udelay(10);
+ }
+ }
+
+ return err;
+}
-static struct reginfo ov2655_Contrast4[]=
+/* sensor register read */
+static int sensor_read(struct i2c_client *client, u16 reg, u8 *val)
{
- //Contrast +1
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x04},
- {0x3390, 0x45},
- {0x3398, 0x24},
- {0x3399, 0x24},
- {0x0000, 0x00}
-};
+ int err,cnt;
+ u8 buf[2];
+ struct i2c_msg msg[2];
+
+ buf[0] = reg >> 8;
+ buf[1] = reg & 0xFF;
+
+ msg[0].addr = client->addr;
+ msg[0].flags = client->flags;
+ msg[0].buf = buf;
+ msg[0].len = sizeof(buf);
+ msg[0].scl_rate = 400*1000; /* ddl@rock-chips.com : 100kHz */
+ msg[0].read_type = I2C_NO_STOP; /* */
+
+ msg[1].addr = client->addr;
+ msg[1].flags = client->flags|I2C_M_RD;
+ msg[1].buf = buf;
+ msg[1].len = 1;
+ msg[1].scl_rate = 100*1000; /* ddl@rock-chips.com : 100kHz */
+ msg[1].read_type = I2C_NO_STOP; /* */
+
+ cnt = 3;
+ err = -EAGAIN;
+ while ((cnt--) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
+ err = i2c_transfer(client->adapter, msg, 2);
+
+ if (err >= 0) {
+ *val = buf[0];
+ return 0;
+ } else {
+ SENSOR_TR("\n %s read reg failed, try to read again!\n",SENSOR_NAME_STRING());
+ udelay(10);
+ }
+ }
+ return err;
+}
-static struct reginfo ov2655_Contrast5[]=
+/* write a array of registers */
+static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
{
- //Contrast +2
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x04},
- {0x3390, 0x45},
- {0x3398, 0x28},
- {0x3399, 0x28},
- {0x0000, 0x00}
-};
+ int err;
+ int i = 0;
+
+ while (regarray[i].reg != 0)
+ {
+ err = sensor_write(client, regarray[i].reg, regarray[i].val);
+ if (err != 0)
+ {
+ SENSOR_TR("%s..write failed current i = %d\n", SENSOR_NAME_STRING(),i);
+ return err;
+ }
+ i++;
+ }
+ return 0;
+}
-static struct reginfo ov2655_Contrast6[]=
+static int sensor_init(struct v4l2_subdev *sd, u32 val)
{
- //Contrast +3
- {0x3301, 0xff},//bit[7]:1, enable SDE
- {0x3391, 0x04}, //bit[2] enable contrast/brightness
- {0x3390, 0x45}, //bit[2] Yoffset sign
- {0x3398, 0x2c},
- {0x3399, 0x2c},
- {0x0000, 0x00}
-};
+ struct i2c_client *client = sd->priv;
+ struct soc_camera_device *icd = client->dev.platform_data;
+ struct sensor *sensor = to_sensor(client);
+ const struct v4l2_queryctrl *qctrl;
+ int ret;
+
+ SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
+
+ /* soft reset */
+ ret = sensor_write(client, 0x3012, 0x80);
+ if (ret != 0)
+ {
+ SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
+ ret = -ENODEV;
+ goto sensor_INIT_ERR;
+ }
+
+ mdelay(5); //delay 5 microseconds
-static struct reginfo ov2655_MirrorOn[]=
+ ret = sensor_write_array(client, sensor_init_data);
+ if (ret != 0)
+ {
+ SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
+ goto sensor_INIT_ERR;
+ }
+
+ icd->user_width = SENSOR_INIT_WIDTH;
+ icd->user_height = SENSOR_INIT_HEIGHT;
+ sensor->info_priv.winseqe_cur_addr = (int)SENSOR_INIT_WINSEQADR;
+
+ /* sensor sensor information for initialization */
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
+ if (qctrl)
+ sensor->info_priv.whiteBalance = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
+ if (qctrl)
+ sensor->info_priv.brightness = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
+ if (qctrl)
+ sensor->info_priv.effect = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
+ if (qctrl)
+ sensor->info_priv.exposure = qctrl->default_value;
+
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
+ if (qctrl)
+ sensor->info_priv.saturation = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
+ if (qctrl)
+ sensor->info_priv.contrast = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
+ if (qctrl)
+ sensor->info_priv.mirror = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
+ if (qctrl)
+ sensor->info_priv.flip = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
+ if (qctrl)
+ sensor->info_priv.scene = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
+ if (qctrl)
+ sensor->info_priv.digitalzoom = qctrl->default_value;
+
+ /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
+ #if CONFIG_SENSOR_Focus
+ sensor_set_focus();
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
+ if (qctrl)
+ sensor->info_priv.focus = qctrl->default_value;
+ #endif
+
+ #if CONFIG_SENSOR_Flash
+ sensor_set_flash();
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
+ if (qctrl)
+ sensor->info_priv.flash = qctrl->default_value;
+ #endif
+
+ SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,icd->user_width,icd->user_height);
+
+ return 0;
+sensor_INIT_ERR:
+ return ret;
+}
+
+static struct reginfo sensor_power_down_sequence[]=
{
- {0x3069, 0x84},
- {0x307c, 0x13},
- {0x3087, 0x02},
- {0x0000, 0x00}
+ {0x30ab, 0x00},
+ {0x30ad, 0x0a},
+ {0x30ae,0x27},
+ {0x363b,0x01},
+ {0x00,0x00}
};
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
+{
+ int ret;
+ struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+ struct soc_camera_link *icl;
+
+
+ if (pm_msg.event == PM_EVENT_SUSPEND)
+ {
+ SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
+ ret = sensor_write_array(client, sensor_power_down_sequence) ;
+ if (ret != 0)
+ {
+ SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
+ return ret;
+ }
+ else
+ {
+ icl = to_soc_camera_link(icd);
+ if (icl->power) {
+ ret = icl->power(icd->pdev, 0);
+ if (ret < 0)
+ return -EINVAL;
+ }
+ }
+ }
+ else
+ {
+ SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
+ return -EINVAL;
+ }
+ return 0;
+}
-static struct reginfo ov2655_MirrorOff[]=
+static int sensor_resume(struct soc_camera_device *icd)
{
- {0x3069, 0x84},
- {0x307c, 0x10},
- {0x3087, 0x02},
- {0x0000, 0x00}
-};
+ struct soc_camera_link *icl;
+ int ret;
-static struct reginfo ov2655_FlipOn[]=
-{
- {0x300e, 0x34},
- {0x300f, 0xa6},
- {0x3010, 0x81},
- {0x3082, 0x01},
- {0x30f4, 0x01},
- {0x3090, 0x3b},
- {0x3091, 0xc0},
- {0x30ac, 0x42},
- {0x0000, 0x00}
-};
+ icl = to_soc_camera_link(icd);
+ if (icl->power) {
+ ret = icl->power(icd->pdev, 0);
+ if (ret < 0)
+ return -EINVAL;
+ }
-static struct reginfo ov2655_FlipOff[]=
-{
- {0x300e, 0x34},
- {0x300f, 0xa6},
- {0x3010, 0x81},
- {0x3082, 0x01},
- {0x30f4, 0x01},
- {0x3090, 0x33},
- {0x3091, 0xc0},
- {0x30ac, 0x42},
- {0x0000, 0x00}
-};
+ return 0;
-static struct reginfo ov2655_SceneAuto[] =
-{
-#if 0 /* ddl@rock-chips.com : */
- {0x3014, 0x04},
- {0x3015, 0x00},
- {0x302e, 0x00},
- {0x302d, 0x00},
- {0x0000, 0x00}
-#else
- {0x3014, 0x84},
- {0x3015, 0x02},
- {0x302e, 0x00},
- {0x302d, 0x00},
- {0x0000, 0x00}
-#endif
-};
+}
-static struct reginfo ov2655_SceneNight[] =
+static int sensor_set_bus_param(struct soc_camera_device *icd,
+ unsigned long flags)
{
-#if 1
- //30fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,36Mzh pclk
- {0x300e, 0x34},
- {0x3011, 0x00},
- {0x302c, 0x00},
- {0x3071, 0x00},
- {0x3070, 0xb9},
- {0x301c, 0x02},
- {0x3073, 0x00},
- {0x3072, 0x9a},
- {0x301d, 0x03},
- {0x3014, 0x0c},
- {0x3015, 0x50},//add 5 dummy frame
- {0x302e, 0x00},
- {0x302d, 0x00},
- {0x0000, 0x00}
-#else
- //15fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,18Mhz pclk
- {0x300e, 0x34},
- {0x3011, 0x01},
- {0x302c, 0x00},
- {0x3071, 0x00},
- {0x3070, 0x5d},
- {0x301c, 0x05},
- {0x3073, 0x00},
- {0x3072, 0x4d},
- {0x301d, 0x07},
- {0x3014, 0x0c},
- {0x3015, 0x50},
- {0x302e, 0x00},
- {0x302d, 0x00},
-#endif
-};
+ return 0;
+}
-static struct reginfo ov2655_Zoom0[] =
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
{
- {0x0, 0x0},
-};
+ struct soc_camera_link *icl = to_soc_camera_link(icd);
+ unsigned long flags = SENSOR_BUS_PARAM;
-static struct reginfo ov2655_Zoom1[] =
-{
- {0x0, 0x0},
-};
+ return soc_camera_apply_sensor_flags(icl, flags);
+}
-static struct reginfo ov2655_Zoom2[] =
+static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
{
- {0x0, 0x0},
-};
+ struct i2c_client *client = sd->priv;
+ struct soc_camera_device *icd = client->dev.platform_data;
+ struct sensor *sensor = to_sensor(client);
+ struct v4l2_pix_format *pix = &f->fmt.pix;
+ pix->width = icd->user_width;
+ pix->height = icd->user_height;
+ pix->pixelformat = sensor->pixfmt;
+ pix->field = V4L2_FIELD_NONE;
+ pix->colorspace = V4L2_COLORSPACE_JPEG;
-static struct reginfo ov2655_Zoom3[] =
+ return 0;
+}
+static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
{
- {0x0, 0x0},
-};
+ struct i2c_client *client = sd->priv;
+ struct sensor *sensor = to_sensor(client);
+ struct v4l2_pix_format *pix = &f->fmt.pix;
+ struct reginfo *winseqe_set_addr;
+ int ret, set_w,set_h;
-static struct reginfo *ov2655_ExposureSeqe[] = {ov2655_Exposure0, ov2655_Exposure1, ov2655_Exposure2, ov2655_Exposure3,
- ov2655_Exposure4, ov2655_Exposure5,ov2655_Exposure6,NULL,
-};
+ set_w = pix->width;
+ set_h = pix->height;
-static struct reginfo *ov2655_EffectSeqe[] = {ov2655_Effect_Normal, ov2655_Effect_WandB, ov2655_Effect_Negative,ov2655_Effect_Sepia,
- ov2655_Effect_Bluish, ov2655_Effect_Green,NULL,
-};
+ if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+ {
+ winseqe_set_addr = sensor_qcif;
+ set_w = 176;
+ set_h = 144;
+ }
+ else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+ {
+ winseqe_set_addr = sensor_qvga;
+ set_w = 320;
+ set_h = 240;
+ }
+ else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+ {
+ winseqe_set_addr = sensor_cif;
+ set_w = 352;
+ set_h = 288;
+ }
+ else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+ {
+ winseqe_set_addr = sensor_vga;
+ set_w = 640;
+ set_h = 480;
+ }
+ else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg)
+ {
+ winseqe_set_addr = sensor_svga;
+ set_w = 800;
+ set_h = 600;
+ }
+ else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+ {
+ winseqe_set_addr = sensor_sxga;
+ set_w = 1280;
+ set_h = 1024;
+ }
+ else if (((set_w <= 1600) && (set_h <= 1200)) && sensor_uxga[0].reg)
+ {
+ winseqe_set_addr = sensor_uxga;
+ set_w = 1600;
+ set_h = 1200;
+ }
+ else if (sensor_qvga[0].reg)
+ {
+ winseqe_set_addr = sensor_qvga; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */
+ set_w = 320;
+ set_h = 240;
+ }
+ else
+ {
+ SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,pix->width,pix->height);
+ return -EINVAL;
+ }
-static struct reginfo *ov2655_WhiteBalanceSeqe[] = {ov2655_WhiteB_Auto, ov2655_WhiteB_TungstenLamp1,ov2655_WhiteB_TungstenLamp2,
- ov2655_WhiteB_ClearDay, ov2655_WhiteB_Cloudy,NULL,
-};
+ if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr)
+ {
+ ret = sensor_write_array(client, winseqe_set_addr);
+ if (ret != 0)
+ {
+ SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
+ return ret;
+ }
-static struct reginfo *ov2655_BrightnessSeqe[] = {ov2655_Brightness0, ov2655_Brightness1, ov2655_Brightness2, ov2655_Brightness3,
- ov2655_Brightness4, ov2655_Brightness5,NULL,
-};
+ sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
+ mdelay(250);
-static struct reginfo *ov2655_ContrastSeqe[] = {ov2655_Contrast0, ov2655_Contrast1, ov2655_Contrast2, ov2655_Contrast3,
- ov2655_Contrast4, ov2655_Contrast5, ov2655_Contrast6, NULL,
-};
+ SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
+ }
+ else
+ {
+ SENSOR_TR("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
+ }
-static struct reginfo *ov2655_SaturationSeqe[] = {ov2655_Saturation0, ov2655_Saturation1, ov2655_Saturation2, NULL,};
+ return 0;
+}
-static struct reginfo *ov2655_MirrorSeqe[] = {ov2655_MirrorOff, ov2655_MirrorOn,NULL,};
+static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+{
+ struct v4l2_pix_format *pix = &f->fmt.pix;
+ bool bayer = pix->pixelformat == V4L2_PIX_FMT_UYVY ||
+ pix->pixelformat == V4L2_PIX_FMT_YUYV;
-static struct reginfo *ov2655_FlipSeqe[] = {ov2655_FlipOff, ov2655_FlipOn,NULL,};
+ /*
+ * With Bayer format enforce even side lengths, but let the user play
+ * with the starting pixel
+ */
-static struct reginfo *ov2655_SceneSeqe[] = {ov2655_SceneAuto, ov2655_SceneNight,NULL,};
+ if (pix->height > SENSOR_MAX_HEIGHT)
+ pix->height = SENSOR_MAX_HEIGHT;
+ else if (pix->height < SENSOR_MIN_HEIGHT)
+ pix->height = SENSOR_MIN_HEIGHT;
+ else if (bayer)
+ pix->height = ALIGN(pix->height, 2);
-static struct reginfo *ov2655_ZoomSeqe[] = {ov2655_Zoom0, ov2655_Zoom1, ov2655_Zoom2, ov2655_Zoom3, NULL,};
+ if (pix->width > SENSOR_MAX_WIDTH)
+ pix->width = SENSOR_MAX_WIDTH;
+ else if (pix->width < SENSOR_MIN_WIDTH)
+ pix->width = SENSOR_MIN_WIDTH;
+ else if (bayer)
+ pix->width = ALIGN(pix->width, 2);
+ return 0;
+}
-static const struct v4l2_querymenu ov2655_menus[] =
+ static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
{
- { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
- { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
- { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
- { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
- { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
- { .id = V4L2_CID_EFFECT, .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT, .index = 5, .name = "aqua", .reserved = 0,},
- { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
- { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
- { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
-};
+ struct i2c_client *client = sd->priv;
-static struct soc_camera_ops ov2655_ops =
-{
- .suspend = ov2655_suspend,
- .resume = ov2655_resume,
- .set_bus_param = ov2655_set_bus_param,
- .query_bus_param = ov2655_query_bus_param,
- .controls = ov2655_controls,
- .menus = ov2655_menus,
- .num_controls = ARRAY_SIZE(ov2655_controls),
- .num_menus = ARRAY_SIZE(ov2655_menus),
-};
-static int ov2655_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+ if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
+ return -EINVAL;
+
+ if (id->match.addr != client->addr)
+ return -ENODEV;
+
+ id->ident = SENSOR_V4L2_IDENT; /* ddl@rock-chips.com : Return OV2655 identifier */
+ id->revision = 0;
+
+ return 0;
+}
+#if CONFIG_SENSOR_Brightness
+static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov2655_BrightnessSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
{
- if (ov2655_write_array(client, ov2655_BrightnessSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
{
- OV2655_TR("\n OV2655 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("\n OV2655 Set Brightness - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-static int ov2655_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Effect
+static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov2655_EffectSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
{
- if (ov2655_write_array(client, ov2655_EffectSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)
{
- OV2655_TR("\n OV2655 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("\n OV2655 Set effect - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-static int ov2655_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Exposure
+static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov2655_ExposureSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
{
- if (ov2655_write_array(client, ov2655_ExposureSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
{
- OV2655_TR("\n OV2655 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("\n OV2655 Set Exposurce - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov2655_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Saturation
+static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov2655_SaturationSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
{
- if (ov2655_write_array(client, ov2655_SaturationSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
{
- OV2655_TR("\n OV2655 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("\n OV2655 Set Saturation - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV2655_TR("\n Saturation valure = %d is invalidate.. ******** ddl *********\n",value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov2655_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Contrast
+static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov2655_ContrastSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
{
- if (ov2655_write_array(client, ov2655_ContrastSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
{
- OV2655_TR("\n OV2655 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("\n OV2655 Set Contrast - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV2655_TR("\n Contrast valure = %d is invalidate.. ******** ddl *********\n", value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov2655_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Mirror
+static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov2655_MirrorSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)
{
- if (ov2655_write_array(client, ov2655_MirrorSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 0)
{
- OV2655_TR("\n OV2655 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("\n OV2655 Set Mirror - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV2655_TR("\n Mirror valure = %d is invalidate.. ******** ddl *********\n", value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-
-static int ov2655_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Flip
+static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov2655_FlipSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)
{
- if (ov2655_write_array(client, ov2655_FlipSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)
{
- OV2655_TR("\n OV2655 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("\n OV2655 Set Flip - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV2655_TR("\n Flip valure = %d is invalidate.. ******** ddl *********\n", value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov2655_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Scene
+static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov2655_SceneSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
{
- if (ov2655_write_array(client, ov2655_SceneSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
{
- OV2655_TR("\n OV2655 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("\n OV2655 Set Scene - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV2655_TR("\n Scene valure = %d is invalidate.. ******** ddl *********\n", value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov2655_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_WhiteBalance
+static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
-
+
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov2655_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
{
- if (ov2655_write_array(client, ov2655_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
{
- OV2655_TR("OV2655 WriteReg Fail.. %x\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("ov2655_set_whiteBalance - %x\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov2655_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)
+#endif
+#if CONFIG_SENSOR_DigitalZoom
+static int sensor_set_digitalzoom(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 ov2655 *ov2655 = to_ov2655(client);
+ struct sensor *sensor = to_sensor(client);
+ const struct v4l2_queryctrl *qctrl_info;
int digitalzoom_cur, digitalzoom_total;
-
- digitalzoom_cur = ov2655->info_priv.digitalzoom;
- digitalzoom_total = ov2655_controls[10].maximum;
-
+
+ qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
+ if (qctrl_info)
+ return -EINVAL;
+
+ digitalzoom_cur = sensor->info_priv.digitalzoom;
+ digitalzoom_total = qctrl_info->maximum;
+
if ((*value > 0) && (digitalzoom_cur >= digitalzoom_total))
{
- OV2655_TR("ov2655 digitalzoom is maximum - %x\n", digitalzoom_cur);
+ SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
return -EINVAL;
}
- if ((*value < 0) && (digitalzoom_cur <= ov2655_controls[10].minimum))
+ if ((*value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
{
- OV2655_TR("ov2655 digitalzoom is minimum - %x\n", digitalzoom_cur);
+ SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
return -EINVAL;
}
- if ((*value > 0) && ((digitalzoom_cur + *value) > digitalzoom_total))
+ if ((*value > 0) && ((digitalzoom_cur + *value) > digitalzoom_total))
{
*value = digitalzoom_total - digitalzoom_cur;
}
- if ((*value < 0) && ((digitalzoom_cur + *value) < 0))
+ if ((*value < 0) && ((digitalzoom_cur + *value) < 0))
{
*value = 0 - digitalzoom_cur;
}
-
- digitalzoom_cur += *value;
-
- if (ov2655_ZoomSeqe[digitalzoom_cur] != NULL)
+
+ digitalzoom_cur += *value;
+
+ if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
{
- if (ov2655_write_array(client, ov2655_ZoomSeqe[digitalzoom_cur]) != 0)
+ if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
{
- OV2655_TR("OV2655 WriteReg Fail.. %x\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV2655_DG("ov2655_set_digitalzoom - %x\n", *value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, *value);
return 0;
}
-
+
return -EINVAL;
}
-
-static int ov2655_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+#endif
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
struct i2c_client *client = sd->priv;
- struct ov2655 *ov2655 = to_ov2655(client);
+ struct sensor *sensor = to_sensor(client);
const struct v4l2_queryctrl *qctrl;
- qctrl = soc_camera_find_qctrl(&ov2655_ops, ctrl->id);
+ qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
if (!qctrl)
{
- OV2655_TR("\n%s..%s..%d.. ioctrl is faild ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
+ SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
return -EINVAL;
}
{
case V4L2_CID_BRIGHTNESS:
{
- ctrl->value = ov2655->info_priv.brightness;
+ ctrl->value = sensor->info_priv.brightness;
break;
}
case V4L2_CID_SATURATION:
{
- ctrl->value = ov2655->info_priv.saturation;
+ ctrl->value = sensor->info_priv.saturation;
break;
}
case V4L2_CID_CONTRAST:
{
- ctrl->value = ov2655->info_priv.contrast;
+ ctrl->value = sensor->info_priv.contrast;
break;
}
case V4L2_CID_DO_WHITE_BALANCE:
{
- ctrl->value = ov2655->info_priv.whiteBalance;
+ ctrl->value = sensor->info_priv.whiteBalance;
break;
}
case V4L2_CID_EXPOSURE:
{
- ctrl->value = ov2655->info_priv.exposure;
+ ctrl->value = sensor->info_priv.exposure;
break;
}
case V4L2_CID_HFLIP:
{
- ctrl->value = ov2655->info_priv.mirror;
+ ctrl->value = sensor->info_priv.mirror;
break;
}
case V4L2_CID_VFLIP:
{
- ctrl->value = ov2655->info_priv.flip;
+ ctrl->value = sensor->info_priv.flip;
break;
}
default :
-static int ov2655_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
struct i2c_client *client = sd->priv;
- struct ov2655 *ov2655 = to_ov2655(client);
+ struct sensor *sensor = to_sensor(client);
struct soc_camera_device *icd = client->dev.platform_data;
const struct v4l2_queryctrl *qctrl;
- qctrl = soc_camera_find_qctrl(&ov2655_ops, ctrl->id);
+ qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
if (!qctrl)
{
- OV2655_TR("\n OV2655 ioctrl id = %x is invalidate ******** ddl *********\n", ctrl->id);
+ SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
return -EINVAL;
}
switch (ctrl->id)
{
+#if CONFIG_SENSOR_Brightness
case V4L2_CID_BRIGHTNESS:
{
- if (ctrl->value != ov2655->info_priv.brightness)
+ if (ctrl->value != sensor->info_priv.brightness)
{
- if (ov2655_set_brightness(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov2655->info_priv.brightness = ctrl->value;
+ sensor->info_priv.brightness = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Exposure
case V4L2_CID_EXPOSURE:
{
- if (ctrl->value != ov2655->info_priv.exposure)
+ if (ctrl->value != sensor->info_priv.exposure)
{
- if (ov2655_set_exposure(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov2655->info_priv.exposure = ctrl->value;
+ sensor->info_priv.exposure = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Saturation
case V4L2_CID_SATURATION:
{
- if (ctrl->value != ov2655->info_priv.saturation)
+ if (ctrl->value != sensor->info_priv.saturation)
{
- if (ov2655_set_saturation(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov2655->info_priv.saturation = ctrl->value;
+ sensor->info_priv.saturation = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Contrast
case V4L2_CID_CONTRAST:
{
- if (ctrl->value != ov2655->info_priv.contrast)
+ if (ctrl->value != sensor->info_priv.contrast)
{
- if (ov2655_set_contrast(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov2655->info_priv.contrast = ctrl->value;
+ sensor->info_priv.contrast = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_WhiteBalance
case V4L2_CID_DO_WHITE_BALANCE:
{
- if (ctrl->value != ov2655->info_priv.whiteBalance)
+ if (ctrl->value != sensor->info_priv.whiteBalance)
{
- if (ov2655_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov2655->info_priv.whiteBalance = ctrl->value;
+ sensor->info_priv.whiteBalance = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Mirror
case V4L2_CID_HFLIP:
{
- if (ctrl->value != ov2655->info_priv.mirror)
+ if (ctrl->value != sensor->info_priv.mirror)
{
- if (ov2655_set_mirror(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
return -EINVAL;
- ov2655->info_priv.mirror = ctrl->value;
+ sensor->info_priv.mirror = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Flip
case V4L2_CID_VFLIP:
{
- if (ctrl->value != ov2655->info_priv.flip)
+ if (ctrl->value != sensor->info_priv.flip)
{
- if (ov2655_set_flip(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
return -EINVAL;
- ov2655->info_priv.flip = ctrl->value;
+ sensor->info_priv.flip = ctrl->value;
}
break;
}
- default :
+#endif
+ default:
break;
}
return 0;
}
-static int ov2655_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
+static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
{
const struct v4l2_queryctrl *qctrl;
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
- struct ov2655 *ov2655 = to_ov2655(client);
+ struct sensor *sensor = to_sensor(client);
- qctrl = soc_camera_find_qctrl(&ov2655_ops, ext_ctrl->id);
+ qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
if (!qctrl)
{
- OV2655_TR("\n%s..%s..%d.. ioctrl is faild ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
+ SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
return -EINVAL;
}
{
case V4L2_CID_SCENE:
{
- ext_ctrl->value = ov2655->info_priv.scene;
+ ext_ctrl->value = sensor->info_priv.scene;
break;
}
case V4L2_CID_EFFECT:
{
- ext_ctrl->value = ov2655->info_priv.effect;
+ ext_ctrl->value = sensor->info_priv.effect;
break;
}
case V4L2_CID_ZOOM_ABSOLUTE:
{
- ext_ctrl->value = ov2655->info_priv.digitalzoom;
+ ext_ctrl->value = sensor->info_priv.digitalzoom;
break;
}
case V4L2_CID_ZOOM_RELATIVE:
}
case V4L2_CID_FOCUS_ABSOLUTE:
{
- ext_ctrl->value = ov2655->info_priv.focus;
+ ext_ctrl->value = sensor->info_priv.focus;
break;
}
case V4L2_CID_FOCUS_RELATIVE:
}
case V4L2_CID_FLASH:
{
- ext_ctrl->value = ov2655->info_priv.flash;
+ ext_ctrl->value = sensor->info_priv.flash;
break;
}
default :
}
return 0;
}
-static int ov2655_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
+static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
{
const struct v4l2_queryctrl *qctrl;
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
- struct ov2655 *ov2655 = to_ov2655(client);
+ struct sensor *sensor = to_sensor(client);
int val_offset;
- qctrl = soc_camera_find_qctrl(&ov2655_ops, ext_ctrl->id);
+ qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
if (!qctrl)
{
- OV2655_TR("\n OV2655 ioctrl id = %d is invalidate ******** ddl *********\n", ext_ctrl->id);
+ SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
return -EINVAL;
}
+ val_offset = 0;
switch (ext_ctrl->id)
{
+#if CONFIG_SENSOR_Scene
case V4L2_CID_SCENE:
{
- if (ext_ctrl->value != ov2655->info_priv.scene)
+ if (ext_ctrl->value != sensor->info_priv.scene)
{
- if (ov2655_set_scene(icd, qctrl,ext_ctrl->value) != 0)
+ if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
return -EINVAL;
- ov2655->info_priv.scene = ext_ctrl->value;
+ sensor->info_priv.scene = ext_ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Effect
case V4L2_CID_EFFECT:
{
- if (ext_ctrl->value != ov2655->info_priv.effect)
+ if (ext_ctrl->value != sensor->info_priv.effect)
{
- if (ov2655_set_effect(icd, qctrl,ext_ctrl->value) != 0)
+ if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
return -EINVAL;
- ov2655->info_priv.effect= ext_ctrl->value;
+ sensor->info_priv.effect= ext_ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_DigitalZoom
case V4L2_CID_ZOOM_ABSOLUTE:
{
if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
return -EINVAL;
-
- if (ext_ctrl->value != ov2655->info_priv.digitalzoom)
+
+ if (ext_ctrl->value != sensor->info_priv.digitalzoom)
{
- val_offset = ext_ctrl->value -ov2655->info_priv.digitalzoom;
+ val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
- if (ov2655_set_digitalzoom(icd, qctrl,&val_offset) != 0)
+ if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
return -EINVAL;
- ov2655->info_priv.digitalzoom += val_offset;
+ sensor->info_priv.digitalzoom += val_offset;
- OV2655_DG("ov2655 digitalzoom is %x\n", ov2655->info_priv.digitalzoom);
- }
+ SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
+ }
break;
}
case V4L2_CID_ZOOM_RELATIVE:
- {
+ {
if (ext_ctrl->value)
{
- if (ov2655_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
+ if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
return -EINVAL;
- ov2655->info_priv.digitalzoom += ext_ctrl->value;
+ sensor->info_priv.digitalzoom += ext_ctrl->value;
- OV2655_DG("ov2655 digitalzoom is %x\n", ov2655->info_priv.digitalzoom);
+ SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
}
break;
}
-
+#endif
+#if CONFIG_SENSOR_Focus
case V4L2_CID_FOCUS_ABSOLUTE:
{
if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
return -EINVAL;
-
- if (ext_ctrl->value != ov2655->info_priv.focus)
+
+ if (ext_ctrl->value != sensor->info_priv.focus)
{
- val_offset = ext_ctrl->value -ov2655->info_priv.focus;
+ val_offset = ext_ctrl->value -sensor->info_priv.focus;
- ov2655->info_priv.focus += val_offset;
- }
+ sensor->info_priv.focus += val_offset;
+ }
- break;
+ break;
}
case V4L2_CID_FOCUS_RELATIVE:
{
if (ext_ctrl->value)
- {
- ov2655->info_priv.focus += ext_ctrl->value;
+ {
+ sensor->info_priv.focus += ext_ctrl->value;
- OV2655_DG("ov2655 focus is %x\n", ov2655->info_priv.focus);
+ SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);
}
break;
}
-
+#endif
+#if CONFIG_SENSOR_Flash
case V4L2_CID_FLASH:
{
- ov2655->info_priv.flash = ext_ctrl->value;
+ sensor->info_priv.flash = ext_ctrl->value;
- OV2655_DG("ov2655 flash is %x\n", ov2655->info_priv.flash);
+ SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
break;
- }
+ }
+#endif
default:
break;
}
return 0;
}
-static int ov2655_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
+static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
{
struct i2c_client *client = sd->priv;
- struct soc_camera_device *icd = client->dev.platform_data;
+ 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 (ov2655_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
+
+ for (i=0; i<ext_ctrl->count; i++) {
+ if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
error_cnt++;
error_idx = i;
}
if (error_cnt > 1)
error_idx = ext_ctrl->count;
-
- if (error_idx != -1) {
+
+ if (error_idx != -1) {
ext_ctrl->error_idx = error_idx;
return -EINVAL;
} else {
}
}
-static int ov2655_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
+static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
{
struct i2c_client *client = sd->priv;
- struct soc_camera_device *icd = client->dev.platform_data;
+ 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 (ov2655_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
+
+ for (i=0; i<ext_ctrl->count; i++) {
+ if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
error_cnt++;
error_idx = i;
}
if (error_cnt > 1)
error_idx = ext_ctrl->count;
-
- if (error_idx != -1) {
+
+ if (error_idx != -1) {
ext_ctrl->error_idx = error_idx;
return -EINVAL;
} else {
/* Interface active, can use i2c. If it fails, it can indeed mean, that
* this wasn't our capture interface, so, we wait for the right one */
-static int ov2655_video_probe(struct soc_camera_device *icd,
+static int sensor_video_probe(struct soc_camera_device *icd,
struct i2c_client *client)
{
char value;
int ret,pid = 0;
- struct ov2655 *ov2655 = to_ov2655(client);
+ struct sensor *sensor = to_sensor(client);
/* We must have a parent by now. And it cannot be a wrong one.
* So this entire test is completely redundant. */
return -ENODEV;
/* soft reset */
- ret = ov2655_write(client, 0x3012, 0x80);
+ ret = sensor_write(client, 0x3012, 0x80);
if (ret != 0)
{
- OV2655_TR("soft reset ov2655 failed\n");
+ SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());
return -ENODEV;
}
mdelay(5); //delay 5 microseconds
-
- /* check if it is an ov2655 sensor */
- ret = ov2655_read(client, 0x300a, &value);
+
+ /* check if it is an sensor sensor */
+ ret = sensor_read(client, 0x300a, &value);
if (ret != 0) {
- OV2655_TR("read chip id high byte failed\n");
+ SENSOR_TR("read chip id high byte failed\n");
ret = -ENODEV;
- goto ov2655_video_probe_err;
- }
+ goto sensor_video_probe_err;
+ }
pid |= (value << 8);
- ret = ov2655_read(client, 0x300b, &value);
+ ret = sensor_read(client, 0x300b, &value);
if (ret != 0) {
- OV2655_TR("read chip id low byte failed\n");
+ SENSOR_TR("read chip id low byte failed\n");
ret = -ENODEV;
- goto ov2655_video_probe_err;
+ goto sensor_video_probe_err;
}
-
+
pid |= (value & 0xff);
- OV2655_DG("\n OV2655 pid = 0x%x\n", pid);
- if (pid == 0x2656) {
- ov2655->model = V4L2_IDENT_OV2655;
+ SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
+ if (pid == SENSOR_ID) {
+ sensor->model = SENSOR_V4L2_IDENT;
} else {
- OV2655_TR("error: devicr mismatched pid = 0x%x\n", pid);
+ SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
ret = -ENODEV;
- goto ov2655_video_probe_err;
+ goto sensor_video_probe_err;
}
-
- icd->formats = ov2655_colour_formats;
- icd->num_formats = ARRAY_SIZE(ov2655_colour_formats);
+
+ icd->formats = sensor_colour_formats;
+ icd->num_formats = ARRAY_SIZE(sensor_colour_formats);
return 0;
-ov2655_video_probe_err:
+sensor_video_probe_err:
return ret;
}
-static struct v4l2_subdev_core_ops ov2655_subdev_core_ops = {
- .init = ov2655_init,
- .g_ctrl = ov2655_g_control,
- .s_ctrl = ov2655_s_control,
- .g_ext_ctrls = ov2655_g_ext_controls,
- .s_ext_ctrls = ov2655_s_ext_controls,
- .g_chip_ident = ov2655_g_chip_ident,
+static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
+ .init = sensor_init,
+ .g_ctrl = sensor_g_control,
+ .s_ctrl = sensor_s_control,
+ .g_ext_ctrls = sensor_g_ext_controls,
+ .s_ext_ctrls = sensor_s_ext_controls,
+ .g_chip_ident = sensor_g_chip_ident,
};
-static struct v4l2_subdev_video_ops ov2655_subdev_video_ops = {
- .s_fmt = ov2655_s_fmt,
- .g_fmt = ov2655_g_fmt,
- .try_fmt = ov2655_try_fmt,
+static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
+ .s_fmt = sensor_s_fmt,
+ .g_fmt = sensor_g_fmt,
+ .try_fmt = sensor_try_fmt,
};
-static struct v4l2_subdev_ops ov2655_subdev_ops = {
- .core = &ov2655_subdev_core_ops,
- .video = &ov2655_subdev_video_ops,
+static struct v4l2_subdev_ops sensor_subdev_ops = {
+ .core = &sensor_subdev_core_ops,
+ .video = &sensor_subdev_video_ops,
};
-static int ov2655_probe(struct i2c_client *client,
+static int sensor_probe(struct i2c_client *client,
const struct i2c_device_id *did)
{
- struct ov2655 *ov2655;
+ struct sensor *sensor;
struct soc_camera_device *icd = client->dev.platform_data;
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
struct soc_camera_link *icl;
int ret;
- OV2655_DG("\n%s..%s..%d ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
+ SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
if (!icd) {
- dev_err(&client->dev, "ov2655: missing soc-camera data!\n");
+ dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
return -EINVAL;
}
icl = to_soc_camera_link(icd);
if (!icl) {
- dev_err(&client->dev, "ov2655 driver needs platform data\n");
+ dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
return -EINVAL;
}
return -EIO;
}
- ov2655 = kzalloc(sizeof(struct ov2655), GFP_KERNEL);
- if (!ov2655)
+ sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
+ if (!sensor)
return -ENOMEM;
- v4l2_i2c_subdev_init(&ov2655->subdev, client, &ov2655_subdev_ops);
+ v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
/* Second stage probe - when a capture adapter is there */
- icd->ops = &ov2655_ops;
- icd->y_skip_top = 0;
-
- ret = ov2655_video_probe(icd, client);
+ icd->ops = &sensor_ops;
+ icd->y_skip_top = 0;
+
+ ret = sensor_video_probe(icd, client);
if (ret) {
icd->ops = NULL;
i2c_set_clientdata(client, NULL);
- kfree(ov2655);
+ kfree(sensor);
}
- OV2655_DG("\n%s..%s..%d ret = %x ^^^^^^^^ ddl^^^^^^^^\n",__FUNCTION__,__FILE__,__LINE__,ret);
+ SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
return ret;
}
-static int ov2655_remove(struct i2c_client *client)
+static int sensor_remove(struct i2c_client *client)
{
- struct ov2655 *ov2655 = to_ov2655(client);
+ struct sensor *sensor = to_sensor(client);
struct soc_camera_device *icd = client->dev.platform_data;
icd->ops = NULL;
i2c_set_clientdata(client, NULL);
client->driver = NULL;
- kfree(ov2655);
+ kfree(sensor);
return 0;
}
-static const struct i2c_device_id ov2655_id[] = {
- { "ov2655", 0 },
+static const struct i2c_device_id sensor_id[] = {
+ {SENSOR_NAME_STRING(), 0 },
{ }
};
-MODULE_DEVICE_TABLE(i2c, ov2655_id);
+MODULE_DEVICE_TABLE(i2c, sensor_id);
-static struct i2c_driver ov2655_i2c_driver = {
+static struct i2c_driver sensor_i2c_driver = {
.driver = {
- .name = "ov2655",
+ .name = SENSOR_NAME_STRING(),
},
- .probe = ov2655_probe,
- .remove = ov2655_remove,
- .id_table = ov2655_id,
+ .probe = sensor_probe,
+ .remove = sensor_remove,
+ .id_table = sensor_id,
};
-static int __init ov2655_mod_init(void)
+static int __init sensor_mod_init(void)
{
- OV2655_DG("\n%s..%s..%d ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
- return i2c_add_driver(&ov2655_i2c_driver);
+ SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
+ return i2c_add_driver(&sensor_i2c_driver);
}
-static void __exit ov2655_mod_exit(void)
+static void __exit sensor_mod_exit(void)
{
- i2c_del_driver(&ov2655_i2c_driver);
+ i2c_del_driver(&sensor_i2c_driver);
}
-//module_init(ov2655_mod_init);
-device_initcall_sync(ov2655_mod_init);
-module_exit(ov2655_mod_exit);
+device_initcall_sync(sensor_mod_init);
+module_exit(sensor_mod_exit);
-MODULE_DESCRIPTION("OV2655 Camera sensor driver");
-MODULE_AUTHOR("lbt <kernel@rock-chips>");
+MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
+MODULE_AUTHOR("ddl <kernel@rock-chips>");
MODULE_LICENSE("GPL");
#include <media/v4l2-chip-ident.h>
#include <media/soc_camera.h>
+#define _CONS(a,b) a##b
+#define CONS(a,b) _CONS(a,b)
+
+#define __STR(x) #x
+#define _STR(x) __STR(x)
+#define STR(x) _STR(x)
+
+/* Sensor Driver Configuration */
+#define SENSOR_NAME ov9650
+#define SENSOR_V4L2_IDENT V4L2_IDENT_OV9650
+#define SENSOR_ID 0x96
+#define SENSOR_MIN_WIDTH 176
+#define SENSOR_MIN_HEIGHT 144
+#define SENSOR_MAX_WIDTH 1280
+#define SENSOR_MAX_HEIGHT 1024
+#define SENSOR_INIT_WIDTH 320 /* Sensor pixel size for sensor_init_data array */
+#define SENSOR_INIT_HEIGHT 240
+#define SENSOR_INIT_WINSEQADR sensor_qvga
+
+#define CONFIG_SENSOR_WhiteBalance 1
+#define CONFIG_SENSOR_Brightness 0
+#define CONFIG_SENSOR_Contrast 0
+#define CONFIG_SENSOR_Saturation 0
+#define CONFIG_SENSOR_Effect 1
+#define CONFIG_SENSOR_Scene 0
+#define CONFIG_SENSOR_DigitalZoom 0
+#define CONFIG_SENSOR_Focus 0
+#define CONFIG_SENSOR_Exposure 0
+#define CONFIG_SENSOR_Flash 0
+#define CONFIG_SENSOR_Mirror 0
+#define CONFIG_SENSOR_Flip 0
+
+#define CONFIG_SENSOR_TR 1
+#define CONFIG_SENSOR_DEBUG 1
+
+#define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
+#define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
+
+#define MIN(x,y) ((x<y) ? x: y)
+#define MAX(x,y) ((x>y) ? x: y)
+
+#if (CONFIG_SENSOR_TR)
+ #define SENSOR_TR(format, ...) printk(format, ## __VA_ARGS__)
+ #if (CONFIG_SENSOR_DEBUG)
+ #define SENSOR_DG(format, ...) printk(format, ## __VA_ARGS__)
+ #else
+ #define SENSOR_DG(format, ...)
+ #endif
+#else
+ #define SENSOR_TR(format, ...)
+#endif
+
+#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\
+ SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |\
+ SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ)
+
+#define COLOR_TEMPERATURE_CLOUDY_DN 6500
+#define COLOR_TEMPERATURE_CLOUDY_UP 8000
+#define COLOR_TEMPERATURE_CLEARDAY_DN 5000
+#define COLOR_TEMPERATURE_CLEARDAY_UP 6500
+#define COLOR_TEMPERATURE_OFFICE_DN 3500
+#define COLOR_TEMPERATURE_OFFICE_UP 5000
+#define COLOR_TEMPERATURE_HOME_DN 2500
+#define COLOR_TEMPERATURE_HOME_UP 3500
struct reginfo
{
u8 val;
};
-/* init 352X288 SVGA */
-static struct reginfo ov9650_init_data[] =
+/* init 320X240 QVGA */
+static struct reginfo sensor_init_data[] =
{
{0x12, 0x80},
{0x11, 0x00},//0x82:Ϊ20Ø\91£»//0x02£ºÎª10Ø\91£»
};
/* 1280X1024 SXGA */
-static struct reginfo ov9650_sxga[] =
-{
- {0x04, 0x00},
+static struct reginfo sensor_sxga[] =
+{ {0x04, 0x00},
{0xa8, 0x80},
{0x0c, 0x00},
{0x0d, 0x00},
};
/* 800X600 SVGA*/
-static struct reginfo ov9650_svga[] =
+static struct reginfo sensor_svga[] =
{
- {0x00,0x00}
+ {0x0, 0x0},
};
/* 640X480 VGA */
-static struct reginfo ov9650_vga[] =
+static struct reginfo sensor_vga[] =
{
{0xa8, 0x80},
{0x0c, 0x04},
};
/* 352X288 CIF */
-static struct reginfo ov9650_cif[] =
+static struct reginfo sensor_cif[] =
{
{0x0c ,0x04},
{0x0d ,0x80},
};
/* 320*240 QVGA */
-static struct reginfo ov9650_qvga[] =
+static struct reginfo sensor_qvga[] =
{
{0x12, 0x10},
{0xa8, 0x80},
};
/* 176X144 QCIF*/
-static struct reginfo ov9650_qcif[] =
+static struct reginfo sensor_qcif[] =
{
{0x0c ,0x04},
{0x0d ,0x80},
{0x00,0x00}
};
-#define MIN(x,y) ((x<y) ? x: y)
-#define MAX(x,y) ((x>y) ? x: y)
+#if CONFIG_SENSOR_WhiteBalance
+static struct reginfo sensor_WhiteB_Auto[]=
+{
+ {0x84, 0x6C}, //Contrast 4
+ {0x85, 0x78},
+ {0x86, 0x8C},
+ {0x87, 0x9E},
+ {0x88, 0xBB},
+ {0x89, 0xD2},
+ {0x8A, 0xE6},
+ {0x6C, 0x40},
+ {0x6D, 0x30},
+ {0x6E, 0x48},
+ {0x6F, 0x60},
+ {0x70, 0x70},
+ {0x71, 0x70},
+ {0x72, 0x70},
+ {0x73, 0x70},
+ {0x74, 0x60},
+ {0x75, 0x60},
+ {0x76, 0x50},
+ {0x77, 0x48},
+ {0x78, 0x3A},
+ {0x79, 0x2E},
+ {0x7A, 0x28},
+ {0x7B, 0x22},
-#define OV9650_MIN_WIDTH 176
-#define OV9650_MIN_HEIGHT 144
-#define OV9650_MAX_WIDTH 1280
-#define OV9650_MAX_HEIGHT 1024
-
-#define CONFIG_OV9650_TR 1
-#define CONFIG_OV9650_DEBUG 0
-#if (CONFIG_OV9650_TR)
- #define OV9650_TR(format, ...) printk(format, ## __VA_ARGS__)
- #if (CONFIG_OV9650_DEBUG)
- #define OV9650_DG(format, ...) printk(format, ## __VA_ARGS__)
- #else
- #define OV9650_DG(format, ...)
- #endif
-#else
- #define OV9650_TR(format, ...)
-#endif
+ {0x0f, 0x4a}, //Saturation 3
+ {0x27, 0x80},
+ {0x28, 0x80},
+ {0x2c, 0x80},
+ {0x62, 0x60},
+ {0x63, 0xe0},
+ {0x64, 0x04},
+ {0x65, 0x00},
+ {0x66, 0x01},
+ {0x24, 0x70},
+ {0x25, 0x64},
-#define COL_FMT(_name, _depth, _fourcc, _colorspace) \
- { .name = _name, .depth = _depth, .fourcc = _fourcc, \
- .colorspace = _colorspace }
+ {0x4f, 0x2e}, //Brightness 3
+ {0x50, 0x31},
+ {0x51, 0x02},
+ {0x52, 0x0e},
+ {0x53, 0x1e},
+ {0x54, 0x2d},
-#define JPG_FMT(_name, _depth, _fourcc) \
- COL_FMT(_name, _depth, _fourcc, V4L2_COLORSPACE_JPEG)
+ {0x11, 0x80},
+ {0x14, 0x2a},
+ {0x13, 0xe7},
+ {0x66, 0x05},
-static const struct soc_camera_data_format ov9650_colour_formats[] = {
- JPG_FMT("ov9650 UYVY", 16, V4L2_PIX_FMT_UYVY),
- JPG_FMT("ov9650 YUYV", 16, V4L2_PIX_FMT_YUYV),
+ {0x00, 0x00}
};
-
-typedef struct ov9650_info_priv_s
+/* Cloudy Colour Temperature : 6500K - 8000K */
+static struct reginfo sensor_WhiteB_Cloudy[]=
{
- int whiteBalance;
- int brightness;
- int contrast;
- int saturation;
- int effect;
- int scene;
- int digitalzoom;
- int focus;
- int flash;
- int exposure;
- unsigned char mirror; /* HFLIP */
- unsigned char flip; /* VFLIP */
- unsigned int winseqe_cur_addr;
+ {0x7C,0x04}, //Contrast 5
+ {0x7D,0x09},
+ {0x7E,0x13},
+ {0x7F,0x29},
+ {0x80,0x35},
+ {0x81,0x41},
+ {0x82,0x4D},
+ {0x83,0x59},
+ {0x84,0x64},
+ {0x85,0x6F},
+ {0x86,0x85},
+ {0x87,0x97},
+ {0x88,0xB7},
+ {0x89,0xCF},
+ {0x8A,0xE3},
+ {0x6C,0x40},
+ {0x6D,0x50},
+ {0x6E,0x50},
+ {0x6F,0x58},
+ {0x70,0x60},
+ {0x71,0x60},
+ {0x72,0x60},
+ {0x73,0x60},
+ {0x74,0x58},
+ {0x75,0x58},
+ {0x76,0x58},
+ {0x77,0x48},
+ {0x78,0x40},
+ {0x79,0x30},
+ {0x7A,0x28},
+ {0x7B,0x26},
+
- unsigned int powerdown_pin;
-} ov9650_info_priv_t;
+ {0x4f,0x3a}, //Saturation 4
+ {0x50,0x3d},
+ {0x51,0x03},
+ {0x52,0x12},
+ {0x53,0x26},
+ {0x54,0x38},
+ {0x4f, 0x2e}, //Brightness 3
+ {0x50, 0x31},
+ {0x51, 0x02},
+ {0x52, 0x0e},
+ {0x53, 0x1e},
+ {0x54, 0x2d},
-struct ov9650
+ {0x11,0x80},
+ {0x14,0x0a},
+ {0x13,0xc7},
+ {0x66,0x05},
+ {0x00, 0x00}
+};
+/* ClearDay Colour Temperature : 5000K - 6500K */
+static struct reginfo sensor_WhiteB_ClearDay[]=
{
- struct v4l2_subdev subdev;
- struct i2c_client *client;
- ov9650_info_priv_t info_priv;
- unsigned int pixfmt;
- int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
+ //Sunny
+ {0x7C,0x04}, //Contrast 5
+ {0x7D,0x09},
+ {0x7E,0x13},
+ {0x7F,0x29},
+ {0x80,0x35},
+ {0x81,0x41},
+ {0x82,0x4D},
+ {0x83,0x59},
+ {0x84,0x64},
+ {0x85,0x6F},
+ {0x86,0x85},
+ {0x87,0x97},
+ {0x88,0xB7},
+ {0x89,0xCF},
+ {0x8A,0xE3},
+ {0x6C,0x40},
+ {0x6D,0x50},
+ {0x6E,0x50},
+ {0x6F,0x58},
+ {0x70,0x60},
+ {0x71,0x60},
+ {0x72,0x60},
+ {0x73,0x60},
+ {0x74,0x58},
+ {0x75,0x58},
+ {0x76,0x58},
+ {0x77,0x48},
+ {0x78,0x40},
+ {0x79,0x30},
+ {0x7A,0x28},
+ {0x7B,0x26},
+
+
+
+ {0x4f,0x3a}, //Saturation 4
+ {0x50,0x3d},
+ {0x51,0x03},
+ {0x52,0x12},
+ {0x53,0x26},
+ {0x54,0x38},
+ {0x4f, 0x2e}, //Brightness 3
+ {0x50, 0x31},
+ {0x51, 0x02},
+ {0x52, 0x0e},
+ {0x53, 0x1e},
+ {0x54, 0x2d},
+
+ {0x11,0x80},
+ {0x14,0x0a},
+ {0x13,0xc7},
+ {0x66,0x05},
+ {0x00, 0x00}
};
+/* Office Colour Temperature : 3500K - 5000K */
+static struct reginfo sensor_WhiteB_TungstenLamp1[]=
+{
+ //Office
+ {0x84, 0x6C}, //Contrast 4
+ {0x85, 0x78},
+ {0x86, 0x8C},
+ {0x87, 0x9E},
+ {0x88, 0xBB},
+ {0x89, 0xD2},
+ {0x8A, 0xE6},
+ {0x6C, 0x40},
+ {0x6D, 0x30},
+ {0x6E, 0x48},
+ {0x6F, 0x60},
+ {0x70, 0x70},
+ {0x71, 0x70},
+ {0x72, 0x70},
+ {0x73, 0x70},
+ {0x74, 0x60},
+ {0x75, 0x60},
+ {0x76, 0x50},
+ {0x77, 0x48},
+ {0x78, 0x3A},
+ {0x79, 0x2E},
+ {0x7A, 0x28},
+ {0x7B, 0x22},
+
+ {0x0f, 0x4a}, //Saturation 3
+ {0x27, 0x80},
+ {0x28, 0x80},
+ {0x2c, 0x80},
+ {0x62, 0x60},
+ {0x63, 0xe0},
+ {0x64, 0x04},
+ {0x65, 0x00},
+ {0x66, 0x01},
+ {0x24, 0x70},
+ {0x25, 0x64},
+
+ {0x4f, 0x2e}, //Brightness 3
+ {0x50, 0x31},
+ {0x51, 0x02},
+ {0x52, 0x0e},
+ {0x53, 0x1e},
+ {0x54, 0x2d},
+
+ {0x11,0x80},
+ {0x14,0x2a},
+ {0x13,0xe7},
+ {0x66,0x05},
+
+ {0x00, 0x00}
-static const struct v4l2_queryctrl ov9650_controls[] =
+
+};
+/* Home Colour Temperature : 2500K - 3500K */
+static struct reginfo sensor_WhiteB_TungstenLamp2[]=
{
- {
- .id = V4L2_CID_DO_WHITE_BALANCE,
- .type = V4L2_CTRL_TYPE_MENU,
- .name = "White Balance Control",
- .minimum = 0,
- .maximum = 4,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_BRIGHTNESS,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Brightness Control",
- .minimum = -3,
- .maximum = 2,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_EFFECT,
- .type = V4L2_CTRL_TYPE_MENU,
- .name = "Effect Control",
- .minimum = 0,
- .maximum = 5,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_EXPOSURE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Exposure Control",
- .minimum = 0,
- .maximum = 6,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_SATURATION,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Saturation Control",
- .minimum = 0,
- .maximum = 2,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_CONTRAST,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Contrast Control",
- .minimum = -3,
- .maximum = 3,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_HFLIP,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Mirror Control",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 1,
- }, {
- .id = V4L2_CID_VFLIP,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Flip Control",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 1,
- }, {
- .id = V4L2_CID_SCENE,
- .type = V4L2_CTRL_TYPE_MENU,
- .name = "Scene Control",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_ZOOM_RELATIVE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "DigitalZoom Control",
- .minimum = -1,
- .maximum = 1,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_ZOOM_ABSOLUTE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "DigitalZoom Control",
- .minimum = 0,
- .maximum = 3,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_FOCUS_RELATIVE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Focus Control",
- .minimum = -1,
- .maximum = 1,
- .step = 1,
- .default_value = 0,
- }, {
- .id = V4L2_CID_FOCUS_ABSOLUTE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Focus Control",
- .minimum = 0,
- .maximum = 255,
- .step = 1,
- .default_value = 125,
- }, {
- .id = V4L2_CID_FLASH,
- .type = V4L2_CTRL_TYPE_MENU,
- .name = "Flash Control",
- .minimum = 0,
- .maximum = 3,
- .step = 1,
- .default_value = 0,
- }
-};
-
-static int ov9650_probe(struct i2c_client *client, const struct i2c_device_id *did);
-static int ov9650_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
-static int ov9650_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
-static int ov9650_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
-static int ov9650_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
-static int ov9650_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
-
-
-static struct ov9650* to_ov9650(const struct i2c_client *client)
-{
- return container_of(i2c_get_clientdata(client), struct ov9650, subdev);
-}
-
-/* ov9650 register write */
-static int ov9650_write(struct i2c_client *client, u8 reg, u8 val)
-{
- int ret;
- ret = i2c_master_reg8_send(client, reg, &val, 1, 400*1000);
- return ret;
-}
-
-/* ov9650 register read */
-static int ov9650_read(struct i2c_client *client, u8 reg, u8 *val)
-{
- int err,cnt;
- u8 buf[1];
- struct i2c_msg msg[1];
-
- buf[0] = reg & 0xFF;
-
- msg->addr = client->addr;
- msg->flags = client->flags;
- msg->buf = buf;
- msg->len = sizeof(buf);
- msg->scl_rate = 400*1000; /* ddl@rock-chips.com : 100kHz */
- i2c_transfer(client->adapter, msg, 1);
- msg->addr = client->addr;
- msg->flags = client->flags|I2C_M_RD;
- msg->buf = buf;
- msg->len = 1; /* ddl@rock-chips.com : 100kHz */
-
- cnt = 3;
- err = -EAGAIN;
- while ((cnt--) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
- err = i2c_transfer(client->adapter, msg, 1);
-
- if (err >= 0) {
- *val = buf[0];
- return 0;
- } else {
- udelay(10);
- }
- }
-
- return err;
-}
-
-/* write a array of registers */
-static int ov9650_write_array(struct i2c_client *client, struct reginfo *regarray)
-{
- int err;
- int i = 0;
-
- while (regarray[i].reg != 0)
- {
- err = ov9650_write(client, regarray[i].reg, regarray[i].val);
- if (err < 0)
- {
- OV9650_TR("write failed current i = %d\n", i);
- return err;
- }
- i++;
- }
- return 0;
-}
-
-static int ov9650_init(struct v4l2_subdev *sd, u32 val)
-{
- struct i2c_client *client = sd->priv;
- struct soc_camera_device *icd = client->dev.platform_data;
- struct ov9650 *ov9650 = to_ov9650(client);
- int ret;
-
- OV9650_DG("\n%s..%d.. *** ddl ***\n",__FUNCTION__,__LINE__);
-
- /* soft reset */
- ret = ov9650_write(client, 0x12, 0x80);
- if (ret < 0)
- {
- OV9650_TR("soft reset ov9650 failed\n");
- return -ENODEV;
- }
-
- mdelay(5); //delay 5 microseconds
-
- ret = ov9650_write_array(client, ov9650_init_data);
- if (ret != 0)
- {
- OV9650_TR("error: ov9650 initial failed\n");
- return ret;
- }
-
- icd->user_width = 320;
- icd->user_height = 240;
-
- /* sensor ov9650 information for initialization */
- ov9650->info_priv.whiteBalance = ov9650_controls[0].default_value;
- ov9650->info_priv.brightness = ov9650_controls[1].default_value;
- ov9650->info_priv.effect = ov9650_controls[2].default_value;
- ov9650->info_priv.exposure = ov9650_controls[3].default_value;
- ov9650->info_priv.saturation = ov9650_controls[4].default_value;
- ov9650->info_priv.contrast = ov9650_controls[5].default_value;
- ov9650->info_priv.mirror = ov9650_controls[6].default_value;
- ov9650->info_priv.flip = ov9650_controls[7].default_value;
- ov9650->info_priv.scene = ov9650_controls[8].default_value;
- ov9650->info_priv.digitalzoom = ov9650_controls[10].default_value;
- ov9650->info_priv.winseqe_cur_addr = (int)ov9650_svga;
-
- /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
- //ov9650_set_focus();
- //ov9650_set_flash();
- ov9650->info_priv.focus = ov9650_controls[12].default_value;
- ov9650->info_priv.flash = ov9650_controls[13].default_value;
-
-
- OV9650_DG("\n%s..%d.. *** ddl *** icd->width = %d.. icd->height %d\n",__FUNCTION__,__LINE__,icd->user_width,icd->user_height);
-
- return 0;
-}
-
-static struct reginfo ov9650_power_down_sequence[]=
-{
- {0x00,0x00}
-};
-static int ov9650_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
-{
- int ret;
- struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
- struct soc_camera_link *icl;
-
-
- if (pm_msg.event == PM_EVENT_SUSPEND)
- {
- OV9650_DG("\n ov9650 Enter Suspend. %x ******** ddl *********\n", __LINE__);
- ret = ov9650_write_array(client, ov9650_power_down_sequence) ;
- if (ret != 0)
- {
- OV9650_TR("\n OV9650 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
- return ret;
- }
- else
- {
- icl = to_soc_camera_link(icd);
- if (icl->power) {
- ret = icl->power(icd->pdev, 0);
- if (ret < 0)
- return -EINVAL;
- }
- }
- }
- else
- {
- OV9650_TR("\n Sov9650 cann't suppout Suspend. %x ******** ddl *********\n", __LINE__);
- return -EINVAL;
- }
- return 0;
-}
-
-static int ov9650_resume(struct soc_camera_device *icd)
-{
- struct soc_camera_link *icl;
- int ret;
-
- icl = to_soc_camera_link(icd);
- if (icl->power) {
- ret = icl->power(icd->pdev, 0);
- if (ret < 0)
- return -EINVAL;
- }
-
- return 0;
-
-}
-
-static int ov9650_set_bus_param(struct soc_camera_device *icd,
- unsigned long flags)
-{
-
- return 0;
-}
-
-static unsigned long ov9650_query_bus_param(struct soc_camera_device *icd)
-{
- struct soc_camera_link *icl = to_soc_camera_link(icd);
- unsigned long flags = SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |
- SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |
- SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ;
-
- return soc_camera_apply_sensor_flags(icl, flags);
-}
-
-static int ov9650_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
- struct i2c_client *client = sd->priv;
- struct soc_camera_device *icd = client->dev.platform_data;
- struct ov9650 *ov9650 = to_ov9650(client);
- struct v4l2_pix_format *pix = &f->fmt.pix;
-
- pix->width = icd->user_width;
- pix->height = icd->user_height;
- pix->pixelformat = ov9650->pixfmt;
- pix->field = V4L2_FIELD_NONE;
- pix->colorspace = V4L2_COLORSPACE_JPEG;
-
- return 0;
-}
-static int ov9650_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
- struct i2c_client *client = sd->priv;
- struct ov9650 *ov9650 = to_ov9650(client);
- struct v4l2_pix_format *pix = &f->fmt.pix;
- struct reginfo *winseqe_set_addr;
- int ret, set_w,set_h;
-
- set_w = pix->width;
- set_h = pix->height;
-
- if ((set_w <= 176) && (set_h <= 144))
- {
- winseqe_set_addr = ov9650_qcif;
- set_w = 176;
- set_h = 144;
- }
- else if ((set_w <= 320) && (set_h <= 240))
- {
- winseqe_set_addr = ov9650_qvga;
- set_w = 320;
- set_h = 240;
- }
- else if ((set_w <= 352) && (set_h<= 288))
- {
- winseqe_set_addr = ov9650_cif;
- set_w = 352;
- set_h = 288;
- }
- else if ((set_w <= 640) && (set_h <= 480))
- {
- winseqe_set_addr = ov9650_vga;
- set_w = 640;
- set_h = 480;
- }
- else if ((set_w <= 1280) && (set_h <= 1024))
- {
- winseqe_set_addr = ov9650_sxga;
- set_w = 1280;
- set_h = 1024;
- }
- else
- {
- winseqe_set_addr = ov9650_qvga; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */
- set_w = 320;
- set_h = 240;
- }
-
- if ((int)winseqe_set_addr != ov9650->info_priv.winseqe_cur_addr)
- {
- ret = ov9650_write_array(client, winseqe_set_addr);
- if (ret != 0)
- {
- OV9650_TR("ov9650 set format capability failed\n");
- return ret;
- }
-
- ov9650->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
- mdelay(250);
-
- OV9650_DG("\n%s..%d *** ddl *** icd->width = %d.. icd->height %d\n",__FUNCTION__,__LINE__,set_w,set_h);
- }
- else
- {
- OV9650_TR("\n .. Current Format is validate *** ddl *** icd->width = %d.. icd->height %d\n",set_w,set_h);
- }
-
- return 0;
-}
-
-static int ov9650_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
- struct v4l2_pix_format *pix = &f->fmt.pix;
- bool bayer = pix->pixelformat == V4L2_PIX_FMT_UYVY ||
- pix->pixelformat == V4L2_PIX_FMT_YUYV;
-
- /*
- * With Bayer format enforce even side lengths, but let the user play
- * with the starting pixel
- */
-
- if (pix->height > OV9650_MAX_HEIGHT)
- pix->height = OV9650_MAX_HEIGHT;
- else if (pix->height < OV9650_MIN_HEIGHT)
- pix->height = OV9650_MIN_HEIGHT;
- else if (bayer)
- pix->height = ALIGN(pix->height, 2);
-
- if (pix->width > OV9650_MAX_WIDTH)
- pix->width = OV9650_MAX_WIDTH;
- else if (pix->width < OV9650_MIN_WIDTH)
- pix->width = OV9650_MIN_WIDTH;
- else if (bayer)
- pix->width = ALIGN(pix->width, 2);
-
- return 0;
-}
-
- static int ov9650_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
-{
- struct i2c_client *client = sd->priv;
-
- if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
- return -EINVAL;
-
- if (id->match.addr != client->addr)
- return -ENODEV;
-
- id->ident = V4L2_IDENT_OV9650; /* ddl@rock-chips.com : Return OV9650 identifier */
- id->revision = 0;
-
- return 0;
-}
-
-#define COLOR_TEMPERATURE_CLOUDY_DN 6500
-#define COLOR_TEMPERATURE_CLOUDY_UP 8000
-#define COLOR_TEMPERATURE_CLEARDAY_DN 5000
-#define COLOR_TEMPERATURE_CLEARDAY_UP 6500
-#define COLOR_TEMPERATURE_OFFICE_DN 3500
-#define COLOR_TEMPERATURE_OFFICE_UP 5000
-#define COLOR_TEMPERATURE_HOME_DN 2500
-#define COLOR_TEMPERATURE_HOME_UP 3500
-
-static struct reginfo ov9650_WhiteB_Auto[]=
-{
- {0x84, 0x6C}, //Contrast 4
- {0x85, 0x78},
- {0x86, 0x8C},
- {0x87, 0x9E},
- {0x88, 0xBB},
- {0x89, 0xD2},
- {0x8A, 0xE6},
- {0x6C, 0x40},
- {0x6D, 0x30},
- {0x6E, 0x48},
- {0x6F, 0x60},
- {0x70, 0x70},
- {0x71, 0x70},
- {0x72, 0x70},
- {0x73, 0x70},
- {0x74, 0x60},
- {0x75, 0x60},
- {0x76, 0x50},
- {0x77, 0x48},
- {0x78, 0x3A},
- {0x79, 0x2E},
- {0x7A, 0x28},
- {0x7B, 0x22},
-
- {0x0f, 0x4a}, //Saturation 3
- {0x27, 0x80},
- {0x28, 0x80},
- {0x2c, 0x80},
- {0x62, 0x60},
- {0x63, 0xe0},
- {0x64, 0x04},
- {0x65, 0x00},
- {0x66, 0x01},
- {0x24, 0x70},
- {0x25, 0x64},
-
- {0x4f, 0x2e}, //Brightness 3
- {0x50, 0x31},
- {0x51, 0x02},
- {0x52, 0x0e},
- {0x53, 0x1e},
- {0x54, 0x2d},
-
- {0x11, 0x80},
- {0x14, 0x2a},
- {0x13, 0xe7},
- {0x66, 0x05},
-
- {0x00, 0x00}
-};
-/* Cloudy Colour Temperature : 6500K - 8000K */
-static struct reginfo ov9650_WhiteB_Cloudy[]=
-{
- {0x7C,0x04}, //Contrast 5
- {0x7D,0x09},
- {0x7E,0x13},
- {0x7F,0x29},
- {0x80,0x35},
- {0x81,0x41},
- {0x82,0x4D},
- {0x83,0x59},
- {0x84,0x64},
- {0x85,0x6F},
- {0x86,0x85},
- {0x87,0x97},
- {0x88,0xB7},
- {0x89,0xCF},
- {0x8A,0xE3},
- {0x6C,0x40},
- {0x6D,0x50},
- {0x6E,0x50},
- {0x6F,0x58},
- {0x70,0x60},
- {0x71,0x60},
- {0x72,0x60},
- {0x73,0x60},
- {0x74,0x58},
- {0x75,0x58},
- {0x76,0x58},
- {0x77,0x48},
- {0x78,0x40},
- {0x79,0x30},
- {0x7A,0x28},
- {0x7B,0x26},
-
-
-
- {0x4f,0x3a}, //Saturation 4
- {0x50,0x3d},
- {0x51,0x03},
- {0x52,0x12},
- {0x53,0x26},
- {0x54,0x38},
- {0x4f, 0x2e}, //Brightness 3
- {0x50, 0x31},
- {0x51, 0x02},
- {0x52, 0x0e},
- {0x53, 0x1e},
- {0x54, 0x2d},
-
- {0x11,0x80},
- {0x14,0x0a},
- {0x13,0xc7},
- {0x66,0x05},
- {0x00, 0x00}
-};
-/* ClearDay Colour Temperature : 5000K - 6500K */
-static struct reginfo ov9650_WhiteB_ClearDay[]=
-{
- //Sunny
- {0x7C,0x04}, //Contrast 5
- {0x7D,0x09},
- {0x7E,0x13},
- {0x7F,0x29},
- {0x80,0x35},
- {0x81,0x41},
- {0x82,0x4D},
- {0x83,0x59},
- {0x84,0x64},
- {0x85,0x6F},
- {0x86,0x85},
- {0x87,0x97},
- {0x88,0xB7},
- {0x89,0xCF},
- {0x8A,0xE3},
- {0x6C,0x40},
- {0x6D,0x50},
- {0x6E,0x50},
- {0x6F,0x58},
- {0x70,0x60},
- {0x71,0x60},
- {0x72,0x60},
- {0x73,0x60},
- {0x74,0x58},
- {0x75,0x58},
- {0x76,0x58},
- {0x77,0x48},
- {0x78,0x40},
- {0x79,0x30},
- {0x7A,0x28},
- {0x7B,0x26},
-
-
-
- {0x4f,0x3a}, //Saturation 4
- {0x50,0x3d},
- {0x51,0x03},
- {0x52,0x12},
- {0x53,0x26},
- {0x54,0x38},
- {0x4f, 0x2e}, //Brightness 3
- {0x50, 0x31},
- {0x51, 0x02},
- {0x52, 0x0e},
- {0x53, 0x1e},
- {0x54, 0x2d},
-
- {0x11,0x80},
- {0x14,0x0a},
- {0x13,0xc7},
- {0x66,0x05},
- {0x00, 0x00}
-};
-/* Office Colour Temperature : 3500K - 5000K */
-static struct reginfo ov9650_WhiteB_TungstenLamp1[]=
-{
- //Office
+ //Home
{0x84, 0x6C}, //Contrast 4
{0x85, 0x78},
{0x86, 0x8C},
{0x53, 0x1e},
{0x54, 0x2d},
- {0x11,0x80},
- {0x14,0x2a},
- {0x13,0xe7},
- {0x66,0x05},
+ {0x11, 0x80},
+ {0x14, 0x2a},
+ {0x13, 0xe7},
+ {0x66, 0x05},
+ {0x00, 0x00}
+};
+static struct reginfo *sensor_WhiteBalanceSeqe[] = {sensor_WhiteB_Auto, sensor_WhiteB_TungstenLamp1,sensor_WhiteB_TungstenLamp2,
+ sensor_WhiteB_ClearDay, sensor_WhiteB_Cloudy,NULL,
+};
+#endif
+
+#if CONFIG_SENSOR_Brightness
+static struct reginfo sensor_Brightness0[]=
+{
+ // Brightness -2
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x49},
+ {0x339a, 0x20},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Brightness1[]=
+{
+ // Brightness -1
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x49},
+ {0x339a, 0x10},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Brightness2[]=
+{
+ // Brightness 0
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x00},
+ {0x3390, 0x41},
+ {0x339a, 0x00},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Brightness3[]=
+{
+ // Brightness +1
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x41},
+ {0x339a, 0x10},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Brightness4[]=
+{
+ // Brightness +2
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04},
+ {0x3390, 0x41},
+ {0x339a, 0x20},
+ {0x0000, 0x00}
+};
+
+static struct reginfo sensor_Brightness5[]=
+{
+ // Brightness +3
+ {0x3301, 0xff},//bit[7]:1, enable SDE
+ {0x3391, 0x04}, //bit[2] enable
+ {0x3390, 0x41}, //bit[3] sign of brightness
+ {0x339a, 0x30},
+ {0x0000, 0x00}
+};
+static struct reginfo *sensor_BrightnessSeqe[] = {sensor_Brightness0, sensor_Brightness1, sensor_Brightness2, sensor_Brightness3,
+ sensor_Brightness4, sensor_Brightness5,NULL,
+};
+
+#endif
+#if CONFIG_SENSOR_Effect
+static struct reginfo sensor_Effect_Normal[] =
+{
+ {0x3a,0x0d},
+ {0x67,0x80},
+ {0x68,0x80},
{0x00, 0x00}
+};
+static struct reginfo sensor_Effect_WandB[] =
+{
+ {0x3a,0x1d},
+ {0x67,0x80},
+ {0x68,0x80},
+ {0x00, 0x00}
};
-/* Home Colour Temperature : 2500K - 3500K */
-static struct reginfo ov9650_WhiteB_TungstenLamp2[]=
+
+static struct reginfo sensor_Effect_Sepia[] =
{
- //Home
- {0x84, 0x6C}, //Contrast 4
- {0x85, 0x78},
- {0x86, 0x8C},
- {0x87, 0x9E},
- {0x88, 0xBB},
- {0x89, 0xD2},
- {0x8A, 0xE6},
- {0x6C, 0x40},
- {0x6D, 0x30},
- {0x6E, 0x48},
- {0x6F, 0x60},
- {0x70, 0x70},
- {0x71, 0x70},
- {0x72, 0x70},
- {0x73, 0x70},
- {0x74, 0x60},
- {0x75, 0x60},
- {0x76, 0x50},
- {0x77, 0x48},
- {0x78, 0x3A},
- {0x79, 0x2E},
- {0x7A, 0x28},
- {0x7B, 0x22},
+ {0x3a,0x1d},
+ {0x67,0x40},
+ {0x68,0xa0},
+ {0x00, 0x00}
+};
- {0x0f, 0x4a}, //Saturation 3
- {0x27, 0x80},
- {0x28, 0x80},
- {0x2c, 0x80},
- {0x62, 0x60},
- {0x63, 0xe0},
- {0x64, 0x04},
- {0x65, 0x00},
- {0x66, 0x01},
- {0x24, 0x70},
- {0x25, 0x64},
+static struct reginfo sensor_Effect_Negative[] =
+{
+ //Negative
+ {0x3a,0x2d},
+ {0x67,0x80},
+ {0x68,0x80},
+ {0x00, 0x00}
+};
+static struct reginfo sensor_Effect_Bluish[] =
+{
+ // Bluish
+ {0x3a,0x1d},
+ {0x67,0xc0},
+ {0x68,0x80},
+ {0x00, 0x00}
+};
- {0x4f, 0x2e}, //Brightness 3
- {0x50, 0x31},
- {0x51, 0x02},
- {0x52, 0x0e},
- {0x53, 0x1e},
- {0x54, 0x2d},
+static struct reginfo sensor_Effect_Green[] =
+{
+ // Greenish
+ {0x3a,0x1d},
+ {0x67,0x40},
+ {0x68,0x40},
+ {0x00, 0x00}
+};
+static struct reginfo *sensor_EffectSeqe[] = {sensor_Effect_Normal, sensor_Effect_WandB, sensor_Effect_Negative,sensor_Effect_Sepia,
+ sensor_Effect_Bluish, sensor_Effect_Green,NULL,
+};
+#endif
+#if CONFIG_SENSOR_Exposure
+static struct reginfo sensor_Exposure0[]=
+{
+ {0x00, 0x00}
+};
- {0x11, 0x80},
- {0x14, 0x2a},
- {0x13, 0xe7},
- {0x66, 0x05},
+static struct reginfo sensor_Exposure1[]=
+{
{0x00, 0x00}
};
-static struct reginfo ov9650_Brightness0[]=
+static struct reginfo sensor_Exposure2[]=
{
- // Brightness -2
+ {0x00, 0x00}
+};
+static struct reginfo sensor_Exposure3[]=
+{
{0x00, 0x00}
};
-static struct reginfo ov9650_Brightness1[]=
+static struct reginfo sensor_Exposure4[]=
{
- // Brightness -1
+ {0x00, 0x00}
+};
+static struct reginfo sensor_Exposure5[]=
+{
{0x00, 0x00}
};
-static struct reginfo ov9650_Brightness2[]=
+static struct reginfo sensor_Exposure6[]=
{
- // Brightness 0
+ {0x00, 0x00}
+};
+static struct reginfo *sensor_ExposureSeqe[] = {sensor_Exposure0, sensor_Exposure1, sensor_Exposure2, sensor_Exposure3,
+ sensor_Exposure4, sensor_Exposure5,sensor_Exposure6,NULL,
+};
+#endif
+#if CONFIG_SENSOR_Saturation
+static struct reginfo sensor_Saturation0[]=
+{
{0x00, 0x00}
};
-static struct reginfo ov9650_Brightness3[]=
+static struct reginfo sensor_Saturation1[]=
{
- // Brightness +1
+ {0x00, 0x00}
+};
+
+static struct reginfo sensor_Saturation2[]=
+{
+ {0x00, 0x00}
+};
+static struct reginfo *sensor_SaturationSeqe[] = {sensor_Saturation0, sensor_Saturation1, sensor_Saturation2, NULL,};
+
+#endif
+#if CONFIG_SENSOR_Contrast
+static struct reginfo sensor_Contrast0[]=
+{
+ {0x00, 0x00}
+};
+
+static struct reginfo sensor_Contrast1[]=
+{
+ {0x00, 0x00}
+};
+static struct reginfo sensor_Contrast2[]=
+{
{0x00, 0x00}
};
-static struct reginfo ov9650_Brightness4[]=
+static struct reginfo sensor_Contrast3[]=
{
- // Brightness +2
-
{0x00, 0x00}
};
-static struct reginfo ov9650_Brightness5[]=
+static struct reginfo sensor_Contrast4[]=
{
- // Brightness +3
-
{0x00, 0x00}
};
-static struct reginfo ov9650_Effect_Normal[] =
+
+static struct reginfo sensor_Contrast5[]=
{
- {0x3a,0x0d},
- {0x67,0x80},
- {0x68,0x80},
{0x00, 0x00}
};
-static struct reginfo ov9650_Effect_WandB[] =
+static struct reginfo sensor_Contrast6[]=
{
- {0x3a,0x1d},
- {0x67,0x80},
- {0x68,0x80},
{0x00, 0x00}
};
+static struct reginfo *sensor_ContrastSeqe[] = {sensor_Contrast0, sensor_Contrast1, sensor_Contrast2, sensor_Contrast3,
+ sensor_Contrast4, sensor_Contrast5, sensor_Contrast6, NULL,
+};
-static struct reginfo ov9650_Effect_Sepia[] =
+#endif
+#if CONFIG_SENSOR_Mirror
+static struct reginfo sensor_MirrorOn[]=
{
- {0x3a,0x1d},
- {0x67,0x40},
- {0x68,0xa0},
{0x00, 0x00}
};
-static struct reginfo ov9650_Effect_Negative[] =
+static struct reginfo sensor_MirrorOff[]=
{
- //Negative
- {0x3a,0x2d},
- {0x67,0x80},
- {0x68,0x80},
{0x00, 0x00}
};
-static struct reginfo ov9650_Effect_Bluish[] =
+static struct reginfo *sensor_MirrorSeqe[] = {sensor_MirrorOff, sensor_MirrorOn,NULL,};
+#endif
+#if CONFIG_SENSOR_Flip
+static struct reginfo sensor_FlipOn[]=
{
- // Bluish
- {0x3a,0x1d},
- {0x67,0xc0},
- {0x68,0x80},
{0x00, 0x00}
};
-static struct reginfo ov9650_Effect_Green[] =
+static struct reginfo sensor_FlipOff[]=
{
- // Greenish
- {0x3a,0x1d},
- {0x67,0x40},
- {0x68,0x40},
{0x00, 0x00}
};
-static struct reginfo ov9650_Exposure0[]=
-{
- //-3
+static struct reginfo *sensor_FlipSeqe[] = {sensor_FlipOff, sensor_FlipOn,NULL,};
- {0x00, 0x00}
+#endif
+#if CONFIG_SENSOR_Scene
+static struct reginfo sensor_SceneAuto[] =
+{
+{0x00, 0x00}
};
-static struct reginfo ov9650_Exposure1[]=
+static struct reginfo sensor_SceneNight[] =
{
- //-2
-
- {0x00, 0x00}
+{0x00, 0x00}
};
+static struct reginfo *sensor_SceneSeqe[] = {sensor_SceneAuto, sensor_SceneNight,NULL,};
-static struct reginfo ov9650_Exposure2[]=
+#endif
+#if CONFIG_SENSOR_DigitalZoom
+static struct reginfo sensor_Zoom0[] =
{
- //-0.3EV
-
- {0x00, 0x00}
+ {0x0, 0x0},
};
-static struct reginfo ov9650_Exposure3[]=
+static struct reginfo sensor_Zoom1[] =
{
- //default
+ {0x0, 0x0},
+};
- {0x00, 0x00}
+static struct reginfo sensor_Zoom2[] =
+{
+ {0x0, 0x0},
};
-static struct reginfo ov9650_Exposure4[]=
+
+static struct reginfo sensor_Zoom3[] =
+{
+ {0x0, 0x0},
+};
+static struct reginfo *sensor_ZoomSeqe[] = {sensor_Zoom0, sensor_Zoom1, sensor_Zoom2, sensor_Zoom3, NULL,};
+#endif
+static const struct v4l2_querymenu sensor_menus[] =
{
- // 1
+ #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,},
+ { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
+ { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
+ #endif
- {0x00, 0x00}
+ #if CONFIG_SENSOR_Effect
+ { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
+ { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
+ { .id = V4L2_CID_EFFECT, .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT, .index = 5, .name = "aqua", .reserved = 0,},
+ #endif
+
+ #if CONFIG_SENSOR_Scene
+ { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
+ #endif
+
+ #if CONFIG_SENSOR_Flash
+ { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
+ { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
+ #endif
};
-static struct reginfo ov9650_Exposure5[]=
+static const struct v4l2_queryctrl sensor_controls[] =
{
- // 2
+ #if CONFIG_SENSOR_WhiteBalance
+ {
+ .id = V4L2_CID_DO_WHITE_BALANCE,
+ .type = V4L2_CTRL_TYPE_MENU,
+ .name = "White Balance Control",
+ .minimum = 0,
+ .maximum = 4,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
- {0x00, 0x00}
+ #if CONFIG_SENSOR_Brightness
+ {
+ .id = V4L2_CID_BRIGHTNESS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Brightness Control",
+ .minimum = -3,
+ .maximum = 2,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Effect
+ {
+ .id = V4L2_CID_EFFECT,
+ .type = V4L2_CTRL_TYPE_MENU,
+ .name = "Effect Control",
+ .minimum = 0,
+ .maximum = 5,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Exposure
+ {
+ .id = V4L2_CID_EXPOSURE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Exposure Control",
+ .minimum = 0,
+ .maximum = 6,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Saturation
+ {
+ .id = V4L2_CID_SATURATION,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Saturation Control",
+ .minimum = 0,
+ .maximum = 2,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Contrast
+ {
+ .id = V4L2_CID_CONTRAST,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Contrast Control",
+ .minimum = -3,
+ .maximum = 3,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Mirror
+ {
+ .id = V4L2_CID_HFLIP,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "Mirror Control",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 1,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Flip
+ {
+ .id = V4L2_CID_VFLIP,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "Flip Control",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 1,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Scene
+ {
+ .id = V4L2_CID_SCENE,
+ .type = V4L2_CTRL_TYPE_MENU,
+ .name = "Scene Control",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_DigitalZoom
+ {
+ .id = V4L2_CID_ZOOM_RELATIVE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "DigitalZoom Control",
+ .minimum = -1,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ }, {
+ .id = V4L2_CID_ZOOM_ABSOLUTE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "DigitalZoom Control",
+ .minimum = 0,
+ .maximum = 3,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Focus
+ {
+ .id = V4L2_CID_FOCUS_RELATIVE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Focus Control",
+ .minimum = -1,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ }, {
+ .id = V4L2_CID_FOCUS_ABSOLUTE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Focus Control",
+ .minimum = 0,
+ .maximum = 255,
+ .step = 1,
+ .default_value = 125,
+ },
+ #endif
+
+ #if CONFIG_SENSOR_Flash
+ {
+ .id = V4L2_CID_FLASH,
+ .type = V4L2_CTRL_TYPE_MENU,
+ .name = "Flash Control",
+ .minimum = 0,
+ .maximum = 3,
+ .step = 1,
+ .default_value = 0,
+ },
+ #endif
};
-static struct reginfo ov9650_Exposure6[]=
+static int sensor_probe(struct i2c_client *client, const struct i2c_device_id *did);
+static int sensor_video_probe(struct soc_camera_device *icd, struct i2c_client *client);
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
+static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
+static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl);
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
+static int sensor_resume(struct soc_camera_device *icd);
+static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
+
+static struct soc_camera_ops sensor_ops =
{
- // 3
+ .suspend = sensor_suspend,
+ .resume = sensor_resume,
+ .set_bus_param = sensor_set_bus_param,
+ .query_bus_param = sensor_query_bus_param,
+ .controls = sensor_controls,
+ .menus = sensor_menus,
+ .num_controls = ARRAY_SIZE(sensor_controls),
+ .num_menus = ARRAY_SIZE(sensor_menus),
+};
- {0x00, 0x00}
+#define COL_FMT(_name, _depth, _fourcc, _colorspace) \
+ { .name = _name, .depth = _depth, .fourcc = _fourcc, \
+ .colorspace = _colorspace }
+
+#define JPG_FMT(_name, _depth, _fourcc) \
+ COL_FMT(_name, _depth, _fourcc, V4L2_COLORSPACE_JPEG)
+
+static const struct soc_camera_data_format sensor_colour_formats[] = {
+ JPG_FMT(SENSOR_NAME_STRING(UYVY), 16, V4L2_PIX_FMT_UYVY),
+ JPG_FMT(SENSOR_NAME_STRING(YUYV), 16, V4L2_PIX_FMT_YUYV),
};
-static struct reginfo ov9650_Saturation0[]=
+typedef struct sensor_info_priv_s
{
+ int whiteBalance;
+ int brightness;
+ int contrast;
+ int saturation;
+ int effect;
+ int scene;
+ int digitalzoom;
+ int focus;
+ int flash;
+ int exposure;
+ unsigned char mirror; /* HFLIP */
+ unsigned char flip; /* VFLIP */
+ unsigned int winseqe_cur_addr;
- {0x00, 0x00}
+} sensor_info_priv_t;
+
+struct sensor
+{
+ struct v4l2_subdev subdev;
+ struct i2c_client *client;
+ sensor_info_priv_t info_priv;
+ unsigned int pixfmt;
+ int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
};
-static struct reginfo ov9650_Saturation1[]=
+static struct sensor* to_sensor(const struct i2c_client *client)
{
+ return container_of(i2c_get_clientdata(client), struct sensor, subdev);
+}
- {0x00, 0x00}
-};
+/* sensor register write */
+static int sensor_write(struct i2c_client *client, u8 reg, u8 val)
+{
+ int err,cnt;
+ u8 buf[2];
+ struct i2c_msg msg[1];
+
+ buf[0] = reg & 0xFF;
+ buf[1] = val;
+
+ msg->addr = client->addr;
+ msg->flags = client->flags;
+ msg->buf = buf;
+ msg->len = sizeof(buf);
+ msg->scl_rate = 400*1000; /* ddl@rock-chips.com : 100kHz */
+ msg->read_type = I2C_NORMAL;
+
+ cnt = 3;
+ err = -EAGAIN;
+
+ while ((cnt--) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
+ err = i2c_transfer(client->adapter, msg, 1);
+
+ if (err >= 0) {
+ return 0;
+ } else {
+ SENSOR_TR("\n %s write reg failed, try to write again!\n",SENSOR_NAME_STRING());
+ udelay(10);
+ }
+ }
-static struct reginfo ov9650_Saturation2[]=
+ return err;
+}
+
+/* sensor register read */
+static int sensor_read(struct i2c_client *client, u8 reg, u8 *val)
{
+ int err,cnt;
+ u8 buf[1];
+ struct i2c_msg msg[1];
- {0x00, 0x00}
-};
+ buf[0] = reg & 0xFF;
+
+ msg->addr = client->addr;
+ msg->flags = client->flags;
+ msg->buf = buf;
+ msg->len = sizeof(buf);
+ msg->scl_rate = 400*1000; /* ddl@rock-chips.com : 100kHz */
+ i2c_transfer(client->adapter, msg, 1);
+ msg->addr = client->addr;
+ msg->flags = client->flags|I2C_M_RD;
+ msg->buf = buf;
+ msg->len = 1; /* ddl@rock-chips.com : 100kHz */
+ cnt = 3;
+ err = -EAGAIN;
+ while ((cnt--) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
+ err = i2c_transfer(client->adapter, msg, 1);
-static struct reginfo ov9650_Contrast0[]=
-{
- //Contrast -3
+ if (err >= 0) {
+ *val = buf[0];
+ return 0;
+ } else {
+ SENSOR_TR("\n %s write reg failed, try to read again!\n",SENSOR_NAME_STRING());
+ udelay(10);
+ }
+ }
- {0x00, 0x00}
-};
+ return err;
+}
-static struct reginfo ov9650_Contrast1[]=
+/* write a array of registers */
+static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
{
- //Contrast -2
+ int err;
+ int i = 0;
- {0x00, 0x00}
-};
+ while (regarray[i].reg != 0)
+ {
+ err = sensor_write(client, regarray[i].reg, regarray[i].val);
+ if (err != 0)
+ {
+ SENSOR_TR("%s..write failed current i = %d\n", SENSOR_NAME_STRING(),i);
+ return err;
+ }
+ i++;
+ }
+ return 0;
+}
-static struct reginfo ov9650_Contrast2[]=
+static int sensor_init(struct v4l2_subdev *sd, u32 val)
{
- // Contrast -1
-
- {0x00, 0x00}
-};
+ struct i2c_client *client = sd->priv;
+ struct soc_camera_device *icd = client->dev.platform_data;
+ struct sensor *sensor = to_sensor(client);
+ const struct v4l2_queryctrl *qctrl;
+ int ret;
-static struct reginfo ov9650_Contrast3[]=
-{
- //Contrast 0
+ SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
- {0x00, 0x00}
-};
+ /* soft reset */
+ ret = sensor_write(client, 0x12, 0x80);
+ if (ret != 0)
+ {
+ SENSOR_TR("%s soft reset sensor failed\n",SENSOR_NAME_STRING());
+ ret = -ENODEV;
+ goto sensor_INIT_ERR;
+ }
-static struct reginfo ov9650_Contrast4[]=
-{
- //Contrast +1
+ mdelay(5); //delay 5 microseconds
- {0x00, 0x00}
-};
+ ret = sensor_write_array(client, sensor_init_data);
+ if (ret != 0)
+ {
+ SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
+ goto sensor_INIT_ERR;
+ }
+ icd->user_width = SENSOR_INIT_WIDTH;
+ icd->user_height = SENSOR_INIT_HEIGHT;
+ sensor->info_priv.winseqe_cur_addr = (int)SENSOR_INIT_WINSEQADR;
+
+ /* sensor sensor information for initialization */
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
+ if (qctrl)
+ sensor->info_priv.whiteBalance = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_BRIGHTNESS);
+ if (qctrl)
+ sensor->info_priv.brightness = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
+ if (qctrl)
+ sensor->info_priv.effect = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EXPOSURE);
+ if (qctrl)
+ sensor->info_priv.exposure = qctrl->default_value;
+
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SATURATION);
+ if (qctrl)
+ sensor->info_priv.saturation = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_CONTRAST);
+ if (qctrl)
+ sensor->info_priv.contrast = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_HFLIP);
+ if (qctrl)
+ sensor->info_priv.mirror = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_VFLIP);
+ if (qctrl)
+ sensor->info_priv.flip = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_SCENE);
+ if (qctrl)
+ sensor->info_priv.scene = qctrl->default_value;
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
+ if (qctrl)
+ sensor->info_priv.digitalzoom = qctrl->default_value;
-static struct reginfo ov9650_Contrast5[]=
-{
- //Contrast +2
+ /* ddl@rock-chips.com : if sensor support auto focus and flash, programer must run focus and flash code */
+ #if CONFIG_SENSOR_Focus
+ sensor_set_focus();
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FOCUS_ABSOLUTE);
+ if (qctrl)
+ sensor->info_priv.focus = qctrl->default_value;
+ #endif
- {0x00, 0x00}
-};
+ #if CONFIG_SENSOR_Flash
+ sensor_set_flash();
+ qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
+ if (qctrl)
+ sensor->info_priv.flash = qctrl->default_value;
+ #endif
-static struct reginfo ov9650_Contrast6[]=
-{
- //Contrast +3
+ SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,icd->user_width,icd->user_height);
- {0x00, 0x00}
-};
+ return 0;
+sensor_INIT_ERR:
+ return ret;
+}
-static struct reginfo ov9650_MirrorOn[]=
+static struct reginfo sensor_power_down_sequence[]=
{
-
- {0x00, 0x00}
+ {0x00,0x00}
};
-
-static struct reginfo ov9650_MirrorOff[]=
+static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
{
+ int ret;
+ struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+ struct soc_camera_link *icl;
- {0x00, 0x00}
-};
-
-static struct reginfo ov9650_FlipOn[]=
-{
- {0x00, 0x00}
-};
+ if (pm_msg.event == PM_EVENT_SUSPEND)
+ {
+ SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
+ ret = sensor_write_array(client, sensor_power_down_sequence) ;
+ if (ret != 0)
+ {
+ SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
+ return ret;
+ }
+ else
+ {
+ icl = to_soc_camera_link(icd);
+ if (icl->power) {
+ ret = icl->power(icd->pdev, 0);
+ if (ret < 0)
+ return -EINVAL;
+ }
+ }
+ }
+ else
+ {
+ SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
+ return -EINVAL;
+ }
+ return 0;
+}
-static struct reginfo ov9650_FlipOff[]=
+static int sensor_resume(struct soc_camera_device *icd)
{
+ struct soc_camera_link *icl;
+ int ret;
- {0x00, 0x00}
-};
+ icl = to_soc_camera_link(icd);
+ if (icl->power) {
+ ret = icl->power(icd->pdev, 0);
+ if (ret < 0)
+ return -EINVAL;
+ }
-static struct reginfo ov9650_SceneAuto[] =
-{
+ return 0;
- {0x00, 0x00}
-};
+}
-static struct reginfo ov9650_SceneNight[] =
+static int sensor_set_bus_param(struct soc_camera_device *icd,
+ unsigned long flags)
{
- {0x00, 0x00}
-};
+ return 0;
+}
-static struct reginfo ov9650_Zoom0[] =
+static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
{
- {0x0, 0x0},
-};
+ struct soc_camera_link *icl = to_soc_camera_link(icd);
+ unsigned long flags = SENSOR_BUS_PARAM;
-static struct reginfo ov9650_Zoom1[] =
-{
- {0x0, 0x0},
-};
+ return soc_camera_apply_sensor_flags(icl, flags);
+}
-static struct reginfo ov9650_Zoom2[] =
+static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
{
- {0x0, 0x0},
-};
+ struct i2c_client *client = sd->priv;
+ struct soc_camera_device *icd = client->dev.platform_data;
+ struct sensor *sensor = to_sensor(client);
+ struct v4l2_pix_format *pix = &f->fmt.pix;
+ pix->width = icd->user_width;
+ pix->height = icd->user_height;
+ pix->pixelformat = sensor->pixfmt;
+ pix->field = V4L2_FIELD_NONE;
+ pix->colorspace = V4L2_COLORSPACE_JPEG;
-static struct reginfo ov9650_Zoom3[] =
+ return 0;
+}
+static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
{
- {0x0, 0x0},
-};
+ struct i2c_client *client = sd->priv;
+ struct sensor *sensor = to_sensor(client);
+ struct v4l2_pix_format *pix = &f->fmt.pix;
+ struct reginfo *winseqe_set_addr;
+ int ret, set_w,set_h;
-static struct reginfo *ov9650_ExposureSeqe[] = {ov9650_Exposure0, ov9650_Exposure1, ov9650_Exposure2, ov9650_Exposure3,
- ov9650_Exposure4, ov9650_Exposure5,ov9650_Exposure6,NULL,
-};
+ set_w = pix->width;
+ set_h = pix->height;
-static struct reginfo *ov9650_EffectSeqe[] = {ov9650_Effect_Normal, ov9650_Effect_WandB, ov9650_Effect_Negative,ov9650_Effect_Sepia,
- ov9650_Effect_Bluish, ov9650_Effect_Green,NULL,
-};
+ if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg)
+ {
+ winseqe_set_addr = sensor_qcif;
+ set_w = 176;
+ set_h = 144;
+ }
+ else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg)
+ {
+ winseqe_set_addr = sensor_qvga;
+ set_w = 320;
+ set_h = 240;
+ }
+ else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg)
+ {
+ winseqe_set_addr = sensor_cif;
+ set_w = 352;
+ set_h = 288;
+ }
+ else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg)
+ {
+ winseqe_set_addr = sensor_vga;
+ set_w = 640;
+ set_h = 480;
+ }
+ else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg)
+ {
+ winseqe_set_addr = sensor_sxga;
+ set_w = 1280;
+ set_h = 1024;
+ }
+ else if (sensor_qvga[0].reg)
+ {
+ winseqe_set_addr = sensor_qvga; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */
+ set_w = 320;
+ set_h = 240;
+ }
+ else
+ {
+ SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,pix->width,pix->height);
+ return -EINVAL;
+ }
-static struct reginfo *ov9650_WhiteBalanceSeqe[] = {ov9650_WhiteB_Auto, ov9650_WhiteB_TungstenLamp1,ov9650_WhiteB_TungstenLamp2,
- ov9650_WhiteB_ClearDay, ov9650_WhiteB_Cloudy,NULL,
-};
+ if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr)
+ {
+ ret = sensor_write_array(client, winseqe_set_addr);
+ if (ret != 0)
+ {
+ SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
+ return ret;
+ }
-static struct reginfo *ov9650_BrightnessSeqe[] = {ov9650_Brightness0, ov9650_Brightness1, ov9650_Brightness2, ov9650_Brightness3,
- ov9650_Brightness4, ov9650_Brightness5,NULL,
-};
+ sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
+ mdelay(250);
-static struct reginfo *ov9650_ContrastSeqe[] = {ov9650_Contrast0, ov9650_Contrast1, ov9650_Contrast2, ov9650_Contrast3,
- ov9650_Contrast4, ov9650_Contrast5, ov9650_Contrast6, NULL,
-};
+ SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
+ }
+ else
+ {
+ SENSOR_TR("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
+ }
-static struct reginfo *ov9650_SaturationSeqe[] = {ov9650_Saturation0, ov9650_Saturation1, ov9650_Saturation2, NULL,};
+ return 0;
+}
-static struct reginfo *ov9650_MirrorSeqe[] = {ov9650_MirrorOff, ov9650_MirrorOn,NULL,};
+static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+{
+ struct v4l2_pix_format *pix = &f->fmt.pix;
+ bool bayer = pix->pixelformat == V4L2_PIX_FMT_UYVY ||
+ pix->pixelformat == V4L2_PIX_FMT_YUYV;
-static struct reginfo *ov9650_FlipSeqe[] = {ov9650_FlipOff, ov9650_FlipOn,NULL,};
+ /*
+ * With Bayer format enforce even side lengths, but let the user play
+ * with the starting pixel
+ */
-static struct reginfo *ov9650_SceneSeqe[] = {ov9650_SceneAuto, ov9650_SceneNight,NULL,};
+ if (pix->height > SENSOR_MAX_HEIGHT)
+ pix->height = SENSOR_MAX_HEIGHT;
+ else if (pix->height < SENSOR_MIN_HEIGHT)
+ pix->height = SENSOR_MIN_HEIGHT;
+ else if (bayer)
+ pix->height = ALIGN(pix->height, 2);
-static struct reginfo *ov9650_ZoomSeqe[] = {ov9650_Zoom0, ov9650_Zoom1, ov9650_Zoom2, ov9650_Zoom3, NULL,};
+ if (pix->width > SENSOR_MAX_WIDTH)
+ pix->width = SENSOR_MAX_WIDTH;
+ else if (pix->width < SENSOR_MIN_WIDTH)
+ pix->width = SENSOR_MIN_WIDTH;
+ else if (bayer)
+ pix->width = ALIGN(pix->width, 2);
+ return 0;
+}
-static const struct v4l2_querymenu ov9650_menus[] =
+ static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
{
- { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 0, .name = "auto", .reserved = 0, }, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 1, .name = "incandescent", .reserved = 0,},
- { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 2, .name = "fluorescent", .reserved = 0,}, { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 3, .name = "daylight", .reserved = 0,},
- { .id = V4L2_CID_DO_WHITE_BALANCE, .index = 4, .name = "cloudy-daylight", .reserved = 0,},
- { .id = V4L2_CID_EFFECT, .index = 0, .name = "none", .reserved = 0, }, { .id = V4L2_CID_EFFECT, .index = 1, .name = "mono", .reserved = 0,},
- { .id = V4L2_CID_EFFECT, .index = 2, .name = "negative", .reserved = 0,}, { .id = V4L2_CID_EFFECT, .index = 3, .name = "sepia", .reserved = 0,},
- { .id = V4L2_CID_EFFECT, .index = 4, .name = "posterize", .reserved = 0,} ,{ .id = V4L2_CID_EFFECT, .index = 5, .name = "aqua", .reserved = 0,},
- { .id = V4L2_CID_SCENE, .index = 0, .name = "auto", .reserved = 0,} ,{ .id = V4L2_CID_SCENE, .index = 1, .name = "night", .reserved = 0,},
- { .id = V4L2_CID_FLASH, .index = 0, .name = "off", .reserved = 0, }, { .id = V4L2_CID_FLASH, .index = 1, .name = "auto", .reserved = 0,},
- { .id = V4L2_CID_FLASH, .index = 2, .name = "on", .reserved = 0,}, { .id = V4L2_CID_FLASH, .index = 3, .name = "torch", .reserved = 0,},
-};
+ struct i2c_client *client = sd->priv;
-static struct soc_camera_ops ov9650_ops =
-{
- .suspend = ov9650_suspend,
- .resume = ov9650_resume,
- .set_bus_param = ov9650_set_bus_param,
- .query_bus_param = ov9650_query_bus_param,
- .controls = ov9650_controls,
- .menus = ov9650_menus,
- .num_controls = ARRAY_SIZE(ov9650_controls),
- .num_menus = ARRAY_SIZE(ov9650_menus),
-};
-static int ov9650_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+ if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
+ return -EINVAL;
+
+ if (id->match.addr != client->addr)
+ return -ENODEV;
+
+ id->ident = SENSOR_V4L2_IDENT; /* ddl@rock-chips.com : Return OV9650 identifier */
+ id->revision = 0;
+
+ return 0;
+}
+#if CONFIG_SENSOR_Brightness
+static int sensor_set_brightness(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov9650_BrightnessSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_BrightnessSeqe[value - qctrl->minimum] != NULL)
{
- if (ov9650_write_array(client, ov9650_BrightnessSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_BrightnessSeqe[value - qctrl->minimum]) != 0)
{
- OV9650_TR("\n OV9650 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("\n OV9650 Set Brightness - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-static int ov9650_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Effect
+static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov9650_EffectSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_EffectSeqe[value - qctrl->minimum] != NULL)
{
- if (ov9650_write_array(client, ov9650_EffectSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_EffectSeqe[value - qctrl->minimum]) != 0)
{
- OV9650_TR("\n OV9650 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("\n OV9650 Set effect - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-static int ov9650_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Exposure
+static int sensor_set_exposure(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov9650_ExposureSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_ExposureSeqe[value - qctrl->minimum] != NULL)
{
- if (ov9650_write_array(client, ov9650_ExposureSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_ExposureSeqe[value - qctrl->minimum]) != 0)
{
- OV9650_TR("\n OV9650 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("\n OV9650 Set Exposurce - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov9650_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Saturation
+static int sensor_set_saturation(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov9650_SaturationSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_SaturationSeqe[value - qctrl->minimum] != NULL)
{
- if (ov9650_write_array(client, ov9650_SaturationSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_SaturationSeqe[value - qctrl->minimum]) != 0)
{
- OV9650_TR("\n OV9650 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("\n OV9650 Set Saturation - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV9650_TR("\n Saturation valure = %d is invalidate.. ******** ddl *********\n",value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov9650_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Contrast
+static int sensor_set_contrast(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov9650_ContrastSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_ContrastSeqe[value - qctrl->minimum] != NULL)
{
- if (ov9650_write_array(client, ov9650_ContrastSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_ContrastSeqe[value - qctrl->minimum]) != 0)
{
- OV9650_TR("\n OV9650 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("\n OV9650 Set Contrast - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV9650_TR("\n Contrast valure = %d is invalidate.. ******** ddl *********\n", value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov9650_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Mirror
+static int sensor_set_mirror(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov9650_MirrorSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_MirrorSeqe[value - qctrl->minimum] != NULL)
{
- if (ov9650_write_array(client, ov9650_MirrorSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_MirrorSeqe[value - qctrl->minimum]) != 0)
{
- OV9650_TR("\n OV9650 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("\n OV9650 Set Mirror - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV9650_TR("\n Mirror valure = %d is invalidate.. ******** ddl *********\n", value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-
-static int ov9650_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Flip
+static int sensor_set_flip(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov9650_FlipSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_FlipSeqe[value - qctrl->minimum] != NULL)
{
- if (ov9650_write_array(client, ov9650_FlipSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_FlipSeqe[value - qctrl->minimum]) != 0)
{
- OV9650_TR("\n OV9650 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("\n OV9650 Set Flip - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV9650_TR("\n Flip valure = %d is invalidate.. ******** ddl *********\n", value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov9650_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_Scene
+static int sensor_set_scene(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov9650_SceneSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_SceneSeqe[value - qctrl->minimum] != NULL)
{
- if (ov9650_write_array(client, ov9650_SceneSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_SceneSeqe[value - qctrl->minimum]) != 0)
{
- OV9650_TR("\n OV9650 WriteReg Fail.. %x ******** ddl *********\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("\n OV9650 Set Scene - %x ******** ddl *********\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
- OV9650_TR("\n Scene valure = %d is invalidate.. ******** ddl *********\n", value);
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov9650_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
+#endif
+#if CONFIG_SENSOR_WhiteBalance
+static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
if ((value >= qctrl->minimum) && (value <= qctrl->maximum))
{
- if (ov9650_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
+ if (sensor_WhiteBalanceSeqe[value - qctrl->minimum] != NULL)
{
- if (ov9650_write_array(client, ov9650_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
+ if (sensor_write_array(client, sensor_WhiteBalanceSeqe[value - qctrl->minimum]) != 0)
{
- OV9650_TR("OV9650 WriteReg Fail.. %x\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("ov9650_set_whiteBalance - %x\n", value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
}
+ SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
-
-static int ov9650_set_digitalzoom(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int *value)
+#endif
+#if CONFIG_SENSOR_DigitalZoom
+static int sensor_set_digitalzoom(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 ov9650 *ov9650 = to_ov9650(client);
+ struct sensor *sensor = to_sensor(client);
+ const struct v4l2_queryctrl *qctrl_info;
int digitalzoom_cur, digitalzoom_total;
- digitalzoom_cur = ov9650->info_priv.digitalzoom;
- digitalzoom_total = ov9650_controls[10].maximum;
+ qctrl_info = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_ZOOM_ABSOLUTE);
+ if (qctrl_info)
+ return -EINVAL;
+
+ digitalzoom_cur = sensor->info_priv.digitalzoom;
+ digitalzoom_total = qctrl_info->maximum;
if ((*value > 0) && (digitalzoom_cur >= digitalzoom_total))
{
- OV9650_TR("ov9650 digitalzoom is maximum - %x\n", digitalzoom_cur);
+ SENSOR_TR("%s digitalzoom is maximum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
return -EINVAL;
}
- if ((*value < 0) && (digitalzoom_cur <= ov9650_controls[10].minimum))
+ if ((*value < 0) && (digitalzoom_cur <= qctrl_info->minimum))
{
- OV9650_TR("ov9650 digitalzoom is minimum - %x\n", digitalzoom_cur);
+ SENSOR_TR("%s digitalzoom is minimum - %x\n", SENSOR_NAME_STRING(), digitalzoom_cur);
return -EINVAL;
}
digitalzoom_cur += *value;
- if (ov9650_ZoomSeqe[digitalzoom_cur] != NULL)
+ if (sensor_ZoomSeqe[digitalzoom_cur] != NULL)
{
- if (ov9650_write_array(client, ov9650_ZoomSeqe[digitalzoom_cur]) != 0)
+ if (sensor_write_array(client, sensor_ZoomSeqe[digitalzoom_cur]) != 0)
{
- OV9650_TR("OV9650 WriteReg Fail.. %x\n", __LINE__);
+ SENSOR_TR("%s..%s WriteReg Fail.. \n",SENSOR_NAME_STRING(), __FUNCTION__);
return -EINVAL;
}
- OV9650_DG("ov9650_set_digitalzoom - %x\n", *value);
+ SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, *value);
return 0;
}
return -EINVAL;
}
-
-static int ov9650_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+#endif
+static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
struct i2c_client *client = sd->priv;
- struct ov9650 *ov9650 = to_ov9650(client);
+ struct sensor *sensor = to_sensor(client);
const struct v4l2_queryctrl *qctrl;
- qctrl = soc_camera_find_qctrl(&ov9650_ops, ctrl->id);
+ qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
if (!qctrl)
{
- OV9650_TR("\n%s..%s..%d.. ioctrl is faild ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
+ SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
return -EINVAL;
}
{
case V4L2_CID_BRIGHTNESS:
{
- ctrl->value = ov9650->info_priv.brightness;
+ ctrl->value = sensor->info_priv.brightness;
break;
}
case V4L2_CID_SATURATION:
{
- ctrl->value = ov9650->info_priv.saturation;
+ ctrl->value = sensor->info_priv.saturation;
break;
}
case V4L2_CID_CONTRAST:
{
- ctrl->value = ov9650->info_priv.contrast;
+ ctrl->value = sensor->info_priv.contrast;
break;
}
case V4L2_CID_DO_WHITE_BALANCE:
{
- ctrl->value = ov9650->info_priv.whiteBalance;
+ ctrl->value = sensor->info_priv.whiteBalance;
break;
}
case V4L2_CID_EXPOSURE:
{
- ctrl->value = ov9650->info_priv.exposure;
+ ctrl->value = sensor->info_priv.exposure;
break;
}
case V4L2_CID_HFLIP:
{
- ctrl->value = ov9650->info_priv.mirror;
+ ctrl->value = sensor->info_priv.mirror;
break;
}
case V4L2_CID_VFLIP:
{
- ctrl->value = ov9650->info_priv.flip;
+ ctrl->value = sensor->info_priv.flip;
break;
}
default :
-static int ov9650_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
struct i2c_client *client = sd->priv;
- struct ov9650 *ov9650 = to_ov9650(client);
+ struct sensor *sensor = to_sensor(client);
struct soc_camera_device *icd = client->dev.platform_data;
const struct v4l2_queryctrl *qctrl;
- qctrl = soc_camera_find_qctrl(&ov9650_ops, ctrl->id);
+ qctrl = soc_camera_find_qctrl(&sensor_ops, ctrl->id);
if (!qctrl)
{
- OV9650_TR("\n OV9650 ioctrl id = %x is invalidate ******** ddl *********\n", ctrl->id);
+ SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ctrl->id);
return -EINVAL;
}
switch (ctrl->id)
{
+#if CONFIG_SENSOR_Brightness
case V4L2_CID_BRIGHTNESS:
{
- if (ctrl->value != ov9650->info_priv.brightness)
+ if (ctrl->value != sensor->info_priv.brightness)
{
- if (ov9650_set_brightness(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_brightness(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov9650->info_priv.brightness = ctrl->value;
+ sensor->info_priv.brightness = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Exposure
case V4L2_CID_EXPOSURE:
{
- if (ctrl->value != ov9650->info_priv.exposure)
+ if (ctrl->value != sensor->info_priv.exposure)
{
- if (ov9650_set_exposure(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_exposure(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov9650->info_priv.exposure = ctrl->value;
+ sensor->info_priv.exposure = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Saturation
case V4L2_CID_SATURATION:
{
- if (ctrl->value != ov9650->info_priv.saturation)
+ if (ctrl->value != sensor->info_priv.saturation)
{
- if (ov9650_set_saturation(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_saturation(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov9650->info_priv.saturation = ctrl->value;
+ sensor->info_priv.saturation = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Contrast
case V4L2_CID_CONTRAST:
{
- if (ctrl->value != ov9650->info_priv.contrast)
+ if (ctrl->value != sensor->info_priv.contrast)
{
- if (ov9650_set_contrast(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_contrast(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov9650->info_priv.contrast = ctrl->value;
+ sensor->info_priv.contrast = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_WhiteBalance
case V4L2_CID_DO_WHITE_BALANCE:
{
- if (ctrl->value != ov9650->info_priv.whiteBalance)
+ if (ctrl->value != sensor->info_priv.whiteBalance)
{
- if (ov9650_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_whiteBalance(icd, qctrl,ctrl->value) != 0)
{
return -EINVAL;
}
- ov9650->info_priv.whiteBalance = ctrl->value;
+ sensor->info_priv.whiteBalance = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Mirror
case V4L2_CID_HFLIP:
{
- if (ctrl->value != ov9650->info_priv.mirror)
+ if (ctrl->value != sensor->info_priv.mirror)
{
- if (ov9650_set_mirror(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_mirror(icd, qctrl,ctrl->value) != 0)
return -EINVAL;
- ov9650->info_priv.mirror = ctrl->value;
+ sensor->info_priv.mirror = ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Flip
case V4L2_CID_VFLIP:
{
- if (ctrl->value != ov9650->info_priv.flip)
+ if (ctrl->value != sensor->info_priv.flip)
{
- if (ov9650_set_flip(icd, qctrl,ctrl->value) != 0)
+ if (sensor_set_flip(icd, qctrl,ctrl->value) != 0)
return -EINVAL;
- ov9650->info_priv.flip = ctrl->value;
+ sensor->info_priv.flip = ctrl->value;
}
break;
}
- default :
+#endif
+ default:
break;
}
return 0;
}
-static int ov9650_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
+static int sensor_g_ext_control(struct soc_camera_device *icd , struct v4l2_ext_control *ext_ctrl)
{
const struct v4l2_queryctrl *qctrl;
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
- struct ov9650 *ov9650 = to_ov9650(client);
+ struct sensor *sensor = to_sensor(client);
- qctrl = soc_camera_find_qctrl(&ov9650_ops, ext_ctrl->id);
+ qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
if (!qctrl)
{
- OV9650_TR("\n%s..%s..%d.. ioctrl is faild ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
+ SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
return -EINVAL;
}
{
case V4L2_CID_SCENE:
{
- ext_ctrl->value = ov9650->info_priv.scene;
+ ext_ctrl->value = sensor->info_priv.scene;
break;
}
case V4L2_CID_EFFECT:
{
- ext_ctrl->value = ov9650->info_priv.effect;
+ ext_ctrl->value = sensor->info_priv.effect;
break;
}
case V4L2_CID_ZOOM_ABSOLUTE:
{
- ext_ctrl->value = ov9650->info_priv.digitalzoom;
+ ext_ctrl->value = sensor->info_priv.digitalzoom;
break;
}
case V4L2_CID_ZOOM_RELATIVE:
}
case V4L2_CID_FOCUS_ABSOLUTE:
{
- ext_ctrl->value = ov9650->info_priv.focus;
+ ext_ctrl->value = sensor->info_priv.focus;
break;
}
case V4L2_CID_FOCUS_RELATIVE:
}
case V4L2_CID_FLASH:
{
- ext_ctrl->value = ov9650->info_priv.flash;
+ ext_ctrl->value = sensor->info_priv.flash;
break;
}
default :
}
return 0;
}
-static int ov9650_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
+static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_control *ext_ctrl)
{
const struct v4l2_queryctrl *qctrl;
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
- struct ov9650 *ov9650 = to_ov9650(client);
+ struct sensor *sensor = to_sensor(client);
int val_offset;
- qctrl = soc_camera_find_qctrl(&ov9650_ops, ext_ctrl->id);
+ qctrl = soc_camera_find_qctrl(&sensor_ops, ext_ctrl->id);
if (!qctrl)
{
- OV9650_TR("\n OV9650 ioctrl id = %d is invalidate ******** ddl *********\n", ext_ctrl->id);
+ SENSOR_TR("\n %s ioctrl id = %d is invalidate \n", SENSOR_NAME_STRING(), ext_ctrl->id);
return -EINVAL;
}
+ val_offset = 0;
switch (ext_ctrl->id)
{
+#if CONFIG_SENSOR_Scene
case V4L2_CID_SCENE:
{
- if (ext_ctrl->value != ov9650->info_priv.scene)
+ if (ext_ctrl->value != sensor->info_priv.scene)
{
- if (ov9650_set_scene(icd, qctrl,ext_ctrl->value) != 0)
+ if (sensor_set_scene(icd, qctrl,ext_ctrl->value) != 0)
return -EINVAL;
- ov9650->info_priv.scene = ext_ctrl->value;
+ sensor->info_priv.scene = ext_ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_Effect
case V4L2_CID_EFFECT:
{
- if (ext_ctrl->value != ov9650->info_priv.effect)
+ if (ext_ctrl->value != sensor->info_priv.effect)
{
- if (ov9650_set_effect(icd, qctrl,ext_ctrl->value) != 0)
+ if (sensor_set_effect(icd, qctrl,ext_ctrl->value) != 0)
return -EINVAL;
- ov9650->info_priv.effect= ext_ctrl->value;
+ sensor->info_priv.effect= ext_ctrl->value;
}
break;
}
+#endif
+#if CONFIG_SENSOR_DigitalZoom
case V4L2_CID_ZOOM_ABSOLUTE:
{
if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
return -EINVAL;
- if (ext_ctrl->value != ov9650->info_priv.digitalzoom)
+ if (ext_ctrl->value != sensor->info_priv.digitalzoom)
{
- val_offset = ext_ctrl->value -ov9650->info_priv.digitalzoom;
+ val_offset = ext_ctrl->value -sensor->info_priv.digitalzoom;
- if (ov9650_set_digitalzoom(icd, qctrl,&val_offset) != 0)
+ if (sensor_set_digitalzoom(icd, qctrl,&val_offset) != 0)
return -EINVAL;
- ov9650->info_priv.digitalzoom += val_offset;
+ sensor->info_priv.digitalzoom += val_offset;
- OV9650_DG("ov9650 digitalzoom is %x\n", ov9650->info_priv.digitalzoom);
+ SENSOR_DG("%s digitalzoom is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
}
break;
{
if (ext_ctrl->value)
{
- if (ov9650_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
+ if (sensor_set_digitalzoom(icd, qctrl,&ext_ctrl->value) != 0)
return -EINVAL;
- ov9650->info_priv.digitalzoom += ext_ctrl->value;
+ sensor->info_priv.digitalzoom += ext_ctrl->value;
- OV9650_DG("ov9650 digitalzoom is %x\n", ov9650->info_priv.digitalzoom);
+ SENSOR_DG("%s digitalzoom is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.digitalzoom);
}
break;
}
-
+#endif
+#if CONFIG_SENSOR_Focus
case V4L2_CID_FOCUS_ABSOLUTE:
{
if ((ext_ctrl->value < qctrl->minimum) || (ext_ctrl->value > qctrl->maximum))
return -EINVAL;
- if (ext_ctrl->value != ov9650->info_priv.focus)
+ if (ext_ctrl->value != sensor->info_priv.focus)
{
- val_offset = ext_ctrl->value -ov9650->info_priv.focus;
+ val_offset = ext_ctrl->value -sensor->info_priv.focus;
- ov9650->info_priv.focus += val_offset;
+ sensor->info_priv.focus += val_offset;
}
break;
{
if (ext_ctrl->value)
{
- ov9650->info_priv.focus += ext_ctrl->value;
+ sensor->info_priv.focus += ext_ctrl->value;
- OV9650_DG("ov9650 focus is %x\n", ov9650->info_priv.focus);
+ SENSOR_DG("%s focus is %x\n", SENSOR_NAME_STRING(), sensor->info_priv.focus);
}
break;
}
-
+#endif
+#if CONFIG_SENSOR_Flash
case V4L2_CID_FLASH:
{
- ov9650->info_priv.flash = ext_ctrl->value;
+ sensor->info_priv.flash = ext_ctrl->value;
- OV9650_DG("ov9650 flash is %x\n", ov9650->info_priv.flash);
+ SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
break;
}
+#endif
default:
break;
}
return 0;
}
-static int ov9650_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
+static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
{
struct i2c_client *client = sd->priv;
struct soc_camera_device *icd = client->dev.platform_data;
for (i=0; i<ext_ctrl->count; i++) {
- if (ov9650_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
+ if (sensor_g_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
error_cnt++;
error_idx = i;
}
}
}
-static int ov9650_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
+static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
{
struct i2c_client *client = sd->priv;
struct soc_camera_device *icd = client->dev.platform_data;
for (i=0; i<ext_ctrl->count; i++) {
- if (ov9650_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
+ if (sensor_s_ext_control(icd, &ext_ctrl->controls[i]) != 0) {
error_cnt++;
error_idx = i;
}
/* Interface active, can use i2c. If it fails, it can indeed mean, that
* this wasn't our capture interface, so, we wait for the right one */
-static int ov9650_video_probe(struct soc_camera_device *icd,
+static int sensor_video_probe(struct soc_camera_device *icd,
struct i2c_client *client)
{
char pid = 0;
int ret;
- struct ov9650 *ov9650 = to_ov9650(client);
+ struct sensor *sensor = to_sensor(client);
/* We must have a parent by now. And it cannot be a wrong one.
* So this entire test is completely redundant. */
return -ENODEV;
/* soft reset */
- ret = ov9650_write(client, 0x12, 0x80);
- if (ret < 0)
+ ret = sensor_write(client, 0x12, 0x80);
+ if (ret != 0)
{
- OV9650_TR("soft reset ov9650 failed\n");
+ SENSOR_TR("soft reset %s failed\n",SENSOR_NAME_STRING());
return -ENODEV;
}
- mdelay(5); //delay 5 microseconds
- /* check if it is an ov9650 sensor */
- ret = ov9650_read(client, 0x0a, &pid);
+ mdelay(5); //delay 5 microseconds
+
+ /* check if it is an sensor sensor */
+ ret = sensor_read(client, 0x0a, &pid);
if (ret != 0) {
- OV9650_TR("OV9650 read chip id failed\n");
+ SENSOR_TR("%s read chip id high byte failed\n",SENSOR_NAME_STRING());
ret = -ENODEV;
- goto ov9650_video_probe_err;
+ goto sensor_video_probe_err;
}
- OV9650_DG("\n OV9650 pid = 0x%x\n", pid);
- if (pid == 0x96) {
- ov9650->model = V4L2_IDENT_OV9650;
+ SENSOR_DG("\n %s pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
+ if (pid == SENSOR_ID) {
+ sensor->model = SENSOR_V4L2_IDENT;
} else {
- OV9650_TR("error: devicr mismatched pid = 0x%x\n", pid);
+ SENSOR_TR("error: %s mismatched pid = 0x%x\n", SENSOR_NAME_STRING(), pid);
ret = -ENODEV;
- goto ov9650_video_probe_err;
+ goto sensor_video_probe_err;
}
- icd->formats = ov9650_colour_formats;
- icd->num_formats = ARRAY_SIZE(ov9650_colour_formats);
+ icd->formats = sensor_colour_formats;
+ icd->num_formats = ARRAY_SIZE(sensor_colour_formats);
return 0;
-ov9650_video_probe_err:
+sensor_video_probe_err:
return ret;
}
-static struct v4l2_subdev_core_ops ov9650_subdev_core_ops = {
- .init = ov9650_init,
- .g_ctrl = ov9650_g_control,
- .s_ctrl = ov9650_s_control,
- .g_ext_ctrls = ov9650_g_ext_controls,
- .s_ext_ctrls = ov9650_s_ext_controls,
- .g_chip_ident = ov9650_g_chip_ident,
+static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
+ .init = sensor_init,
+ .g_ctrl = sensor_g_control,
+ .s_ctrl = sensor_s_control,
+ .g_ext_ctrls = sensor_g_ext_controls,
+ .s_ext_ctrls = sensor_s_ext_controls,
+ .g_chip_ident = sensor_g_chip_ident,
};
-static struct v4l2_subdev_video_ops ov9650_subdev_video_ops = {
- .s_fmt = ov9650_s_fmt,
- .g_fmt = ov9650_g_fmt,
- .try_fmt = ov9650_try_fmt,
+static struct v4l2_subdev_video_ops sensor_subdev_video_ops = {
+ .s_fmt = sensor_s_fmt,
+ .g_fmt = sensor_g_fmt,
+ .try_fmt = sensor_try_fmt,
};
-static struct v4l2_subdev_ops ov9650_subdev_ops = {
- .core = &ov9650_subdev_core_ops,
- .video = &ov9650_subdev_video_ops,
+static struct v4l2_subdev_ops sensor_subdev_ops = {
+ .core = &sensor_subdev_core_ops,
+ .video = &sensor_subdev_video_ops,
};
-static int ov9650_probe(struct i2c_client *client,
+static int sensor_probe(struct i2c_client *client,
const struct i2c_device_id *did)
{
- struct ov9650 *ov9650;
+ struct sensor *sensor;
struct soc_camera_device *icd = client->dev.platform_data;
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
struct soc_camera_link *icl;
int ret;
- OV9650_DG("\n%s..%s..%d ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
+ SENSOR_DG("\n%s..%s..%d..\n",__FUNCTION__,__FILE__,__LINE__);
if (!icd) {
- dev_err(&client->dev, "ov9650: missing soc-camera data!\n");
+ dev_err(&client->dev, "%s: missing soc-camera data!\n",SENSOR_NAME_STRING());
return -EINVAL;
}
icl = to_soc_camera_link(icd);
if (!icl) {
- dev_err(&client->dev, "ov9650 driver needs platform data\n");
+ dev_err(&client->dev, "%s driver needs platform data\n", SENSOR_NAME_STRING());
return -EINVAL;
}
return -EIO;
}
- ov9650 = kzalloc(sizeof(struct ov9650), GFP_KERNEL);
- if (!ov9650)
+ sensor = kzalloc(sizeof(struct sensor), GFP_KERNEL);
+ if (!sensor)
return -ENOMEM;
- v4l2_i2c_subdev_init(&ov9650->subdev, client, &ov9650_subdev_ops);
+ v4l2_i2c_subdev_init(&sensor->subdev, client, &sensor_subdev_ops);
/* Second stage probe - when a capture adapter is there */
- icd->ops = &ov9650_ops;
+ icd->ops = &sensor_ops;
icd->y_skip_top = 0;
-
- ret = ov9650_video_probe(icd, client);
-
+ ret = sensor_video_probe(icd, client);
if (ret) {
icd->ops = NULL;
i2c_set_clientdata(client, NULL);
- kfree(ov9650);
+ kfree(sensor);
}
- OV9650_DG("\n%s..%s..%d ret = %x ^^^^^^^^ ddl^^^^^^^^\n",__FUNCTION__,__FILE__,__LINE__,ret);
+ SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
return ret;
}
-static int ov9650_remove(struct i2c_client *client)
+static int sensor_remove(struct i2c_client *client)
{
- struct ov9650 *ov9650 = to_ov9650(client);
+ struct sensor *sensor = to_sensor(client);
struct soc_camera_device *icd = client->dev.platform_data;
icd->ops = NULL;
i2c_set_clientdata(client, NULL);
client->driver = NULL;
- kfree(ov9650);
+ kfree(sensor);
return 0;
}
-static const struct i2c_device_id ov9650_id[] = {
- { "ov9650", 0 },
+static const struct i2c_device_id sensor_id[] = {
+ {SENSOR_NAME_STRING(), 0 },
{ }
};
-MODULE_DEVICE_TABLE(i2c, ov9650_id);
+MODULE_DEVICE_TABLE(i2c, sensor_id);
-static struct i2c_driver ov9650_i2c_driver = {
+static struct i2c_driver sensor_i2c_driver = {
.driver = {
- .name = "ov9650",
+ .name = SENSOR_NAME_STRING(),
},
- .probe = ov9650_probe,
- .remove = ov9650_remove,
- .id_table = ov9650_id,
+ .probe = sensor_probe,
+ .remove = sensor_remove,
+ .id_table = sensor_id,
};
-static int __init ov9650_mod_init(void)
+static int __init sensor_mod_init(void)
{
- OV9650_DG("\n%s..%s..%d ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
- return i2c_add_driver(&ov9650_i2c_driver);
+ SENSOR_DG("\n%s..%s.. \n",__FUNCTION__,SENSOR_NAME_STRING());
+ return i2c_add_driver(&sensor_i2c_driver);
}
-static void __exit ov9650_mod_exit(void)
+static void __exit sensor_mod_exit(void)
{
- i2c_del_driver(&ov9650_i2c_driver);
+ i2c_del_driver(&sensor_i2c_driver);
}
-//module_init(ov9650_mod_init);
-device_initcall_sync(ov9650_mod_init);
-module_exit(ov9650_mod_exit);
+device_initcall_sync(sensor_mod_init);
+module_exit(sensor_mod_exit);
-MODULE_DESCRIPTION("OV9650 Camera sensor driver");
-MODULE_AUTHOR("lbt <kernel@rock-chips>");
+MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
+MODULE_AUTHOR("ddl <kernel@rock-chips>");
MODULE_LICENSE("GPL");
+
enum v4l2_field field,
unsigned int msize,
void *priv);
-
+
/* buffer for one video frame */
struct rk28_buffer
{
/* planar capture requires Y, U and V buffers to be page aligned */
*size = PAGE_ALIGN( icd->user_width * icd->user_height * bytes_per_pixel); /* Y pages UV pages, yuv422*/
- RK28CAMERA_DG("\n%s..%d.. size = %d ******** ddl *********\n",__FUNCTION__,__LINE__, *size);
-
+ RK28CAMERA_DG("\n%s..%d.. size = %d\n",__FUNCTION__,__LINE__, *size);
+
return 0;
}
static void rk28_videobuf_free(struct videobuf_queue *vq, struct rk28_buffer *buf)
dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__,
vb, vb->baddr, vb->bsize);
-
- //RK28CAMERA_TR("\n%s..%d.. ******** ddl *********\n",__FUNCTION__,__LINE__);
-
+
+ //RK28CAMERA_TR("\n%s..%d.. \n",__FUNCTION__,__LINE__);
+
/* Added list head initialization on alloc */
WARN_ON(!list_empty(&vb->queue));
vb->field = field;
vb->state = VIDEOBUF_NEEDS_INIT;
}
-
+
vb->size = vb->width * vb->height * ((buf->fmt->depth + 7) >> 3) ; /* ddl@rock-chips.com : fmt->depth is coorect */
if (0 != vb->baddr && vb->bsize < vb->size) {
ret = -EINVAL;
}
vb->state = VIDEOBUF_PREPARED;
}
- //RK28CAMERA_TR("\n%s..%d.. ^^^^^^^^^ ddl ^^^^^^^^^^ \n",__FUNCTION__,__LINE__);
+ //RK28CAMERA_TR("\n%s..%d.. \n",__FUNCTION__,__LINE__);
return 0;
fail:
rk28_videobuf_free(vq, buf);
dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__,
vb, vb->baddr, vb->bsize);
-
+
vb->state = VIDEOBUF_ACTIVE;
spin_lock_irqsave(&pcdev->lock, flags);
list_add_tail(&vb->queue, &pcdev->capture);
- if (!pcdev->active) {
+ if (!pcdev->active) {
pcdev->active = vb;
rk28_videobuf_capture(vb);
}
struct videobuf_buffer *vb;
read_vip_reg(RK28_VIP_INT_STS); /* clear vip interrupte single */
-
+
/* ddl@rock-chps.com : Current VIP is run in One Frame Mode, Frame 1 is validate */
if (read_vip_reg(RK28_VIP_FB_SR) & 0x01) {
-
+
if (pcdev->frame_inval) {
pcdev->frame_inval--;
rk28_videobuf_capture(pcdev->active);
return IRQ_HANDLED;
}
-
+
vb = pcdev->active;
list_del_init(&vb->queue);
{
unsigned long sensor_bus_flags = SOCAM_MCLK_24MHZ;
struct clk *parent;
-
- RK28CAMERA_DG("\n%s..%d.. ******** ddl *********\n",__FUNCTION__,__LINE__);
- if (!pcdev->clk || IS_ERR(pcdev->clk))
+
+ RK28CAMERA_DG("\n%s..%d.. \n",__FUNCTION__,__LINE__);
+ if (!pcdev->clk || IS_ERR(pcdev->clk))
RK28CAMERA_TR(KERN_ERR "failed to get vip_clk source\n");
-
+
//if (icd->ops->query_bus_param) /* ddl@rock-chips.com : Query Sensor's xclk */
//sensor_bus_flags = icd->ops->query_bus_param(icd);
-
- if (sensor_bus_flags & SOCAM_MCLK_48MHZ) {
+
+ if (sensor_bus_flags & SOCAM_MCLK_48MHZ) {
parent = clk_get(NULL, "clk48m");
- if (!parent || IS_ERR(parent))
+ if (!parent || IS_ERR(parent))
goto RK28_CAMERA_ACTIVE_ERR;
- } else if (sensor_bus_flags & SOCAM_MCLK_27MHZ) {
+ } else if (sensor_bus_flags & SOCAM_MCLK_27MHZ) {
parent = clk_get(NULL, "extclk");
- if (!parent || IS_ERR(parent))
+ if (!parent || IS_ERR(parent))
goto RK28_CAMERA_ACTIVE_ERR;
- } else {
+ } else {
parent = clk_get(NULL, "xin24m");
- if (!parent || IS_ERR(parent))
- goto RK28_CAMERA_ACTIVE_ERR;
+ if (!parent || IS_ERR(parent))
+ goto RK28_CAMERA_ACTIVE_ERR;
}
-
- clk_set_parent(pcdev->clk, parent);
-
+
+ clk_set_parent(pcdev->clk, parent);
+
clk_enable(pcdev->clk);
rk2818_mux_api_set(GPIOF6_VIPCLK_SEL_NAME, IOMUXB_VIP_CLKOUT);
ndelay(10);
-
+
write_vip_reg(RK28_VIP_RESET, 0x76543210); /* ddl@rock-chips.com : vip software reset */
udelay(10);
write_vip_reg(RK28_VIP_INT_MASK, 0x01); //capture complete interrupt enable
write_vip_reg(RK28_VIP_CRM, 0x00000000); //Y/CB/CR color modification
- return 0;
+ return 0;
RK28_CAMERA_ACTIVE_ERR:
return -ENODEV;
}
static void rk28_camera_deactivate(struct rk28_camera_dev *pcdev)
-{
+{
pcdev->active = NULL;
write_vip_reg(RK28_VIP_CTRL, 0);
rk2818_mux_api_set(GPIOF6_VIPCLK_SEL_NAME, IOMUXB_GPIO1_B6);
clk_disable(pcdev->clk);
-
+
return;
}
{
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct rk28_camera_dev *pcdev = ici->priv;
- struct device *control = to_soc_camera_control(icd);
+ struct device *control = to_soc_camera_control(icd);
struct v4l2_subdev *sd;
int ret;
ret = rk28_camera_activate(pcdev,icd);
if (ret)
goto ebusy;
-
+
/* ddl@rock-chips.com : v4l2_subdev is not created when ici->ops->add called in soc_camera_probe */
if (control) {
sd = dev_get_drvdata(control);
unsigned int vip_ctrl_val = 0;
int ret = 0;
- RK28CAMERA_DG("\n%s..%d.. ******** ddl *********\n",__FUNCTION__,__LINE__);
+ RK28CAMERA_DG("\n%s..%d..\n",__FUNCTION__,__LINE__);
bus_flags = RK28_CAM_BUS_PARAM;
}
ret = icd->ops->set_bus_param(icd, common_flags);
- if (ret < 0)
+ if (ret < 0)
goto RK28_CAMERA_SET_BUS_PARAM_END;
icd->buswidth = 8;
-
+
vip_ctrl_val = read_vip_reg(RK28_VIP_CTRL);
if (common_flags & SOCAM_PCLK_SAMPLE_FALLING)
vip_ctrl_val |= NEGATIVE_EDGE;
set_vip_vsp(VSY_HIGH_ACTIVE);
vip_ctrl_val |= ENABLE_CAPTURE;
-
+
write_vip_reg(RK28_VIP_CTRL, vip_ctrl_val);
- RK28CAMERA_DG("\n%s..CtrReg=%x ******** ddl *********\n",__FUNCTION__,read_vip_reg(RK28_VIP_CTRL));
+ RK28CAMERA_DG("\n%s..CtrReg=%x \n",__FUNCTION__,read_vip_reg(RK28_VIP_CTRL));
RK28_CAMERA_SET_BUS_PARAM_END:
if (ret)
- RK28CAMERA_TR("\n%s..%d.. ret = %d ^^^^^^^^^ ddl^^^^^^^^^^\n",__FUNCTION__,__LINE__, ret);
+ RK28CAMERA_TR("\n%s..%d.. ret = %d \n",__FUNCTION__,__LINE__, ret);
return ret;
}
.depth = 16,
.fourcc = V4L2_PIX_FMT_YUV422P,
.colorspace = V4L2_COLORSPACE_JPEG,
- },
+ },
};
static void rk28_camera_setup_format(struct soc_camera_device *icd, __u32 host_pixfmt, __u32 cam_pixfmt, struct v4l2_rect *rect)
{
unsigned int vip_fs,vip_crop;
unsigned int vip_ctrl_val = SENSOR | ONEFRAME |DISABLE_CAPTURE;
-
+
switch (host_pixfmt)
{
case V4L2_PIX_FMT_YUV422P:
default: /* ddl@rock-chips.com : vip output format is hold when pixfmt is invalidate */
vip_ctrl_val |= (read_vip_reg(RK28_VIP_CTRL) & VIPREGYUV422);
break;
- }
+ }
switch (cam_pixfmt)
{
vip_ctrl_val |= (read_vip_reg(RK28_VIP_CTRL) & SENSOR_YUYV);
break;
}
-
- write_vip_reg(RK28_VIP_CTRL, vip_ctrl_val); /* ddl@rock-chips.com: VIP capture mode and capture format must be set before FS register set */
+
+ write_vip_reg(RK28_VIP_CTRL, vip_ctrl_val); /* ddl@rock-chips.com: VIP capture mode and capture format must be set before FS register set */
read_vip_reg(RK28_VIP_INT_STS); /* clear vip interrupte single */
-
+
if (vip_ctrl_val & ONEFRAME) {
vip_crop = ((rect->left<<16) + rect->top);
vip_fs = (((rect->width + rect->left)<<16) + (rect->height+rect->top));
} else if (vip_ctrl_val & PING_PONG) {
WARN_ON(rect->left ||rect->top );
+ RK28CAMERA_DG("\n %s..PingPang not support Crop \n",__FUNCTION__);
+ return;
}
-
+
write_vip_reg(RK28_VIP_CROP, vip_crop);
write_vip_reg(RK28_VIP_FS, vip_fs);
- write_vip_reg(RK28_VIP_FB_SR, 0x00000003);
-
- RK28CAMERA_DG("\n%s.. crop:%x .. fs : %x *** ddl ***\n",__FUNCTION__,vip_crop,vip_fs);
+ write_vip_reg(RK28_VIP_FB_SR, 0x00000003);
+
+ RK28CAMERA_DG("\n%s.. crop:%x .. fs : %x\n",__FUNCTION__,vip_crop,vip_fs);
}
static int rk28_camera_get_formats(struct soc_camera_device *icd, int idx,
{
struct device *dev = icd->dev.parent;
int formats = 0, buswidth, ret;
-
+
buswidth = 8;
-
+
ret = rk28_camera_try_bus_param(icd, buswidth);
if (ret < 0)
return 0;
dev_dbg(dev, "Providing format %s using %s\n",
rk28_camera_formats[0].name,
icd->formats[idx].name);
- }
-
+ }
+
formats++;
if (xlate) {
xlate->host_fmt = &rk28_camera_formats[1];
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
struct v4l2_format f;
struct v4l2_pix_format *pix = &f.fmt.pix;
- int ret;
-
+ int ret;
+
f.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
ret = v4l2_subdev_call(sd, video, g_fmt, &f);
if (ret < 0)
return ret;
-
- if ((pix->width < (a->c.left + a->c.width)) || (pix->height < (a->c.top + a->c.height))) {
-
+
+ if ((pix->width < (a->c.left + a->c.width)) || (pix->height < (a->c.top + a->c.height))) {
+
pix->width = a->c.left + a->c.width;
pix->height = a->c.top + a->c.height;
-
+
v4l_bound_align_image(&pix->width, 48, 2048, 1,
&pix->height, 32, 2048, 0,
icd->current_fmt->fourcc == V4L2_PIX_FMT_YUV422P ?4 : 0);
-
+
ret = v4l2_subdev_call(sd, video, s_fmt, &f);
if (ret < 0)
return ret;
- }
+ }
rk28_camera_setup_format(icd, icd->current_fmt->fourcc, pix->pixelformat, &a->c);
icd->user_width = pix->width;
icd->user_height = pix->height;
-
+
return 0;
}
struct device *dev = icd->dev.parent;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
const struct soc_camera_data_format *cam_fmt = NULL;
- const struct soc_camera_format_xlate *xlate = NULL;
+ const struct soc_camera_format_xlate *xlate = NULL;
struct v4l2_pix_format *pix = &f->fmt.pix;
struct v4l2_format cam_f = *f;
struct v4l2_rect rect;
int ret;
- RK28CAMERA_DG("\n%s..%d.. ******** ddl *********\n",__FUNCTION__,__LINE__);
+ RK28CAMERA_DG("\n%s..%d.. \n",__FUNCTION__,__LINE__);
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
if (!xlate) {
dev_err(dev, "Format %x not found\n", pix->pixelformat);
ret = -EINVAL;
- goto RK28_CAMERA_SET_FMT_END;
+ goto RK28_CAMERA_SET_FMT_END;
}
cam_fmt = xlate->cam_fmt;
rect.width = pix->width;
rect.height = pix->height;
- RK28CAMERA_DG("\n%s..%s..%s ^^^^^^^^^ ddl^^^^^^^^^^\n",__FUNCTION__,xlate->host_fmt->name, cam_fmt->name);
+ RK28CAMERA_DG("\n%s..%s..%s \n",__FUNCTION__,xlate->host_fmt->name, cam_fmt->name);
rk28_camera_setup_format(icd, pix->pixelformat, cam_fmt->fourcc, &rect);
-
+
icd->buswidth = xlate->buswidth;
- icd->current_fmt = xlate->host_fmt;
+ icd->current_fmt = xlate->host_fmt;
}
RK28_CAMERA_SET_FMT_END:
if (ret)
- RK28CAMERA_TR("\n%s..%d.. ret = %d ^^^^^^^^^ ddl^^^^^^^^^^\n",__FUNCTION__,__LINE__, ret);
+ RK28CAMERA_TR("\n%s..%d.. ret = %d \n",__FUNCTION__,__LINE__, ret);
return ret;
}
struct v4l2_pix_format *pix = &f->fmt.pix;
__u32 pixfmt = pix->pixelformat;
enum v4l2_field field;
- int ret,i;
+ int ret;
- RK28CAMERA_DG("\n%s..%d.. ******** ddl *********\n",__FUNCTION__,__LINE__);
+ RK28CAMERA_DG("\n%s..%d.. \n",__FUNCTION__,__LINE__);
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
- if (!xlate) {
+ if (!xlate) {
dev_err(ici->v4l2_dev.dev, "Format %x not found\n", pixfmt);
ret = -EINVAL;
goto RK28_CAMERA_TRY_FMT_END;
RK28_CAMERA_TRY_FMT_END:
if (ret)
- RK28CAMERA_TR("\n%s..%d.. ret = %d ^^^^^^^^^ ddl^^^^^^^^^^\n",__FUNCTION__,__LINE__, ret);
- return ret;
+ RK28CAMERA_TR("\n%s..%d.. ret = %d \n",__FUNCTION__,__LINE__, ret);
+ return ret;
}
static int rk28_camera_reqbufs(struct soc_camera_file *icf,
}
static struct soc_camera_host_ops rk28_soc_camera_host_ops =
-{
+{
.owner = THIS_MODULE,
.add = rk28_camera_add_device,
.remove = rk28_camera_remove_device,
int irq;
int err = 0;
- RK28CAMERA_DG("\n%s..%s..%d ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
+ RK28CAMERA_DG("\n%s..%s..%d \n",__FUNCTION__,__FILE__,__LINE__);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0);
if (!res || irq < 0) {
goto exit_alloc;
}
rk28_camdev_info_ptr = pcdev;
-
+
/*config output clk*/
pcdev->clk = clk_get(&pdev->dev, "vip");
if (!pcdev->clk || IS_ERR(pcdev->clk)) {
err = -ENOENT;
goto exit_eclkget;
}
-
+
dev_set_drvdata(&pdev->dev, pcdev);
pcdev->res = res;
if (err) {
dev_err(pcdev->dev, "Camera interrupt register failed \n");
goto exit_reqirq;
- }
+ }
pcdev->soc_host.drv_name = RK28_CAM_DRV_NAME;
pcdev->soc_host.ops = &rk28_soc_camera_host_ops;
if (err)
goto exit_free_irq;
- RK28CAMERA_DG("\n%s..%s..%d ^^^^^^^^ ddl^^^^^^^^\n",__FUNCTION__,__FILE__,__LINE__);
+ RK28CAMERA_DG("\n%s..%s..%d \n",__FUNCTION__,__FILE__,__LINE__);
return 0;
-exit_free_irq:
+exit_free_irq:
free_irq(pcdev->irq, pcdev);
exit_reqirq:
iounmap(pcdev->base);
exit_ioremap:
release_mem_region(res->start, res->end - res->start + 1);
-exit_reqmem:
+exit_reqmem:
clk_put(pcdev->clk);
exit_eclkget:
kfree(pcdev);
-exit_alloc:
+exit_alloc:
rk28_camdev_info_ptr = NULL;
-exit:
+exit:
return err;
}
free_irq(pcdev->irq, pcdev);
soc_camera_host_unregister(&pcdev->soc_host);
-
+
res = pcdev->res;
release_mem_region(res->start, res->end - res->start + 1);
static int __devinit rk28_camera_init(void)
{
- RK28CAMERA_DG("\n%s..%s..%d ******** ddl *********\n",__FUNCTION__,__FILE__,__LINE__);
+ RK28CAMERA_DG("\n%s..%s..%d \n",__FUNCTION__,__FILE__,__LINE__);
return platform_driver_register(&rk28_camera_driver);
}