Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 1 | /* |
| 2 | Functions to query card hardware |
| 3 | Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com> |
| 4 | Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl> |
| 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 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | /* hardware flags */ |
| 22 | #define IVTV_HW_CX25840 (1 << 0) |
| 23 | #define IVTV_HW_SAA7115 (1 << 1) |
| 24 | #define IVTV_HW_SAA7127 (1 << 2) |
| 25 | #define IVTV_HW_MSP34XX (1 << 3) |
| 26 | #define IVTV_HW_TUNER (1 << 4) |
| 27 | #define IVTV_HW_WM8775 (1 << 5) |
| 28 | #define IVTV_HW_CS53L32A (1 << 6) |
| 29 | #define IVTV_HW_TVEEPROM (1 << 7) |
| 30 | #define IVTV_HW_SAA7114 (1 << 8) |
| 31 | #define IVTV_HW_TVAUDIO (1 << 9) |
| 32 | #define IVTV_HW_UPD64031A (1 << 10) |
| 33 | #define IVTV_HW_UPD6408X (1 << 11) |
| 34 | #define IVTV_HW_SAA717X (1 << 12) |
| 35 | #define IVTV_HW_WM8739 (1 << 13) |
| 36 | #define IVTV_HW_GPIO (1 << 14) |
| 37 | |
| 38 | #define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114) |
| 39 | |
| 40 | /* video inputs */ |
| 41 | #define IVTV_CARD_INPUT_VID_TUNER 1 |
| 42 | #define IVTV_CARD_INPUT_SVIDEO1 2 |
| 43 | #define IVTV_CARD_INPUT_SVIDEO2 3 |
| 44 | #define IVTV_CARD_INPUT_COMPOSITE1 4 |
| 45 | #define IVTV_CARD_INPUT_COMPOSITE2 5 |
| 46 | #define IVTV_CARD_INPUT_COMPOSITE3 6 |
| 47 | |
| 48 | /* audio inputs */ |
| 49 | #define IVTV_CARD_INPUT_AUD_TUNER 1 |
| 50 | #define IVTV_CARD_INPUT_LINE_IN1 2 |
| 51 | #define IVTV_CARD_INPUT_LINE_IN2 3 |
| 52 | |
| 53 | #define IVTV_CARD_MAX_VIDEO_INPUTS 6 |
| 54 | #define IVTV_CARD_MAX_AUDIO_INPUTS 3 |
| 55 | #define IVTV_CARD_MAX_TUNERS 2 |
| 56 | |
| 57 | /* SAA71XX HW inputs */ |
| 58 | #define IVTV_SAA71XX_COMPOSITE0 0 |
| 59 | #define IVTV_SAA71XX_COMPOSITE1 1 |
| 60 | #define IVTV_SAA71XX_COMPOSITE2 2 |
| 61 | #define IVTV_SAA71XX_COMPOSITE3 3 |
| 62 | #define IVTV_SAA71XX_COMPOSITE4 4 |
| 63 | #define IVTV_SAA71XX_COMPOSITE5 5 |
| 64 | #define IVTV_SAA71XX_SVIDEO0 6 |
| 65 | #define IVTV_SAA71XX_SVIDEO1 7 |
| 66 | #define IVTV_SAA71XX_SVIDEO2 8 |
| 67 | #define IVTV_SAA71XX_SVIDEO3 9 |
| 68 | |
| 69 | /* SAA717X needs to mark the tuner input by ORing with this flag */ |
| 70 | #define IVTV_SAA717X_TUNER_FLAG 0x80 |
| 71 | |
| 72 | /* Dummy HW input */ |
| 73 | #define IVTV_DUMMY_AUDIO 0 |
| 74 | |
| 75 | /* GPIO HW inputs */ |
| 76 | #define IVTV_GPIO_TUNER 0 |
| 77 | #define IVTV_GPIO_LINE_IN 1 |
| 78 | |
| 79 | /* SAA717X HW inputs */ |
| 80 | #define IVTV_SAA717X_IN0 0 |
| 81 | #define IVTV_SAA717X_IN1 1 |
| 82 | #define IVTV_SAA717X_IN2 2 |
| 83 | |
| 84 | /* V4L2 capability aliases */ |
| 85 | #define IVTV_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ |
| 86 | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE | \ |
| 87 | V4L2_CAP_SLICED_VBI_CAPTURE) |
| 88 | #define IVTV_CAP_DECODER (V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT | \ |
Hans Verkuil | 1f13760 | 2007-05-29 08:18:37 -0300 | [diff] [blame] | 89 | V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_OVERLAY) |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 90 | |
| 91 | struct ivtv_card_video_input { |
| 92 | u8 video_type; /* video input type */ |
| 93 | u8 audio_index; /* index in ivtv_card_audio_input array */ |
| 94 | u16 video_input; /* hardware video input */ |
| 95 | }; |
| 96 | |
| 97 | struct ivtv_card_audio_input { |
| 98 | u8 audio_type; /* audio input type */ |
| 99 | u32 audio_input; /* hardware audio input */ |
| 100 | u16 muxer_input; /* hardware muxer input for boards with a |
| 101 | multiplexer chip */ |
| 102 | }; |
| 103 | |
| 104 | struct ivtv_card_output { |
| 105 | u8 name[32]; |
| 106 | u16 video_output; /* hardware video output */ |
| 107 | }; |
| 108 | |
| 109 | struct ivtv_card_pci_info { |
| 110 | u16 device; |
| 111 | u16 subsystem_vendor; |
| 112 | u16 subsystem_device; |
| 113 | }; |
| 114 | |
| 115 | /* GPIO definitions */ |
| 116 | |
| 117 | /* The mask is the set of bits used by the operation */ |
| 118 | |
| 119 | struct ivtv_gpio_init { /* set initial GPIO DIR and OUT values */ |
| 120 | u16 direction; /* DIR setting. Leave to 0 if no init is needed */ |
| 121 | u16 initial_value; |
| 122 | }; |
| 123 | |
| 124 | struct ivtv_gpio_video_input { /* select tuner/line in input */ |
| 125 | u16 mask; /* leave to 0 if not supported */ |
| 126 | u16 tuner; |
| 127 | u16 composite; |
| 128 | u16 svideo; |
| 129 | }; |
| 130 | |
| 131 | struct ivtv_gpio_audio_input { /* select tuner/line in input */ |
| 132 | u16 mask; /* leave to 0 if not supported */ |
| 133 | u16 tuner; |
| 134 | u16 linein; |
| 135 | u16 radio; |
| 136 | }; |
| 137 | |
| 138 | struct ivtv_gpio_audio_mute { |
| 139 | u16 mask; /* leave to 0 if not supported */ |
| 140 | u16 mute; /* set this value to mute, 0 to unmute */ |
| 141 | }; |
| 142 | |
| 143 | struct ivtv_gpio_audio_mode { |
| 144 | u16 mask; /* leave to 0 if not supported */ |
| 145 | u16 mono; /* set audio to mono */ |
| 146 | u16 stereo; /* set audio to stereo */ |
| 147 | u16 lang1; /* set audio to the first language */ |
| 148 | u16 lang2; /* set audio to the second language */ |
| 149 | u16 both; /* both languages are output */ |
| 150 | }; |
| 151 | |
| 152 | struct ivtv_gpio_audio_freq { |
| 153 | u16 mask; /* leave to 0 if not supported */ |
| 154 | u16 f32000; |
| 155 | u16 f44100; |
| 156 | u16 f48000; |
| 157 | }; |
| 158 | |
| 159 | struct ivtv_gpio_audio_detect { |
| 160 | u16 mask; /* leave to 0 if not supported */ |
| 161 | u16 stereo; /* if the input matches this value then |
| 162 | stereo is detected */ |
| 163 | }; |
| 164 | |
| 165 | struct ivtv_card_tuner { |
| 166 | v4l2_std_id std; /* standard for which the tuner is suitable */ |
| 167 | int tuner; /* tuner ID (from tuner.h) */ |
| 168 | }; |
| 169 | |
| 170 | /* for card information/parameters */ |
| 171 | struct ivtv_card { |
| 172 | int type; |
| 173 | char *name; |
| 174 | u32 v4l2_capabilities; |
| 175 | u32 hw_video; /* hardware used to process video */ |
| 176 | u32 hw_audio; /* hardware used to process audio */ |
| 177 | u32 hw_audio_ctrl; /* hardware used for the V4L2 controls (only 1 dev allowed) */ |
| 178 | u32 hw_muxer; /* hardware used to multiplex audio input */ |
| 179 | u32 hw_all; /* all hardware used by the board */ |
| 180 | struct ivtv_card_video_input video_inputs[IVTV_CARD_MAX_VIDEO_INPUTS]; |
| 181 | struct ivtv_card_audio_input audio_inputs[IVTV_CARD_MAX_AUDIO_INPUTS]; |
| 182 | struct ivtv_card_audio_input radio_input; |
| 183 | int nof_outputs; |
| 184 | const struct ivtv_card_output *video_outputs; |
| 185 | u8 gr_config; /* config byte for the ghost reduction device */ |
| 186 | |
| 187 | /* GPIO card-specific settings */ |
| 188 | struct ivtv_gpio_init gpio_init; |
| 189 | struct ivtv_gpio_video_input gpio_video_input; |
| 190 | struct ivtv_gpio_audio_input gpio_audio_input; |
| 191 | struct ivtv_gpio_audio_mute gpio_audio_mute; |
| 192 | struct ivtv_gpio_audio_mode gpio_audio_mode; |
| 193 | struct ivtv_gpio_audio_freq gpio_audio_freq; |
| 194 | struct ivtv_gpio_audio_detect gpio_audio_detect; |
| 195 | |
| 196 | struct ivtv_card_tuner tuners[IVTV_CARD_MAX_TUNERS]; |
| 197 | |
| 198 | /* list of device and subsystem vendor/devices that |
| 199 | correspond to this card type. */ |
| 200 | const struct ivtv_card_pci_info *pci_list; |
| 201 | }; |
| 202 | |
| 203 | int ivtv_get_input(struct ivtv *itv, u16 index, struct v4l2_input *input); |
| 204 | int ivtv_get_output(struct ivtv *itv, u16 index, struct v4l2_output *output); |
| 205 | int ivtv_get_audio_input(struct ivtv *itv, u16 index, struct v4l2_audio *input); |
| 206 | int ivtv_get_audio_output(struct ivtv *itv, u16 index, struct v4l2_audioout *output); |
| 207 | const struct ivtv_card *ivtv_get_card(u16 index); |