diff options
Diffstat (limited to 'include/media/v4l2-subdev.h')
-rw-r--r-- | include/media/v4l2-subdev.h | 126 |
1 files changed, 83 insertions, 43 deletions
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 2bcdca0a57fc..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 | ||
37 | struct v4l2_device; | 37 | struct v4l2_device; |
38 | struct v4l2_ctrl_handler; | ||
38 | struct v4l2_subdev; | 39 | struct v4l2_subdev; |
39 | struct tuner_setup; | 40 | struct 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 | |||
101 | struct 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 | */ |
114 | struct v4l2_subdev_core_ops { | 141 | struct 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. |
@@ -184,28 +215,6 @@ struct v4l2_subdev_audio_ops { | |||
184 | }; | 215 | }; |
185 | 216 | ||
186 | /* | 217 | /* |
187 | decode_vbi_line: video decoders that support sliced VBI need to implement | ||
188 | this ioctl. Field p of the v4l2_sliced_vbi_line struct is set to the | ||
189 | start of the VBI data that was generated by the decoder. The driver | ||
190 | then parses the sliced VBI data and sets the other fields in the | ||
191 | struct accordingly. The pointer p is updated to point to the start of | ||
192 | the payload which can be copied verbatim into the data field of the | ||
193 | v4l2_sliced_vbi_data struct. If no valid VBI data was found, then the | ||
194 | type field is set to 0 on return. | ||
195 | |||
196 | s_vbi_data: used to generate VBI signals on a video signal. | ||
197 | v4l2_sliced_vbi_data is filled with the data packets that should be | ||
198 | output. Note that if you set the line field to 0, then that VBI signal | ||
199 | is disabled. If no valid VBI data was found, then the type field is | ||
200 | set to 0 on return. | ||
201 | |||
202 | g_vbi_data: used to obtain the sliced VBI packet from a readback register. | ||
203 | Not all video decoders support this. If no data is available because | ||
204 | the readback register contains invalid or erroneous data -EIO is | ||
205 | returned. Note that you must fill in the 'id' member and the 'field' | ||
206 | member (to determine whether CC data from the first or second field | ||
207 | should be obtained). | ||
208 | |||
209 | 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 |
210 | video input devices. | 219 | video input devices. |
211 | 220 | ||
@@ -243,10 +252,6 @@ struct v4l2_subdev_audio_ops { | |||
243 | struct v4l2_subdev_video_ops { | 252 | struct v4l2_subdev_video_ops { |
244 | 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); |
245 | 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); |
246 | int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line); | ||
247 | int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data); | ||
248 | int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data); | ||
249 | int (*g_sliced_vbi_cap)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_cap *cap); | ||
250 | 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); |
251 | int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std); | 256 | int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std); |
252 | int (*g_input_status)(struct v4l2_subdev *sd, u32 *status); | 257 | int (*g_input_status)(struct v4l2_subdev *sd, u32 *status); |
@@ -262,6 +267,8 @@ struct v4l2_subdev_video_ops { | |||
262 | int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); | 267 | int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); |
263 | int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); | 268 | int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); |
264 | 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); | ||
265 | int (*s_dv_preset)(struct v4l2_subdev *sd, | 272 | int (*s_dv_preset)(struct v4l2_subdev *sd, |
266 | struct v4l2_dv_preset *preset); | 273 | struct v4l2_dv_preset *preset); |
267 | int (*query_dv_preset)(struct v4l2_subdev *sd, | 274 | int (*query_dv_preset)(struct v4l2_subdev *sd, |
@@ -270,7 +277,7 @@ struct v4l2_subdev_video_ops { | |||
270 | struct v4l2_dv_timings *timings); | 277 | struct v4l2_dv_timings *timings); |
271 | int (*g_dv_timings)(struct v4l2_subdev *sd, | 278 | int (*g_dv_timings)(struct v4l2_subdev *sd, |
272 | struct v4l2_dv_timings *timings); | 279 | struct v4l2_dv_timings *timings); |
273 | int (*enum_mbus_fmt)(struct v4l2_subdev *sd, int index, | 280 | int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, |
274 | enum v4l2_mbus_pixelcode *code); | 281 | enum v4l2_mbus_pixelcode *code); |
275 | int (*g_mbus_fmt)(struct v4l2_subdev *sd, | 282 | int (*g_mbus_fmt)(struct v4l2_subdev *sd, |
276 | struct v4l2_mbus_framefmt *fmt); | 283 | struct v4l2_mbus_framefmt *fmt); |
@@ -280,6 +287,45 @@ struct v4l2_subdev_video_ops { | |||
280 | struct v4l2_mbus_framefmt *fmt); | 287 | struct v4l2_mbus_framefmt *fmt); |
281 | }; | 288 | }; |
282 | 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 | */ | ||
319 | struct 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 | |||
283 | /** | 329 | /** |
284 | * struct v4l2_subdev_sensor_ops - v4l2-subdev sensor operations | 330 | * struct v4l2_subdev_sensor_ops - v4l2-subdev sensor operations |
285 | * @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. |
@@ -292,11 +338,6 @@ struct v4l2_subdev_sensor_ops { | |||
292 | }; | 338 | }; |
293 | 339 | ||
294 | /* | 340 | /* |
295 | interrupt_service_routine: Called by the bridge chip's interrupt service | ||
296 | handler, when an IR interrupt status has be raised due to this subdev, | ||
297 | so that this subdev can handle the details. It may schedule work to be | ||
298 | performed later. It must not sleep. *Called from an IRQ context*. | ||
299 | |||
300 | [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 |
301 | the IR receiver or transmitter. | 342 | the IR receiver or transmitter. |
302 | 343 | ||
@@ -320,14 +361,9 @@ struct v4l2_subdev_sensor_ops { | |||
320 | */ | 361 | */ |
321 | 362 | ||
322 | enum v4l2_subdev_ir_mode { | 363 | enum v4l2_subdev_ir_mode { |
323 | V4L2_SUBDEV_IR_MODE_PULSE_WIDTH, /* space & mark widths in nanosecs */ | 364 | V4L2_SUBDEV_IR_MODE_PULSE_WIDTH, /* uses struct ir_raw_event records */ |
324 | }; | 365 | }; |
325 | 366 | ||
326 | /* Data format of data read or written for V4L2_SUBDEV_IR_MODE_PULSE_WIDTH */ | ||
327 | #define V4L2_SUBDEV_IR_PULSE_MAX_WIDTH_NS 0x7fffffff | ||
328 | #define V4L2_SUBDEV_IR_PULSE_LEVEL_MASK 0x80000000 | ||
329 | #define V4L2_SUBDEV_IR_PULSE_RX_SEQ_END 0xffffffff | ||
330 | |||
331 | struct v4l2_subdev_ir_parameters { | 367 | struct v4l2_subdev_ir_parameters { |
332 | /* Either Rx or Tx */ | 368 | /* Either Rx or Tx */ |
333 | 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 */ |
@@ -341,7 +377,10 @@ struct v4l2_subdev_ir_parameters { | |||
341 | u32 max_pulse_width; /* ns, valid only for baseband signal */ | 377 | u32 max_pulse_width; /* ns, valid only for baseband signal */ |
342 | unsigned int carrier_freq; /* Hz, valid only for modulated signal*/ | 378 | unsigned int carrier_freq; /* Hz, valid only for modulated signal*/ |
343 | unsigned int duty_cycle; /* percent, valid only for modulated signal*/ | 379 | unsigned int duty_cycle; /* percent, valid only for modulated signal*/ |
344 | 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 */ | ||
345 | 384 | ||
346 | /* Rx only */ | 385 | /* Rx only */ |
347 | 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 */ |
@@ -351,10 +390,6 @@ struct v4l2_subdev_ir_parameters { | |||
351 | }; | 390 | }; |
352 | 391 | ||
353 | struct v4l2_subdev_ir_ops { | 392 | struct v4l2_subdev_ir_ops { |
354 | /* Common to receiver and transmitter */ | ||
355 | int (*interrupt_service_routine)(struct v4l2_subdev *sd, | ||
356 | u32 status, bool *handled); | ||
357 | |||
358 | /* Receiver */ | 393 | /* Receiver */ |
359 | 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, |
360 | ssize_t *num); | 395 | ssize_t *num); |
@@ -379,6 +414,7 @@ struct v4l2_subdev_ops { | |||
379 | const struct v4l2_subdev_tuner_ops *tuner; | 414 | const struct v4l2_subdev_tuner_ops *tuner; |
380 | const struct v4l2_subdev_audio_ops *audio; | 415 | const struct v4l2_subdev_audio_ops *audio; |
381 | const struct v4l2_subdev_video_ops *video; | 416 | const struct v4l2_subdev_video_ops *video; |
417 | const struct v4l2_subdev_vbi_ops *vbi; | ||
382 | const struct v4l2_subdev_ir_ops *ir; | 418 | const struct v4l2_subdev_ir_ops *ir; |
383 | const struct v4l2_subdev_sensor_ops *sensor; | 419 | const struct v4l2_subdev_sensor_ops *sensor; |
384 | }; | 420 | }; |
@@ -387,6 +423,8 @@ struct v4l2_subdev_ops { | |||
387 | 423 | ||
388 | /* Set this flag if this subdev is a i2c device. */ | 424 | /* Set this flag if this subdev is a i2c device. */ |
389 | #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) | ||
390 | 428 | ||
391 | /* Each instance of a subdev driver should create this struct, either | 429 | /* Each instance of a subdev driver should create this struct, either |
392 | stand-alone or embedded in a larger struct. | 430 | stand-alone or embedded in a larger struct. |
@@ -397,6 +435,8 @@ struct v4l2_subdev { | |||
397 | u32 flags; | 435 | u32 flags; |
398 | struct v4l2_device *v4l2_dev; | 436 | struct v4l2_device *v4l2_dev; |
399 | 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; | ||
400 | /* name must be unique */ | 440 | /* name must be unique */ |
401 | char name[V4L2_SUBDEV_NAME_SIZE]; | 441 | char name[V4L2_SUBDEV_NAME_SIZE]; |
402 | /* can be used to group similar subdevs, value is driver-specific */ | 442 | /* can be used to group similar subdevs, value is driver-specific */ |