[PATCH V3] Add camera (CSI) driver for MX1

2009-04-03 Thread Darius Augulis
From: Paulius Zaleckas paulius.zalec...@teltonika.lt

Changelog since V2:
- My signed-off line added
- Makefile updated
- .init and .exit removed from pdata
- includes sorted
- Video memory limit added
- Pointers in free_buffer() fixed
- Indentation fixed
- Spinlocks added
- PM implementation removed
- Added missed clk_put()
- pdata test added
- CSI device renamed
- Platform flags fixed
- i.MX replaced by MX1 in debug prints

Signed-off-by: Darius Augulis augulis.dar...@gmail.com
Signed-off-by: Paulius Zaleckas paulius.zalec...@teltonika.lt
---

 arch/arm/mach-mx1/Makefile  |5 
 arch/arm/mach-mx1/devices.c |2 
 arch/arm/mach-mx1/ksym_mx1.c|   20 +
 arch/arm/mach-mx1/mx1_camera_fiq.S  |   35 +
 arch/arm/plat-mxc/include/mach/memory.h |8 
 arch/arm/plat-mxc/include/mach/mx1_camera.h |   35 +
 drivers/media/video/Kconfig |   13 
 drivers/media/video/Makefile|1 
 drivers/media/video/mx1_camera.c|  824 +++
 9 files changed, 940 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-mx1/ksym_mx1.c
 create mode 100644 arch/arm/mach-mx1/mx1_camera_fiq.S
 create mode 100644 arch/arm/plat-mxc/include/mach/mx1_camera.h
 create mode 100644 drivers/media/video/mx1_camera.c


diff --git a/arch/arm/mach-mx1/Makefile b/arch/arm/mach-mx1/Makefile
index 5e85456..2097021 100644
--- a/arch/arm/mach-mx1/Makefile
+++ b/arch/arm/mach-mx1/Makefile
@@ -6,6 +6,9 @@
 
 obj-y  += generic.o clock.o devices.o
 
+# Support for CMOS sensor interface
+obj-$(CONFIG_MX1_VIDEO)+= ksym_mx1.o mx1_camera_fiq.o
+
 # Power management
 obj-$(CONFIG_PM)   += pm.o
 
@@ -15,4 +18,4 @@ endif
 
 # Specific board support
 obj-$(CONFIG_ARCH_MX1ADS) += mx1ads.o
-obj-$(CONFIG_MACH_SCB9328) += scb9328.o
\ No newline at end of file
+obj-$(CONFIG_MACH_SCB9328) += scb9328.o
diff --git a/arch/arm/mach-mx1/devices.c b/arch/arm/mach-mx1/devices.c
index 97f42d9..76d1ffb 100644
--- a/arch/arm/mach-mx1/devices.c
+++ b/arch/arm/mach-mx1/devices.c
@@ -44,7 +44,7 @@ static struct resource imx_csi_resources[] = {
 static u64 imx_csi_dmamask = 0xUL;
 
 struct platform_device imx_csi_device = {
-   .name   = imx-csi,
+   .name   = mx1-camera,
.id = 0, /* This is used to put cameras on this interface */
.dev= {
.dma_mask = imx_csi_dmamask,
diff --git a/arch/arm/mach-mx1/ksym_mx1.c b/arch/arm/mach-mx1/ksym_mx1.c
new file mode 100644
index 000..9f1116b
--- /dev/null
+++ b/arch/arm/mach-mx1/ksym_mx1.c
@@ -0,0 +1,20 @@
+/*
+ * Exported ksyms of ARCH_MX1
+ *
+ * Copyright (C) 2008, Darius Augulis augulis.dar...@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/platform_device.h
+#include linux/module.h
+
+#if defined(CONFIG_MX1_VIDEO)
+#include mach/mx1_camera.h
+
+/* IMX camera FIQ handler */
+EXPORT_SYMBOL(mx1_camera_sof_fiq_start);
+EXPORT_SYMBOL(mx1_camera_sof_fiq_end);
+#endif
diff --git a/arch/arm/mach-mx1/mx1_camera_fiq.S 
b/arch/arm/mach-mx1/mx1_camera_fiq.S
new file mode 100644
index 000..9c69aa6
--- /dev/null
+++ b/arch/arm/mach-mx1/mx1_camera_fiq.S
@@ -0,0 +1,35 @@
+/*
+ *  Copyright (C) 2008 Paulius Zaleckas paulius.zalec...@teltonika.lt
+ *
+ *  Based on linux/arch/arm/lib/floppydma.S
+ *  Copyright (C) 1995, 1996 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include linux/linkage.h
+#include asm/assembler.h
+
+   .text
+   .global mx1_camera_sof_fiq_end
+   .global mx1_camera_sof_fiq_start
+mx1_camera_sof_fiq_start:
+   @ enable dma
+   ldr r12, [r9]
+   orr r12, r12, #0x0001
+   str r12, [r9]
+   @ unmask DMA interrupt
+   ldr r12, [r8]
+   bic r12, r12, r13
+   str r12, [r8]
+   @ disable SOF interrupt
+   ldr r12, [r10]
+   bic r12, r12, #0x0001
+   str r12, [r10]
+   @ clear SOF flag
+   mov r12, #0x0001
+   str r12, [r11]
+   @ return from FIQ
+   subspc, lr, #4
+mx1_camera_sof_fiq_end:
diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index e0783e6..7113b3e 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -24,4 +24,12 @@
 #define PHYS_OFFSETUL(0x8000)
 #endif
 
+#if defined(CONFIG_MX1_VIDEO)
+/*
+ * Increase size of DMA

Re: [PATCH V3] Add camera (CSI) driver for MX1

2009-04-03 Thread Darius Augulis

Guennadi Liakhovetski wrote:

Ok, we're almost there:-) Should be the last iteration.

On Fri, 3 Apr 2009, Darius Augulis wrote:

  

From: Paulius Zaleckas paulius.zalec...@teltonika.lt

Changelog since V2:
- My signed-off line added
- Makefile updated
- .init and .exit removed from pdata
- includes sorted
- Video memory limit added
- Pointers in free_buffer() fixed
- Indentation fixed
- Spinlocks added
- PM implementation removed
- Added missed clk_put()
- pdata test added
- CSI device renamed
- Platform flags fixed
- i.MX replaced by MX1 in debug prints



I usually put such changelogs below the --- line, so it doesn't appear 
in the git commit message, and here you just put a short description of 
the patch.


  

Signed-off-by: Darius Augulis augulis.dar...@gmail.com
Signed-off-by: Paulius Zaleckas paulius.zalec...@teltonika.lt
---



[snip]

  

diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index e0783e6..7113b3e 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -24,4 +24,12 @@
 #define PHYS_OFFSETUL(0x8000)
 #endif
 
+#if defined(CONFIG_MX1_VIDEO)



This #ifdef is not needed any more now, the file is not compiled if 
CONFIG_MX1_VIDEO is not defined.
  

this header file is included by arch/arm/include/asm/memory.h
By default dma bufer size is only 2Mbytes. If we remove this ifdef, this 
bufer will be increased to re-defined size.

Therefore I suggest to leave this ifdef.

  

+   /* Make choises, based on platform choice */
+   if ((common_flags  SOCAM_VSYNC_ACTIVE_HIGH) 
+   (common_flags  SOCAM_VSYNC_ACTIVE_LOW)) {
+   if (pcdev-pdata-flags  MX1_CAMERA_VSYNC_HIGH)
+   common_flags = ~SOCAM_VSYNC_ACTIVE_LOW;
+   else
+   common_flags = ~SOCAM_VSYNC_ACTIVE_HIGH;
+   }
+
+   if ((common_flags  SOCAM_PCLK_SAMPLE_RISING) 
+   (common_flags  SOCAM_PCLK_SAMPLE_FALLING)) {
+   if (pcdev-pdata-flags  MX1_CAMERA_PCLK_RISING)
+   common_flags = ~SOCAM_PCLK_SAMPLE_FALLING;
+   else
+   common_flags = ~SOCAM_PCLK_SAMPLE_RISING;
+   }
+
+   if ((common_flags  SOCAM_DATA_ACTIVE_HIGH) 
+   (common_flags  SOCAM_DATA_ACTIVE_LOW)) {
+   if (pcdev-pdata-flags  MX1_CAMERA_DATA_HIGH)
+   common_flags = ~SOCAM_DATA_ACTIVE_LOW;
+   else
+   common_flags = ~SOCAM_DATA_ACTIVE_HIGH;
+   }



In all three clauses above pdata can be NULL.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer

  


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V4] Add camera (CSI) driver for MX1

2009-04-03 Thread Darius Augulis

Changelog since V3:
- DMA buffer size decreased to 4Mbytes
- Added pdata test in set_bus_param()

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V4] Add camera (CSI) driver for MX1

2009-04-03 Thread Darius Augulis

Sascha Hauer wrote:

On Fri, Apr 03, 2009 at 02:15:34PM +0200, Guennadi Liakhovetski wrote:

On Fri, 3 Apr 2009, Darius Augulis wrote:


From: Paulius Zaleckas paulius.zalec...@teltonika.lt

Signed-off-by: Darius Augulis augulis.dar...@gmail.com
Signed-off-by: Paulius Zaleckas paulius.zalec...@teltonika.lt
Ok, I'll just swap these two Sob's to reflect the processing chain, add a 
description like


Add support for CMOS Sensor Interface on i.MX1 and i.MXL SoCs.

and fix a couple of trivial conflicts, which probably appear, because you 
based your patches on an MXC tree, and not on current linux-next. 
Wondering, if it still will work then... At least it compiles. BTW, should 
it really also work with IMX? Then you might want to change this


depends on VIDEO_DEV  ARCH_MX1  SOC_CAMERA

to

depends on VIDEO_DEV  (ARCH_MX1 || ARCH_IMX)  SOC_CAMERA


This shouldn't be necessary. ARCH_IMX does not have the platform part to
make use of this driver and will never get it.

but you can do this later, maybe, when you actually get a chance to test 
it on IMX (if you haven't done so yet).


Sascha, we need your ack for the ARM part.


I'm OK with this driver: I have never worked with FIQs though so I can't
say much to it.


At least I can confirm it worked well with 2.6.28.5 kernel version.



Sascha



--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V4] Add camera (CSI) driver for MX1

2009-04-03 Thread Darius Augulis

Guennadi Liakhovetski wrote:

On Fri, 3 Apr 2009, Sascha Hauer wrote:

  

On Fri, Apr 03, 2009 at 02:15:34PM +0200, Guennadi Liakhovetski wrote:

Wondering, if it still will work then... At least it compiles. BTW, should 
it really also work with IMX? Then you might want to change this


depends on VIDEO_DEV  ARCH_MX1  SOC_CAMERA

to

depends on VIDEO_DEV  (ARCH_MX1 || ARCH_IMX)  SOC_CAMERA
  

This shouldn't be necessary. ARCH_IMX does not have the platform part to
make use of this driver and will never get it.



Confused... Then why the whole that IMX/MX1 in the driver? And why will 
it never get it - are they compatible or not? Or just there's no demand / 
chips are EOLed or something...


  


in Linux kernel imx is the old name of mx1.
mx1 contains of two processors: i.MX1 and i.MXL.

but you can do this later, maybe, when you actually get a chance to test 
it on IMX (if you haven't done so yet).


Sascha, we need your ack for the ARM part.
  

I'm OK with this driver: I have never worked with FIQs though so I can't
say much to it.



Ok, I take it as an Acked-by then:-)

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer

  


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: soc_camera_open() not called

2009-04-02 Thread Darius Augulis

Guennadi Liakhovetski wrote:

On Wed, 1 Apr 2009, Robert Jarzmik wrote:


Darius Augulis augulis.dar...@gmail.com writes:


Darius Augulis wrote:


Hi,

I'm trying to launch mx1_camera based on new v4l and soc-camera tree.
After loading mx1_camera module, I see that .add callback is not called.
In debug log I see that soc_camera_open() is not called too.
What should call this function? Is this my driver problem?
p.s. loading sensor driver does not change situation.
  

Are you by any chance using last 2.6.29 kernel ?
If so, would [1] be the answer to your question ?

[1] http://lkml.org/lkml/2009/3/24/625

thanks. it means we should expect soc-camera fix for this?
I'm using 2.6.29-git8, but seems it's not fixed yet.

No, I don't think so.


You're right.


The last time I checked there had to be an amendement to the patch which
introduced the driver core regression, as it touches other areas as well
(sound/soc and mtd from memory).

I think Guennadi can confirm this, as he's the one who raised the issue in the
first place.


If Darius had followed the thread you referred to he would have come down 
to this message


http://lkml.org/lkml/2009/3/26/202

which provides a reply as to what should be fixed, and yes, Ming Lei has 
already provided a patch to fix this, it should hit mainstream... some 
time before -rc1.


could you please send me this patch or show where is it available?



Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mt9t031: use platform power hook

2009-04-02 Thread Darius Augulis

Guennadi Liakhovetski wrote:

Use platform power hook to turn the camera on and off.

Signed-off-by: Guennadi Liakhovetski l...@denx.de
---
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c
index 23f9ce9..2b0927b 100644
--- a/drivers/media/video/mt9t031.c
+++ b/drivers/media/video/mt9t031.c
@@ -141,8 +141,19 @@ static int get_shutter(struct soc_camera_device *icd, u32 
*data)
 
 static int mt9t031_init(struct soc_camera_device *icd)

 {
+   struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
+   struct soc_camera_link *icl = mt9t031-client-dev.platform_data;
int ret;
 
+	if (icl-power) {

+   ret = icl-power(mt9t031-client-dev, 1);
+   if (ret  0) {
+   dev_err(icd-vdev-parent,
+   Platform failed to power-on the camera.\n);
+   return ret;
+   }
+   }


probably you would have to call icl-reset there too?
I guess this camera sensor does have a reset pin?



+
/* Disable chip output, synchronous option update */
ret = reg_write(icd, MT9T031_RESET, 1);
if (ret = 0)
@@ -150,13 +161,23 @@ static int mt9t031_init(struct soc_camera_device *icd)
if (ret = 0)
ret = reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
 
+	if (ret  0  icl-power)

+   icl-power(mt9t031-client-dev, 0);
+
return ret = 0 ? 0 : -EIO;
 }
 
 static int mt9t031_release(struct soc_camera_device *icd)

 {
+   struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
+   struct soc_camera_link *icl = mt9t031-client-dev.platform_data;
+
/* Disable the chip */
reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
+
+   if (icl-power)
+   icl-power(mt9t031-client-dev, 0);
+
return 0;
 }
 
--

To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH V2] Add camera (CSI) driver for MX1

2009-04-02 Thread Darius Augulis



+ * struct mx1_camera_pdata - i.MX1/i.MXL camera platform data
+ * @init:  Init board resources
+ * @exit:  Release board resources
+ * @mclk_10khz:master clock frequency in 10kHz units
+ * @flags: MX1 camera platform flags
+ */
+struct mx1_camera_pdata {
+   int (*init)(struct device *);
+   int (*exit)(struct device *);



I thought the agreement was to avoid these .init() and .exit() hooks in 
new code...
  


Should I config board statically during system start-up?



+static void mx1_videobuf_queue(struct videobuf_queue *vq,
+   struct videobuf_buffer *vb)
+{
+   struct soc_camera_device *icd = vq-priv_data;
+   struct soc_camera_host *ici = to_soc_camera_host(icd-dev.parent);
+   struct mx1_camera_dev *pcdev = ici-priv;
+   struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb);
+
+   dev_dbg(icd-dev, %s (vb=0x%p) 0x%08lx %d\n, __func__,
+   vb, vb-baddr, vb-bsize);
+
+   list_add_tail(vb-queue, pcdev-capture);



No, you had a spinlock here and in DMA ISR in the previous version, and it 
was correct. Without that lock the above list_add races with 
list_del_init() in mx1_camera_wakeup().
  


what can save and help for the spinlock on single-core system? mx3 there 
does not have spinlock.


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


soc_camera_open() not called

2009-04-01 Thread Darius Augulis

Hi,

I'm trying to launch mx1_camera based on new v4l and soc-camera tree.
After loading mx1_camera module, I see that .add callback is not called.
In debug log I see that soc_camera_open() is not called too.
What should call this function? Is this my driver problem?
p.s. loading sensor driver does not change situation.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: soc_camera_open() not called

2009-04-01 Thread Darius Augulis

Darius Augulis wrote:

Hi,

I'm trying to launch mx1_camera based on new v4l and soc-camera tree.
After loading mx1_camera module, I see that .add callback is not called.
In debug log I see that soc_camera_open() is not called too.
What should call this function? Is this my driver problem?
p.s. loading sensor driver does not change situation.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



actually I thought about soc_camera_probe(), not soc_camera_open().
But the problem still the same. video_probe in my driver is not called.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: soc_camera_open() not called

2009-04-01 Thread Darius Augulis

Robert Jarzmik wrote:

Darius Augulis augulis.dar...@gmail.com writes:

  

Darius Augulis wrote:


Hi,

I'm trying to launch mx1_camera based on new v4l and soc-camera tree.
After loading mx1_camera module, I see that .add callback is not called.
In debug log I see that soc_camera_open() is not called too.
What should call this function? Is this my driver problem?
p.s. loading sensor driver does not change situation.
  


Are you by any chance using last 2.6.29 kernel ?
If so, would [1] be the answer to your question ?
  


thanks. it means we should expect soc-camera fix for this?
I'm using 2.6.29-git8, but seems it's not fixed yet.



Cheers

--
Robert

[1] http://lkml.org/lkml/2009/3/24/625

  


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH V2] Add camera (CSI) driver for MX1

2009-03-31 Thread Darius Augulis

Changelog since V1:

- Licensing fixed (GPL V2)
- Includes sorted
- Code indentation fixed
- Fixed errors listed by checkpatch
- Most of Guennadi comments fixed
- Spinlocks removed
- .power and .reset removed from pdata
- Redundant test if (!(common_flags  SOCAM_DATAWIDTH_8)) removed
- Setup bus parameters in imx_camera_set_bus_param() based on pdata choice
- .set_crop method added
- Driver based on newest v4l-dvb tree
- Suspend and resume moved to soc_camera_host_ops
- Driver dependencies fixed
- Driver renamed to mx1_camera
- My signed-off line added


Notes:

- Buffer count unfixed (if (!*count) *count = 32;). Don't know how to fix 
correctly.
- Suspend and resume are almost redundant. Maybe remove them at all?
- Several WARN_ON warning still here, not sure about removing them.


Waiting for further comments and recommendations.



Darius Augulis wrote:

From: Paulius Zaleckas paulius.zalec...@teltonika.lt

Signed-off-by: Paulius Zaleckas paulius.zalec...@teltonika.lt
---

 arch/arm/mach-mx1/Makefile  |7 
 arch/arm/mach-mx1/ksym_mx1.c|   20 +

 arch/arm/mach-mx1/mx1_camera_fiq.S  |   35 +
 arch/arm/plat-mxc/include/mach/memory.h |8 
 arch/arm/plat-mxc/include/mach/mx1_camera.h |   39 +
 drivers/media/video/Kconfig |9 
 drivers/media/video/Makefile|1 
 drivers/media/video/mx1_camera.c|  838 +++

 8 files changed, 955 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-mx1/ksym_mx1.c
 create mode 100644 arch/arm/mach-mx1/mx1_camera_fiq.S
 create mode 100644 arch/arm/plat-mxc/include/mach/mx1_camera.h
 create mode 100644 drivers/media/video/mx1_camera.c


diff --git a/arch/arm/mach-mx1/Makefile b/arch/arm/mach-mx1/Makefile
index b969719..4fbdbbd 100644
--- a/arch/arm/mach-mx1/Makefile
+++ b/arch/arm/mach-mx1/Makefile
@@ -4,7 +4,12 @@
 
 # Object file lists.
 
-obj-y			+= generic.o clock.o devices.o

+obj-y  += generic.o clock.o devices.o ksym_mx1.o
+
+# Support for CMOS sensor interface
+ifdef CONFIG_VIDEO_MX1
+obj-y  += mx1_camera_fiq.o
+endif
 
 # Specific board support

 obj-$(CONFIG_ARCH_MX1ADS) += mx1ads.o
diff --git a/arch/arm/mach-mx1/ksym_mx1.c b/arch/arm/mach-mx1/ksym_mx1.c
new file mode 100644
index 000..d771b2c
--- /dev/null
+++ b/arch/arm/mach-mx1/ksym_mx1.c
@@ -0,0 +1,20 @@
+/*
+ * Exported ksyms of ARCH_MX1
+ *
+ * Copyright (C) 2008, Darius Augulis augulis.dar...@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/platform_device.h
+#include linux/module.h
+
+#if defined(CONFIG_VIDEO_MX1) || defined(CONFIG_VIDEO_MX1_MODULE)
+#include mach/mx1_camera.h
+
+/* IMX camera FIQ handler */
+EXPORT_SYMBOL(mx1_camera_sof_fiq_start);
+EXPORT_SYMBOL(mx1_camera_sof_fiq_end);
+#endif
diff --git a/arch/arm/mach-mx1/mx1_camera_fiq.S 
b/arch/arm/mach-mx1/mx1_camera_fiq.S
new file mode 100644
index 000..9c69aa6
--- /dev/null
+++ b/arch/arm/mach-mx1/mx1_camera_fiq.S
@@ -0,0 +1,35 @@
+/*
+ *  Copyright (C) 2008 Paulius Zaleckas paulius.zalec...@teltonika.lt
+ *
+ *  Based on linux/arch/arm/lib/floppydma.S
+ *  Copyright (C) 1995, 1996 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include linux/linkage.h
+#include asm/assembler.h
+
+   .text
+   .global mx1_camera_sof_fiq_end
+   .global mx1_camera_sof_fiq_start
+mx1_camera_sof_fiq_start:
+   @ enable dma
+   ldr r12, [r9]
+   orr r12, r12, #0x0001
+   str r12, [r9]
+   @ unmask DMA interrupt
+   ldr r12, [r8]
+   bic r12, r12, r13
+   str r12, [r8]
+   @ disable SOF interrupt
+   ldr r12, [r10]
+   bic r12, r12, #0x0001
+   str r12, [r10]
+   @ clear SOF flag
+   mov r12, #0x0001
+   str r12, [r11]
+   @ return from FIQ
+   subspc, lr, #4
+mx1_camera_sof_fiq_end:
diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index 0b80839..c6f2170 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -19,4 +19,12 @@
 #define PHYS_OFFSETUL(0x8000)
 #endif
 
+#if defined(CONFIG_VIDEO_MX1) || defined(CONFIG_VIDEO_MX1_MODULE)

+/*
+ * Increase size of DMA-consistent memory region.
+ * This is required for i.MX camera driver to capture at least four VGA frames.
+ */
+#define CONSISTENT_DMA_SIZE SZ_8M
+#endif /* CONFIG_VIDEO_MX1 */
+
 #endif /* __ASM_ARCH_MXC_MEMORY_H__

suspend and resume in MX3_CAMERA are missing

2009-03-31 Thread Darius Augulis

subj.

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH V2] Add camera (CSI) driver for MX1

2009-03-30 Thread Darius Augulis
From: Paulius Zaleckas paulius.zalec...@teltonika.lt

Signed-off-by: Paulius Zaleckas paulius.zalec...@teltonika.lt
---

 arch/arm/mach-mx1/Makefile  |7 
 arch/arm/mach-mx1/ksym_mx1.c|   20 +
 arch/arm/mach-mx1/mx1_camera_fiq.S  |   35 +
 arch/arm/plat-mxc/include/mach/memory.h |8 
 arch/arm/plat-mxc/include/mach/mx1_camera.h |   39 +
 drivers/media/video/Kconfig |9 
 drivers/media/video/Makefile|1 
 drivers/media/video/mx1_camera.c|  838 +++
 8 files changed, 955 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-mx1/ksym_mx1.c
 create mode 100644 arch/arm/mach-mx1/mx1_camera_fiq.S
 create mode 100644 arch/arm/plat-mxc/include/mach/mx1_camera.h
 create mode 100644 drivers/media/video/mx1_camera.c


diff --git a/arch/arm/mach-mx1/Makefile b/arch/arm/mach-mx1/Makefile
index b969719..4fbdbbd 100644
--- a/arch/arm/mach-mx1/Makefile
+++ b/arch/arm/mach-mx1/Makefile
@@ -4,7 +4,12 @@
 
 # Object file lists.
 
-obj-y  += generic.o clock.o devices.o
+obj-y  += generic.o clock.o devices.o ksym_mx1.o
+
+# Support for CMOS sensor interface
+ifdef CONFIG_VIDEO_MX1
+obj-y  += mx1_camera_fiq.o
+endif
 
 # Specific board support
 obj-$(CONFIG_ARCH_MX1ADS) += mx1ads.o
diff --git a/arch/arm/mach-mx1/ksym_mx1.c b/arch/arm/mach-mx1/ksym_mx1.c
new file mode 100644
index 000..d771b2c
--- /dev/null
+++ b/arch/arm/mach-mx1/ksym_mx1.c
@@ -0,0 +1,20 @@
+/*
+ * Exported ksyms of ARCH_MX1
+ *
+ * Copyright (C) 2008, Darius Augulis augulis.dar...@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/platform_device.h
+#include linux/module.h
+
+#if defined(CONFIG_VIDEO_MX1) || defined(CONFIG_VIDEO_MX1_MODULE)
+#include mach/mx1_camera.h
+
+/* IMX camera FIQ handler */
+EXPORT_SYMBOL(mx1_camera_sof_fiq_start);
+EXPORT_SYMBOL(mx1_camera_sof_fiq_end);
+#endif
diff --git a/arch/arm/mach-mx1/mx1_camera_fiq.S 
b/arch/arm/mach-mx1/mx1_camera_fiq.S
new file mode 100644
index 000..9c69aa6
--- /dev/null
+++ b/arch/arm/mach-mx1/mx1_camera_fiq.S
@@ -0,0 +1,35 @@
+/*
+ *  Copyright (C) 2008 Paulius Zaleckas paulius.zalec...@teltonika.lt
+ *
+ *  Based on linux/arch/arm/lib/floppydma.S
+ *  Copyright (C) 1995, 1996 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include linux/linkage.h
+#include asm/assembler.h
+
+   .text
+   .global mx1_camera_sof_fiq_end
+   .global mx1_camera_sof_fiq_start
+mx1_camera_sof_fiq_start:
+   @ enable dma
+   ldr r12, [r9]
+   orr r12, r12, #0x0001
+   str r12, [r9]
+   @ unmask DMA interrupt
+   ldr r12, [r8]
+   bic r12, r12, r13
+   str r12, [r8]
+   @ disable SOF interrupt
+   ldr r12, [r10]
+   bic r12, r12, #0x0001
+   str r12, [r10]
+   @ clear SOF flag
+   mov r12, #0x0001
+   str r12, [r11]
+   @ return from FIQ
+   subspc, lr, #4
+mx1_camera_sof_fiq_end:
diff --git a/arch/arm/plat-mxc/include/mach/memory.h 
b/arch/arm/plat-mxc/include/mach/memory.h
index 0b80839..c6f2170 100644
--- a/arch/arm/plat-mxc/include/mach/memory.h
+++ b/arch/arm/plat-mxc/include/mach/memory.h
@@ -19,4 +19,12 @@
 #define PHYS_OFFSETUL(0x8000)
 #endif
 
+#if defined(CONFIG_VIDEO_MX1) || defined(CONFIG_VIDEO_MX1_MODULE)
+/*
+ * Increase size of DMA-consistent memory region.
+ * This is required for i.MX camera driver to capture at least four VGA frames.
+ */
+#define CONSISTENT_DMA_SIZE SZ_8M
+#endif /* CONFIG_VIDEO_MX1 */
+
 #endif /* __ASM_ARCH_MXC_MEMORY_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx1_camera.h 
b/arch/arm/plat-mxc/include/mach/mx1_camera.h
new file mode 100644
index 000..1bf03e8
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/mx1_camera.h
@@ -0,0 +1,39 @@
+/*
+ * mx1_camera.h - i.MX1/i.MXL camera driver header file
+ *
+ * Copyright (c) 2008, Paulius Zaleckas paulius.zalec...@teltonika.lt
+ * Copyright (C) 2009, Darius Augulis augulis.dar...@gmail.com
+ *
+ * Based on PXA camera.h file:
+ * Copyright (C) 2003, Intel Corporation
+ * Copyright (C) 2008, Guennadi Liakhovetski ker...@pengutronix.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARCH_CAMERA_H_
+#define __ASM_ARCH_CAMERA_H_
+
+#define MX1_CAMERA_DP

Re: [PATCH 1/5] CSI camera interface driver for MX1

2009-03-27 Thread Darius Augulis

Mauro Carvalho Chehab wrote:

Hi Darius,

Please always base your patches against the last v4l-dvb tree or linux-next.
This is specially important those days, where v4l core is suffering several
changes.


Hi,

could you please advice which v4l-dvb Git repository I should pull from?
Because git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/devel.git does 
not have any new stuff now.
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-next.git is marked as 
unstable for testing purposes.
What is better to base my patches on?

Darius.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/5] CSI camera interface driver for MX1

2009-03-27 Thread Darius Augulis

Mauro Carvalho Chehab wrote:
 On Fri, 27 Mar 2009 11:37:23 +0200
 Darius Augulis augulis.dar...@gmail.com wrote:

 Mauro Carvalho Chehab wrote:
 Hi Darius,

 Please always base your patches against the last v4l-dvb tree or linux-next.
 This is specially important those days, where v4l core is suffering several
 changes.

 Btw, you shouldn't be c/c a list that requires subscription. Every time I send
 something, I got such errors:

I sent it to ARM Linux ML, because it has lot of ARM stuff and there are people 
who maintain ARM/MXC.
You probably could remove some CC from your reply message?
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/5] CSI camera interface driver for MX1

2009-03-27 Thread Darius Augulis

Hi Guennadi,


+/*
+ *  Videobuf operations
+ */
+static int imx_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
+ unsigned int *size)
+{
+   struct soc_camera_device *icd = vq-priv_data;
+
+   *size = icd-width * icd-height *
+   ((icd-current_fmt-depth + 7)  3);
+
+   if (0 == *count)
+   *count = 32;


Doesn't look like a good idea to me. You don't restrict picture sizes in 
your try_fmt / set_fmt and here you default to 32 buffers...


I'm not sure about this one. Should I leave this unchanged?



+   struct imx_camera_dev *pcdev = ici-priv;
+   struct imx_buffer *buf = container_of(vb, struct imx_buffer, vb);
+   unsigned long flags;
+
+   dev_dbg(icd-dev, %s (vb=0x%p) 0x%08lx %d\n, __func__,
+   vb, vb-baddr, vb-bsize);
+   spin_lock_irqsave(pcdev-lock, flags);


You use an FIQ for SoF, and spin_lock_irqsave() to protect. Don't they 
only disable IRQs and not FIQs? But it seems your FIQ cannot cause any 
trouble, so, it should be fine. Do you really need an FIQ?


yes, FIQ is necessary. Because IRQ is to slow. When SoF is detected, DMA must 
be activated immediately, but not to early.
Whe tried to use IRQ, and many starts of frames were missed.
May I remove these spin_lock_irqsave's?




+
+   list_add_tail(vb-queue, pcdev-capture);
+
+   vb-state = VIDEOBUF_ACTIVE;
+
+   if (!pcdev-active) {
+   pcdev-active = buf;
+
+   /* setup sg list for future DMA */
+   if (!imx_camera_setup_dma(pcdev)) {
+   unsigned int temp;
+   /* enable SOF irq */
+   temp = __raw_readl(pcdev-base + CSICR1) |
+ CSICR1_SOF_INTEN;


Hm, looks like an error in the datasheet:

SOF_INTEN   Start Of Frame Interrupt--SOF interrupt status bit; set Read:
Bit 16  when interrupt occurs.  0 = No 
interrupt
1 = SOF 
interrupt occurred
Write:
0 = No 
action
1 = 
Clears bit

This is not a status bit, but a control SoF interrupt enable bit, right?


Yes, probably it's only 'small' error in datasheet :)



+static void imx_camera_dma_irq(int channel, void *data)
+{
+   struct imx_camera_dev *pcdev = data;
+   struct imx_buffer *buf;
+   unsigned long flags;
+   struct videobuf_buffer *vb;
+
+   spin_lock_irqsave(pcdev-lock, flags);
+
+   imx_dma_disable(channel);
+
+   if (unlikely(!pcdev-active)) {
+   dev_err(pcdev-dev, DMA End IRQ with no active buffer\n);
+   goto out;
+   }
+
+   vb = pcdev-active-vb;
+   buf = container_of(vb, struct imx_buffer, vb);
+   WARN_ON(buf-inwork || list_empty(vb-queue));
+   dev_dbg(pcdev-dev, %s (vb=0x%p) 0x%08lx %d\n, __func__,
+   vb, vb-baddr, vb-bsize);
+
+   imx_camera_wakeup(pcdev, vb, buf);


AFAIU, your flow looks as follows:

1. configure DMA, enable Start of Frame FIQ
2. SoF FIQ enable DMA, DMA IRQ, disable SoF FIQ
3. DMA done IRQ disable DMA, report completed buffer, goto 1


is it ok?



+static int imx_camera_set_bus_param(struct soc_camera_device *icd, __u32 
pixfmt)
+{
+   struct soc_camera_host *ici =
+   to_soc_camera_host(icd-dev.parent);
+   struct imx_camera_dev *pcdev = ici-priv;
+   unsigned long camera_flags, common_flags;
+   unsigned int csicr1;
+   int ret;
+
+   camera_flags = icd-ops-query_bus_param(icd);
+
+   common_flags = soc_camera_bus_param_compatible(camera_flags,
+  CSI_BUS_FLAGS);
+   if (!common_flags)
+   return -EINVAL;
+
+   if (!(common_flags  SOCAM_DATAWIDTH_8)) {


I don't understand this. In your CSI_BUS_FLAGS you only support 8 bits. If 
the camera doesn't support it, you get a 0 back in common_flags and return 
-EINVAL above. So, this test seems redundant.


yes, this is uneeded. I removed this already.



+static struct soc_camera_host_ops imx_soc_camera_host_ops = {
+   .owner  = THIS_MODULE,
+   .add= imx_camera_add_device,
+   .remove = imx_camera_remove_device,
+   .set_fmt= imx_camera_set_fmt,
+   .try_fmt= imx_camera_try_fmt,
+   .init_videobuf  = imx_camera_init_videobuf,
+   .reqbufs= imx_camera_reqbufs,
+   .poll   = imx_camera_poll,
+   .querycap   = imx_camera_querycap,
+   .set_bus_param  = imx_camera_set_bus_param,


You are not implementing this against a current v4l tree. Please, rebase 
onto, e.g., linux-next. You will have to at least implement a 

how to disable mail sending in this ML?

2009-03-25 Thread Darius Augulis

Hi All,

subj.
Want to still subscribed, but don't need all these posts in my mailbox.
How to disable?

Thanks.


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 5/9] New drivers for MXC: add CSI support for MX1

2009-03-25 Thread Darius Augulis
+ *
+ * Based on PXA camera.h file:
+ * Copyright (C) 2003, Intel Corporation
+ * Copyright (C) 2008, Guennadi Liakhovetski ker...@pengutronix.de
+ *
+ * This file is released under the GPLv2
+ */
+
+#ifndef __ASM_ARCH_CAMERA_H_
+#define __ASM_ARCH_CAMERA_H_
+
+extern unsigned char imx_camera_sof_fiq_start, imx_camera_sof_fiq_end;
+
+struct imxcamera_platform_data {
+   int (*init)(struct device *);
+   int (*exit)(struct device *);
+   int (*power)(struct device *, int);
+   int (*reset)(struct device *, int);
+
+   unsigned long mclk_10khz;
+};
+
+#endif /* __ASM_ARCH_CAMERA_H_ */
Index: linux-2.6.29/arch/arm/mach-mx1/imx_camera_fiq.S
===
--- /dev/null
+++ linux-2.6.29/arch/arm/mach-mx1/imx_camera_fiq.S
@@ -0,0 +1,35 @@
+/*
+ *  Copyright (C) 2008 Paulius Zaleckas paulius.zalec...@teltonika.lt
+ *
+ *  Based on linux/arch/arm/lib/floppydma.S
+ *  Copyright (C) 1995, 1996 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include linux/linkage.h
+#include asm/assembler.h
+
+   .text
+   .global imx_camera_sof_fiq_end
+   .global imx_camera_sof_fiq_start
+imx_camera_sof_fiq_start:
+   @ enable dma
+   ldr r12, [r9]
+   orr r12, r12, #0x0001
+   str r12, [r9]
+   @ unmask DMA interrupt
+   ldr r12, [r8]
+   bic r12, r12, r13
+   str r12, [r8]
+   @ disable SOF interrupt
+   ldr r12, [r10]
+   bic r12, r12, #0x0001
+   str r12, [r10]
+   @ clear SOF flag
+   mov r12, #0x0001
+   str r12, [r11]
+   @ return from FIQ
+   subspc, lr, #4
+imx_camera_sof_fiq_end:
Index: linux-2.6.29/arch/arm/mach-mx1/ksym_mx1.c
===
--- /dev/null
+++ linux-2.6.29/arch/arm/mach-mx1/ksym_mx1.c
@@ -0,0 +1,23 @@
+/*
+ * Exported ksyms of ARCH_MX1
+ *
+ * Copyright (C) 2008, Darius Augulis augulis.dar...@gmail.com
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include linux/platform_device.h
+#include linux/module.h
+
+
+#if defined(CONFIG_VIDEO_IMX) || defined(CONFIG_VIDEO_IMX_MODULE)
+#include mach/camera.h
+
+/* IMX camera FIQ handler */
+EXPORT_SYMBOL(imx_camera_sof_fiq_start);
+EXPORT_SYMBOL(imx_camera_sof_fiq_end);
+#endif


Re: [PATCH V2 5/9] New drivers for MXC: add CSI support for MX1

2009-03-25 Thread Darius Augulis

Changes since prev. version:
- Rebased on 2.6.29
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html