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