aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-subdev.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/media/v4l2-subdev.h')
-rw-r--r--include/media/v4l2-subdev.h107
1 files changed, 95 insertions, 12 deletions
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 1d181b4ccb01..9a8535be1edf 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -27,6 +27,22 @@ 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
40/* s_crystal_freq */
41struct v4l2_crystal_freq {
42 u32 freq; /* frequency in Hz of the crystal */
43 u32 flags; /* device specific flags */
44};
45
30/* Sub-devices are devices that are connected somehow to the main bridge 46/* Sub-devices are devices that are connected somehow to the main bridge
31 device. These devices are usually audio/video muxers/encoders/decoders or 47 device. These devices are usually audio/video muxers/encoders/decoders or
32 sensors and webcam controllers. 48 sensors and webcam controllers.
@@ -68,6 +84,21 @@ struct tuner_setup;
68 the use-case it might be better to use subdev-specific ops (currently 84 the use-case it might be better to use subdev-specific ops (currently
69 not yet implemented) since ops provide proper type-checking. 85 not yet implemented) since ops provide proper type-checking.
70 */ 86 */
87
88/* init: initialize the sensor registors to some sort of reasonable default
89 values. Do not use for new drivers and should be removed in existing
90 drivers.
91
92 reset: generic reset command. The argument selects which subsystems to
93 reset. Passing 0 will always reset the whole chip. Do not use for new
94 drivers without discussing this first on the linux-media mailinglist.
95 There should be no reason normally to reset a device.
96
97 s_gpio: set GPIO pins. Very simple right now, might need to be extended with
98 a direction argument if needed.
99
100 s_standby: puts tuner on powersaving state, disabling it, except for i2c.
101 */
71struct v4l2_subdev_core_ops { 102struct v4l2_subdev_core_ops {
72 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); 103 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
73 int (*log_status)(struct v4l2_subdev *sd); 104 int (*log_status)(struct v4l2_subdev *sd);
@@ -89,6 +120,14 @@ struct v4l2_subdev_core_ops {
89#endif 120#endif
90}; 121};
91 122
123/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio.
124
125 s_radio: v4l device was opened in Radio mode, to be replaced by s_mode.
126
127 s_type_addr: sets tuner type and its I2C addr.
128
129 s_config: sets tda9887 specific stuff, like port1, port2 and qss
130 */
92struct v4l2_subdev_tuner_ops { 131struct v4l2_subdev_tuner_ops {
93 int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type); 132 int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type);
94 int (*s_radio)(struct v4l2_subdev *sd); 133 int (*s_radio)(struct v4l2_subdev *sd);
@@ -101,12 +140,68 @@ struct v4l2_subdev_tuner_ops {
101 int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config); 140 int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
102}; 141};
103 142
143/* s_clock_freq: set the frequency (in Hz) of the audio clock output.
144 Used to slave an audio processor to the video decoder, ensuring that
145 audio and video remain synchronized. Usual values for the frequency
146 are 48000, 44100 or 32000 Hz. If the frequency is not supported, then
147 -EINVAL is returned.
148
149 s_i2s_clock_freq: sets I2S speed in bps. This is used to provide a standard
150 way to select I2S clock used by driving digital audio streams at some
151 board designs. Usual values for the frequency are 1024000 and 2048000.
152 If the frequency is not supported, then -EINVAL is returned.
153
154 s_routing: used to define the input and/or output pins of an audio chip.
155 Never attempt to use user-level input IDs (e.g. Composite, S-Video,
156 Tuner) at this level. An i2c device shouldn't know about whether an
157 input pin is connected to a Composite connector, become on another
158 board or platform it might be connected to something else entirely.
159 The calling driver is responsible for mapping a user-level input to
160 the right pins on the i2c device.
161 */
104struct v4l2_subdev_audio_ops { 162struct v4l2_subdev_audio_ops {
105 int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq); 163 int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
106 int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq); 164 int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
107 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route); 165 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route);
108}; 166};
109 167
168/*
169 decode_vbi_line: video decoders that support sliced VBI need to implement
170 this ioctl. Field p of the v4l2_sliced_vbi_line struct is set to the
171 start of the VBI data that was generated by the decoder. The driver
172 then parses the sliced VBI data and sets the other fields in the
173 struct accordingly. The pointer p is updated to point to the start of
174 the payload which can be copied verbatim into the data field of the
175 v4l2_sliced_vbi_data struct. If no valid VBI data was found, then the
176 type field is set to 0 on return.
177
178 s_vbi_data: used to generate VBI signals on a video signal.
179 v4l2_sliced_vbi_data is filled with the data packets that should be
180 output. Note that if you set the line field to 0, then that VBI signal
181 is disabled. If no valid VBI data was found, then the type field is
182 set to 0 on return.
183
184 g_vbi_data: used to obtain the sliced VBI packet from a readback register.
185 Not all video decoders support this. If no data is available because
186 the readback register contains invalid or erroneous data -EIO is
187 returned. Note that you must fill in the 'id' member and the 'field'
188 member (to determine whether CC data from the first or second field
189 should be obtained).
190
191 s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
192 video input devices.
193
194 s_crystal_freq: sets the frequency of the crystal used to generate the
195 clocks. An extra flags field allows device specific configuration
196 regarding clock frequency dividers, etc. If not used, then set flags
197 to 0. If the frequency is not supported, then -EINVAL is returned.
198
199 g_input_status: get input status. Same as the status field in the v4l2_input
200 struct.
201
202 s_routing: see s_routing in audio_ops, except this version is for video
203 devices.
204 */
110struct v4l2_subdev_video_ops { 205struct v4l2_subdev_video_ops {
111 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route); 206 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route);
112 int (*s_crystal_freq)(struct v4l2_subdev *sd, struct v4l2_crystal_freq *freq); 207 int (*s_crystal_freq)(struct v4l2_subdev *sd, struct v4l2_crystal_freq *freq);
@@ -163,18 +258,6 @@ static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
163 return sd->priv; 258 return sd->priv;
164} 259}
165 260
166/* Convert an ioctl-type command to the proper v4l2_subdev_ops function call.
167 This is used by subdev modules that can be called by both old-style ioctl
168 commands and through the v4l2_subdev_ops.
169
170 The ioctl API of the subdev driver can call this function to call the
171 right ops based on the ioctl cmd and arg.
172
173 Once all subdev drivers have been converted and all drivers no longer
174 use the ioctl interface, then this function can be removed.
175 */
176int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg);
177
178static inline void v4l2_subdev_init(struct v4l2_subdev *sd, 261static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
179 const struct v4l2_subdev_ops *ops) 262 const struct v4l2_subdev_ops *ops)
180{ 263{