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