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>
37 #include <linux/slab.h>
39 #include <linux/proc_fs.h>
40 #include <linux/i2c.h>
41 #include <linux/i2c-algo-bit.h>
42 #include <linux/videodev2.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/mutex.h>
52 #include <media/v4l2-common.h>
53 #include <media/bt819.h>
55 #include "videocodec.h"
57 #include "zoran_card.h"
58 #include "zoran_device.h"
59 #include "zoran_procfs.h"
61 extern const struct zoran_format zoran_formats
[];
63 static int card
[BUZ_MAX
] = { [0 ... (BUZ_MAX
-1)] = -1 };
64 module_param_array(card
, int, NULL
, 0444);
65 MODULE_PARM_DESC(card
, "Card type");
68 The video mem address of the video card.
69 The driver has a little database for some videocards
70 to determine it from there. If your video card is not in there
71 you have either to give it to the driver as a parameter
72 or set in in a VIDIOCSFBUF ioctl
75 static unsigned long vidmem
; /* default = 0 - Video memory base address */
76 module_param(vidmem
, ulong
, 0444);
77 MODULE_PARM_DESC(vidmem
, "Default video memory base address");
80 Default input and video norm at startup of the driver.
83 static unsigned int default_input
; /* default 0 = Composite, 1 = S-Video */
84 module_param(default_input
, uint
, 0444);
85 MODULE_PARM_DESC(default_input
,
86 "Default input (0=Composite, 1=S-Video, 2=Internal)");
88 static int default_mux
= 1; /* 6 Eyes input selection */
89 module_param(default_mux
, int, 0644);
90 MODULE_PARM_DESC(default_mux
,
91 "Default 6 Eyes mux setting (Input selection)");
93 static int default_norm
; /* default 0 = PAL, 1 = NTSC 2 = SECAM */
94 module_param(default_norm
, int, 0444);
95 MODULE_PARM_DESC(default_norm
, "Default norm (0=PAL, 1=NTSC, 2=SECAM)");
97 /* /dev/videoN, -1 for autodetect */
98 static int video_nr
[BUZ_MAX
] = { [0 ... (BUZ_MAX
-1)] = -1 };
99 module_param_array(video_nr
, int, NULL
, 0444);
100 MODULE_PARM_DESC(video_nr
, "Video device number (-1=Auto)");
103 int v4l_bufsize
= 864; /* Everybody should be able to work with this setting */
104 module_param(v4l_nbufs
, int, 0644);
105 MODULE_PARM_DESC(v4l_nbufs
, "Maximum number of V4L buffers to use");
106 module_param(v4l_bufsize
, int, 0644);
107 MODULE_PARM_DESC(v4l_bufsize
, "Maximum size per V4L buffer (in kB)");
110 int jpg_bufsize
= 512; /* max size for 100% quality full-PAL frame */
111 module_param(jpg_nbufs
, int, 0644);
112 MODULE_PARM_DESC(jpg_nbufs
, "Maximum number of JPG buffers to use");
113 module_param(jpg_bufsize
, int, 0644);
114 MODULE_PARM_DESC(jpg_bufsize
, "Maximum size per JPG buffer (in kB)");
116 int pass_through
= 0; /* 1=Pass through TV signal when device is not used */
117 /* 0=Show color bar when device is not used (LML33: only if lml33dpath=1) */
118 module_param(pass_through
, int, 0644);
119 MODULE_PARM_DESC(pass_through
,
120 "Pass TV signal through to TV-out when idling");
122 int zr36067_debug
= 1;
123 module_param_named(debug
, zr36067_debug
, int, 0644);
124 MODULE_PARM_DESC(debug
, "Debug level (0-5)");
126 #define ZORAN_VERSION "0.10.1"
128 MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");
129 MODULE_AUTHOR("Serguei Miridonov");
130 MODULE_LICENSE("GPL");
131 MODULE_VERSION(ZORAN_VERSION
);
133 #define ZR_DEVICE(subven, subdev, data) { \
134 .vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \
135 .subvendor = (subven), .subdevice = (subdev), .driver_data = (data) }
137 static struct pci_device_id zr36067_pci_tbl
[] = {
138 ZR_DEVICE(PCI_VENDOR_ID_MIRO
, PCI_DEVICE_ID_MIRO_DC10PLUS
, DC10plus
),
139 ZR_DEVICE(PCI_VENDOR_ID_MIRO
, PCI_DEVICE_ID_MIRO_DC30PLUS
, DC30plus
),
140 ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH
, PCI_DEVICE_ID_LML_33R10
, LML33R10
),
141 ZR_DEVICE(PCI_VENDOR_ID_IOMEGA
, PCI_DEVICE_ID_IOMEGA_BUZ
, BUZ
),
142 ZR_DEVICE(PCI_ANY_ID
, PCI_ANY_ID
, NUM_CARDS
),
145 MODULE_DEVICE_TABLE(pci
, zr36067_pci_tbl
);
147 static unsigned int zoran_num
; /* number of cards found */
149 /* videocodec bus functions ZR36060 */
151 zr36060_read (struct videocodec
*codec
,
154 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
157 if (post_office_wait(zr
)
158 || post_office_write(zr
, 0, 1, reg
>> 8)
159 || post_office_write(zr
, 0, 2, reg
& 0xff)) {
163 data
= post_office_read(zr
, 0, 3) & 0xff;
168 zr36060_write (struct videocodec
*codec
,
172 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
174 if (post_office_wait(zr
)
175 || post_office_write(zr
, 0, 1, reg
>> 8)
176 || post_office_write(zr
, 0, 2, reg
& 0xff)) {
180 post_office_write(zr
, 0, 3, val
& 0xff);
183 /* videocodec bus functions ZR36050 */
185 zr36050_read (struct videocodec
*codec
,
188 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
191 if (post_office_wait(zr
)
192 || post_office_write(zr
, 1, 0, reg
>> 2)) { // reg. HIGHBYTES
196 data
= post_office_read(zr
, 0, reg
& 0x03) & 0xff; // reg. LOWBYTES + read
201 zr36050_write (struct videocodec
*codec
,
205 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 post_office_write(zr
, 0, reg
& 0x03, val
& 0xff); // reg. LOWBYTES + wr. data
215 /* videocodec bus functions ZR36016 */
217 zr36016_read (struct videocodec
*codec
,
220 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
223 if (post_office_wait(zr
)) {
227 data
= post_office_read(zr
, 2, reg
& 0x03) & 0xff; // read
231 /* hack for in zoran_device.c */
233 zr36016_write (struct videocodec
*codec
,
237 struct zoran
*zr
= (struct zoran
*) codec
->master_data
->data
;
239 if (post_office_wait(zr
)) {
243 post_office_write(zr
, 2, reg
& 0x03, val
& 0x0ff); // wr. data
247 * Board specific information
251 dc10_init (struct zoran
*zr
)
253 dprintk(3, KERN_DEBUG
"%s: %s\n", ZR_DEVNAME(zr
), __func__
);
255 /* Pixel clock selection */
258 /* Enable the video bus sync signals */
263 dc10plus_init (struct zoran
*zr
)
265 dprintk(3, KERN_DEBUG
"%s: %s\n", ZR_DEVNAME(zr
), __func__
);
269 buz_init (struct zoran
*zr
)
271 dprintk(3, KERN_DEBUG
"%s: %s\n", ZR_DEVNAME(zr
), __func__
);
273 /* some stuff from Iomega */
274 pci_write_config_dword(zr
->pci_dev
, 0xfc, 0x90680f15);
275 pci_write_config_dword(zr
->pci_dev
, 0x0c, 0x00012020);
276 pci_write_config_dword(zr
->pci_dev
, 0xe8, 0xc0200000);
280 lml33_init (struct zoran
*zr
)
282 dprintk(3, KERN_DEBUG
"%s: %s\n", ZR_DEVNAME(zr
), __func__
);
284 GPIO(zr
, 2, 1); // Set Composite input/output
288 avs6eyes_init (struct zoran
*zr
)
290 // AverMedia 6-Eyes original driver by Christer Weinigel
292 // Lifted straight from Christer's old driver and
293 // modified slightly by Martin Samuelsson.
295 int mux
= default_mux
; /* 1 = BT866, 7 = VID1 */
297 GPIO(zr
, 4, 1); /* Bt866 SLEEP on */
300 GPIO(zr
, 0, 1); /* ZR36060 /RESET on */
301 GPIO(zr
, 1, 0); /* ZR36060 /SLEEP on */
302 GPIO(zr
, 2, mux
& 1); /* MUX S0 */
303 GPIO(zr
, 3, 0); /* /FRAME on */
304 GPIO(zr
, 4, 0); /* Bt866 SLEEP off */
305 GPIO(zr
, 5, mux
& 2); /* MUX S1 */
306 GPIO(zr
, 6, 0); /* ? */
307 GPIO(zr
, 7, mux
& 4); /* MUX S2 */
312 codecid_to_modulename (u16 codecid
)
317 case CODEC_TYPE_ZR36060
:
320 case CODEC_TYPE_ZR36050
:
323 case CODEC_TYPE_ZR36016
:
332 // u16 Wt, Wa, HStart, HSyncStart, Ht, Ha, VStart;
335 static struct tvnorm f50sqpixel
= { 944, 768, 83, 880, 625, 576, 16 };
336 static struct tvnorm f60sqpixel
= { 780, 640, 51, 716, 525, 480, 12 };
337 static struct tvnorm f50ccir601
= { 864, 720, 75, 804, 625, 576, 18 };
338 static struct tvnorm f60ccir601
= { 858, 720, 57, 788, 525, 480, 16 };
340 static struct tvnorm f50ccir601_lml33
= { 864, 720, 75+34, 804, 625, 576, 18 };
341 static struct tvnorm f60ccir601_lml33
= { 858, 720, 57+34, 788, 525, 480, 16 };
343 /* The DC10 (57/16/50) uses VActive as HSync, so HStart must be 0 */
344 static struct tvnorm f50sqpixel_dc10
= { 944, 768, 0, 880, 625, 576, 0 };
345 static struct tvnorm f60sqpixel_dc10
= { 780, 640, 0, 716, 525, 480, 12 };
347 /* FIXME: I cannot swap U and V in saa7114, so i do one
348 * pixel left shift in zoran (75 -> 74)
349 * (Maxim Yevtyushkin <max@linuxmedialabs.com>) */
350 static struct tvnorm f50ccir601_lm33r10
= { 864, 720, 74+54, 804, 625, 576, 18 };
351 static struct tvnorm f60ccir601_lm33r10
= { 858, 720, 56+54, 788, 525, 480, 16 };
353 /* FIXME: The ks0127 seem incapable of swapping U and V, too, which is why I
354 * copy Maxim's left shift hack for the 6 Eyes.
356 * Christer's driver used the unshifted norms, though...
358 static struct tvnorm f50ccir601_avs6eyes
= { 864, 720, 74, 804, 625, 576, 18 };
359 static struct tvnorm f60ccir601_avs6eyes
= { 858, 720, 56, 788, 525, 480, 16 };
361 static const unsigned short vpx3220_addrs
[] = { 0x43, 0x47, I2C_CLIENT_END
};
362 static const unsigned short saa7110_addrs
[] = { 0x4e, 0x4f, I2C_CLIENT_END
};
363 static const unsigned short saa7111_addrs
[] = { 0x25, 0x24, I2C_CLIENT_END
};
364 static const unsigned short saa7114_addrs
[] = { 0x21, 0x20, I2C_CLIENT_END
};
365 static const unsigned short adv717x_addrs
[] = { 0x6a, 0x6b, 0x2a, 0x2b, I2C_CLIENT_END
};
366 static const unsigned short ks0127_addrs
[] = { 0x6c, 0x6d, I2C_CLIENT_END
};
367 static const unsigned short saa7185_addrs
[] = { 0x44, I2C_CLIENT_END
};
368 static const unsigned short bt819_addrs
[] = { 0x45, I2C_CLIENT_END
};
369 static const unsigned short bt856_addrs
[] = { 0x44, I2C_CLIENT_END
};
370 static const unsigned short bt866_addrs
[] = { 0x44, I2C_CLIENT_END
};
372 static struct card_info zoran_cards
[NUM_CARDS
] __devinitdata
= {
376 .i2c_decoder
= "vpx3220a",
377 .addrs_decoder
= vpx3220_addrs
,
378 .video_codec
= CODEC_TYPE_ZR36050
,
379 .video_vfe
= CODEC_TYPE_ZR36016
,
385 { 0, "Internal/comp" }
387 .norms
= V4L2_STD_NTSC
|V4L2_STD_PAL
|V4L2_STD_SECAM
,
394 .vsync_int
= ZR36057_ISR_GIRQ1
,
395 .gpio
= { 2, 1, -1, 3, 7, 0, 4, 5 },
396 .gpio_pol
= { 0, 0, 0, 1, 0, 0, 0, 0 },
398 .vfe_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
399 .gws_not_connected
= 0,
405 .i2c_decoder
= "saa7110",
406 .addrs_decoder
= saa7110_addrs
,
407 .i2c_encoder
= "adv7175",
408 .addrs_encoder
= adv717x_addrs
,
409 .video_codec
= CODEC_TYPE_ZR36060
,
415 { 5, "Internal/comp" }
417 .norms
= V4L2_STD_NTSC
|V4L2_STD_PAL
|V4L2_STD_SECAM
,
422 .jpeg_int
= ZR36057_ISR_GIRQ0
,
423 .vsync_int
= ZR36057_ISR_GIRQ1
,
424 .gpio
= { 3, 0, 6, 1, 2, -1, 4, 5 },
425 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
427 .vfe_pol
= { 1, 1, 1, 1, 0, 0, 0, 0 },
428 .gws_not_connected
= 0,
430 .init
= &dc10plus_init
,
434 .i2c_decoder
= "saa7110",
435 .addrs_decoder
= saa7110_addrs
,
436 .i2c_encoder
= "adv7175",
437 .addrs_encoder
= adv717x_addrs
,
438 .video_codec
= CODEC_TYPE_ZR36060
,
444 { 5, "Internal/comp" }
446 .norms
= V4L2_STD_NTSC
|V4L2_STD_PAL
|V4L2_STD_SECAM
,
452 .jpeg_int
= ZR36057_ISR_GIRQ0
,
453 .vsync_int
= ZR36057_ISR_GIRQ1
,
454 .gpio
= { 3, 0, 6, 1, 2, -1, 4, 5 },
455 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
457 .vfe_pol
= { 1, 1, 1, 1, 0, 0, 0, 0 },
458 .gws_not_connected
= 0,
460 .init
= &dc10plus_init
,
464 .i2c_decoder
= "vpx3220a",
465 .addrs_decoder
= vpx3220_addrs
,
466 .i2c_encoder
= "adv7175",
467 .addrs_encoder
= adv717x_addrs
,
468 .video_codec
= CODEC_TYPE_ZR36050
,
469 .video_vfe
= CODEC_TYPE_ZR36016
,
475 { 0, "Internal/comp" }
477 .norms
= V4L2_STD_NTSC
|V4L2_STD_PAL
|V4L2_STD_SECAM
,
484 .vsync_int
= ZR36057_ISR_GIRQ1
,
485 .gpio
= { 2, 1, -1, 3, 7, 0, 4, 5 },
486 .gpio_pol
= { 0, 0, 0, 1, 0, 0, 0, 0 },
488 .vfe_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
489 .gws_not_connected
= 0,
495 .i2c_decoder
= "vpx3220a",
496 .addrs_decoder
= vpx3220_addrs
,
497 .i2c_encoder
= "adv7175",
498 .addrs_encoder
= adv717x_addrs
,
499 .video_codec
= CODEC_TYPE_ZR36050
,
500 .video_vfe
= CODEC_TYPE_ZR36016
,
506 { 0, "Internal/comp" }
508 .norms
= V4L2_STD_NTSC
|V4L2_STD_PAL
|V4L2_STD_SECAM
,
515 .vsync_int
= ZR36057_ISR_GIRQ1
,
516 .gpio
= { 2, 1, -1, 3, 7, 0, 4, 5 },
517 .gpio_pol
= { 0, 0, 0, 1, 0, 0, 0, 0 },
519 .vfe_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
520 .gws_not_connected
= 0,
526 .i2c_decoder
= "bt819a",
527 .addrs_decoder
= bt819_addrs
,
528 .i2c_encoder
= "bt856",
529 .addrs_encoder
= bt856_addrs
,
530 .video_codec
= CODEC_TYPE_ZR36060
,
537 .norms
= V4L2_STD_NTSC
|V4L2_STD_PAL
,
543 .jpeg_int
= ZR36057_ISR_GIRQ1
,
544 .vsync_int
= ZR36057_ISR_GIRQ0
,
545 .gpio
= { 1, -1, 3, 5, 7, -1, -1, -1 },
546 .gpio_pol
= { 0, 0, 0, 0, 1, 0, 0, 0 },
548 .vfe_pol
= { 1, 1, 0, 0, 0, 1, 0, 0 },
549 .gws_not_connected
= 1,
555 .i2c_decoder
= "saa7114",
556 .addrs_decoder
= saa7114_addrs
,
557 .i2c_encoder
= "adv7170",
558 .addrs_encoder
= adv717x_addrs
,
559 .video_codec
= CODEC_TYPE_ZR36060
,
566 .norms
= V4L2_STD_NTSC
|V4L2_STD_PAL
,
572 .jpeg_int
= ZR36057_ISR_GIRQ1
,
573 .vsync_int
= ZR36057_ISR_GIRQ0
,
574 .gpio
= { 1, -1, 3, 5, 7, -1, -1, -1 },
575 .gpio_pol
= { 0, 0, 0, 0, 1, 0, 0, 0 },
577 .vfe_pol
= { 1, 1, 0, 0, 0, 1, 0, 0 },
578 .gws_not_connected
= 1,
584 .i2c_decoder
= "saa7111",
585 .addrs_decoder
= saa7111_addrs
,
586 .i2c_encoder
= "saa7185",
587 .addrs_encoder
= saa7185_addrs
,
588 .video_codec
= CODEC_TYPE_ZR36060
,
595 .norms
= V4L2_STD_NTSC
|V4L2_STD_PAL
|V4L2_STD_SECAM
,
601 .jpeg_int
= ZR36057_ISR_GIRQ1
,
602 .vsync_int
= ZR36057_ISR_GIRQ0
,
603 .gpio
= { 1, -1, 3, -1, -1, -1, -1, -1 },
604 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 },
606 .vfe_pol
= { 1, 1, 0, 0, 0, 1, 0, 0 },
607 .gws_not_connected
= 1,
613 /* AverMedia chose not to brand the 6-Eyes. Thus it
614 can't be autodetected, and requires card=x. */
615 .i2c_decoder
= "ks0127",
616 .addrs_decoder
= ks0127_addrs
,
617 .i2c_encoder
= "bt866",
618 .addrs_encoder
= bt866_addrs
,
619 .video_codec
= CODEC_TYPE_ZR36060
,
623 { 0, "Composite 1" },
624 { 1, "Composite 2" },
625 { 2, "Composite 3" },
626 { 4, "Composite 4" },
627 { 5, "Composite 5" },
628 { 6, "Composite 6" },
634 .norms
= V4L2_STD_NTSC
|V4L2_STD_PAL
,
636 &f50ccir601_avs6eyes
,
637 &f60ccir601_avs6eyes
,
640 .jpeg_int
= ZR36057_ISR_GIRQ1
,
641 .vsync_int
= ZR36057_ISR_GIRQ0
,
642 .gpio
= { 1, 0, 3, -1, -1, -1, -1, -1 },// Validity unknown /Sam
643 .gpio_pol
= { 0, 0, 0, 0, 0, 0, 0, 0 }, // Validity unknown /Sam
644 .gpcs
= { 3, 1 }, // Validity unknown /Sam
645 .vfe_pol
= { 1, 0, 0, 0, 0, 1, 0, 0 }, // Validity unknown /Sam
646 .gws_not_connected
= 1,
648 .init
= &avs6eyes_init
,
656 /* software I2C functions */
658 zoran_i2c_getsda (void *data
)
660 struct zoran
*zr
= (struct zoran
*) data
;
662 return (btread(ZR36057_I2CBR
) >> 1) & 1;
666 zoran_i2c_getscl (void *data
)
668 struct zoran
*zr
= (struct zoran
*) data
;
670 return btread(ZR36057_I2CBR
) & 1;
674 zoran_i2c_setsda (void *data
,
677 struct zoran
*zr
= (struct zoran
*) data
;
683 btwrite(zr
->i2cbr
, ZR36057_I2CBR
);
687 zoran_i2c_setscl (void *data
,
690 struct zoran
*zr
= (struct zoran
*) data
;
696 btwrite(zr
->i2cbr
, ZR36057_I2CBR
);
699 static const struct i2c_algo_bit_data zoran_i2c_bit_data_template
= {
700 .setsda
= zoran_i2c_setsda
,
701 .setscl
= zoran_i2c_setscl
,
702 .getsda
= zoran_i2c_getsda
,
703 .getscl
= zoran_i2c_getscl
,
709 zoran_register_i2c (struct zoran
*zr
)
711 memcpy(&zr
->i2c_algo
, &zoran_i2c_bit_data_template
,
712 sizeof(struct i2c_algo_bit_data
));
713 zr
->i2c_algo
.data
= zr
;
714 strlcpy(zr
->i2c_adapter
.name
, ZR_DEVNAME(zr
),
715 sizeof(zr
->i2c_adapter
.name
));
716 i2c_set_adapdata(&zr
->i2c_adapter
, &zr
->v4l2_dev
);
717 zr
->i2c_adapter
.algo_data
= &zr
->i2c_algo
;
718 zr
->i2c_adapter
.dev
.parent
= &zr
->pci_dev
->dev
;
719 return i2c_bit_add_bus(&zr
->i2c_adapter
);
723 zoran_unregister_i2c (struct zoran
*zr
)
725 i2c_del_adapter(&zr
->i2c_adapter
);
728 /* Check a zoran_params struct for correctness, insert default params */
731 zoran_check_jpg_settings (struct zoran
*zr
,
732 struct zoran_jpg_settings
*settings
,
735 int err
= 0, err0
= 0;
739 "%s: %s - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
740 ZR_DEVNAME(zr
), __func__
, settings
->decimation
, settings
->HorDcm
,
741 settings
->VerDcm
, settings
->TmpDcm
);
744 "%s: %s - x: %d, y: %d, w: %d, y: %d\n",
745 ZR_DEVNAME(zr
), __func__
, settings
->img_x
, settings
->img_y
,
746 settings
->img_width
, settings
->img_height
);
747 /* Check decimation, set default values for decimation = 1, 2, 4 */
748 switch (settings
->decimation
) {
751 settings
->HorDcm
= 1;
752 settings
->VerDcm
= 1;
753 settings
->TmpDcm
= 1;
754 settings
->field_per_buff
= 2;
757 settings
->img_width
= BUZ_MAX_WIDTH
;
758 settings
->img_height
= BUZ_MAX_HEIGHT
/ 2;
762 settings
->HorDcm
= 2;
763 settings
->VerDcm
= 1;
764 settings
->TmpDcm
= 2;
765 settings
->field_per_buff
= 1;
766 settings
->img_x
= (BUZ_MAX_WIDTH
== 720) ? 8 : 0;
768 settings
->img_width
=
769 (BUZ_MAX_WIDTH
== 720) ? 704 : BUZ_MAX_WIDTH
;
770 settings
->img_height
= BUZ_MAX_HEIGHT
/ 2;
774 if (zr
->card
.type
== DC10_new
) {
777 "%s: %s - HDec by 4 is not supported on the DC10\n",
778 ZR_DEVNAME(zr
), __func__
);
783 settings
->HorDcm
= 4;
784 settings
->VerDcm
= 2;
785 settings
->TmpDcm
= 2;
786 settings
->field_per_buff
= 1;
787 settings
->img_x
= (BUZ_MAX_WIDTH
== 720) ? 8 : 0;
789 settings
->img_width
=
790 (BUZ_MAX_WIDTH
== 720) ? 704 : BUZ_MAX_WIDTH
;
791 settings
->img_height
= BUZ_MAX_HEIGHT
/ 2;
795 /* We have to check the data the user has set */
797 if (settings
->HorDcm
!= 1 && settings
->HorDcm
!= 2 &&
798 (zr
->card
.type
== DC10_new
|| settings
->HorDcm
!= 4)) {
799 settings
->HorDcm
= clamp(settings
->HorDcm
, 1, 2);
802 if (settings
->VerDcm
!= 1 && settings
->VerDcm
!= 2) {
803 settings
->VerDcm
= clamp(settings
->VerDcm
, 1, 2);
806 if (settings
->TmpDcm
!= 1 && settings
->TmpDcm
!= 2) {
807 settings
->TmpDcm
= clamp(settings
->TmpDcm
, 1, 2);
810 if (settings
->field_per_buff
!= 1 &&
811 settings
->field_per_buff
!= 2) {
812 settings
->field_per_buff
= clamp(settings
->field_per_buff
, 1, 2);
815 if (settings
->img_x
< 0) {
819 if (settings
->img_y
< 0) {
823 if (settings
->img_width
< 0 || settings
->img_width
> BUZ_MAX_WIDTH
) {
824 settings
->img_width
= clamp(settings
->img_width
, 0, (int)BUZ_MAX_WIDTH
);
827 if (settings
->img_height
< 0 || settings
->img_height
> BUZ_MAX_HEIGHT
/ 2) {
828 settings
->img_height
= clamp(settings
->img_height
, 0, BUZ_MAX_HEIGHT
/ 2);
831 if (settings
->img_x
+ settings
->img_width
> BUZ_MAX_WIDTH
) {
832 settings
->img_x
= BUZ_MAX_WIDTH
- settings
->img_width
;
835 if (settings
->img_y
+ settings
->img_height
> BUZ_MAX_HEIGHT
/ 2) {
836 settings
->img_y
= BUZ_MAX_HEIGHT
/ 2 - settings
->img_height
;
839 if (settings
->img_width
% (16 * settings
->HorDcm
) != 0) {
840 settings
->img_width
-= settings
->img_width
% (16 * settings
->HorDcm
);
841 if (settings
->img_width
== 0)
842 settings
->img_width
= 16 * settings
->HorDcm
;
845 if (settings
->img_height
% (8 * settings
->VerDcm
) != 0) {
846 settings
->img_height
-= settings
->img_height
% (8 * settings
->VerDcm
);
847 if (settings
->img_height
== 0)
848 settings
->img_height
= 8 * settings
->VerDcm
;
855 "%s: %s - error in params for decimation = 0\n",
856 ZR_DEVNAME(zr
), __func__
);
863 "%s: %s - decimation = %d, must be 0, 1, 2 or 4\n",
864 ZR_DEVNAME(zr
), __func__
, settings
->decimation
);
869 if (settings
->jpg_comp
.quality
> 100)
870 settings
->jpg_comp
.quality
= 100;
871 if (settings
->jpg_comp
.quality
< 5)
872 settings
->jpg_comp
.quality
= 5;
873 if (settings
->jpg_comp
.APPn
< 0)
874 settings
->jpg_comp
.APPn
= 0;
875 if (settings
->jpg_comp
.APPn
> 15)
876 settings
->jpg_comp
.APPn
= 15;
877 if (settings
->jpg_comp
.APP_len
< 0)
878 settings
->jpg_comp
.APP_len
= 0;
879 if (settings
->jpg_comp
.APP_len
> 60)
880 settings
->jpg_comp
.APP_len
= 60;
881 if (settings
->jpg_comp
.COM_len
< 0)
882 settings
->jpg_comp
.COM_len
= 0;
883 if (settings
->jpg_comp
.COM_len
> 60)
884 settings
->jpg_comp
.COM_len
= 60;
891 zoran_open_init_params (struct zoran
*zr
)
895 /* User must explicitly set a window */
896 zr
->overlay_settings
.is_set
= 0;
897 zr
->overlay_mask
= NULL
;
898 zr
->overlay_active
= ZORAN_FREE
;
900 zr
->v4l_memgrab_active
= 0;
901 zr
->v4l_overlay_active
= 0;
902 zr
->v4l_grab_frame
= NO_GRAB_ACTIVE
;
903 zr
->v4l_grab_seq
= 0;
904 zr
->v4l_settings
.width
= 192;
905 zr
->v4l_settings
.height
= 144;
906 zr
->v4l_settings
.format
= &zoran_formats
[7]; /* YUY2 - YUV-4:2:2 packed */
907 zr
->v4l_settings
.bytesperline
=
908 zr
->v4l_settings
.width
*
909 ((zr
->v4l_settings
.format
->depth
+ 7) / 8);
911 /* DMA ring stuff for V4L */
912 zr
->v4l_pend_tail
= 0;
913 zr
->v4l_pend_head
= 0;
914 zr
->v4l_sync_tail
= 0;
915 zr
->v4l_buffers
.active
= ZORAN_FREE
;
916 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
917 zr
->v4l_buffers
.buffer
[i
].state
= BUZ_STATE_USER
; /* nothing going on */
919 zr
->v4l_buffers
.allocated
= 0;
921 for (i
= 0; i
< BUZ_MAX_FRAME
; i
++) {
922 zr
->jpg_buffers
.buffer
[i
].state
= BUZ_STATE_USER
; /* nothing going on */
924 zr
->jpg_buffers
.active
= ZORAN_FREE
;
925 zr
->jpg_buffers
.allocated
= 0;
926 /* Set necessary params and call zoran_check_jpg_settings to set the defaults */
927 zr
->jpg_settings
.decimation
= 1;
928 zr
->jpg_settings
.jpg_comp
.quality
= 50; /* default compression factor 8 */
929 if (zr
->card
.type
!= BUZ
)
930 zr
->jpg_settings
.odd_even
= 1;
932 zr
->jpg_settings
.odd_even
= 0;
933 zr
->jpg_settings
.jpg_comp
.APPn
= 0;
934 zr
->jpg_settings
.jpg_comp
.APP_len
= 0; /* No APPn marker */
935 memset(zr
->jpg_settings
.jpg_comp
.APP_data
, 0,
936 sizeof(zr
->jpg_settings
.jpg_comp
.APP_data
));
937 zr
->jpg_settings
.jpg_comp
.COM_len
= 0; /* No COM marker */
938 memset(zr
->jpg_settings
.jpg_comp
.COM_data
, 0,
939 sizeof(zr
->jpg_settings
.jpg_comp
.COM_data
));
940 zr
->jpg_settings
.jpg_comp
.jpeg_markers
=
941 V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT
;
942 i
= zoran_check_jpg_settings(zr
, &zr
->jpg_settings
, 0);
944 dprintk(1, KERN_ERR
"%s: %s internal error\n",
945 ZR_DEVNAME(zr
), __func__
);
947 clear_interrupt_counters(zr
);
951 static void __devinit
952 test_interrupts (struct zoran
*zr
)
957 clear_interrupt_counters(zr
);
960 icr
= btread(ZR36057_ICR
);
961 btwrite(0x78000000 | ZR36057_ICR_IntPinEn
, ZR36057_ICR
);
962 prepare_to_wait(&zr
->test_q
, &wait
, TASK_INTERRUPTIBLE
);
963 timeout
= schedule_timeout(HZ
);
964 finish_wait(&zr
->test_q
, &wait
);
965 btwrite(0, ZR36057_ICR
);
966 btwrite(0x78000000, ZR36057_ISR
);
968 dprintk(5, KERN_INFO
"%s: Testing interrupts...\n", ZR_DEVNAME(zr
));
970 dprintk(1, ": time spent: %d\n", 1 * HZ
- timeout
);
972 if (zr36067_debug
> 1)
973 print_interrupts(zr
);
974 btwrite(icr
, ZR36057_ICR
);
978 zr36057_init (struct zoran
*zr
)
984 "%s: %s - initializing card[%d], zr=%p\n",
985 ZR_DEVNAME(zr
), __func__
, zr
->id
, zr
);
987 /* default setup of all parameters which will persist between opens */
990 init_waitqueue_head(&zr
->v4l_capq
);
991 init_waitqueue_head(&zr
->jpg_capq
);
992 init_waitqueue_head(&zr
->test_q
);
993 zr
->jpg_buffers
.allocated
= 0;
994 zr
->v4l_buffers
.allocated
= 0;
996 zr
->vbuf_base
= (void *) vidmem
;
1000 zr
->vbuf_bytesperline
= 0;
1002 /* Avoid nonsense settings from user for default input/norm */
1003 if (default_norm
< 0 || default_norm
> 2)
1005 if (default_norm
== 0) {
1006 zr
->norm
= V4L2_STD_PAL
;
1007 zr
->timing
= zr
->card
.tvn
[0];
1008 } else if (default_norm
== 1) {
1009 zr
->norm
= V4L2_STD_NTSC
;
1010 zr
->timing
= zr
->card
.tvn
[1];
1012 zr
->norm
= V4L2_STD_SECAM
;
1013 zr
->timing
= zr
->card
.tvn
[2];
1015 if (zr
->timing
== NULL
) {
1018 "%s: %s - default TV standard not supported by hardware. PAL will be used.\n",
1019 ZR_DEVNAME(zr
), __func__
);
1020 zr
->norm
= V4L2_STD_PAL
;
1021 zr
->timing
= zr
->card
.tvn
[0];
1024 if (default_input
> zr
->card
.inputs
-1) {
1027 "%s: default_input value %d out of range (0-%d)\n",
1028 ZR_DEVNAME(zr
), default_input
, zr
->card
.inputs
-1);
1031 zr
->input
= default_input
;
1033 /* default setup (will be repeated at every open) */
1034 zoran_open_init_params(zr
);
1036 /* allocate memory *before* doing anything to the hardware
1037 * in case allocation fails */
1038 zr
->stat_com
= kzalloc(BUZ_NUM_STAT_COM
* 4, GFP_KERNEL
);
1039 zr
->video_dev
= video_device_alloc();
1040 if (!zr
->stat_com
|| !zr
->video_dev
) {
1043 "%s: %s - kmalloc (STAT_COM) failed\n",
1044 ZR_DEVNAME(zr
), __func__
);
1048 for (j
= 0; j
< BUZ_NUM_STAT_COM
; j
++) {
1049 zr
->stat_com
[j
] = cpu_to_le32(1); /* mark as unavailable to zr36057 */
1053 * Now add the template and register the device unit.
1055 memcpy(zr
->video_dev
, &zoran_template
, sizeof(zoran_template
));
1056 zr
->video_dev
->parent
= &zr
->pci_dev
->dev
;
1057 strcpy(zr
->video_dev
->name
, ZR_DEVNAME(zr
));
1058 err
= video_register_device(zr
->video_dev
, VFL_TYPE_GRABBER
, video_nr
[zr
->id
]);
1061 video_set_drvdata(zr
->video_dev
, zr
);
1063 zoran_init_hardware(zr
);
1064 if (zr36067_debug
> 2)
1065 detect_guest_activity(zr
);
1066 test_interrupts(zr
);
1067 if (!pass_through
) {
1068 decoder_call(zr
, video
, s_stream
, 0);
1069 encoder_call(zr
, video
, s_routing
, 2, 0, 0);
1072 zr
->zoran_proc
= NULL
;
1073 zr
->initialized
= 1;
1077 kfree(zr
->stat_com
);
1078 kfree(zr
->video_dev
);
1082 static void __devexit
zoran_remove(struct pci_dev
*pdev
)
1084 struct v4l2_device
*v4l2_dev
= dev_get_drvdata(&pdev
->dev
);
1085 struct zoran
*zr
= to_zoran(v4l2_dev
);
1087 if (!zr
->initialized
)
1090 /* unregister videocodec bus */
1092 struct videocodec_master
*master
= zr
->codec
->master_data
;
1094 videocodec_detach(zr
->codec
);
1098 struct videocodec_master
*master
= zr
->vfe
->master_data
;
1100 videocodec_detach(zr
->vfe
);
1104 /* unregister i2c bus */
1105 zoran_unregister_i2c(zr
);
1106 /* disable PCI bus-mastering */
1107 zoran_set_pci_master(zr
, 0);
1108 /* put chip into reset */
1109 btwrite(0, ZR36057_SPGPPCR
);
1110 free_irq(zr
->pci_dev
->irq
, zr
);
1111 /* unmap and free memory */
1112 kfree(zr
->stat_com
);
1113 zoran_proc_cleanup(zr
);
1114 iounmap(zr
->zr36057_mem
);
1115 pci_disable_device(zr
->pci_dev
);
1116 video_unregister_device(zr
->video_dev
);
1118 v4l2_device_unregister(&zr
->v4l2_dev
);
1123 zoran_vdev_release (struct video_device
*vdev
)
1128 static struct videocodec_master
* __devinit
1129 zoran_setup_videocodec (struct zoran
*zr
,
1132 struct videocodec_master
*m
= NULL
;
1134 m
= kmalloc(sizeof(struct videocodec_master
), GFP_KERNEL
);
1136 dprintk(1, KERN_ERR
"%s: %s - no memory\n",
1137 ZR_DEVNAME(zr
), __func__
);
1141 /* magic and type are unused for master struct. Makes sense only at
1143 In the past, .type were initialized to the old V4L1 .hardware
1144 value, as VID_HARDWARE_ZR36067
1149 m
->flags
= CODEC_FLAG_ENCODER
| CODEC_FLAG_DECODER
;
1150 strlcpy(m
->name
, ZR_DEVNAME(zr
), sizeof(m
->name
));
1155 case CODEC_TYPE_ZR36060
:
1156 m
->readreg
= zr36060_read
;
1157 m
->writereg
= zr36060_write
;
1158 m
->flags
|= CODEC_FLAG_JPEG
| CODEC_FLAG_VFE
;
1160 case CODEC_TYPE_ZR36050
:
1161 m
->readreg
= zr36050_read
;
1162 m
->writereg
= zr36050_write
;
1163 m
->flags
|= CODEC_FLAG_JPEG
;
1165 case CODEC_TYPE_ZR36016
:
1166 m
->readreg
= zr36016_read
;
1167 m
->writereg
= zr36016_write
;
1168 m
->flags
|= CODEC_FLAG_VFE
;
1175 static void zoran_subdev_notify(struct v4l2_subdev
*sd
, unsigned int cmd
, void *arg
)
1177 struct zoran
*zr
= to_zoran(sd
->v4l2_dev
);
1179 /* Bt819 needs to reset its FIFO buffer using #FRST pin and
1180 LML33 card uses GPIO(7) for that. */
1181 if (cmd
== BT819_FIFO_RESET_LOW
)
1183 else if (cmd
== BT819_FIFO_RESET_HIGH
)
1188 * Scan for a Buz card (actually for the PCI controller ZR36057),
1189 * request the irq and map the io memory
1191 static int __devinit
zoran_probe(struct pci_dev
*pdev
,
1192 const struct pci_device_id
*ent
)
1194 unsigned char latency
, need_latency
;
1197 struct videocodec_master
*master_vfe
= NULL
;
1198 struct videocodec_master
*master_codec
= NULL
;
1200 char *codec_name
, *vfe_name
;
1205 if (nr
>= BUZ_MAX
) {
1206 dprintk(1, KERN_ERR
"%s: driver limited to %d card(s) maximum\n",
1207 ZORAN_NAME
, BUZ_MAX
);
1211 zr
= kzalloc(sizeof(struct zoran
), GFP_KERNEL
);
1213 dprintk(1, KERN_ERR
"%s: %s - kzalloc failed\n",
1214 ZORAN_NAME
, __func__
);
1217 zr
->v4l2_dev
.notify
= zoran_subdev_notify
;
1218 if (v4l2_device_register(&pdev
->dev
, &zr
->v4l2_dev
))
1222 snprintf(ZR_DEVNAME(zr
), sizeof(ZR_DEVNAME(zr
)), "MJPEG[%u]", zr
->id
);
1223 spin_lock_init(&zr
->spinlock
);
1224 mutex_init(&zr
->resource_lock
);
1225 mutex_init(&zr
->other_lock
);
1226 if (pci_enable_device(pdev
))
1228 zr
->revision
= zr
->pci_dev
->revision
;
1232 "%s: Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n",
1233 ZR_DEVNAME(zr
), zr
->revision
< 2 ? '5' : '6', zr
->revision
,
1234 zr
->pci_dev
->irq
, (uint64_t)pci_resource_start(zr
->pci_dev
, 0));
1235 if (zr
->revision
>= 2) {
1238 "%s: Subsystem vendor=0x%04x id=0x%04x\n",
1239 ZR_DEVNAME(zr
), zr
->pci_dev
->subsystem_vendor
,
1240 zr
->pci_dev
->subsystem_device
);
1243 /* Use auto-detected card type? */
1244 if (card
[nr
] == -1) {
1245 if (zr
->revision
< 2) {
1248 "%s: No card type specified, please use the card=X module parameter\n",
1252 "%s: It is not possible to auto-detect ZR36057 based cards\n",
1257 card_num
= ent
->driver_data
;
1258 if (card_num
>= NUM_CARDS
) {
1261 "%s: Unknown card, try specifying card=X module parameter\n",
1267 "%s: %s() - card %s detected\n",
1268 ZR_DEVNAME(zr
), __func__
, zoran_cards
[card_num
].name
);
1270 card_num
= card
[nr
];
1271 if (card_num
>= NUM_CARDS
|| card_num
< 0) {
1274 "%s: User specified card type %d out of range (0 .. %d)\n",
1275 ZR_DEVNAME(zr
), card_num
, NUM_CARDS
- 1);
1280 /* even though we make this a non pointer and thus
1281 * theoretically allow for making changes to this struct
1282 * on a per-individual card basis at runtime, this is
1283 * strongly discouraged. This structure is intended to
1284 * keep general card information, no settings or anything */
1285 zr
->card
= zoran_cards
[card_num
];
1286 snprintf(ZR_DEVNAME(zr
), sizeof(ZR_DEVNAME(zr
)),
1287 "%s[%u]", zr
->card
.name
, zr
->id
);
1289 zr
->zr36057_mem
= pci_ioremap_bar(zr
->pci_dev
, 0);
1290 if (!zr
->zr36057_mem
) {
1291 dprintk(1, KERN_ERR
"%s: %s() - ioremap failed\n",
1292 ZR_DEVNAME(zr
), __func__
);
1296 result
= request_irq(zr
->pci_dev
->irq
, zoran_irq
,
1297 IRQF_SHARED
| IRQF_DISABLED
, ZR_DEVNAME(zr
), zr
);
1299 if (result
== -EINVAL
) {
1302 "%s: %s - bad irq number or handler\n",
1303 ZR_DEVNAME(zr
), __func__
);
1304 } else if (result
== -EBUSY
) {
1307 "%s: %s - IRQ %d busy, change your PnP config in BIOS\n",
1308 ZR_DEVNAME(zr
), __func__
, zr
->pci_dev
->irq
);
1312 "%s: %s - can't assign irq, error code %d\n",
1313 ZR_DEVNAME(zr
), __func__
, result
);
1318 /* set PCI latency timer */
1319 pci_read_config_byte(zr
->pci_dev
, PCI_LATENCY_TIMER
,
1321 need_latency
= zr
->revision
> 1 ? 32 : 48;
1322 if (latency
!= need_latency
) {
1323 dprintk(2, KERN_INFO
"%s: Changing PCI latency from %d to %d\n",
1324 ZR_DEVNAME(zr
), latency
, need_latency
);
1325 pci_write_config_byte(zr
->pci_dev
, PCI_LATENCY_TIMER
,
1329 zr36057_restart(zr
);
1331 dprintk(2, KERN_INFO
"%s: Initializing i2c bus...\n",
1334 if (zoran_register_i2c(zr
) < 0) {
1335 dprintk(1, KERN_ERR
"%s: %s - can't initialize i2c bus\n",
1336 ZR_DEVNAME(zr
), __func__
);
1340 zr
->decoder
= v4l2_i2c_new_subdev(&zr
->v4l2_dev
,
1341 &zr
->i2c_adapter
, zr
->card
.i2c_decoder
,
1342 0, zr
->card
.addrs_decoder
);
1344 if (zr
->card
.i2c_encoder
)
1345 zr
->encoder
= v4l2_i2c_new_subdev(&zr
->v4l2_dev
,
1346 &zr
->i2c_adapter
, zr
->card
.i2c_encoder
,
1347 0, zr
->card
.addrs_encoder
);
1350 KERN_INFO
"%s: Initializing videocodec bus...\n",
1353 if (zr
->card
.video_codec
) {
1354 codec_name
= codecid_to_modulename(zr
->card
.video_codec
);
1356 result
= request_module(codec_name
);
1360 "%s: failed to load modules %s: %d\n",
1361 ZR_DEVNAME(zr
), codec_name
, result
);
1365 if (zr
->card
.video_vfe
) {
1366 vfe_name
= codecid_to_modulename(zr
->card
.video_vfe
);
1368 result
= request_module(vfe_name
);
1372 "%s: failed to load modules %s: %d\n",
1373 ZR_DEVNAME(zr
), vfe_name
, result
);
1378 /* reset JPEG codec */
1379 jpeg_codec_sleep(zr
, 1);
1380 jpeg_codec_reset(zr
);
1381 /* video bus enabled */
1382 /* display codec revision */
1383 if (zr
->card
.video_codec
!= 0) {
1384 master_codec
= zoran_setup_videocodec(zr
, zr
->card
.video_codec
);
1387 zr
->codec
= videocodec_attach(master_codec
);
1389 dprintk(1, KERN_ERR
"%s: %s - no codec found\n",
1390 ZR_DEVNAME(zr
), __func__
);
1393 if (zr
->codec
->type
!= zr
->card
.video_codec
) {
1394 dprintk(1, KERN_ERR
"%s: %s - wrong codec\n",
1395 ZR_DEVNAME(zr
), __func__
);
1396 goto zr_detach_codec
;
1399 if (zr
->card
.video_vfe
!= 0) {
1400 master_vfe
= zoran_setup_videocodec(zr
, zr
->card
.video_vfe
);
1402 goto zr_detach_codec
;
1403 zr
->vfe
= videocodec_attach(master_vfe
);
1405 dprintk(1, KERN_ERR
"%s: %s - no VFE found\n",
1406 ZR_DEVNAME(zr
), __func__
);
1409 if (zr
->vfe
->type
!= zr
->card
.video_vfe
) {
1410 dprintk(1, KERN_ERR
"%s: %s = wrong VFE\n",
1411 ZR_DEVNAME(zr
), __func__
);
1416 /* take care of Natoma chipset and a revision 1 zr36057 */
1417 if ((pci_pci_problems
& PCIPCI_NATOMA
) && zr
->revision
<= 1) {
1418 zr
->jpg_buffers
.need_contiguous
= 1;
1419 dprintk(1, KERN_INFO
1420 "%s: ZR36057/Natoma bug, max. buffer size is 128K\n",
1424 if (zr36057_init(zr
) < 0)
1427 zoran_proc_init(zr
);
1432 videocodec_detach(zr
->vfe
);
1436 videocodec_detach(zr
->codec
);
1438 kfree(master_codec
);
1440 zoran_unregister_i2c(zr
);
1442 btwrite(0, ZR36057_SPGPPCR
);
1443 free_irq(zr
->pci_dev
->irq
, zr
);
1445 iounmap(zr
->zr36057_mem
);
1447 v4l2_device_unregister(&zr
->v4l2_dev
);
1454 static struct pci_driver zoran_driver
= {
1456 .id_table
= zr36067_pci_tbl
,
1457 .probe
= zoran_probe
,
1458 .remove
= __devexit_p(zoran_remove
),
1461 static int __init
zoran_init(void)
1465 printk(KERN_INFO
"Zoran MJPEG board driver version %s\n",
1468 /* check the parameters we have been given, adjust if necessary */
1471 if (v4l_nbufs
> VIDEO_MAX_FRAME
)
1472 v4l_nbufs
= VIDEO_MAX_FRAME
;
1473 /* The user specfies the in KB, we want them in byte
1474 * (and page aligned) */
1475 v4l_bufsize
= PAGE_ALIGN(v4l_bufsize
* 1024);
1476 if (v4l_bufsize
< 32768)
1477 v4l_bufsize
= 32768;
1478 /* 2 MB is arbitrary but sufficient for the maximum possible images */
1479 if (v4l_bufsize
> 2048 * 1024)
1480 v4l_bufsize
= 2048 * 1024;
1483 if (jpg_nbufs
> BUZ_MAX_FRAME
)
1484 jpg_nbufs
= BUZ_MAX_FRAME
;
1485 jpg_bufsize
= PAGE_ALIGN(jpg_bufsize
* 1024);
1486 if (jpg_bufsize
< 8192)
1488 if (jpg_bufsize
> (512 * 1024))
1489 jpg_bufsize
= 512 * 1024;
1490 /* Use parameter for vidmem or try to find a video card */
1494 "%s: Using supplied video memory base address @ 0x%lx\n",
1495 ZORAN_NAME
, vidmem
);
1498 /* some mainboards might not do PCI-PCI data transfer well */
1499 if (pci_pci_problems
& (PCIPCI_FAIL
|PCIAGP_FAIL
|PCIPCI_ALIMAGIK
)) {
1502 "%s: chipset does not support reliable PCI-PCI DMA\n",
1506 res
= pci_register_driver(&zoran_driver
);
1510 "%s: Unable to register ZR36057 driver\n",
1518 static void __exit
zoran_exit(void)
1520 pci_unregister_driver(&zoran_driver
);
1523 module_init(zoran_init
);
1524 module_exit(zoran_exit
);