aboutsummaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorWerner Almesberger <werner@openmoko.org>2009-03-05 14:39:43 +0000
committerAndy Green <agreen@octopus.localdomain>2009-03-05 14:39:43 +0000
commit781fe463717f137894fe3d8288342630f7b62d72 (patch)
treef76c89a096e7ee00f89fe827da043f21f6f643ff /drivers/media
parent8cc1cf3520d685d3d5b26b5d489e536c389c9058 (diff)
Update Samsung S3C camera interface driver
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 <werner@openmoko.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/s3c_camera_driver.c61
-rw-r--r--drivers/media/video/s3c_camif.c65
-rw-r--r--drivers/media/video/videodev2_s3c.h12
3 files changed, 81 insertions, 57 deletions
diff --git a/drivers/media/video/s3c_camera_driver.c b/drivers/media/video/s3c_camera_driver.c
index f442ae3bab7..599f9b810bb 100644
--- a/drivers/media/video/s3c_camera_driver.c
+++ b/drivers/media/video/s3c_camera_driver.c
@@ -41,12 +41,13 @@
#include <linux/videodev2.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
+#include <linux/semaphore.h>
#include <asm/io.h>
#include <asm/page.h>
-#include <asm/semaphore.h>
-#include <asm/arch/regs-gpio.h>
-#include <asm/arch/regs-camif.h>
+#include <plat/regs-gpio.h>
+#include <plat/regs-camif.h>
#include <media/v4l2-dev.h>
+#include <media/v4l2-ioctl.h>
#include "s3c_camif.h"
#include "videodev2_s3c.h"
@@ -82,7 +83,7 @@ camif_cfg_t *s3c_camif_get_fimc_object(int nr)
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 @@ static int s3c_camif_v4l2_querycap(camif_cfg_t *cfg, void *arg)
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 @@ static irqreturn_t s3c_camif_do_irq_codec(int irq, void *dev_id)
{
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 @@ static int s3c_camif_request_irq(camif_cfg_t * cfg)
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 @@ static int s3c_camif_request_irq(camif_cfg_t * cfg)
/*************************************************************************
* 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 @@ int s3c_camif_ioctl(struct inode *inode, struct file *file, unsigned int cmd, vo
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 @@ int s3c_camif_open(struct inode *inode, struct file *file)
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 @@ int s3c_camif_open(struct inode *inode, struct file *file)
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 @@ int s3c_camif_release(struct inode *inode, struct file *file)
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 @@ static unsigned int s3c_camif_poll(struct file *file, poll_table *wait)
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 @@ struct file_operations camif_c_fops = {
.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 @@ void camif_vdev_release (struct video_device *vdev) {
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 codec_template = {
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 @@ static int s3c_camif_init_preview(camif_cfg_t * cfg)
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 @@ static int s3c_camif_init_codec(camif_cfg_t * cfg)
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 @@ static int s3c_camif_probe(struct platform_device *pdev)
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_open_sensor(camif_cis_t *cis)
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 @@ void s3c_camif_unregister_sensor(struct i2c_client *ptr)
{
camif_cis_t *cis;
- cis = (camif_cis_t *) (ptr->data);
+ cis = i2c_get_clientdata(ptr);
cis->init_sensor = 0;
}
@@ -1868,4 +1882,3 @@ EXPORT_SYMBOL(s3c_camif_unregister_sensor);
MODULE_AUTHOR("Jinsung Yang <jsgood.yang@samsung.com>");
MODULE_DESCRIPTION("S3C Camera Driver for FIMC Interface");
MODULE_LICENSE("GPL");
-
diff --git a/drivers/media/video/s3c_camif.c b/drivers/media/video/s3c_camif.c
index 5d41ef9c0e2..5626c59c1f8 100644
--- a/drivers/media/video/s3c_camif.c
+++ b/drivers/media/video/s3c_camif.c
@@ -30,14 +30,16 @@
#include <linux/wait.h>
#include <linux/videodev.h>
#include <asm/io.h>
-#include <asm/semaphore.h>
-#include <asm/hardware.h>
+#include <linux/semaphore.h>
+#include <mach/hardware.h>
#include <asm/uaccess.h>
-#include <asm/arch/map.h>
-#include <asm/arch/regs-camif.h>
-#include <asm/arch/regs-gpio.h>
-#include <asm/arch/regs-gpioj.h>
-#include <asm/arch/regs-lcd.h>
+#include <mach/map.h>
+#include <mach/gpio.h>
+#include <mach/irqs.h>
+#include <plat/gpio-cfg.h>
+#include <plat/regs-camif.h>
+#include <plat/regs-gpio.h>
+#include <plat/gpio-bank-f.h>
#if defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2450) || defined(CONFIG_CPU_S3C2416)
#include <asm/arch/regs-irq.h>
@@ -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 @@ static int s3c_camif_output_pp_codec_rgb(camif_cfg_t *cfg)
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 @@ static int s3c_camif_io_duplex_preview(camif_cfg_t *cfg)
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 @@ void s3c_camif_set_priority(int flag)
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 @@ static int s3c_camif_set_gpio(void)
#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);
-
- writel(0, S3C_GPFPU);
+ 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, S3C64XX_GPFPUD);
return 0;
}
diff --git a/drivers/media/video/videodev2_s3c.h b/drivers/media/video/videodev2_s3c.h
index efbcd71830a..7c795434e8e 100644
--- a/drivers/media/video/videodev2_s3c.h
+++ b/drivers/media/video/videodev2_s3c.h
@@ -99,7 +99,7 @@ static struct v4l2_input fimc_inputs[] = {
.tuner = 0,
.std = V4L2_STD_PAL_BG | V4L2_STD_NTSC_M,
.status = 0,
- },
+ },
{
.index = 1,
.name = "Memory Input (MSDMA)",
@@ -117,9 +117,9 @@ static struct v4l2_output fimc_outputs[] = {
.name = "Pingpong Memory Output",
.type = 0,
.audioset = 0,
- .modulator = 0,
+ .modulator = 0,
.std = 0,
- },
+ },
{
.index = 1,
.name = "LCD FIFO Output",
@@ -127,7 +127,7 @@ static struct v4l2_output fimc_outputs[] = {
.audioset = 0,
.modulator = 0,
.std = 0,
- }
+ }
};
const struct v4l2_fmtdesc fimc_codec_formats[] = {
@@ -168,14 +168,14 @@ const struct v4l2_fmtdesc fimc_preview_formats[] = {
.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,