Mauro Carvalho Chehab | 6aad127 | 2016-01-29 06:11:30 -0200 | [diff] [blame] | 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 | |
Mauro Carvalho Chehab | db15227 | 2016-02-12 07:35:44 -0200 | [diff] [blame] | 17 | #ifndef _V4L2_MC_H |
| 18 | #define _V4L2_MC_H |
| 19 | |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 20 | #include <media/media-device.h> |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame^] | 21 | #include <media/v4l2-dev.h> |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 22 | |
Mauro Carvalho Chehab | 6aad127 | 2016-01-29 06:11:30 -0200 | [diff] [blame] | 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. |
Mauro Carvalho Chehab | 5c9077e | 2016-01-29 07:00:08 -0200 | [diff] [blame] | 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. |
Mauro Carvalho Chehab | 6aad127 | 2016-01-29 06:11:30 -0200 | [diff] [blame] | 43 | * @TUNER_NUM_PADS: Number of pads of the tuner. |
| 44 | */ |
| 45 | enum tuner_pad_index { |
| 46 | TUNER_PAD_RF_INPUT, |
| 47 | TUNER_PAD_OUTPUT, |
Mauro Carvalho Chehab | 5c9077e | 2016-01-29 07:00:08 -0200 | [diff] [blame] | 48 | TUNER_PAD_AUD_OUT, |
Mauro Carvalho Chehab | 6aad127 | 2016-01-29 06:11:30 -0200 | [diff] [blame] | 49 | TUNER_NUM_PADS |
Mauro Carvalho Chehab | 5c9077e | 2016-01-29 07:00:08 -0200 | [diff] [blame] | 50 | }; |
Mauro Carvalho Chehab | 953a457 | 2016-01-29 07:00:37 -0200 | [diff] [blame] | 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 | */ |
| 61 | enum 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 | */ |
| 78 | enum 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 | }; |
Mauro Carvalho Chehab | e4001e9 | 2016-01-29 07:00:57 -0200 | [diff] [blame] | 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 | */ |
| 92 | enum demod_pad_index { |
| 93 | DEMOD_PAD_IF_INPUT, |
| 94 | DEMOD_PAD_VID_OUT, |
| 95 | DEMOD_PAD_VBI_OUT, |
| 96 | DEMOD_NUM_PADS |
| 97 | }; |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 98 | |
Mauro Carvalho Chehab | eee7d35 | 2016-02-11 15:21:46 -0200 | [diff] [blame] | 99 | /* We don't need to include pci.h or usb.h here */ |
| 100 | struct pci_dev; |
| 101 | struct usb_device; |
Mauro Carvalho Chehab | 7047f29 | 2016-02-05 13:16:18 -0200 | [diff] [blame] | 102 | |
| 103 | #ifdef CONFIG_MEDIA_CONTROLLER |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 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 | */ |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 118 | int v4l2_mc_create_media_graph(struct media_device *mdev); |
Mauro Carvalho Chehab | 7047f29 | 2016-02-05 13:16:18 -0200 | [diff] [blame] | 119 | |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame^] | 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 | */ |
| 136 | int 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 | */ |
| 150 | void 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 | */ |
| 164 | int v4l_vb2q_enable_media_source(struct vb2_queue *q); |
| 165 | |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 166 | #else |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame^] | 167 | |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 168 | static inline int v4l2_mc_create_media_graph(struct media_device *mdev) |
| 169 | { |
| 170 | return 0; |
| 171 | } |
Mauro Carvalho Chehab | 7047f29 | 2016-02-05 13:16:18 -0200 | [diff] [blame] | 172 | |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame^] | 173 | static int v4l_enable_media_source(struct video_device *vdev) |
| 174 | { |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | static void v4l_disable_media_source(struct video_device *vdev) |
| 179 | { |
| 180 | return; |
| 181 | } |
| 182 | |
| 183 | static int v4l_vb2q_enable_media_source(struct vb2_queue *q) |
| 184 | { |
| 185 | return 0; |
| 186 | } |
| 187 | |
Mauro Carvalho Chehab | 54d0dba | 2016-02-05 07:02:43 -0200 | [diff] [blame] | 188 | #endif |
Shuah Khan | d0a164f | 2016-02-11 21:41:25 -0200 | [diff] [blame^] | 189 | #endif /* _V4L2_MC_H */ |