V4L/DVB(7879): Adding cx18 Support for mxl5005s
[linux-2.6/kvm.git] / drivers / media / video / cx18 / cx18-cards.c
blobbf6f7edca88722c507c9d0045170f24bb97988dd
1 /*
2 * cx18 functions to query card hardware
4 * Derived from ivtv-cards.c
6 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
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.
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.
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
24 #include "cx18-driver.h"
25 #include "cx18-cards.h"
26 #include "cx18-i2c.h"
27 #include <media/cs5345.h>
29 /********************** card configuration *******************************/
31 /* usual i2c tuner addresses to probe */
32 static 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 },
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. */
43 /* Hauppauge HVR-1600 cards */
45 /* Note: for Hauppauge cards the tveeprom information is used instead
46 of PCI IDs */
47 static 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,
54 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345
55 | CX18_HW_DVB,
56 .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 },
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 },
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,
82 .gpio_init.initial_value = 0x3001,
83 .gpio_init.direction = 0x3001,
84 .i2c = &cx18_i2c_std,
87 static 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 },
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 },
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,
121 .gpio_init.initial_value = 0x3001,
122 .gpio_init.direction = 0x3001,
123 .i2c = &cx18_i2c_std,
126 /* ------------------------------------------------------------------------- */
128 /* Compro VideoMate H900: not working at the moment! */
130 static const struct cx18_card_pci_info cx18_pci_h900[] = {
131 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
132 { 0, 0, 0 }
135 static const struct cx18_card cx18_card_h900 = {
136 .type = CX18_CARD_COMPRO_H900,
137 .name = "Compro VideoMate H900",
138 .comment = "Not yet supported!\n",
139 .v4l2_capabilities = 0,
140 .hw_audio_ctrl = CX18_HW_CX23418,
141 .hw_all = CX18_HW_TUNER,
142 .video_inputs = {
143 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
144 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
145 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 },
147 .audio_inputs = {
148 { CX18_CARD_INPUT_AUD_TUNER,
149 CX23418_AUDIO8, 0 },
150 { CX18_CARD_INPUT_LINE_IN1,
151 CX23418_AUDIO_SERIAL, 0 },
153 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
154 CX23418_AUDIO_SERIAL, 0 },
155 .tuners = {
156 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
158 .ddr = {
159 /* EtronTech EM6A9160TS-5G memory */
160 .chip_config = 0x50003,
161 .refresh = 0x753,
162 .timing1 = 0x24330e84,
163 .timing2 = 0x1f,
164 .tune_lane = 0,
165 .initial_emrs = 0,
167 .pci_list = cx18_pci_h900,
168 .i2c = &cx18_i2c_std,
171 /* ------------------------------------------------------------------------- */
173 /* Yuan MPC718: not working at the moment! */
175 static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
176 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 },
177 { 0, 0, 0 }
180 static const struct cx18_card cx18_card_mpc718 = {
181 .type = CX18_CARD_YUAN_MPC718,
182 .name = "Yuan MPC718",
183 .comment = "Not yet supported!\n",
184 .v4l2_capabilities = 0,
185 .hw_audio_ctrl = CX18_HW_CX23418,
186 .hw_all = CX18_HW_TUNER,
187 .video_inputs = {
188 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
189 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
190 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 },
192 .audio_inputs = {
193 { CX18_CARD_INPUT_AUD_TUNER,
194 CX23418_AUDIO8, 0 },
195 { CX18_CARD_INPUT_LINE_IN1,
196 CX23418_AUDIO_SERIAL, 0 },
198 .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
199 CX23418_AUDIO_SERIAL, 0 },
200 .tuners = {
201 /* XC3028 tuner */
202 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
204 /* tuner reset */
205 .gpio_init = { .direction = 0x1000, .initial_value = 0x1000 },
206 .ddr = {
207 /* Probably Samsung K4D263238G-VC33 memory */
208 .chip_config = 0x003,
209 .refresh = 0x30c,
210 .timing1 = 0x23230b73,
211 .timing2 = 0x08,
212 .tune_lane = 0,
213 .initial_emrs = 2,
215 .pci_list = cx18_pci_mpc718,
216 .i2c = &cx18_i2c_std,
219 static const struct cx18_card *cx18_card_list[] = {
220 &cx18_card_hvr1600_esmt,
221 &cx18_card_hvr1600_samsung,
222 &cx18_card_h900,
223 &cx18_card_mpc718,
226 const struct cx18_card *cx18_get_card(u16 index)
228 if (index >= ARRAY_SIZE(cx18_card_list))
229 return NULL;
230 return cx18_card_list[index];
233 int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input)
235 const struct cx18_card_video_input *card_input =
236 cx->card->video_inputs + index;
237 static const char * const input_strs[] = {
238 "Tuner 1",
239 "S-Video 1",
240 "S-Video 2",
241 "Composite 1",
242 "Composite 2",
243 "Composite 3"
246 memset(input, 0, sizeof(*input));
247 if (index >= cx->nof_inputs)
248 return -EINVAL;
249 input->index = index;
250 strlcpy(input->name, input_strs[card_input->video_type - 1],
251 sizeof(input->name));
252 input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ?
253 V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA);
254 input->audioset = (1 << cx->nof_audio_inputs) - 1;
255 input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ?
256 cx->tuner_std : V4L2_STD_ALL;
257 return 0;
260 int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio)
262 const struct cx18_card_audio_input *aud_input =
263 cx->card->audio_inputs + index;
264 static const char * const input_strs[] = {
265 "Tuner 1",
266 "Line In 1",
267 "Line In 2"
270 memset(audio, 0, sizeof(*audio));
271 if (index >= cx->nof_audio_inputs)
272 return -EINVAL;
273 strlcpy(audio->name, input_strs[aud_input->audio_type - 1],
274 sizeof(audio->name));
275 audio->index = index;
276 audio->capability = V4L2_AUDCAP_STEREO;
277 return 0;