1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3    Functions to query card hardware
4    Copyright (C) 2003-2004  Kevin Thayer <nufan_wfk at yahoo.com>
5    Copyright (C) 2005-2007  Hans Verkuil <hverkuil@xs4all.nl>
6
7 */
8
9#ifndef IVTV_CARDS_H
10#define IVTV_CARDS_H
11
12/* Supported cards */
13#define IVTV_CARD_PVR_250	      0	/* WinTV PVR 250 */
14#define IVTV_CARD_PVR_350	      1	/* encoder, decoder, tv-out */
15#define IVTV_CARD_PVR_150	      2	/* WinTV PVR 150 and PVR 500 (really just two
16					   PVR150s on one PCI board) */
17#define IVTV_CARD_M179		      3	/* AVerMedia M179 (encoder only) */
18#define IVTV_CARD_MPG600	      4	/* Kuroutoshikou ITVC16-STVLP/YUAN MPG600, encoder only */
19#define IVTV_CARD_MPG160	      5	/* Kuroutoshikou ITVC15-STVLP/YUAN MPG160
20					   cx23415 based, but does not have tv-out */
21#define IVTV_CARD_PG600		      6	/* YUAN PG600/DIAMONDMM PVR-550 based on the CX Falcon 2 */
22#define IVTV_CARD_AVC2410	      7	/* Adaptec AVC-2410 */
23#define IVTV_CARD_AVC2010	      8	/* Adaptec AVD-2010 (No Tuner) */
24#define IVTV_CARD_TG5000TV	      9 /* NAGASE TRANSGEAR 5000TV, encoder only */
25#define IVTV_CARD_VA2000MAX_SNT6     10 /* VA2000MAX-STN6 */
26#define IVTV_CARD_CX23416GYC	     11 /* Kuroutoshikou CX23416GYC-STVLP (Yuan MPG600GR OEM) */
27#define IVTV_CARD_GV_MVPRX	     12 /* I/O Data GV-MVP/RX, RX2, RX2W */
28#define IVTV_CARD_GV_MVPRX2E	     13 /* I/O Data GV-MVP/RX2E */
29#define IVTV_CARD_GOTVIEW_PCI_DVD    14	/* GotView PCI DVD */
30#define IVTV_CARD_GOTVIEW_PCI_DVD2   15	/* GotView PCI DVD2 */
31#define IVTV_CARD_YUAN_MPC622        16	/* Yuan MPC622 miniPCI */
32#define IVTV_CARD_DCTMTVP1	     17 /* DIGITAL COWBOY DCT-MTVP1 */
33#define IVTV_CARD_PG600V2	     18 /* Yuan PG600V2/GotView PCI DVD Lite */
34#define IVTV_CARD_CLUB3D	     19 /* Club3D ZAP-TV1x01 */
35#define IVTV_CARD_AVERTV_MCE116	     20 /* AVerTV MCE 116 Plus */
36#define IVTV_CARD_ASUS_FALCON2	     21 /* ASUS Falcon2 */
37#define IVTV_CARD_AVER_PVR150PLUS    22 /* AVerMedia PVR-150 Plus */
38#define IVTV_CARD_AVER_EZMAKER       23 /* AVerMedia EZMaker PCI Deluxe */
39#define IVTV_CARD_AVER_M104          24 /* AverMedia M104 miniPCI card */
40#define IVTV_CARD_BUFFALO_MV5L       25 /* Buffalo PC-MV5L/PCI card */
41#define IVTV_CARD_AVER_ULTRA1500MCE  26 /* AVerMedia UltraTV 1500 MCE */
42#define IVTV_CARD_KIKYOU             27 /* Sony VAIO Giga Pocket (ENX Kikyou) */
43#define IVTV_CARD_LAST		     27
44
45/* Variants of existing cards but with the same PCI IDs. The driver
46   detects these based on other device information.
47   These cards must always come last.
48   New cards must be inserted above, and the indices of the cards below
49   must be adjusted accordingly. */
50
51/* PVR-350 V1 (uses saa7114) */
52#define IVTV_CARD_PVR_350_V1	     (IVTV_CARD_LAST+1)
53/* 2 variants of Kuroutoshikou CX23416GYC-STVLP (Yuan MPG600GR OEM) */
54#define IVTV_CARD_CX23416GYC_NOGR    (IVTV_CARD_LAST+2)
55#define IVTV_CARD_CX23416GYC_NOGRYCS (IVTV_CARD_LAST+3)
56
57/* system vendor and device IDs */
58#define PCI_VENDOR_ID_ICOMP  0x4444
59#define PCI_DEVICE_ID_IVTV15 0x0803
60#define PCI_DEVICE_ID_IVTV16 0x0016
61
62/* subsystem vendor ID */
63#define IVTV_PCI_ID_HAUPPAUGE		0x0070
64#define IVTV_PCI_ID_HAUPPAUGE_ALT1	0x0270
65#define IVTV_PCI_ID_HAUPPAUGE_ALT2	0x4070
66#define IVTV_PCI_ID_ADAPTEC		0x9005
67#define IVTV_PCI_ID_ASUSTEK		0x1043
68#define IVTV_PCI_ID_AVERMEDIA		0x1461
69#define IVTV_PCI_ID_YUAN1		0x12ab
70#define IVTV_PCI_ID_YUAN2		0xff01
71#define IVTV_PCI_ID_YUAN3		0xffab
72#define IVTV_PCI_ID_YUAN4		0xfbab
73#define IVTV_PCI_ID_DIAMONDMM		0xff92
74#define IVTV_PCI_ID_IODATA		0x10fc
75#define IVTV_PCI_ID_MELCO		0x1154
76#define IVTV_PCI_ID_GOTVIEW1		0xffac
77#define IVTV_PCI_ID_GOTVIEW2		0xffad
78#define IVTV_PCI_ID_SONY		0x104d
79
80/* hardware flags, no gaps allowed */
81enum ivtv_hw_bits {
82	IVTV_HW_BIT_CX25840,
83	IVTV_HW_BIT_SAA7115,
84	IVTV_HW_BIT_SAA7127,
85	IVTV_HW_BIT_MSP34XX,
86	IVTV_HW_BIT_TUNER,
87	IVTV_HW_BIT_WM8775,
88	IVTV_HW_BIT_CS53L32A,
89	IVTV_HW_BIT_TVEEPROM,
90	IVTV_HW_BIT_SAA7114,
91	IVTV_HW_BIT_UPD64031A,
92	IVTV_HW_BIT_UPD6408X,
93	IVTV_HW_BIT_SAA717X,
94	IVTV_HW_BIT_WM8739,
95	IVTV_HW_BIT_VP27SMPX,
96	IVTV_HW_BIT_M52790,
97	IVTV_HW_BIT_GPIO,
98	IVTV_HW_BIT_I2C_IR_RX_AVER,
99	IVTV_HW_BIT_I2C_IR_RX_HAUP_EXT,		 /* External before internal */
100	IVTV_HW_BIT_I2C_IR_RX_HAUP_INT,
101	IVTV_HW_BIT_Z8F0811_IR_HAUP,
102	IVTV_HW_BIT_I2C_IR_RX_ADAPTEC,
103
104	IVTV_HW_MAX_BITS	/* Should be the last one */
105};
106
107#define IVTV_HW_CX25840			BIT(IVTV_HW_BIT_CX25840)
108#define IVTV_HW_SAA7115			BIT(IVTV_HW_BIT_SAA7115)
109#define IVTV_HW_SAA7127			BIT(IVTV_HW_BIT_SAA7127)
110#define IVTV_HW_MSP34XX			BIT(IVTV_HW_BIT_MSP34XX)
111#define IVTV_HW_TUNER			BIT(IVTV_HW_BIT_TUNER)
112#define IVTV_HW_WM8775			BIT(IVTV_HW_BIT_WM8775)
113#define IVTV_HW_CS53L32A		BIT(IVTV_HW_BIT_CS53L32A)
114#define IVTV_HW_TVEEPROM		BIT(IVTV_HW_BIT_TVEEPROM)
115#define IVTV_HW_SAA7114			BIT(IVTV_HW_BIT_SAA7114)
116#define IVTV_HW_UPD64031A		BIT(IVTV_HW_BIT_UPD64031A)
117#define IVTV_HW_UPD6408X		BIT(IVTV_HW_BIT_UPD6408X)
118#define IVTV_HW_SAA717X			BIT(IVTV_HW_BIT_SAA717X)
119#define IVTV_HW_WM8739			BIT(IVTV_HW_BIT_WM8739)
120#define IVTV_HW_VP27SMPX		BIT(IVTV_HW_BIT_VP27SMPX)
121#define IVTV_HW_M52790			BIT(IVTV_HW_BIT_M52790)
122#define IVTV_HW_GPIO			BIT(IVTV_HW_BIT_GPIO)
123#define IVTV_HW_I2C_IR_RX_AVER		BIT(IVTV_HW_BIT_I2C_IR_RX_AVER)
124#define IVTV_HW_I2C_IR_RX_HAUP_EXT	BIT(IVTV_HW_BIT_I2C_IR_RX_HAUP_EXT)
125#define IVTV_HW_I2C_IR_RX_HAUP_INT	BIT(IVTV_HW_BIT_I2C_IR_RX_HAUP_INT)
126#define IVTV_HW_Z8F0811_IR_HAUP		BIT(IVTV_HW_BIT_Z8F0811_IR_HAUP)
127#define IVTV_HW_I2C_IR_RX_ADAPTEC	BIT(IVTV_HW_BIT_I2C_IR_RX_ADAPTEC)
128
129#define IVTV_HW_SAA711X   (IVTV_HW_SAA7115 | IVTV_HW_SAA7114)
130
131#define IVTV_HW_IR_ANY (IVTV_HW_I2C_IR_RX_AVER | \
132			IVTV_HW_I2C_IR_RX_HAUP_EXT | \
133			IVTV_HW_I2C_IR_RX_HAUP_INT | \
134			IVTV_HW_Z8F0811_IR_HAUP | \
135			IVTV_HW_I2C_IR_RX_ADAPTEC)
136
137/* video inputs */
138#define	IVTV_CARD_INPUT_VID_TUNER	1
139#define	IVTV_CARD_INPUT_SVIDEO1		2
140#define	IVTV_CARD_INPUT_SVIDEO2		3
141#define	IVTV_CARD_INPUT_COMPOSITE1	4
142#define	IVTV_CARD_INPUT_COMPOSITE2	5
143#define	IVTV_CARD_INPUT_COMPOSITE3	6
144
145/* audio inputs */
146#define	IVTV_CARD_INPUT_AUD_TUNER	1
147#define	IVTV_CARD_INPUT_LINE_IN1	2
148#define	IVTV_CARD_INPUT_LINE_IN2	3
149
150#define IVTV_CARD_MAX_VIDEO_INPUTS 6
151#define IVTV_CARD_MAX_AUDIO_INPUTS 3
152#define IVTV_CARD_MAX_TUNERS	   3
153
154/* SAA71XX HW inputs */
155#define IVTV_SAA71XX_COMPOSITE0 0
156#define IVTV_SAA71XX_COMPOSITE1 1
157#define IVTV_SAA71XX_COMPOSITE2 2
158#define IVTV_SAA71XX_COMPOSITE3 3
159#define IVTV_SAA71XX_COMPOSITE4 4
160#define IVTV_SAA71XX_COMPOSITE5 5
161#define IVTV_SAA71XX_SVIDEO0    6
162#define IVTV_SAA71XX_SVIDEO1    7
163#define IVTV_SAA71XX_SVIDEO2    8
164#define IVTV_SAA71XX_SVIDEO3    9
165
166/* SAA717X needs to mark the tuner input by ORing with this flag */
167#define IVTV_SAA717X_TUNER_FLAG 0x80
168
169/* Dummy HW input */
170#define IVTV_DUMMY_AUDIO        0
171
172/* GPIO HW inputs */
173#define IVTV_GPIO_TUNER   0
174#define IVTV_GPIO_LINE_IN 1
175
176/* SAA717X HW inputs */
177#define IVTV_SAA717X_IN0 0
178#define IVTV_SAA717X_IN1 1
179#define IVTV_SAA717X_IN2 2
180
181/* V4L2 capability aliases */
182#define IVTV_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \
183			  V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE | \
184			  V4L2_CAP_SLICED_VBI_CAPTURE)
185#define IVTV_CAP_DECODER (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_SLICED_VBI_OUTPUT)
186
187struct ivtv_card_video_input {
188	u8  video_type;		/* video input type */
189	u8  audio_index;	/* index in ivtv_card_audio_input array */
190	u16 video_input;	/* hardware video input */
191};
192
193struct ivtv_card_audio_input {
194	u8  audio_type;		/* audio input type */
195	u32 audio_input;	/* hardware audio input */
196	u16 muxer_input;	/* hardware muxer input for boards with a
197				   multiplexer chip */
198};
199
200struct ivtv_card_output {
201	u8  name[32];
202	u16 video_output;  /* hardware video output */
203};
204
205struct ivtv_card_pci_info {
206	u16 device;
207	u16 subsystem_vendor;
208	u16 subsystem_device;
209};
210
211/* GPIO definitions */
212
213/* The mask is the set of bits used by the operation */
214
215struct ivtv_gpio_init {		/* set initial GPIO DIR and OUT values */
216	u16 direction;		/* DIR setting. Leave to 0 if no init is needed */
217	u16 initial_value;
218};
219
220struct ivtv_gpio_video_input {	/* select tuner/line in input */
221	u16 mask;		/* leave to 0 if not supported */
222	u16 tuner;
223	u16 composite;
224	u16 svideo;
225};
226
227struct ivtv_gpio_audio_input {	/* select tuner/line in input */
228	u16 mask;		/* leave to 0 if not supported */
229	u16 tuner;
230	u16 linein;
231	u16 radio;
232};
233
234struct ivtv_gpio_audio_mute {
235	u16 mask;		/* leave to 0 if not supported */
236	u16 mute;		/* set this value to mute, 0 to unmute */
237};
238
239struct ivtv_gpio_audio_mode {
240	u16 mask;		/* leave to 0 if not supported */
241	u16 mono;		/* set audio to mono */
242	u16 stereo;		/* set audio to stereo */
243	u16 lang1;		/* set audio to the first language */
244	u16 lang2;		/* set audio to the second language */
245	u16 both;		/* both languages are output */
246};
247
248struct ivtv_gpio_audio_freq {
249	u16 mask;		/* leave to 0 if not supported */
250	u16 f32000;
251	u16 f44100;
252	u16 f48000;
253};
254
255struct ivtv_gpio_audio_detect {
256	u16 mask;		/* leave to 0 if not supported */
257	u16 stereo;		/* if the input matches this value then
258				   stereo is detected */
259};
260
261struct ivtv_card_tuner {
262	v4l2_std_id std;	/* standard for which the tuner is suitable */
263	int	    tuner;	/* tuner ID (from tuner.h) */
264};
265
266struct ivtv_card_tuner_i2c {
267	unsigned short radio[2];/* radio tuner i2c address to probe */
268	unsigned short demod[2];/* demodulator i2c address to probe */
269	unsigned short tv[4];	/* tv tuner i2c addresses to probe */
270};
271
272/* for card information/parameters */
273struct ivtv_card {
274	int type;
275	char *name;
276	char *comment;
277	u32 v4l2_capabilities;
278	u32 hw_video;		/* hardware used to process video */
279	u32 hw_audio;		/* hardware used to process audio */
280	u32 hw_audio_ctrl;	/* hardware used for the V4L2 controls (only 1 dev allowed) */
281	u32 hw_muxer;		/* hardware used to multiplex audio input */
282	u32 hw_all;		/* all hardware used by the board */
283	struct ivtv_card_video_input video_inputs[IVTV_CARD_MAX_VIDEO_INPUTS];
284	struct ivtv_card_audio_input audio_inputs[IVTV_CARD_MAX_AUDIO_INPUTS];
285	struct ivtv_card_audio_input radio_input;
286	int nof_outputs;
287	const struct ivtv_card_output *video_outputs;
288	u8 gr_config;		/* config byte for the ghost reduction device */
289	u8 xceive_pin;		/* XCeive tuner GPIO reset pin */
290
291	/* GPIO card-specific settings */
292	struct ivtv_gpio_init		gpio_init;
293	struct ivtv_gpio_video_input	gpio_video_input;
294	struct ivtv_gpio_audio_input	gpio_audio_input;
295	struct ivtv_gpio_audio_mute	gpio_audio_mute;
296	struct ivtv_gpio_audio_mode	gpio_audio_mode;
297	struct ivtv_gpio_audio_freq	gpio_audio_freq;
298	struct ivtv_gpio_audio_detect	gpio_audio_detect;
299
300	struct ivtv_card_tuner tuners[IVTV_CARD_MAX_TUNERS];
301	struct ivtv_card_tuner_i2c *i2c;
302
303	/* list of device and subsystem vendor/devices that
304	   correspond to this card type. */
305	const struct ivtv_card_pci_info *pci_list;
306};
307
308int ivtv_get_input(struct ivtv *itv, u16 index, struct v4l2_input *input);
309int ivtv_get_output(struct ivtv *itv, u16 index, struct v4l2_output *output);
310int ivtv_get_audio_input(struct ivtv *itv, u16 index, struct v4l2_audio *input);
311int ivtv_get_audio_output(struct ivtv *itv, u16 index, struct v4l2_audioout *output);
312const struct ivtv_card *ivtv_get_card(u16 index);
313
314#endif
315