Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Mauro Carvalho Chehab | 6aad127 | 2016-01-29 06:11:30 -0200 | [diff] [blame] | 2 | /* |
| 3 | * v4l2-mc.h - Media Controller V4L2 types and prototypes |
| 4 | * |
Mauro Carvalho Chehab | dc19ed1 | 2016-06-14 14:48:50 -0300 | [diff] [blame] | 5 | * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@kernel.org> |
Sakari Ailus | 7641379 | 2016-02-21 13:25:09 -0300 | [diff] [blame] | 6 | * Copyright (C) 2006-2010 Nokia Corporation |
| 7 | * Copyright (c) 2016 Intel Corporation. |
Mauro Carvalho Chehab | 6aad127 | 2016-01-29 06:11:30 -0200 | [diff] [blame] | 8 | */ |
| 9 | |
Mauro Carvalho Chehab | db15227 | 2016-02-12 07:35:44 -0200 | [diff] [blame] | 10 | #ifndef _V4L2_MC_H |
| 11 | #define _V4L2_MC_H |
| 12 | |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 13 | #include <media/media-device.h> |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 14 | #include <media/v4l2-dev.h> |
Sakari Ailus | 7641379 | 2016-02-21 13:25:09 -0300 | [diff] [blame] | 15 | #include <linux/types.h> |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 16 | |
Mauro Carvalho Chehab | eee7d35 | 2016-02-11 15:21:46 -0200 | [diff] [blame] | 17 | /* We don't need to include pci.h or usb.h here */ |
| 18 | struct pci_dev; |
| 19 | struct usb_device; |
Mauro Carvalho Chehab | 7047f29 | 2016-02-05 13:16:18 -0200 | [diff] [blame] | 20 | |
| 21 | #ifdef CONFIG_MEDIA_CONTROLLER |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 22 | /** |
| 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 at |
| 28 | * 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). |
Mauro Carvalho Chehab | 89cb3dd | 2016-07-17 08:44:08 -0300 | [diff] [blame] | 30 | * |
| 31 | * .. note:: |
| 32 | * |
| 33 | * Webcams are modelled on a very simple way: the sensor is |
| 34 | * connected directly to the I/O entity. All dirty details, like |
| 35 | * scaler and crop HW are hidden. While such mapping is enough for v4l2 |
| 36 | * interface centric PC-consumer's hardware, V4L2 subdev centric camera |
| 37 | * hardware should not use this routine, as it will not build the right graph. |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 38 | */ |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 39 | int v4l2_mc_create_media_graph(struct media_device *mdev); |
Mauro Carvalho Chehab | 7047f29 | 2016-02-05 13:16:18 -0200 | [diff] [blame] | 40 | |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 41 | /** |
| 42 | * v4l_enable_media_source() - Hold media source for exclusive use |
| 43 | * if free |
| 44 | * |
Mauro Carvalho Chehab | 4f27dba | 2016-03-03 12:14:33 -0300 | [diff] [blame] | 45 | * @vdev: pointer to struct video_device |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 46 | * |
| 47 | * This interface calls enable_source handler to determine if |
| 48 | * media source is free for use. The enable_source handler is |
| 49 | * responsible for checking is the media source is free and |
| 50 | * start a pipeline between the media source and the media |
| 51 | * entity associated with the video device. This interface |
| 52 | * should be called from v4l2-core and dvb-core interfaces |
| 53 | * that change the source configuration. |
| 54 | * |
| 55 | * Return: returns zero on success or a negative error code. |
| 56 | */ |
| 57 | int v4l_enable_media_source(struct video_device *vdev); |
| 58 | |
| 59 | /** |
| 60 | * v4l_disable_media_source() - Release media source |
| 61 | * |
Mauro Carvalho Chehab | 4f27dba | 2016-03-03 12:14:33 -0300 | [diff] [blame] | 62 | * @vdev: pointer to struct video_device |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 63 | * |
| 64 | * This interface calls disable_source handler to release |
| 65 | * the media source. The disable_source handler stops the |
| 66 | * active media pipeline between the media source and the |
| 67 | * media entity associated with the video device. |
| 68 | * |
| 69 | * Return: returns zero on success or a negative error code. |
| 70 | */ |
| 71 | void v4l_disable_media_source(struct video_device *vdev); |
| 72 | |
| 73 | /* |
| 74 | * v4l_vb2q_enable_media_tuner - Hold media source for exclusive use |
| 75 | * if free. |
| 76 | * @q - pointer to struct vb2_queue |
| 77 | * |
| 78 | * Wrapper for v4l_enable_media_source(). This function should |
| 79 | * be called from v4l2-core to enable the media source with |
| 80 | * pointer to struct vb2_queue as the input argument. Some |
| 81 | * v4l2-core interfaces don't have access to video device and |
| 82 | * this interface finds the struct video_device for the q and |
| 83 | * calls v4l_enable_media_source(). |
| 84 | */ |
| 85 | int v4l_vb2q_enable_media_source(struct vb2_queue *q); |
| 86 | |
Sakari Ailus | 7641379 | 2016-02-21 13:25:09 -0300 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * v4l2_pipeline_pm_use - Update the use count of an entity |
| 90 | * @entity: The entity |
| 91 | * @use: Use (1) or stop using (0) the entity |
| 92 | * |
| 93 | * Update the use count of all entities in the pipeline and power entities on or |
| 94 | * off accordingly. |
| 95 | * |
| 96 | * This function is intended to be called in video node open (use == |
| 97 | * 1) and release (use == 0). It uses struct media_entity.use_count to |
| 98 | * track the power status. The use of this function should be paired |
| 99 | * with v4l2_pipeline_link_notify(). |
| 100 | * |
| 101 | * Return 0 on success or a negative error code on failure. Powering entities |
| 102 | * off is assumed to never fail. No failure can occur when the use parameter is |
| 103 | * set to 0. |
| 104 | */ |
| 105 | int v4l2_pipeline_pm_use(struct media_entity *entity, int use); |
| 106 | |
| 107 | |
| 108 | /** |
| 109 | * v4l2_pipeline_link_notify - Link management notification callback |
| 110 | * @link: The link |
| 111 | * @flags: New link flags that will be applied |
| 112 | * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*) |
| 113 | * |
| 114 | * React to link management on powered pipelines by updating the use count of |
| 115 | * all entities in the source and sink sides of the link. Entities are powered |
| 116 | * on or off accordingly. The use of this function should be paired |
| 117 | * with v4l2_pipeline_pm_use(). |
| 118 | * |
| 119 | * Return 0 on success or a negative error code on failure. Powering entities |
| 120 | * off is assumed to never fail. This function will not fail for disconnection |
| 121 | * events. |
| 122 | */ |
| 123 | int v4l2_pipeline_link_notify(struct media_link *link, u32 flags, |
| 124 | unsigned int notification); |
| 125 | |
Mauro Carvalho Chehab | a77bf70 | 2016-03-03 12:30:51 -0300 | [diff] [blame] | 126 | #else /* CONFIG_MEDIA_CONTROLLER */ |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 127 | |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 128 | static inline int v4l2_mc_create_media_graph(struct media_device *mdev) |
| 129 | { |
| 130 | return 0; |
| 131 | } |
Mauro Carvalho Chehab | 7047f29 | 2016-02-05 13:16:18 -0200 | [diff] [blame] | 132 | |
Hans Verkuil | 9532e6b | 2016-03-03 04:37:14 -0300 | [diff] [blame] | 133 | static inline int v4l_enable_media_source(struct video_device *vdev) |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 134 | { |
| 135 | return 0; |
| 136 | } |
| 137 | |
Hans Verkuil | 9532e6b | 2016-03-03 04:37:14 -0300 | [diff] [blame] | 138 | static inline void v4l_disable_media_source(struct video_device *vdev) |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 139 | { |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 140 | } |
| 141 | |
Hans Verkuil | 9532e6b | 2016-03-03 04:37:14 -0300 | [diff] [blame] | 142 | static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q) |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 143 | { |
| 144 | return 0; |
| 145 | } |
Mauro Carvalho Chehab | a77bf70 | 2016-03-03 12:30:51 -0300 | [diff] [blame] | 146 | |
Hans Verkuil | 1e89f58 | 2016-03-04 05:46:58 -0300 | [diff] [blame] | 147 | static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use) |
Mauro Carvalho Chehab | a77bf70 | 2016-03-03 12:30:51 -0300 | [diff] [blame] | 148 | { |
| 149 | return 0; |
| 150 | } |
| 151 | |
Hans Verkuil | 1e89f58 | 2016-03-04 05:46:58 -0300 | [diff] [blame] | 152 | static inline int v4l2_pipeline_link_notify(struct media_link *link, u32 flags, |
| 153 | unsigned int notification) |
Mauro Carvalho Chehab | a77bf70 | 2016-03-03 12:30:51 -0300 | [diff] [blame] | 154 | { |
| 155 | return 0; |
| 156 | } |
| 157 | |
| 158 | #endif /* CONFIG_MEDIA_CONTROLLER */ |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame] | 159 | #endif /* _V4L2_MC_H */ |