]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - include/media/v4l2-mc.h
[media] media: v4l-core add enable/disable source common interfaces
[mirror_ubuntu-hirsute-kernel.git] / include / media / v4l2-mc.h
CommitLineData
6aad127d
MCC
1/*
2 * v4l2-mc.h - Media Controller V4L2 types and prototypes
3 *
4 * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
db152276
MCC
17#ifndef _V4L2_MC_H
18#define _V4L2_MC_H
19
54d0dbac 20#include <media/media-device.h>
d0a164f5 21#include <media/v4l2-dev.h>
54d0dbac 22
6aad127d
MCC
23/**
24 * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER
25 *
26 * @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a
27 * RF connector entity.
5c9077ea
MCC
28 * @TUNER_PAD_OUTPUT: Tuner video output source pad. Contains the video
29 * chrominance and luminance or the hole bandwidth
30 * of the signal converted to an Intermediate Frequency
31 * (IF) or to baseband (on zero-IF tuners).
32 * @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode
33 * analog TV signals have an extra pad for audio output.
34 * Old tuners use an analog stage with a saw filter for
35 * the audio IF frequency. The output of the pad is, in
36 * this case, the audio IF, with should be decoded either
37 * by the bridge chipset (that's the case of cx2388x
38 * chipsets) or may require an external IF sound
39 * processor, like msp34xx. On modern silicon tuners,
40 * the audio IF decoder is usually incorporated at the
41 * tuner. On such case, the output of this pad is an
42 * audio sampled data.
6aad127d
MCC
43 * @TUNER_NUM_PADS: Number of pads of the tuner.
44 */
45enum tuner_pad_index {
46 TUNER_PAD_RF_INPUT,
47 TUNER_PAD_OUTPUT,
5c9077ea 48 TUNER_PAD_AUD_OUT,
6aad127d 49 TUNER_NUM_PADS
5c9077ea 50};
953a457e
MCC
51
52/**
53 * enum if_vid_dec_index - video IF-PLL pad index for
54 * MEDIA_ENT_F_IF_VID_DECODER
55 *
56 * @IF_VID_DEC_PAD_IF_INPUT: video Intermediate Frequency (IF) sink pad
57 * @IF_VID_DEC_PAD_OUT: IF-PLL video output source pad. Contains the
58 * video chrominance and luminance IF signals.
59 * @IF_VID_DEC_PAD_NUM_PADS: Number of pads of the video IF-PLL.
60 */
61enum if_vid_dec_pad_index {
62 IF_VID_DEC_PAD_IF_INPUT,
63 IF_VID_DEC_PAD_OUT,
64 IF_VID_DEC_PAD_NUM_PADS
65};
66
67/**
68 * enum if_aud_dec_index - audio/sound IF-PLL pad index for
69 * MEDIA_ENT_F_IF_AUD_DECODER
70 *
71 * @IF_AUD_DEC_PAD_IF_INPUT: audio Intermediate Frequency (IF) sink pad
72 * @IF_AUD_DEC_PAD_OUT: IF-PLL audio output source pad. Contains the
73 * audio sampled stream data, usually connected
74 * to the bridge bus via an Inter-IC Sound (I2S)
75 * bus.
76 * @IF_AUD_DEC_PAD_NUM_PADS: Number of pads of the audio IF-PLL.
77 */
78enum if_aud_dec_pad_index {
79 IF_AUD_DEC_PAD_IF_INPUT,
80 IF_AUD_DEC_PAD_OUT,
81 IF_AUD_DEC_PAD_NUM_PADS
82};
e4001e95
MCC
83
84/**
85 * enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER
86 *
87 * @DEMOD_PAD_IF_INPUT: IF input sink pad.
88 * @DEMOD_PAD_VID_OUT: Video output source pad.
89 * @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad.
90 * @DEMOD_NUM_PADS: Maximum number of output pads.
91 */
92enum demod_pad_index {
93 DEMOD_PAD_IF_INPUT,
94 DEMOD_PAD_VID_OUT,
95 DEMOD_PAD_VBI_OUT,
96 DEMOD_NUM_PADS
97};
54d0dbac 98
eee7d353
MCC
99/* We don't need to include pci.h or usb.h here */
100struct pci_dev;
101struct usb_device;
7047f298
MCC
102
103#ifdef CONFIG_MEDIA_CONTROLLER
54d0dbac
MCC
104/**
105 * v4l2_mc_create_media_graph() - create Media Controller links at the graph.
106 *
107 * @mdev: pointer to the &media_device struct.
108 *
109 * Add links between the entities commonly found on PC customer's hardware at
110 * the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners,
111 * analog TV decoder and I/O entities (video, VBI and Software Defined Radio).
112 * NOTE: webcams are modelled on a very simple way: the sensor is
113 * connected directly to the I/O entity. All dirty details, like
114 * scaler and crop HW are hidden. While such mapping is enough for v4l2
115 * interface centric PC-consumer's hardware, V4L2 subdev centric camera
116 * hardware should not use this routine, as it will not build the right graph.
117 */
54d0dbac 118int v4l2_mc_create_media_graph(struct media_device *mdev);
7047f298 119
d0a164f5
SK
120/**
121 * v4l_enable_media_source() - Hold media source for exclusive use
122 * if free
123 *
124 * @vdev - poniter to struct video_device
125 *
126 * This interface calls enable_source handler to determine if
127 * media source is free for use. The enable_source handler is
128 * responsible for checking is the media source is free and
129 * start a pipeline between the media source and the media
130 * entity associated with the video device. This interface
131 * should be called from v4l2-core and dvb-core interfaces
132 * that change the source configuration.
133 *
134 * Return: returns zero on success or a negative error code.
135 */
136int v4l_enable_media_source(struct video_device *vdev);
137
138/**
139 * v4l_disable_media_source() - Release media source
140 *
141 * @vdev - poniter to struct video_device
142 *
143 * This interface calls disable_source handler to release
144 * the media source. The disable_source handler stops the
145 * active media pipeline between the media source and the
146 * media entity associated with the video device.
147 *
148 * Return: returns zero on success or a negative error code.
149 */
150void v4l_disable_media_source(struct video_device *vdev);
151
152/*
153 * v4l_vb2q_enable_media_tuner - Hold media source for exclusive use
154 * if free.
155 * @q - pointer to struct vb2_queue
156 *
157 * Wrapper for v4l_enable_media_source(). This function should
158 * be called from v4l2-core to enable the media source with
159 * pointer to struct vb2_queue as the input argument. Some
160 * v4l2-core interfaces don't have access to video device and
161 * this interface finds the struct video_device for the q and
162 * calls v4l_enable_media_source().
163 */
164int v4l_vb2q_enable_media_source(struct vb2_queue *q);
165
54d0dbac 166#else
d0a164f5 167
54d0dbac
MCC
168static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
169{
170 return 0;
171}
7047f298 172
d0a164f5
SK
173static int v4l_enable_media_source(struct video_device *vdev)
174{
175 return 0;
176}
177
178static void v4l_disable_media_source(struct video_device *vdev)
179{
180 return;
181}
182
183static int v4l_vb2q_enable_media_source(struct vb2_queue *q)
184{
185 return 0;
186}
187
54d0dbac 188#endif
d0a164f5 189#endif /* _V4L2_MC_H */