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 17 #ifndef _V4L2_MC_H 18 #define _V4L2_MC_H 19 20 #include <media/media-device.h> 21 22 /** 23 * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER 24 * 25 * @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a 26 * RF connector entity. 27 * @TUNER_PAD_OUTPUT: Tuner video output source pad. Contains the video 28 * chrominance and luminance or the hole bandwidth 29 * of the signal converted to an Intermediate Frequency 30 * (IF) or to baseband (on zero-IF tuners). 31 * @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode 32 * analog TV signals have an extra pad for audio output. 33 * Old tuners use an analog stage with a saw filter for 34 * the audio IF frequency. The output of the pad is, in 35 * this case, the audio IF, with should be decoded either 36 * by the bridge chipset (that's the case of cx2388x 37 * chipsets) or may require an external IF sound 38 * processor, like msp34xx. On modern silicon tuners, 39 * the audio IF decoder is usually incorporated at the 40 * tuner. On such case, the output of this pad is an 41 * audio sampled data. 42 * @TUNER_NUM_PADS: Number of pads of the tuner. 43 */ 44 enum tuner_pad_index { 45 TUNER_PAD_RF_INPUT, 46 TUNER_PAD_OUTPUT, 47 TUNER_PAD_AUD_OUT, 48 TUNER_NUM_PADS 49 }; 50 51 /** 52 * enum if_vid_dec_index - video IF-PLL pad index for 53 * MEDIA_ENT_F_IF_VID_DECODER 54 * 55 * @IF_VID_DEC_PAD_IF_INPUT: video Intermediate Frequency (IF) sink pad 56 * @IF_VID_DEC_PAD_OUT: IF-PLL video output source pad. Contains the 57 * video chrominance and luminance IF signals. 58 * @IF_VID_DEC_PAD_NUM_PADS: Number of pads of the video IF-PLL. 59 */ 60 enum if_vid_dec_pad_index { 61 IF_VID_DEC_PAD_IF_INPUT, 62 IF_VID_DEC_PAD_OUT, 63 IF_VID_DEC_PAD_NUM_PADS 64 }; 65 66 /** 67 * enum if_aud_dec_index - audio/sound IF-PLL pad index for 68 * MEDIA_ENT_F_IF_AUD_DECODER 69 * 70 * @IF_AUD_DEC_PAD_IF_INPUT: audio Intermediate Frequency (IF) sink pad 71 * @IF_AUD_DEC_PAD_OUT: IF-PLL audio output source pad. Contains the 72 * audio sampled stream data, usually connected 73 * to the bridge bus via an Inter-IC Sound (I2S) 74 * bus. 75 * @IF_AUD_DEC_PAD_NUM_PADS: Number of pads of the audio IF-PLL. 76 */ 77 enum if_aud_dec_pad_index { 78 IF_AUD_DEC_PAD_IF_INPUT, 79 IF_AUD_DEC_PAD_OUT, 80 IF_AUD_DEC_PAD_NUM_PADS 81 }; 82 83 /** 84 * enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER 85 * 86 * @DEMOD_PAD_IF_INPUT: IF input sink pad. 87 * @DEMOD_PAD_VID_OUT: Video output source pad. 88 * @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad. 89 * @DEMOD_NUM_PADS: Maximum number of output pads. 90 */ 91 enum demod_pad_index { 92 DEMOD_PAD_IF_INPUT, 93 DEMOD_PAD_VID_OUT, 94 DEMOD_PAD_VBI_OUT, 95 DEMOD_NUM_PADS 96 }; 97 98 /* We don't need to include pci.h or usb.h here */ 99 struct pci_dev; 100 struct usb_device; 101 102 #ifdef CONFIG_MEDIA_CONTROLLER 103 /** 104 * v4l2_mc_create_media_graph() - create Media Controller links at the graph. 105 * 106 * @mdev: pointer to the &media_device struct. 107 * 108 * Add links between the entities commonly found on PC customer's hardware at 109 * the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners, 110 * analog TV decoder and I/O entities (video, VBI and Software Defined Radio). 111 * NOTE: webcams are modelled on a very simple way: the sensor is 112 * connected directly to the I/O entity. All dirty details, like 113 * scaler and crop HW are hidden. While such mapping is enough for v4l2 114 * interface centric PC-consumer's hardware, V4L2 subdev centric camera 115 * hardware should not use this routine, as it will not build the right graph. 116 */ 117 int v4l2_mc_create_media_graph(struct media_device *mdev); 118 119 /** 120 * v4l2_mc_pci_media_device_init() - create and initialize a 121 * struct &media_device from a PCI device. 122 * 123 * @pci_dev: pointer to struct pci_dev 124 * @name: media device name. If %NULL, the routine will use the default 125 * name for the pci device, given by pci_name() macro. 126 */ 127 struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev, 128 const char *name); 129 /** 130 * __v4l2_mc_usb_media_device_init() - create and initialize a 131 * struct &media_device from a PCI device. 132 * 133 * @udev: pointer to struct usb_device 134 * @board_name: media device name. If %NULL, the routine will use the usb 135 * product name, if available. 136 * @driver_name: name of the driver. if %NULL, the routine will use the name 137 * given by udev->dev->driver->name, with is usually the wrong 138 * thing to do. 139 * 140 * NOTE: It is better to call v4l2_mc_usb_media_device_init() instead, as 141 * such macro fills driver_name with %KBUILD_MODNAME. 142 */ 143 struct media_device *__v4l2_mc_usb_media_device_init(struct usb_device *udev, 144 const char *board_name, 145 const char *driver_name); 146 147 #else 148 static inline int v4l2_mc_create_media_graph(struct media_device *mdev) 149 { 150 return 0; 151 } 152 153 static inline 154 struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev, 155 char *name) 156 { 157 return NULL; 158 } 159 160 static inline 161 struct media_device *__v4l2_mc_usb_media_device_init(struct usb_device *udev, 162 char *board_name, 163 char *driver_name) 164 { 165 return NULL; 166 } 167 #endif 168 169 #define v4l2_mc_usb_media_device_init(udev, name) \ 170 __v4l2_mc_usb_media_device_init(udev, name, KBUILD_MODNAME) 171 172 #endif 173