blob: 1032ea77837e356766cb27aaa2bb3f3295688b84 [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 Quincey1c72cfdce2006-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
Janne Grunau26dc4d02008-09-21 20:50:11 -030060DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062struct budget_av {
63 struct budget budget;
64 struct video_device *vd;
65 int cur_input;
66 int has_saa7113;
67 struct tasklet_struct ciintf_irq_tasklet;
68 int slot_status;
69 struct dvb_ca_en50221 ca;
Andrew de Quincey5c1208b2006-05-22 10:32:02 -030070 u8 reinitialise_demod:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071};
72
Andrew de Quincey5c1208b2006-05-22 10:32:02 -030073static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot);
74
75
Andrew de Quincey86f40cc2006-03-30 15:53:35 -030076/* GPIO Connections:
77 * 0 - Vcc/Reset (Reset is controlled by capacitor). Resets the frontend *AS WELL*!
78 * 1 - CI memory select 0=>IO memory, 1=>Attribute Memory
79 * 2 - CI Card Enable (Active Low)
80 * 3 - CI Card Detect
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -070081 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/****************************************************************************
84 * INITIALIZATION
85 ****************************************************************************/
86
87static u8 i2c_readreg(struct i2c_adapter *i2c, u8 id, u8 reg)
88{
89 u8 mm1[] = { 0x00 };
90 u8 mm2[] = { 0x00 };
91 struct i2c_msg msgs[2];
92
93 msgs[0].flags = 0;
94 msgs[1].flags = I2C_M_RD;
95 msgs[0].addr = msgs[1].addr = id / 2;
96 mm1[0] = reg;
97 msgs[0].len = 1;
98 msgs[1].len = 1;
99 msgs[0].buf = mm1;
100 msgs[1].buf = mm2;
101
102 i2c_transfer(i2c, msgs, 2);
103
104 return mm2[0];
105}
106
107static int i2c_readregs(struct i2c_adapter *i2c, u8 id, u8 reg, u8 * buf, u8 len)
108{
109 u8 mm1[] = { reg };
110 struct i2c_msg msgs[2] = {
111 {.addr = id / 2,.flags = 0,.buf = mm1,.len = 1},
112 {.addr = id / 2,.flags = I2C_M_RD,.buf = buf,.len = len}
113 };
114
115 if (i2c_transfer(i2c, msgs, 2) != 2)
116 return -EIO;
117
118 return 0;
119}
120
121static int i2c_writereg(struct i2c_adapter *i2c, u8 id, u8 reg, u8 val)
122{
123 u8 msg[2] = { reg, val };
124 struct i2c_msg msgs;
125
126 msgs.flags = 0;
127 msgs.addr = id / 2;
128 msgs.len = 2;
129 msgs.buf = msg;
130 return i2c_transfer(i2c, &msgs, 1);
131}
132
133static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
134{
135 struct budget_av *budget_av = (struct budget_av *) ca->data;
136 int result;
137
138 if (slot != 0)
139 return -EINVAL;
140
141 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
142 udelay(1);
143
Andrew de Quincey2d0235d2006-01-09 15:25:05 -0200144 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300145 if (result == -ETIMEDOUT) {
146 ciintf_slot_shutdown(ca, slot);
147 printk(KERN_INFO "budget-av: cam ejected 1\n");
148 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 return result;
150}
151
152static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
153{
154 struct budget_av *budget_av = (struct budget_av *) ca->data;
155 int result;
156
157 if (slot != 0)
158 return -EINVAL;
159
160 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
161 udelay(1);
162
Andrew de Quincey2d0235d2006-01-09 15:25:05 -0200163 result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300164 if (result == -ETIMEDOUT) {
165 ciintf_slot_shutdown(ca, slot);
166 printk(KERN_INFO "budget-av: cam ejected 2\n");
167 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 return result;
169}
170
171static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
172{
173 struct budget_av *budget_av = (struct budget_av *) ca->data;
174 int result;
175
176 if (slot != 0)
177 return -EINVAL;
178
179 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
180 udelay(1);
181
182 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
Christoph Pfister87270732008-04-09 17:34:09 -0300183 if (result == -ETIMEDOUT) {
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300184 ciintf_slot_shutdown(ca, slot);
185 printk(KERN_INFO "budget-av: cam ejected 3\n");
186 return -ETIMEDOUT;
187 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 return result;
189}
190
191static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
192{
193 struct budget_av *budget_av = (struct budget_av *) ca->data;
194 int result;
195
196 if (slot != 0)
197 return -EINVAL;
198
199 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
200 udelay(1);
201
202 result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300203 if (result == -ETIMEDOUT) {
204 ciintf_slot_shutdown(ca, slot);
205 printk(KERN_INFO "budget-av: cam ejected 5\n");
206 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 return result;
208}
209
210static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
211{
212 struct budget_av *budget_av = (struct budget_av *) ca->data;
213 struct saa7146_dev *saa = budget_av->budget.dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 if (slot != 0)
216 return -EINVAL;
217
218 dprintk(1, "ciintf_slot_reset\n");
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300219 budget_av->slot_status = SLOTSTATUS_RESET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700221 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700223 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
224 msleep(2);
225 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); /* Vcc on */
226 msleep(20); /* 20 ms Vcc settling time */
227
228 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); /* enable card */
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300229 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
230 msleep(20);
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700231
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300232 /* reinitialise the frontend if necessary */
233 if (budget_av->reinitialise_demod)
234 dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 return 0;
237}
238
239static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
240{
241 struct budget_av *budget_av = (struct budget_av *) ca->data;
242 struct saa7146_dev *saa = budget_av->budget.dev;
243
244 if (slot != 0)
245 return -EINVAL;
246
247 dprintk(1, "ciintf_slot_shutdown\n");
248
249 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300250 budget_av->slot_status = SLOTSTATUS_NONE;
251
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 return 0;
253}
254
255static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
256{
257 struct budget_av *budget_av = (struct budget_av *) ca->data;
258 struct saa7146_dev *saa = budget_av->budget.dev;
259
260 if (slot != 0)
261 return -EINVAL;
262
263 dprintk(1, "ciintf_slot_ts_enable: %d\n", budget_av->slot_status);
264
265 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300266
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 return 0;
268}
269
270static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
271{
272 struct budget_av *budget_av = (struct budget_av *) ca->data;
273 struct saa7146_dev *saa = budget_av->budget.dev;
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300274 int result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
276 if (slot != 0)
277 return -EINVAL;
278
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300279 /* test the card detect line - needs to be done carefully
280 * since it never goes high for some CAMs on this interface (e.g. topuptv) */
281 if (budget_av->slot_status == SLOTSTATUS_NONE) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
283 udelay(1);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300284 if (saa7146_read(saa, PSR) & MASK_06) {
285 if (budget_av->slot_status == SLOTSTATUS_NONE) {
286 budget_av->slot_status = SLOTSTATUS_PRESENT;
287 printk(KERN_INFO "budget-av: cam inserted A\n");
Andrew de Quincey2d0235d2006-01-09 15:25:05 -0200288 }
289 }
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300290 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
291 }
Andrew de Quincey2d0235d2006-01-09 15:25:05 -0200292
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300293 /* We also try and read from IO memory to work round the above detection bug. If
294 * there is no CAM, we will get a timeout. Only done if there is no cam
295 * present, since this test actually breaks some cams :(
296 *
297 * if the CI interface is not open, we also do the above test since we
298 * don't care if the cam has problems - we'll be resetting it on open() anyway */
299 if ((budget_av->slot_status == SLOTSTATUS_NONE) || (!open)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300301 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1);
302 if ((result >= 0) && (budget_av->slot_status == SLOTSTATUS_NONE)) {
303 budget_av->slot_status = SLOTSTATUS_PRESENT;
304 printk(KERN_INFO "budget-av: cam inserted B\n");
305 } else if (result < 0) {
306 if (budget_av->slot_status != SLOTSTATUS_NONE) {
307 ciintf_slot_shutdown(ca, slot);
308 printk(KERN_INFO "budget-av: cam ejected 5\n");
309 return 0;
310 }
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700311 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 }
313
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300314 /* read from attribute memory in reset/ready state to know when the CAM is ready */
315 if (budget_av->slot_status == SLOTSTATUS_RESET) {
316 result = ciintf_read_attribute_mem(ca, slot, 0);
317 if (result == 0x1d) {
318 budget_av->slot_status = SLOTSTATUS_READY;
319 }
320 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300322 /* work out correct return code */
323 if (budget_av->slot_status != SLOTSTATUS_NONE) {
324 if (budget_av->slot_status & SLOTSTATUS_READY) {
325 return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
326 }
327 return DVB_CA_EN50221_POLL_CAM_PRESENT;
328 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 return 0;
330}
331
332static int ciintf_init(struct budget_av *budget_av)
333{
334 struct saa7146_dev *saa = budget_av->budget.dev;
335 int result;
336
337 memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221));
338
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700339 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
340 saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO);
342 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
343
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 /* Enable DEBI pins */
Hartmut Birr2a893de2006-12-03 21:08:08 -0300345 saa7146_write(saa, MC1, MASK_27 | MASK_11);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
347 /* register CI interface */
348 budget_av->ca.owner = THIS_MODULE;
349 budget_av->ca.read_attribute_mem = ciintf_read_attribute_mem;
350 budget_av->ca.write_attribute_mem = ciintf_write_attribute_mem;
351 budget_av->ca.read_cam_control = ciintf_read_cam_control;
352 budget_av->ca.write_cam_control = ciintf_write_cam_control;
353 budget_av->ca.slot_reset = ciintf_slot_reset;
354 budget_av->ca.slot_shutdown = ciintf_slot_shutdown;
355 budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable;
356 budget_av->ca.poll_slot_status = ciintf_poll_slot_status;
357 budget_av->ca.data = budget_av;
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300358 budget_av->budget.ci_present = 1;
359 budget_av->slot_status = SLOTSTATUS_NONE;
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700360
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -0700361 if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 &budget_av->ca, 0, 1)) != 0) {
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700363 printk(KERN_ERR "budget-av: ci initialisation failed.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 goto error;
365 }
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700366
367 printk(KERN_INFO "budget-av: ci interface initialised.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 return 0;
369
370error:
Hartmut Birr2a893de2006-12-03 21:08:08 -0300371 saa7146_write(saa, MC1, MASK_27);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 return result;
373}
374
375static void ciintf_deinit(struct budget_av *budget_av)
376{
377 struct saa7146_dev *saa = budget_av->budget.dev;
378
379 saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
380 saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);
381 saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT);
382 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
383
384 /* release the CA device */
385 dvb_ca_en50221_release(&budget_av->ca);
386
387 /* disable DEBI pins */
Hartmut Birr2a893de2006-12-03 21:08:08 -0300388 saa7146_write(saa, MC1, MASK_27);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389}
390
391
392static const u8 saa7113_tab[] = {
393 0x01, 0x08,
394 0x02, 0xc0,
395 0x03, 0x33,
396 0x04, 0x00,
397 0x05, 0x00,
398 0x06, 0xeb,
399 0x07, 0xe0,
400 0x08, 0x28,
401 0x09, 0x00,
402 0x0a, 0x80,
403 0x0b, 0x47,
404 0x0c, 0x40,
405 0x0d, 0x00,
406 0x0e, 0x01,
407 0x0f, 0x44,
408
409 0x10, 0x08,
410 0x11, 0x0c,
411 0x12, 0x7b,
412 0x13, 0x00,
413 0x15, 0x00, 0x16, 0x00, 0x17, 0x00,
414
415 0x57, 0xff,
416 0x40, 0x82, 0x58, 0x00, 0x59, 0x54, 0x5a, 0x07,
417 0x5b, 0x83, 0x5e, 0x00,
418 0xff
419};
420
421static int saa7113_init(struct budget_av *budget_av)
422{
423 struct budget *budget = &budget_av->budget;
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700424 struct saa7146_dev *saa = budget->dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 const u8 *data = saa7113_tab;
426
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700427 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
428 msleep(200);
429
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 if (i2c_writereg(&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) {
431 dprintk(1, "saa7113 not found on KNC card\n");
432 return -ENODEV;
433 }
434
435 dprintk(1, "saa7113 detected and initializing\n");
436
437 while (*data != 0xff) {
438 i2c_writereg(&budget->i2c_adap, 0x4a, *data, *(data + 1));
439 data += 2;
440 }
441
442 dprintk(1, "saa7113 status=%02x\n", i2c_readreg(&budget->i2c_adap, 0x4a, 0x1f));
443
444 return 0;
445}
446
447static int saa7113_setinput(struct budget_av *budget_av, int input)
448{
449 struct budget *budget = &budget_av->budget;
450
451 if (1 != budget_av->has_saa7113)
452 return -ENODEV;
453
454 if (input == 1) {
455 i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc7);
456 i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x80);
457 } else if (input == 0) {
458 i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc0);
459 i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x00);
460 } else
461 return -EINVAL;
462
463 budget_av->cur_input = input;
464 return 0;
465}
466
467
468static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
469{
470 u8 aclk = 0;
471 u8 bclk = 0;
472 u8 m1;
473
474 aclk = 0xb5;
475 if (srate < 2000000)
476 bclk = 0x86;
477 else if (srate < 5000000)
478 bclk = 0x89;
479 else if (srate < 15000000)
480 bclk = 0x8f;
481 else if (srate < 45000000)
482 bclk = 0x95;
483
484 m1 = 0x14;
485 if (srate < 4000000)
486 m1 = 0x10;
487
488 stv0299_writereg(fe, 0x13, aclk);
489 stv0299_writereg(fe, 0x14, bclk);
490 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
491 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
492 stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
493 stv0299_writereg(fe, 0x0f, 0x80 | m1);
494
495 return 0;
496}
497
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300498static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe,
499 struct dvb_frontend_parameters *params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 u32 div;
502 u8 buf[4];
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300503 struct budget *budget = (struct budget *) fe->dvb->priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
505
506 if ((params->frequency < 950000) || (params->frequency > 2150000))
507 return -EINVAL;
508
509 div = (params->frequency + (125 - 1)) / 125; // round correctly
510 buf[0] = (div >> 8) & 0x7f;
511 buf[1] = div & 0xff;
512 buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
513 buf[3] = 0x20;
514
515 if (params->u.qpsk.symbol_rate < 4000000)
516 buf[3] |= 1;
517
518 if (params->frequency < 1250000)
519 buf[3] |= 0;
520 else if (params->frequency < 1550000)
521 buf[3] |= 0x40;
522 else if (params->frequency < 2050000)
523 buf[3] |= 0x80;
524 else if (params->frequency < 2150000)
525 buf[3] |= 0xC0;
526
Patrick Boettcherdea74862006-05-14 05:01:31 -0300527 if (fe->ops.i2c_gate_ctrl)
528 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300529 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 return -EIO;
531 return 0;
532}
533
534static u8 typhoon_cinergy1200s_inittab[] = {
535 0x01, 0x15,
536 0x02, 0x30,
537 0x03, 0x00,
538 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
539 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
540 0x06, 0x40, /* DAC not used, set to high impendance mode */
541 0x07, 0x00, /* DAC LSB */
542 0x08, 0x40, /* DiSEqC off */
543 0x09, 0x00, /* FIFO */
544 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
545 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
546 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
547 0x10, 0x3f, // AGC2 0x3d
548 0x11, 0x84,
Oliver Endrissff29d062005-11-08 21:35:43 -0800549 0x12, 0xb9,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 0x15, 0xc9, // lock detector threshold
551 0x16, 0x00,
552 0x17, 0x00,
553 0x18, 0x00,
554 0x19, 0x00,
555 0x1a, 0x00,
556 0x1f, 0x50,
557 0x20, 0x00,
558 0x21, 0x00,
559 0x22, 0x00,
560 0x23, 0x00,
561 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
562 0x29, 0x1e, // 1/2 threshold
563 0x2a, 0x14, // 2/3 threshold
564 0x2b, 0x0f, // 3/4 threshold
565 0x2c, 0x09, // 5/6 threshold
566 0x2d, 0x05, // 7/8 threshold
567 0x2e, 0x01,
568 0x31, 0x1f, // test all FECs
569 0x32, 0x19, // viterbi and synchro search
570 0x33, 0xfc, // rs control
571 0x34, 0x93, // error control
572 0x0f, 0x92,
573 0xff, 0xff
574};
575
576static struct stv0299_config typhoon_config = {
577 .demod_address = 0x68,
578 .inittab = typhoon_cinergy1200s_inittab,
579 .mclk = 88000000UL,
580 .invert = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 .skip_reinit = 0,
Oliver Endrissda2c7f62008-04-20 22:13:37 -0300582 .lock_output = STV0299_LOCKOUTPUT_1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 .volt13_op0_op1 = STV0299_VOLT13_OP0,
584 .min_delay_ms = 100,
585 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586};
587
588
589static struct stv0299_config cinergy_1200s_config = {
590 .demod_address = 0x68,
591 .inittab = typhoon_cinergy1200s_inittab,
592 .mclk = 88000000UL,
593 .invert = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .skip_reinit = 0,
Oliver Endrissda2c7f62008-04-20 22:13:37 -0300595 .lock_output = STV0299_LOCKOUTPUT_0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 .volt13_op0_op1 = STV0299_VOLT13_OP0,
597 .min_delay_ms = 100,
598 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599};
600
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200601static struct stv0299_config cinergy_1200s_1894_0010_config = {
602 .demod_address = 0x68,
603 .inittab = typhoon_cinergy1200s_inittab,
604 .mclk = 88000000UL,
605 .invert = 1,
606 .skip_reinit = 0,
Oliver Endrissda2c7f62008-04-20 22:13:37 -0300607 .lock_output = STV0299_LOCKOUTPUT_1,
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200608 .volt13_op0_op1 = STV0299_VOLT13_OP0,
609 .min_delay_ms = 100,
610 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200611};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300613static int philips_cu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614{
615 struct budget *budget = (struct budget *) fe->dvb->priv;
Hartmut Birraa323ac2007-04-21 19:37:17 -0300616 u8 buf[6];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
Hartmut Birraa323ac2007-04-21 19:37:17 -0300618 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619
Hartmut Birraa323ac2007-04-21 19:37:17 -0300620#define CU1216_IF 36125000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621#define TUNER_MUL 62500
622
Hartmut Birraa323ac2007-04-21 19:37:17 -0300623 u32 div = (params->frequency + CU1216_IF + TUNER_MUL / 2) / TUNER_MUL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
625 buf[0] = (div >> 8) & 0x7f;
626 buf[1] = div & 0xff;
Hartmut Birraa323ac2007-04-21 19:37:17 -0300627 buf[2] = 0xce;
Johannes Stezenbacheef57642005-07-07 17:57:58 -0700628 buf[3] = (params->frequency < 150000000 ? 0x01 :
629 params->frequency < 445000000 ? 0x02 : 0x04);
Hartmut Birraa323ac2007-04-21 19:37:17 -0300630 buf[4] = 0xde;
631 buf[5] = 0x20;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632
Patrick Boettcherdea74862006-05-14 05:01:31 -0300633 if (fe->ops.i2c_gate_ctrl)
634 fe->ops.i2c_gate_ctrl(fe, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
636 return -EIO;
Hartmut Birraa323ac2007-04-21 19:37:17 -0300637
638 /* wait for the pll lock */
639 msg.flags = I2C_M_RD;
640 msg.len = 1;
641 for (i = 0; i < 20; i++) {
642 if (fe->ops.i2c_gate_ctrl)
643 fe->ops.i2c_gate_ctrl(fe, 1);
644 if (i2c_transfer(&budget->i2c_adap, &msg, 1) == 1 && (buf[0] & 0x40))
645 break;
646 msleep(10);
647 }
648
649 /* switch the charge pump to the lower current */
650 msg.flags = 0;
651 msg.len = 2;
652 msg.buf = &buf[2];
653 buf[2] &= ~0x40;
654 if (fe->ops.i2c_gate_ctrl)
655 fe->ops.i2c_gate_ctrl(fe, 1);
656 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
657 return -EIO;
658
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 return 0;
660}
661
Hartmut Birraa323ac2007-04-21 19:37:17 -0300662static struct tda1002x_config philips_cu1216_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .demod_address = 0x0c,
Hartmut Birrdc120b02007-04-21 19:44:10 -0300664 .invert = 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665};
666
Hartmut Birraa323ac2007-04-21 19:37:17 -0300667static struct tda1002x_config philips_cu1216_config_altaddress = {
Andrew de Quincey61cebe92006-11-19 14:10:59 -0300668 .demod_address = 0x0d,
Hartmut Birrdc120b02007-04-21 19:44:10 -0300669 .invert = 0,
Andrew de Quincey61cebe92006-11-19 14:10:59 -0300670};
671
Antti Palosaari4388c3b2008-05-17 22:58:04 -0300672static struct tda10023_config philips_cu1216_tda10023_config = {
673 .demod_address = 0x0c,
674 .invert = 1,
675};
676
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300677static int philips_tu1216_tuner_init(struct dvb_frontend *fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678{
679 struct budget *budget = (struct budget *) fe->dvb->priv;
680 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
681 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
682
683 // setup PLL configuration
Patrick Boettcherdea74862006-05-14 05:01:31 -0300684 if (fe->ops.i2c_gate_ctrl)
685 fe->ops.i2c_gate_ctrl(fe, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
687 return -EIO;
688 msleep(1);
689
690 return 0;
691}
692
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300693static int philips_tu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694{
695 struct budget *budget = (struct budget *) fe->dvb->priv;
696 u8 tuner_buf[4];
697 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,.len =
698 sizeof(tuner_buf) };
699 int tuner_frequency = 0;
700 u8 band, cp, filter;
701
702 // determine charge pump
703 tuner_frequency = params->frequency + 36166000;
704 if (tuner_frequency < 87000000)
705 return -EINVAL;
706 else if (tuner_frequency < 130000000)
707 cp = 3;
708 else if (tuner_frequency < 160000000)
709 cp = 5;
710 else if (tuner_frequency < 200000000)
711 cp = 6;
712 else if (tuner_frequency < 290000000)
713 cp = 3;
714 else if (tuner_frequency < 420000000)
715 cp = 5;
716 else if (tuner_frequency < 480000000)
717 cp = 6;
718 else if (tuner_frequency < 620000000)
719 cp = 3;
720 else if (tuner_frequency < 830000000)
721 cp = 5;
722 else if (tuner_frequency < 895000000)
723 cp = 7;
724 else
725 return -EINVAL;
726
727 // determine band
728 if (params->frequency < 49000000)
729 return -EINVAL;
730 else if (params->frequency < 161000000)
731 band = 1;
732 else if (params->frequency < 444000000)
733 band = 2;
734 else if (params->frequency < 861000000)
735 band = 4;
736 else
737 return -EINVAL;
738
739 // setup PLL filter
740 switch (params->u.ofdm.bandwidth) {
741 case BANDWIDTH_6_MHZ:
742 filter = 0;
743 break;
744
745 case BANDWIDTH_7_MHZ:
746 filter = 0;
747 break;
748
749 case BANDWIDTH_8_MHZ:
750 filter = 1;
751 break;
752
753 default:
754 return -EINVAL;
755 }
756
757 // calculate divisor
758 // ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
759 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
760
761 // setup tuner buffer
762 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
763 tuner_buf[1] = tuner_frequency & 0xff;
764 tuner_buf[2] = 0xca;
765 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
766
Patrick Boettcherdea74862006-05-14 05:01:31 -0300767 if (fe->ops.i2c_gate_ctrl)
768 fe->ops.i2c_gate_ctrl(fe, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
770 return -EIO;
771
772 msleep(1);
773 return 0;
774}
775
776static int philips_tu1216_request_firmware(struct dvb_frontend *fe,
777 const struct firmware **fw, char *name)
778{
779 struct budget *budget = (struct budget *) fe->dvb->priv;
780
781 return request_firmware(fw, name, &budget->dev->pci->dev);
782}
783
784static struct tda1004x_config philips_tu1216_config = {
785
786 .demod_address = 0x8,
787 .invert = 1,
788 .invert_oclk = 1,
Hartmut Hackmannecb60de2005-07-07 17:57:40 -0700789 .xtal_freq = TDA10046_XTAL_4M,
790 .agc_config = TDA10046_AGC_DEFAULT,
791 .if_freq = TDA10046_FREQ_3617,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 .request_firmware = philips_tu1216_request_firmware,
793};
794
Regis Prevotf8bf1342006-01-11 23:31:53 -0200795static u8 philips_sd1878_inittab[] = {
796 0x01, 0x15,
797 0x02, 0x30,
798 0x03, 0x00,
799 0x04, 0x7d,
800 0x05, 0x35,
801 0x06, 0x40,
802 0x07, 0x00,
803 0x08, 0x43,
804 0x09, 0x02,
805 0x0C, 0x51,
806 0x0D, 0x82,
807 0x0E, 0x23,
808 0x10, 0x3f,
809 0x11, 0x84,
810 0x12, 0xb9,
811 0x15, 0xc9,
812 0x16, 0x19,
813 0x17, 0x8c,
814 0x18, 0x59,
815 0x19, 0xf8,
816 0x1a, 0xfe,
817 0x1c, 0x7f,
818 0x1d, 0x00,
819 0x1e, 0x00,
820 0x1f, 0x50,
821 0x20, 0x00,
822 0x21, 0x00,
823 0x22, 0x00,
824 0x23, 0x00,
825 0x28, 0x00,
826 0x29, 0x28,
827 0x2a, 0x14,
828 0x2b, 0x0f,
829 0x2c, 0x09,
830 0x2d, 0x09,
831 0x31, 0x1f,
832 0x32, 0x19,
833 0x33, 0xfc,
834 0x34, 0x93,
835 0xff, 0xff
836};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837
Regis Prevotf8bf1342006-01-11 23:31:53 -0200838static int philips_sd1878_ci_set_symbol_rate(struct dvb_frontend *fe,
839 u32 srate, u32 ratio)
840{
841 u8 aclk = 0;
842 u8 bclk = 0;
843 u8 m1;
844
845 aclk = 0xb5;
846 if (srate < 2000000)
847 bclk = 0x86;
848 else if (srate < 5000000)
849 bclk = 0x89;
850 else if (srate < 15000000)
851 bclk = 0x8f;
852 else if (srate < 45000000)
853 bclk = 0x95;
854
855 m1 = 0x14;
856 if (srate < 4000000)
857 m1 = 0x10;
858
859 stv0299_writereg(fe, 0x0e, 0x23);
860 stv0299_writereg(fe, 0x0f, 0x94);
861 stv0299_writereg(fe, 0x10, 0x39);
862 stv0299_writereg(fe, 0x13, aclk);
863 stv0299_writereg(fe, 0x14, bclk);
864 stv0299_writereg(fe, 0x15, 0xc9);
865 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
866 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
867 stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
868 stv0299_writereg(fe, 0x0f, 0x80 | m1);
869
870 return 0;
871}
872
873static struct stv0299_config philips_sd1878_config = {
874 .demod_address = 0x68,
Andrew de Quincey5c1208b2006-05-22 10:32:02 -0300875 .inittab = philips_sd1878_inittab,
Regis Prevotf8bf1342006-01-11 23:31:53 -0200876 .mclk = 88000000UL,
877 .invert = 0,
878 .skip_reinit = 0,
Oliver Endrissda2c7f62008-04-20 22:13:37 -0300879 .lock_output = STV0299_LOCKOUTPUT_1,
Regis Prevotf8bf1342006-01-11 23:31:53 -0200880 .volt13_op0_op1 = STV0299_VOLT13_OP0,
881 .min_delay_ms = 100,
882 .set_symbol_rate = philips_sd1878_ci_set_symbol_rate,
Regis Prevotf8bf1342006-01-11 23:31:53 -0200883};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884
885static u8 read_pwm(struct budget_av *budget_av)
886{
887 u8 b = 0xff;
888 u8 pwm;
889 struct i2c_msg msg[] = { {.addr = 0x50,.flags = 0,.buf = &b,.len = 1},
890 {.addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1}
891 };
892
893 if ((i2c_transfer(&budget_av->budget.i2c_adap, msg, 2) != 2)
894 || (pwm == 0xff))
895 pwm = 0x48;
896
897 return pwm;
898}
899
Hartmut Birraa323ac2007-04-21 19:37:17 -0300900#define SUBID_DVBS_KNC1 0x0010
901#define SUBID_DVBS_KNC1_PLUS 0x0011
902#define SUBID_DVBS_TYPHOON 0x4f56
903#define SUBID_DVBS_CINERGY1200 0x1154
904#define SUBID_DVBS_CYNERGY1200N 0x1155
905#define SUBID_DVBS_TV_STAR 0x0014
Oliver Endriss03aa73c2008-01-29 23:56:51 -0300906#define SUBID_DVBS_TV_STAR_PLUS_X4 0x0015
Hartmut Birraa323ac2007-04-21 19:37:17 -0300907#define SUBID_DVBS_TV_STAR_CI 0x0016
908#define SUBID_DVBS_EASYWATCH_1 0x001a
Oliver Endrissf72ce642007-05-13 23:25:57 -0300909#define SUBID_DVBS_EASYWATCH_2 0x001b
Hartmut Birraa323ac2007-04-21 19:37:17 -0300910#define SUBID_DVBS_EASYWATCH 0x001e
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700911
Hartmut Birraa323ac2007-04-21 19:37:17 -0300912#define SUBID_DVBC_EASYWATCH 0x002a
913#define SUBID_DVBC_EASYWATCH_MK3 0x002c
914#define SUBID_DVBC_KNC1 0x0020
915#define SUBID_DVBC_KNC1_PLUS 0x0021
916#define SUBID_DVBC_KNC1_MK3 0x0022
917#define SUBID_DVBC_KNC1_PLUS_MK3 0x0023
918#define SUBID_DVBC_CINERGY1200 0x1156
919#define SUBID_DVBC_CINERGY1200_MK3 0x1176
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700920
Kim Sandberg251130b2008-01-30 00:42:01 -0300921#define SUBID_DVBT_EASYWATCH 0x003a
Hartmut Birraa323ac2007-04-21 19:37:17 -0300922#define SUBID_DVBT_KNC1_PLUS 0x0031
923#define SUBID_DVBT_KNC1 0x0030
924#define SUBID_DVBT_CINERGY1200 0x1157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925
926static void frontend_init(struct budget_av *budget_av)
927{
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700928 struct saa7146_dev * saa = budget_av->budget.dev;
929 struct dvb_frontend * fe = NULL;
930
Andrew de Quincey473f5422006-04-13 17:29:07 -0300931 /* Enable / PowerON Frontend */
932 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
933
Hartmut Birr740cf9e2006-11-03 15:34:18 -0300934 /* Wait for PowerON */
935 msleep(100);
936
Andrew de Quincey473f5422006-04-13 17:29:07 -0300937 /* additional setup necessary for the PLUS cards */
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700938 switch (saa->pci->subsystem_device) {
939 case SUBID_DVBS_KNC1_PLUS:
940 case SUBID_DVBC_KNC1_PLUS:
941 case SUBID_DVBT_KNC1_PLUS:
Thomas Hammc01d1e42006-11-17 07:12:58 -0300942 case SUBID_DVBC_EASYWATCH:
Hartmut Birraa323ac2007-04-21 19:37:17 -0300943 case SUBID_DVBC_KNC1_PLUS_MK3:
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700944 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 break;
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700946 }
947
948 switch (saa->pci->subsystem_device) {
949
950 case SUBID_DVBS_KNC1:
Christoph Pfisterc4e3bcb2008-04-09 17:37:36 -0300951 /*
952 * maybe that setting is needed for other dvb-s cards as well,
953 * but so far it has been only confirmed for this type
954 */
955 budget_av->reinitialise_demod = 1;
956 /* fall through */
Christoph Pfister4e318be2006-08-12 09:13:35 -0300957 case SUBID_DVBS_KNC1_PLUS:
Lothar Englisch60110ce2006-06-06 16:13:46 -0300958 case SUBID_DVBS_EASYWATCH_1:
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200959 if (saa->pci->subsystem_vendor == 0x1894) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300960 fe = dvb_attach(stv0299_attach, &cinergy_1200s_1894_0010_config,
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200961 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300962 if (fe) {
Andrew de Quincey1c72cfdce2006-09-05 17:58:20 -0300963 dvb_attach(tua6100_attach, fe, 0x60, &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300964 }
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200965 } else {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300966 fe = dvb_attach(stv0299_attach, &typhoon_config,
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200967 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300968 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300969 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300970 }
Andrew de Quinceyeffa7912006-01-09 15:25:09 -0200971 }
972 break;
973
Regis Prevotf8bf1342006-01-11 23:31:53 -0200974 case SUBID_DVBS_TV_STAR:
Oliver Endriss03aa73c2008-01-29 23:56:51 -0300975 case SUBID_DVBS_TV_STAR_PLUS_X4:
Regis Prevotf8bf1342006-01-11 23:31:53 -0200976 case SUBID_DVBS_TV_STAR_CI:
977 case SUBID_DVBS_CYNERGY1200N:
Thilo Berger36f4f332006-02-27 00:09:08 -0300978 case SUBID_DVBS_EASYWATCH:
Oliver Endrissf72ce642007-05-13 23:25:57 -0300979 case SUBID_DVBS_EASYWATCH_2:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300980 fe = dvb_attach(stv0299_attach, &philips_sd1878_config,
Regis Prevotf8bf1342006-01-11 23:31:53 -0200981 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300982 if (fe) {
Michael Krufky9b98fd22007-05-07 01:48:56 -0300983 dvb_attach(dvb_pll_attach, fe, 0x60,
984 &budget_av->budget.i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300985 DVB_PLL_PHILIPS_SD1878_TDA8261);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300986 }
Regis Prevotf8bf1342006-01-11 23:31:53 -0200987 break;
988
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700989 case SUBID_DVBS_TYPHOON:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300990 fe = dvb_attach(stv0299_attach, &typhoon_config,
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700991 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300992 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300993 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
Andrew de Quinceye87d41c2006-04-18 17:47:11 -0300994 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995 break;
996
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700997 case SUBID_DVBS_CINERGY1200:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300998 fe = dvb_attach(stv0299_attach, &cinergy_1200s_config,
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -0700999 &budget_av->budget.i2c_adap);
Andrew de Quinceye87d41c2006-04-18 17:47:11 -03001000 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001001 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
Andrew de Quinceye87d41c2006-04-18 17:47:11 -03001002 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003 break;
1004
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001005 case SUBID_DVBC_KNC1:
1006 case SUBID_DVBC_KNC1_PLUS:
Andrew de Quincey5c1208b2006-05-22 10:32:02 -03001007 case SUBID_DVBC_CINERGY1200:
Thomas Hammc01d1e42006-11-17 07:12:58 -03001008 case SUBID_DVBC_EASYWATCH:
Andrew de Quincey5c1208b2006-05-22 10:32:02 -03001009 budget_av->reinitialise_demod = 1;
Hartmut Birraa323ac2007-04-21 19:37:17 -03001010 budget_av->budget.dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001011 fe = dvb_attach(tda10021_attach, &philips_cu1216_config,
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001012 &budget_av->budget.i2c_adap,
1013 read_pwm(budget_av));
Andrew de Quincey61cebe92006-11-19 14:10:59 -03001014 if (fe == NULL)
1015 fe = dvb_attach(tda10021_attach, &philips_cu1216_config_altaddress,
1016 &budget_av->budget.i2c_adap,
1017 read_pwm(budget_av));
Andrew de Quinceye87d41c2006-04-18 17:47:11 -03001018 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001019 fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
Andrew de Quinceye87d41c2006-04-18 17:47:11 -03001020 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021 break;
1022
Hartmut Birraa323ac2007-04-21 19:37:17 -03001023 case SUBID_DVBC_EASYWATCH_MK3:
1024 case SUBID_DVBC_CINERGY1200_MK3:
1025 case SUBID_DVBC_KNC1_MK3:
1026 case SUBID_DVBC_KNC1_PLUS_MK3:
1027 budget_av->reinitialise_demod = 1;
1028 budget_av->budget.dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
Antti Palosaari4388c3b2008-05-17 22:58:04 -03001029 fe = dvb_attach(tda10023_attach,
1030 &philips_cu1216_tda10023_config,
1031 &budget_av->budget.i2c_adap,
1032 read_pwm(budget_av));
Hartmut Birraa323ac2007-04-21 19:37:17 -03001033 if (fe) {
1034 fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
1035 }
1036 break;
1037
Kim Sandberg251130b2008-01-30 00:42:01 -03001038 case SUBID_DVBT_EASYWATCH:
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001039 case SUBID_DVBT_KNC1:
1040 case SUBID_DVBT_KNC1_PLUS:
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001041 case SUBID_DVBT_CINERGY1200:
Andrew de Quincey5c1208b2006-05-22 10:32:02 -03001042 budget_av->reinitialise_demod = 1;
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001043 fe = dvb_attach(tda10046_attach, &philips_tu1216_config,
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001044 &budget_av->budget.i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001045 if (fe) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001046 fe->ops.tuner_ops.init = philips_tu1216_tuner_init;
1047 fe->ops.tuner_ops.set_params = philips_tu1216_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001048 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049 break;
1050 }
1051
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001052 if (fe == NULL) {
1053 printk(KERN_ERR "budget-av: A frontend driver was not found "
Bjorn Helgaas29e66a62008-09-04 17:24:51 -03001054 "for device [%04x:%04x] subsystem [%04x:%04x]\n",
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001055 saa->pci->vendor,
1056 saa->pci->device,
1057 saa->pci->subsystem_vendor,
1058 saa->pci->subsystem_device);
1059 return;
1060 }
1061
1062 budget_av->budget.dvb_frontend = fe;
1063
1064 if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
1065 budget_av->budget.dvb_frontend)) {
1066 printk(KERN_ERR "budget-av: Frontend registration failed!\n");
Andrew de Quinceyf52a8382006-08-08 09:10:09 -03001067 dvb_frontend_detach(budget_av->budget.dvb_frontend);
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001068 budget_av->budget.dvb_frontend = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069 }
1070}
1071
1072
1073static void budget_av_irq(struct saa7146_dev *dev, u32 * isr)
1074{
1075 struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
1076
1077 dprintk(8, "dev: %p, budget_av: %p\n", dev, budget_av);
1078
1079 if (*isr & MASK_10)
1080 ttpci_budget_irq10_handler(dev, isr);
1081}
1082
1083static int budget_av_detach(struct saa7146_dev *dev)
1084{
1085 struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
1086 int err;
1087
1088 dprintk(2, "dev: %p\n", dev);
1089
1090 if (1 == budget_av->has_saa7113) {
1091 saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
1092
1093 msleep(200);
1094
1095 saa7146_unregister_device(&budget_av->vd, dev);
Marco Schluessler716a4e32007-02-03 14:47:14 -03001096
1097 saa7146_vv_release(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 }
1099
1100 if (budget_av->budget.ci_present)
1101 ciintf_deinit(budget_av);
1102
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001103 if (budget_av->budget.dvb_frontend != NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 dvb_unregister_frontend(budget_av->budget.dvb_frontend);
Andrew de Quinceyf52a8382006-08-08 09:10:09 -03001105 dvb_frontend_detach(budget_av->budget.dvb_frontend);
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001106 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 err = ttpci_budget_deinit(&budget_av->budget);
1108
1109 kfree(budget_av);
1110
1111 return err;
1112}
1113
1114static struct saa7146_ext_vv vv_data;
1115
1116static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
1117{
1118 struct budget_av *budget_av;
1119 u8 *mac;
1120 int err;
1121
1122 dprintk(2, "dev: %p\n", dev);
1123
Panagiotis Issaris74081872006-01-11 19:40:56 -02001124 if (!(budget_av = kzalloc(sizeof(struct budget_av), GFP_KERNEL)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 return -ENOMEM;
1126
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001127 budget_av->has_saa7113 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 budget_av->budget.ci_present = 0;
1129
1130 dev->ext_priv = budget_av;
1131
Janne Grunau26dc4d02008-09-21 20:50:11 -03001132 err = ttpci_budget_init(&budget_av->budget, dev, info, THIS_MODULE,
1133 adapter_nr);
1134 if (err) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 kfree(budget_av);
1136 return err;
1137 }
1138
1139 /* knc1 initialization */
1140 saa7146_write(dev, DD1_STREAM_B, 0x04000000);
1141 saa7146_write(dev, DD1_INIT, 0x07000600);
1142 saa7146_write(dev, MC2, MASK_09 | MASK_25 | MASK_10 | MASK_26);
1143
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001144 if (saa7113_init(budget_av) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 budget_av->has_saa7113 = 1;
1146
1147 if (0 != saa7146_vv_init(dev, &vv_data)) {
1148 /* fixme: proper cleanup here */
1149 ERR(("cannot init vv subsystem.\n"));
1150 return err;
1151 }
1152
1153 if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) {
1154 /* fixme: proper cleanup here */
1155 ERR(("cannot register capture v4l2 device.\n"));
Marco Schluessler716a4e32007-02-03 14:47:14 -03001156 saa7146_vv_release(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 return err;
1158 }
1159
1160 /* beware: this modifies dev->vv ... */
1161 saa7146_set_hps_source_and_sync(dev, SAA7146_HPS_SOURCE_PORT_A,
1162 SAA7146_HPS_SYNC_PORT_A);
1163
1164 saa7113_setinput(budget_av, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 }
1166
1167 /* fixme: find some sane values here... */
1168 saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
1169
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -07001170 mac = budget_av->budget.dvb_adapter.proposed_mac;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) {
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001172 printk(KERN_ERR "KNC1-%d: Could not read MAC from KNC1 card\n",
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -07001173 budget_av->budget.dvb_adapter.num);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 memset(mac, 0, 6);
1175 } else {
Johannes Stezenbachb82a96a2005-05-16 21:54:49 -07001176 printk(KERN_INFO "KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -07001177 budget_av->budget.dvb_adapter.num,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
1179 }
1180
Johannes Stezenbachfdc53a62005-05-16 21:54:39 -07001181 budget_av->budget.dvb_adapter.priv = budget_av;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 frontend_init(budget_av);
Andrew de Quinceyc5e768a2006-06-29 13:16:11 -03001183 ciintf_init(budget_av);
Oliver Endriss32e4c3a2006-07-18 22:55:23 -03001184
1185 ttpci_budget_init_hooks(&budget_av->budget);
1186
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 return 0;
1188}
1189
1190#define KNC1_INPUTS 2
1191static struct v4l2_input knc1_inputs[KNC1_INPUTS] = {
1192 {0, "Composite", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0},
1193 {1, "S-Video", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0},
1194};
1195
1196static struct saa7146_extension_ioctls ioctls[] = {
1197 {VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE},
1198 {VIDIOC_G_INPUT, SAA7146_EXCLUSIVE},
1199 {VIDIOC_S_INPUT, SAA7146_EXCLUSIVE},
1200 {0, 0}
1201};
1202
1203static int av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
1204{
1205 struct saa7146_dev *dev = fh->dev;
1206 struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
1207
1208 switch (cmd) {
1209 case VIDIOC_ENUMINPUT:{
1210 struct v4l2_input *i = arg;
1211
1212 dprintk(1, "VIDIOC_ENUMINPUT %d.\n", i->index);
1213 if (i->index < 0 || i->index >= KNC1_INPUTS) {
1214 return -EINVAL;
1215 }
1216 memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input));
1217 return 0;
1218 }
1219 case VIDIOC_G_INPUT:{
1220 int *input = (int *) arg;
1221
1222 *input = budget_av->cur_input;
1223
1224 dprintk(1, "VIDIOC_G_INPUT %d.\n", *input);
1225 return 0;
1226 }
1227 case VIDIOC_S_INPUT:{
1228 int input = *(int *) arg;
1229 dprintk(1, "VIDIOC_S_INPUT %d.\n", input);
1230 return saa7113_setinput(budget_av, input);
1231 }
1232 default:
1233 return -ENOIOCTLCMD;
1234 }
1235 return 0;
1236}
1237
1238static struct saa7146_standard standard[] = {
1239 {.name = "PAL",.id = V4L2_STD_PAL,
1240 .v_offset = 0x17,.v_field = 288,
1241 .h_offset = 0x14,.h_pixels = 680,
1242 .v_max_out = 576,.h_max_out = 768 },
1243
1244 {.name = "NTSC",.id = V4L2_STD_NTSC,
1245 .v_offset = 0x16,.v_field = 240,
1246 .h_offset = 0x06,.h_pixels = 708,
1247 .v_max_out = 480,.h_max_out = 640, },
1248};
1249
1250static struct saa7146_ext_vv vv_data = {
1251 .inputs = 2,
1252 .capabilities = 0, // perhaps later: V4L2_CAP_VBI_CAPTURE, but that need tweaking with the saa7113
1253 .flags = 0,
1254 .stds = &standard[0],
Andi Drebesaf520a32007-07-30 11:48:10 -03001255 .num_stds = ARRAY_SIZE(standard),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001256 .ioctls = &ioctls[0],
1257 .ioctl = av_ioctl,
1258};
1259
1260static struct saa7146_extension budget_extension;
1261
1262MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S);
1263MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
1264MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
Regis Prevotf8bf1342006-01-11 23:31:53 -02001265MAKE_BUDGET_INFO(kncxs, "KNC TV STAR DVB-S", BUDGET_TVSTAR);
Thilo Berger36f4f332006-02-27 00:09:08 -03001266MAKE_BUDGET_INFO(satewpls, "Satelco EasyWatch DVB-S light", BUDGET_TVSTAR);
Lothar Englisch60110ce2006-06-06 16:13:46 -03001267MAKE_BUDGET_INFO(satewpls1, "Satelco EasyWatch DVB-S light", BUDGET_KNC1S);
Oliver Endrissf72ce642007-05-13 23:25:57 -03001268MAKE_BUDGET_INFO(satewps, "Satelco EasyWatch DVB-S", BUDGET_KNC1S);
Thomas Hammc01d1e42006-11-17 07:12:58 -03001269MAKE_BUDGET_INFO(satewplc, "Satelco EasyWatch DVB-C", BUDGET_KNC1CP);
Hartmut Birraa323ac2007-04-21 19:37:17 -03001270MAKE_BUDGET_INFO(satewcmk3, "Satelco EasyWatch DVB-C MK3", BUDGET_KNC1C_MK3);
Kim Sandberg251130b2008-01-30 00:42:01 -03001271MAKE_BUDGET_INFO(satewt, "Satelco EasyWatch DVB-T", BUDGET_KNC1T);
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001272MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP);
Oliver Endriss03aa73c2008-01-29 23:56:51 -03001273MAKE_BUDGET_INFO(knc1spx4, "KNC1 DVB-S Plus X4", BUDGET_KNC1SP);
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001274MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP);
Hartmut Birraa323ac2007-04-21 19:37:17 -03001275MAKE_BUDGET_INFO(knc1cmk3, "KNC1 DVB-C MK3", BUDGET_KNC1C_MK3);
1276MAKE_BUDGET_INFO(knc1cpmk3, "KNC1 DVB-C Plus MK3", BUDGET_KNC1CP_MK3);
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001277MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
Regis Prevotf8bf1342006-01-11 23:31:53 -02001279MAKE_BUDGET_INFO(cin1200sn, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
Hartmut Birraa323ac2007-04-21 19:37:17 -03001281MAKE_BUDGET_INFO(cin1200cmk3, "Terratec Cinergy 1200 DVB-C MK3", BUDGET_CIN1200C_MK3);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
1283
1284static struct pci_device_id pci_tbl[] = {
1285 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001286 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
Andrew de Quinceyeffa7912006-01-09 15:25:09 -02001287 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001288 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
Christoph Pfister4e318be2006-08-12 09:13:35 -03001289 MAKE_EXTENSION_PCI(knc1sp, 0x1894, 0x0011),
Regis Prevotf8bf1342006-01-11 23:31:53 -02001290 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
Oliver Endriss03aa73c2008-01-29 23:56:51 -03001291 MAKE_EXTENSION_PCI(knc1spx4, 0x1894, 0x0015),
Regis Prevotf8bf1342006-01-11 23:31:53 -02001292 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
Thilo Berger36f4f332006-02-27 00:09:08 -03001293 MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e),
Lothar Englisch60110ce2006-06-06 16:13:46 -03001294 MAKE_EXTENSION_PCI(satewpls1, 0x1894, 0x001a),
Oliver Endrissf72ce642007-05-13 23:25:57 -03001295 MAKE_EXTENSION_PCI(satewps, 0x1894, 0x001b),
Thomas Hammc01d1e42006-11-17 07:12:58 -03001296 MAKE_EXTENSION_PCI(satewplc, 0x1894, 0x002a),
Hartmut Birraa323ac2007-04-21 19:37:17 -03001297 MAKE_EXTENSION_PCI(satewcmk3, 0x1894, 0x002c),
Kim Sandberg251130b2008-01-30 00:42:01 -03001298 MAKE_EXTENSION_PCI(satewt, 0x1894, 0x003a),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001300 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
Hartmut Birraa323ac2007-04-21 19:37:17 -03001301 MAKE_EXTENSION_PCI(knc1cmk3, 0x1894, 0x0022),
1302 MAKE_EXTENSION_PCI(knc1cpmk3, 0x1894, 0x0023),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),
Johannes Stezenbach2d4f2c22005-05-16 21:54:23 -07001304 MAKE_EXTENSION_PCI(knc1tp, 0x1894, 0x0031),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154),
Regis Prevotf8bf1342006-01-11 23:31:53 -02001306 MAKE_EXTENSION_PCI(cin1200sn, 0x153b, 0x1155),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307 MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156),
Hartmut Birraa323ac2007-04-21 19:37:17 -03001308 MAKE_EXTENSION_PCI(cin1200cmk3, 0x153b, 0x1176),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309 MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157),
1310 {
1311 .vendor = 0,
1312 }
1313};
1314
1315MODULE_DEVICE_TABLE(pci, pci_tbl);
1316
1317static struct saa7146_extension budget_extension = {
Julian Scheel27b05fd2005-07-12 13:58:39 -07001318 .name = "budget_av",
Oliver Endriss00c4cc62006-11-01 13:09:51 -03001319 .flags = SAA7146_USE_I2C_IRQ,
Oliver Endriss69459f3d2005-12-01 00:51:48 -08001320
Linus Torvalds1da177e2005-04-16 15:20:36 -07001321 .pci_tbl = pci_tbl,
1322
1323 .module = THIS_MODULE,
1324 .attach = budget_av_attach,
1325 .detach = budget_av_detach,
1326
1327 .irq_mask = MASK_10,
1328 .irq_func = budget_av_irq,
1329};
1330
1331static int __init budget_av_init(void)
1332{
1333 return saa7146_register_extension(&budget_extension);
1334}
1335
1336static void __exit budget_av_exit(void)
1337{
1338 saa7146_unregister_extension(&budget_extension);
1339}
1340
1341module_init(budget_av_init);
1342module_exit(budget_av_exit);
1343
1344MODULE_LICENSE("GPL");
1345MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
1346MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
1347 "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");