rpms/kernel/FC-6 linux-2.6-marvell-88alp01.patch, NONE, 1.1 kernel-2.6.spec, 1.2798, 1.2799 config-olpc-generic, 1.13, 1.14

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Mon Oct 16 20:00:06 UTC 2006


Author: mtosatti

Update of /cvs/dist/rpms/kernel/FC-6
In directory cvs.devel.redhat.com:/tmp/cvs-serv30221

Modified Files:
	kernel-2.6.spec config-olpc-generic 
Added Files:
	linux-2.6-marvell-88alp01.patch 
Log Message:
Add Marvell 88ALP01 camera controller support



linux-2.6-marvell-88alp01.patch:
 Documentation/video4linux/m88alp01-ccic        |   57 
 drivers/media/video/Kconfig                    |   30 
 drivers/media/video/Makefile                   |    2 
 drivers/media/video/m88alp01-ccic.c            | 2372 +++++++++++++++++++++++++
 drivers/media/video/m88alp01-regs.h            |  153 +
 drivers/media/video/ovcamchip/Makefile         |    2 
 drivers/media/video/ovcamchip/ov7670.c         |  794 ++++++++
 drivers/media/video/ovcamchip/ovcamchip_core.c |   24 
 include/linux/i2c-id.h                         |    1 
 include/linux/videodev2.h                      |    1 
 include/media/ovcamchip.h                      |    3 
 11 files changed, 3425 insertions(+), 14 deletions(-)

--- NEW FILE linux-2.6-marvell-88alp01.patch ---
diff -Nur -p linux-2.6.18.i586.orig/Documentation/video4linux/m88alp01-ccic linux-2.6.18.i586/Documentation/video4linux/m88alp01-ccic
--- linux-2.6.18.i586.orig/Documentation/video4linux/m88alp01-ccic	1969-12-31 19:00:00.000000000 -0500
+++ linux-2.6.18.i586/Documentation/video4linux/m88alp01-ccic	2006-10-16 14:19:52.000000000 -0400
@@ -0,0 +1,57 @@
+This is the initial version of the Cafe camera driver.  Here's a few notes
+to go along with it...
+
+ - You need a 2.6.18+ kernel for this driver.  If you're running
+   2.6.18-vanilla, you'll need a couple of small v4l2 patches 
+   or the driver will not function.
+
+ - The name of the driver (m88alp01-ccic) was taken from the product name
+   found in the draft spec.  If we want to change its name (and Marvell
+   could well change theirs) now is probably the right time to do so.
+
+ - It is rock-solid with mplayer.  The command I use is:
+
+     mplayer tv:// -tv driver=v4l2:width=640:height=480 -nosound
+
+   That will give you a 30fps window, VGA resolution, showing whatever the
+   camera sees.  You can tweak contrast and brightness ('1' and '2' for
+   contrast, '3' and '4' for brightness); no other controls are hooked up
+   yet. 
+
+ - Also supported are the RGB565 and RGB444 formats.  RGB565 can be
+   displayed directly with a command like:
+
+     mplayer tv:// -tv driver=v4l2:width=640:height=480:outfmt=bgr16 -nosound
+
+   No application currently knows how to do RGB444, so the driver currently
+   implements a fake RGB32 mode generated from RGB444. V4L2 drivers are not
+   supposed to do video format transformations, so this options will
+   probably come out eventually, but it is useful for testing now; use
+   outfmt=rgb32 with mplayer to get this mode.
+
+ - It does not behave at all well with gqcam - which appears to be trying
+   to use the read() method.  There is some residual weirdness with read()
+   that I've not yet had a chance to track down.  Xawtv also does strange
+   stuff. 
+
+ - This driver uses the "ovcamchip" layer because it was convenient, but it
+   is at most a marriage of convenience.  This layer has traditionally been
+   used to configure OmniVision sensors for a specific back-end processor;
+   here, instead, we want to see the sensor's output data directly.  So the
+   supplied OV7670 driver will not work with the older ovcamchip users, and
+   the other OmniVision sensor drivers are not useful for the m88alp01
+   camera controller.  
+
+   I have made a beginning attempt to shove some V4L2 functionality down
+   into the ovcamchip layer as a way of making it a bit more general, but
+   (1) this work is rough as yet, and (2) I have not been able to talk with
+   the ovcamchip maintainer about how he would like things done.  So
+   changes may be required in this interface.
+
+Please do look it over, try it out, and get back to me with any questions
+or comments.
+
+jon
+
+Jonathan Corbet
+corbet at lwn.net
diff -Nur -p linux-2.6.18.i586.orig/drivers/media/video/Kconfig linux-2.6.18.i586/drivers/media/video/Kconfig
--- linux-2.6.18.i586.orig/drivers/media/video/Kconfig	2006-10-16 14:11:57.000000000 -0400
+++ linux-2.6.18.i586/drivers/media/video/Kconfig	2006-10-16 14:19:34.000000000 -0400
@@ -326,6 +326,25 @@ config VIDEO_M32R_AR_M64278
 	  Say Y here to use the Renesas M64278E-800 camera module,
 	  which supports VGA(640x480 pixcels) size of images.
 
+config VIDEO_OVCAMCHIP
+	tristate "OmniVision Camera Chip support"
+	depends on I2C 
+	---help---
+	  Support for the OmniVision OV6xxx and OV7xxx series of camera chips.
+	  This driver is intended to be used with the ov511 and w9968cf USB
+	  camera drivers.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ovcamchip.
+
+config VIDEO_M88ALP01_CCIC
+	tristate "Marvell 88ALP01 CMOS Camera Controller support"
+	depends on I2C && VIDEO_V4L2
+	---help---
+	  This is a video4linux2 driver for the Marvell 88ALP01 integrated
+	  CMOS camera controller.  It currently requires the "ovcamchip"
+	  module.
+
 #
 # Encoder / Decoder module configuration
 #
@@ -453,17 +472,6 @@ source "drivers/media/video/usbvideo/Kco
 
 source "drivers/media/video/et61x251/Kconfig"
 
-config VIDEO_OVCAMCHIP
-	tristate "OmniVision Camera Chip support"
-	depends on I2C && VIDEO_V4L1
-	---help---
-	  Support for the OmniVision OV6xxx and OV7xxx series of camera chips.
-	  This driver is intended to be used with the ov511 and w9968cf USB
-	  camera drivers.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called ovcamchip.
-
 config USB_W9968CF
 	tristate "USB W996[87]CF JPEG Dual Mode Camera support"
 	depends on USB && VIDEO_V4L1 && I2C
diff -Nur -p linux-2.6.18.i586.orig/drivers/media/video/m88alp01-ccic.c linux-2.6.18.i586/drivers/media/video/m88alp01-ccic.c
--- linux-2.6.18.i586.orig/drivers/media/video/m88alp01-ccic.c	1969-12-31 19:00:00.000000000 -0500
+++ linux-2.6.18.i586/drivers/media/video/m88alp01-ccic.c	2006-10-16 14:19:52.000000000 -0400
@@ -0,0 +1,2372 @@
+/*
+ * A driver for the CMOS camera controller in the Marvell 88ALP01
+ * multifunction chip.  Currently works with the Omnivision OV7670
+ * sensor.
+ *
+ * Copyright 2006 One Laptop Per Child Association, Inc.
+ *
+ * Written by Jonathan Corbet, corbet at lwn.net.
+ *
+ * This file may be distributed under the terms of the GNU General
+ * Public License, version 2.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/pci.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/videodev2.h>
+#include <linux/device.h>
+#include <linux/wait.h>
+#include <linux/list.h>
+#include <linux/dma-mapping.h>
+#include <linux/delay.h>
+#include <linux/debugfs.h>
+#include <linux/jiffies.h>
+#include <media/ovcamchip.h>
+
+#include <asm/uaccess.h>
+#include <asm/io.h>
+
+#include "m88alp01-regs.h"
+
+#define DEBUG  /* For the foreseeable future */
+
+#define M88_VERSION 0x000001
+
+
+/*
+ * Parameters.
+ */
+MODULE_AUTHOR("Jonathan Corbet <corbet at lwn.net>");
+MODULE_DESCRIPTION("Marvell 88ALP01 CMOS Camera Controller driver");
+MODULE_LICENSE("GPL");
+MODULE_SUPPORTED_DEVICE("Video");
+
+/*
+ * Internal DMA buffer management.  Since the controller cannot do S/G I/O,
+ * we must have physically contiguous buffers to bring frames into.
+ * These parameters control how many buffers we use, whether we
+ * allocate them at load time (better chance of success, but nails down
+ * memory) or when somebody tries to use the camera (riskier), and,
+ * for load-time allocation, how big they should be.
+ *
+ * The controller can cycle through three buffers.  We could use
+ * more by flipping pointers around, but it probably makes little
+ * sense.
+ */
+
+#define MAX_DMA_BUFS 3
+static int alloc_bufs_at_load = 1;
+module_param(alloc_bufs_at_load, bool, 0444);
+MODULE_PARM_DESC(alloc_bufs_at_load,
+		"Non-zero value causes DMA buffers to be allocated at module "
+		"load time.  This increases the chances of successfully getting "
+		"those buffers, but at the cost of nailing down the memory from "
+		"the outset.");
+
+static int n_dma_bufs = 2; 
+module_param(n_dma_bufs, uint, 0644);
+MODULE_PARM_DESC(n_dma_bufs,
+		"The number of DMA buffers to allocate.  Can be either two "
+		"(saves memory, makes timing tighter) or three.");
+
+static int dma_buf_size = 640 * 480 * 2;  /* Worst case */
+module_param(dma_buf_size, uint, 0444);
+MODULE_PARM_DESC(dma_buf_size,
+		"The size of the allocated DMA buffers.  If actual operating "
+		"parameters require larger buffers, an attempt to reallocate "
+		"will be made.");
+		
+static int min_buffers = 1;
+module_param(min_buffers, uint, 0644);
[...3168 lines suppressed...]
+	 */
+	if (pix->field == V4L2_FIELD_ANY)
+		pix->field = V4L2_FIELD_NONE;
+	else if (pix->field != V4L2_FIELD_NONE)
+		return -EINVAL;
+	/*
+	 * Round requested image size down to the nearest
+	 * we support, but not below the smallest.
+	 */
+#if 0
+	if (pix->height < m88_height_options[0] ||
+			pix->width < m88_width_options[0])
+		sizeindex = 0;
+	else {
+		for (sizeindex = N_WINDOW_SIZES-1; sizeindex > 0; sizeindex--)
+			if (pix->height >= m88_height_options[sizeindex] &&
+			    pix->width >= m88_width_options[sizeindex])
+				break;
+	}
+	pix->width = m88_width_options[sizeindex];
+	pix->height = m88_height_options[sizeindex];
+#endif
+	/*
+	 * Wire VGA for now; we'll add flexibility later
+	 */
+	pix->width = 640;
+	pix->height = 480;
+	pix->bytesperline = pix->width*BYTES_PER_PIXEL;
+	if (pix->pixelformat == V4L2_PIX_FMT_RGB32)
+		pix->bytesperline *= 2;
+	pix->sizeimage = pix->height*pix->bytesperline;
+	return 0;
+
+}
+
+/*
+ * Set a format.
+ */
+static int ov7670_s_fmt(struct i2c_client *c, struct v4l2_format *fmt)
+{
+	int ret, i;
+	struct v4l2_pix_format *pix = &fmt->fmt.pix;
+
+	ret = ov7670_try_fmt(c, fmt);
+	if (ret)
+		return ret;
+	/*
+	 * Resolution wired to VGA for the moment.
+	 */
+	ov_write_mask(c, REG_COM7, COM7_FMT_VGA, COM7_FMT_MASK);
+	/*
+	 * Find our format again.  Kind of silly that we have to
+	 * search twice.  We know it exists, though, or try_fmt()
+	 * would have barfed.
+	 */
+	for (i = 0; i < N_OV7670_FMTS; i++)
+		if (ov7670_formats[i].pixelformat == pix->pixelformat)
+			break;
+	ov_write_regvals(c, ov7670_formats[i].regs);
+	return 0;
+}
+
+
+static int ov7670_command(struct i2c_client *c, unsigned int cmd, void *arg)
+{
+	switch (cmd) {
+	case OVCAMCHIP_CMD_S_CTRL:
+		return ov7670_set_v4l1_control(c, arg);
+	case OVCAMCHIP_CMD_G_CTRL:
+		return ov7670_get_v4l1_control(c, arg);
+	case OVCAMCHIP_CMD_S_MODE:
+		return ov7670_set_window(c, arg);
+	/*
+	 * Accept a few V4L2 ioctls directly.
+	 */
+	case VIDIOC_ENUM_FMT:
+		return ov7670_enum_fmt(c, (struct v4l2_fmtdesc *) arg);
+	case VIDIOC_TRY_FMT:
+		return ov7670_try_fmt(c, (struct v4l2_format *) arg);
+	case VIDIOC_S_FMT:
+		return ov7670_s_fmt(c, (struct v4l2_format *) arg);
+		
+	default:
+		DDEBUG(2, &c->dev, "command not supported: %d", cmd);
+		return -ENOIOCTLCMD;
+	}
+}
+
+struct ovcamchip_ops ov7670_ops = {
+	.init    =	ov7670_init,
+	.free    =	ov7670_free,
+	.command =	ov7670_command,
+};
diff -Nur -p linux-2.6.18.i586.orig/drivers/media/video/ovcamchip/ovcamchip_core.c linux-2.6.18.i586/drivers/media/video/ovcamchip/ovcamchip_core.c
--- linux-2.6.18.i586.orig/drivers/media/video/ovcamchip/ovcamchip_core.c	2006-10-16 14:11:59.000000000 -0400
+++ linux-2.6.18.i586/drivers/media/video/ovcamchip/ovcamchip_core.c	2006-10-16 14:19:41.000000000 -0400
@@ -46,6 +46,8 @@ MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 /* Registers common to all chips, that are needed for detection */
+#define GENERIC_REG_PID_HIGH	  0x0a	/* Product ID */
+#define GENERIC_REG_PID_LOW	  0x0b
 #define GENERIC_REG_ID_HIGH       0x1C	/* manufacturer ID MSB */
 #define GENERIC_REG_ID_LOW        0x1D	/* manufacturer ID LSB */
 #define GENERIC_REG_COM_I         0x29	/* misc ID bits */
@@ -55,6 +57,7 @@ extern struct ovcamchip_ops ov6x30_ops;
 extern struct ovcamchip_ops ov7x10_ops;
 extern struct ovcamchip_ops ov7x20_ops;
 extern struct ovcamchip_ops ov76be_ops;
+extern struct ovcamchip_ops ov7670_ops;
 
 static char *chip_names[NUM_CC_TYPES] = {
 	[CC_UNKNOWN]	= "Unknown chip",
@@ -66,6 +69,7 @@ static char *chip_names[NUM_CC_TYPES] = 
 	[CC_OV6630]	= "OV6630",
 	[CC_OV6630AE]	= "OV6630AE",
 	[CC_OV6630AF]	= "OV6630AF",
+	[CC_OV7670]	= "OV7670"
 };
 
 /* Forward declarations */
@@ -164,10 +168,27 @@ static int ov7xx0_detect(struct i2c_clie
 {
 	struct ovcamchip *ov = i2c_get_clientdata(c);
 	int rc;
-	unsigned char val;
+	unsigned char val, val2;
 
 	PDEBUG(4, "");
 
+	/*
+	 * Detect the 7670 via the product ID registers.  Not sure why
+	 * they aren't all done this way.
+	 */
+	rc = ov_read(c, GENERIC_REG_PID_HIGH, &val) +
+		ov_read(c, GENERIC_REG_PID_LOW, &val2);
+	if (rc < 0) {
+		PERROR("Error reading 0v7xx0 PID regs");
+		return -1;
+	}
+	if (val == 0x76 && val2 == 0x73) {
+		ov->subtype = CC_OV7670;
+		ov->sops = &ov7670_ops;	
+		PINFO("Camera chip is an OV7670");
+		return 0;
+	}
+
 	/* Detect chip (sub)type */
 	rc = ov_read(c, GENERIC_REG_COM_I, &val);
 	if (rc < 0) {
@@ -300,6 +321,7 @@ static int ovcamchip_attach(struct i2c_a
 	case I2C_HW_SMBUS_OV518:
 	case I2C_HW_SMBUS_OVFX2:
 	case I2C_HW_SMBUS_W9968CF:
+	case I2C_HW_SMBUS_M88ALP01:
 		PDEBUG(1, "Adapter ID 0x%06x accepted", adap->id);
 		break;
 	default:
diff -Nur -p linux-2.6.18.i586.orig/include/linux/i2c-id.h linux-2.6.18.i586/include/linux/i2c-id.h
--- linux-2.6.18.i586.orig/include/linux/i2c-id.h	2006-10-16 14:11:46.000000000 -0400
+++ linux-2.6.18.i586/include/linux/i2c-id.h	2006-10-16 14:19:34.000000000 -0400
@@ -249,6 +249,7 @@
 #define I2C_HW_SMBUS_OV518	0x04000f /* OV518(+) USB 1.1 webcam ICs */
 #define I2C_HW_SMBUS_OV519	0x040010 /* OV519 USB 1.1 webcam IC */
 #define I2C_HW_SMBUS_OVFX2	0x040011 /* Cypress/OmniVision FX2 webcam */
+#define I2C_HW_SMBUS_M88ALP01	0x040012 /* Marvell 88ALP01 cam  */
 
 /* --- ISA pseudo-adapter						*/
 #define I2C_HW_ISA		0x050000
diff -Nur -p linux-2.6.18.i586.orig/include/linux/videodev2.h linux-2.6.18.i586/include/linux/videodev2.h
--- linux-2.6.18.i586.orig/include/linux/videodev2.h	2006-10-16 14:11:44.000000000 -0400
+++ linux-2.6.18.i586/include/linux/videodev2.h	2006-10-16 14:19:52.000000000 -0400
@@ -244,6 +244,7 @@ struct v4l2_pix_format
 #define V4L2_PIX_FMT_YYUV    v4l2_fourcc('Y','Y','U','V') /* 16  YUV 4:2:2     */
 #define V4L2_PIX_FMT_HI240   v4l2_fourcc('H','I','2','4') /*  8  8-bit color   */
 #define V4L2_PIX_FMT_HM12    v4l2_fourcc('H','M','1','2') /*  8  YUV 4:1:1 16x16 macroblocks */
+#define V4L2_PIX_FMT_RGB444  v4l2_fourcc('R','4','4','4') /* 16  xxxxrrrr ggggbbbb */
 
 /* see http://www.siliconimaging.com/RGB%20Bayer.htm */
 #define V4L2_PIX_FMT_SBGGR8  v4l2_fourcc('B','A','8','1') /*  8  BGBG.. GRGR.. */
diff -Nur -p linux-2.6.18.i586.orig/include/media/ovcamchip.h linux-2.6.18.i586/include/media/ovcamchip.h
--- linux-2.6.18.i586.orig/include/media/ovcamchip.h	2006-10-16 14:11:39.000000000 -0400
+++ linux-2.6.18.i586/include/media/ovcamchip.h	2006-10-16 14:19:41.000000000 -0400
@@ -38,7 +38,7 @@ enum {
 };
 
 /* Chip types */
-#define NUM_CC_TYPES	9
+#define NUM_CC_TYPES	10
 enum {
 	CC_UNKNOWN,
 	CC_OV76BE,
@@ -49,6 +49,7 @@ enum {
 	CC_OV6630,
 	CC_OV6630AE,
 	CC_OV6630AF,
+	CC_OV7670
 };
 
 /* --------------------------------- */


Index: kernel-2.6.spec
===================================================================
RCS file: /cvs/dist/rpms/kernel/FC-6/kernel-2.6.spec,v
retrieving revision 1.2798
retrieving revision 1.2799
diff -u -r1.2798 -r1.2799
--- kernel-2.6.spec	16 Oct 2006 18:30:23 -0000	1.2798
+++ kernel-2.6.spec	16 Oct 2006 20:00:03 -0000	1.2799
@@ -498,6 +498,7 @@
 Patch1796: linux-2.6-hidp-compat.patch
 Patch1797: linux-2.6-cmtp-compat.patch
 Patch1798: linux-2.6-cafe-nand.patch
+Patch1799: linux-2.6-marvell-88alp01.patch
 
 # SELinux/audit patches.
 Patch1801: linux-2.6-selinux-mprotect-checks.patch
@@ -1117,6 +1118,8 @@
 %patch1791 -p1
 # OLPC touchpad
 %patch1792 -p1
+# Marvell 88ALP01 camera
+%patch1799 -p1
 %endif
 # Fixes for DUB-E100 vB1 usb ethernet
 %patch1794 -p1
@@ -2015,6 +2018,9 @@
 %endif
 
 %changelog
+* Mon Oct 16 2006 Marcelo Tosatti <mtosatti at redhat.com>
+- Add Marvell 88ALP01 camera controller support (OLPC)
+
 * Mon Oct 16 2006 Dave Jones <davej at redhat.com> 
 - Silence another noisy boot-time printk. (#210810)
 - Remove broken VIA quirk that prevented booting on some EPIAs (#210817)


Index: config-olpc-generic
===================================================================
RCS file: /cvs/dist/rpms/kernel/FC-6/config-olpc-generic,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- config-olpc-generic	16 Oct 2006 01:41:08 -0000	1.13
+++ config-olpc-generic	16 Oct 2006 20:00:04 -0000	1.14
@@ -365,6 +365,8 @@
 # CONFIG_TUNER_3036 is not set
 # CONFIG_VIDEO_SAA7134 is not set
 # CONFIG_VIDEO_CX88 is not set
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_VIDEO_M88ALP01_CCIC=m
 # CONFIG_VIDEO_MSP3400 is not set
 # CONFIG_VIDEO_CS53L32A is not set
 # CONFIG_VIDEO_TLV320AIC23B is not set




More information about the fedora-cvs-commits mailing list