blob: 2f4db970152e7ce86647a666637c8c8cc773ef1e [file] [log] [blame]
Steven Tothd19770e2007-03-11 20:44:05 -03001/*
2 * Driver for the Conexant CX23885 PCIe bridge
3 *
Steven Toth6d897612008-09-03 17:12:12 -03004 * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
Steven Tothd19770e2007-03-11 20:44:05 -03005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/pci.h>
25#include <linux/delay.h>
Steven Toth7b888012008-01-10 03:40:49 -030026#include <media/cx25840.h>
Steven Tothd19770e2007-03-11 20:44:05 -030027
28#include "cx23885.h"
Steven Toth90a71b12008-08-04 21:38:46 -030029#include "tuner-xc2028.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030030#include "netup-init.h"
Andy Walls29f8a0a2009-09-26 23:17:30 -030031#include "cx23888-ir.h"
Steven Tothd19770e2007-03-11 20:44:05 -030032
33/* ------------------------------------------------------------------ */
34/* board config info */
35
36struct cx23885_board cx23885_boards[] = {
37 [CX23885_BOARD_UNKNOWN] = {
38 .name = "UNKNOWN/GENERIC",
Steven Tothc7712612008-01-10 02:24:27 -030039 /* Ensure safe default for unknown boards */
40 .clk_freq = 0,
Steven Tothd19770e2007-03-11 20:44:05 -030041 .input = {{
42 .type = CX23885_VMUX_COMPOSITE1,
43 .vmux = 0,
Steven Toth9c8ced52008-10-16 20:18:44 -030044 }, {
Steven Tothd19770e2007-03-11 20:44:05 -030045 .type = CX23885_VMUX_COMPOSITE2,
46 .vmux = 1,
Steven Toth9c8ced52008-10-16 20:18:44 -030047 }, {
Steven Tothd19770e2007-03-11 20:44:05 -030048 .type = CX23885_VMUX_COMPOSITE3,
49 .vmux = 2,
Steven Toth9c8ced52008-10-16 20:18:44 -030050 }, {
Steven Tothd19770e2007-03-11 20:44:05 -030051 .type = CX23885_VMUX_COMPOSITE4,
52 .vmux = 3,
Steven Toth9c8ced52008-10-16 20:18:44 -030053 } },
Steven Tothd19770e2007-03-11 20:44:05 -030054 },
55 [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = {
56 .name = "Hauppauge WinTV-HVR1800lp",
Steven Tothd19770e2007-03-11 20:44:05 -030057 .portc = CX23885_MPEG_DVB,
58 .input = {{
59 .type = CX23885_VMUX_TELEVISION,
60 .vmux = 0,
61 .gpio0 = 0xff00,
Steven Toth9c8ced52008-10-16 20:18:44 -030062 }, {
Steven Tothd19770e2007-03-11 20:44:05 -030063 .type = CX23885_VMUX_DEBUG,
64 .vmux = 0,
65 .gpio0 = 0xff01,
Steven Toth9c8ced52008-10-16 20:18:44 -030066 }, {
Steven Tothd19770e2007-03-11 20:44:05 -030067 .type = CX23885_VMUX_COMPOSITE1,
68 .vmux = 1,
69 .gpio0 = 0xff02,
Steven Toth9c8ced52008-10-16 20:18:44 -030070 }, {
Steven Tothd19770e2007-03-11 20:44:05 -030071 .type = CX23885_VMUX_SVIDEO,
72 .vmux = 2,
73 .gpio0 = 0xff02,
Steven Toth9c8ced52008-10-16 20:18:44 -030074 } },
Steven Tothd19770e2007-03-11 20:44:05 -030075 },
76 [CX23885_BOARD_HAUPPAUGE_HVR1800] = {
77 .name = "Hauppauge WinTV-HVR1800",
Steven Toth7b888012008-01-10 03:40:49 -030078 .porta = CX23885_ANALOG_VIDEO,
Steven Totha589b662008-01-13 23:44:47 -030079 .portb = CX23885_MPEG_ENCODER,
Steven Tothd19770e2007-03-11 20:44:05 -030080 .portc = CX23885_MPEG_DVB,
Steven Toth7b888012008-01-10 03:40:49 -030081 .tuner_type = TUNER_PHILIPS_TDA8290,
82 .tuner_addr = 0x42, /* 0x84 >> 1 */
Steven Tothd19770e2007-03-11 20:44:05 -030083 .input = {{
84 .type = CX23885_VMUX_TELEVISION,
Steven Toth7b888012008-01-10 03:40:49 -030085 .vmux = CX25840_VIN7_CH3 |
86 CX25840_VIN5_CH2 |
87 CX25840_VIN2_CH1,
88 .gpio0 = 0,
Steven Toth9c8ced52008-10-16 20:18:44 -030089 }, {
Steven Tothd19770e2007-03-11 20:44:05 -030090 .type = CX23885_VMUX_COMPOSITE1,
Steven Toth7b888012008-01-10 03:40:49 -030091 .vmux = CX25840_VIN7_CH3 |
92 CX25840_VIN4_CH2 |
93 CX25840_VIN6_CH1,
94 .gpio0 = 0,
Steven Toth9c8ced52008-10-16 20:18:44 -030095 }, {
Steven Tothd19770e2007-03-11 20:44:05 -030096 .type = CX23885_VMUX_SVIDEO,
Steven Toth7b888012008-01-10 03:40:49 -030097 .vmux = CX25840_VIN7_CH3 |
98 CX25840_VIN4_CH2 |
99 CX25840_VIN8_CH1 |
100 CX25840_SVIDEO_ON,
101 .gpio0 = 0,
Steven Toth9c8ced52008-10-16 20:18:44 -0300102 } },
Steven Tothd19770e2007-03-11 20:44:05 -0300103 },
Steven Totha77743b2007-08-22 21:01:20 -0300104 [CX23885_BOARD_HAUPPAUGE_HVR1250] = {
105 .name = "Hauppauge WinTV-HVR1250",
106 .portc = CX23885_MPEG_DVB,
107 .input = {{
108 .type = CX23885_VMUX_TELEVISION,
109 .vmux = 0,
110 .gpio0 = 0xff00,
Steven Toth9c8ced52008-10-16 20:18:44 -0300111 }, {
Steven Totha77743b2007-08-22 21:01:20 -0300112 .type = CX23885_VMUX_DEBUG,
113 .vmux = 0,
114 .gpio0 = 0xff01,
Steven Toth9c8ced52008-10-16 20:18:44 -0300115 }, {
Steven Totha77743b2007-08-22 21:01:20 -0300116 .type = CX23885_VMUX_COMPOSITE1,
117 .vmux = 1,
118 .gpio0 = 0xff02,
Steven Toth9c8ced52008-10-16 20:18:44 -0300119 }, {
Steven Totha77743b2007-08-22 21:01:20 -0300120 .type = CX23885_VMUX_SVIDEO,
121 .vmux = 2,
122 .gpio0 = 0xff02,
Steven Toth9c8ced52008-10-16 20:18:44 -0300123 } },
Steven Totha77743b2007-08-22 21:01:20 -0300124 },
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300125 [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = {
126 .name = "DViCO FusionHDTV5 Express",
Steven Totha6a3f142007-09-08 21:31:56 -0300127 .portb = CX23885_MPEG_DVB,
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300128 },
Steven Tothd1987d52007-12-18 01:57:06 -0300129 [CX23885_BOARD_HAUPPAUGE_HVR1500Q] = {
130 .name = "Hauppauge WinTV-HVR1500Q",
131 .portc = CX23885_MPEG_DVB,
132 },
Michael Krufky07b4a832007-12-18 01:09:11 -0300133 [CX23885_BOARD_HAUPPAUGE_HVR1500] = {
134 .name = "Hauppauge WinTV-HVR1500",
135 .portc = CX23885_MPEG_DVB,
136 },
Steven Tothb3ea0162008-04-19 01:14:19 -0300137 [CX23885_BOARD_HAUPPAUGE_HVR1200] = {
138 .name = "Hauppauge WinTV-HVR1200",
139 .portc = CX23885_MPEG_DVB,
140 },
Steven Totha780a312008-04-19 01:25:52 -0300141 [CX23885_BOARD_HAUPPAUGE_HVR1700] = {
142 .name = "Hauppauge WinTV-HVR1700",
143 .portc = CX23885_MPEG_DVB,
144 },
Steven Toth66762372008-04-22 15:38:26 -0300145 [CX23885_BOARD_HAUPPAUGE_HVR1400] = {
146 .name = "Hauppauge WinTV-HVR1400",
147 .portc = CX23885_MPEG_DVB,
148 },
Michael Krufky335377b2008-05-07 01:43:10 -0300149 [CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP] = {
150 .name = "DViCO FusionHDTV7 Dual Express",
Steven Tothaaadeac2008-06-30 20:58:38 -0300151 .portb = CX23885_MPEG_DVB,
Michael Krufky335377b2008-05-07 01:43:10 -0300152 .portc = CX23885_MPEG_DVB,
153 },
Steven Tothaef2d182008-08-04 21:39:53 -0300154 [CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP] = {
155 .name = "DViCO FusionHDTV DVB-T Dual Express",
156 .portb = CX23885_MPEG_DVB,
157 .portc = CX23885_MPEG_DVB,
158 },
Steven Toth4c56b042008-08-12 13:30:03 -0300159 [CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H] = {
160 .name = "Leadtek Winfast PxDVR3200 H",
161 .portc = CX23885_MPEG_DVB,
162 },
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -0300163 [CX23885_BOARD_COMPRO_VIDEOMATE_E650F] = {
164 .name = "Compro VideoMate E650F",
165 .portc = CX23885_MPEG_DVB,
166 },
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300167 [CX23885_BOARD_TBS_6920] = {
168 .name = "TurboSight TBS 6920",
169 .portb = CX23885_MPEG_DVB,
170 },
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300171 [CX23885_BOARD_TEVII_S470] = {
172 .name = "TeVii S470",
173 .portb = CX23885_MPEG_DVB,
174 },
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300175 [CX23885_BOARD_DVBWORLD_2005] = {
176 .name = "DVBWorld DVB-S2 2005",
177 .portb = CX23885_MPEG_DVB,
178 },
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300179 [CX23885_BOARD_NETUP_DUAL_DVBS2_CI] = {
180 .cimax = 1,
181 .name = "NetUP Dual DVB-S2 CI",
182 .portb = CX23885_MPEG_DVB,
183 .portc = CX23885_MPEG_DVB,
184 },
Steven Toth2074dff2009-05-02 11:39:46 -0300185 [CX23885_BOARD_HAUPPAUGE_HVR1270] = {
186 .name = "Hauppauge WinTV-HVR1270",
Michael Krufkya5dbf452009-05-03 23:27:02 -0300187 .portc = CX23885_MPEG_DVB,
Steven Toth2074dff2009-05-02 11:39:46 -0300188 },
Michael Krufkyd099bec2009-05-08 22:39:24 -0300189 [CX23885_BOARD_HAUPPAUGE_HVR1275] = {
190 .name = "Hauppauge WinTV-HVR1275",
191 .portc = CX23885_MPEG_DVB,
192 },
Michael Krufky19bc5792009-05-08 16:05:29 -0300193 [CX23885_BOARD_HAUPPAUGE_HVR1255] = {
194 .name = "Hauppauge WinTV-HVR1255",
195 .portc = CX23885_MPEG_DVB,
196 },
Michael Krufky6b926ec2009-05-12 17:32:17 -0300197 [CX23885_BOARD_HAUPPAUGE_HVR1210] = {
198 .name = "Hauppauge WinTV-HVR1210",
199 .portc = CX23885_MPEG_DVB,
200 },
David Wong493b7122009-05-18 05:25:49 -0300201 [CX23885_BOARD_MYGICA_X8506] = {
202 .name = "Mygica X8506 DMB-TH",
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300203 .tuner_type = TUNER_XC5000,
204 .tuner_addr = 0x61,
David T.L. Wongbc1548a2009-10-21 11:09:28 -0300205 .porta = CX23885_ANALOG_VIDEO,
David Wong493b7122009-05-18 05:25:49 -0300206 .portb = CX23885_MPEG_DVB,
David T.L. Wongbc1548a2009-10-21 11:09:28 -0300207 .input = {
208 {
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300209 .type = CX23885_VMUX_TELEVISION,
210 .vmux = CX25840_COMPOSITE2,
211 },
212 {
David T.L. Wongbc1548a2009-10-21 11:09:28 -0300213 .type = CX23885_VMUX_COMPOSITE1,
214 .vmux = CX25840_COMPOSITE8,
215 },
216 {
217 .type = CX23885_VMUX_SVIDEO,
218 .vmux = CX25840_SVIDEO_LUMA3 |
219 CX25840_SVIDEO_CHROMA4,
220 },
221 {
222 .type = CX23885_VMUX_COMPONENT,
223 .vmux = CX25840_COMPONENT_ON |
224 CX25840_VIN1_CH1 |
225 CX25840_VIN6_CH2 |
226 CX25840_VIN7_CH3,
227 },
228 },
David Wong493b7122009-05-18 05:25:49 -0300229 },
David Wong2365b2d2009-06-17 01:38:12 -0300230 [CX23885_BOARD_MAGICPRO_PROHDTVE2] = {
231 .name = "Magic-Pro ProHDTV Extreme 2",
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300232 .tuner_type = TUNER_XC5000,
233 .tuner_addr = 0x61,
David T.L. Wongbc1548a2009-10-21 11:09:28 -0300234 .porta = CX23885_ANALOG_VIDEO,
David Wong2365b2d2009-06-17 01:38:12 -0300235 .portb = CX23885_MPEG_DVB,
David T.L. Wongbc1548a2009-10-21 11:09:28 -0300236 .input = {
237 {
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300238 .type = CX23885_VMUX_TELEVISION,
239 .vmux = CX25840_COMPOSITE2,
240 },
241 {
David T.L. Wongbc1548a2009-10-21 11:09:28 -0300242 .type = CX23885_VMUX_COMPOSITE1,
243 .vmux = CX25840_COMPOSITE8,
244 },
245 {
246 .type = CX23885_VMUX_SVIDEO,
247 .vmux = CX25840_SVIDEO_LUMA3 |
248 CX25840_SVIDEO_CHROMA4,
249 },
250 {
251 .type = CX23885_VMUX_COMPONENT,
252 .vmux = CX25840_COMPONENT_ON |
253 CX25840_VIN1_CH1 |
254 CX25840_VIN6_CH2 |
255 CX25840_VIN7_CH3,
256 },
257 },
David Wong2365b2d2009-06-17 01:38:12 -0300258 },
Steven Toth136973802009-07-20 15:37:25 -0300259 [CX23885_BOARD_HAUPPAUGE_HVR1850] = {
260 .name = "Hauppauge WinTV-HVR1850",
261 .portb = CX23885_MPEG_ENCODER,
262 .portc = CX23885_MPEG_DVB,
263 },
Vladimir Geroy34e383d2009-09-18 18:55:47 -0300264 [CX23885_BOARD_COMPRO_VIDEOMATE_E800] = {
265 .name = "Compro VideoMate E800",
266 .portc = CX23885_MPEG_DVB,
267 },
Michael Krufkyaee0b242009-11-11 01:52:45 -0300268 [CX23885_BOARD_HAUPPAUGE_HVR1290] = {
269 .name = "Hauppauge WinTV-HVR1290",
270 .portc = CX23885_MPEG_DVB,
271 },
Steven Tothd19770e2007-03-11 20:44:05 -0300272};
273const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
274
275/* ------------------------------------------------------------------ */
276/* PCI subsystem IDs */
277
278struct cx23885_subid cx23885_subids[] = {
279 {
280 .subvendor = 0x0070,
281 .subdevice = 0x3400,
282 .card = CX23885_BOARD_UNKNOWN,
Steven Toth9c8ced52008-10-16 20:18:44 -0300283 }, {
Steven Tothd19770e2007-03-11 20:44:05 -0300284 .subvendor = 0x0070,
285 .subdevice = 0x7600,
286 .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp,
Steven Toth9c8ced52008-10-16 20:18:44 -0300287 }, {
Steven Tothd19770e2007-03-11 20:44:05 -0300288 .subvendor = 0x0070,
289 .subdevice = 0x7800,
290 .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
Steven Toth9c8ced52008-10-16 20:18:44 -0300291 }, {
Steven Tothd19770e2007-03-11 20:44:05 -0300292 .subvendor = 0x0070,
293 .subdevice = 0x7801,
294 .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
Steven Toth9c8ced52008-10-16 20:18:44 -0300295 }, {
Steven Totha77743b2007-08-22 21:01:20 -0300296 .subvendor = 0x0070,
Michael Krufky6ccb8cf2007-12-27 21:46:34 -0300297 .subdevice = 0x7809,
298 .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
Steven Toth9c8ced52008-10-16 20:18:44 -0300299 }, {
Michael Krufky6ccb8cf2007-12-27 21:46:34 -0300300 .subvendor = 0x0070,
Steven Totha77743b2007-08-22 21:01:20 -0300301 .subdevice = 0x7911,
302 .card = CX23885_BOARD_HAUPPAUGE_HVR1250,
Steven Toth9c8ced52008-10-16 20:18:44 -0300303 }, {
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300304 .subvendor = 0x18ac,
305 .subdevice = 0xd500,
306 .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP,
Steven Toth9c8ced52008-10-16 20:18:44 -0300307 }, {
Steven Tothd1987d52007-12-18 01:57:06 -0300308 .subvendor = 0x0070,
Michael Krufkyb00fff02007-12-27 22:19:31 -0300309 .subdevice = 0x7790,
310 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
Steven Toth9c8ced52008-10-16 20:18:44 -0300311 }, {
Michael Krufkyb00fff02007-12-27 22:19:31 -0300312 .subvendor = 0x0070,
Steven Tothd1987d52007-12-18 01:57:06 -0300313 .subdevice = 0x7797,
314 .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
Steven Toth9c8ced52008-10-16 20:18:44 -0300315 }, {
Michael Krufky07b4a832007-12-18 01:09:11 -0300316 .subvendor = 0x0070,
Michael Krufkyb00fff02007-12-27 22:19:31 -0300317 .subdevice = 0x7710,
318 .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
Steven Toth9c8ced52008-10-16 20:18:44 -0300319 }, {
Michael Krufkyb00fff02007-12-27 22:19:31 -0300320 .subvendor = 0x0070,
Michael Krufky07b4a832007-12-18 01:09:11 -0300321 .subdevice = 0x7717,
322 .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
Steven Tothb3ea0162008-04-19 01:14:19 -0300323 }, {
324 .subvendor = 0x0070,
325 .subdevice = 0x71d1,
326 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
Steven Totha780a312008-04-19 01:25:52 -0300327 }, {
328 .subvendor = 0x0070,
Michael Krufky3c3852c2008-05-02 16:12:44 -0300329 .subdevice = 0x71d3,
330 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
331 }, {
332 .subvendor = 0x0070,
Steven Totha780a312008-04-19 01:25:52 -0300333 .subdevice = 0x8101,
334 .card = CX23885_BOARD_HAUPPAUGE_HVR1700,
Steven Toth66762372008-04-22 15:38:26 -0300335 }, {
336 .subvendor = 0x0070,
337 .subdevice = 0x8010,
338 .card = CX23885_BOARD_HAUPPAUGE_HVR1400,
Steven Toth9c8ced52008-10-16 20:18:44 -0300339 }, {
Michael Krufky335377b2008-05-07 01:43:10 -0300340 .subvendor = 0x18ac,
341 .subdevice = 0xd618,
342 .card = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP,
Steven Toth9c8ced52008-10-16 20:18:44 -0300343 }, {
Steven Tothaef2d182008-08-04 21:39:53 -0300344 .subvendor = 0x18ac,
345 .subdevice = 0xdb78,
346 .card = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP,
Steven Toth4c56b042008-08-12 13:30:03 -0300347 }, {
348 .subvendor = 0x107d,
349 .subdevice = 0x6681,
350 .card = CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H,
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -0300351 }, {
352 .subvendor = 0x185b,
353 .subdevice = 0xe800,
354 .card = CX23885_BOARD_COMPRO_VIDEOMATE_E650F,
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300355 }, {
356 .subvendor = 0x6920,
357 .subdevice = 0x8888,
358 .card = CX23885_BOARD_TBS_6920,
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300359 }, {
360 .subvendor = 0xd470,
361 .subdevice = 0x9022,
362 .card = CX23885_BOARD_TEVII_S470,
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300363 }, {
364 .subvendor = 0x0001,
365 .subdevice = 0x2005,
366 .card = CX23885_BOARD_DVBWORLD_2005,
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300367 }, {
368 .subvendor = 0x1b55,
369 .subdevice = 0x2a2c,
370 .card = CX23885_BOARD_NETUP_DUAL_DVBS2_CI,
Steven Toth2074dff2009-05-02 11:39:46 -0300371 }, {
372 .subvendor = 0x0070,
373 .subdevice = 0x2211,
374 .card = CX23885_BOARD_HAUPPAUGE_HVR1270,
Michael Krufkyd099bec2009-05-08 22:39:24 -0300375 }, {
376 .subvendor = 0x0070,
377 .subdevice = 0x2215,
378 .card = CX23885_BOARD_HAUPPAUGE_HVR1275,
Michael Krufky19bc5792009-05-08 16:05:29 -0300379 }, {
380 .subvendor = 0x0070,
381 .subdevice = 0x2251,
382 .card = CX23885_BOARD_HAUPPAUGE_HVR1255,
Michael Krufky6b926ec2009-05-12 17:32:17 -0300383 }, {
384 .subvendor = 0x0070,
385 .subdevice = 0x2291,
386 .card = CX23885_BOARD_HAUPPAUGE_HVR1210,
387 }, {
388 .subvendor = 0x0070,
389 .subdevice = 0x2295,
390 .card = CX23885_BOARD_HAUPPAUGE_HVR1210,
David Wong493b7122009-05-18 05:25:49 -0300391 }, {
392 .subvendor = 0x14f1,
393 .subdevice = 0x8651,
394 .card = CX23885_BOARD_MYGICA_X8506,
David Wong2365b2d2009-06-17 01:38:12 -0300395 }, {
396 .subvendor = 0x14f1,
397 .subdevice = 0x8657,
398 .card = CX23885_BOARD_MAGICPRO_PROHDTVE2,
Steven Toth136973802009-07-20 15:37:25 -0300399 }, {
400 .subvendor = 0x0070,
401 .subdevice = 0x8541,
402 .card = CX23885_BOARD_HAUPPAUGE_HVR1850,
Vladimir Geroy34e383d2009-09-18 18:55:47 -0300403 }, {
404 .subvendor = 0x1858,
405 .subdevice = 0xe800,
406 .card = CX23885_BOARD_COMPRO_VIDEOMATE_E800,
Michael Krufkyaee0b242009-11-11 01:52:45 -0300407 }, {
408 .subvendor = 0x0070,
409 .subdevice = 0x8551,
410 .card = CX23885_BOARD_HAUPPAUGE_HVR1290,
Steven Tothd19770e2007-03-11 20:44:05 -0300411 },
412};
413const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
414
415void cx23885_card_list(struct cx23885_dev *dev)
416{
417 int i;
418
419 if (0 == dev->pci->subsystem_vendor &&
420 0 == dev->pci->subsystem_device) {
Steven Toth9c8ced52008-10-16 20:18:44 -0300421 printk(KERN_INFO
422 "%s: Board has no valid PCIe Subsystem ID and can't\n"
423 "%s: be autodetected. Pass card=<n> insmod option\n"
424 "%s: to workaround that. Redirect complaints to the\n"
425 "%s: vendor of the TV card. Best regards,\n"
Steven Tothd19770e2007-03-11 20:44:05 -0300426 "%s: -- tux\n",
427 dev->name, dev->name, dev->name, dev->name, dev->name);
428 } else {
Steven Toth9c8ced52008-10-16 20:18:44 -0300429 printk(KERN_INFO
430 "%s: Your board isn't known (yet) to the driver.\n"
431 "%s: Try to pick one of the existing card configs via\n"
Steven Tothd19770e2007-03-11 20:44:05 -0300432 "%s: card=<n> insmod option. Updating to the latest\n"
433 "%s: version might help as well.\n",
434 dev->name, dev->name, dev->name, dev->name);
435 }
Steven Toth9c8ced52008-10-16 20:18:44 -0300436 printk(KERN_INFO "%s: Here is a list of valid choices for the card=<n> insmod option:\n",
Steven Tothd19770e2007-03-11 20:44:05 -0300437 dev->name);
438 for (i = 0; i < cx23885_bcount; i++)
Steven Toth9c8ced52008-10-16 20:18:44 -0300439 printk(KERN_INFO "%s: card=%d -> %s\n",
Steven Tothd19770e2007-03-11 20:44:05 -0300440 dev->name, i, cx23885_boards[i].name);
441}
442
443static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
444{
445 struct tveeprom tv;
446
Steven Toth9c8ced52008-10-16 20:18:44 -0300447 tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv,
448 eeprom_data);
Steven Tothd19770e2007-03-11 20:44:05 -0300449
Steven Tothd19770e2007-03-11 20:44:05 -0300450 /* Make sure we support the board model */
Steven Toth9c8ced52008-10-16 20:18:44 -0300451 switch (tv.model) {
Michael Krufky5308cf02009-05-12 18:37:35 -0300452 case 22001:
453 /* WinTV-HVR1270 (PCIe, Retail, half height)
454 * ATSC/QAM and basic analog, IR Blast */
455 case 22009:
456 /* WinTV-HVR1210 (PCIe, Retail, half height)
457 * DVB-T and basic analog, IR Blast */
458 case 22011:
459 /* WinTV-HVR1270 (PCIe, Retail, half height)
460 * ATSC/QAM and basic analog, IR Recv */
461 case 22019:
462 /* WinTV-HVR1210 (PCIe, Retail, half height)
463 * DVB-T and basic analog, IR Recv */
464 case 22021:
465 /* WinTV-HVR1275 (PCIe, Retail, half height)
466 * ATSC/QAM and basic analog, IR Recv */
467 case 22029:
468 /* WinTV-HVR1210 (PCIe, Retail, half height)
469 * DVB-T and basic analog, IR Recv */
470 case 22101:
471 /* WinTV-HVR1270 (PCIe, Retail, full height)
472 * ATSC/QAM and basic analog, IR Blast */
473 case 22109:
474 /* WinTV-HVR1210 (PCIe, Retail, full height)
475 * DVB-T and basic analog, IR Blast */
476 case 22111:
477 /* WinTV-HVR1270 (PCIe, Retail, full height)
478 * ATSC/QAM and basic analog, IR Recv */
479 case 22119:
480 /* WinTV-HVR1210 (PCIe, Retail, full height)
481 * DVB-T and basic analog, IR Recv */
482 case 22121:
483 /* WinTV-HVR1275 (PCIe, Retail, full height)
484 * ATSC/QAM and basic analog, IR Recv */
485 case 22129:
486 /* WinTV-HVR1210 (PCIe, Retail, full height)
487 * DVB-T and basic analog, IR Recv */
Michael Krufky36396c82008-05-02 16:14:33 -0300488 case 71009:
489 /* WinTV-HVR1200 (PCIe, Retail, full height)
490 * DVB-T and basic analog */
491 case 71359:
492 /* WinTV-HVR1200 (PCIe, OEM, half height)
493 * DVB-T and basic analog */
494 case 71439:
495 /* WinTV-HVR1200 (PCIe, OEM, half height)
496 * DVB-T and basic analog */
497 case 71449:
498 /* WinTV-HVR1200 (PCIe, OEM, full height)
499 * DVB-T and basic analog */
500 case 71939:
501 /* WinTV-HVR1200 (PCIe, OEM, half height)
502 * DVB-T and basic analog */
503 case 71949:
504 /* WinTV-HVR1200 (PCIe, OEM, full height)
505 * DVB-T and basic analog */
506 case 71959:
507 /* WinTV-HVR1200 (PCIe, OEM, full height)
508 * DVB-T and basic analog */
509 case 71979:
510 /* WinTV-HVR1200 (PCIe, OEM, half height)
511 * DVB-T and basic analog */
512 case 71999:
513 /* WinTV-HVR1200 (PCIe, OEM, full height)
514 * DVB-T and basic analog */
Steven Toth9c8ced52008-10-16 20:18:44 -0300515 case 76601:
516 /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual
517 channel ATSC and MPEG2 HW Encoder */
518 case 77001:
519 /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC
520 and Basic analog */
521 case 77011:
522 /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC
523 and Basic analog */
524 case 77041:
525 /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM
526 and Basic analog */
527 case 77051:
528 /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM
529 and Basic analog */
530 case 78011:
531 /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM,
532 Dual channel ATSC and MPEG2 HW Encoder */
533 case 78501:
534 /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM,
535 Dual channel ATSC and MPEG2 HW Encoder */
536 case 78521:
537 /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM,
538 Dual channel ATSC and MPEG2 HW Encoder */
539 case 78531:
540 /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM,
541 Dual channel ATSC and MPEG2 HW Encoder */
542 case 78631:
543 /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM,
544 Dual channel ATSC and MPEG2 HW Encoder */
545 case 79001:
546 /* WinTV-HVR1250 (PCIe, Retail, IR, full height,
547 ATSC and Basic analog */
548 case 79101:
549 /* WinTV-HVR1250 (PCIe, Retail, IR, half height,
550 ATSC and Basic analog */
551 case 79561:
552 /* WinTV-HVR1250 (PCIe, OEM, No IR, half height,
553 ATSC and Basic analog */
554 case 79571:
555 /* WinTV-HVR1250 (PCIe, OEM, No IR, full height,
556 ATSC and Basic analog */
557 case 79671:
558 /* WinTV-HVR1250 (PCIe, OEM, No IR, half height,
559 ATSC and Basic analog */
Steven Toth66762372008-04-22 15:38:26 -0300560 case 80019:
561 /* WinTV-HVR1400 (Express Card, Retail, IR,
562 * DVB-T and Basic analog */
Michael Krufky36396c82008-05-02 16:14:33 -0300563 case 81509:
564 /* WinTV-HVR1700 (PCIe, OEM, No IR, half height)
565 * DVB-T and MPEG2 HW Encoder */
Steven Totha780a312008-04-19 01:25:52 -0300566 case 81519:
Michael Krufky36396c82008-05-02 16:14:33 -0300567 /* WinTV-HVR1700 (PCIe, OEM, No IR, full height)
Steven Totha780a312008-04-19 01:25:52 -0300568 * DVB-T and MPEG2 HW Encoder */
Steven Tothd19770e2007-03-11 20:44:05 -0300569 break;
Steven Toth136973802009-07-20 15:37:25 -0300570 case 85021:
571 /* WinTV-HVR1850 (PCIe, OEM, RCA in, IR, FM,
572 Dual channel ATSC and MPEG2 HW Encoder */
573 break;
Steven Tothd19770e2007-03-11 20:44:05 -0300574 default:
Steven Toth136973802009-07-20 15:37:25 -0300575 printk(KERN_WARNING "%s: warning: "
576 "unknown hauppauge model #%d\n",
Steven Toth9c8ced52008-10-16 20:18:44 -0300577 dev->name, tv.model);
Steven Tothd19770e2007-03-11 20:44:05 -0300578 break;
579 }
580
581 printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
582 dev->name, tv.model);
583}
584
Michael Krufkyd7cba042008-09-12 13:31:45 -0300585int cx23885_tuner_callback(void *priv, int component, int command, int arg)
Steven Toth8c700172008-01-05 16:55:45 -0300586{
Steven Toth89ce2212008-08-04 22:18:19 -0300587 struct cx23885_tsport *port = priv;
588 struct cx23885_dev *dev = port->dev;
Steven Toth6df51692008-06-30 22:17:05 -0300589 u32 bitmask = 0;
590
Steven Toth89ce2212008-08-04 22:18:19 -0300591 if (command == XC2028_RESET_CLK)
592 return 0;
593
Steven Toth6df51692008-06-30 22:17:05 -0300594 if (command != 0) {
595 printk(KERN_ERR "%s(): Unknown command 0x%x.\n",
596 __func__, command);
597 return -EINVAL;
598 }
Steven Toth8c700172008-01-05 16:55:45 -0300599
Steven Toth9c8ced52008-10-16 20:18:44 -0300600 switch (dev->board) {
Steven Toth90a71b12008-08-04 21:38:46 -0300601 case CX23885_BOARD_HAUPPAUGE_HVR1400:
602 case CX23885_BOARD_HAUPPAUGE_HVR1500:
Steven Toth8c700172008-01-05 16:55:45 -0300603 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
Steven Toth4c56b042008-08-12 13:30:03 -0300604 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -0300605 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Vladimir Geroy34e383d2009-09-18 18:55:47 -0300606 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
Steven Toth90a71b12008-08-04 21:38:46 -0300607 /* Tuner Reset Command */
Steven Toth4c56b042008-08-12 13:30:03 -0300608 bitmask = 0x04;
Steven Toth6df51692008-06-30 22:17:05 -0300609 break;
610 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
Steven Tothaef2d182008-08-04 21:39:53 -0300611 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
Steven Toth4c56b042008-08-12 13:30:03 -0300612 /* Two identical tuners on two different i2c buses,
613 * we need to reset the correct gpio. */
Christopher Pascoed4dc6732009-04-27 11:27:04 -0300614 if (port->nr == 1)
Steven Toth4c56b042008-08-12 13:30:03 -0300615 bitmask = 0x01;
Christopher Pascoed4dc6732009-04-27 11:27:04 -0300616 else if (port->nr == 2)
Steven Toth4c56b042008-08-12 13:30:03 -0300617 bitmask = 0x04;
Steven Toth8c700172008-01-05 16:55:45 -0300618 break;
619 }
620
Steven Toth6df51692008-06-30 22:17:05 -0300621 if (bitmask) {
622 /* Drive the tuner into reset and back out */
623 cx_clear(GP0_IO, bitmask);
624 mdelay(200);
625 cx_set(GP0_IO, bitmask);
626 }
627
628 return 0;
Steven Toth8c700172008-01-05 16:55:45 -0300629}
Steven Toth73c993a2008-01-05 17:08:05 -0300630
Steven Totha6a3f142007-09-08 21:31:56 -0300631void cx23885_gpio_setup(struct cx23885_dev *dev)
632{
Steven Toth9c8ced52008-10-16 20:18:44 -0300633 switch (dev->board) {
Steven Totha6a3f142007-09-08 21:31:56 -0300634 case CX23885_BOARD_HAUPPAUGE_HVR1250:
635 /* GPIO-0 cx24227 demodulator reset */
636 cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */
637 break;
Michael Krufky07b4a832007-12-18 01:09:11 -0300638 case CX23885_BOARD_HAUPPAUGE_HVR1500:
639 /* GPIO-0 cx24227 demodulator */
640 /* GPIO-2 xc3028 tuner */
641
642 /* Put the parts into reset */
643 cx_set(GP0_IO, 0x00050000);
644 cx_clear(GP0_IO, 0x00000005);
645 msleep(5);
646
647 /* Bring the parts out of reset */
648 cx_set(GP0_IO, 0x00050005);
649 break;
Steven Tothd1987d52007-12-18 01:57:06 -0300650 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
651 /* GPIO-0 cx24227 demodulator reset */
652 /* GPIO-2 xc5000 tuner reset */
653 cx_set(GP0_IO, 0x00050005); /* Bring the part out of reset */
654 break;
Steven Totha6a3f142007-09-08 21:31:56 -0300655 case CX23885_BOARD_HAUPPAUGE_HVR1800:
656 /* GPIO-0 656_CLK */
657 /* GPIO-1 656_D0 */
658 /* GPIO-2 8295A Reset */
659 /* GPIO-3-10 cx23417 data0-7 */
660 /* GPIO-11-14 cx23417 addr0-3 */
661 /* GPIO-15-18 cx23417 READY, CS, RD, WR */
662 /* GPIO-19 IR_RX */
Michael Krufky3ba71d22007-12-07 01:40:36 -0300663
Steven Totha589b662008-01-13 23:44:47 -0300664 /* CX23417 GPIO's */
665 /* EIO15 Zilog Reset */
666 /* EIO14 S5H1409/CX24227 Reset */
Steven Tothf659c512009-06-25 23:43:31 -0300667 mc417_gpio_enable(dev, GPIO_15 | GPIO_14, 1);
668
669 /* Put the demod into reset and protect the eeprom */
670 mc417_gpio_clear(dev, GPIO_15 | GPIO_14);
671 mdelay(100);
672
673 /* Bring the demod and blaster out of reset */
674 mc417_gpio_set(dev, GPIO_15 | GPIO_14);
675 mdelay(100);
Steven Totha589b662008-01-13 23:44:47 -0300676
Steven Toth5206d6e2008-01-10 02:09:27 -0300677 /* Force the TDA8295A into reset and back */
Steven Toth21ff3e42009-06-25 23:50:39 -0300678 cx23885_gpio_enable(dev, GPIO_2, 1);
679 cx23885_gpio_set(dev, GPIO_2);
Steven Toth5206d6e2008-01-10 02:09:27 -0300680 mdelay(20);
Steven Toth21ff3e42009-06-25 23:50:39 -0300681 cx23885_gpio_clear(dev, GPIO_2);
Steven Toth5206d6e2008-01-10 02:09:27 -0300682 mdelay(20);
Steven Toth21ff3e42009-06-25 23:50:39 -0300683 cx23885_gpio_set(dev, GPIO_2);
Steven Toth5206d6e2008-01-10 02:09:27 -0300684 mdelay(20);
Steven Totha6a3f142007-09-08 21:31:56 -0300685 break;
Steven Tothb3ea0162008-04-19 01:14:19 -0300686 case CX23885_BOARD_HAUPPAUGE_HVR1200:
687 /* GPIO-0 tda10048 demodulator reset */
688 /* GPIO-2 tda18271 tuner reset */
689
690 /* Put the parts into reset and back */
691 cx_set(GP0_IO, 0x00050000);
692 mdelay(20);
693 cx_clear(GP0_IO, 0x00000005);
694 mdelay(20);
695 cx_set(GP0_IO, 0x00050005);
696 break;
Steven Totha780a312008-04-19 01:25:52 -0300697 case CX23885_BOARD_HAUPPAUGE_HVR1700:
698 /* GPIO-0 TDA10048 demodulator reset */
699 /* GPIO-2 TDA8295A Reset */
700 /* GPIO-3-10 cx23417 data0-7 */
701 /* GPIO-11-14 cx23417 addr0-3 */
702 /* GPIO-15-18 cx23417 READY, CS, RD, WR */
703
704 /* The following GPIO's are on the interna AVCore (cx25840) */
705 /* GPIO-19 IR_RX */
706 /* GPIO-20 IR_TX 416/DVBT Select */
707 /* GPIO-21 IIS DAT */
708 /* GPIO-22 IIS WCLK */
709 /* GPIO-23 IIS BCLK */
710
711 /* Put the parts into reset and back */
712 cx_set(GP0_IO, 0x00050000);
713 mdelay(20);
714 cx_clear(GP0_IO, 0x00000005);
715 mdelay(20);
716 cx_set(GP0_IO, 0x00050005);
717 break;
Steven Toth66762372008-04-22 15:38:26 -0300718 case CX23885_BOARD_HAUPPAUGE_HVR1400:
719 /* GPIO-0 Dibcom7000p demodulator reset */
720 /* GPIO-2 xc3028L tuner reset */
721 /* GPIO-13 LED */
722
723 /* Put the parts into reset and back */
724 cx_set(GP0_IO, 0x00050000);
725 mdelay(20);
726 cx_clear(GP0_IO, 0x00000005);
727 mdelay(20);
728 cx_set(GP0_IO, 0x00050005);
729 break;
Steven Toth1ecc5ae2008-06-30 21:23:50 -0300730 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
731 /* GPIO-0 xc5000 tuner reset i2c bus 0 */
732 /* GPIO-1 s5h1409 demod reset i2c bus 0 */
733 /* GPIO-2 xc5000 tuner reset i2c bus 1 */
734 /* GPIO-3 s5h1409 demod reset i2c bus 0 */
735
736 /* Put the parts into reset and back */
737 cx_set(GP0_IO, 0x000f0000);
738 mdelay(20);
739 cx_clear(GP0_IO, 0x0000000f);
740 mdelay(20);
741 cx_set(GP0_IO, 0x000f000f);
742 break;
Steven Tothaef2d182008-08-04 21:39:53 -0300743 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
744 /* GPIO-0 portb xc3028 reset */
745 /* GPIO-1 portb zl10353 reset */
746 /* GPIO-2 portc xc3028 reset */
747 /* GPIO-3 portc zl10353 reset */
748
749 /* Put the parts into reset and back */
750 cx_set(GP0_IO, 0x000f0000);
751 mdelay(20);
752 cx_clear(GP0_IO, 0x0000000f);
753 mdelay(20);
754 cx_set(GP0_IO, 0x000f000f);
755 break;
Steven Toth4c56b042008-08-12 13:30:03 -0300756 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -0300757 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Vladimir Geroy34e383d2009-09-18 18:55:47 -0300758 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
Steven Toth4c56b042008-08-12 13:30:03 -0300759 /* GPIO-2 xc3028 tuner reset */
760
761 /* The following GPIO's are on the internal AVCore (cx25840) */
762 /* GPIO-? zl10353 demod reset */
763
764 /* Put the parts into reset and back */
765 cx_set(GP0_IO, 0x00040000);
766 mdelay(20);
767 cx_clear(GP0_IO, 0x00000004);
768 mdelay(20);
769 cx_set(GP0_IO, 0x00040004);
770 break;
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300771 case CX23885_BOARD_TBS_6920:
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300772 case CX23885_BOARD_TEVII_S470:
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300773 cx_write(MC417_CTL, 0x00000036);
774 cx_write(MC417_OEN, 0x00001000);
775 cx_write(MC417_RWD, 0x00001800);
776 break;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300777 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
778 /* GPIO-0 INTA from CiMax1
779 GPIO-1 INTB from CiMax2
780 GPIO-2 reset chips
781 GPIO-3 to GPIO-10 data/addr for CA
782 GPIO-11 ~CS0 to CiMax1
783 GPIO-12 ~CS1 to CiMax2
784 GPIO-13 ADL0 load LSB addr
785 GPIO-14 ADL1 load MSB addr
786 GPIO-15 ~RDY from CiMax
787 GPIO-17 ~RD to CiMax
788 GPIO-18 ~WR to CiMax
789 */
790 cx_set(GP0_IO, 0x00040000); /* GPIO as out */
791 /* GPIO1 and GPIO2 as INTA and INTB from CiMaxes, reset low */
792 cx_clear(GP0_IO, 0x00030004);
793 mdelay(100);/* reset delay */
794 cx_set(GP0_IO, 0x00040004); /* GPIO as out, reset high */
795 cx_write(MC417_CTL, 0x00000037);/* enable GPIO3-18 pins */
796 /* GPIO-15 IN as ~ACK, rest as OUT */
797 cx_write(MC417_OEN, 0x00001000);
798 /* ~RD, ~WR high; ADL0, ADL1 low; ~CS0, ~CS1 high */
799 cx_write(MC417_RWD, 0x0000c300);
800 /* enable irq */
801 cx_write(GPIO_ISM, 0x00000000);/* INTERRUPTS active low*/
802 break;
Steven Toth2074dff2009-05-02 11:39:46 -0300803 case CX23885_BOARD_HAUPPAUGE_HVR1270:
Michael Krufkyd099bec2009-05-08 22:39:24 -0300804 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Michael Krufky19bc5792009-05-08 16:05:29 -0300805 case CX23885_BOARD_HAUPPAUGE_HVR1255:
Michael Krufky6b926ec2009-05-12 17:32:17 -0300806 case CX23885_BOARD_HAUPPAUGE_HVR1210:
Michael Krufkyd099bec2009-05-08 22:39:24 -0300807 /* GPIO-5 RF Control: 0 = RF1 Terrestrial, 1 = RF2 Cable */
Michael Krufky6b926ec2009-05-12 17:32:17 -0300808 /* GPIO-6 I2C Gate which can isolate the demod from the bus */
809 /* GPIO-9 Demod reset */
Steven Toth2074dff2009-05-02 11:39:46 -0300810
811 /* Put the parts into reset and back */
Michael Krufkyd099bec2009-05-08 22:39:24 -0300812 cx23885_gpio_enable(dev, GPIO_9 | GPIO_6 | GPIO_5, 1);
813 cx23885_gpio_set(dev, GPIO_9 | GPIO_6 | GPIO_5);
Steven Toth2074dff2009-05-02 11:39:46 -0300814 cx23885_gpio_clear(dev, GPIO_9);
815 mdelay(20);
816 cx23885_gpio_set(dev, GPIO_9);
817 break;
David Wong493b7122009-05-18 05:25:49 -0300818 case CX23885_BOARD_MYGICA_X8506:
David Wong2365b2d2009-06-17 01:38:12 -0300819 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
David T.L. Wong8e069bb2009-10-21 12:29:11 -0300820 /* GPIO-0 (0)Analog / (1)Digital TV */
David Wong493b7122009-05-18 05:25:49 -0300821 /* GPIO-1 reset XC5000 */
David Wong2365b2d2009-06-17 01:38:12 -0300822 /* GPIO-2 reset LGS8GL5 / LGS8G75 */
David T.L. Wong8e069bb2009-10-21 12:29:11 -0300823 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1 | GPIO_2, 1);
824 cx23885_gpio_clear(dev, GPIO_1 | GPIO_2);
David Wong493b7122009-05-18 05:25:49 -0300825 mdelay(100);
David T.L. Wong8e069bb2009-10-21 12:29:11 -0300826 cx23885_gpio_set(dev, GPIO_0 | GPIO_1 | GPIO_2);
David Wong493b7122009-05-18 05:25:49 -0300827 mdelay(100);
828 break;
Steven Toth136973802009-07-20 15:37:25 -0300829 case CX23885_BOARD_HAUPPAUGE_HVR1850:
Michael Krufkyaee0b242009-11-11 01:52:45 -0300830 case CX23885_BOARD_HAUPPAUGE_HVR1290:
Steven Toth136973802009-07-20 15:37:25 -0300831 /* GPIO-0 656_CLK */
832 /* GPIO-1 656_D0 */
833 /* GPIO-2 Wake# */
834 /* GPIO-3-10 cx23417 data0-7 */
835 /* GPIO-11-14 cx23417 addr0-3 */
836 /* GPIO-15-18 cx23417 READY, CS, RD, WR */
837 /* GPIO-19 IR_RX */
838 /* GPIO-20 C_IR_TX */
839 /* GPIO-21 I2S DAT */
840 /* GPIO-22 I2S WCLK */
841 /* GPIO-23 I2S BCLK */
842 /* ALT GPIO: EXP GPIO LATCH */
843
844 /* CX23417 GPIO's */
845 /* GPIO-14 S5H1411/CX24228 Reset */
846 /* GPIO-13 EEPROM write protect */
847 mc417_gpio_enable(dev, GPIO_14 | GPIO_13, 1);
848
849 /* Put the demod into reset and protect the eeprom */
850 mc417_gpio_clear(dev, GPIO_14 | GPIO_13);
851 mdelay(100);
852
853 /* Bring the demod out of reset */
854 mc417_gpio_set(dev, GPIO_14);
855 mdelay(100);
856
857 /* CX24228 GPIO */
858 /* Connected to IF / Mux */
859 break;
Steven Totha6a3f142007-09-08 21:31:56 -0300860 }
861}
862
863int cx23885_ir_init(struct cx23885_dev *dev)
864{
Andy Walls29f8a0a2009-09-26 23:17:30 -0300865 int ret = 0;
Steven Totha6a3f142007-09-08 21:31:56 -0300866 switch (dev->board) {
867 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufky07b4a832007-12-18 01:09:11 -0300868 case CX23885_BOARD_HAUPPAUGE_HVR1500:
Steven Tothd1987d52007-12-18 01:57:06 -0300869 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
Steven Totha6a3f142007-09-08 21:31:56 -0300870 case CX23885_BOARD_HAUPPAUGE_HVR1800:
Steven Tothb3ea0162008-04-19 01:14:19 -0300871 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Toth66762372008-04-22 15:38:26 -0300872 case CX23885_BOARD_HAUPPAUGE_HVR1400:
Steven Toth2074dff2009-05-02 11:39:46 -0300873 case CX23885_BOARD_HAUPPAUGE_HVR1270:
Michael Krufkyd099bec2009-05-08 22:39:24 -0300874 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Michael Krufky19bc5792009-05-08 16:05:29 -0300875 case CX23885_BOARD_HAUPPAUGE_HVR1255:
Michael Krufky6b926ec2009-05-12 17:32:17 -0300876 case CX23885_BOARD_HAUPPAUGE_HVR1210:
Steven Totha6a3f142007-09-08 21:31:56 -0300877 /* FIXME: Implement me */
878 break;
Andy Walls29f8a0a2009-09-26 23:17:30 -0300879 case CX23885_BOARD_HAUPPAUGE_HVR1850:
880 ret = cx23888_ir_probe(dev);
881 if (ret)
882 break;
883 dev->sd_ir = cx23885_find_hw(dev, CX23885_HW_888_IR);
Andy Wallsf59ad612009-09-27 19:51:50 -0300884 dev->pci_irqmask |= PCI_MSK_IR;
Andy Walls29f8a0a2009-09-26 23:17:30 -0300885 break;
Steven Toth12886872008-08-04 21:41:06 -0300886 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
887 request_module("ir-kbd-i2c");
888 break;
Steven Totha6a3f142007-09-08 21:31:56 -0300889 }
890
Andy Walls29f8a0a2009-09-26 23:17:30 -0300891 return ret;
Steven Totha6a3f142007-09-08 21:31:56 -0300892}
893
Andy Wallsf59ad612009-09-27 19:51:50 -0300894void cx23885_ir_fini(struct cx23885_dev *dev)
895{
896 switch (dev->board) {
897 case CX23885_BOARD_HAUPPAUGE_HVR1850:
898 dev->pci_irqmask &= ~PCI_MSK_IR;
899 cx_clear(PCI_INT_MSK, PCI_MSK_IR);
900 cx23888_ir_remove(dev);
901 dev->sd_ir = NULL;
902 break;
903 }
904}
905
906void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
907{
908 switch (dev->board) {
909 case CX23885_BOARD_HAUPPAUGE_HVR1850:
910 if (dev->sd_ir && (dev->pci_irqmask & PCI_MSK_IR))
911 cx_set(PCI_INT_MSK, PCI_MSK_IR);
912 break;
913 }
914}
915
Steven Tothd19770e2007-03-11 20:44:05 -0300916void cx23885_card_setup(struct cx23885_dev *dev)
917{
Steven Totha6a3f142007-09-08 21:31:56 -0300918 struct cx23885_tsport *ts1 = &dev->ts1;
919 struct cx23885_tsport *ts2 = &dev->ts2;
920
Steven Tothd19770e2007-03-11 20:44:05 -0300921 static u8 eeprom[256];
922
923 if (dev->i2c_bus[0].i2c_rc == 0) {
924 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
Michael Krufky44a64812007-03-20 23:00:18 -0300925 tveeprom_read(&dev->i2c_bus[0].i2c_client,
926 eeprom, sizeof(eeprom));
Steven Tothd19770e2007-03-11 20:44:05 -0300927 }
928
929 switch (dev->board) {
Steven Totha77743b2007-08-22 21:01:20 -0300930 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufky07b4a832007-12-18 01:09:11 -0300931 case CX23885_BOARD_HAUPPAUGE_HVR1500:
Steven Tothd1987d52007-12-18 01:57:06 -0300932 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
Steven Toth66762372008-04-22 15:38:26 -0300933 case CX23885_BOARD_HAUPPAUGE_HVR1400:
Steven Tothc88133e2008-03-29 17:36:09 -0300934 if (dev->i2c_bus[0].i2c_rc == 0)
935 hauppauge_eeprom(dev, eeprom+0x80);
936 break;
Steven Tothd19770e2007-03-11 20:44:05 -0300937 case CX23885_BOARD_HAUPPAUGE_HVR1800:
938 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
Steven Tothb3ea0162008-04-19 01:14:19 -0300939 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Totha780a312008-04-19 01:25:52 -0300940 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Toth2074dff2009-05-02 11:39:46 -0300941 case CX23885_BOARD_HAUPPAUGE_HVR1270:
Michael Krufkyd099bec2009-05-08 22:39:24 -0300942 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Michael Krufky19bc5792009-05-08 16:05:29 -0300943 case CX23885_BOARD_HAUPPAUGE_HVR1255:
Michael Krufky6b926ec2009-05-12 17:32:17 -0300944 case CX23885_BOARD_HAUPPAUGE_HVR1210:
Steven Toth136973802009-07-20 15:37:25 -0300945 case CX23885_BOARD_HAUPPAUGE_HVR1850:
Michael Krufkyaee0b242009-11-11 01:52:45 -0300946 case CX23885_BOARD_HAUPPAUGE_HVR1290:
Steven Tothd19770e2007-03-11 20:44:05 -0300947 if (dev->i2c_bus[0].i2c_rc == 0)
Steven Tothc88133e2008-03-29 17:36:09 -0300948 hauppauge_eeprom(dev, eeprom+0xc0);
Steven Tothd19770e2007-03-11 20:44:05 -0300949 break;
950 }
Steven Totha6a3f142007-09-08 21:31:56 -0300951
952 switch (dev->board) {
Michael Krufky335377b2008-05-07 01:43:10 -0300953 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
Steven Tothaef2d182008-08-04 21:39:53 -0300954 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
Michael Krufky335377b2008-05-07 01:43:10 -0300955 ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
956 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
957 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
958 /* break omitted intentionally */
Steven Totha6a3f142007-09-08 21:31:56 -0300959 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
960 ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
961 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
962 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
963 break;
Steven Totha589b662008-01-13 23:44:47 -0300964 case CX23885_BOARD_HAUPPAUGE_HVR1800:
965 /* Defaults for VID B - Analog encoder */
966 /* DREQ_POL, SMODE, PUNC_CLK, MCLK_POL Serial bus + punc clk */
967 ts1->gen_ctrl_val = 0x10e;
968 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
969 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
970
971 /* APB_TSVALERR_POL (active low)*/
972 ts1->vld_misc_val = 0x2000;
973 ts1->hw_sop_ctrl_val = (0x47 << 16 | 188 << 4 | 0xc);
974
975 /* Defaults for VID C */
976 ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
977 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
978 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
979 break;
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300980 case CX23885_BOARD_TEVII_S470:
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300981 case CX23885_BOARD_TBS_6920:
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300982 case CX23885_BOARD_DVBWORLD_2005:
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300983 ts1->gen_ctrl_val = 0x5; /* Parallel */
984 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
985 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
986 break;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300987 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
988 ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
989 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
990 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
991 ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
992 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
993 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
994 break;
David Wong493b7122009-05-18 05:25:49 -0300995 case CX23885_BOARD_MYGICA_X8506:
David Wong2365b2d2009-06-17 01:38:12 -0300996 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
David Wong493b7122009-05-18 05:25:49 -0300997 ts1->gen_ctrl_val = 0x5; /* Parallel */
998 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
999 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
1000 break;
Steven Totha6a3f142007-09-08 21:31:56 -03001001 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufky07b4a832007-12-18 01:09:11 -03001002 case CX23885_BOARD_HAUPPAUGE_HVR1500:
Steven Tothd1987d52007-12-18 01:57:06 -03001003 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
Steven Totha6a3f142007-09-08 21:31:56 -03001004 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
Steven Tothb3ea0162008-04-19 01:14:19 -03001005 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Totha780a312008-04-19 01:25:52 -03001006 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Toth66762372008-04-22 15:38:26 -03001007 case CX23885_BOARD_HAUPPAUGE_HVR1400:
Steven Toth4c56b042008-08-12 13:30:03 -03001008 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -03001009 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Steven Toth2074dff2009-05-02 11:39:46 -03001010 case CX23885_BOARD_HAUPPAUGE_HVR1270:
Michael Krufkyd099bec2009-05-08 22:39:24 -03001011 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Michael Krufky19bc5792009-05-08 16:05:29 -03001012 case CX23885_BOARD_HAUPPAUGE_HVR1255:
Michael Krufky6b926ec2009-05-12 17:32:17 -03001013 case CX23885_BOARD_HAUPPAUGE_HVR1210:
Steven Toth136973802009-07-20 15:37:25 -03001014 case CX23885_BOARD_HAUPPAUGE_HVR1850:
Vladimir Geroy34e383d2009-09-18 18:55:47 -03001015 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
Michael Krufkyaee0b242009-11-11 01:52:45 -03001016 case CX23885_BOARD_HAUPPAUGE_HVR1290:
Steven Totha6a3f142007-09-08 21:31:56 -03001017 default:
1018 ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
1019 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
1020 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
1021 }
1022
Steven Tothce89cfb2008-04-19 01:36:06 -03001023 /* Certain boards support analog, or require the avcore to be
1024 * loaded, ensure this happens.
1025 */
1026 switch (dev->board) {
1027 case CX23885_BOARD_HAUPPAUGE_HVR1800:
1028 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
1029 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Toth4c56b042008-08-12 13:30:03 -03001030 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -03001031 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001032 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
Vladimir Geroy34e383d2009-09-18 18:55:47 -03001033 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
Andy Wallsc6b70532009-09-27 00:14:33 -03001034 case CX23885_BOARD_HAUPPAUGE_HVR1850:
David T.L. Wongbc1548a2009-10-21 11:09:28 -03001035 case CX23885_BOARD_MYGICA_X8506:
1036 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
Michael Krufkyaee0b242009-11-11 01:52:45 -03001037 case CX23885_BOARD_HAUPPAUGE_HVR1290:
Hans Verkuile6574f22009-04-01 03:57:53 -03001038 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1039 &dev->i2c_bus[2].i2c_adap,
Hans Verkuil53dacb12009-08-10 02:49:08 -03001040 "cx25840", "cx25840", 0x88 >> 1, NULL);
Hans Verkuilcc26b072009-03-29 19:20:26 -03001041 v4l2_subdev_call(dev->sd_cx25840, core, load_fw);
Steven Tothce89cfb2008-04-19 01:36:06 -03001042 break;
1043 }
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001044
1045 /* AUX-PLL 27MHz CLK */
1046 switch (dev->board) {
1047 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1048 netup_initialize(dev);
1049 break;
1050 }
Steven Tothd19770e2007-03-11 20:44:05 -03001051}
1052
1053/* ------------------------------------------------------------------ */