RE: [PATCH v3] [media] at91: add Atmel Image Sensor Interface (ISI) support
Hi, Guennadi On Friday, June 03, 2011, Guennadi Liakhovetski wrote > On Fri, 3 Jun 2011, Josh Wu wrote: >> This patch is to enable Atmel Image Sensor Interface (ISI) driver support. >> - Using soc-camera framework with videobuf2 dma-contig allocator >> - Supporting video streaming of YUV packed format >> - Tested on AT91SAM9M10G45-EK with OV2640 >> >> Signed-off-by: Josh Wu >> --- >> base on branch staging/for_v3.0 >> Modified in V3: >> refined the interrupt handling code. >> added a list to manage the allocated descriptors. >> removed redundant code in isi_camera_set_bus_param(). >> return error when platform data is not provided. >> >> drivers/media/video/Kconfig |8 + >> drivers/media/video/Makefile|1 + >> drivers/media/video/atmel-isi.c | 1074 >> +++ >> include/media/atmel-isi.h | 119 + >> 4 files changed, 1202 insertions(+), 0 deletions(-) >> create mode 100644 drivers/media/video/atmel-isi.c >> create mode 100644 include/media/atmel-isi.h >> >> diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig >> index bb53de7..93d1098 100644 >> --- a/drivers/media/video/Kconfig >> +++ b/drivers/media/video/Kconfig >> @@ -952,6 +952,14 @@ config VIDEO_SAMSUNG_S5P_FIMC >>To compile this driver as a module, choose M here: the >>module will be called s5p-fimc. >> >> +config VIDEO_ATMEL_ISI >> +tristate "ATMEL Image Sensor Interface (ISI) support" >> +depends on VIDEO_DEV && SOC_CAMERA && ARCH_AT91 >> +select VIDEOBUF2_DMA_CONTIG >> +---help--- >> + This module makes the ATMEL Image Sensor Interface available >> + as a v4l2 device. >> + >> config VIDEO_S5P_MIPI_CSIS >> tristate "Samsung S5P and EXYNOS4 MIPI CSI receiver driver" >> depends on VIDEO_V4L2 && PM_RUNTIME && PLAT_S5P && VIDEO_V4L2_SUBDEV_API >> diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile >> index f0fecd6..d9833f4 100644 >> --- a/drivers/media/video/Makefile >> +++ b/drivers/media/video/Makefile >> @@ -166,6 +166,7 @@ obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o >> obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o >> obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o >> obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o >> +obj-$(CONFIG_VIDEO_ATMEL_ISI) += atmel-isi.o >> >> obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC)+= s5p-fimc/ >> >> diff --git a/drivers/media/video/atmel-isi.c >> b/drivers/media/video/atmel-isi.c >> new file mode 100644 >> index 000..a020bd3 >> --- /dev/null >> +++ b/drivers/media/video/atmel-isi.c >> @@ -0,0 +1,1074 @@ >> +/* >> + * Copyright (c) 2011 Atmel Corporation >> + * Josh Wu, >> + * >> + * Based on previous work by Lars Haring, >> + * and Sedji Gaouaou >> + * Based on the bttv driver for Bt848 with respective copyright holders >> + * >> + * 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 >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> + >> +#define MAX_BUFFER_NUM 32 >> +#define MAX_SUPPORT_WIDTH 2048 >> +#define MAX_SUPPORT_HEIGHT 2048 >> +#define VID_LIMIT_BYTES (16 * 1024 * 1024) >> +#define MIN_FRAME_RATE 15 >> +#define FRAME_INTERVAL_MILLI_SEC(1000 / MIN_FRAME_RATE) >> + >> +/* ISI states */ >> +enum { >> +ISI_STATE_IDLE = 0, >> +ISI_STATE_READY, >> +ISI_STATE_WAIT_SOF, >> +}; >> + >> +/* Frame buffer descriptor */ >> +struct fbd { >> +/* Physical address of the frame buffer */ >> +u32 fb_address; >> +/* DMA Control Register(only in HISI2) */ >> +u32 dma_ctrl; >> +/* Physical address of the next fbd */ >> +u32 next_fbd_address; >> +}; >> + >> +static void set_dma_ctrl(struct fbd *fb_desc, u32 ctrl) >> +{ >> +fb_desc->dma_ctrl = ctrl; >> +} >> + >> +struct isi_dma_desc { >> +struct list_head list; >> +struct fbd *p_fbd; >> +u32 fbd_phys; >> +}; >> + >> +/* Frame buffer data */ >> +struct frame_buffer { >> +struct vb2_buffer vb; >> +struct fbd *p_fb_desc; >> +u32 fb_desc_phys; > Why don't you replace the above two members with "struct isi_dma_desc *"? > Then you also don't need to scan the DMA descriptor array in > .buf_cleanup(). Will fix in v4. This change makes code simpler. >> +struct list_head list; >> +}; >> + >> +struct atmel_isi { >> +/* Protects the access of variables shared with the ISR */ >> +spinlock_t lock; >> +void __iomem*regs; >> + >> +int sequence; >> +/* State of the ISI module in capturing mode */ >> +int
Re: [PATCH v3] [media] at91: add Atmel Image Sensor Interface (ISI) support
On Fri, 3 Jun 2011, Josh Wu wrote: > This patch is to enable Atmel Image Sensor Interface (ISI) driver support. > - Using soc-camera framework with videobuf2 dma-contig allocator > - Supporting video streaming of YUV packed format > - Tested on AT91SAM9M10G45-EK with OV2640 > > Signed-off-by: Josh Wu > --- > base on branch staging/for_v3.0 > Modified in V3: > refined the interrupt handling code. > added a list to manage the allocated descriptors. > removed redundant code in isi_camera_set_bus_param(). > return error when platform data is not provided. > > drivers/media/video/Kconfig |8 + > drivers/media/video/Makefile|1 + > drivers/media/video/atmel-isi.c | 1074 > +++ > include/media/atmel-isi.h | 119 + > 4 files changed, 1202 insertions(+), 0 deletions(-) > create mode 100644 drivers/media/video/atmel-isi.c > create mode 100644 include/media/atmel-isi.h > > diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig > index bb53de7..93d1098 100644 > --- a/drivers/media/video/Kconfig > +++ b/drivers/media/video/Kconfig > @@ -952,6 +952,14 @@ config VIDEO_SAMSUNG_S5P_FIMC > To compile this driver as a module, choose M here: the > module will be called s5p-fimc. > > +config VIDEO_ATMEL_ISI > + tristate "ATMEL Image Sensor Interface (ISI) support" > + depends on VIDEO_DEV && SOC_CAMERA && ARCH_AT91 > + select VIDEOBUF2_DMA_CONTIG > + ---help--- > + This module makes the ATMEL Image Sensor Interface available > + as a v4l2 device. > + > config VIDEO_S5P_MIPI_CSIS > tristate "Samsung S5P and EXYNOS4 MIPI CSI receiver driver" > depends on VIDEO_V4L2 && PM_RUNTIME && PLAT_S5P && VIDEO_V4L2_SUBDEV_API > diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile > index f0fecd6..d9833f4 100644 > --- a/drivers/media/video/Makefile > +++ b/drivers/media/video/Makefile > @@ -166,6 +166,7 @@ obj-$(CONFIG_VIDEO_PXA27x)+= pxa_camera.o > obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o > obj-$(CONFIG_VIDEO_SH_MOBILE_CEU)+= sh_mobile_ceu_camera.o > obj-$(CONFIG_VIDEO_OMAP1)+= omap1_camera.o > +obj-$(CONFIG_VIDEO_ATMEL_ISI)+= atmel-isi.o > > obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/ > > diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c > new file mode 100644 > index 000..a020bd3 > --- /dev/null > +++ b/drivers/media/video/atmel-isi.c > @@ -0,0 +1,1074 @@ > +/* > + * Copyright (c) 2011 Atmel Corporation > + * Josh Wu, > + * > + * Based on previous work by Lars Haring, > + * and Sedji Gaouaou > + * Based on the bttv driver for Bt848 with respective copyright holders > + * > + * 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 > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > + > +#define MAX_BUFFER_NUM 32 > +#define MAX_SUPPORT_WIDTH2048 > +#define MAX_SUPPORT_HEIGHT 2048 > +#define VID_LIMIT_BYTES (16 * 1024 * 1024) > +#define MIN_FRAME_RATE 15 > +#define FRAME_INTERVAL_MILLI_SEC (1000 / MIN_FRAME_RATE) > + > +/* ISI states */ > +enum { > + ISI_STATE_IDLE = 0, > + ISI_STATE_READY, > + ISI_STATE_WAIT_SOF, > +}; > + > +/* Frame buffer descriptor */ > +struct fbd { > + /* Physical address of the frame buffer */ > + u32 fb_address; > + /* DMA Control Register(only in HISI2) */ > + u32 dma_ctrl; > + /* Physical address of the next fbd */ > + u32 next_fbd_address; > +}; > + > +static void set_dma_ctrl(struct fbd *fb_desc, u32 ctrl) > +{ > + fb_desc->dma_ctrl = ctrl; > +} > + > +struct isi_dma_desc { > + struct list_head list; > + struct fbd *p_fbd; > + u32 fbd_phys; > +}; > + > +/* Frame buffer data */ > +struct frame_buffer { > + struct vb2_buffer vb; > + struct fbd *p_fb_desc; > + u32 fb_desc_phys; Why don't you replace the above two members with "struct isi_dma_desc *"? Then you also don't need to scan the DMA descriptor array in .buf_cleanup(). > + struct list_head list; > +}; > + > +struct atmel_isi { > + /* Protects the access of variables shared with the ISR */ > + spinlock_t lock; > + void __iomem*regs; > + > + int sequence; > + /* State of the ISI module in capturing mode */ > + int state; > + > + /* Wait queue for waiting for SOF */ > + wait_queue_head_t vsync_wq; > + > + struct vb2_alloc_ctx*alloc_ctx; > + > + /* Allocate descriptors for dma buf
[PATCH v3] [media] at91: add Atmel Image Sensor Interface (ISI) support
This patch is to enable Atmel Image Sensor Interface (ISI) driver support. - Using soc-camera framework with videobuf2 dma-contig allocator - Supporting video streaming of YUV packed format - Tested on AT91SAM9M10G45-EK with OV2640 Signed-off-by: Josh Wu --- base on branch staging/for_v3.0 Modified in V3: refined the interrupt handling code. added a list to manage the allocated descriptors. removed redundant code in isi_camera_set_bus_param(). return error when platform data is not provided. drivers/media/video/Kconfig |8 + drivers/media/video/Makefile|1 + drivers/media/video/atmel-isi.c | 1074 +++ include/media/atmel-isi.h | 119 + 4 files changed, 1202 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/atmel-isi.c create mode 100644 include/media/atmel-isi.h diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index bb53de7..93d1098 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -952,6 +952,14 @@ config VIDEO_SAMSUNG_S5P_FIMC To compile this driver as a module, choose M here: the module will be called s5p-fimc. +config VIDEO_ATMEL_ISI + tristate "ATMEL Image Sensor Interface (ISI) support" + depends on VIDEO_DEV && SOC_CAMERA && ARCH_AT91 + select VIDEOBUF2_DMA_CONTIG + ---help--- + This module makes the ATMEL Image Sensor Interface available + as a v4l2 device. + config VIDEO_S5P_MIPI_CSIS tristate "Samsung S5P and EXYNOS4 MIPI CSI receiver driver" depends on VIDEO_V4L2 && PM_RUNTIME && PLAT_S5P && VIDEO_V4L2_SUBDEV_API diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index f0fecd6..d9833f4 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -166,6 +166,7 @@ obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o +obj-$(CONFIG_VIDEO_ATMEL_ISI) += atmel-isi.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/ diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c new file mode 100644 index 000..a020bd3 --- /dev/null +++ b/drivers/media/video/atmel-isi.c @@ -0,0 +1,1074 @@ +/* + * Copyright (c) 2011 Atmel Corporation + * Josh Wu, + * + * Based on previous work by Lars Haring, + * and Sedji Gaouaou + * Based on the bttv driver for Bt848 with respective copyright holders + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define MAX_BUFFER_NUM 32 +#define MAX_SUPPORT_WIDTH 2048 +#define MAX_SUPPORT_HEIGHT 2048 +#define VID_LIMIT_BYTES(16 * 1024 * 1024) +#define MIN_FRAME_RATE 15 +#define FRAME_INTERVAL_MILLI_SEC (1000 / MIN_FRAME_RATE) + +/* ISI states */ +enum { + ISI_STATE_IDLE = 0, + ISI_STATE_READY, + ISI_STATE_WAIT_SOF, +}; + +/* Frame buffer descriptor */ +struct fbd { + /* Physical address of the frame buffer */ + u32 fb_address; + /* DMA Control Register(only in HISI2) */ + u32 dma_ctrl; + /* Physical address of the next fbd */ + u32 next_fbd_address; +}; + +static void set_dma_ctrl(struct fbd *fb_desc, u32 ctrl) +{ + fb_desc->dma_ctrl = ctrl; +} + +struct isi_dma_desc { + struct list_head list; + struct fbd *p_fbd; + u32 fbd_phys; +}; + +/* Frame buffer data */ +struct frame_buffer { + struct vb2_buffer vb; + struct fbd *p_fb_desc; + u32 fb_desc_phys; + struct list_head list; +}; + +struct atmel_isi { + /* Protects the access of variables shared with the ISR */ + spinlock_t lock; + void __iomem*regs; + + int sequence; + /* State of the ISI module in capturing mode */ + int state; + + /* Wait queue for waiting for SOF */ + wait_queue_head_t vsync_wq; + + struct vb2_alloc_ctx*alloc_ctx; + + /* Allocate descriptors for dma buffer use */ + struct fbd *p_fb_descriptors; + u32 fb_descriptors_phys; + struct list_head dma_desc_head; + struct isi_dma_desc dma_desc[MAX_BUFFER_NUM]; + + struct completion complete; + struct clk *pclk; + unsigned intirq; + + struct isi_p