Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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-mc.h - Media Controller V4L2 types and prototypes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2006-2010 Nokia Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (c) 2016 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #ifndef _V4L2_MC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define _V4L2_MC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <media/media-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <media/v4l2-dev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <media/v4l2-subdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /* We don't need to include pci.h or usb.h here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) struct pci_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) struct usb_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #ifdef CONFIG_MEDIA_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * v4l2_mc_create_media_graph() - create Media Controller links at the graph.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * @mdev:	pointer to the &media_device struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * Add links between the entities commonly found on PC customer's hardware at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * analog TV decoder and I/O entities (video, VBI and Software Defined Radio).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *    Webcams are modelled on a very simple way: the sensor is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *    connected directly to the I/O entity. All dirty details, like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *    scaler and crop HW are hidden. While such mapping is enough for v4l2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *    interface centric PC-consumer's hardware, V4L2 subdev centric camera
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *    hardware should not use this routine, as it will not build the right graph.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) int v4l2_mc_create_media_graph(struct media_device *mdev);
^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)  * v4l_enable_media_source() -	Hold media source for exclusive use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *				if free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * @vdev:	pointer to struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * This interface calls enable_source handler to determine if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * media source is free for use. The enable_source handler is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * responsible for checking is the media source is free and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * start a pipeline between the media source and the media
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * entity associated with the video device. This interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * should be called from v4l2-core and dvb-core interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * that change the source configuration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * Return: returns zero on success or a negative error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) int v4l_enable_media_source(struct video_device *vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * v4l_disable_media_source() -	Release media source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * @vdev:	pointer to struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * This interface calls disable_source handler to release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * the media source. The disable_source handler stops the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * active media pipeline between the media source and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * media entity associated with the video device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * Return: returns zero on success or a negative error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) void v4l_disable_media_source(struct video_device *vdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * v4l_vb2q_enable_media_tuner -  Hold media source for exclusive use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *				  if free.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * @q - pointer to struct vb2_queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * Wrapper for v4l_enable_media_source(). This function should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * be called from v4l2-core to enable the media source with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * pointer to struct vb2_queue as the input argument. Some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * v4l2-core interfaces don't have access to video device and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * this interface finds the struct video_device for the q and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * calls v4l_enable_media_source().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) int v4l_vb2q_enable_media_source(struct vb2_queue *q);
^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)  * v4l2_create_fwnode_links_to_pad - Create fwnode-based links from a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  *                                   source subdev to a sink subdev pad.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * @src_sd: pointer to a source subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * @sink:  pointer to a subdev sink pad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * This function searches for fwnode endpoint connections from a source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  * subdevice to a single sink pad, and if suitable connections are found,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  * translates them into media links to that pad. The function can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * called by the sink subdevice, in its v4l2-async notifier subdev bound
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * callback, to create links from a bound source subdevice.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *    Any sink subdevice that calls this function must implement the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  *    .get_fwnode_pad media operation in order to verify endpoints passed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *    to the sink are owned by the sink.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * Return 0 on success or a negative error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 				    struct media_pad *sink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * v4l2_create_fwnode_links - Create fwnode-based links from a source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *                            subdev to a sink subdev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * @src_sd: pointer to a source subdevice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * @sink_sd: pointer to a sink subdevice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  * This function searches for any and all fwnode endpoint connections
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * between source and sink subdevices, and translates them into media
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * links. The function can be called by the sink subdevice, in its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  * v4l2-async notifier subdev bound callback, to create all links from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * a bound source subdevice.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *    Any sink subdevice that calls this function must implement the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  *    .get_fwnode_pad media operation in order to verify endpoints passed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  *    to the sink are owned by the sink.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * Return 0 on success or a negative error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int v4l2_create_fwnode_links(struct v4l2_subdev *src_sd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			     struct v4l2_subdev *sink_sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * v4l2_pipeline_pm_get - Increase the use count of a pipeline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * @entity: The root entity of a pipeline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * Update the use count of all entities in the pipeline and power entities on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * This function is intended to be called in video node open. It uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * struct media_entity.use_count to track the power status. The use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  * of this function should be paired with v4l2_pipeline_link_notify().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * Return 0 on success or a negative error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) int v4l2_pipeline_pm_get(struct media_entity *entity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * v4l2_pipeline_pm_put - Decrease the use count of a pipeline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  * @entity: The root entity of a pipeline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * Update the use count of all entities in the pipeline and power entities off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * This function is intended to be called in video node release. It uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * struct media_entity.use_count to track the power status. The use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * of this function should be paired with v4l2_pipeline_link_notify().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) void v4l2_pipeline_pm_put(struct media_entity *entity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * v4l2_pipeline_link_notify - Link management notification callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  * @link: The link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  * @flags: New link flags that will be applied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * React to link management on powered pipelines by updating the use count of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * all entities in the source and sink sides of the link. Entities are powered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * on or off accordingly. The use of this function should be paired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * with v4l2_pipeline_pm_{get,put}().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * Return 0 on success or a negative error code on failure. Powering entities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  * off is assumed to never fail. This function will not fail for disconnection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			      unsigned int notification);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) #else /* CONFIG_MEDIA_CONTROLLER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) static inline int v4l_enable_media_source(struct video_device *vdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static inline void v4l_disable_media_source(struct video_device *vdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) static inline int v4l2_pipeline_pm_get(struct media_entity *entity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) static inline void v4l2_pipeline_pm_put(struct media_entity *entity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static inline int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 					    unsigned int notification)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #endif /* CONFIG_MEDIA_CONTROLLER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #endif /* _V4L2_MC_H */