aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2010-10-19 20:32:11 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-21 11:45:28 -0400
commit024fafbac36b176d978ccd0fb1cae1fbc38c7fee (patch)
tree02b52bf8c6104ab4a8f7bcdf87741aee4b219f3b
parentdc4589c814a3a50a4cfc2077690fc7fd397308c8 (diff)
[media] Add the via framebuffer camera controller driver
Add a driver for the video capture port on VIA integrated chipsets. This version has a remaining OLPCism or two and expects to be talking to an ov7670; those can be improved as the need arises. This work was supported by the One Laptop Per Child project. Thanks to Laurent Pinchart for a number of useful comments. Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/Kconfig10
-rw-r--r--drivers/media/video/Makefile2
-rw-r--r--drivers/media/video/via-camera.c1474
-rw-r--r--drivers/media/video/via-camera.h93
-rw-r--r--drivers/video/via/accel.c2
-rw-r--r--drivers/video/via/via-core.c16
-rw-r--r--include/linux/via-core.h4
-rw-r--r--include/media/v4l2-chip-ident.h4
8 files changed, 1601 insertions, 4 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 2d4226710ed5..0efbb29a1a08 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -712,6 +712,16 @@ config VIDEO_SR030PC30
712 ---help--- 712 ---help---
713 This driver supports SR030PC30 VGA camera from Siliconfile 713 This driver supports SR030PC30 VGA camera from Siliconfile
714 714
715config VIDEO_VIA_CAMERA
716 tristate "VIAFB camera controller support"
717 depends on FB_VIA
718 select VIDEOBUF_DMA_SG
719 select VIDEO_OV7670
720 help
721 Driver support for the integrated camera controller in VIA
722 Chrome9 chipsets. Currently only tested on OLPC xo-1.5 systems
723 with ov7670 sensors.
724
715config SOC_CAMERA 725config SOC_CAMERA
716 tristate "SoC camera support" 726 tristate "SoC camera support"
717 depends on VIDEO_V4L2 && HAS_DMA && I2C 727 depends on VIDEO_V4L2 && HAS_DMA && I2C
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index d5e49ddbf9dd..af79d476a4c8 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -122,6 +122,8 @@ obj-$(CONFIG_VIDEO_CX2341X) += cx2341x.o
122 122
123obj-$(CONFIG_VIDEO_CAFE_CCIC) += cafe_ccic.o 123obj-$(CONFIG_VIDEO_CAFE_CCIC) += cafe_ccic.o
124 124
125obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o
126
125obj-$(CONFIG_USB_DABUSB) += dabusb.o 127obj-$(CONFIG_USB_DABUSB) += dabusb.o
126obj-$(CONFIG_USB_SE401) += se401.o 128obj-$(CONFIG_USB_SE401) += se401.o
127obj-$(CONFIG_USB_ZR364XX) += zr364xx.o 129obj-$(CONFIG_USB_ZR364XX) += zr364xx.o
diff --git a/drivers/media/video/via-camera.c b/drivers/media/video/via-camera.c
new file mode 100644
index 000000000000..02a21bccae18
--- /dev/null
+++ b/drivers/media/video/via-camera.c
@@ -0,0 +1,1474 @@
1/*
2 * Driver for the VIA Chrome integrated camera controller.
3 *
4 * Copyright 2009,2010 Jonathan Corbet <corbet@lwn.net>
5 * Distributable under the terms of the GNU General Public License, version 2
6 *
7 * This work was supported by the One Laptop Per Child project
8 */
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/device.h>
12#include <linux/list.h>
13#include <linux/pci.h>
14#include <linux/gpio.h>
15#include <linux/interrupt.h>
16#include <linux/pci.h>
17#include <linux/platform_device.h>
18#include <linux/videodev2.h>
19#include <media/v4l2-device.h>
20#include <media/v4l2-ioctl.h>
21#include <media/v4l2-chip-ident.h>
22#include <media/videobuf-dma-sg.h>
23#include <linux/device.h>
24#include <linux/delay.h>
25#include <linux/dma-mapping.h>
26#include <linux/pm_qos_params.h>
27#include <linux/via-core.h>
28#include <linux/via-gpio.h>
29#include <linux/via_i2c.h>
30
31#include "via-camera.h"
32
33MODULE_AUTHOR("Jonathan Corbet <corbet@lwn.net>");
34MODULE_DESCRIPTION("VIA framebuffer-based camera controller driver");
35MODULE_LICENSE("GPL");
36
37static int flip_image;
38module_param(flip_image, bool, 0444);
39MODULE_PARM_DESC(flip_image,
40 "If set, the sensor will be instructed to flip the image "
41 "vertically.");
42
43#ifdef CONFIG_OLPC_XO_1_5
44static int override_serial;
45module_param(override_serial, bool, 0444);
46MODULE_PARM_DESC(override_serial,
47 "The camera driver will normally refuse to load if "
48 "the XO 1.5 serial port is enabled. Set this option "
49 "to force the issue.");
50#endif
51
52/*
53 * Basic window sizes.
54 */
55#define VGA_WIDTH 640
56#define VGA_HEIGHT 480
57#define QCIF_WIDTH 176
58#define QCIF_HEIGHT 144
59
60/*
61 * The structure describing our camera.
62 */
63enum viacam_opstate { S_IDLE = 0, S_RUNNING = 1 };
64
65struct via_camera {
66 struct v4l2_device v4l2_dev;
67 struct video_device vdev;
68 struct v4l2_subdev *sensor;
69 struct platform_device *platdev;
70 struct viafb_dev *viadev;
71 struct mutex lock;
72 enum viacam_opstate opstate;
73 unsigned long flags;
74 struct pm_qos_request_list qos_request;
75 /*
76 * GPIO info for power/reset management
77 */
78 int power_gpio;
79 int reset_gpio;
80 /*
81 * I/O memory stuff.
82 */
83 void __iomem *mmio; /* Where the registers live */
84 void __iomem *fbmem; /* Frame buffer memory */
85 u32 fb_offset; /* Reserved memory offset (FB) */
86 /*
87 * Capture buffers and related. The controller supports
88 * up to three, so that's what we have here. These buffers
89 * live in frame buffer memory, so we don't call them "DMA".
90 */
91 unsigned int cb_offsets[3]; /* offsets into fb mem */
92 u8 *cb_addrs[3]; /* Kernel-space addresses */
93 int n_cap_bufs; /* How many are we using? */
94 int next_buf;
95 struct videobuf_queue vb_queue;
96 struct list_head buffer_queue; /* prot. by reg_lock */
97 /*
98 * User tracking.
99 */
100 int users;
101 struct file *owner;
102 /*
103 * Video format information. sensor_format is kept in a form
104 * that we can use to pass to the sensor. We always run the
105 * sensor in VGA resolution, though, and let the controller
106 * downscale things if need be. So we keep the "real*
107 * dimensions separately.
108 */
109 struct v4l2_pix_format sensor_format;
110 struct v4l2_pix_format user_format;
111 enum v4l2_mbus_pixelcode mbus_code;
112};
113
114/*
115 * Yes, this is a hack, but there's only going to be one of these
116 * on any system we know of.
117 */
118static struct via_camera *via_cam_info;
119
120/*
121 * Flag values, manipulated with bitops
122 */
123#define CF_DMA_ACTIVE 0 /* A frame is incoming */
124#define CF_CONFIG_NEEDED 1 /* Must configure hardware */
125
126
127/*
128 * Nasty ugly v4l2 boilerplate.
129 */
130#define sensor_call(cam, optype, func, args...) \
131 v4l2_subdev_call(cam->sensor, optype, func, ##args)
132
133/*
134 * Debugging and related.
135 */
136#define cam_err(cam, fmt, arg...) \
137 dev_err(&(cam)->platdev->dev, fmt, ##arg);
138#define cam_warn(cam, fmt, arg...) \
139 dev_warn(&(cam)->platdev->dev, fmt, ##arg);
140#define cam_dbg(cam, fmt, arg...) \
141 dev_dbg(&(cam)->platdev->dev, fmt, ##arg);
142
143/*
144 * Format handling. This is ripped almost directly from Hans's changes
145 * to cafe_ccic.c. It's a little unfortunate; until this change, we