blob: 553adbf2cd44eab938109121e1c388aa93a97f69 [file] [log] [blame]
Hans Verkuil1c1e45d2008-04-28 20:24:33 -03001/*
2 * cx18 functions to query card hardware
3 *
4 * Derived from ivtv-cards.c
5 *
6 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 * 02111-1307 USA
22 */
23
24#include "cx18-driver.h"
25#include "cx18-cards.h"
26#include "cx18-i2c.h"
27#include <media/cs5345.h>
28
29/********************** card configuration *******************************/
30
31/* usual i2c tuner addresses to probe */
32static struct cx18_card_tuner_i2c cx18_i2c_std = {
33 .radio = { I2C_CLIENT_END },
34 .demod = { 0x43, I2C_CLIENT_END },
35 .tv = { 0x61, 0x60, I2C_CLIENT_END },
36};
37
38/* Please add new PCI IDs to: http://pci-ids.ucw.cz/iii
39 This keeps the PCI ID database up to date. Note that the entries
40 must be added under vendor 0x4444 (Conexant) as subsystem IDs.
41 New vendor IDs should still be added to the vendor ID list. */
42
43/* Hauppauge HVR-1600 cards */
44
45/* Note: for Hauppauge cards the tveeprom information is used instead
46 of PCI IDs */
47static const struct cx18_card cx18_card_hvr1600_esmt = {
48 .type = CX18_CARD_HVR_1600_ESMT,
49 .name = "Hauppauge HVR-1600",
Hans Verkuil6b13cf12008-05-12 14:00:33 -030050 .comment = "VBI is not yet supported\n",
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030051 .v4l2_capabilities = CX18_CAP_ENCODER,
52 .hw_audio_ctrl = CX18_HW_CX23418,
53 .hw_muxer = CX18_HW_CS5345,
Hans Verkuil6b13cf12008-05-12 14:00:33 -030054 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
55 CX18_HW_CS5345 | CX18_HW_DVB,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030056 .video_inputs = {
57 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
58 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
59 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 },
60 { CX18_CARD_INPUT_SVIDEO2, 2, CX23418_SVIDEO2 },
61 { CX18_CARD_INPUT_COMPOSITE2, 2, CX23418_COMPOSITE4 },
62 },
63 .audio_inputs = {
64 { CX18_CARD_INPUT_AUD_TUNER,
65 CX23418_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
66 { CX18_CARD_INPUT_LINE_IN1,
67 CX23418_AUDIO_SERIAL, CS5345_IN_2 },
68 { CX18_CARD_INPUT_LINE_IN2,
69 CX23418_AUDIO_SERIAL, CS5345_IN_2 },
70 },
71 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
72 CX23418_AUDIO_SERIAL, 0 },
73 .ddr = {
74 /* ESMT M13S128324A-5B memory */
75 .chip_config = 0x003,
76 .refresh = 0x30c,
77 .timing1 = 0x44220e82,
78 .timing2 = 0x08,
79 .tune_lane = 0,
80 .initial_emrs = 0,
81 },
82 .gpio_init.initial_value = 0x3001,
83 .gpio_init.direction = 0x3001,
84 .i2c = &cx18_i2c_std,
85};
86
87static const struct cx18_card cx18_card_hvr1600_samsung = {
88 .type = CX18_CARD_HVR_1600_SAMSUNG,
89 .name = "Hauppauge HVR-1600 (Preproduction)",
Hans Verkuil1d081602008-05-12 14:45:19 -030090 .comment = "VBI is not yet supported\n",
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030091 .v4l2_capabilities = CX18_CAP_ENCODER,
92 .hw_audio_ctrl = CX18_HW_CX23418,
93 .hw_muxer = CX18_HW_CS5345,
Hans Verkuil1d081602008-05-12 14:45:19 -030094 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
95 CX18_HW_CS5345 | CX18_HW_DVB,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030096 .video_inputs = {
97 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
98 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
99 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 },
100 { CX18_CARD_INPUT_SVIDEO2, 2, CX23418_SVIDEO2 },
101 { CX18_CARD_INPUT_COMPOSITE2, 2, CX23418_COMPOSITE4 },
102 },
103 .audio_inputs = {
104 { CX18_CARD_INPUT_AUD_TUNER,
105 CX23418_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
106 { CX18_CARD_INPUT_LINE_IN1,
107 CX23418_AUDIO_SERIAL, CS5345_IN_2 },
108 { CX18_CARD_INPUT_LINE_IN2,
109 CX23418_AUDIO_SERIAL, CS5345_IN_2 },
110 },
111 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
112 CX23418_AUDIO_SERIAL, 0 },
113 .ddr = {
114 /* Samsung K4D263238G-VC33 memory */
115 .chip_config = 0x003,
116 .refresh = 0x30c,
117 .timing1 = 0x23230b73,
118 .timing2 = 0x08,
119 .tune_lane = 0,
120 .initial_emrs = 2,
121 },
122 .gpio_init.initial_value = 0x3001,
123 .gpio_init.direction = 0x3001,
124 .i2c = &cx18_i2c_std,
125};
126
127/* ------------------------------------------------------------------------- */
128
129/* Compro VideoMate H900: not working at the moment! */
130
131static const struct cx18_card_pci_info cx18_pci_h900[] = {
132 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
133 { 0, 0, 0 }
134};
135
136static const struct cx18_card cx18_card_h900 = {
137 .type = CX18_CARD_COMPRO_H900,
138 .name = "Compro VideoMate H900",
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300139 .comment = "DVB & VBI are not yet supported\n",
140 .v4l2_capabilities = CX18_CAP_ENCODER,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300141 .hw_audio_ctrl = CX18_HW_CX23418,
142 .hw_all = CX18_HW_TUNER,
143 .video_inputs = {
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300144 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE2 },
145 { CX18_CARD_INPUT_SVIDEO1, 1,
146 CX23418_SVIDEO_LUMA3 | CX23418_SVIDEO_CHROMA4 },
147 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE1 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300148 },
149 .audio_inputs = {
150 { CX18_CARD_INPUT_AUD_TUNER,
151 CX23418_AUDIO8, 0 },
152 { CX18_CARD_INPUT_LINE_IN1,
153 CX23418_AUDIO_SERIAL, 0 },
154 },
155 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
156 CX23418_AUDIO_SERIAL, 0 },
157 .tuners = {
158 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
159 },
160 .ddr = {
161 /* EtronTech EM6A9160TS-5G memory */
162 .chip_config = 0x50003,
163 .refresh = 0x753,
164 .timing1 = 0x24330e84,
165 .timing2 = 0x1f,
166 .tune_lane = 0,
167 .initial_emrs = 0,
168 },
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300169 .xceive_pin = 15,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300170 .pci_list = cx18_pci_h900,
171 .i2c = &cx18_i2c_std,
172};
173
174/* ------------------------------------------------------------------------- */
175
176/* Yuan MPC718: not working at the moment! */
177
178static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
179 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 },
180 { 0, 0, 0 }
181};
182
183static const struct cx18_card cx18_card_mpc718 = {
184 .type = CX18_CARD_YUAN_MPC718,
185 .name = "Yuan MPC718",
186 .comment = "Not yet supported!\n",
187 .v4l2_capabilities = 0,
188 .hw_audio_ctrl = CX18_HW_CX23418,
189 .hw_all = CX18_HW_TUNER,
190 .video_inputs = {
191 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
192 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
193 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 },
194 },
195 .audio_inputs = {
196 { CX18_CARD_INPUT_AUD_TUNER,
197 CX23418_AUDIO8, 0 },
198 { CX18_CARD_INPUT_LINE_IN1,
199 CX23418_AUDIO_SERIAL, 0 },
200 },
201 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
202 CX23418_AUDIO_SERIAL, 0 },
203 .tuners = {
204 /* XC3028 tuner */
205 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
206 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300207 .ddr = {
208 /* Probably Samsung K4D263238G-VC33 memory */
209 .chip_config = 0x003,
210 .refresh = 0x30c,
211 .timing1 = 0x23230b73,
212 .timing2 = 0x08,
213 .tune_lane = 0,
214 .initial_emrs = 2,
215 },
Hans Verkuil6b13cf12008-05-12 14:00:33 -0300216 .xceive_pin = 15,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300217 .pci_list = cx18_pci_mpc718,
218 .i2c = &cx18_i2c_std,
219};
220
221static const struct cx18_card *cx18_card_list[] = {
222 &cx18_card_hvr1600_esmt,
223 &cx18_card_hvr1600_samsung,
224 &cx18_card_h900,
225 &cx18_card_mpc718,
226};
227
228const struct cx18_card *cx18_get_card(u16 index)
229{
230 if (index >= ARRAY_SIZE(cx18_card_list))
231 return NULL;
232 return cx18_card_list[index];
233}
234
235int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input)
236{
237 const struct cx18_card_video_input *card_input =
238 cx->card->video_inputs + index;
239 static const char * const input_strs[] = {
240 "Tuner 1",
241 "S-Video 1",
242 "S-Video 2",
243 "Composite 1",
244 "Composite 2",
245 "Composite 3"
246 };
247
248 memset(input, 0, sizeof(*input));
249 if (index >= cx->nof_inputs)
250 return -EINVAL;
251 input->index = index;
252 strlcpy(input->name, input_strs[card_input->video_type - 1],
253 sizeof(input->name));
254 input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
255 V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA);
256 input->audioset = (1 << cx->nof_audio_inputs) - 1;
257 input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ?
258 cx->tuner_std : V4L2_STD_ALL;
259 return 0;
260}
261
262int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio)
263{
264 const struct cx18_card_audio_input *aud_input =
265 cx->card->audio_inputs + index;
266 static const char * const input_strs[] = {
267 "Tuner 1",
268 "Line In 1",
269 "Line In 2"
270 };
271
272 memset(audio, 0, sizeof(*audio));
273 if (index >= cx->nof_audio_inputs)
274 return -EINVAL;
275 strlcpy(audio->name, input_strs[aud_input->audio_type - 1],
276 sizeof(audio->name));
277 audio->index = index;
278 audio->capability = V4L2_AUDCAP_STEREO;
279 return 0;
280}