source: scripts/patches/linux-2.6.10-cx88-update.patch@ c9946b3

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since c9946b3 was 7f65c0e, checked in by Jim Gifford <clfs@…>, 19 years ago

r625@server (orig r623): jim | 2005-10-31 12:43:24 -0800
Final Move

  • Property mode set to 100644
File size: 41.8 KB
RevLine 
[617118d]1Subject: [patch] cx88 update
2
3FIXME: description
4
5Signed-off-by: Gerd Knorr <kraxel@bytesex.org>
6Index: linux-2004-12-16/drivers/media/video/cx88/cx88-cards.c
7===================================================================
8--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88-cards.c 2004-12-17 12:09:01.000000000 +0100
9+++ linux-2004-12-16/drivers/media/video/cx88/cx88-cards.c 2004-12-17 12:47:15.117293538 +0100
10@@ -1,5 +1,5 @@
11 /*
12- * $Id: cx88-cards.c,v 1.47 2004/11/03 09:04:50 kraxel Exp $
13+ * $Id: cx88-cards.c,v 1.53 2004/12/14 15:33:30 kraxel Exp $
14 *
15 * device driver for Conexant 2388x based TV cards
16 * card-specific stuff.
17@@ -32,7 +32,8 @@
18
19 #include "cx88.h"
20 #ifdef WITH_DVB
21-#include "cx22702.h"
22+# include "dvb-pll.h"
23+# include "cx22702.h"
24 #endif
25
26 /* ------------------------------------------------------------------ */
27@@ -91,7 +92,7 @@ struct cx88_board cx88_boards[] = {
28 },
29 [CX88_BOARD_PIXELVIEW] = {
30 .name = "PixelView",
31- .tuner_type = UNSET,
32+ .tuner_type = 5,
33 .input = {{
34 .type = CX88_VMUX_TELEVISION,
35 .vmux = 0,
36@@ -223,20 +224,26 @@ struct cx88_board cx88_boards[] = {
37 },
38 },
39 [CX88_BOARD_LEADTEK_PVR2000] = {
40+ // gpio values for PAL version from regspy by DScaler
41 .name = "Leadtek PVR 2000",
42 .tuner_type = 38,
43+ .tda9887_conf = TDA9887_PRESENT,
44 .input = {{
45 .type = CX88_VMUX_TELEVISION,
46 .vmux = 0,
47+ .gpio0 = 0x0000bde6,
48 },{
49 .type = CX88_VMUX_COMPOSITE1,
50 .vmux = 1,
51+ .gpio0 = 0x0000bde6,
52 },{
53 .type = CX88_VMUX_SVIDEO,
54 .vmux = 2,
55+ .gpio0 = 0x0000bde6,
56 }},
57 .radio = {
58 .type = CX88_RADIO,
59+ .gpio0 = 0x0000bd62,
60 },
61 .blackbird = 1,
62 },
63@@ -452,6 +459,22 @@ struct cx88_board cx88_boards[] = {
64 }},
65 .dvb = 1,
66 },
67+ [CX88_BOARD_DNTV_LIVE_DVB_T] = {
68+ .name = "digitalnow DNTV Live! DVB-T",
69+ .tuner_type = TUNER_ABSENT,
70+ .input = {{
71+ .type = CX88_VMUX_COMPOSITE1,
72+ .vmux = 1,
73+ .gpio0 = 0x00000700,
74+ .gpio2 = 0x00000101,
75+ },{
76+ .type = CX88_VMUX_SVIDEO,
77+ .vmux = 2,
78+ .gpio0 = 0x00000700,
79+ .gpio2 = 0x00000101,
80+ }},
81+ .dvb = 1,
82+ },
83 };
84 const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
85
86@@ -543,6 +566,18 @@ struct cx88_subid cx88_subids[] = {
87 .subvendor = 0x18AC,
88 .subdevice = 0xDB10,
89 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
90+ },{
91+ .subvendor = 0x1554,
92+ .subdevice = 0x4811,
93+ .card = CX88_BOARD_PIXELVIEW,
94+ },{
95+ .subvendor = 0x7063,
96+ .subdevice = 0x3000, /* HD-3000 card */
97+ .card = CX88_BOARD_PCHDTV_HD3000,
98+ },{
99+ .subvendor = 0x17DE,
100+ .subdevice = 0xA8A6,
101+ .card = CX88_BOARD_DNTV_LIVE_DVB_T,
102 }
103 };
104 const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
105@@ -632,11 +667,13 @@ static struct {
106 { TUNER_LG_PAL_FM, "LG TPI8PSB01D"},
107 { TUNER_LG_PAL, "LG TPI8PSB11D"},
108 { TUNER_LG_PAL_I_FM, "LG TAPC-I001D"},
109- { TUNER_LG_PAL_I, "LG TAPC-I701D"}
110+ { TUNER_LG_PAL_I, "LG TAPC-I701D"},
111+ { TUNER_THOMSON_DTT7610, "DTT-7610"}
112 };
113
114 static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
115 {
116+#if 0
117 unsigned int blk2,tuner,radio,model;
118
119 if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0) {
120@@ -663,6 +700,13 @@ static void hauppauge_eeprom(struct cx88
121 core->name, model, (tuner < ARRAY_SIZE(hauppauge_tuner)
122 ? hauppauge_tuner[tuner].name : "?"),
123 core->tuner_type, radio ? "yes" : "no");
124+#else
125+ struct tveeprom tv;
126+
127+ tveeprom_hauppauge_analog(&tv, eeprom_data);
128+ core->tuner_type = tv.tuner_type;
129+ core->has_radio = tv.has_radio;
130+#endif
131 }
132
133 #ifdef WITH_DVB
134@@ -670,7 +714,6 @@ static int hauppauge_eeprom_dvb(struct c
135 {
136 int model;
137 int tuner;
138- char *tname;
139
140 /* Make sure we support the board model */
141 model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c];
142@@ -689,23 +732,20 @@ static int hauppauge_eeprom_dvb(struct c
143 /* Make sure we support the tuner */
144 tuner = ee[0x2d];
145 switch(tuner) {
146- case 0x4B:
147- tname = "Thomson DTT 7595";
148- core->pll_type = PLLTYPE_DTT7595;
149- break;
150- case 0x4C:
151- tname = "Thomson DTT 7592";
152- core->pll_type = PLLTYPE_DTT7592;
153+ case 0x4B: /* ddt 7595 */
154+ case 0x4C: /* dtt 7592 */
155+ core->pll_desc = &dvb_pll_thomson_dtt759x;
156 break;
157 default:
158 printk("%s: error: unknown hauppauge tuner 0x%02x\n",
159 core->name, tuner);
160 return -ENODEV;
161 }
162- printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%s (%d)\n",
163- core->name, model, tname, tuner);
164+ printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%d (%s)\n",
165+ core->name, model, tuner,
166+ core->pll_desc ? core->pll_desc->name : "UNKNOWN");
167
168- core->pll_addr = 0x61;
169+ core->pll_addr = 0x61;
170 core->demod_addr = 0x43;
171 }
172 #endif
173@@ -763,36 +803,6 @@ static void gdi_eeprom(struct cx88_core
174
175 /* ----------------------------------------------------------------------- */
176
177-static int
178-i2c_eeprom(struct i2c_client *c, unsigned char *eedata, int len)
179-{
180- unsigned char buf;
181- int err;
182-
183- c->addr = 0xa0 >> 1;
184- buf = 0;
185- if (1 != (err = i2c_master_send(c,&buf,1))) {
186- printk(KERN_INFO "cx88: Huh, no eeprom present (err=%d)?\n",
187- err);
188- return -1;
189- }
190- if (len != (err = i2c_master_recv(c,eedata,len))) {
191- printk(KERN_WARNING "cx88: i2c eeprom read error (err=%d)\n",
192- err);
193- return -1;
194- }
195-#if 0
196- for (i = 0; i < len; i++) {
197- if (0 == (i % 16))
198- printk(KERN_INFO "cx88 ee: %02x:",i);
199- printk(" %02x",eedata[i]);
200- if (15 == (i % 16))
201- printk("\n");
202- }
203-#endif
204- return 0;
205-}
206-
207 void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
208 {
209 int i;
210@@ -823,21 +833,33 @@ void cx88_card_setup(struct cx88_core *c
211 {
212 static u8 eeprom[128];
213
214+ if (0 == core->i2c_rc) {
215+ core->i2c_client.addr = 0xa0 >> 1;
216+ tveeprom_read(&core->i2c_client,eeprom,sizeof(eeprom));
217+ }
218+
219 switch (core->board) {
220 case CX88_BOARD_HAUPPAUGE:
221 if (0 == core->i2c_rc)
222- i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
223- hauppauge_eeprom(core,eeprom+8);
224+ hauppauge_eeprom(core,eeprom+8);
225 break;
226 case CX88_BOARD_GDI:
227 if (0 == core->i2c_rc)
228- i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
229- gdi_eeprom(core,eeprom);
230+ gdi_eeprom(core,eeprom);
231 break;
232 case CX88_BOARD_WINFAST2000XP:
233 if (0 == core->i2c_rc)
234- i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
235- leadtek_eeprom(core,eeprom);
236+ leadtek_eeprom(core,eeprom);
237+ break;
238+#ifdef WITH_DVB
239+ case CX88_BOARD_HAUPPAUGE_DVB_T1:
240+ if (0 == core->i2c_rc)
241+ hauppauge_eeprom_dvb(core,eeprom);
242+ break;
243+ case CX88_BOARD_CONEXANT_DVB_T1:
244+ core->pll_desc = &dvb_pll_thomson_dtt7579;
245+ core->pll_addr = 0x60;
246+ core->demod_addr = 0x43;
247 break;
248 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
249 /* Tuner reset is hooked to the tuner out of reset */
250@@ -845,17 +867,22 @@ void cx88_card_setup(struct cx88_core *c
251 cx_clear(MO_GP0_IO, 0x00000001);
252 msleep(1);
253 cx_set(MO_GP0_IO, 0x00000101);
254+ core->pll_addr = 0x61;
255+ core->pll_desc = &dvb_pll_lg_z201;
256 break;
257-#ifdef WITH_DVB
258- case CX88_BOARD_HAUPPAUGE_DVB_T1:
259- if (0 == core->i2c_rc)
260- i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
261- hauppauge_eeprom_dvb(core,eeprom);
262+ case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
263+ core->pll_addr = 0x60;
264+ core->pll_desc = &dvb_pll_thomson_dtt7579;
265 break;
266- case CX88_BOARD_CONEXANT_DVB_T1:
267- core->pll_type = PLLTYPE_DTT7579;
268- core->pll_addr = 0x60;
269- core->demod_addr = 0x43;
270+ case CX88_BOARD_DNTV_LIVE_DVB_T:
271+ cx_set(MO_GP0_IO, 0x00000707);
272+ cx_set(MO_GP2_IO, 0x00000101);
273+ cx_clear(MO_GP2_IO, 0x00000001);
274+ msleep(1);
275+ cx_clear(MO_GP0_IO, 0x00000007);
276+ cx_set(MO_GP2_IO, 0x00000101);
277+ core->pll_addr = 0x61;
278+ core->pll_desc = &dvb_pll_unknown_1;
279 break;
280 #endif
281 }
282Index: linux-2004-12-16/drivers/media/video/cx88/cx88-core.c
283===================================================================
284--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88-core.c 2004-12-17 12:07:24.000000000 +0100
285+++ linux-2004-12-16/drivers/media/video/cx88/cx88-core.c 2004-12-17 12:47:15.126291846 +0100
286@@ -1,5 +1,5 @@
287 /*
288- * $Id: cx88-core.c,v 1.15 2004/10/25 11:26:36 kraxel Exp $
289+ * $Id: cx88-core.c,v 1.21 2004/12/10 12:33:39 kraxel Exp $
290 *
291 * device driver for Conexant 2388x based TV cards
292 * driver core
293@@ -24,6 +24,7 @@
294 #include <linux/init.h>
295 #include <linux/list.h>
296 #include <linux/module.h>
297+#include <linux/moduleparam.h>
298 #include <linux/kernel.h>
299 #include <linux/slab.h>
300 #include <linux/kmod.h>
301@@ -62,6 +63,10 @@ static unsigned int nicam = 0;
302 module_param(nicam,int,0644);
303 MODULE_PARM_DESC(nicam,"tv audio is nicam");
304
305+static unsigned int nocomb = 0;
306+module_param(nocomb,int,0644);
307+MODULE_PARM_DESC(nicam,"disable comb filter");
308+
309 #define dprintk(level,fmt, arg...) if (core_debug >= level) \
310 printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
311
312@@ -462,6 +467,7 @@ int cx88_risc_decode(u32 risc)
313 return incr[risc >> 28] ? incr[risc >> 28] : 1;
314 }
315
316+#if 0 /* currently unused, but useful for debugging */
317 void cx88_risc_disasm(struct cx88_core *core,
318 struct btcx_riscmem *risc)
319 {
320@@ -479,6 +485,7 @@ void cx88_risc_disasm(struct cx88_core *
321 break;
322 }
323 }
324+#endif
325
326 void cx88_sram_channel_dump(struct cx88_core *core,
327 struct sram_channel *ch)
328@@ -579,10 +586,19 @@ void cx88_print_irqbits(char *name, char
329
330 /* ------------------------------------------------------------------ */
331
332-void cx88_irq(struct cx88_core *core, u32 status, u32 mask)
333+int cx88_core_irq(struct cx88_core *core, u32 status)
334 {
335- cx88_print_irqbits(core->name, "irq pci",
336- cx88_pci_irqs, status, mask);
337+ int handled = 0;
338+
339+ if (status & (1<<18)) {
340+ cx88_ir_irq(core);
341+ handled++;
342+ }
343+ if (!handled)
344+ cx88_print_irqbits(core->name, "irq pci",
345+ cx88_pci_irqs, status,
346+ core->pci_irqmask);
347+ return handled;
348 }
349
350 void cx88_wakeup(struct cx88_core *core,
351@@ -800,6 +816,8 @@ int cx88_set_scale(struct cx88_core *cor
352 value |= (1 << 0); // 3-tap interpolation
353 if (width < 193)
354 value |= (1 << 1); // 5-tap interpolation
355+ if (nocomb)
356+ value |= (3 << 5); // disable comb filter
357
358 cx_write(MO_FILTER_EVEN, value);
359 cx_write(MO_FILTER_ODD, value);
360@@ -969,6 +987,9 @@ int cx88_set_tvnorm(struct cx88_core *co
361 cx_write(MO_VBI_PACKET, ((1 << 11) | /* (norm_vdelay(norm) << 11) | */
362 norm_vbipack(norm)));
363
364+ // this is needed as well to set all tvnorm parameter
365+ cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED);
366+
367 // audio
368 set_tvaudio(core);
369
370@@ -1105,9 +1126,10 @@ struct cx88_core* cx88_core_get(struct p
371 goto fail_unlock;
372
373 memset(core,0,sizeof(*core));
374+ atomic_inc(&core->refcount);
375 core->pci_bus = pci->bus->number;
376 core->pci_slot = PCI_SLOT(pci->devfn);
377- atomic_inc(&core->refcount);
378+ core->pci_irqmask = 0x00fc00;
379
380 core->nr = cx88_devcount++;
381 sprintf(core->name,"cx88[%d]",core->nr);
382@@ -1150,6 +1172,8 @@ struct cx88_core* cx88_core_get(struct p
383 cx88_reset(core);
384 cx88_i2c_init(core,pci);
385 cx88_card_setup(core);
386+ cx88_ir_init(core,pci);
387+ cx_write(MO_PCI_INTMSK, core->pci_irqmask);
388
389 up(&devlist);
390 return core;
391@@ -1170,6 +1194,7 @@ void cx88_core_put(struct cx88_core *cor
392 return;
393
394 down(&devlist);
395+ cx88_ir_fini(core);
396 if (0 == core->i2c_rc)
397 i2c_bit_del_bus(&core->i2c_adap);
398 list_del(&core->devlist);
399@@ -1187,7 +1212,7 @@ EXPORT_SYMBOL(cx88_vid_irqs);
400 EXPORT_SYMBOL(cx88_mpeg_irqs);
401 EXPORT_SYMBOL(cx88_print_irqbits);
402
403-EXPORT_SYMBOL(cx88_irq);
404+EXPORT_SYMBOL(cx88_core_irq);
405 EXPORT_SYMBOL(cx88_wakeup);
406 EXPORT_SYMBOL(cx88_reset);
407 EXPORT_SYMBOL(cx88_shutdown);
408@@ -1197,8 +1222,6 @@ EXPORT_SYMBOL(cx88_risc_databuffer);
409 EXPORT_SYMBOL(cx88_risc_stopper);
410 EXPORT_SYMBOL(cx88_free_buffer);
411
412-EXPORT_SYMBOL(cx88_risc_disasm);
413-
414 EXPORT_SYMBOL(cx88_sram_channels);
415 EXPORT_SYMBOL(cx88_sram_channel_setup);
416 EXPORT_SYMBOL(cx88_sram_channel_dump);
417Index: linux-2004-12-16/drivers/media/video/cx88/cx88-blackbird.c
418===================================================================
419--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88-blackbird.c 2004-12-17 12:09:05.000000000 +0100
420+++ linux-2004-12-16/drivers/media/video/cx88/cx88-blackbird.c 2004-12-17 12:47:15.136289964 +0100
421@@ -1,5 +1,5 @@
422 /*
423- * $Id: cx88-blackbird.c,v 1.17 2004/11/07 13:17:15 kraxel Exp $
424+ * $Id: cx88-blackbird.c,v 1.23 2004/12/10 12:33:39 kraxel Exp $
425 *
426 * Support for a cx23416 mpeg encoder via cx2388x host port.
427 * "blackbird" reference design.
428@@ -25,6 +25,7 @@
429 */
430
431 #include <linux/module.h>
432+#include <linux/moduleparam.h>
433 #include <linux/init.h>
434 #include <linux/fs.h>
435 #include <linux/delay.h>
436@@ -207,10 +208,6 @@ static int register_write(struct cx88_co
437 cx_read(P1_RADDR0);
438
439 return wait_ready_gpio0_bit1(core,1);
440-#if 0
441- udelay(1000); /* without this, things don't go right (subsequent memory_write()'s don't get through */
442- /* ? would this be safe here? set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); */
443-#endif
444 }
445
446
447@@ -283,7 +280,7 @@ static int blackbird_api_cmd(struct cx88
448 timeout = jiffies + msecs_to_jiffies(10);
449 for (;;) {
450 memory_read(dev->core, dev->mailbox, &flag);
451- if (0 == (flag & 4))
452+ if (0 != (flag & 4))
453 break;
454 if (time_after(jiffies,timeout)) {
455 dprintk(0, "ERROR: API Mailbox timeout\n");
456@@ -324,7 +321,7 @@ static int blackbird_find_mailbox(struct
457 signaturecnt = 0;
458 if (4 == signaturecnt) {
459 dprintk(1, "Mailbox signature found\n");
460- return i;
461+ return i+1;
462 }
463 }
464 dprintk(0, "Mailbox signature values not found!\n");
465@@ -427,7 +424,8 @@ static void blackbird_codec_settings(str
466 blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAMERATE, 1, 0, 0);
467
468 /* assign frame size */
469- blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_SIZE, 2, 0, 480, 720);
470+ blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_SIZE, 2, 0,
471+ dev->height, dev->width);
472
473 /* assign aspect ratio */
474 blackbird_api_cmd(dev, IVTV_API_ASSIGN_ASPECT_RATIO, 1, 0, 2);
475@@ -629,8 +627,8 @@ static int mpeg_do_ioctl(struct inode *i
476
477 memset(f,0,sizeof(*f));
478 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
479- f->fmt.pix.width = 720;
480- f->fmt.pix.height = 576;
481+ f->fmt.pix.width = dev->width;
482+ f->fmt.pix.height = dev->height;
483 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
484 f->fmt.pix.sizeimage = 1024 * 512 /* FIXME: BUFFER_SIZE */;
485 }
486@@ -694,6 +692,10 @@ static int mpeg_open(struct inode *inode
487 file->private_data = fh;
488 fh->dev = dev;
489
490+ /* FIXME: locking against other video device */
491+ cx88_set_scale(dev->core, dev->width, dev->height,
492+ V4L2_FIELD_INTERLACED);
493+
494 videobuf_queue_init(&fh->mpegq, &blackbird_qops,
495 dev->pci, &dev->slock,
496 V4L2_BUF_TYPE_VIDEO_CAPTURE,
497@@ -715,6 +717,7 @@ static int mpeg_release(struct inode *in
498 if (fh->mpegq.reading)
499 videobuf_read_stop(&fh->mpegq);
500
501+ videobuf_mmap_free(&fh->mpegq);
502 file->private_data = NULL;
503 kfree(fh);
504 return 0;
505@@ -821,6 +824,8 @@ static int __devinit blackbird_probe(str
506 memset(dev,0,sizeof(*dev));
507 dev->pci = pci_dev;
508 dev->core = core;
509+ dev->width = 720;
510+ dev->height = 480;
511
512 err = cx8802_init_common(dev);
513 if (0 != err)
514Index: linux-2004-12-16/drivers/media/video/Kconfig
515===================================================================
516--- linux-2004-12-16.orig/drivers/media/video/Kconfig 2004-12-17 12:47:08.871468650 +0100
517+++ linux-2004-12-16/drivers/media/video/Kconfig 2004-12-17 12:47:43.205009038 +0100
518@@ -309,6 +309,7 @@ config VIDEO_CX88
519 select VIDEO_BTCX
520 select VIDEO_BUF
521 select VIDEO_TUNER
522+ select VIDEO_TVEEPROM
523 ---help---
524 This is a video4linux driver for Conexant 2388x based
525 TV cards.
526@@ -318,7 +319,7 @@ config VIDEO_CX88
527
528 config VIDEO_CX88_DVB
529 tristate "DVB Support for cx2388x based TV cards"
530- depends on VIDEO_CX88 && DVB_CORE && BROKEN
531+ depends on VIDEO_CX88 && DVB_CORE
532 select VIDEO_BUF_DVB
533 ---help---
534 This adds support for DVB cards based on the
535Index: linux-2004-12-16/drivers/media/video/cx88/cx88-video.c
536===================================================================
537--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88-video.c 2004-12-17 12:08:16.000000000 +0100
538+++ linux-2004-12-16/drivers/media/video/cx88/cx88-video.c 2004-12-17 12:47:15.148287707 +0100
539@@ -1,5 +1,5 @@
540 /*
541- * $Id: cx88-video.c,v 1.46 2004/11/07 14:44:59 kraxel Exp $
542+ * $Id: cx88-video.c,v 1.50 2004/12/10 12:33:39 kraxel Exp $
543 *
544 * device driver for Conexant 2388x based TV cards
545 * video4linux video interface
546@@ -24,6 +24,7 @@
547 #include <linux/init.h>
548 #include <linux/list.h>
549 #include <linux/module.h>
550+#include <linux/moduleparam.h>
551 #include <linux/kmod.h>
552 #include <linux/kernel.h>
553 #include <linux/slab.h>
554@@ -428,7 +429,7 @@ static int start_video_dma(struct cx8800
555 q->count = 1;
556
557 /* enable irqs */
558- cx_set(MO_PCI_INTMSK, 0x00fc01);
559+ cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x01);
560 cx_set(MO_VID_INTMSK, 0x0f0011);
561
562 /* enable capture */
563@@ -1002,7 +1003,7 @@ static int video_open(struct inode *inod
564 }
565
566 static ssize_t
567-video_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
568+video_read(struct file *file, char *data, size_t count, loff_t *ppos)
569 {
570 struct cx8800_fh *fh = file->private_data;
571
572@@ -1083,6 +1084,8 @@ static int video_release(struct inode *i
573 res_free(dev,fh,RESOURCE_VBI);
574 }
575
576+ videobuf_mmap_free(&fh->vidq);
577+ videobuf_mmap_free(&fh->vbiq);
578 file->private_data = NULL;
579 kfree(fh);
580 return 0;
581@@ -1880,19 +1883,18 @@ static irqreturn_t cx8800_irq(int irq, v
582 {
583 struct cx8800_dev *dev = dev_id;
584 struct cx88_core *core = dev->core;
585- u32 status, mask;
586+ u32 status;
587 int loop, handled = 0;
588
589 for (loop = 0; loop < 10; loop++) {
590- status = cx_read(MO_PCI_INTSTAT) & (~0x1f | 0x01);
591- mask = cx_read(MO_PCI_INTMSK);
592- if (0 == (status & mask))
593+ status = cx_read(MO_PCI_INTSTAT) & (core->pci_irqmask | 0x01);
594+ if (0 == status)
595 goto out;
596 cx_write(MO_PCI_INTSTAT, status);
597 handled = 1;
598
599- if (status & mask & ~0x1f)
600- cx88_irq(core,status,mask);
601+ if (status & core->pci_irqmask)
602+ cx88_core_irq(core,status);
603 if (status & 0x01)
604 cx8800_vid_irq(dev);
605 };
606Index: linux-2004-12-16/drivers/media/video/cx88/cx88-mpeg.c
607===================================================================
608--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88-mpeg.c 2004-12-17 12:09:55.000000000 +0100
609+++ linux-2004-12-16/drivers/media/video/cx88/cx88-mpeg.c 2004-12-17 12:47:15.150287331 +0100
610@@ -1,5 +1,5 @@
611 /*
612- * $Id: cx88-mpeg.c,v 1.14 2004/10/25 11:26:36 kraxel Exp $
613+ * $Id: cx88-mpeg.c,v 1.16 2004/12/10 12:33:39 kraxel Exp $
614 *
615 * Support for the mpeg transport stream transfers
616 * PCI function #2 of the cx2388x.
617@@ -24,6 +24,7 @@
618 */
619
620 #include <linux/module.h>
621+#include <linux/moduleparam.h>
622 #include <linux/init.h>
623 #include <linux/device.h>
624 #include <linux/interrupt.h>
625@@ -93,7 +94,7 @@ static int cx8802_start_dma(struct cx880
626 q->count = 1;
627
628 /* enable irqs */
629- cx_set(MO_PCI_INTMSK, 0x00fc04);
630+ cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x04);
631 cx_write(MO_TS_INTMSK, 0x1f0011);
632
633 /* start dma */
634@@ -292,19 +293,18 @@ static irqreturn_t cx8802_irq(int irq, v
635 {
636 struct cx8802_dev *dev = dev_id;
637 struct cx88_core *core = dev->core;
638- u32 status, mask;
639+ u32 status;
640 int loop, handled = 0;
641
642 for (loop = 0; loop < 10; loop++) {
643- status = cx_read(MO_PCI_INTSTAT) & (~0x1f | 0x04);
644- mask = cx_read(MO_PCI_INTMSK);
645- if (0 == (status & mask))
646+ status = cx_read(MO_PCI_INTSTAT) & (core->pci_irqmask | 0x04);
647+ if (0 == status)
648 goto out;
649 handled = 1;
650 cx_write(MO_PCI_INTSTAT, status);
651
652- if (status & mask & ~0x1f)
653- cx88_irq(core,status,mask);
654+ if (status & core->pci_irqmask)
655+ cx88_core_irq(core,status);
656 if (status & 0x04)
657 cx8802_mpeg_irq(dev);
658 };
659Index: linux-2004-12-16/drivers/media/video/cx88/cx88-tvaudio.c
660===================================================================
661--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88-tvaudio.c 2004-12-17 12:07:52.000000000 +0100
662+++ linux-2004-12-16/drivers/media/video/cx88/cx88-tvaudio.c 2004-12-17 12:47:15.155286390 +0100
663@@ -1,5 +1,5 @@
664 /*
665- $Id: cx88-tvaudio.c,v 1.24 2004/10/25 11:51:00 kraxel Exp $
666+ $Id: cx88-tvaudio.c,v 1.26 2004/12/10 12:33:39 kraxel Exp $
667
668 cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
669
670@@ -37,6 +37,7 @@
671 */
672
673 #include <linux/module.h>
674+#include <linux/moduleparam.h>
675 #include <linux/errno.h>
676 #include <linux/kernel.h>
677 #include <linux/slab.h>
678Index: linux-2004-12-16/drivers/media/video/cx88/cx88-dvb.c
679===================================================================
680--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88-dvb.c 2004-12-17 12:08:32.000000000 +0100
681+++ linux-2004-12-16/drivers/media/video/cx88/cx88-dvb.c 2004-12-17 12:47:15.164284697 +0100
682@@ -1,5 +1,5 @@
683 /*
684- * $Id: cx88-dvb.c,v 1.19 2004/11/07 14:44:59 kraxel Exp $
685+ * $Id: cx88-dvb.c,v 1.21 2004/12/09 12:51:35 kraxel Exp $
686 *
687 * device driver for Conexant 2388x based TV cards
688 * MPEG Transport Stream (DVB) routines
689@@ -31,6 +31,7 @@
690 #include <linux/suspend.h>
691
692 #include "cx88.h"
693+#include "dvb-pll.h"
694 #include "cx22702.h"
695 #include "mt352.h"
696 #include "mt352_priv.h" /* FIXME */
697@@ -110,72 +111,52 @@ static int dvico_fusionhdtv_demod_init(s
698 return 0;
699 }
700
701-#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
702-
703-static int lg_z201_pll_set(struct dvb_frontend* fe,
704- struct dvb_frontend_parameters* params, u8* pllbuf)
705+static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
706 {
707- u32 div;
708- unsigned char cp = 0;
709- unsigned char bs = 0;
710-
711- div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
712-
713- if (params->frequency < 542000000) cp = 0xbc;
714- else if (params->frequency < 830000000) cp = 0xf4;
715- else cp = 0xfc;
716-
717- if (params->frequency == 0) bs = 0x03;
718- else if (params->frequency < 157500000) bs = 0x01;
719- else if (params->frequency < 443250000) bs = 0x02;
720- else bs = 0x04;
721-
722- pllbuf[0] = 0xC2; /* Note: non-linux standard PLL I2C address */
723- pllbuf[1] = div >> 8;
724- pllbuf[2] = div & 0xff;
725- pllbuf[3] = cp;
726- pllbuf[4] = bs;
727+ static u8 clock_config [] = { 0x89, 0x38, 0x39 };
728+ static u8 reset [] = { 0x50, 0x80 };
729+ static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
730+ static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
731+ 0x00, 0xFF, 0x00, 0x40, 0x40 };
732+ static u8 dntv_extra[] = { 0xB5, 0x7A };
733+ static u8 capt_range_cfg[] = { 0x75, 0x32 };
734+
735+ mt352_write(fe, clock_config, sizeof(clock_config));
736+ udelay(2000);
737+ mt352_write(fe, reset, sizeof(reset));
738+ mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
739+
740+ mt352_write(fe, agc_cfg, sizeof(agc_cfg));
741+ udelay(2000);
742+ mt352_write(fe, dntv_extra, sizeof(dntv_extra));
743+ mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
744
745 return 0;
746 }
747
748-static int thomson_dtt7579_pll_set(struct dvb_frontend* fe,
749- struct dvb_frontend_parameters* params,
750- u8* pllbuf)
751-{
752- u32 div;
753- unsigned char cp = 0;
754- unsigned char bs = 0;
755-
756- div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
757-
758- if (params->frequency < 542000000) cp = 0xb4;
759- else if (params->frequency < 771000000) cp = 0xbc;
760- else cp = 0xf4;
761-
762- if (params->frequency == 0) bs = 0x03;
763- else if (params->frequency < 443250000) bs = 0x02;
764- else bs = 0x08;
765-
766- pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address
767- pllbuf[1] = div >> 8;
768- pllbuf[2] = div & 0xff;
769- pllbuf[3] = cp;
770- pllbuf[4] = bs;
771-
772+static int mt352_pll_set(struct dvb_frontend* fe,
773+ struct dvb_frontend_parameters* params,
774+ u8* pllbuf)
775+{
776+ struct cx8802_dev *dev= fe->dvb->priv;
777+
778+ pllbuf[0] = dev->core->pll_addr << 1;
779+ dvb_pll_configure(dev->core->pll_desc, pllbuf+1,
780+ params->frequency,
781+ params->u.ofdm.bandwidth);
782 return 0;
783 }
784
785-struct mt352_config dvico_fusionhdtv_dvbt1 = {
786+static struct mt352_config dvico_fusionhdtv = {
787 .demod_address = 0x0F,
788 .demod_init = dvico_fusionhdtv_demod_init,
789- .pll_set = lg_z201_pll_set,
790+ .pll_set = mt352_pll_set,
791 };
792
793-struct mt352_config dvico_fusionhdtv_dvbt_plus = {
794- .demod_address = 0x0F,
795- .demod_init = dvico_fusionhdtv_demod_init,
796- .pll_set = thomson_dtt7579_pll_set,
797+static struct mt352_config dntv_live_dvbt_config = {
798+ .demod_address = 0x0f,
799+ .demod_init = dntv_live_dvbt_demod_init,
800+ .pll_set = mt352_pll_set,
801 };
802
803 static int dvb_register(struct cx8802_dev *dev)
804@@ -189,32 +170,32 @@ static int dvb_register(struct cx8802_de
805 case CX88_BOARD_CONEXANT_DVB_T1:
806 dev->dvb.frontend = cx22702_create(&dev->core->i2c_adap,
807 dev->core->pll_addr,
808- dev->core->pll_type,
809+ dev->core->pll_desc,
810 dev->core->demod_addr);
811 break;
812 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
813- dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt1,
814+ case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
815+ dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
816 &dev->core->i2c_adap);
817- if (dev->dvb.frontend) {
818- dev->dvb.frontend->ops->info.frequency_min = 174000000;
819- dev->dvb.frontend->ops->info.frequency_max = 862000000;
820- }
821 break;
822- case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
823- dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt_plus,
824+ case CX88_BOARD_DNTV_LIVE_DVB_T:
825+ dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
826 &dev->core->i2c_adap);
827- if (dev->dvb.frontend) {
828- dev->dvb.frontend->ops->info.frequency_min = 174000000;
829- dev->dvb.frontend->ops->info.frequency_max = 862000000;
830- }
831 break;
832 default:
833 printk("%s: FIXME: frontend handling not here yet ...\n",
834 dev->core->name);
835 break;
836 }
837- if (NULL == dev->dvb.frontend)
838+ if (NULL == dev->dvb.frontend) {
839+ printk("%s: frontend initialization failed\n",dev->core->name);
840 return -1;
841+ }
842+
843+ if (dev->core->pll_desc) {
844+ dev->dvb.frontend->ops->info.frequency_min = dev->core->pll_desc->min;
845+ dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max;
846+ }
847
848 /* Copy the board name into the DVB structure */
849 strlcpy(dev->dvb.frontend->ops->info.name,
850@@ -222,7 +203,7 @@ static int dvb_register(struct cx8802_de
851 sizeof(dev->dvb.frontend->ops->info.name));
852
853 /* register everything */
854- return videobuf_dvb_register(&dev->dvb);
855+ return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
856 }
857
858 /* ----------------------------------------------------------- */
859Index: linux-2004-12-16/drivers/media/video/cx88/cx88-input.c
860===================================================================
861--- /dev/null 1970-01-01 00:00:00.000000000 +0000
862+++ linux-2004-12-16/drivers/media/video/cx88/cx88-input.c 2004-12-17 12:47:15.165284509 +0100
863@@ -0,0 +1,394 @@
864+/*
865+ * $Id: cx88-input.c,v 1.3 2004/12/10 12:33:39 kraxel Exp $
866+ *
867+ * Device driver for GPIO attached remote control interfaces
868+ * on Conexant 2388x based TV/DVB cards.
869+ *
870+ * Copyright (c) 2003 Pavel Machek
871+ * Copyright (c) 2004 Gerd Knorr
872+ * Copyright (c) 2004 Chris Pascoe
873+ *
874+ * This program is free software; you can redistribute it and/or modify
875+ * it under the terms of the GNU General Public License as published by
876+ * the Free Software Foundation; either version 2 of the License, or
877+ * (at your option) any later version.
878+ *
879+ * This program is distributed in the hope that it will be useful,
880+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
881+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
882+ * GNU General Public License for more details.
883+ *
884+ * You should have received a copy of the GNU General Public License
885+ * along with this program; if not, write to the Free Software
886+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
887+ */
888+
889+#include <linux/init.h>
890+#include <linux/delay.h>
891+#include <linux/input.h>
892+#include <linux/pci.h>
893+#include <linux/module.h>
894+#include <linux/moduleparam.h>
895+
896+#include <media/ir-common.h>
897+
898+#include "cx88.h"
899+
900+/* ---------------------------------------------------------------------- */
901+
902+/* DigitalNow DNTV Live DVB-T Remote */
903+static IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = {
904+ [ 0x00 ] = KEY_ESC, // 'go up a level?'
905+ [ 0x01 ] = KEY_KP1, // '1'
906+ [ 0x02 ] = KEY_KP2, // '2'
907+ [ 0x03 ] = KEY_KP3, // '3'
908+ [ 0x04 ] = KEY_KP4, // '4'
909+ [ 0x05 ] = KEY_KP5, // '5'
910+ [ 0x06 ] = KEY_KP6, // '6'
911+ [ 0x07 ] = KEY_KP7, // '7'
912+ [ 0x08 ] = KEY_KP8, // '8'
913+ [ 0x09 ] = KEY_KP9, // '9'
914+ [ 0x0a ] = KEY_KP0, // '0'
915+ [ 0x0b ] = KEY_TUNER, // 'tv/fm'
916+ [ 0x0c ] = KEY_SEARCH, // 'scan'
917+ [ 0x0d ] = KEY_STOP, // 'stop'
918+ [ 0x0e ] = KEY_PAUSE, // 'pause'
919+ [ 0x0f ] = KEY_LIST, // 'source'
920+
921+ [ 0x10 ] = KEY_MUTE, // 'mute'
922+ [ 0x11 ] = KEY_REWIND, // 'backward <<'
923+ [ 0x12 ] = KEY_POWER, // 'power'
924+ [ 0x13 ] = KEY_S, // 'snap'
925+ [ 0x14 ] = KEY_AUDIO, // 'stereo'
926+ [ 0x15 ] = KEY_CLEAR, // 'reset'
927+ [ 0x16 ] = KEY_PLAY, // 'play'
928+ [ 0x17 ] = KEY_ENTER, // 'enter'
929+ [ 0x18 ] = KEY_ZOOM, // 'full screen'
930+ [ 0x19 ] = KEY_FASTFORWARD, // 'forward >>'
931+ [ 0x1a ] = KEY_CHANNELUP, // 'channel +'
932+ [ 0x1b ] = KEY_VOLUMEUP, // 'volume +'
933+ [ 0x1c ] = KEY_INFO, // 'preview'
934+ [ 0x1d ] = KEY_RECORD, // 'record'
935+ [ 0x1e ] = KEY_CHANNELDOWN, // 'channel -'
936+ [ 0x1f ] = KEY_VOLUMEDOWN, // 'volume -'
937+};
938+
939+/* ---------------------------------------------------------------------- */
940+
941+struct cx88_IR {
942+ struct cx88_core *core;
943+ struct input_dev input;
944+ struct ir_input_state ir;
945+ char name[32];
946+ char phys[32];
947+
948+ /* sample from gpio pin 16 */
949+ int sampling;
950+ u32 samples[16];
951+ int scount;
952+ unsigned long release;
953+
954+ /* poll external decoder */
955+ int polling;
956+ struct work_struct work;
957+ struct timer_list timer;
958+ u32 gpio_addr;
959+ u32 last_gpio;
960+ u32 mask_keycode;
961+ u32 mask_keydown;
962+ u32 mask_keyup;
963+};
964+
965+static int ir_debug = 0;
966+module_param(ir_debug, int, 0644); /* debug level [IR] */
967+MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
968+
969+#define ir_dprintk(fmt, arg...) if (ir_debug) \
970+ printk(KERN_DEBUG "%s IR: " fmt , ir->core->name, ## arg)
971+
972+/* ---------------------------------------------------------------------- */
973+
974+static void cx88_ir_handle_key(struct cx88_IR *ir)
975+{
976+ struct cx88_core *core = ir->core;
977+ u32 gpio, data;
978+
979+ /* read gpio value */
980+ gpio = cx_read(ir->gpio_addr);
981+ if (ir->polling) {
982+ if (ir->last_gpio == gpio)
983+ return;
984+ ir->last_gpio = gpio;
985+ }
986+
987+ /* extract data */
988+ data = ir_extract_bits(gpio, ir->mask_keycode);
989+ ir_dprintk("irq gpio=0x%x code=%d | %s%s%s\n",
990+ gpio, data,
991+ ir->polling ? "poll" : "irq",
992+ (gpio & ir->mask_keydown) ? " down" : "",
993+ (gpio & ir->mask_keyup) ? " up" : "");
994+
995+ if (ir->mask_keydown) {
996+ /* bit set on keydown */
997+ if (gpio & ir->mask_keydown) {
998+ ir_input_keydown(&ir->input,&ir->ir,data,data);
999+ } else {
1000+ ir_input_nokey(&ir->input,&ir->ir);
1001+ }
1002+
1003+ } else if (ir->mask_keyup) {
1004+ /* bit cleared on keydown */
1005+ if (0 == (gpio & ir->mask_keyup)) {
1006+ ir_input_keydown(&ir->input,&ir->ir,data,data);
1007+ } else {
1008+ ir_input_nokey(&ir->input,&ir->ir);
1009+ }
1010+
1011+ } else {
1012+ /* can't disturgissh keydown/up :-/ */
1013+ ir_input_keydown(&ir->input,&ir->ir,data,data);
1014+ ir_input_nokey(&ir->input,&ir->ir);
1015+ }
1016+}
1017+
1018+static void ir_timer(unsigned long data)
1019+{
1020+ struct cx88_IR *ir = (struct cx88_IR*)data;
1021+
1022+ schedule_work(&ir->work);
1023+}
1024+
1025+static void cx88_ir_work(void *data)
1026+{
1027+ struct cx88_IR *ir = data;
1028+ unsigned long timeout;
1029+
1030+ cx88_ir_handle_key(ir);
1031+ timeout = jiffies + (ir->polling * HZ / 1000);
1032+ mod_timer(&ir->timer, timeout);
1033+}
1034+
1035+/* ---------------------------------------------------------------------- */
1036+
1037+int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
1038+{
1039+ struct cx88_IR *ir;
1040+ IR_KEYTAB_TYPE *ir_codes = NULL;
1041+ int ir_type = IR_TYPE_OTHER;
1042+
1043+ ir = kmalloc(sizeof(*ir),GFP_KERNEL);
1044+ if (NULL == ir)
1045+ return -ENOMEM;
1046+ memset(ir,0,sizeof(*ir));
1047+
1048+ /* detect & configure */
1049+ switch (core->board) {
1050+ case CX88_BOARD_DNTV_LIVE_DVB_T:
1051+ ir_codes = ir_codes_dntv_live_dvb_t;
1052+ ir->gpio_addr = MO_GP1_IO;
1053+ ir->mask_keycode = 0x1f;
1054+ ir->mask_keyup = 0x60;
1055+ ir->polling = 50; // ms
1056+ break;
1057+ case CX88_BOARD_HAUPPAUGE:
1058+ case CX88_BOARD_HAUPPAUGE_DVB_T1:
1059+ ir_codes = ir_codes_rc5_tv;
1060+ ir_type = IR_TYPE_RC5;
1061+ ir->sampling = 1;
1062+ break;
1063+ }
1064+ if (NULL == ir_codes) {
1065+ kfree(ir);
1066+ return -ENODEV;
1067+ }
1068+
1069+ /* init input device */
1070+ snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)",
1071+ cx88_boards[core->board].name);
1072+ snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
1073+ pci_name(pci));
1074+
1075+ ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes);
1076+ ir->input.name = ir->name;
1077+ ir->input.phys = ir->phys;
1078+ ir->input.id.bustype = BUS_PCI;
1079+ ir->input.id.version = 1;
1080+ if (pci->subsystem_vendor) {
1081+ ir->input.id.vendor = pci->subsystem_vendor;
1082+ ir->input.id.product = pci->subsystem_device;
1083+ } else {
1084+ ir->input.id.vendor = pci->vendor;
1085+ ir->input.id.product = pci->device;
1086+ }
1087+
1088+ /* record handles to ourself */
1089+ ir->core = core;
1090+ core->ir = ir;
1091+
1092+ if (ir->polling) {
1093+ INIT_WORK(&ir->work, cx88_ir_work, ir);
1094+ init_timer(&ir->timer);
1095+ ir->timer.function = ir_timer;
1096+ ir->timer.data = (unsigned long)ir;
1097+ schedule_work(&ir->work);
1098+ }
1099+ if (ir->sampling) {
1100+ core->pci_irqmask |= (1<<18); // IR_SMP_INT
1101+ cx_write(MO_DDS_IO, 0xa80a80); // 4 kHz sample rate
1102+ cx_write(MO_DDSCFG_IO, 0x5); // enable
1103+ }
1104+
1105+ /* all done */
1106+ input_register_device(&ir->input);
1107+ printk("%s: registered IR remote control\n", core->name);
1108+
1109+ return 0;
1110+}
1111+
1112+int cx88_ir_fini(struct cx88_core *core)
1113+{
1114+ struct cx88_IR *ir = core->ir;
1115+
1116+ /* skip detach on non attached boards */
1117+ if (NULL == ir)
1118+ return 0;
1119+
1120+ if (ir->polling) {
1121+ del_timer(&ir->timer);
1122+ flush_scheduled_work();
1123+ }
1124+
1125+ input_unregister_device(&ir->input);
1126+ kfree(ir);
1127+
1128+ /* done */
1129+ core->ir = NULL;
1130+ return 0;
1131+}
1132+
1133+/* ---------------------------------------------------------------------- */
1134+
1135+static int inline getbit(u32 *samples, int bit)
1136+{
1137+ return (samples[bit/32] & (1 << (31-(bit%32)))) ? 1 : 0;
1138+}
1139+
1140+static int dump_samples(u32 *samples, int count)
1141+{
1142+ int i, bit, start;
1143+
1144+ printk(KERN_DEBUG "ir samples @ 4kHz: ");
1145+ start = 0;
1146+ for (i = 0; i < count * 32; i++) {
1147+ bit = getbit(samples,i);
1148+ if (bit)
1149+ start = 1;
1150+ if (0 == start)
1151+ continue;
1152+ printk("%s", bit ? "#" : "_");
1153+ }
1154+ printk("\n");
1155+}
1156+
1157+static int ir_decode_biphase(u32 *samples, int count, int low, int high)
1158+{
1159+ int i,last,bit,len,flips;
1160+ u32 value;
1161+
1162+ /* find start bit (1) */
1163+ for (i = 0; i < 32; i++) {
1164+ bit = getbit(samples,i);
1165+ if (bit)
1166+ break;
1167+ }
1168+
1169+ /* go decoding */
1170+ len = 0;
1171+ flips = 0;
1172+ value = 1;
1173+ for (; i < count * 32; i++) {
1174+ if (len > high)
1175+ break;
1176+ if (flips > 1)
1177+ break;
1178+ last = bit;
1179+ bit = getbit(samples,i);
1180+ if (last == bit) {
1181+ len++;
1182+ continue;
1183+ }
1184+ if (len < low) {
1185+ len++;
1186+ flips++;
1187+ continue;
1188+ }
1189+ value <<= 1;
1190+ value |= bit;
1191+ flips = 0;
1192+ len = 1;
1193+ }
1194+ return value;
1195+}
1196+
1197+void cx88_ir_irq(struct cx88_core *core)
1198+{
1199+ struct cx88_IR *ir = core->ir;
1200+ u32 samples,rc5;
1201+ int i;
1202+
1203+ if (NULL == ir)
1204+ return;
1205+ if (!ir->sampling)
1206+ return;
1207+
1208+ samples = cx_read(MO_SAMPLE_IO);
1209+ if (0 != samples && 0xffffffff != samples) {
1210+ /* record sample data */
1211+ if (ir->scount < ARRAY_SIZE(ir->samples))
1212+ ir->samples[ir->scount++] = samples;
1213+ return;
1214+ }
1215+ if (!ir->scount) {
1216+ /* nothing to sample */
1217+ if (ir->ir.keypressed && time_after(jiffies,ir->release))
1218+ ir_input_nokey(&ir->input,&ir->ir);
1219+ return;
1220+ }
1221+
1222+ /* have a complete sample */
1223+ if (ir->scount < ARRAY_SIZE(ir->samples))
1224+ ir->samples[ir->scount++] = samples;
1225+ for (i = 0; i < ir->scount; i++)
1226+ ir->samples[i] = ~ir->samples[i];
1227+ if (ir_debug)
1228+ dump_samples(ir->samples,ir->scount);
1229+
1230+ /* decode it */
1231+ switch (core->board) {
1232+ case CX88_BOARD_HAUPPAUGE:
1233+ case CX88_BOARD_HAUPPAUGE_DVB_T1:
1234+ rc5 = ir_decode_biphase(ir->samples,ir->scount,5,7);
1235+ ir_dprintk("biphase decoded: %x\n",rc5);
1236+ if ((rc5 & 0xfffff000) != 0x3000)
1237+ break;
1238+ ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5);
1239+ ir->release = jiffies + msecs_to_jiffies(120);
1240+ break;
1241+ }
1242+
1243+ ir->scount = 0;
1244+ return;
1245+}
1246+
1247+/* ---------------------------------------------------------------------- */
1248+
1249+MODULE_AUTHOR("Gerd Knorr, Pavel Machek, Chris Pascoe");
1250+MODULE_DESCRIPTION("input driver for cx88 GPIO-based IR remote controls");
1251+MODULE_LICENSE("GPL");
1252+
1253+/*
1254+ * Local variables:
1255+ * c-basic-offset: 8
1256+ * End:
1257+ */
1258Index: linux-2004-12-16/drivers/media/video/cx88/cx88-vbi.c
1259===================================================================
1260--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88-vbi.c 2004-12-17 12:08:00.000000000 +0100
1261+++ linux-2004-12-16/drivers/media/video/cx88/cx88-vbi.c 2004-12-17 12:47:15.166284321 +0100
1262@@ -1,8 +1,9 @@
1263 /*
1264- * $Id: cx88-vbi.c,v 1.14 2004/11/07 13:17:15 kraxel Exp $
1265+ * $Id: cx88-vbi.c,v 1.16 2004/12/10 12:33:39 kraxel Exp $
1266 */
1267 #include <linux/kernel.h>
1268 #include <linux/module.h>
1269+#include <linux/moduleparam.h>
1270 #include <linux/init.h>
1271 #include <linux/slab.h>
1272
1273@@ -64,7 +65,7 @@ int cx8800_start_vbi_dma(struct cx8800_d
1274 q->count = 1;
1275
1276 /* enable irqs */
1277- cx_set(MO_PCI_INTMSK, 0x00fc01);
1278+ cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x01);
1279 cx_set(MO_VID_INTMSK, 0x0f0088);
1280
1281 /* enable capture */
1282Index: linux-2004-12-16/drivers/media/video/cx88/cx88.h
1283===================================================================
1284--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88.h 2004-12-17 12:09:48.000000000 +0100
1285+++ linux-2004-12-16/drivers/media/video/cx88/cx88.h 2004-12-17 12:47:15.169283757 +0100
1286@@ -1,5 +1,5 @@
1287 /*
1288- * $Id: cx88.h,v 1.40 2004/11/03 09:04:51 kraxel Exp $
1289+ * $Id: cx88.h,v 1.47 2004/12/14 15:33:30 kraxel Exp $
1290 *
1291 * v4l2 device driver for cx2388x based TV cards
1292 *
1293@@ -27,6 +27,7 @@
1294 #include <linux/kdev_t.h>
1295
1296 #include <media/tuner.h>
1297+#include <media/tveeprom.h>
1298 #include <media/audiochip.h>
1299 #include <media/video-buf.h>
1300 #include <media/video-buf-dvb.h>
1301@@ -156,6 +157,8 @@ extern struct sram_channel cx88_sram_cha
1302 #define CX88_BOARD_CONEXANT_DVB_T1 19
1303 #define CX88_BOARD_PROVIDEO_PV259 20
1304 #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS 21
1305+#define CX88_BOARD_PCHDTV_HD3000 22
1306+#define CX88_BOARD_DNTV_LIVE_DVB_T 23
1307
1308 enum cx88_itype {
1309 CX88_VMUX_COMPOSITE1 = 1,
1310@@ -238,6 +241,7 @@ struct cx88_core {
1311 u32 __iomem *lmmio;
1312 u8 __iomem *bmmio;
1313 u32 shadow[SHADOW_MAX];
1314+ int pci_irqmask;
1315
1316 /* i2c i/o */
1317 struct i2c_adapter i2c_adap;
1318@@ -252,7 +256,7 @@ struct cx88_core {
1319 unsigned int has_radio;
1320
1321 /* config info -- dvb */
1322- unsigned int pll_type;
1323+ struct dvb_pll_desc *pll_desc;
1324 unsigned int pll_addr;
1325 unsigned int demod_addr;
1326
1327@@ -262,6 +266,9 @@ struct cx88_core {
1328 u32 tvaudio;
1329 u32 input;
1330 u32 astat;
1331+
1332+ /* IR remote control state */
1333+ struct cx88_IR *ir;
1334 };
1335
1336 struct cx8800_dev;
1337@@ -371,6 +378,8 @@ struct cx8802_dev {
1338 struct list_head devlist;
1339 struct video_device *mpeg_dev;
1340 u32 mailbox;
1341+ int width;
1342+ int height;
1343
1344 /* for dvb only */
1345 struct videobuf_dvb dvb;
1346@@ -411,7 +420,7 @@ extern void cx88_print_irqbits(char *nam
1347 u32 bits, u32 mask);
1348 extern void cx88_print_ioctl(char *name, unsigned int cmd);
1349
1350-extern void cx88_irq(struct cx88_core *core, u32 status, u32 mask);
1351+extern int cx88_core_irq(struct cx88_core *core, u32 status);
1352 extern void cx88_wakeup(struct cx88_core *core,
1353 struct cx88_dmaqueue *q, u32 count);
1354 extern void cx88_shutdown(struct cx88_core *core);
1355@@ -508,6 +517,13 @@ void cx88_set_stereo(struct cx88_core *c
1356 int cx88_audio_thread(void *data);
1357
1358 /* ----------------------------------------------------------- */
1359+/* cx88-input.c */
1360+
1361+int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci);
1362+int cx88_ir_fini(struct cx88_core *core);
1363+void cx88_ir_irq(struct cx88_core *core);
1364+
1365+/* ----------------------------------------------------------- */
1366 /* cx88-mpeg.c */
1367
1368 int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf);
1369Index: linux-2004-12-16/drivers/media/video/cx88/Makefile
1370===================================================================
1371--- linux-2004-12-16.orig/drivers/media/video/cx88/Makefile 2004-12-17 12:07:11.000000000 +0100
1372+++ linux-2004-12-16/drivers/media/video/cx88/Makefile 2004-12-17 12:47:15.177282252 +0100
1373@@ -1,4 +1,5 @@
1374-cx88xx-objs := cx88-cards.o cx88-core.o cx88-i2c.o cx88-tvaudio.o
1375+cx88xx-objs := cx88-cards.o cx88-core.o cx88-i2c.o cx88-tvaudio.o \
1376+ cx88-input.o
1377 cx8800-objs := cx88-video.o cx88-vbi.o
1378 cx8802-objs := cx88-mpeg.o
1379
1380Index: linux-2004-12-16/drivers/media/video/cx88/cx88-i2c.c
1381===================================================================
1382--- linux-2004-12-16.orig/drivers/media/video/cx88/cx88-i2c.c 2004-12-17 12:07:37.000000000 +0100
1383+++ linux-2004-12-16/drivers/media/video/cx88/cx88-i2c.c 2004-12-17 12:47:15.184280935 +0100
1384@@ -1,5 +1,5 @@
1385 /*
1386- $Id: cx88-i2c.c,v 1.18 2004/10/13 10:39:00 kraxel Exp $
1387+ $Id: cx88-i2c.c,v 1.19 2004/12/10 12:33:39 kraxel Exp $
1388
1389 cx88-i2c.c -- all the i2c code is here
1390
1391@@ -25,6 +25,7 @@
1392 */
1393
1394 #include <linux/module.h>
1395+#include <linux/moduleparam.h>
1396 #include <linux/init.h>
1397
1398 #include <asm/io.h>
Note: See TracBrowser for help on using the repository browser.