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.h127
1 files changed, 84 insertions, 43 deletions
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 9ba99cd39ee7..4a97d7341a94 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -35,6 +35,7 @@
35#define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ 0x00000001 35#define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ 0x00000001
36 36
37struct v4l2_device; 37struct v4l2_device;
38struct v4l2_ctrl_handler;
38struct v4l2_subdev; 39struct v4l2_subdev;
39struct tuner_setup; 40struct tuner_setup;
40 41
@@ -90,10 +91,31 @@ struct v4l2_decode_vbi_line {
90 not yet implemented) since ops provide proper type-checking. 91 not yet implemented) since ops provide proper type-checking.
91 */ 92 */
92 93
94/* Subdevice external IO pin configuration */
95#define V4L2_SUBDEV_IO_PIN_DISABLE (1 << 0) /* ENABLE assumed */
96#define V4L2_SUBDEV_IO_PIN_OUTPUT (1 << 1)
97#define V4L2_SUBDEV_IO_PIN_INPUT (1 << 2)
98#define V4L2_SUBDEV_IO_PIN_SET_VALUE (1 << 3) /* Set output value */
99#define V4L2_SUBDEV_IO_PIN_ACTIVE_LOW (1 << 4) /* ACTIVE HIGH assumed */
100
101struct v4l2_subdev_io_pin_config {
102 u32 flags; /* V4L2_SUBDEV_IO_PIN_* flags for this pin's config */
103 u8 pin; /* Chip external IO pin to configure */
104 u8 function; /* Internal signal pad/function to route to IO pin */
105 u8 value; /* Initial value for pin - e.g. GPIO output value */
106 u8 strength; /* Pin drive strength */
107};
108
93/* s_config: if set, then it is always called by the v4l2_i2c_new_subdev* 109/* s_config: if set, then it is always called by the v4l2_i2c_new_subdev*
94 functions after the v4l2_subdev was registered. It is used to pass 110 functions after the v4l2_subdev was registered. It is used to pass
95 platform data to the subdev which can be used during initialization. 111 platform data to the subdev which can be used during initialization.
96 112
113 s_io_pin_config: configure one or more chip I/O pins for chips that
114 multiplex different internal signal pads out to IO pins. This function
115 takes a pointer to an array of 'n' pin configuration entries, one for
116 each pin being configured. This function could be called at times
117 other than just subdevice initialization.
118
97 init: initialize the sensor registors to some sort of reasonable default 119 init: initialize the sensor registors to some sort of reasonable default
98 values. Do not use for new drivers and should be removed in existing 120 values. Do not use for new drivers and should be removed in existing
99 drivers. 121 drivers.
@@ -110,11 +132,18 @@ struct v4l2_decode_vbi_line {
110 132
111 s_power: puts subdevice in power saving mode (on == 0) or normal operation 133 s_power: puts subdevice in power saving mode (on == 0) or normal operation
112 mode (on == 1). 134 mode (on == 1).
135
136 interrupt_service_routine: Called by the bridge chip's interrupt service
137 handler, when an interrupt status has be raised due to this subdev,
138 so that this subdev can handle the details. It may schedule work to be
139 performed later. It must not sleep. *Called from an IRQ context*.
113 */ 140 */
114struct v4l2_subdev_core_ops { 141struct v4l2_subdev_core_ops {
115 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); 142 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
116 int (*log_status)(struct v4l2_subdev *sd); 143 int (*log_status)(struct v4l2_subdev *sd);
117 int (*s_config)(struct v4l2_subdev *sd, int irq, void *platform_data); 144 int (*s_config)(struct v4l2_subdev *sd, int irq, void *platform_data);
145 int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n,
146 struct v4l2_subdev_io_pin_config *pincfg);
118 int (*init)(struct v4l2_subdev *sd, u32 val); 147 int (*init)(struct v4l2_subdev *sd, u32 val);
119 int (*load_fw)(struct v4l2_subdev *sd); 148 int (*load_fw)(struct v4l2_subdev *sd);
120 int (*reset)(struct v4l2_subdev *sd, u32 val); 149 int (*reset)(struct v4l2_subdev *sd, u32 val);
@@ -133,6 +162,8 @@ struct v4l2_subdev_core_ops {
133 int (*s_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); 162 int (*s_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
134#endif 163#endif
135 int (*s_power)(struct v4l2_subdev *sd, int on); 164 int (*s_power)(struct v4l2_subdev *sd, int on);
165 int (*interrupt_service_routine)(struct v4l2_subdev *sd,
166 u32 status, bool *handled);
136}; 167};
137 168
138/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio. 169/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio.
@@ -180,31 +211,10 @@ struct v4l2_subdev_audio_ops {
180 int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq); 211 int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
181 int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq); 212 int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
182 int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config); 213 int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
214 int (*s_stream)(struct v4l2_subdev *sd, int enable);
183}; 215};
184 216
185/* 217/*
186 decode_vbi_line: video decoders that support sliced VBI need to implement
187 this ioctl. Field p of the v4l2_sliced_vbi_line struct is set to the
188 start of the VBI data that was generated by the decoder. The driver
189 then parses the sliced VBI data and sets the other fields in the
190 struct accordingly. The pointer p is updated to point to the start of
191 the payload which can be copied verbatim into the data field of the
192 v4l2_sliced_vbi_data struct. If no valid VBI data was found, then the
193 type field is set to 0 on return.
194
195 s_vbi_data: used to generate VBI signals on a video signal.
196 v4l2_sliced_vbi_data is filled with the data packets that should be
197 output. Note that if you set the line field to 0, then that VBI signal
198 is disabled. If no valid VBI data was found, then the type field is
199 set to 0 on return.
200
201 g_vbi_data: used to obtain the sliced VBI packet from a readback register.
202 Not all video decoders support this. If no data is available because
203 the readback register contains invalid or erroneous data -EIO is
204 returned. Note that you must fill in the 'id' member and the 'field'
205 member (to determine whether CC data from the first or second field
206 should be obtained).
207
208 s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by 218 s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
209 video input devices. 219 video input devices.
210 220
@@ -242,10 +252,6 @@ struct v4l2_subdev_audio_ops {
242struct v4l2_subdev_video_ops { 252struct v4l2_subdev_video_ops {
243 int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config); 253 int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
244 int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags); 254 int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags);
245 int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line);
246 int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data);
247 int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data);
248 int (*g_sliced_vbi_cap)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_cap *cap);
249 int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std); 255 int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
250 int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std); 256 int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
251 int (*g_input_status)(struct v4l2_subdev *sd, u32 *status); 257 int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
@@ -261,6 +267,8 @@ struct v4l2_subdev_video_ops {
261 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); 267 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
262 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); 268 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
263 int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival); 269 int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival);
270 int (*enum_dv_presets) (struct v4l2_subdev *sd,
271 struct v4l2_dv_enum_preset *preset);
264 int (*s_dv_preset)(struct v4l2_subdev *sd, 272 int (*s_dv_preset)(struct v4l2_subdev *sd,
265 struct v4l2_dv_preset *preset); 273 struct v4l2_dv_preset *preset);
266 int (*query_dv_preset)(struct v4l2_subdev *sd, 274 int (*query_dv_preset)(struct v4l2_subdev *sd,
@@ -269,7 +277,7 @@ struct v4l2_subdev_video_ops {
269 struct v4l2_dv_timings *timings); 277 struct v4l2_dv_timings *timings);
270 int (*g_dv_timings)(struct v4l2_subdev *sd, 278 int (*g_dv_timings)(struct v4l2_subdev *sd,
271 struct v4l2_dv_timings *timings); 279 struct v4l2_dv_timings *timings);
272 int (*enum_mbus_fmt)(struct v4l2_subdev *sd, int index, 280 int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
273 enum v4l2_mbus_pixelcode *code); 281 enum v4l2_mbus_pixelcode *code);
274 int (*g_mbus_fmt)(struct v4l2_subdev *sd, 282 int (*g_mbus_fmt)(struct v4l2_subdev *sd,
275 struct v4l2_mbus_framefmt *fmt); 283 struct v4l2_mbus_framefmt *fmt);
@@ -279,6 +287,45 @@ struct v4l2_subdev_video_ops {
279 struct v4l2_mbus_framefmt *fmt); 287 struct v4l2_mbus_framefmt *fmt);
280}; 288};
281 289
290/*
291 decode_vbi_line: video decoders that support sliced VBI need to implement
292 this ioctl. Field p of the v4l2_sliced_vbi_line struct is set to the
293 start of the VBI data that was generated by the decoder. The driver
294 then parses the sliced VBI data and sets the other fields in the
295 struct accordingly. The pointer p is updated to point to the start of
296 the payload which can be copied verbatim into the data field of the
297 v4l2_sliced_vbi_data struct. If no valid VBI data was found, then the
298 type field is set to 0 on return.
299
300 s_vbi_data: used to generate VBI signals on a video signal.
301 v4l2_sliced_vbi_data is filled with the data packets that should be
302 output. Note that if you set the line field to 0, then that VBI signal
303 is disabled. If no valid VBI data was found, then the type field is
304 set to 0 on return.
305
306 g_vbi_data: used to obtain the sliced VBI packet from a readback register.
307 Not all video decoders support this. If no data is available because
308 the readback register contains invalid or erroneous data -EIO is
309 returned. Note that you must fill in the 'id' member and the 'field'
310 member (to determine whether CC data from the first or second field
311 should be obtained).
312
313 s_raw_fmt: setup the video encoder/decoder for raw VBI.
314
315 g_sliced_fmt: retrieve the current sliced VBI settings.
316
317 s_sliced_fmt: setup the sliced VBI settings.
318 */
319struct v4l2_subdev_vbi_ops {
320 int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line);
321 int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data);
322 int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data);
323 int (*g_sliced_vbi_cap)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_cap *cap);
324 int (*s_raw_fmt)(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt);
325 int (*g_sliced_fmt)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
326 int (*s_sliced_fmt)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
327};
328
282/** 329/**
283 * struct v4l2_subdev_sensor_ops - v4l2-subdev sensor operations 330 * 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. 331 * @g_skip_top_lines: number of lines at the top of the image to be skipped.
@@ -291,11 +338,6 @@ struct v4l2_subdev_sensor_ops {
291}; 338};
292 339
293/* 340/*
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 341 [rt]x_g_parameters: Get the current operating parameters and state of the
300 the IR receiver or transmitter. 342 the IR receiver or transmitter.
301 343
@@ -319,14 +361,9 @@ struct v4l2_subdev_sensor_ops {
319 */ 361 */
320 362
321enum v4l2_subdev_ir_mode { 363enum v4l2_subdev_ir_mode {
322 V4L2_SUBDEV_IR_MODE_PULSE_WIDTH, /* space & mark widths in nanosecs */ 364 V4L2_SUBDEV_IR_MODE_PULSE_WIDTH, /* uses struct ir_raw_event records */
323}; 365};
324 366
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
330struct v4l2_subdev_ir_parameters { 367struct v4l2_subdev_ir_parameters {
331 /* Either Rx or Tx */ 368 /* Either Rx or Tx */
332 unsigned int bytes_per_data_element; /* of data in read or write call */ 369 unsigned int bytes_per_data_element; /* of data in read or write call */
@@ -340,7 +377,10 @@ struct v4l2_subdev_ir_parameters {
340 u32 max_pulse_width; /* ns, valid only for baseband signal */ 377 u32 max_pulse_width; /* ns, valid only for baseband signal */
341 unsigned int carrier_freq; /* Hz, valid only for modulated signal*/ 378 unsigned int carrier_freq; /* Hz, valid only for modulated signal*/
342 unsigned int duty_cycle; /* percent, valid only for modulated signal*/ 379 unsigned int duty_cycle; /* percent, valid only for modulated signal*/
343 bool invert; /* logically invert sense of mark/space */ 380 bool invert_level; /* invert signal level */
381
382 /* Tx only */
383 bool invert_carrier_sense; /* Send 0/space as a carrier burst */
344 384
345 /* Rx only */ 385 /* Rx only */
346 u32 noise_filter_min_width; /* ns, min time of a valid pulse */ 386 u32 noise_filter_min_width; /* ns, min time of a valid pulse */
@@ -350,10 +390,6 @@ struct v4l2_subdev_ir_parameters {
350}; 390};
351 391
352struct v4l2_subdev_ir_ops { 392struct 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 */ 393 /* Receiver */
358 int (*rx_read)(struct v4l2_subdev *sd, u8 *buf, size_t count, 394 int (*rx_read)(struct v4l2_subdev *sd, u8 *buf, size_t count,
359 ssize_t *num); 395 ssize_t *num);
@@ -378,6 +414,7 @@ struct v4l2_subdev_ops {
378 const struct v4l2_subdev_tuner_ops *tuner; 414 const struct v4l2_subdev_tuner_ops *tuner;
379 const struct v4l2_subdev_audio_ops *audio; 415 const struct v4l2_subdev_audio_ops *audio;
380 const struct v4l2_subdev_video_ops *video; 416 const struct v4l2_subdev_video_ops *video;
417 const struct v4l2_subdev_vbi_ops *vbi;
381 const struct v4l2_subdev_ir_ops *ir; 418 const struct v4l2_subdev_ir_ops *ir;
382 const struct v4l2_subdev_sensor_ops *sensor; 419 const struct v4l2_subdev_sensor_ops *sensor;
383}; 420};
@@ -386,6 +423,8 @@ struct v4l2_subdev_ops {
386 423
387/* Set this flag if this subdev is a i2c device. */ 424/* Set this flag if this subdev is a i2c device. */
388#define V4L2_SUBDEV_FL_IS_I2C (1U << 0) 425#define V4L2_SUBDEV_FL_IS_I2C (1U << 0)
426/* Set this flag if this subdev is a spi device. */
427#define V4L2_SUBDEV_FL_IS_SPI (1U << 1)
389 428
390/* Each instance of a subdev driver should create this struct, either 429/* Each instance of a subdev driver should create this struct, either
391 stand-alone or embedded in a larger struct. 430 stand-alone or embedded in a larger struct.
@@ -396,6 +435,8 @@ struct v4l2_subdev {
396 u32 flags; 435 u32 flags;
397 struct v4l2_device *v4l2_dev; 436 struct v4l2_device *v4l2_dev;
398 const struct v4l2_subdev_ops *ops; 437 const struct v4l2_subdev_ops *ops;
438 /* The control handler of this subdev. May be NULL. */
439 struct v4l2_ctrl_handler *ctrl_handler;
399 /* name must be unique */ 440 /* name must be unique */
400 char name[V4L2_SUBDEV_NAME_SIZE]; 441 char name[V4L2_SUBDEV_NAME_SIZE];
401 /* can be used to group similar subdevs, value is driver-specific */ 442 /* can be used to group similar subdevs, value is driver-specific */