v4l2-subdev.h 37 KB

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