blob: c18865b0d6ccf59a25b0b487b9f91b7f01e8e83d [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"
Hans Verkuild3d9b802008-06-08 06:05:18 -030026#include "cx18-av-core.h"
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030027#include "cx18-i2c.h"
28#include <media/cs5345.h>
29
30/********************** card configuration *******************************/
31
32/* usual i2c tuner addresses to probe */
33static struct cx18_card_tuner_i2c cx18_i2c_std = {
34 .radio = { I2C_CLIENT_END },
35 .demod = { 0x43, I2C_CLIENT_END },
36 .tv = { 0x61, 0x60, I2C_CLIENT_END },
37};
38
39/* Please add new PCI IDs to: http://pci-ids.ucw.cz/iii
40 This keeps the PCI ID database up to date. Note that the entries
41 must be added under vendor 0x4444 (Conexant) as subsystem IDs.
42 New vendor IDs should still be added to the vendor ID list. */
43
44/* Hauppauge HVR-1600 cards */
45
46/* Note: for Hauppauge cards the tveeprom information is used instead
47 of PCI IDs */
48static const struct cx18_card cx18_card_hvr1600_esmt = {
49 .type = CX18_CARD_HVR_1600_ESMT,
50 .name = "Hauppauge HVR-1600",
Hans Verkuil6b13cf12008-05-12 14:00:33 -030051 .comment = "VBI is not yet supported\n",
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030052 .v4l2_capabilities = CX18_CAP_ENCODER,
53 .hw_audio_ctrl = CX18_HW_CX23418,
54 .hw_muxer = CX18_HW_CS5345,
Hans Verkuil6b13cf12008-05-12 14:00:33 -030055 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
56 CX18_HW_CS5345 | CX18_HW_DVB,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030057 .video_inputs = {
Hans Verkuild3d9b802008-06-08 06:05:18 -030058 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 },
59 { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 },
60 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
61 { CX18_CARD_INPUT_SVIDEO2, 2, CX18_AV_SVIDEO2 },
62 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030063 },
64 .audio_inputs = {
65 { CX18_CARD_INPUT_AUD_TUNER,
Hans Verkuild3d9b802008-06-08 06:05:18 -030066 CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030067 { CX18_CARD_INPUT_LINE_IN1,
Hans Verkuild3d9b802008-06-08 06:05:18 -030068 CX18_AV_AUDIO_SERIAL, CS5345_IN_2 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030069 { CX18_CARD_INPUT_LINE_IN2,
Andy Walls46195b52008-06-19 23:17:05 -030070 CX18_AV_AUDIO_SERIAL, CS5345_IN_3 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030071 },
72 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
Andy Walls46195b52008-06-19 23:17:05 -030073 CX18_AV_AUDIO_SERIAL, CS5345_IN_4 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030074 .ddr = {
75 /* ESMT M13S128324A-5B memory */
76 .chip_config = 0x003,
77 .refresh = 0x30c,
78 .timing1 = 0x44220e82,
79 .timing2 = 0x08,
80 .tune_lane = 0,
81 .initial_emrs = 0,
82 },
83 .gpio_init.initial_value = 0x3001,
84 .gpio_init.direction = 0x3001,
85 .i2c = &cx18_i2c_std,
86};
87
88static const struct cx18_card cx18_card_hvr1600_samsung = {
89 .type = CX18_CARD_HVR_1600_SAMSUNG,
90 .name = "Hauppauge HVR-1600 (Preproduction)",
Hans Verkuil1d081602008-05-12 14:45:19 -030091 .comment = "VBI is not yet supported\n",
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030092 .v4l2_capabilities = CX18_CAP_ENCODER,
93 .hw_audio_ctrl = CX18_HW_CX23418,
94 .hw_muxer = CX18_HW_CS5345,
Hans Verkuil1d081602008-05-12 14:45:19 -030095 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
96 CX18_HW_CS5345 | CX18_HW_DVB,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030097 .video_inputs = {
Hans Verkuild3d9b802008-06-08 06:05:18 -030098 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 },
99 { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 },
100 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
101 { CX18_CARD_INPUT_SVIDEO2, 2, CX18_AV_SVIDEO2 },
102 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300103 },
104 .audio_inputs = {
105 { CX18_CARD_INPUT_AUD_TUNER,
Hans Verkuild3d9b802008-06-08 06:05:18 -0300106 CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300107 { CX18_CARD_INPUT_LINE_IN1,
Hans Verkuild3d9b802008-06-08 06:05:18 -0300108 CX18_AV_AUDIO_SERIAL, CS5345_IN_2 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300109 { CX18_CARD_INPUT_LINE_IN2,
Andy Walls46195b52008-06-19 23:17:05 -0300110 CX18_AV_AUDIO_SERIAL, CS5345_IN_3 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300111 },
112 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
Andy Walls46195b52008-06-19 23:17:05 -0300113 CX18_AV_AUDIO_SERIAL, CS5345_IN_4 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300114 .ddr = {
115 /* Samsung K4D263238G-VC33 memory */
116 .chip_config = 0x003,
117 .refresh = 0x30c,
118 .timing1 = 0x23230b73,
119 .timing2 = 0x08,
120 .tune_lane = 0,
121 .initial_emrs = 2,
122 },
123 .gpio_init.initial_value = 0x3001,
124 .gpio_init.direction = 0x3001,
125 .i2c = &cx18_i2c_std,
126};
127
128/* ------------------------------------------------------------------------- */
129
Hans Verkuil8f993572008-05-25 11:45:53 -0300130/* Compro VideoMate H900: note that this card is analog only! */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300131
132static const struct cx18_card_pci_info cx18_pci_h900[] = {
133 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
134 { 0, 0, 0 }
135};
136
137static const struct cx18_card cx18_card_h900 = {
138 .type = CX18_CARD_COMPRO_H900,
139 .name = "Compro VideoMate H900",
Hans Verkuil8f993572008-05-25 11:45:53 -0300140 .comment = "VBI is not yet supported\n",
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300141 .v4l2_capabilities = CX18_CAP_ENCODER,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300142 .hw_audio_ctrl = CX18_HW_CX23418,
143 .hw_all = CX18_HW_TUNER,
144 .video_inputs = {
Hans Verkuild3d9b802008-06-08 06:05:18 -0300145 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300146 { CX18_CARD_INPUT_SVIDEO1, 1,
Hans Verkuild3d9b802008-06-08 06:05:18 -0300147 CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
148 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300149 },
150 .audio_inputs = {
151 { CX18_CARD_INPUT_AUD_TUNER,
Hans Verkuild3d9b802008-06-08 06:05:18 -0300152 CX18_AV_AUDIO8, 0 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300153 { CX18_CARD_INPUT_LINE_IN1,
Hans Verkuild3d9b802008-06-08 06:05:18 -0300154 CX18_AV_AUDIO_SERIAL, 0 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300155 },
156 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
Hans Verkuild3d9b802008-06-08 06:05:18 -0300157 CX18_AV_AUDIO_SERIAL, 0 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300158 .tuners = {
159 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
160 },
161 .ddr = {
162 /* EtronTech EM6A9160TS-5G memory */
163 .chip_config = 0x50003,
164 .refresh = 0x753,
165 .timing1 = 0x24330e84,
166 .timing2 = 0x1f,
167 .tune_lane = 0,
168 .initial_emrs = 0,
169 },
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300170 .xceive_pin = 15,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300171 .pci_list = cx18_pci_h900,
172 .i2c = &cx18_i2c_std,
173};
174
175/* ------------------------------------------------------------------------- */
176
177/* Yuan MPC718: not working at the moment! */
178
179static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
180 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 },
181 { 0, 0, 0 }
182};
183
184static const struct cx18_card cx18_card_mpc718 = {
185 .type = CX18_CARD_YUAN_MPC718,
186 .name = "Yuan MPC718",
187 .comment = "Not yet supported!\n",
188 .v4l2_capabilities = 0,
189 .hw_audio_ctrl = CX18_HW_CX23418,
190 .hw_all = CX18_HW_TUNER,
191 .video_inputs = {
Hans Verkuild3d9b802008-06-08 06:05:18 -0300192 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 },
193 { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 },
194 { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300195 },
196 .audio_inputs = {
197 { CX18_CARD_INPUT_AUD_TUNER,
Hans Verkuild3d9b802008-06-08 06:05:18 -0300198 CX18_AV_AUDIO8, 0 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300199 { CX18_CARD_INPUT_LINE_IN1,
Hans Verkuild3d9b802008-06-08 06:05:18 -0300200 CX18_AV_AUDIO_SERIAL, 0 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300201 },
202 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
Hans Verkuild3d9b802008-06-08 06:05:18 -0300203 CX18_AV_AUDIO_SERIAL, 0 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300204 .tuners = {
205 /* XC3028 tuner */
206 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
207 },
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300208 .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 },
Hans Verkuil6b13cf12008-05-12 14:00:33 -0300217 .xceive_pin = 15,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300218 .pci_list = cx18_pci_mpc718,
219 .i2c = &cx18_i2c_std,
220};
221
222static const struct cx18_card *cx18_card_list[] = {
223 &cx18_card_hvr1600_esmt,
224 &cx18_card_hvr1600_samsung,
225 &cx18_card_h900,
226 &cx18_card_mpc718,
227};
228
229const struct cx18_card *cx18_get_card(u16 index)
230{
231 if (index >= ARRAY_SIZE(cx18_card_list))
232 return NULL;
233 return cx18_card_list[index];
234}
235
236int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input)
237{
238 const struct cx18_card_video_input *card_input =
239 cx->card->video_inputs + index;
240 static const char * const input_strs[] = {
241 "Tuner 1",
242 "S-Video 1",
243 "S-Video 2",
244 "Composite 1",
245 "Composite 2",
246 "Composite 3"
247 };
248
249 memset(input, 0, sizeof(*input));
250 if (index >= cx->nof_inputs)
251 return -EINVAL;
252 input->index = index;
253 strlcpy(input->name, input_strs[card_input->video_type - 1],
254 sizeof(input->name));
255 input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
256 V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA);
257 input->audioset = (1 << cx->nof_audio_inputs) - 1;
258 input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ?
259 cx->tuner_std : V4L2_STD_ALL;
260 return 0;
261}
262
263int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio)
264{
265 const struct cx18_card_audio_input *aud_input =
266 cx->card->audio_inputs + index;
267 static const char * const input_strs[] = {
268 "Tuner 1",
269 "Line In 1",
270 "Line In 2"
271 };
272
273 memset(audio, 0, sizeof(*audio));
274 if (index >= cx->nof_audio_inputs)
275 return -EINVAL;
276 strlcpy(audio->name, input_strs[aud_input->audio_type - 1],
277 sizeof(audio->name));
278 audio->index = index;
279 audio->capability = V4L2_AUDCAP_STEREO;
280 return 0;
281}