diff options
Diffstat (limited to 'include/media/v4l2-subdev.h')
-rw-r--r-- | include/media/v4l2-subdev.h | 162 |
1 files changed, 153 insertions, 9 deletions
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index d411345f244b..9ba99cd39ee7 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h | |||
@@ -22,6 +22,17 @@ | |||
22 | #define _V4L2_SUBDEV_H | 22 | #define _V4L2_SUBDEV_H |
23 | 23 | ||
24 | #include <media/v4l2-common.h> | 24 | #include <media/v4l2-common.h> |
25 | #include <media/v4l2-mediabus.h> | ||
26 | |||
27 | /* generic v4l2_device notify callback notification values */ | ||
28 | #define V4L2_SUBDEV_IR_RX_NOTIFY _IOW('v', 0, u32) | ||
29 | #define V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ 0x00000001 | ||
30 | #define V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED 0x00000002 | ||
31 | #define V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN 0x00000004 | ||
32 | #define V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN 0x00000008 | ||
33 | |||
34 | #define V4L2_SUBDEV_IR_TX_NOTIFY _IOW('v', 1, u32) | ||
35 | #define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ 0x00000001 | ||
25 | 36 | ||
26 | struct v4l2_device; | 37 | struct v4l2_device; |
27 | struct v4l2_subdev; | 38 | struct v4l2_subdev; |
@@ -96,6 +107,9 @@ struct v4l2_decode_vbi_line { | |||
96 | 107 | ||
97 | s_gpio: set GPIO pins. Very simple right now, might need to be extended with | 108 | s_gpio: set GPIO pins. Very simple right now, might need to be extended with |
98 | a direction argument if needed. | 109 | a direction argument if needed. |
110 | |||
111 | s_power: puts subdevice in power saving mode (on == 0) or normal operation | ||
112 | mode (on == 1). | ||
99 | */ | 113 | */ |
100 | struct v4l2_subdev_core_ops { | 114 | struct v4l2_subdev_core_ops { |
101 | int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); | 115 | int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); |
@@ -118,6 +132,7 @@ struct v4l2_subdev_core_ops { | |||
118 | int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); | 132 | int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); |
119 | int (*s_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); | 133 | int (*s_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); |
120 | #endif | 134 | #endif |
135 | int (*s_power)(struct v4l2_subdev *sd, int on); | ||
121 | }; | 136 | }; |
122 | 137 | ||
123 | /* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio. | 138 | /* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio. |
@@ -127,8 +142,6 @@ struct v4l2_subdev_core_ops { | |||
127 | s_type_addr: sets tuner type and its I2C addr. | 142 | s_type_addr: sets tuner type and its I2C addr. |
128 | 143 | ||
129 | s_config: sets tda9887 specific stuff, like port1, port2 and qss | 144 | s_config: sets tda9887 specific stuff, like port1, port2 and qss |
130 | |||
131 | s_standby: puts tuner on powersaving state, disabling it, except for i2c. | ||
132 | */ | 145 | */ |
133 | struct v4l2_subdev_tuner_ops { | 146 | struct v4l2_subdev_tuner_ops { |
134 | int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type); | 147 | int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type); |
@@ -141,7 +154,6 @@ struct v4l2_subdev_tuner_ops { | |||
141 | int (*s_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm); | 154 | int (*s_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm); |
142 | int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type); | 155 | int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type); |
143 | int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config); | 156 | int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config); |
144 | int (*s_standby)(struct v4l2_subdev *sd); | ||
145 | }; | 157 | }; |
146 | 158 | ||
147 | /* s_clock_freq: set the frequency (in Hz) of the audio clock output. | 159 | /* s_clock_freq: set the frequency (in Hz) of the audio clock output. |
@@ -196,7 +208,7 @@ struct v4l2_subdev_audio_ops { | |||
196 | s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by | 208 | s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by |
197 | video input devices. | 209 | video input devices. |
198 | 210 | ||
199 | s_crystal_freq: sets the frequency of the crystal used to generate the | 211 | s_crystal_freq: sets the frequency of the crystal used to generate the |
200 | clocks in Hz. An extra flags field allows device specific configuration | 212 | clocks in Hz. An extra flags field allows device specific configuration |
201 | regarding clock frequency dividers, etc. If not used, then set flags | 213 | regarding clock frequency dividers, etc. If not used, then set flags |
202 | to 0. If the frequency is not supported, then -EINVAL is returned. | 214 | to 0. If the frequency is not supported, then -EINVAL is returned. |
@@ -206,6 +218,26 @@ struct v4l2_subdev_audio_ops { | |||
206 | 218 | ||
207 | s_routing: see s_routing in audio_ops, except this version is for video | 219 | s_routing: see s_routing in audio_ops, except this version is for video |
208 | devices. | 220 | devices. |
221 | |||
222 | s_dv_preset: set dv (Digital Video) preset in the sub device. Similar to | ||
223 | s_std() | ||
224 | |||
225 | query_dv_preset: query dv preset in the sub device. This is similar to | ||
226 | querystd() | ||
227 | |||
228 | s_dv_timings(): Set custom dv timings in the sub device. This is used | ||
229 | when sub device is capable of setting detailed timing information | ||
230 | in the hardware to generate/detect the video signal. | ||
231 | |||
232 | g_dv_timings(): Get custom dv timings in the sub device. | ||
233 | |||
234 | enum_mbus_fmt: enumerate pixel formats, provided by a video data source | ||
235 | |||
236 | g_mbus_fmt: get the current pixel format, provided by a video data source | ||
237 | |||
238 | try_mbus_fmt: try to set a pixel format on a video data source | ||
239 | |||
240 | s_mbus_fmt: set a pixel format on a video data source | ||
209 | */ | 241 | */ |
210 | struct v4l2_subdev_video_ops { | 242 | struct v4l2_subdev_video_ops { |
211 | int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config); | 243 | int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config); |
@@ -229,13 +261,125 @@ struct v4l2_subdev_video_ops { | |||
229 | int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); | 261 | int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); |
230 | int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); | 262 | int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); |
231 | int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival); | 263 | int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival); |
264 | int (*s_dv_preset)(struct v4l2_subdev *sd, | ||
265 | struct v4l2_dv_preset *preset); | ||
266 | int (*query_dv_preset)(struct v4l2_subdev *sd, | ||
267 | struct v4l2_dv_preset *preset); | ||
268 | int (*s_dv_timings)(struct v4l2_subdev *sd, | ||
269 | struct v4l2_dv_timings *timings); | ||
270 | int (*g_dv_timings)(struct v4l2_subdev *sd, | ||
271 | struct v4l2_dv_timings *timings); | ||
272 | int (*enum_mbus_fmt)(struct v4l2_subdev *sd, int index, | ||
273 | enum v4l2_mbus_pixelcode *code); | ||
274 | int (*g_mbus_fmt)(struct v4l2_subdev *sd, | ||
275 | struct v4l2_mbus_framefmt *fmt); | ||
276 | int (*try_mbus_fmt)(struct v4l2_subdev *sd, | ||
277 | struct v4l2_mbus_framefmt *fmt); | ||
278 | int (*s_mbus_fmt)(struct v4l2_subdev *sd, | ||
279 | struct v4l2_mbus_framefmt *fmt); | ||
280 | }; | ||
281 | |||
282 | /** | ||
283 | * struct v4l2_subdev_sensor_ops - v4l2-subdev sensor operations | ||
284 | * @g_skip_top_lines: number of lines at the top of the image to be skipped. | ||
285 | * This is needed for some sensors, which always corrupt | ||
286 | * several top lines of the output image, or which send their | ||
287 | * metadata in them. | ||
288 | */ | ||
289 | struct v4l2_subdev_sensor_ops { | ||
290 | int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines); | ||
291 | }; | ||
292 | |||
293 | /* | ||
294 | interrupt_service_routine: Called by the bridge chip's interrupt service | ||
295 | handler, when an IR interrupt status has be raised due to this subdev, | ||
296 | so that this subdev can handle the details. It may schedule work to be | ||
297 | performed later. It must not sleep. *Called from an IRQ context*. | ||
298 | |||
299 | [rt]x_g_parameters: Get the current operating parameters and state of the | ||
300 | the IR receiver or transmitter. | ||
301 | |||
302 | [rt]x_s_parameters: Set the current operating parameters and state of the | ||
303 | the IR receiver or transmitter. It is recommended to call | ||
304 | [rt]x_g_parameters first to fill out the current state, and only change | ||
305 | the fields that need to be changed. Upon return, the actual device | ||
306 | operating parameters and state will be returned. Note that hardware | ||
307 | limitations may prevent the actual settings from matching the requested | ||
308 | settings - e.g. an actual carrier setting of 35,904 Hz when 36,000 Hz | ||
309 | was requested. An exception is when the shutdown parameter is true. | ||
310 | The last used operational parameters will be returned, but the actual | ||
311 | state of the hardware be different to minimize power consumption and | ||
312 | processing when shutdown is true. | ||
313 | |||
314 | rx_read: Reads received codes or pulse width data. | ||
315 | The semantics are similar to a non-blocking read() call. | ||
316 | |||
317 | tx_write: Writes codes or pulse width data for transmission. | ||
318 | The semantics are similar to a non-blocking write() call. | ||
319 | */ | ||
320 | |||
321 | enum v4l2_subdev_ir_mode { | ||
322 | V4L2_SUBDEV_IR_MODE_PULSE_WIDTH, /* space & mark widths in nanosecs */ | ||
323 | }; | ||
324 | |||
325 | /* Data format of data read or written for V4L2_SUBDEV_IR_MODE_PULSE_WIDTH */ | ||
326 | #define V4L2_SUBDEV_IR_PULSE_MAX_WIDTH_NS 0x7fffffff | ||
327 | #define V4L2_SUBDEV_IR_PULSE_LEVEL_MASK 0x80000000 | ||
328 | #define V4L2_SUBDEV_IR_PULSE_RX_SEQ_END 0xffffffff | ||
329 | |||
330 | struct v4l2_subdev_ir_parameters { | ||
331 | /* Either Rx or Tx */ | ||
332 | unsigned int bytes_per_data_element; /* of data in read or write call */ | ||
333 | enum v4l2_subdev_ir_mode mode; | ||
334 | |||
335 | bool enable; | ||
336 | bool interrupt_enable; | ||
337 | bool shutdown; /* true: set hardware to low/no power, false: normal */ | ||
338 | |||
339 | bool modulation; /* true: uses carrier, false: baseband */ | ||
340 | u32 max_pulse_width; /* ns, valid only for baseband signal */ | ||
341 | unsigned int carrier_freq; /* Hz, valid only for modulated signal*/ | ||
342 | unsigned int duty_cycle; /* percent, valid only for modulated signal*/ | ||
343 | bool invert; /* logically invert sense of mark/space */ | ||
344 | |||
345 | /* Rx only */ | ||
346 | u32 noise_filter_min_width; /* ns, min time of a valid pulse */ | ||
347 | unsigned int carrier_range_lower; /* Hz, valid only for modulated sig */ | ||
348 | unsigned int carrier_range_upper; /* Hz, valid only for modulated sig */ | ||
349 | u32 resolution; /* ns */ | ||
350 | }; | ||
351 | |||
352 | struct v4l2_subdev_ir_ops { | ||
353 | /* Common to receiver and transmitter */ | ||
354 | int (*interrupt_service_routine)(struct v4l2_subdev *sd, | ||
355 | u32 status, bool *handled); | ||
356 | |||
357 | /* Receiver */ | ||
358 | int (*rx_read)(struct v4l2_subdev *sd, u8 *buf, size_t count, | ||
359 | ssize_t *num); | ||
360 | |||
361 | int (*rx_g_parameters)(struct v4l2_subdev *sd, | ||
362 | struct v4l2_subdev_ir_parameters *params); | ||
363 | int (*rx_s_parameters)(struct v4l2_subdev *sd, | ||
364 | struct v4l2_subdev_ir_parameters *params); | ||
365 | |||
366 | /* Transmitter */ | ||
367 | int (*tx_write)(struct v4l2_subdev *sd, u8 *buf, size_t count, | ||
368 | ssize_t *num); | ||
369 | |||
370 | int (*tx_g_parameters)(struct v4l2_subdev *sd, | ||
371 | struct v4l2_subdev_ir_parameters *params); | ||
372 | int (*tx_s_parameters)(struct v4l2_subdev *sd, | ||
373 | struct v4l2_subdev_ir_parameters *params); | ||
232 | }; | 374 | }; |
233 | 375 | ||
234 | struct v4l2_subdev_ops { | 376 | struct v4l2_subdev_ops { |
235 | const struct v4l2_subdev_core_ops *core; | 377 | const struct v4l2_subdev_core_ops *core; |
236 | const struct v4l2_subdev_tuner_ops *tuner; | 378 | const struct v4l2_subdev_tuner_ops *tuner; |
237 | const struct v4l2_subdev_audio_ops *audio; | 379 | const struct v4l2_subdev_audio_ops *audio; |
238 | const struct v4l2_subdev_video_ops *video; | 380 | const struct v4l2_subdev_video_ops *video; |
381 | const struct v4l2_subdev_ir_ops *ir; | ||
382 | const struct v4l2_subdev_sensor_ops *sensor; | ||
239 | }; | 383 | }; |
240 | 384 | ||
241 | #define V4L2_SUBDEV_NAME_SIZE 32 | 385 | #define V4L2_SUBDEV_NAME_SIZE 32 |
@@ -290,7 +434,7 @@ static inline void v4l2_subdev_init(struct v4l2_subdev *sd, | |||
290 | Example: err = v4l2_subdev_call(sd, core, g_chip_ident, &chip); | 434 | Example: err = v4l2_subdev_call(sd, core, g_chip_ident, &chip); |
291 | */ | 435 | */ |
292 | #define v4l2_subdev_call(sd, o, f, args...) \ | 436 | #define v4l2_subdev_call(sd, o, f, args...) \ |
293 | (!(sd) ? -ENODEV : (((sd) && (sd)->ops->o && (sd)->ops->o->f) ? \ | 437 | (!(sd) ? -ENODEV : (((sd)->ops->o && (sd)->ops->o->f) ? \ |
294 | (sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD)) | 438 | (sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD)) |
295 | 439 | ||
296 | /* Send a notification to v4l2_device. */ | 440 | /* Send a notification to v4l2_device. */ |