Add camera (CSI) driver for MX1
PATCH v3 1/1 Add camera (CSI) driver for MX1
From: Paulius Zaleckas <[email protected]>
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
---
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
arch/arm/mach-mx1/Makefile +4 -1
@@ -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 +obj-$(CONFIG_MACH_SCB9328) += scb9328.o
arch/arm/mach-mx1/devices.c +1 -1
@@ -44,7 +44,7 @@ static struct resource imx_csi_resources[] = {static u64 imx_csi_dmamask =0xffffffffUL ;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,
arch/arm/mach-mx1/ksym_mx1.c new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Exported ksyms of ARCH_MX1 +* +* Copyright (C) 2008, Darius Augulis <[email protected]> +* +* 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
arch/arm/mach-mx1/mx1_camera_fiq.S new file +35 -0
@@ -0,0 +1,35 @@ +/* + * Copyright (C) 2008 Paulius Zaleckas <[email protected]> + * + * 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, #0x00000001 + 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, #0x00010000 + str r12, [r10] + @ clear SOF flag + mov r12, #0x00010000 + str r12, [r11] + @ return from FIQ + subs pc, lr, #4 +mx1_camera_sof_fiq_end:
arch/arm/plat-mxc/include/mach/memory.h +8 -0
@@ -24,4 +24,12 @@#define PHYS_OFFSET UL(0x80000000)#endif +#if defined(CONFIG_MX1_VIDEO ) +/* +* 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_MX1_VIDEO */ +#endif /* __ASM_ARCH_MXC_MEMORY_H__ */
arch/arm/plat-mxc/include/mach/mx1_camera.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* mx1_camera.h - i.MX1/i.MXL camera driver header file +* +* Copyright (c) 2008, Paulius Zaleckas <[email protected]> +* Copyright (C) 2009, Darius Augulis <[email protected]> +* +* Based on PXA camera.h file: +* Copyright (C) 2003, Intel Corporation +* Copyright (C) 2008, Guennadi Liakhovetski <[email protected]> +* +* 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_DATA_HIGH 1 +#define MX1_CAMERA_PCLK_RISING 2 +#define MX1_CAMERA_VSYNC_HIGH 4 + +extern unsigned char mx1_camera_sof_fiq_start, mx1_camera_sof_fiq_end; + +/** +* struct mx1_camera_pdata - i.MX1/i.MXL camera platform data +* @mclk_10khz: master clock frequency in 10kHz units +* @flags: MX1 camera platform flags +*/ +struct mx1_camera_pdata { +unsigned long mclk_10khz; +unsigned long flags; +}; + +#endif /* __ASM_ARCH_CAMERA_H_ */
drivers/media/video/Kconfig +12 -1
@@ -746,6 +746,18 @@ config SOC_CAMERA_OV772X help This is a ov772x camera driver +config MX1_VIDEO + bool + +config VIDEO_MX1 + tristate "i.MX1/i.MXL CMOS Sensor Interface driver" + depends on VIDEO_DEV && ARCH_MX1 && SOC_CAMERA + select FIQ + select VIDEOBUF_DMA_CONTIG + select MX1_VIDEO + ---help--- + This is a v4l2 driver for the i.MX1/i.MXL CMOS Sensor Interface + config VIDEO_MX3 tristate "i.MX3x Camera Sensor Interface driver" depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA
@@ -904,5 +916,4 @@ config USB_S2255 This driver can be compiled as a module, called s2255drv. endif # V4L_USB_DRIVERS - endif # VIDEO_CAPTURE_DRIVERS
drivers/media/video/Makefile +1 -0
@@ -133,6 +133,7 @@ obj-$(CONFIG_VIDEO_CX18) += cx18/ obj-$(CONFIG_VIDEO_VIVI) += vivi.o obj-$(CONFIG_VIDEO_CX23885) += cx23885/ +obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
drivers/media/video/mx1_camera.c new file +824 -0
824 lines not on this page · raw message
Ok, we're almost there:-) Should be the last iteration.
Quoted 17 lines · Darius Augulis
From: Paulius Zaleckas <[email protected]>
Changelog since V2:
- My signed-off line added
-Makefileupdated
- .init and .exit removed from pdata
- includes sorted
- Video memory limit added
- Pointers infree_buffer()fixed
- Indentation fixed
- Spinlocks added
- PM implementation removed
- Added missedclk_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.
Quoted 4 lines
Signed-off-by Darius Augulis <[email protected]>Signed-off-by Paulius Zaleckas <[email protected]>---
[snip]
arch/arm/plat-mxc/include/mach/memory.h line 27
Quoted 9 lines
arch/arm/plat-mxc/include/mach/memory.h +1
-0@@ -24,4 +24,12 @@#define PHYS_OFFSET UL(0x80000000)#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.
Quoted 14 lines
arch/arm/plat-mxc/include/mach/memory.h +14
-0+/* 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
arch/arm/plat-mxc/include/mach/memory.h
Quoted 10 lines
arch/arm/plat-mxc/include/mach/memory.h +10
-0+ 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
Quoted 43 lines · Guennadi Liakhovetski
Ok, we're almost there:-) Should be the last iteration.
Quoted 18 lines · Darius Augulis
From: Paulius Zaleckas <[email protected]>
Changelog since V2:
- My signed-off line added
-Makefileupdated
- .init and .exit removed from pdata
- includes sorted
- Video memory limit added
- Pointers infree_buffer()fixed
- Indentation fixed
- Spinlocks added
- PM implementation removed
- Added missedclk_put()
- pdata test added
- CSI device renamed
- Platform flags fixed
- "i.MX" replaced by "MX1" in debug printsI 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.
Quoted 4 lines
Signed-off-by Darius Augulis <[email protected]>Signed-off-by Paulius Zaleckas <[email protected]>---
[snip]
Quoted 8 lines
arch/arm/plat-mxc/include/mach/memory.h +0
-0@@ -24,4 +24,12 @@#define PHYS_OFFSET UL(0x80000000)#endif
Quoted 5 lines
arch/arm/plat-mxc/include/mach/memory.h line 28
Quoted 2 lines
arch/arm/plat-mxc/include/mach/memory.h +1
-0+#if defined(CONFIG_MX1_VIDEO )This #ifdef is not needed any more now, the file is not compiled if
CONFIG_MX1_VIDEOis 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.
Quoted 36 lines
Quoted 16 lines
arch/arm/plat-mxc/include/mach/memory.h +14
-0+/* 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 arch/arm/plat-mxc/include/mach/memory.h
Quoted 10 lines
arch/arm/plat-mxc/include/mach/memory.h +10
-0+ 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
Quoted 52 lines · Darius Augulis
Quoted 37 lines · Guennadi Liakhovetski
Ok, we're almost there:-) Should be the last iteration.
Quoted 18 lines · Darius Augulis
From: Paulius Zaleckas <[email protected]>
Changelog since V2:
- My signed-off line added
-Makefileupdated
- .init and .exit removed from pdata
- includes sorted
- Video memory limit added
- Pointers infree_buffer()fixed
- Indentation fixed
- Spinlocks added
- PM implementation removed
- Added missedclk_put()
- pdata test added
- CSI device renamed
- Platform flags fixed
- "i.MX" replaced by "MX1" in debug printsI 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.
Quoted 4 lines
Signed-off-by Darius Augulis <[email protected]>Signed-off-by Paulius Zaleckas <[email protected]>---
[snip]
Quoted 14 lines
arch/arm/plat-mxc/include/mach/memory.h line 27
Quoted 10 lines
arch/arm/plat-mxc/include/mach/memory.h +0
-0@@ -24,4 +24,12 @@#define PHYS_OFFSET UL(0x80000000)#endif +#if defined(CONFIG_MX1_VIDEO)This #ifdef is not needed any more now, the file is not compiled if
CONFIG_MX1_VIDEOis not defined.
Quoted 4 lines
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.
Ouch, sorry, I meant this one:
arch/arm/mach-mx1/ksym_mx1.c new file +14 -0
@@ -0,0 +1,20 @@ +/* +* Exported ksyms of ARCH_MX1 +* +* Copyright (C) 2008, Darius Augulis <[email protected]> +* +* 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 )
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
Quoted 26 lines · Guennadi Liakhovetski
Quoted 24 lines · Darius Augulis
Quoted 23 lines · Guennadi Liakhovetski
Ok, we're almost there:-) Should be the last iteration.
Quoted 18 lines · Darius Augulis
From: Paulius Zaleckas <[email protected]>
Changelog since V2:
- My signed-off line added
-Makefileupdated
- .init and .exit removed from pdata
- includes sorted
- Video memory limit added
- Pointers infree_buffer()fixed
- Indentation fixed
- Spinlocks added
- PM implementation removed
- Added missedclk_put()
- pdata test added
- CSI device renamed
- Platform flags fixed
- "i.MX" replaced by "MX1" in debug prints
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
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.
I'm using Stgit and I can't put anything below --- with "stg edit", because Stgit automatically removes everything what is below ---. I don't want to send patches manually, so I will add changelog in the reply message.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Signed-off-by Darius Augulis <[email protected]>Signed-off-by Paulius Zaleckas <[email protected]>---
[snip]