18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  V4L2 sub-device support header.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2008  Hans Verkuil <hverkuil@xs4all.nl>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _V4L2_SUBDEV_H
98c2ecf20Sopenharmony_ci#define _V4L2_SUBDEV_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci#include <linux/v4l2-subdev.h>
138c2ecf20Sopenharmony_ci#include <media/media-entity.h>
148c2ecf20Sopenharmony_ci#include <media/v4l2-async.h>
158c2ecf20Sopenharmony_ci#include <media/v4l2-common.h>
168c2ecf20Sopenharmony_ci#include <media/v4l2-dev.h>
178c2ecf20Sopenharmony_ci#include <media/v4l2-fh.h>
188c2ecf20Sopenharmony_ci#include <media/v4l2-mediabus.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* generic v4l2_device notify callback notification values */
218c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_IR_RX_NOTIFY		_IOW('v', 0, u32)
228c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ	0x00000001
238c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED	0x00000002
248c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_IR_RX_HW_FIFO_OVERRUN	0x00000004
258c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_IR_RX_SW_FIFO_OVERRUN	0x00000008
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_IR_TX_NOTIFY		_IOW('v', 1, u32)
288c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ	0x00000001
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define	V4L2_DEVICE_NOTIFY_EVENT		_IOW('v', 2, struct v4l2_event)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistruct v4l2_device;
338c2ecf20Sopenharmony_cistruct v4l2_ctrl_handler;
348c2ecf20Sopenharmony_cistruct v4l2_event;
358c2ecf20Sopenharmony_cistruct v4l2_event_subscription;
368c2ecf20Sopenharmony_cistruct v4l2_fh;
378c2ecf20Sopenharmony_cistruct v4l2_subdev;
388c2ecf20Sopenharmony_cistruct v4l2_subdev_fh;
398c2ecf20Sopenharmony_cistruct tuner_setup;
408c2ecf20Sopenharmony_cistruct v4l2_mbus_frame_desc;
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/**
438c2ecf20Sopenharmony_ci * struct v4l2_decode_vbi_line - used to decode_vbi_line
448c2ecf20Sopenharmony_ci *
458c2ecf20Sopenharmony_ci * @is_second_field: Set to 0 for the first (odd) field;
468c2ecf20Sopenharmony_ci *	set to 1 for the second (even) field.
478c2ecf20Sopenharmony_ci * @p: Pointer to the sliced VBI data from the decoder. On exit, points to
488c2ecf20Sopenharmony_ci *	the start of the payload.
498c2ecf20Sopenharmony_ci * @line: Line number of the sliced VBI data (1-23)
508c2ecf20Sopenharmony_ci * @type: VBI service type (V4L2_SLICED_*). 0 if no service found
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_cistruct v4l2_decode_vbi_line {
538c2ecf20Sopenharmony_ci	u32 is_second_field;
548c2ecf20Sopenharmony_ci	u8 *p;
558c2ecf20Sopenharmony_ci	u32 line;
568c2ecf20Sopenharmony_ci	u32 type;
578c2ecf20Sopenharmony_ci};
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/*
608c2ecf20Sopenharmony_ci * Sub-devices are devices that are connected somehow to the main bridge
618c2ecf20Sopenharmony_ci * device. These devices are usually audio/video muxers/encoders/decoders or
628c2ecf20Sopenharmony_ci * sensors and webcam controllers.
638c2ecf20Sopenharmony_ci *
648c2ecf20Sopenharmony_ci * Usually these devices are controlled through an i2c bus, but other buses
658c2ecf20Sopenharmony_ci * may also be used.
668c2ecf20Sopenharmony_ci *
678c2ecf20Sopenharmony_ci * The v4l2_subdev struct provides a way of accessing these devices in a
688c2ecf20Sopenharmony_ci * generic manner. Most operations that these sub-devices support fall in
698c2ecf20Sopenharmony_ci * a few categories: core ops, audio ops, video ops and tuner ops.
708c2ecf20Sopenharmony_ci *
718c2ecf20Sopenharmony_ci * More categories can be added if needed, although this should remain a
728c2ecf20Sopenharmony_ci * limited set (no more than approx. 8 categories).
738c2ecf20Sopenharmony_ci *
748c2ecf20Sopenharmony_ci * Each category has its own set of ops that subdev drivers can implement.
758c2ecf20Sopenharmony_ci *
768c2ecf20Sopenharmony_ci * A subdev driver can leave the pointer to the category ops NULL if
778c2ecf20Sopenharmony_ci * it does not implement them (e.g. an audio subdev will generally not
788c2ecf20Sopenharmony_ci * implement the video category ops). The exception is the core category:
798c2ecf20Sopenharmony_ci * this must always be present.
808c2ecf20Sopenharmony_ci *
818c2ecf20Sopenharmony_ci * These ops are all used internally so it is no problem to change, remove
828c2ecf20Sopenharmony_ci * or add ops or move ops from one to another category. Currently these
838c2ecf20Sopenharmony_ci * ops are based on the original ioctls, but since ops are not limited to
848c2ecf20Sopenharmony_ci * one argument there is room for improvement here once all i2c subdev
858c2ecf20Sopenharmony_ci * drivers are converted to use these ops.
868c2ecf20Sopenharmony_ci */
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/*
898c2ecf20Sopenharmony_ci * Core ops: it is highly recommended to implement at least these ops:
908c2ecf20Sopenharmony_ci *
918c2ecf20Sopenharmony_ci * log_status
928c2ecf20Sopenharmony_ci * g_register
938c2ecf20Sopenharmony_ci * s_register
948c2ecf20Sopenharmony_ci *
958c2ecf20Sopenharmony_ci * This provides basic debugging support.
968c2ecf20Sopenharmony_ci *
978c2ecf20Sopenharmony_ci * The ioctl ops is meant for generic ioctl-like commands. Depending on
988c2ecf20Sopenharmony_ci * the use-case it might be better to use subdev-specific ops (currently
998c2ecf20Sopenharmony_ci * not yet implemented) since ops provide proper type-checking.
1008c2ecf20Sopenharmony_ci */
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/**
1038c2ecf20Sopenharmony_ci * enum v4l2_subdev_io_pin_bits - Subdevice external IO pin configuration
1048c2ecf20Sopenharmony_ci *	bits
1058c2ecf20Sopenharmony_ci *
1068c2ecf20Sopenharmony_ci * @V4L2_SUBDEV_IO_PIN_DISABLE: disables a pin config. ENABLE assumed.
1078c2ecf20Sopenharmony_ci * @V4L2_SUBDEV_IO_PIN_OUTPUT: set it if pin is an output.
1088c2ecf20Sopenharmony_ci * @V4L2_SUBDEV_IO_PIN_INPUT: set it if pin is an input.
1098c2ecf20Sopenharmony_ci * @V4L2_SUBDEV_IO_PIN_SET_VALUE: to set the output value via
1108c2ecf20Sopenharmony_ci *				  &struct v4l2_subdev_io_pin_config->value.
1118c2ecf20Sopenharmony_ci * @V4L2_SUBDEV_IO_PIN_ACTIVE_LOW: pin active is bit 0.
1128c2ecf20Sopenharmony_ci *				   Otherwise, ACTIVE HIGH is assumed.
1138c2ecf20Sopenharmony_ci */
1148c2ecf20Sopenharmony_cienum v4l2_subdev_io_pin_bits {
1158c2ecf20Sopenharmony_ci	V4L2_SUBDEV_IO_PIN_DISABLE	= 0,
1168c2ecf20Sopenharmony_ci	V4L2_SUBDEV_IO_PIN_OUTPUT	= 1,
1178c2ecf20Sopenharmony_ci	V4L2_SUBDEV_IO_PIN_INPUT	= 2,
1188c2ecf20Sopenharmony_ci	V4L2_SUBDEV_IO_PIN_SET_VALUE	= 3,
1198c2ecf20Sopenharmony_ci	V4L2_SUBDEV_IO_PIN_ACTIVE_LOW	= 4,
1208c2ecf20Sopenharmony_ci};
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci/**
1238c2ecf20Sopenharmony_ci * struct v4l2_subdev_io_pin_config - Subdevice external IO pin configuration
1248c2ecf20Sopenharmony_ci *
1258c2ecf20Sopenharmony_ci * @flags: bitmask with flags for this pin's config, whose bits are defined by
1268c2ecf20Sopenharmony_ci *	   &enum v4l2_subdev_io_pin_bits.
1278c2ecf20Sopenharmony_ci * @pin: Chip external IO pin to configure
1288c2ecf20Sopenharmony_ci * @function: Internal signal pad/function to route to IO pin
1298c2ecf20Sopenharmony_ci * @value: Initial value for pin - e.g. GPIO output value
1308c2ecf20Sopenharmony_ci * @strength: Pin drive strength
1318c2ecf20Sopenharmony_ci */
1328c2ecf20Sopenharmony_cistruct v4l2_subdev_io_pin_config {
1338c2ecf20Sopenharmony_ci	u32 flags;
1348c2ecf20Sopenharmony_ci	u8 pin;
1358c2ecf20Sopenharmony_ci	u8 function;
1368c2ecf20Sopenharmony_ci	u8 value;
1378c2ecf20Sopenharmony_ci	u8 strength;
1388c2ecf20Sopenharmony_ci};
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci/**
1418c2ecf20Sopenharmony_ci * struct v4l2_subdev_core_ops - Define core ops callbacks for subdevs
1428c2ecf20Sopenharmony_ci *
1438c2ecf20Sopenharmony_ci * @log_status: callback for VIDIOC_LOG_STATUS() ioctl handler code.
1448c2ecf20Sopenharmony_ci *
1458c2ecf20Sopenharmony_ci * @s_io_pin_config: configure one or more chip I/O pins for chips that
1468c2ecf20Sopenharmony_ci *	multiplex different internal signal pads out to IO pins.  This function
1478c2ecf20Sopenharmony_ci *	takes a pointer to an array of 'n' pin configuration entries, one for
1488c2ecf20Sopenharmony_ci *	each pin being configured.  This function could be called at times
1498c2ecf20Sopenharmony_ci *	other than just subdevice initialization.
1508c2ecf20Sopenharmony_ci *
1518c2ecf20Sopenharmony_ci * @init: initialize the sensor registers to some sort of reasonable default
1528c2ecf20Sopenharmony_ci *	values. Do not use for new drivers and should be removed in existing
1538c2ecf20Sopenharmony_ci *	drivers.
1548c2ecf20Sopenharmony_ci *
1558c2ecf20Sopenharmony_ci * @load_fw: load firmware.
1568c2ecf20Sopenharmony_ci *
1578c2ecf20Sopenharmony_ci * @reset: generic reset command. The argument selects which subsystems to
1588c2ecf20Sopenharmony_ci *	reset. Passing 0 will always reset the whole chip. Do not use for new
1598c2ecf20Sopenharmony_ci *	drivers without discussing this first on the linux-media mailinglist.
1608c2ecf20Sopenharmony_ci *	There should be no reason normally to reset a device.
1618c2ecf20Sopenharmony_ci *
1628c2ecf20Sopenharmony_ci * @s_gpio: set GPIO pins. Very simple right now, might need to be extended with
1638c2ecf20Sopenharmony_ci *	a direction argument if needed.
1648c2ecf20Sopenharmony_ci *
1658c2ecf20Sopenharmony_ci * @command: called by in-kernel drivers in order to call functions internal
1668c2ecf20Sopenharmony_ci *	   to subdev drivers driver that have a separate callback.
1678c2ecf20Sopenharmony_ci *
1688c2ecf20Sopenharmony_ci * @ioctl: called at the end of ioctl() syscall handler at the V4L2 core.
1698c2ecf20Sopenharmony_ci *	   used to provide support for private ioctls used on the driver.
1708c2ecf20Sopenharmony_ci *
1718c2ecf20Sopenharmony_ci * @compat_ioctl32: called when a 32 bits application uses a 64 bits Kernel,
1728c2ecf20Sopenharmony_ci *		    in order to fix data passed from/to userspace.
1738c2ecf20Sopenharmony_ci *
1748c2ecf20Sopenharmony_ci * @g_register: callback for VIDIOC_DBG_G_REGISTER() ioctl handler code.
1758c2ecf20Sopenharmony_ci *
1768c2ecf20Sopenharmony_ci * @s_register: callback for VIDIOC_DBG_S_REGISTER() ioctl handler code.
1778c2ecf20Sopenharmony_ci *
1788c2ecf20Sopenharmony_ci * @s_power: puts subdevice in power saving mode (on == 0) or normal operation
1798c2ecf20Sopenharmony_ci *	mode (on == 1).
1808c2ecf20Sopenharmony_ci *
1818c2ecf20Sopenharmony_ci * @interrupt_service_routine: Called by the bridge chip's interrupt service
1828c2ecf20Sopenharmony_ci *	handler, when an interrupt status has be raised due to this subdev,
1838c2ecf20Sopenharmony_ci *	so that this subdev can handle the details.  It may schedule work to be
1848c2ecf20Sopenharmony_ci *	performed later.  It must not sleep. **Called from an IRQ context**.
1858c2ecf20Sopenharmony_ci *
1868c2ecf20Sopenharmony_ci * @subscribe_event: used by the drivers to request the control framework that
1878c2ecf20Sopenharmony_ci *		     for it to be warned when the value of a control changes.
1888c2ecf20Sopenharmony_ci *
1898c2ecf20Sopenharmony_ci * @unsubscribe_event: remove event subscription from the control framework.
1908c2ecf20Sopenharmony_ci */
1918c2ecf20Sopenharmony_cistruct v4l2_subdev_core_ops {
1928c2ecf20Sopenharmony_ci	int (*log_status)(struct v4l2_subdev *sd);
1938c2ecf20Sopenharmony_ci	int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n,
1948c2ecf20Sopenharmony_ci				      struct v4l2_subdev_io_pin_config *pincfg);
1958c2ecf20Sopenharmony_ci	int (*init)(struct v4l2_subdev *sd, u32 val);
1968c2ecf20Sopenharmony_ci	int (*load_fw)(struct v4l2_subdev *sd);
1978c2ecf20Sopenharmony_ci	int (*reset)(struct v4l2_subdev *sd, u32 val);
1988c2ecf20Sopenharmony_ci	int (*s_gpio)(struct v4l2_subdev *sd, u32 val);
1998c2ecf20Sopenharmony_ci	long (*command)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
2008c2ecf20Sopenharmony_ci	long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
2018c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT
2028c2ecf20Sopenharmony_ci	long (*compat_ioctl32)(struct v4l2_subdev *sd, unsigned int cmd,
2038c2ecf20Sopenharmony_ci			       unsigned long arg);
2048c2ecf20Sopenharmony_ci#endif
2058c2ecf20Sopenharmony_ci#ifdef CONFIG_VIDEO_ADV_DEBUG
2068c2ecf20Sopenharmony_ci	int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
2078c2ecf20Sopenharmony_ci	int (*s_register)(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg);
2088c2ecf20Sopenharmony_ci#endif
2098c2ecf20Sopenharmony_ci	int (*s_power)(struct v4l2_subdev *sd, int on);
2108c2ecf20Sopenharmony_ci	int (*interrupt_service_routine)(struct v4l2_subdev *sd,
2118c2ecf20Sopenharmony_ci						u32 status, bool *handled);
2128c2ecf20Sopenharmony_ci	int (*subscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
2138c2ecf20Sopenharmony_ci			       struct v4l2_event_subscription *sub);
2148c2ecf20Sopenharmony_ci	int (*unsubscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
2158c2ecf20Sopenharmony_ci				 struct v4l2_event_subscription *sub);
2168c2ecf20Sopenharmony_ci};
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci/**
2198c2ecf20Sopenharmony_ci * struct v4l2_subdev_tuner_ops - Callbacks used when v4l device was opened
2208c2ecf20Sopenharmony_ci *	in radio mode.
2218c2ecf20Sopenharmony_ci *
2228c2ecf20Sopenharmony_ci * @standby: puts the tuner in standby mode. It will be woken up
2238c2ecf20Sopenharmony_ci *	     automatically the next time it is used.
2248c2ecf20Sopenharmony_ci *
2258c2ecf20Sopenharmony_ci * @s_radio: callback that switches the tuner to radio mode.
2268c2ecf20Sopenharmony_ci *	     drivers should explicitly call it when a tuner ops should
2278c2ecf20Sopenharmony_ci *	     operate on radio mode, before being able to handle it.
2288c2ecf20Sopenharmony_ci *	     Used on devices that have both AM/FM radio receiver and TV.
2298c2ecf20Sopenharmony_ci *
2308c2ecf20Sopenharmony_ci * @s_frequency: callback for VIDIOC_S_FREQUENCY() ioctl handler code.
2318c2ecf20Sopenharmony_ci *
2328c2ecf20Sopenharmony_ci * @g_frequency: callback for VIDIOC_G_FREQUENCY() ioctl handler code.
2338c2ecf20Sopenharmony_ci *		 freq->type must be filled in. Normally done by video_ioctl2()
2348c2ecf20Sopenharmony_ci *		 or the bridge driver.
2358c2ecf20Sopenharmony_ci *
2368c2ecf20Sopenharmony_ci * @enum_freq_bands: callback for VIDIOC_ENUM_FREQ_BANDS() ioctl handler code.
2378c2ecf20Sopenharmony_ci *
2388c2ecf20Sopenharmony_ci * @g_tuner: callback for VIDIOC_G_TUNER() ioctl handler code.
2398c2ecf20Sopenharmony_ci *
2408c2ecf20Sopenharmony_ci * @s_tuner: callback for VIDIOC_S_TUNER() ioctl handler code. @vt->type must be
2418c2ecf20Sopenharmony_ci *	     filled in. Normally done by video_ioctl2 or the
2428c2ecf20Sopenharmony_ci *	     bridge driver.
2438c2ecf20Sopenharmony_ci *
2448c2ecf20Sopenharmony_ci * @g_modulator: callback for VIDIOC_G_MODULATOR() ioctl handler code.
2458c2ecf20Sopenharmony_ci *
2468c2ecf20Sopenharmony_ci * @s_modulator: callback for VIDIOC_S_MODULATOR() ioctl handler code.
2478c2ecf20Sopenharmony_ci *
2488c2ecf20Sopenharmony_ci * @s_type_addr: sets tuner type and its I2C addr.
2498c2ecf20Sopenharmony_ci *
2508c2ecf20Sopenharmony_ci * @s_config: sets tda9887 specific stuff, like port1, port2 and qss
2518c2ecf20Sopenharmony_ci *
2528c2ecf20Sopenharmony_ci * .. note::
2538c2ecf20Sopenharmony_ci *
2548c2ecf20Sopenharmony_ci *	On devices that have both AM/FM and TV, it is up to the driver
2558c2ecf20Sopenharmony_ci *	to explicitly call s_radio when the tuner should be switched to
2568c2ecf20Sopenharmony_ci *	radio mode, before handling other &struct v4l2_subdev_tuner_ops
2578c2ecf20Sopenharmony_ci *	that would require it. An example of such usage is::
2588c2ecf20Sopenharmony_ci *
2598c2ecf20Sopenharmony_ci *	  static void s_frequency(void *priv, const struct v4l2_frequency *f)
2608c2ecf20Sopenharmony_ci *	  {
2618c2ecf20Sopenharmony_ci *		...
2628c2ecf20Sopenharmony_ci *		if (f.type == V4L2_TUNER_RADIO)
2638c2ecf20Sopenharmony_ci *			v4l2_device_call_all(v4l2_dev, 0, tuner, s_radio);
2648c2ecf20Sopenharmony_ci *		...
2658c2ecf20Sopenharmony_ci *		v4l2_device_call_all(v4l2_dev, 0, tuner, s_frequency);
2668c2ecf20Sopenharmony_ci *	  }
2678c2ecf20Sopenharmony_ci */
2688c2ecf20Sopenharmony_cistruct v4l2_subdev_tuner_ops {
2698c2ecf20Sopenharmony_ci	int (*standby)(struct v4l2_subdev *sd);
2708c2ecf20Sopenharmony_ci	int (*s_radio)(struct v4l2_subdev *sd);
2718c2ecf20Sopenharmony_ci	int (*s_frequency)(struct v4l2_subdev *sd, const struct v4l2_frequency *freq);
2728c2ecf20Sopenharmony_ci	int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
2738c2ecf20Sopenharmony_ci	int (*enum_freq_bands)(struct v4l2_subdev *sd, struct v4l2_frequency_band *band);
2748c2ecf20Sopenharmony_ci	int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
2758c2ecf20Sopenharmony_ci	int (*s_tuner)(struct v4l2_subdev *sd, const struct v4l2_tuner *vt);
2768c2ecf20Sopenharmony_ci	int (*g_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
2778c2ecf20Sopenharmony_ci	int (*s_modulator)(struct v4l2_subdev *sd, const struct v4l2_modulator *vm);
2788c2ecf20Sopenharmony_ci	int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type);
2798c2ecf20Sopenharmony_ci	int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
2808c2ecf20Sopenharmony_ci};
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci/**
2838c2ecf20Sopenharmony_ci * struct v4l2_subdev_audio_ops - Callbacks used for audio-related settings
2848c2ecf20Sopenharmony_ci *
2858c2ecf20Sopenharmony_ci * @s_clock_freq: set the frequency (in Hz) of the audio clock output.
2868c2ecf20Sopenharmony_ci *	Used to slave an audio processor to the video decoder, ensuring that
2878c2ecf20Sopenharmony_ci *	audio and video remain synchronized. Usual values for the frequency
2888c2ecf20Sopenharmony_ci *	are 48000, 44100 or 32000 Hz. If the frequency is not supported, then
2898c2ecf20Sopenharmony_ci *	-EINVAL is returned.
2908c2ecf20Sopenharmony_ci *
2918c2ecf20Sopenharmony_ci * @s_i2s_clock_freq: sets I2S speed in bps. This is used to provide a standard
2928c2ecf20Sopenharmony_ci *	way to select I2S clock used by driving digital audio streams at some
2938c2ecf20Sopenharmony_ci *	board designs. Usual values for the frequency are 1024000 and 2048000.
2948c2ecf20Sopenharmony_ci *	If the frequency is not supported, then %-EINVAL is returned.
2958c2ecf20Sopenharmony_ci *
2968c2ecf20Sopenharmony_ci * @s_routing: used to define the input and/or output pins of an audio chip,
2978c2ecf20Sopenharmony_ci *	and any additional configuration data.
2988c2ecf20Sopenharmony_ci *	Never attempt to use user-level input IDs (e.g. Composite, S-Video,
2998c2ecf20Sopenharmony_ci *	Tuner) at this level. An i2c device shouldn't know about whether an
3008c2ecf20Sopenharmony_ci *	input pin is connected to a Composite connector, become on another
3018c2ecf20Sopenharmony_ci *	board or platform it might be connected to something else entirely.
3028c2ecf20Sopenharmony_ci *	The calling driver is responsible for mapping a user-level input to
3038c2ecf20Sopenharmony_ci *	the right pins on the i2c device.
3048c2ecf20Sopenharmony_ci *
3058c2ecf20Sopenharmony_ci * @s_stream: used to notify the audio code that stream will start or has
3068c2ecf20Sopenharmony_ci *	stopped.
3078c2ecf20Sopenharmony_ci */
3088c2ecf20Sopenharmony_cistruct v4l2_subdev_audio_ops {
3098c2ecf20Sopenharmony_ci	int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
3108c2ecf20Sopenharmony_ci	int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
3118c2ecf20Sopenharmony_ci	int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
3128c2ecf20Sopenharmony_ci	int (*s_stream)(struct v4l2_subdev *sd, int enable);
3138c2ecf20Sopenharmony_ci};
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci/**
3168c2ecf20Sopenharmony_ci * enum v4l2_mbus_frame_desc_entry - media bus frame description flags
3178c2ecf20Sopenharmony_ci *
3188c2ecf20Sopenharmony_ci * @V4L2_MBUS_FRAME_DESC_FL_LEN_MAX:
3198c2ecf20Sopenharmony_ci *	Indicates that &struct v4l2_mbus_frame_desc_entry->length field
3208c2ecf20Sopenharmony_ci *	specifies maximum data length.
3218c2ecf20Sopenharmony_ci * @V4L2_MBUS_FRAME_DESC_FL_BLOB:
3228c2ecf20Sopenharmony_ci *	Indicates that the format does not have line offsets, i.e.
3238c2ecf20Sopenharmony_ci *	the receiver should use 1D DMA.
3248c2ecf20Sopenharmony_ci */
3258c2ecf20Sopenharmony_cienum v4l2_mbus_frame_desc_flags {
3268c2ecf20Sopenharmony_ci	V4L2_MBUS_FRAME_DESC_FL_LEN_MAX	= BIT(0),
3278c2ecf20Sopenharmony_ci	V4L2_MBUS_FRAME_DESC_FL_BLOB	= BIT(1),
3288c2ecf20Sopenharmony_ci};
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci/**
3318c2ecf20Sopenharmony_ci * struct v4l2_mbus_frame_desc_entry - media bus frame description structure
3328c2ecf20Sopenharmony_ci *
3338c2ecf20Sopenharmony_ci * @flags:	bitmask flags, as defined by &enum v4l2_mbus_frame_desc_flags.
3348c2ecf20Sopenharmony_ci * @pixelcode:	media bus pixel code, valid if @flags
3358c2ecf20Sopenharmony_ci *		%FRAME_DESC_FL_BLOB is not set.
3368c2ecf20Sopenharmony_ci * @length:	number of octets per frame, valid if @flags
3378c2ecf20Sopenharmony_ci *		%V4L2_MBUS_FRAME_DESC_FL_LEN_MAX is set.
3388c2ecf20Sopenharmony_ci */
3398c2ecf20Sopenharmony_cistruct v4l2_mbus_frame_desc_entry {
3408c2ecf20Sopenharmony_ci	enum v4l2_mbus_frame_desc_flags flags;
3418c2ecf20Sopenharmony_ci	u32 pixelcode;
3428c2ecf20Sopenharmony_ci	u32 length;
3438c2ecf20Sopenharmony_ci};
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci#define V4L2_FRAME_DESC_ENTRY_MAX	4
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci/**
3488c2ecf20Sopenharmony_ci * struct v4l2_mbus_frame_desc - media bus data frame description
3498c2ecf20Sopenharmony_ci * @entry: frame descriptors array
3508c2ecf20Sopenharmony_ci * @num_entries: number of entries in @entry array
3518c2ecf20Sopenharmony_ci */
3528c2ecf20Sopenharmony_cistruct v4l2_mbus_frame_desc {
3538c2ecf20Sopenharmony_ci	struct v4l2_mbus_frame_desc_entry entry[V4L2_FRAME_DESC_ENTRY_MAX];
3548c2ecf20Sopenharmony_ci	unsigned short num_entries;
3558c2ecf20Sopenharmony_ci};
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci/**
3588c2ecf20Sopenharmony_ci * struct v4l2_subdev_video_ops - Callbacks used when v4l device was opened
3598c2ecf20Sopenharmony_ci *				  in video mode.
3608c2ecf20Sopenharmony_ci *
3618c2ecf20Sopenharmony_ci * @s_routing: see s_routing in audio_ops, except this version is for video
3628c2ecf20Sopenharmony_ci *	devices.
3638c2ecf20Sopenharmony_ci *
3648c2ecf20Sopenharmony_ci * @s_crystal_freq: sets the frequency of the crystal used to generate the
3658c2ecf20Sopenharmony_ci *	clocks in Hz. An extra flags field allows device specific configuration
3668c2ecf20Sopenharmony_ci *	regarding clock frequency dividers, etc. If not used, then set flags
3678c2ecf20Sopenharmony_ci *	to 0. If the frequency is not supported, then -EINVAL is returned.
3688c2ecf20Sopenharmony_ci *
3698c2ecf20Sopenharmony_ci * @g_std: callback for VIDIOC_G_STD() ioctl handler code.
3708c2ecf20Sopenharmony_ci *
3718c2ecf20Sopenharmony_ci * @s_std: callback for VIDIOC_S_STD() ioctl handler code.
3728c2ecf20Sopenharmony_ci *
3738c2ecf20Sopenharmony_ci * @s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
3748c2ecf20Sopenharmony_ci *	video input devices.
3758c2ecf20Sopenharmony_ci *
3768c2ecf20Sopenharmony_ci * @g_std_output: get current standard for video OUTPUT devices. This is ignored
3778c2ecf20Sopenharmony_ci *	by video input devices.
3788c2ecf20Sopenharmony_ci *
3798c2ecf20Sopenharmony_ci * @querystd: callback for VIDIOC_QUERYSTD() ioctl handler code.
3808c2ecf20Sopenharmony_ci *
3818c2ecf20Sopenharmony_ci * @g_tvnorms: get &v4l2_std_id with all standards supported by the video
3828c2ecf20Sopenharmony_ci *	CAPTURE device. This is ignored by video output devices.
3838c2ecf20Sopenharmony_ci *
3848c2ecf20Sopenharmony_ci * @g_tvnorms_output: get v4l2_std_id with all standards supported by the video
3858c2ecf20Sopenharmony_ci *	OUTPUT device. This is ignored by video capture devices.
3868c2ecf20Sopenharmony_ci *
3878c2ecf20Sopenharmony_ci * @g_input_status: get input status. Same as the status field in the
3888c2ecf20Sopenharmony_ci *	&struct v4l2_input
3898c2ecf20Sopenharmony_ci *
3908c2ecf20Sopenharmony_ci * @s_stream: used to notify the driver that a video stream will start or has
3918c2ecf20Sopenharmony_ci *	stopped.
3928c2ecf20Sopenharmony_ci *
3938c2ecf20Sopenharmony_ci * @g_pixelaspect: callback to return the pixelaspect ratio.
3948c2ecf20Sopenharmony_ci *
3958c2ecf20Sopenharmony_ci * @g_frame_interval: callback for VIDIOC_SUBDEV_G_FRAME_INTERVAL()
3968c2ecf20Sopenharmony_ci *		      ioctl handler code.
3978c2ecf20Sopenharmony_ci *
3988c2ecf20Sopenharmony_ci * @s_frame_interval: callback for VIDIOC_SUBDEV_S_FRAME_INTERVAL()
3998c2ecf20Sopenharmony_ci *		      ioctl handler code.
4008c2ecf20Sopenharmony_ci *
4018c2ecf20Sopenharmony_ci * @s_dv_timings: Set custom dv timings in the sub device. This is used
4028c2ecf20Sopenharmony_ci *	when sub device is capable of setting detailed timing information
4038c2ecf20Sopenharmony_ci *	in the hardware to generate/detect the video signal.
4048c2ecf20Sopenharmony_ci *
4058c2ecf20Sopenharmony_ci * @g_dv_timings: Get custom dv timings in the sub device.
4068c2ecf20Sopenharmony_ci *
4078c2ecf20Sopenharmony_ci * @query_dv_timings: callback for VIDIOC_QUERY_DV_TIMINGS() ioctl handler code.
4088c2ecf20Sopenharmony_ci *
4098c2ecf20Sopenharmony_ci * @s_rx_buffer: set a host allocated memory buffer for the subdev. The subdev
4108c2ecf20Sopenharmony_ci *	can adjust @size to a lower value and must not write more data to the
4118c2ecf20Sopenharmony_ci *	buffer starting at @data than the original value of @size.
4128c2ecf20Sopenharmony_ci */
4138c2ecf20Sopenharmony_cistruct v4l2_subdev_video_ops {
4148c2ecf20Sopenharmony_ci	int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
4158c2ecf20Sopenharmony_ci	int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags);
4168c2ecf20Sopenharmony_ci	int (*g_std)(struct v4l2_subdev *sd, v4l2_std_id *norm);
4178c2ecf20Sopenharmony_ci	int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);
4188c2ecf20Sopenharmony_ci	int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
4198c2ecf20Sopenharmony_ci	int (*g_std_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
4208c2ecf20Sopenharmony_ci	int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
4218c2ecf20Sopenharmony_ci	int (*g_tvnorms)(struct v4l2_subdev *sd, v4l2_std_id *std);
4228c2ecf20Sopenharmony_ci	int (*g_tvnorms_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
4238c2ecf20Sopenharmony_ci	int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
4248c2ecf20Sopenharmony_ci	int (*s_stream)(struct v4l2_subdev *sd, int enable);
4258c2ecf20Sopenharmony_ci	int (*g_pixelaspect)(struct v4l2_subdev *sd, struct v4l2_fract *aspect);
4268c2ecf20Sopenharmony_ci	int (*g_frame_interval)(struct v4l2_subdev *sd,
4278c2ecf20Sopenharmony_ci				struct v4l2_subdev_frame_interval *interval);
4288c2ecf20Sopenharmony_ci	int (*s_frame_interval)(struct v4l2_subdev *sd,
4298c2ecf20Sopenharmony_ci				struct v4l2_subdev_frame_interval *interval);
4308c2ecf20Sopenharmony_ci	int (*s_dv_timings)(struct v4l2_subdev *sd,
4318c2ecf20Sopenharmony_ci			struct v4l2_dv_timings *timings);
4328c2ecf20Sopenharmony_ci	int (*g_dv_timings)(struct v4l2_subdev *sd,
4338c2ecf20Sopenharmony_ci			struct v4l2_dv_timings *timings);
4348c2ecf20Sopenharmony_ci	int (*query_dv_timings)(struct v4l2_subdev *sd,
4358c2ecf20Sopenharmony_ci			struct v4l2_dv_timings *timings);
4368c2ecf20Sopenharmony_ci	int (*s_rx_buffer)(struct v4l2_subdev *sd, void *buf,
4378c2ecf20Sopenharmony_ci			   unsigned int *size);
4388c2ecf20Sopenharmony_ci};
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci/**
4418c2ecf20Sopenharmony_ci * struct v4l2_subdev_vbi_ops - Callbacks used when v4l device was opened
4428c2ecf20Sopenharmony_ci *				  in video mode via the vbi device node.
4438c2ecf20Sopenharmony_ci *
4448c2ecf20Sopenharmony_ci *  @decode_vbi_line: video decoders that support sliced VBI need to implement
4458c2ecf20Sopenharmony_ci *	this ioctl. Field p of the &struct v4l2_decode_vbi_line is set to the
4468c2ecf20Sopenharmony_ci *	start of the VBI data that was generated by the decoder. The driver
4478c2ecf20Sopenharmony_ci *	then parses the sliced VBI data and sets the other fields in the
4488c2ecf20Sopenharmony_ci *	struct accordingly. The pointer p is updated to point to the start of
4498c2ecf20Sopenharmony_ci *	the payload which can be copied verbatim into the data field of the
4508c2ecf20Sopenharmony_ci *	&struct v4l2_sliced_vbi_data. If no valid VBI data was found, then the
4518c2ecf20Sopenharmony_ci *	type field is set to 0 on return.
4528c2ecf20Sopenharmony_ci *
4538c2ecf20Sopenharmony_ci * @s_vbi_data: used to generate VBI signals on a video signal.
4548c2ecf20Sopenharmony_ci *	&struct v4l2_sliced_vbi_data is filled with the data packets that
4558c2ecf20Sopenharmony_ci *	should be output. Note that if you set the line field to 0, then that
4568c2ecf20Sopenharmony_ci *	VBI signal is disabled. If no valid VBI data was found, then the type
4578c2ecf20Sopenharmony_ci *	field is set to 0 on return.
4588c2ecf20Sopenharmony_ci *
4598c2ecf20Sopenharmony_ci * @g_vbi_data: used to obtain the sliced VBI packet from a readback register.
4608c2ecf20Sopenharmony_ci *	Not all video decoders support this. If no data is available because
4618c2ecf20Sopenharmony_ci *	the readback register contains invalid or erroneous data %-EIO is
4628c2ecf20Sopenharmony_ci *	returned. Note that you must fill in the 'id' member and the 'field'
4638c2ecf20Sopenharmony_ci *	member (to determine whether CC data from the first or second field
4648c2ecf20Sopenharmony_ci *	should be obtained).
4658c2ecf20Sopenharmony_ci *
4668c2ecf20Sopenharmony_ci * @g_sliced_vbi_cap: callback for VIDIOC_G_SLICED_VBI_CAP() ioctl handler
4678c2ecf20Sopenharmony_ci *		      code.
4688c2ecf20Sopenharmony_ci *
4698c2ecf20Sopenharmony_ci * @s_raw_fmt: setup the video encoder/decoder for raw VBI.
4708c2ecf20Sopenharmony_ci *
4718c2ecf20Sopenharmony_ci * @g_sliced_fmt: retrieve the current sliced VBI settings.
4728c2ecf20Sopenharmony_ci *
4738c2ecf20Sopenharmony_ci * @s_sliced_fmt: setup the sliced VBI settings.
4748c2ecf20Sopenharmony_ci */
4758c2ecf20Sopenharmony_cistruct v4l2_subdev_vbi_ops {
4768c2ecf20Sopenharmony_ci	int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line);
4778c2ecf20Sopenharmony_ci	int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data);
4788c2ecf20Sopenharmony_ci	int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data);
4798c2ecf20Sopenharmony_ci	int (*g_sliced_vbi_cap)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_cap *cap);
4808c2ecf20Sopenharmony_ci	int (*s_raw_fmt)(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt);
4818c2ecf20Sopenharmony_ci	int (*g_sliced_fmt)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
4828c2ecf20Sopenharmony_ci	int (*s_sliced_fmt)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
4838c2ecf20Sopenharmony_ci};
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_ci/**
4868c2ecf20Sopenharmony_ci * struct v4l2_subdev_sensor_ops - v4l2-subdev sensor operations
4878c2ecf20Sopenharmony_ci * @g_skip_top_lines: number of lines at the top of the image to be skipped.
4888c2ecf20Sopenharmony_ci *		      This is needed for some sensors, which always corrupt
4898c2ecf20Sopenharmony_ci *		      several top lines of the output image, or which send their
4908c2ecf20Sopenharmony_ci *		      metadata in them.
4918c2ecf20Sopenharmony_ci * @g_skip_frames: number of frames to skip at stream start. This is needed for
4928c2ecf20Sopenharmony_ci *		   buggy sensors that generate faulty frames when they are
4938c2ecf20Sopenharmony_ci *		   turned on.
4948c2ecf20Sopenharmony_ci */
4958c2ecf20Sopenharmony_cistruct v4l2_subdev_sensor_ops {
4968c2ecf20Sopenharmony_ci	int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
4978c2ecf20Sopenharmony_ci	int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);
4988c2ecf20Sopenharmony_ci};
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci/**
5018c2ecf20Sopenharmony_ci * enum v4l2_subdev_ir_mode- describes the type of IR supported
5028c2ecf20Sopenharmony_ci *
5038c2ecf20Sopenharmony_ci * @V4L2_SUBDEV_IR_MODE_PULSE_WIDTH: IR uses struct ir_raw_event records
5048c2ecf20Sopenharmony_ci */
5058c2ecf20Sopenharmony_cienum v4l2_subdev_ir_mode {
5068c2ecf20Sopenharmony_ci	V4L2_SUBDEV_IR_MODE_PULSE_WIDTH,
5078c2ecf20Sopenharmony_ci};
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_ci/**
5108c2ecf20Sopenharmony_ci * struct v4l2_subdev_ir_parameters - Parameters for IR TX or TX
5118c2ecf20Sopenharmony_ci *
5128c2ecf20Sopenharmony_ci * @bytes_per_data_element: bytes per data element of data in read or
5138c2ecf20Sopenharmony_ci *	write call.
5148c2ecf20Sopenharmony_ci * @mode: IR mode as defined by &enum v4l2_subdev_ir_mode.
5158c2ecf20Sopenharmony_ci * @enable: device is active if true
5168c2ecf20Sopenharmony_ci * @interrupt_enable: IR interrupts are enabled if true
5178c2ecf20Sopenharmony_ci * @shutdown: if true: set hardware to low/no power, false: normal mode
5188c2ecf20Sopenharmony_ci *
5198c2ecf20Sopenharmony_ci * @modulation: if true, it uses carrier, if false: baseband
5208c2ecf20Sopenharmony_ci * @max_pulse_width:  maximum pulse width in ns, valid only for baseband signal
5218c2ecf20Sopenharmony_ci * @carrier_freq: carrier frequency in Hz, valid only for modulated signal
5228c2ecf20Sopenharmony_ci * @duty_cycle: duty cycle percentage, valid only for modulated signal
5238c2ecf20Sopenharmony_ci * @invert_level: invert signal level
5248c2ecf20Sopenharmony_ci *
5258c2ecf20Sopenharmony_ci * @invert_carrier_sense: Send 0/space as a carrier burst. used only in TX.
5268c2ecf20Sopenharmony_ci *
5278c2ecf20Sopenharmony_ci * @noise_filter_min_width: min time of a valid pulse, in ns. Used only for RX.
5288c2ecf20Sopenharmony_ci * @carrier_range_lower: Lower carrier range, in Hz, valid only for modulated
5298c2ecf20Sopenharmony_ci *	signal. Used only for RX.
5308c2ecf20Sopenharmony_ci * @carrier_range_upper: Upper carrier range, in Hz, valid only for modulated
5318c2ecf20Sopenharmony_ci *	signal. Used only for RX.
5328c2ecf20Sopenharmony_ci * @resolution: The receive resolution, in ns . Used only for RX.
5338c2ecf20Sopenharmony_ci */
5348c2ecf20Sopenharmony_cistruct v4l2_subdev_ir_parameters {
5358c2ecf20Sopenharmony_ci	unsigned int bytes_per_data_element;
5368c2ecf20Sopenharmony_ci	enum v4l2_subdev_ir_mode mode;
5378c2ecf20Sopenharmony_ci
5388c2ecf20Sopenharmony_ci	bool enable;
5398c2ecf20Sopenharmony_ci	bool interrupt_enable;
5408c2ecf20Sopenharmony_ci	bool shutdown;
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_ci	bool modulation;
5438c2ecf20Sopenharmony_ci	u32 max_pulse_width;
5448c2ecf20Sopenharmony_ci	unsigned int carrier_freq;
5458c2ecf20Sopenharmony_ci	unsigned int duty_cycle;
5468c2ecf20Sopenharmony_ci	bool invert_level;
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci	/* Tx only */
5498c2ecf20Sopenharmony_ci	bool invert_carrier_sense;
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_ci	/* Rx only */
5528c2ecf20Sopenharmony_ci	u32 noise_filter_min_width;
5538c2ecf20Sopenharmony_ci	unsigned int carrier_range_lower;
5548c2ecf20Sopenharmony_ci	unsigned int carrier_range_upper;
5558c2ecf20Sopenharmony_ci	u32 resolution;
5568c2ecf20Sopenharmony_ci};
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci/**
5598c2ecf20Sopenharmony_ci * struct v4l2_subdev_ir_ops - operations for IR subdevices
5608c2ecf20Sopenharmony_ci *
5618c2ecf20Sopenharmony_ci * @rx_read: Reads received codes or pulse width data.
5628c2ecf20Sopenharmony_ci *	The semantics are similar to a non-blocking read() call.
5638c2ecf20Sopenharmony_ci * @rx_g_parameters: Get the current operating parameters and state of
5648c2ecf20Sopenharmony_ci *	the IR receiver.
5658c2ecf20Sopenharmony_ci * @rx_s_parameters: Set the current operating parameters and state of
5668c2ecf20Sopenharmony_ci *	the IR receiver.  It is recommended to call
5678c2ecf20Sopenharmony_ci *	[rt]x_g_parameters first to fill out the current state, and only change
5688c2ecf20Sopenharmony_ci *	the fields that need to be changed.  Upon return, the actual device
5698c2ecf20Sopenharmony_ci *	operating parameters and state will be returned.  Note that hardware
5708c2ecf20Sopenharmony_ci *	limitations may prevent the actual settings from matching the requested
5718c2ecf20Sopenharmony_ci *	settings - e.g. an actual carrier setting of 35,904 Hz when 36,000 Hz
5728c2ecf20Sopenharmony_ci *	was requested.  An exception is when the shutdown parameter is true.
5738c2ecf20Sopenharmony_ci *	The last used operational parameters will be returned, but the actual
5748c2ecf20Sopenharmony_ci *	state of the hardware be different to minimize power consumption and
5758c2ecf20Sopenharmony_ci *	processing when shutdown is true.
5768c2ecf20Sopenharmony_ci *
5778c2ecf20Sopenharmony_ci * @tx_write: Writes codes or pulse width data for transmission.
5788c2ecf20Sopenharmony_ci *	The semantics are similar to a non-blocking write() call.
5798c2ecf20Sopenharmony_ci * @tx_g_parameters: Get the current operating parameters and state of
5808c2ecf20Sopenharmony_ci *	the IR transmitter.
5818c2ecf20Sopenharmony_ci * @tx_s_parameters: Set the current operating parameters and state of
5828c2ecf20Sopenharmony_ci *	the IR transmitter.  It is recommended to call
5838c2ecf20Sopenharmony_ci *	[rt]x_g_parameters first to fill out the current state, and only change
5848c2ecf20Sopenharmony_ci *	the fields that need to be changed.  Upon return, the actual device
5858c2ecf20Sopenharmony_ci *	operating parameters and state will be returned.  Note that hardware
5868c2ecf20Sopenharmony_ci *	limitations may prevent the actual settings from matching the requested
5878c2ecf20Sopenharmony_ci *	settings - e.g. an actual carrier setting of 35,904 Hz when 36,000 Hz
5888c2ecf20Sopenharmony_ci *	was requested.  An exception is when the shutdown parameter is true.
5898c2ecf20Sopenharmony_ci *	The last used operational parameters will be returned, but the actual
5908c2ecf20Sopenharmony_ci *	state of the hardware be different to minimize power consumption and
5918c2ecf20Sopenharmony_ci *	processing when shutdown is true.
5928c2ecf20Sopenharmony_ci */
5938c2ecf20Sopenharmony_cistruct v4l2_subdev_ir_ops {
5948c2ecf20Sopenharmony_ci	/* Receiver */
5958c2ecf20Sopenharmony_ci	int (*rx_read)(struct v4l2_subdev *sd, u8 *buf, size_t count,
5968c2ecf20Sopenharmony_ci				ssize_t *num);
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_ci	int (*rx_g_parameters)(struct v4l2_subdev *sd,
5998c2ecf20Sopenharmony_ci				struct v4l2_subdev_ir_parameters *params);
6008c2ecf20Sopenharmony_ci	int (*rx_s_parameters)(struct v4l2_subdev *sd,
6018c2ecf20Sopenharmony_ci				struct v4l2_subdev_ir_parameters *params);
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ci	/* Transmitter */
6048c2ecf20Sopenharmony_ci	int (*tx_write)(struct v4l2_subdev *sd, u8 *buf, size_t count,
6058c2ecf20Sopenharmony_ci				ssize_t *num);
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci	int (*tx_g_parameters)(struct v4l2_subdev *sd,
6088c2ecf20Sopenharmony_ci				struct v4l2_subdev_ir_parameters *params);
6098c2ecf20Sopenharmony_ci	int (*tx_s_parameters)(struct v4l2_subdev *sd,
6108c2ecf20Sopenharmony_ci				struct v4l2_subdev_ir_parameters *params);
6118c2ecf20Sopenharmony_ci};
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci/**
6148c2ecf20Sopenharmony_ci * struct v4l2_subdev_pad_config - Used for storing subdev pad information.
6158c2ecf20Sopenharmony_ci *
6168c2ecf20Sopenharmony_ci * @try_fmt: &struct v4l2_mbus_framefmt
6178c2ecf20Sopenharmony_ci * @try_crop: &struct v4l2_rect to be used for crop
6188c2ecf20Sopenharmony_ci * @try_compose: &struct v4l2_rect to be used for compose
6198c2ecf20Sopenharmony_ci *
6208c2ecf20Sopenharmony_ci * This structure only needs to be passed to the pad op if the 'which' field
6218c2ecf20Sopenharmony_ci * of the main argument is set to %V4L2_SUBDEV_FORMAT_TRY. For
6228c2ecf20Sopenharmony_ci * %V4L2_SUBDEV_FORMAT_ACTIVE it is safe to pass %NULL.
6238c2ecf20Sopenharmony_ci */
6248c2ecf20Sopenharmony_cistruct v4l2_subdev_pad_config {
6258c2ecf20Sopenharmony_ci	struct v4l2_mbus_framefmt try_fmt;
6268c2ecf20Sopenharmony_ci	struct v4l2_rect try_crop;
6278c2ecf20Sopenharmony_ci	struct v4l2_rect try_compose;
6288c2ecf20Sopenharmony_ci};
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci/**
6318c2ecf20Sopenharmony_ci * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
6328c2ecf20Sopenharmony_ci *
6338c2ecf20Sopenharmony_ci * @init_cfg: initialize the pad config to default values
6348c2ecf20Sopenharmony_ci * @enum_mbus_code: callback for VIDIOC_SUBDEV_ENUM_MBUS_CODE() ioctl handler
6358c2ecf20Sopenharmony_ci *		    code.
6368c2ecf20Sopenharmony_ci * @enum_frame_size: callback for VIDIOC_SUBDEV_ENUM_FRAME_SIZE() ioctl handler
6378c2ecf20Sopenharmony_ci *		     code.
6388c2ecf20Sopenharmony_ci *
6398c2ecf20Sopenharmony_ci * @enum_frame_interval: callback for VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL() ioctl
6408c2ecf20Sopenharmony_ci *			 handler code.
6418c2ecf20Sopenharmony_ci *
6428c2ecf20Sopenharmony_ci * @get_fmt: callback for VIDIOC_SUBDEV_G_FMT() ioctl handler code.
6438c2ecf20Sopenharmony_ci *
6448c2ecf20Sopenharmony_ci * @set_fmt: callback for VIDIOC_SUBDEV_S_FMT() ioctl handler code.
6458c2ecf20Sopenharmony_ci *
6468c2ecf20Sopenharmony_ci * @get_selection: callback for VIDIOC_SUBDEV_G_SELECTION() ioctl handler code.
6478c2ecf20Sopenharmony_ci *
6488c2ecf20Sopenharmony_ci * @set_selection: callback for VIDIOC_SUBDEV_S_SELECTION() ioctl handler code.
6498c2ecf20Sopenharmony_ci *
6508c2ecf20Sopenharmony_ci * @get_edid: callback for VIDIOC_SUBDEV_G_EDID() ioctl handler code.
6518c2ecf20Sopenharmony_ci *
6528c2ecf20Sopenharmony_ci * @set_edid: callback for VIDIOC_SUBDEV_S_EDID() ioctl handler code.
6538c2ecf20Sopenharmony_ci *
6548c2ecf20Sopenharmony_ci * @dv_timings_cap: callback for VIDIOC_SUBDEV_DV_TIMINGS_CAP() ioctl handler
6558c2ecf20Sopenharmony_ci *		    code.
6568c2ecf20Sopenharmony_ci *
6578c2ecf20Sopenharmony_ci * @enum_dv_timings: callback for VIDIOC_SUBDEV_ENUM_DV_TIMINGS() ioctl handler
6588c2ecf20Sopenharmony_ci *		     code.
6598c2ecf20Sopenharmony_ci *
6608c2ecf20Sopenharmony_ci * @link_validate: used by the media controller code to check if the links
6618c2ecf20Sopenharmony_ci *		   that belongs to a pipeline can be used for stream.
6628c2ecf20Sopenharmony_ci *
6638c2ecf20Sopenharmony_ci * @get_frame_desc: get the current low level media bus frame parameters.
6648c2ecf20Sopenharmony_ci *
6658c2ecf20Sopenharmony_ci * @set_frame_desc: set the low level media bus frame parameters, @fd array
6668c2ecf20Sopenharmony_ci *                  may be adjusted by the subdev driver to device capabilities.
6678c2ecf20Sopenharmony_ci *
6688c2ecf20Sopenharmony_ci * @get_mbus_config: get the media bus configuration of a remote sub-device.
6698c2ecf20Sopenharmony_ci *		     The media bus configuration is usually retrieved from the
6708c2ecf20Sopenharmony_ci *		     firmware interface at sub-device probe time, immediately
6718c2ecf20Sopenharmony_ci *		     applied to the hardware and eventually adjusted by the
6728c2ecf20Sopenharmony_ci *		     driver. Remote sub-devices (usually video receivers) shall
6738c2ecf20Sopenharmony_ci *		     use this operation to query the transmitting end bus
6748c2ecf20Sopenharmony_ci *		     configuration in order to adjust their own one accordingly.
6758c2ecf20Sopenharmony_ci *		     Callers should make sure they get the most up-to-date as
6768c2ecf20Sopenharmony_ci *		     possible configuration from the remote end, likely calling
6778c2ecf20Sopenharmony_ci *		     this operation as close as possible to stream on time. The
6788c2ecf20Sopenharmony_ci *		     operation shall fail if the pad index it has been called on
6798c2ecf20Sopenharmony_ci *		     is not valid or in case of unrecoverable failures.
6808c2ecf20Sopenharmony_ci *
6818c2ecf20Sopenharmony_ci * @set_mbus_config: set the media bus configuration of a remote sub-device.
6828c2ecf20Sopenharmony_ci *		     This operations is intended to allow, in combination with
6838c2ecf20Sopenharmony_ci *		     the get_mbus_config operation, the negotiation of media bus
6848c2ecf20Sopenharmony_ci *		     configuration parameters between media sub-devices. The
6858c2ecf20Sopenharmony_ci *		     operation shall not fail if the requested configuration is
6868c2ecf20Sopenharmony_ci *		     not supported, but the driver shall update the content of
6878c2ecf20Sopenharmony_ci *		     the %config argument to reflect what has been actually
6888c2ecf20Sopenharmony_ci *		     applied to the hardware. The operation shall fail if the
6898c2ecf20Sopenharmony_ci *		     pad index it has been called on is not valid or in case of
6908c2ecf20Sopenharmony_ci *		     unrecoverable failures.
6918c2ecf20Sopenharmony_ci */
6928c2ecf20Sopenharmony_cistruct v4l2_subdev_pad_ops {
6938c2ecf20Sopenharmony_ci	int (*init_cfg)(struct v4l2_subdev *sd,
6948c2ecf20Sopenharmony_ci			struct v4l2_subdev_pad_config *cfg);
6958c2ecf20Sopenharmony_ci	int (*enum_mbus_code)(struct v4l2_subdev *sd,
6968c2ecf20Sopenharmony_ci			      struct v4l2_subdev_pad_config *cfg,
6978c2ecf20Sopenharmony_ci			      struct v4l2_subdev_mbus_code_enum *code);
6988c2ecf20Sopenharmony_ci	int (*enum_frame_size)(struct v4l2_subdev *sd,
6998c2ecf20Sopenharmony_ci			       struct v4l2_subdev_pad_config *cfg,
7008c2ecf20Sopenharmony_ci			       struct v4l2_subdev_frame_size_enum *fse);
7018c2ecf20Sopenharmony_ci	int (*enum_frame_interval)(struct v4l2_subdev *sd,
7028c2ecf20Sopenharmony_ci				   struct v4l2_subdev_pad_config *cfg,
7038c2ecf20Sopenharmony_ci				   struct v4l2_subdev_frame_interval_enum *fie);
7048c2ecf20Sopenharmony_ci	int (*get_fmt)(struct v4l2_subdev *sd,
7058c2ecf20Sopenharmony_ci		       struct v4l2_subdev_pad_config *cfg,
7068c2ecf20Sopenharmony_ci		       struct v4l2_subdev_format *format);
7078c2ecf20Sopenharmony_ci	int (*set_fmt)(struct v4l2_subdev *sd,
7088c2ecf20Sopenharmony_ci		       struct v4l2_subdev_pad_config *cfg,
7098c2ecf20Sopenharmony_ci		       struct v4l2_subdev_format *format);
7108c2ecf20Sopenharmony_ci	int (*get_selection)(struct v4l2_subdev *sd,
7118c2ecf20Sopenharmony_ci			     struct v4l2_subdev_pad_config *cfg,
7128c2ecf20Sopenharmony_ci			     struct v4l2_subdev_selection *sel);
7138c2ecf20Sopenharmony_ci	int (*set_selection)(struct v4l2_subdev *sd,
7148c2ecf20Sopenharmony_ci			     struct v4l2_subdev_pad_config *cfg,
7158c2ecf20Sopenharmony_ci			     struct v4l2_subdev_selection *sel);
7168c2ecf20Sopenharmony_ci	int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
7178c2ecf20Sopenharmony_ci	int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
7188c2ecf20Sopenharmony_ci	int (*dv_timings_cap)(struct v4l2_subdev *sd,
7198c2ecf20Sopenharmony_ci			      struct v4l2_dv_timings_cap *cap);
7208c2ecf20Sopenharmony_ci	int (*enum_dv_timings)(struct v4l2_subdev *sd,
7218c2ecf20Sopenharmony_ci			       struct v4l2_enum_dv_timings *timings);
7228c2ecf20Sopenharmony_ci#ifdef CONFIG_MEDIA_CONTROLLER
7238c2ecf20Sopenharmony_ci	int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link,
7248c2ecf20Sopenharmony_ci			     struct v4l2_subdev_format *source_fmt,
7258c2ecf20Sopenharmony_ci			     struct v4l2_subdev_format *sink_fmt);
7268c2ecf20Sopenharmony_ci#endif /* CONFIG_MEDIA_CONTROLLER */
7278c2ecf20Sopenharmony_ci	int (*get_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
7288c2ecf20Sopenharmony_ci			      struct v4l2_mbus_frame_desc *fd);
7298c2ecf20Sopenharmony_ci	int (*set_frame_desc)(struct v4l2_subdev *sd, unsigned int pad,
7308c2ecf20Sopenharmony_ci			      struct v4l2_mbus_frame_desc *fd);
7318c2ecf20Sopenharmony_ci	int (*get_mbus_config)(struct v4l2_subdev *sd, unsigned int pad,
7328c2ecf20Sopenharmony_ci			       struct v4l2_mbus_config *config);
7338c2ecf20Sopenharmony_ci	int (*set_mbus_config)(struct v4l2_subdev *sd, unsigned int pad,
7348c2ecf20Sopenharmony_ci			       struct v4l2_mbus_config *config);
7358c2ecf20Sopenharmony_ci};
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_ci/**
7388c2ecf20Sopenharmony_ci * struct v4l2_subdev_ops - Subdev operations
7398c2ecf20Sopenharmony_ci *
7408c2ecf20Sopenharmony_ci * @core: pointer to &struct v4l2_subdev_core_ops. Can be %NULL
7418c2ecf20Sopenharmony_ci * @tuner: pointer to &struct v4l2_subdev_tuner_ops. Can be %NULL
7428c2ecf20Sopenharmony_ci * @audio: pointer to &struct v4l2_subdev_audio_ops. Can be %NULL
7438c2ecf20Sopenharmony_ci * @video: pointer to &struct v4l2_subdev_video_ops. Can be %NULL
7448c2ecf20Sopenharmony_ci * @vbi: pointer to &struct v4l2_subdev_vbi_ops. Can be %NULL
7458c2ecf20Sopenharmony_ci * @ir: pointer to &struct v4l2_subdev_ir_ops. Can be %NULL
7468c2ecf20Sopenharmony_ci * @sensor: pointer to &struct v4l2_subdev_sensor_ops. Can be %NULL
7478c2ecf20Sopenharmony_ci * @pad: pointer to &struct v4l2_subdev_pad_ops. Can be %NULL
7488c2ecf20Sopenharmony_ci */
7498c2ecf20Sopenharmony_cistruct v4l2_subdev_ops {
7508c2ecf20Sopenharmony_ci	const struct v4l2_subdev_core_ops	*core;
7518c2ecf20Sopenharmony_ci	const struct v4l2_subdev_tuner_ops	*tuner;
7528c2ecf20Sopenharmony_ci	const struct v4l2_subdev_audio_ops	*audio;
7538c2ecf20Sopenharmony_ci	const struct v4l2_subdev_video_ops	*video;
7548c2ecf20Sopenharmony_ci	const struct v4l2_subdev_vbi_ops	*vbi;
7558c2ecf20Sopenharmony_ci	const struct v4l2_subdev_ir_ops		*ir;
7568c2ecf20Sopenharmony_ci	const struct v4l2_subdev_sensor_ops	*sensor;
7578c2ecf20Sopenharmony_ci	const struct v4l2_subdev_pad_ops	*pad;
7588c2ecf20Sopenharmony_ci};
7598c2ecf20Sopenharmony_ci
7608c2ecf20Sopenharmony_ci/**
7618c2ecf20Sopenharmony_ci * struct v4l2_subdev_internal_ops - V4L2 subdev internal ops
7628c2ecf20Sopenharmony_ci *
7638c2ecf20Sopenharmony_ci * @registered: called when this subdev is registered. When called the v4l2_dev
7648c2ecf20Sopenharmony_ci *	field is set to the correct v4l2_device.
7658c2ecf20Sopenharmony_ci *
7668c2ecf20Sopenharmony_ci * @unregistered: called when this subdev is unregistered. When called the
7678c2ecf20Sopenharmony_ci *	v4l2_dev field is still set to the correct v4l2_device.
7688c2ecf20Sopenharmony_ci *
7698c2ecf20Sopenharmony_ci * @open: called when the subdev device node is opened by an application.
7708c2ecf20Sopenharmony_ci *
7718c2ecf20Sopenharmony_ci * @close: called when the subdev device node is closed. Please note that
7728c2ecf20Sopenharmony_ci *	it is possible for @close to be called after @unregistered!
7738c2ecf20Sopenharmony_ci *
7748c2ecf20Sopenharmony_ci * @release: called when the last user of the subdev device is gone. This
7758c2ecf20Sopenharmony_ci *	happens after the @unregistered callback and when the last open
7768c2ecf20Sopenharmony_ci *	filehandle to the v4l-subdevX device node was closed. If no device
7778c2ecf20Sopenharmony_ci *	node was created for this sub-device, then the @release callback
7788c2ecf20Sopenharmony_ci *	is called right after the @unregistered callback.
7798c2ecf20Sopenharmony_ci *	The @release callback is typically used to free the memory containing
7808c2ecf20Sopenharmony_ci *	the v4l2_subdev structure. It is almost certainly required for any
7818c2ecf20Sopenharmony_ci *	sub-device that sets the V4L2_SUBDEV_FL_HAS_DEVNODE flag.
7828c2ecf20Sopenharmony_ci *
7838c2ecf20Sopenharmony_ci * .. note::
7848c2ecf20Sopenharmony_ci *	Never call this from drivers, only the v4l2 framework can call
7858c2ecf20Sopenharmony_ci *	these ops.
7868c2ecf20Sopenharmony_ci */
7878c2ecf20Sopenharmony_cistruct v4l2_subdev_internal_ops {
7888c2ecf20Sopenharmony_ci	int (*registered)(struct v4l2_subdev *sd);
7898c2ecf20Sopenharmony_ci	void (*unregistered)(struct v4l2_subdev *sd);
7908c2ecf20Sopenharmony_ci	int (*open)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
7918c2ecf20Sopenharmony_ci	int (*close)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
7928c2ecf20Sopenharmony_ci	void (*release)(struct v4l2_subdev *sd);
7938c2ecf20Sopenharmony_ci};
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_NAME_SIZE 32
7968c2ecf20Sopenharmony_ci
7978c2ecf20Sopenharmony_ci/* Set this flag if this subdev is a i2c device. */
7988c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_FL_IS_I2C			(1U << 0)
7998c2ecf20Sopenharmony_ci/* Set this flag if this subdev is a spi device. */
8008c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_FL_IS_SPI			(1U << 1)
8018c2ecf20Sopenharmony_ci/* Set this flag if this subdev needs a device node. */
8028c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_FL_HAS_DEVNODE		(1U << 2)
8038c2ecf20Sopenharmony_ci/*
8048c2ecf20Sopenharmony_ci * Set this flag if this subdev generates events.
8058c2ecf20Sopenharmony_ci * Note controls can send events, thus drivers exposing controls
8068c2ecf20Sopenharmony_ci * should set this flag.
8078c2ecf20Sopenharmony_ci */
8088c2ecf20Sopenharmony_ci#define V4L2_SUBDEV_FL_HAS_EVENTS		(1U << 3)
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_cistruct regulator_bulk_data;
8118c2ecf20Sopenharmony_ci
8128c2ecf20Sopenharmony_ci/**
8138c2ecf20Sopenharmony_ci * struct v4l2_subdev_platform_data - regulators config struct
8148c2ecf20Sopenharmony_ci *
8158c2ecf20Sopenharmony_ci * @regulators: Optional regulators used to power on/off the subdevice
8168c2ecf20Sopenharmony_ci * @num_regulators: Number of regululators
8178c2ecf20Sopenharmony_ci * @host_priv: Per-subdevice data, specific for a certain video host device
8188c2ecf20Sopenharmony_ci */
8198c2ecf20Sopenharmony_cistruct v4l2_subdev_platform_data {
8208c2ecf20Sopenharmony_ci	struct regulator_bulk_data *regulators;
8218c2ecf20Sopenharmony_ci	int num_regulators;
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_ci	void *host_priv;
8248c2ecf20Sopenharmony_ci};
8258c2ecf20Sopenharmony_ci
8268c2ecf20Sopenharmony_ci/**
8278c2ecf20Sopenharmony_ci * struct v4l2_subdev - describes a V4L2 sub-device
8288c2ecf20Sopenharmony_ci *
8298c2ecf20Sopenharmony_ci * @entity: pointer to &struct media_entity
8308c2ecf20Sopenharmony_ci * @list: List of sub-devices
8318c2ecf20Sopenharmony_ci * @owner: The owner is the same as the driver's &struct device owner.
8328c2ecf20Sopenharmony_ci * @owner_v4l2_dev: true if the &sd->owner matches the owner of @v4l2_dev->dev
8338c2ecf20Sopenharmony_ci *	owner. Initialized by v4l2_device_register_subdev().
8348c2ecf20Sopenharmony_ci * @flags: subdev flags. Can be:
8358c2ecf20Sopenharmony_ci *   %V4L2_SUBDEV_FL_IS_I2C - Set this flag if this subdev is a i2c device;
8368c2ecf20Sopenharmony_ci *   %V4L2_SUBDEV_FL_IS_SPI - Set this flag if this subdev is a spi device;
8378c2ecf20Sopenharmony_ci *   %V4L2_SUBDEV_FL_HAS_DEVNODE - Set this flag if this subdev needs a
8388c2ecf20Sopenharmony_ci *   device node;
8398c2ecf20Sopenharmony_ci *   %V4L2_SUBDEV_FL_HAS_EVENTS -  Set this flag if this subdev generates
8408c2ecf20Sopenharmony_ci *   events.
8418c2ecf20Sopenharmony_ci *
8428c2ecf20Sopenharmony_ci * @v4l2_dev: pointer to struct &v4l2_device
8438c2ecf20Sopenharmony_ci * @ops: pointer to struct &v4l2_subdev_ops
8448c2ecf20Sopenharmony_ci * @internal_ops: pointer to struct &v4l2_subdev_internal_ops.
8458c2ecf20Sopenharmony_ci *	Never call these internal ops from within a driver!
8468c2ecf20Sopenharmony_ci * @ctrl_handler: The control handler of this subdev. May be NULL.
8478c2ecf20Sopenharmony_ci * @name: Name of the sub-device. Please notice that the name must be unique.
8488c2ecf20Sopenharmony_ci * @grp_id: can be used to group similar subdevs. Value is driver-specific
8498c2ecf20Sopenharmony_ci * @dev_priv: pointer to private data
8508c2ecf20Sopenharmony_ci * @host_priv: pointer to private data used by the device where the subdev
8518c2ecf20Sopenharmony_ci *	is attached.
8528c2ecf20Sopenharmony_ci * @devnode: subdev device node
8538c2ecf20Sopenharmony_ci * @dev: pointer to the physical device, if any
8548c2ecf20Sopenharmony_ci * @fwnode: The fwnode_handle of the subdev, usually the same as
8558c2ecf20Sopenharmony_ci *	    either dev->of_node->fwnode or dev->fwnode (whichever is non-NULL).
8568c2ecf20Sopenharmony_ci * @async_list: Links this subdev to a global subdev_list or @notifier->done
8578c2ecf20Sopenharmony_ci *	list.
8588c2ecf20Sopenharmony_ci * @asd: Pointer to respective &struct v4l2_async_subdev.
8598c2ecf20Sopenharmony_ci * @notifier: Pointer to the managing notifier.
8608c2ecf20Sopenharmony_ci * @subdev_notifier: A sub-device notifier implicitly registered for the sub-
8618c2ecf20Sopenharmony_ci *		     device using v4l2_device_register_sensor_subdev().
8628c2ecf20Sopenharmony_ci * @pdata: common part of subdevice platform data
8638c2ecf20Sopenharmony_ci *
8648c2ecf20Sopenharmony_ci * Each instance of a subdev driver should create this struct, either
8658c2ecf20Sopenharmony_ci * stand-alone or embedded in a larger struct.
8668c2ecf20Sopenharmony_ci *
8678c2ecf20Sopenharmony_ci * This structure should be initialized by v4l2_subdev_init() or one of
8688c2ecf20Sopenharmony_ci * its variants: v4l2_spi_subdev_init(), v4l2_i2c_subdev_init().
8698c2ecf20Sopenharmony_ci */
8708c2ecf20Sopenharmony_cistruct v4l2_subdev {
8718c2ecf20Sopenharmony_ci#if defined(CONFIG_MEDIA_CONTROLLER)
8728c2ecf20Sopenharmony_ci	struct media_entity entity;
8738c2ecf20Sopenharmony_ci#endif
8748c2ecf20Sopenharmony_ci	struct list_head list;
8758c2ecf20Sopenharmony_ci	struct module *owner;
8768c2ecf20Sopenharmony_ci	bool owner_v4l2_dev;
8778c2ecf20Sopenharmony_ci	u32 flags;
8788c2ecf20Sopenharmony_ci	struct v4l2_device *v4l2_dev;
8798c2ecf20Sopenharmony_ci	const struct v4l2_subdev_ops *ops;
8808c2ecf20Sopenharmony_ci	const struct v4l2_subdev_internal_ops *internal_ops;
8818c2ecf20Sopenharmony_ci	struct v4l2_ctrl_handler *ctrl_handler;
8828c2ecf20Sopenharmony_ci	char name[V4L2_SUBDEV_NAME_SIZE];
8838c2ecf20Sopenharmony_ci	u32 grp_id;
8848c2ecf20Sopenharmony_ci	void *dev_priv;
8858c2ecf20Sopenharmony_ci	void *host_priv;
8868c2ecf20Sopenharmony_ci	struct video_device *devnode;
8878c2ecf20Sopenharmony_ci	struct device *dev;
8888c2ecf20Sopenharmony_ci	struct fwnode_handle *fwnode;
8898c2ecf20Sopenharmony_ci	struct list_head async_list;
8908c2ecf20Sopenharmony_ci	struct v4l2_async_subdev *asd;
8918c2ecf20Sopenharmony_ci	struct v4l2_async_notifier *notifier;
8928c2ecf20Sopenharmony_ci	struct v4l2_async_notifier *subdev_notifier;
8938c2ecf20Sopenharmony_ci	struct v4l2_subdev_platform_data *pdata;
8948c2ecf20Sopenharmony_ci};
8958c2ecf20Sopenharmony_ci
8968c2ecf20Sopenharmony_ci
8978c2ecf20Sopenharmony_ci/**
8988c2ecf20Sopenharmony_ci * media_entity_to_v4l2_subdev - Returns a &struct v4l2_subdev from
8998c2ecf20Sopenharmony_ci *    the &struct media_entity embedded in it.
9008c2ecf20Sopenharmony_ci *
9018c2ecf20Sopenharmony_ci * @ent: pointer to &struct media_entity.
9028c2ecf20Sopenharmony_ci */
9038c2ecf20Sopenharmony_ci#define media_entity_to_v4l2_subdev(ent)				\
9048c2ecf20Sopenharmony_ci({									\
9058c2ecf20Sopenharmony_ci	typeof(ent) __me_sd_ent = (ent);				\
9068c2ecf20Sopenharmony_ci									\
9078c2ecf20Sopenharmony_ci	__me_sd_ent ?							\
9088c2ecf20Sopenharmony_ci		container_of(__me_sd_ent, struct v4l2_subdev, entity) :	\
9098c2ecf20Sopenharmony_ci		NULL;							\
9108c2ecf20Sopenharmony_ci})
9118c2ecf20Sopenharmony_ci
9128c2ecf20Sopenharmony_ci/**
9138c2ecf20Sopenharmony_ci * vdev_to_v4l2_subdev - Returns a &struct v4l2_subdev from
9148c2ecf20Sopenharmony_ci *	the &struct video_device embedded on it.
9158c2ecf20Sopenharmony_ci *
9168c2ecf20Sopenharmony_ci * @vdev: pointer to &struct video_device
9178c2ecf20Sopenharmony_ci */
9188c2ecf20Sopenharmony_ci#define vdev_to_v4l2_subdev(vdev) \
9198c2ecf20Sopenharmony_ci	((struct v4l2_subdev *)video_get_drvdata(vdev))
9208c2ecf20Sopenharmony_ci
9218c2ecf20Sopenharmony_ci/**
9228c2ecf20Sopenharmony_ci * struct v4l2_subdev_fh - Used for storing subdev information per file handle
9238c2ecf20Sopenharmony_ci *
9248c2ecf20Sopenharmony_ci * @vfh: pointer to &struct v4l2_fh
9258c2ecf20Sopenharmony_ci * @pad: pointer to &struct v4l2_subdev_pad_config
9268c2ecf20Sopenharmony_ci * @owner: module pointer to the owner of this file handle
9278c2ecf20Sopenharmony_ci */
9288c2ecf20Sopenharmony_cistruct v4l2_subdev_fh {
9298c2ecf20Sopenharmony_ci	struct v4l2_fh vfh;
9308c2ecf20Sopenharmony_ci	struct module *owner;
9318c2ecf20Sopenharmony_ci#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
9328c2ecf20Sopenharmony_ci	struct v4l2_subdev_pad_config *pad;
9338c2ecf20Sopenharmony_ci#endif
9348c2ecf20Sopenharmony_ci};
9358c2ecf20Sopenharmony_ci
9368c2ecf20Sopenharmony_ci/**
9378c2ecf20Sopenharmony_ci * to_v4l2_subdev_fh - Returns a &struct v4l2_subdev_fh from
9388c2ecf20Sopenharmony_ci *	the &struct v4l2_fh embedded on it.
9398c2ecf20Sopenharmony_ci *
9408c2ecf20Sopenharmony_ci * @fh: pointer to &struct v4l2_fh
9418c2ecf20Sopenharmony_ci */
9428c2ecf20Sopenharmony_ci#define to_v4l2_subdev_fh(fh)	\
9438c2ecf20Sopenharmony_ci	container_of(fh, struct v4l2_subdev_fh, vfh)
9448c2ecf20Sopenharmony_ci
9458c2ecf20Sopenharmony_ci#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
9468c2ecf20Sopenharmony_ci
9478c2ecf20Sopenharmony_ci/**
9488c2ecf20Sopenharmony_ci * v4l2_subdev_get_try_format - ancillary routine to call
9498c2ecf20Sopenharmony_ci *	&struct v4l2_subdev_pad_config->try_fmt
9508c2ecf20Sopenharmony_ci *
9518c2ecf20Sopenharmony_ci * @sd: pointer to &struct v4l2_subdev
9528c2ecf20Sopenharmony_ci * @cfg: pointer to &struct v4l2_subdev_pad_config array.
9538c2ecf20Sopenharmony_ci * @pad: index of the pad in the @cfg array.
9548c2ecf20Sopenharmony_ci */
9558c2ecf20Sopenharmony_cistatic inline struct v4l2_mbus_framefmt *
9568c2ecf20Sopenharmony_civ4l2_subdev_get_try_format(struct v4l2_subdev *sd,
9578c2ecf20Sopenharmony_ci			   struct v4l2_subdev_pad_config *cfg,
9588c2ecf20Sopenharmony_ci			   unsigned int pad)
9598c2ecf20Sopenharmony_ci{
9608c2ecf20Sopenharmony_ci	if (WARN_ON(pad >= sd->entity.num_pads))
9618c2ecf20Sopenharmony_ci		pad = 0;
9628c2ecf20Sopenharmony_ci	return &cfg[pad].try_fmt;
9638c2ecf20Sopenharmony_ci}
9648c2ecf20Sopenharmony_ci
9658c2ecf20Sopenharmony_ci/**
9668c2ecf20Sopenharmony_ci * v4l2_subdev_get_try_crop - ancillary routine to call
9678c2ecf20Sopenharmony_ci *	&struct v4l2_subdev_pad_config->try_crop
9688c2ecf20Sopenharmony_ci *
9698c2ecf20Sopenharmony_ci * @sd: pointer to &struct v4l2_subdev
9708c2ecf20Sopenharmony_ci * @cfg: pointer to &struct v4l2_subdev_pad_config array.
9718c2ecf20Sopenharmony_ci * @pad: index of the pad in the @cfg array.
9728c2ecf20Sopenharmony_ci */
9738c2ecf20Sopenharmony_cistatic inline struct v4l2_rect *
9748c2ecf20Sopenharmony_civ4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
9758c2ecf20Sopenharmony_ci			 struct v4l2_subdev_pad_config *cfg,
9768c2ecf20Sopenharmony_ci			 unsigned int pad)
9778c2ecf20Sopenharmony_ci{
9788c2ecf20Sopenharmony_ci	if (WARN_ON(pad >= sd->entity.num_pads))
9798c2ecf20Sopenharmony_ci		pad = 0;
9808c2ecf20Sopenharmony_ci	return &cfg[pad].try_crop;
9818c2ecf20Sopenharmony_ci}
9828c2ecf20Sopenharmony_ci
9838c2ecf20Sopenharmony_ci/**
9848c2ecf20Sopenharmony_ci * v4l2_subdev_get_try_compose - ancillary routine to call
9858c2ecf20Sopenharmony_ci *	&struct v4l2_subdev_pad_config->try_compose
9868c2ecf20Sopenharmony_ci *
9878c2ecf20Sopenharmony_ci * @sd: pointer to &struct v4l2_subdev
9888c2ecf20Sopenharmony_ci * @cfg: pointer to &struct v4l2_subdev_pad_config array.
9898c2ecf20Sopenharmony_ci * @pad: index of the pad in the @cfg array.
9908c2ecf20Sopenharmony_ci */
9918c2ecf20Sopenharmony_cistatic inline struct v4l2_rect *
9928c2ecf20Sopenharmony_civ4l2_subdev_get_try_compose(struct v4l2_subdev *sd,
9938c2ecf20Sopenharmony_ci			    struct v4l2_subdev_pad_config *cfg,
9948c2ecf20Sopenharmony_ci			    unsigned int pad)
9958c2ecf20Sopenharmony_ci{
9968c2ecf20Sopenharmony_ci	if (WARN_ON(pad >= sd->entity.num_pads))
9978c2ecf20Sopenharmony_ci		pad = 0;
9988c2ecf20Sopenharmony_ci	return &cfg[pad].try_compose;
9998c2ecf20Sopenharmony_ci}
10008c2ecf20Sopenharmony_ci
10018c2ecf20Sopenharmony_ci#endif
10028c2ecf20Sopenharmony_ci
10038c2ecf20Sopenharmony_ciextern const struct v4l2_file_operations v4l2_subdev_fops;
10048c2ecf20Sopenharmony_ci
10058c2ecf20Sopenharmony_ci/**
10068c2ecf20Sopenharmony_ci * v4l2_set_subdevdata - Sets V4L2 dev private device data
10078c2ecf20Sopenharmony_ci *
10088c2ecf20Sopenharmony_ci * @sd: pointer to &struct v4l2_subdev
10098c2ecf20Sopenharmony_ci * @p: pointer to the private device data to be stored.
10108c2ecf20Sopenharmony_ci */
10118c2ecf20Sopenharmony_cistatic inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
10128c2ecf20Sopenharmony_ci{
10138c2ecf20Sopenharmony_ci	sd->dev_priv = p;
10148c2ecf20Sopenharmony_ci}
10158c2ecf20Sopenharmony_ci
10168c2ecf20Sopenharmony_ci/**
10178c2ecf20Sopenharmony_ci * v4l2_get_subdevdata - Gets V4L2 dev private device data
10188c2ecf20Sopenharmony_ci *
10198c2ecf20Sopenharmony_ci * @sd: pointer to &struct v4l2_subdev
10208c2ecf20Sopenharmony_ci *
10218c2ecf20Sopenharmony_ci * Returns the pointer to the private device data to be stored.
10228c2ecf20Sopenharmony_ci */
10238c2ecf20Sopenharmony_cistatic inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
10248c2ecf20Sopenharmony_ci{
10258c2ecf20Sopenharmony_ci	return sd->dev_priv;
10268c2ecf20Sopenharmony_ci}
10278c2ecf20Sopenharmony_ci
10288c2ecf20Sopenharmony_ci/**
10298c2ecf20Sopenharmony_ci * v4l2_set_subdev_hostdata - Sets V4L2 dev private host data
10308c2ecf20Sopenharmony_ci *
10318c2ecf20Sopenharmony_ci * @sd: pointer to &struct v4l2_subdev
10328c2ecf20Sopenharmony_ci * @p: pointer to the private data to be stored.
10338c2ecf20Sopenharmony_ci */
10348c2ecf20Sopenharmony_cistatic inline void v4l2_set_subdev_hostdata(struct v4l2_subdev *sd, void *p)
10358c2ecf20Sopenharmony_ci{
10368c2ecf20Sopenharmony_ci	sd->host_priv = p;
10378c2ecf20Sopenharmony_ci}
10388c2ecf20Sopenharmony_ci
10398c2ecf20Sopenharmony_ci/**
10408c2ecf20Sopenharmony_ci * v4l2_get_subdev_hostdata - Gets V4L2 dev private data
10418c2ecf20Sopenharmony_ci *
10428c2ecf20Sopenharmony_ci * @sd: pointer to &struct v4l2_subdev
10438c2ecf20Sopenharmony_ci *
10448c2ecf20Sopenharmony_ci * Returns the pointer to the private host data to be stored.
10458c2ecf20Sopenharmony_ci */
10468c2ecf20Sopenharmony_cistatic inline void *v4l2_get_subdev_hostdata(const struct v4l2_subdev *sd)
10478c2ecf20Sopenharmony_ci{
10488c2ecf20Sopenharmony_ci	return sd->host_priv;
10498c2ecf20Sopenharmony_ci}
10508c2ecf20Sopenharmony_ci
10518c2ecf20Sopenharmony_ci#ifdef CONFIG_MEDIA_CONTROLLER
10528c2ecf20Sopenharmony_ci
10538c2ecf20Sopenharmony_ci/**
10548c2ecf20Sopenharmony_ci * v4l2_subdev_get_fwnode_pad_1_to_1 - Get pad number from a subdev fwnode
10558c2ecf20Sopenharmony_ci *                                     endpoint, assuming 1:1 port:pad
10568c2ecf20Sopenharmony_ci *
10578c2ecf20Sopenharmony_ci * @entity: Pointer to the subdev entity
10588c2ecf20Sopenharmony_ci * @endpoint: Pointer to a parsed fwnode endpoint
10598c2ecf20Sopenharmony_ci *
10608c2ecf20Sopenharmony_ci * This function can be used as the .get_fwnode_pad operation for
10618c2ecf20Sopenharmony_ci * subdevices that map port numbers and pad indexes 1:1. If the endpoint
10628c2ecf20Sopenharmony_ci * is owned by the subdevice, the function returns the endpoint port
10638c2ecf20Sopenharmony_ci * number.
10648c2ecf20Sopenharmony_ci *
10658c2ecf20Sopenharmony_ci * Returns the endpoint port number on success or a negative error code.
10668c2ecf20Sopenharmony_ci */
10678c2ecf20Sopenharmony_ciint v4l2_subdev_get_fwnode_pad_1_to_1(struct media_entity *entity,
10688c2ecf20Sopenharmony_ci				      struct fwnode_endpoint *endpoint);
10698c2ecf20Sopenharmony_ci
10708c2ecf20Sopenharmony_ci/**
10718c2ecf20Sopenharmony_ci * v4l2_subdev_link_validate_default - validates a media link
10728c2ecf20Sopenharmony_ci *
10738c2ecf20Sopenharmony_ci * @sd: pointer to &struct v4l2_subdev
10748c2ecf20Sopenharmony_ci * @link: pointer to &struct media_link
10758c2ecf20Sopenharmony_ci * @source_fmt: pointer to &struct v4l2_subdev_format
10768c2ecf20Sopenharmony_ci * @sink_fmt: pointer to &struct v4l2_subdev_format
10778c2ecf20Sopenharmony_ci *
10788c2ecf20Sopenharmony_ci * This function ensures that width, height and the media bus pixel
10798c2ecf20Sopenharmony_ci * code are equal on both source and sink of the link.
10808c2ecf20Sopenharmony_ci */
10818c2ecf20Sopenharmony_ciint v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
10828c2ecf20Sopenharmony_ci				      struct media_link *link,
10838c2ecf20Sopenharmony_ci				      struct v4l2_subdev_format *source_fmt,
10848c2ecf20Sopenharmony_ci				      struct v4l2_subdev_format *sink_fmt);
10858c2ecf20Sopenharmony_ci
10868c2ecf20Sopenharmony_ci/**
10878c2ecf20Sopenharmony_ci * v4l2_subdev_link_validate - validates a media link
10888c2ecf20Sopenharmony_ci *
10898c2ecf20Sopenharmony_ci * @link: pointer to &struct media_link
10908c2ecf20Sopenharmony_ci *
10918c2ecf20Sopenharmony_ci * This function calls the subdev's link_validate ops to validate
10928c2ecf20Sopenharmony_ci * if a media link is valid for streaming. It also internally
10938c2ecf20Sopenharmony_ci * calls v4l2_subdev_link_validate_default() to ensure that
10948c2ecf20Sopenharmony_ci * width, height and the media bus pixel code are equal on both
10958c2ecf20Sopenharmony_ci * source and sink of the link.
10968c2ecf20Sopenharmony_ci */
10978c2ecf20Sopenharmony_ciint v4l2_subdev_link_validate(struct media_link *link);
10988c2ecf20Sopenharmony_ci
10998c2ecf20Sopenharmony_ci/**
11008c2ecf20Sopenharmony_ci * v4l2_subdev_alloc_pad_config - Allocates memory for pad config
11018c2ecf20Sopenharmony_ci *
11028c2ecf20Sopenharmony_ci * @sd: pointer to struct v4l2_subdev
11038c2ecf20Sopenharmony_ci */
11048c2ecf20Sopenharmony_cistruct
11058c2ecf20Sopenharmony_civ4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
11068c2ecf20Sopenharmony_ci
11078c2ecf20Sopenharmony_ci/**
11088c2ecf20Sopenharmony_ci * v4l2_subdev_free_pad_config - Frees memory allocated by
11098c2ecf20Sopenharmony_ci *	v4l2_subdev_alloc_pad_config().
11108c2ecf20Sopenharmony_ci *
11118c2ecf20Sopenharmony_ci * @cfg: pointer to &struct v4l2_subdev_pad_config
11128c2ecf20Sopenharmony_ci */
11138c2ecf20Sopenharmony_civoid v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg);
11148c2ecf20Sopenharmony_ci#endif /* CONFIG_MEDIA_CONTROLLER */
11158c2ecf20Sopenharmony_ci
11168c2ecf20Sopenharmony_ci/**
11178c2ecf20Sopenharmony_ci * v4l2_subdev_init - initializes the sub-device struct
11188c2ecf20Sopenharmony_ci *
11198c2ecf20Sopenharmony_ci * @sd: pointer to the &struct v4l2_subdev to be initialized
11208c2ecf20Sopenharmony_ci * @ops: pointer to &struct v4l2_subdev_ops.
11218c2ecf20Sopenharmony_ci */
11228c2ecf20Sopenharmony_civoid v4l2_subdev_init(struct v4l2_subdev *sd,
11238c2ecf20Sopenharmony_ci		      const struct v4l2_subdev_ops *ops);
11248c2ecf20Sopenharmony_ci
11258c2ecf20Sopenharmony_ciextern const struct v4l2_subdev_ops v4l2_subdev_call_wrappers;
11268c2ecf20Sopenharmony_ci
11278c2ecf20Sopenharmony_ci/**
11288c2ecf20Sopenharmony_ci * v4l2_subdev_call - call an operation of a v4l2_subdev.
11298c2ecf20Sopenharmony_ci *
11308c2ecf20Sopenharmony_ci * @sd: pointer to the &struct v4l2_subdev
11318c2ecf20Sopenharmony_ci * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
11328c2ecf20Sopenharmony_ci *     Each element there groups a set of callbacks functions.
11338c2ecf20Sopenharmony_ci * @f: callback function to be called.
11348c2ecf20Sopenharmony_ci *     The callback functions are defined in groups, according to
11358c2ecf20Sopenharmony_ci *     each element at &struct v4l2_subdev_ops.
11368c2ecf20Sopenharmony_ci * @args: arguments for @f.
11378c2ecf20Sopenharmony_ci *
11388c2ecf20Sopenharmony_ci * Example: err = v4l2_subdev_call(sd, video, s_std, norm);
11398c2ecf20Sopenharmony_ci */
11408c2ecf20Sopenharmony_ci#define v4l2_subdev_call(sd, o, f, args...)				\
11418c2ecf20Sopenharmony_ci	({								\
11428c2ecf20Sopenharmony_ci		struct v4l2_subdev *__sd = (sd);			\
11438c2ecf20Sopenharmony_ci		int __result;						\
11448c2ecf20Sopenharmony_ci		if (!__sd)						\
11458c2ecf20Sopenharmony_ci			__result = -ENODEV;				\
11468c2ecf20Sopenharmony_ci		else if (!(__sd->ops->o && __sd->ops->o->f))		\
11478c2ecf20Sopenharmony_ci			__result = -ENOIOCTLCMD;			\
11488c2ecf20Sopenharmony_ci		else if (v4l2_subdev_call_wrappers.o &&			\
11498c2ecf20Sopenharmony_ci			 v4l2_subdev_call_wrappers.o->f)		\
11508c2ecf20Sopenharmony_ci			__result = v4l2_subdev_call_wrappers.o->f(	\
11518c2ecf20Sopenharmony_ci							__sd, ##args);	\
11528c2ecf20Sopenharmony_ci		else							\
11538c2ecf20Sopenharmony_ci			__result = __sd->ops->o->f(__sd, ##args);	\
11548c2ecf20Sopenharmony_ci		__result;						\
11558c2ecf20Sopenharmony_ci	})
11568c2ecf20Sopenharmony_ci
11578c2ecf20Sopenharmony_ci/**
11588c2ecf20Sopenharmony_ci * v4l2_subdev_has_op - Checks if a subdev defines a certain operation.
11598c2ecf20Sopenharmony_ci *
11608c2ecf20Sopenharmony_ci * @sd: pointer to the &struct v4l2_subdev
11618c2ecf20Sopenharmony_ci * @o: The group of callback functions in &struct v4l2_subdev_ops
11628c2ecf20Sopenharmony_ci * which @f is a part of.
11638c2ecf20Sopenharmony_ci * @f: callback function to be checked for its existence.
11648c2ecf20Sopenharmony_ci */
11658c2ecf20Sopenharmony_ci#define v4l2_subdev_has_op(sd, o, f) \
11668c2ecf20Sopenharmony_ci	((sd)->ops->o && (sd)->ops->o->f)
11678c2ecf20Sopenharmony_ci
11688c2ecf20Sopenharmony_ci/**
11698c2ecf20Sopenharmony_ci * v4l2_subdev_notify_event() - Delivers event notification for subdevice
11708c2ecf20Sopenharmony_ci * @sd: The subdev for which to deliver the event
11718c2ecf20Sopenharmony_ci * @ev: The event to deliver
11728c2ecf20Sopenharmony_ci *
11738c2ecf20Sopenharmony_ci * Will deliver the specified event to all userspace event listeners which are
11748c2ecf20Sopenharmony_ci * subscribed to the v42l subdev event queue as well as to the bridge driver
11758c2ecf20Sopenharmony_ci * using the notify callback. The notification type for the notify callback
11768c2ecf20Sopenharmony_ci * will be %V4L2_DEVICE_NOTIFY_EVENT.
11778c2ecf20Sopenharmony_ci */
11788c2ecf20Sopenharmony_civoid v4l2_subdev_notify_event(struct v4l2_subdev *sd,
11798c2ecf20Sopenharmony_ci			      const struct v4l2_event *ev);
11808c2ecf20Sopenharmony_ci
11818c2ecf20Sopenharmony_ci#endif
1182