1 /* SPDX-License-Identifier: GPL-2.0-or-later * << 2 /* 1 /* 3 * v4l2-mc.h - Media Controller V4L2 types and 2 * v4l2-mc.h - Media Controller V4L2 types and prototypes 4 * 3 * 5 * Copyright (C) 2016 Mauro Carvalho Chehab <m 4 * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@kernel.org> 6 * Copyright (C) 2006-2010 Nokia Corporation 5 * Copyright (C) 2006-2010 Nokia Corporation 7 * Copyright (c) 2016 Intel Corporation. 6 * Copyright (c) 2016 Intel Corporation. >> 7 * >> 8 * This program is free software; you can redistribute it and/or modify >> 9 * it under the terms of the GNU General Public License as published by >> 10 * the Free Software Foundation; either version 2 of the License, or >> 11 * (at your option) any later version. >> 12 * >> 13 * This program is distributed in the hope that it will be useful, >> 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of >> 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> 16 * GNU General Public License for more details. 8 */ 17 */ 9 18 10 #ifndef _V4L2_MC_H 19 #ifndef _V4L2_MC_H 11 #define _V4L2_MC_H 20 #define _V4L2_MC_H 12 21 13 #include <media/media-device.h> 22 #include <media/media-device.h> 14 #include <media/v4l2-dev.h> 23 #include <media/v4l2-dev.h> 15 #include <media/v4l2-subdev.h> << 16 #include <linux/types.h> 24 #include <linux/types.h> 17 25 18 /* We don't need to include pci.h or usb.h her 26 /* We don't need to include pci.h or usb.h here */ 19 struct pci_dev; 27 struct pci_dev; 20 struct usb_device; 28 struct usb_device; 21 29 22 #ifdef CONFIG_MEDIA_CONTROLLER 30 #ifdef CONFIG_MEDIA_CONTROLLER 23 /** 31 /** 24 * v4l2_mc_create_media_graph() - create Media 32 * v4l2_mc_create_media_graph() - create Media Controller links at the graph. 25 * 33 * 26 * @mdev: pointer to the &media_device s 34 * @mdev: pointer to the &media_device struct. 27 * 35 * 28 * Add links between the entities commonly fou 36 * Add links between the entities commonly found on PC customer's hardware at 29 * the V4L2 side: camera sensors, audio and vi 37 * the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners, 30 * analog TV decoder and I/O entities (video, 38 * analog TV decoder and I/O entities (video, VBI and Software Defined Radio). 31 * 39 * 32 * .. note:: 40 * .. note:: 33 * 41 * 34 * Webcams are modelled on a very simple wa 42 * Webcams are modelled on a very simple way: the sensor is 35 * connected directly to the I/O entity. Al 43 * connected directly to the I/O entity. All dirty details, like 36 * scaler and crop HW are hidden. While suc 44 * scaler and crop HW are hidden. While such mapping is enough for v4l2 37 * interface centric PC-consumer's hardware 45 * interface centric PC-consumer's hardware, V4L2 subdev centric camera 38 * hardware should not use this routine, as 46 * hardware should not use this routine, as it will not build the right graph. 39 */ 47 */ 40 int v4l2_mc_create_media_graph(struct media_de 48 int v4l2_mc_create_media_graph(struct media_device *mdev); 41 49 42 /** 50 /** 43 * v4l_enable_media_source() - Hold media sou 51 * v4l_enable_media_source() - Hold media source for exclusive use 44 * if free 52 * if free 45 * 53 * 46 * @vdev: pointer to struct video_device 54 * @vdev: pointer to struct video_device 47 * 55 * 48 * This interface calls enable_source handler 56 * This interface calls enable_source handler to determine if 49 * media source is free for use. The enable_so 57 * media source is free for use. The enable_source handler is 50 * responsible for checking is the media sourc 58 * responsible for checking is the media source is free and 51 * start a pipeline between the media source a 59 * start a pipeline between the media source and the media 52 * entity associated with the video device. Th 60 * entity associated with the video device. This interface 53 * should be called from v4l2-core and dvb-cor 61 * should be called from v4l2-core and dvb-core interfaces 54 * that change the source configuration. 62 * that change the source configuration. 55 * 63 * 56 * Return: returns zero on success or a negati 64 * Return: returns zero on success or a negative error code. 57 */ 65 */ 58 int v4l_enable_media_source(struct video_devic 66 int v4l_enable_media_source(struct video_device *vdev); 59 67 60 /** 68 /** 61 * v4l_disable_media_source() - Release media 69 * v4l_disable_media_source() - Release media source 62 * 70 * 63 * @vdev: pointer to struct video_device 71 * @vdev: pointer to struct video_device 64 * 72 * 65 * This interface calls disable_source handler 73 * This interface calls disable_source handler to release 66 * the media source. The disable_source handle 74 * the media source. The disable_source handler stops the 67 * active media pipeline between the media sou 75 * active media pipeline between the media source and the 68 * media entity associated with the video devi 76 * media entity associated with the video device. 69 * 77 * 70 * Return: returns zero on success or a negati 78 * Return: returns zero on success or a negative error code. 71 */ 79 */ 72 void v4l_disable_media_source(struct video_dev 80 void v4l_disable_media_source(struct video_device *vdev); 73 81 74 /* 82 /* 75 * v4l_vb2q_enable_media_tuner - Hold media s 83 * v4l_vb2q_enable_media_tuner - Hold media source for exclusive use 76 * if free. 84 * if free. 77 * @q - pointer to struct vb2_queue 85 * @q - pointer to struct vb2_queue 78 * 86 * 79 * Wrapper for v4l_enable_media_source(). This 87 * Wrapper for v4l_enable_media_source(). This function should 80 * be called from v4l2-core to enable the medi 88 * be called from v4l2-core to enable the media source with 81 * pointer to struct vb2_queue as the input ar 89 * pointer to struct vb2_queue as the input argument. Some 82 * v4l2-core interfaces don't have access to v 90 * v4l2-core interfaces don't have access to video device and 83 * this interface finds the struct video_devic 91 * this interface finds the struct video_device for the q and 84 * calls v4l_enable_media_source(). 92 * calls v4l_enable_media_source(). 85 */ 93 */ 86 int v4l_vb2q_enable_media_source(struct vb2_qu 94 int v4l_vb2q_enable_media_source(struct vb2_queue *q); 87 95 88 /** << 89 * v4l2_create_fwnode_links_to_pad - Create fw << 90 * source su << 91 * << 92 * @src_sd: pointer to a source subdev << 93 * @sink: pointer to a sink pad << 94 * @flags: the link flags << 95 * << 96 * This function searches for fwnode endpoint << 97 * subdevice to a single sink pad, and if suit << 98 * translates them into media links to that pa << 99 * called by the sink, in its v4l2-async notif << 100 * links from a bound source subdevice. << 101 * << 102 * The @flags argument specifies the link flag << 103 * the flags are valid regardless of the numbe << 104 * For instance, setting the MEDIA_LNK_FL_ENAB << 105 * links to be enabled, which isn't valid if m << 106 * << 107 * .. note:: << 108 * << 109 * Any sink subdevice that calls this funct << 110 * .get_fwnode_pad media operation in order << 111 * to the sink are owned by the sink. << 112 * << 113 * Return 0 on success or a negative error cod << 114 */ << 115 int v4l2_create_fwnode_links_to_pad(struct v4l << 116 struct med << 117 << 118 /** << 119 * v4l2_create_fwnode_links - Create fwnode-ba << 120 * subdev to a sink << 121 * << 122 * @src_sd: pointer to a source subdevice << 123 * @sink_sd: pointer to a sink subdevice << 124 * << 125 * This function searches for any and all fwno << 126 * between source and sink subdevices, and tra << 127 * links. The function can be called by the si << 128 * v4l2-async notifier subdev bound callback, << 129 * a bound source subdevice. << 130 * << 131 * .. note:: << 132 * << 133 * Any sink subdevice that calls this funct << 134 * .get_fwnode_pad media operation in order << 135 * to the sink are owned by the sink. << 136 * << 137 * Return 0 on success or a negative error cod << 138 */ << 139 int v4l2_create_fwnode_links(struct v4l2_subde << 140 struct v4l2_subde << 141 << 142 /** << 143 * v4l2_pipeline_pm_get - Increase the use cou << 144 * @entity: The root entity of a pipeline << 145 * << 146 * THIS FUNCTION IS DEPRECATED. DO NOT USE IN << 147 * ON SUB-DEVICE DRIVERS INSTEAD. << 148 * << 149 * Update the use count of all entities in the << 150 * << 151 * This function is intended to be called in v << 152 * struct media_entity.use_count to track the << 153 * of this function should be paired with v4l2 << 154 * << 155 * Return 0 on success or a negative error cod << 156 */ << 157 int v4l2_pipeline_pm_get(struct media_entity * << 158 96 159 /** 97 /** 160 * v4l2_pipeline_pm_put - Decrease the use cou !! 98 * v4l2_pipeline_pm_use - Update the use count of an entity 161 * @entity: The root entity of a pipeline !! 99 * @entity: The entity 162 * !! 100 * @use: Use (1) or stop using (0) the entity 163 * THIS FUNCTION IS DEPRECATED. DO NOT USE IN !! 101 * 164 * ON SUB-DEVICE DRIVERS INSTEAD. !! 102 * Update the use count of all entities in the pipeline and power entities on or >> 103 * off accordingly. >> 104 * >> 105 * This function is intended to be called in video node open (use == >> 106 * 1) and release (use == 0). It uses struct media_entity.use_count to >> 107 * track the power status. The use of this function should be paired >> 108 * with v4l2_pipeline_link_notify(). 165 * 109 * 166 * Update the use count of all entities in the !! 110 * Return 0 on success or a negative error code on failure. Powering entities 167 * !! 111 * off is assumed to never fail. No failure can occur when the use parameter is 168 * This function is intended to be called in v !! 112 * set to 0. 169 * struct media_entity.use_count to track the << 170 * of this function should be paired with v4l2 << 171 */ 113 */ 172 void v4l2_pipeline_pm_put(struct media_entity !! 114 int v4l2_pipeline_pm_use(struct media_entity *entity, int use); 173 115 174 116 175 /** 117 /** 176 * v4l2_pipeline_link_notify - Link management 118 * v4l2_pipeline_link_notify - Link management notification callback 177 * @link: The link 119 * @link: The link 178 * @flags: New link flags that will be applied 120 * @flags: New link flags that will be applied 179 * @notification: The link's state change noti 121 * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*) 180 * 122 * 181 * React to link management on powered pipelin 123 * React to link management on powered pipelines by updating the use count of 182 * all entities in the source and sink sides o 124 * all entities in the source and sink sides of the link. Entities are powered 183 * on or off accordingly. The use of this func 125 * on or off accordingly. The use of this function should be paired 184 * with v4l2_pipeline_pm_{get,put}(). !! 126 * with v4l2_pipeline_pm_use(). 185 * 127 * 186 * Return 0 on success or a negative error cod 128 * Return 0 on success or a negative error code on failure. Powering entities 187 * off is assumed to never fail. This function 129 * off is assumed to never fail. This function will not fail for disconnection 188 * events. 130 * events. 189 */ 131 */ 190 int v4l2_pipeline_link_notify(struct media_lin 132 int v4l2_pipeline_link_notify(struct media_link *link, u32 flags, 191 unsigned int not 133 unsigned int notification); 192 134 193 #else /* CONFIG_MEDIA_CONTROLLER */ 135 #else /* CONFIG_MEDIA_CONTROLLER */ 194 136 195 static inline int v4l2_mc_create_media_graph(s 137 static inline int v4l2_mc_create_media_graph(struct media_device *mdev) 196 { 138 { 197 return 0; 139 return 0; 198 } 140 } 199 141 200 static inline int v4l_enable_media_source(stru 142 static inline int v4l_enable_media_source(struct video_device *vdev) 201 { 143 { 202 return 0; 144 return 0; 203 } 145 } 204 146 205 static inline void v4l_disable_media_source(st 147 static inline void v4l_disable_media_source(struct video_device *vdev) 206 { 148 { 207 } 149 } 208 150 209 static inline int v4l_vb2q_enable_media_source 151 static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q) 210 { 152 { 211 return 0; 153 return 0; 212 } 154 } 213 155 214 static inline int v4l2_pipeline_pm_get(struct !! 156 static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use) 215 { 157 { 216 return 0; 158 return 0; 217 } 159 } 218 << 219 static inline void v4l2_pipeline_pm_put(struct << 220 {} << 221 160 222 static inline int v4l2_pipeline_link_notify(st 161 static inline int v4l2_pipeline_link_notify(struct media_link *link, u32 flags, 223 un 162 unsigned int notification) 224 { 163 { 225 return 0; 164 return 0; 226 } 165 } 227 166 228 #endif /* CONFIG_MEDIA_CONTROLLER */ 167 #endif /* CONFIG_MEDIA_CONTROLLER */ 229 #endif /* _V4L2_MC_H */ 168 #endif /* _V4L2_MC_H */ 230 169
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.