2 * Zoran zr36057/zr36067 PCI controller driver, for the
3 * Pinnacle/Miro DC10/DC10+/DC30/DC30+, Iomega Buz, Linux
4 * Media Labs LML33/LML33R10.
6 * This part handles card-specific data and detection
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
10 * Currently maintained by:
11 * Ronald Bultje <rbultje@ronald.bitfreak.net>
12 * Laurent Pinchart <laurent.pinchart@skynet.be>
13 * Mailinglist <mjpeg-users@lists.sf.net>
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include <linux/delay.h>
32 #include <linux/types.h>
33 #include <linux/kernel.h>
34 #include <linux/module.h>
35 #include <linux/init.h>
36 #include <linux/vmalloc.h>
38 #include <linux/proc_fs.h>
39 #include <linux/i2c.h>
40 #include <linux/i2c-algo-bit.h>
41 #include <linux/videodev.h>
42 #include <media/v4l2-common.h>
43 #include <linux/spinlock.h>
44 #include <linux/sem.h>
45 #include <linux/kmod.h>
46 #include <linux/wait.h>
48 #include <linux/pci.h>
49 #include <linux/interrupt.h>
50 #include <linux/video_decoder.h>
51 #include <linux/video_encoder.h>
52 #include <linux/mutex.h>
56 #include "videocodec.h"
58 #include "zoran_card.h"
59 #include "zoran_device.h"
60 #include "zoran_procfs.h"
62 #define I2C_NAME(x) (x)->name
64 extern const struct zoran_format zoran_formats
[];
66 static int card
[BUZ_MAX
] = { -1, -1, -1, -1 };
67 module_param_array(card
, int, NULL
, 0);
68 MODULE_PARM_DESC(card
, "The type of card");
70 static int encoder
[BUZ_MAX
] = { -1, -1, -1, -1 };
71 module_param_array(encoder
, int, NULL
, 0);
72 MODULE_PARM_DESC(encoder
, "i2c TV encoder");
74 static int decoder
[BUZ_MAX
] = { -1, -1, -1, -1 };
75 module_param_array(decoder
, int, NULL
, 0);
76 MODULE_PARM_DESC(decoder
, "i2c TV decoder");
79 The video mem address of the video card.
80 The driver has a little database for some videocards
81 to determine it from there. If your video card is not in there
82 you have either to give it to the driver as a parameter
83 or set in in a VIDIOCSFBUF ioctl
86 static unsigned long vidmem
= 0; /* Video memory base address */
87 module_param(vidmem
, ulong
, 0);
90 Default input and video norm at startup of the driver.
93 static int default_input
= 0; /* 0=Composite, 1=S-Video */
94 module_param(default_input
, int, 0);
95 MODULE_PARM_DESC(default_input
,
96 "Default input (0=Composite, 1=S-Video, 2=Internal)");
98 static int default_mux
= 1; /* 6 Eyes input selection */
99 module_param(default_mux
, int, 0);
100 MODULE_PARM_DESC(default_mux
,
101 "Default 6 Eyes mux setting (Input selection)");
103 static int default_norm
= 0; /* 0=PAL, 1=NTSC 2=SECAM */
104 module_param(default_norm
, int, 0);
105 MODULE_PARM_DESC(default_norm
, "Default norm (0=PAL, 1=NTSC, 2=SECAM)");
107 static int video_nr
= -1; /* /dev/videoN, -1 for autodetect */
108 module_param(video_nr
, int, 0);
109 MODULE_PARM_DESC(video_nr
, "video device number");
112 Number and size of grab buffers for Video 4 Linux
113 The vast majority of applications should not need more than 2,
114 the very popular BTTV driver actually does ONLY have 2.
115 Time sensitive applications might need more, the maximum
116 is VIDEO_MAX_FRAME (defined in <linux/videodev.h>).
118 The size is set so that the maximum possible request
119 can be satisfied. Decrease it, if bigphys_area alloc'd
120 memory is low. If you don't have the bigphys_area patch,
121 set it to 128 KB. Will you allow only to grab small
122 images with V4L, but that's better than nothing.
124 v4l_bufsize has to be given in KB !
129 int v4l_bufsize
= 128; /* Everybody should be able to work with this setting */
130 module_param(v4l_nbufs
, int, 0);
131 MODULE_PARM_DESC(v4l_nbufs
, "Maximum number of V4L buffers to use");
132 module_param(v4l_bufsize
, int, 0);
133 MODULE_PARM_DESC(v4l_bufsize
, "Maximum size per V4L buffer (in kB)");
136 int jpg_bufsize
= 512; /* max size for 100% quality full-PAL frame */
137 module_param(jpg_nbufs
, int, 0);
138 MODULE_PARM_DESC(jpg_nbufs
, "Maximum number of JPG buffers to use");
139 module_param(jpg_bufsize
, int, 0);
140 MODULE_PARM_DESC(jpg_bufsize
, "Maximum size per JPG buffer (in kB)");
142 int pass_through
= 0; /* 1=Pass through TV signal when device is not used */
143 /* 0=Show color bar when device is not used (LML33: only if lml33dpath=1) */
144 module_param(pass_through
, int, 0);
145 MODULE_PARM_DESC(pass_through
,
146 "Pass TV signal through to TV-out when idling");
148 static int debug
= 1;
149 int *zr_debug
= &debug
;
150 module_param(debug
, int, 0);
151 MODULE_PARM_DESC(debug
, "Debug level (0-4)");
153 MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");
154 MODULE_AUTHOR("Serguei Miridonov");
155 MODULE_LICENSE("GPL");
157 static struct pci_device_id zr36067_pci_tbl
[] = {
158 {PCI_VENDOR_ID_ZORAN
, PCI_DEVICE_ID_ZORAN_36057
,
159 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0},
162 MODULE_DEVICE_TABLE(pci
, zr36067_pci_tbl
);
164 #define dprintk(num, format, args...) \
166 if (*zr_debug >= num) \
167 printk(format, ##args); \
170 int zoran_num
; /* number of Buzs in use */
171 struct zoran zoran
[BUZ_MAX
];
173 /* videocodec bus functions ZR36060 */
175 zr36060_read (struct videocodec
*codec
,
178 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
181 if (post_office_wait(zr
)
182 || post_office_write(zr
, 0, 1, reg
>> 8)
183 || post_office_write(zr
, 0, 2, reg
& 0xff)) {
187 data
= post_office_read(zr
, 0, 3) & 0xff;
192 zr36060_write (struct videocodec
*codec
,
196 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
198 if (post_office_wait(zr
)
199 || post_office_write(zr
, 0, 1, reg
>> 8)
200 || post_office_write(zr
, 0, 2, reg
& 0xff)) {
204 post_office_write(zr
, 0, 3, val
& 0xff);
207 /* videocodec bus functions ZR36050 */
209 zr36050_read (struct videocodec
*codec
,
212 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
215 if (post_office_wait(zr
)
216 || post_office_write(zr
, 1, 0, reg
>> 2)) { // reg. HIGHBYTES
220 data
= post_office_read(zr
, 0, reg
& 0x03) & 0xff; // reg. LOWBYTES + read
225 zr36050_write (struct videocodec
*codec
,
229 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
231 if (post_office_wait(zr
)
232 || post_office_write(zr
, 1, 0, reg
>> 2)) { // reg. HIGHBYTES
236 post_office_write(zr
, 0, reg
& 0x03, val
& 0xff); // reg. LOWBYTES + wr. data
239 /* videocodec bus functions ZR36016 */
241 zr36016_read (struct videocodec
*codec
,
244 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
247 if (post_office_wait(zr
)) {
251 data
= post_office_read(zr
, 2, reg
& 0x03) & 0xff; // read
255 /* hack for in zoran_device.c */
257 zr36016_write (struct videocodec
*codec
,
261 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
263 if (post_office_wait(zr
)) {
267 post_office_write(zr
, 2, reg
& 0x03, val
& 0x0ff); // wr. data
271 * Board specific information
275 dc10_init (struct zoran
*zr
)
277 dprintk(3, KERN_DEBUG
"%s: dc10_init()\n", ZR_DEVNAME(zr
));
279 /* Pixel clock selection */
282 /* Enable the video bus sync signals */
287 dc10plus_init (struct zoran
*zr
)
289 dprintk(3, KERN_DEBUG
"%s: dc10plus_init()\n", ZR_DEVNAME(zr
));
293 buz_init (struct zoran
*zr
)
295 dprintk(3, KERN_DEBUG
"%s: buz_init()\n", ZR_DEVNAME(zr
));
297 /* some stuff from Iomega */
298 pci_write_config_dword(zr
->pci_dev
, 0xfc, 0x90680f15);
299 pci_write_config_dword(zr
->pci_dev
, 0x0c, 0x00012020);
300 pci_write_config_dword(zr
->pci_dev
, 0xe8, 0xc0200000);
304 lml33_init (struct zoran
*zr
)
306 dprintk(3, KERN_DEBUG
"%s: lml33_init()\n", ZR_DEVNAME(zr
));
308 GPIO(zr
, 2, 1); // Set Composite input/output
312 avs6eyes_init (struct zoran
*zr
)
314 // AverMedia 6-Eyes original driver by Christer Weinigel
316 // Lifted straight from Christer's old driver and
317 // modified slightly by Martin Samuelsson.
319 int mux
= default_mux
; /* 1 = BT866, 7 = VID1 */
321 GPIO(zr
, 4, 1); /* Bt866 SLEEP on */
324 GPIO(zr
, 0, 1); /* ZR36060 /RESET on */
325 GPIO(zr
, 1, 0); /* ZR36060 /SLEEP on */
326 GPIO(zr
, 2, mux
& 1); /* MUX S0 */
327 GPIO(zr
, 3, 0); /* /FRAME on */
328 GPIO(zr
, 4, 0); /* Bt866 SLEEP off */
329 GPIO(zr
, 5, mux
& 2); /* MUX S1 */
330 GPIO(zr
, 6, 0); /* ? */
331 GPIO(zr
, 7, mux
& 4); /* MUX S2 */
336 i2cid_to_modulename (u16 i2c_id
)
341 case I2C_DRIVERID_SAA7110
:
344 case I2C_DRIVERID_SAA7111A
:
347 case I2C_DRIVERID_SAA7114
:
350 case I2C_DRIVERID_SAA7185B
:
353 case I2C_DRIVERID_ADV7170
:
356 case I2C_DRIVERID_ADV7175
:
359 case I2C_DRIVERID_BT819
:
362 case I2C_DRIVERID_BT856
:
365 case I2C_DRIVERID_VPX3220
:
368 /* case I2C_DRIVERID_VPX3224:
371 case I2C_DRIVERID_MSE3000:
382 codecid_to_modulename (u16 codecid
)
387 case CODEC_TYPE_ZR36060
:
390 case CODEC_TYPE_ZR36050
:
393 case CODEC_TYPE_ZR36016
:
404 // u16 Wt, Wa, HStart, HSyncStart, Ht, Ha, VStart;
407 static struct tvnorm f50sqpixel
= { 944, 768, 83, 880, 625, 576, 16 };
408 static struct tvnorm f60sqpixel
= { 780, 640, 51, 716, 525, 480, 12 };
409 static struct tvnorm f50ccir601
= { 864, 720, 75, 804, 625, 576, 18 };
410 static struct tvnorm f60ccir601
= { 858, 720, 57, 788, 525, 480, 16 };
412 static struct tvnorm f50ccir601_lml33
= { 864, 720, 75+34, 804, 625, 576, 18 };
413 static struct tvnorm f60ccir601_lml33
= { 858, 720, 57+34, 788, 525, 480, 16 };
415 /* The DC10 (57/16/50) uses VActive as HSync, so HStart must be 0 */
416 static struct tvnorm f50sqpixel_dc10
= { 944, 768, 0, 880, 625, 576, 0 };
417 static struct tvnorm f60sqpixel_dc10
= { 780, 640, 0, 716, 525, 480, 12 };
419 /* FIXME: I cannot swap U and V in saa7114, so i do one
420 * pixel left shift in zoran (75 -> 74)
421 * (Maxim Yevtyushkin <max@linuxmedialabs.com>) */
422 static struct tvnorm f50ccir601_lm33r10
= { 864, 720, 74+54, 804, 625, 576, 18 };
423 static struct tvnorm f60ccir601_lm33r10
= { 858, 720, 56+54, 788, 525, 480, 16 };
425 /* FIXME: The ks0127 seem incapable of swapping U and V, too, which is why I
426 * copy Maxim's left shift hack for the 6 Eyes.
428 * Christer's driver used the unshifted norms, though...
430 static struct tvnorm f50ccir601_avs6eyes
= { 864, 720, 74, 804, 625, 576, 18 };
431 static struct tvnorm f60ccir601_avs6eyes
= { 858, 720, 56, 788, 525, 480, 16 };
433 static struct card_info zoran_cards
[NUM_CARDS
] __devinitdata
= {
437 .i2c_decoder
= I2C_DRIVERID_VPX3220
,
438 /*.i2c_encoder = I2C_DRIVERID_MSE3000,*/
439 .video_codec
= CODEC_TYPE_ZR36050
,
440 .video_vfe
= CODEC_TYPE_ZR36016
,
446 { 0, "Internal/comp" }
455 .vsync_int
= ZR36057_ISR_GIRQ1
,
456 .gpio
= { 2, 1, -1, 3, 7, 0, 4, 5 },
457 .gpio_pol
= { 0, 0, 0, 1, 0, 0, 0, 0 },
459 .vfe_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
460 .gws_not_connected
= 0,
466 .i2c_decoder
= I2C_DRIVERID_SAA7110
,
467 .i2c_encoder
= I2C_DRIVERID_ADV7175
,
468 .video_codec
= CODEC_TYPE_ZR36060
,
474 { 5, "Internal/comp" }
481 .jpeg_int
= ZR36057_ISR_GIRQ0
,
482 .vsync_int
= ZR36057_ISR_GIRQ1
,
483 .gpio
= { 3, 0, 6, 1, 2, -1, 4, 5 },
484 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
486 .vfe_pol
= { 1, 1, 1, 1, 0, 0, 0, 0 },
487 .gws_not_connected
= 0,
489 .init
= &dc10plus_init
,
493 .vendor_id
= PCI_VENDOR_ID_MIRO
,
494 .device_id
= PCI_DEVICE_ID_MIRO_DC10PLUS
,
495 .i2c_decoder
= I2C_DRIVERID_SAA7110
,
496 .i2c_encoder
= I2C_DRIVERID_ADV7175
,
497 .video_codec
= CODEC_TYPE_ZR36060
,
503 { 5, "Internal/comp" }
511 .jpeg_int
= ZR36057_ISR_GIRQ0
,
512 .vsync_int
= ZR36057_ISR_GIRQ1
,
513 .gpio
= { 3, 0, 6, 1, 2, -1, 4, 5 },
514 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
516 .vfe_pol
= { 1, 1, 1, 1, 0, 0, 0, 0 },
517 .gws_not_connected
= 0,
519 .init
= &dc10plus_init
,
523 .i2c_decoder
= I2C_DRIVERID_VPX3220
,
524 .i2c_encoder
= I2C_DRIVERID_ADV7175
,
525 .video_codec
= CODEC_TYPE_ZR36050
,
526 .video_vfe
= CODEC_TYPE_ZR36016
,
532 { 0, "Internal/comp" }
541 .vsync_int
= ZR36057_ISR_GIRQ1
,
542 .gpio
= { 2, 1, -1, 3, 7, 0, 4, 5 },
543 .gpio_pol
= { 0, 0, 0, 1, 0, 0, 0, 0 },
545 .vfe_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
546 .gws_not_connected
= 0,
552 .vendor_id
= PCI_VENDOR_ID_MIRO
,
553 .device_id
= PCI_DEVICE_ID_MIRO_DC30PLUS
,
554 .i2c_decoder
= I2C_DRIVERID_VPX3220
,
555 .i2c_encoder
= I2C_DRIVERID_ADV7175
,
556 .video_codec
= CODEC_TYPE_ZR36050
,
557 .video_vfe
= CODEC_TYPE_ZR36016
,
563 { 0, "Internal/comp" }
572 .vsync_int
= ZR36057_ISR_GIRQ1
,
573 .gpio
= { 2, 1, -1, 3, 7, 0, 4, 5 },
574 .gpio_pol
= { 0, 0, 0, 1, 0, 0, 0, 0 },
576 .vfe_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
577 .gws_not_connected
= 0,
583 .i2c_decoder
= I2C_DRIVERID_BT819
,
584 .i2c_encoder
= I2C_DRIVERID_BT856
,
585 .video_codec
= CODEC_TYPE_ZR36060
,
598 .jpeg_int
= ZR36057_ISR_GIRQ1
,
599 .vsync_int
= ZR36057_ISR_GIRQ0
,
600 .gpio
= { 1, -1, 3, 5, 7, -1, -1, -1 },
601 .gpio_pol
= { 0, 0, 0, 0, 1, 0, 0, 0 },
603 .vfe_pol
= { 1, 1, 0, 0, 0, 1, 0, 0 },
604 .gws_not_connected
= 1,
610 .vendor_id
= PCI_VENDOR_ID_ELECTRONICDESIGNGMBH
,
611 .device_id
= PCI_DEVICE_ID_LML_33R10
,
612 .i2c_decoder
= I2C_DRIVERID_SAA7114
,
613 .i2c_encoder
= I2C_DRIVERID_ADV7170
,
614 .video_codec
= CODEC_TYPE_ZR36060
,
627 .jpeg_int
= ZR36057_ISR_GIRQ1
,
628 .vsync_int
= ZR36057_ISR_GIRQ0
,
629 .gpio
= { 1, -1, 3, 5, 7, -1, -1, -1 },
630 .gpio_pol
= { 0, 0, 0, 0, 1, 0, 0, 0 },
632 .vfe_pol
= { 1, 1, 0, 0, 0, 1, 0, 0 },
633 .gws_not_connected
= 1,
639 .vendor_id
= PCI_VENDOR_ID_IOMEGA
,
640 .device_id
= PCI_DEVICE_ID_IOMEGA_BUZ
,
641 .i2c_decoder
= I2C_DRIVERID_SAA7111A
,
642 .i2c_encoder
= I2C_DRIVERID_SAA7185B
,
643 .video_codec
= CODEC_TYPE_ZR36060
,
656 .jpeg_int
= ZR36057_ISR_GIRQ1
,
657 .vsync_int
= ZR36057_ISR_GIRQ0
,
658 .gpio
= { 1, -1, 3, -1, -1, -1, -1, -1 },
659 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
661 .vfe_pol
= { 1, 1, 0, 0, 0, 1, 0, 0 },
662 .gws_not_connected
= 1,
668 /* AverMedia chose not to brand the 6-Eyes. Thus it
669 can't be autodetected, and requires card=x. */
672 .i2c_decoder
= I2C_DRIVERID_KS0127
,
673 .i2c_encoder
= I2C_DRIVERID_BT866
,
674 .video_codec
= CODEC_TYPE_ZR36060
,
678 { 0, "Composite 1" },
679 { 1, "Composite 2" },
680 { 2, "Composite 3" },
681 { 4, "Composite 4" },
682 { 5, "Composite 5" },
683 { 6, "Composite 6" },
691 &f50ccir601_avs6eyes
,
692 &f60ccir601_avs6eyes
,
695 .jpeg_int
= ZR36057_ISR_GIRQ1
,
696 .vsync_int
= ZR36057_ISR_GIRQ0
,
697 .gpio
= { 1, 0, 3, -1, -1, -1, -1, -1 },// Validity unknown /Sam
698 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 }, // Validity unknown /Sam
699 .gpcs
= { 3, 1 }, // Validity unknown /Sam
700 .vfe_pol
= { 1, 0, 0, 0, 0, 1, 0, 0 }, // Validity unknown /Sam
701 .gws_not_connected
= 1,
703 .init
= &avs6eyes_init
,
711 /* software I2C functions */
713 zoran_i2c_getsda (void *data
)
715 struct zoran
*zr
= (struct zoran
*) data
;
717 return (btread(ZR36057_I2CBR
) >> 1) & 1;
721 zoran_i2c_getscl (void *data
)
723 struct zoran
*zr
= (struct zoran
*) data
;
725 return btread(ZR36057_I2CBR
) & 1;
729 zoran_i2c_setsda (void *data
,
732 struct zoran
*zr
= (struct zoran
*) data
;
738 btwrite(zr
->i2cbr
, ZR36057_I2CBR
);
742 zoran_i2c_setscl (void *data
,
745 struct zoran
*zr
= (struct zoran
*) data
;
751 btwrite(zr
->i2cbr
, ZR36057_I2CBR
);
755 zoran_i2c_client_register (struct i2c_client
*client
)
757 struct zoran
*zr
= (struct zoran
*) i2c_get_adapdata(client
->adapter
);
761 KERN_DEBUG
"%s: i2c_client_register() - driver id = %d\n",
762 ZR_DEVNAME(zr
), client
->driver
->id
);
764 mutex_lock(&zr
->resource_lock
);
767 /* we're already busy, so we keep a reference to
768 * them... Could do a lot of stuff here, but this
769 * is easiest. (Did I ever mention I'm a lazy ass?)
772 goto clientreg_unlock_and_return
;
775 if (client
->driver
->id
== zr
->card
.i2c_decoder
)
776 zr
->decoder
= client
;
777 else if (client
->driver
->id
== zr
->card
.i2c_encoder
)
778 zr
->encoder
= client
;
781 goto clientreg_unlock_and_return
;
784 clientreg_unlock_and_return
:
785 mutex_unlock(&zr
->resource_lock
);
791 zoran_i2c_client_unregister (struct i2c_client
*client
)
793 struct zoran
*zr
= (struct zoran
*) i2c_get_adapdata(client
->adapter
);
796 dprintk(2, KERN_DEBUG
"%s: i2c_client_unregister()\n", ZR_DEVNAME(zr
));
798 mutex_lock(&zr
->resource_lock
);
802 goto clientunreg_unlock_and_return
;
805 /* try to locate it */
806 if (client
== zr
->encoder
) {
808 } else if (client
== zr
->decoder
) {
810 snprintf(ZR_DEVNAME(zr
), sizeof(ZR_DEVNAME(zr
)), "MJPEG[%d]", zr
->id
);
812 clientunreg_unlock_and_return
:
813 mutex_unlock(&zr
->resource_lock
);
817 static struct i2c_algo_bit_data zoran_i2c_bit_data_template
= {
818 .setsda
= zoran_i2c_setsda
,
819 .setscl
= zoran_i2c_setscl
,
820 .getsda
= zoran_i2c_getsda
,
821 .getscl
= zoran_i2c_getscl
,
826 static struct i2c_adapter zoran_i2c_adapter_template
= {
828 .id
= I2C_HW_B_ZR36067
,
830 .client_register
= zoran_i2c_client_register
,
831 .client_unregister
= zoran_i2c_client_unregister
,
835 zoran_register_i2c (struct zoran
*zr
)
837 memcpy(&zr
->i2c_algo
, &zoran_i2c_bit_data_template
,
838 sizeof(struct i2c_algo_bit_data
));
839 zr
->i2c_algo
.data
= zr
;
840 memcpy(&zr
->i2c_adapter
, &zoran_i2c_adapter_template
,
841 sizeof(struct i2c_adapter
));
842 strncpy(I2C_NAME(&zr
->i2c_adapter
), ZR_DEVNAME(zr
),
843 sizeof(I2C_NAME(&zr
->i2c_adapter
)) - 1);
844 i2c_set_adapdata(&zr
->i2c_adapter
, zr
);
845 zr
->i2c_adapter
.algo_data
= &zr
->i2c_algo
;
846 zr
->i2c_adapter
.dev
.parent
= &zr
->pci_dev
->dev
;
847 return i2c_bit_add_bus(&zr
->i2c_adapter
);
851 zoran_unregister_i2c (struct zoran
*zr
)
853 i2c_del_adapter(&zr
->i2c_adapter
);
856 /* Check a zoran_params struct for correctness, insert default params */
859 zoran_check_jpg_settings (struct zoran
*zr
,
860 struct zoran_jpg_settings
*settings
)
862 int err
= 0, err0
= 0;
866 "%s: check_jpg_settings() - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
867 ZR_DEVNAME(zr
), settings
->decimation
, settings
->HorDcm
,
868 settings
->VerDcm
, settings
->TmpDcm
);
871 "%s: check_jpg_settings() - x: %d, y: %d, w: %d, y: %d\n",
872 ZR_DEVNAME(zr
), settings
->img_x
, settings
->img_y
,
873 settings
->img_width
, settings
->img_height
);
874 /* Check decimation, set default values for decimation = 1, 2, 4 */
875 switch (settings
->decimation
) {
878 settings
->HorDcm
= 1;
879 settings
->VerDcm
= 1;
880 settings
->TmpDcm
= 1;
881 settings
->field_per_buff
= 2;
884 settings
->img_width
= BUZ_MAX_WIDTH
;
885 settings
->img_height
= BUZ_MAX_HEIGHT
/ 2;
889 settings
->HorDcm
= 2;
890 settings
->VerDcm
= 1;
891 settings
->TmpDcm
= 2;
892 settings
->field_per_buff
= 1;
893 settings
->img_x
= (BUZ_MAX_WIDTH
== 720) ? 8 : 0;
895 settings
->img_width
=
896 (BUZ_MAX_WIDTH
== 720) ? 704 : BUZ_MAX_WIDTH
;
897 settings
->img_height
= BUZ_MAX_HEIGHT
/ 2;
901 if (zr
->card
.type
== DC10_new
) {
904 "%s: check_jpg_settings() - HDec by 4 is not supported on the DC10\n",
910 settings
->HorDcm
= 4;
911 settings
->VerDcm
= 2;
912 settings
->TmpDcm
= 2;
913 settings
->field_per_buff
= 1;
914 settings
->img_x
= (BUZ_MAX_WIDTH
== 720) ? 8 : 0;
916 settings
->img_width
=
917 (BUZ_MAX_WIDTH
== 720) ? 704 : BUZ_MAX_WIDTH
;
918 settings
->img_height
= BUZ_MAX_HEIGHT
/ 2;
922 /* We have to check the data the user has set */
924 if (settings
->HorDcm
!= 1 && settings
->HorDcm
!= 2 &&
925 (zr
->card
.type
== DC10_new
|| settings
->HorDcm
!= 4))
927 if (settings
->VerDcm
!= 1 && settings
->VerDcm
!= 2)
929 if (settings
->TmpDcm
!= 1 && settings
->TmpDcm
!= 2)
931 if (settings
->field_per_buff
!= 1 &&
932 settings
->field_per_buff
!= 2)
934 if (settings
->img_x
< 0)
936 if (settings
->img_y
< 0)
938 if (settings
->img_width
< 0)
940 if (settings
->img_height
< 0)
942 if (settings
->img_x
+ settings
->img_width
> BUZ_MAX_WIDTH
)
944 if (settings
->img_y
+ settings
->img_height
>
947 if (settings
->HorDcm
&& settings
->VerDcm
) {
948 if (settings
->img_width
%
949 (16 * settings
->HorDcm
) != 0)
951 if (settings
->img_height
%
952 (8 * settings
->VerDcm
) != 0)
959 "%s: check_jpg_settings() - error in params for decimation = 0\n",
967 "%s: check_jpg_settings() - decimation = %d, must be 0, 1, 2 or 4\n",
968 ZR_DEVNAME(zr
), settings
->decimation
);
973 if (settings
->jpg_comp
.quality
> 100)
974 settings
->jpg_comp
.quality
= 100;
975 if (settings
->jpg_comp
.quality
< 5)
976 settings
->jpg_comp
.quality
= 5;
977 if (settings
->jpg_comp
.APPn
< 0)
978 settings
->jpg_comp
.APPn
= 0;
979 if (settings
->jpg_comp
.APPn
> 15)
980 settings
->jpg_comp
.APPn
= 15;
981 if (settings
->jpg_comp
.APP_len
< 0)
982 settings
->jpg_comp
.APP_len
= 0;
983 if (settings
->jpg_comp
.APP_len
> 60)
984 settings
->jpg_comp
.APP_len
= 60;
985 if (settings
->jpg_comp
.COM_len
< 0)
986 settings
->jpg_comp
.COM_len
= 0;
987 if (settings
->jpg_comp
.COM_len
> 60)
988 settings
->jpg_comp
.COM_len
= 60;
995 zoran_open_init_params (struct zoran
*zr
)
999 /* User must explicitly set a window */
1000 zr
->overlay_settings
.is_set
= 0;
1001 zr
->overlay_mask
= NULL
;
1002 zr
->overlay_active
= ZORAN_FREE
;
1004 zr
->v4l_memgrab_active
= 0;
1005 zr
->v4l_overlay_active
= 0;
1006 zr
->v4l_grab_frame
= NO_GRAB_ACTIVE
;
1007 zr
->v4l_grab_seq
= 0;
1008 zr
->v4l_settings
.width
= 192;
1009 zr
->v4l_settings
.height
= 144;
1010 zr
->v4l_settings
.format
= &zoran_formats
[4]; /* YUY2 - YUV-4:2:2 packed */
1011 zr
->v4l_settings
.bytesperline
=
1012 zr
->v4l_settings
.width
*
1013 ((zr
->v4l_settings
.format
->depth
+ 7) / 8);
1015 /* DMA ring stuff for V4L */
1016 zr
->v4l_pend_tail
= 0;
1017 zr
->v4l_pend_head
= 0;
1018 zr
->v4l_sync_tail
= 0;
1019 zr
->v4l_buffers
.active
= ZORAN_FREE
;
1020 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
1021 zr
->v4l_buffers
.buffer
[i
].state
= BUZ_STATE_USER
; /* nothing going on */
1023 zr
->v4l_buffers
.allocated
= 0;
1025 for (i
= 0; i
< BUZ_MAX_FRAME
; i
++) {
1026 zr
->jpg_buffers
.buffer
[i
].state
= BUZ_STATE_USER
; /* nothing going on */
1028 zr
->jpg_buffers
.active
= ZORAN_FREE
;
1029 zr
->jpg_buffers
.allocated
= 0;
1030 /* Set necessary params and call zoran_check_jpg_settings to set the defaults */
1031 zr
->jpg_settings
.decimation
= 1;
1032 zr
->jpg_settings
.jpg_comp
.quality
= 50; /* default compression factor 8 */
1033 if (zr
->card
.type
!= BUZ
)
1034 zr
->jpg_settings
.odd_even
= 1;
1036 zr
->jpg_settings
.odd_even
= 0;
1037 zr
->jpg_settings
.jpg_comp
.APPn
= 0;
1038 zr
->jpg_settings
.jpg_comp
.APP_len
= 0; /* No APPn marker */
1039 memset(zr
->jpg_settings
.jpg_comp
.APP_data
, 0,
1040 sizeof(zr
->jpg_settings
.jpg_comp
.APP_data
));
1041 zr
->jpg_settings
.jpg_comp
.COM_len
= 0; /* No COM marker */
1042 memset(zr
->jpg_settings
.jpg_comp
.COM_data
, 0,
1043 sizeof(zr
->jpg_settings
.jpg_comp
.COM_data
));
1044 zr
->jpg_settings
.jpg_comp
.jpeg_markers
=
1045 JPEG_MARKER_DHT
| JPEG_MARKER_DQT
;
1046 i
= zoran_check_jpg_settings(zr
, &zr
->jpg_settings
);
1050 "%s: zoran_open_init_params() internal error\n",
1053 clear_interrupt_counters(zr
);
1057 static void __devinit
1058 test_interrupts (struct zoran
*zr
)
1063 clear_interrupt_counters(zr
);
1066 icr
= btread(ZR36057_ICR
);
1067 btwrite(0x78000000 | ZR36057_ICR_IntPinEn
, ZR36057_ICR
);
1068 prepare_to_wait(&zr
->test_q
, &wait
, TASK_INTERRUPTIBLE
);
1069 timeout
= schedule_timeout(HZ
);
1070 finish_wait(&zr
->test_q
, &wait
);
1071 btwrite(0, ZR36057_ICR
);
1072 btwrite(0x78000000, ZR36057_ISR
);
1074 dprintk(5, KERN_INFO
"%s: Testing interrupts...\n", ZR_DEVNAME(zr
));
1076 dprintk(1, ": time spent: %d\n", 1 * HZ
- timeout
);
1079 print_interrupts(zr
);
1080 btwrite(icr
, ZR36057_ICR
);
1083 static int __devinit
1084 zr36057_init (struct zoran
*zr
)
1092 "%s: zr36057_init() - initializing card[%d], zr=%p\n",
1093 ZR_DEVNAME(zr
), zr
->id
, zr
);
1095 /* default setup of all parameters which will persist between opens */
1098 init_waitqueue_head(&zr
->v4l_capq
);
1099 init_waitqueue_head(&zr
->jpg_capq
);
1100 init_waitqueue_head(&zr
->test_q
);
1101 zr
->jpg_buffers
.allocated
= 0;
1102 zr
->v4l_buffers
.allocated
= 0;
1104 zr
->buffer
.base
= (void *) vidmem
;
1105 zr
->buffer
.width
= 0;
1106 zr
->buffer
.height
= 0;
1107 zr
->buffer
.depth
= 0;
1108 zr
->buffer
.bytesperline
= 0;
1110 /* Avoid nonsense settings from user for default input/norm */
1111 if (default_norm
< VIDEO_MODE_PAL
&&
1112 default_norm
> VIDEO_MODE_SECAM
)
1113 default_norm
= VIDEO_MODE_PAL
;
1114 zr
->norm
= default_norm
;
1115 if (!(zr
->timing
= zr
->card
.tvn
[zr
->norm
])) {
1118 "%s: zr36057_init() - default TV standard not supported by hardware. PAL will be used.\n",
1120 zr
->norm
= VIDEO_MODE_PAL
;
1121 zr
->timing
= zr
->card
.tvn
[zr
->norm
];
1124 zr
->input
= default_input
= (default_input
? 1 : 0);
1126 /* Should the following be reset at every open ? */
1128 zr
->contrast
= 32768;
1129 zr
->saturation
= 32768;
1130 zr
->brightness
= 32768;
1132 /* default setup (will be repeated at every open) */
1133 zoran_open_init_params(zr
);
1135 /* allocate memory *before* doing anything to the hardware
1136 * in case allocation fails */
1137 zr
->stat_com
= kzalloc(BUZ_NUM_STAT_COM
* 4, GFP_KERNEL
);
1138 zr
->video_dev
= kmalloc(sizeof(struct video_device
), GFP_KERNEL
);
1139 if (!zr
->stat_com
|| !zr
->video_dev
) {
1142 "%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
1147 for (j
= 0; j
< BUZ_NUM_STAT_COM
; j
++) {
1148 zr
->stat_com
[j
] = 1; /* mark as unavailable to zr36057 */
1152 * Now add the template and register the device unit.
1154 memcpy(zr
->video_dev
, &zoran_template
, sizeof(zoran_template
));
1155 strcpy(zr
->video_dev
->name
, ZR_DEVNAME(zr
));
1156 err
= video_register_device(zr
->video_dev
, VFL_TYPE_GRABBER
, video_nr
);
1158 goto exit_unregister
;
1160 zoran_init_hardware(zr
);
1162 detect_guest_activity(zr
);
1163 test_interrupts(zr
);
1164 if (!pass_through
) {
1165 decoder_command(zr
, DECODER_ENABLE_OUTPUT
, &zero
);
1166 encoder_command(zr
, ENCODER_SET_INPUT
, &two
);
1169 zr
->zoran_proc
= NULL
;
1170 zr
->initialized
= 1;
1174 zoran_unregister_i2c(zr
);
1176 kfree(zr
->stat_com
);
1177 kfree(zr
->video_dev
);
1182 zoran_release (struct zoran
*zr
)
1184 if (!zr
->initialized
)
1186 /* unregister videocodec bus */
1188 struct videocodec_master
*master
= zr
->codec
->master_data
;
1190 videocodec_detach(zr
->codec
);
1194 struct videocodec_master
*master
= zr
->vfe
->master_data
;
1196 videocodec_detach(zr
->vfe
);
1200 /* unregister i2c bus */
1201 zoran_unregister_i2c(zr
);
1202 /* disable PCI bus-mastering */
1203 zoran_set_pci_master(zr
, 0);
1204 /* put chip into reset */
1205 btwrite(0, ZR36057_SPGPPCR
);
1206 free_irq(zr
->pci_dev
->irq
, zr
);
1207 /* unmap and free memory */
1208 kfree(zr
->stat_com
);
1209 zoran_proc_cleanup(zr
);
1210 iounmap(zr
->zr36057_mem
);
1211 pci_disable_device(zr
->pci_dev
);
1212 video_unregister_device(zr
->video_dev
);
1216 zoran_vdev_release (struct video_device
*vdev
)
1221 static struct videocodec_master
* __devinit
1222 zoran_setup_videocodec (struct zoran
*zr
,
1225 struct videocodec_master
*m
= NULL
;
1227 m
= kmalloc(sizeof(struct videocodec_master
), GFP_KERNEL
);
1231 "%s: zoran_setup_videocodec() - no memory\n",
1236 m
->magic
= 0L; /* magic not used */
1237 m
->type
= VID_HARDWARE_ZR36067
;
1238 m
->flags
= CODEC_FLAG_ENCODER
| CODEC_FLAG_DECODER
;
1239 strncpy(m
->name
, ZR_DEVNAME(zr
), sizeof(m
->name
));
1244 case CODEC_TYPE_ZR36060
:
1245 m
->readreg
= zr36060_read
;
1246 m
->writereg
= zr36060_write
;
1247 m
->flags
|= CODEC_FLAG_JPEG
| CODEC_FLAG_VFE
;
1249 case CODEC_TYPE_ZR36050
:
1250 m
->readreg
= zr36050_read
;
1251 m
->writereg
= zr36050_write
;
1252 m
->flags
|= CODEC_FLAG_JPEG
;
1254 case CODEC_TYPE_ZR36016
:
1255 m
->readreg
= zr36016_read
;
1256 m
->writereg
= zr36016_write
;
1257 m
->flags
|= CODEC_FLAG_VFE
;
1265 * Scan for a Buz card (actually for the PCI contoler ZR36057),
1266 * request the irq and map the io memory
1268 static int __devinit
1271 unsigned char latency
, need_latency
;
1273 struct pci_dev
*dev
= NULL
;
1275 struct videocodec_master
*master_vfe
= NULL
;
1276 struct videocodec_master
*master_codec
= NULL
;
1278 char *i2c_enc_name
, *i2c_dec_name
, *codec_name
, *vfe_name
;
1281 while (zoran_num
< BUZ_MAX
&&
1282 (dev
= pci_get_device(PCI_VENDOR_ID_ZORAN
, PCI_DEVICE_ID_ZORAN_36057
, dev
)) != NULL
) {
1283 card_num
= card
[zoran_num
];
1284 zr
= &zoran
[zoran_num
];
1285 memset(zr
, 0, sizeof(struct zoran
)); // Just in case if previous cycle failed
1287 //zr->zr36057_mem = NULL;
1289 snprintf(ZR_DEVNAME(zr
), sizeof(ZR_DEVNAME(zr
)), "MJPEG[%u]", zr
->id
);
1290 spin_lock_init(&zr
->spinlock
);
1291 mutex_init(&zr
->resource_lock
);
1292 if (pci_enable_device(dev
))
1294 zr
->zr36057_adr
= pci_resource_start(zr
->pci_dev
, 0);
1295 pci_read_config_byte(zr
->pci_dev
, PCI_CLASS_REVISION
,
1297 if (zr
->revision
< 2) {
1300 "%s: Zoran ZR36057 (rev %d) irq: %d, memory: 0x%08x.\n",
1301 ZR_DEVNAME(zr
), zr
->revision
, zr
->pci_dev
->irq
,
1304 if (card_num
== -1) {
1307 "%s: find_zr36057() - no card specified, please use the card=X insmod option\n",
1313 unsigned short ss_vendor
, ss_device
;
1315 ss_vendor
= zr
->pci_dev
->subsystem_vendor
;
1316 ss_device
= zr
->pci_dev
->subsystem_device
;
1319 "%s: Zoran ZR36067 (rev %d) irq: %d, memory: 0x%08x\n",
1320 ZR_DEVNAME(zr
), zr
->revision
, zr
->pci_dev
->irq
,
1324 "%s: subsystem vendor=0x%04x id=0x%04x\n",
1325 ZR_DEVNAME(zr
), ss_vendor
, ss_device
);
1326 if (card_num
== -1) {
1329 "%s: find_zr36057() - trying to autodetect card type\n",
1331 for (i
=0;i
<NUM_CARDS
;i
++) {
1332 if (ss_vendor
== zoran_cards
[i
].vendor_id
&&
1333 ss_device
== zoran_cards
[i
].device_id
) {
1336 "%s: find_zr36057() - card %s detected\n",
1338 zoran_cards
[i
].name
);
1343 if (i
== NUM_CARDS
) {
1346 "%s: find_zr36057() - unknown card\n",
1353 if (card_num
< 0 || card_num
>= NUM_CARDS
) {
1356 "%s: find_zr36057() - invalid cardnum %d\n",
1357 ZR_DEVNAME(zr
), card_num
);
1361 /* even though we make this a non pointer and thus
1362 * theoretically allow for making changes to this struct
1363 * on a per-individual card basis at runtime, this is
1364 * strongly discouraged. This structure is intended to
1365 * keep general card information, no settings or anything */
1366 zr
->card
= zoran_cards
[card_num
];
1367 snprintf(ZR_DEVNAME(zr
), sizeof(ZR_DEVNAME(zr
)),
1368 "%s[%u]", zr
->card
.name
, zr
->id
);
1370 zr
->zr36057_mem
= ioremap_nocache(zr
->zr36057_adr
, 0x1000);
1371 if (!zr
->zr36057_mem
) {
1374 "%s: find_zr36057() - ioremap failed\n",
1379 result
= request_irq(zr
->pci_dev
->irq
,
1381 IRQF_SHARED
| IRQF_DISABLED
,
1385 if (result
== -EINVAL
) {
1388 "%s: find_zr36057() - bad irq number or handler\n",
1390 } else if (result
== -EBUSY
) {
1393 "%s: find_zr36057() - IRQ %d busy, change your PnP config in BIOS\n",
1394 ZR_DEVNAME(zr
), zr
->pci_dev
->irq
);
1398 "%s: find_zr36057() - can't assign irq, error code %d\n",
1399 ZR_DEVNAME(zr
), result
);
1404 /* set PCI latency timer */
1405 pci_read_config_byte(zr
->pci_dev
, PCI_LATENCY_TIMER
,
1407 need_latency
= zr
->revision
> 1 ? 32 : 48;
1408 if (latency
!= need_latency
) {
1411 "%s: Changing PCI latency from %d to %d.\n",
1412 ZR_DEVNAME(zr
), latency
, need_latency
);
1413 pci_write_config_byte(zr
->pci_dev
,
1418 zr36057_restart(zr
);
1420 dprintk(2, KERN_INFO
"%s: Initializing i2c bus...\n",
1424 if (decoder
[zr
->id
] != -1) {
1425 i2c_dec_name
= i2cid_to_modulename(decoder
[zr
->id
]);
1426 zr
->card
.i2c_decoder
= decoder
[zr
->id
];
1427 } else if (zr
->card
.i2c_decoder
!= 0) {
1429 i2cid_to_modulename(zr
->card
.i2c_decoder
);
1431 i2c_dec_name
= NULL
;
1435 if ((result
= request_module(i2c_dec_name
)) < 0) {
1438 "%s: failed to load module %s: %d\n",
1439 ZR_DEVNAME(zr
), i2c_dec_name
, result
);
1444 if (encoder
[zr
->id
] != -1) {
1445 i2c_enc_name
= i2cid_to_modulename(encoder
[zr
->id
]);
1446 zr
->card
.i2c_encoder
= encoder
[zr
->id
];
1447 } else if (zr
->card
.i2c_encoder
!= 0) {
1449 i2cid_to_modulename(zr
->card
.i2c_encoder
);
1451 i2c_enc_name
= NULL
;
1455 if ((result
= request_module(i2c_enc_name
)) < 0) {
1458 "%s: failed to load module %s: %d\n",
1459 ZR_DEVNAME(zr
), i2c_enc_name
, result
);
1463 if (zoran_register_i2c(zr
) < 0) {
1466 "%s: find_zr36057() - can't initialize i2c bus\n",
1472 KERN_INFO
"%s: Initializing videocodec bus...\n",
1475 if (zr
->card
.video_codec
!= 0 &&
1477 codecid_to_modulename(zr
->card
.video_codec
)) != NULL
) {
1478 if ((result
= request_module(codec_name
)) < 0) {
1481 "%s: failed to load modules %s: %d\n",
1482 ZR_DEVNAME(zr
), codec_name
, result
);
1485 if (zr
->card
.video_vfe
!= 0 &&
1487 codecid_to_modulename(zr
->card
.video_vfe
)) != NULL
) {
1488 if ((result
= request_module(vfe_name
)) < 0) {
1491 "%s: failed to load modules %s: %d\n",
1492 ZR_DEVNAME(zr
), vfe_name
, result
);
1496 /* reset JPEG codec */
1497 jpeg_codec_sleep(zr
, 1);
1498 jpeg_codec_reset(zr
);
1499 /* video bus enabled */
1500 /* display codec revision */
1501 if (zr
->card
.video_codec
!= 0) {
1502 master_codec
= zoran_setup_videocodec(zr
,
1503 zr
->card
.video_codec
);
1506 zr
->codec
= videocodec_attach(master_codec
);
1510 "%s: find_zr36057() - no codec found\n",
1514 if (zr
->codec
->type
!= zr
->card
.video_codec
) {
1517 "%s: find_zr36057() - wrong codec\n",
1519 goto zr_detach_codec
;
1522 if (zr
->card
.video_vfe
!= 0) {
1523 master_vfe
= zoran_setup_videocodec(zr
,
1524 zr
->card
.video_vfe
);
1526 goto zr_detach_codec
;
1527 zr
->vfe
= videocodec_attach(master_vfe
);
1531 "%s: find_zr36057() - no VFE found\n",
1535 if (zr
->vfe
->type
!= zr
->card
.video_vfe
) {
1538 "%s: find_zr36057() = wrong VFE\n",
1543 /* Success so keep the pci_dev referenced */
1544 pci_dev_get(zr
->pci_dev
);
1550 videocodec_detach(zr
->vfe
);
1554 videocodec_detach(zr
->codec
);
1556 kfree(master_codec
);
1558 zoran_unregister_i2c(zr
);
1560 btwrite(0, ZR36057_SPGPPCR
);
1561 free_irq(zr
->pci_dev
->irq
, zr
);
1563 iounmap(zr
->zr36057_mem
);
1566 if (dev
) /* Clean up ref count on early exit */
1569 if (zoran_num
== 0) {
1570 dprintk(1, KERN_INFO
"No known MJPEG cards found.\n");
1576 init_dc10_cards (void)
1580 memset(zoran
, 0, sizeof(zoran
));
1581 printk(KERN_INFO
"Zoran MJPEG board driver version %d.%d.%d\n",
1582 MAJOR_VERSION
, MINOR_VERSION
, RELEASE_VERSION
);
1584 /* Look for cards */
1585 if (find_zr36057() < 0) {
1590 dprintk(1, KERN_INFO
"%s: %d card(s) found\n", ZORAN_NAME
,
1592 /* check the parameters we have been given, adjust if necessary */
1595 if (v4l_nbufs
> VIDEO_MAX_FRAME
)
1596 v4l_nbufs
= VIDEO_MAX_FRAME
;
1597 /* The user specfies the in KB, we want them in byte
1598 * (and page aligned) */
1599 v4l_bufsize
= PAGE_ALIGN(v4l_bufsize
* 1024);
1600 if (v4l_bufsize
< 32768)
1601 v4l_bufsize
= 32768;
1602 /* 2 MB is arbitrary but sufficient for the maximum possible images */
1603 if (v4l_bufsize
> 2048 * 1024)
1604 v4l_bufsize
= 2048 * 1024;
1607 if (jpg_nbufs
> BUZ_MAX_FRAME
)
1608 jpg_nbufs
= BUZ_MAX_FRAME
;
1609 jpg_bufsize
= PAGE_ALIGN(jpg_bufsize
* 1024);
1610 if (jpg_bufsize
< 8192)
1612 if (jpg_bufsize
> (512 * 1024))
1613 jpg_bufsize
= 512 * 1024;
1614 /* Use parameter for vidmem or try to find a video card */
1618 "%s: Using supplied video memory base address @ 0x%lx\n",
1619 ZORAN_NAME
, vidmem
);
1622 /* random nonsense */
1623 dprintk(5, KERN_DEBUG
"Jotti is een held!\n");
1625 /* some mainboards might not do PCI-PCI data transfer well */
1626 if (pci_pci_problems
& (PCIPCI_FAIL
|PCIAGP_FAIL
|PCIPCI_ALIMAGIK
)) {
1629 "%s: chipset does not support reliable PCI-PCI DMA\n",
1633 /* take care of Natoma chipset and a revision 1 zr36057 */
1634 for (i
= 0; i
< zoran_num
; i
++) {
1635 struct zoran
*zr
= &zoran
[i
];
1637 if ((pci_pci_problems
& PCIPCI_NATOMA
) && zr
->revision
<= 1) {
1638 zr
->jpg_buffers
.need_contiguous
= 1;
1641 "%s: ZR36057/Natoma bug, max. buffer size is 128K\n",
1645 if (zr36057_init(zr
) < 0) {
1646 for (i
= 0; i
< zoran_num
; i
++)
1647 zoran_release(&zoran
[i
]);
1650 zoran_proc_init(zr
);
1657 unload_dc10_cards (void)
1661 for (i
= 0; i
< zoran_num
; i
++)
1662 zoran_release(&zoran
[i
]);
1665 module_init(init_dc10_cards
);
1666 module_exit(unload_dc10_cards
);