.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * v4l2-mc.h - Media Controller V4L2 types and prototypes |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@kernel.org> |
---|
5 | 6 | * Copyright (C) 2006-2010 Nokia Corporation |
---|
6 | 7 | * 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. |
---|
17 | 8 | */ |
---|
18 | 9 | |
---|
19 | 10 | #ifndef _V4L2_MC_H |
---|
.. | .. |
---|
21 | 12 | |
---|
22 | 13 | #include <media/media-device.h> |
---|
23 | 14 | #include <media/v4l2-dev.h> |
---|
| 15 | +#include <media/v4l2-subdev.h> |
---|
24 | 16 | #include <linux/types.h> |
---|
25 | | - |
---|
26 | | -/** |
---|
27 | | - * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER |
---|
28 | | - * |
---|
29 | | - * @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a |
---|
30 | | - * RF connector entity. |
---|
31 | | - * @TUNER_PAD_OUTPUT: Tuner video output source pad. Contains the video |
---|
32 | | - * chrominance and luminance or the hole bandwidth |
---|
33 | | - * of the signal converted to an Intermediate Frequency |
---|
34 | | - * (IF) or to baseband (on zero-IF tuners). |
---|
35 | | - * @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode |
---|
36 | | - * analog TV signals have an extra pad for audio output. |
---|
37 | | - * Old tuners use an analog stage with a saw filter for |
---|
38 | | - * the audio IF frequency. The output of the pad is, in |
---|
39 | | - * this case, the audio IF, with should be decoded either |
---|
40 | | - * by the bridge chipset (that's the case of cx2388x |
---|
41 | | - * chipsets) or may require an external IF sound |
---|
42 | | - * processor, like msp34xx. On modern silicon tuners, |
---|
43 | | - * the audio IF decoder is usually incorporated at the |
---|
44 | | - * tuner. On such case, the output of this pad is an |
---|
45 | | - * audio sampled data. |
---|
46 | | - * @TUNER_NUM_PADS: Number of pads of the tuner. |
---|
47 | | - */ |
---|
48 | | -enum tuner_pad_index { |
---|
49 | | - TUNER_PAD_RF_INPUT, |
---|
50 | | - TUNER_PAD_OUTPUT, |
---|
51 | | - TUNER_PAD_AUD_OUT, |
---|
52 | | - TUNER_NUM_PADS |
---|
53 | | -}; |
---|
54 | | - |
---|
55 | | -/** |
---|
56 | | - * enum if_vid_dec_pad_index - video IF-PLL pad index for |
---|
57 | | - * MEDIA_ENT_F_IF_VID_DECODER |
---|
58 | | - * |
---|
59 | | - * @IF_VID_DEC_PAD_IF_INPUT: video Intermediate Frequency (IF) sink pad |
---|
60 | | - * @IF_VID_DEC_PAD_OUT: IF-PLL video output source pad. Contains the |
---|
61 | | - * video chrominance and luminance IF signals. |
---|
62 | | - * @IF_VID_DEC_PAD_NUM_PADS: Number of pads of the video IF-PLL. |
---|
63 | | - */ |
---|
64 | | -enum if_vid_dec_pad_index { |
---|
65 | | - IF_VID_DEC_PAD_IF_INPUT, |
---|
66 | | - IF_VID_DEC_PAD_OUT, |
---|
67 | | - IF_VID_DEC_PAD_NUM_PADS |
---|
68 | | -}; |
---|
69 | | - |
---|
70 | | -/** |
---|
71 | | - * enum if_aud_dec_pad_index - audio/sound IF-PLL pad index for |
---|
72 | | - * MEDIA_ENT_F_IF_AUD_DECODER |
---|
73 | | - * |
---|
74 | | - * @IF_AUD_DEC_PAD_IF_INPUT: audio Intermediate Frequency (IF) sink pad |
---|
75 | | - * @IF_AUD_DEC_PAD_OUT: IF-PLL audio output source pad. Contains the |
---|
76 | | - * audio sampled stream data, usually connected |
---|
77 | | - * to the bridge bus via an Inter-IC Sound (I2S) |
---|
78 | | - * bus. |
---|
79 | | - * @IF_AUD_DEC_PAD_NUM_PADS: Number of pads of the audio IF-PLL. |
---|
80 | | - */ |
---|
81 | | -enum if_aud_dec_pad_index { |
---|
82 | | - IF_AUD_DEC_PAD_IF_INPUT, |
---|
83 | | - IF_AUD_DEC_PAD_OUT, |
---|
84 | | - IF_AUD_DEC_PAD_NUM_PADS |
---|
85 | | -}; |
---|
86 | | - |
---|
87 | | -/** |
---|
88 | | - * enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER |
---|
89 | | - * |
---|
90 | | - * @DEMOD_PAD_IF_INPUT: IF input sink pad. |
---|
91 | | - * @DEMOD_PAD_VID_OUT: Video output source pad. |
---|
92 | | - * @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad. |
---|
93 | | - * @DEMOD_PAD_AUDIO_OUT: Audio output source pad. |
---|
94 | | - * @DEMOD_NUM_PADS: Maximum number of output pads. |
---|
95 | | - */ |
---|
96 | | -enum demod_pad_index { |
---|
97 | | - DEMOD_PAD_IF_INPUT, |
---|
98 | | - DEMOD_PAD_VID_OUT, |
---|
99 | | - DEMOD_PAD_VBI_OUT, |
---|
100 | | - DEMOD_PAD_AUDIO_OUT, |
---|
101 | | - DEMOD_NUM_PADS |
---|
102 | | -}; |
---|
103 | 17 | |
---|
104 | 18 | /* We don't need to include pci.h or usb.h here */ |
---|
105 | 19 | struct pci_dev; |
---|
.. | .. |
---|
171 | 85 | */ |
---|
172 | 86 | int v4l_vb2q_enable_media_source(struct vb2_queue *q); |
---|
173 | 87 | |
---|
| 88 | +/** |
---|
| 89 | + * v4l2_create_fwnode_links_to_pad - Create fwnode-based links from a |
---|
| 90 | + * source subdev to a sink subdev pad. |
---|
| 91 | + * |
---|
| 92 | + * @src_sd: pointer to a source subdev |
---|
| 93 | + * @sink: pointer to a subdev sink pad |
---|
| 94 | + * |
---|
| 95 | + * This function searches for fwnode endpoint connections from a source |
---|
| 96 | + * subdevice to a single sink pad, and if suitable connections are found, |
---|
| 97 | + * translates them into media links to that pad. The function can be |
---|
| 98 | + * called by the sink subdevice, in its v4l2-async notifier subdev bound |
---|
| 99 | + * callback, to create links from a bound source subdevice. |
---|
| 100 | + * |
---|
| 101 | + * .. note:: |
---|
| 102 | + * |
---|
| 103 | + * Any sink subdevice that calls this function must implement the |
---|
| 104 | + * .get_fwnode_pad media operation in order to verify endpoints passed |
---|
| 105 | + * to the sink are owned by the sink. |
---|
| 106 | + * |
---|
| 107 | + * Return 0 on success or a negative error code on failure. |
---|
| 108 | + */ |
---|
| 109 | +int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd, |
---|
| 110 | + struct media_pad *sink); |
---|
174 | 111 | |
---|
175 | 112 | /** |
---|
176 | | - * v4l2_pipeline_pm_use - Update the use count of an entity |
---|
177 | | - * @entity: The entity |
---|
178 | | - * @use: Use (1) or stop using (0) the entity |
---|
| 113 | + * v4l2_create_fwnode_links - Create fwnode-based links from a source |
---|
| 114 | + * subdev to a sink subdev. |
---|
179 | 115 | * |
---|
180 | | - * Update the use count of all entities in the pipeline and power entities on or |
---|
181 | | - * off accordingly. |
---|
| 116 | + * @src_sd: pointer to a source subdevice |
---|
| 117 | + * @sink_sd: pointer to a sink subdevice |
---|
182 | 118 | * |
---|
183 | | - * This function is intended to be called in video node open (use == |
---|
184 | | - * 1) and release (use == 0). It uses struct media_entity.use_count to |
---|
185 | | - * track the power status. The use of this function should be paired |
---|
186 | | - * with v4l2_pipeline_link_notify(). |
---|
| 119 | + * This function searches for any and all fwnode endpoint connections |
---|
| 120 | + * between source and sink subdevices, and translates them into media |
---|
| 121 | + * links. The function can be called by the sink subdevice, in its |
---|
| 122 | + * v4l2-async notifier subdev bound callback, to create all links from |
---|
| 123 | + * a bound source subdevice. |
---|
187 | 124 | * |
---|
188 | | - * Return 0 on success or a negative error code on failure. Powering entities |
---|
189 | | - * off is assumed to never fail. No failure can occur when the use parameter is |
---|
190 | | - * set to 0. |
---|
| 125 | + * .. note:: |
---|
| 126 | + * |
---|
| 127 | + * Any sink subdevice that calls this function must implement the |
---|
| 128 | + * .get_fwnode_pad media operation in order to verify endpoints passed |
---|
| 129 | + * to the sink are owned by the sink. |
---|
| 130 | + * |
---|
| 131 | + * Return 0 on success or a negative error code on failure. |
---|
191 | 132 | */ |
---|
192 | | -int v4l2_pipeline_pm_use(struct media_entity *entity, int use); |
---|
| 133 | +int v4l2_create_fwnode_links(struct v4l2_subdev *src_sd, |
---|
| 134 | + struct v4l2_subdev *sink_sd); |
---|
| 135 | + |
---|
| 136 | +/** |
---|
| 137 | + * v4l2_pipeline_pm_get - Increase the use count of a pipeline |
---|
| 138 | + * @entity: The root entity of a pipeline |
---|
| 139 | + * |
---|
| 140 | + * Update the use count of all entities in the pipeline and power entities on. |
---|
| 141 | + * |
---|
| 142 | + * This function is intended to be called in video node open. It uses |
---|
| 143 | + * struct media_entity.use_count to track the power status. The use |
---|
| 144 | + * of this function should be paired with v4l2_pipeline_link_notify(). |
---|
| 145 | + * |
---|
| 146 | + * Return 0 on success or a negative error code on failure. |
---|
| 147 | + */ |
---|
| 148 | +int v4l2_pipeline_pm_get(struct media_entity *entity); |
---|
| 149 | + |
---|
| 150 | +/** |
---|
| 151 | + * v4l2_pipeline_pm_put - Decrease the use count of a pipeline |
---|
| 152 | + * @entity: The root entity of a pipeline |
---|
| 153 | + * |
---|
| 154 | + * Update the use count of all entities in the pipeline and power entities off. |
---|
| 155 | + * |
---|
| 156 | + * This function is intended to be called in video node release. It uses |
---|
| 157 | + * struct media_entity.use_count to track the power status. The use |
---|
| 158 | + * of this function should be paired with v4l2_pipeline_link_notify(). |
---|
| 159 | + */ |
---|
| 160 | +void v4l2_pipeline_pm_put(struct media_entity *entity); |
---|
193 | 161 | |
---|
194 | 162 | |
---|
195 | 163 | /** |
---|
.. | .. |
---|
201 | 169 | * React to link management on powered pipelines by updating the use count of |
---|
202 | 170 | * all entities in the source and sink sides of the link. Entities are powered |
---|
203 | 171 | * on or off accordingly. The use of this function should be paired |
---|
204 | | - * with v4l2_pipeline_pm_use(). |
---|
| 172 | + * with v4l2_pipeline_pm_{get,put}(). |
---|
205 | 173 | * |
---|
206 | 174 | * Return 0 on success or a negative error code on failure. Powering entities |
---|
207 | 175 | * off is assumed to never fail. This function will not fail for disconnection |
---|
.. | .. |
---|
231 | 199 | return 0; |
---|
232 | 200 | } |
---|
233 | 201 | |
---|
234 | | -static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use) |
---|
| 202 | +static inline int v4l2_pipeline_pm_get(struct media_entity *entity) |
---|
235 | 203 | { |
---|
236 | 204 | return 0; |
---|
237 | 205 | } |
---|
238 | 206 | |
---|
| 207 | +static inline void v4l2_pipeline_pm_put(struct media_entity *entity) |
---|
| 208 | +{} |
---|
| 209 | + |
---|
239 | 210 | static inline int v4l2_pipeline_link_notify(struct media_link *link, u32 flags, |
---|
240 | 211 | unsigned int notification) |
---|
241 | 212 | { |
---|