Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 94814
Collapse All | Expand All

(-)linux-2.6.11/Documentation/scsi-changer.txt (+180 lines)
Added Link Here
1
2
README for the SCSI media changer driver
3
========================================
4
5
This is a driver for SCSI Medium Changer devices, which are listed
6
with "Type: Medium Changer" in /proc/scsi/scsi.
7
8
This is for *real* Jukeboxes.  It is *not* supported to work with
9
common small CD-ROM changers, neither one-lun-per-slot SCSI changers
10
nor IDE drives.
11
12
Userland tools available from here:
13
	http://linux.bytesex.org/misc/changer.html
14
15
16
General Information
17
-------------------
18
19
First some words about how changers work: A changer has 2 (possibly
20
more) SCSI ID's. One for the changer device which controls the robot,
21
and one for the device which actually reads and writes the data. The
22
later may be anything, a MOD, a CD-ROM, a tape or whatever. For the
23
changer device this is a "don't care", he *only* shuffles around the
24
media, nothing else.
25
26
27
The SCSI changer model is complex, compared to - for example - IDE-CD
28
changers. But it allows to handle nearly all possible cases. It knows
29
4 different types of changer elements:
30
31
  media transport - this one shuffles around the media, i.e. the
32
                    transport arm.  Also known as "picker".
33
  storage         - a slot which can hold a media.
34
  import/export   - the same as above, but is accessable from outside,
35
                    i.e. there the operator (you !) can use this to
36
                    fill in and remove media from the changer.
37
		    Sometimes named "mailslot".
38
  data transfer   - this is the device which reads/writes, i.e. the
39
		    CD-ROM / Tape / whatever drive.
40
41
None of these is limited to one: A huge Jukebox could have slots for
42
123 CD-ROM's, 5 CD-ROM readers (and therefore 6 SCSI ID's: the changer
43
and each CD-ROM) and 2 transport arms. No problem to handle.
44
45
46
How it is implemented
47
---------------------
48
49
I implemented the driver as character device driver with a NetBSD-like
50
ioctl interface. Just grabbed NetBSD's header file and one of the
51
other linux SCSI device drivers as starting point. The interface
52
should be source code compatible with NetBSD. So if there is any
53
software (anybody knows ???) which supports a BSDish changer driver,
54
it should work with this driver too.
55
56
Over time a few more ioctls where added, volume tag support for example
57
wasn't covered by the NetBSD ioctl API.
58
59
60
Current State
61
-------------
62
63
Support for more than one transport arm is not implemented yet (and
64
nobody asked for it so far...).
65
66
I test and use the driver myself with a 35 slot cdrom jukebox from
67
Grundig.  I got some reports telling it works ok with tape autoloaders
68
(Exabyte, HP and DEC).  Some People use this driver with amanda.  It
69
works fine with small (11 slots) and a huge (4 MOs, 88 slots)
70
magneto-optical Jukebox.  Probably with lots of other changers too, most
71
(but not all :-) people mail me only if it does *not* work...
72
73
I don't have any device lists, neither black-list nor white-list.  Thus
74
it is quite useless to ask me whenever a specific device is supported or
75
not.  In theory every changer device which supports the SCSI-2 media
76
changer command set should work out-of-the-box with this driver.  If it
77
doesn't, it is a bug.  Either within the driver or within the firmware
78
of the changer device.
79
80
81
Using it
82
--------
83
84
This is a character device with major number is 86, so use
85
"mknod /dev/sch0 c 86 0" to create the special file for the driver.
86
87
If the module finds the changer, it prints some messages about the
88
device [ try "dmesg" if you don't see anything ] and should show up in
89
/proc/devices. If not....  some changers use ID ? / LUN 0 for the
90
device and ID ? / LUN 1 for the robot mechanism. But Linux does *not*
91
look for LUN's other than 0 as default, becauce there are to many
92
broken devices. So you can try:
93
94
  1) echo "scsi add-single-device 0 0 ID 1" > /proc/scsi/scsi
95
     (replace ID with the SCSI-ID of the device)
96
  2) boot the kernel with "max_scsi_luns=1" on the command line
97
     (append="max_scsi_luns=1" in lilo.conf should do the trick)
98
99
100
Trouble?
101
--------
102
103
If you insmod the driver with "insmod debug=1", it will be verbose and
104
prints a lot of stuff to the syslog.  Compiling the kernel with
105
CONFIG_SCSI_CONSTANTS=y improves the quality of the error messages alot
106
because the kernel will translate the error codes into human-readable
107
strings then.
108
109
You can display these messages with the dmesg command (or check the
110
logfiles).  If you email me some question becauce of a problem with the
111
driver, please include these messages.
112
113
114
Insmod options
115
--------------
116
117
debug=0/1
118
	Enable debug messages (see above, default: 0).
119
120
verbose=0/1
121
	Be verbose (default: 1).
122
123
init=0/1
124
	Send INITIALIZE ELEMENT STATUS command to the changer
125
	at insmod time (default: 1).
126
127
timeout_init=<seconds>
128
	timeout for the INITIALIZE ELEMENT STATUS command
129
	(default: 3600).
130
131
timeout_move=<seconds>
132
	timeout for all other commands (default: 120).
133
134
dt_id=<id1>,<id2>,...
135
dt_lun=<lun1>,<lun2>,...
136
	These two allow to specify the SCSI ID and LUN for the data
137
	transfer elements.  You likely don't need this as the jukebox
138
	should provide this information.  But some devices don't ...
139
140
vendor_firsts=
141
vendor_counts=
142
vendor_labels=
143
	These insmod options can be used to tell the driver that there
144
	are some vendor-specific element types.  Grundig for example
145
	does this.  Some jukeboxes have a printer to label fresh burned
146
	CDs, which is addressed as element 0xc000 (type 5).  To tell the
147
	driver about this vendor-specific element, use this:
148
		$ insmod ch			\
149
			vendor_firsts=0xc000	\
150
			vendor_counts=1		\
151
			vendor_labels=printer
152
	All three insmod options accept up to four comma-separated
153
	values, this way you can configure the element types 5-8.
154
	You likely need the SCSI specs for the device in question to
155
	find the correct values as they are not covered by the SCSI-2
156
	standard.
157
158
159
Credits
160
-------
161
162
I wrote this driver using the famous mailing-patches-around-the-world
163
method.  With (more or less) help from:
164
165
	Daniel Moehwald <moehwald@hdg.de>
166
	Dane Jasper <dane@sonic.net>
167
	R. Scott Bailey <sbailey@dsddi.eds.com>
168
	Jonathan Corbet <corbet@lwn.net>
169
170
Special thanks go to
171
	Martin Kuehne <martin.kuehne@bnbt.de>
172
for a old, second-hand (but full functional) cdrom jukebox which I use
173
to develop/test driver and tools now.
174
175
Have fun,
176
177
   Gerd
178
179
-- 
180
Gerd Knorr <kraxel@bytesex.org>
(-)linux-2.6.11.orig/Documentation/video4linux/CARDLIST.saa7134 (-20 / +21 lines)
Lines 6-34 Link Here
6
  5 -> SKNet Monster TV                         [1131:4e85]
6
  5 -> SKNet Monster TV                         [1131:4e85]
7
  6 -> Tevion MD 9717                          
7
  6 -> Tevion MD 9717                          
8
  7 -> KNC One TV-Station RDS / Typhoon TV Tuner RDS [1131:fe01,1894:fe01]
8
  7 -> KNC One TV-Station RDS / Typhoon TV Tuner RDS [1131:fe01,1894:fe01]
9
  8 -> KNC One TV-Station DVR                   [1894:a006]
9
  8 -> Terratec Cinergy 400 TV                  [153B:1142]
10
  9 -> Terratec Cinergy 400 TV                  [153B:1142]
10
  9 -> Medion 5044                             
11
 10 -> Medion 5044
11
 10 -> Kworld/KuroutoShikou SAA7130-TVPCI      
12
 11 -> Kworld/KuroutoShikou SAA7130-TVPCI
12
 11 -> Terratec Cinergy 600 TV                  [153B:1143]
13
 12 -> Terratec Cinergy 600 TV                  [153B:1143]
13
 12 -> Medion 7134                              [16be:0003]
14
 13 -> Medion 7134                              [16be:0003]
14
 13 -> Typhoon TV+Radio 90031                  
15
 14 -> Typhoon TV+Radio 90031
15
 14 -> ELSA EX-VISION 300TV                     [1048:226b]
16
 15 -> ELSA EX-VISION 300TV                     [1048:226b]
16
 15 -> ELSA EX-VISION 500TV                     [1048:226b]
17
 16 -> ELSA EX-VISION 500TV                     [1048:226b]
17
 16 -> ASUS TV-FM 7134                          [1043:4842,1043:4830,1043:4840]
18
 17 -> ASUS TV-FM 7134                          [1043:4842,1043:4830,1043:4840]
18
 17 -> AOPEN VA1000 POWER                       [1131:7133]
19
 18 -> AOPEN VA1000 POWER                       [1131:7133]
19
 18 -> BMK MPEX No Tuner                       
20
 19 -> 10MOONS PCI TV CAPTURE CARD              [1131:2001]
20
 19 -> Compro VideoMate TV                      [185b:c100]
21
 20 -> BMK MPEX No Tuner
21
 20 -> Matrox CronosPlus                        [102B:48d0]
22
 21 -> Compro VideoMate TV                      [185b:c100]
22
 21 -> 10MOONS PCI TV CAPTURE CARD              [1131:2001]
23
 22 -> Matrox CronosPlus                        [102B:48d0]
23
 22 -> Medion 2819/ AverMedia M156              [1461:a70b,1461:2115]
24
 23 -> Medion 2819/ AverMedia M156              [1461:a70b,1461:2115]
24
 23 -> BMK MPEX Tuner                          
25
 24 -> BMK MPEX Tuner
25
 24 -> KNC One TV-Station DVR                   [1894:a006]
26
 25 -> ASUS TV-FM 7133                          [1043:4843]
26
 25 -> ASUS TV-FM 7133                          [1043:4843]
27
 26 -> Pinnacle PCTV Stereo (saa7134)           [11bd:002b]
27
 26 -> Pinnacle PCTV Stereo (saa7134)           [11bd:002b]
28
 27 -> Manli MuchTV M-TV002
28
 27 -> Manli MuchTV M-TV002                    
29
 28 -> Manli MuchTV M-TV001
29
 28 -> Manli MuchTV M-TV001                    
30
 29 -> Nagase Sangyo TransGear 3000TV           [1461:050c]
30
 29 -> Nagase Sangyo TransGear 3000TV           [1461:050c]
31
 30 -> Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM)  [1019:4cb4]
31
 30 -> Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM)  [1019:4cb4]
32
 31 -> Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM) [1019:4cb5]
32
 31 -> Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM) [1019:4cb5]
33
 32 -> AVACS SmartTV
33
 32 -> AVACS SmartTV                           
34
 33 -> AVerMedia DVD EZMaker                    [1461:10ff]
34
 33 -> AVerMedia DVD EZMaker                    [1461:10ff]
35
 34 -> LifeView FlyTV Platinum33 mini           [5168:0212]
(-)linux-2.6.11.orig/Documentation/video4linux/README.cx88 (-3 lines)
Lines 11-19 current status Link Here
11
video
11
video
12
	- Basically works.
12
	- Basically works.
13
	- Some minor image quality glitches.
13
	- Some minor image quality glitches.
14
	- Red and blue are swapped sometimes for not-yet known
15
	  reasons (seems to depend on the image size, try to resize
16
	  your tv app window as workaround ...).
17
	- For now only capture, overlay support isn't completed yet.
14
	- For now only capture, overlay support isn't completed yet.
18
15
19
audio
16
audio
(-)linux-2.6.11.orig/Documentation/video4linux/bttv/Cards (-2 / +5 lines)
Lines 1-9 Link Here
1
1
2
Gunther Mayer's bttv card gallery (graphical version of this text file :-)
2
Gunther Mayer's bttv card gallery (graphical version of this text file :-)
3
is available at: http://mayerg.gmxhome.de/bttv/bttv-gallery.html
3
is available at: http://www.bttv-gallery.de/
4
4
5
5
6
Suppported cards:
6
Supported cards:
7
Bt848/Bt848a/Bt849/Bt878/Bt879 cards
7
Bt848/Bt848a/Bt849/Bt878/Bt879 cards
8
------------------------------------
8
------------------------------------
9
9
Lines 166-171 Lifeview Flyvideo Series: Link Here
166
	        or Flyvideo 3000 (SAA7134) w/Stereo TV
166
	        or Flyvideo 3000 (SAA7134) w/Stereo TV
167
		   These exist in variations w/FM and w/Remote sometimes denoted
167
		   These exist in variations w/FM and w/Remote sometimes denoted
168
		   by suffixes "FM" and "R".
168
		   by suffixes "FM" and "R".
169
  3) You have a laptop (miniPCI card):
170
      Product    = FlyTV Platinum Mini
171
      Model/Chip = LR212/saa7135      
169
172
170
      Lifeview.com.tw states (Feb. 2002):
173
      Lifeview.com.tw states (Feb. 2002):
171
      "The FlyVideo2000 and FlyVideo2000s product name have renamed to FlyVideo98."
174
      "The FlyVideo2000 and FlyVideo2000s product name have renamed to FlyVideo98."
(-)linux-2.6.11.orig/Documentation/video4linux/bttv/README (-1 / +1 lines)
Lines 22-28 very likely specified the wrong (or no) Link Here
22
cards is in CARDLIST.bttv
22
cards is in CARDLIST.bttv
23
23
24
If bttv takes very long to load (happens sometimes with the cheap
24
If bttv takes very long to load (happens sometimes with the cheap
25
cards which have no tuner), try adding this to your modprobe.conf:
25
cards which have no tuner), try adding this to your modules.conf:
26
	options i2c-algo-bit bit_test=1
26
	options i2c-algo-bit bit_test=1
27
27
28
For the WinTV/PVR you need one firmware file from the driver CD:
28
For the WinTV/PVR you need one firmware file from the driver CD:
(-)linux-2.6.11.orig/MAINTAINERS (-2 / +3 lines)
Lines 501-507 P: Gerd Knorr Link Here
501
M:	kraxel@bytesex.org
501
M:	kraxel@bytesex.org
502
L:	video4linux-list@redhat.com
502
L:	video4linux-list@redhat.com
503
W:	http://bytesex.org/bttv/
503
W:	http://bytesex.org/bttv/
504
S:	Maintained
504
S:	Orphan
505
505
506
BUSLOGIC SCSI DRIVER
506
BUSLOGIC SCSI DRIVER
507
P:	Leonard N. Zubkoff
507
P:	Leonard N. Zubkoff
Lines 2534-2540 S: Maintained Link Here
2534
VIDEO FOR LINUX
2534
VIDEO FOR LINUX
2535
P:	Gerd Knorr
2535
P:	Gerd Knorr
2536
M:	kraxel@bytesex.org
2536
M:	kraxel@bytesex.org
2537
S:	Maintained
2537
L:	video4linux-list@redhat.com
2538
S:	Orphan
2538
2539
2539
W1 DALLAS'S 1-WIRE BUS
2540
W1 DALLAS'S 1-WIRE BUS
2540
P:	Evgeniy Polyakov
2541
P:	Evgeniy Polyakov
(-)linux-2.6.11.orig/arch/x86_64/ia32/ia32_ioctl.c (-20 lines)
Lines 18-42 Link Here
18
#define CODE
18
#define CODE
19
#include "compat_ioctl.c"
19
#include "compat_ioctl.c"
20
  
20
  
21
#ifndef TIOCGDEV
22
#define TIOCGDEV       _IOR('T',0x32, unsigned int)
23
#endif
24
static int tiocgdev(unsigned fd, unsigned cmd,  unsigned int __user *ptr) 
25
{ 
26
27
	struct file *file = fget(fd);
28
	struct tty_struct *real_tty;
29
30
	if (!file)
31
		return -EBADF;
32
	if (file->f_op->ioctl != tty_ioctl)
33
		return -EINVAL; 
34
	real_tty = (struct tty_struct *)file->private_data;
35
	if (!real_tty) 	
36
		return -EINVAL; 
37
	return put_user(new_encode_dev(tty_devnum(real_tty)), ptr); 
38
} 
39
40
#define RTC_IRQP_READ32	_IOR('p', 0x0b, unsigned int)	 /* Read IRQ rate   */
21
#define RTC_IRQP_READ32	_IOR('p', 0x0b, unsigned int)	 /* Read IRQ rate   */
41
#define RTC_IRQP_SET32	_IOW('p', 0x0c, unsigned int)	 /* Set IRQ rate    */
22
#define RTC_IRQP_SET32	_IOW('p', 0x0c, unsigned int)	 /* Set IRQ rate    */
42
#define RTC_EPOCH_READ32	_IOR('p', 0x0d, unsigned)	 /* Read epoch      */
23
#define RTC_EPOCH_READ32	_IOR('p', 0x0d, unsigned)	 /* Read epoch      */
Lines 176-182 COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - Link Here
176
COMPATIBLE_IOCTL(FIOQSIZE)
157
COMPATIBLE_IOCTL(FIOQSIZE)
177
158
178
/* And these ioctls need translation */
159
/* And these ioctls need translation */
179
HANDLE_IOCTL(TIOCGDEV, tiocgdev)
180
/* realtime device */
160
/* realtime device */
181
HANDLE_IOCTL(RTC_IRQP_READ,  rtc32_ioctl)
161
HANDLE_IOCTL(RTC_IRQP_READ,  rtc32_ioctl)
182
HANDLE_IOCTL(RTC_IRQP_READ32,rtc32_ioctl)
162
HANDLE_IOCTL(RTC_IRQP_READ32,rtc32_ioctl)
(-)linux-2.6.11.orig/drivers/char/tty_io.c (+15 lines)
Lines 2369-2374 int tty_ioctl(struct inode * inode, stru Link Here
2369
		case TIOCMBIC:
2369
		case TIOCMBIC:
2370
		case TIOCMBIS:
2370
		case TIOCMBIS:
2371
			return tty_tiocmset(tty, file, cmd, p);
2371
			return tty_tiocmset(tty, file, cmd, p);
2372
		/*
2373
		 * Without the real device to which /dev/console is connected,
2374
		 * blogd can not work.
2375
		 *	blogd spawns a pty/tty pair,
2376
		 *	set /dev/console to the tty of that pair (ioctl TIOCCONS),
2377
		 *	then reads in all input from the current /dev/console,
2378
		 *	buffer or write the readed data to /var/log/boot.msg
2379
		 *	_and_ to the original real device.
2380
		 */
2381
		case TIOCGDEV:
2382
		{
2383
			unsigned int ret = new_encode_dev(tty_devnum(real_tty));
2384
			return put_user(ret, (unsigned int __user *)p);
2385
		}
2386
2372
	}
2387
	}
2373
	if (tty->driver->ioctl) {
2388
	if (tty->driver->ioctl) {
2374
		retval = (tty->driver->ioctl)(tty, file, cmd, arg);
2389
		retval = (tty->driver->ioctl)(tty, file, cmd, arg);
(-)linux-2.6.11.orig/drivers/media/common/ir-common.c (-2 / +162 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: ir-common.c,v 1.6 2004/12/10 12:33:39 kraxel Exp $
2
 * $Id: ir-common.c,v 1.8 2005/02/22 12:28:40 kraxel Exp $
3
 *
3
 *
4
 * some common structs and functions to handle infrared remotes via
4
 * some common structs and functions to handle infrared remotes via
5
 * input layer ...
5
 * input layer ...
Lines 23-29 Link Here
23
23
24
#include <linux/module.h>
24
#include <linux/module.h>
25
#include <linux/moduleparam.h>
25
#include <linux/moduleparam.h>
26
27
#include <media/ir-common.h>
26
#include <media/ir-common.h>
28
27
29
/* -------------------------------------------------------------------------- */
28
/* -------------------------------------------------------------------------- */
Lines 45-50 module_param(debug, int, 0644); Link Here
45
44
46
/* generic RC5 keytable                                          */
45
/* generic RC5 keytable                                          */
47
/* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */
46
/* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */
47
/* used by old (black) Hauppauge remotes                         */
48
IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE] = {
48
IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE] = {
49
	[ 0x00 ] = KEY_KP0,             // 0
49
	[ 0x00 ] = KEY_KP0,             // 0
50
	[ 0x01 ] = KEY_KP1,             // 1
50
	[ 0x01 ] = KEY_KP1,             // 1
Lines 117-128 IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB Link Here
117
};
117
};
118
EXPORT_SYMBOL_GPL(ir_codes_rc5_tv);
118
EXPORT_SYMBOL_GPL(ir_codes_rc5_tv);
119
119
120
/* Table for Leadtek Winfast Remote Controls - used by both bttv and cx88 */
121
IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
122
	[  5 ] = KEY_KP1,
123
	[  6 ] = KEY_KP2,
124
	[  7 ] = KEY_KP3,
125
	[  9 ] = KEY_KP4,
126
	[ 10 ] = KEY_KP5,
127
	[ 11 ] = KEY_KP6,
128
	[ 13 ] = KEY_KP7,
129
	[ 14 ] = KEY_KP8,
130
	[ 15 ] = KEY_KP9,
131
	[ 18 ] = KEY_KP0,
132
133
	[  0 ] = KEY_POWER,
134
//      [ 27 ] = MTS button
135
	[  2 ] = KEY_TUNER,     // TV/FM
136
	[ 30 ] = KEY_VIDEO,
137
//      [ 22 ] = display button
138
	[  4 ] = KEY_VOLUMEUP,
139
	[  8 ] = KEY_VOLUMEDOWN,
140
	[ 12 ] = KEY_CHANNELUP,
141
	[ 16 ] = KEY_CHANNELDOWN,
142
	[  3 ] = KEY_ZOOM,      // fullscreen
143
	[ 31 ] = KEY_SUBTITLE,  // closed caption/teletext
144
	[ 32 ] = KEY_SLEEP,
145
//      [ 41 ] = boss key
146
	[ 20 ] = KEY_MUTE,
147
	[ 43 ] = KEY_RED,
148
	[ 44 ] = KEY_GREEN,
149
	[ 45 ] = KEY_YELLOW,
150
	[ 46 ] = KEY_BLUE,
151
	[ 24 ] = KEY_KPPLUS,    //fine tune +
152
	[ 25 ] = KEY_KPMINUS,   //fine tune -
153
//      [ 42 ] = picture in picture
154
        [ 33 ] = KEY_KPDOT,
155
	[ 19 ] = KEY_KPENTER,
156
//      [ 17 ] = recall
157
	[ 34 ] = KEY_BACK,
158
	[ 35 ] = KEY_PLAYPAUSE,
159
	[ 36 ] = KEY_NEXT,
160
//      [ 37 ] = time shifting
161
	[ 38 ] = KEY_STOP,
162
	[ 39 ] = KEY_RECORD
163
//      [ 40 ] = snapshot
164
};
165
EXPORT_SYMBOL_GPL(ir_codes_winfast);
166
120
/* empty keytable, can be used as placeholder for not-yet created keytables */
167
/* empty keytable, can be used as placeholder for not-yet created keytables */
121
IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = {
168
IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = {
122
	[ 42 ] = KEY_COFFEE,
169
	[ 42 ] = KEY_COFFEE,
123
};
170
};
124
EXPORT_SYMBOL_GPL(ir_codes_empty);
171
EXPORT_SYMBOL_GPL(ir_codes_empty);
125
172
173
/* Hauppauge: the newer, gray remotes (seems there are multiple
174
 * slightly different versions), shipped with cx88+ivtv cards.
175
 * almost rc5 coding, but some non-standard keys */
176
IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE] = {
177
	[ 0x00 ] = KEY_KP0,             // 0
178
	[ 0x01 ] = KEY_KP1,             // 1
179
	[ 0x02 ] = KEY_KP2,             // 2
180
	[ 0x03 ] = KEY_KP3,             // 3
181
	[ 0x04 ] = KEY_KP4,             // 4
182
	[ 0x05 ] = KEY_KP5,             // 5
183
	[ 0x06 ] = KEY_KP6,             // 6
184
	[ 0x07 ] = KEY_KP7,             // 7
185
	[ 0x08 ] = KEY_KP8,             // 8
186
	[ 0x09 ] = KEY_KP9,             // 9
187
	[ 0x0b ] = KEY_RED,             // red button
188
	[ 0x0c ] = KEY_OPTION,          // black key without text
189
	[ 0x0d ] = KEY_MENU,            // menu
190
	[ 0x0f ] = KEY_MUTE,            // mute
191
	[ 0x10 ] = KEY_VOLUMEUP,        // volume +
192
	[ 0x11 ] = KEY_VOLUMEDOWN,      // volume -
193
	[ 0x1e ] = KEY_NEXT,            // skip >|
194
	[ 0x1f ] = KEY_EXIT,            // back/exit
195
	[ 0x20 ] = KEY_CHANNELUP,       // channel / program +
196
	[ 0x21 ] = KEY_CHANNELDOWN,     // channel / program -
197
	[ 0x22 ] = KEY_CHANNEL,         // source (old black remote)
198
	[ 0x24 ] = KEY_PREVIOUS,        // replay |<
199
	[ 0x25 ] = KEY_ENTER,           // OK
200
	[ 0x26 ] = KEY_SLEEP,           // minimize (old black remote)
201
	[ 0x29 ] = KEY_BLUE,            // blue key
202
	[ 0x2e ] = KEY_GREEN,           // green button
203
	[ 0x30 ] = KEY_PAUSE,           // pause
204
	[ 0x32 ] = KEY_REWIND,          // backward <<
205
	[ 0x34 ] = KEY_FASTFORWARD,     // forward >>
206
	[ 0x35 ] = KEY_PLAY,            // play
207
	[ 0x36 ] = KEY_STOP,            // stop
208
	[ 0x37 ] = KEY_RECORD,          // recording
209
	[ 0x38 ] = KEY_YELLOW,          // yellow key
210
	[ 0x3b ] = KEY_SELECT,          // top right button
211
	[ 0x3c ] = KEY_ZOOM,            // full
212
	[ 0x3d ] = KEY_POWER,           // system power (green button)
213
};
214
EXPORT_SYMBOL(ir_codes_hauppauge_new);
215
126
/* -------------------------------------------------------------------------- */
216
/* -------------------------------------------------------------------------- */
127
217
128
static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
218
static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
Lines 192-197 void ir_input_keydown(struct input_dev * Link Here
192
#endif
282
#endif
193
}
283
}
194
284
285
/* -------------------------------------------------------------------------- */
286
195
u32 ir_extract_bits(u32 data, u32 mask)
287
u32 ir_extract_bits(u32 data, u32 mask)
196
{
288
{
197
	int mbit, vbit;
289
	int mbit, vbit;
Lines 209-218 u32 ir_extract_bits(u32 data, u32 mask) Link Here
209
	return value;
301
	return value;
210
}
302
}
211
303
304
static int inline getbit(u32 *samples, int bit)
305
{
306
	return (samples[bit/32] & (1 << (31-(bit%32)))) ? 1 : 0;
307
}
308
309
/* sump raw samples for visual debugging ;) */
310
int ir_dump_samples(u32 *samples, int count)
311
{
312
	int i, bit, start;
313
314
	printk(KERN_DEBUG "ir samples: ");
315
	start = 0;
316
	for (i = 0; i < count * 32; i++) {
317
		bit = getbit(samples,i);
318
		if (bit)
319
			start = 1;
320
		if (0 == start)
321
			continue;
322
		printk("%s", bit ? "#" : "_");
323
	}
324
	printk("\n");
325
	return 0;
326
}
327
328
/* decode raw samples, biphase coding, used by rc5 for example */
329
int ir_decode_biphase(u32 *samples, int count, int low, int high)
330
{
331
	int i,last,bit,len,flips;
332
	u32 value;
333
334
	/* find start bit (1) */
335
	for (i = 0; i < 32; i++) {
336
		bit = getbit(samples,i);
337
		if (bit)
338
			break;
339
	}
340
341
	/* go decoding */
342
	len   = 0;
343
	flips = 0;
344
	value = 1;
345
	for (; i < count * 32; i++) {
346
		if (len > high)
347
			break;
348
		if (flips > 1)
349
			break;
350
		last = bit;
351
		bit  = getbit(samples,i);
352
		if (last == bit) {
353
			len++;
354
			continue;
355
		}
356
		if (len < low) {
357
			len++;
358
			flips++;
359
			continue;
360
		}
361
		value <<= 1;
362
		value |= bit;
363
		flips = 0;
364
		len   = 1;
365
	}
366
	return value;
367
}
368
212
EXPORT_SYMBOL_GPL(ir_input_init);
369
EXPORT_SYMBOL_GPL(ir_input_init);
213
EXPORT_SYMBOL_GPL(ir_input_nokey);
370
EXPORT_SYMBOL_GPL(ir_input_nokey);
214
EXPORT_SYMBOL_GPL(ir_input_keydown);
371
EXPORT_SYMBOL_GPL(ir_input_keydown);
372
215
EXPORT_SYMBOL_GPL(ir_extract_bits);
373
EXPORT_SYMBOL_GPL(ir_extract_bits);
374
EXPORT_SYMBOL_GPL(ir_dump_samples);
375
EXPORT_SYMBOL_GPL(ir_decode_biphase);
216
376
217
/*
377
/*
218
 * Local variables:
378
 * Local variables:
(-)linux-2.6.11.orig/drivers/media/dvb/dvb-core/dvb_frontend.c (+21 lines)
Lines 919-921 int dvb_unregister_frontend(struct dvb_f Link Here
919
	return 0;
919
	return 0;
920
}
920
}
921
EXPORT_SYMBOL(dvb_unregister_frontend);
921
EXPORT_SYMBOL(dvb_unregister_frontend);
922
923
void dvb_suspend_frontend(struct dvb_frontend* fe)
924
{
925
	if (fe->ops->sleep)
926
		fe->ops->sleep(fe);
927
}
928
EXPORT_SYMBOL(dvb_suspend_frontend);
929
930
void dvb_resume_frontend(struct dvb_frontend* fe)
931
{
932
	struct dvb_frontend_private *fepriv = fe->frontend_priv;
933
934
	if (fe->ops->init)
935
		fe->ops->init(fe);
936
	fepriv->state = FESTATE_RETUNE;
937
	dvb_frontend_wakeup(fe);
938
	dvb_frontend_add_event (fe, 0);	    
939
	fepriv->status = 0;
940
}
941
EXPORT_SYMBOL(dvb_resume_frontend);
942
(-)linux-2.6.11.orig/drivers/media/dvb/dvb-core/dvb_frontend.h (+2 lines)
Lines 122-126 extern int dvb_register_frontend(struct Link Here
122
				 struct dvb_frontend* fe);
122
				 struct dvb_frontend* fe);
123
123
124
extern int dvb_unregister_frontend(struct dvb_frontend* fe);
124
extern int dvb_unregister_frontend(struct dvb_frontend* fe);
125
extern void dvb_suspend_frontend(struct dvb_frontend* fe);
126
extern void dvb_resume_frontend(struct dvb_frontend* fe);
125
127
126
#endif
128
#endif
(-)linux-2.6.11.orig/drivers/media/dvb/frontends/Kconfig (+4 lines)
Lines 157-160 config DVB_NXT2002 Link Here
157
	help
157
	help
158
	  An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
158
	  An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
159
159
160
config DVB_OR51132
161
	tristate "OR51132 based (pcHDTV)"
162
	depends on DVB_CORE
163
160
endmenu
164
endmenu
(-)linux-2.6.11.orig/drivers/media/dvb/frontends/Makefile (-1 / +2 lines)
Lines 4-9 Link Here
4
4
5
EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
5
EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
6
6
7
obj-$(CONFIG_DVB_CORE) += dvb-pll.o
7
obj-$(CONFIG_DVB_STV0299) += stv0299.o
8
obj-$(CONFIG_DVB_STV0299) += stv0299.o
8
obj-$(CONFIG_DVB_SP8870) += sp8870.o
9
obj-$(CONFIG_DVB_SP8870) += sp8870.o
9
obj-$(CONFIG_DVB_CX22700) += cx22700.o
10
obj-$(CONFIG_DVB_CX22700) += cx22700.o
Lines 25-28 obj-$(CONFIG_DVB_TDA80XX) += tda80xx.o Link Here
25
obj-$(CONFIG_DVB_TDA10021) += tda10021.o
26
obj-$(CONFIG_DVB_TDA10021) += tda10021.o
26
obj-$(CONFIG_DVB_STV0297) += stv0297.o
27
obj-$(CONFIG_DVB_STV0297) += stv0297.o
27
obj-$(CONFIG_DVB_NXT2002) += nxt2002.o
28
obj-$(CONFIG_DVB_NXT2002) += nxt2002.o
28
29
obj-$(CONFIG_DVB_OR51132) += or51132.o
(-)linux-2.6.11.orig/drivers/media/dvb/frontends/cx22702.c (-223 / +341 lines)
Lines 1-8 Link Here
1
/*
1
/*
2
    Conexant 22702 DVB OFDM demodulator driver
2
    Conexant 22702 DVB OFDM frontend driver
3
3
4
    based on:
4
    based on:
5
        Alps TDMB7 DVB OFDM demodulator driver
5
        Alps TDMB7 DVB OFDM frontend driver
6
6
7
    Copyright (C) 2001-2002 Convergence Integrated Media GmbH
7
    Copyright (C) 2001-2002 Convergence Integrated Media GmbH
8
	  Holger Waechtler <holger@convergence.de>
8
	  Holger Waechtler <holger@convergence.de>
Lines 31-60 Link Here
31
#include <linux/string.h>
31
#include <linux/string.h>
32
#include <linux/slab.h>
32
#include <linux/slab.h>
33
#include <linux/delay.h>
33
#include <linux/delay.h>
34
34
#include "dvb_frontend.h"
35
#include "dvb_frontend.h"
36
#include "dvb-pll.h"
35
#include "cx22702.h"
37
#include "cx22702.h"
36
38
39
#define FRONTEND_NAME "dvbfe_cx22702"
37
40
38
struct cx22702_state {
41
#define dprintk	if (debug) printk
39
40
	struct i2c_adapter* i2c;
41
42
	struct dvb_frontend_ops ops;
43
42
44
	/* configuration settings */
43
static int debug = 0;
45
	const struct cx22702_config* config;
44
module_param(debug, int, 0644);
45
MODULE_PARM_DESC(debug, "Enable verbose debug messages");
46
46
47
	struct dvb_frontend frontend;
47
/* ------------------------------------------------------------------ */
48
48
49
	/* previous uncorrected block counter */
49
struct cx22702_state {
50
	const struct cx22702_config     *config;
51
	struct i2c_client               demod;
52
	struct i2c_client               pll;
53
	struct dvb_frontend             fe;
54
	struct dvb_frontend_ops         ops;
50
	u8 prevUCBlocks;
55
	u8 prevUCBlocks;
51
};
56
};
52
57
53
static int debug = 0;
58
static struct i2c_client demod_template;
54
#define dprintk	if (debug) printk
59
static struct i2c_client pll_template;
55
60
56
/* Register values to initialise the demod */
61
/* Register values to initialise the demod */
57
static u8 init_tab [] = {
62
static u8 init_tab[] = {
58
	0x00, 0x00, /* Stop aquisition */
63
	0x00, 0x00, /* Stop aquisition */
59
	0x0B, 0x06,
64
	0x0B, 0x06,
60
	0x09, 0x01,
65
	0x09, 0x01,
Lines 83-155 static u8 init_tab [] = { Link Here
83
	0xfd, 0x00,
88
	0xfd, 0x00,
84
};
89
};
85
90
86
static int cx22702_writereg (struct cx22702_state* state, u8 reg, u8 data)
91
/* ------------------------------------------------------------------ */
92
93
static int writereg(struct i2c_client *c, u8 reg, u8 data)
87
{
94
{
95
	u8 buf[] = { reg, data };
88
	int ret;
96
	int ret;
89
	u8 buf [] = { reg, data };
90
	struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
91
97
92
	ret = i2c_transfer(state->i2c, &msg, 1);
98
	ret = i2c_master_send(c, buf, 2);
93
99
	if (ret != 2) {
94
	if (ret != 1)
95
		printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
100
		printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
96
			__FUNCTION__, reg, data, ret);
101
		       __FUNCTION__, reg, data, ret);
102
		return -1;
103
	}
104
	return 0;
105
}
97
106
98
	return (ret != 1) ? -1 : 0;
107
static int readreg(struct i2c_client *c, u8 reg)
108
{
109
	u8 wr [] = { reg };
110
	u8 rd [] = { 0 };
111
	struct i2c_msg msg [] = {
112
		{ .addr = c->addr, .flags = 0,        .buf = wr, .len = 1 },
113
		{ .addr = c->addr, .flags = I2C_M_RD, .buf = rd, .len = 1 },
114
	};
115
	int ret;
116
117
	ret = i2c_transfer(c->adapter, msg, 2);
118
	if (ret != 2) {
119
		printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
120
		return -1;
121
	}
122
	return rd[0];
99
}
123
}
100
124
101
static u8 cx22702_readreg (struct cx22702_state* state, u8 reg)
125
/* ------------------------------------------------------------------ */
126
127
#define PLL_ENABLE(cx)  writereg(&cx->demod, 0x0D, readreg(&cx->demod, 0x0D) & 0xfe)
128
#define PLL_DISABLE(cx) writereg(&cx->demod, 0x0D, readreg(&cx->demod, 0x0D) | 0x01)
129
130
static int pll_write4(struct i2c_client *c, u8 *data)
102
{
131
{
103
	int ret;
132
	int ret;
104
	u8 b0 [] = { reg };
105
	u8 b1 [] = { 0 };
106
133
107
	struct i2c_msg msg [] = {
134
	ret = i2c_master_send(c, data, 4);
108
		{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
135
	if (ret != 4) {
109
		{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
136
		printk("%s: i/o error (addr == 0x%02x, ret == %i)\n",
137
		       __FUNCTION__, c->addr, ret);
138
		return -EIO;
139
	}
140
	return 0;
141
}
110
142
111
	ret = i2c_transfer(state->i2c, msg, 2);
143
/* ------------------------------------------------------------------ */
112
144
113
	if (ret != 2)
145
static int cx22702_reset(struct cx22702_state *state)
114
		printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
146
{
147
	int i;
115
148
116
	return b1[0];
149
	dprintk("%s\n",__FUNCTION__);
150
	writereg(&state->demod, 0x00, 0x02);
151
	msleep(10);
152
153
	for (i=0; i<ARRAY_SIZE(init_tab); i+=2)
154
		writereg(&state->demod, init_tab[i], init_tab[i+1]);
155
	return 0;
117
}
156
}
118
157
119
static int cx22702_set_inversion (struct cx22702_state *state, int inversion)
158
static int cx22702_set_inversion(struct cx22702_state *state, int inversion)
120
{
159
{
121
	u8 val;
160
	u8 val;
122
161
123
	switch (inversion) {
162
	switch (inversion) {
163
	case INVERSION_AUTO:
164
		return -EOPNOTSUPP;
124
165
125
		case INVERSION_AUTO:
166
	case INVERSION_ON:
126
			return -EOPNOTSUPP;
167
		val = readreg(&state->demod, 0x0C);
127
168
		return writereg(&state->demod, 0x0C, val | 0x01);
128
		case INVERSION_ON:
129
			val = cx22702_readreg (state, 0x0C);
130
			return cx22702_writereg (state, 0x0C, val | 0x01);
131
132
		case INVERSION_OFF:
133
			val = cx22702_readreg (state, 0x0C);
134
			return cx22702_writereg (state, 0x0C, val & 0xfe);
135
169
136
		default:
170
	case INVERSION_OFF:
137
			return -EINVAL;
171
		val = readreg(&state->demod, 0x0C);
172
		return writereg(&state->demod, 0x0C, val & 0xfe);
138
173
174
	default:
175
		return -EINVAL;
139
	}
176
	}
140
141
}
177
}
142
178
143
/* Retrieve the demod settings */
179
/* Retrieve the demod settings */
144
static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_parameters *p)
180
static int cx22702_get_tps(struct cx22702_state *state,
181
			   struct dvb_ofdm_parameters *p)
145
{
182
{
146
	u8 val;
183
	u8 val;
147
184
148
	/* Make sure the TPS regs are valid */
185
	/* Make sure the TPS regs are valid */
149
	if (!(cx22702_readreg(state, 0x0A) & 0x20))
186
	if (!(readreg(&state->demod, 0x0A) & 0x20))
150
		return -EAGAIN;
187
		return -EAGAIN;
151
188
152
	val = cx22702_readreg (state, 0x01);
189
	val = readreg(&state->demod, 0x01);
153
	switch( (val&0x18)>>3) {
190
	switch( (val&0x18)>>3) {
154
		case 0: p->constellation =   QPSK; break;
191
		case 0: p->constellation =   QPSK; break;
155
		case 1: p->constellation = QAM_16; break;
192
		case 1: p->constellation = QAM_16; break;
Lines 162-169 static int cx22702_get_tps (struct cx227 Link Here
162
		case 3: p->hierarchy_information =    HIERARCHY_4; break;
199
		case 3: p->hierarchy_information =    HIERARCHY_4; break;
163
	}
200
	}
164
201
165
202
	val = readreg(&state->demod, 0x02);
166
	val = cx22702_readreg (state, 0x02);
167
	switch( (val&0x38)>>3 ) {
203
	switch( (val&0x38)>>3 ) {
168
		case 0: p->code_rate_HP = FEC_1_2; break;
204
		case 0: p->code_rate_HP = FEC_1_2; break;
169
		case 1: p->code_rate_HP = FEC_2_3; break;
205
		case 1: p->code_rate_HP = FEC_2_3; break;
Lines 179-192 static int cx22702_get_tps (struct cx227 Link Here
179
		case 4: p->code_rate_LP = FEC_7_8; break;
215
		case 4: p->code_rate_LP = FEC_7_8; break;
180
	}
216
	}
181
217
182
218
	val = readreg(&state->demod, 0x03);
183
	val = cx22702_readreg (state, 0x03);
184
	switch( (val&0x0c)>>2 ) {
219
	switch( (val&0x0c)>>2 ) {
185
		case 0: p->guard_interval = GUARD_INTERVAL_1_32; break;
220
		case 0: p->guard_interval = GUARD_INTERVAL_1_32; break;
186
		case 1: p->guard_interval = GUARD_INTERVAL_1_16; break;
221
		case 1: p->guard_interval = GUARD_INTERVAL_1_16; break;
187
		case 2: p->guard_interval =  GUARD_INTERVAL_1_8; break;
222
		case 2: p->guard_interval =  GUARD_INTERVAL_1_8; break;
188
		case 3: p->guard_interval =  GUARD_INTERVAL_1_4; break;
223
		case 3: p->guard_interval =  GUARD_INTERVAL_1_4; break;
189
}
224
	}
190
	switch( val&0x03 ) {
225
	switch( val&0x03 ) {
191
		case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break;
226
		case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break;
192
		case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break;
227
		case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break;
Lines 195-236 static int cx22702_get_tps (struct cx227 Link Here
195
	return 0;
230
	return 0;
196
}
231
}
197
232
198
199
200
201
202
203
204
205
206
207
208
209
210
/* Talk to the demod, set the FEC, GUARD, QAM settings etc */
233
/* Talk to the demod, set the FEC, GUARD, QAM settings etc */
211
static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
234
static int cx22702_set_tps(struct cx22702_state *state,
235
			   struct dvb_frontend_parameters *p)
212
{
236
{
213
	u8 val;
237
	u8 val;
214
	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
238
	u8 pllbuf[4];
239
240
	dprintk("%s\n",__FUNCTION__);
215
241
216
	/* set PLL */
242
	/* set PLL */
217
        cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe);
243
	dvb_pll_configure(state->config->pll_desc, pllbuf,
218
	state->config->pll_set(fe, p);
244
			  p->frequency,
219
        cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);
245
			  p->u.ofdm.bandwidth);
246
	PLL_ENABLE(state);
247
	pll_write4(&state->pll,pllbuf);
248
	PLL_DISABLE(state);
220
249
221
	/* set inversion */
250
	/* set inversion */
222
	cx22702_set_inversion (state, p->inversion);
251
	cx22702_set_inversion(state, p->inversion);
223
252
224
	/* set bandwidth */
253
	/* set bandwidth */
225
	switch(p->u.ofdm.bandwidth) {
254
	switch(p->u.ofdm.bandwidth) {
226
	case BANDWIDTH_6_MHZ:
255
	case BANDWIDTH_6_MHZ:
227
		cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20 );
256
		writereg(&state->demod, 0x0C, (readreg(&state->demod, 0x0C) & 0xcf) | 0x20 );
228
		break;
257
		break;
229
	case BANDWIDTH_7_MHZ:
258
	case BANDWIDTH_7_MHZ:
230
		cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10 );
259
		writereg(&state->demod, 0x0C, (readreg(&state->demod, 0x0C) & 0xcf) | 0x10 );
231
		break;
260
		break;
232
	case BANDWIDTH_8_MHZ:
261
	case BANDWIDTH_8_MHZ:
233
		cx22702_writereg(state, 0x0C, cx22702_readreg(state, 0x0C) &0xcf );
262
		writereg(&state->demod, 0x0C, readreg(&state->demod, 0x0C) &0xcf );
234
		break;
263
		break;
235
	default:
264
	default:
236
		dprintk ("%s: invalid bandwidth\n",__FUNCTION__);
265
		dprintk ("%s: invalid bandwidth\n",__FUNCTION__);
Lines 249-261 static int cx22702_set_tps (struct dvb_f Link Here
249
	   (p->u.ofdm.transmission_mode==TRANSMISSION_MODE_AUTO) ) {
278
	   (p->u.ofdm.transmission_mode==TRANSMISSION_MODE_AUTO) ) {
250
279
251
		/* TPS Source - use hardware driven values */
280
		/* TPS Source - use hardware driven values */
252
		cx22702_writereg(state, 0x06, 0x10);
281
		writereg(&state->demod, 0x06, 0x10);
253
		cx22702_writereg(state, 0x07, 0x9);
282
		writereg(&state->demod, 0x07, 0x9);
254
		cx22702_writereg(state, 0x08, 0xC1);
283
		writereg(&state->demod, 0x08, 0xC1);
255
		cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc );
284
		writereg(&state->demod, 0x0B, readreg(&state->demod, 0x0B) & 0xfc );
256
		cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 );
285
		writereg(&state->demod, 0x0C, (readreg(&state->demod, 0x0C) & 0xBF) | 0x40 );
257
		cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */
286
		writereg(&state->demod, 0x00, 0x01); /* Begin aquisition */
258
		printk("%s: Autodetecting\n",__FUNCTION__);
287
		dprintk("%s: Autodetecting\n",__FUNCTION__);
259
		return 0;
288
		return 0;
260
	}
289
	}
261
290
Lines 278-284 static int cx22702_set_tps (struct dvb_f Link Here
278
			dprintk ("%s: invalid hierarchy\n",__FUNCTION__);
307
			dprintk ("%s: invalid hierarchy\n",__FUNCTION__);
279
			return -EINVAL;
308
			return -EINVAL;
280
	}
309
	}
281
	cx22702_writereg (state, 0x06, val);
310
	writereg(&state->demod, 0x06, val);
282
311
283
	val=0;
312
	val=0;
284
	switch(p->u.ofdm.code_rate_HP) {
313
	switch(p->u.ofdm.code_rate_HP) {
Lines 303-309 static int cx22702_set_tps (struct dvb_f Link Here
303
			dprintk ("%s: invalid code_rate_LP\n",__FUNCTION__);
332
			dprintk ("%s: invalid code_rate_LP\n",__FUNCTION__);
304
			return -EINVAL;
333
			return -EINVAL;
305
	}
334
	}
306
	cx22702_writereg (state, 0x07, val);
335
	writereg(&state->demod, 0x07, val);
307
336
308
	val=0;
337
	val=0;
309
	switch(p->u.ofdm.guard_interval) {
338
	switch(p->u.ofdm.guard_interval) {
Lines 322-532 static int cx22702_set_tps (struct dvb_f Link Here
322
			dprintk ("%s: invalid transmission_mode\n",__FUNCTION__);
351
			dprintk ("%s: invalid transmission_mode\n",__FUNCTION__);
323
			return -EINVAL;
352
			return -EINVAL;
324
	}
353
	}
325
	cx22702_writereg(state, 0x08, val);
354
	writereg(&state->demod, 0x08, val);
326
	cx22702_writereg(state, 0x0B, (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02 );
355
	writereg(&state->demod, 0x0B, (readreg(&state->demod, 0x0B) & 0xfc) | 0x02 );
327
	cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 );
356
	writereg(&state->demod, 0x0C, (readreg(&state->demod, 0x0C) & 0xBF) | 0x40 );
328
357
329
	/* Begin channel aquisition */
358
	/* Begin channel aquisition */
330
	cx22702_writereg(state, 0x00, 0x01);
359
	writereg(&state->demod, 0x00, 0x01);
331
360
332
	return 0;
361
	return 0;
333
}
362
}
334
363
364
/* ------------------------------------------------------------------ */
335
365
336
/* Reset the demod hardware and reset all of the configuration registers
366
static int cx22702_init(struct dvb_frontend* fe)
337
   to a default state. */
338
static int cx22702_init (struct dvb_frontend* fe)
339
{
367
{
340
	int i;
368
	struct cx22702_state *state = fe->demodulator_priv;
341
	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
342
343
	cx22702_writereg (state, 0x00, 0x02);
344
345
	msleep(10);
346
347
	for (i=0; i<sizeof(init_tab); i+=2)
348
		cx22702_writereg (state, init_tab[i], init_tab[i+1]);
349
350
351
	/* init PLL */
352
	if (state->config->pll_init) {
353
	        cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe);
354
		state->config->pll_init(fe);
355
		cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);
356
	}
357
369
370
	cx22702_reset(state);
358
	return 0;
371
	return 0;
359
}
372
}
360
373
361
static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status)
374
static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status)
362
{
375
{
363
	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
376
	struct cx22702_state *state = fe->demodulator_priv;
364
	u8 reg0A;
377
	u8 reg0A = readreg(&state->demod, 0x0A);
365
	u8 reg23;
378
	u8 reg23 = readreg(&state->demod, 0x23);
366
367
			*status = 0;
368
369
	reg0A = cx22702_readreg (state, 0x0A);
370
	reg23 = cx22702_readreg (state, 0x23);
371
372
			dprintk ("%s: status demod=0x%02x agc=0x%02x\n"
373
				,__FUNCTION__,reg0A,reg23);
374
375
			if(reg0A & 0x10) {
376
				*status |= FE_HAS_LOCK;
377
				*status |= FE_HAS_VITERBI;
378
				*status |= FE_HAS_SYNC;
379
			}
380
381
			if(reg0A & 0x20)
382
				*status |= FE_HAS_CARRIER;
383
379
384
			if(reg23 < 0xf0)
380
	*status = 0;
385
				*status |= FE_HAS_SIGNAL;
381
	if (reg0A & 0x10)
382
		*status |= FE_HAS_LOCK| FE_HAS_VITERBI | FE_HAS_SYNC;
383
	if (reg0A & 0x20)
384
		*status |= FE_HAS_CARRIER;
385
	if (reg23 < 0xf0)
386
		*status |= FE_HAS_SIGNAL;
386
387
388
	dprintk ("%s: status demod=0x%02x agc=0x%02x status=0x%x\n",
389
		 __FUNCTION__,reg0A,reg23,*status);
387
	return 0;
390
	return 0;
388
			}
391
}
389
392
390
static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber)
393
static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber)
391
		{
394
{
392
	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
395
	struct cx22702_state *state = fe->demodulator_priv;
393
394
	if(cx22702_readreg (state, 0xE4) & 0x02) {
395
				/* Realtime statistics */
396
		*ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7
397
			| (cx22702_readreg (state, 0xDF)&0x7F);
398
			} else {
399
		/* Averagtine statistics */
400
		*ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7
401
			| cx22702_readreg (state, 0xDF);
402
		}
403
396
397
	*ber = (readreg(&state->demod, 0xDE) & 0x7F) << 7;
398
	*ber |= readreg(&state->demod, 0xDF) & 0x7F;
404
	return 0;
399
	return 0;
405
		}
400
}
406
407
static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
408
		{
409
	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
410
401
411
	*signal_strength = cx22702_readreg (state, 0x23);
402
static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* strength)
403
{
404
	struct cx22702_state *state = fe->demodulator_priv;
405
	u8 signal;
412
406
407
	signal = readreg(&state->demod, 0x23);
408
	*strength = ((signal<<8) | signal);
413
	return 0;
409
	return 0;
414
}
410
}
415
411
416
static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr)
412
static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr)
417
{
413
{
418
	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
414
	u32 ber;
419
420
	u16 rs_ber=0;
421
	if(cx22702_readreg (state, 0xE4) & 0x02) {
422
		/* Realtime statistics */
423
		rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7
424
			| (cx22702_readreg (state, 0xDF)& 0x7F);
425
	} else {
426
		/* Averagine statistics */
427
		rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 8
428
			| cx22702_readreg (state, 0xDF);
429
	}
430
	*snr = ~rs_ber;
431
415
416
	/* We don't have an register for this         */
417
	/* We'll take the inverse of the BER register */
418
	cx22702_read_ber(fe, &ber);
419
	*snr = ~ber;
432
	return 0;
420
	return 0;
433
}
421
}
434
422
435
static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
423
static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
436
{
424
{
437
	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
425
	struct cx22702_state *state = fe->demodulator_priv;
438
426
	u8 ucb;
439
	u8 _ucblocks;
440
427
441
	/* RS Uncorrectable Packet Count then reset */
428
	/* RS Uncorrectable Packet Count then reset */
442
	_ucblocks = cx22702_readreg (state, 0xE3);
429
	ucb = readreg(&state->demod, 0xE3);
443
	if (state->prevUCBlocks < _ucblocks) *ucblocks = (_ucblocks - state->prevUCBlocks);
430
	if (state->prevUCBlocks <= ucb)
444
	else *ucblocks = state->prevUCBlocks - _ucblocks;
431
		*ucblocks = (ucb - state->prevUCBlocks);
445
	state->prevUCBlocks = _ucblocks;
432
	else
446
433
		*ucblocks = 256 + ucb - state->prevUCBlocks;
434
	state->prevUCBlocks = ucb;
447
	return 0;
435
	return 0;
448
}
436
}
449
437
450
static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
438
static int cx22702_get_frontend(struct dvb_frontend* fe,
439
				struct dvb_frontend_parameters* params)
451
{
440
{
452
	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
441
	struct cx22702_state *state = fe->demodulator_priv;
442
	u8 reg0C = readreg(&state->demod, 0x0C);
443
	params->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF;
444
	return cx22702_get_tps(state, &params->u.ofdm);
445
}
453
446
454
	u8 reg0C = cx22702_readreg (state, 0x0C);
447
static int cx22702_set_frontend(struct dvb_frontend* fe,
448
				struct dvb_frontend_parameters* params)
449
{
450
	struct cx22702_state *state = fe->demodulator_priv;
451
	int ret;
455
452
456
	p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF;
453
	ret=cx22702_set_tps(state, params);
457
	return cx22702_get_tps (state, &p->u.ofdm);
454
	if (debug && ret < 0)
455
		printk("%s: set_tps failed ret=%d\n",__FUNCTION__,ret);
456
	return ret;
458
}
457
}
459
458
460
static void cx22702_release(struct dvb_frontend* fe)
459
static void cx22702_release(struct dvb_frontend* fe)
461
{
460
{
462
	struct cx22702_state* state = (struct cx22702_state*) fe->demodulator_priv;
461
	struct cx22702_state *state = fe->demodulator_priv;
463
		kfree(state);
464
	}
465
462
466
static struct dvb_frontend_ops cx22702_ops;
463
	i2c_detach_client(&state->demod);
464
	i2c_detach_client(&state->pll);
465
	kfree(state);
466
}
467
467
468
struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
468
static int cx22702_sleep(struct dvb_frontend* fe)
469
				    struct i2c_adapter* i2c)
470
{
469
{
471
	struct cx22702_state* state = NULL;
470
	struct cx22702_state *state = fe->demodulator_priv;
472
471
	u8 pllbuf[4];
473
	/* allocate memory for the internal state */
474
	state = (struct cx22702_state*) kmalloc(sizeof(struct cx22702_state), GFP_KERNEL);
475
	if (state == NULL) goto error;
476
477
	/* setup the state */
478
	state->config = config;
479
	state->i2c = i2c;
480
	memcpy(&state->ops, &cx22702_ops, sizeof(struct dvb_frontend_ops));
481
	state->prevUCBlocks = 0;
482
483
	/* check if the demod is there */
484
	if (cx22702_readreg(state, 0x1f) != 0x3) goto error;
485
472
486
	/* create dvb_frontend */
473
	dprintk("%s\n",__FUNCTION__);
487
	state->frontend.ops = &state->ops;
488
	state->frontend.demodulator_priv = state;
489
	return &state->frontend;
490
474
491
error:
475
	dvb_pll_configure(state->config->pll_desc, pllbuf, 0, 0);
492
	if (state) kfree(state);
476
	PLL_ENABLE(state);
493
	return NULL;
477
	pll_write4(&state->pll,pllbuf);
478
	PLL_DISABLE(state);
479
	return 0;
494
}
480
}
495
481
496
static struct dvb_frontend_ops cx22702_ops = {
482
static struct dvb_frontend_ops cx22702_fe_ops = {
497
498
	.info = {
483
	.info = {
499
		.name			= "Conexant CX22702 DVB-T",
484
		.name			= "cx22702 demod",
500
		.type			= FE_OFDM,
485
		.type			= FE_OFDM,
501
		.frequency_min		= 177000000,
486
		.frequency_min		= 177000000,
502
		.frequency_max		= 858000000,
487
		.frequency_max		= 858000000,
503
		.frequency_stepsize	= 166666,
488
		.frequency_stepsize	= 166666,
504
		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
489
		.caps =
505
		FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
490
		FE_CAN_FEC_1_2 |
506
		FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
491
		FE_CAN_FEC_2_3 |
507
		FE_CAN_HIERARCHY_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
492
		FE_CAN_FEC_3_4 |
508
		FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_RECOVER
493
		FE_CAN_FEC_5_6 |
494
		FE_CAN_FEC_7_8 |
495
		FE_CAN_FEC_AUTO |
496
		FE_CAN_QPSK |
497
		FE_CAN_QAM_16 |
498
		FE_CAN_QAM_64 |
499
		FE_CAN_QAM_AUTO |
500
		FE_CAN_HIERARCHY_AUTO |
501
		FE_CAN_GUARD_INTERVAL_AUTO |
502
		FE_CAN_TRANSMISSION_MODE_AUTO |
503
		FE_CAN_RECOVER,
509
	},
504
	},
505
	.init                 = cx22702_init,
506
	.sleep                = cx22702_sleep,
507
	.set_frontend         = cx22702_set_frontend,
508
	.get_frontend         = cx22702_get_frontend,
509
	.read_status          = cx22702_read_status,
510
	.read_ber             = cx22702_read_ber,
511
	.read_signal_strength = cx22702_read_signal_strength,
512
	.read_snr             = cx22702_read_snr,
513
	.read_ucblocks        = cx22702_read_ucblocks,
514
	.release              = cx22702_release,
515
};
510
516
511
	.release = cx22702_release,
517
/* ------------------------------------------------------------------ */
512
518
513
	.init = cx22702_init,
519
/* Validate the demod, make sure we understand the hardware */
520
static int cx22702_validate_demod(struct i2c_client *c)
521
{
522
	int type = readreg(c, 0x1f);
514
523
515
	.set_frontend = cx22702_set_tps,
524
	if (0x03 != type) {
516
	.get_frontend = cx22702_get_frontend,
525
		printk ("%s i2c demod type 0x%02x not known\n",
526
			__FUNCTION__, type);
527
		return -ENODEV;
528
	}
529
	return 0;
530
}
517
531
518
	.read_status = cx22702_read_status,
532
/* Validate the tuner PLL, make sure we understand the hardware */
519
	.read_ber = cx22702_read_ber,
533
static int cx22702_validate_pll(struct cx22702_state *state)
520
	.read_signal_strength = cx22702_read_signal_strength,
534
{
521
	.read_snr = cx22702_read_snr,
535
	int result=0;
522
	.read_ucblocks = cx22702_read_ucblocks,
536
537
	PLL_ENABLE(state);
538
	result = readreg(&state->pll,0xc2);
539
	PLL_DISABLE(state);
540
	return result;
541
}
542
543
struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
544
				    struct i2c_adapter* i2c)
545
{
546
	struct cx22702_state *state;
547
	int ret;
548
549
	state = kmalloc(sizeof(*state), GFP_KERNEL);
550
	if (NULL == state)
551
		return NULL;
552
	memset(state, 0, sizeof(*state));
553
554
	state->config              = config;
555
	state->ops                 = cx22702_fe_ops;
556
	state->fe.demodulator_priv = state;
557
	state->fe.ops              = &state->ops;
558
559
	state->demod         = demod_template;
560
	state->demod.adapter = i2c;
561
	state->demod.addr    = config->demod_address;
562
	state->pll           = pll_template;
563
	strlcpy(state->pll.name, config->pll_desc->name, sizeof(state->pll.name));
564
	state->pll.adapter   = i2c;
565
	state->pll.addr      = config->pll_address;
566
	i2c_set_clientdata(&state->demod, state);
567
	i2c_set_clientdata(&state->pll, state);
568
569
	/* verify devices */
570
	ret=cx22702_validate_demod(&state->demod);
571
	if (ret < 0)
572
		goto fail_free;
573
	ret=cx22702_validate_pll(state);
574
	if(ret < 0)
575
		goto fail_free;
576
577
	/* register i2c */
578
	ret = i2c_attach_client(&state->demod);
579
	if (0 != ret) {
580
		printk("cx22702: i2c demod register failed (%d)\n", ret);
581
		goto fail_free;
582
	}
583
	ret = i2c_attach_client(&state->pll);
584
	if (0 != ret) {
585
		printk("cx22702: i2c pll register failed (%d)\n", ret);
586
		goto fail_unreg1;
587
	}
588
589
	/* all fine ;) */
590
	return &state->fe;
591
592
fail_unreg1:
593
	i2c_detach_client(&state->demod);
594
fail_free:
595
	kfree(state);
596
	return NULL;
597
}
598
EXPORT_SYMBOL(cx22702_attach);
599
600
/* ------------------------------------------------------------------ */
601
602
static struct i2c_driver demod_driver = {
603
	.owner = THIS_MODULE,
604
	.name  = __stringify(KBUILD_MODNAME) " demod",
605
	.id    = I2C_DRIVERID_DVBFE_CX22702,
606
};
607
static struct i2c_client demod_template = {
608
	.name   = "cx22702",
609
	.flags  = I2C_CLIENT_ALLOW_USE,
610
	.driver = &demod_driver,
523
};
611
};
524
612
525
module_param(debug, int, 0644);
613
static struct i2c_driver pll_driver = {
526
MODULE_PARM_DESC(debug, "Enable verbose debug messages");
614
	.owner = THIS_MODULE,
615
	.name  = __stringify(KBUILD_MODNAME) " pll",
616
	.id    = I2C_DRIVERID_DVBFE_CX22702,
617
};
618
static struct i2c_client pll_template = {
619
	.name   = "unset",
620
	.flags  = I2C_CLIENT_ALLOW_USE,
621
	.driver = &pll_driver,
622
};
527
623
528
MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver");
624
static int __init init_cx22702 (void)
625
{
626
	i2c_add_driver(&demod_driver);
627
	i2c_add_driver(&pll_driver);
628
	return 0;
629
}
630
631
static void __exit exit_cx22702 (void)
632
{
633
	i2c_del_driver(&pll_driver);
634
	i2c_del_driver(&demod_driver);
635
}
636
637
module_init (init_cx22702);
638
module_exit (exit_cx22702);
639
640
MODULE_DESCRIPTION("CX22702 DVB Frontend driver");
529
MODULE_AUTHOR("Steven Toth");
641
MODULE_AUTHOR("Steven Toth");
642
MODULE_AUTHOR("Gerd Knorr");
530
MODULE_LICENSE("GPL");
643
MODULE_LICENSE("GPL");
531
644
532
EXPORT_SYMBOL(cx22702_attach);
645
/*
646
 * Local variables:
647
 * c-basic-offset: 8
648
 * compile-command: "make DVB=1"
649
 * End:
650
 */
(-)linux-2.6.11.orig/drivers/media/dvb/frontends/cx22702.h (+6 lines)
Lines 36-43 struct cx22702_config Link Here
36
	u8 demod_address;
36
	u8 demod_address;
37
37
38
	/* PLL maintenance */
38
	/* PLL maintenance */
39
	u8 pll_address;
40
	struct dvb_pll_desc *pll_desc;
41
42
#if 0 /* disabled for now, but maybe we'll need it again for plls
43
       * which don't fit into the dvb_pll_desc model ... */
39
	int (*pll_init)(struct dvb_frontend* fe);
44
	int (*pll_init)(struct dvb_frontend* fe);
40
	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
45
	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
46
#endif
41
};
47
};
42
48
43
extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
49
extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
(-)linux-2.6.11/drivers/media/dvb/frontends/dvb-pll.c (+168 lines)
Added Link Here
1
/*
2
 * $Id: dvb-pll.c,v 1.7 2005/02/10 11:52:02 kraxel Exp $
3
 *
4
 * descriptions + helper functions for simple dvb plls.
5
 *
6
 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  (at your option) any later version.
12
 *
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU General Public License for more details.
17
 *
18
 *  You should have received a copy of the GNU General Public License
19
 *  along with this program; if not, write to the Free Software
20
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
 */
22
23
#include <linux/module.h>
24
#include <linux/dvb/frontend.h>
25
#include <asm/types.h>
26
27
#include "dvb-pll.h"
28
29
/* ----------------------------------------------------------- */
30
/* descriptions                                                */
31
32
struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
33
	.name  = "Thomson dtt7579",
34
	.min   = 177000000,
35
	.max   = 858000000,
36
	.count = 5,
37
	.entries = {
38
		{          0, 36166667, 166666, 0xb4, 0x03 }, /* go sleep */
39
		{  443250000, 36166667, 166666, 0xb4, 0x02 },
40
		{  542000000, 36166667, 166666, 0xb4, 0x08 },
41
		{  771000000, 36166667, 166666, 0xbc, 0x08 },
42
		{  999999999, 36166667, 166666, 0xf4, 0x08 },
43
	},
44
};
45
EXPORT_SYMBOL(dvb_pll_thomson_dtt7579);
46
47
struct dvb_pll_desc dvb_pll_thomson_dtt7610 = {
48
	.name  = "Thomson dtt7610",
49
	.min   =  44000000,
50
	.max   = 958000000,
51
	.count = 3,
52
	.entries = {
53
		{ 157250000, 44000000, 62500, 0x8e, 0x39 },
54
		{ 454000000, 44000000, 62500, 0x8e, 0x3a },
55
		{ 999999999, 44000000, 62500, 0x8e, 0x3c },
56
	},
57
};
58
EXPORT_SYMBOL(dvb_pll_thomson_dtt7610);
59
60
static void thomson_dtt759x_bw(u8 *buf, int bandwidth)
61
{
62
	if (BANDWIDTH_7_MHZ == bandwidth)
63
		buf[3] |= 0x10;
64
}
65
66
struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
67
	.name  = "Thomson dtt759x",
68
	.min   = 177000000,
69
	.max   = 896000000,
70
	.setbw = thomson_dtt759x_bw,
71
	.count = 6,
72
	.entries = {
73
		{          0, 36166667, 166666, 0x84, 0x03 },
74
		{  264000000, 36166667, 166666, 0xb4, 0x02 },
75
		{  470000000, 36166667, 166666, 0xbc, 0x02 },
76
		{  735000000, 36166667, 166666, 0xbc, 0x08 },
77
		{  835000000, 36166667, 166666, 0xf4, 0x08 },
78
		{  999999999, 36166667, 166666, 0xfc, 0x08 },
79
	},
80
};
81
EXPORT_SYMBOL(dvb_pll_thomson_dtt759x);
82
83
struct dvb_pll_desc dvb_pll_lg_z201 = {
84
	.name  = "LG z201",
85
	.min   = 174000000,
86
	.max   = 862000000,
87
	.count = 5,
88
	.entries = {
89
		{          0, 36166667, 166666, 0xbc, 0x03 },
90
		{  443250000, 36166667, 166666, 0xbc, 0x01 },
91
		{  542000000, 36166667, 166666, 0xbc, 0x02 },
92
		{  830000000, 36166667, 166666, 0xf4, 0x02 },
93
		{  999999999, 36166667, 166666, 0xfc, 0x02 },
94
	},
95
};
96
EXPORT_SYMBOL(dvb_pll_lg_z201);
97
98
struct dvb_pll_desc dvb_pll_unknown_1 = {
99
	.name  = "unknown 1", /* used by dntv live dvb-t */
100
	.min   = 174000000,
101
	.max   = 862000000,
102
	.count = 9,
103
	.entries = {
104
		{  150000000, 36166667, 166666, 0xb4, 0x01 },
105
		{  173000000, 36166667, 166666, 0xbc, 0x01 },
106
		{  250000000, 36166667, 166666, 0xb4, 0x02 },
107
		{  400000000, 36166667, 166666, 0xbc, 0x02 },
108
		{  420000000, 36166667, 166666, 0xf4, 0x02 },
109
		{  470000000, 36166667, 166666, 0xfc, 0x02 },
110
		{  600000000, 36166667, 166666, 0xbc, 0x08 },
111
		{  730000000, 36166667, 166666, 0xf4, 0x08 },
112
		{  999999999, 36166667, 166666, 0xfc, 0x08 },
113
	},
114
};
115
EXPORT_SYMBOL(dvb_pll_unknown_1);
116
117
/* ----------------------------------------------------------- */
118
/* code                                                        */
119
120
static int debug = 0;
121
module_param(debug, int, 0644);
122
MODULE_PARM_DESC(debug, "enable verbose debug messages");
123
124
int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
125
		      u32 freq, int bandwidth)
126
{
127
	u32 div;
128
	int i;
129
130
	if (freq != 0 && (freq < desc->min || freq > desc->max))
131
	    return -EINVAL;
132
133
	for (i = 0; i < desc->count; i++) {
134
		if (freq > desc->entries[i].limit)
135
			continue;
136
		break;
137
	}
138
	if (debug)
139
		printk("pll: %s: freq=%d bw=%d | i=%d/%d\n",
140
		       desc->name, freq, bandwidth, i, desc->count);
141
	BUG_ON(i == desc->count);
142
143
	div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize;
144
	buf[0] = div >> 8;
145
	buf[1] = div & 0xff;
146
	buf[2] = desc->entries[i].cb1;
147
	buf[3] = desc->entries[i].cb2;
148
149
	if (desc->setbw)
150
		desc->setbw(buf, bandwidth);
151
152
	if (debug)
153
		printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
154
		       desc->name, div, buf[0], buf[1], buf[2], buf[3]);
155
156
	return 0;
157
}
158
EXPORT_SYMBOL(dvb_pll_configure);
159
160
MODULE_DESCRIPTION("dvb pll library");
161
MODULE_AUTHOR("Gerd Knorr");
162
MODULE_LICENSE("GPL");
163
164
/*
165
 * Local variables:
166
 * c-basic-offset: 8
167
 * End:
168
 */
(-)linux-2.6.11/drivers/media/dvb/frontends/dvb-pll.h (+34 lines)
Added Link Here
1
/*
2
 * $Id: dvb-pll.h,v 1.2 2005/02/10 11:43:41 kraxel Exp $
3
 */
4
5
struct dvb_pll_desc {
6
	char *name;
7
	u32  min;
8
	u32  max;
9
	void (*setbw)(u8 *buf, int bandwidth);
10
	int  count;
11
	struct {
12
		u32 limit;
13
		u32 offset;
14
		u32 stepsize;
15
		u8  cb1;
16
		u8  cb2;
17
	} entries[];
18
};
19
20
extern struct dvb_pll_desc dvb_pll_thomson_dtt7579;
21
extern struct dvb_pll_desc dvb_pll_thomson_dtt759x;
22
extern struct dvb_pll_desc dvb_pll_thomson_dtt7610;
23
extern struct dvb_pll_desc dvb_pll_lg_z201;
24
extern struct dvb_pll_desc dvb_pll_unknown_1;
25
26
int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
27
		      u32 freq, int bandwidth);
28
29
/*
30
 * Local variables:
31
 * c-basic-offset: 8
32
 * compile-command: "make DVB=1"
33
 * End:
34
 */
(-)linux-2.6.11.orig/drivers/media/dvb/frontends/mt352.c (-63 / +126 lines)
Lines 41-53 Link Here
41
#include "mt352.h"
41
#include "mt352.h"
42
42
43
struct mt352_state {
43
struct mt352_state {
44
45
	struct i2c_adapter* i2c;
44
	struct i2c_adapter* i2c;
46
47
	struct dvb_frontend_ops ops;
45
	struct dvb_frontend_ops ops;
48
46
49
	/* configuration settings */
47
	/* configuration settings */
50
	const struct mt352_config* config;
48
	const struct mt352_config* config;
49
	int s0,s1,s3;
51
50
52
	struct dvb_frontend frontend;
51
	struct dvb_frontend frontend;
53
};
52
};
Lines 66-88 static int mt352_single_write(struct dvb Link Here
66
			       .buf = buf, .len = 2 };
65
			       .buf = buf, .len = 2 };
67
	int err = i2c_transfer(state->i2c, &msg, 1);
66
	int err = i2c_transfer(state->i2c, &msg, 1);
68
	if (err != 1) {
67
	if (err != 1) {
69
		dprintk("mt352_write() to reg %x failed (err = %d)!\n", reg, err);
68
		printk("mt352_write() to reg %x failed (err = %d)!\n", reg, err);
70
		return err;
69
		return err;
71
}
70
	}
72
	return 0; 
71
	return 0;
73
}
72
}
74
73
75
int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
74
int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
76
{
75
{
77
	int err,i;
76
	int err,i;
78
	for (i=0; i < ilen-1; i++)
77
	for (i=0; i < ilen-1; i++)
79
		if ((err = mt352_single_write(fe,ibuf[0]+i,ibuf[i+1]))) 
78
		if ((err = mt352_single_write(fe,ibuf[0]+i,ibuf[i+1])))
80
			return err;
79
			return err;
81
80
82
	return 0;
81
	return 0;
83
}
82
}
84
83
85
static u8 mt352_read_register(struct mt352_state* state, u8 reg)
84
static int mt352_read_register(struct mt352_state* state, u8 reg)
86
{
85
{
87
	int ret;
86
	int ret;
88
	u8 b0 [] = { reg };
87
	u8 b0 [] = { reg };
Lines 96-136 static u8 mt352_read_register(struct mt3 Link Here
96
95
97
	ret = i2c_transfer(state->i2c, msg, 2);
96
	ret = i2c_transfer(state->i2c, msg, 2);
98
97
99
	if (ret != 2)
98
	if (ret != 2) {
100
		dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
99
		printk("%s: readreg error (reg=%d, ret==%i)\n",
100
		       __FUNCTION__, reg, ret);
101
		return ret;
102
	}
101
103
102
	return b1[0];
104
	return b1[0];
103
}
105
}
104
106
105
u8 mt352_read(struct dvb_frontend *fe, u8 reg)
107
int mt352_read(struct dvb_frontend *fe, u8 reg)
106
{
108
{
107
	return mt352_read_register(fe->demodulator_priv,reg);
109
	return mt352_read_register(fe->demodulator_priv,reg);
108
}
110
}
109
111
112
static int mt352_sleep(struct dvb_frontend* fe)
113
{
114
	static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 };
110
115
116
	mt352_write(fe, mt352_softdown, sizeof(mt352_softdown));
117
	return 0;
118
}
111
119
120
static void mt352_calc_nominal_rate(struct mt352_state* state,
121
				    enum fe_bandwidth bandwidth,
122
				    unsigned char *buf)
123
{
124
	u32 adc_clock = 20480; /* 20.340 MHz */
125
	u32 bw,value;
112
126
127
	switch (bandwidth) {
128
	case BANDWIDTH_6_MHZ:
129
		bw = 6;
130
		break;
131
	case BANDWIDTH_7_MHZ:
132
		bw = 7;
133
		break;
134
	case BANDWIDTH_8_MHZ:
135
	default:
136
		bw = 8;
137
		break;
138
	}
139
	if (state->config->adc_clock)
140
		adc_clock = state->config->adc_clock;
113
141
142
	value = 64 * bw * (1<<16) / (7 * 8);
143
	value = value * 1000 / adc_clock;
144
	dprintk("%s: bw %d, adc_clock %d => 0x%x\n",
145
		__FUNCTION__, bw, adc_clock, value);
146
	buf[0] = msb(value);
147
	buf[1] = lsb(value);
148
}
114
149
115
150
static void mt352_calc_input_freq(struct mt352_state* state,
116
151
				  unsigned char *buf)
117
static int mt352_sleep(struct dvb_frontend* fe)
118
{
152
{
119
	static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 };
153
	int adc_clock = 20480; /* 20.480000 MHz */
154
	int if2       = 36167; /* 36.166667 MHz */
155
	int ife,value;
120
156
121
	mt352_write(fe, mt352_softdown, sizeof(mt352_softdown));
157
	if (state->config->adc_clock)
158
		adc_clock = state->config->adc_clock;
159
	if (state->config->if2)
160
		if2 = state->config->if2;
122
161
123
	return 0;
162
	ife = (2*adc_clock - if2);
163
	value = -16374 * ife / adc_clock;
164
	dprintk("%s: if2 %d, ife %d, adc_clock %d => %d / 0x%x\n",
165
		__FUNCTION__, if2, ife, adc_clock, value, value & 0x3fff);
166
	buf[0] = msb(value);
167
	buf[1] = lsb(value);
124
}
168
}
125
169
126
static int mt352_set_parameters(struct dvb_frontend* fe,
170
static int mt352_set_parameters(struct dvb_frontend* fe,
127
				struct dvb_frontend_parameters *param)
171
				struct dvb_frontend_parameters *param)
128
{
172
{
129
	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
173
	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
130
	unsigned char buf[14];
174
	unsigned char buf[13];
175
	static unsigned char tuner_go[] = { 0x5d, 0x01 };
176
	static unsigned char fsm_go[]   = { 0x5e, 0x01 };
131
	unsigned int tps = 0;
177
	unsigned int tps = 0;
132
	struct dvb_ofdm_parameters *op = &param->u.ofdm;
178
	struct dvb_ofdm_parameters *op = &param->u.ofdm;
133
	int i;
134
179
135
	switch (op->code_rate_HP) {
180
	switch (op->code_rate_HP) {
136
		case FEC_2_3:
181
		case FEC_2_3:
Lines 241-279 static int mt352_set_parameters(struct d Link Here
241
	buf[1] = msb(tps);      /* TPS_GIVEN_(1|0) */
286
	buf[1] = msb(tps);      /* TPS_GIVEN_(1|0) */
242
	buf[2] = lsb(tps);
287
	buf[2] = lsb(tps);
243
288
244
	buf[3] = 0x50;
289
	buf[3] = 0x50;  // old
245
290
//	buf[3] = 0xf4;  // pinnacle
246
	/**
247
	 *  these settings assume 20.48MHz f_ADC, for other tuners you might
248
	 *  need other values. See p. 33 in the MT352 Design Manual.
249
	 */
250
	if (op->bandwidth == BANDWIDTH_8_MHZ) {
251
		buf[4] = 0x72;  /* TRL_NOMINAL_RATE_(1|0) */
252
		buf[5] = 0x49;
253
	} else if (op->bandwidth == BANDWIDTH_7_MHZ) {
254
		buf[4] = 0x64;
255
		buf[5] = 0x00;
256
	} else {		/* 6MHz */
257
		buf[4] = 0x55;
258
		buf[5] = 0xb7;
259
	}
260
261
	buf[6] = 0x31;  /* INPUT_FREQ_(1|0), 20.48MHz clock, 36.166667MHz IF */
262
	buf[7] = 0x05;  /* see MT352 Design Manual page 32 for details */
263
291
292
	mt352_calc_nominal_rate(state, op->bandwidth, buf+4);
293
	mt352_calc_input_freq(state, buf+6);
264
	state->config->pll_set(fe, param, buf+8);
294
	state->config->pll_set(fe, param, buf+8);
265
295
266
	buf[13] = 0x01; /* TUNER_GO!! */
296
#if 0 /* FIXME: should be catched elsewhere ... */
267
268
	/* Only send the tuning request if the tuner doesn't have the requested
297
	/* Only send the tuning request if the tuner doesn't have the requested
269
	 * parameters already set.  Enhances tuning time and prevents stream
298
	 * parameters already set.  Enhances tuning time and prevents stream
270
	 * breakup when retuning the same transponder. */
299
	 * breakup when retuning the same transponder. */
271
	for (i = 1; i < 13; i++)
300
	for (i = 1; i < 13; i++)
272
		if (buf[i] != mt352_read_register(state, i + 0x50)) {
301
		if (buf[i] != mt352_read_register(state, i + 0x50))
273
			mt352_write(fe, buf, sizeof(buf));
274
			break;
302
			break;
275
		}
303
	if (13 == i)
304
		/* no changes */
305
		return 0;
306
#endif
276
307
308
	mt352_write(fe, buf, sizeof(buf));
309
	if (state->config->no_tuner) {
310
		/* start decoding */
311
		mt352_write(fe, fsm_go, 2);
312
	} else {
313
		/* start tuning */
314
		mt352_write(fe, tuner_go, 2);
315
	}
277
	return 0;
316
	return 0;
278
}
317
}
279
318
Lines 395-418 static int mt352_get_parameters(struct d Link Here
395
static int mt352_read_status(struct dvb_frontend* fe, fe_status_t* status)
434
static int mt352_read_status(struct dvb_frontend* fe, fe_status_t* status)
396
{
435
{
397
	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
436
	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
398
	u8 r;
437
#if 1
399
438
	int val;
400
		*status = 0;
401
	r = mt352_read_register (state, STATUS_0);
402
		if (r & (1 << 4))
403
			*status = FE_HAS_CARRIER;
404
		if (r & (1 << 1))
405
			*status |= FE_HAS_VITERBI;
406
		if (r & (1 << 5))
407
			*status |= FE_HAS_LOCK;
408
439
409
	r = mt352_read_register (state, STATUS_1);
440
	if (0 != mt352_read_register(state, INTERRUPT_0)) {
410
		if (r & (1 << 1))
441
		val = mt352_read_register(state, STATUS_0);
411
			*status |= FE_HAS_SYNC;
442
		if (-1 != val)
443
			state->s0 = val;
444
		val = mt352_read_register(state, STATUS_1);
445
		if (-1 != val)
446
			state->s1 = val;
447
		val = mt352_read_register(state, STATUS_3);
448
		if (-1 != val)
449
			state->s3 = val;
450
	}
451
#else
452
	state->s0 = mt352_read_register(state, STATUS_0);
453
	state->s1 = mt352_read_register(state, STATUS_1);
454
	state->s3 = mt352_read_register(state, STATUS_3);
455
	if (-1 == state->s0 || -1 == state->s1 || -1 == state->s3)
456
		return -EIO;
457
#endif
412
458
413
	r = mt352_read_register (state, STATUS_3);
459
	*status = 0;
414
		if (r & (1 << 6))
460
	if (state->s0 & (1 << 4))
415
			*status |= FE_HAS_SIGNAL;
461
		*status |= FE_HAS_CARRIER;
462
	if (state->s0 & (1 << 1))
463
		*status |= FE_HAS_VITERBI;
464
	if (state->s0 & (1 << 5))
465
		*status |= FE_HAS_LOCK;
466
	if (state->s1 & (1 << 1))
467
		*status |= FE_HAS_SYNC;
468
	if (state->s3 & (1 << 6))
469
		*status |= FE_HAS_SIGNAL;
416
470
417
	if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
471
	if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
418
		      (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
472
		      (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
Lines 470-476 static int mt352_get_tune_settings(struc Link Here
470
	fe_tune_settings->max_drift = 0;
524
	fe_tune_settings->max_drift = 0;
471
525
472
	return 0;
526
	return 0;
473
	}
527
}
474
528
475
static int mt352_init(struct dvb_frontend* fe)
529
static int mt352_init(struct dvb_frontend* fe)
476
{
530
{
Lines 478-499 static int mt352_init(struct dvb_fronten Link Here
478
532
479
	static u8 mt352_reset_attach [] = { RESET, 0xC0 };
533
	static u8 mt352_reset_attach [] = { RESET, 0xC0 };
480
534
535
	dprintk("%s: hello\n",__FUNCTION__);
536
481
	if ((mt352_read_register(state, CLOCK_CTL) & 0x10) == 0 ||
537
	if ((mt352_read_register(state, CLOCK_CTL) & 0x10) == 0 ||
482
	    (mt352_read_register(state, CONFIG) & 0x20) == 0) {
538
	    (mt352_read_register(state, CONFIG) & 0x20) == 0) {
483
539
484
	/* Do a "hard" reset */
540
		/* Do a "hard" reset */
485
		mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach));
541
		mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach));
486
		return state->config->demod_init(fe);
542
		return state->config->demod_init(fe);
487
	}
543
	}
488
544
489
	return 0;
545
	return 0;
490
	}
546
}
491
547
492
static void mt352_release(struct dvb_frontend* fe)
548
static void mt352_release(struct dvb_frontend* fe)
493
{
549
{
494
	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
550
	struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
495
		kfree(state);
551
	kfree(state);
496
	}
552
}
497
553
498
static struct dvb_frontend_ops mt352_ops;
554
static struct dvb_frontend_ops mt352_ops;
499
555
Lines 505-510 struct dvb_frontend* mt352_attach(const Link Here
505
	/* allocate memory for the internal state */
561
	/* allocate memory for the internal state */
506
	state = (struct mt352_state*) kmalloc(sizeof(struct mt352_state), GFP_KERNEL);
562
	state = (struct mt352_state*) kmalloc(sizeof(struct mt352_state), GFP_KERNEL);
507
	if (state == NULL) goto error;
563
	if (state == NULL) goto error;
564
	memset(state,0,sizeof(*state));
508
565
509
	/* setup the state */
566
	/* setup the state */
510
	state->config = config;
567
	state->config = config;
Lines 568-570 MODULE_LICENSE("GPL"); Link Here
568
EXPORT_SYMBOL(mt352_attach);
625
EXPORT_SYMBOL(mt352_attach);
569
EXPORT_SYMBOL(mt352_write);
626
EXPORT_SYMBOL(mt352_write);
570
EXPORT_SYMBOL(mt352_read);
627
EXPORT_SYMBOL(mt352_read);
628
/*
629
 * Local variables:
630
 * c-basic-offset: 8
631
 * compile-command: "make DVB=1"
632
 * End:
633
 */
(-)linux-2.6.11.orig/drivers/media/dvb/frontends/mt352.h (-1 / +14 lines)
Lines 40-45 struct mt352_config Link Here
40
	/* the demodulator's i2c address */
40
	/* the demodulator's i2c address */
41
	u8 demod_address;
41
	u8 demod_address;
42
42
43
	/* frequencies in kHz */
44
	int adc_clock;  // default: 20480
45
	int if2;        // default: 36166
46
47
	/* set if no pll is connected to the secondary i2c bus */
48
	int no_tuner;
49
43
	/* Initialise the demodulator and PLL. Cannot be NULL */
50
	/* Initialise the demodulator and PLL. Cannot be NULL */
44
	int (*demod_init)(struct dvb_frontend* fe);
51
	int (*demod_init)(struct dvb_frontend* fe);
45
52
Lines 54-59 extern struct dvb_frontend* mt352_attach Link Here
54
					 struct i2c_adapter* i2c);
61
					 struct i2c_adapter* i2c);
55
62
56
extern int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen);
63
extern int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen);
57
extern u8 mt352_read(struct dvb_frontend *fe, u8 reg);
64
extern int mt352_read(struct dvb_frontend *fe, u8 reg);
58
65
59
#endif // MT352_H
66
#endif // MT352_H
67
68
/*
69
 * Local variables:
70
 * c-basic-offset: 8
71
 * End:
72
 */
(-)linux-2.6.11/drivers/media/dvb/frontends/or51132.c (+628 lines)
Added Link Here
1
/*
2
 *    Support for OR51132 (pcHDTV HD-3000) - VSB/QAM
3
 *
4
 *    Copyright (C) 2005 Kirk Lapray <kirk_lapray@bigfoot.com>
5
 *
6
 *    Based on code from Jack Kelliher (kelliher@xmission.com)
7
 *                           Copyright (C) 2002 & pcHDTV, inc.
8
 *
9
 *    This program is free software; you can redistribute it and/or modify
10
 *    it under the terms of the GNU General Public License as published by
11
 *    the Free Software Foundation; either version 2 of the License, or
12
 *    (at your option) any later version.
13
 *
14
 *    This program is distributed in the hope that it will be useful,
15
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *    GNU General Public License for more details.
18
 *
19
 *    You should have received a copy of the GNU General Public License
20
 *    along with this program; if not, write to the Free Software
21
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
 *
23
*/
24
25
/*
26
 * This driver needs two external firmware files. Please copy
27
 * "dvb-fe-or51132-vsb.fw" and "dvb-fe-or51132-qam.fw" to
28
 * /usr/lib/hotplug/firmware/ or /lib/firmware/
29
 * (depending on configuration of firmware hotplug).
30
 */
31
#define OR51132_VSB_FIRMWARE "dvb-fe-or51132-vsb.fw"
32
#define OR51132_QAM_FIRMWARE "dvb-fe-or51132-qam.fw"
33
34
#include <linux/kernel.h>
35
#include <linux/module.h>
36
#include <linux/moduleparam.h>
37
#include <linux/init.h>
38
#include <linux/delay.h>
39
#include <asm/byteorder.h>
40
41
#include "dvb_frontend.h"
42
#include "dvb-pll.h"
43
#include "or51132.h"
44
45
static int debug;
46
#define dprintk(args...) \
47
	do { \
48
		if (debug) printk(KERN_DEBUG "or51132: " args); \
49
	} while (0)
50
51
52
struct or51132_state
53
{
54
	struct i2c_adapter* i2c;
55
	struct dvb_frontend_ops ops;
56
57
	/* Configuration settings */
58
	const struct or51132_config* config;
59
60
	struct dvb_frontend frontend;
61
	
62
	/* Demodulator private data */
63
	fe_modulation_t current_modulation;
64
65
	/* Tuner private data */
66
	u32 current_frequency;
67
};
68
69
static int i2c_writebytes (struct or51132_state* state, u8 reg, u8 *buf, int len)
70
{
71
	int err;
72
	struct i2c_msg msg;
73
	msg.addr  = reg;
74
	msg.flags = 0;
75
	msg.len   = len;
76
	msg.buf   = buf;
77
78
	if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
79
		printk(KERN_WARNING "or51132: i2c_writebytes error (addr %02x, err == %i)\n", reg, err);
80
		return -EREMOTEIO;
81
	}
82
83
	return 0;
84
}
85
86
static u8 i2c_readbytes (struct or51132_state* state, u8 reg, u8* buf, int len)
87
{
88
	int err;
89
	struct i2c_msg msg;
90
	msg.addr   = reg;
91
	msg.flags = I2C_M_RD;
92
	msg.len = len;
93
	msg.buf = buf;
94
95
	if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
96
		printk(KERN_WARNING "or51132: i2c_readbytes error (addr %02x, err == %i)\n", reg, err);
97
		return -EREMOTEIO;
98
	}
99
100
	return 0;
101
}
102
103
static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
104
{
105
	struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
106
	static u8 run_buf[] = {0x7F,0x01};
107
	static u8 get_ver_buf[] = {0x04,0x00,0x30,0x00,0x00};
108
	u8 rec_buf[14];
109
	u8 cmd_buf[14];
110
	u32 firmwareAsize, firmwareBsize;
111
	int i,ret;
112
113
	dprintk("Firmware is %ld bytes\n",fw->size);
114
115
	/* Get size of firmware A and B */
116
	firmwareAsize = le32_to_cpu(*((u32*)fw->data));
117
	dprintk("FirmwareA is %i bytes\n",firmwareAsize);
118
	firmwareBsize = le32_to_cpu(*((u32*)(fw->data+4)));
119
	dprintk("FirmwareB is %i bytes\n",firmwareBsize);
120
121
	/* Upload firmware */
122
	if ((ret = i2c_writebytes(state,state->config->demod_address,
123
				 &fw->data[8],firmwareAsize))) {
124
		printk(KERN_WARNING "or51132: load_firmware error 1\n");
125
		return ret;
126
	}
127
	msleep(1); /* 1ms */
128
	if ((ret = i2c_writebytes(state,state->config->demod_address,
129
				 &fw->data[8+firmwareAsize],firmwareBsize))) {
130
		printk(KERN_WARNING "or51132: load_firmware error 2\n");
131
		return ret;
132
	}
133
	msleep(1); /* 1ms */
134
135
	if ((ret = i2c_writebytes(state,state->config->demod_address,
136
				 run_buf,2))) {
137
		printk(KERN_WARNING "or51132: load_firmware error 3\n");
138
		return ret;
139
	}
140
141
	/* Wait at least 5 msec */ 
142
	msleep(20); /* 10ms */
143
144
	if ((ret = i2c_writebytes(state,state->config->demod_address,
145
				 run_buf,2))) {
146
		printk(KERN_WARNING "or51132: load_firmware error 4\n");
147
		return ret;
148
	}
149
150
	/* 50ms for operation to begin */
151
	msleep(50);
152
153
	/* Read back ucode version to besure we loaded correctly and are really up and running */
154
	/* Get uCode version */
155
	cmd_buf[0] = 0x10;
156
	cmd_buf[1] = 0x10;
157
	cmd_buf[2] = 0x00;
158
	cmd_buf[3] = 0x00;
159
	msleep(20); /* 20ms */
160
	if ((ret = i2c_writebytes(state,state->config->demod_address,
161
				 cmd_buf,3))) {
162
		printk(KERN_WARNING "or51132: load_firmware error a\n");
163
		return ret;
164
	}
165
166
	cmd_buf[0] = 0x04;
167
	cmd_buf[1] = 0x17;
168
	cmd_buf[2] = 0x00;
169
	cmd_buf[3] = 0x00;
170
	msleep(20); /* 20ms */
171
	if ((ret = i2c_writebytes(state,state->config->demod_address,
172
				 cmd_buf,2))) {
173
		printk(KERN_WARNING "or51132: load_firmware error b\n");
174
		return ret;
175
	}
176
177
	cmd_buf[0] = 0x00;
178
	cmd_buf[1] = 0x00;
179
	cmd_buf[2] = 0x00;
180
	cmd_buf[3] = 0x00;
181
	msleep(20); /* 20ms */
182
	if ((ret = i2c_writebytes(state,state->config->demod_address,
183
				 cmd_buf,2))) {
184
		printk(KERN_WARNING "or51132: load_firmware error c\n");
185
		return ret;
186
	}
187
188
	for(i=0;i<4;i++) {
189
		msleep(20); /* 20ms */
190
		get_ver_buf[4] = i+1;
191
		if ((ret = i2c_readbytes(state,state->config->demod_address,
192
					&rec_buf[i*2],2))) {
193
			printk(KERN_WARNING 
194
			       "or51132: load_firmware error d - %d\n",i);
195
			return ret;
196
		}
197
	}
198
199
	printk(KERN_WARNING
200
	       "or51132: Version: %02X%02X%02X%02X-%02X%02X%02X%02X (%02X%01X-%01X-%02X%01X-%01X)\n",
201
	       rec_buf[1],rec_buf[0],rec_buf[3],rec_buf[2],
202
	       rec_buf[5],rec_buf[4],rec_buf[7],rec_buf[6],
203
	       rec_buf[3],rec_buf[2]>>4,rec_buf[2]&0x0f,
204
	       rec_buf[5],rec_buf[4]>>4,rec_buf[4]&0x0f);
205
206
	cmd_buf[0] = 0x10;
207
	cmd_buf[1] = 0x00;
208
	cmd_buf[2] = 0x00;
209
	cmd_buf[3] = 0x00;
210
	msleep(20); /* 20ms */
211
	if ((ret = i2c_writebytes(state,state->config->demod_address,
212
				 cmd_buf,3))) {
213
		printk(KERN_WARNING "or51132: load_firmware error e\n");
214
		return ret;
215
	}
216
	return 0;
217
};
218
219
static int or51132_init(struct dvb_frontend* fe)
220
{
221
	return 0;
222
}
223
224
static int or51132_read_ber(struct dvb_frontend* fe, u32* ber)
225
{
226
	*ber = 0;
227
	return 0;
228
}
229
230
static int or51132_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
231
{
232
	*ucblocks = 0;
233
	return 0;
234
}
235
236
static int or51132_sleep(struct dvb_frontend* fe)
237
{
238
	return 0;
239
}
240
241
static int or51132_setmode(struct dvb_frontend* fe)
242
{
243
	struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
244
	unsigned char cmd_buf[4];
245
246
	dprintk("setmode %d\n",(int)state->current_modulation);
247
	/* set operation mode in Receiver 1 register; */
248
	cmd_buf[0] = 0x04;
249
	cmd_buf[1] = 0x01;
250
	switch (state->current_modulation) {
251
	case QAM_256:
252
	case QAM_64:
253
	case QAM_AUTO:
254
		/* Auto-deinterleave; MPEG ser, MPEG2tr, phase noise-high*/
255
		cmd_buf[2] = 0x5F;
256
		break;
257
	case VSB_8:
258
		/* Auto CH, Auto NTSC rej, MPEGser, MPEG2tr, phase noise-high*/
259
		cmd_buf[2] = 0x50;
260
		break;
261
	default:
262
		printk("setmode:Modulation set to unsupported value\n");
263
	};
264
	cmd_buf[3] = 0x00;
265
	if (i2c_writebytes(state,state->config->demod_address,
266
			   cmd_buf,3)) {
267
		printk(KERN_WARNING "or51132: set_mode error 1\n");
268
		return -1;
269
	}
270
	dprintk("or51132: set #1 to %02x\n", cmd_buf[2]);
271
272
	/* Set operation mode in Receiver 6 register */
273
	cmd_buf[0] = 0x1C;
274
	switch (state->current_modulation) {
275
	case QAM_AUTO:
276
		/* REC MODE Normal Carrier Lock */
277
		cmd_buf[1] = 0x00;
278
		/* Channel MODE Auto QAM64/256 */
279
		cmd_buf[2] = 0x4f;
280
		break;
281
	case QAM_256:
282
		/* REC MODE Normal Carrier Lock */
283
		cmd_buf[1] = 0x00;
284
		/* Channel MODE QAM256 */
285
		cmd_buf[2] = 0x45;
286
		break;
287
	case QAM_64:
288
		/* REC MODE Normal Carrier Lock */
289
		cmd_buf[1] = 0x00;
290
		/* Channel MODE QAM64 */
291
		cmd_buf[2] = 0x43;
292
		break;
293
	case VSB_8:
294
		 /* REC MODE inv IF spectrum, Normal */
295
		cmd_buf[1] = 0x03;
296
		/* Channel MODE ATSC/VSB8 */
297
		cmd_buf[2] = 0x06;
298
		break;
299
	default:
300
		printk("setmode: Modulation set to unsupported value\n");
301
	};
302
	cmd_buf[3] = 0x00;
303
	msleep(20); /* 20ms */
304
	if (i2c_writebytes(state,state->config->demod_address,
305
			   cmd_buf,3)) {
306
		printk(KERN_WARNING "or51132: set_mode error 2\n");
307
		return -1;
308
	}
309
	dprintk("or51132: set #6 to 0x%02x%02x\n", cmd_buf[1], cmd_buf[2]);
310
311
	return 0;
312
}
313
314
static int or51132_set_parameters(struct dvb_frontend* fe,
315
				  struct dvb_frontend_parameters *param)
316
{
317
	int ret;
318
	u8 buf[4];
319
	struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
320
	const struct firmware *fw;
321
322
	/* Change only if we are actually changing the modulation */
323
	if (state->current_modulation != param->u.vsb.modulation) {
324
		switch(param->u.vsb.modulation) {
325
		case VSB_8:
326
			dprintk("set_parameters VSB MODE\n");
327
			printk("or51132: Waiting for firmware upload(%s)...\n",
328
			       OR51132_VSB_FIRMWARE);
329
			ret = request_firmware(&fw, OR51132_VSB_FIRMWARE, 
330
					       &state->i2c->dev);
331
			if (ret){
332
				printk(KERN_WARNING "or51132: No firmware up"
333
				       "loaded(timeout or file not found?)\n");
334
				return ret;
335
			}
336
			/* Set non-punctured clock for VSB */
337
			state->config->set_ts_params(fe, 0);
338
			break;
339
		case QAM_AUTO:
340
		case QAM_64:
341
		case QAM_256:
342
			dprintk("set_parameters QAM MODE\n");
343
			printk("or51132: Waiting for firmware upload(%s)...\n",
344
			       OR51132_QAM_FIRMWARE);
345
			ret = request_firmware(&fw, OR51132_QAM_FIRMWARE, 
346
					       &state->i2c->dev);
347
			if (ret){
348
				printk(KERN_WARNING "or51132: No firmware up"
349
				       "loaded(timeout or file not found?)\n");
350
				return ret;
351
			}
352
			/* Set punctured clock for QAM */
353
			state->config->set_ts_params(fe, 1);
354
			break;
355
		default:
356
			printk("or51132:Modulation type(%d) UNSUPPORTED\n",
357
			       param->u.vsb.modulation);
358
			return -1;
359
		};
360
		ret = or51132_load_firmware(fe, fw);
361
		release_firmware(fw);
362
		if (ret) {
363
			printk(KERN_WARNING "or51132: Writing firmware to "
364
			       "device failed!\n");
365
			return ret;
366
		}
367
		printk("or51132: Firmware upload complete.\n");
368
369
		state->current_modulation = param->u.vsb.modulation;
370
		or51132_setmode(fe);
371
	}
372
373
	/* Change only if we are actually changing the channel */
374
	if (state->current_frequency != param->frequency) {
375
		dvb_pll_configure(state->config->pll_desc, buf,
376
				  param->frequency, 0);
377
		dprintk("set_parameters tuner bytes: 0x%02x 0x%02x "
378
			"0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]);
379
		if (i2c_writebytes(state, state->config->pll_address ,buf, 4))
380
			printk(KERN_WARNING "or51132: set_parameters error "
381
			       "writing to tuner\n");
382
	
383
		/* Set to current mode */
384
		or51132_setmode(fe);
385
	
386
		/* Update current frequency */
387
		state->current_frequency = param->frequency;
388
	}
389
	return 0;
390
}
391
392
static int or51132_read_status(struct dvb_frontend* fe, fe_status_t* status)
393
{
394
	struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
395
	unsigned char rec_buf[2];
396
	unsigned char snd_buf[2];
397
	*status = 0;
398
399
	/* Receiver Status */
400
	snd_buf[0]=0x04;
401
	snd_buf[1]=0x00;
402
	msleep(30); /* 30ms */
403
	if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
404
		printk(KERN_WARNING "or51132: read_status write error\n");
405
		return -1;
406
	}
407
	msleep(30); /* 30ms */
408
	if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
409
		printk(KERN_WARNING "or51132: read_status read error\n");
410
		return -1;
411
	}
412
	dprintk("read_status %x %x\n",rec_buf[0],rec_buf[1]);
413
414
	if (rec_buf[1] & 0x01) { /* Receiver Lock */
415
		*status |= FE_HAS_SIGNAL;
416
		*status |= FE_HAS_CARRIER;
417
		*status |= FE_HAS_VITERBI;
418
		*status |= FE_HAS_SYNC;
419
		*status |= FE_HAS_LOCK;
420
	}
421
	return 0;
422
}
423
424
/* log10-1 table at .5 increments from 1 to 100.5 */
425
unsigned int i100x20log10[] = {
426
     0,  352,  602,  795,  954, 1088, 1204, 1306, 1397, 1480,
427
  1556, 1625, 1690, 1750, 1806, 1858, 1908, 1955, 2000, 2042,
428
  2082, 2121, 2158, 2193, 2227, 2260, 2292, 2322, 2352, 2380,
429
  2408, 2434, 2460, 2486, 2510, 2534, 2557, 2580, 2602, 2623,
430
  2644, 2664, 2684, 2704, 2723, 2742, 2760, 2778, 2795, 2813,
431
  2829, 2846, 2862, 2878, 2894, 2909, 2924, 2939, 2954, 2968,
432
  2982, 2996, 3010, 3023, 3037, 3050, 3062, 3075, 3088, 3100,
433
  3112, 3124, 3136, 3148, 3159, 3170, 3182, 3193, 3204, 3214,
434
  3225, 3236, 3246, 3256, 3266, 3276, 3286, 3296, 3306, 3316,
435
  3325, 3334, 3344, 3353, 3362, 3371, 3380, 3389, 3397, 3406,
436
  3415, 3423, 3432, 3440, 3448, 3456, 3464, 3472, 3480, 3488,
437
  3496, 3504, 3511, 3519, 3526, 3534, 3541, 3549, 3556, 3563,
438
  3570, 3577, 3584, 3591, 3598, 3605, 3612, 3619, 3625, 3632,
439
  3639, 3645, 3652, 3658, 3665, 3671, 3677, 3683, 3690, 3696,
440
  3702, 3708, 3714, 3720, 3726, 3732, 3738, 3744, 3750, 3755,
441
  3761, 3767, 3772, 3778, 3784, 3789, 3795, 3800, 3806, 3811,
442
  3816, 3822, 3827, 3832, 3838, 3843, 3848, 3853, 3858, 3863,
443
  3868, 3874, 3879, 3884, 3888, 3893, 3898, 3903, 3908, 3913,
444
  3918, 3922, 3927, 3932, 3936, 3941, 3946, 3950, 3955, 3960,
445
  3964, 3969, 3973, 3978, 3982, 3986, 3991, 3995, 4000, 4004,
446
};
447
448
unsigned int denom[] = {1,1,100,1000,10000,100000,1000000,10000000,100000000};
449
450
unsigned int i20Log10(unsigned short val)
451
{
452
	unsigned int rntval = 100;
453
	unsigned int tmp = val;
454
	unsigned int exp = 1;
455
456
	while(tmp > 100) {tmp /= 100; exp++;}
457
458
	val = (2 * val)/denom[exp];
459
	if (exp > 1) rntval = 2000*exp;
460
461
	rntval += i100x20log10[val];
462
	return rntval;
463
}
464
465
static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
466
{
467
	struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
468
	unsigned char rec_buf[2];
469
	unsigned char snd_buf[2];
470
	u8 rcvr_stat;
471
	u16 snr_equ;
472
	int usK;
473
	
474
	snd_buf[0]=0x04;
475
	snd_buf[1]=0x02; /* SNR after Equalizer */
476
	msleep(30); /* 30ms */
477
	if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
478
		printk(KERN_WARNING "or51132: read_status write error\n");
479
		return -1;
480
	}
481
	msleep(30); /* 30ms */
482
	if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
483
		printk(KERN_WARNING "or51132: read_status read error\n");
484
		return -1;
485
	}
486
	snr_equ = rec_buf[0] | (rec_buf[1] << 8);
487
	dprintk("read_signal_strength snr_equ %x %x (%i)\n",rec_buf[0],rec_buf[1],snr_equ);
488
489
	/* Receiver Status */
490
	snd_buf[0]=0x04;
491
	snd_buf[1]=0x00;
492
	msleep(30); /* 30ms */
493
	if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
494
		printk(KERN_WARNING "or51132: read_signal_strength read_status write error\n");
495
		return -1;
496
	}
497
	msleep(30); /* 30ms */
498
	if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
499
		printk(KERN_WARNING "or51132: read_signal_strength read_status read error\n");
500
		return -1;
501
	}
502
	dprintk("read_signal_strength read_status %x %x\n",rec_buf[0],rec_buf[1]);
503
	rcvr_stat = rec_buf[1];
504
	usK = (rcvr_stat & 0x10) ? 3 : 0;
505
506
        /* The value reported back from the frontend will be FFFF=100% 0000=0% */
507
	*strength = (((8952 - i20Log10(snr_equ) - usK*100)/3+5)*65535)/1000;
508
	dprintk("read_signal_strength %i\n",*strength);
509
510
	return 0;
511
}
512
513
static int or51132_read_snr(struct dvb_frontend* fe, u16* snr)
514
{
515
	struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
516
	unsigned char rec_buf[2];
517
	unsigned char snd_buf[2];
518
	u16 snr_equ;
519
520
	snd_buf[0]=0x04;
521
	snd_buf[1]=0x02; /* SNR after Equalizer */
522
	msleep(30); /* 30ms */
523
	if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
524
		printk(KERN_WARNING "or51132: read_snr write error\n");
525
		return -1;
526
	}
527
	msleep(30); /* 30ms */
528
	if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
529
		printk(KERN_WARNING "or51132: read_snr dvr read error\n");
530
		return -1;
531
	}
532
	snr_equ = rec_buf[0] | (rec_buf[1] << 8);
533
	dprintk("read_snr snr_equ %x %x (%i)\n",rec_buf[0],rec_buf[1],snr_equ);
534
535
	*snr = 0xFFFF - snr_equ;
536
	dprintk("read_snr %i\n",*snr);
537
538
	return 0;
539
}
540
541
static int or51132_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fe_tune_settings)
542
{
543
	fe_tune_settings->min_delay_ms = 500;
544
	fe_tune_settings->step_size = 0;
545
	fe_tune_settings->max_drift = 0;
546
547
	return 0;
548
}
549
550
static void or51132_release(struct dvb_frontend* fe)
551
{
552
	struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
553
	kfree(state);
554
}
555
556
static struct dvb_frontend_ops or51132_ops;
557
558
struct dvb_frontend* or51132_attach(const struct or51132_config* config,
559
				    struct i2c_adapter* i2c)
560
{
561
	struct or51132_state* state = NULL;
562
563
	/* Allocate memory for the internal state */
564
	state = kmalloc(sizeof(struct or51132_state), GFP_KERNEL);
565
	if (state == NULL)
566
		goto error;
567
568
	/* Setup the state */
569
	state->config = config;
570
	state->i2c = i2c;
571
	memcpy(&state->ops, &or51132_ops, sizeof(struct dvb_frontend_ops));
572
	state->current_frequency = -1;
573
	state->current_modulation = -1;
574
575
	/* Create dvb_frontend */
576
	state->frontend.ops = &state->ops;
577
	state->frontend.demodulator_priv = state;
578
	return &state->frontend;
579
580
error:
581
	if (state)
582
		kfree(state);
583
	return NULL;
584
}
585
586
static struct dvb_frontend_ops or51132_ops = {
587
588
	.info = {
589
		.name			= "Oren OR51132 VSB/QAM Frontend",
590
		.type 			= FE_ATSC,
591
		.frequency_min		= 44000000,
592
		.frequency_max		= 958000000,
593
		.frequency_stepsize	= 166666,
594
		.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
595
			FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
596
			FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_QAM_AUTO |
597
			FE_CAN_8VSB
598
	},
599
600
	.release = or51132_release,
601
602
	.init = or51132_init,
603
	.sleep = or51132_sleep,
604
605
	.set_frontend = or51132_set_parameters,
606
	.get_tune_settings = or51132_get_tune_settings,
607
608
	.read_status = or51132_read_status,
609
	.read_ber = or51132_read_ber,
610
	.read_signal_strength = or51132_read_signal_strength,
611
	.read_snr = or51132_read_snr,
612
	.read_ucblocks = or51132_read_ucblocks,
613
};
614
615
module_param(debug, int, 0644);
616
MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
617
618
MODULE_DESCRIPTION("OR51132 ATSC [pcHDTV HD-3000] (8VSB & ITU J83 AnnexB FEC QAM64/256) Demodulator Driver");
619
MODULE_AUTHOR("Kirk Lapray");
620
MODULE_LICENSE("GPL");
621
622
EXPORT_SYMBOL(or51132_attach);
623
624
/*
625
 * Local variables:
626
 * c-basic-offset: 8
627
 * End:
628
 */
(-)linux-2.6.11/drivers/media/dvb/frontends/or51132.h (+48 lines)
Added Link Here
1
/*
2
 *    Support for OR51132 (pcHDTV HD-3000) - VSB/QAM
3
 *
4
 *    Copyright (C) 2005 Kirk Lapray <kirk_lapray@bigfoot.com>
5
 *
6
 *    This program is free software; you can redistribute it and/or modify
7
 *    it under the terms of the GNU General Public License as published by
8
 *    the Free Software Foundation; either version 2 of the License, or
9
 *    (at your option) any later version.
10
 *
11
 *    This program is distributed in the hope that it will be useful,
12
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *    GNU General Public License for more details.
15
 *
16
 *    You should have received a copy of the GNU General Public License
17
 *    along with this program; if not, write to the Free Software
18
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
 *
20
*/
21
22
#ifndef OR51132_H
23
#define OR51132_H
24
25
#include <linux/firmware.h>
26
#include <linux/dvb/frontend.h>
27
28
struct or51132_config
29
{
30
	/* The demodulator's i2c address */
31
	u8 demod_address;
32
	u8 pll_address;
33
	struct dvb_pll_desc *pll_desc;
34
35
	/* Need to set device param for start_dma */
36
	int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
37
};
38
39
extern struct dvb_frontend* or51132_attach(const struct or51132_config* config,
40
					   struct i2c_adapter* i2c);
41
42
#endif // OR51132_H
43
44
/*
45
 * Local variables:
46
 * c-basic-offset: 8
47
 * End:
48
 */
(-)linux-2.6.11.orig/drivers/media/radio/miropcm20-radio.c (-9 / +3 lines)
Lines 75-83 static int pcm20_getflags(struct pcm20_d Link Here
75
75
76
	if ((i=aci_rw_cmd(ACI_READ_TUNERSTATION, -1, -1))<0)
76
	if ((i=aci_rw_cmd(ACI_READ_TUNERSTATION, -1, -1))<0)
77
		return i;
77
		return i;
78
#ifdef DEBUG
78
	pr_debug("check_sig: 0x%x\n", i);
79
	printk("check_sig: 0x%x\n", i);
80
#endif
81
	if (i & 0x80) {
79
	if (i & 0x80) {
82
		/* no signal from tuner */
80
		/* no signal from tuner */
83
		*flags=0;
81
		*flags=0;
Lines 107-115 static int pcm20_getflags(struct pcm20_d Link Here
107
105
108
	if ((i=aci_rds_cmd(RDS_RXVALUE, &buf, 1))<0)
106
	if ((i=aci_rds_cmd(RDS_RXVALUE, &buf, 1))<0)
109
		return i;
107
		return i;
110
#ifdef DEBUG
108
	pr_debug("rds-signal: %d\n", buf);
111
	printk("rds-signal: %d\n", buf);
112
#endif
113
	if (buf > 15) {
109
	if (buf > 15) {
114
		printk("miropcm20-radio: RX strengths unexpected high...\n");
110
		printk("miropcm20-radio: RX strengths unexpected high...\n");
115
		buf=15;
111
		buf=15;
Lines 172-180 static int pcm20_do_ioctl(struct inode * Link Here
172
			unsigned long *freq = arg;
168
			unsigned long *freq = arg;
173
			pcm20->freq = *freq;
169
			pcm20->freq = *freq;
174
			i=pcm20_setfreq(pcm20, pcm20->freq);
170
			i=pcm20_setfreq(pcm20, pcm20->freq);
175
#ifdef DEBUG
171
			pr_debug("First view (setfreq): 0x%x\n", i);
176
			printk("First view (setfreq): 0x%x\n", i);
177
#endif
178
			return i;
172
			return i;
179
		}
173
		}
180
		case VIDIOCGAUDIO:
174
		case VIDIOCGAUDIO:
(-)linux-2.6.11.orig/drivers/media/radio/radio-zoltrix.c (-19 / +7 lines)
Lines 29-35 Link Here
29
#include <linux/module.h>	/* Modules                        */
29
#include <linux/module.h>	/* Modules                        */
30
#include <linux/init.h>		/* Initdata                       */
30
#include <linux/init.h>		/* Initdata                       */
31
#include <linux/ioport.h>	/* check_region, request_region   */
31
#include <linux/ioport.h>	/* check_region, request_region   */
32
#include <linux/delay.h>	/* udelay                 */
32
#include <linux/delay.h>	/* udelay, msleep                 */
33
#include <asm/io.h>		/* outb, outb_p                   */
33
#include <asm/io.h>		/* outb, outb_p                   */
34
#include <asm/uaccess.h>	/* copy to/from user              */
34
#include <asm/uaccess.h>	/* copy to/from user              */
35
#include <linux/videodev.h>	/* kernel radio structs           */
35
#include <linux/videodev.h>	/* kernel radio structs           */
Lines 51-65 struct zol_device { Link Here
51
	struct semaphore lock;
51
	struct semaphore lock;
52
};
52
};
53
53
54
55
/* local things */
56
57
static void sleep_delay(void)
58
{
59
	/* Sleep nicely for +/- 10 mS */
60
	schedule();
61
}
62
63
static int zol_setvol(struct zol_device *dev, int vol)
54
static int zol_setvol(struct zol_device *dev, int vol)
64
{
55
{
65
	dev->curvol = vol;
56
	dev->curvol = vol;
Lines 76-82 static int zol_setvol(struct zol_device Link Here
76
	}
67
	}
77
68
78
	outb(dev->curvol-1, io);
69
	outb(dev->curvol-1, io);
79
	sleep_delay();
70
	msleep(10);
80
	inb(io + 2);
71
	inb(io + 2);
81
	up(&dev->lock);
72
	up(&dev->lock);
82
	return 0;
73
	return 0;
Lines 176-186 static int zol_getsigstr(struct zol_devi Link Here
176
	down(&dev->lock);
167
	down(&dev->lock);
177
	outb(0x00, io);         /* This stuff I found to do nothing */
168
	outb(0x00, io);         /* This stuff I found to do nothing */
178
	outb(dev->curvol, io);
169
	outb(dev->curvol, io);
179
	sleep_delay();
170
	msleep(20);
180
	sleep_delay();
181
171
182
	a = inb(io);
172
	a = inb(io);
183
	sleep_delay();
173
	msleep(10);
184
	b = inb(io);
174
	b = inb(io);
185
175
186
	up(&dev->lock);
176
	up(&dev->lock);
Lines 202-212 static int zol_is_stereo (struct zol_dev Link Here
202
	
192
	
203
	outb(0x00, io);
193
	outb(0x00, io);
204
	outb(dev->curvol, io);
194
	outb(dev->curvol, io);
205
	sleep_delay();
195
	msleep(20);
206
	sleep_delay();
207
196
208
	x1 = inb(io);
197
	x1 = inb(io);
209
	sleep_delay();
198
	msleep(10);
210
	x2 = inb(io);
199
	x2 = inb(io);
211
200
212
	up(&dev->lock);
201
	up(&dev->lock);
Lines 368-375 static int __init zoltrix_init(void) Link Here
368
357
369
	outb(0, io);
358
	outb(0, io);
370
	outb(0, io);
359
	outb(0, io);
371
	sleep_delay();
360
	msleep(20);
372
	sleep_delay();
373
	inb(io + 3);
361
	inb(io + 3);
374
362
375
	zoltrix_unit.curvol = 0;
363
	zoltrix_unit.curvol = 0;
(-)linux-2.6.11.orig/drivers/media/video/Kconfig (-4 / +12 lines)
Lines 249-255 config VIDEO_SAA7134 Link Here
249
249
250
config VIDEO_SAA7134_DVB
250
config VIDEO_SAA7134_DVB
251
	tristate "DVB Support for saa7134 based TV cards"
251
	tristate "DVB Support for saa7134 based TV cards"
252
	depends on VIDEO_SAA7134 && DVB_CORE && BROKEN
252
	depends on VIDEO_SAA7134 && DVB_CORE
253
	select VIDEO_BUF_DVB
254
	select DVB_MT352
253
	---help---
255
	---help---
254
	  This adds support for DVB cards based on the
256
	  This adds support for DVB cards based on the
255
	  Philips saa7134 chip.
257
	  Philips saa7134 chip.
Lines 305-315 config VIDEO_HEXIUM_GEMINI Link Here
305
307
306
config VIDEO_CX88
308
config VIDEO_CX88
307
	tristate "Conexant 2388x (bt878 successor) support"
309
	tristate "Conexant 2388x (bt878 successor) support"
308
	depends on VIDEO_DEV && PCI && EXPERIMENTAL
310
	depends on VIDEO_DEV && PCI && I2C && EXPERIMENTAL
309
	select I2C_ALGOBIT
311
	select I2C_ALGOBIT
312
	select FW_LOADER
310
	select VIDEO_BTCX
313
	select VIDEO_BTCX
311
	select VIDEO_BUF
314
	select VIDEO_BUF
312
	select VIDEO_TUNER
315
	select VIDEO_TUNER
316
	select VIDEO_TVEEPROM
317
	select VIDEO_IR
313
	---help---
318
	---help---
314
	  This is a video4linux driver for Conexant 2388x based
319
	  This is a video4linux driver for Conexant 2388x based
315
	  TV cards.
320
	  TV cards.
Lines 319-328 config VIDEO_CX88 Link Here
319
324
320
config VIDEO_CX88_DVB
325
config VIDEO_CX88_DVB
321
	tristate "DVB Support for cx2388x based TV cards"
326
	tristate "DVB Support for cx2388x based TV cards"
322
	depends on VIDEO_CX88 && DVB_CORE && BROKEN
327
	depends on VIDEO_CX88 && DVB_CORE
323
	select VIDEO_BUF_DVB
328
	select VIDEO_BUF_DVB
329
	select DVB_MT352
330
	select DVB_CX22702
331
	select DVB_OR51132
324
	---help---
332
	---help---
325
	  This adds support for DVB cards based on the
333
	  This adds support for DVB/ATSC cards based on the
326
	  Connexant 2388x chip.
334
	  Connexant 2388x chip.
327
335
328
config VIDEO_OVCAMCHIP
336
config VIDEO_OVCAMCHIP
(-)linux-2.6.11.orig/drivers/media/video/Makefile (+1 lines)
Lines 7-12 bttv-objs := bttv-driver.o bttv-cards.o Link Here
7
zoran-objs      :=	zr36120.o zr36120_i2c.o zr36120_mem.o
7
zoran-objs      :=	zr36120.o zr36120_i2c.o zr36120_mem.o
8
zr36067-objs	:=	zoran_procfs.o zoran_device.o \
8
zr36067-objs	:=	zoran_procfs.o zoran_device.o \
9
			zoran_driver.o zoran_card.o
9
			zoran_driver.o zoran_card.o
10
tuner-objs	:=	tuner-core.o tuner-simple.o mt20xx.o tda8290.o
10
11
11
obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o
12
obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o
12
13
(-)linux-2.6.11.orig/drivers/media/video/bt832.c (-18 / +28 lines)
Lines 6-12 Link Here
6
  It outputs an 8-bit 4:2:2 YUV or YCrCb video signal which can be directly
6
  It outputs an 8-bit 4:2:2 YUV or YCrCb video signal which can be directly
7
  connected to bt848/bt878 GPIO pins on this purpose.
7
  connected to bt848/bt878 GPIO pins on this purpose.
8
  (see: VLSI Vision Ltd. www.vvl.co.uk for camera datasheets)
8
  (see: VLSI Vision Ltd. www.vvl.co.uk for camera datasheets)
9
  
9
10
  Supported Cards:
10
  Supported Cards:
11
  -  Pixelview Rev.4E: 0x8a
11
  -  Pixelview Rev.4E: 0x8a
12
		GPIO 0x400000 toggles Bt832 RESET, and the chip changes to i2c 0x88 !
12
		GPIO 0x400000 toggles Bt832 RESET, and the chip changes to i2c 0x88 !
Lines 31-38 Link Here
31
#include <linux/errno.h>
31
#include <linux/errno.h>
32
#include <linux/slab.h>
32
#include <linux/slab.h>
33
33
34
#include "id.h"
34
#include <media/audiochip.h>
35
#include "audiochip.h"
35
#include <media/id.h>
36
#include "bttv.h"
36
#include "bttv.h"
37
#include "bt832.h"
37
#include "bt832.h"
38
38
Lines 95-101 int bt832_init(struct i2c_client *i2c_cl Link Here
95
95
96
	buf=kmalloc(65,GFP_KERNEL);
96
	buf=kmalloc(65,GFP_KERNEL);
97
	bt832_hexdump(i2c_client_s,buf);
97
	bt832_hexdump(i2c_client_s,buf);
98
	
98
99
	if(buf[0x40] != 0x31) {
99
	if(buf[0x40] != 0x31) {
100
		printk("bt832: this i2c chip is no bt832 (id=%02x). Detaching.\n",buf[0x40]);
100
		printk("bt832: this i2c chip is no bt832 (id=%02x). Detaching.\n",buf[0x40]);
101
		kfree(buf);
101
		kfree(buf);
Lines 135-141 int bt832_init(struct i2c_client *i2c_cl Link Here
135
	buf[1]= 0x27 & (~0x01); // Default | !skip
135
	buf[1]= 0x27 & (~0x01); // Default | !skip
136
	if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
136
	if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
137
                printk("bt832: i2c i/o error EO: rc == %d (should be 2)\n",rc);
137
                printk("bt832: i2c i/o error EO: rc == %d (should be 2)\n",rc);
138
	
138
139
        bt832_hexdump(i2c_client_s,buf);
139
        bt832_hexdump(i2c_client_s,buf);
140
140
141
#if 0
141
#if 0
Lines 168-175 int bt832_init(struct i2c_client *i2c_cl Link Here
168
168
169
169
170
170
171
static int bt832_attach(struct i2c_adapter *adap, int addr,
171
static int bt832_attach(struct i2c_adapter *adap, int addr, int kind)
172
			  unsigned short flags, int kind)
173
{
172
{
174
	struct bt832 *t;
173
	struct bt832 *t;
175
174
Lines 184-210 static int bt832_attach(struct i2c_adapt Link Here
184
                return -ENOMEM;
183
                return -ENOMEM;
185
	memset(t,0,sizeof(*t));
184
	memset(t,0,sizeof(*t));
186
	t->client = client_template;
185
	t->client = client_template;
187
        t->client.data = t;
186
        i2c_set_clientdata(&t->client, t);
188
        i2c_attach_client(&t->client);
187
        i2c_attach_client(&t->client);
189
188
190
	if(! bt832_init(&t->client)) {
189
	if(! bt832_init(&t->client)) {
191
		bt832_detach(&t->client);
190
		bt832_detach(&t->client);
192
		return -1;
191
		return -1;
193
	}
192
	}
194
        
193
195
	return 0;
194
	return 0;
196
}
195
}
197
196
198
static int bt832_probe(struct i2c_adapter *adap)
197
static int bt832_probe(struct i2c_adapter *adap)
199
{
198
{
199
#ifdef I2C_CLASS_TV_ANALOG
200
	if (adap->class & I2C_CLASS_TV_ANALOG)
200
	if (adap->class & I2C_CLASS_TV_ANALOG)
201
		return i2c_probe(adap, &addr_data, bt832_attach);
201
		return i2c_probe(adap, &addr_data, bt832_attach);
202
#else
203
	if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
204
		return i2c_probe(adap, &addr_data, bt832_attach);
205
#endif
202
	return 0;
206
	return 0;
203
}
207
}
204
208
205
static int bt832_detach(struct i2c_client *client)
209
static int bt832_detach(struct i2c_client *client)
206
{
210
{
207
	struct bt832 *t = (struct bt832*)client->data;
211
	struct bt832 *t = i2c_get_clientdata(client);
208
212
209
	printk("bt832: detach.\n");
213
	printk("bt832: detach.\n");
210
	i2c_detach_client(client);
214
	i2c_detach_client(client);
Lines 215-221 static int bt832_detach(struct i2c_clien Link Here
215
static int
219
static int
216
bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
220
bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
217
{
221
{
218
	struct bt832 *t = (struct bt832*)client->data;
222
	struct bt832 *t = i2c_get_clientdata(client);
219
223
220
	printk("bt832: command %x\n",cmd);
224
	printk("bt832: command %x\n",cmd);
221
225
Lines 249-267 static struct i2c_driver driver = { Link Here
249
};
253
};
250
static struct i2c_client client_template =
254
static struct i2c_client client_template =
251
{
255
{
252
        .name   = "bt832",
256
	I2C_DEVNAME("bt832"),
253
	.flags  = I2C_CLIENT_ALLOW_USE,
257
	.flags      = I2C_CLIENT_ALLOW_USE,
254
        .driver = &driver,
258
        .driver     = &driver,
255
};
259
};
256
260
257
261
258
int bt832_init_module(void)
262
static int __init bt832_init_module(void)
259
{
263
{
260
	i2c_add_driver(&driver);
264
	return i2c_add_driver(&driver);
261
	return 0;
262
}
265
}
263
266
264
static void bt832_cleanup_module(void)
267
static void __exit bt832_cleanup_module(void)
265
{
268
{
266
	i2c_del_driver(&driver);
269
	i2c_del_driver(&driver);
267
}
270
}
Lines 269-271 static void bt832_cleanup_module(void) Link Here
269
module_init(bt832_init_module);
272
module_init(bt832_init_module);
270
module_exit(bt832_cleanup_module);
273
module_exit(bt832_cleanup_module);
271
274
275
/*
276
 * Overrides for Emacs so that we follow Linus's tabbing style.
277
 * ---------------------------------------------------------------------------
278
 * Local variables:
279
 * c-basic-offset: 8
280
 * End:
281
 */
(-)linux-2.6.11.orig/drivers/media/video/bt832.h (-18 / +18 lines)
Lines 1-6 Link Here
1
/* Bt832 CMOS Camera Video Processor (VP)
1
/* Bt832 CMOS Camera Video Processor (VP)
2
2
3
 The Bt832 CMOS Camera Video Processor chip connects a Quartsight CMOS 
3
 The Bt832 CMOS Camera Video Processor chip connects a Quartsight CMOS
4
  color digital camera directly to video capture devices via an 8-bit,
4
  color digital camera directly to video capture devices via an 8-bit,
5
  4:2:2 YUV or YCrCb video interface.
5
  4:2:2 YUV or YCrCb video interface.
6
6
Lines 85-91 Link Here
85
#define BT832_DEVICE_ID		63
85
#define BT832_DEVICE_ID		63
86
# define BT832_DEVICE_ID__31		0x31 // Bt832 has ID 0x31
86
# define BT832_DEVICE_ID__31		0x31 // Bt832 has ID 0x31
87
87
88
/* STMicroelectronivcs VV5404 camera module 
88
/* STMicroelectronivcs VV5404 camera module
89
   i2c: 0x20: sensor address
89
   i2c: 0x20: sensor address
90
   i2c: 0xa0: eeprom for ccd defect map
90
   i2c: 0xa0: eeprom for ccd defect map
91
 */
91
 */
Lines 256-281 For the CCIR-601 standards, the sampling Link Here
256
//===========================================================================
256
//===========================================================================
257
// Timing generator SRAM table values for CCIR601 720x480 NTSC
257
// Timing generator SRAM table values for CCIR601 720x480 NTSC
258
//===========================================================================
258
//===========================================================================
259
// For NTSC CCIR656 
259
// For NTSC CCIR656
260
BYTE BtCard::SRAMTable_NTSC[] =
260
BYTE BtCard::SRAMTable_NTSC[] =
261
{
261
{
262
    // SRAM Timing Table for NTSC
262
    // SRAM Timing Table for NTSC
263
    0x0c, 0xc0, 0x00, 
263
    0x0c, 0xc0, 0x00,
264
    0x00, 0x90, 0xc2, 
264
    0x00, 0x90, 0xc2,
265
    0x03, 0x10, 0x03, 
265
    0x03, 0x10, 0x03,
266
    0x06, 0x10, 0x34, 
266
    0x06, 0x10, 0x34,
267
    0x12, 0x12, 0x65, 
267
    0x12, 0x12, 0x65,
268
    0x02, 0x13, 0x24, 
268
    0x02, 0x13, 0x24,
269
    0x19, 0x00, 0x24, 
269
    0x19, 0x00, 0x24,
270
    0x39, 0x00, 0x96, 
270
    0x39, 0x00, 0x96,
271
    0x59, 0x08, 0x93, 
271
    0x59, 0x08, 0x93,
272
    0x83, 0x08, 0x97,
272
    0x83, 0x08, 0x97,
273
    0x03, 0x50, 0x30, 
273
    0x03, 0x50, 0x30,
274
    0xc0, 0x40, 0x30, 
274
    0xc0, 0x40, 0x30,
275
    0x86, 0x01, 0x01, 
275
    0x86, 0x01, 0x01,
276
    0xa6, 0x0d, 0x62, 
276
    0xa6, 0x0d, 0x62,
277
    0x03, 0x11, 0x61, 
277
    0x03, 0x11, 0x61,
278
    0x05, 0x37, 0x30, 
278
    0x05, 0x37, 0x30,
279
    0xac, 0x21, 0x50
279
    0xac, 0x21, 0x50
280
};
280
};
281
281
(-)linux-2.6.11.orig/drivers/media/video/btcx-risc.c (-5 / +7 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
    $Id: btcx-risc.c,v 1.5 2004/12/10 12:33:39 kraxel Exp $
2
    $Id: btcx-risc.c,v 1.6 2005/02/21 13:57:59 kraxel Exp $
3
3
4
    btcx-risc.c
4
    btcx-risc.c
5
5
Lines 52-63 void btcx_riscmem_free(struct pci_dev *p Link Here
52
{
52
{
53
	if (NULL == risc->cpu)
53
	if (NULL == risc->cpu)
54
		return;
54
		return;
55
	pci_free_consistent(pci, risc->size, risc->cpu, risc->dma);
56
	memset(risc,0,sizeof(*risc));
57
	if (debug) {
55
	if (debug) {
58
		memcnt--;
56
		memcnt--;
59
		printk("btcx: riscmem free [%d]\n",memcnt);
57
		printk("btcx: riscmem free [%d] dma=%lx\n",
58
		       memcnt, (unsigned long)risc->dma);
60
	}
59
	}
60
	pci_free_consistent(pci, risc->size, risc->cpu, risc->dma);
61
	memset(risc,0,sizeof(*risc));
61
}
62
}
62
63
63
int btcx_riscmem_alloc(struct pci_dev *pci,
64
int btcx_riscmem_alloc(struct pci_dev *pci,
Lines 78-84 int btcx_riscmem_alloc(struct pci_dev *p Link Here
78
		risc->size = size;
79
		risc->size = size;
79
		if (debug) {
80
		if (debug) {
80
			memcnt++;
81
			memcnt++;
81
			printk("btcx: riscmem alloc size=%d [%d]\n",size,memcnt);
82
			printk("btcx: riscmem alloc [%d] dma=%lx cpu=%p size=%d\n",
83
			       memcnt, (unsigned long)dma, cpu, size);
82
		}
84
		}
83
	}
85
	}
84
	memset(risc->cpu,0,risc->size);
86
	memset(risc->cpu,0,risc->size);
(-)linux-2.6.11.orig/drivers/media/video/bttv-cards.c (-2 / +175 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
    $Id: bttv-cards.c,v 1.42 2005/01/13 17:22:33 kraxel Exp $
2
    $Id: bttv-cards.c,v 1.47 2005/02/22 14:06:32 kraxel Exp $
3
3
4
    bttv-cards.c
4
    bttv-cards.c
5
5
Lines 80-85 static void picolo_tetra_init(struct btt Link Here
80
static void tibetCS16_muxsel(struct bttv *btv, unsigned int input);
80
static void tibetCS16_muxsel(struct bttv *btv, unsigned int input);
81
static void tibetCS16_init(struct bttv *btv);
81
static void tibetCS16_init(struct bttv *btv);
82
82
83
static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input);
84
static void kodicom4400r_init(struct bttv *btv);
85
83
static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input);
86
static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input);
84
static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input);
87
static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input);
85
88
Lines 101-106 static unsigned int pll[BTTV_MAX] = { Link Here
101
static unsigned int tuner[BTTV_MAX]  = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
104
static unsigned int tuner[BTTV_MAX]  = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
102
static unsigned int svhs[BTTV_MAX]   = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
105
static unsigned int svhs[BTTV_MAX]   = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
103
static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
106
static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
107
static struct bttv  *master[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = NULL };
104
#ifdef MODULE
108
#ifdef MODULE
105
static unsigned int autoload = 1;
109
static unsigned int autoload = 1;
106
#else
110
#else
Lines 170-175 static struct CARD { Link Here
170
	// some cards ship with byteswapped IDs ...
174
	// some cards ship with byteswapped IDs ...
171
	{ 0x1200bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
175
	{ 0x1200bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
172
	{ 0xff00bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
176
	{ 0xff00bd11, BTTV_PINNACLE,      "Pinnacle PCTV [bswap]" },
177
	// this seems to happen as well ...
178
	{ 0xff1211bd, BTTV_PINNACLE,      "Pinnacle PCTV" },
173
179
174
	{ 0x3000121a, BTTV_VOODOOTV_FM,   "3Dfx VoodooTV FM/ VoodooTV 200" },
180
	{ 0x3000121a, BTTV_VOODOOTV_FM,   "3Dfx VoodooTV FM/ VoodooTV 200" },
175
	{ 0x263710b4, BTTV_VOODOOTV_FM,   "3Dfx VoodooTV FM/ VoodooTV 200" },
181
	{ 0x263710b4, BTTV_VOODOOTV_FM,   "3Dfx VoodooTV FM/ VoodooTV 200" },
Lines 291-297 static struct CARD { Link Here
291
	{ 0x07611461, BTTV_AVDVBT_761,    "AverMedia AverTV DVB-T 761" },
297
	{ 0x07611461, BTTV_AVDVBT_761,    "AverMedia AverTV DVB-T 761" },
292
	{ 0x001c11bd, BTTV_PINNACLESAT,   "Pinnacle PCTV Sat" },
298
	{ 0x001c11bd, BTTV_PINNACLESAT,   "Pinnacle PCTV Sat" },
293
	{ 0x002611bd, BTTV_TWINHAN_DST,   "Pinnacle PCTV SAT CI" },
299
	{ 0x002611bd, BTTV_TWINHAN_DST,   "Pinnacle PCTV SAT CI" },
294
	{ 0x00011822, BTTV_TWINHAN_DST,   "Twinhan VisionPlus DVB-T" },
300
	{ 0x00011822, BTTV_TWINHAN_DST,   "Twinhan VisionPlus DVB" },
295
	{ 0xfc00270f, BTTV_TWINHAN_DST,   "ChainTech digitop DST-1000 DVB-S" },
301
	{ 0xfc00270f, BTTV_TWINHAN_DST,   "ChainTech digitop DST-1000 DVB-S" },
296
	{ 0x07711461, BTTV_AVDVBT_771,    "AVermedia AverTV DVB-T 771" },
302
	{ 0x07711461, BTTV_AVDVBT_771,    "AVermedia AverTV DVB-T 771" },
297
	{ 0xdb1018ac, BTTV_DVICO_DVBT_LITE,    "DVICO FusionHDTV DVB-T Lite" },
303
	{ 0xdb1018ac, BTTV_DVICO_DVBT_LITE,    "DVICO FusionHDTV DVB-T Lite" },
Lines 1920-1925 struct tvcard bttv_tvcards[] = { Link Here
1920
	.svhs           = 2,
1926
	.svhs           = 2,
1921
	.muxsel         = { 2, 3, 1, 0},
1927
	.muxsel         = { 2, 3, 1, 0},
1922
	.tuner_type     = TUNER_PHILIPS_ATSC,
1928
	.tuner_type     = TUNER_PHILIPS_ATSC,
1929
	.has_dvb        = 1,
1923
},{
1930
},{
1924
	.name           = "Twinhan DST + clones",
1931
	.name           = "Twinhan DST + clones",
1925
	.no_msp34xx     = 1,
1932
	.no_msp34xx     = 1,
Lines 2188-2193 struct tvcard bttv_tvcards[] = { Link Here
2188
		.no_tda7432	= 1,
2195
		.no_tda7432	= 1,
2189
		.tuner_type     = -1,
2196
		.tuner_type     = -1,
2190
		.muxsel_hook    = tibetCS16_muxsel,
2197
		.muxsel_hook    = tibetCS16_muxsel,
2198
},
2199
{
2200
	/* Bill Brack <wbrack@mmm.com.hk> */
2201
	/*
2202
	 * Note that, because of the card's wiring, the "master"
2203
	 * BT878A chip (i.e. the one which controls the analog switch
2204
	 * and must use this card type) is the 2nd one detected.  The
2205
	 * other 3 chips should use card type 0x85, whose description
2206
	 * follows this one.  There is a EEPROM on the card (which is
2207
	 * connected to the I2C of one of those other chips), but is
2208
	 * not currently handled.  There is also a facility for a
2209
	 * "monitor", which is also not currently implemented.
2210
	 */
2211
	.name		= "Kodicom 4400R (master)",
2212
	.video_inputs	= 16,
2213
	.audio_inputs	= 0,
2214
	.tuner		= -1,
2215
	.tuner_type	= -1,
2216
	.svhs		= -1,
2217
	/* GPIO bits 0-9 used for analog switch:
2218
	 *   00 - 03:	camera selector
2219
	 *   04 - 06:	channel (controller) selector
2220
	 *   07:	data (1->on, 0->off)
2221
	 *   08:	strobe
2222
	 *   09:	reset
2223
	 * bit 16 is input from sync separator for the channel
2224
	 */
2225
	.gpiomask	= 0x0003ff,
2226
	.no_gpioirq     = 1,
2227
	.muxsel		= { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2228
	.pll		= PLL_28,
2229
	.no_msp34xx	= 1,
2230
	.no_tda7432	= 1,
2231
	.no_tda9875	= 1,
2232
	.muxsel_hook	= kodicom4400r_muxsel,
2233
},
2234
{
2235
	/* Bill Brack <wbrack@mmm.com.hk> */
2236
	/* Note that, for reasons unknown, the "master" BT878A chip (i.e. the
2237
	 * one which controls the analog switch, and must use the card type)
2238
	 * is the 2nd one detected.  The other 3 chips should use this card
2239
	 * type
2240
	 */
2241
	.name		= "Kodicom 4400R (slave)",
2242
	.video_inputs	= 16,
2243
	.audio_inputs	= 0,
2244
	.tuner		= -1,
2245
	.tuner_type	= -1,
2246
	.svhs		= -1,
2247
	.gpiomask	= 0x010000,
2248
	.no_gpioirq     = 1,
2249
	.muxsel		= { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2250
	.pll		= PLL_28,
2251
	.no_msp34xx	= 1,
2252
	.no_tda7432	= 1,
2253
	.no_tda9875	= 1,
2254
	.muxsel_hook	= kodicom4400r_muxsel,
2191
}};
2255
}};
2192
2256
2193
static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
2257
static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
Lines 2682-2687 void __devinit bttv_init_card2(struct bt Link Here
2682
	case BTTV_TIBET_CS16:
2746
	case BTTV_TIBET_CS16:
2683
		tibetCS16_init(btv);
2747
		tibetCS16_init(btv);
2684
		break;
2748
		break;
2749
	case BTTV_KODICOM_4400R:
2750
		kodicom4400r_init(btv);
2751
		break;
2685
	}
2752
	}
2686
2753
2687
	/* pll configuration */
2754
	/* pll configuration */
Lines 3894-3899 static void tibetCS16_init(struct bttv * Link Here
3894
	gpio_write(0x0f7fff);
3961
	gpio_write(0x0f7fff);
3895
}
3962
}
3896
3963
3964
/*
3965
 * The following routines for the Kodicom-4400r get a little mind-twisting.
3966
 * There is a "master" controller and three "slave" controllers, together
3967
 * an analog switch which connects any of 16 cameras to any of the BT87A's.
3968
 * The analog switch is controlled by the "master", but the detection order
3969
 * of the four BT878A chips is in an order which I just don't understand.
3970
 * The "master" is actually the second controller to be detected.  The
3971
 * logic on the board uses logical numbers for the 4 controlers, but
3972
 * those numbers are different from the detection sequence.  When working
3973
 * with the analog switch, we need to "map" from the detection sequence
3974
 * over to the board's logical controller number.  This mapping sequence
3975
 * is {3, 0, 2, 1}, i.e. the first controller to be detected is logical
3976
 * unit 3, the second (which is the master) is logical unit 0, etc.
3977
 * We need to maintain the status of the analog switch (which of the 16
3978
 * cameras is connected to which of the 4 controllers).  Rather than
3979
 * add to the bttv structure for this, we use the data reserved for
3980
 * the mbox (unused for this card type).
3981
 */
3982
3983
/*
3984
 * First a routine to set the analog switch, which controls which camera
3985
 * is routed to which controller.  The switch comprises an X-address
3986
 * (gpio bits 0-3, representing the camera, ranging from 0-15), and a
3987
 * Y-address (gpio bits 4-6, representing the controller, ranging from 0-3).
3988
 * A data value (gpio bit 7) of '1' enables the switch, and '0' disables
3989
 * the switch.  A STROBE bit (gpio bit 8) latches the data value into the
3990
 * specified address.  The idea is to set the address and data, then bring
3991
 * STROBE high, and finally bring STROBE back to low.
3992
 */
3993
static void kodicom4400r_write(struct bttv *btv,
3994
			       unsigned char xaddr,
3995
			       unsigned char yaddr,
3996
			       unsigned char data) {
3997
	unsigned int udata;
3998
	
3999
	udata = (data << 7) | ((yaddr&3) << 4) | (xaddr&0xf);
4000
	gpio_bits(0x1ff, udata);		/* write ADDR and DAT */
4001
	gpio_bits(0x1ff, udata | (1 << 8));	/* strobe high */
4002
	gpio_bits(0x1ff, udata);		/* strobe low */
4003
}
4004
4005
/*
4006
 * Next the mux select.  Both the "master" and "slave" 'cards' (controllers)
4007
 * use this routine.  The routine finds the "master" for the card, maps
4008
 * the controller number from the detected position over to the logical
4009
 * number, writes the appropriate data to the analog switch, and housekeeps
4010
 * the local copy of the switch information.  The parameter 'input' is the
4011
 * requested camera number (0 - 15).
4012
 */
4013
static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input)
4014
{
4015
	char *sw_status;
4016
	int xaddr, yaddr;
4017
	struct bttv *mctlr;
4018
	static unsigned char map[4] = {3, 0, 2, 1};
4019
	
4020
	mctlr = master[btv->c.nr];
4021
	if (mctlr == NULL) {	/* ignore if master not yet detected */
4022
		return;
4023
	}
4024
	yaddr = (btv->c.nr - mctlr->c.nr + 1) & 3; /* the '&' is for safety */
4025
	yaddr = map[yaddr];
4026
	sw_status = (char *)(&mctlr->mbox_we);
4027
	xaddr = input & 0xf;
4028
	/* Check if the controller/camera pair has changed, else ignore */
4029
	if (sw_status[yaddr] != xaddr)
4030
	{
4031
		/* "open" the old switch, "close" the new one, save the new */
4032
		kodicom4400r_write(mctlr, sw_status[yaddr], yaddr, 0);
4033
		sw_status[yaddr] = xaddr;
4034
		kodicom4400r_write(mctlr, xaddr, yaddr, 1);
4035
	}
4036
}
4037
4038
/*
4039
 * During initialisation, we need to reset the analog switch.  We
4040
 * also preset the switch to map the 4 connectors on the card to the
4041
 * *user's* (see above description of kodicom4400r_muxsel) channels
4042
 * 0 through 3
4043
 */
4044
static void kodicom4400r_init(struct bttv *btv)
4045
{
4046
	char *sw_status = (char *)(&btv->mbox_we);
4047
	int ix;
4048
4049
	gpio_inout(0x0003ff, 0x0003ff);
4050
	gpio_write(1 << 9);	/* reset MUX */
4051
	gpio_write(0);
4052
	/* Preset camera 0 to the 4 controllers */
4053
	for (ix=0; ix<4; ix++) {
4054
		sw_status[ix] = ix;
4055
		kodicom4400r_write(btv, ix, ix, 1);
4056
	}
4057
	/*
4058
	 * Since this is the "master", we need to set up the
4059
	 * other three controller chips' pointers to this structure
4060
	 * for later use in the muxsel routine.
4061
	 */
4062
	if ((btv->c.nr<1) || (btv->c.nr>BTTV_MAX-3))
4063
	    return;
4064
	master[btv->c.nr-1] = btv;
4065
	master[btv->c.nr]   = btv;
4066
	master[btv->c.nr+1] = btv;
4067
	master[btv->c.nr+2] = btv;
4068
}
4069
3897
// The Grandtec X-Guard framegrabber card uses two Dual 4-channel
4070
// The Grandtec X-Guard framegrabber card uses two Dual 4-channel
3898
// video multiplexers to provide up to 16 video inputs. These
4071
// video multiplexers to provide up to 16 video inputs. These
3899
// multiplexers are controlled by the lower 8 GPIO pins of the
4072
// multiplexers are controlled by the lower 8 GPIO pins of the
(-)linux-2.6.11.orig/drivers/media/video/bttv-driver.c (-17 / +78 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
    $Id: bttv-driver.c,v 1.34 2005/01/07 13:11:19 kraxel Exp $
2
    $Id: bttv-driver.c,v 1.37 2005/02/21 13:57:59 kraxel Exp $
3
3
4
    bttv - Bt848 frame grabber driver
4
    bttv - Bt848 frame grabber driver
5
5
Lines 3167-3172 static struct video_device radio_templat Link Here
3167
};
3167
};
3168
3168
3169
/* ----------------------------------------------------------------------- */
3169
/* ----------------------------------------------------------------------- */
3170
/* some debug code                                                         */
3171
3172
int bttv_risc_decode(u32 risc)
3173
{
3174
	static char *instr[16] = {
3175
		[ BT848_RISC_WRITE     >> 28 ] = "write",
3176
		[ BT848_RISC_SKIP      >> 28 ] = "skip",
3177
		[ BT848_RISC_WRITEC    >> 28 ] = "writec",
3178
		[ BT848_RISC_JUMP      >> 28 ] = "jump",
3179
		[ BT848_RISC_SYNC      >> 28 ] = "sync",
3180
		[ BT848_RISC_WRITE123  >> 28 ] = "write123",
3181
		[ BT848_RISC_SKIP123   >> 28 ] = "skip123",
3182
		[ BT848_RISC_WRITE1S23 >> 28 ] = "write1s23",
3183
	};
3184
	static int incr[16] = {
3185
		[ BT848_RISC_WRITE     >> 28 ] = 2,
3186
		[ BT848_RISC_JUMP      >> 28 ] = 2,
3187
		[ BT848_RISC_SYNC      >> 28 ] = 2,
3188
		[ BT848_RISC_WRITE123  >> 28 ] = 5,
3189
		[ BT848_RISC_SKIP123   >> 28 ] = 2,
3190
		[ BT848_RISC_WRITE1S23 >> 28 ] = 3,
3191
	};
3192
	static char *bits[] = {
3193
		"be0",  "be1",  "be2",  "be3/resync",
3194
		"set0", "set1", "set2", "set3",
3195
		"clr0", "clr1", "clr2", "clr3",
3196
		"irq",  "res",  "eol",  "sol",
3197
	};
3198
	int i;
3199
3200
	printk("0x%08x [ %s", risc,
3201
	       instr[risc >> 28] ? instr[risc >> 28] : "INVALID");
3202
	for (i = ARRAY_SIZE(bits)-1; i >= 0; i--)
3203
		if (risc & (1 << (i + 12)))
3204
			printk(" %s",bits[i]);
3205
	printk(" count=%d ]\n", risc & 0xfff);
3206
	return incr[risc >> 28] ? incr[risc >> 28] : 1;
3207
}
3208
3209
void bttv_risc_disasm(struct bttv *btv,
3210
		      struct btcx_riscmem *risc)
3211
{
3212
	unsigned int i,j,n;
3213
3214
	printk("%s: risc disasm: %p [dma=0x%08lx]\n",
3215
	       btv->c.name, risc->cpu, (unsigned long)risc->dma);
3216
	for (i = 0; i < (risc->size >> 2); i += n) {
3217
		printk("%s:   0x%lx: ", btv->c.name,
3218
		       (unsigned long)(risc->dma + (i<<2)));
3219
		n = bttv_risc_decode(risc->cpu[i]);
3220
		for (j = 1; j < n; j++)
3221
			printk("%s:   0x%lx: 0x%08x [ arg #%d ]\n",
3222
			       btv->c.name, (unsigned long)(risc->dma + ((i+j)<<2)),
3223
			       risc->cpu[i+j], j);
3224
		if (0 == risc->cpu[i])
3225
			break;
3226
	}
3227
}
3228
3229
static void bttv_print_riscaddr(struct bttv *btv)
3230
{
3231
	printk("  main: %08Lx\n",
3232
	       (unsigned long long)btv->main.dma);
3233
	printk("  vbi : o=%08Lx e=%08Lx\n",
3234
	       btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0,
3235
	       btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0);
3236
	printk("  cap : o=%08Lx e=%08Lx\n",
3237
	       btv->curr.top    ? (unsigned long long)btv->curr.top->top.dma : 0,
3238
	       btv->curr.bottom ? (unsigned long long)btv->curr.bottom->bottom.dma : 0);
3239
	printk("  scr : o=%08Lx e=%08Lx\n",
3240
	       btv->screen ? (unsigned long long)btv->screen->top.dma : 0,
3241
	       btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0);
3242
	bttv_risc_disasm(btv, &btv->main);
3243
}
3244
3245
/* ----------------------------------------------------------------------- */
3170
/* irq handler                                                             */
3246
/* irq handler                                                             */
3171
3247
3172
static char *irq_name[] = {
3248
static char *irq_name[] = {
Lines 3204-3224 static void bttv_print_irqbits(u32 print Link Here
3204
	}
3280
	}
3205
}
3281
}
3206
3282
3207
static void bttv_print_riscaddr(struct bttv *btv)
3208
{
3209
	printk("  main: %08Lx\n",
3210
	       (unsigned long long)btv->main.dma);
3211
	printk("  vbi : o=%08Lx e=%08Lx\n",
3212
	       btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0,
3213
	       btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0);
3214
	printk("  cap : o=%08Lx e=%08Lx\n",
3215
	       btv->curr.top    ? (unsigned long long)btv->curr.top->top.dma : 0,
3216
	       btv->curr.bottom ? (unsigned long long)btv->curr.bottom->bottom.dma : 0);
3217
	printk("  scr : o=%08Lx e=%08Lx\n",
3218
	       btv->screen ? (unsigned long long)btv->screen->top.dma  : 0,
3219
	       btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0);
3220
}
3221
3222
static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc)
3283
static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc)
3223
{
3284
{
3224
	printk("bttv%d: irq: skipped frame [main=%lx,o_vbi=%lx,o_field=%lx,rc=%lx]\n",
3285
	printk("bttv%d: irq: skipped frame [main=%lx,o_vbi=%lx,o_field=%lx,rc=%lx]\n",
Lines 3921-3927 static void __devexit bttv_remove(struct Link Here
3921
        return;
3982
        return;
3922
}
3983
}
3923
3984
3924
static int bttv_suspend(struct pci_dev *pci_dev, u32 state)
3985
static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
3925
{
3986
{
3926
        struct bttv *btv = pci_get_drvdata(pci_dev);
3987
        struct bttv *btv = pci_get_drvdata(pci_dev);
3927
	struct bttv_buffer_set idle;
3988
	struct bttv_buffer_set idle;
(-)linux-2.6.11.orig/drivers/media/video/bttv-gpio.c (-15 / +2 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
    $Id: bttv-gpio.c,v 1.6 2004/11/03 09:04:50 kraxel Exp $
2
    $Id: bttv-gpio.c,v 1.7 2005/02/16 12:14:10 kraxel Exp $
3
3
4
    bttv-gpio.c  --  gpio sub drivers
4
    bttv-gpio.c  --  gpio sub drivers
5
5
Lines 94-99 int bttv_sub_del_devices(struct bttv_cor Link Here
94
94
95
	list_for_each_safe(item,save,&core->subs) {
95
	list_for_each_safe(item,save,&core->subs) {
96
		sub = list_entry(item,struct bttv_sub_device,list);
96
		sub = list_entry(item,struct bttv_sub_device,list);
97
		list_del(&sub->list);
97
		device_unregister(&sub->dev);
98
		device_unregister(&sub->dev);
98
	}
99
	}
99
	return 0;
100
	return 0;
Lines 113-132 void bttv_gpio_irq(struct bttv_core *cor Link Here
113
	}
114
	}
114
}
115
}
115
116
116
void bttv_i2c_info(struct bttv_core *core, struct i2c_client *client, int attach)
117
{
118
	struct bttv_sub_driver *drv;
119
	struct bttv_sub_device *dev;
120
	struct list_head *item;
121
122
	list_for_each(item,&core->subs) {
123
		dev = list_entry(item,struct bttv_sub_device,list);
124
		drv = to_bttv_sub_drv(dev->dev.driver);
125
		if (drv && drv->i2c_info)
126
			drv->i2c_info(dev,client,attach);
127
	}
128
}
129
130
/* ----------------------------------------------------------------------- */
117
/* ----------------------------------------------------------------------- */
131
/* external: sub-driver register/unregister                                */
118
/* external: sub-driver register/unregister                                */
132
119
(-)linux-2.6.11.orig/drivers/media/video/bttv-i2c.c (-14 / +1 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
    $Id: bttv-i2c.c,v 1.17 2004/12/14 15:33:30 kraxel Exp $
2
    $Id: bttv-i2c.c,v 1.18 2005/02/16 12:14:10 kraxel Exp $
3
3
4
    bttv-i2c.c  --  all the i2c code is here
4
    bttv-i2c.c  --  all the i2c code is here
5
5
Lines 39-45 static struct i2c_adapter bttv_i2c_adap_ Link Here
39
static struct i2c_client bttv_i2c_client_template;
39
static struct i2c_client bttv_i2c_client_template;
40
40
41
static int attach_inform(struct i2c_client *client);
41
static int attach_inform(struct i2c_client *client);
42
static int detach_inform(struct i2c_client *client);
43
42
44
static int i2c_debug = 0;
43
static int i2c_debug = 0;
45
static int i2c_hw = 0;
44
static int i2c_hw = 0;
Lines 112-118 static struct i2c_adapter bttv_i2c_adap_ Link Here
112
	I2C_DEVNAME("bt848"),
111
	I2C_DEVNAME("bt848"),
113
	.id                = I2C_HW_B_BT848,
112
	.id                = I2C_HW_B_BT848,
114
	.client_register   = attach_inform,
113
	.client_register   = attach_inform,
115
	.client_unregister = detach_inform,
116
};
114
};
117
115
118
/* ----------------------------------------------------------------------- */
116
/* ----------------------------------------------------------------------- */
Lines 290-296 static struct i2c_adapter bttv_i2c_adap_ Link Here
290
	.id            = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
288
	.id            = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
291
	.algo          = &bttv_algo,
289
	.algo          = &bttv_algo,
292
	.client_register = attach_inform,
290
	.client_register = attach_inform,
293
	.client_unregister = detach_inform,
294
};
291
};
295
292
296
/* ----------------------------------------------------------------------- */
293
/* ----------------------------------------------------------------------- */
Lines 305-326 static int attach_inform(struct i2c_clie Link Here
305
	if (btv->pinnacle_id != UNSET)
302
	if (btv->pinnacle_id != UNSET)
306
		bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
303
		bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
307
				      &btv->pinnacle_id);
304
				      &btv->pinnacle_id);
308
	bttv_i2c_info(&btv->c, client, 1);
309
310
        if (bttv_debug)
305
        if (bttv_debug)
311
		printk("bttv%d: i2c attach [client=%s]\n",
306
		printk("bttv%d: i2c attach [client=%s]\n",
312
		       btv->c.nr, i2c_clientname(client));
307
		       btv->c.nr, i2c_clientname(client));
313
        return 0;
308
        return 0;
314
}
309
}
315
310
316
static int detach_inform(struct i2c_client *client)
317
{
318
        struct bttv *btv = i2c_get_adapdata(client->adapter);
319
320
	bttv_i2c_info(&btv->c, client, 0);
321
	return 0;
322
}
323
324
void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
311
void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
325
{
312
{
326
	if (0 != btv->i2c_rc)
313
	if (0 != btv->i2c_rc)
(-)linux-2.6.11.orig/drivers/media/video/bttv.h (-3 / +2 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: bttv.h,v 1.14 2005/01/07 13:11:19 kraxel Exp $
2
 * $Id: bttv.h,v 1.17 2005/02/22 14:06:32 kraxel Exp $
3
 *
3
 *
4
 *  bttv - Bt848 frame grabber driver
4
 *  bttv - Bt848 frame grabber driver
5
 *
5
 *
Lines 134-139 Link Here
134
#define BTTV_APAC_VIEWCOMP  0x7f
134
#define BTTV_APAC_VIEWCOMP  0x7f
135
#define BTTV_DVICO_DVBT_LITE  0x80
135
#define BTTV_DVICO_DVBT_LITE  0x80
136
#define BTTV_TIBET_CS16  0x83
136
#define BTTV_TIBET_CS16  0x83
137
#define BTTV_KODICOM_4400R  0x84
137
138
138
/* i2c address list */
139
/* i2c address list */
139
#define I2C_TSA5522        0xc2
140
#define I2C_TSA5522        0xc2
Lines 302-309 struct bttv_sub_driver { Link Here
302
	struct device_driver   drv;
303
	struct device_driver   drv;
303
	char                   wanted[BUS_ID_SIZE];
304
	char                   wanted[BUS_ID_SIZE];
304
	void                   (*gpio_irq)(struct bttv_sub_device *sub);
305
	void                   (*gpio_irq)(struct bttv_sub_device *sub);
305
	void                   (*i2c_info)(struct bttv_sub_device *sub,
306
					   struct i2c_client *client, int attach);
307
};
306
};
308
#define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv)
307
#define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv)
309
308
(-)linux-2.6.11.orig/drivers/media/video/bttvp.h (-2 / +1 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
    $Id: bttvp.h,v 1.15 2004/12/14 15:33:30 kraxel Exp $
2
    $Id: bttvp.h,v 1.17 2005/02/16 12:14:10 kraxel Exp $
3
3
4
    bttv - Bt848 frame grabber driver
4
    bttv - Bt848 frame grabber driver
5
5
Lines 209-215 extern struct bus_type bttv_sub_bus_type Link Here
209
int bttv_sub_add_device(struct bttv_core *core, char *name);
209
int bttv_sub_add_device(struct bttv_core *core, char *name);
210
int bttv_sub_del_devices(struct bttv_core *core);
210
int bttv_sub_del_devices(struct bttv_core *core);
211
void bttv_gpio_irq(struct bttv_core *core);
211
void bttv_gpio_irq(struct bttv_core *core);
212
void bttv_i2c_info(struct bttv_core *core, struct i2c_client *client, int attach);
213
212
214
213
215
/* ---------------------------------------------------------- */
214
/* ---------------------------------------------------------- */
(-)linux-2.6.11.orig/drivers/media/video/cx88/Makefile (-1 / +2 lines)
Lines 1-4 Link Here
1
cx88xx-objs	:= cx88-cards.o cx88-core.o cx88-i2c.o cx88-tvaudio.o
1
cx88xx-objs	:= cx88-cards.o cx88-core.o cx88-i2c.o cx88-tvaudio.o \
2
		   cx88-input.o
2
cx8800-objs	:= cx88-video.o cx88-vbi.o
3
cx8800-objs	:= cx88-video.o cx88-vbi.o
3
cx8802-objs	:= cx88-mpeg.o
4
cx8802-objs	:= cx88-mpeg.o
4
5
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88-blackbird.c (-11 / +18 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: cx88-blackbird.c,v 1.17 2004/11/07 13:17:15 kraxel Exp $
2
 * $Id: cx88-blackbird.c,v 1.26 2005/03/07 15:58:05 kraxel Exp $
3
 *
3
 *
4
 *  Support for a cx23416 mpeg encoder via cx2388x host port.
4
 *  Support for a cx23416 mpeg encoder via cx2388x host port.
5
 *  "blackbird" reference design.
5
 *  "blackbird" reference design.
Lines 25-30 Link Here
25
 */
25
 */
26
26
27
#include <linux/module.h>
27
#include <linux/module.h>
28
#include <linux/moduleparam.h>
28
#include <linux/init.h>
29
#include <linux/init.h>
29
#include <linux/fs.h>
30
#include <linux/fs.h>
30
#include <linux/delay.h>
31
#include <linux/delay.h>
Lines 207-216 static int register_write(struct cx88_co Link Here
207
	cx_read(P1_RADDR0);
208
	cx_read(P1_RADDR0);
208
209
209
	return wait_ready_gpio0_bit1(core,1);
210
	return wait_ready_gpio0_bit1(core,1);
210
#if 0
211
	udelay(1000); /* without this, things don't go right (subsequent memory_write()'s don't get through */
212
	/* ? would this be safe here? set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); */
213
#endif
214
}
211
}
215
212
216
213
Lines 283-289 static int blackbird_api_cmd(struct cx88 Link Here
283
	timeout = jiffies + msecs_to_jiffies(10);
280
	timeout = jiffies + msecs_to_jiffies(10);
284
	for (;;) {
281
	for (;;) {
285
		memory_read(dev->core, dev->mailbox, &flag);
282
		memory_read(dev->core, dev->mailbox, &flag);
286
		if (0 == (flag & 4))
283
		if (0 != (flag & 4))
287
			break;
284
			break;
288
		if (time_after(jiffies,timeout)) {
285
		if (time_after(jiffies,timeout)) {
289
			dprintk(0, "ERROR: API Mailbox timeout\n");
286
			dprintk(0, "ERROR: API Mailbox timeout\n");
Lines 324-330 static int blackbird_find_mailbox(struct Link Here
324
			signaturecnt = 0;
321
			signaturecnt = 0;
325
		if (4 == signaturecnt) {
322
		if (4 == signaturecnt) {
326
			dprintk(1, "Mailbox signature found\n");
323
			dprintk(1, "Mailbox signature found\n");
327
			return i;
324
			return i+1;
328
		}
325
		}
329
	}
326
	}
330
	dprintk(0, "Mailbox signature values not found!\n");
327
	dprintk(0, "Mailbox signature values not found!\n");
Lines 427-433 static void blackbird_codec_settings(str Link Here
427
        blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAMERATE, 1, 0, 0);
424
        blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAMERATE, 1, 0, 0);
428
425
429
        /* assign frame size */
426
        /* assign frame size */
430
        blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_SIZE, 2, 0, 480, 720);
427
        blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_SIZE, 2, 0,
428
			  dev->height, dev->width);
431
429
432
        /* assign aspect ratio */
430
        /* assign aspect ratio */
433
        blackbird_api_cmd(dev, IVTV_API_ASSIGN_ASPECT_RATIO, 1, 0, 2);
431
        blackbird_api_cmd(dev, IVTV_API_ASSIGN_ASPECT_RATIO, 1, 0, 2);
Lines 629-636 static int mpeg_do_ioctl(struct inode *i Link Here
629
627
630
		memset(f,0,sizeof(*f));
628
		memset(f,0,sizeof(*f));
631
		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
629
		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
632
		f->fmt.pix.width        = 720;
630
		f->fmt.pix.width        = dev->width;
633
		f->fmt.pix.height       = 576;
631
		f->fmt.pix.height       = dev->height;
634
		f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
632
		f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
635
		f->fmt.pix.sizeimage    = 1024 * 512 /* FIXME: BUFFER_SIZE */;
633
		f->fmt.pix.sizeimage    = 1024 * 512 /* FIXME: BUFFER_SIZE */;
636
	}
634
	}
Lines 694-699 static int mpeg_open(struct inode *inode Link Here
694
	file->private_data = fh;
692
	file->private_data = fh;
695
	fh->dev      = dev;
693
	fh->dev      = dev;
696
694
695
	/* FIXME: locking against other video device */
696
	cx88_set_scale(dev->core, dev->width, dev->height,
697
		       V4L2_FIELD_INTERLACED);
698
697
	videobuf_queue_init(&fh->mpegq, &blackbird_qops,
699
	videobuf_queue_init(&fh->mpegq, &blackbird_qops,
698
			    dev->pci, &dev->slock,
700
			    dev->pci, &dev->slock,
699
			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
701
			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
Lines 715-720 static int mpeg_release(struct inode *in Link Here
715
	if (fh->mpegq.reading)
717
	if (fh->mpegq.reading)
716
		videobuf_read_stop(&fh->mpegq);
718
		videobuf_read_stop(&fh->mpegq);
717
719
720
	videobuf_mmap_free(&fh->mpegq);
718
	file->private_data = NULL;
721
	file->private_data = NULL;
719
	kfree(fh);
722
	kfree(fh);
720
	return 0;
723
	return 0;
Lines 821-826 static int __devinit blackbird_probe(str Link Here
821
	memset(dev,0,sizeof(*dev));
824
	memset(dev,0,sizeof(*dev));
822
	dev->pci = pci_dev;
825
	dev->pci = pci_dev;
823
	dev->core = core;
826
	dev->core = core;
827
	dev->width = 720;
828
	dev->height = 480;
824
829
825
	err = cx8802_init_common(dev);
830
	err = cx8802_init_common(dev);
826
	if (0 != err)
831
	if (0 != err)
Lines 852-857 static void __devexit blackbird_remove(s Link Here
852
857
853
	/* common */
858
	/* common */
854
	cx8802_fini_common(dev);
859
	cx8802_fini_common(dev);
860
	cx88_core_put(dev->core,dev->pci);
861
	kfree(dev);
855
}
862
}
856
863
857
static struct pci_device_id cx8802_pci_tbl[] = {
864
static struct pci_device_id cx8802_pci_tbl[] = {
Lines 885-891 static int blackbird_init(void) Link Here
885
	printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
892
	printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
886
	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
893
	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
887
#endif
894
#endif
888
	return pci_module_init(&blackbird_pci_driver);
895
	return pci_register_driver(&blackbird_pci_driver);
889
}
896
}
890
897
891
static void blackbird_fini(void)
898
static void blackbird_fini(void)
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88-cards.c (-167 / +226 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: cx88-cards.c,v 1.47 2004/11/03 09:04:50 kraxel Exp $
2
 * $Id: cx88-cards.c,v 1.66 2005/03/04 09:12:23 kraxel Exp $
3
 *
3
 *
4
 * device driver for Conexant 2388x based TV cards
4
 * device driver for Conexant 2388x based TV cards
5
 * card-specific stuff.
5
 * card-specific stuff.
Lines 26-39 Link Here
26
#include <linux/pci.h>
26
#include <linux/pci.h>
27
#include <linux/delay.h>
27
#include <linux/delay.h>
28
28
29
#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
30
# define WITH_DVB 1
31
#endif
32
33
#include "cx88.h"
29
#include "cx88.h"
34
#ifdef WITH_DVB
35
#include "cx22702.h"
36
#endif
37
30
38
/* ------------------------------------------------------------------ */
31
/* ------------------------------------------------------------------ */
39
/* board config info                                                  */
32
/* board config info                                                  */
Lines 59-64 struct cx88_board cx88_boards[] = { Link Here
59
	[CX88_BOARD_HAUPPAUGE] = {
52
	[CX88_BOARD_HAUPPAUGE] = {
60
		.name		= "Hauppauge WinTV 34xxx models",
53
		.name		= "Hauppauge WinTV 34xxx models",
61
		.tuner_type     = UNSET,
54
		.tuner_type     = UNSET,
55
		.tda9887_conf   = TDA9887_PRESENT,
62
		.input          = {{
56
		.input          = {{
63
			.type   = CX88_VMUX_TELEVISION,
57
			.type   = CX88_VMUX_TELEVISION,
64
			.vmux   = 0,
58
			.vmux   = 0,
Lines 91-97 struct cx88_board cx88_boards[] = { Link Here
91
	},
85
	},
92
	[CX88_BOARD_PIXELVIEW] = {
86
	[CX88_BOARD_PIXELVIEW] = {
93
		.name           = "PixelView",
87
		.name           = "PixelView",
94
		.tuner_type     = UNSET,
88
		.tuner_type     = 5,
95
		.input          = {{
89
		.input          = {{
96
			.type   = CX88_VMUX_TELEVISION,
90
			.type   = CX88_VMUX_TELEVISION,
97
			.vmux   = 0,
91
			.vmux   = 0,
Lines 126-132 struct cx88_board cx88_boards[] = { Link Here
126
                        .gpio0  = 0x03fe,
120
                        .gpio0  = 0x03fe,
127
		}},
121
		}},
128
	},
122
	},
129
        [CX88_BOARD_WINFAST2000XP] = {
123
        [CX88_BOARD_WINFAST2000XP_EXPERT] = {
130
                .name           = "Leadtek Winfast 2000XP Expert",
124
                .name           = "Leadtek Winfast 2000XP Expert",
131
                .tuner_type     = 44,
125
                .tuner_type     = 44,
132
		.tda9887_conf   = TDA9887_PRESENT,
126
		.tda9887_conf   = TDA9887_PRESENT,
Lines 217-242 struct cx88_board cx88_boards[] = { Link Here
217
                .input          = {{
211
                .input          = {{
218
                        .type   = CX88_VMUX_TELEVISION,
212
                        .type   = CX88_VMUX_TELEVISION,
219
                        .vmux   = 0,
213
                        .vmux   = 0,
220
                }},
214
			.gpio0  = 0x0035e700,
215
			.gpio1  = 0x00003004,
216
			.gpio2  = 0x0035e700,
217
			.gpio3  = 0x02000000,
218
		},{
219
220
			.type   = CX88_VMUX_COMPOSITE1,
221
			.vmux   = 1,
222
			.gpio0  = 0x0035c700,
223
			.gpio1  = 0x00003004,
224
			.gpio2  = 0x0035c700,
225
			.gpio3  = 0x02000000,
226
		},{
227
			.type   = CX88_VMUX_SVIDEO,
228
			.vmux   = 2,
229
			.gpio0  = 0x0035c700,
230
			.gpio1  = 0x0035c700,
231
			.gpio2  = 0x02000000,
232
			.gpio3  = 0x02000000,
233
		}},
221
                .radio = {
234
                .radio = {
222
                        .type   = CX88_RADIO,
235
			.type   = CX88_RADIO,
223
                },
236
			.gpio0  = 0x0035d700,
237
			.gpio1  = 0x00007004,
238
			.gpio2  = 0x0035d700,
239
			.gpio3  = 0x02000000,
240
		 },
224
        },
241
        },
225
        [CX88_BOARD_LEADTEK_PVR2000] = {
242
        [CX88_BOARD_LEADTEK_PVR2000] = {
243
		// gpio values for PAL version from regspy by DScaler
226
                .name           = "Leadtek PVR 2000",
244
                .name           = "Leadtek PVR 2000",
227
                .tuner_type     = 38,
245
                .tuner_type     = 38,
246
		.tda9887_conf   = TDA9887_PRESENT,
228
                .input          = {{
247
                .input          = {{
229
                        .type   = CX88_VMUX_TELEVISION,
248
                        .type   = CX88_VMUX_TELEVISION,
230
                        .vmux   = 0,
249
                        .vmux   = 0,
250
                        .gpio0  = 0x0000bde6,
231
                },{
251
                },{
232
                        .type   = CX88_VMUX_COMPOSITE1,
252
                        .type   = CX88_VMUX_COMPOSITE1,
233
                        .vmux   = 1,
253
                        .vmux   = 1,
254
                        .gpio0  = 0x0000bde6,
234
                },{
255
                },{
235
                        .type   = CX88_VMUX_SVIDEO,
256
                        .type   = CX88_VMUX_SVIDEO,
236
                        .vmux   = 2,
257
                        .vmux   = 2,
258
                        .gpio0  = 0x0000bde6,
237
                }},
259
                }},
238
                .radio = {
260
                .radio = {
239
                        .type   = CX88_RADIO,
261
                        .type   = CX88_RADIO,
262
                        .gpio0  = 0x0000bd62,
240
                },
263
                },
241
		.blackbird = 1,
264
		.blackbird = 1,
242
        },
265
        },
Lines 320-333 struct cx88_board cx88_boards[] = { Link Here
320
                .name           = "KWorld/VStream XPert DVB-T",
343
                .name           = "KWorld/VStream XPert DVB-T",
321
		.tuner_type     = TUNER_ABSENT,
344
		.tuner_type     = TUNER_ABSENT,
322
                .input          = {{
345
                .input          = {{
323
                        .type   = CX88_VMUX_DVB,
324
                        .vmux   = 0,
325
                },{
326
                        .type   = CX88_VMUX_COMPOSITE1,
346
                        .type   = CX88_VMUX_COMPOSITE1,
327
                        .vmux   = 1,
347
                        .vmux   = 1,
348
			.gpio0  = 0x0700,
349
			.gpio2  = 0x0101,
328
                },{
350
                },{
329
                        .type   = CX88_VMUX_SVIDEO,
351
                        .type   = CX88_VMUX_SVIDEO,
330
                        .vmux   = 2,
352
                        .vmux   = 2,
353
			.gpio0  = 0x0700,
354
			.gpio2  = 0x0101,
331
                }},
355
                }},
332
		.dvb            = 1,
356
		.dvb            = 1,
333
	},
357
	},
Lines 452-457 struct cx88_board cx88_boards[] = { Link Here
452
		}},
476
		}},
453
		.dvb            = 1,
477
		.dvb            = 1,
454
	},
478
	},
479
	[CX88_BOARD_DNTV_LIVE_DVB_T] = {
480
		.name	        = "digitalnow DNTV Live! DVB-T",
481
		.tuner_type     = TUNER_ABSENT,
482
		.input	        = {{
483
			.type   = CX88_VMUX_COMPOSITE1,
484
			.vmux   = 1,
485
			.gpio0  = 0x00000700,
486
			.gpio2  = 0x00000101,
487
		},{
488
			.type   = CX88_VMUX_SVIDEO,
489
			.vmux   = 2,
490
			.gpio0  = 0x00000700,
491
			.gpio2  = 0x00000101,
492
		}},
493
		.dvb            = 1,
494
	},
495
	[CX88_BOARD_PCHDTV_HD3000] = {
496
		.name           = "pcHDTV HD3000 HDTV",
497
		.tuner_type     = TUNER_THOMSON_DTT7610,
498
		.input          = {{
499
			.type   = CX88_VMUX_TELEVISION,
500
			.vmux   = 0,
501
			.gpio0  = 0x00008484,
502
			.gpio1  = 0x00000000,
503
			.gpio2  = 0x00000000,
504
			.gpio3  = 0x00000000,
505
		},{
506
			.type   = CX88_VMUX_COMPOSITE1,
507
			.vmux   = 1,
508
			.gpio0  = 0x00008400,
509
			.gpio1  = 0x00000000,
510
			.gpio2  = 0x00000000,
511
			.gpio3  = 0x00000000,
512
		},{
513
			.type   = CX88_VMUX_SVIDEO,
514
			.vmux   = 2,
515
			.gpio0  = 0x00008400,
516
			.gpio1  = 0x00000000,
517
			.gpio2  = 0x00000000,
518
			.gpio3  = 0x00000000,
519
		}},
520
		.radio = {
521
			.type   = CX88_RADIO,
522
			.vmux   = 2,
523
			.gpio0  = 0x00008400,
524
			.gpio1  = 0x00000000,
525
			.gpio2  = 0x00000000,
526
			.gpio3  = 0x00000000,
527
		},
528
		.dvb            = 1,
529
	},
530
	[CX88_BOARD_HAUPPAUGE_ROSLYN] = {
531
		// entry added by Kaustubh D. Bhalerao <bhalerao.1@osu.edu>
532
		// GPIO values obtained from regspy, courtesy Sean Covel
533
		.name        = "Hauppauge WinTV 28xxx (Roslyn) models",
534
		.tuner_type  = UNSET,
535
		.input          = {{
536
			.type   = CX88_VMUX_TELEVISION,
537
			.vmux   = 0,
538
			.gpio0  = 0xed12,  // internal decoder
539
			.gpio2  = 0x00ff,
540
		},{
541
			.type   = CX88_VMUX_DEBUG,
542
			.vmux   = 0,
543
			.gpio0  = 0xff01,  // mono from tuner chip
544
		},{
545
			.type   = CX88_VMUX_COMPOSITE1,
546
			.vmux   = 1,
547
			.gpio0  = 0xff02,
548
		},{
549
			.type   = CX88_VMUX_SVIDEO,
550
			.vmux   = 2,
551
			.gpio0  = 0xed92,
552
			.gpio2  = 0x00ff,
553
		}},
554
		.radio = {
555
			 .type   = CX88_RADIO,
556
			 .gpio0  = 0xed96,
557
			 .gpio2  = 0x00ff,
558
		 },
559
		.blackbird = 1,
560
	},
561
	[CX88_BOARD_DIGITALLOGIC_MEC] = {
562
		/* params copied over from Leadtek PVR 2000 */
563
		.name           = "Digital-Logic MICROSPACE Entertainment Center (MEC)",
564
		/* not sure yet about the tuner type */
565
		.tuner_type     = 38,
566
		.tda9887_conf   = TDA9887_PRESENT,
567
		.input          = {{
568
			.type   = CX88_VMUX_TELEVISION,
569
			.vmux   = 0,
570
			.gpio0  = 0x0000bde6,
571
		},{
572
			.type   = CX88_VMUX_COMPOSITE1,
573
			.vmux   = 1,
574
			.gpio0  = 0x0000bde6,
575
		},{
576
			.type   = CX88_VMUX_SVIDEO,
577
			.vmux   = 2,
578
			.gpio0  = 0x0000bde6,
579
		}},
580
		.radio = {
581
			.type   = CX88_RADIO,
582
			.gpio0  = 0x0000bd62,
583
		},
584
		.blackbird = 1,
585
	},
586
	[CX88_BOARD_IODATA_GVBCTV7E] = {
587
		.name           = "IODATA GV/BCTV7E",
588
		.tuner_type     = TUNER_PHILIPS_FQ1286,
589
		.tda9887_conf   = TDA9887_PRESENT,
590
		.input          = {{
591
			.type   = CX88_VMUX_TELEVISION,
592
			.vmux   = 1,
593
			.gpio1  = 0x0000e03f,
594
		},{
595
			.type   = CX88_VMUX_COMPOSITE1,
596
			.vmux   = 2,
597
			.gpio1  = 0x0000e07f,
598
		},{
599
			.type   = CX88_VMUX_SVIDEO,
600
			.vmux   = 3,
601
			.gpio1  = 0x0000e07f,
602
		}}
603
	},
455
};
604
};
456
const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
605
const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
457
606
Lines 482-492 struct cx88_subid cx88_subids[] = { Link Here
482
	},{
631
	},{
483
                .subvendor = 0x107d,
632
                .subvendor = 0x107d,
484
                .subdevice = 0x6611,
633
                .subdevice = 0x6611,
485
                .card      = CX88_BOARD_WINFAST2000XP,
634
                .card      = CX88_BOARD_WINFAST2000XP_EXPERT,
486
	},{
635
	},{
487
                .subvendor = 0x107d,
636
                .subvendor = 0x107d,
488
                .subdevice = 0x6613,	/* NTSC */
637
                .subdevice = 0x6613,	/* NTSC */
489
                .card      = CX88_BOARD_WINFAST2000XP,
638
                .card      = CX88_BOARD_WINFAST2000XP_EXPERT,
490
	},{
639
	},{
491
		.subvendor = 0x107d,
640
		.subvendor = 0x107d,
492
                .subdevice = 0x6620,
641
                .subdevice = 0x6620,
Lines 543-548 struct cx88_subid cx88_subids[] = { Link Here
543
		.subvendor = 0x18AC,
692
		.subvendor = 0x18AC,
544
		.subdevice = 0xDB10,
693
		.subdevice = 0xDB10,
545
		.card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
694
		.card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
695
	},{
696
                .subvendor = 0x1554,
697
                .subdevice = 0x4811,
698
                .card      = CX88_BOARD_PIXELVIEW,
699
	},{
700
		.subvendor = 0x7063,
701
		.subdevice = 0x3000, /* HD-3000 card */
702
		.card      = CX88_BOARD_PCHDTV_HD3000,
703
	},{
704
		.subvendor = 0x17DE,
705
		.subdevice = 0xA8A6,
706
		.card      = CX88_BOARD_DNTV_LIVE_DVB_T,
707
	},{
708
		.subvendor = 0x0070,
709
		.subdevice = 0x2801,
710
		.card      = CX88_BOARD_HAUPPAUGE_ROSLYN,
711
	},{
712
		.subvendor = 0x14F1,
713
		.subdevice = 0x0342,
714
		.card      = CX88_BOARD_DIGITALLOGIC_MEC,
715
	},{
716
		.subvendor = 0x10fc,
717
		.subdevice = 0xd035,
718
		.card      = CX88_BOARD_IODATA_GVBCTV7E,
546
	}
719
	}
547
};
720
};
548
const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
721
const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
Lines 552-558 const unsigned int cx88_idcount = ARRAY_ Link Here
552
725
553
static void __devinit leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
726
static void __devinit leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
554
{
727
{
555
	/* This is just for the Winfast 2000 XP board ATM; I don't have data on
728
	/* This is just for the "Winfast 2000XP Expert" board ATM; I don't have data on
556
	 * any others.
729
	 * any others.
557
	 *
730
	 *
558
	 * Byte 0 is 1 on the NTSC board.
731
	 * Byte 0 is 1 on the NTSC board.
Lines 569-676 static void __devinit leadtek_eeprom(str Link Here
569
	core->has_radio  = 1;
742
	core->has_radio  = 1;
570
	core->tuner_type = (eeprom_data[6] == 0x13) ? 43 : 38;
743
	core->tuner_type = (eeprom_data[6] == 0x13) ? 43 : 38;
571
744
572
	printk(KERN_INFO "%s: Leadtek Winfast 2000 XP config: "
745
	printk(KERN_INFO "%s: Leadtek Winfast 2000XP Expert config: "
573
	       "tuner=%d, eeprom[0]=0x%02x\n",
746
	       "tuner=%d, eeprom[0]=0x%02x\n",
574
	       core->name, core->tuner_type, eeprom_data[0]);
747
	       core->name, core->tuner_type, eeprom_data[0]);
575
}
748
}
576
749
577
750
578
/* ----------------------------------------------------------------------- */
751
/* ----------------------------------------------------------------------- */
579
/* some hauppauge specific stuff                                           */
580
581
static struct {
582
        int  id;
583
        char *name;
584
} hauppauge_tuner[] __devinitdata = {
585
        { TUNER_ABSENT,        "" },
586
        { TUNER_ABSENT,        "External" },
587
        { TUNER_ABSENT,        "Unspecified" },
588
        { TUNER_PHILIPS_PAL,   "Philips FI1216" },
589
        { TUNER_PHILIPS_SECAM, "Philips FI1216MF" },
590
        { TUNER_PHILIPS_NTSC,  "Philips FI1236" },
591
        { TUNER_PHILIPS_PAL_I, "Philips FI1246" },
592
        { TUNER_PHILIPS_PAL_DK,"Philips FI1256" },
593
        { TUNER_PHILIPS_PAL,   "Philips FI1216 MK2" },
594
        { TUNER_PHILIPS_SECAM, "Philips FI1216MF MK2" },
595
        { TUNER_PHILIPS_NTSC,  "Philips FI1236 MK2" },
596
        { TUNER_PHILIPS_PAL_I, "Philips FI1246 MK2" },
597
        { TUNER_PHILIPS_PAL_DK,"Philips FI1256 MK2" },
598
        { TUNER_TEMIC_NTSC,    "Temic 4032FY5" },
599
        { TUNER_TEMIC_PAL,     "Temic 4002FH5" },
600
        { TUNER_TEMIC_PAL_I,   "Temic 4062FY5" },
601
        { TUNER_PHILIPS_PAL,   "Philips FR1216 MK2" },
602
        { TUNER_PHILIPS_SECAM, "Philips FR1216MF MK2" },
603
        { TUNER_PHILIPS_NTSC,  "Philips FR1236 MK2" },
604
        { TUNER_PHILIPS_PAL_I, "Philips FR1246 MK2" },
605
        { TUNER_PHILIPS_PAL_DK,"Philips FR1256 MK2" },
606
        { TUNER_PHILIPS_PAL,   "Philips FM1216" },
607
        { TUNER_PHILIPS_SECAM, "Philips FM1216MF" },
608
        { TUNER_PHILIPS_NTSC,  "Philips FM1236" },
609
        { TUNER_PHILIPS_PAL_I, "Philips FM1246" },
610
        { TUNER_PHILIPS_PAL_DK,"Philips FM1256" },
611
        { TUNER_TEMIC_4036FY5_NTSC, "Temic 4036FY5" },
612
        { TUNER_ABSENT,        "Samsung TCPN9082D" },
613
        { TUNER_ABSENT,        "Samsung TCPM9092P" },
614
        { TUNER_TEMIC_4006FH5_PAL, "Temic 4006FH5" },
615
        { TUNER_ABSENT,        "Samsung TCPN9085D" },
616
        { TUNER_ABSENT,        "Samsung TCPB9085P" },
617
        { TUNER_ABSENT,        "Samsung TCPL9091P" },
618
        { TUNER_TEMIC_4039FR5_NTSC, "Temic 4039FR5" },
619
        { TUNER_PHILIPS_FQ1216ME,   "Philips FQ1216 ME" },
620
        { TUNER_TEMIC_4066FY5_PAL_I, "Temic 4066FY5" },
621
        { TUNER_PHILIPS_NTSC,        "Philips TD1536" },
622
        { TUNER_PHILIPS_NTSC,        "Philips TD1536D" },
623
	{ TUNER_PHILIPS_NTSC,  "Philips FMR1236" }, /* mono radio */
624
        { TUNER_ABSENT,        "Philips FI1256MP" },
625
        { TUNER_ABSENT,        "Samsung TCPQ9091P" },
626
        { TUNER_TEMIC_4006FN5_MULTI_PAL, "Temic 4006FN5" },
627
        { TUNER_TEMIC_4009FR5_PAL, "Temic 4009FR5" },
628
        { TUNER_TEMIC_4046FM5,     "Temic 4046FM5" },
629
	{ TUNER_TEMIC_4009FN5_MULTI_PAL_FM, "Temic 4009FN5" },
630
	{ TUNER_ABSENT,        "Philips TD1536D_FH_44"},
631
	{ TUNER_LG_NTSC_FM,    "LG TPI8NSR01F"},
632
	{ TUNER_LG_PAL_FM,     "LG TPI8PSB01D"},
633
	{ TUNER_LG_PAL,        "LG TPI8PSB11D"},
634
	{ TUNER_LG_PAL_I_FM,   "LG TAPC-I001D"},
635
	{ TUNER_LG_PAL_I,      "LG TAPC-I701D"}
636
};
637
752
638
static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
753
static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
639
{
754
{
640
	unsigned int blk2,tuner,radio,model;
755
	struct tveeprom tv;
641
642
	if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0) {
643
		printk(KERN_WARNING "%s: Hauppauge eeprom: invalid\n",
644
		       core->name);
645
		return;
646
	}
647
648
	/* Block 2 starts after len+3 bytes header */
649
	blk2 = eeprom_data[1] + 3;
650
651
	/* decode + use some config infos */
652
	model = eeprom_data[12] << 8 | eeprom_data[11];
653
	tuner = eeprom_data[9];
654
	radio = eeprom_data[blk2-1] & 0x01;
655
656
        if (tuner < ARRAY_SIZE(hauppauge_tuner))
657
                core->tuner_type = hauppauge_tuner[tuner].id;
658
	if (radio)
659
		core->has_radio = 1;
660
756
661
	printk(KERN_INFO "%s: hauppauge eeprom: model=%d, "
757
	tveeprom_hauppauge_analog(&tv, eeprom_data);
662
	       "tuner=%s (%d), radio=%s\n",
758
	core->tuner_type = tv.tuner_type;
663
	       core->name, model, (tuner < ARRAY_SIZE(hauppauge_tuner)
759
	core->has_radio  = tv.has_radio;
664
				   ? hauppauge_tuner[tuner].name : "?"),
665
	       core->tuner_type, radio ? "yes" : "no");
666
}
760
}
667
761
668
#ifdef WITH_DVB
669
static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
762
static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
670
{
763
{
671
	int model;
764
	int model;
672
	int tuner;
765
	int tuner;
673
	char *tname;
674
766
675
	/* Make sure we support the board model */
767
	/* Make sure we support the board model */
676
	model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c];
768
	model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c];
Lines 689-714 static int hauppauge_eeprom_dvb(struct c Link Here
689
	/* Make sure we support the tuner */
781
	/* Make sure we support the tuner */
690
	tuner = ee[0x2d];
782
	tuner = ee[0x2d];
691
	switch(tuner) {
783
	switch(tuner) {
692
	case 0x4B:
784
	case 0x4B: /* dtt 7595 */
693
		tname = "Thomson DTT 7595";
785
	case 0x4C: /* dtt 7592 */
694
		core->pll_type = PLLTYPE_DTT7595;
695
		break;
696
	case 0x4C:
697
		tname = "Thomson DTT 7592";
698
		core->pll_type = PLLTYPE_DTT7592;
699
		break;
786
		break;
700
	default:
787
	default:
701
		printk("%s: error: unknown hauppauge tuner 0x%02x\n",
788
		printk("%s: error: unknown hauppauge tuner 0x%02x\n",
702
		       core->name, tuner);
789
		       core->name, tuner);
703
		return -ENODEV;
790
		return -ENODEV;
704
	}
791
	}
705
	printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%s (%d)\n",
792
	printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%d\n",
706
	       core->name, model, tname, tuner);
793
	       core->name, model, tuner);
707
794
	return 0;
708
	core->pll_addr = 0x61;
709
	core->demod_addr = 0x43;
710
}
795
}
711
#endif
712
796
713
/* ----------------------------------------------------------------------- */
797
/* ----------------------------------------------------------------------- */
714
/* some GDI (was: Modular Technology) specific stuff                       */
798
/* some GDI (was: Modular Technology) specific stuff                       */
Lines 763-798 static void gdi_eeprom(struct cx88_core Link Here
763
847
764
/* ----------------------------------------------------------------------- */
848
/* ----------------------------------------------------------------------- */
765
849
766
static int
767
i2c_eeprom(struct i2c_client *c, unsigned char *eedata, int len)
768
{
769
	unsigned char buf;
770
	int err;
771
772
	c->addr = 0xa0 >> 1;
773
	buf = 0;
774
	if (1 != (err = i2c_master_send(c,&buf,1))) {
775
		printk(KERN_INFO "cx88: Huh, no eeprom present (err=%d)?\n",
776
		       err);
777
		return -1;
778
	}
779
	if (len != (err = i2c_master_recv(c,eedata,len))) {
780
		printk(KERN_WARNING "cx88: i2c eeprom read error (err=%d)\n",
781
		       err);
782
		return -1;
783
	}
784
#if 0
785
	for (i = 0; i < len; i++) {
786
		if (0 == (i % 16))
787
			printk(KERN_INFO "cx88 ee: %02x:",i);
788
		printk(" %02x",eedata[i]);
789
		if (15 == (i % 16))
790
			printk("\n");
791
	}
792
#endif
793
	return 0;
794
}
795
796
void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
850
void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
797
{
851
{
798
	int i;
852
	int i;
Lines 823-863 void cx88_card_setup(struct cx88_core *c Link Here
823
{
877
{
824
	static u8 eeprom[128];
878
	static u8 eeprom[128];
825
879
880
	if (0 == core->i2c_rc) {
881
		core->i2c_client.addr = 0xa0 >> 1;
882
		tveeprom_read(&core->i2c_client,eeprom,sizeof(eeprom));
883
	}
884
826
	switch (core->board) {
885
	switch (core->board) {
827
	case CX88_BOARD_HAUPPAUGE:
886
	case CX88_BOARD_HAUPPAUGE:
887
	case CX88_BOARD_HAUPPAUGE_ROSLYN:
828
		if (0 == core->i2c_rc)
888
		if (0 == core->i2c_rc)
829
			i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
889
			hauppauge_eeprom(core,eeprom+8);
830
		hauppauge_eeprom(core,eeprom+8);
831
		break;
890
		break;
832
	case CX88_BOARD_GDI:
891
	case CX88_BOARD_GDI:
833
		if (0 == core->i2c_rc)
892
		if (0 == core->i2c_rc)
834
			i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
893
			gdi_eeprom(core,eeprom);
835
		gdi_eeprom(core,eeprom);
836
		break;
894
		break;
837
	case CX88_BOARD_WINFAST2000XP:
895
	case CX88_BOARD_WINFAST2000XP_EXPERT:
838
		if (0 == core->i2c_rc)
896
		if (0 == core->i2c_rc)
839
			i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
897
			leadtek_eeprom(core,eeprom);
840
		leadtek_eeprom(core,eeprom);
898
		break;
899
	case CX88_BOARD_HAUPPAUGE_DVB_T1:
900
		if (0 == core->i2c_rc)
901
			hauppauge_eeprom_dvb(core,eeprom);
841
		break;
902
		break;
842
	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
903
	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
843
		/* Tuner reset is hooked to  the tuner out of reset */
904
	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
905
		/* GPIO0:0 is hooked to mt352 reset pin */
844
		cx_set(MO_GP0_IO, 0x00000101);
906
		cx_set(MO_GP0_IO, 0x00000101);
845
		cx_clear(MO_GP0_IO, 0x00000001);
907
		cx_clear(MO_GP0_IO, 0x00000001);
846
		msleep(1);
908
		msleep(1);
847
		cx_set(MO_GP0_IO, 0x00000101);
909
		cx_set(MO_GP0_IO, 0x00000101);
848
		break;
910
		break;
849
#ifdef WITH_DVB
911
	case CX88_BOARD_KWORLD_DVB_T:
850
	case CX88_BOARD_HAUPPAUGE_DVB_T1:
912
	case CX88_BOARD_DNTV_LIVE_DVB_T:
851
		if (0 == core->i2c_rc)
913
		cx_set(MO_GP0_IO, 0x00000707);
852
			i2c_eeprom(&core->i2c_client,eeprom,sizeof(eeprom));
914
		cx_set(MO_GP2_IO, 0x00000101);
853
		hauppauge_eeprom_dvb(core,eeprom);
915
		cx_clear(MO_GP2_IO, 0x00000001);
854
		break;
916
		msleep(1);
855
	case CX88_BOARD_CONEXANT_DVB_T1:
917
		cx_clear(MO_GP0_IO, 0x00000007);
856
		core->pll_type   = PLLTYPE_DTT7579;
918
		cx_set(MO_GP2_IO, 0x00000101);
857
		core->pll_addr   = 0x60;
858
		core->demod_addr = 0x43;
859
		break;
919
		break;
860
#endif
861
	}
920
	}
862
	if (cx88_boards[core->board].radio.type == CX88_RADIO)
921
	if (cx88_boards[core->board].radio.type == CX88_RADIO)
863
		core->has_radio = 1;
922
		core->has_radio = 1;
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88-core.c (-10 / +32 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: cx88-core.c,v 1.15 2004/10/25 11:26:36 kraxel Exp $
2
 * $Id: cx88-core.c,v 1.24 2005/01/19 12:01:55 kraxel Exp $
3
 *
3
 *
4
 * device driver for Conexant 2388x based TV cards
4
 * device driver for Conexant 2388x based TV cards
5
 * driver core
5
 * driver core
Lines 24-29 Link Here
24
#include <linux/init.h>
24
#include <linux/init.h>
25
#include <linux/list.h>
25
#include <linux/list.h>
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/moduleparam.h>
27
#include <linux/kernel.h>
28
#include <linux/kernel.h>
28
#include <linux/slab.h>
29
#include <linux/slab.h>
29
#include <linux/kmod.h>
30
#include <linux/kmod.h>
Lines 62-67 static unsigned int nicam = 0; Link Here
62
module_param(nicam,int,0644);
63
module_param(nicam,int,0644);
63
MODULE_PARM_DESC(nicam,"tv audio is nicam");
64
MODULE_PARM_DESC(nicam,"tv audio is nicam");
64
65
66
static unsigned int nocomb = 0;
67
module_param(nocomb,int,0644);
68
MODULE_PARM_DESC(nocomb,"disable comb filter");
69
65
#define dprintk(level,fmt, arg...)	if (core_debug >= level)	\
70
#define dprintk(level,fmt, arg...)	if (core_debug >= level)	\
66
	printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
71
	printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
67
72
Lines 462-467 int cx88_risc_decode(u32 risc) Link Here
462
	return incr[risc >> 28] ? incr[risc >> 28] : 1;
467
	return incr[risc >> 28] ? incr[risc >> 28] : 1;
463
}
468
}
464
469
470
#if 0 /* currently unused, but useful for debugging */
465
void cx88_risc_disasm(struct cx88_core *core,
471
void cx88_risc_disasm(struct cx88_core *core,
466
		      struct btcx_riscmem *risc)
472
		      struct btcx_riscmem *risc)
467
{
473
{
Lines 479-484 void cx88_risc_disasm(struct cx88_core * Link Here
479
			break;
485
			break;
480
	}
486
	}
481
}
487
}
488
#endif
482
489
483
void cx88_sram_channel_dump(struct cx88_core *core,
490
void cx88_sram_channel_dump(struct cx88_core *core,
484
			    struct sram_channel *ch)
491
			    struct sram_channel *ch)
Lines 579-588 void cx88_print_irqbits(char *name, char Link Here
579
586
580
/* ------------------------------------------------------------------ */
587
/* ------------------------------------------------------------------ */
581
588
582
void cx88_irq(struct cx88_core *core, u32 status, u32 mask)
589
int cx88_core_irq(struct cx88_core *core, u32 status)
583
{
590
{
584
	cx88_print_irqbits(core->name, "irq pci",
591
	int handled = 0;
585
			   cx88_pci_irqs, status, mask);
592
593
	if (status & (1<<18)) {
594
		cx88_ir_irq(core);
595
		handled++;
596
	}
597
	if (!handled)
598
		cx88_print_irqbits(core->name, "irq pci",
599
				   cx88_pci_irqs, status,
600
				   core->pci_irqmask);
601
	return handled;
586
}
602
}
587
603
588
void cx88_wakeup(struct cx88_core *core,
604
void cx88_wakeup(struct cx88_core *core,
Lines 800-805 int cx88_set_scale(struct cx88_core *cor Link Here
800
		value |= (1 << 0); // 3-tap interpolation
816
		value |= (1 << 0); // 3-tap interpolation
801
	if (width < 193)
817
	if (width < 193)
802
		value |= (1 << 1); // 5-tap interpolation
818
		value |= (1 << 1); // 5-tap interpolation
819
	if (nocomb)
820
		value |= (3 << 5); // disable comb filter
803
821
804
	cx_write(MO_FILTER_EVEN,  value);
822
	cx_write(MO_FILTER_EVEN,  value);
805
	cx_write(MO_FILTER_ODD,   value);
823
	cx_write(MO_FILTER_ODD,   value);
Lines 887-894 static int set_tvaudio(struct cx88_core Link Here
887
	cx88_set_tvaudio(core);
905
	cx88_set_tvaudio(core);
888
	// cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO);
906
	// cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO);
889
907
890
	cx_write(MO_AUDD_LNGTH, 128/8);  /* fifo size */
908
	cx_write(MO_AUDD_LNGTH,    128); /* fifo size */
891
	cx_write(MO_AUDR_LNGTH, 128/8);  /* fifo size */
909
	cx_write(MO_AUDR_LNGTH,    128); /* fifo size */
892
	cx_write(MO_AUD_DMACNTRL, 0x03); /* need audio fifo */
910
	cx_write(MO_AUD_DMACNTRL, 0x03); /* need audio fifo */
893
	return 0;
911
	return 0;
894
}
912
}
Lines 969-974 int cx88_set_tvnorm(struct cx88_core *co Link Here
969
	cx_write(MO_VBI_PACKET, ((1 << 11) | /* (norm_vdelay(norm)   << 11) | */
987
	cx_write(MO_VBI_PACKET, ((1 << 11) | /* (norm_vdelay(norm)   << 11) | */
970
				 norm_vbipack(norm)));
988
				 norm_vbipack(norm)));
971
989
990
	// this is needed as well to set all tvnorm parameter
991
	cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED);
992
972
	// audio
993
	// audio
973
	set_tvaudio(core);
994
	set_tvaudio(core);
974
995
Lines 1105-1113 struct cx88_core* cx88_core_get(struct p Link Here
1105
		goto fail_unlock;
1126
		goto fail_unlock;
1106
1127
1107
	memset(core,0,sizeof(*core));
1128
	memset(core,0,sizeof(*core));
1129
	atomic_inc(&core->refcount);
1108
	core->pci_bus  = pci->bus->number;
1130
	core->pci_bus  = pci->bus->number;
1109
	core->pci_slot = PCI_SLOT(pci->devfn);
1131
	core->pci_slot = PCI_SLOT(pci->devfn);
1110
	atomic_inc(&core->refcount);
1132
	core->pci_irqmask = 0x00fc00;
1111
1133
1112
	core->nr = cx88_devcount++;
1134
	core->nr = cx88_devcount++;
1113
	sprintf(core->name,"cx88[%d]",core->nr);
1135
	sprintf(core->name,"cx88[%d]",core->nr);
Lines 1150-1155 struct cx88_core* cx88_core_get(struct p Link Here
1150
	cx88_reset(core);
1172
	cx88_reset(core);
1151
	cx88_i2c_init(core,pci);
1173
	cx88_i2c_init(core,pci);
1152
	cx88_card_setup(core);
1174
	cx88_card_setup(core);
1175
	cx88_ir_init(core,pci);
1153
1176
1154
	up(&devlist);
1177
	up(&devlist);
1155
	return core;
1178
	return core;
Lines 1170-1175 void cx88_core_put(struct cx88_core *cor Link Here
1170
		return;
1193
		return;
1171
1194
1172
	down(&devlist);
1195
	down(&devlist);
1196
	cx88_ir_fini(core);
1173
	if (0 == core->i2c_rc)
1197
	if (0 == core->i2c_rc)
1174
		i2c_bit_del_bus(&core->i2c_adap);
1198
		i2c_bit_del_bus(&core->i2c_adap);
1175
	list_del(&core->devlist);
1199
	list_del(&core->devlist);
Lines 1187-1193 EXPORT_SYMBOL(cx88_vid_irqs); Link Here
1187
EXPORT_SYMBOL(cx88_mpeg_irqs);
1211
EXPORT_SYMBOL(cx88_mpeg_irqs);
1188
EXPORT_SYMBOL(cx88_print_irqbits);
1212
EXPORT_SYMBOL(cx88_print_irqbits);
1189
1213
1190
EXPORT_SYMBOL(cx88_irq);
1214
EXPORT_SYMBOL(cx88_core_irq);
1191
EXPORT_SYMBOL(cx88_wakeup);
1215
EXPORT_SYMBOL(cx88_wakeup);
1192
EXPORT_SYMBOL(cx88_reset);
1216
EXPORT_SYMBOL(cx88_reset);
1193
EXPORT_SYMBOL(cx88_shutdown);
1217
EXPORT_SYMBOL(cx88_shutdown);
Lines 1197-1204 EXPORT_SYMBOL(cx88_risc_databuffer); Link Here
1197
EXPORT_SYMBOL(cx88_risc_stopper);
1221
EXPORT_SYMBOL(cx88_risc_stopper);
1198
EXPORT_SYMBOL(cx88_free_buffer);
1222
EXPORT_SYMBOL(cx88_free_buffer);
1199
1223
1200
EXPORT_SYMBOL(cx88_risc_disasm);
1201
1202
EXPORT_SYMBOL(cx88_sram_channels);
1224
EXPORT_SYMBOL(cx88_sram_channels);
1203
EXPORT_SYMBOL(cx88_sram_channel_setup);
1225
EXPORT_SYMBOL(cx88_sram_channel_setup);
1204
EXPORT_SYMBOL(cx88_sram_channel_dump);
1226
EXPORT_SYMBOL(cx88_sram_channel_dump);
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88-dvb.c (-72 / +115 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: cx88-dvb.c,v 1.19 2004/11/07 14:44:59 kraxel Exp $
2
 * $Id: cx88-dvb.c,v 1.31 2005/03/07 15:58:05 kraxel Exp $
3
 *
3
 *
4
 * device driver for Conexant 2388x based TV cards
4
 * device driver for Conexant 2388x based TV cards
5
 * MPEG Transport Stream (DVB) routines
5
 * MPEG Transport Stream (DVB) routines
Lines 30-39 Link Here
30
#include <linux/file.h>
30
#include <linux/file.h>
31
#include <linux/suspend.h>
31
#include <linux/suspend.h>
32
32
33
/* those two frontends need merging via linuxtv cvs ... */
34
#define HAVE_CX22702 1
35
#define HAVE_OR51132 1
36
33
#include "cx88.h"
37
#include "cx88.h"
34
#include "cx22702.h"
38
#include "dvb-pll.h"
35
#include "mt352.h"
39
#include "mt352.h"
36
#include "mt352_priv.h" /* FIXME */
40
#include "mt352_priv.h"
41
#if HAVE_CX22702
42
# include "cx22702.h"
43
#endif
44
#if HAVE_OR51132
45
# include "or51132.h"
46
#endif
37
47
38
MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
48
MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
39
MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
49
MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
Lines 110-220 static int dvico_fusionhdtv_demod_init(s Link Here
110
	return 0;
120
	return 0;
111
}
121
}
112
122
113
#define IF_FREQUENCYx6 217    /* 6 * 36.16666666667MHz */
123
static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
114
115
static int lg_z201_pll_set(struct dvb_frontend* fe,
116
			   struct dvb_frontend_parameters* params, u8* pllbuf)
117
{
124
{
118
	u32 div;
125
	static u8 clock_config []  = { 0x89, 0x38, 0x39 };
119
	unsigned char cp = 0;
126
	static u8 reset []         = { 0x50, 0x80 };
120
	unsigned char bs = 0;
127
	static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
121
128
	static u8 agc_cfg []       = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
122
	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
129
	                               0x00, 0xFF, 0x00, 0x40, 0x40 };
123
130
	static u8 dntv_extra[]     = { 0xB5, 0x7A };
124
	if (params->frequency < 542000000) cp = 0xbc;
131
	static u8 capt_range_cfg[] = { 0x75, 0x32 };
125
	else if (params->frequency < 830000000) cp = 0xf4;
126
	else cp = 0xfc;
127
132
128
	if (params->frequency == 0) bs = 0x03;
133
	mt352_write(fe, clock_config,   sizeof(clock_config));
129
	else if (params->frequency < 157500000) bs = 0x01;
134
	udelay(2000);
130
	else if (params->frequency < 443250000) bs = 0x02;
135
	mt352_write(fe, reset,          sizeof(reset));
131
	else bs = 0x04;
136
	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
132
137
133
	pllbuf[0] = 0xC2; /* Note: non-linux standard PLL I2C address */
138
	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
134
	pllbuf[1] = div >> 8;
139
	udelay(2000);
135
	pllbuf[2] = div & 0xff;
140
	mt352_write(fe, dntv_extra,     sizeof(dntv_extra));
136
	pllbuf[3] = cp;
141
	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
137
	pllbuf[4] = bs;
138
142
139
	return 0;
143
	return 0;
140
}
144
}
141
145
142
static int thomson_dtt7579_pll_set(struct dvb_frontend* fe,
146
static int mt352_pll_set(struct dvb_frontend* fe,
143
				   struct dvb_frontend_parameters* params,
147
			 struct dvb_frontend_parameters* params,
144
				   u8* pllbuf)
148
			 u8* pllbuf)
145
{
149
{
146
	u32 div;
150
	struct cx8802_dev *dev= fe->dvb->priv;
147
	unsigned char cp = 0;
148
	unsigned char bs = 0;
149
150
	div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
151
152
	if (params->frequency < 542000000) cp = 0xb4;
153
	else if (params->frequency < 771000000) cp = 0xbc;
154
	else cp = 0xf4;
155
156
        if (params->frequency == 0) bs = 0x03;
157
	else if (params->frequency < 443250000) bs = 0x02;
158
	else bs = 0x08;
159
160
	pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address
161
	pllbuf[1] = div >> 8;
162
   	pllbuf[2] = div & 0xff;
163
   	pllbuf[3] = cp;
164
   	pllbuf[4] = bs;
165
151
152
	pllbuf[0] = dev->core->pll_addr << 1;
153
	dvb_pll_configure(dev->core->pll_desc, pllbuf+1,
154
			  params->frequency,
155
			  params->u.ofdm.bandwidth);
166
	return 0;
156
	return 0;
167
}
157
}
168
158
169
struct mt352_config dvico_fusionhdtv_dvbt1 = {
159
static struct mt352_config dvico_fusionhdtv = {
170
	.demod_address = 0x0F,
160
	.demod_address = 0x0F,
171
	.demod_init    = dvico_fusionhdtv_demod_init,
161
	.demod_init    = dvico_fusionhdtv_demod_init,
172
	.pll_set       = lg_z201_pll_set,
162
	.pll_set       = mt352_pll_set,
173
};
163
};
174
164
175
struct mt352_config dvico_fusionhdtv_dvbt_plus = {
165
static struct mt352_config dntv_live_dvbt_config = {
176
	.demod_address = 0x0F,
166
	.demod_address = 0x0f,
177
	.demod_init    = dvico_fusionhdtv_demod_init,
167
	.demod_init    = dntv_live_dvbt_demod_init,
178
	.pll_set       = thomson_dtt7579_pll_set,
168
	.pll_set       = mt352_pll_set,
169
};
170
171
#if HAVE_CX22702
172
static struct cx22702_config connexant_refboard_config = {
173
	.demod_address = 0x43,
174
	.pll_address   = 0x60,
175
	.pll_desc      = &dvb_pll_thomson_dtt7579,
176
};
177
178
static struct cx22702_config hauppauge_novat_config = {
179
	.demod_address = 0x43,
180
	.pll_address   = 0x61,
181
	.pll_desc      = &dvb_pll_thomson_dtt759x,
179
};
182
};
183
#endif
184
185
#if HAVE_OR51132
186
static int or51132_set_ts_param(struct dvb_frontend* fe, 
187
				int is_punctured)
188
{
189
	struct cx8802_dev *dev= fe->dvb->priv;
190
	dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
191
	return 0;
192
}
193
194
struct or51132_config pchdtv_hd3000 = {
195
	.demod_address    = 0x15,
196
	.pll_address      = 0x61,
197
	.pll_desc         = &dvb_pll_thomson_dtt7610,
198
	.set_ts_params    = or51132_set_ts_param,
199
};
200
#endif
180
201
181
static int dvb_register(struct cx8802_dev *dev)
202
static int dvb_register(struct cx8802_dev *dev)
182
{
203
{
183
	/* init struct videobuf_dvb */
204
	/* init struct videobuf_dvb */
184
	dev->dvb.name = dev->core->name;
205
	dev->dvb.name = dev->core->name;
206
	dev->ts_gen_cntrl = 0x0c;
185
207
186
	/* init frontend */
208
	/* init frontend */
187
	switch (dev->core->board) {
209
	switch (dev->core->board) {
210
#if HAVE_CX22702
188
	case CX88_BOARD_HAUPPAUGE_DVB_T1:
211
	case CX88_BOARD_HAUPPAUGE_DVB_T1:
212
		dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config,
213
						   &dev->core->i2c_adap);
214
		break;
189
	case CX88_BOARD_CONEXANT_DVB_T1:
215
	case CX88_BOARD_CONEXANT_DVB_T1:
190
		dev->dvb.frontend = cx22702_create(&dev->core->i2c_adap,
216
		dev->dvb.frontend = cx22702_attach(&connexant_refboard_config,
191
						   dev->core->pll_addr,
217
						   &dev->core->i2c_adap);
192
						   dev->core->pll_type,
193
						   dev->core->demod_addr);
194
		break;
218
		break;
219
#endif
195
	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
220
	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
196
		dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt1,
221
		dev->core->pll_addr = 0x61;
222
		dev->core->pll_desc = &dvb_pll_lg_z201;
223
		dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
197
						 &dev->core->i2c_adap);
224
						 &dev->core->i2c_adap);
198
		if (dev->dvb.frontend) {
199
			dev->dvb.frontend->ops->info.frequency_min = 174000000;
200
			dev->dvb.frontend->ops->info.frequency_max = 862000000;
201
		}
202
		break;
225
		break;
203
	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
226
	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
204
		dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt_plus,
227
		dev->core->pll_addr = 0x60;
228
		dev->core->pll_desc = &dvb_pll_thomson_dtt7579;
229
		dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
230
						 &dev->core->i2c_adap);
231
		break;
232
	case CX88_BOARD_KWORLD_DVB_T:
233
	case CX88_BOARD_DNTV_LIVE_DVB_T:
234
		dev->core->pll_addr = 0x61;
235
		dev->core->pll_desc = &dvb_pll_unknown_1;
236
		dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
237
						 &dev->core->i2c_adap);
238
		break;
239
#if HAVE_OR51132
240
	case CX88_BOARD_PCHDTV_HD3000:
241
		dev->dvb.frontend = or51132_attach(&pchdtv_hd3000,
205
						 &dev->core->i2c_adap);
242
						 &dev->core->i2c_adap);
206
		if (dev->dvb.frontend) {
207
			dev->dvb.frontend->ops->info.frequency_min = 174000000;
208
			dev->dvb.frontend->ops->info.frequency_max = 862000000;
209
		}
210
		break;
243
		break;
244
#endif
211
	default:
245
	default:
212
		printk("%s: FIXME: frontend handling not here yet ...\n",
246
		printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n"
213
		       dev->core->name);
247
		       "%s: you might want to look out for patches here:\n"
248
		       "%s:     http://dl.bytesex.org/patches/\n",
249
		       dev->core->name, dev->core->name, dev->core->name);
214
		break;
250
		break;
215
	}
251
	}
216
	if (NULL == dev->dvb.frontend)
252
	if (NULL == dev->dvb.frontend) {
253
		printk("%s: frontend initialization failed\n",dev->core->name);
217
		return -1;
254
		return -1;
255
	}
256
257
	if (dev->core->pll_desc) {
258
		dev->dvb.frontend->ops->info.frequency_min = dev->core->pll_desc->min;
259
		dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max;
260
	}
218
261
219
	/* Copy the board name into the DVB structure */
262
	/* Copy the board name into the DVB structure */
220
	strlcpy(dev->dvb.frontend->ops->info.name,
263
	strlcpy(dev->dvb.frontend->ops->info.name,
Lines 222-228 static int dvb_register(struct cx8802_de Link Here
222
		sizeof(dev->dvb.frontend->ops->info.name));
265
		sizeof(dev->dvb.frontend->ops->info.name));
223
266
224
	/* register everything */
267
	/* register everything */
225
	return videobuf_dvb_register(&dev->dvb);
268
	return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
226
}
269
}
227
270
228
/* ----------------------------------------------------------- */
271
/* ----------------------------------------------------------- */
Lines 319-325 static int dvb_init(void) Link Here
319
	printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
362
	printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
320
	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
363
	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
321
#endif
364
#endif
322
	return pci_module_init(&dvb_pci_driver);
365
	return pci_register_driver(&dvb_pci_driver);
323
}
366
}
324
367
325
static void dvb_fini(void)
368
static void dvb_fini(void)
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88-i2c.c (-1 / +2 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
    $Id: cx88-i2c.c,v 1.18 2004/10/13 10:39:00 kraxel Exp $
2
    $Id: cx88-i2c.c,v 1.20 2005/02/15 15:59:35 kraxel Exp $
3
3
4
    cx88-i2c.c  --  all the i2c code is here
4
    cx88-i2c.c  --  all the i2c code is here
5
5
Lines 25-30 Link Here
25
*/
25
*/
26
26
27
#include <linux/module.h>
27
#include <linux/module.h>
28
#include <linux/moduleparam.h>
28
#include <linux/init.h>
29
#include <linux/init.h>
29
30
30
#include <asm/io.h>
31
#include <asm/io.h>
(-)linux-2.6.11/drivers/media/video/cx88/cx88-input.c (+396 lines)
Added Link Here
1
/*
2
 * $Id: cx88-input.c,v 1.9 2005/03/04 09:12:23 kraxel Exp $
3
 *
4
 * Device driver for GPIO attached remote control interfaces
5
 * on Conexant 2388x based TV/DVB cards.
6
 *
7
 * Copyright (c) 2003 Pavel Machek
8
 * Copyright (c) 2004 Gerd Knorr
9
 * Copyright (c) 2004 Chris Pascoe
10
 *
11
 * This program is free software; you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation; either version 2 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
 */
25
26
#include <linux/init.h>
27
#include <linux/delay.h>
28
#include <linux/input.h>
29
#include <linux/pci.h>
30
#include <linux/module.h>
31
#include <linux/moduleparam.h>
32
33
#include <media/ir-common.h>
34
35
#include "cx88.h"
36
37
/* ---------------------------------------------------------------------- */
38
39
/* DigitalNow DNTV Live DVB-T Remote */
40
static IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = {
41
	[ 0x00 ] = KEY_ESC,         // 'go up a level?'
42
	[ 0x01 ] = KEY_KP1,         // '1'
43
	[ 0x02 ] = KEY_KP2,         // '2'
44
	[ 0x03 ] = KEY_KP3,         // '3'
45
	[ 0x04 ] = KEY_KP4,         // '4'
46
	[ 0x05 ] = KEY_KP5,         // '5'
47
	[ 0x06 ] = KEY_KP6,         // '6'
48
	[ 0x07 ] = KEY_KP7,         // '7'
49
	[ 0x08 ] = KEY_KP8,         // '8'
50
	[ 0x09 ] = KEY_KP9,         // '9'
51
	[ 0x0a ] = KEY_KP0,         // '0'
52
	[ 0x0b ] = KEY_TUNER,       // 'tv/fm'
53
	[ 0x0c ] = KEY_SEARCH,      // 'scan'
54
	[ 0x0d ] = KEY_STOP,        // 'stop'
55
	[ 0x0e ] = KEY_PAUSE,       // 'pause'
56
	[ 0x0f ] = KEY_LIST,        // 'source'
57
58
	[ 0x10 ] = KEY_MUTE,        // 'mute'
59
	[ 0x11 ] = KEY_REWIND,      // 'backward <<'
60
	[ 0x12 ] = KEY_POWER,       // 'power'
61
	[ 0x13 ] = KEY_S,           // 'snap'
62
	[ 0x14 ] = KEY_AUDIO,       // 'stereo'
63
	[ 0x15 ] = KEY_CLEAR,       // 'reset'
64
	[ 0x16 ] = KEY_PLAY,        // 'play'
65
	[ 0x17 ] = KEY_ENTER,       // 'enter'
66
	[ 0x18 ] = KEY_ZOOM,        // 'full screen'
67
	[ 0x19 ] = KEY_FASTFORWARD, // 'forward >>'
68
	[ 0x1a ] = KEY_CHANNELUP,   // 'channel +'
69
	[ 0x1b ] = KEY_VOLUMEUP,    // 'volume +'
70
	[ 0x1c ] = KEY_INFO,        // 'preview'
71
	[ 0x1d ] = KEY_RECORD,      // 'record'
72
	[ 0x1e ] = KEY_CHANNELDOWN, // 'channel -'
73
	[ 0x1f ] = KEY_VOLUMEDOWN,  // 'volume -'
74
};
75
76
/* ---------------------------------------------------------------------- */
77
78
/* IO-DATA BCTV7E Remote */
79
static IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE] = {
80
	[ 0x40 ] = KEY_TV,              // TV
81
	[ 0x20 ] = KEY_RADIO,           // FM
82
	[ 0x60 ] = KEY_EPG,             // EPG
83
	[ 0x00 ] = KEY_POWER,           // power
84
85
	[ 0x50 ] = KEY_KP1,             // 1
86
	[ 0x30 ] = KEY_KP2,             // 2
87
	[ 0x70 ] = KEY_KP3,             // 3
88
	[ 0x10 ] = KEY_L,               // Live
89
90
	[ 0x48 ] = KEY_KP4,             // 4
91
	[ 0x28 ] = KEY_KP5,             // 5
92
	[ 0x68 ] = KEY_KP6,             // 6
93
	[ 0x08 ] = KEY_T,               // Time Shift
94
95
	[ 0x58 ] = KEY_KP7,             // 7
96
	[ 0x38 ] = KEY_KP8,             // 8
97
	[ 0x78 ] = KEY_KP9,             // 9
98
	[ 0x18 ] = KEY_PLAYPAUSE,       // Play
99
100
	[ 0x44 ] = KEY_KP0,             // 10
101
	[ 0x24 ] = KEY_ENTER,           // 11
102
	[ 0x64 ] = KEY_ESC,             // 12
103
	[ 0x04 ] = KEY_M,               // Multi
104
105
	[ 0x54 ] = KEY_VIDEO,           // VIDEO
106
	[ 0x34 ] = KEY_CHANNELUP,       // channel +
107
	[ 0x74 ] = KEY_VOLUMEUP,        // volume +
108
	[ 0x14 ] = KEY_MUTE,            // Mute
109
110
	[ 0x4c ] = KEY_S,               // SVIDEO
111
	[ 0x2c ] = KEY_CHANNELDOWN,     // channel -
112
	[ 0x6c ] = KEY_VOLUMEDOWN,      // volume -
113
	[ 0x0c ] = KEY_ZOOM,            // Zoom
114
115
	[ 0x5c ] = KEY_PAUSE,           // pause
116
	[ 0x3c ] = KEY_C,               // || (red)
117
	[ 0x7c ] = KEY_RECORD,          // recording
118
	[ 0x1c ] = KEY_STOP,            // stop
119
120
	[ 0x41 ] = KEY_REWIND,          // backward <<
121
	[ 0x21 ] = KEY_PLAY,            // play
122
	[ 0x61 ] = KEY_FASTFORWARD,     // forward >>
123
	[ 0x01 ] = KEY_NEXT,            // skip >|
124
};
125
126
/* ---------------------------------------------------------------------- */
127
128
struct cx88_IR {
129
	struct cx88_core	*core;
130
	struct input_dev        input;
131
	struct ir_input_state   ir;
132
	char                    name[32];
133
	char                    phys[32];
134
135
	/* sample from gpio pin 16 */
136
	int                     sampling;
137
	u32                     samples[16];
138
	int                     scount;
139
	unsigned long           release;
140
141
	/* poll external decoder */
142
	int                     polling;
143
	struct work_struct      work;
144
	struct timer_list       timer;
145
	u32			gpio_addr;
146
	u32                     last_gpio;
147
	u32                     mask_keycode;
148
	u32                     mask_keydown;
149
	u32                     mask_keyup;
150
};
151
152
static int ir_debug = 0;
153
module_param(ir_debug, int, 0644);    /* debug level [IR] */
154
MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
155
156
#define ir_dprintk(fmt, arg...)	if (ir_debug) \
157
	printk(KERN_DEBUG "%s IR: " fmt , ir->core->name, ## arg)
158
159
/* ---------------------------------------------------------------------- */
160
161
static void cx88_ir_handle_key(struct cx88_IR *ir)
162
{
163
	struct cx88_core *core = ir->core;
164
	u32 gpio, data;
165
166
	/* read gpio value */
167
	gpio = cx_read(ir->gpio_addr);
168
	if (ir->polling) {
169
		if (ir->last_gpio == gpio)
170
			return;
171
		ir->last_gpio = gpio;
172
	}
173
174
	/* extract data */
175
	data = ir_extract_bits(gpio, ir->mask_keycode);
176
	ir_dprintk("irq gpio=0x%x code=%d | %s%s%s\n",
177
		gpio, data,
178
		ir->polling               ? "poll"  : "irq",
179
		(gpio & ir->mask_keydown) ? " down" : "",
180
		(gpio & ir->mask_keyup)   ? " up"   : "");
181
182
	if (ir->mask_keydown) {
183
		/* bit set on keydown */
184
		if (gpio & ir->mask_keydown) {
185
			ir_input_keydown(&ir->input,&ir->ir,data,data);
186
		} else {
187
			ir_input_nokey(&ir->input,&ir->ir);
188
		}
189
190
	} else if (ir->mask_keyup) {
191
		/* bit cleared on keydown */
192
		if (0 == (gpio & ir->mask_keyup)) {
193
			ir_input_keydown(&ir->input,&ir->ir,data,data);
194
		} else {
195
			ir_input_nokey(&ir->input,&ir->ir);
196
		}
197
198
	} else {
199
		/* can't distinguish keydown/up :-/ */
200
		ir_input_keydown(&ir->input,&ir->ir,data,data);
201
		ir_input_nokey(&ir->input,&ir->ir);
202
	}
203
}
204
205
static void ir_timer(unsigned long data)
206
{
207
	struct cx88_IR *ir = (struct cx88_IR*)data;
208
209
	schedule_work(&ir->work);
210
}
211
212
static void cx88_ir_work(void *data)
213
{
214
	struct cx88_IR *ir = data;
215
	unsigned long timeout;
216
217
	cx88_ir_handle_key(ir);
218
	timeout = jiffies + (ir->polling * HZ / 1000);
219
	mod_timer(&ir->timer, timeout);
220
}
221
222
/* ---------------------------------------------------------------------- */
223
224
int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
225
{
226
	struct cx88_IR *ir;
227
	IR_KEYTAB_TYPE *ir_codes = NULL;
228
	int ir_type = IR_TYPE_OTHER;
229
230
	ir = kmalloc(sizeof(*ir),GFP_KERNEL);
231
	if (NULL == ir)
232
		return -ENOMEM;
233
	memset(ir,0,sizeof(*ir));
234
235
	/* detect & configure */
236
	switch (core->board) {
237
	case CX88_BOARD_DNTV_LIVE_DVB_T:
238
		ir_codes         = ir_codes_dntv_live_dvb_t;
239
		ir->gpio_addr    = MO_GP1_IO;
240
		ir->mask_keycode = 0x1f;
241
		ir->mask_keyup   = 0x60;
242
		ir->polling      = 50; // ms
243
		break;
244
	case CX88_BOARD_HAUPPAUGE:
245
	case CX88_BOARD_HAUPPAUGE_DVB_T1:
246
		ir_codes         = ir_codes_hauppauge_new;
247
		ir_type          = IR_TYPE_RC5;
248
		ir->sampling     = 1;
249
		break;
250
	case CX88_BOARD_WINFAST2000XP_EXPERT:
251
		ir_codes         = ir_codes_winfast;
252
		ir->gpio_addr    = MO_GP0_IO;
253
		ir->mask_keycode = 0x8f8; 
254
		ir->mask_keyup   = 0x100;
255
		ir->polling      = 1; // ms
256
		break;
257
	case CX88_BOARD_IODATA_GVBCTV7E:
258
		ir_codes         = ir_codes_iodata_bctv7e;
259
		ir->gpio_addr    = MO_GP0_IO;
260
		ir->mask_keycode = 0xfd;
261
		ir->mask_keydown = 0x02;
262
		ir->polling      = 5; // ms
263
		break;
264
	}
265
	if (NULL == ir_codes) {
266
		kfree(ir);
267
		return -ENODEV;
268
	}
269
270
	/* init input device */
271
	snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)",
272
		 cx88_boards[core->board].name);
273
	snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
274
		 pci_name(pci));
275
276
	ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes);
277
	ir->input.name = ir->name;
278
	ir->input.phys = ir->phys;
279
	ir->input.id.bustype = BUS_PCI;
280
	ir->input.id.version = 1;
281
	if (pci->subsystem_vendor) {
282
		ir->input.id.vendor  = pci->subsystem_vendor;
283
		ir->input.id.product = pci->subsystem_device;
284
	} else {
285
		ir->input.id.vendor  = pci->vendor;
286
		ir->input.id.product = pci->device;
287
	}
288
289
	/* record handles to ourself */
290
	ir->core = core;
291
	core->ir = ir;
292
293
	if (ir->polling) {
294
		INIT_WORK(&ir->work, cx88_ir_work, ir);
295
		init_timer(&ir->timer);
296
		ir->timer.function = ir_timer;
297
		ir->timer.data     = (unsigned long)ir;
298
		schedule_work(&ir->work);
299
	}
300
	if (ir->sampling) {
301
		core->pci_irqmask |= (1<<18);   // IR_SMP_INT
302
		cx_write(MO_DDS_IO, 0xa80a80);  // 4 kHz sample rate
303
		cx_write(MO_DDSCFG_IO,   0x5);  // enable
304
	}
305
306
	/* all done */
307
	input_register_device(&ir->input);
308
	printk("%s: registered IR remote control\n", core->name);
309
310
	return 0;
311
}
312
313
int cx88_ir_fini(struct cx88_core *core)
314
{
315
	struct cx88_IR *ir = core->ir;
316
317
	/* skip detach on non attached boards */
318
	if (NULL == ir)
319
		return 0;
320
321
	if (ir->polling) {
322
		del_timer(&ir->timer);
323
		flush_scheduled_work();
324
	}
325
326
	input_unregister_device(&ir->input);
327
	kfree(ir);
328
329
	/* done */
330
	core->ir = NULL;
331
	return 0;
332
}
333
334
/* ---------------------------------------------------------------------- */
335
336
void cx88_ir_irq(struct cx88_core *core)
337
{
338
	struct cx88_IR *ir = core->ir;
339
	u32 samples,rc5;
340
	int i;
341
342
	if (NULL == ir)
343
		return;
344
	if (!ir->sampling)
345
		return;
346
347
	samples = cx_read(MO_SAMPLE_IO);
348
	if (0 != samples  &&  0xffffffff != samples) {
349
		/* record sample data */
350
		if (ir->scount < ARRAY_SIZE(ir->samples))
351
			ir->samples[ir->scount++] = samples;
352
		return;
353
	}
354
	if (!ir->scount) {
355
		/* nothing to sample */
356
		if (ir->ir.keypressed && time_after(jiffies,ir->release))
357
			ir_input_nokey(&ir->input,&ir->ir);
358
		return;
359
	}
360
361
	/* have a complete sample */
362
	if (ir->scount < ARRAY_SIZE(ir->samples))
363
		ir->samples[ir->scount++] = samples;
364
	for (i = 0; i < ir->scount; i++)
365
		ir->samples[i] = ~ir->samples[i];
366
	if (ir_debug)
367
		ir_dump_samples(ir->samples,ir->scount);
368
369
	/* decode it */
370
	switch (core->board) {
371
	case CX88_BOARD_HAUPPAUGE:
372
	case CX88_BOARD_HAUPPAUGE_DVB_T1:
373
		rc5 = ir_decode_biphase(ir->samples,ir->scount,5,7);
374
		ir_dprintk("biphase decoded: %x\n",rc5);
375
		if ((rc5 & 0xfffff000) != 0x3000)
376
			break;
377
		ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5);
378
		ir->release = jiffies + msecs_to_jiffies(120);
379
		break;
380
	}
381
382
	ir->scount = 0;
383
	return;
384
}
385
386
/* ---------------------------------------------------------------------- */
387
388
MODULE_AUTHOR("Gerd Knorr, Pavel Machek, Chris Pascoe");
389
MODULE_DESCRIPTION("input driver for cx88 GPIO-based IR remote controls");
390
MODULE_LICENSE("GPL");
391
392
/*
393
 * Local variables:
394
 * c-basic-offset: 8
395
 * End:
396
 */
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88-mpeg.c (-23 / +21 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: cx88-mpeg.c,v 1.14 2004/10/25 11:26:36 kraxel Exp $
2
 * $Id: cx88-mpeg.c,v 1.25 2005/03/07 14:18:00 kraxel Exp $
3
 *
3
 *
4
 *  Support for the mpeg transport stream transfers
4
 *  Support for the mpeg transport stream transfers
5
 *  PCI function #2 of the cx2388x.
5
 *  PCI function #2 of the cx2388x.
Lines 24-29 Link Here
24
 */
24
 */
25
25
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/moduleparam.h>
27
#include <linux/init.h>
28
#include <linux/init.h>
28
#include <linux/device.h>
29
#include <linux/device.h>
29
#include <linux/interrupt.h>
30
#include <linux/interrupt.h>
Lines 68-75 static int cx8802_start_dma(struct cx880 Link Here
68
	 * also: move to cx88-blackbird + cx88-dvb source files? */
69
	 * also: move to cx88-blackbird + cx88-dvb source files? */
69
70
70
	if (cx88_boards[core->board].dvb) {
71
	if (cx88_boards[core->board].dvb) {
71
		/* Setup TS portion of chip */
72
		/* negedge driven & software reset */
72
		cx_write(TS_GEN_CNTRL, 0x0c);
73
		cx_write(TS_GEN_CNTRL, 0x40); 
74
		udelay(100);
75
		cx_write(MO_PINMUX_IO, 0x00);
76
		cx_write(TS_HW_SOP_CNTRL,47<<16|188<<4|0x00);
77
		cx_write(TS_SOP_STAT,0x00);
78
		cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl); 
79
		udelay(100);
73
	}
80
	}
74
81
75
	if (cx88_boards[core->board].blackbird) {
82
	if (cx88_boards[core->board].blackbird) {
Lines 93-99 static int cx8802_start_dma(struct cx880 Link Here
93
	q->count = 1;
100
	q->count = 1;
94
101
95
	/* enable irqs */
102
	/* enable irqs */
96
	cx_set(MO_PCI_INTMSK, 0x00fc04);
103
	cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x04);
97
	cx_write(MO_TS_INTMSK,  0x1f0011);
104
	cx_write(MO_TS_INTMSK,  0x1f0011);
98
105
99
	/* start dma */
106
	/* start dma */
Lines 292-310 static irqreturn_t cx8802_irq(int irq, v Link Here
292
{
299
{
293
	struct cx8802_dev *dev = dev_id;
300
	struct cx8802_dev *dev = dev_id;
294
	struct cx88_core *core = dev->core;
301
	struct cx88_core *core = dev->core;
295
	u32 status, mask;
302
	u32 status;
296
	int loop, handled = 0;
303
	int loop, handled = 0;
297
304
298
	for (loop = 0; loop < 10; loop++) {
305
	for (loop = 0; loop < 10; loop++) {
299
		status = cx_read(MO_PCI_INTSTAT) & (~0x1f | 0x04);
306
		status = cx_read(MO_PCI_INTSTAT) & (core->pci_irqmask | 0x04);
300
		mask   = cx_read(MO_PCI_INTMSK);
307
		if (0 == status)
301
		if (0 == (status & mask))
302
			goto out;
308
			goto out;
303
		handled = 1;
309
		handled = 1;
304
		cx_write(MO_PCI_INTSTAT, status);
310
		cx_write(MO_PCI_INTSTAT, status);
305
311
306
		if (status & mask & ~0x1f)
312
		if (status & core->pci_irqmask)
307
			cx88_irq(core,status,mask);
313
			cx88_core_irq(core,status);
308
		if (status & 0x04)
314
		if (status & 0x04)
309
			cx8802_mpeg_irq(dev);
315
			cx8802_mpeg_irq(dev);
310
	};
316
	};
Lines 323-328 static irqreturn_t cx8802_irq(int irq, v Link Here
323
329
324
int cx8802_init_common(struct cx8802_dev *dev)
330
int cx8802_init_common(struct cx8802_dev *dev)
325
{
331
{
332
	struct cx88_core *core = dev->core;
326
	int err;
333
	int err;
327
334
328
	/* pci init */
335
	/* pci init */
Lines 354-364 int cx8802_init_common(struct cx8802_dev Link Here
354
	cx88_risc_stopper(dev->pci,&dev->mpegq.stopper,
361
	cx88_risc_stopper(dev->pci,&dev->mpegq.stopper,
355
			  MO_TS_DMACNTRL,0x11,0x00);
362
			  MO_TS_DMACNTRL,0x11,0x00);
356
363
357
#if 0 /* FIXME */
358
	/* initialize hardware */
359
	cx8802_reset(dev);
360
#endif
361
362
	/* get irq */
364
	/* get irq */
363
	err = request_irq(dev->pci->irq, cx8802_irq,
365
	err = request_irq(dev->pci->irq, cx8802_irq,
364
			  SA_SHIRQ | SA_INTERRUPT, dev->core->name, dev);
366
			  SA_SHIRQ | SA_INTERRUPT, dev->core->name, dev);
Lines 367-377 int cx8802_init_common(struct cx8802_dev Link Here
367
		       dev->core->name, dev->pci->irq);
369
		       dev->core->name, dev->pci->irq);
368
		return err;
370
		return err;
369
	}
371
	}
370
372
	cx_set(MO_PCI_INTMSK, core->pci_irqmask);
371
#if 0 /* FIXME */
372
	/* register i2c bus + load i2c helpers */
373
	cx88_card_setup(dev);
374
#endif
375
373
376
	/* everything worked */
374
	/* everything worked */
377
	pci_set_drvdata(dev->pci,dev);
375
	pci_set_drvdata(dev->pci,dev);
Lines 393-399 void cx8802_fini_common(struct cx8802_de Link Here
393
391
394
/* ----------------------------------------------------------- */
392
/* ----------------------------------------------------------- */
395
393
396
int cx8802_suspend_common(struct pci_dev *pci_dev, u32 state)
394
int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
397
{
395
{
398
        struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
396
        struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
399
	struct cx88_core *core = dev->core;
397
	struct cx88_core *core = dev->core;
Lines 413-419 int cx8802_suspend_common(struct pci_dev Link Here
413
#endif
411
#endif
414
412
415
	pci_save_state(pci_dev);
413
	pci_save_state(pci_dev);
416
	if (0 != pci_set_power_state(pci_dev, state)) {
414
	if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
417
		pci_disable_device(pci_dev);
415
		pci_disable_device(pci_dev);
418
		dev->state.disabled = 1;
416
		dev->state.disabled = 1;
419
	}
417
	}
Lines 429-435 int cx8802_resume_common(struct pci_dev Link Here
429
		pci_enable_device(pci_dev);
427
		pci_enable_device(pci_dev);
430
		dev->state.disabled = 0;
428
		dev->state.disabled = 0;
431
	}
429
	}
432
	pci_set_power_state(pci_dev, 0);
430
	pci_set_power_state(pci_dev, PCI_D0);
433
	pci_restore_state(pci_dev);
431
	pci_restore_state(pci_dev);
434
432
435
#if 1
433
#if 1
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88-tvaudio.c (-136 / +319 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
    $Id: cx88-tvaudio.c,v 1.24 2004/10/25 11:51:00 kraxel Exp $
2
    $Id: cx88-tvaudio.c,v 1.34 2005/03/07 16:10:51 kraxel Exp $
3
3
4
    cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
4
    cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
5
5
Lines 37-42 Link Here
37
*/
37
*/
38
38
39
#include <linux/module.h>
39
#include <linux/module.h>
40
#include <linux/moduleparam.h>
40
#include <linux/errno.h>
41
#include <linux/errno.h>
41
#include <linux/kernel.h>
42
#include <linux/kernel.h>
42
#include <linux/slab.h>
43
#include <linux/slab.h>
Lines 56-62 Link Here
56
57
57
#include "cx88.h"
58
#include "cx88.h"
58
59
59
static unsigned int audio_debug = 1;
60
static unsigned int audio_debug = 0;
60
module_param(audio_debug,int,0644);
61
module_param(audio_debug,int,0644);
61
MODULE_PARM_DESC(audio_debug,"enable debug messages [audio]");
62
MODULE_PARM_DESC(audio_debug,"enable debug messages [audio]");
62
63
Lines 141-146 static void set_audio_finish(struct cx88 Link Here
141
{
142
{
142
	u32 volume;
143
	u32 volume;
143
144
145
	if (cx88_boards[core->board].blackbird) {
146
		// 'pass-thru mode': this enables the i2s output to the mpeg encoder
147
		cx_set(AUD_CTL, 0x2000);
148
		cx_write(AUD_I2SOUTPUTCNTL, 1);
149
		//cx_write(AUD_APB_IN_RATE_ADJ, 0);
150
	}
151
144
	// finish programming
152
	// finish programming
145
	cx_write(AUD_SOFT_RESET, 0x0000);
153
	cx_write(AUD_SOFT_RESET, 0x0000);
146
154
Lines 263-268 static void set_audio_standard_BTSC(stru Link Here
263
	set_audio_finish(core);
271
	set_audio_finish(core);
264
}
272
}
265
273
274
#if 0
266
static void set_audio_standard_NICAM(struct cx88_core *core)
275
static void set_audio_standard_NICAM(struct cx88_core *core)
267
{
276
{
268
	static const struct rlist nicam_common[] = {
277
	static const struct rlist nicam_common[] = {
Lines 335-462 static void set_audio_standard_NICAM(str Link Here
335
	};
344
	};
336
        set_audio_finish(core);
345
        set_audio_finish(core);
337
}
346
}
347
#endif
338
348
339
static void set_audio_standard_NICAM_L(struct cx88_core *core)
349
static void set_audio_standard_NICAM_L(struct cx88_core *core, int stereo)
340
{
350
{
341
	/* This is officially weird.. register dumps indicate windows
351
        /* This is probably weird..
342
	 * uses audio mode 4.. A2. Let's operate and find out. */
352
         * Let's operate and find out. */
343
353
344
	static const struct rlist nicam_l[] = {
354
        static const struct rlist nicam_l_mono[] = {
345
		// setup QAM registers
355
                { AUD_ERRLOGPERIOD_R,     0x00000064 },
346
		{ AUD_PDF_DDS_CNST_BYTE2,	   0x48 },
356
                { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF },
347
		{ AUD_PDF_DDS_CNST_BYTE1,          0x3d },
357
                { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F },
348
		{ AUD_PDF_DDS_CNST_BYTE0,          0xf5 },
358
                { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F },
349
		{ AUD_QAM_MODE,                    0x00 },
350
		{ AUD_PHACC_FREQ_8MSB,             0x3a },
351
		{ AUD_PHACC_FREQ_8LSB,             0x4a },
352
359
353
		{ AUD_POLY0_DDS_CONSTANT,          0x000e4db2 },
360
                { AUD_PDF_DDS_CNST_BYTE2, 0x48 },
354
		{ AUD_IIR1_0_SEL,                  0x00000000 },
361
                { AUD_PDF_DDS_CNST_BYTE1, 0x3D },
355
		{ AUD_IIR1_1_SEL,                  0x00000002 },
362
                { AUD_QAM_MODE,           0x00 },
356
		{ AUD_IIR1_2_SEL,                  0x00000023 },
363
                { AUD_PDF_DDS_CNST_BYTE0, 0xf5 },
357
		{ AUD_IIR1_3_SEL,                  0x00000004 },
364
                { AUD_PHACC_FREQ_8MSB,    0x3a },
358
		{ AUD_IIR1_4_SEL,                  0x00000005 },
365
                { AUD_PHACC_FREQ_8LSB,    0x4a },
359
		{ AUD_IIR1_5_SEL,                  0x00000007 },
360
		{ AUD_IIR1_0_SHIFT,                0x00000007 },
361
		{ AUD_IIR1_1_SHIFT,                0x00000000 },
362
		{ AUD_IIR1_2_SHIFT,                0x00000000 },
363
		{ AUD_IIR1_3_SHIFT,                0x00000007 },
364
		{ AUD_IIR1_4_SHIFT,                0x00000007 },
365
		{ AUD_IIR1_5_SHIFT,                0x00000007 },
366
		{ AUD_IIR2_0_SEL,                  0x00000002 },
367
		{ AUD_IIR2_1_SEL,                  0x00000003 },
368
		{ AUD_IIR2_2_SEL,                  0x00000004 },
369
		{ AUD_IIR2_3_SEL,                  0x00000005 },
370
		{ AUD_IIR3_0_SEL,                  0x00000007 },
371
		{ AUD_IIR3_1_SEL,                  0x00000023 },
372
		{ AUD_IIR3_2_SEL,                  0x00000016 },
373
		{ AUD_IIR4_0_SHIFT,                0x00000000 },
374
		{ AUD_IIR4_1_SHIFT,                0x00000000 },
375
		{ AUD_IIR3_2_SHIFT,                0x00000002 },
376
		{ AUD_IIR4_0_SEL,                  0x0000001d },
377
		{ AUD_IIR4_1_SEL,                  0x00000019 },
378
		{ AUD_IIR4_2_SEL,                  0x00000008 },
379
		{ AUD_IIR4_0_SHIFT,                0x00000000 },
380
		{ AUD_IIR4_1_SHIFT,                0x00000007 },
381
		{ AUD_IIR4_2_SHIFT,                0x00000007 },
382
		{ AUD_IIR4_0_CA0,                  0x0003e57e },
383
		{ AUD_IIR4_0_CA1,                  0x00005e11 },
384
		{ AUD_IIR4_0_CA2,                  0x0003a7cf },
385
		{ AUD_IIR4_0_CB0,                  0x00002368 },
386
		{ AUD_IIR4_0_CB1,                  0x0003bf1b },
387
		{ AUD_IIR4_1_CA0,                  0x00006349 },
388
		{ AUD_IIR4_1_CA1,                  0x00006f27 },
389
		{ AUD_IIR4_1_CA2,                  0x0000e7a3 },
390
		{ AUD_IIR4_1_CB0,                  0x00005653 },
391
		{ AUD_IIR4_1_CB1,                  0x0000cf97 },
392
		{ AUD_IIR4_2_CA0,                  0x00006349 },
393
		{ AUD_IIR4_2_CA1,                  0x00006f27 },
394
		{ AUD_IIR4_2_CA2,                  0x0000e7a3 },
395
		{ AUD_IIR4_2_CB0,                  0x00005653 },
396
		{ AUD_IIR4_2_CB1,                  0x0000cf97 },
397
		{ AUD_HP_MD_IIR4_1,                0x00000001 },
398
		{ AUD_HP_PROG_IIR4_1,              0x0000001a },
399
		{ AUD_DN0_FREQ,                    0x00000000 },
400
		{ AUD_DN1_FREQ,                    0x00003318 },
401
		{ AUD_DN1_SRC_SEL,                 0x00000017 },
402
		{ AUD_DN1_SHFT,                    0x00000007 },
403
		{ AUD_DN1_AFC,                     0x00000000 },
404
		{ AUD_DN1_FREQ_SHIFT,              0x00000000 },
405
		{ AUD_DN2_FREQ,                    0x00003551 },
406
		{ AUD_DN2_SRC_SEL,                 0x00000001 },
407
		{ AUD_DN2_SHFT,                    0x00000000 },
408
		{ AUD_DN2_AFC,                     0x00000002 },
409
		{ AUD_DN2_FREQ_SHIFT,              0x00000000 },
410
		{ AUD_PDET_SRC,                    0x00000014 },
411
		{ AUD_PDET_SHIFT,                  0x00000000 },
412
		{ AUD_DEEMPH0_SRC_SEL,             0x00000011 },
413
		{ AUD_DEEMPH1_SRC_SEL,             0x00000011 },
414
		{ AUD_DEEMPH0_SHIFT,               0x00000000 },
415
		{ AUD_DEEMPH1_SHIFT,               0x00000000 },
416
		{ AUD_DEEMPH0_G0,                  0x00007000 },
417
		{ AUD_DEEMPH0_A0,                  0x00000000 },
418
		{ AUD_DEEMPH0_B0,                  0x00000000 },
419
		{ AUD_DEEMPH0_A1,                  0x00000000 },
420
		{ AUD_DEEMPH0_B1,                  0x00000000 },
421
		{ AUD_DEEMPH1_G0,                  0x00007000 },
422
		{ AUD_DEEMPH1_A0,                  0x00000000 },
423
		{ AUD_DEEMPH1_B0,                  0x00000000 },
424
		{ AUD_DEEMPH1_A1,                  0x00000000 },
425
		{ AUD_DEEMPH1_B1,                  0x00000000 },
426
		{ AUD_DMD_RA_DDS,                  0x00f5c285 },
427
		{ AUD_RATE_ADJ1,                   0x00000100 },
428
		{ AUD_RATE_ADJ2,                   0x00000200 },
429
		{ AUD_RATE_ADJ3,                   0x00000300 },
430
		{ AUD_RATE_ADJ4,                   0x00000400 },
431
		{ AUD_RATE_ADJ5,                   0x00000500 },
432
		{ AUD_C2_UP_THR,                   0x00005400 },
433
		{ AUD_C2_LO_THR,                   0x00003000 },
434
		{ AUD_C1_UP_THR,                   0x00007000 },
435
		{ AUD_C2_LO_THR,                   0x00005400 },
436
		{ AUD_CTL,                         0x0000100c },
437
		{ AUD_DCOC_0_SRC,                  0x00000021 },
438
		{ AUD_DCOC_1_SRC,                  0x00000003 },
439
		{ AUD_DCOC1_SHIFT,                 0x00000000 },
440
		{ AUD_DCOC_1_SHIFT_IN0,            0x0000000a },
441
		{ AUD_DCOC_1_SHIFT_IN1,            0x00000008 },
442
		{ AUD_DCOC_PASS_IN,                0x00000000 },
443
		{ AUD_DCOC_2_SRC,                  0x0000001b },
444
		{ AUD_IIR4_0_SEL,                  0x0000001d },
445
		{ AUD_POLY0_DDS_CONSTANT,          0x000e4db2 },
446
		{ AUD_PHASE_FIX_CTL,               0x00000000 },
447
		{ AUD_CORDIC_SHIFT_1,              0x00000007 },
448
		{ AUD_PLL_EN,                      0x00000000 },
449
		{ AUD_PLL_PRESCALE,                0x00000002 },
450
		{ AUD_PLL_INT,                     0x0000001e },
451
		{ AUD_OUT1_SHIFT,                  0x00000000 },
452
366
453
		{ /* end of list */ },
367
                { AUD_DEEMPHGAIN_R, 0x6680 },
454
	};
368
                { AUD_DEEMPHNUMER1_R, 0x353DE },
369
                { AUD_DEEMPHNUMER2_R, 0x1B1 },
370
                { AUD_DEEMPHDENOM1_R, 0x0F3D0 },
371
                { AUD_DEEMPHDENOM2_R, 0x0 },
372
                { AUD_FM_MODE_ENABLE, 0x7 },
373
                { AUD_POLYPH80SCALEFAC, 0x3 },
374
                { AUD_AFE_12DB_EN, 0x1 },
375
                { AAGC_GAIN, 0x0 },
376
                { AAGC_HYST, 0x18 },
377
                { AAGC_DEF, 0x20 },
378
                { AUD_DN0_FREQ, 0x0 },
379
                { AUD_POLY0_DDS_CONSTANT, 0x0E4DB2 },
380
                { AUD_DCOC_0_SRC, 0x21 },
381
                { AUD_IIR1_0_SEL, 0x0 },
382
                { AUD_IIR1_0_SHIFT, 0x7 },
383
                { AUD_IIR1_1_SEL, 0x2 },
384
                { AUD_IIR1_1_SHIFT, 0x0 },
385
                { AUD_DCOC_1_SRC, 0x3 },
386
                { AUD_DCOC1_SHIFT, 0x0 },
387
                { AUD_DCOC_PASS_IN, 0x0 },
388
                { AUD_IIR1_2_SEL, 0x23 },
389
                { AUD_IIR1_2_SHIFT, 0x0 },
390
                { AUD_IIR1_3_SEL, 0x4 },
391
                { AUD_IIR1_3_SHIFT, 0x7 },
392
                { AUD_IIR1_4_SEL, 0x5 },
393
                { AUD_IIR1_4_SHIFT, 0x7 },
394
                { AUD_IIR3_0_SEL, 0x7 },
395
                { AUD_IIR3_0_SHIFT, 0x0 },
396
                { AUD_DEEMPH0_SRC_SEL, 0x11 },
397
                { AUD_DEEMPH0_SHIFT, 0x0 },
398
                { AUD_DEEMPH0_G0, 0x7000 },
399
                { AUD_DEEMPH0_A0, 0x0 },
400
                { AUD_DEEMPH0_B0, 0x0 },
401
                { AUD_DEEMPH0_A1, 0x0 },
402
                { AUD_DEEMPH0_B1, 0x0 },
403
                { AUD_DEEMPH1_SRC_SEL, 0x11 },
404
                { AUD_DEEMPH1_SHIFT, 0x0 },
405
                { AUD_DEEMPH1_G0, 0x7000 },
406
                { AUD_DEEMPH1_A0, 0x0 },
407
                { AUD_DEEMPH1_B0, 0x0 },
408
                { AUD_DEEMPH1_A1, 0x0 },
409
                { AUD_DEEMPH1_B1, 0x0 },
410
                { AUD_OUT0_SEL, 0x3F },
411
                { AUD_OUT1_SEL, 0x3F },
412
                { AUD_DMD_RA_DDS, 0x0F5C285 },
413
                { AUD_PLL_INT, 0x1E },
414
                { AUD_PLL_DDS, 0x0 },
415
                { AUD_PLL_FRAC, 0x0E542 },
455
416
456
	dprintk("%s (status: unknown)\n",__FUNCTION__);
417
                // setup QAM registers
457
        set_audio_start(core, 0x0004,
418
                { AUD_RATE_ADJ1,      0x00000100 },
458
			0 /* FIXME */);
419
                { AUD_RATE_ADJ2,      0x00000200 },
459
	set_audio_registers(core, nicam_l);
420
                { AUD_RATE_ADJ3,      0x00000300 },
421
                { AUD_RATE_ADJ4,      0x00000400 },
422
                { AUD_RATE_ADJ5,      0x00000500 },
423
                { AUD_RATE_THRES_DMD, 0x000000C0 },
424
                { /* end of list */ },
425
        };
426
427
        static const struct rlist nicam_l[] = {
428
                // setup QAM registers
429
                { AUD_RATE_ADJ1, 0x00000060 },
430
                { AUD_RATE_ADJ2, 0x000000F9 },
431
                { AUD_RATE_ADJ3, 0x000001CC },
432
                { AUD_RATE_ADJ4, 0x000002B3 },
433
                { AUD_RATE_ADJ5, 0x00000726 },
434
                { AUD_DEEMPHDENOM1_R, 0x0000F3D0 },
435
                { AUD_DEEMPHDENOM2_R, 0x00000000 },
436
                { AUD_ERRLOGPERIOD_R, 0x00000064 },
437
                { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF },
438
                { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F },
439
                { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F },
440
                { AUD_POLYPH80SCALEFAC, 0x00000003 },
441
                { AUD_DMD_RA_DDS, 0x00C00000 },
442
                { AUD_PLL_INT, 0x0000001E },
443
                { AUD_PLL_DDS, 0x00000000 },
444
                { AUD_PLL_FRAC, 0x0000E542 },
445
                { AUD_START_TIMER, 0x00000000 },
446
                { AUD_DEEMPHNUMER1_R, 0x000353DE },
447
                { AUD_DEEMPHNUMER2_R, 0x000001B1 },
448
                { AUD_PDF_DDS_CNST_BYTE2, 0x06 },
449
                { AUD_PDF_DDS_CNST_BYTE1, 0x82 },
450
                { AUD_QAM_MODE, 0x05 },
451
                { AUD_PDF_DDS_CNST_BYTE0, 0x12 },
452
                { AUD_PHACC_FREQ_8MSB, 0x34 },
453
                { AUD_PHACC_FREQ_8LSB, 0x4C },
454
                { AUD_DEEMPHGAIN_R, 0x00006680 },
455
                { AUD_RATE_THRES_DMD, 0x000000C0  },
456
                { /* end of list */ },
457
        } ;
458
        dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo);
459
460
        if (!stereo) {
461
		/* AM mono sound */
462
                set_audio_start(core, 0x0004,
463
				0x100c /* FIXME again */);
464
                set_audio_registers(core, nicam_l_mono);
465
        } else {
466
                set_audio_start(core, 0x0010,
467
				0x1924 /* FIXME again */);
468
                set_audio_registers(core, nicam_l);
469
        }
470
        set_audio_finish(core);
471
472
}
473
474
static void set_audio_standard_PAL_I(struct cx88_core *core, int stereo)
475
{
476
       static const struct rlist pal_i_fm_mono[] = {
477
            {AUD_ERRLOGPERIOD_R,       0x00000064},
478
            {AUD_ERRINTRPTTHSHLD1_R,   0x00000fff},
479
            {AUD_ERRINTRPTTHSHLD2_R,   0x0000001f},
480
            {AUD_ERRINTRPTTHSHLD3_R,   0x0000000f},
481
            {AUD_PDF_DDS_CNST_BYTE2,   0x06},
482
            {AUD_PDF_DDS_CNST_BYTE1,   0x82},
483
            {AUD_PDF_DDS_CNST_BYTE0,   0x12},
484
            {AUD_QAM_MODE,             0x05},
485
            {AUD_PHACC_FREQ_8MSB,      0x3a},
486
            {AUD_PHACC_FREQ_8LSB,      0x93},
487
            {AUD_DMD_RA_DDS,           0x002a4f2f},
488
            {AUD_PLL_INT,              0x0000001e},
489
            {AUD_PLL_DDS,              0x00000004},
490
            {AUD_PLL_FRAC,             0x0000e542},
491
            {AUD_RATE_ADJ1,            0x00000100},
492
            {AUD_RATE_ADJ2,            0x00000200},
493
            {AUD_RATE_ADJ3,            0x00000300},
494
            {AUD_RATE_ADJ4,            0x00000400},
495
            {AUD_RATE_ADJ5,            0x00000500},
496
            {AUD_THR_FR,               0x00000000},
497
            {AUD_PILOT_BQD_1_K0,       0x0000755b},
498
            {AUD_PILOT_BQD_1_K1,       0x00551340},
499
            {AUD_PILOT_BQD_1_K2,       0x006d30be},
500
            {AUD_PILOT_BQD_1_K3,       0xffd394af},
501
            {AUD_PILOT_BQD_1_K4,       0x00400000},
502
            {AUD_PILOT_BQD_2_K0,       0x00040000},
503
            {AUD_PILOT_BQD_2_K1,       0x002a4841},
504
            {AUD_PILOT_BQD_2_K2,       0x00400000},
505
            {AUD_PILOT_BQD_2_K3,       0x00000000},
506
            {AUD_PILOT_BQD_2_K4,       0x00000000},
507
            {AUD_MODE_CHG_TIMER,       0x00000060},
508
            {AUD_AFE_12DB_EN,          0x00000001},
509
            {AAGC_HYST,                0x0000000a},
510
            {AUD_CORDIC_SHIFT_0,       0x00000007},
511
            {AUD_CORDIC_SHIFT_1,       0x00000007},
512
            {AUD_C1_UP_THR,            0x00007000},
513
            {AUD_C1_LO_THR,            0x00005400},
514
            {AUD_C2_UP_THR,            0x00005400},
515
            {AUD_C2_LO_THR,            0x00003000},
516
            {AUD_DCOC_0_SRC,           0x0000001a},
517
            {AUD_DCOC0_SHIFT,          0x00000000},
518
            {AUD_DCOC_0_SHIFT_IN0,     0x0000000a},
519
            {AUD_DCOC_0_SHIFT_IN1,     0x00000008},
520
            {AUD_DCOC_PASS_IN,         0x00000003},
521
            {AUD_IIR3_0_SEL,           0x00000021},
522
            {AUD_DN2_AFC,              0x00000002},
523
            {AUD_DCOC_1_SRC,           0x0000001b},
524
            {AUD_DCOC1_SHIFT,          0x00000000},
525
            {AUD_DCOC_1_SHIFT_IN0,     0x0000000a},
526
            {AUD_DCOC_1_SHIFT_IN1,     0x00000008},
527
            {AUD_IIR3_1_SEL,           0x00000023},
528
            {AUD_DN0_FREQ,             0x000035a3},
529
            {AUD_DN2_FREQ,             0x000029c7},
530
            {AUD_CRDC0_SRC_SEL,        0x00000511},
531
            {AUD_IIR1_0_SEL,           0x00000001},
532
            {AUD_IIR1_1_SEL,           0x00000000},
533
            {AUD_IIR3_2_SEL,           0x00000003},
534
            {AUD_IIR3_2_SHIFT,         0x00000000},
535
            {AUD_IIR3_0_SEL,           0x00000002},
536
            {AUD_IIR2_0_SEL,           0x00000021},
537
            {AUD_IIR2_0_SHIFT,         0x00000002},
538
            {AUD_DEEMPH0_SRC_SEL,      0x0000000b},
539
            {AUD_DEEMPH1_SRC_SEL,      0x0000000b},
540
            {AUD_POLYPH80SCALEFAC,     0x00000001},
541
            {AUD_START_TIMER,          0x00000000},
542
            { /* end of list */ },
543
       };
544
545
       static const struct rlist pal_i_nicam[] = {
546
           { AUD_RATE_ADJ1,           0x00000010 },
547
           { AUD_RATE_ADJ2,           0x00000040 },
548
           { AUD_RATE_ADJ3,           0x00000100 },
549
           { AUD_RATE_ADJ4,           0x00000400 },
550
           { AUD_RATE_ADJ5,           0x00001000 },
551
	   //     { AUD_DMD_RA_DDS,          0x00c0d5ce },
552
	   { AUD_DEEMPHGAIN_R,        0x000023c2 },
553
	   { AUD_DEEMPHNUMER1_R,      0x0002a7bc },
554
	   { AUD_DEEMPHNUMER2_R,      0x0003023e },
555
	   { AUD_DEEMPHDENOM1_R,      0x0000f3d0 },
556
	   { AUD_DEEMPHDENOM2_R,      0x00000000 },
557
	   { AUD_DEEMPHDENOM2_R,      0x00000000 },
558
	   { AUD_ERRLOGPERIOD_R,      0x00000fff },
559
	   { AUD_ERRINTRPTTHSHLD1_R,  0x000003ff },
560
	   { AUD_ERRINTRPTTHSHLD2_R,  0x000000ff },
561
	   { AUD_ERRINTRPTTHSHLD3_R,  0x0000003f },
562
	   { AUD_POLYPH80SCALEFAC,    0x00000003 },
563
	   { AUD_PDF_DDS_CNST_BYTE2,  0x06 },
564
	   { AUD_PDF_DDS_CNST_BYTE1,  0x82 },
565
	   { AUD_PDF_DDS_CNST_BYTE0,  0x16 },
566
	   { AUD_QAM_MODE,            0x05 },
567
	   { AUD_PDF_DDS_CNST_BYTE0,  0x12 },
568
	   { AUD_PHACC_FREQ_8MSB,     0x3a },
569
	   { AUD_PHACC_FREQ_8LSB,     0x93 },
570
            { /* end of list */ },
571
        };
572
573
        dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo);
574
575
        if (!stereo) {
576
		// FM mono
577
		set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_FORCE_MONO1);
578
		set_audio_registers(core, pal_i_fm_mono);
579
        } else {
580
		// Nicam Stereo
581
		set_audio_start(core, 0x0010, EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO);
582
		set_audio_registers(core, pal_i_nicam);
583
        }
460
        set_audio_finish(core);
584
        set_audio_finish(core);
461
}
585
}
462
586
Lines 553-565 static void set_audio_standard_A2(struct Link Here
553
	set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_AUTO_STEREO);
677
	set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_AUTO_STEREO);
554
	set_audio_registers(core, a2_common);
678
	set_audio_registers(core, a2_common);
555
	switch (core->tvaudio) {
679
	switch (core->tvaudio) {
556
	case WW_NICAM_I:
557
		/* gives at least mono according to the dscaler guys */
558
		/* so use use that while nicam is broken ...         */
559
		dprintk("%s PAL-I mono (status: unknown)\n",__FUNCTION__);
560
		set_audio_registers(core, a2_table1);
561
		cx_write(AUD_CTL, EN_A2_FORCE_MONO1);
562
		break;
563
	case WW_A2_BG:
680
	case WW_A2_BG:
564
		dprintk("%s PAL-BG A2 (status: known-good)\n",__FUNCTION__);
681
		dprintk("%s PAL-BG A2 (status: known-good)\n",__FUNCTION__);
565
		set_audio_registers(core, a2_table1);
682
		set_audio_registers(core, a2_table1);
Lines 646-656 void cx88_set_tvaudio(struct cx88_core * Link Here
646
	case WW_BTSC:
763
	case WW_BTSC:
647
		set_audio_standard_BTSC(core,0);
764
		set_audio_standard_BTSC(core,0);
648
		break;
765
		break;
649
	// case WW_NICAM_I:
650
	case WW_NICAM_BGDKL:
766
	case WW_NICAM_BGDKL:
651
		set_audio_standard_NICAM(core);
767
		set_audio_standard_NICAM_L(core,0);
652
		break;
768
		break;
653
	case WW_NICAM_I:
769
	case WW_NICAM_I:
770
		set_audio_standard_PAL_I(core,0);
771
		break;
654
	case WW_A2_BG:
772
	case WW_A2_BG:
655
	case WW_A2_DK:
773
	case WW_A2_DK:
656
	case WW_A2_M:
774
	case WW_A2_M:
Lines 663-669 void cx88_set_tvaudio(struct cx88_core * Link Here
663
		set_audio_standard_FM(core);
781
		set_audio_standard_FM(core);
664
		break;
782
		break;
665
	case WW_SYSTEM_L_AM:
783
	case WW_SYSTEM_L_AM:
666
		set_audio_standard_NICAM_L(core);
784
		set_audio_standard_NICAM_L(core, 1);
667
		break;
785
		break;
668
	case WW_NONE:
786
	case WW_NONE:
669
	default:
787
	default:
Lines 674-679 void cx88_set_tvaudio(struct cx88_core * Link Here
674
	return;
792
	return;
675
}
793
}
676
794
795
void cx88_newstation(struct cx88_core *core)
796
{
797
	core->audiomode_manual = UNSET;
798
	
799
	switch (core->tvaudio) {
800
	case WW_SYSTEM_L_AM:
801
		/* try nicam ... */
802
		core->audiomode_current = V4L2_TUNER_MODE_STEREO;
803
		set_audio_standard_NICAM_L(core, 1);
804
		break;
805
	}
806
}
807
677
void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
808
void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t)
678
{
809
{
679
	static char *m[] = {"stereo", "dual mono", "mono", "sap"};
810
	static char *m[] = {"stereo", "dual mono", "mono", "sap"};
Lines 721-742 void cx88_get_stereo(struct cx88_core *c Link Here
721
		}
852
		}
722
		break;
853
		break;
723
	case WW_NICAM_BGDKL:
854
	case WW_NICAM_BGDKL:
724
		if (0 == mode)
855
		if (0 == mode) {
725
			t->audmode = V4L2_TUNER_MODE_STEREO;
856
			t->audmode = V4L2_TUNER_MODE_STEREO;
857
			t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
858
		}
726
		break;
859
		break;
860
        case WW_SYSTEM_L_AM:
861
                if (0x0 == mode && !(cx_read(AUD_INIT) & 0x04)) {
862
                        t->audmode = V4L2_TUNER_MODE_STEREO;
863
			t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
864
		}
865
                break ;
727
	default:
866
	default:
728
		t->rxsubchans = V4L2_TUNER_SUB_MONO;
867
		/* nothing */
729
		t->audmode    = V4L2_TUNER_MODE_MONO;
730
		break;
868
		break;
731
	}
869
	}
732
	return;
870
	return;
733
}
871
}
734
872
735
void cx88_set_stereo(struct cx88_core *core, u32 mode)
873
void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
736
{
874
{
737
	u32 ctl  = UNSET;
875
	u32 ctl  = UNSET;
738
	u32 mask = UNSET;
876
	u32 mask = UNSET;
739
877
878
	if (manual) {
879
		core->audiomode_manual = mode;
880
	} else {
881
		if (UNSET != core->audiomode_manual)
882
			return;
883
	}
884
	core->audiomode_current = mode;
885
740
	switch (core->tvaudio) {
886
	switch (core->tvaudio) {
741
	case WW_BTSC:
887
	case WW_BTSC:
742
		switch (mode) {
888
		switch (mode) {
Lines 789-794 void cx88_set_stereo(struct cx88_core *c Link Here
789
			break;
935
			break;
790
		}
936
		}
791
		break;
937
		break;
938
	case WW_SYSTEM_L_AM:
939
		switch (mode) {
940
		case V4L2_TUNER_MODE_MONO:
941
		case V4L2_TUNER_MODE_LANG1:  /* FIXME */
942
			set_audio_standard_NICAM_L(core, 0);
943
			break;
944
		case V4L2_TUNER_MODE_STEREO:
945
			set_audio_standard_NICAM_L(core, 1);
946
			break;
947
		}
948
		break;
949
	case WW_NICAM_I:
950
		switch (mode) {
951
		case V4L2_TUNER_MODE_MONO:
952
		case V4L2_TUNER_MODE_LANG1:
953
			set_audio_standard_PAL_I(core, 0);
954
			break;
955
		case V4L2_TUNER_MODE_STEREO:
956
			set_audio_standard_PAL_I(core, 1);
957
			break;
958
		}
959
		break;
792
	case WW_FM:
960
	case WW_FM:
793
		switch (mode) {
961
		switch (mode) {
794
		case V4L2_TUNER_MODE_MONO:
962
		case V4L2_TUNER_MODE_MONO:
Lines 804-816 void cx88_set_stereo(struct cx88_core *c Link Here
804
	}
972
	}
805
973
806
	if (UNSET != ctl) {
974
	if (UNSET != ctl) {
807
		cx_write(AUD_SOFT_RESET, 0x0001);
808
		cx_andor(AUD_CTL, mask,  ctl);
809
		cx_write(AUD_SOFT_RESET, 0x0000);
810
		dprintk("cx88_set_stereo: mask 0x%x, ctl 0x%x "
975
		dprintk("cx88_set_stereo: mask 0x%x, ctl 0x%x "
811
			"[status=0x%x,ctl=0x%x,vol=0x%x]\n",
976
			"[status=0x%x,ctl=0x%x,vol=0x%x]\n",
812
			mask, ctl, cx_read(AUD_STATUS),
977
			mask, ctl, cx_read(AUD_STATUS),
813
			cx_read(AUD_CTL), cx_sread(SHADOW_AUD_VOL_CTL));
978
			cx_read(AUD_CTL), cx_sread(SHADOW_AUD_VOL_CTL));
979
		cx_andor(AUD_CTL, mask, ctl);
814
	}
980
	}
815
	return;
981
	return;
816
}
982
}
Lines 819-834 int cx88_audio_thread(void *data) Link Here
819
{
985
{
820
	struct cx88_core *core = data;
986
	struct cx88_core *core = data;
821
	struct v4l2_tuner t;
987
	struct v4l2_tuner t;
988
	u32 mode = 0;
822
989
823
	dprintk("cx88: tvaudio thread started\n");
990
	dprintk("cx88: tvaudio thread started\n");
824
	for (;;) {
991
	for (;;) {
992
		msleep_interruptible(1000);
825
		if (kthread_should_stop())
993
		if (kthread_should_stop())
826
			break;
994
			break;
827
995
828
		/* just monitor the audio status for now ... */
996
		/* just monitor the audio status for now ... */
829
		memset(&t,0,sizeof(t));
997
		memset(&t,0,sizeof(t));
830
		cx88_get_stereo(core,&t);
998
		cx88_get_stereo(core,&t);
831
		msleep_interruptible(1000);
999
1000
		if (UNSET != core->audiomode_manual)
1001
			/* manually set, don't do anything. */
1002
			continue;
1003
1004
		/* monitor signal */
1005
		if (t.rxsubchans & V4L2_TUNER_SUB_STEREO)
1006
			mode = V4L2_TUNER_MODE_STEREO;
1007
		else
1008
			mode = V4L2_TUNER_MODE_MONO;
1009
		if (mode == core->audiomode_current)
1010
			continue;
1011
1012
		/* automatically switch to best available mode */
1013
		cx88_set_stereo(core, mode, 0);
832
	}
1014
	}
833
1015
834
	dprintk("cx88: tvaudio thread exiting\n");
1016
	dprintk("cx88: tvaudio thread exiting\n");
Lines 838-843 int cx88_audio_thread(void *data) Link Here
838
/* ----------------------------------------------------------- */
1020
/* ----------------------------------------------------------- */
839
1021
840
EXPORT_SYMBOL(cx88_set_tvaudio);
1022
EXPORT_SYMBOL(cx88_set_tvaudio);
1023
EXPORT_SYMBOL(cx88_newstation);
841
EXPORT_SYMBOL(cx88_set_stereo);
1024
EXPORT_SYMBOL(cx88_set_stereo);
842
EXPORT_SYMBOL(cx88_get_stereo);
1025
EXPORT_SYMBOL(cx88_get_stereo);
843
EXPORT_SYMBOL(cx88_audio_thread);
1026
EXPORT_SYMBOL(cx88_audio_thread);
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88-vbi.c (-2 / +3 lines)
Lines 1-8 Link Here
1
/*
1
/*
2
 * $Id: cx88-vbi.c,v 1.14 2004/11/07 13:17:15 kraxel Exp $
2
 * $Id: cx88-vbi.c,v 1.16 2004/12/10 12:33:39 kraxel Exp $
3
 */
3
 */
4
#include <linux/kernel.h>
4
#include <linux/kernel.h>
5
#include <linux/module.h>
5
#include <linux/module.h>
6
#include <linux/moduleparam.h>
6
#include <linux/init.h>
7
#include <linux/init.h>
7
#include <linux/slab.h>
8
#include <linux/slab.h>
8
9
Lines 64-70 int cx8800_start_vbi_dma(struct cx8800_d Link Here
64
	q->count = 1;
65
	q->count = 1;
65
66
66
	/* enable irqs */
67
	/* enable irqs */
67
	cx_set(MO_PCI_INTMSK, 0x00fc01);
68
	cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x01);
68
	cx_set(MO_VID_INTMSK, 0x0f0088);
69
	cx_set(MO_VID_INTMSK, 0x0f0088);
69
70
70
	/* enable capture */
71
	/* enable capture */
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88-video.c (-16 / +20 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: cx88-video.c,v 1.46 2004/11/07 14:44:59 kraxel Exp $
2
 * $Id: cx88-video.c,v 1.58 2005/03/07 15:58:05 kraxel Exp $
3
 *
3
 *
4
 * device driver for Conexant 2388x based TV cards
4
 * device driver for Conexant 2388x based TV cards
5
 * video4linux video interface
5
 * video4linux video interface
Lines 24-29 Link Here
24
#include <linux/init.h>
24
#include <linux/init.h>
25
#include <linux/list.h>
25
#include <linux/list.h>
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/moduleparam.h>
27
#include <linux/kmod.h>
28
#include <linux/kmod.h>
28
#include <linux/kernel.h>
29
#include <linux/kernel.h>
29
#include <linux/slab.h>
30
#include <linux/slab.h>
Lines 428-434 static int start_video_dma(struct cx8800 Link Here
428
	q->count = 1;
429
	q->count = 1;
429
430
430
	/* enable irqs */
431
	/* enable irqs */
431
	cx_set(MO_PCI_INTMSK, 0x00fc01);
432
	cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x01);
432
	cx_set(MO_VID_INTMSK, 0x0f0011);
433
	cx_set(MO_VID_INTMSK, 0x0f0011);
433
434
434
	/* enable capture */
435
	/* enable capture */
Lines 994-1000 static int video_open(struct inode *inod Link Here
994
		cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3);
995
		cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3);
995
		dev->core->tvaudio = WW_FM;
996
		dev->core->tvaudio = WW_FM;
996
		cx88_set_tvaudio(core);
997
		cx88_set_tvaudio(core);
997
		cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO);
998
		cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1);
998
		cx88_call_i2c_clients(dev->core,AUDC_SET_RADIO,NULL);
999
		cx88_call_i2c_clients(dev->core,AUDC_SET_RADIO,NULL);
999
	}
1000
	}
1000
1001
Lines 1002-1008 static int video_open(struct inode *inod Link Here
1002
}
1003
}
1003
1004
1004
static ssize_t
1005
static ssize_t
1005
video_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
1006
video_read(struct file *file, char *data, size_t count, loff_t *ppos)
1006
{
1007
{
1007
	struct cx8800_fh *fh = file->private_data;
1008
	struct cx8800_fh *fh = file->private_data;
1008
1009
Lines 1083-1088 static int video_release(struct inode *i Link Here
1083
		res_free(dev,fh,RESOURCE_VBI);
1084
		res_free(dev,fh,RESOURCE_VBI);
1084
	}
1085
	}
1085
1086
1087
	videobuf_mmap_free(&fh->vidq);
1088
	videobuf_mmap_free(&fh->vbiq);
1086
	file->private_data = NULL;
1089
	file->private_data = NULL;
1087
	kfree(fh);
1090
	kfree(fh);
1088
	return 0;
1091
	return 0;
Lines 1338-1344 static int video_do_ioctl(struct inode * Link Here
1338
			0;
1341
			0;
1339
		if (UNSET != core->tuner_type)
1342
		if (UNSET != core->tuner_type)
1340
			cap->capabilities |= V4L2_CAP_TUNER;
1343
			cap->capabilities |= V4L2_CAP_TUNER;
1341
1342
		return 0;
1344
		return 0;
1343
	}
1345
	}
1344
1346
Lines 1429-1434 static int video_do_ioctl(struct inode * Link Here
1429
		if (*i >= 4)
1431
		if (*i >= 4)
1430
			return -EINVAL;
1432
			return -EINVAL;
1431
		down(&dev->lock);
1433
		down(&dev->lock);
1434
		cx88_newstation(core);
1432
		video_mux(dev,*i);
1435
		video_mux(dev,*i);
1433
		up(&dev->lock);
1436
		up(&dev->lock);
1434
		return 0;
1437
		return 0;
Lines 1560-1566 static int video_do_ioctl(struct inode * Link Here
1560
			return -EINVAL;
1563
			return -EINVAL;
1561
		if (0 != t->index)
1564
		if (0 != t->index)
1562
			return -EINVAL;
1565
			return -EINVAL;
1563
		cx88_set_stereo(core, t->audmode);
1566
		cx88_set_stereo(core, t->audmode, 1);
1564
		return 0;
1567
		return 0;
1565
	}
1568
	}
1566
	case VIDIOC_G_FREQUENCY:
1569
	case VIDIOC_G_FREQUENCY:
Lines 1590-1595 static int video_do_ioctl(struct inode * Link Here
1590
			return -EINVAL;
1593
			return -EINVAL;
1591
		down(&dev->lock);
1594
		down(&dev->lock);
1592
		dev->freq = f->frequency;
1595
		dev->freq = f->frequency;
1596
		cx88_newstation(core);
1593
#ifdef V4L2_I2C_CLIENTS
1597
#ifdef V4L2_I2C_CLIENTS
1594
		cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f);
1598
		cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f);
1595
#else
1599
#else
Lines 1880-1898 static irqreturn_t cx8800_irq(int irq, v Link Here
1880
{
1884
{
1881
	struct cx8800_dev *dev = dev_id;
1885
	struct cx8800_dev *dev = dev_id;
1882
	struct cx88_core *core = dev->core;
1886
	struct cx88_core *core = dev->core;
1883
	u32 status, mask;
1887
	u32 status;
1884
	int loop, handled = 0;
1888
	int loop, handled = 0;
1885
1889
1886
	for (loop = 0; loop < 10; loop++) {
1890
	for (loop = 0; loop < 10; loop++) {
1887
		status = cx_read(MO_PCI_INTSTAT) & (~0x1f | 0x01);
1891
		status = cx_read(MO_PCI_INTSTAT) & (core->pci_irqmask | 0x01);
1888
		mask   = cx_read(MO_PCI_INTMSK);
1892
		if (0 == status)
1889
		if (0 == (status & mask))
1890
			goto out;
1893
			goto out;
1891
		cx_write(MO_PCI_INTSTAT, status);
1894
		cx_write(MO_PCI_INTSTAT, status);
1892
		handled = 1;
1895
		handled = 1;
1893
1896
1894
		if (status & mask & ~0x1f)
1897
		if (status & core->pci_irqmask)
1895
			cx88_irq(core,status,mask);
1898
			cx88_core_irq(core,status);
1896
		if (status & 0x01)
1899
		if (status & 0x01)
1897
			cx8800_vid_irq(dev);
1900
			cx8800_vid_irq(dev);
1898
	};
1901
	};
Lines 2055-2060 static int __devinit cx8800_initdev(stru Link Here
2055
		       core->name,pci_dev->irq);
2058
		       core->name,pci_dev->irq);
2056
		goto fail_core;
2059
		goto fail_core;
2057
	}
2060
	}
2061
	cx_set(MO_PCI_INTMSK, core->pci_irqmask);
2058
2062
2059
	/* load and configure helper modules */
2063
	/* load and configure helper modules */
2060
	if (TUNER_ABSENT != core->tuner_type)
2064
	if (TUNER_ABSENT != core->tuner_type)
Lines 2156-2162 static void __devexit cx8800_finidev(str Link Here
2156
	kfree(dev);
2160
	kfree(dev);
2157
}
2161
}
2158
2162
2159
static int cx8800_suspend(struct pci_dev *pci_dev, u32 state)
2163
static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
2160
{
2164
{
2161
        struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
2165
        struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
2162
	struct cx88_core *core = dev->core;
2166
	struct cx88_core *core = dev->core;
Lines 2181-2187 static int cx8800_suspend(struct pci_dev Link Here
2181
#endif
2185
#endif
2182
2186
2183
	pci_save_state(pci_dev);
2187
	pci_save_state(pci_dev);
2184
	if (0 != pci_set_power_state(pci_dev, state)) {
2188
	if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
2185
		pci_disable_device(pci_dev);
2189
		pci_disable_device(pci_dev);
2186
		dev->state.disabled = 1;
2190
		dev->state.disabled = 1;
2187
	}
2191
	}
Lines 2197-2203 static int cx8800_resume(struct pci_dev Link Here
2197
		pci_enable_device(pci_dev);
2201
		pci_enable_device(pci_dev);
2198
		dev->state.disabled = 0;
2202
		dev->state.disabled = 0;
2199
	}
2203
	}
2200
	pci_set_power_state(pci_dev, 0);
2204
	pci_set_power_state(pci_dev, PCI_D0);
2201
	pci_restore_state(pci_dev);
2205
	pci_restore_state(pci_dev);
2202
2206
2203
#if 1
2207
#if 1
Lines 2254-2260 static int cx8800_init(void) Link Here
2254
	printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
2258
	printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
2255
	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
2259
	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
2256
#endif
2260
#endif
2257
	return pci_module_init(&cx8800_pci_driver);
2261
	return pci_register_driver(&cx8800_pci_driver);
2258
}
2262
}
2259
2263
2260
static void cx8800_fini(void)
2264
static void cx8800_fini(void)
(-)linux-2.6.11.orig/drivers/media/video/cx88/cx88.h (-7 / +31 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: cx88.h,v 1.40 2004/11/03 09:04:51 kraxel Exp $
2
 * $Id: cx88.h,v 1.56 2005/03/04 09:12:23 kraxel Exp $
3
 *
3
 *
4
 * v4l2 device driver for cx2388x based TV cards
4
 * v4l2 device driver for cx2388x based TV cards
5
 *
5
 *
Lines 27-32 Link Here
27
#include <linux/kdev_t.h>
27
#include <linux/kdev_t.h>
28
28
29
#include <media/tuner.h>
29
#include <media/tuner.h>
30
#include <media/tveeprom.h>
30
#include <media/audiochip.h>
31
#include <media/audiochip.h>
31
#include <media/video-buf.h>
32
#include <media/video-buf.h>
32
#include <media/video-buf-dvb.h>
33
#include <media/video-buf-dvb.h>
Lines 139-145 extern struct sram_channel cx88_sram_cha Link Here
139
#define CX88_BOARD_GDI                      2
140
#define CX88_BOARD_GDI                      2
140
#define CX88_BOARD_PIXELVIEW                3
141
#define CX88_BOARD_PIXELVIEW                3
141
#define CX88_BOARD_ATI_WONDER_PRO           4
142
#define CX88_BOARD_ATI_WONDER_PRO           4
142
#define CX88_BOARD_WINFAST2000XP            5
143
#define CX88_BOARD_WINFAST2000XP_EXPERT     5
143
#define CX88_BOARD_AVERTV_303               6
144
#define CX88_BOARD_AVERTV_303               6
144
#define CX88_BOARD_MSI_TVANYWHERE_MASTER    7
145
#define CX88_BOARD_MSI_TVANYWHERE_MASTER    7
145
#define CX88_BOARD_WINFAST_DV2000           8
146
#define CX88_BOARD_WINFAST_DV2000           8
Lines 156-161 extern struct sram_channel cx88_sram_cha Link Here
156
#define CX88_BOARD_CONEXANT_DVB_T1         19
157
#define CX88_BOARD_CONEXANT_DVB_T1         19
157
#define CX88_BOARD_PROVIDEO_PV259          20
158
#define CX88_BOARD_PROVIDEO_PV259          20
158
#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS 21
159
#define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS 21
160
#define CX88_BOARD_PCHDTV_HD3000           22
161
#define CX88_BOARD_DNTV_LIVE_DVB_T         23
162
#define CX88_BOARD_HAUPPAUGE_ROSLYN        24
163
#define CX88_BOARD_DIGITALLOGIC_MEC	       25
164
#define CX88_BOARD_IODATA_GVBCTV7E         26
159
165
160
enum cx88_itype {
166
enum cx88_itype {
161
	CX88_VMUX_COMPOSITE1 = 1,
167
	CX88_VMUX_COMPOSITE1 = 1,
Lines 238-243 struct cx88_core { Link Here
238
        u32                        __iomem *lmmio;
244
        u32                        __iomem *lmmio;
239
        u8                         __iomem *bmmio;
245
        u8                         __iomem *bmmio;
240
	u32                        shadow[SHADOW_MAX];
246
	u32                        shadow[SHADOW_MAX];
247
	int                        pci_irqmask;
241
248
242
	/* i2c i/o */
249
	/* i2c i/o */
243
	struct i2c_adapter         i2c_adap;
250
	struct i2c_adapter         i2c_adap;
Lines 252-267 struct cx88_core { Link Here
252
	unsigned int               has_radio;
259
	unsigned int               has_radio;
253
260
254
	/* config info -- dvb */
261
	/* config info -- dvb */
255
	unsigned int               pll_type;
262
	struct dvb_pll_desc        *pll_desc;
256
	unsigned int               pll_addr;
263
	unsigned int               pll_addr;
257
	unsigned int               demod_addr;
258
264
259
	/* state info */
265
	/* state info */
260
	struct task_struct         *kthread;
266
	struct task_struct         *kthread;
261
	struct cx88_tvnorm         *tvnorm;
267
	struct cx88_tvnorm         *tvnorm;
262
	u32                        tvaudio;
268
	u32                        tvaudio;
269
	u32                        audiomode_manual;
270
	u32                        audiomode_current;
263
	u32                        input;
271
	u32                        input;
264
	u32                        astat;
272
	u32                        astat;
273
274
	/* IR remote control state */
275
	struct cx88_IR             *ir;
265
};
276
};
266
277
267
struct cx8800_dev;
278
struct cx8800_dev;
Lines 371-381 struct cx8802_dev { Link Here
371
	struct list_head           devlist;
382
	struct list_head           devlist;
372
	struct video_device        *mpeg_dev;
383
	struct video_device        *mpeg_dev;
373
	u32                        mailbox;
384
	u32                        mailbox;
385
	int                        width;
386
	int                        height;
374
387
375
	/* for dvb only */
388
	/* for dvb only */
376
	struct videobuf_dvb        dvb;
389
	struct videobuf_dvb        dvb;
377
	void*                      fe_handle;
390
	void*                      fe_handle;
378
	int                        (*fe_release)(void *handle);
391
	int                        (*fe_release)(void *handle);
392
393
	/* for switching modulation types */
394
	unsigned char              ts_gen_cntrl;
379
};
395
};
380
396
381
/* ----------------------------------------------------------- */
397
/* ----------------------------------------------------------- */
Lines 411-417 extern void cx88_print_irqbits(char *nam Link Here
411
			       u32 bits, u32 mask);
427
			       u32 bits, u32 mask);
412
extern void cx88_print_ioctl(char *name, unsigned int cmd);
428
extern void cx88_print_ioctl(char *name, unsigned int cmd);
413
429
414
extern void cx88_irq(struct cx88_core *core, u32 status, u32 mask);
430
extern int cx88_core_irq(struct cx88_core *core, u32 status);
415
extern void cx88_wakeup(struct cx88_core *core,
431
extern void cx88_wakeup(struct cx88_core *core,
416
			struct cx88_dmaqueue *q, u32 count);
432
			struct cx88_dmaqueue *q, u32 count);
417
extern void cx88_shutdown(struct cx88_core *core);
433
extern void cx88_shutdown(struct cx88_core *core);
Lines 503-513 extern void cx88_card_setup(struct cx88_ Link Here
503
#define WW_FM		12
519
#define WW_FM		12
504
520
505
void cx88_set_tvaudio(struct cx88_core *core);
521
void cx88_set_tvaudio(struct cx88_core *core);
522
void cx88_newstation(struct cx88_core *core);
506
void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t);
523
void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t);
507
void cx88_set_stereo(struct cx88_core *core, u32 mode);
524
void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual);
508
int cx88_audio_thread(void *data);
525
int cx88_audio_thread(void *data);
509
526
510
/* ----------------------------------------------------------- */
527
/* ----------------------------------------------------------- */
528
/* cx88-input.c                                                */
529
530
int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci);
531
int cx88_ir_fini(struct cx88_core *core);
532
void cx88_ir_irq(struct cx88_core *core);
533
534
/* ----------------------------------------------------------- */
511
/* cx88-mpeg.c                                                 */
535
/* cx88-mpeg.c                                                 */
512
536
513
int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf);
537
int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf);
Lines 517-523 void cx8802_cancel_buffers(struct cx8802 Link Here
517
int cx8802_init_common(struct cx8802_dev *dev);
541
int cx8802_init_common(struct cx8802_dev *dev);
518
void cx8802_fini_common(struct cx8802_dev *dev);
542
void cx8802_fini_common(struct cx8802_dev *dev);
519
543
520
int cx8802_suspend_common(struct pci_dev *pci_dev, u32 state);
544
int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state);
521
int cx8802_resume_common(struct pci_dev *pci_dev);
545
int cx8802_resume_common(struct pci_dev *pci_dev);
522
546
523
/*
547
/*
(-)linux-2.6.11.orig/drivers/media/video/ir-kbd-gpio.c (-48 / +3 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: ir-kbd-gpio.c,v 1.11 2004/10/25 11:26:36 kraxel Exp $
2
 * $Id: ir-kbd-gpio.c,v 1.12 2005/02/22 12:28:40 kraxel Exp $
3
 *
3
 *
4
 * Copyright (c) 2003 Gerd Knorr
4
 * Copyright (c) 2003 Gerd Knorr
5
 * Copyright (c) 2003 Pavel Machek
5
 * Copyright (c) 2003 Pavel Machek
Lines 114-164 static IR_KEYTAB_TYPE ir_codes_avermedia Link Here
114
	[ 0x3e ] = KEY_VOLUMEUP,    // 'volume +'
114
	[ 0x3e ] = KEY_VOLUMEUP,    // 'volume +'
115
};
115
};
116
116
117
static IR_KEYTAB_TYPE winfast_codes[IR_KEYTAB_SIZE] = {
118
	[  5 ] = KEY_KP1,
119
	[  6 ] = KEY_KP2,
120
	[  7 ] = KEY_KP3,
121
	[  9 ] = KEY_KP4,
122
	[ 10 ] = KEY_KP5,
123
	[ 11 ] = KEY_KP6,
124
	[ 13 ] = KEY_KP7,
125
	[ 14 ] = KEY_KP8,
126
	[ 15 ] = KEY_KP9,
127
	[ 18 ] = KEY_KP0,
128
129
	[  0 ] = KEY_POWER,
130
//      [ 27 ] = MTS button
131
	[  2 ] = KEY_TUNER,     // TV/FM
132
	[ 30 ] = KEY_VIDEO,
133
//      [ 22 ] = display button
134
	[  4 ] = KEY_VOLUMEUP,
135
	[  8 ] = KEY_VOLUMEDOWN,
136
	[ 12 ] = KEY_CHANNELUP,
137
	[ 16 ] = KEY_CHANNELDOWN,
138
	[  3 ] = KEY_ZOOM,      // fullscreen
139
	[ 31 ] = KEY_SUBTITLE,  // closed caption/teletext
140
	[ 32 ] = KEY_SLEEP,
141
//      [ 41 ] = boss key
142
	[ 20 ] = KEY_MUTE,
143
	[ 43 ] = KEY_RED,
144
	[ 44 ] = KEY_GREEN,
145
	[ 45 ] = KEY_YELLOW,
146
	[ 46 ] = KEY_BLUE,
147
	[ 24 ] = KEY_KPPLUS,    //fine tune +
148
	[ 25 ] = KEY_KPMINUS,   //fine tune -
149
//      [ 42 ] = picture in picture
150
        [ 33 ] = KEY_KPDOT,
151
	[ 19 ] = KEY_KPENTER,
152
//      [ 17 ] = recall
153
	[ 34 ] = KEY_BACK,
154
	[ 35 ] = KEY_PLAYPAUSE,
155
	[ 36 ] = KEY_NEXT,
156
//      [ 37 ] = time shifting
157
	[ 38 ] = KEY_STOP,
158
	[ 39 ] = KEY_RECORD
159
//      [ 40 ] = snapshot
160
};
161
162
static IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = {
117
static IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = {
163
	[  2 ] = KEY_KP0,
118
	[  2 ] = KEY_KP0,
164
	[  1 ] = KEY_KP1,
119
	[  1 ] = KEY_KP1,
Lines 388-399 static int ir_probe(struct device *dev) Link Here
388
                break;
343
                break;
389
344
390
	case BTTV_WINFAST2000:
345
	case BTTV_WINFAST2000:
391
		ir_codes         = winfast_codes;
346
		ir_codes         = ir_codes_winfast;
392
		ir->mask_keycode = 0x1f8;
347
		ir->mask_keycode = 0x1f8;
393
		break;
348
		break;
394
	case BTTV_MAGICTVIEW061:
349
	case BTTV_MAGICTVIEW061:
395
	case BTTV_MAGICTVIEW063:
350
	case BTTV_MAGICTVIEW063:
396
		ir_codes         = winfast_codes;
351
		ir_codes         = ir_codes_winfast;
397
		ir->mask_keycode = 0x0008e000;
352
		ir->mask_keycode = 0x0008e000;
398
		ir->mask_keydown = 0x00200000;
353
		ir->mask_keydown = 0x00200000;
399
		break;
354
		break;
(-)linux-2.6.11.orig/drivers/media/video/msp3400.c (-10 / +18 lines)
Lines 380-386 static void msp3400c_setvolume(struct i2 Link Here
380
	int val = 0, bal = 0;
380
	int val = 0, bal = 0;
381
381
382
	if (!muted) {
382
	if (!muted) {
383
		val = (volume * 0x7F / 65535) << 8;
383
		/* 0x7f instead if 0x73 here has sound quality issues,
384
		 * probably due to overmodulation + clipping ... */
385
		val = (volume * 0x73 / 65535) << 8;
384
	}
386
	}
385
	if (val) {
387
	if (val) {
386
		bal = (balance / 256) - 128;
388
		bal = (balance / 256) - 128;
Lines 993-999 static int msp34xx_modus(int norm) Link Here
993
{
995
{
994
	switch (norm) {
996
	switch (norm) {
995
	case VIDEO_MODE_PAL:
997
	case VIDEO_MODE_PAL:
998
#if 1
999
		/* experimental: not sure this works with all chip versions */
1000
		return 0x7003;
1001
#else
1002
		/* previous value, try this if it breaks ... */
996
		return 0x1003;
1003
		return 0x1003;
1004
#endif
997
	case VIDEO_MODE_NTSC:  /* BTSC */
1005
	case VIDEO_MODE_NTSC:  /* BTSC */
998
		return 0x2003;
1006
		return 0x2003;
999
	case VIDEO_MODE_SECAM:
1007
	case VIDEO_MODE_SECAM:
Lines 1260-1265 static int msp34xxg_thread(void *data) Link Here
1260
	int val, std, i;
1268
	int val, std, i;
1261
1269
1262
	printk("msp34xxg: daemon started\n");
1270
	printk("msp34xxg: daemon started\n");
1271
	msp->source = 1; /* default */
1263
	for (;;) {
1272
	for (;;) {
1264
		d2printk(KERN_DEBUG "msp34xxg: thread: sleep\n");
1273
		d2printk(KERN_DEBUG "msp34xxg: thread: sleep\n");
1265
		msp34xx_sleep(msp,-1);
1274
		msp34xx_sleep(msp,-1);
Lines 1330-1337 static void msp34xxg_set_source(struct i Link Here
1330
1339
1331
	/* fix matrix mode to stereo and let the msp choose what
1340
	/* fix matrix mode to stereo and let the msp choose what
1332
	 * to output according to 'source', as recommended
1341
	 * to output according to 'source', as recommended
1342
	 * for MONO (source==0) downmixing set bit[7:0] to 0x30
1333
	 */
1343
	 */
1334
	int value = (source&0x07)<<8|(source==0 ? 0x00:0x20);
1344
	int value = (source&0x07)<<8|(source==0 ? 0x30:0x20);
1335
	dprintk("msp34xxg: set source to %d (0x%x)\n", source, value);
1345
	dprintk("msp34xxg: set source to %d (0x%x)\n", source, value);
1336
	msp3400c_write(client,
1346
	msp3400c_write(client,
1337
		       I2C_MSP3400C_DFP,
1347
		       I2C_MSP3400C_DFP,
Lines 1355-1361 static void msp34xxg_set_source(struct i Link Here
1355
	msp3400c_write(client,
1365
	msp3400c_write(client,
1356
		       I2C_MSP3400C_DEM,
1366
		       I2C_MSP3400C_DEM,
1357
		       0x22, /* a2 threshold for stereo/bilingual */
1367
		       0x22, /* a2 threshold for stereo/bilingual */
1358
		       source==0 ? 0x7f0:stereo_threshold);
1368
		       stereo_threshold);
1359
	msp->source=source;
1369
	msp->source=source;
1360
}
1370
}
1361
1371
Lines 1390-1396 static void msp34xxg_detect_stereo(struc Link Here
1390
static void msp34xxg_set_audmode(struct i2c_client *client, int audmode)
1400
static void msp34xxg_set_audmode(struct i2c_client *client, int audmode)
1391
{
1401
{
1392
	struct msp3400c *msp = i2c_get_clientdata(client);
1402
	struct msp3400c *msp = i2c_get_clientdata(client);
1393
	int source = 0;
1403
	int source;
1394
1404
1395
	switch (audmode) {
1405
	switch (audmode) {
1396
	case V4L2_TUNER_MODE_MONO:
1406
	case V4L2_TUNER_MODE_MONO:
Lines 1406-1414 static void msp34xxg_set_audmode(struct Link Here
1406
	case V4L2_TUNER_MODE_LANG2:
1416
	case V4L2_TUNER_MODE_LANG2:
1407
		source=4; /* stereo or B */
1417
		source=4; /* stereo or B */
1408
		break;
1418
		break;
1409
	default: /* doing nothing: a safe, sane default */
1419
	default:
1410
		audmode = 0;
1420
		audmode = 0;
1411
		return;
1421
		source  = 1;
1422
		break;
1412
	}
1423
	}
1413
	msp->audmode = audmode;
1424
	msp->audmode = audmode;
1414
	msp34xxg_set_source(client, source);
1425
	msp34xxg_set_source(client, source);
Lines 1510-1521 static int msp_attach(struct i2c_adapter Link Here
1510
1521
1511
	msp->opmode = opmode;
1522
	msp->opmode = opmode;
1512
	if (OPMODE_AUTO == msp->opmode) {
1523
	if (OPMODE_AUTO == msp->opmode) {
1513
#if 0 /* seems to work for ivtv only, disable by default for now ... */
1514
		if (HAVE_SIMPLER(msp))
1524
		if (HAVE_SIMPLER(msp))
1515
			msp->opmode = OPMODE_SIMPLER;
1525
			msp->opmode = OPMODE_SIMPLER;
1516
		else
1526
		else if (HAVE_SIMPLE(msp))
1517
#endif
1518
		if (HAVE_SIMPLE(msp))
1519
			msp->opmode = OPMODE_SIMPLE;
1527
			msp->opmode = OPMODE_SIMPLE;
1520
		else
1528
		else
1521
			msp->opmode = OPMODE_MANUAL;
1529
			msp->opmode = OPMODE_MANUAL;
(-)linux-2.6.11/drivers/media/video/mt20xx.c (+558 lines)
Added Link Here
1
/*
2
 * $Id: mt20xx.c,v 1.4 2005/03/04 09:24:56 kraxel Exp $
3
 *
4
 * i2c tv tuner chip device driver
5
 * controls microtune tuners, mt2032 + mt2050 at the moment.
6
 */
7
#include <linux/delay.h>
8
#include <linux/i2c.h>
9
#include <linux/videodev.h>
10
#include <linux/moduleparam.h>
11
#include <media/tuner.h>
12
13
/* ---------------------------------------------------------------------- */
14
15
static unsigned int optimize_vco  = 1;
16
module_param(optimize_vco,      int, 0644);
17
18
static unsigned int tv_antenna    = 1;
19
module_param(tv_antenna,        int, 0644);
20
21
static unsigned int radio_antenna = 0;
22
module_param(radio_antenna,     int, 0644);
23
24
/* ---------------------------------------------------------------------- */
25
26
#define MT2032 0x04
27
#define MT2030 0x06
28
#define MT2040 0x07
29
#define MT2050 0x42
30
31
static char *microtune_part[] = {
32
	[ MT2030 ] = "MT2030",
33
	[ MT2032 ] = "MT2032",
34
	[ MT2040 ] = "MT2040",
35
	[ MT2050 ] = "MT2050",
36
};
37
38
// IsSpurInBand()?
39
static int mt2032_spurcheck(struct i2c_client *c,
40
			    int f1, int f2, int spectrum_from,int spectrum_to)
41
{
42
	struct tuner *t = i2c_get_clientdata(c);
43
	int n1=1,n2,f;
44
45
	f1=f1/1000; //scale to kHz to avoid 32bit overflows
46
	f2=f2/1000;
47
	spectrum_from/=1000;
48
	spectrum_to/=1000;
49
50
	tuner_dbg("spurcheck f1=%d f2=%d  from=%d to=%d\n",
51
		  f1,f2,spectrum_from,spectrum_to);
52
53
	do {
54
	    n2=-n1;
55
	    f=n1*(f1-f2);
56
	    do {
57
		n2--;
58
		f=f-f2;
59
		tuner_dbg("spurtest n1=%d n2=%d ftest=%d\n",n1,n2,f);
60
61
		if( (f>spectrum_from) && (f<spectrum_to))
62
			tuner_dbg("mt2032 spurcheck triggered: %d\n",n1);
63
	    } while ( (f>(f2-spectrum_to)) || (n2>-5));
64
	    n1++;
65
	} while (n1<5);
66
67
	return 1;
68
}
69
70
static int mt2032_compute_freq(struct i2c_client *c,
71
			       unsigned int rfin,
72
			       unsigned int if1, unsigned int if2,
73
			       unsigned int spectrum_from,
74
			       unsigned int spectrum_to,
75
			       unsigned char *buf,
76
			       int *ret_sel,
77
			       unsigned int xogc) //all in Hz
78
{
79
	struct tuner *t = i2c_get_clientdata(c);
80
        unsigned int fref,lo1,lo1n,lo1a,s,sel,lo1freq, desired_lo1,
81
		desired_lo2,lo2,lo2n,lo2a,lo2num,lo2freq;
82
83
        fref= 5250 *1000; //5.25MHz
84
	desired_lo1=rfin+if1;
85
86
	lo1=(2*(desired_lo1/1000)+(fref/1000)) / (2*fref/1000);
87
        lo1n=lo1/8;
88
        lo1a=lo1-(lo1n*8);
89
90
        s=rfin/1000/1000+1090;
91
92
	if(optimize_vco) {
93
		if(s>1890) sel=0;
94
		else if(s>1720) sel=1;
95
		else if(s>1530) sel=2;
96
		else if(s>1370) sel=3;
97
		else sel=4; // >1090
98
	}
99
	else {
100
        	if(s>1790) sel=0; // <1958
101
        	else if(s>1617) sel=1;
102
        	else if(s>1449) sel=2;
103
        	else if(s>1291) sel=3;
104
        	else sel=4; // >1090
105
	}
106
	*ret_sel=sel;
107
108
        lo1freq=(lo1a+8*lo1n)*fref;
109
110
	tuner_dbg("mt2032: rfin=%d lo1=%d lo1n=%d lo1a=%d sel=%d, lo1freq=%d\n",
111
		  rfin,lo1,lo1n,lo1a,sel,lo1freq);
112
113
        desired_lo2=lo1freq-rfin-if2;
114
        lo2=(desired_lo2)/fref;
115
        lo2n=lo2/8;
116
        lo2a=lo2-(lo2n*8);
117
        lo2num=((desired_lo2/1000)%(fref/1000))* 3780/(fref/1000); //scale to fit in 32bit arith
118
        lo2freq=(lo2a+8*lo2n)*fref + lo2num*(fref/1000)/3780*1000;
119
120
	tuner_dbg("mt2032: rfin=%d lo2=%d lo2n=%d lo2a=%d num=%d lo2freq=%d\n",
121
		  rfin,lo2,lo2n,lo2a,lo2num,lo2freq);
122
123
        if(lo1a<0 || lo1a>7 || lo1n<17 ||lo1n>48 || lo2a<0 ||lo2a >7 ||lo2n<17 || lo2n>30) {
124
		tuner_info("mt2032: frequency parameters out of range: %d %d %d %d\n",
125
			   lo1a, lo1n, lo2a,lo2n);
126
                return(-1);
127
        }
128
129
	mt2032_spurcheck(c, lo1freq, desired_lo2,  spectrum_from, spectrum_to);
130
	// should recalculate lo1 (one step up/down)
131
132
	// set up MT2032 register map for transfer over i2c
133
	buf[0]=lo1n-1;
134
	buf[1]=lo1a | (sel<<4);
135
	buf[2]=0x86; // LOGC
136
	buf[3]=0x0f; //reserved
137
	buf[4]=0x1f;
138
	buf[5]=(lo2n-1) | (lo2a<<5);
139
 	if(rfin >400*1000*1000)
140
                buf[6]=0xe4;
141
        else
142
                buf[6]=0xf4; // set PKEN per rev 1.2
143
	buf[7]=8+xogc;
144
	buf[8]=0xc3; //reserved
145
	buf[9]=0x4e; //reserved
146
	buf[10]=0xec; //reserved
147
	buf[11]=(lo2num&0xff);
148
	buf[12]=(lo2num>>8) |0x80; // Lo2RST
149
150
	return 0;
151
}
152
153
static int mt2032_check_lo_lock(struct i2c_client *c)
154
{
155
	struct tuner *t = i2c_get_clientdata(c);
156
	int try,lock=0;
157
	unsigned char buf[2];
158
159
	for(try=0;try<10;try++) {
160
		buf[0]=0x0e;
161
		i2c_master_send(c,buf,1);
162
		i2c_master_recv(c,buf,1);
163
		tuner_dbg("mt2032 Reg.E=0x%02x\n",buf[0]);
164
		lock=buf[0] &0x06;
165
166
		if (lock==6)
167
			break;
168
169
		tuner_dbg("mt2032: pll wait 1ms for lock (0x%2x)\n",buf[0]);
170
		udelay(1000);
171
	}
172
        return lock;
173
}
174
175
static int mt2032_optimize_vco(struct i2c_client *c,int sel,int lock)
176
{
177
	struct tuner *t = i2c_get_clientdata(c);
178
	unsigned char buf[2];
179
	int tad1;
180
181
	buf[0]=0x0f;
182
	i2c_master_send(c,buf,1);
183
	i2c_master_recv(c,buf,1);
184
	tuner_dbg("mt2032 Reg.F=0x%02x\n",buf[0]);
185
	tad1=buf[0]&0x07;
186
187
	if(tad1 ==0) return lock;
188
	if(tad1 ==1) return lock;
189
190
	if(tad1==2) {
191
		if(sel==0)
192
			return lock;
193
		else sel--;
194
	}
195
	else {
196
		if(sel<4)
197
			sel++;
198
		else
199
			return lock;
200
	}
201
202
	tuner_dbg("mt2032 optimize_vco: sel=%d\n",sel);
203
204
	buf[0]=0x0f;
205
	buf[1]=sel;
206
        i2c_master_send(c,buf,2);
207
	lock=mt2032_check_lo_lock(c);
208
	return lock;
209
}
210
211
212
static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
213
			       unsigned int if1, unsigned int if2,
214
			       unsigned int from, unsigned int to)
215
{
216
	unsigned char buf[21];
217
	int lint_try,ret,sel,lock=0;
218
	struct tuner *t = i2c_get_clientdata(c);
219
220
	tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n",
221
		  rfin,if1,if2,from,to);
222
223
        buf[0]=0;
224
        ret=i2c_master_send(c,buf,1);
225
        i2c_master_recv(c,buf,21);
226
227
	buf[0]=0;
228
	ret=mt2032_compute_freq(c,rfin,if1,if2,from,to,&buf[1],&sel,t->xogc);
229
	if (ret<0)
230
		return;
231
232
        // send only the relevant registers per Rev. 1.2
233
        buf[0]=0;
234
        ret=i2c_master_send(c,buf,4);
235
        buf[5]=5;
236
        ret=i2c_master_send(c,buf+5,4);
237
        buf[11]=11;
238
        ret=i2c_master_send(c,buf+11,3);
239
        if(ret!=3)
240
		tuner_warn("i2c i/o error: rc == %d (should be 3)\n",ret);
241
242
	// wait for PLLs to lock (per manual), retry LINT if not.
243
	for(lint_try=0; lint_try<2; lint_try++) {
244
		lock=mt2032_check_lo_lock(c);
245
246
		if(optimize_vco)
247
			lock=mt2032_optimize_vco(c,sel,lock);
248
		if(lock==6) break;
249
250
		tuner_dbg("mt2032: re-init PLLs by LINT\n");
251
		buf[0]=7;
252
		buf[1]=0x80 +8+t->xogc; // set LINT to re-init PLLs
253
		i2c_master_send(c,buf,2);
254
		mdelay(10);
255
		buf[1]=8+t->xogc;
256
		i2c_master_send(c,buf,2);
257
        }
258
259
	if (lock!=6)
260
		tuner_warn("MT2032 Fatal Error: PLLs didn't lock.\n");
261
262
	buf[0]=2;
263
	buf[1]=0x20; // LOGC for optimal phase noise
264
	ret=i2c_master_send(c,buf,2);
265
	if (ret!=2)
266
		tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret);
267
}
268
269
270
static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq)
271
{
272
	struct tuner *t = i2c_get_clientdata(c);
273
	int if2,from,to;
274
275
	// signal bandwidth and picture carrier
276
	if (t->std & V4L2_STD_525_60) {
277
		// NTSC
278
		from = 40750*1000;
279
		to   = 46750*1000;
280
		if2  = 45750*1000;
281
	} else {
282
		// PAL
283
		from = 32900*1000;
284
		to   = 39900*1000;
285
		if2  = 38900*1000;
286
	}
287
288
        mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
289
			   1090*1000*1000, if2, from, to);
290
}
291
292
static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
293
{
294
	struct tuner *t = i2c_get_clientdata(c);
295
	int if2 = t->radio_if2;
296
297
	// per Manual for FM tuning: first if center freq. 1085 MHz
298
        mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
299
			   1085*1000*1000,if2,if2,if2);
300
}
301
302
// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001
303
static int mt2032_init(struct i2c_client *c)
304
{
305
	struct tuner *t = i2c_get_clientdata(c);
306
        unsigned char buf[21];
307
        int ret,xogc,xok=0;
308
309
	// Initialize Registers per spec.
310
        buf[1]=2; // Index to register 2
311
        buf[2]=0xff;
312
        buf[3]=0x0f;
313
        buf[4]=0x1f;
314
        ret=i2c_master_send(c,buf+1,4);
315
316
        buf[5]=6; // Index register 6
317
        buf[6]=0xe4;
318
        buf[7]=0x8f;
319
        buf[8]=0xc3;
320
        buf[9]=0x4e;
321
        buf[10]=0xec;
322
        ret=i2c_master_send(c,buf+5,6);
323
324
        buf[12]=13;  // Index register 13
325
        buf[13]=0x32;
326
        ret=i2c_master_send(c,buf+12,2);
327
328
        // Adjust XOGC (register 7), wait for XOK
329
        xogc=7;
330
        do {
331
		tuner_dbg("mt2032: xogc = 0x%02x\n",xogc&0x07);
332
                mdelay(10);
333
                buf[0]=0x0e;
334
                i2c_master_send(c,buf,1);
335
                i2c_master_recv(c,buf,1);
336
                xok=buf[0]&0x01;
337
                tuner_dbg("mt2032: xok = 0x%02x\n",xok);
338
                if (xok == 1) break;
339
340
                xogc--;
341
                tuner_dbg("mt2032: xogc = 0x%02x\n",xogc&0x07);
342
                if (xogc == 3) {
343
                        xogc=4; // min. 4 per spec
344
                        break;
345
                }
346
                buf[0]=0x07;
347
                buf[1]=0x88 + xogc;
348
                ret=i2c_master_send(c,buf,2);
349
                if (ret!=2)
350
			tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret);
351
        } while (xok != 1 );
352
	t->xogc=xogc;
353
354
	t->tv_freq    = mt2032_set_tv_freq;
355
	t->radio_freq = mt2032_set_radio_freq;
356
        return(1);
357
}
358
359
static void mt2050_set_antenna(struct i2c_client *c, unsigned char antenna)
360
{
361
	struct tuner *t = i2c_get_clientdata(c);
362
       unsigned char buf[2];
363
       int ret;
364
365
       buf[0] = 6;
366
       buf[1] = antenna ? 0x11 : 0x10;
367
       ret=i2c_master_send(c,buf,2);
368
       tuner_dbg("mt2050: enabled antenna connector %d\n", antenna);
369
}
370
371
static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned int if2)
372
{
373
	struct tuner *t = i2c_get_clientdata(c);
374
	unsigned int if1=1218*1000*1000;
375
	unsigned int f_lo1,f_lo2,lo1,lo2,f_lo1_modulo,f_lo2_modulo,num1,num2,div1a,div1b,div2a,div2b;
376
	int ret;
377
	unsigned char buf[6];
378
379
	tuner_dbg("mt2050_set_if_freq freq=%d if1=%d if2=%d\n",
380
		  freq,if1,if2);
381
382
	f_lo1=freq+if1;
383
	f_lo1=(f_lo1/1000000)*1000000;
384
385
	f_lo2=f_lo1-freq-if2;
386
	f_lo2=(f_lo2/50000)*50000;
387
388
	lo1=f_lo1/4000000;
389
	lo2=f_lo2/4000000;
390
391
	f_lo1_modulo= f_lo1-(lo1*4000000);
392
	f_lo2_modulo= f_lo2-(lo2*4000000);
393
394
	num1=4*f_lo1_modulo/4000000;
395
	num2=4096*(f_lo2_modulo/1000)/4000;
396
397
	// todo spurchecks
398
399
	div1a=(lo1/12)-1;
400
	div1b=lo1-(div1a+1)*12;
401
402
	div2a=(lo2/8)-1;
403
	div2b=lo2-(div2a+1)*8;
404
405
	if (tuner_debug > 1) {
406
		tuner_dbg("lo1 lo2 = %d %d\n", lo1, lo2);
407
		tuner_dbg("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n",
408
			  num1,num2,div1a,div1b,div2a,div2b);
409
	}
410
411
	buf[0]=1;
412
	buf[1]= 4*div1b + num1;
413
	if(freq<275*1000*1000) buf[1] = buf[1]|0x80;
414
415
	buf[2]=div1a;
416
	buf[3]=32*div2b + num2/256;
417
	buf[4]=num2-(num2/256)*256;
418
	buf[5]=div2a;
419
	if(num2!=0) buf[5]=buf[5]|0x40;
420
421
	if (tuner_debug > 1) {
422
		int i;
423
		tuner_dbg("bufs is: ");
424
		for(i=0;i<6;i++)
425
			printk("%x ",buf[i]);
426
		printk("\n");
427
	}
428
429
	ret=i2c_master_send(c,buf,6);
430
        if (ret!=6)
431
		tuner_warn("i2c i/o error: rc == %d (should be 6)\n",ret);
432
}
433
434
static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq)
435
{
436
	struct tuner *t = i2c_get_clientdata(c);
437
	unsigned int if2;
438
439
	if (t->std & V4L2_STD_525_60) {
440
		// NTSC
441
                if2 = 45750*1000;
442
        } else {
443
                // PAL
444
                if2 = 38900*1000;
445
        }
446
	if (V4L2_TUNER_DIGITAL_TV == t->mode) {
447
		// DVB (pinnacle 300i)
448
		if2 = 36150*1000;
449
	}
450
	mt2050_set_if_freq(c, freq*62500, if2);
451
	mt2050_set_antenna(c, tv_antenna);
452
}
453
454
static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq)
455
{
456
	struct tuner *t = i2c_get_clientdata(c);
457
	int if2 = t->radio_if2;
458
459
	mt2050_set_if_freq(c, freq*62500, if2);
460
	mt2050_set_antenna(c, radio_antenna);
461
}
462
463
static int mt2050_init(struct i2c_client *c)
464
{
465
	struct tuner *t = i2c_get_clientdata(c);
466
	unsigned char buf[2];
467
	int ret;
468
469
	buf[0]=6;
470
	buf[1]=0x10;
471
	ret=i2c_master_send(c,buf,2); //  power
472
473
	buf[0]=0x0f;
474
	buf[1]=0x0f;
475
	ret=i2c_master_send(c,buf,2); // m1lo
476
477
	buf[0]=0x0d;
478
	ret=i2c_master_send(c,buf,1);
479
	i2c_master_recv(c,buf,1);
480
481
	tuner_dbg("mt2050: sro is %x\n",buf[0]);
482
	t->tv_freq    = mt2050_set_tv_freq;
483
	t->radio_freq = mt2050_set_radio_freq;
484
	return 0;
485
}
486
487
int microtune_init(struct i2c_client *c)
488
{
489
	struct tuner *t = i2c_get_clientdata(c);
490
	char *name;
491
        unsigned char buf[21];
492
	int company_code;
493
494
	memset(buf,0,sizeof(buf));
495
	t->tv_freq    = NULL;
496
	t->radio_freq = NULL;
497
	name = "unknown";
498
499
        i2c_master_send(c,buf,1);
500
        i2c_master_recv(c,buf,21);
501
        if (tuner_debug) {
502
                int i;
503
		tuner_dbg("MT20xx hexdump:");
504
                for(i=0;i<21;i++) {
505
                        printk(" %02x",buf[i]);
506
                        if(((i+1)%8)==0) printk(" ");
507
                }
508
                printk("\n");
509
        }
510
	company_code = buf[0x11] << 8 | buf[0x12];
511
	tuner_info("microtune: companycode=%04x part=%02x rev=%02x\n",
512
		   company_code,buf[0x13],buf[0x14]);
513
514
#if 0
515
	/* seems to cause more problems than it solves ... */
516
	switch (company_code) {
517
	case 0x30bf:
518
	case 0x3cbf:
519
	case 0x3dbf:
520
	case 0x4d54:
521
	case 0x8e81:
522
	case 0x8e91:
523
		/* ok (?) */
524
		break;
525
	default:
526
		tuner_warn("tuner: microtune: unknown companycode\n");
527
		return 0;
528
	}
529
#endif
530
531
	if (buf[0x13] < ARRAY_SIZE(microtune_part) &&
532
	    NULL != microtune_part[buf[0x13]])
533
		name = microtune_part[buf[0x13]];
534
	switch (buf[0x13]) {
535
	case MT2032:
536
		mt2032_init(c);
537
		break;
538
	case MT2050:
539
		mt2050_init(c);
540
		break;
541
	default:
542
		tuner_info("microtune %s found, not (yet?) supported, sorry :-/\n",
543
			   name);
544
                return 0;
545
        }
546
547
	strlcpy(c->name, name, sizeof(c->name));
548
	tuner_info("microtune %s found, OK\n",name);
549
	return 0;
550
}
551
552
/*
553
 * Overrides for Emacs so that we follow Linus's tabbing style.
554
 * ---------------------------------------------------------------------------
555
 * Local variables:
556
 * c-basic-offset: 8
557
 * End:
558
 */
(-)linux-2.6.11.orig/drivers/media/video/planb.c (-2 / +2 lines)
Lines 40-45 Link Here
40
#include <linux/mm.h>
40
#include <linux/mm.h>
41
#include <linux/sched.h>
41
#include <linux/sched.h>
42
#include <linux/videodev.h>
42
#include <linux/videodev.h>
43
#include <linux/wait.h>
43
#include <asm/uaccess.h>
44
#include <asm/uaccess.h>
44
#include <asm/io.h>
45
#include <asm/io.h>
45
#include <asm/prom.h>
46
#include <asm/prom.h>
Lines 1609-1616 static int planb_ioctl(struct video_devi Link Here
1609
				}
1610
				}
1610
				planb_lock(pb);
1611
				planb_lock(pb);
1611
				/* empty the grabbing queue */
1612
				/* empty the grabbing queue */
1612
				while(pb->grabbing)
1613
				wait_event(pb->capq, !pb->grabbing);
1613
					interruptible_sleep_on(&pb->capq);
1614
				pb->maxlines = maxlines;
1614
				pb->maxlines = maxlines;
1615
				pb->win.norm = v.norm;
1615
				pb->win.norm = v.norm;
1616
				/* Stop overlay if running */
1616
				/* Stop overlay if running */
(-)linux-2.6.11.orig/drivers/media/video/saa5246a.c (-12 / +1 lines)
Lines 65-82 static struct video_device saa_template; Link Here
65
/* Addresses to scan */
65
/* Addresses to scan */
66
static unsigned short normal_i2c[]	 = { I2C_ADDRESS, I2C_CLIENT_END };
66
static unsigned short normal_i2c[]	 = { I2C_ADDRESS, I2C_CLIENT_END };
67
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
67
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
68
static unsigned short probe[2]		 = { I2C_CLIENT_END, I2C_CLIENT_END };
68
I2C_CLIENT_INSMOD;
69
static unsigned short probe_range[2]	 = { I2C_CLIENT_END, I2C_CLIENT_END };
70
static unsigned short ignore[2]		 = { I2C_CLIENT_END, I2C_CLIENT_END };
71
static unsigned short ignore_range[2]	 = { I2C_CLIENT_END, I2C_CLIENT_END };
72
static unsigned short force[2]		 = { I2C_CLIENT_END, I2C_CLIENT_END };
73
74
static struct i2c_client_address_data addr_data = {
75
	normal_i2c, normal_i2c_range,
76
	probe, probe_range,
77
	ignore, ignore_range,
78
	force
79
};
80
69
81
static struct i2c_client client_template;
70
static struct i2c_client client_template;
82
71
(-)linux-2.6.11.orig/drivers/media/video/saa5249.c (-12 / +1 lines)
Lines 133-150 static struct video_device saa_template; Link Here
133
/* Addresses to scan */
133
/* Addresses to scan */
134
static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END};
134
static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END};
135
static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
135
static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
136
static unsigned short probe[2]        = { I2C_CLIENT_END, I2C_CLIENT_END };
136
I2C_CLIENT_INSMOD;
137
static unsigned short probe_range[2]  = { I2C_CLIENT_END, I2C_CLIENT_END };
138
static unsigned short ignore[2]       = { I2C_CLIENT_END, I2C_CLIENT_END };
139
static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
140
static unsigned short force[2]        = { I2C_CLIENT_END, I2C_CLIENT_END };
141
142
static struct i2c_client_address_data addr_data = {
143
	normal_i2c, normal_i2c_range, 
144
	probe, probe_range, 
145
	ignore, ignore_range, 
146
	force
147
};
148
137
149
static struct i2c_client client_template;
138
static struct i2c_client client_template;
150
139
(-)linux-2.6.11.orig/drivers/media/video/saa7110.c (-2 / +8 lines)
Lines 30-35 Link Here
30
#include <linux/types.h>
30
#include <linux/types.h>
31
#include <linux/delay.h>
31
#include <linux/delay.h>
32
#include <linux/slab.h>
32
#include <linux/slab.h>
33
#include <linux/wait.h>
33
#include <asm/io.h>
34
#include <asm/io.h>
34
#include <asm/uaccess.h>
35
#include <asm/uaccess.h>
35
36
Lines 205-217 static const unsigned char initseq[] = { Link Here
205
static int
206
static int
206
determine_norm (struct i2c_client *client)
207
determine_norm (struct i2c_client *client)
207
{
208
{
209
	DEFINE_WAIT(wait);
208
	struct saa7110 *decoder = i2c_get_clientdata(client);
210
	struct saa7110 *decoder = i2c_get_clientdata(client);
209
	int status;
211
	int status;
210
212
211
	/* mode changed, start automatic detection */
213
	/* mode changed, start automatic detection */
212
	saa7110_write_block(client, initseq, sizeof(initseq));
214
	saa7110_write_block(client, initseq, sizeof(initseq));
213
	saa7110_selmux(client, decoder->input);
215
	saa7110_selmux(client, decoder->input);
214
	sleep_on_timeout(&decoder->wq, HZ / 4);
216
	prepare_to_wait(&decoder->wq, &wait, TASK_UNINTERRUPTIBLE);
217
	schedule_timeout(HZ/4);
218
	finish_wait(&decoder->wq, &wait);
215
	status = saa7110_read(client);
219
	status = saa7110_read(client);
216
	if (status & 0x40) {
220
	if (status & 0x40) {
217
		dprintk(1, KERN_INFO "%s: status=0x%02x (no signal)\n",
221
		dprintk(1, KERN_INFO "%s: status=0x%02x (no signal)\n",
Lines 250-256 determine_norm (struct i2c_client *clien Link Here
250
	saa7110_write(client, 0x11, 0x59);
254
	saa7110_write(client, 0x11, 0x59);
251
	//saa7110_write(client,0x2E,0x9A);
255
	//saa7110_write(client,0x2E,0x9A);
252
256
253
	sleep_on_timeout(&decoder->wq, HZ / 4);
257
	prepare_to_wait(&decoder->wq, &wait, TASK_UNINTERRUPTIBLE);
258
	schedule_timeout(HZ/4);
259
	finish_wait(&decoder->wq, &wait);
254
260
255
	status = saa7110_read(client);
261
	status = saa7110_read(client);
256
	if ((status & 0x03) == 0x01) {
262
	if ((status & 0x03) == 0x01) {
(-)linux-2.6.11.orig/drivers/media/video/saa7134/Makefile (+1 lines)
Lines 8-10 obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa71 Link Here
8
8
9
EXTRA_CFLAGS += -I$(src)/..
9
EXTRA_CFLAGS += -I$(src)/..
10
EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
10
EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
11
EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa6752hs.c (-89 / +225 lines)
Lines 11-19 Link Here
11
#include <linux/types.h>
11
#include <linux/types.h>
12
#include <linux/videodev.h>
12
#include <linux/videodev.h>
13
#include <linux/init.h>
13
#include <linux/init.h>
14
#include <linux/crc32.h>
14
15
15
#include <media/id.h>
16
#include <media/id.h>
16
#include <media/saa6752hs.h>
17
18
#define MPEG_VIDEO_TARGET_BITRATE_MAX  27000
19
#define MPEG_VIDEO_MAX_BITRATE_MAX     27000
20
#define MPEG_TOTAL_TARGET_BITRATE_MAX  27000
21
#define MPEG_PID_MAX ((1 << 14) - 1)
17
22
18
/* Addresses to scan */
23
/* Addresses to scan */
19
static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END};
24
static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END};
Lines 27-32 MODULE_LICENSE("GPL"); Link Here
27
static struct i2c_driver driver;
32
static struct i2c_driver driver;
28
static struct i2c_client client_template;
33
static struct i2c_client client_template;
29
34
35
struct saa6752hs_state {
36
	struct i2c_client             client;
37
	struct v4l2_mpeg_compression  params;
38
};
30
39
31
enum saa6752hs_command {
40
enum saa6752hs_command {
32
	SAA6752HS_COMMAND_RESET = 0,
41
	SAA6752HS_COMMAND_RESET = 0,
Lines 40-46 enum saa6752hs_command { Link Here
40
	SAA6752HS_COMMAND_MAX
49
	SAA6752HS_COMMAND_MAX
41
};
50
};
42
51
43
44
/* ---------------------------------------------------------------------- */
52
/* ---------------------------------------------------------------------- */
45
53
46
static u8 PAT[] = {
54
static u8 PAT[] = {
Lines 64-72 static u8 PAT[] = { Link Here
64
72
65
	0x00, 0x01, // program_number(1)
73
	0x00, 0x01, // program_number(1)
66
74
67
	0xe0, 0x10, // PMT PID(0x10)
75
	0xe0, 0x00, // PMT PID
68
76
69
	0x76, 0xf1, 0x44, 0xd1 // CRC32
77
	0x00, 0x00, 0x00, 0x00 // CRC32
70
};
78
};
71
79
72
static u8 PMT[] = {
80
static u8 PMT[] = {
Lines 74-80 static u8 PMT[] = { Link Here
74
	0x01, // table number for encoder
82
	0x01, // table number for encoder
75
83
76
	0x47, // sync
84
	0x47, // sync
77
	0x40, 0x10, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0x10)
85
	0x40, 0x00, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid
78
	0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0)
86
	0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0)
79
87
80
	0x00, // PSI pointer to start of table
88
	0x00, // PSI pointer to start of table
Lines 88-114 static u8 PMT[] = { Link Here
88
96
89
	0x00, 0x00, // section_number(0), last_section_number(0)
97
	0x00, 0x00, // section_number(0), last_section_number(0)
90
98
91
	0xe1, 0x04, // PCR_PID (0x104)
99
	0xe0, 0x00, // PCR_PID
92
100
93
	0xf0, 0x00, // program_info_length(0)
101
	0xf0, 0x00, // program_info_length(0)
94
102
95
	0x02, 0xe1, 0x00, 0xf0, 0x00, // video stream type(2), pid(0x100)
103
	0x02, 0xe0, 0x00, 0xf0, 0x00, // video stream type(2), pid
96
	0x04, 0xe1, 0x03, 0xf0, 0x00, // audio stream type(4), pid(0x103)
104
	0x04, 0xe0, 0x00, 0xf0, 0x00, // audio stream type(4), pid
97
105
98
	0xa1, 0xca, 0x0f, 0x82 // CRC32
106
	0x00, 0x00, 0x00, 0x00 // CRC32
99
};
107
};
100
108
101
static struct mpeg_params mpeg_params_template =
109
static struct v4l2_mpeg_compression param_defaults =
102
{
110
{
103
	.bitrate_mode = MPEG_BITRATE_MODE_CBR,
111
	.st_type         = V4L2_MPEG_TS_2,
104
	.video_target_bitrate = 5000,
112
	.st_bitrate      = {
105
	.audio_bitrate = MPEG_AUDIO_BITRATE_256,
113
		.mode    = V4L2_BITRATE_CBR,
106
	.total_bitrate = 6000,
114
		.target  = 7000,
107
};
115
	},
108
116
117
	.ts_pid_pmt      = 16,
118
	.ts_pid_video    = 260,
119
	.ts_pid_audio    = 256,
120
	.ts_pid_pcr      = 259,
109
121
110
/* ---------------------------------------------------------------------- */
122
	.vi_type         = V4L2_MPEG_VI_2,
123
	.vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3,
124
	.vi_bitrate      = {
125
		.mode    = V4L2_BITRATE_VBR,
126
		.target  = 4000,
127
		.max     = 6000,
128
	},
111
129
130
	.au_type         = V4L2_MPEG_AU_2_II,
131
	.au_bitrate      = {
132
		.mode    = V4L2_BITRATE_CBR,
133
		.target  = 256,
134
	},
135
136
#if 0
137
	/* FIXME: size? via S_FMT? */
138
	.video_format = MPEG_VIDEO_FORMAT_D1,
139
#endif
140
};
141
142
/* ---------------------------------------------------------------------- */
112
143
113
static int saa6752hs_chip_command(struct i2c_client* client,
144
static int saa6752hs_chip_command(struct i2c_client* client,
114
				  enum saa6752hs_command command)
145
				  enum saa6752hs_command command)
Lines 124-130 static int saa6752hs_chip_command(struct Link Here
124
		break;
155
		break;
125
156
126
	case SAA6752HS_COMMAND_STOP:
157
	case SAA6752HS_COMMAND_STOP:
127
		  	buf[0] = 0x03;
158
	  	buf[0] = 0x03;
128
		break;
159
		break;
129
160
130
	case SAA6752HS_COMMAND_START:
161
	case SAA6752HS_COMMAND_START:
Lines 180-253 static int saa6752hs_chip_command(struct Link Here
180
211
181
212
182
static int saa6752hs_set_bitrate(struct i2c_client* client,
213
static int saa6752hs_set_bitrate(struct i2c_client* client,
183
				 struct mpeg_params* params)
214
				 struct v4l2_mpeg_compression* params)
184
{
215
{
185
  	u8 buf[3];
216
  	u8 buf[3];
186
217
187
	// set the bitrate mode
218
	// set the bitrate mode
188
	buf[0] = 0x71;
219
	buf[0] = 0x71;
189
	buf[1] = params->bitrate_mode;
220
	buf[1] = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ? 0 : 1;
190
	i2c_master_send(client, buf, 2);
221
	i2c_master_send(client, buf, 2);
191
222
192
	// set the video bitrate
223
	// set the video bitrate
193
	if (params->bitrate_mode == MPEG_BITRATE_MODE_VBR) {
224
	if (params->vi_bitrate.mode == V4L2_BITRATE_VBR) {
194
		// set the target bitrate
225
		// set the target bitrate
195
		buf[0] = 0x80;
226
		buf[0] = 0x80;
196
	    	buf[1] = params->video_target_bitrate >> 8;
227
	    	buf[1] = params->vi_bitrate.target >> 8;
197
	  	buf[2] = params->video_target_bitrate & 0xff;
228
	  	buf[2] = params->vi_bitrate.target & 0xff;
198
		i2c_master_send(client, buf, 3);
229
		i2c_master_send(client, buf, 3);
199
230
200
		// set the max bitrate
231
		// set the max bitrate
201
		buf[0] = 0x81;
232
		buf[0] = 0x81;
202
	    	buf[1] = params->video_max_bitrate >> 8;
233
	    	buf[1] = params->vi_bitrate.max >> 8;
203
	  	buf[2] = params->video_max_bitrate & 0xff;
234
	  	buf[2] = params->vi_bitrate.max & 0xff;
204
		i2c_master_send(client, buf, 3);
235
		i2c_master_send(client, buf, 3);
205
	} else {
236
	} else {
206
		// set the target bitrate (no max bitrate for CBR)
237
		// set the target bitrate (no max bitrate for CBR)
207
  		buf[0] = 0x81;
238
  		buf[0] = 0x81;
208
	    	buf[1] = params->video_target_bitrate >> 8;
239
	    	buf[1] = params->vi_bitrate.target >> 8;
209
	  	buf[2] = params->video_target_bitrate & 0xff;
240
	  	buf[2] = params->vi_bitrate.target & 0xff;
210
		i2c_master_send(client, buf, 3);
241
		i2c_master_send(client, buf, 3);
211
	}
242
	}
212
243
213
	// set the audio bitrate
244
	// set the audio bitrate
214
 	buf[0] = 0x94;
245
 	buf[0] = 0x94;
215
  	buf[1] = params->audio_bitrate;
246
	buf[1] = (256 == params->au_bitrate.target) ? 0 : 1;
216
	i2c_master_send(client, buf, 2);
247
	i2c_master_send(client, buf, 2);
217
248
218
	// set the total bitrate
249
	// set the total bitrate
219
	buf[0] = 0xb1;
250
	buf[0] = 0xb1;
220
  	buf[1] = params->total_bitrate >> 8;
251
  	buf[1] = params->st_bitrate.target >> 8;
221
  	buf[2] = params->total_bitrate & 0xff;
252
  	buf[2] = params->st_bitrate.target & 0xff;
222
	i2c_master_send(client, buf, 3);
253
	i2c_master_send(client, buf, 3);
223
254
255
	// return success
224
	return 0;
256
	return 0;
225
}
257
}
226
258
227
259
228
static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params)
260
static void saa6752hs_set_params(struct i2c_client* client,
261
				 struct v4l2_mpeg_compression* params)
229
{
262
{
230
	unsigned char buf[3];
263
	struct saa6752hs_state *h = i2c_get_clientdata(client);
231
	void *data;
232
264
233
	// check the bitrate parameters first
265
	/* check PIDs */
234
	if (params != NULL) {
266
	if (params->ts_pid_pmt <= MPEG_PID_MAX)
235
		if (params->bitrate_mode >= MPEG_BITRATE_MODE_MAX)
267
		h->params.ts_pid_pmt = params->ts_pid_pmt;
236
			return -EINVAL;
268
	if (params->ts_pid_pcr <= MPEG_PID_MAX)
237
		if (params->video_target_bitrate >= MPEG_VIDEO_TARGET_BITRATE_MAX)
269
		h->params.ts_pid_pcr = params->ts_pid_pcr;
238
			return -EINVAL;
270
	if (params->ts_pid_video <= MPEG_PID_MAX)
239
  		if (params->video_max_bitrate >= MPEG_VIDEO_MAX_BITRATE_MAX)
271
		h->params.ts_pid_video = params->ts_pid_video;
240
			return -EINVAL;
272
	if (params->ts_pid_audio <= MPEG_PID_MAX)
241
		if (params->audio_bitrate >= MPEG_AUDIO_BITRATE_MAX)
273
		h->params.ts_pid_audio = params->ts_pid_audio;
242
			return -EINVAL;
243
		if (params->total_bitrate >= MPEG_TOTAL_BITRATE_MAX)
244
        		return -EINVAL;
245
		if (params->bitrate_mode         == MPEG_BITRATE_MODE_MAX &&
246
		    params->video_target_bitrate <= params->video_max_bitrate)
247
			return -EINVAL;
248
	}
249
274
250
    	// Set GOP structure {3, 13}
275
	/* check bitrate parameters */
276
	if ((params->vi_bitrate.mode == V4L2_BITRATE_CBR) ||
277
	    (params->vi_bitrate.mode == V4L2_BITRATE_VBR))
278
		h->params.vi_bitrate.mode = params->vi_bitrate.mode;
279
	if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
280
		h->params.st_bitrate.target = params->st_bitrate.target;
281
	if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
282
		h->params.vi_bitrate.target = params->vi_bitrate.target;
283
	if (params->vi_bitrate.mode == V4L2_BITRATE_VBR)
284
		h->params.vi_bitrate.max = params->vi_bitrate.max;
285
	if (params->au_bitrate.mode != V4L2_BITRATE_NONE)
286
		h->params.au_bitrate.target = params->au_bitrate.target;
287
288
	/* aspect ratio */
289
	if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3 ||
290
	    params->vi_aspect_ratio == V4L2_MPEG_ASPECT_16_9)
291
		h->params.vi_aspect_ratio = params->vi_aspect_ratio;
292
293
	/* range checks */
294
	if (h->params.st_bitrate.target > MPEG_TOTAL_TARGET_BITRATE_MAX)
295
		h->params.st_bitrate.target = MPEG_TOTAL_TARGET_BITRATE_MAX;
296
	if (h->params.vi_bitrate.target > MPEG_VIDEO_TARGET_BITRATE_MAX)
297
		h->params.vi_bitrate.target = MPEG_VIDEO_TARGET_BITRATE_MAX;
298
	if (h->params.vi_bitrate.max > MPEG_VIDEO_MAX_BITRATE_MAX)
299
		h->params.vi_bitrate.max = MPEG_VIDEO_MAX_BITRATE_MAX;
300
	if (h->params.au_bitrate.target <= 256)
301
		h->params.au_bitrate.target = 256;
302
	else
303
		h->params.au_bitrate.target = 384;
304
}
305
306
static int saa6752hs_init(struct i2c_client* client)
307
{
308
	unsigned char buf[9], buf2[4];
309
	struct saa6752hs_state *h;
310
	u32 crc;
311
	unsigned char localPAT[256];
312
	unsigned char localPMT[256];
313
314
	h = i2c_get_clientdata(client);
315
316
	// Set video format - must be done first as it resets other settings
317
	buf[0] = 0x41;
318
	buf[1] = 0 /* MPEG_VIDEO_FORMAT_D1 */;
319
	i2c_master_send(client, buf, 2);
320
321
        // set bitrate
322
        saa6752hs_set_bitrate(client, &h->params);
323
324
	// Set GOP structure {3, 13}
251
	buf[0] = 0x72;
325
	buf[0] = 0x72;
252
	buf[1] = 0x03;
326
	buf[1] = 0x03;
253
	buf[2] = 0x0D;
327
	buf[2] = 0x0D;
Lines 265-271 static int saa6752hs_init(struct i2c_cli Link Here
265
339
266
    	// Set Output Protocol
340
    	// Set Output Protocol
267
	buf[0] = 0xD0;
341
	buf[0] = 0xD0;
268
	buf[1] = 0x01;
342
	buf[1] = 0x81;
269
	i2c_master_send(client,buf,2);
343
	i2c_master_send(client,buf,2);
270
344
271
    	// Set video output stream format {TS}
345
    	// Set video output stream format {TS}
Lines 273-297 static int saa6752hs_init(struct i2c_cli Link Here
273
	buf[1] = 0x05;
347
	buf[1] = 0x05;
274
	i2c_master_send(client,buf,2);
348
	i2c_master_send(client,buf,2);
275
349
276
    	// Set Audio PID {0x103}
350
	/* compute PAT */
351
	memcpy(localPAT, PAT, sizeof(PAT));
352
	localPAT[17] = 0xe0 | ((h->params.ts_pid_pmt >> 8) & 0x0f);
353
	localPAT[18] = h->params.ts_pid_pmt & 0xff;
354
	crc = crc32_be(~0, &localPAT[7], sizeof(PAT) - 7 - 4);
355
	localPAT[sizeof(PAT) - 4] = (crc >> 24) & 0xFF;
356
	localPAT[sizeof(PAT) - 3] = (crc >> 16) & 0xFF;
357
	localPAT[sizeof(PAT) - 2] = (crc >> 8) & 0xFF;
358
	localPAT[sizeof(PAT) - 1] = crc & 0xFF;
359
360
	/* compute PMT */
361
      	memcpy(localPMT, PMT, sizeof(PMT));
362
   	localPMT[3] = 0x40 | ((h->params.ts_pid_pmt >> 8) & 0x0f);
363
   	localPMT[4] = h->params.ts_pid_pmt & 0xff;
364
	localPMT[15] = 0xE0 | ((h->params.ts_pid_pcr >> 8) & 0x0F);
365
	localPMT[16] = h->params.ts_pid_pcr & 0xFF;
366
	localPMT[20] = 0xE0 | ((h->params.ts_pid_video >> 8) & 0x0F);
367
	localPMT[21] = h->params.ts_pid_video & 0xFF;
368
	localPMT[25] = 0xE0 | ((h->params.ts_pid_audio >> 8) & 0x0F);
369
	localPMT[26] = h->params.ts_pid_audio & 0xFF;
370
	crc = crc32_be(~0, &localPMT[7], sizeof(PMT) - 7 - 4);
371
	localPMT[sizeof(PMT) - 4] = (crc >> 24) & 0xFF;
372
	localPMT[sizeof(PMT) - 3] = (crc >> 16) & 0xFF;
373
	localPMT[sizeof(PMT) - 2] = (crc >> 8) & 0xFF;
374
	localPMT[sizeof(PMT) - 1] = crc & 0xFF;
375
376
    	// Set Audio PID
277
	buf[0] = 0xC1;
377
	buf[0] = 0xC1;
278
	buf[1] = 0x01;
378
	buf[1] = (h->params.ts_pid_audio >> 8) & 0xFF;
279
	buf[2] = 0x03;
379
	buf[2] = h->params.ts_pid_audio & 0xFF;
280
	i2c_master_send(client,buf,3);
380
	i2c_master_send(client,buf,3);
281
381
282
        // setup bitrate settings
382
	// Set Video PID
283
	data = i2c_get_clientdata(client);
383
	buf[0] = 0xC0;
284
	if (params) {
384
	buf[1] = (h->params.ts_pid_video >> 8) & 0xFF;
285
		saa6752hs_set_bitrate(client, params);
385
	buf[2] = h->params.ts_pid_video & 0xFF;
286
		memcpy(data, params, sizeof(struct mpeg_params));
386
	i2c_master_send(client,buf,3);
287
	} else {
387
288
		// parameters were not supplied. use the previous set
388
 	// Set PCR PID
289
   		saa6752hs_set_bitrate(client, (struct mpeg_params*) data);
389
	buf[0] = 0xC4;
290
	}
390
	buf[1] = (h->params.ts_pid_pcr >> 8) & 0xFF;
391
	buf[2] = h->params.ts_pid_pcr & 0xFF;
392
	i2c_master_send(client,buf,3);
291
393
292
	// Send SI tables
394
	// Send SI tables
293
  	i2c_master_send(client,PAT,sizeof(PAT));
395
	i2c_master_send(client,localPAT,sizeof(PAT));
294
  	i2c_master_send(client,PMT,sizeof(PMT));
396
	i2c_master_send(client,localPMT,sizeof(PMT));
295
397
296
	// mute then unmute audio. This removes buzzing artefacts
398
	// mute then unmute audio. This removes buzzing artefacts
297
	buf[0] = 0xa4;
399
	buf[0] = 0xa4;
Lines 303-333 static int saa6752hs_init(struct i2c_cli Link Here
303
	// start it going
405
	// start it going
304
	saa6752hs_chip_command(client, SAA6752HS_COMMAND_START);
406
	saa6752hs_chip_command(client, SAA6752HS_COMMAND_START);
305
407
408
	// readout current state
409
	buf[0] = 0xE1;
410
	buf[1] = 0xA7;
411
	buf[2] = 0xFE;
412
	buf[3] = 0x82;
413
	buf[4] = 0xB0;
414
	i2c_master_send(client, buf, 5);
415
	i2c_master_recv(client, buf2, 4);
416
417
	// change aspect ratio
418
	buf[0] = 0xE0;
419
	buf[1] = 0xA7;
420
	buf[2] = 0xFE;
421
	buf[3] = 0x82;
422
	buf[4] = 0xB0;
423
	buf[5] = buf2[0];
424
	switch(h->params.vi_aspect_ratio) {
425
	case V4L2_MPEG_ASPECT_16_9:
426
		buf[6] = buf2[1] | 0x40;
427
		break;
428
	case V4L2_MPEG_ASPECT_4_3:
429
	default:
430
		buf[6] = buf2[1] & 0xBF;
431
		break;
432
		break;
433
	}
434
	buf[7] = buf2[2];
435
	buf[8] = buf2[3];
436
	i2c_master_send(client, buf, 9);
437
438
   	// return success
306
	return 0;
439
	return 0;
307
}
440
}
308
441
309
static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
442
static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
310
{
443
{
311
	struct i2c_client *client;
444
	struct saa6752hs_state *h;
312
	struct mpeg_params* params;
313
314
        client_template.adapter = adap;
315
        client_template.addr = addr;
316
445
317
        printk("saa6752hs: chip found @ 0x%x\n", addr<<1);
446
        printk("saa6752hs: chip found @ 0x%x\n", addr<<1);
318
447
319
        if (NULL == (client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)))
448
        if (NULL == (h = kmalloc(sizeof(*h), GFP_KERNEL)))
320
                return -ENOMEM;
449
                return -ENOMEM;
321
        memcpy(client,&client_template,sizeof(struct i2c_client));
450
	memset(h,0,sizeof(*h));
322
	strlcpy(client->name, "saa6752hs", sizeof(client->name));
451
	h->client = client_template;
323
452
	h->params = param_defaults;
324
	if (NULL == (params = kmalloc(sizeof(struct mpeg_params), GFP_KERNEL)))
453
	h->client.adapter = adap;
325
		return -ENOMEM;
454
	h->client.addr = addr;
326
	memcpy(params,&mpeg_params_template,sizeof(struct mpeg_params));
327
	i2c_set_clientdata(client, params);
328
329
        i2c_attach_client(client);
330
455
456
	i2c_set_clientdata(&h->client, h);
457
        i2c_attach_client(&h->client);
331
	return 0;
458
	return 0;
332
}
459
}
333
460
Lines 340-369 static int saa6752hs_probe(struct i2c_ad Link Here
340
467
341
static int saa6752hs_detach(struct i2c_client *client)
468
static int saa6752hs_detach(struct i2c_client *client)
342
{
469
{
343
	void *data;
470
	struct saa6752hs_state *h;
344
471
345
	data = i2c_get_clientdata(client);
472
	h = i2c_get_clientdata(client);
346
	i2c_detach_client(client);
473
	i2c_detach_client(client);
347
	kfree(data);
474
	kfree(h);
348
	kfree(client);
349
	return 0;
475
	return 0;
350
}
476
}
351
477
352
static int
478
static int
353
saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
479
saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
354
{
480
{
355
	struct mpeg_params* init_arg = arg;
481
	struct saa6752hs_state *h = i2c_get_clientdata(client);
482
	struct v4l2_mpeg_compression *params = arg;
483
	int err = 0;
356
484
357
        switch (cmd) {
485
        switch (cmd) {
358
	case MPEG_SETPARAMS:
486
	case VIDIOC_S_MPEGCOMP:
359
   		return saa6752hs_init(client, init_arg);
487
		if (NULL == params) {
360
488
			/* apply settings and start encoder */
489
			saa6752hs_init(client);
490
			break;
491
		}
492
		saa6752hs_set_params(client, params);
493
		/* fall through */
494
	case VIDIOC_G_MPEGCOMP:
495
		*params = h->params;
496
		break;
361
	default:
497
	default:
362
		/* nothing */
498
		/* nothing */
363
		break;
499
		break;
364
	}
500
	}
365
501
366
	return 0;
502
	return err;
367
}
503
}
368
504
369
/* ----------------------------------------------------------------------- */
505
/* ----------------------------------------------------------------------- */
Lines 380-386 static struct i2c_driver driver = { Link Here
380
516
381
static struct i2c_client client_template =
517
static struct i2c_client client_template =
382
{
518
{
383
	I2C_DEVNAME("(saa6752hs unset)"),
519
	I2C_DEVNAME("saa6752hs"),
384
	.flags      = I2C_CLIENT_ALLOW_USE,
520
	.flags      = I2C_CLIENT_ALLOW_USE,
385
        .driver     = &driver,
521
        .driver     = &driver,
386
};
522
};
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-cards.c (-38 / +362 lines)
Lines 1-5 Link Here
1
1
/*
2
/*
2
 * $Id: saa7134-cards.c,v 1.35 2004/11/07 14:44:59 kraxel Exp $
3
 * $Id: saa7134-cards.c,v 1.54 2005/03/07 12:01:51 kraxel Exp $
3
 *
4
 *
4
 * device driver for philips saa7134 based TV cards
5
 * device driver for philips saa7134 based TV cards
5
 * card-specific stuff.
6
 * card-specific stuff.
Lines 156-166 struct saa7134_board saa7134_boards[] = Link Here
156
			.gpio = 0x8000,
157
			.gpio = 0x8000,
157
		},
158
		},
158
	},
159
	},
159
	[SAA7134_BOARD_FLYTVPLATINUM] = {
160
	[SAA7134_BOARD_FLYTVPLATINUM_MINI] = {
160
		/* "Arnaud Quette" <aquette@free.fr> */
161
		/* "Arnaud Quette" <aquette@free.fr> */
161
		.name           = "LifeView FlyTV Platinum",
162
		.name           = "LifeView FlyTV Platinum Mini",
162
		.audio_clock    = 0x00200000,
163
		.audio_clock    = 0x00200000,
163
		.tuner_type     = TUNER_PHILIPS_SECAM,
164
		.tuner_type     = TUNER_PHILIPS_TDA8290,
164
		.inputs         = {{
165
		.inputs         = {{
165
			.name = name_tv,
166
			.name = name_tv,
166
			.vmux = 1,
167
			.vmux = 1,
Lines 176-181 struct saa7134_board saa7134_boards[] = Link Here
176
			.amux = LINE2,
177
			.amux = LINE2,
177
		}},
178
		}},
178
	},
179
	},
180
	[SAA7134_BOARD_FLYTVPLATINUM_FM] = {
181
		/* LifeView FlyTV Platinum FM (LR214WF) */
182
		/* "Peter Missel <peter.missel@onlinehome.de> */
183
		.name           = "LifeView FlyTV Platinum FM",
184
		.audio_clock    = 0x00200000,
185
		.tuner_type     = TUNER_PHILIPS_TDA8290,
186
//		.gpiomask       = 0xe000,
187
		.inputs         = {{
188
			.name = name_tv,
189
			.vmux = 1,
190
			.amux = TV,
191
//			.gpio = 0x0000,
192
			.tv   = 1,
193
                },{
194
/*			.name = name_tv_mono,
195
			.vmux = 1,
196
			.amux = LINE2,
197
			.gpio = 0x0000,
198
			.tv   = 1,
199
		},{
200
*/			.name = name_comp1,	/* Composite signal on S-Video input */
201
			.vmux = 0,
202
			.amux = LINE2,
203
//			.gpio = 0x4000,
204
		},{
205
			.name = name_comp2,	/* Composite input */
206
			.vmux = 3,
207
			.amux = LINE2,
208
//			.gpio = 0x4000,
209
		},{
210
			.name = name_svideo,	/* S-Video signal on S-Video input */
211
			.vmux = 8,
212
			.amux = LINE2,
213
//			.gpio = 0x4000,
214
		}},
215
/*		.radio = {
216
			.name = name_radio,
217
			.amux = LINE2,
218
			.gpio = 0x2000,
219
		},
220
*/	},
179
	[SAA7134_BOARD_EMPRESS] = {
221
	[SAA7134_BOARD_EMPRESS] = {
180
		/* "Gert Vervoort" <gert.vervoort@philips.com> */
222
		/* "Gert Vervoort" <gert.vervoort@philips.com> */
181
		.name		= "EMPRESS",
223
		.name		= "EMPRESS",
Lines 436-441 struct saa7134_board saa7134_boards[] = Link Here
436
		.audio_clock    = 0x00187de7,
478
		.audio_clock    = 0x00187de7,
437
		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
479
		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
438
		.tda9887_conf   = TDA9887_PRESENT,
480
		.tda9887_conf   = TDA9887_PRESENT,
481
		.mpeg           = SAA7134_MPEG_DVB,
439
		.inputs = {{
482
		.inputs = {{
440
			.name   = name_tv,
483
			.name   = name_tv,
441
			.vmux   = 1,
484
			.vmux   = 1,
Lines 444-454 struct saa7134_board saa7134_boards[] = Link Here
444
		},{
487
		},{
445
			.name   = name_comp1,
488
			.name   = name_comp1,
446
			.vmux   = 0,
489
			.vmux   = 0,
447
			.amux   = LINE2,
490
			.amux   = LINE1,
448
		},{
491
		},{
449
			.name   = name_svideo,
492
			.name   = name_svideo,
450
			.vmux   = 8,
493
			.vmux   = 8,
451
			.amux   = LINE2,
494
			.amux   = LINE1,
452
		}},
495
		}},
453
		.radio = {
496
		.radio = {
454
			.name   = name_radio,
497
			.name   = name_radio,
Lines 544-549 struct saa7134_board saa7134_boards[] = Link Here
544
                        .amux = LINE1,
587
                        .amux = LINE1,
545
                },
588
                },
546
	},
589
	},
590
	[SAA7135_BOARD_ASUSTeK_TVFM7135] = {
591
                .name           = "ASUS TV-FM 7135",
592
                .audio_clock    = 0x00187de7,
593
                .tuner_type     = TUNER_PHILIPS_TDA8290,
594
		.gpiomask       = 0x200000,
595
                .inputs         = {{
596
                        .name = name_tv,
597
                        .vmux = 1,
598
                        .amux = TV,
599
			.gpio = 0x0000,
600
                        .tv   = 1,
601
                },{
602
                        .name = name_comp1,
603
                        .vmux = 4,
604
                        .amux = LINE2,
605
			.gpio = 0x0000,
606
                },{
607
                        .name = name_svideo,
608
                        .vmux = 6,
609
                        .amux = LINE2,
610
			.gpio = 0x0000,
611
                }},
612
                .radio = {
613
                        .name = name_radio,
614
                        .amux = TV,
615
			.gpio = 0x200000,
616
                },
617
	},
547
	[SAA7134_BOARD_VA1000POWER] = {
618
	[SAA7134_BOARD_VA1000POWER] = {
548
                .name           = "AOPEN VA1000 POWER",
619
                .name           = "AOPEN VA1000 POWER",
549
		.audio_clock    = 0x00187de7,
620
		.audio_clock    = 0x00187de7,
Lines 749-755 struct saa7134_board saa7134_boards[] = Link Here
749
		},{
820
		},{
750
			.name = name_tv,
821
			.name = name_tv,
751
			.vmux = 3,
822
			.vmux = 3,
752
			.amux = LINE2,
823
			.amux = TV,
753
			.tv   = 1,
824
			.tv   = 1,
754
		}},
825
		}},
755
		.mpeg      = SAA7134_MPEG_EMPRESS,
826
		.mpeg      = SAA7134_MPEG_EMPRESS,
Lines 828-833 struct saa7134_board saa7134_boards[] = Link Here
828
			.name = name_radio,
899
			.name = name_radio,
829
			.amux = LINE2,
900
			.amux = LINE2,
830
		},
901
		},
902
		.mute = {
903
			.name = name_mute,
904
                        .amux = LINE1,
905
		},
831
	},
906
	},
832
	[SAA7134_BOARD_MANLI_MTV001] = {
907
	[SAA7134_BOARD_MANLI_MTV001] = {
833
		/* Ognjen Nastic <ognjen@logosoft.ba> UNTESTED */
908
		/* Ognjen Nastic <ognjen@logosoft.ba> UNTESTED */
Lines 975-980 struct saa7134_board saa7134_boards[] = Link Here
975
		.inputs         = {{
1050
		.inputs         = {{
976
			.name = name_comp1,
1051
			.name = name_comp1,
977
			.vmux = 3,
1052
			.vmux = 3,
1053
		},{
1054
			.name = name_svideo,
1055
			.vmux = 8,
978
		}},
1056
		}},
979
	},
1057
	},
980
        [SAA7134_BOARD_NOVAC_PRIMETV7133] = {
1058
        [SAA7134_BOARD_NOVAC_PRIMETV7133] = {
Lines 995-1005 struct saa7134_board saa7134_boards[] = Link Here
995
                        .vmux = 8,
1073
                        .vmux = 8,
996
                }},
1074
                }},
997
        },
1075
        },
998
	[SAA7134_BOARD_AVERMEDIA_305] = {
1076
	[SAA7134_BOARD_AVERMEDIA_STUDIO_305] = {
999
		.name           = "AverMedia 305",
1077
		.name           = "AverMedia AverTV Studio 305",
1000
		.audio_clock    = 0x00187de7,
1078
		.audio_clock    = 0x00187de7,
1001
		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
1079
		.tuner_type     = TUNER_PHILIPS_FM1256_IH3,
1002
		.tda9887_conf   = TDA9887_PRESENT,
1080
		.tda9887_conf   = TDA9887_PRESENT,
1081
		.gpiomask = 0x3,
1003
		.inputs         = {{
1082
		.inputs         = {{
1004
			.name = name_tv,
1083
			.name = name_tv,
1005
			.vmux = 1,
1084
			.vmux = 1,
Lines 1104-1126 struct saa7134_board saa7134_boards[] = Link Here
1104
                        .name = name_svideo,
1183
                        .name = name_svideo,
1105
                        .vmux = 8,
1184
                        .vmux = 8,
1106
                        .amux = LINE1,
1185
                        .amux = LINE1,
1107
			.gpio = 0x00080
1186
			.gpio = 0x00080,
1108
                },{
1187
                },{
1109
                        .name = name_comp1,
1188
                        .name = name_comp1,
1110
                        .vmux = 3,
1189
                        .vmux = 3,
1111
                        .amux = LINE1,
1190
                        .amux = LINE1,
1112
			.gpio = 0x00080
1191
			.gpio = 0x00080,
1113
                },{
1192
                },{
1114
                        .name = name_tv,
1193
                        .name = name_tv,
1115
                        .vmux = 1,
1194
                        .vmux = 1,
1116
                        .amux = LINE2,
1195
                        .amux = LINE2_LEFT,
1117
                        .tv   = 1,
1196
                        .tv   = 1,
1118
			.gpio = 0x00080
1197
			.gpio = 0x00080,
1119
                }},
1198
                }},
1120
		.radio = {
1199
		.radio = {
1121
			 .name = name_radio,
1200
			.name = name_radio,
1122
			 .amux = LINE2,
1201
			.amux = LINE2,
1123
			.gpio = 0x80000
1202
			.gpio = 0x80000,
1124
		 },
1203
		 },
1125
		.mute = {
1204
		.mute = {
1126
			.name = name_mute,
1205
			.name = name_mute,
Lines 1129-1149 struct saa7134_board saa7134_boards[] = Link Here
1129
		},
1208
		},
1130
        },
1209
        },
1131
        [SAA7134_BOARD_SABRENT_SBTTVFM] = {
1210
        [SAA7134_BOARD_SABRENT_SBTTVFM] = {
1132
		/* Michael Rodriguez-Torrent */
1211
		/* Michael Rodriguez-Torrent <mrtorrent@asu.edu> */
1133
                .name           = "Sabrent SBT-TVFM (saa7130)",
1212
                .name           = "Sabrent SBT-TVFM (saa7130)",
1134
                .audio_clock    = 0x00187de7,
1213
                .audio_clock    = 0x00187de7,
1135
                .tuner_type     = TUNER_PHILIPS_NTSC_M,
1214
                .tuner_type     = TUNER_PHILIPS_NTSC_M,
1136
  		.tda9887_conf   = TDA9887_PRESENT,
1137
                .inputs         = {{
1215
                .inputs         = {{
1216
			.name = name_comp1,
1217
			.vmux = 1,
1218
			.amux = LINE2,
1219
		},{
1138
                        .name = name_tv,
1220
                        .name = name_tv,
1139
                        .vmux = 3,
1221
                        .vmux = 3,
1140
                        .amux = LINE2,
1222
                        .amux = LINE2,
1141
                        .tv   = 1,
1223
                        .tv   = 1,
1142
                },{
1224
                },{
1143
                        .name = name_comp1,
1144
                        .vmux = 1,
1145
                        .amux = LINE2,
1146
                },{
1147
                        .name = name_svideo,
1225
                        .name = name_svideo,
1148
                        .vmux = 8,
1226
                        .vmux = 8,
1149
                        .amux = LINE2,
1227
                        .amux = LINE2,
Lines 1208-1239 struct saa7134_board saa7134_boards[] = Link Here
1208
		 }
1286
		 }
1209
	},
1287
	},
1210
        [SAA7134_BOARD_AVERMEDIA_307] = {
1288
        [SAA7134_BOARD_AVERMEDIA_307] = {
1211
		/* Nickolay V. Shmyrev <nshmyrev@yandex.ru> */
1289
		/*
1290
		Nickolay V. Shmyrev <nshmyrev@yandex.ru>
1291
		Lots of thanks to Andrey Zolotarev <zolotarev_andrey@mail.ru>
1292
		*/
1212
		.name           = "Avermedia AVerTV Studio 307",
1293
		.name           = "Avermedia AVerTV Studio 307",
1213
		.audio_clock    = 0x00187de7,
1294
		.audio_clock    = 0x00187de7,
1214
		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
1295
		.tuner_type     = TUNER_PHILIPS_FM1256_IH3,
1215
		.tda9887_conf   = TDA9887_PRESENT,
1296
		.tda9887_conf   = TDA9887_PRESENT,
1297
		.gpiomask       = 0x03,
1216
		.inputs         = {{
1298
		.inputs         = {{
1217
			.name = name_tv,
1299
			.name = name_tv,
1218
			.vmux = 1,
1300
			.vmux = 1,
1219
			.amux = TV,
1301
			.amux = TV,
1220
			.tv   = 1,
1302
			.tv   = 1,
1303
			.gpio = 0x00,
1221
		},{
1304
		},{
1222
			.name = name_comp1,
1305
			.name = name_comp1,
1223
			.vmux = 0,
1306
			.vmux = 0,
1224
			.amux = LINE2,
1307
			.amux = LINE2,
1308
			.gpio = 0x00,
1225
		},{
1309
		},{
1226
			.name = name_comp2,
1310
			.name = name_comp2,
1227
			.vmux = 3,
1311
			.vmux = 3,
1228
			.amux = LINE2,
1312
			.amux = LINE2,
1313
			.gpio = 0x00,
1229
		},{
1314
		},{
1230
			.name = name_svideo,
1315
			.name = name_svideo,
1231
			.vmux = 8,
1316
			.vmux = 8,
1232
			.amux = LINE2,
1317
			.amux = LINE2,
1318
			.gpio = 0x00,
1233
		}},
1319
		}},
1234
		.radio = {
1320
		.radio = {
1235
			.name = name_radio,
1321
			.name = name_radio,
1236
			.amux = TV,
1322
			.amux = LINE1,
1323
			.gpio = 0x01,
1237
		},
1324
		},
1238
        },
1325
        },
1239
	[SAA7134_BOARD_AVERMEDIA_CARDBUS] = {
1326
	[SAA7134_BOARD_AVERMEDIA_CARDBUS] = {
Lines 1263-1272 struct saa7134_board saa7134_boards[] = Link Here
1263
	[SAA7134_BOARD_CINERGY400_CARDBUS] = {
1350
	[SAA7134_BOARD_CINERGY400_CARDBUS] = {
1264
		.name           = "Terratec Cinergy 400 mobile",
1351
		.name           = "Terratec Cinergy 400 mobile",
1265
		.audio_clock    = 0x187de7,
1352
		.audio_clock    = 0x187de7,
1266
		.tuner_type     = UNSET /* not supported yet :/ */,
1353
		.tuner_type     = TUNER_ALPS_TSBE5_PAL,
1354
  		.tda9887_conf   = TDA9887_PRESENT,
1267
		.inputs         = {{
1355
		.inputs         = {{
1268
       			.name = name_tv,
1356
       			.name = name_tv,
1269
			.vmux = 5,
1357
			.vmux = 1,
1358
			.amux = TV,
1359
			.tv   = 1,
1360
               },{
1361
			.name = name_tv_mono,
1362
			.vmux = 1,
1363
			.amux = LINE2,
1270
			.tv   = 1,
1364
			.tv   = 1,
1271
                },{
1365
                },{
1272
                        .name = name_comp1,
1366
                        .name = name_comp1,
Lines 1274-1281 struct saa7134_board saa7134_boards[] = Link Here
1274
                        .amux = LINE1,
1368
                        .amux = LINE1,
1275
                },{
1369
                },{
1276
                        .name = name_svideo,
1370
                        .name = name_svideo,
1371
                        .vmux = 8,
1372
                        .amux = LINE1,
1373
		}},
1374
	},
1375
	[SAA7134_BOARD_CINERGY600_MK3] = {
1376
                .name           = "Terratec Cinergy 600 TV MK3",
1377
                .audio_clock    = 0x00200000,
1378
		.tuner_type	= TUNER_PHILIPS_FM1216ME_MK3,
1379
  		.tda9887_conf   = TDA9887_PRESENT,
1380
                .inputs         = {{
1381
                        .name = name_tv,
1382
                        .vmux = 1,
1383
                        .amux = TV,
1384
                        .tv   = 1,
1385
                },{
1386
                        .name = name_comp1,
1277
                        .vmux = 4,
1387
                        .vmux = 4,
1278
                        .amux = LINE1,
1388
                        .amux = LINE1,
1389
                },{
1390
                        .name = name_svideo,
1391
                        .vmux = 8,
1392
                        .amux = LINE1,
1393
                },{
1394
                        .name = name_comp2, // CVideo over SVideo Connector
1395
                        .vmux = 0,
1396
                        .amux = LINE1,
1397
                }},
1398
		.radio = {
1399
			.name = name_radio,
1400
			.amux = LINE2,
1401
               },
1402
        },
1403
 	[SAA7134_BOARD_VIDEOMATE_GOLD_PLUS] = {
1404
 		/* Dylan Walkden <dylan_walkden@hotmail.com> */
1405
 		.name		= "Compro VideoMate Gold+ Pal",
1406
 		.audio_clock	= 0x00187de7,
1407
 		.tuner_type	= TUNER_PHILIPS_PAL,
1408
 		.gpiomask	= 0x1ce780,
1409
 		.inputs		= {{
1410
 			.name = name_svideo,
1411
 			.vmux = 0,		// CVideo over SVideo Connector - ok?
1412
 			.amux = LINE1,
1413
 			.gpio = 0x008080,
1414
 		},{
1415
 			.name = name_comp1,
1416
 			.vmux = 3,
1417
 			.amux = LINE1,
1418
 			.gpio = 0x008080,
1419
 		},{
1420
 			.name = name_tv,
1421
 			.vmux = 1,
1422
 			.amux = TV,
1423
 			.tv   = 1,
1424
 			.gpio = 0x008080,
1425
 		}},
1426
 		.radio = {
1427
 			.name = name_radio,
1428
 			.amux = LINE2,
1429
 			.gpio = 0x80000,
1430
 		},
1431
 		.mute = {
1432
 			.name = name_mute,
1433
 			.amux = LINE2,
1434
 			.gpio = 0x0c8000,
1435
 		},
1436
 	},
1437
	[SAA7134_BOARD_PINNACLE_300I_DVBT_PAL] = {
1438
                .name           = "Pinnacle PCTV 300i DVB-T + PAL",
1439
                .audio_clock    = 0x00187de7,
1440
                .tuner_type     = TUNER_MT2032,
1441
                .tda9887_conf   = TDA9887_PRESENT | TDA9887_INTERCARRIER,
1442
		.mpeg           = SAA7134_MPEG_DVB,
1443
                .inputs         = {{
1444
                        .name = name_tv,
1445
                        .vmux = 3,
1446
                        .amux = TV,
1447
                        .tv   = 1,
1448
                },{
1449
                        .name = name_comp1,
1450
                        .vmux = 0,
1451
                        .amux = LINE2,
1452
                },{
1453
                        .name = name_comp2,
1454
                        .vmux = 1,
1455
                        .amux = LINE2,
1456
                },{
1457
                        .name = name_svideo,
1458
                        .vmux = 8,
1459
                        .amux = LINE2,
1460
                }},
1461
        },
1462
	[SAA7134_BOARD_PROVIDEO_PV952] = {
1463
		/* andreas.kretschmer@web.de */
1464
		.name		= "ProVideo PV952",
1465
		.audio_clock	= 0x00187de7,
1466
		.tuner_type	= TUNER_PHILIPS_FM1216ME_MK3,
1467
		.tda9887_conf   = TDA9887_PRESENT,
1468
		.inputs         = {{
1469
			.name = name_comp1,
1470
			.vmux = 0,
1471
			.amux = LINE1,
1472
		},{
1473
			.name = name_tv,
1474
			.vmux = 1,
1475
			.amux = TV,
1476
			.tv   = 1,
1477
		},{
1478
			.name = name_tv_mono,
1479
			.vmux = 1,
1480
			.amux = LINE2,
1481
			.tv   = 1,
1482
		}},
1483
		.radio = {
1484
			.name = name_radio,
1485
			.amux = LINE2,
1486
		},
1487
	},
1488
	[SAA7134_BOARD_AVERMEDIA_305] = {
1489
		/* much like the "studio" version but without radio
1490
		 * and another tuner (sirspiritus@yandex.ru) */
1491
		.name           = "AverMedia AverTV/305",
1492
		.audio_clock    = 0x00187de7,
1493
		.tuner_type     = TUNER_PHILIPS_FQ1216ME,
1494
		.tda9887_conf   = TDA9887_PRESENT,
1495
		.gpiomask = 0x3,
1496
		.inputs         = {{
1497
			.name = name_tv,
1498
			.vmux = 1,
1499
			.amux = LINE2,
1500
			.tv   = 1,
1501
		},{
1502
			.name = name_comp1,
1503
			.vmux = 0,
1504
			.amux = LINE2,
1505
		},{
1506
			.name = name_comp2,
1507
			.vmux = 3,
1508
			.amux = LINE2,
1509
		},{
1510
			.name = name_svideo,
1511
			.vmux = 8,
1512
			.amux = LINE2,
1513
		}},
1514
		.mute = {
1515
			 .name = name_mute,
1516
			 .amux = LINE1,
1517
		},
1518
	},
1519
	[SAA7134_BOARD_FLYDVBTDUO] = {
1520
		/* LifeView FlyDVB-T DUO */
1521
		/* "Nico Sabbi <nsabbi@tiscali.it> */
1522
		.name           = "LifeView FlyDVB-T DUO",
1523
		.audio_clock    = 0x00200000,
1524
		.tuner_type     = TUNER_PHILIPS_TDA8290,
1525
//		.gpiomask       = 0xe000,
1526
		.inputs         = {{
1527
			.name = name_tv,
1528
			.vmux = 1,
1529
			.amux = TV,
1530
//			.gpio = 0x0000,
1531
			.tv   = 1,
1532
                },{
1533
			.name = name_comp1,	/* Composite signal on S-Video input */
1534
			.vmux = 0,
1535
			.amux = LINE2,
1536
//			.gpio = 0x4000,
1537
		},{
1538
			.name = name_comp2,	/* Composite input */
1539
			.vmux = 3,
1540
			.amux = LINE2,
1541
//			.gpio = 0x4000,
1542
		},{
1543
			.name = name_svideo,	/* S-Video signal on S-Video input */
1544
			.vmux = 8,
1545
			.amux = LINE2,
1546
//			.gpio = 0x4000,
1279
		}},
1547
		}},
1280
	},
1548
	},
1281
};
1549
};
Lines 1322-1327 struct pci_device_id saa7134_pci_tbl[] = Link Here
1322
                .subdevice    = 0x1143,
1590
                .subdevice    = 0x1143,
1323
                .driver_data  = SAA7134_BOARD_CINERGY600,
1591
                .driver_data  = SAA7134_BOARD_CINERGY600,
1324
        },{
1592
        },{
1593
                .vendor       = PCI_VENDOR_ID_PHILIPS,
1594
                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1595
                .subvendor    = 0x153B,
1596
                .subdevice    = 0x1158,
1597
                .driver_data  = SAA7134_BOARD_CINERGY600_MK3,
1598
        },{
1325
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1599
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1326
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
1600
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
1327
		.subvendor    = 0x153b,
1601
		.subvendor    = 0x153b,
Lines 1349-1356 struct pci_device_id saa7134_pci_tbl[] = Link Here
1349
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1623
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1350
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7135,
1624
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7135,
1351
		.subvendor    = 0x5168,
1625
		.subvendor    = 0x5168,
1352
		.subdevice    = 0x0212,
1626
		.subdevice    = 0x0212, /* minipci, LR212 */
1353
		.driver_data  = SAA7134_BOARD_FLYTVPLATINUM,
1627
		.driver_data  = SAA7134_BOARD_FLYTVPLATINUM_MINI,
1628
        },{
1629
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1630
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
1631
		.subvendor    = 0x5168,
1632
		.subdevice    = 0x0214, /* Standard PCI, LR214WF */
1633
		.driver_data  = SAA7134_BOARD_FLYTVPLATINUM_FM,
1354
        },{
1634
        },{
1355
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1635
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1356
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1636
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
Lines 1377-1382 struct pci_device_id saa7134_pci_tbl[] = Link Here
1377
                .driver_data  = SAA7134_BOARD_ASUSTeK_TVFM7134,
1657
                .driver_data  = SAA7134_BOARD_ASUSTeK_TVFM7134,
1378
	},{
1658
	},{
1379
                .vendor       = PCI_VENDOR_ID_PHILIPS,
1659
                .vendor       = PCI_VENDOR_ID_PHILIPS,
1660
                .device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
1661
                .subvendor    = PCI_VENDOR_ID_ASUSTEK,
1662
                .subdevice    = 0x4845,
1663
                .driver_data  = SAA7135_BOARD_ASUSTeK_TVFM7135,
1664
	},{
1665
                .vendor       = PCI_VENDOR_ID_PHILIPS,
1380
                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1666
                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1381
                .subvendor    = PCI_VENDOR_ID_ASUSTEK,
1667
                .subvendor    = PCI_VENDOR_ID_ASUSTEK,
1382
                .subdevice    = 0x4830,
1668
                .subdevice    = 0x4830,
Lines 1452-1457 struct pci_device_id saa7134_pci_tbl[] = Link Here
1452
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
1738
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
1453
                .subvendor    = 0x1461, /* Avermedia Technologies Inc */
1739
                .subvendor    = 0x1461, /* Avermedia Technologies Inc */
1454
                .subdevice    = 0x2115,
1740
                .subdevice    = 0x2115,
1741
		.driver_data  = SAA7134_BOARD_AVERMEDIA_STUDIO_305,
1742
	},{
1743
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1744
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
1745
                .subvendor    = 0x1461, /* Avermedia Technologies Inc */
1746
                .subdevice    = 0x2108,
1455
		.driver_data  = SAA7134_BOARD_AVERMEDIA_305,
1747
		.driver_data  = SAA7134_BOARD_AVERMEDIA_305,
1456
	},{
1748
	},{
1457
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1749
		.vendor       = PCI_VENDOR_ID_PHILIPS,
Lines 1483-1490 struct pci_device_id saa7134_pci_tbl[] = Link Here
1483
                .vendor       = PCI_VENDOR_ID_PHILIPS,
1775
                .vendor       = PCI_VENDOR_ID_PHILIPS,
1484
                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1776
                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1485
                .subvendor    = 0x11bd,
1777
                .subvendor    = 0x11bd,
1486
                .subdevice    = 0x002d, /* 300i DVB-T + PAL */
1778
                .subdevice    = 0x002d,
1487
                .driver_data  = SAA7134_BOARD_PINNACLE_PCTV_STEREO,
1779
                .driver_data  = SAA7134_BOARD_PINNACLE_300I_DVBT_PAL,
1488
        },{
1780
        },{
1489
                .vendor       = PCI_VENDOR_ID_PHILIPS,
1781
                .vendor       = PCI_VENDOR_ID_PHILIPS,
1490
                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1782
                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
Lines 1509-1528 struct pci_device_id saa7134_pci_tbl[] = Link Here
1509
		.subvendor    = 0x153B,
1801
		.subvendor    = 0x153B,
1510
		.subdevice    = 0x1152,
1802
		.subdevice    = 0x1152,
1511
		.driver_data  = SAA7134_BOARD_CINERGY200,
1803
		.driver_data  = SAA7134_BOARD_CINERGY200,
1512
1513
 	},{
1804
 	},{
1514
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1805
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1515
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
1806
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
1516
                .subvendor    = 0x185b,
1807
                .subvendor    = 0x185b,
1517
                .subdevice    = 0xc100,
1808
                .subdevice    = 0xc100,
1518
		.driver_data  = SAA7134_BOARD_VIDEOMATE_TV_PVR,
1809
		.driver_data  = SAA7134_BOARD_VIDEOMATE_TV_PVR,
1519
1520
 	},{
1810
 	},{
1521
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1811
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1812
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
1813
                .subvendor    = 0x1131,
1814
                .subdevice    = 0,
1815
		.driver_data  = SAA7134_BOARD_SABRENT_SBTTVFM,
1816
	},{
1817
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1522
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1818
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1523
               .subvendor    = 0x1461, /* Avermedia Technologies Inc */
1819
		.subvendor    = 0x1461, /* Avermedia Technologies Inc */
1524
               .subdevice    = 0x9715,
1820
		.subdevice    = 0x9715,
1525
		.driver_data  = SAA7134_BOARD_AVERMEDIA_307,
1821
		.driver_data  = SAA7134_BOARD_AVERMEDIA_307,
1822
	},{
1823
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1824
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1825
		.subvendor    = 0x185b,
1826
		.subdevice    = 0xc200,
1827
		.driver_data  = SAA7134_BOARD_VIDEOMATE_GOLD_PLUS,
1828
        },{
1829
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1830
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
1831
		.subvendor    = 0x1540,
1832
		.subdevice    = 0x9524,
1833
		.driver_data  = SAA7134_BOARD_PROVIDEO_PV952,
1834
1835
 	},{
1836
		.vendor       = PCI_VENDOR_ID_PHILIPS,
1837
		.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
1838
		.subvendor    = 0x5168,
1839
		.subdevice    = 0x0306,
1840
		.driver_data  = SAA7134_BOARD_FLYDVBTDUO,
1526
1841
1527
 	},{
1842
 	},{
1528
		/* --- boards without eeprom + subsystem ID --- */
1843
		/* --- boards without eeprom + subsystem ID --- */
Lines 1631-1646 int saa7134_board_init1(struct saa7134_d Link Here
1631
	case SAA7134_BOARD_FLYVIDEO2000:
1946
	case SAA7134_BOARD_FLYVIDEO2000:
1632
	case SAA7134_BOARD_FLYVIDEO3000:
1947
	case SAA7134_BOARD_FLYVIDEO3000:
1633
		dev->has_remote = 1;
1948
		dev->has_remote = 1;
1634
		/* fall throuth */
1635
	case SAA7134_BOARD_FLYTVPLATINUM:
1636
		board_flyvideo(dev);
1949
		board_flyvideo(dev);
1637
		break;
1950
		break;
1638
	case SAA7134_BOARD_CINERGY400:
1951
	case SAA7134_BOARD_CINERGY400:
1639
	case SAA7134_BOARD_CINERGY600:
1952
	case SAA7134_BOARD_CINERGY600:
1953
	case SAA7134_BOARD_CINERGY600_MK3:
1640
	case SAA7134_BOARD_ECS_TVP3XP:
1954
	case SAA7134_BOARD_ECS_TVP3XP:
1641
	case SAA7134_BOARD_ECS_TVP3XP_4CB5:
1955
	case SAA7134_BOARD_ECS_TVP3XP_4CB5:
1642
	case SAA7134_BOARD_MD2819:
1956
	case SAA7134_BOARD_MD2819:
1957
	case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
1958
	case SAA7134_BOARD_AVERMEDIA_305:
1643
	case SAA7134_BOARD_AVERMEDIA_307:
1959
	case SAA7134_BOARD_AVERMEDIA_307:
1960
//	case SAA7134_BOARD_SABRENT_SBTTVFM:  /* not finished yet */
1961
	case SAA7134_BOARD_VIDEOMATE_TV_PVR:
1644
		dev->has_remote = 1;
1962
		dev->has_remote = 1;
1645
		break;
1963
		break;
1646
	case SAA7134_BOARD_AVACSSMARTTV:
1964
	case SAA7134_BOARD_AVACSSMARTTV:
Lines 1656-1663 int saa7134_board_init1(struct saa7134_d Link Here
1656
		/* power-up tuner chip */
1974
		/* power-up tuner chip */
1657
		saa_andorl(SAA7134_GPIO_GPMODE0 >> 2,   0x00040000, 0x00040000);
1975
		saa_andorl(SAA7134_GPIO_GPMODE0 >> 2,   0x00040000, 0x00040000);
1658
		saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000);
1976
		saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000);
1977
		msleep(1);
1659
		break;
1978
		break;
1660
	}
1979
	}
1980
	if (dev->has_remote)
1981
		dev->irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18  |
1982
				   SAA7134_IRQ2_INTE_GPIO18A |
1983
				   SAA7134_IRQ2_INTE_GPIO16  );
1661
	return 0;
1984
	return 0;
1662
}
1985
}
1663
1986
Lines 1676-1681 int saa7134_board_init2(struct saa7134_d Link Here
1676
			: SAA7134_BOARD_BMK_MPEX_TUNER;
1999
			: SAA7134_BOARD_BMK_MPEX_TUNER;
1677
		if (board == dev->board)
2000
		if (board == dev->board)
1678
			break;
2001
			break;
2002
		dev->board = board;
1679
		printk("%s: board type fixup: %s\n", dev->name,
2003
		printk("%s: board type fixup: %s\n", dev->name,
1680
		       saa7134_boards[dev->board].name);
2004
		       saa7134_boards[dev->board].name);
1681
		dev->tuner_type = saa7134_boards[dev->board].tuner_type;
2005
		dev->tuner_type = saa7134_boards[dev->board].tuner_type;
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-core.c (-18 / +25 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-core.c,v 1.15 2004/11/07 14:44:59 kraxel Exp $
2
 * $Id: saa7134-core.c,v 1.28 2005/02/22 09:56:29 kraxel Exp $
3
 *
3
 *
4
 * device driver for philips saa7134 based TV cards
4
 * device driver for philips saa7134 based TV cards
5
 * driver core
5
 * driver core
Lines 25-30 Link Here
25
#include <linux/init.h>
25
#include <linux/init.h>
26
#include <linux/list.h>
26
#include <linux/list.h>
27
#include <linux/module.h>
27
#include <linux/module.h>
28
#include <linux/moduleparam.h>
28
#include <linux/kernel.h>
29
#include <linux/kernel.h>
29
#include <linux/slab.h>
30
#include <linux/slab.h>
30
#include <linux/kmod.h>
31
#include <linux/kmod.h>
Lines 88-94 MODULE_PARM_DESC(card, "card type"); Link Here
88
static DECLARE_MUTEX(devlist_lock);
89
static DECLARE_MUTEX(devlist_lock);
89
LIST_HEAD(saa7134_devlist);
90
LIST_HEAD(saa7134_devlist);
90
static LIST_HEAD(mops_list);
91
static LIST_HEAD(mops_list);
91
unsigned int saa7134_devcount;
92
static unsigned int saa7134_devcount;
92
93
93
#define dprintk(fmt, arg...)	if (core_debug) \
94
#define dprintk(fmt, arg...)	if (core_debug) \
94
	printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
95
	printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
Lines 620-626 static irqreturn_t saa7134_irq(int irq, Link Here
620
			dump_statusregs(dev);
621
			dump_statusregs(dev);
621
#endif
622
#endif
622
623
623
		if (report & SAA7134_IRQ_REPORT_INTL)
624
		if (report & SAA7134_IRQ_REPORT_RDCAP /* _INTL */)
624
			saa7134_irq_video_intl(dev);
625
			saa7134_irq_video_intl(dev);
625
626
626
		if ((report & SAA7134_IRQ_REPORT_DONE_RA0) &&
627
		if ((report & SAA7134_IRQ_REPORT_DONE_RA0) &&
Lines 642-649 static irqreturn_t saa7134_irq(int irq, Link Here
642
			       SAA7134_IRQ_REPORT_GPIO18)) &&
643
			       SAA7134_IRQ_REPORT_GPIO18)) &&
643
		    dev->remote)
644
		    dev->remote)
644
			saa7134_input_irq(dev);
645
			saa7134_input_irq(dev);
646
	}
645
647
646
	};
647
	if (10 == loop) {
648
	if (10 == loop) {
648
		print_irqstatus(dev,loop,report,status);
649
		print_irqstatus(dev,loop,report,status);
649
		if (report & SAA7134_IRQ_REPORT_PE) {
650
		if (report & SAA7134_IRQ_REPORT_PE) {
Lines 651-656 static irqreturn_t saa7134_irq(int irq, Link Here
651
			printk(KERN_WARNING "%s/irq: looping -- "
652
			printk(KERN_WARNING "%s/irq: looping -- "
652
			       "clearing PE (parity error!) enable bit\n",dev->name);
653
			       "clearing PE (parity error!) enable bit\n",dev->name);
653
			saa_clearl(SAA7134_IRQ2,SAA7134_IRQ2_INTE_PE);
654
			saa_clearl(SAA7134_IRQ2,SAA7134_IRQ2_INTE_PE);
655
		} else if (report & (SAA7134_IRQ_REPORT_GPIO16 |
656
				     SAA7134_IRQ_REPORT_GPIO18)) {
657
			/* disable gpio IRQs */
658
			printk(KERN_WARNING "%s/irq: looping -- "
659
			       "clearing GPIO enable bits\n",dev->name);
660
			saa_clearl(SAA7134_IRQ2, (SAA7134_IRQ2_INTE_GPIO16 |
661
						  SAA7134_IRQ2_INTE_GPIO18));
654
		} else {
662
		} else {
655
			/* disable all irqs */
663
			/* disable all irqs */
656
			printk(KERN_WARNING "%s/irq: looping -- "
664
			printk(KERN_WARNING "%s/irq: looping -- "
Lines 725-744 static int saa7134_hwinit2(struct saa713 Link Here
725
733
726
	/* enable IRQ's */
734
	/* enable IRQ's */
727
	saa_writel(SAA7134_IRQ1, 0);
735
	saa_writel(SAA7134_IRQ1, 0);
728
	saa_writel(SAA7134_IRQ2,
736
	saa_writel(SAA7134_IRQ2, dev->irq2_mask);
729
		   SAA7134_IRQ2_INTE_GPIO18  |
730
		   SAA7134_IRQ2_INTE_GPIO18A |
731
		   SAA7134_IRQ2_INTE_GPIO16  |
732
		   SAA7134_IRQ2_INTE_SC2     |
733
		   SAA7134_IRQ2_INTE_SC1     |
734
		   SAA7134_IRQ2_INTE_SC0     |
735
		   /* SAA7134_IRQ2_INTE_DEC5    |  FIXME: TRIG_ERR ??? */
736
		   SAA7134_IRQ2_INTE_DEC3    |
737
		   SAA7134_IRQ2_INTE_DEC2    |
738
		   /* SAA7134_IRQ2_INTE_DEC1    | */
739
		   SAA7134_IRQ2_INTE_DEC0    |
740
		   SAA7134_IRQ2_INTE_PE      |
741
		   SAA7134_IRQ2_INTE_AR);
742
737
743
	return 0;
738
	return 0;
744
}
739
}
Lines 959-964 static int __devinit saa7134_initdev(str Link Here
959
	}
954
	}
960
955
961
	/* initialize hardware #1 */
956
	/* initialize hardware #1 */
957
   	dev->irq2_mask =
958
		SAA7134_IRQ2_INTE_DEC3    |
959
		SAA7134_IRQ2_INTE_DEC2    |
960
		SAA7134_IRQ2_INTE_DEC1    |
961
		SAA7134_IRQ2_INTE_DEC0    |
962
		SAA7134_IRQ2_INTE_PE      |
963
		SAA7134_IRQ2_INTE_AR;
962
	saa7134_board_init1(dev);
964
	saa7134_board_init1(dev);
963
	saa7134_hwinit1(dev);
965
	saa7134_hwinit1(dev);
964
966
Lines 1060-1065 static int __devinit saa7134_initdev(str Link Here
1060
	}
1062
	}
1061
	list_add_tail(&dev->devlist,&saa7134_devlist);
1063
	list_add_tail(&dev->devlist,&saa7134_devlist);
1062
	up(&devlist_lock);
1064
	up(&devlist_lock);
1065
1066
	/* check for signal */
1067
	saa7134_irq_video_intl(dev);
1063
	return 0;
1068
	return 0;
1064
1069
1065
 fail5:
1070
 fail5:
Lines 1207-1212 static int saa7134_init(void) Link Here
1207
1212
1208
static void saa7134_fini(void)
1213
static void saa7134_fini(void)
1209
{
1214
{
1215
	if (pending_registered)
1216
		unregister_module_notifier(&pending_notifier);
1210
	pci_unregister_driver(&saa7134_pci_driver);
1217
	pci_unregister_driver(&saa7134_pci_driver);
1211
}
1218
}
1212
1219
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-dvb.c (-8 / +183 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-dvb.c,v 1.4 2004/11/07 14:44:59 kraxel Exp $
2
 * $Id: saa7134-dvb.c,v 1.12 2005/02/18 12:28:29 kraxel Exp $
3
 *
3
 *
4
 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
4
 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
5
 *
5
 *
Lines 30-64 Link Here
30
#include "saa7134-reg.h"
30
#include "saa7134-reg.h"
31
#include "saa7134.h"
31
#include "saa7134.h"
32
32
33
#include "dvb-pll.h"
34
#include "mt352.h"
35
#include "mt352_priv.h" /* FIXME */
36
#include "tda1004x.h"
37
33
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
38
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
34
MODULE_LICENSE("GPL");
39
MODULE_LICENSE("GPL");
35
40
41
static unsigned int antenna_pwr = 0;
42
module_param(antenna_pwr, int, 0444);
43
MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
44
36
/* ------------------------------------------------------------------ */
45
/* ------------------------------------------------------------------ */
37
46
38
static int dvb_init(struct saa7134_dev *dev)
47
static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
39
{
48
{
40
	printk("%s: %s\n",dev->name,__FUNCTION__);
49
	u32 ok;
50
51
	if (!on) {
52
		saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
53
		saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
54
		return 0;
55
	}
56
57
	saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
58
	saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
59
	udelay(10);
60
61
	saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 28));
62
	saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
63
	udelay(10);
64
	saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 28));
65
	udelay(10);
66
	ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
67
	printk("%s: %s %s\n", dev->name, __FUNCTION__,
68
	       ok ? "on" : "off");
69
70
	if (!ok)
71
		saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
72
	return ok;
73
}
74
75
static int mt352_pinnacle_init(struct dvb_frontend* fe)
76
{
77
	static u8 clock_config []  = { CLOCK_CTL,  0x3d, 0x28 };
78
	static u8 reset []         = { RESET,      0x80 };
79
	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
80
	static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0xa0 };
81
	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
82
	static u8 fsm_ctl_cfg[]    = { 0x7b,       0x04 };
83
	static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x0f };
84
	static u8 scan_ctl_cfg []  = { SCAN_CTL,   0x0d };
85
	static u8 irq_cfg []       = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
86
	struct saa7134_dev *dev= fe->dvb->priv;
87
88
	printk("%s: %s called\n",dev->name,__FUNCTION__);
89
90
	mt352_write(fe, clock_config,   sizeof(clock_config));
91
	udelay(200);
92
	mt352_write(fe, reset,          sizeof(reset));
93
	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
94
	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
95
	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
96
	mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
97
98
	mt352_write(fe, fsm_ctl_cfg,    sizeof(fsm_ctl_cfg));
99
	mt352_write(fe, scan_ctl_cfg,   sizeof(scan_ctl_cfg));
100
	mt352_write(fe, irq_cfg,        sizeof(irq_cfg));
101
	return 0;
102
}
103
104
static int mt352_pinnacle_pll_set(struct dvb_frontend* fe,
105
				  struct dvb_frontend_parameters* params,
106
				  u8* pllbuf)
107
{
108
	static int on  = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
109
	static int off = TDA9887_PRESENT | TDA9887_PORT2_ACTIVE;
110
	struct saa7134_dev *dev = fe->dvb->priv;
111
	struct v4l2_frequency f;
112
113
	/* set frequency (mt2050) */
114
	f.tuner     = 0;
115
	f.type      = V4L2_TUNER_DIGITAL_TV;
116
	f.frequency = params->frequency / 1000 * 16 / 1000;
117
	saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
118
	saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
119
	saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&off);
120
121
	pinnacle_antenna_pwr(dev, antenna_pwr);
41
122
123
	/* mt352 setup */
124
	mt352_pinnacle_init(fe);
125
	pllbuf[0] = 0xc2;
126
	pllbuf[1] = 0x00;
127
	pllbuf[2] = 0x00;
128
	pllbuf[3] = 0x80;
129
	pllbuf[4] = 0x00;
130
	return 0;
131
}
132
133
static struct mt352_config pinnacle_300i = {
134
	.demod_address = 0x3c >> 1,
135
	.adc_clock     = 20333,
136
	.if2           = 36150,
137
	.no_tuner      = 1,
138
	.demod_init    = mt352_pinnacle_init,
139
	.pll_set       = mt352_pinnacle_pll_set,
140
};
141
142
/* ------------------------------------------------------------------ */
143
144
static int medion_cardbus_init(struct dvb_frontend* fe)
145
{
146
	/* anything to do here ??? */
147
	return 0;
148
}
149
150
static int medion_cardbus_pll_set(struct dvb_frontend* fe,
151
				  struct dvb_frontend_parameters* params)
152
{
153
	struct saa7134_dev *dev = fe->dvb->priv;
154
	struct v4l2_frequency f;
155
156
	/*
157
	 * this instructs tuner.o to set the frequency, the call will
158
	 * end up in tuner_command(), VIDIOC_S_FREQUENCY switch.
159
	 * tda9887.o will see that as well.
160
	 */
161
	f.tuner     = 0;
162
	f.type      = V4L2_TUNER_DIGITAL_TV;
163
	f.frequency = params->frequency / 1000 * 16 / 1000;
164
	saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
165
	return 0;
166
}
167
168
static int fe_request_firmware(struct dvb_frontend* fe,
169
			       const struct firmware **fw, char* name)
170
{
171
	struct saa7134_dev *dev = fe->dvb->priv;
172
	return request_firmware(fw, name, &dev->pci->dev);
173
}
174
	
175
struct tda1004x_config medion_cardbus = {
176
	.demod_address = 0x08,  /* not sure this is correct */
177
	.invert        = 0,
178
        .invert_oclk   = 0,
179
        .pll_init      = medion_cardbus_init,
180
        .pll_set       = medion_cardbus_pll_set,
181
        .request_firmware = fe_request_firmware,
182
};
183
184
/* ------------------------------------------------------------------ */
185
186
static int dvb_init(struct saa7134_dev *dev)
187
{
42
	/* init struct videobuf_dvb */
188
	/* init struct videobuf_dvb */
189
	dev->ts.nr_bufs    = 32;
190
	dev->ts.nr_packets = 32*4;
43
	dev->dvb.name = dev->name;
191
	dev->dvb.name = dev->name;
44
	videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
192
	videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
45
			    dev->pci, &dev->slock,
193
			    dev->pci, &dev->slock,
46
			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
194
			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
47
			    V4L2_FIELD_TOP,
195
			    V4L2_FIELD_ALTERNATE,
48
			    sizeof(struct saa7134_buf),
196
			    sizeof(struct saa7134_buf),
49
			    dev);
197
			    dev);
50
198
51
	/* TODO: init frontend */
199
	switch (dev->board) {
52
	if (NULL == dev->dvb.frontend)
200
	case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
201
		printk("%s: pinnacle 300i dvb setup\n",dev->name);
202
		dev->dvb.frontend = mt352_attach(&pinnacle_300i,
203
						 &dev->i2c_adap);
204
		break;
205
	case SAA7134_BOARD_MD7134:
206
		dev->dvb.frontend = tda10046_attach(&medion_cardbus,
207
						    &dev->i2c_adap);
208
		if (NULL == dev->dvb.frontend)
209
			printk("%s: Hmm, looks like this is the old MD7134 "
210
			       "version without DVB-T support\n",dev->name);
211
		break;
212
	default:
213
		printk("%s: Huh? unknown DVB card?\n",dev->name);
214
		break;
215
	}
216
217
	if (NULL == dev->dvb.frontend) {
218
		printk("%s: frontend initialization failed\n",dev->name);
53
		return -1;
219
		return -1;
220
	}
54
221
55
	/* register everything else */
222
	/* register everything else */
56
	return videobuf_dvb_register(&dev->dvb);
223
	return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
57
}
224
}
58
225
59
static int dvb_fini(struct saa7134_dev *dev)
226
static int dvb_fini(struct saa7134_dev *dev)
60
{
227
{
228
	static int on  = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
229
61
	printk("%s: %s\n",dev->name,__FUNCTION__);
230
	printk("%s: %s\n",dev->name,__FUNCTION__);
231
232
	switch (dev->board) {
233
	case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
234
		/* otherwise we don't detect the tuner on next insmod */
235
		saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
236
		break;
237
	};
62
	videobuf_dvb_unregister(&dev->dvb);
238
	videobuf_dvb_unregister(&dev->dvb);
63
	return 0;
239
	return 0;
64
}
240
}
Lines 86-91 module_exit(dvb_unregister); Link Here
86
/*
262
/*
87
 * Local variables:
263
 * Local variables:
88
 * c-basic-offset: 8
264
 * c-basic-offset: 8
89
 * compile-command: "make DVB=1"
90
 * End:
265
 * End:
91
 */
266
 */
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-empress.c (-9 / +51 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-empress.c,v 1.3 2004/11/07 13:17:15 kraxel Exp $
2
 * $Id: saa7134-empress.c,v 1.10 2005/02/03 10:24:33 kraxel Exp $
3
 *
3
 *
4
 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
4
 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
5
 *
5
 *
Lines 21-26 Link Here
21
#include <linux/init.h>
21
#include <linux/init.h>
22
#include <linux/list.h>
22
#include <linux/list.h>
23
#include <linux/module.h>
23
#include <linux/module.h>
24
#include <linux/moduleparam.h>
24
#include <linux/kernel.h>
25
#include <linux/kernel.h>
25
#include <linux/slab.h>
26
#include <linux/slab.h>
26
#include <linux/delay.h>
27
#include <linux/delay.h>
Lines 50-65 MODULE_PARM_DESC(debug,"enable debug mes Link Here
50
51
51
static void ts_reset_encoder(struct saa7134_dev* dev)
52
static void ts_reset_encoder(struct saa7134_dev* dev)
52
{
53
{
54
	if (!dev->empress_started)
55
		return;
56
53
	saa_writeb(SAA7134_SPECIAL_MODE, 0x00);
57
	saa_writeb(SAA7134_SPECIAL_MODE, 0x00);
54
	msleep(10);
58
	msleep(10);
55
   	saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
59
   	saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
56
	msleep(100);
60
	msleep(100);
61
	dev->empress_started = 0;
57
}
62
}
58
63
59
static int ts_init_encoder(struct saa7134_dev* dev, void* arg)
64
static int ts_init_encoder(struct saa7134_dev* dev)
60
{
65
{
61
	ts_reset_encoder(dev);
66
	ts_reset_encoder(dev);
62
	saa7134_i2c_call_clients(dev, MPEG_SETPARAMS, arg);
67
	saa7134_i2c_call_clients(dev, VIDIOC_S_MPEGCOMP, NULL);
68
	dev->empress_started = 1;
63
 	return 0;
69
 	return 0;
64
}
70
}
65
71
Lines 81-98 static int ts_open(struct inode *inode, Link Here
81
		return -ENODEV;
87
		return -ENODEV;
82
88
83
	dprintk("open minor=%d\n",minor);
89
	dprintk("open minor=%d\n",minor);
84
	down(&dev->empress_tsq.lock);
85
	err = -EBUSY;
90
	err = -EBUSY;
86
	if (dev->empress_users)
91
	if (down_trylock(&dev->empress_tsq.lock))
87
		goto done;
92
		goto done;
93
	if (dev->empress_users)
94
		goto done_up;
88
95
89
	dev->empress_users++;
96
	dev->empress_users++;
90
	file->private_data = dev;
97
	file->private_data = dev;
91
	ts_init_encoder(dev, NULL);
92
	err = 0;
98
	err = 0;
93
99
94
 done:
100
done_up:
95
	up(&dev->empress_tsq.lock);
101
	up(&dev->empress_tsq.lock);
102
done:
96
	return err;
103
	return err;
97
}
104
}
98
105
Lines 105-110 static int ts_release(struct inode *inod Link Here
105
	down(&dev->empress_tsq.lock);
112
	down(&dev->empress_tsq.lock);
106
	if (dev->empress_tsq.reading)
113
	if (dev->empress_tsq.reading)
107
		videobuf_read_stop(&dev->empress_tsq);
114
		videobuf_read_stop(&dev->empress_tsq);
115
	videobuf_mmap_free(&dev->empress_tsq);
108
	dev->empress_users--;
116
	dev->empress_users--;
109
117
110
	/* stop the encoder */
118
	/* stop the encoder */
Lines 119-124 ts_read(struct file *file, char __user * Link Here
119
{
127
{
120
	struct saa7134_dev *dev = file->private_data;
128
	struct saa7134_dev *dev = file->private_data;
121
129
130
	if (!dev->empress_started)
131
		ts_init_encoder(dev);
132
122
	return videobuf_read_stream(&dev->empress_tsq,
133
	return videobuf_read_stream(&dev->empress_tsq,
123
				    data, count, ppos, 0,
134
				    data, count, ppos, 0,
124
				    file->f_flags & O_NONBLOCK);
135
				    file->f_flags & O_NONBLOCK);
Lines 281-288 static int ts_do_ioctl(struct inode *ino Link Here
281
	case VIDIOC_S_CTRL:
292
	case VIDIOC_S_CTRL:
282
		return saa7134_common_ioctl(dev, cmd, arg);
293
		return saa7134_common_ioctl(dev, cmd, arg);
283
294
284
	case MPEG_SETPARAMS:
295
	case VIDIOC_S_MPEGCOMP:
285
		return ts_init_encoder(dev, arg);
296
		saa7134_i2c_call_clients(dev, VIDIOC_S_MPEGCOMP, arg);
297
		ts_init_encoder(dev);
298
		return 0;
299
	case VIDIOC_G_MPEGCOMP:
300
		saa7134_i2c_call_clients(dev, VIDIOC_G_MPEGCOMP, arg);
301
		return 0;
286
302
287
	default:
303
	default:
288
		return -ENOIOCTLCMD;
304
		return -ENOIOCTLCMD;
Lines 320-325 static struct video_device saa7134_empre Link Here
320
	.minor	       = -1,
336
	.minor	       = -1,
321
};
337
};
322
338
339
static void empress_signal_update(void* data)
340
{
341
	struct saa7134_dev* dev = (struct saa7134_dev*) data;
342
343
	if (dev->nosignal) {
344
		dprintk("no video signal\n");
345
		ts_reset_encoder(dev);
346
	} else {
347
		dprintk("video signal acquired\n");
348
		if (dev->empress_users)
349
			ts_init_encoder(dev);
350
	}
351
}
352
353
static void empress_signal_change(struct saa7134_dev *dev)
354
{
355
	schedule_work(&dev->empress_workqueue);
356
}
357
358
323
static int empress_init(struct saa7134_dev *dev)
359
static int empress_init(struct saa7134_dev *dev)
324
{
360
{
325
	int err;
361
	int err;
Lines 335-340 static int empress_init(struct saa7134_d Link Here
335
		 "%s empress (%s)", dev->name,
371
		 "%s empress (%s)", dev->name,
336
		 saa7134_boards[dev->board].name);
372
		 saa7134_boards[dev->board].name);
337
373
374
	INIT_WORK(&dev->empress_workqueue, empress_signal_update, (void*) dev);
375
338
	err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
376
	err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
339
				    empress_nr[dev->nr]);
377
				    empress_nr[dev->nr]);
340
	if (err < 0) {
378
	if (err < 0) {
Lines 353-358 static int empress_init(struct saa7134_d Link Here
353
			    V4L2_FIELD_ALTERNATE,
391
			    V4L2_FIELD_ALTERNATE,
354
			    sizeof(struct saa7134_buf),
392
			    sizeof(struct saa7134_buf),
355
			    dev);
393
			    dev);
394
395
	empress_signal_update(dev);
356
	return 0;
396
	return 0;
357
}
397
}
358
398
Lines 362-367 static int empress_fini(struct saa7134_d Link Here
362
402
363
	if (NULL == dev->empress_dev)
403
	if (NULL == dev->empress_dev)
364
		return 0;
404
		return 0;
405
	flush_scheduled_work();
365
	video_unregister_device(dev->empress_dev);
406
	video_unregister_device(dev->empress_dev);
366
	dev->empress_dev = NULL;
407
	dev->empress_dev = NULL;
367
	return 0;
408
	return 0;
Lines 371-376 static struct saa7134_mpeg_ops empress_o Link Here
371
	.type          = SAA7134_MPEG_EMPRESS,
412
	.type          = SAA7134_MPEG_EMPRESS,
372
	.init          = empress_init,
413
	.init          = empress_init,
373
	.fini          = empress_fini,
414
	.fini          = empress_fini,
415
	.signal_change = empress_signal_change,
374
};
416
};
375
417
376
static int __init empress_register(void)
418
static int __init empress_register(void)
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-i2c.c (-19 / +18 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-i2c.c,v 1.7 2004/11/07 13:17:15 kraxel Exp $
2
 * $Id: saa7134-i2c.c,v 1.10 2005/01/24 17:37:23 kraxel Exp $
3
 *
3
 *
4
 * device driver for philips saa7134 based TV cards
4
 * device driver for philips saa7134 based TV cards
5
 * i2c interface support
5
 * i2c interface support
Lines 24-29 Link Here
24
#include <linux/init.h>
24
#include <linux/init.h>
25
#include <linux/list.h>
25
#include <linux/list.h>
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/moduleparam.h>
27
#include <linux/kernel.h>
28
#include <linux/kernel.h>
28
#include <linux/slab.h>
29
#include <linux/slab.h>
29
#include <linux/delay.h>
30
#include <linux/delay.h>
Lines 205-211 static inline int i2c_send_byte(struct s Link Here
205
	dword &= 0x0f;
206
	dword &= 0x0f;
206
	dword |= (attr << 6);
207
	dword |= (attr << 6);
207
	dword |= ((__u32)data << 8);
208
	dword |= ((__u32)data << 8);
208
	dword |= 0x00 << 16;
209
	dword |= 0x00 << 16;  /* 100 kHz */
210
//	dword |= 0x40 << 16;  /* 400 kHz */
209
	dword |= 0xf0 << 24;
211
	dword |= 0xf0 << 24;
210
	saa_writel(SAA7134_I2C_ATTR_STATUS >> 2, dword);
212
	saa_writel(SAA7134_I2C_ATTR_STATUS >> 2, dword);
211
#endif
213
#endif
Lines 248-260 static int saa7134_i2c_xfer(struct i2c_a Link Here
248
		if (!i2c_reset(dev))
250
		if (!i2c_reset(dev))
249
			return -EIO;
251
			return -EIO;
250
252
253
	d2printk("start xfer\n");
251
	d1printk(KERN_DEBUG "%s: i2c xfer:",dev->name);
254
	d1printk(KERN_DEBUG "%s: i2c xfer:",dev->name);
252
	for (i = 0; i < num; i++) {
255
	for (i = 0; i < num; i++) {
253
		if (!(msgs[i].flags & I2C_M_NOSTART) || 0 == i) {
256
		if (!(msgs[i].flags & I2C_M_NOSTART) || 0 == i) {
254
			/* send address */
257
			/* send address */
258
			d2printk("send address\n");
255
			addr  = msgs[i].addr << 1;
259
			addr  = msgs[i].addr << 1;
256
			if (msgs[i].flags & I2C_M_RD)
260
			if (msgs[i].flags & I2C_M_RD)
257
				addr |= 1;
261
				addr |= 1;
262
			if (i > 0 && msgs[i].flags & I2C_M_RD) {
263
				/* workaround for a saa7134 i2c bug
264
				 * needed to talk to the mt352 demux
265
				 * thanks to pinnacle for the hint */
266
				int quirk = 0xfd;
267
				d1printk(" [%02x quirk]",quirk);
268
				i2c_send_byte(dev,START,quirk);
269
				i2c_recv_byte(dev);
270
			}
258
			d1printk(" < %02x", addr);
271
			d1printk(" < %02x", addr);
259
			rc = i2c_send_byte(dev,START,addr);
272
			rc = i2c_send_byte(dev,START,addr);
260
			if (rc < 0)
273
			if (rc < 0)
Lines 262-267 static int saa7134_i2c_xfer(struct i2c_a Link Here
262
		}
275
		}
263
		if (msgs[i].flags & I2C_M_RD) {
276
		if (msgs[i].flags & I2C_M_RD) {
264
			/* read bytes */
277
			/* read bytes */
278
			d2printk("read bytes\n");
265
			for (byte = 0; byte < msgs[i].len; byte++) {
279
			for (byte = 0; byte < msgs[i].len; byte++) {
266
				d1printk(" =");
280
				d1printk(" =");
267
				rc = i2c_recv_byte(dev);
281
				rc = i2c_recv_byte(dev);
Lines 272-277 static int saa7134_i2c_xfer(struct i2c_a Link Here
272
			}
286
			}
273
		} else {
287
		} else {
274
			/* write bytes */
288
			/* write bytes */
289
			d2printk("write bytes\n");
275
			for (byte = 0; byte < msgs[i].len; byte++) {
290
			for (byte = 0; byte < msgs[i].len; byte++) {
276
				data = msgs[i].buf[byte];
291
				data = msgs[i].buf[byte];
277
				d1printk(" %02x", data);
292
				d1printk(" %02x", data);
Lines 281-286 static int saa7134_i2c_xfer(struct i2c_a Link Here
281
			}
296
			}
282
		}
297
		}
283
	}
298
	}
299
	d2printk("xfer done\n");
284
	d1printk(" >");
300
	d1printk(" >");
285
	i2c_set_attr(dev,STOP);
301
	i2c_set_attr(dev,STOP);
286
	rc = -EIO;
302
	rc = -EIO;
Lines 313-330 static u32 functionality(struct i2c_adap Link Here
313
	return I2C_FUNC_SMBUS_EMUL;
329
	return I2C_FUNC_SMBUS_EMUL;
314
}
330
}
315
331
316
#ifndef I2C_PEC
317
static void inc_use(struct i2c_adapter *adap)
318
{
319
	MOD_INC_USE_COUNT;
320
}
321
322
static void dec_use(struct i2c_adapter *adap)
323
{
324
	MOD_DEC_USE_COUNT;
325
}
326
#endif
327
328
static int attach_inform(struct i2c_client *client)
332
static int attach_inform(struct i2c_client *client)
329
{
333
{
330
        struct saa7134_dev *dev = client->adapter->algo_data;
334
        struct saa7134_dev *dev = client->adapter->algo_data;
Lines 345-356 static struct i2c_algorithm saa7134_algo Link Here
345
};
349
};
346
350
347
static struct i2c_adapter saa7134_adap_template = {
351
static struct i2c_adapter saa7134_adap_template = {
348
#ifdef I2C_PEC
349
	.owner         = THIS_MODULE,
352
	.owner         = THIS_MODULE,
350
#else
351
	.inc_use       = inc_use,
352
	.dec_use       = dec_use,
353
#endif
354
#ifdef I2C_CLASS_TV_ANALOG
353
#ifdef I2C_CLASS_TV_ANALOG
355
	.class         = I2C_CLASS_TV_ANALOG,
354
	.class         = I2C_CLASS_TV_ANALOG,
356
#endif
355
#endif
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-input.c (-1 / +59 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-input.c,v 1.12 2004/11/07 13:17:15 kraxel Exp $
2
 * $Id: saa7134-input.c,v 1.16 2004/12/10 12:33:39 kraxel Exp $
3
 *
3
 *
4
 * handle saa7134 IR remotes via linux kernel input layer.
4
 * handle saa7134 IR remotes via linux kernel input layer.
5
 *
5
 *
Lines 20-25 Link Here
20
 */
20
 */
21
21
22
#include <linux/module.h>
22
#include <linux/module.h>
23
#include <linux/moduleparam.h>
23
#include <linux/init.h>
24
#include <linux/init.h>
24
#include <linux/delay.h>
25
#include <linux/delay.h>
25
#include <linux/sched.h>
26
#include <linux/sched.h>
Lines 258-263 static IR_KEYTAB_TYPE md2819_codes[IR_KE Link Here
258
	[ 17 ] = KEY_CHANNELDOWN,	// CHANNEL/PAGE-
259
	[ 17 ] = KEY_CHANNELDOWN,	// CHANNEL/PAGE-
259
	[ 49 ] = KEY_CHANNELUP		// CHANNEL/PAGE+
260
	[ 49 ] = KEY_CHANNELUP		// CHANNEL/PAGE+
260
};
261
};
262
263
static IR_KEYTAB_TYPE videomate_tv_pvr_codes[IR_KEYTAB_SIZE] = {
264
	[ 20 ] = KEY_MUTE,
265
	[ 36 ] = KEY_ZOOM,
266
267
	[  1 ] = KEY_DVD,
268
	[ 35 ] = KEY_RADIO,
269
	[  0 ] = KEY_TV,
270
271
	[ 10 ] = KEY_REWIND,
272
	[  8 ] = KEY_PLAYPAUSE,
273
	[ 15 ] = KEY_FORWARD,
274
275
	[  2 ] = KEY_PREVIOUS,
276
	[  7 ] = KEY_STOP,
277
	[  6 ] = KEY_NEXT,
278
279
	[ 12 ] = KEY_UP,
280
	[ 14 ] = KEY_DOWN,
281
	[ 11 ] = KEY_LEFT,
282
	[ 13 ] = KEY_RIGHT,
283
	[ 17 ] = KEY_OK,
284
285
	[  3 ] = KEY_MENU,
286
	[  9 ] = KEY_SETUP,
287
	[  5 ] = KEY_VIDEO,
288
	[ 34 ] = KEY_CHANNEL,
289
290
	[ 18 ] = KEY_VOLUMEUP,
291
	[ 21 ] = KEY_VOLUMEDOWN,
292
	[ 16 ] = KEY_CHANNELUP,
293
	[ 19 ] = KEY_CHANNELDOWN,
294
295
	[  4 ] = KEY_RECORD,
296
297
	[ 22 ] = KEY_KP1,
298
	[ 23 ] = KEY_KP2,
299
	[ 24 ] = KEY_KP3,
300
	[ 25 ] = KEY_KP4,
301
	[ 26 ] = KEY_KP5,
302
	[ 27 ] = KEY_KP6,
303
	[ 28 ] = KEY_KP7,
304
	[ 29 ] = KEY_KP8,
305
	[ 30 ] = KEY_KP9,
306
	[ 31 ] = KEY_KP0,
307
308
	[ 32 ] = KEY_LANGUAGE,
309
	[ 33 ] = KEY_SLEEP,
310
};
261
/* ---------------------------------------------------------------------- */
311
/* ---------------------------------------------------------------------- */
262
312
263
static int build_key(struct saa7134_dev *dev)
313
static int build_key(struct saa7134_dev *dev)
Lines 335-340 int saa7134_input_init1(struct saa7134_d Link Here
335
		break;
385
		break;
336
	case SAA7134_BOARD_CINERGY400:
386
	case SAA7134_BOARD_CINERGY400:
337
	case SAA7134_BOARD_CINERGY600:
387
	case SAA7134_BOARD_CINERGY600:
388
	case SAA7134_BOARD_CINERGY600_MK3:
338
		ir_codes     = cinergy_codes;
389
		ir_codes     = cinergy_codes;
339
		mask_keycode = 0x00003f;
390
		mask_keycode = 0x00003f;
340
		mask_keyup   = 0x040000;
391
		mask_keyup   = 0x040000;
Lines 353-358 int saa7134_input_init1(struct saa7134_d Link Here
353
		polling      = 50; // ms
404
		polling      = 50; // ms
354
		break;
405
		break;
355
	case SAA7134_BOARD_MD2819:
406
	case SAA7134_BOARD_MD2819:
407
	case SAA7134_BOARD_AVERMEDIA_305:
356
	case SAA7134_BOARD_AVERMEDIA_307:
408
	case SAA7134_BOARD_AVERMEDIA_307:
357
		ir_codes     = md2819_codes;
409
		ir_codes     = md2819_codes;
358
		mask_keycode = 0x0007C8;
410
		mask_keycode = 0x0007C8;
Lines 362-367 int saa7134_input_init1(struct saa7134_d Link Here
362
		saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
414
		saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
363
		saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
415
		saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
364
		break;
416
		break;
417
	case SAA7134_BOARD_VIDEOMATE_TV_PVR:
418
		ir_codes     = videomate_tv_pvr_codes;
419
		mask_keycode = 0x00003F;
420
		mask_keyup   = 0x400000;
421
		polling      = 50; // ms
422
		break;
365
	}
423
	}
366
	if (NULL == ir_codes) {
424
	if (NULL == ir_codes) {
367
		printk("%s: Oops: IR config error [card=%d]\n",
425
		printk("%s: Oops: IR config error [card=%d]\n",
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-oss.c (-1 / +5 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-oss.c,v 1.11 2004/11/07 13:17:15 kraxel Exp $
2
 * $Id: saa7134-oss.c,v 1.13 2004/12/10 12:33:39 kraxel Exp $
3
 *
3
 *
4
 * device driver for philips saa7134 based TV cards
4
 * device driver for philips saa7134 based TV cards
5
 * oss dsp interface
5
 * oss dsp interface
Lines 24-29 Link Here
24
#include <linux/init.h>
24
#include <linux/init.h>
25
#include <linux/list.h>
25
#include <linux/list.h>
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/moduleparam.h>
27
#include <linux/kernel.h>
28
#include <linux/kernel.h>
28
#include <linux/slab.h>
29
#include <linux/slab.h>
29
#include <linux/soundcard.h>
30
#include <linux/soundcard.h>
Lines 543-548 mixer_recsrc_7134(struct saa7134_dev *de Link Here
543
		break;
544
		break;
544
	case LINE1:
545
	case LINE1:
545
	case LINE2:
546
	case LINE2:
547
	case LINE2_LEFT:
546
		analog_io = (LINE1 == dev->oss.input) ? 0x00 : 0x08;
548
		analog_io = (LINE1 == dev->oss.input) ? 0x00 : 0x08;
547
		rate = (32000 == dev->oss.rate) ? 0x01 : 0x03;
549
		rate = (32000 == dev->oss.rate) ? 0x01 : 0x03;
548
		saa_andorb(SAA7134_ANALOG_IO_SELECT,  0x08, analog_io);
550
		saa_andorb(SAA7134_ANALOG_IO_SELECT,  0x08, analog_io);
Lines 566-571 mixer_recsrc_7133(struct saa7134_dev *de Link Here
566
		value = 0xbbbb32;  /* AUX1 */
568
		value = 0xbbbb32;  /* AUX1 */
567
		break;
569
		break;
568
	case LINE2:
570
	case LINE2:
571
	case LINE2_LEFT:
569
		value = 0xbbbb54;  /* AUX2 */
572
		value = 0xbbbb54;  /* AUX2 */
570
		break;
573
		break;
571
	}
574
	}
Lines 608-613 mixer_level(struct saa7134_dev *dev, enu Link Here
608
				   (100 == level) ? 0x00 : 0x10);
611
				   (100 == level) ? 0x00 : 0x10);
609
			break;
612
			break;
610
		case LINE2:
613
		case LINE2:
614
		case LINE2_LEFT:
611
			saa_andorb(SAA7134_ANALOG_IO_SELECT,  0x20,
615
			saa_andorb(SAA7134_ANALOG_IO_SELECT,  0x20,
612
				   (100 == level) ? 0x00 : 0x20);
616
				   (100 == level) ? 0x00 : 0x20);
613
			break;
617
			break;
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-ts.c (-3 / +4 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-ts.c,v 1.12 2004/11/07 13:17:15 kraxel Exp $
2
 * $Id: saa7134-ts.c,v 1.14 2005/02/03 10:24:33 kraxel Exp $
3
 *
3
 *
4
 * device driver for philips saa7134 based TV cards
4
 * device driver for philips saa7134 based TV cards
5
 * video4linux video interface
5
 * video4linux video interface
Lines 24-29 Link Here
24
#include <linux/init.h>
24
#include <linux/init.h>
25
#include <linux/list.h>
25
#include <linux/list.h>
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/moduleparam.h>
27
#include <linux/kernel.h>
28
#include <linux/kernel.h>
28
#include <linux/slab.h>
29
#include <linux/slab.h>
29
#include <linux/delay.h>
30
#include <linux/delay.h>
Lines 220-229 void saa7134_irq_ts_done(struct saa7134_ Link Here
220
	if (dev->ts_q.curr) {
221
	if (dev->ts_q.curr) {
221
		field = dev->ts_q.curr->vb.field;
222
		field = dev->ts_q.curr->vb.field;
222
		if (field == V4L2_FIELD_TOP) {
223
		if (field == V4L2_FIELD_TOP) {
223
			if ((status & 0x100000) != 0x100000)
224
			if ((status & 0x100000) != 0x000000)
224
				goto done;
225
				goto done;
225
		} else {
226
		} else {
226
			if ((status & 0x100000) != 0x000000)
227
			if ((status & 0x100000) != 0x100000)
227
				goto done;
228
				goto done;
228
		}
229
		}
229
		saa7134_buffer_finish(dev,&dev->ts_q,STATE_DONE);
230
		saa7134_buffer_finish(dev,&dev->ts_q,STATE_DONE);
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-tvaudio.c (-24 / +39 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-tvaudio.c,v 1.17 2004/11/07 13:17:15 kraxel Exp $
2
 * $Id: saa7134-tvaudio.c,v 1.22 2005/01/07 13:11:19 kraxel Exp $
3
 *
3
 *
4
 * device driver for philips saa7134 based TV cards
4
 * device driver for philips saa7134 based TV cards
5
 * tv audio decoder (fm stereo, nicam, ...)
5
 * tv audio decoder (fm stereo, nicam, ...)
Lines 24-29 Link Here
24
#include <linux/init.h>
24
#include <linux/init.h>
25
#include <linux/list.h>
25
#include <linux/list.h>
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/moduleparam.h>
27
#include <linux/kernel.h>
28
#include <linux/kernel.h>
28
#include <linux/slab.h>
29
#include <linux/slab.h>
29
#include <linux/delay.h>
30
#include <linux/delay.h>
Lines 237-249 static void mute_input_7134(struct saa71 Link Here
237
238
238
	if (PCI_DEVICE_ID_PHILIPS_SAA7134 == dev->pci->device)
239
	if (PCI_DEVICE_ID_PHILIPS_SAA7134 == dev->pci->device)
239
		/* 7134 mute */
240
		/* 7134 mute */
240
		saa_writeb(SAA7134_AUDIO_MUTE_CTRL, mute ? 0xff : 0xbb);
241
		saa_writeb(SAA7134_AUDIO_MUTE_CTRL, mute ? 0xbf : 0xbb);
241
242
242
	/* switch internal audio mux */
243
	/* switch internal audio mux */
243
	switch (in->amux) {
244
	switch (in->amux) {
244
	case TV:    ausel=0xc0; ics=0x00; ocs=0x02; break;
245
	case TV:         ausel=0xc0; ics=0x00; ocs=0x02; break;
245
	case LINE1: ausel=0x80; ics=0x00; ocs=0x00; break;
246
	case LINE1:      ausel=0x80; ics=0x00; ocs=0x00; break;
246
	case LINE2: ausel=0x80; ics=0x08; ocs=0x01; break;
247
	case LINE2:      ausel=0x80; ics=0x08; ocs=0x01; break;
248
	case LINE2_LEFT: ausel=0x80; ics=0x08; ocs=0x05; break;
247
	}
249
	}
248
	saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, ausel);
250
	saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, ausel);
249
	saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, ics);
251
	saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, ics);
Lines 437-451 static int tvaudio_getstereo(struct saa7 Link Here
437
		nicam = saa_readb(SAA7134_NICAM_STATUS);
439
		nicam = saa_readb(SAA7134_NICAM_STATUS);
438
		dprintk("getstereo: nicam=0x%x\n",nicam);
440
		dprintk("getstereo: nicam=0x%x\n",nicam);
439
		switch (nicam & 0x0b) {
441
		switch (nicam & 0x0b) {
440
		case 0x08:
441
			retval = V4L2_TUNER_SUB_MONO;
442
			break;
443
		case 0x09:
442
		case 0x09:
444
			retval = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
443
			retval = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
445
			break;
444
			break;
446
		case 0x0a:
445
		case 0x0a:
447
			retval = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
446
			retval = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
448
			break;
447
			break;
448
		case 0x08:
449
		default:
450
			retval = V4L2_TUNER_SUB_MONO;
451
			break;
449
		}
452
		}
450
		break;
453
		break;
451
	}
454
	}
Lines 748-756 static int mute_input_7133(struct saa713 Link Here
748
	int mask;
751
	int mask;
749
752
750
	switch (dev->input->amux) {
753
	switch (dev->input->amux) {
751
	case TV:    reg = 0x02; break;
754
	case TV:
752
	case LINE1: reg = 0x00; break;
755
		reg = 0x02;
753
	case LINE2: reg = 0x01; break;
756
		break;
757
	case LINE1:
758
		reg = 0x00;
759
		break;
760
	case LINE2:
761
	case LINE2_LEFT:
762
		reg = 0x01;
763
		break;
754
	}
764
	}
755
	if (dev->ctl_mute)
765
	if (dev->ctl_mute)
756
		reg = 0x07;
766
		reg = 0x07;
Lines 869-874 static int tvaudio_thread_ddep(void *dat Link Here
869
/* ------------------------------------------------------------------ */
879
/* ------------------------------------------------------------------ */
870
/* common stuff + external entry points                               */
880
/* common stuff + external entry points                               */
871
881
882
static void saa7134_enable_i2s(struct saa7134_dev *dev)
883
{
884
	int i2s_format;
885
886
	if (!card_is_empress(dev))
887
		return;
888
	i2s_format = (dev->input->amux == TV) ? 0x00 : 0x01;
889
890
	/* enable I2S audio output for the mpeg encoder */
891
	saa_writeb(SAA7134_I2S_OUTPUT_SELECT,  0x80);
892
	saa_writeb(SAA7134_I2S_OUTPUT_FORMAT,  i2s_format);
893
	saa_writeb(SAA7134_I2S_OUTPUT_LEVEL,   0x0F);
894
	saa_writeb(SAA7134_I2S_AUDIO_OUTPUT,   0x01);
895
}
896
872
int saa7134_tvaudio_rx2mode(u32 rx)
897
int saa7134_tvaudio_rx2mode(u32 rx)
873
{
898
{
874
	u32 mode;
899
	u32 mode;
Lines 911-916 void saa7134_tvaudio_setinput(struct saa Link Here
911
		mute_input_7133(dev);
936
		mute_input_7133(dev);
912
		break;
937
		break;
913
	}
938
	}
939
	saa7134_enable_i2s(dev);
914
}
940
}
915
941
916
void saa7134_tvaudio_setvolume(struct saa7134_dev *dev, int level)
942
void saa7134_tvaudio_setvolume(struct saa7134_dev *dev, int level)
Lines 946-963 int saa7134_tvaudio_init2(struct saa7134 Link Here
946
	DECLARE_MUTEX_LOCKED(sem);
972
	DECLARE_MUTEX_LOCKED(sem);
947
	int (*my_thread)(void *data) = NULL;
973
	int (*my_thread)(void *data) = NULL;
948
974
949
	/* enable I2S audio output */
950
	if (card_is_empress(dev)) {
951
		int i2sform = (48000 == dev->oss.rate)
952
			? 0x01 : 0x00;
953
954
		/* enable I2S output */
955
		saa_writeb(SAA7134_I2S_OUTPUT_SELECT,  0x80);
956
		saa_writeb(SAA7134_I2S_OUTPUT_FORMAT,  i2sform);
957
		saa_writeb(SAA7134_I2S_OUTPUT_LEVEL,   0x0F);
958
		saa_writeb(SAA7134_I2S_AUDIO_OUTPUT,   0x01);
959
	}
960
961
	switch (dev->pci->device) {
975
	switch (dev->pci->device) {
962
	case PCI_DEVICE_ID_PHILIPS_SAA7134:
976
	case PCI_DEVICE_ID_PHILIPS_SAA7134:
963
		my_thread = tvaudio_thread;
977
		my_thread = tvaudio_thread;
Lines 977-985 int saa7134_tvaudio_init2(struct saa7134 Link Here
977
		if (dev->thread.pid < 0)
991
		if (dev->thread.pid < 0)
978
			printk(KERN_WARNING "%s: kernel_thread() failed\n",
992
			printk(KERN_WARNING "%s: kernel_thread() failed\n",
979
			       dev->name);
993
			       dev->name);
980
		wake_up_interruptible(&dev->thread.wq);
994
		saa7134_tvaudio_do_scan(dev);
981
	}
995
	}
982
996
997
	saa7134_enable_i2s(dev);
983
	return 0;
998
	return 0;
984
}
999
}
985
1000
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-vbi.c (-1 / +2 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-vbi.c,v 1.5 2004/11/07 13:17:15 kraxel Exp $
2
 * $Id: saa7134-vbi.c,v 1.6 2004/12/10 12:33:39 kraxel Exp $
3
 *
3
 *
4
 * device driver for philips saa7134 based TV cards
4
 * device driver for philips saa7134 based TV cards
5
 * video4linux video interface
5
 * video4linux video interface
Lines 24-29 Link Here
24
#include <linux/init.h>
24
#include <linux/init.h>
25
#include <linux/list.h>
25
#include <linux/list.h>
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/moduleparam.h>
27
#include <linux/kernel.h>
28
#include <linux/kernel.h>
28
#include <linux/slab.h>
29
#include <linux/slab.h>
29
30
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134-video.c (-15 / +44 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134-video.c,v 1.19 2004/11/07 14:44:59 kraxel Exp $
2
 * $Id: saa7134-video.c,v 1.28 2005/02/15 15:59:35 kraxel Exp $
3
 *
3
 *
4
 * device driver for philips saa7134 based TV cards
4
 * device driver for philips saa7134 based TV cards
5
 * video4linux video interface
5
 * video4linux video interface
Lines 24-29 Link Here
24
#include <linux/init.h>
24
#include <linux/init.h>
25
#include <linux/list.h>
25
#include <linux/list.h>
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/moduleparam.h>
27
#include <linux/kernel.h>
28
#include <linux/kernel.h>
28
#include <linux/slab.h>
29
#include <linux/slab.h>
29
30
Lines 267-272 static struct saa7134_tvnorm tvnorms[] = Link Here
267
		.chroma_ctrl2  = 0x06,
268
		.chroma_ctrl2  = 0x06,
268
		.vgate_misc    = 0x1c,
269
		.vgate_misc    = 0x1c,
269
270
271
	},{
272
		.name          = "PAL-60",
273
		.id            = V4L2_STD_PAL_60,
274
275
		.h_start       = 0,
276
		.h_stop        = 719,
277
		.video_v_start = 22,
278
		.video_v_stop  = 22+239,
279
		.vbi_v_start   = 10, /* FIXME */
280
		.vbi_v_stop    = 21, /* FIXME */
281
		.src_timing    = 1,
282
		
283
		.sync_control  = 0x18,
284
		.luma_control  = 0x40,
285
		.chroma_ctrl1  = 0x81,
286
		.chroma_gain   = 0x2a,
287
		.chroma_ctrl2  = 0x06,
288
		.vgate_misc    = 0x1c,
270
	}
289
	}
271
};
290
};
272
#define TVNORMS ARRAY_SIZE(tvnorms)
291
#define TVNORMS ARRAY_SIZE(tvnorms)
Lines 443-453 void res_free(struct saa7134_dev *dev, s Link Here
443
462
444
static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
463
static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
445
{
464
{
446
	int luma_control,sync_control,mux,nosignal;
465
	int luma_control,sync_control,mux;
447
466
448
	dprintk("set tv norm = %s\n",norm->name);
467
	dprintk("set tv norm = %s\n",norm->name);
449
	dev->tvnorm = norm;
468
	dev->tvnorm = norm;
450
        nosignal = (0 == (saa_readb(SAA7134_STATUS_VIDEO1) & 0x03));
451
469
452
	mux = card_in(dev,dev->ctl_input).vmux;
470
	mux = card_in(dev,dev->ctl_input).vmux;
453
	luma_control = norm->luma_control;
471
	luma_control = norm->luma_control;
Lines 455-461 static void set_tvnorm(struct saa7134_de Link Here
455
473
456
	if (mux > 5)
474
	if (mux > 5)
457
		luma_control |= 0x80; /* svideo */
475
		luma_control |= 0x80; /* svideo */
458
	if (noninterlaced || nosignal)
476
	if (noninterlaced || dev->nosignal)
459
		sync_control |= 0x20;
477
		sync_control |= 0x20;
460
478
461
	/* setup cropping */
479
	/* setup cropping */
Lines 1359-1364 static int video_release(struct inode *i Link Here
1359
		res_free(dev,fh,RESOURCE_VBI);
1377
		res_free(dev,fh,RESOURCE_VBI);
1360
	}
1378
	}
1361
1379
1380
	/* free stuff */
1381
	videobuf_mmap_free(&fh->cap);
1382
	videobuf_mmap_free(&fh->vbi);
1362
	saa7134_pgtable_free(dev->pci,&fh->pt_cap);
1383
	saa7134_pgtable_free(dev->pci,&fh->pt_cap);
1363
	saa7134_pgtable_free(dev->pci,&fh->pt_vbi);
1384
	saa7134_pgtable_free(dev->pci,&fh->pt_vbi);
1364
1385
Lines 1472-1477 static int saa7134_try_fmt(struct saa713 Link Here
1472
			f->fmt.pix.width = maxw;
1493
			f->fmt.pix.width = maxw;
1473
		if (f->fmt.pix.height > maxh)
1494
		if (f->fmt.pix.height > maxh)
1474
			f->fmt.pix.height = maxh;
1495
			f->fmt.pix.height = maxh;
1496
		f->fmt.pix.width &= ~0x03;
1475
		f->fmt.pix.bytesperline =
1497
		f->fmt.pix.bytesperline =
1476
			(f->fmt.pix.width * fmt->depth) >> 3;
1498
			(f->fmt.pix.width * fmt->depth) >> 3;
1477
		f->fmt.pix.sizeimage =
1499
		f->fmt.pix.sizeimage =
Lines 2267-2273 int saa7134_video_init1(struct saa7134_d Link Here
2267
	dev->ctl_hue        = ctrl_by_id(V4L2_CID_HUE)->default_value;
2289
	dev->ctl_hue        = ctrl_by_id(V4L2_CID_HUE)->default_value;
2268
	dev->ctl_saturation = ctrl_by_id(V4L2_CID_SATURATION)->default_value;
2290
	dev->ctl_saturation = ctrl_by_id(V4L2_CID_SATURATION)->default_value;
2269
	dev->ctl_volume     = ctrl_by_id(V4L2_CID_AUDIO_VOLUME)->default_value;
2291
	dev->ctl_volume     = ctrl_by_id(V4L2_CID_AUDIO_VOLUME)->default_value;
2270
	dev->ctl_mute       = ctrl_by_id(V4L2_CID_AUDIO_MUTE)->default_value;
2292
	dev->ctl_mute       = 1; // ctrl_by_id(V4L2_CID_AUDIO_MUTE)->default_value;
2271
	dev->ctl_invert     = ctrl_by_id(V4L2_CID_PRIVATE_INVERT)->default_value;
2293
	dev->ctl_invert     = ctrl_by_id(V4L2_CID_PRIVATE_INVERT)->default_value;
2272
	dev->ctl_automute   = ctrl_by_id(V4L2_CID_PRIVATE_AUTOMUTE)->default_value;
2294
	dev->ctl_automute   = ctrl_by_id(V4L2_CID_PRIVATE_AUTOMUTE)->default_value;
2273
2295
Lines 2317-2340 int saa7134_video_fini(struct saa7134_de Link Here
2317
void saa7134_irq_video_intl(struct saa7134_dev *dev)
2339
void saa7134_irq_video_intl(struct saa7134_dev *dev)
2318
{
2340
{
2319
	static const char *st[] = {
2341
	static const char *st[] = {
2320
		"no signal", "found NTSC", "found PAL", "found SECAM" };
2342
		"(no signal)", "NTSC", "PAL", "SECAM" };
2321
	int norm;
2343
	u32 st1,st2;
2322
2344
2323
	norm = saa_readb(SAA7134_STATUS_VIDEO1) & 0x03;
2345
	st1 = saa_readb(SAA7134_STATUS_VIDEO1);
2324
	dprintk("DCSDT: %s\n",st[norm]);
2346
	st2 = saa_readb(SAA7134_STATUS_VIDEO2);
2347
	dprintk("DCSDT: pll: %s, sync: %s, norm: %s\n",
2348
		(st1 & 0x40) ? "not locked" : "locked",
2349
		(st2 & 0x40) ? "no"         : "yes",
2350
		st[st1 & 0x03]);
2351
	dev->nosignal = (st1 & 0x40) || (st2 & 0x40);
2325
2352
2326
	if (0 != norm) {
2353
	if (dev->nosignal) {
2327
		/* wake up tvaudio audio carrier scan thread */
2328
		saa7134_tvaudio_do_scan(dev);
2329
		if (!noninterlaced)
2330
			saa_clearb(SAA7134_SYNC_CTRL, 0x20);
2331
	} else {
2332
		/* no video signal -> mute audio */
2354
		/* no video signal -> mute audio */
2333
		if (dev->ctl_automute)
2355
		if (dev->ctl_automute)
2334
			dev->automute = 1;
2356
			dev->automute = 1;
2335
		saa7134_tvaudio_setmute(dev);
2357
		saa7134_tvaudio_setmute(dev);
2336
		saa_setb(SAA7134_SYNC_CTRL, 0x20);
2358
		saa_setb(SAA7134_SYNC_CTRL, 0x20);
2359
	} else {
2360
		/* wake up tvaudio audio carrier scan thread */
2361
		saa7134_tvaudio_do_scan(dev);
2362
		if (!noninterlaced)
2363
			saa_clearb(SAA7134_SYNC_CTRL, 0x20);
2337
	}
2364
	}
2365
	if (dev->mops && dev->mops->signal_change)
2366
		dev->mops->signal_change(dev);
2338
}
2367
}
2339
2368
2340
void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status)
2369
void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status)
(-)linux-2.6.11.orig/drivers/media/video/saa7134/saa7134.h (-4 / +17 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: saa7134.h,v 1.27 2004/11/04 11:03:52 kraxel Exp $
2
 * $Id: saa7134.h,v 1.38 2005/03/07 12:01:51 kraxel Exp $
3
 *
3
 *
4
 * v4l2 device driver for philips saa7134 based TV cards
4
 * v4l2 device driver for philips saa7134 based TV cards
5
 *
5
 *
Lines 64-69 enum saa7134_audio_in { Link Here
64
	TV    = 1,
64
	TV    = 1,
65
	LINE1 = 2,
65
	LINE1 = 2,
66
	LINE2 = 3,
66
	LINE2 = 3,
67
	LINE2_LEFT,
67
};
68
};
68
69
69
enum saa7134_video_out {
70
enum saa7134_video_out {
Lines 156-166 struct saa7134_format { Link Here
156
#define SAA7134_BOARD_AVACSSMARTTV     32
157
#define SAA7134_BOARD_AVACSSMARTTV     32
157
#define SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER 33
158
#define SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER 33
158
#define SAA7134_BOARD_NOVAC_PRIMETV7133 34
159
#define SAA7134_BOARD_NOVAC_PRIMETV7133 34
159
#define SAA7134_BOARD_AVERMEDIA_305    35
160
#define SAA7134_BOARD_AVERMEDIA_STUDIO_305 35
160
#define SAA7133_BOARD_UPMOST_PURPLE_TV 36
161
#define SAA7133_BOARD_UPMOST_PURPLE_TV 36
161
#define SAA7134_BOARD_ITEMS_MTV005     37
162
#define SAA7134_BOARD_ITEMS_MTV005     37
162
#define SAA7134_BOARD_CINERGY200       38
163
#define SAA7134_BOARD_CINERGY200       38
163
#define SAA7134_BOARD_FLYTVPLATINUM    39
164
#define SAA7134_BOARD_FLYTVPLATINUM_MINI 39
164
#define SAA7134_BOARD_VIDEOMATE_TV_PVR 40
165
#define SAA7134_BOARD_VIDEOMATE_TV_PVR 40
165
#define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS 41
166
#define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS 41
166
#define SAA7134_BOARD_SABRENT_SBTTVFM  42
167
#define SAA7134_BOARD_SABRENT_SBTTVFM  42
Lines 169-174 struct saa7134_format { Link Here
169
#define SAA7134_BOARD_AVERMEDIA_307    45
170
#define SAA7134_BOARD_AVERMEDIA_307    45
170
#define SAA7134_BOARD_AVERMEDIA_CARDBUS 46
171
#define SAA7134_BOARD_AVERMEDIA_CARDBUS 46
171
#define SAA7134_BOARD_CINERGY400_CARDBUS 47
172
#define SAA7134_BOARD_CINERGY400_CARDBUS 47
173
#define SAA7134_BOARD_CINERGY600_MK3   48
174
#define SAA7134_BOARD_VIDEOMATE_GOLD_PLUS 49
175
#define SAA7134_BOARD_PINNACLE_300I_DVBT_PAL 50
176
#define SAA7134_BOARD_PROVIDEO_PV952   51
177
#define SAA7134_BOARD_AVERMEDIA_305    52
178
#define SAA7135_BOARD_ASUSTeK_TVFM7135 53
179
#define SAA7134_BOARD_FLYTVPLATINUM_FM 54
180
#define SAA7134_BOARD_FLYDVBTDUO 55
172
181
173
#define SAA7134_MAXBOARDS 8
182
#define SAA7134_MAXBOARDS 8
174
#define SAA7134_INPUT_MAX 8
183
#define SAA7134_INPUT_MAX 8
Lines 355-360 struct saa7134_mpeg_ops { Link Here
355
	struct list_head           next;
364
	struct list_head           next;
356
	int                        (*init)(struct saa7134_dev *dev);
365
	int                        (*init)(struct saa7134_dev *dev);
357
	int                        (*fini)(struct saa7134_dev *dev);
366
	int                        (*fini)(struct saa7134_dev *dev);
367
	void                       (*signal_change)(struct saa7134_dev *dev);
358
};
368
};
359
369
360
/* global device status */
370
/* global device status */
Lines 390-395 struct saa7134_dev { Link Here
390
	unsigned int               tuner_type;
400
	unsigned int               tuner_type;
391
	unsigned int               tda9887_conf;
401
	unsigned int               tda9887_conf;
392
	unsigned int               gpio_value;
402
	unsigned int               gpio_value;
403
	unsigned int               irq2_mask;
393
404
394
	/* i2c i/o */
405
	/* i2c i/o */
395
	struct i2c_adapter         i2c_adap;
406
	struct i2c_adapter         i2c_adap;
Lines 437-442 struct saa7134_dev { Link Here
437
	struct saa7134_input       *hw_input;
448
	struct saa7134_input       *hw_input;
438
	unsigned int               hw_mute;
449
	unsigned int               hw_mute;
439
	int                        last_carrier;
450
	int                        last_carrier;
451
	int                        nosignal;
440
452
441
	/* SAA7134_MPEG_* */
453
	/* SAA7134_MPEG_* */
442
	struct saa7134_ts          ts;
454
	struct saa7134_ts          ts;
Lines 447-452 struct saa7134_dev { Link Here
447
	struct video_device        *empress_dev;
459
	struct video_device        *empress_dev;
448
	struct videobuf_queue      empress_tsq;
460
	struct videobuf_queue      empress_tsq;
449
	unsigned int               empress_users;
461
	unsigned int               empress_users;
462
	struct work_struct         empress_workqueue;
463
	int                        empress_started;
450
464
451
	/* SAA7134_MPEG_DVB only */
465
	/* SAA7134_MPEG_DVB only */
452
	struct videobuf_dvb        dvb;
466
	struct videobuf_dvb        dvb;
Lines 476-482 struct saa7134_dev { Link Here
476
/* saa7134-core.c                                              */
490
/* saa7134-core.c                                              */
477
491
478
extern struct list_head  saa7134_devlist;
492
extern struct list_head  saa7134_devlist;
479
extern unsigned int      saa7134_devcount;
480
493
481
void saa7134_print_ioctl(char *name, unsigned int cmd);
494
void saa7134_print_ioctl(char *name, unsigned int cmd);
482
void saa7134_track_gpio(struct saa7134_dev *dev, char *msg);
495
void saa7134_track_gpio(struct saa7134_dev *dev, char *msg);
(-)linux-2.6.11.orig/drivers/media/video/stradis.c (-6 / +3 lines)
Lines 2181-2192 static void release_saa(void) Link Here
2181
		/* unmap and free memory */
2181
		/* unmap and free memory */
2182
		saa->audhead = saa->audtail = saa->osdhead = 0;
2182
		saa->audhead = saa->audtail = saa->osdhead = 0;
2183
		saa->vidhead = saa->vidtail = saa->osdtail = 0;
2183
		saa->vidhead = saa->vidtail = saa->osdtail = 0;
2184
		if (saa->vidbuf)
2184
		vfree(saa->vidbuf);
2185
			vfree(saa->vidbuf);
2185
		vfree(saa->audbuf);
2186
		if (saa->audbuf)
2186
		vfree(saa->osdbuf);
2187
			vfree(saa->audbuf);
2188
		if (saa->osdbuf)
2189
			vfree(saa->osdbuf);
2190
		if (saa->dmavid2)
2187
		if (saa->dmavid2)
2191
			kfree((void *) saa->dmavid2);
2188
			kfree((void *) saa->dmavid2);
2192
		saa->audbuf = saa->vidbuf = saa->osdbuf = NULL;
2189
		saa->audbuf = saa->vidbuf = saa->osdbuf = NULL;
(-)linux-2.6.11/drivers/media/video/tda8290.c (+224 lines)
Added Link Here
1
/*
2
 * $Id: tda8290.c,v 1.7 2005/03/07 12:01:51 kraxel Exp $
3
 *
4
 * i2c tv tuner chip device driver
5
 * controls the philips tda8290+75 tuner chip combo.
6
 */
7
#include <linux/i2c.h>
8
#include <linux/videodev.h>
9
#include <linux/delay.h>
10
#include <media/tuner.h>
11
12
/* ---------------------------------------------------------------------- */
13
14
struct freq_entry {
15
	u16	freq;
16
	u8	value;
17
};
18
19
static struct freq_entry band_table[] = {
20
	{ 0x2DF4, 0x1C },
21
	{ 0x2574, 0x14 },
22
	{ 0x22B4, 0x0C },
23
	{ 0x20D4, 0x0B },
24
	{ 0x1E74, 0x3B },
25
	{ 0x1C34, 0x33 },
26
	{ 0x16F4, 0x5B },
27
	{ 0x1454, 0x53 },
28
	{ 0x12D4, 0x52 },
29
	{ 0x1034, 0x4A },
30
	{ 0x0EE4, 0x7A },
31
	{ 0x0D34, 0x72 },
32
	{ 0x0B54, 0x9A },
33
	{ 0x0914, 0x91 },
34
	{ 0x07F4, 0x89 },
35
	{ 0x0774, 0xB9 },
36
	{ 0x067B, 0xB1 },
37
	{ 0x0634, 0xD9 },
38
	{ 0x05A4, 0xD8 },	// FM radio
39
	{ 0x0494, 0xD0 },
40
	{ 0x03BC, 0xC8 },
41
	{ 0x0394, 0xF8 },	// 57250000 Hz
42
	{ 0x0000, 0xF0 },	// 0
43
};
44
45
static struct freq_entry div_table[] = {
46
	{ 0x1C34, 3 },
47
	{ 0x0D34, 2 },
48
	{ 0x067B, 1 },
49
        { 0x0000, 0 },
50
};
51
52
static struct freq_entry agc_table[] = {
53
	{ 0x22B4, 0x8F },
54
	{ 0x0B54, 0x9F },
55
	{ 0x09A4, 0x8F },
56
	{ 0x0554, 0x9F },
57
	{ 0x0000, 0xBF },
58
};
59
60
static __u8 get_freq_entry( struct freq_entry* table, __u16 freq)
61
{
62
	while(table->freq && table->freq > freq)
63
		table++;
64
	return table->value;
65
}
66
67
/* ---------------------------------------------------------------------- */
68
69
static unsigned char i2c_enable_bridge[2] = 	{ 0x21, 0xC0 };
70
static unsigned char i2c_disable_bridge[2] = 	{ 0x21, 0x80 };
71
static unsigned char i2c_init_tda8275[14] = 	{ 0x00, 0x00, 0x00, 0x00,
72
						  0x7C, 0x04, 0xA3, 0x3F,
73
						  0x2A, 0x04, 0xFF, 0x00,
74
						  0x00, 0x40 };
75
static unsigned char i2c_set_VS[2] = 		{ 0x30, 0x6F };
76
static unsigned char i2c_set_GP01_CF[2] = 	{ 0x20, 0x0B };
77
static unsigned char i2c_tda8290_reset[2] =	{ 0x00, 0x00 };
78
static unsigned char i2c_gainset_off[2] =	{ 0x28, 0x14 };
79
static unsigned char i2c_gainset_on[2] =	{ 0x28, 0x54 };
80
static unsigned char i2c_agc3_00[2] =		{ 0x80, 0x00 };
81
static unsigned char i2c_agc2_BF[2] =		{ 0x60, 0xBF };
82
static unsigned char i2c_cb1_D2[2] =		{ 0x30, 0xD2 };
83
static unsigned char i2c_cb1_56[2] =		{ 0x30, 0x56 };
84
static unsigned char i2c_cb1_52[2] =		{ 0x30, 0x52 };
85
static unsigned char i2c_cb1_50[2] =		{ 0x30, 0x50 };
86
static unsigned char i2c_agc2_7F[2] =		{ 0x60, 0x7F };
87
static unsigned char i2c_agc3_08[2] =		{ 0x80, 0x08 };
88
89
static struct i2c_msg i2c_msg_init[] = {
90
	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_init_tda8275), i2c_init_tda8275 },
91
	{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_disable_bridge), i2c_disable_bridge },
92
	{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_set_VS), i2c_set_VS },
93
	{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_set_GP01_CF), i2c_set_GP01_CF },
94
};
95
96
static struct i2c_msg i2c_msg_prolog[] = {
97
//	{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_easy_mode), i2c_easy_mode },
98
	{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_gainset_off), i2c_gainset_off },
99
	{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_tda8290_reset), i2c_tda8290_reset },
100
	{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_enable_bridge), i2c_enable_bridge },
101
};
102
103
static struct i2c_msg i2c_msg_config[] = {
104
//	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_set_freq), i2c_set_freq },
105
	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc3_00), i2c_agc3_00 },
106
	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc2_BF), i2c_agc2_BF },
107
	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_D2), i2c_cb1_D2 },
108
	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_56), i2c_cb1_56 },
109
	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_52), i2c_cb1_52 },
110
};
111
112
static struct i2c_msg i2c_msg_epilog[] = {
113
	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_50), i2c_cb1_50 },
114
	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc2_7F), i2c_agc2_7F },
115
	{ I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc3_08), i2c_agc3_08 },
116
	{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_disable_bridge), i2c_disable_bridge },
117
	{ I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_gainset_on), i2c_gainset_on },
118
};
119
120
static int tda8290_tune(struct i2c_client *c)
121
{
122
	struct tuner *t = i2c_get_clientdata(c);
123
	struct i2c_msg easy_mode =
124
		{ I2C_ADDR_TDA8290, 0, 2, t->i2c_easy_mode };
125
	struct i2c_msg set_freq =
126
		{ I2C_ADDR_TDA8275, 0, 8, t->i2c_set_freq  };
127
128
	i2c_transfer(c->adapter, &easy_mode,      1);
129
	i2c_transfer(c->adapter, i2c_msg_prolog, ARRAY_SIZE(i2c_msg_prolog));
130
131
	i2c_transfer(c->adapter, &set_freq,       1);
132
	i2c_transfer(c->adapter, i2c_msg_config, ARRAY_SIZE(i2c_msg_config));
133
134
	msleep(550);
135
	i2c_transfer(c->adapter, i2c_msg_epilog, ARRAY_SIZE(i2c_msg_epilog));
136
	return 0;
137
}
138
139
static void set_frequency(struct tuner *t, u16 ifc)
140
{
141
	u32 N = (((t->freq<<3)+ifc)&0x3fffc);
142
143
	N = N >> get_freq_entry(div_table, t->freq);
144
	t->i2c_set_freq[0] = 0;
145
	t->i2c_set_freq[1] = (unsigned char)(N>>8);
146
	t->i2c_set_freq[2] = (unsigned char) N;
147
	t->i2c_set_freq[3] = 0x40;
148
	t->i2c_set_freq[4] = 0x52;
149
	t->i2c_set_freq[5] = get_freq_entry(band_table, t->freq);
150
	t->i2c_set_freq[6] = get_freq_entry(agc_table,  t->freq);
151
	t->i2c_set_freq[7] = 0x8f;
152
}
153
154
#define V4L2_STD_MN	(V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC)
155
#define V4L2_STD_B	(V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B)
156
#define V4L2_STD_GH	(V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H)
157
#define V4L2_STD_DK	(V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK)
158
159
static void set_audio(struct tuner *t)
160
{
161
	t->i2c_easy_mode[0] = 0x01;
162
163
	if (t->std & V4L2_STD_MN)
164
		t->i2c_easy_mode[1] = 0x01;
165
	else if (t->std & V4L2_STD_B)
166
		t->i2c_easy_mode[1] = 0x02;
167
	else if (t->std & V4L2_STD_GH)
168
		t->i2c_easy_mode[1] = 0x04;
169
	else if (t->std & V4L2_STD_PAL_I)
170
		t->i2c_easy_mode[1] = 0x08;
171
	else if (t->std & V4L2_STD_DK)
172
		t->i2c_easy_mode[1] = 0x10;
173
	else if (t->std & V4L2_STD_SECAM_L)
174
		t->i2c_easy_mode[1] = 0x20;
175
}
176
177
static void set_tv_freq(struct i2c_client *c, unsigned int freq)
178
{
179
	struct tuner *t = i2c_get_clientdata(c);
180
181
	set_audio(t);
182
	set_frequency(t, 864);
183
	tda8290_tune(c);
184
}
185
186
static void set_radio_freq(struct i2c_client *c, unsigned int freq)
187
{
188
	struct tuner *t = i2c_get_clientdata(c);
189
	set_frequency(t, 704);
190
	tda8290_tune(c);
191
}
192
193
static int has_signal(struct i2c_client *c)
194
{
195
	unsigned char i2c_get_afc[1] = { 0x1B };
196
	unsigned char afc = 0;
197
	
198
	i2c_master_send(c, i2c_get_afc, ARRAY_SIZE(i2c_get_afc));
199
	i2c_master_recv(c, &afc, 1);
200
	return (afc & 0x80)? 65535:0;
201
}
202
	
203
int tda8290_init(struct i2c_client *c)
204
{
205
	struct tuner *t = i2c_get_clientdata(c);
206
207
	strlcpy(c->name, "tda8290+75", sizeof(c->name));
208
	tuner_info("tuner: type set to %s\n", c->name);
209
	t->tv_freq    = set_tv_freq;
210
	t->radio_freq = set_radio_freq;
211
	t->has_signal = has_signal;
212
213
	i2c_master_send(c, i2c_enable_bridge, ARRAY_SIZE(i2c_enable_bridge));
214
	i2c_transfer(c->adapter, i2c_msg_init, ARRAY_SIZE(i2c_msg_init));
215
	return 0;
216
}
217
218
/*
219
 * Overrides for Emacs so that we follow Linus's tabbing style.
220
 * ---------------------------------------------------------------------------
221
 * Local variables:
222
 * c-basic-offset: 8
223
 * End:
224
 */
(-)linux-2.6.11.orig/drivers/media/video/tda9887.c (-1 / +1 lines)
Lines 557-563 static int tda9887_configure(struct tda9 Link Here
557
#if 0
557
#if 0
558
	/* This as-is breaks some cards, must be fixed in a
558
	/* This as-is breaks some cards, must be fixed in a
559
	 * card-specific way, probably using TDA9887_SET_CONFIG to
559
	 * card-specific way, probably using TDA9887_SET_CONFIG to
560
	  * turn on/off port2 */
560
	 * turn on/off port2 */
561
	if (t->std & V4L2_STD_SECAM_L) {
561
	if (t->std & V4L2_STD_SECAM_L) {
562
		/* secam fixup (FIXME: move this to tvnorms array?) */
562
		/* secam fixup (FIXME: move this to tvnorms array?) */
563
		buf[1] &= ~cOutputPort2Inactive;
563
		buf[1] &= ~cOutputPort2Inactive;
(-)linux-2.6.11/drivers/media/video/tuner-core.c (+443 lines)
Added Link Here
1
/*
2
 * $Id: tuner-core.c,v 1.5 2005/02/15 15:59:35 kraxel Exp $
3
 *
4
 * i2c tv tuner chip device driver
5
 * core core, i.e. kernel interfaces, registering and so on
6
 */
7
8
#include <linux/module.h>
9
#include <linux/moduleparam.h>
10
#include <linux/kernel.h>
11
#include <linux/sched.h>
12
#include <linux/string.h>
13
#include <linux/timer.h>
14
#include <linux/delay.h>
15
#include <linux/errno.h>
16
#include <linux/slab.h>
17
#include <linux/poll.h>
18
#include <linux/i2c.h>
19
#include <linux/types.h>
20
#include <linux/videodev.h>
21
#include <linux/init.h>
22
23
#include <media/tuner.h>
24
#include <media/audiochip.h>
25
26
#define UNSET (-1U)
27
28
/* standard i2c insmod options */
29
static unsigned short normal_i2c[] = {
30
	0x4b, /* tda8290 */
31
	I2C_CLIENT_END
32
};
33
static unsigned short normal_i2c_range[] = {
34
	0x60, 0x6f,
35
	I2C_CLIENT_END
36
};
37
I2C_CLIENT_INSMOD;
38
39
/* insmod options used at init time => read/only */
40
static unsigned int addr  =  0;
41
module_param(addr, int, 0444);
42
43
/* insmod options used at runtime => read/write */
44
unsigned int tuner_debug   = 0;
45
module_param(tuner_debug,       int, 0644);
46
47
static unsigned int tv_range[2]    = { 44, 958 };
48
static unsigned int radio_range[2] = { 65, 108 };
49
50
module_param_array(tv_range,    int, NULL, 0644);
51
module_param_array(radio_range, int, NULL, 0644);
52
53
MODULE_DESCRIPTION("device driver for various TV and TV+FM radio tuners");
54
MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer");
55
MODULE_LICENSE("GPL");
56
57
static int this_adap;
58
59
static struct i2c_driver driver;
60
static struct i2c_client client_template;
61
62
/* ---------------------------------------------------------------------- */
63
64
// Set tuner frequency,  freq in Units of 62.5kHz = 1/16MHz
65
static void set_tv_freq(struct i2c_client *c, unsigned int freq)
66
{
67
	struct tuner *t = i2c_get_clientdata(c);
68
69
	if (t->type == UNSET) {
70
		tuner_info("tuner type not set\n");
71
		return;
72
	}
73
	if (NULL == t->tv_freq) {
74
		tuner_info("Huh? tv_set is NULL?\n");
75
		return;
76
	}
77
	if (freq < tv_range[0]*16 || freq > tv_range[1]*16) {
78
		/* FIXME: better do that chip-specific, but
79
		   right now we don't have that in the config
80
		   struct and this way is still better than no
81
		   check at all */
82
		tuner_info("TV freq (%d.%02d) out of range (%d-%d)\n",
83
			   freq/16,freq%16*100/16,tv_range[0],tv_range[1]);
84
		return;
85
	}
86
	t->tv_freq(c,freq);
87
}
88
89
static void set_radio_freq(struct i2c_client *c, unsigned int freq)
90
{
91
	struct tuner *t = i2c_get_clientdata(c);
92
93
	if (t->type == UNSET) {
94
		tuner_info("tuner type not set\n");
95
		return;
96
	}
97
	if (NULL == t->radio_freq) {
98
		tuner_info("no radio tuning for this one, sorry.\n");
99
		return;
100
	}
101
	if (freq < radio_range[0]*16 || freq > radio_range[1]*16) {
102
		tuner_info("radio freq (%d.%02d) out of range (%d-%d)\n",
103
			   freq/16,freq%16*100/16,
104
			   radio_range[0],radio_range[1]);
105
		return;
106
	}
107
	t->radio_freq(c,freq);
108
}
109
110
static void set_freq(struct i2c_client *c, unsigned long freq)
111
{
112
	struct tuner *t = i2c_get_clientdata(c);
113
114
	switch (t->mode) {
115
	case V4L2_TUNER_RADIO:
116
		tuner_dbg("radio freq set to %lu.%02lu\n",
117
			  freq/16,freq%16*100/16);
118
		set_radio_freq(c,freq);
119
		break;
120
	case V4L2_TUNER_ANALOG_TV:
121
	case V4L2_TUNER_DIGITAL_TV:
122
		tuner_dbg("tv freq set to %lu.%02lu\n",
123
			  freq/16,freq%16*100/16);
124
		set_tv_freq(c, freq);
125
		break;
126
	}
127
	t->freq = freq;
128
}
129
130
static void set_type(struct i2c_client *c, unsigned int type)
131
{
132
	struct tuner *t = i2c_get_clientdata(c);
133
134
	/* sanity check */
135
	if (type == UNSET  ||  type == TUNER_ABSENT)
136
		return;
137
	if (type >= tuner_count)
138
		return;
139
140
	if (NULL == t->i2c.dev.driver) {
141
		/* not registered yet */
142
		t->type = type;
143
		return;
144
	}
145
	if (t->initialized)
146
		/* run only once */
147
		return;
148
149
	t->initialized = 1;
150
	t->type = type;
151
	switch (t->type) {
152
	case TUNER_MT2032:
153
		microtune_init(c);
154
		break;
155
	case TUNER_PHILIPS_TDA8290:
156
		tda8290_init(c);
157
		break;
158
	default:
159
		default_tuner_init(c);
160
		break;
161
	}
162
}
163
164
static char pal[] = "-";
165
module_param_string(pal, pal, 0644, sizeof(pal));
166
167
static int tuner_fixup_std(struct tuner *t)
168
{
169
	if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) {
170
		/* get more precise norm info from insmod option */
171
		switch (pal[0]) {
172
		case 'b':
173
		case 'B':
174
		case 'g':
175
		case 'G':
176
			tuner_dbg("insmod fixup: PAL => PAL-BG\n");
177
			t->std = V4L2_STD_PAL_BG;
178
			break;
179
		case 'i':
180
		case 'I':
181
			tuner_dbg("insmod fixup: PAL => PAL-I\n");
182
			t->std = V4L2_STD_PAL_I;
183
			break;
184
		case 'd':
185
		case 'D':
186
		case 'k':
187
		case 'K':
188
			tuner_dbg("insmod fixup: PAL => PAL-DK\n");
189
			t->std = V4L2_STD_PAL_DK;
190
			break;
191
		}
192
	}
193
	return 0;
194
}
195
196
/* ---------------------------------------------------------------------- */
197
198
static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
199
{
200
	struct tuner *t;
201
202
	if (this_adap > 0)
203
		return -1;
204
	this_adap++;
205
206
        client_template.adapter = adap;
207
        client_template.addr = addr;
208
209
        t = kmalloc(sizeof(struct tuner),GFP_KERNEL);
210
        if (NULL == t)
211
                return -ENOMEM;
212
        memset(t,0,sizeof(struct tuner));
213
        memcpy(&t->i2c,&client_template,sizeof(struct i2c_client));
214
	i2c_set_clientdata(&t->i2c, t);
215
	t->type       = UNSET;
216
	t->radio_if2  = 10700*1000; // 10.7MHz - FM radio
217
218
        i2c_attach_client(&t->i2c);
219
	tuner_info("chip found @ 0x%x (%s)\n",
220
		   addr << 1, adap->name);
221
	set_type(&t->i2c, t->type);
222
	return 0;
223
}
224
225
static int tuner_probe(struct i2c_adapter *adap)
226
{
227
	if (0 != addr) {
228
		normal_i2c[0]       = addr;
229
		normal_i2c_range[0] = addr;
230
		normal_i2c_range[1] = addr;
231
	}
232
	this_adap = 0;
233
234
	if (adap->class & I2C_CLASS_TV_ANALOG)
235
		return i2c_probe(adap, &addr_data, tuner_attach);
236
	return 0;
237
}
238
239
static int tuner_detach(struct i2c_client *client)
240
{
241
	struct tuner *t = i2c_get_clientdata(client);
242
243
	i2c_detach_client(&t->i2c);
244
	kfree(t);
245
	return 0;
246
}
247
248
#define SWITCH_V4L2	if (!t->using_v4l2 && tuner_debug) \
249
		          tuner_info("switching to v4l2\n"); \
250
	                  t->using_v4l2 = 1;
251
#define CHECK_V4L2	if (t->using_v4l2) { if (tuner_debug) \
252
			  tuner_info("ignore v4l1 call\n"); \
253
		          return 0; }
254
255
static int
256
tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
257
{
258
	struct tuner *t = i2c_get_clientdata(client);
259
        unsigned int *iarg = (int*)arg;
260
261
        switch (cmd) {
262
263
	/* --- configuration --- */
264
	case TUNER_SET_TYPE:
265
		set_type(client,*iarg);
266
		break;
267
	case AUDC_SET_RADIO:
268
		if (V4L2_TUNER_RADIO != t->mode) {
269
			set_tv_freq(client,400 * 16);
270
			t->mode = V4L2_TUNER_RADIO;
271
		}
272
		break;
273
	case AUDC_CONFIG_PINNACLE:
274
		switch (*iarg) {
275
		case 2:
276
			tuner_dbg("pinnacle pal\n");
277
			t->radio_if2 = 33300 * 1000;
278
			break;
279
		case 3:
280
			tuner_dbg("pinnacle ntsc\n");
281
			t->radio_if2 = 41300 * 1000;
282
			break;
283
		}
284
                break;
285
286
	/* --- v4l ioctls --- */
287
	/* take care: bttv does userspace copying, we'll get a
288
	   kernel pointer here... */
289
	case VIDIOCSCHAN:
290
	{
291
		static const v4l2_std_id map[] = {
292
			[ VIDEO_MODE_PAL   ] = V4L2_STD_PAL,
293
			[ VIDEO_MODE_NTSC  ] = V4L2_STD_NTSC_M,
294
			[ VIDEO_MODE_SECAM ] = V4L2_STD_SECAM,
295
			[ 4 /* bttv */     ] = V4L2_STD_PAL_M,
296
			[ 5 /* bttv */     ] = V4L2_STD_PAL_N,
297
			[ 6 /* bttv */     ] = V4L2_STD_NTSC_M_JP,
298
		};
299
		struct video_channel *vc = arg;
300
301
		CHECK_V4L2;
302
		t->mode = V4L2_TUNER_ANALOG_TV;
303
		if (vc->norm < ARRAY_SIZE(map))
304
			t->std = map[vc->norm];
305
		tuner_fixup_std(t);
306
		if (t->freq)
307
			set_tv_freq(client,t->freq);
308
		return 0;
309
	}
310
	case VIDIOCSFREQ:
311
	{
312
		unsigned long *v = arg;
313
314
		CHECK_V4L2;
315
		set_freq(client,*v);
316
		return 0;
317
	}
318
	case VIDIOCGTUNER:
319
	{
320
		struct video_tuner *vt = arg;
321
322
		CHECK_V4L2;
323
		if (V4L2_TUNER_RADIO == t->mode  &&  t->has_signal)
324
			vt->signal = t->has_signal(client);
325
		return 0;
326
	}
327
	case VIDIOCGAUDIO:
328
	{
329
		struct video_audio *va = arg;
330
331
		CHECK_V4L2;
332
		if (V4L2_TUNER_RADIO == t->mode  &&  t->is_stereo)
333
			va->mode = t->is_stereo(client)
334
				? VIDEO_SOUND_STEREO
335
				: VIDEO_SOUND_MONO;
336
		return 0;
337
	}
338
339
	case VIDIOC_S_STD:
340
	{
341
		v4l2_std_id *id = arg;
342
343
		SWITCH_V4L2;
344
		t->mode = V4L2_TUNER_ANALOG_TV;
345
		t->std = *id;
346
		tuner_fixup_std(t);
347
		if (t->freq)
348
			set_freq(client,t->freq);
349
		break;
350
	}
351
	case VIDIOC_S_FREQUENCY:
352
	{
353
		struct v4l2_frequency *f = arg;
354
355
		SWITCH_V4L2;
356
		if (V4L2_TUNER_RADIO == f->type &&
357
		    V4L2_TUNER_RADIO != t->mode)
358
			set_tv_freq(client,400*16);
359
		t->mode  = f->type;
360
		t->freq  = f->frequency;
361
		set_freq(client,t->freq);
362
		break;
363
	}
364
	case VIDIOC_G_TUNER:
365
	{
366
		struct v4l2_tuner *tuner = arg;
367
368
		SWITCH_V4L2;
369
		if (V4L2_TUNER_RADIO == t->mode  &&  t->has_signal)
370
			tuner->signal = t->has_signal(client);
371
		break;
372
	}
373
	default:
374
		/* nothing */
375
		break;
376
	}
377
378
	return 0;
379
}
380
381
static int tuner_suspend(struct device * dev, u32 state, u32 level)
382
{
383
	struct i2c_client *c = container_of(dev, struct i2c_client, dev);
384
	struct tuner *t = i2c_get_clientdata(c);
385
386
	tuner_dbg("suspend\n");
387
	/* FIXME: power down ??? */
388
	return 0;
389
}
390
391
static int tuner_resume(struct device * dev, u32 level)
392
{
393
	struct i2c_client *c = container_of(dev, struct i2c_client, dev);
394
	struct tuner *t = i2c_get_clientdata(c);
395
396
	tuner_dbg("resume\n");
397
	if (t->freq)
398
		set_freq(c,t->freq);
399
	return 0;
400
}
401
402
/* ----------------------------------------------------------------------- */
403
404
static struct i2c_driver driver = {
405
	.owner          = THIS_MODULE,
406
        .name           = "tuner",
407
        .id             = I2C_DRIVERID_TUNER,
408
        .flags          = I2C_DF_NOTIFY,
409
        .attach_adapter = tuner_probe,
410
        .detach_client  = tuner_detach,
411
        .command        = tuner_command,
412
	.driver = {
413
		.suspend = tuner_suspend,
414
		.resume  = tuner_resume,
415
	},
416
};
417
static struct i2c_client client_template =
418
{
419
	I2C_DEVNAME("(tuner unset)"),
420
	.flags      = I2C_CLIENT_ALLOW_USE,
421
        .driver     = &driver,
422
};
423
424
static int __init tuner_init_module(void)
425
{
426
	return i2c_add_driver(&driver);
427
}
428
429
static void __exit tuner_cleanup_module(void)
430
{
431
	i2c_del_driver(&driver);
432
}
433
434
module_init(tuner_init_module);
435
module_exit(tuner_cleanup_module);
436
437
/*
438
 * Overrides for Emacs so that we follow Linus's tabbing style.
439
 * ---------------------------------------------------------------------------
440
 * Local variables:
441
 * c-basic-offset: 8
442
 * End:
443
 */
(-)linux-2.6.11/drivers/media/video/tuner-simple.c (+474 lines)
Added Link Here
1
/*
2
 * $Id: tuner-simple.c,v 1.10 2005/03/08 08:38:00 kraxel Exp $
3
 *
4
 * i2c tv tuner chip device driver
5
 * controls all those simple 4-control-bytes style tuners.
6
 */
7
#include <linux/delay.h>
8
#include <linux/i2c.h>
9
#include <linux/videodev.h>
10
#include <media/tuner.h>
11
12
/* ---------------------------------------------------------------------- */
13
14
/* tv standard selection for Temic 4046 FM5
15
   this value takes the low bits of control byte 2
16
   from datasheet Rev.01, Feb.00
17
     standard     BG      I       L       L2      D
18
     picture IF   38.9    38.9    38.9    33.95   38.9
19
     sound 1      33.4    32.9    32.4    40.45   32.4
20
     sound 2      33.16
21
     NICAM        33.05   32.348  33.05           33.05
22
 */
23
#define TEMIC_SET_PAL_I         0x05
24
#define TEMIC_SET_PAL_DK        0x09
25
#define TEMIC_SET_PAL_L         0x0a // SECAM ?
26
#define TEMIC_SET_PAL_L2        0x0b // change IF !
27
#define TEMIC_SET_PAL_BG        0x0c
28
29
/* tv tuner system standard selection for Philips FQ1216ME
30
   this value takes the low bits of control byte 2
31
   from datasheet "1999 Nov 16" (supersedes "1999 Mar 23")
32
     standard 		BG	DK	I	L	L`
33
     picture carrier	38.90	38.90	38.90	38.90	33.95
34
     colour		34.47	34.47	34.47	34.47	38.38
35
     sound 1		33.40	32.40	32.90	32.40	40.45
36
     sound 2		33.16	-	-	-	-
37
     NICAM		33.05	33.05	32.35	33.05	39.80
38
 */
39
#define PHILIPS_SET_PAL_I	0x01 /* Bit 2 always zero !*/
40
#define PHILIPS_SET_PAL_BGDK	0x09
41
#define PHILIPS_SET_PAL_L2	0x0a
42
#define PHILIPS_SET_PAL_L	0x0b
43
44
/* system switching for Philips FI1216MF MK2
45
   from datasheet "1996 Jul 09",
46
    standard         BG     L      L'
47
    picture carrier  38.90  38.90  33.95
48
    colour	     34.47  34.37  38.38
49
    sound 1          33.40  32.40  40.45
50
    sound 2          33.16  -      -
51
    NICAM            33.05  33.05  39.80
52
 */
53
#define PHILIPS_MF_SET_BG	0x01 /* Bit 2 must be zero, Bit 3 is system output */
54
#define PHILIPS_MF_SET_PAL_L	0x03 // France
55
#define PHILIPS_MF_SET_PAL_L2	0x02 // L'
56
57
58
/* ---------------------------------------------------------------------- */
59
60
struct tunertype
61
{
62
	char *name;
63
	unsigned char Vendor;
64
	unsigned char Type;
65
66
	unsigned short thresh1;  /*  band switch VHF_LO <=> VHF_HI  */
67
	unsigned short thresh2;  /*  band switch VHF_HI <=> UHF     */
68
	unsigned char VHF_L;
69
	unsigned char VHF_H;
70
	unsigned char UHF;
71
	unsigned char config;
72
	unsigned short IFPCoff; /* 622.4=16*38.90 MHz PAL,
73
				   732  =16*45.75 NTSCi,
74
				   940  =16*58.75 NTSC-Japan
75
				   704  =16*44    ATSC */
76
};
77
78
/*
79
 *	The floats in the tuner struct are computed at compile time
80
 *	by gcc and cast back to integers. Thus we don't violate the
81
 *	"no float in kernel" rule.
82
 */
83
static struct tunertype tuners[] = {
84
        { "Temic PAL (4002 FH5)", TEMIC, PAL,
85
	  16*140.25,16*463.25,0x02,0x04,0x01,0x8e,623},
86
	{ "Philips PAL_I (FI1246 and compatibles)", Philips, PAL_I,
87
	  16*140.25,16*463.25,0xa0,0x90,0x30,0x8e,623},
88
	{ "Philips NTSC (FI1236,FM1236 and compatibles)", Philips, NTSC,
89
	  16*157.25,16*451.25,0xA0,0x90,0x30,0x8e,732},
90
	{ "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)", Philips, SECAM,
91
	  16*168.25,16*447.25,0xA7,0x97,0x37,0x8e,623},
92
93
	{ "NoTuner", NoTuner, NOTUNER,
94
	  0,0,0x00,0x00,0x00,0x00,0x00},
95
	{ "Philips PAL_BG (FI1216 and compatibles)", Philips, PAL,
96
	  16*168.25,16*447.25,0xA0,0x90,0x30,0x8e,623},
97
	{ "Temic NTSC (4032 FY5)", TEMIC, NTSC,
98
	  16*157.25,16*463.25,0x02,0x04,0x01,0x8e,732},
99
	{ "Temic PAL_I (4062 FY5)", TEMIC, PAL_I,
100
	  16*170.00,16*450.00,0x02,0x04,0x01,0x8e,623},
101
102
 	{ "Temic NTSC (4036 FY5)", TEMIC, NTSC,
103
	  16*157.25,16*463.25,0xa0,0x90,0x30,0x8e,732},
104
        { "Alps HSBH1", TEMIC, NTSC,
105
	  16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732},
106
        { "Alps TSBE1",TEMIC,PAL,
107
	  16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732},
108
        { "Alps TSBB5", Alps, PAL_I, /* tested (UK UHF) with Modulartech MM205 */
109
	  16*133.25,16*351.25,0x01,0x02,0x08,0x8e,632},
110
111
        { "Alps TSBE5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */
112
	  16*133.25,16*351.25,0x01,0x02,0x08,0x8e,622},
113
        { "Alps TSBC5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */
114
	  16*133.25,16*351.25,0x01,0x02,0x08,0x8e,608},
115
	{ "Temic PAL_BG (4006FH5)", TEMIC, PAL,
116
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
117
  	{ "Alps TSCH6",Alps,NTSC,
118
  	  16*137.25,16*385.25,0x14,0x12,0x11,0x8e,732},
119
120
  	{ "Temic PAL_DK (4016 FY5)",TEMIC,PAL,
121
  	  16*168.25,16*456.25,0xa0,0x90,0x30,0x8e,623},
122
  	{ "Philips NTSC_M (MK2)",Philips,NTSC,
123
  	  16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732},
124
        { "Temic PAL_I (4066 FY5)", TEMIC, PAL_I,
125
          16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623},
126
        { "Temic PAL* auto (4006 FN5)", TEMIC, PAL,
127
          16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623},
128
129
        { "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)", TEMIC, PAL,
130
          16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
131
        { "Temic NTSC (4039 FR5)", TEMIC, NTSC,
132
          16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732},
133
        { "Temic PAL/SECAM multi (4046 FM5)", TEMIC, PAL,
134
          16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623},
135
        { "Philips PAL_DK (FI1256 and compatibles)", Philips, PAL,
136
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
137
138
	{ "Philips PAL/SECAM multi (FQ1216ME)", Philips, PAL,
139
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
140
	{ "LG PAL_I+FM (TAPC-I001D)", LGINNOTEK, PAL_I,
141
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
142
	{ "LG PAL_I (TAPC-I701D)", LGINNOTEK, PAL_I,
143
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
144
	{ "LG NTSC+FM (TPI8NSR01F)", LGINNOTEK, NTSC,
145
	  16*210.00,16*497.00,0xa0,0x90,0x30,0x8e,732},
146
147
	{ "LG PAL_BG+FM (TPI8PSB01D)", LGINNOTEK, PAL,
148
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
149
	{ "LG PAL_BG (TPI8PSB11D)", LGINNOTEK, PAL,
150
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
151
	{ "Temic PAL* auto + FM (4009 FN5)", TEMIC, PAL,
152
	  16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
153
	{ "SHARP NTSC_JP (2U5JF5540)", SHARP, NTSC, /* 940=16*58.75 NTSC@Japan */
154
	  16*137.25,16*317.25,0x01,0x02,0x08,0x8e,940 },
155
156
	{ "Samsung PAL TCPM9091PD27", Samsung, PAL,  /* from sourceforge v3tv */
157
          16*169,16*464,0xA0,0x90,0x30,0x8e,623},
158
	{ "MT20xx universal", Microtune,PAL|NTSC,
159
	  /* see mt20xx.c for details */ },
160
	{ "Temic PAL_BG (4106 FH5)", TEMIC, PAL,
161
          16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
162
	{ "Temic PAL_DK/SECAM_L (4012 FY5)", TEMIC, PAL,
163
          16*140.25, 16*463.25, 0x02,0x04,0x01,0x8e,623},
164
165
	{ "Temic NTSC (4136 FY5)", TEMIC, NTSC,
166
          16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732},
167
        { "LG PAL (newer TAPC series)", LGINNOTEK, PAL,
168
          16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,623},
169
	{ "Philips PAL/SECAM multi (FM1216ME MK3)", Philips, PAL,
170
	  16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 },
171
	{ "LG NTSC (newer TAPC series)", LGINNOTEK, NTSC,
172
          16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,732},
173
174
	{ "HITACHI V7-J180AT", HITACHI, NTSC,
175
	  16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,940 },
176
	{ "Philips PAL_MK (FI1216 MK)", Philips, PAL,
177
	  16*140.25,16*463.25,0x01,0xc2,0xcf,0x8e,623},
178
	{ "Philips 1236D ATSC/NTSC daul in",Philips,ATSC,
179
	  16*157.25,16*454.00,0xa0,0x90,0x30,0x8e,732},
180
        { "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", Philips, NTSC,
181
          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732},
182
183
        { "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", Philips, NTSC,
184
          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732},
185
	{ "Microtune 4049 FM5",Microtune,PAL,
186
	  16*141.00,16*464.00,0xa0,0x90,0x30,0x8e,623},
187
	{ "Panasonic VP27s/ENGE4324D", Panasonic, NTSC,
188
	  16*160.00,16*454.00,0x01,0x02,0x08,0xce,940},
189
        { "LG NTSC (TAPE series)", LGINNOTEK, NTSC,
190
          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 },
191
192
        { "Tenna TNF 8831 BGFF)", Philips, PAL,
193
          16*161.25,16*463.25,0xa0,0x90,0x30,0x8e,623},
194
	{ "Microtune 4042 FI5 ATSC/NTSC dual in", Microtune, NTSC,
195
	  16*162.00,16*457.00,0xa2,0x94,0x31,0x8e,732},
196
        { "TCL 2002N", TCL, NTSC,
197
          16*172.00,16*448.00,0x01,0x02,0x08,0x8e,732},
198
	{ "Philips PAL/SECAM_D (FM 1256 I-H3)", Philips, PAL,
199
	  16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 },
200
201
	{ "Thomson DDT 7610 (ATSC/NTSC)", THOMSON, ATSC,
202
	  16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732},
203
	{ "Philips FQ1286", Philips, NTSC,
204
	  16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, // UHF band untested
205
	{ "tda8290+75", Philips,PAL|NTSC,
206
	  /* see tda8290.c for details */ },
207
	{ "LG PAL (TAPE series)", LGINNOTEK, PAL,
208
          16*170.00, 16*450.00, 0x01,0x02,0x08,0xce,623},
209
210
        { "Philips PAL/SECAM multi (FQ1216AME MK4)", Philips, PAL,
211
          16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 },
212
        { "Philips FQ1236A MK4", Philips, NTSC,
213
          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 },
214
215
};
216
unsigned const int tuner_count = ARRAY_SIZE(tuners);
217
218
/* ---------------------------------------------------------------------- */
219
220
static int tuner_getstatus(struct i2c_client *c)
221
{
222
	unsigned char byte;
223
224
	if (1 != i2c_master_recv(c,&byte,1))
225
		return 0;
226
	return byte;
227
}
228
229
#define TUNER_POR       0x80
230
#define TUNER_FL        0x40
231
#define TUNER_MODE      0x38
232
#define TUNER_AFC       0x07
233
234
#define TUNER_STEREO    0x10 /* radio mode */
235
#define TUNER_SIGNAL    0x07 /* radio mode */
236
237
static int tuner_signal(struct i2c_client *c)
238
{
239
	return (tuner_getstatus(c) & TUNER_SIGNAL)<<13;
240
}
241
242
static int tuner_stereo(struct i2c_client *c)
243
{
244
	return (tuner_getstatus (c) & TUNER_STEREO);
245
}
246
247
#if 0 /* unused */
248
static int tuner_islocked (struct i2c_client *c)
249
{
250
        return (tuner_getstatus (c) & TUNER_FL);
251
}
252
253
static int tuner_afcstatus (struct i2c_client *c)
254
{
255
        return (tuner_getstatus (c) & TUNER_AFC) - 2;
256
}
257
258
static int tuner_mode (struct i2c_client *c)
259
{
260
        return (tuner_getstatus (c) & TUNER_MODE) >> 3;
261
}
262
#endif
263
264
/* ---------------------------------------------------------------------- */
265
266
static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
267
{
268
	struct tuner *t = i2c_get_clientdata(c);
269
	u8 config;
270
	u16 div;
271
	struct tunertype *tun;
272
        unsigned char buffer[4];
273
	int rc;
274
275
	tun = &tuners[t->type];
276
	if (freq < tun->thresh1) {
277
		config = tun->VHF_L;
278
		tuner_dbg("tv: VHF lowrange\n");
279
	} else if (freq < tun->thresh2) {
280
		config = tun->VHF_H;
281
		tuner_dbg("tv: VHF high range\n");
282
	} else {
283
		config = tun->UHF;
284
		tuner_dbg("tv: UHF range\n");
285
	}
286
287
288
	/* tv norm specific stuff for multi-norm tuners */
289
	switch (t->type) {
290
	case TUNER_PHILIPS_SECAM: // FI1216MF
291
		/* 0x01 -> ??? no change ??? */
292
		/* 0x02 -> PAL BDGHI / SECAM L */
293
		/* 0x04 -> ??? PAL others / SECAM others ??? */
294
		config &= ~0x02;
295
		if (t->std & V4L2_STD_SECAM)
296
			config |= 0x02;
297
		break;
298
299
	case TUNER_TEMIC_4046FM5:
300
		config &= ~0x0f;
301
302
		if (t->std & V4L2_STD_PAL_BG) {
303
			config |= TEMIC_SET_PAL_BG;
304
305
		} else if (t->std & V4L2_STD_PAL_I) {
306
			config |= TEMIC_SET_PAL_I;
307
308
		} else if (t->std & V4L2_STD_PAL_DK) {
309
			config |= TEMIC_SET_PAL_DK;
310
311
		} else if (t->std & V4L2_STD_SECAM_L) {
312
			config |= TEMIC_SET_PAL_L;
313
314
		}
315
		break;
316
317
	case TUNER_PHILIPS_FQ1216ME:
318
		config &= ~0x0f;
319
320
		if (t->std & (V4L2_STD_PAL_BG|V4L2_STD_PAL_DK)) {
321
			config |= PHILIPS_SET_PAL_BGDK;
322
323
		} else if (t->std & V4L2_STD_PAL_I) {
324
			config |= PHILIPS_SET_PAL_I;
325
326
		} else if (t->std & V4L2_STD_SECAM_L) {
327
			config |= PHILIPS_SET_PAL_L;
328
329
		}
330
		break;
331
332
	case TUNER_PHILIPS_ATSC:
333
		/* 0x00 -> ATSC antenna input 1 */
334
		/* 0x01 -> ATSC antenna input 2 */
335
		/* 0x02 -> NTSC antenna input 1 */
336
		/* 0x03 -> NTSC antenna input 2 */
337
		config &= ~0x03;
338
		if (!(t->std & V4L2_STD_ATSC))
339
			config |= 2;
340
		/* FIXME: input */
341
		break;
342
343
	case TUNER_MICROTUNE_4042FI5:
344
		/* Set the charge pump for fast tuning */
345
		tun->config |= 0x40;
346
		break;
347
	}
348
349
	/*
350
	 * Philips FI1216MK2 remark from specification :
351
	 * for channel selection involving band switching, and to ensure
352
	 * smooth tuning to the desired channel without causing
353
	 * unnecessary charge pump action, it is recommended to consider
354
	 * the difference between wanted channel frequency and the
355
	 * current channel frequency.  Unnecessary charge pump action
356
	 * will result in very low tuning voltage which may drive the
357
	 * oscillator to extreme conditions.
358
	 *
359
	 * Progfou: specification says to send config data before
360
	 * frequency in case (wanted frequency < current frequency).
361
	 */
362
363
	div=freq + tun->IFPCoff;
364
	if (t->type == TUNER_PHILIPS_SECAM && freq < t->freq) {
365
		buffer[0] = tun->config;
366
		buffer[1] = config;
367
		buffer[2] = (div>>8) & 0x7f;
368
		buffer[3] = div      & 0xff;
369
	} else {
370
		buffer[0] = (div>>8) & 0x7f;
371
		buffer[1] = div      & 0xff;
372
		buffer[2] = tun->config;
373
		buffer[3] = config;
374
	}
375
	tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
376
		  buffer[0],buffer[1],buffer[2],buffer[3]);
377
378
        if (4 != (rc = i2c_master_send(c,buffer,4)))
379
		tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
380
381
	if (t->type == TUNER_MICROTUNE_4042FI5) {
382
		// FIXME - this may also work for other tuners
383
		unsigned long timeout = jiffies + msecs_to_jiffies(1);
384
		u8 status_byte = 0;
385
386
		/* Wait until the PLL locks */
387
		for (;;) {
388
			if (time_after(jiffies,timeout))
389
				return;
390
			if (1 != (rc = i2c_master_recv(c,&status_byte,1))) {
391
				tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc);
392
				break;
393
			}
394
			/* bit 6 is PLL locked indicator */
395
			if (status_byte & 0x40)
396
				break;
397
			udelay(10);
398
		}
399
400
		/* Set the charge pump for optimized phase noise figure */
401
		tun->config &= ~0x40;
402
		buffer[0] = (div>>8) & 0x7f;
403
		buffer[1] = div      & 0xff;
404
		buffer[2] = tun->config;
405
		buffer[3] = config;
406
		tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
407
		       buffer[0],buffer[1],buffer[2],buffer[3]);
408
409
		if (4 != (rc = i2c_master_send(c,buffer,4)))
410
			tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
411
	}
412
}
413
414
static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
415
{
416
	struct tunertype *tun;
417
	struct tuner *t = i2c_get_clientdata(c);
418
        unsigned char buffer[4];
419
	unsigned div;
420
	int rc;
421
422
	tun=&tuners[t->type];
423
	div = freq + (int)(16*10.7);
424
	buffer[2] = tun->config;
425
426
	switch (t->type) {
427
	case TUNER_PHILIPS_FM1216ME_MK3:
428
	case TUNER_PHILIPS_FM1236_MK3:
429
		buffer[3] = 0x19;
430
		break;
431
	case TUNER_PHILIPS_FM1256_IH3:
432
		div = (20 * freq)/16 + 333 * 2;
433
	        buffer[2] = 0x80;
434
		buffer[3] = 0x19;
435
		break;
436
	case TUNER_LG_PAL_FM:
437
		buffer[3] = 0xa5;
438
		break;
439
	default:
440
		buffer[3] = 0xa4;
441
		break;
442
	}
443
        buffer[0] = (div>>8) & 0x7f;
444
        buffer[1] = div      & 0xff;
445
446
	tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
447
	       buffer[0],buffer[1],buffer[2],buffer[3]);
448
449
        if (4 != (rc = i2c_master_send(c,buffer,4)))
450
		tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
451
}
452
453
int default_tuner_init(struct i2c_client *c)
454
{
455
	struct tuner *t = i2c_get_clientdata(c);
456
457
	tuner_info("type set to %d (%s)\n",
458
		   t->type, tuners[t->type].name);
459
	strlcpy(c->name, tuners[t->type].name, sizeof(c->name));
460
461
	t->tv_freq    = default_set_tv_freq;
462
	t->radio_freq = default_set_radio_freq;
463
	t->has_signal = tuner_signal;
464
	t->is_stereo  = tuner_stereo;
465
	return 0;
466
}
467
468
/*
469
 * Overrides for Emacs so that we follow Linus's tabbing style.
470
 * ---------------------------------------------------------------------------
471
 * Local variables:
472
 * c-basic-offset: 8
473
 * End:
474
 */
(-)linux-2.6.11.orig/drivers/media/video/tuner.c (-1425 lines)
Removed Link Here
1
/*
2
 * $Id: tuner.c,v 1.36 2005/01/14 13:29:40 kraxel Exp $
3
 */
4
5
#include <linux/module.h>
6
#include <linux/moduleparam.h>
7
#include <linux/kernel.h>
8
#include <linux/sched.h>
9
#include <linux/string.h>
10
#include <linux/timer.h>
11
#include <linux/delay.h>
12
#include <linux/errno.h>
13
#include <linux/slab.h>
14
#include <linux/poll.h>
15
#include <linux/i2c.h>
16
#include <linux/types.h>
17
#include <linux/videodev.h>
18
#include <linux/init.h>
19
20
#include <media/tuner.h>
21
#include <media/audiochip.h>
22
23
#define UNSET (-1U)
24
25
/* standard i2c insmod options */
26
static unsigned short normal_i2c[] = {I2C_CLIENT_END};
27
static unsigned short normal_i2c_range[] = {0x60,0x6f,I2C_CLIENT_END};
28
I2C_CLIENT_INSMOD;
29
30
/* insmod options used at init time => read/only */
31
static unsigned int type  =  UNSET;
32
static unsigned int addr  =  0;
33
module_param(type, int, 0444);
34
module_param(addr, int, 0444);
35
36
/* insmod options used at runtime => read/write */
37
static unsigned int debug         = 0;
38
static unsigned int tv_antenna    = 1;
39
static unsigned int radio_antenna = 0;
40
static unsigned int optimize_vco  = 1;
41
module_param(debug,             int, 0644);
42
module_param(tv_antenna,        int, 0644);
43
module_param(radio_antenna,     int, 0644);
44
module_param(optimize_vco,      int, 0644);
45
46
static unsigned int tv_range[2]    = { 44, 958 };
47
static unsigned int radio_range[2] = { 65, 108 };
48
49
module_param_array(tv_range,    int, NULL, 0644);
50
module_param_array(radio_range, int, NULL, 0644);
51
52
MODULE_DESCRIPTION("device driver for various TV and TV+FM radio tuners");
53
MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer");
54
MODULE_LICENSE("GPL");
55
56
static int this_adap;
57
#define dprintk     if (debug) printk
58
59
struct tuner {
60
	unsigned int type;            /* chip type */
61
	unsigned int freq;            /* keep track of the current settings */
62
	v4l2_std_id  std;
63
	int          using_v4l2;
64
65
	enum v4l2_tuner_type mode;
66
	unsigned int input;
67
68
	// only for MT2032
69
	unsigned int xogc;
70
	unsigned int radio_if2;
71
72
	void (*tv_freq)(struct i2c_client *c, unsigned int freq);
73
	void (*radio_freq)(struct i2c_client *c, unsigned int freq);
74
};
75
76
static struct i2c_driver driver;
77
static struct i2c_client client_template;
78
79
/* ---------------------------------------------------------------------- */
80
81
/* tv standard selection for Temic 4046 FM5
82
   this value takes the low bits of control byte 2
83
   from datasheet Rev.01, Feb.00
84
     standard     BG      I       L       L2      D
85
     picture IF   38.9    38.9    38.9    33.95   38.9
86
     sound 1      33.4    32.9    32.4    40.45   32.4
87
     sound 2      33.16
88
     NICAM        33.05   32.348  33.05           33.05
89
 */
90
#define TEMIC_SET_PAL_I         0x05
91
#define TEMIC_SET_PAL_DK        0x09
92
#define TEMIC_SET_PAL_L         0x0a // SECAM ?
93
#define TEMIC_SET_PAL_L2        0x0b // change IF !
94
#define TEMIC_SET_PAL_BG        0x0c
95
96
/* tv tuner system standard selection for Philips FQ1216ME
97
   this value takes the low bits of control byte 2
98
   from datasheet "1999 Nov 16" (supersedes "1999 Mar 23")
99
     standard 		BG	DK	I	L	L`
100
     picture carrier	38.90	38.90	38.90	38.90	33.95
101
     colour		34.47	34.47	34.47	34.47	38.38
102
     sound 1		33.40	32.40	32.90	32.40	40.45
103
     sound 2		33.16	-	-	-	-
104
     NICAM		33.05	33.05	32.35	33.05	39.80
105
 */
106
#define PHILIPS_SET_PAL_I	0x01 /* Bit 2 always zero !*/
107
#define PHILIPS_SET_PAL_BGDK	0x09
108
#define PHILIPS_SET_PAL_L2	0x0a
109
#define PHILIPS_SET_PAL_L	0x0b
110
111
/* system switching for Philips FI1216MF MK2
112
   from datasheet "1996 Jul 09",
113
    standard         BG     L      L'
114
    picture carrier  38.90  38.90  33.95
115
    colour	     34.47  34.37  38.38
116
    sound 1          33.40  32.40  40.45
117
    sound 2          33.16  -      -
118
    NICAM            33.05  33.05  39.80
119
 */
120
#define PHILIPS_MF_SET_BG	0x01 /* Bit 2 must be zero, Bit 3 is system output */
121
#define PHILIPS_MF_SET_PAL_L	0x03 // France
122
#define PHILIPS_MF_SET_PAL_L2	0x02 // L'
123
124
125
/* ---------------------------------------------------------------------- */
126
127
struct tunertype
128
{
129
	char *name;
130
	unsigned char Vendor;
131
	unsigned char Type;
132
133
	unsigned short thresh1;  /*  band switch VHF_LO <=> VHF_HI  */
134
	unsigned short thresh2;  /*  band switch VHF_HI <=> UHF     */
135
	unsigned char VHF_L;
136
	unsigned char VHF_H;
137
	unsigned char UHF;
138
	unsigned char config;
139
	unsigned short IFPCoff; /* 622.4=16*38.90 MHz PAL,
140
				   732  =16*45.75 NTSCi,
141
				   940  =16*58.75 NTSC-Japan
142
				   704  =16*44    ATSC */
143
};
144
145
/*
146
 *	The floats in the tuner struct are computed at compile time
147
 *	by gcc and cast back to integers. Thus we don't violate the
148
 *	"no float in kernel" rule.
149
 */
150
static struct tunertype tuners[] = {
151
        { "Temic PAL (4002 FH5)", TEMIC, PAL,
152
	  16*140.25,16*463.25,0x02,0x04,0x01,0x8e,623},
153
	{ "Philips PAL_I (FI1246 and compatibles)", Philips, PAL_I,
154
	  16*140.25,16*463.25,0xa0,0x90,0x30,0x8e,623},
155
	{ "Philips NTSC (FI1236,FM1236 and compatibles)", Philips, NTSC,
156
	  16*157.25,16*451.25,0xA0,0x90,0x30,0x8e,732},
157
	{ "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)", Philips, SECAM,
158
	  16*168.25,16*447.25,0xA7,0x97,0x37,0x8e,623},
159
160
	{ "NoTuner", NoTuner, NOTUNER,
161
	  0,0,0x00,0x00,0x00,0x00,0x00},
162
	{ "Philips PAL_BG (FI1216 and compatibles)", Philips, PAL,
163
	  16*168.25,16*447.25,0xA0,0x90,0x30,0x8e,623},
164
	{ "Temic NTSC (4032 FY5)", TEMIC, NTSC,
165
	  16*157.25,16*463.25,0x02,0x04,0x01,0x8e,732},
166
	{ "Temic PAL_I (4062 FY5)", TEMIC, PAL_I,
167
	  16*170.00,16*450.00,0x02,0x04,0x01,0x8e,623},
168
169
 	{ "Temic NTSC (4036 FY5)", TEMIC, NTSC,
170
	  16*157.25,16*463.25,0xa0,0x90,0x30,0x8e,732},
171
        { "Alps HSBH1", TEMIC, NTSC,
172
	  16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732},
173
        { "Alps TSBE1",TEMIC,PAL,
174
	  16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732},
175
        { "Alps TSBB5", Alps, PAL_I, /* tested (UK UHF) with Modulartech MM205 */
176
	  16*133.25,16*351.25,0x01,0x02,0x08,0x8e,632},
177
178
        { "Alps TSBE5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */
179
	  16*133.25,16*351.25,0x01,0x02,0x08,0x8e,622},
180
        { "Alps TSBC5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */
181
	  16*133.25,16*351.25,0x01,0x02,0x08,0x8e,608},
182
	{ "Temic PAL_BG (4006FH5)", TEMIC, PAL,
183
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
184
  	{ "Alps TSCH6",Alps,NTSC,
185
  	  16*137.25,16*385.25,0x14,0x12,0x11,0x8e,732},
186
187
  	{ "Temic PAL_DK (4016 FY5)",TEMIC,PAL,
188
  	  16*168.25,16*456.25,0xa0,0x90,0x30,0x8e,623},
189
  	{ "Philips NTSC_M (MK2)",Philips,NTSC,
190
  	  16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732},
191
        { "Temic PAL_I (4066 FY5)", TEMIC, PAL_I,
192
          16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623},
193
        { "Temic PAL* auto (4006 FN5)", TEMIC, PAL,
194
          16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623},
195
196
        { "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)", TEMIC, PAL,
197
          16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
198
        { "Temic NTSC (4039 FR5)", TEMIC, NTSC,
199
          16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732},
200
        { "Temic PAL/SECAM multi (4046 FM5)", TEMIC, PAL,
201
          16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623},
202
        { "Philips PAL_DK (FI1256 and compatibles)", Philips, PAL,
203
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
204
205
	{ "Philips PAL/SECAM multi (FQ1216ME)", Philips, PAL,
206
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
207
	{ "LG PAL_I+FM (TAPC-I001D)", LGINNOTEK, PAL_I,
208
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
209
	{ "LG PAL_I (TAPC-I701D)", LGINNOTEK, PAL_I,
210
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
211
	{ "LG NTSC+FM (TPI8NSR01F)", LGINNOTEK, NTSC,
212
	  16*210.00,16*497.00,0xa0,0x90,0x30,0x8e,732},
213
214
	{ "LG PAL_BG+FM (TPI8PSB01D)", LGINNOTEK, PAL,
215
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
216
	{ "LG PAL_BG (TPI8PSB11D)", LGINNOTEK, PAL,
217
	  16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623},
218
	{ "Temic PAL* auto + FM (4009 FN5)", TEMIC, PAL,
219
	  16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
220
	{ "SHARP NTSC_JP (2U5JF5540)", SHARP, NTSC, /* 940=16*58.75 NTSC@Japan */
221
	  16*137.25,16*317.25,0x01,0x02,0x08,0x8e,940 },
222
223
	{ "Samsung PAL TCPM9091PD27", Samsung, PAL,  /* from sourceforge v3tv */
224
          16*169,16*464,0xA0,0x90,0x30,0x8e,623},
225
	{ "MT20xx universal", Microtune,PAL|NTSC,
226
               0,0,0,0,0,0,0},
227
	{ "Temic PAL_BG (4106 FH5)", TEMIC, PAL,
228
          16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
229
	{ "Temic PAL_DK/SECAM_L (4012 FY5)", TEMIC, PAL,
230
          16*140.25, 16*463.25, 0x02,0x04,0x01,0x8e,623},
231
232
	{ "Temic NTSC (4136 FY5)", TEMIC, NTSC,
233
          16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732},
234
        { "LG PAL (newer TAPC series)", LGINNOTEK, PAL,
235
          16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,623},
236
	{ "Philips PAL/SECAM multi (FM1216ME MK3)", Philips, PAL,
237
	  16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 },
238
	{ "LG NTSC (newer TAPC series)", LGINNOTEK, NTSC,
239
          16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,732},
240
241
	{ "HITACHI V7-J180AT", HITACHI, NTSC,
242
	  16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,940 },
243
	{ "Philips PAL_MK (FI1216 MK)", Philips, PAL,
244
	  16*140.25,16*463.25,0x01,0xc2,0xcf,0x8e,623},
245
	{ "Philips 1236D ATSC/NTSC daul in",Philips,ATSC,
246
	  16*157.25,16*454.00,0xa0,0x90,0x30,0x8e,732},
247
        { "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", Philips, NTSC,
248
          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732},
249
250
        { "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", Philips, NTSC,
251
          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732},
252
	{ "Microtune 4049 FM5",Microtune,PAL,
253
	  16*141.00,16*464.00,0xa0,0x90,0x30,0x8e,623},
254
	{ "Panasonic VP27s/ENGE4324D", Panasonic, NTSC,
255
	  16*160.00,16*454.00,0x01,0x02,0x08,0xce,940},
256
        { "LG NTSC (TAPE series)", LGINNOTEK, NTSC,
257
          16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 },
258
259
        { "Tenna TNF 8831 BGFF)", Philips, PAL,
260
          16*161.25,16*463.25,0xa0,0x90,0x30,0x8e,623},
261
	{ "Microtune 4042 FI5 ATSC/NTSC dual in", Microtune, NTSC,
262
	  16*162.00,16*457.00,0xa2,0x94,0x31,0x8e,732},
263
        { "TCL 2002N", TCL, NTSC,
264
          16*172.00,16*448.00,0x01,0x02,0x08,0x8e,732},
265
	{ "Philips PAL/SECAM_D (FM 1256 I-H3)", Philips, PAL,
266
	  16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 },
267
268
	{ "Thomson DDT 7610 ATSC/NTSC)", THOMSON, ATSC,
269
	  16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732},
270
	{ "Philips FQ1286", Philips, NTSC,
271
	  16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, // UHF band untested
272
273
};
274
#define TUNERS ARRAY_SIZE(tuners)
275
276
/* ---------------------------------------------------------------------- */
277
278
static int tuner_getstatus(struct i2c_client *c)
279
{
280
	unsigned char byte;
281
282
	struct tuner *t = i2c_get_clientdata(c);
283
284
        if (t->type == TUNER_MT2032)
285
		return 0;
286
287
	if (1 != i2c_master_recv(c,&byte,1))
288
		return 0;
289
	return byte;
290
}
291
292
#define TUNER_POR       0x80
293
#define TUNER_FL        0x40
294
#define TUNER_MODE      0x38
295
#define TUNER_AFC       0x07
296
297
#define TUNER_STEREO    0x10 /* radio mode */
298
#define TUNER_SIGNAL    0x07 /* radio mode */
299
300
static int tuner_signal(struct i2c_client *c)
301
{
302
	return (tuner_getstatus(c) & TUNER_SIGNAL)<<13;
303
}
304
305
static int tuner_stereo(struct i2c_client *c)
306
{
307
	return (tuner_getstatus (c) & TUNER_STEREO);
308
}
309
310
#if 0 /* unused */
311
static int tuner_islocked (struct i2c_client *c)
312
{
313
        return (tuner_getstatus (c) & TUNER_FL);
314
}
315
316
static int tuner_afcstatus (struct i2c_client *c)
317
{
318
        return (tuner_getstatus (c) & TUNER_AFC) - 2;
319
}
320
321
static int tuner_mode (struct i2c_client *c)
322
{
323
        return (tuner_getstatus (c) & TUNER_MODE) >> 3;
324
}
325
#endif
326
327
/* ---------------------------------------------------------------------- */
328
329
#define MT2032 0x04
330
#define MT2030 0x06
331
#define MT2040 0x07
332
#define MT2050 0x42
333
334
static char *microtune_part[] = {
335
	[ MT2030 ] = "MT2030",
336
	[ MT2032 ] = "MT2032",
337
	[ MT2040 ] = "MT2040",
338
	[ MT2050 ] = "MT2050",
339
};
340
341
// IsSpurInBand()?
342
static int mt2032_spurcheck(int f1, int f2, int spectrum_from,int spectrum_to)
343
{
344
	int n1=1,n2,f;
345
346
	f1=f1/1000; //scale to kHz to avoid 32bit overflows
347
	f2=f2/1000;
348
	spectrum_from/=1000;
349
	spectrum_to/=1000;
350
351
	dprintk("spurcheck f1=%d f2=%d  from=%d to=%d\n",f1,f2,spectrum_from,spectrum_to);
352
353
	do {
354
	    n2=-n1;
355
	    f=n1*(f1-f2);
356
	    do {
357
		n2--;
358
		f=f-f2;
359
		dprintk(" spurtest n1=%d n2=%d ftest=%d\n",n1,n2,f);
360
361
		if( (f>spectrum_from) && (f<spectrum_to))
362
			printk("mt2032 spurcheck triggered: %d\n",n1);
363
	    } while ( (f>(f2-spectrum_to)) || (n2>-5));
364
	    n1++;
365
	} while (n1<5);
366
367
	return 1;
368
}
369
370
static int mt2032_compute_freq(unsigned int rfin,
371
			       unsigned int if1, unsigned int if2,
372
			       unsigned int spectrum_from,
373
			       unsigned int spectrum_to,
374
			       unsigned char *buf,
375
			       int *ret_sel,
376
			       unsigned int xogc) //all in Hz
377
{
378
        unsigned int fref,lo1,lo1n,lo1a,s,sel,lo1freq, desired_lo1,
379
		desired_lo2,lo2,lo2n,lo2a,lo2num,lo2freq;
380
381
        fref= 5250 *1000; //5.25MHz
382
	desired_lo1=rfin+if1;
383
384
	lo1=(2*(desired_lo1/1000)+(fref/1000)) / (2*fref/1000);
385
        lo1n=lo1/8;
386
        lo1a=lo1-(lo1n*8);
387
388
        s=rfin/1000/1000+1090;
389
390
	if(optimize_vco) {
391
		if(s>1890) sel=0;
392
		else if(s>1720) sel=1;
393
		else if(s>1530) sel=2;
394
		else if(s>1370) sel=3;
395
		else sel=4; // >1090
396
	}
397
	else {
398
        	if(s>1790) sel=0; // <1958
399
        	else if(s>1617) sel=1;
400
        	else if(s>1449) sel=2;
401
        	else if(s>1291) sel=3;
402
        	else sel=4; // >1090
403
	}
404
	*ret_sel=sel;
405
406
        lo1freq=(lo1a+8*lo1n)*fref;
407
408
        dprintk("mt2032: rfin=%d lo1=%d lo1n=%d lo1a=%d sel=%d, lo1freq=%d\n",
409
		rfin,lo1,lo1n,lo1a,sel,lo1freq);
410
411
        desired_lo2=lo1freq-rfin-if2;
412
        lo2=(desired_lo2)/fref;
413
        lo2n=lo2/8;
414
        lo2a=lo2-(lo2n*8);
415
        lo2num=((desired_lo2/1000)%(fref/1000))* 3780/(fref/1000); //scale to fit in 32bit arith
416
        lo2freq=(lo2a+8*lo2n)*fref + lo2num*(fref/1000)/3780*1000;
417
418
        dprintk("mt2032: rfin=%d lo2=%d lo2n=%d lo2a=%d num=%d lo2freq=%d\n",
419
		rfin,lo2,lo2n,lo2a,lo2num,lo2freq);
420
421
        if(lo1a<0 || lo1a>7 || lo1n<17 ||lo1n>48 || lo2a<0 ||lo2a >7 ||lo2n<17 || lo2n>30) {
422
                printk("mt2032: frequency parameters out of range: %d %d %d %d\n",
423
		       lo1a, lo1n, lo2a,lo2n);
424
                return(-1);
425
        }
426
427
	mt2032_spurcheck(lo1freq, desired_lo2,  spectrum_from, spectrum_to);
428
	// should recalculate lo1 (one step up/down)
429
430
	// set up MT2032 register map for transfer over i2c
431
	buf[0]=lo1n-1;
432
	buf[1]=lo1a | (sel<<4);
433
	buf[2]=0x86; // LOGC
434
	buf[3]=0x0f; //reserved
435
	buf[4]=0x1f;
436
	buf[5]=(lo2n-1) | (lo2a<<5);
437
 	if(rfin >400*1000*1000)
438
                buf[6]=0xe4;
439
        else
440
                buf[6]=0xf4; // set PKEN per rev 1.2
441
	buf[7]=8+xogc;
442
	buf[8]=0xc3; //reserved
443
	buf[9]=0x4e; //reserved
444
	buf[10]=0xec; //reserved
445
	buf[11]=(lo2num&0xff);
446
	buf[12]=(lo2num>>8) |0x80; // Lo2RST
447
448
	return 0;
449
}
450
451
static int mt2032_check_lo_lock(struct i2c_client *c)
452
{
453
	int try,lock=0;
454
	unsigned char buf[2];
455
	for(try=0;try<10;try++) {
456
		buf[0]=0x0e;
457
		i2c_master_send(c,buf,1);
458
		i2c_master_recv(c,buf,1);
459
		dprintk("mt2032 Reg.E=0x%02x\n",buf[0]);
460
		lock=buf[0] &0x06;
461
462
		if (lock==6)
463
			break;
464
465
		dprintk("mt2032: pll wait 1ms for lock (0x%2x)\n",buf[0]);
466
		udelay(1000);
467
	}
468
        return lock;
469
}
470
471
static int mt2032_optimize_vco(struct i2c_client *c,int sel,int lock)
472
{
473
	unsigned char buf[2];
474
	int tad1;
475
476
	buf[0]=0x0f;
477
	i2c_master_send(c,buf,1);
478
	i2c_master_recv(c,buf,1);
479
	dprintk("mt2032 Reg.F=0x%02x\n",buf[0]);
480
	tad1=buf[0]&0x07;
481
482
	if(tad1 ==0) return lock;
483
	if(tad1 ==1) return lock;
484
485
	if(tad1==2) {
486
		if(sel==0)
487
			return lock;
488
		else sel--;
489
	}
490
	else {
491
		if(sel<4)
492
			sel++;
493
		else
494
			return lock;
495
	}
496
497
	dprintk("mt2032 optimize_vco: sel=%d\n",sel);
498
499
	buf[0]=0x0f;
500
	buf[1]=sel;
501
        i2c_master_send(c,buf,2);
502
	lock=mt2032_check_lo_lock(c);
503
	return lock;
504
}
505
506
507
static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
508
			       unsigned int if1, unsigned int if2,
509
			       unsigned int from, unsigned int to)
510
{
511
	unsigned char buf[21];
512
	int lint_try,ret,sel,lock=0;
513
	struct tuner *t = i2c_get_clientdata(c);
514
515
	dprintk("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n",rfin,if1,if2,from,to);
516
517
        buf[0]=0;
518
        ret=i2c_master_send(c,buf,1);
519
        i2c_master_recv(c,buf,21);
520
521
	buf[0]=0;
522
	ret=mt2032_compute_freq(rfin,if1,if2,from,to,&buf[1],&sel,t->xogc);
523
	if (ret<0)
524
		return;
525
526
        // send only the relevant registers per Rev. 1.2
527
        buf[0]=0;
528
        ret=i2c_master_send(c,buf,4);
529
        buf[5]=5;
530
        ret=i2c_master_send(c,buf+5,4);
531
        buf[11]=11;
532
        ret=i2c_master_send(c,buf+11,3);
533
        if(ret!=3)
534
                printk("mt2032_set_if_freq failed with %d\n",ret);
535
536
	// wait for PLLs to lock (per manual), retry LINT if not.
537
	for(lint_try=0; lint_try<2; lint_try++) {
538
		lock=mt2032_check_lo_lock(c);
539
540
		if(optimize_vco)
541
			lock=mt2032_optimize_vco(c,sel,lock);
542
		if(lock==6) break;
543
544
		printk("mt2032: re-init PLLs by LINT\n");
545
		buf[0]=7;
546
		buf[1]=0x80 +8+t->xogc; // set LINT to re-init PLLs
547
		i2c_master_send(c,buf,2);
548
		mdelay(10);
549
		buf[1]=8+t->xogc;
550
		i2c_master_send(c,buf,2);
551
        }
552
553
	if (lock!=6)
554
		printk("MT2032 Fatal Error: PLLs didn't lock.\n");
555
556
	buf[0]=2;
557
	buf[1]=0x20; // LOGC for optimal phase noise
558
	ret=i2c_master_send(c,buf,2);
559
	if (ret!=2)
560
		printk("mt2032_set_if_freq2 failed with %d\n",ret);
561
}
562
563
564
static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq)
565
{
566
	struct tuner *t = i2c_get_clientdata(c);
567
	int if2,from,to;
568
569
	// signal bandwidth and picture carrier
570
	if (t->std & V4L2_STD_525_60) {
571
		// NTSC
572
		from = 40750*1000;
573
		to   = 46750*1000;
574
		if2  = 45750*1000;
575
	} else {
576
		// PAL
577
		from = 32900*1000;
578
		to   = 39900*1000;
579
		if2  = 38900*1000;
580
	}
581
582
        mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
583
			   1090*1000*1000, if2, from, to);
584
}
585
586
static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
587
{
588
	struct tuner *t = i2c_get_clientdata(c);
589
	int if2 = t->radio_if2;
590
591
	// per Manual for FM tuning: first if center freq. 1085 MHz
592
        mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
593
			   1085*1000*1000,if2,if2,if2);
594
}
595
596
// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001
597
static int mt2032_init(struct i2c_client *c)
598
{
599
	struct tuner *t = i2c_get_clientdata(c);
600
        unsigned char buf[21];
601
        int ret,xogc,xok=0;
602
603
	// Initialize Registers per spec.
604
        buf[1]=2; // Index to register 2
605
        buf[2]=0xff;
606
        buf[3]=0x0f;
607
        buf[4]=0x1f;
608
        ret=i2c_master_send(c,buf+1,4);
609
610
        buf[5]=6; // Index register 6
611
        buf[6]=0xe4;
612
        buf[7]=0x8f;
613
        buf[8]=0xc3;
614
        buf[9]=0x4e;
615
        buf[10]=0xec;
616
        ret=i2c_master_send(c,buf+5,6);
617
618
        buf[12]=13;  // Index register 13
619
        buf[13]=0x32;
620
        ret=i2c_master_send(c,buf+12,2);
621
622
        // Adjust XOGC (register 7), wait for XOK
623
        xogc=7;
624
        do {
625
		dprintk("mt2032: xogc = 0x%02x\n",xogc&0x07);
626
                mdelay(10);
627
                buf[0]=0x0e;
628
                i2c_master_send(c,buf,1);
629
                i2c_master_recv(c,buf,1);
630
                xok=buf[0]&0x01;
631
                dprintk("mt2032: xok = 0x%02x\n",xok);
632
                if (xok == 1) break;
633
634
                xogc--;
635
                dprintk("mt2032: xogc = 0x%02x\n",xogc&0x07);
636
                if (xogc == 3) {
637
                        xogc=4; // min. 4 per spec
638
                        break;
639
                }
640
                buf[0]=0x07;
641
                buf[1]=0x88 + xogc;
642
                ret=i2c_master_send(c,buf,2);
643
                if (ret!=2)
644
                        printk("mt2032_init failed with %d\n",ret);
645
        } while (xok != 1 );
646
	t->xogc=xogc;
647
648
	t->tv_freq    = mt2032_set_tv_freq;
649
	t->radio_freq = mt2032_set_radio_freq;
650
        return(1);
651
}
652
653
static void mt2050_set_antenna(struct i2c_client *c, unsigned char antenna)
654
{
655
       unsigned char buf[2];
656
       int ret;
657
658
       buf[0] = 6;
659
       buf[1] = antenna ? 0x11 : 0x10;
660
       ret=i2c_master_send(c,buf,2);
661
       dprintk("mt2050: enabled antenna connector %d\n", antenna);
662
}
663
664
static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned int if2)
665
{
666
	unsigned int if1=1218*1000*1000;
667
	unsigned int f_lo1,f_lo2,lo1,lo2,f_lo1_modulo,f_lo2_modulo,num1,num2,div1a,div1b,div2a,div2b;
668
	int ret;
669
	unsigned char buf[6];
670
671
	dprintk("mt2050_set_if_freq freq=%d if1=%d if2=%d\n",
672
		freq,if1,if2);
673
674
	f_lo1=freq+if1;
675
	f_lo1=(f_lo1/1000000)*1000000;
676
677
	f_lo2=f_lo1-freq-if2;
678
	f_lo2=(f_lo2/50000)*50000;
679
680
	lo1=f_lo1/4000000;
681
	lo2=f_lo2/4000000;
682
683
	f_lo1_modulo= f_lo1-(lo1*4000000);
684
	f_lo2_modulo= f_lo2-(lo2*4000000);
685
686
	num1=4*f_lo1_modulo/4000000;
687
	num2=4096*(f_lo2_modulo/1000)/4000;
688
689
	// todo spurchecks
690
691
	div1a=(lo1/12)-1;
692
	div1b=lo1-(div1a+1)*12;
693
694
	div2a=(lo2/8)-1;
695
	div2b=lo2-(div2a+1)*8;
696
697
	if (debug > 1) {
698
		printk("lo1 lo2 = %d %d\n", lo1, lo2);
699
		printk("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n",num1,num2,div1a,div1b,div2a,div2b);
700
	}
701
702
	buf[0]=1;
703
	buf[1]= 4*div1b + num1;
704
	if(freq<275*1000*1000) buf[1] = buf[1]|0x80;
705
706
	buf[2]=div1a;
707
	buf[3]=32*div2b + num2/256;
708
	buf[4]=num2-(num2/256)*256;
709
	buf[5]=div2a;
710
	if(num2!=0) buf[5]=buf[5]|0x40;
711
712
	if (debug > 1) {
713
		int i;
714
		printk("bufs is: ");
715
		for(i=0;i<6;i++)
716
			printk("%x ",buf[i]);
717
		printk("\n");
718
	}
719
720
	ret=i2c_master_send(c,buf,6);
721
        if (ret!=6)
722
                printk("mt2050_set_if_freq failed with %d\n",ret);
723
}
724
725
static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq)
726
{
727
	struct tuner *t = i2c_get_clientdata(c);
728
	unsigned int if2;
729
730
	if (t->std & V4L2_STD_525_60) {
731
		// NTSC
732
                if2 = 45750*1000;
733
        } else {
734
                // PAL
735
                if2 = 38900*1000;
736
        }
737
	if (V4L2_TUNER_DIGITAL_TV == t->mode) {
738
		// testing for DVB ...
739
		if2 = 36150*1000;
740
	}
741
	mt2050_set_if_freq(c, freq*62500, if2);
742
	mt2050_set_antenna(c, tv_antenna);
743
}
744
745
static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq)
746
{
747
	struct tuner *t = i2c_get_clientdata(c);
748
	int if2 = t->radio_if2;
749
750
	mt2050_set_if_freq(c, freq*62500, if2);
751
	mt2050_set_antenna(c, radio_antenna);
752
}
753
754
static int mt2050_init(struct i2c_client *c)
755
{
756
	struct tuner *t = i2c_get_clientdata(c);
757
	unsigned char buf[2];
758
	int ret;
759
760
	buf[0]=6;
761
	buf[1]=0x10;
762
	ret=i2c_master_send(c,buf,2); //  power
763
764
	buf[0]=0x0f;
765
	buf[1]=0x0f;
766
	ret=i2c_master_send(c,buf,2); // m1lo
767
768
	buf[0]=0x0d;
769
	ret=i2c_master_send(c,buf,1);
770
	i2c_master_recv(c,buf,1);
771
772
	dprintk("mt2050: sro is %x\n",buf[0]);
773
	t->tv_freq    = mt2050_set_tv_freq;
774
	t->radio_freq = mt2050_set_radio_freq;
775
	return 0;
776
}
777
778
static int microtune_init(struct i2c_client *c)
779
{
780
	struct tuner *t = i2c_get_clientdata(c);
781
	char *name;
782
        unsigned char buf[21];
783
	int company_code;
784
785
	memset(buf,0,sizeof(buf));
786
	t->tv_freq    = NULL;
787
	t->radio_freq = NULL;
788
	name = "unknown";
789
790
        i2c_master_send(c,buf,1);
791
        i2c_master_recv(c,buf,21);
792
        if(debug) {
793
                int i;
794
                printk(KERN_DEBUG "tuner: MT2032 hexdump:\n");
795
                for(i=0;i<21;i++) {
796
                        printk(" %02x",buf[i]);
797
                        if(((i+1)%8)==0) printk(" ");
798
                        if(((i+1)%16)==0) printk("\n ");
799
                }
800
                printk("\n ");
801
        }
802
	company_code = buf[0x11] << 8 | buf[0x12];
803
        printk("tuner: microtune: companycode=%04x part=%02x rev=%02x\n",
804
	       company_code,buf[0x13],buf[0x14]);
805
806
#if 0
807
	/* seems to cause more problems than it solves ... */
808
	switch (company_code) {
809
	case 0x30bf:
810
	case 0x3cbf:
811
	case 0x3dbf:
812
	case 0x4d54:
813
	case 0x8e81:
814
	case 0x8e91:
815
		/* ok (?) */
816
		break;
817
	default:
818
		printk("tuner: microtune: unknown companycode\n");
819
		return 0;
820
	}
821
#endif
822
823
	if (buf[0x13] < ARRAY_SIZE(microtune_part) &&
824
	    NULL != microtune_part[buf[0x13]])
825
		name = microtune_part[buf[0x13]];
826
	switch (buf[0x13]) {
827
	case MT2032:
828
		mt2032_init(c);
829
		break;
830
	case MT2050:
831
		mt2050_init(c);
832
		break;
833
	default:
834
		printk("tuner: microtune %s found, not (yet?) supported, sorry :-/\n",
835
		       name);
836
                return 0;
837
        }
838
	printk("tuner: microtune %s found, OK\n",name);
839
	return 0;
840
}
841
842
/* ---------------------------------------------------------------------- */
843
844
static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
845
{
846
	struct tuner *t = i2c_get_clientdata(c);
847
	u8 config;
848
	u16 div;
849
	struct tunertype *tun;
850
        unsigned char buffer[4];
851
	int rc;
852
853
	tun = &tuners[t->type];
854
	if (freq < tun->thresh1) {
855
		config = tun->VHF_L;
856
		dprintk("tv: VHF lowrange\n");
857
	} else if (freq < tun->thresh2) {
858
		config = tun->VHF_H;
859
		dprintk("tv: VHF high range\n");
860
	} else {
861
		config = tun->UHF;
862
		dprintk("tv: UHF range\n");
863
	}
864
865
866
	/* tv norm specific stuff for multi-norm tuners */
867
	switch (t->type) {
868
	case TUNER_PHILIPS_SECAM: // FI1216MF
869
		/* 0x01 -> ??? no change ??? */
870
		/* 0x02 -> PAL BDGHI / SECAM L */
871
		/* 0x04 -> ??? PAL others / SECAM others ??? */
872
		config &= ~0x02;
873
		if (t->std & V4L2_STD_SECAM)
874
			config |= 0x02;
875
		break;
876
877
	case TUNER_TEMIC_4046FM5:
878
		config &= ~0x0f;
879
880
		if (t->std & V4L2_STD_PAL_BG) {
881
			config |= TEMIC_SET_PAL_BG;
882
883
		} else if (t->std & V4L2_STD_PAL_I) {
884
			config |= TEMIC_SET_PAL_I;
885
886
		} else if (t->std & V4L2_STD_PAL_DK) {
887
			config |= TEMIC_SET_PAL_DK;
888
889
		} else if (t->std & V4L2_STD_SECAM_L) {
890
			config |= TEMIC_SET_PAL_L;
891
892
		}
893
		break;
894
895
	case TUNER_PHILIPS_FQ1216ME:
896
		config &= ~0x0f;
897
898
		if (t->std & (V4L2_STD_PAL_BG|V4L2_STD_PAL_DK)) {
899
			config |= PHILIPS_SET_PAL_BGDK;
900
901
		} else if (t->std & V4L2_STD_PAL_I) {
902
			config |= PHILIPS_SET_PAL_I;
903
904
		} else if (t->std & V4L2_STD_SECAM_L) {
905
			config |= PHILIPS_SET_PAL_L;
906
907
		}
908
		break;
909
910
	case TUNER_PHILIPS_ATSC:
911
		/* 0x00 -> ATSC antenna input 1 */
912
		/* 0x01 -> ATSC antenna input 2 */
913
		/* 0x02 -> NTSC antenna input 1 */
914
		/* 0x03 -> NTSC antenna input 2 */
915
		config &= ~0x03;
916
		if (!(t->std & V4L2_STD_ATSC))
917
			config |= 2;
918
		/* FIXME: input */
919
		break;
920
921
	case TUNER_MICROTUNE_4042FI5:
922
		/* Set the charge pump for fast tuning */
923
		tun->config |= 0x40;
924
		break;
925
	}
926
927
	/*
928
	 * Philips FI1216MK2 remark from specification :
929
	 * for channel selection involving band switching, and to ensure
930
	 * smooth tuning to the desired channel without causing
931
	 * unnecessary charge pump action, it is recommended to consider
932
	 * the difference between wanted channel frequency and the
933
	 * current channel frequency.  Unnecessary charge pump action
934
	 * will result in very low tuning voltage which may drive the
935
	 * oscillator to extreme conditions.
936
	 *
937
	 * Progfou: specification says to send config data before
938
	 * frequency in case (wanted frequency < current frequency).
939
	 */
940
941
	div=freq + tun->IFPCoff;
942
	if (t->type == TUNER_PHILIPS_SECAM && freq < t->freq) {
943
		buffer[0] = tun->config;
944
		buffer[1] = config;
945
		buffer[2] = (div>>8) & 0x7f;
946
		buffer[3] = div      & 0xff;
947
	} else {
948
		buffer[0] = (div>>8) & 0x7f;
949
		buffer[1] = div      & 0xff;
950
		buffer[2] = tun->config;
951
		buffer[3] = config;
952
	}
953
	dprintk("tuner: tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
954
		buffer[0],buffer[1],buffer[2],buffer[3]);
955
956
        if (4 != (rc = i2c_master_send(c,buffer,4)))
957
                printk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
958
959
	if (t->type == TUNER_MICROTUNE_4042FI5) {
960
		// FIXME - this may also work for other tuners
961
		unsigned long timeout = jiffies + msecs_to_jiffies(1);
962
		u8 status_byte = 0;
963
964
		/* Wait until the PLL locks */
965
		for (;;) {
966
			if (time_after(jiffies,timeout))
967
				return;
968
			if (1 != (rc = i2c_master_recv(c,&status_byte,1))) {
969
				dprintk("tuner: i2c i/o read error: rc == %d (should be 1)\n",rc);
970
				break;
971
			}
972
			/* bit 6 is PLL locked indicator */
973
			if (status_byte & 0x40)
974
				break;
975
			udelay(10);
976
		}
977
978
		/* Set the charge pump for optimized phase noise figure */
979
		tun->config &= ~0x40;
980
		buffer[0] = (div>>8) & 0x7f;
981
		buffer[1] = div      & 0xff;
982
		buffer[2] = tun->config;
983
		buffer[3] = config;
984
		dprintk("tuner: tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
985
			buffer[0],buffer[1],buffer[2],buffer[3]);
986
987
		if (4 != (rc = i2c_master_send(c,buffer,4)))
988
			dprintk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
989
	}
990
}
991
992
static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
993
{
994
	struct tunertype *tun;
995
	struct tuner *t = i2c_get_clientdata(c);
996
        unsigned char buffer[4];
997
	unsigned div;
998
	int rc;
999
1000
	tun=&tuners[t->type];
1001
	div = freq + (int)(16*10.7);
1002
	buffer[2] = tun->config;
1003
1004
	switch (t->type) {
1005
	case TUNER_PHILIPS_FM1216ME_MK3:
1006
	case TUNER_PHILIPS_FM1236_MK3:
1007
		buffer[3] = 0x19;
1008
		break;
1009
	case TUNER_PHILIPS_FM1256_IH3:
1010
		div = (20 * freq)/16 + 333 * 2;
1011
	        buffer[2] = 0x80;
1012
		buffer[3] = 0x19;
1013
		break;
1014
	case TUNER_LG_PAL_FM:
1015
		buffer[3] = 0xa5;
1016
		break;
1017
	default:
1018
		buffer[3] = 0xa4;
1019
		break;
1020
	}
1021
        buffer[0] = (div>>8) & 0x7f;
1022
        buffer[1] = div      & 0xff;
1023
1024
	dprintk("tuner: radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
1025
		buffer[0],buffer[1],buffer[2],buffer[3]);
1026
1027
        if (4 != (rc = i2c_master_send(c,buffer,4)))
1028
                printk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
1029
}
1030
1031
/* ---------------------------------------------------------------------- */
1032
1033
// Set tuner frequency,  freq in Units of 62.5kHz = 1/16MHz
1034
static void set_tv_freq(struct i2c_client *c, unsigned int freq)
1035
{
1036
	struct tuner *t = i2c_get_clientdata(c);
1037
1038
	if (t->type == UNSET) {
1039
		printk("tuner: tuner type not set\n");
1040
		return;
1041
	}
1042
	if (NULL == t->tv_freq) {
1043
		printk("tuner: Huh? tv_set is NULL?\n");
1044
		return;
1045
	}
1046
	if (freq < tv_range[0]*16 || freq > tv_range[1]*16) {
1047
		/* FIXME: better do that chip-specific, but
1048
		   right now we don't have that in the config
1049
		   struct and this way is still better than no
1050
		   check at all */
1051
		printk("tuner: TV freq (%d.%02d) out of range (%d-%d)\n",
1052
		       freq/16,freq%16*100/16,tv_range[0],tv_range[1]);
1053
		return;
1054
	}
1055
	t->tv_freq(c,freq);
1056
}
1057
1058
static void set_radio_freq(struct i2c_client *c, unsigned int freq)
1059
{
1060
	struct tuner *t = i2c_get_clientdata(c);
1061
1062
	if (t->type == UNSET) {
1063
		printk("tuner: tuner type not set\n");
1064
		return;
1065
	}
1066
	if (NULL == t->radio_freq) {
1067
		printk("tuner: no radio tuning for this one, sorry.\n");
1068
		return;
1069
	}
1070
	if (freq < radio_range[0]*16 || freq > radio_range[1]*16) {
1071
		printk("tuner: radio freq (%d.%02d) out of range (%d-%d)\n",
1072
		       freq/16,freq%16*100/16,
1073
		       radio_range[0],radio_range[1]);
1074
		return;
1075
	}
1076
	t->radio_freq(c,freq);
1077
}
1078
1079
static void set_freq(struct i2c_client *c, unsigned long freq)
1080
{
1081
	struct tuner *t = i2c_get_clientdata(c);
1082
1083
	switch (t->mode) {
1084
	case V4L2_TUNER_RADIO:
1085
		dprintk("tuner: radio freq set to %lu.%02lu\n",
1086
			freq/16,freq%16*100/16);
1087
		set_radio_freq(c,freq);
1088
		break;
1089
	case V4L2_TUNER_ANALOG_TV:
1090
	case V4L2_TUNER_DIGITAL_TV:
1091
		dprintk("tuner: tv freq set to %lu.%02lu\n",
1092
			freq/16,freq%16*100/16);
1093
		set_tv_freq(c, freq);
1094
		break;
1095
	}
1096
	t->freq = freq;
1097
}
1098
1099
static void set_type(struct i2c_client *c, unsigned int type, char *source)
1100
{
1101
	struct tuner *t = i2c_get_clientdata(c);
1102
1103
	if (t->type != UNSET && t->type != TUNER_ABSENT) {
1104
		if (t->type != type)
1105
			printk("tuner: type already set to %d, "
1106
			       "ignoring request for %d\n", t->type, type);
1107
		return;
1108
	}
1109
	if (type >= TUNERS)
1110
		return;
1111
1112
	t->type = type;
1113
	printk("tuner: type set to %d (%s) by %s\n",
1114
	       t->type,tuners[t->type].name, source);
1115
	strlcpy(c->name, tuners[t->type].name, sizeof(c->name));
1116
1117
	switch (t->type) {
1118
	case TUNER_MT2032:
1119
		microtune_init(c);
1120
		break;
1121
	default:
1122
		t->tv_freq    = default_set_tv_freq;
1123
		t->radio_freq = default_set_radio_freq;
1124
		break;
1125
	}
1126
}
1127
1128
static char pal[] = "-";
1129
module_param_string(pal, pal, 0644, sizeof(pal));
1130
1131
static int tuner_fixup_std(struct tuner *t)
1132
{
1133
	if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) {
1134
		/* get more precise norm info from insmod option */
1135
		switch (pal[0]) {
1136
		case 'b':
1137
		case 'B':
1138
		case 'g':
1139
		case 'G':
1140
			dprintk("insmod fixup: PAL => PAL-BG\n");
1141
			t->std = V4L2_STD_PAL_BG;
1142
			break;
1143
		case 'i':
1144
		case 'I':
1145
			dprintk("insmod fixup: PAL => PAL-I\n");
1146
			t->std = V4L2_STD_PAL_I;
1147
			break;
1148
		case 'd':
1149
		case 'D':
1150
		case 'k':
1151
		case 'K':
1152
			dprintk("insmod fixup: PAL => PAL-DK\n");
1153
			t->std = V4L2_STD_PAL_DK;
1154
			break;
1155
		}
1156
	}
1157
	return 0;
1158
}
1159
1160
/* ---------------------------------------------------------------------- */
1161
1162
static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
1163
{
1164
	struct tuner *t;
1165
	struct i2c_client *client;
1166
1167
	if (this_adap > 0)
1168
		return -1;
1169
	this_adap++;
1170
1171
        client_template.adapter = adap;
1172
        client_template.addr = addr;
1173
1174
        printk("tuner: chip found at addr 0x%x i2c-bus %s\n",
1175
	       addr<<1, adap->name);
1176
1177
        if (NULL == (client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)))
1178
                return -ENOMEM;
1179
        memcpy(client,&client_template,sizeof(struct i2c_client));
1180
        t = kmalloc(sizeof(struct tuner),GFP_KERNEL);
1181
        if (NULL == t) {
1182
                kfree(client);
1183
                return -ENOMEM;
1184
        }
1185
        memset(t,0,sizeof(struct tuner));
1186
	i2c_set_clientdata(client, t);
1187
	t->type       = UNSET;
1188
	t->radio_if2  = 10700*1000; // 10.7MHz - FM radio
1189
1190
        i2c_attach_client(client);
1191
	if (type < TUNERS) {
1192
		set_type(client, type, "insmod option");
1193
		printk("tuner: The type=<n> insmod option will go away soon.\n");
1194
		printk("tuner: Please use the tuner=<n> option provided by\n");
1195
		printk("tuner: tv aard core driver (bttv, saa7134, ...) instead.\n");
1196
	}
1197
	return 0;
1198
}
1199
1200
static int tuner_probe(struct i2c_adapter *adap)
1201
{
1202
	if (0 != addr) {
1203
		normal_i2c_range[0] = addr;
1204
		normal_i2c_range[1] = addr;
1205
	}
1206
	this_adap = 0;
1207
1208
#ifdef I2C_CLASS_TV_ANALOG
1209
	if (adap->class & I2C_CLASS_TV_ANALOG)
1210
		return i2c_probe(adap, &addr_data, tuner_attach);
1211
#else
1212
	switch (adap->id) {
1213
	case I2C_ALGO_BIT | I2C_HW_SMBUS_VOODOO3:
1214
	case I2C_ALGO_BIT | I2C_HW_B_BT848:
1215
	case I2C_ALGO_BIT | I2C_HW_B_RIVA:
1216
	case I2C_ALGO_SAA7134:
1217
	case I2C_ALGO_SAA7146:
1218
		return i2c_probe(adap, &addr_data, tuner_attach);
1219
		break;
1220
	}
1221
#endif
1222
	return 0;
1223
}
1224
1225
static int tuner_detach(struct i2c_client *client)
1226
{
1227
	struct tuner *t = i2c_get_clientdata(client);
1228
1229
	i2c_detach_client(client);
1230
	kfree(t);
1231
	kfree(client);
1232
	return 0;
1233
}
1234
1235
#define SWITCH_V4L2	if (!t->using_v4l2 && debug) \
1236
		          printk("tuner: switching to v4l2\n"); \
1237
	                  t->using_v4l2 = 1;
1238
#define CHECK_V4L2	if (t->using_v4l2) { if (debug) \
1239
			  printk("tuner: ignore v4l1 call\n"); \
1240
		          return 0; }
1241
1242
static int
1243
tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
1244
{
1245
	struct tuner *t = i2c_get_clientdata(client);
1246
        unsigned int *iarg = (int*)arg;
1247
1248
        switch (cmd) {
1249
1250
	/* --- configuration --- */
1251
	case TUNER_SET_TYPE:
1252
		set_type(client,*iarg,client->adapter->name);
1253
		break;
1254
	case AUDC_SET_RADIO:
1255
		if (V4L2_TUNER_RADIO != t->mode) {
1256
			set_tv_freq(client,400 * 16);
1257
			t->mode = V4L2_TUNER_RADIO;
1258
		}
1259
		break;
1260
	case AUDC_CONFIG_PINNACLE:
1261
		switch (*iarg) {
1262
		case 2:
1263
			dprintk("tuner: pinnacle pal\n");
1264
			t->radio_if2 = 33300 * 1000;
1265
			break;
1266
		case 3:
1267
			dprintk("tuner: pinnacle ntsc\n");
1268
			t->radio_if2 = 41300 * 1000;
1269
			break;
1270
		}
1271
                break;
1272
1273
	/* --- v4l ioctls --- */
1274
	/* take care: bttv does userspace copying, we'll get a
1275
	   kernel pointer here... */
1276
	case VIDIOCSCHAN:
1277
	{
1278
		static const v4l2_std_id map[] = {
1279
			[ VIDEO_MODE_PAL   ] = V4L2_STD_PAL,
1280
			[ VIDEO_MODE_NTSC  ] = V4L2_STD_NTSC_M,
1281
			[ VIDEO_MODE_SECAM ] = V4L2_STD_SECAM,
1282
			[ 4 /* bttv */     ] = V4L2_STD_PAL_M,
1283
			[ 5 /* bttv */     ] = V4L2_STD_PAL_N,
1284
			[ 6 /* bttv */     ] = V4L2_STD_NTSC_M_JP,
1285
		};
1286
		struct video_channel *vc = arg;
1287
1288
		CHECK_V4L2;
1289
		t->mode = V4L2_TUNER_ANALOG_TV;
1290
		if (vc->norm < ARRAY_SIZE(map))
1291
			t->std = map[vc->norm];
1292
		tuner_fixup_std(t);
1293
		if (t->freq)
1294
			set_tv_freq(client,t->freq);
1295
		return 0;
1296
	}
1297
	case VIDIOCSFREQ:
1298
	{
1299
		unsigned long *v = arg;
1300
1301
		CHECK_V4L2;
1302
		set_freq(client,*v);
1303
		return 0;
1304
	}
1305
	case VIDIOCGTUNER:
1306
	{
1307
		struct video_tuner *vt = arg;
1308
1309
		CHECK_V4L2;
1310
		if (V4L2_TUNER_RADIO == t->mode)
1311
			vt->signal = tuner_signal(client);
1312
		return 0;
1313
	}
1314
	case VIDIOCGAUDIO:
1315
	{
1316
		struct video_audio *va = arg;
1317
1318
		CHECK_V4L2;
1319
		if (V4L2_TUNER_RADIO == t->mode)
1320
			va->mode = (tuner_stereo(client) ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO);
1321
		return 0;
1322
	}
1323
1324
	case VIDIOC_S_STD:
1325
	{
1326
		v4l2_std_id *id = arg;
1327
1328
		SWITCH_V4L2;
1329
		t->mode = V4L2_TUNER_ANALOG_TV;
1330
		t->std = *id;
1331
		tuner_fixup_std(t);
1332
		if (t->freq)
1333
			set_freq(client,t->freq);
1334
		break;
1335
	}
1336
	case VIDIOC_S_FREQUENCY:
1337
	{
1338
		struct v4l2_frequency *f = arg;
1339
1340
		SWITCH_V4L2;
1341
		if (V4L2_TUNER_RADIO == f->type &&
1342
		    V4L2_TUNER_RADIO != t->mode)
1343
			set_tv_freq(client,400*16);
1344
		t->mode  = f->type;
1345
		t->freq  = f->frequency;
1346
		set_freq(client,t->freq);
1347
		break;
1348
	}
1349
	case VIDIOC_G_TUNER:
1350
	{
1351
		struct v4l2_tuner *tuner = arg;
1352
1353
		SWITCH_V4L2;
1354
		if (V4L2_TUNER_RADIO == t->mode)
1355
			tuner->signal = tuner_signal(client);
1356
		break;
1357
	}
1358
	default:
1359
		/* nothing */
1360
		break;
1361
	}
1362
1363
	return 0;
1364
}
1365
1366
static int tuner_suspend(struct device * dev, u32 state, u32 level)
1367
{
1368
	dprintk("tuner: suspend\n");
1369
	/* FIXME: power down ??? */
1370
	return 0;
1371
}
1372
1373
static int tuner_resume(struct device * dev, u32 level)
1374
{
1375
	struct i2c_client *c = container_of(dev, struct i2c_client, dev);
1376
	struct tuner *t = i2c_get_clientdata(c);
1377
1378
	dprintk("tuner: resume\n");
1379
	if (t->freq)
1380
		set_freq(c,t->freq);
1381
	return 0;
1382
}
1383
1384
/* ----------------------------------------------------------------------- */
1385
1386
static struct i2c_driver driver = {
1387
	.owner          = THIS_MODULE,
1388
        .name           = "i2c TV tuner driver",
1389
        .id             = I2C_DRIVERID_TUNER,
1390
        .flags          = I2C_DF_NOTIFY,
1391
        .attach_adapter = tuner_probe,
1392
        .detach_client  = tuner_detach,
1393
        .command        = tuner_command,
1394
	.driver = {
1395
		.suspend = tuner_suspend,
1396
		.resume  = tuner_resume,
1397
	},
1398
};
1399
static struct i2c_client client_template =
1400
{
1401
	I2C_DEVNAME("(tuner unset)"),
1402
	.flags      = I2C_CLIENT_ALLOW_USE,
1403
        .driver     = &driver,
1404
};
1405
1406
static int __init tuner_init_module(void)
1407
{
1408
	return i2c_add_driver(&driver);
1409
}
1410
1411
static void __exit tuner_cleanup_module(void)
1412
{
1413
	i2c_del_driver(&driver);
1414
}
1415
1416
module_init(tuner_init_module);
1417
module_exit(tuner_cleanup_module);
1418
1419
/*
1420
 * Overrides for Emacs so that we follow Linus's tabbing style.
1421
 * ---------------------------------------------------------------------------
1422
 * Local variables:
1423
 * c-basic-offset: 8
1424
 * End:
1425
 */
(-)linux-2.6.11.orig/drivers/media/video/tvaudio.c (-1 / +1 lines)
Lines 990-996 static int tda9874a_initialize(struct CH Link Here
990
{
990
{
991
	if (tda9874a_SIF > 2)
991
	if (tda9874a_SIF > 2)
992
		tda9874a_SIF = 1;
992
		tda9874a_SIF = 1;
993
	if (tda9874a_STD >= 8)
993
	if (tda9874a_STD > 8)
994
		tda9874a_STD = 0;
994
		tda9874a_STD = 0;
995
	if(tda9874a_AMSEL > 1)
995
	if(tda9874a_AMSEL > 1)
996
		tda9874a_AMSEL = 0;
996
		tda9874a_AMSEL = 0;
(-)linux-2.6.11.orig/drivers/media/video/tveeprom.c (-10 / +20 lines)
Lines 30-39 Link Here
30
30
31
31
32
#include <linux/module.h>
32
#include <linux/module.h>
33
#include <linux/moduleparam.h>
33
#include <linux/errno.h>
34
#include <linux/errno.h>
34
#include <linux/kernel.h>
35
#include <linux/kernel.h>
35
#include <linux/init.h>
36
#include <linux/init.h>
36
#include <linux/types.h>
37
#include <linux/types.h>
38
#include <linux/videodev.h>
37
#include <linux/i2c.h>
39
#include <linux/i2c.h>
38
40
39
#include <media/tuner.h>
41
#include <media/tuner.h>
Lines 73-79 hauppauge_tuner_fmt[] = Link Here
73
	{ 0x00000007, "PAL(B/G)" },
75
	{ 0x00000007, "PAL(B/G)" },
74
	{ 0x00001000, "NTSC(M)" },
76
	{ 0x00001000, "NTSC(M)" },
75
	{ 0x00000010, "PAL(I)" },
77
	{ 0x00000010, "PAL(I)" },
76
	{ 0x00400000, "SECAM(L/L�)" },
78
	{ 0x00400000, "SECAM(L/L´)" },
77
	{ 0x00000e00, "PAL(D/K)" },
79
	{ 0x00000e00, "PAL(D/K)" },
78
	{ 0x03000000, "ATSC Digital" },
80
	{ 0x03000000, "ATSC Digital" },
79
};
81
};
Lines 190-200 hauppauge_tuner[] = Link Here
190
	{ TUNER_ABSENT,        "TCL MFPE05 2"},
192
	{ TUNER_ABSENT,        "TCL MFPE05 2"},
191
	/* 90-99 */
193
	/* 90-99 */
192
	{ TUNER_ABSENT,        "LG TALN H202T"},
194
	{ TUNER_ABSENT,        "LG TALN H202T"},
193
	{ TUNER_ABSENT,        "Philips FQ1216AME MK4"},
195
	{ TUNER_PHILIPS_FQ1216AME_MK4, "Philips FQ1216AME MK4"},
194
	{ TUNER_ABSENT,        "Philips FQ1236A MK4"},
196
	{ TUNER_PHILIPS_FQ1236A_MK4, "Philips FQ1236A MK4"},
195
	{ TUNER_ABSENT,        "Philips FQ1286A MK4"},
197
	{ TUNER_ABSENT,        "Philips FQ1286A MK4"},
196
	{ TUNER_ABSENT,        "Philips FQ1216ME MK5"},
198
	{ TUNER_ABSENT,        "Philips FQ1216ME MK5"},
197
	{ TUNER_ABSENT,        "Philips FQ1236 MK5"},
199
	{ TUNER_ABSENT,        "Philips FQ1236 MK5"},
200
	{ TUNER_ABSENT,        "Unspecified"},
201
	{ TUNER_LG_PAL_TAPE,   "LG PAL (TAPE Series)"},
198
};
202
};
199
203
200
static char *sndtype[] = {
204
static char *sndtype[] = {
Lines 240-245 static int hasRadioTuner(int tunerType) Link Here
240
                case 61: //PNPEnv_TUNER_TAPE_M001D_MK3:
244
                case 61: //PNPEnv_TUNER_TAPE_M001D_MK3:
241
                case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM:
245
                case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM:
242
                case 89: //PNPEnv_TUNER_TCL_MFPE05_2:
246
                case 89: //PNPEnv_TUNER_TCL_MFPE05_2:
247
                case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4:
243
                    return 1;
248
                    return 1;
244
        }
249
        }
245
        return 0;
250
        return 0;
Lines 255-262 void tveeprom_hauppauge_analog(struct tv Link Here
255
	** if packet[0] & f8 == f8, then EOD and packet[1] == checksum
260
	** if packet[0] & f8 == f8, then EOD and packet[1] == checksum
256
	**
261
	**
257
	** In our (ivtv) case we're interested in the following:
262
	** In our (ivtv) case we're interested in the following:
258
	** tuner type: tag [00].05 or [0a].01 (index into hauppauge_tuners)
263
	** tuner type: tag [00].05 or [0a].01 (index into hauppauge_tuner)
259
	** tuner fmts: tag [00].04 or [0a].00 (bitmask index into hauppauge_fmts)
264
	** tuner fmts: tag [00].04 or [0a].00 (bitmask index into hauppauge_tuner_fmt)
260
	** radio:      tag [00].{last} or [0e].00  (bitmask.  bit2=FM)
265
	** radio:      tag [00].{last} or [0e].00  (bitmask.  bit2=FM)
261
	** audio proc: tag [02].01 or [05].00 (lower nibble indexes lut?)
266
	** audio proc: tag [02].01 or [05].00 (lower nibble indexes lut?)
262
267
Lines 268-278 void tveeprom_hauppauge_analog(struct tv Link Here
268
	** # of inputs/outputs ???
273
	** # of inputs/outputs ???
269
	*/
274
	*/
270
275
271
	int i, j, len, done, tag, tuner = 0, t_format = 0;
276
	int i, j, len, done, beenhere, tag, tuner = 0, t_format = 0;
272
	char *t_name = NULL, *t_fmt_name = NULL;
277
	char *t_name = NULL, *t_fmt_name = NULL;
273
278
274
	dprintk(1, "%s\n",__FUNCTION__);
279
	dprintk(1, "%s\n",__FUNCTION__);
275
	tvee->revision = done = len = 0;
280
	tvee->revision = done = len = beenhere = 0;
276
	for (i = 0; !done && i < 256; i += len) {
281
	for (i = 0; !done && i < 256; i += len) {
277
		dprintk(2, "processing pos = %02x (%02x, %02x)\n",
282
		dprintk(2, "processing pos = %02x (%02x, %02x)\n",
278
			i, eeprom_data[i], eeprom_data[i + 1]);
283
			i, eeprom_data[i], eeprom_data[i + 1]);
Lines 341-349 void tveeprom_hauppauge_analog(struct tv Link Here
341
				(eeprom_data[i+7] << 16);
346
				(eeprom_data[i+7] << 16);
342
			break;
347
			break;
343
		case 0x0a:
348
		case 0x0a:
344
			tuner = eeprom_data[i+2];
349
			if(beenhere == 0) {
345
			t_format = eeprom_data[i+1];
350
				tuner = eeprom_data[i+2];
346
			break;
351
				t_format = eeprom_data[i+1];
352
				beenhere = 1;
353
				break;
354
			} else {
355
				break;
356
			}
347
		case 0x0e:
357
		case 0x0e:
348
			tvee->has_radio = eeprom_data[i+1];
358
			tvee->has_radio = eeprom_data[i+1];
349
			break;
359
			break;
(-)linux-2.6.11.orig/drivers/media/video/video-buf.c (-2 / +11 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: video-buf.c,v 1.17 2004/12/10 12:33:40 kraxel Exp $
2
 * $Id: video-buf.c,v 1.18 2005/02/24 13:32:30 kraxel Exp $
3
 *
3
 *
4
 * generic helper functions for video4linux capture buffers, to handle
4
 * generic helper functions for video4linux capture buffers, to handle
5
 * memory management and PCI DMA.  Right now bttv + saa7134 use it.
5
 * memory management and PCI DMA.  Right now bttv + saa7134 use it.
Lines 217-225 int videobuf_dma_pci_map(struct pci_dev Link Here
217
		return -ENOMEM;
217
		return -ENOMEM;
218
	}
218
	}
219
219
220
	if (!dma->bus_addr)
220
	if (!dma->bus_addr) {
221
		dma->sglen = pci_map_sg(dev,dma->sglist,dma->nr_pages,
221
		dma->sglen = pci_map_sg(dev,dma->sglist,dma->nr_pages,
222
					dma->direction);
222
					dma->direction);
223
		if (0 == dma->sglen) {
224
			printk(KERN_WARNING
225
			       "%s: pci_map_sg failed\n",__FUNCTION__);
226
			kfree(dma->sglist);
227
			dma->sglist = NULL;
228
			dma->sglen = 0;
229
			return -EIO;
230
		}
231
	}
223
	return 0;
232
	return 0;
224
}
233
}
225
234
(-)linux-2.6.11.orig/drivers/media/video/zoran_card.c (-1 / +5 lines)
Lines 41-46 Link Here
41
#include <linux/spinlock.h>
41
#include <linux/spinlock.h>
42
#include <linux/sem.h>
42
#include <linux/sem.h>
43
#include <linux/kmod.h>
43
#include <linux/kmod.h>
44
#include <linux/wait.h>
44
45
45
#include <linux/pci.h>
46
#include <linux/pci.h>
46
#include <linux/interrupt.h>
47
#include <linux/interrupt.h>
Lines 968-973 zoran_open_init_params (struct zoran *zr Link Here
968
static void __devinit
969
static void __devinit
969
test_interrupts (struct zoran *zr)
970
test_interrupts (struct zoran *zr)
970
{
971
{
972
	DEFINE_WAIT(wait);
971
	int timeout, icr;
973
	int timeout, icr;
972
974
973
	clear_interrupt_counters(zr);
975
	clear_interrupt_counters(zr);
Lines 975-981 test_interrupts (struct zoran *zr) Link Here
975
	zr->testing = 1;
977
	zr->testing = 1;
976
	icr = btread(ZR36057_ICR);
978
	icr = btread(ZR36057_ICR);
977
	btwrite(0x78000000 | ZR36057_ICR_IntPinEn, ZR36057_ICR);
979
	btwrite(0x78000000 | ZR36057_ICR_IntPinEn, ZR36057_ICR);
978
	timeout = interruptible_sleep_on_timeout(&zr->test_q, 1 * HZ);
980
	prepare_to_wait(&zr->test_q, &wait, TASK_INTERRUPTIBLE);
981
	timeout = schedule_timeout(HZ);
982
	finish_wait(&zr->test_q, &wait);
979
	btwrite(0, ZR36057_ICR);
983
	btwrite(0, ZR36057_ICR);
980
	btwrite(0x78000000, ZR36057_ISR);
984
	btwrite(0x78000000, ZR36057_ISR);
981
	zr->testing = 0;
985
	zr->testing = 0;
(-)linux-2.6.11.orig/drivers/media/video/zoran_device.c (-5 / +5 lines)
Lines 46-51 Link Here
46
#include <linux/video_decoder.h>
46
#include <linux/video_decoder.h>
47
#include <linux/video_encoder.h>
47
#include <linux/video_encoder.h>
48
#include <linux/delay.h>
48
#include <linux/delay.h>
49
#include <linux/wait.h>
49
50
50
#include <asm/io.h>
51
#include <asm/io.h>
51
52
Lines 696-706 wait_grab_pending (struct zoran *zr) Link Here
696
	if (!zr->v4l_memgrab_active)
697
	if (!zr->v4l_memgrab_active)
697
		return 0;
698
		return 0;
698
699
699
	while (zr->v4l_pend_tail != zr->v4l_pend_head) {
700
	wait_event_interruptible(zr->v4l_capq,
700
		interruptible_sleep_on(&zr->v4l_capq);
701
			(zr->v4l_pend_tail == zr->v4l_pend_head));
701
		if (signal_pending(current))
702
	if (signal_pending(current))
702
			return -ERESTARTSYS;
703
		return -ERESTARTSYS;
703
	}
704
704
705
	spin_lock_irqsave(&zr->spinlock, flags);
705
	spin_lock_irqsave(&zr->spinlock, flags);
706
	zr36057_set_memgrab(zr, 0);
706
	zr36057_set_memgrab(zr, 0);
(-)linux-2.6.11.orig/drivers/media/video/zoran_driver.c (-25 / +23 lines)
Lines 52-57 Link Here
52
#include <linux/slab.h>
52
#include <linux/slab.h>
53
#include <linux/pci.h>
53
#include <linux/pci.h>
54
#include <linux/vmalloc.h>
54
#include <linux/vmalloc.h>
55
#include <linux/wait.h>
55
#include <linux/byteorder/generic.h>
56
#include <linux/byteorder/generic.h>
56
57
57
#include <linux/interrupt.h>
58
#include <linux/interrupt.h>
Lines 918-929 v4l_sync (struct file *file, Link Here
918
	}
919
	}
919
920
920
	/* wait on this buffer to get ready */
921
	/* wait on this buffer to get ready */
921
	while (zr->v4l_buffers.buffer[frame].state == BUZ_STATE_PEND) {
922
	if (!wait_event_interruptible_timeout(zr->v4l_capq,
922
		if (!interruptible_sleep_on_timeout(&zr->v4l_capq, 10 * HZ))
923
				(zr->v4l_buffers.buffer[frame].state != BUZ_STATE_PEND),
923
			return -ETIME;
924
				10*HZ))
924
		else if (signal_pending(current))
925
		return -ETIME;
925
			return -ERESTARTSYS;
926
	if (signal_pending(current))
926
	}
927
		return -ERESTARTSYS;
927
928
928
	/* buffer should now be in BUZ_STATE_DONE */
929
	/* buffer should now be in BUZ_STATE_DONE */
929
	if (zr->v4l_buffers.buffer[frame].state != BUZ_STATE_DONE)
930
	if (zr->v4l_buffers.buffer[frame].state != BUZ_STATE_DONE)
Lines 1107-1113 jpg_sync (struct file *file, Link Here
1107
	struct zoran_fh *fh = file->private_data;
1108
	struct zoran_fh *fh = file->private_data;
1108
	struct zoran *zr = fh->zr;
1109
	struct zoran *zr = fh->zr;
1109
	unsigned long flags;
1110
	unsigned long flags;
1110
	int frame, timeout;
1111
	int frame;
1111
1112
1112
	if (fh->jpg_buffers.active == ZORAN_FREE) {
1113
	if (fh->jpg_buffers.active == ZORAN_FREE) {
1113
		dprintk(1,
1114
		dprintk(1,
Lines 1124-1152 jpg_sync (struct file *file, Link Here
1124
			ZR_DEVNAME(zr));
1125
			ZR_DEVNAME(zr));
1125
		return -EINVAL;
1126
		return -EINVAL;
1126
	}
1127
	}
1127
	while (zr->jpg_que_tail == zr->jpg_dma_tail) {
1128
	if (!wait_event_interruptible_timeout(zr->jpg_capq,
1128
		if (zr->jpg_dma_tail == zr->jpg_dma_head)
1129
			(zr->jpg_que_tail != zr->jpg_dma_tail ||
1129
			break;
1130
			 zr->jpg_dma_tail == zr->jpg_dma_head),
1130
1131
			10*HZ)) {
1131
		timeout =
1132
		int isr;
1132
		    interruptible_sleep_on_timeout(&zr->jpg_capq, 10 * HZ);
1133
		if (!timeout) {
1134
			int isr;
1135
1133
1136
			btand(~ZR36057_JMC_Go_en, ZR36057_JMC);
1134
		btand(~ZR36057_JMC_Go_en, ZR36057_JMC);
1137
			udelay(1);
1135
		udelay(1);
1138
			zr->codec->control(zr->codec, CODEC_G_STATUS,
1136
		zr->codec->control(zr->codec, CODEC_G_STATUS,
1139
					   sizeof(isr), &isr);
1137
					   sizeof(isr), &isr);
1140
			dprintk(1,
1138
		dprintk(1,
1141
				KERN_ERR
1139
			KERN_ERR
1142
				"%s: jpg_sync() - timeout: codec isr=0x%02x\n",
1140
			"%s: jpg_sync() - timeout: codec isr=0x%02x\n",
1143
				ZR_DEVNAME(zr), isr);
1141
			ZR_DEVNAME(zr), isr);
1144
1142
1145
			return -ETIME;
1143
		return -ETIME;
1146
1144
1147
		} else if (signal_pending(current))
1148
			return -ERESTARTSYS;
1149
	}
1145
	}
1146
	if (signal_pending(current))
1147
		return -ERESTARTSYS;
1150
1148
1151
	spin_lock_irqsave(&zr->spinlock, flags);
1149
	spin_lock_irqsave(&zr->spinlock, flags);
1152
1150
(-)linux-2.6.11.orig/drivers/media/video/zr36120.c (-18 / +16 lines)
Lines 30-35 Link Here
30
#include <linux/mm.h>
30
#include <linux/mm.h>
31
#include <linux/pci.h>
31
#include <linux/pci.h>
32
#include <linux/signal.h>
32
#include <linux/signal.h>
33
#include <linux/wait.h>
33
#include <asm/io.h>
34
#include <asm/io.h>
34
#include <asm/pgtable.h>
35
#include <asm/pgtable.h>
35
#include <asm/page.h>
36
#include <asm/page.h>
Lines 899-910 long zoran_read(struct video_device* dev Link Here
899
		zoran_cap(ztv, 1);
900
		zoran_cap(ztv, 1);
900
901
901
		/* wait till this buffer gets grabbed */
902
		/* wait till this buffer gets grabbed */
902
		while (unused->status == FBUFFER_BUSY) {
903
		wait_event_interruptible(ztv->grabq,
903
			interruptible_sleep_on(&ztv->grabq);
904
				(unused->status != FBUFFER_BUSY));
904
			/* see if a signal did it */
905
		/* see if a signal did it */
905
			if (signal_pending(current))
906
		if (signal_pending(current))
906
				return -EINTR;
907
			return -EINTR;
907
		}
908
		done = unused;
908
		done = unused;
909
	}
909
	}
910
	else
910
	else
Lines 1326-1337 int zoran_ioctl(struct video_device* dev Link Here
1326
			return -EINVAL;
1326
			return -EINVAL;
1327
		 case FBUFFER_BUSY:
1327
		 case FBUFFER_BUSY:
1328
			/* wait till this buffer gets grabbed */
1328
			/* wait till this buffer gets grabbed */
1329
			while (ztv->grabinfo[i].status == FBUFFER_BUSY) {
1329
			wait_event_interruptible(ztv->grabq,
1330
				interruptible_sleep_on(&ztv->grabq);
1330
					(ztv->grabinfo[i].status != FBUFFER_BUSY));
1331
				/* see if a signal did it */
1331
			/* see if a signal did it */
1332
				if (signal_pending(current))
1332
			if (signal_pending(current))
1333
					return -EINTR;
1333
				return -EINTR;
1334
			}
1335
			/* don't fall through; a DONE buffer is not UNUSED */
1334
			/* don't fall through; a DONE buffer is not UNUSED */
1336
			break;
1335
			break;
1337
		 case FBUFFER_DONE:
1336
		 case FBUFFER_DONE:
Lines 1640-1651 long vbi_read(struct video_device* dev, Link Here
1640
		zoran_cap(ztv, 1);
1639
		zoran_cap(ztv, 1);
1641
1640
1642
		/* wait till this buffer gets grabbed */
1641
		/* wait till this buffer gets grabbed */
1643
		while (unused->status == FBUFFER_BUSY) {
1642
		wait_event_interruptible(ztv->vbiq,
1644
			interruptible_sleep_on(&ztv->vbiq);
1643
				(unused->status != FBUFFER_BUSY));
1645
			/* see if a signal did it */
1644
		/* see if a signal did it */
1646
			if (signal_pending(current))
1645
		if (signal_pending(current))
1647
				return -EINTR;
1646
			return -EINTR;
1648
		}
1649
		done = unused;
1647
		done = unused;
1650
	}
1648
	}
1651
	else
1649
	else
(-)linux-2.6.11.orig/drivers/scsi/Kconfig (+18 lines)
Lines 137-142 config CHR_DEV_SG Link Here
137
137
138
	  If unsure, say N.
138
	  If unsure, say N.
139
139
140
config CHR_DEV_SCH
141
	tristate "SCSI media changer support"
142
	depends on SCSI
143
	---help---
144
	  This is a driver for SCSI media changers.  Most common devices are
145
	  tape libraries and MOD/CDROM jukeboxes.  *Real* jukeboxes, you
146
	  don't need this for those tiny 6-slot cdrom changers.  Media
147
	  changers are listed as "Type: Medium Changer" in /proc/scsi/scsi.
148
	  If you have such hardware and want to use it with linux, say Y
149
	  here.  Check <file:Documentation/scsi-changer.txt> for details.
150
	
151
	  If you want to compile this as a module ( = code which can be
152
	  inserted in and removed from the running kernel whenever you want),
153
	  say M here and read <file:Documentation/modules.txt> and
154
	  <file:Documentation/scsi.txt>. The module will be called ch.o.
155
	  If unsure, say N.
156
	
157
140
comment "Some SCSI devices (e.g. CD jukebox) support multiple LUNs"
158
comment "Some SCSI devices (e.g. CD jukebox) support multiple LUNs"
141
	depends on SCSI
159
	depends on SCSI
142
160
(-)linux-2.6.11.orig/drivers/scsi/Makefile (+1 lines)
Lines 141-146 obj-$(CONFIG_CHR_DEV_OSST) += osst.o Link Here
141
obj-$(CONFIG_BLK_DEV_SD)	+= sd_mod.o
141
obj-$(CONFIG_BLK_DEV_SD)	+= sd_mod.o
142
obj-$(CONFIG_BLK_DEV_SR)	+= sr_mod.o
142
obj-$(CONFIG_BLK_DEV_SR)	+= sr_mod.o
143
obj-$(CONFIG_CHR_DEV_SG)	+= sg.o
143
obj-$(CONFIG_CHR_DEV_SG)	+= sg.o
144
obj-$(CONFIG_CHR_DEV_SCH)	+= ch.o
144
145
145
scsi_mod-y			+= scsi.o hosts.o scsi_ioctl.o constants.o \
146
scsi_mod-y			+= scsi.o hosts.o scsi_ioctl.o constants.o \
146
				   scsicam.o scsi_error.o scsi_lib.o \
147
				   scsicam.o scsi_error.o scsi_lib.o \
(-)linux-2.6.11/drivers/scsi/ch.c (+1020 lines)
Added Link Here
1
/*
2
 * SCSI Media Changer device driver for Linux 2.6
3
 *
4
 *     (c) 1996-2003 Gerd Knorr <kraxel@bytesex.org>
5
 *
6
 */
7
8
#define VERSION "0.24"
9
10
#include <linux/config.h>
11
#include <linux/module.h>
12
#include <linux/init.h>
13
#include <linux/fs.h>
14
#include <linux/kernel.h>
15
#include <linux/sched.h>
16
#include <linux/mm.h>
17
#include <linux/major.h>
18
#include <linux/string.h>
19
#include <linux/errno.h>
20
#include <linux/interrupt.h>
21
#include <linux/blkdev.h>
22
#include <linux/completion.h>
23
#include <linux/devfs_fs_kernel.h>
24
#include <linux/ioctl32.h>
25
#include <linux/compat.h>
26
#include <linux/chio.h>			/* here are all the ioctls */
27
28
#include <scsi/scsi.h>
29
#include <scsi/scsi_cmnd.h>
30
#include <scsi/scsi_driver.h>
31
#include <scsi/scsi_ioctl.h>
32
#include <scsi/scsi_host.h>
33
#include <scsi/scsi_device.h>
34
#include <scsi/scsi_request.h>
35
#include <scsi/scsi_dbg.h>
36
37
#define CH_DT_MAX       16
38
#define CH_TYPES        8
39
40
MODULE_DESCRIPTION("device driver for scsi media changer devices");
41
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org>");
42
MODULE_LICENSE("GPL");
43
44
static int init = 1;
45
module_param(init, int, 0444);
46
MODULE_PARM_DESC(init, \
47
    "initialize element status on driver load (default: on)");
48
49
static int timeout_move = 300;
50
module_param(timeout_move, int, 0644);
51
MODULE_PARM_DESC(timeout_move,"timeout for move commands "
52
		 "(default: 300 seconds)");
53
54
static int timeout_init = 3600;
55
module_param(timeout_init, int, 0644);
56
MODULE_PARM_DESC(timeout_init,"timeout for INITIALIZE ELEMENT STATUS "
57
		 "(default: 3600 seconds)");
58
59
static int verbose = 1;
60
module_param(verbose, int, 0644);
61
MODULE_PARM_DESC(verbose,"be verbose (default: on)");
62
63
static int debug = 0;
64
module_param(debug, int, 0644);
65
MODULE_PARM_DESC(debug,"enable/disable debug messages, also prints more "
66
		 "detailed sense codes on scsi errors (default: off)");
67
68
static int dt_id[CH_DT_MAX] = { [ 0 ... (CH_DT_MAX-1) ] = -1 };
69
static int dt_lun[CH_DT_MAX];
70
module_param_array(dt_id,  int, NULL, 0444);
71
module_param_array(dt_lun, int, NULL, 0444);
72
73
/* tell the driver about vendor-specific slots */
74
static int vendor_firsts[CH_TYPES-4];
75
static int vendor_counts[CH_TYPES-4];
76
module_param_array(vendor_firsts, int, NULL, 0444);
77
module_param_array(vendor_counts, int, NULL, 0444);
78
79
static char *vendor_labels[CH_TYPES-4] = {
80
	"v0", "v1", "v2", "v3"
81
};
82
// module_param_string_array(vendor_labels, NULL, 0444);
83
84
#define dprintk(fmt, arg...)    if (debug) \
85
        printk(KERN_DEBUG "%s: " fmt, ch->name, ##arg)
86
#define vprintk(fmt, arg...)    if (verbose) \
87
        printk(KERN_INFO "%s: " fmt, ch->name, ##arg)
88
89
/* ------------------------------------------------------------------- */
90
91
#define MAX_RETRIES   1
92
93
static int  ch_probe(struct device *);
94
static int  ch_remove(struct device *);
95
static int  ch_open(struct inode * inode, struct file * filp);
96
static int  ch_release(struct inode * inode, struct file * filp);
97
static int  ch_ioctl(struct inode * inode, struct file * filp,
98
		     unsigned int cmd, unsigned long arg);
99
static long ch_ioctl_compat(struct file * filp,
100
			    unsigned int cmd, unsigned long arg);
101
102
typedef struct {
103
	struct list_head    list;
104
	int                 minor;
105
	char                name[8];
106
	struct scsi_device  *device;
107
	struct scsi_device  **dt;        /* ptrs to data transfer elements */
108
	u_int               firsts[CH_TYPES];
109
	u_int               counts[CH_TYPES];
110
	u_int               unit_attention;
111
	u_int		    voltags;
112
	struct semaphore    lock;
113
} scsi_changer;
114
115
static LIST_HEAD(ch_devlist);
116
static spinlock_t ch_devlist_lock = SPIN_LOCK_UNLOCKED;
117
static int ch_devcount;
118
119
struct scsi_driver ch_template =
120
{
121
	.owner     	= THIS_MODULE,
122
	.gendrv     	= {
123
		.name	= "ch",
124
		.probe  = ch_probe,
125
		.remove = ch_remove,
126
	},
127
};
128
129
static struct file_operations changer_fops =
130
{
131
	.owner        = THIS_MODULE,
132
	.open         = ch_open,
133
	.release      = ch_release,
134
	.ioctl        = ch_ioctl,
135
#ifdef CONFIG_COMPAT
136
	.compat_ioctl = ch_ioctl_compat,
137
#endif
138
};
139
140
static struct {
141
	unsigned char  sense;
142
	unsigned char  asc;
143
	unsigned char  ascq;
144
	int	       errno;
145
} err[] = {
146
/* Just filled in what looks right. Hav'nt checked any standard paper for
147
   these errno assignments, so they may be wrong... */
148
	{
149
		.sense  = ILLEGAL_REQUEST,
150
		.asc    = 0x21,
151
		.ascq   = 0x01,
152
		.errno  = EBADSLT, /* Invalid element address */
153
	},{
154
		.sense  = ILLEGAL_REQUEST,
155
		.asc    = 0x28,
156
		.ascq   = 0x01,
157
		.errno  = EBADE,   /* Import or export element accessed */
158
	},{
159
		.sense  = ILLEGAL_REQUEST,
160
		.asc    = 0x3B,
161
		.ascq   = 0x0D,
162
		.errno  = EXFULL,  /* Medium destination element full */
163
	},{
164
		.sense  = ILLEGAL_REQUEST,
165
		.asc    = 0x3B,
166
		.ascq   = 0x0E,
167
		.errno  = EBADE,   /* Medium source element empty */
168
	},{
169
		.sense  = ILLEGAL_REQUEST,
170
		.asc    = 0x20,
171
		.ascq   = 0x00,
172
		.errno  = EBADRQC, /* Invalid command operation code */
173
	},{
174
	        /* end of list */
175
	}
176
};
177
178
/* ------------------------------------------------------------------- */
179
180
static int ch_find_errno(unsigned char *sense_buffer)
181
{
182
	int i,errno = 0;
183
184
	/* Check to see if additional sense information is available */
185
	if (sense_buffer[7]  > 5 &&
186
	    sense_buffer[12] != 0) {
187
		for (i = 0; err[i].errno != 0; i++) {
188
			if (err[i].sense == sense_buffer[ 2] &&
189
			    err[i].asc   == sense_buffer[12] &&
190
			    err[i].ascq  == sense_buffer[13]) {
191
				errno = -err[i].errno;
192
				break;
193
			}
194
		}
195
	}
196
	if (errno == 0)
197
		errno = -EIO;
198
	return errno;
199
}
200
201
static void
202
ch_request_done(struct scsi_cmnd *sc)
203
{
204
	sc->request->rq_status = RQ_SCSI_DONE; /* Busy, but indicate request done */
205
        if (sc->request->waiting != NULL)
206
		complete(sc->request->waiting);
207
}
208
209
static int
210
ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
211
	   void *buffer, unsigned buflength)
212
{
213
	int errno, retries = 0, timeout;
214
	DECLARE_COMPLETION(wait);
215
	struct scsi_request *sr;
216
	
217
	sr = scsi_allocate_request(ch->device, GFP_KERNEL);
218
	if (NULL == sr)
219
		return -ENOMEM;
220
221
 retry:
222
	errno = 0;
223
	if (debug) {
224
		dprintk("command: ");
225
		__scsi_print_command(cmd);
226
	}
227
228
	sr->sr_request->waiting = &wait;
229
	timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
230
		? timeout_init : timeout_move;
231
	scsi_do_req(sr, cmd, buffer, buflength, ch_request_done,
232
		    timeout * HZ, MAX_RETRIES);
233
	wait_for_completion(&wait);
234
	sr->sr_request->waiting = NULL;
235
236
	dprintk("result: 0x%x\n",sr->sr_result);
237
	if (driver_byte(sr->sr_result) != 0) {
238
		if (debug)
239
			scsi_print_req_sense(ch->name, sr);
240
		errno = ch_find_errno(sr->sr_sense_buffer);
241
242
		switch(sr->sr_sense_buffer[2] & 0xf) {
243
		case UNIT_ATTENTION:
244
			ch->unit_attention = 1;
245
			if (retries++ < 3)
246
				goto retry;
247
			break;
248
		}
249
	}
250
	scsi_release_request(sr);
251
	return errno;
252
}
253
254
/* ------------------------------------------------------------------------ */
255
256
static int
257
ch_elem_to_typecode(scsi_changer *ch, u_int elem)
258
{
259
	int i;
260
	
261
	for (i = 0; i < CH_TYPES; i++) {
262
		if (elem >= ch->firsts[i]  &&
263
		    elem <  ch->firsts[i] +
264
	            ch->counts[i])
265
			return i+1;
266
	}
267
	return 0;
268
}
269
270
static int
271
ch_read_element_status(scsi_changer *ch, u_int elem, char *data)
272
{
273
	u_char  cmd[12];
274
	u_char  *buffer;
275
	int     result;
276
	
277
	buffer = kmalloc(512, GFP_KERNEL);
278
	if(!buffer)
279
		return -ENOMEM;
280
	
281
 retry:
282
	memset(cmd,0,sizeof(cmd));
283
	cmd[0] = READ_ELEMENT_STATUS;
284
	cmd[1] = (ch->device->lun << 5) | 
285
		(ch->voltags ? 0x10 : 0) |
286
		ch_elem_to_typecode(ch,elem);
287
	cmd[2] = (elem >> 8) & 0xff;
288
	cmd[3] = elem        & 0xff;
289
	cmd[5] = 1;
290
	cmd[9] = 255;
291
	if (0 == (result = ch_do_scsi(ch, cmd, buffer, 256))) {
292
		if (((buffer[16] << 8) | buffer[17]) != elem) {
293
			dprintk("asked for element 0x%02x, got 0x%02x\n",
294
				elem,(buffer[16] << 8) | buffer[17]);
295
			kfree(buffer);
296
			return -EIO;
297
		}
298
		memcpy(data,buffer+16,16);
299
	} else {
300
		if (ch->voltags) {
301
			ch->voltags = 0;
302
			vprintk("device has no volume tag support%s\n","");
303
			goto retry;
304
		}
305
		dprintk("READ ELEMENT STATUS for element 0x%x failed\n",elem);
306
	}
307
	kfree(buffer);
308
	return result;
309
}
310
311
static int 
312
ch_init_elem(scsi_changer *ch)
313
{
314
	int err;
315
	u_char cmd[6];
316
317
	vprintk("INITIALIZE ELEMENT STATUS, may take some time ...%s\n","");
318
	memset(cmd,0,sizeof(cmd));
319
	cmd[0] = INITIALIZE_ELEMENT_STATUS;
320
	cmd[1] = ch->device->lun << 5;
321
	err = ch_do_scsi(ch, cmd, NULL, 0);
322
	vprintk("... finished%s\n","");
323
	return err;
324
}
325
326
static int
327
ch_readconfig(scsi_changer *ch)
328
{
329
	u_char  cmd[10], data[16];
330
	u_char  *buffer;
331
	int     result,id,lun,i;
332
	u_int   elem;
333
	
334
	buffer = kmalloc(512, GFP_KERNEL);
335
	if (!buffer)
336
		return -ENOMEM;
337
	memset(buffer,0,512);
338
	
339
	memset(cmd,0,sizeof(cmd));
340
	cmd[0] = MODE_SENSE;
341
	cmd[1] = ch->device->lun << 5;
342
	cmd[2] = 0x1d;
343
	cmd[4] = 255;
344
	result = ch_do_scsi(ch, cmd, buffer, 255);
345
	if (0 != result) {
346
		cmd[1] |= (1<<3);
347
		result  = ch_do_scsi(ch, cmd, buffer, 255);
348
	}
349
	if (0 == result) {
350
		ch->firsts[CHET_MT] =
351
			(buffer[buffer[3]+ 6] << 8) | buffer[buffer[3]+ 7];
352
		ch->counts[CHET_MT] =
353
			(buffer[buffer[3]+ 8] << 8) | buffer[buffer[3]+ 9];
354
		ch->firsts[CHET_ST] =
355
			(buffer[buffer[3]+10] << 8) | buffer[buffer[3]+11];
356
		ch->counts[CHET_ST] =
357
			(buffer[buffer[3]+12] << 8) | buffer[buffer[3]+13];
358
		ch->firsts[CHET_IE] =
359
			(buffer[buffer[3]+14] << 8) | buffer[buffer[3]+15];
360
		ch->counts[CHET_IE] =
361
			(buffer[buffer[3]+16] << 8) | buffer[buffer[3]+17];
362
		ch->firsts[CHET_DT] =
363
			(buffer[buffer[3]+18] << 8) | buffer[buffer[3]+19];
364
		ch->counts[CHET_DT] =
365
			(buffer[buffer[3]+20] << 8) | buffer[buffer[3]+21];
366
		vprintk("type #1 (mt): 0x%x+%d [medium transport]\n",
367
			ch->firsts[CHET_MT],
368
			ch->counts[CHET_MT]);
369
		vprintk("type #2 (st): 0x%x+%d [storage]\n",
370
			ch->firsts[CHET_ST],
371
			ch->counts[CHET_ST]);
372
		vprintk("type #3 (ie): 0x%x+%d [import/export]\n",
373
			ch->firsts[CHET_IE],
374
			ch->counts[CHET_IE]);
375
		vprintk("type #4 (dt): 0x%x+%d [data transfer]\n",
376
			ch->firsts[CHET_DT],
377
			ch->counts[CHET_DT]);
378
	} else {
379
		vprintk("reading element address assigment page failed!%s\n",
380
			"");
381
	}
382
	
383
	/* vendor specific element types */
384
	for (i = 0; i < 4; i++) {
385
		if (0 == vendor_counts[i])
386
			continue;
387
		if (NULL == vendor_labels[i])
388
			continue;
389
		ch->firsts[CHET_V1+i] = vendor_firsts[i];
390
		ch->counts[CHET_V1+i] = vendor_counts[i];
391
		vprintk("type #%d (v%d): 0x%x+%d [%s, vendor specific]\n",
392
			i+5,i+1,vendor_firsts[i],vendor_counts[i],
393
			vendor_labels[i]);
394
	}
395
396
	/* look up the devices of the data transfer elements */
397
	ch->dt = kmalloc(ch->counts[CHET_DT]*sizeof(struct scsi_device),
398
			 GFP_KERNEL);
399
	for (elem = 0; elem < ch->counts[CHET_DT]; elem++) {
400
		id  = -1;
401
		lun = 0;
402
		if (-1 != dt_id[elem]) {
403
			id  = dt_id[elem];
404
			lun = dt_lun[elem];
405
			vprintk("dt 0x%x: [insmod option] ",
406
				elem+ch->firsts[CHET_DT]);
407
		} else if (0 != ch_read_element_status
408
			   (ch,elem+ch->firsts[CHET_DT],data)) {
409
			vprintk("dt 0x%x: READ ELEMENT STATUS failed\n",
410
				elem+ch->firsts[CHET_DT]);
411
		} else {
412
			vprintk("dt 0x%x: ",elem+ch->firsts[CHET_DT]);
413
			if (data[6] & 0x80) {
414
				if (verbose)
415
					printk("not this SCSI bus\n");
416
				ch->dt[elem] = NULL;
417
			} else if (0 == (data[6] & 0x30)) {
418
				if (verbose)
419
					printk("ID/LUN unknown\n");
420
				ch->dt[elem] = NULL;
421
			} else {
422
				id  = ch->device->id;
423
				lun = 0;
424
				if (data[6] & 0x20) id  = data[7];
425
				if (data[6] & 0x10) lun = data[6] & 7;
426
			}
427
		}
428
		if (-1 != id) {
429
			if (verbose)
430
				printk("ID %i, LUN %i, ",id,lun);
431
			ch->dt[elem] =
432
				scsi_device_lookup(ch->device->host,
433
						   ch->device->channel,
434
						   id,lun);
435
			if (!ch->dt[elem]) {
436
				/* should not happen */
437
				if (verbose)
438
					printk("Huh? device not found!\n");
439
			} else {
440
				if (verbose)
441
					printk("name: %8.8s %16.16s %4.4s\n",
442
					       ch->dt[elem]->vendor,
443
					       ch->dt[elem]->model,
444
					       ch->dt[elem]->rev);
445
			}
446
		}
447
	}
448
	ch->voltags = 1;
449
	kfree(buffer);
450
451
	return 0;
452
}
453
454
/* ------------------------------------------------------------------------ */
455
456
static int
457
ch_position(scsi_changer *ch, u_int trans, u_int elem, int rotate)
458
{
459
	u_char  cmd[10];
460
	
461
	dprintk("position: 0x%x\n",elem);
462
	if (0 == trans)
463
		trans = ch->firsts[CHET_MT];
464
	memset(cmd,0,sizeof(cmd));
465
	cmd[0]  = POSITION_TO_ELEMENT;
466
	cmd[1]  = ch->device->lun << 5;
467
	cmd[2]  = (trans >> 8) & 0xff;
468
	cmd[3]  =  trans       & 0xff;
469
	cmd[4]  = (elem  >> 8) & 0xff;
470
	cmd[5]  =  elem        & 0xff;
471
	cmd[8]  = rotate ? 1 : 0;
472
	return ch_do_scsi(ch, cmd, NULL,0);
473
}
474
475
static int
476
ch_move(scsi_changer *ch, u_int trans, u_int src, u_int dest, int rotate)
477
{
478
	u_char  cmd[12];
479
	
480
	dprintk("move: 0x%x => 0x%x\n",src,dest);
481
	if (0 == trans)
482
		trans = ch->firsts[CHET_MT];
483
	memset(cmd,0,sizeof(cmd));
484
	cmd[0]  = MOVE_MEDIUM;
485
	cmd[1]  = ch->device->lun << 5;
486
	cmd[2]  = (trans >> 8) & 0xff;
487
	cmd[3]  =  trans       & 0xff;
488
	cmd[4]  = (src   >> 8) & 0xff;
489
	cmd[5]  =  src         & 0xff;
490
	cmd[6]  = (dest  >> 8) & 0xff;
491
	cmd[7]  =  dest        & 0xff;
492
	cmd[10] = rotate ? 1 : 0;
493
	return ch_do_scsi(ch, cmd, NULL,0);
494
}
495
496
static int
497
ch_exchange(scsi_changer *ch, u_int trans, u_int src,
498
	    u_int dest1, u_int dest2, int rotate1, int rotate2)
499
{
500
	u_char  cmd[12];
501
	
502
	dprintk("exchange: 0x%x => 0x%x => 0x%x\n",
503
		src,dest1,dest2);
504
	if (0 == trans)
505
		trans = ch->firsts[CHET_MT];
506
	memset(cmd,0,sizeof(cmd));
507
	cmd[0]  = EXCHANGE_MEDIUM;
508
	cmd[1]  = ch->device->lun << 5;
509
	cmd[2]  = (trans >> 8) & 0xff;
510
	cmd[3]  =  trans       & 0xff;
511
	cmd[4]  = (src   >> 8) & 0xff;
512
	cmd[5]  =  src         & 0xff;
513
	cmd[6]  = (dest1 >> 8) & 0xff;
514
	cmd[7]  =  dest1       & 0xff;
515
	cmd[8]  = (dest2 >> 8) & 0xff;
516
	cmd[9]  =  dest2       & 0xff;
517
	cmd[10] = (rotate1 ? 1 : 0) | (rotate2 ? 2 : 0);
518
	
519
	return ch_do_scsi(ch, cmd, NULL,0);
520
}
521
522
static void
523
ch_check_voltag(char *tag)
524
{
525
	int i;
526
527
	for (i = 0; i < 32; i++) {
528
		/* restrict to ascii */
529
		if (tag[i] >= 0x7f || tag[i] < 0x20)
530
			tag[i] = ' ';
531
		/* don't allow search wildcards */
532
		if (tag[i] == '?' ||
533
		    tag[i] == '*')
534
			tag[i] = ' ';
535
	}
536
}
537
538
static int
539
ch_set_voltag(scsi_changer *ch, u_int elem,
540
	      int alternate, int clear, u_char *tag)
541
{
542
	u_char  cmd[12];
543
	u_char  *buffer;
544
	int result;
545
546
	buffer = kmalloc(512, GFP_KERNEL);
547
	if (!buffer)
548
		return -ENOMEM;
549
	memset(buffer,0,512);
550
551
	dprintk("%s %s voltag: 0x%x => \"%s\"\n",
552
		clear     ? "clear"     : "set",
553
		alternate ? "alternate" : "primary",
554
		elem, tag);
555
	memset(cmd,0,sizeof(cmd));
556
	cmd[0]  = SEND_VOLUME_TAG;
557
	cmd[1] = (ch->device->lun << 5) | 
558
		ch_elem_to_typecode(ch,elem);
559
	cmd[2] = (elem >> 8) & 0xff;
560
	cmd[3] = elem        & 0xff;
561
	cmd[5] = clear
562
		? (alternate ? 0x0d : 0x0c)
563
		: (alternate ? 0x0b : 0x0a);
564
	
565
	cmd[9] = 255;
566
567
	memcpy(buffer,tag,32);
568
	ch_check_voltag(buffer);
569
570
	result = ch_do_scsi(ch, cmd, buffer, 256);
571
	kfree(buffer);
572
	return result;
573
}
574
575
static int ch_gstatus(scsi_changer *ch, int type, unsigned char *dest)
576
{
577
	int retval = 0;
578
	u_char data[16];
579
	unsigned int i;
580
	
581
	down(&ch->lock);
582
	for (i = 0; i < ch->counts[type]; i++) {
583
		if (0 != ch_read_element_status
584
		    (ch, ch->firsts[type]+i,data)) {
585
			retval = -EIO;
586
			break;
587
		}
588
		put_user(data[2], dest+i);
589
		if (data[2] & CESTATUS_EXCEPT)
590
			vprintk("element 0x%x: asc=0x%x, ascq=0x%x\n",
591
				ch->firsts[type]+i,
592
				(int)data[4],(int)data[5]);
593
		retval = ch_read_element_status
594
			(ch, ch->firsts[type]+i,data);
595
		if (0 != retval)
596
			break;
597
	}
598
	up(&ch->lock);
599
	return retval;
600
}
601
602
/* ------------------------------------------------------------------------ */
603
604
static int
605
ch_release(struct inode *inode, struct file *file)
606
{
607
	scsi_changer *ch = file->private_data;
608
609
	scsi_device_put(ch->device);
610
	file->private_data = NULL;
611
	return 0;
612
}
613
614
static int
615
ch_open(struct inode *inode, struct file *file)
616
{
617
	scsi_changer *tmp, *ch;
618
	int minor = iminor(inode);
619
620
	spin_lock(&ch_devlist_lock);
621
	ch = NULL;
622
	list_for_each_entry(tmp,&ch_devlist,list) {
623
		if (tmp->minor == minor)
624
			ch = tmp;
625
	}
626
	if (NULL == ch || scsi_device_get(ch->device)) {
627
		spin_unlock(&ch_devlist_lock);
628
		return -ENXIO;
629
	}
630
	spin_unlock(&ch_devlist_lock);
631
632
	file->private_data = ch;
633
	return 0;
634
}
635
636
static int
637
ch_checkrange(scsi_changer *ch, unsigned int type, unsigned int unit)
638
{
639
	if (type >= CH_TYPES  ||  unit >= ch->counts[type])
640
		return -1;
641
	return 0;
642
}
643
644
static int ch_ioctl(struct inode * inode, struct file * file,
645
		    unsigned int cmd, unsigned long arg)
646
{
647
	scsi_changer *ch = file->private_data;
648
	int retval;
649
	
650
	switch (cmd) {
651
	case CHIOGPARAMS:
652
	{
653
		struct changer_params params;
654
		
655
		params.cp_curpicker = 0;
656
		params.cp_npickers  = ch->counts[CHET_MT];
657
		params.cp_nslots    = ch->counts[CHET_ST];
658
		params.cp_nportals  = ch->counts[CHET_IE];
659
		params.cp_ndrives   = ch->counts[CHET_DT];
660
		
661
		if (copy_to_user((void *) arg, &params, sizeof(params)))
662
			return -EFAULT;
663
		return 0;
664
	}
665
	case CHIOGVPARAMS:
666
	{
667
		struct changer_vendor_params vparams;
668
669
		memset(&vparams,0,sizeof(vparams));
670
		if (ch->counts[CHET_V1]) {
671
			vparams.cvp_n1  = ch->counts[CHET_V1];
672
			strncpy(vparams.cvp_label1,vendor_labels[0],16);
673
		}
674
		if (ch->counts[CHET_V2]) {
675
			vparams.cvp_n2  = ch->counts[CHET_V2];
676
			strncpy(vparams.cvp_label2,vendor_labels[1],16);
677
		}
678
		if (ch->counts[CHET_V3]) {
679
			vparams.cvp_n3  = ch->counts[CHET_V3];
680
			strncpy(vparams.cvp_label3,vendor_labels[2],16);
681
		}
682
		if (ch->counts[CHET_V4]) {
683
			vparams.cvp_n4  = ch->counts[CHET_V4];
684
			strncpy(vparams.cvp_label4,vendor_labels[3],16);
685
		}
686
		if (copy_to_user((void *) arg, &vparams, sizeof(vparams)))
687
			return -EFAULT;
688
		return 0;
689
	}
690
	
691
	case CHIOPOSITION:
692
	{
693
		struct changer_position pos;
694
		
695
		if (copy_from_user(&pos, (void*)arg, sizeof (pos)))
696
			return -EFAULT;
697
698
		if (0 != ch_checkrange(ch, pos.cp_type, pos.cp_unit)) {
699
			dprintk("CHIOPOSITION: invalid parameter%s\n","");
700
			return -EBADSLT;
701
		}
702
		down(&ch->lock);
703
		retval = ch_position(ch,0,
704
				     ch->firsts[pos.cp_type] + pos.cp_unit,
705
				     pos.cp_flags & CP_INVERT);
706
		up(&ch->lock);
707
		return retval;
708
	}
709
	
710
	case CHIOMOVE:
711
	{
712
		struct changer_move mv;
713
714
		if (copy_from_user(&mv, (void*)arg, sizeof (mv)))
715
			return -EFAULT;
716
717
		if (0 != ch_checkrange(ch, mv.cm_fromtype, mv.cm_fromunit) ||
718
		    0 != ch_checkrange(ch, mv.cm_totype,   mv.cm_tounit  )) {
719
			dprintk("CHIOMOVE: invalid parameter%s\n","");
720
			return -EBADSLT;
721
		}
722
		
723
		down(&ch->lock);
724
		retval = ch_move(ch,0,
725
				 ch->firsts[mv.cm_fromtype] + mv.cm_fromunit,
726
				 ch->firsts[mv.cm_totype]   + mv.cm_tounit,
727
				 mv.cm_flags & CM_INVERT);
728
		up(&ch->lock);
729
		return retval;
730
	}
731
732
	case CHIOEXCHANGE:
733
	{
734
		struct changer_exchange mv;
735
		
736
		if (copy_from_user(&mv, (void*)arg, sizeof (mv)))
737
			return -EFAULT;
738
739
		if (0 != ch_checkrange(ch, mv.ce_srctype,  mv.ce_srcunit ) ||
740
		    0 != ch_checkrange(ch, mv.ce_fdsttype, mv.ce_fdstunit) ||
741
		    0 != ch_checkrange(ch, mv.ce_sdsttype, mv.ce_sdstunit)) {
742
			dprintk("CHIOEXCHANGE: invalid parameter%s\n","");
743
			return -EBADSLT;
744
		}
745
		
746
		down(&ch->lock);
747
		retval = ch_exchange
748
			(ch,0,
749
			 ch->firsts[mv.ce_srctype]  + mv.ce_srcunit,
750
			 ch->firsts[mv.ce_fdsttype] + mv.ce_fdstunit,
751
			 ch->firsts[mv.ce_sdsttype] + mv.ce_sdstunit,
752
			 mv.ce_flags & CE_INVERT1, mv.ce_flags & CE_INVERT2);
753
		up(&ch->lock);
754
		return retval;
755
	}
756
757
	case CHIOGSTATUS:
758
	{
759
		struct changer_element_status ces;
760
		
761
		if (copy_from_user(&ces, (void*)arg, sizeof (ces)))
762
			return -EFAULT;
763
		if (ces.ces_type < 0 || ces.ces_type >= CH_TYPES)
764
			return -EINVAL;
765
766
		return ch_gstatus(ch, ces.ces_type, ces.ces_data);
767
	}
768
769
	case CHIOGELEM:
770
	{
771
		struct changer_get_element cge;
772
		u_char  cmd[12];
773
		u_char  *buffer;
774
		unsigned int elem;
775
		int     result,i;
776
		
777
		if (copy_from_user(&cge, (void*)arg, sizeof (cge)))
778
			return -EFAULT;
779
780
		if (0 != ch_checkrange(ch, cge.cge_type, cge.cge_unit))
781
			return -EINVAL;
782
		elem = ch->firsts[cge.cge_type] + cge.cge_unit;
783
		
784
		buffer = kmalloc(512, GFP_KERNEL);
785
		if (!buffer)
786
			return -ENOMEM;
787
		down(&ch->lock);
788
		
789
	voltag_retry:
790
		memset(cmd,0,sizeof(cmd));
791
		cmd[0] = READ_ELEMENT_STATUS;
792
		cmd[1] = (ch->device->lun << 5) |
793
			(ch->voltags ? 0x10 : 0) |
794
			ch_elem_to_typecode(ch,elem);
795
		cmd[2] = (elem >> 8) & 0xff;
796
		cmd[3] = elem        & 0xff;
797
		cmd[5] = 1;
798
		cmd[9] = 255;
799
		
800
		if (0 == (result = ch_do_scsi(ch, cmd, buffer, 256))) {
801
			cge.cge_status = buffer[18];
802
			cge.cge_flags = 0;
803
			if (buffer[18] & CESTATUS_EXCEPT) {
804
				/* FIXME: fill cge_errno */
805
			}
806
			if (buffer[25] & 0x80) {
807
				cge.cge_flags |= CGE_SRC;
808
				if (buffer[25] & 0x40)
809
					cge.cge_flags |= CGE_INVERT;
810
				elem = (buffer[26]<<8) | buffer[27];
811
				for (i = 0; i < 4; i++) {
812
					if (elem >= ch->firsts[i] &&
813
					    elem <  ch->firsts[i] + ch->counts[i]) {
814
						cge.cge_srctype = i;
815
						cge.cge_srcunit = elem-ch->firsts[i];
816
					}
817
				}
818
			}
819
			if ((buffer[22] & 0x30) == 0x30) {
820
				cge.cge_flags |= CGE_IDLUN;
821
				cge.cge_id  = buffer[23];
822
				cge.cge_lun = buffer[22] & 7;
823
			}
824
			if (buffer[9] & 0x80) {
825
				cge.cge_flags |= CGE_PVOLTAG;
826
				memcpy(cge.cge_pvoltag,buffer+28,36);
827
			}
828
			if (buffer[9] & 0x40) {
829
				cge.cge_flags |= CGE_AVOLTAG;
830
				memcpy(cge.cge_avoltag,buffer+64,36);
831
			}
832
		} else if (ch->voltags) {
833
			ch->voltags = 0;
834
			vprintk("device has no volume tag support%s\n","");
835
			goto voltag_retry;
836
		}
837
		kfree(buffer);
838
		up(&ch->lock);
839
		
840
		if (copy_to_user((void*)arg, &cge, sizeof (cge)))
841
			return -EFAULT;
842
		return result;
843
	}
844
845
	case CHIOINITELEM:
846
	{
847
		down(&ch->lock);
848
		retval = ch_init_elem(ch);
849
		up(&ch->lock);
850
		return retval;
851
	}
852
		
853
	case CHIOSVOLTAG:
854
	{
855
		struct changer_set_voltag csv;
856
		int elem;
857
858
		if (copy_from_user(&csv, (void*)arg, sizeof(csv)))
859
			return -EFAULT;
860
861
		if (0 != ch_checkrange(ch, csv.csv_type, csv.csv_unit)) {
862
			dprintk("CHIOSVOLTAG: invalid parameter%s\n","");
863
			return -EBADSLT;
864
		}
865
		elem = ch->firsts[csv.csv_type] + csv.csv_unit;
866
		down(&ch->lock);
867
		retval = ch_set_voltag(ch, elem,
868
				       csv.csv_flags & CSV_AVOLTAG,
869
				       csv.csv_flags & CSV_CLEARTAG,
870
				       csv.csv_voltag);
871
		up(&ch->lock);
872
		return retval;
873
	}
874
875
	default:
876
		return scsi_ioctl(ch->device, cmd, (void*)arg);
877
878
	}
879
}
880
881
#ifdef CONFIG_COMPAT
882
883
struct changer_element_status32 {
884
	int		ces_type;
885
	compat_uptr_t	ces_data;
886
};
887
#define CHIOGSTATUS32  _IOW('c', 8,struct changer_element_status32)
888
889
static long ch_ioctl_compat(struct file * file,
890
			    unsigned int cmd, unsigned long arg)
891
{
892
	scsi_changer *ch = file->private_data;
893
	
894
	switch (cmd) {
895
	case CHIOGPARAMS:
896
	case CHIOGVPARAMS:
897
	case CHIOPOSITION:
898
	case CHIOMOVE:
899
	case CHIOEXCHANGE:
900
	case CHIOGELEM:
901
	case CHIOINITELEM:
902
	case CHIOSVOLTAG:
903
		/* compatible */
904
		return ch_ioctl(NULL /* inode, unused */,
905
				file, cmd, arg);
906
	case CHIOGSTATUS32:
907
	{
908
		struct changer_element_status32 ces32;
909
		unsigned char *data;
910
		
911
		if (copy_from_user(&ces32, (void*)arg, sizeof (ces32)))
912
			return -EFAULT;
913
		if (ces32.ces_type < 0 || ces32.ces_type >= CH_TYPES)
914
			return -EINVAL;
915
916
		data = compat_ptr(ces32.ces_data);
917
		return ch_gstatus(ch, ces32.ces_type, data);
918
	}
919
	default:
920
		// return scsi_ioctl_compat(ch->device, cmd, (void*)arg);
921
		return -ENOIOCTLCMD;
922
923
	}
924
}
925
#endif
926
927
/* ------------------------------------------------------------------------ */
928
929
static int ch_probe(struct device *dev)
930
{
931
	struct scsi_device *sd = to_scsi_device(dev);
932
	scsi_changer *ch;
933
	
934
	if (sd->type != TYPE_MEDIUM_CHANGER)
935
		return -ENODEV;
936
    
937
	ch = kmalloc(sizeof(*ch), GFP_KERNEL);
938
	if (NULL == ch)
939
		return -ENOMEM;
940
941
	memset(ch,0,sizeof(*ch));
942
	ch->minor = ch_devcount;
943
	sprintf(ch->name,"ch%d",ch->minor);
944
	init_MUTEX(&ch->lock);
945
	ch->device = sd;
946
	ch_readconfig(ch);
947
	if (init)
948
		ch_init_elem(ch);
949
950
	devfs_mk_cdev(MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
951
		      S_IFCHR | S_IRUGO | S_IWUGO, ch->name);
952
953
	printk(KERN_INFO "Attached scsi changer %s "
954
	       "at scsi%d, channel %d, id %d, lun %d\n", 
955
	       ch->name, sd->host->host_no, sd->channel, sd->id, sd->lun);
956
	
957
	spin_lock(&ch_devlist_lock);
958
	list_add_tail(&ch->list,&ch_devlist);
959
	ch_devcount++;
960
	spin_unlock(&ch_devlist_lock);
961
	return 0;
962
}
963
964
static int ch_remove(struct device *dev)
965
{
966
	struct scsi_device *sd = to_scsi_device(dev);
967
	scsi_changer *tmp, *ch;
968
969
	spin_lock(&ch_devlist_lock);
970
	ch = NULL;
971
	list_for_each_entry(tmp,&ch_devlist,list) {
972
		if (tmp->device == sd)
973
			ch = tmp;
974
	}
975
	BUG_ON(NULL == ch);
976
	list_del(&ch->list);
977
	spin_unlock(&ch_devlist_lock);
978
979
	devfs_remove(ch->name);
980
	kfree(ch->dt);
981
	kfree(ch);
982
	ch_devcount--;
983
	return 0;
984
}
985
986
static int __init init_ch_module(void)
987
{
988
	int rc;
989
	
990
	printk(KERN_INFO "SCSI Media Changer driver v" VERSION " \n");
991
	rc = register_chrdev(SCSI_CHANGER_MAJOR,"ch",&changer_fops);
992
	if (rc < 0) {
993
		printk("Unable to get major %d for SCSI-Changer\n",
994
		       SCSI_CHANGER_MAJOR);
995
		return rc;
996
	}
997
	rc = scsi_register_driver(&ch_template.gendrv);
998
	if (rc < 0)
999
		goto fail1;
1000
	return 0;
1001
1002
 fail1:
1003
	unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");
1004
	return rc;
1005
}
1006
1007
static void __exit exit_ch_module(void) 
1008
{
1009
	scsi_unregister_driver(&ch_template.gendrv);
1010
	unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");
1011
}
1012
1013
module_init(init_ch_module);
1014
module_exit(exit_ch_module);
1015
1016
/*
1017
 * Local variables:
1018
 * c-basic-offset: 8
1019
 * End:
1020
 */
(-)linux-2.6.11.orig/include/asm-alpha/ioctls.h (+1 lines)
Lines 91-96 Link Here
91
#define TIOCGSID	0x5429  /* Return the session ID of FD */
91
#define TIOCGSID	0x5429  /* Return the session ID of FD */
92
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
92
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
93
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
93
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
94
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
94
95
95
#define TIOCSERCONFIG	0x5453
96
#define TIOCSERCONFIG	0x5453
96
#define TIOCSERGWILD	0x5454
97
#define TIOCSERGWILD	0x5454
(-)linux-2.6.11.orig/include/asm-arm/ioctls.h (+1 lines)
Lines 48-53 Link Here
48
#define TIOCGSID	0x5429  /* Return the session ID of FD */
48
#define TIOCGSID	0x5429  /* Return the session ID of FD */
49
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
49
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
50
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
50
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
51
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
51
52
52
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
53
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
53
#define FIOCLEX		0x5451
54
#define FIOCLEX		0x5451
(-)linux-2.6.11.orig/include/asm-i386/ioctls.h (+1 lines)
Lines 49-54 Link Here
49
#define TIOCGSID	0x5429  /* Return the session ID of FD */
49
#define TIOCGSID	0x5429  /* Return the session ID of FD */
50
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
50
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
51
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
51
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
52
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
52
53
53
#define FIONCLEX	0x5450
54
#define FIONCLEX	0x5450
54
#define FIOCLEX		0x5451
55
#define FIOCLEX		0x5451
(-)linux-2.6.11.orig/include/asm-ia64/ioctls.h (+1 lines)
Lines 55-60 Link Here
55
#define TIOCGSID	0x5429  /* Return the session ID of FD */
55
#define TIOCGSID	0x5429  /* Return the session ID of FD */
56
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
56
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
57
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
57
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
58
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
58
59
59
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
60
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
60
#define FIOCLEX		0x5451
61
#define FIOCLEX		0x5451
(-)linux-2.6.11.orig/include/asm-m68k/ioctls.h (+1 lines)
Lines 48-53 Link Here
48
#define TIOCGSID	0x5429  /* Return the session ID of FD */
48
#define TIOCGSID	0x5429  /* Return the session ID of FD */
49
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
49
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
50
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
50
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
51
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
51
52
52
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
53
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
53
#define FIOCLEX		0x5451
54
#define FIOCLEX		0x5451
(-)linux-2.6.11.orig/include/asm-mips/ioctls.h (+1 lines)
Lines 79-84 Link Here
79
#define TIOCGSID	0x7416  /* Return the session ID of FD */
79
#define TIOCGSID	0x7416  /* Return the session ID of FD */
80
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
80
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
81
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
81
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
82
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
82
83
83
/* I hope the range from 0x5480 on is free ... */
84
/* I hope the range from 0x5480 on is free ... */
84
#define TIOCSCTTY	0x5480		/* become controlling tty */
85
#define TIOCSCTTY	0x5480		/* become controlling tty */
(-)linux-2.6.11.orig/include/asm-ppc/ioctls.h (+1 lines)
Lines 88-93 Link Here
88
#define TIOCGSID	0x5429  /* Return the session ID of FD */
88
#define TIOCGSID	0x5429  /* Return the session ID of FD */
89
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
89
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
90
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
90
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
91
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
91
92
92
#define TIOCSERCONFIG	0x5453
93
#define TIOCSERCONFIG	0x5453
93
#define TIOCSERGWILD	0x5454
94
#define TIOCSERGWILD	0x5454
(-)linux-2.6.11.orig/include/asm-ppc64/ioctls.h (+1 lines)
Lines 95-100 Link Here
95
#define TIOCGSID	0x5429  /* Return the session ID of FD */
95
#define TIOCGSID	0x5429  /* Return the session ID of FD */
96
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
96
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
97
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
97
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
98
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
98
99
99
#define TIOCSERCONFIG	0x5453
100
#define TIOCSERCONFIG	0x5453
100
#define TIOCSERGWILD	0x5454
101
#define TIOCSERGWILD	0x5454
(-)linux-2.6.11.orig/include/asm-s390/ioctls.h (+1 lines)
Lines 56-61 Link Here
56
#define TIOCGSID	0x5429  /* Return the session ID of FD */
56
#define TIOCGSID	0x5429  /* Return the session ID of FD */
57
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
57
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
58
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
58
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
59
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
59
60
60
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
61
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
61
#define FIOCLEX		0x5451
62
#define FIOCLEX		0x5451
(-)linux-2.6.11.orig/include/asm-sh/ioctls.h (+1 lines)
Lines 80-85 Link Here
80
#define TIOCGSID	_IOR('T', 41, pid_t) /* 0x5429 */ /* Return the session ID of FD */
80
#define TIOCGSID	_IOR('T', 41, pid_t) /* 0x5429 */ /* Return the session ID of FD */
81
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
81
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
82
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
82
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
83
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
83
84
84
#define TIOCSERCONFIG	_IO('T', 83) /* 0x5453 */
85
#define TIOCSERCONFIG	_IO('T', 83) /* 0x5453 */
85
#define TIOCSERGWILD	_IOR('T', 84,  int) /* 0x5454 */
86
#define TIOCSERGWILD	_IOR('T', 84,  int) /* 0x5454 */
(-)linux-2.6.11.orig/include/asm-sparc/ioctls.h (+1 lines)
Lines 15-20 Link Here
15
#define TCSETS		_IOW('T', 9, struct termios)
15
#define TCSETS		_IOW('T', 9, struct termios)
16
#define TCSETSW		_IOW('T', 10, struct termios)
16
#define TCSETSW		_IOW('T', 10, struct termios)
17
#define TCSETSF		_IOW('T', 11, struct termios)
17
#define TCSETSF		_IOW('T', 11, struct termios)
18
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
18
19
19
/* Note that all the ioctls that are not available in Linux have a 
20
/* Note that all the ioctls that are not available in Linux have a 
20
 * double underscore on the front to: a) avoid some programs to
21
 * double underscore on the front to: a) avoid some programs to
(-)linux-2.6.11.orig/include/asm-sparc64/ioctls.h (+1 lines)
Lines 16-21 Link Here
16
#define TCSETS		_IOW('T', 9, struct termios)
16
#define TCSETS		_IOW('T', 9, struct termios)
17
#define TCSETSW		_IOW('T', 10, struct termios)
17
#define TCSETSW		_IOW('T', 10, struct termios)
18
#define TCSETSF		_IOW('T', 11, struct termios)
18
#define TCSETSF		_IOW('T', 11, struct termios)
19
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
19
20
20
/* Note that all the ioctls that are not available in Linux have a 
21
/* Note that all the ioctls that are not available in Linux have a 
21
 * double underscore on the front to: a) avoid some programs to
22
 * double underscore on the front to: a) avoid some programs to
(-)linux-2.6.11.orig/include/asm-x86_64/ioctls.h (+1 lines)
Lines 48-53 Link Here
48
#define TIOCGSID	0x5429  /* Return the session ID of FD */
48
#define TIOCGSID	0x5429  /* Return the session ID of FD */
49
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
49
#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
50
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
50
#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
51
#define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
51
52
52
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
53
#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
53
#define FIOCLEX		0x5451
54
#define FIOCLEX		0x5451
(-)linux-2.6.11/include/linux/chio.h (+168 lines)
Added Link Here
1
/*
2
 * ioctl interface for the scsi media changer driver
3
 */
4
5
/* changer element types */
6
#define CHET_MT   0	/* media transport element (robot) */
7
#define CHET_ST   1	/* storage element (media slots) */
8
#define CHET_IE   2	/* import/export element */
9
#define CHET_DT   3	/* data transfer element (tape/cdrom/whatever) */
10
#define CHET_V1   4	/* vendor specific #1 */
11
#define CHET_V2   5	/* vendor specific #2 */
12
#define CHET_V3   6	/* vendor specific #3 */
13
#define CHET_V4   7	/* vendor specific #4 */
14
15
16
/*
17
 * CHIOGPARAMS
18
 *    query changer properties
19
 *
20
 * CHIOVGPARAMS
21
 *    query vendor-specific element types
22
 *
23
 *    accessing elements works by specifing type and unit of the element.
24
 *    for eample, storage elements are addressed with type = CHET_ST and
25
 *    unit = 0 .. cp_nslots-1
26
 *
27
 */
28
struct changer_params {
29
	int cp_curpicker;  /* current transport element */
30
	int cp_npickers;   /* number of transport elements      (CHET_MT) */
31
	int cp_nslots;     /* number of storage elements        (CHET_ST) */
32
	int cp_nportals;   /* number of import/export elements  (CHET_IE) */
33
	int cp_ndrives;    /* number of data transfer elements  (CHET_DT) */
34
};
35
struct changer_vendor_params {
36
	int  cvp_n1;       /* number of vendor specific elems   (CHET_V1) */
37
	char cvp_label1[16];
38
	int  cvp_n2;       /* number of vendor specific elems   (CHET_V2) */
39
	char cvp_label2[16];
40
	int  cvp_n3;       /* number of vendor specific elems   (CHET_V3) */
41
	char cvp_label3[16];
42
	int  cvp_n4;       /* number of vendor specific elems   (CHET_V4) */
43
	char cvp_label4[16];
44
	int  reserved[8];
45
};
46
47
48
/*
49
 * CHIOMOVE
50
 *    move a medium from one element to another
51
 */
52
struct changer_move {
53
	int cm_fromtype;	/* type/unit of source element */
54
	int cm_fromunit;	
55
	int cm_totype;	/* type/unit of destination element */
56
	int cm_tounit;
57
	int cm_flags;
58
};
59
#define CM_INVERT   1   /* flag: rotate media (for double-sided like MOD) */
60
61
62
/*
63
 * CHIOEXCHANGE
64
 *    move one medium from element #1 to element #2,
65
 *    and another one from element #2 to element #3.
66
 *    element #1 and #3 are allowed to be identical.
67
 */
68
struct changer_exchange {
69
	int ce_srctype;	    /* type/unit of element #1 */
70
	int ce_srcunit;
71
	int ce_fdsttype;    /* type/unit of element #2 */
72
	int ce_fdstunit;
73
	int ce_sdsttype;    /* type/unit of element #3 */
74
	int ce_sdstunit;
75
	int ce_flags;
76
};
77
#define CE_INVERT1   1
78
#define CE_INVERT2   2
79
80
81
/*
82
 * CHIOPOSITION
83
 *    move the transport element (robot arm) to a specific element.
84
 */
85
struct changer_position {
86
	int cp_type;
87
	int cp_unit;
88
	int cp_flags;
89
};
90
#define CP_INVERT   1
91
92
93
/*
94
 * CHIOGSTATUS
95
 *    get element status for all elements of a specific type
96
 */
97
struct changer_element_status {
98
	int             ces_type;
99
	unsigned char   *ces_data;
100
};
101
#define CESTATUS_FULL     0x01 /* full */
102
#define CESTATUS_IMPEXP   0x02	/* media was imported (inserted by sysop) */
103
#define CESTATUS_EXCEPT   0x04	/* error condition */
104
#define CESTATUS_ACCESS   0x08	/* access allowed */
105
#define CESTATUS_EXENAB   0x10	/* element can export media */
106
#define CESTATUS_INENAB   0x20	/* element can import media */
107
108
109
/*
110
 * CHIOGELEM
111
 *    get more detailed status informtion for a single element
112
 */
113
struct changer_get_element {
114
	int	cge_type;	 /* type/unit */
115
	int	cge_unit;
116
	int	cge_status;      /* status */
117
	int     cge_errno;       /* errno */
118
	int     cge_srctype;     /* source element of the last move/exchange */
119
	int     cge_srcunit;
120
	int     cge_id;          /* scsi id  (for data transfer elements) */
121
	int     cge_lun;         /* scsi lun (for data transfer elements) */
122
	char    cge_pvoltag[36]; /* primary volume tag */
123
	char    cge_avoltag[36]; /* alternate volume tag */
124
	int     cge_flags;
125
};
126
/* flags */
127
#define CGE_ERRNO     0x01       /* errno available       */
128
#define CGE_INVERT    0x02       /* media inverted        */
129
#define CGE_SRC       0x04       /* media src available   */
130
#define CGE_IDLUN     0x08       /* ID+LUN available      */
131
#define CGE_PVOLTAG   0x10       /* primary volume tag available */
132
#define CGE_AVOLTAG   0x20       /* alternate volume tag available */
133
134
135
/*
136
 * CHIOSVOLTAG
137
 *    set volume tag
138
 */
139
struct changer_set_voltag {
140
	int	csv_type;	 /* type/unit */
141
	int	csv_unit;
142
	char    csv_voltag[36];  /* volume tag */
143
	int     csv_flags;
144
};
145
#define CSV_PVOLTAG   0x01       /* primary volume tag */
146
#define CSV_AVOLTAG   0x02       /* alternate volume tag */
147
#define CSV_CLEARTAG  0x04       /* clear volume tag */
148
149
/* ioctls */
150
#define CHIOMOVE       _IOW('c', 1,struct changer_move)
151
#define CHIOEXCHANGE   _IOW('c', 2,struct changer_exchange)
152
#define CHIOPOSITION   _IOW('c', 3,struct changer_position)
153
#define CHIOGPICKER    _IOR('c', 4,int)                        /* not impl. */
154
#define CHIOSPICKER    _IOW('c', 5,int)                        /* not impl. */
155
#define CHIOGPARAMS    _IOR('c', 6,struct changer_params)
156
#define CHIOGSTATUS    _IOW('c', 8,struct changer_element_status)
157
#define CHIOGELEM      _IOW('c',16,struct changer_get_element)
158
#define CHIOINITELEM   _IO('c',17)
159
#define CHIOSVOLTAG    _IOW('c',18,struct changer_set_voltag)
160
#define CHIOGVPARAMS   _IOR('c',19,struct changer_vendor_params)
161
162
/* ---------------------------------------------------------------------- */
163
164
/*
165
 * Local variables:
166
 * c-basic-offset: 8
167
 * End:
168
 */
(-)linux-2.6.11.orig/include/linux/compat_ioctl.h (+1 lines)
Lines 27-32 COMPATIBLE_IOCTL(TIOCSBRK) Link Here
27
COMPATIBLE_IOCTL(TIOCCBRK)
27
COMPATIBLE_IOCTL(TIOCCBRK)
28
ULONG_IOCTL(TIOCMIWAIT)
28
ULONG_IOCTL(TIOCMIWAIT)
29
COMPATIBLE_IOCTL(TIOCGICOUNT)
29
COMPATIBLE_IOCTL(TIOCGICOUNT)
30
COMPATIBLE_IOCTL(TIOCGDEV)
30
/* Little t */
31
/* Little t */
31
COMPATIBLE_IOCTL(TIOCGETD)
32
COMPATIBLE_IOCTL(TIOCGETD)
32
COMPATIBLE_IOCTL(TIOCSETD)
33
COMPATIBLE_IOCTL(TIOCSETD)
(-)linux-2.6.11.orig/include/linux/major.h (+1 lines)
Lines 101-106 Link Here
101
#define I2O_MAJOR		80	/* 80->87 */
101
#define I2O_MAJOR		80	/* 80->87 */
102
102
103
#define SHMIQ_MAJOR		85   /* Linux/mips, SGI /dev/shmiq */
103
#define SHMIQ_MAJOR		85   /* Linux/mips, SGI /dev/shmiq */
104
#define SCSI_CHANGER_MAJOR      86
104
105
105
#define IDE6_MAJOR		88
106
#define IDE6_MAJOR		88
106
#define IDE7_MAJOR		89
107
#define IDE7_MAJOR		89
(-)linux-2.6.11.orig/include/linux/videodev2.h (-54 / +82 lines)
Lines 268-331 struct v4l2_timecode Link Here
268
/* The above is based on SMPTE timecodes */
268
/* The above is based on SMPTE timecodes */
269
269
270
270
271
#if 1
271
/*
272
/*
272
 *	C O M P R E S S I O N   P A R A M E T E R S
273
 *	M P E G   C O M P R E S S I O N   P A R A M E T E R S
274
 *
275
 *  ### WARNING: this is still work-in-progress right now, most likely
276
 *  ###          there will be some incompatible changes.
277
 *
273
 */
278
 */
274
#if 0
275
/* ### generic compression settings don't work, there is too much
276
 * ### codec-specific stuff.  Maybe reuse that for MPEG codec settings
277
 * ### later ... */
278
struct v4l2_compression
279
{
280
	__u32	quality;
281
	__u32	keyframerate;
282
	__u32	pframerate;
283
	__u32	reserved[5];
284
279
285
/*  what we'll need for MPEG, extracted from some postings on
286
    the v4l list (Gert Vervoort, PlasmaJohn).
287
280
288
system stream:
281
enum v4l2_bitrate_mode {
289
  - type: elementary stream(ES), packatised elementary stream(s) (PES)
282
	V4L2_BITRATE_NONE = 0,	/* not specified */
290
    program stream(PS), transport stream(TS)
283
	V4L2_BITRATE_CBR,	/* constant bitrate */
291
  - system bitrate
284
	V4L2_BITRATE_VBR,	/* variable bitrate */
292
  - PS packet size (DVD: 2048 bytes, VCD: 2324 bytes)
285
};
293
  - TS video PID
286
struct v4l2_bitrate {
294
  - TS audio PID
287
	/* rates are specified in kbit/sec */
295
  - TS PCR PID
288
	enum v4l2_bitrate_mode	mode;
296
  - TS system information tables (PAT, PMT, CAT, NIT and SIT)
289
	__u32			min;
297
  - (MPEG-1 systems stream vs. MPEG-2 program stream (TS not supported
290
	__u32			target;  /* use this one for CBR */
298
    by MPEG-1 systems)
291
	__u32			max;
292
};
299
293
300
audio:
294
enum v4l2_mpeg_streamtype {
301
  - type: MPEG (+Layer I,II,III), AC-3, LPCM
295
	V4L2_MPEG_SS_1,		/* MPEG-1 system stream */
302
  - bitrate
296
	V4L2_MPEG_PS_2,		/* MPEG-2 program stream */
303
  - sampling frequency (DVD: 48 Khz, VCD: 44.1 KHz, 32 kHz)
297
	V4L2_MPEG_TS_2,		/* MPEG-2 transport stream */
304
  - Trick Modes? (ff, rew)
298
	V4L2_MPEG_PS_DVD,      	/* MPEG-2 program stream with DVD header fixups */
305
  - Copyright
299
};
306
  - Inverse Telecine
300
enum v4l2_mpeg_audiotype {
301
	V4L2_MPEG_AU_2_I,	/* MPEG-2 layer 1 */
302
	V4L2_MPEG_AU_2_II,	/* MPEG-2 layer 2 */
303
	V4L2_MPEG_AU_2_III,	/* MPEG-2 layer 3 */
304
	V4L2_MPEG_AC3,		/* AC3 */
305
	V4L2_MPEG_LPCM,		/* LPCM */
306
};
307
enum v4l2_mpeg_videotype {
308
	V4L2_MPEG_VI_1,		/* MPEG-1 */
309
	V4L2_MPEG_VI_2,		/* MPEG-2 */
310
};
311
enum v4l2_mpeg_aspectratio {
312
	V4L2_MPEG_ASPECT_SQUARE = 1,   /* square pixel */
313
	V4L2_MPEG_ASPECT_4_3    = 2,   /*  4 : 3       */
314
	V4L2_MPEG_ASPECT_16_9   = 3,   /* 16 : 9       */
315
	V4L2_MPEG_ASPECT_1_221  = 4,   /*  1 : 2,21    */
316
};
307
317
308
video:
318
struct v4l2_mpeg_compression {
309
  - picturesize (SIF, 1/2 D1, 2/3 D1, D1) and PAL/NTSC norm can be set
319
	/* general */
310
    through excisting V4L2 controls
320
	enum v4l2_mpeg_streamtype	st_type;
311
  - noise reduction, parameters encoder specific?
321
	struct v4l2_bitrate		st_bitrate;
312
  - MPEG video version: MPEG-1, MPEG-2
313
  - GOP (Group Of Pictures) definition:
314
    - N: number of frames per GOP
315
    - M: distance between reference (I,P) frames
316
    - open/closed GOP
317
  - quantiser matrix: inter Q matrix (64 bytes) and intra Q matrix (64 bytes)
318
  - quantiser scale: linear or logarithmic
319
  - scanning: alternate or zigzag
320
  - bitrate mode: CBR (constant bitrate) or VBR (variable bitrate).
321
  - target video bitrate for CBR
322
  - target video bitrate for VBR
323
  - maximum video bitrate for VBR - min. quantiser value for VBR
324
  - max. quantiser value for VBR
325
  - adaptive quantisation value
326
  - return the number of bytes per GOP or bitrate for bitrate monitoring
327
322
328
*/
323
	/* transport streams */
324
	__u16				ts_pid_pmt;
325
	__u16				ts_pid_audio;
326
	__u16				ts_pid_video;
327
	__u16				ts_pid_pcr;
328
329
	/* program stream */
330
	__u16				ps_size;
331
	__u16				reserved_1;    /* align */
332
333
	/* audio */
334
	enum v4l2_mpeg_audiotype	au_type;
335
	struct v4l2_bitrate		au_bitrate;
336
	__u32				au_sample_rate;
337
	__u8                            au_pesid;
338
	__u8                            reserved_2[3]; /* align */
339
340
	/* video */
341
	enum v4l2_mpeg_videotype	vi_type;
342
	enum v4l2_mpeg_aspectratio	vi_aspect_ratio;
343
	struct v4l2_bitrate		vi_bitrate;
344
	__u32				vi_frame_rate;
345
	__u16				vi_frames_per_gop;
346
	__u16				vi_bframes_count;
347
	__u8                            vi_pesid;
348
	__u8                            reserved_3[3]; /* align */
349
350
	/* misc flags */
351
	__u32                           closed_gops:1;
352
	__u32                           pulldown:1;
353
	__u32                           reserved_4:30; /* align */
354
355
	/* I don't expect the above being perfect yet ;) */
356
	__u32				reserved_5[8];
329
};
357
};
330
#endif
358
#endif
331
359
Lines 841-849 struct v4l2_streamparm Link Here
841
#define VIDIOC_ENUM_FMT         _IOWR ('V',  2, struct v4l2_fmtdesc)
869
#define VIDIOC_ENUM_FMT         _IOWR ('V',  2, struct v4l2_fmtdesc)
842
#define VIDIOC_G_FMT		_IOWR ('V',  4, struct v4l2_format)
870
#define VIDIOC_G_FMT		_IOWR ('V',  4, struct v4l2_format)
843
#define VIDIOC_S_FMT		_IOWR ('V',  5, struct v4l2_format)
871
#define VIDIOC_S_FMT		_IOWR ('V',  5, struct v4l2_format)
844
#if 0
872
#if 1 /* experimental */
845
#define VIDIOC_G_COMP		_IOR  ('V',  6, struct v4l2_compression)
873
#define VIDIOC_G_MPEGCOMP       _IOR  ('V',  6, struct v4l2_mpeg_compression)
846
#define VIDIOC_S_COMP		_IOW  ('V',  7, struct v4l2_compression)
874
#define VIDIOC_S_MPEGCOMP     	_IOW  ('V',  7, struct v4l2_mpeg_compression)
847
#endif
875
#endif
848
#define VIDIOC_REQBUFS		_IOWR ('V',  8, struct v4l2_requestbuffers)
876
#define VIDIOC_REQBUFS		_IOWR ('V',  8, struct v4l2_requestbuffers)
849
#define VIDIOC_QUERYBUF		_IOWR ('V',  9, struct v4l2_buffer)
877
#define VIDIOC_QUERYBUF		_IOWR ('V',  9, struct v4l2_buffer)
(-)linux-2.6.11.orig/include/media/ir-common.h (-1 / +5 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Id: ir-common.h,v 1.6 2004/09/15 16:15:24 kraxel Exp $
2
 * $Id: ir-common.h,v 1.8 2005/02/22 12:28:40 kraxel Exp $
3
 *
3
 *
4
 * some common structs and functions to handle infrared remotes via
4
 * some common structs and functions to handle infrared remotes via
5
 * input layer ...
5
 * input layer ...
Lines 47-53 struct ir_input_state { Link Here
47
};
47
};
48
48
49
extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE];
49
extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE];
50
extern IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE];
50
extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE];
51
extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE];
52
extern IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE];
51
53
52
void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
54
void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
53
		   int ir_type, IR_KEYTAB_TYPE *ir_codes);
55
		   int ir_type, IR_KEYTAB_TYPE *ir_codes);
Lines 55-60 void ir_input_nokey(struct input_dev *de Link Here
55
void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
57
void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
56
		      u32 ir_key, u32 ir_raw);
58
		      u32 ir_key, u32 ir_raw);
57
u32  ir_extract_bits(u32 data, u32 mask);
59
u32  ir_extract_bits(u32 data, u32 mask);
60
int  ir_dump_samples(u32 *samples, int count);
61
int  ir_decode_biphase(u32 *samples, int count, int low, int high);
58
62
59
/*
63
/*
60
 * Local variables:
64
 * Local variables:
(-)linux-2.6.11.orig/include/media/saa6752hs.h (-6 / +23 lines)
Lines 18-31 Link Here
18
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
*/
19
*/
20
20
21
#ifndef _SAA6752HS_H
21
#if 0 /* ndef _SAA6752HS_H */
22
#define _SAA6752HS_H
22
#define _SAA6752HS_H
23
23
24
enum mpeg_bitrate_mode {
24
enum mpeg_video_bitrate_mode {
25
	MPEG_BITRATE_MODE_VBR = 0, /* Variable bitrate */
25
	MPEG_VIDEO_BITRATE_MODE_VBR = 0, /* Variable bitrate */
26
	MPEG_BITRATE_MODE_CBR = 1, /* Constant bitrate */
26
	MPEG_VIDEO_BITRATE_MODE_CBR = 1, /* Constant bitrate */
27
27
28
	MPEG_BITRATE_MODE_MAX
28
	MPEG_VIDEO_BITRATE_MODE_MAX
29
};
29
};
30
30
31
enum mpeg_audio_bitrate {
31
enum mpeg_audio_bitrate {
Lines 35-50 enum mpeg_audio_bitrate { Link Here
35
	MPEG_AUDIO_BITRATE_MAX
35
	MPEG_AUDIO_BITRATE_MAX
36
};
36
};
37
37
38
enum mpeg_video_format {
39
	MPEG_VIDEO_FORMAT_D1 = 0,
40
	MPEG_VIDEO_FORMAT_2_3_D1 = 1,
41
	MPEG_VIDEO_FORMAT_1_2_D1 = 2,
42
	MPEG_VIDEO_FORMAT_SIF = 3,
43
44
	MPEG_VIDEO_FORMAT_MAX
45
};
46
38
#define MPEG_VIDEO_TARGET_BITRATE_MAX 27000
47
#define MPEG_VIDEO_TARGET_BITRATE_MAX 27000
39
#define MPEG_VIDEO_MAX_BITRATE_MAX 27000
48
#define MPEG_VIDEO_MAX_BITRATE_MAX 27000
40
#define MPEG_TOTAL_BITRATE_MAX 27000
49
#define MPEG_TOTAL_BITRATE_MAX 27000
50
#define MPEG_PID_MAX ((1 << 14) - 1)
41
51
42
struct mpeg_params {
52
struct mpeg_params {
43
	enum mpeg_bitrate_mode bitrate_mode;
53
	enum mpeg_video_bitrate_mode video_bitrate_mode;
44
	unsigned int video_target_bitrate;
54
	unsigned int video_target_bitrate;
45
	unsigned int video_max_bitrate; // only used for VBR
55
	unsigned int video_max_bitrate; // only used for VBR
46
	enum mpeg_audio_bitrate audio_bitrate;
56
	enum mpeg_audio_bitrate audio_bitrate;
47
	unsigned int total_bitrate;
57
	unsigned int total_bitrate;
58
59
   	unsigned int pmt_pid;
60
	unsigned int video_pid;
61
	unsigned int audio_pid;
62
	unsigned int pcr_pid;
63
64
	enum mpeg_video_format video_format;
48
};
65
};
49
66
50
#define MPEG_SETPARAMS             _IOW('6',100,struct mpeg_params)
67
#define MPEG_SETPARAMS             _IOW('6',100,struct mpeg_params)
(-)linux-2.6.11.orig/include/media/tuner.h (-4 / +77 lines)
Lines 29-83 Link Here
29
#define TUNER_PHILIPS_PAL_I 1
29
#define TUNER_PHILIPS_PAL_I 1
30
#define TUNER_PHILIPS_NTSC  2
30
#define TUNER_PHILIPS_NTSC  2
31
#define TUNER_PHILIPS_SECAM 3		/* you must actively select B/G, L, L` */
31
#define TUNER_PHILIPS_SECAM 3		/* you must actively select B/G, L, L` */
32
32
#define TUNER_ABSENT        4
33
#define TUNER_ABSENT        4
33
#define TUNER_PHILIPS_PAL   5
34
#define TUNER_PHILIPS_PAL   5
34
#define TUNER_TEMIC_NTSC    6        /* 4032 FY5 (3X 7004, 9498, 9789)  */
35
#define TUNER_TEMIC_NTSC    6        /* 4032 FY5 (3X 7004, 9498, 9789)  */
35
#define TUNER_TEMIC_PAL_I   7        /* 4062 FY5 (3X 8501, 9957)        */
36
#define TUNER_TEMIC_PAL_I   7        /* 4062 FY5 (3X 8501, 9957)        */
37
36
#define TUNER_TEMIC_4036FY5_NTSC 8   /* 4036 FY5 (3X 1223, 1981, 7686)  */
38
#define TUNER_TEMIC_4036FY5_NTSC 8   /* 4036 FY5 (3X 1223, 1981, 7686)  */
37
#define TUNER_ALPS_TSBH1_NTSC 	 9
39
#define TUNER_ALPS_TSBH1_NTSC 	 9
38
#define TUNER_ALPS_TSBE1_PAL 	10
40
#define TUNER_ALPS_TSBE1_PAL 	10
39
#define TUNER_ALPS_TSBB5_PAL_I 	11
41
#define TUNER_ALPS_TSBB5_PAL_I 	11
42
40
#define TUNER_ALPS_TSBE5_PAL 	12
43
#define TUNER_ALPS_TSBE5_PAL 	12
41
#define TUNER_ALPS_TSBC5_PAL 	13
44
#define TUNER_ALPS_TSBC5_PAL 	13
42
#define TUNER_TEMIC_4006FH5_PAL	14   /* 4006 FH5 (3X 9500, 9501, 7291)     */
45
#define TUNER_TEMIC_4006FH5_PAL	14   /* 4006 FH5 (3X 9500, 9501, 7291)     */
43
#define TUNER_ALPS_TSHC6_NTSC 	15
46
#define TUNER_ALPS_TSHC6_NTSC 	15
47
44
#define TUNER_TEMIC_PAL_DK	16   /* 4016 FY5 (3X 1392, 1393)     */
48
#define TUNER_TEMIC_PAL_DK	16   /* 4016 FY5 (3X 1392, 1393)     */
45
#define TUNER_PHILIPS_NTSC_M	17
49
#define TUNER_PHILIPS_NTSC_M	17
46
#define TUNER_TEMIC_4066FY5_PAL_I       18  /* 4066 FY5 (3X 7032, 7035) */
50
#define TUNER_TEMIC_4066FY5_PAL_I       18  /* 4066 FY5 (3X 7032, 7035) */
47
#define TUNER_TEMIC_4006FN5_MULTI_PAL   19  /* B/G, I and D/K autodetected (3X 7595, 7606, 7657)*/
51
#define TUNER_TEMIC_4006FN5_MULTI_PAL   19  /* B/G, I and D/K autodetected (3X 7595, 7606, 7657)*/
52
48
#define TUNER_TEMIC_4009FR5_PAL         20  /* incl. FM radio (3X 7607, 7488, 7711)*/
53
#define TUNER_TEMIC_4009FR5_PAL         20  /* incl. FM radio (3X 7607, 7488, 7711)*/
49
#define TUNER_TEMIC_4039FR5_NTSC        21  /* incl. FM radio (3X 7246, 7578, 7732)*/
54
#define TUNER_TEMIC_4039FR5_NTSC        21  /* incl. FM radio (3X 7246, 7578, 7732)*/
50
#define TUNER_TEMIC_4046FM5             22  /* you must actively select B/G, D/K, I, L, L` !  (3X 7804, 7806, 8103, 8104)*/
55
#define TUNER_TEMIC_4046FM5             22  /* you must actively select B/G, D/K, I, L, L` !  (3X 7804, 7806, 8103, 8104)*/
51
#define TUNER_PHILIPS_PAL_DK		23
56
#define TUNER_PHILIPS_PAL_DK		23
57
52
#define TUNER_PHILIPS_FQ1216ME		24  /* you must actively select B/G/D/K, I, L, L` */
58
#define TUNER_PHILIPS_FQ1216ME		24  /* you must actively select B/G/D/K, I, L, L` */
53
#define TUNER_LG_PAL_I_FM	25
59
#define TUNER_LG_PAL_I_FM	25
54
#define TUNER_LG_PAL_I		26
60
#define TUNER_LG_PAL_I		26
55
#define TUNER_LG_NTSC_FM	27
61
#define TUNER_LG_NTSC_FM	27
62
56
#define TUNER_LG_PAL_FM		28
63
#define TUNER_LG_PAL_FM		28
57
#define TUNER_LG_PAL		29
64
#define TUNER_LG_PAL		29
58
#define TUNER_TEMIC_4009FN5_MULTI_PAL_FM	30  /* B/G, I and D/K autodetected (3X 8155, 8160, 8163)*/
65
#define TUNER_TEMIC_4009FN5_MULTI_PAL_FM	30  /* B/G, I and D/K autodetected (3X 8155, 8160, 8163)*/
59
#define TUNER_SHARP_2U5JF5540_NTSC  31
66
#define TUNER_SHARP_2U5JF5540_NTSC  31
67
60
#define TUNER_Samsung_PAL_TCPM9091PD27 32
68
#define TUNER_Samsung_PAL_TCPM9091PD27 32
61
#define TUNER_MT2032 33
69
#define TUNER_MT2032 33
62
#define TUNER_TEMIC_4106FH5 	34	/* 4106 FH5 (3X 7808, 7865)*/
70
#define TUNER_TEMIC_4106FH5 	34	/* 4106 FH5 (3X 7808, 7865)*/
63
#define TUNER_TEMIC_4012FY5	35	/* 4012 FY5 (3X 0971, 1099)*/
71
#define TUNER_TEMIC_4012FY5	35	/* 4012 FY5 (3X 0971, 1099)*/
72
64
#define TUNER_TEMIC_4136FY5	36	/* 4136 FY5 (3X 7708, 7746)*/
73
#define TUNER_TEMIC_4136FY5	36	/* 4136 FY5 (3X 7708, 7746)*/
65
#define TUNER_LG_PAL_NEW_TAPC   37
74
#define TUNER_LG_PAL_NEW_TAPC   37
66
#define TUNER_PHILIPS_FM1216ME_MK3  38
75
#define TUNER_PHILIPS_FM1216ME_MK3  38
67
#define TUNER_LG_NTSC_NEW_TAPC   39
76
#define TUNER_LG_NTSC_NEW_TAPC   39
77
68
#define TUNER_HITACHI_NTSC       40
78
#define TUNER_HITACHI_NTSC       40
69
#define TUNER_PHILIPS_PAL_MK     41
79
#define TUNER_PHILIPS_PAL_MK     41
70
#define TUNER_PHILIPS_ATSC       42
80
#define TUNER_PHILIPS_ATSC       42
71
#define TUNER_PHILIPS_FM1236_MK3 43
81
#define TUNER_PHILIPS_FM1236_MK3 43
82
72
#define TUNER_PHILIPS_4IN1       44	/* ATI TV Wonder Pro - Conexant */
83
#define TUNER_PHILIPS_4IN1       44	/* ATI TV Wonder Pro - Conexant */
73
/* Microtune mergeged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */
84
/* Microtune mergeged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */
74
#define TUNER_MICROTUNE_4049FM5  45
85
#define TUNER_MICROTUNE_4049FM5  45
75
#define TUNER_LG_NTSC_TAPE       47
86
#define TUNER_LG_NTSC_TAPE       47
87
76
#define TUNER_TNF_8831BGFF       48
88
#define TUNER_TNF_8831BGFF       48
77
#define TUNER_MICROTUNE_4042FI5  49	/* FusionHDTV 3 Gold - 4042 FI5 (3X 8147) */
89
#define TUNER_MICROTUNE_4042FI5  49	/* FusionHDTV 3 Gold - 4042 FI5 (3X 8147) */
78
#define TUNER_TCL_2002N          50
90
#define TUNER_TCL_2002N          50
79
#define TUNER_PHILIPS_FM1256_IH3   51
91
#define TUNER_PHILIPS_FM1256_IH3   51
92
80
#define TUNER_THOMSON_DTT7610    52
93
#define TUNER_THOMSON_DTT7610    52
94
#define TUNER_PHILIPS_FQ1286     53
95
#define TUNER_PHILIPS_TDA8290    54
96
#define TUNER_LG_PAL_TAPE        55    /* Hauppauge PVR-150 PAL */
97
98
#define TUNER_PHILIPS_FQ1216AME_MK4 56 /* Hauppauge PVR-150 PAL */
99
#define TUNER_PHILIPS_FQ1236A_MK4 57   /* Hauppauge PVR-500MCE NTSC */
81
100
82
#define NOTUNER 0
101
#define NOTUNER 0
83
#define PAL     1	/* PAL_BG */
102
#define PAL     1	/* PAL_BG */
Lines 102-111 Link Here
102
121
103
#define TUNER_SET_TYPE               _IOW('t',1,int)    /* set tuner type */
122
#define TUNER_SET_TYPE               _IOW('t',1,int)    /* set tuner type */
104
#define TUNER_SET_TVFREQ             _IOW('t',2,int)    /* set tv freq */
123
#define TUNER_SET_TVFREQ             _IOW('t',2,int)    /* set tv freq */
105
#if 0 /* obsolete */
106
# define TUNER_SET_RADIOFREQ         _IOW('t',3,int)    /* set radio freq */
107
# define TUNER_SET_MODE              _IOW('t',4,int)    /* set tuner mode */
108
#endif
109
124
110
#define  TDA9887_SET_CONFIG          _IOW('t',5,int)
125
#define  TDA9887_SET_CONFIG          _IOW('t',5,int)
111
/* tv card specific */
126
/* tv card specific */
Lines 123-126 Link Here
123
# define TDA9887_DEEMPHASIS_75       (3<<16)
138
# define TDA9887_DEEMPHASIS_75       (3<<16)
124
# define TDA9887_AUTOMUTE            (1<<18)
139
# define TDA9887_AUTOMUTE            (1<<18)
125
140
141
#ifdef __KERNEL__
142
143
#define I2C_ADDR_TDA8290        0x4b
144
#define I2C_ADDR_TDA8275        0x61
145
146
struct tuner {
147
	/* device */
148
	struct i2c_client i2c;
149
150
	/* state + config */
151
	unsigned int initialized;
152
	unsigned int type;            /* chip type */
153
	unsigned int freq;            /* keep track of the current settings */
154
	v4l2_std_id  std;
155
	int          using_v4l2;
156
157
	enum v4l2_tuner_type mode;
158
	unsigned int input;
159
160
	/* used by MT2032 */
161
	unsigned int xogc;
162
	unsigned int radio_if2;
163
164
	/* used by tda8290 */
165
	unsigned char i2c_easy_mode[2];
166
	unsigned char i2c_set_freq[8];
167
168
	/* function ptrs */
169
	void (*tv_freq)(struct i2c_client *c, unsigned int freq);
170
	void (*radio_freq)(struct i2c_client *c, unsigned int freq);
171
	int  (*has_signal)(struct i2c_client *c);
172
	int  (*is_stereo)(struct i2c_client *c);
173
};
174
175
extern unsigned int tuner_debug;
176
extern unsigned const int tuner_count;
177
178
extern int microtune_init(struct i2c_client *c);
179
extern int tda8290_init(struct i2c_client *c);
180
extern int default_tuner_init(struct i2c_client *c);
181
182
#define tuner_warn(fmt, arg...) \
183
	dev_printk(KERN_WARNING , &t->i2c.dev , fmt , ## arg)
184
#define tuner_info(fmt, arg...) \
185
	dev_printk(KERN_INFO , &t->i2c.dev , fmt , ## arg)
186
#define tuner_dbg(fmt, arg...) \
187
	if (tuner_debug) dev_printk(KERN_DEBUG , &t->i2c.dev , fmt , ## arg)
188
189
#endif /* __KERNEL__ */
190
126
#endif
191
#endif
192
193
/*
194
 * Overrides for Emacs so that we follow Linus's tabbing style.
195
 * ---------------------------------------------------------------------------
196
 * Local variables:
197
 * c-basic-offset: 8
198
 * End:
199
 */
(-)linux-2.6.11.orig/include/scsi/scsi.h (+3 lines)
Lines 41-46 extern const char *const scsi_device_typ Link Here
41
#define FORMAT_UNIT           0x04
41
#define FORMAT_UNIT           0x04
42
#define READ_BLOCK_LIMITS     0x05
42
#define READ_BLOCK_LIMITS     0x05
43
#define REASSIGN_BLOCKS       0x07
43
#define REASSIGN_BLOCKS       0x07
44
#define INITIALIZE_ELEMENT_STATUS 0x07
44
#define READ_6                0x08
45
#define READ_6                0x08
45
#define WRITE_6               0x0a
46
#define WRITE_6               0x0a
46
#define SEEK_6                0x0b
47
#define SEEK_6                0x0b
Lines 65-70 extern const char *const scsi_device_typ Link Here
65
#define READ_10               0x28
66
#define READ_10               0x28
66
#define WRITE_10              0x2a
67
#define WRITE_10              0x2a
67
#define SEEK_10               0x2b
68
#define SEEK_10               0x2b
69
#define POSITION_TO_ELEMENT   0x2b
68
#define WRITE_VERIFY          0x2e
70
#define WRITE_VERIFY          0x2e
69
#define VERIFY                0x2f
71
#define VERIFY                0x2f
70
#define SEARCH_HIGH           0x30
72
#define SEARCH_HIGH           0x30
Lines 97-102 extern const char *const scsi_device_typ Link Here
97
#define PERSISTENT_RESERVE_OUT 0x5f
99
#define PERSISTENT_RESERVE_OUT 0x5f
98
#define REPORT_LUNS           0xa0
100
#define REPORT_LUNS           0xa0
99
#define MOVE_MEDIUM           0xa5
101
#define MOVE_MEDIUM           0xa5
102
#define EXCHANGE_MEDIUM       0xa6
100
#define READ_12               0xa8
103
#define READ_12               0xa8
101
#define WRITE_12              0xaa
104
#define WRITE_12              0xaa
102
#define WRITE_VERIFY_12       0xae
105
#define WRITE_VERIFY_12       0xae
(-)linux-2.6.11/localversion-kraxel (+1 lines)
Added Link Here
1
-kraxel1

Return to bug 94814