aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-12-30 20:41:32 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-12-30 20:41:32 -0500
commitf54a6ec0fd85002d94d05b4bb679508eeb066683 (patch)
tree0f24dd66cce563d2c5e7656c2489e5b96eef31f9 /include
parent5ed1836814d908f45cafde0e79cb85314ab9d41d (diff)
parent134179823b3ca9c8b98e0631906459dbb022ff9b (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (583 commits) V4L/DVB (10130): use USB API functions rather than constants V4L/DVB (10129): dvb: remove deprecated use of RW_LOCK_UNLOCKED in frontends V4L/DVB (10128): modify V4L documentation to be a valid XHTML V4L/DVB (10127): stv06xx: Avoid having y unitialized V4L/DVB (10125): em28xx: Don't do AC97 vendor detection for i2s audio devices V4L/DVB (10124): em28xx: expand output formats available V4L/DVB (10123): em28xx: fix reversed definitions of I2S audio modes V4L/DVB (10122): em28xx: don't load em28xx-alsa for em2870 based devices V4L/DVB (10121): em28xx: remove worthless Pinnacle PCTV HD Mini 80e device profile V4L/DVB (10120): em28xx: remove redundant Pinnacle Dazzle DVC 100 profile V4L/DVB (10119): em28xx: fix corrupted XCLK value V4L/DVB (10118): zoran: fix warning for a variable not used V4L/DVB (10116): af9013: Fix gcc false warnings V4L/DVB (10111a): usbvideo.h: remove an useless blank line V4L/DVB (10111): quickcam_messenger.c: fix a warning V4L/DVB (10110): v4l2-ioctl: Fix warnings when using .unlocked_ioctl = __video_ioctl2 V4L/DVB (10109): anysee: Fix usage of an unitialized function V4L/DVB (10104): uvcvideo: Add support for video output devices V4L/DVB (10102): uvcvideo: Ignore interrupt endpoint for built-in iSight webcams. V4L/DVB (10101): uvcvideo: Fix bulk URB processing when the header is erroneous ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/videodev2.h14
-rw-r--r--include/media/i2c-addr.h2
-rw-r--r--include/media/ir-common.h2
-rw-r--r--include/media/ov772x.h21
-rw-r--r--include/media/saa7146_vv.h3
-rw-r--r--include/media/soc_camera.h111
-rw-r--r--include/media/tvp514x.h118
-rw-r--r--include/media/tw9910.h39
-rw-r--r--include/media/v4l2-chip-ident.h10
-rw-r--r--include/media/v4l2-common.h41
-rw-r--r--include/media/v4l2-dev.h51
-rw-r--r--include/media/v4l2-device.h109
-rw-r--r--include/media/v4l2-int-device.h6
-rw-r--r--include/media/v4l2-ioctl.h14
-rw-r--r--include/media/v4l2-subdev.h189
15 files changed, 685 insertions, 45 deletions
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 4669d7e72e75..1f126e30766c 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -293,6 +293,7 @@ struct v4l2_pix_format {
293#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */ 293#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */
294#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */ 294#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */
295#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */ 295#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */
296#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */
296#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */ 297#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */
297#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */ 298#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */
298#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ 299#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */
@@ -304,6 +305,8 @@ struct v4l2_pix_format {
304/* two planes -- one Y, one Cr + Cb interleaved */ 305/* two planes -- one Y, one Cr + Cb interleaved */
305#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ 306#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
306#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */ 307#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */
308#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */
309#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
307 310
308/* The following formats are not defined in the V4L2 specification */ 311/* The following formats are not defined in the V4L2 specification */
309#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */ 312#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
@@ -1050,7 +1053,7 @@ enum v4l2_mpeg_video_bitrate_mode {
1050#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210) 1053#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210)
1051#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211) 1054#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211)
1052 1055
1053/* MPEG-class control IDs specific to the CX2584x driver as defined by V4L2 */ 1056/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
1054#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) 1057#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
1055#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) 1058#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0)
1056enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { 1059enum v4l2_mpeg_cx2341x_video_spatial_filter_mode {
@@ -1117,6 +1120,12 @@ enum v4l2_exposure_auto_type {
1117#define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11) 1120#define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11)
1118#define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12) 1121#define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12)
1119 1122
1123#define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13)
1124#define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+14)
1125#define V4L2_CID_ZOOM_CONTINUOUS (V4L2_CID_CAMERA_CLASS_BASE+15)
1126
1127#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16)
1128
1120/* 1129/*
1121 * T U N I N G 1130 * T U N I N G
1122 */ 1131 */
@@ -1369,6 +1378,7 @@ struct v4l2_streamparm {
1369#define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */ 1378#define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */
1370#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver ID */ 1379#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver ID */
1371#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ 1380#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */
1381#define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */
1372 1382
1373struct v4l2_register { 1383struct v4l2_register {
1374 __u32 match_type; /* Match type */ 1384 __u32 match_type; /* Match type */
@@ -1458,6 +1468,8 @@ struct v4l2_chip_ident {
1458#define VIDIOC_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_chip_ident) 1468#define VIDIOC_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_chip_ident)
1459#endif 1469#endif
1460#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek) 1470#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
1471/* Reminder: when adding new ioctls please add support for them to
1472 drivers/media/video/v4l2-compat-ioctl32.c as well! */
1461 1473
1462#ifdef __OLD_VIDIOC_ 1474#ifdef __OLD_VIDIOC_
1463/* for compatibility, will go away some day */ 1475/* for compatibility, will go away some day */
diff --git a/include/media/i2c-addr.h b/include/media/i2c-addr.h
index e7ff44a35ca0..5d0f56054d26 100644
--- a/include/media/i2c-addr.h
+++ b/include/media/i2c-addr.h
@@ -12,8 +12,6 @@
12/* bttv address list */ 12/* bttv address list */
13#define I2C_ADDR_TSA5522 0xc2 13#define I2C_ADDR_TSA5522 0xc2
14#define I2C_ADDR_TDA7432 0x8a 14#define I2C_ADDR_TDA7432 0x8a
15#define I2C_ADDR_BT832_ALT1 0x88
16#define I2C_ADDR_BT832_ALT2 0x8a // alternate setting
17#define I2C_ADDR_TDA8425 0x82 15#define I2C_ADDR_TDA8425 0x82
18#define I2C_ADDR_TDA9840 0x84 16#define I2C_ADDR_TDA9840 0x84
19#define I2C_ADDR_TDA9850 0xb6 /* also used by 9855,9873 */ 17#define I2C_ADDR_TDA9850 0xb6 /* also used by 9855,9873 */
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 38f2d93c3957..5bf2ea00678c 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -157,6 +157,8 @@ extern IR_KEYTAB_TYPE ir_codes_avermedia_a16d[IR_KEYTAB_SIZE];
157extern IR_KEYTAB_TYPE ir_codes_encore_enltv_fm53[IR_KEYTAB_SIZE]; 157extern IR_KEYTAB_TYPE ir_codes_encore_enltv_fm53[IR_KEYTAB_SIZE];
158extern IR_KEYTAB_TYPE ir_codes_real_audio_220_32_keys[IR_KEYTAB_SIZE]; 158extern IR_KEYTAB_TYPE ir_codes_real_audio_220_32_keys[IR_KEYTAB_SIZE];
159extern IR_KEYTAB_TYPE ir_codes_msi_tvanywhere_plus[IR_KEYTAB_SIZE]; 159extern IR_KEYTAB_TYPE ir_codes_msi_tvanywhere_plus[IR_KEYTAB_SIZE];
160extern IR_KEYTAB_TYPE ir_codes_ati_tv_wonder_hd_600[IR_KEYTAB_SIZE];
161extern IR_KEYTAB_TYPE ir_codes_kworld_plus_tv_analog[IR_KEYTAB_SIZE];
160#endif 162#endif
161 163
162/* 164/*
diff --git a/include/media/ov772x.h b/include/media/ov772x.h
new file mode 100644
index 000000000000..e391d55edb95
--- /dev/null
+++ b/include/media/ov772x.h
@@ -0,0 +1,21 @@
1/* ov772x Camera
2 *
3 * Copyright (C) 2008 Renesas Solutions Corp.
4 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __OV772X_H__
12#define __OV772X_H__
13
14#include <media/soc_camera.h>
15
16struct ov772x_camera_info {
17 unsigned long buswidth;
18 struct soc_camera_link link;
19};
20
21#endif /* __OV772X_H__ */
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index 1d104096619c..6bbb0d93bb5f 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -216,8 +216,7 @@ void saa7146_set_gpio(struct saa7146_dev *saa, u8 pin, u8 data);
216extern struct saa7146_use_ops saa7146_video_uops; 216extern struct saa7146_use_ops saa7146_video_uops;
217int saa7146_start_preview(struct saa7146_fh *fh); 217int saa7146_start_preview(struct saa7146_fh *fh);
218int saa7146_stop_preview(struct saa7146_fh *fh); 218int saa7146_stop_preview(struct saa7146_fh *fh);
219int saa7146_video_do_ioctl(struct inode *inode, struct file *file, 219int saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg);
220 unsigned int cmd, void *arg);
221 220
222/* from saa7146_vbi.c */ 221/* from saa7146_vbi.c */
223extern struct saa7146_use_ops saa7146_vbi_uops; 222extern struct saa7146_use_ops saa7146_vbi_uops;
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index c5de7bb19fda..425b6a98c95c 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -12,9 +12,10 @@
12#ifndef SOC_CAMERA_H 12#ifndef SOC_CAMERA_H
13#define SOC_CAMERA_H 13#define SOC_CAMERA_H
14 14
15#include <linux/mutex.h>
16#include <linux/pm.h>
15#include <linux/videodev2.h> 17#include <linux/videodev2.h>
16#include <media/videobuf-core.h> 18#include <media/videobuf-core.h>
17#include <linux/pm.h>
18 19
19struct soc_camera_device { 20struct soc_camera_device {
20 struct list_head list; 21 struct list_head list;
@@ -36,14 +37,19 @@ struct soc_camera_device {
36 unsigned char iface; /* Host number */ 37 unsigned char iface; /* Host number */
37 unsigned char devnum; /* Device number per host */ 38 unsigned char devnum; /* Device number per host */
38 unsigned char buswidth; /* See comment in .c */ 39 unsigned char buswidth; /* See comment in .c */
40 struct soc_camera_sense *sense; /* See comment in struct definition */
39 struct soc_camera_ops *ops; 41 struct soc_camera_ops *ops;
40 struct video_device *vdev; 42 struct video_device *vdev;
41 const struct soc_camera_data_format *current_fmt; 43 const struct soc_camera_data_format *current_fmt;
42 const struct soc_camera_data_format *formats; 44 const struct soc_camera_data_format *formats;
43 int num_formats; 45 int num_formats;
46 struct soc_camera_format_xlate *user_formats;
47 int num_user_formats;
44 struct module *owner; 48 struct module *owner;
45 /* soc_camera.c private count. Only accessed with video_lock held */ 49 void *host_priv; /* Per-device host private data */
50 /* soc_camera.c private count. Only accessed with .video_lock held */
46 int use_count; 51 int use_count;
52 struct mutex video_lock; /* Protects device data */
47}; 53};
48 54
49struct soc_camera_file { 55struct soc_camera_file {
@@ -56,7 +62,7 @@ struct soc_camera_host {
56 struct device dev; 62 struct device dev;
57 unsigned char nr; /* Host number */ 63 unsigned char nr; /* Host number */
58 void *priv; 64 void *priv;
59 char *drv_name; 65 const char *drv_name;
60 struct soc_camera_host_ops *ops; 66 struct soc_camera_host_ops *ops;
61}; 67};
62 68
@@ -64,25 +70,33 @@ struct soc_camera_host_ops {
64 struct module *owner; 70 struct module *owner;
65 int (*add)(struct soc_camera_device *); 71 int (*add)(struct soc_camera_device *);
66 void (*remove)(struct soc_camera_device *); 72 void (*remove)(struct soc_camera_device *);
67 int (*suspend)(struct soc_camera_device *, pm_message_t state); 73 int (*suspend)(struct soc_camera_device *, pm_message_t);
68 int (*resume)(struct soc_camera_device *); 74 int (*resume)(struct soc_camera_device *);
69 int (*set_fmt_cap)(struct soc_camera_device *, __u32, 75 int (*get_formats)(struct soc_camera_device *, int,
70 struct v4l2_rect *); 76 struct soc_camera_format_xlate *);
71 int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *); 77 int (*set_fmt)(struct soc_camera_device *, __u32, struct v4l2_rect *);
78 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *);
72 void (*init_videobuf)(struct videobuf_queue *, 79 void (*init_videobuf)(struct videobuf_queue *,
73 struct soc_camera_device *); 80 struct soc_camera_device *);
74 int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *); 81 int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *);
75 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *); 82 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *);
76 int (*try_bus_param)(struct soc_camera_device *, __u32);
77 int (*set_bus_param)(struct soc_camera_device *, __u32); 83 int (*set_bus_param)(struct soc_camera_device *, __u32);
78 unsigned int (*poll)(struct file *, poll_table *); 84 unsigned int (*poll)(struct file *, poll_table *);
79}; 85};
80 86
87#define SOCAM_SENSOR_INVERT_PCLK (1 << 0)
88#define SOCAM_SENSOR_INVERT_MCLK (1 << 1)
89#define SOCAM_SENSOR_INVERT_HSYNC (1 << 2)
90#define SOCAM_SENSOR_INVERT_VSYNC (1 << 3)
91#define SOCAM_SENSOR_INVERT_DATA (1 << 4)
92
81struct soc_camera_link { 93struct soc_camera_link {
82 /* Camera bus id, used to match a camera and a bus */ 94 /* Camera bus id, used to match a camera and a bus */
83 int bus_id; 95 int bus_id;
84 /* GPIO number to switch between 8 and 10 bit modes */ 96 /* GPIO number to switch between 8 and 10 bit modes */
85 unsigned int gpio; 97 unsigned int gpio;
98 /* Per camera SOCAM_SENSOR_* bus flags */
99 unsigned long flags;
86 /* Optional callbacks to power on or off and reset the sensor */ 100 /* Optional callbacks to power on or off and reset the sensor */
87 int (*power)(struct device *, int); 101 int (*power)(struct device *, int);
88 int (*reset)(struct device *); 102 int (*reset)(struct device *);
@@ -106,13 +120,35 @@ extern void soc_camera_device_unregister(struct soc_camera_device *icd);
106extern int soc_camera_video_start(struct soc_camera_device *icd); 120extern int soc_camera_video_start(struct soc_camera_device *icd);
107extern void soc_camera_video_stop(struct soc_camera_device *icd); 121extern void soc_camera_video_stop(struct soc_camera_device *icd);
108 122
123extern const struct soc_camera_data_format *soc_camera_format_by_fourcc(
124 struct soc_camera_device *icd, unsigned int fourcc);
125extern const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
126 struct soc_camera_device *icd, unsigned int fourcc);
127
109struct soc_camera_data_format { 128struct soc_camera_data_format {
110 char *name; 129 const char *name;
111 unsigned int depth; 130 unsigned int depth;
112 __u32 fourcc; 131 __u32 fourcc;
113 enum v4l2_colorspace colorspace; 132 enum v4l2_colorspace colorspace;
114}; 133};
115 134
135/**
136 * struct soc_camera_format_xlate - match between host and sensor formats
137 * @cam_fmt: sensor format provided by the sensor
138 * @host_fmt: host format after host translation from cam_fmt
139 * @buswidth: bus width for this format
140 *
141 * Host and sensor translation structure. Used in table of host and sensor
142 * formats matchings in soc_camera_device. A host can override the generic list
143 * generation by implementing get_formats(), and use it for format checks and
144 * format setup.
145 */
146struct soc_camera_format_xlate {
147 const struct soc_camera_data_format *cam_fmt;
148 const struct soc_camera_data_format *host_fmt;
149 unsigned char buswidth;
150};
151
116struct soc_camera_ops { 152struct soc_camera_ops {
117 struct module *owner; 153 struct module *owner;
118 int (*probe)(struct soc_camera_device *); 154 int (*probe)(struct soc_camera_device *);
@@ -123,13 +159,14 @@ struct soc_camera_ops {
123 int (*release)(struct soc_camera_device *); 159 int (*release)(struct soc_camera_device *);
124 int (*start_capture)(struct soc_camera_device *); 160 int (*start_capture)(struct soc_camera_device *);
125 int (*stop_capture)(struct soc_camera_device *); 161 int (*stop_capture)(struct soc_camera_device *);
126 int (*set_fmt_cap)(struct soc_camera_device *, __u32, 162 int (*set_fmt)(struct soc_camera_device *, __u32, struct v4l2_rect *);
127 struct v4l2_rect *); 163 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *);
128 int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
129 unsigned long (*query_bus_param)(struct soc_camera_device *); 164 unsigned long (*query_bus_param)(struct soc_camera_device *);
130 int (*set_bus_param)(struct soc_camera_device *, unsigned long); 165 int (*set_bus_param)(struct soc_camera_device *, unsigned long);
131 int (*get_chip_id)(struct soc_camera_device *, 166 int (*get_chip_id)(struct soc_camera_device *,
132 struct v4l2_chip_ident *); 167 struct v4l2_chip_ident *);
168 int (*set_std)(struct soc_camera_device *, v4l2_std_id *);
169 int (*enum_input)(struct soc_camera_device *, struct v4l2_input *);
133#ifdef CONFIG_VIDEO_ADV_DEBUG 170#ifdef CONFIG_VIDEO_ADV_DEBUG
134 int (*get_register)(struct soc_camera_device *, struct v4l2_register *); 171 int (*get_register)(struct soc_camera_device *, struct v4l2_register *);
135 int (*set_register)(struct soc_camera_device *, struct v4l2_register *); 172 int (*set_register)(struct soc_camera_device *, struct v4l2_register *);
@@ -140,6 +177,32 @@ struct soc_camera_ops {
140 int num_controls; 177 int num_controls;
141}; 178};
142 179
180#define SOCAM_SENSE_PCLK_CHANGED (1 << 0)
181
182/**
183 * This struct can be attached to struct soc_camera_device by the host driver
184 * to request sense from the camera, for example, when calling .set_fmt(). The
185 * host then can check which flags are set and verify respective values if any.
186 * For example, if SOCAM_SENSE_PCLK_CHANGED is set, it means, pixclock has
187 * changed during this operation. After completion the host should detach sense.
188 *
189 * @flags ored SOCAM_SENSE_* flags
190 * @master_clock if the host wants to be informed about pixel-clock
191 * change, it better set master_clock.
192 * @pixel_clock_max maximum pixel clock frequency supported by the host,
193 * camera is not allowed to exceed this.
194 * @pixel_clock if the camera driver changed pixel clock during this
195 * operation, it sets SOCAM_SENSE_PCLK_CHANGED, uses
196 * master_clock to calculate the new pixel-clock and
197 * sets this field.
198 */
199struct soc_camera_sense {
200 unsigned long flags;
201 unsigned long master_clock;
202 unsigned long pixel_clock_max;
203 unsigned long pixel_clock;
204};
205
143static inline struct v4l2_queryctrl const *soc_camera_find_qctrl( 206static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
144 struct soc_camera_ops *ops, int id) 207 struct soc_camera_ops *ops, int id)
145{ 208{
@@ -158,15 +221,20 @@ static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
158#define SOCAM_HSYNC_ACTIVE_LOW (1 << 3) 221#define SOCAM_HSYNC_ACTIVE_LOW (1 << 3)
159#define SOCAM_VSYNC_ACTIVE_HIGH (1 << 4) 222#define SOCAM_VSYNC_ACTIVE_HIGH (1 << 4)
160#define SOCAM_VSYNC_ACTIVE_LOW (1 << 5) 223#define SOCAM_VSYNC_ACTIVE_LOW (1 << 5)
161#define SOCAM_DATAWIDTH_8 (1 << 6) 224#define SOCAM_DATAWIDTH_4 (1 << 6)
162#define SOCAM_DATAWIDTH_9 (1 << 7) 225#define SOCAM_DATAWIDTH_8 (1 << 7)
163#define SOCAM_DATAWIDTH_10 (1 << 8) 226#define SOCAM_DATAWIDTH_9 (1 << 8)
164#define SOCAM_DATAWIDTH_16 (1 << 9) 227#define SOCAM_DATAWIDTH_10 (1 << 9)
165#define SOCAM_PCLK_SAMPLE_RISING (1 << 10) 228#define SOCAM_DATAWIDTH_15 (1 << 10)
166#define SOCAM_PCLK_SAMPLE_FALLING (1 << 11) 229#define SOCAM_DATAWIDTH_16 (1 << 11)
230#define SOCAM_PCLK_SAMPLE_RISING (1 << 12)
231#define SOCAM_PCLK_SAMPLE_FALLING (1 << 13)
232#define SOCAM_DATA_ACTIVE_HIGH (1 << 14)
233#define SOCAM_DATA_ACTIVE_LOW (1 << 15)
167 234
168#define SOCAM_DATAWIDTH_MASK (SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_9 | \ 235#define SOCAM_DATAWIDTH_MASK (SOCAM_DATAWIDTH_4 | SOCAM_DATAWIDTH_8 | \
169 SOCAM_DATAWIDTH_10 | SOCAM_DATAWIDTH_16) 236 SOCAM_DATAWIDTH_9 | SOCAM_DATAWIDTH_10 | \
237 SOCAM_DATAWIDTH_15 | SOCAM_DATAWIDTH_16)
170 238
171static inline unsigned long soc_camera_bus_param_compatible( 239static inline unsigned long soc_camera_bus_param_compatible(
172 unsigned long camera_flags, unsigned long bus_flags) 240 unsigned long camera_flags, unsigned long bus_flags)
@@ -182,4 +250,7 @@ static inline unsigned long soc_camera_bus_param_compatible(
182 return (!hsync || !vsync || !pclk) ? 0 : common_flags; 250 return (!hsync || !vsync || !pclk) ? 0 : common_flags;
183} 251}
184 252
253extern unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl,
254 unsigned long flags);
255
185#endif 256#endif
diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
new file mode 100644
index 000000000000..5e7ee968c6dc
--- /dev/null
+++ b/include/media/tvp514x.h
@@ -0,0 +1,118 @@
1/*
2 * drivers/media/video/tvp514x.h
3 *
4 * Copyright (C) 2008 Texas Instruments Inc
5 * Author: Vaibhav Hiremath <hvaibhav@ti.com>
6 *
7 * Contributors:
8 * Sivaraj R <sivaraj@ti.com>
9 * Brijesh R Jadav <brijesh.j@ti.com>
10 * Hardik Shah <hardik.shah@ti.com>
11 * Manjunath Hadli <mrh@ti.com>
12 * Karicheri Muralidharan <m-karicheri2@ti.com>
13 *
14 * This package is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */
28
29#ifndef _TVP514X_H
30#define _TVP514X_H
31
32/*
33 * Other macros
34 */
35#define TVP514X_MODULE_NAME "tvp514x"
36
37#define TVP514X_XCLK_BT656 (27000000)
38
39/* Number of pixels and number of lines per frame for different standards */
40#define NTSC_NUM_ACTIVE_PIXELS (720)
41#define NTSC_NUM_ACTIVE_LINES (480)
42#define PAL_NUM_ACTIVE_PIXELS (720)
43#define PAL_NUM_ACTIVE_LINES (576)
44
45/**
46 * enum tvp514x_input - enum for different decoder input pin
47 * configuration.
48 */
49enum tvp514x_input {
50 /*
51 * CVBS input selection
52 */
53 INPUT_CVBS_VI1A = 0x0,
54 INPUT_CVBS_VI1B,
55 INPUT_CVBS_VI1C,
56 INPUT_CVBS_VI2A = 0x04,
57 INPUT_CVBS_VI2B,
58 INPUT_CVBS_VI2C,
59 INPUT_CVBS_VI3A = 0x08,
60 INPUT_CVBS_VI3B,
61 INPUT_CVBS_VI3C,
62 INPUT_CVBS_VI4A = 0x0C,
63 /*
64 * S-Video input selection
65 */
66 INPUT_SVIDEO_VI2A_VI1A = 0x44,
67 INPUT_SVIDEO_VI2B_VI1B,
68 INPUT_SVIDEO_VI2C_VI1C,
69 INPUT_SVIDEO_VI2A_VI3A = 0x54,
70 INPUT_SVIDEO_VI2B_VI3B,
71 INPUT_SVIDEO_VI2C_VI3C,
72 INPUT_SVIDEO_VI4A_VI1A = 0x4C,
73 INPUT_SVIDEO_VI4A_VI1B,
74 INPUT_SVIDEO_VI4A_VI1C,
75 INPUT_SVIDEO_VI4A_VI3A = 0x5C,
76 INPUT_SVIDEO_VI4A_VI3B,
77 INPUT_SVIDEO_VI4A_VI3C,
78
79 /* Need to add entries for
80 * RGB, YPbPr and SCART.
81 */
82 INPUT_INVALID
83};
84
85/**
86 * enum tvp514x_output - enum for output format
87 * supported.
88 *
89 */
90enum tvp514x_output {
91 OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
92 OUTPUT_20BIT_422_SEPERATE_SYNC,
93 OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
94 OUTPUT_INVALID
95};
96
97/**
98 * struct tvp514x_platform_data - Platform data values and access functions.
99 * @power_set: Power state access function, zero is off, non-zero is on.
100 * @ifparm: Interface parameters access function.
101 * @priv_data_set: Device private data (pointer) access function.
102 * @clk_polarity: Clock polarity of the current interface.
103 * @ hs_polarity: HSYNC Polarity configuration for current interface.
104 * @ vs_polarity: VSYNC Polarity configuration for current interface.
105 */
106struct tvp514x_platform_data {
107 char *master;
108 int (*power_set) (enum v4l2_power on);
109 int (*ifparm) (struct v4l2_ifparm *p);
110 int (*priv_data_set) (void *);
111 /* Interface control params */
112 bool clk_polarity;
113 bool hs_polarity;
114 bool vs_polarity;
115};
116
117
118#endif /* ifndef _TVP514X_H */
diff --git a/include/media/tw9910.h b/include/media/tw9910.h
new file mode 100644
index 000000000000..73231e7880d8
--- /dev/null
+++ b/include/media/tw9910.h
@@ -0,0 +1,39 @@
1/*
2 * tw9910 Driver header
3 *
4 * Copyright (C) 2008 Renesas Solutions Corp.
5 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
6 *
7 * Based on ov772x.h
8 *
9 * Copyright (C) Kuninori Morimoto <morimoto.kuninori@renesas.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#ifndef __TW9910_H__
17#define __TW9910_H__
18
19#include <media/soc_camera.h>
20
21enum tw9910_mpout_pin {
22 TW9910_MPO_VLOSS,
23 TW9910_MPO_HLOCK,
24 TW9910_MPO_SLOCK,
25 TW9910_MPO_VLOCK,
26 TW9910_MPO_MONO,
27 TW9910_MPO_DET50,
28 TW9910_MPO_FIELD,
29 TW9910_MPO_RTCO,
30};
31
32struct tw9910_video_info {
33 unsigned long buswidth;
34 enum tw9910_mpout_pin mpout;
35 struct soc_camera_link link;
36};
37
38
39#endif /* __TW9910_H__ */
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index d73a8e9028a5..43dbb659f1f5 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -60,6 +60,8 @@ enum {
60 60
61 /* OmniVision sensors: reserved range 250-299 */ 61 /* OmniVision sensors: reserved range 250-299 */
62 V4L2_IDENT_OV7670 = 250, 62 V4L2_IDENT_OV7670 = 250,
63 V4L2_IDENT_OV7720 = 251,
64 V4L2_IDENT_OV7725 = 252,
63 65
64 /* Conexant MPEG encoder/decoders: reserved range 410-420 */ 66 /* Conexant MPEG encoder/decoders: reserved range 410-420 */
65 V4L2_IDENT_CX23415 = 415, 67 V4L2_IDENT_CX23415 = 415,
@@ -69,6 +71,9 @@ enum {
69 /* module vp27smpx: just ident 2700 */ 71 /* module vp27smpx: just ident 2700 */
70 V4L2_IDENT_VP27SMPX = 2700, 72 V4L2_IDENT_VP27SMPX = 2700,
71 73
74 /* module tvp5150 */
75 V4L2_IDENT_TVP5150 = 5150,
76
72 /* module cs5345: just ident 5345 */ 77 /* module cs5345: just ident 5345 */
73 V4L2_IDENT_CS5345 = 5345, 78 V4L2_IDENT_CS5345 = 5345,
74 79
@@ -82,6 +87,9 @@ enum {
82 /* module wm8775: just ident 8775 */ 87 /* module wm8775: just ident 8775 */
83 V4L2_IDENT_WM8775 = 8775, 88 V4L2_IDENT_WM8775 = 8775,
84 89
90 /* module tw9910: just ident 9910 */
91 V4L2_IDENT_TW9910 = 9910,
92
85 /* module cs53132a: just ident 53132 */ 93 /* module cs53132a: just ident 53132 */
86 V4L2_IDENT_CS53l32A = 53132, 94 V4L2_IDENT_CS53l32A = 53132,
87 95
@@ -166,8 +174,10 @@ enum {
166 V4L2_IDENT_MT9M001C12ST = 45000, 174 V4L2_IDENT_MT9M001C12ST = 45000,
167 V4L2_IDENT_MT9M001C12STM = 45005, 175 V4L2_IDENT_MT9M001C12STM = 45005,
168 V4L2_IDENT_MT9M111 = 45007, 176 V4L2_IDENT_MT9M111 = 45007,
177 V4L2_IDENT_MT9M112 = 45008,
169 V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */ 178 V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */
170 V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */ 179 V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */
180 V4L2_IDENT_MT9T031 = 45020,
171}; 181};
172 182
173#endif 183#endif
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 2f8719abf5cb..f99c866d8c37 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -57,6 +57,29 @@
57 57
58/* ------------------------------------------------------------------------- */ 58/* ------------------------------------------------------------------------- */
59 59
60/* These printk constructs can be used with v4l2_device and v4l2_subdev */
61#define v4l2_printk(level, dev, fmt, arg...) \
62 printk(level "%s: " fmt, (dev)->name , ## arg)
63
64#define v4l2_err(dev, fmt, arg...) \
65 v4l2_printk(KERN_ERR, dev, fmt , ## arg)
66
67#define v4l2_warn(dev, fmt, arg...) \
68 v4l2_printk(KERN_WARNING, dev, fmt , ## arg)
69
70#define v4l2_info(dev, fmt, arg...) \
71 v4l2_printk(KERN_INFO, dev, fmt , ## arg)
72
73/* These three macros assume that the debug level is set with a module
74 parameter called 'debug'. */
75#define v4l2_dbg(level, debug, dev, fmt, arg...) \
76 do { \
77 if (debug >= (level)) \
78 v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \
79 } while (0)
80
81/* ------------------------------------------------------------------------- */
82
60/* Priority helper functions */ 83/* Priority helper functions */
61 84
62struct v4l2_prio_state { 85struct v4l2_prio_state {
@@ -104,11 +127,29 @@ struct i2c_driver;
104struct i2c_adapter; 127struct i2c_adapter;
105struct i2c_client; 128struct i2c_client;
106struct i2c_device_id; 129struct i2c_device_id;
130struct v4l2_device;
131struct v4l2_subdev;
132struct v4l2_subdev_ops;
107 133
108int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver, 134int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
109 const char *name, 135 const char *name,
110 int (*probe)(struct i2c_client *, const struct i2c_device_id *)); 136 int (*probe)(struct i2c_client *, const struct i2c_device_id *));
111 137
138/* Load an i2c module and return an initialized v4l2_subdev struct.
139 Only call request_module if module_name != NULL.
140 The client_type argument is the name of the chip that's on the adapter. */
141struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
142 const char *module_name, const char *client_type, u8 addr);
143/* Probe and load an i2c module and return an initialized v4l2_subdev struct.
144 Only call request_module if module_name != NULL.
145 The client_type argument is the name of the chip that's on the adapter. */
146struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
147 const char *module_name, const char *client_type,
148 const unsigned short *addrs);
149/* Initialize an v4l2_subdev with data from an i2c_client struct */
150void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
151 const struct v4l2_subdev_ops *ops);
152
112/* ------------------------------------------------------------------------- */ 153/* ------------------------------------------------------------------------- */
113 154
114/* Internal ioctls */ 155/* Internal ioctls */
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index a0a6b41c5e09..0a88d1d17d30 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -25,6 +25,12 @@
25#define VFL_TYPE_MAX 4 25#define VFL_TYPE_MAX 4
26 26
27struct v4l2_ioctl_callbacks; 27struct v4l2_ioctl_callbacks;
28struct v4l2_device;
29
30/* Flag to mark the video_device struct as unregistered.
31 Drivers can set this flag if they want to block all future
32 device access. It is set by video_unregister_device. */
33#define V4L2_FL_UNREGISTERED (0)
28 34
29/* 35/*
30 * Newer version of video_device, handled by videodev2.c 36 * Newer version of video_device, handled by videodev2.c
@@ -39,15 +45,20 @@ struct video_device
39 45
40 /* sysfs */ 46 /* sysfs */
41 struct device dev; /* v4l device */ 47 struct device dev; /* v4l device */
42 struct cdev cdev; /* character device */ 48 struct cdev *cdev; /* character device */
43 void (*cdev_release)(struct kobject *kobj); 49
50 /* Set either parent or v4l2_dev if your driver uses v4l2_device */
44 struct device *parent; /* device parent */ 51 struct device *parent; /* device parent */
52 struct v4l2_device *v4l2_dev; /* v4l2_device parent */
45 53
46 /* device info */ 54 /* device info */
47 char name[32]; 55 char name[32];
48 int vfl_type; 56 int vfl_type;
57 /* 'minor' is set to -1 if the registration failed */
49 int minor; 58 int minor;
50 u16 num; 59 u16 num;
60 /* use bitops to set/clear/test flags */
61 unsigned long flags;
51 /* attribute to differentiate multiple indices on one physical device */ 62 /* attribute to differentiate multiple indices on one physical device */
52 int index; 63 int index;
53 64
@@ -58,7 +69,7 @@ struct video_device
58 v4l2_std_id current_norm; /* Current tvnorm */ 69 v4l2_std_id current_norm; /* Current tvnorm */
59 70
60 /* callbacks */ 71 /* callbacks */
61 void (*release)(struct video_device *vfd); 72 void (*release)(struct video_device *vdev);
62 73
63 /* ioctl callbacks */ 74 /* ioctl callbacks */
64 const struct v4l2_ioctl_ops *ioctl_ops; 75 const struct v4l2_ioctl_ops *ioctl_ops;
@@ -67,36 +78,41 @@ struct video_device
67/* dev to video-device */ 78/* dev to video-device */
68#define to_video_device(cd) container_of(cd, struct video_device, dev) 79#define to_video_device(cd) container_of(cd, struct video_device, dev)
69 80
70/* Register and unregister devices. Note that if video_register_device fails, 81/* Register video devices. Note that if video_register_device fails,
71 the release() callback of the video_device structure is *not* called, so 82 the release() callback of the video_device structure is *not* called, so
72 the caller is responsible for freeing any data. Usually that means that 83 the caller is responsible for freeing any data. Usually that means that
73 you call video_device_release() on failure. */ 84 you call video_device_release() on failure.
74int __must_check video_register_device(struct video_device *vfd, int type, int nr); 85
75int __must_check video_register_device_index(struct video_device *vfd, 86 Also note that vdev->minor is set to -1 if the registration failed. */
87int __must_check video_register_device(struct video_device *vdev, int type, int nr);
88int __must_check video_register_device_index(struct video_device *vdev,
76 int type, int nr, int index); 89 int type, int nr, int index);
77void video_unregister_device(struct video_device *vfd); 90
91/* Unregister video devices. Will do nothing if vdev == NULL or
92 vdev->minor < 0. */
93void video_unregister_device(struct video_device *vdev);
78 94
79/* helper functions to alloc/release struct video_device, the 95/* helper functions to alloc/release struct video_device, the
80 latter can also be used for video_device->release(). */ 96 latter can also be used for video_device->release(). */
81struct video_device * __must_check video_device_alloc(void); 97struct video_device * __must_check video_device_alloc(void);
82 98
83/* this release function frees the vfd pointer */ 99/* this release function frees the vdev pointer */
84void video_device_release(struct video_device *vfd); 100void video_device_release(struct video_device *vdev);
85 101
86/* this release function does nothing, use when the video_device is a 102/* this release function does nothing, use when the video_device is a
87 static global struct. Note that having a static video_device is 103 static global struct. Note that having a static video_device is
88 a dubious construction at best. */ 104 a dubious construction at best. */
89void video_device_release_empty(struct video_device *vfd); 105void video_device_release_empty(struct video_device *vdev);
90 106
91/* helper functions to access driver private data. */ 107/* helper functions to access driver private data. */
92static inline void *video_get_drvdata(struct video_device *dev) 108static inline void *video_get_drvdata(struct video_device *vdev)
93{ 109{
94 return dev_get_drvdata(&dev->dev); 110 return dev_get_drvdata(&vdev->dev);
95} 111}
96 112
97static inline void video_set_drvdata(struct video_device *dev, void *data) 113static inline void video_set_drvdata(struct video_device *vdev, void *data)
98{ 114{
99 dev_set_drvdata(&dev->dev, data); 115 dev_set_drvdata(&vdev->dev, data);
100} 116}
101 117
102struct video_device *video_devdata(struct file *file); 118struct video_device *video_devdata(struct file *file);
@@ -108,4 +124,9 @@ static inline void *video_drvdata(struct file *file)
108 return video_get_drvdata(video_devdata(file)); 124 return video_get_drvdata(video_devdata(file));
109} 125}
110 126
127static inline int video_is_unregistered(struct video_device *vdev)
128{
129 return test_bit(V4L2_FL_UNREGISTERED, &vdev->flags);
130}
131
111#endif /* _V4L2_DEV_H */ 132#endif /* _V4L2_DEV_H */
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
new file mode 100644
index 000000000000..97b283a04289
--- /dev/null
+++ b/include/media/v4l2-device.h
@@ -0,0 +1,109 @@
1/*
2 V4L2 device support header.
3
4 Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef _V4L2_DEVICE_H
22#define _V4L2_DEVICE_H
23
24#include <media/v4l2-subdev.h>
25
26/* Each instance of a V4L2 device should create the v4l2_device struct,
27 either stand-alone or embedded in a larger struct.
28
29 It allows easy access to sub-devices (see v4l2-subdev.h) and provides
30 basic V4L2 device-level support.
31 */
32
33#define V4L2_DEVICE_NAME_SIZE (BUS_ID_SIZE + 16)
34
35struct v4l2_device {
36 /* dev->driver_data points to this struct */
37 struct device *dev;
38 /* used to keep track of the registered subdevs */
39 struct list_head subdevs;
40 /* lock this struct; can be used by the driver as well if this
41 struct is embedded into a larger struct. */
42 spinlock_t lock;
43 /* unique device name, by default the driver name + bus ID */
44 char name[V4L2_DEVICE_NAME_SIZE];
45};
46
47/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev */
48int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev);
49/* Set v4l2_dev->dev->driver_data to NULL and unregister all sub-devices */
50void v4l2_device_unregister(struct v4l2_device *v4l2_dev);
51
52/* Register a subdev with a v4l2 device. While registered the subdev module
53 is marked as in-use. An error is returned if the module is no longer
54 loaded when you attempt to register it. */
55int __must_check v4l2_device_register_subdev(struct v4l2_device *dev, struct v4l2_subdev *sd);
56/* Unregister a subdev with a v4l2 device. Can also be called if the subdev
57 wasn't registered. In that case it will do nothing. */
58void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
59
60/* Iterate over all subdevs. */
61#define v4l2_device_for_each_subdev(sd, dev) \
62 list_for_each_entry(sd, &(dev)->subdevs, list)
63
64/* Call the specified callback for all subdevs matching the condition.
65 Ignore any errors. Note that you cannot add or delete a subdev
66 while walking the subdevs list. */
67#define __v4l2_device_call_subdevs(dev, cond, o, f, args...) \
68 do { \
69 struct v4l2_subdev *sd; \
70 \
71 list_for_each_entry(sd, &(dev)->subdevs, list) \
72 if ((cond) && sd->ops->o && sd->ops->o->f) \
73 sd->ops->o->f(sd , ##args); \
74 } while (0)
75
76/* Call the specified callback for all subdevs matching the condition.
77 If the callback returns an error other than 0 or -ENOIOCTLCMD, then
78 return with that error code. Note that you cannot add or delete a
79 subdev while walking the subdevs list. */
80#define __v4l2_device_call_subdevs_until_err(dev, cond, o, f, args...) \
81({ \
82 struct v4l2_subdev *sd; \
83 int err = 0; \
84 \
85 list_for_each_entry(sd, &(dev)->subdevs, list) { \
86 if ((cond) && sd->ops->o && sd->ops->o->f) \
87 err = sd->ops->o->f(sd , ##args); \
88 if (err && err != -ENOIOCTLCMD) \
89 break; \
90 } \
91 (err == -ENOIOCTLCMD) ? 0 : err; \
92})
93
94/* Call the specified callback for all subdevs matching grp_id (if 0, then
95 match them all). Ignore any errors. Note that you cannot add or delete
96 a subdev while walking the subdevs list. */
97#define v4l2_device_call_all(dev, grp_id, o, f, args...) \
98 __v4l2_device_call_subdevs(dev, \
99 !(grp_id) || sd->grp_id == (grp_id), o, f , ##args)
100
101/* Call the specified callback for all subdevs matching grp_id (if 0, then
102 match them all). If the callback returns an error other than 0 or
103 -ENOIOCTLCMD, then return with that error code. Note that you cannot
104 add or delete a subdev while walking the subdevs list. */
105#define v4l2_device_call_until_err(dev, grp_id, o, f, args...) \
106 __v4l2_device_call_subdevs_until_err(dev, \
107 !(grp_id) || sd->grp_id == (grp_id), o, f , ##args)
108
109#endif
diff --git a/include/media/v4l2-int-device.h b/include/media/v4l2-int-device.h
index 9c2df41dbf92..ecda3c725837 100644
--- a/include/media/v4l2-int-device.h
+++ b/include/media/v4l2-int-device.h
@@ -183,6 +183,9 @@ enum v4l2_int_ioctl_num {
183 vidioc_int_s_crop_num, 183 vidioc_int_s_crop_num,
184 vidioc_int_g_parm_num, 184 vidioc_int_g_parm_num,
185 vidioc_int_s_parm_num, 185 vidioc_int_s_parm_num,
186 vidioc_int_querystd_num,
187 vidioc_int_s_std_num,
188 vidioc_int_s_video_routing_num,
186 189
187 /* 190 /*
188 * 191 *
@@ -284,6 +287,9 @@ V4L2_INT_WRAPPER_1(g_crop, struct v4l2_crop, *);
284V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *); 287V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *);
285V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *); 288V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *);
286V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *); 289V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *);
290V4L2_INT_WRAPPER_1(querystd, v4l2_std_id, *);
291V4L2_INT_WRAPPER_1(s_std, v4l2_std_id, *);
292V4L2_INT_WRAPPER_1(s_video_routing, struct v4l2_routing, *);
287 293
288V4L2_INT_WRAPPER_0(dev_init); 294V4L2_INT_WRAPPER_0(dev_init);
289V4L2_INT_WRAPPER_0(dev_exit); 295V4L2_INT_WRAPPER_0(dev_exit);
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index e6ba25b3d7c8..fcdb58c4ce07 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -232,6 +232,12 @@ struct v4l2_ioctl_ops {
232 int (*vidioc_g_chip_ident) (struct file *file, void *fh, 232 int (*vidioc_g_chip_ident) (struct file *file, void *fh,
233 struct v4l2_chip_ident *chip); 233 struct v4l2_chip_ident *chip);
234 234
235 int (*vidioc_enum_framesizes) (struct file *file, void *fh,
236 struct v4l2_frmsizeenum *fsize);
237
238 int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
239 struct v4l2_frmivalenum *fival);
240
235 /* For other private ioctls */ 241 /* For other private ioctls */
236 int (*vidioc_default) (struct file *file, void *fh, 242 int (*vidioc_default) (struct file *file, void *fh,
237 int cmd, void *arg); 243 int cmd, void *arg);
@@ -285,15 +291,13 @@ extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,
285 unsigned long arg); 291 unsigned long arg);
286 292
287/* Include support for obsoleted stuff */ 293/* Include support for obsoleted stuff */
288extern int video_usercopy(struct inode *inode, struct file *file, 294extern int video_usercopy(struct file *file, unsigned int cmd,
289 unsigned int cmd, unsigned long arg, 295 unsigned long arg, v4l2_kioctl func);
290 int (*func)(struct inode *inode, struct file *file,
291 unsigned int cmd, void *arg));
292 296
293/* Standard handlers for V4L ioctl's */ 297/* Standard handlers for V4L ioctl's */
294 298
295/* This prototype is used on fops.unlocked_ioctl */ 299/* This prototype is used on fops.unlocked_ioctl */
296extern int __video_ioctl2(struct file *file, 300extern long __video_ioctl2(struct file *file,
297 unsigned int cmd, unsigned long arg); 301 unsigned int cmd, unsigned long arg);
298 302
299/* This prototype is used on fops.ioctl 303/* This prototype is used on fops.ioctl
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
new file mode 100644
index 000000000000..ceef016bb0b7
--- /dev/null
+++ b/include/media/v4l2-subdev.h
@@ -0,0 +1,189 @@
1/*
2 V4L2 sub-device support header.
3
4 Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef _V4L2_SUBDEV_H
22#define _V4L2_SUBDEV_H
23
24#include <media/v4l2-common.h>
25
26struct v4l2_device;
27struct v4l2_subdev;
28struct tuner_setup;
29
30/* Sub-devices are devices that are connected somehow to the main bridge
31 device. These devices are usually audio/video muxers/encoders/decoders or
32 sensors and webcam controllers.
33
34 Usually these devices are controlled through an i2c bus, but other busses
35 may also be used.
36
37 The v4l2_subdev struct provides a way of accessing these devices in a
38 generic manner. Most operations that these sub-devices support fall in
39 a few categories: core ops, audio ops, video ops and tuner ops.
40
41 More categories can be added if needed, although this should remain a
42 limited set (no more than approx. 8 categories).
43
44 Each category has its own set of ops that subdev drivers can implement.
45
46 A subdev driver can leave the pointer to the category ops NULL if
47 it does not implement them (e.g. an audio subdev will generally not
48 implement the video category ops). The exception is the core category:
49 this must always be present.
50
51 These ops are all used internally so it is no problem to change, remove
52 or add ops or move ops from one to another category. Currently these
53 ops are based on the original ioctls, but since ops are not limited to
54 one argument there is room for improvement here once all i2c subdev
55 drivers are converted to use these ops.
56 */
57
58/* Core ops: it is highly recommended to implement at least these ops:
59
60 g_chip_ident
61 log_status
62 g_register
63 s_register
64
65 This provides basic debugging support.
66
67 The ioctl ops is meant for generic ioctl-like commands. Depending on
68 the use-case it might be better to use subdev-specific ops (currently
69 not yet implemented) since ops provide proper type-checking.
70 */
71struct v4l2_subdev_core_ops {
72 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip);
73 int (*log_status)(struct v4l2_subdev *sd);
74 int (*init)(struct v4l2_subdev *sd, u32 val);
75 int (*s_standby)(struct v4l2_subdev *sd, u32 standby);
76 int (*reset)(struct v4l2_subdev *sd, u32 val);
77 int (*s_gpio)(struct v4l2_subdev *sd, u32 val);
78 int (*queryctrl)(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc);
79 int (*g_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
80 int (*s_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
81 int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm);
82 int (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
83#ifdef CONFIG_VIDEO_ADV_DEBUG
84 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_register *reg);
85 int (*s_register)(struct v4l2_subdev *sd, struct v4l2_register *reg);
86#endif
87};
88
89struct v4l2_subdev_tuner_ops {
90 int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type);
91 int (*s_radio)(struct v4l2_subdev *sd);
92 int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
93 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
94 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
95 int (*s_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
96 int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);
97 int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type);
98 int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
99};
100
101struct v4l2_subdev_audio_ops {
102 int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
103 int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
104 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route);
105};
106
107struct v4l2_subdev_video_ops {
108 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route);
109 int (*s_crystal_freq)(struct v4l2_subdev *sd, struct v4l2_crystal_freq *freq);
110 int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line);
111 int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data);
112 int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data);
113 int (*g_sliced_vbi_cap)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_cap *cap);
114 int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
115 int (*s_stream)(struct v4l2_subdev *sd, int enable);
116 int (*s_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
117 int (*g_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
118};
119
120struct v4l2_subdev_ops {
121 const struct v4l2_subdev_core_ops *core;
122 const struct v4l2_subdev_tuner_ops *tuner;
123 const struct v4l2_subdev_audio_ops *audio;
124 const struct v4l2_subdev_video_ops *video;
125};
126
127#define V4L2_SUBDEV_NAME_SIZE 32
128
129/* Each instance of a subdev driver should create this struct, either
130 stand-alone or embedded in a larger struct.
131 */
132struct v4l2_subdev {
133 struct list_head list;
134 struct module *owner;
135 struct v4l2_device *dev;
136 const struct v4l2_subdev_ops *ops;
137 /* name must be unique */
138 char name[V4L2_SUBDEV_NAME_SIZE];
139 /* can be used to group similar subdevs, value is driver-specific */
140 u32 grp_id;
141 /* pointer to private data */
142 void *priv;
143};
144
145static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
146{
147 sd->priv = p;
148}
149
150static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
151{
152 return sd->priv;
153}
154
155/* Convert an ioctl-type command to the proper v4l2_subdev_ops function call.
156 This is used by subdev modules that can be called by both old-style ioctl
157 commands and through the v4l2_subdev_ops.
158
159 The ioctl API of the subdev driver can call this function to call the
160 right ops based on the ioctl cmd and arg.
161
162 Once all subdev drivers have been converted and all drivers no longer
163 use the ioctl interface, then this function can be removed.
164 */
165int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg);
166
167static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
168 const struct v4l2_subdev_ops *ops)
169{
170 INIT_LIST_HEAD(&sd->list);
171 /* ops->core MUST be set */
172 BUG_ON(!ops || !ops->core);
173 sd->ops = ops;
174 sd->dev = NULL;
175 sd->name[0] = '\0';
176 sd->grp_id = 0;
177 sd->priv = NULL;
178}
179
180/* Call an ops of a v4l2_subdev, doing the right checks against
181 NULL pointers.
182
183 Example: err = v4l2_subdev_call(sd, core, g_chip_ident, &chip);
184 */
185#define v4l2_subdev_call(sd, o, f, args...) \
186 (!(sd) ? -ENODEV : (((sd) && (sd)->ops->o && (sd)->ops->o->f) ? \
187 (sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD))
188
189#endif