/* SPDX-License-Identifier: GPL-2.0-or-later */1/*2* v4l2-mc.h - Media Controller V4L2 types and prototypes3*4* Copyright (C) 2016 Mauro Carvalho Chehab <[email protected]>5* Copyright (C) 2006-2010 Nokia Corporation6* Copyright (c) 2016 Intel Corporation.7*/89#ifndef _V4L2_MC_H10#define _V4L2_MC_H1112#include <media/media-device.h>13#include <media/v4l2-dev.h>14#include <media/v4l2-subdev.h>15#include <linux/types.h>1617/* We don't need to include pci.h or usb.h here */18struct pci_dev;19struct usb_device;2021#ifdef CONFIG_MEDIA_CONTROLLER22/**23* v4l2_mc_create_media_graph() - create Media Controller links at the graph.24*25* @mdev: pointer to the &media_device struct.26*27* Add links between the entities commonly found on PC customer's hardware at28* the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners,29* analog TV decoder and I/O entities (video, VBI and Software Defined Radio).30*31* .. note::32*33* Webcams are modelled on a very simple way: the sensor is34* connected directly to the I/O entity. All dirty details, like35* scaler and crop HW are hidden. While such mapping is enough for v4l236* interface centric PC-consumer's hardware, V4L2 subdev centric camera37* hardware should not use this routine, as it will not build the right graph.38*/39int v4l2_mc_create_media_graph(struct media_device *mdev);4041/**42* v4l_enable_media_source() - Hold media source for exclusive use43* if free44*45* @vdev: pointer to struct video_device46*47* This interface calls enable_source handler to determine if48* media source is free for use. The enable_source handler is49* responsible for checking is the media source is free and50* start a pipeline between the media source and the media51* entity associated with the video device. This interface52* should be called from v4l2-core and dvb-core interfaces53* that change the source configuration.54*55* Return: returns zero on success or a negative error code.56*/57int v4l_enable_media_source(struct video_device *vdev);5859/**60* v4l_disable_media_source() - Release media source61*62* @vdev: pointer to struct video_device63*64* This interface calls disable_source handler to release65* the media source. The disable_source handler stops the66* active media pipeline between the media source and the67* media entity associated with the video device.68*69* Return: returns zero on success or a negative error code.70*/71void v4l_disable_media_source(struct video_device *vdev);7273/*74* v4l_vb2q_enable_media_tuner - Hold media source for exclusive use75* if free.76* @q - pointer to struct vb2_queue77*78* Wrapper for v4l_enable_media_source(). This function should79* be called from v4l2-core to enable the media source with80* pointer to struct vb2_queue as the input argument. Some81* v4l2-core interfaces don't have access to video device and82* this interface finds the struct video_device for the q and83* calls v4l_enable_media_source().84*/85int v4l_vb2q_enable_media_source(struct vb2_queue *q);8687/**88* v4l2_create_fwnode_links_to_pad - Create fwnode-based links from a89* source subdev to a sink pad.90*91* @src_sd: pointer to a source subdev92* @sink: pointer to a sink pad93* @flags: the link flags94*95* This function searches for fwnode endpoint connections from a source96* subdevice to a single sink pad, and if suitable connections are found,97* translates them into media links to that pad. The function can be98* called by the sink, in its v4l2-async notifier bound callback, to create99* links from a bound source subdevice.100*101* The @flags argument specifies the link flags. The caller shall ensure that102* the flags are valid regardless of the number of links that may be created.103* For instance, setting the MEDIA_LNK_FL_ENABLED flag will cause all created104* links to be enabled, which isn't valid if more than one link is created.105*106* .. note::107*108* Any sink subdevice that calls this function must implement the109* .get_fwnode_pad media operation in order to verify endpoints passed110* to the sink are owned by the sink.111*112* Return 0 on success or a negative error code on failure.113*/114int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,115struct media_pad *sink, u32 flags);116117/**118* v4l2_create_fwnode_links - Create fwnode-based links from a source119* subdev to a sink subdev.120*121* @src_sd: pointer to a source subdevice122* @sink_sd: pointer to a sink subdevice123*124* This function searches for any and all fwnode endpoint connections125* between source and sink subdevices, and translates them into media126* links. The function can be called by the sink subdevice, in its127* v4l2-async notifier subdev bound callback, to create all links from128* a bound source subdevice.129*130* .. note::131*132* Any sink subdevice that calls this function must implement the133* .get_fwnode_pad media operation in order to verify endpoints passed134* to the sink are owned by the sink.135*136* Return 0 on success or a negative error code on failure.137*/138int v4l2_create_fwnode_links(struct v4l2_subdev *src_sd,139struct v4l2_subdev *sink_sd);140141/**142* v4l2_pipeline_pm_get - Increase the use count of a pipeline143* @entity: The root entity of a pipeline144*145* THIS FUNCTION IS DEPRECATED. DO NOT USE IN NEW DRIVERS. USE RUNTIME PM146* ON SUB-DEVICE DRIVERS INSTEAD.147*148* Update the use count of all entities in the pipeline and power entities on.149*150* This function is intended to be called in video node open. It uses151* struct media_entity.use_count to track the power status. The use152* of this function should be paired with v4l2_pipeline_link_notify().153*154* Return 0 on success or a negative error code on failure.155*/156int v4l2_pipeline_pm_get(struct media_entity *entity);157158/**159* v4l2_pipeline_pm_put - Decrease the use count of a pipeline160* @entity: The root entity of a pipeline161*162* THIS FUNCTION IS DEPRECATED. DO NOT USE IN NEW DRIVERS. USE RUNTIME PM163* ON SUB-DEVICE DRIVERS INSTEAD.164*165* Update the use count of all entities in the pipeline and power entities off.166*167* This function is intended to be called in video node release. It uses168* struct media_entity.use_count to track the power status. The use169* of this function should be paired with v4l2_pipeline_link_notify().170*/171void v4l2_pipeline_pm_put(struct media_entity *entity);172173174/**175* v4l2_pipeline_link_notify - Link management notification callback176* @link: The link177* @flags: New link flags that will be applied178* @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*)179*180* THIS FUNCTION IS DEPRECATED. DO NOT USE IN NEW DRIVERS. USE RUNTIME PM181* ON SUB-DEVICE DRIVERS INSTEAD.182*183* React to link management on powered pipelines by updating the use count of184* all entities in the source and sink sides of the link. Entities are powered185* on or off accordingly. The use of this function should be paired186* with v4l2_pipeline_pm_{get,put}().187*188* Return 0 on success or a negative error code on failure. Powering entities189* off is assumed to never fail. This function will not fail for disconnection190* events.191*/192int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,193unsigned int notification);194195#else /* CONFIG_MEDIA_CONTROLLER */196197static inline int v4l2_mc_create_media_graph(struct media_device *mdev)198{199return 0;200}201202static inline int v4l_enable_media_source(struct video_device *vdev)203{204return 0;205}206207static inline void v4l_disable_media_source(struct video_device *vdev)208{209}210211static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q)212{213return 0;214}215216static inline int v4l2_pipeline_pm_get(struct media_entity *entity)217{218return 0;219}220221static inline void v4l2_pipeline_pm_put(struct media_entity *entity)222{}223224static inline int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,225unsigned int notification)226{227return 0;228}229230#endif /* CONFIG_MEDIA_CONTROLLER */231#endif /* _V4L2_MC_H */232233234