From 5a3a5ad7a32d81304493e7857d9712824ab0dd96 Mon Sep 17 00:00:00 2001 From: ddl Date: Fri, 5 Jul 2013 11:44:41 +0800 Subject: [PATCH] camera: rk2928 sync rk30 --- .../mach-rk2928/include/mach/rk2928_camera.h | 6 +- drivers/media/video/rk2928_camera.c | 137 ++++++++++++++++-- 2 files changed, 124 insertions(+), 19 deletions(-) mode change 100644 => 100755 drivers/media/video/rk2928_camera.c diff --git a/arch/arm/mach-rk2928/include/mach/rk2928_camera.h b/arch/arm/mach-rk2928/include/mach/rk2928_camera.h index bb0239343d29..307572c2dab0 100644 --- a/arch/arm/mach-rk2928/include/mach/rk2928_camera.h +++ b/arch/arm/mach-rk2928/include/mach/rk2928_camera.h @@ -37,12 +37,8 @@ #define CAMERA_SCALE_CROP_MACHINE "pp" #endif -#if (CONFIG_CAMERA_SCALE_CROP_MACHINE == RK_CAM_SCALE_CROP_ARM) - #define CAMERA_VIDEOBUF_ARM_ACCESS 1 -#else - #define CAMERA_VIDEOBUF_ARM_ACCESS 0 -#endif +#define CAMERA_VIDEOBUF_ARM_ACCESS 1 #endif diff --git a/drivers/media/video/rk2928_camera.c b/drivers/media/video/rk2928_camera.c old mode 100644 new mode 100755 index c4ed001d9c37..3922dc94c297 --- a/drivers/media/video/rk2928_camera.c +++ b/drivers/media/video/rk2928_camera.c @@ -14,6 +14,7 @@ static int rk_sensor_iomux(int pin) { + iomux_set_gpio_mode(pin); return 0; } #define PMEM_CAM_BASE 0 //just for compile ,no meaning @@ -21,6 +22,7 @@ static int rk_sensor_iomux(int pin) static u64 rockchip_device_camera_dmamask = 0xffffffffUL; +#if RK_SUPPORT_CIF0 static struct resource rk_camera_resource_host_0[] = { [0] = { .start = RK2928_CIF_PHYS, @@ -33,6 +35,8 @@ static struct resource rk_camera_resource_host_0[] = { .flags = IORESOURCE_IRQ, } }; +#endif +#if RK_SUPPORT_CIF1 static struct resource rk_camera_resource_host_1[] = { [0] = { .start = RK2928_CIF_PHYS, @@ -45,7 +49,10 @@ static struct resource rk_camera_resource_host_1[] = { .flags = IORESOURCE_IRQ, } }; +#endif + /*platform_device : */ +#if RK_SUPPORT_CIF0 struct platform_device rk_device_camera_host_0 = { .name = RK29_CAM_DRV_NAME, .id = RK_CAM_PLATFORM_DEV_ID_0, /* This is used to put cameras on this interface */ @@ -57,6 +64,9 @@ static struct resource rk_camera_resource_host_1[] = { .platform_data = &rk_camera_platform_data, } }; +#endif + +#if RK_SUPPORT_CIF1 /*platform_device : */ struct platform_device rk_device_camera_host_1 = { .name = RK29_CAM_DRV_NAME, @@ -69,6 +79,7 @@ static struct resource rk_camera_resource_host_1[] = { .platform_data = &rk_camera_platform_data, } }; +#endif static void rk_init_camera_plateform_data(void) { @@ -90,11 +101,76 @@ static void rk_init_camera_plateform_data(void) static void rk30_camera_request_reserve_mem(void) { + int i,max_resolution; + int cam_ipp_mem=PMEM_CAMIPP_NECESSARY, cam_pmem=PMEM_CAM_NECESSARY; + + i =0; + max_resolution = 0x00; + while (strstr(new_camera[i].dev.device_info.dev.init_name,"end")==NULL) { + if (new_camera[i].resolution > max_resolution) + max_resolution = new_camera[i].resolution; + i++; + } + + if (max_resolution < PMEM_SENSOR_FULL_RESOLUTION_CIF_1) + max_resolution = PMEM_SENSOR_FULL_RESOLUTION_CIF_1; + if (max_resolution < PMEM_SENSOR_FULL_RESOLUTION_CIF_0) + max_resolution = PMEM_SENSOR_FULL_RESOLUTION_CIF_0; + + switch (max_resolution) + { + case 0x800000: + default: + { + cam_ipp_mem = 0x800000; + cam_pmem = 0x1900000; + break; + } + + case 0x500000: + { + cam_ipp_mem = 0x800000; + cam_pmem = 0x1400000; + break; + } + + case 0x300000: + { + cam_ipp_mem = 0x600000; + cam_pmem = 0xf00000; + break; + } + + case 0x200000: + { + cam_ipp_mem = 0x600000; + cam_pmem = 0xc00000; + break; + } + + case 0x100000: + { + cam_ipp_mem = 0x600000; + cam_pmem = 0xa00000; + break; + } + + case 0x30000: + { + cam_ipp_mem = 0x600000; + cam_pmem = 0x600000; + break; + } + } + + + #ifdef CONFIG_VIDEO_RK29_WORK_IPP - #ifdef CONFIG_VIDEO_RKCIF_WORK_SIMUL_OFF + rk_camera_platform_data.meminfo.vbase = rk_camera_platform_data.meminfo_cif1.vbase = NULL; + #if defined(CONFIG_VIDEO_RKCIF_WORK_SIMUL_OFF) || ((RK_SUPPORT_CIF0 && RK_SUPPORT_CIF1) == 0) rk_camera_platform_data.meminfo.name = "camera_ipp_mem"; - rk_camera_platform_data.meminfo.start = board_mem_reserve_add("camera_ipp_mem",PMEM_CAMIPP_NECESSARY); - rk_camera_platform_data.meminfo.size= PMEM_CAMIPP_NECESSARY; + rk_camera_platform_data.meminfo.start = board_mem_reserve_add("camera_ipp_mem",cam_ipp_mem); + rk_camera_platform_data.meminfo.size= cam_ipp_mem; memcpy(&rk_camera_platform_data.meminfo_cif1,&rk_camera_platform_data.meminfo,sizeof(struct rk29camera_mem_res)); #else @@ -108,8 +184,8 @@ static void rk30_camera_request_reserve_mem(void) #endif #endif #if PMEM_CAM_NECESSARY - android_pmem_cam_pdata.start = board_mem_reserve_add((char*)(android_pmem_cam_pdata.name),PMEM_CAM_NECESSARY); - android_pmem_cam_pdata.size= PMEM_CAM_NECESSARY; + android_pmem_cam_pdata.start = board_mem_reserve_add((char*)(android_pmem_cam_pdata.name),cam_pmem); + android_pmem_cam_pdata.size= cam_pmem; #endif } @@ -117,6 +193,7 @@ static int rk_register_camera_devices(void) { int i; int host_registered_0,host_registered_1; + struct rkcamera_platform_data *new_camera; rk_init_camera_plateform_data(); @@ -125,24 +202,56 @@ static int rk_register_camera_devices(void) for (i=0; idev.device_info.dev.init_name,"end")==NULL) { + if (new_camera->dev.link_info.bus_id == RK_CAM_PLATFORM_DEV_ID_1) { + host_registered_1 = 1; + } else if (new_camera->dev.link_info.bus_id == RK_CAM_PLATFORM_DEV_ID_0) { + host_registered_0 = 1; + } + new_camera++; + } + } + #if RK_SUPPORT_CIF0 + if (host_registered_0) { + platform_device_register(&rk_device_camera_host_0); + } + #endif + #if RK_SUPPORT_CIF1 + if (host_registered_1) { + platform_device_register(&rk_device_camera_host_1); + } + #endif + for (i=0; i