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 extern const struct zoran_format zoran_formats
[];
64 static int card
[BUZ_MAX
] = { -1, -1, -1, -1 };
65 module_param_array(card
, int, NULL
, 0444);
66 MODULE_PARM_DESC(card
, "The type of card");
68 static int encoder
[BUZ_MAX
] = { -1, -1, -1, -1 };
69 module_param_array(encoder
, int, NULL
, 0444);
70 MODULE_PARM_DESC(encoder
, "i2c TV encoder");
72 static int decoder
[BUZ_MAX
] = { -1, -1, -1, -1 };
73 module_param_array(decoder
, int, NULL
, 0444);
74 MODULE_PARM_DESC(decoder
, "i2c TV decoder");
77 The video mem address of the video card.
78 The driver has a little database for some videocards
79 to determine it from there. If your video card is not in there
80 you have either to give it to the driver as a parameter
81 or set in in a VIDIOCSFBUF ioctl
84 static unsigned long vidmem
; /* default = 0 - Video memory base address */
85 module_param(vidmem
, ulong
, 0444);
86 MODULE_PARM_DESC(vidmem
, "Default video memory base address");
89 Default input and video norm at startup of the driver.
92 static unsigned int default_input
; /* default 0 = Composite, 1 = S-Video */
93 module_param(default_input
, uint
, 0444);
94 MODULE_PARM_DESC(default_input
,
95 "Default input (0=Composite, 1=S-Video, 2=Internal)");
97 static int default_mux
= 1; /* 6 Eyes input selection */
98 module_param(default_mux
, int, 0644);
99 MODULE_PARM_DESC(default_mux
,
100 "Default 6 Eyes mux setting (Input selection)");
102 static int default_norm
; /* default 0 = PAL, 1 = NTSC 2 = SECAM */
103 module_param(default_norm
, int, 0444);
104 MODULE_PARM_DESC(default_norm
, "Default norm (0=PAL, 1=NTSC, 2=SECAM)");
106 /* /dev/videoN, -1 for autodetect */
107 static int video_nr
[BUZ_MAX
] = {-1, -1, -1, -1};
108 module_param_array(video_nr
, int, NULL
, 0444);
109 MODULE_PARM_DESC(video_nr
, "video device number (-1=Auto)");
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, 0644);
131 MODULE_PARM_DESC(v4l_nbufs
, "Maximum number of V4L buffers to use");
132 module_param(v4l_bufsize
, int, 0644);
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, 0644);
138 MODULE_PARM_DESC(jpg_nbufs
, "Maximum number of JPG buffers to use");
139 module_param(jpg_bufsize
, int, 0644);
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, 0644);
145 MODULE_PARM_DESC(pass_through
,
146 "Pass TV signal through to TV-out when idling");
148 int zr36067_debug
= 1;
149 module_param_named(debug
, zr36067_debug
, int, 0644);
150 MODULE_PARM_DESC(debug
, "Debug level (0-5)");
152 MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");
153 MODULE_AUTHOR("Serguei Miridonov");
154 MODULE_LICENSE("GPL");
156 static struct pci_device_id zr36067_pci_tbl
[] = {
157 { PCI_DEVICE(PCI_VENDOR_ID_ZORAN
, PCI_DEVICE_ID_ZORAN_36057
), },
160 MODULE_DEVICE_TABLE(pci
, zr36067_pci_tbl
);
162 atomic_t zoran_num
= ATOMIC_INIT(0); /* number of Buzs in use */
163 struct zoran
*zoran
[BUZ_MAX
];
165 /* videocodec bus functions ZR36060 */
167 zr36060_read (struct videocodec
*codec
,
170 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
173 if (post_office_wait(zr
)
174 || post_office_write(zr
, 0, 1, reg
>> 8)
175 || post_office_write(zr
, 0, 2, reg
& 0xff)) {
179 data
= post_office_read(zr
, 0, 3) & 0xff;
184 zr36060_write (struct videocodec
*codec
,
188 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
190 if (post_office_wait(zr
)
191 || post_office_write(zr
, 0, 1, reg
>> 8)
192 || post_office_write(zr
, 0, 2, reg
& 0xff)) {
196 post_office_write(zr
, 0, 3, val
& 0xff);
199 /* videocodec bus functions ZR36050 */
201 zr36050_read (struct videocodec
*codec
,
204 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
207 if (post_office_wait(zr
)
208 || post_office_write(zr
, 1, 0, reg
>> 2)) { // reg. HIGHBYTES
212 data
= post_office_read(zr
, 0, reg
& 0x03) & 0xff; // reg. LOWBYTES + read
217 zr36050_write (struct videocodec
*codec
,
221 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
223 if (post_office_wait(zr
)
224 || post_office_write(zr
, 1, 0, reg
>> 2)) { // reg. HIGHBYTES
228 post_office_write(zr
, 0, reg
& 0x03, val
& 0xff); // reg. LOWBYTES + wr. data
231 /* videocodec bus functions ZR36016 */
233 zr36016_read (struct videocodec
*codec
,
236 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
239 if (post_office_wait(zr
)) {
243 data
= post_office_read(zr
, 2, reg
& 0x03) & 0xff; // read
247 /* hack for in zoran_device.c */
249 zr36016_write (struct videocodec
*codec
,
253 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
255 if (post_office_wait(zr
)) {
259 post_office_write(zr
, 2, reg
& 0x03, val
& 0x0ff); // wr. data
263 * Board specific information
267 dc10_init (struct zoran
*zr
)
269 dprintk(3, KERN_DEBUG
"%s: dc10_init()\n", ZR_DEVNAME(zr
));
271 /* Pixel clock selection */
274 /* Enable the video bus sync signals */
279 dc10plus_init (struct zoran
*zr
)
281 dprintk(3, KERN_DEBUG
"%s: dc10plus_init()\n", ZR_DEVNAME(zr
));
285 buz_init (struct zoran
*zr
)
287 dprintk(3, KERN_DEBUG
"%s: buz_init()\n", ZR_DEVNAME(zr
));
289 /* some stuff from Iomega */
290 pci_write_config_dword(zr
->pci_dev
, 0xfc, 0x90680f15);
291 pci_write_config_dword(zr
->pci_dev
, 0x0c, 0x00012020);
292 pci_write_config_dword(zr
->pci_dev
, 0xe8, 0xc0200000);
296 lml33_init (struct zoran
*zr
)
298 dprintk(3, KERN_DEBUG
"%s: lml33_init()\n", ZR_DEVNAME(zr
));
300 GPIO(zr
, 2, 1); // Set Composite input/output
304 avs6eyes_init (struct zoran
*zr
)
306 // AverMedia 6-Eyes original driver by Christer Weinigel
308 // Lifted straight from Christer's old driver and
309 // modified slightly by Martin Samuelsson.
311 int mux
= default_mux
; /* 1 = BT866, 7 = VID1 */
313 GPIO(zr
, 4, 1); /* Bt866 SLEEP on */
316 GPIO(zr
, 0, 1); /* ZR36060 /RESET on */
317 GPIO(zr
, 1, 0); /* ZR36060 /SLEEP on */
318 GPIO(zr
, 2, mux
& 1); /* MUX S0 */
319 GPIO(zr
, 3, 0); /* /FRAME on */
320 GPIO(zr
, 4, 0); /* Bt866 SLEEP off */
321 GPIO(zr
, 5, mux
& 2); /* MUX S1 */
322 GPIO(zr
, 6, 0); /* ? */
323 GPIO(zr
, 7, mux
& 4); /* MUX S2 */
328 i2cid_to_modulename (u16 i2c_id
)
333 case I2C_DRIVERID_SAA7110
:
336 case I2C_DRIVERID_SAA7111A
:
339 case I2C_DRIVERID_SAA7114
:
342 case I2C_DRIVERID_SAA7185B
:
345 case I2C_DRIVERID_ADV7170
:
348 case I2C_DRIVERID_ADV7175
:
351 case I2C_DRIVERID_BT819
:
354 case I2C_DRIVERID_BT856
:
357 case I2C_DRIVERID_BT866
:
360 case I2C_DRIVERID_VPX3220
:
363 case I2C_DRIVERID_KS0127
:
372 codecid_to_modulename (u16 codecid
)
377 case CODEC_TYPE_ZR36060
:
380 case CODEC_TYPE_ZR36050
:
383 case CODEC_TYPE_ZR36016
:
392 // u16 Wt, Wa, HStart, HSyncStart, Ht, Ha, VStart;
395 static struct tvnorm f50sqpixel
= { 944, 768, 83, 880, 625, 576, 16 };
396 static struct tvnorm f60sqpixel
= { 780, 640, 51, 716, 525, 480, 12 };
397 static struct tvnorm f50ccir601
= { 864, 720, 75, 804, 625, 576, 18 };
398 static struct tvnorm f60ccir601
= { 858, 720, 57, 788, 525, 480, 16 };
400 static struct tvnorm f50ccir601_lml33
= { 864, 720, 75+34, 804, 625, 576, 18 };
401 static struct tvnorm f60ccir601_lml33
= { 858, 720, 57+34, 788, 525, 480, 16 };
403 /* The DC10 (57/16/50) uses VActive as HSync, so HStart must be 0 */
404 static struct tvnorm f50sqpixel_dc10
= { 944, 768, 0, 880, 625, 576, 0 };
405 static struct tvnorm f60sqpixel_dc10
= { 780, 640, 0, 716, 525, 480, 12 };
407 /* FIXME: I cannot swap U and V in saa7114, so i do one
408 * pixel left shift in zoran (75 -> 74)
409 * (Maxim Yevtyushkin <max@linuxmedialabs.com>) */
410 static struct tvnorm f50ccir601_lm33r10
= { 864, 720, 74+54, 804, 625, 576, 18 };
411 static struct tvnorm f60ccir601_lm33r10
= { 858, 720, 56+54, 788, 525, 480, 16 };
413 /* FIXME: The ks0127 seem incapable of swapping U and V, too, which is why I
414 * copy Maxim's left shift hack for the 6 Eyes.
416 * Christer's driver used the unshifted norms, though...
418 static struct tvnorm f50ccir601_avs6eyes
= { 864, 720, 74, 804, 625, 576, 18 };
419 static struct tvnorm f60ccir601_avs6eyes
= { 858, 720, 56, 788, 525, 480, 16 };
421 static struct card_info zoran_cards
[NUM_CARDS
] __devinitdata
= {
425 .i2c_decoder
= I2C_DRIVERID_VPX3220
,
426 .video_codec
= CODEC_TYPE_ZR36050
,
427 .video_vfe
= CODEC_TYPE_ZR36016
,
433 { 0, "Internal/comp" }
442 .vsync_int
= ZR36057_ISR_GIRQ1
,
443 .gpio
= { 2, 1, -1, 3, 7, 0, 4, 5 },
444 .gpio_pol
= { 0, 0, 0, 1, 0, 0, 0, 0 },
446 .vfe_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
447 .gws_not_connected
= 0,
453 .i2c_decoder
= I2C_DRIVERID_SAA7110
,
454 .i2c_encoder
= I2C_DRIVERID_ADV7175
,
455 .video_codec
= CODEC_TYPE_ZR36060
,
461 { 5, "Internal/comp" }
468 .jpeg_int
= ZR36057_ISR_GIRQ0
,
469 .vsync_int
= ZR36057_ISR_GIRQ1
,
470 .gpio
= { 3, 0, 6, 1, 2, -1, 4, 5 },
471 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
473 .vfe_pol
= { 1, 1, 1, 1, 0, 0, 0, 0 },
474 .gws_not_connected
= 0,
476 .init
= &dc10plus_init
,
480 .vendor_id
= PCI_VENDOR_ID_MIRO
,
481 .device_id
= PCI_DEVICE_ID_MIRO_DC10PLUS
,
482 .i2c_decoder
= I2C_DRIVERID_SAA7110
,
483 .i2c_encoder
= I2C_DRIVERID_ADV7175
,
484 .video_codec
= CODEC_TYPE_ZR36060
,
490 { 5, "Internal/comp" }
498 .jpeg_int
= ZR36057_ISR_GIRQ0
,
499 .vsync_int
= ZR36057_ISR_GIRQ1
,
500 .gpio
= { 3, 0, 6, 1, 2, -1, 4, 5 },
501 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
503 .vfe_pol
= { 1, 1, 1, 1, 0, 0, 0, 0 },
504 .gws_not_connected
= 0,
506 .init
= &dc10plus_init
,
510 .i2c_decoder
= I2C_DRIVERID_VPX3220
,
511 .i2c_encoder
= I2C_DRIVERID_ADV7175
,
512 .video_codec
= CODEC_TYPE_ZR36050
,
513 .video_vfe
= CODEC_TYPE_ZR36016
,
519 { 0, "Internal/comp" }
528 .vsync_int
= ZR36057_ISR_GIRQ1
,
529 .gpio
= { 2, 1, -1, 3, 7, 0, 4, 5 },
530 .gpio_pol
= { 0, 0, 0, 1, 0, 0, 0, 0 },
532 .vfe_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
533 .gws_not_connected
= 0,
539 .vendor_id
= PCI_VENDOR_ID_MIRO
,
540 .device_id
= PCI_DEVICE_ID_MIRO_DC30PLUS
,
541 .i2c_decoder
= I2C_DRIVERID_VPX3220
,
542 .i2c_encoder
= I2C_DRIVERID_ADV7175
,
543 .video_codec
= CODEC_TYPE_ZR36050
,
544 .video_vfe
= CODEC_TYPE_ZR36016
,
550 { 0, "Internal/comp" }
559 .vsync_int
= ZR36057_ISR_GIRQ1
,
560 .gpio
= { 2, 1, -1, 3, 7, 0, 4, 5 },
561 .gpio_pol
= { 0, 0, 0, 1, 0, 0, 0, 0 },
563 .vfe_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
564 .gws_not_connected
= 0,
570 .i2c_decoder
= I2C_DRIVERID_BT819
,
571 .i2c_encoder
= I2C_DRIVERID_BT856
,
572 .video_codec
= CODEC_TYPE_ZR36060
,
585 .jpeg_int
= ZR36057_ISR_GIRQ1
,
586 .vsync_int
= ZR36057_ISR_GIRQ0
,
587 .gpio
= { 1, -1, 3, 5, 7, -1, -1, -1 },
588 .gpio_pol
= { 0, 0, 0, 0, 1, 0, 0, 0 },
590 .vfe_pol
= { 1, 1, 0, 0, 0, 1, 0, 0 },
591 .gws_not_connected
= 1,
597 .vendor_id
= PCI_VENDOR_ID_ELECTRONICDESIGNGMBH
,
598 .device_id
= PCI_DEVICE_ID_LML_33R10
,
599 .i2c_decoder
= I2C_DRIVERID_SAA7114
,
600 .i2c_encoder
= I2C_DRIVERID_ADV7170
,
601 .video_codec
= CODEC_TYPE_ZR36060
,
614 .jpeg_int
= ZR36057_ISR_GIRQ1
,
615 .vsync_int
= ZR36057_ISR_GIRQ0
,
616 .gpio
= { 1, -1, 3, 5, 7, -1, -1, -1 },
617 .gpio_pol
= { 0, 0, 0, 0, 1, 0, 0, 0 },
619 .vfe_pol
= { 1, 1, 0, 0, 0, 1, 0, 0 },
620 .gws_not_connected
= 1,
626 .vendor_id
= PCI_VENDOR_ID_IOMEGA
,
627 .device_id
= PCI_DEVICE_ID_IOMEGA_BUZ
,
628 .i2c_decoder
= I2C_DRIVERID_SAA7111A
,
629 .i2c_encoder
= I2C_DRIVERID_SAA7185B
,
630 .video_codec
= CODEC_TYPE_ZR36060
,
643 .jpeg_int
= ZR36057_ISR_GIRQ1
,
644 .vsync_int
= ZR36057_ISR_GIRQ0
,
645 .gpio
= { 1, -1, 3, -1, -1, -1, -1, -1 },
646 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
648 .vfe_pol
= { 1, 1, 0, 0, 0, 1, 0, 0 },
649 .gws_not_connected
= 1,
655 /* AverMedia chose not to brand the 6-Eyes. Thus it
656 can't be autodetected, and requires card=x. */
659 .i2c_decoder
= I2C_DRIVERID_KS0127
,
660 .i2c_encoder
= I2C_DRIVERID_BT866
,
661 .video_codec
= CODEC_TYPE_ZR36060
,
665 { 0, "Composite 1" },
666 { 1, "Composite 2" },
667 { 2, "Composite 3" },
668 { 4, "Composite 4" },
669 { 5, "Composite 5" },
670 { 6, "Composite 6" },
678 &f50ccir601_avs6eyes
,
679 &f60ccir601_avs6eyes
,
682 .jpeg_int
= ZR36057_ISR_GIRQ1
,
683 .vsync_int
= ZR36057_ISR_GIRQ0
,
684 .gpio
= { 1, 0, 3, -1, -1, -1, -1, -1 },// Validity unknown /Sam
685 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 }, // Validity unknown /Sam
686 .gpcs
= { 3, 1 }, // Validity unknown /Sam
687 .vfe_pol
= { 1, 0, 0, 0, 0, 1, 0, 0 }, // Validity unknown /Sam
688 .gws_not_connected
= 1,
690 .init
= &avs6eyes_init
,
698 /* software I2C functions */
700 zoran_i2c_getsda (void *data
)
702 struct zoran
*zr
= (struct zoran
*) data
;
704 return (btread(ZR36057_I2CBR
) >> 1) & 1;
708 zoran_i2c_getscl (void *data
)
710 struct zoran
*zr
= (struct zoran
*) data
;
712 return btread(ZR36057_I2CBR
) & 1;
716 zoran_i2c_setsda (void *data
,
719 struct zoran
*zr
= (struct zoran
*) data
;
725 btwrite(zr
->i2cbr
, ZR36057_I2CBR
);
729 zoran_i2c_setscl (void *data
,
732 struct zoran
*zr
= (struct zoran
*) data
;
738 btwrite(zr
->i2cbr
, ZR36057_I2CBR
);
742 zoran_i2c_client_register (struct i2c_client
*client
)
744 struct zoran
*zr
= (struct zoran
*) i2c_get_adapdata(client
->adapter
);
748 KERN_DEBUG
"%s: i2c_client_register() - driver id = %d\n",
749 ZR_DEVNAME(zr
), client
->driver
->id
);
751 mutex_lock(&zr
->resource_lock
);
754 /* we're already busy, so we keep a reference to
755 * them... Could do a lot of stuff here, but this
756 * is easiest. (Did I ever mention I'm a lazy ass?)
759 goto clientreg_unlock_and_return
;
762 if (client
->driver
->id
== zr
->card
.i2c_decoder
)
763 zr
->decoder
= client
;
764 else if (client
->driver
->id
== zr
->card
.i2c_encoder
)
765 zr
->encoder
= client
;
768 goto clientreg_unlock_and_return
;
771 clientreg_unlock_and_return
:
772 mutex_unlock(&zr
->resource_lock
);
778 zoran_i2c_client_unregister (struct i2c_client
*client
)
780 struct zoran
*zr
= (struct zoran
*) i2c_get_adapdata(client
->adapter
);
783 dprintk(2, KERN_DEBUG
"%s: i2c_client_unregister()\n", ZR_DEVNAME(zr
));
785 mutex_lock(&zr
->resource_lock
);
789 goto clientunreg_unlock_and_return
;
792 /* try to locate it */
793 if (client
== zr
->encoder
) {
795 } else if (client
== zr
->decoder
) {
797 snprintf(ZR_DEVNAME(zr
), sizeof(ZR_DEVNAME(zr
)), "MJPEG[%d]", zr
->id
);
799 clientunreg_unlock_and_return
:
800 mutex_unlock(&zr
->resource_lock
);
804 static const struct i2c_algo_bit_data zoran_i2c_bit_data_template
= {
805 .setsda
= zoran_i2c_setsda
,
806 .setscl
= zoran_i2c_setscl
,
807 .getsda
= zoran_i2c_getsda
,
808 .getscl
= zoran_i2c_getscl
,
814 zoran_register_i2c (struct zoran
*zr
)
816 memcpy(&zr
->i2c_algo
, &zoran_i2c_bit_data_template
,
817 sizeof(struct i2c_algo_bit_data
));
818 zr
->i2c_algo
.data
= zr
;
819 zr
->i2c_adapter
.class = I2C_CLASS_TV_ANALOG
;
820 zr
->i2c_adapter
.id
= I2C_HW_B_ZR36067
;
821 zr
->i2c_adapter
.client_register
= zoran_i2c_client_register
;
822 zr
->i2c_adapter
.client_unregister
= zoran_i2c_client_unregister
;
823 strlcpy(zr
->i2c_adapter
.name
, ZR_DEVNAME(zr
),
824 sizeof(zr
->i2c_adapter
.name
));
825 i2c_set_adapdata(&zr
->i2c_adapter
, zr
);
826 zr
->i2c_adapter
.algo_data
= &zr
->i2c_algo
;
827 zr
->i2c_adapter
.dev
.parent
= &zr
->pci_dev
->dev
;
828 return i2c_bit_add_bus(&zr
->i2c_adapter
);
832 zoran_unregister_i2c (struct zoran
*zr
)
834 i2c_del_adapter(&zr
->i2c_adapter
);
837 /* Check a zoran_params struct for correctness, insert default params */
840 zoran_check_jpg_settings (struct zoran
*zr
,
841 struct zoran_jpg_settings
*settings
)
843 int err
= 0, err0
= 0;
847 "%s: check_jpg_settings() - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
848 ZR_DEVNAME(zr
), settings
->decimation
, settings
->HorDcm
,
849 settings
->VerDcm
, settings
->TmpDcm
);
852 "%s: check_jpg_settings() - x: %d, y: %d, w: %d, y: %d\n",
853 ZR_DEVNAME(zr
), settings
->img_x
, settings
->img_y
,
854 settings
->img_width
, settings
->img_height
);
855 /* Check decimation, set default values for decimation = 1, 2, 4 */
856 switch (settings
->decimation
) {
859 settings
->HorDcm
= 1;
860 settings
->VerDcm
= 1;
861 settings
->TmpDcm
= 1;
862 settings
->field_per_buff
= 2;
865 settings
->img_width
= BUZ_MAX_WIDTH
;
866 settings
->img_height
= BUZ_MAX_HEIGHT
/ 2;
870 settings
->HorDcm
= 2;
871 settings
->VerDcm
= 1;
872 settings
->TmpDcm
= 2;
873 settings
->field_per_buff
= 1;
874 settings
->img_x
= (BUZ_MAX_WIDTH
== 720) ? 8 : 0;
876 settings
->img_width
=
877 (BUZ_MAX_WIDTH
== 720) ? 704 : BUZ_MAX_WIDTH
;
878 settings
->img_height
= BUZ_MAX_HEIGHT
/ 2;
882 if (zr
->card
.type
== DC10_new
) {
885 "%s: check_jpg_settings() - HDec by 4 is not supported on the DC10\n",
891 settings
->HorDcm
= 4;
892 settings
->VerDcm
= 2;
893 settings
->TmpDcm
= 2;
894 settings
->field_per_buff
= 1;
895 settings
->img_x
= (BUZ_MAX_WIDTH
== 720) ? 8 : 0;
897 settings
->img_width
=
898 (BUZ_MAX_WIDTH
== 720) ? 704 : BUZ_MAX_WIDTH
;
899 settings
->img_height
= BUZ_MAX_HEIGHT
/ 2;
903 /* We have to check the data the user has set */
905 if (settings
->HorDcm
!= 1 && settings
->HorDcm
!= 2 &&
906 (zr
->card
.type
== DC10_new
|| settings
->HorDcm
!= 4))
908 if (settings
->VerDcm
!= 1 && settings
->VerDcm
!= 2)
910 if (settings
->TmpDcm
!= 1 && settings
->TmpDcm
!= 2)
912 if (settings
->field_per_buff
!= 1 &&
913 settings
->field_per_buff
!= 2)
915 if (settings
->img_x
< 0)
917 if (settings
->img_y
< 0)
919 if (settings
->img_width
< 0)
921 if (settings
->img_height
< 0)
923 if (settings
->img_x
+ settings
->img_width
> BUZ_MAX_WIDTH
)
925 if (settings
->img_y
+ settings
->img_height
>
928 if (settings
->HorDcm
&& settings
->VerDcm
) {
929 if (settings
->img_width
%
930 (16 * settings
->HorDcm
) != 0)
932 if (settings
->img_height
%
933 (8 * settings
->VerDcm
) != 0)
940 "%s: check_jpg_settings() - error in params for decimation = 0\n",
948 "%s: check_jpg_settings() - decimation = %d, must be 0, 1, 2 or 4\n",
949 ZR_DEVNAME(zr
), settings
->decimation
);
954 if (settings
->jpg_comp
.quality
> 100)
955 settings
->jpg_comp
.quality
= 100;
956 if (settings
->jpg_comp
.quality
< 5)
957 settings
->jpg_comp
.quality
= 5;
958 if (settings
->jpg_comp
.APPn
< 0)
959 settings
->jpg_comp
.APPn
= 0;
960 if (settings
->jpg_comp
.APPn
> 15)
961 settings
->jpg_comp
.APPn
= 15;
962 if (settings
->jpg_comp
.APP_len
< 0)
963 settings
->jpg_comp
.APP_len
= 0;
964 if (settings
->jpg_comp
.APP_len
> 60)
965 settings
->jpg_comp
.APP_len
= 60;
966 if (settings
->jpg_comp
.COM_len
< 0)
967 settings
->jpg_comp
.COM_len
= 0;
968 if (settings
->jpg_comp
.COM_len
> 60)
969 settings
->jpg_comp
.COM_len
= 60;
976 zoran_open_init_params (struct zoran
*zr
)
980 /* User must explicitly set a window */
981 zr
->overlay_settings
.is_set
= 0;
982 zr
->overlay_mask
= NULL
;
983 zr
->overlay_active
= ZORAN_FREE
;
985 zr
->v4l_memgrab_active
= 0;
986 zr
->v4l_overlay_active
= 0;
987 zr
->v4l_grab_frame
= NO_GRAB_ACTIVE
;
988 zr
->v4l_grab_seq
= 0;
989 zr
->v4l_settings
.width
= 192;
990 zr
->v4l_settings
.height
= 144;
991 zr
->v4l_settings
.format
= &zoran_formats
[7]; /* YUY2 - YUV-4:2:2 packed */
992 zr
->v4l_settings
.bytesperline
=
993 zr
->v4l_settings
.width
*
994 ((zr
->v4l_settings
.format
->depth
+ 7) / 8);
996 /* DMA ring stuff for V4L */
997 zr
->v4l_pend_tail
= 0;
998 zr
->v4l_pend_head
= 0;
999 zr
->v4l_sync_tail
= 0;
1000 zr
->v4l_buffers
.active
= ZORAN_FREE
;
1001 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
1002 zr
->v4l_buffers
.buffer
[i
].state
= BUZ_STATE_USER
; /* nothing going on */
1004 zr
->v4l_buffers
.allocated
= 0;
1006 for (i
= 0; i
< BUZ_MAX_FRAME
; i
++) {
1007 zr
->jpg_buffers
.buffer
[i
].state
= BUZ_STATE_USER
; /* nothing going on */
1009 zr
->jpg_buffers
.active
= ZORAN_FREE
;
1010 zr
->jpg_buffers
.allocated
= 0;
1011 /* Set necessary params and call zoran_check_jpg_settings to set the defaults */
1012 zr
->jpg_settings
.decimation
= 1;
1013 zr
->jpg_settings
.jpg_comp
.quality
= 50; /* default compression factor 8 */
1014 if (zr
->card
.type
!= BUZ
)
1015 zr
->jpg_settings
.odd_even
= 1;
1017 zr
->jpg_settings
.odd_even
= 0;
1018 zr
->jpg_settings
.jpg_comp
.APPn
= 0;
1019 zr
->jpg_settings
.jpg_comp
.APP_len
= 0; /* No APPn marker */
1020 memset(zr
->jpg_settings
.jpg_comp
.APP_data
, 0,
1021 sizeof(zr
->jpg_settings
.jpg_comp
.APP_data
));
1022 zr
->jpg_settings
.jpg_comp
.COM_len
= 0; /* No COM marker */
1023 memset(zr
->jpg_settings
.jpg_comp
.COM_data
, 0,
1024 sizeof(zr
->jpg_settings
.jpg_comp
.COM_data
));
1025 zr
->jpg_settings
.jpg_comp
.jpeg_markers
=
1026 JPEG_MARKER_DHT
| JPEG_MARKER_DQT
;
1027 i
= zoran_check_jpg_settings(zr
, &zr
->jpg_settings
);
1031 "%s: zoran_open_init_params() internal error\n",
1034 clear_interrupt_counters(zr
);
1038 static void __devinit
1039 test_interrupts (struct zoran
*zr
)
1044 clear_interrupt_counters(zr
);
1047 icr
= btread(ZR36057_ICR
);
1048 btwrite(0x78000000 | ZR36057_ICR_IntPinEn
, ZR36057_ICR
);
1049 prepare_to_wait(&zr
->test_q
, &wait
, TASK_INTERRUPTIBLE
);
1050 timeout
= schedule_timeout(HZ
);
1051 finish_wait(&zr
->test_q
, &wait
);
1052 btwrite(0, ZR36057_ICR
);
1053 btwrite(0x78000000, ZR36057_ISR
);
1055 dprintk(5, KERN_INFO
"%s: Testing interrupts...\n", ZR_DEVNAME(zr
));
1057 dprintk(1, ": time spent: %d\n", 1 * HZ
- timeout
);
1059 if (zr36067_debug
> 1)
1060 print_interrupts(zr
);
1061 btwrite(icr
, ZR36057_ICR
);
1064 static int __devinit
1065 zr36057_init (struct zoran
*zr
)
1073 "%s: zr36057_init() - initializing card[%d], zr=%p\n",
1074 ZR_DEVNAME(zr
), zr
->id
, zr
);
1076 /* default setup of all parameters which will persist between opens */
1079 init_waitqueue_head(&zr
->v4l_capq
);
1080 init_waitqueue_head(&zr
->jpg_capq
);
1081 init_waitqueue_head(&zr
->test_q
);
1082 zr
->jpg_buffers
.allocated
= 0;
1083 zr
->v4l_buffers
.allocated
= 0;
1085 zr
->buffer
.base
= (void *) vidmem
;
1086 zr
->buffer
.width
= 0;
1087 zr
->buffer
.height
= 0;
1088 zr
->buffer
.depth
= 0;
1089 zr
->buffer
.bytesperline
= 0;
1091 /* Avoid nonsense settings from user for default input/norm */
1092 if (default_norm
< VIDEO_MODE_PAL
&&
1093 default_norm
> VIDEO_MODE_SECAM
)
1094 default_norm
= VIDEO_MODE_PAL
;
1095 zr
->norm
= default_norm
;
1096 if (!(zr
->timing
= zr
->card
.tvn
[zr
->norm
])) {
1099 "%s: zr36057_init() - default TV standard not supported by hardware. PAL will be used.\n",
1101 zr
->norm
= VIDEO_MODE_PAL
;
1102 zr
->timing
= zr
->card
.tvn
[zr
->norm
];
1105 if (default_input
> zr
->card
.inputs
-1) {
1108 "%s: default_input value %d out of range (0-%d)\n",
1109 ZR_DEVNAME(zr
), default_input
, zr
->card
.inputs
-1);
1112 zr
->input
= default_input
;
1114 /* Should the following be reset at every open ? */
1116 zr
->contrast
= 32768;
1117 zr
->saturation
= 32768;
1118 zr
->brightness
= 32768;
1120 /* default setup (will be repeated at every open) */
1121 zoran_open_init_params(zr
);
1123 /* allocate memory *before* doing anything to the hardware
1124 * in case allocation fails */
1125 zr
->stat_com
= kzalloc(BUZ_NUM_STAT_COM
* 4, GFP_KERNEL
);
1126 zr
->video_dev
= kmalloc(sizeof(struct video_device
), GFP_KERNEL
);
1127 if (!zr
->stat_com
|| !zr
->video_dev
) {
1130 "%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
1135 for (j
= 0; j
< BUZ_NUM_STAT_COM
; j
++) {
1136 zr
->stat_com
[j
] = cpu_to_le32(1); /* mark as unavailable to zr36057 */
1140 * Now add the template and register the device unit.
1142 memcpy(zr
->video_dev
, &zoran_template
, sizeof(zoran_template
));
1143 strcpy(zr
->video_dev
->name
, ZR_DEVNAME(zr
));
1144 err
= video_register_device(zr
->video_dev
, VFL_TYPE_GRABBER
, video_nr
[zr
->id
]);
1148 zoran_init_hardware(zr
);
1149 if (zr36067_debug
> 2)
1150 detect_guest_activity(zr
);
1151 test_interrupts(zr
);
1152 if (!pass_through
) {
1153 decoder_command(zr
, DECODER_ENABLE_OUTPUT
, &zero
);
1154 encoder_command(zr
, ENCODER_SET_INPUT
, &two
);
1157 zr
->zoran_proc
= NULL
;
1158 zr
->initialized
= 1;
1162 kfree(zr
->stat_com
);
1163 kfree(zr
->video_dev
);
1167 static void __devexit
zoran_remove(struct pci_dev
*pdev
)
1169 struct zoran
*zr
= pci_get_drvdata(pdev
);
1171 if (!zr
->initialized
)
1174 /* unregister videocodec bus */
1176 struct videocodec_master
*master
= zr
->codec
->master_data
;
1178 videocodec_detach(zr
->codec
);
1182 struct videocodec_master
*master
= zr
->vfe
->master_data
;
1184 videocodec_detach(zr
->vfe
);
1188 /* unregister i2c bus */
1189 zoran_unregister_i2c(zr
);
1190 /* disable PCI bus-mastering */
1191 zoran_set_pci_master(zr
, 0);
1192 /* put chip into reset */
1193 btwrite(0, ZR36057_SPGPPCR
);
1194 free_irq(zr
->pci_dev
->irq
, zr
);
1195 /* unmap and free memory */
1196 kfree(zr
->stat_com
);
1197 zoran_proc_cleanup(zr
);
1198 iounmap(zr
->zr36057_mem
);
1199 pci_disable_device(zr
->pci_dev
);
1200 video_unregister_device(zr
->video_dev
);
1202 pci_set_drvdata(pdev
, NULL
);
1207 zoran_vdev_release (struct video_device
*vdev
)
1212 static struct videocodec_master
* __devinit
1213 zoran_setup_videocodec (struct zoran
*zr
,
1216 struct videocodec_master
*m
= NULL
;
1218 m
= kmalloc(sizeof(struct videocodec_master
), GFP_KERNEL
);
1222 "%s: zoran_setup_videocodec() - no memory\n",
1227 /* magic and type are unused for master struct. Makes sense only at
1229 In the past, .type were initialized to the old V4L1 .hardware
1230 value, as VID_HARDWARE_ZR36067
1235 m
->flags
= CODEC_FLAG_ENCODER
| CODEC_FLAG_DECODER
;
1236 strncpy(m
->name
, ZR_DEVNAME(zr
), sizeof(m
->name
));
1241 case CODEC_TYPE_ZR36060
:
1242 m
->readreg
= zr36060_read
;
1243 m
->writereg
= zr36060_write
;
1244 m
->flags
|= CODEC_FLAG_JPEG
| CODEC_FLAG_VFE
;
1246 case CODEC_TYPE_ZR36050
:
1247 m
->readreg
= zr36050_read
;
1248 m
->writereg
= zr36050_write
;
1249 m
->flags
|= CODEC_FLAG_JPEG
;
1251 case CODEC_TYPE_ZR36016
:
1252 m
->readreg
= zr36016_read
;
1253 m
->writereg
= zr36016_write
;
1254 m
->flags
|= CODEC_FLAG_VFE
;
1262 * Scan for a Buz card (actually for the PCI controller ZR36057),
1263 * request the irq and map the io memory
1265 static int __devinit
zoran_probe(struct pci_dev
*pdev
,
1266 const struct pci_device_id
*ent
)
1268 unsigned char latency
, need_latency
;
1271 struct videocodec_master
*master_vfe
= NULL
;
1272 struct videocodec_master
*master_codec
= NULL
;
1274 char *i2c_enc_name
, *i2c_dec_name
, *codec_name
, *vfe_name
;
1278 nr
= atomic_inc_return(&zoran_num
) - 1;
1279 if (nr
>= BUZ_MAX
) {
1282 "%s: driver limited to %d card(s) maximum\n",
1283 ZORAN_NAME
, BUZ_MAX
);
1287 card_num
= card
[nr
];
1288 zr
= kzalloc(sizeof(struct zoran
), GFP_KERNEL
);
1292 "%s: find_zr36057() - kzalloc failed\n",
1294 /* The entry in zoran[] gets leaked */
1299 snprintf(ZR_DEVNAME(zr
), sizeof(ZR_DEVNAME(zr
)), "MJPEG[%u]", zr
->id
);
1300 spin_lock_init(&zr
->spinlock
);
1301 mutex_init(&zr
->resource_lock
);
1302 if (pci_enable_device(pdev
))
1304 zr
->zr36057_adr
= pci_resource_start(zr
->pci_dev
, 0);
1305 pci_read_config_byte(zr
->pci_dev
, PCI_CLASS_REVISION
, &zr
->revision
);
1306 if (zr
->revision
< 2) {
1309 "%s: Zoran ZR36057 (rev %d) irq: %d, memory: 0x%08x.\n",
1310 ZR_DEVNAME(zr
), zr
->revision
, zr
->pci_dev
->irq
,
1313 if (card_num
== -1) {
1316 "%s: find_zr36057() - no card specified, please use the card=X insmod option\n",
1322 unsigned short ss_vendor
, ss_device
;
1324 ss_vendor
= zr
->pci_dev
->subsystem_vendor
;
1325 ss_device
= zr
->pci_dev
->subsystem_device
;
1328 "%s: Zoran ZR36067 (rev %d) irq: %d, memory: 0x%08x\n",
1329 ZR_DEVNAME(zr
), zr
->revision
, zr
->pci_dev
->irq
,
1333 "%s: subsystem vendor=0x%04x id=0x%04x\n",
1334 ZR_DEVNAME(zr
), ss_vendor
, ss_device
);
1335 if (card_num
== -1) {
1338 "%s: find_zr36057() - trying to autodetect card type\n",
1340 for (i
= 0; i
< NUM_CARDS
; i
++) {
1341 if (ss_vendor
== zoran_cards
[i
].vendor_id
&&
1342 ss_device
== zoran_cards
[i
].device_id
) {
1345 "%s: find_zr36057() - card %s detected\n",
1347 zoran_cards
[i
].name
);
1352 if (i
== NUM_CARDS
) {
1355 "%s: find_zr36057() - unknown card\n",
1362 if (card_num
< 0 || card_num
>= NUM_CARDS
) {
1365 "%s: find_zr36057() - invalid cardnum %d\n",
1366 ZR_DEVNAME(zr
), card_num
);
1370 /* even though we make this a non pointer and thus
1371 * theoretically allow for making changes to this struct
1372 * on a per-individual card basis at runtime, this is
1373 * strongly discouraged. This structure is intended to
1374 * keep general card information, no settings or anything */
1375 zr
->card
= zoran_cards
[card_num
];
1376 snprintf(ZR_DEVNAME(zr
), sizeof(ZR_DEVNAME(zr
)),
1377 "%s[%u]", zr
->card
.name
, zr
->id
);
1379 zr
->zr36057_mem
= ioremap_nocache(zr
->zr36057_adr
, 0x1000);
1380 if (!zr
->zr36057_mem
) {
1383 "%s: find_zr36057() - ioremap failed\n",
1388 result
= request_irq(zr
->pci_dev
->irq
, zoran_irq
,
1389 IRQF_SHARED
| IRQF_DISABLED
, ZR_DEVNAME(zr
), zr
);
1391 if (result
== -EINVAL
) {
1394 "%s: find_zr36057() - bad irq number or handler\n",
1396 } else if (result
== -EBUSY
) {
1399 "%s: find_zr36057() - IRQ %d busy, change your PnP config in BIOS\n",
1400 ZR_DEVNAME(zr
), zr
->pci_dev
->irq
);
1404 "%s: find_zr36057() - can't assign irq, error code %d\n",
1405 ZR_DEVNAME(zr
), result
);
1410 /* set PCI latency timer */
1411 pci_read_config_byte(zr
->pci_dev
, PCI_LATENCY_TIMER
,
1413 need_latency
= zr
->revision
> 1 ? 32 : 48;
1414 if (latency
!= need_latency
) {
1417 "%s: Changing PCI latency from %d to %d\n",
1418 ZR_DEVNAME(zr
), latency
, need_latency
);
1419 pci_write_config_byte(zr
->pci_dev
, PCI_LATENCY_TIMER
,
1423 zr36057_restart(zr
);
1425 dprintk(2, KERN_INFO
"%s: Initializing i2c bus...\n",
1429 if (decoder
[zr
->id
] != -1) {
1430 i2c_dec_name
= i2cid_to_modulename(decoder
[zr
->id
]);
1431 zr
->card
.i2c_decoder
= decoder
[zr
->id
];
1432 } else if (zr
->card
.i2c_decoder
!= 0) {
1433 i2c_dec_name
= i2cid_to_modulename(zr
->card
.i2c_decoder
);
1435 i2c_dec_name
= NULL
;
1439 result
= request_module(i2c_dec_name
);
1443 "%s: failed to load module %s: %d\n",
1444 ZR_DEVNAME(zr
), i2c_dec_name
, result
);
1449 if (encoder
[zr
->id
] != -1) {
1450 i2c_enc_name
= i2cid_to_modulename(encoder
[zr
->id
]);
1451 zr
->card
.i2c_encoder
= encoder
[zr
->id
];
1452 } else if (zr
->card
.i2c_encoder
!= 0) {
1453 i2c_enc_name
= i2cid_to_modulename(zr
->card
.i2c_encoder
);
1455 i2c_enc_name
= NULL
;
1459 result
= request_module(i2c_enc_name
);
1463 "%s: failed to load module %s: %d\n",
1464 ZR_DEVNAME(zr
), i2c_enc_name
, result
);
1468 if (zoran_register_i2c(zr
) < 0) {
1471 "%s: find_zr36057() - can't initialize i2c bus\n",
1477 KERN_INFO
"%s: Initializing videocodec bus...\n",
1480 if (zr
->card
.video_codec
) {
1481 codec_name
= codecid_to_modulename(zr
->card
.video_codec
);
1483 result
= request_module(codec_name
);
1487 "%s: failed to load modules %s: %d\n",
1488 ZR_DEVNAME(zr
), codec_name
, result
);
1492 if (zr
->card
.video_vfe
) {
1493 vfe_name
= codecid_to_modulename(zr
->card
.video_vfe
);
1495 result
= request_module(vfe_name
);
1499 "%s: failed to load modules %s: %d\n",
1500 ZR_DEVNAME(zr
), vfe_name
, result
);
1505 /* reset JPEG codec */
1506 jpeg_codec_sleep(zr
, 1);
1507 jpeg_codec_reset(zr
);
1508 /* video bus enabled */
1509 /* display codec revision */
1510 if (zr
->card
.video_codec
!= 0) {
1511 master_codec
= zoran_setup_videocodec(zr
, zr
->card
.video_codec
);
1514 zr
->codec
= videocodec_attach(master_codec
);
1518 "%s: find_zr36057() - no codec found\n",
1522 if (zr
->codec
->type
!= zr
->card
.video_codec
) {
1525 "%s: find_zr36057() - wrong codec\n",
1527 goto zr_detach_codec
;
1530 if (zr
->card
.video_vfe
!= 0) {
1531 master_vfe
= zoran_setup_videocodec(zr
, zr
->card
.video_vfe
);
1533 goto zr_detach_codec
;
1534 zr
->vfe
= videocodec_attach(master_vfe
);
1538 "%s: find_zr36057() - no VFE found\n",
1542 if (zr
->vfe
->type
!= zr
->card
.video_vfe
) {
1545 "%s: find_zr36057() = wrong VFE\n",
1552 /* take care of Natoma chipset and a revision 1 zr36057 */
1553 if ((pci_pci_problems
& PCIPCI_NATOMA
) && zr
->revision
<= 1) {
1554 zr
->jpg_buffers
.need_contiguous
= 1;
1557 "%s: ZR36057/Natoma bug, max. buffer size is 128K\n",
1561 if (zr36057_init(zr
) < 0)
1564 zoran_proc_init(zr
);
1566 pci_set_drvdata(pdev
, zr
);
1571 videocodec_detach(zr
->vfe
);
1575 videocodec_detach(zr
->codec
);
1577 kfree(master_codec
);
1579 zoran_unregister_i2c(zr
);
1581 btwrite(0, ZR36057_SPGPPCR
);
1582 free_irq(zr
->pci_dev
->irq
, zr
);
1584 iounmap(zr
->zr36057_mem
);
1591 static struct pci_driver zoran_driver
= {
1593 .id_table
= zr36067_pci_tbl
,
1594 .probe
= zoran_probe
,
1595 .remove
= zoran_remove
,
1598 static int __init
zoran_init(void)
1602 memset(zoran
, 0, sizeof(zoran
));
1603 printk(KERN_INFO
"Zoran MJPEG board driver version %d.%d.%d\n",
1604 MAJOR_VERSION
, MINOR_VERSION
, RELEASE_VERSION
);
1606 /* check the parameters we have been given, adjust if necessary */
1609 if (v4l_nbufs
> VIDEO_MAX_FRAME
)
1610 v4l_nbufs
= VIDEO_MAX_FRAME
;
1611 /* The user specfies the in KB, we want them in byte
1612 * (and page aligned) */
1613 v4l_bufsize
= PAGE_ALIGN(v4l_bufsize
* 1024);
1614 if (v4l_bufsize
< 32768)
1615 v4l_bufsize
= 32768;
1616 /* 2 MB is arbitrary but sufficient for the maximum possible images */
1617 if (v4l_bufsize
> 2048 * 1024)
1618 v4l_bufsize
= 2048 * 1024;
1621 if (jpg_nbufs
> BUZ_MAX_FRAME
)
1622 jpg_nbufs
= BUZ_MAX_FRAME
;
1623 jpg_bufsize
= PAGE_ALIGN(jpg_bufsize
* 1024);
1624 if (jpg_bufsize
< 8192)
1626 if (jpg_bufsize
> (512 * 1024))
1627 jpg_bufsize
= 512 * 1024;
1628 /* Use parameter for vidmem or try to find a video card */
1632 "%s: Using supplied video memory base address @ 0x%lx\n",
1633 ZORAN_NAME
, vidmem
);
1636 /* random nonsense */
1637 dprintk(6, KERN_DEBUG
"Jotti is een held!\n");
1639 /* some mainboards might not do PCI-PCI data transfer well */
1640 if (pci_pci_problems
& (PCIPCI_FAIL
|PCIAGP_FAIL
|PCIPCI_ALIMAGIK
)) {
1643 "%s: chipset does not support reliable PCI-PCI DMA\n",
1647 res
= pci_register_driver(&zoran_driver
);
1651 "%s: Unable to register ZR36057 driver\n",
1659 static void __exit
zoran_exit(void)
1661 pci_unregister_driver(&zoran_driver
);
1664 module_init(zoran_init
);
1665 module_exit(zoran_exit
);