0x0000000f
  	   ˆÂÆ0ÃÈ     !ˆÇÆ„}¿ÅÃÈ ?÷     !/* SPDX-License-Identifier: GPL-2.0 */
/*
 *
 *	V 4 L 2   D R I V E R   H E L P E R   A P I
 *
 * Moved from videodev2.h
 *
 *	Some commonly needed functions for drivers (v4l2-common.o module)
 */
#ifndef _V4L2_DEV_H
#define _V4L2_DEV_H

#include <linux/poll.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/cdev.h>
#include <linux/mutex.h>
#include <linux/videodev2.h>

#include <media/media-entity.h>

#define VIDEO_MAJOR	81

/**
 * enum vfl_devnode_type - type of V4L2 device node
 *
 * @VFL_TYPE_VIDEO:	for video input/output devices
 * @VFL_TYPE_VBI:	for vertical blank data (i.e. closed captions, teletext)
 * @VFL_TYPE_RADIO:	for radio tuners
 * @VFL_TYPE_SUBDEV:	for V4L2 subdevices
 * @VFL_TYPE_SDR:	for Software Defined Radio tuners
 * @VFL_TYPE_TOUCH:	for touch sensors
 * @VFL_TYPE_MAX:	number of VFL types, must always be last in the enum
 */
enum vfl_devnode_type {
	VFL_TYPE_VIDEO,
	VFL_TYPE_VBI,
	VFL_TYPE_RADIO,
	VFL_TYPE_SUBDEV,
	VFL_TYPE_SDR,
	VFL_TYPE_TOUCH,
	VFL_TYPE_MAX /* Shall be the last one */
};

/**
 * enum  vfl_devnode_direction - Identifies if a &struct video_device
 * 	corresponds to a receiver, a transmitter or a mem-to-mem device.
 *
 * @VFL_DIR_RX:		device is a receiver.
 * @VFL_DIR_TX:		device is a transmitter.
 * @VFL_DIR_M2M:	device is a memory to memory device.
 *
 * Note: Ignored if &enum vfl_devnode_type is %VFL_TYPE_SUBDEV.
 */
enum vfl_devnode_direction {
	VFL_DIR_RX,
	VFL_DIR_TX,
	VFL_DIR_M2M,
};

struct v4l2_ioctl_callbacks;
struct video_device;
struct v4l2_device;
struct v4l2_ctrl_handler;

/**
 * enum v4l2_video_device_flags - Flags used by &struct video_device
 *
 * @V4L2_FL_REGISTERED:
 *	indicates that a &struct video_device is registered.
 *	Drivers can clear this flag if they want to block all future
 *	device access. It is cleared by video_unregister_device.
 * @V4L2_FL_USES_V4L2_FH:
 *	indicates that file->private_data points to &struct v4l2_fh.
 *	This flag is set by the core when v4l2_fh_init() is called.
 *	All new drivers should use it.
 * @V4L2_FL_QUIRK_INVERTED_CROP:
 *	some old M2M drivers use g/s_crop/cropcap incorrectly: crop and
 *	compose are swapped. If this flag is set, then the selection
 *	targets are swapped in the g/s_crop/cropcap functions in v4l2-ioctl.c.
 *	This allows those drivers to correctly implement the selection API,
 *	but the old crop API will still work as expected in order to preserve
 *	backwards compatibility.
 *	Never set this flag for new drivers.
 * @V4L2_FL_SUBDEV_RO_DEVNODE:
 *	indicates that the video device node is registered in read-only mode.
 *	The flag only applies to device nodes registered for sub-devices, it is
 *	set by the core when the sub-devices device nodes are registered with
 *	v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl
 *	handler to restrict access to some ioctl calls.
 */
enum v4l2_video_device_flags {
	V4L2_FL_REGISTERED		= 0,
	V4L2_FL_USES_V4L2_FH		= 1,
	V4L2_FL_QUIRK_INVERTED_CROP	= 2,
	V4L2_FL_SUBDEV_RO_DEVNODE	= 3,
};

/* Priority helper functions */

/**
 * struct v4l2_prio_state - stores the priority states
 *
 * @prios: array with elements to store the array priorities
 *
 *
 * .. note::
 *    The size of @prios array matches the number of priority types defined
 *    by enum &v4l2_priority.
 */
struct v4l2_prio_state {
	atomic_t prios[4];
};

/**
 * v4l2_prio_init - initializes a struct v4l2_prio_state
 *
 * @global: pointer to &struct v4l2_prio_state
 */
void v4l2_prio_init(struct v4l2_prio_state *global);

/**
 * v4l2_prio_change - changes the v4l2 file handler priority
 *
 * @global: pointer to the &struct v4l2_prio_state of the device node.
 * @local: pointer to the desired priority, as defined by enum &v4l2_priority
 * @new: Priority type requested, as defined by enum &v4l2_priority.
 *
 * .. note::
 *	This function should be used only by the V4L2 core.
 */
int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
		     enum v4l2_priority new);

/**
 * v4l2_prio_open - Implements the p