* Re: [PATCH 1/4] [PATCH] ARM: OMAP: Update camera sensor interface
@ 2007-03-02 16:37 Sakari Ailus
0 siblings, 0 replies; 2+ messages in thread
From: Sakari Ailus @ 2007-03-02 16:37 UTC (permalink / raw)
To: ext Trilok Soni; +Cc: linux-omap-open-source
Hi,
(Sorry for not replying, I just recently ordered this list.)
> From: Trilok Soni <soni.trilok@gmail.com>
...
> +#define PAR_MODE_NOBT8 0
> +#define PAR_MODE_NOBT10 1
> +#define PAR_MODE_NOBT12 2
> +#define PAR_MODE_BT8 4
> +#define PAR_MODE_BT10 5
> +
> +#define SYNC_ACTIVE_HIGH 0
> +#define SYNC_ACTIVE_LOW 1
How about prefixing these with OMAP_SENSOR_ or something?
> +#define V4L2_BUF_TYPE_STILL_CAPTURE V4L2_BUF_TYPE_PRIVATE
> +
> struct omap_camera_sensor {
> unsigned int version;
> char name[OMAP_SENSOR_NAME_LEN + 1];
>
> - void *(*init)(struct v4l2_pix_format *);
> + int parallel_mode; /* parallel I/F mode */
> + int hs_polarity; /* horizontal sync polarity */
> + int vs_polarity; /* vertical sync polarity */
> + int image_swap; /* image swap or not */
> + int bt_correction; /* BT correction enabled or not */
It's probably good to add here more information about the sensor. OV9640
has differences in these compared to TCP825x? Or the Micron sensor?
> + /* init the sensor with the passed pix format. A none zero private
> + pointer must be returned on success. The same pointer is passed
> + back for all other functions. This gives a sensor driver the
> + chance to handle multiple sensor. */
Multiple sensor support is ability to handle different sensors?
What do you think of giving names to the function arguments?
> + void *(*init)(struct v4l2_pix_format *, struct v4l2_pix_format *);
...
> + /* These are only for those sensors that use a different sensor
context
> + for still image capture. A simple sensor driver doesn't have to
> + implement them. */
> + int (*try_format_still_capture) (struct v4l2_pix_format *, void *);
> + int (*configure_still_capture) (struct v4l2_pix_format *,
unsigned long,
> + struct v4l2_fract *, void *);
> + unsigned long (*calc_xclk_still_capture) (struct v4l2_pix_format *,
> + struct v4l2_fract *, void *);
> + int (*enter_still_capture) (int, void *);
> + int (*exit_still_capture) (void *);
Probably capturing still images and video is exclusive at least here?
I've been thinking that omap24xxcam_poll mess...
--
Sakari Ailus
sakari.ailus@nokia.com
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 1/4] [PATCH] ARM: OMAP: Update camera sensor interface
@ 2007-02-15 11:28 Trilok Soni
0 siblings, 0 replies; 2+ messages in thread
From: Trilok Soni @ 2007-02-15 11:28 UTC (permalink / raw)
To: linux-omap-open-source
[-- Attachment #1: Type: text/plain, Size: 18 bytes --]
--
--Trilok Soni
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ARM-OMAP-Update-camera-sensor-interface.patch --]
[-- Type: text/x-patch; name="0001-ARM-OMAP-Update-camera-sensor-interface.patch", Size: 30923 bytes --]
From 50a5355a45f096c99e9b8a536b07296d1ff692de Mon Sep 17 00:00:00 2001
From: Trilok Soni <soni.trilok@gmail.com>
Date: Thu, 15 Feb 2007 20:49:40 +0530
Subject: [PATCH 1/4] [PATCH] ARM: OMAP: Update camera sensor interface
- Remove whitespaces
- Update sensor inteface to accomodate Micron sensor.
- Update ov9640 sensor driver accoradingly.
Signed-off-by: Trilok Soni <soni.trilok@gmail.com>
---
drivers/media/video/omap/sensor_if.h | 59 +++++++--
drivers/media/video/omap/sensor_ov9640.c | 223 +++++++++++++++---------------
2 files changed, 162 insertions(+), 120 deletions(-)
diff --git a/drivers/media/video/omap/sensor_if.h b/drivers/media/video/omap/sensor_if.h
index 47bb716..4eee8b7 100644
--- a/drivers/media/video/omap/sensor_if.h
+++ b/drivers/media/video/omap/sensor_if.h
@@ -1,48 +1,87 @@
/*
* drivers/media/video/omap/sensor_if.h
*
- * Copyright (C) 2004 Texas Instruments, Inc.
- *
+ * Copyright (C) 2004 Texas Instruments, Inc.
+ *
* Sensor interface to OMAP camera capture drivers
* Sensor driver should implement this interface
*
- * 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.
*/
-
+
#ifndef OMAP_SENSOR_IF_H
#define OMAP_SENSOR_IF_H
#define OMAP_SENSOR_NAME_LEN 31
+#define PAR_MODE_NOBT8 0
+#define PAR_MODE_NOBT10 1
+#define PAR_MODE_NOBT12 2
+#define PAR_MODE_BT8 4
+#define PAR_MODE_BT10 5
+
+#define SYNC_ACTIVE_HIGH 0
+#define SYNC_ACTIVE_LOW 1
+
+#define V4L2_BUF_TYPE_STILL_CAPTURE V4L2_BUF_TYPE_PRIVATE
+
struct omap_camera_sensor {
unsigned int version;
char name[OMAP_SENSOR_NAME_LEN + 1];
- void *(*init)(struct v4l2_pix_format *);
+ int parallel_mode; /* parallel I/F mode */
+ int hs_polarity; /* horizontal sync polarity */
+ int vs_polarity; /* vertical sync polarity */
+ int image_swap; /* image swap or not */
+ int bt_correction; /* BT correction enabled or not */
+
+ /* init the sensor with the passed pix format. A none zero private
+ pointer must be returned on success. The same pointer is passed
+ back for all other functions. This gives a sensor driver the
+ chance to handle multiple sensor. */
+ void *(*init)(struct v4l2_pix_format *, struct v4l2_pix_format *);
+ /* clean up the sensor */
int (*cleanup)(void *);
+ /* These are for power management */
int (*power_on)(void *);
int (*power_off)(void *);
+ /* Handle V4L2 fmt IOCTLs */
int (*enum_pixformat)(struct v4l2_fmtdesc *, void *);
int (*try_format)(struct v4l2_pix_format *, void *);
+ /* Calculated the needed xclk for the pix format passed and the
+ desired capture rate. */
unsigned long (*calc_xclk)(struct v4l2_pix_format *,
struct v4l2_fract *, void *);
int (*configure)(struct v4l2_pix_format *, unsigned long,
struct v4l2_fract *, void *);
+ /* These handle V4L2 control IOCTLs */
int (*query_control) (struct v4l2_queryctrl *, void *);
int (*get_control)(struct v4l2_control *, void *);
int (*set_control)(struct v4l2_control *, void *);
+
+ /* These are only for those sensors that use a different sensor context
+ for still image capture. A simple sensor driver doesn't have to
+ implement them. */
+ int (*try_format_still_capture) (struct v4l2_pix_format *, void *);
+ int (*configure_still_capture) (struct v4l2_pix_format *, unsigned long,
+ struct v4l2_fract *, void *);
+ unsigned long (*calc_xclk_still_capture) (struct v4l2_pix_format *,
+ struct v4l2_fract *, void *);
+ int (*enter_still_capture) (int, void *);
+ int (*exit_still_capture) (void *);
+
};
extern struct omap_camera_sensor camera_sensor_if;
diff --git a/drivers/media/video/omap/sensor_ov9640.c b/drivers/media/video/omap/sensor_ov9640.c
index 78c8250..49dab65 100644
--- a/drivers/media/video/omap/sensor_ov9640.c
+++ b/drivers/media/video/omap/sensor_ov9640.c
@@ -1,4 +1,3 @@
-
/*
* drivers/media/video/omap/sensor_ov9640.c
*
@@ -9,8 +8,8 @@
* Copyright (C) 2004 MontaVista Software, Inc.
* Copyright (C) 2004 Texas Instruments.
*
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
* kind, whether express or implied.
*/
@@ -113,7 +112,7 @@ const static struct v4l2_fmtdesc ov9640_formats[] = {
#define OV9640_REG_TERM 0xFF /* terminating list entry for reg */
#define OV9640_VAL_TERM 0xFF /* terminating list entry for val */
-/* common OV9640 register initialization for all image sizes, pixel formats,
+/* common OV9640 register initialization for all image sizes, pixel formats,
* and frame rates
*/
const static struct ov9640_reg ov9640_common[] = {
@@ -161,7 +160,7 @@ const static struct ov9640_reg ov9640_common[] = {
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
-/* OV9640 register configuration for all combinations of pixel format and
+/* OV9640 register configuration for all combinations of pixel format and
* image size
*/
/* YUV (YCbCr) QQCIF */
@@ -171,7 +170,7 @@ const static struct ov9640_reg qqcif_yuv[] = {
{ 0x4F, 0x50 }, { 0x50, 0x43 }, { 0x51, 0x0D }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x19 }, { 0x53, 0x4C }, { 0x54, 0x65 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x40 }, { 0x56, 0x40 }, { 0x57, 0x40 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x0F }, /* MTXS */
+ { 0x58, 0x0F }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* YUV (YCbCr) QQVGA */
@@ -181,7 +180,7 @@ const static struct ov9640_reg qqvga_yuv[] = {
{ 0x4F, 0x50 }, { 0x50, 0x43 }, { 0x51, 0x0D }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x19 }, { 0x53, 0x4C }, { 0x54, 0x65 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x40 }, { 0x56, 0x40 }, { 0x57, 0x40 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x0F }, /* MTXS */
+ { 0x58, 0x0F }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* YUV (YCbCr) QCIF */
@@ -191,7 +190,7 @@ const static struct ov9640_reg qcif_yuv[] = {
{ 0x4F, 0x50 }, { 0x50, 0x43 }, { 0x51, 0x0D }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x19 }, { 0x53, 0x4C }, { 0x54, 0x65 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x40 }, { 0x56, 0x40 }, { 0x57, 0x40 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x0F }, /* MTXS */
+ { 0x58, 0x0F }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* YUV (YCbCr) QVGA */
@@ -201,7 +200,7 @@ const static struct ov9640_reg qvga_yuv[] = {
{ 0x4F, 0x50 }, { 0x50, 0x43 }, { 0x51, 0x0D }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x19 }, { 0x53, 0x4C }, { 0x54, 0x65 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x40 }, { 0x56, 0x40 }, { 0x57, 0x40 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x0F }, /* MTXS */
+ { 0x58, 0x0F }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* YUV (YCbCr) CIF */
@@ -211,7 +210,7 @@ const static struct ov9640_reg cif_yuv[] = {
{ 0x4F, 0x50 }, { 0x50, 0x43 }, { 0x51, 0x0D }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x19 }, { 0x53, 0x4C }, { 0x54, 0x65 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x40 }, { 0x56, 0x40 }, { 0x57, 0x40 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x0F }, /* MTXS */
+ { 0x58, 0x0F }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* YUV (YCbCr) VGA */
@@ -221,7 +220,7 @@ const static struct ov9640_reg vga_yuv[] = {
{ 0x4F, 0x50 }, { 0x50, 0x43 }, { 0x51, 0x0D }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x19 }, { 0x53, 0x4C }, { 0x54, 0x65 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x40 }, { 0x56, 0x40 }, { 0x57, 0x40 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x0F }, /* MTXS */
+ { 0x58, 0x0F }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* YUV (YCbCr) SXGA */
@@ -231,7 +230,7 @@ const static struct ov9640_reg sxga_yuv[] = {
{ 0x4F, 0x50 }, { 0x50, 0x43 }, { 0x51, 0x0D }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x19 }, { 0x53, 0x4C }, { 0x54, 0x65 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x40 }, { 0x56, 0x40 }, { 0x57, 0x40 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x0F }, /* MTXS */
+ { 0x58, 0x0F }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB565 QQCIF */
@@ -241,7 +240,7 @@ const static struct ov9640_reg qqcif_565[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB565 QQVGA */
@@ -251,7 +250,7 @@ const static struct ov9640_reg qqvga_565[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB565 QCIF */
@@ -261,7 +260,7 @@ const static struct ov9640_reg qcif_565[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB565 QVGA */
@@ -271,7 +270,7 @@ const static struct ov9640_reg qvga_565[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB565 CIF */
@@ -281,7 +280,7 @@ const static struct ov9640_reg cif_565[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB565 VGA */
@@ -291,7 +290,7 @@ const static struct ov9640_reg vga_565[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB565 SXGA */
@@ -301,7 +300,7 @@ const static struct ov9640_reg sxga_565[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB555 QQCIF */
@@ -311,7 +310,7 @@ const static struct ov9640_reg qqcif_555[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB555 QQVGA */
@@ -321,7 +320,7 @@ const static struct ov9640_reg qqvga_555[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB555 QCIF */
@@ -331,7 +330,7 @@ const static struct ov9640_reg qcif_555[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB555 QVGA */
@@ -341,7 +340,7 @@ const static struct ov9640_reg qvga_555[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB555 CIF */
@@ -351,7 +350,7 @@ const static struct ov9640_reg cif_555[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB555 VGA */
@@ -361,7 +360,7 @@ const static struct ov9640_reg vga_555[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
/* RGB555 SXGA */
@@ -371,11 +370,11 @@ const static struct ov9640_reg sxga_555[] = {
{ 0x4F, 0x71 }, { 0x50, 0x3E }, { 0x51, 0x0C }, /* MTX1, MTX2, MTX3 */
{ 0x52, 0x33 }, { 0x53, 0x72 }, { 0x54, 0x00 }, /* MTX4, MTX5, MTX6 */
{ 0x55, 0x2B }, { 0x56, 0x66 }, { 0x57, 0xD2 }, /* MTX7, MTX8, MTX9 */
- { 0x58, 0x65 }, /* MTXS */
+ { 0x58, 0x65 }, /* MTXS */
{ OV9640_REG_TERM, OV9640_VAL_TERM }
};
-
+
#define DEF_GAIN 31
#define DEF_AUTOGAIN 1
#define DEF_EXPOSURE 154
@@ -443,12 +442,12 @@ const static struct ov9640_reg *
};
-/*
- * Read a value from a register in an OV9640 sensor device. The value is
+/*
+ * Read a value from a register in an OV9640 sensor device. The value is
* returned in 'val'.
* Returns zero if successful, or non-zero otherwise.
*/
-static int
+static int
ov9640_read_reg(struct i2c_client *client, u8 reg, u8 *val)
{
int err;
@@ -478,7 +477,7 @@ ov9640_read_reg(struct i2c_client *client, u8 reg, u8 *val)
/* Write a value to a register in an OV9640 sensor device.
* Returns zero if successful, or non-zero otherwise.
*/
-static int
+static int
ov9640_write_reg(struct i2c_client *client, u8 reg, u8 val)
{
int err;
@@ -487,7 +486,7 @@ ov9640_write_reg(struct i2c_client *client, u8 reg, u8 val)
if (!client->adapter)
return -ENODEV;
-
+
msg->addr = client->addr;
msg->flags = 0;
msg->len = 2;
@@ -500,7 +499,7 @@ ov9640_write_reg(struct i2c_client *client, u8 reg, u8 val)
return err;
}
-static int
+static int
ov9640_write_reg_mask(struct i2c_client *client, u8 reg, u8 *val, u8 mask)
{
u8 oldval, newval;
@@ -528,7 +527,7 @@ ov9640_write_reg_mask(struct i2c_client *client, u8 reg, u8 *val, u8 mask)
return 0;
}
-static int
+static int
ov9640_read_reg_mask(struct i2c_client *client, u8 reg, u8 *val, u8 mask)
{
int rc;
@@ -541,17 +540,17 @@ ov9640_read_reg_mask(struct i2c_client *client, u8 reg, u8 *val, u8 mask)
}
/* Initialize a list of OV9640 registers.
- * The list of registers is terminated by the pair of values
+ * The list of registers is terminated by the pair of values
* { OV9640_REG_TERM, OV9640_VAL_TERM }.
* Returns zero if successful, or non-zero otherwise.
*/
-static int
+static int
ov9640_write_regs(struct i2c_client *client, const struct ov9640_reg reglist[])
{
int err;
const struct ov9640_reg *next = reglist;
-
- while (!((next->reg == OV9640_REG_TERM)
+
+ while (!((next->reg == OV9640_REG_TERM)
&& (next->val == OV9640_VAL_TERM)))
{
err = ov9640_write_reg(client, next->reg, next->val);
@@ -580,12 +579,12 @@ find_vctrl(int id)
return i;
}
-/* Calculate the internal clock divisor (value of the CLKRC register) of the
- * OV9640 given the image size, the frequency (in Hz) of its XCLK input and a
- * desired frame period (in seconds). The frame period 'fper' is expressed as
+/* Calculate the internal clock divisor (value of the CLKRC register) of the
+ * OV9640 given the image size, the frequency (in Hz) of its XCLK input and a
+ * desired frame period (in seconds). The frame period 'fper' is expressed as
* a fraction. The frame period is an input/output parameter.
- * Returns the value of the OV9640 CLKRC register that will yield the frame
- * period returned in 'fper' at the specified xclk frequency. The
+ * Returns the value of the OV9640 CLKRC register that will yield the frame
+ * period returned in 'fper' at the specified xclk frequency. The
* returned period will be as close to the requested period as possible.
*/
static unsigned char
@@ -597,11 +596,11 @@ ov9640_clkrc(enum image_size isize, unsigned long xclk, struct v4l2_fract *fper)
#ifdef CONFIG_ARCH_OMAP24XX
const static unsigned long clks_per_frame[] =
{ 200000, 400000, 200000, 400000, 400000, 800000, 3200000 };
- /* QQCIF QQVGA QCIF QVGA CIF VGA SXGA
+ /* QQCIF QQVGA QCIF QVGA CIF VGA SXGA
* 199680,400000, 199680, 400000, 399360, 800000, 3200000
*/
#else
- const static unsigned long clks_per_frame[] =
+ const static unsigned long clks_per_frame[] =
{ 200000, 200000, 200000, 200000, 400000, 800000, 3200000 };
#endif
@@ -652,15 +651,15 @@ ov9640_clkrc(enum image_size isize, unsigned long xclk, struct v4l2_fract *fper)
return (0x80 | (divisor - 1));
}
-/* Configure the OV9640 for a specified image size, pixel format, and frame
- * period. xclk is the frequency (in Hz) of the xclk input to the OV9640.
+/* Configure the OV9640 for a specified image size, pixel format, and frame
+ * period. xclk is the frequency (in Hz) of the xclk input to the OV9640.
* fper is the frame period (in seconds) expressed as a fraction.
* Returns zero if successful, or non-zero otherwise.
* The actual frame period is returned in fper.
*/
static int
-ov9640_configure(struct i2c_client *client,
- enum image_size isize,
+ov9640_configure(struct i2c_client *client,
+ enum image_size isize,
enum pixel_format pfmt,
unsigned long xclk,
struct v4l2_fract *fper)
@@ -754,14 +753,14 @@ ov9640sensor_power_off(void *priv)
return ov9640_powerdown();
}
-/* Detect if an OV9640 is present, and if so which revision.
- * A device is considered to be detected if the manufacturer ID (MIDH and MIDL)
- * and the product ID (PID) registers match the expected values.
+/* Detect if an OV9640 is present, and if so which revision.
+ * A device is considered to be detected if the manufacturer ID (MIDH and MIDL)
+ * and the product ID (PID) registers match the expected values.
* Any value of the version ID (VER) register is accepted.
* Here are the version numbers we know about:
* 0x48 --> OV9640 Revision 1 or OV9640 Revision 2
* 0x49 --> OV9640 Revision 3
- * Returns a negative error number if no device is detected, or the
+ * Returns a negative error number if no device is detected, or the
* non-negative value of the version ID register if a device is detected.
*/
static int
@@ -771,7 +770,7 @@ ov9640_detect(struct i2c_client *client)
if (!client)
return -ENODEV;
-
+
if (ov9640_read_reg(client, OV9640_MIDH, &midh))
return -ENODEV;
if (ov9640_read_reg(client, OV9640_MIDL, &midl))
@@ -781,11 +780,11 @@ ov9640_detect(struct i2c_client *client)
if (ov9640_read_reg(client, OV9640_VER, &ver))
return -ENODEV;
- if ((midh != OV9640_MIDH_MAGIC)
+ if ((midh != OV9640_MIDH_MAGIC)
|| (midl != OV9640_MIDL_MAGIC)
|| (pid != OV9640_PID_MAGIC))
{
- /* We didn't read the values we expected, so
+ /* We didn't read the values we expected, so
* this must not be an OV9640.
*/
return -ENODEV;
@@ -795,14 +794,14 @@ ov9640_detect(struct i2c_client *client)
static struct i2c_driver ov9640sensor_i2c_driver;
-/* This function registers an I2C client via i2c_attach_client() for an OV9640
- * sensor device. If 'probe' is non-zero, then the I2C client is only
- * registered if the device can be detected. If 'probe' is zero, then no
+/* This function registers an I2C client via i2c_attach_client() for an OV9640
+ * sensor device. If 'probe' is non-zero, then the I2C client is only
+ * registered if the device can be detected. If 'probe' is zero, then no
* device detection is attempted and the I2C client is always registered.
- * Returns zero if an I2C client is successfully registered, or non-zero
+ * Returns zero if an I2C client is successfully registered, or non-zero
* otherwise.
*/
-static int
+static int
ov9640_i2c_attach_client(struct i2c_adapter *adap, int addr, int probe)
{
struct ov9640_sensor *sensor = &ov9640;
@@ -835,13 +834,13 @@ ov9640_i2c_attach_client(struct i2c_adapter *adap, int addr, int probe)
return 0;
}
-/* This function is called by i2c_del_adapter() and i2c_del_driver()
- * if the adapter or driver with which this I2C client is associated is
+/* This function is called by i2c_del_adapter() and i2c_del_driver()
+ * if the adapter or driver with which this I2C client is associated is
* removed. This function unregisters the client via i2c_detach_client().
- * Returns zero if the client is successfully detached, or non-zero
+ * Returns zero if the client is successfully detached, or non-zero
* otherwise.
*/
-static int
+static int
ov9640_i2c_detach_client(struct i2c_client *client)
{
int err;
@@ -855,26 +854,26 @@ ov9640_i2c_detach_client(struct i2c_client *client)
return err;
}
-/* This function will be called for each registered I2C bus adapter when our
- * I2C driver is registered via i2c_add_driver(). It will also be called
+/* This function will be called for each registered I2C bus adapter when our
+ * I2C driver is registered via i2c_add_driver(). It will also be called
* whenever a new I2C adapter is registered after our I2C driver is registered.
- * This function probes the specified I2C bus adapter to determine if an
- * OV9640 sensor device is present. If a device is detected, an I2C client
- * is registered for it via ov9640_i2c_attach_client(). Note that we can't use
- * the standard i2c_probe() function to look for the sensor because the OMAP
+ * This function probes the specified I2C bus adapter to determine if an
+ * OV9640 sensor device is present. If a device is detected, an I2C client
+ * is registered for it via ov9640_i2c_attach_client(). Note that we can't use
+ * the standard i2c_probe() function to look for the sensor because the OMAP
* I2C controller doesn't support probing.
- * Returns zero if an OV9640 device is detected and an I2C client successfully
+ * Returns zero if an OV9640 device is detected and an I2C client successfully
* registered for it, or non-zero otherwise.
*/
-static int
+static int
ov9640_i2c_probe_adapter(struct i2c_adapter *adap)
{
return ov9640_i2c_attach_client(adap, OV9640_I2C_ADDR, 1);
}
-/* Find the best match for a requested image capture size. The best match
- * is chosen as the nearest match that has the same number or fewer pixels
- * as the requested size, or the smallest image size if the requested size
+/* Find the best match for a requested image capture size. The best match
+ * is chosen as the nearest match that has the same number or fewer pixels
+ * as the requested size, or the smallest image size if the requested size
* has fewer pixels than the smallest image.
*/
static enum image_size
@@ -893,7 +892,7 @@ ov9640_find_size(unsigned int width, unsigned int height)
return SXGA;
}
-/* following are sensor interface functions implemented by
+/* following are sensor interface functions implemented by
* OV9640 sensor driver.
*/
static int
@@ -920,16 +919,16 @@ ov9640sensor_get_control(struct v4l2_control *vc, void *priv)
struct i2c_client *client = &sensor->client;
int i, val;
struct vcontrol * lvc;
-
+
i = find_vctrl(vc->id);
if (i < 0)
return -EINVAL;
- lvc = &control[i];
+ lvc = &control[i];
if (ov9640_read_reg_mask(client, lvc->reg, (u8 *)&val, lvc->mask))
return -EIO;
-
- val = val >> lvc->start_bit;
+
+ val = val >> lvc->start_bit;
if (val >= 0) {
vc->value = lvc->current_value = val;
return 0;
@@ -997,8 +996,8 @@ ov9640sensor_enum_pixformat(struct v4l2_fmtdesc *fmt, void *priv)
return 0;
}
-/* Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
- * ioctl is used to negotiate the image capture size and pixel format
+/* Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
+ * ioctl is used to negotiate the image capture size and pixel format
* without actually making it take effect.
*/
static int
@@ -1037,9 +1036,9 @@ ov9640sensor_try_format(struct v4l2_pix_format *pix, void *priv)
return 0;
}
-/* Given the image capture format in pix, the nominal frame period in
- * timeperframe, calculate the required xclk frequency
- * The nominal xclk input frequency of the OV9640 is 24MHz, maximum
+/* Given the image capture format in pix, the nominal frame period in
+ * timeperframe, calculate the required xclk frequency
+ * The nominal xclk input frequency of the OV9640 is 24MHz, maximum
* frequency is 48MHz, and minimum frequency is 10MHz.
*/
static unsigned long
@@ -1048,18 +1047,18 @@ ov9640sensor_calc_xclk(struct v4l2_pix_format *pix,
{
unsigned long tgt_xclk; /* target xclk */
unsigned long tgt_fpm; /* target frames per minute */
- enum image_size isize;
-
- /* We use arbitrary rules to select the xclk frequency. If the
- * capture size is VGA and the frame rate is greater than 900
- * frames per minute, or if the capture size is SXGA and the
- * frame rate is greater than 450 frames per minutes, then the
- * xclk frequency will be set to 48MHz. Otherwise, the xclk
- * frequency will be set to 24MHz. If the mclk frequency is such that
- * the target xclk frequency is not achievable, then xclk will be set
+ enum image_size isize;
+
+ /* We use arbitrary rules to select the xclk frequency. If the
+ * capture size is VGA and the frame rate is greater than 900
+ * frames per minute, or if the capture size is SXGA and the
+ * frame rate is greater than 450 frames per minutes, then the
+ * xclk frequency will be set to 48MHz. Otherwise, the xclk
+ * frequency will be set to 24MHz. If the mclk frequency is such that
+ * the target xclk frequency is not achievable, then xclk will be set
* as close as to the target as possible.
*/
- if ((timeperframe->numerator == 0)
+ if ((timeperframe->numerator == 0)
|| (timeperframe->denominator == 0))
{
/* supply a default nominal_timeperframe of 15 fps */
@@ -1094,7 +1093,7 @@ ov9640sensor_configure(struct v4l2_pix_format *pix, unsigned long xclk,
struct v4l2_fract *timeperframe, void *priv)
{
struct ov9640_sensor *sensor = (struct ov9640_sensor *) priv;
- enum pixel_format pfmt = YUV;
+ enum pixel_format pfmt = YUV;
switch (pix->pixelformat) {
case V4L2_PIX_FMT_RGB565:
@@ -1109,7 +1108,7 @@ ov9640sensor_configure(struct v4l2_pix_format *pix, unsigned long xclk,
case V4L2_PIX_FMT_UYVY:
default:
pfmt = YUV;
- }
+ }
return ov9640_configure(&sensor->client,
ov9640_find_size(pix->width, pix->height),
@@ -1118,7 +1117,7 @@ ov9640sensor_configure(struct v4l2_pix_format *pix, unsigned long xclk,
/* Prepare for the driver to exit.
* Balances ov9640sensor_init().
- * This function must de-initialize the sensor and its associated data
+ * This function must de-initialize the sensor and its associated data
* structures.
*/
static int
@@ -1129,7 +1128,7 @@ ov9640sensor_cleanup(void *priv)
if (sensor) {
i2c_del_driver(&ov9640sensor_i2c_driver);
ov9640_powerdown();
- }
+ }
return 0;
}
@@ -1145,21 +1144,21 @@ static struct i2c_driver ov9640sensor_i2c_driver = {
/* Initialize the OV9640 sensor.
- * This routine allocates and initializes the data structure for the sensor,
- * powers up the sensor, registers the I2C driver, and sets a default image
- * capture format in pix. The capture format is not actually programmed
+ * This routine allocates and initializes the data structure for the sensor,
+ * powers up the sensor, registers the I2C driver, and sets a default image
+ * capture format in pix. The capture format is not actually programmed
* into the OV9640 sensor by this routine.
- * This function must return a non-NULL value to indicate that
+ * This function must return a non-NULL value to indicate that
* initialization is successful.
*/
static void *
-ov9640sensor_init(struct v4l2_pix_format *pix)
+ov9640sensor_init(struct v4l2_pix_format *pix, struct v4l2_pix_format *pix2)
{
struct ov9640_sensor *sensor = &ov9640;
- int err;
+ int err;
memset(sensor, 0, sizeof(*sensor));
-
+
/* power-up the sensor */
if (ov9640_powerup())
return NULL;
@@ -1170,12 +1169,12 @@ ov9640sensor_init(struct v4l2_pix_format *pix)
return NULL;
}
if (!sensor->client.adapter) {
- printk(KERN_WARNING
+ printk(KERN_WARNING
"Failed to detect OV9640 sensor chip.\n");
return NULL;
}
else
- printk(KERN_INFO
+ printk(KERN_INFO
"OV9640 sensor chip version 0x%02x detected\n", sensor->ver);
/* Make the default capture format QCIF RGB565 */
@@ -1190,6 +1189,10 @@ ov9640sensor_init(struct v4l2_pix_format *pix)
struct omap_camera_sensor camera_sensor_if = {
.version = 0x01,
.name = "OV9640",
+ .parallel_mode = PAR_MODE_NOBT8,
+ .hs_polarity = SYNC_ACTIVE_HIGH,
+ .vs_polarity = SYNC_ACTIVE_LOW,
+ .image_swap = 0,
.init = ov9640sensor_init,
.cleanup = ov9640sensor_cleanup,
.enum_pixformat = ov9640sensor_enum_pixformat,
@@ -1215,6 +1218,6 @@ void print_ov9640_regs(void *priv)
if (ov9640_read_reg(&sensor->client,reg,&val))
printk("error reading %x\n", reg);
else
- printk("reg %x = %x\n", reg, val);
+ printk("reg %x = %x\n", reg, val);
}
#endif
--
1.5.0
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-03-02 16:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-02 16:37 [PATCH 1/4] [PATCH] ARM: OMAP: Update camera sensor interface Sakari Ailus
-- strict thread matches above, loose matches on Subject: below --
2007-02-15 11:28 Trilok Soni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox