blob: 0f2bfb4ba8449253e019a66fe8fc70db21e993ea [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",
50 .comment = "DVB & VBI are not yet supported\n",
51 .v4l2_capabilities = CX18_CAP_ENCODER,
52 .hw_audio_ctrl = CX18_HW_CX23418,
53 .hw_muxer = CX18_HW_CS5345,
Steven Toth67129472008-05-01 07:23:23 -030054 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345
55 | 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)",
90 .comment = "DVB & VBI are not yet supported\n",
91 .v4l2_capabilities = CX18_CAP_ENCODER,
92 .hw_audio_ctrl = CX18_HW_CX23418,
93 .hw_muxer = CX18_HW_CS5345,
94 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345,
95 .video_inputs = {
96 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
97 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
98 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 },
99 { CX18_CARD_INPUT_SVIDEO2, 2, CX23418_SVIDEO2 },
100 { CX18_CARD_INPUT_COMPOSITE2, 2, CX23418_COMPOSITE4 },
101 },
102 .audio_inputs = {
103 { CX18_CARD_INPUT_AUD_TUNER,
104 CX23418_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
105 { CX18_CARD_INPUT_LINE_IN1,
106 CX23418_AUDIO_SERIAL, CS5345_IN_2 },
107 { CX18_CARD_INPUT_LINE_IN2,
108 CX23418_AUDIO_SERIAL, CS5345_IN_2 },
109 },
110 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
111 CX23418_AUDIO_SERIAL, 0 },
112 .ddr = {
113 /* Samsung K4D263238G-VC33 memory */
114 .chip_config = 0x003,
115 .refresh = 0x30c,
116 .timing1 = 0x23230b73,
117 .timing2 = 0x08,
118 .tune_lane = 0,
119 .initial_emrs = 2,
120 },
121 .gpio_init.initial_value = 0x3001,
122 .gpio_init.direction = 0x3001,
123 .i2c = &cx18_i2c_std,
124};
125
126/* ------------------------------------------------------------------------- */
127
128/* Compro VideoMate H900: not working at the moment! */
129
130static const struct cx18_card_pci_info cx18_pci_h900[] = {
131 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
132 { 0, 0, 0 }
133};
134
135static const struct cx18_card cx18_card_h900 = {
136 .type = CX18_CARD_COMPRO_H900,
137 .name = "Compro VideoMate H900",
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300138 .comment = "DVB & VBI are not yet supported\n",
139 .v4l2_capabilities = CX18_CAP_ENCODER,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300140 .hw_audio_ctrl = CX18_HW_CX23418,
141 .hw_all = CX18_HW_TUNER,
142 .video_inputs = {
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300143 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE2 },
144 { CX18_CARD_INPUT_SVIDEO1, 1,
145 CX23418_SVIDEO_LUMA3 | CX23418_SVIDEO_CHROMA4 },
146 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE1 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300147 },
148 .audio_inputs = {
149 { CX18_CARD_INPUT_AUD_TUNER,
150 CX23418_AUDIO8, 0 },
151 { CX18_CARD_INPUT_LINE_IN1,
152 CX23418_AUDIO_SERIAL, 0 },
153 },
154 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
155 CX23418_AUDIO_SERIAL, 0 },
156 .tuners = {
157 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
158 },
159 .ddr = {
160 /* EtronTech EM6A9160TS-5G memory */
161 .chip_config = 0x50003,
162 .refresh = 0x753,
163 .timing1 = 0x24330e84,
164 .timing2 = 0x1f,
165 .tune_lane = 0,
166 .initial_emrs = 0,
167 },
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300168 .xceive_pin = 15,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300169 .pci_list = cx18_pci_h900,
170 .i2c = &cx18_i2c_std,
171};
172
173/* ------------------------------------------------------------------------- */
174
175/* Yuan MPC718: not working at the moment! */
176
177static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
178 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 },
179 { 0, 0, 0 }
180};
181
182static const struct cx18_card cx18_card_mpc718 = {
183 .type = CX18_CARD_YUAN_MPC718,
184 .name = "Yuan MPC718",
185 .comment = "Not yet supported!\n",
186 .v4l2_capabilities = 0,
187 .hw_audio_ctrl = CX18_HW_CX23418,
188 .hw_all = CX18_HW_TUNER,
189 .video_inputs = {
190 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
191 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
192 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 },
193 },
194 .audio_inputs = {
195 { CX18_CARD_INPUT_AUD_TUNER,
196 CX23418_AUDIO8, 0 },
197 { CX18_CARD_INPUT_LINE_IN1,
198 CX23418_AUDIO_SERIAL, 0 },
199 },
200 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
201 CX23418_AUDIO_SERIAL, 0 },
202 .tuners = {
203 /* XC3028 tuner */
204 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
205 },
206 /* tuner reset */
207 .gpio_init = { .direction = 0x1000, .initial_value = 0x1000 },
208 .ddr = {
209 /* Probably Samsung K4D263238G-VC33 memory */
210 .chip_config = 0x003,
211 .refresh = 0x30c,
212 .timing1 = 0x23230b73,
213 .timing2 = 0x08,
214 .tune_lane = 0,
215 .initial_emrs = 2,
216 },
217 .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}