mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 22:52:35 +02:00
camera rk30:commit v0.2.6,support two cif controls.
This commit is contained in:
parent
25acf71835
commit
dcfe492512
|
|
@ -54,6 +54,152 @@
|
|||
|
||||
#define RK30_FB0_MEM_SIZE 8*SZ_1M
|
||||
|
||||
#ifdef CONFIG_VIDEO_RK29
|
||||
/*---------------- Camera Sensor Macro Define Begin ------------------------*/
|
||||
/*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
|
||||
#define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV2659//RK_CAM_SENSOR_OV5642 /* back camera sensor */
|
||||
#define CONFIG_SENSOR_IIC_ADDR_0 0x60//0x78
|
||||
#define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1
|
||||
#define CONFIG_SENSOR_CIF_INDEX_0 0
|
||||
#define CONFIG_SENSOR_ORIENTATION_0 90
|
||||
#define CONFIG_SENSOR_POWER_PIN_0 INVALID_GPIO
|
||||
#define CONFIG_SENSOR_RESET_PIN_0 INVALID_GPIO
|
||||
#define CONFIG_SENSOR_POWERDN_PIN_0 INVALID_GPIO
|
||||
#define CONFIG_SENSOR_FALSH_PIN_0 INVALID_GPIO
|
||||
#define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
|
||||
#define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
|
||||
#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
|
||||
#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
|
||||
|
||||
#define CONFIG_SENSOR_QCIF_FPS_FIXED_0 15000
|
||||
#define CONFIG_SENSOR_QVGA_FPS_FIXED_0 15000
|
||||
#define CONFIG_SENSOR_CIF_FPS_FIXED_0 15000
|
||||
#define CONFIG_SENSOR_VGA_FPS_FIXED_0 15000
|
||||
#define CONFIG_SENSOR_480P_FPS_FIXED_0 15000
|
||||
#define CONFIG_SENSOR_SVGA_FPS_FIXED_0 15000
|
||||
#define CONFIG_SENSOR_720P_FPS_FIXED_0 30000
|
||||
|
||||
#define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659 /* front camera sensor */
|
||||
#define CONFIG_SENSOR_IIC_ADDR_1 0x60
|
||||
#define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1
|
||||
#define CONFIG_SENSOR_CIF_INDEX_1 1
|
||||
#define CONFIG_SENSOR_ORIENTATION_1 270
|
||||
#define CONFIG_SENSOR_POWER_PIN_1 INVALID_GPIO
|
||||
#define CONFIG_SENSOR_RESET_PIN_1 INVALID_GPIO
|
||||
#define CONFIG_SENSOR_POWERDN_PIN_1 INVALID_GPIO
|
||||
#define CONFIG_SENSOR_FALSH_PIN_1 INVALID_GPIO
|
||||
#define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
|
||||
#define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
|
||||
#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
|
||||
#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
|
||||
|
||||
#define CONFIG_SENSOR_QCIF_FPS_FIXED_1 15000
|
||||
#define CONFIG_SENSOR_QVGA_FPS_FIXED_1 15000
|
||||
#define CONFIG_SENSOR_CIF_FPS_FIXED_1 15000
|
||||
#define CONFIG_SENSOR_VGA_FPS_FIXED_1 15000
|
||||
#define CONFIG_SENSOR_480P_FPS_FIXED_1 15000
|
||||
#define CONFIG_SENSOR_SVGA_FPS_FIXED_1 15000
|
||||
#define CONFIG_SENSOR_720P_FPS_FIXED_1 30000
|
||||
|
||||
#define CONFIG_USE_CIF_0 1
|
||||
#define CONFIG_USE_CIF_1 0
|
||||
#endif //#ifdef CONFIG_VIDEO_RK29
|
||||
/*---------------- Camera Sensor Configuration Macro End------------------------*/
|
||||
#include "../../../drivers/media/video/rk30_camera.c"
|
||||
/*---------------- Camera Sensor Macro Define End ---------*/
|
||||
|
||||
#define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
|
||||
#ifdef CONFIG_VIDEO_RK29_WORK_IPP
|
||||
#define MEM_CAMIPP_SIZE PMEM_CAMIPP_NECESSARY
|
||||
#else
|
||||
#define MEM_CAMIPP_SIZE 0
|
||||
#endif
|
||||
/*****************************************************************************************
|
||||
* camera devices
|
||||
* author: ddl@rock-chips.com
|
||||
*****************************************************************************************/
|
||||
#ifdef CONFIG_VIDEO_RK29
|
||||
#define CONFIG_SENSOR_POWER_IOCTL_USR 0
|
||||
#define CONFIG_SENSOR_RESET_IOCTL_USR 0
|
||||
#define CONFIG_SENSOR_POWERDOWN_IOCTL_USR 0
|
||||
#define CONFIG_SENSOR_FLASH_IOCTL_USR 0
|
||||
|
||||
#if CONFIG_SENSOR_POWER_IOCTL_USR
|
||||
static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
|
||||
{
|
||||
#error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_SENSOR_RESET_IOCTL_USR
|
||||
static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
|
||||
{
|
||||
#error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
|
||||
static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
|
||||
{
|
||||
#error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_SENSOR_FLASH_IOCTL_USR
|
||||
static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
|
||||
{
|
||||
#error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
|
||||
#if CONFIG_SENSOR_POWER_IOCTL_USR
|
||||
.sensor_power_cb = sensor_power_usr_cb,
|
||||
#else
|
||||
.sensor_power_cb = NULL,
|
||||
#endif
|
||||
|
||||
#if CONFIG_SENSOR_RESET_IOCTL_USR
|
||||
.sensor_reset_cb = sensor_reset_usr_cb,
|
||||
#else
|
||||
.sensor_reset_cb = NULL,
|
||||
#endif
|
||||
|
||||
#if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
|
||||
.sensor_powerdown_cb = sensor_powerdown_usr_cb,
|
||||
#else
|
||||
.sensor_powerdown_cb = NULL,
|
||||
#endif
|
||||
|
||||
#if CONFIG_SENSOR_FLASH_IOCTL_USR
|
||||
.sensor_flash_cb = sensor_flash_usr_cb,
|
||||
#else
|
||||
.sensor_flash_cb = NULL,
|
||||
#endif
|
||||
};
|
||||
static struct reginfo_t rk_init_data_sensor_reg_0[] =
|
||||
{
|
||||
{0x0000, 0x00,0,0}
|
||||
};
|
||||
static struct reginfo_t rk_init_data_sensor_winseqreg_0[] ={
|
||||
{0x0000, 0x00,0,0}
|
||||
};
|
||||
static rk_sensor_user_init_data_s rk_init_data_sensor_0 =
|
||||
{
|
||||
.rk_sensor_init_width = INVALID_VALUE,
|
||||
.rk_sensor_init_height = INVALID_VALUE,
|
||||
.rk_sensor_init_bus_param = INVALID_VALUE,
|
||||
.rk_sensor_init_pixelcode = INVALID_VALUE,
|
||||
.rk_sensor_init_data = rk_init_data_sensor_reg_0,
|
||||
.rk_sensor_init_winseq = NULL,//rk_init_data_sensor_winseqreg_0,
|
||||
.rk_sensor_winseq_size = sizeof(rk_init_data_sensor_winseqreg_0) / sizeof(struct reginfo_t),
|
||||
|
||||
};
|
||||
static rk_sensor_user_init_data_s* rk_init_data_sensor_0_p = &rk_init_data_sensor_0;
|
||||
static rk_sensor_user_init_data_s* rk_init_data_sensor_1_p = NULL;
|
||||
#include "../../../drivers/media/video/rk30_camera.c"
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_TOUCHSCREEN_GT8XX)
|
||||
#define TOUCH_RESET_PIN RK30_PIN4_PD0
|
||||
|
|
@ -722,6 +868,25 @@ static void __init rk30_reserve(void)
|
|||
resource_fb[2].start = board_mem_reserve_add("fb2",RK30_FB0_MEM_SIZE);
|
||||
resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
|
||||
#endif
|
||||
|
||||
#if (MEM_CAMIPP_SIZE != 0)
|
||||
#if CONFIG_USE_CIF_0
|
||||
rk_camera_platform_data.meminfo.name = "camera_ipp_mem_0";
|
||||
rk_camera_platform_data.meminfo.start = board_mem_reserve_add("camera_ipp_mem_0",MEM_CAMIPP_SIZE);
|
||||
rk_camera_platform_data.meminfo.size= MEM_CAMIPP_SIZE;
|
||||
#endif
|
||||
#if CONFIG_USE_CIF_1
|
||||
rk_camera_platform_data.meminfo_cif1.name = "camera_ipp_mem_1";
|
||||
rk_camera_platform_data.meminfo_cif1.start =board_mem_reserve_add("camera_ipp_mem_1",MEM_CAMIPP_SIZE);
|
||||
rk_camera_platform_data.meminfo_cif1.size= MEM_CAMIPP_SIZE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (PMEM_CAM_SIZE != 0)
|
||||
android_pmem_cam_pdata.start = board_mem_reserve_add("camera_pmem",PMEM_CAM_SIZE);
|
||||
android_pmem_cam_pdata.size = PMEM_CAM_SIZE;
|
||||
#endif
|
||||
|
||||
board_mem_reserved();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -973,7 +973,6 @@ static void __init rk30_init_sdmmc(void)
|
|||
platform_device_register(&device_sdmmc1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int __init rk30_init_devices(void)
|
||||
{
|
||||
rk30_init_dma();
|
||||
|
|
@ -1003,7 +1002,6 @@ static int __init rk30_init_devices(void)
|
|||
rk_serial_debug_init(DEBUG_UART_PHYS, IRQ_UART0 + CONFIG_RK_DEBUG_UART, IRQ_UART_SIGNAL, -1);
|
||||
#endif
|
||||
rk30_init_i2s();
|
||||
|
||||
return 0;
|
||||
}
|
||||
arch_initcall(rk30_init_devices);
|
||||
|
|
|
|||
224
arch/arm/plat-rk/include/plat/rk_camera.h
Executable file
224
arch/arm/plat-rk/include/plat/rk_camera.h
Executable file
|
|
@ -0,0 +1,224 @@
|
|||
/*
|
||||
camera.h - PXA camera driver header file
|
||||
|
||||
Copyright (C) 2003, Intel Corporation
|
||||
Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_ARCH_CAMERA_RK_H_
|
||||
#define __ASM_ARCH_CAMERA_RK_H_
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
#include <media/soc_camera.h>
|
||||
#define RK29_CAM_DRV_NAME "rk30xx-camera"
|
||||
#define RK29_CAM_PLATFORM_DEV_ID 33
|
||||
#define RK_CAM_PLATFORM_DEV_ID_0 RK29_CAM_PLATFORM_DEV_ID
|
||||
#define RK_CAM_PLATFORM_DEV_ID_1 (RK_CAM_PLATFORM_DEV_ID_0+1)
|
||||
#define INVALID_GPIO -1
|
||||
#define INVALID_VALUE -1
|
||||
#define RK29_CAM_IO_SUCCESS 0
|
||||
#define RK29_CAM_EIO_INVALID -1
|
||||
#define RK29_CAM_EIO_REQUESTFAIL -2
|
||||
|
||||
#define RK_CAM_NUM 2
|
||||
/*---------------- Camera Sensor Must Define Macro Begin ------------------------*/
|
||||
#define RK29_CAM_SENSOR_OV7675 ov7675
|
||||
#define RK29_CAM_SENSOR_OV9650 ov9650
|
||||
#define RK29_CAM_SENSOR_OV2640 ov2640
|
||||
#define RK29_CAM_SENSOR_OV2655 ov2655
|
||||
#define RK29_CAM_SENSOR_OV2659 ov2659
|
||||
#define RK29_CAM_SENSOR_OV7690 ov7690
|
||||
#define RK29_CAM_SENSOR_OV3640 ov3640
|
||||
#define RK29_CAM_SENSOR_OV5640 ov5640
|
||||
#define RK29_CAM_SENSOR_OV5642 ov5642
|
||||
#define RK29_CAM_SENSOR_S5K6AA s5k6aa
|
||||
#define RK29_CAM_SENSOR_MT9D112 mt9d112
|
||||
#define RK29_CAM_SENSOR_MT9D113 mt9d113
|
||||
#define RK29_CAM_SENSOR_MT9P111 mt9p111
|
||||
#define RK29_CAM_SENSOR_MT9T111 mt9t111
|
||||
#define RK29_CAM_SENSOR_GT2005 gt2005
|
||||
#define RK29_CAM_SENSOR_GC0307 gc0307
|
||||
#define RK29_CAM_SENSOR_GC0308 gc0308
|
||||
#define RK29_CAM_SENSOR_GC0309 gc0309
|
||||
#define RK29_CAM_SENSOR_GC2015 gc2015
|
||||
#define RK29_CAM_SENSOR_SIV120B siv120b
|
||||
#define RK29_CAM_SENSOR_SID130B sid130B
|
||||
#define RK29_CAM_SENSOR_HI253 hi253
|
||||
#define RK29_CAM_SENSOR_HI704 hi704
|
||||
#define RK29_CAM_SENSOR_NT99250 nt99250
|
||||
|
||||
#define RK29_CAM_SENSOR_NAME_OV7675 "ov7675"
|
||||
#define RK29_CAM_SENSOR_NAME_OV9650 "ov9650"
|
||||
#define RK29_CAM_SENSOR_NAME_OV2640 "ov2640"
|
||||
#define RK29_CAM_SENSOR_NAME_OV2655 "ov2655"
|
||||
#define RK29_CAM_SENSOR_NAME_OV2659 "ov2659"
|
||||
#define RK29_CAM_SENSOR_NAME_OV7690 "ov7690"
|
||||
#define RK29_CAM_SENSOR_NAME_OV3640 "ov3640"
|
||||
#define RK29_CAM_SENSOR_NAME_OV5640 "ov5640"
|
||||
#define RK29_CAM_SENSOR_NAME_OV5642 "ov5642"
|
||||
#define RK29_CAM_SENSOR_NAME_S5K6AA "s5k6aa"
|
||||
#define RK29_CAM_SENSOR_NAME_MT9D112 "mt9d112"
|
||||
#define RK29_CAM_SENSOR_NAME_MT9D113 "mt9d113"
|
||||
#define RK29_CAM_SENSOR_NAME_MT9P111 "mt9p111"
|
||||
#define RK29_CAM_SENSOR_NAME_MT9T111 "mt9t111"
|
||||
#define RK29_CAM_SENSOR_NAME_GT2005 "gt2005"
|
||||
#define RK29_CAM_SENSOR_NAME_GC0307 "gc0307"
|
||||
#define RK29_CAM_SENSOR_NAME_GC0308 "gc0308"
|
||||
#define RK29_CAM_SENSOR_NAME_GC0309 "gc0309"
|
||||
#define RK29_CAM_SENSOR_NAME_GC2015 "gc2015"
|
||||
#define RK29_CAM_SENSOR_NAME_SIV120B "siv120b"
|
||||
#define RK29_CAM_SENSOR_NAME_SID130B "sid130B"
|
||||
#define RK29_CAM_SENSOR_NAME_HI253 "hi253"
|
||||
#define RK29_CAM_SENSOR_NAME_HI704 "hi704"
|
||||
#define RK29_CAM_SENSOR_NAME_NT99250 "nt99250"
|
||||
|
||||
#define ov7675_FULL_RESOLUTION 0x30000 // 0.3 megapixel
|
||||
#define ov9650_FULL_RESOLUTION 0x130000 // 1.3 megapixel
|
||||
#define ov2640_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
#define ov2655_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
#define ov2659_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
#define ov7690_FULL_RESOLUTION 0x300000 // 2 megapixel
|
||||
#define ov3640_FULL_RESOLUTION 0x300000 // 3 megapixel
|
||||
#define ov5640_FULL_RESOLUTION 0x500000 // 5 megapixel
|
||||
#define ov5642_FULL_RESOLUTION 0x500000 // 5 megapixel
|
||||
#define s5k6aa_FULL_RESOLUTION 0x130000 // 1.3 megapixel
|
||||
#define mt9d112_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
#define mt9d113_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
#define mt9t111_FULL_RESOLUTION 0x300000 // 3 megapixel
|
||||
#define mt9p111_FULL_RESOLUTION 0x500000 // 5 megapixel
|
||||
#define gt2005_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
#define gc0308_FULL_RESOLUTION 0x30000 // 0.3 megapixel
|
||||
#define gc0309_FULL_RESOLUTION 0x30000 // 0.3 megapixel
|
||||
#define gc2015_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
#define siv120b_FULL_RESOLUTION 0x30000 // 0.3 megapixel
|
||||
#define sid130B_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
#define hi253_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
#define hi704_FULL_RESOLUTION 0x30000 // 0.3 megapixel
|
||||
#define nt99250_FULL_RESOLUTION 0x200000 // 2 megapixel
|
||||
/*---------------- Camera Sensor Must Define Macro End ------------------------*/
|
||||
|
||||
|
||||
#define RK29_CAM_POWERACTIVE_BITPOS 0x00
|
||||
#define RK29_CAM_POWERACTIVE_MASK (1<<RK29_CAM_POWERACTIVE_BITPOS)
|
||||
#define RK29_CAM_POWERACTIVE_H (0x01<<RK29_CAM_POWERACTIVE_BITPOS)
|
||||
#define RK29_CAM_POWERACTIVE_L (0x00<<RK29_CAM_POWERACTIVE_BITPOS)
|
||||
|
||||
#define RK29_CAM_RESETACTIVE_BITPOS 0x01
|
||||
#define RK29_CAM_RESETACTIVE_MASK (1<<RK29_CAM_RESETACTIVE_BITPOS)
|
||||
#define RK29_CAM_RESETACTIVE_H (0x01<<RK29_CAM_RESETACTIVE_BITPOS)
|
||||
#define RK29_CAM_RESETACTIVE_L (0x00<<RK29_CAM_RESETACTIVE_BITPOS)
|
||||
|
||||
#define RK29_CAM_POWERDNACTIVE_BITPOS 0x02
|
||||
#define RK29_CAM_POWERDNACTIVE_MASK (1<<RK29_CAM_POWERDNACTIVE_BITPOS)
|
||||
#define RK29_CAM_POWERDNACTIVE_H (0x01<<RK29_CAM_POWERDNACTIVE_BITPOS)
|
||||
#define RK29_CAM_POWERDNACTIVE_L (0x00<<RK29_CAM_POWERDNACTIVE_BITPOS)
|
||||
|
||||
#define RK29_CAM_FLASHACTIVE_BITPOS 0x03
|
||||
#define RK29_CAM_FLASHACTIVE_MASK (1<<RK29_CAM_FLASHACTIVE_BITPOS)
|
||||
#define RK29_CAM_FLASHACTIVE_H (0x01<<RK29_CAM_FLASHACTIVE_BITPOS)
|
||||
#define RK29_CAM_FLASHACTIVE_L (0x00<<RK29_CAM_FLASHACTIVE_BITPOS)
|
||||
|
||||
/* v4l2_subdev_core_ops.ioctl ioctl_cmd macro */
|
||||
#define RK29_CAM_SUBDEV_ACTIVATE 0x00
|
||||
#define RK29_CAM_SUBDEV_DEACTIVATE 0x01
|
||||
#define RK29_CAM_SUBDEV_IOREQUEST 0x02
|
||||
#define RK29_CAM_SUBDEV_CB_REGISTER 0x03
|
||||
|
||||
enum rk29camera_ioctrl_cmd
|
||||
{
|
||||
Cam_Power,
|
||||
Cam_Reset,
|
||||
Cam_PowerDown,
|
||||
Cam_Flash
|
||||
};
|
||||
|
||||
enum rk29sensor_power_cmd
|
||||
{
|
||||
Sensor_Reset,
|
||||
Sensor_PowerDown,
|
||||
Sensor_Flash
|
||||
};
|
||||
|
||||
enum rk29camera_flash_cmd
|
||||
{
|
||||
Flash_Off,
|
||||
Flash_On,
|
||||
Flash_Torch
|
||||
};
|
||||
|
||||
struct rk29camera_gpio_res {
|
||||
unsigned int gpio_reset;
|
||||
unsigned int gpio_power;
|
||||
unsigned int gpio_powerdown;
|
||||
unsigned int gpio_flash;
|
||||
unsigned int gpio_flag;
|
||||
unsigned int gpio_init;
|
||||
const char *dev_name;
|
||||
};
|
||||
|
||||
struct rk29camera_mem_res {
|
||||
const char *name;
|
||||
unsigned int start;
|
||||
unsigned int size;
|
||||
};
|
||||
struct rk29camera_info {
|
||||
const char *dev_name;
|
||||
unsigned int orientation;
|
||||
struct v4l2_frmivalenum fival[10];
|
||||
};
|
||||
|
||||
struct reginfo_t
|
||||
{
|
||||
u16 reg;
|
||||
u16 val;
|
||||
u16 reg_len;
|
||||
u16 rev;
|
||||
};
|
||||
typedef struct rk_sensor_user_init_data{
|
||||
int rk_sensor_init_width;
|
||||
int rk_sensor_init_height;
|
||||
unsigned long rk_sensor_init_bus_param;
|
||||
enum v4l2_mbus_pixelcode rk_sensor_init_pixelcode;
|
||||
struct reginfo_t * rk_sensor_init_data;
|
||||
int rk_sensor_winseq_size;
|
||||
struct reginfo_t * rk_sensor_init_winseq;
|
||||
}rk_sensor_user_init_data_s;
|
||||
struct rk29camera_platform_data {
|
||||
int (*io_init)(void);
|
||||
int (*io_deinit)(int sensor);
|
||||
int (*sensor_ioctrl)(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
|
||||
rk_sensor_user_init_data_s* sensor_init_data[RK_CAM_NUM];
|
||||
struct rk29camera_gpio_res gpio_res[RK_CAM_NUM];
|
||||
struct rk29camera_mem_res meminfo;
|
||||
struct rk29camera_mem_res meminfo_cif1;
|
||||
struct rk29camera_info info[RK_CAM_NUM];
|
||||
};
|
||||
|
||||
struct rk29camera_platform_ioctl_cb {
|
||||
int (*sensor_power_cb)(struct rk29camera_gpio_res *res, int on);
|
||||
int (*sensor_reset_cb)(struct rk29camera_gpio_res *res, int on);
|
||||
int (*sensor_powerdown_cb)(struct rk29camera_gpio_res *res, int on);
|
||||
int (*sensor_flash_cb)(struct rk29camera_gpio_res *res, int on);
|
||||
};
|
||||
|
||||
typedef struct rk29_camera_sensor_cb {
|
||||
int (*sensor_cb)(void *arg);
|
||||
}rk29_camera_sensor_cb_s;
|
||||
|
||||
|
||||
#endif /* __ASM_ARCH_CAMERA_H_ */
|
||||
|
||||
|
|
@ -1137,47 +1137,47 @@ config VIDEO_OMAP2
|
|||
This is a v4l2 driver for the TI OMAP2 camera capture interface
|
||||
|
||||
config VIDEO_RK29
|
||||
tristate "RK29XX Camera Sensor Interface driver"
|
||||
depends on VIDEO_DEV && ARCH_RK29 && SOC_CAMERA && HAS_DMA
|
||||
tristate "RKXX Camera Sensor Interface driver"
|
||||
depends on VIDEO_DEV && PLAT_RK && SOC_CAMERA && HAS_DMA
|
||||
select VIDEOBUF_DMA_CONTIG
|
||||
---help---
|
||||
This is a v4l2 driver for the RK29XX Camera Sensor Interface
|
||||
|
||||
choice
|
||||
prompt "RK29XX Camera Sensor Interface Work Mode"
|
||||
prompt "RKXX Camera Sensor Interface Work Mode"
|
||||
depends on VIDEO_RK29
|
||||
default VIDEO_RK29_WORK_ONEFRAME
|
||||
---help---
|
||||
RK29 Camera Sensor Interface(VIP) can work in 2 modes, ie:OneFrame,PingPong.
|
||||
|
||||
config VIDEO_RK29_WORK_ONEFRAME
|
||||
bool "VIP OneFrame Mode"
|
||||
bool "CIF OneFrame Mode"
|
||||
|
||||
config VIDEO_RK29_WORK_PINGPONG
|
||||
bool "VIP PingPong Mode"
|
||||
bool "CIF PingPong Mode"
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "RK29XX camera sensor interface work with IPP "
|
||||
prompt "RKXX camera sensor interface work with IPP "
|
||||
depends on VIDEO_RK29 && RK29_IPP
|
||||
default VIDEO_RK29_WORK_IPP
|
||||
---help---
|
||||
RK29 Camera Sensor Interface(VIP) can work with IPP or not IPP
|
||||
|
||||
config VIDEO_RK29_WORK_IPP
|
||||
bool "VIP work with IPP"
|
||||
bool "CIF work with IPP"
|
||||
|
||||
config VIDEO_RK29_WORK_NOT_IPP
|
||||
bool "VIP don't work with IPP"
|
||||
bool "CIF don't work with IPP"
|
||||
|
||||
endchoice
|
||||
choice
|
||||
prompt "RK29XX camera digital zoom with IPP "
|
||||
prompt "RKXX camera digital zoom with IPP "
|
||||
depends on VIDEO_RK29 && RK29_IPP && VIDEO_RK29_WORK_IPP
|
||||
default VIDEO_RK29_DIGITALZOOM_IPP_ON
|
||||
---help---
|
||||
RK29 Camera digital zoom with IPP
|
||||
RK Camera digital zoom with IPP
|
||||
config VIDEO_RK29_DIGITALZOOM_IPP_ON
|
||||
bool "Digital zoom with IPP on"
|
||||
|
||||
|
|
|
|||
|
|
@ -189,8 +189,11 @@ obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o
|
|||
obj-$(CONFIG_VIDEO_MX2) += mx2_camera.o
|
||||
obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o
|
||||
obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
|
||||
obj-$(CONFIG_VIDEO_RK29_WORK_ONEFRAME) += rk29_camera_oneframe.o
|
||||
obj-$(CONFIG_VIDEO_RK29_WORK_PINGPONG) += rk29_camera_pingpong.o
|
||||
obj-$(CONFIG_VIDEO_RK29_WORK_ONEFRAME) += rk30_camera_oneframe.o
|
||||
obj-$(CONFIG_VIDEO_RK29_WORK_PINGPONG) += rk30_camera_pingpong.o
|
||||
obj-$(CONFIG_VIDEO_RK29_WORK_ONEFRAME) += rk29_camera_oneframe.o
|
||||
obj-$(CONFIG_VIDEO_RK29_WORK_PINGPONG) += rk29_camera_pingpong.o
|
||||
|
||||
obj-$(CONFIG_VIDEO_RK29XX_VOUT) += rk29xx/
|
||||
obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o
|
||||
obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -51,10 +51,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 480//144
|
||||
#define SENSOR_MAX_WIDTH 800//1600
|
||||
#define SENSOR_MAX_HEIGHT 600//1200
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -74,10 +75,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -1613,6 +1610,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
|
|
@ -1621,9 +1625,63 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret;
|
||||
|
||||
|
||||
char value;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1644,7 +1702,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
|
||||
mdelay(5); */ //delay 5 microseconds
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2822,20 +2880,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -51,10 +51,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 480//144
|
||||
#define SENSOR_MAX_WIDTH 640
|
||||
#define SENSOR_MAX_HEIGHT 480
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -74,10 +75,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -1488,6 +1485,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
|
|
@ -1496,8 +1500,63 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret;
|
||||
|
||||
char value;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1518,7 +1577,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
|
||||
mdelay(5); */ //delay 5 microseconds
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2664,20 +2723,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 640
|
||||
#define SENSOR_MAX_HEIGHT 480
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,10 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|\
|
||||
SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH |\
|
||||
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
|
||||
|
|
@ -100,7 +97,7 @@ struct reginfo
|
|||
u8 val;
|
||||
};
|
||||
|
||||
/* init SVGA preview */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
/*init registers code.*/
|
||||
|
|
@ -1445,6 +1442,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1453,7 +1457,63 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
ret = -ENODEV;
|
||||
|
|
@ -1488,7 +1548,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2617,20 +2677,23 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
112
drivers/media/video/gc0309_for_td8801.c
Normal file → Executable file
112
drivers/media/video/gc0309_for_td8801.c
Normal file → Executable file
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 640
|
||||
#define SENSOR_MAX_HEIGHT 480
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,9 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|\
|
||||
SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH |\
|
||||
SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ)
|
||||
|
||||
#define COLOR_TEMPERATURE_CLOUDY_DN 6500
|
||||
#define COLOR_TEMPERATURE_CLOUDY_UP 8000
|
||||
|
|
@ -1445,6 +1443,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1453,7 +1458,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
ret = -ENODEV;
|
||||
|
|
@ -1488,7 +1548,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2618,20 +2678,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 480
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 800//1024 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 600//768
|
||||
#define SENSOR_INIT_WINSEQADR sensor_svga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,10 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -100,7 +97,7 @@ struct reginfo
|
|||
u8 val;
|
||||
};
|
||||
|
||||
/* init SVGA preview */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
|
||||
{
|
||||
|
|
@ -1597,6 +1594,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 800;
|
||||
static s32 sensor_init_height = 600;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1605,8 +1609,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 800;
|
||||
sensor_init_height = 600;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1653,7 +1711,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2830,20 +2888,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 480
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,10 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\
|
||||
SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH |\
|
||||
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
|
||||
|
|
@ -100,7 +97,7 @@ struct reginfo
|
|||
u8 val;
|
||||
};
|
||||
|
||||
/* init 352X288 SVGA */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
{0x0101 , 0x00},
|
||||
|
|
@ -2243,6 +2240,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
|
|
@ -2252,8 +2256,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -2300,7 +2358,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -3469,20 +3527,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 1600 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 1200
|
||||
#define SENSOR_INIT_WINSEQADR sensor_uxga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,10 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -101,7 +98,7 @@ struct reginfo
|
|||
u8 val;
|
||||
};
|
||||
|
||||
/* init SVGA preview */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
// {0x01, 0xf9},
|
||||
|
|
@ -2155,6 +2152,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 1600;
|
||||
static s32 sensor_init_height = 1200;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -2163,8 +2168,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_uxga;
|
||||
sensor_init_width = 1600;
|
||||
sensor_init_height = 1200;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -2203,7 +2262,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
#endif
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -3370,20 +3429,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 640
|
||||
#define SENSOR_MAX_HEIGHT 480
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,10 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -101,7 +98,7 @@ struct reginfo
|
|||
u8 val;
|
||||
};
|
||||
|
||||
/* init SVGA preview */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
//PAGE 0
|
||||
|
|
@ -1633,6 +1630,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1641,8 +1645,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1681,7 +1739,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
#endif
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2824,20 +2882,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include "mt9d112.h"
|
||||
|
||||
static int debug;
|
||||
|
|
@ -53,10 +54,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 240
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -77,11 +79,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
|
||||
#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\
|
||||
SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH |\
|
||||
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
|
||||
|
|
@ -1768,6 +1765,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 800;
|
||||
static s32 sensor_init_height = 600;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1775,10 +1779,66 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret;
|
||||
int ret,i = 0,j=0;
|
||||
#if (SENSOR_ID_REG != SEQUENCE_END)
|
||||
u16 pid = 0;
|
||||
#endif
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 800;
|
||||
sensor_init_height = 600;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
|
||||
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
|
|
@ -1823,7 +1883,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -3119,20 +3179,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
}
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include "mt9d113.h"
|
||||
|
||||
static int debug;
|
||||
|
|
@ -56,10 +57,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 600
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 800 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 600
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_data
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 0
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -79,10 +81,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 1
|
||||
|
||||
#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_FALLING |\
|
||||
SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH |\
|
||||
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
|
||||
|
|
@ -1562,6 +1560,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 800;
|
||||
static s32 sensor_init_height = 600;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1569,9 +1574,63 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret;
|
||||
u16 pid = 0;
|
||||
|
||||
char value;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 800;
|
||||
sensor_init_height = 600;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1625,7 +1684,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2933,20 +2992,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
}
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
116
drivers/media/video/mt9p111.c
Normal file → Executable file
116
drivers/media/video/mt9p111.c
Normal file → Executable file
|
|
@ -22,7 +22,8 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include "mt9p111.h"
|
||||
|
||||
static int debug;
|
||||
|
|
@ -57,10 +58,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 2592
|
||||
#define SENSOR_MAX_HEIGHT 1944
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
#define YUV420_BUFFER_MAX_SIZE 7558272 /* 2592*1944*1.5*/
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
|
|
@ -84,11 +86,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
|
||||
#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|\
|
||||
SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH|\
|
||||
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
|
||||
|
|
@ -117,7 +114,7 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_AF_MODE_CLOSE 5
|
||||
#endif
|
||||
|
||||
/* init 640X480 VGA */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
//[Step2-PLL_Timing]
|
||||
|
|
@ -2859,6 +2856,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -2868,11 +2873,66 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
#endif
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret,pid = 0;
|
||||
int ret,pid = 0,i = 0 ,j = 0;
|
||||
int index =0 ;
|
||||
#if (SENSOR_RESET_REG != SEQUENCE_END)
|
||||
struct reginfo reg_info;
|
||||
#endif
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
|
|
@ -2923,7 +2983,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
|
||||
SENSOR_DG("\n sensor_init_data..%s.\n",SENSOR_NAME_STRING());
|
||||
|
||||
ret =sensor_write_init_data(client, sensor_init_data);
|
||||
ret =sensor_write_init_data(client, sensor_init_data_p);
|
||||
if (ret != 0) {
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
goto sensor_INIT_ERR;
|
||||
|
|
@ -4638,20 +4698,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
}
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include "mt9t111.h"
|
||||
|
||||
static int debug;
|
||||
|
|
@ -55,10 +56,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 2048
|
||||
#define SENSOR_MAX_HEIGHT 1536
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -82,11 +84,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
|
||||
#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|\
|
||||
SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH|\
|
||||
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
|
||||
|
|
@ -113,7 +110,7 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_AF_MODE_CLOSE 5
|
||||
#endif
|
||||
|
||||
/* init 640X480 VGA */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
//[Step2-PLL_Timing]
|
||||
|
|
@ -6692,6 +6689,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -6699,10 +6704,65 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret,pid = 0;
|
||||
int ret,pid = 0,i = 0 , j = 0;
|
||||
#if (SENSOR_RESET_REG != SEQUENCE_END)
|
||||
struct reginfo reg_info;
|
||||
#endif
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
ret = -ENODEV;
|
||||
|
|
@ -6747,7 +6807,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -8266,20 +8326,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
}
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 800 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 600
|
||||
#define SENSOR_INIT_WINSEQADR sensor_svga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 0
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,10 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -100,7 +97,7 @@ struct reginfo
|
|||
u8 val;
|
||||
};
|
||||
|
||||
/* init 352X288 SVGA */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
{0x3024,0x02}, //TG //0x02
|
||||
|
|
@ -1444,6 +1441,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 800;
|
||||
static s32 sensor_init_height = 600;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1452,8 +1457,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 800;
|
||||
sensor_init_height = 600;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1503,7 +1562,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
}
|
||||
#endif
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2712,20 +2771,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
1327
drivers/media/video/ov2640.c
Normal file → Executable file
1327
drivers/media/video/ov2640.c
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
|
|
@ -1,4 +1,4 @@
|
|||
#include <linux/videodev2.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/log2.h>
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -25,6 +25,7 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#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)
|
||||
|
|
@ -41,10 +42,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 480
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 0
|
||||
#define CONFIG_SENSOR_Brightness 1
|
||||
|
|
@ -64,9 +66,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -1553,15 +1552,78 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = sensor_init_data;
|
||||
static struct reginfo* sensor_init_winseq_p = sensor_svga;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct soc_camera_device *icd = client->dev.platform_data;
|
||||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
//if val ==1,mean that sensor need to be reinit
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
|
|
@ -1611,7 +1673,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -1766,7 +1828,7 @@ static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
|
|||
|
||||
static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct soc_camera_device *icd = client->dev.platform_data;
|
||||
struct sensor *sensor = to_sensor(client);
|
||||
|
||||
|
|
@ -1815,7 +1877,7 @@ static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefm
|
|||
}
|
||||
static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct sensor *sensor = to_sensor(client);
|
||||
const struct sensor_datafmt *fmt;
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
|
|
@ -1995,7 +2057,7 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
|
|||
|
||||
static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct sensor *sensor = to_sensor(client);
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret = 0;
|
||||
|
|
@ -2023,7 +2085,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
|
|||
}
|
||||
static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
||||
if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
|
||||
return -EINVAL;
|
||||
|
|
@ -2307,7 +2369,7 @@ static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_que
|
|||
|
||||
static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
|
||||
|
|
@ -2366,7 +2428,7 @@ 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)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct sensor *sensor = to_sensor(client);
|
||||
struct soc_camera_device *icd = client->dev.platform_data;
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
|
|
@ -2656,7 +2718,7 @@ static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_c
|
|||
|
||||
static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct soc_camera_device *icd = client->dev.platform_data;
|
||||
int i, error_cnt=0, error_idx=-1;
|
||||
|
||||
|
|
@ -2681,7 +2743,7 @@ static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_control
|
|||
|
||||
static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct soc_camera_device *icd = client->dev.platform_data;
|
||||
int i, error_cnt=0, error_idx=-1;
|
||||
|
||||
|
|
@ -2769,7 +2831,7 @@ static int sensor_video_probe(struct soc_camera_device *icd,
|
|||
|
||||
static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
struct soc_camera_device *icd = client->dev.platform_data;
|
||||
struct sensor *sensor = to_sensor(client);
|
||||
int ret = 0;
|
||||
|
|
@ -2785,20 +2847,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
@ -2953,4 +3017,4 @@ module_exit(sensor_mod_exit);
|
|||
|
||||
MODULE_DESCRIPTION(SENSOR_NAME_STRING(Camera sensor driver));
|
||||
MODULE_AUTHOR("ddl <kernel@rock-chips>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,10 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 1
|
||||
|
||||
#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
|
||||
|
|
@ -97,7 +94,7 @@ struct reginfo
|
|||
u8 val;
|
||||
};
|
||||
|
||||
/* init 352X288 SVGA */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
{0x308c, 0x80},
|
||||
|
|
@ -1684,6 +1681,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1692,8 +1697,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1744,7 +1803,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2915,20 +2974,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 600
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 800 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 600
|
||||
#define SENSOR_INIT_WINSEQADR sensor_svga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,10 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -1461,7 +1458,8 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
{
|
||||
struct soc_camera_link *icl = to_soc_camera_link(icd);
|
||||
int ret = 0;
|
||||
|
||||
//for fpga debug ,not control io
|
||||
//return 0;
|
||||
SENSOR_DG("%s %s cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
|
||||
switch (cmd)
|
||||
{
|
||||
|
|
@ -1501,6 +1499,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 800;
|
||||
static s32 sensor_init_height = 600;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = sensor_init_data;
|
||||
static struct reginfo* sensor_init_winseq_p = sensor_svga;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1509,8 +1514,63 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
//if val ==1,mean that sensor need to be reinit
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 800;
|
||||
sensor_init_height = 600;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1558,7 +1618,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2775,18 +2835,21 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
115
drivers/media/video/ov3640.c
Normal file → Executable file
115
drivers/media/video/ov3640.c
Normal file → Executable file
|
|
@ -19,7 +19,9 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include "ov3640.h"
|
||||
|
||||
static int debug;
|
||||
|
|
@ -50,10 +52,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 2048
|
||||
#define SENSOR_MAX_HEIGHT 1536
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_data
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -78,11 +81,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
|
||||
#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
|
||||
|
|
@ -2542,6 +2540,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = sd->priv;
|
||||
|
|
@ -2550,8 +2555,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -2600,7 +2659,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -3985,20 +4044,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
}
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include "ov5640.h"
|
||||
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 2592
|
||||
#define SENSOR_MAX_HEIGHT 1944
|
||||
#define SENSOR_INIT_WIDTH 800 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 600
|
||||
#define SENSOR_INIT_WINSEQADR sensor_svga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -81,9 +82,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_WRITE_REGS 1
|
||||
#define WRITE_REGS_NUM 100
|
||||
|
||||
#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
|
||||
|
|
@ -2363,6 +2361,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 800;
|
||||
static s32 sensor_init_height = 600;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = sensor_init_data;
|
||||
static struct reginfo* sensor_init_winseq_p = sensor_svga;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -2371,7 +2376,63 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
//if val ==1,mean that sensor need to be reinit
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 800;
|
||||
sensor_init_height = 600;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
|
|
@ -2419,7 +2480,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0) {
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
goto sensor_INIT_ERR;
|
||||
|
|
@ -3786,20 +3847,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
}
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
113
drivers/media/video/ov5640_for_td8801.c
Normal file → Executable file
113
drivers/media/video/ov5640_for_td8801.c
Normal file → Executable file
|
|
@ -19,9 +19,9 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include "ov5640.h"
|
||||
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug = 1;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 2592
|
||||
#define SENSOR_MAX_HEIGHT 1944
|
||||
#define SENSOR_INIT_WIDTH 800 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 600
|
||||
#define SENSOR_INIT_WINSEQADR sensor_svga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -81,9 +82,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_WRITE_REGS 1
|
||||
#define WRITE_REGS_NUM 100
|
||||
|
||||
#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
|
||||
|
|
@ -2363,6 +2361,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 800;
|
||||
static s32 sensor_init_height = 600;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = sensor_init_data;
|
||||
static struct reginfo* sensor_init_winseq_p = sensor_svga;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -2371,7 +2376,63 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
//if val ==1,mean that sensor need to be reinit
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 800;
|
||||
sensor_init_height = 600;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
|
|
@ -2419,7 +2480,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0) {
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
goto sensor_INIT_ERR;
|
||||
|
|
@ -3786,20 +3847,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
}
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include "ov5642.h"
|
||||
|
||||
static int debug;
|
||||
|
|
@ -50,10 +51,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 2592
|
||||
#define SENSOR_MAX_HEIGHT 1944
|
||||
#define SENSOR_INIT_WIDTH 800 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 600
|
||||
#define SENSOR_INIT_WINSEQADR sensor_svga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -78,11 +80,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
|
||||
#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
|
||||
|
|
@ -164,7 +161,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define StepFocus_Nearest_Tag 0x04
|
||||
#define StepFocus_Spec_Tag 0x10
|
||||
#endif
|
||||
|
||||
/* init 800X600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
|
|
@ -4243,6 +4239,14 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static s32 sensor_init_width = 800;
|
||||
static s32 sensor_init_height = 600;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -4251,8 +4255,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
char value;
|
||||
int ret,pid = 0;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 800;
|
||||
sensor_init_height = 600;
|
||||
if (tmp_plat_data != NULL) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && (i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -4299,7 +4357,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0) {
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
goto sensor_INIT_ERR;
|
||||
|
|
@ -5706,18 +5764,20 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -51,10 +51,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 480//144
|
||||
#define SENSOR_MAX_WIDTH 640
|
||||
#define SENSOR_MAX_HEIGHT 480
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 0
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -74,10 +75,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -95,8 +92,7 @@ struct reginfo
|
|||
u8 reg;
|
||||
u8 val;
|
||||
};
|
||||
|
||||
/* init 640X480 VGA */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
{0x12, 0x80},
|
||||
|
|
@ -1383,6 +1379,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 800;
|
||||
static s32 sensor_init_height = 600;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1390,7 +1393,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_svga;
|
||||
sensor_init_width = 800;
|
||||
sensor_init_height = 600;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
|
|
@ -1412,7 +1470,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
|
||||
mdelay(5); //delay 5 microseconds
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2570,19 +2628,21 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
117
drivers/media/video/ov7690.c
Normal file → Executable file
117
drivers/media/video/ov7690.c
Normal file → Executable file
|
|
@ -19,8 +19,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 640
|
||||
#define SENSOR_MAX_HEIGHT 480
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,10 +74,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -94,7 +91,8 @@ struct reginfo
|
|||
u8 reg;
|
||||
u8 val;
|
||||
};
|
||||
/* init 640X480 VGA */
|
||||
|
||||
/* init 640*480 VGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
{0x12, 0x80},
|
||||
|
|
@ -1179,6 +1177,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1186,8 +1191,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret;
|
||||
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1207,7 +1266,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
}
|
||||
mdelay(5); //delay 5 microseconds
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2386,20 +2445,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -1551,7 +1551,6 @@ static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,
|
|||
{
|
||||
struct rk29camera_gpio_res *res = NULL;
|
||||
int ret = RK29_CAM_IO_SUCCESS;
|
||||
|
||||
if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
|
||||
res = (struct rk29camera_gpio_res *)&rk29_camera_platform_data.gpio_res[0];
|
||||
} else if (rk29_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) {
|
||||
|
|
@ -1561,7 +1560,6 @@ static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,
|
|||
ret = RK29_CAM_EIO_INVALID;
|
||||
goto rk29_sensor_ioctrl_end;
|
||||
}
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case Cam_Power:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#if CONFIG_ARCH_RK29
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/io.h>
|
||||
|
|
@ -553,7 +553,6 @@ static void rk29_camera_capture_process(struct work_struct *work)
|
|||
vipdata_base = pcdev->vipmem_phybase + vb->i*pcdev->vipmem_bsize;
|
||||
src_y_size = pcdev->host_width*pcdev->host_height;
|
||||
dst_y_size = pcdev->icd->user_width*pcdev->icd->user_height;
|
||||
|
||||
for (h=0; h<scale_times; h++) {
|
||||
for (w=0; w<scale_times; w++) {
|
||||
|
||||
|
|
@ -575,17 +574,17 @@ static void rk29_camera_capture_process(struct work_struct *work)
|
|||
vb->state = VIDEOBUF_ERROR;
|
||||
spin_unlock_irqrestore(&pcdev->lock, flags);
|
||||
|
||||
RK29CAMERA_TR("Capture image(vb->i:0x%x) which IPP operated is error:\n",vb->i);
|
||||
RK29CAMERA_TR("widx:%d hidx:%d ",w,h);
|
||||
RK29CAMERA_TR("%dx%d@(%d,%d)->%dx%d\n",pcdev->zoominfo.a.c.width,pcdev->zoominfo.a.c.height,pcdev->zoominfo.a.c.left,pcdev->zoominfo.a.c.top,pcdev->icd->user_width,pcdev->icd->user_height);
|
||||
RK29CAMERA_TR("ipp_req.src0.YrgbMst:0x%x ipp_req.src0.CbrMst:0x%x \n", ipp_req.src0.YrgbMst,ipp_req.src0.CbrMst);
|
||||
RK29CAMERA_TR("ipp_req.src0.w:0x%x ipp_req.src0.h:0x%x \n",ipp_req.src0.w,ipp_req.src0.h);
|
||||
RK29CAMERA_TR("ipp_req.src0.fmt:0x%x\n",ipp_req.src0.fmt);
|
||||
RK29CAMERA_TR("ipp_req.dst0.YrgbMst:0x%x ipp_req.dst0.CbrMst:0x%x \n",ipp_req.dst0.YrgbMst,ipp_req.dst0.CbrMst);
|
||||
RK29CAMERA_TR("ipp_req.dst0.w:0x%x ipp_req.dst0.h:0x%x \n",ipp_req.dst0.w ,ipp_req.dst0.h);
|
||||
RK29CAMERA_TR("ipp_req.dst0.fmt:0x%x\n",ipp_req.dst0.fmt);
|
||||
RK29CAMERA_TR("ipp_req.src_vir_w:0x%x ipp_req.dst_vir_w :0x%x\n",ipp_req.src_vir_w ,ipp_req.dst_vir_w);
|
||||
RK29CAMERA_TR("ipp_req.timeout:0x%x ipp_req.flag :0x%x\n",ipp_req.timeout,ipp_req.flag);
|
||||
printk("Capture image(vb->i:0x%x) which IPP operated is error:\n",vb->i);
|
||||
printk("widx:%d hidx:%d ",w,h);
|
||||
printk("%dx%d@(%d,%d)->%dx%d\n",pcdev->zoominfo.a.c.width,pcdev->zoominfo.a.c.height,pcdev->zoominfo.a.c.left,pcdev->zoominfo.a.c.top,pcdev->icd->user_width,pcdev->icd->user_height);
|
||||
printk("ipp_req.src0.YrgbMst:0x%x ipp_req.src0.CbrMst:0x%x \n", ipp_req.src0.YrgbMst,ipp_req.src0.CbrMst);
|
||||
printk("ipp_req.src0.w:0x%x ipp_req.src0.h:0x%x \n",ipp_req.src0.w,ipp_req.src0.h);
|
||||
printk("ipp_req.src0.fmt:0x%x\n",ipp_req.src0.fmt);
|
||||
printk("ipp_req.dst0.YrgbMst:0x%x ipp_req.dst0.CbrMst:0x%x \n",ipp_req.dst0.YrgbMst,ipp_req.dst0.CbrMst);
|
||||
printk("ipp_req.dst0.w:0x%x ipp_req.dst0.h:0x%x \n",ipp_req.dst0.w ,ipp_req.dst0.h);
|
||||
printk("ipp_req.dst0.fmt:0x%x\n",ipp_req.dst0.fmt);
|
||||
printk("ipp_req.src_vir_w:0x%x ipp_req.dst_vir_w :0x%x\n",ipp_req.src_vir_w ,ipp_req.dst_vir_w);
|
||||
printk("ipp_req.timeout:0x%x ipp_req.flag :0x%x\n",ipp_req.timeout,ipp_req.flag);
|
||||
|
||||
goto do_ipp_err;
|
||||
}
|
||||
|
|
@ -2231,3 +2230,4 @@ module_exit(rk29_camera_exit);
|
|||
MODULE_DESCRIPTION("RK29 Soc Camera Host driver");
|
||||
MODULE_AUTHOR("ddl <ddl@rock-chips>");
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
|
|
|||
1704
drivers/media/video/rk30_camera.c
Executable file
1704
drivers/media/video/rk30_camera.c
Executable file
File diff suppressed because it is too large
Load Diff
2337
drivers/media/video/rk30_camera_oneframe.c
Executable file
2337
drivers/media/video/rk30_camera_oneframe.c
Executable file
File diff suppressed because it is too large
Load Diff
118
drivers/media/video/s5k6aa.c
Normal file → Executable file
118
drivers/media/video/s5k6aa.c
Normal file → Executable file
|
|
@ -19,7 +19,8 @@
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/delay.h>
|
||||
#include "s5k6aa.h"
|
||||
static int debug;
|
||||
|
|
@ -54,10 +55,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 480
|
||||
#define SENSOR_MAX_WIDTH 1280
|
||||
#define SENSOR_MAX_HEIGHT 1024
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 0
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -79,11 +81,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
|
||||
#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\
|
||||
SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH |\
|
||||
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
|
||||
|
|
@ -110,7 +107,7 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_AF_MODE_CLOSE 5
|
||||
#endif
|
||||
|
||||
/* init 640X480 SVGA */
|
||||
/* init 800*600 SVGA */
|
||||
static struct reginfo sensor_init_data[] =
|
||||
{
|
||||
{0x0010,0x0001}, // Reset
|
||||
|
|
@ -3310,6 +3307,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
|
|
@ -3318,9 +3322,63 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret;
|
||||
u16 pid = 0;
|
||||
|
||||
char value;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
sensor_ioctrl(icd,Sensor_Reset, 1);
|
||||
|
|
@ -3368,7 +3426,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -4605,20 +4663,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
}
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
113
drivers/media/video/sid130B.c
Executable file → Normal file
113
drivers/media/video/sid130B.c
Executable file → Normal file
|
|
@ -19,7 +19,9 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
|
||||
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
|
@ -50,10 +52,12 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 1600
|
||||
#define SENSOR_MAX_HEIGHT 1200
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_UYVY8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -73,9 +77,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -1674,6 +1675,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1681,7 +1689,62 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
|
|
@ -1742,7 +1805,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
goto sensor_INIT_ERR;
|
||||
}
|
||||
#endif
|
||||
ret = sensor_write_array(client, sensor_init_data);
|
||||
ret = sensor_write_array(client, sensor_init_data_p);
|
||||
if (ret != 0)
|
||||
{
|
||||
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
|
||||
|
|
@ -2919,20 +2982,22 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
|
|||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/soc_camera.h>
|
||||
#include <mach/rk29_camera.h>
|
||||
|
||||
#include <plat/rk_camera.h>
|
||||
#include <linux/vmalloc.h>
|
||||
static int debug;
|
||||
module_param(debug, int, S_IRUGO|S_IWUSR);
|
||||
|
||||
|
|
@ -51,10 +51,11 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define SENSOR_MIN_HEIGHT 480//144
|
||||
#define SENSOR_MAX_WIDTH 640
|
||||
#define SENSOR_MAX_HEIGHT 480
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_MBUS_FMT_YUYV8_2X8
|
||||
#define SENSOR_INIT_WIDTH sensor_init_width /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT sensor_init_height
|
||||
#define SENSOR_INIT_WINSEQADR sensor_init_winseq_p
|
||||
#define SENSOR_INIT_PIXFMT sensor_init_pixelcode
|
||||
#define SENSOR_BUS_PARAM sensor_init_busparam
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 0
|
||||
#define CONFIG_SENSOR_Brightness 0
|
||||
|
|
@ -74,10 +75,6 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
|
|||
#define CONFIG_SENSOR_I2C_NOSCHED 0
|
||||
#define CONFIG_SENSOR_I2C_RDWRCHK 0
|
||||
|
||||
#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
|
||||
|
|
@ -1457,7 +1454,13 @@ static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd
|
|||
sensor_power_end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static s32 sensor_init_width = 640;
|
||||
static s32 sensor_init_height = 480;
|
||||
static unsigned long sensor_init_busparam = (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING|SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATAWIDTH_8 |SOCAM_MCLK_24MHZ);
|
||||
static enum v4l2_mbus_pixelcode sensor_init_pixelcode = V4L2_MBUS_FMT_YUYV8_2X8;
|
||||
static struct reginfo* sensor_init_data_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_p = NULL;
|
||||
static struct reginfo* sensor_init_winseq_board = NULL;
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
|
@ -1465,8 +1468,63 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
struct sensor *sensor = to_sensor(client);
|
||||
const struct v4l2_queryctrl *qctrl;
|
||||
const struct sensor_datafmt *fmt;
|
||||
int ret, i;
|
||||
|
||||
char value;
|
||||
int ret,pid = 0,i = 0,j=0;
|
||||
struct rk29camera_platform_data* tmp_plat_data =(struct rk29camera_platform_data*)val;
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
sensor_init_winseq_p = sensor_vga;
|
||||
sensor_init_width = 640;
|
||||
sensor_init_height = 480;
|
||||
if (tmp_plat_data != NULL && (u32)tmp_plat_data != 1) {
|
||||
for(i = 0;i < RK_CAM_NUM;i++){
|
||||
if ((tmp_plat_data->sensor_init_data[i])&& tmp_plat_data->info[i].dev_name &&
|
||||
(strcmp(tmp_plat_data->info[i].dev_name, dev_name(icd->pdev)) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tmp_plat_data && ((u32)tmp_plat_data != 1) &&(i < RK_CAM_NUM) && tmp_plat_data->sensor_init_data[i]){
|
||||
//user has defined the init data
|
||||
//init reg
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
for(j = 0;j< sizeof(sensor_init_data)/sizeof(struct reginfo);j++){
|
||||
sensor_init_data[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].reg;
|
||||
sensor_init_data[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data[j].val;
|
||||
}
|
||||
sensor_init_data_p = sensor_init_data;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data){
|
||||
sensor_init_data_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_data);
|
||||
}
|
||||
//init winseq
|
||||
if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq && (sizeof(struct reginfo) != sizeof(struct reginfo_t))){
|
||||
int tmp_winseq_size = tmp_plat_data->sensor_init_data[i]->rk_sensor_winseq_size;
|
||||
if(sensor_init_winseq_board)
|
||||
{
|
||||
vfree(sensor_init_winseq_board);
|
||||
sensor_init_winseq_board = NULL;
|
||||
}
|
||||
sensor_init_winseq_board = (struct reginfo*)vmalloc(tmp_winseq_size);
|
||||
if(!sensor_init_winseq_board)
|
||||
SENSOR_TR("%s :vmalloc erro !",__FUNCTION__);
|
||||
for(j = 0;j< tmp_winseq_size;j++){
|
||||
sensor_init_winseq_board[j].reg = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].reg;
|
||||
sensor_init_winseq_board[j].val = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq[j].val;
|
||||
}
|
||||
sensor_init_winseq_p = sensor_init_winseq_board;
|
||||
}
|
||||
else if(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq){
|
||||
sensor_init_winseq_p = (struct reginfo*)(tmp_plat_data->sensor_init_data[i]->rk_sensor_init_winseq);
|
||||
}
|
||||
//init width,height,bus,pixelcode
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width != INVALID_VALUE)
|
||||
sensor_init_width = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_width;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height != INVALID_VALUE)
|
||||
sensor_init_height = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_height;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param != INVALID_VALUE)
|
||||
sensor_init_busparam = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_bus_param;
|
||||
if(tmp_plat_data->sensor_init_data[i] && tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode != INVALID_VALUE)
|
||||
sensor_init_pixelcode = tmp_plat_data->sensor_init_data[i]->rk_sensor_init_pixelcode;
|
||||
}
|
||||
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
|
||||
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
|
||||
|
|
@ -1491,7 +1549,7 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
|||
|
||||
// ret = sensor_write(client, sensor_init_data + i*2, sensor_init_data + i*2 + 1);
|
||||
// printk("write to reg[0x%x] 0x%x\n",sensor_init_data[i].reg,sensor_init_data[i].val);
|
||||
ret = sensor_write(client, sensor_init_data[i].reg, sensor_init_data[i].val);
|
||||
ret = sensor_write(client, sensor_init_data_p[i].reg, sensor_init_data_p[i].val);
|
||||
//ret = sensor_write_array(client, sensor_init_data);
|
||||
if (ret != 0)
|
||||
{
|
||||
|
|
@ -2607,20 +2665,23 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
|||
|
||||
case RK29_CAM_SUBDEV_IOREQUEST:
|
||||
{
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
|
||||
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
|
||||
}
|
||||
} else {
|
||||
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
|
||||
if (sensor->sensor_io_request != NULL) {
|
||||
int j = 0;
|
||||
for(j = 0;j < RK_CAM_NUM;j++){
|
||||
if (sensor->sensor_io_request->gpio_res[j].dev_name &&
|
||||
(strcmp(sensor->sensor_io_request->gpio_res[j].dev_name, dev_name(icd->pdev)) == 0)) {
|
||||
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(j == RK_CAM_NUM){
|
||||
SENSOR_TR("%s %s RK_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
|
||||
ret = -EINVAL;
|
||||
goto sensor_ioctl_end;
|
||||
}
|
||||
}
|
||||
|
||||
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
|
||||
for this project */
|
||||
#if CONFIG_SENSOR_Flash
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user