Update the camera interface driver from 2.6.21 to 2.6.29 and fix some trivial issues. There are still a few ugly spots, marked with "@@@". Only tested on S3C6410. Signed-off-by: Werner Almesberger --- Index: cam/drivers/media/video/s3c_camera_driver.c =================================================================== --- cam.orig/drivers/media/video/s3c_camera_driver.c 2009-03-04 20:02:45.000000000 +0800 +++ cam/drivers/media/video/s3c_camera_driver.c 2009-03-04 19:52:02.000000000 +0800 @@ -41,12 +41,13 @@ #include #include #include +#include #include #include -#include -#include -#include +#include +#include #include +#include #include "s3c_camif.h" #include "videodev2_s3c.h" @@ -82,7 +83,7 @@ static int s3c_camif_check_global_status(camif_cfg_t *cfg) { int ret = 0; - + if (down_interruptible((struct semaphore *) &cfg->cis->lock)) return -ERESTARTSYS; @@ -420,7 +421,7 @@ sprintf(cap->bus_info, "FIMC AHB Bus"); cap->version = 0; - cap->capabilities = cfg->v->type2; + cap->capabilities = V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; return 0; } @@ -1147,7 +1148,8 @@ { camif_cfg_t *cfg = (camif_cfg_t *) dev_id; -#if defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410) +/* @@@ SMKD ? - WA */ +#if 0 && (defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410)) s3c_gpio_setpin(S3C_GPN15, 1); #endif s3c_camif_clear_irq(irq); @@ -1199,14 +1201,14 @@ int ret = 0; if (cfg->dma_type & CAMIF_CODEC) { - if ((ret = request_irq(cfg->irq, s3c_camif_do_irq_codec, SA_INTERRUPT, cfg->shortname, cfg))) + if ((ret = request_irq(cfg->irq, s3c_camif_do_irq_codec, IRQF_SHARED, cfg->shortname, cfg))) printk(KERN_ERR "Request irq (CAM_C) failed\n"); else printk(KERN_INFO "Request irq %d for codec\n", cfg->irq); } if (cfg->dma_type & CAMIF_PREVIEW) { - if ((ret = request_irq(cfg->irq, s3c_camif_do_irq_preview, SA_INTERRUPT, cfg->shortname, cfg))) + if ((ret = request_irq(cfg->irq, s3c_camif_do_irq_preview, IRQF_SHARED, cfg->shortname, cfg))) printk("Request_irq (CAM_P) failed\n"); else printk(KERN_INFO "Request irq %d for preview\n", cfg->irq); @@ -1218,10 +1220,11 @@ /************************************************************************* * Standard file operations part ************************************************************************/ -int s3c_camif_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg) +long s3c_camif_ioctl(struct file *file, unsigned int cmd, unsigned long _arg) { camif_cfg_t *cfg = file->private_data; int ret = -1; + void *arg = (void *) _arg; /* @@@ - WA */ switch (cmd) { case VIDIOC_QUERYCAP: @@ -1345,17 +1348,21 @@ break; default: /* For v4l compatability */ - v4l_compat_translate_ioctl(inode, file, cmd, arg, s3c_camif_ioctl); + ret = v4l_compat_translate_ioctl(file, cmd, arg, s3c_camif_ioctl); break; } /* End of Switch */ return ret; } -int s3c_camif_open(struct inode *inode, struct file *file) +/* @@@ - WA */ +#define s3c_camif_exclusive_open(inode, file) 0 +#define s3c_camif_exclusive_release(inode, file) + +int s3c_camif_open(struct file *file) { int err; - camif_cfg_t *cfg = s3c_camif_get_fimc_object(MINOR(inode->i_rdev)); + camif_cfg_t *cfg = s3c_camif_get_fimc_object(MINOR(file->f_dentry->d_inode->i_rdev)); if (!cfg->cis) { printk(KERN_ERR "An object for a CIS is missing\n"); @@ -1374,7 +1381,7 @@ up((struct semaphore *) &cfg->cis->lock); } - err = video_exclusive_open(inode, file); + err = s3c_camif_exclusive_open(inode, file); cfg->cis->user++; cfg->status = CAMIF_STOPPED; @@ -1393,9 +1400,9 @@ return 0; } -int s3c_camif_release(struct inode *inode, struct file *file) +int s3c_camif_release(struct file *file) { - camif_cfg_t *cfg = s3c_camif_get_fimc_object(MINOR(inode->i_rdev)); + camif_cfg_t *cfg = s3c_camif_get_fimc_object(MINOR(file->f_dentry->d_inode->i_rdev)); if (cfg->dma_type & CAMIF_PREVIEW) { cfg->cis->status &= ~PWANT2START; @@ -1407,7 +1414,7 @@ s3c_camif_stop_capture(cfg); } - video_exclusive_release(inode, file); + s3c_camif_exclusive_release(inode, file); if (cfg->cis->sensor == NULL) DPRINTK("A CIS sensor for MSDMA has been used\n"); @@ -1546,7 +1553,7 @@ return mask; } -struct file_operations camif_c_fops = { +struct v4l2_file_operations camif_c_fops = { .owner = THIS_MODULE, .open = s3c_camif_open, .release = s3c_camif_release, @@ -1557,7 +1564,7 @@ .poll = s3c_camif_poll, }; -struct file_operations camif_p_fops = { +struct v4l2_file_operations camif_p_fops = { .owner = THIS_MODULE, .open = s3c_camif_open, .release = s3c_camif_release, @@ -1577,9 +1584,11 @@ struct video_device codec_template = { .name = CODEC_DEV_NAME, +#if 0 .type = VID_TYPE_OVERLAY | VID_TYPE_CAPTURE | VID_TYPE_CLIPPING | VID_TYPE_SCALES, .type2 = V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING, .hardware = VID_HARDWARE_SAMSUNG_FIMC3X, +#endif .fops = &camif_c_fops, .release = camif_vdev_release, .minor = CODEC_MINOR, @@ -1587,9 +1596,11 @@ struct video_device preview_template = { .name = PREVIEW_DEV_NAME, +#if 0 .type = VID_TYPE_OVERLAY | VID_TYPE_CAPTURE | VID_TYPE_CLIPPING | VID_TYPE_SCALES, .type2 = V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING, .hardware = VID_HARDWARE_SAMSUNG_FIMC3X, +#endif .fops = &camif_p_fops, .release = camif_vdev_release, .minor = PREVIEW_MINOR, @@ -1647,7 +1658,8 @@ cfg->flip = CAMIF_FLIP_Y; cfg->v = &preview_template; - init_MUTEX((struct semaphore *) &cfg->v->lock); + /* @@@ - WA */ + //init_MUTEX((struct semaphore *) &cfg->v->lock); init_waitqueue_head(&cfg->waitq); cfg->status = CAMIF_STOPPED; @@ -1671,7 +1683,8 @@ cfg->flip = CAMIF_FLIP_X; cfg->v = &codec_template; - init_MUTEX((struct semaphore *) &cfg->v->lock); + /* @@@ - WA */ + //init_MUTEX((struct semaphore *) &cfg->v->lock); init_waitqueue_head(&cfg->waitq); @@ -1764,9 +1777,10 @@ if (IS_ERR(cam_clock)) { printk("Failed to find camera clock source\n"); - ret = PTR_ERR(cam_clock); + return PTR_ERR(cam_clock); } +printk("cam_clock %p\n", cam_clock); clk_enable(cam_clock); /* Print banner */ @@ -1834,7 +1848,7 @@ void s3c_camif_register_sensor(struct i2c_client *ptr) { camif_cfg_t *codec, *preview; - camif_cis_t *cis = (camif_cis_t *) ptr->data; + camif_cis_t *cis = i2c_get_clientdata(ptr); codec = s3c_camif_get_fimc_object(CODEC_MINOR); preview = s3c_camif_get_fimc_object(PREVIEW_MINOR); @@ -1855,7 +1869,7 @@ { camif_cis_t *cis; - cis = (camif_cis_t *) (ptr->data); + cis = i2c_get_clientdata(ptr); cis->init_sensor = 0; } @@ -1868,4 +1882,3 @@ MODULE_AUTHOR("Jinsung Yang "); MODULE_DESCRIPTION("S3C Camera Driver for FIMC Interface"); MODULE_LICENSE("GPL"); - Index: cam/drivers/media/video/s3c_camif.c =================================================================== --- cam.orig/drivers/media/video/s3c_camif.c 2009-03-04 20:02:52.000000000 +0800 +++ cam/drivers/media/video/s3c_camif.c 2009-03-04 19:52:02.000000000 +0800 @@ -30,14 +30,16 @@ #include #include #include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #if defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2450) || defined(CONFIG_CPU_S3C2416) #include @@ -45,6 +47,9 @@ #include "s3c_camif.h" +#define S3C_VIDW00ADD0B0 (S3C24XX_VA_LCD+0xa0) +#define S3C_VIDW01ADD0B0 (S3C24XX_VA_LCD+0xa8) + static unsigned int irq_old_priority; /************************************************************************* @@ -673,7 +678,10 @@ cfg->buffer_size = area; if (cfg->input_channel == MSDMA_FROM_CODEC) { +{ +void __iomem *S3C24XX_VA_LCD = ioremap(S3C64XX_PA_FB, 1024*1024); val = readl(S3C_VIDW00ADD0B0); +} for (i = 0; i < 4; i++) writel(val, cfg->regs + S3C_CICOYSA(i)); @@ -865,7 +873,10 @@ unsigned int val; int i; +{ +void __iomem *S3C24XX_VA_LCD = ioremap(S3C64XX_PA_FB, 1024*1024); val = readl(S3C_VIDW01ADD0B0); +} if (!((cfg->dst_fmt & CAMIF_RGB16) || (cfg->dst_fmt & CAMIF_RGB24))) printk(KERN_ERR "Invalid target format\n"); @@ -1631,20 +1642,20 @@ unsigned int val; if (flag) { - irq_old_priority = readl(S3C_PRIORITY); + irq_old_priority = readl(S3C64XX_PRIORITY); val = irq_old_priority; val &= ~(3 << 7); - writel(val, S3C_PRIORITY); + writel(val, S3C64XX_PRIORITY); /* Arbiter 1, REQ2 first */ val |= (1 << 7); - writel(val, S3C_PRIORITY); + writel(val, S3C64XX_PRIORITY); /* Disable Priority Rotate */ val &= ~(1 << 1); - writel(val, S3C_PRIORITY); + writel(val, S3C64XX_PRIORITY); } else - writel(irq_old_priority, S3C_PRIORITY); + writel(irq_old_priority, S3C64XX_PRIORITY); } /************************************************************************* @@ -1749,21 +1760,21 @@ #elif defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410) static int s3c_camif_set_gpio(void) { - s3c_gpio_cfgpin(S3C_GPF5, S3C_GPF5_CAMIF_YDATA0); - s3c_gpio_cfgpin(S3C_GPF6, S3C_GPF6_CAMIF_YDATA1); - s3c_gpio_cfgpin(S3C_GPF7, S3C_GPF7_CAMIF_YDATA2); - s3c_gpio_cfgpin(S3C_GPF8, S3C_GPF8_CAMIF_YDATA03); - s3c_gpio_cfgpin(S3C_GPF9, S3C_GPF9_CAMIF_YDATA4); - s3c_gpio_cfgpin(S3C_GPF10, S3C_GPF10_CAMIF_YDATA5); - s3c_gpio_cfgpin(S3C_GPF11, S3C_GPF11_CAMIF_YDATA06); - s3c_gpio_cfgpin(S3C_GPF12, S3C_GPF12_CAMIF_YDATA7); - s3c_gpio_cfgpin(S3C_GPF2, S3C_GPF2_CAMIF_CLK); - s3c_gpio_cfgpin(S3C_GPF4, S3C_GPF4_CAMIF_VSYNC); - s3c_gpio_cfgpin(S3C_GPF1, S3C_GPF1_CAMIF_HREF); - s3c_gpio_cfgpin(S3C_GPF0, S3C_GPF0_CAMIF_CLK); - s3c_gpio_cfgpin(S3C_GPF3, S3C_GPF3_CAMIF_RST); + s3c_gpio_cfgpin(S3C64XX_GPF(5), S3C64XX_GPF5_CAMIF_YDATA0); + s3c_gpio_cfgpin(S3C64XX_GPF(6), S3C64XX_GPF6_CAMIF_YDATA1); + s3c_gpio_cfgpin(S3C64XX_GPF(7), S3C64XX_GPF7_CAMIF_YDATA2); + s3c_gpio_cfgpin(S3C64XX_GPF(8), S3C64XX_GPF8_CAMIF_YDATA3); + s3c_gpio_cfgpin(S3C64XX_GPF(9), S3C64XX_GPF9_CAMIF_YDATA4); + s3c_gpio_cfgpin(S3C64XX_GPF(10), S3C64XX_GPF10_CAMIF_YDATA5); + s3c_gpio_cfgpin(S3C64XX_GPF(11), S3C64XX_GPF11_CAMIF_YDATA6); + s3c_gpio_cfgpin(S3C64XX_GPF(12), S3C64XX_GPF12_CAMIF_YDATA7); + s3c_gpio_cfgpin(S3C64XX_GPF(2), S3C64XX_GPF2_CAMIF_PCLK); + s3c_gpio_cfgpin(S3C64XX_GPF(4), S3C64XX_GPF4_CAMIF_VSYNC); + s3c_gpio_cfgpin(S3C64XX_GPF(1), S3C64XX_GPF1_CAMIF_HREF); + s3c_gpio_cfgpin(S3C64XX_GPF(0), S3C64XX_GPF0_CAMIF_CLK); + s3c_gpio_cfgpin(S3C64XX_GPF(3), S3C64XX_GPF3_CAMIF_nRST); - writel(0, S3C_GPFPU); + writel(0, S3C64XX_GPFPUD); return 0; } Index: cam/drivers/media/video/videodev2_s3c.h =================================================================== --- cam.orig/drivers/media/video/videodev2_s3c.h 2009-03-04 20:02:52.000000000 +0800 +++ cam/drivers/media/video/videodev2_s3c.h 2009-03-04 19:52:02.000000000 +0800 @@ -99,7 +99,7 @@ .tuner = 0, .std = V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, .status = 0, - }, + }, { .index = 1, .name = "Memory Input (MSDMA)", @@ -117,9 +117,9 @@ .name = "Pingpong Memory Output", .type = 0, .audioset = 0, - .modulator = 0, + .modulator = 0, .std = 0, - }, + }, { .index = 1, .name = "LCD FIFO Output", @@ -127,7 +127,7 @@ .audioset = 0, .modulator = 0, .std = 0, - } + } }; const struct v4l2_fmtdesc fimc_codec_formats[] = { @@ -168,14 +168,14 @@ .type = V4L2_BUF_TYPE_VIDEO_OVERLAY, .flags = FORMAT_FLAGS_PACKED, .description = "16 bpp RGB, le", - .pixelformat = V4L2_PIX_FMT_RGB565, + .pixelformat = V4L2_PIX_FMT_RGB565, }, { .index = 1, .type = V4L2_BUF_TYPE_VIDEO_OVERLAY, .flags = FORMAT_FLAGS_PACKED, .description = "24 bpp RGB, le", - .pixelformat = V4L2_PIX_FMT_RGB24, + .pixelformat = V4L2_PIX_FMT_RGB24, }, { .index = 2, --