aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
Diffstat (limited to 'include/media')
-rw-r--r--include/media/bt819.h33
-rw-r--r--include/media/cx2341x.h6
-rw-r--r--include/media/cx25840.h12
-rw-r--r--include/media/ir-common.h3
-rw-r--r--include/media/ir-kbd-i2c.h3
-rw-r--r--include/media/msp3400.h4
-rw-r--r--include/media/ov772x.h40
-rw-r--r--include/media/saa7146.h10
-rw-r--r--include/media/saa7146_vv.h17
-rw-r--r--include/media/sh_mobile_ceu.h5
-rw-r--r--include/media/soc_camera.h24
-rw-r--r--include/media/tvaudio.h19
-rw-r--r--include/media/v4l2-chip-ident.h94
-rw-r--r--include/media/v4l2-common.h159
-rw-r--r--include/media/v4l2-dev.h2
-rw-r--r--include/media/v4l2-device.h40
-rw-r--r--include/media/v4l2-i2c-drv-legacy.h152
-rw-r--r--include/media/v4l2-i2c-drv.h6
-rw-r--r--include/media/v4l2-ioctl.h2
-rw-r--r--include/media/v4l2-subdev.h137
-rw-r--r--include/media/videobuf-core.h1
21 files changed, 410 insertions, 359 deletions
diff --git a/include/media/bt819.h b/include/media/bt819.h
new file mode 100644
index 000000000000..38f666bde77a
--- /dev/null
+++ b/include/media/bt819.h
@@ -0,0 +1,33 @@
1/*
2 bt819.h - bt819 notifications
3
4 Copyright (C) 2009 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., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef _BT819_H_
22#define _BT819_H_
23
24#include <linux/ioctl.h>
25
26/* v4l2_device notifications. */
27
28/* Needed to reset the FIFO buffer when changing the input
29 or the video standard. */
30#define BT819_FIFO_RESET_LOW _IO('b', 0)
31#define BT819_FIFO_RESET_HIGH _IO('b', 1)
32
33#endif
diff --git a/include/media/cx2341x.h b/include/media/cx2341x.h
index 9ec4d5889ef5..9ebe8558b9b6 100644
--- a/include/media/cx2341x.h
+++ b/include/media/cx2341x.h
@@ -1,5 +1,5 @@
1/* 1/*
2 cx23415/6 header containing common defines. 2 cx23415/6/8 header containing common defines.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@ enum cx2341x_port {
28enum cx2341x_cap { 28enum cx2341x_cap {
29 CX2341X_CAP_HAS_SLICED_VBI = 1 << 0, 29 CX2341X_CAP_HAS_SLICED_VBI = 1 << 0,
30 CX2341X_CAP_HAS_TS = 1 << 1, 30 CX2341X_CAP_HAS_TS = 1 << 1,
31 CX2341X_CAP_HAS_AC3 = 1 << 2,
31}; 32};
32 33
33struct cx2341x_mpeg_params { 34struct cx2341x_mpeg_params {
@@ -47,11 +48,12 @@ struct cx2341x_mpeg_params {
47 enum v4l2_mpeg_audio_sampling_freq audio_sampling_freq; 48 enum v4l2_mpeg_audio_sampling_freq audio_sampling_freq;
48 enum v4l2_mpeg_audio_encoding audio_encoding; 49 enum v4l2_mpeg_audio_encoding audio_encoding;
49 enum v4l2_mpeg_audio_l2_bitrate audio_l2_bitrate; 50 enum v4l2_mpeg_audio_l2_bitrate audio_l2_bitrate;
51 enum v4l2_mpeg_audio_ac3_bitrate audio_ac3_bitrate;
50 enum v4l2_mpeg_audio_mode audio_mode; 52 enum v4l2_mpeg_audio_mode audio_mode;
51 enum v4l2_mpeg_audio_mode_extension audio_mode_extension; 53 enum v4l2_mpeg_audio_mode_extension audio_mode_extension;
52 enum v4l2_mpeg_audio_emphasis audio_emphasis; 54 enum v4l2_mpeg_audio_emphasis audio_emphasis;
53 enum v4l2_mpeg_audio_crc audio_crc; 55 enum v4l2_mpeg_audio_crc audio_crc;
54 u16 audio_properties; 56 u32 audio_properties;
55 u16 audio_mute; 57 u16 audio_mute;
56 58
57 /* video */ 59 /* video */
diff --git a/include/media/cx25840.h b/include/media/cx25840.h
index db431d513f2f..2c3fbaa33f74 100644
--- a/include/media/cx25840.h
+++ b/include/media/cx25840.h
@@ -21,6 +21,18 @@
21#ifndef _CX25840_H_ 21#ifndef _CX25840_H_
22#define _CX25840_H_ 22#define _CX25840_H_
23 23
24/* Note that the cx25840 driver requires that the bridge driver calls the
25 v4l2_subdev's init operation in order to load the driver's firmware.
26 Without this the audio standard detection will fail and you will
27 only get mono.
28
29 Since loading the firmware is often problematic when the driver is
30 compiled into the kernel I recommend postponing calling this function
31 until the first open of the video device. Another reason for
32 postponing it is that loading this firmware takes a long time (seconds)
33 due to the slow i2c bus speed. So it will speed up the boot process if
34 you can avoid loading the fw as long as the video device isn't used. */
35
24enum cx25840_video_input { 36enum cx25840_video_input {
25 /* Composite video inputs In1-In8 */ 37 /* Composite video inputs In1-In8 */
26 CX25840_COMPOSITE1 = 1, 38 CX25840_COMPOSITE1 = 1,
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 5bf2ea00678c..7b5b91f60425 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -111,6 +111,7 @@ extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE];
111extern IR_KEYTAB_TYPE ir_codes_avermedia[IR_KEYTAB_SIZE]; 111extern IR_KEYTAB_TYPE ir_codes_avermedia[IR_KEYTAB_SIZE];
112extern IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE]; 112extern IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE];
113extern IR_KEYTAB_TYPE ir_codes_avermedia_m135a[IR_KEYTAB_SIZE]; 113extern IR_KEYTAB_TYPE ir_codes_avermedia_m135a[IR_KEYTAB_SIZE];
114extern IR_KEYTAB_TYPE ir_codes_avermedia_cardbus[IR_KEYTAB_SIZE];
114extern IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE]; 115extern IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE];
115extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE]; 116extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE];
116extern IR_KEYTAB_TYPE ir_codes_pixelview_new[IR_KEYTAB_SIZE]; 117extern IR_KEYTAB_TYPE ir_codes_pixelview_new[IR_KEYTAB_SIZE];
@@ -159,6 +160,8 @@ extern 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]; 160extern 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_ati_tv_wonder_hd_600[IR_KEYTAB_SIZE];
161extern IR_KEYTAB_TYPE ir_codes_kworld_plus_tv_analog[IR_KEYTAB_SIZE]; 162extern IR_KEYTAB_TYPE ir_codes_kworld_plus_tv_analog[IR_KEYTAB_SIZE];
163extern IR_KEYTAB_TYPE ir_codes_kaiomy[IR_KEYTAB_SIZE];
164extern IR_KEYTAB_TYPE ir_codes_dm1105_nec[IR_KEYTAB_SIZE];
162#endif 165#endif
163 166
164/* 167/*
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 00fa57eb9fde..07963d705400 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -14,8 +14,7 @@ struct IR_i2c {
14 /* Used to avoid fast repeating */ 14 /* Used to avoid fast repeating */
15 unsigned char old; 15 unsigned char old;
16 16
17 struct work_struct work; 17 struct delayed_work work;
18 struct timer_list timer;
19 char phys[32]; 18 char phys[32];
20 int (*get_key)(struct IR_i2c*, u32*, u32*); 19 int (*get_key)(struct IR_i2c*, u32*, u32*);
21}; 20};
diff --git a/include/media/msp3400.h b/include/media/msp3400.h
index 6ab854931c05..90cf22ada8b4 100644
--- a/include/media/msp3400.h
+++ b/include/media/msp3400.h
@@ -54,13 +54,13 @@
54 ======= 54 =======
55 55
56 So to specify a complete routing scheme for the msp3400 you will have to 56 So to specify a complete routing scheme for the msp3400 you will have to
57 specify in the 'input' field of the v4l2_routing struct: 57 specify in the 'input' arg of the s_routing function:
58 58
59 1) which tuner input to use 59 1) which tuner input to use
60 2) which SCART input to use 60 2) which SCART input to use
61 3) which DSP input to use for each DSP output 61 3) which DSP input to use for each DSP output
62 62
63 And in the 'output' field of the v4l2_routing struct you specify: 63 And in the 'output' arg of the s_routing function you specify:
64 64
65 1) which SCART input to use for each SCART output 65 1) which SCART input to use for each SCART output
66 66
diff --git a/include/media/ov772x.h b/include/media/ov772x.h
index e391d55edb95..30d9629198ef 100644
--- a/include/media/ov772x.h
+++ b/include/media/ov772x.h
@@ -13,9 +13,49 @@
13 13
14#include <media/soc_camera.h> 14#include <media/soc_camera.h>
15 15
16/* for flags */
17#define OV772X_FLAG_VFLIP 0x00000001 /* Vertical flip image */
18#define OV772X_FLAG_HFLIP 0x00000002 /* Horizontal flip image */
19
20/*
21 * for Edge ctrl
22 *
23 * strength also control Auto or Manual Edge Control Mode
24 * see also OV772X_MANUAL_EDGE_CTRL
25 */
26struct ov772x_edge_ctrl {
27 unsigned char strength;
28 unsigned char threshold;
29 unsigned char upper;
30 unsigned char lower;
31};
32
33#define OV772X_MANUAL_EDGE_CTRL 0x80 /* un-used bit of strength */
34#define EDGE_STRENGTH_MASK 0x1F
35#define EDGE_THRESHOLD_MASK 0x0F
36#define EDGE_UPPER_MASK 0xFF
37#define EDGE_LOWER_MASK 0xFF
38
39#define OV772X_AUTO_EDGECTRL(u, l) \
40{ \
41 .upper = (u & EDGE_UPPER_MASK), \
42 .lower = (l & EDGE_LOWER_MASK), \
43}
44
45#define OV772X_MANUAL_EDGECTRL(s, t) \
46{ \
47 .strength = (s & EDGE_STRENGTH_MASK) | OV772X_MANUAL_EDGE_CTRL,\
48 .threshold = (t & EDGE_THRESHOLD_MASK), \
49}
50
51/*
52 * ov772x camera info
53 */
16struct ov772x_camera_info { 54struct ov772x_camera_info {
17 unsigned long buswidth; 55 unsigned long buswidth;
56 unsigned long flags;
18 struct soc_camera_link link; 57 struct soc_camera_link link;
58 struct ov772x_edge_ctrl edgectrl;
19}; 59};
20 60
21#endif /* __OV772X_H__ */ 61#endif /* __OV772X_H__ */
diff --git a/include/media/saa7146.h b/include/media/saa7146.h
index c5a6e22a4b37..7a9f76ecbbbd 100644
--- a/include/media/saa7146.h
+++ b/include/media/saa7146.h
@@ -13,11 +13,12 @@
13#include <linux/stringify.h> 13#include <linux/stringify.h>
14#include <linux/mutex.h> 14#include <linux/mutex.h>
15#include <linux/scatterlist.h> 15#include <linux/scatterlist.h>
16#include <media/v4l2-device.h>
16 17
17#include <linux/vmalloc.h> /* for vmalloc() */ 18#include <linux/vmalloc.h> /* for vmalloc() */
18#include <linux/mm.h> /* for vmalloc_to_page() */ 19#include <linux/mm.h> /* for vmalloc_to_page() */
19 20
20#define SAA7146_VERSION_CODE 0x000500 /* 0.5.0 */ 21#define SAA7146_VERSION_CODE 0x000600 /* 0.6.0 */
21 22
22#define saa7146_write(sxy,adr,dat) writel((dat),(sxy->mem+(adr))) 23#define saa7146_write(sxy,adr,dat) writel((dat),(sxy->mem+(adr)))
23#define saa7146_read(sxy,adr) readl(sxy->mem+(adr)) 24#define saa7146_read(sxy,adr) readl(sxy->mem+(adr))
@@ -110,6 +111,8 @@ struct saa7146_dev
110 111
111 struct list_head item; 112 struct list_head item;
112 113
114 struct v4l2_device v4l2_dev;
115
113 /* different device locks */ 116 /* different device locks */
114 spinlock_t slock; 117 spinlock_t slock;
115 struct mutex lock; 118 struct mutex lock;
@@ -145,6 +148,11 @@ struct saa7146_dev
145 struct saa7146_dma d_rps1; 148 struct saa7146_dma d_rps1;
146}; 149};
147 150
151static inline struct saa7146_dev *to_saa7146_dev(struct v4l2_device *v4l2_dev)
152{
153 return container_of(v4l2_dev, struct saa7146_dev, v4l2_dev);
154}
155
148/* from saa7146_i2c.c */ 156/* from saa7146_i2c.c */
149int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate); 157int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate);
150 158
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index c8d0b23fde29..eed5fccc83f3 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -150,16 +150,6 @@ struct saa7146_vv
150 unsigned int resources; /* resource management for device */ 150 unsigned int resources; /* resource management for device */
151}; 151};
152 152
153#define SAA7146_EXCLUSIVE 0x1
154#define SAA7146_BEFORE 0x2
155#define SAA7146_AFTER 0x4
156
157struct saa7146_extension_ioctls
158{
159 unsigned int cmd;
160 int flags;
161};
162
163/* flags */ 153/* flags */
164#define SAA7146_USE_PORT_B_FOR_VBI 0x2 /* use input port b for vbi hardware bug workaround */ 154#define SAA7146_USE_PORT_B_FOR_VBI 0x2 /* use input port b for vbi hardware bug workaround */
165 155
@@ -176,8 +166,10 @@ struct saa7146_ext_vv
176 int num_stds; 166 int num_stds;
177 int (*std_callback)(struct saa7146_dev*, struct saa7146_standard *); 167 int (*std_callback)(struct saa7146_dev*, struct saa7146_standard *);
178 168
179 struct saa7146_extension_ioctls *ioctls; 169 /* the extension can override this */
180 long (*ioctl)(struct saa7146_fh *, unsigned int cmd, void *arg); 170 struct v4l2_ioctl_ops ops;
171 /* pointer to the saa7146 core ops */
172 const struct v4l2_ioctl_ops *core_ops;
181 173
182 struct v4l2_file_operations vbi_fops; 174 struct v4l2_file_operations vbi_fops;
183}; 175};
@@ -213,6 +205,7 @@ void saa7146_set_hps_source_and_sync(struct saa7146_dev *saa, int source, int sy
213void saa7146_set_gpio(struct saa7146_dev *saa, u8 pin, u8 data); 205void saa7146_set_gpio(struct saa7146_dev *saa, u8 pin, u8 data);
214 206
215/* from saa7146_video.c */ 207/* from saa7146_video.c */
208extern const struct v4l2_ioctl_ops saa7146_video_ioctl_ops;
216extern struct saa7146_use_ops saa7146_video_uops; 209extern struct saa7146_use_ops saa7146_video_uops;
217int saa7146_start_preview(struct saa7146_fh *fh); 210int saa7146_start_preview(struct saa7146_fh *fh);
218int saa7146_stop_preview(struct saa7146_fh *fh); 211int saa7146_stop_preview(struct saa7146_fh *fh);
diff --git a/include/media/sh_mobile_ceu.h b/include/media/sh_mobile_ceu.h
index b5dbefea3740..0f3524cff435 100644
--- a/include/media/sh_mobile_ceu.h
+++ b/include/media/sh_mobile_ceu.h
@@ -1,10 +1,11 @@
1#ifndef __ASM_SH_MOBILE_CEU_H__ 1#ifndef __ASM_SH_MOBILE_CEU_H__
2#define __ASM_SH_MOBILE_CEU_H__ 2#define __ASM_SH_MOBILE_CEU_H__
3 3
4#include <media/soc_camera.h> 4#define SH_CEU_FLAG_USE_8BIT_BUS (1 << 0) /* use 8bit bus width */
5#define SH_CEU_FLAG_USE_16BIT_BUS (1 << 1) /* use 16bit bus width */
5 6
6struct sh_mobile_ceu_info { 7struct sh_mobile_ceu_info {
7 unsigned long flags; /* SOCAM_... */ 8 unsigned long flags;
8}; 9};
9 10
10#endif /* __ASM_SH_MOBILE_CEU_H__ */ 11#endif /* __ASM_SH_MOBILE_CEU_H__ */
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 7440d9250665..37013688af44 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -45,6 +45,7 @@ struct soc_camera_device {
45 int num_formats; 45 int num_formats;
46 struct soc_camera_format_xlate *user_formats; 46 struct soc_camera_format_xlate *user_formats;
47 int num_user_formats; 47 int num_user_formats;
48 enum v4l2_field field; /* Preserve field over close() */
48 struct module *owner; 49 struct module *owner;
49 void *host_priv; /* Per-device host private data */ 50 void *host_priv; /* Per-device host private data */
50 /* soc_camera.c private count. Only accessed with .video_lock held */ 51 /* soc_camera.c private count. Only accessed with .video_lock held */
@@ -74,7 +75,8 @@ struct soc_camera_host_ops {
74 int (*resume)(struct soc_camera_device *); 75 int (*resume)(struct soc_camera_device *);
75 int (*get_formats)(struct soc_camera_device *, int, 76 int (*get_formats)(struct soc_camera_device *, int,
76 struct soc_camera_format_xlate *); 77 struct soc_camera_format_xlate *);
77 int (*set_fmt)(struct soc_camera_device *, __u32, struct v4l2_rect *); 78 int (*set_crop)(struct soc_camera_device *, struct v4l2_rect *);
79 int (*set_fmt)(struct soc_camera_device *, struct v4l2_format *);
78 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *); 80 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *);
79 void (*init_videobuf)(struct videobuf_queue *, 81 void (*init_videobuf)(struct videobuf_queue *,
80 struct soc_camera_device *); 82 struct soc_camera_device *);
@@ -93,13 +95,18 @@ struct soc_camera_host_ops {
93struct soc_camera_link { 95struct soc_camera_link {
94 /* Camera bus id, used to match a camera and a bus */ 96 /* Camera bus id, used to match a camera and a bus */
95 int bus_id; 97 int bus_id;
96 /* GPIO number to switch between 8 and 10 bit modes */
97 unsigned int gpio;
98 /* Per camera SOCAM_SENSOR_* bus flags */ 98 /* Per camera SOCAM_SENSOR_* bus flags */
99 unsigned long flags; 99 unsigned long flags;
100 /* Optional callbacks to power on or off and reset the sensor */ 100 /* Optional callbacks to power on or off and reset the sensor */
101 int (*power)(struct device *, int); 101 int (*power)(struct device *, int);
102 int (*reset)(struct device *); 102 int (*reset)(struct device *);
103 /*
104 * some platforms may support different data widths than the sensors
105 * native ones due to different data line routing. Let the board code
106 * overwrite the width flags.
107 */
108 int (*set_bus_param)(struct soc_camera_link *, unsigned long flags);
109 unsigned long (*query_bus_param)(struct soc_camera_link *);
103}; 110};
104 111
105static inline struct soc_camera_device *to_soc_camera_dev(struct device *dev) 112static inline struct soc_camera_device *to_soc_camera_dev(struct device *dev)
@@ -159,7 +166,8 @@ struct soc_camera_ops {
159 int (*release)(struct soc_camera_device *); 166 int (*release)(struct soc_camera_device *);
160 int (*start_capture)(struct soc_camera_device *); 167 int (*start_capture)(struct soc_camera_device *);
161 int (*stop_capture)(struct soc_camera_device *); 168 int (*stop_capture)(struct soc_camera_device *);
162 int (*set_fmt)(struct soc_camera_device *, __u32, struct v4l2_rect *); 169 int (*set_crop)(struct soc_camera_device *, struct v4l2_rect *);
170 int (*set_fmt)(struct soc_camera_device *, struct v4l2_format *);
163 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *); 171 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *);
164 unsigned long (*query_bus_param)(struct soc_camera_device *); 172 unsigned long (*query_bus_param)(struct soc_camera_device *);
165 int (*set_bus_param)(struct soc_camera_device *, unsigned long); 173 int (*set_bus_param)(struct soc_camera_device *, unsigned long);
@@ -239,15 +247,19 @@ static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
239static inline unsigned long soc_camera_bus_param_compatible( 247static inline unsigned long soc_camera_bus_param_compatible(
240 unsigned long camera_flags, unsigned long bus_flags) 248 unsigned long camera_flags, unsigned long bus_flags)
241{ 249{
242 unsigned long common_flags, hsync, vsync, pclk; 250 unsigned long common_flags, hsync, vsync, pclk, data, buswidth, mode;
243 251
244 common_flags = camera_flags & bus_flags; 252 common_flags = camera_flags & bus_flags;
245 253
246 hsync = common_flags & (SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW); 254 hsync = common_flags & (SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW);
247 vsync = common_flags & (SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW); 255 vsync = common_flags & (SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW);
248 pclk = common_flags & (SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING); 256 pclk = common_flags & (SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING);
257 data = common_flags & (SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_LOW);
258 mode = common_flags & (SOCAM_MASTER | SOCAM_SLAVE);
259 buswidth = common_flags & SOCAM_DATAWIDTH_MASK;
249 260
250 return (!hsync || !vsync || !pclk) ? 0 : common_flags; 261 return (!hsync || !vsync || !pclk || !data || !mode || !buswidth) ? 0 :
262 common_flags;
251} 263}
252 264
253extern unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl, 265extern unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl,
diff --git a/include/media/tvaudio.h b/include/media/tvaudio.h
index 6915aafc875a..1ac8184693f8 100644
--- a/include/media/tvaudio.h
+++ b/include/media/tvaudio.h
@@ -21,10 +21,29 @@
21#ifndef _TVAUDIO_H 21#ifndef _TVAUDIO_H
22#define _TVAUDIO_H 22#define _TVAUDIO_H
23 23
24#include <media/i2c-addr.h>
25
24/* The tvaudio module accepts the following inputs: */ 26/* The tvaudio module accepts the following inputs: */
25#define TVAUDIO_INPUT_TUNER 0 27#define TVAUDIO_INPUT_TUNER 0
26#define TVAUDIO_INPUT_RADIO 1 28#define TVAUDIO_INPUT_RADIO 1
27#define TVAUDIO_INPUT_EXTERN 2 29#define TVAUDIO_INPUT_EXTERN 2
28#define TVAUDIO_INPUT_INTERN 3 30#define TVAUDIO_INPUT_INTERN 3
29 31
32static inline const unsigned short *tvaudio_addrs(void)
33{
34 static const unsigned short addrs[] = {
35 I2C_ADDR_TDA8425 >> 1,
36 I2C_ADDR_TEA6300 >> 1,
37 I2C_ADDR_TEA6420 >> 1,
38 I2C_ADDR_TDA9840 >> 1,
39 I2C_ADDR_TDA985x_L >> 1,
40 I2C_ADDR_TDA985x_H >> 1,
41 I2C_ADDR_TDA9874 >> 1,
42 I2C_ADDR_PIC16C54 >> 1,
43 I2C_CLIENT_END
44 };
45
46 return addrs;
47}
48
30#endif 49#endif
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 9aaf652b20ef..1be461a29077 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -37,10 +37,8 @@ enum {
37 /* module saa7110: just ident 100 */ 37 /* module saa7110: just ident 100 */
38 V4L2_IDENT_SAA7110 = 100, 38 V4L2_IDENT_SAA7110 = 100,
39 39
40 /* module saa7111: just ident 101 */ 40 /* module saa7115: reserved range 101-149 */
41 V4L2_IDENT_SAA7111 = 101, 41 V4L2_IDENT_SAA7111 = 101,
42
43 /* module saa7115: reserved range 102-149 */
44 V4L2_IDENT_SAA7113 = 103, 42 V4L2_IDENT_SAA7113 = 103,
45 V4L2_IDENT_SAA7114 = 104, 43 V4L2_IDENT_SAA7114 = 104,
46 V4L2_IDENT_SAA7115 = 105, 44 V4L2_IDENT_SAA7115 = 105,
@@ -63,44 +61,96 @@ enum {
63 V4L2_IDENT_OV7720 = 251, 61 V4L2_IDENT_OV7720 = 251,
64 V4L2_IDENT_OV7725 = 252, 62 V4L2_IDENT_OV7725 = 252,
65 63
66 /* Conexant MPEG encoder/decoders: reserved range 410-420 */ 64 /* module saa7146: reserved range 300-309 */
65 V4L2_IDENT_SAA7146 = 300,
66
67 /* Conexant MPEG encoder/decoders: reserved range 400-420 */
68 V4L2_IDENT_CX23418_843 = 403, /* Integrated A/V Decoder on the '418 */
67 V4L2_IDENT_CX23415 = 415, 69 V4L2_IDENT_CX23415 = 415,
68 V4L2_IDENT_CX23416 = 416, 70 V4L2_IDENT_CX23416 = 416,
69 V4L2_IDENT_CX23418 = 418, 71 V4L2_IDENT_CX23418 = 418,
70 72
73 /* module au0828 */
74 V4L2_IDENT_AU0828 = 828,
75
76 /* module indycam: just ident 2000 */
77 V4L2_IDENT_INDYCAM = 2000,
78
79 /* module bt819: reserved range 810-819 */
80 V4L2_IDENT_BT815A = 815,
81 V4L2_IDENT_BT817A = 817,
82 V4L2_IDENT_BT819A = 819,
83
84 /* module bt856: just ident 856 */
85 V4L2_IDENT_BT856 = 856,
86
87 /* module bt866: just ident 866 */
88 V4L2_IDENT_BT866 = 866,
89
90 /* module ks0127: reserved range 1120-1129 */
91 V4L2_IDENT_KS0122S = 1122,
92 V4L2_IDENT_KS0127 = 1127,
93 V4L2_IDENT_KS0127B = 1128,
94
71 /* module vp27smpx: just ident 2700 */ 95 /* module vp27smpx: just ident 2700 */
72 V4L2_IDENT_VP27SMPX = 2700, 96 V4L2_IDENT_VP27SMPX = 2700,
73 97
98 /* module vpx3220: reserved range: 3210-3229 */
99 V4L2_IDENT_VPX3214C = 3214,
100 V4L2_IDENT_VPX3216B = 3216,
101 V4L2_IDENT_VPX3220A = 3220,
102
74 /* module tvp5150 */ 103 /* module tvp5150 */
75 V4L2_IDENT_TVP5150 = 5150, 104 V4L2_IDENT_TVP5150 = 5150,
76 105
106 /* module saa5246a: just ident 5246 */
107 V4L2_IDENT_SAA5246A = 5246,
108
109 /* module saa5249: just ident 5249 */
110 V4L2_IDENT_SAA5249 = 5249,
111
77 /* module cs5345: just ident 5345 */ 112 /* module cs5345: just ident 5345 */
78 V4L2_IDENT_CS5345 = 5345, 113 V4L2_IDENT_CS5345 = 5345,
79 114
115 /* module tea6415c: just ident 6415 */
116 V4L2_IDENT_TEA6415C = 6415,
117
118 /* module tea6420: just ident 6420 */
119 V4L2_IDENT_TEA6420 = 6420,
120
121 /* module saa6588: just ident 6588 */
122 V4L2_IDENT_SAA6588 = 6588,
123
80 /* module saa6752hs: reserved range 6750-6759 */ 124 /* module saa6752hs: reserved range 6750-6759 */
81 V4L2_IDENT_SAA6752HS = 6752, 125 V4L2_IDENT_SAA6752HS = 6752,
82 V4L2_IDENT_SAA6752HS_AC3 = 6753, 126 V4L2_IDENT_SAA6752HS_AC3 = 6753,
83 127
128 /* module adv7170: just ident 7170 */
129 V4L2_IDENT_ADV7170 = 7170,
130
131 /* module adv7175: just ident 7175 */
132 V4L2_IDENT_ADV7175 = 7175,
133
134 /* module saa7185: just ident 7185 */
135 V4L2_IDENT_SAA7185 = 7185,
136
137 /* module saa7191: just ident 7191 */
138 V4L2_IDENT_SAA7191 = 7191,
139
84 /* module wm8739: just ident 8739 */ 140 /* module wm8739: just ident 8739 */
85 V4L2_IDENT_WM8739 = 8739, 141 V4L2_IDENT_WM8739 = 8739,
86 142
87 /* module wm8775: just ident 8775 */ 143 /* module wm8775: just ident 8775 */
88 V4L2_IDENT_WM8775 = 8775, 144 V4L2_IDENT_WM8775 = 8775,
89 145
90 /* module tw9910: just ident 9910 */ 146 /* module tda9840: just ident 9840 */
91 V4L2_IDENT_TW9910 = 9910, 147 V4L2_IDENT_TDA9840 = 9840,
92
93 /* module cs53132a: just ident 53132 */
94 V4L2_IDENT_CS53l32A = 53132,
95
96 /* module upd64031a: just ident 64031 */
97 V4L2_IDENT_UPD64031A = 64031,
98 148
99 /* module upd64083: just ident 64083 */ 149 /* module cafe_ccic, just ident 8801 */
100 V4L2_IDENT_UPD64083 = 64083, 150 V4L2_IDENT_CAFE = 8801,
101 151
102 /* module m52790: just ident 52790 */ 152 /* module tw9910: just ident 9910 */
103 V4L2_IDENT_M52790 = 52790, 153 V4L2_IDENT_TW9910 = 9910,
104 154
105 /* module msp3400: reserved range 34000-34999 and 44000-44999 */ 155 /* module msp3400: reserved range 34000-34999 and 44000-44999 */
106 V4L2_IDENT_MSPX4XX = 34000, /* generic MSPX4XX identifier, only 156 V4L2_IDENT_MSPX4XX = 34000, /* generic MSPX4XX identifier, only
@@ -178,6 +228,18 @@ enum {
178 V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */ 228 V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */
179 V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */ 229 V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */
180 V4L2_IDENT_MT9T031 = 45020, 230 V4L2_IDENT_MT9T031 = 45020,
231
232 /* module cs53132a: just ident 53132 */
233 V4L2_IDENT_CS53l32A = 53132,
234
235 /* module upd64031a: just ident 64031 */
236 V4L2_IDENT_UPD64031A = 64031,
237
238 /* module upd64083: just ident 64083 */
239 V4L2_IDENT_UPD64083 = 64083,
240
241 /* module m52790: just ident 52790 */
242 V4L2_IDENT_M52790 = 52790,
181}; 243};
182 244
183#endif 245#endif
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 95e74f1874e1..c48c24e4d0fa 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -102,11 +102,15 @@ int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
102const char *v4l2_ctrl_get_name(u32 id); 102const char *v4l2_ctrl_get_name(u32 id);
103const char **v4l2_ctrl_get_menu(u32 id); 103const char **v4l2_ctrl_get_menu(u32 id);
104int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def); 104int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def);
105int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl);
106int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, 105int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu,
107 struct v4l2_queryctrl *qctrl, const char **menu_items); 106 struct v4l2_queryctrl *qctrl, const char **menu_items);
108#define V4L2_CTRL_MENU_IDS_END (0xffffffff) 107#define V4L2_CTRL_MENU_IDS_END (0xffffffff)
109int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids); 108int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids);
109
110/* Note: ctrl_classes points to an array of u32 pointers. Each u32 array is a
111 0-terminated array of control IDs. Each array must be sorted low to high
112 and belong to the same control class. The array of u32 pointers must also
113 be sorted, from low class IDs to high class IDs. */
110u32 v4l2_ctrl_next(const u32 * const *ctrl_classes, u32 id); 114u32 v4l2_ctrl_next(const u32 * const *ctrl_classes, u32 id);
111 115
112/* ------------------------------------------------------------------------- */ 116/* ------------------------------------------------------------------------- */
@@ -121,7 +125,7 @@ int v4l2_chip_match_host(const struct v4l2_dbg_match *match);
121 125
122/* ------------------------------------------------------------------------- */ 126/* ------------------------------------------------------------------------- */
123 127
124/* Helper function for I2C legacy drivers */ 128/* I2C Helper functions */
125 129
126struct i2c_driver; 130struct i2c_driver;
127struct i2c_adapter; 131struct i2c_adapter;
@@ -131,157 +135,62 @@ struct v4l2_device;
131struct v4l2_subdev; 135struct v4l2_subdev;
132struct v4l2_subdev_ops; 136struct v4l2_subdev_ops;
133 137
134int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
135 const char *name,
136 int (*probe)(struct i2c_client *, const struct i2c_device_id *));
137 138
138/* Load an i2c module and return an initialized v4l2_subdev struct. 139/* Load an i2c module and return an initialized v4l2_subdev struct.
139 Only call request_module if module_name != NULL. 140 Only call request_module if module_name != NULL.
140 The client_type argument is the name of the chip that's on the adapter. */ 141 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, 142struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
143 struct i2c_adapter *adapter,
142 const char *module_name, const char *client_type, u8 addr); 144 const char *module_name, const char *client_type, u8 addr);
143/* Probe and load an i2c module and return an initialized v4l2_subdev struct. 145/* Probe and load an i2c module and return an initialized v4l2_subdev struct.
144 Only call request_module if module_name != NULL. 146 Only call request_module if module_name != NULL.
145 The client_type argument is the name of the chip that's on the adapter. */ 147 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, 148struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev,
149 struct i2c_adapter *adapter,
147 const char *module_name, const char *client_type, 150 const char *module_name, const char *client_type,
148 const unsigned short *addrs); 151 const unsigned short *addrs);
152/* Like v4l2_i2c_new_probed_subdev, except probe for a single address. */
153struct v4l2_subdev *v4l2_i2c_new_probed_subdev_addr(struct v4l2_device *v4l2_dev,
154 struct i2c_adapter *adapter,
155 const char *module_name, const char *client_type, u8 addr);
149/* Initialize an v4l2_subdev with data from an i2c_client struct */ 156/* Initialize an v4l2_subdev with data from an i2c_client struct */
150void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, 157void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
151 const struct v4l2_subdev_ops *ops); 158 const struct v4l2_subdev_ops *ops);
159/* Return i2c client address of v4l2_subdev. */
160unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd);
161
162enum v4l2_i2c_tuner_type {
163 ADDRS_RADIO, /* Radio tuner addresses */
164 ADDRS_DEMOD, /* Demod tuner addresses */
165 ADDRS_TV, /* TV tuner addresses */
166 /* TV tuner addresses if demod is present, this excludes
167 addresses used by the demodulator from the list of
168 candidates. */
169 ADDRS_TV_WITH_DEMOD,
170};
171/* Return a list of I2C tuner addresses to probe. Use only if the tuner
172 addresses are unknown. */
173const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type);
152 174
153/* ------------------------------------------------------------------------- */ 175/* ------------------------------------------------------------------------- */
154 176
155/* Internal ioctls */ 177/* Note: these remaining ioctls/structs should be removed as well, but they are
156 178 still used in tuner-simple.c (TUNER_SET_CONFIG), cx18/ivtv (RESET) and
157/* VIDIOC_INT_DECODE_VBI_LINE */ 179 v4l2-int-device.h (v4l2_routing). To remove these ioctls some more cleanup
158struct v4l2_decode_vbi_line { 180 is needed in those modules. */
159 u32 is_second_field; /* Set to 0 for the first (odd) field,
160 set to 1 for the second (even) field. */
161 u8 *p; /* Pointer to the sliced VBI data from the decoder.
162 On exit points to the start of the payload. */
163 u32 line; /* Line number of the sliced VBI data (1-23) */
164 u32 type; /* VBI service type (V4L2_SLICED_*). 0 if no service found */
165};
166 181
182/* s_config */
167struct v4l2_priv_tun_config { 183struct v4l2_priv_tun_config {
168 int tuner; 184 int tuner;
169 void *priv; 185 void *priv;
170}; 186};
171
172/* audio ioctls */
173
174/* v4l device was opened in Radio mode, to be replaced by VIDIOC_INT_S_TUNER_MODE */
175#define AUDC_SET_RADIO _IO('d',88)
176
177/* tuner ioctls */
178
179/* Sets tuner type and its I2C addr */
180#define TUNER_SET_TYPE_ADDR _IOW('d', 90, int)
181
182/* Puts tuner on powersaving state, disabling it, except for i2c. To be replaced
183 by VIDIOC_INT_S_STANDBY. */
184#define TUNER_SET_STANDBY _IOW('d', 91, int)
185
186/* Sets tda9887 specific stuff, like port1, port2 and qss */
187#define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config) 187#define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config)
188 188
189/* Switch the tuner to a specific tuner mode. Replacement of AUDC_SET_RADIO */
190#define VIDIOC_INT_S_TUNER_MODE _IOW('d', 93, enum v4l2_tuner_type)
191
192/* Generic standby command. Passing -1 (all bits set to 1) will put the whole
193 chip into standby mode, value 0 will make the chip fully active. Specific
194 bits can be used by certain chips to enable/disable specific subsystems.
195 Replacement of TUNER_SET_STANDBY. */
196#define VIDIOC_INT_S_STANDBY _IOW('d', 94, u32)
197
198/* 100, 101 used by VIDIOC_DBG_[SG]_REGISTER */
199
200/* Generic reset command. The argument selects which subsystems to reset.
201 Passing 0 will always reset the whole chip. */
202#define VIDIOC_INT_RESET _IOW ('d', 102, u32) 189#define VIDIOC_INT_RESET _IOW ('d', 102, u32)
203 190
204/* Set the frequency (in Hz) of the audio clock output.
205 Used to slave an audio processor to the video decoder, ensuring that audio
206 and video remain synchronized.
207 Usual values for the frequency are 48000, 44100 or 32000 Hz.
208 If the frequency is not supported, then -EINVAL is returned. */
209#define VIDIOC_INT_AUDIO_CLOCK_FREQ _IOW ('d', 103, u32)
210
211/* Video decoders that support sliced VBI need to implement this ioctl.
212 Field p of the v4l2_sliced_vbi_line struct is set to the start of the VBI
213 data that was generated by the decoder. The driver then parses the sliced
214 VBI data and sets the other fields in the struct accordingly. The pointer p
215 is updated to point to the start of the payload which can be copied
216 verbatim into the data field of the v4l2_sliced_vbi_data struct. If no
217 valid VBI data was found, then the type field is set to 0 on return. */
218#define VIDIOC_INT_DECODE_VBI_LINE _IOWR('d', 104, struct v4l2_decode_vbi_line)
219
220/* Used to generate VBI signals on a video signal. v4l2_sliced_vbi_data is
221 filled with the data packets that should be output. Note that if you set
222 the line field to 0, then that VBI signal is disabled. If no
223 valid VBI data was found, then the type field is set to 0 on return. */
224#define VIDIOC_INT_S_VBI_DATA _IOW ('d', 105, struct v4l2_sliced_vbi_data)
225
226/* Used to obtain the sliced VBI packet from a readback register. Not all
227 video decoders support this. If no data is available because the readback
228 register contains invalid or erroneous data -EIO is returned. Note that
229 you must fill in the 'id' member and the 'field' member (to determine
230 whether CC data from the first or second field should be obtained). */
231#define VIDIOC_INT_G_VBI_DATA _IOWR('d', 106, struct v4l2_sliced_vbi_data)
232
233/* Sets I2S speed in bps. This is used to provide a standard way to select I2S
234 clock used by driving digital audio streams at some board designs.
235 Usual values for the frequency are 1024000 and 2048000.
236 If the frequency is not supported, then -EINVAL is returned. */
237#define VIDIOC_INT_I2S_CLOCK_FREQ _IOW ('d', 108, u32)
238
239/* Routing definition, device dependent. It specifies which inputs (if any)
240 should be routed to which outputs (if any). */
241struct v4l2_routing { 191struct v4l2_routing {
242 u32 input; 192 u32 input;
243 u32 output; 193 u32 output;
244}; 194};
245 195
246/* These internal commands should be used to define the inputs and outputs
247 of an audio/video chip. They will replace the v4l2 API commands
248 VIDIOC_S/G_INPUT, VIDIOC_S/G_OUTPUT, VIDIOC_S/G_AUDIO and VIDIOC_S/G_AUDOUT
249 that are meant to be used by the user.
250 The internal commands should be used to switch inputs/outputs
251 because only the driver knows how to map a 'Television' input to the precise
252 input/output routing of an A/D converter, or a DSP, or a video digitizer.
253 These four commands should only be sent directly to an i2c device, they
254 should not be broadcast as the routing is very device specific. */
255#define VIDIOC_INT_S_AUDIO_ROUTING _IOW ('d', 109, struct v4l2_routing)
256#define VIDIOC_INT_G_AUDIO_ROUTING _IOR ('d', 110, struct v4l2_routing)
257#define VIDIOC_INT_S_VIDEO_ROUTING _IOW ('d', 111, struct v4l2_routing)
258#define VIDIOC_INT_G_VIDEO_ROUTING _IOR ('d', 112, struct v4l2_routing)
259
260struct v4l2_crystal_freq {
261 u32 freq; /* frequency in Hz of the crystal */
262 u32 flags; /* device specific flags */
263};
264
265/* Sets the frequency of the crystal used to generate the clocks.
266 An extra flags field allows device specific configuration regarding
267 clock frequency dividers, etc. If not used, then set flags to 0.
268 If the frequency is not supported, then -EINVAL is returned. */
269#define VIDIOC_INT_S_CRYSTAL_FREQ _IOW('d', 113, struct v4l2_crystal_freq)
270
271/* Initialize the sensor registors to some sort of reasonable
272 default values. */
273#define VIDIOC_INT_INIT _IOW('d', 114, u32)
274
275/* Set v4l2_std_id for video OUTPUT devices. This is ignored by
276 video input devices. */
277#define VIDIOC_INT_S_STD_OUTPUT _IOW('d', 115, v4l2_std_id)
278
279/* Get v4l2_std_id for video OUTPUT devices. This is ignored by
280 video input devices. */
281#define VIDIOC_INT_G_STD_OUTPUT _IOW('d', 116, v4l2_std_id)
282
283/* Set GPIO pins. Very simple right now, might need to be extended with
284 a v4l2_gpio struct if a direction is also needed. */
285#define VIDIOC_INT_S_GPIO _IOW('d', 117, u32)
286
287#endif /* V4L2_COMMON_H_ */ 196#endif /* V4L2_COMMON_H_ */
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index e36faab8459b..2058dd45e915 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -40,6 +40,8 @@ struct v4l2_file_operations {
40 unsigned int (*poll) (struct file *, struct poll_table_struct *); 40 unsigned int (*poll) (struct file *, struct poll_table_struct *);
41 long (*ioctl) (struct file *, unsigned int, unsigned long); 41 long (*ioctl) (struct file *, unsigned int, unsigned long);
42 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 42 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
43 unsigned long (*get_unmapped_area) (struct file *, unsigned long,
44 unsigned long, unsigned long, unsigned long);
43 int (*mmap) (struct file *, struct vm_area_struct *); 45 int (*mmap) (struct file *, struct vm_area_struct *);
44 int (*open) (struct file *); 46 int (*open) (struct file *);
45 int (*release) (struct file *); 47 int (*release) (struct file *);
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 55e41afd95ef..0dd3e8e8653e 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -33,7 +33,9 @@
33#define V4L2_DEVICE_NAME_SIZE (BUS_ID_SIZE + 16) 33#define V4L2_DEVICE_NAME_SIZE (BUS_ID_SIZE + 16)
34 34
35struct v4l2_device { 35struct v4l2_device {
36 /* dev->driver_data points to this struct */ 36 /* dev->driver_data points to this struct.
37 Note: dev might be NULL if there is no parent device
38 as is the case with e.g. ISA devices. */
37 struct device *dev; 39 struct device *dev;
38 /* used to keep track of the registered subdevs */ 40 /* used to keep track of the registered subdevs */
39 struct list_head subdevs; 41 struct list_head subdevs;
@@ -42,33 +44,43 @@ struct v4l2_device {
42 spinlock_t lock; 44 spinlock_t lock;
43 /* unique device name, by default the driver name + bus ID */ 45 /* unique device name, by default the driver name + bus ID */
44 char name[V4L2_DEVICE_NAME_SIZE]; 46 char name[V4L2_DEVICE_NAME_SIZE];
47 /* notify callback called by some sub-devices. */
48 void (*notify)(struct v4l2_subdev *sd,
49 unsigned int notification, void *arg);
45}; 50};
46 51
47/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev */ 52/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev.
53 dev may be NULL in rare cases (ISA devices). In that case you
54 must fill in the v4l2_dev->name field before calling this function. */
48int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev); 55int __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 */ 56/* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
57 Since the parent disappears this ensures that v4l2_dev doesn't have an
58 invalid parent pointer. */
59void v4l2_device_disconnect(struct v4l2_device *v4l2_dev);
60/* Unregister all sub-devices and any other resources related to v4l2_dev. */
50void v4l2_device_unregister(struct v4l2_device *v4l2_dev); 61void v4l2_device_unregister(struct v4l2_device *v4l2_dev);
51 62
52/* Register a subdev with a v4l2 device. While registered the subdev module 63/* 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 64 is marked as in-use. An error is returned if the module is no longer
54 loaded when you attempt to register it. */ 65 loaded when you attempt to register it. */
55int __must_check v4l2_device_register_subdev(struct v4l2_device *dev, struct v4l2_subdev *sd); 66int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
67 struct v4l2_subdev *sd);
56/* Unregister a subdev with a v4l2 device. Can also be called if the subdev 68/* 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. */ 69 wasn't registered. In that case it will do nothing. */
58void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); 70void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
59 71
60/* Iterate over all subdevs. */ 72/* Iterate over all subdevs. */
61#define v4l2_device_for_each_subdev(sd, dev) \ 73#define v4l2_device_for_each_subdev(sd, v4l2_dev) \
62 list_for_each_entry(sd, &(dev)->subdevs, list) 74 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list)
63 75
64/* Call the specified callback for all subdevs matching the condition. 76/* Call the specified callback for all subdevs matching the condition.
65 Ignore any errors. Note that you cannot add or delete a subdev 77 Ignore any errors. Note that you cannot add or delete a subdev
66 while walking the subdevs list. */ 78 while walking the subdevs list. */
67#define __v4l2_device_call_subdevs(dev, cond, o, f, args...) \ 79#define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \
68 do { \ 80 do { \
69 struct v4l2_subdev *sd; \ 81 struct v4l2_subdev *sd; \
70 \ 82 \
71 list_for_each_entry(sd, &(dev)->subdevs, list) \ 83 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) \
72 if ((cond) && sd->ops->o && sd->ops->o->f) \ 84 if ((cond) && sd->ops->o && sd->ops->o->f) \
73 sd->ops->o->f(sd , ##args); \ 85 sd->ops->o->f(sd , ##args); \
74 } while (0) 86 } while (0)
@@ -77,12 +89,12 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
77 If the callback returns an error other than 0 or -ENOIOCTLCMD, then 89 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 90 return with that error code. Note that you cannot add or delete a
79 subdev while walking the subdevs list. */ 91 subdev while walking the subdevs list. */
80#define __v4l2_device_call_subdevs_until_err(dev, cond, o, f, args...) \ 92#define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \
81({ \ 93({ \
82 struct v4l2_subdev *sd; \ 94 struct v4l2_subdev *sd; \
83 long err = 0; \ 95 long err = 0; \
84 \ 96 \
85 list_for_each_entry(sd, &(dev)->subdevs, list) { \ 97 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) { \
86 if ((cond) && sd->ops->o && sd->ops->o->f) \ 98 if ((cond) && sd->ops->o && sd->ops->o->f) \
87 err = sd->ops->o->f(sd , ##args); \ 99 err = sd->ops->o->f(sd , ##args); \
88 if (err && err != -ENOIOCTLCMD) \ 100 if (err && err != -ENOIOCTLCMD) \
@@ -94,16 +106,16 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
94/* Call the specified callback for all subdevs matching grp_id (if 0, then 106/* 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 107 match them all). Ignore any errors. Note that you cannot add or delete
96 a subdev while walking the subdevs list. */ 108 a subdev while walking the subdevs list. */
97#define v4l2_device_call_all(dev, grpid, o, f, args...) \ 109#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \
98 __v4l2_device_call_subdevs(dev, \ 110 __v4l2_device_call_subdevs(v4l2_dev, \
99 !(grpid) || sd->grp_id == (grpid), o, f , ##args) 111 !(grpid) || sd->grp_id == (grpid), o, f , ##args)
100 112
101/* Call the specified callback for all subdevs matching grp_id (if 0, then 113/* 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 114 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 115 -ENOIOCTLCMD, then return with that error code. Note that you cannot
104 add or delete a subdev while walking the subdevs list. */ 116 add or delete a subdev while walking the subdevs list. */
105#define v4l2_device_call_until_err(dev, grpid, o, f, args...) \ 117#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \
106 __v4l2_device_call_subdevs_until_err(dev, \ 118 __v4l2_device_call_subdevs_until_err(v4l2_dev, \
107 !(grpid) || sd->grp_id == (grpid), o, f , ##args) 119 !(grpid) || sd->grp_id == (grpid), o, f , ##args)
108 120
109#endif 121#endif
diff --git a/include/media/v4l2-i2c-drv-legacy.h b/include/media/v4l2-i2c-drv-legacy.h
deleted file mode 100644
index e65dd9d84e8b..000000000000
--- a/include/media/v4l2-i2c-drv-legacy.h
+++ /dev/null
@@ -1,152 +0,0 @@
1/*
2 * v4l2-i2c-drv-legacy.h - contains I2C handling code that's identical
3 * for all V4L2 I2C drivers. Use this header if the
4 * I2C driver is used by both legacy drivers and
5 * drivers converted to the bus-based I2C API.
6 *
7 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24/* NOTE: the full version of this header is in the v4l-dvb repository
25 * and allows v4l i2c drivers to be compiled on older kernels as well.
26 * The version of this header as it appears in the kernel is a stripped
27 * version (without all the backwards compatibility stuff) and so it
28 * looks a bit odd.
29 *
30 * If you look at the full version then you will understand the reason
31 * for introducing this header since you really don't want to have all
32 * the tricky backwards compatibility code in each and every i2c driver.
33 */
34
35struct v4l2_i2c_driver_data {
36 const char * const name;
37 int driverid;
38 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
39 int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
40 int (*remove)(struct i2c_client *client);
41 int (*suspend)(struct i2c_client *client, pm_message_t state);
42 int (*resume)(struct i2c_client *client);
43 int (*legacy_probe)(struct i2c_adapter *adapter);
44 int legacy_class;
45 const struct i2c_device_id *id_table;
46};
47
48static struct v4l2_i2c_driver_data v4l2_i2c_data;
49static const struct i2c_client_address_data addr_data;
50static struct i2c_driver v4l2_i2c_driver_legacy;
51static char v4l2_i2c_drv_name_legacy[32];
52
53static int v4l2_i2c_drv_attach_legacy(struct i2c_adapter *adapter, int address, int kind)
54{
55 return v4l2_i2c_attach(adapter, address, &v4l2_i2c_driver_legacy,
56 v4l2_i2c_drv_name_legacy, v4l2_i2c_data.probe);
57}
58
59static int v4l2_i2c_drv_probe_legacy(struct i2c_adapter *adapter)
60{
61 if (v4l2_i2c_data.legacy_probe) {
62 if (v4l2_i2c_data.legacy_probe(adapter))
63 return i2c_probe(adapter, &addr_data, v4l2_i2c_drv_attach_legacy);
64 return 0;
65 }
66 if (adapter->class & v4l2_i2c_data.legacy_class)
67 return i2c_probe(adapter, &addr_data, v4l2_i2c_drv_attach_legacy);
68 return 0;
69}
70
71static int v4l2_i2c_drv_detach_legacy(struct i2c_client *client)
72{
73 int err;
74
75 if (v4l2_i2c_data.remove)
76 v4l2_i2c_data.remove(client);
77
78 err = i2c_detach_client(client);
79 if (err)
80 return err;
81 kfree(client);
82 return 0;
83}
84
85static int v4l2_i2c_drv_suspend_helper(struct i2c_client *client, pm_message_t state)
86{
87 return v4l2_i2c_data.suspend ? v4l2_i2c_data.suspend(client, state) : 0;
88}
89
90static int v4l2_i2c_drv_resume_helper(struct i2c_client *client)
91{
92 return v4l2_i2c_data.resume ? v4l2_i2c_data.resume(client) : 0;
93}
94
95/* ----------------------------------------------------------------------- */
96
97/* i2c implementation */
98static struct i2c_driver v4l2_i2c_driver_legacy = {
99 .driver = {
100 .owner = THIS_MODULE,
101 },
102 .attach_adapter = v4l2_i2c_drv_probe_legacy,
103 .detach_client = v4l2_i2c_drv_detach_legacy,
104 .suspend = v4l2_i2c_drv_suspend_helper,
105 .resume = v4l2_i2c_drv_resume_helper,
106};
107
108/* ----------------------------------------------------------------------- */
109
110/* i2c implementation */
111static struct i2c_driver v4l2_i2c_driver = {
112 .suspend = v4l2_i2c_drv_suspend_helper,
113 .resume = v4l2_i2c_drv_resume_helper,
114};
115
116static int __init v4l2_i2c_drv_init(void)
117{
118 int err;
119
120 strlcpy(v4l2_i2c_drv_name_legacy, v4l2_i2c_data.name, sizeof(v4l2_i2c_drv_name_legacy));
121 strlcat(v4l2_i2c_drv_name_legacy, "'", sizeof(v4l2_i2c_drv_name_legacy));
122
123 if (v4l2_i2c_data.legacy_class == 0)
124 v4l2_i2c_data.legacy_class = I2C_CLASS_TV_ANALOG;
125
126 v4l2_i2c_driver_legacy.driver.name = v4l2_i2c_drv_name_legacy;
127 v4l2_i2c_driver_legacy.id = v4l2_i2c_data.driverid;
128 v4l2_i2c_driver_legacy.command = v4l2_i2c_data.command;
129 err = i2c_add_driver(&v4l2_i2c_driver_legacy);
130
131 if (err)
132 return err;
133 v4l2_i2c_driver.driver.name = v4l2_i2c_data.name;
134 v4l2_i2c_driver.id = v4l2_i2c_data.driverid;
135 v4l2_i2c_driver.command = v4l2_i2c_data.command;
136 v4l2_i2c_driver.probe = v4l2_i2c_data.probe;
137 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
138 v4l2_i2c_driver.id_table = v4l2_i2c_data.id_table;
139 err = i2c_add_driver(&v4l2_i2c_driver);
140 if (err)
141 i2c_del_driver(&v4l2_i2c_driver_legacy);
142 return err;
143}
144
145static void __exit v4l2_i2c_drv_cleanup(void)
146{
147 i2c_del_driver(&v4l2_i2c_driver_legacy);
148 i2c_del_driver(&v4l2_i2c_driver);
149}
150
151module_init(v4l2_i2c_drv_init);
152module_exit(v4l2_i2c_drv_cleanup);
diff --git a/include/media/v4l2-i2c-drv.h b/include/media/v4l2-i2c-drv.h
index efdc8bf27f87..10a2882c3cbf 100644
--- a/include/media/v4l2-i2c-drv.h
+++ b/include/media/v4l2-i2c-drv.h
@@ -39,14 +39,11 @@
39 39
40struct v4l2_i2c_driver_data { 40struct v4l2_i2c_driver_data {
41 const char * const name; 41 const char * const name;
42 int driverid;
43 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); 42 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
44 int (*probe)(struct i2c_client *client, const struct i2c_device_id *id); 43 int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
45 int (*remove)(struct i2c_client *client); 44 int (*remove)(struct i2c_client *client);
46 int (*suspend)(struct i2c_client *client, pm_message_t state); 45 int (*suspend)(struct i2c_client *client, pm_message_t state);
47 int (*resume)(struct i2c_client *client); 46 int (*resume)(struct i2c_client *client);
48 int (*legacy_probe)(struct i2c_adapter *adapter);
49 int legacy_class;
50 const struct i2c_device_id *id_table; 47 const struct i2c_device_id *id_table;
51}; 48};
52 49
@@ -54,12 +51,11 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data;
54static struct i2c_driver v4l2_i2c_driver; 51static struct i2c_driver v4l2_i2c_driver;
55 52
56 53
57/* Bus-based I2C implementation for kernels >= 2.6.22 */ 54/* Bus-based I2C implementation for kernels >= 2.6.26 */
58 55
59static int __init v4l2_i2c_drv_init(void) 56static int __init v4l2_i2c_drv_init(void)
60{ 57{
61 v4l2_i2c_driver.driver.name = v4l2_i2c_data.name; 58 v4l2_i2c_driver.driver.name = v4l2_i2c_data.name;
62 v4l2_i2c_driver.id = v4l2_i2c_data.driverid;
63 v4l2_i2c_driver.command = v4l2_i2c_data.command; 59 v4l2_i2c_driver.command = v4l2_i2c_data.command;
64 v4l2_i2c_driver.probe = v4l2_i2c_data.probe; 60 v4l2_i2c_driver.probe = v4l2_i2c_data.probe;
65 v4l2_i2c_driver.remove = v4l2_i2c_data.remove; 61 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index b01c044868d0..7a4529defa88 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -15,6 +15,7 @@
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/compiler.h> /* need __user */ 16#include <linux/compiler.h> /* need __user */
17#ifdef CONFIG_VIDEO_V4L1_COMPAT 17#ifdef CONFIG_VIDEO_V4L1_COMPAT
18#define __MIN_V4L1
18#include <linux/videodev.h> 19#include <linux/videodev.h>
19#else 20#else
20#include <linux/videodev2.h> 21#include <linux/videodev2.h>
@@ -267,6 +268,7 @@ struct v4l2_ioctl_ops {
267 268
268/* Video standard functions */ 269/* Video standard functions */
269extern const char *v4l2_norm_to_name(v4l2_std_id id); 270extern const char *v4l2_norm_to_name(v4l2_std_id id);
271extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod);
270extern int v4l2_video_std_construct(struct v4l2_standard *vs, 272extern int v4l2_video_std_construct(struct v4l2_standard *vs,
271 int id, const char *name); 273 int id, const char *name);
272/* Prints the ioctl in a human-readable format */ 274/* Prints the ioctl in a human-readable format */
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 37b09e56e943..17856081c809 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -27,6 +27,16 @@ struct v4l2_device;
27struct v4l2_subdev; 27struct v4l2_subdev;
28struct tuner_setup; 28struct tuner_setup;
29 29
30/* decode_vbi_line */
31struct v4l2_decode_vbi_line {
32 u32 is_second_field; /* Set to 0 for the first (odd) field,
33 set to 1 for the second (even) field. */
34 u8 *p; /* Pointer to the sliced VBI data from the decoder.
35 On exit points to the start of the payload. */
36 u32 line; /* Line number of the sliced VBI data (1-23) */
37 u32 type; /* VBI service type (V4L2_SLICED_*). 0 if no service found */
38};
39
30/* Sub-devices are devices that are connected somehow to the main bridge 40/* Sub-devices are devices that are connected somehow to the main bridge
31 device. These devices are usually audio/video muxers/encoders/decoders or 41 device. These devices are usually audio/video muxers/encoders/decoders or
32 sensors and webcam controllers. 42 sensors and webcam controllers.
@@ -68,17 +78,36 @@ struct tuner_setup;
68 the use-case it might be better to use subdev-specific ops (currently 78 the use-case it might be better to use subdev-specific ops (currently
69 not yet implemented) since ops provide proper type-checking. 79 not yet implemented) since ops provide proper type-checking.
70 */ 80 */
81
82/* init: initialize the sensor registors to some sort of reasonable default
83 values. Do not use for new drivers and should be removed in existing
84 drivers.
85
86 load_fw: load firmware.
87
88 reset: generic reset command. The argument selects which subsystems to
89 reset. Passing 0 will always reset the whole chip. Do not use for new
90 drivers without discussing this first on the linux-media mailinglist.
91 There should be no reason normally to reset a device.
92
93 s_gpio: set GPIO pins. Very simple right now, might need to be extended with
94 a direction argument if needed.
95 */
71struct v4l2_subdev_core_ops { 96struct v4l2_subdev_core_ops {
72 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); 97 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
73 int (*log_status)(struct v4l2_subdev *sd); 98 int (*log_status)(struct v4l2_subdev *sd);
74 int (*init)(struct v4l2_subdev *sd, u32 val); 99 int (*init)(struct v4l2_subdev *sd, u32 val);
75 int (*s_standby)(struct v4l2_subdev *sd, u32 standby); 100 int (*load_fw)(struct v4l2_subdev *sd);
76 int (*reset)(struct v4l2_subdev *sd, u32 val); 101 int (*reset)(struct v4l2_subdev *sd, u32 val);
77 int (*s_gpio)(struct v4l2_subdev *sd, u32 val); 102 int (*s_gpio)(struct v4l2_subdev *sd, u32 val);
78 int (*queryctrl)(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc); 103 int (*queryctrl)(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc);
79 int (*g_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl); 104 int (*g_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
80 int (*s_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl); 105 int (*s_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
106 int (*g_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls);
107 int (*s_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls);
108 int (*try_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls);
81 int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm); 109 int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm);
110 int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);
82 long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg); 111 long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
83#ifdef CONFIG_VIDEO_ADV_DEBUG 112#ifdef CONFIG_VIDEO_ADV_DEBUG
84 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); 113 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
@@ -86,6 +115,16 @@ struct v4l2_subdev_core_ops {
86#endif 115#endif
87}; 116};
88 117
118/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio.
119
120 s_radio: v4l device was opened in Radio mode, to be replaced by s_mode.
121
122 s_type_addr: sets tuner type and its I2C addr.
123
124 s_config: sets tda9887 specific stuff, like port1, port2 and qss
125
126 s_standby: puts tuner on powersaving state, disabling it, except for i2c.
127 */
89struct v4l2_subdev_tuner_ops { 128struct v4l2_subdev_tuner_ops {
90 int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type); 129 int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type);
91 int (*s_radio)(struct v4l2_subdev *sd); 130 int (*s_radio)(struct v4l2_subdev *sd);
@@ -93,28 +132,93 @@ struct v4l2_subdev_tuner_ops {
93 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); 132 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
94 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); 133 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
95 int (*s_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); 134 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); 135 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); 136 int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
137 int (*s_standby)(struct v4l2_subdev *sd);
99}; 138};
100 139
140/* s_clock_freq: set the frequency (in Hz) of the audio clock output.
141 Used to slave an audio processor to the video decoder, ensuring that
142 audio and video remain synchronized. Usual values for the frequency
143 are 48000, 44100 or 32000 Hz. If the frequency is not supported, then
144 -EINVAL is returned.
145
146 s_i2s_clock_freq: sets I2S speed in bps. This is used to provide a standard
147 way to select I2S clock used by driving digital audio streams at some
148 board designs. Usual values for the frequency are 1024000 and 2048000.
149 If the frequency is not supported, then -EINVAL is returned.
150
151 s_routing: used to define the input and/or output pins of an audio chip,
152 and any additional configuration data.
153 Never attempt to use user-level input IDs (e.g. Composite, S-Video,
154 Tuner) at this level. An i2c device shouldn't know about whether an
155 input pin is connected to a Composite connector, become on another
156 board or platform it might be connected to something else entirely.
157 The calling driver is responsible for mapping a user-level input to
158 the right pins on the i2c device.
159 */
101struct v4l2_subdev_audio_ops { 160struct v4l2_subdev_audio_ops {
102 int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq); 161 int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
103 int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq); 162 int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
104 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route); 163 int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
105}; 164};
106 165
166/*
167 decode_vbi_line: video decoders that support sliced VBI need to implement
168 this ioctl. Field p of the v4l2_sliced_vbi_line struct is set to the
169 start of the VBI data that was generated by the decoder. The driver
170 then parses the sliced VBI data and sets the other fields in the
171 struct accordingly. The pointer p is updated to point to the start of
172 the payload which can be copied verbatim into the data field of the
173 v4l2_sliced_vbi_data struct. If no valid VBI data was found, then the
174 type field is set to 0 on return.
175
176 s_vbi_data: used to generate VBI signals on a video signal.
177 v4l2_sliced_vbi_data is filled with the data packets that should be
178 output. Note that if you set the line field to 0, then that VBI signal
179 is disabled. If no valid VBI data was found, then the type field is
180 set to 0 on return.
181
182 g_vbi_data: used to obtain the sliced VBI packet from a readback register.
183 Not all video decoders support this. If no data is available because
184 the readback register contains invalid or erroneous data -EIO is
185 returned. Note that you must fill in the 'id' member and the 'field'
186 member (to determine whether CC data from the first or second field
187 should be obtained).
188
189 s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
190 video input devices.
191
192 s_crystal_freq: sets the frequency of the crystal used to generate the
193 clocks in Hz. An extra flags field allows device specific configuration
194 regarding clock frequency dividers, etc. If not used, then set flags
195 to 0. If the frequency is not supported, then -EINVAL is returned.
196
197 g_input_status: get input status. Same as the status field in the v4l2_input
198 struct.
199
200 s_routing: see s_routing in audio_ops, except this version is for video
201 devices.
202 */
107struct v4l2_subdev_video_ops { 203struct v4l2_subdev_video_ops {
108 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route); 204 int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
109 int (*s_crystal_freq)(struct v4l2_subdev *sd, struct v4l2_crystal_freq *freq); 205 int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags);
110 int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line); 206 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); 207 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); 208 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); 209 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); 210 int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
211 int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
212 int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
115 int (*s_stream)(struct v4l2_subdev *sd, int enable); 213 int (*s_stream)(struct v4l2_subdev *sd, int enable);
116 int (*s_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt); 214 int (*enum_fmt)(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmtdesc);
117 int (*g_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt); 215 int (*g_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
216 int (*try_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
217 int (*s_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
218 int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
219 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
220 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
221 int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival);
118}; 222};
119 223
120struct v4l2_subdev_ops { 224struct v4l2_subdev_ops {
@@ -132,7 +236,7 @@ struct v4l2_subdev_ops {
132struct v4l2_subdev { 236struct v4l2_subdev {
133 struct list_head list; 237 struct list_head list;
134 struct module *owner; 238 struct module *owner;
135 struct v4l2_device *dev; 239 struct v4l2_device *v4l2_dev;
136 const struct v4l2_subdev_ops *ops; 240 const struct v4l2_subdev_ops *ops;
137 /* name must be unique */ 241 /* name must be unique */
138 char name[V4L2_SUBDEV_NAME_SIZE]; 242 char name[V4L2_SUBDEV_NAME_SIZE];
@@ -152,18 +256,6 @@ static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
152 return sd->priv; 256 return sd->priv;
153} 257}
154 258
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, 259static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
168 const struct v4l2_subdev_ops *ops) 260 const struct v4l2_subdev_ops *ops)
169{ 261{
@@ -171,7 +263,7 @@ static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
171 /* ops->core MUST be set */ 263 /* ops->core MUST be set */
172 BUG_ON(!ops || !ops->core); 264 BUG_ON(!ops || !ops->core);
173 sd->ops = ops; 265 sd->ops = ops;
174 sd->dev = NULL; 266 sd->v4l2_dev = NULL;
175 sd->name[0] = '\0'; 267 sd->name[0] = '\0';
176 sd->grp_id = 0; 268 sd->grp_id = 0;
177 sd->priv = NULL; 269 sd->priv = NULL;
@@ -186,4 +278,9 @@ static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
186 (!(sd) ? -ENODEV : (((sd) && (sd)->ops->o && (sd)->ops->o->f) ? \ 278 (!(sd) ? -ENODEV : (((sd) && (sd)->ops->o && (sd)->ops->o->f) ? \
187 (sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD)) 279 (sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD))
188 280
281/* Send a notification to v4l2_device. */
282#define v4l2_subdev_notify(sd, notification, arg) \
283 ((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
284 (sd)->v4l2_dev->notify((sd), (notification), (arg)))
285
189#endif 286#endif
diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h
index 874f1340d049..1c5946c44758 100644
--- a/include/media/videobuf-core.h
+++ b/include/media/videobuf-core.h
@@ -18,6 +18,7 @@
18 18
19#include <linux/poll.h> 19#include <linux/poll.h>
20#ifdef CONFIG_VIDEO_V4L1_COMPAT 20#ifdef CONFIG_VIDEO_V4L1_COMPAT
21#define __MIN_V4L1
21#include <linux/videodev.h> 22#include <linux/videodev.h>
22#endif 23#endif
23#include <linux/videodev2.h> 24#include <linux/videodev2.h>