blob: b7d1f2f18d3a45e1939b61e69ea1dd9ff6448cc9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * budget-av.c: driver for the SAA7146 based Budget DVB cards
3 * with analog video in
4 *
5 * Compiled from various sources by Michael Hunold <michael@mihu.de>
6 *
7 * CI interface support (c) 2004 Olivier Gournet <ogournet@anevia.com> &
8 * Andrew de Quincey <adq_dvb@lidskialf.net>
9 *
10 * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
11 *
12 * Copyright (C) 1999-2002 Ralph Metzler
13 * & Marcus Metzler for convergence integrated media GmbH
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 *
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
31 *
32 *
33 * the project's page is at http://www.linuxtv.org/dvb/
34 */
35
36#include "budget.h"
37#include "stv0299.h"
Hartmut Birraa323ac2007-04-21 19:37:17 -030038#include "tda1002x.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include "tda1004x.h"
Andrew de Quincey1c72cfdc2006-09-05 17:58:20 -030040#include "tua6100.h"
Regis Prevotf8bf1342006-01-11 23:31:53 -020041#include "dvb-pll.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <media/saa7146_vv.h>
43#include <linux/module.h>
44#include <linux/errno.h>
45#include <linux/slab.h>
46#include <linux/interrupt.h>
47#include <linux/input.h>
48#include <linux/spinlock.h>
49
50#include "dvb_ca_en50221.h"
51
52#define DEBICICAM 0x02420000
53
Andrew de Quincey5c1208b2006-05-22 10:32:02 -030054#define SLOTSTATUS_NONE 1
55#define SLOTSTATUS_PRESENT 2
56#define SLOTSTATUS_RESET 4
57#define SLOTSTATUS_READY 8
58#define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060struct budget_av {
61 struct budget budget;
62 struct video_device *vd;
63 int cur_input;
64 int has_saa7113;
65 struct tasklet_struct ciintf_irq_tasklet;
66 int slot_status;
67 struct dvb_ca_en50221 ca;
Andrew de Quincey5c1208b2006-05-22 10:32:02 -030068 u8 reinitialise_demod:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069};
70
Andrew de Quincey5c1208b2006-05-22 10:32:02 -030071static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot);
72
73
Andrew de Quincey86f40cc2006-03-30 15:53:35 -030074/* GPIO Connections:
75 * 0 - Vcc/Reset (Reset is controlled by capacitor). Resets the frontend *AS WELL*!
76 * 1 - CI memory select 0=>IO memory, 1=>Attribute Memory
77 * 2 - CI Card Enable (Active Low)
78 * 3 - CI Card Detect
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -070079 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81/****************************************************************************
82 * INITIALIZATION
83 ****************************************************************************/
84
85static u8 i2c_readreg(struct i2c_adapter *i2c, u8 id, u8 reg)
86{
87 u8 mm1[] = { 0x00 };
88 u8 mm2[] = { 0x00 };
89 struct i2c_msg msgs[2];
90
91 msgs[0].flags = 0;
92 msgs[1].flags = I2C_M_RD;
93 msgs[0].addr = msgs[1].addr = id / 2;
94 mm1[0] = reg;
95 msgs[0].len = 1;
96 msgs[1].len = 1;
97 msgs[0].buf = mm1;
98 msgs[1].buf = mm2;
99
100 i2c_transfer(i2c, msgs, 2);
101
102 return mm2[0];
103}
104
105static int i2c_readregs(struct i2c_adapter *i2c, u8 id, u8 reg, u8 * buf, u8 len)
106{
107 u8 mm1[] = { reg };
108 struct i2c_msg msgs[2] = {
109 {.addr = id / 2,.flags = 0,.buf = mm1,.len = 1},
110 {.addr = id / 2,.flags = I2C_M_RD,.buf = buf,.len = len}
111 };
112
113 if (i2c_transfer(i2c, msgs, 2) != 2)
114 return -EIO;
115
116 return 0;
117}
118
119static int i2c_writereg(struct i2c_adapter *i2c, u8 id, u8 reg, u8 val)
120{
121 u8 msg[2] = { reg, val };
122 struct i2c_msg msgs;
123
124 msgs.flags = 0;
125 msgs.addr = id / 2;
126 msgs.len = 2;
127 msgs.buf = msg;
128 return i2c_transfer(i2c, &msgs, 1);
129}
130
131static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
132{
133 struct budget_av *budget_av = (struct budget_av *) ca->data;
134 int result;
135
136 if (slot != 0)
137 return -EINVAL;
138
139 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
140 udelay(1);
141
Andrew de Quincey2d0235d2006-01-09 15:25:05 -0200142 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300143 if (result == -ETIMEDOUT) {
144 ciintf_slot_shutdown(ca, slot);
145 printk(KERN_INFO "budget-av: cam ejected 1\n");
146 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 return result;
148}
149
150static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
151{
152 struct budget_av *budget_av = (struct budget_av *) ca->data;
153 int result;
154
155 if (slot != 0)
156 return -EINVAL;
157
158 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
159 udelay(1);
160
Andrew de Quincey2d0235d2006-01-09 15:25:05 -0200161 result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300162 if (result == -ETIMEDOUT) {
163 ciintf_slot_shutdown(ca, slot);
164 printk(KERN_INFO "budget-av: cam ejected 2\n");
165 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 return result;
167}
168
169static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
170{
171 struct budget_av *budget_av = (struct budget_av *) ca->data;
172 int result;
173
174 if (slot != 0)
175 return -EINVAL;
176
177 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
178 udelay(1);
179
180 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
Christoph Pfister87270732008-04-09 17:34:09 -0300181 if (result == -ETIMEDOUT) {
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300182 ciintf_slot_shutdown(ca, slot);
183 printk(KERN_INFO "budget-av: cam ejected 3\n");
184 return -ETIMEDOUT;
185 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 return result;
187}
188
189static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
190{
191 struct budget_av *budget_av = (struct budget_av *) ca->data;
192 int result;
193
194 if (slot != 0)
195 return -EINVAL;
196
197 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
198 udelay(1);
199
200 result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300201 if (result == -ETIMEDOUT) {
202 ciintf_slot_shutdown(ca, slot);
203 printk(KERN_INFO "budget-av: cam ejected 5\n");
204 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 return result;
206}
207
208static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
209{
210 struct budget_av *budget_av = (struct budget_av *) ca->data;
211 struct saa7146_dev *saa = budget_av->budget.dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
213 if (slot != 0)
214 return -EINVAL;
215
216 dprintk(1, "ciintf_slot_reset\n");
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300217 budget_av->slot_status = SLOTSTATUS_RESET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700219 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700221 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
222 msleep(2);
223 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); /* Vcc on */
224 msleep(20); /* 20 ms Vcc settling time */
225
226 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); /* enable card */
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300227 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
228 msleep(20);
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700229
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300230 /* reinitialise the frontend if necessary */
231 if (budget_av->reinitialise_demod)
232 dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 return 0;
235}
236
237static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
238{
239 struct budget_av *budget_av = (struct budget_av *) ca->data;
240 struct saa7146_dev *saa = budget_av->budget.dev;
241
242 if (slot != 0)
243 return -EINVAL;
244
245 dprintk(1, "ciintf_slot_shutdown\n");
246
247 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300248 budget_av->slot_status = SLOTSTATUS_NONE;
249
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 return 0;
251}
252
253static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
254{
255 struct budget_av *budget_av = (struct budget_av *) ca->data;
256 struct saa7146_dev *saa = budget_av->budget.dev;
257
258 if (slot != 0)
259 return -EINVAL;
260
261 dprintk(1, "ciintf_slot_ts_enable: %d\n", budget_av->slot_status);
262
263 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300264
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 return 0;
266}
267
268static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
269{
270 struct budget_av *budget_av = (struct budget_av *) ca->data;
271 struct saa7146_dev *saa = budget_av->budget.dev;
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300272 int result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
274 if (slot != 0)
275 return -EINVAL;
276
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300277 /* test the card detect line - needs to be done carefully
278 * since it never goes high for some CAMs on this interface (e.g. topuptv) */
279 if (budget_av->slot_status == SLOTSTATUS_NONE) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
281 udelay(1);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300282 if (saa7146_read(saa, PSR) & MASK_06) {
283 if (budget_av->slot_status == SLOTSTATUS_NONE) {
284 budget_av->slot_status = SLOTSTATUS_PRESENT;
285 printk(KERN_INFO "budget-av: cam inserted A\n");
Andrew de Quincey2d0235d2006-01-09 15:25:05 -0200286 }
287 }
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300288 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
289 }
Andrew de Quincey2d0235d2006-01-09 15:25:05 -0200290
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300291 /* We also try and read from IO memory to work round the above detection bug. If
292 * there is no CAM, we will get a timeout. Only done if there is no cam
293 * present, since this test actually breaks some cams :(
294 *
295 * if the CI interface is not open, we also do the above test since we
296 * don't care if the cam has problems - we'll be resetting it on open() anyway */
297 if ((budget_av->slot_status == SLOTSTATUS_NONE) || (!open)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300299 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1);
300 if ((result >= 0) && (budget_av->slot_status == SLOTSTATUS_NONE)) {
301 budget_av->slot_status = SLOTSTATUS_PRESENT;
302 printk(KERN_INFO "budget-av: cam inserted B\n");
303 } else if (result < 0) {
304 if (budget_av->slot_status != SLOTSTATUS_NONE) {
305 ciintf_slot_shutdown(ca, slot);
306 printk(KERN_INFO "budget-av: cam ejected 5\n");
307 return 0;
308 }
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700309 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 }
311
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300312 /* read from attribute memory in reset/ready state to know when the CAM is ready */
313 if (budget_av->slot_status == SLOTSTATUS_RESET) {
314 result = ciintf_read_attribute_mem(ca, slot, 0);
315 if (result == 0x1d) {
316 budget_av->slot_status = SLOTSTATUS_READY;
317 }
318 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300320 /* work out correct return code */
321 if (budget_av->slot_status != SLOTSTATUS_NONE) {
322 if (budget_av->slot_status & SLOTSTATUS_READY) {
323 return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
324 }
325 return DVB_CA_EN50221_POLL_CAM_PRESENT;
326 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 return 0;
328}
329
330static int ciintf_init(struct budget_av *budget_av)
331{
332 struct saa7146_dev *saa = budget_av->budget.dev;
333 int result;
334
335 memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221));
336
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700337 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
338 saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO);
340 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
341
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 /* Enable DEBI pins */
Hartmut Birr2a893de2006-12-03 21:08:08 -0300343 saa7146_write(saa, MC1, MASK_27 | MASK_11);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
345 /* register CI interface */
346 budget_av->ca.owner = THIS_MODULE;
347 budget_av->ca.read_attribute_mem = ciintf_read_attribute_mem;
348 budget_av->ca.write_attribute_mem = ciintf_write_attribute_mem;
349 budget_av->ca.read_cam_control = ciintf_read_cam_control;
350 budget_av->ca.write_cam_control = ciintf_write_cam_control;
351 budget_av->ca.slot_reset = ciintf_slot_reset;
352 budget_av->ca.slot_shutdown = ciintf_slot_shutdown;
353 budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable;
354 budget_av->ca.poll_slot_status = ciintf_poll_slot_status;
355 budget_av->ca.data = budget_av;
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300356 budget_av->budget.ci_present = 1;
357 budget_av->slot_status = SLOTSTATUS_NONE;
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700358
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -0700359 if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 &budget_av->ca, 0, 1)) != 0) {
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700361 printk(KERN_ERR "budget-av: ci initialisation failed.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 goto error;
363 }
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700364
365 printk(KERN_INFO "budget-av: ci interface initialised.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 return 0;
367
368error:
Hartmut Birr2a893de2006-12-03 21:08:08 -0300369 saa7146_write(saa, MC1, MASK_27);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 return result;
371}
372
373static void ciintf_deinit(struct budget_av *budget_av)
374{
375 struct saa7146_dev *saa = budget_av->budget.dev;
376
377 saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
378 saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);
379 saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT);
380 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
381
382 /* release the CA device */
383 dvb_ca_en50221_release(&budget_av->ca);
384
385 /* disable DEBI pins */
Hartmut Birr2a893de2006-12-03 21:08:08 -0300386 saa7146_write(saa, MC1, MASK_27);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387}
388
389
390static const u8 saa7113_tab[] = {
391 0x01, 0x08,
392 0x02, 0xc0,
393 0x03, 0x33,
394 0x04, 0x00,
395 0x05, 0x00,
396 0x06, 0xeb,
397 0x07, 0xe0,
398 0x08, 0x28,
399 0x09, 0x00,
400 0x0a, 0x80,
401 0x0b, 0x47,
402 0x0c, 0x40,
403 0x0d, 0x00,
404 0x0e, 0x01,
405 0x0f, 0x44,
406
407 0x10, 0x08,
408 0x11, 0x0c,
409 0x12, 0x7b,
410 0x13, 0x00,
411 0x15, 0x00, 0x16, 0x00, 0x17, 0x00,
412
413 0x57, 0xff,
414 0x40, 0x82, 0x58, 0x00, 0x59, 0x54, 0x5a, 0x07,
415 0x5b, 0x83, 0x5e, 0x00,
416 0xff
417};
418
419static int saa7113_init(struct budget_av *budget_av)
420{
421 struct budget *budget = &budget_av->budget;
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700422 struct saa7146_dev *saa = budget->dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 const u8 *data = saa7113_tab;
424
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700425 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
426 msleep(200);
427
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 if (i2c_writereg(&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) {
429 dprintk(1, "saa7113 not found on KNC card\n");
430 return -ENODEV;
431 }
432
433 dprintk(1, "saa7113 detected and initializing\n");
434
435 while (*data != 0xff) {
436 i2c_writereg(&budget->i2c_adap, 0x4a, *data, *(data + 1));
437 data += 2;
438 }
439
440 dprintk(1, "saa7113 status=%02x\n", i2c_readreg(&budget->i2c_adap, 0x4a, 0x1f));
441
442 return 0;
443}
444
445static int saa7113_setinput(struct budget_av *budget_av, int input)
446{
447 struct budget *budget = &budget_av->budget;
448
449 if (1 != budget_av->has_saa7113)
450 return -ENODEV;
451
452 if (input == 1) {
453 i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc7);
454 i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x80);
455 } else if (input == 0) {
456 i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc0);
457 i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x00);
458 } else
459 return -EINVAL;
460
461 budget_av->cur_input = input;
462 return 0;
463}
464
465
466static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
467{
468 u8 aclk = 0;
469 u8 bclk = 0;
470 u8 m1;
471
472 aclk = 0xb5;
473 if (srate < 2000000)
474 bclk = 0x86;
475 else if (srate < 5000000)
476 bclk = 0x89;
477 else if (srate < 15000000)
478 bclk = 0x8f;
479 else if (srate < 45000000)
480 bclk = 0x95;
481
482 m1 = 0x14;
483 if (srate < 4000000)
484 m1 = 0x10;
485
486 stv0299_writereg(fe, 0x13, aclk);
487 stv0299_writereg(fe, 0x14, bclk);
488 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
489 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
490 stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
491 stv0299_writereg(fe, 0x0f, 0x80 | m1);
492
493 return 0;
494}
495
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300496static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe,
497 struct dvb_frontend_parameters *params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 u32 div;
500 u8 buf[4];
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300501 struct budget *budget = (struct budget *) fe->dvb->priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
503
504 if ((params->frequency < 950000) || (params->frequency > 2150000))
505 return -EINVAL;
506
507 div = (params->frequency + (125 - 1)) / 125; // round correctly
508 buf[0] = (div >> 8) & 0x7f;
509 buf[1] = div & 0xff;
510 buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
511 buf[3] = 0x20;
512
513 if (params->u.qpsk.symbol_rate < 4000000)
514 buf[3] |= 1;
515
516 if (params->frequency < 1250000)
517 buf[3] |= 0;
518 else if (params->frequency < 1550000)
519 buf[3] |= 0x40;
520 else if (params->frequency < 2050000)
521 buf[3] |= 0x80;
522 else if (params->frequency < 2150000)
523 buf[3] |= 0xC0;
524
Patrick Boettcherdea74862006-05-14 05:01:31 -0300525 if (fe->ops.i2c_gate_ctrl)
526 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300527 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 return -EIO;
529 return 0;
530}
531
532static u8 typhoon_cinergy1200s_inittab[] = {
533 0x01, 0x15,
534 0x02, 0x30,
535 0x03, 0x00,
536 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
537 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
538 0x06, 0x40, /* DAC not used, set to high impendance mode */
539 0x07, 0x00, /* DAC LSB */
540 0x08, 0x40, /* DiSEqC off */
541 0x09, 0x00, /* FIFO */
542 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
543 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
544 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
545 0x10, 0x3f, // AGC2 0x3d
546 0x11, 0x84,
Oliver Endrissff29d062005-11-08 21:35:43 -0800547 0x12, 0xb9,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 0x15, 0xc9, // lock detector threshold
549 0x16, 0x00,
550 0x17, 0x00,
551 0x18, 0x00,
552 0x19, 0x00,
553 0x1a, 0x00,
554 0x1f, 0x50,
555 0x20, 0x00,
556 0x21, 0x00,
557 0x22, 0x00,
558 0x23, 0x00,
559 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
560 0x29, 0x1e, // 1/2 threshold
561 0x2a, 0x14, // 2/3 threshold
562 0x2b, 0x0f, // 3/4 threshold
563 0x2c, 0x09, // 5/6 threshold
564 0x2d, 0x05, // 7/8 threshold
565 0x2e, 0x01,
566 0x31, 0x1f, // test all FECs
567 0x32, 0x19, // viterbi and synchro search
568 0x33, 0xfc, // rs control
569 0x34, 0x93, // error control
570 0x0f, 0x92,
571 0xff, 0xff
572};
573
574static struct stv0299_config typhoon_config = {
575 .demod_address = 0x68,
576 .inittab = typhoon_cinergy1200s_inittab,
577 .mclk = 88000000UL,
578 .invert = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 .skip_reinit = 0,
Oliver Endrissda2c7f62008-04-20 22:13:37 -0300580 .lock_output = STV0299_LOCKOUTPUT_1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 .volt13_op0_op1 = STV0299_VOLT13_OP0,
582 .min_delay_ms = 100,
583 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584};
585
586
587static struct stv0299_config cinergy_1200s_config = {
588 .demod_address = 0x68,
589 .inittab = typhoon_cinergy1200s_inittab,
590 .mclk = 88000000UL,
591 .invert = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 .skip_reinit = 0,
Oliver Endrissda2c7f62008-04-20 22:13:37 -0300593 .lock_output = STV0299_LOCKOUTPUT_0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .volt13_op0_op1 = STV0299_VOLT13_OP0,
595 .min_delay_ms = 100,
596 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597};
598
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200599static struct stv0299_config cinergy_1200s_1894_0010_config = {
600 .demod_address = 0x68,
601 .inittab = typhoon_cinergy1200s_inittab,
602 .mclk = 88000000UL,
603 .invert = 1,
604 .skip_reinit = 0,
Oliver Endrissda2c7f62008-04-20 22:13:37 -0300605 .lock_output = STV0299_LOCKOUTPUT_1,
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200606 .volt13_op0_op1 = STV0299_VOLT13_OP0,
607 .min_delay_ms = 100,
608 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200609};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300611static int philips_cu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612{
613 struct budget *budget = (struct budget *) fe->dvb->priv;
Hartmut Birraa323ac2007-04-21 19:37:17 -0300614 u8 buf[6];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
Hartmut Birraa323ac2007-04-21 19:37:17 -0300616 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617
Hartmut Birraa323ac2007-04-21 19:37:17 -0300618#define CU1216_IF 36125000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619#define TUNER_MUL 62500
620
Hartmut Birraa323ac2007-04-21 19:37:17 -0300621 u32 div = (params->frequency + CU1216_IF + TUNER_MUL / 2) / TUNER_MUL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622
623 buf[0] = (div >> 8) & 0x7f;
624 buf[1] = div & 0xff;
Hartmut Birraa323ac2007-04-21 19:37:17 -0300625 buf[2] = 0xce;
Johannes Stezenbacheef57642005-07-07 17:57:58 -0700626 buf[3] = (params->frequency < 150000000 ? 0x01 :
627 params->frequency < 445000000 ? 0x02 : 0x04);
Hartmut Birraa323ac2007-04-21 19:37:17 -0300628 buf[4] = 0xde;
629 buf[5] = 0x20;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
Patrick Boettcherdea74862006-05-14 05:01:31 -0300631 if (fe->ops.i2c_gate_ctrl)
632 fe->ops.i2c_gate_ctrl(fe, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
634 return -EIO;
Hartmut Birraa323ac2007-04-21 19:37:17 -0300635
636 /* wait for the pll lock */
637 msg.flags = I2C_M_RD;
638 msg.len = 1;
639 for (i = 0; i < 20; i++) {
640 if (fe->ops.i2c_gate_ctrl)
641 fe->ops.i2c_gate_ctrl(fe, 1);
642 if (i2c_transfer(&budget->i2c_adap, &msg, 1) == 1 && (buf[0] & 0x40))
643 break;
644 msleep(10);
645 }
646
647 /* switch the charge pump to the lower current */
648 msg.flags = 0;
649 msg.len = 2;
650 msg.buf = &buf[2];
651 buf[2] &= ~0x40;
652 if (fe->ops.i2c_gate_ctrl)
653 fe->ops.i2c_gate_ctrl(fe, 1);
654 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
655 return -EIO;
656
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 return 0;
658}
659
Hartmut Birraa323ac2007-04-21 19:37:17 -0300660static struct tda1002x_config philips_cu1216_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .demod_address = 0x0c,
Hartmut Birrdc120b072007-04-21 19:44:10 -0300662 .invert = 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663};
664
Hartmut Birraa323ac2007-04-21 19:37:17 -0300665static struct tda1002x_config philips_cu1216_config_altaddress = {
Andrew de Quincey61cebe92006-11-19 14:10:59 -0300666 .demod_address = 0x0d,
Hartmut Birrdc120b072007-04-21 19:44:10 -0300667 .invert = 0,
Andrew de Quincey61cebe92006-11-19 14:10:59 -0300668};
669
Antti Palosaari4388c3b2008-05-17 22:58:04 -0300670static struct tda10023_config philips_cu1216_tda10023_config = {
671 .demod_address = 0x0c,
672 .invert = 1,
673};
674
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300675static int philips_tu1216_tuner_init(struct dvb_frontend *fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676{
677 struct budget *budget = (struct budget *) fe->dvb->priv;
678 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
679 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
680
681 // setup PLL configuration
Patrick Boettcherdea74862006-05-14 05:01:31 -0300682 if (fe->ops.i2c_gate_ctrl)
683 fe->ops.i2c_gate_ctrl(fe, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
685 return -EIO;
686 msleep(1);
687
688 return 0;
689}
690
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300691static int philips_tu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692{
693 struct budget *budget = (struct budget *) fe->dvb->priv;
694 u8 tuner_buf[4];
695 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,.len =
696 sizeof(tuner_buf) };
697 int tuner_frequency = 0;
698 u8 band, cp, filter;
699
700 // determine charge pump
701 tuner_frequency = params->frequency + 36166000;
702 if (tuner_frequency < 87000000)
703 return -EINVAL;
704 else if (tuner_frequency < 130000000)
705 cp = 3;
706 else if (tuner_frequency < 160000000)
707 cp = 5;
708 else if (tuner_frequency < 200000000)
709 cp = 6;
710 else if (tuner_frequency < 290000000)
711 cp = 3;
712 else if (tuner_frequency < 420000000)
713 cp = 5;
714 else if (tuner_frequency < 480000000)
715 cp = 6;
716 else if (tuner_frequency < 620000000)
717 cp = 3;
718 else if (tuner_frequency < 830000000)
719 cp = 5;
720 else if (tuner_frequency < 895000000)
721 cp = 7;
722 else
723 return -EINVAL;
724
725 // determine band
726 if (params->frequency < 49000000)
727 return -EINVAL;
728 else if (params->frequency < 161000000)
729 band = 1;
730 else if (params->frequency < 444000000)
731 band = 2;
732 else if (params->frequency < 861000000)
733 band = 4;
734 else
735 return -EINVAL;
736
737 // setup PLL filter
738 switch (params->u.ofdm.bandwidth) {
739 case BANDWIDTH_6_MHZ:
740 filter = 0;
741 break;
742
743 case BANDWIDTH_7_MHZ:
744 filter = 0;
745 break;
746
747 case BANDWIDTH_8_MHZ:
748 filter = 1;
749 break;
750
751 default:
752 return -EINVAL;
753 }
754
755 // calculate divisor
756 // ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
757 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
758
759 // setup tuner buffer
760 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
761 tuner_buf[1] = tuner_frequency & 0xff;
762 tuner_buf[2] = 0xca;
763 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
764
Patrick Boettcherdea74862006-05-14 05:01:31 -0300765 if (fe->ops.i2c_gate_ctrl)
766 fe->ops.i2c_gate_ctrl(fe, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
768 return -EIO;
769
770 msleep(1);
771 return 0;
772}
773
774static int philips_tu1216_request_firmware(struct dvb_frontend *fe,
775 const struct firmware **fw, char *name)
776{
777 struct budget *budget = (struct budget *) fe->dvb->priv;
778
779 return request_firmware(fw, name, &budget->dev->pci->dev);
780}
781
782static struct tda1004x_config philips_tu1216_config = {
783
784 .demod_address = 0x8,
785 .invert = 1,
786 .invert_oclk = 1,
Hartmut Hackmannecb60de2005-07-07 17:57:40 -0700787 .xtal_freq = TDA10046_XTAL_4M,
788 .agc_config = TDA10046_AGC_DEFAULT,
789 .if_freq = TDA10046_FREQ_3617,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 .request_firmware = philips_tu1216_request_firmware,
791};
792
Regis Prevotf8bf1342006-01-11 23:31:53 -0200793static u8 philips_sd1878_inittab[] = {
794 0x01, 0x15,
795 0x02, 0x30,
796 0x03, 0x00,
797 0x04, 0x7d,
798 0x05, 0x35,
799 0x06, 0x40,
800 0x07, 0x00,
801 0x08, 0x43,
802 0x09, 0x02,
803 0x0C, 0x51,
804 0x0D, 0x82,
805 0x0E, 0x23,
806 0x10, 0x3f,
807 0x11, 0x84,
808 0x12, 0xb9,
809 0x15, 0xc9,
810 0x16, 0x19,
811 0x17, 0x8c,
812 0x18, 0x59,
813 0x19, 0xf8,
814 0x1a, 0xfe,
815 0x1c, 0x7f,
816 0x1d, 0x00,
817 0x1e, 0x00,
818 0x1f, 0x50,
819 0x20, 0x00,
820 0x21, 0x00,
821 0x22, 0x00,
822 0x23, 0x00,
823 0x28, 0x00,
824 0x29, 0x28,
825 0x2a, 0x14,
826 0x2b, 0x0f,
827 0x2c, 0x09,
828 0x2d, 0x09,
829 0x31, 0x1f,
830 0x32, 0x19,
831 0x33, 0xfc,
832 0x34, 0x93,
833 0xff, 0xff
834};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835
Regis Prevotf8bf1342006-01-11 23:31:53 -0200836static int philips_sd1878_ci_set_symbol_rate(struct dvb_frontend *fe,
837 u32 srate, u32 ratio)
838{
839 u8 aclk = 0;
840 u8 bclk = 0;
841 u8 m1;
842
843 aclk = 0xb5;
844 if (srate < 2000000)
845 bclk = 0x86;
846 else if (srate < 5000000)
847 bclk = 0x89;
848 else if (srate < 15000000)
849 bclk = 0x8f;
850 else if (srate < 45000000)
851 bclk = 0x95;
852
853 m1 = 0x14;
854 if (srate < 4000000)
855 m1 = 0x10;
856
857 stv0299_writereg(fe, 0x0e, 0x23);
858 stv0299_writereg(fe, 0x0f, 0x94);
859 stv0299_writereg(fe, 0x10, 0x39);
860 stv0299_writereg(fe, 0x13, aclk);
861 stv0299_writereg(fe, 0x14, bclk);
862 stv0299_writereg(fe, 0x15, 0xc9);
863 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
864 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
865 stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
866 stv0299_writereg(fe, 0x0f, 0x80 | m1);
867
868 return 0;
869}
870
871static struct stv0299_config philips_sd1878_config = {
872 .demod_address = 0x68,
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300873 .inittab = philips_sd1878_inittab,
Regis Prevotf8bf1342006-01-11 23:31:53 -0200874 .mclk = 88000000UL,
875 .invert = 0,
876 .skip_reinit = 0,
Oliver Endrissda2c7f62008-04-20 22:13:37 -0300877 .lock_output = STV0299_LOCKOUTPUT_1,
Regis Prevotf8bf1342006-01-11 23:31:53 -0200878 .volt13_op0_op1 = STV0299_VOLT13_OP0,
879 .min_delay_ms = 100,
880 .set_symbol_rate = philips_sd1878_ci_set_symbol_rate,
Regis Prevotf8bf1342006-01-11 23:31:53 -0200881};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882
883static u8 read_pwm(struct budget_av *budget_av)
884{
885 u8 b = 0xff;
886 u8 pwm;
887 struct i2c_msg msg[] = { {.addr = 0x50,.flags = 0,.buf = &b,.len = 1},
888 {.addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1}
889 };
890
891 if ((i2c_transfer(&budget_av->budget.i2c_adap, msg, 2) != 2)
892 || (pwm == 0xff))
893 pwm = 0x48;
894
895 return pwm;
896}
897
Hartmut Birraa323ac2007-04-21 19:37:17 -0300898#define SUBID_DVBS_KNC1 0x0010
899#define SUBID_DVBS_KNC1_PLUS 0x0011
900#define SUBID_DVBS_TYPHOON 0x4f56
901#define SUBID_DVBS_CINERGY1200 0x1154
902#define SUBID_DVBS_CYNERGY1200N 0x1155
903#define SUBID_DVBS_TV_STAR 0x0014
Oliver Endriss03aa73c2008-01-29 23:56:51 -0300904#define SUBID_DVBS_TV_STAR_PLUS_X4 0x0015
Hartmut Birraa323ac2007-04-21 19:37:17 -0300905#define SUBID_DVBS_TV_STAR_CI 0x0016
906#define SUBID_DVBS_EASYWATCH_1 0x001a
Oliver Endrissf72ce642007-05-13 23:25:57 -0300907#define SUBID_DVBS_EASYWATCH_2 0x001b
Hartmut Birraa323ac2007-04-21 19:37:17 -0300908#define SUBID_DVBS_EASYWATCH 0x001e
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700909
Hartmut Birraa323ac2007-04-21 19:37:17 -0300910#define SUBID_DVBC_EASYWATCH 0x002a
911#define SUBID_DVBC_EASYWATCH_MK3 0x002c
912#define SUBID_DVBC_KNC1 0x0020
913#define SUBID_DVBC_KNC1_PLUS 0x0021
914#define SUBID_DVBC_KNC1_MK3 0x0022
915#define SUBID_DVBC_KNC1_PLUS_MK3 0x0023
916#define SUBID_DVBC_CINERGY1200 0x1156
917#define SUBID_DVBC_CINERGY1200_MK3 0x1176
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700918
Kim Sandberg251130b2008-01-30 00:42:01 -0300919#define SUBID_DVBT_EASYWATCH 0x003a
Hartmut Birraa323ac2007-04-21 19:37:17 -0300920#define SUBID_DVBT_KNC1_PLUS 0x0031
921#define SUBID_DVBT_KNC1 0x0030
922#define SUBID_DVBT_CINERGY1200 0x1157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923
924static void frontend_init(struct budget_av *budget_av)
925{
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700926 struct saa7146_dev * saa = budget_av->budget.dev;
927 struct dvb_frontend * fe = NULL;
928
Andrew de Quincey473f5422006-04-13 17:29:07 -0300929 /* Enable / PowerON Frontend */
930 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
931
Hartmut Birr740cf9e2006-11-03 15:34:18 -0300932 /* Wait for PowerON */
933 msleep(100);
934
Andrew de Quincey473f5422006-04-13 17:29:07 -0300935 /* additional setup necessary for the PLUS cards */
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700936 switch (saa->pci->subsystem_device) {
937 case SUBID_DVBS_KNC1_PLUS:
938 case SUBID_DVBC_KNC1_PLUS:
939 case SUBID_DVBT_KNC1_PLUS:
Thomas Hammc01d1e42006-11-17 07:12:58 -0300940 case SUBID_DVBC_EASYWATCH:
Hartmut Birraa323ac2007-04-21 19:37:17 -0300941 case SUBID_DVBC_KNC1_PLUS_MK3:
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700942 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 break;
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700944 }
945
946 switch (saa->pci->subsystem_device) {
947
948 case SUBID_DVBS_KNC1:
Christoph Pfisterc4e3bcb2008-04-09 17:37:36 -0300949 /*
950 * maybe that setting is needed for other dvb-s cards as well,
951 * but so far it has been only confirmed for this type
952 */
953 budget_av->reinitialise_demod = 1;
954 /* fall through */
Christoph Pfister4e318be2006-08-12 09:13:35 -0300955 case SUBID_DVBS_KNC1_PLUS:
Lothar Englisch60110ce2006-06-06 16:13:46 -0300956 case SUBID_DVBS_EASYWATCH_1:
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200957 if (saa->pci->subsystem_vendor == 0x1894) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300958 fe = dvb_attach(stv0299_attach, &cinergy_1200s_1894_0010_config,
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200959 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300960 if (fe) {
Andrew de Quincey1c72cfdc2006-09-05 17:58:20 -0300961 dvb_attach(tua6100_attach, fe, 0x60, &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300962 }
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200963 } else {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300964 fe = dvb_attach(stv0299_attach, &typhoon_config,
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200965 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300966 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300967 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300968 }
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200969 }
970 break;
971
Regis Prevotf8bf1342006-01-11 23:31:53 -0200972 case SUBID_DVBS_TV_STAR:
Oliver Endriss03aa73c2008-01-29 23:56:51 -0300973 case SUBID_DVBS_TV_STAR_PLUS_X4:
Regis Prevotf8bf1342006-01-11 23:31:53 -0200974 case SUBID_DVBS_TV_STAR_CI:
975 case SUBID_DVBS_CYNERGY1200N:
Thilo Berger36f4f332006-02-27 00:09:08 -0300976 case SUBID_DVBS_EASYWATCH:
Oliver Endrissf72ce642007-05-13 23:25:57 -0300977 case SUBID_DVBS_EASYWATCH_2:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300978 fe = dvb_attach(stv0299_attach, &philips_sd1878_config,
Regis Prevotf8bf1342006-01-11 23:31:53 -0200979 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300980 if (fe) {
Michael Krufky9b98fd22007-05-07 01:48:56 -0300981 dvb_attach(dvb_pll_attach, fe, 0x60,
982 &budget_av->budget.i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300983 DVB_PLL_PHILIPS_SD1878_TDA8261);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300984 }
Regis Prevotf8bf1342006-01-11 23:31:53 -0200985 break;
986
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700987 case SUBID_DVBS_TYPHOON:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300988 fe = dvb_attach(stv0299_attach, &typhoon_config,
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700989 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300990 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300991 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300992 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 break;
994
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700995 case SUBID_DVBS_CINERGY1200:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300996 fe = dvb_attach(stv0299_attach, &cinergy_1200s_config,
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700997 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300998 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300999 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
Andrew de Quinceye87d41c2006-04-18 17:47:11 -03001000 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 break;
1002
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001003 case SUBID_DVBC_KNC1:
1004 case SUBID_DVBC_KNC1_PLUS:
Andrew de Quincey5c1208b2006-05-22 10:32:02 -03001005 case SUBID_DVBC_CINERGY1200:
Thomas Hammc01d1e42006-11-17 07:12:58 -03001006 case SUBID_DVBC_EASYWATCH:
Andrew de Quincey5c1208b2006-05-22 10:32:02 -03001007 budget_av->reinitialise_demod = 1;
Hartmut Birraa323ac2007-04-21 19:37:17 -03001008 budget_av->budget.dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001009 fe = dvb_attach(tda10021_attach, &philips_cu1216_config,
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001010 &budget_av->budget.i2c_adap,
1011 read_pwm(budget_av));
Andrew de Quincey61cebe92006-11-19 14:10:59 -03001012 if (fe == NULL)
1013 fe = dvb_attach(tda10021_attach, &philips_cu1216_config_altaddress,
1014 &budget_av->budget.i2c_adap,
1015 read_pwm(budget_av));
Andrew de Quinceye87d41c2006-04-18 17:47:11 -03001016 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001017 fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
Andrew de Quinceye87d41c2006-04-18 17:47:11 -03001018 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019 break;
1020
Hartmut Birraa323ac2007-04-21 19:37:17 -03001021 case SUBID_DVBC_EASYWATCH_MK3:
1022 case SUBID_DVBC_CINERGY1200_MK3:
1023 case SUBID_DVBC_KNC1_MK3:
1024 case SUBID_DVBC_KNC1_PLUS_MK3:
1025 budget_av->reinitialise_demod = 1;
1026 budget_av->budget.dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
Antti Palosaari4388c3b2008-05-17 22:58:04 -03001027 fe = dvb_attach(tda10023_attach,
1028 &philips_cu1216_tda10023_config,
1029 &budget_av->budget.i2c_adap,
1030 read_pwm(budget_av));
Hartmut Birraa323ac2007-04-21 19:37:17 -03001031 if (fe) {
1032 fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
1033 }
1034 break;
1035
Kim Sandberg251130b2008-01-30 00:42:01 -03001036 case SUBID_DVBT_EASYWATCH:
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001037 case SUBID_DVBT_KNC1:
1038 case SUBID_DVBT_KNC1_PLUS:
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001039 case SUBID_DVBT_CINERGY1200:
Andrew de Quincey5c1208b2006-05-22 10:32:02 -03001040 budget_av->reinitialise_demod = 1;
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001041 fe = dvb_attach(tda10046_attach, &philips_tu1216_config,
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001042 &budget_av->budget.i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001043 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001044 fe->ops.tuner_ops.init = philips_tu1216_tuner_init;
1045 fe->ops.tuner_ops.set_params = philips_tu1216_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001046 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 break;
1048 }
1049
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001050 if (fe == NULL) {
1051 printk(KERN_ERR "budget-av: A frontend driver was not found "
1052 "for device %04x/%04x subsystem %04x/%04x\n",
1053 saa->pci->vendor,
1054 saa->pci->device,
1055 saa->pci->subsystem_vendor,
1056 saa->pci->subsystem_device);
1057 return;
1058 }
1059
1060 budget_av->budget.dvb_frontend = fe;
1061
1062 if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
1063 budget_av->budget.dvb_frontend)) {
1064 printk(KERN_ERR "budget-av: Frontend registration failed!\n");
Andrew de Quinceyf52a8382006-08-08 09:10:09 -03001065 dvb_frontend_detach(budget_av->budget.dvb_frontend);
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001066 budget_av->budget.dvb_frontend = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067 }
1068}
1069
1070
1071static void budget_av_irq(struct saa7146_dev *dev, u32 * isr)
1072{
1073 struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
1074
1075 dprintk(8, "dev: %p, budget_av: %p\n", dev, budget_av);
1076
1077 if (*isr & MASK_10)
1078 ttpci_budget_irq10_handler(dev, isr);
1079}
1080
1081static int budget_av_detach(struct saa7146_dev *dev)
1082{
1083 struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
1084 int err;
1085
1086 dprintk(2, "dev: %p\n", dev);
1087
1088 if (1 == budget_av->has_saa7113) {
1089 saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
1090
1091 msleep(200);
1092
1093 saa7146_unregister_device(&budget_av->vd, dev);
Marco Schluessler716a4e32007-02-03 14:47:14 -03001094
1095 saa7146_vv_release(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 }
1097
1098 if (budget_av->budget.ci_present)
1099 ciintf_deinit(budget_av);
1100
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001101 if (budget_av->budget.dvb_frontend != NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 dvb_unregister_frontend(budget_av->budget.dvb_frontend);
Andrew de Quinceyf52a8382006-08-08 09:10:09 -03001103 dvb_frontend_detach(budget_av->budget.dvb_frontend);
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001104 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 err = ttpci_budget_deinit(&budget_av->budget);
1106
1107 kfree(budget_av);
1108
1109 return err;
1110}
1111
1112static struct saa7146_ext_vv vv_data;
1113
1114static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
1115{
1116 struct budget_av *budget_av;
1117 u8 *mac;
1118 int err;
1119
1120 dprintk(2, "dev: %p\n", dev);
1121
Panagiotis Issaris74081872006-01-11 19:40:56 -02001122 if (!(budget_av = kzalloc(sizeof(struct budget_av), GFP_KERNEL)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123 return -ENOMEM;
1124
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001125 budget_av->has_saa7113 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 budget_av->budget.ci_present = 0;
1127
1128 dev->ext_priv = budget_av;
1129
1130 if ((err = ttpci_budget_init(&budget_av->budget, dev, info, THIS_MODULE))) {
1131 kfree(budget_av);
1132 return err;
1133 }
1134
1135 /* knc1 initialization */
1136 saa7146_write(dev, DD1_STREAM_B, 0x04000000);
1137 saa7146_write(dev, DD1_INIT, 0x07000600);
1138 saa7146_write(dev, MC2, MASK_09 | MASK_25 | MASK_10 | MASK_26);
1139
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001140 if (saa7113_init(budget_av) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141 budget_av->has_saa7113 = 1;
1142
1143 if (0 != saa7146_vv_init(dev, &vv_data)) {
1144 /* fixme: proper cleanup here */
1145 ERR(("cannot init vv subsystem.\n"));
1146 return err;
1147 }
1148
1149 if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) {
1150 /* fixme: proper cleanup here */
1151 ERR(("cannot register capture v4l2 device.\n"));
Marco Schluessler716a4e32007-02-03 14:47:14 -03001152 saa7146_vv_release(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 return err;
1154 }
1155
1156 /* beware: this modifies dev->vv ... */
1157 saa7146_set_hps_source_and_sync(dev, SAA7146_HPS_SOURCE_PORT_A,
1158 SAA7146_HPS_SYNC_PORT_A);
1159
1160 saa7113_setinput(budget_av, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 }
1162
1163 /* fixme: find some sane values here... */
1164 saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
1165
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -07001166 mac = budget_av->budget.dvb_adapter.proposed_mac;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) {
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001168 printk(KERN_ERR "KNC1-%d: Could not read MAC from KNC1 card\n",
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -07001169 budget_av->budget.dvb_adapter.num);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 memset(mac, 0, 6);
1171 } else {
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001172 printk(KERN_INFO "KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -07001173 budget_av->budget.dvb_adapter.num,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
1175 }
1176
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -07001177 budget_av->budget.dvb_adapter.priv = budget_av;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 frontend_init(budget_av);
Andrew de Quinceyc5e768a2006-06-29 13:16:11 -03001179 ciintf_init(budget_av);
Oliver Endriss32e4c3a2006-07-18 22:55:23 -03001180
1181 ttpci_budget_init_hooks(&budget_av->budget);
1182
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 return 0;
1184}
1185
1186#define KNC1_INPUTS 2
1187static struct v4l2_input knc1_inputs[KNC1_INPUTS] = {
1188 {0, "Composite", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0},
1189 {1, "S-Video", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0},
1190};
1191
1192static struct saa7146_extension_ioctls ioctls[] = {
1193 {VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE},
1194 {VIDIOC_G_INPUT, SAA7146_EXCLUSIVE},
1195 {VIDIOC_S_INPUT, SAA7146_EXCLUSIVE},
1196 {0, 0}
1197};
1198
1199static int av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
1200{
1201 struct saa7146_dev *dev = fh->dev;
1202 struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
1203
1204 switch (cmd) {
1205 case VIDIOC_ENUMINPUT:{
1206 struct v4l2_input *i = arg;
1207
1208 dprintk(1, "VIDIOC_ENUMINPUT %d.\n", i->index);
1209 if (i->index < 0 || i->index >= KNC1_INPUTS) {
1210 return -EINVAL;
1211 }
1212 memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input));
1213 return 0;
1214 }
1215 case VIDIOC_G_INPUT:{
1216 int *input = (int *) arg;
1217
1218 *input = budget_av->cur_input;
1219
1220 dprintk(1, "VIDIOC_G_INPUT %d.\n", *input);
1221 return 0;
1222 }
1223 case VIDIOC_S_INPUT:{
1224 int input = *(int *) arg;
1225 dprintk(1, "VIDIOC_S_INPUT %d.\n", input);
1226 return saa7113_setinput(budget_av, input);
1227 }
1228 default:
1229 return -ENOIOCTLCMD;
1230 }
1231 return 0;
1232}
1233
1234static struct saa7146_standard standard[] = {
1235 {.name = "PAL",.id = V4L2_STD_PAL,
1236 .v_offset = 0x17,.v_field = 288,
1237 .h_offset = 0x14,.h_pixels = 680,
1238 .v_max_out = 576,.h_max_out = 768 },
1239
1240 {.name = "NTSC",.id = V4L2_STD_NTSC,
1241 .v_offset = 0x16,.v_field = 240,
1242 .h_offset = 0x06,.h_pixels = 708,
1243 .v_max_out = 480,.h_max_out = 640, },
1244};
1245
1246static struct saa7146_ext_vv vv_data = {
1247 .inputs = 2,
1248 .capabilities = 0, // perhaps later: V4L2_CAP_VBI_CAPTURE, but that need tweaking with the saa7113
1249 .flags = 0,
1250 .stds = &standard[0],
Andi Drebesaf520a32007-07-30 11:48:10 -03001251 .num_stds = ARRAY_SIZE(standard),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252 .ioctls = &ioctls[0],
1253 .ioctl = av_ioctl,
1254};
1255
1256static struct saa7146_extension budget_extension;
1257
1258MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S);
1259MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
1260MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
Regis Prevotf8bf1342006-01-11 23:31:53 -02001261MAKE_BUDGET_INFO(kncxs, "KNC TV STAR DVB-S", BUDGET_TVSTAR);
Thilo Berger36f4f332006-02-27 00:09:08 -03001262MAKE_BUDGET_INFO(satewpls, "Satelco EasyWatch DVB-S light", BUDGET_TVSTAR);
Lothar Englisch60110ce2006-06-06 16:13:46 -03001263MAKE_BUDGET_INFO(satewpls1, "Satelco EasyWatch DVB-S light", BUDGET_KNC1S);
Oliver Endrissf72ce642007-05-13 23:25:57 -03001264MAKE_BUDGET_INFO(satewps, "Satelco EasyWatch DVB-S", BUDGET_KNC1S);
Thomas Hammc01d1e42006-11-17 07:12:58 -03001265MAKE_BUDGET_INFO(satewplc, "Satelco EasyWatch DVB-C", BUDGET_KNC1CP);
Hartmut Birraa323ac2007-04-21 19:37:17 -03001266MAKE_BUDGET_INFO(satewcmk3, "Satelco EasyWatch DVB-C MK3", BUDGET_KNC1C_MK3);
Kim Sandberg251130b2008-01-30 00:42:01 -03001267MAKE_BUDGET_INFO(satewt, "Satelco EasyWatch DVB-T", BUDGET_KNC1T);
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001268MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP);
Oliver Endriss03aa73c2008-01-29 23:56:51 -03001269MAKE_BUDGET_INFO(knc1spx4, "KNC1 DVB-S Plus X4", BUDGET_KNC1SP);
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001270MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP);
Hartmut Birraa323ac2007-04-21 19:37:17 -03001271MAKE_BUDGET_INFO(knc1cmk3, "KNC1 DVB-C MK3", BUDGET_KNC1C_MK3);
1272MAKE_BUDGET_INFO(knc1cpmk3, "KNC1 DVB-C Plus MK3", BUDGET_KNC1CP_MK3);
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001273MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
Regis Prevotf8bf1342006-01-11 23:31:53 -02001275MAKE_BUDGET_INFO(cin1200sn, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
Hartmut Birraa323ac2007-04-21 19:37:17 -03001277MAKE_BUDGET_INFO(cin1200cmk3, "Terratec Cinergy 1200 DVB-C MK3", BUDGET_CIN1200C_MK3);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
1279
1280static struct pci_device_id pci_tbl[] = {
1281 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001282 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
Andrew de Quinceyeffa7912006-01-09 15:25:09 -02001283 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001284 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
Christoph Pfister4e318be2006-08-12 09:13:35 -03001285 MAKE_EXTENSION_PCI(knc1sp, 0x1894, 0x0011),
Regis Prevotf8bf1342006-01-11 23:31:53 -02001286 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
Oliver Endriss03aa73c2008-01-29 23:56:51 -03001287 MAKE_EXTENSION_PCI(knc1spx4, 0x1894, 0x0015),
Regis Prevotf8bf1342006-01-11 23:31:53 -02001288 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
Thilo Berger36f4f332006-02-27 00:09:08 -03001289 MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e),
Lothar Englisch60110ce2006-06-06 16:13:46 -03001290 MAKE_EXTENSION_PCI(satewpls1, 0x1894, 0x001a),
Oliver Endrissf72ce642007-05-13 23:25:57 -03001291 MAKE_EXTENSION_PCI(satewps, 0x1894, 0x001b),
Thomas Hammc01d1e42006-11-17 07:12:58 -03001292 MAKE_EXTENSION_PCI(satewplc, 0x1894, 0x002a),
Hartmut Birraa323ac2007-04-21 19:37:17 -03001293 MAKE_EXTENSION_PCI(satewcmk3, 0x1894, 0x002c),
Kim Sandberg251130b2008-01-30 00:42:01 -03001294 MAKE_EXTENSION_PCI(satewt, 0x1894, 0x003a),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001296 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
Hartmut Birraa323ac2007-04-21 19:37:17 -03001297 MAKE_EXTENSION_PCI(knc1cmk3, 0x1894, 0x0022),
1298 MAKE_EXTENSION_PCI(knc1cpmk3, 0x1894, 0x0023),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001300 MAKE_EXTENSION_PCI(knc1tp, 0x1894, 0x0031),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301 MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154),
Regis Prevotf8bf1342006-01-11 23:31:53 -02001302 MAKE_EXTENSION_PCI(cin1200sn, 0x153b, 0x1155),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156),
Hartmut Birraa323ac2007-04-21 19:37:17 -03001304 MAKE_EXTENSION_PCI(cin1200cmk3, 0x153b, 0x1176),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157),
1306 {
1307 .vendor = 0,
1308 }
1309};
1310
1311MODULE_DEVICE_TABLE(pci, pci_tbl);
1312
1313static struct saa7146_extension budget_extension = {
Julian Scheel27b05fd2005-07-12 13:58:39 -07001314 .name = "budget_av",
Oliver Endriss00c4cc62006-11-01 13:09:51 -03001315 .flags = SAA7146_USE_I2C_IRQ,
Oliver Endriss69459f32005-12-01 00:51:48 -08001316
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 .pci_tbl = pci_tbl,
1318
1319 .module = THIS_MODULE,
1320 .attach = budget_av_attach,
1321 .detach = budget_av_detach,
1322
1323 .irq_mask = MASK_10,
1324 .irq_func = budget_av_irq,
1325};
1326
1327static int __init budget_av_init(void)
1328{
1329 return saa7146_register_extension(&budget_extension);
1330}
1331
1332static void __exit budget_av_exit(void)
1333{
1334 saa7146_unregister_extension(&budget_extension);
1335}
1336
1337module_init(budget_av_init);
1338module_exit(budget_av_exit);
1339
1340MODULE_LICENSE("GPL");
1341MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
1342MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
1343 "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");