v4l2-subdev.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  1. /*
  2. * V4L2 sub-device support header.
  3. *
  4. * Copyright (C) 2008 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. #ifndef _V4L2_SUBDEV_H
  17. #define _V4L2_SUBDEV_H
  18. #include <linux/types.h>
  19. #include <linux/v4l2-subdev.h>
  20. #include <media/media-entity.h>
  21. #include <media/v4l2-async.h>
  22. #include <media/v4l2-common.h>
  23. #include <media/v4l2-dev.h>
  24. #include <media/v4l2-fh.h>
  25. #include <media/v4l2-mediabus.h>
  26. /* generic v4l2_device notify callback notification values */
  27. #define V4L2_SUBDEV_IR_RX_NOTIFY _IOW('v', 0, u32)
  28. #define V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ 0x00000001
  29. #define V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED 0x00000002
  30. #define V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN 0x00000004
  31. #define V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN 0x00000008
  32. #define V4L2_SUBDEV_IR_TX_NOTIFY _IOW('v', 1, u32)
  33. #define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ 0x00000001
  34. #define V4L2_DEVICE_NOTIFY_EVENT _IOW('v', 2, struct v4l2_event)
  35. struct v4l2_device;
  36. struct v4l2_ctrl_handler;
  37. struct v4l2_event;
  38. struct v4l2_event_subscription;
  39. struct v4l2_fh;
  40. struct v4l2_subdev;
  41. struct v4l2_subdev_fh;
  42. struct tuner_setup;
  43. struct v4l2_mbus_frame_desc;
  44. /**
  45. * struct v4l2_decode_vbi_line - used to decode_vbi_line
  46. *
  47. * @is_second_field: Set to 0 for the first (odd) field;
  48. * set to 1 for the second (even) field.
  49. * @p: Pointer to the sliced VBI data from the decoder. On exit, points to
  50. * the start of the payload.
  51. * @line: Line number of the sliced VBI data (1-23)
  52. * @type: VBI service type (V4L2_SLICED_*). 0 if no service found
  53. */
  54. struct v4l2_decode_vbi_line {
  55. u32 is_second_field;
  56. u8 *p;
  57. u32 line;
  58. u32 type;
  59. };
  60. /*
  61. * Sub-devices are devices that are connected somehow to the main bridge
  62. * device. These devices are usually audio/video muxers/encoders/decoders or
  63. * sensors and webcam controllers.
  64. *
  65. * Usually these devices are controlled through an i2c bus, but other busses
  66. * may also be used.
  67. *
  68. * The v4l2_subdev struct provides a way of accessing these devices in a
  69. * generic manner. Most operations that these sub-devices support fall in
  70. * a few categories: core ops, audio ops, video ops and tuner ops.
  71. *
  72. * More categories can be added if needed, although this should remain a
  73. * limited set (no more than approx. 8 categories).
  74. *
  75. * Each category has its own set of ops that subdev drivers can implement.
  76. *
  77. * A subdev driver can leave the pointer to the category ops NULL if
  78. * it does not implement them (e.g. an audio subdev will generally not
  79. * implement the video category ops). The exception is the core category:
  80. * this must always be present.
  81. *
  82. * These ops are all used internally so it is no problem to change, remove
  83. * or add ops or move ops from one to another category. Currently these
  84. * ops are based on the original ioctls, but since ops are not limited to
  85. * one argument there is room for improvement here once all i2c subdev
  86. * drivers are converted to use these ops.
  87. */
  88. /*
  89. * Core ops: it is highly recommended to implement at least these ops:
  90. *
  91. * log_status
  92. * g_register
  93. * s_register
  94. *
  95. * This provides basic debugging support.
  96. *
  97. * The ioctl ops is meant for generic ioctl-like commands. Depending on
  98. * the use-case it might be better to use subdev-specific ops (currently
  99. * not yet implemented) since ops provide proper type-checking.
  100. */
  101. /* Subdevice external IO pin configuration */
  102. #define V4L2_SUBDEV_IO_PIN_DISABLE (1 << 0) /* ENABLE assumed */
  103. #define V4L2_SUBDEV_IO_PIN_OUTPUT (1 << 1)
  104. #define V4L2_SUBDEV_IO_PIN_INPUT (1 << 2)
  105. #define V4L2_SUBDEV_IO_PIN_SET_VALUE (1 << 3) /* Set output value */
  106. #define V4L2_SUBDEV_IO_PIN_ACTIVE_LOW (1 << 4) /* ACTIVE HIGH assumed */
  107. /**
  108. * struct v4l2_subdev_io_pin_config - Subdevice external IO pin configuration
  109. *
  110. * @flags: bitmask with flags for this pin's config:
  111. * %V4L2_SUBDEV_IO_PIN_DISABLE - disables a pin config,
  112. * %V4L2_SUBDEV_IO_PIN_OUTPUT - if pin is an output,
  113. * %V4L2_SUBDEV_IO_PIN_INPUT - if pin is an input,
  114. * %V4L2_SUBDEV_IO_PIN_SET_VALUE - to set the output value via @value
  115. * and %V4L2_SUBDEV_IO_PIN_ACTIVE_LOW - if active is 0.
  116. * @pin: Chip external IO pin to configure
  117. * @function: Internal signal pad/function to route to IO pin
  118. * @value: Initial value for pin - e.g. GPIO output value
  119. * @strength: Pin drive strength
  120. */
  121. struct v4l2_subdev_io_pin_config {
  122. u32 flags;
  123. u8 pin;
  124. u8 function;
  125. u8 value;
  126. u8 strength;
  127. };
  128. /**
  129. * struct v4l2_subdev_core_ops - Define core ops callbacks for subdevs
  130. *
  131. * @log_status: callback for %VIDIOC_LOG_STATUS ioctl handler code.
  132. *
  133. * @s_io_pin_config: configure one or more chip I/O pins for chips that
  134. * multiplex different internal signal pads out to IO pins. This function
  135. * takes a pointer to an array of 'n' pin configuration entries, one for
  136. * each pin being configured. This function could be called at times
  137. * other than just subdevice initialization.
  138. *
  139. * @init: initialize the sensor registers to some sort of reasonable default
  140. * values. Do not use for new drivers and should be removed in existing
  141. * drivers.
  142. *
  143. * @load_fw: load firmware.
  144. *
  145. * @reset: generic reset command. The argument selects which subsystems to
  146. * reset. Passing 0 will always reset the whole chip. Do not use for new
  147. * drivers without discussing this first on the linux-media mailinglist.
  148. * There should be no reason normally to reset a device.
  149. *
  150. * @s_gpio: set GPIO pins. Very simple right now, might need to be extended with
  151. * a direction argument if needed.
  152. *
  153. * @ioctl: called at the end of ioctl() syscall handler at the V4L2 core.
  154. * used to provide support for private ioctls used on the driver.
  155. *
  156. * @compat_ioctl32: called when a 32 bits application uses a 64 bits Kernel,
  157. * in order to fix data passed from/to userspace.
  158. *
  159. * @g_register: callback for %VIDIOC_G_REGISTER ioctl handler code.
  160. *
  161. * @s_register: callback for %VIDIOC_G_REGISTER ioctl handler code.
  162. *
  163. * @s_power: puts subdevice in power saving mode (on == 0) or normal operation
  164. * mode (on == 1).
  165. *
  166. * @interrupt_service_routine: Called by the bridge chip's interrupt service
  167. * handler, when an interrupt status has be raised due to this subdev,
  168. * so that this subdev can handle the details. It may schedule work to be
  169. * performed later. It must not sleep. **Called from an IRQ context**.
  170. *
  171. * @subscribe_event: used by the drivers to request the control framework that
  172. * for it to be warned when the value of a control changes.
  173. *
  174. * @unsubscribe_event: remove event subscription from the control framework.
  175. */
  176. struct v4l2_subdev_core_ops {
  177. int (*log_status)(struct v4l2_subdev *sd);
  178. int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n,
  179. struct v4l2_subdev_io_pin_config *pincfg);
  180. int (*init)(struct v4l2_subdev *sd, u32 val);
  181. int (*load_fw)(struct v4l2_subdev *sd);
  182. int (*reset)(struct v4l2_subdev *sd, u32 val);
  183. int (*s_gpio)(struct v4l2_subdev *sd, u32 val);
  184. long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
  185. #ifdef CONFIG_COMPAT
  186. long (*compat_ioctl32)(struct v4l2_subdev *sd, unsigned int cmd,
  187. unsigned long arg);
  188. #endif
  189. #ifdef CONFIG_VIDEO_ADV_DEBUG
  190. int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
  191. int (*s_register)(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg);
  192. #endif
  193. int (*s_power)(struct v4l2_subdev *sd, int on);
  194. int (*interrupt_service_routine)(struct v4l2_subdev *sd,
  195. u32 status, bool *handled);
  196. int (*subscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
  197. struct v4l2_event_subscription *sub);
  198. int (*unsubscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
  199. struct v4l2_event_subscription *sub);
  200. };
  201. /**
  202. * struct v4l2_subdev_tuner_ops - Callbacks used when v4l device was opened
  203. * in radio mode.
  204. *
  205. * @s_radio: callback for %VIDIOC_S_RADIO ioctl handler code.
  206. *
  207. * @s_frequency: callback for %VIDIOC_S_FREQUENCY ioctl handler code.
  208. *
  209. * @g_frequency: callback for %VIDIOC_G_FREQUENCY ioctl handler code.
  210. * freq->type must be filled in. Normally done by video_ioctl2()
  211. * or the bridge driver.
  212. *
  213. * @enum_freq_bands: callback for %VIDIOC_ENUM_FREQ_BANDS ioctl handler code.
  214. *
  215. * @g_tuner: callback for %VIDIOC_G_TUNER ioctl handler code.
  216. *
  217. * @s_tuner: callback for %VIDIOC_S_TUNER ioctl handler code. @vt->type must be
  218. * filled in. Normally done by video_ioctl2 or the
  219. * bridge driver.
  220. *
  221. * @g_modulator: callback for %VIDIOC_G_MODULATOR ioctl handler code.
  222. *
  223. * @s_modulator: callback for %VIDIOC_S_MODULATOR ioctl handler code.
  224. *
  225. * @s_type_addr: sets tuner type and its I2C addr.
  226. *
  227. * @s_config: sets tda9887 specific stuff, like port1, port2 and qss
  228. */
  229. struct v4l2_subdev_tuner_ops {
  230. int (*s_radio)(struct v4l2_subdev *sd);
  231. int (*s_frequency)(struct v4l2_subdev *sd, const struct v4l2_frequency *freq);
  232. int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
  233. int (*enum_freq_bands)(struct v4l2_subdev *sd, struct v4l2_frequency_band *band);
  234. int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
  235. int (*s_tuner)(struct v4l2_subdev *sd, const struct v4l2_tuner *vt);
  236. int (*g_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
  237. int (*s_modulator)(struct v4l2_subdev *sd, const struct v4l2_modulator *vm);
  238. int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type);
  239. int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
  240. };
  241. /**
  242. * struct v4l2_subdev_audio_ops - Callbacks used for audio-related settings
  243. *
  244. * @s_clock_freq: set the frequency (in Hz) of the audio clock output.
  245. * Used to slave an audio processor to the video decoder, ensuring that
  246. * audio and video remain synchronized. Usual values for the frequency
  247. * are 48000, 44100 or 32000 Hz. If the frequency is not supported, then
  248. * -EINVAL is returned.
  249. *
  250. * @s_i2s_clock_freq: sets I2S speed in bps. This is used to provide a standard
  251. * way to select I2S clock used by driving digital audio streams at some
  252. * board designs. Usual values for the frequency are 1024000 and 2048000.
  253. * If the frequency is not supported, then %-EINVAL is returned.
  254. *
  255. * @s_routing: used to define the input and/or output pins of an audio chip,
  256. * and any additional configuration data.
  257. * Never attempt to use user-level input IDs (e.g. Composite, S-Video,
  258. * Tuner) at this level. An i2c device shouldn't know about whether an
  259. * input pin is connected to a Composite connector, become on another
  260. * board or platform it might be connected to something else entirely.
  261. * The calling driver is responsible for mapping a user-level input to
  262. * the right pins on the i2c device.
  263. *
  264. * @s_stream: used to notify the audio code that stream will start or has
  265. * stopped.
  266. */
  267. struct v4l2_subdev_audio_ops {
  268. int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
  269. int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
  270. int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
  271. int (*s_stream)(struct v4l2_subdev *sd, int enable);
  272. };
  273. /* Indicates the @length field specifies maximum data length. */
  274. #define V4L2_MBUS_FRAME_DESC_FL_LEN_MAX (1U << 0)
  275. /*
  276. * Indicates that the format does not have line offsets, i.e. the
  277. * receiver should use 1D DMA.
  278. */
  279. #define V4L2_MBUS_FRAME_DESC_FL_BLOB (1U << 1)
  280. /**
  281. * struct v4l2_mbus_frame_desc_entry - media bus frame description structure
  282. *
  283. * @flags: bitmask flags: %V4L2_MBUS_FRAME_DESC_FL_LEN_MAX and
  284. * %V4L2_MBUS_FRAME_DESC_FL_BLOB.
  285. * @pixelcode: media bus pixel code, valid if FRAME_DESC_FL_BLOB is not set
  286. * @length: number of octets per frame, valid if V4L2_MBUS_FRAME_DESC_FL_BLOB
  287. * is set
  288. */
  289. struct v4l2_mbus_frame_desc_entry {
  290. u16 flags;
  291. u32 pixelcode;
  292. u32 length;
  293. };
  294. #define V4L2_FRAME_DESC_ENTRY_MAX 4
  295. /**
  296. * struct v4l2_mbus_frame_desc - media bus data frame description
  297. * @entry: frame descriptors array
  298. * @num_entries: number of entries in @entry array
  299. */
  300. struct v4l2_mbus_frame_desc {
  301. struct v4l2_mbus_frame_desc_entry entry[V4L2_FRAME_DESC_ENTRY_MAX];
  302. unsigned short num_entries;
  303. };
  304. /**
  305. * struct v4l2_subdev_video_ops - Callbacks used when v4l device was opened
  306. * in video mode.
  307. *
  308. * @s_routing: see s_routing in audio_ops, except this version is for video
  309. * devices.
  310. *
  311. * @s_crystal_freq: sets the frequency of the crystal used to generate the
  312. * clocks in Hz. An extra flags field allows device specific configuration
  313. * regarding clock frequency dividers, etc. If not used, then set flags
  314. * to 0. If the frequency is not supported, then -EINVAL is returned.
  315. *
  316. * @g_std: callback for %VIDIOC_G_STD ioctl handler code.
  317. *
  318. * @s_std: callback for %VIDIOC_S_STD ioctl handler code.
  319. *
  320. * @s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
  321. * video input devices.
  322. *
  323. * @g_std_output: get current standard for video OUTPUT devices. This is ignored
  324. * by video input devices.
  325. *
  326. * @querystd: callback for %VIDIOC_QUERYSTD ioctl handler code.
  327. *
  328. * @g_tvnorms: get &v4l2_std_id with all standards supported by the video
  329. * CAPTURE device. This is ignored by video output devices.
  330. *
  331. * @g_tvnorms_output: get v4l2_std_id with all standards supported by the video
  332. * OUTPUT device. This is ignored by video capture devices.
  333. *
  334. * @g_input_status: get input status. Same as the status field in the
  335. * &struct &v4l2_input
  336. *
  337. * @s_stream: used to notify the driver that a video stream will start or has
  338. * stopped.
  339. *
  340. * @g_pixelaspect: callback to return the pixelaspect ratio.
  341. *
  342. * @g_parm: callback for %VIDIOC_G_PARM ioctl handler code.
  343. *
  344. * @s_parm: callback for %VIDIOC_S_PARM ioctl handler code.
  345. *
  346. * @g_frame_interval: callback for %VIDIOC_G_FRAMEINTERVAL ioctl handler code.
  347. *
  348. * @s_frame_interval: callback for %VIDIOC_S_FRAMEINTERVAL ioctl handler code.
  349. *
  350. * @s_dv_timings: Set custom dv timings in the sub device. This is used
  351. * when sub device is capable of setting detailed timing information
  352. * in the hardware to generate/detect the video signal.
  353. *
  354. * @g_dv_timings: Get custom dv timings in the sub device.
  355. *
  356. * @query_dv_timings: callback for %VIDIOC_QUERY_DV_TIMINGS ioctl handler code.
  357. *
  358. * @g_mbus_config: get supported mediabus configurations
  359. *
  360. * @s_mbus_config: set a certain mediabus configuration. This operation is added
  361. * for compatibility with soc-camera drivers and should not be used by new
  362. * software.
  363. *
  364. * @s_rx_buffer: set a host allocated memory buffer for the subdev. The subdev
  365. * can adjust @size to a lower value and must not write more data to the
  366. * buffer starting at @data than the original value of @size.
  367. */
  368. struct v4l2_subdev_video_ops {
  369. int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
  370. int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags);
  371. int (*g_std)(struct v4l2_subdev *sd, v4l2_std_id *norm);
  372. int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);
  373. int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
  374. int (*g_std_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
  375. int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
  376. int (*g_tvnorms)(struct v4l2_subdev *sd, v4l2_std_id *std);
  377. int (*g_tvnorms_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
  378. int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
  379. int (*s_stream)(struct v4l2_subdev *sd, int enable);
  380. int (*g_pixelaspect)(struct v4l2_subdev *sd, struct v4l2_fract *aspect);
  381. int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
  382. int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
  383. int (*g_frame_interval)(struct v4l2_subdev *sd,
  384. struct v4l2_subdev_frame_interval *interval);
  385. int (*s_frame_interval)(struct v4l2_subdev *sd,
  386. struct v4l2_subdev_frame_interval *interval);
  387. int (*s_dv_timings)(struct v4l2_subdev *sd,
  388. struct v4l2_dv_timings *timings);
  389. int (*g_dv_timings)(struct v4l2_subdev *sd,
  390. struct v4l2_dv_timings *timings);
  391. int (*query_dv_timings)(struct v4l2_subdev *sd,
  392. struct v4l2_dv_timings *timings);
  393. int (*g_mbus_config)(struct v4l2_subdev *sd,
  394. struct v4l2_mbus_config *cfg);
  395. int (*s_mbus_config)(struct v4l2_subdev *sd,
  396. const struct v4l2_mbus_config *cfg);
  397. int (*s_rx_buffer)(struct v4l2_subdev *sd, void *buf,
  398. unsigned int *size);
  399. };
  400. /**
  401. * struct v4l2_subdev_vbi_ops - Callbacks used when v4l device was opened
  402. * in video mode via the vbi device node.
  403. *
  404. * @decode_vbi_line: video decoders that support sliced VBI need to implement
  405. * this ioctl. Field p of the &struct v4l2_decode_vbi_line is set to the
  406. * start of the VBI data that was generated by the decoder. The driver
  407. * then parses the sliced VBI data and sets the other fields in the
  408. * struct accordingly. The pointer p is updated to point to the start of
  409. * the payload which can be copied verbatim into the data field of the
  410. * &struct v4l2_sliced_vbi_data. If no valid VBI data was found, then the
  411. * type field is set to 0 on return.
  412. *
  413. * @s_vbi_data: used to generate VBI signals on a video signal.
  414. * &struct v4l2_sliced_vbi_data is filled with the data packets that
  415. * should be output. Note that if you set the line field to 0, then that
  416. * VBI signal is disabled. If no valid VBI data was found, then the type
  417. * field is set to 0 on return.
  418. *
  419. * @g_vbi_data: used to obtain the sliced VBI packet from a readback register.
  420. * Not all video decoders support this. If no data is available because
  421. * the readback register contains invalid or erroneous data %-EIO is
  422. * returned. Note that you must fill in the 'id' member and the 'field'
  423. * member (to determine whether CC data from the first or second field
  424. * should be obtained).
  425. *
  426. * @g_sliced_vbi_cap: callback for %VIDIOC_SLICED_VBI_CAP ioctl handler code.
  427. *
  428. * @s_raw_fmt: setup the video encoder/decoder for raw VBI.
  429. *
  430. * @g_sliced_fmt: retrieve the current sliced VBI settings.
  431. *
  432. * @s_sliced_fmt: setup the sliced VBI settings.
  433. */
  434. struct v4l2_subdev_vbi_ops {
  435. int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line);
  436. int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data);
  437. int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data);
  438. int (*g_sliced_vbi_cap)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_cap *cap);
  439. int (*s_raw_fmt)(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt);
  440. int (*g_sliced_fmt)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
  441. int (*s_sliced_fmt)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
  442. };
  443. /**
  444. * struct v4l2_subdev_sensor_ops - v4l2-subdev sensor operations
  445. * @g_skip_top_lines: number of lines at the top of the image to be skipped.
  446. * This is needed for some sensors, which always corrupt
  447. * several top lines of the output image, or which send their
  448. * metadata in them.
  449. * @g_skip_frames: number of frames to skip at stream start. This is needed for
  450. * buggy sensors that generate faulty frames when they are
  451. * turned on.
  452. */
  453. struct v4l2_subdev_sensor_ops {
  454. int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
  455. int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);
  456. };
  457. /**
  458. * enum v4l2_subdev_ir_mode- describes the type of IR supported
  459. *
  460. * @V4L2_SUBDEV_IR_MODE_PULSE_WIDTH: IR uses struct ir_raw_event records
  461. */
  462. enum v4l2_subdev_ir_mode {
  463. V4L2_SUBDEV_IR_MODE_PULSE_WIDTH,
  464. };
  465. /**
  466. * struct v4l2_subdev_ir_parameters - Parameters for IR TX or TX
  467. *
  468. * @bytes_per_data_element: bytes per data element of data in read or
  469. * write call.
  470. * @mode: IR mode as defined by &enum v4l2_subdev_ir_mode.
  471. * @enable: device is active if true
  472. * @interrupt_enable: IR interrupts are enabled if true
  473. * @shutdown: if true: set hardware to low/no power, false: normal mode
  474. *
  475. * @modulation: if true, it uses carrier, if false: baseband
  476. * @max_pulse_width: maximum pulse width in ns, valid only for baseband signal
  477. * @carrier_freq: carrier frequency in Hz, valid only for modulated signal
  478. * @duty_cycle: duty cycle percentage, valid only for modulated signal
  479. * @invert_level: invert signal level
  480. *
  481. * @invert_carrier_sense: Send 0/space as a carrier burst. used only in TX.
  482. *
  483. * @noise_filter_min_width: min time of a valid pulse, in ns. Used only for RX.
  484. * @carrier_range_lower: Lower carrier range, in Hz, valid only for modulated
  485. * signal. Used only for RX.
  486. * @carrier_range_upper: Upper carrier range, in Hz, valid only for modulated
  487. * signal. Used only for RX.
  488. * @resolution: The receive resolution, in ns . Used only for RX.
  489. */
  490. struct v4l2_subdev_ir_parameters {
  491. unsigned int bytes_per_data_element;
  492. enum v4l2_subdev_ir_mode mode;
  493. bool enable;
  494. bool interrupt_enable;
  495. bool shutdown;
  496. bool modulation;
  497. u32 max_pulse_width;
  498. unsigned int carrier_freq;
  499. unsigned int duty_cycle;
  500. bool invert_level;
  501. /* Tx only */
  502. bool invert_carrier_sense;
  503. /* Rx only */
  504. u32 noise_filter_min_width;
  505. unsigned int carrier_range_lower;
  506. unsigned int carrier_range_upper;
  507. u32 resolution;
  508. };
  509. /**
  510. * struct v4l2_subdev_ir_ops - operations for IR subdevices
  511. *
  512. * @rx_read: Reads received codes or pulse width data.
  513. * The semantics are similar to a non-blocking read() call.
  514. * @rx_g_parameters: Get the current operating parameters and state of the
  515. * the IR receiver.
  516. * @rx_s_parameters: Set the current operating parameters and state of the
  517. * the IR receiver. It is recommended to call
  518. * [rt]x_g_parameters first to fill out the current state, and only change
  519. * the fields that need to be changed. Upon return, the actual device
  520. * operating parameters and state will be returned. Note that hardware
  521. * limitations may prevent the actual settings from matching the requested
  522. * settings - e.g. an actual carrier setting of 35,904 Hz when 36,000 Hz
  523. * was requested. An exception is when the shutdown parameter is true.
  524. * The last used operational parameters will be returned, but the actual
  525. * state of the hardware be different to minimize power consumption and
  526. * processing when shutdown is true.
  527. *
  528. * @tx_write: Writes codes or pulse width data for transmission.
  529. * The semantics are similar to a non-blocking write() call.
  530. * @tx_g_parameters: Get the current operating parameters and state of the
  531. * the IR transmitter.
  532. * @tx_s_parameters: Set the current operating parameters and state of the
  533. * the IR transmitter. It is recommended to call
  534. * [rt]x_g_parameters first to fill out the current state, and only change
  535. * the fields that need to be changed. Upon return, the actual device
  536. * operating parameters and state will be returned. Note that hardware
  537. * limitations may prevent the actual settings from matching the requested
  538. * settings - e.g. an actual carrier setting of 35,904 Hz when 36,000 Hz
  539. * was requested. An exception is when the shutdown parameter is true.
  540. * The last used operational parameters will be returned, but the actual
  541. * state of the hardware be different to minimize power consumption and
  542. * processing when shutdown is true.
  543. */
  544. struct v4l2_subdev_ir_ops {
  545. /* Receiver */
  546. int (*rx_read)(struct v4l2_subdev *sd, u8 *buf, size_t count,
  547. ssize_t *num);
  548. int (*rx_g_parameters)(struct v4l2_subdev *sd,
  549. struct v4l2_subdev_ir_parameters *params);
  550. int (*rx_s_parameters)(struct v4l2_subdev *sd,
  551. struct v4l2_subdev_ir_parameters *params);
  552. /* Transmitter */
  553. int (*tx_write)(struct v4l2_subdev *sd, u8 *buf, size_t count,
  554. ssize_t *num);
  555. int (*tx_g_parameters)(struct v4l2_subdev *sd,
  556. struct v4l2_subdev_ir_parameters *params);
  557. int (*tx_s_parameters)(struct v4l2_subdev *sd,
  558. struct v4l2_subdev_ir_parameters *params);
  559. };
  560. /**
  561. * struct v4l2_subdev_pad_config - Used for storing subdev pad information.
  562. *
  563. * @try_fmt: pointer to &struct v4l2_mbus_framefmt
  564. * @try_crop: pointer to &struct v4l2_rect to be used for crop
  565. * @try_compose: pointer to &struct v4l2_rect to be used for compose
  566. *
  567. * This structure only needs to be passed to the pad op if the 'which' field
  568. * of the main argument is set to %V4L2_SUBDEV_FORMAT_TRY. For
  569. * %V4L2_SUBDEV_FORMAT_ACTIVE it is safe to pass %NULL.
  570. */
  571. struct v4l2_subdev_pad_config {
  572. struct v4l2_mbus_framefmt try_fmt;
  573. struct v4l2_rect try_crop;
  574. struct v4l2_rect try_compose;
  575. };
  576. /**
  577. * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
  578. *
  579. * @init_cfg: initialize the pad config to default values
  580. * @enum_mbus_code: callback for %VIDIOC_SUBDEV_ENUM_MBUS_CODE ioctl handler
  581. * code.
  582. * @enum_frame_size: callback for %VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl handler
  583. * code.
  584. *
  585. * @enum_frame_interval: callback for %VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL ioctl
  586. * handler code.
  587. *
  588. * @get_fmt: callback for %VIDIOC_SUBDEV_G_FMT ioctl handler code.
  589. *
  590. * @set_fmt: callback for %VIDIOC_SUBDEV_S_FMT ioctl handler code.
  591. *
  592. * @get_selection: callback for %VIDIOC_SUBDEV_G_SELECTION ioctl handler code.
  593. *
  594. * @set_selection: callback for %VIDIOC_SUBDEV_S_SELECTION ioctl handler code.
  595. *
  596. * @get_edid: callback for %VIDIOC_SUBDEV_G_EDID ioctl handler code.
  597. *
  598. * @set_edid: callback for %VIDIOC_SUBDEV_S_EDID ioctl handler code.
  599. *
  600. * @dv_timings_cap: callback for %VIDIOC_SUBDEV_DV_TIMINGS_CAP ioctl handler
  601. * code.
  602. *
  603. * @enum_dv_timings: callback for %VIDIOC_SUBDEV_ENUM_DV_TIMINGS ioctl handler
  604. * code.
  605. *
  606. * @link_validate: used by the media controller code to check if the links
  607. * that belongs to a pipeline can be used for stream.
  608. *
  609. * @get_frame_desc: get the current low level media bus frame parameters.
  610. *
  611. * @set_frame_desc: set the low level media bus frame parameters, @fd array
  612. * may be adjusted by the subdev driver to device capabilities.
  613. */
  614. struct v4l2_subdev_pad_ops {
  615. int (*init_cfg)(struct v4l2_subdev *sd,
  616. struct v4l2_subdev_pad_config *cfg);
  617. int (*enum_mbus_code)(struct v4l2_subdev *sd,
  618. struct v4l2_subdev_pad_config *cfg,
  619. struct v4l2_subdev_mbus_code_enum *code);
  620. int (*enum_frame_size)(struct v4l2_subdev *sd,
  621. struct v4l2_subdev_pad_config *cfg,
  622. struct v4l2_subdev_frame_size_enum *fse);
  623. int (*enum_frame_interval)(struct v4l2_subdev *sd,
  624. struct v4l2_subdev_pad_config *cfg,
  625. struct v4l2_subdev_frame_interval_enum *fie);
  626. int (*get_fmt)(struct v4l2_subdev *sd,
  627. struct v4l2_subdev_pad_config *cfg,
  628. struct v4l2_subdev_format *format);
  629. int (*set_fmt)(struct v4l2_subdev *sd,
  630. struct v4l2_subdev_pad_config *cfg,
  631. struct v4l2_subdev_format *format);
  632. int (*get_selection)(struct v4l2_subdev *sd,
  633. struct v4l2_subdev_pad_config *cfg,
  634. struct v4l2_subdev_selection *sel);
  635. int (*set_selection)(struct v4l2_subdev *sd,
  636. struct v4l2_subdev_pad_config *cfg,
  637. struct v4l2_subdev_selection *sel);
  638. int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
  639. int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
  640. int (*dv_timings_cap)(struct v4l2_subdev *sd,
  641. struct v4l2_dv_timings_cap *cap);
  642. int (*enum_dv_timings)(struct v4l2_subdev *sd,
  643. struct v4l2_enum_dv_timings *timings);
  644. #ifdef CONFIG_MEDIA_CONTROLLER
  645. int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link,
  646. struct v4l2_subdev_format *source_fmt,
  647. struct v4l2_subdev_format *sink_fmt);
  648. #endif /* CONFIG_MEDIA_CONTROLLER */
  649. int (*get_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
  650. struct v4l2_mbus_frame_desc *fd);
  651. int (*set_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
  652. struct v4l2_mbus_frame_desc *fd);
  653. };
  654. /**
  655. * struct v4l2_subdev_ops - Subdev operations
  656. *
  657. * @core: pointer to &struct v4l2_subdev_core_ops. Can be %NULL
  658. * @tuner: pointer to &struct v4l2_subdev_tuner_ops. Can be %NULL
  659. * @audio: pointer to &struct v4l2_subdev_audio_ops. Can be %NULL
  660. * @video: pointer to &struct v4l2_subdev_video_ops. Can be %NULL
  661. * @vbi: pointer to &struct v4l2_subdev_vbi_ops. Can be %NULL
  662. * @ir: pointer to &struct v4l2_subdev_ir_ops. Can be %NULL
  663. * @sensor: pointer to &struct v4l2_subdev_sensor_ops. Can be %NULL
  664. * @pad: pointer to &struct v4l2_subdev_pad_ops. Can be %NULL
  665. */
  666. struct v4l2_subdev_ops {
  667. const struct v4l2_subdev_core_ops *core;
  668. const struct v4l2_subdev_tuner_ops *tuner;
  669. const struct v4l2_subdev_audio_ops *audio;
  670. const struct v4l2_subdev_video_ops *video;
  671. const struct v4l2_subdev_vbi_ops *vbi;
  672. const struct v4l2_subdev_ir_ops *ir;
  673. const struct v4l2_subdev_sensor_ops *sensor;
  674. const struct v4l2_subdev_pad_ops *pad;
  675. };
  676. /**
  677. * struct v4l2_subdev_internal_ops - V4L2 subdev internal ops
  678. *
  679. * @registered: called when this subdev is registered. When called the v4l2_dev
  680. * field is set to the correct v4l2_device.
  681. *
  682. * @unregistered: called when this subdev is unregistered. When called the
  683. * v4l2_dev field is still set to the correct v4l2_device.
  684. *
  685. * @open: called when the subdev device node is opened by an application.
  686. *
  687. * @close: called when the subdev device node is closed.
  688. *
  689. * .. note::
  690. * Never call this from drivers, only the v4l2 framework can call
  691. * these ops.
  692. */
  693. struct v4l2_subdev_internal_ops {
  694. int (*registered)(struct v4l2_subdev *sd);
  695. void (*unregistered)(struct v4l2_subdev *sd);
  696. int (*open)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
  697. int (*close)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
  698. };
  699. #define V4L2_SUBDEV_NAME_SIZE 32
  700. /* Set this flag if this subdev is a i2c device. */
  701. #define V4L2_SUBDEV_FL_IS_I2C (1U << 0)
  702. /* Set this flag if this subdev is a spi device. */
  703. #define V4L2_SUBDEV_FL_IS_SPI (1U << 1)
  704. /* Set this flag if this subdev needs a device node. */
  705. #define V4L2_SUBDEV_FL_HAS_DEVNODE (1U << 2)
  706. /* Set this flag if this subdev generates events. */
  707. #define V4L2_SUBDEV_FL_HAS_EVENTS (1U << 3)
  708. struct regulator_bulk_data;
  709. /**
  710. * struct v4l2_subdev_platform_data - regulators config struct
  711. *
  712. * @regulators: Optional regulators used to power on/off the subdevice
  713. * @num_regulators: Number of regululators
  714. * @host_priv: Per-subdevice data, specific for a certain video host device
  715. */
  716. struct v4l2_subdev_platform_data {
  717. struct regulator_bulk_data *regulators;
  718. int num_regulators;
  719. void *host_priv;
  720. };
  721. /**
  722. * struct v4l2_subdev - describes a V4L2 sub-device
  723. *
  724. * @entity: pointer to &struct media_entity
  725. * @list: List of sub-devices
  726. * @owner: The owner is the same as the driver's &struct device owner.
  727. * @owner_v4l2_dev: true if the &sd->owner matches the owner of @v4l2_dev->dev
  728. * ownner. Initialized by v4l2_device_register_subdev().
  729. * @flags: subdev flags. Can be:
  730. * %V4L2_SUBDEV_FL_IS_I2C - Set this flag if this subdev is a i2c device;
  731. * %V4L2_SUBDEV_FL_IS_SPI - Set this flag if this subdev is a spi device;
  732. * %V4L2_SUBDEV_FL_HAS_DEVNODE - Set this flag if this subdev needs a
  733. * device node;
  734. * %V4L2_SUBDEV_FL_HAS_EVENTS - Set this flag if this subdev generates
  735. * events.
  736. *
  737. * @v4l2_dev: pointer to struct &v4l2_device
  738. * @ops: pointer to struct &v4l2_subdev_ops
  739. * @internal_ops: pointer to struct &v4l2_subdev_internal_ops.
  740. * Never call these internal ops from within a driver!
  741. * @ctrl_handler: The control handler of this subdev. May be NULL.
  742. * @name: Name of the sub-device. Please notice that the name must be unique.
  743. * @grp_id: can be used to group similar subdevs. Value is driver-specific
  744. * @dev_priv: pointer to private data
  745. * @host_priv: pointer to private data used by the device where the subdev
  746. * is attached.
  747. * @devnode: subdev device node
  748. * @dev: pointer to the physical device, if any
  749. * @of_node: The device_node of the subdev, usually the same as dev->of_node.
  750. * @async_list: Links this subdev to a global subdev_list or @notifier->done
  751. * list.
  752. * @asd: Pointer to respective &struct v4l2_async_subdev.
  753. * @notifier: Pointer to the managing notifier.
  754. * @pdata: common part of subdevice platform data
  755. *
  756. * Each instance of a subdev driver should create this struct, either
  757. * stand-alone or embedded in a larger struct.
  758. *
  759. * This structure should be initialized by v4l2_subdev_init() or one of
  760. * its variants: v4l2_spi_subdev_init(), v4l2_i2c_subdev_init().
  761. */
  762. struct v4l2_subdev {
  763. #if defined(CONFIG_MEDIA_CONTROLLER)
  764. struct media_entity entity;
  765. #endif
  766. struct list_head list;
  767. struct module *owner;
  768. bool owner_v4l2_dev;
  769. u32 flags;
  770. struct v4l2_device *v4l2_dev;
  771. const struct v4l2_subdev_ops *ops;
  772. const struct v4l2_subdev_internal_ops *internal_ops;
  773. struct v4l2_ctrl_handler *ctrl_handler;
  774. char name[V4L2_SUBDEV_NAME_SIZE];
  775. u32 grp_id;
  776. void *dev_priv;
  777. void *host_priv;
  778. struct video_device *devnode;
  779. struct device *dev;
  780. struct device_node *of_node;
  781. struct list_head async_list;
  782. struct v4l2_async_subdev *asd;
  783. struct v4l2_async_notifier *notifier;
  784. struct v4l2_subdev_platform_data *pdata;
  785. };
  786. #define media_entity_to_v4l2_subdev(ent) \
  787. container_of(ent, struct v4l2_subdev, entity)
  788. #define vdev_to_v4l2_subdev(vdev) \
  789. ((struct v4l2_subdev *)video_get_drvdata(vdev))
  790. /**
  791. * struct v4l2_subdev_fh - Used for storing subdev information per file handle
  792. *
  793. * @vfh: pointer to struct v4l2_fh
  794. * @pad: pointer to v4l2_subdev_pad_config
  795. */
  796. struct v4l2_subdev_fh {
  797. struct v4l2_fh vfh;
  798. #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
  799. struct v4l2_subdev_pad_config *pad;
  800. #endif
  801. };
  802. #define to_v4l2_subdev_fh(fh) \
  803. container_of(fh, struct v4l2_subdev_fh, vfh)
  804. #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
  805. #define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name) \
  806. static inline struct rtype * \
  807. fun_name(struct v4l2_subdev *sd, \
  808. struct v4l2_subdev_pad_config *cfg, \
  809. unsigned int pad) \
  810. { \
  811. BUG_ON(pad >= sd->entity.num_pads); \
  812. return &cfg[pad].field_name; \
  813. }
  814. __V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, v4l2_subdev_get_try_format, try_fmt)
  815. __V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_crop, try_crop)
  816. __V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_compose, try_compose)
  817. #endif
  818. extern const struct v4l2_file_operations v4l2_subdev_fops;
  819. /**
  820. * v4l2_set_subdevdata - Sets V4L2 dev private device data
  821. *
  822. * @sd: pointer to &struct v4l2_subdev
  823. * @p: pointer to the private device data to be stored.
  824. */
  825. static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
  826. {
  827. sd->dev_priv = p;
  828. }
  829. /**
  830. * v4l2_get_subdevdata - Gets V4L2 dev private device data
  831. *
  832. * @sd: pointer to &struct v4l2_subdev
  833. *
  834. * Returns the pointer to the private device data to be stored.
  835. */
  836. static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
  837. {
  838. return sd->dev_priv;
  839. }
  840. /**
  841. * v4l2_set_subdev_hostdata - Sets V4L2 dev private host data
  842. *
  843. * @sd: pointer to &struct v4l2_subdev
  844. * @p: pointer to the private data to be stored.
  845. */
  846. static inline void v4l2_set_subdev_hostdata(struct v4l2_subdev *sd, void *p)
  847. {
  848. sd->host_priv = p;
  849. }
  850. /**
  851. * v4l2_get_subdev_hostdata - Gets V4L2 dev private data
  852. *
  853. * @sd: pointer to &struct v4l2_subdev
  854. *
  855. * Returns the pointer to the private host data to be stored.
  856. */
  857. static inline void *v4l2_get_subdev_hostdata(const struct v4l2_subdev *sd)
  858. {
  859. return sd->host_priv;
  860. }
  861. #ifdef CONFIG_MEDIA_CONTROLLER
  862. /**
  863. * v4l2_subdev_link_validate_default - validates a media link
  864. *
  865. * @sd: pointer to &struct v4l2_subdev
  866. * @link: pointer to &struct media_link
  867. * @source_fmt: pointer to &struct v4l2_subdev_format
  868. * @sink_fmt: pointer to &struct v4l2_subdev_format
  869. *
  870. * This function ensures that width, height and the media bus pixel
  871. * code are equal on both source and sink of the link.
  872. */
  873. int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
  874. struct media_link *link,
  875. struct v4l2_subdev_format *source_fmt,
  876. struct v4l2_subdev_format *sink_fmt);
  877. /**
  878. * v4l2_subdev_link_validate - validates a media link
  879. *
  880. * @link: pointer to &struct media_link
  881. *
  882. * This function calls the subdev's link_validate ops to validate
  883. * if a media link is valid for streaming. It also internally
  884. * calls v4l2_subdev_link_validate_default() to ensure that
  885. * width, height and the media bus pixel code are equal on both
  886. * source and sink of the link.
  887. */
  888. int v4l2_subdev_link_validate(struct media_link *link);
  889. /**
  890. * v4l2_subdev_alloc_pad_config - Allocates memory for pad config
  891. *
  892. * @sd: pointer to struct v4l2_subdev
  893. */
  894. struct
  895. v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
  896. /**
  897. * v4l2_subdev_free_pad_config - Frees memory allocated by
  898. * v4l2_subdev_alloc_pad_config().
  899. *
  900. * @cfg: pointer to &struct v4l2_subdev_pad_config
  901. */
  902. void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg);
  903. #endif /* CONFIG_MEDIA_CONTROLLER */
  904. /**
  905. * v4l2_subdev_init - initializes the sub-device struct
  906. *
  907. * @sd: pointer to the &struct v4l2_subdev to be initialized
  908. * @ops: pointer to &struct v4l2_subdev_ops.
  909. */
  910. void v4l2_subdev_init(struct v4l2_subdev *sd,
  911. const struct v4l2_subdev_ops *ops);
  912. /*
  913. * Call an ops of a v4l2_subdev, doing the right checks against
  914. * NULL pointers.
  915. *
  916. * Example: err = v4l2_subdev_call(sd, video, s_std, norm);
  917. */
  918. #define v4l2_subdev_call(sd, o, f, args...) \
  919. (!(sd) ? -ENODEV : (((sd)->ops->o && (sd)->ops->o->f) ? \
  920. (sd)->ops->o->f((sd), ##args) : -ENOIOCTLCMD))
  921. #define v4l2_subdev_has_op(sd, o, f) \
  922. ((sd)->ops->o && (sd)->ops->o->f)
  923. /**
  924. * v4l2_subdev_notify_event() - Delivers event notification for subdevice
  925. * @sd: The subdev for which to deliver the event
  926. * @ev: The event to deliver
  927. *
  928. * Will deliver the specified event to all userspace event listeners which are
  929. * subscribed to the v42l subdev event queue as well as to the bridge driver
  930. * using the notify callback. The notification type for the notify callback
  931. * will be %V4L2_DEVICE_NOTIFY_EVENT.
  932. */
  933. void v4l2_subdev_notify_event(struct v4l2_subdev *sd,
  934. const struct v4l2_event *ev);
  935. #endif