All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 0/6] OMAP1: CAMERA: Converts omap1 camera to use v4l2-int-device api
@ 2007-10-09 12:52 Eduardo Valentin
  2007-10-09 12:52 ` [PATCH 1/6] OMAP1: CAMERA: Changed omap16xxcam.c to the coding style standard Eduardo Valentin
  2007-10-22  6:31 ` [RFC][PATCH 0/6] OMAP1: CAMERA: Converts omap1 camera to use v4l2-int-device api Trilok Soni
  0 siblings, 2 replies; 13+ messages in thread
From: Eduardo Valentin @ 2007-10-09 12:52 UTC (permalink / raw)
  To: linux-omap-mailing-list

Hi all,

This patch set converts omap1 camera to use v4l2-int-device api. It was
tested on H3 with ov9640 sensor, so board-h3.c was modified to add ov9640
specific initializations. The gpio-expander code was modified also to use
the i2c adapter id configured with i2c board specific info. Currently, it is
working only with read method. To work with MMAP, camera_core.c needs more
re-work.

Here is the overall diffstat:
 b/arch/arm/mach-omap1/board-h3.c         |  141 +++++++++
 b/drivers/i2c/chips/gpio_expander_omap.c |    5
 b/drivers/media/video/omap/Kconfig       |    6
 b/drivers/media/video/omap/Makefile      |    4
 b/drivers/media/video/omap/camera_core.c |  394 ++++++++++++++++++---------
 b/drivers/media/video/omap/camera_core.h |   27 -
 b/drivers/media/video/omap/omap16xxcam.c |  442 +++++++++++++++----------------
 drivers/media/video/omap/camera_core.c   |  404 +++++++++++++---------------
 8 files changed, 827 insertions(+), 596 deletions(-)

BR,

Eduardo Valentin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/6] OMAP1: CAMERA: Changed omap16xxcam.c to the coding style standard
  2007-10-09 12:52 [RFC][PATCH 0/6] OMAP1: CAMERA: Converts omap1 camera to use v4l2-int-device api Eduardo Valentin
@ 2007-10-09 12:52 ` Eduardo Valentin
  2007-10-09 12:52   ` [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board Eduardo Valentin
  2007-10-22  6:31 ` [RFC][PATCH 0/6] OMAP1: CAMERA: Converts omap1 camera to use v4l2-int-device api Trilok Soni
  1 sibling, 1 reply; 13+ messages in thread
From: Eduardo Valentin @ 2007-10-09 12:52 UTC (permalink / raw)
  To: linux-omap-mailing-list; +Cc: Eduardo Valentin

From: Eduardo Valentin <eduardo.valentin@indt.org.br>

- Executed Lindent on omap16xxcam.c
- Removed extra blank spaces
- Lines with more than 80 columns were broken
- Added KERN_* flags on printk calls

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
 drivers/media/video/omap/omap16xxcam.c |  441 ++++++++++++++++----------------
 1 files changed, 215 insertions(+), 226 deletions(-)

diff --git a/drivers/media/video/omap/omap16xxcam.c b/drivers/media/video/omap/omap16xxcam.c
index 34cf1a6..82c006b 100644
--- a/drivers/media/video/omap/omap16xxcam.c
+++ b/drivers/media/video/omap/omap16xxcam.c
@@ -1,23 +1,23 @@
 /*
  * drivers/media/video/omap/omap16xxcam.c
  *
- * Copyright (C) 2004 Texas Instruments, Inc. 
- * 
+ * Copyright (C) 2004 Texas Instruments, Inc.
+ *
  * Video-for-Linux (Version 2) camera capture driver for
  * the OMAP H2 and H3 camera controller.
  *
- * leverage some code from CEE distribution 
+ * leverage some code from CEE distribution
  * Copyright (C) 2003-2004 MontaVista Software, Inc.
- * 
- * This package is free software; you can redistribute it and/or modify 
+ *
+ * This package 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. 
- * 
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
+ * published by the Free Software Foundation.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
- 
+
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
@@ -38,7 +38,6 @@
 #include "omap16xxcam.h"
 #include "camera_hw_if.h"
 #include "camera_core.h"
- 
 
 #define CONF_CAMERAIF_RESET_R 5
 #define EN_PER	  0
@@ -49,13 +48,13 @@
 #define NUM_CAMDMA_CHANNELS 2
 
 typedef struct {
-        unsigned int ctrlclock;     /* 00 */
-        unsigned int it_status;     /* 04 */
-        unsigned int mode;          /* 08 */
-        unsigned int status;        /* 0C */
-        unsigned int camdata;       /* 10 */
-        unsigned int gpio;   	    /* 14 */
-        unsigned int peak_counter;  /* 18 */
+	unsigned int ctrlclock;		/* 00 */
+	unsigned int it_status;		/* 04 */
+	unsigned int mode;		/* 08 */
+	unsigned int status;		/* 0C */
+	unsigned int camdata;		/* 10 */
+	unsigned int gpio;		/* 14 */
+	unsigned int peak_counter;	/* 18 */
 } camera_regs_t;
 
 struct camdma_state {
@@ -68,12 +67,12 @@ struct omap16xxcam {
 	camera_regs_t *camera_regs;
 	unsigned long iobase_phys;
 
-	/* frequncy (in Hz) of camera interface functional clock (ocp_clk) */
+	/* Frequency (in Hz) of camera interface functional clock (ocp_clk) */
 	unsigned long ocp_clk;
 
 	struct clk *func_clk;
 
-	/* dma related stuff */
+	/* DMA related stuff */
 	spinlock_t dma_lock;
 	int free_dmach;
 	int next_dmach;
@@ -86,22 +85,21 @@ struct omap16xxcam {
 	int new;
 };
 static struct omap16xxcam hardware_data;
-   
+
 static int omap16xxcam_set_xclk(int, void *);
 static void omap16xx_cam_dma_link_callback(int, unsigned short, void *);
 
 /* Clears the camera data FIFO by setting RAZ_FIFO bit in MODE configuration
-   register. */
-static void
-omap16xx_cam_clear_fifo(struct omap16xxcam *data)
+ * register.
+ */
+static void omap16xx_cam_clear_fifo(struct omap16xxcam *data)
 {
 	data->camera_regs->mode |= RAZ_FIFO;
 	udelay(10);
 	data->camera_regs->mode &= ~RAZ_FIFO;
 }
-  
-static void
-omap16xx_cam_reset(struct omap16xxcam *data, int yes)
+
+static void omap16xx_cam_reset(struct omap16xxcam *data, int yes)
 {
 	if (machine_is_omap_h3())
 		data->camera_regs->gpio = yes ? 0 : 1;
@@ -109,93 +107,96 @@ omap16xx_cam_reset(struct omap16xxcam *data, int yes)
 		data->camera_regs->gpio = yes ? 1 : 0;
 }
 
-static void 
-omap16xx_cam_init(void)
+static void omap16xx_cam_init(void)
 {
 	/*
 	 * FIXME - Use mux API's instead of directly writing in to MUX registers
 	 */
-	omap_writel(omap_readl(FUNC_MUX_CTRL_4) & ~(0x1ff << 21), FUNC_MUX_CTRL_4);
+	omap_writel(omap_readl(FUNC_MUX_CTRL_4) & ~(0x1ff << 21),
+		    FUNC_MUX_CTRL_4);
 	omap_writel(0, FUNC_MUX_CTRL_5);
-	omap_writel(omap_readl(PULL_DWN_CTRL_0) & ~(0x1FFF << 17), PULL_DWN_CTRL_0);
+	omap_writel(omap_readl(PULL_DWN_CTRL_0) & ~(0x1FFF << 17),
+		    PULL_DWN_CTRL_0);
 	omap_writel(omap_readl(PU_PD_SEL_0) & ~(0x1FFF << 17), PU_PD_SEL_0);
 
 	omap_writel(0xeaef, COMP_MODE_CTRL_0);
-	omap_writel(omap_readl(OMAP1610_RESET_CONTROL) & ~(1 << CONF_CAMERAIF_RESET_R),
-			OMAP1610_RESET_CONTROL);
-	omap_writel(omap_readl(OMAP1610_RESET_CONTROL) | (1 << CONF_CAMERAIF_RESET_R),
-			OMAP1610_RESET_CONTROL);
-    
+	omap_writel(omap_readl(OMAP1610_RESET_CONTROL) &
+		    ~(1 << CONF_CAMERAIF_RESET_R), OMAP1610_RESET_CONTROL);
+	omap_writel(omap_readl(OMAP1610_RESET_CONTROL) |
+		    (1 << CONF_CAMERAIF_RESET_R), OMAP1610_RESET_CONTROL);
+
 	/* Enable peripheral reset */
 	omap_writew(omap_readw(ARM_RSTCT2) | (1 << EN_PER), ARM_RSTCT2);
 
-	/* enable peripheral clock */
+	/* Enable peripheral clock */
 	clk_enable(hardware_data.func_clk);
 }
 
-static void
-omap16xx_cam_waitfor_syncedge(struct omap16xxcam *data, u32 edge_mask)
+static void omap16xx_cam_waitfor_syncedge(struct omap16xxcam *data,
+					  u32 edge_mask)
 {
-	data->camera_regs->mode = (FIFO_TRIGGER_LVL << THRESHOLD_BIT) | edge_mask;
+	data->camera_regs->mode =
+	    (FIFO_TRIGGER_LVL << THRESHOLD_BIT) | edge_mask;
 	do {
 		interruptible_sleep_on(&data->vsync_wait);
 	} while (signal_pending(current));
 }
 
-static void
-omap16xx_cam_configure_dma(struct omap16xxcam *data)
+static void omap16xx_cam_configure_dma(struct omap16xxcam *data)
 {
 
 	data->camera_regs->mode = (FIFO_TRIGGER_LVL << THRESHOLD_BIT)
-			 | EN_DMA | EN_FIFO_FULL;
-	data->camera_regs->ctrlclock |= LCLK_EN; 
+	    | EN_DMA | EN_FIFO_FULL;
+	data->camera_regs->ctrlclock |= LCLK_EN;
 }
 
-/* acquire h/w resources DMA */
-static int
-omap16xx_cam_link_open(struct omap16xxcam *data)
+/* Acquire h/w resources DMA */
+static int omap16xx_cam_link_open(struct omap16xxcam *data)
 {
 	int ret;
 
-	/* Acquire first dma channel */
-	if ((ret = omap_request_dma(OMAP_DMA_CAMERA_IF_RX, 
-				"camera dma 1", omap16xx_cam_dma_link_callback,
-				(void *)data, &data->dma_channel_number1))) {
-                return ret;
+	/* Acquire first DMA channel */
+	ret = omap_request_dma(OMAP_DMA_CAMERA_IF_RX,
+			       "camera dma 1",
+			       omap16xx_cam_dma_link_callback,
+			       (void *)data, &data->dma_channel_number1);
+	if (ret)
+		return ret;
+
+	/* Acquire second DMA channel */
+	ret = omap_request_dma(OMAP_DMA_CAMERA_IF_RX,
+			       "camera dma 2",
+			       omap16xx_cam_dma_link_callback,
+			       (void *)data, &data->dma_channel_number2);
+	if (ret) {
+		printk(KERN_ERR "No DMA available for camera\n");
+		return ret;
 	}
-	/* Acquire second dma channel */
-	if ((ret = omap_request_dma(OMAP_DMA_CAMERA_IF_RX, 
-				"camera dma 2", omap16xx_cam_dma_link_callback,
-				(void *)data, &data->dma_channel_number2))) {
-                printk ("No DMA available for camera\n");
-                return ret;
-        }
- 	data->next_dmach = data->dma_channel_number1;
+	data->next_dmach = data->dma_channel_number1;
 	OMAP_DMA_CLNK_CTRL_REG(data->dma_channel_number1) =
-		data->dma_channel_number2;
+	    data->dma_channel_number2;
 	OMAP_DMA_CLNK_CTRL_REG(data->dma_channel_number2) =
-		data->dma_channel_number1;
+	    data->dma_channel_number1;
 
 	return 0;
 }
 
-/* free h/w resources, stop i/f */
-static int
-omap16xx_cam_link_close(struct omap16xxcam *data)
+/* Free h/w resources, stop i/f */
+static int omap16xx_cam_link_close(struct omap16xxcam *data)
 {
-	/* free dma channels */
+	/* Free DMA channels */
 	omap_stop_dma(data->dma_channel_number1);
 	omap_stop_dma(data->dma_channel_number2);
 
-	omap_free_dma (data->dma_channel_number1);
-	omap_free_dma (data->dma_channel_number2);
+	omap_free_dma(data->dma_channel_number1);
+	omap_free_dma(data->dma_channel_number2);
 
 	return 0;
 }
 
-/* dma callback routine. */
-static void
-omap16xx_cam_dma_link_callback(int lch, unsigned short ch_status, void *data)
+/* DMA callback routine. */
+static void omap16xx_cam_dma_link_callback(int lch, unsigned short ch_status,
+					   void *data)
 {
 	int count;
 	void *arg1, *arg2;
@@ -204,52 +205,51 @@ omap16xx_cam_dma_link_callback(int lch, unsigned short ch_status, void *data)
 	dma_callback_t callback;
 
 	spin_lock(&cam->dma_lock);
-	if (cam->free_dmach == 2)
-	{
-		printk("callback all CHANNELS WERE IDLE \n");
+	if (cam->free_dmach == 2) {
+		printk(KERN_ERR "callback all CHANNELS WERE IDLE \n");
 		spin_unlock(&cam->dma_lock);
 		return;
 	}
 	if (cam->free_dmach == 0) {
 		lch = cam->next_dmach;
 	} else {
-		lch = cam->next_dmach == cam->dma_channel_number1 ? 
-			cam->dma_channel_number2 : cam->dma_channel_number1;
+		lch = cam->next_dmach == cam->dma_channel_number1 ?
+		    cam->dma_channel_number2 : cam->dma_channel_number1;
 	}
 
-	while (cam->free_dmach < 2)
-	{
+	while (cam->free_dmach < 2) {
 		if (OMAP_DMA_CCR_REG(lch) & (1 << 7))
-			break;	
+			break;
 
 		count = (lch == cam->dma_channel_number2) ? 1 : 0;
 
 		callback = cam->camdma[count].callback;
- 		arg1 = cam->camdma[count].arg1;
+		arg1 = cam->camdma[count].arg1;
 		arg2 = cam->camdma[count].arg2;
 		cam->free_dmach++;
 
-		spin_unlock(&cam->dma_lock);		
- 		callback(arg1, arg2);
+		spin_unlock(&cam->dma_lock);
+		callback(arg1, arg2);
 		spin_lock(&cam->dma_lock);
 
-		lch = (lch == cam->dma_channel_number2) ? cam->dma_channel_number1 :
-							cam->dma_channel_number2;
+		lch =
+		    (lch ==
+		     cam->dma_channel_number2) ? cam->
+		    dma_channel_number1 : cam->dma_channel_number2;
 	}
 	spin_unlock(&cam->dma_lock);
-	
+
 }
 
-static irqreturn_t
-omap16xx_cam_isr(int irq, void *client_data)
+static irqreturn_t omap16xx_cam_isr(int irq, void *client_data)
 {
 	struct omap16xxcam *data = (struct omap16xxcam *)client_data;
 	unsigned int itstat = data->camera_regs->it_status;
 
 	/* VSYNC UP interrupt, start filling FIFO and enabling DMA */
-	if (itstat & V_UP) {		
+	if (itstat & V_UP) {
 		data->camera_regs->mode &= ~EN_V_UP;
-	 	omap16xx_cam_clear_fifo(data);	
+		omap16xx_cam_clear_fifo(data);
 		omap16xx_cam_configure_dma(data);
 		omap_start_dma(data->next_dmach);
 		wake_up_interruptible(&data->vsync_wait);
@@ -261,29 +261,29 @@ omap16xx_cam_isr(int irq, void *client_data)
 	}
 
 	if (itstat & H_UP)
-		printk("H_UP\n");
-	
+		printk(KERN_INFO "H_UP\n");
+
 	if (itstat & H_DOWN)
-		printk("H_DOWN\n");
-	
+		printk(KERN_INFO "H_DOWN\n");
+
 	if (itstat & FIFO_FULL) {
-		omap16xx_cam_clear_fifo(data);	
-		printk("FIFO_FULL\n");
+		omap16xx_cam_clear_fifo(data);
+		printk(KERN_INFO "FIFO_FULL\n");
 	}
-	
+
 	if (itstat & DATA_XFER)
-		printk("DATA_TRANS\n");
-	
+		printk(KERN_INFO "DATA_TRANS\n");
+
 	return IRQ_HANDLED;
 }
- 
-/* ------------- below are interface functions ----------------- */
-/* ------------- these functions are named omap16xxcam_<name> -- */
-static int
-omap16xxcam_init_dma(void *priv)
+
+/* ------------- Below are interface functions -----------------
+ * ------------- These functions are named omap16xxcam_<name> --
+ */
+static int omap16xxcam_init_dma(void *priv)
 {
 	int ch;
-	struct omap16xxcam *data = (struct omap16xxcam *) priv;
+	struct omap16xxcam *data = (struct omap16xxcam *)priv;
 
 	data->free_dmach = 2;
 	for (ch = 0; ch < 2; ++ch) {
@@ -295,12 +295,12 @@ omap16xxcam_init_dma(void *priv)
 	return 0;
 }
 
-/* start the dma of chains */
-static int 
-omap16xxcam_start_dma(struct sgdma_state *sgdma,
-		dma_callback_t callback, void *arg1, void *arg2, void *priv)
+/* Start the DMA of chains */
+static int omap16xxcam_start_dma(struct sgdma_state *sgdma,
+				 dma_callback_t callback, void *arg1,
+				 void *arg2, void *priv)
 {
-	struct omap16xxcam *data = (struct omap16xxcam *) priv;
+	struct omap16xxcam *data = (struct omap16xxcam *)priv;
 	struct scatterlist *sglist;
 	unsigned long irqflags;
 	int dmach;
@@ -313,37 +313,37 @@ omap16xxcam_start_dma(struct sgdma_state *sgdma,
 	if (!data->free_dmach) {
 		spin_unlock_irqrestore(&data->dma_lock, irqflags);
 		return -EBUSY;
-	} 
+	}
 	dmach = data->next_dmach;
-	count = (dmach == data->dma_channel_number2) ? 1:0;
+	count = (dmach == data->dma_channel_number2) ? 1 : 0;
 	data->camdma[count].callback = callback;
 	data->camdma[count].arg1 = arg1;
 	data->camdma[count].arg2 = arg2;
 
 	if (cpu_is_omap1710())
 		omap_set_dma_src_params(dmach, OMAP_DMA_PORT_OCP_T1,
-			    OMAP_DMA_AMODE_CONSTANT, CAM_CAMDATA_REG,
-			    0, 0);
+					OMAP_DMA_AMODE_CONSTANT,
+					CAM_CAMDATA_REG, 0, 0);
 	else
 		omap_set_dma_src_params(dmach, OMAP_DMA_PORT_TIPB,
-			    OMAP_DMA_AMODE_CONSTANT, CAM_CAMDATA_REG,
-			    0, 0);
+					OMAP_DMA_AMODE_CONSTANT,
+					CAM_CAMDATA_REG, 0, 0);
 
 	omap_set_dma_dest_params(dmach, OMAP_DMA_PORT_EMIFF,
-	                     OMAP_DMA_AMODE_POST_INC, sg_dma_address(sglist),
-			     0, 0);
+				 OMAP_DMA_AMODE_POST_INC,
+				 sg_dma_address(sglist), 0, 0);
 
 	omap_set_dma_transfer_params(dmach, OMAP_DMA_DATA_TYPE_S32,
-			FIFO_TRIGGER_LVL, 
-			sg_dma_len(sglist)/(4 * FIFO_TRIGGER_LVL), 
- 			OMAP_DMA_SYNC_FRAME,
-			0, 0);
+				     FIFO_TRIGGER_LVL,
+				     sg_dma_len(sglist) / (4 *
+							   FIFO_TRIGGER_LVL),
+				     OMAP_DMA_SYNC_FRAME, 0, 0);
+
+	OMAP_DMA_CLNK_CTRL_REG(dmach) &= ~(1 << 15);
 
-	OMAP_DMA_CLNK_CTRL_REG(dmach) &= ~( 1<< 15);
+	prev_dmach = (dmach == data->dma_channel_number2) ?
+	    data->dma_channel_number1 : data->dma_channel_number2;
 
-	prev_dmach = (dmach == data->dma_channel_number2) ? 
-		data->dma_channel_number1 : data->dma_channel_number2;
-	
 	if (data->new) {
 		data->new = 0;
 		omap16xx_cam_waitfor_syncedge(data, EN_V_UP);
@@ -351,20 +351,20 @@ omap16xxcam_start_dma(struct sgdma_state *sgdma,
 		if (OMAP_DMA_CCR_REG(prev_dmach) & (1 << 7))
 			OMAP_DMA_CLNK_CTRL_REG(prev_dmach) |= (1 << 15);
 		else {
-			/* no transfer is in progress */
-  			omap_start_dma(dmach);
-		}	
+			/* No transfer is in progress */
+			omap_start_dma(dmach);
+		}
 	}
- 	
-	data->next_dmach = prev_dmach; 
+
+	data->next_dmach = prev_dmach;
 	data->free_dmach--;
 	spin_unlock_irqrestore(&data->dma_lock, irqflags);
 	return 0;
 }
-int static
-omap16xxcam_finish_dma(void *priv)
+
+int static omap16xxcam_finish_dma(void *priv)
 {
-	struct omap16xxcam *data = (struct omap16xxcam *) priv;
+	struct omap16xxcam *data = (struct omap16xxcam *)priv;
 
 	while (data->free_dmach < 2)
 		mdelay(1);
@@ -372,112 +372,107 @@ omap16xxcam_finish_dma(void *priv)
 	return 0;
 }
 
-
-/* Enables the camera. Takes camera out of reset. Enables the clocks. */ 
-static int
-omap16xxcam_enable(void *priv)
+/* Enables the camera. Takes camera out of reset. Enables the clocks. */
+static int omap16xxcam_enable(void *priv)
 {
-	struct omap16xxcam *data = (struct omap16xxcam *) priv;
+	struct omap16xxcam *data = (struct omap16xxcam *)priv;
 
 	omap16xx_cam_reset(data, 1);
-	
-	/* give clock to camera_module */
+
+	/* Give clock to camera_module */
 	data->camera_regs->mode = (FIFO_TRIGGER_LVL << THRESHOLD_BIT);
 	data->camera_regs->ctrlclock = MCLK_EN | CAMEXCLK_EN;
 
 	omap16xx_cam_clear_fifo(data);
 
-	/* wait for camera to settle down */
+	/* Wait for camera to settle down */
 	mdelay(5);
 
 	return 0;
 }
- 
+
 /* Disables all the camera clocks. Put the camera interface in reset. */
-static int
-omap16xxcam_disable(void *priv)
-{ 	
-	struct omap16xxcam *data = (struct omap16xxcam *) priv;
+static int omap16xxcam_disable(void *priv)
+{
+	struct omap16xxcam *data = (struct omap16xxcam *)priv;
 
 	omap16xx_cam_clear_fifo(data);
 
-	data->camera_regs->ctrlclock = 0x00000000;     
+	data->camera_regs->ctrlclock = 0x00000000;
 	data->camera_regs->mode = 0x00000000;
-	
+
 	omap16xx_cam_reset(data, 0);
 
 	return 0;
 }
 
 /* Abort the data transfer */
-static int
-omap16xxcam_abort(void *priv)
+static int omap16xxcam_abort(void *priv)
 {
 	return omap16xxcam_disable(priv);
 }
 
-static int
-omap16xxcam_set_xclk(int xclk, void *priv)
-{ 	
-	struct omap16xxcam *data = (struct omap16xxcam *) priv;
- 	int xclk_val;
+static int omap16xxcam_set_xclk(int xclk, void *priv)
+{
+	struct omap16xxcam *data = (struct omap16xxcam *)priv;
+	int xclk_val;
 	int divisor = 1;
-	divisor = data->ocp_clk/xclk;
-	if ( divisor * xclk < data->ocp_clk)
-		++divisor; 
+	divisor = data->ocp_clk / xclk;
+	if (divisor * xclk < data->ocp_clk)
+		++divisor;
 
 	switch (divisor) {
-		case 1:
-		case 2:
-			xclk_val = FOSCMOD_TC2_CK2;
-			break;
-		case 3:
-			xclk_val = FOSCMOD_TC2_CK3;
-			break;
-		case 4:
-		case 5:
-		case 6:
-		case 7:
-			xclk_val = FOSCMOD_TC2_CK4;
-			break;
-		case 8:
-		case 9:
-			xclk_val = FOSCMOD_TC2_CK8;
-			break;
-		case 10:
-		case 11:
-			xclk_val = FOSCMOD_TC2_CK10;
-			break;
-		case 12:
-		case 13:
-		case 14:
-		case 15:
-			xclk_val = FOSCMOD_TC2_CK12;
-			break;
-		case 16:
-			xclk_val = FOSCMOD_TC2_CK16;
-			break;
-		default:
-			xclk_val = FOSCMOD_TC2_CK16;
+	case 1:
+	case 2:
+		xclk_val = FOSCMOD_TC2_CK2;
+		break;
+	case 3:
+		xclk_val = FOSCMOD_TC2_CK3;
+		break;
+	case 4:
+	case 5:
+	case 6:
+	case 7:
+		xclk_val = FOSCMOD_TC2_CK4;
+		break;
+	case 8:
+	case 9:
+		xclk_val = FOSCMOD_TC2_CK8;
+		break;
+	case 10:
+	case 11:
+		xclk_val = FOSCMOD_TC2_CK10;
+		break;
+	case 12:
+	case 13:
+	case 14:
+	case 15:
+		xclk_val = FOSCMOD_TC2_CK12;
+		break;
+	case 16:
+		xclk_val = FOSCMOD_TC2_CK16;
+		break;
+	default:
+		xclk_val = FOSCMOD_TC2_CK16;
 	}
-	
-	/* follow the protocol to change the XCLK clock */
+
+	/* Follow the protocol to change the XCLK clock */
 	data->camera_regs->ctrlclock &= ~CAMEXCLK_EN;
 	data->camera_regs->ctrlclock |= xclk_val;
 	data->camera_regs->ctrlclock |= CAMEXCLK_EN;
 
-	return (data->ocp_clk/divisor);
+	return (data->ocp_clk / divisor);
 }
 
-static int
-omap16xxcam_open(void *priv)
+static int omap16xxcam_open(void *priv)
 {
-	struct omap16xxcam *data = (struct omap16xxcam *) priv;
+	struct omap16xxcam *data = (struct omap16xxcam *)priv;
 	int ret;
 
-	if ((ret = request_irq(INT_CAMERA, omap16xx_cam_isr, IRQF_DISABLED,
-					"camera", data))) {
-		printk("FAILED to aquire irq\n");
+	ret = request_irq(INT_CAMERA, omap16xx_cam_isr, IRQF_DISABLED,
+			  "camera", data);
+	if (ret) {
+		printk(KERN_ERR "FAILED to acquire IRQ\n");
 		return ret;
 	}
 
@@ -488,22 +483,20 @@ omap16xxcam_open(void *priv)
 	return omap16xx_cam_link_open(data);
 }
 
-static int
-omap16xxcam_close(void *priv)
+static int omap16xxcam_close(void *priv)
 {
-	struct omap16xxcam *data = (struct omap16xxcam *) priv;
+	struct omap16xxcam *data = (struct omap16xxcam *)priv;
 
 	omap16xxcam_disable(priv);
-	 
+
 	free_irq(INT_CAMERA, data);
-	
+
 	return omap16xx_cam_link_close(data);
 }
 
-static int
-omap16xxcam_cleanup(void *priv)
+static int omap16xxcam_cleanup(void *priv)
 {
-	struct omap16xxcam *data = (struct omap16xxcam *) priv;
+	struct omap16xxcam *data = (struct omap16xxcam *)priv;
 
 	if (!data->camera_regs)
 		return -EINVAL;
@@ -511,7 +504,7 @@ omap16xxcam_cleanup(void *priv)
 	omap16xxcam_disable(data);
 	if (cpu_is_omap1710())
 		iounmap((void *)data->camera_regs);
-	data->camera_regs= NULL;
+	data->camera_regs = NULL;
 
 	if (data->iobase_phys) {
 		release_mem_region(data->iobase_phys, CAMERA_IOSIZE);
@@ -527,9 +520,8 @@ omap16xxcam_cleanup(void *priv)
 	return 0;
 }
 
-/* Initialise the OMAP camera interface */
-static void *
-omap16xxcam_init(void)
+/* Initialize the OMAP camera interface */
+static void *omap16xxcam_init(void)
 {
 	unsigned long cam_iobase;
 
@@ -540,36 +532,34 @@ omap16xxcam_init(void)
 	}
 
 	if (cpu_is_omap1710()) {
-		cam_iobase = (unsigned long) ioremap (CAMERA_BASE,
-				CAMERA_IOSIZE);
+		cam_iobase = (unsigned long)ioremap(CAMERA_BASE, CAMERA_IOSIZE);
 		if (!cam_iobase) {
-			printk("CANNOT MAP CAMERA REGISTER\n");
+			printk(KERN_ERR "CANNOT MAP CAMERA REGISTER\n");
 			return NULL;
 		}
-	}
-	else
+	} else
 		cam_iobase = io_p2v(CAMERA_BASE);
 
 	/* Set the base address of the camera registers */
-	hardware_data.camera_regs = (camera_regs_t *)cam_iobase;
-	hardware_data.iobase_phys = (unsigned long) CAMERA_BASE;
+	hardware_data.camera_regs = (camera_regs_t *) cam_iobase;
+	hardware_data.iobase_phys = (unsigned long)CAMERA_BASE;
 
-	/* get the input clock value to camera interface and store it */
+	/* Get the input clock value to camera interface and store it */
 	if (cpu_is_omap1710())
 		hardware_data.func_clk = clk_get(0, "tc2_ck");
 	else
 		hardware_data.func_clk = clk_get(0, "armper_ck");
 	hardware_data.ocp_clk = clk_get_rate(hardware_data.func_clk);
 
-	/* Init the camera IF */
+	/* Initialize the camera IF */
 	omap16xx_cam_init();
-	/* enable it. This is needed for sensor detection */
-	omap16xxcam_enable((void*)&hardware_data);
-	/* Init dma data */
+	/* Enable it. This is needed for sensor detection */
+	omap16xxcam_enable((void *)&hardware_data);
+	/* Initialize DMA data */
 	spin_lock_init(&hardware_data.dma_lock);
 
 	init_waitqueue_head(&hardware_data.vsync_wait);
-	return (void*)&hardware_data;
+	return (void *)&hardware_data;
 }
 
 struct camera_hardware camera_hardware_if = {
@@ -587,4 +577,3 @@ struct camera_hardware camera_hardware_if = {
 	.start_dma	= omap16xxcam_start_dma,
 	.finish_dma	= omap16xxcam_finish_dma,
 };
-
-- 
1.5.3.4.206.g58ba4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board.
  2007-10-09 12:52 ` [PATCH 1/6] OMAP1: CAMERA: Changed omap16xxcam.c to the coding style standard Eduardo Valentin
@ 2007-10-09 12:52   ` Eduardo Valentin
  2007-10-09 12:52     ` [PATCH 3/6] OMAP: Update gpio expander code to the corret i2c adapter id Eduardo Valentin
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Eduardo Valentin @ 2007-10-09 12:52 UTC (permalink / raw)
  To: linux-omap-mailing-list; +Cc: Eduardo Valentin

From: Eduardo Valentin <eduardo.valentin@indt.org.br>

This code is based on board-h4.c and drivers/media/video/omap/h3_sensor_power.c codes.

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
 arch/arm/mach-omap1/board-h3.c |  140 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 140 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index df77cf5..8ecc5f2 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -26,6 +26,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/input.h>
 #include <linux/clk.h>
+#include <linux/i2c.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/tsc2101.h>
 
@@ -37,6 +38,8 @@
 #include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 
+#include <media/v4l2-int-device.h>
+
 #include <asm/arch/gpio.h>
 #include <asm/arch/gpioexpander.h>
 #include <asm/arch/irqs.h>
@@ -50,6 +53,8 @@
 #include <asm/arch/mcbsp.h>
 #include <asm/arch/omap-alsa.h>
 
+#include <../drivers/media/video/ov9640.h>
+
 extern int omap_gpio_init(void);
 
 static int h3_keymap[] = {
@@ -547,6 +552,138 @@ static int nand_dev_ready(struct nand_platform_data *data)
 	return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
 }
 
+/*
+ * Common OV9640 register initialization for all image sizes, pixel formats,
+ * and frame rates
+ */
+const static struct ov9640_reg ov9640_common[] = {
+
+	{ 0x12, 0x80 }, { 0x11, 0x80 }, { 0x13, 0x88 },	/* COM7, CLKRC, COM8 */
+	{ 0x01, 0x58 }, { 0x02, 0x24 }, { 0x04, 0x00 },	/* BLUE, RED, COM1 */
+	{ 0x0E, 0x81 }, { 0x0F, 0x4F }, { 0x14, 0xcA },	/* COM5, COM6, COM9 */
+	{ 0x16, 0x02 }, { 0x1B, 0x01 }, { 0x24, 0x70 },	/* ?, PSHFT, AEW */
+	{ 0x25, 0x68 }, { 0x26, 0xD3 }, { 0x27, 0x90 },	/* AEB, VPT, BBIAS */
+	{ 0x2A, 0x00 }, { 0x2B, 0x00 }, { 0x32, 0x24 },	/* EXHCH, EXHCL, HREF */
+	{ 0x33, 0x02 }, { 0x37, 0x02 }, { 0x38, 0x13 },	/* CHLF, ADC, ACOM */
+	{ 0x39, 0xF0 }, { 0x3A, 0x00 }, { 0x3B, 0x01 },	/* OFON, TSLB, COM11 */
+	{ 0x3D, 0x90 }, { 0x3E, 0x02 }, { 0x3F, 0xF2 },	/* COM13, COM14, EDGE */
+	{ 0x41, 0x02 }, { 0x42, 0xC8 },		/* COM16, COM17 */
+	{ 0x43, 0xF0 }, { 0x44, 0x10 }, { 0x45, 0x6C },	/* ?, ?, ? */
+	{ 0x46, 0x6C }, { 0x47, 0x44 }, { 0x48, 0x44 },	/* ?, ?, ? */
+	{ 0x49, 0x03 }, { 0x59, 0x49 }, { 0x5A, 0x94 },	/* ?, ?, ? */
+	{ 0x5B, 0x46 }, { 0x5C, 0x84 }, { 0x5D, 0x5C },	/* ?, ?, ? */
+	{ 0x5E, 0x08 }, { 0x5F, 0x00 }, { 0x60, 0x14 },	/* ?, ?, ? */
+	{ 0x61, 0xCE },					/* ? */
+	{ 0x62, 0x70 }, { 0x63, 0x00 }, { 0x64, 0x04 },	/* LCC1, LCC2, LCC3 */
+	{ 0x65, 0x00 }, { 0x66, 0x00 },			/* LCC4, LCC5 */
+	{ 0x69, 0x00 }, { 0x6A, 0x3E }, { 0x6B, 0x3F },	/* HV, MBD, DBLV */
+	{ 0x6C, 0x40 }, { 0x6D, 0x30 }, { 0x6E, 0x4B },	/* GSP1, GSP2, GSP3 */
+	{ 0x6F, 0x60 }, { 0x70, 0x70 }, { 0x71, 0x70 },	/* GSP4, GSP5, GSP6 */
+	{ 0x72, 0x70 }, { 0x73, 0x70 }, { 0x74, 0x60 },	/* GSP7, GSP8, GSP9 */
+	{ 0x75, 0x60 }, { 0x76, 0x50 }, { 0x77, 0x48 },	/* GSP10,GSP11,GSP12 */
+	{ 0x78, 0x3A }, { 0x79, 0x2E }, { 0x7A, 0x28 },	/* GSP13,GSP14,GSP15 */
+	{ 0x7B, 0x22 }, { 0x7C, 0x04 }, { 0x7D, 0x07 },	/* GSP16,GST1, GST2 */
+	{ 0x7E, 0x10 }, { 0x7F, 0x28 }, { 0x80, 0x36 },	/* GST3, GST4, GST5 */
+	{ 0x81, 0x44 }, { 0x82, 0x52 }, { 0x83, 0x60 },	/* GST6, GST7, GST8 */
+	{ 0x84, 0x6C }, { 0x85, 0x78 }, { 0x86, 0x8C },	/* GST9, GST10,GST11 */
+	{ 0x87, 0x9E }, { 0x88, 0xBB }, { 0x89, 0xD2 },	/* GST12,GST13,GST14 */
+	{ 0x8A, 0xE6 }, { 0x13, 0xaF }, { 0x15, 0x02 },	/* GST15, COM8 */
+	{ 0x22, 0x8a }, /* GROS */
+	{ OV9640_REG_TERM, OV9640_VAL_TERM }
+};
+
+#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE)
+static int ov9640_sensor_powerup(void)
+{
+	unsigned char expa;
+	int err;
+
+	/* read current state of GPIO EXPA outputs */
+	err = read_gpio_expa(&expa, 0x27);
+	if (err) {
+		printk(KERN_ERR "Error reading GPIO EXPA\n");
+		return err;
+	}
+	/* Set GPIO EXPA P3 (CAMERA_MODULE_EN) to power-up sensor */
+	err = write_gpio_expa(expa | 0x08, 0x27);
+	if (err) {
+		printk(KERN_ERR "Error writing to GPIO EXPA\n");
+		return err;
+	}
+
+	return 0;
+}
+static int ov9640_sensor_powerdown(void)
+{
+	unsigned char expa;
+	int err;
+
+	/* read current state of GPIO EXPA outputs */
+	err = read_gpio_expa(&expa, 0x27);
+	if (err) {
+		printk(KERN_ERR "Error reading GPIO EXPA\n");
+		return err;
+	}
+	/* Clear GPIO EXPA P3 (CAMERA_MODULE_EN) to power-down sensor */
+	err = write_gpio_expa(expa & ~0x08, 0x27);
+	if (err) {
+		printk(KERN_ERR "Error writing to GPIO EXPA\n");
+		return err;
+	}
+
+	return 0;
+}
+
+static int ov9640_sensor_power_set(int power)
+{
+	int err = 0;
+
+	if (power)
+		err = ov9640_sensor_powerup();
+	else
+		err = ov9640_sensor_powerdown();
+
+	return err;
+}
+
+static struct v4l2_ifparm ifparm = {
+	.if_type = V4L2_IF_TYPE_BT656,
+	.u = {
+		.bt656 = {
+			 .frame_start_on_rising_vs = 1,
+			 .nobt_vs_inv = 1,
+			 .mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT,
+			 .clock_min = OV9640_XCLK_MIN,
+			 .clock_max = OV9640_XCLK_MAX,
+		 },
+	},
+};
+
+static int ov9640_ifparm(struct v4l2_ifparm *p)
+{
+	*p = ifparm;
+
+	return 0;
+}
+#else
+static int ov9640_sensor_power_set(int power) { return 0; }
+static int ov9640_ifparm(struct v4l2_ifparm *p) { return 0; }
+#endif
+
+static struct ov9640_platform_data h3_ov9640_platform_data = {
+	.power_set	= ov9640_sensor_power_set,
+	.default_regs	= ov9640_common,
+	.ifparm		= ov9640_ifparm,
+};
+
+static struct i2c_board_info __initdata h3_i2c_board_info[] = {
+	{
+		I2C_BOARD_INFO("ov9640", 0x30),
+		.platform_data = &h3_ov9640_platform_data,
+	},
+};
+
+
 static void __init h3_init(void)
 {
 	/* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
@@ -569,6 +706,9 @@ static void __init h3_init(void)
 	/* GPIO10 pullup/down register, Enable pullup on GPIO10 */
 	omap_cfg_reg(V2_1710_GPIO10);
 
+	i2c_register_board_info(1, h3_i2c_board_info,
+				ARRAY_SIZE(h3_i2c_board_info));
+
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 	spi_register_board_info(h3_spi_board_info,
 				ARRAY_SIZE(h3_spi_board_info));
-- 
1.5.3.4.206.g58ba4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/6] OMAP: Update gpio expander code to the corret i2c adapter id
  2007-10-09 12:52   ` [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board Eduardo Valentin
@ 2007-10-09 12:52     ` Eduardo Valentin
  2007-10-09 12:52       ` [PATCH 4/6] OMAP1: CAMERA: Convert camera_core.c to use v4l2-int-device API Eduardo Valentin
  2007-10-10 14:06     ` [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board Eduardo Valentin
  2007-10-31 10:41     ` Tony Lindgren
  2 siblings, 1 reply; 13+ messages in thread
From: Eduardo Valentin @ 2007-10-09 12:52 UTC (permalink / raw)
  To: linux-omap-mailing-list; +Cc: Eduardo Valentin

From: Eduardo Valentin <eduardo.valentin@indt.org.br>

- Update gpio expander code to the corret i2c adapter id
- Due to changes on i2c binding style, the i2c adapter is 1
and not 0. (as configured on i2c_register_board_info)

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
 drivers/i2c/chips/gpio_expander_omap.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/chips/gpio_expander_omap.c b/drivers/i2c/chips/gpio_expander_omap.c
index 92e96ba..dfe7f04 100644
--- a/drivers/i2c/chips/gpio_expander_omap.c
+++ b/drivers/i2c/chips/gpio_expander_omap.c
@@ -26,7 +26,7 @@ int write_gpio_expa(u8 val, int addr)
 	struct i2c_msg msg[1];
 	unsigned char data[1];
 
-	adap = i2c_get_adapter(0);
+	adap = i2c_get_adapter(1);
 	if (!adap)
 		return -ENODEV;
 	msg->addr = addr;	/* I2C address of GPIO EXPA */
@@ -51,7 +51,7 @@ int read_gpio_expa(u8 * val, int addr)
 	struct i2c_msg msg[1];
 	unsigned char data[1];
 
-	adap = i2c_get_adapter(0);
+	adap = i2c_get_adapter(1);
 	if (!adap)
 		return -ENODEV;
 	msg->addr = addr;	/* I2C address of GPIO EXPA */
-- 
1.5.3.4.206.g58ba4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/6] OMAP1: CAMERA: Convert camera_core.c to use v4l2-int-device API
  2007-10-09 12:52     ` [PATCH 3/6] OMAP: Update gpio expander code to the corret i2c adapter id Eduardo Valentin
@ 2007-10-09 12:52       ` Eduardo Valentin
  2007-10-09 12:52         ` [PATCH 5/6] OMAP1: CAMERA: Changed camera_core.c to the coding style standard Eduardo Valentin
  0 siblings, 1 reply; 13+ messages in thread
From: Eduardo Valentin @ 2007-10-09 12:52 UTC (permalink / raw)
  To: linux-omap-mailing-list; +Cc: Eduardo Valentin

From: Eduardo Valentin <eduardo.valentin@indt.org.br>

This patch converts camera_core.c to use v4l2-int-device API.
Only read method was tested with success. MMAP method still needs
re-work and tests.

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
 drivers/media/video/omap/camera_core.c |  394 +++++++++++++++++++++-----------
 drivers/media/video/omap/camera_core.h |   26 +-
 2 files changed, 279 insertions(+), 141 deletions(-)

diff --git a/drivers/media/video/omap/camera_core.c b/drivers/media/video/omap/camera_core.c
index bbd51d1..217a79f 100644
--- a/drivers/media/video/omap/camera_core.c
+++ b/drivers/media/video/omap/camera_core.c
@@ -54,6 +54,101 @@ static int capture_mem = 1280*960*2*2;
 static int overlay_mem = 640*480*2;
 
 
+/*
+ * Enable the external sensor interface. Try to negotiate interface
+ * parameters with the sensor and start using the new ones. The calls
+ * to sensor_if_enable and sensor_if_disable need not to be balanced.
+ */
+static int camera_sensor_if_enable(struct camera_device *cam)
+{
+	int rval;
+	struct v4l2_ifparm p;
+
+	rval = vidioc_int_g_ifparm(cam->sdev, &p);
+	if (rval) {
+		dev_err(cam->dev, "vidioc_int_g_ifparm failed with %d\n", rval);
+		return rval;
+	}
+
+	cam->if_type = p.if_type;
+
+	switch (p.if_type) {
+	case V4L2_IF_TYPE_BT656:
+		cam->if_u.bt656.xclk =
+			cam->cam_hardware->set_xclk(cam->if_u.bt656.xclk,
+						    cam->hardware_data);
+		break;
+	default:
+		/* FIXME: how about other interfaces? */
+		dev_err(cam->dev, "interface type %d not supported\n",
+			p.if_type);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void camera_sensor_if_disable(const struct camera_device *cam)
+{
+	switch (cam->if_type) {
+	case V4L2_IF_TYPE_BT656:
+		break;
+	}
+}
+
+/*
+ * Initialise the sensor hardware.
+ */
+static int camera_sensor_init(struct camera_device *cam)
+{
+	int err = 0;
+	struct v4l2_int_device *sdev = cam->sdev;
+
+	/* Enable the xclk output.  The sensor may (and does, in the case of
+	 * the OV9640) require an xclk input in order for its initialization
+	 * routine to work.
+	 */
+
+	cam->if_u.bt656.xclk = 21000000;/* choose an arbitrary xclk frequency */
+
+	cam->if_u.bt656.xclk = cam->cam_hardware->set_xclk(cam->if_u.bt656.xclk,
+							   cam->hardware_data);
+
+	err = camera_sensor_if_enable(cam);
+	if (err) {
+		dev_err(cam->dev, "sensor interface could not be enabled at "
+			"initialisation, %d\n", err);
+		cam->sdev = NULL;
+		goto out;
+	}
+
+	/* power up sensor during sensor initialization */
+	vidioc_int_s_power(sdev, 1);
+
+	err = vidioc_int_dev_init(sdev);
+	if (err) {
+		dev_err(cam->dev, "cannot initialize sensor, error %d\n", err);
+		/* Sensor init failed --- it's nonexistent to us! */
+		cam->sdev = NULL;
+		goto out;
+	}
+
+	dev_info(cam->dev, "sensor is %s\n", sdev->name);
+
+out:
+	camera_sensor_if_disable(cam);
+
+	vidioc_int_s_power(sdev, 0);
+
+	return err;
+}
+
+static void camera_sensor_exit(struct camera_device *cam)
+{
+	if (cam->sdev)
+		vidioc_int_dev_exit(cam->sdev);
+}
+
 /* DMA completion routine for the scatter-gather DMA fragments. */
 /* This function is called when a scatter DMA fragment is completed */
 static void
@@ -68,7 +163,7 @@ camera_core_callback_sgdma(void *arg1, void *arg2)
 	sgdma = cam->sgdma + sgslot;
 	if (!sgdma->queued_sglist) {
 		spin_unlock(&cam->sg_lock);
-		dev_err(&cam->dev, "SGDMA completed when none queued\n");
+		dev_err(cam->dev, "SGDMA completed when none queued\n");
 		return;
 	}
 	if (!--sgdma->queued_sglist) {
@@ -318,7 +413,8 @@ camera_core_vbq_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
 static int
 camera_core_vbq_setup(struct videobuf_queue *q, unsigned int *cnt, unsigned int *size)
 {
-	struct camera_device *cam = q->priv_data;
+	struct camera_fh *fh = q->priv_data;
+	struct camera_device *cam = fh->cam;
 
 	if (*cnt <= 0)
 		*cnt = VIDEO_MAX_FRAME; /* supply a default number of buffers */
@@ -340,7 +436,8 @@ static int
 camera_core_vbq_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
         enum v4l2_field field)
 {
-	struct camera_device *cam = q->priv_data;
+	struct camera_fh *fh = q->priv_data;
+	struct camera_device *cam = fh->cam;
 	int err = 0;
 
 	spin_lock(&cam->img_lock);
@@ -368,7 +465,8 @@ camera_core_vbq_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
 static void
 camera_core_vbq_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 {
-	struct camera_device *cam = q->priv_data;
+	struct camera_fh *fh = q->priv_data;
+	struct camera_device *cam = fh->cam;
 	enum videobuf_state state = vb->state;
 	int err;
 
@@ -382,7 +480,7 @@ camera_core_vbq_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 		* scatter-gather DMA slots as video buffers so that can't
 		* happen.
 		*/
-		dev_dbg(&cam->dev, "Failed to queue a video buffer for SGDMA\n");
+		dev_dbg(cam->dev, "Failed to queue a video buffer for SGDMA\n");
 		vb->state = state;
 	}
 }
@@ -417,7 +515,7 @@ static int vidioc_enum_fmt_cap(struct file *file, void *fh,
 	struct camera_fh *ofh  = fh;
 	struct camera_device *cam = ofh->cam;
 
-	return cam->cam_sensor->enum_pixformat(f, cam->sensor_data);
+	return vidioc_int_enum_fmt_cap(cam->sdev, f);
 }
 
 static int vidioc_g_fmt_cap(struct file *file, void *fh,
@@ -438,18 +536,16 @@ static int vidioc_s_fmt_cap(struct file *file, void *fh,
 {
 	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
-	unsigned int temp_sizeimage = 0;
+	int rval = 0;
+
+	vidioc_int_try_fmt_cap(cam->sdev, f);
 
-	temp_sizeimage = cam->pix.sizeimage;
-	cam->cam_sensor->try_format(&f->fmt.pix, cam->sensor_data);
 	cam->pix = f->fmt.pix;
 
-	cam->xclk = cam->cam_sensor->calc_xclk(&cam->pix,
-			       &cam->nominal_timeperframe, cam->sensor_data);
-	cam->cparm.timeperframe = cam->nominal_timeperframe;
-	cam->xclk = cam->cam_hardware->set_xclk(cam->xclk, cam->hardware_data);
-	return cam->cam_sensor->configure(&cam->pix, cam->xclk,
-				  &cam->cparm.timeperframe, cam->sensor_data);
+	rval = vidioc_int_s_fmt_cap(cam->sdev, f);
+	camera_sensor_if_enable(cam);
+
+	return rval;
 }
 
 static int vidioc_try_fmt_cap(struct file *file, void *fh,
@@ -458,7 +554,7 @@ static int vidioc_try_fmt_cap(struct file *file, void *fh,
 	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
 
-	return cam->cam_sensor->try_format(&f->fmt.pix, cam->sensor_data);
+	return vidioc_int_try_fmt_cap(cam->sdev, f);
 }
 
 static int vidioc_reqbufs(struct file *file, void *fh,
@@ -563,7 +659,7 @@ static int vidioc_queryctrl(struct file *file, void *fh,
 	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
 
-	return cam->cam_sensor->query_control(a, cam->sensor_data);
+	return vidioc_int_queryctrl(cam->sdev, a);
 }
 
 static int vidioc_g_ctrl(struct file *file, void *fh,
@@ -572,7 +668,7 @@ static int vidioc_g_ctrl(struct file *file, void *fh,
 	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
 
-	return cam->cam_sensor->get_control(a, cam->sensor_data);
+	return vidioc_int_g_ctrl(cam->sdev, a);
 }
 
 static int vidioc_s_ctrl(struct file *file, void *fh,
@@ -581,7 +677,7 @@ static int vidioc_s_ctrl(struct file *file, void *fh,
 	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
 
-	return cam->cam_sensor->set_control(a, cam->sensor_data);
+	return vidioc_int_s_ctrl(cam->sdev, a);
 }
 
 static int vidioc_g_fbuf(struct file *file, void *fh,
@@ -723,7 +819,7 @@ camera_core_read(struct file *file, char *data, size_t count, loff_t *ppos)
 				GFP_KERNEL | GFP_DMA);
 	}
 	if (!cam->capture_base) {
-		dev_err(&cam->dev, "cannot allocate capture buffer\n");
+		dev_err(cam->dev, "cannot allocate capture buffer\n");
 		return 0;
 	}
 
@@ -744,7 +840,7 @@ camera_core_read(struct file *file, char *data, size_t count, loff_t *ppos)
 		timeout = interruptible_sleep_on_timeout
 				(&cam->new_video_frame, timeout);
 		if (timeout == 0) {
-			dev_err(&cam->dev, "timeout waiting video frame\n");
+			dev_err(cam->dev, "timeout waiting video frame\n");
 			return -EIO; /* time out */
 		}
 	}
@@ -796,6 +892,8 @@ camera_core_release(struct inode *inode, struct file *file)
 		kfree(fh->vbq.read_buf);
 	}
 
+	module_put(cam->sdev->module);
+
 	cam->cam_hardware->close(cam->hardware_data);
 	cam->active = 0;
 	return 0;
@@ -807,6 +905,8 @@ camera_core_open(struct inode *inode, struct file *file)
 	int minor = iminor(inode);
 	struct camera_device *cam = camera_dev;
 	struct camera_fh *fh;
+	struct v4l2_format format;
+	int rval;
 
 	if (!cam || !cam->vfd || (cam->vfd->minor != minor))
 		return -ENODEV;
@@ -821,11 +921,20 @@ camera_core_open(struct inode *inode, struct file *file)
 
 	spin_lock(&cam->img_lock);
 	if (cam->active == 1) {
-		dev_err(&cam->dev, "Camera device Active\n");
+		dev_err(cam->dev, "Camera device Active\n");
 		spin_unlock(&cam->img_lock);
-		return -EPERM;
+		rval = -EPERM;
+		goto err;
 	}
 	cam->active = 1;
+
+	if (cam->sdev == NULL || !try_module_get(cam->sdev->module)) {
+		spin_unlock(&cam->img_lock);
+		rval = -ENODEV;
+		goto err;
+	}
+
+	vidioc_int_g_fmt_cap(cam->sdev, &format);
 	spin_unlock(&cam->img_lock);
 
 	videobuf_queue_init(&fh->vbq, &cam->vbq_ops, NULL, &cam->vbq_lock,
@@ -835,60 +944,64 @@ camera_core_open(struct inode *inode, struct file *file)
 	cam->capture_started = 0;
 
 	if (cam->cam_hardware->open(cam->hardware_data)) {
-		dev_err(&cam->dev, "Camera IF configuration failed\n");
+		dev_err(cam->dev, "Camera IF configuration failed\n");
 		cam->active = 0;
-		return -ENODEV;
+		rval = -ENODEV;
+		goto err;
 	}
-
-	cam->xclk = cam->cam_hardware->set_xclk(cam->xclk, cam->hardware_data);
-	/* program the sensor for the capture format and rate */
-	if (cam->cam_sensor->configure(&cam->pix, cam->xclk,
-				&cam->cparm.timeperframe, cam->sensor_data)) {
-		dev_err(&cam->dev, "Camera sensor configuration failed\n");
+	rval = vidioc_s_fmt_cap(file, fh, &format);
+	if (rval) {
+		dev_err(cam->dev, "Camera sensor configuration failed (%d)\n", rval);
 		cam->cam_hardware->close(cam->hardware_data);
 		cam->active = 0;
-		return -ENODEV;
+		rval = -ENODEV;
+		goto err;
 	}
 
 	return 0;
+
+err:
+	module_put(cam->sdev->module);
+	kfree(fh);
+	return rval;
 }
 
 #ifdef CONFIG_PM
 static int camera_core_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	struct camera_device *cam = platform_get_drvdata(pdev);
-	int ret = 0;
 
 	spin_lock(&cam->img_lock);
 	if (cam->active)
 		cam->cam_hardware->close(cam->hardware_data);
 
-	cam->cam_sensor->power_off(cam->sensor_data);
+	vidioc_int_s_power(cam->sdev, 0);
 	spin_unlock(&cam->img_lock);
 
-	return ret;
+	return 0;
 }
 
 static int camera_core_resume(struct platform_device *pdev)
 {
 	struct camera_device *cam = platform_get_drvdata(pdev);
-	int ret = 0;
 
 	spin_lock(&cam->img_lock);
-	cam->cam_sensor->power_on(cam->sensor_data);
+	vidioc_int_s_power(cam->sdev, 1);
 	if (cam->active) {
+		struct v4l2_format format;
+
 		cam->capture_completed = 1;
 		cam->cam_hardware->open(cam->hardware_data);
-		cam->cam_hardware->set_xclk(cam->xclk, cam->hardware_data);
 
-		cam->cam_sensor->configure(&cam->pix, cam->xclk,
-					   &cam->cparm.timeperframe,
-					   cam->sensor_data);
+		vidioc_int_g_fmt_cap(cam->sdev, &format);
+		vidioc_int_s_fmt_cap(cam->sdev, &format);
+		camera_sensor_if_enable(cam);
+
 		camera_core_sgdma_process(cam);
 	}
 	spin_unlock(&cam->img_lock);
 
-	return ret;
+	return 0;
 }
 #endif	/* CONFIG_PM */
 
@@ -902,29 +1015,50 @@ static struct file_operations camera_core_fops = {
 	.open			= camera_core_open,
 	.release		= camera_core_release,
 };
+static ssize_t
+camera_streaming_show(struct device *dev, struct device_attribute *attr,
+		char *buf)
+{
+	struct camera_device *cam = dev_get_drvdata(dev);
 
-static int __init camera_core_probe(struct platform_device *pdev)
+	return sprintf(buf, "%s\n", cam->streaming ?  "active" : "inactive");
+}
+
+static DEVICE_ATTR(streaming, S_IRUGO, camera_streaming_show, NULL);
+
+static void camera_device_unregister(struct v4l2_int_device *ctl)
 {
-	struct camera_device *cam;
+	struct camera_device *cam = ctl->priv;
+
+	camera_sensor_exit(cam);
+}
+
+static int camera_device_register(struct v4l2_int_device *ctl,
+				       struct v4l2_int_device *s)
+{
+	struct camera_device *cam = ctl->priv;
 	struct video_device *vfd;
-	int	status;
+	int rval;
+	/*Initialise the pointer to the sensor interface and camera interface */
 
-	cam = kzalloc(sizeof(struct camera_device), GFP_KERNEL);
-	if (!cam) {
-		dev_err(&cam->dev, "could not allocate memory\n");
-		status = -ENOMEM;
-		goto err0;
-	}
+	/* We already have a slave. */
+	if (cam->sdev)
+		return -EBUSY;
 
-	/* Save the pointer to camera device in a global variable */
-	camera_dev = cam;
+	cam->sdev = s;
+
+	if (device_create_file(cam->dev, &dev_attr_streaming) != 0) {
+		dev_err(cam->dev, "could not register sysfs entry\n");
+		rval = -EBUSY;
+		goto err;
+	}
 
 	/* initialize the video_device struct */
 	vfd = cam->vfd = video_device_alloc();
 	if (!vfd) {
-		dev_err(&cam->dev, " could not allocate video device struct\n");
-		status = -ENOMEM;
-		goto err1;
+		dev_err(cam->dev, " could not allocate video device struct\n");
+		rval = -ENOMEM;
+		goto err;
 	}
 
 	vfd->release = video_device_release;
@@ -959,6 +1093,74 @@ static int __init camera_core_probe(struct platform_device *pdev)
 	vfd->vidioc_s_fbuf = vidioc_s_fbuf;
 	vfd->vidioc_overlay = vidioc_overlay;
 
+
+	dev_info(cam->dev, "%s interface with %s sensor\n",
+		cam->cam_hardware->name, cam->sdev->name);
+
+	if (video_register_device(vfd, VFL_TYPE_GRABBER, video_nr) < 0) {
+		dev_err(cam->dev, "could not register Video for Linux device\n");
+		rval = -ENODEV;
+		goto err;
+	}
+
+
+	rval = camera_sensor_init(cam);
+	if (rval)
+		goto err;
+
+	/* Disable the Camera after detection */
+	cam->cam_hardware->disable(cam->hardware_data);
+
+	return 0;
+
+err:
+	camera_device_unregister(ctl);
+
+	return rval;
+}
+
+static struct v4l2_int_master camera_master = {
+	.attach = camera_device_register,
+	.detach = camera_device_unregister,
+};
+
+static struct v4l2_int_device camera = {
+	.module	= THIS_MODULE,
+	.name	= CAM_NAME,
+	.type	= v4l2_int_type_master,
+	.u	= {
+		.master = &camera_master
+	},
+};
+
+static int __init camera_core_probe(struct platform_device *pdev)
+{
+	struct camera_device *cam;
+	int	status = 0;
+
+	cam = kzalloc(sizeof(struct camera_device), GFP_KERNEL);
+	if (!cam) {
+		dev_err(&pdev->dev, "could not allocate memory\n");
+		status = -ENOMEM;
+		goto err;
+	}
+
+	platform_set_drvdata(pdev, cam);
+
+	cam->dev = &pdev->dev;
+
+	/* initialize the camera interface */
+	cam->cam_hardware = &camera_hardware_if;
+	cam->hardware_data = cam->cam_hardware->init();
+	if (!cam->hardware_data) {
+		dev_err(cam->dev, "cannot initialize interface hardware\n");
+		status = -ENODEV;
+		goto err;
+	}
+
+	/* Save the pointer to camera device in a global variable */
+	camera_dev = cam;
+
 	/* initialize the videobuf queue ops */
 	cam->vbq_ops.buf_setup = camera_core_vbq_setup;
 	cam->vbq_ops.buf_prepare = camera_core_vbq_prepare;
@@ -973,102 +1175,38 @@ static int __init camera_core_probe(struct platform_device *pdev)
 					(dma_addr_t *) &cam->overlay_base_phys,
 					GFP_KERNEL | GFP_DMA);
 		if (!cam->overlay_base) {
-			dev_err(&cam->dev, "cannot allocate overlay framebuffer\n");
+			dev_err(cam->dev, "cannot allocate overlay framebuffer\n");
 			status = -ENOMEM;
-			goto err2;
+			goto err;
 		}
 	}
 	memset((void*)cam->overlay_base, 0, cam->overlay_size);
 	spin_lock_init(&cam->overlay_lock);
 	spin_lock_init(&cam->capture_lock);
 
-	/*Initialise the pointer to the sensor interface and camera interface */
-	cam->cam_sensor = &camera_sensor_if;
-	cam->cam_hardware = &camera_hardware_if;
-
-	/* initialize the camera interface */
-	cam->hardware_data = cam->cam_hardware->init();
-	if (!cam->hardware_data) {
-		dev_err(&cam->dev, "cannot initialize interface hardware\n");
-		status = -ENODEV;
-		goto err3;
-	}
-
 	/* initialize the spinlock used to serialize access to the image
 	 * parameters
 	 */
 	spin_lock_init(&cam->img_lock);
 
-	/* initialize the streaming capture parameters */
-	cam->cparm.capability = V4L2_CAP_TIMEPERFRAME;
-	cam->cparm.readbuffers = 1;
-
-	/* Enable the xclk output.  The sensor may (and does, in the case of
-	 * the OV9640) require an xclk input in order for its initialization
-	 * routine to work.
-	 */
-	cam->xclk = 21000000;	/* choose an arbitrary xclk frequency */
-	cam->xclk = cam->cam_hardware->set_xclk(cam->xclk, cam->hardware_data);
-
-	/* initialize the sensor and define a default capture format cam->pix */
-	cam->sensor_data = cam->cam_sensor->init(&cam->pix);
-	if (!cam->sensor_data) {
-		cam->cam_hardware->disable(cam->hardware_data);
-		dev_err(&cam->dev, "cannot initialize sensor\n");
-		status = -ENODEV;
-		goto err4;
-	}
-
-	dev_info(&cam->dev, "%s interface with %s sensor\n",
-		cam->cam_hardware->name, cam->cam_sensor->name);
-
-	/* select an arbitrary default capture frame rate of 15fps */
-	cam->nominal_timeperframe.numerator = 1;
-	cam->nominal_timeperframe.denominator = 15;
-
-	/* calculate xclk based on the default capture format and default
-	 * frame rate
-	 */
-	cam->xclk = cam->cam_sensor->calc_xclk(&cam->pix,
-		&cam->nominal_timeperframe, cam->sensor_data);
-	cam->cparm.timeperframe = cam->nominal_timeperframe;
-
 	/* initialise the wait queue */
 	init_waitqueue_head(&cam->new_video_frame);
 
 	/* Initialise the DMA structures */
 	camera_core_sgdma_init(cam);
 
-	/* Disable the Camera after detection */
-	cam->cam_hardware->disable(cam->hardware_data);
-
 	platform_set_drvdata(pdev, cam);
 
-	if (video_register_device(vfd, VFL_TYPE_GRABBER, video_nr) < 0) {
-		dev_err(&cam->dev, "could not register Video for Linux device\n");
-		status = -ENODEV;
-		goto err5;
-	}
+	camera.priv = cam;
 
-	dev_info(&cam->dev, "registered device video%d [v4l2]\n", vfd->minor);
+	if (v4l2_int_device_register(&camera))
+		goto err;
 
 	return 0;
 
- err5:
-	cam->cam_sensor->cleanup(cam->sensor_data);
- err4:
-	cam->cam_hardware->cleanup(cam->hardware_data);
- err3:
-	dma_free_coherent(NULL, cam->overlay_size,
-				(void *)cam->overlay_base,
-				cam->overlay_base_phys);
+ err:
+	vidioc_int_dev_exit(cam->sdev);
 	cam->overlay_base = 0;
- err2:
-	video_device_release(vfd);
- err1:
-	kfree(cam);
-	camera_dev = NULL;
- err0:
 	return status;
 }
 
@@ -1100,7 +1238,7 @@ static int camera_core_remove(struct platform_device *pdev)
 	}
 	cam->overlay_base_phys = 0;
 
-	cam->cam_sensor->cleanup(cam->sensor_data);
+	vidioc_int_dev_exit(cam->sdev);
 	cam->cam_hardware->cleanup(cam->hardware_data);
 	kfree(cam);
 	camera_dev = NULL;
diff --git a/drivers/media/video/omap/camera_core.h b/drivers/media/video/omap/camera_core.h
index a300d67..e156cc3 100644
--- a/drivers/media/video/omap/camera_core.h
+++ b/drivers/media/video/omap/camera_core.h
@@ -19,6 +19,7 @@ struct camera_fh;
 
 #include <media/video-buf.h>
 #include <asm/scatterlist.h>
+#include <media/v4l2-int-device.h>
 
 struct camera_device;
 typedef void (*dma_callback_t)(void *arg1, void *arg2);
@@ -39,7 +40,7 @@ struct sgdma_state {
 
 /* per-device data structure */
 struct camera_device {
-	struct device dev;
+	struct device *dev;
 	struct video_device *vfd;
 
 	spinlock_t overlay_lock;        /* spinlock for overlay DMA counter */
@@ -80,18 +81,18 @@ struct camera_device {
 	 */
 	struct camera_fh *previewing;
 
-	/* capture parameters (frame rate, number of buffers) */
-	struct v4l2_captureparm cparm;
-
-	/* This is the frame period actually requested by the user. */
-	struct v4l2_fract nominal_timeperframe;
-
-	/* frequency (in Hz) of camera interface xclk output */
-	unsigned long xclk;
-
+	/*
+	 * Sensor interface parameters: interface type, CC_CTRL
+	 * register value and interface specific data.
+	 */
+	int if_type;
+	union {
+		struct parallel {
+			u32 xclk;
+		} bt656;
+	} if_u;
 	/* Pointer to the sensor interface ops */
-	struct omap_camera_sensor *cam_sensor;
-	void *sensor_data;
+	struct v4l2_int_device *sdev;
 
 	/* Pointer to the camera interface hardware ops */
 	struct camera_hardware *cam_hardware;
@@ -104,7 +105,6 @@ struct camera_device {
 	 * VIDIOC_S_FMT/VIDIOC_G_FMT ioctls with a CAPTURE buffer type.
 	 */
 	struct v4l2_pix_format pix;
-	struct v4l2_pix_format pix2;
 
 	/* crop defines the size and offset of the video overlay source window
 	 * within the framebuffer.  These parameters are set/queried by the
-- 
1.5.3.4.206.g58ba4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/6] OMAP1: CAMERA: Changed camera_core.c to the coding style standard
  2007-10-09 12:52       ` [PATCH 4/6] OMAP1: CAMERA: Convert camera_core.c to use v4l2-int-device API Eduardo Valentin
@ 2007-10-09 12:52         ` Eduardo Valentin
  2007-10-09 12:52           ` [PATCH 6/6] OMAP1: CAMERA: Remove unecessary files from Makefile and Kconfig Eduardo Valentin
  0 siblings, 1 reply; 13+ messages in thread
From: Eduardo Valentin @ 2007-10-09 12:52 UTC (permalink / raw)
  To: linux-omap-mailing-list; +Cc: Eduardo Valentin

From: Eduardo Valentin <eduardo.valentin@indt.org.br>

- Executed Lindent on camera_core.c
- Removed extra blank spaces
- Lines with more than 80 columns were broken

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
 drivers/media/video/omap/camera_core.c |  403 +++++++++++++++-----------------
 1 files changed, 191 insertions(+), 212 deletions(-)

diff --git a/drivers/media/video/omap/camera_core.c b/drivers/media/video/omap/camera_core.c
index 217a79f..1d47212 100644
--- a/drivers/media/video/omap/camera_core.c
+++ b/drivers/media/video/omap/camera_core.c
@@ -40,24 +40,22 @@
 static struct camera_device *camera_dev;
 static void camera_core_sgdma_process(struct camera_device *cam);
 
-/* module parameters */
-static int video_nr = -1;	/* video device minor (-1 ==> auto assign) */
+/* Module parameters */
+static int video_nr = -1;	/* Video device minor (-1 ==> auto assign) */
 
 /* Maximum amount of memory to use for capture buffers.
  * Default is 4800KB, enough to double-buffer SXGA.
  */
-static int capture_mem = 1280*960*2*2;
+static int capture_mem = 1280 * 960 * 2 * 2;
 
-/*Size of video overlay framebuffer. This determines the maximum image size
- *that can be previewed. Default is 600KB, enough for sxga.
+/* Size of video overlay framebuffer. This determines the maximum image size
+ * that can be previewed. Default is 600KB, enough for sxga.
  */
-static int overlay_mem = 640*480*2;
+static int overlay_mem = 640 * 480 * 2;
 
-
-/*
- * Enable the external sensor interface. Try to negotiate interface
+/* Enable the external sensor interface. Try to negotiate interface
  * parameters with the sensor and start using the new ones. The calls
- * to sensor_if_enable and sensor_if_disable need not to be balanced.
+ * to sensor_if_enable and sensor_if_disable do not need to be balanced.
  */
 static int camera_sensor_if_enable(struct camera_device *cam)
 {
@@ -75,8 +73,8 @@ static int camera_sensor_if_enable(struct camera_device *cam)
 	switch (p.if_type) {
 	case V4L2_IF_TYPE_BT656:
 		cam->if_u.bt656.xclk =
-			cam->cam_hardware->set_xclk(cam->if_u.bt656.xclk,
-						    cam->hardware_data);
+		    cam->cam_hardware->set_xclk(cam->if_u.bt656.xclk,
+						cam->hardware_data);
 		break;
 	default:
 		/* FIXME: how about other interfaces? */
@@ -96,9 +94,7 @@ static void camera_sensor_if_disable(const struct camera_device *cam)
 	}
 }
 
-/*
- * Initialise the sensor hardware.
- */
+/* Initialize the sensor hardware. */
 static int camera_sensor_init(struct camera_device *cam)
 {
 	int err = 0;
@@ -109,7 +105,8 @@ static int camera_sensor_init(struct camera_device *cam)
 	 * routine to work.
 	 */
 
-	cam->if_u.bt656.xclk = 21000000;/* choose an arbitrary xclk frequency */
+	/* Choose an arbitrary xclk frequency */
+	cam->if_u.bt656.xclk = 21000000;
 
 	cam->if_u.bt656.xclk = cam->cam_hardware->set_xclk(cam->if_u.bt656.xclk,
 							   cam->hardware_data);
@@ -117,18 +114,18 @@ static int camera_sensor_init(struct camera_device *cam)
 	err = camera_sensor_if_enable(cam);
 	if (err) {
 		dev_err(cam->dev, "sensor interface could not be enabled at "
-			"initialisation, %d\n", err);
+			"initialization, %d\n", err);
 		cam->sdev = NULL;
 		goto out;
 	}
 
-	/* power up sensor during sensor initialization */
+	/* Power up sensor during sensor initialization */
 	vidioc_int_s_power(sdev, 1);
 
 	err = vidioc_int_dev_init(sdev);
 	if (err) {
 		dev_err(cam->dev, "cannot initialize sensor, error %d\n", err);
-		/* Sensor init failed --- it's nonexistent to us! */
+		/* Sensor initialization failed --- it's nonexistent to us! */
 		cam->sdev = NULL;
 		goto out;
 	}
@@ -149,10 +146,10 @@ static void camera_sensor_exit(struct camera_device *cam)
 		vidioc_int_dev_exit(cam->sdev);
 }
 
-/* DMA completion routine for the scatter-gather DMA fragments. */
-/* This function is called when a scatter DMA fragment is completed */
-static void
-camera_core_callback_sgdma(void *arg1, void *arg2)
+/* DMA completion routine for the scatter-gather DMA fragments.
+ * This function is called when a scatter DMA fragment is completed
+ */
+static void camera_core_callback_sgdma(void *arg1, void *arg2)
 {
 	struct camera_device *cam = (struct camera_device *)arg1;
 	int sgslot = (int)arg2;
@@ -167,16 +164,17 @@ camera_core_callback_sgdma(void *arg1, void *arg2)
 		return;
 	}
 	if (!--sgdma->queued_sglist) {
-		/* queue for this sglist is empty so check whether transfer
-		** of the frame has been completed */
+		/* Queue for this sglist is empty so check whether transfer
+		 * of the frame has been completed
+		 */
 		if (sgdma->next_sglist == sgdma->sglen) {
 			dma_callback_t callback = sgdma->callback;
 			void *arg = sgdma->arg;
-			/* all done with this sglist */
+			/* All done with this sglist */
 			cam->free_sgdma++;
 			if (callback) {
 				spin_unlock(&cam->sg_lock);
-				(*callback)(cam, arg);
+				(*callback) (cam, arg);
 				camera_core_sgdma_process(cam);
 				return;
 			}
@@ -188,8 +186,7 @@ camera_core_callback_sgdma(void *arg1, void *arg2)
 	return;
 }
 
-static void
-camera_core_sgdma_init(struct camera_device *cam)
+static void camera_core_sgdma_init(struct camera_device *cam)
 {
 	int sg;
 
@@ -209,12 +206,10 @@ camera_core_sgdma_init(struct camera_device *cam)
 	}
 }
 
-/*
- * Process the scatter-gather DMA queue by starting queued transfers
- * This function is called to program the dma to start the transfer of an image.
+/* Process the scatter-gather DMA queue by starting queued transfers
+ * This function is called to program the DMA to start the transfer of an image.
  */
-static void
-camera_core_sgdma_process(struct camera_device *cam)
+static void camera_core_sgdma_process(struct camera_device *cam)
 {
 	unsigned long irqflags;
 	int queued_sgdma, sgslot;
@@ -235,18 +230,20 @@ camera_core_sgdma_process(struct camera_device *cam)
 		sgdma = cam->sgdma + sgslot;
 		while (sgdma->next_sglist < sgdma->sglen) {
 			sglist = sgdma->sglist + sgdma->next_sglist;
-			if (cam->cam_hardware->start_dma(sgdma, camera_core_callback_sgdma,
-				(void *)cam, (void *)sgslot, cam->hardware_data)) {
-					/* dma start failed */
-					cam->in_use = 0;
-					return;
+			if (cam->cam_hardware->
+			    start_dma(sgdma, camera_core_callback_sgdma,
+				      (void *)cam, (void *)sgslot,
+				      cam->hardware_data)) {
+				/* DMA start failed */
+				cam->in_use = 0;
+				return;
 			} else {
-				/* dma start successful */
-				sgdma->next_sglist ++;
-				sgdma->queued_sglist ++;
+				/* DMA start successful */
+				sgdma->next_sglist++;
+				sgdma->queued_sglist++;
 			}
 		}
-		queued_sgdma-- ;
+		queued_sgdma--;
 		sgslot = (sgslot + 1) % (NUM_SG_DMA);
 	}
 
@@ -257,10 +254,10 @@ camera_core_sgdma_process(struct camera_device *cam)
  * Returns zero if the transfer was successfully queued, or
  * non-zero if all of the scatter-gather slots are already in use.
  */
-static int
-camera_core_sgdma_queue(struct camera_device *cam,
-        const struct scatterlist *sglist, int sglen, dma_callback_t callback,
-        void *arg)
+static int camera_core_sgdma_queue(struct camera_device *cam,
+				   const struct scatterlist *sglist,
+				   int sglen, dma_callback_t callback,
+				   void *arg)
 {
 	unsigned long irqflags;
 	struct sgdma_state *sgdma;
@@ -295,21 +292,19 @@ camera_core_sgdma_queue(struct camera_device *cam,
 	return 0;
 }
 
-
-/* -------------------overlay routines ------------------------------*/
-/* callback routine for overlay DMA completion. We just start another DMA
+/* -------------------overlay routines ------------------------------
+ * Callback routine for overlay DMA completion. We just start another DMA
  * transfer unless overlay has been turned off
  */
-
-static void
-camera_core_overlay_callback(void *arg1, void *arg)
+static void camera_core_overlay_callback(void *arg1, void *arg)
 {
 	struct camera_device *cam = (struct camera_device *)arg1;
 	int err;
 	unsigned long irqflags;
 	int i, j;
 	int count, index;
-	unsigned char *fb_buf = phys_to_virt((unsigned long)camera_dev->fbuf.base);
+	unsigned char *fb_buf =
+	    phys_to_virt((unsigned long)camera_dev->fbuf.base);
 
 	spin_lock_irqsave(&cam->overlay_lock, irqflags);
 
@@ -324,12 +319,13 @@ camera_core_overlay_callback(void *arg1, void *arg)
 
 	count = 0;
 	j = ((cam->pix.width - 1) * cam->fbuf.fmt.bytesperline);
-	for (i = 0 ; i < cam->pix.sizeimage; i += cam->pix.bytesperline) {
+	for (i = 0; i < cam->pix.sizeimage; i += cam->pix.bytesperline) {
 		for (index = 0; index < cam->pix.bytesperline; index++) {
-			fb_buf[j] = *(((unsigned char *) cam->overlay_base) +
-								 i + index);
+			fb_buf[j] = *(((unsigned char *)cam->overlay_base) +
+				      i + index);
 			index++;
-			fb_buf[j + 1] = *(((unsigned char *) cam->overlay_base) + i + index);
+			fb_buf[j + 1] =
+			    *(((unsigned char *)cam->overlay_base) + i + index);
 			j = j - cam->fbuf.fmt.bytesperline;
 		}
 		count += 2;
@@ -338,7 +334,8 @@ camera_core_overlay_callback(void *arg1, void *arg)
 
 	while (cam->overlay_cnt < 2) {
 		err = camera_core_sgdma_queue(cam, &cam->overlay_sglist, 1,
-			camera_core_overlay_callback, NULL);
+					      camera_core_overlay_callback,
+					      NULL);
 		if (err)
 			break;
 		++cam->overlay_cnt;
@@ -348,9 +345,7 @@ camera_core_overlay_callback(void *arg1, void *arg)
 
 }
 
-
-static void
-camera_core_start_overlay(struct camera_device *cam)
+static void camera_core_start_overlay(struct camera_device *cam)
 {
 	int err;
 	unsigned long irqflags;
@@ -361,10 +356,11 @@ camera_core_start_overlay(struct camera_device *cam)
 	spin_lock_irqsave(&cam->overlay_lock, irqflags);
 
 	sg_dma_address(&cam->overlay_sglist) = cam->overlay_base_phys;
-	sg_dma_len(&cam->overlay_sglist)= cam->pix.sizeimage;
+	sg_dma_len(&cam->overlay_sglist) = cam->pix.sizeimage;
 	while (cam->overlay_cnt < 2) {
 		err = camera_core_sgdma_queue(cam, &cam->overlay_sglist, 1,
-				camera_core_overlay_callback, NULL);
+					      camera_core_overlay_callback,
+					      NULL);
 		if (err)
 			break;
 		++cam->overlay_cnt;
@@ -373,13 +369,11 @@ camera_core_start_overlay(struct camera_device *cam)
 	spin_unlock_irqrestore(&cam->overlay_lock, irqflags);
 }
 
-/* ------------------ videobuf_queue_ops --------------------------------*/
-
-/* This routine is called from interrupt context when a scatter-gather DMA
+/* ------------------ videobuf_queue_ops --------------------------------
+ * This routine is called from interrupt context when a scatter-gather DMA
  * transfer of a videobuf_buffer completes.
  */
-static void
-camera_core_vbq_complete(void *arg1, void *arg)
+static void camera_core_vbq_complete(void *arg1, void *arg)
 {
 	struct camera_device *cam = (struct camera_device *)arg1;
 	struct videobuf_buffer *vb = (struct videobuf_buffer *)arg;
@@ -396,8 +390,8 @@ camera_core_vbq_complete(void *arg1, void *arg)
 	spin_unlock(&cam->vbq_lock);
 }
 
-static void
-camera_core_vbq_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
+static void camera_core_vbq_release(struct videobuf_queue *q,
+				    struct videobuf_buffer *vb)
 {
 	videobuf_waiton(vb, 0, 0);
 	videobuf_dma_unmap(q, &vb->dma);
@@ -410,14 +404,14 @@ camera_core_vbq_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
  * number requested, the currently selected image size, and the maximum
  * amount of memory permitted for kernel capture buffers.
  */
-static int
-camera_core_vbq_setup(struct videobuf_queue *q, unsigned int *cnt, unsigned int *size)
+static int camera_core_vbq_setup(struct videobuf_queue *q, unsigned int *cnt,
+				 unsigned int *size)
 {
 	struct camera_fh *fh = q->priv_data;
 	struct camera_device *cam = fh->cam;
 
 	if (*cnt <= 0)
-		*cnt = VIDEO_MAX_FRAME; /* supply a default number of buffers */
+		*cnt = VIDEO_MAX_FRAME;	/* Supply a default number of buffers */
 
 	if (*cnt > VIDEO_MAX_FRAME)
 		*cnt = VIDEO_MAX_FRAME;
@@ -432,9 +426,9 @@ camera_core_vbq_setup(struct videobuf_queue *q, unsigned int *cnt, unsigned int
 	return 0;
 }
 
-static int
-camera_core_vbq_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
-        enum v4l2_field field)
+static int camera_core_vbq_prepare(struct videobuf_queue *q,
+				   struct videobuf_buffer *vb,
+				   enum v4l2_field field)
 {
 	struct camera_fh *fh = q->priv_data;
 	struct camera_device *cam = fh->cam;
@@ -457,13 +451,13 @@ camera_core_vbq_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
 	if (!err)
 		vb->state = STATE_PREPARED;
 	else
-		camera_core_vbq_release (q, vb);
+		camera_core_vbq_release(q, vb);
 
 	return err;
 }
 
-static void
-camera_core_vbq_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
+static void camera_core_vbq_queue(struct videobuf_queue *q,
+				  struct videobuf_buffer *vb)
 {
 	struct camera_fh *fh = q->priv_data;
 	struct camera_device *cam = fh->cam;
@@ -472,25 +466,20 @@ camera_core_vbq_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
 
 	vb->state = STATE_QUEUED;
 	err = camera_core_sgdma_queue(cam, vb->dma.sglist, vb->dma.sglen,
-                camera_core_vbq_complete, vb);
+				      camera_core_vbq_complete, vb);
 	if (err) {
 		/* Oops.  We're not supposed to get any errors here.  The only
-		* way we could get an error is if we ran out of scatter-gather
-		* DMA slots, but we are supposed to have at least as many
-		* scatter-gather DMA slots as video buffers so that can't
-		* happen.
-		*/
+		 * way we could get an error is if we ran out of scatter-gather
+		 * DMA slots, but we are supposed to have at least as many
+		 * scatter-gather DMA slots as video buffers so that can't
+		 * happen.
+		 */
 		dev_dbg(cam->dev, "Failed to queue a video buffer for SGDMA\n");
 		vb->state = state;
 	}
 }
 
-
-/*
- *
- * IOCTL interface.
- *
- */
+/* IOCTL interface. */
 static int vidioc_querycap(struct file *file, void *fh,
 			   struct v4l2_capability *cap)
 {
@@ -501,10 +490,8 @@ static int vidioc_querycap(struct file *file, void *fh,
 	strlcpy(cap->card, cam->vfd->name, sizeof(cap->card));
 	cap->version = OMAP1CAM_VERSION;
 	cap->capabilities =
-		V4L2_CAP_VIDEO_CAPTURE |
-		V4L2_CAP_VIDEO_OVERLAY |
-		V4L2_CAP_READWRITE |
-		V4L2_CAP_STREAMING;
+	    V4L2_CAP_VIDEO_CAPTURE |
+	    V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
 
 	return 0;
 }
@@ -512,27 +499,25 @@ static int vidioc_querycap(struct file *file, void *fh,
 static int vidioc_enum_fmt_cap(struct file *file, void *fh,
 			       struct v4l2_fmtdesc *f)
 {
-	struct camera_fh *ofh  = fh;
+	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
 
 	return vidioc_int_enum_fmt_cap(cam->sdev, f);
 }
 
-static int vidioc_g_fmt_cap(struct file *file, void *fh,
-			    struct v4l2_format *f)
+static int vidioc_g_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
 {
-	struct camera_fh *ofh  = fh;
+	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
 
-	/* get the current format */
+	/* Get the current format */
 	memset(&f->fmt.pix, 0, sizeof(f->fmt.pix));
 	f->fmt.pix = cam->pix;
 
 	return 0;
 }
 
-static int vidioc_s_fmt_cap(struct file *file, void *fh,
-			    struct v4l2_format *f)
+static int vidioc_s_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
 {
 	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
@@ -565,8 +550,7 @@ static int vidioc_reqbufs(struct file *file, void *fh,
 	return videobuf_reqbufs(&ofh->vbq, b);
 }
 
-static int vidioc_querybuf(struct file *file, void *fh,
-			   struct v4l2_buffer *b)
+static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
 {
 	struct camera_fh *ofh = fh;
 
@@ -599,8 +583,7 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
 		return -EBUSY;
 	} else
 		cam->streaming = ofh;
-		/* FIXME: start camera interface */
-
+	/* FIXME: start camera interface */
 
 	spin_unlock(&cam->img_lock);
 
@@ -620,7 +603,7 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
 	spin_lock(&cam->img_lock);
 	if (cam->streaming == ofh)
 		cam->streaming = NULL;
-		/* FIXME: stop camera interface */
+	/* FIXME: stop camera interface */
 
 	spin_unlock(&cam->img_lock);
 	return 0;
@@ -662,8 +645,7 @@ static int vidioc_queryctrl(struct file *file, void *fh,
 	return vidioc_int_queryctrl(cam->sdev, a);
 }
 
-static int vidioc_g_ctrl(struct file *file, void *fh,
-			 struct v4l2_control *a)
+static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *a)
 {
 	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
@@ -671,8 +653,7 @@ static int vidioc_g_ctrl(struct file *file, void *fh,
 	return vidioc_int_g_ctrl(cam->sdev, a);
 }
 
-static int vidioc_s_ctrl(struct file *file, void *fh,
-			 struct v4l2_control *a)
+static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *a)
 {
 	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
@@ -711,15 +692,13 @@ static int vidioc_s_fbuf(struct file *file, void *fh,
 	return 0;
 }
 
-static int vidioc_overlay(struct file *file, void *fh,
-			 unsigned int i)
+static int vidioc_overlay(struct file *file, void *fh, unsigned int i)
 {
 	struct camera_fh *ofh = fh;
 	struct camera_device *cam = ofh->cam;
 	int enable = i;
 
-	/*
-	 * check whether the capture format and
+	/* Check whether the capture format and
 	 * the display format matches
 	 * return failure if they are different
 	 */
@@ -733,7 +712,7 @@ static int vidioc_overlay(struct file *file, void *fh,
 	    (cam->pix.height > cam->fbuf.fmt.width))
 		return -EINVAL;
 
-	if (!cam->previewing && enable)	{
+	if (!cam->previewing && enable) {
 		cam->previewing = fh;
 		cam->overlay_cnt = 0;
 		camera_core_start_overlay(cam);
@@ -743,22 +722,17 @@ static int vidioc_overlay(struct file *file, void *fh,
 	return 0;
 }
 
-/*
- *  file operations
- */
-
-static unsigned
-int camera_core_poll(struct file *file, struct poll_table_struct *wait)
+/* File operations */
+static unsigned int camera_core_poll(struct file *file,
+				     struct poll_table_struct *wait)
 {
 	return -EINVAL;
 }
 
-/* ------------------------------------------------------------ */
-/* callback routine for read DMA completion. We just start another DMA
+/* Callback routine for read DMA completion. We just start another DMA
  * transfer unless overlay has been turned off
  */
-static void
-camera_core_capture_callback(void *arg1, void *arg)
+static void camera_core_capture_callback(void *arg1, void *arg)
 {
 	struct camera_device *cam = (struct camera_device *)arg1;
 	int err;
@@ -778,33 +752,38 @@ camera_core_capture_callback(void *arg1, void *arg)
 		sg_dma_address(&cam->capture_sglist) = cam->capture_base_phys;
 		sg_dma_len(&cam->capture_sglist) = cam->pix.sizeimage;
 		err = camera_core_sgdma_queue(cam, &cam->capture_sglist, 1,
-			camera_core_capture_callback, NULL);
+					      camera_core_capture_callback,
+					      NULL);
 	} else {
 		cam->capture_completed = 1;
 		if (cam->reading) {
 			/* Wake up any process which are waiting for the
-			** DMA to complete */
+			 * DMA to complete
+			 */
 			wake_up_interruptible(&camera_dev->new_video_frame);
-			sg_dma_address(&cam->capture_sglist) = cam->capture_base_phys;
+			sg_dma_address(&cam->capture_sglist) =
+			    cam->capture_base_phys;
 			sg_dma_len(&cam->capture_sglist) = cam->pix.sizeimage;
-			err = camera_core_sgdma_queue(cam, &cam->capture_sglist, 1,
-				camera_core_capture_callback, NULL);
+			err =
+			   camera_core_sgdma_queue(cam, &cam->capture_sglist,
+						   1,
+						   camera_core_capture_callback,
+						   NULL);
 		}
 	}
 
 	spin_unlock_irqrestore(&cam->capture_lock, irqflags);
 }
 
-
-static ssize_t
-camera_core_read(struct file *file, char *data, size_t count, loff_t *ppos)
+static ssize_t camera_core_read(struct file *file, char *data, size_t count,
+				loff_t *ppos)
 {
 	struct camera_fh *fh = file->private_data;
 	struct camera_device *cam = fh->cam;
 	int err;
 	unsigned long irqflags;
 	long timeout;
-#if 0	/* use video_buf to do capture */
+#if 0				/* Use video_buf to do capture */
 	int i;
 	for (i = 0; i < 14; i++)
 		videobuf_read_one(file, &fh->vbq, data, count, ppos);
@@ -813,10 +792,12 @@ camera_core_read(struct file *file, char *data, size_t count, loff_t *ppos)
 #endif
 
 	if (!cam->capture_base) {
-		cam->capture_base = (unsigned long)dma_alloc_coherent(NULL,
-				cam->pix.sizeimage,
-				(dma_addr_t *) &cam->capture_base_phys,
-				GFP_KERNEL | GFP_DMA);
+		cam->capture_base = (unsigned long)
+		    dma_alloc_coherent(NULL,
+				       cam->pix.sizeimage,
+				       (dma_addr_t *) &
+				       cam->capture_base_phys,
+				       GFP_KERNEL | GFP_DMA);
 	}
 	if (!cam->capture_base) {
 		dev_err(cam->dev, "cannot allocate capture buffer\n");
@@ -827,39 +808,37 @@ camera_core_read(struct file *file, char *data, size_t count, loff_t *ppos)
 	cam->reading = fh;
 	cam->capture_started = 1;
 	sg_dma_address(&cam->capture_sglist) = cam->capture_base_phys;
-	sg_dma_len(&cam->capture_sglist)= cam->pix.sizeimage;
+	sg_dma_len(&cam->capture_sglist) = cam->pix.sizeimage;
 	spin_unlock_irqrestore(&cam->capture_lock, irqflags);
 
 	err = camera_core_sgdma_queue(cam, &cam->capture_sglist, 1,
-			camera_core_capture_callback, NULL);
+				      camera_core_capture_callback, NULL);
 
 	/* Wait till DMA is completed */
 	timeout = HZ * 10;
 	cam->capture_completed = 0;
 	while (cam->capture_completed == 0) {
 		timeout = interruptible_sleep_on_timeout
-				(&cam->new_video_frame, timeout);
+		    (&cam->new_video_frame, timeout);
 		if (timeout == 0) {
 			dev_err(cam->dev, "timeout waiting video frame\n");
-			return -EIO; /* time out */
+			return -EIO;	/* Time out */
 		}
 	}
-	/* copy the data to the user buffer */
+	/* Copy the data to the user buffer */
 	err = copy_to_user(data, (void *)cam->capture_base, cam->pix.sizeimage);
 	return (cam->pix.sizeimage - err);
 
 }
 
-static int
-camera_core_mmap(struct file *file, struct vm_area_struct *vma)
+static int camera_core_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	struct camera_fh *fh = file->private_data;
 
 	return videobuf_mmap_mapper(&fh->vbq, vma);
 }
 
-static int
-camera_core_release(struct inode *inode, struct file *file)
+static int camera_core_release(struct inode *inode, struct file *file)
 {
 	struct camera_fh *fh = file->private_data;
 	struct camera_device *cam = fh->cam;
@@ -882,8 +861,8 @@ camera_core_release(struct inode *inode, struct file *file)
 
 	if (cam->capture_base) {
 		dma_free_coherent(NULL, cam->pix.sizeimage,
-					(void *)cam->capture_base,
-					cam->capture_base_phys);
+				  (void *)cam->capture_base,
+				  cam->capture_base_phys);
 		cam->capture_base = 0;
 		cam->capture_base_phys = 0;
 	}
@@ -899,8 +878,7 @@ camera_core_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static int
-camera_core_open(struct inode *inode, struct file *file)
+static int camera_core_open(struct inode *inode, struct file *file)
 {
 	int minor = iminor(inode);
 	struct camera_device *cam = camera_dev;
@@ -911,7 +889,7 @@ camera_core_open(struct inode *inode, struct file *file)
 	if (!cam || !cam->vfd || (cam->vfd->minor != minor))
 		return -ENODEV;
 
-	/* allocate per-filehandle data */
+	/* Allocate per-filehandle data */
 	fh = kmalloc(sizeof(*fh), GFP_KERNEL);
 	if (NULL == fh)
 		return -ENOMEM;
@@ -938,7 +916,8 @@ camera_core_open(struct inode *inode, struct file *file)
 	spin_unlock(&cam->img_lock);
 
 	videobuf_queue_init(&fh->vbq, &cam->vbq_ops, NULL, &cam->vbq_lock,
-		fh->type, V4L2_FIELD_NONE, sizeof(struct videobuf_buffer), fh);
+			    fh->type, V4L2_FIELD_NONE,
+			    sizeof(struct videobuf_buffer), fh);
 
 	cam->capture_completed = 0;
 	cam->capture_started = 0;
@@ -951,7 +930,8 @@ camera_core_open(struct inode *inode, struct file *file)
 	}
 	rval = vidioc_s_fmt_cap(file, fh, &format);
 	if (rval) {
-		dev_err(cam->dev, "Camera sensor configuration failed (%d)\n", rval);
+		dev_err(cam->dev, "Camera sensor configuration failed (%d)\n",
+			rval);
 		cam->cam_hardware->close(cam->hardware_data);
 		cam->active = 0;
 		rval = -ENODEV;
@@ -1003,25 +983,24 @@ static int camera_core_resume(struct platform_device *pdev)
 
 	return 0;
 }
-#endif	/* CONFIG_PM */
+#endif /* CONFIG_PM */
 
 static struct file_operations camera_core_fops = {
-	.owner			= THIS_MODULE,
-	.llseek			= no_llseek,
-	.read			= camera_core_read,
-	.poll			= camera_core_poll,
-	.ioctl			= video_ioctl2,
-	.mmap			= camera_core_mmap,
-	.open			= camera_core_open,
-	.release		= camera_core_release,
+	.owner		= THIS_MODULE,
+	.llseek		= no_llseek,
+	.read		= camera_core_read,
+	.poll		= camera_core_poll,
+	.ioctl		= video_ioctl2,
+	.mmap		= camera_core_mmap,
+	.open		= camera_core_open,
+	.release	= camera_core_release,
 };
-static ssize_t
-camera_streaming_show(struct device *dev, struct device_attribute *attr,
-		char *buf)
+static ssize_t camera_streaming_show(struct device *dev,
+				     struct device_attribute *attr, char *buf)
 {
 	struct camera_device *cam = dev_get_drvdata(dev);
 
-	return sprintf(buf, "%s\n", cam->streaming ?  "active" : "inactive");
+	return sprintf(buf, "%s\n", cam->streaming ? "active" : "inactive");
 }
 
 static DEVICE_ATTR(streaming, S_IRUGO, camera_streaming_show, NULL);
@@ -1034,12 +1013,11 @@ static void camera_device_unregister(struct v4l2_int_device *ctl)
 }
 
 static int camera_device_register(struct v4l2_int_device *ctl,
-				       struct v4l2_int_device *s)
+				  struct v4l2_int_device *s)
 {
 	struct camera_device *cam = ctl->priv;
 	struct video_device *vfd;
 	int rval;
-	/*Initialise the pointer to the sensor interface and camera interface */
 
 	/* We already have a slave. */
 	if (cam->sdev)
@@ -1053,7 +1031,7 @@ static int camera_device_register(struct v4l2_int_device *ctl,
 		goto err;
 	}
 
-	/* initialize the video_device struct */
+	/* Initialize the video_device struct */
 	vfd = cam->vfd = video_device_alloc();
 	if (!vfd) {
 		dev_err(cam->dev, " could not allocate video device struct\n");
@@ -1066,7 +1044,7 @@ static int camera_device_register(struct v4l2_int_device *ctl,
 	strlcpy(vfd->name, CAM_NAME, sizeof(vfd->name));
 	vfd->type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY | VID_TYPE_CHROMAKEY;
 
-	/* need to register for a VID_HARDWARE_* ID in videodev.h */
+	/* Need to register for a VID_HARDWARE_* ID in videodev.h */
 	vfd->hardware = 0;
 	vfd->fops = &camera_core_fops;
 	video_set_drvdata(vfd, cam);
@@ -1093,17 +1071,16 @@ static int camera_device_register(struct v4l2_int_device *ctl,
 	vfd->vidioc_s_fbuf = vidioc_s_fbuf;
 	vfd->vidioc_overlay = vidioc_overlay;
 
-
 	dev_info(cam->dev, "%s interface with %s sensor\n",
-		cam->cam_hardware->name, cam->sdev->name);
+		 cam->cam_hardware->name, cam->sdev->name);
 
 	if (video_register_device(vfd, VFL_TYPE_GRABBER, video_nr) < 0) {
-		dev_err(cam->dev, "could not register Video for Linux device\n");
+		dev_err(cam->dev,
+			"could not register Video for Linux device\n");
 		rval = -ENODEV;
 		goto err;
 	}
 
-
 	rval = camera_sensor_init(cam);
 	if (rval)
 		goto err;
@@ -1136,7 +1113,7 @@ static struct v4l2_int_device camera = {
 static int __init camera_core_probe(struct platform_device *pdev)
 {
 	struct camera_device *cam;
-	int	status = 0;
+	int status = 0;
 
 	cam = kzalloc(sizeof(struct camera_device), GFP_KERNEL);
 	if (!cam) {
@@ -1149,7 +1126,7 @@ static int __init camera_core_probe(struct platform_device *pdev)
 
 	cam->dev = &pdev->dev;
 
-	/* initialize the camera interface */
+	/* Initialize the camera interface */
 	cam->cam_hardware = &camera_hardware_if;
 	cam->hardware_data = cam->cam_hardware->init();
 	if (!cam->hardware_data) {
@@ -1161,38 +1138,41 @@ static int __init camera_core_probe(struct platform_device *pdev)
 	/* Save the pointer to camera device in a global variable */
 	camera_dev = cam;
 
-	/* initialize the videobuf queue ops */
+	/* Initialize the videobuf queue ops */
 	cam->vbq_ops.buf_setup = camera_core_vbq_setup;
 	cam->vbq_ops.buf_prepare = camera_core_vbq_prepare;
 	cam->vbq_ops.buf_queue = camera_core_vbq_queue;
 	cam->vbq_ops.buf_release = camera_core_vbq_release;
 
-	/* initilize the overlay interface */
+	/* Initialize the overlay interface */
 	cam->overlay_size = overlay_mem;
 	if (cam->overlay_size > 0) {
-		cam->overlay_base = (unsigned long) dma_alloc_coherent(NULL,
-					cam->overlay_size,
-					(dma_addr_t *) &cam->overlay_base_phys,
-					GFP_KERNEL | GFP_DMA);
+		cam->overlay_base = (unsigned long)
+		    dma_alloc_coherent(NULL,
+				       cam->overlay_size,
+				       (dma_addr_t *) &
+				       cam->overlay_base_phys,
+				       GFP_KERNEL | GFP_DMA);
 		if (!cam->overlay_base) {
-			dev_err(cam->dev, "cannot allocate overlay framebuffer\n");
+			dev_err(cam->dev,
+				"cannot allocate overlay framebuffer\n");
 			status = -ENOMEM;
 			goto err;
 		}
 	}
-	memset((void*)cam->overlay_base, 0, cam->overlay_size);
+	memset((void *)cam->overlay_base, 0, cam->overlay_size);
 	spin_lock_init(&cam->overlay_lock);
 	spin_lock_init(&cam->capture_lock);
 
-	/* initialize the spinlock used to serialize access to the image
+	/* Initialize the spinlock used to serialize access to the image
 	 * parameters
 	 */
 	spin_lock_init(&cam->img_lock);
 
-	/* initialise the wait queue */
+	/* Initialize the wait queue */
 	init_waitqueue_head(&cam->new_video_frame);
 
-	/* Initialise the DMA structures */
+	/* Initialize the DMA structures */
 	camera_core_sgdma_init(cam);
 
 	platform_set_drvdata(pdev, cam);
@@ -1204,7 +1184,7 @@ static int __init camera_core_probe(struct platform_device *pdev)
 
 	return 0;
 
- err:
+err:
 	vidioc_int_dev_exit(cam->sdev);
 	cam->overlay_base = 0;
 	return status;
@@ -1219,21 +1199,21 @@ static int camera_core_remove(struct platform_device *pdev)
 	if (vfd) {
 		if (vfd->minor == -1) {
 			/* The device never got registered, so release the
-			** video_device struct directly
-			*/
+			 * video_device struct directly
+			 */
 			video_device_release(vfd);
 		} else {
-			/* The unregister function will release the video_device
-			** struct as well as unregistering it.
-			*/
+			/* The unregister function will release the
+			 * video_device struct as well as unregistering it.
+			 */
 			video_unregister_device(vfd);
 		}
 		cam->vfd = NULL;
 	}
 	if (cam->overlay_base) {
 		dma_free_coherent(NULL, cam->overlay_size,
-					(void *)cam->overlay_base,
-					cam->overlay_base_phys);
+				  (void *)cam->overlay_base,
+				  cam->overlay_base_phys);
 		cam->overlay_base = 0;
 	}
 	cam->overlay_base_phys = 0;
@@ -1247,27 +1227,26 @@ static int camera_core_remove(struct platform_device *pdev)
 }
 
 static struct platform_driver camera_core_driver = {
-	.driver = {
-		.name		= CAM_NAME,
-		.owner		= THIS_MODULE,
+	.driver	= {
+		.name	= CAM_NAME,
+		.owner	= THIS_MODULE,
 	},
-	.probe			= camera_core_probe,
-	.remove			= camera_core_remove,
+	.probe		= camera_core_probe,
+	.remove		= camera_core_remove,
 #ifdef CONFIG_PM
-	.suspend		= camera_core_suspend,
-	.resume			= camera_core_resume,
+	.suspend	= camera_core_suspend,
+	.resume		= camera_core_resume,
 #endif
 };
 
 /* FIXME register omap16xx or omap24xx camera device in arch/arm/...
- * system init code, with its resources and mux setup, NOT here.
+ * system initialization code, with its resources and mux setup, NOT here.
  * Then MODULE_ALIAS(CAM_NAME) so it hotplugs and coldplugs; this
  * "legacy" driver style is trouble.
  */
 static struct platform_device *cam;
 
-static void __exit
-camera_core_cleanup(void)
+static void __exit camera_core_cleanup(void)
 {
 	platform_driver_unregister(&camera_core_driver);
 	platform_device_unregister(cam);
@@ -1275,8 +1254,7 @@ camera_core_cleanup(void)
 
 static char banner[] __initdata = KERN_INFO "OMAP Camera driver initializing\n";
 
-static int __init
-camera_core_init(void)
+static int __init camera_core_init(void)
 {
 
 	printk(banner);
@@ -1293,10 +1271,11 @@ MODULE_LICENSE("GPL");
 
 module_param(video_nr, int, 0);
 MODULE_PARM_DESC(video_nr,
-		"Minor number for video device (-1 ==> auto assign)");
+		 "Minor number for video device (-1 ==> auto assign)");
 module_param(capture_mem, int, 0);
 MODULE_PARM_DESC(capture_mem,
-        "Maximum amount of memory for capture buffers (default 4800KB)");
+		 "Maximum amount of memory for capture buffers "
+		 "(default 4800KB)");
 
 module_init(camera_core_init);
 module_exit(camera_core_cleanup);
-- 
1.5.3.4.206.g58ba4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/6] OMAP1: CAMERA: Remove unecessary files from Makefile and Kconfig.
  2007-10-09 12:52         ` [PATCH 5/6] OMAP1: CAMERA: Changed camera_core.c to the coding style standard Eduardo Valentin
@ 2007-10-09 12:52           ` Eduardo Valentin
  0 siblings, 0 replies; 13+ messages in thread
From: Eduardo Valentin @ 2007-10-09 12:52 UTC (permalink / raw)
  To: linux-omap-mailing-list; +Cc: Eduardo Valentin

From: Eduardo Valentin <eduardo.valentin@indt.org.br>

- Once ov9640 is implemented using v4l2-int-device API,
this patch removes unecessary files from Makefile and Kconfig.

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
 drivers/media/video/omap/Kconfig  |    6 ------
 drivers/media/video/omap/Makefile |    3 ---
 2 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/media/video/omap/Kconfig b/drivers/media/video/omap/Kconfig
index 809193b..0fb0686 100644
--- a/drivers/media/video/omap/Kconfig
+++ b/drivers/media/video/omap/Kconfig
@@ -4,9 +4,3 @@ config VIDEO_OMAP_CAMERA
 	depends on VIDEO_DEV && (ARCH_OMAP16XX || ARCH_OMAP24XX)
 	help
 	  V4L2 camera driver support for OMAP1/2 based boards.
-	
-config VIDEO_CAMERA_SENSOR_OV9640
-	tristate "OV9640 sensor support"
-	depends on VIDEO_OMAP_CAMERA
-	help
-	  OmniVision 9640 camera sensor support
diff --git a/drivers/media/video/omap/Makefile b/drivers/media/video/omap/Makefile
index 36ae615..9b4a998 100644
--- a/drivers/media/video/omap/Makefile
+++ b/drivers/media/video/omap/Makefile
@@ -1,11 +1,8 @@
 # Makefile for OMAP1/2 camera driver
 
 obj-$(CONFIG_VIDEO_OMAP_CAMERA) += omapcamera.o
-obj-$(CONFIG_VIDEO_CAMERA_SENSOR_OV9640) += sensor_ov9640.o
 
 objs-y$(CONFIG_ARCH_OMAP16XX) += omap16xxcam.o camera_core.o
-objs-y$(CONFIG_MACH_OMAP_H3) += h3_sensor_power.o
-objs-y$(CONFIG_MACH_OMAP_H4) += h4_sensor_power.o
 
 omapcamera-objs := $(objs-yy)
 
-- 
1.5.3.4.206.g58ba4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board.
  2007-10-09 12:52   ` [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board Eduardo Valentin
  2007-10-09 12:52     ` [PATCH 3/6] OMAP: Update gpio expander code to the corret i2c adapter id Eduardo Valentin
@ 2007-10-10 14:06     ` Eduardo Valentin
  2007-10-10 14:06       ` Eduardo Valentin
  2007-10-31 10:41     ` Tony Lindgren
  2 siblings, 1 reply; 13+ messages in thread
From: Eduardo Valentin @ 2007-10-10 14:06 UTC (permalink / raw)
  To: linux-omap-mailing-list

Hi all,

This is an update for the last patch 02/06. Thanks to the comments from David Brownell, I've optimized a small piece of code in this patch.

Thanks,

Eduardo Valentin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board.
  2007-10-10 14:06     ` [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board Eduardo Valentin
@ 2007-10-10 14:06       ` Eduardo Valentin
  0 siblings, 0 replies; 13+ messages in thread
From: Eduardo Valentin @ 2007-10-10 14:06 UTC (permalink / raw)
  To: linux-omap-mailing-list; +Cc: Eduardo Valentin

From: Eduardo Valentin <eduardo.valentin@indt.org.br>

This code is based on board-h4.c and drivers/media/video/omap/h3_sensor_power.c codes.

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
 arch/arm/mach-omap1/board-h3.c |  113 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index df77cf5..f69802e 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -26,6 +26,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/input.h>
 #include <linux/clk.h>
+#include <linux/i2c.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/tsc2101.h>
 
@@ -37,6 +38,8 @@
 #include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 
+#include <media/v4l2-int-device.h>
+
 #include <asm/arch/gpio.h>
 #include <asm/arch/gpioexpander.h>
 #include <asm/arch/irqs.h>
@@ -50,6 +53,8 @@
 #include <asm/arch/mcbsp.h>
 #include <asm/arch/omap-alsa.h>
 
+#include <../drivers/media/video/ov9640.h>
+
 extern int omap_gpio_init(void);
 
 static int h3_keymap[] = {
@@ -547,6 +552,111 @@ static int nand_dev_ready(struct nand_platform_data *data)
 	return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
 }
 
+/*
+ * Common OV9640 register initialization for all image sizes, pixel formats,
+ * and frame rates
+ */
+const static struct ov9640_reg ov9640_common[] = {
+
+	{ 0x12, 0x80 }, { 0x11, 0x80 }, { 0x13, 0x88 },	/* COM7, CLKRC, COM8 */
+	{ 0x01, 0x58 }, { 0x02, 0x24 }, { 0x04, 0x00 },	/* BLUE, RED, COM1 */
+	{ 0x0E, 0x81 }, { 0x0F, 0x4F }, { 0x14, 0xcA },	/* COM5, COM6, COM9 */
+	{ 0x16, 0x02 }, { 0x1B, 0x01 }, { 0x24, 0x70 },	/* ?, PSHFT, AEW */
+	{ 0x25, 0x68 }, { 0x26, 0xD3 }, { 0x27, 0x90 },	/* AEB, VPT, BBIAS */
+	{ 0x2A, 0x00 }, { 0x2B, 0x00 }, { 0x32, 0x24 },	/* EXHCH, EXHCL, HREF */
+	{ 0x33, 0x02 }, { 0x37, 0x02 }, { 0x38, 0x13 },	/* CHLF, ADC, ACOM */
+	{ 0x39, 0xF0 }, { 0x3A, 0x00 }, { 0x3B, 0x01 },	/* OFON, TSLB, COM11 */
+	{ 0x3D, 0x90 }, { 0x3E, 0x02 }, { 0x3F, 0xF2 },	/* COM13, COM14, EDGE */
+	{ 0x41, 0x02 }, { 0x42, 0xC8 },		/* COM16, COM17 */
+	{ 0x43, 0xF0 }, { 0x44, 0x10 }, { 0x45, 0x6C },	/* ?, ?, ? */
+	{ 0x46, 0x6C }, { 0x47, 0x44 }, { 0x48, 0x44 },	/* ?, ?, ? */
+	{ 0x49, 0x03 }, { 0x59, 0x49 }, { 0x5A, 0x94 },	/* ?, ?, ? */
+	{ 0x5B, 0x46 }, { 0x5C, 0x84 }, { 0x5D, 0x5C },	/* ?, ?, ? */
+	{ 0x5E, 0x08 }, { 0x5F, 0x00 }, { 0x60, 0x14 },	/* ?, ?, ? */
+	{ 0x61, 0xCE },					/* ? */
+	{ 0x62, 0x70 }, { 0x63, 0x00 }, { 0x64, 0x04 },	/* LCC1, LCC2, LCC3 */
+	{ 0x65, 0x00 }, { 0x66, 0x00 },			/* LCC4, LCC5 */
+	{ 0x69, 0x00 }, { 0x6A, 0x3E }, { 0x6B, 0x3F },	/* HV, MBD, DBLV */
+	{ 0x6C, 0x40 }, { 0x6D, 0x30 }, { 0x6E, 0x4B },	/* GSP1, GSP2, GSP3 */
+	{ 0x6F, 0x60 }, { 0x70, 0x70 }, { 0x71, 0x70 },	/* GSP4, GSP5, GSP6 */
+	{ 0x72, 0x70 }, { 0x73, 0x70 }, { 0x74, 0x60 },	/* GSP7, GSP8, GSP9 */
+	{ 0x75, 0x60 }, { 0x76, 0x50 }, { 0x77, 0x48 },	/* GSP10,GSP11,GSP12 */
+	{ 0x78, 0x3A }, { 0x79, 0x2E }, { 0x7A, 0x28 },	/* GSP13,GSP14,GSP15 */
+	{ 0x7B, 0x22 }, { 0x7C, 0x04 }, { 0x7D, 0x07 },	/* GSP16,GST1, GST2 */
+	{ 0x7E, 0x10 }, { 0x7F, 0x28 }, { 0x80, 0x36 },	/* GST3, GST4, GST5 */
+	{ 0x81, 0x44 }, { 0x82, 0x52 }, { 0x83, 0x60 },	/* GST6, GST7, GST8 */
+	{ 0x84, 0x6C }, { 0x85, 0x78 }, { 0x86, 0x8C },	/* GST9, GST10,GST11 */
+	{ 0x87, 0x9E }, { 0x88, 0xBB }, { 0x89, 0xD2 },	/* GST12,GST13,GST14 */
+	{ 0x8A, 0xE6 }, { 0x13, 0xaF }, { 0x15, 0x02 },	/* GST15, COM8 */
+	{ 0x22, 0x8a }, /* GROS */
+	{ OV9640_REG_TERM, OV9640_VAL_TERM }
+};
+
+#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE)
+static int ov9640_sensor_power_set(int power)
+{
+	unsigned char expa;
+	int err;
+
+	/* read current state of GPIO EXPA outputs */
+	err = read_gpio_expa(&expa, 0x27);
+	if (err) {
+		printk(KERN_ERR "Error reading GPIO EXPA\n");
+		return err;
+	}
+	/* Clear GPIO EXPA P3 (CAMERA_MODULE_EN) to power-up/down sensor */
+	if (power)
+		expa |= 0x08;
+	else
+		expa &= ~0x08;
+
+	err = write_gpio_expa(expa, 0x27);
+	if (err) {
+		printk(KERN_ERR "Error writing to GPIO EXPA\n");
+		return err;
+	}
+
+	return err;
+}
+
+static struct v4l2_ifparm ifparm = {
+	.if_type = V4L2_IF_TYPE_BT656,
+	.u = {
+		.bt656 = {
+			 .frame_start_on_rising_vs = 1,
+			 .nobt_vs_inv = 1,
+			 .mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT,
+			 .clock_min = OV9640_XCLK_MIN,
+			 .clock_max = OV9640_XCLK_MAX,
+		 },
+	},
+};
+
+static int ov9640_ifparm(struct v4l2_ifparm *p)
+{
+	*p = ifparm;
+
+	return 0;
+}
+#else
+static int ov9640_sensor_power_set(int power) { return 0; }
+static int ov9640_ifparm(struct v4l2_ifparm *p) { return 0; }
+#endif
+
+static struct ov9640_platform_data h3_ov9640_platform_data = {
+	.power_set	= ov9640_sensor_power_set,
+	.default_regs	= ov9640_common,
+	.ifparm		= ov9640_ifparm,
+};
+
+static struct i2c_board_info __initdata h3_i2c_board_info[] = {
+	{
+		I2C_BOARD_INFO("ov9640", 0x30),
+		.platform_data = &h3_ov9640_platform_data,
+	},
+};
+
+
 static void __init h3_init(void)
 {
 	/* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
@@ -569,6 +679,9 @@ static void __init h3_init(void)
 	/* GPIO10 pullup/down register, Enable pullup on GPIO10 */
 	omap_cfg_reg(V2_1710_GPIO10);
 
+	i2c_register_board_info(1, h3_i2c_board_info,
+				ARRAY_SIZE(h3_i2c_board_info));
+
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 	spi_register_board_info(h3_spi_board_info,
 				ARRAY_SIZE(h3_spi_board_info));
-- 
1.5.3.4.206.g58ba4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [RFC][PATCH 0/6] OMAP1: CAMERA: Converts omap1 camera to use v4l2-int-device api
  2007-10-09 12:52 [RFC][PATCH 0/6] OMAP1: CAMERA: Converts omap1 camera to use v4l2-int-device api Eduardo Valentin
  2007-10-09 12:52 ` [PATCH 1/6] OMAP1: CAMERA: Changed omap16xxcam.c to the coding style standard Eduardo Valentin
@ 2007-10-22  6:31 ` Trilok Soni
  1 sibling, 0 replies; 13+ messages in thread
From: Trilok Soni @ 2007-10-22  6:31 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: linux-omap-mailing-list

Hi Eduardo,

On 10/9/07, Eduardo Valentin <edubezval@gmail.com> wrote:
> Hi all,
>
> This patch set converts omap1 camera to use v4l2-int-device api. It was
> tested on H3 with ov9640 sensor, so board-h3.c was modified to add ov9640
> specific initializations. The gpio-expander code was modified also to use
> the i2c adapter id configured with i2c board specific info. Currently, it is
> working only with read method. To work with MMAP, camera_core.c needs more
> re-work.
>
> Here is the overall diffstat:
>  b/arch/arm/mach-omap1/board-h3.c         |  141 +++++++++
>  b/drivers/i2c/chips/gpio_expander_omap.c |    5
>  b/drivers/media/video/omap/Kconfig       |    6
>  b/drivers/media/video/omap/Makefile      |    4
>  b/drivers/media/video/omap/camera_core.c |  394 ++++++++++++++++++---------
>  b/drivers/media/video/omap/camera_core.h |   27 -
>  b/drivers/media/video/omap/omap16xxcam.c |  442 +++++++++++++++----------------
>  drivers/media/video/omap/camera_core.c   |  404 +++++++++++++---------------
>  8 files changed, 827 insertions(+), 596 deletions(-)
>

Thanx for sending OMAP1 changes to fit with new framework. So, it
looks like that new ov9640.c is ready for upstream.

-- 
--Trilok Soni

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board.
  2007-10-09 12:52   ` [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board Eduardo Valentin
  2007-10-09 12:52     ` [PATCH 3/6] OMAP: Update gpio expander code to the corret i2c adapter id Eduardo Valentin
  2007-10-10 14:06     ` [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board Eduardo Valentin
@ 2007-10-31 10:41     ` Tony Lindgren
  2007-11-01 15:32       ` Eduardo Valentin
  2 siblings, 1 reply; 13+ messages in thread
From: Tony Lindgren @ 2007-10-31 10:41 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Eduardo Valentin, linux-omap-mailing-list

Hi,

* Eduardo Valentin <edubezval@gmail.com> [071009 05:53]:
> From: Eduardo Valentin <eduardo.valentin@indt.org.br>
> 
> This code is based on board-h4.c and drivers/media/video/omap/h3_sensor_power.c codes.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> ---
>  arch/arm/mach-omap1/board-h3.c |  140 ++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 140 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
> index df77cf5..8ecc5f2 100644
> --- a/arch/arm/mach-omap1/board-h3.c
> +++ b/arch/arm/mach-omap1/board-h3.c

<snip>

> @@ -547,6 +552,138 @@ static int nand_dev_ready(struct nand_platform_data *data)
>  	return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
>  }
>  
> +/*
> + * Common OV9640 register initialization for all image sizes, pixel formats,
> + * and frame rates
> + */
> +const static struct ov9640_reg ov9640_common[] = {
> +
> +	{ 0x12, 0x80 }, { 0x11, 0x80 }, { 0x13, 0x88 },	/* COM7, CLKRC, COM8 */
> +	{ 0x01, 0x58 }, { 0x02, 0x24 }, { 0x04, 0x00 },	/* BLUE, RED, COM1 */
> +	{ 0x0E, 0x81 }, { 0x0F, 0x4F }, { 0x14, 0xcA },	/* COM5, COM6, COM9 */
> +	{ 0x16, 0x02 }, { 0x1B, 0x01 }, { 0x24, 0x70 },	/* ?, PSHFT, AEW */
> +	{ 0x25, 0x68 }, { 0x26, 0xD3 }, { 0x27, 0x90 },	/* AEB, VPT, BBIAS */
> +	{ 0x2A, 0x00 }, { 0x2B, 0x00 }, { 0x32, 0x24 },	/* EXHCH, EXHCL, HREF */
> +	{ 0x33, 0x02 }, { 0x37, 0x02 }, { 0x38, 0x13 },	/* CHLF, ADC, ACOM */
> +	{ 0x39, 0xF0 }, { 0x3A, 0x00 }, { 0x3B, 0x01 },	/* OFON, TSLB, COM11 */
> +	{ 0x3D, 0x90 }, { 0x3E, 0x02 }, { 0x3F, 0xF2 },	/* COM13, COM14, EDGE */
> +	{ 0x41, 0x02 }, { 0x42, 0xC8 },		/* COM16, COM17 */
> +	{ 0x43, 0xF0 }, { 0x44, 0x10 }, { 0x45, 0x6C },	/* ?, ?, ? */
> +	{ 0x46, 0x6C }, { 0x47, 0x44 }, { 0x48, 0x44 },	/* ?, ?, ? */
> +	{ 0x49, 0x03 }, { 0x59, 0x49 }, { 0x5A, 0x94 },	/* ?, ?, ? */
> +	{ 0x5B, 0x46 }, { 0x5C, 0x84 }, { 0x5D, 0x5C },	/* ?, ?, ? */
> +	{ 0x5E, 0x08 }, { 0x5F, 0x00 }, { 0x60, 0x14 },	/* ?, ?, ? */
> +	{ 0x61, 0xCE },					/* ? */
> +	{ 0x62, 0x70 }, { 0x63, 0x00 }, { 0x64, 0x04 },	/* LCC1, LCC2, LCC3 */
> +	{ 0x65, 0x00 }, { 0x66, 0x00 },			/* LCC4, LCC5 */
> +	{ 0x69, 0x00 }, { 0x6A, 0x3E }, { 0x6B, 0x3F },	/* HV, MBD, DBLV */
> +	{ 0x6C, 0x40 }, { 0x6D, 0x30 }, { 0x6E, 0x4B },	/* GSP1, GSP2, GSP3 */
> +	{ 0x6F, 0x60 }, { 0x70, 0x70 }, { 0x71, 0x70 },	/* GSP4, GSP5, GSP6 */
> +	{ 0x72, 0x70 }, { 0x73, 0x70 }, { 0x74, 0x60 },	/* GSP7, GSP8, GSP9 */
> +	{ 0x75, 0x60 }, { 0x76, 0x50 }, { 0x77, 0x48 },	/* GSP10,GSP11,GSP12 */
> +	{ 0x78, 0x3A }, { 0x79, 0x2E }, { 0x7A, 0x28 },	/* GSP13,GSP14,GSP15 */
> +	{ 0x7B, 0x22 }, { 0x7C, 0x04 }, { 0x7D, 0x07 },	/* GSP16,GST1, GST2 */
> +	{ 0x7E, 0x10 }, { 0x7F, 0x28 }, { 0x80, 0x36 },	/* GST3, GST4, GST5 */
> +	{ 0x81, 0x44 }, { 0x82, 0x52 }, { 0x83, 0x60 },	/* GST6, GST7, GST8 */
> +	{ 0x84, 0x6C }, { 0x85, 0x78 }, { 0x86, 0x8C },	/* GST9, GST10,GST11 */
> +	{ 0x87, 0x9E }, { 0x88, 0xBB }, { 0x89, 0xD2 },	/* GST12,GST13,GST14 */
> +	{ 0x8A, 0xE6 }, { 0x13, 0xaF }, { 0x15, 0x02 },	/* GST15, COM8 */
> +	{ 0x22, 0x8a }, /* GROS */
> +	{ OV9640_REG_TERM, OV9640_VAL_TERM }
> +};
> +
> +#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE)

<snip>

How about moving the struct ov9640_reg to be within CONFIG_VIDEO_OV9640?

Regards,

Tony

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board.
  2007-10-31 10:41     ` Tony Lindgren
@ 2007-11-01 15:32       ` Eduardo Valentin
  2007-11-15  1:46         ` Tony Lindgren
  0 siblings, 1 reply; 13+ messages in thread
From: Eduardo Valentin @ 2007-11-01 15:32 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Eduardo Valentin, linux-omap-mailing-list

[-- Attachment #1: Type: text/plain, Size: 4010 bytes --]

Hi Tony,

I'm re-sending the patch. As I said, it was based on board-h4.c. But I
totally agree with you. I believe this new one is a better way to
implement it. Unnecessary structures and functions are not created if
the OV9640 is not selected. I've just compiled tested this new patch.

Cheers,

On 10/31/07, Tony Lindgren <tony@atomide.com> wrote:
> Hi,
>
> * Eduardo Valentin <edubezval@gmail.com> [071009 05:53]:
> > From: Eduardo Valentin <eduardo.valentin@indt.org.br>
> >
> > This code is based on board-h4.c and drivers/media/video/omap/h3_sensor_power.c codes.
> >
> > Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> > ---
> >  arch/arm/mach-omap1/board-h3.c |  140 ++++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 140 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
> > index df77cf5..8ecc5f2 100644
> > --- a/arch/arm/mach-omap1/board-h3.c
> > +++ b/arch/arm/mach-omap1/board-h3.c
>
> <snip>
>
> > @@ -547,6 +552,138 @@ static int nand_dev_ready(struct nand_platform_data *data)
> >       return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
> >  }
> >
> > +/*
> > + * Common OV9640 register initialization for all image sizes, pixel formats,
> > + * and frame rates
> > + */
> > +const static struct ov9640_reg ov9640_common[] = {
> > +
> > +     { 0x12, 0x80 }, { 0x11, 0x80 }, { 0x13, 0x88 }, /* COM7, CLKRC, COM8 */
> > +     { 0x01, 0x58 }, { 0x02, 0x24 }, { 0x04, 0x00 }, /* BLUE, RED, COM1 */
> > +     { 0x0E, 0x81 }, { 0x0F, 0x4F }, { 0x14, 0xcA }, /* COM5, COM6, COM9 */
> > +     { 0x16, 0x02 }, { 0x1B, 0x01 }, { 0x24, 0x70 }, /* ?, PSHFT, AEW */
> > +     { 0x25, 0x68 }, { 0x26, 0xD3 }, { 0x27, 0x90 }, /* AEB, VPT, BBIAS */
> > +     { 0x2A, 0x00 }, { 0x2B, 0x00 }, { 0x32, 0x24 }, /* EXHCH, EXHCL, HREF */
> > +     { 0x33, 0x02 }, { 0x37, 0x02 }, { 0x38, 0x13 }, /* CHLF, ADC, ACOM */
> > +     { 0x39, 0xF0 }, { 0x3A, 0x00 }, { 0x3B, 0x01 }, /* OFON, TSLB, COM11 */
> > +     { 0x3D, 0x90 }, { 0x3E, 0x02 }, { 0x3F, 0xF2 }, /* COM13, COM14, EDGE */
> > +     { 0x41, 0x02 }, { 0x42, 0xC8 },         /* COM16, COM17 */
> > +     { 0x43, 0xF0 }, { 0x44, 0x10 }, { 0x45, 0x6C }, /* ?, ?, ? */
> > +     { 0x46, 0x6C }, { 0x47, 0x44 }, { 0x48, 0x44 }, /* ?, ?, ? */
> > +     { 0x49, 0x03 }, { 0x59, 0x49 }, { 0x5A, 0x94 }, /* ?, ?, ? */
> > +     { 0x5B, 0x46 }, { 0x5C, 0x84 }, { 0x5D, 0x5C }, /* ?, ?, ? */
> > +     { 0x5E, 0x08 }, { 0x5F, 0x00 }, { 0x60, 0x14 }, /* ?, ?, ? */
> > +     { 0x61, 0xCE },                                 /* ? */
> > +     { 0x62, 0x70 }, { 0x63, 0x00 }, { 0x64, 0x04 }, /* LCC1, LCC2, LCC3 */
> > +     { 0x65, 0x00 }, { 0x66, 0x00 },                 /* LCC4, LCC5 */
> > +     { 0x69, 0x00 }, { 0x6A, 0x3E }, { 0x6B, 0x3F }, /* HV, MBD, DBLV */
> > +     { 0x6C, 0x40 }, { 0x6D, 0x30 }, { 0x6E, 0x4B }, /* GSP1, GSP2, GSP3 */
> > +     { 0x6F, 0x60 }, { 0x70, 0x70 }, { 0x71, 0x70 }, /* GSP4, GSP5, GSP6 */
> > +     { 0x72, 0x70 }, { 0x73, 0x70 }, { 0x74, 0x60 }, /* GSP7, GSP8, GSP9 */
> > +     { 0x75, 0x60 }, { 0x76, 0x50 }, { 0x77, 0x48 }, /* GSP10,GSP11,GSP12 */
> > +     { 0x78, 0x3A }, { 0x79, 0x2E }, { 0x7A, 0x28 }, /* GSP13,GSP14,GSP15 */
> > +     { 0x7B, 0x22 }, { 0x7C, 0x04 }, { 0x7D, 0x07 }, /* GSP16,GST1, GST2 */
> > +     { 0x7E, 0x10 }, { 0x7F, 0x28 }, { 0x80, 0x36 }, /* GST3, GST4, GST5 */
> > +     { 0x81, 0x44 }, { 0x82, 0x52 }, { 0x83, 0x60 }, /* GST6, GST7, GST8 */
> > +     { 0x84, 0x6C }, { 0x85, 0x78 }, { 0x86, 0x8C }, /* GST9, GST10,GST11 */
> > +     { 0x87, 0x9E }, { 0x88, 0xBB }, { 0x89, 0xD2 }, /* GST12,GST13,GST14 */
> > +     { 0x8A, 0xE6 }, { 0x13, 0xaF }, { 0x15, 0x02 }, /* GST15, COM8 */
> > +     { 0x22, 0x8a }, /* GROS */
> > +     { OV9640_REG_TERM, OV9640_VAL_TERM }
> > +};
> > +
> > +#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE)
>
> <snip>
>
> How about moving the struct ov9640_reg to be within CONFIG_VIDEO_OV9640?
>
> Regards,
>
> Tony
>


-- 
Eduardo Bezerra Valentin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-OMAP-Update-ov9640-ifparm-for-H3-board.patch --]
[-- Type: text/x-diff; name=0001-OMAP-Update-ov9640-ifparm-for-H3-board.patch, Size: 5604 bytes --]

From b6030eac258261550b946ab211124ced3536285e Mon Sep 17 00:00:00 2001
From: Eduardo Valentin <eduardo.valentin@indt.org.br>
Date: Wed, 10 Oct 2007 10:06:18 -0400
Subject: [PATCH] OMAP: Update ov9640 ifparm for H3 board.

This code is based on board-h4.c and drivers/media/video/omap/h3_sensor_power.c codes.

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---
 arch/arm/mach-omap1/board-h3.c |  112 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 112 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index df77cf5..f6095f0 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -26,6 +26,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/input.h>
 #include <linux/clk.h>
+#include <linux/i2c.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/tsc2101.h>
 
@@ -37,6 +38,8 @@
 #include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 
+#include <media/v4l2-int-device.h>
+
 #include <asm/arch/gpio.h>
 #include <asm/arch/gpioexpander.h>
 #include <asm/arch/irqs.h>
@@ -50,6 +53,8 @@
 #include <asm/arch/mcbsp.h>
 #include <asm/arch/omap-alsa.h>
 
+#include <../drivers/media/video/ov9640.h>
+
 extern int omap_gpio_init(void);
 
 static int h3_keymap[] = {
@@ -547,6 +552,110 @@ static int nand_dev_ready(struct nand_platform_data *data)
 	return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
 }
 
+#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE)
+/*
+ * Common OV9640 register initialization for all image sizes, pixel formats,
+ * and frame rates
+ */
+const static struct ov9640_reg ov9640_common[] = {
+
+	{ 0x12, 0x80 }, { 0x11, 0x80 }, { 0x13, 0x88 },	/* COM7, CLKRC, COM8 */
+	{ 0x01, 0x58 }, { 0x02, 0x24 }, { 0x04, 0x00 },	/* BLUE, RED, COM1 */
+	{ 0x0E, 0x81 }, { 0x0F, 0x4F }, { 0x14, 0xcA },	/* COM5, COM6, COM9 */
+	{ 0x16, 0x02 }, { 0x1B, 0x01 }, { 0x24, 0x70 },	/* ?, PSHFT, AEW */
+	{ 0x25, 0x68 }, { 0x26, 0xD3 }, { 0x27, 0x90 },	/* AEB, VPT, BBIAS */
+	{ 0x2A, 0x00 }, { 0x2B, 0x00 }, { 0x32, 0x24 },	/* EXHCH, EXHCL, HREF */
+	{ 0x33, 0x02 }, { 0x37, 0x02 }, { 0x38, 0x13 },	/* CHLF, ADC, ACOM */
+	{ 0x39, 0xF0 }, { 0x3A, 0x00 }, { 0x3B, 0x01 },	/* OFON, TSLB, COM11 */
+	{ 0x3D, 0x90 }, { 0x3E, 0x02 }, { 0x3F, 0xF2 },	/* COM13, COM14, EDGE */
+	{ 0x41, 0x02 }, { 0x42, 0xC8 },		/* COM16, COM17 */
+	{ 0x43, 0xF0 }, { 0x44, 0x10 }, { 0x45, 0x6C },	/* ?, ?, ? */
+	{ 0x46, 0x6C }, { 0x47, 0x44 }, { 0x48, 0x44 },	/* ?, ?, ? */
+	{ 0x49, 0x03 }, { 0x59, 0x49 }, { 0x5A, 0x94 },	/* ?, ?, ? */
+	{ 0x5B, 0x46 }, { 0x5C, 0x84 }, { 0x5D, 0x5C },	/* ?, ?, ? */
+	{ 0x5E, 0x08 }, { 0x5F, 0x00 }, { 0x60, 0x14 },	/* ?, ?, ? */
+	{ 0x61, 0xCE },					/* ? */
+	{ 0x62, 0x70 }, { 0x63, 0x00 }, { 0x64, 0x04 },	/* LCC1, LCC2, LCC3 */
+	{ 0x65, 0x00 }, { 0x66, 0x00 },			/* LCC4, LCC5 */
+	{ 0x69, 0x00 }, { 0x6A, 0x3E }, { 0x6B, 0x3F },	/* HV, MBD, DBLV */
+	{ 0x6C, 0x40 }, { 0x6D, 0x30 }, { 0x6E, 0x4B },	/* GSP1, GSP2, GSP3 */
+	{ 0x6F, 0x60 }, { 0x70, 0x70 }, { 0x71, 0x70 },	/* GSP4, GSP5, GSP6 */
+	{ 0x72, 0x70 }, { 0x73, 0x70 }, { 0x74, 0x60 },	/* GSP7, GSP8, GSP9 */
+	{ 0x75, 0x60 }, { 0x76, 0x50 }, { 0x77, 0x48 },	/* GSP10,GSP11,GSP12 */
+	{ 0x78, 0x3A }, { 0x79, 0x2E }, { 0x7A, 0x28 },	/* GSP13,GSP14,GSP15 */
+	{ 0x7B, 0x22 }, { 0x7C, 0x04 }, { 0x7D, 0x07 },	/* GSP16,GST1, GST2 */
+	{ 0x7E, 0x10 }, { 0x7F, 0x28 }, { 0x80, 0x36 },	/* GST3, GST4, GST5 */
+	{ 0x81, 0x44 }, { 0x82, 0x52 }, { 0x83, 0x60 },	/* GST6, GST7, GST8 */
+	{ 0x84, 0x6C }, { 0x85, 0x78 }, { 0x86, 0x8C },	/* GST9, GST10,GST11 */
+	{ 0x87, 0x9E }, { 0x88, 0xBB }, { 0x89, 0xD2 },	/* GST12,GST13,GST14 */
+	{ 0x8A, 0xE6 }, { 0x13, 0xaF }, { 0x15, 0x02 },	/* GST15, COM8 */
+	{ 0x22, 0x8a }, /* GROS */
+	{ OV9640_REG_TERM, OV9640_VAL_TERM }
+};
+
+static int ov9640_sensor_power_set(int power)
+{
+	unsigned char expa;
+	int err;
+
+	/* read current state of GPIO EXPA outputs */
+	err = read_gpio_expa(&expa, 0x27);
+	if (err) {
+		printk(KERN_ERR "Error reading GPIO EXPA\n");
+		return err;
+	}
+	/* Clear GPIO EXPA P3 (CAMERA_MODULE_EN) to power-up/down sensor */
+	if (power)
+		expa |= 0x08;
+	else
+		expa &= ~0x08;
+
+	err = write_gpio_expa(expa, 0x27);
+	if (err) {
+		printk(KERN_ERR "Error writing to GPIO EXPA\n");
+		return err;
+	}
+
+	return err;
+}
+
+static struct v4l2_ifparm ifparm = {
+	.if_type = V4L2_IF_TYPE_BT656,
+	.u = {
+		.bt656 = {
+			 .frame_start_on_rising_vs = 1,
+			 .nobt_vs_inv = 1,
+			 .mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT,
+			 .clock_min = OV9640_XCLK_MIN,
+			 .clock_max = OV9640_XCLK_MAX,
+		 },
+	},
+};
+
+static int ov9640_ifparm(struct v4l2_ifparm *p)
+{
+	*p = ifparm;
+
+	return 0;
+}
+
+static struct ov9640_platform_data h3_ov9640_platform_data = {
+	.power_set	= ov9640_sensor_power_set,
+	.default_regs	= ov9640_common,
+	.ifparm		= ov9640_ifparm,
+};
+#endif
+
+static struct i2c_board_info __initdata h3_i2c_board_info[] = {
+#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE)
+	{
+		I2C_BOARD_INFO("ov9640", 0x30),
+		.platform_data = &h3_ov9640_platform_data,
+	},
+#endif
+};
+
+
 static void __init h3_init(void)
 {
 	/* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
@@ -569,6 +678,9 @@ static void __init h3_init(void)
 	/* GPIO10 pullup/down register, Enable pullup on GPIO10 */
 	omap_cfg_reg(V2_1710_GPIO10);
 
+	i2c_register_board_info(1, h3_i2c_board_info,
+				ARRAY_SIZE(h3_i2c_board_info));
+
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 	spi_register_board_info(h3_spi_board_info,
 				ARRAY_SIZE(h3_spi_board_info));
-- 
1.5.3.4.206.g58ba4


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board.
  2007-11-01 15:32       ` Eduardo Valentin
@ 2007-11-15  1:46         ` Tony Lindgren
  0 siblings, 0 replies; 13+ messages in thread
From: Tony Lindgren @ 2007-11-15  1:46 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Eduardo Valentin, linux-omap-mailing-list

* Eduardo Valentin <edubezval@gmail.com> [071101 08:32]:
> Hi Tony,
> 
> I'm re-sending the patch. As I said, it was based on board-h4.c. But I
> totally agree with you. I believe this new one is a better way to
> implement it. Unnecessary structures and functions are not created if
> the OV9640 is not selected. I've just compiled tested this new patch.

Thanks for updating it. I'll push the whole series today.

Tony

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-11-15  1:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-09 12:52 [RFC][PATCH 0/6] OMAP1: CAMERA: Converts omap1 camera to use v4l2-int-device api Eduardo Valentin
2007-10-09 12:52 ` [PATCH 1/6] OMAP1: CAMERA: Changed omap16xxcam.c to the coding style standard Eduardo Valentin
2007-10-09 12:52   ` [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board Eduardo Valentin
2007-10-09 12:52     ` [PATCH 3/6] OMAP: Update gpio expander code to the corret i2c adapter id Eduardo Valentin
2007-10-09 12:52       ` [PATCH 4/6] OMAP1: CAMERA: Convert camera_core.c to use v4l2-int-device API Eduardo Valentin
2007-10-09 12:52         ` [PATCH 5/6] OMAP1: CAMERA: Changed camera_core.c to the coding style standard Eduardo Valentin
2007-10-09 12:52           ` [PATCH 6/6] OMAP1: CAMERA: Remove unecessary files from Makefile and Kconfig Eduardo Valentin
2007-10-10 14:06     ` [PATCH 2/6] OMAP: Update ov9640 ifparm for H3 board Eduardo Valentin
2007-10-10 14:06       ` Eduardo Valentin
2007-10-31 10:41     ` Tony Lindgren
2007-11-01 15:32       ` Eduardo Valentin
2007-11-15  1:46         ` Tony Lindgren
2007-10-22  6:31 ` [RFC][PATCH 0/6] OMAP1: CAMERA: Converts omap1 camera to use v4l2-int-device api Trilok Soni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.