From 7336bd1117d69c25ad79caf7ac79608de7819c21 Mon Sep 17 00:00:00 2001 From: ddl Date: Wed, 7 Nov 2012 11:53:13 +0800 Subject: [PATCH] camera: add support interpolate to 8Mega, version v0.2.0x17 --- arch/arm/plat-rk/include/plat/rk_camera.h | 8 ++- arch/arm/plat-rk/rk_camera.c | 10 ++- drivers/media/video/Kconfig | 59 ++++++++++------- drivers/media/video/gc0308.c | 34 ++++++---- drivers/media/video/hi253.c | 76 +++++++++++++++++++--- drivers/media/video/ov5642.c | 40 ++++++++++-- drivers/media/video/rk30_camera_oneframe.c | 16 +++-- 7 files changed, 186 insertions(+), 57 deletions(-) diff --git a/arch/arm/plat-rk/include/plat/rk_camera.h b/arch/arm/plat-rk/include/plat/rk_camera.h index 42f363983715..0d22f69bdd39 100755 --- a/arch/arm/plat-rk/include/plat/rk_camera.h +++ b/arch/arm/plat-rk/include/plat/rk_camera.h @@ -37,7 +37,7 @@ #define RK_CAM_NUM 6 #define RK29_CAM_SUPPORT_NUMS RK_CAM_NUM -#define RK_CAM_SUPPORT_RESOLUTION 0x500000 +#define RK_CAM_SUPPORT_RESOLUTION 0x800000 /*---------------- Camera Sensor Must Define Macro Begin ------------------------*/ #define RK29_CAM_SENSOR_OV7675 ov7675 #define RK29_CAM_SENSOR_OV9650 ov9650 @@ -114,7 +114,11 @@ #define ov3640_FULL_RESOLUTION 0x300000 // 3 megapixel #define ov3660_FULL_RESOLUTION 0x300000 // 3 megapixel #define ov5640_FULL_RESOLUTION 0x500000 // 5 megapixel -#define ov5642_FULL_RESOLUTION 0x500000 // 5 megapixel +#if defined(CONFIG_SOC_CAMERA_OV5642_INTERPOLATION_8M) + #define ov5642_FULL_RESOLUTION 0x800000 // 8 megapixel +#else + #define ov5642_FULL_RESOLUTION 0x500000 // 5 megapixel +#endif #define s5k6aa_FULL_RESOLUTION 0x130000 // 1.3 megapixel #define mt9d112_FULL_RESOLUTION 0x200000 // 2 megapixel #define mt9d113_FULL_RESOLUTION 0x200000 // 2 megapixel diff --git a/arch/arm/plat-rk/rk_camera.c b/arch/arm/plat-rk/rk_camera.c index f57f49a7bcc5..e747b829564e 100755 --- a/arch/arm/plat-rk/rk_camera.c +++ b/arch/arm/plat-rk/rk_camera.c @@ -185,7 +185,10 @@ #endif //CIF 0 -#if (PMEM_SENSOR_FULL_RESOLUTION_CIF_0 == 0x500000) +#if (PMEM_SENSOR_FULL_RESOLUTION_CIF_0 == 0x800000) /* ddl@rock-chips.com : It is only support 5Mega interplate to 8Mega */ +#define PMEM_CAM_NECESSARY_CIF_0 0x1900000 /* 1280*720*1.5*4(preview) + 12M(capture raw) + 7M(jpeg encode output) */ +#define PMEM_CAMIPP_NECESSARY_CIF_0 0x800000 +#elif (PMEM_SENSOR_FULL_RESOLUTION_CIF_0 == 0x500000) #define PMEM_CAM_NECESSARY_CIF_0 0x1400000 /* 1280*720*1.5*4(preview) + 7.5M(capture raw) + 4M(jpeg encode output) */ #define PMEM_CAMIPP_NECESSARY_CIF_0 0x800000 #elif (PMEM_SENSOR_FULL_RESOLUTION_CIF_0 == 0x300000) @@ -209,7 +212,10 @@ #endif //CIF 1 -#if (PMEM_SENSOR_FULL_RESOLUTION_CIF_1 == 0x500000) +#if (PMEM_SENSOR_FULL_RESOLUTION_CIF_1 == 0x800000) /* ddl@rock-chips.com : It is only support 5Mega interplate to 8Mega */ +#define PMEM_CAM_NECESSARY_CIF_1 0x1900000 /* 1280*720*1.5*4(preview) + 12M(capture raw) + 7M(jpeg encode output) */ +#define PMEM_CAMIPP_NECESSARY_CIF_1 0x800000 +#elif (PMEM_SENSOR_FULL_RESOLUTION_CIF_1 == 0x500000) #define PMEM_CAM_NECESSARY_CIF_1 0x1400000 /* 1280*720*1.5*4(preview) + 7.5M(capture raw) + 4M(jpeg encode output) */ #define PMEM_CAMIPP_NECESSARY_CIF_1 0x800000 #elif (PMEM_SENSOR_FULL_RESOLUTION_CIF_1 == 0x300000) diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f83a671dced4..009e8fc41605 100755 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -1035,6 +1035,20 @@ config OV5642_USER_DEFINED_SERIES bool "OV5642 user defined init series" default n +config SOC_CAMERA_OV5642_INTERPOLATION + bool "support sensor interpolation for higher resolution" + depends on SOC_CAMERA_OV5642 +choice + prompt "OV5642 interpolation resolution" + depends on SOC_CAMERA_OV5642_INTERPOLATION + default SOC_CAMERA_OV5642_INTERPOLATION_8M + ---help--- + OV5642 interpolation resolution + +config SOC_CAMERA_OV5642_INTERPOLATION_8M + bool "8 megapixel 3264x2448" +endchoice + choice prompt "OV5642 Module Focus select" depends on SOC_CAMERA_OV5642 @@ -1137,24 +1151,20 @@ config GC0308_USER_DEFINED_SERIES config SOC_CAMERA_GC0308_INTERPOLATION bool "support sensor interpolation for higher resolution" depends on SOC_CAMERA_GC0308 - -config SOC_CAMERA_GC0308_INTERPOLATION_2M - bool "sensor interpolation 2 megapixel 1600x1200" +choice + prompt "GC0308 interpolation resolution" depends on SOC_CAMERA_GC0308_INTERPOLATION - help - 0x200000 2 megapixel 1600x1200 + default SOC_CAMERA_GC0308_INTERPOLATION_1M + ---help--- + GC0308 interpolation resolution +config SOC_CAMERA_GC0308_INTERPOLATION_1M + bool "1 megapixel 1024x768" +config SOC_CAMERA_GC0308_INTERPOLATION_2M + bool "2 megapixel 1600x1200" config SOC_CAMERA_GC0308_INTERPOLATION_3M - bool "sensor interpolation 3 megapixel 2048x1536" - depends on SOC_CAMERA_GC0308_INTERPOLATION - help - 0x300000 3 megapixel 2048x1536 - -config SOC_CAMERA_GC0308_INTERPOLATION_5M - bool "sensor interpolation 5 megapixel 2592x1944" - depends on SOC_CAMERA_GC0308_INTERPOLATION - help - 0x500000 5 megapixel 2592x1944 + bool "3 megapixel 2048x1536" +endchoice config SOC_CAMERA_GC0309 tristate "GC0309 support for rockchip" @@ -1210,17 +1220,18 @@ config SOC_CAMERA_HI253_INTERPOLATION bool "support sensor interpolation for higher resolution" depends on SOC_CAMERA_HI253 -config SOC_CAMERA_HI253_INTERPOLATION_3M - bool "sensor interpolation 3 megapixel 2048x1536" +choice + prompt "HI253 interpolation resolution" depends on SOC_CAMERA_HI253_INTERPOLATION - help - 0x300000 3 megapixel 2048x1536 - + default SOC_CAMERA_HI253_INTERPOLATION_3M + ---help--- + HI253 interpolation resolution + +config SOC_CAMERA_HI253_INTERPOLATION_3M + bool "3 megapixel 2048x1536" config SOC_CAMERA_HI253_INTERPOLATION_5M - bool "sensor interpolation 5 megapixel 2592x1944" - depends on SOC_CAMERA_HI253_INTERPOLATION - help - 0x500000 5 megapixel 2592x1944 + bool "5 megapixel 2592x1944" +endchoice config SOC_CAMERA_HI704 tristate "HI704 support for rockchip" diff --git a/drivers/media/video/gc0308.c b/drivers/media/video/gc0308.c index abffd9a9b16b..5193eab94794 100755 --- a/drivers/media/video/gc0308.c +++ b/drivers/media/video/gc0308.c @@ -49,6 +49,8 @@ module_param(debug, int, S_IRUGO|S_IWUSR); #define SENSOR_ID 0x9b #define SENSOR_MIN_WIDTH 640//176 #define SENSOR_MIN_HEIGHT 480//144 +#define SENSOR_MAX_WIDTH_REAL 640 +#define SENSOR_MAX_HEIGHT_REAL 480 #if defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION_5M) #define SENSOR_MAX_WIDTH 2592 #define SENSOR_MAX_HEIGHT 1944 @@ -59,8 +61,8 @@ module_param(debug, int, S_IRUGO|S_IWUSR); #define SENSOR_MAX_WIDTH 1600 #define SENSOR_MAX_HEIGHT 1200 #else - #define SENSOR_MAX_WIDTH 640 - #define SENSOR_MAX_HEIGHT 480 + #define SENSOR_MAX_WIDTH SENSOR_MAX_WIDTH_REAL + #define SENSOR_MAX_HEIGHT SENSOR_MAX_HEIGHT_REAL #endif #define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */ #define SENSOR_INIT_HEIGHT 480 @@ -1839,12 +1841,12 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) set_w = 1280; set_h = 1024; } -#if defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION_2M)||defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION_3M) || defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION_5M) - else if (((set_w <= SENSOR_MAX_WIDTH) && (set_h <= SENSOR_MAX_HEIGHT)) ) +#if defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION) + else if (((set_w <= SENSOR_MAX_WIDTH) && (set_h <= SENSOR_MAX_HEIGHT)) ) { - winseqe_set_addr = sensor_vga; - set_w = 640; - set_h = 480; + winseqe_set_addr = sensor_vga; + set_w = SENSOR_MAX_WIDTH_REAL; + set_h = SENSOR_MAX_HEIGHT_REAL; } #endif @@ -1938,6 +1940,14 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) mf->code = fmt->code; } + /* ddl@rock-chips.com : It is query max resolution only. */ + if (mf->reserved[6] == 0xfefe5a5a) { + mf->height = SENSOR_MAX_HEIGHT; + mf->width = SENSOR_MAX_WIDTH; + ret = 0; + goto sensor_try_fmt_end; + } + if (mf->height > SENSOR_MAX_HEIGHT) mf->height = SENSOR_MAX_HEIGHT; else if (mf->height < SENSOR_MIN_HEIGHT) @@ -1981,11 +1991,11 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) set_w = 1280; set_h = 1024; } -#if defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION_2M)||defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION_3M) || defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION_5M) - else if (((set_w <= SENSOR_MAX_WIDTH) && (set_h <= SENSOR_MAX_HEIGHT)) ) +#if defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION) + else if (((set_w <= SENSOR_MAX_WIDTH) && (set_h <= SENSOR_MAX_HEIGHT)) ) { - set_w = 640; - set_h = 480; + set_w = SENSOR_MAX_WIDTH_REAL; + set_h = SENSOR_MAX_HEIGHT_REAL; } #endif @@ -1999,7 +2009,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) mf->height = set_h; mf->colorspace = fmt->colorspace; - +sensor_try_fmt_end: return ret; } diff --git a/drivers/media/video/hi253.c b/drivers/media/video/hi253.c index 12cad80975b5..7553bbadd81b 100755 --- a/drivers/media/video/hi253.c +++ b/drivers/media/video/hi253.c @@ -48,6 +48,8 @@ module_param(debug, int, S_IRUGO|S_IWUSR); #define SENSOR_ID 0x92 #define SENSOR_MIN_WIDTH 176 #define SENSOR_MIN_HEIGHT 144 +#define SENSOR_MAX_WIDTH_REAL 1600 +#define SENSOR_MAX_HEIGHT_REAL 1200 #if defined(CONFIG_SOC_CAMERA_HI253_INTERPOLATION_5M) #define SENSOR_MAX_WIDTH 2592 #define SENSOR_MAX_HEIGHT 1944 @@ -55,8 +57,8 @@ module_param(debug, int, S_IRUGO|S_IWUSR); #define SENSOR_MAX_WIDTH 2048 #define SENSOR_MAX_HEIGHT 1536 #else - #define SENSOR_MAX_WIDTH 1600 - #define SENSOR_MAX_HEIGHT 1200 + #define SENSOR_MAX_WIDTH SENSOR_MAX_WIDTH_REAL + #define SENSOR_MAX_HEIGHT SENSOR_MAX_HEIGHT_REAL #endif #define SENSOR_INIT_WIDTH 1600 /* Sensor pixel size for sensor_init_data array */ @@ -2541,12 +2543,12 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) set_w = 1600; set_h = 1200; } -#if defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION_3M) || defined(CONFIG_SOC_CAMERA_GC0308_INTERPOLATION_5M) +#if defined(CONFIG_SOC_CAMERA_HI253_INTERPOLATION) else if (((set_w <= SENSOR_MAX_WIDTH) && (set_h <= SENSOR_MAX_HEIGHT)) ) { - winseqe_set_addr = sensor_uxga; - set_w = 1600; - set_h = 1200; + winseqe_set_addr = sensor_uxga; + set_w = SENSOR_MAX_WIDTH_REAL; + set_h = SENSOR_MAX_HEIGHT_REAL; } #endif else @@ -2642,7 +2644,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) struct i2c_client *client = v4l2_get_subdevdata(sd); struct sensor *sensor = to_sensor(client); const struct sensor_datafmt *fmt; - int ret = 0; + int ret = 0,set_w,set_h;; fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts, ARRAY_SIZE(sensor_colour_fmts)); @@ -2651,6 +2653,14 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) mf->code = fmt->code; } + /* ddl@rock-chips.com : It is query max resolution only. */ + if (mf->reserved[6] == 0xfefe5a5a) { + mf->height = SENSOR_MAX_HEIGHT; + mf->width = SENSOR_MAX_WIDTH; + ret = 0; + goto sensor_try_fmt_end; + } + if (mf->height > SENSOR_MAX_HEIGHT) mf->height = SENSOR_MAX_HEIGHT; else if (mf->height < SENSOR_MIN_HEIGHT) @@ -2660,9 +2670,59 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) mf->width = SENSOR_MAX_WIDTH; else if (mf->width < SENSOR_MIN_WIDTH) mf->width = SENSOR_MIN_WIDTH; + + set_w = mf->width; + set_h = mf->height; - mf->colorspace = fmt->colorspace; + if (((set_w <= 176) && (set_h <= 144)) && sensor_qcif[0].reg) + { + set_w = 176; + set_h = 144; + } + else if (((set_w <= 320) && (set_h <= 240)) && sensor_qvga[0].reg) + { + set_w = 320; + set_h = 240; + } + else if (((set_w <= 352) && (set_h<= 288)) && sensor_cif[0].reg) + { + set_w = 352; + set_h = 288; + } + else if (((set_w <= 640) && (set_h <= 480)) && sensor_vga[0].reg) + { + set_w = 640; + set_h = 480; + } + else if (((set_w <= 800) && (set_h <= 600)) && sensor_svga[0].reg) + { + set_w = 800; + set_h = 600; + } + else if (((set_w <= 1280) && (set_h <= 1024)) && sensor_sxga[0].reg) + { + set_w = 1280; + set_h = 1024; + } +#if defined(CONFIG_SOC_CAMERA_HI253_INTERPOLATION) + else if (((set_w <= SENSOR_MAX_WIDTH) && (set_h <= SENSOR_MAX_HEIGHT)) ) + { + set_w = SENSOR_MAX_WIDTH_REAL; + set_h = SENSOR_MAX_HEIGHT_REAL; + } +#endif + + else + { + set_w = SENSOR_INIT_WIDTH; + set_h = SENSOR_INIT_HEIGHT; + } + + mf->width = set_w; + mf->height = set_h; + mf->colorspace = fmt->colorspace; +sensor_try_fmt_end: return ret; } diff --git a/drivers/media/video/ov5642.c b/drivers/media/video/ov5642.c index 7f73e81fb2da..04ad8883ca13 100755 --- a/drivers/media/video/ov5642.c +++ b/drivers/media/video/ov5642.c @@ -49,8 +49,15 @@ module_param(debug, int, S_IRUGO|S_IWUSR); #define SENSOR_ID 0x5642 #define SENSOR_MIN_WIDTH 176 #define SENSOR_MIN_HEIGHT 144 -#define SENSOR_MAX_WIDTH 2592 -#define SENSOR_MAX_HEIGHT 1944 +#define SENSOR_MAX_WIDTH_REAL 2592 +#define SENSOR_MAX_HEIGHT_REAL 1944 +#if defined(CONFIG_SOC_CAMERA_OV5642_INTERPOLATION_8M) +#define SENSOR_MAX_WIDTH 3264 +#define SENSOR_MAX_HEIGHT 2448 +#else +#define SENSOR_MAX_WIDTH SENSOR_MAX_WIDTH_REAL +#define SENSOR_MAX_HEIGHT SENSOR_MAX_HEIGHT_REAL +#endif #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 @@ -4587,6 +4594,8 @@ static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_mbus_frame ret = true; } else if ((mf->width == 2592) && (mf->height == 1944)) { ret = true; + } else if ((mf->width == 3264) && (mf->height == 2448)) { + ret = true; } if (ret == true) @@ -4726,6 +4735,14 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) set_w = 2592; set_h = 1944; } +#if defined(CONFIG_SOC_CAMERA_OV5642_INTERPOLATION) + else if (((set_w <= SENSOR_MAX_WIDTH) && (set_h <= SENSOR_MAX_HEIGHT)) ) + { + winseqe_set_addr = sensor_qsxga; + set_w = SENSOR_MAX_WIDTH_REAL; + set_h = SENSOR_MAX_HEIGHT_REAL; + } +#endif else { winseqe_set_addr = SENSOR_INIT_WINSEQADR; /* ddl@rock-chips.com : Sensor output smallest size if isn't support app */ @@ -4858,7 +4875,15 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) if (fmt == NULL) { fmt = &sensor->info_priv.fmt; mf->code = fmt->code; - } + } + /* ddl@rock-chips.com : It is query max resolution only. */ + if (mf->reserved[6] == 0xfefe5a5a) { + mf->height = SENSOR_MAX_HEIGHT; + mf->width = SENSOR_MAX_WIDTH; + ret = 0; + printk("%s(%d): query resolution\n",__FUNCTION__,__LINE__); + goto sensor_try_fmt_end; + } if (mf->height > SENSOR_MAX_HEIGHT) mf->height = SENSOR_MAX_HEIGHT; @@ -4933,6 +4958,13 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) set_w = 2592; set_h = 1944; } +#if defined(CONFIG_SOC_CAMERA_OV5642_INTERPOLATION) + else if (((set_w <= SENSOR_MAX_WIDTH) && (set_h <= SENSOR_MAX_HEIGHT)) ) + { + set_w = SENSOR_MAX_WIDTH_REAL; + set_h = SENSOR_MAX_HEIGHT_REAL; + } +#endif else { set_w = SENSOR_INIT_WIDTH; @@ -4943,7 +4975,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) mf->height = set_h; mf->colorspace = fmt->colorspace; - +sensor_try_fmt_end: return ret; } diff --git a/drivers/media/video/rk30_camera_oneframe.c b/drivers/media/video/rk30_camera_oneframe.c index 9ea8180d3e36..3113b0fa4ba1 100755 --- a/drivers/media/video/rk30_camera_oneframe.c +++ b/drivers/media/video/rk30_camera_oneframe.c @@ -271,9 +271,10 @@ module_param(debug, int, S_IRUGO|S_IWUSR); 5.arm scale algorithm has something wrong(may exceed the bound of width or height) ,fix it. *v0.x.15: * 1. support rk3066b; - +*v0.x.17: +* 1. support 8Mega picture; */ -#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 2, 0x15) +#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 2, 0x17) /* limit to rk29 hardware capabilities */ #define RK_CAM_BUS_PARAM (SOCAM_MASTER |\ @@ -932,6 +933,7 @@ static int rk_camera_scale_crop_ipp(struct work_struct *work) int src_y_offset,src_uv_offset,dst_y_offset,dst_uv_offset,src_y_size,dst_y_size; int scale_times,w,h; int ret = 0; + /* *ddl@rock-chips.com: * IPP Dest image resolution is 2047x1088, so scale operation break up some times @@ -1002,7 +1004,6 @@ static int rk_camera_scale_crop_ipp(struct work_struct *work) } } } - do_ipp_err: return ret; } @@ -1046,7 +1047,7 @@ static int rk_camera_scale_crop_arm(struct work_struct *work) zoomindstxIntInv = ((unsigned long)cropW<<16)/dstW + 1; zoomindstyIntInv = ((unsigned long)cropH<<16)/dstH + 1; - + //y //for(y = 0; yvipmem_bsize)); @@ -2148,6 +2148,8 @@ static bool rk_camera_fmt_capturechk(struct v4l2_format *f) ret = true; } else if ((f->fmt.pix.width == 2592) && (f->fmt.pix.height == 1944)) { ret = true; + } else if ((f->fmt.pix.width == 3264) && (f->fmt.pix.height == 2448)) { + ret = true; } if (ret == true) @@ -2203,6 +2205,10 @@ static int rk_camera_try_fmt(struct soc_camera_device *icd, mf.field = pix->field; mf.colorspace = pix->colorspace; mf.code = xlate->code; + /* ddl@rock-chips.com : It is query max resolution only. */ + if ((usr_w == 10000) && (usr_h == 10000)) { + mf.reserved[6] = 0xfefe5a5a; + } ret = v4l2_subdev_call(sd, video, try_mbus_fmt, &mf); if (ret < 0) -- 2.34.1