From 53b3954eb0a7bc50b81af8eec58dd8835c6b335c Mon Sep 17 00:00:00 2001 From: ddl Date: Fri, 6 Aug 2010 17:41:42 +0800 Subject: [PATCH] Camera Support DC! Modify soc_camera_s_fmt_vid_cap function for DC --- Makefile | 2 +- arch/arm/mach-rk2818/board-raho.c | 164 +--------------------------- arch/arm/mach-rk2818/devices.c | 2 +- drivers/fpga/spi_i2c.c | 2 +- drivers/media/video/rk2818_camera.c | 4 +- drivers/media/video/soc_camera.c | 24 +++- drivers/media/video/v4l2-ioctl.c | 6 +- 7 files changed, 31 insertions(+), 173 deletions(-) diff --git a/Makefile b/Makefile index d7cf5448ee7b..806fd6a7af09 100644 --- a/Makefile +++ b/Makefile @@ -184,7 +184,7 @@ export KBUILD_BUILDHOST := $(SUBARCH) #CROSS_COMPILE ?= ARCH ?= arm #CROSS_COMPILE :=/opt/android0320/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi- -CROSS_COMPILE ?=../toolchain/arm-eabi-4.4.0/bin/arm-eabi- +CROSS_COMPILE ?=/root/toolchain/arm-eabi-4.4.0/bin/arm-eabi- # Architecture as present in compile.h UTS_MACHINE := $(ARCH) diff --git a/arch/arm/mach-rk2818/board-raho.c b/arch/arm/mach-rk2818/board-raho.c index 805eab3dd712..525819a539d4 100644 --- a/arch/arm/mach-rk2818/board-raho.c +++ b/arch/arm/mach-rk2818/board-raho.c @@ -415,9 +415,7 @@ struct rk2818_spi_chip spi_xpt2046_info = { /***************************************************************************************** * camera devices *author: ddl@rock-chips.com - *****************************************************************************************/ -#if 1 - + *****************************************************************************************/ #define RK2818_CAM_POWER_PIN FPGA_PIO1_05//SPI_GPIO_P1_05 #define RK2818_CAM_RESET_PIN FPGA_PIO1_14//SPI_GPIO_P1_14 @@ -530,167 +528,7 @@ static int rk28_sensor_power(struct device *dev, int on) } return 0; } -#else - - /***************************************************************************************** - * camera devices - *author: ddl@rock-chips.com - *****************************************************************************************/ -#define RK2818_CAM_POWER_PIN SPI_GPIO_P1_05 -#define RK2818_CAM_RESET_PIN SPI_GPIO_P1_14 -static int rk28_sensor_init(void); -static int rk28_sensor_deinit(void); - -struct rk28camera_platform_data rk28_camera_platform_data = { - .init = rk28_sensor_init, - .deinit = rk28_sensor_deinit, - .gpio_res = { - { - .gpio_reset = RK2818_CAM_RESET_PIN, - .gpio_power = RK2818_CAM_POWER_PIN, - .gpio_flag = 0x03, - .dev_name = "ov2655" - }, { - .gpio_reset = 0xFFFFFFFF, - .gpio_power = 0xFFFFFFFF, - .gpio_flag = 0x00, - .dev_name = NULL - } - } -}; - -static int rk28_sensor_init(void) -{ - int ret = 0, i; - unsigned int camera_reset=0xffffffff,camera_power=0xffffffff, camera_ioflag; - - printk("\n%s....%d ******** ddl *********\n",__FUNCTION__,__LINE__); - - for (i=0; i<2; i++) { - camera_reset = rk28_camera_platform_data.gpio_res[i].gpio_reset; - camera_power = rk28_camera_platform_data.gpio_res[i].gpio_power; - camera_ioflag = rk28_camera_platform_data.gpio_res[i].gpio_flag; - - if (camera_power != 0xffffffff) { - if (camera_ioflag & 0x02) { /* ddl@rock-chips.com : fpga io extern */ - spi_gpio_set_pinlevel(camera_power, SPI_GPIO_LOW); - spi_gpio_set_pindirection(camera_power, SPI_GPIO_OUT); - } else { - ret = gpio_request(camera_power, "camera power"); - if (ret) - continue; - - gpio_set_value(camera_reset, 1); - gpio_direction_output(camera_power, 0); - } - } - - if (camera_reset != 0xffffffff) { - if (camera_ioflag & 0x01) { - spi_gpio_set_pinlevel(camera_reset, SPI_GPIO_HIGH); - spi_gpio_set_pindirection(camera_reset, SPI_GPIO_OUT); - } else { - ret = gpio_request(camera_reset, "camera reset"); - if (ret) { - if (camera_power != 0xffffffff) - gpio_free(camera_power); - - continue; - } - gpio_direction_output(camera_reset, 0); - gpio_set_value(camera_reset, 1); - } - } - } - - return 0; -} - -static int rk28_sensor_deinit(void) -{ - unsigned int i; - unsigned int camera_reset=0xffffffff,camera_power=0xffffffff,camera_ioflag; - - printk("\n%s....%d ******** ddl *********\n",__FUNCTION__,__LINE__); - - for (i=0; i<2; i++) { - camera_reset = rk28_camera_platform_data.gpio_res[i].gpio_reset; - camera_power = rk28_camera_platform_data.gpio_res[i].gpio_power; - camera_ioflag = rk28_camera_platform_data.gpio_res[i].gpio_flag; - - if (camera_power != 0xffffffff){ - if ((camera_ioflag & 0x02) == 0) { - gpio_direction_input(camera_power); - gpio_free(camera_power); - } else { - spi_gpio_set_pinlevel(camera_power, SPI_GPIO_HIGH); - spi_gpio_set_pindirection(camera_power, SPI_GPIO_IN); - } - } - - if (camera_reset != 0xffffffff) { - if ((camera_ioflag & 0x01) == 0) { - gpio_direction_input(camera_reset); - gpio_free(camera_reset); - } else { - spi_gpio_set_pinlevel(camera_reset, SPI_GPIO_HIGH); - spi_gpio_set_pindirection(camera_reset, SPI_GPIO_IN); - } - } - } - - return 0; -} - - -static int rk28_sensor_power(struct device *dev, int on) -{ - unsigned int camera_reset=0xffffffff,camera_power=0xffffffff,camera_ioflag; - - if(rk28_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk28_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) { - camera_reset = rk28_camera_platform_data.gpio_res[0].gpio_reset; - camera_power = rk28_camera_platform_data.gpio_res[0].gpio_power; - camera_ioflag = rk28_camera_platform_data.gpio_res[0].gpio_flag; - } else if (rk28_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk28_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) { - camera_reset = rk28_camera_platform_data.gpio_res[1].gpio_reset; - camera_power = rk28_camera_platform_data.gpio_res[1].gpio_power; - camera_ioflag = rk28_camera_platform_data.gpio_res[1].gpio_flag; - } - - if (camera_reset != 0xffffffff) { - if (camera_ioflag & 0x01) { - spi_gpio_set_pinlevel(camera_reset, on); - } else { - gpio_set_value(camera_reset, on); - } - printk("\n%s..%s..ResetPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev),camera_reset, on); - } - if (camera_power != 0xffffffff) { - if (camera_ioflag & 0x02) { - spi_gpio_set_pinlevel(camera_power, !on); - } else { - gpio_set_value(camera_power, !on); - } - printk("\n%s..%s..PowerPin=%d ..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_power, !on); - } - if (camera_reset != 0xffffffff) { - mdelay(3); - if (camera_ioflag & 0x01) { - spi_gpio_set_pinlevel(camera_reset,on); - } else { - gpio_set_value(camera_reset,on); - } - printk("\n%s..%s..ResetPin= %d..PinLevel = %x ******** ddl *********\n",__FUNCTION__,dev_name(dev), camera_reset, on); - } - - mdelay(3000); - - return 0; -} - - -#endif #define OV2655_IIC_ADDR 0x60 static struct i2c_board_info rk2818_i2c_cam_info[] = { diff --git a/arch/arm/mach-rk2818/devices.c b/arch/arm/mach-rk2818/devices.c index e9c1ae8cb800..3cd21b180669 100755 --- a/arch/arm/mach-rk2818/devices.c +++ b/arch/arm/mach-rk2818/devices.c @@ -468,7 +468,7 @@ static struct android_pmem_platform_data pmem_pdata = { static struct android_pmem_platform_data pmem_pdata_dsp = { .name = "pmem-dsp", - .no_allocator = 1, + .no_allocator = 0, .cached = 0, .start = 0x6db00000, .size = 0x1500000, diff --git a/drivers/fpga/spi_i2c.c b/drivers/fpga/spi_i2c.c index e80854cbb941..35f81509acba 100755 --- a/drivers/fpga/spi_i2c.c +++ b/drivers/fpga/spi_i2c.c @@ -93,7 +93,7 @@ int spi_i2c_select_speed(int speed) result = ICE_SET_400K_I2C_SPEED; break; default: - printk("not support this rate ,set spi i2c rate fail\n"); + result = ICE_SET_100K_I2C_SPEED; /* ddl@rock-chips.com : default set 100KHz */ break; } return result; diff --git a/drivers/media/video/rk2818_camera.c b/drivers/media/video/rk2818_camera.c index aaff81cd24b6..f6f0273e4595 100644 --- a/drivers/media/video/rk2818_camera.c +++ b/drivers/media/video/rk2818_camera.c @@ -774,12 +774,12 @@ static int rk28_camera_try_fmt(struct soc_camera_device *icd, struct v4l2_pix_format *pix = &f->fmt.pix; __u32 pixfmt = pix->pixelformat; enum v4l2_field field; - int ret; + int ret,i; RK28CAMERA_TR("\n%s..%d.. ******** ddl *********\n",__FUNCTION__,__LINE__); xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); - if (!xlate) { + if (!xlate) { dev_err(ici->v4l2_dev.dev, "Format %x not found\n", pixfmt); ret = -EINVAL; goto RK28_CAMERA_TRY_FMT_END; diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 4eb5f65498b6..141d81ab1cbb 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -292,7 +292,8 @@ static int soc_camera_set_fmt(struct soc_camera_file *icf, dev_dbg(&icd->dev, "S_FMT(%c%c%c%c, %ux%u)\n", pixfmtstr(pix->pixelformat), pix->width, pix->height); - + + printk("%s..%d.. ********ddl*******\n",__FUNCTION__, __LINE__); /* We always call try_fmt() before set_fmt() or set_crop() */ ret = ici->ops->try_fmt(icd, f); if (ret < 0) @@ -443,6 +444,8 @@ static int soc_camera_close(struct file *file) module_put(ici->ops->owner); + printk("icf->vb_vidq.bufs[0] = 0x%x\n",(int)(icf->vb_vidq.bufs[0])); + vfree(icf); dev_dbg(&icd->dev, "camera device close\n"); @@ -509,17 +512,34 @@ static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv, { struct soc_camera_file *icf = file->private_data; struct soc_camera_device *icd = icf->icd; - int ret; + int ret,i; WARN_ON(priv != file->private_data); mutex_lock(&icf->vb_vidq.vb_lock); + #if 0 if (icf->vb_vidq.bufs[0]) { dev_err(&icd->dev, "S_FMT denied: queue initialised\n"); ret = -EBUSY; goto unlock; } + #else + + /* ddl@rock-chips.com : + Judge queue initialised by Judge icf->vb_vidq.bufs[0] whether is NULL , it is error. */ + + i = 0; + while (icf->vb_vidq.bufs[i]) { + if (icf->vb_vidq.bufs[i]->state != VIDEOBUF_NEEDS_INIT) { + dev_err(&icd->dev, "S_FMT denied: queue initialised\n"); + ret = -EBUSY; + goto unlock; + } + i++; + } + + #endif ret = soc_camera_set_fmt(icf, f); diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 30cc3347ae52..db80147d1ee9 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -788,10 +788,10 @@ static long __video_do_ioctl(struct file *file, case VIDIOC_S_FMT: { struct v4l2_format *f = (struct v4l2_format *)arg; - + /* FIXME: Should be one dump per type */ dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names)); - + switch (f->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: CLEAR_AFTER_FIELD(f, fmt.pix); @@ -1863,7 +1863,7 @@ long video_ioctl2(struct file *file, int is_ext_ctrl; size_t ctrls_size = 0; void __user *user_ptr = NULL; - + #ifdef __OLD_VIDIOC_ cmd = video_fix_command(cmd); #endif -- 2.34.1