Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 45100 | Differences between
and this patch

Collapse All | Expand All

(-)linux-2.4.26/CVS/Entries (+9 lines)
Line 0 Link Here
1
D/Documentation////
2
D/arch////
3
D/drivers////
4
D/fs////
5
D/include////
6
D/init////
7
D/scripts////
8
/Makefile/1.8/Thu Apr 15 13:58:24 2004//
9
/kernel.config/1.18/Thu Apr 15 14:01:29 2004//
(-)linux-2.4.26/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel
(-)linux-2.4.26/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/Documentation/CVS/Entries (+3 lines)
Line 0 Link Here
1
/README.xbox/1.6/Thu Feb 19 15:13:44 2004//
2
D/input////
3
/Configure.help/1.17/Thu Apr 15 13:57:48 2004//
(-)linux-2.4.26/Documentation/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/Documentation
(-)linux-2.4.26/Documentation/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/Documentation/Configure.help (+117 lines)
Lines 412-417 Link Here
412
  Otherwise low memory pages are used as bounce buffers causing a
412
  Otherwise low memory pages are used as bounce buffers causing a
413
  degrade in performance.
413
  degrade in performance.
414
414
415
Xbox support
416
CONFIG_XBOX
417
  If you want your kernel to be compatible with the Microsoft Xbox,
418
  say Y. This option includes adjustments so that the kernel runs
419
  both on a standard PC or on an Xbox.
420
421
  This code autodetects an Xbox at boot, and if it is found, it
422
  avoids the PCI enumeration chipset bug, adjusts the system
423
  frequency and adds the Xbox shutdown/reset sequence.
424
425
Xbox DVD eject fix
426
CONFIG_XBOX_EJECT
427
  If you want to be able to eject the DVD drive tray, say Y, or else
428
  your eject button will be a reset button. For security reasons, the
429
  Xbox is reset by default when the optical media is supposed to be
430
  ejected.
431
432
  If you want to compile this as a module ( = code which can be
433
  inserted in and removed from the running kernel whenever you want),
434
  say M and read <file:Documentation/modules.txt>. The module will be
435
  called xboxejectfix.o.
436
437
  You should really say Y here. If you compile it as a module, make
438
  sure that it gets loaded as soon as possible, so that you are
439
  protected against accidental resets from the very beginning.
440
415
OOM killer support
441
OOM killer support
416
CONFIG_OOM_KILLER
442
CONFIG_OOM_KILLER
417
   This option selects the kernel behaviour during total out of memory
443
   This option selects the kernel behaviour during total out of memory
Lines 5010-5015 Link Here
5010
  module will be called rivafb.o. If you want to compile it as a
5036
  module will be called rivafb.o. If you want to compile it as a
5011
  module, say M here and read <file:Documentation/modules.txt>.
5037
  module, say M here and read <file:Documentation/modules.txt>.
5012
5038
5039
Xbox (nVidia) support
5040
CONFIG_FB_XBOX
5041
  This driver supports graphics boards with the nVidia GeForce 3MX GPU
5042
  as found in the Microsoft Xbox. Note that this driver and CONFIG_FB_RIVA
5043
  (nVidia Riva support) are mutually exclusive, ie. you can enable only
5044
  one and not both.
5045
5046
  Note 2: This driver depends on both CONFIG_XBOX (Xbox support) and
5047
  CONFIG_I2C_XBOX (I2C XBOX).
5048
5049
  Say Y if you are running Linux on the Xbox, otherwise, say N.
5050
5051
  The driver is also available as a module ( = code which can be
5052
  inserted and removed from the running kernel whenever you want). The
5053
  module will be called xboxfb.o. If you want to compile it as a
5054
  module, say M here and read <file:Documentation/modules.txt>.
5055
5013
Trident Blade/Image support
5056
Trident Blade/Image support
5014
CONFIG_FB_TRIDENT
5057
CONFIG_FB_TRIDENT
5015
  This driver is supposed to support graphics boards with the
5058
  This driver is supposed to support graphics boards with the
Lines 12446-12451 Link Here
12446
  <file:Documentation/networking/net-modules.txt>.  The module will be
12489
  <file:Documentation/networking/net-modules.txt>.  The module will be
12447
  called forcedeth.o.
12490
  called forcedeth.o.
12448
12491
12492
nForce Ethernet support (EXPERIMENTAL)
12493
CONFIG_FORCEDETH
12494
  If you have a network (Ethernet) controller of this type, say Y and
12495
  read the Ethernet-HOWTO, available from
12496
  <http://www.tldp.org/docs.html#howto>.
12497
12498
  To compile this driver as a module, choose M here and read
12499
  <file:Documentation/networking/net-modules.txt>.  The module will be
12500
  called forcedeth.o.
12501
12449
CS89x0 support (Daynaport CS and LC cards)
12502
CS89x0 support (Daynaport CS and LC cards)
12450
CONFIG_CS89x0
12503
CONFIG_CS89x0
12451
  Support for CS89x0 chipset based Ethernet cards. If you have a
12504
  Support for CS89x0 chipset based Ethernet cards. If you have a
Lines 14968-14973 Link Here
14968
  The module will be called powermate.o. If you want to compile it as a
15021
  The module will be called powermate.o. If you want to compile it as a
14969
  module, say M here and read <file:Documentation/modules.txt>.
15022
  module, say M here and read <file:Documentation/modules.txt>.
14970
15023
15024
Xbox Infrared DVD dongle support (EXPERIMENTAL)
15025
CONFIG_USB_XBOXIR
15026
  Say Y here if you want to use the Xbox DVD dongle and remote control
15027
  to help control running applications using keyboard codes. Make sure
15028
  to say Y to "USB Keyboard support" (CONFIG_INPUT_KBD) and/or
15029
  "Event interface support" (CONFIG_INPUT_EVDEV) as well.
15030
15031
Xbox Controller (XPad)
15032
CONFIG_USB_XPAD
15033
  Say Y here if you want to use the X-Box pad with your computer.
15034
  Make sure to say Y to "Joystick support" (CONFIG_INPUT_JOYDEV)
15035
  and/or "Event interface support" (CONFIG_INPUT_EVDEV) as well.
15036
15037
  For information about how to connect the X-Box pad to USB, see
15038
  Documentation/input/xpad.txt.
15039
15040
  This driver is also available as a module ( = code which can be
15041
  inserted in and removed from the running kernel whenever you want).
15042
  The module will be called xpad.o.  If you want to compile it as a
15043
  module, say M here and read <file:Documentation/modules.txt>.
15044
15045
Xbox Controller Mouse Emulation
15046
CONFIG_USB_XPAD_MOUSE
15047
  Say Y here if you want to use the Xbox pad as a mouse
15048
  with your computer. Make sure to say Y to "Mouse support"
15049
  (CONFIG_INPUT_MOUSEDEV) as well. This emulation is part of the
15050
  regular XPad driver, so you have to enable CONFIG_USB_XPAD for
15051
  this to work.
15052
15053
  For information about how to connect the Xbox pad to USB, see
15054
  Documentation/input/xpad.txt.
15055
14971
Aiptek HyperPen tablet support
15056
Aiptek HyperPen tablet support
14972
CONFIG_USB_AIPTEK
15057
CONFIG_USB_AIPTEK
14973
  Say Y here if you want to use the USB version of the Aiptek HyperPen
15058
  Say Y here if you want to use the USB version of the Aiptek HyperPen
Lines 16865-16870 Link Here
16865
  root partition (the one containing the directory /) cannot be a
16950
  root partition (the one containing the directory /) cannot be a
16866
  module, so saying M could be dangerous.  If unsure, say N.
16951
  module, so saying M could be dangerous.  If unsure, say N.
16867
16952
16953
FATX (Xbox) fs support
16954
CONFIG_FATX_FS
16955
  This adds support for the FATX filesystem as found in Microsoft's Xbox.
16956
16957
  The FATX filesystem is a derivative of the FAT filesystem minus some
16958
  legacy fields and redundant information. For lengthier discussions on
16959
  the filesystem, see:
16960
16961
  http://xbox-linux.sourceforge.net/docs/fatxfat.html
16962
  http://xbox-linux.sourceforge.net/docs/hdpartfs.html
16963
  http://xbox-linux.sourceforge.net/docs/hackingfatx.html
16964
16965
  If you are running Linux on the Xbox, say Y unless you know what
16966
  you're doing. Otherwise, say N.
16967
16968
  If you want to compile this as a module ( = code which can be
16969
  inserted in and removed from the running kernel whenever you want),
16970
  say M here and read <file:Documentation/modules.txt>.  The module
16971
  will be called fatx.o.
16972
16868
/proc file system support
16973
/proc file system support
16869
CONFIG_PROC_FS
16974
CONFIG_PROC_FS
16870
  This is a virtual file system providing information about the status
16975
  This is a virtual file system providing information about the status
Lines 17496-17501 Link Here
17496
  Say Y here if you would like to use hard disks under Linux which
17601
  Say Y here if you would like to use hard disks under Linux which
17497
  were partitioned on a Macintosh.
17602
  were partitioned on a Macintosh.
17498
17603
17604
Xbox partition support
17605
CONFIG_XBOX_PARTITION
17606
  The Xbox makes use of a static and implicit partitioning scheme.
17607
  The locations and sizes of the four partitions on the Xbox hard
17608
  disk are hard-coded into the native Xbox kernel.
17609
17610
  Say Y here if you are running Linux on the Xbox, or would like
17611
  to access a hard disk partitioned for the Xbox under a PC
17612
  running Linux.
17613
17614
  If unsure, say N.
17615
17499
Windows Logical Disk Manager (Dynamic Disk) support (EXPERIMENTAL)
17616
Windows Logical Disk Manager (Dynamic Disk) support (EXPERIMENTAL)
17500
CONFIG_LDM_PARTITION
17617
CONFIG_LDM_PARTITION
17501
  Say Y here if you would like to use hard disks under Linux which
17618
  Say Y here if you would like to use hard disks under Linux which
(-)linux-2.4.26/Documentation/README.xbox (+232 lines)
Line 0 Link Here
1
$Id: README.xbox,v 1.6 2004/02/19 15:13:44 aothieno Exp $
2
3
We are baselined on 2.4.25
4
5
6
Introductory Note
7
-----------------
8
9
First, if you are shaking with excitement and fear and this is your first 
10
attempt to compile the kernel, don't worry if things don't work out first time.
11
Expect trouble the first couple of attempts, make sure you have a way to boot 
12
an old kernel after trying a fresh one.  Note too that the kernel compile 
13
process does nothing to your system config until you copy the new kernel image 
14
to /boot and make it the default choice for boot.
15
16
A very easy mistake to make is to forget to do the make modules and 
17
make modules_install after doing the bzImage, since it takes a little while 
18
and your mind has probably wandered.
19
20
Don't be afraid to come on IRC irc.oftc.net, #xbox-linux or the devel mailing 
21
list and ask some of the old hands there.
22
23
24
Compiling the kernel patched for Xbox
25
-------------------------------------
26
27
In order to use this CVS archive you need to setup things properly.
28
29
This document decribes three different ways to build the xbox kernel.
30
31
The first method attempts to build the kernel from the "HEAD" or current
32
version inside CVS. The current version is traditionally unstable and
33
(like in most projects) is very user unfriendly and may not even compile.
34
This is traditionally used by the experienced developers only. The code
35
changes frequently.
36
37
The second method is more 'user friendly'. It shows you how to extract a known
38
(tagged) working release of the kernel which will always compile. In essence,
39
the developers have put together a working set of files, tested them, tried them
40
and 'tagged' them as 'user friendly', IE. a fully working kernel.
41
42
The third, and easiest method, it to download and apply one of the tagged
43
release patches and apply it to the vanilla base kernel. This option is the
44
easiest option for users. You don't even need to know anything about cvs!
45
If you are unsure, choose this option.
46
47
Independent of how you've chosen to build your kernel, you will most certainly
48
perform these preliminary steps:
49
50
1. Download a kernel source tarball from:
51
52
   http://www.XY.kernel.org/pub/linux/kernel/v2.4/linux-2.4.25.tar.gz
53
   where XY is a two-letter country code, eg. `us', `de', `fr', etc.
54
55
2. Extract the contents of the archive into /usr/src:
56
57
   $ cd /usr/src
58
   $ tar xzvf linux-2.4.25.tar.gz
59
   $ mv linux-2.4.25{,-xbox}
60
61
62
Option 1: Installing From A Recent CVS Snapshot.
63
------------------------------------------------
64
65
3.1 Assuming you have a SF.net account, checkout the latest CVS snapshot:
66
67
    $ cvs -d:ext:username@cvs.sf.net:/cvsroot/xbox-linux co kernel
68
69
    If you do not have a SF.net user account, you may perform an anonymous
70
    checkout instead:
71
72
    $ cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/xbox-linux login
73
    $ cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/xbox-linux co kernel
74
75
    Now, you may copy the contents of the CVS repository into the kernel
76
    source directory:
77
78
    $ cp -rf kernel/* linux-2.4.25-xbox/
79
80
81
Option 2: Installing From A Tagged CVS Release.
82
-----------------------------------------------
83
84
3.2 Tagged releases are known to work, although this can not be fully
85
    guaranteed. Information regarding available tags can always be
86
    obtained from either the user or developer mailing lists. The
87
    current tagged release is `kernel-2_4_25-0_1_0'.
88
89
    So, assuming you have a SF.net account, you may proceed to
90
    checkout a tagged release like this:
91
92
    $ cvs -d:ext:username@cvs.sf.net:/cvsroot/xbox-linux \
93
      co -r kernel-2_4_25-0_1_0 kernel
94
95
    Or anonymously, if you don't have a SF.net account:
96
97
    $ cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/xbox-linux login
98
    $ cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/xbox-linux \
99
      co -r kernel-2_4_25-0_1_0 kernel
100
101
    Then copy the contents of the tagged release into the kernel source
102
    directory:
103
104
    $ cp -rf kernel/* linux-2.4.25-xbox/
105
106
107
Option 3: Installing From A Tagged CVS Release by Patching.
108
-----------------------------------------------------------
109
110
3.3 Tagged releases are also available in form of a patch against a stock
111
    version of the Linux kernel. Grab it from the SF.net project download
112
    page, save it in /usr/src and then apply it, like so:
113
114
    $ bzip2 -dc patch-kernel-2.4.20-dev-0.6.1.bz2 | patch -p0
115
116
117
4. With a patched kernel, you may now proceed to preparing the source tree
118
   for the final build:
119
120
   $ cd linux-2.4.25-xbox/
121
   $ make mrproper
122
   $ cp kernel.config .config
123
124
5. We need to load and save the config file to cause some actions to be made
125
   by the makefile. There are a bunch of ways to do this, the simplest is:
126
127
   $ make oldconfig
128
129
   If you need to see and change the config options, you need some packages
130
   installed:
131
132
   make menuconfig (curses-based configuration):
133
   ---------------------------------------------
134
   ncurses-base, ncurses-bin, ncurses-term, libncurses5 & libncurses5-dev
135
136
   make xconfig (graphical-based configuration):
137
   ---------------------------------------------
138
   tcl, tk
139
	  
140
   Exit from the menu configuration tools and choose YES to save your
141
   configuration. (This will build the menu configuration utilities and
142
   refresh the kernel configuration file named .config we previously made
143
   a default for)
144
145
   Now you have a usable kernel tree which you can do your compilations.
146
147
6. Compile the kernel and the modules, make sure none of these commands
148
   abort abnormally with errors. (NOTE: You will need to be root to make
149
   modules_install):
150
151
   $ make dep
152
   $ make bzImage
153
   $ make modules
154
   # make modules_install
155
156
The kernel has been compiled and is called `arch/i386/boot/bzImage'. Kernel
157
modules have been compiled and installed into `/lib/modules/2.4.25-xbox/'.
158
159
Kernel compilation complete.
160
161
162
Patch Files:
163
------------
164
165
Patch files will be released to the community based on tagged releases of CVS.
166
The name of the file will include the base kernel and the project tag version,
167
for example: patch-kernel-2.4.20-dev-0.6.1.bz2
168
169
Clearly, this patch should be applied to 2.4.20, is development quality and
170
was taken from the CVS tagged version 0.5.2.
171
 
172
173
Template Configuration File: `kernel.config':
174
---------------------------------------------
175
176
A default configuration file has been added with all of the necessary
177
compile options automatically set. This may save you time and trouble.
178
179
180
Finally (optional):
181
-------------------
182
If you've got no use for it, feel free to remove your working copy of the
183
CVS checkout:
184
185
   $ cd ../
186
   $ rm -rf kernel/
187
188
189
CVS Syncmail:
190
-------------
191
192
CVS is configured to send all repository changes to the xbox-linux-cvs 
193
mailing list.
194
195
The following text is taken from the official sourceforge CVS synmail 
196
configuration document:
197
198
199
A Warning Regarding Commit Messages:
200
------------------------------------
201
202
When you begin to use syncmail within your project CVS repository, it is 
203
important to give your developers prior notice. syncmail-generated messages
204
to your mailing list will contain the commit message used by the developer; 
205
developers should keep this in mind when entering their commit message 
206
(not to make inappropriate statements within their commit messages). 
207
SourceForge.net does not provide the means to remove posts from mailing
208
list archives; once a commit message appears in list archives, it will always 
209
appear in those archives. Proceed with caution."
210
211
212
Inside the Xbox Patches:
213
------------------------
214
215
The Xbox has at least the following problems so it doesn't run the Linux
216
kernel very well:
217
218
* the PCI bug: reading from 0:0:1 freezes the machine
219
* the timer: it is off by 6%
220
* the shutdown/reboot sequence: it's incompatible
221
222
The current kernel detects the Xbox by its 0:0:0 PCI device ID and sets
223
machine_is_xbox to 1. The PCI, timer and shutdown/reboot patches will
224
be applied then. This means that a Linux kernel with Xbox support will
225
still work on a PC without any differences.
226
227
228
Problems:
229
---------
230
231
If you have any problems *ask* (try the IRC channel)
232
(-)linux-2.4.26/Documentation/input/CVS/Entries (+2 lines)
Line 0 Link Here
1
/xpad.txt/1.3/Sun Aug 10 23:38:45 2003//
2
D
(-)linux-2.4.26/Documentation/input/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/Documentation/input
(-)linux-2.4.26/Documentation/input/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/Documentation/input/xpad.txt (+145 lines)
Line 0 Link Here
1
xpad - Linux USB driver for Xbox gamepads
2
------------------------------------------
3
4
This driver is work in progress. Although it is already fairly functional,
5
there are still quite a few things that are not implemented.
6
See the ToDo-List in drivers/usb/input/xpad.c for details.
7
8
9
0. Status
10
---------
11
12
I believe this driver to have been more or less intensively tested by
13
xbox-linux users, because it somehow managed it into their CVS [1] ;)
14
I myself have tested it on just one Linux-Box. This one is running a 2.4.19
15
kernel with usb-uhci on an amd athlon 600.
16
Additionally I did receive a few mails from people who have successfully
17
used the driver on different PC systems and notebooks. I did not yet receive
18
info on wether it works on PPC or non-i386 hardware.
19
20
Version 0.1.0-pre includes Oliver Schwartz' xpad-mouse driver code. This allows
21
for the xpad to be used as a pointer device (right thumbstick is movement, left
22
trigger is left mouse button, right one is right). This is not supposed to stay
23
that way (differs from Oliver's mapping), so don't get too used to it.
24
25
The jstest-program from joystick-1.2.15 (jstest-version 2.1.0) reports
26
14 axes (6 of them are the analog buttons) and 10 buttons (the analog buttons
27
are mapped as digital ones, too).
28
29
Alls 14 axes work, though they all have the same range (-32768..32767)
30
and the zero-setting is not correct for the triggers and the buttons
31
(I don't know if that is some limitation of jstest, since the input device
32
setup should be fine. I didn't have a look at jstest itself yet).
33
34
All of the 10 buttons work. The six buttons on the right side (A, B, C [black],
35
X, Y, Z [white]) are pressure-sensitive and report analog values as 8 bit
36
unsigned. These are mapped to analog (ABS_HAT1X - ABS_HAT3Y) as well as
37
digital inputs.
38
39
As of version 0.1.0-pre there is EXPERIMENTAL force feedback code. Note that
40
this is currently just plain stupid (as I have yet to find out all the neat
41
USB tricks) and is known to have bugs. Specifically, it does not work with the
42
stock MS controllers. The InterAct device rumbles just fine, though. I am
43
currently trying to figure out why.
44
Anyway, USE the stuff AT YOUR OWN RISK, the usual disclaimer applies. It
45
actually managed to crash my system once (unfortunately not reproducable).
46
You HAVE BEEN WARNED.
47
48
I tested the controller with quake3, and configuration and
49
in game functionality were OK. However, I find it rather difficult to
50
play first person shooters with a pad. Your mileage may vary.
51
52
53
1. USB adapter
54
--------------
55
56
Before you can actually use the driver, you need to get yourself an
57
adapter cable to connect the Xbox controller to your Linux-Box.
58
59
Such a cable is pretty easy to build. The Controller itself is a USB compound
60
device (a hub with three ports for two expansion slots and the controller
61
device) with the only difference in a nonstandard connector (5 pins vs. 4 on
62
standard USB connector).
63
64
You just need to solder a USB connector onto the cable and keep the
65
yellow wire unconnected. The other pins have the same order on both
66
connectors so there is no magic to it. Detailed info on these matters
67
can be found on the net ([2], [3], [4]).
68
69
Thanks to the trip splitter found on the cable you don't even need to cut the
70
original one. You can buy an extension cable and cut that instead. That way,
71
you can still use the controller with your Xbox, if you have one ;)
72
73
74
2. driver installation
75
----------------------
76
77
Once you have the adapter cable and the controller is connected, you need
78
to load your USB subsystem and should cat /proc/bus/usb/devices.
79
There should be an entry like the one at the end [5].
80
81
Currently (as of version 0.1.0), the following three devices are recognized:
82
 original Microsoft Xbox controller (US), vendor=0x045e, product=0x0202
83
 original Microsoft Xbox controller (Japan), vendor=0x045e, product=0x0285
84
 InterAct PowerPad Pro (Germany), vendor=0x05fd, product=0x107a
85
86
The driver does feel responsible for the actual USB ids, not the vendor
87
settings, so other controllers SHOULD work (although they will be reported as
88
unknown controller). If you have indication of that statement being wrong,
89
please send me a note.
90
Also, if you have a controller that is not recognized (but works) and you want
91
it to be correctly setup, please drop me a line with the appropriate info (that
92
is, include the name, vendor and product ID; sending the whole dump out of
93
/proc/bus/usb/devices along would be even better).
94
95
If you compiled and installed the driver, test the functionality:
96
> modprobe xpad
97
> modprobe joydev
98
> jstest /dev/js0
99
100
There should be 24 inputs (14 axes, 10 buttons), and the values should change
101
if you move the sticks and push the buttons.
102
103
You can test the force feedback functionality by
104
> modprobe evdev
105
> fftest /dev/input/event0
106
107
You need the Johann Deneux' fftest utility and the evdev module. Note that
108
the actual event interface number might differ (depends on wether you have the
109
mouse support included and wether it loads first or not) on your specific setup.
110
111
It works? Voila, your done ;)
112
113
114
3. Thanks
115
---------
116
117
I have to thank ITO Takayuki for the detailed info on his site
118
 http://euc.jp/periphs/xbox-controller.ja.html.
119
 
120
His useful info and both the usb-skeleton as well as the iforce input driver
121
(Greg Kroah-Hartmann; Vojtech Pavlik) helped a lot in rapid prototyping
122
the basic functionality.
123
124
125
4. References
126
-------------
127
128
1. http://xbox-linux.sourceforge.net
129
2. http://euc.jp/periphs/xbox-controller.ja.html (ITO Takayuki)
130
3. http://xpad.xbox-scene.com/
131
4. http://www.xboxhackz.com/Hackz-Reference.htm
132
133
5. /proc/bus/usb/devices - dump from InterAct PowerPad Pro (Germany):
134
135
T:  Bus=01 Lev=03 Prnt=04 Port=00 Cnt=01 Dev#=  5 Spd=12  MxCh= 0
136
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=32 #Cfgs=  1
137
P:  Vendor=05fd ProdID=107a Rev= 1.00
138
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
139
I:  If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=(none)
140
E:  Ad=81(I) Atr=03(Int.) MxPS=  32 Ivl= 10ms
141
E:  Ad=02(O) Atr=03(Int.) MxPS=  32 Ivl= 10ms
142
143
-- 
144
Marko Friedemann <mfr@bmx-chemnitz.de>
145
2003-01-23
(-)linux-2.4.26/Makefile (-1 / +1 lines)
Lines 1-7 Link Here
1
VERSION = 2
1
VERSION = 2
2
PATCHLEVEL = 4
2
PATCHLEVEL = 4
3
SUBLEVEL = 26
3
SUBLEVEL = 26
4
EXTRAVERSION =
4
EXTRAVERSION = -xbox
5
5
6
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
6
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
7
7
(-)linux-2.4.26/arch/CVS/Entries (+1 lines)
Line 0 Link Here
1
D/i386////
(-)linux-2.4.26/arch/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/arch
(-)linux-2.4.26/arch/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/arch/i386/CVS/Entries (+3 lines)
Line 0 Link Here
1
/config.in/1.11/Wed Feb 18 23:45:57 2004//
2
D/boot////
3
D/kernel////
(-)linux-2.4.26/arch/i386/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/arch/i386
(-)linux-2.4.26/arch/i386/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/arch/i386/boot/CVS/Entries (+1 lines)
Line 0 Link Here
1
D/compressed////
(-)linux-2.4.26/arch/i386/boot/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/arch/i386/boot
(-)linux-2.4.26/arch/i386/boot/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/arch/i386/boot/compressed/CVS/Entries (+2 lines)
Line 0 Link Here
1
/Makefile/1.4/Tue Nov 25 22:05:11 2003//
2
D
(-)linux-2.4.26/arch/i386/boot/compressed/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/arch/i386/boot/compressed
(-)linux-2.4.26/arch/i386/boot/compressed/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/arch/i386/boot/compressed/Makefile (-1 / +7 lines)
Lines 34-41 Link Here
34
34
35
comma	:= ,
35
comma	:= ,
36
36
37
# we don't know why, but newer (v1.1+) Xbox only boot
38
# if misc.o is compiled without optimization
39
ifeq ($(CONFIG_XBOX),y)
40
  EXTRACFLAGS-misc:= -O0
41
endif
42
37
misc.o: misc.c
43
misc.o: misc.c
38
	$(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c misc.c
44
	$(CC) $(CFLAGS) $(EXTRACFLAGS-misc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c misc.c
39
45
40
piggy.o:	$(SYSTEM)
46
piggy.o:	$(SYSTEM)
41
	tmppiggy=_tmp_$$$$piggy; \
47
	tmppiggy=_tmp_$$$$piggy; \
(-)linux-2.4.26/arch/i386/config.in (+4 lines)
Lines 222-227 Link Here
222
   bool 'HIGHMEM I/O support' CONFIG_HIGHIO
222
   bool 'HIGHMEM I/O support' CONFIG_HIGHIO
223
fi
223
fi
224
224
225
bool 'Xbox support' CONFIG_XBOX
226
if [ "$CONFIG_XBOX" = "y" ]; then
227
   tristate '  Xbox DVD eject fix' CONFIG_XBOX_EJECT
228
fi
225
bool 'Math emulation' CONFIG_MATH_EMULATION
229
bool 'Math emulation' CONFIG_MATH_EMULATION
226
bool 'MTRR (Memory Type Range Register) support' CONFIG_MTRR
230
bool 'MTRR (Memory Type Range Register) support' CONFIG_MTRR
227
bool 'Symmetric multi-processing support' CONFIG_SMP
231
bool 'Symmetric multi-processing support' CONFIG_SMP
(-)linux-2.4.26/arch/i386/kernel/CVS/Entries (+6 lines)
Line 0 Link Here
1
/Makefile/1.4/Fri Nov 28 23:51:51 2003//
2
/pci-pc.c/1.10/Fri Dec 19 00:03:21 2003//
3
/process.c/1.12/Thu Feb 19 21:42:04 2004//
4
/xboxejectfix.c/1.6/Fri Aug  8 12:19:48 2003//
5
/setup.c/1.5/Thu Apr 15 13:57:48 2004//
6
D
(-)linux-2.4.26/arch/i386/kernel/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/arch/i386/kernel
(-)linux-2.4.26/arch/i386/kernel/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/arch/i386/kernel/Makefile (+1 lines)
Lines 43-47 Link Here
43
obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o
43
obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o
44
obj-$(CONFIG_X86_VISWS_APIC)	+= visws_apic.o
44
obj-$(CONFIG_X86_VISWS_APIC)	+= visws_apic.o
45
obj-$(CONFIG_EDD)             	+= edd.o
45
obj-$(CONFIG_EDD)             	+= edd.o
46
obj-$(CONFIG_XBOX_EJECT)	+= xboxejectfix.o
46
47
47
include $(TOPDIR)/Rules.make
48
include $(TOPDIR)/Rules.make
(-)linux-2.4.26/arch/i386/kernel/pci-pc.c (+16 lines)
Lines 183-191 Link Here
183
static int pci_conf1_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value) /* !CONFIG_MULTIQUAD */
183
static int pci_conf1_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value) /* !CONFIG_MULTIQUAD */
184
{
184
{
185
	unsigned long flags;
185
	unsigned long flags;
186
#ifdef CONFIG_XBOX
187
	extern int machine_is_xbox;
188
#endif /* CONFIG_XBOX */
186
189
187
	if (bus > 255 || dev > 31 || fn > 7 || reg > 255)
190
	if (bus > 255 || dev > 31 || fn > 7 || reg > 255)
188
		return -EINVAL;
191
		return -EINVAL;
192
#ifdef CONFIG_XBOX
193
	/* Because of a hardware bug in the Xbox (nForce) chipset,
194
	 * reading from 0:0:1 and 0:0:2 in the PCI configuration
195
	 * space crashes the machine. */
196
	if (machine_is_xbox) {
197
		if (bus > 1)
198
			return -EINVAL;
199
		if ((bus == 1) && (dev | fn))
200
			return -EINVAL;
201
		if ((bus == 0 && dev == 0) && ((fn == 1) || (fn == 2)))
202
			return -EINVAL;
203
	}
204
#endif /* CONFIG_XBOX */
189
205
190
	spin_lock_irqsave(&pci_config_lock, flags);
206
	spin_lock_irqsave(&pci_config_lock, flags);
191
207
(-)linux-2.4.26/arch/i386/kernel/process.c (+24 lines)
Lines 50-55 Link Here
50
#endif
50
#endif
51
#include <asm/apic.h>
51
#include <asm/apic.h>
52
52
53
#ifdef CONFIG_XBOX
54
#include <linux/xbox.h>
55
#endif
56
53
#include <linux/irq.h>
57
#include <linux/irq.h>
54
58
55
asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
59
asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
Lines 412-417 Link Here
412
	disable_IO_APIC();
416
	disable_IO_APIC();
413
#endif
417
#endif
414
418
419
#ifdef CONFIG_XBOX
420
	if (machine_is_xbox) {
421
		while (1) {
422
			Xbox_reset();
423
			mdelay(1000);
424
			printk(KERN_EMERG "Calling I2C reset again\n");
425
		}
426
	}
427
		
428
#endif
429
415
	if(!reboot_thru_bios) {
430
	if(!reboot_thru_bios) {
416
		/* rebooting needs to touch the page at absolute addr 0 */
431
		/* rebooting needs to touch the page at absolute addr 0 */
417
		*((unsigned short *)__va(0x472)) = reboot_mode;
432
		*((unsigned short *)__va(0x472)) = reboot_mode;
Lines 438-443 Link Here
438
453
439
void machine_power_off(void)
454
void machine_power_off(void)
440
{
455
{
456
#ifdef CONFIG_XBOX
457
	if (machine_is_xbox) {
458
		while (1) {
459
			Xbox_power_off();
460
			mdelay(1000);
461
			printk(KERN_EMERG "Calling I2C power off again\n");
462
		}
463
	}
464
#endif
441
	if (pm_power_off)
465
	if (pm_power_off)
442
		pm_power_off();
466
		pm_power_off();
443
}
467
}
(-)linux-2.4.26/arch/i386/kernel/setup.c (+20 lines)
Lines 133-138 Link Here
133
EXPORT_SYMBOL(mmu_cr4_features);
133
EXPORT_SYMBOL(mmu_cr4_features);
134
134
135
/*
135
/*
136
 * Xbox timer patch
137
 */
138
#ifdef CONFIG_XBOX
139
int CLOCK_TICK_RATE;
140
int machine_is_xbox __initdata = 0;
141
#endif
142
143
/*
136
 * Bus types ..
144
 * Bus types ..
137
 */
145
 */
138
#ifdef CONFIG_EISA
146
#ifdef CONFIG_EISA
Lines 1203-1208 Link Here
1203
	rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
1211
	rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
1204
	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
1212
	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
1205
#endif
1213
#endif
1214
	/* SETUP_ARCH for Xbox */
1215
#ifdef CONFIG_XBOX
1216
	outl(0x80000000, 0xcf8);
1217
	if (inl(0xcfc)==0x02a510de) { /* Xbox PCI 0:0:0 ID 0x10de/0x02a5 */
1218
		machine_is_xbox = 1;
1219
		CLOCK_TICK_RATE = 1125000;
1220
		printk("Xbox detected - enabling Xbox patches.\n");
1221
	} else {
1222
		CLOCK_TICK_RATE = 1193180;
1223
	}
1224
#endif
1225
1206
	setup_memory_region();
1226
	setup_memory_region();
1207
	copy_edd();
1227
	copy_edd();
1208
1228
(-)linux-2.4.26/arch/i386/kernel/xboxejectfix.c (+146 lines)
Line 0 Link Here
1
/**
2
 * Driver that handles the EXTSMI# interrupt on the xbox.
3
 * Makes it possible to use the eject-button without the xbox rebooting...
4
 *
5
 * smbus-command sequence to prevent reboot from cromwell.
6
 *
7
 * Changelog:
8
 *  2003-01-14 Anders Gustafsson <andersg@0x63.nu>
9
 *             initial version
10
 *  2003-02-08 Milosch Meriac <xboxlinux@meriac.de>
11
 *             rewrote debug macros because of compiler errors
12
 *  2003-08-06 Michael Steil <mist@c64.org>
13
 *             removed Linux I2C dependency, now compiles
14
 *             without I2C in the kernel
15
 *
16
 * Todo: add errorhandling!
17
 *
18
 */
19
20
#include <linux/kernel.h>
21
#include <linux/module.h>
22
#include <linux/init.h>
23
#include <asm/io.h>
24
#include <linux/xbox.h>
25
26
#define IRQ 12
27
#define DRIVER_NAME "xboxejectfix"
28
29
/* just some crap */
30
static char dev[]=DRIVER_NAME;
31
32
/* External variable from ide-cd.c that specifies whether we simulate drive
33
   locking in software */
34
extern volatile int Xbox_simulate_drive_locked;
35
36
#define BASE 0x8000
37
38
/* Power Management 1 Enable Register */
39
#define PM02 (BASE+0x02)
40
41
/* Power Management 1 Control Register */
42
#define PM04 (BASE+0x04)
43
44
/* ACPI GP Status Register */
45
#define PM20 (BASE+0x20)
46
47
/* ACPI GP Enable Register */
48
#define PM22 (BASE+0x22)
49
# define EXTSMI_EN_MASK 0x0002
50
51
/* Global SMI Enable Register */
52
#define PM2A (BASE+0x2A)
53
54
55
static DECLARE_MUTEX(extsmi_sem);
56
static DECLARE_COMPLETION(extsmi_exited);
57
static int extsmi_pid=0;
58
59
static void extsmi_interupt(int i,void *dev,struct pt_regs *r){
60
	int reason;
61
62
	reason=inw(0x8020);
63
	outw(reason,0x8020); /* ack  IS THIS NEEDED? */
64
	if(reason&0x2){
65
		/* wake up thread */
66
		up(&extsmi_sem);
67
	}
68
}
69
70
/**
71
 * Process an event. This is run in process-context.
72
 */
73
static void extsmi_process(void){
74
	int reason;
75
	reason=Xbox_SMC_read(SMC_CMD_INTERRUPT_REASON);
76
77
	if(reason&TRAYBUTTON_MASK){ /* Tray button! Respond to prevent reboot! */
78
		Xbox_SMC_write(SMC_CMD_INTERRUPT_RESPOND, SMC_SUBCMD_RESPOND_CONTINUE);
79
		Xbox_SMC_write(0x00, 0x0c);
80
		/* eject unless lock simulation is being used */
81
		if (!Xbox_simulate_drive_locked)
82
			Xbox_tray_eject();
83
	}
84
}
85
86
static int extsmi_thread(void *data){
87
	daemonize();
88
	reparent_to_init();
89
	strcpy(current->comm, "xbox_extsmi");
90
91
	do {
92
		extsmi_process();
93
		down_interruptible(&extsmi_sem);
94
	} while (!signal_pending(current));
95
	
96
         complete_and_exit(&extsmi_exited, 0);
97
}
98
99
static int extsmi_init(void){
100
	int pid;
101
	
102
	if (!machine_is_xbox) {
103
		printk("This machine is no Xbox.\n");
104
		return -1;
105
	}
106
	printk("Enabling Xbox eject problem workaround.\n");
107
108
        pid = kernel_thread(extsmi_thread, NULL,
109
			    CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
110
	if (pid < 0) {
111
		return pid;
112
	}
113
114
	extsmi_pid = pid;
115
116
	/* this shuts a lot of interrupts off! */
117
	outw(inw(0x80e2)&0xf8c7,0x80e2);
118
	outw(0,0x80ac);
119
	outb(0,0x8025);
120
	outw(EXTSMI_EN_MASK,PM22); /* enable the EXTSMI# interupt! */
121
	outw(0,PM02);
122
	outb(1,PM04); /* enable sci interrupts! */
123
	Xbox_SMC_write(SMC_CMD_RESET_ON_EJECT, SMC_SUBCMD_RESET_ON_EJECT_DISABLE);
124
125
	/* FIXME! retval! */
126
	request_irq(IRQ,extsmi_interupt,SA_INTERRUPT|SA_SHIRQ /* |SA_SAMPLE_RANDOM */,
127
		    "xboxejectfix",dev);
128
	return 0;
129
}
130
131
static void extsmi_exit(void){
132
	int res;
133
	if (!machine_is_xbox) return; /* can this happen??? */
134
	free_irq(IRQ,dev);
135
136
	/* Kill the thread */
137
	res = kill_proc(extsmi_pid, SIGTERM, 1);
138
	wait_for_completion(&extsmi_exited);
139
	return;
140
}
141
142
module_init(extsmi_init);
143
module_exit(extsmi_exit);
144
145
MODULE_AUTHOR("Anders Gustafsson <andersg@0x63.nu>");
146
MODULE_LICENSE("GPL");
(-)linux-2.4.26/conf.vars (+25 lines)
Line 0 Link Here
1
VERSION          = 2
2
PATCHLEVEL       = 4
3
SUBLEVEL 	      = 26
4
EXTRAVERSION     = 
5
ARCH             = i386
6
KPKG_ARCH        = 
7
HOSTCC           = gcc-3.2
8
HOSTCFLAGS       = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
9
CROSS_COMPILE    = 
10
AS               = as
11
LD               = ld -m elf_i386
12
CC               = gcc-3.2
13
CPP              = gcc-3.2 -E
14
AR               = ar
15
NM               = nm
16
STRIP            = strip
17
OBJCOPY          = objcopy -O binary -R .note -R .comment -S
18
OBJDUMP          = objdump
19
MAKE             = /usr/bin/make
20
GENKSYMS 	      = /sbin/genksyms
21
CFLAGS           = -D__KERNEL__ -I$(TOPDIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i686
22
AFLAGS           = -D__ASSEMBLY__ -D__KERNEL__ -I$(TOPDIR)/include
23
MODFLAGS 	      = -DMODULE
24
do_parallel      = 
25
fast_dep         = 
(-)linux-2.4.26/debian/buildinfo (+15 lines)
Line 0 Link Here
1
gcc-2.95.4-14
2
gcc-2.95-2.95.4-11woody1
3
gcc-3.2-3.2.2-1xebian
4
gcc-3.2-base-3.2.2-1xebian
5
perl-5.6.1-8.7
6
dpkg-1.9.21
7
libc6-2.2.5-11.5
8
libc6-dev-2.2.5-11.5
9
binutils-2.14.90.0.7-3xebian
10
make-3.79.1-14
11
dpkg-dev-1.9.21
12
this was built on a machine with the kernel:
13
Linux centi.localdomain.local 2.6.5 #1 Sun May 2 17:31:11 CEST 2004 i686 unknown
14
using the compiler:
15
gcc version 3.2.2
(-)linux-2.4.26/debian/changelog (+451 lines)
Line 0 Link Here
1
kernel-source-2.4.26 (1) unstable; urgency=low
2
3
  * Added support for netwinders
4
  * Modified modules support to not assume everything in /usr/src/modules
5
    is a directory. 
6
7
 -- Manoj Srivastava <srivasta@debian.org>  Wed, 25 Nov 1998 01:39:43 -0600
8
9
kernel-source-0.34 (1.01)  unstable; urgency=low
10
11
  * This is a major change in the source/header packages. In architectures
12
    different from i386, `kernel-headers-*' and `kernel-source-*' are
13
    incompatible. This also has an effect on libc6-dev, which depends on
14
    kernel-headers-2.0.3x | kernel-source-2.0.3x, which is only true on
15
    i386 architectures. One possible solution would be to make libc6-dev
16
    depend on kernel-headers-2.0.32, but that won't work because
17
    kernel-source provides kernel-headers. In fact, since kernel-headers
18
    are arch dependent, but kernel-source is arch: all, kernel-source-*
19
    should not provide kernel-header* at all. 
20
    
21
    Once kernel source stops providing kernel-header*, and libc6-dev
22
    depends on kernel-headers-2.0.32 and links /usr/include/{linux,asm} to
23
    /usr/src/kernel-headers-2.0.32 (nor /usr/src/linux-2.0.32) things
24
    would work again in a Multi arch compatible fashion.
25
  
26
    Hence, now kernel-source-* packages compiled with this kernel-package
27
    shall not provide any sort of kernel-headers. For the sake of
28
    backwards compatibility, /usr/src/linux-$version symlinks are still
29
    being provided (as people may upload newer kernels while keeping an
30
    older libc6-dev around, which depends on /usr/src/linux-2.0.32. 
31
  
32
    However, I have been badgered enough about this that I shall remove
33
    the /usr/src/linux-$version symlinks at some point. This version no
34
    longer registers stuff in /usr/src/.linux-versions, and is no longer
35
    as paranoid about /usr/src/linux; but it does not outright remove
36
    those files either, so as not to cause people with older kernels
37
    having a problem during removal.As soon as it is deemed permissible,
38
    we shall get less paranoid about /usr/src/linux-$version as well. 
39
  * closes: Bug#18277
40
41
 -- Manoj Srivastava <srivasta@debian.org>  Wed, 18 Feb 1998 16:44:31 -0600
42
43
kernel-source-0.33 (1.01) unstable; urgency=low
44
45
  * Added SUBARCH, which is used to distinguish Amiga, Atari, Macintosh,
46
    etc. kernels for Debian/m68k, and may well be required for the alpha,
47
    from what I hear. Unlike the FLAVOURS variable, which affects
48
    everything it can lay its grubby hands on (kernel image, headers,
49
    source, doc package versions, and where the modules are looked for
50
    under /lib/modules), this only affects the naming of the kernel-image
51
    as the source and doc packages are architecture independent and the
52
    kernel-headers do not vary from one sub-architecture to the
53
    next. These changes are courtesy of James Troup <J.J.Troup@scm.brad.ac.uk>
54
55
 -- Manoj Srivastava <srivasta@debian.org>  Mon, 16 Feb 1998 16:47:08 -0600
56
57
kernel-source-0.32 (1.01) unstable; urgency=low
58
59
  * Ensure that the /usr/src/linux and /usr/src/linux-<version> links
60
    always exist, no matter what. Apparently, upgrading from
61
    kernel-source-2.0.32_2.0.32-1 to kernel-source-2.0.32_2.0.32-3 does
62
    not create /usr/src/linux-<version>, which breaks libc6-dev.
63
  * Toned down the language about LILO, so as not to startle new sparc users
64
65
 -- Manoj Srivastava <srivasta@debian.org>  Thu, 12 Feb 1998 21:56:50 -0600
66
67
kernel-source-0.31 (1.01) unstable; urgency=low
68
69
  * Added ARCH to make called, this allows for cross compiling kernels
70
    (added on a request by  James Troup <J.J.Troup@scm.brad.ac.uk>)
71
  * Make kernel-headers arch: any, so we can indeed have different headers
72
    for different architectures.
73
  * m68k can now handle vmlinuz, so reverse that behaviour in the rules
74
    file. AFAIK m68k still uses zImage.
75
  * Improvements to /usr/doc/kernel-patch/MultiArch.gz, based on
76
    suggestions by James Troup <J.J.Troup@scm.brad.ac.uk>/
77
78
 -- Manoj Srivastava <srivasta@debian.org>  Mon,  9 Feb 1998 17:11:05 -0600
79
80
kernel-source-0.30 (1.01) unstable; urgency=low
81
82
  * Redid the Headers README file
83
  * Added a rationale to the LinkPolicy document. So far, it detailed
84
    *what* Debian did. Now, it also says *why* we do it.
85
86
 -- Manoj Srivastava <srivasta@debian.org>  Thu, 29 Jan 1998 19:13:58 -0600
87
88
kernel-source-0.29 (1.01) unstable; urgency=low
89
90
  * Important changes for kernel-source-* and kernel-header-* packages: now
91
    kernel-source-* packages also provide the exact kernel-header-* (libc6
92
    need only depend on kernel-header-* now.
93
  * The kernel-header-* and kernel-source-* packages now also maitain the
94
    /usr/src/linux-X.YY.ZZ links (in addition to the /usr/src/linux links)
95
    This is used in the libc6 package.
96
97
 -- Manoj Srivastava <srivasta@debian.org>  Sat, 13 Dec 1997 12:46:47 -0600
98
99
100
kernel-source-0.28 (1.01) unstable; urgency=low
101
102
  * Fixed a typo where we tried to dd /vmlinuz-2.0.32 rather than the
103
    correct /boot/vmlinuz-2.0.32 in image.postinst. How come this glaring
104
    an error has gone unreported until now?
105
106
 -- Manoj Srivastava <srivasta@debian.org>  Fri, 23 Jan 1998 14:36:34 -0600
107
108
kernel-source-0.27 (1.01) unstable; urgency=low
109
110
 * Fixed Typo in kernel rules that put all modules into block (this
111
    is more of a thinko/cut and paste error. fixes: Bug#16697,Bug#16702
112
  * No longer a fatal error if there is no /vmlinuz (or
113
    equivalent). fixes: Bug#16899
114
  * Added language to the abort on /usr/src/linux not being a
115
    link. 
116
  * Documented the fact that if you re-run make-kpkg with a different
117
    revision number, you have to reconfigure the kernel. 
118
    fixes: Bug#16968
119
  * ignore obsolete fdformat in favour of superformat.
120
  * Changed the kernel rules file not break on the sound modules of
121
    2.1.70+ kernels (I think it is a bug in the kernel Makefile, but this
122
    fix make make-kpkg handle the problem and be more robust).
123
  * Modified image.postinst to also cater to people on whose architecture
124
    the image is not called vmlinuz but something else (like vmlinux, for
125
    example). closes:Bug#16258
126
  * Made the postrm's also know about the kernel versrion, not just the
127
    postinst. (Sorry). closes:Bug#15920
128
  * Changed include.postrm to be more careful about removing the symbolic
129
    link /usr/src/linux-X.Y.Z. Keep track if there is another package
130
    installed that could provide the link.
131
132
 -- Manoj Srivastava <srivasta@debian.org>  Wed, 21 Jan 1998 03:27:35 -0600
133
134
kernel-source-0.26 (1.01) unstable; urgency=low
135
136
  * Added HAM modules to the module we know about, these were introduced
137
    in 2.1.70.
138
139
 -- Manoj Srivastava <srivasta@debian.org>  Tue,  9 Dec 1997 23:27:04 -0600
140
141
kernel-source-0.25 (1.01) unstable; urgency=low
142
143
  * Ignore unmounted devices while looking for a root file system. Much
144
    thanks to Thomas Kocourek <tko@westgac3.dragon.com> for noticing
145
    this. 
146
  * Make sure that the copyright file for the kernel-doc package is not
147
    compressed. closes:Bug#14403,Bug#14405
148
  * Added internal utility kpkg-vercheck to test the validity of the
149
    package version.
150
151
 -- Manoj Srivastava <srivasta@debian.org>  Mon, 10 Nov 1997 10:37:08 -0600
152
153
kernel-source-0.24 (1.01) unstable; urgency=low
154
155
  * Install the README.headers in the right place for the source
156
    package. closes:Bug#14552.
157
  * Handle the new NLS_MODULES that have appeared in the newest 2.1.6x
158
    kernels. closes:Bug#14527.
159
160
 -- Manoj Srivastava <srivasta@debian.org>  Wed,  5 Nov 1997 23:30:48 -0600
161
162
kernel-source-0.23 (1.-0) unstable; urgency=low
163
164
  * Added README.headers to the kernel-source package as well, since the
165
    information _is_ relevant to compiling kernels. Since kernel source
166
    packages have higher visibility than kernel header packages, this may
167
    help avoid some FAQs from being asked.
168
  * Changed image postinst not to use the obsolete -d option to
169
    superformat. Removed extra spaces from the exec option, so that it is
170
    more likely to work. Noticed by Joost Kooij <kooij@mpn.cp.philips.com>
171
  * Note that the proposed two level versioning scheme fails if standard
172
    kernels use epochs. Further note that one may introduce epochs even in
173
    custom kernels. 
174
175
 -- Manoj Srivastava <srivasta@debian.org>  Thu, 23 Oct 1997 12:19:51 -0500
176
177
kernel-source-0.22 (1.01) unstable; urgency=low
178
179
  * Handle obsolete /System.map and /System.old links left around by older
180
    kernel-package packages. All the programs that look at the information
181
    in the map files (including top, ps, and klogd) also will look at
182
    /boot/System.map-<version>, we just need to ensure that that file is
183
    present, and no longer require the symbolic link. 
184
    Actually, having the symbolic link in / is technically detrimental
185
    (apart from cluttering up /); many programs, though looking in /boot,
186
    still allow /System.map to override. If you use LILO to choose between
187
    multiple kernels, then the /System.map symbolic link only applies to
188
    one such kernel, for all other choices the symbols loaded will be
189
    wrong. Not having the symbolic links at all prevents this. 
190
    Therefore, the new image.postinst file shall offer to remove the
191
    symbolic links in /. This should fix BUG#13359
192
193
 -- Manoj Srivastava <srivasta@debian.org>  Fri, 26 Sep 1997 10:44:39 -0500
194
195
kernel-source-0.21 (1.01) unstable; urgency=low
196
197
  * Fixed handling of modules.dep in the image.postinst. We do not attempt
198
    to recreate a modules.dep, since the man page admits the file so
199
    created may be incorrect. We warn the installer that there maybe
200
    problems loading modules into the kernel until reboot iff the version
201
    being installed is the same as the version currently running.
202
203
 -- Manoj Srivastava <srivasta@debian.org>  Tue, 16 Sep 1997 15:07:02 -0500
204
205
kernel-source-0.20 (1.01) unstable; urgency=low
206
207
  * No longer create a System.map symlink in /, since that may confuse
208
    klogd when choosing kernel images using LILO. Since top, ps, and klogd
209
    look at /boot/System.map-<version>, we just need to make sure that
210
    file is present. This makes us friendlier to multiple images of the
211
    same kernel version.
212
  * No longer redirect output to a file in /tmp for security reasons (we
213
    use a log file in /var/log instead). This fixes BUG#11765,
214
    BUG#11766 and BUG#11847 
215
  * Added support for different flavours of the same kernel version for
216
    people who need them. This is based on the ideas and work of Bill
217
    Mitchell <mitchell@mozcom.com> and Noel Maddy <ncm@biostat.hfh.edu>.
218
    This should make us fully compliant to having multiple flavours of the
219
    same kernel version. 
220
  * Added dependencies to targets in rules. Now things should work as
221
    expected if one edits a .config file. 
222
  * Fixed destination for the Buildinfo file. This fixes BUG#11884.
223
224
 -- Manoj Srivastava <srivasta@debian.org>  Mon,  4 Aug 1997 13:03:51 -0500
225
226
kernel-source-0.19 (1.01) unstable; urgency=low
227
228
  * All kernel packages produced now list the version of kernel-package
229
    used in the file /usr/doc/Buildinfo.
230
  * The image prerm will allow you to remove an running kernel image and
231
    hose your system. You will be warned. (under protest).
232
  * Fixed typo in control file for kernel-doc description. This fixes
233
    Bug#11568.
234
235
 -- Manoj Srivastava <srivasta@debian.org>  Tue, 29 Jul 1997 17:47:41 -0500
236
237
kernel-source-0.18 (1.01) unstable; urgency=low
238
239
  * No longer carries around an extra uncompressed kernel image, and does
240
    not anymore create /boot/psdatabase-X.X.XX. The psdatabase file does
241
    not seem to be required anymore.
242
243
 -- Manoj Srivastava <srivasta@debian.org>  Wed, 18 Jun 1997 13:05:33 -0500
244
245
kernel-source-0.17 (1.01) unstable; urgency=low
246
247
  * Added patches to support m68k from "Frank Neumann"
248
    <Frank.Neumann@Informatik.Uni-Oldenburg.DE>.
249
  * Added patched to support sparcs from Eric Delaunay
250
    <delaunay@lix.polytechnique.fr> 
251
252
 -- Manoj Srivastava <srivasta@debian.org>  Mon,  2 Jun 1997 15:17:59 -0500
253
254
kernel-source-0.16 (1.01) unstable; urgency=low
255
256
  * Moved config to /boot, where it arguably should have gone to in the
257
    first place. The /boot directory contains other information pertinent 
258
    to the kernel, such as the System.map file, and the psdatabase.  The 
259
    information about exactly what was configured into the kernel was 
260
    missing, and it can get quite critical on some machines.  Also, the 
261
    config file may serve as a base for compiling the next kernel. This 
262
    file is not really a configuration file (not when packaged as part of 
263
    the kernel-image package), hence it does not belong in /etc (no amout 
264
    of changing this file will have any affet on system behaviour).
265
266
 -- Manoj Srivastava <srivasta@debian.org>  Wed, 21 May 1997 01:44:17 -0500
267
268
kernel-source-0.15 (1.01) unstable; urgency=low
269
270
  * Kernel-image and kernel-doc now suggest each other.
271
  * Also recognize powerpc as a synonym for ppc in determining whether
272
    we use zImage or bzImage by default.
273
  * Fixed up some typos in documentation
274
  * Added rules target kernel_doc. This fixes BUG#9138
275
  * Also install .config file under /usr/doc. This fixes BUG#9298
276
277
 -- Manoj Srivastava <srivasta@debian.org>  Fri, 2 May 1997 14:34:51 -0500
278
279
kernel-source-0.14 (1.01) unstable; urgency=low
280
281
  * No longer install text files in the modules directory, since depmod
282
    in modutils-2.1.34 fails when it finds a non-ELF file in modules
283
    directory. This fixes Bug#9243.
284
285
 -- Manoj Srivastava <srivasta@debian.org>  Wed, 30 Apr 1997 15:24:51 -0500
286
287
kernel-source-0.13 (1.01) unstable; urgency=low
288
289
  * Really add in all the changes sent in by Herbert Xu. The changes are: 
290
    * Changed to source package name back to kernel-source-2.4.26 again. 
291
    * Changed the installs to be without -o root -g root since it is no
292
      longer useful as the chowns are done before the packages are built. It
293
      also means that if it is used in targets like stamp-configure which may
294
      be run by anyone it won't not generate an error.
295
    * Made rules file generate the control file.
296
    * Fixed some typos in chown commands while generating the header
297
      packages. 
298
299
 -- Manoj Srivastava <srivasta@debian.org>  Mon, 21 Apr 1997 15:12:19 -0500
300
301
 kernel-source-0.12 (1.01) unstable; urgency=low
302
303
  * Forgot to mention that the source package for the kernel packages 
304
    (produced by make-kpkg buildpackage, for example) has been changed to 
305
    not contain the kernel version as part of the name (all the deb files 
306
    produced have not changed), so we now get kernel-image-xxx_yy_zz.deb, 
307
    kernel-source-xxx_yy_zz.deb, and kernel-headers-xxx_yy_zz.deb, along
308
    with kernel-source.tar.gz and kernel-source_yy.diff.gz
309
  * Added changes from the kernel packages maintainer (this is the
310
    kernel-packages maintainer speaking, Herbert Xu handles the kernel
311
    image, headers, and source packages at the moment).
312
313
 -- Manoj Srivastava <srivasta@debian.org>  Sun, 13 Apr 1997 00:03:36 -0500
314
315
 kernel-source-0.11 (1.01) unstable; urgency=low
316
317
  * set umask to copy the kernel source files untainted by package creators
318
    umask. 
319
  * set umask to copy the kernel header files untainted by package creators
320
    umask.
321
322
 -- Manoj Srivastava <srivasta@debian.org>  Tuesday, 1 Apr 1997 11:04:42 -0600
323
324
 kernel-source-0.10 (1.01) unstable; urgency=low
325
326
  * image postinst no longer aborts when the user gives up on formatting a
327
    floppy, but is offered a choice to proceed with a preformatted floppy. 
328
  * Fixed spelling errors in kernel image postinst
329
  * Offer to user superformat if it exists.
330
  * Tested boot floppy creation.
331
  * Tested on 2.0.29, 2.1.29, and 2.1.30
332
  * Mention setfdprm in postinst if fail to format floppy.
333
  * Fix a typo in code determining which floppy drive to use
334
  * Allow leading whitespace in responses
335
336
 -- Manoj Srivastava <srivasta@debian.org>  Sun, 23 Mar 1997 22:53:13 -0600
337
338
kernel-source-0.9 (1.01) unstable; urgency=low
339
340
  n Stupid @#$%$%@! vi changed Feb to February in the changelog messing up
341
    gencontrol. 
342
343
 -- Manoj Srivastava <srivasta@debian.org>  Mon, 17 Feb 1997 19:29:02 -0600
344
345
kernel-source-0.8 (1.01) unstable; urgency=low
346
347
  * Removed extra root checks
348
  * Added error messages to failed root check
349
 
350
 -- Manoj Srivastava <srivasta@debian.org> Thursday, 13 February 1997 14:47:06 -0600
351
352
kernel-source-0.7 (1.01) unstable; urgency=low
353
354
  * Fixed kernel rules file so that one does not depend on the existence of modules
355
356
 -- Manoj Srivastava <srivasta@debian.org>  Tuesday, 28 January 1997 22:15:27 -0600
357
358
kernel-source-0.6 (1.01) unstable; urgency=low
359
360
  * changed priority of kernel-source package to optional
361
  * changed priority of kernel-image package to optional
362
363
 -- Manoj Srivastava <srivasta@debian.org>  Fri, 22 Nov 1996 11:02:31 -0600
364
365
366
kernel-source-0.5 (1.01) unstable; urgency=low
367
368
  * kernel-source-X.XX now no longer recommends bin86, since bin86 is only
369
    available intel platforms.  It now merely mentions it in the
370
    description.
371
372
 -- Manoj Srivastava <srivasta@debian.org>  Thu, 7 Nov 1996 22:17:47 -0600
373
374
kernel-source-0.4 (1.01) unstable; urgency=low
375
376
  * kernel-source-X.XX now recommends bin86, which fixes Bug#4443
377
  * Added short, succinct (and potentially dangerous) instructions on
378
    compiling kernels at the top of the README file.  This fixes Bug#4445.
379
380
 -- Manoj Srivastava <srivasta@debian.org>  Wed, 6 Nov 1996 23:59:47 -0600
381
382
kernel-source-0.3 (1.01) unstable; urgency=low
383
384
  * Changed everything to new packaging standards.
385
  * Major re-organization.
386
  * Added explanation for kernel-headers-X.XX (and why we need this
387
    package inspite of having headers in libc5-dev)
388
  * Added README files for all packages (the old README files became
389
    copyright files).
390
  * Added target for buildpackage (wich needed a hack in the target clean
391
    so as not to remove the ./debian directory prematurely)
392
393
 -- Manoj Srivastava <srivasta@debian.org>  Tue, 5 Nov 1996 22:42:12 -0600
394
395
kernel-source-0.2 (1.01) unstable; urgency=low
396
397
  * Made image.postinst more polite.
398
  * Also enabled kernel-{source,image,headers} targets in kernel.rules 
399
  * Changed make-kpkg to also accept the new targets.
400
  * Fixed typo in man page.
401
  * The man page says it is an administrators man page rather than a 
402
    programmers man page.
403
  * Recommended libc-dev for kernel-source and kernel-package
404
  * source suggests ncurses3.0-dev, tk40-dev and the description explains 
405
    you could use make menuconfig rather than plain old make config if you
406
    had these packages.
407
  * Fixed typo in the rules for modules in /usr/src/modules/ directory
408
  * Made the rules for such modules ignore errors (since they are not
409
    really a part of this package, error there should not halt this build
410
    (or so people seem to want it)
411
  * Look for modules in the kernel config file (or the default config file
412
    if the user has not supplied a config file), and only make modules and
413
    install them if modules have been configured in the config file. This 
414
    could be tested better.
415
  * Fixed the make-kpkg.8 man page so that it now does not seem to mandate
416
    a source and diff file for additional modules installed under the 
417
    directory /usr/src/modules/ (whether these files are produced is at
418
    the discretion of the maintainer of that modules package.
419
  * Make configure depend on stamp-configure which in turn depends on
420
    .config Hopefully, this will remake the image target if one changes
421
    the config file Hopefully, this will not cause the image target to
422
    build needlessly. 
423
424
 -- Manoj Srivastava <srivasta@debian.org>  
425
426
kernel-source-0.1 (1.01) unstable; urgency=low
427
428
  * Changed the scripts to refer to /usr/bin/perl rather than /bin/perl.
429
  * Added an extended description to the image control file.
430
  * Added a note that the dist target requires a PGP key.
431
  * Fixed a typo (missing DEBDIR) in debian.rules.
432
  * Fixed the targets expected by make-kpkg (kernel_image rather than 
433
    kernel-image, etc).
434
  * In image.postinst, made arguments to system be a single argument if  
435
    the arguments contain shell meta-characters, (this way perl passes
436
    them to sh -c).
437
  * Made make-kpkg accept non floats as revision numbers, to facilitate  
438
    local names.
439
  * Fixed silly bug in makefloppy in image.postinst.
440
  * Fixed the extended description of the kernel-package package.
441
  * Updated the image postinst to install the mbr, if it exists, and to
442
    activate the root partition, and to not overwrite the mbr (oops).
443
  * Changed maintainer email address to debian.org (I'll be in a state of  
444
    flux soon)
445
446
447
 -- Manoj Srivastava <srivasta@pilgrim.umass.edu>  
448
449
Local variables:
450
mode: debian-changelog
451
End:
(-)linux-2.4.26/debian/control (+80 lines)
Line 0 Link Here
1
Source: kernel-source-2.4.26
2
Section: devel
3
Priority: optional
4
Maintainer:  Edgar Hucek <hostmaster@ed-soft.at>
5
Standards-Version: 3.5.9.0
6
7
Package: kernel-headers-2.4.26
8
Architecture: any
9
Section: devel
10
Priority: optional
11
Provides: kernel-headers, kernel-headers-2.4
12
Description: Header files related to Linux kernel version 2.4.26
13
 This package provides kernel header files for version 2.4.26, for sites 
14
 that want the latest kernel headers. Please read
15
 /usr/share/doc/kernel-headers-2.4.26/debian.README.gz for details
16
17
Package: kernel-source-2.4.26
18
Architecture: all
19
Section: devel
20
Priority: optional
21
Provides: kernel-source, kernel-source-2.4
22
Depends: binutils, bzip2
23
Recommends: libc-dev, gcc, make
24
Suggests: libncurses-dev | ncurses-dev, kernel-package
25
Description: Linux kernel source for version 2.4.26
26
 This package provides the source code for the Linux kernel version 2.4.26.
27
 .
28
 You may configure the kernel to your setup by typing "make config"
29
 and following instructions, but you could get ncursesX.X-dev and try
30
 "make menuconfig" for a jazzier, and easier to use interface. There 
31
 are options to use QT or GNOME based configuration interfaces, but they
32
 need additional packages to be installed. Also, please read the detailed 
33
 documentation in the file
34
 /usr/share/doc/kernel-source-2.4.26/README.headers.gz.
35
 .
36
 If you wish to use this package to create a custom Linux kernel, then
37
 it is suggested that you investigate the package kernel-package,
38
 which has been designed to ease the task of creating kernel image
39
 packages. 
40
41
Package: kernel-image-2.4.26
42
Architecture: i386
43
Section: base
44
Priority: optional
45
Provides: kernel-image,  kernel-image-2.4
46
Depends:  coreutils | fileutils (>= 4.0)
47
Suggests: lilo (>= 19.1) | grub,  fdutils, kernel-doc-2.4.26 | kernel-source-2.4.26 
48
Description: Linux kernel binary image for version 2.4.26.
49
 This package contains the Linux kernel image for version 2.4.26,
50
 the corresponding System.map file, and the modules built by the
51
 packager.  It also contains scripts that try to ensure that the
52
 system is not left in a unbootable state after an update.
53
 .
54
 If you wish to update a bootdisk, or to use a bootloader to make
55
 installing and using the image easier, we suggest you install the latest
56
 fdutils (for formatting a floppy to be used as boot disk), and LILO, for a
57
 powerful bootloader. Of course, both these are optional. 
58
 .
59
 Kernel image packages are generally produced using kernel-package,
60
 and it is suggested that you install that package if you wish to
61
 create a custom kernel from the sources. Please look at kernel-img.conf(5),
62
 and /usr/share/doc/kernel-package/README.gz  from the package kernel-package
63
 for details on how to tailor the  installation of this or any other kernel 
64
 image package
65
66
Package: kernel-doc-2.4.26
67
Architecture: all
68
Section: doc
69
Priority: optional
70
Provides: kernel-doc-2.4
71
Suggests: kernel-image-2.4.26
72
Description: Linux kernel specific documentation for version 2.4.26.
73
 This package provides various Readme's in the 2.4.26 kernel
74
 Documentation/ subdirectory: these typically contain kernel-specific
75
 installation notes for some drivers. for example. Please see
76
 /usr/share/doc/kernel-doc-X.X.XX/Documentation/00-INDEX for a list of
77
 contents.  Please also read the Changes file, as it contains
78
 information about the problems which may result by upgrading your
79
 kernel.
80
(-)linux-2.4.26/debian/files (+1 lines)
Line 0 Link Here
1
kernel-image-2.4.26_1_i386.deb base optional
(-)linux-2.4.26/debian/rules (+2153 lines)
Line 0 Link Here
1
#! /usr/bin/make -f
2
############################ -*- Mode: Makefile -*- ###########################
3
## debian.rules ---
4
## Author	    : Manoj Srivastava ( srivasta@pilgrim.umass.edu )
5
## Created On	    : Sat Apr 27 06:36:31 1996
6
## Created On Node  : melkor.pilgrim.umass.edu
7
## Last Modified By : Manoj Srivastava
8
## Last Modified On : Sun Jan 11 11:54:53 2004
9
## Last Machine Used: glaurung.internal.golden-gryphon.com
10
## Update Count	    : 655
11
## Status	    : Unknown, Use with caution!
12
## HISTORY	    :
13
## Description	    :
14
## $Id: rules,v 1.227 2003/10/07 16:24:20 srivasta Exp $
15
###############################################################################
16
17
ifdef KPKG_ARCH
18
  ifneq ($(strip $(KPKG_ARCH)),um)
19
    ha:=-a$(KPKG_ARCH)
20
  endif
21
endif
22
23
DPKG_ARCH := dpkg-architecture
24
# set the dpkg-architecture vars
25
export DEB_BUILD_ARCH      := $(shell $(DPKG_ARCH) $(ha) -qDEB_BUILD_ARCH)
26
export DEB_BUILD_GNU_CPU   := $(shell $(DPKG_ARCH) $(ha) -qDEB_BUILD_GNU_CPU)
27
export DEB_BUILD_GNU_TYPE  := $(shell $(DPKG_ARCH) $(ha) -qDEB_BUILD_GNU_TYPE)
28
export DEB_HOST_ARCH       := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_ARCH)
29
export DEB_HOST_GNU_CPU    := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_GNU_CPU)
30
export DEB_HOST_GNU_SYSTEM := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_GNU_SYSTEM)
31
export DEB_HOST_GNU_TYPE   := $(shell $(DPKG_ARCH) $(ha) -qDEB_HOST_GNU_TYPE)
32
export DEB_BUILD_GNU_SYSTEM:= $(shell $(DPKG_ARCH) $(ha) -qDEB_BUILD_GNU_SYSTEM)
33
34
#
35
# VERSION=$(shell LC_ALL=C dpkg-parsechangelog | grep ^Version: | \
36
#                          sed 's/^Version: *//')
37
#
38
39
# The version of kernel-package this belongs to
40
kpkg_version := 8.079-1xebian
41
42
# The maintainer information.
43
maintainer = Herbert Xu
44
email= herbert@greathan.apana.org.au
45
46
pgp=$(maintainer)
47
48
49
#  Package specific stuff
50
# decide if image is meant to be in /boot rather than /
51
link_in_boot :=
52
# Can we use symlinks?
53
no_symlink :=
54
# If so, where is the real file (usually, vmlinuz-X.X.X is real, and
55
# vmlinuz is the link, this variable reverses it.
56
reverse_symlink :=
57
58
# The version numbers for kernel-image, kernel-headers and
59
# kernel-source are deduced from the Makefile (see below,
60
# and footnote 1 for details)
61
62
# Whether to look for and install kernel patches by default.
63
# Be very careful if you do this.
64
patch_the_kernel := AUTO
65
66
# do not create libc headers by default
67
make_libc_headers := NO
68
69
# run make clean after build
70
do_clean := YES
71
72
# install uncompressed kernel ELF-image (for oprofile)
73
int_install_vmlinux := NO
74
75
# what kernel config target to run in our configure target.
76
config_target := oldconfig
77
78
79
# The default architecture (all if architecture independent)
80
CROSS_ARG:=
81
82
ifdef KPKG_ARCH
83
  architecture:=$(KPKG_ARCH)
84
else
85
  #architecture:=$(shell CC=$(HOSTCC) dpkg --print-gnu-build-architecture)
86
  architecture:=$(DEB_HOST_ARCH)
87
endif
88
89
ifndef CROSS_COMPILE
90
  ifneq ($(strip $(KPKG_ARCH)),um)
91
    ifneq ($(strip $(architecture)),$(strip $(DEB_BUILD_ARCH)))
92
      KERNEL_CROSS:=$(architecture)-$(strip $(DEB_HOST_GNU_SYSTEM))-
93
    endif
94
  endif
95
else
96
  KERNEL_CROSS:=$(CROSS_COMPILE)-
97
endif
98
99
ifneq ($(strip $(KERNEL_CROSS)),)
100
  CROSS_ARG:=CROSS_COMPILE=$(KERNEL_CROSS)
101
endif
102
103
KERNEL_ARCH:=$(architecture)
104
DEBCONFIG = $(CONFDIR)/config
105
IMAGEDIR=/boot
106
INT_IMAGE_DESTDIR=debian/tmp-image$(IMAGEDIR)
107
108
109
VERSION =$(shell egrep '^VERSION +=' Makefile 2>/dev/null | \
110
 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
111
PATCHLEVEL =$(shell egrep '^PATCHLEVEL +=' Makefile 2>/dev/null | \
112
 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
113
SUBLEVEL =$(shell egrep '^SUBLEVEL +=' Makefile 2>/dev/null | \
114
 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
115
EXTRA_VERSION =$(shell egrep '^EXTRAVERSION +=' Makefile 2>/dev/null | \
116
 sed -e 's/EXTRAVERSION *= *\([^ \t]*\)/\1/')
117
HAVE_NEW_MODLIB =$(shell egrep '\(INSTALL_MOD_PATH\)' Makefile 2>/dev/null )
118
119
ifneq ($(strip $(EXTRA_VERSION)),)
120
HAS_ILLEGAL_EXTRA_VERSION =$(shell                         \
121
    perl -e '$$i="$(EXTRA_VERSION)"; $$i !~ m/^[a-z\.\-\+][a-z\d\.\-\+]*$$/o && print YES;')
122
  ifneq ($(strip $(HAS_ILLEGAL_EXTRA_VERSION)),)
123
    $(error Error: The EXTRAVERSION may only contain lowercase alphanumerics \
124
 and  the  characters  - +  . The current value is: $(EXTRA_VERSION). Aborting.)
125
  endif
126
endif
127
128
######################################################################
129
###          Architecture specific stuff                           ###
130
######################################################################
131
# Each architecture has the following specified for it
132
# (a) The kernel image type (i.e. zImage or bzImage)
133
# (b) The dependency on a loader, if any
134
# (c) The name of the loader
135
# (d) The name of the documentation file for the loader
136
# (e) The build target
137
# (f) The location of the kernelimage source
138
# (g) The location of the kernelimage destination
139
# (h) The name of the arch specific configuration file
140
# Some architectures has sub architectures
141
142
### m68k
143
ifeq ($(strip $(architecture)),m68k)
144
  ifeq (,$(findstring /$(KPKG_SUBARCH)/,/amiga/atari/mac/mvme147/mvme16x/bvme6000/))
145
    GUESS_SUBARCH:=$(shell awk '/Model/ { print $$2}' /proc/hardware)
146
    ifneq (,$(findstring Motorola,$(GUESS_SUBARCH)))
147
     GUESS_SUBARCH:=$(shell awk '/Model/ { print $$3}' /proc/hardware)
148
     ifneq (,$(findstring MVME147,$(GUESS_SUBARCH)))
149
      KPKG_SUBARCH:=mvme147
150
     else
151
      KPKG_SUBARCH:=mvme16x
152
     endif
153
    else
154
     ifneq (,$(findstring BVME,$(GUESS_SUBARCH)))
155
      KPKG_SUBARCH:=bvme6000
156
     else
157
      ifneq (,$(findstring Amiga,$(GUESS_SUBARCH)))
158
       KPKG_SUBARCH:=amiga
159
      else
160
       ifneq (,$(findstring Atari,$(GUESS_SUBARCH)))
161
        KPKG_SUBARCH:=atari
162
       else
163
        ifneq (,$(findstring Mac,$(GUESS_SUBARCH)))
164
         KPKG_SUBARCH:=mac
165
        endif
166
       endif
167
      endif
168
     endif
169
    endif
170
  endif
171
  NEED_DIRECT_GZIP_IMAGE=NO
172
  kimage := zImage
173
  target = $(kimage)
174
  kimagesrc = vmlinux.gz
175
  kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
176
  DEBCONFIG = $(CONFDIR)/config.$(KPKG_SUBARCH)
177
  ifneq (,$(findstring $(KPKG_SUBARCH),mvme147 mvme16x bvme6000))
178
    loaderdep=vmelilo
179
    loader=vmelilo
180
    loaderdoc=VmeliloDefault
181
  else
182
    loaderdep=
183
    loader=lilo
184
    loaderdoc=
185
  endif
186
endif
187
188
### ARM
189
ifeq ($(strip $(architecture)),arm)
190
  GUESS_SUBARCH:='netwinder'
191
192
  ifneq (,$(findstring $(KPKG_SUBARCH),netwinder))
193
    KPKG_SUBARCH:=$(GUESS_SUBARCH)
194
    kimage := zImage
195
    target = Image
196
    kimagesrc = arch/$(KERNEL_ARCH)/boot/Image
197
    kimagedest = $(INT_IMAGE_DESTDIR)/vmlinux-$(version)
198
    loaderdep=
199
    loader=nettrom
200
    loaderdoc=
201
    NEED_DIRECT_GZIP_IMAGE=NO
202
    DEBCONFIG= $(CONFDIR)/config.netwinder
203
  else
204
    kimage := zImage
205
    target = zImage
206
    NEED_DIRECT_GZIP_IMAGE=NO
207
    kimagesrc = arch/$(KERNEL_ARCH)/boot/zImage
208
    kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
209
    DEBCONFIG = $(CONFDIR)/config.arm
210
  endif
211
endif
212
213
### PowerPC
214
ifneq ($(strip $(filter ppc powerpc,$(architecture))),)
215
  ifeq ($(DEB_BUILD_ARCH),powerpc)
216
  # This is only meaningful when building on a PowerPC
217
    ifeq ($(GUESS_SUBARCH),)
218
      GUESS_SUBARCH:=$(shell awk '/machine/ { print $$3}' /proc/cpuinfo)
219
      ifneq (,$(findstring Power,$(GUESS_SUBARCH)))
220
        GUESS_SUBARCH:=pmac
221
      else
222
        ifneq (,$(findstring iMac,$(GUESS_SUBARCH)))
223
          GUESS_SUBARCH:=pmac
224
        endif
225
      endif
226
    else
227
      GUESS_SUBARCH:=pmac
228
    endif
229
  endif
230
231
  ifeq (,$(findstring $(KPKG_SUBARCH),apus prpmc chrp mbx pmac prep Amiga APUs CHRP MBX PReP chrp-rs6k ))
232
    KPKG_SUBARCH:=$(GUESS_SUBARCH)
233
  endif
234
235
  KERNEL_ARCH:=ppc
236
237
  ifneq (,$(findstring $(KPKG_SUBARCH),APUs apus Amiga))
238
    KPKG_SUBARCH:=apus
239
    loader := NoLoader
240
    kimage := vmapus.gz
241
    target = zImage
242
    kimagesrc = $(shell if [ -d arch/$(KERNEL_ARCH)/boot/images ]; then \
243
	echo arch/$(KERNEL_ARCH)/boot/images/vmapus.gz ; else \
244
	echo arch/$(KERNEL_ARCH)/boot/$(kimage) ; fi)
245
    kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
246
    DEBCONFIG = $(CONFDIR)/config.apus
247
  endif
248
249
  ifneq (,$(findstring $(KPKG_SUBARCH),chrp-rs6k))
250
    KPKG_SUBARCH:=chrp-rs6k
251
    loaderdep=quik
252
    loader=quik
253
    loaderdoc=QuikDefault
254
    kimage := zImage
255
    target = $(kimage)
256
    kimagesrc = $(shell if [ -d arch/$(KERNEL_ARCH)/chrpboot ]; then \
257
	echo arch/$(KERNEL_ARCH)/chrpboot/$(kimage) ; else \
258
	echo arch/$(KERNEL_ARCH)/boot/images/$(kimage).chrp-rs6k ; fi)
259
    kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
260
    DEBCONFIG = $(CONFDIR)/config.chrp
261
  endif
262
263
  ifneq (,$(findstring $(KPKG_SUBARCH),CHRP chrp))
264
    KPKG_SUBARCH:=chrp
265
    loaderdep=quik
266
    loader=quik
267
    loaderdoc=QuikDefault
268
    kimage := zImage
269
    target = $(kimage)
270
    kimagesrc = $(shell if [ -d arch/$(KERNEL_ARCH)/chrpboot ]; then \
271
         echo arch/$(KERNEL_ARCH)/chrpboot/$(kimage) ; else \
272
         echo arch/$(KERNEL_ARCH)/boot/images/$(kimage).chrp ; fi)
273
    kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
274
    DEBCONFIG = $(CONFDIR)/config.chrp
275
  endif
276
277
  ifneq (,$(findstring $(KPKG_SUBARCH),PRPMC prpmc))
278
    KPKG_SUBARCH:=prpmc
279
    loader := NoLoader
280
    kimage := zImage
281
    target = $(kimage)
282
    kimagesrc = arch/$(KERNEL_ARCH)/boot/images/zImage.pplus
283
    kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
284
  endif
285
286
  ifneq (,$(findstring $(KPKG_SUBARCH),MBX mbx))
287
    KPKG_SUBARCH:=mbx
288
    loader := NoLoader
289
    kimage := zImage
290
    target = $(kimage)
291
    kimagesrc = $(shell if [ -d arch/$(KERNEL_ARCH)/mbxboot ]; then \
292
	echo arch/$(KERNEL_ARCH)/mbxboot/$(kimage) ; else \
293
	echo arch/$(KERNEL_ARCH)/boot/images/zvmlinux.embedded; fi)
294
    kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
295
    DEBCONFIG = $(CONFDIR)/config.mbx
296
  endif
297
298
  ifneq (,$(findstring $(KPKG_SUBARCH),pmac))
299
    KPKG_SUBARCH:=pmac
300
    target := zImage
301
    ifeq ($(DEB_BUILD_ARCH),powerpc)
302
      # This is only meaningful when building on a PowerPC
303
      ifneq (,$(shell grep NewWorld /proc/cpuinfo))
304
        loaderdep=yaboot
305
        loader=yaboot
306
        #loaderdoc=
307
      else
308
        loaderdep=quik
309
        loader=quik
310
        loaderdoc=QuikDefault
311
      endif
312
    else
313
      loaderdep=yaboot
314
      loader=yaboot
315
    endif
316
    kimagesrc = vmlinux
317
    kimage := vmlinux
318
    kimagedest = $(INT_IMAGE_DESTDIR)/vmlinux-$(version)
319
    HAVE_COFF_IMAGE = YES
320
    coffsrc = $(shell if [ -d arch/$(KERNEL_ARCH)/coffboot ]; then \
321
         echo arch/$(KERNEL_ARCH)/coffboot/$(kimage).coff ; else \
322
         echo arch/$(KERNEL_ARCH)/boot/images/$(kimage).coff ; fi)
323
    coffdest=$(INT_IMAGE_DESTDIR)/vmlinux.coff-$(version)
324
    DEBCONFIG = $(CONFDIR)/config.pmac
325
  endif
326
327
  ifneq (,$(findstring $(KPKG_SUBARCH),PReP prep))
328
    KPKG_SUBARCH:=prep
329
    loader := NoLoader
330
    kimage := zImage
331
    target = $(kimage)
332
    kimagesrc = $(shell if [ -d arch/$(KERNEL_ARCH)/boot/images ]; then \
333
         echo arch/$(KERNEL_ARCH)/boot/images/$(kimage).prep ; else \
334
         echo arch/$(KERNEL_ARCH)/boot/$(kimage) ; fi)
335
    kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
336
    DEBCONFIG = $(CONFDIR)/config.prep
337
  endif
338
339
endif
340
341
342
##### Alpha
343
ifeq ($(strip $(architecture)),alpha)
344
kimage := vmlinuz
345
loaderdep=
346
loader=milo
347
loaderdoc=
348
target = boot
349
kimagesrc = arch/$(KERNEL_ARCH)/boot/vmlinux.gz
350
kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
351
DEBCONFIG = $(CONFDIR)/config.alpha
352
endif
353
354
355
##### Sparc
356
ifeq ($(strip $(architecture)),sparc)
357
  kimage := vmlinuz
358
  loaderdep = silo
359
  loader = silo
360
  loaderdoc=SiloDefault
361
  NEED_DIRECT_GZIP_IMAGE = YES
362
  kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
363
  DEBCONFIG = $(CONFDIR)/config.sparc
364
  ARCH_IN_NAME = YES
365
366
  ifeq (,$(KPKG_SUBARCH))
367
    ifeq (sparc64,$(strip $(shell uname -m)))
368
      KPKG_SUBARCH = sparc64
369
    else
370
      KPKG_SUBARCH = sparc32
371
    endif
372
  endif
373
374
  ifneq (,$(filter sparc64%,$(KPKG_SUBARCH)))
375
     KERNEL_ARCH = sparc64
376
  else
377
     ifneq (,$(filter sparc%,$(KPKG_SUBARCH)))
378
        KERNEL_ARCH = sparc
379
     else
380
        KERNEL_ARCH = $(strip $(shell uname -m))
381
     endif
382
  endif
383
384
  ifneq ($(shell if [ $(VERSION) -ge 2 -a $(PATCHLEVEL) -ge 5 -a  \
385
                    $(SUBLEVEL) -ge 41 ]; then echo new; \
386
             elif [ $(VERSION) -ge 2 -a $(PATCHLEVEL) -ge 6 ]; then \
387
                                         echo new; \
388
             elif [ $(VERSION) -ge 3 ]; then echo new; fi),)
389
    target    = image
390
    kimagesrc = arch/$(KERNEL_ARCH)/boot/image
391
  else
392
    target    = vmlinux
393
    kimagesrc = vmlinux
394
  endif
395
endif
396
397
398
##### i386 and such
399
ifeq ($(strip $(architecture)),i386)
400
  # sub archs can be i386 i486 i586 i686
401
  GUESS_SUBARCH:=$(shell if test -f .config; then \
402
                        perl -nle '/^CONFIG_M(.86)=y/ && print "$$1"' .config;\
403
                       else \
404
                         uname -m;\
405
                       fi)
406
  ifeq (,$(findstring $(KPKG_SUBARCH),i386 i486 i586 i686))
407
    KPKG_SUBARCH:=$(GUESS_SUBARCH)
408
  endif
409
  kimage := bzImage
410
  loaderdep=lilo (>= 19.1) | grub
411
  loader=lilo
412
  loaderdoc=LiloDefault
413
  target = $(kimage)
414
  kimagesrc = $(strip arch/$(KERNEL_ARCH)/boot/$(kimage))
415
  kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
416
  DEBCONFIG= $(CONFDIR)/config.$(KPKG_SUBARCH)
417
  kelfimagesrc = vmlinux
418
  kelfimagedest = $(INT_IMAGE_DESTDIR)/vmlinux-$(version)
419
endif
420
421
##### S/390
422
ifeq ($(strip $(architecture)),s390)
423
  kimage := zimage
424
  loaderdep=zipl
425
  loader=zipl
426
  loaderdoc=
427
  target = image
428
  NEED_DIRECT_GZIP_IMAGE=NO
429
  kimagesrc = $(strip arch/$(KERNEL_ARCH)/boot/$(target))
430
  kimagedest = $(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
431
  DEBCONFIG= $(CONFDIR)/config.$(KPKG_SUBARCH)
432
endif
433
434
##### hppa
435
ifeq ($(strip $(architecture)),hppa)
436
  kimage := vmlinux
437
  loaderdep=palo
438
  loader=palo
439
  loaderdoc=
440
  target=$(kimage)
441
  NEED_DIRECT_GZIP_IMAGE=NO
442
  # Override arch name because hppa uses arch/parisc not arch/hppa
443
  KERNEL_ARCH := parisc
444
  kimagesrc=$(kimage)
445
  kimagedest=$(INT_IMAGE_DESTDIR)/vmlinux-$(version)
446
  # This doesn't seem to work, but the other archs do it...
447
  DEBCONFIG=$(CONFDIR)/config.$(KPKG_SUBARCH)
448
endif
449
450
##### ia64
451
ifeq ($(strip $(architecture)),ia64)
452
  kimage := vmlinuz
453
  loaderdep=elilo
454
  loader=elilo
455
  loaderdoc=
456
  target=compressed
457
  NEED_DIRECT_GZIP_IMAGE=NO
458
  kimagesrc=vmlinux.gz
459
  kimagedest=$(INT_IMAGE_DESTDIR)/vmlinuz-$(version)
460
  DEBCONFIG=$(CONFDIR)/config.$(KPKG_SUBARCH)
461
endif
462
463
##### mips
464
ifeq ($(strip $(architecture)),mips)
465
  kimage := vmlinux
466
  loaderdep=arcboot
467
  loader=arcboot
468
  loaderdoc=
469
  NEED_DIRECT_GZIP_IMAGE=NO
470
  kimagesrc = $(strip vmlinux)
471
  kimagedest = $(INT_IMAGE_DESTDIR)/vmlinux-$(version)
472
  DEBCONFIG= $(CONFDIR)/config.$(KPKG_SUBARCH)
473
474
  ifneq ($(shell if [ $(VERSION) -ge 2 -a $(PATCHLEVEL) -ge 5 -a  \
475
                      $(SUBLEVEL) -ge 41 ]; then echo new; \
476
               elif [ $(VERSION) -ge 2 -a $(PATCHLEVEL) -ge 6 ]; then \
477
                                           echo new; \
478
               elif [ $(VERSION) -ge 3 ]; then echo new; fi),)
479
    target    =
480
  else
481
    target    = boot
482
  endif
483
484
  ifneq (,$(filter mips64%,$(KPKG_SUBARCH)))
485
    KERNEL_ARCH = mips64
486
  endif
487
  ifneq (,$(filter %-64,$(KPKG_SUBARCH)))
488
    KERNEL_ARCH = mips64
489
  endif
490
endif
491
492
##### mipsel
493
ifeq ($(strip $(architecture)),mipsel)
494
  kimage := vmlinux
495
  loaderdep=delo
496
  loader=delo
497
  loaderdoc=
498
  NEED_DIRECT_GZIP_IMAGE=NO
499
  kimagesrc = $(strip vmlinux)
500
  kimagedest = $(INT_IMAGE_DESTDIR)/vmlinux-$(version)
501
  DEBCONFIG= $(CONFDIR)/config.$(KPKG_SUBARCH)
502
  KERNEL_ARCH= mips
503
  #HAVE_COFF_IMAGE = YES
504
  #coffsrc = $(strip arch/$(KERNEL_ARCH)/boot/vmlinux.ecoff)
505
  #coffdest=$(INT_IMAGE_DESTDIR)/vmlinux.ecoff-$(version)
506
507
  ifneq ($(shell if [ $(VERSION) -ge 2 -a $(PATCHLEVEL) -ge 5 -a  \
508
                      $(SUBLEVEL) -ge 41 ]; then echo new; \
509
               elif [ $(VERSION) -ge 2 -a $(PATCHLEVEL) -ge 6 ]; then \
510
                                           echo new; \
511
               elif [ $(VERSION) -ge 3 ]; then echo new; fi),)
512
    target    =
513
  else
514
    target    = boot
515
  endif
516
517
  ifneq (,$(filter mips64el%,$(KPKG_SUBARCH)))
518
    KERNEL_ARCH = mips64
519
  endif
520
  ifneq (,$(filter %-64,$(KPKG_SUBARCH)))
521
    KERNEL_ARCH = mips64
522
  endif
523
endif
524
525
ifeq ($(strip $(architecture)),um)
526
  kimage := linux
527
  target = linux
528
  loaderdep=
529
  loaderdoc=
530
endif
531
######################################################################
532
######################################################################
533
534
ifneq ($(strip $(loaderdep)),)
535
  int_loaderdep := $(loaderdep),
536
else
537
  int_loaderdep :=
538
endif
539
540
541
542
# The following variable is used to simplify the process of making
543
# diffs and orig targets, Please set it if AND ONLY IF no patches
544
# have been applied to the upstream source, in other words, we have
545
# just added debian* files.  If any patches were applied, please
546
# leave it empty
547
548
# NO_SRC_CHANGES =
549
NO_SRC_CHANGES = YES
550
551
552
# NOTE: FLAVOUR is now obsolete
553
# If you want to have more than one kernel configuration per kernel
554
# version, set FLAVOUR in the top level kernel Makefile *before*
555
# invoking make-kpkg -- it will be appended to UTS_RELEASE in
556
# version.h (separated by a hyphen). This affects everything -- the
557
# names and versions of the image, source, headers, and doc packages,
558
# and where the modules are searched for in /lib/modules.
559
560
ifdef FLAVOUR
561
# uhm - should check if we really have a Makefile capable of Flavours?
562
endif
563
564
FLAVOUR:=$(shell grep ^FLAVOUR Makefile 2>/dev/null | \
565
                  perl -ple 's/FLAVOUR[\s:=]+//g')
566
567
ifeq ($(strip $(FLAVOUR_SEP)),)
568
FLAVOUR_SEP:= +
569
endif
570
571
ifneq ($(strip $(FLAVOUR)),)
572
INT_FLAV := $(FLAVOUR_SEP)$(FLAVOUR)
573
FLAV_ARG := FLAVOUR=$(FLAVOUR)
574
else
575
INT_FLAV :=
576
FLAV_ARG :=
577
endif
578
579
## This is the replacement for FLAVOUR
580
EXTRAVERSION =$(strip $(EXTRA_VERSION))
581
ifneq ($(strip $(APPEND_TO_VERSION)),)
582
iatv := $(strip $(APPEND_TO_VERSION))
583
EXTRAV_ARG := EXTRAVERSION=${EXTRA_VERSION}${iatv}
584
else
585
iatv :=
586
EXTRAV_ARG :=
587
endif
588
589
UTS_RELEASE_VERSION=$(shell if [ -f include/linux/version.h ]; then                     \
590
                 grep 'define UTS_RELEASE' include/linux/version.h |                    \
591
                 perl -nle  'm/^\s*\#define\s+UTS_RELEASE\s+("?)(\S+)\1/g && print $$2;';\
592
                 else echo "" ;                                                         \
593
                 fi)
594
 
595
version = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(iatv)$(INT_FLAV)
596
597
# KPKG_SUBARCH is used to distinguish Amiga, Atari, Macintosh, etc. kernels
598
# for Debian/m68k.  INT_SUBARCH is used in the names of the image file
599
# produced. It only affects the naming of the kernel-image as the
600
# source and doc packages are architecture independent and the
601
# kernel-headers do not vary from one sub-architecture to the next.
602
603
# This is the default
604
INT_SUBARCH :=
605
606
ifneq ($(strip $(ARCH_IN_NAME)),)
607
ifneq ($(strip $(KPKG_SUBARCH)),)
608
INT_SUBARCH := -$(KPKG_SUBARCH)
609
endif
610
endif
611
612
613
614
# The name of the package (for example, `emacs').
615
package   := kernel-source-$(version)
616
h_package := kernel-headers-$(version)
617
i_package := kernel-image-$(version)$(INT_SUBARCH)
618
d_package := kernel-doc-$(version)
619
l_package := libc-kheaders
620
621
SOURCE_TOP:= debian/tmp-source
622
HEADER_TOP:= debian/tmp-headers
623
IMAGE_TOP := debian/tmp-image
624
DOC_TOP   := debian/tmp-doc
625
626
SOURCE_DOC:= $(SOURCE_TOP)/usr/share/doc/$(package)
627
HEADER_DOC:= $(HEADER_TOP)/usr/share/doc/$(h_package)
628
IMAGE_DOC := $(IMAGE_TOP)/usr/share/doc/$(i_package)
629
DOC_DOC   := $(DOC_TOP)/usr/share/doc/$(d_package)
630
631
SOURCE_SRC:= $(SOURCE_TOP)/usr/src/$(package)
632
HEADER_SRC:= $(HEADER_TOP)/usr/src/$(h_package)
633
634
635
636
FILES_TO_CLEAN  = modules/modversions.h modules/ksyms.ver debian/files \
637
                  conf.vars scripts/cramfs/cramfsck scripts/cramfs/mkcramfs \
638
                  applied_patches debian/buildinfo
639
STAMPS_TO_CLEAN = stamp-build stamp-configure stamp-source stamp-image \
640
                  stamp-headers stamp-src stamp-diff stamp-doc \
641
                  stamp-buildpackage stamp-libc-kheaders stamp-debian \
642
                  stamp-patch stamp-kernel-configure
643
DIRS_TO_CLEAN   = $(SOURCE_TOP) $(HEADER_TOP) $(IMAGE_TOP) $(DOC_TOP)
644
645
CONFLOC    :=$(shell if test -f ~/.kernel-pkg.conf; then\
646
                        echo ~/.kernel-pkg.conf; \
647
                     else \
648
                        echo /etc/kernel-pkg.conf; \
649
                     fi)
650
LIBLOC     :=/usr/share/kernel-package
651
652
ifeq ($(strip $(MODULE_LOC)),)
653
MODULE_LOC =/usr/src/modules
654
endif
655
656
DEBDIR      = $(LIBLOC)
657
DEBDIR_NAME = $(shell basename $(DEBDIR))
658
659
ifeq ($(strip $(VERSIONED_PATCH_DIR)),)
660
VERSIONED_PATCH_DIR         = $(shell if [ -d \
661
/usr/src/kernel-patches/$(architecture)/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL) \
662
			       ]; then echo \
663
/usr/src/kernel-patches/$(architecture)/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL); \
664
			    fi)
665
endif
666
667
ifeq ($(strip $(VERSIONED_ALL_PATCH_DIR)),)
668
VERSIONED_ALL_PATCH_DIR         = $(shell if [ -d \
669
/usr/src/kernel-patches/all/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL) \
670
			       ]; then echo \
671
/usr/src/kernel-patches/all/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL); \
672
			    fi)
673
endif
674
675
ifeq ($(strip $(PATCH_DIR)),)
676
PATCH_DIR  = $(shell if [ -d /usr/src/kernel-patches/$(architecture)/ ];\
677
                        then echo /usr/src/kernel-patches/$(architecture); \
678
	             fi)
679
endif
680
681
ifeq ($(strip $(ALL_PATCH_DIR)),)
682
ALL_PATCH_DIR  = $(shell if [ -d /usr/src/kernel-patches/all/ ]; \
683
                            then echo /usr/src/kernel-patches/all/ ;\
684
			 fi)
685
endif
686
687
VERSIONED_ALL_PATCH_APPLY   = $(VERSIONED_ALL_PATCH_DIR)/apply
688
VERSIONED_ALL_PATCH_UNPATCH = $(VERSIONED_ALL_PATCH_DIR)/unpatch
689
690
VERSIONED_DIR_PATCH_APPLY   = $(VERSIONED_PATCH_DIR)/apply
691
VERSIONED_DIR_PATCH_UNPATCH = $(VERSIONED_PATCH_DIR)/unpatch
692
693
ALL_PATCH_APPLY   = $(ALL_PATCH_DIR)/apply
694
ALL_PATCH_UNPATCH = $(ALL_PATCH_DIR)/unpatch
695
696
DIR_PATCH_APPLY   = $(PATCH_DIR)/apply
697
DIR_PATCH_UNPATCH = $(PATCH_DIR)/unpatch
698
699
# The destination of all .deb files
700
# (suggested by Rob Browning <osiris@cs.utexas.edu>)
701
DEB_DEST := ..
702
SRCTOP := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
703
INSTALL_MOD_PATH=$(SRCTOP)/$(IMAGE_TOP)
704
KPKG_DEST_DIR ?= $(SRCTOP)/..
705
706
install_file=    install -p    -o root -g root -m 644
707
install_program= install -p    -o root -g root -m 755
708
make_directory=  install -p -d -o root -g root -m 755
709
deb_rule = $(MAKE) -f $(DEBDIR)/rules
710
711
# Include any site specific overrides here.
712
-include $(CONFLOC)
713
714
# Over ride the config file from the environment/command line
715
ifneq ($(strip $(KPKG_MAINTAINER)),)
716
maintainer=$(KPKG_MAINTAINER)
717
endif
718
719
ifneq ($(strip $(KPKG_EMAIL)),)
720
email=$(KPKG_EMAIL)
721
endif
722
723
# This should be a  name to feed the modules build for pgp signature,
724
# since we the maintainer would be different there.
725
ifneq ($(strip $(PGP_SIGNATURE)),)
726
pgp=$(PGP_SIGNATURE)
727
endif
728
729
ifneq ($(strip $(EXTRA_DOCS)),)
730
extra_docs = $(EXTRA_DOCS)
731
endif
732
733
ifneq ($(strip $(extra_docs)),)
734
HAVE_EXTRA_DOCS:=$(shell if [ -e $(extra_docs) ]; then echo YES; fi)
735
endif
736
737
ifneq ($(strip $(DEBIAN_REVISION_MANDATORY)),)
738
debian_revision_mandatory:=$(DEBIAN_REVISION_MANDATORY)
739
endif
740
 
741
742
ifneq ($(strip $(install_vmlinux)),)
743
int_install_vmlinux:=$(install_vmlinux)
744
endif
745
 
746
ifneq ($(strip $(KPKG_FOLLOW_SYMLINKS_IN_SRC)),)
747
int_follow_symlinks_in_src=YES
748
else
749
ifneq ($(strip $(kpkg_follow_symlinks_in_src)),)
750
int_follow_symlinks_in_src=YES
751
endif
752
endif
753
754
755
756
757
758
# The Debian revision
759
ifneq ($(strip $(DEBIAN_REVISION)),)
760
HAS_CHANGELOG := $(shell \
761
    if test -f debian/changelog -a \( -f stamp-debian -o -f debian/official \);\
762
    then echo YES;\
763
    else echo NO; fi; )
764
else
765
HAS_CHANGELOG := $(shell if test -f debian/changelog; then echo YES;\
766
                          else echo NO; fi; )
767
endif
768
# If there is a changelog file, it overrides. The only exception is
769
# when there is no stamp-config, and there is no debian/official,
770
# *AND* there is a DEBIAN_REVISION, in which case the DEBIAN_REVISION
771
# over rides (since we are going to replace the changelog file soon
772
# anyway.  Else, use the commandline or env var setting. Or else
773
# default to 10.00.Custom, unless the human has requested that the
774
# revision is mandatory, in which case we raise an error
775
776
ifeq ($(strip $(HAS_CHANGELOG)),YES)
777
debian := $(shell if test -f debian/changelog; then \
778
                     perl -nle 'print /\((\S+)\)/; exit 0' debian/changelog;\
779
                  fi; )
780
else
781
ifneq ($(strip $(DEBIAN_REVISION)),)
782
debian := $(DEBIAN_REVISION)
783
else
784
ifeq ($(strip $(debian)),)
785
ifneq ($(strip $(debian_revision_mandatory)),)
786
$(error A Debian revision is mandatory, but none was provided)
787
else
788
debian := 10.00.Custom
789
endif
790
endif
791
endif
792
endif
793
794
AM_OFFICIAL := $(shell if [ -f debian/official ]; then echo YES; fi )
795
796
# Hmm. The version that we have computed *MUST* match the one that is in the
797
# changelog.
798
ifeq ($(strip $(HAS_CHANGELOG)),YES)
799
saved_version := $(shell if test -f debian/changelog; then \
800
                     perl -nle 'print /^kernel-source-(\S+)/; exit 0' \
801
                          debian/changelog;\
802
                  fi; )
803
ifneq ($(strip $(saved_version)),)
804
ifneq ($(strip $(saved_version)),$(strip $(version)))
805
HAVE_VERSION_MISMATCH=YES
806
endif
807
endif
808
endif
809
810
811
ifneq ($(strip $(DELETE_BUILD_LINK)),)
812
delete_build_link := YES
813
else
814
ifeq ($(strip $(delete_build_link)),)
815
delete_build_link := $(shell if test -f debian/official; then echo YES;\
816
                          else echo NO; fi; )
817
endif
818
endif
819
820
ifneq ($(strip $(IMAGE_IN_BOOT)),)
821
link_in_boot := $(IMAGE_IN_BOOT)
822
endif
823
824
ifneq ($(strip $(LINK_IN_BOOT)),)
825
link_in_boot := $(LINK_IN_BOOT)
826
endif
827
828
ifneq ($(strip $(NO_SYMLINK)),)
829
no_symlink := $(NO_SYMLINK)
830
endif
831
832
ifneq ($(strip $(REVERSE_SYMLINK)),)
833
reverse_symlink := $(REVERSE_SYMLINK)
834
endif
835
836
ifneq ($(strip $(IMAGE_TYPE)),)
837
kimage = $(IMAGE_TYPE)
838
endif
839
840
ifneq ($(strip $(PATCH_THE_KERNEL)),)
841
patch_the_kernel = $(PATCH_THE_KERNEL)
842
endif
843
844
ifneq ($(strip $(KPKG_SELECTED_PATCHES)),)
845
ifeq ($(strip $(patch_the_kernel)),NO)
846
patch_the_kernel = NO
847
else
848
ifeq ($(strip $(patch_the_kernel)),no)
849
patch_the_kernel = NO
850
else
851
patch_the_kernel = YES
852
endif
853
endif
854
endif
855
856
857
ifeq ($(strip $(patch_the_kernel)),yes)
858
patch_the_kernel = YES
859
endif
860
ifeq ($(strip $(patch_the_kernel)),Yes)
861
patch_the_kernel = YES
862
endif
863
ifeq ($(strip $(patch_the_kernel)),YEs)
864
patch_the_kernel = YES
865
endif
866
ifeq ($(strip $(patch_the_kernel)),yEs)
867
patch_the_kernel = YES
868
endif
869
ifeq ($(strip $(patch_the_kernel)),yES)
870
patch_the_kernel = YES
871
endif
872
ifeq ($(strip $(patch_the_kernel)),yeS)
873
patch_the_kernel = YES
874
endif
875
876
877
878
ifneq ($(strip $(CONFIG_TARGET)),)
879
config_target := $(CONFIG_TARGET)
880
have_new_config_target := YES
881
endif
882
883
# If config_target doesn't end in `config' then reset it to `oldconfig'.
884
ifneq ($(patsubst %config,config,$(strip $(config_target))),config)
885
config_target := oldconfig
886
have_new_config_target :=
887
endif
888
889
ifneq ($(strip $(USE_SAVED_CONFIG)),)
890
use_saved_config = $(USE_SAVED_CONFIG)
891
endif
892
893
#ifeq ($(origin var),command line)
894
#$(warn You are setting an internal var from the cmdline. Use at your own risk)
895
#endif
896
#you can automated it a bit more with $(foreach) and $(if)
897
898
###ROOT_COMMAND
899
ifneq ($(strip $(ROOT_CMD)),)
900
int_root_cmd := -r$(strip $(ROOT_CMD))
901
else
902
# well, ROOT_CMD is not set yet
903
ifneq ($(strip $(root_cmd)),)
904
905
# Try and set ROOT_CMD from root_cmd
906
int_dummy_root := $(root_cmd)
907
ifneq ($(strip $(findstring -us, $(int_dummy_root))),)
908
int_dummy_root := $(subst -us,, $(strip $(int_dummy_root)))
909
endif
910
ifneq ($(strip $(findstring -uc, $(int_dummy_root))),)
911
int_dummy_root := $(subst -uc,, $(strip $(int_dummy_root)))
912
endif
913
914
915
ifneq ($(strip $(findstring -r, $(int_dummy_root))),)
916
ROOT_CMD := $(patsubst -r%, %, $(filter -r%, $(strip $(int_dummy_root))))
917
else
918
ROOT_CMD     := $(strip $(root_cmd))
919
endif
920
921
922
ifeq ($(strip $(findstring -r, $(root_cmd))),)
923
int_root_cmd := -r$(strip $(root_cmd))
924
else
925
int_root_cmd := $(root_cmd)
926
endif
927
endif
928
endif
929
930
ifneq ($(strip $(UNSIGN_SOURCE)),)
931
int_root_cmd := $(int_root_cmd) -us
932
endif
933
934
ifneq ($(strip $(UNSIGN_CHANGELOG)),)
935
int_root_cmd := $(int_root_cmd) -uc
936
endif
937
938
# make sure that root_cmd and int_root_cmd are the same
939
ifneq ($(strip $(int_root_cmd)),)
940
root_cmd := $(int_root_cmd)
941
endif
942
943
int_am_root  := $(shell [ $$(id -u) -eq 0 ] && echo "YES" )
944
int_get_root := $(shell [ $$(id -u) -ne 0 ] && echo "$(ROOT_CMD)" )
945
946
947
ifneq ($(strip $(CLEAN_SOURCE)),)
948
do_clean = $(CLEAN_SOURCE)
949
endif
950
951
ifneq ($(strip $(CONCURRENCY_LEVEL)),)
952
do_parallel = -j$(CONCURRENCY_LEVEL)
953
954
# Well, I wish there was something better than guessing by version number
955
CAN_DO_DEP_FAST=$(shell if   [ $(VERSION) -lt 2 ];    then echo '';  \
956
                        elif [ $(VERSION) -gt 2 ];    then echo YES; \
957
                        elif [ $(PATCHLEVEL) -lt 4 ]; then echo '';  \
958
                        else                             echo YES; \
959
                        fi)
960
ifneq ($(strip $(CAN_DO_DEP_FAST)),)
961
fast_dep= -j$(CONCURRENCY_LEVEL)
962
endif
963
964
endif
965
966
ifneq ($(strip $(SOURCE_CLEAN_HOOK)),)
967
source_clean_hook=$(SOURCE_CLEAN_HOOK)
968
endif
969
ifneq ($(strip $(HEADER_CLEAN_HOOK)),)
970
header_clean_hook=$(HEADER_CLEAN_HOOK)
971
endif
972
ifneq ($(strip $(DOC_CLEAN_HOOK)),)
973
doc_clean_hook=$(DOC_CLEAN_HOOK)
974
endif
975
976
ifneq ($(strip $(INITRD)),)
977
initrddep := initrd-tools (>= 0.1.48), # there is a space here
978
else
979
initrddep :=
980
endif
981
982
ifeq ($(strip $(CONFDIR)),)
983
ifeq ($(strip $(patch_the_kernel)),YES)
984
CONFDIR     = $(PATCH_DIR)
985
else
986
ifeq ($(strip $(patch_the_kernel)),yes)
987
CONFDIR     = $(PATCH_DIR)
988
else
989
CONFDIR     = $(DEBDIR)/Config
990
endif
991
endif
992
endif
993
994
# The file which has local configuration
995
CONFIG_FILE := $(shell if test -e .config ; then \
996
                           echo .config; \
997
                       elif test -e $(DEBCONFIG) ; then \
998
                           echo $(DEBCONFIG); \
999
                       elif test -e $(CONFDIR)/config ; then \
1000
                           echo $(CONFDIR)/config ; \
1001
                       elif test -e $(DEBDIR)/config ; then \
1002
                           echo $(DEBDIR)/config ; \
1003
                       elif test -e /boot/config-$(version) ; then \
1004
                           echo /boot/config-$(version) ; \
1005
                       elif test -e /boot/config-$$(uname -r) ; then \
1006
                           echo /boot/config-$$(uname -r) ; \
1007
                       else echo /dev/null ; \
1008
                       fi)
1009
1010
1011
# See if we are being run in the kernel directory
1012
IN_KERNEL_DIR := $(shell if test -d drivers -a -d kernel -a -d fs -a                \
1013
                                 -d include/linux ; then                            \
1014
                            echo YES;                                               \
1015
                         fi )
1016
1017
IN_KERNEL_HEADERS=$(shell if [ -f kernel-headers.revision ]; then                    \
1018
                               cat kernel-headers.revision;                          \
1019
                            else echo "" ;                                          \
1020
                            fi)
1021
1022
ifeq ($(strip $(IN_KERNEL_DIR)),)
1023
ifneq ($(strip $(IN_KERNEL_HEADERS)),)
1024
version=$(UTS_RELEASE_VERSION)
1025
debian=$(IN_KERNEL_HEADERS)
1026
endif
1027
endif
1028
1029
1030
# Deal with modules issues
1031
1032
# define MODULES_ENABLED if appropriate
1033
ifneq ($(strip $(shell egrep ^[^\#]*CONFIG_MODULES $(CONFIG_FILE))),)
1034
MODULES_ENABLED := YES
1035
endif
1036
1037
# accept both space separated list of modules, as well as comma
1038
# separated ones
1039
comma:= ,
1040
empty:=
1041
space:= $(empty) $(empty)
1042
valid_modules:=
1043
1044
# See what modules we are talking about
1045
ifeq ($(strip $(MODULES_ENABLED)),YES)
1046
ifneq ($(strip $(KPKG_SELECTED_MODULES)),)
1047
canonical_modules=$(subst $(comma),$(space),$(KPKG_SELECTED_MODULES))
1048
else
1049
canonical_modules=$(shell test -e $(MODULE_LOC) && \
1050
                       find $(MODULE_LOC) -follow -maxdepth 1 -type d -print |\
1051
			   egrep -v '^$(MODULE_LOC)/$$')
1052
endif
1053
1054
1055
# Now, if we have any modules at all, they are in canonical_modules
1056
ifneq ($(strip $(canonical_modules)),)
1057
1058
# modules can have the full path, or just the name of the module. We
1059
# make all the modules ahve absolute paths by fleshing them out.
1060
path_modules   :=$(filter     /%, $(canonical_modules))
1061
no_path_modules:=$(filter-out /%, $(canonical_modules))
1062
fleshed_out    :=$(foreach mod,$(no_path_modules),$(MODULE_LOC)/$(mod))
1063
1064
# Hmmph. recreate the canonical modules; now everything has a full
1065
# path name.
1066
1067
canonical_modules:=$(path_modules) $(fleshed_out)
1068
# test to see if the dir names are real
1069
valid_modules = $(shell for dir in $(canonical_modules); do \
1070
                            if [ -d $$dir ] && [ -x $$dir/debian/rules ]; then \
1071
                               echo $$dir;                  \
1072
                            fi;                             \
1073
                        done)
1074
1075
1076
endif
1077
endif
1078
1079
ifeq ($(strip $(patch_the_kernel)),YES)
1080
1081
# Well then. Let us see if we want to select the patches we apply.
1082
ifneq ($(strip $(KPKG_SELECTED_PATCHES)),)
1083
canonical_patches=$(subst $(comma),$(space),$(KPKG_SELECTED_PATCHES))
1084
1085
ifneq ($(strip $(canonical_patches)),)
1086
# test to see if the patches exist
1087
temp_valid_patches = $(shell for name in $(canonical_patches); do             \
1088
                            if [ -x $(VERSIONED_DIR_PATCH_APPLY)/$$name -a    \
1089
                                 -x $(VERSIONED_DIR_PATCH_UNPATCH)/$$name ];  \
1090
                               then echo $(VERSIONED_DIR_PATCH_APPLY)/$$name; \
1091
                            elif [ -x $(VERSIONED_ALL_PATCH_APPLY)/$$name -a  \
1092
                                   -x $(VERSIONED_ALL_PATCH_UNPATCH)/$$name ];\
1093
                               then echo $(VERSIONED_ALL_PATCH_APPLY)/$$name; \
1094
                            elif [ -x $(DIR_PATCH_APPLY)/$$name -a            \
1095
                                 -x $(DIR_PATCH_UNPATCH)/$$name ]; then       \
1096
                               echo $(DIR_PATCH_APPLY)/$$name;                \
1097
                            elif [ -x $(ALL_PATCH_APPLY)/$$name -a            \
1098
                                    -x $(ALL_PATCH_UNPATCH)/$$name ]; then    \
1099
                               echo $(ALL_PATCH_APPLY)/$$name;                \
1100
                            else                                              \
1101
                               echo $$name.error;                             \
1102
                            fi;                                               \
1103
                        done)
1104
1105
temp_patch_not_found = $(filter %.error, $(temp_valid_patches))
1106
patch_not_found = $(subst .error,,$(temp_patch_not_found))
1107
ifneq ($(strip $(patch_not_found)),)
1108
$(error Could not find patch for $(patch_not_found))
1109
endif
1110
1111
valid_patches = $(filter-out %.error, $(temp_valid_patches))
1112
1113
ifeq ($(strip $(valid_patches)),)
1114
$(error Could not find patch scripts for $(canonical_patches))
1115
endif
1116
1117
1118
1119
canonical_unpatches = $(shell new="";                                         \
1120
                              for name in $(canonical_patches); do            \
1121
                                  new="$$name $$new";                         \
1122
                              done;                                           \
1123
                              echo $$new;)
1124
1125
temp_valid_unpatches = $(shell for name in $(canonical_unpatches); do         \
1126
                            if [ -x $(VERSIONED_DIR_PATCH_APPLY)/$$name -a    \
1127
                                 -x $(VERSIONED_DIR_PATCH_UNPATCH)/$$name ];  \
1128
                              then echo $(VERSIONED_DIR_PATCH_UNPATCH)/$$name;\
1129
                            elif [ -x $(VERSIONED_ALL_PATCH_APPLY)/$$name -a  \
1130
                                   -x $(VERSIONED_ALL_PATCH_UNPATCH)/$$name ];\
1131
                              then echo $(VERSIONED_ALL_PATCH_UNPATCH)/$$name;\
1132
                            elif [ -x $(DIR_PATCH_APPLY)/$$name -a            \
1133
                                 -x $(DIR_PATCH_UNPATCH)/$$name ]; then       \
1134
                               echo $(DIR_PATCH_UNPATCH)/$$name;              \
1135
                            elif [ -x $(ALL_PATCH_APPLY)/$$name -a            \
1136
                                    -x $(ALL_PATCH_UNPATCH)/$$name ]; then    \
1137
                               echo $(ALL_PATCH_UNPATCH)/$$name;              \
1138
                            else                                              \
1139
                               echo $$name.error;                             \
1140
                            fi;                                               \
1141
                        done)
1142
temp_unpatch_not_found = $(filter %.error, $(temp_valid_unpatches))
1143
unpatch_not_found = $(subst .error,,$(temp_unpatch_not_found))
1144
ifneq ($(strip $(unpatch_not_found)),)
1145
$(error Could not find unpatch for $(unpatch_not_found))
1146
endif
1147
1148
valid_unpatches = $(filter-out %.error, $(temp_valid_unpatches))
1149
1150
ifeq ($(strip $(valid_unpatches)),)
1151
$(error Could not find un-patch scripts for $(canonical_unpatches))
1152
endif
1153
1154
1155
endif
1156
endif
1157
endif
1158
1159
old_applied_patches=$(shell if [ -f applied_patches ]; then                   \
1160
                               cat applied_patches;                           \
1161
                            else                                              \
1162
                               echo '';                                       \
1163
                            fi )
1164
1165
ifeq ($(strip $(valid_unpatches)),)
1166
ifneq ($(strip $(old_applied_patches)),) 
1167
old_unpatches=$(shell new="";                                          \
1168
                      for name in $(notdir $(old_applied_patches)); do \
1169
                          new="$$name $$new";                          \
1170
                      done;                                            \
1171
                      echo $$new;)
1172
temp_old_unpatches = $(shell for name in $(old_unpatches); do         \
1173
                            if [ -x $(VERSIONED_DIR_PATCH_UNPATCH)/$$name ];  \
1174
                              then echo $(VERSIONED_DIR_PATCH_UNPATCH)/$$name;\
1175
                            elif [ -x $(VERSIONED_ALL_PATCH_UNPATCH)/$$name ];\
1176
                              then echo $(VERSIONED_ALL_PATCH_UNPATCH)/$$name;\
1177
                            elif [ -x $(DIR_PATCH_UNPATCH)/$$name ]; then     \
1178
                               echo $(DIR_PATCH_UNPATCH)/$$name;              \
1179
                            elif [ -x $(ALL_PATCH_UNPATCH)/$$name ]; then     \
1180
                               echo $(ALL_PATCH_UNPATCH)/$$name;              \
1181
                            else                                              \
1182
                               echo $$name.error;                             \
1183
                            fi;                                               \
1184
                        done)
1185
temp_old_unpatch_not_found = $(filter %.error, $(temp_old_unpatches))
1186
old_unpatch_not_found = $(subst .error,,$(temp_unpatch_not_found))
1187
valid_unpatches = $(filter-out %.error, $(temp_old_unpatches))
1188
endif
1189
endif
1190
1191
# See if the version numbers are valid
1192
HAVE_VALID_PACKAGE_VERSION := $(shell \
1193
      if test -x $(DEBDIR)/kpkg-vercheck; then \
1194
	$(DEBDIR)/kpkg-vercheck $(debian) ; \
1195
      else \
1196
        echo "Could not find $(DEBDIR)/kpkg-vercheck" ; \
1197
      fi )
1198
1199
TAR_COMPRESSION := $(shell \
1200
      if tar --help | grep -- \-\-bzip2 >/dev/null; then  \
1201
         echo --bzip2; \
1202
      else \
1203
         echo --gzip; \
1204
      fi )
1205
TAR_SUFFIX := $(shell \
1206
      if tar --help | grep -- \-\-bzip2 >/dev/null; then  \
1207
         echo bz2; \
1208
      else \
1209
         echo gz; \
1210
      fi )
1211
1212
STOP_FOR_BIN86 = NO
1213
CONTROL=$(DEBDIR)/Control
1214
ifeq ($(strip $(architecture)),i386)
1215
NEED_BIN86 := $(shell if dpkg --compare-versions \
1216
                  $(VERSION).$(PATCHLEVEL) lt 2.4 >/dev/null 2>&1; \
1217
                  then echo YES; fi)
1218
ifeq ($(strip $(NEED_BIN86)),YES)
1219
CONTROL=$(DEBDIR)/Control.bin86
1220
HAVE_BIN86 := $(shell if test -x /usr/bin/as86; then echo YES; \
1221
                      else echo NO; fi )
1222
ifeq ($(strip $(HAVE_BIN86)),NO)
1223
STOP_FOR_BIN86 = YES
1224
endif
1225
endif
1226
endif
1227
1228
# Bug out if the version number id not all lowercase
1229
lc_version = $(shell echo $(version) | tr A-Z a-z)
1230
ifneq ($(strip $(version)),$(strip $(lc_version)))
1231
$(error Error. The version number $(strip $(version)) is not all \
1232
 lowercase. Since the version ends up in the package name of the \
1233
 kernel image package, this is a Debian policy violation, and \
1234
 the packaging system shall refuse to package the image. )
1235
endif
1236
1237
ifeq (,$(strip $(kimagedest)))
1238
$(error Error. I do not know where the kernel image goes to [kimagedest undefined]\
1239
 The usual case for this is that I could not determine which arch or subarch \
1240
 tihs machine belongs to. Please specify a subarch, and try again.)
1241
endif
1242
ifeq (,$(strip $(kimagesrc)))
1243
$(error Error. I do not know where the kernel image goes to [kimagesrc undefined]\
1244
 The usual case for this is that I could not determine which arch or subarch \
1245
 tihs machine belongs to. Please specify a subarch, and try again.)
1246
endif
1247
1248
# export variables
1249
export root_cmd FLAVOUR INT_SUBARCH APPEND_TO_VERSION UNSIGN_CHANGELOG  \
1250
       UNSIGN_SOURCE ROOT_CMD MODULE_LOC EXTRAVERSION ALL_PATCH_DIR     \
1251
       ALL_PATCH_APPLY ALL_PATCH_UNPATCH DIR_PATCH_UNPATCH              \
1252
       DIR_PATCH_APPLY VERSIONED_PATCH_DIR VERSIONED_ALL_PATCH_UNPATCH  \
1253
       VERSIONED_ALL_PATCH_APPLY VERSIONED_DIR_PATCH_UNPATCH            \
1254
       VERSIONED_DIR_PATCH_APPLY KPKG_SELECTED_PATCHES                  \
1255
       KPKG_SELECTED_MODULES CONCURRENCY_LEVEL
1256
1257
1258
ifeq ($(strip $(IN_KERNEL_DIR)),)
1259
# Hah! Not in kernel directory!!
1260
build configure clean binary kernel_source kernel-source kernel-headers\
1261
stamp-source kernel_headers stamp-headers kernel_image stamp-image \
1262
kernel-image kernel-doc kernel_doc stamp-doc buildpackage \
1263
libc_kheaders libc-kheaders stamp-libc-kheaders kernel-image-deb debian:
1264
	@echo "You should invoke this command from the top level directory of"
1265
	@echo "a linux kernel source directory tree, and as far as I can tell,"
1266
	@echo "the current directory:"
1267
	@echo "	$(SRCTOP)"
1268
	@echo "is not a top level linux kernel source directory. "
1269
	@echo ""
1270
	@echo "	(If I am wrong then kernel-packages and the linux kernel"
1271
	@echo "	 are so out sync that you'd better get the latest versions"
1272
	@echo "	 of the kernel-package package and the Linux sources)"
1273
	@echo ""
1274
	@echo "Please change directory to wherever linux kernel sources"
1275
	@echo "reside and try again."
1276
else
1277
ifneq ($(strip $(HAVE_VALID_PACKAGE_VERSION)),YES)
1278
# Hah! Bogus version number
1279
build configure clean binary kernel_source kernel-source kernel-headers\
1280
stamp-source kernel_headers stamp-headers kernel_image stamp-image \
1281
kernel-image kernel-doc kernel_doc stamp-doc buildpackage kernel-image-deb \
1282
debian:
1283
	@echo "Problems ecountered with the version number $(debian)."
1284
	@echo "$(HAVE_VALID_PACKAGE_VERSION)"
1285
	@echo ""
1286
	@echo "Please re-read the README file and try again."
1287
else
1288
ifeq ($(strip $(STOP_FOR__BIN86)),YES)
1289
# Hah! we need bin 86, but it aint here
1290
build configure clean binary kernel_source kernel-source kernel-headers\
1291
stamp-source kernel_headers stamp-headers kernel_image stamp-image \
1292
kernel-image kernel-doc kernel_doc stamp-doc buildpackage kernel-image-deb \
1293
debian:
1294
	@echo "You Need to install the package bin86 before you can "
1295
	@echo "compile the kernel on this machine"
1296
	@echo ""
1297
	@echo "Please install bin86 and try again."
1298
else
1299
all build: debian configure stamp-build
1300
stamp-build:
1301
# Builds the binary package.
1302
# debian.config contains the current idea of what the image should
1303
# have.
1304
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
1305
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
1306
endif
1307
ifneq ($(strip $(UTS_RELEASE_VERSION)), $(strip $(version)))
1308
	@echo "The UTS Release version in include/linux/version.h" 
1309
	@echo "     \"$(strip $(UTS_RELEASE_VERSION))\" "
1310
	@echo "does not match current version " 
1311
	@echo "     \"$(strip $(version))\" "
1312
	@echo "Reconfiguring." 
1313
	touch Makefile
1314
endif
1315
	-test -f stamp-configure || $(deb_rule) configure
1316
	$(MAKE) $(do_parallel) $(EXTRAV_ARG) $(FLAV_ARG) ARCH=$(KERNEL_ARCH) \
1317
	                    $(CROSS_ARG) $(target)
1318
ifneq ($(strip $(shell egrep ^[^\#]*CONFIG_MODULES $(CONFIG_FILE))),)
1319
	$(MAKE) $(do_parallel) $(EXTRAV_ARG) $(FLAV_ARG) ARCH=$(KERNEL_ARCH) \
1320
	                    $(CROSS_ARG) modules
1321
endif
1322
	COLUMNS=150 dpkg -l 'gcc*' perl dpkg 'libc6*' binutils ldso make dpkg-dev |\
1323
         awk '$$1 == "ii" { printf("%s-%s\n", $$2, $$3) }'   > debian/buildinfo
1324
	@echo this was built on a machine with the kernel: >> debian/buildinfo
1325
	uname -a >> debian/buildinfo
1326
	echo using the compiler: >> debian/buildinfo
1327
	grep LINUX_COMPILER include/linux/compile.h | \
1328
           sed -e 's/.*LINUX_COMPILER "//' -e 's/"$$//' >> debian/buildinfo
1329
	echo done >  $@
1330
1331
buildpackage: clean stamp-buildpackage
1332
stamp-buildpackage: configure
1333
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
1334
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
1335
endif
1336
	test -f stamp-configure || $(deb_rule) configure
1337
	echo 'Building Package' > stamp-building
1338
ifneq ($(strip $(root_cmd)),)
1339
	dpkg-buildpackage -nc $(strip $(root_cmd)) -m"$(maintainer) <$(email)>" -k"$(pgp)"
1340
else
1341
	dpkg-buildpackage -nc -m"$(maintainer) <$(email)>" -k"$(pgp)"
1342
endif
1343
	rm -f stamp-building
1344
	echo done >  $@
1345
1346
# stamp-debian and stamp-configure used to be a single target. Now
1347
# they are split - the reason is that arch-indep packages need to be
1348
# built before arch-dep packages, and make-kpkg tries to do 'make
1349
# config' for both cases.  This used to work because the .config file
1350
# resided with kernel-source, but now that it is in kernel-patch, it
1351
# breaks down.  I think the cleanest way out of this is to only deal
1352
# with config files when necessary, and thus the split. Herbert Xu
1353
debian: stamp-debian
1354
stamp-debian:
1355
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
1356
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
1357
endif
1358
	@test -f $(DEBDIR)/rules || \
1359
            echo Error: Could not find $(DEBDIR)/rules
1360
	-test ! -f stamp-debian && test ! -f debian/official && \
1361
	      rm -rf ./debian && mkdir ./debian
1362
ifeq ($(strip $(patch_the_kernel)),YES)
1363
	-test -f applied_patches && rm -f applied_patches
1364
ifneq ($(strip $(valid_patches)),)
1365
	-for patch in $(valid_patches) ; do            \
1366
          if test -x  $$patch; then                    \
1367
              if $$patch; then                         \
1368
                  echo "Patch $$patch processed fine"; \
1369
		  echo "$(notdir $$patch)" >> applied_patches;   \
1370
              else                                     \
1371
                   echo "Patch $(notdir $$patch)  failed.";      \
1372
                   echo "Hit return to Continue";      \
1373
		   read ans;                           \
1374
              fi;                                      \
1375
	  fi;                                          \
1376
        done
1377
	echo done >  stamp-patch
1378
else
1379
	if [ -n "$(VERSIONED_PATCH_DIR)" -a                   \
1380
             -d $(VERSIONED_DIR_PATCH_APPLY) ]; then          \
1381
            run-parts --exit-on-error $(VERSIONED_DIR_PATCH_APPLY); \
1382
	    (cd $(VERSIONED_DIR_PATCH_APPLY); ls -1) >>       \
1383
                                           applied_patches;   \
1384
        echo done >  stamp-patch;                                    \
1385
        else                                                  \
1386
	    true;                                             \
1387
	fi
1388
	if [ -n "$(VERSIONED_ALL_PATCH_DIR)" -a               \
1389
             -d $(VERSIONED_ALL_PATCH_APPLY)  ]; then         \
1390
            run-parts --exit-on-error $(VERSIONED_ALL_PATCH_APPLY); \
1391
	    (cd $(VERSIONED_ALL_PATCH_APPLY); ls -1) >>       \
1392
                                           applied_patches;   \
1393
        echo done >  stamp-patch;                                    \
1394
        else                                                  \
1395
	    true;                                             \
1396
	fi
1397
	if [ -n "$(PATCH_DIR)" -a                             \
1398
             -d $(DIR_PATCH_APPLY) ]; then                    \
1399
            run-parts --exit-on-error $(DIR_PATCH_APPLY);           \
1400
	    (cd $(DIR_PATCH_APPLY); ls -1) >> applied_patches;\
1401
        else                                                  \
1402
	    true;                                             \
1403
	fi
1404
	if [ -n "$(ALL_PATCH_DIR)" -a                         \
1405
             -d $(ALL_PATCH_APPLY)  ]; then                   \
1406
            run-parts --exit-on-error $(ALL_PATCH_APPLY);           \
1407
	    (cd $(ALL_PATCH_APPLY); ls -1) >> applied_patches;\
1408
        echo done >  stamp-patch;                                    \
1409
        else                                                  \
1410
	    true;                                             \
1411
	fi
1412
endif
1413
endif
1414
	-test ! -f stamp-debian -a \
1415
               ! \( -f debian/official -a -f debian/control \) &&         \
1416
	   sed -e 's/=V/$(version)/g'        -e 's/=D/$(debian)/g'       \
1417
	       -e 's/=A/$(architecture)/g'   -e 's/=SA/$(INT_SUBARCH)/g' \
1418
                -e 's/=L/$(int_loaderdep) /g' -e 's/=I/$(initrddep)/g'    \
1419
                -e 's/=CV/$(VERSION).$(PATCHLEVEL)/g'                     \
1420
                -e 's/=M/$(maintainer) <$(email)>/g'                      \
1421
		         $(CONTROL)> debian/control
1422
	-test ! -f stamp-debian && test ! -f debian/official &&              \
1423
	   sed -e 's/=V/$(version)/g' -e 's/=D/$(debian)/g'                  \
1424
	    -e 's/=A/$(architecture)/g' -e 's/=M/$(maintainer) <$(email)>/g' \
1425
		$(DEBDIR)/changelog > debian/changelog
1426
	-test ! -f debian/rules &&                                       \
1427
	   install -p -m 755 $(DEBDIR)/rules debian/rules
1428
	echo done >  $@
1429
1430
# We could always do $(MAKE) -n -p dummy | grep ^CC >> .mak here if we cared
1431
ifeq ($(strip $(INCLUDE_KERNEL_MAKEFILE)),yes)
1432
include Makefile
1433
conf_vars:
1434
	@echo Please ignore the warning about overriding and ignoring targets above.
1435
	@echo These are harmless. They are only invoked in a part of the process
1436
	@echo that tries to snarf variable values for the conf.vars file.
1437
	@echo "VERSION          = $(VERSION)"        > .mak
1438
	@echo "PATCHLEVEL       = $(PATCHLEVEL)"    >> .mak
1439
	@echo "SUBLEVEL 	      = $(SUBLEVEL)"      >> .mak
1440
	@echo "EXTRAVERSION     = $(EXTRAVERSION)"  >> .mak
1441
ifneq ($(strip $(iatv)),)
1442
	@echo "APPEND_TO_VERSION = $(iatv)"          >> .mak
1443
endif
1444
	@echo "ARCH             = $(ARCH)"          >> .mak
1445
	@echo "KPKG_ARCH        = $(KPKG_ARCH)"     >> .mak
1446
	@echo "HOSTCC           = $(HOSTCC)"        >> .mak
1447
	@echo "HOSTCFLAGS       = $(HOSTCFLAGS)"    >> .mak
1448
	@echo "CROSS_COMPILE    = $(CROSS_COMPILE)" >> .mak
1449
	@echo "AS               = $(AS)"            >> .mak
1450
	@echo "LD               = $(LD)"            >> .mak
1451
	@echo "CC               = $(CC)"            >> .mak
1452
	@echo "CPP              = $(CPP)"           >> .mak
1453
	@echo "AR               = $(AR)"            >> .mak
1454
	@echo "NM               = $(NM)"            >> .mak
1455
	@echo "STRIP            = $(STRIP)"         >> .mak
1456
	@echo "OBJCOPY          = $(OBJCOPY)"       >> .mak
1457
	@echo "OBJDUMP          = $(OBJDUMP)"       >> .mak
1458
	@echo "MAKE             = $(MAKE)"          >> .mak
1459
	@echo "GENKSYMS 	      = $(GENKSYMS)"      >> .mak
1460
	@echo "CFLAGS           = $(CFLAGS)"        >> .mak
1461
	@echo "AFLAGS           = $(AFLAGS)"        >> .mak
1462
	@echo "MODFLAGS 	      = $(MODFLAGS)"      >> .mak
1463
	@echo "do_parallel      = $(do_parallel)"   >> .mak
1464
	@echo "fast_dep         = $(fast_dep)"      >> .mak
1465
	@sed -e 's%$(TOPDIR)%$$(TOPDIR)%g' .mak     > conf.vars
1466
	@rm -f .mak
1467
else
1468
conf.vars: Makefile
1469
	$(MAKE) -f debian/rules INCLUDE_KERNEL_MAKEFILE=yes conf_vars
1470
endif
1471
1472
dummy_do_dep:
1473
	+$(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) \
1474
                                 ARCH=$(KERNEL_ARCH) $(fast_dep) dep 
1475
1476
stamp-kernel-configure: stamp-debian .config
1477
	$(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) \
1478
                                 ARCH=$(KERNEL_ARCH) $(config_target) 	
1479
ifeq ($(shell if [ $(VERSION) -ge 2 -a $(PATCHLEVEL) -ge 5 ]; then \
1480
                  echo new;fi),)
1481
	+$(MAKE) -f ./debian/rules dummy_do_dep
1482
	$(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) \
1483
                                 ARCH=$(KERNEL_ARCH) clean 
1484
else
1485
	$(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) \
1486
                                ARCH=$(KERNEL_ARCH) prepare
1487
endif
1488
	echo done >  $@
1489
1490
configure: debian .config stamp-configure
1491
stamp-configure: stamp-debian .config conf.vars stamp-kernel-configure
1492
	echo done >  $@
1493
1494
1495
1496
.config:
1497
ifneq ($(strip $(use_saved_config)),NO)
1498
	test -f .config || test ! -f .config.save || \
1499
		            cp -pf .config.save .config
1500
endif
1501
	test -f .config || test ! -f $(CONFIG_FILE) || \
1502
		            cp -pf $(CONFIG_FILE) .config
1503
	test -f .config || test ! -f $(DEBDIR)/config || \
1504
		            cp -pf $(DEBDIR)/config  .config
1505
ifeq ($(strip $(have_new_config_target)),)
1506
	test -f .config || (echo "*** Need a config file .config" && false)
1507
endif
1508
# if $(have_new_config_target) is set, then we need not have a .config
1509
# file at this point
1510
1511
clean:
1512
ifeq ($(strip $(int_am_root)),)
1513
ifeq ($(strip $(int_get_root)),)
1514
	@echo "You may need root privileges - some parts may fail"
1515
endif
1516
	$(int_get_root) $(deb_rule) real_stamp_clean 
1517
else
1518
	$(deb_rule) real_stamp_clean 
1519
endif
1520
1521
# Perhaps a list of patches should be dumped to a file on patching? so we
1522
# only unpatch what we have applied? That would be changed, though saner,
1523
# behaviour
1524
real_stamp_clean:
1525
	test ! -f .config || cp -pf .config config.precious
1526
	-test -f Makefile && \
1527
            $(MAKE) $(FLAV_ARG) $(EXTRAV_ARG) ARCH=$(KERNEL_ARCH) distclean
1528
	test ! -f config.precious || mv -f config.precious .config
1529
ifeq ($(strip $(patch_the_kernel)),YES)
1530
	$(deb_rule) unpatch_now
1531
endif
1532
ifeq ($(strip $(NO_UNPATCH_BY_DEFAULT)),)
1533
	test ! -f stamp-patch || $(deb_rule) unpatch_now
1534
endif
1535
	-test -f stamp-building || test -f debian/official || rm -rf debian
1536
	rm -f $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN)
1537
	rm -rf $(DIRS_TO_CLEAN)
1538
1539
1540
unpatch_now:
1541
ifneq ($(strip $(valid_unpatches)),)
1542
	-for patch in $(valid_unpatches) ; do              \
1543
          if test -x  $$patch; then                        \
1544
              if $$patch; then                             \
1545
                  echo "Removed Patch $$patch ";           \
1546
              else                                         \
1547
                   echo "Patch $$patch  failed.";          \
1548
                   echo "Hit return to Continue";          \
1549
		   read ans;                               \
1550
              fi;                                          \
1551
	  fi;                                              \
1552
        done
1553
	rm -f stamp-patch
1554
else
1555
	if [ -n "$(VERSIONED_PATCH_DIR)" -a                     \
1556
             -d $(VERSIONED_DIR_PATCH_UNPATCH) ]; then          \
1557
            run-parts --report $(VERSIONED_DIR_PATCH_UNPATCH); \
1558
        else                                                    \
1559
	    true;                                               \
1560
	fi
1561
	if [ -n "$(VERSIONED_ALL_PATCH_DIR)" -a                 \
1562
             -d $(VERSIONED_ALL_PATCH_UNPATCH)  ]; then         \
1563
            run-parts --report $(VERSIONED_ALL_PATCH_UNPATCH); \
1564
        else                                                    \
1565
	    true;                                               \
1566
	fi
1567
	if [ -n "$(PATCH_DIR)" -a                               \
1568
             -d $(DIR_PATCH_UNPATCH) ]; then                    \
1569
            run-parts --report $(DIR_PATCH_UNPATCH);           \
1570
        else                                                    \
1571
	    true;                                               \
1572
	fi
1573
	if [ -n "$(ALL_PATCH_DIR)" -a                           \
1574
             -d $(ALL_PATCH_UNPATCH)  ]; then                   \
1575
            run-parts --report $(ALL_PATCH_UNPATCH);           \
1576
        else                                                    \
1577
	    true;                                               \
1578
	fi
1579
	rm -f stamp-patch
1580
endif
1581
1582
1583
binary:       binary-indep binary-arch
1584
binary-indep: kernel_source kernel_doc
1585
binary-arch:  kernel_image  kernel_headers
1586
1587
1588
kernel-source kernel_source: stamp-source
1589
stamp-source: stamp-debian
1590
ifeq ($(strip $(int_am_root)),)
1591
ifeq ($(strip $(int_get_root)),)
1592
	@echo need root privileges; exit 1
1593
else
1594
	$(int_get_root) $(deb_rule) real_stamp_source
1595
endif
1596
else
1597
	$(deb_rule) real_stamp_source
1598
endif
1599
1600
real_stamp_source:
1601
ifeq ($(strip $(architecture)),um)
1602
	echo done >  stamp-source
1603
else
1604
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
1605
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
1606
endif
1607
	test -f stamp-debian || $(deb_rule) debian
1608
	rm -rf $(SOURCE_TOP)
1609
	$(make_directory) $(SOURCE_TOP)/DEBIAN
1610
	$(make_directory) $(SOURCE_SRC)
1611
	$(make_directory) $(SOURCE_DOC)
1612
	sed -e 's/=P/$(package)/g' -e 's/=V/$(version)/g' \
1613
	    $(DEBDIR)/include.postinst > $(SOURCE_TOP)/DEBIAN/postinst
1614
	chmod 755 $(SOURCE_TOP)/DEBIAN/postinst
1615
	$(install_file) debian/changelog         $(SOURCE_DOC)/changelog
1616
	gzip -9qf                             	 $(SOURCE_DOC)/changelog
1617
	$(install_file) $(DEBDIR)/README      	 $(SOURCE_DOC)/debian.README
1618
	gzip -9qf                             	 $(SOURCE_DOC)/debian.README
1619
	$(install_file) $(DEBDIR)/README.grub 	 $(SOURCE_DOC)/README.grub
1620
	gzip -9qf                                $(SOURCE_DOC)/README.grub
1621
	$(install_file) $(DEBDIR)/README.headers $(SOURCE_DOC)/README.headers
1622
	gzip -9qf                                $(SOURCE_DOC)/README.headers
1623
	$(install_file) $(DEBDIR)/README.tecra   $(SOURCE_DOC)/README.tecra
1624
	gzip -9qf                                $(SOURCE_DOC)/README.tecra
1625
	$(install_file) $(DEBDIR)/README.modules $(SOURCE_DOC)/README.modules
1626
	gzip -9qf                                $(SOURCE_DOC)/README.modules
1627
	$(install_file) $(DEBDIR)/sample.module.control \
1628
                                            $(SOURCE_DOC)/sample.module.control
1629
	gzip -9qf                           $(SOURCE_DOC)/sample.module.control
1630
	$(install_file) README                     $(SOURCE_DOC)/README
1631
	gzip -9qf                                  $(SOURCE_DOC)/README
1632
	$(install_file) $(DEBDIR)/Flavours         $(SOURCE_DOC)/Flavours
1633
	gzip -9qf                                  $(SOURCE_DOC)/Flavours
1634
	$(install_file) $(DEBDIR)/Rationale        $(SOURCE_DOC)/Rationale
1635
	gzip -9qf                                  $(SOURCE_DOC)/Rationale
1636
	$(install_file) $(DEBDIR)/copyright.source $(SOURCE_DOC)/copyright
1637
	echo "This was produced by kernel-package version $(kpkg_version)." > \
1638
	         $(SOURCE_DOC)/Buildinfo
1639
ifneq ($(strip $(int_follow_symlinks_in_src)),)
1640
	-tar cfh - `echo * | sed -e 's/ debian//g' -e 's/\.deb//g' ` \
1641
	| (cd $(SOURCE_SRC); umask 000; tar xpsf -)
1642
	(cd $(SOURCE_SRC)/include; rm -rf asm ; )
1643
else
1644
	-tar cf - `echo * | sed -e 's/ debian//g' -e 's/\.deb//g' ` \
1645
	| (cd $(SOURCE_SRC); umask 000; tar xspf -)
1646
	(cd $(SOURCE_SRC)/include; rm -f asm ; )
1647
endif
1648
	(cd $(SOURCE_SRC); \
1649
            $(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) ARCH=$(KERNEL_ARCH) distclean)
1650
	(cd $(SOURCE_SRC);         rm -f stamp-building $(STAMPS_TO_CLEAN))
1651
	(cd $(SOURCE_SRC);         \
1652
         [ ! -d scripts/cramfs ]   || make -C scripts/cramfs distclean ; )
1653
	if test -f debian/official -a -f debian/README.Debian ; then \
1654
           $(install_file) debian/README.Debian $(SOURCE_SRC)/README.Debian ; \
1655
           $(install_file) debian/README.Debian $(SOURCE_DOC)/README.Debian ; \
1656
	   gzip -9qf $(SOURCE_DOC)/README.Debian;\
1657
	else \
1658
	    sed -e 's/=V/$(version)/g' -e 's/=A/$(architecture)/g' \
1659
                 $(DEBDIR)/README.source >  $(SOURCE_SRC)/README.Debian ; \
1660
	fi
1661
	if test -f README.Debian ; then \
1662
           $(install_file) README.Debian $(SOURCE_DOC)/README.Debian.1st; \
1663
	   gzip -9qf                     $(SOURCE_DOC)/README.Debian.1st;\
1664
	fi
1665
ifneq ($(strip $(source_clean_hook)),)
1666
	(cd $(SOURCE_SRC);              \
1667
               test -x $(source_clean_hook) && $(source_clean_hook))
1668
endif
1669
	chmod -R og=rX $(SOURCE_TOP)
1670
	chown -R root:root $(SOURCE_TOP)
1671
	(cd $(SOURCE_TOP)/usr/src/; \
1672
           tar $(TAR_COMPRESSION) -cf $(package).tar.$(TAR_SUFFIX) $(package);\
1673
             rm -rf $(package);)
1674
	dpkg-gencontrol -isp -p$(package) -P$(SOURCE_TOP)/
1675
	chmod -R og=rX $(SOURCE_TOP)
1676
	chown -R root:root $(SOURCE_TOP)
1677
	dpkg --build $(SOURCE_TOP) $(DEB_DEST)
1678
	rm -f -r $(SOURCE_TOP)
1679
	echo done >  stamp-source
1680
endif
1681
1682
libc-kheaders libc_kheaders: stamp-libc-kheaders
1683
stamp-libc-kheaders: configure
1684
	@echo This target is now obsolete.
1685
1686
1687
kernel-headers kernel_headers: stamp-headers
1688
stamp-headers: configure
1689
ifeq ($(strip $(int_am_root)),)
1690
ifeq ($(strip $(int_get_root)),)
1691
	@echo need root privileges; exit 1
1692
else
1693
	$(int_get_root) $(deb_rule) real_stamp_headers
1694
endif
1695
else
1696
	$(deb_rule) real_stamp_headers
1697
endif
1698
1699
real_stamp_headers:
1700
ifeq ($(strip $(architecture)),um)
1701
	echo done >  stamp-headers
1702
else
1703
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
1704
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
1705
endif
1706
ifneq ($(strip $(UTS_RELEASE_VERSION)),$(strip $(version)))
1707
	@echo "The UTS Release version in include/linux/version.h $(UTS_RELEASE_VERSION) does not match current version $(version), reconfiguring"
1708
	touch Makefile
1709
endif
1710
	test -f stamp-configure || $(deb_rule) configure
1711
	rm -rf $(HEADER_TOP)
1712
	$(make_directory) $(HEADER_TOP)/DEBIAN
1713
	$(make_directory) $(HEADER_SRC)
1714
	$(make_directory) $(HEADER_DOC)
1715
	sed -e 's/=P/$(h_package)/g' -e 's/=V/$(version)/g' \
1716
		$(DEBDIR)/include.postinst > $(HEADER_TOP)/DEBIAN/postinst
1717
	chmod 755 $(HEADER_TOP)/DEBIAN/postinst
1718
	$(install_file) $(DEBDIR)/copyright.headers $(HEADER_DOC)/copyright
1719
	$(install_file) debian/changelog         $(HEADER_DOC)/changelog
1720
	gzip -9qf                                $(HEADER_DOC)/changelog
1721
	$(install_file) $(DEBDIR)/README.headers $(HEADER_DOC)/debian.README
1722
	gzip -9qf                                $(HEADER_DOC)/debian.README
1723
	$(install_file) .config  	              $(HEADER_DOC)/config-$(version)
1724
	$(install_file) conf.vars  	     $(HEADER_DOC)/conf.vars
1725
	gzip -9qf                                $(HEADER_DOC)/config-$(version)
1726
	gzip -9qf                                $(HEADER_DOC)/conf.vars
1727
	$(install_file) CREDITS                  $(HEADER_DOC)/     
1728
	gzip -9qf                                $(HEADER_DOC)/CREDITS
1729
	$(install_file) MAINTAINERS              $(HEADER_DOC)/     
1730
	gzip -9qf                                $(HEADER_DOC)/MAINTAINERS
1731
	$(install_file) REPORTING-BUGS           $(HEADER_DOC)/     
1732
	gzip -9qf                                $(HEADER_DOC)/REPORTING-BUGS
1733
	$(install_file) README                   $(HEADER_DOC)/     
1734
	gzip -9qf                                $(HEADER_DOC)/README
1735
	if test -f debian/official -a -f debian/README.Debian ; then \
1736
           $(install_file) debian/README.Debian $(HEADER_DOC)/README.Debian ; \
1737
           gzip -9qf                            $(HEADER_DOC)/README.Debian ; \
1738
           $(install_file) README.Debian $(HEADER_DOC)/README.Debian;\
1739
	   gzip -9qf                     $(HEADER_DOC)/README.Debian;\
1740
	fi
1741
	if test -f README.Debian ; then \
1742
           $(install_file) README.Debian $(HEADER_DOC)/README.Debian.1st;\
1743
	     gzip -9qf                   $(HEADER_DOC)/README.Debian.1st;\
1744
	fi
1745
	echo "This was produced by kernel-package version $(kpkg_version)." > \
1746
	         $(HEADER_DOC)/Buildinfo
1747
	chmod 0644 $(HEADER_DOC)/Buildinfo
1748
	$(install_file) Makefile       $(HEADER_SRC)
1749
ifneq ($(strip $(int_follow_symlinks_in_src)),)
1750
	-tar cfh - include |        (cd $(HEADER_SRC); umask 000; tar xsf -)
1751
	(cd $(HEADER_SRC)/include; rm -rf asm; ln -s asm-$(KERNEL_ARCH) asm)
1752
else
1753
	-tar cf - include |        (cd $(HEADER_SRC); umask 000; tar xsf -)
1754
	(cd $(HEADER_SRC)/include; rm -f asm; ln -s asm-$(KERNEL_ARCH) asm)
1755
endif
1756
	$(install_file) .config  	        $(HEADER_SRC)/.config
1757
	echo $(debian)                    > $(HEADER_SRC)/kernel-headers.revision
1758
ifneq ($(strip $(header_clean_hook)),)
1759
	(cd $(HEADER_SRC);              \
1760
               test -x $(header_clean_hook) && $(header_clean_hook))
1761
endif
1762
	dpkg-gencontrol -DArchitecture=$(architecture) -isp \
1763
                        -p$(h_package) -P$(HEADER_TOP)/
1764
	chown -R root:root $(HEADER_TOP)
1765
	chmod -R og=rX $(HEADER_TOP)
1766
	dpkg --build $(HEADER_TOP) $(DEB_DEST)
1767
	rm -rf $(HEADER_TOP)
1768
	echo done >  stamp-headers
1769
endif
1770
1771
kernel-doc kernel_doc: stamp-doc
1772
stamp-doc: stamp-debian
1773
ifeq ($(strip $(int_am_root)),)
1774
ifeq ($(strip $(int_get_root)),)
1775
	@echo need root privileges; exit 1
1776
else
1777
	$(int_get_root) $(deb_rule) real_stamp_doc
1778
endif
1779
else
1780
	$(deb_rule) real_stamp_doc
1781
endif
1782
1783
real_stamp_doc:
1784
ifeq ($(strip $(architecture)),um)
1785
	echo done >  stamp-doc
1786
else
1787
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
1788
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
1789
endif
1790
	test -f stamp-debian || $(deb_rule) debian
1791
	rm -rf            $(DOC_TOP)
1792
	$(make_directory) $(DOC_TOP)/DEBIAN
1793
	$(make_directory) $(DOC_DOC)
1794
	$(install_file) debian/changelog          $(DOC_DOC)/changelog
1795
	$(install_file) $(DEBDIR)/README.doc      $(DOC_DOC)/README.Debian
1796
	echo "This was produced by kernel-package version $(kpkg_version)." > \
1797
	           $(DOC_DOC)/Buildinfo
1798
	chmod 0644 $(DOC_DOC)/Buildinfo
1799
	if test -f debian/official -a -f debian/README.Debian ; then \
1800
           $(install_file) debian/README.Debian $(DOC_DOC)/README.Debian;\
1801
	fi
1802
	if test -f README.Debian ; then \
1803
           $(install_file) README.Debian $(DOC_DOC)/README.Debian.1st;\
1804
	fi
1805
ifneq ($(strip $(shell if [ -x /usr/bin/db2html ]; then echo YSE; fi)),)
1806
	$(MAKE)  mandocs htmldocs
1807
endif
1808
	-tar cf - Documentation | (cd $(DOC_DOC); umask 000; tar xsf -)
1809
ifneq ($(strip $(doc_clean_hook)),)
1810
	(cd $(DOC_DOC);              \
1811
               test -x $(doc_clean_hook) && $(doc_clean_hook))
1812
endif
1813
	-gzip -9qfr $(DOC_DOC)
1814
	-find $(DOC_DOC) -type f -name \*.gz -perm +111 -exec gunzip {} \;
1815
	$(install_file) $(DEBDIR)/copyright.doc $(DOC_DOC)/copyright
1816
	sed -e 's/=P/$(d_package)/g' -e 's/=V/$(version)/g' \
1817
		$(DEBDIR)/include.postinst > $(DOC_TOP)/DEBIAN/postinst
1818
	chmod 755 $(DOC_TOP)/DEBIAN/postinst
1819
	dpkg-gencontrol -isp -p$(d_package) -P$(DOC_TOP)/
1820
	chmod -R og=rX $(DOC_TOP)
1821
	chown -R root:root $(DOC_TOP)
1822
	dpkg --build $(DOC_TOP) $(DEB_DEST)
1823
	rm -rf $(DOC_TOP)
1824
	echo done >  stamp-doc
1825
endif
1826
1827
kernel-image kernel_image: stamp-image
1828
stamp-image: configure build kernel-image-deb
1829
# % make config
1830
# % make-kpkg build
1831
# % sudo make -f debian/rules kernel-image-deb
1832
# seems to create a working .deb with a kernel that gives the correct
1833
# user name (as opposed to root@...)
1834
kernel-image-deb:
1835
ifeq ($(strip $(int_am_root)),)
1836
ifeq ($(strip $(int_get_root)),)
1837
	@echo need root privileges; exit 1
1838
else
1839
	$(int_get_root) $(deb_rule) real_stamp_image
1840
endif
1841
else
1842
	$(deb_rule) real_stamp_image
1843
endif
1844
1845
real_stamp_image:
1846
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
1847
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
1848
endif
1849
ifneq ($(strip $(UTS_RELEASE_VERSION)),$(strip $(version)))
1850
	@echo "The UTS Release version in include/linux/version.h $(UTS_RELEASE_VERSION) does not match current version $(version), reconfiguring."
1851
	touch Makefile
1852
endif
1853
	rm -f -r ./$(IMAGE_TOP) ./$(IMAGE_TOP).deb
1854
	test -f stamp-configure     || $(deb_rule) configure
1855
	test -f stamp-build         || $(deb_rule) build
1856
	$(make_directory) $(IMAGE_TOP)/DEBIAN
1857
	$(make_directory) $(IMAGE_TOP)/$(IMAGEDIR)
1858
	$(make_directory) $(IMAGE_DOC)
1859
	sed -e 's/=V/$(version)/g'    -e 's/=B/$(link_in_boot)/g'   \
1860
            -e 's/=S/$(no_symlink)/g' -e 's/=R/$(reverse_symlink)/g' \
1861
            -e 's/=K/$(kimage)/g'     -e 's/=L/$(loader)/g'          \
1862
            -e 's/=I/$(INITRD)/g'     -e 's,=D,$(IMAGEDIR),g'        \
1863
            -e 's@=M@$(MKIMAGE)@g'    -e 's/=OF/$(AM_OFFICIAL)/g'    \
1864
             $(DEBDIR)/image.postinst > $(IMAGE_TOP)/DEBIAN/postinst
1865
	chmod 755 $(IMAGE_TOP)/DEBIAN/postinst
1866
	sed -e 's/=V/$(version)/g'    -e 's/=B/$(link_in_boot)/g'   \
1867
            -e 's/=S/$(no_symlink)/g' -e 's/=R/$(reverse_symlink)/g' \
1868
            -e 's/=K/$(kimage)/g'     -e 's/=L/$(loader)/g'          \
1869
            -e 's/=I/$(INITRD)/g'     -e 's,=D,$(IMAGEDIR),g'        \
1870
            -e 's@=M@$(MKIMAGE)@g'    -e 's/=OF/$(AM_OFFICIAL)/g'    \
1871
             $(DEBDIR)/image.postrm > $(IMAGE_TOP)/DEBIAN/postrm
1872
	chmod 755 $(IMAGE_TOP)/DEBIAN/postrm
1873
	sed -e 's/=V/$(version)/g'    -e 's/=L/$(loader)/g'          \
1874
	    -e 's/=I/$(INITRD)/g'     -e 's/=OF/$(AM_OFFICIAL)/g'    \
1875
             -e 's@=M@$(MKIMAGE)@g'                                   \
1876
	             $(DEBDIR)/image.preinst > $(IMAGE_TOP)/DEBIAN/preinst
1877
	chmod 755 $(IMAGE_TOP)/DEBIAN/preinst
1878
	sed -e 's/=V/$(version)/g'    -e 's/=L/$(loader)/g'          \
1879
             -e 's@=M@$(MKIMAGE)@g'    -e 's/=OF/$(AM_OFFICIAL)/g'    \
1880
	             $(DEBDIR)/image.prerm > $(IMAGE_TOP)/DEBIAN/prerm
1881
	chmod 755 $(IMAGE_TOP)/DEBIAN/prerm
1882
	$(install_file) Documentation/Changes $(IMAGE_DOC)/
1883
	gzip -9qf $(IMAGE_DOC)/Changes
1884
	$(install_file) debian/changelog        $(IMAGE_DOC)/changelog
1885
	gzip -9qf                               $(IMAGE_DOC)/changelog
1886
ifdef loaderdoc
1887
	$(install_file) $(DEBDIR)/$(loaderdoc)  $(IMAGE_DOC)/$(loaderdoc)
1888
	gzip -9qf                               $(IMAGE_DOC)/$(loaderdoc)
1889
endif
1890
	$(install_file) $(DEBDIR)/README.image  $(IMAGE_DOC)/debian.README
1891
	gzip -9qf                               $(IMAGE_DOC)/debian.README
1892
	$(install_file) $(DEBDIR)/copyright.image $(IMAGE_DOC)/copyright
1893
	echo "This was produced by kernel-package version $(kpkg_version)." > \
1894
	           $(IMAGE_DOC)/Buildinfo
1895
	chmod 0644 $(IMAGE_DOC)/Buildinfo
1896
	$(install_file) .config          $(INT_IMAGE_DESTDIR)/config-$(version)
1897
	$(install_file) conf.vars        $(IMAGE_DOC)/conf.vars
1898
	gzip -9qf                        $(IMAGE_DOC)/conf.vars
1899
	$(install_file) debian/buildinfo $(IMAGE_DOC)/buildinfo
1900
	gzip -9qf                        $(IMAGE_DOC)/buildinfo
1901
	if test -f debian/official -a -f debian/README.Debian ; then \
1902
           $(install_file) debian/README.Debian  $(IMAGE_DOC)/README.Debian ; \
1903
         gzip -9qf                               $(IMAGE_DOC)/README.Debian;\
1904
	fi
1905
	if test -f README.Debian ; then \
1906
           $(install_file) README.Debian $(IMAGE_DOC)/README.Debian.1st;\
1907
           gzip -9qf                     $(IMAGE_DOC)/README.Debian.1st;\
1908
	fi
1909
ifeq ($(strip $(HAVE_EXTRA_DOCS)),YES)
1910
	$(install_file) $(extra_docs) 	         $(IMAGE_DOC)/
1911
endif
1912
ifneq ($(strip $(shell egrep ^[^\#]*CONFIG_MODULES $(CONFIG_FILE))),)
1913
ifeq  ($(strip $(HAVE_NEW_MODLIB)),)
1914
	$(mod_inst_cmds)
1915
else
1916
# could have also said DEPMOD=/bin/true instead of moving files
1917
ifneq ($(strip $(KERNEL_CROSS)),)
1918
	mv System.map System.precious
1919
endif
1920
	$(MAKE) $(EXTRAV_ARG) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH)           \
1921
                $(CROSS_ARG) ARCH=$(KERNEL_ARCH) modules_install
1922
ifneq ($(strip $(KERNEL_CROSS)),)
1923
	mv System.precious System.map
1924
endif
1925
endif
1926
	-depmod -q -FSystem.map -b $(IMAGE_TOP) $(version)
1927
endif
1928
	if test -d $(SRCTOP)/debian/image.d ; then                            \
1929
             IMAGE_TOP=$(IMAGE_TOP) version=$(version)                        \
1930
                   run-parts --verbose $(SRCTOP)/debian/image.d ;             \
1931
        fi
1932
	if [ -x debian/post-install ]; then                                   \
1933
		IMAGE_TOP=$(IMAGE_TOP) version=$(version) debian/post-install;\
1934
	fi
1935
ifeq ($(strip $(NEED_DIRECT_GZIP_IMAGE)),YES)
1936
	gzip -9vc $(kimagesrc) > $(kimagedest)
1937
else
1938
	cp $(kimagesrc) $(kimagedest)
1939
endif
1940
	chmod 644 $(kimagedest)
1941
ifeq ($(strip $(HAVE_COFF_IMAGE)),YES)
1942
	cp $(coffsrc)   $(coffdest)
1943
	chmod 644       $(coffdest)
1944
endif
1945
ifeq ($(strip $(int_install_vmlinux)),YES)
1946
ifneq ($(strip $(kelfimagesrc)),)
1947
	cp $(kelfimagesrc) $(kelfimagedest)
1948
	chmod 644 $(kelfimagedest)
1949
endif
1950
endif
1951
	test ! -s applied_patches || cp applied_patches                        \
1952
                        $(INT_IMAGE_DESTDIR)/patches-$(version)
1953
	test ! -s applied_patches || chmod 644                                 \
1954
                        $(INT_IMAGE_DESTDIR)/patches-$(version)
1955
	test ! -f System.map ||  cp System.map                                 \
1956
                        $(INT_IMAGE_DESTDIR)/System.map-$(version)
1957
	test ! -f System.map ||  chmod 644                                     \
1958
                        $(INT_IMAGE_DESTDIR)/System.map-$(version)
1959
ifeq ($(strip $(delete_build_link)),YES)
1960
	rm -f $(IMAGE_TOP)/lib/modules/$(version)/build
1961
endif
1962
	dpkg-gencontrol -DArchitecture=$(architecture) -isp                   \
1963
                        -p$(i_package) -P$(IMAGE_TOP)/
1964
	chmod -R og=rX $(IMAGE_TOP)
1965
	chown -R root:root $(IMAGE_TOP)
1966
	dpkg --build $(IMAGE_TOP) $(DEB_DEST)
1967
	rm -f -r $(IMAGE_TOP)
1968
ifeq ($(strip $(do_clean)),YES)
1969
	$(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) ARCH=$(KERNEL_ARCH) \
1970
                                clean
1971
	rm -f stamp-build
1972
endif
1973
	echo done >  stamp-image
1974
1975
# This for STOP_FOR_BIN86
1976
endif
1977
1978
# This endif is for HAVE_VALID_PACKAGE_VERSION
1979
endif
1980
1981
#This  endif is for IN_KERNEL_DIR
1982
endif
1983
1984
1985
# only generate module image packages
1986
modules-image modules_image: configure 
1987
ifeq ($(strip $(shell egrep ^[^\#]*CONFIG_MODULES $(CONFIG_FILE))),)
1988
	@echo Modules not configured, so not making $@
1989
else
1990
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
1991
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
1992
endif
1993
	-for module in $(valid_modules) ; do                        \
1994
          if test -d  $$module; then                                \
1995
	    (cd $$module;                                           \
1996
              if ./debian/rules KVERS="$(version)" KSRC="$(SRCTOP)" \
1997
                             KMAINT="$(pgp)" KEMAIL="$(email)"      \
1998
                             KPKG_DEST_DIR="$(KPKG_DEST_DIR)"       \
1999
                             KPKG_MAINTAINER="$(maintainer)"        \
2000
                             KDREV="$(debian)" kdist_image; then    \
2001
                  echo "Module $$module processed fine";            \
2002
              else                                                  \
2003
                   echo "Module $$module failed.";                  \
2004
                   echo "Hit return to Continue";                   \
2005
		   read ans;                                        \
2006
              fi;                                                   \
2007
	     );                                                     \
2008
	  fi;                                                       \
2009
        done
2010
endif
2011
2012
# generate the modules packages and sign them
2013
modules: configure 
2014
ifeq ($(strip $(shell egrep ^[^\#]*CONFIG_MODULES $(CONFIG_FILE))),)
2015
	@echo Modules not configured, so not making $@
2016
else
2017
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
2018
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
2019
endif
2020
	-for module in $(valid_modules) ; do                        \
2021
          if test -d  $$module; then                                \
2022
	    (cd $$module;                                           \
2023
              if ./debian/rules KVERS="$(version)" KSRC="$(SRCTOP)" \
2024
                             KMAINT="$(pgp)" KEMAIL="$(email)"      \
2025
                             KPKG_DEST_DIR="$(KPKG_DEST_DIR)"       \
2026
                             KPKG_MAINTAINER="$(maintainer)"        \
2027
                             ARCH=$(KERNEL_ARCH)                    \
2028
                             KDREV="$(debian)" kdist; then          \
2029
                  echo "Module $$module processed fine";            \
2030
              else                                                  \
2031
                   echo "Module $$module failed.";                  \
2032
                   echo "Hit return to Continue?";                  \
2033
		   read ans;                                        \
2034
              fi;                                                   \
2035
	     );                                                     \
2036
	  fi;                                                       \
2037
        done
2038
endif
2039
2040
# configure the modules packages
2041
modules-config modules_config: configure
2042
ifeq ($(strip $(shell egrep ^[^\#]*CONFIG_MODULES $(CONFIG_FILE))),)
2043
	@echo Modules not configured, so not making $@
2044
else
2045
ifneq ($(strip $(HAVE_VERSION_MISMATCH)),)
2046
	@(echo "The changelog says we are creating $(saved_version), but I thought the version is $(version)"; exit 1)
2047
endif
2048
	-for module in $(valid_modules) ; do                        \
2049
          if test -d  $$module; then                                \
2050
	    (cd $$module;                                           \
2051
              if ./debian/rules KVERS="$(version)" KSRC="$(SRCTOP)" \
2052
                             KMAINT="$(pgp)" KEMAIL="$(email)"      \
2053
                             KPKG_DEST_DIR="$(KPKG_DEST_DIR)"       \
2054
                             KPKG_MAINTAINER="$(maintainer)"        \
2055
                             ARCH=$(KERNEL_ARCH)                    \
2056
                             KDREV="$(debian)" kdist_configure; then\
2057
                  echo "Module $$module configured fine";           \
2058
              else                                                  \
2059
                   echo "Module $$module failed to configure";      \
2060
                   echo "Hit return to Continue?";                  \
2061
		   read ans;                                        \
2062
              fi;                                                   \
2063
	     );                                                     \
2064
	  fi;                                                       \
2065
        done
2066
endif
2067
2068
modules-clean modules_clean: .config
2069
ifeq ($(strip $(shell egrep ^[^\#]*CONFIG_MODULES $(CONFIG_FILE))),)
2070
	@echo Modules not configured, so not making $@
2071
else
2072
	-for module in $(MODULE_LOC)/* ; do \
2073
          if test -d  $$module; then \
2074
	    (cd $$module; \
2075
              if ./debian/rules KVERS="$(version)" KSRC="$(SRCTOP)" \
2076
                             KMAINT="$(pgp)" KEMAIL="$(email)"      \
2077
                             KPKG_DEST_DIR="$(KPKG_DEST_DIR)"       \
2078
                             KPKG_MAINTAINER="$(maintainer)"        \
2079
                             ARCH=$(KERNEL_ARCH)                    \
2080
                             KDREV="$(debian)" kdist_clean; then    \
2081
                  echo "Module $$module cleaned";                   \
2082
              else                                                  \
2083
                   echo "Module $$module failed to clean up";       \
2084
                   echo "Hit return to Continue?";                  \
2085
		   read ans;                                        \
2086
              fi;                                                   \
2087
	     );                                                     \
2088
	  fi;                                                       \
2089
        done
2090
endif
2091
2092
2093
source diff:
2094
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
2095
2096
define mod_inst_cmds
2097
        @( \
2098
        MODLIB=$(INSTALL_MOD_PATH)/lib/modules/$(version); \
2099
        cd modules; \
2100
        MODULES=""; \
2101
        inst_mod() { These="`cat $$1`"; MODULES="$$MODULES $$These"; \
2102
                mkdir -p $$MODLIB/$$2; cp $$These $$MODLIB/$$2; \
2103
                echo Installing modules under $$MODLIB/$$2; \
2104
        }; \
2105
        \
2106
	if [ -f BLOCK_MODULES    ]; then inst_mod BLOCK_MODULES    block; fi; \
2107
	if [ -f NET_MODULES      ]; then inst_mod NET_MODULES      net;   fi; \
2108
	if [ -f IPV4_MODULES     ]; then inst_mod IPV4_MODULES     ipv4;  fi; \
2109
	if [ -f IPV6_MODULES     ]; then inst_mod IPV6_MODULES     ipv6;  fi; \
2110
        if [ -f ATM_MODULES      ]; then inst_mod ATM_MODULES      atm;   fi; \
2111
	if [ -f SCSI_MODULES     ]; then inst_mod SCSI_MODULES     scsi;  fi; \
2112
	if [ -f FS_MODULES       ]; then inst_mod FS_MODULES       fs;    fi; \
2113
	if [ -f NLS_MODULES      ]; then inst_mod NLS_MODULES      fs;    fi; \
2114
	if [ -f CDROM_MODULES    ]; then inst_mod CDROM_MODULES    cdrom; fi; \
2115
	if [ -f HAM_MODULES      ]; then inst_mod HAM_MODULES      net;   fi; \
2116
	if [ -f SOUND_MODULES    ]; then inst_mod SOUND_MODULES    sound; fi; \
2117
	if [ -f VIDEO_MODULES    ]; then inst_mod VIDEO_MODULES    video; fi; \
2118
	if [ -f FC4_MODULES      ]; then inst_mod FC4_MODULES      fc4;   fi; \
2119
	if [ -f IRDA_MODULES     ]; then inst_mod IRDA_MODULES     net;   fi; \
2120
        if [ -f USB_MODULES      ]; then inst_mod USB_MODULES      usb;   fi; \
2121
        if [ -f SK98LIN_MODULES  ]; then inst_mod SK98LIN_MODULES  net;   fi; \
2122
        if [ -f SKFP_MODULES     ]; then inst_mod SKFP_MODULES     net;   fi; \
2123
        if [ -f IEEE1394_MODULES ]; then inst_mod IEEE1394_MODULES ieee1394; fi;\
2124
        if [ -f PCMCIA_MODULES   ]; then inst_mod PCMCIA_MODULES pcmcia;   fi; \
2125
        if [ -f PCMCIA_NET_MODULES ]; then inst_mod PCMCIA_NET_MODULES pcmcia; fi; \
2126
        if [ -f PCMCIA_CHAR_MODULES ]; then inst_mod PCMCIA_CHAR_MODULES pcmcia; fi; \
2127
        if [ -f PCMCIA_SCSI_MODULES ]; then inst_mod PCMCIA_SCSI_MODULES pcmcia; fi; \
2128
        \
2129
        for f in *.o; do [ -r $$f ] && echo $$f; done > .allmods; \
2130
        echo $$MODULES | tr ' ' '\n' | sort | comm -23 .allmods - > .misc; \
2131
        if [ -s .misc ]; then inst_mod .misc misc; fi; \
2132
        rm -f .misc .allmods; \
2133
        )
2134
endef
2135
2136
# 		2.0.38	2.2.12	2.3.1
2137
# BLOCK_MODULES	X	X	X
2138
# NET_MODULES	X	X	X
2139
# IPV4_MODULES	X	X	X
2140
# IPV6_MODULES		X	X
2141
# ATM_MODULES			X
2142
# SCSI_MODULES	X	X	X
2143
# FS_MODULES	X	X	X
2144
# NLS_MODULES		X	X
2145
# CDROM_MODULES	X	X	X
2146
# HAM_MODULES		X	X
2147
# SOUND_MODULES		X	X
2148
# VIDEO_MODULES		X	X
2149
# FC4_MODULES		X	X
2150
# IRDA_MODULES		X	X
2151
# USB_MODULES			X
2152
2153
.PHONY: binary binary-arch binary-indep clean debian modules modules_image
(-)linux-2.4.26/drivers/CVS/Entries (+11 lines)
Line 0 Link Here
1
D/cdrom////
2
D/char////
3
D/i2c////
4
D/ide////
5
D/input////
6
D/net////
7
D/pci////
8
D/sound////
9
D/usb////
10
D/video////
11
D/xbox////
(-)linux-2.4.26/drivers/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers
(-)linux-2.4.26/drivers/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/block/Config.in (+1 lines)
Lines 41-46 Link Here
41
dep_tristate 'Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL)' CONFIG_BLK_DEV_UMEM $CONFIG_PCI $CONFIG_EXPERIMENTAL
41
dep_tristate 'Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL)' CONFIG_BLK_DEV_UMEM $CONFIG_PCI $CONFIG_EXPERIMENTAL
42
42
43
tristate 'Loopback device support' CONFIG_BLK_DEV_LOOP
43
tristate 'Loopback device support' CONFIG_BLK_DEV_LOOP
44
tristate 'Klaus Knoppers cloop device' CONFIG_BLK_DEV_CLOOP
44
dep_tristate 'Network block device support' CONFIG_BLK_DEV_NBD $CONFIG_NET
45
dep_tristate 'Network block device support' CONFIG_BLK_DEV_NBD $CONFIG_NET
45
46
46
tristate 'RAM disk support' CONFIG_BLK_DEV_RAM
47
tristate 'RAM disk support' CONFIG_BLK_DEV_RAM
(-)linux-2.4.26/drivers/block/Makefile (+1 lines)
Lines 33-37 Link Here
33
obj-$(CONFIG_BLK_DEV_NBD)	+= nbd.o
33
obj-$(CONFIG_BLK_DEV_NBD)	+= nbd.o
34
34
35
subdir-$(CONFIG_PARIDE) += paride
35
subdir-$(CONFIG_PARIDE) += paride
36
subdir-$(CONFIG_BLK_DEV_CLOOP)	+= cloop
36
37
37
include $(TOPDIR)/Rules.make
38
include $(TOPDIR)/Rules.make
(-)linux-2.4.26/drivers/block/cloop/Makefile (+14 lines)
Line 0 Link Here
1
#
2
# Makefile for the cloop device drivers.
3
#
4
5
O_TARGET := cloop.o
6
7
obj-y		:= compressed_loop.o
8
obj-m		:= $(O_TARGET)
9
10
export-objs =	compressed_loop.o
11
12
obj-$(CONFIG_BLK_DEV_CLOOP)      += cloop.o
13
14
include $(TOPDIR)/Rules.make
(-)linux-2.4.26/drivers/block/cloop/compressed_loop.c (+893 lines)
Line 0 Link Here
1
/*
2
 *  compressed_loop.c: Read-only compressed loop blockdevice
3
 *  hacked up by Rusty in 1999, extended and maintained by Klaus Knopper
4
 *
5
 *  cloop file looks like:
6
 *  [32-bit uncompressed block size: network order]
7
 *  [32-bit number of blocks (n_blocks): network order]
8
 *  [64-bit file offsets of start of blocks: network order]
9
 *    * (n_blocks + 1).
10
 * n_blocks of:
11
 *   [compressed block]
12
 *
13
 *  Inspired by loop.c by Theodore Ts'o, 3/29/93.
14
 *
15
 * Copyright 1999-2003 by Paul `Rusty' Russell & Klaus Knopper.
16
 * Redistribution of this file is permitted under the GNU Public License.
17
 *
18
 * CHANGES: (see CHANGELOG file)
19
 */
20
21
#define CLOOP_NAME "cloop"
22
#define CLOOP_VERSION "2.01"
23
#define CLOOP_MAX 8
24
25
/* Define this if you are using Greenshoe Linux */
26
/* #define REDHAT_KERNEL */
27
28
#include <linux/version.h>
29
#include <linux/module.h>
30
#include <linux/sched.h>
31
#include <linux/fs.h>
32
#include <linux/file.h>
33
#include <linux/stat.h>
34
#include <linux/errno.h>
35
#include <linux/major.h>
36
#include <linux/vmalloc.h>
37
#include <linux/slab.h>
38
#include <linux/devfs_fs_kernel.h>
39
#include <asm/semaphore.h>
40
#include <asm/div64.h> /* do_div() for 64bit division */
41
#include <asm/uaccess.h>
42
/* Use zlib_inflate from lib/zlib_inflate */
43
#include <linux/zutil.h>
44
#include <linux/loop.h>
45
// #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
46
// #include <linux/buffer_head.h>
47
// #endif
48
#include "compressed_loop.h"
49
50
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
51
EXPORT_NO_SYMBOLS;
52
#endif
53
54
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
55
/* New License scheme */
56
#ifdef MODULE_LICENSE
57
MODULE_LICENSE("GPL");
58
#endif
59
#endif
60
61
#ifndef MIN
62
#define MIN(x,y) ((x) < (y) ? (x) : (y))
63
#endif
64
65
#ifndef MAX
66
#define MAX(x,y) ((x) > (y) ? (x) : (y))
67
#endif
68
69
/* Use experimental major for now */
70
#define MAJOR_NR 240
71
72
#define DEVICE_NAME CLOOP_NAME
73
#define DEVICE_NR(device) (MINOR(device))
74
#define DEVICE_ON(device)
75
#define DEVICE_OFF(device)
76
#define DEVICE_NO_RANDOM
77
#define TIMEOUT_VALUE (6 * HZ)
78
79
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
80
#include <linux/blk.h>
81
#else
82
#include <linux/blkdev.h>
83
#include <linux/buffer_head.h>
84
#endif
85
86
#if 0
87
#define DEBUGP printk
88
#else
89
#define DEBUGP(format, x...)
90
#endif
91
92
/* One file can be opened at module insertion time */
93
/* insmod cloop file=/path/to/file */
94
static char *file=NULL;
95
MODULE_PARM(file, "s");
96
MODULE_PARM_DESC(file, "Initial cloop image file (full path) for /dev/cloop");
97
static struct file *initial_file=NULL;
98
99
struct cloop_device
100
{
101
 /* Copied straight from the file */
102
 struct cloop_head head;
103
104
 /* An array of offsets of compressed blocks within the file */
105
 loff_t *offsets;
106
107
 /* We buffer one uncompressed `block' */
108
 int buffered_blocknum;
109
 void *buffer;
110
 void *compressed_buffer;
111
112
 z_stream zstream;
113
114
 struct file   *backing_file;  /* associated file */
115
 struct inode  *backing_inode; /* for bmap */
116
117
 unsigned int underlying_blksize;
118
 int refcnt;
119
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
120
 int dev;
121
#else
122
 struct block_device *bdev;
123
#endif
124
 int isblkdev;
125
 struct semaphore clo_lock;
126
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
127
 struct gendisk *disk;
128
 request_queue_t *clo_queue;
129
#endif
130
};
131
132
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
133
static int cloop_sizes[CLOOP_MAX];
134
static int cloop_blksizes[CLOOP_MAX];
135
#endif
136
137
static struct cloop_device cloop_dev[CLOOP_MAX];
138
static char *cloop_name=CLOOP_NAME;
139
static const int max_cloop = CLOOP_MAX;
140
141
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
142
static devfs_handle_t devfs_handle;
143
#endif
144
145
#if (!(defined(CONFIG_ZLIB_INFLATE) || defined(CONFIG_ZLIB_INFLATE_MODULE))) /* Must be compiled into kernel. */
146
#error  "Invalid Kernel configuration. CONFIG_ZLIB_INFLATE support is needed for cloop."
147
#endif
148
149
static int uncompress(struct cloop_device *clo, char *dest, unsigned long *destLen,
150
                      char *source, unsigned long sourceLen)
151
{
152
 /* Most of this code can be found in fs/cramfs/uncompress.c */
153
 int err;
154
 clo->zstream.next_in = source;
155
 clo->zstream.avail_in = sourceLen;
156
 clo->zstream.next_out = dest;
157
 clo->zstream.avail_out = *destLen;
158
 err = zlib_inflateReset(&clo->zstream);
159
 if (err != Z_OK)
160
  {
161
   printk(KERN_ERR "%s: zlib_inflateReset error %d\n", cloop_name, err);
162
   zlib_inflateEnd(&clo->zstream); zlib_inflateInit(&clo->zstream);
163
  }
164
 err = zlib_inflate(&clo->zstream, Z_FINISH);
165
 *destLen = clo->zstream.total_out;
166
 if (err != Z_STREAM_END) return err;
167
 return Z_OK;
168
}
169
170
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
171
/* Get blocksize of underlying device */
172
static unsigned int get_blksize(int dev)
173
{
174
 unsigned int bs = BLOCK_SIZE;
175
 if (blksize_size[MAJOR(dev)])
176
  {
177
    bs = blksize_size[MAJOR(dev)][MINOR(dev)];
178
    if (!bs) bs = BLOCK_SIZE;
179
  }
180
 return bs;
181
}
182
#endif
183
184
/* This is more complicated than it looks. */
185
struct clo_read_data
186
{
187
 struct cloop_device *clo;
188
 char *data; /* We need to keep track of where we are in the buffer */
189
 int bsize;
190
};
191
192
/* We need this for do_generic_file_read() because the default function */
193
/* wants to read into user-space for an unknown reason. :-/ See loop.c. */
194
static int clo_read_actor(read_descriptor_t * desc, struct page *page,
195
                          unsigned long offset, unsigned long size)
196
{
197
 char *kaddr;
198
 struct clo_read_data *p = (struct clo_read_data*)desc->buf;
199
 unsigned long count = desc->count;
200
 if (size > count) size = count;
201
 kaddr = kmap(page);
202
 memcpy(p->data, kaddr + offset, size);
203
 kunmap(page);
204
 desc->count = count - size;
205
 desc->written += size;
206
 p->data += size;
207
 return size;
208
}
209
210
static size_t clo_read_from_file(struct cloop_device *clo, struct file *f, char *buf,
211
  loff_t pos, size_t buf_len)
212
{
213
 size_t buf_done=0;
214
 while (buf_done < buf_len)
215
  {
216
   size_t size = buf_len - buf_done;
217
   struct clo_read_data cd={ /* do_generic_file_read() needs this. */
218
           clo,              /* struct cloop_device *clo */
219
           (char *)(buf + buf_done), /* char *data */
220
           size};            /* Actual data size */
221
   read_descriptor_t desc;
222
   desc.written = 0;
223
   desc.count   = size;
224
   desc.buf     = (char*)&cd;
225
   desc.error   = 0;
226
#ifdef REDHAT_KERNEL /* Greenshoe Linux */
227
   do_generic_file_read(f, &pos, &desc, clo_read_actor, 0);
228
#else /* Normal Kernel */
229
   do_generic_file_read(f, &pos, &desc, clo_read_actor);
230
#endif
231
   if(desc.error||desc.written<=0)
232
    {
233
     int left = size - desc.written;
234
     if(left<0) left = 0; /* better safe than sorry */
235
     printk(KERN_ERR "%s: Read error at pos %Lu in file %s, %d bytes lost.\n",
236
            cloop_name, pos, file, left);
237
     memset(buf + buf_len - left, 0, left);
238
     break;
239
    }
240
   buf_done+=desc.written;
241
  }
242
 return buf_done;
243
}
244
245
/* This looks more complicated than it is */
246
static int load_buffer(struct cloop_device *clo, int blocknum)
247
{
248
 unsigned int buf_done = 0;
249
 unsigned long buflen;
250
 unsigned int buf_length;
251
 int ret;
252
253
 if(blocknum > ntohl(clo->head.num_blocks) || blocknum < 0)
254
  {
255
   printk(KERN_WARNING "%s: Invalid block number %d requested.\n",
256
                       cloop_name, blocknum);
257
   clo->buffered_blocknum = -1;
258
   return 0;
259
  }
260
261
 if (blocknum == clo->buffered_blocknum) return 1;
262
263
 /* Is there a ntohl for 64-bit values? */
264
 buf_length = be64_to_cpu(clo->offsets[blocknum+1]) - be64_to_cpu(clo->offsets[blocknum]);
265
266
/* Load one compressed block from the file. */
267
 clo_read_from_file(clo, clo->backing_file, (char *)clo->compressed_buffer,
268
                    be64_to_cpu(clo->offsets[blocknum]), buf_length);
269
270
 /* Do decompression into real buffer. */
271
 buflen = ntohl(clo->head.block_size);
272
273
 /* Do the uncompression */
274
 ret = uncompress(clo, clo->buffer, &buflen, clo->compressed_buffer,
275
                  buf_length);
276
 /* DEBUGP("cloop: buflen after uncompress: %ld\n",buflen); */
277
 if (ret != 0)
278
  {
279
   printk(KERN_ERR "%s: error %i uncompressing block %u %u/%lu/%u/%u "
280
          "%Lu-%Lu\n", cloop_name, ret, blocknum,
281
	  ntohl(clo->head.block_size), buflen, buf_length, buf_done,
282
	  be64_to_cpu(clo->offsets[blocknum]), be64_to_cpu(clo->offsets[blocknum+1]));
283
   clo->buffered_blocknum = -1;
284
   return 0;
285
  }
286
 clo->buffered_blocknum = blocknum;
287
 return 1;
288
}
289
290
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
291
static int make_clo_request(request_queue_t *q, int rw, struct buffer_head *bh)
292
#else
293
static int make_clo_request(request_queue_t *q, struct bio *bio)
294
#endif
295
{
296
 struct cloop_device *cloop;
297
 int status = 0;
298
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
299
 int cloop_num;
300
#endif
301
 unsigned int len;
302
 loff_t offset;
303
 char *dest;
304
305
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
306
 /* (possible) high memory conversion */
307
 bh = blk_queue_bounce(q,rw,bh);
308
#else
309
 int rw = bio_rw(bio);
310
 unsigned int vecnr;
311
 cloop = q->queuedata;
312
#endif
313
314
 /* quick sanity checks */
315
 if (rw != READ && rw != READA)
316
  {
317
   DEBUGP("do_clo_request: bad command\n");
318
   goto out;
319
  }
320
321
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
322
 cloop_num = MINOR(bh->b_rdev);
323
324
 if (cloop_num >= max_cloop)
325
  {
326
   DEBUGP("do_clo_request: invalid cloop minor\n");
327
   goto out;
328
  }
329
330
 cloop = &cloop_dev[cloop_num];
331
#endif
332
333
 if (!cloop->backing_file)
334
  {
335
   DEBUGP("do_clo_request: not connected to a file\n");
336
   goto out;
337
  }
338
339
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
340
 if (bh->b_rsector == -1)
341
  {
342
   DEBUGP("do_clo_request: bad sector requested\n");
343
   goto out;
344
  }
345
346
 down(&cloop->clo_lock);
347
 len        = bh->b_size;
348
 offset     = (loff_t)bh->b_rsector << 9;
349
 dest       = bh->b_data;
350
#else
351
 down(&cloop->clo_lock);
352
 offset     = (loff_t)bio->bi_sector << 9;
353
 for(vecnr=0; vecnr < bio->bi_vcnt; vecnr++)
354
  {
355
   struct bio_vec *bvec=&bio->bi_io_vec[vecnr];
356
   len = bvec->bv_len;
357
   dest= kmap(bvec->bv_page) + bvec->bv_offset;
358
#endif
359
360
  
361
 while(len > 0)
362
  {
363
   u_int32_t length_in_buffer;
364
   loff_t block_offset=offset;
365
  
366
   /* do_div (div64.h) returns the 64bit division remainder and  */
367
   /* puts the result in the first argument, i.e. block_offset   */
368
   /* becomes the blocknumber to load, and offset_in_buffer the  */
369
   /* position in the buffer */
370
   u_int32_t offset_in_buffer;
371
   offset_in_buffer = do_div(block_offset, ntohl(cloop->head.block_size));
372
 
373
   status=load_buffer(cloop,block_offset);
374
   if(!status) break; /* invalid data, leave inner loop, goto next request */
375
  
376
   /* Now, at least part of what we want will be in the buffer. */
377
   length_in_buffer = ntohl(cloop->head.block_size) - offset_in_buffer;
378
  
379
   if(length_in_buffer > len)
380
    {
381
/*     DEBUGP("Warning: length_in_buffer=%u > len=%u\n",
382
                        length_in_buffer,len); */
383
     length_in_buffer = len;
384
    }
385
386
   memcpy(dest, cloop->buffer + offset_in_buffer, length_in_buffer);
387
388
   dest   += length_in_buffer;
389
   len    -= length_in_buffer;
390
   offset += length_in_buffer;
391
  } /* while inner loop */
392
393
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
394
   kunmap(bvec->bv_page);
395
  } /* end for vecnr*/
396
#endif
397
398
 up(&cloop->clo_lock);
399
400
out:
401
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
402
 bh->b_end_io(bh,status);
403
#else
404
 bio_endio(bio, bio->bi_size,status==0);
405
#endif
406
 return 0;
407
}
408
409
/* Read header and offsets from already opened file */
410
static int clo_set_file(int cloop_num, struct file *file, char *filename)
411
{
412
 struct cloop_device *clo=&cloop_dev[cloop_num];
413
 struct inode *inode;
414
 char *bbuf=NULL;
415
 unsigned int i, offsets_read, total_offsets;
416
 unsigned long largest_block=0;
417
 int isblkdev;
418
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
419
 int dev;
420
#endif
421
 int error = 0;
422
423
 inode = file->f_dentry->d_inode;
424
 isblkdev=S_ISBLK(inode->i_mode)?1:0;
425
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
426
 dev=isblkdev?inode->i_rdev:inode->i_dev;
427
#endif
428
 if(!isblkdev&&!S_ISREG(inode->i_mode))
429
  {
430
   printk(KERN_ERR "%s: %s not a regular file or block device\n",
431
		   cloop_name, filename);
432
   error=-EBADF; goto error_release;
433
  }
434
435
 clo->backing_file = file;
436
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
437
 clo->dev = dev;
438
#endif
439
 clo->backing_inode= inode ;
440
441
 if(!isblkdev&&inode->i_size<sizeof(struct cloop_head))
442
  {
443
   printk(KERN_ERR "%s: %lu bytes (must be >= %u bytes)\n",
444
                   cloop_name, (unsigned long)inode->i_size,
445
		   (unsigned)sizeof(struct cloop_head));
446
   error=-EBADF; goto error_release;
447
  }
448
449
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
450
 if(isblkdev)
451
  {
452
   request_queue_t *q = bdev_get_queue(inode->i_bdev);
453
   blk_queue_max_sectors(clo->clo_queue, q->max_sectors);
454
   blk_queue_max_phys_segments(clo->clo_queue,q->max_phys_segments);
455
   blk_queue_max_hw_segments(clo->clo_queue, q->max_hw_segments);
456
   blk_queue_max_segment_size(clo->clo_queue, q->max_segment_size);
457
   blk_queue_segment_boundary(clo->clo_queue, q->seg_boundary_mask);
458
   blk_queue_merge_bvec(clo->clo_queue, q->merge_bvec_fn);
459
   clo->underlying_blksize = block_size(inode->i_bdev);
460
 }
461
else
462
   clo->underlying_blksize = inode->i_blksize;
463
#else
464
 /* Get initial block size out of device */
465
 clo->underlying_blksize = get_blksize(dev);
466
#endif
467
 DEBUGP("Underlying blocksize is %u\n", clo->underlying_blksize);
468
469
 bbuf = vmalloc(clo->underlying_blksize);
470
 if(!bbuf)
471
  {
472
   printk(KERN_ERR "%s: out of kernel mem for block buffer (%lu bytes)\n",
473
                   cloop_name, (unsigned long)clo->underlying_blksize);
474
   error=-ENOMEM; goto error_release;
475
  }
476
 total_offsets = 1; /* Dummy total_offsets: will be filled in first time around */
477
 for (i = 0, offsets_read = 0; offsets_read < total_offsets; i++)
478
  {
479
   unsigned int offset = 0, num_readable;
480
481
   /* Kernel 2.4 version */
482
   size_t bytes_read = clo_read_from_file(clo, file, bbuf,
483
                                          i*clo->underlying_blksize,
484
                                          clo->underlying_blksize);
485
   if(bytes_read != clo->underlying_blksize) { error=-EBADF; goto error_release; }
486
487
   /* Header will be in block zero */
488
   if(i==0)
489
    {
490
     memcpy(&clo->head, bbuf, sizeof(struct cloop_head));
491
     offset = sizeof(struct cloop_head);
492
     if (ntohl(clo->head.block_size) % 512 != 0)
493
      {
494
       printk(KERN_ERR "%s: blocksize %u not multiple of 512\n",
495
              cloop_name, ntohl(clo->head.block_size));
496
       error=-EBADF; goto error_release;
497
      }
498
499
     if (clo->head.preamble[0x0B]!='V'||clo->head.preamble[0x0C]<'1')
500
      {
501
       printk(KERN_ERR "%s: Cannot read old 32-bit (version 0.68) images, "
502
		       "please use an older version of %s for this file.\n",
503
		       cloop_name, cloop_name);
504
       error=-EBADF; goto error_release;
505
      }
506
507
     if (clo->head.preamble[0x0C]<'2')
508
      {
509
       printk(KERN_ERR "%s: Cannot read old architecture-dependent "
510
		       "(format <= 1.0) images, please use an older "
511
		       "version of %s for this file.\n",
512
		       cloop_name, cloop_name);
513
       error=-EBADF; goto error_release;
514
      }
515
516
     total_offsets=ntohl(clo->head.num_blocks)+1;
517
518
     if (!isblkdev && (sizeof(struct cloop_head)+sizeof(loff_t)*
519
                       total_offsets > inode->i_size))
520
      {
521
       printk(KERN_ERR "%s: file too small for %u blocks\n",
522
              cloop_name, ntohl(clo->head.num_blocks));
523
       error=-EBADF; goto error_release;
524
      }
525
526
     clo->offsets = vmalloc(sizeof(loff_t) * total_offsets);
527
     if (!clo->offsets)
528
      {
529
       printk(KERN_ERR "%s: out of kernel mem for offsets\n", cloop_name);
530
       error=-ENOMEM; goto error_release;
531
      }
532
    }
533
534
   num_readable = MIN(total_offsets - offsets_read,
535
                      (clo->underlying_blksize - offset) 
536
                      / sizeof(loff_t));
537
   memcpy(&clo->offsets[offsets_read], bbuf+offset, num_readable * sizeof(loff_t));
538
   offsets_read += num_readable;
539
  }
540
541
  { /* Search for largest block rather than estimate. KK. */
542
   int i;
543
   for(i=0;i<total_offsets-1;i++)
544
    {
545
     loff_t d=be64_to_cpu(clo->offsets[i+1]) - be64_to_cpu(clo->offsets[i]);
546
     largest_block=MAX(largest_block,d);
547
    }
548
   printk("%s: %s: %u blocks, %u bytes/block, largest block is %lu bytes.\n",
549
          cloop_name, filename, ntohl(clo->head.num_blocks),
550
          ntohl(clo->head.block_size), largest_block);
551
  }
552
553
/* Combo kmalloc used too large chunks (>130000). */
554
 clo->buffer = vmalloc(ntohl(clo->head.block_size));
555
 if(!clo->buffer)
556
  {
557
   printk(KERN_ERR "%s: out of memory for buffer %lu\n",
558
          cloop_name, (unsigned long) ntohl(clo->head.block_size));
559
   error=-ENOMEM; goto error_release_free;
560
  }
561
562
 clo->compressed_buffer = vmalloc(largest_block);
563
564
 if(!clo->compressed_buffer)
565
  {
566
   printk(KERN_ERR "%s: out of memory for compressed buffer %lu\n",
567
          cloop_name, largest_block);
568
   error=-ENOMEM; goto error_release_free_buffer;
569
  }
570
 clo->zstream.workspace = vmalloc(zlib_inflate_workspacesize());
571
 if(!clo->zstream.workspace)
572
  {
573
   printk(KERN_ERR "%s: out of mem for zlib working area %u\n",
574
          cloop_name, zlib_inflate_workspacesize());
575
   error=-ENOMEM; goto error_release_free_all;
576
  }
577
 zlib_inflateInit(&clo->zstream);
578
579
 if(!isblkdev &&
580
    be64_to_cpu(clo->offsets[ntohl(clo->head.num_blocks)]) != inode->i_size)
581
  {
582
   printk(KERN_ERR "%s: final offset wrong (%Lu not %Lu)\n",
583
          cloop_name,
584
          be64_to_cpu(clo->offsets[ntohl(clo->head.num_blocks)]),
585
          inode->i_size);
586
   vfree(clo->zstream.workspace); clo->zstream.workspace=NULL;
587
   goto error_release_free_all;
588
  }
589
590
 clo->buffered_blocknum = -1;
591
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
592
 cloop_sizes[cloop_num] = ntohl(clo->head.num_blocks)
593
                      * ( ntohl(clo->head.block_size) / BLOCK_SIZE );
594
 /* this seems to be the maximum allowed blocksize (Kernel limit) */
595
 cloop_blksizes[cloop_num] = PAGE_SIZE;
596
#else
597
 set_capacity(clo->disk, (sector_t)(ntohl(clo->head.num_blocks)*(ntohl(clo->head.block_size)>>9)));
598
#endif
599
 return error;
600
601
error_release_free_all:
602
 vfree(clo->compressed_buffer);
603
 clo->compressed_buffer=NULL;
604
error_release_free_buffer:
605
 vfree(clo->buffer);
606
 clo->buffer=NULL;
607
error_release_free:
608
 vfree(clo->offsets);
609
 clo->offsets=NULL;
610
error_release:
611
 if(bbuf) vfree(bbuf);
612
 clo->backing_file=NULL;
613
 return error;
614
}
615
616
/* Code adapted from Theodore Ts'o's linux/drivers/block/loop.c */ 
617
/* Get file from ioctl arg (losetup) */
618
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
619
static int clo_set_fd(int cloop_num, struct file *clo_file, kdev_t dev,
620
		       unsigned int arg)
621
#else
622
static int clo_set_fd(int cloop_num, struct file *clo_file, struct block_device *bdev,
623
		       unsigned int arg)
624
#endif
625
{
626
 struct cloop_device *clo=&cloop_dev[cloop_num];
627
 struct file *file=NULL;
628
 int error = 0;
629
630
 /* Already an allocated file present */
631
 if(clo->backing_file) return -EBUSY;
632
 file = fget(arg); /* get filp struct from ioctl arg fd */
633
 if(!file) return -EBADF;
634
 error=clo_set_file(cloop_num,file,"losetup_file");
635
 if(error) fput(file);
636
 return error;
637
}
638
639
static int clo_clr_fd(int cloop_num, struct block_device *bdev)
640
{
641
 struct cloop_device *clo = &cloop_dev[cloop_num];
642
 struct file *filp = clo->backing_file;
643
644
 if(clo->refcnt > 1)	/* we needed one fd for the ioctl */
645
   return -EBUSY;
646
 if(filp==NULL) return -EINVAL;
647
 if(filp!=initial_file) fput(filp);
648
 else { filp_close(initial_file,0); initial_file=NULL; }
649
 clo->backing_file  = NULL;
650
 clo->backing_inode = NULL;
651
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
652
 cloop_sizes[cloop_num] = 0;
653
 cloop_blksizes[cloop_num] = 0;
654
#else
655
 invalidate_bdev(bdev, 0);
656
 set_capacity(clo->disk, 0);
657
#endif
658
 return 0;
659
}
660
661
static int clo_ioctl(struct inode *inode, struct file *file,
662
	unsigned int cmd, unsigned long arg)
663
{
664
	struct cloop_device *clo;
665
	int cloop_num, err=0;
666
667
	if (!inode) return -EINVAL;
668
	if (MAJOR(inode->i_rdev) != MAJOR_NR) {
669
		printk(KERN_WARNING "cloop_ioctl: pseudo-major != %d\n",
670
		       MAJOR_NR);
671
		return -ENODEV;
672
	}
673
	cloop_num = MINOR(inode->i_rdev);
674
	if (cloop_num >= max_cloop) return -ENODEV;
675
	clo = &cloop_dev[cloop_num];
676
	switch (cmd) { /* We use the same ioctls that loop does */
677
	case LOOP_SET_FD:
678
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
679
	 err = clo_set_fd(cloop_num, file, inode->i_rdev, arg);
680
#else
681
	 err = clo_set_fd(cloop_num, file, inode->i_bdev, arg);
682
#endif
683
	 break;
684
	case LOOP_CLR_FD:
685
	 err = clo_clr_fd(cloop_num, inode->i_bdev);
686
	 break;
687
        case LOOP_SET_STATUS:
688
        case LOOP_GET_STATUS:
689
	 err=0; break;
690
	default:
691
	 err = -EINVAL;
692
	}
693
	return err;
694
}
695
696
697
static int clo_open(struct inode *inode, struct file *file)
698
{
699
 int cloop_num;
700
 if(!inode) return -EINVAL;
701
702
 if(MAJOR(inode->i_rdev) != MAJOR_NR)
703
  {
704
   printk(KERN_WARNING "%s: pseudo-major != %d\n", cloop_name, MAJOR_NR);
705
   return -ENODEV;
706
  }
707
708
 cloop_num=MINOR(inode->i_rdev);
709
 if(cloop_num >= max_cloop) return -ENODEV;
710
711
 /* Allow write open for ioctl, but not for mount. */
712
 /* losetup uses write-open and flags=0x8002 to set a new file */
713
 if((file->f_mode & FMODE_WRITE) && !(file->f_flags & 0x2))
714
  {
715
   printk(KERN_WARNING "%s: Can't open device read-write\n", cloop_name);
716
   return -EROFS;
717
  }
718
719
 cloop_dev[cloop_num].refcnt+=1;
720
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
721
 MOD_INC_USE_COUNT;
722
#endif
723
 return 0;
724
}
725
726
static int clo_close(struct inode *inode, struct file *file)
727
{
728
 int cloop_num, err=0;
729
730
 if(!inode) return 0;
731
732
 if(MAJOR(inode->i_rdev) != MAJOR_NR)
733
  {
734
   printk(KERN_WARNING "%s: pseudo-major != %d\n", cloop_name, MAJOR_NR);
735
   return 0;
736
  }
737
738
 cloop_num=MINOR(inode->i_rdev);
739
 if(cloop_num >= max_cloop) return 0;
740
741
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
742
 err = fsync_dev(inode->i_rdev);
743
#endif
744
 cloop_dev[cloop_num].refcnt-=1;
745
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
746
 MOD_DEC_USE_COUNT;
747
#endif
748
 return err;
749
}
750
751
static struct block_device_operations clo_fops =
752
{
753
        owner:		THIS_MODULE,
754
        open:           clo_open,
755
        release:        clo_close,
756
        ioctl:          clo_ioctl
757
};
758
759
static int cloop_init(void)
760
{
761
 int i, error=0;
762
 printk("%s: Initializing %s v"CLOOP_VERSION"\n", cloop_name, cloop_name);
763
764
 for(i=0;i<max_cloop;i++)
765
  {
766
   memset(&cloop_dev[i],0,sizeof(struct cloop_device));
767
   init_MUTEX(&cloop_dev[i].clo_lock);
768
  }
769
770
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
771
 if(devfs_register_blkdev(MAJOR_NR, cloop_name, &clo_fops))
772
#else
773
 if(register_blkdev(MAJOR_NR, cloop_name))
774
#endif
775
  {
776
   printk(KERN_WARNING "%s: Unable to get major %d for cloop\n",
777
          cloop_name, MAJOR_NR);
778
   return -EINVAL;
779
  }
780
781
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
782
 blk_size[MAJOR_NR] = cloop_sizes;
783
 blksize_size[MAJOR_NR] = cloop_blksizes;
784
 blk_queue_make_request(BLK_DEFAULT_QUEUE(MAJOR_NR), make_clo_request);
785
786
 for (i=0;i<max_cloop;i++) register_disk(NULL,MKDEV(MAJOR_NR,i),1,&clo_fops,0);
787
788
 devfs_handle = devfs_mk_dir(NULL, "cloop", NULL);
789
 devfs_register_series(devfs_handle, "%u", max_cloop, DEVFS_FL_DEFAULT,
790
		 MAJOR_NR, 0,
791
		 S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP,
792
		 &clo_fops, NULL);
793
#else
794
 devfs_mk_dir("cloop");
795
 for(i=0; i<max_cloop; i++) 
796
   if(!(cloop_dev[i].disk = alloc_disk(1))) goto out_disks;
797
 for(i=0; i<max_cloop; i++)
798
  {
799
   struct cloop_device *clo = &cloop_dev[i];
800
   clo->clo_queue = blk_alloc_queue(GFP_KERNEL);
801
   if(!clo->clo_queue) goto out_mem;
802
   blk_queue_make_request(clo->clo_queue, make_clo_request);
803
   clo->disk->queue = clo->clo_queue;
804
   clo->clo_queue->queuedata = clo;
805
   clo->disk->queue = clo->clo_queue;
806
   clo->disk->major = MAJOR_NR;
807
   clo->disk->first_minor = i;
808
   clo->disk->fops = &clo_fops;
809
   sprintf(clo->disk->disk_name, "%s%d", cloop_name, i);
810
   sprintf(clo->disk->devfs_name, "%s/%d", cloop_name, i);
811
   clo->disk->private_data = clo;
812
   add_disk(clo->disk);
813
  }
814
#endif
815
816
 printk(KERN_INFO "cloop: loaded (max %d devices)\n", max_cloop);
817
818
 if(file) /* global file name for first cloop-Device is a module option string. */
819
  {
820
   initial_file=filp_open(file,0x00,0x00);
821
   if(initial_file==NULL||IS_ERR(initial_file))
822
    {
823
     printk(KERN_ERR
824
            "%s: Unable to get file %s for cloop device\n",
825
            cloop_name, file);
826
     return -EINVAL;
827
    }
828
   error=clo_set_file(0,initial_file,file);
829
   if(error) { i=max_cloop; goto out_mem; }
830
  }
831
832
 return 0;
833
834
out_mem:
835
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
836
 while (i--) blk_put_queue(cloop_dev[i].clo_queue);
837
 i = max_cloop;
838
out_disks:
839
 while (i--) { put_disk(cloop_dev[i].disk); cloop_dev[i].disk=NULL; }
840
#endif
841
 unregister_blkdev(MAJOR_NR,cloop_name);
842
/* error_filp_close: */
843
 if(initial_file) filp_close(initial_file,0); initial_file=NULL;
844
 cloop_dev[0].backing_file=NULL;
845
 return error;
846
}
847
848
static void cloop_exit(void) 
849
{
850
 int i;
851
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
852
 if(devfs_unregister_blkdev(MAJOR_NR, cloop_name) != 0)
853
#else
854
 devfs_remove(cloop_name);
855
 if(unregister_blkdev(MAJOR_NR, cloop_name) != 0)
856
#endif
857
   printk(KERN_WARNING "%s: cannot unregister block device\n", cloop_name);
858
 for(i=0;i<max_cloop;i++)
859
  {
860
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
861
   del_gendisk(cloop_dev[i].disk);
862
   blk_put_queue(cloop_dev[i].clo_queue);
863
   put_disk(cloop_dev[i].disk);
864
#endif
865
   if(cloop_dev[i].offsets) vfree(cloop_dev[i].offsets);
866
   if(cloop_dev[i].buffer)  vfree(cloop_dev[i].buffer);
867
   if(cloop_dev[i].compressed_buffer) vfree(cloop_dev[i].compressed_buffer);
868
   zlib_inflateEnd(&cloop_dev[i].zstream);
869
   if(cloop_dev[i].zstream.workspace) vfree(cloop_dev[i].zstream.workspace);
870
   if(cloop_dev[i].backing_file && cloop_dev[i].backing_file!=initial_file)
871
    {
872
     fput(cloop_dev[i].backing_file);
873
    }
874
  }
875
 if(initial_file) filp_close(initial_file,0);
876
 printk("%s: unloaded.\n", cloop_name);
877
}
878
879
/* The cloop init and exit function registration (especially needed for Kernel 2.6) */
880
module_init(cloop_init);
881
module_exit(cloop_exit);
882
883
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
884
#include <linux/vermagic.h>
885
#include <linux/compiler.h>
886
887
MODULE_INFO(vermagic, VERMAGIC_STRING);
888
889
static const char __module_depends[]
890
__attribute_used__
891
__attribute__((section(".modinfo"))) =
892
"depends=";
893
#endif
(-)linux-2.4.26/drivers/block/cloop/compressed_loop.h (+23 lines)
Line 0 Link Here
1
#ifndef _COMPRESSED_LOOP_H
2
#define _COMPRESSED_LOOP_H
3
4
#define CLOOP_HEADROOM 128
5
6
/* The cloop header usually looks like this:          */
7
/* #!/bin/sh                                          */
8
/* #V2.00 Format                                      */
9
/* ...padding up to CLOOP_HEADROOM...                 */
10
/* block_size (32bit number, network order)           */
11
/* num_blocks (32bit number, network order)           */
12
13
struct cloop_head
14
{
15
	char preamble[CLOOP_HEADROOM];
16
	u_int32_t block_size;
17
	u_int32_t num_blocks;
18
};
19
20
/* data_index (num_blocks 64bit pointers, network order)...      */
21
/* compressed data (gzip block compressed format)...             */
22
23
#endif /*_COMPRESSED_LOOP_H*/
(-)linux-2.4.26/drivers/cdrom/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)linux-2.4.26/drivers/cdrom/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/cdrom
(-)linux-2.4.26/drivers/cdrom/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/char/CVS/Entries (+2 lines)
Line 0 Link Here
1
/pc_keyb.c/1.10/Sun Sep 14 11:13:48 2003//
2
D
(-)linux-2.4.26/drivers/char/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/char
(-)linux-2.4.26/drivers/char/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/char/pc_keyb.c (-2 / +15 lines)
Lines 806-811 Link Here
806
	int status;
806
	int status;
807
807
808
	/*
808
	/*
809
	 * This is not really IA-64 specific.  Probably ought to be done on all platforms
810
	 * that are (potentially) legacy-free.
811
	 */
812
	if (kbd_read_status() == 0xff && kbd_read_input() == 0xff) {
813
		kbd_exists = 0;
814
		return "No keyboard controller preset";
815
	}
816
817
	/*
809
	 * Test the keyboard interface.
818
	 * Test the keyboard interface.
810
	 * This seems to be the only way to get it going.
819
	 * This seems to be the only way to get it going.
811
	 * If the test is successful a x55 is placed in the input buffer.
820
	 * If the test is successful a x55 is placed in the input buffer.
Lines 898-908 Link Here
898
907
899
void __init pckbd_init_hw(void)
908
void __init pckbd_init_hw(void)
900
{
909
{
901
	if (!kbd_controller_present()) {
910
911
/*
912
 	if (!kbd_controller_present()) {
902
		kbd_exists = 0;
913
		kbd_exists = 0;
903
		return;
914
		return;
904
	}
915
	}
905
916
*/
906
	kbd_request_region();
917
	kbd_request_region();
907
918
908
	/* Flush any pending input. */
919
	/* Flush any pending input. */
Lines 912-917 Link Here
912
		char *msg = initialize_kbd();
923
		char *msg = initialize_kbd();
913
		if (msg)
924
		if (msg)
914
			printk(KERN_WARNING "initialize_kbd: %s\n", msg);
925
			printk(KERN_WARNING "initialize_kbd: %s\n", msg);
926
		if (!kbd_exists)
927
			return;
915
	}
928
	}
916
929
917
#if defined CONFIG_PSMOUSE
930
#if defined CONFIG_PSMOUSE
(-)linux-2.4.26/drivers/i2c/CVS/Entries (+5 lines)
Line 0 Link Here
1
/Makefile/1.8/Wed Feb 18 23:45:57 2004//
2
/extsmi.c/1.4/Wed Dec 10 00:18:28 2003//
3
/i2c-xbox.c/1.2/Thu Mar  6 22:51:42 2003//
4
/Config.in/1.10/Thu Apr 15 13:57:48 2004//
5
D
(-)linux-2.4.26/drivers/i2c/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/i2c
(-)linux-2.4.26/drivers/i2c/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/i2c/Config.in (+5 lines)
Lines 63-67 Link Here
63
63
64
   dep_tristate 'I2C device interface' CONFIG_I2C_CHARDEV $CONFIG_I2C
64
   dep_tristate 'I2C device interface' CONFIG_I2C_CHARDEV $CONFIG_I2C
65
   dep_tristate 'I2C /proc interface (required for hardware sensors)' CONFIG_I2C_PROC $CONFIG_I2C $CONFIG_SYSCTL
65
   dep_tristate 'I2C /proc interface (required for hardware sensors)' CONFIG_I2C_PROC $CONFIG_I2C $CONFIG_SYSCTL
66
   if [ "$CONFIG_XBOX" = "y" ]; then
67
      dep_tristate 'I2C XBOX' CONFIG_I2C_XBOX $CONFIG_I2C
68
      dep_tristate '  I2C XBOX EXTSMI' CONFIG_I2C_EXTSMI $CONFIG_I2C_XBOX
69
   fi
70
66
fi
71
fi
67
endmenu
72
endmenu
(-)linux-2.4.26/drivers/i2c/Makefile (-1 / +3 lines)
Lines 6-12 Link Here
6
6
7
export-objs	:= i2c-core.o i2c-algo-bit.o i2c-algo-pcf.o \
7
export-objs	:= i2c-core.o i2c-algo-bit.o i2c-algo-pcf.o \
8
		   i2c-algo-ite.o i2c-algo-sibyte.o i2c-algo-sgi.o \
8
		   i2c-algo-ite.o i2c-algo-sibyte.o i2c-algo-sgi.o \
9
		   i2c-proc.o
9
		   i2c-proc.o i2c-xbox.o
10
10
11
obj-$(CONFIG_I2C)		+= i2c-core.o
11
obj-$(CONFIG_I2C)		+= i2c-core.o
12
obj-$(CONFIG_I2C_CHARDEV)	+= i2c-dev.o
12
obj-$(CONFIG_I2C_CHARDEV)	+= i2c-dev.o
Lines 25-30 Link Here
25
obj-$(CONFIG_I2C_ALGO_SIBYTE)	+= i2c-algo-sibyte.o i2c-sibyte.o
25
obj-$(CONFIG_I2C_ALGO_SIBYTE)	+= i2c-algo-sibyte.o i2c-sibyte.o
26
obj-$(CONFIG_I2C_MAX1617)	+= i2c-max1617.o
26
obj-$(CONFIG_I2C_MAX1617)	+= i2c-max1617.o
27
obj-$(CONFIG_I2C_ALGO_SGI)	+= i2c-algo-sgi.o
27
obj-$(CONFIG_I2C_ALGO_SGI)	+= i2c-algo-sgi.o
28
obj-$(CONFIG_I2C_XBOX)		+= i2c-xbox.o
29
obj-$(CONFIG_I2C_EXTSMI)	+= extsmi.o
28
30
29
# This is needed for automatic patch generation: sensors code starts here
31
# This is needed for automatic patch generation: sensors code starts here
30
# This is needed for automatic patch generation: sensors code ends here
32
# This is needed for automatic patch generation: sensors code ends here
(-)linux-2.4.26/drivers/i2c/extsmi.c (+269 lines)
Line 0 Link Here
1
/**
2
 * Driver that handles the EXTSMI# interrupt on the xbox.
3
 * Makes it possible to use the eject-button without the xbox rebooting...
4
 *
5
 * smbus-command sequence to prevent reboot from cromwell.
6
 *
7
 * Changelog:
8
 *  2003-01-14 Anders Gustafsson <andersg@0x63.nu>
9
 *             initial version
10
 *  2003-02-08 Milosch Meriac <xboxlinux@meriac.de>
11
 *             rewrote debug macros because of compiler errors
12
 *
13
 * Todo: add errorhandling!
14
 *
15
 */
16
17
18
19
20
#include <linux/kernel.h>
21
#include <linux/module.h>
22
/*#include <linux/interrupt.h>*/
23
#include <linux/init.h>
24
#include <asm/io.h>
25
26
#include <linux/i2c.h>
27
28
29
30
/* FIXME! -> .h */
31
32
#define PIC_ADDRESS 0x10
33
34
#define SMC_CMD_TRAY_STATE 0x03
35
#define SMC_CMD_EJECT 0x0C
36
#define SMC_CMD_INTERRUPT_REASON 0x11
37
#define SMC_CMD_RESET_ON_EJECT 0x19
38
#define SMC_CMD_LED_MODE 0x07
39
#define SMC_CMD_LED_REGISTER 0x08
40
41
#define SMC_SUBCMD_EJECT_EJECT 0x00
42
#define SMC_SUBCMD_EJECT_LOAD 0x01
43
#define SMC_SUBCMD_RESET_ON_EJECT_ENABLE 0x00
44
#define SMC_SUBCMD_RESET_ON_EJECT_DISABLE 0x01
45
46
/* interrupt causes */
47
#define POWERDOWN_MASK (1<<0)
48
#define TRAYCLOSED_MASK (1<<1)
49
#define TRAYOPENING_MASK (1<<2)
50
#define AVPLUGGED_MASK (1<<3)
51
#define AVUNPLUGGED_MASK (1<<4)
52
#define TRAYBUTTON_MASK (1<<5)
53
#define TRAYCLOSING_MASK (1<<6)
54
#define UNKNOWN_MASK (1<<7)
55
56
#define IRQ 12
57
#define DRIVER_NAME "extsmi"
58
59
#ifdef DEBUG
60
#	define SMI_DEBUG_OUT(a...) printk(a)
61
#else
62
#	define SMI_DEBUG_OUT(a...)
63
#endif
64
65
/* just some crap */
66
static char dev[]="test";
67
68
#define BASE 0x8000
69
70
/* Power Management 1 Enable Register */
71
#define PM02 (BASE+0x02)
72
73
/* Power Management 1 Control Register */
74
#define PM04 (BASE+0x04)
75
76
/* ACPI GP Status Register */
77
#define PM20 (BASE+0x20)
78
79
/* ACPI GP Enable Register */
80
#define PM22 (BASE+0x22)
81
# define EXTSMI_EN_MASK 0x0002
82
83
/* Global SMI Enable Register */
84
#define PM2A (BASE+0x2A)
85
86
87
static DECLARE_MUTEX(extsmi_sem);
88
static DECLARE_COMPLETION(extsmi_exited);
89
static int extsmi_pid=0;
90
91
static int extsmi_attach_adapter(struct i2c_adapter *adap);
92
93
static struct i2c_driver extsmi_driver = {
94
	.name		= "i2c xbox-extsmi driver",
95
	.id		= I2C_DRIVERID_I2CDEV,
96
	.flags		= I2C_DF_DUMMY,
97
	.attach_adapter	= extsmi_attach_adapter,
98
};
99
100
static struct i2c_adapter *xbox_adap;
101
102
static struct i2c_client extsmi_client = {
103
	.name		= "I2C xbox-extsmi client",
104
	.id		= 1,
105
	.flags		= 0,
106
	.addr		= PIC_ADDRESS,
107
	.adapter	= NULL,
108
	.driver		= &extsmi_driver,
109
};
110
111
112
static int extsmi_attach_adapter(struct i2c_adapter *adap)
113
{
114
	int i;
115
116
	if ((i = i2c_adapter_id(adap)) < 0) {
117
		printk("i2c-dev.o: Unknown adapter ?!?\n");
118
		return -ENODEV;
119
	}
120
121
	/* FIXME! XXX! This is bogus, will break with more than one adaptor */
122
	if (! xbox_adap) {
123
		xbox_adap = adap;
124
		extsmi_client.adapter=adap;
125
		printk(KERN_INFO DRIVER_NAME ": Using '%s'!\n",adap->name);
126
	} else {
127
		/* This is actually a detach_adapter call! */
128
		xbox_adap=NULL;
129
	}
130
131
	return 0;
132
}
133
134
135
136
static void extsmi_interupt(int i,void *dev,struct pt_regs *r){
137
	int reason;
138
139
	reason=inw(0x8020);
140
	outw(reason,0x8020); /* ack  IS THIS NEEDED? */
141
	if(reason&0x2){
142
		SMI_DEBUG_OUT("EXTSMI#\n");
143
144
		/* wake up thread */
145
		up(&extsmi_sem);
146
		SMI_DEBUG_OUT("Interrupt: 0x%02x\n",reason);
147
	}
148
/*
149
	reason=inw(0x8020);
150
	SMI_DEBUG_OUT("Interrupt %d 0x%04x\n",hits,reason);
151
*/
152
153
/*	 Stop irq-storm
154
	if(hits==400){
155
		free_irq(12,dev);
156
	}
157
*/
158
}
159
160
161
162
/**
163
 * Process a event. This is run i process-context.
164
 */
165
static void extsmi_process(void){
166
	int reason;
167
	
168
	if(extsmi_client.adapter==NULL){
169
		printk("bh with no client!?\n");
170
		return;
171
	}
172
	
173
	reason=i2c_smbus_read_byte_data(&extsmi_client,SMC_CMD_INTERRUPT_REASON);
174
	if(reason&TRAYBUTTON_MASK){ /* Tray button! Respond to prevent reboot! */
175
		i2c_smbus_write_byte_data(&extsmi_client,0x0d,0x04);
176
		i2c_smbus_write_byte_data(&extsmi_client,0x00,0x0c);
177
		SMI_DEBUG_OUT("Button<tm> pressed\n");
178
179
		/* eject? */
180
#ifndef NO_EJECT
181
		i2c_smbus_write_byte_data(&extsmi_client, SMC_CMD_RESET_ON_EJECT, SMC_SUBCMD_RESET_ON_EJECT_DISABLE);
182
		i2c_smbus_write_byte_data(&extsmi_client, SMC_CMD_EJECT, SMC_SUBCMD_EJECT_EJECT);
183
#endif
184
	}
185
	
186
	SMI_DEBUG_OUT("bh-reason: 0x%02x\n",reason);
187
}
188
189
190
static int extsmi_thread(void *data){
191
192
	daemonize();
193
	reparent_to_init();
194
	strcpy(current->comm, "xbox_extsmi");
195
196
197
	do {
198
		extsmi_process();
199
		down_interruptible(&extsmi_sem);
200
	} while (!signal_pending(current));
201
	
202
         complete_and_exit(&extsmi_exited, 0);
203
204
}
205
206
207
static int extsmi_init(void){
208
	int res;
209
	int pid;
210
	
211
        pid = kernel_thread(extsmi_thread, NULL,
212
			    CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
213
	if (pid < 0) {
214
		return pid;
215
	}
216
217
	extsmi_pid = pid;
218
219
	if ((res = i2c_add_driver(&extsmi_driver))) {
220
		printk(KERN_ERR DRIVER_NAME ": Driver registration failed, module not inserted.\n");
221
		/* FIXME! CLEANUP!! */
222
		return res;
223
	}
224
225
	/* this shuts a lot of interrupts off! */
226
	outw(inw(0x80e2)&0xf8c7,0x80e2);
227
	outw(0,0x80ac);
228
	outb(0,0x8025);
229
	outw(EXTSMI_EN_MASK,PM22); /* enable the EXTSMI# interupt! */
230
	outw(0,PM02);
231
//	outw(0,0x80d8);  // andy@warmcat.com 2003-02-26  removed as this kills RGB out and serves no other purpose
232
233
	outb(1,PM04); /* enable sci interrupts! */
234
235
	/* FIXME! retval! */
236
	request_irq(IRQ,extsmi_interupt,SA_INTERRUPT|SA_SHIRQ /* |SA_SAMPLE_RANDOM */,
237
		    "xbox_extsmi",dev);
238
239
	
240
	/* LED blinking
241
	  i2c_smbus_write_byte_data(&i2cxbox_client,SMC_CMD_LED_MODE,1);
242
	  i2c_smbus_write_byte_data(&i2cxbox_client,SMC_CMD_LED_REGISTER,0xc6);
243
	*/
244
245
	return 0;
246
}
247
248
static void extsmi_exit(void){
249
	int res;
250
	free_irq(IRQ,dev);
251
252
	/* Kill the thread */
253
	res = kill_proc(extsmi_pid, SIGTERM, 1);
254
	wait_for_completion(&extsmi_exited);
255
256
	if ((res = i2c_del_driver(&extsmi_driver))) {
257
		printk(KERN_ERR DRIVER_NAME ": Driver deregistration failed, "
258
		       "module not removed.\n");
259
		return;
260
	}
261
	
262
	return;
263
}
264
265
module_init(extsmi_init);
266
module_exit(extsmi_exit);
267
268
MODULE_AUTHOR("Anders Gustafsson <andersg@0x63.nu>");
269
MODULE_LICENSE("GPL");
(-)linux-2.4.26/drivers/i2c/i2c-xbox.c (+524 lines)
Line 0 Link Here
1
/*
2
    i2c-xbox.c - Part of lm_sensors, Linux kernel modules for hardware
3
              monitoring
4
5
    Copyright (c) 1999-2002 Edgar Hucek <hostmaster@ed-soft.at>
6
7
    Shamelessly ripped from i2c-xbox.c:
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
   Supports XBOX, Note: we assume there can only be one device, with one SMBus interface.
26
*/
27
28
#include <linux/version.h>
29
#include <linux/module.h>
30
#include <linux/pci.h>
31
#include <asm/io.h>
32
#include <linux/kernel.h>
33
#include <linux/stddef.h>
34
#include <linux/sched.h>
35
#include <linux/ioport.h>
36
#include <linux/i2c.h>
37
#include <linux/init.h>
38
39
#include <linux/sched.h>
40
#include <linux/errno.h>  /* error codes */
41
#include <linux/tqueue.h>
42
#include <linux/interrupt.h> /* intr_count */
43
#include <linux/xbox.h>
44
#include <linux/delay.h>
45
46
47
#define GS_ABRT_STS (1 << 0)
48
#define GS_COL_STS (1 << 1)
49
#define GS_PRERR_STS (1 << 2)
50
#define GS_HST_STS (1 << 3)
51
#define GS_IRQ_ON (1 << 4)
52
#define GS_HCYC_STS (1 << 4)
53
#define GS_TO_STS (1 << 5)
54
#define GS_SMB_STS (1 << 11)
55
56
#define SMB_GCTL_HOST_START      (1 << 3)
57
#define SMB_GCTL_HOST_INTERRUPT  (1 << 4)
58
#define SMB_GCTL_ABORT           (1 << 5)
59
#define SMB_GCTL_SNOOP           (1 << 8)
60
#define SMB_GCTL_SLAVE_INTERRUPT (1 << 9)
61
#define SMB_GCTL_ALERT_INTERRUPT (1 << 10)
62
63
#define GS_CLEAR_STS (GS_ABRT_STS | GS_COL_STS | GS_PRERR_STS | \
64
  GS_HCYC_STS | GS_TO_STS)
65
66
#define GE_CYC_TYPE_MASK (7)
67
#define GE_HOST_STC (1 << 3)
68
#define GE_ABORT (1 << 5)
69
70
#define I2C_HW_SMBUS_XBOX   0x05
71
#define SMBGCFG   0x041          /* mh */
72
#define SMBBA     0x058           /* mh */
73
74
struct sd {
75
    const unsigned short vendor;
76
    const unsigned short device;
77
    const unsigned short function;
78
    const char* name;
79
    int amdsetup:1;
80
};
81
82
static struct sd supported[] = {
83
    {PCI_VENDOR_ID_NVIDIA, 0x01b4, 1, "nVidia XBOX nForce", 0},
84
    {0, 0, 0}
85
};
86
87
/* XBOX SMBus address offsets */
88
#define SMB_ADDR_OFFSET        0x04
89
#define SMB_IOSIZE             8
90
#define SMB_GLOBAL_STATUS      (0x0 + xbox_smba)
91
#define SMB_GLOBAL_ENABLE      (0x2 + xbox_smba)
92
#define SMB_HOST_ADDRESS       (0x4 + xbox_smba)
93
#define SMB_HOST_DATA          (0x6 + xbox_smba)
94
#define SMB_HOST_COMMAND       (0x8 + xbox_smba)
95
96
97
98
99
100
/* Other settings */
101
#define MAX_TIMEOUT 500
102
103
/* XBOX constants */
104
#define XBOX_QUICK        0x00
105
#define XBOX_BYTE         0x01
106
#define XBOX_BYTE_DATA    0x02
107
#define XBOX_WORD_DATA    0x03
108
#define XBOX_PROCESS_CALL 0x04
109
#define XBOX_BLOCK_DATA   0x05
110
111
#define XBOX_IRQ	7
112
//#define XBOX_IRQ	15
113
114
/* insmod parameters */
115
116
#ifdef MODULE
117
static
118
#else
119
extern
120
#endif
121
int __init i2c_xbox_init(void);
122
static int __init xbox_cleanup(void);
123
static int xbox_setup(void);
124
static s32 xbox_access(struct i2c_adapter *adap, u16 addr,
125
			 unsigned short flags, char read_write,
126
			 u8 command, int size, union i2c_smbus_data *data);
127
static void xbox_do_pause(unsigned int amount);
128
static void xbox_abort(void);
129
static int xbox_transaction(void);
130
static void xbox_inc(struct i2c_adapter *adapter);
131
static void xbox_dec(struct i2c_adapter *adapter);
132
static u32 xbox_func(struct i2c_adapter *adapter);
133
134
#ifdef MODULE
135
extern int init_module(void);
136
extern int cleanup_module(void);
137
#endif				/* MODULE */
138
139
static struct i2c_algorithm smbus_algorithm = {
140
	/* name */ "Non-I2C SMBus adapter",
141
	/* id */ I2C_ALGO_SMBUS,
142
	/* master_xfer */ NULL,
143
	/* smbus_access */ xbox_access,
144
	/* slave;_send */ NULL,
145
	/* slave_rcv */ NULL,
146
	/* algo_control */ NULL,
147
	/* functionality */ xbox_func,
148
};
149
150
static struct i2c_adapter xbox_adapter = {
151
	"unset",
152
	I2C_ALGO_SMBUS | I2C_HW_SMBUS_XBOX,
153
	&smbus_algorithm,
154
	NULL,
155
	xbox_inc,
156
	xbox_dec,
157
	NULL,
158
	NULL,
159
};
160
161
static int __initdata xbox_initialized;
162
static unsigned short xbox_smba = 0;
163
spinlock_t xbox_driver_lock = SPIN_LOCK_UNLOCKED;
164
struct driver_data;
165
static struct pci_dev *XBOX_dev;
166
167
168
169
void xbox_interrupt(int irq, void *dev_id, struct pt_regs *regs)
170
{
171
	spin_lock(&xbox_driver_lock);
172
	printk("interrupt\n");
173
	spin_unlock(&xbox_driver_lock);
174
	
175
}
176
177
/* Detect whether a XBOX can be found, and initialize it, where necessary.
178
   Note the differences between kernels with the old PCI BIOS interface and
179
   newer kernels with the real PCI interface. In compat.h some things are
180
   defined to make the transition easier. */
181
int xbox_setup(void)
182
{
183
	unsigned char temp;
184
	struct sd *currdev;
185
	u16 cmd;
186
	int result;
187
188
	XBOX_dev = NULL;
189
190
	if (pci_present() == 0) {
191
		printk("i2c-xbox.o: Error: No PCI-bus found!\n");
192
		return(-ENODEV);
193
	}
194
195
	/* Look for a supported chip */
196
	for(currdev = supported; currdev->vendor; ) {
197
		XBOX_dev = pci_find_device(currdev->vendor,
198
						currdev->device, XBOX_dev);
199
		if (XBOX_dev != NULL)	{
200
#ifdef DEBUG
201
			printk
202
			    ("i2c-xbox.o: DEBUG: pci_find_device currdev->vendor 0x%04x currdev->device 0x%04x\n", currdev->vendor, currdev->device);
203
			printk
204
			    ("i2c-xbox.o: DEBUG: pci_find_device currdev->function %d XBOX_dev->devfn %d\n", currdev->function, PCI_FUNC(XBOX_dev->devfn));
205
#endif
206
	                pci_read_config_byte(XBOX_dev, SMBGCFG, &temp);
207
			pci_read_config_word(XBOX_dev, 0x14, &xbox_smba);
208
			
209
			xbox_smba &= 0xfffc;
210
			printk
211
			    ("i2c-xbox.o: DEBUG: SMBA %04x\n", xbox_smba);
212
			printk
213
			    ("i2c-xbox.o: DEBUG: SMBGCFG %04x\n", xbox_smba);
214
			if (PCI_FUNC(XBOX_dev->devfn) == currdev->function)
215
			{
216
				pci_read_config_word(XBOX_dev,PCI_STATUS,&cmd);
217
//				outb(SMB_GCTL_ALERT_INTERRUPT,SMB_GLOBAL_ENABLE);
218
			        printk("i2c-xbox.o: PCI status %04x\n",cmd);
219
				result = request_irq(XBOX_dev->irq, xbox_interrupt,SA_SHIRQ, "xbox", XBOX_dev);
220
			        if (result) {
221
				        printk("i2c-xbox.o: can't get assigned irq %i\n",XBOX_dev->irq);
222
				}
223
				break;
224
			}
225
		} else {
226
		    currdev++;
227
		}
228
	}
229
230
	if (XBOX_dev == NULL) {
231
		printk
232
		    ("i2c-xbox.o: Error: No XBOX or compatible device detected!\n");
233
		return(-ENODEV);
234
	}
235
	printk(KERN_INFO "i2c-xbox.o: Found %s SMBus controller.\n", currdev->name);
236
237
	if (check_region(xbox_smba, SMB_IOSIZE)) {
238
		printk
239
		    ("i2c-xbox.o: SMB region 0x%x already in use!\n",
240
		     xbox_smba);
241
		return(-ENODEV);
242
	}
243
244
#ifdef DEBUG
245
	printk("i2c-xbox.o: DEBUG: XBOX_smba = 0x%X\n", xbox_smba);
246
#endif
247
	
248
	/* Everything is happy, let's grab the memory and set things up. */
249
	request_region(xbox_smba, SMB_IOSIZE, "xbox-smbus");
250
251
	return 0;
252
}
253
254
/* 
255
  SMBUS event = I/O 28-29 bit 11
256
     see E0 for the status bits and enabled in E2
257
     
258
*/
259
260
/* Internally used pause function */
261
void xbox_do_pause(unsigned int amount)
262
{
263
	current->state = TASK_INTERRUPTIBLE;
264
	schedule_timeout(amount);
265
}
266
267
void xbox_abort(void)
268
{
269
	printk("i2c-xbox.o: Sending abort.\n");
270
	outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
271
	xbox_do_pause(100);
272
	outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
273
}
274
275
int xbox_transaction(void)
276
{
277
	int temp;
278
	int result = 0;
279
	int timeout = 0;
280
281
#ifdef DEBUG
282
	printk
283
	    ("i2c-xbox.o: Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
284
	     inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE),
285
	     inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA));
286
#endif
287
288
	/* Make sure the SMBus host is ready to start transmitting */
289
	if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) {
290
#ifdef DEBUG
291
		printk
292
		    ("i2c-xbox.o: SMBus busy (%04x). Waiting... \n", temp);
293
#endif
294
		do {
295
			udelay(100);
296
			temp = inw_p(SMB_GLOBAL_STATUS);
297
		} while ((temp & (GS_HST_STS | GS_SMB_STS)) &&
298
		         (timeout++ < MAX_TIMEOUT));
299
		/* If the SMBus is still busy, we give up */
300
		if (timeout >= MAX_TIMEOUT) {
301
			printk("i2c-xbox.o: Busy wait timeout! (%04x)\n", temp);
302
			xbox_abort();
303
			return(-1);
304
		}
305
		timeout = 0;
306
	}
307
308
	/* start the transaction by setting the start bit */
309
	outw_p(inw(SMB_GLOBAL_ENABLE) | GE_HOST_STC , SMB_GLOBAL_ENABLE);
310
311
	/* We will always wait for a fraction of a second! */
312
	temp = inw_p(SMB_GLOBAL_STATUS);
313
	while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT)) {
314
		udelay(100);
315
		temp = inw_p(SMB_GLOBAL_STATUS);		
316
	} 
317
318
	/* If the SMBus is still busy, we give up */
319
	if (timeout >= MAX_TIMEOUT) {
320
		printk("i2c-xbox.o: Completion timeout!\n");
321
		xbox_abort ();
322
		return(-1);
323
	}
324
325
	if (temp & GS_PRERR_STS) {
326
		result = -1;
327
#ifdef DEBUG
328
		printk("i2c-xbox.o: SMBus Protocol error (no response)!\n");
329
#endif
330
	}
331
332
	if (temp & GS_COL_STS) {
333
		result = -1;
334
		printk("i2c-xbox.o: SMBus collision!\n");
335
	}
336
337
	if (temp & GS_TO_STS) {
338
		result = -1;
339
#ifdef DEBUG
340
		printk("i2c-xbox.o: SMBus protocol timeout!\n");
341
#endif
342
	}
343
#ifdef DEBUG
344
	if (temp & GS_HCYC_STS) {
345
		printk("i2c-xbox.o: SMBus protocol success!\n");
346
	}
347
#endif
348
349
	outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
350
351
#ifdef DEBUG
352
	if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) {
353
		printk
354
		    ("i2c-xbox.o: Failed reset at end of transaction (%04x)\n",
355
		     temp);
356
	}
357
	printk
358
	    ("i2c-xbox.o: Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
359
	     inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE),
360
	     inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA));
361
#endif
362
363
	return result;
364
}
365
366
/* Return -1 on error. */
367
s32 xbox_access(struct i2c_adapter * adap, u16 addr,
368
		  unsigned short flags, char read_write,
369
		  u8 command, int size, union i2c_smbus_data * data)
370
{
371
  /** TODO: Should I supporte the 10-bit transfers? */
372
	switch (size) {
373
	case I2C_SMBUS_PROC_CALL:
374
		printk
375
		    ("i2c-xbox.o: I2C_SMBUS_PROC_CALL not supported!\n");
376
		/* TODO: Well... It is supported, I'm just not sure what to do here... */
377
		return -1;
378
	case I2C_SMBUS_QUICK:
379
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
380
		       SMB_HOST_ADDRESS);
381
		size = XBOX_QUICK;
382
		break;
383
	case I2C_SMBUS_BYTE:
384
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
385
		       SMB_HOST_ADDRESS);
386
		/* TODO: Why only during write? */
387
		if (read_write == I2C_SMBUS_WRITE)
388
			outb_p(command, SMB_HOST_COMMAND);
389
		size = XBOX_BYTE;
390
		break;
391
	case I2C_SMBUS_BYTE_DATA:
392
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
393
		       SMB_HOST_ADDRESS);
394
		outb_p(command, SMB_HOST_COMMAND);
395
		if (read_write == I2C_SMBUS_WRITE)
396
			outw_p(data->byte, SMB_HOST_DATA);
397
		size = XBOX_BYTE_DATA;
398
		break;
399
	case I2C_SMBUS_WORD_DATA:
400
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
401
		       SMB_HOST_ADDRESS);
402
		outb_p(command, SMB_HOST_COMMAND);
403
		if (read_write == I2C_SMBUS_WRITE)
404
			outw_p(data->word, SMB_HOST_DATA);	/* TODO: endian???? */
405
		size = XBOX_WORD_DATA;
406
		break;
407
	}
408
409
	/* How about enabling interrupts... */
410
	outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE);
411
412
	if (xbox_transaction())	/* Error in transaction */
413
		return -1;
414
415
	if ((read_write == I2C_SMBUS_WRITE) || (size == XBOX_QUICK))
416
		return 0;
417
418
419
	switch (size) {
420
	case XBOX_BYTE:
421
		data->byte = inw_p(SMB_HOST_DATA);
422
		break;
423
	case XBOX_BYTE_DATA:
424
		data->byte = inw_p(SMB_HOST_DATA);
425
		break;
426
	case XBOX_WORD_DATA:
427
		data->word = inw_p(SMB_HOST_DATA);	/* TODO: endian???? */
428
		break;
429
	}
430
431
	return 0;
432
}
433
434
void xbox_inc(struct i2c_adapter *adapter)
435
{
436
	MOD_INC_USE_COUNT;
437
}
438
439
void xbox_dec(struct i2c_adapter *adapter)
440
{
441
442
	MOD_DEC_USE_COUNT;
443
}
444
445
u32 xbox_func(struct i2c_adapter *adapter)
446
{
447
	return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
448
	    I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
449
	    I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL;
450
}
451
452
int __init i2c_xbox_init(void)
453
{
454
	int res;
455
	printk("i2c-xbox.o version 0.0.1\n");
456
#ifdef DEBUG
457
/* PE- It might be good to make this a permanent part of the code! */
458
	if (xbox_initialized) {
459
		printk
460
		    ("i2c-xbox.o: Oops, xbox_init called a second time!\n");
461
		return -EBUSY;
462
	}
463
#endif
464
	xbox_initialized = 0;
465
	if ((res = xbox_setup())) {
466
		printk
467
		    ("i2c-xbox.o: XBOX or compatible device not detected, module not inserted.\n");
468
		xbox_cleanup();
469
		return res;
470
	}
471
	xbox_initialized++;
472
	sprintf(xbox_adapter.name, "SMBus adapter at %04x",xbox_smba);
473
	if ((res = i2c_add_adapter(&xbox_adapter))) {
474
		printk
475
		    ("i2c-xbox.o: Adapter registration failed, module not inserted.\n");
476
		xbox_cleanup();
477
		return res;
478
	}
479
	xbox_initialized++;
480
	printk("i2c-xbox.o: SMBus bus detected and initialized\n");
481
	return 0;
482
}
483
484
int __init xbox_cleanup(void)
485
{
486
	int res;
487
	if (xbox_initialized >= 2) {
488
		if ((res = i2c_del_adapter(&xbox_adapter))) {
489
			printk
490
			    ("i2c-xbox.o: i2c_del_adapter failed, module not removed\n");
491
			return res;
492
		} else
493
			xbox_initialized--;
494
	}
495
	if (xbox_initialized >= 1) {
496
		release_region(xbox_smba, SMB_IOSIZE);
497
		xbox_initialized--;
498
	}
499
	free_irq(XBOX_dev->irq, XBOX_dev);
500
	return 0;
501
}
502
503
EXPORT_SYMBOL(i2c_xbox_init);
504
505
#ifdef MODULE
506
507
MODULE_AUTHOR("Edgar Hucek <hostmaster@ed-soft.at>");
508
MODULE_DESCRIPTION("XBOX nForce SMBus driver");
509
510
#ifdef MODULE_LICENSE
511
MODULE_LICENSE("GPL");
512
#endif
513
514
int init_module(void)
515
{
516
	return i2c_xbox_init();
517
}
518
519
int cleanup_module(void)
520
{
521
	return xbox_cleanup();
522
}
523
524
#endif				/* MODULE */
(-)linux-2.4.26/drivers/ide/CVS/Entries (+3 lines)
Line 0 Link Here
1
/ide-cd.c/1.9/Mon Jan 26 23:14:10 2004//
2
/ide-cd.h/1.2/Fri Oct  3 15:56:41 2003//
3
D
(-)linux-2.4.26/drivers/ide/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/ide
(-)linux-2.4.26/drivers/ide/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/ide/ide-cd.c (+93 lines)
Lines 308-313 Link Here
308
#include <linux/cdrom.h>
308
#include <linux/cdrom.h>
309
#include <linux/ide.h>
309
#include <linux/ide.h>
310
#include <linux/completion.h>
310
#include <linux/completion.h>
311
#include <linux/xbox.h>
311
312
312
#include <asm/irq.h>
313
#include <asm/irq.h>
313
#include <asm/io.h>
314
#include <asm/io.h>
Lines 317-322 Link Here
317
318
318
#include "ide-cd.h"
319
#include "ide-cd.h"
319
320
321
#ifdef CONFIG_XBOX
322
/* Global flag indicating whether to simulate Xbox drive locking in
323
   software.  There should only be one Xbox drive in a system!  This
324
   variable is externally referenced by arch/i386/kernel/xboxejectfix.c. */
325
volatile int Xbox_simulate_drive_locked = 0;
326
#endif /* CONFIG_XBOX */
327
320
/****************************************************************************
328
/****************************************************************************
321
 * Generic packet command support and error handling routines.
329
 * Generic packet command support and error handling routines.
322
 */
330
 */
Lines 1986-1991 Link Here
1986
	if (sense == NULL)
1994
	if (sense == NULL)
1987
		sense = &my_sense;
1995
		sense = &my_sense;
1988
1996
1997
#ifdef CONFIG_XBOX
1998
	/* If we're on an Xbox and this is an Xbox drive, simulate the lock
1999
	   request in software.  (See arch/i386/kernel/xboxejectfix.c) */
2000
	if (CDROM_CONFIG_FLAGS(drive)->xbox_drive && machine_is_xbox) {
2001
		CDROM_STATE_FLAGS(drive)->door_locked = lockflag;
2002
		Xbox_simulate_drive_locked = lockflag;
2003
		return 0;
2004
	}
2005
#endif /* CONFIG_XBOX */
2006
1989
	/* If the drive cannot lock the door, just pretend. */
2007
	/* If the drive cannot lock the door, just pretend. */
1990
	if (CDROM_CONFIG_FLAGS(drive)->no_doorlock) {
2008
	if (CDROM_CONFIG_FLAGS(drive)->no_doorlock) {
1991
		stat = 0;
2009
		stat = 0;
Lines 2033-2038 Link Here
2033
	if (CDROM_STATE_FLAGS(drive)->door_locked && ejectflag)
2051
	if (CDROM_STATE_FLAGS(drive)->door_locked && ejectflag)
2034
		return 0;
2052
		return 0;
2035
2053
2054
#ifdef CONFIG_XBOX
2055
	/* Older Xbox DVD drives don't understand the ATAPI command, but the SMC
2056
	   can do the eject.  Note that some Xbox drives support the eject
2057
	   command, namely the Samsung, so for that drive we do a regular eject
2058
	   sequence. */
2059
	if (machine_is_xbox && CDROM_CONFIG_FLAGS(drive)->xbox_drive &&
2060
		CDROM_CONFIG_FLAGS(drive)->xbox_eject) {
2061
		if (ejectflag) {
2062
			Xbox_tray_load();
2063
		} else {
2064
			Xbox_simulate_drive_locked = 0;
2065
			Xbox_tray_eject();
2066
		}
2067
		return 0;
2068
	}
2069
#endif
2070
2036
	memset(&pc, 0, sizeof (pc));
2071
	memset(&pc, 0, sizeof (pc));
2037
	pc.sense = sense;
2072
	pc.sense = sense;
2038
2073
Lines 2922-2927 Link Here
2922
	CDROM_CONFIG_FLAGS(drive)->supp_disc_present = 0;
2957
	CDROM_CONFIG_FLAGS(drive)->supp_disc_present = 0;
2923
	CDROM_CONFIG_FLAGS(drive)->audio_play = 0;
2958
	CDROM_CONFIG_FLAGS(drive)->audio_play = 0;
2924
	CDROM_CONFIG_FLAGS(drive)->close_tray = 1;
2959
	CDROM_CONFIG_FLAGS(drive)->close_tray = 1;
2960
	CDROM_CONFIG_FLAGS(drive)->xbox_drive = 0;
2961
	CDROM_CONFIG_FLAGS(drive)->xbox_eject = 0;
2925
	
2962
	
2926
	/* limit transfer size per interrupt. */
2963
	/* limit transfer size per interrupt. */
2927
	CDROM_CONFIG_FLAGS(drive)->limit_nframes = 0;
2964
	CDROM_CONFIG_FLAGS(drive)->limit_nframes = 0;
Lines 2988-2993 Link Here
2988
			/* uses CD in slot 0 when value is set to 3 */
3025
			/* uses CD in slot 0 when value is set to 3 */
2989
			cdi->sanyo_slot = 3;
3026
			cdi->sanyo_slot = 3;
2990
	}
3027
	}
3028
	/* THOMSON DVD drives in the Xbox report incorrect capabilities
3029
	   and do not understand the ATAPI eject command, but the SMC
3030
	   can do the eject. */
3031
	else if ((strcmp(drive->id->model, "THOMSON-DVD") == 0)) {
3032
		CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
3033
		CDROM_CONFIG_FLAGS(drive)->dvd = 1;
3034
		CDROM_CONFIG_FLAGS(drive)->xbox_drive = 1;
3035
		CDROM_CONFIG_FLAGS(drive)->xbox_eject = 1;
3036
	}
3037
	/* PHILIPS drives in Xboxen manufactured pre September 2003,
3038
	   report correct capabilities, but do not understand the ATAPI
3039
	   eject command, hence require the SMC to do so. */
3040
	else if ((strcmp(drive->id->model, "PHILIPS XBOX DVD DRIVE") == 0)) {
3041
		CDROM_CONFIG_FLAGS(drive)->xbox_drive = 1;
3042
		CDROM_CONFIG_FLAGS(drive)->xbox_eject = 1;
3043
	}
3044
	/* PHILIPS drives in Xboxen manufactured post September 2003,
3045
	   report incorrect capabilities, but understand the ATAPI
3046
	   eject command. */
3047
	else if ((strcmp(drive->id->model, "PHILIPS J5 3235C") == 0)) {
3048
		CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
3049
		CDROM_CONFIG_FLAGS(drive)->dvd = 1;
3050
		CDROM_CONFIG_FLAGS(drive)->xbox_drive = 1;
3051
		CDROM_CONFIG_FLAGS(drive)->xbox_eject = 0;
3052
	}
3053
	/* SAMSUNG drives in the Xbox report correct capabilities
3054
	   and understand the ATAPI eject command. */
3055
	else if (strcmp(drive->id->model, "SAMSUNG DVD-ROM SDG-605B") == 0) {
3056
		CDROM_CONFIG_FLAGS(drive)->xbox_drive = 1;
3057
		CDROM_CONFIG_FLAGS(drive)->xbox_eject = 0;
3058
	}
3059
3060
	/* Is an Xbox drive detected? */
3061
	if (CDROM_CONFIG_FLAGS(drive)->xbox_drive) {
3062
		/* If an Xbox drive is present in a regular PC, we can't eject.
3063
		   Act like the drive cannot eject, unless the ATAPI eject command
3064
		   is supported by the drive.  If the drive doesn't support ATAPI
3065
		   ejecting, act like door locking is impossible as well. */
3066
#ifdef CONFIG_XBOX
3067
		if (!machine_is_xbox) {
3068
#endif /* CONFIG_XBOX */
3069
			CDROM_CONFIG_FLAGS(drive)->no_doorlock = CDROM_CONFIG_FLAGS
3070
				(drive)->xbox_eject;
3071
			CDROM_CONFIG_FLAGS(drive)->no_eject = CDROM_CONFIG_FLAGS(drive)
3072
				->xbox_eject;
3073
#ifdef CONFIG_XBOX
3074
		} else {
3075
			/* An Xbox drive in an Xbox.  We can support ejecting through
3076
			   the SMC and support drive locking in software by ignoring
3077
			   the eject interrupt (see arch/i386/kernel/xboxejectfix.c). */
3078
			CDROM_CONFIG_FLAGS(drive)->no_doorlock = 0;
3079
			CDROM_CONFIG_FLAGS(drive)->no_eject = 0;
3080
			Xbox_simulate_drive_locked = 0;
3081
		}
3082
#endif /* CONFIG_XBOX */
3083
	}
2991
#endif /* not STANDARD_ATAPI */
3084
#endif /* not STANDARD_ATAPI */
2992
3085
2993
	info->toc		= NULL;
3086
	info->toc		= NULL;
(-)linux-2.4.26/drivers/ide/ide-cd.h (-1 / +3 lines)
Lines 85-91 Link Here
85
	__u8 audio_play		: 1; /* can do audio related commands */
85
	__u8 audio_play		: 1; /* can do audio related commands */
86
	__u8 close_tray		: 1; /* can close the tray */
86
	__u8 close_tray		: 1; /* can close the tray */
87
	__u8 writing		: 1; /* pseudo write in progress */
87
	__u8 writing		: 1; /* pseudo write in progress */
88
	__u8 reserved		: 3;
88
	__u8 xbox_drive		: 1; /* drive is an Xbox drive */
89
	__u8 xbox_eject		: 1; /* use Xbox SMC eject mechanism */
90
	__u8 reserved		: 1;
89
	byte max_speed;		     /* Max speed of the drive */
91
	byte max_speed;		     /* Max speed of the drive */
90
};
92
};
91
#define CDROM_CONFIG_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->config_flags))
93
#define CDROM_CONFIG_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->config_flags))
(-)linux-2.4.26/drivers/input/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)linux-2.4.26/drivers/input/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/input
(-)linux-2.4.26/drivers/input/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/net/CVS/Entries (+1 lines)
Line 0 Link Here
1
D/nvnet////
(-)linux-2.4.26/drivers/net/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/net
(-)linux-2.4.26/drivers/net/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/net/nvnet/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)linux-2.4.26/drivers/net/nvnet/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/net/nvnet
(-)linux-2.4.26/drivers/net/nvnet/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/pci/CVS/Entries (+2 lines)
Line 0 Link Here
1
/pci.ids/1.5/Wed Feb 18 23:45:58 2004//
2
D
(-)linux-2.4.26/drivers/pci/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/pci
(-)linux-2.4.26/drivers/pci/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/pci/pci.ids (+1 lines)
Lines 2754-2759 Link Here
2754
	0286  NV28 [GeForce4 Ti 4200 Go AGP 8x]
2754
	0286  NV28 [GeForce4 Ti 4200 Go AGP 8x]
2755
	0288  NV28GL [Quadro4 980 XGL]
2755
	0288  NV28GL [Quadro4 980 XGL]
2756
	0289  NV28GL [Quadro4 780 XGL]
2756
	0289  NV28GL [Quadro4 780 XGL]
2757
	02a0  NV16 [GeForce3 - nForce GPU]
2757
	0300  NV30 [GeForce FX]
2758
	0300  NV30 [GeForce FX]
2758
	0301  NV30 [GeForce FX 5800 Ultra]
2759
	0301  NV30 [GeForce FX 5800 Ultra]
2759
	0302  NV30 [GeForce FX 5800]
2760
	0302  NV30 [GeForce FX 5800]
(-)linux-2.4.26/drivers/sound/CVS/Entries (+3 lines)
Line 0 Link Here
1
/ac97_codec.c/1.6/Fri Nov 28 23:51:51 2003//
2
/i810_audio.c/1.6/Thu Apr 15 13:57:48 2004//
3
D
(-)linux-2.4.26/drivers/sound/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/sound
(-)linux-2.4.26/drivers/sound/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/sound/ac97_codec.c (+1 lines)
Lines 179-184 Link Here
179
	{0x83847666, "SigmaTel STAC9750T",	&sigmatel_9744_ops},
179
	{0x83847666, "SigmaTel STAC9750T",	&sigmatel_9744_ops},
180
	{0x83847684, "SigmaTel STAC9783/84?",	&null_ops},
180
	{0x83847684, "SigmaTel STAC9783/84?",	&null_ops},
181
	{0x57454301, "Winbond 83971D",		&null_ops},
181
	{0x57454301, "Winbond 83971D",		&null_ops},
182
	{0x574d4c09, "nVidia Xbox",             &null_ops},
182
};
183
};
183
184
184
static const char *ac97_stereo_enhancements[] =
185
static const char *ac97_stereo_enhancements[] =
(-)linux-2.4.26/drivers/sound/i810_audio.c (-1 / +5 lines)
Lines 2744-2750 Link Here
2744
		set_current_state(TASK_UNINTERRUPTIBLE);
2744
		set_current_state(TASK_UNINTERRUPTIBLE);
2745
		schedule_timeout(HZ/20);
2745
		schedule_timeout(HZ/20);
2746
	} 
2746
	} 
2747
	return i;
2747
#ifdef CONFIG_XBOX
2748
        return 1;
2749
#else
2750
        return i;
2751
#endif
2748
}
2752
}
2749
2753
2750
/**
2754
/**
(-)linux-2.4.26/drivers/usb/CVS/Entries (+13 lines)
Line 0 Link Here
1
/Config.in/1.11/Tue Mar  9 23:24:11 2004//
2
/Makefile/1.13/Tue Mar  9 23:24:11 2004//
3
/hub.c/1.4/Sat Sep 13 20:36:10 2003//
4
/readme.txt/1.2/Mon Sep  2 00:56:47 2002//
5
/ult.c/1.1/Mon Sep  2 00:56:47 2002//
6
/usb-xboxir.c/1.4/Wed Dec 10 00:18:28 2003//
7
/usb-xboxir.h/1.3/Mon Dec  2 23:04:58 2002//
8
/xir.c/1.3/Mon Mar 15 20:40:27 2004//
9
/xir.h/1.2/Mon Mar 15 20:25:34 2004//
10
/xpad-core.c/1.6/Tue Apr  6 19:51:51 2004//
11
/xpad-mouse.c/1.7/Mon Mar 15 20:25:34 2004//
12
/xpad.h/1.5/Mon Apr  5 18:34:03 2004//
13
D/storage////
(-)linux-2.4.26/drivers/usb/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/usb
(-)linux-2.4.26/drivers/usb/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/usb/Config.in (+7 lines)
Lines 58-63 Link Here
58
   fi
58
   fi
59
   dep_tristate '  Aiptek 6000U/8000U tablet support' CONFIG_USB_AIPTEK $CONFIG_USB $CONFIG_INPUT
59
   dep_tristate '  Aiptek 6000U/8000U tablet support' CONFIG_USB_AIPTEK $CONFIG_USB $CONFIG_INPUT
60
   dep_tristate '  Wacom Intuos/Graphire tablet support' CONFIG_USB_WACOM $CONFIG_USB $CONFIG_INPUT
60
   dep_tristate '  Wacom Intuos/Graphire tablet support' CONFIG_USB_WACOM $CONFIG_USB $CONFIG_INPUT
61
   dep_tristate '  Xbox controller ("Xpad") support (EXPERIMENTAL)' CONFIG_USB_XPAD $CONFIG_USB $CONFIG_INPUT $CONFIG_EXPERIMENTAL
62
   dep_mbool '    Xbox controller mouse emulation support (EXPERIMENTAL)' CONFIG_USB_XPAD_MOUSE $CONFIG_USB $CONFIG_INPUT $CONFIG_EXPERIMENTAL $CONFIG_USB_XPAD
63
   dep_tristate '  Xbox Infrared DVD dongle for LIRC support (EXPERIMENTAL)' CONFIG_USB_XIR $CONFIG_USB $CONFIG_EXPERIMENTAL
64
   if [ "$CONFIG_USB_XIR" == "n" ]; then
65
      dep_tristate '  Xbox Infrared DVD dongle support (EXPERIMENTAL)' CONFIG_USB_XBOXIR $CONFIG_USB $CONFIG_INPUT $CONFIG_USB_KBD $CONFIG_EXPERIMENTAL
66
   fi
67
     
61
   dep_tristate '  KB Gear JamStudio tablet support' CONFIG_USB_KBTAB $CONFIG_USB $CONFIG_INPUT
68
   dep_tristate '  KB Gear JamStudio tablet support' CONFIG_USB_KBTAB $CONFIG_USB $CONFIG_INPUT
62
   dep_tristate '  Griffin Technology PowerMate support' CONFIG_USB_POWERMATE $CONFIG_USB $CONFIG_INPUT
69
   dep_tristate '  Griffin Technology PowerMate support' CONFIG_USB_POWERMATE $CONFIG_USB $CONFIG_INPUT
63
70
(-)linux-2.4.26/drivers/usb/Makefile (-2 / +13 lines)
Lines 10-24 Link Here
10
10
11
# Objects that export symbols.
11
# Objects that export symbols.
12
12
13
export-objs		:= hcd.o usb.o ov511.o pwc-uncompress.o
13
export-objs		:= hcd.o usb.o ov511.o pwc-uncompress.o xir.o
14
14
15
# Multipart objects.
15
# Multipart objects.
16
16
17
list-multi		:= usbcore.o hid.o pwc.o
17
list-multi		:= usbcore.o hid.o pwc.o xpad.o
18
usbcore-objs		:= usb.o usb-debug.o hub.o
18
usbcore-objs		:= usb.o usb-debug.o hub.o
19
hid-objs		:= hid-core.o
19
hid-objs		:= hid-core.o
20
pwc-objs		:= pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o
20
pwc-objs		:= pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o
21
auerswald-objs		:= auerbuf.o auerchain.o auerchar.o auermain.o
21
auerswald-objs		:= auerbuf.o auerchain.o auerchar.o auermain.o
22
xpad-objs		:= xpad-core.o
22
23
23
# Optional parts of multipart objects.
24
# Optional parts of multipart objects.
24
25
Lines 40-45 Link Here
40
endif
41
endif
41
endif
42
endif
42
43
44
ifeq ($(CONFIG_USB_XPAD_MOUSE),y)
45
	xpad-objs	+= xpad-mouse.o
46
endif
47
43
# Object file lists.
48
# Object file lists.
44
49
45
obj-y	:=
50
obj-y	:=
Lines 87-92 Link Here
87
obj-$(CONFIG_USB_WACOM)		+= wacom.o
92
obj-$(CONFIG_USB_WACOM)		+= wacom.o
88
obj-$(CONFIG_USB_KBTAB)		+= kbtab.o
93
obj-$(CONFIG_USB_KBTAB)		+= kbtab.o
89
obj-$(CONFIG_USB_POWERMATE)	+= powermate.o
94
obj-$(CONFIG_USB_POWERMATE)	+= powermate.o
95
obj-$(CONFIG_USB_XBOXIR)	+= usb-xboxir.o
90
96
91
obj-$(CONFIG_USB_SCANNER)	+= scanner.o
97
obj-$(CONFIG_USB_SCANNER)	+= scanner.o
92
obj-$(CONFIG_USB_ACM)		+= acm.o
98
obj-$(CONFIG_USB_ACM)		+= acm.o
Lines 120-125 Link Here
120
obj-$(CONFIG_USB_USBNET)	+= usbnet.o
126
obj-$(CONFIG_USB_USBNET)	+= usbnet.o
121
obj-$(CONFIG_USB_AUERSWALD)	+= auerswald.o
127
obj-$(CONFIG_USB_AUERSWALD)	+= auerswald.o
122
obj-$(CONFIG_USB_BRLVGER)	+= brlvger.o
128
obj-$(CONFIG_USB_BRLVGER)	+= brlvger.o
129
obj-$(CONFIG_USB_XPAD)		+= xpad.o
130
obj-$(CONFIG_USB_XIR)		+= xir.o
123
obj-$(CONFIG_USB_LCD)		+= usblcd.o
131
obj-$(CONFIG_USB_LCD)		+= usblcd.o
124
obj-$(CONFIG_USB_SPEEDTOUCH)	+= speedtch.o
132
obj-$(CONFIG_USB_SPEEDTOUCH)	+= speedtch.o
125
133
Lines 152-154 Link Here
152
160
153
auerswald.o: $(auerswald-objs)
161
auerswald.o: $(auerswald-objs)
154
	$(LD) -r -o $@ $(auerswald-objs)
162
	$(LD) -r -o $@ $(auerswald-objs)
163
164
xpad.o: $(xpad-objs)
165
	$(LD) -r -o $@ $(xpad-objs)
(-)linux-2.4.26/drivers/usb/hub.c (-6 / +11 lines)
Lines 534-542 Link Here
534
	return ret;
534
	return ret;
535
}
535
}
536
536
537
#define HUB_RESET_TRIES		5
537
#define HUB_RESET_TRIES		10	/* Formerly 5 */
538
#define HUB_PROBE_TRIES		2
538
#define HUB_PROBE_TRIES		20	/* Formerly 2 */
539
#define HUB_SHORT_RESET_TIME	10
539
#define HUB_SHORT_RESET_TIME	15	/* Formerly 10 */
540
#define HUB_LONG_RESET_TIME	200
540
#define HUB_LONG_RESET_TIME	200
541
#define HUB_RESET_TIMEOUT	500
541
#define HUB_RESET_TIMEOUT	500
542
542
Lines 599-604 Link Here
599
	for (i = 0; i < HUB_RESET_TRIES; i++) {
599
	for (i = 0; i < HUB_RESET_TRIES; i++) {
600
		usb_set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET);
600
		usb_set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET);
601
601
602
		wait_ms(10);
603
602
		/* return on disconnect or reset */
604
		/* return on disconnect or reset */
603
		status = usb_hub_port_wait_reset(hub, port, dev, delay);
605
		status = usb_hub_port_wait_reset(hub, port, dev, delay);
604
		if (status != -1) {
606
		if (status != -1) {
Lines 642-649 Link Here
642
 * every 100ms for transient disconnects to restart the delay.
644
 * every 100ms for transient disconnects to restart the delay.
643
 */
645
 */
644
646
645
#define HUB_DEBOUNCE_TIMEOUT	400
647
#define HUB_DEBOUNCE_TIMEOUT	600	/* Formerly 400 */
646
#define HUB_DEBOUNCE_STEP	100
648
#define HUB_DEBOUNCE_STEP	200	/* Formerly 100 */
647
649
648
/* return: -1 on error, 0 on success, 1 on disconnect.  */
650
/* return: -1 on error, 0 on success, 1 on disconnect.  */
649
static int usb_hub_port_debounce(struct usb_device *hub, int port)
651
static int usb_hub_port_debounce(struct usb_device *hub, int port)
Lines 678-683 Link Here
678
	struct usb_device *dev;
680
	struct usb_device *dev;
679
	unsigned int delay = HUB_SHORT_RESET_TIME;
681
	unsigned int delay = HUB_SHORT_RESET_TIME;
680
	int i;
682
	int i;
683
/*	int delay;*/
681
684
682
	dbg("port %d, portstatus %x, change %x, %s",
685
	dbg("port %d, portstatus %x, change %x, %s",
683
		port + 1, portstatus, portchange, portspeed (portstatus));
686
		port + 1, portstatus, portchange, portspeed (portstatus));
Lines 704-709 Link Here
704
	}
707
	}
705
708
706
	down(&usb_address0_sem);
709
	down(&usb_address0_sem);
710
/*	delay = HUB_SHORT_RESET_TIME;*/
707
711
708
	for (i = 0; i < HUB_PROBE_TRIES; i++) {
712
	for (i = 0; i < HUB_PROBE_TRIES; i++) {
709
		struct usb_device *pdev;
713
		struct usb_device *pdev;
Lines 759-764 Link Here
759
			dev->bus->bus_name, dev->devpath, dev->devnum);
763
			dev->bus->bus_name, dev->devpath, dev->devnum);
760
764
761
		/* Run it through the hoops (find a driver, etc) */
765
		/* Run it through the hoops (find a driver, etc) */
766
		wait_ms(HUB_SHORT_RESET_TIME);
762
		if (!usb_new_device(dev)) {
767
		if (!usb_new_device(dev)) {
763
			hub->children[port] = dev;
768
			hub->children[port] = dev;
764
			goto done;
769
			goto done;
Lines 1057-1063 Link Here
1057
	ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, descriptor,
1062
	ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, descriptor,
1058
			sizeof(*descriptor));
1063
			sizeof(*descriptor));
1059
	if (ret < 0) {
1064
	if (ret < 0) {
1060
		kfree(descriptor);
1065
/*		kfree(descriptor);*/
1061
		return ret;
1066
		return ret;
1062
	}
1067
	}
1063
1068
(-)linux-2.4.26/drivers/usb/readme.txt (+33 lines)
Line 0 Link Here
1
 *
2
 *  WARNING: The author does not have a USB keyboard to test with. Expect bugs.
3
 *
4
 *  XBOX DVD dongle infrared device driver for the input driver suite.
5
 *
6
 *  This work was derived from the usbkbd.c kernel module.
7
 *
8
 *  Purpose:
9
 *
10
 *  The goal of this driver is to accept and translate the IR messages
11
 *  from an XBOX DVD dongle, pushing them into the kernel HID layer
12
 *  as normal keyboard events.
13
 *
14
 *  Conclusion:
15
 *
16
 *  The keybdev.o module is capable of receiving these
17
 *  events and pushing them into the appropriate keyboard layers
18
 *  for interaction with userland applications. You are now able
19
 *  to use the XBOX remote control to drive userland applications.
20
 *
21
 *  TODO (next release):
22
 *  - Rename /proc/xboxir to /proc/xbox/ir
23
 *  - Investigate whether the IR eye is capable of receiving NON XBOX RC codes (ala Pronto)
24
 *  - Integrate into the kernel build process
25
 *  - Add ioctls to allow codes to be added and removed dynamically.
26
 *  - Add an ioctl to restore the driver to it's default configuration state.
27
 *
28
 *  The "ult" configuration tool needs to communicate to the xbox ir drivers using a character
29
 *  device MAJOR 180, MINOR 240. Create this device as follows:
30
 *
31
 *  mknod /dev/xboxir c 180 240
32
 *  chmod 600 /dev/xboxir
33
(-)linux-2.4.26/drivers/usb/storage/CVS/Entries (+6 lines)
Line 0 Link Here
1
/README/1.1/Mon May 12 08:43:33 2003//
2
/protocol.c/1.3/Fri Nov 28 23:51:52 2003//
3
/protocol.h/1.3/Wed Oct 15 15:27:58 2003//
4
/usb.c/1.4/Wed Feb 18 23:45:58 2004//
5
/usb.h/1.3/Sat Sep 13 20:36:11 2003//
6
D
(-)linux-2.4.26/drivers/usb/storage/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/usb/storage
(-)linux-2.4.26/drivers/usb/storage/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/usb/storage/README (+83 lines)
Line 0 Link Here
1
 usb-storage driver patched to accept Xbox Memory Units
2
--------------------------------------------------------
3
4
BEFORE using this driver, consider the following:
5
6
1) this is EXPERIMENTAL
7
2) this is KNOWN to HAVE BUGS
8
3) this has NOT been extensively TESTED
9
4) this is NOT SUPPORTED well
10
5) this CANNOT be used to WRITE onto the thing
11
12
Still there? OK. Some further notes:
13
14
15
 Author
16
--------
17
18
Credits belong to Paul Bartholomew who found out what is needed to get those
19
units accepted. He sent a message containing the whole subtree (precompiled)
20
to the xbox-linux-devel mailing list.
21
22
I made a diff against a vanilla kernel and sent that to the ml a day or two
23
later (patches are smaller and it is a lot easier to identify the changes).
24
25
Because of that, people misunderstood me as the author, which is not correct.
26
Credit where credit is due.
27
28
While testing the thing I noticed that it tried to detect all luns (you can
29
setup the kernel do to that). Because it detected 8 luns but only 4 worked
30
(and those were all just mirrors of the data) AND the other 4 caused timeouts
31
I added a line to suppress luns > 0.
32
33
34
 writing
35
---------
36
37
While reading from the device worked fine, writing was and is an unresolved
38
issue. I did indeed mess the thing up when I mounted it read/write and
39
added a file. After unmounting it was not valid FATX anymore. The Xbox insisted
40
on formatting it. Having a previously generated dump at hand I decided to
41
write that onto the thing in raw mode. While that recreated the directory
42
structures (even the Xbox displayed all the savegames with icons and the
43
funky stuff) from the looks of it the files themselves were not there (or, to
44
be precise here, were all filled with 0xFF). I did not investigate on this
45
further yet. Any volunteers?
46
47
IF you REALLY intend to write onto an Xbox Memory Unit (because, for instance,
48
you are eager to fire up 007:auf with that "boot-linux-savegame"), PLEASE
49
consider the following:
50
 
51
Do NOT mount the device itself writeable! That will almost certainly screw
52
it up.
53
Do NOT expect it to WORK AT ALL. Or you're screwed up when it fulfills my
54
prophecy.
55
Do NOT come to the list whining about its (not-working) state or about loss
56
of data or the like. It's EXPERIMENTAL, remember? You have been warned.
57
58
You are encouraged, however, to contribute to the effort with testing,
59
reporting success/failures and even code. It's open source, after all. If you
60
do contribute, xbox-linux-devel@lists.sourceforge.net should be where you post
61
anything.
62
63
OK, so you ignored my previous statements and want to write onto the thing.
64
In that case, please, at least TRY it this way:
65
66
1) dump the device contents into a file
67
   #> dd if=/path/to/device of=/path/to/file
68
2) (optional, recommended) make a backup copy of that dump
69
3) (optional) verify the file (should be of size 8MB and start with "FATX")
70
4) mount that file loopback
71
   #> mount -t fatx -o loop /path/to/file /path/to/mountpoint
72
5) edit/copy/add/delete files inside the mountpoint directory
73
6) umount the file
74
   #> umount /path/to/mountpoint
75
7) (optional) remount the file and check for errors
76
8) write the file back onto the device (do NOT hold your breath!)
77
   #> dd if=/path/to/file of=/path/to/device
78
9) (prohibited) curse the driver author and/or linux folk because it did not
79
   work (DON'T DO THAT! You have been warned.)
80
81
-- 
82
Marko Friedemann
83
12.05.2003
(-)linux-2.4.26/drivers/usb/storage/protocol.c (-1 / +89 lines)
Lines 1-6 Link Here
1
/* Driver for USB Mass Storage compliant devices
1
/* Driver for USB Mass Storage compliant devices
2
 *
2
 *
3
 * $Id: protocol.c,v 1.13 2002/02/25 00:34:56 mdharm Exp $
3
 * $Id: protocol.c,v 1.3 2003/11/28 23:51:52 aothieno Exp $
4
 *
4
 *
5
 * Current development and maintenance by:
5
 * Current development and maintenance by:
6
 *   (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
6
 *   (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
Lines 399-401 Link Here
399
	}
399
	}
400
}
400
}
401
401
402
#ifdef US_SC_XBMEM
403
unsigned char	Xbmem_fake_inquiry_data[] = {
404
	0x20, 0x80, 0x02, 0x02, 0x1F, 0x00, 0x00, 0x00,
405
	
406
	0x4D, 0x53, 0x46, 0x54, 0x20, 0x20, 0x20, 0x20,	// VendorName
407
	0x58, 0x42, 0x4D, 0x45, 0x4D, 0x20, 0x20, 0x20,	// ProductName
408
	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
409
	0x30, 0x31, 0x30, 0x30,				// Version
410
};
411
412
unsigned char	Xbmem_fake_mode_sense_data[] = {
413
	0x03, 0x00, 0x00, 0x00,
414
};
415
416
void usb_stor_xbmem_scsi_command(Scsi_Cmnd *srb, struct us_data *us)
417
{
418
	unsigned char	*fake_resp_data;
419
	int fake_resp_len;
420
	unsigned int	fake_resp_result;
421
	int	i;
422
	struct scatterlist *sg;
423
	int len;
424
	int transferred;
425
	int amt;
426
427
	warn("usb_stor_xbmem_scsi_command: cmd=0x%x\n", srb->cmnd[0]);
428
429
	fake_resp_len = -1;
430
	fake_resp_data = NULL;
431
	fake_resp_result = (GOOD << 1);
432
	switch(srb->cmnd[0]) {
433
	case INQUIRY:
434
		warn("XBMEM: fake INQUIRY\n");
435
		fake_resp_data = Xbmem_fake_inquiry_data;
436
		fake_resp_len = sizeof(Xbmem_fake_inquiry_data);
437
		fake_resp_result = (GOOD << 1);
438
		break;
439
	case TEST_UNIT_READY:
440
		warn("XBMEM: fake TEST_UNIT_READY\n");
441
		fake_resp_len = 0;
442
		fake_resp_result = (GOOD << 1);
443
		break;
444
	case MODE_SENSE:
445
		warn("XBMEM: fake MODE_SENSE\n");
446
		fake_resp_data = Xbmem_fake_mode_sense_data;
447
		fake_resp_len = sizeof(Xbmem_fake_mode_sense_data);
448
		fake_resp_result = (GOOD << 1);
449
		break;
450
	case START_STOP:
451
		warn("XBMEM: fake START_STOP\n");
452
		fake_resp_len = 0;
453
		fake_resp_result = (GOOD << 1);
454
		break;
455
	case ALLOW_MEDIUM_REMOVAL:
456
		warn("XBMEM: fake ALLOW_MEDIUM_REMOVAL\n");
457
		fake_resp_len = 0;
458
		fake_resp_result = (GOOD << 1);
459
		break;
460
	default:
461
		break;
462
	}
463
	if (fake_resp_len != -1) {
464
		len = (us->srb->request_bufflen > fake_resp_len) ? 
465
			fake_resp_len : us->srb->request_bufflen;
466
		if (us->srb->use_sg) {
467
			warn("XBMEM: use_sg is TRUE\n");
468
			sg = (struct scatterlist *)us->srb->request_buffer;
469
			for (i = 0; i < us->srb->use_sg; i++) {
470
				memset(sg[0].address, 0, sg[i].length);
471
			}
472
			for (i = 0, transferred = 0;
473
				i < us->srb->use_sg && (transferred < len); i++) {
474
				amt = sg[i].length > (len-transferred) ?
475
					(len-transferred) : sg[i].length;
476
				memcpy(sg[i].address, fake_resp_data+transferred, amt);
477
				transferred -= amt;
478
			}
479
		} else {
480
			warn("XBMEM: use_sg is FALSE\n");
481
			memset(us->srb->request_buffer, 0, us->srb->request_bufflen);
482
			memcpy(us->srb->request_buffer, fake_resp_data, len);
483
		}
484
		us->srb->result = fake_resp_result;
485
	} else {
486
		usb_stor_transparent_scsi_command(srb, us);
487
	}
488
}
489
#endif
(-)linux-2.4.26/drivers/usb/storage/protocol.h (-4 / +8 lines)
Lines 1-7 Link Here
1
/* Driver for USB Mass Storage compliant devices
1
/* Driver for USB Mass Storage compliant devices
2
 * Protocol Functions Header File
2
 * Protocol Functions Header File
3
 *
3
 *
4
 * $Id: protocol.h,v 1.4 2001/02/13 07:10:03 mdharm Exp $
4
 * $Id: protocol.h,v 1.3 2003/10/15 15:27:58 aothieno Exp $
5
 *
5
 *
6
 * Current development and maintenance by:
6
 * Current development and maintenance by:
7
 *   (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
7
 *   (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
Lines 54-61 Link Here
54
#define US_SC_8070	0x05		/* Removable media */
54
#define US_SC_8070	0x05		/* Removable media */
55
#define US_SC_SCSI	0x06		/* Transparent */
55
#define US_SC_SCSI	0x06		/* Transparent */
56
#define US_SC_ISD200    0x07            /* ISD200 ATA */
56
#define US_SC_ISD200    0x07            /* ISD200 ATA */
57
#define US_SC_MIN	US_SC_RBC
57
#define US_SC_XBMEM	0x42		/* Xbox memory unit */
58
#define US_SC_MAX	US_SC_ISD200
58
#define US_SC_MIN	US_SC_RBC	/* paulb: added   - Xbox memory unit */
59
#define US_SC_MAX	US_SC_XBMEM 	/* paulb: changed - Xbox memory unit */
60
//#define US_SC_MAX	US_SC_ISD200	/* paulb: old setting */
59
61
60
#define US_SC_DEVICE	0xff		/* Use device's value */
62
#define US_SC_DEVICE	0xff		/* Use device's value */
61
63
Lines 63-67 Link Here
63
extern void usb_stor_qic157_command(Scsi_Cmnd*, struct us_data*);
65
extern void usb_stor_qic157_command(Scsi_Cmnd*, struct us_data*);
64
extern void usb_stor_ufi_command(Scsi_Cmnd*, struct us_data*);
66
extern void usb_stor_ufi_command(Scsi_Cmnd*, struct us_data*);
65
extern void usb_stor_transparent_scsi_command(Scsi_Cmnd*, struct us_data*);
67
extern void usb_stor_transparent_scsi_command(Scsi_Cmnd*, struct us_data*);
66
68
#ifdef US_SC_XBMEM
69
extern void usb_stor_xbmem_scsi_command(Scsi_Cmnd*, struct us_data*);
70
#endif
67
#endif
71
#endif
(-)linux-2.4.26/drivers/usb/storage/usb.c (-5 / +33 lines)
Lines 1-6 Link Here
1
/* Driver for USB Mass Storage compliant devices
1
/* Driver for USB Mass Storage compliant devices
2
 *
2
 *
3
 * $Id: usb.c,v 1.73 2002/01/27 09:02:15 mdharm Exp $
3
 * $Id: usb.c,v 1.4 2004/02/18 23:45:58 aothieno Exp $
4
 *
4
 *
5
 * Current development and maintenance by:
5
 * Current development and maintenance by:
6
 *   (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
6
 *   (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
Lines 155-161 Link Here
155
	{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_BULK) },
155
	{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_BULK) },
156
	{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_BULK) },
156
	{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_BULK) },
157
	{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) },
157
	{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) },
158
158
#ifdef US_SC_XBMEM
159
	{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_XBMEM, US_PR_BULK) },
160
#endif
159
	/* Terminating entry */
161
	/* Terminating entry */
160
	{ }
162
	{ }
161
};
163
};
Lines 230-236 Link Here
230
	  useTransport: US_PR_BULK},
232
	  useTransport: US_PR_BULK},
231
	{ useProtocol: US_SC_SCSI,
233
	{ useProtocol: US_SC_SCSI,
232
	  useTransport: US_PR_BULK},
234
	  useTransport: US_PR_BULK},
233
235
#ifdef US_SC_XBMEM
236
	{ useProtocol: US_SC_XBMEM,
237
	  useTransport: US_PR_BULK},
238
#endif
234
	/* Terminating entry */
239
	/* Terminating entry */
235
	{ 0 }
240
	{ 0 }
236
};
241
};
Lines 319-324 Link Here
319
	 */
324
	 */
320
	exit_files(current);
325
	exit_files(current);
321
	current->files = init_task.files;
326
	current->files = init_task.files;
327
	//current->flags |= PF_IOTHREAD;		/* paulb? */
322
	atomic_inc(&current->files->count);
328
	atomic_inc(&current->files->count);
323
	daemonize();
329
	daemonize();
324
	reparent_to_init();
330
	reparent_to_init();
Lines 440-450 Link Here
440
					unsigned char data_ptr[36] = {
446
					unsigned char data_ptr[36] = {
441
					    0x00, 0x80, 0x02, 0x02,
447
					    0x00, 0x80, 0x02, 0x02,
442
					    0x1F, 0x00, 0x00, 0x00};
448
					    0x1F, 0x00, 0x00, 0x00};
443
449
warn("Fake INQUIRY command\n");
444
					US_DEBUGP("Faking INQUIRY command\n");
450
					US_DEBUGP("Faking INQUIRY command\n");
445
					fill_inquiry_response(us, data_ptr, 36);
451
					fill_inquiry_response(us, data_ptr, 36);
446
					us->srb->result = GOOD << 1;
452
					us->srb->result = GOOD << 1;
453
				} else if ((us->srb->cmnd[0] == START_STOP) &&
454
				    (us->flags & US_FL_START_CHECK)) {
455
					unsigned char saved_cdb[6];
456
457
					/* Handle those devices which fake
458
					 * START_STOP on us, this confuses
459
					 * the hell out of media check code. */
460
warn("Converting START_STOP cmd\n");
461
					US_DEBUGP("Convering START_STOP command\n");
462
					memcpy(saved_cdb, us->srb->cmnd, 6);
463
					memset(us->srb->cmnd, 0, 6);
464
					us->srb->cmnd[0] = TEST_UNIT_READY;
465
					US_DEBUG(usb_stor_show_command(us->srb));
466
					us->proto_handler(us->srb, us);
467
					memcpy(us->srb->cmnd, saved_cdb, 6);
447
				} else {
468
				} else {
469
warn("USB SCSI command: 0x%x\n", us->srb->cmnd[0]);
448
					/* we've got a command, let's do it! */
470
					/* we've got a command, let's do it! */
449
					US_DEBUG(usb_stor_show_command(us->srb));
471
					US_DEBUG(usb_stor_show_command(us->srb));
450
					us->proto_handler(us->srb, us);
472
					us->proto_handler(us->srb, us);
Lines 952-958 Link Here
952
			ss->protocol_name = "Transparent SCSI";
974
			ss->protocol_name = "Transparent SCSI";
953
			ss->proto_handler = usb_stor_transparent_scsi_command;
975
			ss->proto_handler = usb_stor_transparent_scsi_command;
954
			break;
976
			break;
955
977
#ifdef US_SC_XBMEM
978
		case US_SC_XBMEM:
979
			ss->protocol_name = "Xbox Mem card";
980
			ss->proto_handler = usb_stor_xbmem_scsi_command;
981
                        ss->max_lun = 0;  /* fix: ignore all luns > 0 */
982
			break;
983
#endif
956
		case US_SC_UFI:
984
		case US_SC_UFI:
957
			ss->protocol_name = "Uniform Floppy Interface (UFI)";
985
			ss->protocol_name = "Uniform Floppy Interface (UFI)";
958
			ss->proto_handler = usb_stor_ufi_command;
986
			ss->proto_handler = usb_stor_ufi_command;
(-)linux-2.4.26/drivers/usb/storage/usb.h (-1 / +2 lines)
Lines 1-7 Link Here
1
/* Driver for USB Mass Storage compliant devices
1
/* Driver for USB Mass Storage compliant devices
2
 * Main Header File
2
 * Main Header File
3
 *
3
 *
4
 * $Id: usb.h,v 1.18 2001/07/30 00:27:59 mdharm Exp $
4
 * $Id: usb.h,v 1.3 2003/09/13 20:36:11 huceke Exp $
5
 *
5
 *
6
 * Current development and maintenance by:
6
 * Current development and maintenance by:
7
 *   (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
7
 *   (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
Lines 99-104 Link Here
99
#define US_FL_SINGLE_LUN      0x00000001 /* allow access to only LUN 0	    */
99
#define US_FL_SINGLE_LUN      0x00000001 /* allow access to only LUN 0	    */
100
#define US_FL_MODE_XLATE      0x00000002 /* translate _6 to _10 commands for
100
#define US_FL_MODE_XLATE      0x00000002 /* translate _6 to _10 commands for
101
						    Win/MacOS compatibility */
101
						    Win/MacOS compatibility */
102
#define US_FL_START_CHECK     0x00000008 /* START_STOP => TEST UNIT READY */
102
#define US_FL_IGNORE_SER      0x00000010 /* Ignore the serial number given  */
103
#define US_FL_IGNORE_SER      0x00000010 /* Ignore the serial number given  */
103
#define US_FL_SCM_MULT_TARG   0x00000020 /* supports multiple targets */
104
#define US_FL_SCM_MULT_TARG   0x00000020 /* supports multiple targets */
104
#define US_FL_FIX_INQUIRY     0x00000040 /* INQUIRY response needs fixing */
105
#define US_FL_FIX_INQUIRY     0x00000040 /* INQUIRY response needs fixing */
(-)linux-2.4.26/drivers/usb/ult.c (+264 lines)
Line 0 Link Here
1
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or 
6
 * (at your option) any later version.
7
 * 
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 * 
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
 * 
17
 */
18
19
/*
20
 *  $Id: ult.c,v 1.1 2002/09/02 00:56:47 steventoth Exp $
21
 *
22
 *  Copyright (c) 2002 Steven Toth <steve@toth.demon.co.uk>
23
 *
24
 *  This tool is a user space usb-xboxir.o configuration tool.
25
 *
26
 *  History:
27
 *
28
 *  2002_09_02 - 0.1 - Initial release
29
 *
30
 */
31
32
/*
33
 * Compile with:
34
 * gcc ult.c -o ult -I/usr/src/linux-2.4.19-XBOX-toths1/include -I/usr/src/linux-2.4.19-XBOX-toths1/drivers/usb
35
 */
36
37
#include <stdio.h>
38
#include <fcntl.h>
39
#include <sys/types.h>
40
#include <sys/stat.h>
41
#include <sys/ioctl.h>
42
#include <linux/input.h>
43
#include <usb-xboxir.h>
44
45
#define PROGNAME "ult"
46
#define PROCNAME "/proc/xboxir"
47
#define VERSION  "0.1"
48
49
int fh,verbose=0;
50
struct t_rc_kbd_matrix entry;
51
char *src_name;
52
char *tgt_name;
53
54
char * get_rc_name_by_code(unsigned char c);
55
char * get_hid_name_by_code(unsigned int c);
56
void write_entry();
57
void usage(void);
58
void dump_proc(void);
59
unsigned int get_hid_key_by_name(char *n);
60
unsigned char get_rc_key_by_name(char *n);
61
void dump_keys(void);
62
char * get_rc_name_by_code(unsigned char c);
63
char * get_hid_name_by_code(unsigned int c);
64
65
void write_entry() {
66
	if (verbose) printf("Configuring driver: XBOX key %s generates kernel key %s\n", src_name, tgt_name);	
67
	if( (ioctl(fh,XBOXIR_IOCSQSET, &entry)) == -1) {
68
		printf("Error, unable to configure driver table\n");
69
		exit(1);
70
	}
71
}
72
73
void usage(void) {
74
	printf("Description: %s, a user space tool for configuring the xbox ir driver key codes.\n",PROGNAME);
75
	printf("Usage: %s [-hkq] -d /dev/name -s <src key> -t <target key>\n",PROGNAME);
76
	printf(" -h  help\n");
77
	printf(" -v  verbose\n");
78
	printf(" -V  version\n");
79
	printf(" -k  list key codes\n");
80
	printf(" -q  query current settings\n");
81
	printf(" -d  device name\n");
82
	printf(" -s  source keyname (XBOX)\n");
83
	printf(" -t  target keyname (KERNEL)\n\n");
84
	printf("Example: To remap the xbox INFO key to the HID stopcd KEY\n");
85
	printf("     do: %s -d /dev/xboxir -s RC_KEY_INFO -t KEY_STOPCD\n\n",PROGNAME);
86
}
87
88
void dump_proc(void) {
89
	struct t_rc_kbd_matrix entry;
90
	FILE *in;
91
	char line[80];
92
	int ret=0;
93
	
94
95
	in=fopen(PROCNAME,"rb");
96
	if (!in) {
97
		perror("fopen");
98
		exit(1);
99
	}
100
101
	printf("#XBOX key -> HID key\n");
102
	while(!feof(in)) {
103
		memset(&line,0,sizeof(line));
104
		fgets(&line[0],sizeof(line)-1,in);
105
		if(line[0] == '0') {
106
			ret=sscanf(line,"0x%02x:0x%04x",&entry.rc_code,&entry.kbd_code);
107
			//printf("ret=%d\n",ret);
108
			printf("%s -> %s\n",get_rc_name_by_code(entry.rc_code), get_hid_name_by_code(entry.kbd_code) );
109
		}
110
	}
111
112
	fclose(in);
113
}
114
115
/* For a given hid KEY_NAME, find it in the structures and return the unique code */
116
unsigned int get_hid_key_by_name(char *n) {
117
	int i=1; /* Start at 1 as 0 = reserved */
118
119
	while( hidkeys[i].code != 0 ) {
120
		if( strcmp(hidkeys[i].name,n) == 0) {
121
			return(hidkeys[i].code);
122
		}
123
		i++;
124
	}
125
126
	return 0;
127
}
128
129
void dump_keys(void) {
130
	int i=0;
131
	int w=0;
132
133
	printf("XBOX KEY NAME (CODE):\n");
134
	while( rckeys[i].code != 0 ) {
135
		printf("   %s (0x%x)\n",rckeys[i].name,rckeys[i].code);
136
		i++;
137
	}
138
139
	i=1; /* start from 1 as 0 is RESERVED */
140
	printf("HID KEY NAME (CODE):\n");
141
	while( hidkeys[i].code != 0 ) {
142
		printf("   %s (0x%x)\n",hidkeys[i].name,hidkeys[i].code);
143
		i++;
144
	}
145
}
146
147
/* For a given xbox KEY_NAME, find it in the structures and return the unique code */
148
unsigned char get_rc_key_by_name(char *n) {
149
	int i=0;
150
151
	while( rckeys[i].code != 0 ) {
152
		if( strcmp(rckeys[i].name,n) == 0) {
153
			return(rckeys[i].code);
154
		}
155
		i++;
156
	}
157
158
	return 0;
159
}
160
161
/* For a given xbox KEY_CODE, find it in the structures and return the name */
162
char * get_rc_name_by_code(unsigned char c) {
163
	int i=0;
164
165
	while( rckeys[i].code != 0 ) {
166
		if(rckeys[i].code == c) return(rckeys[i].name);
167
		i++;
168
	}
169
170
	return 0;
171
}
172
173
/* For a given hid KEY_CODE, find it in the structures and return the name */
174
char * get_hid_name_by_code(unsigned int c) {
175
	int i=1; /* Start at 1, 0 = reserved */
176
177
	while( hidkeys[i].code != 0 ) {
178
		if(hidkeys[i].code == c) return(hidkeys[i].name);
179
		i++;
180
	}
181
182
	return 0;
183
}
184
185
186
int main(int argc, char **argv[]) {
187
188
	extern char *optarg;
189
	extern int optind, opterr, optopt;
190
	int dflg=0,tflg=0,sflg=0,c=0;
191
	char dev[128],srckey[32],tgtkey[32];
192
193
	while ((c=getopt(argc,argv,"d:s:t:qvkhV")) != -1 ) {
194
		switch(c) {
195
			case 'V':
196
				printf("Version: %s\n", VERSION);
197
				exit(0);
198
				break;
199
			case 'h':
200
				usage();
201
				exit(0);
202
				break;
203
			case 'k':
204
				dump_keys();
205
				exit(0);
206
				break;
207
			case 'q':
208
				dump_proc();
209
				exit(0);
210
				break;
211
			case 'v':
212
				verbose++;
213
				break;
214
			case 'd':
215
				dflg++;
216
				strcpy(dev,optarg);
217
				break;
218
			case 's':
219
				sflg++;
220
				if( (entry.rc_code = get_rc_key_by_name(optarg)) == 0) {
221
					printf("Error, invalid XBOX KEY_NAME\n");
222
					exit(1);
223
				}	
224
				src_name=optarg;
225
				break;
226
			case 't':
227
				tflg++;
228
				//entry.kbd_code = atoi(optarg);
229
				if( (entry.kbd_code = get_hid_key_by_name(optarg)) == 0) {
230
					printf("Error, invalid HID KEY_NAME\n");
231
					exit(1);
232
				}
233
				tgt_name=optarg;
234
				break;
235
			default:
236
				usage();
237
				exit(1);
238
		}
239
	}
240
241
	if(! ((dflg) && (sflg) && (tflg)) ) {
242
		usage();
243
		exit(1);
244
	}
245
246
	if (verbose) printf("Opening device driver named %s\n",dev);
247
248
	if( (fh=open(dev,O_RDWR)) == -1) {
249
		perror("open");
250
		exit(1);
251
	}
252
253
	write_entry();
254
255
	close(fh);
256
	if (verbose) printf("Closed device driver\n");
257
}
258
259
/*
260
#!/bin/sh
261
cat /usr/src/linux/include/linux/input.h | grep "#define" | grep "KEY_" | \
262
awk '{ print " {\"" $2 "\", " $2 "}," }'
263
*/
264
(-)linux-2.4.26/drivers/usb/usb-xboxir.c (+383 lines)
Line 0 Link Here
1
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or 
6
 * (at your option) any later version.
7
 * 
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 * 
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
 * 
17
 */
18
19
/*
20
 *  $Id: usb-xboxir.c,v 1.4 2003/12/10 00:18:28 aothieno Exp $
21
 *
22
 *  Copyright (c) 2002 Steven Toth <steve@toth.demon.co.uk>
23
 *
24
 *  XBOX DVD dongle infrared device driver for the input driver suite.
25
 *
26
 *  This work was derived from the usbkbd.c kernel module.
27
 *
28
 *  History:
29
 *
30
 *  2002_08_31 - 0.1 - Initial release
31
 *  2002_09_02 - 0.2 - Added IOCTL support enabling user space administration
32
 *                     of the translation matrix.
33
 *
34
 */
35
36
#include <linux/kernel.h>
37
#include <linux/slab.h>
38
#include <linux/module.h>
39
#include <linux/proc_fs.h>
40
#include <linux/input.h>
41
#include <linux/init.h>
42
#include <linux/usb.h>
43
#include <asm/uaccess.h>
44
#include "usb-xboxir.h"
45
46
#ifndef MODULE
47
#define MODULE
48
#endif
49
50
#define DRIVER_VERSION		"0.2"
51
#define DRIVER_AUTHOR			"Steven Toth <steve@toth.demon.co.uk>"
52
#define DRIVER_DESC				"USB HID XBOX IR driver"
53
#define PROC_FILE_NAME		"xboxir"
54
#define PROC_FILE_PERMS		S_IFREG | S_IRUGO
55
#define XBOXIR_MINOR			240
56
57
#ifdef dbg
58
#undef dbg
59
#define dbg(format, arg...) do { if(xboxir_debug) printk(KERN_INFO __FILE__ ": " format "\n" , ## arg); } while (0)
60
61
unsigned int xboxir_debug = 0;
62
struct proc_dir_entry *proc_file_ent;
63
64
/*  Dump the contents of the translation table in ASCII to the /proc file */
65
static int usb_xboxir_read_proc_ir( char *buf, char **start, off_t offset, int count, int *eof, void *data)
66
{
67
	int i=0, len=0;
68
69
	if(count>=512) {
70
	
71
		len += sprintf(buf+len,"XBOX:HID\n");
72
		while(rc_kbd_matrix[i].rc_code != 0) {
73
			len += sprintf(buf+len,"0x%02x:0x%04x\n"
74
				,rc_kbd_matrix[i].rc_code
75
				,rc_kbd_matrix[i].kbd_code);
76
			i++;
77
		}
78
79
	} else {
80
		dbg("user attemped to read /proc but user bufferlen was < 512 chars, not big enough, increase");
81
	}
82
83
	*eof = 1;
84
	return len;
85
}
86
87
/* Perform an lookup for xbox rc_code in the table, return the kbd_code. */
88
static unsigned int get_kdb_code(unsigned char c)
89
{
90
	int i=0;
91
92
	/* the table is order so we can take a short cut for invalid code numbers */
93
	while(rc_kbd_matrix[i].rc_code != 0) {
94
		if(rc_kbd_matrix[i].rc_code > c) return 0; /* wasn't in list */
95
		if(rc_kbd_matrix[i].rc_code == c)
96
			return rc_kbd_matrix[i].kbd_code;
97
		i++;
98
	}
99
100
	return 0;
101
}
102
103
/* Perform an lookup for xbox rc_code in the table, set the kbd_code. */
104
static unsigned int set_kdb_code(unsigned char c, unsigned int new_code)
105
{
106
	int i=0;
107
108
	/* the table is order so we can take a short cut for invalid code numbers */
109
	while(rc_kbd_matrix[i].rc_code != 0) {
110
		if(rc_kbd_matrix[i].rc_code > c) return 0; /* wasn't in list */
111
		if(rc_kbd_matrix[i].rc_code == c) {
112
			dbg("Changing translation from HID event 0x%X to 0x%X",rc_kbd_matrix[i].kbd_code, new_code);
113
			rc_kbd_matrix[i].kbd_code = new_code;
114
			return 1;
115
		}
116
		i++;
117
	}
118
119
	return 0;
120
}
121
122
123
/* Start of IOCTL specifics */
124
static int usb_xboxir_ioc_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
125
{
126
	struct t_rc_kbd_matrix input;
127
	int err=0;
128
	int ret=0;
129
130
	if (_IOC_TYPE(cmd) != XBOXIR_IOC_MAGIC) return -ENOTTY;
131
	if (_IOC_NR(cmd) > XBOXIR_IOC_MAXNR) return -ENOTTY;
132
133
	/* Check that the user space addresses are valid - we don't want an exception */
134
	if (_IOC_DIR(cmd) & _IOC_READ)
135
		err = !access_ok(VERIFY_WRITE, (void *)arg, _IOC_SIZE(cmd));
136
	else if (_IOC_DIR(cmd) & _IOC_WRITE)
137
		err = !access_ok(VERIFY_READ, (void *)arg, _IOC_SIZE(cmd));
138
	if (err) return -EFAULT;
139
140
	switch(cmd) {
141
142
		case XBOXIR_IOCSQSET:	/* user performing an update */
143
			if (copy_from_user(&input, (int *)arg, sizeof(input))) return -EFAULT;
144
			dbg("user sent struct containing rc_code=%X, kbd_code=%X",input.rc_code,input.kbd_code);
145
			if( (input.kbd_code = set_kdb_code( input.rc_code, input.kbd_code )) == 0 ) {
146
				ret = -1;
147
			} else {
148
				ret = 0;
149
			}
150
151
			break;
152
153
		case XBOXIR_IOCSQGET:	/* User is performing a query */
154
155
			if (copy_from_user(&input, (int *)arg, sizeof(input))) return -EFAULT;
156
			dbg("user sent struct containing rc_code=%X, kbd_code=%X",input.rc_code,input.kbd_code);
157
			if( (input.kbd_code = get_kdb_code( input.rc_code )) == 0 ) {
158
				ret = -1;
159
			} else {
160
				/* Return the structure to the user */
161
				dbg("we return containing rc_code=%X, kbd_code=%X",input.rc_code,input.kbd_code);
162
				if (copy_to_user((int *)arg, &input, sizeof(input))) return -EFAULT;
163
				ret = 0;
164
			}
165
			break;
166
		default:
167
			return -ENOTTY;
168
	}
169
170
	return ret;
171
}
172
173
static int usb_xboxir_ioc_open (struct inode *inode, struct file *file)
174
{
175
	return 0;
176
}
177
178
/* End of IOCTL specifics */
179
180
/*  USB callback completion handler
181
 *  Code in transfer_buffer is received as six unsigned chars
182
 *  Example PLAY=00 06 ea 0a 40 00
183
 *  The command is located in byte[2], the rest are ignored.
184
 *  Key position is byte[4] bit0 (7-0 format) 0=down, 1=up
185
 *  All other bits are unknown / now required.
186
 */
187
static void usb_xboxir_irq(struct urb *urb)
188
{
189
	struct usb_xboxir *xir = urb->context;
190
	unsigned int kbd_code=0;
191
	unsigned int key_direction=0; // 0=down, 1=up
192
193
	if (urb->status) return;
194
	if (urb->actual_length < 6) return;
195
196
	/* Messy/unnecessary, fix this */
197
	memcpy(xir->irpkt, urb->transfer_buffer, 6);
198
	if ( (kbd_code = get_kdb_code( xir->irpkt[2] )) == 0) return;
199
200
	/* Set the key action based in the sent action */
201
	key_direction =  ( xir->irpkt[4] & 1 ? 0 : 1) ;
202
203
	if(xir->previous_kbd_code) {
204
		input_report_key(&xir->dev, xir->previous_kbd_code, 0);
205
	}
206
207
	input_report_key(&xir->dev, kbd_code, key_direction);
208
209
	xir->previous_kbd_code=kbd_code;
210
211
	dbg("usb_xboxir_irq: actual_length=%d",urb->actual_length);
212
	dbg("%02x %02x %02x %02x %02x %02x"
213
		,xir->irpkt[0],xir->irpkt[1],xir->irpkt[2],xir->irpkt[3],xir->irpkt[4],xir->irpkt[5]);
214
215
}
216
217
static int usb_xboxir_open(struct input_dev *dev)
218
{
219
	struct usb_xboxir *xir = dev->private;
220
221
	if (xir->open++)
222
		return 0;
223
224
	xir->irq.dev = xir->usbdev;
225
	if (usb_submit_urb(&xir->irq))
226
		return -EIO;
227
228
	return 0;
229
}
230
231
static void usb_xboxir_close(struct input_dev *dev)
232
{
233
	struct usb_xboxir *xir = dev->private;
234
235
	if (!--xir->open)
236
		usb_unlink_urb(&xir->irq);
237
}
238
239
static void *usb_xboxir_probe(struct usb_device *dev, unsigned int ifnum,
240
			   const struct usb_device_id *id)
241
{
242
	struct usb_interface *iface;
243
	struct usb_interface_descriptor *interface;
244
	struct usb_endpoint_descriptor *endpoint;
245
	struct usb_xboxir *xir;
246
	int i, pipe, maxp;
247
	char *buf;
248
249
	dbg("usb_xboxir_probe");
250
251
	iface = &dev->actconfig->interface[ifnum];
252
	interface = &iface->altsetting[iface->act_altsetting];
253
254
	if (interface->bNumEndpoints != 1) return NULL;
255
256
	endpoint = interface->endpoint + 0;
257
	if (!(endpoint->bEndpointAddress & 0x80)) return NULL;
258
	if ((endpoint->bmAttributes & 3) != 3) return NULL;
259
260
	pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
261
	maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
262
263
	usb_set_protocol(dev, interface->bInterfaceNumber, 0);
264
	usb_set_idle(dev, interface->bInterfaceNumber, 0, 0);
265
266
	if (!(xir = kmalloc(sizeof(struct usb_xboxir), GFP_KERNEL))) return NULL;
267
	memset(xir, 0, sizeof(struct usb_xboxir));
268
269
	xir->usbdev = dev;
270
271
	// The kinds of events we can send (keyboard)
272
	xir->dev.evbit[0] = BIT(EV_KEY);
273
274
	i=0;
275
	while(rc_kbd_matrix[i].rc_code != 0) {
276
		set_bit(rc_kbd_matrix[i++].kbd_code, xir->dev.keybit);
277
	}
278
	clear_bit(0, xir->dev.keybit);
279
	
280
	xir->dev.private = xir;
281
	xir->dev.event = NULL;
282
	xir->dev.open = usb_xboxir_open;
283
	xir->dev.close = usb_xboxir_close;
284
285
	FILL_INT_URB(&xir->irq, dev, pipe, xir->irpkt, maxp > 8 ? 8 : maxp,
286
		usb_xboxir_irq, xir, endpoint->bInterval);
287
288
	xir->dr.bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
289
	xir->dr.bRequest = USB_REQ_SET_REPORT;
290
	xir->dr.wValue = 0x200;
291
	xir->dr.wIndex = interface->bInterfaceNumber;
292
	xir->dr.wLength = 1;
293
294
	xir->dev.name = xir->name;
295
	xir->dev.idbus = BUS_USB;
296
	xir->dev.idvendor = dev->descriptor.idVendor;
297
	xir->dev.idproduct = dev->descriptor.idProduct;
298
	xir->dev.idversion = dev->descriptor.bcdDevice;
299
300
	if (!(buf = kmalloc(63, GFP_KERNEL))) {
301
		kfree(xir);
302
		return NULL;
303
	}
304
305
	if (dev->descriptor.iManufacturer &&
306
		usb_string(dev, dev->descriptor.iManufacturer, buf, 63) > 0)
307
			strcat(xir->name, buf);
308
	
309
	if (dev->descriptor.iProduct &&
310
		usb_string(dev, dev->descriptor.iProduct, buf, 63) > 0)
311
			sprintf(xir->name, "%s %s", xir->name, buf);
312
313
	if (!strlen(xir->name))
314
		sprintf(xir->name, "USB HID XBOX IR %04x:%04x",
315
			xir->dev.idvendor, xir->dev.idproduct);
316
317
	kfree(buf);
318
319
	input_register_device(&xir->dev);
320
321
	dbg("input%d: %s on usb%d:%d.%d", xir->dev.number, xir->name, dev->bus->busnum, dev->devnum, ifnum);
322
323
	return xir;
324
}
325
326
static void usb_xboxir_disconnect(struct usb_device *dev, void *ptr)
327
{
328
	struct usb_xboxir *xir = ptr;
329
	usb_unlink_urb(&xir->irq);
330
	input_unregister_device(&xir->dev);
331
	kfree(xir);
332
}
333
334
static struct usb_device_id usb_xboxir_id_table [] = {
335
	{ USB_DEVICE(0x045e, 0x0284) }, /* Microsoft, DVD dongle */
336
	{ } /* Terminating entry */
337
};
338
339
MODULE_DEVICE_TABLE (usb, usb_xboxir_id_table);
340
341
static struct file_operations usb_xboxir_fops =
342
{
343
	.owner	= THIS_MODULE,
344
	.ioctl	= usb_xboxir_ioc_ioctl,
345
	.open	= usb_xboxir_ioc_open,
346
};
347
348
349
static struct usb_driver usb_xboxir_driver = {
350
	.name		= "usb-xboxir",
351
	.probe		= usb_xboxir_probe,
352
	.disconnect	= usb_xboxir_disconnect,
353
	.id_table	= usb_xboxir_id_table,
354
	.fops		= &usb_xboxir_fops,
355
	.minor		= XBOXIR_MINOR,
356
};
357
358
static int __init usb_xboxir_init(void)
359
{
360
	usb_register(&usb_xboxir_driver);
361
	proc_file_ent = create_proc_read_entry(PROC_FILE_NAME,
362
			PROC_FILE_PERMS, NULL, usb_xboxir_read_proc_ir, NULL);
363
	dbg("%s:%s", DRIVER_VERSION, DRIVER_DESC);
364
	return 0;
365
}
366
367
static void __exit usb_xboxir_exit(void)
368
{
369
	if (proc_file_ent)
370
		remove_proc_entry(PROC_FILE_NAME, NULL);
371
	usb_deregister(&usb_xboxir_driver);
372
}
373
374
module_init(usb_xboxir_init);
375
module_exit(usb_xboxir_exit);
376
377
MODULE_PARM(xboxir_debug, "i");
378
MODULE_AUTHOR(DRIVER_AUTHOR);
379
MODULE_DESCRIPTION(DRIVER_DESC);
380
MODULE_LICENSE("GPL");
381
382
#undef dbg
383
#endif
(-)linux-2.4.26/drivers/usb/usb-xboxir.h (+372 lines)
Line 0 Link Here
1
/*
2
 *  $Id: usb-xboxir.h,v 1.3 2002/12/02 23:04:58 oliverschwartz Exp $
3
 *
4
 *  Copyright (c) 2002 Steven Toth 
5
 *
6
 */
7
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
 * 
23
 * Should you need to contact me, the author, you can do so either by
24
 * e-mail - mail your message to <steve@toth.demon.co.uk>.
25
 */
26
27
#ifndef USB_XBOX_IR_H
28
#define USB_XBOX_IR_H
29
30
/*  These are all the XBOX remote control keys (and their unique codes).
31
 *  These are stored in a lookup table and translated into HID keyboard events
32
 */
33
#define RC_KEY_SELECT		0x0b
34
#define RC_KEY_UP				0xa6
35
#define RC_KEY_DOWN			0xa7
36
#define RC_KEY_RIGHT		0xa8
37
#define RC_KEY_LEFT			0xa9
38
#define RC_KEY_INFO			0xc3
39
#define RC_KEY_9				0xc6
40
#define RC_KEY_8				0xc7
41
#define RC_KEY_7				0xc8
42
#define RC_KEY_6				0xc9
43
#define RC_KEY_5				0xca
44
#define RC_KEY_4				0xcb
45
#define RC_KEY_3				0xcc
46
#define RC_KEY_2				0xcd
47
#define RC_KEY_1				0xce
48
#define RC_KEY_0				0xcf
49
#define RC_KEY_DISPLAY	0xd5
50
#define RC_KEY_BACK			0xd8
51
#define RC_KEY_SKIPF		0xdd
52
#define RC_KEY_SKIPB		0xdf
53
#define RC_KEY_STOP			0xe0
54
#define RC_KEY_REW			0xe2
55
#define RC_KEY_FWD			0xe3
56
#define RC_KEY_TITLE		0xe5
57
#define RC_KEY_PAUSE		0xe6
58
#define RC_KEY_PLAY			0xea
59
#define RC_KEY_MENU			0xf7
60
61
struct t_rc_kbd_matrix {
62
  unsigned char rc_code;
63
  unsigned int  kbd_code;
64
};
65
66
#ifdef MODULE
67
/*  An ORDERED table (rc_code) to enabling XBOX codes to be translated into HID keyboard codes */
68
static struct {
69
	unsigned char	rc_code;
70
	unsigned int	kbd_code;
71
} rc_kbd_matrix[] = {
72
	{ RC_KEY_SELECT,	KEY_ENTER },
73
	{ RC_KEY_UP,			KEY_UP },
74
	{ RC_KEY_DOWN,		KEY_DOWN },
75
	{ RC_KEY_RIGHT,		KEY_RIGHT },
76
	{ RC_KEY_LEFT,		KEY_LEFT },
77
	{ RC_KEY_INFO,		KEY_HELP },
78
	{ RC_KEY_9,				KEY_9 },
79
	{ RC_KEY_8,				KEY_8 },
80
	{ RC_KEY_7,				KEY_7 },
81
	{ RC_KEY_6,				KEY_6 },
82
	{ RC_KEY_5,				KEY_5 },
83
	{ RC_KEY_4,				KEY_4 },
84
	{ RC_KEY_3,				KEY_3 },
85
	{ RC_KEY_2,				KEY_2 },
86
	{ RC_KEY_1,				KEY_1 },
87
	{ RC_KEY_0,				KEY_0 },
88
	{ RC_KEY_DISPLAY,	KEY_HELP },
89
	{ RC_KEY_BACK,		KEY_BACK },
90
	{ RC_KEY_SKIPF,		KEY_PREVIOUSSONG },
91
	{ RC_KEY_SKIPB,		KEY_NEXTSONG },
92
	{ RC_KEY_STOP,		KEY_STOPCD },
93
	{ RC_KEY_REW,			KEY_REWIND },
94
	{ RC_KEY_FWD,			KEY_FORWARD },
95
	{ RC_KEY_TITLE,		KEY_MENU },
96
	{ RC_KEY_PAUSE,		KEY_PAUSECD },
97
	{ RC_KEY_PLAY,		KEY_PLAYCD },
98
	{ RC_KEY_MENU,		KEY_MENU },
99
	{ 0,0 }
100
};
101
102
struct usb_xboxir {
103
	struct input_dev dev;
104
	struct usb_device *usbdev;
105
	unsigned char irpkt[8];
106
	unsigned int previous_kbd_code;
107
	struct urb irq;
108
	struct usb_ctrlrequest dr;
109
	char name[128];
110
	int open;
111
};
112
#endif
113
114
/* Configure the ioctl stuff */
115
#define XBOXIR_IOC_MAGIC 's'
116
#define XBOXIR_IOCRESET _IO(XBOXIR_IOC_MAGIC, 0)
117
#define XBOXIR_IOCSQSET	_IOW(XBOXIR_IOC_MAGIC, 1, int)	// userland writes to device
118
#define XBOXIR_IOCSQGET	_IOR(XBOXIR_IOC_MAGIC, 2, int)	// userland reads from device
119
#define XBOXIR_IOC_MAXNR 2
120
121
struct {
122
	char *name;
123
	unsigned char code;
124
} rckeys[] = {
125
 {"RC_KEY_SELECT", RC_KEY_SELECT},
126
 {"RC_KEY_UP", RC_KEY_UP},
127
 {"RC_KEY_DOWN", RC_KEY_DOWN},
128
 {"RC_KEY_RIGHT", RC_KEY_RIGHT},
129
 {"RC_KEY_LEFT", RC_KEY_LEFT},
130
 {"RC_KEY_INFO", RC_KEY_INFO},
131
 {"RC_KEY_9", RC_KEY_9},
132
 {"RC_KEY_8", RC_KEY_8},
133
 {"RC_KEY_7", RC_KEY_7},
134
 {"RC_KEY_6", RC_KEY_6},
135
 {"RC_KEY_5", RC_KEY_5},
136
 {"RC_KEY_4", RC_KEY_4},
137
 {"RC_KEY_3", RC_KEY_3},
138
 {"RC_KEY_2", RC_KEY_2},
139
 {"RC_KEY_1", RC_KEY_1},
140
 {"RC_KEY_0", RC_KEY_0},
141
 {"RC_KEY_DISPLAY", RC_KEY_DISPLAY},
142
 {"RC_KEY_BACK", RC_KEY_BACK},
143
 {"RC_KEY_SKIPF", RC_KEY_SKIPF},
144
 {"RC_KEY_SKIPB", RC_KEY_SKIPB},
145
 {"RC_KEY_STOP", RC_KEY_STOP},
146
 {"RC_KEY_REW", RC_KEY_REW},
147
 {"RC_KEY_FWD", RC_KEY_FWD},
148
 {"RC_KEY_TITLE", RC_KEY_TITLE},
149
 {"RC_KEY_PAUSE", RC_KEY_PAUSE},
150
 {"RC_KEY_PLAY", RC_KEY_PLAY},
151
 {"RC_KEY_MENU", RC_KEY_MENU},
152
 {NULL, 0},
153
};
154
155
struct t_ult_hidkeys {
156
	char *name;
157
	unsigned int code;
158
} hidkeys[] = {
159
 {"KEY_RESERVED", KEY_RESERVED},
160
 {"KEY_ESC", KEY_ESC},
161
 {"KEY_1", KEY_1},
162
 {"KEY_2", KEY_2},
163
 {"KEY_3", KEY_3},
164
 {"KEY_4", KEY_4},
165
 {"KEY_5", KEY_5},
166
 {"KEY_6", KEY_6},
167
 {"KEY_7", KEY_7},
168
 {"KEY_8", KEY_8},
169
 {"KEY_9", KEY_9},
170
 {"KEY_0", KEY_0},
171
 {"KEY_MINUS", KEY_MINUS},
172
 {"KEY_EQUAL", KEY_EQUAL},
173
 {"KEY_BACKSPACE", KEY_BACKSPACE},
174
 {"KEY_TAB", KEY_TAB},
175
 {"KEY_Q", KEY_Q},
176
 {"KEY_W", KEY_W},
177
 {"KEY_E", KEY_E},
178
 {"KEY_R", KEY_R},
179
 {"KEY_T", KEY_T},
180
 {"KEY_Y", KEY_Y},
181
 {"KEY_U", KEY_U},
182
 {"KEY_I", KEY_I},
183
 {"KEY_O", KEY_O},
184
 {"KEY_P", KEY_P},
185
 {"KEY_LEFTBRACE", KEY_LEFTBRACE},
186
 {"KEY_RIGHTBRACE", KEY_RIGHTBRACE},
187
 {"KEY_ENTER", KEY_ENTER},
188
 {"KEY_LEFTCTRL", KEY_LEFTCTRL},
189
 {"KEY_A", KEY_A},
190
 {"KEY_S", KEY_S},
191
 {"KEY_D", KEY_D},
192
 {"KEY_F", KEY_F},
193
 {"KEY_G", KEY_G},
194
 {"KEY_H", KEY_H},
195
 {"KEY_J", KEY_J},
196
 {"KEY_K", KEY_K},
197
 {"KEY_L", KEY_L},
198
 {"KEY_SEMICOLON", KEY_SEMICOLON},
199
 {"KEY_APOSTROPHE", KEY_APOSTROPHE},
200
 {"KEY_GRAVE", KEY_GRAVE},
201
 {"KEY_LEFTSHIFT", KEY_LEFTSHIFT},
202
 {"KEY_BACKSLASH", KEY_BACKSLASH},
203
 {"KEY_Z", KEY_Z},
204
 {"KEY_X", KEY_X},
205
 {"KEY_C", KEY_C},
206
 {"KEY_V", KEY_V},
207
 {"KEY_B", KEY_B},
208
 {"KEY_N", KEY_N},
209
 {"KEY_M", KEY_M},
210
 {"KEY_COMMA", KEY_COMMA},
211
 {"KEY_DOT", KEY_DOT},
212
 {"KEY_SLASH", KEY_SLASH},
213
 {"KEY_RIGHTSHIFT", KEY_RIGHTSHIFT},
214
 {"KEY_KPASTERISK", KEY_KPASTERISK},
215
 {"KEY_LEFTALT", KEY_LEFTALT},
216
 {"KEY_SPACE", KEY_SPACE},
217
 {"KEY_CAPSLOCK", KEY_CAPSLOCK},
218
 {"KEY_F1", KEY_F1},
219
 {"KEY_F2", KEY_F2},
220
 {"KEY_F3", KEY_F3},
221
 {"KEY_F4", KEY_F4},
222
 {"KEY_F5", KEY_F5},
223
 {"KEY_F6", KEY_F6},
224
 {"KEY_F7", KEY_F7},
225
 {"KEY_F8", KEY_F8},
226
 {"KEY_F9", KEY_F9},
227
 {"KEY_F10", KEY_F10},
228
 {"KEY_NUMLOCK", KEY_NUMLOCK},
229
 {"KEY_SCROLLLOCK", KEY_SCROLLLOCK},
230
 {"KEY_KP7", KEY_KP7},
231
 {"KEY_KP8", KEY_KP8},
232
 {"KEY_KP9", KEY_KP9},
233
 {"KEY_KPMINUS", KEY_KPMINUS},
234
 {"KEY_KP4", KEY_KP4},
235
 {"KEY_KP5", KEY_KP5},
236
 {"KEY_KP6", KEY_KP6},
237
 {"KEY_KPPLUS", KEY_KPPLUS},
238
 {"KEY_KP1", KEY_KP1},
239
 {"KEY_KP2", KEY_KP2},
240
 {"KEY_KP3", KEY_KP3},
241
 {"KEY_KP0", KEY_KP0},
242
 {"KEY_KPDOT", KEY_KPDOT},
243
 {"KEY_103RD", KEY_103RD},
244
 {"KEY_F13", KEY_F13},
245
 {"KEY_102ND", KEY_102ND},
246
 {"KEY_F11", KEY_F11},
247
 {"KEY_F12", KEY_F12},
248
 {"KEY_F14", KEY_F14},
249
 {"KEY_F15", KEY_F15},
250
 {"KEY_F16", KEY_F16},
251
 {"KEY_F17", KEY_F17},
252
 {"KEY_F18", KEY_F18},
253
 {"KEY_F19", KEY_F19},
254
 {"KEY_F20", KEY_F20},
255
 {"KEY_KPENTER", KEY_KPENTER},
256
 {"KEY_RIGHTCTRL", KEY_RIGHTCTRL},
257
 {"KEY_KPSLASH", KEY_KPSLASH},
258
 {"KEY_SYSRQ", KEY_SYSRQ},
259
 {"KEY_RIGHTALT", KEY_RIGHTALT},
260
 {"KEY_LINEFEED", KEY_LINEFEED},
261
 {"KEY_HOME", KEY_HOME},
262
 {"KEY_UP", KEY_UP},
263
 {"KEY_PAGEUP", KEY_PAGEUP},
264
 {"KEY_LEFT", KEY_LEFT},
265
 {"KEY_RIGHT", KEY_RIGHT},
266
 {"KEY_END", KEY_END},
267
 {"KEY_DOWN", KEY_DOWN},
268
 {"KEY_PAGEDOWN", KEY_PAGEDOWN},
269
 {"KEY_INSERT", KEY_INSERT},
270
 {"KEY_DELETE", KEY_DELETE},
271
 {"KEY_MACRO", KEY_MACRO},
272
 {"KEY_MUTE", KEY_MUTE},
273
 {"KEY_VOLUMEDOWN", KEY_VOLUMEDOWN},
274
 {"KEY_VOLUMEUP", KEY_VOLUMEUP},
275
 {"KEY_POWER", KEY_POWER},
276
 {"KEY_KPEQUAL", KEY_KPEQUAL},
277
 {"KEY_KPPLUSMINUS", KEY_KPPLUSMINUS},
278
 {"KEY_PAUSE", KEY_PAUSE},
279
 {"KEY_F21", KEY_F21},
280
 {"KEY_F22", KEY_F22},
281
 {"KEY_F23", KEY_F23},
282
 {"KEY_F24", KEY_F24},
283
 {"KEY_KPCOMMA", KEY_KPCOMMA},
284
 {"KEY_LEFTMETA", KEY_LEFTMETA},
285
 {"KEY_RIGHTMETA", KEY_RIGHTMETA},
286
 {"KEY_COMPOSE", KEY_COMPOSE},
287
 {"KEY_STOP", KEY_STOP},
288
 {"KEY_AGAIN", KEY_AGAIN},
289
 {"KEY_PROPS", KEY_PROPS},
290
 {"KEY_UNDO", KEY_UNDO},
291
 {"KEY_FRONT", KEY_FRONT},
292
 {"KEY_COPY", KEY_COPY},
293
 {"KEY_OPEN", KEY_OPEN},
294
 {"KEY_PASTE", KEY_PASTE},
295
 {"KEY_FIND", KEY_FIND},
296
 {"KEY_CUT", KEY_CUT},
297
 {"KEY_HELP", KEY_HELP},
298
 {"KEY_MENU", KEY_MENU},
299
 {"KEY_CALC", KEY_CALC},
300
 {"KEY_SETUP", KEY_SETUP},
301
 {"KEY_SLEEP", KEY_SLEEP},
302
 {"KEY_WAKEUP", KEY_WAKEUP},
303
 {"KEY_FILE", KEY_FILE},
304
 {"KEY_SENDFILE", KEY_SENDFILE},
305
 {"KEY_DELETEFILE", KEY_DELETEFILE},
306
 {"KEY_XFER", KEY_XFER},
307
 {"KEY_PROG1", KEY_PROG1},
308
 {"KEY_PROG2", KEY_PROG2},
309
 {"KEY_WWW", KEY_WWW},
310
 {"KEY_MSDOS", KEY_MSDOS},
311
 {"KEY_COFFEE", KEY_COFFEE},
312
 {"KEY_DIRECTION", KEY_DIRECTION},
313
 {"KEY_CYCLEWINDOWS", KEY_CYCLEWINDOWS},
314
 {"KEY_MAIL", KEY_MAIL},
315
 {"KEY_BOOKMARKS", KEY_BOOKMARKS},
316
 {"KEY_COMPUTER", KEY_COMPUTER},
317
 {"KEY_BACK", KEY_BACK},
318
 {"KEY_FORWARD", KEY_FORWARD},
319
 {"KEY_CLOSECD", KEY_CLOSECD},
320
 {"KEY_EJECTCD", KEY_EJECTCD},
321
 {"KEY_EJECTCLOSECD", KEY_EJECTCLOSECD},
322
 {"KEY_NEXTSONG", KEY_NEXTSONG},
323
 {"KEY_PLAYPAUSE", KEY_PLAYPAUSE},
324
 {"KEY_PREVIOUSSONG", KEY_PREVIOUSSONG},
325
 {"KEY_STOPCD", KEY_STOPCD},
326
 {"KEY_RECORD", KEY_RECORD},
327
 {"KEY_REWIND", KEY_REWIND},
328
 {"KEY_PHONE", KEY_PHONE},
329
 {"KEY_ISO", KEY_ISO},
330
 {"KEY_CONFIG", KEY_CONFIG},
331
 {"KEY_HOMEPAGE", KEY_HOMEPAGE},
332
 {"KEY_REFRESH", KEY_REFRESH},
333
 {"KEY_EXIT", KEY_EXIT},
334
 {"KEY_MOVE", KEY_MOVE},
335
 {"KEY_EDIT", KEY_EDIT},
336
 {"KEY_SCROLLUP", KEY_SCROLLUP},
337
 {"KEY_SCROLLDOWN", KEY_SCROLLDOWN},
338
 {"KEY_KPLEFTPAREN", KEY_KPLEFTPAREN},
339
 {"KEY_KPRIGHTPAREN", KEY_KPRIGHTPAREN},
340
 {"KEY_INTL1", KEY_INTL1},
341
 {"KEY_INTL2", KEY_INTL2},
342
 {"KEY_INTL3", KEY_INTL3},
343
 {"KEY_INTL4", KEY_INTL4},
344
 {"KEY_INTL5", KEY_INTL5},
345
 {"KEY_INTL6", KEY_INTL6},
346
 {"KEY_INTL7", KEY_INTL7},
347
 {"KEY_INTL8", KEY_INTL8},
348
 {"KEY_INTL9", KEY_INTL9},
349
 {"KEY_LANG1", KEY_LANG1},
350
 {"KEY_LANG2", KEY_LANG2},
351
 {"KEY_LANG3", KEY_LANG3},
352
 {"KEY_LANG4", KEY_LANG4},
353
 {"KEY_LANG5", KEY_LANG5},
354
 {"KEY_LANG6", KEY_LANG6},
355
 {"KEY_LANG7", KEY_LANG7},
356
 {"KEY_LANG8", KEY_LANG8},
357
 {"KEY_LANG9", KEY_LANG9},
358
 {"KEY_PLAYCD", KEY_PLAYCD},
359
 {"KEY_PAUSECD", KEY_PAUSECD},
360
 {"KEY_PROG3", KEY_PROG3},
361
 {"KEY_PROG4", KEY_PROG4},
362
 {"KEY_SUSPEND", KEY_SUSPEND},
363
 {"KEY_CLOSE", KEY_CLOSE},
364
 {"KEY_UNKNOWN", KEY_UNKNOWN},
365
 {"KEY_BRIGHTNESSDOWN", KEY_BRIGHTNESSDOWN},
366
 {"KEY_BRIGHTNESSUP", KEY_BRIGHTNESSUP},
367
 {"KEY_MAX", KEY_MAX},
368
 {NULL, 0},
369
};
370
371
#endif
372
(-)linux-2.4.26/drivers/usb/xir.c (+364 lines)
Line 0 Link Here
1
/*
2
 * Xbox DVD Playback Kit receiver driver for Linux - v0.0.2
3
 *
4
 * Copyright (c)  2004  Marko Friedemann <mfr@bmx-chemnitz.de>
5
 *
6
 *	Contributors:
7
 *		Steven Toth <steve@toth.demon.co.uk>,
8
 *		Christoph Bartelmus <lirc@bartelmus.de>,
9
 *		Wayne Hogue <w_hogue@hotmail.com>
10
 *
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License as
14
 * published by the Free Software Foundation; either version 2 of
15
 * the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
 *
26
 *
27
 * This driver is based on:
28
 *  - usb-xboxir	by Steven Toth (keyboard emu for the remote)
29
 *  - xpad driver	notes there apply
30
 *
31
 * Thanks to:
32
 *  - Christoph Bartelmus - essential info about the data from USB receiver
33
 *  - Wayne Hogue	  - tests with various remotes, error reports + fixes
34
 *
35
 * TODO:
36
 *  - implement event queue to notify LIRC
37
 *
38
 * History: moved to end of file
39
 */
40
 
41
#include <linux/config.h>
42
#include <linux/kernel.h>
43
#include <linux/init.h>
44
#include <linux/slab.h>
45
#include <linux/module.h>
46
#include <linux/smp_lock.h>
47
//#include <linux/devfs_fs_kernel.h>
48
#include <linux/proc_fs.h>
49
#include <linux/usb.h>
50
#include <linux/version.h>
51
#include <linux/timer.h>
52
#include <asm/uaccess.h>
53
54
#define __USB_XIR
55
#include "xir.h"
56
#undef __USB_XIR
57
58
/* some debug output macros */
59
60
#undef warn
61
#define warn(format, arg...) (xir_verbosity > 0) && printk(KERN_WARNING __FILE__ ": " format "\n" , ## arg)
62
63
#undef info
64
#define info(format, arg...) (xir_verbosity > 1) && printk(KERN_INFO __FILE__ ": " format "\n" , ## arg)
65
66
#undef dbg
67
#define dbg(format, arg...) (xir_verbosity > 2) && printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg)
68
69
int xir_verbosity = 0;
70
MODULE_PARM(xir_verbosity, "i");
71
MODULE_PARM_DESC(xir_verbosity, "\nverbosity level, default: errors only (=0)\n"
72
			    "  +warnings: 1\n"
73
			    "  +info: 2\n"
74
	                    "  +all: 3+");
75
76
/* FIXME: avoid this static */
77
static struct usb_xir *__xir = NULL;
78
79
static struct xir_device xir_device[] = {
80
	/* please keep those ordered wrt. vendor/product ids
81
	  vendor, product, dvd-dongle, name                  */
82
	{ 0x040b, 0x6521, "Gamester Xbox DVD Movie Playback Kit IR" },
83
	{ 0x045e, 0x0284, "Microsoft Xbox DVD Movie Playback Kit IR" },
84
	{ 0x0000, 0x0000, "nothing detected - FAIL" }
85
};
86
87
static struct usb_device_id xir_table [] = {
88
	{ USB_INTERFACE_INFO('X', 'B', 0) },	/* Xbox USB-IF not approved class */
89
	{ }
90
};
91
92
MODULE_DEVICE_TABLE(usb, xir_table);
93
94
static unsigned char xir_get_keycode(int byteNum)
95
{
96
	unsigned char retval;
97
	
98
	if (__xir == NULL)
99
		return 0;
100
101
	if (byteNum > XIR_CODE_BYTES-1) {
102
		err("BUG: cannot get byte %d from %d byte keycode",
103
		    byteNum, XIR_CODE_BYTES-1);
104
		return 0;
105
	}
106
107
	/* CHECKME: shouldn't be no sync neccessary here, should there? */
108
	if (0 == CIRC_CNT(__xir->rx.head, __xir->rx.tail,
109
			  XIR_RXBUF_LEN))
110
		return 0;
111
112
	retval = (unsigned char)__xir->rx.buf[
113
		__xir->rx.head*XIR_CODE_BYTES + byteNum];
114
	
115
	if (byteNum == XIR_CODE_BYTES-1)
116
		XIR_RXBUF_INC(__xir->rx.head);
117
	
118
	return retval;
119
}
120
121
/**
122
 *	xir_lirc_open
123
 *
124
 *	Called from lirc_xir upon usage by lircd.
125
 */
126
static int xir_lirc_open(void)
127
{
128
	if (__xir == NULL) {
129
		warn("device not initialized");
130
		return -ENODEV;
131
	}
132
	
133
	if (__xir->open_count)
134
		return 0;
135
		
136
	info("opening device");
137
	
138
	__xir->irq_in->dev = __xir->udev;
139
	if (usb_submit_urb(__xir->irq_in)) {
140
		err("open input urb failed");
141
		return -EIO;
142
	}
143
	
144
	++__xir->open_count;
145
146
	return 0;
147
}
148
149
/**
150
 *	xir_lirc_close
151
 *
152
 *	Called from lirc_xir upon close event from lircd.
153
 */
154
static void xir_lirc_close(void)
155
{
156
	if (__xir == NULL)
157
		return;
158
159
	if (!--__xir->open_count) {
160
		info("closing device");
161
		usb_unlink_urb(__xir->irq_in);
162
	}
163
}
164
165
EXPORT_SYMBOL(xir_get_keycode);
166
EXPORT_SYMBOL(xir_lirc_open);
167
EXPORT_SYMBOL(xir_lirc_close);
168
169
/**
170
 *	xir_process_packet
171
 *
172
 *	Completes a request by converting the data into events
173
 *	for the input subsystem.
174
 */
175
static void xir_process_packet(struct usb_xir *xir, u16 cmd, unsigned char *data)
176
{
177
	unsigned int _3nibbles = 0;
178
179
	if (xir == NULL)
180
		return;
181
	
182
	dbg("irpp: %02x %02x %02x %02x %02x %02x", data[0], data[1],
183
		data[2], data[3], data[4], data[5]);
184
	
185
	/* RCA (RC-5/-6?) codes use 6 nibbles, 3 of which are the complement
186
	    of the others, we therefore cannot allow for data[3] to be > 0x0F
187
	   since lirc cannot handle 0x00 as a data byte (used as end marker)
188
	    we cannot allow for 0x0F even, because a code of 0x0F 0xF0 would
189
	    translate to 0x00FFF0, which makes lirc choke */
190
	if (data[3] > 0x0E) {
191
		warn("cannot handle bad IR data 0x%01X%02X, key ignored",
192
		     data[3], data[2]);
193
		return;
194
	}
195
196
	/* CHECKME: shouldn't be no sync neccessary here, should there? */
197
	if (0 == CIRC_SPACE(xir->rx.head, xir->rx.tail,
198
			   XIR_RXBUF_LEN))
199
	{
200
		warn("no space left in buffer: keypress lost");
201
		return;
202
	}
203
	
204
	/* the dongle removes the IR redundancy
205
	 * to stay compatible with RCA codes (which the remote sends)
206
	 *  we simply recreate it */
207
	_3nibbles = ((data[3] & 0x0f) << 8) + data[2];
208
	
209
	xir->rx.buf[xir->rx.tail*XIR_CODE_BYTES] = (~_3nibbles & 0xfff) >> 4;
210
	xir->rx.buf[xir->rx.tail*XIR_CODE_BYTES+1] = ((~_3nibbles & 0x0f) << 4)
211
						     + (_3nibbles >> 8);
212
	xir->rx.buf[xir->rx.tail*XIR_CODE_BYTES+2] = data[2];
213
	
214
	XIR_RXBUF_INC(xir->rx.tail);
215
}
216
217
/**
218
 *	xir_irq_in
219
 *
220
 *	Completion handler for interrupt in transfers (user input).
221
 *	Just calls xir_process_packet which does then emit input events.
222
 */
223
static void xir_irq_in(struct urb *urb)
224
{
225
	struct usb_xir *xir = urb->context;
226
	
227
	if (urb->status) {
228
		warn("urb status");
229
		return;
230
	}
231
	
232
	xir_process_packet(xir, 0, xir->idata);
233
}
234
235
/**
236
 *	xir_probe
237
 *
238
 *	Called upon device detection to find a suitable driver.
239
 *	Must return NULL when no xir is found, else setup everything.
240
 */
241
static void * xir_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id)
242
{
243
        int i;
244
	int probedDevNum = -1;	/* this takes the index into the known devices
245
				   array for the recognized device */
246
	
247
	struct usb_xir *xir = NULL;
248
	struct usb_endpoint_descriptor *ep_irq_in;
249
	
250
	// try to detect the device we are called for
251
	for (i = 0; xir_device[i].idVendor; ++i) {
252
		if ((udev->descriptor.idVendor == xir_device[i].idVendor) &&
253
		    (udev->descriptor.idProduct == xir_device[i].idProduct)) {
254
			probedDevNum = i;
255
			break;
256
		}
257
	}
258
	
259
	// sanity check, did we recognize this device? if not, fail
260
	if ((probedDevNum == -1) || (!xir_device[probedDevNum].idVendor &&
261
				     !xir_device[probedDevNum].idProduct))
262
		return NULL;
263
		
264
	if ((xir = kmalloc (sizeof(struct usb_xir), GFP_KERNEL)) == NULL) {
265
		err("cannot allocate memory for new IR receiver");
266
		return NULL;
267
	}
268
	memset(xir, 0, sizeof(struct usb_xir));
269
	
270
	xir->udev = udev;
271
	ep_irq_in = udev->actconfig->interface[ifnum].altsetting[0].endpoint + 0;
272
	
273
	/* setup input interrupt pipe (button and axis state) */
274
	xir->irq_in = usb_alloc_urb(0);
275
        if (!xir->irq_in) {
276
		err("cannot allocate memory for new IR receiver irq urb");
277
                kfree(xir);
278
                return NULL;
279
	}
280
	
281
	/* init input URB for USB INT transfer from device */
282
	FILL_INT_URB(xir->irq_in, udev,
283
		     usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),
284
		     xir->idata, XIR_PKT_LEN,
285
		     xir_irq_in, xir, ep_irq_in->bInterval);
286
	
287
	// XIR_CODE_BYTES bytes per key!
288
	xir->rx.buf = kmalloc(XIR_RXBUF_LEN * XIR_CODE_BYTES, GFP_KERNEL);
289
	if (xir->rx.buf == NULL) {
290
		err("cannot allocate memory for new IR input buffer");
291
		return NULL;
292
	}
293
	memset(xir->rx.buf, 0, XIR_RXBUF_LEN * XIR_CODE_BYTES);
294
	
295
	info("%s", xir_device[probedDevNum].name);
296
	
297
	__xir = xir;
298
	return xir;
299
}
300
301
/**
302
 *	xir_disconnect
303
 *
304
 *	Called upon device disconnect to dispose of the structures and
305
 *	close the USB connections.
306
 */
307
static void xir_disconnect(struct usb_device *udev, void *ptr)
308
{
309
	struct usb_xir *xir = ptr;
310
	if (xir != __xir)
311
		err("BUG: usb dev != lirc dev, possible memory leak");
312
	
313
	info( "disconnecting device" );
314
	
315
	usb_unlink_urb(xir->irq_in);
316
	usb_free_urb(xir->irq_in);
317
	
318
	kfree(xir->rx.buf);
319
	kfree(xir);
320
	
321
	__xir = NULL;
322
}
323
324
/******************* Linux driver framework specific stuff ************/
325
326
static struct usb_driver xir_driver = {
327
	.name		= "xir",
328
	.probe		= xir_probe,
329
	.disconnect	= xir_disconnect,
330
	.id_table	= xir_table,
331
};
332
333
/**
334
 * driver init entry point
335
 */
336
static int __init usb_xir_init(void)
337
{
338
	int result = usb_register(&xir_driver);
339
	if (result == 0)
340
		info(DRIVER_DESC " " DRIVER_VERSION);
341
	return result;
342
}
343
344
/**
345
 * driver exit entry point
346
 */
347
static void __exit usb_xir_exit(void)
348
{
349
	usb_deregister(&xir_driver);
350
}
351
352
module_init(usb_xir_init);
353
module_exit(usb_xir_exit);
354
355
MODULE_AUTHOR(DRIVER_AUTHOR);
356
MODULE_DESCRIPTION(DRIVER_DESC);
357
MODULE_LICENSE("GPL");
358
359
/*
360
 *  driver history
361
 * ----------------
362
 *
363
 * 2002-06-27 - 0.0.1 : first version, just said "XBOX HID controller"
364
 */
(-)linux-2.4.26/drivers/usb/xir.h (+71 lines)
Line 0 Link Here
1
/*
2
 * Xbox DVD Playback Kit receiver driver for Linux - v0.0.2
3
 *
4
 * Copyright (c)  2004  Marko Friedemann <mfr@bmx-chemnitz.de>
5
 *
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License as
9
 * published by the Free Software Foundation; either version 2 of
10
 * the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
 */
21
 
22
#ifndef __XIR_h
23
#define __XIR_h
24
25
26
/************************* driver internals ***************************/
27
#ifdef __KERNEL__
28
29
#ifndef __USB_XIR
30
 extern unsigned char xir_get_keycode(int byteNum);
31
 extern int xir_lirc_open(void);
32
 extern void xir_lirc_close(void);
33
#endif
34
35
#include <linux/input.h>
36
#include <linux/circ_buf.h>
37
38
/****************** driver description and version ********************/
39
#define DRIVER_VERSION		"v0.0.2"
40
#define DRIVER_AUTHOR		"Marko Friedemann <mfr@bmx-chemnitz.de>"
41
42
#define DRIVER_DESC		"driver for Xbox DVD Playback Kit receiver"
43
44
/****************************** constants *****************************/
45
#define XIR_PKT_LEN		6	/* input packet size */
46
#define XIR_CODE_BYTES		3
47
#define XIR_RXBUF_LEN	   	30
48
#define XIR_RXBUF_INC(var)	(var) += 1; (var) %= XIR_RXBUF_LEN
49
50
/************************* the device struct **************************/
51
struct usb_xir {
52
	struct usb_device *udev;		/* usb device */
53
	
54
	struct urb *irq_in;			/* urb for int. in report */
55
	unsigned char idata[XIR_PKT_LEN];	/* input data */
56
	
57
	int open_count;				/* reference count */
58
	
59
	struct circ_buf rx;			/* ring buffer for IR input */
60
};
61
62
/* for the list of know devices */
63
struct xir_device {
64
	u16 idVendor;
65
	u16 idProduct;
66
	char *name;
67
};
68
69
#endif /* __KERNEL__ */
70
71
#endif /* __XIR_h */
(-)linux-2.4.26/drivers/usb/xpad-core.c (+728 lines)
Line 0 Link Here
1
/*
2
 * Xbox input device driver for Linux - v0.1.5
3
 *
4
 * Copyright (c)  2002 - 2004  Marko Friedemann <mfr@bmx-chemnitz.de>
5
 *
6
 *	Contributors:
7
 *		Vojtech Pavlik <vojtech@suse.sz>,
8
 *		Oliver Schwartz <Oliver.Schwartz@gmx.de>,
9
 *		Steven Toth <steve@toth.demon.co.uk>,
10
 *		Franz Lehner <franz@caos.at>,
11
 *		Ivan Hawkes <blackhawk@ivanhawkes.com>
12
 *
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License as
16
 * published by the Free Software Foundation; either version 2 of
17
 * the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
 *
28
 *
29
 * This driver is based on:
30
 *  - information from     http://euc.jp/periphs/xbox-controller.en.html
31
 *  - the iForce driver    drivers/char/joystick/iforce.c
32
 *  - the skeleton-driver  drivers/usb/usb-skeleton.c
33
 *
34
 * Thanks to:
35
 *  - ITO Takayuki for providing essential xpad information on his website
36
 *  - Vojtech Pavlik     - iforce driver / input subsystem
37
 *  - Greg Kroah-Hartman - usb-skeleton driver
38
 *
39
 * TODO:
40
 *  - fine tune axes
41
 *  - fine tune mouse behaviour (should not do linear acceleration)
42
 *  - NEW: get rumble working correctly, fix all the bugs and support multiple
43
 *         simultaneous effects
44
 *  - NEW: split funtionality mouse/joustick into two source files
45
 *  - NEW: implement /proc interface (toggle mouse/rumble enable/disable, etc.)
46
 *  - NEW: implement user space daemon application that handles that interface
47
 *
48
 * History: moved to end of file
49
 */
50
 
51
#include <linux/config.h>
52
#include <linux/kernel.h>
53
#include <linux/init.h>
54
#include <linux/slab.h>
55
#include <linux/module.h>
56
#include <linux/smp_lock.h>
57
//#include <linux/devfs_fs_kernel.h>
58
#include <linux/proc_fs.h>
59
#include <linux/usb.h>
60
#include <linux/version.h>
61
#include <linux/timer.h>
62
#include <asm/uaccess.h>
63
64
#include "xpad.h"
65
66
67
static struct xpad_device xpad_device[] = {
68
	/* please keep those ordered wrt. vendor/product ids
69
	  vendor, product, isMat, name                              */
70
	{ 0x044f, 0x0f07, 0, "Thrustmaster, Inc. Controller" },
71
	{ 0x045e, 0x0202, 0, "Microsoft Xbox Controller" },
72
	{ 0x045e, 0x0285, 0, "Microsoft Xbox Controller S" },
73
	{ 0x045e, 0x0289, 0, "Microsoft Xbox Controller S" }, /* microsoft is stupid */
74
	{ 0x046d, 0xca88, 0, "Logitech Compact Controller for Xbox" },
75
	{ 0x05fd, 0x1007, 0, "???Mad Catz Controller???" }, /* CHECKME: this seems strange */
76
	{ 0x05fd, 0x107a, 0, "InterAct PowerPad Pro" },
77
	{ 0x0738, 0x4516, 0, "Mad Catz Control Pad" },
78
	{ 0x0738, 0x4522, 0, "Mad Catz LumiCON" },
79
	{ 0x0738, 0x4526, 0, "Mad Catz Control Pad Pro" },
80
	{ 0x0738, 0x4536, 0, "Mad Catz MicroCON" },
81
	{ 0x0738, 0x4540, 1, "Mad Catz Beat Pad" },
82
	{ 0x0738, 0x4556, 0, "Mad Catz Lynx Wireless Controller" },
83
	{ 0x0738, 0x6040, 1, "Mad Catz Beat Pad Pro" },
84
	{ 0x0c12, 0x9902, 0, "HAMA VibraX - *FAULTY HARDWARE*" }, /* these are broken */
85
	{ 0x0e4c, 0x2390, 0, "Radica Games Jtech Controller"},
86
	{ 0x0e6f, 0x0003, 0, "Logic3 Freebird wireless Controller" },
87
	{ 0x0f30, 0x0202, 0, "Joytech Advanced Controller" },
88
	{ 0x12ab, 0x8809, 1, "Xbox DDR dancepad" },
89
	{ 0xffff, 0xffff, 0, "Chinese-made Xbox Controller" }, /* WTF are device IDs for? */
90
	{ 0x0000, 0x0000, 0, "nothing detected - FAIL" }
91
};
92
93
static signed short xpad_btn[] = {
94
	BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z,	/* analogue buttons */
95
	BTN_START, BTN_BACK, BTN_THUMBL, BTN_THUMBR,	/* start/back/sticks */
96
	BTN_0, BTN_1, BTN_2, BTN_3,			/* d-pad as buttons */
97
	-1						/* terminating entry */
98
};
99
100
/* these have no analogue inputs and only 10 buttons */
101
static signed short xpad_mat_btn[] = {
102
	BTN_A, BTN_B, BTN_X, BTN_Y, 	/* A, B, X, Y */
103
	BTN_START, BTN_BACK, 		/* start/back */
104
	BTN_0, BTN_1, BTN_2, BTN_3,	/* directions, LEFT/RIGHT is mouse
105
					 * so we cannot use those! */
106
	-1				/* terminating entry */
107
};
108
109
static signed short xpad_abs[] = {
110
	ABS_X, ABS_Y,		/* left stick */
111
	ABS_RX, ABS_RY,		/* right stick */
112
	ABS_Z, ABS_RZ,		/* triggers left/right */
113
	ABS_HAT0X, ABS_HAT0Y,	/* digital pad (d-pad) as axes */
114
	ABS_HAT1X, ABS_HAT1Y,	/* analogue buttons A + B */
115
	ABS_HAT2X, ABS_HAT2Y,	/* analogue buttons C + X */
116
	ABS_HAT3X, ABS_HAT3Y,	/* analogue buttons Y + Z */
117
	-1			/* terminating entry */
118
};
119
120
static struct usb_device_id xpad_table [] = {
121
	{ USB_INTERFACE_INFO('X', 'B', 0) },	/* Xbox USB-IF not approved class */
122
	{ USB_INTERFACE_INFO( 3 ,  0 , 0) },	/* for Joytech Advanced Controller */
123
	{ }
124
};
125
126
MODULE_DEVICE_TABLE(usb, xpad_table);
127
128
static struct usb_xpad *xpad_units[XPAD_MAX_DEVICES];
129
static struct proc_dir_entry *xpad_procdir_units = NULL;
130
131
/***************** Linux /proc filesystem specific functions **********/
132
/**
133
 *	xpad_proc_read_info
134
 *
135
 *	Used to display general driver information in a /proc fs entry.
136
 *	Called when /proc/driver/xpad/info is read from userspace.
137
 */
138
static int xpad_proc_read_info(char *buf, char **start, off_t offset, int count, int *eof, void *data)
139
{
140
	int len=0, i;
141
//	struct usb_xpad *xpad = (struct usb_xpad *)data;
142
143
	len += sprintf( buf+len, "xpad driver %s\n", DRIVER_VERSION );
144
	
145
	len += sprintf( buf+len, "\ndetected units (up to %d devices supported):\n", XPAD_MAX_DEVICES );
146
	for (i=0; i<XPAD_MAX_DEVICES; ++i) {
147
		len += sprintf( buf+len, "\t%d:\t", i );
148
		if (xpad_units[i] == NULL)
149
			len += sprintf( buf+len, "not connected\n" );
150
		else
151
			len += sprintf( buf+len, "%s\n", xpad_units[i]->dev.name );
152
	}
153
	
154
	len += sprintf( buf+len, "\njoystick support available:\tyes\n\n" );
155
	
156
	xpad_mouse_proc_read_info(buf, start, offset, count, eof, data, &len);
157
	xpad_rumble_proc_read_info(buf, start, offset, count, eof, data, &len);
158
	
159
	*eof = 1;
160
	return len;
161
}
162
163
/**
164
 *	xpad_proc_read_unit_info
165
 *
166
 *	Called when an application reads /proc/driver/xpad/units/<unitnumber>.
167
 *	Reports some device data.
168
 */
169
static int xpad_proc_read_unit_info(char *buf, char **start, off_t offset, int count, int *eof, void *data)
170
{
171
	int len=0;
172
	struct usb_xpad *xpad = (struct usb_xpad *)data;
173
	
174
	len += sprintf( buf+len, "device name:\t%s\n", xpad->dev.name );
175
	xpad_mouse_proc_read_unit_info(buf, start, offset, count, eof, data, &len);
176
	xpad_rumble_proc_read_unit_info(buf, start, offset, count, eof, data, &len);
177
	
178
	*eof = 1;
179
	return len;
180
}
181
182
/**
183
 *	xpad_proc_create
184
 *
185
 *	Called upon driver initialization to create the entries for the
186
 *	/proc file system and clear out the array of known devices.
187
 */
188
static int xpad_proc_create(void)
189
{
190
	struct proc_dir_entry *entry;
191
	
192
	/* world readable directory */
193
	int i, flags = S_IFDIR | S_IRUGO | S_IXUGO;
194
	
195
	for (i=0; i<XPAD_MAX_DEVICES; ++i)
196
		xpad_units[i] = NULL;
197
	
198
	entry = create_proc_entry( "xpad", flags, proc_root_driver );
199
	xpad_procdir_units = create_proc_entry( "units",  flags, entry );
200
	
201
	/* world readable file */
202
	flags = S_IFREG | S_IRUGO;
203
	
204
	entry = create_proc_entry( "info", flags, entry );
205
	entry->read_proc = xpad_proc_read_info;
206
	
207
	return 0;
208
}
209
210
/**
211
 *	xpad_proc_unit_create
212
 *
213
 *	Called upon device connect to create the unit's entry in the
214
 *	/proc file system (underneath the driver/xpad/units subdir).
215
 */
216
static void xpad_proc_unit_create(struct usb_xpad *xpad)
217
{
218
	char name[5];
219
	//struct proc_dir_entry *entry;
220
	struct proc_dir_entry *proc[3];
221
	
222
	/* world readable directory */
223
	int flags = S_IFDIR | S_IRUGO | S_IXUGO;
224
	
225
	enum { UNIT, FEATRS, INFO };
226
	
227
	xpad_units[xpad->number] = xpad;
228
	snprintf(name, 5, "%d", xpad->number);
229
230
	/* directory entries for the unit and it's 'features' subdir */
231
	proc[UNIT] = create_proc_entry(name, flags, xpad_procdir_units);
232
	proc[FEATRS] = create_proc_entry("features", flags, proc[UNIT]);
233
	
234
	/* world readable file */
235
	flags = S_IFREG | S_IRUGO;
236
	
237
	proc[INFO] = create_proc_entry("info", flags, proc[UNIT]);
238
	proc[INFO]->data = xpad;
239
	proc[INFO]->read_proc = xpad_proc_read_unit_info;
240
241
	/* MemoryCard1
242
	entry = create_proc_entry("memorycard1", flags, proc[FEATRS]);
243
	entry->data = xpad;
244
	entry->read_proc = xpad_proc_read_stub; */
245
246
	/* MemoryCard2
247
	entry = create_proc_entry("memorycard2", flags, proc[FEATRS]);
248
	entry->data = xpad;
249
	entry->read_proc = xpad_proc_read_stub; */
250
	
251
	xpad_mouse_proc_unit_create(xpad, proc[FEATRS]);
252
	xpad_rumble_proc_unit_create(xpad, proc[FEATRS]);
253
}
254
255
/**
256
 *	xpad_proc_remove
257
 *
258
 *	Called upon driver unloading to get rid of the /proc file entries.
259
 *	Note that those are _not_ updated as long as an application has one
260
 *	of the subdirectories open.
261
 *	Clears the array of known devices, too.
262
 */
263
static void xpad_proc_remove(void)
264
{
265
	int i;
266
267
	xpad_procdir_units = NULL;
268
	for (i=0; i<XPAD_MAX_DEVICES; ++i)
269
		xpad_units[i] = NULL;
270
	remove_proc_entry( "xpad", proc_root_driver );
271
}
272
273
/**
274
 *	xpad_proc_unit_remove
275
 *
276
 *	Called upon device disconnect to dispose of the
277
 *	device /proc entries.
278
 */
279
static void xpad_proc_unit_remove(struct usb_xpad *xpad)
280
{
281
	char proc_name[5];
282
283
	snprintf( proc_name, 5, "%d", xpad->number );
284
	xpad_units[xpad->number] = NULL;
285
	remove_proc_entry( proc_name, xpad_procdir_units );
286
}
287
288
/*********************** the actual xpad functions ********************/
289
/**
290
 *	xpad_process_packet
291
 *
292
 *	Completes a request by converting the data into events
293
 *	for the input subsystem.
294
 *
295
 *	The report descriptor was taken from ITO Takayukis website:
296
 *	 http://euc.jp/periphs/xbox-controller.en.html
297
 */
298
static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
299
{
300
	struct input_dev *dev = &xpad->dev;
301
302
	/* digital pad: bits (3 2 1 0) (right left down up) */
303
	input_report_key(dev, BTN_0, (data[2] & 0x01));
304
	input_report_key(dev, BTN_1, (data[2] & 0x08) >> 3);
305
	input_report_key(dev, BTN_2, (data[2] & 0x02) >> 1);
306
	input_report_key(dev, BTN_3, (data[2] & 0x04) >> 2);	
307
	
308
	/* start/back buttons and stick press left/right */
309
	input_report_key(dev, BTN_START, (data[2] & 0x10) >> 4);
310
	input_report_key(dev, BTN_BACK, (data[2] & 0x20) >> 5);
311
	
312
	/* buttons A, B, X, Y digital mode */
313
	input_report_key(dev, BTN_A, data[4]);
314
	input_report_key(dev, BTN_B, data[5]);
315
	input_report_key(dev, BTN_X, data[6]);
316
	input_report_key(dev, BTN_Y, data[7]);
317
	
318
	if (xpad->isMat)
319
		return;
320
321
	/* left stick */
322
	input_report_abs(dev, ABS_X, ((__s16) (((__s16)data[13] << 8) | data[12])));
323
	input_report_abs(dev, ABS_Y, ((__s16) (((__s16)data[15] << 8) | data[14])));
324
	
325
	/* right stick */
326
	input_report_abs(dev, ABS_RX, ((__s16) (((__s16)data[17] << 8) | data[16])));
327
	input_report_abs(dev, ABS_RY, ((__s16) (((__s16)data[19] << 8) | data[18])));
328
   	
329
   	/* triggers left/right */
330
	input_report_abs(dev, ABS_Z, data[10]);
331
	input_report_abs(dev, ABS_RZ, data[11]);
332
	
333
	/* digital pad: bits (3 2 1 0) (right left down up) */
334
	input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04));
335
	input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x01) - !!(data[2] & 0x02));
336
337
	/* stick press left/right */
338
	input_report_key(dev, BTN_THUMBL, (data[2] & 0x40) >> 6);
339
	input_report_key(dev, BTN_THUMBR, data[2] >> 7);
340
	
341
	/* buttons A, B, X, Y analogue mode */
342
	input_report_abs(dev, ABS_HAT1X, data[4]);
343
	input_report_abs(dev, ABS_HAT1Y, data[5]);
344
	input_report_abs(dev, ABS_HAT2Y, data[6]);
345
	input_report_abs(dev, ABS_HAT3X, data[7]);
346
	
347
	/* button C (black) digital/analogue mode */
348
	input_report_key(dev, BTN_C, data[8]);
349
	input_report_abs(dev, ABS_HAT2X, data[8]);
350
351
	/* button Z (white) digital/analogue mode */
352
	input_report_key(dev, BTN_Z, data[9]);
353
	input_report_abs(dev, ABS_HAT3Y, data[9]);
354
	
355
	/* process input data for mouse event generation */
356
	xpad_mouse_process_packet(xpad, cmd, data);
357
}
358
359
/**
360
 *	xpad_irq_in
361
 *
362
 *	Completion handler for interrupt in transfers (user input).
363
 *	Just calls xpad_process_packet which does then emit input events.
364
 */
365
static void xpad_irq_in(struct urb *urb)
366
{
367
	struct usb_xpad *xpad = urb->context;
368
	
369
	if (urb->status) {
370
		err("urb status");
371
		return;
372
	}
373
	
374
	xpad_process_packet(xpad, 0, xpad->idata);
375
}
376
377
/*	xpad_init_urb
378
 *
379
 *	initialize the input urb
380
 *	this is to be called when joystick or mouse device are opened
381
 */
382
static int xpad_start_urb(struct usb_xpad *xpad)
383
{
384
	int status;
385
	
386
	// check if joystick or mouse device are opened
387
	if (xpad->open_count + xpad->mouse_open_count > 0)
388
		return 0;
389
390
	xpad->irq_in->dev = xpad->udev;
391
	if ((status = usb_submit_urb(xpad->irq_in))) {
392
		err("open input urb failed: %d", status);
393
		return -EIO;
394
	}
395
	
396
	return 0;
397
}
398
399
/**
400
 *	xpad_open
401
 *
402
 *	Called when a an application opens the device.
403
 */
404
static int xpad_open(struct input_dev *dev)
405
{
406
	struct usb_xpad *xpad = dev->private;
407
	int status;
408
	
409
	if (xpad->open_count)
410
		return 0;
411
		
412
	info("opening device");
413
	
414
	if ((status = xpad_start_urb(xpad)))
415
		return status;
416
		
417
	++xpad->open_count;
418
419
	xpad_rumble_open(xpad);
420
	
421
	return 0;
422
}
423
424
static void xpad_stop_urb(struct usb_xpad *xpad)
425
{
426
	if (xpad->open_count + xpad->mouse_open_count > 0)
427
		return;
428
	
429
	usb_unlink_urb(xpad->irq_in);
430
}
431
432
/**
433
 *	xpad_close
434
 *
435
 *	Called when an application closes the device.
436
 */
437
static void xpad_close(struct input_dev *dev)
438
{
439
	struct usb_xpad *xpad = dev->private;
440
	
441
	if (--xpad->open_count)
442
		return;
443
	
444
	info("closing device");
445
	
446
	xpad_stop_urb(xpad);
447
	xpad_rumble_close(xpad);
448
}
449
450
/**
451
 *	xpad_ioctl
452
 *
453
 *	Called via ioctl to change driver parameters (toggle mouse/ff support).
454
 *	Note that this relies on some unofficial changes to the input subsystem.
455
 */ 
456
static int xpad_ioctl(struct input_dev *dev, unsigned int cmd, unsigned long arg)
457
{
458
	/* check magic and max number */
459
	if (_IOC_TYPE(cmd) != USB_XPAD_IOC_MAGIC) return -ENOTTY;
460
	if (_IOC_NR(cmd) > USB_XPAD_IOC_MAXNR) return -ENOTTY;
461
462
	switch (cmd) {
463
		case USB_XPAD_IOCSMOUSE:
464
		case USB_XPAD_IOCGMOUSE:
465
			return xpad_mouse_ioctl(dev, cmd, arg);
466
		case USB_XPAD_IOCSRUMBLE:
467
		case USB_XPAD_IOCGRUMBLE:
468
			return xpad_rumble_ioctl(dev, cmd, arg);
469
		default:
470
			return -ENOTTY;
471
	}
472
}
473
474
/**	xpad_init_input_device
475
 *
476
 *	setup the input device for the kernel
477
 */
478
static void xpad_init_input_device(struct usb_device *udev, struct usb_xpad *xpad, int probedDevNum)
479
{
480
	int i;
481
	
482
	xpad->dev.idbus = BUS_USB;
483
	xpad->dev.idvendor = udev->descriptor.idVendor;
484
	xpad->dev.idproduct = udev->descriptor.idProduct;
485
	xpad->dev.idversion = udev->descriptor.bcdDevice;
486
	xpad->dev.private = xpad;
487
	xpad->dev.name = xpad_device[probedDevNum].name;
488
	xpad->dev.open = xpad_open;
489
	xpad->dev.close = xpad_close;
490
	
491
	/* this was meant to allow a user space tool on-the-fly configuration
492
	   of driver options (mouse on, rumble on, etc)
493
	   yet, Vojtech said this is better done using sysfs (linux 2.6)
494
	   plus, it needs a patch to the input subsystem */
495
//	xpad->dev.ioctl = xpad_ioctl;
496
497
	if (xpad->isMat) {
498
		xpad->dev.evbit[0] = BIT(EV_KEY);
499
		for (i = 0; xpad_mat_btn[i] >= 0; ++i)
500
			set_bit(xpad_mat_btn[i], xpad->dev.keybit);
501
	} else {
502
		xpad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
503
		for (i = 0; xpad_btn[i] >= 0; ++i)
504
			set_bit(xpad_btn[i], xpad->dev.keybit);
505
		
506
		for (i = 0; xpad_abs[i] >= 0; ++i) {
507
			
508
			signed short t = xpad_abs[i];
509
			
510
			set_bit(t, xpad->dev.absbit);
511
			
512
			switch (t) {
513
			case ABS_X:
514
			case ABS_Y:
515
			case ABS_RX:
516
			case ABS_RY:	/* the two sticks */
517
				xpad->dev.absmax[t] =  32767;
518
				xpad->dev.absmin[t] = -32768;
519
				xpad->dev.absflat[t] = 128;
520
				xpad->dev.absfuzz[t] = 16;
521
				break;
522
			case ABS_Z:	/* left trigger */
523
			case ABS_RZ:	/* right trigger */
524
			case ABS_HAT1X:	/* analogue button A */
525
			case ABS_HAT1Y:	/* analogue button B */
526
			case ABS_HAT2X:	/* analogue button C */
527
			case ABS_HAT2Y:	/* analogue button X */
528
			case ABS_HAT3X:	/* analogue button Y */
529
			case ABS_HAT3Y:	/* analogue button Z */
530
				xpad->dev.absmax[t] = 255;
531
				xpad->dev.absmin[t] = 0;
532
				break;
533
			case ABS_HAT0X:
534
			case ABS_HAT0Y:	/* the d-pad */
535
				xpad->dev.absmax[t] =  1;
536
				xpad->dev.absmin[t] = -1;
537
				break;
538
			}
539
		}
540
		
541
		if (xpad_rumble_probe(udev, xpad, ifnum) != 0)
542
			err("could not init rumble");
543
	}
544
	
545
	input_register_device(&xpad->dev);
546
	info("%s", xpad->dev.name);
547
}
548
549
/**
550
 *	xpad_probe
551
 *
552
 *	Called upon device detection to find a suitable driver.
553
 *	Must return NULL when no xpad is found, else setup everything.
554
 */
555
static void * xpad_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id)
556
{
557
        int i;
558
	int probedDevNum = -1;	/* this takes the index into the known devices
559
				   array for the recognized device */
560
	
561
	struct usb_xpad *xpad = NULL;
562
	struct usb_endpoint_descriptor *ep_irq_in;
563
	
564
	// try to detect the device we are called for
565
	for (i = 0; xpad_device[i].idVendor; ++i) {
566
		if ((udev->descriptor.idVendor == xpad_device[i].idVendor) &&
567
		    (udev->descriptor.idProduct == xpad_device[i].idProduct)) {
568
			probedDevNum = i;
569
			break;
570
		}
571
	}
572
	
573
	// sanity check, did we recognize this device? if not, fail
574
	if ((probedDevNum == -1) || (xpad_device[probedDevNum].idVendor ==
575
	    xpad_device[probedDevNum].idVendor == 0))
576
		return NULL;
577
		
578
	if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) {
579
		err("cannot allocate memory for new pad");
580
		return NULL;
581
	}
582
	memset(xpad, 0, sizeof(struct usb_xpad));
583
	
584
	/* find next unused device slot */
585
	for (i=0; (i<XPAD_MAX_DEVICES && xpad_units[i] != NULL); ++i);
586
	if (i == XPAD_MAX_DEVICES) {
587
		err( "no more than %d devices supported", XPAD_MAX_DEVICES );
588
		return NULL;
589
	}
590
	
591
	xpad->udev = udev;
592
	xpad->number = i;
593
	xpad->isMat = xpad_device[probedDevNum].isMat;
594
	xpad_proc_unit_create(xpad);
595
	
596
	/* setup input interrupt pipe (button and axis state) */
597
	ep_irq_in = udev->actconfig->interface[ifnum].altsetting[0].endpoint + 0;
598
	xpad->irq_in = usb_alloc_urb(0);
599
        if (!xpad->irq_in) {
600
		err("cannot allocate memory for new pad irq urb");
601
                kfree(xpad);
602
                return NULL;
603
	}
604
	
605
	/* init input URB for USB INT transfer from device */
606
	FILL_INT_URB(xpad->irq_in, udev,
607
		     usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),
608
		     xpad->idata, XPAD_PKT_LEN,
609
		     xpad_irq_in, xpad, ep_irq_in->bInterval);
610
		
611
	xpad_init_input_device(udev, xpad, probedDevNum);
612
	xpad_mouse_init_input_device(udev, xpad, probedDevNum);
613
614
	return xpad;
615
}
616
617
/**
618
 *	xpad_disconnect
619
 *
620
 *	Called upon device disconnect to dispose of the structures and
621
 *	close the USB connections.
622
 */
623
static void xpad_disconnect(struct usb_device *udev, void *ptr)
624
{
625
	struct usb_xpad *xpad = ptr;
626
	
627
	info( "disconnecting device" );
628
	
629
	usb_unlink_urb(xpad->irq_in);
630
	xpad_rumble_close(xpad);
631
	input_unregister_device(&xpad->dev);
632
	
633
	usb_free_urb(xpad->irq_in);
634
	
635
	xpad_rumble_disconnect(xpad);
636
	// disconnect mouse interface
637
	xpad_mouse_cleanup(xpad);
638
	
639
	xpad_proc_unit_remove(xpad);
640
	kfree(xpad);
641
}
642
643
/******************* Linux driver framework specific stuff ************/
644
645
static struct usb_driver xpad_driver = {
646
	.name		= "xpad",
647
	.probe		= xpad_probe,
648
	.disconnect	= xpad_disconnect,
649
	.id_table	= xpad_table
650
};
651
652
/**
653
 * driver init entry point
654
 */
655
static int __init usb_xpad_init(void)
656
{
657
	xpad_proc_create();
658
	usb_register(&xpad_driver);
659
	info(DRIVER_DESC " " DRIVER_VERSION);
660
	return 0;
661
}
662
663
/**
664
 * driver exit entry point
665
 */
666
static void __exit usb_xpad_exit(void)
667
{
668
	usb_deregister(&xpad_driver);
669
	xpad_proc_remove();
670
}
671
672
module_init(usb_xpad_init);
673
module_exit(usb_xpad_exit);
674
675
MODULE_AUTHOR(DRIVER_AUTHOR);
676
MODULE_DESCRIPTION(DRIVER_DESC);
677
MODULE_LICENSE("GPL");
678
679
/*
680
 *  driver history
681
 * ----------------
682
 *
683
 * 2003-05-15 - 0.1.2 : ioctls, dynamic mouse/rumble activation, /proc fs
684
 *  - added some /proc files for informational purposes (readonly right now)
685
 *  - added init parameters for mouse/rumble activation upon detection
686
 *  - added dynamic changes to mouse events / rumble effect generation via
687
 *    ioctls - NOTE: this requires a currently unofficial joydev patch!
688
 *
689
 * 2003-04-29 - 0.1.1 : minor cleanups, some comments
690
 *  - fixed incorrect handling of unknown devices (please try ir dongle now)
691
 *  - fixed input URB length (the 256 bytes from 0.1.0 broke everything for the
692
 *    MS controller as well as my Interact device, set back to 32 (please
693
 *    REPORT problems BEFORE any further changes here, since those can be fatal)
694
 *  - fixed rumbling for MS controllers (need 6 bytes output report)
695
 *  - dropped kernel-2.5 ifdefs, much more readable now
696
 *  - preparation for major rework under way, stay tuned
697
 *
698
 * 2003-03-25 - 0.1.0 : (Franz) Some Debuggin
699
 *  - Better Handling
700
 *  - X/Y support, Speed differenting
701
 *  - Landing Zone, Dead Zone, Offset kompensation, Zero-adjustment, .... aso.
702
 *  - Removed Wheel handling in Mouse Emulation .. sensless..
703
 *
704
 * 2003-01-23 - 0.1.0-pre : added mouse emulation and rumble support
705
 *  - can provide mouse emulation (compile time switch)
706
 *    this code has been taken from Oliver Schwartz' xpad-mouse driver
707
 *  - basic rumble support (compile time switch)        EXPERIMENTAL!  
708
 *
709
 * 2002-08-05 - 0.0.6 : added analog button support
710
 *
711
 * 2002-07-17 - 0.0.5 : (Vojtech Pavlik) rework
712
 *  - simplified d-pad handling
713
 *
714
 * 2002-07-16 - 0.0.4 : minor changes, merge with Vojtech's v0.0.3
715
 *  - verified the lack of HID and report descriptors
716
 *  - verified that ALL buttons WORK
717
 *  - fixed d-pad to axes mapping
718
 *
719
 * 2002-07-14 - 0.0.3 : (Vojtech Pavlik) rework
720
 *  - indentation fixes
721
 *  - usb + input init sequence fixes
722
 *
723
 * 2002-07-02 - 0.0.2 : basic working version
724
 *  - all axes and 9 of the 10 buttons work (german InterAct device)
725
 *  - the black button does not work
726
 *
727
 * 2002-06-27 - 0.0.1 : first version, just said "XBOX HID controller"
728
 */
(-)linux-2.4.26/drivers/usb/xpad-mouse.c (+318 lines)
Line 0 Link Here
1
/*
2
 * Xbox input device driver for Linux - v0.1.5
3
 *
4
 *	mouse emulation stuff, merged from Olivers xpad-mouse
5
 *
6
 * Copyright (c)  2003, 2004  Marko Friedemann <mfr@bmx-chemnitz.de>
7
 *	portions Copyright (c)	2002  Oliver Schwartz <Oliver.Schwartz@gmx.de>,
8
 *				2003  Franz Lehner <franz@chaos.at>
9
 *
10
 * Released under GPL. See xpad-core.c for details
11
 */
12
13
#include <linux/config.h>
14
#include <linux/kernel.h>
15
#include <linux/init.h>
16
#include <linux/slab.h>
17
#include <linux/module.h>
18
#include <linux/smp_lock.h>
19
#include <linux/proc_fs.h>
20
#include <linux/usb.h>
21
#include <linux/version.h>
22
#include <linux/timer.h>
23
#include <asm/uaccess.h>
24
25
#define __USB_XPAD_MOUSE
26
#include "xpad.h"
27
#undef __USB_XPAD_MOUSE
28
29
#define XPAD_WHEELBRAKE		20
30
#define JOY_DeadZone_fast	6000
31
#define JOY_DeadZone_slow	200
32
#define XPAD_OFFSET_COUNTER	5
33
34
extern struct xpad_device xpad_device[];
35
36
extern int xpad_start_urb(struct usb_xpad *xpad);
37
extern void xpad_stop_urb(struct usb_xpad *xpad);
38
39
static int mouse_on_load = 1;
40
MODULE_PARM( mouse_on_load, "i" );
41
MODULE_PARM_DESC( mouse_on_load, "set to 0 [off] to deactivate mouse support on insmod (default 1 [on])" );
42
43
44
/*static*/ void xpad_mouse_proc_read_info(char *buf, char **start, off_t offset, int count, int *eof, struct usb_xpad *xpad, int *len)
45
{
46
	*len += sprintf( buf+*len, "mouse support available:\tyes\n" );
47
	*len += sprintf( buf+*len, "    automatically activated:\t%s\n\n",
48
		mouse_on_load ? "yes" : "no" );
49
}
50
51
/*static*/ void xpad_mouse_proc_read_unit_info(char *buf, char **start, off_t offset, int count, int *eof, struct usb_xpad *xpad, int *len)
52
{
53
	*len += sprintf( buf+*len, "mouse enabled:\t%s\n", xpad->mouse_enabled ? "yes" : "no" );
54
}
55
56
static int xpad_mouse_proc_read_feature_info(char *buf, char **start, off_t offset, int count, int *eof, void *data)
57
{
58
	int len = 0;
59
	struct usb_xpad *xpad = (struct usb_xpad *)data;
60
	
61
	len += sprintf( buf+len, "%d", xpad->mouse_enabled );
62
	*eof = 1;
63
	
64
	return len;
65
}
66
67
/*static*/ void xpad_mouse_proc_unit_create(struct usb_xpad *xpad, struct proc_dir_entry *entry)
68
{
69
	struct proc_dir_entry *tmp;
70
	
71
	/* world readable file */
72
	int flags = S_IFREG | S_IRUGO;
73
74
	tmp = create_proc_entry("mouse", flags, entry);
75
	tmp->data = xpad;
76
	tmp->read_proc = xpad_mouse_proc_read_feature_info;
77
}
78
79
/**
80
 *	xpad_removedeadzone
81
 *
82
 *	Franz? Please clarify and correct.
83
 *
84
 *	Removes the deadzone for mouse operation.
85
 *	Allows for better handling near the stick's center.
86
 */   
87
int xpad_removedeadzone(signed int position,int speed,int deadzone){
88
     
89
	if (position>31000) position=31000;
90
	if (position<-31000) position=-31000; 
91
	
92
	if ((position>0)&(position<deadzone)) return 0;
93
	if ((position<0)&(position>(-deadzone))) return 0;
94
95
	if (position>deadzone) position -= deadzone;	
96
	if (position<(-(deadzone))) position+= deadzone;	
97
	position = (int)(position / speed);
98
99
	return position;
100
}
101
102
/*static*/ void xpad_mouse_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
103
{
104
        struct input_dev *dev_mouse = &xpad->dev_mouse;
105
	
106
        int signledirection, xyspeed;
107
        //int joy_y2;
108
	unsigned char MouseLeft,MouseRight, MouseMiddle;
109
        signed int left_joy_x, left_joy_y, right_joy_x, right_joy_y;
110
	
111
	if (!xpad->mouse_open_count || !xpad->mouse_enabled)
112
		return;
113
	
114
	left_joy_x = ((__s16) (((__s16)data[13] << 8) | data[12]));
115
	left_joy_y = ((__s16) (((__s16)data[15] << 8) | data[14]));
116
	
117
	right_joy_x = ((__s16) (((__s16)data[17] << 8) | data[16]));
118
	right_joy_y = ((__s16) (((__s16)data[19] << 8) | data[18]));
119
	
120
	// Creates Offset when first starting
121
	/* CHECKME: who coded this? Franz? Please clarify:
122
		1) is this necessary for joystick operation?
123
		2) offset_counter was only defined when MOUSE
124
		   support was configured (has been FIXED, see above) */
125
	if (xpad->offsetset_compensation>0) {
126
		
127
		if (xpad->offsetset_compensation == XPAD_OFFSET_COUNTER) {
128
			xpad->left_offset_x  = left_joy_x;
129
			xpad->left_offset_y  = left_joy_y;
130
			xpad->right_offset_x = right_joy_x;
131
			xpad->right_offset_y = right_joy_y;  
132
		} else {
133
			xpad->left_offset_x  += left_joy_x;
134
			xpad->left_offset_y  += left_joy_y;
135
			xpad->right_offset_x += right_joy_x;
136
			xpad->right_offset_y += right_joy_y;  
137
		}
138
		
139
		if (xpad->offsetset_compensation == 1) {
140
			xpad->left_offset_x  = xpad->left_offset_x  / XPAD_OFFSET_COUNTER;
141
			xpad->left_offset_y  = xpad->left_offset_y  / XPAD_OFFSET_COUNTER;
142
			xpad->right_offset_x = xpad->right_offset_x / XPAD_OFFSET_COUNTER;
143
			xpad->right_offset_y = xpad->right_offset_y / XPAD_OFFSET_COUNTER;  
144
		}
145
		
146
		xpad->offsetset_compensation--;
147
	}
148
	
149
	left_joy_x -= xpad->left_offset_x;
150
	left_joy_y -= xpad->left_offset_y;
151
	
152
	right_joy_x -= xpad->right_offset_x;
153
	right_joy_y -= xpad->right_offset_y;
154
	
155
	if (data[11]<0x10) {
156
		// Normal Speed Mode
157
		xpad->rel_x =  (xpad_removedeadzone(left_joy_x,0x1500,JOY_DeadZone_fast));
158
		xpad->rel_y = -(xpad_removedeadzone(left_joy_y,0x1500,JOY_DeadZone_fast));
159
		xyspeed = 2;
160
		//printk("%d:",xpad->rel_y);
161
	} else {
162
		// Ultra Slow Mode                                                 
163
		xpad->rel_x =  (xpad_removedeadzone(left_joy_x,0x3500,JOY_DeadZone_slow));
164
		xpad->rel_y = -(xpad_removedeadzone(left_joy_y,0x3500,JOY_DeadZone_slow));    
165
		xyspeed = 1;
166
	}
167
	
168
	// X-Y Steering
169
	signledirection=1;
170
	if (signledirection&((data[2] & 0x04)!=0)) { signledirection=0; xpad->rel_x -=xyspeed; }
171
	if (signledirection&((data[2] & 0x08)!=0)) { signledirection=0; xpad->rel_x +=xyspeed; }
172
	if (signledirection&((data[2] & 0x02)!=0)) { signledirection=0; xpad->rel_y +=xyspeed; }
173
	if (signledirection&((data[2] & 0x01)!=0)) { signledirection=0; xpad->rel_y -=xyspeed; }
174
  	
175
	/* wheel handling */
176
	//joy_y2 = xpad_removedeadzone(joy_y2);
177
	//xpad->rel_wheel = (joy_y2>0)?1:(joy_y2<0)?-1:0;
178
	xpad->rel_wheel=0;
179
	
180
	if (data[10]==0xFF) MouseLeft=1; else MouseLeft =0;
181
	if ((MouseLeft==0)&(data[7]!=0)) MouseLeft =1;
182
	if ((MouseLeft==0)&(data[4]!=0)) MouseLeft = 1;
183
	if ((MouseLeft==0)&((data[2] >> 7)!=0)) MouseLeft = 1;
184
	if ((MouseLeft==0)&(((data[2] & 0x40) >> 6)!=0)) MouseLeft = 1;
185
	
186
	if (data[5]!=0) MouseRight=1; else MouseRight=0;
187
	if (data[6]!=0) MouseMiddle =1; else MouseMiddle=0;
188
	
189
	// Generating Mouse Emulation Events  (Button Events)
190
	input_report_key(dev_mouse, BTN_LEFT, MouseLeft);
191
	input_report_key(dev_mouse, BTN_RIGHT, MouseRight);
192
	input_report_key(dev_mouse, BTN_MIDDLE, MouseMiddle);
193
}
194
195
/**
196
 *	xpad_timer
197
 *
198
 *	Reports the mouse events in the interval given in xpad_open.
199
 *
200
 *	Taken from Oliver Schwartz' xpad-mouse driver to avoid strange mouse
201
 *	 behaviour encountered when the input events where send directly
202
 *	 in xpad_process_packet.
203
 */
204
static void xpad_timer(unsigned long data)
205
{
206
	struct usb_xpad * xpad = (struct usb_xpad *)data;
207
208
	if (xpad->mouse_enabled) {
209
		input_report_rel(&xpad->dev_mouse, REL_X, xpad->rel_x);
210
		input_report_rel(&xpad->dev_mouse, REL_Y, xpad->rel_y); 
211
	
212
		/*if (xpad->rel_wheeltimer == 0) {
213
			input_report_rel(&xpad->dev_mouse, REL_WHEEL, xpad->rel_wheel);
214
			xpad->rel_wheeltimer = XPAD_WHEELBRAKE;
215
		} else
216
			xpad->rel_wheeltimer--;*/
217
	}
218
	
219
	// reschedule the timer so that it fires continually
220
	add_timer(&xpad->timer);
221
}
222
223
static int xpad_mouse_open(struct input_dev *dev)
224
{
225
	struct usb_xpad *xpad = dev->private;
226
	int status;
227
	
228
	if (xpad->mouse_open_count)
229
		return 0;
230
	
231
	if ((status = xpad_start_urb(xpad)))
232
		return status;
233
		
234
	++xpad->mouse_open_count;
235
	
236
	info("opening mouse device");
237
238
	// set up timer for mouse event generation
239
	init_timer(&xpad->timer);
240
	xpad->timer.expires = 1*HZ/5; /* every 200 ms */
241
	xpad->timer.data = (unsigned long)xpad;
242
	xpad->timer.function = xpad_timer;
243
	// now start the timer
244
	add_timer(&xpad->timer);
245
	
246
	return 0;
247
}
248
249
static void xpad_mouse_close(struct input_dev *dev)
250
{
251
	struct usb_xpad *xpad = dev->private;
252
	
253
	if (--xpad->mouse_open_count)
254
		return;
255
		
256
	xpad_stop_urb(xpad);
257
	
258
	info("closing mouse device"); 
259
	del_timer(&xpad->timer);
260
}
261
262
/*static*/ int xpad_mouse_init_input_device(struct usb_device *udev, struct usb_xpad *xpad, int probedDevNum)
263
{
264
	/* the mouse device struct for the kernel (mouse emulation) */
265
	xpad->dev_mouse.idbus = BUS_USB;
266
	xpad->dev_mouse.idvendor = udev->descriptor.idVendor;
267
	xpad->dev_mouse.idproduct = udev->descriptor.idProduct;
268
	xpad->dev_mouse.idversion = udev->descriptor.bcdDevice;
269
	xpad->dev_mouse.private = xpad;
270
	xpad->dev_mouse.name = xpad_device[probedDevNum].name;
271
	xpad->dev_mouse.open = xpad_mouse_open;
272
	xpad->dev_mouse.close = xpad_mouse_close;
273
	xpad->offsetset_compensation = XPAD_OFFSET_COUNTER; // Find new offset point
274
	xpad->mouse_enabled = mouse_on_load;
275
	
276
	/* mouse setup */
277
	xpad->dev_mouse.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
278
279
	set_bit(REL_X,     xpad->dev_mouse.relbit);
280
	set_bit(REL_Y,     xpad->dev_mouse.relbit);
281
	set_bit(REL_WHEEL, xpad->dev_mouse.relbit);
282
283
	set_bit(BTN_LEFT,   xpad->dev_mouse.keybit);
284
	set_bit(BTN_RIGHT,  xpad->dev_mouse.keybit);
285
	set_bit(BTN_MIDDLE, xpad->dev_mouse.keybit);
286
	set_bit(BTN_SIDE,   xpad->dev_mouse.keybit);
287
	set_bit(BTN_EXTRA,  xpad->dev_mouse.keybit);
288
	
289
	input_register_device(&xpad->dev_mouse);
290
	info("Mouse Emulation %s@ %s", (mouse_on_load ? "" : "(disabled) "),
291
		xpad->dev_mouse.name);
292
}
293
294
void xpad_mouse_cleanup(struct usb_xpad *xpad)
295
{
296
	del_timer(&xpad->timer);
297
	input_unregister_device(&xpad->dev_mouse);
298
}
299
300
/**
301
 *	xpad_ioctl
302
 *
303
 *	Called via ioctl to change driver parameters (toggle mouse/ff support).
304
 *	Note that this relies on some unofficial changes to the input subsystem.
305
 */ 
306
/*static*/ int xpad_mouse_ioctl(struct input_dev *dev, unsigned int cmd, unsigned long arg)
307
{
308
	struct usb_xpad *xpad = (struct usb_xpad *) dev->private;
309
310
	switch (cmd) {
311
		case USB_XPAD_IOCSMOUSE:
312
			return get_user( xpad->mouse_enabled, (int *) arg );
313
		case USB_XPAD_IOCGMOUSE:
314
			return put_user( xpad->mouse_enabled, (int *) arg );
315
		default:
316
			return -ENOTTY;
317
	}
318
}
(-)linux-2.4.26/drivers/usb/xpad.h (+177 lines)
Line 0 Link Here
1
/*
2
 * Xbox Controller driver for Linux - v0.1.5
3
 *
4
 *	header file containing ioctl definitions
5
 *
6
 * Copyright (c)  2003  Marko Friedemann <mfr@bmx-chemnitz.de>
7
 *
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License as
11
 * published by the Free Software Foundation; either version 2 of
12
 * the License, or (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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
 */
23
 
24
#ifndef __XPAD_h
25
#define __XPAD_h
26
27
28
/*********** ioctl stuff, can be used outside of the driver ***********/
29
#define USB_XPAD_IOC_MAGIC 	'x'
30
31
#define USB_XPAD_IOCRESET 	_IO(  USB_XPAD_IOC_MAGIC, 0 )
32
#define USB_XPAD_IOCSMOUSE 	_IOW( USB_XPAD_IOC_MAGIC, 1, int )
33
#define USB_XPAD_IOCGMOUSE 	_IOR( USB_XPAD_IOC_MAGIC, 2, int )
34
#define USB_XPAD_IOCSRUMBLE 	_IOW( USB_XPAD_IOC_MAGIC, 3, int )
35
#define USB_XPAD_IOCGRUMBLE 	_IOR( USB_XPAD_IOC_MAGIC, 4, int )
36
37
#define USB_XPAD_IOCSIR 	_IOW( USB_XPAD_IOC_MAGIC, 5, int )
38
#define USB_XPAD_IOCGIR 	_IOR( USB_XPAD_IOC_MAGIC, 6, int )
39
40
#define USB_XPAD_IOC_MAXNR 	6
41
42
43
/************************* driver internals ***************************/
44
#ifdef __KERNEL__
45
46
#include <linux/input.h>
47
#include <linux/circ_buf.h>
48
49
/****************** driver description and version ********************/
50
#define DRIVER_VERSION		"v0.1.5"
51
#define DRIVER_AUTHOR		"Marko Friedemann <mfr@bmx-chemnitz.de>,\
52
 Oliver Schwartz <Oliver.Schwartz@gmx.de>, Georg Lukas <georg@op-co.de>"
53
54
#ifdef CONFIG_USB_XPAD_MOUSE
55
#define DRIVER_DESC		"driver for Xbox controllers with mouse emulation"
56
#else
57
#define DRIVER_DESC		"driver for Xbox controllers"
58
#endif
59
60
/****************************** constants *****************************/
61
#define XPAD_MAX_DEVICES	4
62
#define XPAD_PKT_LEN		32	/* input packet size */
63
#define XPAD_PKT_LEN_FF		6	/* output packet size - rumble */
64
65
#define XPAD_TX_BUFSIZE		XPAD_PKT_LEN_FF * 8	/* max. 8 requests */
66
67
/************************* the device struct **************************/
68
struct usb_xpad {
69
	int number;
70
71
	struct input_dev dev;			/* input device interface */
72
	struct usb_device *udev;		/* usb device */
73
	
74
	struct urb *irq_in;			/* urb for int. in report */
75
	unsigned char idata[XPAD_PKT_LEN];	/* input data */
76
	
77
	int open_count;				/* reference count */
78
79
	unsigned char offsetset_compensation;
80
	int left_offset_x;
81
	int left_offset_y;
82
	int right_offset_x;
83
	int right_offset_y;
84
	
85
	int isMat;				/* is this a dancepad/mat? */
86
	
87
#ifdef CONFIG_USB_XPAD_RUMBLE
88
	int rumble_enabled;			/* ioctl can toggle rumble */
89
	
90
	int ep_out_adr;				/* number of out endpoint */
91
	unsigned char tx_data[XPAD_PKT_LEN_FF];	/* output data (rumble) */
92
	int strong_rumble, play_strong;		/* strong rumbling */
93
	int weak_rumble, play_weak;		/* weak rumbling */
94
	struct timer_list rumble_timer;		/* timed urb out retry */
95
	wait_queue_head_t wait;			/* wait for URBs on queue */
96
	
97
	spinlock_t tx_lock;
98
	struct circ_buf tx;
99
	unsigned char tx_buf[XPAD_TX_BUFSIZE];
100
	long tx_flags[1];			/* transmit flags */
101
#endif
102
	
103
#ifdef CONFIG_USB_XPAD_MOUSE
104
	struct input_dev dev_mouse;		/* mouse device interface */
105
	int mouse_open_count;			/* reference count */
106
	int mouse_enabled;			/* ioctl can toggle rumble */
107
	
108
	int rel_x;
109
	int rel_y;
110
	int rel_wheel;
111
	int rel_wheeltimer;
112
	struct timer_list timer;		/* timed mouse input events */
113
#endif
114
};
115
116
/* for the list of know devices */
117
struct xpad_device {
118
	u16 idVendor;
119
	u16 idProduct;
120
	u8  isMat;
121
	char *name;
122
};
123
124
/************************ mouse function stubs ************************/
125
#ifndef CONFIG_USB_XPAD_MOUSE
126
 #define mouse_open_count open_count
127
 #define xpad_mouse_proc_read_info(buf, start, offset, count, eof, xpad, len) {\
128
	*len += sprintf( buf+*len, "mouse support available:\tno\n\n" ); }
129
 #define xpad_mouse_proc_read_unit_info(buf, start, offset, count, eof, xpad, len) {}
130
 #define xpad_mouse_proc_unit_create(xpad, entry) {}
131
 #define xpad_mouse_process_packet(xpad, cmd, data) {}
132
 #define xpad_mouse_init_input_device(udev, xpad, probedDevNum) {}
133
 #define xpad_mouse_cleanup(xpad) {}
134
 #define xpad_mouse_ioctl(dev, cmd, arg) -ENOTTY
135
#else /* CONFIG_USB_XPAD_MOUSE */
136
 #ifndef __USB_XPAD_MOUSE
137
  extern void xpad_mouse_proc_read_info(char *buf, char **start, off_t offset, int count, int *eof, struct usb_xpad *xpad, int *len);
138
  extern void xpad_mouse_proc_read_unit_info(char *buf, char **start, off_t offset, int count, int *eof, struct usb_xpad *xpad, int *len);
139
  extern void xpad_mouse_proc_unit_create(struct usb_xpad *xpad, struct proc_dir_entry *entry);
140
  extern void xpad_mouse_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data);
141
  extern void xpad_mouse_init_input_device(struct usb_device *udev, struct usb_xpad *xpad, int probedDevNum);
142
  extern void xpad_mouse_cleanup(struct usb_xpad *xpad);
143
  extern int  xpad_mouse_ioctl(struct input_dev *dev, unsigned int cmd, unsigned long arg);
144
 #endif /* __USB_XPAD_MOUSE */
145
#endif /* CONFIG_USB_XPAD_MOUSE */
146
147
/************************ rumble function stubs ***********************/
148
#ifndef CONFIG_USB_XPAD_RUMBLE
149
 #define xpad_rumble_proc_read_info(buf, start, offset, count, eof, xpad, len) {\
150
	*len += sprintf( buf+*len, "rumble support available:\tno\n\n" ); }
151
 #define xpad_rumble_proc_read_unit_info(buf, start, offset, count, eof, xpad, len) {}
152
 #define xpad_rumble_proc_unit_create(xpad, entry) {}
153
 #define xpad_rumble_ioctl(dev, cmd, arg) -ENOTTY
154
 #define xpad_rumble_open(xpad) {}
155
 #define xpad_rumble_probe(udev, xpad, ifnum) 0
156
 #define xpad_rumble_close(xpad) {}
157
 #define xpad_rumble_disconnect(xpad) {}
158
#else /* CONFIG_USB_XPAD_RUMBLE */
159
160
 #define XPAD_TX_RUNNING	0
161
 #define XPAD_TX_INC(var, n)	(var) += n; (var) %= XPAD_TX_BUFSIZE
162
163
 #ifndef __USB_XPAD_RUMBLE
164
  extern void xpad_rumble_proc_read_info(char *buf, char **start, off_t offset, int count, int *eof, struct usb_xpad *xpad, int *len);
165
  extern void xpad_rumble_proc_read_unit_info(char *buf, char **start, off_t offset, int count, int *eof, struct usb_xpad *xpad, int *len);
166
  extern void xpad_rumble_proc_unit_create(struct usb_xpad *xpad, struct proc_dir_entry *entry);
167
  extern int  xpad_rumble_ioctl(struct input_dev *dev, unsigned int cmd, unsigned long arg);
168
  extern void xpad_rumble_open(struct usb_xpad *xpad);
169
  extern int  xpad_rumble_probe(struct usb_device *udev, struct usb_xpad *xpad, unsigned int ifnum);
170
  extern void xpad_rumble_close(struct usb_xpad *xpad);
171
  extern void xpad_rumble_disconnect(struct usb_xpad *xpad);
172
 #endif /* __USB_XPAD_RUMBLE */
173
#endif /* CONFIG_USB_XPAD_RUMBLE */
174
175
#endif /* __KERNEL__ */
176
177
#endif /* __XPAD_h */
(-)linux-2.4.26/drivers/video/CVS/Entries (+5 lines)
Line 0 Link Here
1
/Config.in/1.8/Wed Feb 18 23:45:58 2004//
2
/Makefile/1.5/Wed Feb 18 23:45:59 2004//
3
/fbmem.c/1.3/Wed Feb 18 23:45:59 2004//
4
D/riva////
5
D/xbox////
(-)linux-2.4.26/drivers/video/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/video
(-)linux-2.4.26/drivers/video/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/video/Config.in (-6 / +12 lines)
Lines 12-17 Link Here
12
   if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
12
   if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
13
      if [ "$CONFIG_PCI" = "y" ]; then
13
      if [ "$CONFIG_PCI" = "y" ]; then
14
         tristate '  nVidia Riva support (EXPERIMENTAL)' CONFIG_FB_RIVA
14
         tristate '  nVidia Riva support (EXPERIMENTAL)' CONFIG_FB_RIVA
15
         dep_tristate '  Xbox (nVidia) support (EXPERIMENTAL)' CONFIG_FB_XBOX $CONFIG_I2C_XBOX
15
      fi
16
      fi
16
      if [ "$CONFIG_AMIGA" = "y" -o "$CONFIG_PCI" = "y" ]; then
17
      if [ "$CONFIG_AMIGA" = "y" -o "$CONFIG_PCI" = "y" ]; then
17
	 tristate '  Cirrus Logic support (EXPERIMENTAL)' CONFIG_FB_CLGEN
18
	 tristate '  Cirrus Logic support (EXPERIMENTAL)' CONFIG_FB_CLGEN
Lines 312-318 Link Here
312
	   "$CONFIG_FB_TX3912" = "y" -o \
313
	   "$CONFIG_FB_TX3912" = "y" -o \
313
	   "$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_NEOMAGIC" = "y" -o \
314
	   "$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_NEOMAGIC" = "y" -o \
314
	   "$CONFIG_FB_STI" = "y" -o "$CONFIG_FB_HP300" = "y" -o \
315
	   "$CONFIG_FB_STI" = "y" -o "$CONFIG_FB_HP300" = "y" -o \
315
	   "$CONFIG_FB_INTEL" = "y" ]; then
316
	   "$CONFIG_FB_INTEL" = "y" -o "$CONFIG_FB_XBOX" = "y" ]; then
316
	 define_tristate CONFIG_FBCON_CFB8 y
317
	 define_tristate CONFIG_FBCON_CFB8 y
317
      else
318
      else
318
	 if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_ATARI" = "m" -o \
319
	 if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_ATARI" = "m" -o \
Lines 335-341 Link Here
335
	      "$CONFIG_FB_RADEON" = "m" -o "$CONFIG_FB_INTEL" = "m" -o \
336
	      "$CONFIG_FB_RADEON" = "m" -o "$CONFIG_FB_INTEL" = "m" -o \
336
	      "$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_SIS" = "m" -o \
337
	      "$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_SIS" = "m" -o \
337
	      "$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_NEOMAGIC" = "m" -o \
338
	      "$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_NEOMAGIC" = "m" -o \
338
	      "$CONFIG_FB_STI" = "m" -o "$CONFIG_FB_INTEL" = "m" ]; then
339
	      "$CONFIG_FB_STI" = "m" -o "$CONFIG_FB_INTEL" = "m" -o \
340
	      "$CONFIG_FB_XBOX" = "m" ]; then
339
	    define_tristate CONFIG_FBCON_CFB8 m
341
	    define_tristate CONFIG_FBCON_CFB8 m
340
	 fi
342
	 fi
341
      fi
343
      fi
Lines 354-360 Link Here
354
	   "$CONFIG_FB_CYBER2000" = "y" -o "$CONFIG_FB_3DFX" = "y"  -o \
356
	   "$CONFIG_FB_CYBER2000" = "y" -o "$CONFIG_FB_3DFX" = "y"  -o \
355
	   "$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_SA1100" = "y" -o \
357
	   "$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_SA1100" = "y" -o \
356
	   "$CONFIG_FB_PVR2" = "y" -o "$CONFIG_FB_VOODOO1" = "y" -o \
358
	   "$CONFIG_FB_PVR2" = "y" -o "$CONFIG_FB_VOODOO1" = "y" -o \
357
	   "$CONFIG_FB_NEOMAGIC" = "y" -o "$CONFIG_FB_INTEL" = "y" ]; then
359
	   "$CONFIG_FB_NEOMAGIC" = "y" -o "$CONFIG_FB_INTEL" = "y" -o \
360
	   "$CONFIG_FB_XBOX" = "y" ]; then
358
	 define_tristate CONFIG_FBCON_CFB16 y
361
	 define_tristate CONFIG_FBCON_CFB16 y
359
      else
362
      else
360
	 if [ "$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_ATY" = "m" -o \
363
	 if [ "$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_ATY" = "m" -o \
Lines 372-378 Link Here
372
	      "$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_RADEON" = "m" -o \
375
	      "$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_RADEON" = "m" -o \
373
	      "$CONFIG_FB_INTEL" = "m" -o \
376
	      "$CONFIG_FB_INTEL" = "m" -o \
374
	      "$CONFIG_FB_PVR2" = "m" -o "$CONFIG_FB_VOODOO1" = "m" -o \
377
	      "$CONFIG_FB_PVR2" = "m" -o "$CONFIG_FB_VOODOO1" = "m" -o \
375
	      "$CONFIG_FB_NEOMAGIC" = "m" -o "$CONFIG_FB_INTEL" = "m" ]; then
378
	      "$CONFIG_FB_NEOMAGIC" = "m" -o "$CONFIG_FB_INTEL" = "m" -o \
379
	      "$CONFIG_FB_XBOX" = "m" ]; then
376
	    define_tristate CONFIG_FBCON_CFB16 m
380
	    define_tristate CONFIG_FBCON_CFB16 m
377
	 fi
381
	 fi
378
      fi
382
      fi
Lines 405-411 Link Here
405
	   "$CONFIG_FB_INTEL" = "y" -o \
409
	   "$CONFIG_FB_INTEL" = "y" -o \
406
	   "$CONFIG_FB_3DFX" = "y" -o "$CONFIG_FB_SIS" = "y" -o \
410
	   "$CONFIG_FB_3DFX" = "y" -o "$CONFIG_FB_SIS" = "y" -o \
407
	   "$CONFIG_FB_VOODOO1" = "y" -o "$CONFIG_FB_CYBER2000" = "y" -o \
411
	   "$CONFIG_FB_VOODOO1" = "y" -o "$CONFIG_FB_CYBER2000" = "y" -o \
408
	   "$CONFIG_FB_STI" = "y"  -o "$CONFIG_FB_INTEL" = "y" ]; then
412
	   "$CONFIG_FB_STI" = "y"  -o "$CONFIG_FB_INTEL" = "y" -o \
413
	   "$CONFIG_FB_XBOX" = "y" ]; then
409
	 define_tristate CONFIG_FBCON_CFB32 y
414
	 define_tristate CONFIG_FBCON_CFB32 y
410
      else
415
      else
411
	 if [ "$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_ATY" = "m" -o \
416
	 if [ "$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_ATY" = "m" -o \
Lines 419-425 Link Here
419
	      "$CONFIG_FB_INTEL" = "m" -o \
424
	      "$CONFIG_FB_INTEL" = "m" -o \
420
	      "$CONFIG_FB_SGIVW" = "m" -o "$CONFIG_FB_SIS" = "m" -o \
425
	      "$CONFIG_FB_SGIVW" = "m" -o "$CONFIG_FB_SIS" = "m" -o \
421
	      "$CONFIG_FB_PVR2" = "m" -o "$CONFIG_FB_VOODOO1" = "m" -o \
426
	      "$CONFIG_FB_PVR2" = "m" -o "$CONFIG_FB_VOODOO1" = "m" -o \
422
	      "$CONFIG_FB_CYBER2000" = "m" -o "$CONFIG_FB_STI" = "m" ]; then
427
	      "$CONFIG_FB_CYBER2000" = "m" -o "$CONFIG_FB_STI" = "m" -o \
428
	      "$CONFIG_FB_XBOX" = "m" ]; then
423
	    define_tristate CONFIG_FBCON_CFB32 m
429
	    define_tristate CONFIG_FBCON_CFB32 m
424
	 fi
430
	 fi
425
      fi
431
      fi
(-)linux-2.4.26/drivers/video/Makefile (+5 lines)
Lines 114-119 Link Here
114
obj-y				  += riva/rivafb.o
114
obj-y				  += riva/rivafb.o
115
endif
115
endif
116
116
117
subdir-$(CONFIG_FB_XBOX)	  += xbox
118
ifeq ($(CONFIG_FB_XBOX),y)
119
obj-y				  += xbox/xboxfb.o
120
endif
121
117
subdir-$(CONFIG_FB_SIS)		  += sis
122
subdir-$(CONFIG_FB_SIS)		  += sis
118
ifeq ($(CONFIG_FB_SIS),y)
123
ifeq ($(CONFIG_FB_SIS),y)
119
obj-y				  += sis/sisfb.o
124
obj-y				  += sis/sisfb.o
(-)linux-2.4.26/drivers/video/fbmem.c (+5 lines)
Lines 114-119 Link Here
114
extern int sun3fb_setup(char *);
114
extern int sun3fb_setup(char *);
115
extern int sgivwfb_init(void);
115
extern int sgivwfb_init(void);
116
extern int sgivwfb_setup(char*);
116
extern int sgivwfb_setup(char*);
117
extern int xboxfb_init(void);
118
extern int xboxfb_setup(char*);
117
extern int rivafb_init(void);
119
extern int rivafb_init(void);
118
extern int rivafb_setup(char*);
120
extern int rivafb_setup(char*);
119
extern int tdfxfb_init(void);
121
extern int tdfxfb_init(void);
Lines 203-208 Link Here
203
#ifdef CONFIG_FB_RIVA
205
#ifdef CONFIG_FB_RIVA
204
	{ "riva", rivafb_init, rivafb_setup },
206
	{ "riva", rivafb_init, rivafb_setup },
205
#endif
207
#endif
208
#ifdef CONFIG_FB_XBOX
209
	{ "xbox", xboxfb_init, xboxfb_setup },
210
#endif
206
#ifdef CONFIG_FB_RADEON
211
#ifdef CONFIG_FB_RADEON
207
	{ "radeon", radeonfb_init, radeonfb_setup },
212
	{ "radeon", radeonfb_init, radeonfb_setup },
208
#endif
213
#endif
(-)linux-2.4.26/drivers/video/riva/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)linux-2.4.26/drivers/video/riva/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/video/riva
(-)linux-2.4.26/drivers/video/riva/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/video/xbox/CVS/Entries (+18 lines)
Line 0 Link Here
1
/Makefile/1.3/Mon Feb  9 23:16:51 2004//
2
/accel.c/1.2/Wed Dec 10 00:18:28 2003//
3
/conexant.c/1.16/Thu Mar 11 18:03:38 2004//
4
/conexant.h/1.11/Sat Feb 21 21:51:19 2004//
5
/encoder-i2c.c/1.1/Mon Feb  9 23:16:51 2004//
6
/encoder-i2c.h/1.1/Mon Feb  9 23:16:51 2004//
7
/encoder.c/1.3/Thu Feb 12 23:09:07 2004//
8
/encoder.h/1.4/Sat Feb 21 21:51:19 2004//
9
/fbdev.c/1.32/Fri Mar 19 20:46:15 2004//
10
/focus.c/1.20/Thu Apr  1 10:38:29 2004//
11
/focus.h/1.5/Fri Mar  5 20:40:41 2004//
12
/nv4ref.h/1.1/Thu Jul 24 20:39:08 2003//
13
/nvreg.h/1.1/Thu Jul 24 20:39:08 2003//
14
/riva_hw.c/1.3/Sun Mar  7 18:27:52 2004//
15
/riva_hw.h/1.4/Sun Mar  7 18:27:52 2004//
16
/riva_tbl.h/1.1/Thu Jul 24 20:39:08 2003//
17
/xboxfb.h/1.10/Sat Feb 14 00:19:51 2004//
18
D
(-)linux-2.4.26/drivers/video/xbox/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/video/xbox
(-)linux-2.4.26/drivers/video/xbox/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/video/xbox/Makefile (+15 lines)
Line 0 Link Here
1
#
2
# Makefile for the Xbox framebuffer driver
3
#
4
# Note! Dependencies are done automagically by 'make dep', which also
5
# removes any old dependencies. DON'T put your own dependencies here
6
# unless it's something special (ie not a .c file).
7
#
8
# Note 2! The CFLAGS definitions are now in the main makefile...
9
10
O_TARGET := xboxfb.o
11
12
obj-y    := fbdev.o riva_hw.o accel.o encoder-i2c.o encoder.o focus.o conexant.o
13
obj-m    := $(O_TARGET)
14
15
include $(TOPDIR)/Rules.make
(-)linux-2.4.26/drivers/video/xbox/accel.c (+429 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/accel.c - nVidia RIVA 128/TNT/TNT2 fb driver
3
 *
4
 * Copyright 2000 Jindrich Makovicka, Ani Joshi
5
 *
6
 * This file is subject to the terms and conditions of the GNU General Public
7
 * License.  See the file COPYING in the main directory of this archive
8
 * for more details.
9
 */
10
11
#include "xboxfb.h"
12
13
/* acceleration routines */
14
15
inline void wait_for_idle(struct rivafb_info *rinfo)
16
{
17
	while (rinfo->riva.Busy(&rinfo->riva));
18
}
19
20
/* set copy ROP, no mask */
21
static void riva_setup_ROP(struct rivafb_info *rinfo)
22
{
23
	RIVA_FIFO_FREE(rinfo->riva, Patt, 5);
24
	rinfo->riva.Patt->Shape = 0;
25
	rinfo->riva.Patt->Color0 = 0xffffffff;
26
	rinfo->riva.Patt->Color1 = 0xffffffff;
27
	rinfo->riva.Patt->Monochrome[0] = 0xffffffff;
28
	rinfo->riva.Patt->Monochrome[1] = 0xffffffff;
29
30
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
31
	rinfo->riva.Rop->Rop3 = 0xCC;
32
}
33
34
void riva_setup_accel(struct rivafb_info *rinfo)
35
{
36
	RIVA_FIFO_FREE(rinfo->riva, Clip, 2);
37
	rinfo->riva.Clip->TopLeft     = 0x0;
38
	rinfo->riva.Clip->WidthHeight = 0x80008000;
39
	riva_setup_ROP(rinfo);
40
	wait_for_idle(rinfo);
41
}
42
43
static void riva_rectfill(struct rivafb_info *rinfo, int sy,
44
			  int sx, int height, int width, u_int color)
45
{
46
	RIVA_FIFO_FREE(rinfo->riva, Bitmap, 1);
47
	rinfo->riva.Bitmap->Color1A = color;
48
49
	RIVA_FIFO_FREE(rinfo->riva, Bitmap, 2);
50
	rinfo->riva.Bitmap->UnclippedRectangle[0].TopLeft     = (sx << 16) | sy; 
51
	rinfo->riva.Bitmap->UnclippedRectangle[0].WidthHeight = (width << 16) | height;
52
}
53
54
static void fbcon_riva_bmove(struct display *p, int sy, int sx, int dy, int dx,
55
			    int height, int width)
56
{
57
	struct rivafb_info *rinfo = (struct rivafb_info *)(p->fb_info);
58
59
	sx *= fontwidth(p);
60
	sy *= fontheight(p);
61
	dx *= fontwidth(p);
62
	dy *= fontheight(p);
63
	width *= fontwidth(p);
64
	height *= fontheight(p);
65
66
	RIVA_FIFO_FREE(rinfo->riva, Blt, 3);
67
	rinfo->riva.Blt->TopLeftSrc  = (sy << 16) | sx;
68
	rinfo->riva.Blt->TopLeftDst  = (dy << 16) | dx;
69
	rinfo->riva.Blt->WidthHeight = (height  << 16) | width;
70
71
	wait_for_idle(rinfo);
72
}
73
74
static void riva_clear_margins(struct vc_data *conp, struct display *p,
75
				int bottom_only, u32 bgx)
76
{
77
	struct rivafb_info *rinfo = (struct rivafb_info *)(p->fb_info);
78
79
	unsigned int right_start = conp->vc_cols*fontwidth(p);
80
	unsigned int bottom_start = conp->vc_rows*fontheight(p);
81
	unsigned int right_width, bottom_width;
82
83
	if (!bottom_only && (right_width = p->var.xres - right_start))
84
		riva_rectfill(rinfo, 0, right_start, p->var.yres_virtual,
85
			      right_width, bgx);
86
	if ((bottom_width = p->var.yres - bottom_start))
87
		riva_rectfill(rinfo, p->var.yoffset + bottom_start, 0,
88
			      bottom_width, right_start, bgx);
89
}
90
91
static u8 byte_rev[256] = {
92
	0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
93
	0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 
94
	0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 
95
	0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 
96
	0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 
97
	0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 
98
	0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 
99
	0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 
100
	0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 
101
	0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 
102
	0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 
103
	0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 
104
	0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 
105
	0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 
106
	0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 
107
	0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
108
};
109
110
static inline void fbcon_reverse_order(u32 *l)
111
{
112
	u8 *a = (u8 *)l;
113
	*a = byte_rev[*a], a++;
114
/*	*a = byte_rev[*a], a++;
115
	*a = byte_rev[*a], a++;*/
116
	*a = byte_rev[*a];
117
}
118
119
static void fbcon_riva_writechr(struct vc_data *conp, struct display *p,
120
			        int c, int fgx, int bgx, int yy, int xx)
121
{
122
	u8 *cdat;
123
	struct rivafb_info *rinfo = (struct rivafb_info *)(p->fb_info);
124
	int w, h;
125
	volatile u32 *d;
126
	u32 cdat2;
127
	int i, j, cnt;
128
129
	w = fontwidth(p);
130
	h = fontheight(p);
131
132
	if (w <= 8)
133
		cdat = p->fontdata + (c & p->charmask) * h;
134
	else
135
		cdat = p->fontdata + ((c & p->charmask) * h << 1);
136
137
        RIVA_FIFO_FREE(rinfo->riva, Bitmap, 7);
138
        rinfo->riva.Bitmap->ClipE.TopLeft     = (yy << 16) | (xx & 0xFFFF);
139
        rinfo->riva.Bitmap->ClipE.BottomRight = ((yy+h) << 16) | ((xx+w) & 0xffff);
140
        rinfo->riva.Bitmap->Color0E           = bgx;
141
        rinfo->riva.Bitmap->Color1E           = fgx;
142
        rinfo->riva.Bitmap->WidthHeightInE  = (h << 16) | 32;
143
        rinfo->riva.Bitmap->WidthHeightOutE = (h << 16) | 32;
144
        rinfo->riva.Bitmap->PointE          = (yy << 16) | (xx & 0xFFFF);
145
	
146
	d = &rinfo->riva.Bitmap->MonochromeData01E;
147
	for (i = h; i > 0; i-=16) {
148
		if (i >= 16)
149
			cnt = 16;
150
		else
151
			cnt = i;
152
		RIVA_FIFO_FREE(rinfo->riva, Bitmap, cnt);
153
		for (j = 0; j < cnt; j++) {
154
			if (w <= 8) 
155
				cdat2 = *cdat++;
156
			else
157
				cdat2 = *((u16*)cdat)++;
158
			fbcon_reverse_order(&cdat2);
159
			d[j] = cdat2;
160
		}
161
	}
162
}
163
164
#ifdef FBCON_HAS_CFB8
165
void fbcon_riva8_setup(struct display *p)
166
{
167
    p->next_line = p->line_length ? p->line_length : p->var.xres_virtual;
168
    p->next_plane = 0;
169
}
170
171
static void fbcon_riva8_clear(struct vc_data *conp, struct display *p, int sy,
172
			     int sx, int height, int width)
173
{
174
	u32 bgx;
175
176
	struct rivafb_info *rinfo = (struct rivafb_info *)(p->fb_info);
177
178
	bgx = attr_bgcol_ec(p, conp);
179
180
	sx *= fontwidth(p);
181
	sy *= fontheight(p);
182
	width *= fontwidth(p);
183
	height *= fontheight(p);
184
185
	riva_rectfill(rinfo, sy, sx, height, width, bgx);
186
}
187
188
static void fbcon_riva8_putc(struct vc_data *conp, struct display *p, int c,
189
			    int yy, int xx)
190
{
191
	u32 fgx,bgx;
192
193
	fgx = attr_fgcol(p,c);
194
	bgx = attr_bgcol(p,c);
195
	
196
	xx *= fontwidth(p);
197
	yy *= fontheight(p);
198
199
	fbcon_riva_writechr(conp, p, c, fgx, bgx, yy, xx);
200
}
201
202
static void fbcon_riva8_putcs(struct vc_data *conp, struct display *p,
203
			     const unsigned short *s, int count, int yy,
204
			     int xx)
205
{
206
	u16 c;
207
	u32 fgx,bgx;
208
209
	xx *= fontwidth(p);
210
	yy *= fontheight(p);
211
212
	c = scr_readw(s);
213
	fgx = attr_fgcol(p, c);
214
	bgx = attr_bgcol(p, c);
215
	while (count--) {
216
		c = scr_readw(s++);
217
		fbcon_riva_writechr(conp, p, c, fgx, bgx, yy, xx);
218
		xx += fontwidth(p);
219
	}
220
}
221
222
static void fbcon_riva8_revc(struct display *p, int xx, int yy)
223
{
224
	struct rivafb_info *rinfo = (struct rivafb_info *) (p->fb_info);
225
226
	xx *= fontwidth(p);
227
	yy *= fontheight(p);
228
229
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
230
	rinfo->riva.Rop->Rop3 = 0x66; // XOR
231
	riva_rectfill(rinfo, yy, xx, fontheight(p), fontwidth(p), 0x0f);
232
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
233
	rinfo->riva.Rop->Rop3 = 0xCC; // back to COPY
234
}
235
236
static void fbcon_riva8_clear_margins(struct vc_data *conp, struct display *p,
237
				       int bottom_only)
238
{
239
	riva_clear_margins(conp, p, bottom_only, attr_bgcol_ec(p, conp));
240
}
241
242
struct display_switch fbcon_riva8 = {
243
	.setup		= fbcon_riva8_setup,
244
	.bmove		= fbcon_riva_bmove,
245
	.clear		= fbcon_riva8_clear,
246
	.putc		= fbcon_riva8_putc,
247
	.putcs		= fbcon_riva8_putcs,
248
	.revc		= fbcon_riva8_revc,
249
	.clear_margins	= fbcon_riva8_clear_margins,
250
	.fontwidthmask	= FONTWIDTHRANGE(4, 16)
251
};
252
#endif
253
254
#if defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
255
static void fbcon_riva1632_revc(struct display *p, int xx, int yy)
256
{
257
	struct rivafb_info *rinfo = (struct rivafb_info *) (p->fb_info);
258
259
	xx *= fontwidth(p);
260
	yy *= fontheight(p);
261
262
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
263
	rinfo->riva.Rop->Rop3 = 0x66; // XOR
264
	riva_rectfill(rinfo, yy, xx, fontheight(p), fontwidth(p), 0xffffffff);
265
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
266
	rinfo->riva.Rop->Rop3 = 0xCC; // back to COPY
267
}
268
#endif
269
270
#ifdef FBCON_HAS_CFB16
271
void fbcon_riva16_setup(struct display *p)
272
{
273
    p->next_line = p->line_length ? p->line_length : p->var.xres_virtual<<1;
274
    p->next_plane = 0;
275
}
276
277
static void fbcon_riva16_clear(struct vc_data *conp, struct display *p, int sy,
278
			     int sx, int height, int width)
279
{
280
	u32 bgx;
281
282
	struct rivafb_info *rinfo = (struct rivafb_info *)(p->fb_info);
283
284
	bgx = ((u_int16_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)];
285
286
	sx *= fontwidth(p);
287
	sy *= fontheight(p);
288
	width *= fontwidth(p);
289
	height *= fontheight(p);
290
291
	riva_rectfill(rinfo, sy, sx, height, width, bgx);
292
}
293
294
static inline void convert_bgcolor_16(u32 *col)
295
{
296
	*col = ((*col & 0x00007C00) << 9)
297
             | ((*col & 0x000003E0) << 6)
298
             | ((*col & 0x0000001F) << 3)
299
             |          0xFF000000;
300
}
301
302
static void fbcon_riva16_putc(struct vc_data *conp, struct display *p, int c,
303
			    int yy, int xx)
304
{
305
	u32 fgx,bgx;
306
307
	fgx = ((u16 *)p->dispsw_data)[attr_fgcol(p,c)];
308
	bgx = ((u16 *)p->dispsw_data)[attr_bgcol(p,c)];
309
	if (p->var.green.length == 6)
310
		convert_bgcolor_16(&bgx);
311
	xx *= fontwidth(p);
312
	yy *= fontheight(p);
313
314
	fbcon_riva_writechr(conp, p, c, fgx, bgx, yy, xx);
315
}
316
317
static void fbcon_riva16_putcs(struct vc_data *conp, struct display *p,
318
			     const unsigned short *s, int count, int yy,
319
			     int xx)
320
{
321
	u16 c;
322
	u32 fgx,bgx;
323
324
	xx *= fontwidth(p);
325
	yy *= fontheight(p);
326
327
	c = scr_readw(s);
328
	fgx = ((u16 *)p->dispsw_data)[attr_fgcol(p, c)];
329
	bgx = ((u16 *)p->dispsw_data)[attr_bgcol(p, c)];
330
	if (p->var.green.length == 6)
331
		convert_bgcolor_16(&bgx);
332
	while (count--) {
333
		c = scr_readw(s++);
334
		fbcon_riva_writechr(conp, p, c, fgx, bgx, yy, xx);
335
		xx += fontwidth(p);
336
	}
337
}
338
339
static void fbcon_riva16_clear_margins(struct vc_data *conp, struct display *p,
340
				       int bottom_only)
341
{
342
	riva_clear_margins(conp, p, bottom_only, ((u16 *)p->dispsw_data)[attr_bgcol_ec(p, conp)]);
343
}
344
345
struct display_switch fbcon_riva16 = {
346
	.setup		= fbcon_riva16_setup,
347
	.bmove		= fbcon_riva_bmove,
348
	.clear		= fbcon_riva16_clear,
349
	.putc		= fbcon_riva16_putc,
350
	.putcs		= fbcon_riva16_putcs,
351
	.revc		= fbcon_riva1632_revc,
352
	.clear_margins	= fbcon_riva16_clear_margins,
353
	.fontwidthmask	= FONTWIDTHRANGE(4, 16)
354
};
355
#endif
356
357
#ifdef FBCON_HAS_CFB32
358
void fbcon_riva32_setup(struct display *p)
359
{
360
    p->next_line = p->line_length ? p->line_length : p->var.xres_virtual<<2;
361
    p->next_plane = 0;
362
}
363
364
static void fbcon_riva32_clear(struct vc_data *conp, struct display *p, int sy,
365
			     int sx, int height, int width)
366
{
367
	u32 bgx;
368
369
	struct rivafb_info *rinfo = (struct rivafb_info *)(p->fb_info);
370
371
	bgx = ((u_int32_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)];
372
373
	sx *= fontwidth(p);
374
	sy *= fontheight(p);
375
	width *= fontwidth(p);
376
	height *= fontheight(p);
377
378
	riva_rectfill(rinfo, sy, sx, height, width, bgx);
379
}
380
381
static void fbcon_riva32_putc(struct vc_data *conp, struct display *p, int c,
382
			    int yy, int xx)
383
{
384
	u32 fgx,bgx;
385
386
	fgx = ((u32 *)p->dispsw_data)[attr_fgcol(p,c)];
387
	bgx = ((u32 *)p->dispsw_data)[attr_bgcol(p,c)];
388
	xx *= fontwidth(p);
389
	yy *= fontheight(p);
390
	fbcon_riva_writechr(conp, p, c, fgx, bgx, yy, xx);
391
}
392
393
static void fbcon_riva32_putcs(struct vc_data *conp, struct display *p,
394
			     const unsigned short *s, int count, int yy,
395
			     int xx)
396
{
397
	u16 c;
398
	u32 fgx,bgx;
399
400
	xx *= fontwidth(p);
401
	yy *= fontheight(p);
402
403
	c = scr_readw(s);
404
	fgx = ((u32 *)p->dispsw_data)[attr_fgcol(p, c)];
405
	bgx = ((u32 *)p->dispsw_data)[attr_bgcol(p, c)];
406
	while (count--) {
407
		c = scr_readw(s++);
408
		fbcon_riva_writechr(conp, p, c, fgx, bgx, yy, xx);
409
		xx += fontwidth(p);
410
	}
411
}
412
413
static void fbcon_riva32_clear_margins(struct vc_data *conp, struct display *p,
414
				       int bottom_only)
415
{
416
	riva_clear_margins(conp, p, bottom_only, ((u32 *)p->dispsw_data)[attr_bgcol_ec(p, conp)]);
417
}
418
419
struct display_switch fbcon_riva32 = {
420
	.setup		= fbcon_riva32_setup,
421
	.bmove		= fbcon_riva_bmove,
422
	.clear		= fbcon_riva32_clear,
423
	.putc		= fbcon_riva32_putc,
424
	.putcs		= fbcon_riva32_putcs,
425
	.revc		= fbcon_riva1632_revc,
426
	.clear_margins	= fbcon_riva32_clear_margins,
427
	.fontwidthmask	= FONTWIDTHRANGE(4, 16)
428
};
429
#endif
(-)linux-2.4.26/drivers/video/xbox/conexant.c (+639 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/conexant.c - Xbox driver for conexant chip
3
 *
4
 * Maintainer: Oliver Schwartz <Oliver.Schwartz@gmx.de>
5
 *
6
 * Contributors:
7
 * 
8
 * This file is subject to the terms and conditions of the GNU General Public
9
 * License.  See the file COPYING in the main directory of this archive
10
 * for more details.
11
 *
12
 * Known bugs and issues:
13
 *
14
 *      none
15
 */
16
17
#include "conexant.h"
18
#include "focus.h"
19
20
#define ADR(x) (x / 2 - 0x17)
21
22
typedef struct {
23
	long v_activeo;
24
	long v_linesi;
25
	long h_clki;
26
	long h_clko;
27
	long h_blanki;
28
	long h_blanko;
29
	long v_blanki;
30
	long v_blanko;
31
	long vscale;
32
	double clk_ratio;
33
} xbox_tv_mode_parameter;
34
35
36
	// and here is all the video timing for every standard
37
38
static const conexant_video_parameter vidstda[] = {
39
	{ 3579545.00, 0.0000053, 0.00000782, 0.0000047, 0.000063555, 0.0000094, 0.000035667, 0.0000015, 243, 262.5, 0.0000092 },
40
	{ 3579545.00, 0.0000053, 0.00000782, 0.0000047, 0.000064000, 0.0000094, 0.000035667, 0.0000015, 243, 262.5, 0.0000092 },
41
	{ 4433618.75, 0.0000056, 0.00000785, 0.0000047, 0.000064000, 0.0000105, 0.000036407, 0.0000015, 288, 312.5, 0.0000105 },
42
	{ 4433618.75, 0.0000056, 0.00000785, 0.0000047, 0.000064000, 0.0000094, 0.000035667, 0.0000015, 288, 312.5, 0.0000092 },
43
	{ 3582056.25, 0.0000056, 0.00000811, 0.0000047, 0.000064000, 0.0000105, 0.000036407, 0.0000015, 288, 312.5, 0.0000105 },
44
	{ 3575611.88, 0.0000058, 0.00000832, 0.0000047, 0.000063555, 0.0000094, 0.000035667, 0.0000015, 243, 262.5, 0.0000092 },
45
	{ 4433619.49, 0.0000053, 0.00000755, 0.0000047, 0.000063555, 0.0000105, 0.000036407, 0.0000015, 243, 262.5, 0.0000092 }
46
};
47
48
static const unsigned char default_mode[] = {
49
	0x00,
50
	0x00, 0x28, 0x80, 0xE4, 0x00, 0x00, 0x80, 0x80,
51
	0x80, 0x13, 0xDA, 0x4B, 0x28, 0xA3, 0x9F, 0x25,
52
	0xA3, 0x9F, 0x25, 0x00, 0x00, 0x00, 0x00, 0x44,
53
	0xC7, 0x00, 0x00, 0x41, 0x35, 0x03, 0x46, 0x00,
54
	0x02, 0x00, 0x01, 0x60, 0x88, 0x8a, 0xa6, 0x68,
55
	0xc1, 0x2e, 0xf2, 0x27, 0x00, 0xb0, 0x0a, 0x0b,
56
	0x71, 0x5a, 0xe0, 0x36, 0x00, 0x50, 0x72, 0x1c,
57
	0x0d, 0x24, 0xf0, 0x58, 0x81, 0x49, 0x8c, 0x0c,
58
	0x8c, 0x79, 0x26, 0x52, 0x00, 0x24, 0x00, 0x00,
59
	0x00, 0x00, 0x01, 0x9C, 0x9B, 0xC0, 0xC0, 0x19,
60
	0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x57, 0x20,
61
	0x40, 0x6E, 0x7E, 0xF4, 0x51, 0x0F, 0xF1, 0x05,
62
	0xD3, 0x78, 0xA2, 0x25, 0x54, 0xA5, 0x00, 0x00
63
};
64
65
static const double pll_base = 13.5e6;
66
67
static void conexant_calc_blankings(
68
	xbox_video_mode * mode,
69
	xbox_tv_mode_parameter * param
70
);
71
72
static int conexant_calc_mode_params(
73
	xbox_video_mode * mode,
74
	xbox_tv_mode_parameter * param
75
);
76
77
static double fabs(double d) {
78
	if (d > 0) return d;
79
	else return -d;
80
}
81
82
int conexant_calc_vga_mode(
83
	xbox_av_type av_type,
84
	unsigned char pll_int,
85
	unsigned char * regs
86
){
87
	memset(regs, 0, NUM_CONEXANT_REGS);
88
	// Protect against overclocking
89
	if (pll_int > 36) {
90
		pll_int = 36; // 36 / 6 * 13.5 MHz = 81 MHz, just above the limit.
91
	}
92
	if (pll_int == 0) {
93
		pll_int = 1;  // 0 will cause a burnout ...
94
	}
95
	if (av_type == AV_VGA) {
96
		// use internal sync signals
97
		regs[ADR(0x2e)] = 0xbd; // HDTV_EN = 1, RPR_SYNC_DIS = 1, BPB_SYNC_DIS = 1, GY_SYNC_DIS=1, HD_SYNC_EDGE = 1, RASTER_SEL = 01
98
	}
99
	else {
100
 		// use sync on green
101
		regs[ADR(0x2e)] = 0xad; // HDTV_EN = 1, RPR_SYNC_DIS = 1, BPB_SYNC_DIS = 1, HD_SYNC_EDGE = 1, RASTER_SEL = 01
102
	}
103
	regs[ADR(0x32)] = 0x48; // DRVS = 2, IN_MODE[3] = 1;
104
	regs[ADR(0x3c)] = 0x80; // MCOMPY
105
	regs[ADR(0x3e)] = 0x80; // MCOMPU
106
	regs[ADR(0x40)] = 0x80; // MCOMPV
107
	regs[ADR(0xc6)] = 0x98; // IN_MODE = 24 bit RGB multiplexed
108
	regs[ADR(0x6c)] = 0x46; // FLD_MODE = 10, EACTIVE = 1, EN_SCART = 0, EN_REG_RD = 1
109
	regs[ADR(0x9c)] = 0x00; // PLL_FRACT
110
	regs[ADR(0x9e)] = 0x00; // PLL_FRACT
111
	regs[ADR(0xa0)] = pll_int; // PLL_INT
112
	regs[ADR(0xba)] = 0x28; // SLAVER = 1, DACDISD = 1
113
	regs[ADR(0xce)] = 0xe1; // OUT_MUXA = 01, OUT_MUXB = 00, OUT_MUXC = 10, OUT_MUXD = 11
114
	regs[ADR(0xd6)] = 0x0c; // OUT_MODE = 11 (RGB / SCART / HDTV)
115
116
	return 1;
117
}
118
119
int conexant_calc_hdtv_mode(
120
	xbox_hdtv_mode hdtv_mode,
121
	unsigned char pll_int,
122
	unsigned char * regs
123
){
124
	memset(regs, 0, NUM_CONEXANT_REGS);
125
	// Protect against overclocking
126
	if (pll_int > 36) {
127
		pll_int = 36; // 36 / 6 * 13.5 MHz = 81 MHz, just above the limit.
128
	}
129
	if (pll_int == 0) {
130
		pll_int = 1;  // 0 will cause a burnout ...
131
	}
132
	switch (hdtv_mode) {
133
		case HDTV_480p:
134
			// use sync on green
135
			regs[ADR(0x2e)] = 0xed; // HDTV_EN = 1, RGB2PRPB = 1, RPR_SYNC_DIS = 1, BPB_SYNC_DIS = 1, HD_SYNC_EDGE = 1, RASTER_SEL = 01
136
			regs[ADR(0x32)] = 0x48; // DRVS = 2, IN_MODE[3] = 1;
137
			regs[ADR(0x3e)] = 0x45; // MCOMPU
138
			regs[ADR(0x40)] = 0x51; // MCOMPV
139
			break;
140
		case HDTV_720p:
141
			// use sync on green
142
			regs[ADR(0x2e)] = 0xea; // HDTV_EN = 1, RGB2PRPB = 1, RPR_SYNC_DIS = 1, BPB_SYNC_DIS = 1, HD_SYNC_EDGE = 1, RASTER_SEL = 01
143
			regs[ADR(0x32)] = 0x49; // DRVS = 2, IN_MODE[3] = 1, CSC_SEL=1;
144
			regs[ADR(0x3e)] = 0x45; // MCOMPU
145
			regs[ADR(0x40)] = 0x51; // MCOMPV
146
			break;
147
		case HDTV_1080i:
148
			// use sync on green
149
			regs[ADR(0x2e)] = 0xeb; // HDTV_EN = 1, RGB2PRPB = 1, RPR_SYNC_DIS = 1, BPB_SYNC_DIS = 1, HD_SYNC_EDGE = 1, RASTER_SEL = 01
150
			regs[ADR(0x32)] = 0x49; // DRVS = 2, IN_MODE[3] = 1, CSC_SEL=1;
151
			regs[ADR(0x3e)] = 0x48; // MCOMPU
152
			regs[ADR(0x40)] = 0x5b; // MCOMPV
153
			break;
154
	}
155
	regs[ADR(0x3c)] = 0x80; // MCOMPY
156
	regs[ADR(0xa0)] = pll_int; // PLL_INT
157
	regs[ADR(0xc6)] = 0x98; // IN_MODE = 24 bit RGB multiplexed
158
	regs[ADR(0x6c)] = 0x46; // FLD_MODE = 10, EACTIVE = 1, EN_SCART = 0, EN_REG_RD = 1
159
	regs[ADR(0x9c)] = 0x00; // PLL_FRACT
160
	regs[ADR(0x9e)] = 0x00; // PLL_FRACT
161
	regs[ADR(0xba)] = 0x28; // SLAVER = 1, DACDISD = 1
162
	regs[ADR(0xce)] = 0xe1; // OUT_MUXA = 01, OUT_MUXB = 00, OUT_MUXC = 10, OUT_MUXD = 11
163
	regs[ADR(0xd6)] = 0x0c; // OUT_MODE = 11 (RGB / SCART / HDTV)
164
165
	return 1;
166
}
167
168
int conexant_calc_mode(xbox_video_mode * mode, struct riva_regs * riva_out)
169
{
170
	unsigned char b;
171
	unsigned int m = 0;
172
	double dPllOutputFrequency;
173
	xbox_tv_mode_parameter param;
174
	char* regs = riva_out->encoder_mode;
175
176
	if (conexant_calc_mode_params(mode, &param))
177
	{
178
		// copy default mode settings
179
		memcpy(regs,default_mode,sizeof(default_mode));
180
181
		regs[ADR(0x32)] = 0x28; // DRVS = 1, IN_MODE[3] = 1;
182
183
		// H_CLKI
184
		b=regs[ADR(0x8e)]&(~0x07);
185
		regs[ADR(0x8e)] = ((param.h_clki>>8)&0x07)|b;
186
		regs[ADR(0x8a)] = ((param.h_clki)&0xff);
187
		// H_CLKO
188
		b=regs[ADR(0x86)]&(~0x0f);
189
		regs[ADR(0x86)] = ((param.h_clko>>8)&0x0f)|b;
190
		regs[ADR(0x76)] = ((param.h_clko)&0xff);
191
		// V_LINESI
192
		b=regs[ADR(0x38)]&(~0x02);
193
		regs[ADR(0x38)] = ((param.v_linesi>>9)&0x02)|b;
194
		b=regs[ADR(0x96)]&(~0x03);
195
		regs[ADR(0x96)] = ((param.v_linesi>>8)&0x03)|b;
196
		regs[ADR(0x90)] = ((param.v_linesi)&0xff);
197
		// V_ACTIVEO
198
		/* TODO: Absolutely not sure about other modes than plain NTSC / PAL */
199
		switch(mode->tv_encoding) {
200
			case TV_ENC_NTSC:
201
			case TV_ENC_NTSC60:
202
			case TV_ENC_PALM:
203
			case TV_ENC_PAL60:
204
				m=param.v_activeo + 1;
205
				break;
206
			case TV_ENC_PALBDGHI:
207
				m=param.v_activeo + 2;
208
				break;
209
			default:
210
				m=param.v_activeo + 2;
211
				break;
212
		}
213
		b=regs[ADR(0x86)]&(~0x80);
214
		regs[ADR(0x86)] = ((m>>1)&0x80)|b;
215
		regs[ADR(0x84)] = ((m)&0xff);
216
		// H_ACTIVE
217
		b=regs[ADR(0x86)]&(~0x70);
218
		regs[ADR(0x86)] = (((mode->xres + 5)>>4)&0x70)|b;
219
		regs[ADR(0x78)] = ((mode->xres + 5)&0xff);
220
		// V_ACTIVEI
221
		b=regs[ADR(0x96)]&(~0x0c);
222
		regs[ADR(0x96)] = ((mode->yres>>6)&0x0c)|b;
223
		regs[ADR(0x94)] = ((mode->yres)&0xff);
224
		// H_BLANKI
225
		b=regs[ADR(0x38)]&(~0x01);
226
		regs[ADR(0x38)] = ((param.h_blanki>>9)&0x01)|b;
227
		b=regs[ADR(0x8e)]&(~0x08);
228
		regs[ADR(0x8e)] = ((param.h_blanki>>5)&0x08)|b;
229
		regs[ADR(0x8c)] = ((param.h_blanki)&0xff);
230
		// H_BLANKO
231
		b=regs[ADR(0x9a)]&(~0xc0);
232
		regs[ADR(0x9a)] = ((param.h_blanko>>2)&0xc0)|b;
233
		regs[ADR(0x80)] = ((param.h_blanko)&0xff);
234
235
		// V_SCALE
236
		b=regs[ADR(0x9a)]&(~0x3f);
237
		regs[ADR(0x9a)] = ((param.vscale>>8)&0x3f)|b;
238
		regs[ADR(0x98)] = ((param.vscale)&0xff);
239
		// V_BLANKO
240
		regs[ADR(0x82)] = ((param.v_blanko)&0xff);
241
		// V_BLANKI
242
		regs[ADR(0x92)] = ((param.v_blanki)&0xff);
243
		{
244
			unsigned int dwPllRatio, dwFract, dwInt;
245
			// adjust PLL
246
			dwPllRatio = (int)(6.0 * ((double)param.h_clko / vidstda[mode->tv_encoding].m_dSecHsyncPeriod) *
247
				param.clk_ratio * 0x10000 / pll_base + 0.5);
248
			dwInt = dwPllRatio / 0x10000;
249
			dwFract = dwPllRatio - (dwInt * 0x10000);
250
			b=regs[ADR(0xa0)]&(~0x3f);
251
			regs[ADR(0xa0)] = ((dwInt)&0x3f)|b;
252
			regs[ADR(0x9e)] = ((dwFract>>8)&0xff);
253
			regs[ADR(0x9c)] = ((dwFract)&0xff);
254
			// recalc value
255
			dPllOutputFrequency = ((double)dwInt + ((double)dwFract)/65536.0)/(6 * param.clk_ratio / pll_base);
256
			// enable 3:2 clocking mode
257
			b=regs[ADR(0x38)]&(~0x20);
258
			if (param.clk_ratio > 1.1) {
259
				b |= 0x20;
260
			}
261
			regs[ADR(0x38)] = b;
262
263
			// update burst start position
264
			m=(vidstda[mode->tv_encoding].m_dSecBurstStart) * dPllOutputFrequency + 0.5;
265
			b=regs[ADR(0x38)]&(~0x04);
266
			regs[ADR(0x38)] = ((m>>6)&0x04)|b;
267
			regs[ADR(0x7c)] = (m&0xff);
268
			// update burst end position (note +128 is in hardware)
269
			m=(vidstda[mode->tv_encoding].m_dSecBurstEnd) * dPllOutputFrequency + 0.5;
270
			if(m<128) m=128;
271
			b=regs[ADR(0x38)]&(~0x08);
272
			regs[ADR(0x38)] = (((m-128)>>5)&0x08)|b;
273
			regs[ADR(0x7e)] = ((m-128)&0xff);
274
			// update HSYNC width
275
			m=(vidstda[mode->tv_encoding].m_dSecHsyncWidth) * dPllOutputFrequency + 0.5;
276
			regs[ADR(0x7a)] = ((m)&0xff);
277
		}
278
		// adjust Subcarrier generation increment
279
		{
280
			unsigned int dwSubcarrierIncrement = (unsigned int) (
281
				(65536.0 * 65536.0) * (
282
					vidstda[mode->tv_encoding].m_dHzBurstFrequency
283
					* vidstda[mode->tv_encoding].m_dSecHsyncPeriod
284
					/ (double)param.h_clko
285
				) + 0.5
286
			);
287
			regs[ADR(0xae)] = (dwSubcarrierIncrement&0xff);
288
			regs[ADR(0xb0)] = ((dwSubcarrierIncrement>>8)&0xff);
289
			regs[ADR(0xb2)] = ((dwSubcarrierIncrement>>16)&0xff);
290
			regs[ADR(0xb4)] = ((dwSubcarrierIncrement>>24)&0xff);
291
		}
292
		// adjust WSS increment
293
		{
294
			unsigned int dwWssIncrement = 0;
295
296
			switch(mode->tv_encoding) {
297
				case TV_ENC_NTSC:
298
				case TV_ENC_NTSC60:
299
					dwWssIncrement=(unsigned int) ((1048576.0 / ( 0.000002234 * dPllOutputFrequency))+0.5);
300
					break;
301
				case TV_ENC_PALBDGHI:
302
				case TV_ENC_PALN:
303
				case TV_ENC_PALNC:
304
				case TV_ENC_PALM:
305
				case TV_ENC_PAL60:
306
					dwWssIncrement=(unsigned int) ((1048576.0 / ( 0.0000002 * dPllOutputFrequency))+0.5);
307
					break;
308
				default:
309
					break;
310
				}
311
312
			regs[ADR(0x66)] = (dwWssIncrement&0xff);
313
			regs[ADR(0x68)] = ((dwWssIncrement>>8)&0xff);
314
			regs[ADR(0x6a)] = ((dwWssIncrement>>16)&0xf);
315
		}
316
		// set mode register
317
		b=regs[ADR(0xa2)]&(0x41);
318
		switch(mode->tv_encoding) {
319
				case TV_ENC_NTSC:
320
					b |= 0x0a; // SETUP + VSYNC_DUR
321
					break;
322
				case TV_ENC_NTSC60:
323
					b |= 0x08; // VSYNC_DUR
324
					break;
325
				case TV_ENC_PALBDGHI:
326
				case TV_ENC_PALNC:
327
						b |= 0x24; // PAL_MD + 625LINE
328
					break;
329
				case TV_ENC_PALN:
330
					b |= 0x2e; // PAL_MD + SETUP + 625LINE + VSYNC_DUR
331
					break;
332
				case TV_ENC_PALM:
333
					b |= 0x2a; // PAL_MD + SETUP + VSYNC_DUR
334
					break;
335
				case TV_ENC_PAL60:
336
					b |= 0x28; // PAL_MD + VSYNC_DUR
337
					break;
338
				default:
339
					break;
340
		}
341
		regs[ADR(0xa2)] = b;
342
		regs[ADR(0xc6)] = 0x98; // IN_MODE = 24 bit RGB multiplexed
343
		switch(mode->av_type) {
344
			case AV_COMPOSITE:
345
			case AV_SVIDEO:
346
				regs[ADR(0x2e)] |= 0x40; // RGB2YPRPB = 1
347
				regs[ADR(0x6c)] = 0x46; // FLD_MODE = 10, EACTIVE = 1, EN_SCART = 0, EN_REG_RD = 1
348
				regs[ADR(0x5a)] = 0x00; // Y_OFF (Brightness)
349
				regs[ADR(0xa4)] = 0xe5; // SYNC_AMP
350
				regs[ADR(0xa6)] = 0x74; // BST_AMP
351
				regs[ADR(0xba)] = 0x24; // SLAVER = 1, DACDISC = 1
352
				regs[ADR(0xce)] = 0x19; // OUT_MUXA = 01, OUT_MUXB = 10, OUT_MUXC = 10, OUT_MUXD = 00
353
				regs[ADR(0xd6)] = 0x00; // OUT_MODE = 00 (CVBS)
354
				break;
355
			case AV_SCART_RGB:
356
				regs[ADR(0x6c)] = 0x4e; // FLD_MODE = 10, EACTIVE = 1, EN_SCART = 1, EN_REG_RD = 1
357
				regs[ADR(0x5a)] = 0xff; // Y_OFF (Brightness)
358
				regs[ADR(0xa4)] = 0xe7; // SYNC_AMP
359
				regs[ADR(0xa6)] = 0x77; // BST_AMP
360
				regs[ADR(0xba)] = 0x20; // SLAVER = 1, enable all DACs
361
				regs[ADR(0xce)] = 0xe1; // OUT_MUXA = 01, OUT_MUXB = 00, OUT_MUXC = 10, OUT_MUXD = 11
362
				regs[ADR(0xd6)] = 0x0c; // OUT_MODE = 11 (RGB / SCART / HDTV)
363
				break;
364
			default:
365
				break;
366
		}
367
		riva_out->ext.vend = mode->yres;
368
		riva_out->ext.vtotal = param.v_linesi - 1;
369
		riva_out->ext.vcrtc = mode->yres;
370
		riva_out->ext.vsyncstart = param.v_linesi - param.v_blanki;
371
		riva_out->ext.vsyncend = riva_out->ext.vsyncstart + 3;
372
		riva_out->ext.vvalidstart = 0;
373
		riva_out->ext.vvalidend = mode->yres;
374
		riva_out->ext.hend = mode->xres + 7;
375
		riva_out->ext.htotal = param.h_clki - 1;
376
		riva_out->ext.hcrtc = mode->xres - 1;
377
		riva_out->ext.hsyncstart = param.h_clki - param.h_blanki - 7;
378
		riva_out->ext.hsyncend = riva_out->ext.hsyncstart + 32;
379
		riva_out->ext.hvalidstart = 0;
380
		riva_out->ext.hvalidend = mode->xres - 1;
381
		riva_out->ext.crtchdispend = mode->xres + 8;
382
		riva_out->ext.crtcvstart = mode->yres + 34;
383
		riva_out->ext.crtcvtotal = param.v_linesi + 32;
384
		return 1;
385
	}
386
	else
387
	{
388
		return 0;
389
	}
390
}
391
392
static int conexant_calc_mode_params(
393
	xbox_video_mode * mode,
394
	xbox_tv_mode_parameter * param
395
){
396
	const double dMinHBT = 2.5e-6; // 2.5uSec time for horizontal syncing
397
	const double invalidMetric = 1000;
398
399
	/* algorithm shamelessly ripped from nvtv/calc_bt.c */
400
	double dTempVOC = 0;
401
	double dTempHOC = 0;
402
	double dBestMetric = invalidMetric;
403
	double dTempVSR = 0;
404
	double dBestVSR = 0;
405
	double dTempCLKRATIO = 1;
406
	double dBestCLKRATIO = 1;
407
	unsigned int  minTLI = 0;
408
	unsigned int  maxTLI = 0;
409
	unsigned int  tempTLI = 0;
410
	unsigned int  bestTLI = 0;
411
	unsigned int  minHCLKO = 0;
412
	unsigned int  maxHCLKO = 0;
413
	unsigned int  minHCLKI = 0;
414
	unsigned int  tempHCLKI = 0;
415
	unsigned int  bestHCLKI = 0;
416
	int    actCLKRATIO;
417
	unsigned int  dTempHCLKO = 0;
418
	double dTempVACTIVEO = 0;
419
	double dDelta = 0;
420
	double dMetric = 0;
421
	double alo =  vidstda[mode->tv_encoding].m_dwALO;
422
	double tlo =  vidstda[mode->tv_encoding].m_TotalLinesOut;
423
	double tto = vidstda[mode->tv_encoding].m_dSecHsyncPeriod;
424
	double ato = tto - (vidstda[mode->tv_encoding].m_dSecBlankBeginToHsync + vidstda[mode->tv_encoding].m_dSecActiveBegin);
425
426
	/* Range to search */
427
	double dMinHOC = mode->hoc - 0.02;
428
	double dMaxHOC = mode->hoc + 0.02;
429
	double dMinVOC = mode->voc - 0.02;
430
	double dMaxVOC = mode->voc + 0.02;
431
432
	if (dMinHOC < 0) dMinHOC = 0;
433
	if (dMinVOC < 0) dMinVOC = 0;
434
435
	minTLI= (unsigned int)(mode->yres / ((1 - dMinVOC) * alo) * tlo);
436
	maxTLI = min((unsigned int)(mode->yres / ((1 - dMaxVOC) * alo) * tlo), (unsigned int)1023);
437
	minHCLKO = (unsigned int) ((mode->xres * 2) /
438
				((1 - dMinHOC) * (ato / tto)));
439
	maxHCLKO = (unsigned int) ((mode->xres * 2) /
440
				((1 - dMaxHOC) * (ato / tto)));
441
	for (actCLKRATIO = 0; actCLKRATIO <= 1; actCLKRATIO++)
442
	{
443
		dTempCLKRATIO = 1.0;
444
		if (actCLKRATIO) dTempCLKRATIO = 3.0/2.0;
445
		for(tempTLI = minTLI; tempTLI <= maxTLI; tempTLI++)
446
		{
447
			dTempVSR = (double)tempTLI / tlo;
448
			dTempVACTIVEO = (int)((((double)mode->yres * tlo) +
449
						(tempTLI - 1)) / tempTLI);
450
			dTempVOC = 1 - dTempVACTIVEO / alo;
451
452
			for(dTempHCLKO = minHCLKO; dTempHCLKO <= maxHCLKO; dTempHCLKO++)
453
			{
454
				tempHCLKI = (unsigned int)((dTempHCLKO * dTempCLKRATIO) * (tlo / tempTLI) + 0.5);
455
				minHCLKI = ((dMinHBT / tto) * tempHCLKI) + mode->xres;
456
				// check if solution is valid
457
				if ((fabs((double)(tempTLI * tempHCLKI) - (tlo * dTempHCLKO * dTempCLKRATIO)) < 1e-3) &&
458
					(tempHCLKI >= minHCLKI) && (tempHCLKI < 2048))
459
				{
460
					dTempHOC = 1 - (((double)mode->xres / ((double)dTempHCLKO / 2)) /
461
						(ato / tto));
462
					dDelta = fabs(dTempHOC - mode->hoc) + fabs(dTempVOC - mode->voc);
463
					dMetric = ((dTempHOC - mode->hoc) * (dTempHOC - mode->hoc)) +
464
						((dTempVOC - mode->voc) * (dTempVOC - mode->voc)) +
465
						(2 * dDelta * dDelta);
466
					if(dMetric < dBestMetric)
467
					{
468
						dBestVSR = dTempVSR;
469
						dBestMetric = dMetric;
470
						bestTLI = tempTLI;
471
						bestHCLKI = tempHCLKI;
472
						dBestCLKRATIO = dTempCLKRATIO;
473
					}
474
				} /* valid solution */
475
			} /* dTempHCLKO loop */
476
		} /* tempTLI loop */
477
	} /* CLKRATIO loop */
478
479
	if(dBestMetric != invalidMetric)
480
	{
481
		param->v_linesi = bestTLI;
482
		param->h_clki = bestHCLKI;
483
		param->clk_ratio = dBestCLKRATIO;
484
		param->v_activeo = (unsigned int)(
485
			(
486
				(mode->yres * vidstda[mode->tv_encoding].m_TotalLinesOut)
487
				+ param->v_linesi - 1
488
			) / param->v_linesi
489
		);
490
		param->h_clko = (unsigned int)(
491
			(
492
				(param->v_linesi * param->h_clki) /
493
				(vidstda[mode->tv_encoding].m_TotalLinesOut * param->clk_ratio)
494
			)
495
			+ 0.5
496
		);
497
		conexant_calc_blankings(mode, param);
498
		return 1;
499
	}
500
	else
501
	{
502
		return 0;
503
	}
504
}
505
506
static void conexant_calc_blankings(
507
	xbox_video_mode * mode,
508
	xbox_tv_mode_parameter * param
509
){
510
	double dTotalHBlankI;
511
	double dFrontPorchIn;
512
	double dFrontPorchOut;
513
	double dMinFrontPorchIn;
514
	double dBackPorchIn;
515
	double dBackPorchOut;
516
	double dTotalHBlankO;
517
	double dHeadRoom;
518
	double dMaxHsyncDrift;
519
	double dFifoMargin;
520
	double vsrq;
521
	double dMaxHR;
522
	double tlo =  vidstda[mode->tv_encoding].m_TotalLinesOut;
523
	const int MFP = 14; // Minimum front porch
524
	const int MBP = 4;  // Minimum back porch
525
	const int FIFO_SIZE = 1024;
526
	double vsr = (double)param->v_linesi / vidstda[mode->tv_encoding].m_TotalLinesOut;
527
528
	// H_BLANKO
529
	param->h_blanko = 2 * (int)(
530
		vidstda[mode->tv_encoding].m_dSecImageCentre / (2 * vidstda[mode->tv_encoding].m_dSecHsyncPeriod) *
531
		param->h_clko
532
		+ 0.5
533
	) - mode->xres + 15;
534
535
	// V_BLANKO
536
	switch (mode->tv_encoding) {
537
		case TV_ENC_NTSC:
538
		case TV_ENC_NTSC60:
539
		case TV_ENC_PAL60:
540
		case TV_ENC_PALM:
541
			param->v_blanko = (int)( 140 - ( param->v_activeo / 2.0 ) + 0.5 );
542
			break;
543
		default:
544
			param->v_blanko = (int)( 167 - ( param->v_activeo / 2.0 ) + 0.5 );
545
			break;
546
	}
547
548
	// V_BLANKI
549
	vsrq = ( (int)( vsr * 4096.0 + .5 ) ) / 4096.0;
550
	param->vscale = (int)( ( vsr - 1 ) * 4096 + 0.5 );
551
	if( vsrq < vsr )
552
	{
553
	// These calculations are in units of dHCLKO
554
		dMaxHsyncDrift = ( vsrq - vsr ) * tlo / vsr * param->h_clko;
555
		dMinFrontPorchIn = MFP / ( (double)param->h_clki * vsr ) * param->h_clko;
556
		dFrontPorchOut = param->h_clko - param->h_blanko - mode->xres * 2;
557
		dFifoMargin = ( FIFO_SIZE - mode->xres ) * 2;
558
559
		// Check for fifo overflow
560
		if( dFrontPorchOut + dFifoMargin < -dMaxHsyncDrift + dMinFrontPorchIn )
561
		{
562
			dTotalHBlankO = param->h_clko - mode->xres * 2;
563
			dTotalHBlankI = ( (double)param->h_clki - (double)mode->xres ) / param->h_clki / vsr * param->h_clko;
564
565
			// Try forcing the Hsync drift the opposite direction
566
			dMaxHsyncDrift = ( vsrq + 1.0 / 4096 - vsr ) * tlo / vsr * param->h_clko;
567
568
			// Check that fifo overflow and underflow can be avoided
569
			if( dTotalHBlankO + dFifoMargin >= dTotalHBlankI + dMaxHsyncDrift )
570
			{
571
				vsrq = vsrq + 1.0 / 4096;
572
				param->vscale = (int)( ( vsrq - 1 ) * 4096 );
573
			}
574
575
			// NOTE: If fifo overflow and underflow can't be avoided,
576
			//       alternative overscan compensation ratios should
577
			//       be selected and all calculations repeated.  If
578
			//       that is not feasible, the calculations for
579
			//       H_BLANKI below will delay the overflow or under-
580
			//       flow as much as possible, to minimize the visible
581
			//       artifacts.
582
		}
583
	}
584
585
	param->v_blanki = (int)( ( param->v_blanko - 1 ) * vsrq );
586
587
	// H_BLANKI
588
589
	// These calculations are in units of dHCLKI
590
	dTotalHBlankI = param->h_clki - mode->xres;
591
	dFrontPorchIn = max( (double)MFP, min( dTotalHBlankI / 8.0, dTotalHBlankI - (double)MBP ) );
592
	dBackPorchIn = dTotalHBlankI - dFrontPorchIn;
593
	dMaxHsyncDrift = ( vsrq - vsr ) * tlo * param->h_clki;
594
	dTotalHBlankO = ( param->h_clko - mode->xres * 2.0 ) / param->h_clko * vsr * param->h_clki;
595
	dBackPorchOut = ((double)param->h_blanko) / (double)param->h_clko * vsr * param->h_clki;
596
	dFrontPorchOut = dTotalHBlankO - dBackPorchOut;
597
	dFifoMargin = ( FIFO_SIZE - mode->xres ) * 2.0 / param->h_clko * vsr * param->h_clki;
598
	// This may be excessive, but is adjusted by the code.
599
	dHeadRoom = 32.0;
600
601
	// Check that fifo overflow and underflow can be avoided
602
	if( ( dTotalHBlankO + dFifoMargin ) >= ( dTotalHBlankI + fabs( dMaxHsyncDrift ) ) )
603
	{
604
		dMaxHR = ( dTotalHBlankO + dFifoMargin ) - ( dTotalHBlankI - fabs( dMaxHsyncDrift ) );
605
		if( dMaxHR < ( dHeadRoom * 2.0 ) )
606
		{
607
			dHeadRoom = (int)( dMaxHR / 2.0);
608
		}
609
610
		// Check for overflow
611
		if( ( ( dFrontPorchOut + dFifoMargin ) - dHeadRoom ) < ( dFrontPorchIn - min( dMaxHsyncDrift, 0.0 ) ) )
612
		{
613
			dFrontPorchIn = max( (double)MFP, ( dFrontPorchOut + dFifoMargin + min( dMaxHsyncDrift, 0.0 ) - dHeadRoom ) );
614
			dBackPorchIn = dTotalHBlankI - dFrontPorchIn;
615
		}
616
617
		// Check for underflow
618
		if( dBackPorchOut - dHeadRoom < dBackPorchIn + max( dMaxHsyncDrift, 0.0 ) )
619
		{
620
			dBackPorchIn = max( (double)MBP, ( dBackPorchOut - max( dMaxHsyncDrift, 0.0 ) - dHeadRoom ) );
621
			dFrontPorchIn = dTotalHBlankI - dBackPorchIn;
622
		}
623
	}
624
	else if( dMaxHsyncDrift < 0 )
625
	{
626
		// Delay the overflow as long as possible
627
		dBackPorchIn = min( ( dBackPorchOut - 1 ), ( dTotalHBlankI - MFP ) );
628
		dFrontPorchIn = dTotalHBlankI - dBackPorchIn;
629
	}
630
	else
631
	{
632
		// Delay the underflow as long as possible
633
		dFrontPorchIn = min( ( dFrontPorchOut + dFifoMargin - 1 ), ( dTotalHBlankI - MBP ) );
634
		dBackPorchIn = dTotalHBlankI - dFrontPorchIn;
635
	}
636
637
	param->h_blanki = (int)( dBackPorchIn );
638
639
}
(-)linux-2.4.26/drivers/video/xbox/conexant.h (+28 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/conexant.h - Xbox driver for conexant chip
3
 *
4
 * Maintainer: Oliver Schwartz <Oliver.Schwartz@gmx.de>
5
 *
6
 * Contributors:
7
 *
8
 * This file is subject to the terms and conditions of the GNU General Public
9
 * License.  See the file COPYING in the main directory of this archive
10
 * for more details.
11
 *
12
 * Known bugs and issues:
13
 *
14
 *      none
15
 */
16
17
#ifndef conexant_h
18
#define conexant_h
19
20
#include <linux/xboxfbctl.h>
21
#include "xboxfb.h"
22
#include "encoder.h"
23
24
int conexant_calc_mode(xbox_video_mode * mode, struct riva_regs * riva_out);
25
int conexant_calc_vga_mode(xbox_av_type av_type, unsigned char pll_int, unsigned char * mode_out);
26
int conexant_calc_hdtv_mode(xbox_hdtv_mode hdtv_mode, unsigned char pll_int, unsigned char * mode_out);
27
28
#endif
(-)linux-2.4.26/drivers/video/xbox/encoder-i2c.c (+173 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/encoder-i2c.c - Xbox I2C driver for encoder chip
3
 *
4
 * Maintainer: Oliver Schwartz <Oliver.Schwartz@gmx.de>
5
 *
6
 * Contributors:
7
 *
8
 * Most of the code was stolen from extsmi.c
9
 * 
10
 * This file is subject to the terms and conditions of the GNU General Public
11
 * License.  See the file COPYING in the main directory of this archive
12
 * for more details.
13
 *
14
 * Known bugs and issues:
15
 *
16
 *      none
17
 */
18
19
#include <linux/kernel.h>
20
#include <linux/i2c.h>
21
#include <linux/init.h>
22
#include <linux/delay.h>
23
24
#define CONEXANT_ADDRESS 0x45
25
#define FOCUS_ADDRESS 0x6a
26
#define EEPROM_ADDRESS 0x54
27
#define PIC_ADDRESS 0x10
28
29
#define DRIVER_NAME "xbox-tv-i2c"
30
31
extern int __init i2c_xbox_init(void);
32
33
static int tv_attach_adapter(struct i2c_adapter *adap);
34
35
static struct i2c_driver tv_driver = {
36
	.name		= "i2c xbox conexant driver",
37
	.id		= I2C_DRIVERID_I2CDEV,
38
	.flags		= I2C_DF_NOTIFY,
39
	.attach_adapter	= tv_attach_adapter,
40
};
41
42
static struct i2c_client pic_client = {
43
	.name		= "I2C xbox pic client",
44
	.id		= 2,
45
	.flags		= 0,
46
	.addr		= PIC_ADDRESS,
47
	.adapter	= NULL,
48
	.driver		= &tv_driver,
49
};
50
51
static struct i2c_client conexant_client = {
52
	.name		= "I2C xbox conexant client",
53
	.id		= 1,
54
	.flags		= 0,
55
	.addr		= CONEXANT_ADDRESS,
56
	.adapter	= NULL,
57
	.driver		= &tv_driver,
58
};
59
60
static struct i2c_client focus_client = {
61
	.name		= "I2C xbox focus client",
62
	.id		= 1,
63
	.flags		= 0,
64
	.addr		= FOCUS_ADDRESS,
65
	.adapter	= NULL,
66
	.driver		= &tv_driver,
67
};
68
69
static struct i2c_client eeprom_client = {
70
	.name		= "I2C xbox eeprom client",
71
	.id		= 3,
72
	.flags		= 0,
73
	.addr		= EEPROM_ADDRESS,
74
	.adapter	= NULL,
75
	.driver		= &tv_driver,
76
};
77
78
static int tv_attach_adapter(struct i2c_adapter *adap)
79
{
80
	int i;
81
82
	if ((i = i2c_adapter_id(adap)) < 0) {
83
		printk("i2c-dev.o: Unknown adapter ?!?\n");
84
		return -ENODEV;
85
	}
86
87
	printk(KERN_INFO DRIVER_NAME ": Using '%s'!\n",adap->name);
88
	focus_client.adapter = adap;
89
	conexant_client.adapter = adap;
90
	pic_client.adapter = adap;
91
	eeprom_client.adapter = adap;
92
	i2c_attach_client(&focus_client);
93
	i2c_attach_client(&conexant_client);
94
	i2c_attach_client(&pic_client);
95
	i2c_attach_client(&eeprom_client);
96
97
	return 0;
98
}
99
100
int tv_i2c_init(void) {
101
	int res;
102
	i2c_xbox_init();
103
	if ((res = i2c_add_driver(&tv_driver))) {
104
		printk(KERN_ERR DRIVER_NAME ": XBox tv driver registration failed.\n");
105
		return res;
106
	}
107
	return 0;
108
}
109
110
int conexant_i2c_read_reg(unsigned char adr) {
111
	if (!conexant_client.adapter) {
112
		printk(KERN_ERR DRIVER_NAME " : No conexant client attached.\n");
113
		return -1;
114
	}
115
	udelay(500);
116
	return i2c_smbus_read_byte_data(&conexant_client, adr);
117
}
118
119
int conexant_i2c_write_reg(unsigned char adr, unsigned char value) {
120
	if (!conexant_client.adapter) {
121
		printk(KERN_ERR DRIVER_NAME " : No conexant client attached.\n");
122
		return -1;
123
	}
124
	udelay(500);
125
	return i2c_smbus_write_byte_data(&conexant_client, adr, value);
126
}
127
128
int focus_i2c_read_reg(unsigned char adr) {
129
	if (!focus_client.adapter) {
130
		printk(KERN_ERR DRIVER_NAME " : No focus client attached.\n");
131
		return -1;
132
	}
133
	udelay(500);
134
	return i2c_smbus_read_byte_data(&focus_client, adr);
135
}
136
137
int focus_i2c_write_reg(unsigned char adr, unsigned char value) {
138
	if (!focus_client.adapter) {
139
		printk(KERN_ERR DRIVER_NAME " : No focus client attached.\n");
140
		return -1;
141
	}
142
	udelay(500);
143
	return i2c_smbus_write_byte_data(&focus_client, adr, value);
144
}
145
146
unsigned char pic_i2c_read_reg(unsigned char adr) {
147
	if (!pic_client.adapter) {
148
		printk(KERN_ERR DRIVER_NAME " : No pic client attached.\n");
149
		return 0;
150
	}
151
	udelay(500);
152
	return (unsigned char)i2c_smbus_read_byte_data(&pic_client, adr);
153
}
154
155
unsigned char eeprom_i2c_read(unsigned char adr) {
156
	if (!eeprom_client.adapter) {
157
		printk(KERN_ERR DRIVER_NAME " : No eeprom client attached.\n");
158
		return 0;
159
	}
160
	udelay(500);
161
	return (unsigned char)i2c_smbus_read_byte_data(&eeprom_client, adr);
162
}
163
164
void tv_i2c_exit(void){
165
	int res;
166
	
167
	if ((res = i2c_del_driver(&tv_driver))) {
168
		printk(KERN_ERR DRIVER_NAME ": XBox tv Driver deregistration failed, "
169
		       "module not removed.\n");
170
	}
171
	return;
172
}
173
(-)linux-2.4.26/drivers/video/xbox/encoder-i2c.h (+29 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/encoder-i2c.h - Xbox I2C driver for encoder chip
3
 *
4
 * Maintainer: Oliver Schwartz <Oliver.Schwartz@gmx.de>
5
 *
6
 * Contributors:
7
 * 
8
 * This file is subject to the terms and conditions of the GNU General Public
9
 * License.  See the file COPYING in the main directory of this archive
10
 * for more details.
11
 *
12
 * Known bugs and issues:
13
 *
14
 *      none
15
 */
16
 
17
#ifndef encoder_i2c_h
18
#define encoder_i2c_h
19
20
int tv_i2c_init(void);
21
void tv_i2c_exit(void);
22
int conexant_i2c_read_reg(unsigned char adr);
23
int conexant_i2c_write_reg(unsigned char adr, unsigned char value);
24
int focus_i2c_read_reg(unsigned char adr);
25
int focus_i2c_write_reg(unsigned char adr, unsigned char value);
26
unsigned char pic_i2c_read_reg(unsigned char adr);
27
unsigned char eeprom_i2c_read(unsigned char adr);
28
29
#endif
(-)linux-2.4.26/drivers/video/xbox/encoder.c (+172 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/encoder.c - Xbox driver for encoder chip
3
 *
4
 * Maintainer: Oliver Schwartz <Oliver.Schwartz@gmx.de>
5
 *
6
 * Contributors:
7
 *
8
 * This file is subject to the terms and conditions of the GNU General Public
9
 * License.  See the file COPYING in the main directory of this archive
10
 * for more details.
11
 *
12
 * Known bugs and issues:
13
 *
14
 *      none
15
 */
16
17
#include "encoder-i2c.h"
18
#include "encoder.h"
19
#include "focus.h"
20
#include <asm/io.h>
21
22
#define ADR(x) (x / 2 - 0x17)
23
24
static const conexant_video_parameter vidstda[] = {
25
	{ 3579545.00, 0.0000053, 0.00000782, 0.0000047, 0.000063555, 0.0000094, 0.000035667, 0.0000015, 243, 262.5, 0.0000092 },
26
	{ 3579545.00, 0.0000053, 0.00000782, 0.0000047, 0.000064000, 0.0000094, 0.000035667, 0.0000015, 243, 262.5, 0.0000092 },
27
	{ 4433618.75, 0.0000056, 0.00000785, 0.0000047, 0.000064000, 0.0000105, 0.000036407, 0.0000015, 288, 312.5, 0.0000105 },
28
	{ 4433618.75, 0.0000056, 0.00000785, 0.0000047, 0.000064000, 0.0000094, 0.000035667, 0.0000015, 288, 312.5, 0.0000092 },
29
	{ 3582056.25, 0.0000056, 0.00000811, 0.0000047, 0.000064000, 0.0000105, 0.000036407, 0.0000015, 288, 312.5, 0.0000105 },
30
	{ 3575611.88, 0.0000058, 0.00000832, 0.0000047, 0.000063555, 0.0000094, 0.000035667, 0.0000015, 243, 262.5, 0.0000092 },
31
	{ 4433619.49, 0.0000053, 0.00000755, 0.0000047, 0.000063555, 0.0000105, 0.000036407, 0.0000015, 243, 262.5, 0.0000092 }
32
};
33
34
35
static const double pll_base = 13.5e6;
36
37
xbox_encoder_type tv_get_video_encoder(void) {
38
	unsigned char b = 0;
39
	xbox_encoder_type encoder = 0;
40
41
	b = conexant_i2c_read_reg(0x00);
42
	if(b != 255) {
43
		encoder = ENCODER_CONEXANT;
44
	}
45
	b = focus_i2c_read_reg(0x00);
46
	if(b != 255) {
47
		encoder = ENCODER_FOCUS;
48
	}
49
	return encoder;
50
}
51
52
int tv_init(void) {
53
	return tv_i2c_init();
54
}
55
56
void tv_exit(void) {
57
	tv_i2c_exit();
58
}
59
60
void tv_load_mode(unsigned char * mode) {
61
	int n, n1;
62
	unsigned char b;
63
	int encoder = 0;
64
	
65
	encoder = tv_get_video_encoder();
66
67
	if(encoder == ENCODER_CONEXANT) {
68
		conexant_i2c_write_reg(0xc4, 0x00); // EN_OUT = 1
69
70
		// Conexant init (starts at register 0x2e)
71
		n1=0;
72
		for(n=0x2e;n<0x100;n+=2) {
73
			switch(n) {
74
				case 0x6c: // reset
75
					conexant_i2c_write_reg(n, mode[n1] & 0x7f);
76
					break;
77
				case 0xc4: // EN_OUT
78
					conexant_i2c_write_reg(n, mode[n1] & 0xfe);
79
					break;
80
				case 0xb8: // autoconfig
81
					break;
82
83
				default:
84
					conexant_i2c_write_reg(n, mode[n1]);
85
					break;
86
			}
87
			n1++;
88
		}
89
		// Timing Reset
90
		b=conexant_i2c_read_reg(0x6c) & (0x7f);
91
		conexant_i2c_write_reg(0x6c, 0x80|b);
92
		b=conexant_i2c_read_reg(0xc4) & (0xfe);
93
		conexant_i2c_write_reg(0xc4, 0x01|b); // EN_OUT = 1
94
		
95
		/*
96
		conexant_i2c_write_reg(0xA8, (0xD9/1.3));
97
		conexant_i2c_write_reg(0xAA, (0x9A/1.3));
98
		conexant_i2c_write_reg(0xAC, (0xA4/1.3));
99
		*/
100
		
101
		conexant_i2c_write_reg(0xA8, 0x81);
102
		conexant_i2c_write_reg(0xAA, 0x49);
103
		conexant_i2c_write_reg(0xAC, 0x8C);
104
		
105
	} 
106
	
107
	if(encoder == ENCODER_FOCUS) {
108
		//Set the command register soft reset
109
		focus_i2c_write_reg(0x0c,0x03);
110
		focus_i2c_write_reg(0x0d,0x21);
111
		
112
		for (n = 0; n<0xc4; n++) {
113
			focus_i2c_write_reg(n,mode[n]);
114
		}
115
		//Clear soft reset flag
116
		b = focus_i2c_read_reg(0x0c);
117
		b &= ~0x01;
118
		focus_i2c_write_reg(0x0c,b);
119
		b = focus_i2c_read_reg(0x0d);
120
		focus_i2c_write_reg(0x0d,b);
121
	}
122
}
123
124
void tv_save_mode(unsigned char * mode) {
125
	int n, n1;
126
	int encoder = 0;
127
128
	encoder = tv_get_video_encoder();
129
130
	if(encoder == ENCODER_CONEXANT) {
131
		// Conexant init (starts at register 0x2e)
132
		n1=0;
133
		for(n=0x2e;n<0x100;n+=2) {
134
			mode[n1] = conexant_i2c_read_reg(n);
135
			n1++;
136
		}
137
	} 
138
	else if (encoder == ENCODER_FOCUS) {
139
		for (n=0;n<0xc4;n++) {
140
			mode[n] = focus_i2c_read_reg(n);
141
		}
142
143
	}
144
}
145
146
xbox_tv_encoding get_tv_encoding(void) {
147
	unsigned char eeprom_value;
148
	xbox_tv_encoding enc = TV_ENC_PALBDGHI;
149
	eeprom_value = eeprom_i2c_read(0x5a);
150
	if (eeprom_value == 0x40) {
151
		enc = TV_ENC_NTSC;
152
	}
153
	else {
154
		enc = TV_ENC_PALBDGHI;
155
	}
156
	return enc;
157
}
158
159
xbox_av_type detect_av_type(void) {
160
	xbox_av_type avType;
161
	switch (pic_i2c_read_reg(0x04)) {
162
		case 0: avType = AV_SCART_RGB; break;
163
		case 1: avType = AV_HDTV; break;
164
		case 2: avType = AV_VGA_SOG; break;
165
		case 4: avType = AV_SVIDEO; break;
166
		case 6: avType = AV_COMPOSITE; break;
167
		case 7: avType = AV_VGA; break;
168
		default: avType = AV_COMPOSITE; break;
169
	}
170
	return avType;
171
}
172
(-)linux-2.4.26/drivers/video/xbox/encoder.h (+64 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/encoder.h - Xbox driver for encoder chip
3
 *
4
 * Maintainer: Oliver Schwartz <Oliver.Schwartz@gmx.de>
5
 *
6
 * Contributors:
7
 * 
8
 * This file is subject to the terms and conditions of the GNU General Public
9
 * License.  See the file COPYING in the main directory of this archive
10
 * for more details.
11
 *
12
 * Known bugs and issues:
13
 *
14
 *      none
15
 */
16
17
18
#ifndef encoder_h
19
#define encoder_h
20
21
#include <linux/xboxfbctl.h>
22
23
typedef struct {
24
	double m_dHzBurstFrequency;
25
	double m_dSecBurstStart;
26
	double m_dSecBurstEnd;
27
	double m_dSecHsyncWidth;
28
	double m_dSecHsyncPeriod;
29
	double m_dSecActiveBegin;
30
	double m_dSecImageCentre;
31
	double m_dSecBlankBeginToHsync;
32
	unsigned int m_dwALO;
33
	double m_TotalLinesOut;
34
	double m_dSecHsyncToBlankEnd;
35
} conexant_video_parameter;
36
37
typedef struct _xbox_video_mode {
38
	int xres;
39
	int yres;
40
	int bpp;
41
	double hoc;
42
	double voc;
43
	xbox_av_type av_type;
44
	xbox_tv_encoding tv_encoding;
45
} xbox_video_mode;
46
47
typedef enum enumHdtvModes {
48
        HDTV_480p,
49
	HDTV_720p,
50
	HDTV_1080i
51
} xbox_hdtv_mode;
52
53
static const conexant_video_parameter vidstda[];
54
55
int tv_init(void);
56
void tv_exit(void);
57
xbox_encoder_type tv_get_video_encoder(void);
58
59
void tv_save_mode(unsigned char * mode_out);
60
void tv_load_mode(unsigned char * mode);
61
xbox_tv_encoding get_tv_encoding(void);
62
xbox_av_type detect_av_type(void);
63
64
#endif
(-)linux-2.4.26/drivers/video/xbox/fbdev.c (+2521 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/xbox/fbdev.c - nVidia RIVA 128/TNT/TNT2 fb driver
3
 *
4
 * Maintained by Oliver Schwartz <Oliver.Schwartz@gmx.de>
5
 *
6
 * Copyright 1999-2000 Jeff Garzik
7
 *
8
 * Contributors:
9
 *
10
 *	Ani Joshi:  Lots of debugging and cleanup work, really helped
11
 *	get the driver going
12
 *
13
 *	Ferenc Bakonyi:  Bug fixes, cleanup, modularization
14
 *
15
 *	Jindrich Makovicka:  Accel code help, hw cursor, mtrr
16
 *
17
 * Initial template from skeletonfb.c, created 28 Dec 1997 by Geert Uytterhoeven
18
 * Includes riva_hw.c from nVidia, see copyright below.
19
 * KGI code provided the basis for state storage, init, and mode switching.
20
 *
21
 * This file is subject to the terms and conditions of the GNU General Public
22
 * License.  See the file COPYING in the main directory of this archive
23
 * for more details.
24
 *
25
 * Known bugs and issues:
26
 *	restoring text mode fails
27
 *	doublescan modes are broken
28
 *	option 'noaccel' has no effect
29
 */
30
31
#include <linux/config.h>
32
#include <linux/module.h>
33
#include <linux/kernel.h>
34
#include <linux/errno.h>
35
#include <linux/string.h>
36
#include <linux/mm.h>
37
#include <linux/selection.h>
38
#include <linux/tty.h>
39
#include <linux/slab.h>
40
#include <linux/delay.h>
41
#include <linux/fb.h>
42
#include <linux/init.h>
43
#include <linux/pci.h>
44
#include <linux/console.h>
45
#ifdef CONFIG_MTRR
46
#include <asm/mtrr.h>
47
#endif
48
#include "xboxfb.h"
49
#include "nvreg.h"
50
#include <linux/sys.h>
51
#include <asm/uaccess.h>
52
#include <linux/xboxfbctl.h>
53
#include "encoder-i2c.h"
54
#include "conexant.h"
55
#include "focus.h"
56
57
#ifndef CONFIG_PCI		/* sanity check */
58
#error This driver requires PCI support.
59
#endif
60
61
/* version number of this driver */
62
#define RIVAFB_VERSION "0.9.6-xbox"
63
64
65
66
/* ------------------------------------------------------------------------- *
67
 *
68
 * various helpful macros and constants
69
 *
70
 * ------------------------------------------------------------------------- */
71
72
#undef RIVAFBDEBUG
73
#ifdef RIVAFBDEBUG
74
#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
75
#else
76
#define DPRINTK(fmt, args...)
77
#endif
78
79
#ifndef RIVA_NDEBUG
80
#define assert(expr) \
81
	if(!(expr)) { \
82
	printk( "Assertion failed! %s,%s,%s,line=%d\n",\
83
	#expr,__FILE__,__FUNCTION__,__LINE__); \
84
	BUG(); \
85
	}
86
#else
87
#define assert(expr)
88
#endif
89
90
#define PFX "xboxfb: "
91
92
/* macro that allows you to set overflow bits */
93
#define SetBitField(value,from,to) SetBF(to,GetBF(value,from))
94
#define SetBit(n)		(1<<(n))
95
#define Set8Bits(value)		((value)&0xff)
96
97
/* HW cursor parameters */
98
#define DEFAULT_CURSOR_BLINK_RATE	(40)
99
#define CURSOR_HIDE_DELAY		(20)
100
#define CURSOR_SHOW_DELAY		(3)
101
102
#define CURSOR_COLOR		0x7fff
103
#define TRANSPARENT_COLOR	0x0000
104
#define MAX_CURS		32
105
106
107
/* ------------------------------------------------------------------------- *
108
 *
109
 * prototypes
110
 *
111
 * ------------------------------------------------------------------------- */
112
113
static void rivafb_blank(int blank, struct fb_info *info);
114
115
extern void riva_setup_accel(struct rivafb_info *rinfo);
116
extern inline void wait_for_idle(struct rivafb_info *rinfo);
117
118
119
120
/* ------------------------------------------------------------------------- *
121
 *
122
 * card identification
123
 *
124
 * ------------------------------------------------------------------------- */
125
126
enum xbox_chips {
127
	CH_GEFORCE3_XBOX
128
};
129
130
/* directly indexed by xbox_chips enum, above */
131
static struct riva_chip_info {
132
	const char *name;
133
	unsigned arch_rev;
134
} riva_chip_info[] __devinitdata = {
135
	{ "GeForce3-Xbox", NV_ARCH_20}
136
};
137
138
static struct pci_device_id rivafb_pci_tbl[] __devinitdata = {
139
        { PCI_VENDOR_ID_NVIDIA, 0x2a0,
140
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE3_XBOX },
141
	{ 0, } /* terminate list */
142
};
143
MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl);
144
145
146
147
/* ------------------------------------------------------------------------- *
148
 *
149
 * framebuffer related structures
150
 *
151
 * ------------------------------------------------------------------------- */
152
153
#ifdef FBCON_HAS_CFB8
154
extern struct display_switch fbcon_riva8;
155
#endif
156
#ifdef FBCON_HAS_CFB16
157
extern struct display_switch fbcon_riva16;
158
#endif
159
#ifdef FBCON_HAS_CFB32
160
extern struct display_switch fbcon_riva32;
161
#endif
162
163
#if 0
164
/* describes the state of a Riva board */
165
struct rivafb_par {
166
	struct riva_regs state;	/* state of hw board */
167
	__u32 visual;		/* FB_VISUAL_xxx */
168
	unsigned depth;		/* bpp of current mode */
169
};
170
#endif
171
172
struct riva_cursor {
173
	int enable;
174
	int on;
175
	int vbl_cnt;
176
	int last_move_delay;
177
	int blink_rate;
178
	struct {
179
		u16 x, y;
180
	} pos, size;
181
	unsigned short image[MAX_CURS*MAX_CURS];
182
	struct timer_list *timer;
183
};
184
185
/* ------------------------------------------------------------------------- *
186
 *
187
 * global variables
188
 *
189
 * ------------------------------------------------------------------------- */
190
191
struct rivafb_info *riva_boards = NULL;
192
193
/* command line data, set in xboxfb_setup() */
194
static char fontname[40] __initdata = { 0 };
195
static char noaccel __initdata = 0;
196
static char nomove = 0;
197
static char nohwcursor __initdata = 1;
198
static char noblink = 0;
199
200
static unsigned long fb_start __initdata = 0;
201
static unsigned long fb_size __initdata = 0;
202
static xbox_tv_encoding tv_encoding  __initdata = TV_ENC_INVALID;
203
static xbox_av_type av_type __initdata = AV_INVALID;
204
static int hoc __initdata = -1;
205
static int voc __initdata = -1;
206
//#ifdef MODULE
207
//static char *fb_mem = NULL;
208
//static char *tv = NULL;
209
//#endif
210
211
#ifdef CONFIG_MTRR
212
static char nomtrr __initdata = 0;
213
#endif
214
215
static char *mode_option __initdata = NULL;
216
217
static struct fb_var_screeninfo xboxfb_mode_640x480 = {
218
	.xres		= 640,
219
	.yres		= 480,
220
	.xres_virtual	= 640,
221
	.yres_virtual	= 480,
222
	.xoffset	= 0,
223
	.yoffset	= 0,
224
	.bits_per_pixel	= 8,
225
	.grayscale	= 0,
226
	.red		= {0, 6, 0},
227
	.green		= {0, 6, 0},
228
	.blue		= {0, 6, 0},
229
	.transp		= {0, 0, 0},
230
	.nonstd		= 0,
231
	.activate	= 0,
232
	.height		= -1,
233
	.width		= -1,
234
	.accel_flags	= FB_ACCELF_TEXT,
235
	.pixclock	= 39721,
236
	.left_margin	= 40,
237
	.right_margin	= 24,
238
	.upper_margin	= 32,
239
	.lower_margin	= 11,
240
	.hsync_len	= 96,
241
	.vsync_len	= 2,
242
	.sync		= 0,
243
	.vmode		= FB_VMODE_NONINTERLACED
244
};
245
246
static struct fb_var_screeninfo xboxfb_mode_800x600 = {
247
	.xres		= 800,
248
	.yres		= 600,
249
	.xres_virtual	= 800,
250
	.yres_virtual	= 600,
251
	.xoffset	= 0,
252
	.yoffset	= 0,
253
	.bits_per_pixel	= 16,
254
	.grayscale	= 0,
255
	.red		= {0, 5, 10},
256
	.green		= {0, 5, 5},
257
	.blue		= {0, 5, 0},
258
	.transp		= {0, 0, 0},
259
	.nonstd		= 0,
260
	.activate	= 0,
261
	.height		= -1,
262
	.width		= -1,
263
	.accel_flags	= FB_ACCELF_TEXT,
264
	.pixclock	= 22000,
265
	.left_margin	= 135,
266
	.right_margin	= 124,
267
	.upper_margin	= 55,
268
	.lower_margin	= 27,
269
	.hsync_len	= 136,
270
	.vsync_len	= 84,
271
	.sync		= 0,
272
	.vmode		= FB_VMODE_NONINTERLACED
273
};
274
275
static struct fb_var_screeninfo xboxfb_mode_480p = {
276
	.xres		= 720,
277
	.yres		= 480,
278
	.xres_virtual	= 720,
279
	.yres_virtual	= 480,
280
	.xoffset	= 0,
281
	.yoffset	= 0,
282
	.bits_per_pixel	= 32,
283
	.grayscale	= 0,
284
	.red		= {0, 8, 16},
285
	.green		= {0, 8, 8},
286
	.blue		= {0, 8, 0},
287
	.transp		= {0, 0, 0},
288
	.nonstd		= 0,
289
	.activate	= 0,
290
	.height		= -1,
291
	.width		= -1,
292
	.accel_flags	= FB_ACCELF_TEXT,
293
	.pixclock	= 37000,
294
	.left_margin	= 56,
295
	.right_margin	= 18,
296
	.upper_margin	= 29,
297
	.lower_margin	= 9,
298
	.hsync_len	= 64,
299
	.vsync_len	= 7,
300
	.sync		= 0,
301
	.vmode		= FB_VMODE_NONINTERLACED
302
};
303
304
static struct fb_var_screeninfo xboxfb_mode_720p = {
305
	.xres		= 1280,
306
	.yres		= 720,
307
	.xres_virtual	= 1280,
308
	.yres_virtual	= 720,
309
	.xoffset	= 0,
310
	.yoffset	= 0,
311
	.bits_per_pixel	= 8,
312
	.grayscale	= 0,
313
	.red		= {0, 6, 0},
314
	.green		= {0, 6, 0},
315
	.blue		= {0, 6, 0},
316
	.transp		= {0, 0, 0},
317
	.nonstd		= 0,
318
	.activate	= 0,
319
	.height		= -1,
320
	.width		= -1,
321
	.accel_flags	= FB_ACCELF_TEXT,
322
	.pixclock	= 13468,
323
	.left_margin	= 220,
324
	.right_margin	= 70,
325
	.upper_margin	= 22,
326
	.lower_margin	= 3,
327
	.hsync_len	= 80,
328
	.vsync_len	= 5,
329
	.sync		= 0,
330
	.vmode		= FB_VMODE_NONINTERLACED
331
};
332
333
static const char* tvEncodingNames[] = {
334
	"NTSC",
335
	"NTSC-60",
336
	"PAL-BDGHI",
337
	"PAL-N",
338
	"PAL-NC",
339
	"PAL-M",
340
	"PAL-60"
341
};
342
343
static const char* avTypeNames[] = {
344
	"SCART (RGB)",
345
	"S-Video",
346
	"VGA (Sync on green)",
347
	"HDTV (Component video)",
348
	"Composite",
349
	"VGA (internal syncs)"
350
};
351
352
/* from GGI */
353
static const struct riva_regs reg_template = {
354
	{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,	/* ATTR */
355
	 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
356
	 0x41, 0x01, 0x0F, 0x00, 0x00},
357
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	/* CRT  */
358
	 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
359
	 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3,	/* 0x10 */
360
	 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
361
	 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	/* 0x20 */
362
	 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
363
	 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	/* 0x30 */
364
	 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
365
	 0x00,							/* 0x40 */
366
	 },
367
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,	/* GRA  */
368
	 0xFF},
369
	{0x03, 0x01, 0x0F, 0x00, 0x0E},				/* SEQ  */
370
	0xEB							/* MISC */
371
};
372
373
/* ------------------------------------------------------------------------- *
374
 *
375
 * MMIO access macros
376
 *
377
 * ------------------------------------------------------------------------- */
378
379
static inline void CRTCout(struct rivafb_info *rinfo, unsigned char index,
380
			   unsigned char val)
381
{
382
	VGA_WR08(rinfo->riva.PCIO, 0x3d4, index);
383
	VGA_WR08(rinfo->riva.PCIO, 0x3d5, val);
384
}
385
386
static inline unsigned char CRTCin(struct rivafb_info *rinfo,
387
				   unsigned char index)
388
{
389
	VGA_WR08(rinfo->riva.PCIO, 0x3d4, index);
390
	return (VGA_RD08(rinfo->riva.PCIO, 0x3d5));
391
}
392
393
static inline void GRAout(struct rivafb_info *rinfo, unsigned char index,
394
			  unsigned char val)
395
{
396
	VGA_WR08(rinfo->riva.PVIO, 0x3ce, index);
397
	VGA_WR08(rinfo->riva.PVIO, 0x3cf, val);
398
}
399
400
static inline unsigned char GRAin(struct rivafb_info *rinfo,
401
				  unsigned char index)
402
{
403
	VGA_WR08(rinfo->riva.PVIO, 0x3ce, index);
404
	return (VGA_RD08(rinfo->riva.PVIO, 0x3cf));
405
}
406
407
static inline void SEQout(struct rivafb_info *rinfo, unsigned char index,
408
			  unsigned char val)
409
{
410
	VGA_WR08(rinfo->riva.PVIO, 0x3c4, index);
411
	VGA_WR08(rinfo->riva.PVIO, 0x3c5, val);
412
}
413
414
static inline unsigned char SEQin(struct rivafb_info *rinfo,
415
				  unsigned char index)
416
{
417
	VGA_WR08(rinfo->riva.PVIO, 0x3c4, index);
418
	return (VGA_RD08(rinfo->riva.PVIO, 0x3c5));
419
}
420
421
static inline void ATTRout(struct rivafb_info *rinfo, unsigned char index,
422
			   unsigned char val)
423
{
424
	VGA_WR08(rinfo->riva.PCIO, 0x3c0, index);
425
	VGA_WR08(rinfo->riva.PCIO, 0x3c0, val);
426
}
427
428
static inline unsigned char ATTRin(struct rivafb_info *rinfo,
429
				   unsigned char index)
430
{
431
	VGA_WR08(rinfo->riva.PCIO, 0x3c0, index);
432
	return (VGA_RD08(rinfo->riva.PCIO, 0x3c1));
433
}
434
435
static inline void MISCout(struct rivafb_info *rinfo, unsigned char val)
436
{
437
	VGA_WR08(rinfo->riva.PVIO, 0x3c2, val);
438
}
439
440
static inline unsigned char MISCin(struct rivafb_info *rinfo)
441
{
442
	return (VGA_RD08(rinfo->riva.PVIO, 0x3cc));
443
}
444
445
446
447
/* ------------------------------------------------------------------------- *
448
 *
449
 * cursor stuff
450
 *
451
 * ------------------------------------------------------------------------- */
452
453
/**
454
 * riva_cursor_timer_handler - blink timer
455
 * @dev_addr: pointer to rivafb_info object containing info for current riva board
456
 *
457
 * DESCRIPTION:
458
 * Cursor blink timer.
459
 */
460
static void riva_cursor_timer_handler(unsigned long dev_addr)
461
{
462
	struct rivafb_info *rinfo = (struct rivafb_info *)dev_addr;
463
464
	if (!rinfo->cursor) return;
465
466
	if (!rinfo->cursor->enable) goto out;
467
468
	if (rinfo->cursor->last_move_delay < 1000)
469
		rinfo->cursor->last_move_delay++;
470
471
	if (rinfo->cursor->vbl_cnt && --rinfo->cursor->vbl_cnt == 0) {
472
		rinfo->cursor->on ^= 1;
473
		if (rinfo->cursor->on)
474
			*(rinfo->riva.CURSORPOS) = (rinfo->cursor->pos.x & 0xFFFF)
475
						   | (rinfo->cursor->pos.y << 16);
476
		rinfo->riva.ShowHideCursor(&rinfo->riva, rinfo->cursor->on);
477
		if (!noblink)
478
			rinfo->cursor->vbl_cnt = rinfo->cursor->blink_rate;
479
	}
480
out:
481
	rinfo->cursor->timer->expires = jiffies + (HZ / 100);
482
	add_timer(rinfo->cursor->timer);
483
}
484
485
/**
486
 * rivafb_init_cursor - allocates cursor structure and starts blink timer
487
 * @rinfo: pointer to rivafb_info object containing info for current riva board
488
 *
489
 * DESCRIPTION:
490
 * Allocates cursor structure and starts blink timer.
491
 *
492
 * RETURNS:
493
 * Pointer to allocated cursor structure.
494
 *
495
 * CALLED FROM:
496
 * rivafb_init_one()
497
 */
498
static struct riva_cursor * __init rivafb_init_cursor(struct rivafb_info *rinfo)
499
{
500
	struct riva_cursor *cursor;
501
502
	cursor = kmalloc(sizeof(struct riva_cursor), GFP_KERNEL);
503
	if (!cursor) return 0;
504
	memset(cursor, 0, sizeof(*cursor));
505
506
	cursor->timer = kmalloc(sizeof(*cursor->timer), GFP_KERNEL);
507
	if (!cursor->timer) {
508
		kfree(cursor);
509
		return 0;
510
	}
511
	memset(cursor->timer, 0, sizeof(*cursor->timer));
512
513
	cursor->blink_rate = DEFAULT_CURSOR_BLINK_RATE;
514
515
	init_timer(cursor->timer);
516
	cursor->timer->expires = jiffies + (HZ / 100);
517
	cursor->timer->data = (unsigned long)rinfo;
518
	cursor->timer->function = riva_cursor_timer_handler;
519
	add_timer(cursor->timer);
520
521
	return cursor;
522
}
523
524
/**
525
 * rivafb_exit_cursor - stops blink timer and releases cursor structure
526
 * @rinfo: pointer to rivafb_info object containing info for current riva board
527
 *
528
 * DESCRIPTION:
529
 * Stops blink timer and releases cursor structure.
530
 *
531
 * CALLED FROM:
532
 * rivafb_init_one()
533
 * rivafb_remove_one()
534
 */
535
static void rivafb_exit_cursor(struct rivafb_info *rinfo)
536
{
537
	struct riva_cursor *cursor = rinfo->cursor;
538
539
	if (cursor) {
540
		if (cursor->timer) {
541
			del_timer_sync(cursor->timer);
542
			kfree(cursor->timer);
543
		}
544
		kfree(cursor);
545
		rinfo->cursor = 0;
546
	}
547
}
548
549
/**
550
 * rivafb_download_cursor - writes cursor shape into card registers
551
 * @rinfo: pointer to rivafb_info object containing info for current riva board
552
 *
553
 * DESCRIPTION:
554
 * Writes cursor shape into card registers.
555
 *
556
 * CALLED FROM:
557
 * riva_load_video_mode()
558
 */
559
static void rivafb_download_cursor(struct rivafb_info *rinfo)
560
{
561
	int i, save;
562
	int *image;
563
	
564
	if (!rinfo->cursor) return;
565
566
	image = (int *)rinfo->cursor->image;
567
	save = rinfo->riva.ShowHideCursor(&rinfo->riva, 0);
568
	for (i = 0; i < (MAX_CURS*MAX_CURS*2)/sizeof(int); i++)
569
		writel(image[i], rinfo->riva.CURSOR + i);
570
571
	rinfo->riva.ShowHideCursor(&rinfo->riva, save);
572
}
573
574
/**
575
 * rivafb_create_cursor - sets rectangular cursor
576
 * @rinfo: pointer to rivafb_info object containing info for current riva board
577
 * @width: cursor width in pixels
578
 * @height: cursor height in pixels
579
 *
580
 * DESCRIPTION:
581
 * Sets rectangular cursor.
582
 *
583
 * CALLED FROM:
584
 * rivafb_set_font()
585
 * rivafb_set_var()
586
 */
587
static void rivafb_create_cursor(struct rivafb_info *rinfo, int width, int height)
588
{
589
	struct riva_cursor *c = rinfo->cursor;
590
	int i, j, idx;
591
592
	if (c) {
593
		if (width <= 0 || height <= 0) {
594
			width = 8;
595
			height = 16;
596
		}
597
		if (width > MAX_CURS) width = MAX_CURS;
598
		if (height > MAX_CURS) height = MAX_CURS;
599
600
		c->size.x = width;
601
		c->size.y = height;
602
		
603
		idx = 0;
604
605
		for (i = 0; i < height; i++) {
606
			for (j = 0; j < width; j++,idx++)
607
				c->image[idx] = CURSOR_COLOR;
608
			for (j = width; j < MAX_CURS; j++,idx++)
609
				c->image[idx] = TRANSPARENT_COLOR;
610
		}
611
		for (i = height; i < MAX_CURS; i++)
612
			for (j = 0; j < MAX_CURS; j++,idx++)
613
				c->image[idx] = TRANSPARENT_COLOR;
614
	}
615
}
616
617
/**
618
 * rivafb_set_font - change font size
619
 * @p: pointer to display object
620
 * @width: font width in pixels
621
 * @height: font height in pixels
622
 *
623
 * DESCRIPTION:
624
 * Callback function called if font settings changed.
625
 *
626
 * RETURNS:
627
 * 1 (Always succeeds.)
628
 */
629
static int rivafb_set_font(struct display *p, int width, int height)
630
{
631
	struct rivafb_info *fb = (struct rivafb_info *)(p->fb_info);
632
633
	rivafb_create_cursor(fb, width, height);
634
	return 1;
635
}
636
637
/**
638
 * rivafb_cursor - cursor handler
639
 * @p: pointer to display object
640
 * @mode: cursor mode (see CM_*)
641
 * @x: cursor x coordinate in characters
642
 * @y: cursor y coordinate in characters
643
 *
644
 * DESCRIPTION:
645
 * Cursor handler.
646
 */
647
static void rivafb_cursor(struct display *p, int mode, int x, int y)
648
{
649
	struct rivafb_info *rinfo = (struct rivafb_info *)(p->fb_info);
650
	struct riva_cursor *c = rinfo->cursor;
651
652
	if (!c)	return;
653
654
	x = x * fontwidth(p) - p->var.xoffset;
655
	y = y * fontheight(p) - p->var.yoffset;
656
657
	if (c->pos.x == x && c->pos.y == y && (mode == CM_ERASE) == !c->enable)
658
		return;
659
660
	c->enable = 0;
661
	if (c->on) rinfo->riva.ShowHideCursor(&rinfo->riva, 0);
662
663
	c->pos.x = x;
664
	c->pos.y = y;
665
666
	switch (mode) {
667
	case CM_ERASE:
668
		c->on = 0;
669
		break;
670
	case CM_DRAW:
671
	case CM_MOVE:
672
		if (c->last_move_delay <= 1) { /* rapid cursor movement */
673
			c->vbl_cnt = CURSOR_SHOW_DELAY;
674
		} else {
675
			*(rinfo->riva.CURSORPOS) = (x & 0xFFFF) | (y << 16);
676
			rinfo->riva.ShowHideCursor(&rinfo->riva, 1);
677
			if (!noblink) c->vbl_cnt = CURSOR_HIDE_DELAY;
678
			c->on = 1;
679
		}
680
		c->last_move_delay = 0;
681
		c->enable = 1;
682
		break;
683
	}
684
}
685
686
687
688
/* ------------------------------------------------------------------------- *
689
 *
690
 * general utility functions
691
 *
692
 * ------------------------------------------------------------------------- */
693
694
/**
695
 * riva_set_dispsw - sets dispsw
696
 * @rinfo: pointer to internal driver struct for a given Riva card
697
 * @disp: pointer to display object
698
 *
699
  DESCRIPTION:
700
 * Sets up console low level operations depending on the current? color depth
701
 * of the display.
702
 *
703
 * CALLED FROM:
704
 * rivafb_set_var()
705
 * rivafb_switch()
706
 * riva_init_disp()
707
 */
708
static void riva_set_dispsw(struct rivafb_info *rinfo, struct display *disp)
709
{
710
	int accel = disp->var.accel_flags & FB_ACCELF_TEXT;
711
712
	DPRINTK("ENTER\n");
713
714
	assert(rinfo != NULL);
715
716
	disp->dispsw_data = NULL;
717
718
	disp->screen_base = rinfo->fb_base;
719
	disp->type = FB_TYPE_PACKED_PIXELS;
720
	disp->type_aux = 0;
721
	disp->ypanstep = 1;
722
	disp->ywrapstep = 0;
723
	disp->can_soft_blank = 1;
724
	disp->inverse = 0;
725
726
	switch (disp->var.bits_per_pixel) {
727
#ifdef FBCON_HAS_CFB8
728
	case 8:
729
		rinfo->dispsw = accel ? fbcon_riva8 : fbcon_cfb8;
730
		disp->dispsw = &rinfo->dispsw;
731
		disp->line_length = disp->var.xres_virtual;
732
		disp->visual = FB_VISUAL_PSEUDOCOLOR;
733
		break;
734
#endif
735
#ifdef FBCON_HAS_CFB16
736
	case 16:
737
		rinfo->dispsw = accel ? fbcon_riva16 : fbcon_cfb16;
738
		disp->dispsw_data = &rinfo->con_cmap.cfb16;
739
		disp->dispsw = &rinfo->dispsw;
740
		disp->line_length = disp->var.xres_virtual * 2;
741
		disp->visual = FB_VISUAL_DIRECTCOLOR;
742
		break;
743
#endif
744
#ifdef FBCON_HAS_CFB32
745
	case 32:
746
		rinfo->dispsw = accel ? fbcon_riva32 : fbcon_cfb32;
747
		disp->dispsw_data = rinfo->con_cmap.cfb32;
748
		disp->dispsw = &rinfo->dispsw;
749
		disp->line_length = disp->var.xres_virtual * 4;
750
		disp->visual = FB_VISUAL_DIRECTCOLOR;
751
		break;
752
#endif
753
	default:
754
		DPRINTK("Setting fbcon_dummy renderer\n");
755
		rinfo->dispsw = fbcon_dummy;
756
		disp->dispsw = &rinfo->dispsw;
757
	}
758
759
	/* FIXME: verify that the above code sets dsp->* fields correctly */
760
761
	if (rinfo->cursor) {
762
		rinfo->dispsw.cursor = rivafb_cursor;
763
		rinfo->dispsw.set_font = rivafb_set_font;
764
	}
765
766
	DPRINTK("EXIT\n");
767
}
768
769
/**
770
 * riva_wclut - set CLUT entry
771
 * @chip: pointer to RIVA_HW_INST object
772
 * @regnum: register number
773
 * @red: red component
774
 * @green: green component
775
 * @blue: blue component
776
 *
777
 * DESCRIPTION:
778
 * Sets color register @regnum.
779
 *
780
 * CALLED FROM:
781
 * riva_setcolreg()
782
 */
783
static void riva_wclut(RIVA_HW_INST *chip,
784
		       unsigned char regnum, unsigned char red,
785
		       unsigned char green, unsigned char blue)
786
{
787
	VGA_WR08(chip->PDIO, 0x3c8, regnum);
788
	VGA_WR08(chip->PDIO, 0x3c9, red);
789
	VGA_WR08(chip->PDIO, 0x3c9, green);
790
	VGA_WR08(chip->PDIO, 0x3c9, blue);
791
}
792
793
/**
794
 * riva_save_state - saves current chip state
795
 * @rinfo: pointer to rivafb_info object containing info for current riva board
796
 * @regs: pointer to riva_regs object
797
 *
798
 * DESCRIPTION:
799
 * Saves current chip state to @regs.
800
 *
801
 * CALLED FROM:
802
 * rivafb_init_one()
803
 */
804
/* from GGI */
805
static void riva_save_state(struct rivafb_info *rinfo, struct riva_regs *regs)
806
{
807
	int i;
808
809
	rinfo->riva.LockUnlock(&rinfo->riva, 0);
810
811
	rinfo->riva.UnloadStateExt(&rinfo->riva, &regs->ext);
812
813
	regs->misc_output = MISCin(rinfo);
814
815
	for (i = 0; i < NUM_CRT_REGS; i++) {
816
		regs->crtc[i] = CRTCin(rinfo, i);
817
	}
818
819
	for (i = 0; i < NUM_ATC_REGS; i++) {
820
		regs->attr[i] = ATTRin(rinfo, i);
821
	}
822
823
	for (i = 0; i < NUM_GRC_REGS; i++) {
824
		regs->gra[i] = GRAin(rinfo, i);
825
	}
826
827
	for (i = 0; i < NUM_SEQ_REGS; i++) {
828
		regs->seq[i] = SEQin(rinfo, i);
829
	}
830
	tv_save_mode(regs->encoder_mode);
831
}
832
833
/**
834
 * riva_load_state - loads current chip state
835
 * @rinfo: pointer to rivafb_info object containing info for current riva board
836
 * @regs: pointer to riva_regs object
837
 *
838
 * DESCRIPTION:
839
 * Loads chip state from @regs.
840
 *
841
 * CALLED FROM:
842
 * riva_load_video_mode()
843
 * rivafb_init_one()
844
 * rivafb_remove_one()
845
 */
846
/* from GGI */
847
static void riva_load_state(struct rivafb_info *rinfo, struct riva_regs *regs)
848
{
849
	int i;
850
	RIVA_HW_STATE *state = &regs->ext;
851
852
	CRTCout(rinfo, 0x11, 0x00);
853
854
	rinfo->riva.LockUnlock(&rinfo->riva, 0);
855
856
	rinfo->riva.LoadStateExt(&rinfo->riva, state);
857
858
	rinfo->riva.PGRAPH[0x00000820/4] = rinfo->riva_fb_start;
859
	rinfo->riva.PGRAPH[0x00000824/4] = rinfo->riva_fb_start;
860
	rinfo->riva.PGRAPH[0x00000828/4] = rinfo->riva_fb_start;
861
	rinfo->riva.PGRAPH[0x0000082c/4] = rinfo->riva_fb_start;
862
863
	rinfo->riva.PGRAPH[0x00000684/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
864
	rinfo->riva.PGRAPH[0x00000688/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
865
	rinfo->riva.PGRAPH[0x0000068c/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
866
	rinfo->riva.PGRAPH[0x00000690/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
867
	rinfo->riva.PRAMDAC[0x00000848/4] = 0x10100111;
868
	rinfo->riva.PRAMDAC[0x00000880/4] = 0;
869
	rinfo->riva.PRAMDAC[0x000008a0/4] = 0;
870
	rinfo->riva.PMC[0x00008908/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
871
	rinfo->riva.PMC[0x0000890c/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
872
	/* It has been decided to leave the GPU in RGB mode always, and handle
873
	 * the scaling in the encoder, if necessary. This sidesteps the 2.6 
874
	 * kernel cursor issue seen with YUV output */
875
	rinfo->riva.PRAMDAC[0x00000630/4] = 0; 
876
877
	/* These two need to be 0 on RGB to fix the maroon 
878
	 * borders issue */
879
	rinfo->riva.PRAMDAC[0x0000084c/4] = 0;
880
	rinfo->riva.PRAMDAC[0x000008c4/4] = 0;
881
882
	/* YUV values: 
883
	rinfo->riva.PRAMDAC[0x0000084c/4] = 0x00801080;
884
	rinfo->riva.PRAMDAC[0x000008c4/4] = 0x40801080;
885
	*/
886
887
	MISCout(rinfo, regs->misc_output);
888
889
	for (i = 0; i < NUM_CRT_REGS; i++) {
890
		switch (i) {
891
		case 0x0c:
892
		case 0x0d:
893
		case 0x19:
894
		case 0x20 ... 0x40:
895
			break;
896
		default:
897
			CRTCout(rinfo, i, regs->crtc[i]);
898
		}
899
	}
900
901
	for (i = 0; i < NUM_ATC_REGS; i++) {
902
		ATTRout(rinfo, i, regs->attr[i]);
903
	}
904
905
	for (i = 0; i < NUM_GRC_REGS; i++) {
906
		GRAout(rinfo, i, regs->gra[i]);
907
	}
908
909
	for (i = 0; i < NUM_SEQ_REGS; i++) {
910
		SEQout(rinfo, i, regs->seq[i]);
911
	}
912
}
913
914
static inline unsigned long xbox_memory_size(void) {
915
	/* make a guess on the xbox memory size. There are just
916
	   two possibilities */
917
	if ((num_physpages << PAGE_SHIFT) > 64*1024*1024) {
918
		return 128*1024*1024;
919
	} else {
920
		return 64*1024*1024;
921
	}
922
}
923
924
static inline unsigned long available_framebuffer_memory(void) {
925
	return xbox_memory_size() - (num_physpages << PAGE_SHIFT);
926
}
927
928
/**
929
 * xbox_load_video_mode - calculate timings for Xbox
930
 * @rinfo: pointer to rivafb_info object containing info for current riva board
931
 * @video_mode: video mode to set
932
 *
933
 * DESCRIPTION:
934
 * Calculate some timings and then send em off to riva_load_state().
935
 *
936
 * CALLED FROM:
937
 * rivafb_set_var()
938
 */
939
static void xbox_load_video_mode(struct rivafb_info *rinfo,
940
				 struct fb_var_screeninfo *video_mode)
941
{
942
	struct riva_regs newmode;
943
	int bpp, width, hDisplaySize, crtc_hDisplay, crtc_hStart,
944
	    crtc_hEnd, crtc_hTotal, height, crtc_vDisplay, crtc_vStart,
945
		crtc_vEnd, crtc_vTotal, dotClock,
946
		hStart, hTotal, vStart, vTotal;
947
	int crtc_hBlankStart, crtc_hBlankEnd, crtc_vBlankStart, crtc_vBlankEnd;
948
	int encoder_ok = 0;
949
950
	/* time to calculate */
951
	bpp = video_mode->bits_per_pixel;
952
	if (bpp == 16 && video_mode->green.length == 5)
953
		bpp = 15;
954
	dotClock = 1000000000 / video_mode->pixclock;
955
	hDisplaySize = video_mode->xres;
956
	hStart = hDisplaySize + video_mode->right_margin;
957
	hTotal = hDisplaySize + video_mode->right_margin +
958
		  video_mode->hsync_len + video_mode->left_margin;
959
	vStart = video_mode->yres + video_mode->lower_margin;
960
	vTotal = video_mode->yres + video_mode->lower_margin +
961
		 video_mode->vsync_len + video_mode->upper_margin;
962
963
	rivafb_blank(1, (struct fb_info *)rinfo);
964
	memcpy(&newmode, &reg_template, sizeof(struct riva_regs));
965
966
	width = video_mode->xres_virtual;
967
	height = video_mode->yres_virtual;
968
969
	crtc_hDisplay = (hDisplaySize / 8) - 1;
970
	crtc_hStart = (hTotal - 32) / 8;
971
	crtc_hEnd = crtc_hStart + 1;
972
	crtc_hTotal = (hTotal) / 8 - 5;
973
	crtc_hBlankStart = crtc_hDisplay;
974
	crtc_hBlankEnd = crtc_hTotal + 4;
975
	
976
	crtc_vDisplay = video_mode->yres - 1;
977
	crtc_vStart = vStart;
978
	crtc_vEnd = crtc_vStart + 2;
979
	crtc_vTotal = vTotal + 2;
980
	crtc_vBlankStart = crtc_vDisplay;
981
	crtc_vBlankEnd = crtc_vTotal + 1;
982
983
	if ((video_mode->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
984
		crtc_vTotal |= 1;
985
986
	newmode.ext.bpp = bpp;
987
	newmode.ext.fb_start = rinfo->riva_fb_start;
988
989
	/* time to calculate */
990
	if((rinfo->av_type == AV_VGA) || (rinfo->av_type == AV_VGA_SOG) || (rinfo->av_type == AV_HDTV)) {
991
		unsigned char pll_int = (unsigned char)((double)dotClock * 6.0 / 13.5e3 + 0.5);
992
		if (rinfo->av_type == AV_HDTV) {
993
			xbox_hdtv_mode hdtv_mode = HDTV_480p;
994
			if (video_mode->yres > 800) {
995
				hdtv_mode = HDTV_1080i;
996
				crtc_vStart = vStart + 31;
997
				crtc_vEnd = crtc_vStart + 2;
998
			}
999
			else if (video_mode->yres > 600) {
1000
				hdtv_mode = HDTV_720p;
1001
			}
1002
			if (rinfo->video_encoder == ENCODER_CONEXANT)
1003
				encoder_ok = conexant_calc_hdtv_mode(hdtv_mode, pll_int, newmode.encoder_mode);
1004
			else if (rinfo->video_encoder == ENCODER_FOCUS)
1005
				encoder_ok = focus_calc_hdtv_mode(hdtv_mode, pll_int, newmode.encoder_mode);
1006
			else printk("Error - unknown encoder type detected\n");
1007
		}
1008
		else {
1009
			if (rinfo->video_encoder == ENCODER_CONEXANT)
1010
				encoder_ok = conexant_calc_vga_mode(rinfo->av_type, pll_int, newmode.encoder_mode);
1011
			else if (rinfo->video_encoder == ENCODER_FOCUS) {
1012
				//No vga functions as yet - so set up for 480p otherwise we dont boot at all. 
1013
				encoder_ok = focus_calc_hdtv_mode(HDTV_480p, pll_int, newmode.encoder_mode);
1014
			}
1015
			else printk("Error - unknown encoder type detected\n");
1016
		}
1017
		newmode.ext.vend = video_mode->yres - 1;
1018
		newmode.ext.vtotal = vTotal;
1019
		newmode.ext.vcrtc = video_mode->yres - 1;
1020
		newmode.ext.vsyncstart = vStart;
1021
		newmode.ext.vsyncend = vStart + 3;
1022
		newmode.ext.vvalidstart = 0;
1023
		newmode.ext.vvalidend = video_mode->yres - 1;
1024
		newmode.ext.hend = video_mode->xres - 1;
1025
		newmode.ext.htotal = hTotal;
1026
		newmode.ext.hcrtc = video_mode->xres - 1;
1027
		newmode.ext.hsyncstart = hStart;
1028
		newmode.ext.hsyncend = hStart + 32;
1029
		newmode.ext.hvalidstart = 0;
1030
		newmode.ext.hvalidend = video_mode->xres - 1;
1031
	}
1032
1033
	/* Normal composite */
1034
	else {
1035
		xbox_video_mode encoder_mode;
1036
		encoder_mode.xres = video_mode->xres;
1037
		encoder_mode.yres = video_mode->yres;
1038
		encoder_mode.tv_encoding = rinfo->tv_encoding;
1039
		encoder_mode.bpp = bpp;
1040
		encoder_mode.hoc = rinfo->hoc;
1041
		encoder_mode.voc = rinfo->voc;
1042
		encoder_mode.av_type = rinfo->av_type;
1043
		encoder_mode.tv_encoding = rinfo->tv_encoding;
1044
1045
		if (rinfo->video_encoder == ENCODER_CONEXANT) {
1046
			encoder_ok = conexant_calc_mode(&encoder_mode, &newmode);
1047
		}
1048
		else if (rinfo->video_encoder == ENCODER_FOCUS) {
1049
			encoder_ok = focus_calc_mode(&encoder_mode, &newmode);
1050
		}
1051
		else printk("Error - unknown encoder type detected\n");
1052
1053
		crtc_hDisplay = (newmode.ext.crtchdispend / 8) - 1;
1054
		crtc_hStart = (newmode.ext.htotal - 32) / 8;
1055
		crtc_hEnd = crtc_hStart + 1;
1056
		crtc_hTotal = (newmode.ext.htotal) / 8 - 1;
1057
		crtc_hBlankStart = crtc_hDisplay;
1058
		crtc_hBlankEnd = (newmode.ext.htotal) / 8 - 1;
1059
		
1060
		crtc_vDisplay = video_mode->yres - 1;
1061
		crtc_vStart = newmode.ext.crtcvstart;
1062
		crtc_vEnd = newmode.ext.crtcvstart + 3;
1063
		crtc_vTotal = newmode.ext.crtcvtotal;
1064
		crtc_vBlankStart = crtc_vDisplay;
1065
		crtc_vBlankEnd = crtc_vTotal + 1;
1066
	}
1067
1068
	if (encoder_ok) {
1069
		newmode.crtc[0x0] = Set8Bits (crtc_hTotal);
1070
		newmode.crtc[0x1] = Set8Bits (crtc_hDisplay);
1071
		newmode.crtc[0x2] = Set8Bits (crtc_hBlankStart);
1072
		newmode.crtc[0x3] = SetBitField (crtc_hBlankEnd, 4: 0, 4:0) | SetBit (7);
1073
		newmode.crtc[0x4] = Set8Bits (crtc_hStart);
1074
		newmode.crtc[0x5] = SetBitField (crtc_hBlankEnd, 5: 5, 7:7)
1075
			| SetBitField (crtc_hEnd, 4: 0, 4:0);
1076
		newmode.crtc[0x6] = SetBitField (crtc_vTotal, 7: 0, 7:0);
1077
		newmode.crtc[0x7] = SetBitField (crtc_vTotal, 8: 8, 0:0)
1078
			| SetBitField (crtc_vDisplay, 8: 8, 1:1)
1079
			| SetBitField (crtc_vStart, 8: 8, 2:2)
1080
			| SetBitField (crtc_vBlankStart, 8: 8, 3:3)
1081
			| SetBit (4)
1082
			| SetBitField (crtc_vTotal, 9: 9, 5:5)
1083
			| SetBitField (crtc_vDisplay, 9: 9, 6:6)
1084
			| SetBitField (crtc_vStart, 9: 9, 7:7);
1085
		newmode.crtc[0x9] = SetBitField (crtc_vBlankStart, 9: 9, 5:5)
1086
			| SetBit (6);
1087
		newmode.crtc[0x10] = Set8Bits (crtc_vStart);
1088
		newmode.crtc[0x11] = SetBitField (crtc_vEnd, 3: 0, 3:0)
1089
			| SetBit (5);
1090
		newmode.crtc[0x12] = Set8Bits (crtc_vDisplay);
1091
		newmode.crtc[0x13] = ((width / 8) * ((bpp + 1) / 8)) & 0xFF;
1092
		newmode.crtc[0x15] = Set8Bits (crtc_vBlankStart);
1093
		newmode.crtc[0x16] = Set8Bits (crtc_vBlankEnd);
1094
		newmode.ext.screen = SetBitField(crtc_hBlankEnd,6:6,4:4)
1095
			| SetBitField(crtc_vBlankStart,10:10,3:3)
1096
			| SetBitField(crtc_vStart,10:10,2:2)
1097
			| SetBitField(crtc_vDisplay,10:10,1:1)
1098
			| SetBitField(crtc_vTotal,10:10,0:0);
1099
		newmode.ext.horiz  = SetBitField(crtc_hTotal,8:8,0:0) 
1100
			| SetBitField(crtc_hDisplay,8:8,1:1)
1101
			| SetBitField(crtc_hBlankStart,8:8,2:2)
1102
			| SetBitField(crtc_hStart,8:8,3:3);
1103
		newmode.ext.extra  = SetBitField(crtc_vTotal,11:11,0:0)
1104
			| SetBitField(crtc_vDisplay,11:11,2:2)
1105
			| SetBitField(crtc_vStart,11:11,4:4)
1106
			| SetBitField(crtc_vBlankStart,11:11,6:6); 
1107
			
1108
		if ((video_mode->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
1109
			int tmp = (crtc_hTotal >> 1) & ~1;
1110
			newmode.ext.interlace = Set8Bits(tmp);
1111
			newmode.ext.horiz |= SetBitField(tmp, 8:8,4:4);
1112
		} else 
1113
			newmode.ext.interlace = 0xff; /* interlace off */
1114
1115
		rinfo->riva.CalcStateExt(&rinfo->riva, &newmode.ext, bpp, width,
1116
					hDisplaySize, height, dotClock);
1117
		rinfo->current_state = newmode;
1118
		riva_load_state(rinfo, &rinfo->current_state);
1119
		tv_load_mode(newmode.encoder_mode);
1120
		rinfo->riva.LockUnlock(&rinfo->riva, 0); /* important for HW cursor */
1121
		rivafb_download_cursor(rinfo);
1122
	}
1123
	else {
1124
		printk("Error: Unable to set encoder resolution %dx%d\n",video_mode->xres, video_mode->yres);
1125
	}
1126
}
1127
/**
1128
 * riva_board_list_add - maintains board list
1129
 * @board_list: root node of list of boards
1130
 * @new_node: new node to be added
1131
 *
1132
 * DESCRIPTION:
1133
 * Adds @new_node to the list referenced by @board_list.
1134
 *
1135
 * RETURNS:
1136
 * New root node
1137
 *
1138
 * CALLED FROM:
1139
 * rivafb_init_one()
1140
 */
1141
static struct rivafb_info *riva_board_list_add(struct rivafb_info *board_list,
1142
					       struct rivafb_info *new_node)
1143
{
1144
	struct rivafb_info *i_p = board_list;
1145
1146
	new_node->next = NULL;
1147
1148
	if (board_list == NULL)
1149
		return new_node;
1150
1151
	while (i_p->next != NULL)
1152
		i_p = i_p->next;
1153
	i_p->next = new_node;
1154
1155
	return board_list;
1156
}
1157
1158
/**
1159
 * riva_board_list_del - maintains board list
1160
 * @board_list: root node of list of boards
1161
 * @del_node: node to be removed
1162
 *
1163
 * DESCRIPTION:
1164
 * Removes @del_node from the list referenced by @board_list.
1165
 *
1166
 * RETURNS:
1167
 * New root node
1168
 *
1169
 * CALLED FROM:
1170
 * rivafb_remove_one()
1171
 */
1172
static struct rivafb_info *riva_board_list_del(struct rivafb_info *board_list,
1173
					       struct rivafb_info *del_node)
1174
{
1175
	struct rivafb_info *i_p = board_list;
1176
1177
	if (board_list == del_node)
1178
		return del_node->next;
1179
1180
	while (i_p->next != del_node)
1181
		i_p = i_p->next;
1182
	i_p->next = del_node->next;
1183
1184
	return board_list;
1185
}
1186
1187
/**
1188
 * rivafb_do_maximize -
1189
 * @rinfo: pointer to rivafb_info object containing info for current riva board
1190
 * @var:
1191
 * @v:
1192
 * @nom:
1193
 * @den:
1194
 *
1195
 * DESCRIPTION:
1196
 * .
1197
 *
1198
 * RETURNS:
1199
 * -EINVAL on failure, 0 on success
1200
 * 
1201
 *
1202
 * CALLED FROM:
1203
 * rivafb_set_var()
1204
 */
1205
static int rivafb_do_maximize(struct rivafb_info *rinfo,
1206
			      struct fb_var_screeninfo *var,
1207
			      struct fb_var_screeninfo *v,
1208
			      int nom, int den)
1209
{
1210
	static struct {
1211
		int xres, yres;
1212
	} modes[] = {
1213
		{1600, 1280},
1214
		{1280, 1024},
1215
		{1024, 768},
1216
		{800, 600},
1217
		{640, 480},
1218
		{-1, -1}
1219
	};
1220
	int i;
1221
1222
	/* use highest possible virtual resolution */
1223
	if (v->xres_virtual == -1 && v->yres_virtual == -1) {
1224
		printk(KERN_WARNING PFX
1225
		       "using maximum available virtual resolution\n");
1226
		for (i = 0; modes[i].xres != -1; i++) {
1227
			if (modes[i].xres * nom / den * modes[i].yres <
1228
			    rinfo->ram_amount / 2)
1229
				break;
1230
		}
1231
		if (modes[i].xres == -1) {
1232
			printk(KERN_ERR PFX
1233
			       "could not find a virtual resolution that fits into video memory!!\n");
1234
			DPRINTK("EXIT - EINVAL error\n");
1235
			return -EINVAL;
1236
		}
1237
		v->xres_virtual = modes[i].xres;
1238
		v->yres_virtual = modes[i].yres;
1239
1240
		printk(KERN_INFO PFX
1241
		       "virtual resolution set to maximum of %dx%d\n",
1242
		       v->xres_virtual, v->yres_virtual);
1243
	} else if (v->xres_virtual == -1) {
1244
		v->xres_virtual = (rinfo->ram_amount * den /
1245
			(nom * v->yres_virtual * 2)) & ~15;
1246
		printk(KERN_WARNING PFX
1247
		       "setting virtual X resolution to %d\n", v->xres_virtual);
1248
	} else if (v->yres_virtual == -1) {
1249
		v->xres_virtual = (v->xres_virtual + 15) & ~15;
1250
		v->yres_virtual = rinfo->ram_amount * den /
1251
			(nom * v->xres_virtual * 2);
1252
		printk(KERN_WARNING PFX
1253
		       "setting virtual Y resolution to %d\n", v->yres_virtual);
1254
	} else {
1255
		v->xres_virtual = (v->xres_virtual + 15) & ~15;
1256
		if (v->xres_virtual * nom / den * v->yres_virtual > rinfo->ram_amount) {
1257
			printk(KERN_ERR PFX
1258
			       "mode %dx%dx%d rejected...resolution too high to fit into video memory!\n",
1259
			       var->xres, var->yres, var->bits_per_pixel);
1260
			DPRINTK("EXIT - EINVAL error\n");
1261
			return -EINVAL;
1262
		}
1263
	}
1264
1265
	if (v->xres_virtual * nom / den >= 8192) {
1266
		printk(KERN_WARNING PFX
1267
		       "virtual X resolution (%d) is too high, lowering to %d\n",
1268
		       v->xres_virtual, 8192 * den / nom - 16);
1269
		v->xres_virtual = 8192 * den / nom - 16;
1270
	}
1271
	
1272
	if (v->xres_virtual < v->xres) {
1273
		printk(KERN_ERR PFX
1274
		       "virtual X resolution (%d) is smaller than real\n", v->xres_virtual);
1275
		return -EINVAL;
1276
	}
1277
1278
	if (v->yres_virtual < v->yres) {
1279
		printk(KERN_ERR PFX
1280
		       "virtual Y resolution (%d) is smaller than real\n", v->yres_virtual);
1281
		return -EINVAL;
1282
	}
1283
	
1284
	return 0;
1285
}
1286
1287
1288
1289
/* ------------------------------------------------------------------------- *
1290
 *
1291
 * internal fb_ops helper functions
1292
 *
1293
 * ------------------------------------------------------------------------- */
1294
1295
/**
1296
 * riva_get_cmap_len - query current color map length
1297
 * @var: standard kernel fb changeable data
1298
 *
1299
 * DESCRIPTION:
1300
 * Get current color map length.
1301
 *
1302
 * RETURNS:
1303
 * Length of color map
1304
 *
1305
 * CALLED FROM:
1306
 * riva_getcolreg()
1307
 * riva_setcolreg()
1308
 * rivafb_get_cmap()
1309
 * rivafb_set_cmap()
1310
 */
1311
static int riva_get_cmap_len(const struct fb_var_screeninfo *var)
1312
{
1313
	int rc = 16;		/* reasonable default */
1314
1315
	assert(var != NULL);
1316
1317
	switch (var->bits_per_pixel) {
1318
#ifdef FBCON_HAS_CFB8
1319
	case 8:
1320
		rc = 256;	/* pseudocolor... 256 entries HW palette */
1321
		break;
1322
#endif
1323
#ifdef FBCON_HAS_CFB16
1324
	case 15:
1325
		rc = 15;	/* fix for 15 bpp depths on Riva 128 based cards */
1326
		break;
1327
	case 16:
1328
		rc = 16;	/* directcolor... 16 entries SW palette */
1329
		break;		/* Mystique: truecolor, 16 entries SW palette, HW palette hardwired into 1:1 mapping */
1330
#endif
1331
#ifdef FBCON_HAS_CFB32
1332
	case 32:
1333
		rc = 16;	/* directcolor... 16 entries SW palette */
1334
		break;		/* Mystique: truecolor, 16 entries SW palette, HW palette hardwired into 1:1 mapping */
1335
#endif
1336
	default:
1337
		/* should not occur */
1338
		break;
1339
	}
1340
1341
	return rc;
1342
}
1343
1344
/**
1345
 * riva_getcolreg
1346
 * @regno: register index
1347
 * @red: red component
1348
 * @green: green component
1349
 * @blue: blue component
1350
 * @transp: transparency
1351
 * @info: pointer to rivafb_info object containing info for current riva board
1352
 *
1353
 * DESCRIPTION:
1354
 * Read a single color register and split it into colors/transparent.
1355
 * The return values must have a 16 bit magnitude.
1356
 *
1357
 * RETURNS:
1358
 * Return != 0 for invalid regno.
1359
 *
1360
 * CALLED FROM:
1361
 * rivafb_get_cmap()
1362
 * rivafb_switch()
1363
 * fbcmap.c:fb_get_cmap()
1364
 *	fbgen.c:fbgen_get_cmap()
1365
 *	fbgen.c:fbgen_switch()
1366
 */
1367
static int riva_getcolreg(unsigned regno, unsigned *red, unsigned *green,
1368
			  unsigned *blue, unsigned *transp,
1369
			  struct fb_info *info)
1370
{
1371
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1372
1373
	if (regno >= riva_get_cmap_len(&rivainfo->currcon_display->var))
1374
		return 1;
1375
1376
	*red = rivainfo->palette[regno].red;
1377
	*green = rivainfo->palette[regno].green;
1378
	*blue = rivainfo->palette[regno].blue;
1379
	*transp = 0;
1380
1381
	return 0;
1382
}
1383
1384
/**
1385
 * riva_setcolreg
1386
 * @regno: register index
1387
 * @red: red component
1388
 * @green: green component
1389
 * @blue: blue component
1390
 * @transp: transparency
1391
 * @info: pointer to rivafb_info object containing info for current riva board
1392
 *
1393
 * DESCRIPTION:
1394
 * Set a single color register. The values supplied have a 16 bit
1395
 * magnitude.
1396
 *
1397
 * RETURNS:
1398
 * Return != 0 for invalid regno.
1399
 *
1400
 * CALLED FROM:
1401
 * rivafb_set_cmap()
1402
 * fbcmap.c:fb_set_cmap()
1403
 *	fbgen.c:fbgen_get_cmap()
1404
 *	fbgen.c:fbgen_install_cmap()
1405
 *		fbgen.c:fbgen_set_var()
1406
 *		fbgen.c:fbgen_switch()
1407
 *		fbgen.c:fbgen_blank()
1408
 *	fbgen.c:fbgen_blank()
1409
 */
1410
static int riva_setcolreg(unsigned regno, unsigned red, unsigned green,
1411
			  unsigned blue, unsigned transp,
1412
			  struct fb_info *info)
1413
{
1414
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1415
	RIVA_HW_INST *chip = &rivainfo->riva;
1416
	struct display *p;
1417
1418
	DPRINTK("ENTER\n");
1419
1420
	assert(rivainfo != NULL);
1421
	assert(rivainfo->currcon_display != NULL);
1422
1423
	p = rivainfo->currcon_display;
1424
1425
	if (regno >= riva_get_cmap_len(&p->var))
1426
		return -EINVAL;
1427
1428
	rivainfo->palette[regno].red = red;
1429
	rivainfo->palette[regno].green = green;
1430
	rivainfo->palette[regno].blue = blue;
1431
1432
	if (p->var.grayscale) {
1433
		/* gray = 0.30*R + 0.59*G + 0.11*B */
1434
		red = green = blue =
1435
		    (red * 77 + green * 151 + blue * 28) >> 8;
1436
	}
1437
1438
	switch (p->var.bits_per_pixel) {
1439
#ifdef FBCON_HAS_CFB8
1440
	case 8:
1441
		/* "transparent" stuff is completely ignored. */
1442
		riva_wclut(chip, regno, red >> 8, green >> 8, blue >> 8);
1443
		break;
1444
#endif /* FBCON_HAS_CFB8 */
1445
#ifdef FBCON_HAS_CFB16
1446
	case 16:
1447
		assert(regno < 16);
1448
		if (p->var.green.length == 5) {
1449
			/* 0rrrrrgg gggbbbbb */
1450
			rivainfo->con_cmap.cfb16[regno] =
1451
			    ((red & 0xf800) >> 1) |
1452
			    ((green & 0xf800) >> 6) | ((blue & 0xf800) >> 11);
1453
		} else {
1454
			/* rrrrrggg gggbbbbb */
1455
			rivainfo->con_cmap.cfb16[regno] =
1456
			    ((red & 0xf800) >> 0) |
1457
			    ((green & 0xf800) >> 5) | ((blue & 0xf800) >> 11);
1458
		}
1459
		break;
1460
#endif /* FBCON_HAS_CFB16 */
1461
#ifdef FBCON_HAS_CFB32
1462
	case 32:
1463
		assert(regno < 16);
1464
		rivainfo->con_cmap.cfb32[regno] =
1465
		    ((red & 0xff00) << 8) |
1466
		    ((green & 0xff00)) | ((blue & 0xff00) >> 8);
1467
		break;
1468
#endif /* FBCON_HAS_CFB32 */
1469
	default:
1470
		/* do nothing */
1471
		break;
1472
	}
1473
1474
	return 0;
1475
}
1476
1477
1478
1479
/* ------------------------------------------------------------------------- *
1480
 *
1481
 * framebuffer operations
1482
 *
1483
 * ------------------------------------------------------------------------- */
1484
1485
static int rivafb_get_fix(struct fb_fix_screeninfo *fix, int con,
1486
			  struct fb_info *info)
1487
{
1488
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1489
	struct display *p;
1490
1491
	DPRINTK("ENTER\n");
1492
1493
	assert(fix != NULL);
1494
	assert(info != NULL);
1495
	assert(rivainfo->drvr_name && rivainfo->drvr_name[0]);
1496
	assert(rivainfo->fb_base_phys > 0);
1497
	assert(rivainfo->ram_amount > 0);
1498
1499
	p = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1500
1501
	memset(fix, 0, sizeof(struct fb_fix_screeninfo));
1502
	sprintf(fix->id, "nVidia %s", rivainfo->drvr_name);
1503
1504
	fix->type = p->type;
1505
	fix->type_aux = p->type_aux;
1506
	fix->visual = p->visual;
1507
1508
	fix->xpanstep = 1;
1509
	fix->ypanstep = 1;
1510
	fix->ywrapstep = 0;	/* FIXME: no ywrap for now */
1511
1512
	fix->line_length = p->line_length;
1513
1514
	fix->mmio_start = rivainfo->ctrl_base_phys;
1515
	fix->mmio_len = rivainfo->base0_region_size;
1516
	fix->smem_start = rivainfo->fb_base_phys;
1517
	fix->smem_len = rivainfo->ram_amount;
1518
1519
	switch (rivainfo->riva.Architecture) {
1520
	case NV_ARCH_03:
1521
		fix->accel = FB_ACCEL_NV3;
1522
		break;
1523
	case NV_ARCH_04:	/* riva_hw.c now doesn't distinguish between TNT & TNT2 */
1524
		fix->accel = FB_ACCEL_NV4;
1525
		break;
1526
	case NV_ARCH_10:	/* FIXME: ID for GeForce */
1527
	case NV_ARCH_20:
1528
		fix->accel = FB_ACCEL_NV4;
1529
		break;
1530
1531
	}
1532
1533
	DPRINTK("EXIT, returning 0\n");
1534
1535
	return 0;
1536
}
1537
1538
static int rivafb_get_var(struct fb_var_screeninfo *var, int con,
1539
			  struct fb_info *info)
1540
{
1541
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1542
1543
	DPRINTK("ENTER\n");
1544
1545
	assert(info != NULL);
1546
	assert(var != NULL);
1547
1548
	*var = (con < 0) ? rivainfo->disp.var : fb_display[con].var;
1549
1550
	DPRINTK("EXIT, returning 0\n");
1551
1552
	return 0;
1553
}
1554
1555
static int rivafb_set_var(struct fb_var_screeninfo *var, int con,
1556
			  struct fb_info *info)
1557
{
1558
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1559
	struct display *dsp;
1560
	struct fb_var_screeninfo v;
1561
	int nom, den;		/* translating from pixels->bytes */
1562
	int accel;
1563
	unsigned chgvar = 0;
1564
1565
	DPRINTK("ENTER\n");
1566
1567
	assert(info != NULL);
1568
	assert(var != NULL);
1569
1570
	DPRINTK("Requested: %dx%dx%d\n", var->xres, var->yres,
1571
		var->bits_per_pixel);
1572
	DPRINTK("  virtual: %dx%d\n", var->xres_virtual,
1573
		var->yres_virtual);
1574
	DPRINTK("   offset: (%d,%d)\n", var->xoffset, var->yoffset);
1575
	DPRINTK("grayscale: %d\n", var->grayscale);
1576
1577
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1578
	assert(dsp != NULL);
1579
1580
	/* if var has changed, we should call changevar() later */
1581
	if (con >= 0) {
1582
		chgvar = ((dsp->var.xres != var->xres) ||
1583
			  (dsp->var.yres != var->yres) ||
1584
			  (dsp->var.xres_virtual != var->xres_virtual) ||
1585
			  (dsp->var.yres_virtual != var->yres_virtual) ||
1586
			  (dsp->var.accel_flags != var->accel_flags) ||
1587
			  (dsp->var.bits_per_pixel != var->bits_per_pixel)
1588
			  || memcmp(&dsp->var.red, &var->red,
1589
				    sizeof(var->red))
1590
			  || memcmp(&dsp->var.green, &var->green,
1591
				    sizeof(var->green))
1592
			  || memcmp(&dsp->var.blue, &var->blue,
1593
				    sizeof(var->blue)));
1594
	}
1595
1596
	memcpy(&v, var, sizeof(v));
1597
1598
	accel = v.accel_flags & FB_ACCELF_TEXT;
1599
1600
	switch (v.bits_per_pixel) {
1601
#ifdef FBCON_HAS_CFB8
1602
	case 1 ... 8:
1603
		v.bits_per_pixel = 8;
1604
		nom = 1;
1605
		den = 1;
1606
		v.red.offset = 0;
1607
		v.red.length = 8;
1608
		v.green.offset = 0;
1609
		v.green.length = 8;
1610
		v.blue.offset = 0;
1611
		v.blue.length = 8;
1612
		break;
1613
#endif
1614
#ifdef FBCON_HAS_CFB16
1615
	case 9 ... 15:
1616
		v.green.length = 5;
1617
		/* fall through */
1618
	case 16:
1619
		v.bits_per_pixel = 16;
1620
		nom = 2;
1621
		den = 1;
1622
		if (v.green.length == 5) {
1623
			/* 0rrrrrgg gggbbbbb */
1624
			v.red.offset = 10;
1625
			v.green.offset = 5;
1626
			v.blue.offset = 0;
1627
			v.red.length = 5;
1628
			v.green.length = 5;
1629
			v.blue.length = 5;
1630
		} else {
1631
			/* rrrrrggg gggbbbbb */
1632
			v.red.offset = 11;
1633
			v.green.offset = 5;
1634
			v.blue.offset = 0;
1635
			v.red.length = 5;
1636
			v.green.length = 6;
1637
			v.blue.length = 5;
1638
		}
1639
		break;
1640
#endif
1641
#ifdef FBCON_HAS_CFB32
1642
	case 17 ... 32:
1643
		v.bits_per_pixel = 32;
1644
		nom = 4;
1645
		den = 1;
1646
		v.red.offset = 16;
1647
		v.green.offset = 8;
1648
		v.blue.offset = 0;
1649
		v.red.length = 8;
1650
		v.green.length = 8;
1651
		v.blue.length = 8;
1652
		break;
1653
#endif
1654
	default:
1655
		printk(KERN_ERR PFX
1656
		       "mode %dx%dx%d rejected...color depth not supported.\n",
1657
		       var->xres, var->yres, var->bits_per_pixel);
1658
		DPRINTK("EXIT, returning -EINVAL\n");
1659
		return -EINVAL;
1660
	}
1661
1662
	if (rivafb_do_maximize(rivainfo, var, &v, nom, den) < 0)
1663
		return -EINVAL;
1664
1665
	if (v.xoffset < 0)
1666
		v.xoffset = 0;
1667
	if (v.yoffset < 0)
1668
		v.yoffset = 0;
1669
1670
	/* truncate xoffset and yoffset to maximum if too high */
1671
	if (v.xoffset > v.xres_virtual - v.xres)
1672
		v.xoffset = v.xres_virtual - v.xres - 1;
1673
1674
	if (v.yoffset > v.yres_virtual - v.yres)
1675
		v.yoffset = v.yres_virtual - v.yres - 1;
1676
1677
	v.red.msb_right =
1678
	    v.green.msb_right =
1679
	    v.blue.msb_right =
1680
	    v.transp.offset = v.transp.length = v.transp.msb_right = 0;
1681
1682
	switch (v.activate & FB_ACTIVATE_MASK) {
1683
	case FB_ACTIVATE_TEST:
1684
		DPRINTK("EXIT - FB_ACTIVATE_TEST\n");
1685
		return 0;
1686
	case FB_ACTIVATE_NXTOPEN:	/* ?? */
1687
	case FB_ACTIVATE_NOW:
1688
		break;		/* continue */
1689
	default:
1690
		DPRINTK("EXIT - unknown activation type\n");
1691
		return -EINVAL;	/* unknown */
1692
	}
1693
1694
	memcpy(&dsp->var, &v, sizeof(v));
1695
	if (chgvar) {
1696
		riva_set_dispsw(rivainfo, dsp);
1697
1698
		if (accel) {
1699
			if (nomove)
1700
				dsp->scrollmode = SCROLL_YNOMOVE;
1701
			else
1702
				dsp->scrollmode = 0;
1703
		} else
1704
			dsp->scrollmode = SCROLL_YREDRAW;
1705
1706
		if (info && info->changevar)
1707
			info->changevar(con);
1708
	}
1709
1710
	rivafb_create_cursor(rivainfo, fontwidth(dsp), fontheight(dsp));
1711
	xbox_load_video_mode(rivainfo, &v);
1712
	if (accel) riva_setup_accel(rivainfo);
1713
1714
	DPRINTK("EXIT, returning 0\n");
1715
	return 0;
1716
}
1717
1718
static int rivafb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
1719
			   struct fb_info *info)
1720
{
1721
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1722
	struct display *dsp;
1723
1724
	DPRINTK("ENTER\n");
1725
1726
	assert(rivainfo != NULL);
1727
	assert(cmap != NULL);
1728
1729
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1730
1731
	if (con == rivainfo->currcon) {	/* current console? */
1732
		int rc = fb_get_cmap(cmap, kspc, riva_getcolreg, info);
1733
		DPRINTK("EXIT - returning %d\n", rc);
1734
		return rc;
1735
	} else if (dsp->cmap.len)	/* non default colormap? */
1736
		fb_copy_cmap(&dsp->cmap, cmap, kspc ? 0 : 2);
1737
	else
1738
		fb_copy_cmap(fb_default_cmap
1739
			     (riva_get_cmap_len(&dsp->var)), cmap,
1740
			     kspc ? 0 : 2);
1741
1742
	DPRINTK("EXIT, returning 0\n");
1743
1744
	return 0;
1745
}
1746
1747
static int rivafb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
1748
			   struct fb_info *info)
1749
{
1750
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1751
	struct display *dsp;
1752
	unsigned int cmap_len;
1753
1754
	DPRINTK("ENTER\n");
1755
	
1756
	assert(rivainfo != NULL);
1757
	assert(cmap != NULL);
1758
1759
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1760
1761
	cmap_len = riva_get_cmap_len(&dsp->var);
1762
	if (dsp->cmap.len != cmap_len) {
1763
		int err = fb_alloc_cmap(&dsp->cmap, cmap_len, 0);
1764
		if (err) {
1765
			DPRINTK("EXIT - returning %d\n", err);
1766
			return err;
1767
		}
1768
	}
1769
	if (con == rivainfo->currcon) {	/* current console? */
1770
		int rc = fb_set_cmap(cmap, kspc, riva_setcolreg, info);
1771
		DPRINTK("EXIT - returning %d\n", rc);
1772
		return rc;
1773
	} else
1774
		fb_copy_cmap(cmap, &dsp->cmap, kspc ? 0 : 1);
1775
1776
	DPRINTK("EXIT, returning 0\n");
1777
1778
	return 0;
1779
}
1780
1781
/**
1782
 * rivafb_pan_display
1783
 * @var: standard kernel fb changeable data
1784
 * @con: TODO
1785
 * @info: pointer to rivafb_info object containing info for current riva board
1786
 *
1787
 * DESCRIPTION:
1788
 * Pan (or wrap, depending on the `vmode' field) the display using the
1789
 * `xoffset' and `yoffset' fields of the `var' structure.
1790
 * If the values don't fit, return -EINVAL.
1791
 *
1792
 * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
1793
 */
1794
static int rivafb_pan_display(struct fb_var_screeninfo *var, int con,
1795
			      struct fb_info *info)
1796
{
1797
	unsigned int base;
1798
	struct display *dsp;
1799
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1800
1801
	DPRINTK("ENTER\n");
1802
1803
	assert(rivainfo != NULL);
1804
1805
	if (var->xoffset > (var->xres_virtual - var->xres))
1806
		return -EINVAL;
1807
	if (var->yoffset > (var->yres_virtual - var->yres))
1808
		return -EINVAL;
1809
1810
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1811
1812
	if (var->vmode & FB_VMODE_YWRAP) {
1813
		if (var->yoffset < 0
1814
		    || var->yoffset >= dsp->var.yres_virtual
1815
		    || var->xoffset) return -EINVAL;
1816
	} else {
1817
		if (var->xoffset + dsp->var.xres > dsp->var.xres_virtual ||
1818
		    var->yoffset + dsp->var.yres > dsp->var.yres_virtual)
1819
			return -EINVAL;
1820
	}
1821
1822
	base = var->yoffset * dsp->line_length + var->xoffset;
1823
	base += rivainfo->riva_fb_start;
1824
1825
	if (con == rivainfo->currcon) {
1826
		rivainfo->riva.SetStartAddress(&rivainfo->riva, base);
1827
	}
1828
1829
	dsp->var.xoffset = var->xoffset;
1830
	dsp->var.yoffset = var->yoffset;
1831
1832
	if (var->vmode & FB_VMODE_YWRAP)
1833
		dsp->var.vmode |= FB_VMODE_YWRAP;
1834
	else
1835
		dsp->var.vmode &= ~FB_VMODE_YWRAP;
1836
1837
	DPRINTK("EXIT, returning 0\n");
1838
1839
	return 0;
1840
}
1841
1842
static int rivafb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
1843
			unsigned long arg, int con, struct fb_info *info)
1844
{
1845
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1846
	struct fb_var_screeninfo *var = (con < 0) ? &rivainfo->disp.var : &fb_display[con].var;
1847
1848
	xbox_overscan overscan;
1849
	xboxfb_config config;
1850
	xbox_tv_encoding encoding;
1851
	int ret = 0;
1852
1853
	assert(rivainfo != NULL);
1854
1855
	switch (cmd) {
1856
	case FBIO_XBOX_SET_OVERSCAN:
1857
		if(!copy_from_user(&overscan, (xbox_overscan*)arg, sizeof(overscan))) {
1858
			rivainfo->hoc = overscan.hoc;
1859
			rivainfo->voc = overscan.voc;
1860
			xbox_load_video_mode (rivainfo, var);
1861
			if (var->accel_flags & FB_ACCELF_TEXT) {
1862
				riva_setup_accel(rivainfo);
1863
			}
1864
1865
		}
1866
		else {
1867
			ret = -EFAULT;
1868
		}
1869
	break;
1870
	case FBIO_XBOX_GET_OVERSCAN:
1871
		overscan.hoc = rivainfo->hoc;
1872
		overscan.voc = rivainfo->voc;
1873
		if (copy_to_user((xbox_overscan*)arg, &overscan, sizeof(overscan))) {
1874
			ret = -EFAULT;
1875
		}
1876
	break;
1877
	case FBIO_XBOX_GET_CONFIG:
1878
		config.av_type = rivainfo->av_type;
1879
		config.encoder_type = rivainfo->video_encoder;
1880
		if (copy_to_user((xboxfb_config*)arg, &config, sizeof(config))) {
1881
			ret = -EFAULT;
1882
		}
1883
	break;
1884
	case FBIO_XBOX_GET_TV_ENCODING:
1885
		encoding = rivainfo->tv_encoding;
1886
		if (copy_to_user((xbox_tv_encoding*)arg, &encoding, sizeof(encoding))) {
1887
			ret = -EFAULT;
1888
		}
1889
	break;
1890
	case FBIO_XBOX_SET_TV_ENCODING:
1891
		if(!copy_from_user(&encoding, (xbox_tv_encoding*)arg, sizeof(encoding))) {
1892
			rivainfo->tv_encoding = encoding;
1893
			xbox_load_video_mode (rivainfo, var);
1894
			if (var->accel_flags & FB_ACCELF_TEXT) {
1895
				riva_setup_accel(rivainfo);
1896
			}
1897
		}
1898
		else {
1899
			ret = -EFAULT;
1900
		}
1901
	break;
1902
	default:
1903
		ret = -EINVAL;
1904
	}
1905
	return ret;
1906
}
1907
1908
static int rivafb_rasterimg(struct fb_info *info, int start)
1909
{
1910
	struct rivafb_info *rinfo = (struct rivafb_info *)info;
1911
1912
	wait_for_idle(rinfo);
1913
1914
	return 0;
1915
}
1916
1917
static int rivafb_switch(int con, struct fb_info *info)
1918
{
1919
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1920
	struct fb_cmap *cmap;
1921
	struct display *dsp;
1922
1923
	DPRINTK("ENTER\n");
1924
1925
	assert(rivainfo != NULL);
1926
1927
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1928
1929
	if (rivainfo->currcon >= 0) {
1930
		/* Do we have to save the colormap? */
1931
		cmap = &(rivainfo->currcon_display->cmap);
1932
		DPRINTK("switch1: con = %d, cmap.len = %d\n",
1933
			 rivainfo->currcon, cmap->len);
1934
1935
		if (cmap->len) {
1936
			DPRINTK("switch1a: %p %p %p %p\n", cmap->red,
1937
				 cmap->green, cmap->blue, cmap->transp);
1938
			fb_get_cmap(cmap, 1, riva_getcolreg, info);
1939
		}
1940
	}
1941
	rivainfo->currcon = con;
1942
	rivainfo->currcon_display = dsp;
1943
1944
	rivafb_set_var(&dsp->var, con, info);
1945
	riva_set_dispsw(rivainfo, dsp);
1946
1947
	DPRINTK("EXIT, returning 0\n");
1948
	return 0;
1949
}
1950
1951
static int rivafb_updatevar(int con, struct fb_info *info)
1952
{
1953
	int rc;
1954
1955
	DPRINTK("ENTER\n");
1956
1957
	rc = (con < 0) ? -EINVAL : rivafb_pan_display(&fb_display[con].var,
1958
						      con, info);
1959
	DPRINTK("EXIT, returning %d\n", rc);
1960
	return rc;
1961
}
1962
1963
static void rivafb_blank(int blank, struct fb_info *info)
1964
{
1965
	unsigned char tmp, vesa;
1966
	struct rivafb_info *rinfo = (struct rivafb_info *)info;
1967
1968
	DPRINTK("ENTER\n");
1969
1970
	assert(rinfo != NULL);
1971
1972
	tmp = SEQin(rinfo, 0x01) & ~0x20;	/* screen on/off */
1973
	vesa = CRTCin(rinfo, 0x1a) & ~0xc0;	/* sync on/off */
1974
1975
	if (blank) {
1976
		tmp |= 0x20;
1977
		switch (blank - 1) {
1978
		case VESA_NO_BLANKING:
1979
			break;
1980
		case VESA_VSYNC_SUSPEND:
1981
			vesa |= 0x80;
1982
			break;
1983
		case VESA_HSYNC_SUSPEND:
1984
			vesa |= 0x40;
1985
			break;
1986
		case VESA_POWERDOWN:
1987
			vesa |= 0xc0;
1988
			break;
1989
		}
1990
	}
1991
1992
	SEQout(rinfo, 0x01, tmp);
1993
	CRTCout(rinfo, 0x1a, vesa);
1994
1995
	DPRINTK("EXIT\n");
1996
}
1997
1998
1999
2000
/* ------------------------------------------------------------------------- *
2001
 *
2002
 * initialization helper functions
2003
 *
2004
 * ------------------------------------------------------------------------- */
2005
2006
/* kernel interface */
2007
static struct fb_ops riva_fb_ops = {
2008
	.owner		= THIS_MODULE,
2009
	.fb_get_fix	= rivafb_get_fix,
2010
	.fb_get_var	= rivafb_get_var,
2011
	.fb_set_var	= rivafb_set_var,
2012
	.fb_get_cmap	= rivafb_get_cmap,
2013
	.fb_set_cmap	= rivafb_set_cmap,
2014
	.fb_pan_display	= rivafb_pan_display,
2015
	.fb_ioctl	= rivafb_ioctl,
2016
	.fb_rasterimg	= rivafb_rasterimg,
2017
};
2018
2019
static int __devinit riva_init_disp_var(struct rivafb_info *rinfo)
2020
{
2021
#ifndef MODULE
2022
	if (mode_option)
2023
	{
2024
		if (!strncmp(mode_option, "640x480", 7)) {
2025
			rinfo->disp.var = xboxfb_mode_640x480;
2026
		}
2027
		else if (!strncmp(mode_option, "800x600", 7)) {
2028
			rinfo->disp.var = xboxfb_mode_800x600;
2029
		}
2030
		else if (!strncmp(mode_option, "480p", 4)) {
2031
			rinfo->disp.var = xboxfb_mode_480p;
2032
		}
2033
		else if (!strncmp(mode_option, "720p", 4)) {
2034
			rinfo->disp.var = xboxfb_mode_720p;
2035
		}
2036
		else if ((rinfo->av_type == AV_VGA) || (rinfo->av_type == AV_VGA_SOG))
2037
		{
2038
			fb_find_mode(&rinfo->disp.var, &rinfo->info, mode_option,
2039
				NULL, 0, NULL, 8);
2040
		}
2041
	}
2042
#endif
2043
	return 0;
2044
}
2045
2046
static int __devinit riva_init_disp(struct rivafb_info *rinfo)
2047
{
2048
	struct fb_info *info;
2049
	struct display *disp;
2050
2051
	DPRINTK("ENTER\n");
2052
2053
	assert(rinfo != NULL);
2054
2055
	info = &rinfo->info;
2056
	disp = &rinfo->disp;
2057
2058
	disp->var = xboxfb_mode_640x480;
2059
2060
	if (noaccel)
2061
		disp->var.accel_flags &= ~FB_ACCELF_TEXT;
2062
	else
2063
		disp->var.accel_flags |= FB_ACCELF_TEXT;
2064
2065
	info->disp = disp;
2066
2067
	/* FIXME: assure that disp->cmap is completely filled out */
2068
2069
	rinfo->currcon_display = disp;
2070
2071
	if ((riva_init_disp_var(rinfo)) < 0) {
2072
		DPRINTK("EXIT, returning -1\n");
2073
		return -1;
2074
	}
2075
2076
	riva_set_dispsw(rinfo, disp);
2077
2078
	DPRINTK("EXIT, returning 0\n");
2079
	return 0;
2080
2081
}
2082
2083
static int __devinit riva_set_fbinfo(struct rivafb_info *rinfo)
2084
{
2085
	struct fb_info *info;
2086
2087
	assert(rinfo != NULL);
2088
2089
	info = &rinfo->info;
2090
2091
	strcpy(info->modename, rinfo->drvr_name);
2092
	info->node = -1;
2093
	info->flags = FBINFO_FLAG_DEFAULT;
2094
	info->fbops = &riva_fb_ops;
2095
2096
	/* FIXME: set monspecs to what??? */
2097
2098
	info->display_fg = NULL;
2099
	strncpy(info->fontname, fontname, sizeof(info->fontname));
2100
	info->fontname[sizeof(info->fontname) - 1] = 0;
2101
2102
	info->changevar = NULL;
2103
	info->switch_con = rivafb_switch;
2104
	info->updatevar = rivafb_updatevar;
2105
	info->blank = rivafb_blank;
2106
2107
	if (riva_init_disp(rinfo) < 0)	/* must be done last */
2108
		return -1;
2109
2110
	return 0;
2111
}
2112
2113
2114
2115
/* ------------------------------------------------------------------------- *
2116
 *
2117
 * PCI bus
2118
 *
2119
 * ------------------------------------------------------------------------- */
2120
2121
static int __devinit rivafb_init_one(struct pci_dev *pd,
2122
				     const struct pci_device_id *ent)
2123
{
2124
	struct rivafb_info *rinfo;
2125
	struct riva_chip_info *rci = &riva_chip_info[ent->driver_data];
2126
2127
	assert(pd != NULL);
2128
	assert(rci != NULL);
2129
2130
	rinfo = kmalloc(sizeof(struct rivafb_info), GFP_KERNEL);
2131
	if (!rinfo)
2132
		goto err_out;
2133
2134
	memset(rinfo, 0, sizeof(struct rivafb_info));
2135
2136
	rinfo->drvr_name = rci->name;
2137
	rinfo->riva.Architecture = rci->arch_rev;
2138
2139
	rinfo->pd = pd;
2140
	rinfo->base0_region_size = pci_resource_len(pd, 0);
2141
	rinfo->base1_region_size = pci_resource_len(pd, 1);
2142
2143
	rinfo->ctrl_base_phys = pci_resource_start(rinfo->pd, 0);
2144
	rinfo->fb_base_phys = pci_resource_start(rinfo->pd, 1);
2145
2146
	if (xbox_memory_size() == 64*1024*1024) printk(KERN_INFO PFX "Detected 64MB of system RAM\n");
2147
	else printk(KERN_INFO PFX "Detected 128MB of system RAM\n");
2148
2149
	if (!fb_size) {
2150
		fb_size = available_framebuffer_memory();
2151
		fb_start = xbox_memory_size() - fb_size;
2152
		printk(KERN_INFO PFX "Using maximum available framebuffer %dM\n", (int)(fb_size/(1024*1024)));
2153
	}
2154
	rinfo->riva_fb_start = fb_start;
2155
	rinfo->fb_base_phys += fb_start;
2156
	tv_init();
2157
	if (tv_encoding == TV_ENC_INVALID) {
2158
		tv_encoding = get_tv_encoding();
2159
		printk(KERN_INFO PFX "Setting TV mode from EEPROM (%s)\n", tvEncodingNames[tv_encoding]);
2160
	}
2161
	rinfo->tv_encoding = tv_encoding;
2162
	rinfo->video_encoder = tv_get_video_encoder();
2163
	switch(rinfo->video_encoder) {
2164
		case ENCODER_CONEXANT:
2165
			printk(KERN_INFO PFX "detected conexant encoder\n");
2166
			break;
2167
		case ENCODER_FOCUS:
2168
			printk(KERN_INFO PFX "detected focus encoder\n");
2169
			break;
2170
	}
2171
2172
2173
	if (av_type == AV_INVALID) {
2174
		av_type = detect_av_type();
2175
		printk(KERN_INFO PFX "Setting cable type from AVIP ID: %s\n", avTypeNames[av_type]);
2176
	}
2177
	rinfo->av_type = av_type;
2178
	if ((hoc < 0) || (hoc > 20)) {
2179
		hoc = 10;
2180
	}
2181
	rinfo->hoc = hoc / 100.0;
2182
	if ((voc < 0) || (voc > 20)) {
2183
		voc = 10;
2184
	}
2185
	rinfo->voc = voc / 100.0;
2186
	if (!request_mem_region(rinfo->ctrl_base_phys,
2187
				rinfo->base0_region_size, "rivafb")) {
2188
		printk(KERN_ERR PFX "cannot reserve MMIO region\n");
2189
		goto err_out_kfree;
2190
	}
2191
2192
	rinfo->ctrl_base = ioremap(rinfo->ctrl_base_phys,
2193
				   rinfo->base0_region_size);
2194
	if (!rinfo->ctrl_base) {
2195
		printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
2196
		goto err_out_free_base1;
2197
	}
2198
2199
	rinfo->riva.EnableIRQ = 0;
2200
	rinfo->riva.PRAMDAC = (unsigned *)(rinfo->ctrl_base + 0x00680000);
2201
	rinfo->riva.PFB = (unsigned *)(rinfo->ctrl_base + 0x00100000);
2202
	rinfo->riva.PFIFO = (unsigned *)(rinfo->ctrl_base + 0x00002000);
2203
	rinfo->riva.PGRAPH = (unsigned *)(rinfo->ctrl_base + 0x00400000);
2204
	rinfo->riva.PEXTDEV = (unsigned *)(rinfo->ctrl_base + 0x00101000);
2205
	rinfo->riva.PTIMER = (unsigned *)(rinfo->ctrl_base + 0x00009000);
2206
	rinfo->riva.PMC = (unsigned *)(rinfo->ctrl_base + 0x00000000);
2207
	rinfo->riva.FIFO = (unsigned *)(rinfo->ctrl_base + 0x00800000);
2208
2209
	rinfo->riva.PCIO = (U008 *)(rinfo->ctrl_base + 0x00601000);
2210
	rinfo->riva.PDIO = (U008 *)(rinfo->ctrl_base + 0x00681000);
2211
	rinfo->riva.PVIO = (U008 *)(rinfo->ctrl_base + 0x000C0000);
2212
2213
	rinfo->riva.IO = (MISCin(rinfo) & 0x01) ? 0x3D0 : 0x3B0;
2214
2215
	if (rinfo->riva.Architecture == NV_ARCH_03) {
2216
		/*
2217
		 * We have to map the full BASE_1 aperture for Riva128's
2218
		 * because they use the PRAMIN set in "framebuffer" space
2219
		 */
2220
		if (!request_mem_region(rinfo->fb_base_phys,
2221
					rinfo->base1_region_size, "rivafb")) {
2222
			printk(KERN_ERR PFX "cannot reserve FB region\n");
2223
			goto err_out_free_base0;
2224
		}
2225
2226
		rinfo->fb_base = ioremap(rinfo->fb_base_phys,
2227
					 rinfo->base1_region_size);
2228
		if (!rinfo->fb_base) {
2229
			printk(KERN_ERR PFX "cannot ioremap FB base\n");
2230
			goto err_out_iounmap_ctrl;
2231
		}
2232
	}
2233
2234
2235
	switch (rinfo->riva.Architecture) {
2236
	case NV_ARCH_03:
2237
		rinfo->riva.PRAMIN = (unsigned *)(rinfo->fb_base + 0x00C00000);
2238
		break;
2239
	case NV_ARCH_04:
2240
	case NV_ARCH_10:
2241
	case NV_ARCH_20:
2242
		rinfo->riva.PCRTC = (unsigned *)(rinfo->ctrl_base + 0x00600000);
2243
		rinfo->riva.PRAMIN = (unsigned *)(rinfo->ctrl_base + 0x00710000);
2244
		break;
2245
	}
2246
2247
	RivaGetConfig(&rinfo->riva);
2248
2249
	rinfo->ram_amount = fb_size;
2250
2251
	rinfo->dclk_max = rinfo->riva.MaxVClockFreqKHz * 1000;
2252
2253
	if (rinfo->riva.Architecture != NV_ARCH_03) {
2254
		/*
2255
		 * Now the _normal_ chipsets can just map the amount of
2256
		 * real physical ram instead of the whole aperture
2257
		 */
2258
		if (!request_mem_region(rinfo->fb_base_phys,
2259
					rinfo->ram_amount, "rivafb")) {
2260
			printk(KERN_ERR PFX "cannot reserve FB region\n");
2261
			goto err_out_free_base0;
2262
		}
2263
	
2264
		rinfo->fb_base = ioremap(rinfo->fb_base_phys,
2265
					 rinfo->ram_amount);
2266
		if (!rinfo->fb_base) {
2267
			printk(KERN_ERR PFX "cannot ioremap FB base\n");
2268
			goto err_out_iounmap_ctrl;
2269
		}
2270
	}
2271
#ifdef CONFIG_MTRR
2272
	if (!nomtrr) {
2273
		rinfo->mtrr.vram = mtrr_add(rinfo->fb_base_phys,
2274
					    rinfo->ram_amount,
2275
					    MTRR_TYPE_WRCOMB, 1);
2276
		if (rinfo->mtrr.vram < 0) {
2277
			printk(KERN_ERR PFX "unable to setup MTRR\n");
2278
		} else {
2279
			rinfo->mtrr.vram_valid = 1;
2280
			/* let there be speed */
2281
			printk(KERN_INFO PFX "RIVA MTRR set to ON\n");
2282
		}
2283
	}
2284
#endif /* CONFIG_MTRR */
2285
	rinfo->riva.CURSOR = (U032*)(rinfo->fb_base + fb_size - 128 * 1024);
2286
	rinfo->riva.PCRTC[0x00000800/4] = rinfo->riva_fb_start;	
2287
	rinfo->riva.PGRAPH[0x00000820/4] = rinfo->riva_fb_start;
2288
	rinfo->riva.PGRAPH[0x00000824/4] = rinfo->riva_fb_start;
2289
	rinfo->riva.PGRAPH[0x00000828/4] = rinfo->riva_fb_start;
2290
	rinfo->riva.PGRAPH[0x0000082c/4] = rinfo->riva_fb_start;
2291
2292
	rinfo->riva.PGRAPH[0x00000684/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2293
	rinfo->riva.PGRAPH[0x00000688/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2294
	rinfo->riva.PGRAPH[0x0000068c/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2295
	rinfo->riva.PGRAPH[0x00000690/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2296
	rinfo->riva.PMC[0x00008908/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2297
	rinfo->riva.PMC[0x0000890c/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2298
2299
	/* unlock io */
2300
	CRTCout(rinfo, 0x11, 0xFF);	/* vgaHWunlock() + riva unlock (0x7F) */
2301
	rinfo->riva.LockUnlock(&rinfo->riva, 0);
2302
2303
	riva_save_state(rinfo, &rinfo->initial_state);
2304
2305
	if (!nohwcursor) rinfo->cursor = rivafb_init_cursor(rinfo);
2306
	else rinfo->cursor = 0;
2307
2308
	if (riva_set_fbinfo(rinfo) < 0) {
2309
		printk(KERN_ERR PFX "error setting initial video mode\n");
2310
		goto err_out_cursor;
2311
	}
2312
2313
	if (register_framebuffer((struct fb_info *)rinfo) < 0) {
2314
		printk(KERN_ERR PFX
2315
			"error registering riva framebuffer\n");
2316
		goto err_out_load_state;
2317
	}
2318
2319
	riva_boards = riva_board_list_add(riva_boards, rinfo);
2320
2321
	pci_set_drvdata(pd, rinfo);
2322
2323
	printk(KERN_INFO PFX
2324
		"PCI nVidia NV%x framebuffer ver %s (%s, %dMB @ 0x%lX)\n",
2325
		rinfo->riva.Architecture,
2326
		RIVAFB_VERSION,
2327
		rinfo->drvr_name,
2328
		rinfo->ram_amount / (1024 * 1024),
2329
		rinfo->fb_base_phys);
2330
2331
	return 0;
2332
2333
err_out_load_state:
2334
	riva_load_state(rinfo, &rinfo->initial_state);
2335
err_out_cursor:
2336
	rivafb_exit_cursor(rinfo);
2337
/* err_out_iounmap_fb: */
2338
	iounmap(rinfo->fb_base);
2339
err_out_iounmap_ctrl:
2340
	iounmap(rinfo->ctrl_base);
2341
err_out_free_base1:
2342
	release_mem_region(rinfo->fb_base_phys, rinfo->base1_region_size);
2343
err_out_free_base0:
2344
	release_mem_region(rinfo->ctrl_base_phys, rinfo->base0_region_size);
2345
err_out_kfree:
2346
	kfree(rinfo);
2347
err_out:
2348
	return -ENODEV;
2349
}
2350
2351
static void __devexit rivafb_remove_one(struct pci_dev *pd)
2352
{
2353
	struct rivafb_info *board = pci_get_drvdata(pd);
2354
	
2355
	if (!board)
2356
		return;
2357
2358
	riva_boards = riva_board_list_del(riva_boards, board);
2359
2360
	riva_load_state(board, &board->initial_state);
2361
2362
	unregister_framebuffer((struct fb_info *)board);
2363
2364
	rivafb_exit_cursor(board);
2365
2366
#ifdef CONFIG_MTRR
2367
	if (board->mtrr.vram_valid)
2368
		mtrr_del(board->mtrr.vram, board->fb_base_phys,
2369
			 board->ram_amount);
2370
#endif /* CONFIG_MTRR */
2371
2372
	iounmap(board->ctrl_base);
2373
	iounmap(board->fb_base);
2374
2375
	release_mem_region(board->ctrl_base_phys,
2376
			   board->base0_region_size);
2377
	release_mem_region(board->fb_base_phys,
2378
			   board->ram_amount);
2379
2380
	kfree(board);
2381
2382
	pci_set_drvdata(pd, NULL);
2383
}
2384
2385
2386
2387
/* ------------------------------------------------------------------------- *
2388
 *
2389
 * initialization
2390
 *
2391
 * ------------------------------------------------------------------------- */
2392
2393
#ifndef MODULE
2394
int __init xboxfb_setup(char *options)
2395
{
2396
	char *this_opt;
2397
2398
	if (!options || !*options)
2399
		return 0;
2400
2401
	while ((this_opt = strsep(&options, ",")) != NULL) {
2402
		if (!*this_opt)
2403
			continue;
2404
		if (!strncmp(this_opt, "font:", 5)) {
2405
			char *p;
2406
			int i;
2407
2408
			p = this_opt + 5;
2409
			for (i = 0; i < sizeof(fontname) - 1; i++)
2410
				if (!*p || *p == ' ' || *p == ',')
2411
					break;
2412
			memcpy(fontname, this_opt + 5, i);
2413
			fontname[i] = 0;
2414
2415
		} else if (!strncmp(this_opt, "noblink", 7)) {
2416
			noblink = 1;
2417
		} else if (!strncmp(this_opt, "noaccel", 7)) {
2418
			noaccel = 1;
2419
		} else if (!strncmp(this_opt, "nomove", 6)) {
2420
			nomove = 1;
2421
#ifdef CONFIG_MTRR
2422
		} else if (!strncmp(this_opt, "nomtrr", 6)) {
2423
			nomtrr = 1;
2424
#endif
2425
		} else if (!strncmp(this_opt, "nohwcursor", 10)) {
2426
			nohwcursor = 1;
2427
2428
		} else if (!strncmp(this_opt, "fb_mem=", 7)) {
2429
			char *p;
2430
			fb_size = memparse(this_opt+7, &p);
2431
			if (*p == '@') {
2432
				fb_start = memparse(p+1, &p);
2433
			}
2434
			else {
2435
				fb_start = xbox_memory_size() - fb_size;
2436
			} 
2437
		} else if (!strncmp(this_opt, "tv=", 3)) {
2438
			if(!strncmp(this_opt + 3, "PAL", 3)) {
2439
				tv_encoding = TV_ENC_PALBDGHI;
2440
			}
2441
			else if(!strncmp(this_opt + 3, "NTSC", 4)) {
2442
				tv_encoding = TV_ENC_NTSC;
2443
			}
2444
			else if(!strncmp(this_opt + 3, "VGA", 3)) {
2445
				av_type = AV_VGA_SOG;
2446
			}
2447
		} else if (!strncmp(this_opt, "hoc=", 4)) {
2448
			sscanf(this_opt+4, "%d", &hoc);
2449
		} else if (!strncmp(this_opt, "voc=", 4)) {
2450
			sscanf(this_opt+4, "%d", &voc);
2451
		} else
2452
			mode_option = this_opt;
2453
	}
2454
	return 0;
2455
}
2456
#endif /* !MODULE */
2457
2458
static struct pci_driver rivafb_driver = {
2459
	.name		= "rivafb",
2460
	.id_table	= rivafb_pci_tbl,
2461
	.probe		= rivafb_init_one,
2462
	.remove		= __devexit_p(rivafb_remove_one),
2463
};
2464
2465
2466
2467
/* ------------------------------------------------------------------------- *
2468
 *
2469
 * modularization
2470
 *
2471
 * ------------------------------------------------------------------------- */
2472
2473
int __init xboxfb_init(void)
2474
{
2475
	int err;
2476
2477
	err = pci_module_init(&rivafb_driver);
2478
	if (err)
2479
		return err;
2480
	return 0;
2481
}
2482
2483
2484
#ifdef MODULE
2485
static void __exit rivafb_exit(void)
2486
{
2487
	pci_unregister_driver(&rivafb_driver);
2488
}
2489
2490
module_init(xboxfb_init);
2491
module_exit(rivafb_exit);
2492
2493
MODULE_PARM(font, "s");
2494
MODULE_PARM_DESC(font, "Specifies one of the compiled-in fonts (default=none)");
2495
MODULE_PARM(noaccel, "i");
2496
MODULE_PARM_DESC(noaccel, "Disables hardware acceleration (0 or 1=disabled) (default=0)");
2497
MODULE_PARM(nomove, "i");
2498
MODULE_PARM_DESC(nomove, "Enables YSCROLL_NOMOVE (0 or 1=enabled) (default=0)");
2499
MODULE_PARM(nohwcursor, "i");
2500
MODULE_PARM_DESC(nohwcursor, "Disables hardware cursor (0 or 1=disabled) (default=0)");
2501
MODULE_PARM(noblink, "i");
2502
MODULE_PARM_DESC(noblink, "Disables hardware cursor blinking (0 or 1=disabled) (default=0)");
2503
#ifdef CONFIG_MTRR
2504
MODULE_PARM(nomtrr, "i");
2505
MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)");
2506
#endif
2507
2508
MODULE_PARM(fb_mem, "s");
2509
MODULE_PARM_DESC(fb_mem, "Specifies the size and optionally the location of the framebuffer memory");
2510
MODULE_PARM(tv, "s");
2511
MODULE_PARM_DESC(tv, "Specifies the TV encoding (\"PAL\", \"NTSC\" or \"VGA\").");
2512
MODULE_PARM(hoc, "i");
2513
MODULE_PARM_DESC(hoc, "Horizontal overscan compensation ratio, in % (0-20)");
2514
MODULE_PARM(voc, "i");
2515
MODULE_PARM_DESC(voc, "Vertical overscan compensation ratio, in % (0-20)");
2516
2517
#endif /* MODULE */
2518
2519
MODULE_AUTHOR("Oliver Schwartz, maintainer");
2520
MODULE_DESCRIPTION("Framebuffer driver for Xbox");
2521
MODULE_LICENSE("GPL");
(-)linux-2.4.26/drivers/video/xbox/focus.c (+328 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/focus.c - Xbox driver for Focus encoder
3
 *
4
 * Maintainer: David Pye (dmp) <dmp@davidmpye.dyndns.org>
5
 *
6
 * This file is subject to the terms and conditions of the GNU General Public
7
 * License.  See the file COPYING in the main directory of this archive
8
 * for more details.
9
 *
10
 * Known bugs and issues:
11
 *
12
 * VGA SoG/internal sync not yet implemented
13
*/
14
#include "focus.h"
15
#include "encoder.h"
16
17
18
static const unsigned char focus_defaults[0xc4] = {
19
	/*0x00*/ 0x00,0x00,0x00,0x00,0x80,0x02,0xaa,0x0a,
20
	/*0x08*/ 0x00,0x10,0x00,0x00,0x03,0x21,0x15,0x04,
21
	/*0x10*/ 0x00,0xe9,0x07,0x00,0x80,0xf5,0x20,0x00,
22
	/*0x18*/ 0xef,0x21,0x1f,0x00,0x03,0x03,0x00,0x00,
23
	/*0x20*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
24
	/*0x28*/ 0x0c,0x01,0x00,0x00,0x00,0x00,0x08,0x11,
25
	/*0x30*/ 0x00,0x0f,0x05,0xfe,0x0b,0x80,0x00,0x00,
26
	/*0x38*/ 0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
27
	/*0x40*/ 0x2a,0x09,0x8a,0xcb,0x00,0x00,0x8d,0x00,
28
	/*0x48*/ 0x7c,0x3c,0x9a,0x2f,0x21,0x01,0x3f,0x00,
29
	/*0x50*/ 0x3e,0x03,0x17,0x21,0x1b,0x1b,0x24,0x9c,
30
	/*0x58*/ 0x01,0x3e,0x0f,0x0f,0x60,0x05,0xc8,0x00,
31
	/*0x60*/ 0x9d,0x04,0x9d,0x01,0x02,0x00,0x0a,0x05,
32
	/*0x68*/ 0x00,0x1a,0xff,0x03,0x1e,0x0f,0x78,0x00,
33
	/*0x70*/ 0x00,0xb1,0x04,0x15,0x49,0x10,0x00,0xa3,
34
	/*0x78*/ 0xc8,0x15,0x05,0x15,0x3e,0x03,0x00,0x20,
35
	/*0x80*/ 0x57,0x2f,0x07,0x00,0x00,0x08,0x00,0x00,
36
	/*0x88*/ 0x08,0x16,0x16,0x9c,0x03,0x00,0x00,0x00,
37
	/*0x90*/ 0x00,0x00,0xc4,0x48,0x00,0x00,0x00,0x00,
38
	/*0x98*/ 0x00,0x00,0x00,0x80,0x00,0x00,0xe4,0x00,
39
	/*0xa0*/ 0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
40
	/*0xa8*/ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,
41
	/*0xb0*/ 0x00,0x00,0xd7,0x05,0x00,0x00,0xf0,0x00,
42
	/*0xb8*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
43
	/*0xc0*/ 0x00,0x00,0xee,0x00
44
};
45
46
int focus_calc_hdtv_mode(
47
	xbox_hdtv_mode hdtv_mode,
48
	unsigned char pll_int,
49
	unsigned char * regs
50
	){
51
	unsigned char b;
52
	int m=0;
53
	int tv_vtotal, tv_htotal, tv_vactive, tv_hactive, vga_htotal, vga_vtotal;
54
	int pll_n, pll_m, pll_p, ncon, ncod;
55
56
	memcpy(regs,focus_defaults,sizeof(focus_defaults));	
57
	/* Uncomment for HDTV 480p colour bars */
58
	//regs[0x0d]|=0x02;
59
	
60
	/* Turn on bridge bypass */
61
	regs[0x0a] |= 0x10;
62
	/* Turn on the HDTV clock, and turn off the SDTV one */	
63
	regs[0xa1] = 0x04;
64
	
65
	/* HDTV Hor start */
66
	regs[0xb8] = 0xbe;
67
	
68
	/*Set up video mode to HDTV, progressive, 
69
	 * and disable YUV matrix bypass */
70
	regs[0x92] = 0x1a;	
71
	regs[0x93] &= ~0x40;
72
	
73
	switch (hdtv_mode) {
74
		case HDTV_480p:
75
			/* PLL settings */
76
			regs[0x10] = 0x00;
77
			regs[0x11] = 0x00;
78
			regs[0x12] = 0x00;
79
			regs[0x13] = 0x00;
80
			regs[0x14] = 0x00;
81
			regs[0x15] = 0x00;
82
			regs[0x16] = 0x00;
83
			regs[0x17] = 0x00;
84
			regs[0x18] = 0xD7;
85
			regs[0x19] = 0x03;
86
			regs[0x1A] = 0x7C;
87
			regs[0x1B] = 0x00;
88
			regs[0x1C] = 0x07;
89
			regs[0x1D] = 0x07;
90
			/* Porches/HSync width/Luma offset */
91
			regs[0x94] = 0x3F;
92
			regs[0x95] = 0x2D;
93
			regs[0x96] = 0x3B;
94
			regs[0x97] = 0x00;
95
			regs[0x98] = 0x1B;
96
			regs[0x99] = 0x03;
97
			/* Colour scaling */
98
			regs[0xA2] = 0x4D;
99
			regs[0xA4] = 0x96;
100
			regs[0xA6] = 0x1D;
101
			regs[0xA8] = 0x58;
102
			regs[0xAA] = 0x8A;
103
			regs[0xAC] = 0x4A;
104
			break;
105
		case HDTV_720p:
106
			/* PLL settings */
107
			regs[0x10] = 0x00;
108
			regs[0x11] = 0x00;
109
			regs[0x12] = 0x00;
110
			regs[0x13] = 0x00;
111
			regs[0x14] = 0x00;
112
			regs[0x15] = 0x00;
113
			regs[0x16] = 0x00;
114
			regs[0x17] = 0x00;
115
			regs[0x18] = 0x3B;
116
			regs[0x19] = 0x04;
117
			regs[0x1A] = 0xC7;
118
			regs[0x1B] = 0x00;
119
			regs[0x1C] = 0x01;
120
			regs[0x1D] = 0x01;
121
			/* Porches/HSync width/Luma offset */
122
			regs[0x94] = 0x28;
123
			regs[0x95] = 0x46;
124
			regs[0x96] = 0xDC;
125
			regs[0x97] = 0x00;
126
			regs[0x98] = 0x2C;
127
			regs[0x99] = 0x06;
128
			/* Colour scaling */
129
			regs[0xA2] = 0x36;
130
			regs[0xA4] = 0xB7;
131
			regs[0xA6] = 0x13;
132
			regs[0xA8] = 0x58;
133
			regs[0xAA] = 0x8A;
134
			regs[0xAC] = 0x4A;
135
			/* HSync timing invert - needed to centre picture */
136
			regs[0x93] |= 0x01;
137
			
138
			break;
139
		case HDTV_1080i:
140
			/* PLL settings */
141
			regs[0x10] = 0x00;
142
			regs[0x11] = 0x00;
143
			regs[0x12] = 0x00;
144
			regs[0x13] = 0x00;
145
			regs[0x14] = 0x00;
146
			regs[0x15] = 0x00;
147
			regs[0x16] = 0x00;
148
			regs[0x17] = 0x00;
149
			regs[0x18] = 0x3B;
150
			regs[0x19] = 0x04;
151
			regs[0x1A] = 0xC7;
152
			regs[0x1B] = 0x00;
153
			regs[0x1C] = 0x01;
154
			regs[0x1D] = 0x01;
155
			/* Porches/HSync width/Luma offset */
156
			regs[0x94] = 0x2C;
157
			regs[0x95] = 0x2C;
158
			regs[0x96] = 0x58;
159
			regs[0x97] = 0x00;
160
			regs[0x98] = 0x6C;
161
			regs[0x99] = 0x08;
162
			/* Colour scaling */
163
			regs[0xA2] = 0x36;
164
			regs[0xA4] = 0xB7;
165
			regs[0xA6] = 0x13;
166
			regs[0xA8] = 0x58;
167
			regs[0xAA] = 0x8A;
168
			regs[0xAC] = 0x4A;
169
			/* Set mode to interlaced */
170
			regs[0x92] |= 0x80;
171
			break;
172
	}
173
	return 1;
174
}
175
176
int focus_calc_mode(xbox_video_mode * mode, struct riva_regs * riva_out)
177
{
178
	unsigned char b;
179
	char* regs = riva_out->encoder_mode;
180
	int m = 0;
181
	int tv_htotal, tv_vtotal, tv_vactive, tv_hactive;
182
	int vga_htotal, vga_vtotal;
183
	long ncon, ncod;
184
	int pll_m, pll_n, pll_p, vsc, hsc;
185
186
	memcpy(regs,focus_defaults,sizeof(focus_defaults));
187
	
188
	/* Uncomment for SDTV colour bars */
189
	//regs[0x45]=0x02;
190
	
191
	switch(mode->tv_encoding) {
192
		case TV_ENC_NTSC:
193
			tv_vtotal=525;
194
			tv_vactive=480;			
195
			tv_hactive = 710;
196
			tv_htotal  = 858;
197
			regs[0x0d] &= ~0x01;
198
			regs[0x40] = 0x21;
199
			regs[0x41] = 0xF0;
200
			regs[0x42] = 0x7C;
201
			regs[0x43] = 0x1F;
202
			regs[0x49] = 0x44;
203
			regs[0x4a] = 0x76;
204
			regs[0x4b] = 0x3B;
205
			regs[0x4c] = 0x00;
206
			regs[0x60] = 0x89;
207
			regs[0x62] = 0x89;
208
			regs[0x69] = 0x16;
209
			regs[0x6C] = 0x20;
210
			regs[0x74] = 0x04;		
211
			regs[0x75] = 0x10;
212
			regs[0x80] = 0x67; 
213
			regs[0x81] = 0x21; 
214
			regs[0x82] = 0x0C;
215
			regs[0x83] = 0x18;
216
			regs[0x86] = 0x18;
217
			regs[0x89] = 0x13;
218
			regs[0x8A] = 0x13;
219
			break;
220
		case TV_ENC_PALBDGHI:
221
			tv_vtotal = 625;
222
			tv_vactive = 576;
223
			tv_hactive = 702;
224
			tv_htotal = 864;
225
			break;
226
		default:
227
			/* Default to PAL */
228
			tv_vtotal = 625;
229
			tv_vactive = 576;
230
			tv_hactive = 702;
231
			tv_htotal = 864;
232
			break;
233
	}
234
235
	/* Video control  - set to RGB input*/
236
	b = (regs[0x92] &= ~0x04);
237
	regs[0x92] = (b|= 0x01);
238
	regs[0x93] &= ~0x40;
239
	/* Colour scaling */
240
	regs[0xA2] = 0x4D;
241
	regs[0xA4] = 0x96;
242
	regs[0xA6] = 0x1D;
243
	regs[0xA8] = 0xA0;
244
	regs[0xAA] = 0xDB;
245
	regs[0xAC] = 0x7E;
246
	
247
	tv_vactive = tv_vactive * (1.0f-mode->voc);
248
	vga_vtotal = mode->yres * ((float)tv_vtotal/tv_vactive);
249
	vga_htotal = mode->xres * 1.25f;
250
	tv_hactive = tv_hactive * (1.0f-mode->hoc);
251
	/*These should be calculated or at least deduced.
252
	 *However they are good enough for 640x480 -> 800x600 now*/
253
	pll_n  = 32;
254
	pll_m = 512;
255
	pll_p = 4; 
256
	
257
	ncon = vga_htotal * vga_vtotal;
258
	ncod = tv_htotal * tv_vtotal  * pll_p;
259
	
260
	regs[0x04] = (mode->xres+64)&0xFF;
261
	regs[0x05] = ((mode->xres+64)>>8)&0xFF;
262
263
	if (tv_vtotal>vga_vtotal) {
264
		/* Upscaling */
265
		vsc = ((((float)tv_vtotal/(float)vga_vtotal)-1)*65536);
266
		/* For upscaling, adjust FIFO_LAT (FIFO latency) */
267
		regs[0x38] = 0x82;
268
	}
269
	else {
270
		/* Downscaling */
271
		vsc = ((((float)tv_vtotal/(float)vga_vtotal))*65536);
272
	}
273
	regs[0x06] = (vsc)&0xFF;
274
	regs[0x07] = (vsc>>8)&0xFF;
275
276
	hsc = 128*((float)tv_hactive/(float)mode->xres-1);
277
	if (tv_hactive > mode->xres) {
278
		/* Upscaling */
279
		regs[0x08] = 0;
280
		regs[0x09] = hsc&0xFF;
281
	}
282
	else {  /* Downscaling */
283
		hsc = 256 + hsc;
284
		regs[0x08] = hsc&0xFF;
285
		regs[0x09] = 0;
286
	}
287
288
289
	regs[0x10] = (ncon)&0xFF;
290
	regs[0x11] = (ncon>>8)&0xFF ;
291
	regs[0x12] = (ncon>>16)&0xFF ;
292
	regs[0x13] = (ncon>>24)&0xFF ;
293
	regs[0x14] = (ncod)&0xFF ;
294
	regs[0x15] = (ncod>>8)&0xFF ;
295
	regs[0x16] = (ncod>>16)&0xFF ;
296
	regs[0x17] = (ncod>>24)&0xFF ;
297
	regs[0x18] = (pll_m-17)&0xFF;
298
	regs[0x19] = ((pll_m-17)>>8)&0xFF;
299
	regs[0x1A] = (pll_n-1)&0xFF ;
300
	regs[0x1B] = ((pll_n-1)>>8)&0xFF ;
301
	regs[0x1C] = (pll_p-1)&0xFF;
302
	regs[0x1D] = (pll_p-1)&0xFF;
303
	        
304
	/* Guesswork */
305
	riva_out->ext.vsyncstart = vga_vtotal * 0.95;
306
	riva_out->ext.hsyncstart = vga_htotal * 0.95;
307
	
308
	riva_out->ext.width = mode->xres;
309
	riva_out->ext.height = mode->yres;
310
	riva_out->ext.htotal = vga_htotal - 1;
311
	riva_out->ext.vend = mode->yres - 1;
312
	riva_out->ext.vtotal = vga_vtotal- 1;
313
	riva_out->ext.vcrtc = mode->yres - 1;
314
	riva_out->ext.vsyncend = riva_out->ext.vsyncstart + 3;
315
        riva_out->ext.vvalidstart = 0;
316
	riva_out->ext.vvalidend = mode->yres - 1;
317
	riva_out->ext.hend = mode->xres + 7 ;
318
	riva_out->ext.hcrtc = mode->xres - 1;
319
        riva_out->ext.hsyncend = riva_out->ext.hsyncstart + 32;
320
        riva_out->ext.hvalidstart = 0;
321
        riva_out->ext.hvalidend = mode->xres - 1;
322
	riva_out->ext.crtchdispend = mode->xres;
323
        riva_out->ext.crtcvstart = mode->yres + 32;
324
	//increased from 32
325
	riva_out->ext.crtcvtotal = mode->yres + 64;
326
327
	return 1;
328
}
(-)linux-2.4.26/drivers/video/xbox/focus.h (+24 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/focus.c - Xbox driver for Focus encoder
3
 *
4
 * Maintainer: David Pye (dmp) <dmp@davidmpye.dyndns.org>
5
 *
6
 * This file is subject to the terms and conditions of the GNU General Public
7
 * License.  See the file COPYING in the main directory of this archive
8
 * for more details.
9
 *
10
 * Known bugs and issues:
11
 *
12
 * none
13
 */
14
15
16
#ifndef focus_h_
17
#define focus_h_
18
19
#include "encoder.h"
20
#include "xboxfb.h"
21
22
int focus_calc_mode(xbox_video_mode * mode, struct riva_regs * riva_out );
23
int focus_calc_hdtv_mode(xbox_hdtv_mode hdtv_mode, unsigned char pll_int, unsigned char * mode_out);
24
#endif
(-)linux-2.4.26/drivers/video/xbox/nv4ref.h (+2445 lines)
Line 0 Link Here
1
 /***************************************************************************\
2
|*                                                                           *|
3
|*       Copyright 1993-1998 NVIDIA, Corporation.  All rights reserved.      *|
4
|*                                                                           *|
5
|*     NOTICE TO USER:   The source code  is copyrighted under  U.S. and     *|
6
|*     international laws.  Users and possessors of this source code are     *|
7
|*     hereby granted a nonexclusive,  royalty-free copyright license to     *|
8
|*     use this code in individual and commercial software.                  *|
9
|*                                                                           *|
10
|*     Any use of this source code must include,  in the user documenta-     *|
11
|*     tion and  internal comments to the code,  notices to the end user     *|
12
|*     as follows:                                                           *|
13
|*                                                                           *|
14
|*       Copyright 1993-1998 NVIDIA, Corporation.  All rights reserved.      *|
15
|*                                                                           *|
16
|*     NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY     *|
17
|*     OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"     *|
18
|*     WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPOR-     *|
19
|*     ATION DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,     *|
20
|*     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE-     *|
21
|*     MENT,  AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL     *|
22
|*     NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCI-     *|
23
|*     DENTAL, OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RE-     *|
24
|*     SULTING FROM LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION     *|
25
|*     OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF     *|
26
|*     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.     *|
27
|*                                                                           *|
28
|*     U.S. Government  End  Users.   This source code  is a "commercial     *|
29
|*     item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),     *|
30
|*     consisting  of "commercial  computer  software"  and  "commercial     *|
31
|*     computer  software  documentation,"  as such  terms  are  used in     *|
32
|*     48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Govern-     *|
33
|*     ment only as  a commercial end item.   Consistent with  48 C.F.R.     *|
34
|*     12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),     *|
35
|*     all U.S. Government End Users  acquire the source code  with only     *|
36
|*     those rights set forth herein.                                        *|
37
|*                                                                           *|
38
 \***************************************************************************/
39
40
/*
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
42
 * the documentation restriction above, to merely say that this nVidia's
43
 * copyright and disclaimer should be included with all code derived
44
 * from this source.  -- Jeff Garzik <jgarzik@mandrakesoft.com>, 01/Nov/99 
45
 */
46
47
 /***************************************************************************\
48
|*            Modified 1999 by Fredrik Reite (fredrik@reite.com)             *|
49
 \***************************************************************************/
50
51
52
#ifndef __NV4REF_H__
53
#define __NV4REF_H__
54
55
/* Magic values to lock/unlock extended regs */
56
#define NV_CIO_SR_LOCK_INDEX				     0x0000001F /*       */
57
#define NV_CIO_SR_UNLOCK_RW_VALUE                            0x00000057 /*       */
58
#define NV_CIO_SR_UNLOCK_RO_VALUE                            0x00000075 /*       */
59
#define NV_CIO_SR_LOCK_VALUE                                 0x00000099 /*       */
60
61
#define UNLOCK_EXT_MAGIC 0x57
62
#define LOCK_EXT_MAGIC 0x99 /* Any value other than 0x57 will do */
63
64
#define LOCK_EXT_INDEX 0x6
65
66
#define NV_PCRTC_HORIZ_TOTAL                                 0x00
67
#define NV_PCRTC_HORIZ_DISPLAY_END                           0x01
68
#define NV_PCRTC_HORIZ_BLANK_START                           0x02
69
70
#define NV_PCRTC_HORIZ_BLANK_END                             0x03
71
#define NV_PCRTC_HORIZ_BLANK_END_EVRA                        7:7
72
#define NV_PCRTC_HORIZ_BLANK_END_DISPLAY_END_SKEW            6:5
73
#define NV_PCRTC_HORIZ_BLANK_END_HORIZ_BLANK_END             4:0
74
75
#define NV_PCRTC_HORIZ_RETRACE_START                         0x04
76
77
#define NV_PCRTC_HORIZ_RETRACE_END                           0x05
78
#define NV_PCRTC_HORIZ_RETRACE_END_HORIZ_BLANK_END_5         7:7
79
#define NV_PCRTC_HORIZ_RETRACE_END_HORIZ_RETRACE_SKEW        6:5
80
#define NV_PCRTC_HORIZ_RETRACE_END_HORIZ_RETRACE_END         4:0
81
82
#define NV_PCRTC_VERT_TOTAL                                  0x06
83
84
#define NV_PCRTC_OVERFLOW                                    0x07
85
#define NV_PCRTC_OVERFLOW_VERT_RETRACE_START_9               7:7
86
#define NV_PCRTC_OVERFLOW_VERT_DISPLAY_END_9                 6:6
87
#define NV_PCRTC_OVERFLOW_VERT_TOTAL_9                       5:5
88
#define NV_PCRTC_OVERFLOW_LINE_COMPARE_8                     4:4
89
#define NV_PCRTC_OVERFLOW_VERT_BLANK_START_8                 3:3
90
#define NV_PCRTC_OVERFLOW_VERT_RETRACE_START_8               2:2
91
#define NV_PCRTC_OVERFLOW_VERT_DISPLAY_END_8                 1:1
92
#define NV_PCRTC_OVERFLOW_VERT_TOTAL_8                       0:0
93
94
#define NV_PCRTC_PRESET_ROW_SCAN                             0x08
95
96
#define NV_PCRTC_MAX_SCAN_LINE                               0x09
97
#define NV_PCRTC_MAX_SCAN_LINE_DOUBLE_SCAN                   7:7
98
#define NV_PCRTC_MAX_SCAN_LINE_LINE_COMPARE_9                6:6
99
#define NV_PCRTC_MAX_SCAN_LINE_VERT_BLANK_START_9            5:5
100
#define NV_PCRTC_MAX_SCAN_LINE_MAX_SCAN_LINE                 4:0
101
102
#define NV_PCRTC_CURSOR_START                                0x0A
103
#define NV_PCRTC_CURSOR_END                                  0x0B
104
#define NV_PCRTC_START_ADDR_HIGH                             0x0C
105
#define NV_PCRTC_START_ADDR_LOW                              0x0D
106
#define NV_PCRTC_CURSOR_LOCATION_HIGH                        0x0E
107
#define NV_PCRTC_CURSOR_LOCATION_LOW                         0x0F
108
109
#define NV_PCRTC_VERT_RETRACE_START                          0x10
110
#define NV_PCRTC_VERT_RETRACE_END                            0x11
111
#define NV_PCRTC_VERT_DISPLAY_END                            0x12
112
#define NV_PCRTC_OFFSET                                      0x13
113
#define NV_PCRTC_UNDERLINE_LOCATION                          0x14
114
#define NV_PCRTC_VERT_BLANK_START                            0x15
115
#define NV_PCRTC_VERT_BLANK_END                              0x16
116
#define NV_PCRTC_MODE_CONTROL                                0x17
117
#define NV_PCRTC_LINE_COMPARE                                0x18
118
119
/* Extended offset and start address */
120
#define NV_PCRTC_REPAINT0                                    0x19
121
#define NV_PCRTC_REPAINT0_OFFSET_10_8                        7:5 
122
#define NV_PCRTC_REPAINT0_START_ADDR_20_16                   4:0
123
124
/* Horizonal extended bits */
125
#define NV_PCRTC_HORIZ_EXTRA                                 0x2d
126
#define NV_PCRTC_HORIZ_EXTRA_INTER_HALF_START_8              4:4
127
#define NV_PCRTC_HORIZ_EXTRA_HORIZ_RETRACE_START_8           3:3
128
#define NV_PCRTC_HORIZ_EXTRA_HORIZ_BLANK_START_8             2:2
129
#define NV_PCRTC_HORIZ_EXTRA_DISPLAY_END_8                   1:1
130
#define NV_PCRTC_HORIZ_EXTRA_DISPLAY_TOTAL_8                 0:0
131
132
/* Assorted extra bits */
133
#define NV_PCRTC_EXTRA                                       0x25
134
#define NV_PCRTC_EXTRA_OFFSET_11                             5:5
135
#define NV_PCRTC_EXTRA_HORIZ_BLANK_END_6                     4:4
136
#define NV_PCRTC_EXTRA_VERT_BLANK_START_10                   3:3
137
#define NV_PCRTC_EXTRA_VERT_RETRACE_START_10                 2:2
138
#define NV_PCRTC_EXTRA_VERT_DISPLAY_END_10                   1:1
139
#define NV_PCRTC_EXTRA_VERT_TOTAL_10                         0:0
140
141
/* Controls how much data the refresh fifo requests */
142
#define NV_PCRTC_FIFO_CONTROL                                0x1b
143
#define NV_PCRTC_FIFO_CONTROL_UNDERFLOW_WARN                 7:7
144
#define NV_PCRTC_FIFO_CONTROL_BURST_LENGTH                   2:0
145
#define NV_PCRTC_FIFO_CONTROL_BURST_LENGTH_8                 0x0
146
#define NV_PCRTC_FIFO_CONTROL_BURST_LENGTH_32                0x1
147
#define NV_PCRTC_FIFO_CONTROL_BURST_LENGTH_64                0x2
148
#define NV_PCRTC_FIFO_CONTROL_BURST_LENGTH_128               0x3
149
#define NV_PCRTC_FIFO_CONTROL_BURST_LENGTH_256               0x4
150
151
/* When the fifo occupancy falls below *twice* the watermark,
152
 * the refresh fifo will start to be refilled. If this value is 
153
 * too low, you will get junk on the screen. Too high, and performance
154
 * will suffer. Watermark in units of 8 bytes
155
 */
156
#define NV_PCRTC_FIFO                                        0x20
157
#define NV_PCRTC_FIFO_RESET                                  7:7
158
#define NV_PCRTC_FIFO_WATERMARK                              5:0
159
160
/* Various flags */
161
#define NV_PCRTC_REPAINT1                                    0x1a
162
#define NV_PCRTC_REPAINT1_HSYNC                              7:7
163
#define NV_PCRTC_REPAINT1_HYSNC_DISABLE                      0x01
164
#define NV_PCRTC_REPAINT1_HYSNC_ENABLE                       0x00
165
#define NV_PCRTC_REPAINT1_VSYNC                              6:6
166
#define NV_PCRTC_REPAINT1_VYSNC_DISABLE                      0x01
167
#define NV_PCRTC_REPAINT1_VYSNC_ENABLE                       0x00
168
#define NV_PCRTC_REPAINT1_COMPATIBLE_TEXT                    4:4
169
#define NV_PCRTC_REPAINT1_COMPATIBLE_TEXT_ENABLE             0x01
170
#define NV_PCRTC_REPAINT1_COMPATIBLE_TEXT_DISABLE            0x00
171
#define NV_PCRTC_REPAINT1_LARGE_SCREEN                       2:2 
172
#define NV_PCRTC_REPAINT1_LARGE_SCREEN_DISABLE               0x01
173
#define NV_PCRTC_REPAINT1_LARGE_SCREEN_ENABLE                0x00 /* >=1280 */
174
#define NV_PCRTC_REPAINT1_PALETTE_WIDTH                      1:1
175
#define NV_PCRTC_REPAINT1_PALETTE_WIDTH_8BITS                0x00
176
#define NV_PCRTC_REPAINT1_PALETTE_WIDTH_6BITS                0x01
177
178
#define NV_PCRTC_GRCURSOR0                                   0x30
179
#define NV_PCRTC_GRCURSOR0_START_ADDR_21_16                  5:0
180
181
#define NV_PCRTC_GRCURSOR1                                   0x31
182
#define NV_PCRTC_GRCURSOR1_START_ADDR_15_11                  7:3
183
#define NV_PCRTC_GRCURSOR1_SCAN_DBL                          1:1
184
#define NV_PCRTC_GRCURSOR1_SCAN_DBL_DISABLE                  0
185
#define NV_PCRTC_GRCURSOR1_SCAN_DBL_ENABLE                   1
186
#define NV_PCRTC_GRCURSOR1_CURSOR                            0:0
187
#define NV_PCRTC_GRCURSOR1_CURSOR_DISABLE                    0 
188
#define NV_PCRTC_GRCURSOR1_CURSOR_ENABLE                     1
189
190
/* Controls what the format of the framebuffer is */
191
#define NV_PCRTC_PIXEL                       0x28
192
#define NV_PCRTC_PIXEL_MODE                  7:7
193
#define NV_PCRTC_PIXEL_MODE_TV               0x01
194
#define NV_PCRTC_PIXEL_MODE_VGA              0x00
195
#define NV_PCRTC_PIXEL_TV_MODE               6:6
196
#define NV_PCRTC_PIXEL_TV_MODE_NTSC          0x00
197
#define NV_PCRTC_PIXEL_TV_MODE_PAL           0x01
198
#define NV_PCRTC_PIXEL_TV_HORIZ_ADJUST       5:3
199
#define NV_PCRTC_PIXEL_FORMAT                1:0
200
#define NV_PCRTC_PIXEL_FORMAT_VGA            0x00
201
#define NV_PCRTC_PIXEL_FORMAT_8BPP           0x01
202
#define NV_PCRTC_PIXEL_FORMAT_16BPP          0x02
203
#define NV_PCRTC_PIXEL_FORMAT_32BPP          0x03
204
205
/* RAMDAC registers and fields */
206
#define NV_PRAMDAC                            0x00680FFF:0x00680000 /* RW--D */
207
#define NV_PRAMDAC_GRCURSOR_START_POS                    0x00680300 /* RW-4R */
208
#define NV_PRAMDAC_GRCURSOR_START_POS_X                        11:0 /* RWXSF */
209
#define NV_PRAMDAC_GRCURSOR_START_POS_Y                       27:16 /* RWXSF */
210
#define NV_PRAMDAC_NVPLL_COEFF                           0x00680500 /* RW-4R */
211
#define NV_PRAMDAC_NVPLL_COEFF_MDIV                             7:0 /* RWIUF */
212
#define NV_PRAMDAC_NVPLL_COEFF_NDIV                            15:8 /* RWIUF */
213
#define NV_PRAMDAC_NVPLL_COEFF_PDIV                           18:16 /* RWIVF */
214
#define NV_PRAMDAC_MPLL_COEFF                            0x00680504 /* RW-4R */
215
#define NV_PRAMDAC_MPLL_COEFF_MDIV                              7:0 /* RWIUF */
216
#define NV_PRAMDAC_MPLL_COEFF_NDIV                             15:8 /* RWIUF */
217
#define NV_PRAMDAC_MPLL_COEFF_PDIV                            18:16 /* RWIVF */
218
#define NV_PRAMDAC_VPLL_COEFF                            0x00680508 /* RW-4R */
219
#define NV_PRAMDAC_VPLL_COEFF_MDIV                              7:0 /* RWIUF */
220
#define NV_PRAMDAC_VPLL_COEFF_NDIV                             15:8 /* RWIUF */
221
#define NV_PRAMDAC_VPLL_COEFF_PDIV                            18:16 /* RWIVF */
222
#define NV_PRAMDAC_PLL_COEFF_SELECT                      0x0068050C /* RW-4R */
223
#define NV_PRAMDAC_PLL_COEFF_SELECT_DLL_BYPASS                  4:4 /* RWIVF */
224
#define NV_PRAMDAC_PLL_COEFF_SELECT_DLL_BYPASS_FALSE     0x00000000 /* RWI-V */
225
#define NV_PRAMDAC_PLL_COEFF_SELECT_DLL_BYPASS_TRUE      0x00000001 /* RW--V */
226
#define NV_PRAMDAC_PLL_COEFF_SELECT_MPLL_SOURCE                 8:8 /* RWIVF */
227
#define NV_PRAMDAC_PLL_COEFF_SELECT_MPLL_SOURCE_DEFAULT  0x00000000 /* RWI-V */
228
#define NV_PRAMDAC_PLL_COEFF_SELECT_MPLL_SOURCE_PROG     0x00000001 /* RW--V */
229
#define NV_PRAMDAC_PLL_COEFF_SELECT_MPLL_BYPASS               12:12 /* RWIVF */
230
#define NV_PRAMDAC_PLL_COEFF_SELECT_MPLL_BYPASS_FALSE    0x00000000 /* RWI-V */
231
#define NV_PRAMDAC_PLL_COEFF_SELECT_MPLL_BYPASS_TRUE     0x00000001 /* RW--V */
232
#define NV_PRAMDAC_PLL_COEFF_SELECT_VPLL_SOURCE               16:16 /* RWIVF */
233
#define NV_PRAMDAC_PLL_COEFF_SELECT_VPLL_SOURCE_DEFAULT  0x00000000 /* RWI-V */
234
#define NV_PRAMDAC_PLL_COEFF_SELECT_VPLL_SOURCE_PROG     0x00000001 /* RW--V */
235
#define NV_PRAMDAC_PLL_COEFF_SELECT_VPLL_BYPASS               20:20 /* RWIVF */
236
#define NV_PRAMDAC_PLL_COEFF_SELECT_VPLL_BYPASS_FALSE    0x00000000 /* RWI-V */
237
#define NV_PRAMDAC_PLL_COEFF_SELECT_VPLL_BYPASS_TRUE     0x00000001 /* RW--V */
238
#define NV_PRAMDAC_PLL_COEFF_SELECT_PCLK_SOURCE               25:24 /* RWIVF */
239
#define NV_PRAMDAC_PLL_COEFF_SELECT_PCLK_SOURCE_VPLL     0x00000000 /* RWI-V */
240
#define NV_PRAMDAC_PLL_COEFF_SELECT_PCLK_SOURCE_VIP      0x00000001 /* RW--V */
241
#define NV_PRAMDAC_PLL_COEFF_SELECT_PCLK_SOURCE_XTALOSC  0x00000002 /* RW--V */
242
#define NV_PRAMDAC_PLL_COEFF_SELECT_VCLK_RATIO                28:28 /* RWIVF */
243
#define NV_PRAMDAC_PLL_COEFF_SELECT_VCLK_RATIO_DB1       0x00000000 /* RWI-V */
244
#define NV_PRAMDAC_PLL_COEFF_SELECT_VCLK_RATIO_DB2       0x00000001 /* RW--V */
245
#define NV_PRAMDAC_GENERAL_CONTROL                       0x00680600 /* RW-4R */
246
#define NV_PRAMDAC_GENERAL_CONTROL_FF_COEFF                     1:0 /* RWIVF */
247
#define NV_PRAMDAC_GENERAL_CONTROL_FF_COEFF_DEF          0x00000000 /* RWI-V */
248
#define NV_PRAMDAC_GENERAL_CONTROL_IDC_MODE                     4:4 /* RWIVF */
249
#define NV_PRAMDAC_GENERAL_CONTROL_IDC_MODE_GAMMA        0x00000000 /* RWI-V */
250
#define NV_PRAMDAC_GENERAL_CONTROL_IDC_MODE_INDEX        0x00000001 /* RW--V */
251
#define NV_PRAMDAC_GENERAL_CONTROL_VGA_STATE                    8:8 /* RWIVF */
252
#define NV_PRAMDAC_GENERAL_CONTROL_VGA_STATE_NOTSE       0x00000000 /* RWI-V */
253
#define NV_PRAMDAC_GENERAL_CONTROL_VGA_STATE_SEL         0x00000001 /* RW--V */
254
#define NV_PRAMDAC_GENERAL_CONTROL_565_MODE                   12:12 /* RWIVF */
255
#define NV_PRAMDAC_GENERAL_CONTROL_565_MODE_NOTSEL       0x00000000 /* RWI-V */
256
#define NV_PRAMDAC_GENERAL_CONTROL_565_MODE_SEL          0x00000001 /* RW--V */
257
#define NV_PRAMDAC_GENERAL_CONTROL_BLK_PEDSTL                 16:16 /* RWIVF */
258
#define NV_PRAMDAC_GENERAL_CONTROL_BLK_PEDSTL_OFF        0x00000000 /* RWI-V */
259
#define NV_PRAMDAC_GENERAL_CONTROL_BLK_PEDSTL_ON         0x00000001 /* RW--V */
260
#define NV_PRAMDAC_GENERAL_CONTROL_TERMINATION                17:17 /* RWIVF */
261
#define NV_PRAMDAC_GENERAL_CONTROL_TERMINATION_37OHM     0x00000000 /* RWI-V */
262
#define NV_PRAMDAC_GENERAL_CONTROL_TERMINATION_75OHM     0x00000001 /* RW--V */
263
#define NV_PRAMDAC_GENERAL_CONTROL_BPC                        20:20 /* RWIVF */
264
#define NV_PRAMDAC_GENERAL_CONTROL_BPC_6BITS             0x00000000 /* RWI-V */
265
#define NV_PRAMDAC_GENERAL_CONTROL_BPC_8BITS             0x00000001 /* RW--V */
266
#define NV_PRAMDAC_GENERAL_CONTROL_DAC_SLEEP                  24:24 /* RWIVF */
267
#define NV_PRAMDAC_GENERAL_CONTROL_DAC_SLEEP_DIS         0x00000000 /* RWI-V */
268
#define NV_PRAMDAC_GENERAL_CONTROL_DAC_SLEEP_EN          0x00000001 /* RW--V */
269
#define NV_PRAMDAC_GENERAL_CONTROL_PALETTE_CLK                28:28 /* RWIVF */
270
#define NV_PRAMDAC_GENERAL_CONTROL_PALETTE_CLK_EN        0x00000000 /* RWI-V */
271
#define NV_PRAMDAC_GENERAL_CONTROL_PALETTE_CLK_DIS       0x00000001 /* RW--V */
272
273
/* Master Control */
274
#define NV_PMC                                0x00000FFF:0x00000000 /* RW--D */
275
#define NV_PMC_BOOT_0                                    0x00000000 /* R--4R */
276
#define NV_PMC_BOOT_0_MINOR_REVISION                            3:0 /* C--VF */
277
#define NV_PMC_BOOT_0_MINOR_REVISION_0                   0x00000000 /* C---V */
278
#define NV_PMC_BOOT_0_MAJOR_REVISION                            7:4 /* C--VF */
279
#define NV_PMC_BOOT_0_MAJOR_REVISION_A                   0x00000000 /* C---V */
280
#define NV_PMC_BOOT_0_MAJOR_REVISION_B                   0x00000001 /* ----V */
281
#define NV_PMC_BOOT_0_IMPLEMENTATION                           11:8 /* C--VF */
282
#define NV_PMC_BOOT_0_IMPLEMENTATION_NV4_0               0x00000000 /* C---V */
283
#define NV_PMC_BOOT_0_ARCHITECTURE                            15:12 /* C--VF */
284
#define NV_PMC_BOOT_0_ARCHITECTURE_NV0                   0x00000000 /* ----V */
285
#define NV_PMC_BOOT_0_ARCHITECTURE_NV1                   0x00000001 /* ----V */
286
#define NV_PMC_BOOT_0_ARCHITECTURE_NV2                   0x00000002 /* ----V */
287
#define NV_PMC_BOOT_0_ARCHITECTURE_NV3                   0x00000003 /* ----V */
288
#define NV_PMC_BOOT_0_ARCHITECTURE_NV4                   0x00000004 /* C---V */
289
#define NV_PMC_BOOT_0_FIB_REVISION                            19:16 /* C--VF */
290
#define NV_PMC_BOOT_0_FIB_REVISION_0                     0x00000000 /* C---V */
291
#define NV_PMC_BOOT_0_MASK_REVISION                           23:20 /* C--VF */
292
#define NV_PMC_BOOT_0_MASK_REVISION_A                    0x00000000 /* C---V */
293
#define NV_PMC_BOOT_0_MASK_REVISION_B                    0x00000001 /* ----V */
294
#define NV_PMC_BOOT_0_MANUFACTURER                            27:24 /* C--UF */
295
#define NV_PMC_BOOT_0_MANUFACTURER_NVIDIA                0x00000000 /* C---V */
296
#define NV_PMC_BOOT_0_FOUNDRY                                 31:28 /* C--VF */
297
#define NV_PMC_BOOT_0_FOUNDRY_SGS                        0x00000000 /* ----V */
298
#define NV_PMC_BOOT_0_FOUNDRY_HELIOS                     0x00000001 /* ----V */
299
#define NV_PMC_BOOT_0_FOUNDRY_TSMC                       0x00000002 /* C---V */
300
#define NV_PMC_INTR_0                                    0x00000100 /* RW-4R */
301
#define NV_PMC_INTR_0_PMEDIA                                    4:4 /* R--VF */
302
#define NV_PMC_INTR_0_PMEDIA_NOT_PENDING                 0x00000000 /* R---V */
303
#define NV_PMC_INTR_0_PMEDIA_PENDING                     0x00000001 /* R---V */
304
#define NV_PMC_INTR_0_PFIFO                                     8:8 /* R--VF */
305
#define NV_PMC_INTR_0_PFIFO_NOT_PENDING                  0x00000000 /* R---V */
306
#define NV_PMC_INTR_0_PFIFO_PENDING                      0x00000001 /* R---V */
307
#define NV_PMC_INTR_0_PGRAPH                                  12:12 /* R--VF */
308
#define NV_PMC_INTR_0_PGRAPH_NOT_PENDING                 0x00000000 /* R---V */
309
#define NV_PMC_INTR_0_PGRAPH_PENDING                     0x00000001 /* R---V */
310
#define NV_PMC_INTR_0_PVIDEO                                  16:16 /* R--VF */
311
#define NV_PMC_INTR_0_PVIDEO_NOT_PENDING                 0x00000000 /* R---V */
312
#define NV_PMC_INTR_0_PVIDEO_PENDING                     0x00000001 /* R---V */
313
#define NV_PMC_INTR_0_PTIMER                                  20:20 /* R--VF */
314
#define NV_PMC_INTR_0_PTIMER_NOT_PENDING                 0x00000000 /* R---V */
315
#define NV_PMC_INTR_0_PTIMER_PENDING                     0x00000001 /* R---V */
316
#define NV_PMC_INTR_0_PCRTC                                   24:24 /* R--VF */
317
#define NV_PMC_INTR_0_PCRTC_NOT_PENDING                  0x00000000 /* R---V */
318
#define NV_PMC_INTR_0_PCRTC_PENDING                      0x00000001 /* R---V */
319
#define NV_PMC_INTR_0_PBUS                                    28:28 /* R--VF */
320
#define NV_PMC_INTR_0_PBUS_NOT_PENDING                   0x00000000 /* R---V */
321
#define NV_PMC_INTR_0_PBUS_PENDING                       0x00000001 /* R---V */
322
#define NV_PMC_INTR_0_SOFTWARE                                31:31 /* RWIVF */
323
#define NV_PMC_INTR_0_SOFTWARE_NOT_PENDING               0x00000000 /* RWI-V */
324
#define NV_PMC_INTR_0_SOFTWARE_PENDING                   0x00000001 /* RW--V */
325
#define NV_PMC_INTR_EN_0                                 0x00000140 /* RW-4R */
326
#define NV_PMC_INTR_EN_0_INTA                                   1:0 /* RWIVF */
327
#define NV_PMC_INTR_EN_0_INTA_DISABLED                   0x00000000 /* RWI-V */
328
#define NV_PMC_INTR_EN_0_INTA_HARDWARE                   0x00000001 /* RW--V */
329
#define NV_PMC_INTR_EN_0_INTA_SOFTWARE                   0x00000002 /* RW--V */
330
#define NV_PMC_INTR_READ_0                               0x00000160 /* R--4R */
331
#define NV_PMC_INTR_READ_0_INTA                                 0:0 /* R--VF */
332
#define NV_PMC_INTR_READ_0_INTA_LOW                      0x00000000 /* R---V */
333
#define NV_PMC_INTR_READ_0_INTA_HIGH                     0x00000001 /* R---V */
334
#define NV_PMC_ENABLE                                    0x00000200 /* RW-4R */
335
#define NV_PMC_ENABLE_PMEDIA                                    4:4 /* RWIVF */
336
#define NV_PMC_ENABLE_PMEDIA_DISABLED                    0x00000000 /* RWI-V */
337
#define NV_PMC_ENABLE_PMEDIA_ENABLED                     0x00000001 /* RW--V */
338
#define NV_PMC_ENABLE_PFIFO                                     8:8 /* RWIVF */
339
#define NV_PMC_ENABLE_PFIFO_DISABLED                     0x00000000 /* RWI-V */
340
#define NV_PMC_ENABLE_PFIFO_ENABLED                      0x00000001 /* RW--V */
341
#define NV_PMC_ENABLE_PGRAPH                                  12:12 /* RWIVF */
342
#define NV_PMC_ENABLE_PGRAPH_DISABLED                    0x00000000 /* RWI-V */
343
#define NV_PMC_ENABLE_PGRAPH_ENABLED                     0x00000001 /* RW--V */
344
#define NV_PMC_ENABLE_PPMI                                    16:16 /* RWIVF */
345
#define NV_PMC_ENABLE_PPMI_DISABLED                      0x00000000 /* RWI-V */
346
#define NV_PMC_ENABLE_PPMI_ENABLED                       0x00000001 /* RW--V */
347
#define NV_PMC_ENABLE_PFB                                     20:20 /* RWIVF */
348
#define NV_PMC_ENABLE_PFB_DISABLED                       0x00000000 /* RW--V */
349
#define NV_PMC_ENABLE_PFB_ENABLED                        0x00000001 /* RWI-V */
350
#define NV_PMC_ENABLE_PCRTC                                   24:24 /* RWIVF */
351
#define NV_PMC_ENABLE_PCRTC_DISABLED                     0x00000000 /* RW--V */
352
#define NV_PMC_ENABLE_PCRTC_ENABLED                      0x00000001 /* RWI-V */
353
#define NV_PMC_ENABLE_PVIDEO                                  28:28 /* RWIVF */
354
#define NV_PMC_ENABLE_PVIDEO_DISABLED                    0x00000000 /* RWI-V */
355
#define NV_PMC_ENABLE_PVIDEO_ENABLED                     0x00000001 /* RW--V */
356
357
/* dev_timer.ref */
358
#define NV_PTIMER                             0x00009FFF:0x00009000 /* RW--D */
359
#define NV_PTIMER_INTR_0                                 0x00009100 /* RW-4R */
360
#define NV_PTIMER_INTR_0_ALARM                                  0:0 /* RWXVF */
361
#define NV_PTIMER_INTR_0_ALARM_NOT_PENDING               0x00000000 /* R---V */
362
#define NV_PTIMER_INTR_0_ALARM_PENDING                   0x00000001 /* R---V */
363
#define NV_PTIMER_INTR_0_ALARM_RESET                     0x00000001 /* -W--V */
364
#define NV_PTIMER_INTR_EN_0                              0x00009140 /* RW-4R */
365
#define NV_PTIMER_INTR_EN_0_ALARM                               0:0 /* RWIVF */
366
#define NV_PTIMER_INTR_EN_0_ALARM_DISABLED               0x00000000 /* RWI-V */
367
#define NV_PTIMER_INTR_EN_0_ALARM_ENABLED                0x00000001 /* RW--V */
368
#define NV_PTIMER_NUMERATOR                              0x00009200 /* RW-4R */
369
#define NV_PTIMER_NUMERATOR_VALUE                              15:0 /* RWIUF */
370
#define NV_PTIMER_NUMERATOR_VALUE_0                      0x00000000 /* RWI-V */
371
#define NV_PTIMER_DENOMINATOR                            0x00009210 /* RW-4R */
372
#define NV_PTIMER_DENOMINATOR_VALUE                            15:0 /* RWIUF */
373
#define NV_PTIMER_DENOMINATOR_VALUE_0                    0x00000000 /* RWI-V */
374
#define NV_PTIMER_TIME_0                                 0x00009400 /* RW-4R */
375
#define NV_PTIMER_TIME_0_NSEC                                  31:5 /* RWXUF */
376
#define NV_PTIMER_TIME_1                                 0x00009410 /* RW-4R */
377
#define NV_PTIMER_TIME_1_NSEC                                  28:0 /* RWXUF */
378
#define NV_PTIMER_ALARM_0                                0x00009420 /* RW-4R */
379
#define NV_PTIMER_ALARM_0_NSEC                                 31:5 /* RWXUF */
380
381
/* dev_fifo.ref */
382
#define NV_PFIFO                              0x00003FFF:0x00002000 /* RW--D */
383
#define NV_PFIFO_DELAY_0                                 0x00002040 /* RW-4R */
384
#define NV_PFIFO_DELAY_0_WAIT_RETRY                             9:0 /* RWIUF */
385
#define NV_PFIFO_DELAY_0_WAIT_RETRY_0                    0x00000000 /* RWI-V */
386
#define NV_PFIFO_DMA_TIMESLICE                           0x00002044 /* RW-4R */
387
#define NV_PFIFO_DMA_TIMESLICE_SELECT                          16:0 /* RWIUF */
388
#define NV_PFIFO_DMA_TIMESLICE_SELECT_1                  0x00000000 /* RWI-V */
389
#define NV_PFIFO_DMA_TIMESLICE_SELECT_16K                0x00003fff /* RW--V */
390
#define NV_PFIFO_DMA_TIMESLICE_SELECT_32K                0x00007fff /* RW--V */
391
#define NV_PFIFO_DMA_TIMESLICE_SELECT_64K                0x0000ffff /* RW--V */
392
#define NV_PFIFO_DMA_TIMESLICE_SELECT_128K               0x0001ffff /* RW--V */
393
#define NV_PFIFO_DMA_TIMESLICE_TIMEOUT                        24:24 /* RWIUF */
394
#define NV_PFIFO_DMA_TIMESLICE_TIMEOUT_DISABLED          0x00000000 /* RW--V */
395
#define NV_PFIFO_DMA_TIMESLICE_TIMEOUT_ENABLED           0x00000001 /* RWI-V */
396
#define NV_PFIFO_PIO_TIMESLICE                           0x00002048 /* RW-4R */
397
#define NV_PFIFO_PIO_TIMESLICE_SELECT                          16:0 /* RWIUF */
398
#define NV_PFIFO_PIO_TIMESLICE_SELECT_1                  0x00000000 /* RWI-V */
399
#define NV_PFIFO_PIO_TIMESLICE_SELECT_16K                0x00003fff /* RW--V */
400
#define NV_PFIFO_PIO_TIMESLICE_SELECT_32K                0x00007fff /* RW--V */
401
#define NV_PFIFO_PIO_TIMESLICE_SELECT_64K                0x0000ffff /* RW--V */
402
#define NV_PFIFO_PIO_TIMESLICE_SELECT_128K               0x0001ffff /* RW--V */
403
#define NV_PFIFO_PIO_TIMESLICE_TIMEOUT                        24:24 /* RWIUF */
404
#define NV_PFIFO_PIO_TIMESLICE_TIMEOUT_DISABLED          0x00000000 /* RW--V */
405
#define NV_PFIFO_PIO_TIMESLICE_TIMEOUT_ENABLED           0x00000001 /* RWI-V */
406
#define NV_PFIFO_TIMESLICE                               0x0000204C /* RW-4R */
407
#define NV_PFIFO_TIMESLICE_TIMER                               17:0 /* RWIUF */
408
#define NV_PFIFO_TIMESLICE_TIMER_EXPIRED                 0x0003FFFF /* RWI-V */
409
#define NV_PFIFO_NEXT_CHANNEL                            0x00002050 /* RW-4R */
410
#define NV_PFIFO_NEXT_CHANNEL_CHID                              3:0 /* RWXUF */
411
#define NV_PFIFO_NEXT_CHANNEL_MODE                              8:8 /* RWXVF */
412
#define NV_PFIFO_NEXT_CHANNEL_MODE_PIO                   0x00000000 /* RW--V */
413
#define NV_PFIFO_NEXT_CHANNEL_MODE_DMA                   0x00000001 /* RW--V */
414
#define NV_PFIFO_NEXT_CHANNEL_SWITCH                          12:12 /* RWIVF */
415
#define NV_PFIFO_NEXT_CHANNEL_SWITCH_NOT_PENDING         0x00000000 /* RWI-V */
416
#define NV_PFIFO_NEXT_CHANNEL_SWITCH_PENDING             0x00000001 /* RW--V */
417
#define NV_PFIFO_DEBUG_0                                 0x00002080 /* R--4R */
418
#define NV_PFIFO_DEBUG_0_CACHE_ERROR0                           0:0 /* R-XVF */
419
#define NV_PFIFO_DEBUG_0_CACHE_ERROR0_NOT_PENDING        0x00000000 /* R---V */
420
#define NV_PFIFO_DEBUG_0_CACHE_ERROR0_PENDING            0x00000001 /* R---V */
421
#define NV_PFIFO_DEBUG_0_CACHE_ERROR1                           4:4 /* R-XVF */
422
#define NV_PFIFO_DEBUG_0_CACHE_ERROR1_NOT_PENDING        0x00000000 /* R---V */
423
#define NV_PFIFO_DEBUG_0_CACHE_ERROR1_PENDING            0x00000001 /* R---V */
424
#define NV_PFIFO_INTR_0                                  0x00002100 /* RW-4R */
425
#define NV_PFIFO_INTR_0_CACHE_ERROR                             0:0 /* RWXVF */
426
#define NV_PFIFO_INTR_0_CACHE_ERROR_NOT_PENDING          0x00000000 /* R---V */
427
#define NV_PFIFO_INTR_0_CACHE_ERROR_PENDING              0x00000001 /* R---V */
428
#define NV_PFIFO_INTR_0_CACHE_ERROR_RESET                0x00000001 /* -W--V */
429
#define NV_PFIFO_INTR_0_RUNOUT                                  4:4 /* RWXVF */
430
#define NV_PFIFO_INTR_0_RUNOUT_NOT_PENDING               0x00000000 /* R---V */
431
#define NV_PFIFO_INTR_0_RUNOUT_PENDING                   0x00000001 /* R---V */
432
#define NV_PFIFO_INTR_0_RUNOUT_RESET                     0x00000001 /* -W--V */
433
#define NV_PFIFO_INTR_0_RUNOUT_OVERFLOW                         8:8 /* RWXVF */
434
#define NV_PFIFO_INTR_0_RUNOUT_OVERFLOW_NOT_PENDING      0x00000000 /* R---V */
435
#define NV_PFIFO_INTR_0_RUNOUT_OVERFLOW_PENDING          0x00000001 /* R---V */
436
#define NV_PFIFO_INTR_0_RUNOUT_OVERFLOW_RESET            0x00000001 /* -W--V */
437
#define NV_PFIFO_INTR_0_DMA_PUSHER                            12:12 /* RWXVF */
438
#define NV_PFIFO_INTR_0_DMA_PUSHER_NOT_PENDING           0x00000000 /* R---V */
439
#define NV_PFIFO_INTR_0_DMA_PUSHER_PENDING               0x00000001 /* R---V */
440
#define NV_PFIFO_INTR_0_DMA_PUSHER_RESET                 0x00000001 /* -W--V */
441
#define NV_PFIFO_INTR_0_DMA_PT                                16:16 /* RWXVF */
442
#define NV_PFIFO_INTR_0_DMA_PT_NOT_PENDING               0x00000000 /* R---V */
443
#define NV_PFIFO_INTR_0_DMA_PT_PENDING                   0x00000001 /* R---V */
444
#define NV_PFIFO_INTR_0_DMA_PT_RESET                     0x00000001 /* -W--V */
445
#define NV_PFIFO_INTR_EN_0                               0x00002140 /* RW-4R */
446
#define NV_PFIFO_INTR_EN_0_CACHE_ERROR                          0:0 /* RWIVF */
447
#define NV_PFIFO_INTR_EN_0_CACHE_ERROR_DISABLED          0x00000000 /* RWI-V */
448
#define NV_PFIFO_INTR_EN_0_CACHE_ERROR_ENABLED           0x00000001 /* RW--V */
449
#define NV_PFIFO_INTR_EN_0_RUNOUT                               4:4 /* RWIVF */
450
#define NV_PFIFO_INTR_EN_0_RUNOUT_DISABLED               0x00000000 /* RWI-V */
451
#define NV_PFIFO_INTR_EN_0_RUNOUT_ENABLED                0x00000001 /* RW--V */
452
#define NV_PFIFO_INTR_EN_0_RUNOUT_OVERFLOW                      8:8 /* RWIVF */
453
#define NV_PFIFO_INTR_EN_0_RUNOUT_OVERFLOW_DISABLED      0x00000000 /* RWI-V */
454
#define NV_PFIFO_INTR_EN_0_RUNOUT_OVERFLOW_ENABLED       0x00000001 /* RW--V */
455
#define NV_PFIFO_INTR_EN_0_DMA_PUSHER                         12:12 /* RWIVF */
456
#define NV_PFIFO_INTR_EN_0_DMA_PUSHER_DISABLED           0x00000000 /* RWI-V */
457
#define NV_PFIFO_INTR_EN_0_DMA_PUSHER_ENABLED            0x00000001 /* RW--V */
458
#define NV_PFIFO_INTR_EN_0_DMA_PT                             16:16 /* RWIVF */
459
#define NV_PFIFO_INTR_EN_0_DMA_PT_DISABLED               0x00000000 /* RWI-V */
460
#define NV_PFIFO_INTR_EN_0_DMA_PT_ENABLED                0x00000001 /* RW--V */
461
#define NV_PFIFO_RAMHT                                   0x00002210 /* RW-4R */
462
#define NV_PFIFO_RAMHT_BASE_ADDRESS                             8:4 /* RWIUF */
463
#define NV_PFIFO_RAMHT_BASE_ADDRESS_10000                0x00000010 /* RWI-V */
464
#define NV_PFIFO_RAMHT_SIZE                                   17:16 /* RWIUF */
465
#define NV_PFIFO_RAMHT_SIZE_4K                           0x00000000 /* RWI-V */
466
#define NV_PFIFO_RAMHT_SIZE_8K                           0x00000001 /* RW--V */
467
#define NV_PFIFO_RAMHT_SIZE_16K                          0x00000002 /* RW--V */
468
#define NV_PFIFO_RAMHT_SIZE_32K                          0x00000003 /* RW--V */
469
#define NV_PFIFO_RAMHT_SEARCH                                 25:24 /* RWIUF */
470
#define NV_PFIFO_RAMHT_SEARCH_16                         0x00000000 /* RWI-V */
471
#define NV_PFIFO_RAMHT_SEARCH_32                         0x00000001 /* RW--V */
472
#define NV_PFIFO_RAMHT_SEARCH_64                         0x00000002 /* RW--V */
473
#define NV_PFIFO_RAMHT_SEARCH_128                        0x00000003 /* RW--V */
474
#define NV_PFIFO_RAMFC                                   0x00002214 /* RW-4R */
475
#define NV_PFIFO_RAMFC_BASE_ADDRESS                             8:1 /* RWIUF */
476
#define NV_PFIFO_RAMFC_BASE_ADDRESS_11000                0x00000088 /* RWI-V */
477
#define NV_PFIFO_RAMRO                                   0x00002218 /* RW-4R */
478
#define NV_PFIFO_RAMRO_BASE_ADDRESS                             8:1 /* RWIUF */
479
#define NV_PFIFO_RAMRO_BASE_ADDRESS_11200                0x00000089 /* RWI-V */
480
#define NV_PFIFO_RAMRO_BASE_ADDRESS_12000                0x00000090 /* RW--V */
481
#define NV_PFIFO_RAMRO_SIZE                                   16:16 /* RWIVF */
482
#define NV_PFIFO_RAMRO_SIZE_512                          0x00000000 /* RWI-V */
483
#define NV_PFIFO_RAMRO_SIZE_8K                           0x00000001 /* RW--V */
484
#define NV_PFIFO_CACHES                                  0x00002500 /* RW-4R */
485
#define NV_PFIFO_CACHES_REASSIGN                                0:0 /* RWIVF */
486
#define NV_PFIFO_CACHES_REASSIGN_DISABLED                0x00000000 /* RWI-V */
487
#define NV_PFIFO_CACHES_REASSIGN_ENABLED                 0x00000001 /* RW--V */
488
#define NV_PFIFO_CACHES_DMA_SUSPEND                             4:4 /* R--VF */
489
#define NV_PFIFO_CACHES_DMA_SUSPEND_IDLE                 0x00000000 /* R---V */
490
#define NV_PFIFO_CACHES_DMA_SUSPEND_BUSY                 0x00000001 /* R---V */
491
#define NV_PFIFO_MODE                                    0x00002504 /* RW-4R */
492
#define NV_PFIFO_MODE_CHANNEL_0                                 0:0 /* RWIVF */
493
#define NV_PFIFO_MODE_CHANNEL_0_PIO                      0x00000000 /* RWI-V */
494
#define NV_PFIFO_MODE_CHANNEL_0_DMA                      0x00000001 /* RW--V */
495
#define NV_PFIFO_MODE_CHANNEL_1                                 1:1 /* RWIVF */
496
#define NV_PFIFO_MODE_CHANNEL_1_PIO                      0x00000000 /* RWI-V */
497
#define NV_PFIFO_MODE_CHANNEL_1_DMA                      0x00000001 /* RW--V */
498
#define NV_PFIFO_MODE_CHANNEL_2                                 2:2 /* RWIVF */
499
#define NV_PFIFO_MODE_CHANNEL_2_PIO                      0x00000000 /* RWI-V */
500
#define NV_PFIFO_MODE_CHANNEL_2_DMA                      0x00000001 /* RW--V */
501
#define NV_PFIFO_MODE_CHANNEL_3                                 3:3 /* RWIVF */
502
#define NV_PFIFO_MODE_CHANNEL_3_PIO                      0x00000000 /* RWI-V */
503
#define NV_PFIFO_MODE_CHANNEL_3_DMA                      0x00000001 /* RW--V */
504
#define NV_PFIFO_MODE_CHANNEL_4                                 4:4 /* RWIVF */
505
#define NV_PFIFO_MODE_CHANNEL_4_PIO                      0x00000000 /* RWI-V */
506
#define NV_PFIFO_MODE_CHANNEL_4_DMA                      0x00000001 /* RW--V */
507
#define NV_PFIFO_MODE_CHANNEL_5                                 5:5 /* RWIVF */
508
#define NV_PFIFO_MODE_CHANNEL_5_PIO                      0x00000000 /* RWI-V */
509
#define NV_PFIFO_MODE_CHANNEL_5_DMA                      0x00000001 /* RW--V */
510
#define NV_PFIFO_MODE_CHANNEL_6                                 6:6 /* RWIVF */
511
#define NV_PFIFO_MODE_CHANNEL_6_PIO                      0x00000000 /* RWI-V */
512
#define NV_PFIFO_MODE_CHANNEL_6_DMA                      0x00000001 /* RW--V */
513
#define NV_PFIFO_MODE_CHANNEL_7                                 7:7 /* RWIVF */
514
#define NV_PFIFO_MODE_CHANNEL_7_PIO                      0x00000000 /* RWI-V */
515
#define NV_PFIFO_MODE_CHANNEL_7_DMA                      0x00000001 /* RW--V */
516
#define NV_PFIFO_MODE_CHANNEL_8                                 8:8 /* RWIVF */
517
#define NV_PFIFO_MODE_CHANNEL_8_PIO                      0x00000000 /* RWI-V */
518
#define NV_PFIFO_MODE_CHANNEL_8_DMA                      0x00000001 /* RW--V */
519
#define NV_PFIFO_MODE_CHANNEL_9                                 9:9 /* RWIVF */
520
#define NV_PFIFO_MODE_CHANNEL_9_PIO                      0x00000000 /* RWI-V */
521
#define NV_PFIFO_MODE_CHANNEL_9_DMA                      0x00000001 /* RW--V */
522
#define NV_PFIFO_MODE_CHANNEL_10                              10:10 /* RWIVF */
523
#define NV_PFIFO_MODE_CHANNEL_10_PIO                     0x00000000 /* RWI-V */
524
#define NV_PFIFO_MODE_CHANNEL_10_DMA                     0x00000001 /* RW--V */
525
#define NV_PFIFO_MODE_CHANNEL_11                              11:11 /* RWIVF */
526
#define NV_PFIFO_MODE_CHANNEL_11_PIO                     0x00000000 /* RWI-V */
527
#define NV_PFIFO_MODE_CHANNEL_11_DMA                     0x00000001 /* RW--V */
528
#define NV_PFIFO_MODE_CHANNEL_12                              12:12 /* RWIVF */
529
#define NV_PFIFO_MODE_CHANNEL_12_PIO                     0x00000000 /* RWI-V */
530
#define NV_PFIFO_MODE_CHANNEL_12_DMA                     0x00000001 /* RW--V */
531
#define NV_PFIFO_MODE_CHANNEL_13                              13:13 /* RWIVF */
532
#define NV_PFIFO_MODE_CHANNEL_13_PIO                     0x00000000 /* RWI-V */
533
#define NV_PFIFO_MODE_CHANNEL_13_DMA                     0x00000001 /* RW--V */
534
#define NV_PFIFO_MODE_CHANNEL_14                              14:14 /* RWIVF */
535
#define NV_PFIFO_MODE_CHANNEL_14_PIO                     0x00000000 /* RWI-V */
536
#define NV_PFIFO_MODE_CHANNEL_14_DMA                     0x00000001 /* RW--V */
537
#define NV_PFIFO_MODE_CHANNEL_15                              15:15 /* RWIVF */
538
#define NV_PFIFO_MODE_CHANNEL_15_PIO                     0x00000000 /* RWI-V */
539
#define NV_PFIFO_MODE_CHANNEL_15_DMA                     0x00000001 /* RW--V */
540
#define NV_PFIFO_DMA                                     0x00002508 /* RW-4R */
541
#define NV_PFIFO_DMA_CHANNEL_0                                  0:0 /* RWIVF */
542
#define NV_PFIFO_DMA_CHANNEL_0_NOT_PENDING               0x00000000 /* RWI-V */
543
#define NV_PFIFO_DMA_CHANNEL_0_PENDING                   0x00000001 /* RW--V */
544
#define NV_PFIFO_DMA_CHANNEL_1                                  1:1 /* RWIVF */
545
#define NV_PFIFO_DMA_CHANNEL_1_NOT_PENDING               0x00000000 /* RWI-V */
546
#define NV_PFIFO_DMA_CHANNEL_1_PENDING                   0x00000001 /* RW--V */
547
#define NV_PFIFO_DMA_CHANNEL_2                                  2:2 /* RWIVF */
548
#define NV_PFIFO_DMA_CHANNEL_2_NOT_PENDING               0x00000000 /* RWI-V */
549
#define NV_PFIFO_DMA_CHANNEL_2_PENDING                   0x00000001 /* RW--V */
550
#define NV_PFIFO_DMA_CHANNEL_3                                  3:3 /* RWIVF */
551
#define NV_PFIFO_DMA_CHANNEL_3_NOT_PENDING               0x00000000 /* RWI-V */
552
#define NV_PFIFO_DMA_CHANNEL_3_PENDING                   0x00000001 /* RW--V */
553
#define NV_PFIFO_DMA_CHANNEL_4                                  4:4 /* RWIVF */
554
#define NV_PFIFO_DMA_CHANNEL_4_NOT_PENDING               0x00000000 /* RWI-V */
555
#define NV_PFIFO_DMA_CHANNEL_4_PENDING                   0x00000001 /* RW--V */
556
#define NV_PFIFO_DMA_CHANNEL_5                                  5:5 /* RWIVF */
557
#define NV_PFIFO_DMA_CHANNEL_5_NOT_PENDING               0x00000000 /* RWI-V */
558
#define NV_PFIFO_DMA_CHANNEL_5_PENDING                   0x00000001 /* RW--V */
559
#define NV_PFIFO_DMA_CHANNEL_6                                  6:6 /* RWIVF */
560
#define NV_PFIFO_DMA_CHANNEL_6_NOT_PENDING               0x00000000 /* RWI-V */
561
#define NV_PFIFO_DMA_CHANNEL_6_PENDING                   0x00000001 /* RW--V */
562
#define NV_PFIFO_DMA_CHANNEL_7                                  7:7 /* RWIVF */
563
#define NV_PFIFO_DMA_CHANNEL_7_NOT_PENDING               0x00000000 /* RWI-V */
564
#define NV_PFIFO_DMA_CHANNEL_7_PENDING                   0x00000001 /* RW--V */
565
#define NV_PFIFO_DMA_CHANNEL_8                                  8:8 /* RWIVF */
566
#define NV_PFIFO_DMA_CHANNEL_8_NOT_PENDING               0x00000000 /* RWI-V */
567
#define NV_PFIFO_DMA_CHANNEL_8_PENDING                   0x00000001 /* RW--V */
568
#define NV_PFIFO_DMA_CHANNEL_9                                  9:9 /* RWIVF */
569
#define NV_PFIFO_DMA_CHANNEL_9_NOT_PENDING               0x00000000 /* RWI-V */
570
#define NV_PFIFO_DMA_CHANNEL_9_PENDING                   0x00000001 /* RW--V */
571
#define NV_PFIFO_DMA_CHANNEL_10                               10:10 /* RWIVF */
572
#define NV_PFIFO_DMA_CHANNEL_10_NOT_PENDING              0x00000000 /* RWI-V */
573
#define NV_PFIFO_DMA_CHANNEL_10_PENDING                  0x00000001 /* RW--V */
574
#define NV_PFIFO_DMA_CHANNEL_11                               11:11 /* RWIVF */
575
#define NV_PFIFO_DMA_CHANNEL_11_NOT_PENDING              0x00000000 /* RWI-V */
576
#define NV_PFIFO_DMA_CHANNEL_11_PENDING                  0x00000001 /* RW--V */
577
#define NV_PFIFO_DMA_CHANNEL_12                               12:12 /* RWIVF */
578
#define NV_PFIFO_DMA_CHANNEL_12_NOT_PENDING              0x00000000 /* RWI-V */
579
#define NV_PFIFO_DMA_CHANNEL_12_PENDING                  0x00000001 /* RW--V */
580
#define NV_PFIFO_DMA_CHANNEL_13                               13:13 /* RWIVF */
581
#define NV_PFIFO_DMA_CHANNEL_13_NOT_PENDING              0x00000000 /* RWI-V */
582
#define NV_PFIFO_DMA_CHANNEL_13_PENDING                  0x00000001 /* RW--V */
583
#define NV_PFIFO_DMA_CHANNEL_14                               14:14 /* RWIVF */
584
#define NV_PFIFO_DMA_CHANNEL_14_NOT_PENDING              0x00000000 /* RWI-V */
585
#define NV_PFIFO_DMA_CHANNEL_14_PENDING                  0x00000001 /* RW--V */
586
#define NV_PFIFO_DMA_CHANNEL_15                               15:15 /* RWIVF */
587
#define NV_PFIFO_DMA_CHANNEL_15_NOT_PENDING              0x00000000 /* RWI-V */
588
#define NV_PFIFO_DMA_CHANNEL_15_PENDING                  0x00000001 /* RW--V */
589
#define NV_PFIFO_SIZE                                    0x0000250C /* RW-4R */
590
#define NV_PFIFO_SIZE_CHANNEL_0                                 0:0 /* RWIVF */
591
#define NV_PFIFO_SIZE_CHANNEL_0_124_BYTES                0x00000000 /* RWI-V */
592
#define NV_PFIFO_SIZE_CHANNEL_0_512_BYTES                0x00000001 /* RW--V */
593
#define NV_PFIFO_SIZE_CHANNEL_1                                 1:1 /* RWIVF */
594
#define NV_PFIFO_SIZE_CHANNEL_1_124_BYTES                0x00000000 /* RWI-V */
595
#define NV_PFIFO_SIZE_CHANNEL_1_512_BYTES                0x00000001 /* RW--V */
596
#define NV_PFIFO_SIZE_CHANNEL_2                                 2:2 /* RWIVF */
597
#define NV_PFIFO_SIZE_CHANNEL_2_124_BYTES                0x00000000 /* RWI-V */
598
#define NV_PFIFO_SIZE_CHANNEL_2_512_BYTES                0x00000001 /* RW--V */
599
#define NV_PFIFO_SIZE_CHANNEL_3                                 3:3 /* RWIVF */
600
#define NV_PFIFO_SIZE_CHANNEL_3_124_BYTES                0x00000000 /* RWI-V */
601
#define NV_PFIFO_SIZE_CHANNEL_3_512_BYTES                0x00000001 /* RW--V */
602
#define NV_PFIFO_SIZE_CHANNEL_4                                 4:4 /* RWIVF */
603
#define NV_PFIFO_SIZE_CHANNEL_4_124_BYTES                0x00000000 /* RWI-V */
604
#define NV_PFIFO_SIZE_CHANNEL_4_512_BYTES                0x00000001 /* RW--V */
605
#define NV_PFIFO_SIZE_CHANNEL_5                                 5:5 /* RWIVF */
606
#define NV_PFIFO_SIZE_CHANNEL_5_124_BYTES                0x00000000 /* RWI-V */
607
#define NV_PFIFO_SIZE_CHANNEL_5_512_BYTES                0x00000001 /* RW--V */
608
#define NV_PFIFO_SIZE_CHANNEL_6                                 6:6 /* RWIVF */
609
#define NV_PFIFO_SIZE_CHANNEL_6_124_BYTES                0x00000000 /* RWI-V */
610
#define NV_PFIFO_SIZE_CHANNEL_6_512_BYTES                0x00000001 /* RW--V */
611
#define NV_PFIFO_SIZE_CHANNEL_7                                 7:7 /* RWIVF */
612
#define NV_PFIFO_SIZE_CHANNEL_7_124_BYTES                0x00000000 /* RWI-V */
613
#define NV_PFIFO_SIZE_CHANNEL_7_512_BYTES                0x00000001 /* RW--V */
614
#define NV_PFIFO_SIZE_CHANNEL_8                                 8:8 /* RWIVF */
615
#define NV_PFIFO_SIZE_CHANNEL_8_124_BYTES                0x00000000 /* RWI-V */
616
#define NV_PFIFO_SIZE_CHANNEL_8_512_BYTES                0x00000001 /* RW--V */
617
#define NV_PFIFO_SIZE_CHANNEL_9                                 9:9 /* RWIVF */
618
#define NV_PFIFO_SIZE_CHANNEL_9_124_BYTES                0x00000000 /* RWI-V */
619
#define NV_PFIFO_SIZE_CHANNEL_9_512_BYTES                0x00000001 /* RW--V */
620
#define NV_PFIFO_SIZE_CHANNEL_10                              10:10 /* RWIVF */
621
#define NV_PFIFO_SIZE_CHANNEL_10_124_BYTES               0x00000000 /* RWI-V */
622
#define NV_PFIFO_SIZE_CHANNEL_10_512_BYTES               0x00000001 /* RW--V */
623
#define NV_PFIFO_SIZE_CHANNEL_11                              11:11 /* RWIVF */
624
#define NV_PFIFO_SIZE_CHANNEL_11_124_BYTES               0x00000000 /* RWI-V */
625
#define NV_PFIFO_SIZE_CHANNEL_11_512_BYTES               0x00000001 /* RW--V */
626
#define NV_PFIFO_SIZE_CHANNEL_12                              12:12 /* RWIVF */
627
#define NV_PFIFO_SIZE_CHANNEL_12_124_BYTES               0x00000000 /* RWI-V */
628
#define NV_PFIFO_SIZE_CHANNEL_12_512_BYTES               0x00000001 /* RW--V */
629
#define NV_PFIFO_SIZE_CHANNEL_13                              13:13 /* RWIVF */
630
#define NV_PFIFO_SIZE_CHANNEL_13_124_BYTES               0x00000000 /* RWI-V */
631
#define NV_PFIFO_SIZE_CHANNEL_13_512_BYTES               0x00000001 /* RW--V */
632
#define NV_PFIFO_SIZE_CHANNEL_14                              14:14 /* RWIVF */
633
#define NV_PFIFO_SIZE_CHANNEL_14_124_BYTES               0x00000000 /* RWI-V */
634
#define NV_PFIFO_SIZE_CHANNEL_14_512_BYTES               0x00000001 /* RW--V */
635
#define NV_PFIFO_SIZE_CHANNEL_15                              15:15 /* RWIVF */
636
#define NV_PFIFO_SIZE_CHANNEL_15_124_BYTES               0x00000000 /* RWI-V */
637
#define NV_PFIFO_SIZE_CHANNEL_15_512_BYTES               0x00000001 /* RW--V */
638
#define NV_PFIFO_CACHE0_PUSH0                            0x00003000 /* RW-4R */
639
#define NV_PFIFO_CACHE0_PUSH0_ACCESS                            0:0 /* RWIVF */
640
#define NV_PFIFO_CACHE0_PUSH0_ACCESS_DISABLED            0x00000000 /* RWI-V */
641
#define NV_PFIFO_CACHE0_PUSH0_ACCESS_ENABLED             0x00000001 /* RW--V */
642
#define NV_PFIFO_CACHE1_PUSH0                            0x00003200 /* RW-4R */
643
#define NV_PFIFO_CACHE1_PUSH0_ACCESS                            0:0 /* RWIVF */
644
#define NV_PFIFO_CACHE1_PUSH0_ACCESS_DISABLED            0x00000000 /* RWI-V */
645
#define NV_PFIFO_CACHE1_PUSH0_ACCESS_ENABLED             0x00000001 /* RW--V */
646
#define NV_PFIFO_CACHE0_PUSH1                            0x00003004 /* RW-4R */
647
#define NV_PFIFO_CACHE0_PUSH1_CHID                              3:0 /* RWXUF */
648
#define NV_PFIFO_CACHE1_PUSH1                            0x00003204 /* RW-4R */
649
#define NV_PFIFO_CACHE1_PUSH1_CHID                              3:0 /* RWXUF */
650
#define NV_PFIFO_CACHE1_PUSH1_MODE                              8:8 /* RWIVF */
651
#define NV_PFIFO_CACHE1_PUSH1_MODE_PIO                   0x00000000 /* RWI-V */
652
#define NV_PFIFO_CACHE1_PUSH1_MODE_DMA                   0x00000001 /* RW--V */
653
#define NV_PFIFO_CACHE1_DMA_PUSH                         0x00003220 /* RW-4R */
654
#define NV_PFIFO_CACHE1_DMA_PUSH_ACCESS                         0:0 /* RWIVF */
655
#define NV_PFIFO_CACHE1_DMA_PUSH_ACCESS_DISABLED         0x00000000 /* RWI-V */
656
#define NV_PFIFO_CACHE1_DMA_PUSH_ACCESS_ENABLED          0x00000001 /* RW--V */
657
#define NV_PFIFO_CACHE1_DMA_PUSH_STATE                          4:4 /* R--VF */
658
#define NV_PFIFO_CACHE1_DMA_PUSH_STATE_IDLE              0x00000000 /* R---V */
659
#define NV_PFIFO_CACHE1_DMA_PUSH_STATE_BUSY              0x00000001 /* R---V */
660
#define NV_PFIFO_CACHE1_DMA_PUSH_BUFFER                         8:8 /* R--VF */
661
#define NV_PFIFO_CACHE1_DMA_PUSH_BUFFER_NOT_EMPTY        0x00000000 /* R---V */
662
#define NV_PFIFO_CACHE1_DMA_PUSH_BUFFER_EMPTY            0x00000001 /* R---V */
663
#define NV_PFIFO_CACHE1_DMA_PUSH_STATUS                       12:12 /* RWIVF */
664
#define NV_PFIFO_CACHE1_DMA_PUSH_STATUS_RUNNING          0x00000000 /* RWI-V */
665
#define NV_PFIFO_CACHE1_DMA_PUSH_STATUS_SUSPENDED        0x00000001 /* RW--V */
666
#define NV_PFIFO_CACHE1_DMA_FETCH                        0x00003224 /* RW-4R */
667
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG                          7:3 /* RWIUF */
668
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_8_BYTES           0x00000000 /* RW--V */
669
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_16_BYTES          0x00000001 /* RW--V */
670
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_24_BYTES          0x00000002 /* RW--V */
671
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_32_BYTES          0x00000003 /* RW--V */
672
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_40_BYTES          0x00000004 /* RW--V */
673
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_48_BYTES          0x00000005 /* RW--V */
674
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_56_BYTES          0x00000006 /* RW--V */
675
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_64_BYTES          0x00000007 /* RW--V */
676
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_72_BYTES          0x00000008 /* RW--V */
677
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_80_BYTES          0x00000009 /* RW--V */
678
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_88_BYTES          0x0000000A /* RW--V */
679
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_96_BYTES          0x0000000B /* RW--V */
680
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_104_BYTES         0x0000000C /* RW--V */
681
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_112_BYTES         0x0000000D /* RW--V */
682
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_120_BYTES         0x0000000E /* RW--V */
683
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_128_BYTES         0x0000000F /* RWI-V */
684
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_136_BYTES         0x00000010 /* RW--V */
685
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_144_BYTES         0x00000011 /* RW--V */
686
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_152_BYTES         0x00000012 /* RW--V */
687
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_160_BYTES         0x00000013 /* RW--V */
688
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_168_BYTES         0x00000014 /* RW--V */
689
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_176_BYTES         0x00000015 /* RW--V */
690
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_184_BYTES         0x00000016 /* RW--V */
691
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_192_BYTES         0x00000017 /* RW--V */
692
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_200_BYTES         0x00000018 /* RW--V */
693
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_208_BYTES         0x00000019 /* RW--V */
694
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_216_BYTES         0x0000001A /* RW--V */
695
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_224_BYTES         0x0000001B /* RW--V */
696
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_232_BYTES         0x0000001C /* RW--V */
697
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_240_BYTES         0x0000001D /* RW--V */
698
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_248_BYTES         0x0000001E /* RW--V */
699
#define NV_PFIFO_CACHE1_DMA_FETCH_TRIG_256_BYTES         0x0000001F /* RW--V */
700
#define NV_PFIFO_CACHE1_DMA_FETCH_SIZE                        15:13 /* RWIUF */
701
#define NV_PFIFO_CACHE1_DMA_FETCH_SIZE_32_BYTES          0x00000000 /* RW--V */
702
#define NV_PFIFO_CACHE1_DMA_FETCH_SIZE_64_BYTES          0x00000001 /* RW--V */
703
#define NV_PFIFO_CACHE1_DMA_FETCH_SIZE_96_BYTES          0x00000002 /* RW--V */
704
#define NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES         0x00000003 /* RWI-V */
705
#define NV_PFIFO_CACHE1_DMA_FETCH_SIZE_160_BYTES         0x00000004 /* RW--V */
706
#define NV_PFIFO_CACHE1_DMA_FETCH_SIZE_192_BYTES         0x00000005 /* RW--V */
707
#define NV_PFIFO_CACHE1_DMA_FETCH_SIZE_224_BYTES         0x00000006 /* RW--V */
708
#define NV_PFIFO_CACHE1_DMA_FETCH_SIZE_256_BYTES         0x00000007 /* RW--V */
709
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS                    19:16 /* RWIUF */
710
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_0             0x00000000 /* RWI-V */
711
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_1             0x00000001 /* RW--V */
712
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_2             0x00000002 /* RW--V */
713
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_3             0x00000003 /* RW--V */
714
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_4             0x00000004 /* RW--V */
715
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_5             0x00000005 /* RW--V */
716
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_6             0x00000006 /* RW--V */
717
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_7             0x00000007 /* RW--V */
718
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_8             0x00000008 /* RW--V */
719
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_9             0x00000009 /* RW--V */
720
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_10            0x0000000A /* RW--V */
721
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_11            0x0000000B /* RW--V */
722
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_12            0x0000000C /* RW--V */
723
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_13            0x0000000D /* RW--V */
724
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_14            0x0000000E /* RW--V */
725
#define NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_15            0x0000000F /* RW--V */
726
#define NV_PFIFO_CACHE1_DMA_PUT                          0x00003240 /* RW-4R */
727
#define NV_PFIFO_CACHE1_DMA_PUT_OFFSET                         28:2 /* RWXUF */
728
#define NV_PFIFO_CACHE1_DMA_GET                          0x00003244 /* RW-4R */
729
#define NV_PFIFO_CACHE1_DMA_GET_OFFSET                         28:2 /* RWXUF */
730
#define NV_PFIFO_CACHE1_DMA_STATE                        0x00003228 /* RW-4R */
731
#define NV_PFIFO_CACHE1_DMA_STATE_METHOD                       12:2 /* RWXUF */
732
#define NV_PFIFO_CACHE1_DMA_STATE_SUBCHANNEL                  15:13 /* RWXUF */
733
#define NV_PFIFO_CACHE1_DMA_STATE_METHOD_COUNT                28:18 /* RWIUF */
734
#define NV_PFIFO_CACHE1_DMA_STATE_METHOD_COUNT_0         0x00000000 /* RWI-V */
735
#define NV_PFIFO_CACHE1_DMA_STATE_ERROR                       31:30 /* RWXUF */
736
#define NV_PFIFO_CACHE1_DMA_STATE_ERROR_NONE             0x00000000 /* RW--V */
737
#define NV_PFIFO_CACHE1_DMA_STATE_ERROR_NON_CACHE        0x00000001 /* RW--V */
738
#define NV_PFIFO_CACHE1_DMA_STATE_ERROR_RESERVED_CMD     0x00000002 /* RW--V */
739
#define NV_PFIFO_CACHE1_DMA_STATE_ERROR_PROTECTION       0x00000003 /* RW--V */
740
#define NV_PFIFO_CACHE1_DMA_INSTANCE                     0x0000322C /* RW-4R */
741
#define NV_PFIFO_CACHE1_DMA_INSTANCE_ADDRESS                   15:0 /* RWXUF */
742
#define NV_PFIFO_CACHE1_DMA_CTL                          0x00003230 /* RW-4R */
743
#define NV_PFIFO_CACHE1_DMA_CTL_ADJUST                         11:2 /* RWXUF */
744
#define NV_PFIFO_CACHE1_DMA_CTL_PAGE_TABLE                    12:12 /* RWXUF */
745
#define NV_PFIFO_CACHE1_DMA_CTL_PAGE_TABLE_NOT_PRESENT   0x00000000 /* RW--V */
746
#define NV_PFIFO_CACHE1_DMA_CTL_PAGE_TABLE_PRESENT       0x00000001 /* RW--V */
747
#define NV_PFIFO_CACHE1_DMA_CTL_PAGE_ENTRY                    13:13 /* RWXUF */
748
#define NV_PFIFO_CACHE1_DMA_CTL_PAGE_ENTRY_NOT_LINEAR    0x00000000 /* RW--V */
749
#define NV_PFIFO_CACHE1_DMA_CTL_PAGE_ENTRY_LINEAR        0x00000001 /* RW--V */
750
#define NV_PFIFO_CACHE1_DMA_CTL_TARGET_NODE                   17:16 /* RWXUF */
751
#define NV_PFIFO_CACHE1_DMA_CTL_TARGET_NODE_PCI          0x00000002 /* RW--V */
752
#define NV_PFIFO_CACHE1_DMA_CTL_TARGET_NODE_AGP          0x00000003 /* RW--V */
753
#define NV_PFIFO_CACHE1_DMA_CTL_AT_INFO                       31:31 /* RWIUF */
754
#define NV_PFIFO_CACHE1_DMA_CTL_AT_INFO_INVALID          0x00000000 /* RW--V */
755
#define NV_PFIFO_CACHE1_DMA_CTL_AT_INFO_VALID            0x00000001 /* RWI-V */
756
#define NV_PFIFO_CACHE1_DMA_LIMIT                        0x00003234 /* RW-4R */
757
#define NV_PFIFO_CACHE1_DMA_LIMIT_OFFSET                       28:2 /* RWXUF */
758
#define NV_PFIFO_CACHE1_DMA_TLB_TAG                      0x00003238 /* RW-4R */
759
#define NV_PFIFO_CACHE1_DMA_TLB_TAG_ADDRESS                   28:12 /* RWXUF */
760
#define NV_PFIFO_CACHE1_DMA_TLB_TAG_STATE                       0:0 /* RWIUF */
761
#define NV_PFIFO_CACHE1_DMA_TLB_TAG_STATE_INVALID        0x00000000 /* RWI-V */
762
#define NV_PFIFO_CACHE1_DMA_TLB_TAG_STATE_VALID          0x00000001 /* RW--V */
763
#define NV_PFIFO_CACHE1_DMA_TLB_PTE                      0x0000323C /* RW-4R */
764
#define NV_PFIFO_CACHE1_DMA_TLB_PTE_FRAME_ADDRESS             31:12 /* RWXUF */
765
#define NV_PFIFO_CACHE0_PULL0                            0x00003050 /* RW-4R */
766
#define NV_PFIFO_CACHE0_PULL0_ACCESS                            0:0 /* RWIVF */
767
#define NV_PFIFO_CACHE0_PULL0_ACCESS_DISABLED            0x00000000 /* RWI-V */
768
#define NV_PFIFO_CACHE0_PULL0_ACCESS_ENABLED             0x00000001 /* RW--V */
769
#define NV_PFIFO_CACHE0_PULL0_HASH                              4:4 /* R-XVF */
770
#define NV_PFIFO_CACHE0_PULL0_HASH_SUCCEEDED             0x00000000 /* R---V */
771
#define NV_PFIFO_CACHE0_PULL0_HASH_FAILED                0x00000001 /* R---V */
772
#define NV_PFIFO_CACHE0_PULL0_DEVICE                            8:8 /* R-XVF */
773
#define NV_PFIFO_CACHE0_PULL0_DEVICE_HARDWARE            0x00000000 /* R---V */
774
#define NV_PFIFO_CACHE0_PULL0_DEVICE_SOFTWARE            0x00000001 /* R---V */
775
#define NV_PFIFO_CACHE0_PULL0_HASH_STATE                      12:12 /* R-XVF */
776
#define NV_PFIFO_CACHE0_PULL0_HASH_STATE_IDLE            0x00000000 /* R---V */
777
#define NV_PFIFO_CACHE0_PULL0_HASH_STATE_BUSY            0x00000001 /* R---V */
778
#define NV_PFIFO_CACHE1_PULL0                            0x00003250 /* RW-4R */
779
#define NV_PFIFO_CACHE1_PULL0_ACCESS                            0:0 /* RWIVF */
780
#define NV_PFIFO_CACHE1_PULL0_ACCESS_DISABLED            0x00000000 /* RWI-V */
781
#define NV_PFIFO_CACHE1_PULL0_ACCESS_ENABLED             0x00000001 /* RW--V */
782
#define NV_PFIFO_CACHE1_PULL0_HASH                              4:4 /* R-XVF */
783
#define NV_PFIFO_CACHE1_PULL0_HASH_SUCCEEDED             0x00000000 /* R---V */
784
#define NV_PFIFO_CACHE1_PULL0_HASH_FAILED                0x00000001 /* R---V */
785
#define NV_PFIFO_CACHE1_PULL0_DEVICE                            8:8 /* R-XVF */
786
#define NV_PFIFO_CACHE1_PULL0_DEVICE_HARDWARE            0x00000000 /* R---V */
787
#define NV_PFIFO_CACHE1_PULL0_DEVICE_SOFTWARE            0x00000001 /* R---V */
788
#define NV_PFIFO_CACHE1_PULL0_HASH_STATE                      12:12 /* R-XVF */
789
#define NV_PFIFO_CACHE1_PULL0_HASH_STATE_IDLE            0x00000000 /* R---V */
790
#define NV_PFIFO_CACHE1_PULL0_HASH_STATE_BUSY            0x00000001 /* R---V */
791
#define NV_PFIFO_CACHE0_PULL1                            0x00003054 /* RW-4R */
792
#define NV_PFIFO_CACHE0_PULL1_ENGINE                            1:0 /* RWXUF */
793
#define NV_PFIFO_CACHE0_PULL1_ENGINE_SW                  0x00000000 /* RW--V */
794
#define NV_PFIFO_CACHE0_PULL1_ENGINE_GRAPHICS            0x00000001 /* RW--V */
795
#define NV_PFIFO_CACHE0_PULL1_ENGINE_DVD                 0x00000002 /* RW--V */
796
#define NV_PFIFO_CACHE1_PULL1                            0x00003254 /* RW-4R */
797
#define NV_PFIFO_CACHE1_PULL1_ENGINE                            1:0 /* RWXUF */
798
#define NV_PFIFO_CACHE1_PULL1_ENGINE_SW                  0x00000000 /* RW--V */
799
#define NV_PFIFO_CACHE1_PULL1_ENGINE_GRAPHICS            0x00000001 /* RW--V */
800
#define NV_PFIFO_CACHE1_PULL1_ENGINE_DVD                 0x00000002 /* RW--V */
801
#define NV_PFIFO_CACHE0_HASH                             0x00003058 /* RW-4R */
802
#define NV_PFIFO_CACHE0_HASH_INSTANCE                          15:0 /* RWXUF */
803
#define NV_PFIFO_CACHE0_HASH_VALID                            16:16 /* RWXVF */
804
#define NV_PFIFO_CACHE1_HASH                             0x00003258 /* RW-4R */
805
#define NV_PFIFO_CACHE1_HASH_INSTANCE                          15:0 /* RWXUF */
806
#define NV_PFIFO_CACHE1_HASH_VALID                            16:16 /* RWXVF */
807
#define NV_PFIFO_CACHE0_STATUS                           0x00003014 /* R--4R */
808
#define NV_PFIFO_CACHE0_STATUS_LOW_MARK                         4:4 /* R--VF */
809
#define NV_PFIFO_CACHE0_STATUS_LOW_MARK_NOT_EMPTY        0x00000000 /* R---V */
810
#define NV_PFIFO_CACHE0_STATUS_LOW_MARK_EMPTY            0x00000001 /* R---V */
811
#define NV_PFIFO_CACHE0_STATUS_HIGH_MARK                        8:8 /* R--VF */
812
#define NV_PFIFO_CACHE0_STATUS_HIGH_MARK_NOT_FULL        0x00000000 /* R---V */
813
#define NV_PFIFO_CACHE0_STATUS_HIGH_MARK_FULL            0x00000001 /* R---V */
814
#define NV_PFIFO_CACHE1_STATUS                           0x00003214 /* R--4R */
815
#define NV_PFIFO_CACHE1_STATUS_LOW_MARK                         4:4 /* R--VF */
816
#define NV_PFIFO_CACHE1_STATUS_LOW_MARK_NOT_EMPTY        0x00000000 /* R---V */
817
#define NV_PFIFO_CACHE1_STATUS_LOW_MARK_EMPTY            0x00000001 /* R---V */
818
#define NV_PFIFO_CACHE1_STATUS_HIGH_MARK                        8:8 /* R--VF */
819
#define NV_PFIFO_CACHE1_STATUS_HIGH_MARK_NOT_FULL        0x00000000 /* R---V */
820
#define NV_PFIFO_CACHE1_STATUS_HIGH_MARK_FULL            0x00000001 /* R---V */
821
#define NV_PFIFO_CACHE1_STATUS1                          0x00003218 /* R--4R */
822
#define NV_PFIFO_CACHE1_STATUS1_RANOUT                          0:0 /* R-XVF */
823
#define NV_PFIFO_CACHE1_STATUS1_RANOUT_FALSE             0x00000000 /* R---V */
824
#define NV_PFIFO_CACHE1_STATUS1_RANOUT_TRUE              0x00000001 /* R---V */
825
#define NV_PFIFO_CACHE0_PUT                              0x00003010 /* RW-4R */
826
#define NV_PFIFO_CACHE0_PUT_ADDRESS                             2:2 /* RWXUF */
827
#define NV_PFIFO_CACHE1_PUT                              0x00003210 /* RW-4R */
828
#define NV_PFIFO_CACHE1_PUT_ADDRESS                             9:2 /* RWXUF */
829
#define NV_PFIFO_CACHE0_GET                              0x00003070 /* RW-4R */
830
#define NV_PFIFO_CACHE0_GET_ADDRESS                             2:2 /* RWXUF */
831
#define NV_PFIFO_CACHE1_GET                              0x00003270 /* RW-4R */
832
#define NV_PFIFO_CACHE1_GET_ADDRESS                             9:2 /* RWXUF */
833
#define NV_PFIFO_CACHE0_ENGINE                           0x00003080 /* RW-4R */
834
#define NV_PFIFO_CACHE0_ENGINE_0                                1:0 /* RWXUF */
835
#define NV_PFIFO_CACHE0_ENGINE_0_SW                      0x00000000 /* RW--V */
836
#define NV_PFIFO_CACHE0_ENGINE_0_GRAPHICS                0x00000001 /* RW--V */
837
#define NV_PFIFO_CACHE0_ENGINE_0_DVD                     0x00000002 /* RW--V */
838
#define NV_PFIFO_CACHE0_ENGINE_1                                5:4 /* RWXUF */
839
#define NV_PFIFO_CACHE0_ENGINE_1_SW                      0x00000000 /* RW--V */
840
#define NV_PFIFO_CACHE0_ENGINE_1_GRAPHICS                0x00000001 /* RW--V */
841
#define NV_PFIFO_CACHE0_ENGINE_1_DVD                     0x00000002 /* RW--V */
842
#define NV_PFIFO_CACHE0_ENGINE_2                                9:8 /* RWXUF */
843
#define NV_PFIFO_CACHE0_ENGINE_2_SW                      0x00000000 /* RW--V */
844
#define NV_PFIFO_CACHE0_ENGINE_2_GRAPHICS                0x00000001 /* RW--V */
845
#define NV_PFIFO_CACHE0_ENGINE_2_DVD                     0x00000002 /* RW--V */
846
#define NV_PFIFO_CACHE0_ENGINE_3                              13:12 /* RWXUF */
847
#define NV_PFIFO_CACHE0_ENGINE_3_SW                      0x00000000 /* RW--V */
848
#define NV_PFIFO_CACHE0_ENGINE_3_GRAPHICS                0x00000001 /* RW--V */
849
#define NV_PFIFO_CACHE0_ENGINE_3_DVD                     0x00000002 /* RW--V */
850
#define NV_PFIFO_CACHE0_ENGINE_4                              17:16 /* RWXUF */
851
#define NV_PFIFO_CACHE0_ENGINE_4_SW                      0x00000000 /* RW--V */
852
#define NV_PFIFO_CACHE0_ENGINE_4_GRAPHICS                0x00000001 /* RW--V */
853
#define NV_PFIFO_CACHE0_ENGINE_4_DVD                     0x00000002 /* RW--V */
854
#define NV_PFIFO_CACHE0_ENGINE_5                              21:20 /* RWXUF */
855
#define NV_PFIFO_CACHE0_ENGINE_5_SW                      0x00000000 /* RW--V */
856
#define NV_PFIFO_CACHE0_ENGINE_5_GRAPHICS                0x00000001 /* RW--V */
857
#define NV_PFIFO_CACHE0_ENGINE_5_DVD                     0x00000002 /* RW--V */
858
#define NV_PFIFO_CACHE0_ENGINE_6                              25:24 /* RWXUF */
859
#define NV_PFIFO_CACHE0_ENGINE_6_SW                      0x00000000 /* RW--V */
860
#define NV_PFIFO_CACHE0_ENGINE_6_GRAPHICS                0x00000001 /* RW--V */
861
#define NV_PFIFO_CACHE0_ENGINE_6_DVD                     0x00000002 /* RW--V */
862
#define NV_PFIFO_CACHE0_ENGINE_7                              29:28 /* RWXUF */
863
#define NV_PFIFO_CACHE0_ENGINE_7_SW                      0x00000000 /* RW--V */
864
#define NV_PFIFO_CACHE0_ENGINE_7_GRAPHICS                0x00000001 /* RW--V */
865
#define NV_PFIFO_CACHE0_ENGINE_7_DVD                     0x00000002 /* RW--V */
866
#define NV_PFIFO_CACHE1_ENGINE                           0x00003280 /* RW-4R */
867
#define NV_PFIFO_CACHE1_ENGINE_0                                1:0 /* RWXUF */
868
#define NV_PFIFO_CACHE1_ENGINE_0_SW                      0x00000000 /* RW--V */
869
#define NV_PFIFO_CACHE1_ENGINE_0_GRAPHICS                0x00000001 /* RW--V */
870
#define NV_PFIFO_CACHE1_ENGINE_0_DVD                     0x00000002 /* RW--V */
871
#define NV_PFIFO_CACHE1_ENGINE_1                                5:4 /* RWXUF */
872
#define NV_PFIFO_CACHE1_ENGINE_1_SW                      0x00000000 /* RW--V */
873
#define NV_PFIFO_CACHE1_ENGINE_1_GRAPHICS                0x00000001 /* RW--V */
874
#define NV_PFIFO_CACHE1_ENGINE_1_DVD                     0x00000002 /* RW--V */
875
#define NV_PFIFO_CACHE1_ENGINE_2                                9:8 /* RWXUF */
876
#define NV_PFIFO_CACHE1_ENGINE_2_SW                      0x00000000 /* RW--V */
877
#define NV_PFIFO_CACHE1_ENGINE_2_GRAPHICS                0x00000001 /* RW--V */
878
#define NV_PFIFO_CACHE1_ENGINE_2_DVD                     0x00000002 /* RW--V */
879
#define NV_PFIFO_CACHE1_ENGINE_3                              13:12 /* RWXUF */
880
#define NV_PFIFO_CACHE1_ENGINE_3_SW                      0x00000000 /* RW--V */
881
#define NV_PFIFO_CACHE1_ENGINE_3_GRAPHICS                0x00000001 /* RW--V */
882
#define NV_PFIFO_CACHE1_ENGINE_3_DVD                     0x00000002 /* RW--V */
883
#define NV_PFIFO_CACHE1_ENGINE_4                              17:16 /* RWXUF */
884
#define NV_PFIFO_CACHE1_ENGINE_4_SW                      0x00000000 /* RW--V */
885
#define NV_PFIFO_CACHE1_ENGINE_4_GRAPHICS                0x00000001 /* RW--V */
886
#define NV_PFIFO_CACHE1_ENGINE_4_DVD                     0x00000002 /* RW--V */
887
#define NV_PFIFO_CACHE1_ENGINE_5                              21:20 /* RWXUF */
888
#define NV_PFIFO_CACHE1_ENGINE_5_SW                      0x00000000 /* RW--V */
889
#define NV_PFIFO_CACHE1_ENGINE_5_GRAPHICS                0x00000001 /* RW--V */
890
#define NV_PFIFO_CACHE1_ENGINE_5_DVD                     0x00000002 /* RW--V */
891
#define NV_PFIFO_CACHE1_ENGINE_6                              25:24 /* RWXUF */
892
#define NV_PFIFO_CACHE1_ENGINE_6_SW                      0x00000000 /* RW--V */
893
#define NV_PFIFO_CACHE1_ENGINE_6_GRAPHICS                0x00000001 /* RW--V */
894
#define NV_PFIFO_CACHE1_ENGINE_6_DVD                     0x00000002 /* RW--V */
895
#define NV_PFIFO_CACHE1_ENGINE_7                              29:28 /* RWXUF */
896
#define NV_PFIFO_CACHE1_ENGINE_7_SW                      0x00000000 /* RW--V */
897
#define NV_PFIFO_CACHE1_ENGINE_7_GRAPHICS                0x00000001 /* RW--V */
898
#define NV_PFIFO_CACHE1_ENGINE_7_DVD                     0x00000002 /* RW--V */
899
#define NV_PFIFO_CACHE0_METHOD(i)                (0x00003100+(i)*8) /* RW-4A */
900
#define NV_PFIFO_CACHE0_METHOD__SIZE_1                            1 /*       */
901
#define NV_PFIFO_CACHE0_METHOD_ADDRESS                         12:2 /* RWXUF */
902
#define NV_PFIFO_CACHE0_METHOD_SUBCHANNEL                     15:13 /* RWXUF */
903
#define NV_PFIFO_CACHE1_METHOD(i)                (0x00003800+(i)*8) /* RW-4A */
904
#define NV_PFIFO_CACHE1_METHOD__SIZE_1                          128 /*       */
905
#define NV_PFIFO_CACHE1_METHOD_ADDRESS                         12:2 /* RWXUF */
906
#define NV_PFIFO_CACHE1_METHOD_SUBCHANNEL                     15:13 /* RWXUF */
907
#define NV_PFIFO_CACHE1_METHOD_ALIAS(i)          (0x00003C00+(i)*8) /* RW-4A */
908
#define NV_PFIFO_CACHE1_METHOD_ALIAS__SIZE_1                    128 /*       */
909
#define NV_PFIFO_CACHE0_DATA(i)                  (0x00003104+(i)*8) /* RW-4A */
910
#define NV_PFIFO_CACHE0_DATA__SIZE_1                              1 /*       */
911
#define NV_PFIFO_CACHE0_DATA_VALUE                             31:0 /* RWXVF */
912
#define NV_PFIFO_CACHE1_DATA(i)                  (0x00003804+(i)*8) /* RW-4A */
913
#define NV_PFIFO_CACHE1_DATA__SIZE_1                            128 /*       */
914
#define NV_PFIFO_CACHE1_DATA_VALUE                             31:0 /* RWXVF */
915
#define NV_PFIFO_CACHE1_DATA_ALIAS(i)            (0x00003C04+(i)*8) /* RW-4A */
916
#define NV_PFIFO_CACHE1_DATA_ALIAS__SIZE_1                      128 /*       */
917
#define NV_PFIFO_DEVICE(i)                       (0x00002800+(i)*4) /* R--4A */
918
#define NV_PFIFO_DEVICE__SIZE_1                                 128 /*       */
919
#define NV_PFIFO_DEVICE_CHID                                    3:0 /* R--UF */
920
#define NV_PFIFO_DEVICE_SWITCH                                24:24 /* R--VF */
921
#define NV_PFIFO_DEVICE_SWITCH_UNAVAILABLE               0x00000000 /* R---V */
922
#define NV_PFIFO_DEVICE_SWITCH_AVAILABLE                 0x00000001 /* R---V */
923
#define NV_PFIFO_RUNOUT_STATUS                           0x00002400 /* R--4R */
924
#define NV_PFIFO_RUNOUT_STATUS_RANOUT                           0:0 /* R--VF */
925
#define NV_PFIFO_RUNOUT_STATUS_RANOUT_FALSE              0x00000000 /* R---V */
926
#define NV_PFIFO_RUNOUT_STATUS_RANOUT_TRUE               0x00000001 /* R---V */
927
#define NV_PFIFO_RUNOUT_STATUS_LOW_MARK                         4:4 /* R--VF */
928
#define NV_PFIFO_RUNOUT_STATUS_LOW_MARK_NOT_EMPTY        0x00000000 /* R---V */
929
#define NV_PFIFO_RUNOUT_STATUS_LOW_MARK_EMPTY            0x00000001 /* R---V */
930
#define NV_PFIFO_RUNOUT_STATUS_HIGH_MARK                        8:8 /* R--VF */
931
#define NV_PFIFO_RUNOUT_STATUS_HIGH_MARK_NOT_FULL        0x00000000 /* R---V */
932
#define NV_PFIFO_RUNOUT_STATUS_HIGH_MARK_FULL            0x00000001 /* R---V */
933
#define NV_PFIFO_RUNOUT_PUT                              0x00002410 /* RW-4R */
934
#define NV_PFIFO_RUNOUT_PUT_ADDRESS                            12:3 /* RWXUF */
935
#define NV_PFIFO_RUNOUT_PUT_ADDRESS__SIZE_0                     8:3 /* RWXUF */
936
#define NV_PFIFO_RUNOUT_PUT_ADDRESS__SIZE_1                    12:3 /* RWXUF */
937
#define NV_PFIFO_RUNOUT_GET                              0x00002420 /* RW-4R */
938
#define NV_PFIFO_RUNOUT_GET_ADDRESS                            13:3 /* RWXUF */
939
/* dev_graphics.ref */
940
#define NV_PGRAPH                             0x00401FFF:0x00400000 /* RW--D */
941
#define NV_PGRAPH_DEBUG_0                                0x00400080 /* RW-4R */
942
#define NV_PGRAPH_DEBUG_1                                0x00400084 /* RW-4R */
943
#define NV_PGRAPH_DEBUG_2                                0x00400088 /* RW-4R */
944
#define NV_PGRAPH_DEBUG_3                                0x0040008C /* RW-4R */
945
#define NV_PGRAPH_INTR                                   0x00400100 /* RW-4R */
946
#define NV_PGRAPH_INTR_NOTIFY                                   0:0 /* RWIVF */
947
#define NV_PGRAPH_INTR_NOTIFY_NOT_PENDING                0x00000000 /* R-I-V */
948
#define NV_PGRAPH_INTR_NOTIFY_PENDING                    0x00000001 /* R---V */
949
#define NV_PGRAPH_INTR_NOTIFY_RESET                      0x00000001 /* -W--C */
950
#define NV_PGRAPH_INTR_MISSING_HW                               4:4 /* RWIVF */
951
#define NV_PGRAPH_INTR_MISSING_HW_NOT_PENDING            0x00000000 /* R-I-V */
952
#define NV_PGRAPH_INTR_MISSING_HW_PENDING                0x00000001 /* R---V */
953
#define NV_PGRAPH_INTR_MISSING_HW_RESET                  0x00000001 /* -W--C */
954
#define NV_PGRAPH_INTR_TLB_PRESENT_A                            8:8 /* RWIVF */
955
#define NV_PGRAPH_INTR_TLB_PRESENT_A_NOT_PENDING         0x00000000 /* R-I-V */
956
#define NV_PGRAPH_INTR_TLB_PRESENT_A_PENDING             0x00000001 /* R---V */
957
#define NV_PGRAPH_INTR_TLB_PRESENT_A_RESET               0x00000001 /* -W--C */
958
#define NV_PGRAPH_INTR_TLB_PRESENT_B                            9:9 /* RWIVF */
959
#define NV_PGRAPH_INTR_TLB_PRESENT_B_NOT_PENDING         0x00000000 /* R-I-V */
960
#define NV_PGRAPH_INTR_TLB_PRESENT_B_PENDING             0x00000001 /* R---V */
961
#define NV_PGRAPH_INTR_TLB_PRESENT_B_RESET               0x00000001 /* -W--C */
962
#define NV_PGRAPH_INTR_CONTEXT_SWITCH                         12:12 /* RWIVF */
963
#define NV_PGRAPH_INTR_CONTEXT_SWITCH_NOT_PENDING        0x00000000 /* R-I-V */
964
#define NV_PGRAPH_INTR_CONTEXT_SWITCH_PENDING            0x00000001 /* R---V */
965
#define NV_PGRAPH_INTR_CONTEXT_SWITCH_RESET              0x00000001 /* -W--C */
966
#define NV_PGRAPH_INTR_BUFFER_NOTIFY                          16:16 /* RWIVF */
967
#define NV_PGRAPH_INTR_BUFFER_NOTIFY_NOT_PENDING         0x00000000 /* R-I-V */
968
#define NV_PGRAPH_INTR_BUFFER_NOTIFY_PENDING             0x00000001 /* R---V */
969
#define NV_PGRAPH_INTR_BUFFER_NOTIFY_RESET               0x00000001 /* -W--C */
970
#define NV_PGRAPH_NSTATUS                                0x00400104 /* RW-4R */
971
#define NV_PGRAPH_NSTATUS_STATE_IN_USE                        11:11 /* RWIVF */
972
#define NV_PGRAPH_NSTATUS_STATE_IN_USE_NOT_PENDING       0x00000000 /* RWI-V */
973
#define NV_PGRAPH_NSTATUS_STATE_IN_USE_PENDING           0x00000001 /* RW--V */
974
#define NV_PGRAPH_NSTATUS_INVALID_STATE                       12:12 /* RWIVF */
975
#define NV_PGRAPH_NSTATUS_INVALID_STATE_NOT_PENDING      0x00000000 /* RWI-V */
976
#define NV_PGRAPH_NSTATUS_INVALID_STATE_PENDING          0x00000001 /* RW--V */
977
#define NV_PGRAPH_NSTATUS_BAD_ARGUMENT                        13:13 /* RWIVF */
978
#define NV_PGRAPH_NSTATUS_BAD_ARGUMENT_NOT_PENDING       0x00000000 /* RWI-V */
979
#define NV_PGRAPH_NSTATUS_BAD_ARGUMENT_PENDING           0x00000001 /* RW--V */
980
#define NV_PGRAPH_NSTATUS_PROTECTION_FAULT                    14:14 /* RWIVF */
981
#define NV_PGRAPH_NSTATUS_PROTECTION_FAULT_NOT_PENDING   0x00000000 /* RWI-V */
982
#define NV_PGRAPH_NSTATUS_PROTECTION_FAULT_PENDING       0x00000001 /* RW--V */
983
#define NV_PGRAPH_NSOURCE                                0x00400108 /* R--4R */
984
#define NV_PGRAPH_NSOURCE_NOTIFICATION                          0:0 /* R-IVF */
985
#define NV_PGRAPH_NSOURCE_NOTIFICATION_NOT_PENDING       0x00000000 /* R-I-V */
986
#define NV_PGRAPH_NSOURCE_NOTIFICATION_PENDING           0x00000001 /* R---V */
987
#define NV_PGRAPH_NSOURCE_DATA_ERROR                            1:1 /* R-IVF */
988
#define NV_PGRAPH_NSOURCE_DATA_ERROR_NOT_PENDING         0x00000000 /* R-I-V */
989
#define NV_PGRAPH_NSOURCE_DATA_ERROR_PENDING             0x00000001 /* R---V */
990
#define NV_PGRAPH_NSOURCE_PROTECTION_ERROR                      2:2 /* R-IVF */
991
#define NV_PGRAPH_NSOURCE_PROTECTION_ERROR_NOT_PENDING   0x00000000 /* R-I-V */
992
#define NV_PGRAPH_NSOURCE_PROTECTION_ERROR_PENDING       0x00000001 /* R---V */
993
#define NV_PGRAPH_NSOURCE_RANGE_EXCEPTION                       3:3 /* R-IVF */
994
#define NV_PGRAPH_NSOURCE_RANGE_EXCEPTION_NOT_PENDING    0x00000000 /* R-I-V */
995
#define NV_PGRAPH_NSOURCE_RANGE_EXCEPTION_PENDING        0x00000001 /* R---V */
996
#define NV_PGRAPH_NSOURCE_LIMIT_COLOR                           4:4 /* R-IVF */
997
#define NV_PGRAPH_NSOURCE_LIMIT_COLOR_NOT_PENDING        0x00000000 /* R-I-V */
998
#define NV_PGRAPH_NSOURCE_LIMIT_COLOR_PENDING            0x00000001 /* R---V */
999
#define NV_PGRAPH_NSOURCE_LIMIT_ZETA_                           5:5 /* R-IVF */
1000
#define NV_PGRAPH_NSOURCE_LIMIT_ZETA_NOT_PENDING         0x00000000 /* R-I-V */
1001
#define NV_PGRAPH_NSOURCE_LIMIT_ZETA_PENDING             0x00000001 /* R---V */
1002
#define NV_PGRAPH_NSOURCE_ILLEGAL_MTHD                          6:6 /* R-IVF */
1003
#define NV_PGRAPH_NSOURCE_ILLEGAL_MTHD_NOT_PENDING       0x00000000 /* R-I-V */
1004
#define NV_PGRAPH_NSOURCE_ILLEGAL_MTHD_PENDING           0x00000001 /* R---V */
1005
#define NV_PGRAPH_NSOURCE_DMA_R_PROTECTION                      7:7 /* R-IVF */
1006
#define NV_PGRAPH_NSOURCE_DMA_R_PROTECTION_NOT_PENDING   0x00000000 /* R-I-V */
1007
#define NV_PGRAPH_NSOURCE_DMA_R_PROTECTION_PENDING       0x00000001 /* R---V */
1008
#define NV_PGRAPH_NSOURCE_DMA_W_PROTECTION                      8:8 /* R-IVF */
1009
#define NV_PGRAPH_NSOURCE_DMA_W_PROTECTION_NOT_PENDING   0x00000000 /* R-I-V */
1010
#define NV_PGRAPH_NSOURCE_DMA_W_PROTECTION_PENDING       0x00000001 /* R---V */
1011
#define NV_PGRAPH_NSOURCE_FORMAT_EXCEPTION                      9:9 /* R-IVF */
1012
#define NV_PGRAPH_NSOURCE_FORMAT_EXCEPTION_NOT_PENDING   0x00000000 /* R-I-V */
1013
#define NV_PGRAPH_NSOURCE_FORMAT_EXCEPTION_PENDING       0x00000001 /* R---V */
1014
#define NV_PGRAPH_NSOURCE_PATCH_EXCEPTION                     10:10 /* R-IVF */
1015
#define NV_PGRAPH_NSOURCE_PATCH_EXCEPTION_NOT_PENDING    0x00000000 /* R-I-V */
1016
#define NV_PGRAPH_NSOURCE_PATCH_EXCEPTION_PENDING        0x00000001 /* R---V */
1017
#define NV_PGRAPH_NSOURCE_STATE_INVALID                       11:11 /* R-IVF */
1018
#define NV_PGRAPH_NSOURCE_STATE_INVALID_NOT_PENDING      0x00000000 /* R-I-V */
1019
#define NV_PGRAPH_NSOURCE_STATE_INVALID_PENDING          0x00000001 /* R---V */
1020
#define NV_PGRAPH_NSOURCE_DOUBLE_NOTIFY                       12:12 /* R-IVF */
1021
#define NV_PGRAPH_NSOURCE_DOUBLE_NOTIFY_NOT_PENDING      0x00000000 /* R-I-V */
1022
#define NV_PGRAPH_NSOURCE_DOUBLE_NOTIFY_PENDING          0x00000001 /* R---V */
1023
#define NV_PGRAPH_NSOURCE_NOTIFY_IN_USE                       13:13 /* R-IVF */
1024
#define NV_PGRAPH_NSOURCE_NOTIFY_IN_USE_NOT_PENDING      0x00000000 /* R-I-V */
1025
#define NV_PGRAPH_NSOURCE_NOTIFY_IN_USE_PENDING          0x00000001 /* R---V */
1026
#define NV_PGRAPH_NSOURCE_METHOD_CNT                          14:14 /* R-IVF */
1027
#define NV_PGRAPH_NSOURCE_METHOD_CNT_NOT_PENDING         0x00000000 /* R-I-V */
1028
#define NV_PGRAPH_NSOURCE_METHOD_CNT_PENDING             0x00000001 /* R---V */
1029
#define NV_PGRAPH_NSOURCE_BFR_NOTIFICATION                    15:15 /* R-IVF */
1030
#define NV_PGRAPH_NSOURCE_BFR_NOTIFICATION_NOT_PENDING   0x00000000 /* R-I-V */
1031
#define NV_PGRAPH_NSOURCE_BFR_NOTIFICATION_PENDING       0x00000001 /* R---V */
1032
#define NV_PGRAPH_INTR_EN                                0x00400140 /* RW-4R */
1033
#define NV_PGRAPH_INTR_EN_NOTIFY                                0:0 /* RWIVF */
1034
#define NV_PGRAPH_INTR_EN_NOTIFY_DISABLED                0x00000000 /* RWI-V */
1035
#define NV_PGRAPH_INTR_EN_NOTIFY_ENABLED                 0x00000001 /* RW--V */
1036
#define NV_PGRAPH_INTR_EN_MISSING_HW                            4:4 /* RWIVF */
1037
#define NV_PGRAPH_INTR_EN_MISSING_HW_DISABLED            0x00000000 /* RWI-V */
1038
#define NV_PGRAPH_INTR_EN_MISSING_HW_ENABLED             0x00000001 /* RW--V */
1039
#define NV_PGRAPH_INTR_EN_TLB_PRESENT_A                         8:8 /* RWIVF */
1040
#define NV_PGRAPH_INTR_EN_TLB_PRESENT_A_DISABLED         0x00000000 /* RWI-V */
1041
#define NV_PGRAPH_INTR_EN_TLB_PRESENT_A_ENABLED          0x00000001 /* RW--V */
1042
#define NV_PGRAPH_INTR_EN_TLB_PRESENT_B                         9:9 /* RWIVF */
1043
#define NV_PGRAPH_INTR_EN_TLB_PRESENT_B_DISABLED         0x00000000 /* RWI-V */
1044
#define NV_PGRAPH_INTR_EN_TLB_PRESENT_B_ENABLED          0x00000001 /* RW--V */
1045
#define NV_PGRAPH_INTR_EN_CONTEXT_SWITCH                      12:12 /* RWIVF */
1046
#define NV_PGRAPH_INTR_EN_CONTEXT_SWITCH_DISABLED        0x00000000 /* RWI-V */
1047
#define NV_PGRAPH_INTR_EN_CONTEXT_SWITCH_ENABLED         0x00000001 /* RW--V */
1048
#define NV_PGRAPH_INTR_EN_BUFFER_NOTIFY                       16:16 /* RWIVF */
1049
#define NV_PGRAPH_INTR_EN_BUFFER_NOTIFY_DISABLED         0x00000000 /* RWI-V */
1050
#define NV_PGRAPH_INTR_EN_BUFFER_NOTIFY_ENABLED          0x00000001 /* RW--V */
1051
#define NV_PGRAPH_CTX_SWITCH1                            0x00400160 /* RW-4R */
1052
#define NV_PGRAPH_CTX_SWITCH1_GRCLASS                           7:0 /* RWXVF */
1053
#define NV_PGRAPH_CTX_SWITCH1_CHROMA_KEY                      12:12 /* RWXUF */
1054
#define NV_PGRAPH_CTX_SWITCH1_CHROMA_KEY_DISABLE         0x00000000 /* RW--V */
1055
#define NV_PGRAPH_CTX_SWITCH1_CHROMA_KEY_ENABLE          0x00000001 /* RW--V */
1056
#define NV_PGRAPH_CTX_SWITCH1_USER_CLIP                       13:13 /* RWXUF */
1057
#define NV_PGRAPH_CTX_SWITCH1_USER_CLIP_DISABLE          0x00000000 /* RW--V */
1058
#define NV_PGRAPH_CTX_SWITCH1_USER_CLIP_ENABLE           0x00000001 /* RW--V */
1059
#define NV_PGRAPH_CTX_SWITCH1_SWIZZLE                         14:14 /* RWXUF */
1060
#define NV_PGRAPH_CTX_SWITCH1_SWIZZLE_DISABLE            0x00000000 /* RW--V */
1061
#define NV_PGRAPH_CTX_SWITCH1_SWIZZLE_ENABLE             0x00000001 /* RW--V */
1062
#define NV_PGRAPH_CTX_SWITCH1_PATCH_CONFIG                    17:15 /* RWXUF */
1063
#define NV_PGRAPH_CTX_SWITCH1_PATCH_CONFIG_SRCCOPY_AND   0x00000000 /* RW--V */
1064
#define NV_PGRAPH_CTX_SWITCH1_PATCH_CONFIG_ROP_AND       0x00000001 /* RW--V */
1065
#define NV_PGRAPH_CTX_SWITCH1_PATCH_CONFIG_BLEND_AND     0x00000002 /* RW--V */
1066
#define NV_PGRAPH_CTX_SWITCH1_PATCH_CONFIG_SRCCOPY       0x00000003 /* RW--V */
1067
#define NV_PGRAPH_CTX_SWITCH1_PATCH_CONFIG_SRCCOPY_PRE   0x00000004 /* RW--V */
1068
#define NV_PGRAPH_CTX_SWITCH1_PATCH_CONFIG_BLEND_PRE     0x00000005 /* RW--V */
1069
#define NV_PGRAPH_CTX_SWITCH1_PATCH_STATUS                    24:24 /* RWXUF */
1070
#define NV_PGRAPH_CTX_SWITCH1_PATCH_STATUS_INVALID       0x00000000 /* RW--V */
1071
#define NV_PGRAPH_CTX_SWITCH1_PATCH_STATUS_VALID         0x00000001 /* RW--V */
1072
#define NV_PGRAPH_CTX_SWITCH1_CONTEXT_SURFACE                 25:25 /* RWXUF */
1073
#define NV_PGRAPH_CTX_SWITCH1_CONTEXT_SURFACE_INVALID    0x00000000 /* RW--V */
1074
#define NV_PGRAPH_CTX_SWITCH1_CONTEXT_SURFACE_VALID      0x00000001 /* RW--V */
1075
#define NV_PGRAPH_CTX_SWITCH1_VOLATILE_RESET                  31:31 /* CWIVF */
1076
#define NV_PGRAPH_CTX_SWITCH1_VOLATILE_RESET_IGNORE      0x00000000 /* CWI-V */
1077
#define NV_PGRAPH_CTX_SWITCH1_VOLATILE_RESET_ENABLED     0x00000001 /* -W--T */
1078
#define NV_PGRAPH_CTX_SWITCH2                            0x00400164 /* RW-4R */
1079
#define NV_PGRAPH_CTX_SWITCH2_MONO_FORMAT                       1:0 /* RWXUF */
1080
#define NV_PGRAPH_CTX_SWITCH2_MONO_FORMAT_INVALID              0x00 /* RW--V */
1081
#define NV_PGRAPH_CTX_SWITCH2_MONO_FORMAT_CGA6_M1              0x01 /* RW--V */
1082
#define NV_PGRAPH_CTX_SWITCH2_MONO_FORMAT_LE_M1                0x02 /* RW--V */
1083
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT                     13:8 /* RWXUF */
1084
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_INVALID             0x00 /* RW--V */
1085
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_Y8               0x01 /* RW--V */
1086
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_X16A8Y8          0x02 /* RW--V */
1087
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_X24Y8            0x03 /* RW--V */
1088
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_A1R5G5B5         0x06 /* RW--V */
1089
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_X1R5G5B5         0x07 /* RW--V */
1090
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_X16A1R5G5B5      0x08 /* RW--V */
1091
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_X17R5G5B5        0x09 /* RW--V */
1092
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_R5G6B5           0x0A /* RW--V */
1093
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_A16R5G6B5        0x0B /* RW--V */
1094
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_X16R5G6B5        0x0C /* RW--V */
1095
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_A8R8G8B8         0x0D /* RW--V */
1096
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_X8R8G8B8         0x0E /* RW--V */
1097
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_Y16              0x0F /* RW--V */
1098
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_A16Y16           0x10 /* RW--V */
1099
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_X16Y16           0x11 /* RW--V */
1100
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_V8YB8U8YA8       0x12 /* RW--V */
1101
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_YB8V8YA8U8       0x13 /* RW--V */
1102
#define NV_PGRAPH_CTX_SWITCH2_COLOR_FORMAT_LE_Y32              0x14 /* RW--V */
1103
#define NV_PGRAPH_CTX_SWITCH2_NOTIFY_INSTANCE                 31:16 /* RWXUF */
1104
#define NV_PGRAPH_CTX_SWITCH2_NOTIFY_INSTANCE_INVALID        0x0000 /* RW--V */
1105
#define NV_PGRAPH_CTX_SWITCH3                            0x00400168 /* RW-4R */
1106
#define NV_PGRAPH_CTX_SWITCH3_DMA_INSTANCE_0                   15:0 /* RWXUF */
1107
#define NV_PGRAPH_CTX_SWITCH3_DMA_INSTANCE_0_INVALID         0x0000 /* RW--V */
1108
#define NV_PGRAPH_CTX_SWITCH3_DMA_INSTANCE_1                  31:16 /* RWXUF */
1109
#define NV_PGRAPH_CTX_SWITCH3_DMA_INSTANCE_1_INVALID         0x0000 /* RW--V */
1110
#define NV_PGRAPH_CTX_SWITCH4                            0x0040016C /* RW-4R */
1111
#define NV_PGRAPH_CTX_SWITCH4_USER_INSTANCE                    15:0 /* RWXUF */
1112
#define NV_PGRAPH_CTX_SWITCH4_USER_INSTANCE_INVALID          0x0000 /* RW--V */
1113
#define NV_PGRAPH_CTX_CACHE1(i)                  (0x00400180+(i)*4) /* RW-4A */
1114
#define NV_PGRAPH_CTX_CACHE1__SIZE_1                              8 /*       */
1115
#define NV_PGRAPH_CTX_CACHE1_GRCLASS                            7:0 /* RWXVF */
1116
#define NV_PGRAPH_CTX_CACHE1_CHROMA_KEY                       12:12 /* RWXVF */
1117
#define NV_PGRAPH_CTX_CACHE1_USER_CLIP                        13:13 /* RWXVF */
1118
#define NV_PGRAPH_CTX_CACHE1_SWIZZLE                          14:14 /* RWXVF */
1119
#define NV_PGRAPH_CTX_CACHE1_PATCH_CONFIG                     19:15 /* RWXVF */
1120
#define NV_PGRAPH_CTX_CACHE1_SPARE1                           20:20 /* RWXVF */
1121
#define NV_PGRAPH_CTX_CACHE1_PATCH_STATUS                     24:24 /* RWXVF */
1122
#define NV_PGRAPH_CTX_CACHE1_CONTEXT_SURFACE                  25:25 /* RWXVF */
1123
#define NV_PGRAPH_CTX_CACHE2(i)                  (0x004001a0+(i)*4) /* RW-4A */
1124
#define NV_PGRAPH_CTX_CACHE2__SIZE_1                              8 /*       */
1125
#define NV_PGRAPH_CTX_CACHE2_MONO_FORMAT                        1:0 /* RWXVF */
1126
#define NV_PGRAPH_CTX_CACHE2_COLOR_FORMAT                      13:8 /* RWXVF */
1127
#define NV_PGRAPH_CTX_CACHE2_NOTIFY_INSTANCE                  31:16 /* RWXVF */
1128
#define NV_PGRAPH_CTX_CACHE3(i)                  (0x004001c0+(i)*4) /* RW-4A */
1129
#define NV_PGRAPH_CTX_CACHE3__SIZE_1                              8 /*       */
1130
#define NV_PGRAPH_CTX_CACHE3_DMA_INSTANCE_0                    15:0 /* RWXVF */
1131
#define NV_PGRAPH_CTX_CACHE3_DMA_INSTANCE_1                   31:16 /* RWXVF */
1132
#define NV_PGRAPH_CTX_CACHE4(i)                  (0x004001e0+(i)*4) /* RW-4A */
1133
#define NV_PGRAPH_CTX_CACHE4__SIZE_1                              8 /*       */
1134
#define NV_PGRAPH_CTX_CACHE4_USER_INSTANCE                     15:0 /* RWXVF */
1135
#define NV_PGRAPH_CTX_CONTROL                            0x00400170 /* RW-4R */
1136
#define NV_PGRAPH_CTX_CONTROL_MINIMUM_TIME                      1:0 /* RWIVF */
1137
#define NV_PGRAPH_CTX_CONTROL_MINIMUM_TIME_33US          0x00000000 /* RWI-V */
1138
#define NV_PGRAPH_CTX_CONTROL_MINIMUM_TIME_262US         0x00000001 /* RW--V */
1139
#define NV_PGRAPH_CTX_CONTROL_MINIMUM_TIME_2MS           0x00000002 /* RW--V */
1140
#define NV_PGRAPH_CTX_CONTROL_MINIMUM_TIME_17MS          0x00000003 /* RW--V */
1141
#define NV_PGRAPH_CTX_CONTROL_TIME                              8:8 /* RWIVF */
1142
#define NV_PGRAPH_CTX_CONTROL_TIME_EXPIRED               0x00000000 /* RWI-V */
1143
#define NV_PGRAPH_CTX_CONTROL_TIME_NOT_EXPIRED           0x00000001 /* RW--V */
1144
#define NV_PGRAPH_CTX_CONTROL_CHID                            16:16 /* RWIVF */
1145
#define NV_PGRAPH_CTX_CONTROL_CHID_INVALID               0x00000000 /* RWI-V */
1146
#define NV_PGRAPH_CTX_CONTROL_CHID_VALID                 0x00000001 /* RW--V */
1147
#define NV_PGRAPH_CTX_CONTROL_CHANGE                          20:20 /* R--VF */
1148
#define NV_PGRAPH_CTX_CONTROL_CHANGE_UNAVAILABLE         0x00000000 /* R---V */
1149
#define NV_PGRAPH_CTX_CONTROL_CHANGE_AVAILABLE           0x00000001 /* R---V */
1150
#define NV_PGRAPH_CTX_CONTROL_SWITCHING                       24:24 /* RWIVF */
1151
#define NV_PGRAPH_CTX_CONTROL_SWITCHING_IDLE             0x00000000 /* RWI-V */
1152
#define NV_PGRAPH_CTX_CONTROL_SWITCHING_BUSY             0x00000001 /* RW--V */
1153
#define NV_PGRAPH_CTX_CONTROL_DEVICE                          28:28 /* RWIVF */
1154
#define NV_PGRAPH_CTX_CONTROL_DEVICE_DISABLED            0x00000000 /* RWI-V */
1155
#define NV_PGRAPH_CTX_CONTROL_DEVICE_ENABLED             0x00000001 /* RW--V */
1156
#define NV_PGRAPH_CTX_USER                               0x00400174 /* RW-4R */
1157
#define NV_PGRAPH_CTX_USER_SUBCH                              15:13 /* RWIVF */
1158
#define NV_PGRAPH_CTX_USER_SUBCH_0                       0x00000000 /* RWI-V */
1159
#define NV_PGRAPH_CTX_USER_CHID                               27:24 /* RWIVF */
1160
#define NV_PGRAPH_CTX_USER_CHID_0                        0x00000000 /* RWI-V */
1161
#define NV_PGRAPH_FIFO                                   0x00400720 /* RW-4R */
1162
#define NV_PGRAPH_FIFO_ACCESS                                   0:0 /* RWIVF */
1163
#define NV_PGRAPH_FIFO_ACCESS_DISABLED                   0x00000000 /* RW--V */
1164
#define NV_PGRAPH_FIFO_ACCESS_ENABLED                    0x00000001 /* RWI-V */
1165
#define NV_PGRAPH_FFINTFC_FIFO_0(i)              (0x00400730+(i)*4) /* RW-4A */
1166
#define NV_PGRAPH_FFINTFC_FIFO_0__SIZE_1                          4 /*       */
1167
#define NV_PGRAPH_FFINTFC_FIFO_0_TAG                            0:0 /* RWXVF */
1168
#define NV_PGRAPH_FFINTFC_FIFO_0_TAG_MTHD                0x00000000 /* RW--V */
1169
#define NV_PGRAPH_FFINTFC_FIFO_0_TAG_CHSW                0x00000001 /* RW--V */
1170
#define NV_PGRAPH_FFINTFC_FIFO_0_SUBCH                          3:1 /* RWXVF */
1171
#define NV_PGRAPH_FFINTFC_FIFO_0_SUBCH_0                 0x00000000 /* RW--V */
1172
#define NV_PGRAPH_FFINTFC_FIFO_0_SUBCH_1                 0x00000001 /* RW--V */
1173
#define NV_PGRAPH_FFINTFC_FIFO_0_SUBCH_2                 0x00000002 /* RW--V */
1174
#define NV_PGRAPH_FFINTFC_FIFO_0_SUBCH_3                 0x00000003 /* RW--V */
1175
#define NV_PGRAPH_FFINTFC_FIFO_0_SUBCH_4                 0x00000004 /* RW--V */
1176
#define NV_PGRAPH_FFINTFC_FIFO_0_SUBCH_5                 0x00000005 /* RW--V */
1177
#define NV_PGRAPH_FFINTFC_FIFO_0_SUBCH_6                 0x00000006 /* RW--V */
1178
#define NV_PGRAPH_FFINTFC_FIFO_0_SUBCH_7                 0x00000007 /* RW--V */
1179
#define NV_PGRAPH_FFINTFC_FIFO_0_MTHD                          14:4 /* RWXVF */
1180
#define NV_PGRAPH_FFINTFC_FIFO_0_MTHD_CTX_SWITCH         0x00000000 /* RW--V */
1181
#define NV_PGRAPH_FFINTFC_FIFO_1(i)              (0x00400740+(i)*4) /* RW-4A */
1182
#define NV_PGRAPH_FFINTFC_FIFO_1__SIZE_1                          4 /*       */
1183
#define NV_PGRAPH_FFINTFC_FIFO_1_ARGUMENT                      31:0 /* RWXVF */
1184
#define NV_PGRAPH_FFINTFC_FIFO_PTR                       0x00400750 /* RW-4R */
1185
#define NV_PGRAPH_FFINTFC_FIFO_PTR_WRITE                        2:0 /* RWIVF */
1186
#define NV_PGRAPH_FFINTFC_FIFO_PTR_WRITE_0               0x00000000 /* RWI-V */
1187
#define NV_PGRAPH_FFINTFC_FIFO_PTR_READ                         6:4 /* RWIVF */
1188
#define NV_PGRAPH_FFINTFC_FIFO_PTR_READ_0                0x00000000 /* RWI-V */
1189
#define NV_PGRAPH_FFINTFC_ST2                            0x00400754 /* RW-4R */
1190
#define NV_PGRAPH_FFINTFC_ST2_STATUS                            0:0 /* RWIVF */
1191
#define NV_PGRAPH_FFINTFC_ST2_STATUS_INVALID             0x00000000 /* RWI-V */
1192
#define NV_PGRAPH_FFINTFC_ST2_STATUS_VALID               0x00000001 /* RW--V */
1193
#define NV_PGRAPH_FFINTFC_ST2_MTHD                             11:1 /* RWIVF */
1194
#define NV_PGRAPH_FFINTFC_ST2_MTHD_CTX_SWITCH            0x00000000 /* RWI-V */
1195
#define NV_PGRAPH_FFINTFC_ST2_SUBCH                           14:12 /* RWIVF */
1196
#define NV_PGRAPH_FFINTFC_ST2_SUBCH_0                    0x00000000 /* RWI-V */
1197
#define NV_PGRAPH_FFINTFC_ST2_SUBCH_1                    0x00000001 /* RW--V */
1198
#define NV_PGRAPH_FFINTFC_ST2_SUBCH_2                    0x00000002 /* RW--V */
1199
#define NV_PGRAPH_FFINTFC_ST2_SUBCH_3                    0x00000003 /* RW--V */
1200
#define NV_PGRAPH_FFINTFC_ST2_SUBCH_4                    0x00000004 /* RW--V */
1201
#define NV_PGRAPH_FFINTFC_ST2_SUBCH_5                    0x00000005 /* RW--V */
1202
#define NV_PGRAPH_FFINTFC_ST2_SUBCH_6                    0x00000006 /* RW--V */
1203
#define NV_PGRAPH_FFINTFC_ST2_SUBCH_7                    0x00000007 /* RW--V */
1204
#define NV_PGRAPH_FFINTFC_ST2_CHID                            18:15 /* RWIVF */
1205
#define NV_PGRAPH_FFINTFC_ST2_CHID_0                     0x00000000 /* RWI-V */
1206
#define NV_PGRAPH_FFINTFC_ST2_CHID_1                     0x00000001 /* RW--V */
1207
#define NV_PGRAPH_FFINTFC_ST2_CHID_2                     0x00000002 /* RW--V */
1208
#define NV_PGRAPH_FFINTFC_ST2_CHID_3                     0x00000003 /* RW--V */
1209
#define NV_PGRAPH_FFINTFC_ST2_CHID_4                     0x00000004 /* RW--V */
1210
#define NV_PGRAPH_FFINTFC_ST2_CHID_5                     0x00000005 /* RW--V */
1211
#define NV_PGRAPH_FFINTFC_ST2_CHID_6                     0x00000006 /* RW--V */
1212
#define NV_PGRAPH_FFINTFC_ST2_CHID_7                     0x00000007 /* RW--V */
1213
#define NV_PGRAPH_FFINTFC_ST2_CHID_8                     0x00000008 /* RW--V */
1214
#define NV_PGRAPH_FFINTFC_ST2_CHID_9                     0x00000009 /* RW--V */
1215
#define NV_PGRAPH_FFINTFC_ST2_CHID_10                    0x0000000A /* RW--V */
1216
#define NV_PGRAPH_FFINTFC_ST2_CHID_11                    0x0000000B /* RW--V */
1217
#define NV_PGRAPH_FFINTFC_ST2_CHID_12                    0x0000000C /* RW--V */
1218
#define NV_PGRAPH_FFINTFC_ST2_CHID_13                    0x0000000D /* RW--V */
1219
#define NV_PGRAPH_FFINTFC_ST2_CHID_14                    0x0000000E /* RW--V */
1220
#define NV_PGRAPH_FFINTFC_ST2_CHID_15                    0x0000000F /* RW--V */
1221
#define NV_PGRAPH_FFINTFC_ST2_CHID_STATUS                     19:19 /* RWIVF */
1222
#define NV_PGRAPH_FFINTFC_ST2_CHID_STATUS_INVALID        0x00000000 /* RWI-V */
1223
#define NV_PGRAPH_FFINTFC_ST2_CHID_STATUS_VALID          0x00000001 /* RW--V */
1224
#define NV_PGRAPH_FFINTFC_ST2_D                          0x00400758 /* RW-4R */
1225
#define NV_PGRAPH_FFINTFC_ST2_D_ARGUMENT                       31:0 /* RWIVF */
1226
#define NV_PGRAPH_FFINTFC_ST2_D_ARGUMENT_0               0x00000000 /* RWI-V */
1227
#define NV_PGRAPH_STATUS                                 0x00400700 /* R--4R */
1228
#define NV_PGRAPH_STATUS_STATE                                  0:0 /* R-IVF */
1229
#define NV_PGRAPH_STATUS_STATE_IDLE                      0x00000000 /* R-I-V */
1230
#define NV_PGRAPH_STATUS_STATE_BUSY                      0x00000001 /* R---V */
1231
#define NV_PGRAPH_STATUS_XY_LOGIC                               4:4 /* R-IVF */
1232
#define NV_PGRAPH_STATUS_XY_LOGIC_IDLE                   0x00000000 /* R-I-V */
1233
#define NV_PGRAPH_STATUS_XY_LOGIC_BUSY                   0x00000001 /* R---V */
1234
#define NV_PGRAPH_STATUS_FE                                     5:5 /* R-IVF */
1235
#define NV_PGRAPH_STATUS_FE_IDLE                         0x00000000 /* R-I-V */
1236
#define NV_PGRAPH_STATUS_FE_BUSY                         0x00000001 /* R---V */
1237
#define NV_PGRAPH_STATUS_RASTERIZER                             6:6 /* R-IVF */
1238
#define NV_PGRAPH_STATUS_RASTERIZER_IDLE                 0x00000000 /* R-I-V */
1239
#define NV_PGRAPH_STATUS_RASTERIZER_BUSY                 0x00000001 /* R---V */
1240
#define NV_PGRAPH_STATUS_PORT_NOTIFY                            8:8 /* R-IVF */
1241
#define NV_PGRAPH_STATUS_PORT_NOTIFY_IDLE                0x00000000 /* R-I-V */
1242
#define NV_PGRAPH_STATUS_PORT_NOTIFY_BUSY                0x00000001 /* R---V */
1243
#define NV_PGRAPH_STATUS_PORT_REGISTER                        12:12 /* R-IVF */
1244
#define NV_PGRAPH_STATUS_PORT_REGISTER_IDLE              0x00000000 /* R-I-V */
1245
#define NV_PGRAPH_STATUS_PORT_REGISTER_BUSY              0x00000001 /* R---V */
1246
#define NV_PGRAPH_STATUS_PORT_DMA                             16:16 /* R-IVF */
1247
#define NV_PGRAPH_STATUS_PORT_DMA_IDLE                   0x00000000 /* R-I-V */
1248
#define NV_PGRAPH_STATUS_PORT_DMA_BUSY                   0x00000001 /* R---V */
1249
#define NV_PGRAPH_STATUS_DMA_ENGINE                           17:17 /* R-IVF */
1250
#define NV_PGRAPH_STATUS_DMA_ENGINE_IDLE                 0x00000000 /* R-I-V */
1251
#define NV_PGRAPH_STATUS_DMA_ENGINE_BUSY                 0x00000001 /* R---V */
1252
#define NV_PGRAPH_STATUS_DMA_NOTIFY                           20:20 /* R-IVF */
1253
#define NV_PGRAPH_STATUS_DMA_NOTIFY_IDLE                 0x00000000 /* R-I-V */
1254
#define NV_PGRAPH_STATUS_DMA_NOTIFY_BUSY                 0x00000001 /* R---V */
1255
#define NV_PGRAPH_STATUS_DMA_BUFFER_NOTIFY                    21:21 /* R-IVF */
1256
#define NV_PGRAPH_STATUS_DMA_BUFFER_NOTIFY_IDLE          0x00000000 /* R-I-V */
1257
#define NV_PGRAPH_STATUS_DMA_BUFFER_NOTIFY_BUSY          0x00000001 /* R---V */
1258
#define NV_PGRAPH_STATUS_D3D                                  24:24 /* R-IVF */
1259
#define NV_PGRAPH_STATUS_D3D_IDLE                        0x00000000 /* R-I-V */
1260
#define NV_PGRAPH_STATUS_D3D_BUSY                        0x00000001 /* R---V */
1261
#define NV_PGRAPH_STATUS_CACHE                                25:25 /* R-IVF */
1262
#define NV_PGRAPH_STATUS_CACHE_IDLE                      0x00000000 /* R-I-V */
1263
#define NV_PGRAPH_STATUS_CACHE_BUSY                      0x00000001 /* R---V */
1264
#define NV_PGRAPH_STATUS_LIGHTING                             26:26 /* R-IVF */
1265
#define NV_PGRAPH_STATUS_LIGHTING_IDLE                   0x00000000 /* R-I-V */
1266
#define NV_PGRAPH_STATUS_LIGHTING_BUSY                   0x00000001 /* R---V */
1267
#define NV_PGRAPH_STATUS_PREROP                               27:27 /* R-IVF */
1268
#define NV_PGRAPH_STATUS_PREROP_IDLE                     0x00000000 /* R-I-V */
1269
#define NV_PGRAPH_STATUS_PREROP_BUSY                     0x00000001 /* R---V */
1270
#define NV_PGRAPH_STATUS_ROP                                  28:28 /* R-IVF */
1271
#define NV_PGRAPH_STATUS_ROP_IDLE                        0x00000000 /* R-I-V */
1272
#define NV_PGRAPH_STATUS_ROP_BUSY                        0x00000001 /* R---V */
1273
#define NV_PGRAPH_STATUS_PORT_USER                            29:29 /* R-IVF */
1274
#define NV_PGRAPH_STATUS_PORT_USER_IDLE                  0x00000000 /* R-I-V */
1275
#define NV_PGRAPH_STATUS_PORT_USER_BUSY                  0x00000001 /* R---V */
1276
#define NV_PGRAPH_TRAPPED_ADDR                           0x00400704 /* R--4R */
1277
#define NV_PGRAPH_TRAPPED_ADDR_MTHD                            12:2 /* R-XUF */
1278
#define NV_PGRAPH_TRAPPED_ADDR_SUBCH                          15:13 /* R-XUF */
1279
#define NV_PGRAPH_TRAPPED_ADDR_CHID                           27:24 /* R-XUF */
1280
#define NV_PGRAPH_TRAPPED_DATA                           0x00400708 /* R--4R */
1281
#define NV_PGRAPH_TRAPPED_DATA_VALUE                           31:0 /* R-XVF */
1282
#define NV_PGRAPH_SURFACE                                0x0040070C /* RW-4R */
1283
#define NV_PGRAPH_SURFACE_TYPE                                  1:0 /* RWIVF */
1284
#define NV_PGRAPH_SURFACE_TYPE_INVALID                   0x00000000 /* RWI-V */
1285
#define NV_PGRAPH_SURFACE_TYPE_NON_SWIZZLE               0x00000001 /* RW--V */
1286
#define NV_PGRAPH_SURFACE_TYPE_SWIZZLE                   0x00000002 /* RW--V */
1287
#define NV_PGRAPH_NOTIFY                                 0x00400714 /* RW-4R */
1288
#define NV_PGRAPH_NOTIFY_BUFFER_REQ                             0:0 /* RWIVF */
1289
#define NV_PGRAPH_NOTIFY_BUFFER_REQ_NOT_PENDING          0x00000000 /* RWI-V */
1290
#define NV_PGRAPH_NOTIFY_BUFFER_REQ_PENDING              0x00000001 /* RW--V */
1291
#define NV_PGRAPH_NOTIFY_BUFFER_STYLE                           8:8 /* RWIVF */
1292
#define NV_PGRAPH_NOTIFY_BUFFER_STYLE_WRITE_ONLY         0x00000000 /* RWI-V */
1293
#define NV_PGRAPH_NOTIFY_BUFFER_STYLE_WRITE_THEN_AWAKEN  0x00000001 /* RW--V */
1294
#define NV_PGRAPH_NOTIFY_REQ                                  16:16 /* RWIVF */
1295
#define NV_PGRAPH_NOTIFY_REQ_NOT_PENDING                 0x00000000 /* RWI-V */
1296
#define NV_PGRAPH_NOTIFY_REQ_PENDING                     0x00000001 /* RW--V */
1297
#define NV_PGRAPH_NOTIFY_STYLE                                20:20 /* RWIVF */
1298
#define NV_PGRAPH_NOTIFY_STYLE_WRITE_ONLY                0x00000000 /* RWI-V */
1299
#define NV_PGRAPH_NOTIFY_STYLE_WRITE_THEN_AWAKEN         0x00000001 /* RW--V */
1300
#define NV_PGRAPH_BOFFSET(i)                     (0x00400640+(i)*4) /* RW-4A */
1301
#define NV_PGRAPH_BOFFSET__SIZE_1                                 6 /*       */
1302
#define NV_PGRAPH_BOFFSET_LINADRS                              23:0 /* RWIUF */
1303
#define NV_PGRAPH_BOFFSET_LINADRS_0                      0x00000000 /* RWI-V */
1304
#define NV_PGRAPH_BOFFSET0                               0x00400640 /* RW-4R */
1305
#define NV_PGRAPH_BOFFSET0__ALIAS_1            NV_PGRAPH_BOFFSET(0) /*       */
1306
#define NV_PGRAPH_BOFFSET0_LINADRS                             23:0 /* RWIUF */
1307
#define NV_PGRAPH_BOFFSET0_LINADRS_0                     0x00000000 /* RWI-V */
1308
#define NV_PGRAPH_BOFFSET1                               0x00400644 /* RW-4R */
1309
#define NV_PGRAPH_BOFFSET1__ALIAS_1            NV_PGRAPH_BOFFSET(1) /*       */
1310
#define NV_PGRAPH_BOFFSET1_LINADRS                             23:0 /* RWIUF */
1311
#define NV_PGRAPH_BOFFSET1_LINADRS_0                     0x00000000 /* RWI-V */
1312
#define NV_PGRAPH_BOFFSET2                               0x00400648 /* RW-4R */
1313
#define NV_PGRAPH_BOFFSET2__ALIAS_1            NV_PGRAPH_BOFFSET(2) /*       */
1314
#define NV_PGRAPH_BOFFSET2_LINADRS                             23:0 /* RWIUF */
1315
#define NV_PGRAPH_BOFFSET2_LINADRS_0                     0x00000000 /* RWI-V */
1316
#define NV_PGRAPH_BOFFSET3                               0x0040064C /* RW-4R */
1317
#define NV_PGRAPH_BOFFSET3__ALIAS_1            NV_PGRAPH_BOFFSET(3) /*       */
1318
#define NV_PGRAPH_BOFFSET3_LINADRS                             23:0 /* RWIUF */
1319
#define NV_PGRAPH_BOFFSET3_LINADRS_0                     0x00000000 /* RWI-V */
1320
#define NV_PGRAPH_BOFFSET4                               0x00400650 /* RW-4R */
1321
#define NV_PGRAPH_BOFFSET4__ALIAS_1            NV_PGRAPH_BOFFSET(4) /*       */
1322
#define NV_PGRAPH_BOFFSET4_LINADRS                             23:0 /* RWIUF */
1323
#define NV_PGRAPH_BOFFSET4_LINADRS_0                     0x00000000 /* RWI-V */
1324
#define NV_PGRAPH_BOFFSET5                               0x00400654 /* RW-4R */
1325
#define NV_PGRAPH_BOFFSET5__ALIAS_1            NV_PGRAPH_BOFFSET(5) /*       */
1326
#define NV_PGRAPH_BOFFSET5_LINADRS                             23:0 /* RWIUF */
1327
#define NV_PGRAPH_BOFFSET5_LINADRS_0                     0x00000000 /* RWI-V */
1328
#define NV_PGRAPH_BBASE(i)                       (0x00400658+(i)*4) /* RW-4A */
1329
#define NV_PGRAPH_BBASE__SIZE_1                                   6 /*       */
1330
#define NV_PGRAPH_BBASE_LINADRS                                23:0 /* RWIUF */
1331
#define NV_PGRAPH_BBASE_LINADRS_0                        0x00000000 /* RWI-V */
1332
#define NV_PGRAPH_BBASE0                                 0x00400658 /* RW-4R */
1333
#define NV_PGRAPH_BBASE0__ALIAS_1                NV_PGRAPH_BBASE(0) /*       */
1334
#define NV_PGRAPH_BBASE0_LINADRS                               23:0 /* RWIUF */
1335
#define NV_PGRAPH_BBASE0_LINADRS_0                       0x00000000 /* RWI-V */
1336
#define NV_PGRAPH_BBASE1                                 0x0040065c /* RW-4R */
1337
#define NV_PGRAPH_BBASE1__ALIAS_1                NV_PGRAPH_BBASE(1) /*       */
1338
#define NV_PGRAPH_BBASE1_LINADRS                               23:0 /* RWIUF */
1339
#define NV_PGRAPH_BBASE1_LINADRS_0                       0x00000000 /* RWI-V */
1340
#define NV_PGRAPH_BBASE2                                 0x00400660 /* RW-4R */
1341
#define NV_PGRAPH_BBASE2__ALIAS_1                NV_PGRAPH_BBASE(2) /*       */
1342
#define NV_PGRAPH_BBASE2_LINADRS                               23:0 /* RWIUF */
1343
#define NV_PGRAPH_BBASE2_LINADRS_0                       0x00000000 /* RWI-V */
1344
#define NV_PGRAPH_BBASE3                                 0x00400664 /* RW-4R */
1345
#define NV_PGRAPH_BBASE3__ALIAS_1                NV_PGRAPH_BBASE(3) /*       */
1346
#define NV_PGRAPH_BBASE3_LINADRS                               23:0 /* RWIUF */
1347
#define NV_PGRAPH_BBASE3_LINADRS_0                       0x00000000 /* RWI-V */
1348
#define NV_PGRAPH_BBASE4                                 0x00400668 /* RW-4R */
1349
#define NV_PGRAPH_BBASE4__ALIAS_1                NV_PGRAPH_BBASE(4) /*       */
1350
#define NV_PGRAPH_BBASE4_LINADRS                               23:0 /* RWIUF */
1351
#define NV_PGRAPH_BBASE4_LINADRS_0                       0x00000000 /* RWI-V */
1352
#define NV_PGRAPH_BBASE5                                 0x0040066C /* RW-4R */
1353
#define NV_PGRAPH_BBASE5__ALIAS_1                NV_PGRAPH_BBASE(5) /*       */
1354
#define NV_PGRAPH_BBASE5_LINADRS                               23:0 /* RWIUF */
1355
#define NV_PGRAPH_BBASE5_LINADRS_0                       0x00000000 /* RWI-V */
1356
#define NV_PGRAPH_BPITCH(i)                      (0x00400670+(i)*4) /* RW-4A */
1357
#define NV_PGRAPH_BPITCH__SIZE_1                                  5 /*       */
1358
#define NV_PGRAPH_BPITCH_VALUE                                 12:0 /* RWIUF */
1359
#define NV_PGRAPH_BPITCH_VALUE_0                         0x00000000 /* RWI-V */
1360
#define NV_PGRAPH_BPITCH0                                0x00400670 /* RW-4R */
1361
#define NV_PGRAPH_BPITCH0__ALIAS_1              NV_PGRAPH_BPITCH(0) /*       */
1362
#define NV_PGRAPH_BPITCH0_VALUE                                12:0 /* RWIUF */
1363
#define NV_PGRAPH_BPITCH0_VALUE_0                        0x00000000 /* RWI-V */
1364
#define NV_PGRAPH_BPITCH1                                0x00400674 /* RW-4R */
1365
#define NV_PGRAPH_BPITCH1__ALIAS_1              NV_PGRAPH_BPITCH(1) /*       */
1366
#define NV_PGRAPH_BPITCH1_VALUE                                12:0 /* RWIUF */
1367
#define NV_PGRAPH_BPITCH1_VALUE_0                        0x00000000 /* RWI-V */
1368
#define NV_PGRAPH_BPITCH2                                0x00400678 /* RW-4R */
1369
#define NV_PGRAPH_BPITCH2__ALIAS_1              NV_PGRAPH_BPITCH(2) /*       */
1370
#define NV_PGRAPH_BPITCH2_VALUE                                12:0 /* RWIUF */
1371
#define NV_PGRAPH_BPITCH2_VALUE_0                        0x00000000 /* RWI-V */
1372
#define NV_PGRAPH_BPITCH3                                0x0040067C /* RW-4R */
1373
#define NV_PGRAPH_BPITCH3__ALIAS_1              NV_PGRAPH_BPITCH(3) /*       */
1374
#define NV_PGRAPH_BPITCH3_VALUE                                12:0 /* RWIUF */
1375
#define NV_PGRAPH_BPITCH3_VALUE_0                        0x00000000 /* RWI-V */
1376
#define NV_PGRAPH_BPITCH4                                0x00400680 /* RW-4R */
1377
#define NV_PGRAPH_BPITCH4__ALIAS_1              NV_PGRAPH_BPITCH(4) /*       */
1378
#define NV_PGRAPH_BPITCH4_VALUE                                12:0 /* RWIUF */
1379
#define NV_PGRAPH_BPITCH4_VALUE_0                        0x00000000 /* RWI-V */
1380
#define NV_PGRAPH_BLIMIT(i)                      (0x00400684+(i)*4) /* RW-4A */
1381
#define NV_PGRAPH_BLIMIT__SIZE_1                                  6 /*       */
1382
#define NV_PGRAPH_BLIMIT_VALUE                                 23:0 /* RWXUF */
1383
#define NV_PGRAPH_BLIMIT_TYPE                                 31:31 /* RWIVF */
1384
#define NV_PGRAPH_BLIMIT_TYPE_IN_MEMORY                  0x00000000 /* RW--V */
1385
#define NV_PGRAPH_BLIMIT_TYPE_NULL                       0x00000001 /* RWI-V */
1386
#define NV_PGRAPH_BLIMIT0                                0x00400684 /* RW-4R */
1387
#define NV_PGRAPH_BLIMIT0__ALIAS_1              NV_PGRAPH_BLIMIT(0) /*       */
1388
#define NV_PGRAPH_BLIMIT0_VALUE                                23:0 /* RWXUF */
1389
#define NV_PGRAPH_BLIMIT0_TYPE                                31:31 /* RWIVF */
1390
#define NV_PGRAPH_BLIMIT0_TYPE_IN_MEMORY                 0x00000000 /* RW--V */
1391
#define NV_PGRAPH_BLIMIT0_TYPE_NULL                      0x00000001 /* RWI-V */
1392
#define NV_PGRAPH_BLIMIT1                                0x00400688 /* RW-4R */
1393
#define NV_PGRAPH_BLIMIT1__ALIAS_1              NV_PGRAPH_BLIMIT(1) /*       */
1394
#define NV_PGRAPH_BLIMIT1_VALUE                                23:0 /* RWXUF */
1395
#define NV_PGRAPH_BLIMIT1_TYPE                                31:31 /* RWIVF */
1396
#define NV_PGRAPH_BLIMIT1_TYPE_IN_MEMORY                 0x00000000 /* RW--V */
1397
#define NV_PGRAPH_BLIMIT1_TYPE_NULL                      0x00000001 /* RWI-V */
1398
#define NV_PGRAPH_BLIMIT2                                0x0040068c /* RW-4R */
1399
#define NV_PGRAPH_BLIMIT2__ALIAS_1              NV_PGRAPH_BLIMIT(2) /*       */
1400
#define NV_PGRAPH_BLIMIT2_VALUE                                23:0 /* RWXUF */
1401
#define NV_PGRAPH_BLIMIT2_TYPE                                31:31 /* RWIVF */
1402
#define NV_PGRAPH_BLIMIT2_TYPE_IN_MEMORY                 0x00000000 /* RW--V */
1403
#define NV_PGRAPH_BLIMIT2_TYPE_NULL                      0x00000001 /* RWI-V */
1404
#define NV_PGRAPH_BLIMIT3                                0x00400690 /* RW-4R */
1405
#define NV_PGRAPH_BLIMIT3__ALIAS_1              NV_PGRAPH_BLIMIT(3) /*       */
1406
#define NV_PGRAPH_BLIMIT3_VALUE                                23:0 /* RWXUF */
1407
#define NV_PGRAPH_BLIMIT3_TYPE                                31:31 /* RWIVF */
1408
#define NV_PGRAPH_BLIMIT3_TYPE_IN_MEMORY                 0x00000000 /* RW--V */
1409
#define NV_PGRAPH_BLIMIT3_TYPE_NULL                      0x00000001 /* RWI-V */
1410
#define NV_PGRAPH_BLIMIT4                                0x00400694 /* RW-4R */
1411
#define NV_PGRAPH_BLIMIT4__ALIAS_1              NV_PGRAPH_BLIMIT(4) /*       */
1412
#define NV_PGRAPH_BLIMIT4_VALUE                                23:0 /* RWXUF */
1413
#define NV_PGRAPH_BLIMIT4_TYPE                                31:31 /* RWIVF */
1414
#define NV_PGRAPH_BLIMIT4_TYPE_IN_MEMORY                 0x00000000 /* RW--V */
1415
#define NV_PGRAPH_BLIMIT4_TYPE_NULL                      0x00000001 /* RWI-V */
1416
#define NV_PGRAPH_BLIMIT5                                0x00400698 /* RW-4R */
1417
#define NV_PGRAPH_BLIMIT5__ALIAS_1              NV_PGRAPH_BLIMIT(5) /*       */
1418
#define NV_PGRAPH_BLIMIT5_VALUE                                23:0 /* RWXUF */
1419
#define NV_PGRAPH_BLIMIT5_TYPE                                31:31 /* RWIVF */
1420
#define NV_PGRAPH_BLIMIT5_TYPE_IN_MEMORY                 0x00000000 /* RW--V */
1421
#define NV_PGRAPH_BLIMIT5_TYPE_NULL                      0x00000001 /* RWI-V */
1422
#define NV_PGRAPH_BSWIZZLE2                              0x0040069c /* RW-4R */
1423
#define NV_PGRAPH_BSWIZZLE2_WIDTH                             19:16 /* RWIUF */
1424
#define NV_PGRAPH_BSWIZZLE2_WIDTH_0                      0x00000000 /* RWI-V */
1425
#define NV_PGRAPH_BSWIZZLE2_HEIGHT                            27:24 /* RWIUF */
1426
#define NV_PGRAPH_BSWIZZLE2_HEIGHT_0                     0x00000000 /* RWI-V */
1427
#define NV_PGRAPH_BSWIZZLE5                              0x004006a0 /* RW-4R */
1428
#define NV_PGRAPH_BSWIZZLE5_WIDTH                             19:16 /* RWIUF */
1429
#define NV_PGRAPH_BSWIZZLE5_WIDTH_0                      0x00000000 /* RWI-V */
1430
#define NV_PGRAPH_BSWIZZLE5_HEIGHT                            27:24 /* RWIUF */
1431
#define NV_PGRAPH_BSWIZZLE5_HEIGHT_0                     0x00000000 /* RWI-V */
1432
#define NV_PGRAPH_BPIXEL                                 0x00400724 /* RW-4R */
1433
#define NV_PGRAPH_BPIXEL_DEPTH0                                 3:0 /* RWIVF */
1434
#define NV_PGRAPH_BPIXEL_DEPTH0_INVALID                  0x00000000 /* RWI-V */
1435
#define NV_PGRAPH_BPIXEL_DEPTH0_Y8                       0x00000001 /* RW--V */
1436
#define NV_PGRAPH_BPIXEL_DEPTH0_X1R5G5B5_Z1R5G5B5        0x00000002 /* RW--V */
1437
#define NV_PGRAPH_BPIXEL_DEPTH0_X1R5G5B5_O1R5G5B5        0x00000003 /* RW--V */
1438
#define NV_PGRAPH_BPIXEL_DEPTH0_A1R5G5B5                 0x00000004 /* RW--V */
1439
#define NV_PGRAPH_BPIXEL_DEPTH0_R5G6B5                   0x00000005 /* RW--V */
1440
#define NV_PGRAPH_BPIXEL_DEPTH0_Y16                      0x00000006 /* RW--V */
1441
#define NV_PGRAPH_BPIXEL_DEPTH0_X8R8G8B8_Z8R8G8B8        0x00000007 /* RW--V */
1442
#define NV_PGRAPH_BPIXEL_DEPTH0_X8R8G8B8_O1Z7R8G8B8      0x00000008 /* RW--V */
1443
#define NV_PGRAPH_BPIXEL_DEPTH0_X1A7R8G8B8_Z1A7R8G8B8    0x00000009 /* RW--V */
1444
#define NV_PGRAPH_BPIXEL_DEPTH0_X1A7R8G8B8_O1A7R8G8B8    0x0000000a /* RW--V */
1445
#define NV_PGRAPH_BPIXEL_DEPTH0_X8R8G8B8_O8R8G8B8        0x0000000b /* RW--V */
1446
#define NV_PGRAPH_BPIXEL_DEPTH0_A8R8G8B8                 0x0000000c /* RW--V */
1447
#define NV_PGRAPH_BPIXEL_DEPTH0_Y32                      0x0000000d /* RW--V */
1448
#define NV_PGRAPH_BPIXEL_DEPTH0_V8YB8U8YA8               0x0000000e /* RW--V */
1449
#define NV_PGRAPH_BPIXEL_DEPTH0_YB8V8YA8U8               0x0000000f /* RW--V */ 
1450
#define NV_PGRAPH_BPIXEL_DEPTH1                                 7:4 /* RWIVF */
1451
#define NV_PGRAPH_BPIXEL_DEPTH1_INVALID                  0x00000000 /* RWI-V */
1452
#define NV_PGRAPH_BPIXEL_DEPTH1_Y8                       0x00000001 /* RW--V */
1453
#define NV_PGRAPH_BPIXEL_DEPTH1_X1R5G5B5_Z1R5G5B5        0x00000002 /* RW--V */
1454
#define NV_PGRAPH_BPIXEL_DEPTH1_X1R5G5B5_O1R5G5B5        0x00000003 /* RW--V */
1455
#define NV_PGRAPH_BPIXEL_DEPTH1_A1R5G5B5                 0x00000004 /* RW--V */
1456
#define NV_PGRAPH_BPIXEL_DEPTH1_R5G6B5                   0x00000005 /* RW--V */
1457
#define NV_PGRAPH_BPIXEL_DEPTH1_Y16                      0x00000006 /* RW--V */
1458
#define NV_PGRAPH_BPIXEL_DEPTH1_X8R8G8B8_Z8R8G8B8        0x00000007 /* RW--V */
1459
#define NV_PGRAPH_BPIXEL_DEPTH1_X8R8G8B8_O1Z7R8G8B8      0x00000008 /* RW--V */
1460
#define NV_PGRAPH_BPIXEL_DEPTH1_X1A7R8G8B8_Z1A7R8G8B8    0x00000009 /* RW--V */
1461
#define NV_PGRAPH_BPIXEL_DEPTH1_X1A7R8G8B8_O1A7R8G8B8    0x0000000a /* RW--V */
1462
#define NV_PGRAPH_BPIXEL_DEPTH1_X8R8G8B8_O8R8G8B8        0x0000000b /* RW--V */
1463
#define NV_PGRAPH_BPIXEL_DEPTH1_A8R8G8B8                 0x0000000c /* RW--V */
1464
#define NV_PGRAPH_BPIXEL_DEPTH1_Y32                      0x0000000d /* RW--V */
1465
#define NV_PGRAPH_BPIXEL_DEPTH1_V8YB8U8YA8               0x0000000e /* RW--V */
1466
#define NV_PGRAPH_BPIXEL_DEPTH1_YB8V8YA8U8               0x0000000f /* RW--V */ 
1467
#define NV_PGRAPH_BPIXEL_DEPTH2                                11:8 /* RWIVF */
1468
#define NV_PGRAPH_BPIXEL_DEPTH2_INVALID                  0x00000000 /* RWI-V */
1469
#define NV_PGRAPH_BPIXEL_DEPTH2_Y8                       0x00000001 /* RW--V */
1470
#define NV_PGRAPH_BPIXEL_DEPTH2_X1R5G5B5_Z1R5G5B5        0x00000002 /* RW--V */
1471
#define NV_PGRAPH_BPIXEL_DEPTH2_X1R5G5B5_O1R5G5B5        0x00000003 /* RW--V */
1472
#define NV_PGRAPH_BPIXEL_DEPTH2_A1R5G5B5                 0x00000004 /* RW--V */
1473
#define NV_PGRAPH_BPIXEL_DEPTH2_R5G6B5                   0x00000005 /* RW--V */
1474
#define NV_PGRAPH_BPIXEL_DEPTH2_Y16                      0x00000006 /* RW--V */
1475
#define NV_PGRAPH_BPIXEL_DEPTH2_X8R8G8B8_Z8R8G8B8        0x00000007 /* RW--V */
1476
#define NV_PGRAPH_BPIXEL_DEPTH2_X8R8G8B8_O1Z7R8G8B8      0x00000008 /* RW--V */
1477
#define NV_PGRAPH_BPIXEL_DEPTH2_X1A7R8G8B8_Z1A7R8G8B8    0x00000009 /* RW--V */
1478
#define NV_PGRAPH_BPIXEL_DEPTH2_X1A7R8G8B8_O1A7R8G8B8    0x0000000a /* RW--V */
1479
#define NV_PGRAPH_BPIXEL_DEPTH2_X8R8G8B8_O8R8G8B8        0x0000000b /* RW--V */
1480
#define NV_PGRAPH_BPIXEL_DEPTH2_A8R8G8B8                 0x0000000c /* RW--V */
1481
#define NV_PGRAPH_BPIXEL_DEPTH2_Y32                      0x0000000d /* RW--V */
1482
#define NV_PGRAPH_BPIXEL_DEPTH2_V8YB8U8YA8               0x0000000e /* RW--V */
1483
#define NV_PGRAPH_BPIXEL_DEPTH2_YB8V8YA8U8               0x0000000f /* RW--V */ 
1484
#define NV_PGRAPH_BPIXEL_DEPTH3                               15:12 /* RWIVF */
1485
#define NV_PGRAPH_BPIXEL_DEPTH3_INVALID                  0x00000000 /* RWI-V */
1486
#define NV_PGRAPH_BPIXEL_DEPTH3_Y8                       0x00000001 /* RW--V */
1487
#define NV_PGRAPH_BPIXEL_DEPTH3_X1R5G5B5_Z1R5G5B5        0x00000002 /* RW--V */
1488
#define NV_PGRAPH_BPIXEL_DEPTH3_X1R5G5B5_O1R5G5B5        0x00000003 /* RW--V */
1489
#define NV_PGRAPH_BPIXEL_DEPTH3_A1R5G5B5                 0x00000004 /* RW--V */
1490
#define NV_PGRAPH_BPIXEL_DEPTH3_R5G6B5                   0x00000005 /* RW--V */
1491
#define NV_PGRAPH_BPIXEL_DEPTH3_Y16                      0x00000006 /* RW--V */
1492
#define NV_PGRAPH_BPIXEL_DEPTH3_X8R8G8B8_Z8R8G8B8        0x00000007 /* RW--V */
1493
#define NV_PGRAPH_BPIXEL_DEPTH3_X8R8G8B8_O1Z7R8G8B8      0x00000008 /* RW--V */
1494
#define NV_PGRAPH_BPIXEL_DEPTH3_X1A7R8G8B8_Z1A7R8G8B8    0x00000009 /* RW--V */
1495
#define NV_PGRAPH_BPIXEL_DEPTH3_X1A7R8G8B8_O1A7R8G8B8    0x0000000a /* RW--V */
1496
#define NV_PGRAPH_BPIXEL_DEPTH3_X8R8G8B8_O8R8G8B8        0x0000000b /* RW--V */
1497
#define NV_PGRAPH_BPIXEL_DEPTH3_A8R8G8B8                 0x0000000c /* RW--V */
1498
#define NV_PGRAPH_BPIXEL_DEPTH3_Y32                      0x0000000d /* RW--V */
1499
#define NV_PGRAPH_BPIXEL_DEPTH3_V8YB8U8YA8               0x0000000e /* RW--V */
1500
#define NV_PGRAPH_BPIXEL_DEPTH3_YB8V8YA8U8               0x0000000f /* RW--V */ 
1501
#define NV_PGRAPH_BPIXEL_DEPTH4                               19:16 /* RWIVF */
1502
#define NV_PGRAPH_BPIXEL_DEPTH4_INVALID                  0x00000000 /* RWI-V */
1503
#define NV_PGRAPH_BPIXEL_DEPTH4_Y8                       0x00000001 /* RW--V */
1504
#define NV_PGRAPH_BPIXEL_DEPTH4_X1R5G5B5_Z1R5G5B5        0x00000002 /* RW--V */
1505
#define NV_PGRAPH_BPIXEL_DEPTH4_X1R5G5B5_O1R5G5B5        0x00000003 /* RW--V */
1506
#define NV_PGRAPH_BPIXEL_DEPTH4_A1R5G5B5                 0x00000004 /* RW--V */
1507
#define NV_PGRAPH_BPIXEL_DEPTH4_R5G6B5                   0x00000005 /* RW--V */
1508
#define NV_PGRAPH_BPIXEL_DEPTH4_Y16                      0x00000006 /* RW--V */
1509
#define NV_PGRAPH_BPIXEL_DEPTH4_X8R8G8B8_Z8R8G8B8        0x00000007 /* RW--V */
1510
#define NV_PGRAPH_BPIXEL_DEPTH4_X8R8G8B8_O1Z7R8G8B8      0x00000008 /* RW--V */
1511
#define NV_PGRAPH_BPIXEL_DEPTH4_X1A7R8G8B8_Z1A7R8G8B8    0x00000009 /* RW--V */
1512
#define NV_PGRAPH_BPIXEL_DEPTH4_X1A7R8G8B8_O1A7R8G8B8    0x0000000a /* RW--V */
1513
#define NV_PGRAPH_BPIXEL_DEPTH4_X8R8G8B8_O8R8G8B8        0x0000000b /* RW--V */
1514
#define NV_PGRAPH_BPIXEL_DEPTH4_A8R8G8B8                 0x0000000c /* RW--V */
1515
#define NV_PGRAPH_BPIXEL_DEPTH4_Y32                      0x0000000d /* RW--V */
1516
#define NV_PGRAPH_BPIXEL_DEPTH4_V8YB8U8YA8               0x0000000e /* RW--V */
1517
#define NV_PGRAPH_BPIXEL_DEPTH4_YB8V8YA8U8               0x0000000f /* RW--V */ 
1518
#define NV_PGRAPH_BPIXEL_DEPTH5                               23:20 /* RWIVF */
1519
#define NV_PGRAPH_BPIXEL_DEPTH5_INVALID                  0x00000000 /* RWI-V */
1520
#define NV_PGRAPH_BPIXEL_DEPTH5_Y8                       0x00000001 /* RW--V */
1521
#define NV_PGRAPH_BPIXEL_DEPTH5_X1R5G5B5_Z1R5G5B5        0x00000002 /* RW--V */
1522
#define NV_PGRAPH_BPIXEL_DEPTH5_X1R5G5B5_O1R5G5B5        0x00000003 /* RW--V */
1523
#define NV_PGRAPH_BPIXEL_DEPTH5_A1R5G5B5                 0x00000004 /* RW--V */
1524
#define NV_PGRAPH_BPIXEL_DEPTH5_R5G6B5                   0x00000005 /* RW--V */
1525
#define NV_PGRAPH_BPIXEL_DEPTH5_Y16                      0x00000006 /* RW--V */
1526
#define NV_PGRAPH_BPIXEL_DEPTH5_X8R8G8B8_Z8R8G8B8        0x00000007 /* RW--V */
1527
#define NV_PGRAPH_BPIXEL_DEPTH5_X8R8G8B8_O1Z7R8G8B8      0x00000008 /* RW--V */
1528
#define NV_PGRAPH_BPIXEL_DEPTH5_X1A7R8G8B8_Z1A7R8G8B8    0x00000009 /* RW--V */
1529
#define NV_PGRAPH_BPIXEL_DEPTH5_X1A7R8G8B8_O1A7R8G8B8    0x0000000a /* RW--V */
1530
#define NV_PGRAPH_BPIXEL_DEPTH5_X8R8G8B8_O8R8G8B8        0x0000000b /* RW--V */
1531
#define NV_PGRAPH_BPIXEL_DEPTH5_A8R8G8B8                 0x0000000c /* RW--V */
1532
#define NV_PGRAPH_BPIXEL_DEPTH5_Y32                      0x0000000d /* RW--V */
1533
#define NV_PGRAPH_BPIXEL_DEPTH5_V8YB8U8YA8               0x0000000e /* RW--V */
1534
#define NV_PGRAPH_BPIXEL_DEPTH5_YB8V8YA8U8               0x0000000f /* RW--V */ 
1535
#define NV_PGRAPH_LIMIT_VIOL_PIX                         0x00400610 /* RW-4R */
1536
#define NV_PGRAPH_LIMIT_VIOL_PIX_ADRS                          23:0 /* RWIVF */
1537
#define NV_PGRAPH_LIMIT_VIOL_PIX_ADRS_0                  0x00000000 /* RWI-V */
1538
#define NV_PGRAPH_LIMIT_VIOL_PIX_BLIT                         29:29 /* RWIVF */
1539
#define NV_PGRAPH_LIMIT_VIOL_PIX_BLIT_NO_VIOL            0x00000000 /* RWI-V */
1540
#define NV_PGRAPH_LIMIT_VIOL_PIX_BLIT_VIOL               0x00000001 /* RW--V */
1541
#define NV_PGRAPH_LIMIT_VIOL_PIX_LIMIT                        30:30 /* RWIVF */
1542
#define NV_PGRAPH_LIMIT_VIOL_PIX_LIMIT_NO_VIOL           0x00000000 /* RWI-V */
1543
#define NV_PGRAPH_LIMIT_VIOL_PIX_LIMIT_VIOL              0x00000001 /* RW--V */
1544
#define NV_PGRAPH_LIMIT_VIOL_PIX_OVRFLW                       31:31 /* RWIVF */
1545
#define NV_PGRAPH_LIMIT_VIOL_PIX_OVRFLW_NO_VIOL          0x00000000 /* RWI-V */
1546
#define NV_PGRAPH_LIMIT_VIOL_PIX_OVRFLW_VIOL             0x00000001 /* RW--V */
1547
#define NV_PGRAPH_LIMIT_VIOL_Z                           0x00400614 /* RW-4R */
1548
#define NV_PGRAPH_LIMIT_VIOL_Z_ADRS                            23:0 /* RWIVF */
1549
#define NV_PGRAPH_LIMIT_VIOL_Z_ADRS_0                    0x00000000 /* RWI-V */
1550
#define NV_PGRAPH_LIMIT_VIOL_Z_LIMIT                          30:30 /* RWIVF */
1551
#define NV_PGRAPH_LIMIT_VIOL_Z_LIMIT_NO_VIOL             0x00000000 /* RWI-V */
1552
#define NV_PGRAPH_LIMIT_VIOL_Z_LIMIT_VIOL                0x00000001 /* RW--V */
1553
#define NV_PGRAPH_LIMIT_VIOL_Z_OVRFLW                         31:31 /* RWIVF */
1554
#define NV_PGRAPH_LIMIT_VIOL_Z_OVRFLW_NO_VIOL            0x00000000 /* RWI-V */
1555
#define NV_PGRAPH_LIMIT_VIOL_Z_OVRFLW_VIOL               0x00000001 /* RW--V */
1556
#define NV_PGRAPH_STATE                                  0x00400710 /* RW-4R */
1557
#define NV_PGRAPH_STATE_BUFFER_0                                0:0 /* RWIVF */
1558
#define NV_PGRAPH_STATE_BUFFER_0_INVALID                 0x00000000 /* RWI-V */
1559
#define NV_PGRAPH_STATE_BUFFER_0_VALID                   0x00000001 /* RW--V */
1560
#define NV_PGRAPH_STATE_BUFFER_1                                1:1 /* RWIVF */
1561
#define NV_PGRAPH_STATE_BUFFER_1_INVALID                 0x00000000 /* RWI-V */
1562
#define NV_PGRAPH_STATE_BUFFER_1_VALID                   0x00000001 /* RW--V */
1563
#define NV_PGRAPH_STATE_BUFFER_2                                2:2 /* RWIVF */
1564
#define NV_PGRAPH_STATE_BUFFER_2_INVALID                 0x00000000 /* RWI-V */
1565
#define NV_PGRAPH_STATE_BUFFER_2_VALID                   0x00000001 /* RW--V */
1566
#define NV_PGRAPH_STATE_BUFFER_3                                3:3 /* RWIVF */
1567
#define NV_PGRAPH_STATE_BUFFER_3_INVALID                 0x00000000 /* RWI-V */
1568
#define NV_PGRAPH_STATE_BUFFER_3_VALID                   0x00000001 /* RW--V */
1569
#define NV_PGRAPH_STATE_BUFFER_4                                4:4 /* RWIVF */
1570
#define NV_PGRAPH_STATE_BUFFER_4_INVALID                 0x00000000 /* RWI-V */
1571
#define NV_PGRAPH_STATE_BUFFER_4_VALID                   0x00000001 /* RW--V */
1572
#define NV_PGRAPH_STATE_BUFFER_5                                5:5 /* RWIVF */
1573
#define NV_PGRAPH_STATE_BUFFER_5_INVALID                 0x00000000 /* RWI-V */
1574
#define NV_PGRAPH_STATE_BUFFER_5_VALID                   0x00000001 /* RW--V */
1575
#define NV_PGRAPH_STATE_PITCH_0                                 8:8 /* RWIVF */
1576
#define NV_PGRAPH_STATE_PITCH_0_INVALID                  0x00000000 /* RWI-V */
1577
#define NV_PGRAPH_STATE_PITCH_0_VALID                    0x00000001 /* RW--V */
1578
#define NV_PGRAPH_STATE_PITCH_1                                 9:9 /* RWIVF */
1579
#define NV_PGRAPH_STATE_PITCH_1_INVALID                  0x00000000 /* RWI-V */
1580
#define NV_PGRAPH_STATE_PITCH_1_VALID                    0x00000001 /* RW--V */
1581
#define NV_PGRAPH_STATE_PITCH_2                               10:10 /* RWIVF */
1582
#define NV_PGRAPH_STATE_PITCH_2_INVALID                  0x00000000 /* RWI-V */
1583
#define NV_PGRAPH_STATE_PITCH_2_VALID                    0x00000001 /* RW--V */
1584
#define NV_PGRAPH_STATE_PITCH_3                               11:11 /* RWIVF */
1585
#define NV_PGRAPH_STATE_PITCH_3_INVALID                  0x00000000 /* RWI-V */
1586
#define NV_PGRAPH_STATE_PITCH_3_VALID                    0x00000001 /* RW--V */
1587
#define NV_PGRAPH_STATE_PITCH_4                               12:12 /* RWIVF */
1588
#define NV_PGRAPH_STATE_PITCH_4_INVALID                  0x00000000 /* RWI-V */
1589
#define NV_PGRAPH_STATE_PITCH_4_VALID                    0x00000001 /* RW--V */
1590
#define NV_PGRAPH_STATE_CHROMA_COLOR                          16:16 /* RWIVF */
1591
#define NV_PGRAPH_STATE_CHROMA_COLOR_INVALID             0x00000000 /* RWI-V */
1592
#define NV_PGRAPH_STATE_CHROMA_COLOR_VALID               0x00000001 /* RW--V */
1593
#define NV_PGRAPH_STATE_CHROMA_COLORFMT                       17:17 /* RWIVF */
1594
#define NV_PGRAPH_STATE_CHROMA_COLORFMT_INVALID          0x00000000 /* RWI-V */
1595
#define NV_PGRAPH_STATE_CHROMA_COLORFMT_VALID            0x00000001 /* RW--V */
1596
#define NV_PGRAPH_STATE_CPATTERN_COLORFMT                     20:20 /* RWIVF */
1597
#define NV_PGRAPH_STATE_CPATTERN_COLORFMT_INVALID        0x00000000 /* RWI-V */
1598
#define NV_PGRAPH_STATE_CPATTERN_COLORFMT_VALID          0x00000001 /* RW--V */
1599
#define NV_PGRAPH_STATE_CPATTERN_MONOFMT                      21:21 /* RWIVF */
1600
#define NV_PGRAPH_STATE_CPATTERN_MONOFMT_INVALID         0x00000000 /* RWI-V */
1601
#define NV_PGRAPH_STATE_CPATTERN_MONOFMT_VALID           0x00000001 /* RW--V */
1602
#define NV_PGRAPH_STATE_CPATTERN_SELECT                       22:22 /* RWIVF */
1603
#define NV_PGRAPH_STATE_CPATTERN_SELECT_INVALID          0x00000000 /* RWI-V */
1604
#define NV_PGRAPH_STATE_CPATTERN_SELECT_VALID            0x00000001 /* RW--V */
1605
#define NV_PGRAPH_STATE_PATTERN_COLOR0                        24:24 /* RWIVF */
1606
#define NV_PGRAPH_STATE_PATTERN_COLOR0_INVALID           0x00000000 /* RWI-V */
1607
#define NV_PGRAPH_STATE_PATTERN_COLOR0_VALID             0x00000001 /* RW--V */
1608
#define NV_PGRAPH_STATE_PATTERN_COLOR1                        25:25 /* RWIVF */
1609
#define NV_PGRAPH_STATE_PATTERN_COLOR1_INVALID           0x00000000 /* RWI-V */
1610
#define NV_PGRAPH_STATE_PATTERN_COLOR1_VALID             0x00000001 /* RW--V */
1611
#define NV_PGRAPH_STATE_PATTERN_PATT0                         26:26 /* RWIVF */
1612
#define NV_PGRAPH_STATE_PATTERN_PATT0_INVALID            0x00000000 /* RWI-V */
1613
#define NV_PGRAPH_STATE_PATTERN_PATT0_VALID              0x00000001 /* RW--V */
1614
#define NV_PGRAPH_STATE_PATTERN_PATT1                         27:27 /* RWIVF */
1615
#define NV_PGRAPH_STATE_PATTERN_PATT1_INVALID            0x00000000 /* RWI-V */
1616
#define NV_PGRAPH_STATE_PATTERN_PATT1_VALID              0x00000001 /* RW--V */
1617
#define NV_PGRAPH_CACHE_INDEX                            0x00400728 /* RW-4R */
1618
#define NV_PGRAPH_CACHE_INDEX_BANK                              2:2 /* RWXVF */
1619
#define NV_PGRAPH_CACHE_INDEX_BANK_10                    0x00000000 /* RW--V */
1620
#define NV_PGRAPH_CACHE_INDEX_BANK_32                    0x00000001 /* RW--V */
1621
#define NV_PGRAPH_CACHE_INDEX_ADRS                             12:3 /* RWXVF */
1622
#define NV_PGRAPH_CACHE_INDEX_ADRS_0                     0x00000000 /* RW--V */
1623
#define NV_PGRAPH_CACHE_INDEX_ADRS_1024                  0x00000400 /* RW--V */
1624
#define NV_PGRAPH_CACHE_INDEX_OP                              14:13 /* RWXVF */
1625
#define NV_PGRAPH_CACHE_INDEX_OP_WR_CACHE                0x00000000 /* RW--V */
1626
#define NV_PGRAPH_CACHE_INDEX_OP_RD_CACHE                0x00000001 /* RW--V */
1627
#define NV_PGRAPH_CACHE_INDEX_OP_RD_INDEX                0x00000002 /* RW--V */
1628
#define NV_PGRAPH_CACHE_RAM                              0x0040072c /* RW-4R */
1629
#define NV_PGRAPH_CACHE_RAM_VALUE                              31:0 /* RWXVF */
1630
#define NV_PGRAPH_DMA_PITCH                              0x00400760 /* RW-4R */
1631
#define NV_PGRAPH_DMA_PITCH_S0                                 15:0 /* RWXSF */
1632
#define NV_PGRAPH_DMA_PITCH_S1                                31:16 /* RWXSF */
1633
#define NV_PGRAPH_DVD_COLORFMT                           0x00400764 /* RW-4R */
1634
#define NV_PGRAPH_DVD_COLORFMT_IMAGE                            5:0 /* RWNVF */
1635
#define NV_PGRAPH_DVD_COLORFMT_IMAGE_FORMAT_INVALID            0x00 /* RWN-V */
1636
#define NV_PGRAPH_DVD_COLORFMT_IMAGE_FORMAT_LE_V8YB8U8YA8      0x12 /* RW--V */
1637
#define NV_PGRAPH_DVD_COLORFMT_IMAGE_FORMAT_LE_YB8V8YA8U8      0x13 /* RW--V */
1638
#define NV_PGRAPH_DVD_COLORFMT_OVLY                             9:8 /* RWNVF */
1639
#define NV_PGRAPH_DVD_COLORFMT_OVLY_FORMAT_INVALID             0x00 /* RWN-V */
1640
#define NV_PGRAPH_DVD_COLORFMT_OVLY_FORMAT_LE_A8Y8U8V8         0x01 /* RW--V */
1641
#define NV_PGRAPH_DVD_COLORFMT_OVLY_FORMAT_LE_A4V6YB6A4U6YA6   0x02 /* RW--V */
1642
#define NV_PGRAPH_DVD_COLORFMT_OVLY_FORMAT_TRANSPARENT         0x03 /* RW--V */
1643
#define NV_PGRAPH_SCALED_FORMAT                          0x00400768 /* RW-4R */
1644
#define NV_PGRAPH_SCALED_FORMAT_ORIGIN                        17:16 /* RWIVF */
1645
#define NV_PGRAPH_SCALED_FORMAT_ORIGIN_INVALID           0x00000000 /* RWI-V */
1646
#define NV_PGRAPH_SCALED_FORMAT_ORIGIN_CENTER            0x00000001 /* RW--V */
1647
#define NV_PGRAPH_SCALED_FORMAT_ORIGIN_CORNER            0x00000002 /* RW--V */
1648
#define NV_PGRAPH_SCALED_FORMAT_INTERPOLATOR                  24:24 /* RWIVF */
1649
#define NV_PGRAPH_SCALED_FORMAT_INTERPOLATOR_ZOH         0x00000000 /* RWI-V */
1650
#define NV_PGRAPH_SCALED_FORMAT_INTERPOLATOR_FOH         0x00000001 /* RW--V */
1651
#define NV_PGRAPH_PATT_COLOR0                            0x00400800 /* RW-4R */
1652
#define NV_PGRAPH_PATT_COLOR0_VALUE                            31:0 /* RWXUF */
1653
#define NV_PGRAPH_PATT_COLOR1                            0x00400804 /* RW-4R */
1654
#define NV_PGRAPH_PATT_COLOR1_VALUE                            31:0 /* RWXUF */
1655
#define NV_PGRAPH_PATT_COLORRAM(i)               (0x00400900+(i)*4) /* R--4A */
1656
#define NV_PGRAPH_PATT_COLORRAM__SIZE_1                          64 /*       */
1657
#define NV_PGRAPH_PATT_COLORRAM_VALUE                          23:0 /* R--UF */
1658
#define NV_PGRAPH_PATTERN(i)                     (0x00400808+(i)*4) /* RW-4A */
1659
#define NV_PGRAPH_PATTERN__SIZE_1                                 2 /*       */
1660
#define NV_PGRAPH_PATTERN_BITMAP                               31:0 /* RWXVF */
1661
#define NV_PGRAPH_PATTERN_SHAPE                          0x00400810 /* RW-4R */
1662
#define NV_PGRAPH_PATTERN_SHAPE_VALUE                           1:0 /* RWXVF */
1663
#define NV_PGRAPH_PATTERN_SHAPE_VALUE_8X_8Y              0x00000000 /* RW--V */
1664
#define NV_PGRAPH_PATTERN_SHAPE_VALUE_64X_1Y             0x00000001 /* RW--V */
1665
#define NV_PGRAPH_PATTERN_SHAPE_VALUE_1X_64Y             0x00000002 /* RW--V */
1666
#define NV_PGRAPH_PATTERN_SHAPE_SELECT                          4:4 /* RWXVF */
1667
#define NV_PGRAPH_PATTERN_SHAPE_SELECT_2COLOR            0x00000000 /* RW--V */
1668
#define NV_PGRAPH_PATTERN_SHAPE_SELECT_FULLCOLOR         0x00000001 /* RW--V */
1669
#define NV_PGRAPH_MONO_COLOR0                            0x00400600 /* RW-4R */
1670
#define NV_PGRAPH_MONO_COLOR0_VALUE                            31:0 /* RWXUF */
1671
#define NV_PGRAPH_ROP3                                   0x00400604 /* RW-4R */
1672
#define NV_PGRAPH_ROP3_VALUE                                    7:0 /* RWXVF */
1673
#define NV_PGRAPH_CHROMA                                 0x00400814 /* RW-4R */
1674
#define NV_PGRAPH_CHROMA_VALUE                                 31:0 /* RWXUF */
1675
#define NV_PGRAPH_BETA_AND                               0x00400608 /* RW-4R */
1676
#define NV_PGRAPH_BETA_AND_VALUE_FRACTION                     30:23 /* RWXUF */
1677
#define NV_PGRAPH_BETA_PREMULT                           0x0040060c /* RW-4R */
1678
#define NV_PGRAPH_BETA_PREMULT_VALUE                           31:0 /* RWXUF */
1679
#define NV_PGRAPH_CONTROL0                               0x00400818 /* RW-4R */
1680
#define NV_PGRAPH_CONTROL1                               0x0040081c /* RW-4R */
1681
#define NV_PGRAPH_CONTROL2                               0x00400820 /* RW-4R */
1682
#define NV_PGRAPH_BLEND                                  0x00400824 /* RW-4R */
1683
#define NV_PGRAPH_DPRAM_INDEX                            0x00400828 /* RW-4R */
1684
#define NV_PGRAPH_DPRAM_INDEX_ADRS                              6:0 /* RWIVF */
1685
#define NV_PGRAPH_DPRAM_INDEX_ADRS_0                     0x00000000 /* RWI-V */
1686
#define NV_PGRAPH_DPRAM_INDEX_SELECT                           10:8 /* RWIVF */
1687
#define NV_PGRAPH_DPRAM_INDEX_SELECT_ADRS_0              0x00000000 /* RWI-V */
1688
#define NV_PGRAPH_DPRAM_INDEX_SELECT_ADRS_1              0x00000001 /* RW--V */
1689
#define NV_PGRAPH_DPRAM_INDEX_SELECT_DATA_0              0x00000002 /* RW--V */
1690
#define NV_PGRAPH_DPRAM_INDEX_SELECT_DATA_1              0x00000003 /* RW--V */
1691
#define NV_PGRAPH_DPRAM_INDEX_SELECT_WE_0                0x00000004 /* RW--V */
1692
#define NV_PGRAPH_DPRAM_INDEX_SELECT_WE_1                0x00000005 /* RW--V */
1693
#define NV_PGRAPH_DPRAM_INDEX_SELECT_ALPHA_0             0x00000006 /* RW--V */
1694
#define NV_PGRAPH_DPRAM_INDEX_SELECT_ALPHA_1             0x00000007 /* RW--V */
1695
#define NV_PGRAPH_DPRAM_DATA                             0x0040082c /* RW-4R */
1696
#define NV_PGRAPH_DPRAM_DATA_VALUE                             31:0 /* RWXVF */
1697
#define NV_PGRAPH_DPRAM_ADRS_0                           0x0040082c /* RW-4R */
1698
#define NV_PGRAPH_DPRAM_ADRS_0__ALIAS_1        NV_PGRAPH_DPRAM_DATA /*       */
1699
#define NV_PGRAPH_DPRAM_ADRS_0_VALUE                           19:0 /* RWXVF */
1700
#define NV_PGRAPH_DPRAM_ADRS_1                           0x0040082c /* RW-4R */
1701
#define NV_PGRAPH_DPRAM_ADRS_1__ALIAS_1        NV_PGRAPH_DPRAM_DATA /*       */
1702
#define NV_PGRAPH_DPRAM_ADRS_1_VALUE                           19:0 /* RWXVF */
1703
#define NV_PGRAPH_DPRAM_DATA_0                           0x0040082c /* RW-4R */
1704
#define NV_PGRAPH_DPRAM_DATA_0__ALIAS_1        NV_PGRAPH_DPRAM_DATA /*       */
1705
#define NV_PGRAPH_DPRAM_DATA_0_VALUE                           31:0 /* RWXVF */
1706
#define NV_PGRAPH_DPRAM_DATA_1                           0x0040082c /* RW-4R */
1707
#define NV_PGRAPH_DPRAM_DATA_1__ALIAS_1        NV_PGRAPH_DPRAM_DATA /*       */
1708
#define NV_PGRAPH_DPRAM_DATA_1_VALUE                           31:0 /* RWXVF */
1709
#define NV_PGRAPH_DPRAM_WE_0                             0x0040082c /* RW-4R */
1710
#define NV_PGRAPH_DPRAM_WE_0__ALIAS_1          NV_PGRAPH_DPRAM_DATA /*       */
1711
#define NV_PGRAPH_DPRAM_WE_0_VALUE                             23:0 /* RWXVF */
1712
#define NV_PGRAPH_DPRAM_WE_1                             0x0040082c /* RW-4R */
1713
#define NV_PGRAPH_DPRAM_WE_1__ALIAS_1          NV_PGRAPH_DPRAM_DATA /*       */
1714
#define NV_PGRAPH_DPRAM_WE_1_VALUE                             23:0 /* RWXVF */
1715
#define NV_PGRAPH_DPRAM_ALPHA_0                          0x0040082c /* RW-4R */
1716
#define NV_PGRAPH_DPRAM_ALPHA_0__ALIAS_1       NV_PGRAPH_DPRAM_DATA /*       */
1717
#define NV_PGRAPH_DPRAM_ALPHA_0_VALUE                          31:0 /* RWXVF */
1718
#define NV_PGRAPH_DPRAM_ALPHA_1                          0x0040082c /* RW-4R */
1719
#define NV_PGRAPH_DPRAM_ALPHA_1__ALIAS_1       NV_PGRAPH_DPRAM_DATA /*       */
1720
#define NV_PGRAPH_DPRAM_ALPHA_1_VALUE                          31:0 /* RWXVF */
1721
#define NV_PGRAPH_STORED_FMT                             0x00400830 /* RW-4R */
1722
#define NV_PGRAPH_STORED_FMT_MONO0                              5:0 /* RWXVF */
1723
#define NV_PGRAPH_STORED_FMT_PATT0                             13:8 /* RWXVF */
1724
#define NV_PGRAPH_STORED_FMT_PATT1                            21:16 /* RWXVF */
1725
#define NV_PGRAPH_STORED_FMT_CHROMA                           29:24 /* RWXVF */
1726
#define NV_PGRAPH_FORMATS                                0x00400618 /* RW-4R */
1727
#define NV_PGRAPH_FORMATS_ROP                                   2:0 /* R-XVF */
1728
#define NV_PGRAPH_FORMATS_ROP_Y8                         0x00000000 /* -W--V */
1729
#define NV_PGRAPH_FORMATS_ROP_RGB15                      0x00000001 /* -W--V */
1730
#define NV_PGRAPH_FORMATS_ROP_RGB16                      0x00000002 /* -W--V */
1731
#define NV_PGRAPH_FORMATS_ROP_Y16                        0x00000003 /* -W--V */
1732
#define NV_PGRAPH_FORMATS_ROP_INVALID                    0x00000004 /* -W--V */
1733
#define NV_PGRAPH_FORMATS_ROP_RGB24                      0x00000005 /* -W--V */
1734
#define NV_PGRAPH_FORMATS_ROP_RGB30                      0x00000006 /* -W--V */
1735
#define NV_PGRAPH_FORMATS_ROP_Y32                        0x00000007 /* -W--V */
1736
#define NV_PGRAPH_FORMATS_SRC                                   9:4 /* R-XVF */
1737
#define NV_PGRAPH_FORMATS_SRC_INVALID                    0x00000000 /* RW--V */
1738
#define NV_PGRAPH_FORMATS_SRC_LE_Y8                      0x00000001 /* RW--V */
1739
#define NV_PGRAPH_FORMATS_SRC_LE_X16A8Y8                 0x00000002 /* RW--V */
1740
#define NV_PGRAPH_FORMATS_SRC_LE_X24Y8                   0x00000003 /* RW--V */
1741
#define NV_PGRAPH_FORMATS_SRC_LE_A1R5G5B5                0x00000006 /* RW--V */
1742
#define NV_PGRAPH_FORMATS_SRC_LE_X1R5G5B5                0x00000007 /* RW--V */
1743
#define NV_PGRAPH_FORMATS_SRC_LE_X16A1R5G5B5             0x00000008 /* RW--V */
1744
#define NV_PGRAPH_FORMATS_SRC_LE_X17R5G5B5               0x00000009 /* RW--V */
1745
#define NV_PGRAPH_FORMATS_SRC_LE_R5G6B5                  0x0000000A /* RW--V */
1746
#define NV_PGRAPH_FORMATS_SRC_LE_A16R5G6B5               0x0000000B /* RW--V */
1747
#define NV_PGRAPH_FORMATS_SRC_LE_X16R5G6B5               0x0000000C /* RW--V */
1748
#define NV_PGRAPH_FORMATS_SRC_LE_A8R8G8B8                0x0000000D /* RW--V */
1749
#define NV_PGRAPH_FORMATS_SRC_LE_X8R8G8B8                0x0000000E /* RW--V */
1750
#define NV_PGRAPH_FORMATS_SRC_LE_Y16                     0x0000000F /* RW--V */
1751
#define NV_PGRAPH_FORMATS_SRC_LE_A16Y16                  0x00000010 /* RW--V */
1752
#define NV_PGRAPH_FORMATS_SRC_LE_X16Y16                  0x00000011 /* RW--V */
1753
#define NV_PGRAPH_FORMATS_SRC_LE_V8YB8U8YA8              0x00000012 /* RW--V */
1754
#define NV_PGRAPH_FORMATS_SRC_LE_YB8V8YA8U8              0x00000013 /* RW--V */
1755
#define NV_PGRAPH_FORMATS_SRC_LE_Y32                     0x00000014 /* RW--V */
1756
#define NV_PGRAPH_FORMATS_FB                                  15:12 /* R-XVF */
1757
#define NV_PGRAPH_FORMATS_FB_INVALID                     0x00000000 /* RWI-V */
1758
#define NV_PGRAPH_FORMATS_FB_Y8                          0x00000001 /* RW--V */
1759
#define NV_PGRAPH_FORMATS_FB_X1R5G5B5_Z1R5G5B5           0x00000002 /* RW--V */
1760
#define NV_PGRAPH_FORMATS_FB_X1R5G5B5_O1R5G5B5           0x00000003 /* RW--V */
1761
#define NV_PGRAPH_FORMATS_FB_A1R5G5B5                    0x00000004 /* RW--V */
1762
#define NV_PGRAPH_FORMATS_FB_R5G6B5                      0x00000005 /* RW--V */
1763
#define NV_PGRAPH_FORMATS_FB_Y16                         0x00000006 /* RW--V */
1764
#define NV_PGRAPH_FORMATS_FB_X8R8G8B8_Z8R8G8B8           0x00000007 /* RW--V */
1765
#define NV_PGRAPH_FORMATS_FB_X8R8G8B8_O1Z7R8G8B8         0x00000008 /* RW--V */
1766
#define NV_PGRAPH_FORMATS_FB_X1A7R8G8B8_Z1A7R8G8B8       0x00000009 /* RW--V */
1767
#define NV_PGRAPH_FORMATS_FB_X1A7R8G8B8_O1A7R8G8B8       0x0000000a /* RW--V */
1768
#define NV_PGRAPH_FORMATS_FB_X8R8G8B8_O8R8G8B8           0x0000000b /* RW--V */
1769
#define NV_PGRAPH_FORMATS_FB_A8R8G8B8                    0x0000000c /* RW--V */
1770
#define NV_PGRAPH_FORMATS_FB_Y32                         0x0000000d /* RW--V */
1771
#define NV_PGRAPH_FORMATS_FB_V8YB8U8YA8                  0x0000000e /* RW--V */
1772
#define NV_PGRAPH_FORMATS_FB_YB8V8YA8U8                  0x0000000f /* RW--V */ 
1773
#define NV_PGRAPH_ABS_X_RAM(i)                   (0x00400400+(i)*4) /* RW-4A */
1774
#define NV_PGRAPH_ABS_X_RAM__SIZE_1                              32 /*       */
1775
#define NV_PGRAPH_ABS_X_RAM_VALUE                              31:0 /* RWXUF */
1776
#define NV_PGRAPH_X_RAM_BPORT(i)                 (0x00400c00+(i)*4) /* R--4A */
1777
#define NV_PGRAPH_X_RAM_BPORT__SIZE_1                            32 /*       */
1778
#define NV_PGRAPH_X_RAM_BPORT_VALUE                            31:0 /* R--UF */
1779
#define NV_PGRAPH_ABS_Y_RAM(i)                   (0x00400480+(i)*4) /* RW-4A */
1780
#define NV_PGRAPH_ABS_Y_RAM__SIZE_1                              32 /*       */
1781
#define NV_PGRAPH_ABS_Y_RAM_VALUE                              31:0 /* RWXUF */
1782
#define NV_PGRAPH_Y_RAM_BPORT(i)                 (0x00400c80+(i)*4) /* R--4A */
1783
#define NV_PGRAPH_Y_RAM_BPORT__SIZE_1                            32 /*       */
1784
#define NV_PGRAPH_Y_RAM_BPORT_VALUE                            31:0 /* R--UF */
1785
#define NV_PGRAPH_XY_LOGIC_MISC0                         0x00400514 /* RW-4R */
1786
#define NV_PGRAPH_XY_LOGIC_MISC0_COUNTER                       17:0 /* RWBUF */
1787
#define NV_PGRAPH_XY_LOGIC_MISC0_COUNTER_0               0x00000000 /* RWB-V */
1788
#define NV_PGRAPH_XY_LOGIC_MISC0_DIMENSION                    20:20 /* RWVVF */
1789
#define NV_PGRAPH_XY_LOGIC_MISC0_DIMENSION_NONZERO       0x00000000 /* RWV-V */
1790
#define NV_PGRAPH_XY_LOGIC_MISC0_DIMENSION_ZERO          0x00000001 /* RW--V */
1791
#define NV_PGRAPH_XY_LOGIC_MISC0_INDEX                        31:28 /* RWBUF */
1792
#define NV_PGRAPH_XY_LOGIC_MISC0_INDEX_0                 0x00000000 /* RWB-V */
1793
#define NV_PGRAPH_XY_LOGIC_MISC1                         0x00400518 /* RW-4R */
1794
#define NV_PGRAPH_XY_LOGIC_MISC1_INITIAL                        0:0 /* RWNVF */
1795
#define NV_PGRAPH_XY_LOGIC_MISC1_INITIAL_NEEDED          0x00000000 /* RWN-V */
1796
#define NV_PGRAPH_XY_LOGIC_MISC1_INITIAL_DONE            0x00000001 /* RW--V */
1797
#define NV_PGRAPH_XY_LOGIC_MISC1_XTRACLIPX                      4:4 /* RWIVF */
1798
#define NV_PGRAPH_XY_LOGIC_MISC1_XTRACLIPX_NOTNULL       0x00000000 /* RWI-V */
1799
#define NV_PGRAPH_XY_LOGIC_MISC1_XTRACLIPX_NULL          0x00000001 /* RW--V */
1800
#define NV_PGRAPH_XY_LOGIC_MISC1_XTRACLIPY                      5:5 /* RWIVF */
1801
#define NV_PGRAPH_XY_LOGIC_MISC1_XTRACLIPY_NOTNULL       0x00000000 /* RWI-V */
1802
#define NV_PGRAPH_XY_LOGIC_MISC1_XTRACLIPY_NULL          0x00000001 /* RW--V */
1803
#define NV_PGRAPH_XY_LOGIC_MISC1_SEL_XIMAX                    12:12 /* RWIVF */
1804
#define NV_PGRAPH_XY_LOGIC_MISC1_SEL_XIMAX_UUMAX         0x00000000 /* RWI-V */
1805
#define NV_PGRAPH_XY_LOGIC_MISC1_SEL_XIMAX_IMAGEMAX      0x00000001 /* RW--V */
1806
#define NV_PGRAPH_XY_LOGIC_MISC1_SEL_YIMAX                    16:16 /* RWIVF */
1807
#define NV_PGRAPH_XY_LOGIC_MISC1_SEL_YIMAX_UUMAX         0x00000000 /* RWI-V */
1808
#define NV_PGRAPH_XY_LOGIC_MISC1_SEL_YIMAX_IMAGEMAX      0x00000001 /* RW--V */
1809
#define NV_PGRAPH_XY_LOGIC_MISC1_SEL_XXTRA                    20:20 /* RWIVF */
1810
#define NV_PGRAPH_XY_LOGIC_MISC1_SEL_XXTRA_CLIPMAX       0x00000000 /* RWI-V */
1811
#define NV_PGRAPH_XY_LOGIC_MISC1_SEL_XXTRA_IMAGEMAX      0x00000001 /* RW--V */
1812
#define NV_PGRAPH_XY_LOGIC_MISC2                         0x0040051C /* RW-4R */
1813
#define NV_PGRAPH_XY_LOGIC_MISC2_HANDOFF                        0:0 /* RWIVF */
1814
#define NV_PGRAPH_XY_LOGIC_MISC2_HANDOFF_DISABLE         0x00000000 /* RWI-V */
1815
#define NV_PGRAPH_XY_LOGIC_MISC2_HANDOFF_ENABLE          0x00000001 /* RW--V */
1816
#define NV_PGRAPH_XY_LOGIC_MISC2_XTRACLIPX                      4:4 /* RWIVF */
1817
#define NV_PGRAPH_XY_LOGIC_MISC2_XTRACLIPX_NOTNULL       0x00000000 /* RWI-V */
1818
#define NV_PGRAPH_XY_LOGIC_MISC2_XTRACLIPX_NULL          0x00000001 /* RW--V */
1819
#define NV_PGRAPH_XY_LOGIC_MISC2_XTRACLIPY                      5:5 /* RWIVF */
1820
#define NV_PGRAPH_XY_LOGIC_MISC2_XTRACLIPY_NOTNULL       0x00000000 /* RWI-V */
1821
#define NV_PGRAPH_XY_LOGIC_MISC2_XTRACLIPY_NULL          0x00000001 /* RW--V */
1822
#define NV_PGRAPH_XY_LOGIC_MISC2_SEL_XIMAX                    12:12 /* RWIVF */
1823
#define NV_PGRAPH_XY_LOGIC_MISC2_SEL_XIMAX_UCMAX         0x00000000 /* RWI-V */
1824
#define NV_PGRAPH_XY_LOGIC_MISC2_SEL_XIMAX_IMAGEMAX      0x00000001 /* RW--V */
1825
#define NV_PGRAPH_XY_LOGIC_MISC2_SEL_YIMAX                    16:16 /* RWIVF */
1826
#define NV_PGRAPH_XY_LOGIC_MISC2_SEL_YIMAX_UCMAX         0x00000000 /* RWI-V */
1827
#define NV_PGRAPH_XY_LOGIC_MISC2_SEL_YIMAX_IMAGEMAX      0x00000001 /* RW--V */
1828
#define NV_PGRAPH_XY_LOGIC_MISC2_SEL_XXTRA                    20:20 /* RWIVF */
1829
#define NV_PGRAPH_XY_LOGIC_MISC2_SEL_XXTRA_CLIPMAX       0x00000000 /* RWI-V */
1830
#define NV_PGRAPH_XY_LOGIC_MISC2_SEL_XXTRA_IMAGEMAX      0x00000001 /* RW--V */
1831
#define NV_PGRAPH_XY_LOGIC_MISC3                         0x00400520 /* RW-4R */
1832
#define NV_PGRAPH_XY_LOGIC_MISC3_WDIMY_EQ_0                     0:0 /* RWXVF */
1833
#define NV_PGRAPH_XY_LOGIC_MISC3_WDIMY_EQ_0_NULL         0x00000000 /* RW--V */
1834
#define NV_PGRAPH_XY_LOGIC_MISC3_WDIMY_EQ_0_TRUE         0x00000001 /* RW--V */
1835
#define NV_PGRAPH_XY_LOGIC_MISC3_RELOAD_WDIMY                   4:4 /* RWXVF */
1836
#define NV_PGRAPH_XY_LOGIC_MISC3_RELOAD_WDIMY_NULL       0x00000000 /* RW--V */
1837
#define NV_PGRAPH_XY_LOGIC_MISC3_RELOAD_WDIMY_TRUE       0x00000001 /* RW--V */
1838
#define NV_PGRAPH_XY_LOGIC_MISC3_RELOAD_WX                      8:8 /* RWIVF */
1839
#define NV_PGRAPH_XY_LOGIC_MISC3_RELOAD_WX_NULL          0x00000000 /* RWI-V */
1840
#define NV_PGRAPH_XY_LOGIC_MISC3_RELOAD_WX_TRUE          0x00000001 /* RW--V */
1841
#define NV_PGRAPH_XY_LOGIC_MISC3_TEXT_ALG                     12:12 /* RWIVF */
1842
#define NV_PGRAPH_XY_LOGIC_MISC3_TEXT_ALG_NULL           0x00000000 /* RWI-V */
1843
#define NV_PGRAPH_XY_LOGIC_MISC3_TEXT_ALG_TRUE           0x00000001 /* RW--V */
1844
#define NV_PGRAPH_XY_LOGIC_MISC3_TEXT_DIMX                    22:16 /* RWXUF */
1845
#define NV_PGRAPH_XY_LOGIC_MISC3_TEXT_DIMX_0             0x00000000 /* RW--V */
1846
#define NV_PGRAPH_XY_LOGIC_MISC3_TEXT_WDIMX                   30:24 /* RWXUF */
1847
#define NV_PGRAPH_XY_LOGIC_MISC3_TEXT_WDIMX_0            0x00000000 /* RW--V */
1848
#define NV_PGRAPH_X_MISC                                 0x00400500 /* RW-4R */
1849
#define NV_PGRAPH_X_MISC_BIT33_0                                0:0 /* RWNVF */
1850
#define NV_PGRAPH_X_MISC_BIT33_0_0                       0x00000000 /* RWN-V */
1851
#define NV_PGRAPH_X_MISC_BIT33_1                                1:1 /* RWNVF */
1852
#define NV_PGRAPH_X_MISC_BIT33_1_0                       0x00000000 /* RWN-V */
1853
#define NV_PGRAPH_X_MISC_BIT33_2                                2:2 /* RWNVF */
1854
#define NV_PGRAPH_X_MISC_BIT33_2_0                       0x00000000 /* RWN-V */
1855
#define NV_PGRAPH_X_MISC_BIT33_3                                3:3 /* RWNVF */
1856
#define NV_PGRAPH_X_MISC_BIT33_3_0                       0x00000000 /* RWN-V */
1857
#define NV_PGRAPH_X_MISC_RANGE_0                                4:4 /* RWNVF */
1858
#define NV_PGRAPH_X_MISC_RANGE_0_0                       0x00000000 /* RWN-V */
1859
#define NV_PGRAPH_X_MISC_RANGE_1                                5:5 /* RWNVF */
1860
#define NV_PGRAPH_X_MISC_RANGE_1_0                       0x00000000 /* RWN-V */
1861
#define NV_PGRAPH_X_MISC_RANGE_2                                6:6 /* RWNVF */
1862
#define NV_PGRAPH_X_MISC_RANGE_2_0                       0x00000000 /* RWN-V */
1863
#define NV_PGRAPH_X_MISC_RANGE_3                                7:7 /* RWNVF */
1864
#define NV_PGRAPH_X_MISC_RANGE_3_0                       0x00000000 /* RWN-V */
1865
#define NV_PGRAPH_X_MISC_ADDER_OUTPUT                         29:28 /* RWXVF */
1866
#define NV_PGRAPH_X_MISC_ADDER_OUTPUT_EQ_0               0x00000000 /* RW--V */
1867
#define NV_PGRAPH_X_MISC_ADDER_OUTPUT_LT_0               0x00000001 /* RW--V */
1868
#define NV_PGRAPH_X_MISC_ADDER_OUTPUT_GT_0               0x00000002 /* RW--V */
1869
#define NV_PGRAPH_Y_MISC                                 0x00400504 /* RW-4R */
1870
#define NV_PGRAPH_Y_MISC_BIT33_0                                0:0 /* RWNVF */
1871
#define NV_PGRAPH_Y_MISC_BIT33_0_0                       0x00000000 /* RWN-V */
1872
#define NV_PGRAPH_Y_MISC_BIT33_1                                1:1 /* RWNVF */
1873
#define NV_PGRAPH_Y_MISC_BIT33_1_0                       0x00000000 /* RWN-V */
1874
#define NV_PGRAPH_Y_MISC_BIT33_2                                2:2 /* RWNVF */
1875
#define NV_PGRAPH_Y_MISC_BIT33_2_0                       0x00000000 /* RWN-V */
1876
#define NV_PGRAPH_Y_MISC_BIT33_3                                3:3 /* RWNVF */
1877
#define NV_PGRAPH_Y_MISC_BIT33_3_0                       0x00000000 /* RWN-V */
1878
#define NV_PGRAPH_Y_MISC_RANGE_0                                4:4 /* RWNVF */
1879
#define NV_PGRAPH_Y_MISC_RANGE_0_0                       0x00000000 /* RWN-V */
1880
#define NV_PGRAPH_Y_MISC_RANGE_1                                5:5 /* RWNVF */
1881
#define NV_PGRAPH_Y_MISC_RANGE_1_0                       0x00000000 /* RWN-V */
1882
#define NV_PGRAPH_Y_MISC_RANGE_2                                6:6 /* RWNVF */
1883
#define NV_PGRAPH_Y_MISC_RANGE_2_0                       0x00000000 /* RWN-V */
1884
#define NV_PGRAPH_Y_MISC_RANGE_3                                7:7 /* RWNVF */
1885
#define NV_PGRAPH_Y_MISC_RANGE_3_0                       0x00000000 /* RWN-V */
1886
#define NV_PGRAPH_Y_MISC_ADDER_OUTPUT                         29:28 /* RWXVF */
1887
#define NV_PGRAPH_Y_MISC_ADDER_OUTPUT_EQ_0               0x00000000 /* RW--V */
1888
#define NV_PGRAPH_Y_MISC_ADDER_OUTPUT_LT_0               0x00000001 /* RW--V */
1889
#define NV_PGRAPH_Y_MISC_ADDER_OUTPUT_GT_0               0x00000002 /* RW--V */
1890
#define NV_PGRAPH_ABS_UCLIP_XMIN                         0x0040053C /* RW-4R */
1891
#define NV_PGRAPH_ABS_UCLIP_XMIN_VALUE                         15:0 /* RWXSF */
1892
#define NV_PGRAPH_ABS_UCLIP_XMAX                         0x00400544 /* RW-4R */
1893
#define NV_PGRAPH_ABS_UCLIP_XMAX_VALUE                         17:0 /* RWXSF */
1894
#define NV_PGRAPH_ABS_UCLIP_YMIN                         0x00400540 /* RW-4R */
1895
#define NV_PGRAPH_ABS_UCLIP_YMIN_VALUE                         15:0 /* RWXSF */
1896
#define NV_PGRAPH_ABS_UCLIP_YMAX                         0x00400548 /* RW-4R */
1897
#define NV_PGRAPH_ABS_UCLIP_YMAX_VALUE                         17:0 /* RWXSF */
1898
#define NV_PGRAPH_ABS_UCLIPA_XMIN                        0x00400560 /* RW-4R */
1899
#define NV_PGRAPH_ABS_UCLIPA_XMIN_VALUE                        15:0 /* RWXSF */
1900
#define NV_PGRAPH_ABS_UCLIPA_XMAX                        0x00400568 /* RW-4R */
1901
#define NV_PGRAPH_ABS_UCLIPA_XMAX_VALUE                        17:0 /* RWXSF */
1902
#define NV_PGRAPH_ABS_UCLIPA_YMIN                        0x00400564 /* RW-4R */
1903
#define NV_PGRAPH_ABS_UCLIPA_YMIN_VALUE                        15:0 /* RWXSF */
1904
#define NV_PGRAPH_ABS_UCLIPA_YMAX                        0x0040056C /* RW-4R */
1905
#define NV_PGRAPH_ABS_UCLIPA_YMAX_VALUE                        17:0 /* RWXSF */
1906
#define NV_PGRAPH_SOURCE_COLOR                           0x0040050C /* RW-4R */
1907
#define NV_PGRAPH_SOURCE_COLOR_VALUE                           31:0 /* RWNVF */
1908
#define NV_PGRAPH_SOURCE_COLOR_VALUE_0                   0x00000000 /* RWN-V */
1909
#define NV_PGRAPH_VALID1                                 0x00400508 /* RW-4R */
1910
#define NV_PGRAPH_VALID1_VLD                                   22:0 /* RWNVF */
1911
#define NV_PGRAPH_VALID1_VLD_0                           0x00000000 /* RWN-V */
1912
#define NV_PGRAPH_VALID1_CLIP_MIN                             28:28 /* RWIVF */
1913
#define NV_PGRAPH_VALID1_CLIP_MIN_NO_ERROR               0x00000000 /* RWI-V */
1914
#define NV_PGRAPH_VALID1_CLIP_MIN_ONLY                   0x00000001 /* RW--V */
1915
#define NV_PGRAPH_VALID1_CLIPA_MIN                            29:29 /* RWIVF */
1916
#define NV_PGRAPH_VALID1_CLIPA_MIN_NO_ERROR              0x00000000 /* RWI-V */
1917
#define NV_PGRAPH_VALID1_CLIPA_MIN_ONLY                  0x00000001 /* RW--V */
1918
#define NV_PGRAPH_VALID1_CLIP_MAX                             30:30 /* RWIVF */
1919
#define NV_PGRAPH_VALID1_CLIP_MAX_NO_ERROR               0x00000000 /* RWI-V */
1920
#define NV_PGRAPH_VALID1_CLIP_MAX_ONLY                   0x00000001 /* RW--V */
1921
#define NV_PGRAPH_VALID1_CLIPA_MAX                            31:31 /* RWIVF */
1922
#define NV_PGRAPH_VALID1_CLIPA_MAX_NO_ERROR              0x00000000 /* RWI-V */
1923
#define NV_PGRAPH_VALID1_CLIPA_MAX_ONLY                  0x00000001 /* RW--V */
1924
#define NV_PGRAPH_VALID2                                 0x00400578 /* RW-4R */
1925
#define NV_PGRAPH_VALID2_VLD2                                  28:0 /* RWNVF */
1926
#define NV_PGRAPH_VALID2_VLD2_0                          0x00000000 /* RWN-V */
1927
#define NV_PGRAPH_ABS_ICLIP_XMAX                         0x00400534 /* RW-4R */
1928
#define NV_PGRAPH_ABS_ICLIP_XMAX_VALUE                         17:0 /* RWXSF */
1929
#define NV_PGRAPH_ABS_ICLIP_YMAX                         0x00400538 /* RW-4R */
1930
#define NV_PGRAPH_ABS_ICLIP_YMAX_VALUE                         17:0 /* RWXSF */
1931
#define NV_PGRAPH_CLIPX_0                                0x00400524 /* RW-4R */
1932
#define NV_PGRAPH_CLIPX_0_CLIP0_MIN                             1:0 /* RWNVF */
1933
#define NV_PGRAPH_CLIPX_0_CLIP0_MIN_GT                   0x00000000 /* RW--V */
1934
#define NV_PGRAPH_CLIPX_0_CLIP0_MIN_LT                   0x00000001 /* RWN-V */
1935
#define NV_PGRAPH_CLIPX_0_CLIP0_MIN_EQ                   0x00000002 /* RW--V */
1936
#define NV_PGRAPH_CLIPX_0_CLIP0_MAX                             3:2 /* RWNVF */
1937
#define NV_PGRAPH_CLIPX_0_CLIP0_MAX_LT                   0x00000000 /* RW--V */
1938
#define NV_PGRAPH_CLIPX_0_CLIP0_MAX_GT                   0x00000001 /* RWN-V */
1939
#define NV_PGRAPH_CLIPX_0_CLIP0_MAX_EQ                   0x00000002 /* RW--V */
1940
#define NV_PGRAPH_CLIPX_0_CLIP1_MIN                             5:4 /* RWNVF */
1941
#define NV_PGRAPH_CLIPX_0_CLIP1_MIN_GT                   0x00000000 /* RW--V */
1942
#define NV_PGRAPH_CLIPX_0_CLIP1_MIN_LT                   0x00000001 /* RWN-V */
1943
#define NV_PGRAPH_CLIPX_0_CLIP1_MIN_EQ                   0x00000002 /* RW--V */
1944
#define NV_PGRAPH_CLIPX_0_CLIP1_MAX                             7:6 /* RWNVF */
1945
#define NV_PGRAPH_CLIPX_0_CLIP1_MAX_LT                   0x00000000 /* RW--V */
1946
#define NV_PGRAPH_CLIPX_0_CLIP1_MAX_GT                   0x00000001 /* RWN-V */
1947
#define NV_PGRAPH_CLIPX_0_CLIP1_MAX_EQ                   0x00000002 /* RW--V */
1948
#define NV_PGRAPH_CLIPX_0_CLIP2_MIN                             9:8 /* RWNVF */
1949
#define NV_PGRAPH_CLIPX_0_CLIP2_MIN_GT                   0x00000000 /* RW--V */
1950
#define NV_PGRAPH_CLIPX_0_CLIP2_MIN_LT                   0x00000001 /* RWN-V */
1951
#define NV_PGRAPH_CLIPX_0_CLIP2_MIN_EQ                   0x00000002 /* RW--V */
1952
#define NV_PGRAPH_CLIPX_0_CLIP2_MAX                           11:10 /* RWNVF */
1953
#define NV_PGRAPH_CLIPX_0_CLIP2_MAX_LT                   0x00000000 /* RW--V */
1954
#define NV_PGRAPH_CLIPX_0_CLIP2_MAX_GT                   0x00000001 /* RWN-V */
1955
#define NV_PGRAPH_CLIPX_0_CLIP2_MAX_EQ                   0x00000002 /* RW--V */
1956
#define NV_PGRAPH_CLIPX_0_CLIP3_MIN                           13:12 /* RWNVF */
1957
#define NV_PGRAPH_CLIPX_0_CLIP3_MIN_GT                   0x00000000 /* RW--V */
1958
#define NV_PGRAPH_CLIPX_0_CLIP3_MIN_LT                   0x00000001 /* RWN-V */
1959
#define NV_PGRAPH_CLIPX_0_CLIP3_MIN_EQ                   0x00000002 /* RW--V */
1960
#define NV_PGRAPH_CLIPX_0_CLIP3_MAX                           15:14 /* RWNVF */
1961
#define NV_PGRAPH_CLIPX_0_CLIP3_MAX_LT                   0x00000000 /* RW--V */
1962
#define NV_PGRAPH_CLIPX_0_CLIP3_MAX_GT                   0x00000001 /* RWN-V */
1963
#define NV_PGRAPH_CLIPX_0_CLIP3_MAX_EQ                   0x00000002 /* RW--V */
1964
#define NV_PGRAPH_CLIPX_0_CLIP4_MIN                           17:16 /* RWNVF */
1965
#define NV_PGRAPH_CLIPX_0_CLIP4_MIN_GT                   0x00000000 /* RW--V */
1966
#define NV_PGRAPH_CLIPX_0_CLIP4_MIN_LT                   0x00000001 /* RWN-V */
1967
#define NV_PGRAPH_CLIPX_0_CLIP4_MIN_EQ                   0x00000002 /* RW--V */
1968
#define NV_PGRAPH_CLIPX_0_CLIP4_MAX                           19:18 /* RWNVF */
1969
#define NV_PGRAPH_CLIPX_0_CLIP4_MAX_LT                   0x00000000 /* RW--V */
1970
#define NV_PGRAPH_CLIPX_0_CLIP4_MAX_GT                   0x00000001 /* RWN-V */
1971
#define NV_PGRAPH_CLIPX_0_CLIP4_MAX_EQ                   0x00000002 /* RW--V */
1972
#define NV_PGRAPH_CLIPX_0_CLIP5_MIN                           21:20 /* RWNVF */
1973
#define NV_PGRAPH_CLIPX_0_CLIP5_MIN_GT                   0x00000000 /* RW--V */
1974
#define NV_PGRAPH_CLIPX_0_CLIP5_MIN_LT                   0x00000001 /* RWN-V */
1975
#define NV_PGRAPH_CLIPX_0_CLIP5_MIN_EQ                   0x00000002 /* RW--V */
1976
#define NV_PGRAPH_CLIPX_0_CLIP5_MAX                           23:22 /* RWNVF */
1977
#define NV_PGRAPH_CLIPX_0_CLIP5_MAX_LT                   0x00000000 /* RW--V */
1978
#define NV_PGRAPH_CLIPX_0_CLIP5_MAX_GT                   0x00000001 /* RWN-V */
1979
#define NV_PGRAPH_CLIPX_0_CLIP5_MAX_EQ                   0x00000002 /* RW--V */
1980
#define NV_PGRAPH_CLIPX_0_CLIP6_MIN                           25:24 /* RWNVF */
1981
#define NV_PGRAPH_CLIPX_0_CLIP6_MIN_GT                   0x00000000 /* RW--V */
1982
#define NV_PGRAPH_CLIPX_0_CLIP6_MIN_LT                   0x00000001 /* RWN-V */
1983
#define NV_PGRAPH_CLIPX_0_CLIP6_MIN_EQ                   0x00000002 /* RW--V */
1984
#define NV_PGRAPH_CLIPX_0_CLIP6_MAX                           27:26 /* RWNVF */
1985
#define NV_PGRAPH_CLIPX_0_CLIP6_MAX_LT                   0x00000000 /* RW--V */
1986
#define NV_PGRAPH_CLIPX_0_CLIP6_MAX_GT                   0x00000001 /* RWN-V */
1987
#define NV_PGRAPH_CLIPX_0_CLIP6_MAX_EQ                   0x00000002 /* RW--V */
1988
#define NV_PGRAPH_CLIPX_0_CLIP7_MIN                           29:28 /* RWNVF */
1989
#define NV_PGRAPH_CLIPX_0_CLIP7_MIN_GT                   0x00000000 /* RW--V */
1990
#define NV_PGRAPH_CLIPX_0_CLIP7_MIN_LT                   0x00000001 /* RWN-V */
1991
#define NV_PGRAPH_CLIPX_0_CLIP7_MIN_EQ                   0x00000002 /* RW--V */
1992
#define NV_PGRAPH_CLIPX_0_CLIP7_MAX                           31:30 /* RWNVF */
1993
#define NV_PGRAPH_CLIPX_0_CLIP7_MAX_LT                   0x00000000 /* RW--V */
1994
#define NV_PGRAPH_CLIPX_0_CLIP7_MAX_GT                   0x00000001 /* RWN-V */
1995
#define NV_PGRAPH_CLIPX_0_CLIP7_MAX_EQ                   0x00000002 /* RW--V */
1996
#define NV_PGRAPH_CLIPX_1                                0x00400528 /* RW-4R */
1997
#define NV_PGRAPH_CLIPX_1_CLIP8_MIN                             1:0 /* RWNVF */
1998
#define NV_PGRAPH_CLIPX_1_CLIP8_MIN_GT                   0x00000000 /* RW--V */
1999
#define NV_PGRAPH_CLIPX_1_CLIP8_MIN_LT                   0x00000001 /* RWN-V */
2000
#define NV_PGRAPH_CLIPX_1_CLIP8_MIN_EQ                   0x00000002 /* RW--V */
2001
#define NV_PGRAPH_CLIPX_1_CLIP8_MAX                             3:2 /* RWNVF */
2002
#define NV_PGRAPH_CLIPX_1_CLIP8_MAX_LT                   0x00000000 /* RW--V */
2003
#define NV_PGRAPH_CLIPX_1_CLIP8_MAX_GT                   0x00000001 /* RWN-V */
2004
#define NV_PGRAPH_CLIPX_1_CLIP8_MAX_EQ                   0x00000002 /* RW--V */
2005
#define NV_PGRAPH_CLIPX_1_CLIP9_MIN                             5:4 /* RWNVF */
2006
#define NV_PGRAPH_CLIPX_1_CLIP9_MIN_GT                   0x00000000 /* RW--V */
2007
#define NV_PGRAPH_CLIPX_1_CLIP9_MIN_LT                   0x00000001 /* RWN-V */
2008
#define NV_PGRAPH_CLIPX_1_CLIP9_MIN_EQ                   0x00000002 /* RW--V */
2009
#define NV_PGRAPH_CLIPX_1_CLIP9_MAX                             7:6 /* RWNVF */
2010
#define NV_PGRAPH_CLIPX_1_CLIP9_MAX_LT                   0x00000000 /* RW--V */
2011
#define NV_PGRAPH_CLIPX_1_CLIP9_MAX_GT                   0x00000001 /* RWN-V */
2012
#define NV_PGRAPH_CLIPX_1_CLIP9_MAX_EQ                   0x00000002 /* RW--V */
2013
#define NV_PGRAPH_CLIPX_1_CLIP10_MIN                            9:8 /* RWNVF */
2014
#define NV_PGRAPH_CLIPX_1_CLIP10_MIN_GT                  0x00000000 /* RW--V */
2015
#define NV_PGRAPH_CLIPX_1_CLIP10_MIN_LT                  0x00000001 /* RWN-V */
2016
#define NV_PGRAPH_CLIPX_1_CLIP10_MIN_EQ                  0x00000002 /* RW--V */
2017
#define NV_PGRAPH_CLIPX_1_CLIP10_MAX                          11:10 /* RWNVF */
2018
#define NV_PGRAPH_CLIPX_1_CLIP10_MAX_LT                  0x00000000 /* RW--V */
2019
#define NV_PGRAPH_CLIPX_1_CLIP10_MAX_GT                  0x00000001 /* RWN-V */
2020
#define NV_PGRAPH_CLIPX_1_CLIP10_MAX_EQ                  0x00000002 /* RW--V */
2021
#define NV_PGRAPH_CLIPX_1_CLIP11_MIN                          13:12 /* RWNVF */
2022
#define NV_PGRAPH_CLIPX_1_CLIP11_MIN_GT                  0x00000000 /* RW--V */
2023
#define NV_PGRAPH_CLIPX_1_CLIP11_MIN_LT                  0x00000001 /* RWN-V */
2024
#define NV_PGRAPH_CLIPX_1_CLIP11MIN_EQ                   0x00000002 /* RW--V */
2025
#define NV_PGRAPH_CLIPX_1_CLIP11_MAX                          15:14 /* RWNVF */
2026
#define NV_PGRAPH_CLIPX_1_CLIP11_MAX_LT                  0x00000000 /* RW--V */
2027
#define NV_PGRAPH_CLIPX_1_CLIP11_MAX_GT                  0x00000001 /* RWN-V */
2028
#define NV_PGRAPH_CLIPX_1_CLIP11_MAX_EQ                  0x00000002 /* RW--V */
2029
#define NV_PGRAPH_CLIPX_1_CLIP12_MIN                          17:16 /* RWNVF */
2030
#define NV_PGRAPH_CLIPX_1_CLIP12_MIN_GT                  0x00000000 /* RW--V */
2031
#define NV_PGRAPH_CLIPX_1_CLIP12_MIN_LT                  0x00000001 /* RWN-V */
2032
#define NV_PGRAPH_CLIPX_1_CLIP12_MIN_EQ                  0x00000002 /* RW--V */
2033
#define NV_PGRAPH_CLIPX_1_CLIP12_MAX                          19:18 /* RWNVF */
2034
#define NV_PGRAPH_CLIPX_1_CLIP12_MAX_LT                  0x00000000 /* RW--V */
2035
#define NV_PGRAPH_CLIPX_1_CLIP12_MAX_GT                  0x00000001 /* RWN-V */
2036
#define NV_PGRAPH_CLIPX_1_CLIP12_MAX_EQ                  0x00000002 /* RW--V */
2037
#define NV_PGRAPH_CLIPX_1_CLIP13_MIN                          21:20 /* RWNVF */
2038
#define NV_PGRAPH_CLIPX_1_CLIP13_MIN_GT                  0x00000000 /* RW--V */
2039
#define NV_PGRAPH_CLIPX_1_CLIP13_MIN_LT                  0x00000001 /* RWN-V */
2040
#define NV_PGRAPH_CLIPX_1_CLIP13_MIN_EQ                  0x00000002 /* RW--V */
2041
#define NV_PGRAPH_CLIPX_1_CLIP13_MAX                          23:22 /* RWNVF */
2042
#define NV_PGRAPH_CLIPX_1_CLIP13_MAX_LT                  0x00000000 /* RW--V */
2043
#define NV_PGRAPH_CLIPX_1_CLIP13_MAX_GT                  0x00000001 /* RWN-V */
2044
#define NV_PGRAPH_CLIPX_1_CLIP13_MAX_EQ                  0x00000002 /* RW--V */
2045
#define NV_PGRAPH_CLIPX_1_CLIP14_MIN                          25:24 /* RWNVF */
2046
#define NV_PGRAPH_CLIPX_1_CLIP14_MIN_GT                  0x00000000 /* RW--V */
2047
#define NV_PGRAPH_CLIPX_1_CLIP14_MIN_LT                  0x00000001 /* RWN-V */
2048
#define NV_PGRAPH_CLIPX_1_CLIP14_MIN_EQ                  0x00000002 /* RW--V */
2049
#define NV_PGRAPH_CLIPX_1_CLIP14_MAX                          27:26 /* RWNVF */
2050
#define NV_PGRAPH_CLIPX_1_CLIP14_MAX_LT                  0x00000000 /* RW--V */
2051
#define NV_PGRAPH_CLIPX_1_CLIP14_MAX_GT                  0x00000001 /* RWN-V */
2052
#define NV_PGRAPH_CLIPX_1_CLIP14_MAX_EQ                  0x00000002 /* RW--V */
2053
#define NV_PGRAPH_CLIPX_1_CLIP15_MIN                          29:28 /* RWNVF */
2054
#define NV_PGRAPH_CLIPX_1_CLIP15_MIN_GT                  0x00000000 /* RW--V */
2055
#define NV_PGRAPH_CLIPX_1_CLIP15_MIN_LT                  0x00000001 /* RWN-V */
2056
#define NV_PGRAPH_CLIPX_1_CLIP15_MIN_EQ                  0x00000002 /* RW--V */
2057
#define NV_PGRAPH_CLIPX_1_CLIP15_MAX                          31:30 /* RWNVF */
2058
#define NV_PGRAPH_CLIPX_1_CLIP15_MAX_LT                  0x00000000 /* RW--V */
2059
#define NV_PGRAPH_CLIPX_1_CLIP15_MAX_GT                  0x00000001 /* RWN-V */
2060
#define NV_PGRAPH_CLIPX_1_CLIP15_MAX_EQ                  0x00000002 /* RW--V */
2061
#define NV_PGRAPH_CLIPY_0                                0x0040052c /* RW-4R */
2062
#define NV_PGRAPH_CLIPY_0_CLIP0_MIN                             1:0 /* RWNVF */
2063
#define NV_PGRAPH_CLIPY_0_CLIP0_MIN_GT                   0x00000000 /* RW--V */
2064
#define NV_PGRAPH_CLIPY_0_CLIP0_MIN_LT                   0x00000001 /* RWN-V */
2065
#define NV_PGRAPH_CLIPY_0_CLIP0_MIN_EQ                   0x00000002 /* RW--V */
2066
#define NV_PGRAPH_CLIPY_0_CLIP0_MAX                             3:2 /* RWNVF */
2067
#define NV_PGRAPH_CLIPY_0_CLIP0_MAX_LT                   0x00000000 /* RW--V */
2068
#define NV_PGRAPH_CLIPY_0_CLIP0_MAX_GT                   0x00000001 /* RWN-V */
2069
#define NV_PGRAPH_CLIPY_0_CLIP0_MAX_EQ                   0x00000002 /* RW--V */
2070
#define NV_PGRAPH_CLIPY_0_CLIP1_MIN                             5:4 /* RWNVF */
2071
#define NV_PGRAPH_CLIPY_0_CLIP1_MIN_GT                   0x00000000 /* RW--V */
2072
#define NV_PGRAPH_CLIPY_0_CLIP1_MIN_LT                   0x00000001 /* RWN-V */
2073
#define NV_PGRAPH_CLIPY_0_CLIP1_MIN_EQ                   0x00000002 /* RW--V */
2074
#define NV_PGRAPH_CLIPY_0_CLIP1_MAX                             7:6 /* RWNVF */
2075
#define NV_PGRAPH_CLIPY_0_CLIP1_MAX_LT                   0x00000000 /* RW--V */
2076
#define NV_PGRAPH_CLIPY_0_CLIP1_MAX_GT                   0x00000001 /* RWN-V */
2077
#define NV_PGRAPH_CLIPY_0_CLIP1_MAX_EQ                   0x00000002 /* RW--V */
2078
#define NV_PGRAPH_CLIPY_0_CLIP2_MIN                             9:8 /* RWNVF */
2079
#define NV_PGRAPH_CLIPY_0_CLIP2_MIN_GT                   0x00000000 /* RW--V */
2080
#define NV_PGRAPH_CLIPY_0_CLIP2_MIN_LT                   0x00000001 /* RWN-V */
2081
#define NV_PGRAPH_CLIPY_0_CLIP2_MIN_EQ                   0x00000002 /* RW--V */
2082
#define NV_PGRAPH_CLIPY_0_CLIP2_MAX                           11:10 /* RWNVF */
2083
#define NV_PGRAPH_CLIPY_0_CLIP2_MAX_LT                   0x00000000 /* RW--V */
2084
#define NV_PGRAPH_CLIPY_0_CLIP2_MAX_GT                   0x00000001 /* RWN-V */
2085
#define NV_PGRAPH_CLIPY_0_CLIP2_MAX_EQ                   0x00000002 /* RW--V */
2086
#define NV_PGRAPH_CLIPY_0_CLIP3_MIN                           13:12 /* RWNVF */
2087
#define NV_PGRAPH_CLIPY_0_CLIP3_MIN_GT                   0x00000000 /* RW--V */
2088
#define NV_PGRAPH_CLIPY_0_CLIP3_MIN_LT                   0x00000001 /* RWN-V */
2089
#define NV_PGRAPH_CLIPY_0_CLIP3_MIN_EQ                   0x00000002 /* RW--V */
2090
#define NV_PGRAPH_CLIPY_0_CLIP3_MAX                           15:14 /* RWNVF */
2091
#define NV_PGRAPH_CLIPY_0_CLIP3_MAX_LT                   0x00000000 /* RW--V */
2092
#define NV_PGRAPH_CLIPY_0_CLIP3_MAX_GT                   0x00000001 /* RWN-V */
2093
#define NV_PGRAPH_CLIPY_0_CLIP3_MAX_EQ                   0x00000002 /* RW--V */
2094
#define NV_PGRAPH_CLIPY_0_CLIP4_MIN                           17:16 /* RWNVF */
2095
#define NV_PGRAPH_CLIPY_0_CLIP4_MIN_GT                   0x00000000 /* RW--V */
2096
#define NV_PGRAPH_CLIPY_0_CLIP4_MIN_LT                   0x00000001 /* RWN-V */
2097
#define NV_PGRAPH_CLIPY_0_CLIP4_MIN_EQ                   0x00000002 /* RW--V */
2098
#define NV_PGRAPH_CLIPY_0_CLIP4_MAX                           19:18 /* RWNVF */
2099
#define NV_PGRAPH_CLIPY_0_CLIP4_MAX_LT                   0x00000000 /* RW--V */
2100
#define NV_PGRAPH_CLIPY_0_CLIP4_MAX_GT                   0x00000001 /* RWN-V */
2101
#define NV_PGRAPH_CLIPY_0_CLIP4_MAX_EQ                   0x00000002 /* RW--V */
2102
#define NV_PGRAPH_CLIPY_0_CLIP5_MIN                           21:20 /* RWNVF */
2103
#define NV_PGRAPH_CLIPY_0_CLIP5_MIN_GT                   0x00000000 /* RW--V */
2104
#define NV_PGRAPH_CLIPY_0_CLIP5_MIN_LT                   0x00000001 /* RWN-V */
2105
#define NV_PGRAPH_CLIPY_0_CLIP5_MIN_EQ                   0x00000002 /* RW--V */
2106
#define NV_PGRAPH_CLIPY_0_CLIP5_MAX                           23:22 /* RWNVF */
2107
#define NV_PGRAPH_CLIPY_0_CLIP5_MAX_LT                   0x00000000 /* RW--V */
2108
#define NV_PGRAPH_CLIPY_0_CLIP5_MAX_GT                   0x00000001 /* RWN-V */
2109
#define NV_PGRAPH_CLIPY_0_CLIP5_MAX_EQ                   0x00000002 /* RW--V */
2110
#define NV_PGRAPH_CLIPY_0_CLIP6_MIN                           25:24 /* RWNVF */
2111
#define NV_PGRAPH_CLIPY_0_CLIP6_MIN_GT                   0x00000000 /* RW--V */
2112
#define NV_PGRAPH_CLIPY_0_CLIP6_MIN_LT                   0x00000001 /* RWN-V */
2113
#define NV_PGRAPH_CLIPY_0_CLIP6_MIN_EQ                   0x00000002 /* RW--V */
2114
#define NV_PGRAPH_CLIPY_0_CLIP6_MAX                           27:26 /* RWNVF */
2115
#define NV_PGRAPH_CLIPY_0_CLIP6_MAX_LT                   0x00000000 /* RW--V */
2116
#define NV_PGRAPH_CLIPY_0_CLIP6_MAX_GT                   0x00000001 /* RWN-V */
2117
#define NV_PGRAPH_CLIPY_0_CLIP6_MAX_EQ                   0x00000002 /* RW--V */
2118
#define NV_PGRAPH_CLIPY_0_CLIP7_MIN                           29:28 /* RWNVF */
2119
#define NV_PGRAPH_CLIPY_0_CLIP7_MIN_GT                   0x00000000 /* RW--V */
2120
#define NV_PGRAPH_CLIPY_0_CLIP7_MIN_LT                   0x00000001 /* RWN-V */
2121
#define NV_PGRAPH_CLIPY_0_CLIP7_MIN_EQ                   0x00000002 /* RW--V */
2122
#define NV_PGRAPH_CLIPY_0_CLIP7_MAX                           31:30 /* RWNVF */
2123
#define NV_PGRAPH_CLIPY_0_CLIP7_MAX_LT                   0x00000000 /* RW--V */
2124
#define NV_PGRAPH_CLIPY_0_CLIP7_MAX_GT                   0x00000001 /* RWN-V */
2125
#define NV_PGRAPH_CLIPY_0_CLIP7_MAX_EQ                   0x00000002 /* RW--V */
2126
#define NV_PGRAPH_CLIPY_1                                0x00400530 /* RW-4R */
2127
#define NV_PGRAPH_CLIPY_1_CLIP8_MIN                             1:0 /* RWNVF */
2128
#define NV_PGRAPH_CLIPY_1_CLIP8_MIN_GT                   0x00000000 /* RW--V */
2129
#define NV_PGRAPH_CLIPY_1_CLIP8_MIN_LT                   0x00000001 /* RWN-V */
2130
#define NV_PGRAPH_CLIPY_1_CLIP8_MIN_EQ                   0x00000002 /* RW--V */
2131
#define NV_PGRAPH_CLIPY_1_CLIP8_MAX                             3:2 /* RWNVF */
2132
#define NV_PGRAPH_CLIPY_1_CLIP8_MAX_LT                   0x00000000 /* RW--V */
2133
#define NV_PGRAPH_CLIPY_1_CLIP8_MAX_GT                   0x00000001 /* RWN-V */
2134
#define NV_PGRAPH_CLIPY_1_CLIP8_MAX_EQ                   0x00000002 /* RW--V */
2135
#define NV_PGRAPH_CLIPY_1_CLIP9_MIN                             5:4 /* RWNVF */
2136
#define NV_PGRAPH_CLIPY_1_CLIP9_MIN_GT                   0x00000000 /* RW--V */
2137
#define NV_PGRAPH_CLIPY_1_CLIP9_MIN_LT                   0x00000001 /* RWN-V */
2138
#define NV_PGRAPH_CLIPY_1_CLIP9_MIN_EQ                   0x00000002 /* RW--V */
2139
#define NV_PGRAPH_CLIPY_1_CLIP9_MAX                             7:6 /* RWNVF */
2140
#define NV_PGRAPH_CLIPY_1_CLIP9_MAX_LT                   0x00000000 /* RW--V */
2141
#define NV_PGRAPH_CLIPY_1_CLIP9_MAX_GT                   0x00000001 /* RWN-V */
2142
#define NV_PGRAPH_CLIPY_1_CLIP9_MAX_EQ                   0x00000002 /* RW--V */
2143
#define NV_PGRAPH_CLIPY_1_CLIP10_MIN                            9:8 /* RWNVF */
2144
#define NV_PGRAPH_CLIPY_1_CLIP10_MIN_GT                  0x00000000 /* RW--V */
2145
#define NV_PGRAPH_CLIPY_1_CLIP10_MIN_LT                  0x00000001 /* RWN-V */
2146
#define NV_PGRAPH_CLIPY_1_CLIP10_MIN_EQ                  0x00000002 /* RW--V */
2147
#define NV_PGRAPH_CLIPY_1_CLIP10_MAX                          11:10 /* RWNVF */
2148
#define NV_PGRAPH_CLIPY_1_CLIP10_MAX_LT                  0x00000000 /* RW--V */
2149
#define NV_PGRAPH_CLIPY_1_CLIP10_MAX_GT                  0x00000001 /* RWN-V */
2150
#define NV_PGRAPH_CLIPY_1_CLIP10_MAX_EQ                  0x00000002 /* RW--V */
2151
#define NV_PGRAPH_CLIPY_1_CLIP11_MIN                          13:12 /* RWNVF */
2152
#define NV_PGRAPH_CLIPY_1_CLIP11_MIN_GT                  0x00000000 /* RW--V */
2153
#define NV_PGRAPH_CLIPY_1_CLIP11_MIN_LT                  0x00000001 /* RWN-V */
2154
#define NV_PGRAPH_CLIPY_1_CLIP11MIN_EQ                   0x00000002 /* RW--V */
2155
#define NV_PGRAPH_CLIPY_1_CLIP11_MAX                          15:14 /* RWNVF */
2156
#define NV_PGRAPH_CLIPY_1_CLIP11_MAX_LT                  0x00000000 /* RW--V */
2157
#define NV_PGRAPH_CLIPY_1_CLIP11_MAX_GT                  0x00000001 /* RWN-V */
2158
#define NV_PGRAPH_CLIPY_1_CLIP11_MAX_EQ                  0x00000002 /* RW--V */
2159
#define NV_PGRAPH_CLIPY_1_CLIP12_MIN                          17:16 /* RWNVF */
2160
#define NV_PGRAPH_CLIPY_1_CLIP12_MIN_GT                  0x00000000 /* RW--V */
2161
#define NV_PGRAPH_CLIPY_1_CLIP12_MIN_LT                  0x00000001 /* RWN-V */
2162
#define NV_PGRAPH_CLIPY_1_CLIP12_MIN_EQ                  0x00000002 /* RW--V */
2163
#define NV_PGRAPH_CLIPY_1_CLIP12_MAX                          19:18 /* RWNVF */
2164
#define NV_PGRAPH_CLIPY_1_CLIP12_MAX_LT                  0x00000000 /* RW--V */
2165
#define NV_PGRAPH_CLIPY_1_CLIP12_MAX_GT                  0x00000001 /* RWN-V */
2166
#define NV_PGRAPH_CLIPY_1_CLIP12_MAX_EQ                  0x00000002 /* RW--V */
2167
#define NV_PGRAPH_CLIPY_1_CLIP13_MIN                          21:20 /* RWNVF */
2168
#define NV_PGRAPH_CLIPY_1_CLIP13_MIN_GT                  0x00000000 /* RW--V */
2169
#define NV_PGRAPH_CLIPY_1_CLIP13_MIN_LT                  0x00000001 /* RWN-V */
2170
#define NV_PGRAPH_CLIPY_1_CLIP13_MIN_EQ                  0x00000002 /* RW--V */
2171
#define NV_PGRAPH_CLIPY_1_CLIP13_MAX                          23:22 /* RWNVF */
2172
#define NV_PGRAPH_CLIPY_1_CLIP13_MAX_LT                  0x00000000 /* RW--V */
2173
#define NV_PGRAPH_CLIPY_1_CLIP13_MAX_GT                  0x00000001 /* RWN-V */
2174
#define NV_PGRAPH_CLIPY_1_CLIP13_MAX_EQ                  0x00000002 /* RW--V */
2175
#define NV_PGRAPH_CLIPY_1_CLIP14_MIN                          25:24 /* RWNVF */
2176
#define NV_PGRAPH_CLIPY_1_CLIP14_MIN_GT                  0x00000000 /* RW--V */
2177
#define NV_PGRAPH_CLIPY_1_CLIP14_MIN_LT                  0x00000001 /* RWN-V */
2178
#define NV_PGRAPH_CLIPY_1_CLIP14_MIN_EQ                  0x00000002 /* RW--V */
2179
#define NV_PGRAPH_CLIPY_1_CLIP14_MAX                          27:26 /* RWNVF */
2180
#define NV_PGRAPH_CLIPY_1_CLIP14_MAX_LT                  0x00000000 /* RW--V */
2181
#define NV_PGRAPH_CLIPY_1_CLIP14_MAX_GT                  0x00000001 /* RWN-V */
2182
#define NV_PGRAPH_CLIPY_1_CLIP14_MAX_EQ                  0x00000002 /* RW--V */
2183
#define NV_PGRAPH_CLIPY_1_CLIP15_MIN                          29:28 /* RWNVF */
2184
#define NV_PGRAPH_CLIPY_1_CLIP15_MIN_GT                  0x00000000 /* RW--V */
2185
#define NV_PGRAPH_CLIPY_1_CLIP15_MIN_LT                  0x00000001 /* RWN-V */
2186
#define NV_PGRAPH_CLIPY_1_CLIP15_MIN_EQ                  0x00000002 /* RW--V */
2187
#define NV_PGRAPH_CLIPY_1_CLIP15_MAX                          31:30 /* RWNVF */
2188
#define NV_PGRAPH_CLIPY_1_CLIP15_MAX_LT                  0x00000000 /* RW--V */
2189
#define NV_PGRAPH_CLIPY_1_CLIP15_MAX_GT                  0x00000001 /* RWN-V */
2190
#define NV_PGRAPH_CLIPY_1_CLIP15_MAX_EQ                  0x00000002 /* RW--V */
2191
#define NV_PGRAPH_MISC24_0                               0x00400510 /* RW-4R */
2192
#define NV_PGRAPH_MISC24_0_VALUE                               23:0 /* RWXUF */
2193
#define NV_PGRAPH_MISC24_1                               0x00400570 /* RW-4R */
2194
#define NV_PGRAPH_MISC24_1_VALUE                               23:0 /* RWXUF */
2195
#define NV_PGRAPH_MISC24_2                               0x00400574 /* RW-4R */
2196
#define NV_PGRAPH_MISC24_2_VALUE                               23:0 /* RWXUF */
2197
#define NV_PGRAPH_PASSTHRU_0                             0x0040057C /* RW-4R */
2198
#define NV_PGRAPH_PASSTHRU_0_VALUE                             31:0 /* RWXUF */
2199
#define NV_PGRAPH_PASSTHRU_1                             0x00400580 /* RW-4R */
2200
#define NV_PGRAPH_PASSTHRU_1_VALUE                             31:0 /* RWXUF */
2201
#define NV_PGRAPH_PASSTHRU_2                             0x00400584 /* RW-4R */
2202
#define NV_PGRAPH_PASSTHRU_2_VALUE                             31:0 /* RWXUF */
2203
#define NV_PGRAPH_U_RAM(i)                       (0x00400d00+(i)*4) /* RW-4A */
2204
#define NV_PGRAPH_U_RAM__SIZE_1                                  16 /*       */
2205
#define NV_PGRAPH_U_RAM_VALUE                                  31:6 /* RWXFF */
2206
#define NV_PGRAPH_V_RAM(i)                       (0x00400d40+(i)*4) /* RW-4A */
2207
#define NV_PGRAPH_V_RAM__SIZE_1                                  16 /*       */
2208
#define NV_PGRAPH_V_RAM_VALUE                                  31:6 /* RWXFF */
2209
#define NV_PGRAPH_M_RAM(i)                       (0x00400d80+(i)*4) /* RW-4A */
2210
#define NV_PGRAPH_M_RAM__SIZE_1                                  16 /*       */
2211
#define NV_PGRAPH_M_RAM_VALUE                                  31:6 /* RWXFF */
2212
#define NV_PGRAPH_DMA_START_0                            0x00401000 /* RW-4R */
2213
#define NV_PGRAPH_DMA_START_0_VALUE                            31:0 /* RWXUF */
2214
#define NV_PGRAPH_DMA_START_1                            0x00401004 /* RW-4R */
2215
#define NV_PGRAPH_DMA_START_1_VALUE                            31:0 /* RWXUF */
2216
#define NV_PGRAPH_DMA_LENGTH                             0x00401008 /* RW-4R */
2217
#define NV_PGRAPH_DMA_LENGTH_VALUE                             21:0 /* RWXUF */
2218
#define NV_PGRAPH_DMA_MISC                               0x0040100C /* RW-4R */
2219
#define NV_PGRAPH_DMA_MISC_COUNT                               15:0 /* RWXUF */
2220
#define NV_PGRAPH_DMA_MISC_FMT_SRC                            18:16 /* RWXVF */
2221
#define NV_PGRAPH_DMA_MISC_FMT_DST                            22:20 /* RWXVF */
2222
#define NV_PGRAPH_DMA_DATA_0                             0x00401020 /* RW-4R */
2223
#define NV_PGRAPH_DMA_DATA_0_VALUE                             31:0 /* RWXUF */
2224
#define NV_PGRAPH_DMA_DATA_1                             0x00401024 /* RW-4R */
2225
#define NV_PGRAPH_DMA_DATA_1_VALUE                             31:0 /* RWXUF */
2226
#define NV_PGRAPH_DMA_RM                                 0x00401030 /* RW-4R */
2227
#define NV_PGRAPH_DMA_RM_ASSIST_A                               0:0 /* RWIVF */
2228
#define NV_PGRAPH_DMA_RM_ASSIST_A_NOT_PENDING            0x00000000 /* R-I-V */
2229
#define NV_PGRAPH_DMA_RM_ASSIST_A_PENDING                0x00000001 /* R---V */
2230
#define NV_PGRAPH_DMA_RM_ASSIST_A_RESET                  0x00000001 /* -W--C */
2231
#define NV_PGRAPH_DMA_RM_ASSIST_B                               1:1 /* RWIVF */
2232
#define NV_PGRAPH_DMA_RM_ASSIST_B_NOT_PENDING            0x00000000 /* R-I-V */
2233
#define NV_PGRAPH_DMA_RM_ASSIST_B_PENDING                0x00000001 /* R---V */
2234
#define NV_PGRAPH_DMA_RM_ASSIST_B_RESET                  0x00000001 /* -W--C */
2235
#define NV_PGRAPH_DMA_RM_WRITE_REQ                              4:4 /* CWIVF */
2236
#define NV_PGRAPH_DMA_RM_WRITE_REQ_NOT_PENDING           0x00000000 /* CWI-V */
2237
#define NV_PGRAPH_DMA_RM_WRITE_REQ_PENDING               0x00000001 /* -W--T */
2238
#define NV_PGRAPH_DMA_A_XLATE_INST                       0x00401040 /* RW-4R */
2239
#define NV_PGRAPH_DMA_A_XLATE_INST_VALUE                       15:0 /* RWXUF */
2240
#define NV_PGRAPH_DMA_A_CONTROL                          0x00401044 /* RW-4R */
2241
#define NV_PGRAPH_DMA_A_CONTROL_PAGE_TABLE                    12:12 /* RWIVF */
2242
#define NV_PGRAPH_DMA_A_CONTROL_PAGE_TABLE_NOT_PRESENT   0x00000000 /* RWI-V */
2243
#define NV_PGRAPH_DMA_A_CONTROL_PAGE_TABLE_PRESENT       0x00000001 /* RW--V */
2244
#define NV_PGRAPH_DMA_A_CONTROL_PAGE_ENTRY                    13:13 /* RWXVF */
2245
#define NV_PGRAPH_DMA_A_CONTROL_PAGE_ENTRY_NOT_LINEAR    0x00000000 /* RW--V */
2246
#define NV_PGRAPH_DMA_A_CONTROL_PAGE_ENTRY_LINEAR        0x00000001 /* RW--V */
2247
#define NV_PGRAPH_DMA_A_CONTROL_TARGET_NODE                   17:16 /* RWXUF */
2248
#define NV_PGRAPH_DMA_A_CONTROL_TARGET_NODE_NVM          0x00000000 /* RW--V */
2249
#define NV_PGRAPH_DMA_A_CONTROL_TARGET_NODE_PCI          0x00000002 /* RW--V */
2250
#define NV_PGRAPH_DMA_A_CONTROL_TARGET_NODE_AGP          0x00000003 /* RW--V */
2251
#define NV_PGRAPH_DMA_A_CONTROL_ADJUST                        31:20 /* RWXUF */
2252
#define NV_PGRAPH_DMA_A_LIMIT                            0x00401048 /* RW-4R */
2253
#define NV_PGRAPH_DMA_A_LIMIT_OFFSET                           31:0 /* RWXUF */
2254
#define NV_PGRAPH_DMA_A_TLB_PTE                          0x0040104C /* RW-4R */
2255
#define NV_PGRAPH_DMA_A_TLB_PTE_ACCESS                          1:1 /* RWXVF */
2256
#define NV_PGRAPH_DMA_A_TLB_PTE_ACCESS_READ_ONLY         0x00000000 /* RW--V */
2257
#define NV_PGRAPH_DMA_A_TLB_PTE_ACCESS_READ_WRITE        0x00000001 /* RW--V */
2258
#define NV_PGRAPH_DMA_A_TLB_PTE_FRAME_ADDRESS                 31:12 /* RWXUF */
2259
#define NV_PGRAPH_DMA_A_TLB_TAG                          0x00401050 /* RW-4R */
2260
#define NV_PGRAPH_DMA_A_TLB_TAG_ADDRESS                       31:12 /* RWXUF */
2261
#define NV_PGRAPH_DMA_A_ADJ_OFFSET                       0x00401054 /* RW-4R */
2262
#define NV_PGRAPH_DMA_A_ADJ_OFFSET_VALUE                       31:0 /* RWXUF */
2263
#define NV_PGRAPH_DMA_A_OFFSET                           0x00401058 /* RW-4R */
2264
#define NV_PGRAPH_DMA_A_OFFSET_VALUE                           31:0 /* RWXUF */
2265
#define NV_PGRAPH_DMA_A_SIZE                             0x0040105C /* RW-4R */
2266
#define NV_PGRAPH_DMA_A_SIZE_VALUE                             24:0 /* RWXUF */
2267
#define NV_PGRAPH_DMA_A_Y_SIZE                           0x00401060 /* RW-4R */
2268
#define NV_PGRAPH_DMA_A_Y_SIZE_VALUE                           10:0 /* RWXUF */
2269
#define NV_PGRAPH_DMA_B_XLATE_INST                       0x00401080 /* RW-4R */
2270
#define NV_PGRAPH_DMA_B_XLATE_INST_VALUE                       15:0 /* RWXUF */
2271
#define NV_PGRAPH_DMA_B_CONTROL                          0x00401084 /* RW-4R */
2272
#define NV_PGRAPH_DMA_B_CONTROL_PAGE_TABLE                    12:12 /* RWIVF */
2273
#define NV_PGRAPH_DMA_B_CONTROL_PAGE_TABLE_NOT_PRESENT   0x00000000 /* RWI-V */
2274
#define NV_PGRAPH_DMA_B_CONTROL_PAGE_TABLE_PRESENT       0x00000001 /* RW--V */
2275
#define NV_PGRAPH_DMA_B_CONTROL_PAGE_ENTRY                    13:13 /* RWXVF */
2276
#define NV_PGRAPH_DMA_B_CONTROL_PAGE_ENTRY_NOT_LINEAR    0x00000000 /* RW--V */
2277
#define NV_PGRAPH_DMA_B_CONTROL_PAGE_ENTRY_LINEAR        0x00000001 /* RW--V */
2278
#define NV_PGRAPH_DMA_B_CONTROL_TARGET_NODE                   17:16 /* RWXUF */
2279
#define NV_PGRAPH_DMA_B_CONTROL_TARGET_NODE_NVM          0x00000000 /* RW--V */
2280
#define NV_PGRAPH_DMA_B_CONTROL_TARGET_NODE_PCI          0x00000002 /* RW--V */
2281
#define NV_PGRAPH_DMA_B_CONTROL_TARGET_NODE_AGP          0x00000003 /* RW--V */
2282
#define NV_PGRAPH_DMA_B_CONTROL_ADJUST                        31:20 /* RWXUF */
2283
#define NV_PGRAPH_DMA_B_LIMIT                            0x00401088 /* RW-4R */
2284
#define NV_PGRAPH_DMA_B_LIMIT_OFFSET                           31:0 /* RWXUF */
2285
#define NV_PGRAPH_DMA_B_TLB_PTE                          0x0040108C /* RW-4R */
2286
#define NV_PGRAPH_DMA_B_TLB_PTE_ACCESS                          1:1 /* RWXVF */
2287
#define NV_PGRAPH_DMA_B_TLB_PTE_ACCESS_READ_ONLY         0x00000000 /* RW--V */
2288
#define NV_PGRAPH_DMA_B_TLB_PTE_ACCESS_READ_WRITE        0x00000001 /* RW--V */
2289
#define NV_PGRAPH_DMA_B_TLB_PTE_FRAME_ADDRESS                 31:12 /* RWXUF */
2290
#define NV_PGRAPH_DMA_B_TLB_TAG                          0x00401090 /* RW-4R */
2291
#define NV_PGRAPH_DMA_B_TLB_TAG_ADDRESS                       31:12 /* RWXUF */
2292
#define NV_PGRAPH_DMA_B_ADJ_OFFSET                       0x00401094 /* RW-4R */
2293
#define NV_PGRAPH_DMA_B_ADJ_OFFSET_VALUE                       31:0 /* RWXUF */
2294
#define NV_PGRAPH_DMA_B_OFFSET                           0x00401098 /* RW-4R */
2295
#define NV_PGRAPH_DMA_B_OFFSET_VALUE                           31:0 /* RWXUF */
2296
#define NV_PGRAPH_DMA_B_SIZE                             0x0040109C /* RW-4R */
2297
#define NV_PGRAPH_DMA_B_SIZE_VALUE                             24:0 /* RWXUF */
2298
#define NV_PGRAPH_DMA_B_Y_SIZE                           0x004010A0 /* RW-4R */
2299
#define NV_PGRAPH_DMA_B_Y_SIZE_VALUE                           10:0 /* RWXUF */
2300
2301
/* Framebuffer registers */
2302
#define NV_PFB                                0x00100FFF:0x00100000 /* RW--D */
2303
#define NV_PFB_BOOT_0                                    0x00100000 /* RW-4R */
2304
#define NV_PFB_BOOT_0_RAM_AMOUNT                                1:0 /* RW-VF */
2305
#define NV_PFB_BOOT_0_RAM_AMOUNT_32MB                    0x00000000 /* RW--V */
2306
#define NV_PFB_BOOT_0_RAM_AMOUNT_4MB                     0x00000001 /* RW--V */
2307
#define NV_PFB_BOOT_0_RAM_AMOUNT_8MB                     0x00000002 /* RW--V */
2308
#define NV_PFB_BOOT_0_RAM_AMOUNT_16MB                    0x00000003 /* RW--V */
2309
#define NV_PFB_BOOT_0_RAM_WIDTH_128                             2:2 /* RW-VF */
2310
#define NV_PFB_BOOT_0_RAM_WIDTH_128_OFF                  0x00000000 /* RW--V */
2311
#define NV_PFB_BOOT_0_RAM_WIDTH_128_ON                   0x00000001 /* RW--V */
2312
#define NV_PFB_BOOT_0_RAM_TYPE                                  4:3 /* RW-VF */
2313
#define NV_PFB_BOOT_0_RAM_TYPE_256K                      0x00000000 /* RW--V */
2314
#define NV_PFB_BOOT_0_RAM_TYPE_512K_2BANK                0x00000001 /* RW--V */
2315
#define NV_PFB_BOOT_0_RAM_TYPE_512K_4BANK                0x00000002 /* RW--V */
2316
#define NV_PFB_BOOT_0_RAM_TYPE_1024K_2BANK               0x00000003 /* RW--V */
2317
#define NV_PFB_CONFIG_0                                  0x00100200 /* RW-4R */
2318
#define NV_PFB_CONFIG_0_TYPE                                   14:0 /* RWIVF */
2319
#define NV_PFB_CONFIG_0_TYPE_OLD1024_FIXED_8BPP          0x00000120 /* RW--V */
2320
#define NV_PFB_CONFIG_0_TYPE_OLD1024_FIXED_16BPP         0x00000220 /* RW--V */
2321
#define NV_PFB_CONFIG_0_TYPE_OLD1024_FIXED_32BPP         0x00000320 /* RW--V */
2322
#define NV_PFB_CONFIG_0_TYPE_OLD1024_VAR_8BPP            0x00004120 /* RW--V */
2323
#define NV_PFB_CONFIG_0_TYPE_OLD1024_VAR_16BPP           0x00004220 /* RW--V */
2324
#define NV_PFB_CONFIG_0_TYPE_OLD1024_VAR_32BPP           0x00004320 /* RW--V */
2325
#define NV_PFB_CONFIG_0_TYPE_TETRIS                      0x00002000 /* RW--V */
2326
#define NV_PFB_CONFIG_0_TYPE_NOTILING                    0x00001114 /* RWI-V */
2327
#define NV_PFB_CONFIG_0_TETRIS_MODE                           17:15 /* RWI-F */
2328
#define NV_PFB_CONFIG_0_TETRIS_MODE_PASS                 0x00000000 /* RWI-V */
2329
#define NV_PFB_CONFIG_0_TETRIS_MODE_1                    0x00000001 /* RW--V */
2330
#define NV_PFB_CONFIG_0_TETRIS_MODE_2                    0x00000002 /* RW--V */
2331
#define NV_PFB_CONFIG_0_TETRIS_MODE_3                    0x00000003 /* RW--V */
2332
#define NV_PFB_CONFIG_0_TETRIS_MODE_4                    0x00000004 /* RW--V */
2333
#define NV_PFB_CONFIG_0_TETRIS_MODE_5                    0x00000005 /* RW--V */
2334
#define NV_PFB_CONFIG_0_TETRIS_MODE_6                    0x00000006 /* RW--V */
2335
#define NV_PFB_CONFIG_0_TETRIS_MODE_7                    0x00000007 /* RW--V */
2336
#define NV_PFB_CONFIG_0_TETRIS_SHIFT                          19:18 /* RWI-F */
2337
#define NV_PFB_CONFIG_0_TETRIS_SHIFT_0                   0x00000000 /* RWI-V */
2338
#define NV_PFB_CONFIG_0_TETRIS_SHIFT_1                   0x00000001 /* RW--V */
2339
#define NV_PFB_CONFIG_0_TETRIS_SHIFT_2                   0x00000002 /* RW--V */
2340
#define NV_PFB_CONFIG_0_BANK_SWAP                             22:20 /* RWI-F */
2341
#define NV_PFB_CONFIG_0_BANK_SWAP_OFF                    0x00000000 /* RWI-V */
2342
#define NV_PFB_CONFIG_0_BANK_SWAP_1M                     0x00000001 /* RW--V */
2343
#define NV_PFB_CONFIG_0_BANK_SWAP_2M                     0x00000005 /* RW--V */
2344
#define NV_PFB_CONFIG_0_BANK_SWAP_4M                     0x00000007 /* RW--V */
2345
#define NV_PFB_CONFIG_0_UNUSED                                23:23 /* RW-VF */
2346
#define NV_PFB_CONFIG_0_SCRAMBLE_EN                           29:29 /* RWIVF */
2347
#define NV_PFB_CONFIG_0_SCRAMBLE_EN_INIT                 0x00000000 /* RW--V */
2348
#define NV_PFB_CONFIG_0_SCRAMBLE_ACTIVE                  0x00000001 /* RW--V */
2349
#define NV_PFB_CONFIG_0_PRAMIN_WR                             28:28 /* RWIVF */
2350
#define NV_PFB_CONFIG_0_PRAMIN_WR_INIT                   0x00000000 /* RW--V */
2351
#define NV_PFB_CONFIG_0_PRAMIN_WR_DISABLED               0x00000001 /* RW--V */
2352
#define NV_PFB_CONFIG_0_PRAMIN_WR_MASK                        27:24 /* RWIVF */
2353
#define NV_PFB_CONFIG_0_PRAMIN_WR_MASK_INIT              0x00000000 /* RWI-V */
2354
#define NV_PFB_CONFIG_0_PRAMIN_WR_MASK_CLEAR             0x0000000f /* RWI-V */
2355
#define NV_PFB_CONFIG_1                                  0x00100204 /* RW-4R */
2356
#define NV_PFB_RTL                                       0x00100300 /* RW-4R */
2357
#define NV_PFB_RTL_H                                            0:0 /* RWIUF */
2358
#define NV_PFB_RTL_H_DEFAULT                             0x00000000 /* RWI-V */
2359
#define NV_PFB_RTL_MC                                           1:1 /* RWIUF */
2360
#define NV_PFB_RTL_MC_DEFAULT                            0x00000000 /* RWI-V */
2361
#define NV_PFB_RTL_V                                            2:2 /* RWIUF */
2362
#define NV_PFB_RTL_V_DEFAULT                             0x00000000 /* RWI-V */
2363
#define NV_PFB_RTL_G                                            3:3 /* RWIUF */
2364
#define NV_PFB_RTL_G_DEFAULT                             0x00000000 /* RWI-V */
2365
#define NV_PFB_RTL_GB                                           4:4 /* RWIUF */
2366
#define NV_PFB_RTL_GB_DEFAULT                            0x00000000 /* RWI-V */
2367
#define NV_PFB_CONFIG_0_RESOLUTION                              5:0 /* RWIVF */
2368
#define NV_PFB_CONFIG_0_RESOLUTION_320_PIXELS            0x0000000a /* RW--V */
2369
#define NV_PFB_CONFIG_0_RESOLUTION_400_PIXELS            0x0000000d /* RW--V */
2370
#define NV_PFB_CONFIG_0_RESOLUTION_480_PIXELS            0x0000000f /* RW--V */
2371
#define NV_PFB_CONFIG_0_RESOLUTION_512_PIXELS            0x00000010 /* RW--V */
2372
#define NV_PFB_CONFIG_0_RESOLUTION_640_PIXELS            0x00000014 /* RW--V */
2373
#define NV_PFB_CONFIG_0_RESOLUTION_800_PIXELS            0x00000019 /* RW--V */
2374
#define NV_PFB_CONFIG_0_RESOLUTION_960_PIXELS            0x0000001e /* RW--V */
2375
#define NV_PFB_CONFIG_0_RESOLUTION_1024_PIXELS           0x00000020 /* RW--V */
2376
#define NV_PFB_CONFIG_0_RESOLUTION_1152_PIXELS           0x00000024 /* RW--V */
2377
#define NV_PFB_CONFIG_0_RESOLUTION_1280_PIXELS           0x00000028 /* RW--V */
2378
#define NV_PFB_CONFIG_0_RESOLUTION_1600_PIXELS           0x00000032 /* RW--V */
2379
#define NV_PFB_CONFIG_0_RESOLUTION_DEFAULT               0x00000014 /* RWI-V */
2380
#define NV_PFB_CONFIG_0_PIXEL_DEPTH                             9:8 /* RWIVF */
2381
#define NV_PFB_CONFIG_0_PIXEL_DEPTH_8_BITS               0x00000001 /* RW--V */
2382
#define NV_PFB_CONFIG_0_PIXEL_DEPTH_16_BITS              0x00000002 /* RW--V */
2383
#define NV_PFB_CONFIG_0_PIXEL_DEPTH_32_BITS              0x00000003 /* RW--V */
2384
#define NV_PFB_CONFIG_0_PIXEL_DEPTH_DEFAULT              0x00000001 /* RWI-V */
2385
#define NV_PFB_CONFIG_0_TILING                                12:12 /* RWIVF */
2386
#define NV_PFB_CONFIG_0_TILING_ENABLED                   0x00000000 /* RW--V */
2387
#define NV_PFB_CONFIG_0_TILING_DISABLED                  0x00000001 /* RWI-V */
2388
#define NV_PFB_CONFIG_1_SGRAM100                                3:3 /* RWIVF */
2389
#define NV_PFB_CONFIG_1_SGRAM100_ENABLED                 0x00000000 /* RWI-V */
2390
#define NV_PFB_CONFIG_1_SGRAM100_DISABLED                0x00000001 /* RW--V */
2391
#define NV_PFB_DEBUG_0_CKE_ALWAYSON                           29:29 /* RWIVF */
2392
#define NV_PFB_DEBUG_0_CKE_ALWAYSON_OFF                  0x00000000 /* RW--V */
2393
#define NV_PFB_DEBUG_0_CKE_ALWAYSON_ON                   0x00000001 /* RWI-V */
2394
2395
#define NV_PEXTDEV                            0x00101FFF:0x00101000 /* RW--D */
2396
#define NV_PEXTDEV_BOOT_0                                0x00101000 /* R--4R */
2397
#define NV_PEXTDEV_BOOT_0_STRAP_BUS_SPEED                       0:0 /* R-XVF */
2398
#define NV_PEXTDEV_BOOT_0_STRAP_BUS_SPEED_33MHZ          0x00000000 /* R---V */
2399
#define NV_PEXTDEV_BOOT_0_STRAP_BUS_SPEED_66MHZ          0x00000001 /* R---V */
2400
#define NV_PEXTDEV_BOOT_0_STRAP_SUB_VENDOR                      1:1 /* R-XVF */
2401
#define NV_PEXTDEV_BOOT_0_STRAP_SUB_VENDOR_NO_BIOS       0x00000000 /* R---V */
2402
#define NV_PEXTDEV_BOOT_0_STRAP_SUB_VENDOR_BIOS          0x00000001 /* R---V */
2403
#define NV_PEXTDEV_BOOT_0_STRAP_RAM_TYPE                        3:2 /* R-XVF */
2404
#define NV_PEXTDEV_BOOT_0_STRAP_RAM_TYPE_SGRAM_256K      0x00000000 /* R---V */
2405
#define NV_PEXTDEV_BOOT_0_STRAP_RAM_TYPE_SGRAM_512K_2BANK 0x00000001 /* R---V */
2406
#define NV_PEXTDEV_BOOT_0_STRAP_RAM_TYPE_SGRAM_512K_4BANK 0x00000002 /* R---V */
2407
#define NV_PEXTDEV_BOOT_0_STRAP_RAM_TYPE_1024K_2BANK     0x00000003 /* R---V */
2408
#define NV_PEXTDEV_BOOT_0_STRAP_RAM_WIDTH                       4:4 /* R-XVF */
2409
#define NV_PEXTDEV_BOOT_0_STRAP_RAM_WIDTH_64             0x00000000 /* R---V */
2410
#define NV_PEXTDEV_BOOT_0_STRAP_RAM_WIDTH_128            0x00000001 /* R---V */
2411
#define NV_PEXTDEV_BOOT_0_STRAP_BUS_TYPE                        5:5 /* R-XVF */
2412
#define NV_PEXTDEV_BOOT_0_STRAP_BUS_TYPE_PCI             0x00000000 /* R---V */
2413
#define NV_PEXTDEV_BOOT_0_STRAP_BUS_TYPE_AGP             0x00000001 /* R---V */
2414
#define NV_PEXTDEV_BOOT_0_STRAP_CRYSTAL                         6:6 /* R-XVF */
2415
#define NV_PEXTDEV_BOOT_0_STRAP_CRYSTAL_13500K           0x00000000 /* R---V */
2416
#define NV_PEXTDEV_BOOT_0_STRAP_CRYSTAL_14318180         0x00000001 /* R---V */
2417
#define NV_PEXTDEV_BOOT_0_STRAP_TVMODE                          8:7 /* R-XVF */
2418
#define NV_PEXTDEV_BOOT_0_STRAP_TVMODE_SECAM             0x00000000 /* R---V */
2419
#define NV_PEXTDEV_BOOT_0_STRAP_TVMODE_NTSC              0x00000001 /* R---V */
2420
#define NV_PEXTDEV_BOOT_0_STRAP_TVMODE_PAL               0x00000002 /* R---V */
2421
#define NV_PEXTDEV_BOOT_0_STRAP_TVMODE_DISABLED          0x00000003 /* R---V */
2422
#define NV_PEXTDEV_BOOT_0_STRAP_OVERWRITE                     11:11 /* RWIVF */
2423
#define NV_PEXTDEV_BOOT_0_STRAP_OVERWRITE_DISABLED       0x00000000 /* RWI-V */
2424
#define NV_PEXTDEV_BOOT_0_STRAP_OVERWRITE_ENABLED        0x00000001 /* RW--V */
2425
2426
/* Extras */
2427
#define NV_PRAMIN                             0x007FFFFF:0x00700000 /* RW--M */
2428
/*#define NV_PRAMIN                             0x00FFFFFF:0x00C00000*/
2429
#define NV_PNVM                               0x01FFFFFF:0x01000000 /* RW--M */
2430
/*#define NV_PNVM                               0x00BFFFFF:0x00800000*/
2431
#define NV_CHAN0                              0x0080ffff:0x00800000
2432
2433
/* FIFO subchannels */
2434
#define NV_UROP                               0x43
2435
#define NV_UCHROMA                            0x57
2436
#define NV_UCLIP                              0x19
2437
#define NV_UPATT                              0x18
2438
#define NV_ULIN                               0x5C
2439
#define NV_UTRI                               0x5D
2440
#define NV_URECT                              0x5E
2441
#define NV_UBLIT                              0x5F
2442
#define NV_UGLYPH                             0x4B
2443
2444
#endif /*__NV4REF_H__*/
2445
(-)linux-2.4.26/drivers/video/xbox/nvreg.h (+188 lines)
Line 0 Link Here
1
/* $XConsortium: nvreg.h /main/2 1996/10/28 05:13:41 kaleb $ */
2
/*
3
 * Copyright 1996-1997  David J. McKay
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * copy of this software and associated documentation files (the "Software"),
7
 * to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in
13
 * all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
 * DAVID J. MCKAY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
20
 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
 * SOFTWARE.
22
 */
23
24
/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/nv/nvreg.h,v 3.2.2.1 1998/01/18 10:35:36 hohndel Exp $ */
25
26
#ifndef __NVREG_H_
27
#define __NVREG_H_
28
29
/* Little macro to construct bitmask for contiguous ranges of bits */
30
#define BITMASK(t,b) (((unsigned)(1U << (((t)-(b)+1)))-1)  << (b))
31
#define MASKEXPAND(mask) BITMASK(1?mask,0?mask)
32
33
/* Macro to set specific bitfields (mask has to be a macro x:y) ! */
34
#define SetBF(mask,value) ((value) << (0?mask))
35
#define GetBF(var,mask) (((unsigned)((var) & MASKEXPAND(mask))) >> (0?mask) )
36
37
#define MaskAndSetBF(var,mask,value) (var)=(((var)&(~MASKEXPAND(mask)) \
38
                                             | SetBF(mask,value)))
39
40
#define DEVICE_BASE(device) (0?NV##_##device)
41
#define DEVICE_SIZE(device) ((1?NV##_##device) - DEVICE_BASE(device)+1)
42
43
/* This is where we will have to have conditional compilation */
44
#define DEVICE_ACCESS(device,reg) \
45
  nvCONTROL[(NV_##device##_##reg)/4]
46
47
#define DEVICE_WRITE(device,reg,value) DEVICE_ACCESS(device,reg)=(value)
48
#define DEVICE_READ(device,reg)        DEVICE_ACCESS(device,reg)
49
#define DEVICE_PRINT(device,reg) \
50
  ErrorF("NV_"#device"_"#reg"=#%08lx\n",DEVICE_ACCESS(device,reg))
51
#define DEVICE_DEF(device,mask,value) \
52
  SetBF(NV_##device##_##mask,NV_##device##_##mask##_##value)
53
#define DEVICE_VALUE(device,mask,value) SetBF(NV_##device##_##mask,value)
54
#define DEVICE_MASK(device,mask) MASKEXPAND(NV_##device##_##mask)
55
56
#define PDAC_Write(reg,value)           DEVICE_WRITE(PDAC,reg,value)
57
#define PDAC_Read(reg)                  DEVICE_READ(PDAC,reg)
58
#define PDAC_Print(reg)                 DEVICE_PRINT(PDAC,reg)
59
#define PDAC_Def(mask,value)            DEVICE_DEF(PDAC,mask,value)
60
#define PDAC_Val(mask,value)            DEVICE_VALUE(PDAC,mask,value)
61
#define PDAC_Mask(mask)                 DEVICE_MASK(PDAC,mask)
62
63
#define PFB_Write(reg,value)            DEVICE_WRITE(PFB,reg,value)
64
#define PFB_Read(reg)                   DEVICE_READ(PFB,reg)
65
#define PFB_Print(reg)                  DEVICE_PRINT(PFB,reg)
66
#define PFB_Def(mask,value)             DEVICE_DEF(PFB,mask,value)
67
#define PFB_Val(mask,value)             DEVICE_VALUE(PFB,mask,value)
68
#define PFB_Mask(mask)                  DEVICE_MASK(PFB,mask)
69
70
#define PRM_Write(reg,value)            DEVICE_WRITE(PRM,reg,value)
71
#define PRM_Read(reg)                   DEVICE_READ(PRM,reg)
72
#define PRM_Print(reg)                  DEVICE_PRINT(PRM,reg)
73
#define PRM_Def(mask,value)             DEVICE_DEF(PRM,mask,value)
74
#define PRM_Val(mask,value)             DEVICE_VALUE(PRM,mask,value)
75
#define PRM_Mask(mask)                  DEVICE_MASK(PRM,mask)
76
77
#define PGRAPH_Write(reg,value)         DEVICE_WRITE(PGRAPH,reg,value)
78
#define PGRAPH_Read(reg)                DEVICE_READ(PGRAPH,reg)
79
#define PGRAPH_Print(reg)               DEVICE_PRINT(PGRAPH,reg)
80
#define PGRAPH_Def(mask,value)          DEVICE_DEF(PGRAPH,mask,value)
81
#define PGRAPH_Val(mask,value)          DEVICE_VALUE(PGRAPH,mask,value)
82
#define PGRAPH_Mask(mask)               DEVICE_MASK(PGRAPH,mask)
83
84
#define PDMA_Write(reg,value)           DEVICE_WRITE(PDMA,reg,value)
85
#define PDMA_Read(reg)                  DEVICE_READ(PDMA,reg)
86
#define PDMA_Print(reg)                 DEVICE_PRINT(PDMA,reg)
87
#define PDMA_Def(mask,value)            DEVICE_DEF(PDMA,mask,value)
88
#define PDMA_Val(mask,value)            DEVICE_VALUE(PDMA,mask,value)
89
#define PDMA_Mask(mask)                 DEVICE_MASK(PDMA,mask)
90
91
#define PTIMER_Write(reg,value)         DEVICE_WRITE(PTIMER,reg,value)
92
#define PTIMER_Read(reg)                DEVICE_READ(PTIMER,reg)
93
#define PTIMER_Print(reg)               DEVICE_PRINT(PTIMER,reg)
94
#define PTIMER_Def(mask,value)          DEVICE_DEF(PTIMER,mask,value)
95
#define PTIMER_Val(mask,value)          DEVICE_VALUE(PTIEMR,mask,value)
96
#define PTIMER_Mask(mask)               DEVICE_MASK(PTIMER,mask)
97
98
#define PEXTDEV_Write(reg,value)         DEVICE_WRITE(PEXTDEV,reg,value)
99
#define PEXTDEV_Read(reg)                DEVICE_READ(PEXTDEV,reg)
100
#define PEXTDEV_Print(reg)               DEVICE_PRINT(PEXTDEV,reg)
101
#define PEXTDEV_Def(mask,value)          DEVICE_DEF(PEXTDEV,mask,value)
102
#define PEXTDEV_Val(mask,value)          DEVICE_VALUE(PEXTDEV,mask,value)
103
#define PEXTDEV_Mask(mask)               DEVICE_MASK(PEXTDEV,mask)
104
105
#define PFIFO_Write(reg,value)          DEVICE_WRITE(PFIFO,reg,value)
106
#define PFIFO_Read(reg)                 DEVICE_READ(PFIFO,reg)
107
#define PFIFO_Print(reg)                DEVICE_PRINT(PFIFO,reg)
108
#define PFIFO_Def(mask,value)           DEVICE_DEF(PFIFO,mask,value)
109
#define PFIFO_Val(mask,value)           DEVICE_VALUE(PFIFO,mask,value)
110
#define PFIFO_Mask(mask)                DEVICE_MASK(PFIFO,mask)
111
112
#define PRAM_Write(reg,value)           DEVICE_WRITE(PRAM,reg,value)
113
#define PRAM_Read(reg)                  DEVICE_READ(PRAM,reg)
114
#define PRAM_Print(reg)                 DEVICE_PRINT(PRAM,reg)
115
#define PRAM_Def(mask,value)            DEVICE_DEF(PRAM,mask,value)
116
#define PRAM_Val(mask,value)            DEVICE_VALUE(PRAM,mask,value)
117
#define PRAM_Mask(mask)                 DEVICE_MASK(PRAM,mask)
118
119
#define PRAMFC_Write(reg,value)         DEVICE_WRITE(PRAMFC,reg,value)
120
#define PRAMFC_Read(reg)                DEVICE_READ(PRAMFC,reg)
121
#define PRAMFC_Print(reg)               DEVICE_PRINT(PRAMFC,reg)
122
#define PRAMFC_Def(mask,value)          DEVICE_DEF(PRAMFC,mask,value)
123
#define PRAMFC_Val(mask,value)          DEVICE_VALUE(PRAMFC,mask,value)
124
#define PRAMFC_Mask(mask)               DEVICE_MASK(PRAMFC,mask)
125
126
#define PMC_Write(reg,value)            DEVICE_WRITE(PMC,reg,value)
127
#define PMC_Read(reg)                   DEVICE_READ(PMC,reg)
128
#define PMC_Print(reg)                  DEVICE_PRINT(PMC,reg)
129
#define PMC_Def(mask,value)             DEVICE_DEF(PMC,mask,value)
130
#define PMC_Val(mask,value)             DEVICE_VALUE(PMC,mask,value)
131
#define PMC_Mask(mask)                  DEVICE_MASK(PMC,mask)
132
133
#define PMC_Write(reg,value)            DEVICE_WRITE(PMC,reg,value)
134
#define PMC_Read(reg)                   DEVICE_READ(PMC,reg)
135
#define PMC_Print(reg)                  DEVICE_PRINT(PMC,reg)
136
#define PMC_Def(mask,value)             DEVICE_DEF(PMC,mask,value)
137
#define PMC_Val(mask,value)             DEVICE_VALUE(PMC,mask,value)
138
#define PMC_Mask(mask)                  DEVICE_MASK(PMC,mask)
139
140
141
#define PBUS_Write(reg,value)         DEVICE_WRITE(PBUS,reg,value)
142
#define PBUS_Read(reg)                DEVICE_READ(PBUS,reg)
143
#define PBUS_Print(reg)               DEVICE_PRINT(PBUS,reg)
144
#define PBUS_Def(mask,value)          DEVICE_DEF(PBUS,mask,value)
145
#define PBUS_Val(mask,value)          DEVICE_VALUE(PBUS,mask,value)
146
#define PBUS_Mask(mask)               DEVICE_MASK(PBUS,mask)
147
148
149
#define PRAMDAC_Write(reg,value)         DEVICE_WRITE(PRAMDAC,reg,value)
150
#define PRAMDAC_Read(reg)                DEVICE_READ(PRAMDAC,reg)
151
#define PRAMDAC_Print(reg)               DEVICE_PRINT(PRAMDAC,reg)
152
#define PRAMDAC_Def(mask,value)          DEVICE_DEF(PRAMDAC,mask,value)
153
#define PRAMDAC_Val(mask,value)          DEVICE_VALUE(PRAMDAC,mask,value)
154
#define PRAMDAC_Mask(mask)               DEVICE_MASK(PRAMDAC,mask)
155
156
157
#define PDAC_ReadExt(reg) \
158
  ((PDAC_Write(INDEX_LO,(NV_PDAC_EXT_##reg) & 0xff)),\
159
  (PDAC_Write(INDEX_HI,((NV_PDAC_EXT_##reg) >> 8) & 0xff)),\
160
  (PDAC_Read(INDEX_DATA)))
161
162
#define PDAC_WriteExt(reg,value)\
163
  ((PDAC_Write(INDEX_LO,(NV_PDAC_EXT_##reg) & 0xff)),\
164
  (PDAC_Write(INDEX_HI,((NV_PDAC_EXT_##reg) >> 8) & 0xff)),\
165
  (PDAC_Write(INDEX_DATA,(value))))
166
167
#define CRTC_Write(index,value) outb((index), 0x3d4); outb(value, 0x3d5)
168
#define CRTC_Read(index) (outb(index, 0x3d4),inb(0x3d5))
169
170
#define PCRTC_Write(index,value) CRTC_Write(NV_PCRTC_##index,value)
171
#define PCRTC_Read(index) CRTC_Read(NV_PCRTC_##index)
172
173
#define PCRTC_Def(mask,value)          DEVICE_DEF(PCRTC,mask,value)
174
#define PCRTC_Val(mask,value)          DEVICE_VALUE(PCRTC,mask,value)
175
#define PCRTC_Mask(mask)               DEVICE_MASK(PCRTC,mask)
176
177
#define SR_Write(index,value) outb(0x3c4,(index));outb(0x3c5,value)
178
#define SR_Read(index) (outb(0x3c4,index),inb(0x3c5))
179
180
extern volatile unsigned  *nvCONTROL;
181
182
typedef enum {NV1,NV3,NV4,NumNVChips} NVChipType;
183
184
NVChipType GetChipType(void);
185
186
#endif
187
188
(-)linux-2.4.26/drivers/video/xbox/riva_hw.c (+2089 lines)
Line 0 Link Here
1
/***************************************************************************\
2
|*                                                                           *|
3
|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
4
|*                                                                           *|
5
|*     NOTICE TO USER:   The source code  is copyrighted under  U.S. and     *|
6
|*     international laws.  Users and possessors of this source code are     *|
7
|*     hereby granted a nonexclusive,  royalty-free copyright license to     *|
8
|*     use this code in individual and commercial software.                  *|
9
|*                                                                           *|
10
|*     Any use of this source code must include,  in the user documenta-     *|
11
|*     tion and  internal comments to the code,  notices to the end user     *|
12
|*     as follows:                                                           *|
13
|*                                                                           *|
14
|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
15
|*                                                                           *|
16
|*     NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY     *|
17
|*     OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"     *|
18
|*     WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPOR-     *|
19
|*     ATION DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,     *|
20
|*     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE-     *|
21
|*     MENT,  AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL     *|
22
|*     NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCI-     *|
23
|*     DENTAL, OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RE-     *|
24
|*     SULTING FROM LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION     *|
25
|*     OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF     *|
26
|*     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.     *|
27
|*                                                                           *|
28
|*     U.S. Government  End  Users.   This source code  is a "commercial     *|
29
|*     item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),     *|
30
|*     consisting  of "commercial  computer  software"  and  "commercial     *|
31
|*     computer  software  documentation,"  as such  terms  are  used in     *|
32
|*     48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Govern-     *|
33
|*     ment only as  a commercial end item.   Consistent with  48 C.F.R.     *|
34
|*     12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),     *|
35
|*     all U.S. Government End Users  acquire the source code  with only     *|
36
|*     those rights set forth herein.                                        *|
37
|*                                                                           *|
38
 \***************************************************************************/
39
40
/*
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
42
 * the documentation restriction above, to merely say that this nVidia's
43
 * copyright and disclaimer should be included with all code derived
44
 * from this source.  -- Jeff Garzik <jgarzik@mandrakesoft.com>, 01/Nov/99 
45
 */
46
47
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c,v 1.8 2000/02/08 17:19:11 dawes Exp $ */
48
49
#include <linux/config.h>
50
#include "riva_hw.h"
51
#include "riva_tbl.h"
52
/*
53
 * This file is an OS-agnostic file used to make RIVA 128 and RIVA TNT
54
 * operate identically (except TNT has more memory and better 3D quality.
55
 */
56
static int nv3Busy
57
(
58
    RIVA_HW_INST *chip
59
)
60
{
61
    return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x000006B0/4] & 0x01));
62
}
63
static int nv4Busy
64
(
65
    RIVA_HW_INST *chip
66
)
67
{
68
    return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x00000700/4] & 0x01));
69
}
70
static int nv10Busy
71
(
72
    RIVA_HW_INST *chip
73
)
74
{
75
    return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x00000700/4] & 0x01));
76
}
77
static void nv3LockUnlock
78
(
79
    RIVA_HW_INST *chip,
80
    int           LockUnlock
81
)
82
{
83
    VGA_WR08(chip->PVIO, 0x3C4, 0x06);
84
    VGA_WR08(chip->PVIO, 0x3C5, LockUnlock ? 0x99 : 0x57);
85
}
86
static void nv4LockUnlock
87
(
88
    RIVA_HW_INST *chip,
89
    int           LockUnlock
90
)
91
{
92
    VGA_WR08(chip->PCIO, 0x3D4, 0x1F);
93
    VGA_WR08(chip->PCIO, 0x3D5, LockUnlock ? 0x99 : 0x57);
94
}
95
static void nv10LockUnlock
96
(
97
    RIVA_HW_INST *chip,
98
    int           LockUnlock
99
)
100
{
101
    VGA_WR08(chip->PCIO, 0x3D4, 0x1F);
102
    VGA_WR08(chip->PCIO, 0x3D5, LockUnlock ? 0x99 : 0x57);
103
}
104
105
static int ShowHideCursor
106
(
107
    RIVA_HW_INST *chip,
108
    int           ShowHide
109
)
110
{
111
    int current;
112
    current                     =  chip->CurrentState->cursor1;
113
    chip->CurrentState->cursor1 = (chip->CurrentState->cursor1 & 0xFE) |
114
	                          (ShowHide & 0x01);
115
    VGA_WR08(chip->PCIO, 0x3D4, 0x31);
116
    VGA_WR08(chip->PCIO, 0x3D5, chip->CurrentState->cursor1);
117
    return (current & 0x01);
118
}
119
120
/****************************************************************************\
121
*                                                                            *
122
* The video arbitration routines calculate some "magic" numbers.  Fixes      *
123
* the snow seen when accessing the framebuffer without it.                   *
124
* It just works (I hope).                                                    *
125
*                                                                            *
126
\****************************************************************************/
127
128
#define DEFAULT_GR_LWM 100
129
#define DEFAULT_VID_LWM 100
130
#define DEFAULT_GR_BURST_SIZE 256
131
#define DEFAULT_VID_BURST_SIZE 128
132
#define VIDEO		0
133
#define GRAPHICS	1
134
#define MPORT		2
135
#define ENGINE		3
136
#define GFIFO_SIZE	320
137
#define GFIFO_SIZE_128	256
138
#define MFIFO_SIZE	120
139
#define VFIFO_SIZE	256
140
#define	ABS(a)	(a>0?a:-a)
141
typedef struct {
142
  int gdrain_rate;
143
  int vdrain_rate;
144
  int mdrain_rate;
145
  int gburst_size;
146
  int vburst_size;
147
  char vid_en;
148
  char gr_en;
149
  int wcmocc, wcgocc, wcvocc, wcvlwm, wcglwm;
150
  int by_gfacc;
151
  char vid_only_once;
152
  char gr_only_once;
153
  char first_vacc;
154
  char first_gacc;
155
  char first_macc;
156
  int vocc;
157
  int gocc;
158
  int mocc;
159
  char cur;
160
  char engine_en;
161
  char converged;
162
  int priority;
163
} nv3_arb_info;
164
typedef struct {
165
  int graphics_lwm;
166
  int video_lwm;
167
  int graphics_burst_size;
168
  int video_burst_size;
169
  int graphics_hi_priority;
170
  int media_hi_priority;
171
  int rtl_values;
172
  int valid;
173
} nv3_fifo_info;
174
typedef struct {
175
  char pix_bpp;
176
  char enable_video;
177
  char gr_during_vid;
178
  char enable_mp;
179
  int memory_width;
180
  int video_scale;
181
  int pclk_khz;
182
  int mclk_khz;
183
  int mem_page_miss;
184
  int mem_latency;
185
  char mem_aligned;
186
} nv3_sim_state;
187
typedef struct {
188
  int graphics_lwm;
189
  int video_lwm;
190
  int graphics_burst_size;
191
  int video_burst_size;
192
  int valid;
193
} nv4_fifo_info;
194
typedef struct {
195
  int pclk_khz;
196
  int mclk_khz;
197
  int nvclk_khz;
198
  char mem_page_miss;
199
  char mem_latency;
200
  int memory_width;
201
  char enable_video;
202
  char gr_during_vid;
203
  char pix_bpp;
204
  char mem_aligned;
205
  char enable_mp;
206
} nv4_sim_state;
207
typedef struct {
208
  int graphics_lwm;
209
  int video_lwm;
210
  int graphics_burst_size;
211
  int video_burst_size;
212
  int valid;
213
} nv10_fifo_info;
214
typedef struct {
215
  int pclk_khz;
216
  int mclk_khz;
217
  int nvclk_khz;
218
  char mem_page_miss;
219
  char mem_latency;
220
  int memory_type;
221
  int memory_width;
222
  char enable_video;
223
  char gr_during_vid;
224
  char pix_bpp;
225
  char mem_aligned;
226
  char enable_mp;
227
} nv10_sim_state;
228
static int nv3_iterate(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_arb_info *ainfo)
229
{
230
    int iter = 0;
231
    int tmp;
232
    int vfsize, mfsize, gfsize;
233
    int mburst_size = 32;
234
    int mmisses, gmisses, vmisses;
235
    int misses;
236
    int vlwm, glwm, mlwm;
237
    int last, next, cur;
238
    int max_gfsize ;
239
    long ns;
240
241
    vlwm = 0;
242
    glwm = 0;
243
    mlwm = 0;
244
    vfsize = 0;
245
    gfsize = 0;
246
    cur = ainfo->cur;
247
    mmisses = 2;
248
    gmisses = 2;
249
    vmisses = 2;
250
    if (ainfo->gburst_size == 128) max_gfsize = GFIFO_SIZE_128;
251
    else  max_gfsize = GFIFO_SIZE;
252
    max_gfsize = GFIFO_SIZE;
253
    while (1)
254
    {
255
        if (ainfo->vid_en)
256
        {
257
            if (ainfo->wcvocc > ainfo->vocc) ainfo->wcvocc = ainfo->vocc;
258
            if (ainfo->wcvlwm > vlwm) ainfo->wcvlwm = vlwm ;
259
            ns = 1000000 * ainfo->vburst_size/(state->memory_width/8)/state->mclk_khz;
260
            vfsize = ns * ainfo->vdrain_rate / 1000000;
261
            vfsize =  ainfo->wcvlwm - ainfo->vburst_size + vfsize;
262
        }
263
        if (state->enable_mp)
264
        {
265
            if (ainfo->wcmocc > ainfo->mocc) ainfo->wcmocc = ainfo->mocc;
266
        }
267
        if (ainfo->gr_en)
268
        {
269
            if (ainfo->wcglwm > glwm) ainfo->wcglwm = glwm ;
270
            if (ainfo->wcgocc > ainfo->gocc) ainfo->wcgocc = ainfo->gocc;
271
            ns = 1000000 * (ainfo->gburst_size/(state->memory_width/8))/state->mclk_khz;
272
            gfsize = (ns * (long) ainfo->gdrain_rate)/1000000;
273
            gfsize = ainfo->wcglwm - ainfo->gburst_size + gfsize;
274
        }
275
        mfsize = 0;
276
        if (!state->gr_during_vid && ainfo->vid_en)
277
            if (ainfo->vid_en && (ainfo->vocc < 0) && !ainfo->vid_only_once)
278
                next = VIDEO;
279
            else if (ainfo->mocc < 0)
280
                next = MPORT;
281
            else if (ainfo->gocc< ainfo->by_gfacc)
282
                next = GRAPHICS;
283
            else return (0);
284
        else switch (ainfo->priority)
285
            {
286
                case VIDEO:
287
                    if (ainfo->vid_en && ainfo->vocc<0 && !ainfo->vid_only_once)
288
                        next = VIDEO;
289
                    else if (ainfo->gr_en && ainfo->gocc<0 && !ainfo->gr_only_once)
290
                        next = GRAPHICS;
291
                    else if (ainfo->mocc<0)
292
                        next = MPORT;
293
                    else    return (0);
294
                    break;
295
                case GRAPHICS:
296
                    if (ainfo->gr_en && ainfo->gocc<0 && !ainfo->gr_only_once)
297
                        next = GRAPHICS;
298
                    else if (ainfo->vid_en && ainfo->vocc<0 && !ainfo->vid_only_once)
299
                        next = VIDEO;
300
                    else if (ainfo->mocc<0)
301
                        next = MPORT;
302
                    else    return (0);
303
                    break;
304
                default:
305
                    if (ainfo->mocc<0)
306
                        next = MPORT;
307
                    else if (ainfo->gr_en && ainfo->gocc<0 && !ainfo->gr_only_once)
308
                        next = GRAPHICS;
309
                    else if (ainfo->vid_en && ainfo->vocc<0 && !ainfo->vid_only_once)
310
                        next = VIDEO;
311
                    else    return (0);
312
                    break;
313
            }
314
        last = cur;
315
        cur = next;
316
        iter++;
317
        switch (cur)
318
        {
319
            case VIDEO:
320
                if (last==cur)    misses = 0;
321
                else if (ainfo->first_vacc)   misses = vmisses;
322
                else    misses = 1;
323
                ainfo->first_vacc = 0;
324
                if (last!=cur)
325
                {
326
                    ns =  1000000 * (vmisses*state->mem_page_miss + state->mem_latency)/state->mclk_khz; 
327
                    vlwm = ns * ainfo->vdrain_rate/ 1000000;
328
                    vlwm = ainfo->vocc - vlwm;
329
                }
330
                ns = 1000000*(misses*state->mem_page_miss + ainfo->vburst_size)/(state->memory_width/8)/state->mclk_khz;
331
                ainfo->vocc = ainfo->vocc + ainfo->vburst_size - ns*ainfo->vdrain_rate/1000000;
332
                ainfo->gocc = ainfo->gocc - ns*ainfo->gdrain_rate/1000000;
333
                ainfo->mocc = ainfo->mocc - ns*ainfo->mdrain_rate/1000000;
334
                break;
335
            case GRAPHICS:
336
                if (last==cur)    misses = 0;
337
                else if (ainfo->first_gacc)   misses = gmisses;
338
                else    misses = 1;
339
                ainfo->first_gacc = 0;
340
                if (last!=cur)
341
                {
342
                    ns = 1000000*(gmisses*state->mem_page_miss + state->mem_latency)/state->mclk_khz ;
343
                    glwm = ns * ainfo->gdrain_rate/1000000;
344
                    glwm = ainfo->gocc - glwm;
345
                }
346
                ns = 1000000*(misses*state->mem_page_miss + ainfo->gburst_size/(state->memory_width/8))/state->mclk_khz;
347
                ainfo->vocc = ainfo->vocc + 0 - ns*ainfo->vdrain_rate/1000000;
348
                ainfo->gocc = ainfo->gocc + ainfo->gburst_size - ns*ainfo->gdrain_rate/1000000;
349
                ainfo->mocc = ainfo->mocc + 0 - ns*ainfo->mdrain_rate/1000000;
350
                break;
351
            default:
352
                if (last==cur)    misses = 0;
353
                else if (ainfo->first_macc)   misses = mmisses;
354
                else    misses = 1;
355
                ainfo->first_macc = 0;
356
                ns = 1000000*(misses*state->mem_page_miss + mburst_size/(state->memory_width/8))/state->mclk_khz;
357
                ainfo->vocc = ainfo->vocc + 0 - ns*ainfo->vdrain_rate/1000000;
358
                ainfo->gocc = ainfo->gocc + 0 - ns*ainfo->gdrain_rate/1000000;
359
                ainfo->mocc = ainfo->mocc + mburst_size - ns*ainfo->mdrain_rate/1000000;
360
                break;
361
        }
362
        if (iter>100)
363
        {
364
            ainfo->converged = 0;
365
            return (1);
366
        }
367
        ns = 1000000*ainfo->gburst_size/(state->memory_width/8)/state->mclk_khz;
368
        tmp = ns * ainfo->gdrain_rate/1000000;
369
        if (ABS(ainfo->gburst_size) + ((ABS(ainfo->wcglwm) + 16 ) & ~0x7) - tmp > max_gfsize)
370
        {
371
            ainfo->converged = 0;
372
            return (1);
373
        }
374
        ns = 1000000*ainfo->vburst_size/(state->memory_width/8)/state->mclk_khz;
375
        tmp = ns * ainfo->vdrain_rate/1000000;
376
        if (ABS(ainfo->vburst_size) + (ABS(ainfo->wcvlwm + 32) & ~0xf)  - tmp> VFIFO_SIZE)
377
        {
378
            ainfo->converged = 0;
379
            return (1);
380
        }
381
        if (ABS(ainfo->gocc) > max_gfsize)
382
        {
383
            ainfo->converged = 0;
384
            return (1);
385
        }
386
        if (ABS(ainfo->vocc) > VFIFO_SIZE)
387
        {
388
            ainfo->converged = 0;
389
            return (1);
390
        }
391
        if (ABS(ainfo->mocc) > MFIFO_SIZE)
392
        {
393
            ainfo->converged = 0;
394
            return (1);
395
        }
396
        if (ABS(vfsize) > VFIFO_SIZE)
397
        {
398
            ainfo->converged = 0;
399
            return (1);
400
        }
401
        if (ABS(gfsize) > max_gfsize)
402
        {
403
            ainfo->converged = 0;
404
            return (1);
405
        }
406
        if (ABS(mfsize) > MFIFO_SIZE)
407
        {
408
            ainfo->converged = 0;
409
            return (1);
410
        }
411
    }
412
}
413
static char nv3_arb(nv3_fifo_info * res_info, nv3_sim_state * state,  nv3_arb_info *ainfo) 
414
{
415
    long ens, vns, mns, gns;
416
    int mmisses, gmisses, vmisses, eburst_size, mburst_size;
417
    int refresh_cycle;
418
419
    refresh_cycle = 0;
420
    refresh_cycle = 2*(state->mclk_khz/state->pclk_khz) + 5;
421
    mmisses = 2;
422
    if (state->mem_aligned) gmisses = 2;
423
    else    gmisses = 3;
424
    vmisses = 2;
425
    eburst_size = state->memory_width * 1;
426
    mburst_size = 32;
427
    gns = 1000000 * (gmisses*state->mem_page_miss + state->mem_latency)/state->mclk_khz;
428
    ainfo->by_gfacc = gns*ainfo->gdrain_rate/1000000;
429
    ainfo->wcmocc = 0;
430
    ainfo->wcgocc = 0;
431
    ainfo->wcvocc = 0;
432
    ainfo->wcvlwm = 0;
433
    ainfo->wcglwm = 0;
434
    ainfo->engine_en = 1;
435
    ainfo->converged = 1;
436
    if (ainfo->engine_en)
437
    {
438
        ens =  1000000*(state->mem_page_miss + eburst_size/(state->memory_width/8) +refresh_cycle)/state->mclk_khz;
439
        ainfo->mocc = state->enable_mp ? 0-ens*ainfo->mdrain_rate/1000000 : 0;
440
        ainfo->vocc = ainfo->vid_en ? 0-ens*ainfo->vdrain_rate/1000000 : 0;
441
        ainfo->gocc = ainfo->gr_en ? 0-ens*ainfo->gdrain_rate/1000000 : 0;
442
        ainfo->cur = ENGINE;
443
        ainfo->first_vacc = 1;
444
        ainfo->first_gacc = 1;
445
        ainfo->first_macc = 1;
446
        nv3_iterate(res_info, state,ainfo);
447
    }
448
    if (state->enable_mp)
449
    {
450
        mns = 1000000 * (mmisses*state->mem_page_miss + mburst_size/(state->memory_width/8) + refresh_cycle)/state->mclk_khz;
451
        ainfo->mocc = state->enable_mp ? 0 : mburst_size - mns*ainfo->mdrain_rate/1000000;
452
        ainfo->vocc = ainfo->vid_en ? 0 : 0- mns*ainfo->vdrain_rate/1000000;
453
        ainfo->gocc = ainfo->gr_en ? 0: 0- mns*ainfo->gdrain_rate/1000000;
454
        ainfo->cur = MPORT;
455
        ainfo->first_vacc = 1;
456
        ainfo->first_gacc = 1;
457
        ainfo->first_macc = 0;
458
        nv3_iterate(res_info, state,ainfo);
459
    }
460
    if (ainfo->gr_en)
461
    {
462
        ainfo->first_vacc = 1;
463
        ainfo->first_gacc = 0;
464
        ainfo->first_macc = 1;
465
        gns = 1000000*(gmisses*state->mem_page_miss + ainfo->gburst_size/(state->memory_width/8) + refresh_cycle)/state->mclk_khz;
466
        ainfo->gocc = ainfo->gburst_size - gns*ainfo->gdrain_rate/1000000;
467
        ainfo->vocc = ainfo->vid_en? 0-gns*ainfo->vdrain_rate/1000000 : 0;
468
        ainfo->mocc = state->enable_mp ?  0-gns*ainfo->mdrain_rate/1000000: 0;
469
        ainfo->cur = GRAPHICS;
470
        nv3_iterate(res_info, state,ainfo);
471
    }
472
    if (ainfo->vid_en)
473
    {
474
        ainfo->first_vacc = 0;
475
        ainfo->first_gacc = 1;
476
        ainfo->first_macc = 1;
477
        vns = 1000000*(vmisses*state->mem_page_miss + ainfo->vburst_size/(state->memory_width/8) + refresh_cycle)/state->mclk_khz;
478
        ainfo->vocc = ainfo->vburst_size - vns*ainfo->vdrain_rate/1000000;
479
        ainfo->gocc = ainfo->gr_en? (0-vns*ainfo->gdrain_rate/1000000) : 0;
480
        ainfo->mocc = state->enable_mp? 0-vns*ainfo->mdrain_rate/1000000 :0 ;
481
        ainfo->cur = VIDEO;
482
        nv3_iterate(res_info, state, ainfo);
483
    }
484
    if (ainfo->converged)
485
    {
486
        res_info->graphics_lwm = (int)ABS(ainfo->wcglwm) + 16;
487
        res_info->video_lwm = (int)ABS(ainfo->wcvlwm) + 32;
488
        res_info->graphics_burst_size = ainfo->gburst_size;
489
        res_info->video_burst_size = ainfo->vburst_size;
490
        res_info->graphics_hi_priority = (ainfo->priority == GRAPHICS);
491
        res_info->media_hi_priority = (ainfo->priority == MPORT);
492
        if (res_info->video_lwm > 160)
493
        {
494
            res_info->graphics_lwm = 256;
495
            res_info->video_lwm = 128;
496
            res_info->graphics_burst_size = 64;
497
            res_info->video_burst_size = 64;
498
            res_info->graphics_hi_priority = 0;
499
            res_info->media_hi_priority = 0;
500
            ainfo->converged = 0;
501
            return (0);
502
        }
503
        if (res_info->video_lwm > 128)
504
        {
505
            res_info->video_lwm = 128;
506
        }
507
        return (1);
508
    }
509
    else
510
    {
511
        res_info->graphics_lwm = 256;
512
        res_info->video_lwm = 128;
513
        res_info->graphics_burst_size = 64;
514
        res_info->video_burst_size = 64;
515
        res_info->graphics_hi_priority = 0;
516
        res_info->media_hi_priority = 0;
517
        return (0);
518
    }
519
}
520
static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_arb_info *ainfo)
521
{
522
    int done, g,v, p;
523
    
524
    done = 0;
525
    for (p=0; p < 2; p++)
526
    {
527
        for (g=128 ; g > 32; g= g>> 1)
528
        {
529
            for (v=128; v >=32; v = v>> 1)
530
            {
531
                ainfo->priority = p;
532
                ainfo->gburst_size = g;     
533
                ainfo->vburst_size = v;
534
                done = nv3_arb(res_info, state,ainfo);
535
                if (done && (g==128))
536
                    if ((res_info->graphics_lwm + g) > 256)
537
                        done = 0;
538
                if (done)
539
                    goto Done;
540
            }
541
        }
542
    }
543
544
 Done:
545
    return done;
546
}
547
static void nv3CalcArbitration 
548
(
549
    nv3_fifo_info * res_info,
550
    nv3_sim_state * state
551
)
552
{
553
    nv3_fifo_info save_info;
554
    nv3_arb_info ainfo;
555
    char   res_gr, res_vid;
556
557
    ainfo.gr_en = 1;
558
    ainfo.vid_en = state->enable_video;
559
    ainfo.vid_only_once = 0;
560
    ainfo.gr_only_once = 0;
561
    ainfo.gdrain_rate = (int) state->pclk_khz * (state->pix_bpp/8);
562
    ainfo.vdrain_rate = (int) state->pclk_khz * 2;
563
    if (state->video_scale != 0)
564
        ainfo.vdrain_rate = ainfo.vdrain_rate/state->video_scale;
565
    ainfo.mdrain_rate = 33000;
566
    res_info->rtl_values = 0;
567
    if (!state->gr_during_vid && state->enable_video)
568
    {
569
        ainfo.gr_only_once = 1;
570
        ainfo.gr_en = 1;
571
        ainfo.gdrain_rate = 0;
572
        res_vid = nv3_get_param(res_info, state,  &ainfo);
573
        res_vid = ainfo.converged;
574
        save_info.video_lwm = res_info->video_lwm;
575
        save_info.video_burst_size = res_info->video_burst_size;
576
        ainfo.vid_en = 1;
577
        ainfo.vid_only_once = 1;
578
        ainfo.gr_en = 1;
579
        ainfo.gdrain_rate = (int) state->pclk_khz * (state->pix_bpp/8);
580
        ainfo.vdrain_rate = 0;
581
        res_gr = nv3_get_param(res_info, state,  &ainfo);
582
        res_gr = ainfo.converged;
583
        res_info->video_lwm = save_info.video_lwm;
584
        res_info->video_burst_size = save_info.video_burst_size;
585
        res_info->valid = res_gr & res_vid;
586
    }
587
    else
588
    {
589
        if (!ainfo.gr_en) ainfo.gdrain_rate = 0;
590
        if (!ainfo.vid_en) ainfo.vdrain_rate = 0;
591
        res_gr = nv3_get_param(res_info, state,  &ainfo);
592
        res_info->valid = ainfo.converged;
593
    }
594
}
595
static void nv3UpdateArbitrationSettings
596
(
597
    unsigned      VClk, 
598
    unsigned      pixelDepth, 
599
    unsigned     *burst,
600
    unsigned     *lwm,
601
    RIVA_HW_INST *chip
602
)
603
{
604
    nv3_fifo_info fifo_data;
605
    nv3_sim_state sim_data;
606
    unsigned int M, N, P, pll, MClk;
607
    
608
    pll = chip->PRAMDAC[0x00000504/4];
609
    M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
610
    MClk = (N * chip->CrystalFreqKHz / M) >> P;
611
    sim_data.pix_bpp        = (char)pixelDepth;
612
    sim_data.enable_video   = 0;
613
    sim_data.enable_mp      = 0;
614
    sim_data.video_scale    = 1;
615
    sim_data.memory_width   = (chip->PEXTDEV[0x00000000/4] & 0x10) ? 128 : 64;
616
    sim_data.memory_width   = 128;
617
618
    sim_data.mem_latency    = 9;
619
    sim_data.mem_aligned    = 1;
620
    sim_data.mem_page_miss  = 11;
621
    sim_data.gr_during_vid  = 0;
622
    sim_data.pclk_khz       = VClk;
623
    sim_data.mclk_khz       = MClk;
624
    nv3CalcArbitration(&fifo_data, &sim_data);
625
    if (fifo_data.valid)
626
    {
627
        int  b = fifo_data.graphics_burst_size >> 4;
628
        *burst = 0;
629
        while (b >>= 1) (*burst)++;
630
        *lwm   = fifo_data.graphics_lwm >> 3;
631
    }
632
    else
633
    {
634
        *lwm   = 0x24;
635
        *burst = 0x2;
636
    }
637
}
638
static void nv4CalcArbitration 
639
(
640
    nv4_fifo_info *fifo,
641
    nv4_sim_state *arb
642
)
643
{
644
    int data, pagemiss, cas,width, video_enable, color_key_enable, bpp, align;
645
    int nvclks, mclks, pclks, vpagemiss, crtpagemiss, vbs;
646
    int found, mclk_extra, mclk_loop, cbs, m1, p1;
647
    int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
648
    int us_m, us_n, us_p, video_drain_rate, crtc_drain_rate;
649
    int vpm_us, us_video, vlwm, video_fill_us, cpm_us, us_crt,clwm;
650
    int craw, vraw;
651
652
    fifo->valid = 1;
653
    pclk_freq = arb->pclk_khz;
654
    mclk_freq = arb->mclk_khz;
655
    nvclk_freq = arb->nvclk_khz;
656
    pagemiss = arb->mem_page_miss;
657
    cas = arb->mem_latency;
658
    width = arb->memory_width >> 6;
659
    video_enable = arb->enable_video;
660
    color_key_enable = arb->gr_during_vid;
661
    bpp = arb->pix_bpp;
662
    align = arb->mem_aligned;
663
    mp_enable = arb->enable_mp;
664
    clwm = 0;
665
    vlwm = 0;
666
    cbs = 128;
667
    pclks = 2;
668
    nvclks = 2;
669
    nvclks += 2;
670
    nvclks += 1;
671
    mclks = 5;
672
    mclks += 3;
673
    mclks += 1;
674
    mclks += cas;
675
    mclks += 1;
676
    mclks += 1;
677
    mclks += 1;
678
    mclks += 1;
679
    mclk_extra = 3;
680
    nvclks += 2;
681
    nvclks += 1;
682
    nvclks += 1;
683
    nvclks += 1;
684
    if (mp_enable)
685
        mclks+=4;
686
    nvclks += 0;
687
    pclks += 0;
688
    found = 0;
689
    vbs = 0;
690
    while (found != 1)
691
    {
692
        fifo->valid = 1;
693
        found = 1;
694
        mclk_loop = mclks+mclk_extra;
695
        us_m = mclk_loop *1000*1000 / mclk_freq;
696
        us_n = nvclks*1000*1000 / nvclk_freq;
697
        us_p = nvclks*1000*1000 / pclk_freq;
698
        if (video_enable)
699
        {
700
            video_drain_rate = pclk_freq * 2;
701
            crtc_drain_rate = pclk_freq * bpp/8;
702
            vpagemiss = 2;
703
            vpagemiss += 1;
704
            crtpagemiss = 2;
705
            vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
706
            if (nvclk_freq * 2 > mclk_freq * width)
707
                video_fill_us = cbs*1000*1000 / 16 / nvclk_freq ;
708
            else
709
                video_fill_us = cbs*1000*1000 / (8 * width) / mclk_freq;
710
            us_video = vpm_us + us_m + us_n + us_p + video_fill_us;
711
            vlwm = us_video * video_drain_rate/(1000*1000);
712
            vlwm++;
713
            vbs = 128;
714
            if (vlwm > 128) vbs = 64;
715
            if (vlwm > (256-64)) vbs = 32;
716
            if (nvclk_freq * 2 > mclk_freq * width)
717
                video_fill_us = vbs *1000*1000/ 16 / nvclk_freq ;
718
            else
719
                video_fill_us = vbs*1000*1000 / (8 * width) / mclk_freq;
720
            cpm_us = crtpagemiss  * pagemiss *1000*1000/ mclk_freq;
721
            us_crt =
722
            us_video
723
            +video_fill_us
724
            +cpm_us
725
            +us_m + us_n +us_p
726
            ;
727
            clwm = us_crt * crtc_drain_rate/(1000*1000);
728
            clwm++;
729
        }
730
        else
731
        {
732
            crtc_drain_rate = pclk_freq * bpp/8;
733
            crtpagemiss = 2;
734
            crtpagemiss += 1;
735
            cpm_us = crtpagemiss  * pagemiss *1000*1000/ mclk_freq;
736
            us_crt =  cpm_us + us_m + us_n + us_p ;
737
            clwm = us_crt * crtc_drain_rate/(1000*1000);
738
            clwm++;
739
        }
740
        m1 = clwm + cbs - 512;
741
        p1 = m1 * pclk_freq / mclk_freq;
742
        p1 = p1 * bpp / 8;
743
        if ((p1 < m1) && (m1 > 0))
744
        {
745
            fifo->valid = 0;
746
            found = 0;
747
            if (mclk_extra ==0)   found = 1;
748
            mclk_extra--;
749
        }
750
        else if (video_enable)
751
        {
752
            if ((clwm > 511) || (vlwm > 255))
753
            {
754
                fifo->valid = 0;
755
                found = 0;
756
                if (mclk_extra ==0)   found = 1;
757
                mclk_extra--;
758
            }
759
        }
760
        else
761
        {
762
            if (clwm > 519)
763
            {
764
                fifo->valid = 0;
765
                found = 0;
766
                if (mclk_extra ==0)   found = 1;
767
                mclk_extra--;
768
            }
769
        }
770
        craw = clwm;
771
        vraw = vlwm;
772
        if (clwm < 384) clwm = 384;
773
        if (vlwm < 128) vlwm = 128;
774
        data = (int)(clwm);
775
        fifo->graphics_lwm = data;
776
        fifo->graphics_burst_size = 128;
777
        data = (int)((vlwm+15));
778
        fifo->video_lwm = data;
779
        fifo->video_burst_size = vbs;
780
    }
781
}
782
static void nv4UpdateArbitrationSettings
783
(
784
    unsigned      VClk, 
785
    unsigned      pixelDepth, 
786
    unsigned     *burst,
787
    unsigned     *lwm,
788
    RIVA_HW_INST *chip
789
)
790
{
791
    nv4_fifo_info fifo_data;
792
    nv4_sim_state sim_data;
793
    unsigned int M, N, P, pll, MClk, NVClk, cfg1;
794
795
    pll = chip->PRAMDAC[0x00000504/4];
796
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
797
    MClk  = (N * chip->CrystalFreqKHz / M) >> P;
798
    pll = chip->PRAMDAC[0x00000500/4];
799
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
800
    NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
801
    cfg1 = chip->PFB[0x00000204/4];
802
    sim_data.pix_bpp        = (char)pixelDepth;
803
    sim_data.enable_video   = 0;
804
    sim_data.enable_mp      = 0;
805
    sim_data.memory_width   = (chip->PEXTDEV[0x00000000/4] & 0x10) ? 128 : 64;
806
    sim_data.mem_latency    = (char)cfg1 & 0x0F;
807
    sim_data.mem_aligned    = 1;
808
    sim_data.mem_page_miss  = (char)(((cfg1 >> 4) &0x0F) + ((cfg1 >> 31) & 0x01));
809
    sim_data.gr_during_vid  = 0;
810
    sim_data.pclk_khz       = VClk;
811
    sim_data.mclk_khz       = MClk;
812
    sim_data.nvclk_khz      = NVClk;
813
    nv4CalcArbitration(&fifo_data, &sim_data);
814
    if (fifo_data.valid)
815
    {
816
        int  b = fifo_data.graphics_burst_size >> 4;
817
        *burst = 0;
818
        while (b >>= 1) (*burst)++;
819
        *lwm   = fifo_data.graphics_lwm >> 3;
820
    }
821
}
822
static void nv10CalcArbitration 
823
(
824
    nv10_fifo_info *fifo,
825
    nv10_sim_state *arb
826
)
827
{
828
    int data, pagemiss, cas,width, video_enable, color_key_enable, bpp, align;
829
    int nvclks, mclks, pclks, vpagemiss, crtpagemiss, vbs;
830
    int nvclk_fill, us_extra;
831
    int found, mclk_extra, mclk_loop, cbs, m1;
832
    int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
833
    int us_m, us_m_min, us_n, us_p, video_drain_rate, crtc_drain_rate;
834
    int vus_m, vus_n, vus_p;
835
    int vpm_us, us_video, vlwm, cpm_us, us_crt,clwm;
836
    int clwm_rnd_down;
837
    int craw, m2us, us_pipe, us_pipe_min, vus_pipe, p1clk, p2;
838
    int pclks_2_top_fifo, min_mclk_extra;
839
    int us_min_mclk_extra;
840
841
    fifo->valid = 1;
842
    pclk_freq = arb->pclk_khz; /* freq in KHz */
843
    mclk_freq = arb->mclk_khz;
844
    nvclk_freq = arb->nvclk_khz;
845
    pagemiss = arb->mem_page_miss;
846
    cas = arb->mem_latency;
847
    width = arb->memory_width/64;
848
    video_enable = arb->enable_video;
849
    color_key_enable = arb->gr_during_vid;
850
    bpp = arb->pix_bpp;
851
    align = arb->mem_aligned;
852
    mp_enable = arb->enable_mp;
853
    clwm = 0;
854
    vlwm = 1024;
855
856
    cbs = 512;
857
    vbs = 512;
858
859
    pclks = 4; /* lwm detect. */
860
861
    nvclks = 3; /* lwm -> sync. */
862
    nvclks += 2; /* fbi bus cycles (1 req + 1 busy) */
863
864
    mclks  = 1;   /* 2 edge sync.  may be very close to edge so just put one. */
865
866
    mclks += 1;   /* arb_hp_req */
867
    mclks += 5;   /* ap_hp_req   tiling pipeline */
868
869
    mclks += 2;    /* tc_req     latency fifo */
870
    mclks += 2;    /* fb_cas_n_  memory request to fbio block */
871
    mclks += 7;    /* sm_d_rdv   data returned from fbio block */
872
873
    /* fb.rd.d.Put_gc   need to accumulate 256 bits for read */
874
    if (arb->memory_type == 0)
875
      if (arb->memory_width == 64) /* 64 bit bus */
876
        mclks += 4;
877
      else
878
        mclks += 2;
879
    else
880
      if (arb->memory_width == 64) /* 64 bit bus */
881
        mclks += 2;
882
      else
883
        mclks += 1;
884
885
    if ((!video_enable) && (arb->memory_width == 128))
886
    {  
887
      mclk_extra = (bpp == 32) ? 31 : 42; /* Margin of error */
888
      min_mclk_extra = 17;
889
    }
890
    else
891
    {
892
      mclk_extra = (bpp == 32) ? 8 : 4; /* Margin of error */
893
      /* mclk_extra = 4; */ /* Margin of error */
894
      min_mclk_extra = 18;
895
    }
896
897
    nvclks += 1; /* 2 edge sync.  may be very close to edge so just put one. */
898
    nvclks += 1; /* fbi_d_rdv_n */
899
    nvclks += 1; /* Fbi_d_rdata */
900
    nvclks += 1; /* crtfifo load */
901
902
    if(mp_enable)
903
      mclks+=4; /* Mp can get in with a burst of 8. */
904
    /* Extra clocks determined by heuristics */
905
906
    nvclks += 0;
907
    pclks += 0;
908
    found = 0;
909
    while(found != 1) {
910
      fifo->valid = 1;
911
      found = 1;
912
      mclk_loop = mclks+mclk_extra;
913
      us_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
914
      us_m_min = mclks * 1000*1000 / mclk_freq; /* Minimum Mclk latency in us */
915
      us_min_mclk_extra = min_mclk_extra *1000*1000 / mclk_freq;
916
      us_n = nvclks*1000*1000 / nvclk_freq;/* nvclk latency in us */
917
      us_p = pclks*1000*1000 / pclk_freq;/* nvclk latency in us */
918
      us_pipe = us_m + us_n + us_p;
919
      us_pipe_min = us_m_min + us_n + us_p;
920
      us_extra = 0;
921
922
      vus_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
923
      vus_n = (4)*1000*1000 / nvclk_freq;/* nvclk latency in us */
924
      vus_p = 0*1000*1000 / pclk_freq;/* pclk latency in us */
925
      vus_pipe = vus_m + vus_n + vus_p;
926
927
      if(video_enable) {
928
        video_drain_rate = pclk_freq * 4; /* MB/s */
929
        crtc_drain_rate = pclk_freq * bpp/8; /* MB/s */
930
931
        vpagemiss = 1; /* self generating page miss */
932
        vpagemiss += 1; /* One higher priority before */
933
934
        crtpagemiss = 2; /* self generating page miss */
935
        if(mp_enable)
936
            crtpagemiss += 1; /* if MA0 conflict */
937
938
        vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
939
940
        us_video = vpm_us + vus_m; /* Video has separate read return path */
941
942
        cpm_us = crtpagemiss  * pagemiss *1000*1000/ mclk_freq;
943
        us_crt =
944
          us_video  /* Wait for video */
945
          +cpm_us /* CRT Page miss */
946
          +us_m + us_n +us_p /* other latency */
947
          ;
948
949
        clwm = us_crt * crtc_drain_rate/(1000*1000);
950
        clwm++; /* fixed point <= float_point - 1.  Fixes that */
951
      } else {
952
        crtc_drain_rate = pclk_freq * bpp/8; /* bpp * pclk/8 */
953
954
        crtpagemiss = 1; /* self generating page miss */
955
        crtpagemiss += 1; /* MA0 page miss */
956
        if(mp_enable)
957
            crtpagemiss += 1; /* if MA0 conflict */
958
        cpm_us = crtpagemiss  * pagemiss *1000*1000/ mclk_freq;
959
        us_crt =  cpm_us + us_m + us_n + us_p ;
960
        clwm = us_crt * crtc_drain_rate/(1000*1000);
961
        clwm++; /* fixed point <= float_point - 1.  Fixes that */
962
963
  /*
964
          //
965
          // Another concern, only for high pclks so don't do this
966
          // with video:
967
          // What happens if the latency to fetch the cbs is so large that
968
          // fifo empties.  In that case we need to have an alternate clwm value
969
          // based off the total burst fetch
970
          //
971
          us_crt = (cbs * 1000 * 1000)/ (8*width)/mclk_freq ;
972
          us_crt = us_crt + us_m + us_n + us_p + (4 * 1000 * 1000)/mclk_freq;
973
          clwm_mt = us_crt * crtc_drain_rate/(1000*1000);
974
          clwm_mt ++;
975
          if(clwm_mt > clwm)
976
              clwm = clwm_mt;
977
  */
978
          /* Finally, a heuristic check when width == 64 bits */
979
          if(width == 1){
980
              nvclk_fill = nvclk_freq * 8;
981
              if(crtc_drain_rate * 100 >= nvclk_fill * 102)
982
                      clwm = 0xfff; /*Large number to fail */
983
984
              else if(crtc_drain_rate * 100  >= nvclk_fill * 98) {
985
                  clwm = 1024;
986
                  cbs = 512;
987
                  us_extra = (cbs * 1000 * 1000)/ (8*width)/mclk_freq ;
988
              }
989
          }
990
      }
991
992
993
      /*
994
        Overfill check:
995
996
        */
997
998
      clwm_rnd_down = ((int)clwm/8)*8;
999
      if (clwm_rnd_down < clwm)
1000
          clwm += 8;
1001
1002
      m1 = clwm + cbs -  1024; /* Amount of overfill */
1003
      m2us = us_pipe_min + us_min_mclk_extra;
1004
      pclks_2_top_fifo = (1024-clwm)/(8*width);
1005
1006
      /* pclk cycles to drain */
1007
      p1clk = m2us * pclk_freq/(1000*1000); 
1008
      p2 = p1clk * bpp / 8; /* bytes drained. */
1009
1010
      if((p2 < m1) && (m1 > 0)) {
1011
          fifo->valid = 0;
1012
          found = 0;
1013
          if(min_mclk_extra == 0)   {
1014
            if(cbs <= 32) {
1015
              found = 1; /* Can't adjust anymore! */
1016
            } else {
1017
              cbs = cbs/2;  /* reduce the burst size */
1018
            }
1019
          } else {
1020
            min_mclk_extra--;
1021
          }
1022
      } else {
1023
        if (clwm > 1023){ /* Have some margin */
1024
          fifo->valid = 0;
1025
          found = 0;
1026
          if(min_mclk_extra == 0)   
1027
              found = 1; /* Can't adjust anymore! */
1028
          else 
1029
              min_mclk_extra--;
1030
        }
1031
      }
1032
      craw = clwm;
1033
1034
      if(clwm < (1024-cbs+8)) clwm = 1024-cbs+8;
1035
      data = (int)(clwm);
1036
      /*  printf("CRT LWM: %f bytes, prog: 0x%x, bs: 256\n", clwm, data ); */
1037
      fifo->graphics_lwm = data;   fifo->graphics_burst_size = cbs;
1038
1039
      /*  printf("VID LWM: %f bytes, prog: 0x%x, bs: %d\n, ", vlwm, data, vbs ); */
1040
      fifo->video_lwm = 1024;  fifo->video_burst_size = 512;
1041
    }
1042
}
1043
static void nv10UpdateArbitrationSettings
1044
(
1045
    unsigned      VClk, 
1046
    unsigned      pixelDepth, 
1047
    unsigned     *burst,
1048
    unsigned     *lwm,
1049
    RIVA_HW_INST *chip
1050
)
1051
{
1052
    nv10_fifo_info fifo_data;
1053
    nv10_sim_state sim_data;
1054
    unsigned int M, N, P, pll, MClk, NVClk, cfg1;
1055
1056
    pll = chip->PRAMDAC[0x00000504/4];
1057
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
1058
    MClk  = (N * chip->CrystalFreqKHz / M) >> P;
1059
    pll = chip->PRAMDAC[0x00000500/4];
1060
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
1061
    NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
1062
    cfg1 = chip->PFB[0x00000204/4];
1063
    sim_data.pix_bpp        = (char)pixelDepth;
1064
    sim_data.enable_video   = 0;
1065
    sim_data.enable_mp      = 0;
1066
    sim_data.memory_type    = (chip->PFB[0x00000200/4] & 0x01) ? 1 : 0;
1067
    sim_data.memory_width   = (chip->PEXTDEV[0x00000000/4] & 0x10) ? 128 : 64;
1068
    sim_data.mem_latency    = (char)cfg1 & 0x0F;
1069
    sim_data.mem_aligned    = 1;
1070
    sim_data.mem_page_miss  = (char)(((cfg1 >> 4) &0x0F) + ((cfg1 >> 31) & 0x01));
1071
    sim_data.gr_during_vid  = 0;
1072
    sim_data.pclk_khz       = VClk;
1073
    sim_data.mclk_khz       = MClk;
1074
    sim_data.nvclk_khz      = NVClk;
1075
    nv10CalcArbitration(&fifo_data, &sim_data);
1076
    if (fifo_data.valid)
1077
    {
1078
        int  b = fifo_data.graphics_burst_size >> 4;
1079
        *burst = 0;
1080
        while (b >>= 1) (*burst)++;
1081
        *lwm   = fifo_data.graphics_lwm >> 3;
1082
    }
1083
}
1084
1085
/****************************************************************************\
1086
*                                                                            *
1087
*                          RIVA Mode State Routines                          *
1088
*                                                                            *
1089
\****************************************************************************/
1090
1091
/*
1092
 * Calculate the Video Clock parameters for the PLL.
1093
 */
1094
static int CalcVClock
1095
(
1096
    int           clockIn,
1097
    int           double_scan,
1098
    int          *clockOut,
1099
    int          *mOut,
1100
    int          *nOut,
1101
    int          *pOut,
1102
    RIVA_HW_INST *chip
1103
)
1104
{
1105
    unsigned lowM, highM, highP;
1106
    unsigned DeltaNew, DeltaOld;
1107
    unsigned VClk, Freq;
1108
    unsigned M, N, P;
1109
    
1110
    DeltaOld = 0xFFFFFFFF;
1111
1112
    VClk     = (unsigned)clockIn;
1113
    if (double_scan)
1114
        VClk *= 2;
1115
    
1116
    if (chip->CrystalFreqKHz == 14318)
1117
    {
1118
        lowM  = 8;
1119
        highM = 14 - (chip->Architecture == NV_ARCH_03);
1120
    }
1121
    else
1122
    {
1123
        lowM  = 7;
1124
        highM = 13 - (chip->Architecture == NV_ARCH_03);
1125
    }                      
1126
1127
    highP = 4 - (chip->Architecture == NV_ARCH_03);
1128
    for (P = 0; P <= highP; P ++)
1129
    {
1130
        Freq = VClk << P;
1131
        if ((Freq >= 128000) && (Freq <= chip->MaxVClockFreqKHz))
1132
        {
1133
            for (M = lowM; M <= highM; M++)
1134
            {
1135
                N    = ((VClk * M) << P) / chip->CrystalFreqKHz;
1136
                Freq = (chip->CrystalFreqKHz * N / M) >> P;
1137
                if (Freq > VClk)
1138
                    DeltaNew = Freq - VClk;
1139
                else
1140
                    DeltaNew = VClk - Freq;
1141
                if (DeltaNew < DeltaOld)
1142
                {
1143
                    *mOut     = M;
1144
                    *nOut     = N;
1145
                    *pOut     = P;
1146
                    *clockOut = Freq;
1147
                    DeltaOld  = DeltaNew;
1148
                }
1149
            }
1150
        }
1151
    }
1152
    return (DeltaOld != 0xFFFFFFFF);
1153
}
1154
/*
1155
 * Calculate extended mode parameters (SVGA) and save in a 
1156
 * mode state structure.
1157
 */
1158
static void CalcStateExt
1159
(
1160
    RIVA_HW_INST  *chip,
1161
    RIVA_HW_STATE *state,
1162
    int            bpp,
1163
    int            width,
1164
    int            hDisplaySize,
1165
    int            height,
1166
    int            dotClock
1167
)
1168
{
1169
    int pixelDepth, VClk, m, n, p;
1170
    /*
1171
     * Save mode parameters.
1172
     */
1173
    state->bpp    = bpp;
1174
    state->width  = width;
1175
    state->height = height;
1176
    /*
1177
     * Extended RIVA registers.
1178
     */
1179
    pixelDepth = (bpp + 1)/8;
1180
    CalcVClock(dotClock, hDisplaySize < 512,  /* double scan? */
1181
               &VClk, &m, &n, &p, chip);
1182
1183
    switch (chip->Architecture)
1184
    {
1185
        case NV_ARCH_03:
1186
            nv3UpdateArbitrationSettings(VClk, 
1187
                                         pixelDepth * 8, 
1188
                                        &(state->arbitration0),
1189
                                        &(state->arbitration1),
1190
                                         chip);
1191
            state->cursor0  = 0x00;
1192
            state->cursor1  = 0x78;
1193
            state->cursor2  = 0x00000000;
1194
            state->pllsel   = 0x10010100;
1195
            state->config   = ((width + 31)/32)
1196
                            | (((pixelDepth > 2) ? 3 : pixelDepth) << 8)
1197
                            | 0x1000;
1198
            state->general  = 0x00100100;
1199
            state->repaint1 = hDisplaySize < 1280 ? 0x06 : 0x02;
1200
            break;
1201
        case NV_ARCH_04:
1202
            nv4UpdateArbitrationSettings(VClk, 
1203
                                         pixelDepth * 8, 
1204
                                        &(state->arbitration0),
1205
                                        &(state->arbitration1),
1206
                                         chip);
1207
            state->cursor0  = 0x00;
1208
            state->cursor1  = 0xFC;
1209
            state->cursor2  = 0x00000000;
1210
            state->pllsel   = 0x10000700;
1211
            state->config   = 0x00001114;
1212
            state->general  = bpp == 16 ? 0x00101100 : 0x00100100;
1213
            state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
1214
            break;
1215
        case NV_ARCH_10:
1216
	case NV_ARCH_20:
1217
            nv10UpdateArbitrationSettings(VClk, 
1218
                                          pixelDepth * 8, 
1219
                                         &(state->arbitration0),
1220
                                         &(state->arbitration1),
1221
                                          chip);
1222
#ifdef CONFIG_XBOX
1223
            state->cursor0  = 0x80 | (chip->CursorStart >> 17);
1224
            state->cursor1  = (chip->CursorStart >> 11) << 2;
1225
            state->cursor2  = chip->CursorStart >> 24;
1226
#else            
1227
            state->cursor0  = 0x00;
1228
            state->cursor1  = 0xFC;
1229
            state->cursor2  = 0x00000000;
1230
#endif
1231
            state->pllsel   = 0x10000700;
1232
            state->config   = chip->PFB[0x00000200/4];
1233
            state->general  = bpp == 16 ? 0x00101100 : 0x00100100;
1234
            state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
1235
            break;
1236
    }
1237
    state->vpll     = (p << 16) | (n << 8) | m;
1238
    state->repaint0 = (((width/8)*pixelDepth) & 0x700) >> 3;
1239
    state->pixel    = pixelDepth > 2   ? 3    : pixelDepth;
1240
#ifdef CONFIG_XBOX
1241
    /* switch pixel mode to TV */
1242
    state->pixel    |= 0x80;
1243
#endif
1244
    state->offset0  =
1245
    state->offset1  =
1246
    state->offset2  =
1247
    state->offset3  = 0;
1248
    state->pitch0   =
1249
    state->pitch1   =
1250
    state->pitch2   =
1251
    state->pitch3   = pixelDepth * width;
1252
}
1253
/*
1254
 * Load fixed function state and pre-calculated/stored state.
1255
 */
1256
#define LOAD_FIXED_STATE(tbl,dev)                                       \
1257
    for (i = 0; i < sizeof(tbl##Table##dev)/8; i++)                 \
1258
        chip->dev[tbl##Table##dev[i][0]] = tbl##Table##dev[i][1]
1259
#define LOAD_FIXED_STATE_8BPP(tbl,dev)                                  \
1260
    for (i = 0; i < sizeof(tbl##Table##dev##_8BPP)/8; i++)            \
1261
        chip->dev[tbl##Table##dev##_8BPP[i][0]] = tbl##Table##dev##_8BPP[i][1]
1262
#define LOAD_FIXED_STATE_15BPP(tbl,dev)                                 \
1263
    for (i = 0; i < sizeof(tbl##Table##dev##_15BPP)/8; i++)           \
1264
        chip->dev[tbl##Table##dev##_15BPP[i][0]] = tbl##Table##dev##_15BPP[i][1]
1265
#define LOAD_FIXED_STATE_16BPP(tbl,dev)                                 \
1266
    for (i = 0; i < sizeof(tbl##Table##dev##_16BPP)/8; i++)           \
1267
        chip->dev[tbl##Table##dev##_16BPP[i][0]] = tbl##Table##dev##_16BPP[i][1]
1268
#define LOAD_FIXED_STATE_32BPP(tbl,dev)                                 \
1269
    for (i = 0; i < sizeof(tbl##Table##dev##_32BPP)/8; i++)           \
1270
        chip->dev[tbl##Table##dev##_32BPP[i][0]] = tbl##Table##dev##_32BPP[i][1]
1271
static void UpdateFifoState
1272
(
1273
    RIVA_HW_INST  *chip
1274
)
1275
{
1276
    int i;
1277
1278
    switch (chip->Architecture)
1279
    {
1280
        case NV_ARCH_04:
1281
            LOAD_FIXED_STATE(nv4,FIFO);
1282
            chip->Tri03 = 0L;
1283
            chip->Tri05 = (RivaTexturedTriangle05 *)&(chip->FIFO[0x0000E000/4]);
1284
            break;
1285
        case NV_ARCH_10:
1286
	case NV_ARCH_20:
1287
            /*
1288
             * Initialize state for the RivaTriangle3D05 routines.
1289
             */
1290
            LOAD_FIXED_STATE(nv10tri05,PGRAPH);
1291
            LOAD_FIXED_STATE(nv10,FIFO);
1292
            chip->Tri03 = 0L;
1293
            chip->Tri05 = (RivaTexturedTriangle05 *)&(chip->FIFO[0x0000E000/4]);
1294
            break;
1295
    }
1296
}
1297
static void LoadStateExt
1298
(
1299
    RIVA_HW_INST  *chip,
1300
    RIVA_HW_STATE *state
1301
)
1302
{
1303
    int i;
1304
1305
    /*
1306
     * Load HW fixed function state.
1307
     */
1308
    LOAD_FIXED_STATE(Riva,PMC);
1309
    LOAD_FIXED_STATE(Riva,PTIMER);
1310
    switch (chip->Architecture)
1311
    {
1312
        case NV_ARCH_03:
1313
            /*
1314
             * Make sure frame buffer config gets set before loading PRAMIN.
1315
             */
1316
            chip->PFB[0x00000200/4] = state->config;
1317
            LOAD_FIXED_STATE(nv3,PFIFO);
1318
            LOAD_FIXED_STATE(nv3,PRAMIN);
1319
            LOAD_FIXED_STATE(nv3,PGRAPH);
1320
            switch (state->bpp)
1321
            {
1322
                case 15:
1323
                case 16:
1324
                    LOAD_FIXED_STATE_15BPP(nv3,PRAMIN);
1325
                    LOAD_FIXED_STATE_15BPP(nv3,PGRAPH);
1326
                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
1327
                    break;
1328
                case 24:
1329
                case 32:
1330
                    LOAD_FIXED_STATE_32BPP(nv3,PRAMIN);
1331
                    LOAD_FIXED_STATE_32BPP(nv3,PGRAPH);
1332
                    chip->Tri03 = 0L;
1333
                    break;
1334
                case 8:
1335
                default:
1336
                    LOAD_FIXED_STATE_8BPP(nv3,PRAMIN);
1337
                    LOAD_FIXED_STATE_8BPP(nv3,PGRAPH);
1338
                    chip->Tri03 = 0L;
1339
                    break;
1340
            }
1341
            for (i = 0x00000; i < 0x00800; i++)
1342
                chip->PRAMIN[0x00000502 + i] = (i << 12) | 0x03;
1343
            chip->PGRAPH[0x00000630/4] = state->offset0;
1344
            chip->PGRAPH[0x00000634/4] = state->offset1;
1345
            chip->PGRAPH[0x00000638/4] = state->offset2;
1346
            chip->PGRAPH[0x0000063C/4] = state->offset3;
1347
            chip->PGRAPH[0x00000650/4] = state->pitch0;
1348
            chip->PGRAPH[0x00000654/4] = state->pitch1;
1349
            chip->PGRAPH[0x00000658/4] = state->pitch2;
1350
            chip->PGRAPH[0x0000065C/4] = state->pitch3;
1351
            break;
1352
        case NV_ARCH_04:
1353
            /*
1354
             * Make sure frame buffer config gets set before loading PRAMIN.
1355
             */
1356
            chip->PFB[0x00000200/4] = state->config;
1357
            LOAD_FIXED_STATE(nv4,PFIFO);
1358
            LOAD_FIXED_STATE(nv4,PRAMIN);
1359
            LOAD_FIXED_STATE(nv4,PGRAPH);
1360
            switch (state->bpp)
1361
            {
1362
                case 15:
1363
                    LOAD_FIXED_STATE_15BPP(nv4,PRAMIN);
1364
                    LOAD_FIXED_STATE_15BPP(nv4,PGRAPH);
1365
                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
1366
                    break;
1367
                case 16:
1368
                    LOAD_FIXED_STATE_16BPP(nv4,PRAMIN);
1369
                    LOAD_FIXED_STATE_16BPP(nv4,PGRAPH);
1370
                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
1371
                    break;
1372
                case 24:
1373
                case 32:
1374
                    LOAD_FIXED_STATE_32BPP(nv4,PRAMIN);
1375
                    LOAD_FIXED_STATE_32BPP(nv4,PGRAPH);
1376
                    chip->Tri03 = 0L;
1377
                    break;
1378
                case 8:
1379
                default:
1380
                    LOAD_FIXED_STATE_8BPP(nv4,PRAMIN);
1381
                    LOAD_FIXED_STATE_8BPP(nv4,PGRAPH);
1382
                    chip->Tri03 = 0L;
1383
                    break;
1384
            }
1385
            chip->PGRAPH[0x00000640/4] = state->offset0;
1386
            chip->PGRAPH[0x00000644/4] = state->offset1;
1387
            chip->PGRAPH[0x00000648/4] = state->offset2;
1388
            chip->PGRAPH[0x0000064C/4] = state->offset3;
1389
            chip->PGRAPH[0x00000670/4] = state->pitch0;
1390
            chip->PGRAPH[0x00000674/4] = state->pitch1;
1391
            chip->PGRAPH[0x00000678/4] = state->pitch2;
1392
            chip->PGRAPH[0x0000067C/4] = state->pitch3;
1393
            break;
1394
        case NV_ARCH_10:
1395
	case NV_ARCH_20:
1396
            LOAD_FIXED_STATE(nv10,PFIFO);
1397
            LOAD_FIXED_STATE(nv10,PRAMIN);
1398
            LOAD_FIXED_STATE(nv10,PGRAPH);
1399
            switch (state->bpp)
1400
            {
1401
                case 15:
1402
                    LOAD_FIXED_STATE_15BPP(nv10,PRAMIN);
1403
                    LOAD_FIXED_STATE_15BPP(nv10,PGRAPH);
1404
                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
1405
                    break;
1406
                case 16:
1407
                    LOAD_FIXED_STATE_16BPP(nv10,PRAMIN);
1408
                    LOAD_FIXED_STATE_16BPP(nv10,PGRAPH);
1409
                    chip->Tri03 = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
1410
                    break;
1411
                case 24:
1412
                case 32:
1413
                    LOAD_FIXED_STATE_32BPP(nv10,PRAMIN);
1414
                    LOAD_FIXED_STATE_32BPP(nv10,PGRAPH);
1415
                    chip->Tri03 = 0L;
1416
                    break;
1417
                case 8:
1418
                default:
1419
                    LOAD_FIXED_STATE_8BPP(nv10,PRAMIN);
1420
                    LOAD_FIXED_STATE_8BPP(nv10,PGRAPH);
1421
                    chip->Tri03 = 0L;
1422
                    break;
1423
            }
1424
1425
            if (chip->Architecture == NV_ARCH_10) {
1426
                chip->PGRAPH[0x00000640/4] = state->offset0;
1427
                chip->PGRAPH[0x00000644/4] = state->offset1;
1428
                chip->PGRAPH[0x00000648/4] = state->offset2;
1429
                chip->PGRAPH[0x0000064C/4] = state->offset3;
1430
                chip->PGRAPH[0x00000670/4] = state->pitch0;
1431
                chip->PGRAPH[0x00000674/4] = state->pitch1;
1432
                chip->PGRAPH[0x00000678/4] = state->pitch2;
1433
                chip->PGRAPH[0x0000067C/4] = state->pitch3;
1434
                chip->PGRAPH[0x00000680/4] = state->pitch3;
1435
            } else {
1436
                chip->PGRAPH[0x00000820/4] = state->offset0;
1437
                chip->PGRAPH[0x00000824/4] = state->offset1;
1438
                chip->PGRAPH[0x00000828/4] = state->offset2;
1439
                chip->PGRAPH[0x0000082C/4] = state->offset3;
1440
                chip->PGRAPH[0x00000850/4] = state->pitch0;
1441
                chip->PGRAPH[0x00000854/4] = state->pitch1;
1442
                chip->PGRAPH[0x00000858/4] = state->pitch2;
1443
                chip->PGRAPH[0x0000085C/4] = state->pitch3;
1444
                chip->PGRAPH[0x00000860/4] = state->pitch3;
1445
                chip->PGRAPH[0x00000864/4] = state->pitch3;
1446
                chip->PGRAPH[0x000009A4/4] = chip->PFB[0x00000200/4];
1447
                chip->PGRAPH[0x000009A8/4] = chip->PFB[0x00000204/4];
1448
                chip->PRAMDAC[0x0000052C/4] = 0x00000101;
1449
                chip->PRAMDAC[0x0000252C/4] = 0x00000001;
1450
                VGA_WR08(chip->PCIO, 0x03D4, 0x41);
1451
                VGA_WR08(chip->PCIO, 0x03D5, state->extra);
1452
            }
1453
            chip->PRAMDAC[0x00000404/4] |= (1 << 25);
1454
            chip->PRAMDAC[0x00002404/4] |= (1 << 25);
1455
1456
	    chip->PMC[0x00008704/4] = 1;
1457
	    chip->PMC[0x00008140/4] = 0;
1458
	    chip->PMC[0x00008920/4] = 0;
1459
	    chip->PMC[0x00008924/4] = 0;
1460
	    chip->PMC[0x00008908/4] = 0x03ffffff;
1461
	    chip->PMC[0x0000890C/4] = 0x03ffffff;
1462
1463
            chip->PFB[0x00000240/4] = 0;
1464
            chip->PFB[0x00000244/4] = 0;
1465
            chip->PFB[0x00000248/4] = 0;
1466
            chip->PFB[0x0000024C/4] = 0;
1467
            chip->PFB[0x00000250/4] = 0;
1468
            chip->PFB[0x00000254/4] = 0;
1469
            chip->PFB[0x00000258/4] = 0;
1470
            chip->PFB[0x0000025C/4] = 0;
1471
            
1472
	    chip->PGRAPH[0x00000B00/4] = chip->PFB[0x00000240/4];
1473
            chip->PGRAPH[0x00000B04/4] = chip->PFB[0x00000244/4];
1474
            chip->PGRAPH[0x00000B08/4] = chip->PFB[0x00000248/4];
1475
            chip->PGRAPH[0x00000B0C/4] = chip->PFB[0x0000024C/4];
1476
            chip->PGRAPH[0x00000B10/4] = chip->PFB[0x00000250/4];
1477
            chip->PGRAPH[0x00000B14/4] = chip->PFB[0x00000254/4];
1478
            chip->PGRAPH[0x00000B18/4] = chip->PFB[0x00000258/4];
1479
            chip->PGRAPH[0x00000B1C/4] = chip->PFB[0x0000025C/4];
1480
            chip->PGRAPH[0x00000B20/4] = chip->PFB[0x00000260/4];
1481
            chip->PGRAPH[0x00000B24/4] = chip->PFB[0x00000264/4];
1482
            chip->PGRAPH[0x00000B28/4] = chip->PFB[0x00000268/4];
1483
            chip->PGRAPH[0x00000B2C/4] = chip->PFB[0x0000026C/4];
1484
            chip->PGRAPH[0x00000B30/4] = chip->PFB[0x00000270/4];
1485
            chip->PGRAPH[0x00000B34/4] = chip->PFB[0x00000274/4];
1486
            chip->PGRAPH[0x00000B38/4] = chip->PFB[0x00000278/4];
1487
            chip->PGRAPH[0x00000B3C/4] = chip->PFB[0x0000027C/4];
1488
            chip->PGRAPH[0x00000B40/4] = chip->PFB[0x00000280/4];
1489
            chip->PGRAPH[0x00000B44/4] = chip->PFB[0x00000284/4];
1490
            chip->PGRAPH[0x00000B48/4] = chip->PFB[0x00000288/4];
1491
            chip->PGRAPH[0x00000B4C/4] = chip->PFB[0x0000028C/4];
1492
            chip->PGRAPH[0x00000B50/4] = chip->PFB[0x00000290/4];
1493
            chip->PGRAPH[0x00000B54/4] = chip->PFB[0x00000294/4];
1494
            chip->PGRAPH[0x00000B58/4] = chip->PFB[0x00000298/4];
1495
            chip->PGRAPH[0x00000B5C/4] = chip->PFB[0x0000029C/4];
1496
            chip->PGRAPH[0x00000B60/4] = chip->PFB[0x000002A0/4];
1497
            chip->PGRAPH[0x00000B64/4] = chip->PFB[0x000002A4/4];
1498
            chip->PGRAPH[0x00000B68/4] = chip->PFB[0x000002A8/4];
1499
            chip->PGRAPH[0x00000B6C/4] = chip->PFB[0x000002AC/4];
1500
            chip->PGRAPH[0x00000B70/4] = chip->PFB[0x000002B0/4];
1501
            chip->PGRAPH[0x00000B74/4] = chip->PFB[0x000002B4/4];
1502
            chip->PGRAPH[0x00000B78/4] = chip->PFB[0x000002B8/4];
1503
            chip->PGRAPH[0x00000B7C/4] = chip->PFB[0x000002BC/4];
1504
            chip->PGRAPH[0x00000F40/4] = 0x10000000;
1505
            chip->PGRAPH[0x00000F44/4] = 0x00000000;
1506
            chip->PGRAPH[0x00000F50/4] = 0x00000040;
1507
            chip->PGRAPH[0x00000F54/4] = 0x00000008;
1508
            chip->PGRAPH[0x00000F50/4] = 0x00000200;
1509
            for (i = 0; i < (3*16); i++)
1510
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1511
            chip->PGRAPH[0x00000F50/4] = 0x00000040;
1512
            chip->PGRAPH[0x00000F54/4] = 0x00000000;
1513
            chip->PGRAPH[0x00000F50/4] = 0x00000800;
1514
            for (i = 0; i < (16*16); i++)
1515
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1516
            chip->PGRAPH[0x00000F40/4] = 0x30000000;
1517
            chip->PGRAPH[0x00000F44/4] = 0x00000004;
1518
            chip->PGRAPH[0x00000F50/4] = 0x00006400;
1519
            for (i = 0; i < (59*4); i++)
1520
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1521
            chip->PGRAPH[0x00000F50/4] = 0x00006800;
1522
            for (i = 0; i < (47*4); i++)
1523
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1524
            chip->PGRAPH[0x00000F50/4] = 0x00006C00;
1525
            for (i = 0; i < (3*4); i++)
1526
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1527
            chip->PGRAPH[0x00000F50/4] = 0x00007000;
1528
            for (i = 0; i < (19*4); i++)
1529
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1530
            chip->PGRAPH[0x00000F50/4] = 0x00007400;
1531
            for (i = 0; i < (12*4); i++)
1532
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1533
            chip->PGRAPH[0x00000F50/4] = 0x00007800;
1534
            for (i = 0; i < (12*4); i++)
1535
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1536
            chip->PGRAPH[0x00000F50/4] = 0x00004400;
1537
            for (i = 0; i < (8*4); i++)
1538
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1539
            chip->PGRAPH[0x00000F50/4] = 0x00000000;
1540
            for (i = 0; i < 16; i++)
1541
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1542
            chip->PGRAPH[0x00000F50/4] = 0x00000040;
1543
            for (i = 0; i < 4; i++)
1544
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1545
            break;
1546
    }
1547
    LOAD_FIXED_STATE(Riva,FIFO);
1548
    UpdateFifoState(chip);
1549
    /*
1550
     * Load HW mode state.
1551
     */
1552
    VGA_WR08(chip->PCIO, 0x03D4, 0x19);
1553
    VGA_WR08(chip->PCIO, 0x03D5, state->repaint0);
1554
    VGA_WR08(chip->PCIO, 0x03D4, 0x1A);
1555
    VGA_WR08(chip->PCIO, 0x03D5, state->repaint1);
1556
    VGA_WR08(chip->PCIO, 0x03D4, 0x25);
1557
    VGA_WR08(chip->PCIO, 0x03D5, state->screen);
1558
    VGA_WR08(chip->PCIO, 0x03D4, 0x28);
1559
    VGA_WR08(chip->PCIO, 0x03D5, state->pixel);
1560
    VGA_WR08(chip->PCIO, 0x03D4, 0x2D);
1561
    VGA_WR08(chip->PCIO, 0x03D5, state->horiz);
1562
    VGA_WR08(chip->PCIO, 0x03D4, 0x1B);
1563
    VGA_WR08(chip->PCIO, 0x03D5, state->arbitration0);
1564
    VGA_WR08(chip->PCIO, 0x03D4, 0x20);
1565
    VGA_WR08(chip->PCIO, 0x03D5, state->arbitration1);
1566
    VGA_WR08(chip->PCIO, 0x03D4, 0x30);
1567
    VGA_WR08(chip->PCIO, 0x03D5, state->cursor0);
1568
    VGA_WR08(chip->PCIO, 0x03D4, 0x31);
1569
    VGA_WR08(chip->PCIO, 0x03D5, state->cursor1);
1570
    VGA_WR08(chip->PCIO, 0x03D4, 0x39);
1571
    VGA_WR08(chip->PCIO, 0x03D5, state->interlace);
1572
    chip->PRAMDAC[0x00000300/4]  = state->cursor2;
1573
    chip->PRAMDAC[0x00000508/4]  = state->vpll;
1574
    chip->PRAMDAC[0x0000050C/4]  = state->pllsel;
1575
    chip->PRAMDAC[0x00000600/4]  = state->general;
1576
#ifdef CONFIG_XBOX
1577
    chip->PCRTC[0x00000800/4] = state->fb_start;
1578
	chip->PRAMDAC[0x00000800/4] = state->vend;
1579
	chip->PRAMDAC[0x00000804/4] = state->vtotal;
1580
	chip->PRAMDAC[0x00000808/4] = state->vcrtc;
1581
	chip->PRAMDAC[0x0000080c/4] = state->vsyncstart;
1582
	chip->PRAMDAC[0x00000810/4] = state->vsyncend;
1583
	chip->PRAMDAC[0x00000814/4] = state->vvalidstart;
1584
	chip->PRAMDAC[0x00000818/4] = state->vvalidend;
1585
	chip->PRAMDAC[0x00000820/4] = state->hend;
1586
	chip->PRAMDAC[0x00000824/4] = state->htotal;
1587
	chip->PRAMDAC[0x00000828/4] = state->hcrtc;
1588
	chip->PRAMDAC[0x0000082c/4] = state->hsyncstart;
1589
	chip->PRAMDAC[0x00000830/4] = state->hsyncend;
1590
	chip->PRAMDAC[0x00000834/4] = state->hvalidstart;
1591
	chip->PRAMDAC[0x00000838/4] = state->hvalidend;
1592
	chip->PRAMDAC[0x00000840/4] = state->checksum ;
1593
#endif
1594
    /*
1595
     * Turn off VBlank enable and reset.
1596
     */
1597
    *(chip->VBLANKENABLE) = 0;
1598
    *(chip->VBLANK)       = chip->VBlankBit;
1599
    /*
1600
     * Set interrupt enable.
1601
     */    
1602
    chip->PMC[0x00000140/4]  = chip->EnableIRQ & 0x01;
1603
    /*
1604
     * Set current state pointer.
1605
     */
1606
    chip->CurrentState = state;
1607
    /*
1608
     * Reset FIFO free and empty counts.
1609
     */
1610
    chip->FifoFreeCount  = 0;
1611
    /* Free count from first subchannel */
1612
    chip->FifoEmptyCount = chip->Rop->FifoFree; 
1613
}
1614
static void UnloadStateExt
1615
(
1616
    RIVA_HW_INST  *chip,
1617
    RIVA_HW_STATE *state
1618
)
1619
{
1620
    /*
1621
     * Save current HW state.
1622
     */
1623
    VGA_WR08(chip->PCIO, 0x03D4, 0x19);
1624
    state->repaint0     = VGA_RD08(chip->PCIO, 0x03D5);
1625
    VGA_WR08(chip->PCIO, 0x03D4, 0x1A);
1626
    state->repaint1     = VGA_RD08(chip->PCIO, 0x03D5);
1627
    VGA_WR08(chip->PCIO, 0x03D4, 0x25);
1628
    state->screen       = VGA_RD08(chip->PCIO, 0x03D5);
1629
    VGA_WR08(chip->PCIO, 0x03D4, 0x28);
1630
    state->pixel        = VGA_RD08(chip->PCIO, 0x03D5);
1631
    VGA_WR08(chip->PCIO, 0x03D4, 0x2D);
1632
    state->horiz        = VGA_RD08(chip->PCIO, 0x03D5);
1633
    VGA_WR08(chip->PCIO, 0x03D4, 0x1B);
1634
    state->arbitration0 = VGA_RD08(chip->PCIO, 0x03D5);
1635
    VGA_WR08(chip->PCIO, 0x03D4, 0x20);
1636
    state->arbitration1 = VGA_RD08(chip->PCIO, 0x03D5);
1637
    VGA_WR08(chip->PCIO, 0x03D4, 0x30);
1638
    state->cursor0      = VGA_RD08(chip->PCIO, 0x03D5);
1639
    VGA_WR08(chip->PCIO, 0x03D4, 0x31);
1640
    state->cursor1      = VGA_RD08(chip->PCIO, 0x03D5);
1641
    VGA_WR08(chip->PCIO, 0x03D4, 0x39);
1642
    state->interlace    = VGA_RD08(chip->PCIO, 0x03D5);
1643
    state->cursor2      = chip->PRAMDAC[0x00000300/4];
1644
    state->vpll         = chip->PRAMDAC[0x00000508/4];
1645
    state->pllsel       = chip->PRAMDAC[0x0000050C/4];
1646
    state->general      = chip->PRAMDAC[0x00000600/4];
1647
    state->config       = chip->PFB[0x00000200/4];
1648
    switch (chip->Architecture)
1649
    {
1650
        case NV_ARCH_03:
1651
            state->offset0  = chip->PGRAPH[0x00000630/4];
1652
            state->offset1  = chip->PGRAPH[0x00000634/4];
1653
            state->offset2  = chip->PGRAPH[0x00000638/4];
1654
            state->offset3  = chip->PGRAPH[0x0000063C/4];
1655
            state->pitch0   = chip->PGRAPH[0x00000650/4];
1656
            state->pitch1   = chip->PGRAPH[0x00000654/4];
1657
            state->pitch2   = chip->PGRAPH[0x00000658/4];
1658
            state->pitch3   = chip->PGRAPH[0x0000065C/4];
1659
            break;
1660
        case NV_ARCH_04:
1661
            state->offset0  = chip->PGRAPH[0x00000640/4];
1662
            state->offset1  = chip->PGRAPH[0x00000644/4];
1663
            state->offset2  = chip->PGRAPH[0x00000648/4];
1664
            state->offset3  = chip->PGRAPH[0x0000064C/4];
1665
            state->pitch0   = chip->PGRAPH[0x00000670/4];
1666
            state->pitch1   = chip->PGRAPH[0x00000674/4];
1667
            state->pitch2   = chip->PGRAPH[0x00000678/4];
1668
            state->pitch3   = chip->PGRAPH[0x0000067C/4];
1669
            break;
1670
        case NV_ARCH_10:
1671
            state->offset0  = chip->PGRAPH[0x00000640/4];
1672
            state->offset1  = chip->PGRAPH[0x00000644/4];
1673
            state->offset2  = chip->PGRAPH[0x00000648/4];
1674
            state->offset3  = chip->PGRAPH[0x0000064C/4];
1675
            state->pitch0   = chip->PGRAPH[0x00000670/4];
1676
            state->pitch1   = chip->PGRAPH[0x00000674/4];
1677
            state->pitch2   = chip->PGRAPH[0x00000678/4];
1678
            state->pitch3   = chip->PGRAPH[0x0000067C/4];
1679
            break;
1680
        case NV_ARCH_20:
1681
            state->offset0  = chip->PGRAPH[0x00000820/4];
1682
            state->offset1  = chip->PGRAPH[0x00000824/4];
1683
            state->offset2  = chip->PGRAPH[0x00000828/4];
1684
            state->offset3  = chip->PGRAPH[0x0000082C/4];
1685
            state->pitch0   = chip->PGRAPH[0x00000850/4];
1686
            state->pitch1   = chip->PGRAPH[0x00000854/4];
1687
            state->pitch2   = chip->PGRAPH[0x00000858/4];
1688
            state->pitch3   = chip->PGRAPH[0x0000085C/4];
1689
            VGA_WR08(chip->PCIO, 0x03D4, 0x41);
1690
            state->extra = VGA_RD08(chip->PCIO, 0x03D5);
1691
#ifdef CONFIG_XBOX
1692
            state->fb_start    = chip->PCRTC[0x00000800/4];
1693
			state->vend        = chip->PRAMDAC[0x00000800/4];
1694
			state->vtotal      = chip->PRAMDAC[0x00000804/4];
1695
			state->vcrtc       = chip->PRAMDAC[0x00000808/4];
1696
			state->vsyncstart  = chip->PRAMDAC[0x0000080c/4];
1697
			state->vsyncend    = chip->PRAMDAC[0x00000810/4];
1698
			state->vvalidstart = chip->PRAMDAC[0x00000814/4];
1699
			state->vvalidend   = chip->PRAMDAC[0x00000818/4];
1700
			state->hend        = chip->PRAMDAC[0x00000820/4];
1701
			state->htotal      = chip->PRAMDAC[0x00000824/4];
1702
			state->hcrtc       = chip->PRAMDAC[0x00000828/4];
1703
			state->hsyncstart  = chip->PRAMDAC[0x0000082c/4];
1704
			state->hsyncend    = chip->PRAMDAC[0x00000830/4];
1705
			state->hvalidstart = chip->PRAMDAC[0x00000834/4];
1706
			state->hvalidend   = chip->PRAMDAC[0x00000838/4];
1707
			state->checksum    = chip->PRAMDAC[0x00000840/4];
1708
#endif
1709
            break;
1710
    }
1711
}
1712
static void SetStartAddress
1713
(
1714
    RIVA_HW_INST *chip,
1715
    unsigned      start
1716
)
1717
{
1718
    int offset = start >> 2;
1719
    int pan    = (start & 3) << 1;
1720
    unsigned char tmp;
1721
1722
    /*
1723
     * Unlock extended registers.
1724
     */
1725
    chip->LockUnlock(chip, 0);
1726
    /*
1727
     * Set start address.
1728
     */
1729
    VGA_WR08(chip->PCIO, 0x3D4, 0x0D); VGA_WR08(chip->PCIO, 0x3D5, offset);
1730
    offset >>= 8;
1731
    VGA_WR08(chip->PCIO, 0x3D4, 0x0C); VGA_WR08(chip->PCIO, 0x3D5, offset);
1732
    offset >>= 8;
1733
    VGA_WR08(chip->PCIO, 0x3D4, 0x19); tmp = VGA_RD08(chip->PCIO, 0x3D5);
1734
    VGA_WR08(chip->PCIO, 0x3D5, (offset & 0x01F) | (tmp & ~0x1F));
1735
    VGA_WR08(chip->PCIO, 0x3D4, 0x2D); tmp = VGA_RD08(chip->PCIO, 0x3D5);
1736
    VGA_WR08(chip->PCIO, 0x3D5, (offset & 0xE0) | (tmp & ~0xE0));
1737
    /*
1738
     * 4 pixel pan register.
1739
     */
1740
    offset = VGA_RD08(chip->PCIO, chip->IO + 0x0A);
1741
    VGA_WR08(chip->PCIO, 0x3C0, 0x13);
1742
    VGA_WR08(chip->PCIO, 0x3C0, pan);
1743
}
1744
static void nv3SetSurfaces2D
1745
(
1746
    RIVA_HW_INST *chip,
1747
    unsigned     surf0,
1748
    unsigned     surf1
1749
)
1750
{
1751
    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1752
1753
    RIVA_FIFO_FREE(*chip,Tri03,5);
1754
    chip->FIFO[0x00003800] = 0x80000003;
1755
    Surface->Offset        = surf0;
1756
    chip->FIFO[0x00003800] = 0x80000004;
1757
    Surface->Offset        = surf1;
1758
    chip->FIFO[0x00003800] = 0x80000013;
1759
}
1760
static void nv4SetSurfaces2D
1761
(
1762
    RIVA_HW_INST *chip,
1763
    unsigned     surf0,
1764
    unsigned     surf1
1765
)
1766
{
1767
    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1768
1769
    chip->FIFO[0x00003800] = 0x80000003;
1770
    Surface->Offset        = surf0;
1771
    chip->FIFO[0x00003800] = 0x80000004;
1772
    Surface->Offset        = surf1;
1773
    chip->FIFO[0x00003800] = 0x80000014;
1774
}
1775
static void nv10SetSurfaces2D
1776
(
1777
    RIVA_HW_INST *chip,
1778
    unsigned     surf0,
1779
    unsigned     surf1
1780
)
1781
{
1782
    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1783
1784
    chip->FIFO[0x00003800] = 0x80000003;
1785
    Surface->Offset        = surf0;
1786
    chip->FIFO[0x00003800] = 0x80000004;
1787
    Surface->Offset        = surf1;
1788
    chip->FIFO[0x00003800] = 0x80000014;
1789
}
1790
static void nv3SetSurfaces3D
1791
(
1792
    RIVA_HW_INST *chip,
1793
    unsigned     surf0,
1794
    unsigned     surf1
1795
)
1796
{
1797
    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1798
1799
    RIVA_FIFO_FREE(*chip,Tri03,5);
1800
    chip->FIFO[0x00003800] = 0x80000005;
1801
    Surface->Offset        = surf0;
1802
    chip->FIFO[0x00003800] = 0x80000006;
1803
    Surface->Offset        = surf1;
1804
    chip->FIFO[0x00003800] = 0x80000013;
1805
}
1806
static void nv4SetSurfaces3D
1807
(
1808
    RIVA_HW_INST *chip,
1809
    unsigned     surf0,
1810
    unsigned     surf1
1811
)
1812
{
1813
    RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1814
1815
    chip->FIFO[0x00003800] = 0x80000005;
1816
    Surface->Offset        = surf0;
1817
    chip->FIFO[0x00003800] = 0x80000006;
1818
    Surface->Offset        = surf1;
1819
    chip->FIFO[0x00003800] = 0x80000014;
1820
}
1821
static void nv10SetSurfaces3D
1822
(
1823
    RIVA_HW_INST *chip,
1824
    unsigned     surf0,
1825
    unsigned     surf1
1826
)
1827
{
1828
    RivaSurface3D *Surfaces3D = (RivaSurface3D *)&(chip->FIFO[0x0000E000/4]);
1829
1830
    RIVA_FIFO_FREE(*chip,Tri03,4);
1831
    chip->FIFO[0x00003800]         = 0x80000007;
1832
    Surfaces3D->RenderBufferOffset = surf0;
1833
    Surfaces3D->ZBufferOffset      = surf1;
1834
    chip->FIFO[0x00003800]         = 0x80000014;
1835
}
1836
1837
/****************************************************************************\
1838
*                                                                            *
1839
*                      Probe RIVA Chip Configuration                         *
1840
*                                                                            *
1841
\****************************************************************************/
1842
1843
static void nv3GetConfig
1844
(
1845
    RIVA_HW_INST *chip
1846
)
1847
{
1848
    /*
1849
     * Fill in chip configuration.
1850
     */
1851
    if (chip->PFB[0x00000000/4] & 0x00000020)
1852
    {
1853
        if (((chip->PMC[0x00000000/4] & 0xF0) == 0x20)
1854
         && ((chip->PMC[0x00000000/4] & 0x0F) >= 0x02))
1855
        {        
1856
            /*
1857
             * SDRAM 128 ZX.
1858
             */
1859
            chip->RamBandwidthKBytesPerSec = 800000;
1860
            switch (chip->PFB[0x00000000/4] & 0x03)
1861
            {
1862
                case 2:
1863
                    chip->RamAmountKBytes = 1024 * 4;
1864
                    break;
1865
                case 1:
1866
                    chip->RamAmountKBytes = 1024 * 2;
1867
                    break;
1868
                default:
1869
                    chip->RamAmountKBytes = 1024 * 8;
1870
                    break;
1871
            }
1872
        }            
1873
        else            
1874
        {
1875
            chip->RamBandwidthKBytesPerSec = 1000000;
1876
            chip->RamAmountKBytes          = 1024 * 8;
1877
        }            
1878
    }
1879
    else
1880
    {
1881
        /*
1882
         * SGRAM 128.
1883
         */
1884
        chip->RamBandwidthKBytesPerSec = 1000000;
1885
        switch (chip->PFB[0x00000000/4] & 0x00000003)
1886
        {
1887
            case 0:
1888
                chip->RamAmountKBytes = 1024 * 8;
1889
                break;
1890
            case 2:
1891
                chip->RamAmountKBytes = 1024 * 4;
1892
                break;
1893
            default:
1894
                chip->RamAmountKBytes = 1024 * 2;
1895
                break;
1896
        }
1897
    }        
1898
    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000020) ? 14318 : 13500;
1899
    chip->CURSOR           = &(chip->PRAMIN[0x00008000/4 - 0x0800/4]);
1900
    chip->CURSORPOS        = &(chip->PRAMDAC[0x0300/4]);
1901
    chip->VBLANKENABLE     = &(chip->PGRAPH[0x0140/4]);
1902
    chip->VBLANK           = &(chip->PGRAPH[0x0100/4]);
1903
    chip->VBlankBit        = 0x00000100;
1904
    chip->MaxVClockFreqKHz = 256000;
1905
    /*
1906
     * Set chip functions.
1907
     */
1908
    chip->Busy            = nv3Busy;
1909
    chip->ShowHideCursor  = ShowHideCursor;
1910
    chip->CalcStateExt    = CalcStateExt;
1911
    chip->LoadStateExt    = LoadStateExt;
1912
    chip->UnloadStateExt  = UnloadStateExt;
1913
    chip->SetStartAddress = SetStartAddress;
1914
    chip->SetSurfaces2D   = nv3SetSurfaces2D;
1915
    chip->SetSurfaces3D   = nv3SetSurfaces3D;
1916
    chip->LockUnlock      = nv3LockUnlock;
1917
}
1918
static void nv4GetConfig
1919
(
1920
    RIVA_HW_INST *chip
1921
)
1922
{
1923
    /*
1924
     * Fill in chip configuration.
1925
     */
1926
    if (chip->PFB[0x00000000/4] & 0x00000100)
1927
    {
1928
        chip->RamAmountKBytes = ((chip->PFB[0x00000000/4] >> 12) & 0x0F) * 1024 * 2
1929
                              + 1024 * 2;
1930
    }
1931
    else
1932
    {
1933
        switch (chip->PFB[0x00000000/4] & 0x00000003)
1934
        {
1935
            case 0:
1936
                chip->RamAmountKBytes = 1024 * 32;
1937
                break;
1938
            case 1:
1939
                chip->RamAmountKBytes = 1024 * 4;
1940
                break;
1941
            case 2:
1942
                chip->RamAmountKBytes = 1024 * 8;
1943
                break;
1944
            case 3:
1945
            default:
1946
                chip->RamAmountKBytes = 1024 * 16;
1947
                break;
1948
        }
1949
    }
1950
    switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003)
1951
    {
1952
        case 3:
1953
            chip->RamBandwidthKBytesPerSec = 800000;
1954
            break;
1955
        default:
1956
            chip->RamBandwidthKBytesPerSec = 1000000;
1957
            break;
1958
    }
1959
    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
1960
    chip->CURSOR           = &(chip->PRAMIN[0x00010000/4 - 0x0800/4]);
1961
    chip->CURSORPOS        = &(chip->PRAMDAC[0x0300/4]);
1962
    chip->VBLANKENABLE     = &(chip->PCRTC[0x0140/4]);
1963
    chip->VBLANK           = &(chip->PCRTC[0x0100/4]);
1964
    chip->VBlankBit        = 0x00000001;
1965
    chip->MaxVClockFreqKHz = 350000;
1966
    /*
1967
     * Set chip functions.
1968
     */
1969
    chip->Busy            = nv4Busy;
1970
    chip->ShowHideCursor  = ShowHideCursor;
1971
    chip->CalcStateExt    = CalcStateExt;
1972
    chip->LoadStateExt    = LoadStateExt;
1973
    chip->UnloadStateExt  = UnloadStateExt;
1974
    chip->SetStartAddress = SetStartAddress;
1975
    chip->SetSurfaces2D   = nv4SetSurfaces2D;
1976
    chip->SetSurfaces3D   = nv4SetSurfaces3D;
1977
    chip->LockUnlock      = nv4LockUnlock;
1978
}
1979
static void nv10GetConfig
1980
(
1981
    RIVA_HW_INST *chip
1982
)
1983
{
1984
    /*
1985
     * Fill in chip configuration.
1986
     */
1987
    switch ((chip->PFB[0x0000020C/4] >> 20) & 0x000000FF)
1988
    {
1989
        case 0x02:
1990
            chip->RamAmountKBytes = 1024 * 2;
1991
            break;
1992
        case 0x04:
1993
            chip->RamAmountKBytes = 1024 * 4;
1994
            break;
1995
        case 0x08:
1996
            chip->RamAmountKBytes = 1024 * 8;
1997
            break;
1998
        case 0x10:
1999
            chip->RamAmountKBytes = 1024 * 16;
2000
            break;
2001
        case 0x20:
2002
            chip->RamAmountKBytes = 1024 * 32;
2003
            break;
2004
        case 0x40:
2005
            chip->RamAmountKBytes = 1024 * 64;
2006
            break;
2007
        case 0x80:
2008
            chip->RamAmountKBytes = 1024 * 128;
2009
            break;
2010
        default:
2011
            chip->RamAmountKBytes = 1024 * 16;
2012
            break;
2013
    }
2014
    switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003)
2015
    {
2016
        case 3:
2017
            chip->RamBandwidthKBytesPerSec = 800000;
2018
            break;
2019
        default:
2020
            chip->RamBandwidthKBytesPerSec = 1000000;
2021
            break;
2022
    }
2023
    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
2024
#ifdef CONFIG_XBOX
2025
    /* CURSOR has to be set to mapped fb address space, cannot be done here */
2026
    chip->CursorStart      = (chip->RamAmountKBytes - 128) * 1024;
2027
    chip->CURSOR           = 0;
2028
#else
2029
    chip->CURSOR           = &(chip->PRAMIN[0x00010000/4 - 0x0800/4]);
2030
#endif
2031
    chip->CURSORPOS        = &(chip->PRAMDAC[0x0300/4]);
2032
    chip->VBLANKENABLE     = &(chip->PCRTC[0x0140/4]);
2033
    chip->VBLANK           = &(chip->PCRTC[0x0100/4]);
2034
    chip->VBlankBit        = 0x00000001;
2035
    chip->MaxVClockFreqKHz = 350000;
2036
    /*
2037
     * Set chip functions.
2038
     */
2039
    chip->Busy            = nv10Busy;
2040
    chip->ShowHideCursor  = ShowHideCursor;
2041
    chip->CalcStateExt    = CalcStateExt;
2042
    chip->LoadStateExt    = LoadStateExt;
2043
    chip->UnloadStateExt  = UnloadStateExt;
2044
    chip->SetStartAddress = SetStartAddress;
2045
    chip->SetSurfaces2D   = nv10SetSurfaces2D;
2046
    chip->SetSurfaces3D   = nv10SetSurfaces3D;
2047
    chip->LockUnlock      = nv10LockUnlock;
2048
}
2049
int RivaGetConfig
2050
(
2051
    RIVA_HW_INST *chip
2052
)
2053
{
2054
    /*
2055
     * Save this so future SW know whats it's dealing with.
2056
     */
2057
    chip->Version = RIVA_SW_VERSION;
2058
    /*
2059
     * Chip specific configuration.
2060
     */
2061
    switch (chip->Architecture)
2062
    {
2063
        case NV_ARCH_03:
2064
            nv3GetConfig(chip);
2065
            break;
2066
        case NV_ARCH_04:
2067
            nv4GetConfig(chip);
2068
            break;
2069
        case NV_ARCH_10:
2070
	case NV_ARCH_20:
2071
            nv10GetConfig(chip);
2072
            break;
2073
        default:
2074
            return (-1);
2075
    }
2076
    /*
2077
     * Fill in FIFO pointers.
2078
     */
2079
    chip->Rop    = (RivaRop                 *)&(chip->FIFO[0x00000000/4]);
2080
    chip->Clip   = (RivaClip                *)&(chip->FIFO[0x00002000/4]);
2081
    chip->Patt   = (RivaPattern             *)&(chip->FIFO[0x00004000/4]);
2082
    chip->Pixmap = (RivaPixmap              *)&(chip->FIFO[0x00006000/4]);
2083
    chip->Blt    = (RivaScreenBlt           *)&(chip->FIFO[0x00008000/4]);
2084
    chip->Bitmap = (RivaBitmap              *)&(chip->FIFO[0x0000A000/4]);
2085
    chip->Line   = (RivaLine                *)&(chip->FIFO[0x0000C000/4]);
2086
    chip->Tri03  = (RivaTexturedTriangle03  *)&(chip->FIFO[0x0000E000/4]);
2087
    return (0);
2088
}
2089
(-)linux-2.4.26/drivers/video/xbox/riva_hw.h (+490 lines)
Line 0 Link Here
1
/***************************************************************************\
2
|*                                                                           *|
3
|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
4
|*                                                                           *|
5
|*     NOTICE TO USER:   The source code  is copyrighted under  U.S. and     *|
6
|*     international laws.  Users and possessors of this source code are     *|
7
|*     hereby granted a nonexclusive,  royalty-free copyright license to     *|
8
|*     use this code in individual and commercial software.                  *|
9
|*                                                                           *|
10
|*     Any use of this source code must include,  in the user documenta-     *|
11
|*     tion and  internal comments to the code,  notices to the end user     *|
12
|*     as follows:                                                           *|
13
|*                                                                           *|
14
|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
15
|*                                                                           *|
16
|*     NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY     *|
17
|*     OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"     *|
18
|*     WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPOR-     *|
19
|*     ATION DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,     *|
20
|*     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE-     *|
21
|*     MENT,  AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL     *|
22
|*     NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCI-     *|
23
|*     DENTAL, OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RE-     *|
24
|*     SULTING FROM LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION     *|
25
|*     OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF     *|
26
|*     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.     *|
27
|*                                                                           *|
28
|*     U.S. Government  End  Users.   This source code  is a "commercial     *|
29
|*     item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),     *|
30
|*     consisting  of "commercial  computer  software"  and  "commercial     *|
31
|*     computer  software  documentation,"  as such  terms  are  used in     *|
32
|*     48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Govern-     *|
33
|*     ment only as  a commercial end item.   Consistent with  48 C.F.R.     *|
34
|*     12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),     *|
35
|*     all U.S. Government End Users  acquire the source code  with only     *|
36
|*     those rights set forth herein.                                        *|
37
|*                                                                           *|
38
\***************************************************************************/
39
40
/*
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
42
 * the documentation restriction above, to merely say that this nVidia's
43
 * copyright and disclaimer should be included with all code derived
44
 * from this source.  -- Jeff Garzik <jgarzik@mandrakesoft.com>, 01/Nov/99 
45
 */
46
47
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v 1.6 2000/02/08 17:19:12 dawes Exp $ */
48
#ifndef __RIVA_HW_H__
49
#define __RIVA_HW_H__
50
#define RIVA_SW_VERSION 0x00010003
51
52
#include <linux/config.h>
53
54
/*
55
 * Typedefs to force certain sized values.
56
 */
57
typedef unsigned char  U008;
58
typedef unsigned short U016;
59
typedef unsigned int   U032;
60
61
/*
62
 * HW access macros.
63
 */
64
#define NV_WR08(p,i,d)  (((U008 *)(p))[i]=(d))
65
#define NV_RD08(p,i)    (((U008 *)(p))[i])
66
#define NV_WR16(p,i,d)  (((U016 *)(p))[(i)/2]=(d))
67
#define NV_RD16(p,i)    (((U016 *)(p))[(i)/2])
68
#define NV_WR32(p,i,d)  (((U032 *)(p))[(i)/4]=(d))
69
#define NV_RD32(p,i)    (((U032 *)(p))[(i)/4])
70
#define VGA_WR08(p,i,d) NV_WR08(p,i,d)
71
#define VGA_RD08(p,i)   NV_RD08(p,i)
72
73
/*
74
 * Define supported architectures.
75
 */
76
#define NV_ARCH_03  0x03
77
#define NV_ARCH_04  0x04
78
#define NV_ARCH_10  0x10
79
#define NV_ARCH_20  0x20
80
81
/***************************************************************************\
82
*                                                                           *
83
*                             FIFO registers.                               *
84
*                                                                           *
85
\***************************************************************************/
86
87
/*
88
 * Raster OPeration. Windows style ROP3.
89
 */
90
typedef volatile struct
91
{
92
    U032 reserved00[4];
93
    U016 FifoFree;
94
    U016 Nop;
95
    U032 reserved01[0x0BB];
96
    U032 Rop3;
97
} RivaRop;
98
/*
99
 * 8X8 Monochrome pattern.
100
 */
101
typedef volatile struct
102
{
103
    U032 reserved00[4];
104
    U016 FifoFree;
105
    U016 Nop;
106
    U032 reserved01[0x0BD];
107
    U032 Shape;
108
    U032 reserved03[0x001];
109
    U032 Color0;
110
    U032 Color1;
111
    U032 Monochrome[2];
112
} RivaPattern;
113
/*
114
 * Scissor clip rectangle.
115
 */
116
typedef volatile struct
117
{
118
    U032 reserved00[4];
119
    U016 FifoFree;
120
    U016 Nop;
121
    U032 reserved01[0x0BB];
122
    U032 TopLeft;
123
    U032 WidthHeight;
124
} RivaClip;
125
/*
126
 * 2D filled rectangle.
127
 */
128
typedef volatile struct
129
{
130
    U032 reserved00[4];
131
    U016 FifoFree;
132
    U016 Nop[1];
133
    U032 reserved01[0x0BC];
134
    U032 Color;
135
    U032 reserved03[0x03E];
136
    U032 TopLeft;
137
    U032 WidthHeight;
138
} RivaRectangle;
139
/*
140
 * 2D screen-screen BLT.
141
 */
142
typedef volatile struct
143
{
144
    U032 reserved00[4];
145
    U016 FifoFree;
146
    U016 Nop;
147
    U032 reserved01[0x0BB];
148
    U032 TopLeftSrc;
149
    U032 TopLeftDst;
150
    U032 WidthHeight;
151
} RivaScreenBlt;
152
/*
153
 * 2D pixel BLT.
154
 */
155
typedef volatile struct
156
{
157
    U032 reserved00[4];
158
    U016 FifoFree;
159
    U016 Nop[1];
160
    U032 reserved01[0x0BC];
161
    U032 TopLeft;
162
    U032 WidthHeight;
163
    U032 WidthHeightIn;
164
    U032 reserved02[0x03C];
165
    U032 Pixels;
166
} RivaPixmap;
167
/*
168
 * Filled rectangle combined with monochrome expand.  Useful for glyphs.
169
 */
170
typedef volatile struct
171
{
172
    U032 reserved00[4];
173
    U016 FifoFree;
174
    U016 Nop;
175
    U032 reserved01[0x0BB];
176
    U032 reserved03[(0x040)-1];
177
    U032 Color1A;
178
    struct
179
    {
180
        U032 TopLeft;
181
        U032 WidthHeight;
182
    } UnclippedRectangle[64];
183
    U032 reserved04[(0x080)-3];
184
    struct
185
    {
186
        U032 TopLeft;
187
        U032 BottomRight;
188
    } ClipB;
189
    U032 Color1B;
190
    struct
191
    {
192
        U032 TopLeft;
193
        U032 BottomRight;
194
    } ClippedRectangle[64];
195
    U032 reserved05[(0x080)-5];
196
    struct
197
    {
198
        U032 TopLeft;
199
        U032 BottomRight;
200
    } ClipC;
201
    U032 Color1C;
202
    U032 WidthHeightC;
203
    U032 PointC;
204
    U032 MonochromeData1C;
205
    U032 reserved06[(0x080)+121];
206
    struct
207
    {
208
        U032 TopLeft;
209
        U032 BottomRight;
210
    } ClipD;
211
    U032 Color1D;
212
    U032 WidthHeightInD;
213
    U032 WidthHeightOutD;
214
    U032 PointD;
215
    U032 MonochromeData1D;
216
    U032 reserved07[(0x080)+120];
217
    struct
218
    {
219
        U032 TopLeft;
220
        U032 BottomRight;
221
    } ClipE;
222
    U032 Color0E;
223
    U032 Color1E;
224
    U032 WidthHeightInE;
225
    U032 WidthHeightOutE;
226
    U032 PointE;
227
    U032 MonochromeData01E;
228
} RivaBitmap;
229
/*
230
 * 3D textured, Z buffered triangle.
231
 */
232
typedef volatile struct
233
{
234
    U032 reserved00[4];
235
    U016 FifoFree;
236
    U016 Nop;
237
    U032 reserved01[0x0BC];
238
    U032 TextureOffset;
239
    U032 TextureFormat;
240
    U032 TextureFilter;
241
    U032 FogColor;
242
/* This is a problem on LynxOS */
243
#ifdef Control
244
#undef Control
245
#endif
246
    U032 Control;
247
    U032 AlphaTest;
248
    U032 reserved02[0x339];
249
    U032 FogAndIndex;
250
    U032 Color;
251
    float ScreenX;
252
    float ScreenY;
253
    float ScreenZ;
254
    float EyeM;
255
    float TextureS;
256
    float TextureT;
257
} RivaTexturedTriangle03;
258
typedef volatile struct
259
{
260
    U032 reserved00[4];
261
    U016 FifoFree;
262
    U016 Nop;
263
    U032 reserved01[0x0BB];
264
    U032 ColorKey;
265
    U032 TextureOffset;
266
    U032 TextureFormat;
267
    U032 TextureFilter;
268
    U032 Blend;
269
/* This is a problem on LynxOS */
270
#ifdef Control
271
#undef Control
272
#endif
273
    U032 Control;
274
    U032 FogColor;
275
    U032 reserved02[0x39];
276
    struct
277
    {
278
        float ScreenX;
279
        float ScreenY;
280
        float ScreenZ;
281
        float EyeM;
282
        U032 Color;
283
        U032 Specular;
284
        float TextureS;
285
        float TextureT;
286
    } Vertex[16];
287
    U032 DrawTriangle3D;
288
} RivaTexturedTriangle05;
289
/*
290
 * 2D line.
291
 */
292
typedef volatile struct
293
{
294
    U032 reserved00[4];
295
    U016 FifoFree;
296
    U016 Nop[1];
297
    U032 reserved01[0x0BC];
298
    U032 Color;             /* source color               0304-0307*/
299
    U032 Reserved02[0x03e];
300
    struct {                /* start aliased methods in array   0400-    */
301
        U032 point0;        /* y_x S16_S16 in pixels            0-   3*/
302
        U032 point1;        /* y_x S16_S16 in pixels            4-   7*/
303
    } Lin[16];              /* end of aliased methods in array      -047f*/
304
    struct {                /* start aliased methods in array   0480-    */
305
        U032 point0X;       /* in pixels, 0 at left                0-   3*/
306
        U032 point0Y;       /* in pixels, 0 at top                 4-   7*/
307
        U032 point1X;       /* in pixels, 0 at left                8-   b*/
308
        U032 point1Y;       /* in pixels, 0 at top                 c-   f*/
309
    } Lin32[8];             /* end of aliased methods in array      -04ff*/
310
    U032 PolyLin[32];       /* y_x S16_S16 in pixels         0500-057f*/
311
    struct {                /* start aliased methods in array   0580-    */
312
        U032 x;             /* in pixels, 0 at left                0-   3*/
313
        U032 y;             /* in pixels, 0 at top                 4-   7*/
314
    } PolyLin32[16];        /* end of aliased methods in array      -05ff*/
315
    struct {                /* start aliased methods in array   0600-    */
316
        U032 color;         /* source color                     0-   3*/
317
        U032 point;         /* y_x S16_S16 in pixels            4-   7*/
318
    } ColorPolyLin[16];     /* end of aliased methods in array      -067f*/
319
} RivaLine;
320
/*
321
 * 2D/3D surfaces
322
 */
323
typedef volatile struct
324
{
325
    U032 reserved00[4];
326
    U016 FifoFree;
327
    U016 Nop;
328
    U032 reserved01[0x0BE];
329
    U032 Offset;
330
} RivaSurface;
331
typedef volatile struct
332
{
333
    U032 reserved00[4];
334
    U016 FifoFree;
335
    U016 Nop;
336
    U032 reserved01[0x0BD];
337
    U032 Pitch;
338
    U032 RenderBufferOffset;
339
    U032 ZBufferOffset;
340
} RivaSurface3D;
341
    
342
/***************************************************************************\
343
*                                                                           *
344
*                        Virtualized RIVA H/W interface.                    *
345
*                                                                           *
346
\***************************************************************************/
347
348
struct _riva_hw_inst;
349
struct _riva_hw_state;
350
/*
351
 * Virtialized chip interface. Makes RIVA 128 and TNT look alike.
352
 */
353
typedef struct _riva_hw_inst
354
{
355
    /*
356
     * Chip specific settings.
357
     */
358
    U032 Architecture;
359
    U032 Version;
360
    U032 CrystalFreqKHz;
361
    U032 RamAmountKBytes;
362
    U032 MaxVClockFreqKHz;
363
    U032 RamBandwidthKBytesPerSec;
364
    U032 EnableIRQ;
365
    U032 IO;
366
    U032 VBlankBit;
367
    U032 FifoFreeCount;
368
    U032 FifoEmptyCount;
369
#ifdef CONFIG_XBOX
370
    U032 CursorStart;
371
#endif
372
    /*
373
     * Non-FIFO registers.
374
     */
375
    volatile U032 *PCRTC;
376
    volatile U032 *PRAMDAC;
377
    volatile U032 *PFB;
378
    volatile U032 *PFIFO;
379
    volatile U032 *PGRAPH;
380
    volatile U032 *PEXTDEV;
381
    volatile U032 *PTIMER;
382
    volatile U032 *PMC;
383
    volatile U032 *PRAMIN;
384
    volatile U032 *FIFO;
385
    volatile U032 *CURSOR;
386
    volatile U032 *CURSORPOS;
387
    volatile U032 *VBLANKENABLE;
388
    volatile U032 *VBLANK;
389
    volatile U008 *PCIO;
390
    volatile U008 *PVIO;
391
    volatile U008 *PDIO;
392
    /*
393
     * Common chip functions.
394
     */
395
    int  (*Busy)(struct _riva_hw_inst *);
396
    void (*CalcStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *,int,int,int,int,int);
397
    void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
398
    void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
399
    void (*SetStartAddress)(struct _riva_hw_inst *,U032);
400
    void (*SetSurfaces2D)(struct _riva_hw_inst *,U032,U032);
401
    void (*SetSurfaces3D)(struct _riva_hw_inst *,U032,U032);
402
    int  (*ShowHideCursor)(struct _riva_hw_inst *,int);
403
    void (*LockUnlock)(struct _riva_hw_inst *, int);
404
    /*
405
     * Current extended mode settings.
406
     */
407
    struct _riva_hw_state *CurrentState;
408
    /*
409
     * FIFO registers.
410
     */
411
    RivaRop                 *Rop;
412
    RivaPattern             *Patt;
413
    RivaClip                *Clip;
414
    RivaPixmap              *Pixmap;
415
    RivaScreenBlt           *Blt;
416
    RivaBitmap              *Bitmap;
417
    RivaLine                *Line;
418
    RivaTexturedTriangle03  *Tri03;
419
    RivaTexturedTriangle05  *Tri05;
420
} RIVA_HW_INST;
421
/*
422
 * Extended mode state information.
423
 */
424
typedef struct _riva_hw_state
425
{
426
    U032 bpp;
427
    U032 width;
428
    U032 height;
429
    U032 interlace;
430
    U032 repaint0;
431
    U032 repaint1;
432
    U032 screen;
433
    U032 extra;
434
    U032 pixel;
435
    U032 horiz;
436
    U032 arbitration0;
437
    U032 arbitration1;
438
    U032 vpll;
439
    U032 pllsel;
440
    U032 general;
441
    U032 config;
442
    U032 cursor0;
443
    U032 cursor1;
444
    U032 cursor2;
445
    U032 offset0;
446
    U032 offset1;
447
    U032 offset2;
448
    U032 offset3;
449
    U032 pitch0;
450
    U032 pitch1;
451
    U032 pitch2;
452
    U032 pitch3;
453
#ifdef CONFIG_XBOX
454
    U032 fb_start;
455
	U032 vend;
456
	U032 vtotal;
457
	U032 vcrtc;
458
	U032 vsyncstart;
459
	U032 vsyncend;
460
	U032 vvalidstart;
461
	U032 vvalidend;
462
	U032 hend;
463
	U032 htotal;
464
	U032 hcrtc;
465
	U032 hsyncstart;
466
	U032 hsyncend;
467
	U032 hvalidstart;
468
	U032 hvalidend;
469
	U032 crtchdispend;
470
	U032 crtcvstart;
471
	U032 crtcvtotal;
472
	U032 checksum;
473
#endif
474
} RIVA_HW_STATE;
475
/*
476
 * External routines.
477
 */
478
int RivaGetConfig(RIVA_HW_INST *);
479
/*
480
 * FIFO Free Count. Should attempt to yield processor if RIVA is busy.
481
 */
482
483
#define RIVA_FIFO_FREE(hwinst,hwptr,cnt)                           \
484
{                                                                  \
485
   while ((hwinst).FifoFreeCount < (cnt))                          \
486
	(hwinst).FifoFreeCount = (hwinst).hwptr->FifoFree >> 2;        \
487
   (hwinst).FifoFreeCount -= (cnt);                                \
488
}
489
#endif /* __RIVA_HW_H__ */
490
(-)linux-2.4.26/drivers/video/xbox/riva_tbl.h (+961 lines)
Line 0 Link Here
1
 /***************************************************************************\
2
|*                                                                           *|
3
|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
4
|*                                                                           *|
5
|*     NOTICE TO USER:   The source code  is copyrighted under  U.S. and     *|
6
|*     international laws.  Users and possessors of this source code are     *|
7
|*     hereby granted a nonexclusive,  royalty-free copyright license to     *|
8
|*     use this code in individual and commercial software.                  *|
9
|*                                                                           *|
10
|*     Any use of this source code must include,  in the user documenta-     *|
11
|*     tion and  internal comments to the code,  notices to the end user     *|
12
|*     as follows:                                                           *|
13
|*                                                                           *|
14
|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
15
|*                                                                           *|
16
|*     NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY     *|
17
|*     OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"     *|
18
|*     WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPOR-     *|
19
|*     ATION DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,     *|
20
|*     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE-     *|
21
|*     MENT,  AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL     *|
22
|*     NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCI-     *|
23
|*     DENTAL, OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RE-     *|
24
|*     SULTING FROM LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION     *|
25
|*     OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF     *|
26
|*     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.     *|
27
|*                                                                           *|
28
|*     U.S. Government  End  Users.   This source code  is a "commercial     *|
29
|*     item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),     *|
30
|*     consisting  of "commercial  computer  software"  and  "commercial     *|
31
|*     computer  software  documentation,"  as such  terms  are  used in     *|
32
|*     48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Govern-     *|
33
|*     ment only as  a commercial end item.   Consistent with  48 C.F.R.     *|
34
|*     12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),     *|
35
|*     all U.S. Government End Users  acquire the source code  with only     *|
36
|*     those rights set forth herein.                                        *|
37
|*                                                                           *|
38
 \***************************************************************************/
39
40
/*
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
42
 * the documentation restriction above, to merely say that this nVidia's
43
 * copyright and disclaimer should be included with all code derived
44
 * from this source.  -- Jeff Garzik <jgarzik@mandrakesoft.com>, 01/Nov/99 
45
 */
46
47
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h,v 1.5 2000/02/08 17:19:12 dawes Exp $ */
48
/*
49
 * RIVA Fixed Functionality Init Tables.
50
 */
51
static unsigned RivaTablePMC[][2] =
52
{
53
    {0x00000050, 0x00000000},
54
    {0x00000080, 0xFFFF00FF},
55
    {0x00000080, 0xFFFFFFFF}
56
};
57
static unsigned RivaTablePTIMER[][2] =
58
{
59
    {0x00000080, 0x00000008},
60
    {0x00000084, 0x00000003},
61
    {0x00000050, 0x00000000},
62
    {0x00000040, 0xFFFFFFFF}
63
};
64
static unsigned RivaTableFIFO[][2] =
65
{
66
    {0x00000000, 0x80000000},
67
    {0x00000800, 0x80000001},
68
    {0x00001000, 0x80000002},
69
    {0x00001800, 0x80000010},
70
    {0x00002000, 0x80000011},
71
    {0x00002800, 0x80000012},
72
    {0x00003000, 0x80000016},
73
    {0x00003800, 0x80000013}
74
};
75
static unsigned nv3TablePFIFO[][2] =
76
{
77
    {0x00000140, 0x00000000},
78
    {0x00000480, 0x00000000},
79
    {0x00000490, 0x00000000},
80
    {0x00000494, 0x00000000},
81
    {0x00000481, 0x00000000},
82
    {0x00000084, 0x00000000},
83
    {0x00000086, 0x00002000},
84
    {0x00000085, 0x00002200},
85
    {0x00000484, 0x00000000},
86
    {0x0000049C, 0x00000000},
87
    {0x00000104, 0x00000000},
88
    {0x00000108, 0x00000000},
89
    {0x00000100, 0x00000000},
90
    {0x000004A0, 0x00000000},
91
    {0x000004A4, 0x00000000},
92
    {0x000004A8, 0x00000000},
93
    {0x000004AC, 0x00000000},
94
    {0x000004B0, 0x00000000},
95
    {0x000004B4, 0x00000000},
96
    {0x000004B8, 0x00000000},
97
    {0x000004BC, 0x00000000},
98
    {0x00000050, 0x00000000},
99
    {0x00000040, 0xFFFFFFFF},
100
    {0x00000480, 0x00000001},
101
    {0x00000490, 0x00000001},
102
    {0x00000140, 0x00000001}
103
};
104
static unsigned nv3TablePGRAPH[][2] =
105
{
106
    {0x00000020, 0x1230001F},
107
    {0x00000021, 0x10113000},
108
    {0x00000022, 0x1131F101},
109
    {0x00000023, 0x0100F531},
110
    {0x00000060, 0x00000000},
111
    {0x00000065, 0x00000000},
112
    {0x00000068, 0x00000000},
113
    {0x00000069, 0x00000000},
114
    {0x0000006A, 0x00000000},
115
    {0x0000006B, 0x00000000},
116
    {0x0000006C, 0x00000000},
117
    {0x0000006D, 0x00000000},
118
    {0x0000006E, 0x00000000},
119
    {0x0000006F, 0x00000000},
120
    {0x000001A8, 0x00000000},
121
    {0x00000440, 0xFFFFFFFF},
122
    {0x00000480, 0x00000001},
123
    {0x000001A0, 0x00000000},
124
    {0x000001A2, 0x00000000},
125
    {0x0000018A, 0xFFFFFFFF},
126
    {0x00000190, 0x00000000},
127
    {0x00000142, 0x00000000},
128
    {0x00000154, 0x00000000},
129
    {0x00000155, 0xFFFFFFFF},
130
    {0x00000156, 0x00000000},
131
    {0x00000157, 0xFFFFFFFF},
132
    {0x00000064, 0x10010002},
133
    {0x00000050, 0x00000000},
134
    {0x00000051, 0x00000000},
135
    {0x00000040, 0xFFFFFFFF},
136
    {0x00000041, 0xFFFFFFFF},
137
    {0x00000440, 0xFFFFFFFF},
138
    {0x000001A9, 0x00000001}
139
};
140
static unsigned nv3TablePGRAPH_8BPP[][2] =
141
{
142
    {0x000001AA, 0x00001111}
143
};
144
static unsigned nv3TablePGRAPH_15BPP[][2] =
145
{
146
    {0x000001AA, 0x00002222}
147
};
148
static unsigned nv3TablePGRAPH_32BPP[][2] =
149
{
150
    {0x000001AA, 0x00003333}
151
};
152
static unsigned nv3TablePRAMIN[][2] =
153
{
154
    {0x00000500, 0x00010000},
155
    {0x00000501, 0x007FFFFF},
156
    {0x00000200, 0x80000000},
157
    {0x00000201, 0x00C20341},
158
    {0x00000204, 0x80000001},
159
    {0x00000205, 0x00C50342},
160
    {0x00000208, 0x80000002},
161
    {0x00000209, 0x00C60343},
162
    {0x0000020C, 0x80000003},
163
    {0x0000020D, 0x00DC0348},
164
    {0x00000210, 0x80000004},
165
    {0x00000211, 0x00DC0349},
166
    {0x00000214, 0x80000005},
167
    {0x00000215, 0x00DC034A},
168
    {0x00000218, 0x80000006},
169
    {0x00000219, 0x00DC034B},
170
    {0x00000240, 0x80000010},
171
    {0x00000241, 0x00D10344},
172
    {0x00000244, 0x80000011},
173
    {0x00000245, 0x00D00345},
174
    {0x00000248, 0x80000012},
175
    {0x00000249, 0x00CC0346},
176
    {0x0000024C, 0x80000013},
177
    {0x0000024D, 0x00D70347},
178
    {0x00000D05, 0x00000000},
179
    {0x00000D06, 0x00000000},
180
    {0x00000D07, 0x00000000},
181
    {0x00000D09, 0x00000000},
182
    {0x00000D0A, 0x00000000},
183
    {0x00000D0B, 0x00000000},
184
    {0x00000D0D, 0x00000000},
185
    {0x00000D0E, 0x00000000},
186
    {0x00000D0F, 0x00000000},
187
    {0x00000D11, 0x00000000},
188
    {0x00000D12, 0x00000000},
189
    {0x00000D13, 0x00000000},
190
    {0x00000D15, 0x00000000},
191
    {0x00000D16, 0x00000000},
192
    {0x00000D17, 0x00000000},
193
    {0x00000D19, 0x00000000},
194
    {0x00000D1A, 0x00000000},
195
    {0x00000D1B, 0x00000000},
196
    {0x00000D1D, 0x00000140},
197
    {0x00000D1E, 0x00000000},
198
    {0x00000D1F, 0x00000000},
199
    {0x00000D20, 0x10100200},
200
    {0x00000D21, 0x00000000},
201
    {0x00000D22, 0x00000000},
202
    {0x00000D23, 0x00000000},
203
    {0x00000D24, 0x10210200},
204
    {0x00000D25, 0x00000000},
205
    {0x00000D26, 0x00000000},
206
    {0x00000D27, 0x00000000},
207
    {0x00000D28, 0x10420200},
208
    {0x00000D29, 0x00000000},
209
    {0x00000D2A, 0x00000000},
210
    {0x00000D2B, 0x00000000},
211
    {0x00000D2C, 0x10830200},
212
    {0x00000D2D, 0x00000000},
213
    {0x00000D2E, 0x00000000},
214
    {0x00000D2F, 0x00000000} 
215
};
216
static unsigned nv3TablePRAMIN_8BPP[][2] =
217
{
218
    /*           0xXXXXX3XX For  MSB mono format */
219
    /*           0xXXXXX2XX For  LSB mono format */
220
    {0x00000D04, 0x10110203},
221
    {0x00000D08, 0x10110203},
222
    {0x00000D0C, 0x1011020B},
223
    {0x00000D10, 0x10118203},
224
    {0x00000D14, 0x10110203},
225
    {0x00000D18, 0x10110203},
226
    {0x00000D1C, 0x10419208}
227
};
228
static unsigned nv3TablePRAMIN_15BPP[][2] =
229
{
230
    /*           0xXXXXX2XX For  MSB mono format */
231
    /*           0xXXXXX3XX For  LSB mono format */
232
    {0x00000D04, 0x10110200},
233
    {0x00000D08, 0x10110200},
234
    {0x00000D0C, 0x10110208},
235
    {0x00000D10, 0x10118200},
236
    {0x00000D14, 0x10110200},
237
    {0x00000D18, 0x10110200},
238
    {0x00000D1C, 0x10419208}
239
};
240
static unsigned nv3TablePRAMIN_32BPP[][2] =
241
{
242
    /*           0xXXXXX3XX For  MSB mono format */
243
    /*           0xXXXXX2XX For  LSB mono format */
244
    {0x00000D04, 0x10110201},
245
    {0x00000D08, 0x10110201},
246
    {0x00000D0C, 0x10110209},
247
    {0x00000D10, 0x10118201},
248
    {0x00000D14, 0x10110201},
249
    {0x00000D18, 0x10110201},
250
    {0x00000D1C, 0x10419208}
251
};
252
static unsigned nv4TableFIFO[][2] =
253
{
254
    {0x00003800, 0x80000014}
255
};
256
static unsigned nv4TablePFIFO[][2] =
257
{
258
    {0x00000140, 0x00000000},
259
    {0x00000480, 0x00000000},
260
    {0x00000494, 0x00000000},
261
    {0x00000481, 0x00000000},
262
    {0x0000048B, 0x00000000},
263
    {0x00000400, 0x00000000},
264
    {0x00000414, 0x00000000},
265
    {0x00000084, 0x03000100},  
266
    {0x00000085, 0x00000110},
267
    {0x00000086, 0x00000112},  
268
    {0x00000143, 0x0000FFFF},
269
    {0x00000496, 0x0000FFFF},
270
    {0x00000050, 0x00000000},
271
    {0x00000040, 0xFFFFFFFF},
272
    {0x00000415, 0x00000001},
273
    {0x00000480, 0x00000001},
274
    {0x00000494, 0x00000001},
275
    {0x00000495, 0x00000001},
276
    {0x00000140, 0x00000001}
277
};
278
static unsigned nv4TablePGRAPH[][2] =
279
{
280
    {0x00000020, 0x1231C001},
281
    {0x00000021, 0x72111101},
282
    {0x00000022, 0x11D5F071},
283
    {0x00000023, 0x10D4FF31},
284
    {0x00000060, 0x00000000},
285
    {0x00000068, 0x00000000},
286
    {0x00000070, 0x00000000},
287
    {0x00000078, 0x00000000},
288
    {0x00000061, 0x00000000},
289
    {0x00000069, 0x00000000},
290
    {0x00000071, 0x00000000},
291
    {0x00000079, 0x00000000},
292
    {0x00000062, 0x00000000},
293
    {0x0000006A, 0x00000000},
294
    {0x00000072, 0x00000000},
295
    {0x0000007A, 0x00000000},
296
    {0x00000063, 0x00000000},
297
    {0x0000006B, 0x00000000},
298
    {0x00000073, 0x00000000},
299
    {0x0000007B, 0x00000000},
300
    {0x00000064, 0x00000000},
301
    {0x0000006C, 0x00000000},
302
    {0x00000074, 0x00000000},
303
    {0x0000007C, 0x00000000},
304
    {0x00000065, 0x00000000},
305
    {0x0000006D, 0x00000000},
306
    {0x00000075, 0x00000000},
307
    {0x0000007D, 0x00000000},
308
    {0x00000066, 0x00000000},
309
    {0x0000006E, 0x00000000},
310
    {0x00000076, 0x00000000},
311
    {0x0000007E, 0x00000000},
312
    {0x00000067, 0x00000000},
313
    {0x0000006F, 0x00000000},
314
    {0x00000077, 0x00000000},
315
    {0x0000007F, 0x00000000},
316
    {0x00000058, 0x00000000},
317
    {0x00000059, 0x00000000},
318
    {0x0000005A, 0x00000000},
319
    {0x0000005B, 0x00000000},
320
    {0x00000196, 0x00000000},
321
    {0x000001A1, 0x01FFFFFF},
322
    {0x00000197, 0x00000000},
323
    {0x000001A2, 0x01FFFFFF},
324
    {0x00000198, 0x00000000},
325
    {0x000001A3, 0x01FFFFFF},
326
    {0x00000199, 0x00000000},
327
    {0x000001A4, 0x01FFFFFF},
328
    {0x00000050, 0x00000000},
329
    {0x00000040, 0xFFFFFFFF},
330
    {0x0000005C, 0x10010100},
331
    {0x000001C4, 0xFFFFFFFF},
332
    {0x000001C8, 0x00000001},
333
    {0x00000204, 0x00000000},
334
    {0x000001C3, 0x00000001}
335
};
336
static unsigned nv4TablePGRAPH_8BPP[][2] =
337
{
338
    {0x000001C9, 0x00111111},
339
    {0x00000186, 0x00001010},
340
    {0x0000020C, 0x03020202}
341
};
342
static unsigned nv4TablePGRAPH_15BPP[][2] =
343
{
344
    {0x000001C9, 0x00226222},
345
    {0x00000186, 0x00002071},
346
    {0x0000020C, 0x09080808}
347
};
348
static unsigned nv4TablePGRAPH_16BPP[][2] =
349
{
350
    {0x000001C9, 0x00556555},
351
    {0x00000186, 0x000050C2},
352
    {0x0000020C, 0x0C0B0B0B}
353
};
354
static unsigned nv4TablePGRAPH_32BPP[][2] =
355
{
356
    {0x000001C9, 0x0077D777},
357
    {0x00000186, 0x000070E5},
358
    {0x0000020C, 0x0E0D0D0D}
359
};
360
static unsigned nv4TablePRAMIN[][2] =
361
{
362
    {0x00000000, 0x80000010},
363
    {0x00000001, 0x80011145},
364
    {0x00000002, 0x80000011},
365
    {0x00000003, 0x80011146},
366
    {0x00000004, 0x80000012},
367
    {0x00000005, 0x80011147},
368
    {0x00000006, 0x80000013},
369
    {0x00000007, 0x80011148},
370
    {0x00000008, 0x80000014},
371
    {0x00000009, 0x80011149},
372
    {0x0000000A, 0x80000015},
373
    {0x0000000B, 0x8001114A},
374
    {0x00000020, 0x80000000},
375
    {0x00000021, 0x80011142},
376
    {0x00000022, 0x80000001},
377
    {0x00000023, 0x80011143},
378
    {0x00000024, 0x80000002},
379
    {0x00000025, 0x80011144}, 
380
    {0x00000026, 0x80000003},
381
    {0x00000027, 0x8001114B},
382
    {0x00000028, 0x80000004},
383
    {0x00000029, 0x8001114C},
384
    {0x0000002A, 0x80000005},
385
    {0x0000002B, 0x8001114D},
386
    {0x0000002C, 0x80000006},
387
    {0x0000002D, 0x8001114E},
388
    {0x00000500, 0x00003000},
389
    {0x00000501, 0x01FFFFFF},
390
    {0x00000502, 0x00000002},
391
    {0x00000503, 0x00000002},
392
    {0x00000508, 0x01008043},
393
    {0x0000050A, 0x00000000},
394
    {0x0000050B, 0x00000000},
395
    {0x0000050C, 0x01008019},
396
    {0x0000050E, 0x00000000},
397
    {0x0000050F, 0x00000000},
398
#if 1
399
    {0x00000510, 0x01008018},
400
#else
401
    {0x00000510, 0x01008044},
402
#endif
403
    {0x00000512, 0x00000000},
404
    {0x00000513, 0x00000000},
405
    {0x00000514, 0x01008021},
406
    {0x00000516, 0x00000000},
407
    {0x00000517, 0x00000000},
408
    {0x00000518, 0x0100805F},
409
    {0x0000051A, 0x00000000},
410
    {0x0000051B, 0x00000000},
411
#if 1
412
    {0x0000051C, 0x0100804B},
413
#else
414
    {0x0000051C, 0x0100804A},
415
#endif
416
    {0x0000051E, 0x00000000},
417
    {0x0000051F, 0x00000000},
418
    {0x00000520, 0x0100A048},
419
    {0x00000521, 0x00000D01},
420
    {0x00000522, 0x11401140},
421
    {0x00000523, 0x00000000},
422
    {0x00000524, 0x0300A054},
423
    {0x00000525, 0x00000D01},
424
    {0x00000526, 0x11401140},
425
    {0x00000527, 0x00000000},
426
    {0x00000528, 0x0300A055},
427
    {0x00000529, 0x00000D01},
428
    {0x0000052A, 0x11401140},
429
    {0x0000052B, 0x00000000},
430
    {0x0000052C, 0x00000058},
431
    {0x0000052E, 0x11401140},
432
    {0x0000052F, 0x00000000},
433
    {0x00000530, 0x00000059},
434
    {0x00000532, 0x11401140},
435
    {0x00000533, 0x00000000},
436
    {0x00000534, 0x0000005A},
437
    {0x00000536, 0x11401140},
438
    {0x00000537, 0x00000000},
439
    {0x00000538, 0x0000005B},
440
    {0x0000053A, 0x11401140},
441
    {0x0000053B, 0x00000000} 
442
};
443
static unsigned nv4TablePRAMIN_8BPP[][2] =
444
{
445
    /*           0xXXXXXX01 For  MSB mono format */
446
    /*           0xXXXXXX02 For  LSB mono format */
447
    {0x00000509, 0x00000302},
448
    {0x0000050D, 0x00000302},
449
    {0x00000511, 0x00000202},
450
    {0x00000515, 0x00000302},
451
    {0x00000519, 0x00000302},
452
    {0x0000051D, 0x00000302},
453
    {0x0000052D, 0x00000302},
454
    {0x0000052E, 0x00000302},
455
    {0x00000535, 0x00000000},
456
    {0x00000539, 0x00000000} 
457
};
458
static unsigned nv4TablePRAMIN_15BPP[][2] =
459
{
460
    /*           0xXXXXXX01 For  MSB mono format */
461
    /*           0xXXXXXX02 For  LSB mono format */
462
    {0x00000509, 0x00000902},
463
    {0x0000050D, 0x00000902},
464
    {0x00000511, 0x00000802},
465
    {0x00000515, 0x00000902},
466
    {0x00000519, 0x00000902},
467
    {0x0000051D, 0x00000902},
468
    {0x0000052D, 0x00000902},
469
    {0x0000052E, 0x00000902},
470
    {0x00000535, 0x00000702},
471
    {0x00000539, 0x00000702} 
472
};
473
static unsigned nv4TablePRAMIN_16BPP[][2] =
474
{
475
    /*           0xXXXXXX01 For  MSB mono format */
476
    /*           0xXXXXXX02 For  LSB mono format */
477
    {0x00000509, 0x00000C02},
478
    {0x0000050D, 0x00000C02},
479
    {0x00000511, 0x00000B02},
480
    {0x00000515, 0x00000C02},
481
    {0x00000519, 0x00000C02},
482
    {0x0000051D, 0x00000C02},
483
    {0x0000052D, 0x00000C02},
484
    {0x0000052E, 0x00000C02},
485
    {0x00000535, 0x00000702},
486
    {0x00000539, 0x00000702} 
487
};
488
static unsigned nv4TablePRAMIN_32BPP[][2] =
489
{
490
    /*           0xXXXXXX01 For  MSB mono format */
491
    /*           0xXXXXXX02 For  LSB mono format */
492
    {0x00000509, 0x00000E02},
493
    {0x0000050D, 0x00000E02},
494
    {0x00000511, 0x00000D02},
495
    {0x00000515, 0x00000E02},
496
    {0x00000519, 0x00000E02},
497
    {0x0000051D, 0x00000E02},
498
    {0x0000052D, 0x00000E02},
499
    {0x0000052E, 0x00000E02},
500
    {0x00000535, 0x00000E02},
501
    {0x00000539, 0x00000E02} 
502
};
503
static unsigned nv10TableFIFO[][2] =
504
{
505
    {0x00003800, 0x80000014}
506
};
507
static unsigned nv10TablePFIFO[][2] =
508
{
509
    {0x00000140, 0x00000000},
510
    {0x00000480, 0x00000000},
511
    {0x00000494, 0x00000000},
512
    {0x00000481, 0x00000000},
513
    {0x0000048B, 0x00000000},
514
    {0x00000400, 0x00000000},
515
    {0x00000414, 0x00000000},
516
    {0x00000084, 0x03000100},
517
    {0x00000085, 0x00000110},
518
    {0x00000086, 0x00000112},
519
    {0x00000143, 0x0000FFFF},
520
    {0x00000496, 0x0000FFFF},
521
    {0x00000050, 0x00000000},
522
    {0x00000040, 0xFFFFFFFF},
523
    {0x00000415, 0x00000001},
524
    {0x00000480, 0x00000001},
525
    {0x00000494, 0x00000001},
526
    {0x00000495, 0x00000001},
527
    {0x00000140, 0x00000001}
528
};
529
static unsigned nv10TablePGRAPH[][2] =
530
{
531
    {0x00000020, 0x0003FFFF},
532
    {0x00000021, 0x00118701},
533
    {0x00000022, 0x24F82AD9},
534
    {0x00000023, 0x55DE0030},
535
    {0x00000020, 0x00000000},
536
    {0x00000024, 0x00000000},
537
    {0x00000058, 0x00000000},
538
    {0x00000060, 0x00000000},
539
    {0x00000068, 0x00000000},
540
    {0x00000070, 0x00000000},
541
    {0x00000078, 0x00000000},
542
    {0x00000059, 0x00000000},
543
    {0x00000061, 0x00000000},
544
    {0x00000069, 0x00000000},
545
    {0x00000071, 0x00000000},
546
    {0x00000079, 0x00000000},
547
    {0x0000005A, 0x00000000},
548
    {0x00000062, 0x00000000},
549
    {0x0000006A, 0x00000000},
550
    {0x00000072, 0x00000000},
551
    {0x0000007A, 0x00000000},
552
    {0x0000005B, 0x00000000},
553
    {0x00000063, 0x00000000},
554
    {0x0000006B, 0x00000000},
555
    {0x00000073, 0x00000000},
556
    {0x0000007B, 0x00000000},
557
    {0x0000005C, 0x00000000},
558
    {0x00000064, 0x00000000},
559
    {0x0000006C, 0x00000000},
560
    {0x00000074, 0x00000000},
561
    {0x0000007C, 0x00000000},
562
    {0x0000005D, 0x00000000},
563
    {0x00000065, 0x00000000},
564
    {0x0000006D, 0x00000000},
565
    {0x00000075, 0x00000000},
566
    {0x0000007D, 0x00000000},
567
    {0x0000005E, 0x00000000},
568
    {0x00000066, 0x00000000},
569
    {0x0000006E, 0x00000000},
570
    {0x00000076, 0x00000000},
571
    {0x0000007E, 0x00000000},
572
    {0x0000005F, 0x00000000},
573
    {0x00000067, 0x00000000},
574
    {0x0000006F, 0x00000000},
575
    {0x00000077, 0x00000000},
576
    {0x0000007F, 0x00000000},
577
    {0x00000053, 0x00000000},
578
    {0x00000054, 0x00000000},
579
    {0x00000055, 0x00000000},
580
    {0x00000056, 0x00000000},
581
    {0x00000057, 0x00000000},
582
    {0x00000196, 0x00000000},
583
    {0x000001A1, 0x01FFFFFF},
584
    {0x00000197, 0x00000000},
585
    {0x000001A2, 0x01FFFFFF},
586
    {0x00000198, 0x00000000},
587
    {0x000001A3, 0x01FFFFFF},
588
    {0x00000199, 0x00000000},
589
    {0x000001A4, 0x01FFFFFF},
590
    {0x0000019A, 0x00000000},
591
    {0x000001A5, 0x01FFFFFF},
592
    {0x0000019B, 0x00000000},
593
    {0x000001A6, 0x01FFFFFF},
594
    {0x00000050, 0x01111111},
595
    {0x00000040, 0xFFFFFFFF},
596
    {0x00000051, 0x10010100},
597
    {0x000001C5, 0xFFFFFFFF},
598
    {0x000001C8, 0x00000001},
599
    {0x00000204, 0x00000000},
600
    {0x000001C4, 0x00000001}
601
};
602
static unsigned nv10TablePGRAPH_8BPP[][2] =
603
{
604
    {0x000001C9, 0x00111111},
605
    {0x00000186, 0x00001010},
606
    {0x0000020C, 0x03020202}
607
};
608
static unsigned nv10TablePGRAPH_15BPP[][2] =
609
{
610
    {0x000001C9, 0x00226222},
611
    {0x00000186, 0x00002071},
612
    {0x0000020C, 0x09080808}
613
};
614
static unsigned nv10TablePGRAPH_16BPP[][2] =
615
{
616
    {0x000001C9, 0x00556555},
617
    {0x00000186, 0x000050C2},
618
    {0x0000020C, 0x000B0B0C}
619
};
620
static unsigned nv10TablePGRAPH_32BPP[][2] =
621
{
622
    {0x000001C9, 0x0077D777},
623
    {0x00000186, 0x000070E5},
624
    {0x0000020C, 0x0E0D0D0D}
625
};
626
static unsigned nv10tri05TablePGRAPH[][2] =
627
{
628
    {(0x00000E00/4), 0x00000000},
629
    {(0x00000E04/4), 0x00000000},
630
    {(0x00000E08/4), 0x00000000},
631
    {(0x00000E0C/4), 0x00000000},
632
    {(0x00000E10/4), 0x00001000},
633
    {(0x00000E14/4), 0x00001000},
634
    {(0x00000E18/4), 0x4003ff80},
635
    {(0x00000E1C/4), 0x00000000},
636
    {(0x00000E20/4), 0x00000000},
637
    {(0x00000E24/4), 0x00000000},
638
    {(0x00000E28/4), 0x00000000},
639
    {(0x00000E2C/4), 0x00000000},
640
    {(0x00000E30/4), 0x00080008},
641
    {(0x00000E34/4), 0x00080008},
642
    {(0x00000E38/4), 0x00000000},
643
    {(0x00000E3C/4), 0x00000000},
644
    {(0x00000E40/4), 0x00000000},
645
    {(0x00000E44/4), 0x00000000},
646
    {(0x00000E48/4), 0x00000000},
647
    {(0x00000E4C/4), 0x00000000},
648
    {(0x00000E50/4), 0x00000000},
649
    {(0x00000E54/4), 0x00000000},
650
    {(0x00000E58/4), 0x00000000},
651
    {(0x00000E5C/4), 0x00000000},
652
    {(0x00000E60/4), 0x00000000},
653
    {(0x00000E64/4), 0x10000000},
654
    {(0x00000E68/4), 0x00000000},
655
    {(0x00000E6C/4), 0x00000000},
656
    {(0x00000E70/4), 0x00000000},
657
    {(0x00000E74/4), 0x00000000},
658
    {(0x00000E78/4), 0x00000000},
659
    {(0x00000E7C/4), 0x00000000},
660
    {(0x00000E80/4), 0x00000000},
661
    {(0x00000E84/4), 0x00000000},
662
    {(0x00000E88/4), 0x08000000},
663
    {(0x00000E8C/4), 0x00000000},
664
    {(0x00000E90/4), 0x00000000},
665
    {(0x00000E94/4), 0x00000000},
666
    {(0x00000E98/4), 0x00000000},
667
    {(0x00000E9C/4), 0x4B7FFFFF},
668
    {(0x00000EA0/4), 0x00000000},
669
    {(0x00000EA4/4), 0x00000000},
670
    {(0x00000EA8/4), 0x00000000},
671
    {(0x00000F00/4), 0x07FF0800},
672
    {(0x00000F04/4), 0x07FF0800},
673
    {(0x00000F08/4), 0x07FF0800},
674
    {(0x00000F0C/4), 0x07FF0800},
675
    {(0x00000F10/4), 0x07FF0800},
676
    {(0x00000F14/4), 0x07FF0800},
677
    {(0x00000F18/4), 0x07FF0800},
678
    {(0x00000F1C/4), 0x07FF0800},
679
    {(0x00000F20/4), 0x07FF0800},
680
    {(0x00000F24/4), 0x07FF0800},
681
    {(0x00000F28/4), 0x07FF0800},
682
    {(0x00000F2C/4), 0x07FF0800},
683
    {(0x00000F30/4), 0x07FF0800},
684
    {(0x00000F34/4), 0x07FF0800},
685
    {(0x00000F38/4), 0x07FF0800},
686
    {(0x00000F3C/4), 0x07FF0800},
687
    {(0x00000F40/4), 0x10000000},
688
    {(0x00000F44/4), 0x00000000},
689
    {(0x00000F50/4), 0x00006740},
690
    {(0x00000F54/4), 0x00000000},
691
    {(0x00000F54/4), 0x00000000},
692
    {(0x00000F54/4), 0x00000000},
693
    {(0x00000F54/4), 0x3F800000},
694
    {(0x00000F50/4), 0x00006750},
695
    {(0x00000F54/4), 0x40000000},
696
    {(0x00000F54/4), 0x40000000},
697
    {(0x00000F54/4), 0x40000000},
698
    {(0x00000F54/4), 0x40000000},
699
    {(0x00000F50/4), 0x00006760},
700
    {(0x00000F54/4), 0x00000000},
701
    {(0x00000F54/4), 0x00000000},
702
    {(0x00000F54/4), 0x3F800000},
703
    {(0x00000F54/4), 0x00000000},
704
    {(0x00000F50/4), 0x00006770},
705
    {(0x00000F54/4), 0xC5000000},
706
    {(0x00000F54/4), 0xC5000000},
707
    {(0x00000F54/4), 0x00000000},
708
    {(0x00000F54/4), 0x00000000},
709
    {(0x00000F50/4), 0x00006780},
710
    {(0x00000F54/4), 0x00000000},
711
    {(0x00000F54/4), 0x00000000},
712
    {(0x00000F54/4), 0x3F800000},
713
    {(0x00000F54/4), 0x00000000},
714
    {(0x00000F50/4), 0x000067A0},
715
    {(0x00000F54/4), 0x3F800000},
716
    {(0x00000F54/4), 0x3F800000},
717
    {(0x00000F54/4), 0x3F800000},
718
    {(0x00000F54/4), 0x3F800000},
719
    {(0x00000F50/4), 0x00006AB0},
720
    {(0x00000F54/4), 0x3F800000},
721
    {(0x00000F54/4), 0x3F800000},
722
    {(0x00000F54/4), 0x3F800000},
723
    {(0x00000F50/4), 0x00006AC0},
724
    {(0x00000F54/4), 0x00000000},
725
    {(0x00000F54/4), 0x00000000},
726
    {(0x00000F54/4), 0x00000000},
727
    {(0x00000F50/4), 0x00006C10},
728
    {(0x00000F54/4), 0xBF800000},
729
    {(0x00000F50/4), 0x00007030},
730
    {(0x00000F54/4), 0x7149F2CA},
731
    {(0x00000F50/4), 0x00007040},
732
    {(0x00000F54/4), 0x7149F2CA},
733
    {(0x00000F50/4), 0x00007050},
734
    {(0x00000F54/4), 0x7149F2CA},
735
    {(0x00000F50/4), 0x00007060},
736
    {(0x00000F54/4), 0x7149F2CA},
737
    {(0x00000F50/4), 0x00007070},
738
    {(0x00000F54/4), 0x7149F2CA},
739
    {(0x00000F50/4), 0x00007080},
740
    {(0x00000F54/4), 0x7149F2CA},
741
    {(0x00000F50/4), 0x00007090},
742
    {(0x00000F54/4), 0x7149F2CA},
743
    {(0x00000F50/4), 0x000070A0},
744
    {(0x00000F54/4), 0x7149F2CA},
745
    {(0x00000F50/4), 0x00006A80},
746
    {(0x00000F54/4), 0x00000000},
747
    {(0x00000F54/4), 0x00000000},
748
    {(0x00000F54/4), 0x3F800000},
749
    {(0x00000F50/4), 0x00006AA0},
750
    {(0x00000F54/4), 0x00000000},
751
    {(0x00000F54/4), 0x00000000},
752
    {(0x00000F54/4), 0x00000000},
753
    {(0x00000F50/4), 0x00000040},
754
    {(0x00000F54/4), 0x00000005},
755
    {(0x00000F50/4), 0x00006400},
756
    {(0x00000F54/4), 0x3F800000},
757
    {(0x00000F54/4), 0x3F800000},
758
    {(0x00000F54/4), 0x4B7FFFFF},
759
    {(0x00000F54/4), 0x00000000},
760
    {(0x00000F50/4), 0x00006410},
761
    {(0x00000F54/4), 0xC5000000},
762
    {(0x00000F54/4), 0xC5000000},
763
    {(0x00000F54/4), 0x00000000},
764
    {(0x00000F54/4), 0x00000000},
765
    {(0x00000F50/4), 0x00006420},
766
    {(0x00000F54/4), 0x00000000},
767
    {(0x00000F54/4), 0x00000000},
768
    {(0x00000F54/4), 0x00000000},
769
    {(0x00000F54/4), 0x00000000},
770
    {(0x00000F50/4), 0x00006430},
771
    {(0x00000F54/4), 0x00000000},
772
    {(0x00000F54/4), 0x00000000},
773
    {(0x00000F54/4), 0x00000000},
774
    {(0x00000F54/4), 0x00000000},
775
    {(0x00000F50/4), 0x000064C0},
776
    {(0x00000F54/4), 0x3F800000},
777
    {(0x00000F54/4), 0x3F800000},
778
    {(0x00000F54/4), 0x477FFFFF},
779
    {(0x00000F54/4), 0x3F800000},
780
    {(0x00000F50/4), 0x000064D0},
781
    {(0x00000F54/4), 0xC5000000},
782
    {(0x00000F54/4), 0xC5000000},
783
    {(0x00000F54/4), 0x00000000},
784
    {(0x00000F54/4), 0x00000000},
785
    {(0x00000F50/4), 0x000064E0},
786
    {(0x00000F54/4), 0xC4FFF000},
787
    {(0x00000F54/4), 0xC4FFF000},
788
    {(0x00000F54/4), 0x00000000},
789
    {(0x00000F54/4), 0x00000000},
790
    {(0x00000F50/4), 0x000064F0},
791
    {(0x00000F54/4), 0x00000000},
792
    {(0x00000F54/4), 0x00000000},
793
    {(0x00000F54/4), 0x00000000},
794
    {(0x00000F54/4), 0x00000000},
795
    {(0x00000F40/4), 0x30000000},
796
    {(0x00000F44/4), 0x00000004},
797
    {(0x00000F48/4), 0x10000000},
798
    {(0x00000F4C/4), 0x00000000}
799
};
800
static unsigned nv10TablePRAMIN[][2] =
801
{
802
    {0x00000000, 0x80000010},
803
    {0x00000001, 0x80011145},
804
    {0x00000002, 0x80000011},
805
    {0x00000003, 0x80011146},
806
    {0x00000004, 0x80000012},
807
    {0x00000005, 0x80011147},
808
    {0x00000006, 0x80000013},
809
    {0x00000007, 0x80011148},
810
    {0x00000008, 0x80000014},
811
    {0x00000009, 0x80011149},
812
    {0x0000000A, 0x80000015},
813
    {0x0000000B, 0x8001114A},
814
    {0x0000000C, 0x80000016},
815
    {0x0000000D, 0x80011150},
816
    {0x00000020, 0x80000000},
817
    {0x00000021, 0x80011142},
818
    {0x00000022, 0x80000001},
819
    {0x00000023, 0x80011143},
820
    {0x00000024, 0x80000002},
821
    {0x00000025, 0x80011144},
822
    {0x00000026, 0x80000003},
823
    {0x00000027, 0x8001114B},
824
    {0x00000028, 0x80000004},
825
    {0x00000029, 0x8001114C},
826
    {0x0000002A, 0x80000005},
827
    {0x0000002B, 0x8001114D},
828
    {0x0000002C, 0x80000006},
829
    {0x0000002D, 0x8001114E},
830
    {0x0000002E, 0x80000007},
831
    {0x0000002F, 0x8001114F},
832
    {0x00000500, 0x00003000},
833
    {0x00000501, 0x01FFFFFF},
834
    {0x00000502, 0x00000002},
835
    {0x00000503, 0x00000002},
836
    {0x00000508, 0x01008043},
837
    {0x0000050A, 0x00000000},
838
    {0x0000050B, 0x00000000},
839
    {0x0000050C, 0x01008019},
840
    {0x0000050E, 0x00000000},
841
    {0x0000050F, 0x00000000},
842
#if 1
843
    {0x00000510, 0x01008018},
844
#else
845
    {0x00000510, 0x01008044},
846
#endif
847
    {0x00000512, 0x00000000},
848
    {0x00000513, 0x00000000},
849
    {0x00000514, 0x01008021},
850
    {0x00000516, 0x00000000},
851
    {0x00000517, 0x00000000},
852
    {0x00000518, 0x0100805F},
853
    {0x0000051A, 0x00000000},
854
    {0x0000051B, 0x00000000},
855
#if 1
856
    {0x0000051C, 0x0100804B},
857
#else
858
    {0x0000051C, 0x0100804A},
859
#endif
860
    {0x0000051E, 0x00000000},
861
    {0x0000051F, 0x00000000},
862
    {0x00000520, 0x0100A048},
863
    {0x00000521, 0x00000D01},
864
    {0x00000522, 0x11401140},
865
    {0x00000523, 0x00000000},
866
    {0x00000524, 0x0300A094},
867
    {0x00000525, 0x00000D01},
868
    {0x00000526, 0x11401140},
869
    {0x00000527, 0x00000000},
870
    {0x00000528, 0x0300A095},
871
    {0x00000529, 0x00000D01},
872
    {0x0000052A, 0x11401140},
873
    {0x0000052B, 0x00000000},
874
    {0x0000052C, 0x00000058},
875
    {0x0000052E, 0x11401140},
876
    {0x0000052F, 0x00000000},
877
    {0x00000530, 0x00000059},
878
    {0x00000532, 0x11401140},
879
    {0x00000533, 0x00000000},
880
    {0x00000534, 0x0000005A},
881
    {0x00000536, 0x11401140},
882
    {0x00000537, 0x00000000},
883
    {0x00000538, 0x0000005B},
884
    {0x0000053A, 0x11401140},
885
    {0x0000053B, 0x00000000},
886
    {0x0000053C, 0x00000093},
887
    {0x0000053E, 0x11401140},
888
    {0x0000053F, 0x00000000},
889
    {0x00000540, 0x0300A01C},
890
    {0x00000542, 0x11401140},
891
    {0x00000543, 0x00000000}
892
};
893
static unsigned nv10TablePRAMIN_8BPP[][2] =
894
{
895
    /*           0xXXXXXX01 For  MSB mono format */
896
    /*           0xXXXXXX02 For  LSB mono format */
897
    {0x00000509, 0x00000302},
898
    {0x0000050D, 0x00000302},
899
    {0x00000511, 0x00000202},
900
    {0x00000515, 0x00000302},
901
    {0x00000519, 0x00000302},
902
    {0x0000051D, 0x00000302},
903
    {0x0000052D, 0x00000302},
904
    {0x0000052E, 0x00000302},
905
    {0x00000535, 0x00000000},
906
    {0x00000539, 0x00000000},
907
    {0x0000053D, 0x00000000},
908
    {0x00000541, 0x00000302}
909
};
910
static unsigned nv10TablePRAMIN_15BPP[][2] =
911
{
912
    /*           0xXXXXXX01 For  MSB mono format */
913
    /*           0xXXXXXX02 For  LSB mono format */
914
    {0x00000509, 0x00000902},
915
    {0x0000050D, 0x00000902},
916
    {0x00000511, 0x00000802},
917
    {0x00000515, 0x00000902},
918
    {0x00000519, 0x00000902},
919
    {0x0000051D, 0x00000902},
920
    {0x0000052D, 0x00000902},
921
    {0x0000052E, 0x00000902},
922
    {0x00000535, 0x00000902},
923
    {0x00000539, 0x00000902}, 
924
    {0x0000053D, 0x00000902},
925
    {0x00000541, 0x00000902}
926
};
927
static unsigned nv10TablePRAMIN_16BPP[][2] =
928
{
929
    /*           0xXXXXXX01 For  MSB mono format */
930
    /*           0xXXXXXX02 For  LSB mono format */
931
    {0x00000509, 0x00000C02},
932
    {0x0000050D, 0x00000C02},
933
    {0x00000511, 0x00000B02},
934
    {0x00000515, 0x00000C02},
935
    {0x00000519, 0x00000C02},
936
    {0x0000051D, 0x00000C02},
937
    {0x0000052D, 0x00000C02},
938
    {0x0000052E, 0x00000C02},
939
    {0x00000535, 0x00000C02},
940
    {0x00000539, 0x00000C02},
941
    {0x0000053D, 0x00000C02},
942
    {0x00000541, 0x00000C02}
943
};
944
static unsigned nv10TablePRAMIN_32BPP[][2] =
945
{
946
    /*           0xXXXXXX01 For  MSB mono format */
947
    /*           0xXXXXXX02 For  LSB mono format */
948
    {0x00000509, 0x00000E02},
949
    {0x0000050D, 0x00000E02},
950
    {0x00000511, 0x00000D02},
951
    {0x00000515, 0x00000E02},
952
    {0x00000519, 0x00000E02},
953
    {0x0000051D, 0x00000E02},
954
    {0x0000052D, 0x00000E02},
955
    {0x0000052E, 0x00000E02},
956
    {0x00000535, 0x00000E02},
957
    {0x00000539, 0x00000E02},
958
    {0x0000053D, 0x00000E02},
959
    {0x00000541, 0x00000E02}
960
};
961
(-)linux-2.4.26/drivers/video/xbox/xboxfb.h (+96 lines)
Line 0 Link Here
1
#ifndef __XBOXFB_H
2
#define __XBOXFB_H
3
4
#include <linux/config.h>
5
#include <linux/fb.h>
6
#include <video/fbcon.h>
7
#include <video/fbcon-cfb4.h>
8
#include <video/fbcon-cfb8.h>
9
#include <video/fbcon-cfb16.h>
10
#include <video/fbcon-cfb32.h>
11
#include "riva_hw.h"
12
#include <linux/xboxfbctl.h>
13
14
/* GGI compatibility macros */
15
#define NUM_SEQ_REGS		0x05
16
#define NUM_CRT_REGS		0x41
17
#define NUM_GRC_REGS		0x09
18
#define NUM_ATC_REGS		0x15
19
20
#define NUM_CONEXANT_REGS	0x69
21
#define MAX_ENCODER_REGS 	256
22
23
/* holds the state of the VGA core and extended Riva hw state from riva_hw.c.
24
 * From KGI originally. */
25
struct riva_regs {
26
	u8 attr[NUM_ATC_REGS];
27
	u8 crtc[NUM_CRT_REGS];
28
	u8 gra[NUM_GRC_REGS];
29
	u8 seq[NUM_SEQ_REGS];
30
	u8 misc_output;
31
	RIVA_HW_STATE ext;
32
	u8 encoder_mode[MAX_ENCODER_REGS];
33
};
34
35
typedef struct {
36
	unsigned char red, green, blue, transp;
37
} riva_cfb8_cmap_t;
38
39
struct rivafb_info;
40
struct rivafb_info {
41
	struct fb_info info;	/* kernel framebuffer info */
42
43
	RIVA_HW_INST riva;	/* interface to riva_hw.c */
44
45
	const char *drvr_name;	/* Riva hardware board type */
46
47
	unsigned long ctrl_base_phys;	/* physical control register base addr */
48
	unsigned long fb_base_phys;	/* physical framebuffer base addr */
49
50
	caddr_t ctrl_base;	/* virtual control register base addr */
51
	caddr_t fb_base;	/* virtual framebuffer base addr */
52
53
	unsigned ram_amount;	/* amount of RAM on card, in bytes */
54
	unsigned dclk_max;	/* max DCLK */
55
56
	struct riva_regs initial_state;	/* initial startup video mode */
57
	struct riva_regs current_state;
58
59
	struct display disp;
60
	int currcon;
61
	struct display *currcon_display;
62
63
	struct rivafb_info *next;
64
65
	struct pci_dev *pd;	/* pointer to board's pci info */
66
	unsigned base0_region_size;	/* size of control register region */
67
	unsigned base1_region_size;	/* size of framebuffer region */
68
69
	struct riva_cursor *cursor;
70
71
	struct display_switch dispsw;
72
73
	riva_cfb8_cmap_t palette[256];	/* VGA DAC palette cache */
74
75
#if defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
76
	union {
77
#ifdef FBCON_HAS_CFB16
78
		u_int16_t cfb16[16];
79
#endif
80
#ifdef FBCON_HAS_CFB32
81
		u_int32_t cfb32[16];
82
#endif
83
	} con_cmap;
84
#endif				/* FBCON_HAS_CFB16 | FBCON_HAS_CFB32 */
85
#ifdef CONFIG_MTRR
86
	struct { int vram; int vram_valid; } mtrr;
87
#endif
88
	unsigned riva_fb_start; /* start address of fb in riva address space */
89
	xbox_tv_encoding tv_encoding;
90
	xbox_av_type av_type;
91
	xbox_encoder_type video_encoder;
92
	double hoc;
93
	double voc;
94
};
95
96
#endif /* __XBOXFB_H */
(-)linux-2.4.26/drivers/xbox/CVS/Entries (+1 lines)
Line 0 Link Here
1
D/proc////
(-)linux-2.4.26/drivers/xbox/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/xbox
(-)linux-2.4.26/drivers/xbox/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/drivers/xbox/proc/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)linux-2.4.26/drivers/xbox/proc/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/drivers/xbox/proc
(-)linux-2.4.26/drivers/xbox/proc/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/fs/CVS/Entries (+6 lines)
Line 0 Link Here
1
/Config.in/1.7/Wed Feb 18 23:45:59 2004//
2
/Makefile/1.6/Wed Feb 18 23:45:59 2004//
3
D/fat////
4
D/fatx////
5
D/nls////
6
D/partitions////
(-)linux-2.4.26/fs/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/fs
(-)linux-2.4.26/fs/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/fs/Config.in (+1 lines)
Lines 40-45 Link Here
40
dep_tristate '  MSDOS fs support' CONFIG_MSDOS_FS $CONFIG_FAT_FS
40
dep_tristate '  MSDOS fs support' CONFIG_MSDOS_FS $CONFIG_FAT_FS
41
dep_tristate '    UMSDOS: Unix-like file system on top of standard MSDOS fs' CONFIG_UMSDOS_FS $CONFIG_MSDOS_FS
41
dep_tristate '    UMSDOS: Unix-like file system on top of standard MSDOS fs' CONFIG_UMSDOS_FS $CONFIG_MSDOS_FS
42
dep_tristate '  VFAT (Windows-95) fs support' CONFIG_VFAT_FS $CONFIG_FAT_FS
42
dep_tristate '  VFAT (Windows-95) fs support' CONFIG_VFAT_FS $CONFIG_FAT_FS
43
tristate 'FATX (Xbox) fs support' CONFIG_FATX_FS
43
dep_tristate 'EFS file system support (read only) (EXPERIMENTAL)' CONFIG_EFS_FS $CONFIG_EXPERIMENTAL
44
dep_tristate 'EFS file system support (read only) (EXPERIMENTAL)' CONFIG_EFS_FS $CONFIG_EXPERIMENTAL
44
dep_tristate 'Journalling Flash File System (JFFS) support' CONFIG_JFFS_FS $CONFIG_MTD
45
dep_tristate 'Journalling Flash File System (JFFS) support' CONFIG_JFFS_FS $CONFIG_MTD
45
if [ "$CONFIG_JFFS_FS" = "y" -o "$CONFIG_JFFS_FS" = "m" ] ; then
46
if [ "$CONFIG_JFFS_FS" = "y" -o "$CONFIG_JFFS_FS" = "m" ] ; then
(-)linux-2.4.26/fs/Makefile (+1 lines)
Lines 32-37 Link Here
32
subdir-$(CONFIG_INTERMEZZO_FS)	+= intermezzo
32
subdir-$(CONFIG_INTERMEZZO_FS)	+= intermezzo
33
subdir-$(CONFIG_MINIX_FS)	+= minix
33
subdir-$(CONFIG_MINIX_FS)	+= minix
34
subdir-$(CONFIG_FAT_FS)		+= fat
34
subdir-$(CONFIG_FAT_FS)		+= fat
35
subdir-$(CONFIG_FATX_FS)	+= fatx
35
subdir-$(CONFIG_UMSDOS_FS)	+= umsdos
36
subdir-$(CONFIG_UMSDOS_FS)	+= umsdos
36
subdir-$(CONFIG_MSDOS_FS)	+= msdos
37
subdir-$(CONFIG_MSDOS_FS)	+= msdos
37
subdir-$(CONFIG_VFAT_FS)	+= vfat
38
subdir-$(CONFIG_VFAT_FS)	+= vfat
(-)linux-2.4.26/fs/fat/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)linux-2.4.26/fs/fat/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/fs/fat
(-)linux-2.4.26/fs/fat/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/fs/fatx/CVS/Entries (+10 lines)
Line 0 Link Here
1
/Makefile/1.2/Wed Mar 12 09:06:40 2003//
2
/README/1.1/Wed Mar 12 09:06:41 2003//
3
/cache.c/1.2/Sat Mar 15 07:19:45 2003//
4
/dir.c/1.6/Tue Mar 30 08:22:18 2004//
5
/fatxfs_syms.c/1.2/Wed Mar 12 09:06:43 2003//
6
/file.c/1.4/Wed Dec 10 00:18:29 2003//
7
/inode.c/1.11/Wed Dec 10 00:18:29 2003//
8
/misc.c/1.4/Fri Mar 14 17:59:23 2003//
9
/namei.c/1.5/Tue Mar 30 08:22:18 2004//
10
D
(-)linux-2.4.26/fs/fatx/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/fs/fatx
(-)linux-2.4.26/fs/fatx/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/fs/fatx/Makefile (+17 lines)
Line 0 Link Here
1
#
2
# Makefile for the Linux fatx filesystem routines.
3
#
4
# Note! Dependencies are done automagically by 'make dep', which also
5
# removes any old dependencies. DON'T put your own dependencies here
6
# unless it's something special (ie not a .c file).
7
#
8
# Note 2! The CFLAGS definitions are now in the main makefile.
9
10
O_TARGET := fatx.o
11
12
export-objs := fatxfs_syms.o
13
14
obj-y := namei.o cache.o dir.o file.o inode.o misc.o fatxfs_syms.o
15
obj-m := $(O_TARGET)
16
17
include $(TOPDIR)/Rules.make
(-)linux-2.4.26/fs/fatx/README (+59 lines)
Line 0 Link Here
1
there are some things, which should really checked in the FATX driver here.
2
3
- creation of a file with touch creates a Fat entry, with filesize 0 and no
4
cluster alocated (cluter=0)
5
I am not sure, if the xbox will see this as "good" or not, and maybe deletes
6
the entry or something else like
7
8
- attributs
9
there has to be a file-wrapper written, for grepping though the current fatx
10
partition and look for all possible file-attributes
11
12
- filepadding
13
currently file(cluster) padding is been developed.
14
Theoretically this should not harm the thing, but whom knows
15
16
- file = multipe*0x4000 cluster size
17
not even testet how the xbox handles this ? does it open a "fill" cluster,
18
or stops it on the cluster end ? (where data end too)
19
this als has to be cross-checked with the fatx linux driver
20
21
- Fat entry's
22
It supports Mulit-cluster filesystem , means extended FAT enetrys >256
23
entrys.
24
originally comming from the Fat module.
25
this has to be tested on both Xbox (xbox os) and Linux too.
26
stability is a different question.
27
28
- chache system for the cluster thing
29
Comming out of the original Fat driver, it supports caching.
30
this is not tested, nobody knows exact.
31
32
33
note:
34
35
we have written the current fatx driver in this way, that the output looks
36
100% exactly to Xbox like style.
37
Some things are not yet finished (file end padding - cluster-padding)
38
but this will come.
39
40
the Driver is able, to build out of a pre-formatted image(or hdd, flash)
41
with Ed's formatting tool, a compleate filesystem without errors.
42
43
We are writing automated test tools, for comparing files and randoming files
44
on the Xbox hdd on both Os's and make a Sha-1 compare of the files after.
45
Theoretically, it should be .... (let's hope)
46
47
The current driver seems a lot more stabile as the old driver, but it is
48
really new !
49
50
there could a lot of hidden problems there, like filerenaming with
51
new_filenamelenght!=old_filenamelenght ==> not working or so.
52
.. this was really a problem, we found it.. this was luck.
53
54
so be very careful with working on real partitions.
55
there could some very nasty bugs be inside
56
57
58
ed & franz
59
(-)linux-2.4.26/fs/fatx/cache.c (+318 lines)
Line 0 Link Here
1
/*
2
 *  linux/fs/fatx/cache.c
3
 *
4
 *  Written 2003 by Edgar Hucek and Lehner Franz
5
 *
6
 */
7
8
#include <linux/fatx_fs.h>
9
#include <linux/kernel.h>
10
#include <linux/errno.h>
11
#include <linux/string.h>
12
#include <linux/stat.h>
13
14
#define PRINTK(format, args...) do { if (fatx_debug) printk( format, ##args ); } while(0)
15
16
static struct fatx_cache *fatx_cache,cache[FATX_CACHE];
17
static spinlock_t fatx_cache_lock = SPIN_LOCK_UNLOCKED;
18
19
int fatx_access(struct super_block *sb,int nr,int new_value)
20
{
21
	struct buffer_head *bh, *bh2, *c_bh, *c_bh2;
22
	unsigned char *p_first, *p_last;
23
	int copy, first = 0, last = 0, next, b;
24
25
	next = 0;
26
27
	if ((unsigned) (nr-2) >= FATX_SB(sb)->clusters)
28
		return 0;
29
	if (FATX_SB(sb)->fat_bits == 32) {
30
		first = last = nr*4;
31
	} else if (FATX_SB(sb)->fat_bits == 16) {
32
		first = last = nr*2;
33
	}
34
35
	b = FATX_SB(sb)->fat_start + (first >> sb->s_blocksize_bits);
36
	if (!(bh = sb_bread(sb, b))) {
37
		PRINTK("FATX: bread in fatx_access failed\n");
38
		return 0;
39
	}
40
	if ((first >> sb->s_blocksize_bits) == (last >> sb->s_blocksize_bits)) {
41
		bh2 = bh;
42
	} else {
43
		if (!(bh2 = sb_bread(sb, b+1))) {
44
			if(bh) brelse(bh);
45
			PRINTK("FATX: 2nd bread in fatx_access failed\n");
46
			return 0;
47
		}
48
	}
49
	if (FATX_SB(sb)->fat_bits == 32) {
50
		p_first = p_last = NULL; /* GCC needs that stuff */
51
		next = CF_LE_L(((__u32 *) bh->b_data)[(first & (sb->s_blocksize - 1)) >> 2]);
52
		next &= 0xffffffff;
53
		if (next >= EOC_FAT32) next = -1;
54
	} else if (FATX_SB(sb)->fat_bits == 16) {
55
		p_first = p_last = NULL; /* GCC needs that stuff */
56
		next = CF_LE_W(((__u16 *) bh->b_data)[(first & (sb->s_blocksize - 1)) >> 1]);
57
		if (next >= EOC_FAT16) next = -1;
58
	}
59
	PRINTK("FATX: fatx_access: 0x%x, nr=0x%x, first=0x%x, next=0x%x\n", b, nr, first, next);
60
	if (new_value != -1) {
61
		if (FATX_SB(sb)->fat_bits == 32) {
62
			((__u32 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 2]
63
				= CT_LE_L(new_value);
64
		} else if (FATX_SB(sb)->fat_bits == 16) {
65
			((__u16 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 1]
66
				= CT_LE_W(new_value);
67
		}
68
		mark_buffer_dirty(bh);
69
		for (copy = 1; copy < FATX_SB(sb)->fats; copy++) {
70
			b = FATX_SB(sb)->fat_start + (first >> sb->s_blocksize_bits)
71
				+ FATX_SB(sb)->fat_length * copy;
72
			if (!(c_bh = sb_bread(sb, b)))
73
				break;
74
			if (bh != bh2) {
75
				if (!(c_bh2 = sb_bread(sb, b+1))) {
76
					if(c_bh) brelse(c_bh);
77
					break;
78
				}
79
				memcpy(c_bh2->b_data, bh2->b_data, sb->s_blocksize);
80
				mark_buffer_dirty(c_bh2);
81
				if(c_bh2) brelse(c_bh2);
82
			}
83
			memcpy(c_bh->b_data, bh->b_data, sb->s_blocksize);
84
			mark_buffer_dirty(c_bh);
85
			if(c_bh) brelse(c_bh);
86
		}
87
	}
88
	if(bh) brelse(bh);
89
	if (bh != bh2)
90
		if(bh2) brelse(bh2);
91
	return next;
92
}
93
94
void fatx_cache_init(void)
95
{
96
	static int initialized = 0;
97
	int count;
98
99
	spin_lock(&fatx_cache_lock);
100
	if (initialized) {
101
		spin_unlock(&fatx_cache_lock);
102
		return;
103
	}
104
	fatx_cache = &cache[0];
105
	for (count = 0; count < FATX_CACHE; count++) {
106
		cache[count].device = 0;
107
		cache[count].next = count == FATX_CACHE-1 ? NULL :
108
		    &cache[count+1];
109
	}
110
	initialized = 1;
111
	spin_unlock(&fatx_cache_lock);
112
}
113
114
115
void fatx_cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu)
116
{
117
	struct fatx_cache *walk;
118
	int first = FATX_I(inode)->i_start;
119
120
	if (!first)
121
		return;
122
	spin_lock(&fatx_cache_lock);
123
	for (walk = fatx_cache; walk; walk = walk->next)
124
		if (inode->i_dev == walk->device
125
		    && walk->start_cluster == first
126
		    && walk->file_cluster <= cluster
127
		    && walk->file_cluster > *f_clu) {
128
			*d_clu = walk->disk_cluster;
129
#ifdef DEBUG
130
printk("cache hit: %d (%d)\n",walk->file_cluster,*d_clu);
131
#endif
132
			if ((*f_clu = walk->file_cluster) == cluster) { 
133
				spin_unlock(&fatx_cache_lock);
134
				return;
135
			}
136
		}
137
	spin_unlock(&fatx_cache_lock);
138
#ifdef DEBUG
139
printk("cache miss\n");
140
#endif
141
}
142
143
144
#ifdef DEBUG
145
static void list_cache(void)
146
{
147
	struct fatx_cache *walk;
148
149
	for (walk = fatx_cache; walk; walk = walk->next) {
150
		if (walk->device)
151
			printk("<%s,%d>(%d,%d) ", kdevname(walk->device),
152
			       walk->start_cluster, walk->file_cluster,
153
			       walk->disk_cluster);
154
		else printk("-- ");
155
	}
156
	printk("\n");
157
}
158
#endif
159
160
161
void fatx_cache_add(struct inode *inode,int f_clu,int d_clu)
162
{
163
	struct fatx_cache *walk,*last;
164
	int first = FATX_I(inode)->i_start;
165
166
	last = NULL;
167
	spin_lock(&fatx_cache_lock);
168
	for (walk = fatx_cache; walk->next; walk = (last = walk)->next)
169
		if (inode->i_dev == walk->device
170
		    && walk->start_cluster == first
171
		    && walk->file_cluster == f_clu) {
172
			if (walk->disk_cluster != d_clu) {
173
				printk("FAT cache corruption inode=%ld\n",
174
					inode->i_ino);
175
				spin_unlock(&fatx_cache_lock);
176
				fatx_cache_inval_inode(inode);
177
				return;
178
			}
179
			/* update LRU */
180
			if (last == NULL) {
181
				spin_unlock(&fatx_cache_lock);
182
				return;
183
			}
184
			last->next = walk->next;
185
			walk->next = fatx_cache;
186
			fatx_cache = walk;
187
#ifdef DEBUG
188
list_cache();
189
#endif
190
			spin_unlock(&fatx_cache_lock);
191
			return;
192
		}
193
	walk->device = inode->i_dev;
194
	walk->start_cluster = first;
195
	walk->file_cluster = f_clu;
196
	walk->disk_cluster = d_clu;
197
	last->next = NULL;
198
	walk->next = fatx_cache;
199
	fatx_cache = walk;
200
	spin_unlock(&fatx_cache_lock);
201
#ifdef DEBUG
202
list_cache();
203
#endif
204
}
205
206
207
/* Cache invalidation occurs rarely, thus the LRU chain is not updated. It
208
   fixes itself after a while. */
209
210
void fatx_cache_inval_inode(struct inode *inode)
211
{
212
	struct fatx_cache *walk;
213
	int first = FATX_I(inode)->i_start;
214
215
	spin_lock(&fatx_cache_lock);
216
	for (walk = fatx_cache; walk; walk = walk->next)
217
		if (walk->device == inode->i_dev
218
		    && walk->start_cluster == first)
219
			walk->device = 0;
220
	spin_unlock(&fatx_cache_lock);
221
}
222
223
224
void fatx_cache_inval_dev(kdev_t device)
225
{
226
	struct fatx_cache *walk;
227
228
	spin_lock(&fatx_cache_lock);
229
	for (walk = fatx_cache; walk; walk = walk->next)
230
		if (walk->device == device)
231
			walk->device = 0;
232
	spin_unlock(&fatx_cache_lock);
233
}
234
235
236
int fatx_get_cluster(struct inode *inode,int cluster)
237
{
238
	int nr,count;
239
240
	if (!(nr = FATX_I(inode)->i_start)) return 0;
241
	if (!cluster) return nr;
242
	count = 0;
243
	for (fatx_cache_lookup(inode,cluster,&count,&nr); count < cluster;
244
	    count++) {
245
		if ((nr = fatx_access(inode->i_sb,nr,-1)) == -1) return 0;
246
		if (!nr) return 0;
247
	}
248
	fatx_cache_add(inode,cluster,nr);
249
	return nr;
250
}
251
252
unsigned long fatx_bmap(struct inode *inode,unsigned long sector)
253
{
254
	struct super_block *sb = inode->i_sb;
255
	struct fatx_sb_info *sbi = FATX_SB(sb);
256
	unsigned long cluster, offset, last_block;
257
258
	if ((inode->i_ino == FATX_ROOT_INO || (S_ISDIR(inode->i_mode) &&
259
	     !FATX_I(inode)->i_start))) {
260
		if (sector >= sbi->dir_entries >> sbi->dir_per_block_bits)
261
			return 0;
262
		return sector + sbi->dir_start;
263
	}
264
	
265
	last_block = (FATX_I(inode)->mmu_private + (sb->s_blocksize - 1))
266
		>> sb->s_blocksize_bits;
267
	if (sector >= last_block)
268
		return 0;
269
270
	cluster = sector / sbi->cluster_size;
271
	offset  = sector % sbi->cluster_size;
272
	if (!(cluster = fatx_get_cluster(inode, cluster)))
273
		return 0;
274
275
	return (cluster - 2) * sbi->cluster_size + sbi->data_start + offset;
276
}
277
278
279
/* Free all clusters after the skip'th cluster. Doesn't use the cache,
280
   because this way we get an additional sanity check. */
281
282
int fatx_free(struct inode *inode,int skip)
283
{
284
	int nr,last;
285
286
	if (!(nr = FATX_I(inode)->i_start)) return 0;
287
	last = 0;
288
	while (skip--) {
289
		last = nr;
290
		if ((nr = fatx_access(inode->i_sb,nr,-1)) == -1) return 0;
291
		if (!nr) {
292
			printk("fatx_free: skipped EOF\n");
293
			return -EIO;
294
		}
295
	}
296
	if (last) {
297
		fatx_access(inode->i_sb,last,EOF_FAT(inode->i_sb));
298
		fatx_cache_inval_inode(inode);
299
	} else {
300
		fatx_cache_inval_inode(inode);
301
		FATX_I(inode)->i_start = 0;
302
		FATX_I(inode)->i_logstart = 0;
303
		mark_inode_dirty(inode);
304
	}
305
	lock_fatx(inode->i_sb);
306
	while (nr != -1) {
307
		if (!(nr = fatx_access(inode->i_sb,nr,0))) {
308
			fatx_fs_panic(inode->i_sb,"fatx_free: deleting beyond EOF");
309
			break;
310
		}
311
		if (FATX_SB(inode->i_sb)->free_clusters != -1) {
312
			FATX_SB(inode->i_sb)->free_clusters++;
313
		}
314
		inode->i_blocks -= (1 << FATX_SB(inode->i_sb)->cluster_bits) / 512;
315
	}
316
	unlock_fatx(inode->i_sb);
317
	return 0;
318
}
(-)linux-2.4.26/fs/fatx/dir.c (+432 lines)
Line 0 Link Here
1
/*
2
 *  linux/fs/fatx/dir.c
3
 *
4
 *  Written 2003 by Edgar Hucek and Lehner Franz
5
 *
6
 */
7
8
#include <linux/fs.h>
9
#include <linux/fatx_fs.h>
10
#include <linux/nls.h>
11
#include <linux/kernel.h>
12
#include <linux/errno.h>
13
#include <linux/stat.h>
14
#include <linux/string.h>
15
#include <linux/ioctl.h>
16
#include <linux/dirent.h>
17
#include <linux/mm.h>
18
#include <linux/ctype.h>
19
20
#include <asm/uaccess.h>
21
22
#define DEBUG
23
#define PRINTK(format, args...) do { if (fatx_debug) printk( format, ##args ); } while(0)
24
25
static inline void fatx_printname(const char *name, int length)
26
{
27
	int i;
28
	for(i=0;i<length;i++) {
29
		PRINTK("%c",name[i]);
30
	}
31
}
32
33
/*
34
 * Now an ugly part: this set of directory scan routines works on clusters
35
 * rather than on inodes and sectors. They are necessary to locate the '..'
36
 * directory "inode". raw_scan_sector operates in four modes:
37
 *
38
 * name     number   ino      action
39
 * -------- -------- -------- -------------------------------------------------
40
 * non-NULL -        X        Find an entry with that name
41
 * NULL     non-NULL non-NULL Find an entry whose data starts at *number
42
 * NULL     non-NULL NULL     Count subdirectories in *number. (*)
43
 * NULL     NULL     non-NULL Find an empty entry
44
 *
45
 * (*) The return code should be ignored. It DOES NOT indicate success or
46
 *     failure. *number has to be initialized to zero.
47
 *
48
 * - = not used, X = a value is returned unless NULL
49
 *
50
 * If res_bh is non-NULL, the buffer is not deallocated but returned to the
51
 * caller on success. res_de is set accordingly.
52
 *
53
 * If cont is non-zero, raw_found continues with the entry after the one
54
 * res_bh/res_de point to.
55
 */
56
static int fatx_raw_scan_sector(struct super_block *sb,	int sector,
57
		const char *name, int name_length, int *number,
58
		int *ino, struct buffer_head **res_bh,
59
		struct fatx_dir_entry **res_de )
60
{
61
	struct nls_table *t = FATX_SB(sb)->nls_io;
62
	struct buffer_head *bh;
63
	struct fatx_dir_entry *data;
64
	int entry,start,done = 0;
65
66
	PRINTK("FATX: fatx_raw_scan_sector: sector=%08lX\n",(long)sector);
67
	
68
	if (!(bh = sb_bread(sb,sector))) {
69
		printk("FATX: fatx_raw_scan_sector: sb_bread failed\n");
70
		return -EIO;
71
	}
72
	data = (struct fatx_dir_entry *) bh->b_data;
73
	for (entry = 0; entry < FATX_SB(sb)->dir_per_block; entry++) {
74
		if (FATX_END_OF_DIR(&data[entry])) {
75
			//no more entries to look through...
76
			if(bh) brelse(bh);
77
			PRINTK("FATX: fatx_raw_scan_sector: END OF DIR\n");
78
			return -ENOENT;
79
		} else if (name) { //search for name
80
			done = 	(data[entry].name_length == name_length) &&
81
				!strncmp(data[entry].name,name,name_length);
82
		} else if (!ino) { /* count subdirectories */
83
			done = 0;
84
			if (!FATX_IS_FREE(&data[entry]) && (data[entry].attr & ATTR_DIR))
85
				(*number)++;
86
		} else if (number) { /* search for start cluster */
87
			done = !FATX_IS_FREE(&data[entry]) && 
88
				(CF_LE_L(data[entry].start) == *number);
89
		} else { /* search for free entry */
90
			done = FATX_IS_FREE(&data[entry]);
91
		}
92
		if (done) {
93
			if (ino)
94
				*ino = sector * FATX_SB(sb)->dir_per_block + entry;
95
			start = CF_LE_L(data[entry].start);
96
			if (!res_bh) {
97
				if(bh) brelse(bh);
98
			} else {
99
				*res_bh = bh;
100
				*res_de = &data[entry];
101
			}
102
			PRINTK("FATX: fatx_raw_scan_sector: found: start=%08lX\n",(long)start);
103
			return start;
104
		}
105
	}
106
	if(bh) brelse(bh);
107
	PRINTK("FATX: fatx_raw_scan_sector: entry not in sector %08lX\n",(long)sector);
108
	return -EAGAIN;
109
}
110
111
/*
112
 * raw_scan_root performs raw_scan_sector on the root directory until the
113
 * requested entry is found or the end of the directory is reached.
114
 */
115
static int fatx_raw_scan_root(struct super_block *sb, const char *name,
116
		int name_length, int *number, int *ino,
117
		struct buffer_head **res_bh, struct fatx_dir_entry **res_de )
118
{
119
	int count,cluster;
120
121
	for (count = 0; count < FATX_SB(sb)->cluster_size; count++) {
122
		if ((cluster = fatx_raw_scan_sector(sb,FATX_SB(sb)->dir_start + count, name,name_length,number,ino,res_bh,res_de)) >= 0)
123
			return cluster;
124
		if (cluster == -ENOENT) {
125
			//end of dir...act like all sectors scanned and !found
126
			PRINTK("FATX: fatx_raw_scan_root cluster %d\n",cluster);
127
			return cluster;
128
		}
129
	}
130
	
131
	PRINTK("FATX: fatx_raw_scan_root leave\n");
132
133
	return -ENOENT;
134
}
135
136
/*
137
 * raw_scan_nonroot performs raw_scan_sector on a non-root directory until the
138
 * requested entry is found or the end of the directory is reached.
139
 */
140
static int fatx_raw_scan_nonroot(struct super_block *sb, int start,
141
		const char *name, int name_length, int *number,
142
		int *ino, struct buffer_head **res_bh,
143
		struct fatx_dir_entry **res_de )
144
{
145
	int count,cluster;
146
	
147
	PRINTK("FATX: fatx_raw_scan_nonroot: entered (start=%08lX)\n",(long)start);
148
149
	do {
150
		for (count = 0; count < FATX_SB(sb)->cluster_size; count++) {
151
			if ((cluster = fatx_raw_scan_sector(sb,FATX_SB(sb)->data_start + (FATX_SB(sb)->cluster_size * (start - 2) ) + count, name,name_length,number,ino,res_bh,res_de)) >= 0)
152
				return cluster;
153
			if (cluster == -ENOENT) {
154
				//EOD: act like all sectors scanned and !found
155
				return cluster;
156
			}
157
		}
158
		if (!(start = fatx_access(sb,start,-1))) {
159
			printk("FATX: fatx_raw_scan_nonroot: start sector %lX not in use\n",(long)start);
160
			fatx_fs_panic(sb,"FATX error");
161
			break;
162
		}
163
	}
164
	while (start != -1);
165
	return -ENOENT;
166
}
167
168
/*
169
 * Scans a directory for a given file (name points to its formatted name) or
170
 * for an empty directory slot (name is NULL). Returns an error code or zero.
171
 */
172
int fatx_scan(struct inode *dir, const char *name, int name_length,
173
		struct buffer_head **res_bh, struct fatx_dir_entry **res_de,
174
		int *ino )
175
{
176
	int res;
177
178
	if (FATX_I(dir)->i_start)
179
		res = fatx_raw_scan_nonroot(dir->i_sb,FATX_I(dir)->i_start,name,name_length,NULL,ino,res_bh,res_de);
180
	else
181
		res = fatx_raw_scan_root(dir->i_sb,name,name_length,NULL,ino,res_bh,res_de);
182
183
	return res<0 ? res : 0;
184
}
185
186
/*
187
 * See if directory is empty
188
 */
189
int fatx_dir_empty(struct inode *dir)
190
{
191
	loff_t pos;
192
	struct buffer_head *bh;
193
	struct fatx_dir_entry *de;
194
	int ino,result = 0;
195
196
	pos = 0;
197
	bh = NULL;
198
	while (fatx_get_entry(dir,&pos,&bh,&de,&ino) > -1) {
199
		if (FATX_END_OF_DIR(de)) {
200
			break;
201
		}
202
		if (!FATX_IS_FREE(de)) {
203
			result = -ENOTEMPTY;
204
			break;
205
		}
206
	}
207
	if (bh)
208
		brelse(bh);
209
210
	return result;
211
}
212
213
/*
214
 * fatx_subdirs counts the number of sub-directories of dir. It can be run
215
 * on directories being created.
216
 */
217
int fatx_subdirs(struct inode *dir)
218
{
219
	int count;
220
221
	count = 0;
222
	if (dir->i_ino == FATX_ROOT_INO) {
223
		fatx_raw_scan_root(dir->i_sb,NULL,0,&count,NULL,NULL,NULL);
224
	} else {
225
		if ((dir->i_ino != FATX_ROOT_INO) && !FATX_I(dir)->i_start) {
226
			return 0; /* in mkdir */
227
		} else {
228
			fatx_raw_scan_nonroot(dir->i_sb,FATX_I(dir)->i_start,
229
			                      NULL,0,&count,NULL,NULL,NULL);
230
		}
231
	}
232
	return count;
233
}
234
235
int fatx_do_add_entry(
236
		struct inode *dir,
237
		struct buffer_head **bh,
238
		struct fatx_dir_entry **de,
239
		int *ino)
240
{
241
	loff_t offset, curr;
242
	struct buffer_head *new_bh;
243
244
	offset = curr = 0;
245
	*bh = NULL;
246
	while (fatx_get_entry(dir,&curr,bh,de,ino) > -1) {
247
		if (FATX_IS_FREE(*de)) {
248
			PRINTK("FATX: fatx_do_add_entry: found free entry\n");
249
			return offset;
250
		}
251
		if (FATX_END_OF_DIR(*de)) {
252
			struct buffer_head *eod_bh = NULL;
253
			struct fatx_dir_entry *eod_de = NULL;
254
			int eod_ino;
255
			
256
			PRINTK("FATX: fatx_do_add_entry: found EOD at %lX\n",(long)(*de));
257
			//make sure the next one isn't first in new cluster
258
			if (fatx_get_entry(dir,&curr,&eod_bh,&eod_de,&eod_ino) > -1) {
259
				//EOD in same cluster...find proper de and mark new EOD
260
				eod_de->name_length = 0xFF;
261
				mark_buffer_dirty(eod_bh);
262
				PRINTK("FATX: fatx_do_add_entry: marked new EOD at %lX\n",(long)eod_de);
263
				if(eod_bh) brelse(eod_bh);
264
			} else {
265
				//we will take the easy out...do nothing...
266
				//assume fat table used to indicate EOD
267
				//if this is wrong, need to fatx_extend_dir
268
				//making first entry in next cluster EOD
269
				printk("FATX: fatx_do_add_entry: EOD marked by FAT\n");
270
				printk("FATX: ...:offset=%08lX, curr=%08lX\n",
271
						(unsigned long)offset,(unsigned long)curr);
272
			}
273
			PRINTK("FATX: fatx_do_add_entry: using entry at %lX\n",(long)(*de));
274
			return offset;
275
		}
276
		offset = curr;
277
	}
278
	PRINTK("FATX: fatx_do_add_entry: need to extend dir\n");
279
	if (dir->i_ino == FATX_ROOT_INO) {
280
		printk("FATX: fatx_do_add_entry: but it's root dir...can't extend\n");
281
		return -ENOSPC;
282
	}
283
	new_bh = fatx_extend_dir(dir);
284
	if (!new_bh) {
285
		PRINTK("FATX: fatx_do_add_entry: fatx_extend_dir failed...no space?\n");
286
		return -ENOSPC;
287
	}
288
	if(new_bh) brelse(new_bh);
289
	fatx_get_entry(dir,&curr,bh,de,ino);
290
	(*de)[1].name_length = 0xFF;
291
	PRINTK("FATX: fatx_do_add_entry: using entry at %ld\n",(long)offset);
292
	return offset;
293
}
294
295
int fatx_new_dir(struct inode *dir, struct inode *parent)
296
{
297
	struct buffer_head *bh;
298
	struct fatx_dir_entry *de;
299
300
	if ((bh = fatx_extend_dir(dir)) == NULL) {
301
		printk("FATX: fatx_new_dir: failed to get new cluster...no space?\n");
302
		return -ENOSPC;
303
	}
304
	/* zeroed out, so... */
305
	de = (struct fatx_dir_entry*)&bh->b_data[0];
306
	de[0].attr = de[1].attr = ATTR_DIR;
307
	de[0].name_length = 0xFF; //end of dir marker
308
	de[0].start = CT_LE_W(FATX_I(dir)->i_logstart);
309
	de[1].start = CT_LE_W(FATX_I(parent)->i_logstart);
310
	mark_buffer_dirty(bh);
311
	if(bh) brelse(bh);
312
	dir->i_atime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
313
	mark_inode_dirty(dir);
314
315
	return 0;
316
}
317
318
// sure to hope this is correct...
319
int fatx_readdir(struct file *filp, void *dirent, filldir_t filldir)
320
{
321
	struct inode *inode = filp->f_dentry->d_inode;
322
	struct inode *tmpi;
323
	struct super_block *sb = inode->i_sb;
324
	struct fatx_dir_entry *de;
325
	struct buffer_head *bh;
326
	int ino, inum;
327
	loff_t cpos = 0;	//file position (dir position)
328
	int offset = 0;		//cpos offset for root dir handling
329
	int entry = 0;		//next filldir entry location
330
331
	PRINTK("FATX: fatx_readdir entered\n");
332
	
333
	cpos = filp->f_pos;
334
	
335
	if (cpos == 0) {
336
		if (filldir(dirent,".",1,entry++,inode->i_ino,DT_DIR)<0) {
337
			printk("\nFATX: fatx_readdir exiting in root defaults\n");
338
			return 0;
339
		}
340
		cpos += 1 << FATX_DIR_BITS;
341
	}
342
	
343
	if (cpos == 1 << FATX_DIR_BITS) {
344
		if (filldir(dirent,"..",2,entry++,
345
		            filp->f_dentry->d_parent->d_inode->i_ino,DT_DIR)<0) {
346
			printk("\nFATX: fatx_readdir exiting in root defaults\n");
347
			filp->f_pos = 1 << FATX_DIR_BITS;
348
			return 0;
349
		}
350
		cpos += 1 << FATX_DIR_BITS;
351
	}
352
	
353
	offset = 2 << FATX_DIR_BITS;
354
	cpos -= offset;
355
356
 	bh = NULL;
357
358
	while(fatx_get_entry(inode,&cpos,&bh,&de,&ino) != -1) {
359
		if (FATX_END_OF_DIR(de)) {
360
			PRINTK("FATX: entry %ld marked as END OF DIR\n",(long)(cpos >> FATX_DIR_BITS));
361
			cpos -= 1 << FATX_DIR_BITS; // make sure it comes back to here if re-entered
362
			break;		//done...end of dir.
363
		}
364
		
365
		if (FATX_IS_FREE(de)) {
366
			PRINTK("FATX: entry %ld marked as FREE\n",(long)(cpos >> FATX_DIR_BITS));
367
			continue;
368
		}
369
370
		tmpi = fatx_iget(sb, ino);
371
		if (tmpi) {
372
			inum = tmpi->i_ino;
373
			iput(tmpi);
374
		} else {
375
			inum = iunique(sb, FATX_ROOT_INO);
376
		}
377
378
		if (filldir(dirent,de->name,de->name_length,entry++,inum,
379
		            (de->attr & ATTR_DIR) ? DT_DIR : DT_REG ) < 0 ) {
380
			break;
381
		}
382
		PRINTK("\nFATX: fatx_readdir: dir entry %3d: ",(int)entry);
383
		fatx_printname(de->name,de->name_length);
384
		PRINTK("\n");
385
	}
386
387
	filp->f_pos = cpos + offset;		
388
	if (bh)
389
		brelse(bh);
390
	
391
	PRINTK("\nFATX: fatx_readdir leaving\n");
392
	
393
	return 0;
394
}
395
396
struct file_operations fatx_dir_operations = {
397
	.read		= generic_read_dir,
398
	.readdir	= fatx_readdir,
399
	.ioctl		= NULL,
400
	.fsync		= file_fsync,
401
};
402
403
/* This assumes that size of cluster is above the 32*slots */
404
405
int fatx_add_entries(struct inode *dir,int slots, struct buffer_head **bh,
406
		  struct fatx_dir_entry **de, int *ino)
407
{
408
	loff_t offset, curr;
409
	int row;
410
	struct buffer_head *new_bh;
411
412
	offset = curr = 0;
413
	*bh = NULL;
414
	row = 0;
415
	while (fatx_get_entry(dir,&curr,bh,de,ino) > -1) {
416
		if (IS_FREE((*de)->name)) {
417
			if (++row == slots)
418
				return offset;
419
		} else {
420
			row = 0;
421
			offset = curr;
422
		}
423
	}
424
	if (dir->i_ino == FATX_ROOT_INO) 
425
		return -ENOSPC;
426
	new_bh = fatx_extend_dir(dir);
427
	if (!new_bh)
428
		return -ENOSPC;
429
	if(new_bh) brelse(new_bh);
430
	do fatx_get_entry(dir,&curr,bh,de,ino); while (++row<slots);
431
	return offset;
432
}
(-)linux-2.4.26/fs/fatx/fatxfs_syms.c (+64 lines)
Line 0 Link Here
1
/*
2
 *  linux/fs/fatx/fatxfs_syms.c
3
 *
4
 *  Exported kernel symbols for the FATX filesystem.
5
 *
6
 *  Written 2003 by Edgar Hucek and Lehner Franz
7
 *
8
 */
9
10
#include <linux/module.h>
11
#include <linux/mm.h>
12
#include <linux/fatx_fs.h>
13
#include <linux/init.h>
14
15
unsigned int fatx_debug = 0;
16
17
MODULE_PARM(fatx_debug,"i");
18
MODULE_PARM_DESC(fatx_debug,"turn on fatx debugging output");
19
20
EXPORT_SYMBOL(fatx_lookup);
21
EXPORT_SYMBOL(fatx_create);
22
EXPORT_SYMBOL(fatx_rmdir);
23
EXPORT_SYMBOL(fatx_mkdir);
24
EXPORT_SYMBOL(fatx_rename);
25
EXPORT_SYMBOL(fatx_unlink);
26
27
EXPORT_SYMBOL(fatx_new_dir);
28
EXPORT_SYMBOL(fatx_get_block);
29
EXPORT_SYMBOL(fatx_clear_inode);
30
EXPORT_SYMBOL(fatx_date_unix2dos);
31
EXPORT_SYMBOL(fatx_delete_inode);
32
EXPORT_SYMBOL(fatx_get_entry);
33
EXPORT_SYMBOL(fatx_notify_change);
34
EXPORT_SYMBOL(fatx_put_super);
35
EXPORT_SYMBOL(fatx_attach);
36
EXPORT_SYMBOL(fatx_detach);
37
EXPORT_SYMBOL(fatx_build_inode);
38
EXPORT_SYMBOL(fatx_read_super);
39
EXPORT_SYMBOL(fatx_readdir);
40
EXPORT_SYMBOL(fatx_scan);
41
EXPORT_SYMBOL(fatx_statfs);
42
EXPORT_SYMBOL(fatx_write_inode);
43
EXPORT_SYMBOL(fatx_get_cluster);
44
EXPORT_SYMBOL(fatx_add_entries);
45
EXPORT_SYMBOL(fatx_dir_empty);
46
EXPORT_SYMBOL(fatx_truncate);
47
48
static DECLARE_FSTYPE_DEV(fatx_fs_type, "fatx", fatx_read_super);
49
50
static int __init init_fatx_fs(void)
51
{
52
	printk("FATX driver 0.0.1\n");
53
	fatx_hash_init();
54
        return register_filesystem(&fatx_fs_type);
55
}
56
57
static void __exit exit_fatx_fs(void)
58
{
59
        unregister_filesystem(&fatx_fs_type);
60
}
61
62
module_init(init_fatx_fs)
63
module_exit(exit_fatx_fs)
64
MODULE_LICENSE("GPL");
(-)linux-2.4.26/fs/fatx/file.c (+111 lines)
Line 0 Link Here
1
/*
2
 *  linux/fs/fatx/file.c
3
 *
4
 *  Written 2003 by Edgar Hucek and Lehner Franz
5
 *
6
 */
7
8
#include <linux/sched.h>
9
#include <linux/locks.h>
10
#include <linux/fs.h>
11
#include <linux/fatx_fs.h>
12
#include <linux/errno.h>
13
#include <linux/fcntl.h>
14
#include <linux/stat.h>
15
#include <linux/string.h>
16
#include <linux/pagemap.h>
17
18
#include <asm/uaccess.h>
19
#include <asm/system.h>
20
21
#define PRINTK(format, args...) do { if (fatx_debug) printk( format, ##args ); } while(0)
22
23
struct file_operations fatx_file_operations = {
24
	.llseek		= generic_file_llseek,
25
	.read		= fatx_file_read,
26
	.write		= fatx_file_write,
27
	.mmap		= generic_file_mmap,
28
	.fsync		= file_fsync,
29
};
30
31
struct inode_operations fatx_file_inode_operations = {
32
	.truncate	= fatx_truncate,
33
	.setattr	= fatx_notify_change,
34
};
35
36
ssize_t fatx_file_read(	struct file *filp, char *buf, size_t count, loff_t *ppos)
37
{
38
	return generic_file_read(filp,buf,count,ppos);
39
}
40
41
42
int fatx_get_block(struct inode *inode, long iblock, struct buffer_head *bh_result, int create)
43
{
44
	struct super_block *sb = inode->i_sb;
45
	unsigned long phys;
46
47
	phys = fatx_bmap(inode, iblock);
48
	if (phys) {
49
		bh_result->b_dev = inode->i_dev;
50
		bh_result->b_blocknr = phys;
51
		bh_result->b_state |= (1UL << BH_Mapped);
52
		return 0;
53
	}
54
	if (!create)
55
		return 0;
56
	if (iblock << sb->s_blocksize_bits != FATX_I(inode)->mmu_private) {
57
		BUG();
58
		return -EIO;
59
	}
60
	if (!(iblock % FATX_SB(inode->i_sb)->cluster_size)) {
61
		if (fatx_add_cluster(inode) < 0)
62
			return -ENOSPC;
63
	}
64
	FATX_I(inode)->mmu_private += sb->s_blocksize;
65
	phys = fatx_bmap(inode, iblock);
66
	if (!phys)
67
		BUG();
68
	bh_result->b_dev = inode->i_dev;
69
	bh_result->b_blocknr = phys;
70
	bh_result->b_state |= (1UL << BH_Mapped);
71
	bh_result->b_state |= (1UL << BH_New);
72
	return 0;
73
}
74
75
ssize_t fatx_file_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
76
{
77
	struct inode *inode = filp->f_dentry->d_inode;
78
	int retval;
79
80
	retval = generic_file_write(filp, buf, count, ppos);
81
	if (retval > 0) {
82
		inode->i_mtime = inode->i_ctime = inode->i_atime = CURRENT_TIME;
83
		FATX_I(inode)->i_attrs |= ATTR_ARCH;
84
		mark_inode_dirty(inode);
85
	}
86
	return retval;
87
}
88
89
void fatx_truncate(struct inode *inode)
90
{
91
	struct fatx_sb_info *sbi = FATX_SB(inode->i_sb);
92
	int cluster;
93
94
	/* Why no return value?  Surely the disk could fail... */
95
	if (IS_RDONLY (inode))
96
		return /* -EPERM */;
97
	if (IS_IMMUTABLE(inode))
98
		return /* -EPERM */;
99
	cluster = 1 << sbi->cluster_bits;
100
	/* 
101
	 * This protects against truncating a file bigger than it was then
102
	 * trying to write into the hole.
103
	 */
104
	if (FATX_I(inode)->mmu_private > inode->i_size)
105
		FATX_I(inode)->mmu_private = inode->i_size;
106
107
	fatx_free(inode, (inode->i_size + (cluster - 1)) >> sbi->cluster_bits);
108
	FATX_I(inode)->i_attrs |= ATTR_ARCH;
109
	inode->i_ctime = inode->i_mtime = inode->i_atime = CURRENT_TIME;
110
	mark_inode_dirty(inode);
111
}
(-)linux-2.4.26/fs/fatx/inode.c (+663 lines)
Line 0 Link Here
1
/*
2
 *  linux/fs/fatx/inode.c
3
 *
4
 *  Written 2003 by Edgar Hucek and Lehner Franz
5
 *
6
 */
7
8
#include <linux/module.h>
9
#include <linux/fs.h>
10
#include <linux/kernel.h>
11
#include <linux/sched.h>	//needed for 'event'
12
#include <linux/blkdev.h>	//needed for 'blk_size'
13
#include <linux/locks.h>
14
#include <linux/fatx_fs.h>
15
#include <linux/fatx_fs_sb.h>
16
#include <linux/slab.h>
17
#include <linux/bitops.h>
18
#include <linux/major.h>
19
#include <linux/stat.h>
20
#include <linux/locks.h>
21
#include <linux/smp_lock.h>
22
 
23
24
#define CONFIG_NLS_DEFAULT "iso8859-15"
25
26
#define FAT_HASH_BITS   8
27
#define FAT_HASH_SIZE    (1UL << FAT_HASH_BITS)
28
#define FAT_HASH_MASK    (FAT_HASH_SIZE-1)
29
30
#define PRINTK(format, args...) do { if (fatx_debug) printk( format, ##args ); } while(0)
31
32
static int fatx_writepage(struct page *page)
33
{
34
	return block_write_full_page(page,fatx_get_block);
35
}
36
37
static int fatx_readpage(struct file *file, struct page *page)
38
{
39
	return block_read_full_page(page,fatx_get_block);
40
}
41
42
static int fatx_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to)
43
{
44
	return cont_prepare_write(page,from,to,fatx_get_block,
45
		&FATX_I(page->mapping->host)->mmu_private);
46
}
47
48
static int _fatx_bmap(struct address_space *mapping, long block)
49
{
50
	return generic_block_bmap(mapping,block,fatx_get_block);
51
}
52
53
struct address_space_operations fatx_aops = {
54
	.readpage	= fatx_readpage,
55
	.writepage	= fatx_writepage,
56
	.sync_page	= block_sync_page,
57
	.prepare_write	= fatx_prepare_write,
58
	.commit_write	= generic_commit_write,
59
	.bmap		= _fatx_bmap
60
};
61
62
void fatx_put_super(struct super_block *sb)
63
{
64
	fatx_cache_inval_dev(sb->s_dev);
65
	set_blocksize(sb->s_dev,BLOCK_SIZE);
66
        if (FATX_SB(sb)->nls_io) {
67
		unload_nls(FATX_SB(sb)->nls_io);
68
		FATX_SB(sb)->nls_io = NULL;
69
	}
70
}
71
72
static struct list_head fatx_inode_hashtable[FAT_HASH_SIZE];
73
spinlock_t fatx_inode_lock = SPIN_LOCK_UNLOCKED;
74
75
void fatx_hash_init(void)
76
{
77
	int i;
78
	for(i = 0; i < FAT_HASH_SIZE; i++) {
79
		INIT_LIST_HEAD(&fatx_inode_hashtable[i]);
80
	}
81
}
82
83
static inline unsigned long fatx_hash(struct super_block *sb, int i_pos)
84
{
85
	unsigned long tmp = (unsigned long)i_pos | (unsigned long) sb;
86
	tmp = tmp + (tmp >> FAT_HASH_BITS) + (tmp >> FAT_HASH_BITS * 2);
87
	return tmp & FAT_HASH_MASK;
88
}
89
90
void fatx_attach(struct inode *inode, int i_pos)
91
{
92
	spin_lock(&fatx_inode_lock);
93
	FATX_I(inode)->i_location = i_pos;
94
	list_add(&FATX_I(inode)->i_fat_hash,
95
		fatx_inode_hashtable + fatx_hash(inode->i_sb, i_pos));
96
	spin_unlock(&fatx_inode_lock);
97
}
98
99
void fatx_detach(struct inode *inode)
100
{
101
	spin_lock(&fatx_inode_lock);
102
	FATX_I(inode)->i_location = 0;
103
	list_del(&FATX_I(inode)->i_fat_hash);
104
	INIT_LIST_HEAD(&FATX_I(inode)->i_fat_hash);
105
	spin_unlock(&fatx_inode_lock);
106
}
107
108
struct inode *fatx_iget(struct super_block *sb, int i_pos)
109
{
110
	struct list_head *p = fatx_inode_hashtable + fatx_hash(sb, i_pos);
111
	struct list_head *walk;
112
	struct fatx_inode_info *i;
113
	struct inode *inode = NULL;
114
115
	spin_lock(&fatx_inode_lock);
116
	list_for_each(walk, p) {
117
		i = list_entry(walk, struct fatx_inode_info, i_fat_hash);
118
		if (i->i_fat_inode->i_sb != sb)
119
			continue;
120
		if (i->i_location != i_pos)
121
			continue;
122
		inode = igrab(i->i_fat_inode);
123
		if (inode)
124
			break;
125
	}
126
	spin_unlock(&fatx_inode_lock);
127
	return inode;
128
}
129
130
/* doesn't deal with root inode */
131
static void fatx_fill_inode(struct inode *inode, struct fatx_dir_entry *de)
132
{
133
	struct super_block *sb = inode->i_sb;
134
	struct fatx_sb_info *sbi = FATX_SB(sb);
135
	int nr;
136
137
	INIT_LIST_HEAD(&FATX_I(inode)->i_fat_hash);
138
	FATX_I(inode)->i_location = 0;
139
	FATX_I(inode)->i_fat_inode = inode;
140
	inode->i_uid = sbi->options.fs_uid;
141
	inode->i_gid = sbi->options.fs_gid;
142
	inode->i_version = ++event;
143
	inode->i_generation = CURRENT_TIME;
144
	
145
	if ((de->attr & ATTR_DIR) && !FATX_IS_FREE(de)) {
146
		inode->i_generation &= ~1;
147
		inode->i_mode = FATX_MKMODE(de->attr,S_IRWXUGO & 
148
			~sbi->options.fs_umask) | S_IFDIR;
149
		inode->i_op = sbi->dir_ops;
150
		inode->i_fop = &fatx_dir_operations;
151
152
		FATX_I(inode)->i_start = CF_LE_L(de->start);
153
		FATX_I(inode)->i_logstart = FATX_I(inode)->i_start;
154
		inode->i_nlink = fatx_subdirs(inode) + 2;
155
		    /* includes .., compensating for "self" */
156
#ifdef DEBUG
157
		if (!inode->i_nlink) {
158
			printk("directory %d: i_nlink == 0\n",inode->i_ino);
159
			inode->i_nlink = 1;
160
		}
161
#endif
162
		if ((nr = FATX_I(inode)->i_start) != 0)
163
			while (nr != -1) {
164
				inode->i_size += 1 << sbi->cluster_bits;
165
				if (!(nr = fatx_access(sb, nr, -1))) {
166
					printk("Directory %ld: bad FAT\n",
167
					    inode->i_ino);
168
					break;
169
				}
170
			}
171
		FATX_I(inode)->mmu_private = inode->i_size;
172
	} else { /* not a directory */
173
		inode->i_generation |= 1;
174
		inode->i_mode = FATX_MKMODE(de->attr,S_IRWXUGO & ~sbi->options.fs_umask) | S_IFREG;
175
		FATX_I(inode)->i_start = CF_LE_L(de->start);
176
		FATX_I(inode)->i_logstart = FATX_I(inode)->i_start;
177
		inode->i_size = CF_LE_L(de->size);
178
	        inode->i_op = &fatx_file_inode_operations;
179
	        inode->i_fop = &fatx_file_operations;
180
		inode->i_mapping->a_ops = &fatx_aops;
181
		FATX_I(inode)->mmu_private = inode->i_size;
182
	}
183
	FATX_I(inode)->i_attrs = de->attr & ATTR_UNUSED;
184
	/* this is as close to the truth as we can get ... */
185
	inode->i_blksize = 1 << sbi->cluster_bits;
186
	inode->i_blocks = ((inode->i_size + inode->i_blksize - 1)
187
			   & ~(inode->i_blksize - 1)) >> 9;
188
	inode->i_mtime = inode->i_atime =
189
		fatx_date_dos2unix(CF_LE_W(de->time),CF_LE_W(de->date));
190
	inode->i_ctime = fatx_date_dos2unix(CF_LE_W(de->ctime),CF_LE_W(de->cdate));
191
}
192
193
struct inode *fatx_build_inode(	struct super_block *sb,	struct fatx_dir_entry *de, int ino, int *res )
194
{
195
	struct inode *inode;
196
	*res = 0;
197
	inode = fatx_iget(sb, ino);
198
	if (inode)
199
		goto out;
200
	inode = new_inode(sb);
201
	*res = -ENOMEM;
202
	if (!inode)
203
		goto out;
204
	*res = 0;
205
	inode->i_ino = iunique(sb, FATX_ROOT_INO);
206
	fatx_fill_inode(inode, de);
207
	fatx_attach(inode, ino);
208
	insert_inode_hash(inode);
209
out:
210
	return inode;
211
}
212
213
static unsigned int fatx_get_total_size ( struct super_block *sb )
214
{
215
	int major = MAJOR(sb->s_dev);
216
	
217
	if (blk_size[major]) {
218
		int minor = MINOR(sb->s_dev);
219
		return blk_size[major][minor] << 1;
220
	}
221
	return 0;
222
}
223
224
/*
225
 * parse super block values out of FATX "boot block"
226
 * unlike the other FAT variants, much of the data is calculated from the
227
 * the partition information.
228
 */
229
int fatx_parse_boot_block ( struct super_block *sb, struct buffer_head *bh )
230
{
231
	struct fatx_boot_sector *b = (struct fatx_boot_sector *)bh->b_data;
232
	struct fatx_sb_info *sbi = FATX_SB(sb);
233
	int logical_sector_size, hard_blksize;
234
	unsigned int total_sectors;
235
	unsigned long cl_count;
236
	unsigned long fat_length;
237
238
	PRINTK("FATX: entered fatx_parse_boot_block\n");
239
	
240
	if (b->magic != FATX_BOOTBLOCK_MAGIC) {
241
		printk("FATX: boot block signature not found.  Not FATX?\n");
242
		return -1;
243
	}
244
		
245
	PRINTK("FATX: fatx_magic: %08lX\n",(unsigned long)b->magic);
246
			
247
	logical_sector_size = 512;
248
	
249
	sbi->cluster_size = CLUSTER_SIZE;
250
	
251
	PRINTK("FATX: cluster_size: %d\n",(int)sbi->cluster_size);
252
	
253
	//sb->s_block_size enters as hardware block (sector) size
254
	hard_blksize = sb->s_blocksize;
255
	sb->s_blocksize = logical_sector_size;
256
	sb->s_blocksize_bits = ffs(logical_sector_size) - 1;
257
258
	//figure total sector count
259
	total_sectors = fatx_get_total_size(sb);
260
	
261
	PRINTK("FATX: total_sectors for given device: %ld\n",(unsigned long)total_sectors);
262
	
263
	sbi->cluster_bits = 14;
264
	sbi->fats = 1;
265
	
266
	//hmm...fat should start right after boot block sectors (first 8)
267
	sbi->fat_start = 8;	//this might be: + CF_LE_W(b->fatx_unknown)
268
	sbi->root_cluster = 0;
269
	sbi->dir_per_block = logical_sector_size/sizeof(struct fatx_dir_entry);
270
	sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1;
271
	sbi->dir_entries = 256;
272
	
273
	//check cluster count
274
	
275
	cl_count = total_sectors / sbi->cluster_size;
276
277
	if( cl_count >= 0xfff4 ) {
278
		//FATX-32
279
		sb->s_maxbytes = FATX32_MAX_NON_LFS;
280
		sbi->fat_bits = 32;
281
	} else {
282
		//FATX-16
283
		sb->s_maxbytes = FATX16_MAX_NON_LFS;
284
		sbi->fat_bits = 16;
285
	}
286
287
	fat_length = cl_count * (sbi->fat_bits>>3);		
288
	if(fat_length % 4096) {
289
		fat_length = ((fat_length / 4096) + 1) * 4096;
290
	}
291
	sbi->fat_length = fat_length / logical_sector_size;
292
293
	sbi->dir_start = sbi->fat_start + sbi->fat_length;
294
	sbi->data_start = sbi->dir_start + CLUSTER_SIZE;
295
	sbi->clusters = ((total_sectors-sbi->data_start) / sbi->cluster_size);
296
	sbi->free_clusters = -1; /* Don't know yet */
297
	
298
	PRINTK("FATX: logical_sector_size:	%d\n",(int)logical_sector_size);
299
	PRINTK("FATX: fat_length:		%d\n",(int)sbi->fat_length);
300
	PRINTK("FATX: spc_bits:			%d\n",sbi->fat_bits>>3);
301
	PRINTK("FATX: fat_start:		%d\n",(int)sbi->fat_start);
302
	PRINTK("FATX: dir_start:		%d\n",(int)sbi->dir_start);
303
	PRINTK("FATX: data_start:		%d\n",(int)sbi->data_start);
304
	PRINTK("FATX: clusters:			%ld\n",(unsigned long)sbi->clusters);
305
	PRINTK("FATX: fat_bits:			%d\n",(int)sbi->fat_bits);
306
	PRINTK("FATX: fat_length:		%d\n",(int)sbi->fat_length);
307
	PRINTK("FATX: root_dir_sectors:		%d\n",(int)CLUSTER_SIZE);
308
	PRINTK("FATX: dir_per_block:		%d\n",(int)sbi->dir_per_block);
309
	PRINTK("FATX: dir_per_block_bits:	%d\n",(int)sbi->dir_per_block_bits);
310
	PRINTK("FATX: dir_entries :		%d\n",(int)sbi->dir_entries);
311
	PRINTK("FATX: cluster_bits:		%d\n",(int)sbi->cluster_bits);
312
	
313
	PRINTK("FATX: leaving fatx_parse_boot_block\n");
314
		
315
	return 0;
316
}
317
318
static void fatx_read_root(struct inode *inode)
319
{
320
	struct super_block *sb = inode->i_sb;
321
	struct fatx_sb_info *sbi = FATX_SB(sb);
322
323
	INIT_LIST_HEAD(&FATX_I(inode)->i_fat_hash);
324
	FATX_I(inode)->i_location = 0;
325
	FATX_I(inode)->i_fat_inode = inode;
326
	inode->i_uid = sbi->options.fs_uid;
327
	inode->i_gid = sbi->options.fs_gid;
328
	inode->i_version = ++event;
329
	inode->i_generation = 0;
330
	inode->i_mode = (S_IRWXUGO & ~sbi->options.fs_umask) | S_IFDIR;
331
	inode->i_op = sbi->dir_ops;
332
	inode->i_fop = &fatx_dir_operations;
333
	
334
	FATX_I(inode)->i_start = FATX_ROOT_INO;
335
	inode->i_size = sbi->dir_entries * sizeof(struct fatx_dir_entry);
336
337
	inode->i_blksize = 1 << sbi->cluster_bits;
338
	inode->i_blocks = ((inode->i_size + inode->i_blksize - 1)
339
			   & ~(inode->i_blksize - 1)) >> 9;
340
	FATX_I(inode)->i_logstart = 0;
341
	FATX_I(inode)->mmu_private = inode->i_size;
342
343
	FATX_I(inode)->i_attrs = 0;
344
	inode->i_mtime = inode->i_atime = inode->i_ctime = 0;
345
	FATX_I(inode)->i_ctime_ms = 0;
346
	inode->i_nlink = fatx_subdirs(inode) + 2;
347
}
348
349
/* The public inode operations for the fatx fs */
350
struct inode_operations fatx_dir_inode_operations = {
351
	.create		= fatx_create,
352
	.lookup		= fatx_lookup,
353
	.unlink		= fatx_unlink,
354
	.mkdir		= fatx_mkdir,
355
	.rmdir		= fatx_rmdir,
356
	.rename		= fatx_rename,
357
	.setattr	= fatx_notify_change,
358
};
359
360
void fatx_write_inode(struct inode *inode, int wait)
361
{
362
	struct super_block *sb = inode->i_sb;
363
	struct buffer_head *bh;
364
	struct fatx_dir_entry *raw_entry;
365
	unsigned int i_pos;
366
	
367
	PRINTK("FATX: fatx_write_inode: entered\n");
368
369
retry:
370
	i_pos = FATX_I(inode)->i_location;
371
	if (inode->i_ino == FATX_ROOT_INO || !i_pos) {
372
		return;
373
	}
374
	lock_kernel();
375
	if (!(bh = sb_bread(sb, i_pos >> FATX_SB(sb)->dir_per_block_bits))) {
376
		PRINTK("dev = %s, ino = %d\n", kdevname(inode->i_dev), i_pos);
377
		fatx_fs_panic(sb, "fatx_write_inode: unable to read i-node block");
378
		unlock_kernel();
379
		return;
380
	}
381
	spin_lock(&fatx_inode_lock);
382
	if (i_pos != FATX_I(inode)->i_location) {
383
		spin_unlock(&fatx_inode_lock);
384
		if(bh) brelse(bh);
385
		unlock_kernel();
386
		goto retry;
387
	}
388
389
	raw_entry = &((struct fatx_dir_entry *) (bh->b_data))
390
	    [i_pos & (FATX_SB(sb)->dir_per_block - 1)];
391
	if (S_ISDIR(inode->i_mode)) {
392
		raw_entry->attr = ATTR_DIR;
393
		raw_entry->size = 0;
394
	}
395
	else {
396
		raw_entry->attr = ATTR_NONE;
397
		raw_entry->size = CT_LE_L(inode->i_size);
398
	}
399
	raw_entry->attr |= FATX_MKATTR(inode->i_mode) |
400
	    FATX_I(inode)->i_attrs;
401
	raw_entry->start = CT_LE_L(FATX_I(inode)->i_logstart);
402
	
403
	PRINTK("FATX: fatx_write_inode: start == %08lX (LE=%08lX)\n",
404
			(long)FATX_I(inode)->i_logstart,
405
			(long)CT_LE_L(FATX_I(inode)->i_logstart));
406
	
407
	fatx_date_unix2dos(inode->i_mtime,&raw_entry->time,&raw_entry->date);
408
	raw_entry->time = CT_LE_W(raw_entry->time);
409
	raw_entry->date = CT_LE_W(raw_entry->date);
410
	
411
	fatx_date_unix2dos(inode->i_ctime,&raw_entry->ctime,&raw_entry->cdate);
412
	raw_entry->ctime = CT_LE_W(raw_entry->ctime);
413
	raw_entry->cdate = CT_LE_W(raw_entry->cdate);
414
	raw_entry->atime = CT_LE_W(raw_entry->ctime);
415
	raw_entry->adate = CT_LE_W(raw_entry->cdate);
416
	
417
	spin_unlock(&fatx_inode_lock);
418
	mark_buffer_dirty(bh);
419
	if(bh) brelse(bh);
420
	unlock_kernel();
421
	
422
	PRINTK("FATX: fatx_write_inode: leaving\n");
423
}
424
425
int fatx_statfs(struct super_block *sb,struct statfs *buf)
426
{
427
	int free,nr;
428
429
	lock_fatx(sb);
430
        if (FATX_SB(sb)->free_clusters != -1)
431
		free = FATX_SB(sb)->free_clusters;
432
	else {
433
		free = 0;
434
		for (nr = 2; nr < FATX_SB(sb)->clusters+2; nr++)
435
			if (!fatx_access(sb,nr,-1)) free++;
436
		FATX_SB(sb)->free_clusters = free;
437
	}
438
	unlock_fatx(sb);
439
	buf->f_type = sb->s_magic;
440
	buf->f_bsize = 1 << FATX_SB(sb)->cluster_bits;
441
	buf->f_blocks = FATX_SB(sb)->clusters;
442
	buf->f_bfree = free;
443
	buf->f_bavail = free;
444
	buf->f_namelen = FATX_MAX_NAME_LENGTH;
445
	return 0;
446
}
447
448
449
void fatx_delete_inode(struct inode *inode)
450
{
451
	if (!is_bad_inode(inode)) {
452
		lock_kernel();
453
		inode->i_size = 0;
454
		fatx_truncate(inode);
455
		unlock_kernel();
456
	}
457
	clear_inode(inode);
458
}
459
460
void fatx_clear_inode(struct inode *inode)
461
{
462
	if (is_bad_inode(inode))
463
		return;
464
	lock_kernel();
465
	spin_lock(&fatx_inode_lock);
466
	fatx_cache_inval_inode(inode);
467
	list_del(&FATX_I(inode)->i_fat_hash);
468
	spin_unlock(&fatx_inode_lock);
469
	unlock_kernel();
470
}
471
472
static struct super_operations fatx_sops = { 
473
	.write_inode	= fatx_write_inode,
474
	.delete_inode	= fatx_delete_inode,
475
	.put_super	= fatx_put_super,
476
	.statfs		= fatx_statfs,
477
	.clear_inode	= fatx_clear_inode,
478
	.read_inode	= make_bad_inode,
479
};
480
481
static int parse_options(char *options,struct fatx_mount_options *opts)
482
{
483
        char *this_char,*value,save,*savep;
484
        int ret = 1;
485
486
        opts->fs_uid = current->uid;
487
        opts->fs_gid = current->gid;
488
        opts->fs_umask = current->fs->umask;
489
        opts->quiet = 0;
490
491
        if (!options)
492
                goto out;
493
        save = 0;
494
        savep = NULL;
495
        for (this_char = strtok(options,","); this_char;
496
             this_char = strtok(NULL,",")) {
497
                if ((value = strchr(this_char,'=')) != NULL) {
498
                        save = *value;
499
                        savep = value;
500
                        *value++ = 0;
501
                }
502
                if (!strcmp(this_char,"uid")) {
503
                        if (!value || !*value) ret = 0;
504
                        else {
505
                                opts->fs_uid = simple_strtoul(value,&value,0);
506
                                if (*value) ret = 0;
507
                        }
508
                }
509
                else if (!strcmp(this_char,"gid")) {
510
                        if (!value || !*value) ret= 0;
511
                        else {
512
                                opts->fs_gid = simple_strtoul(value,&value,0);
513
                                if (*value) ret = 0;
514
                        }
515
                }
516
                else if (!strcmp(this_char,"umask")) {
517
                        if (!value || !*value) ret = 0;
518
                        else {
519
                                opts->fs_umask = simple_strtoul(value,&value,8);
520
                                if (*value) ret = 0;
521
                        }
522
                }
523
                else if (!strcmp(this_char,"quiet")) {
524
                        if (value) ret = 0;
525
                        else opts->quiet = 1;
526
                }
527
                if (this_char != options) *(this_char-1) = ',';
528
                if (value) *savep = save;
529
                if (ret == 0)
530
                        break;
531
        }
532
out:
533
        return ret;
534
}
535
536
struct super_block *fatx_read_super(struct super_block *sb,void *data, int silent)
537
{
538
	struct inode *root_inode;
539
	struct buffer_head *bh;
540
	struct fatx_sb_info *sbi = FATX_SB(sb);
541
	int hard_blksize;
542
	int error;
543
544
	PRINTK("FATX: entering fatx_read_super\n");
545
546
	sbi->private_data = NULL;
547
548
	sbi->dir_ops = &fatx_dir_inode_operations;
549
550
	sb->s_op = &fatx_sops;
551
552
	hard_blksize = get_hardsect_size(sb->s_dev);
553
	if (!hard_blksize)
554
		hard_blksize = 512;
555
556
	//store fat value parsed into fatx_bits...possibly overridden later
557
	sbi->fat_bits = 0;
558
	
559
        if (!parse_options((char *) data, &(sbi->options)))
560
                goto out_fail;
561
	
562
	fatx_cache_init();
563
564
	sb->s_blocksize = hard_blksize;
565
	set_blocksize(sb->s_dev, hard_blksize);
566
	bh = sb_bread(sb, 0);
567
	if (bh == NULL) {
568
		PRINTK("FATX: unable to read boot sector\n");
569
		goto out_fail;
570
	}
571
572
	// insert call(s) to superblock parsing
573
	error = fatx_parse_boot_block(sb,bh);
574
	brelse(bh);
575
576
	if (error)
577
		goto out_invalid;
578
579
	set_blocksize(sb->s_dev, sb->s_blocksize);
580
581
	sb->s_magic = FATX_BOOTBLOCK_MAGIC;
582
	/* set up enough so that it can read an inode */
583
	init_MUTEX(&sbi->fat_lock);
584
	sbi->prev_free = 0;
585
586
	
587
	sbi->nls_io = NULL;
588
	if (! sbi->nls_io)
589
		sbi->nls_io = load_nls_default();
590
	
591
	root_inode = new_inode(sb);
592
	if (!root_inode)
593
		goto out_unload_nls;
594
	root_inode->i_ino = FATX_ROOT_INO;
595
	fatx_read_root(root_inode);
596
	insert_inode_hash(root_inode);
597
	sb->s_root = d_alloc_root(root_inode);
598
	if (!sb->s_root)
599
		goto out_no_root;
600
601
	PRINTK("FATX: leave fatx_read_super\n");
602
	
603
	return sb;
604
605
out_no_root:
606
	PRINTK("FATX: get root inode failed\n");
607
	iput(root_inode);
608
out_unload_nls:
609
	unload_nls(sbi->nls_io);
610
	goto out_fail;
611
out_invalid:
612
	if (!silent) {
613
		PRINTK("VFS: Can't find a valid FAT filesystem on dev %s.\n",
614
			kdevname(sb->s_dev));
615
	}
616
out_fail:
617
	if(sbi->private_data)
618
		kfree(sbi->private_data);
619
	sbi->private_data = NULL;
620
 
621
	return NULL;
622
}
623
		
624
int fatx_notify_change(struct dentry * dentry, struct iattr * attr)
625
{
626
	struct super_block *sb = dentry->d_sb;
627
	struct inode *inode = dentry->d_inode;
628
	int error;
629
630
	/* FAT cannot truncate to a longer file */
631
	if (attr->ia_valid & ATTR_SIZE) {
632
		if (attr->ia_size > inode->i_size)
633
			return -EPERM;
634
	}
635
636
	error = inode_change_ok(inode, attr);
637
	if (error)
638
		return FATX_SB(sb)->options.quiet ? 0 : error;
639
640
	if (((attr->ia_valid & ATTR_UID) && 
641
	     (attr->ia_uid != FATX_SB(sb)->options.fs_uid)) ||
642
	    ((attr->ia_valid & ATTR_GID) && 
643
	     (attr->ia_gid != FATX_SB(sb)->options.fs_gid)) ||
644
	    ((attr->ia_valid & ATTR_MODE) &&
645
	     (attr->ia_mode & ~FATX_VALID_MODE)))
646
		error = -EPERM;
647
648
	if (error)
649
		return FATX_SB(sb)->options.quiet ? 0 : error;
650
651
	error = inode_setattr(inode, attr);
652
	if (error)
653
		return error;
654
655
	if (S_ISDIR(inode->i_mode))
656
		inode->i_mode |= S_IXUGO;
657
658
	inode->i_mode = ((inode->i_mode & S_IFMT) | ((((inode->i_mode & S_IRWXU
659
	    & ~FATX_SB(sb)->options.fs_umask) | S_IRUSR) >> 6)*S_IXUGO)) &
660
	    ~FATX_SB(sb)->options.fs_umask;
661
	return 0;
662
}
663
(-)linux-2.4.26/fs/fatx/misc.c (+272 lines)
Line 0 Link Here
1
/*
2
 *  linux/fs/fatx/misc.c
3
 *
4
 *  Written 2003 by Edgar Hucek and Lehner Franz
5
 *
6
 */
7
8
#include <linux/fatx_fs.h>
9
#include <linux/sched.h>
10
#include <linux/kernel.h>
11
#include <linux/errno.h>
12
#include <linux/string.h>
13
#include <linux/stat.h>
14
#include <linux/time.h>
15
#include <linux/types.h>
16
17
#define PRINTK(format, args...) do { if (fatx_debug) printk( format, ##args ); } while(0)
18
19
/*
20
 * fatx_fs_panic reports a severe file system problem and sets the file system
21
 * read-only. The file system can be made writable again by remounting it.
22
 */
23
24
void fatx_fs_panic(struct super_block *s,const char *msg)
25
{
26
	int not_ro;
27
28
	not_ro = !(s->s_flags & MS_RDONLY);
29
	if (not_ro) s->s_flags |= MS_RDONLY;
30
	printk("Filesystem panic (dev %s).\n  %s\n", kdevname(s->s_dev), msg);
31
	if (not_ro)
32
		printk("  File system has been set read-only\n");
33
}
34
35
static int day_n[] = {  0, 31, 59, 90,120,151,181,212,243,273,304,334,0,0,0,0 };
36
		/*    Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */
37
38
extern struct timezone sys_tz;
39
40
int fatx_date_dos2unix(unsigned short time,unsigned short date)
41
{
42
	int month,year,secs,days;
43
44
	/* first subtract and mask after that... Otherwise, if
45
	   date == 0, bad things happen */
46
	month=  ((date >> 5) - 1) & 15;
47
	year =  date >> 9;
48
	days =  (date & 31)-1+day_n[month]+(year/4)+(year+30)*365;
49
	//skipped and current leap years
50
	days += ((year & 3) == 0 && month < 2 ? 0 : 1) + 7; 
51
	
52
	secs =  (time & 31)*2;		//seconds into curr minute
53
	secs += 60*((time >> 5) & 63);	//minutes into curr hour
54
	secs += 3600*(time >> 11);	//hours into curr day
55
	secs += 86400*days;		//days (from 1.1.70)
56
	
57
	secs += sys_tz.tz_minuteswest*60;
58
	return secs;
59
}
60
61
62
/*
63
 * fat_add_cluster tries to allocate a new cluster and adds it to the
64
 * file represented by inode.
65
 */
66
int fatx_add_cluster(struct inode *inode)
67
{
68
	struct super_block *sb = inode->i_sb;
69
	int count, nr, limit, last, curr, file_cluster;
70
	int cluster_size = FATX_SB(sb)->cluster_size;
71
	int res = -ENOSPC;
72
	
73
	lock_fatx(sb);
74
75
	if (FATX_SB(sb)->free_clusters == 0) {
76
		unlock_fatx(sb);
77
		return res;
78
	}
79
	limit = FATX_SB(sb)->clusters;
80
	nr = limit; /* to keep GCC happy */
81
	for (count = 0; count < limit; count++) {
82
		nr = ((count + FATX_SB(sb)->prev_free) % limit) + 2;
83
		if (fatx_access(sb, nr, -1) == 0)
84
			break;
85
	}
86
	if (count >= limit) {
87
		FATX_SB(sb)->free_clusters = 0;
88
		unlock_fatx(sb);
89
		return res;
90
	}
91
	
92
	FATX_SB(sb)->prev_free = (count + FATX_SB(sb)->prev_free + 1) % limit;
93
	fatx_access(sb, nr, EOF_FAT(sb));
94
	if (FATX_SB(sb)->free_clusters != -1)
95
		FATX_SB(sb)->free_clusters--;
96
	
97
	unlock_fatx(sb);
98
	
99
	/* We must locate the last cluster of the file to add this
100
	   new one (nr) to the end of the link list (the FAT).
101
	   
102
	   Here file_cluster will be the number of the last cluster of the
103
	   file (before we add nr).
104
	   
105
	   last is the corresponding cluster number on the disk. We will
106
	   use last to plug the nr cluster. We will use file_cluster to
107
	   update the cache.
108
	*/
109
	last = file_cluster = 0;
110
	if ((curr = FATX_I(inode)->i_start) != 0) {
111
		fatx_cache_lookup(inode, INT_MAX, &last, &curr);
112
		file_cluster = last;
113
		while (curr && curr != -1){
114
			file_cluster++;
115
			if (!(curr = fatx_access(sb, last = curr,-1))) {
116
				fatx_fs_panic(sb, "File without EOF");
117
				return res;
118
			}
119
		}
120
	}
121
	if (last) {
122
		fatx_access(sb, last, nr);
123
		fatx_cache_add(inode, file_cluster, nr);
124
	} else {
125
		FATX_I(inode)->i_start = nr;
126
		FATX_I(inode)->i_logstart = nr;
127
		mark_inode_dirty(inode);
128
	}
129
	if (file_cluster
130
	    != inode->i_blocks / cluster_size / (sb->s_blocksize / 512)) {
131
		printk ("file_cluster badly computed!!! %d <> %ld\n",
132
			file_cluster,
133
			inode->i_blocks / cluster_size / (sb->s_blocksize / 512));
134
		fatx_cache_inval_inode(inode);
135
	}
136
	inode->i_blocks += (1 << FATX_SB(sb)->cluster_bits) / 512;
137
	return nr;
138
}
139
140
/* Convert linear UNIX date to a MS-DOS time/date pair. */
141
142
void fatx_date_unix2dos(int unix_date,unsigned short *time,
143
    unsigned short *date)
144
{
145
	int day,year,nl_day,month;
146
147
	unix_date -= sys_tz.tz_minuteswest*60;
148
149
	/* bound low end at Jan 1 GMT 00:00:00 2000. */
150
	if (unix_date < ((30 * 365) + 7) * 24 * 60 * 60) {
151
		unix_date = ((30 * 365) + 7) * 24 * 60 * 60;
152
	}
153
		
154
	*time = (unix_date % 60)/2 + 			//seconds
155
		(((unix_date/60) % 60) << 5) +		//minutes
156
		(((unix_date/3600) % 24) << 11);	//hours
157
	
158
	day = unix_date/86400-(30 * 365 + 7);		//days (from 1.1.2000)
159
	year = day/365;
160
	if ((year+3)/4+365*year > day) year--;
161
	day -= (year+3)/4+365*year;
162
	if (day == 59 && !(year & 3)) {
163
		nl_day = day;
164
		month = 2;
165
	}
166
	else {
167
		nl_day = (year & 3) || day <= 59 ? day : day-1;
168
		for (month = 0; month < 12; month++)
169
			if (day_n[month] > nl_day) break;
170
	}
171
	*date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9);
172
}
173
174
struct buffer_head *fatx_extend_dir(struct inode *inode)
175
{
176
	struct super_block *sb = inode->i_sb;
177
	int nr, sector, last_sector;
178
	struct buffer_head *bh, *res = NULL;
179
	int cluster_size = FATX_SB(sb)->cluster_size;
180
181
	if (inode->i_ino == FATX_ROOT_INO)
182
			return res;
183
184
	nr = fatx_add_cluster(inode);
185
	if (nr < 0)
186
		return res;
187
	
188
	sector = FATX_SB(sb)->data_start + (nr - 2) * cluster_size;
189
	last_sector = sector + cluster_size;
190
	for ( ; sector < last_sector; sector++) {
191
#ifdef DEBUG
192
		printk("zeroing sector %d\n", sector);
193
#endif
194
		if (!(bh = sb_getblk(sb, sector)))
195
			printk("getblk failed\n");
196
		else {
197
			memset(bh->b_data, 0xFF, sb->s_blocksize);
198
			mark_buffer_uptodate(bh, 1);
199
			mark_buffer_dirty(bh);
200
			if (!res)
201
				res = bh;
202
			else
203
				if(bh) brelse(bh);
204
		}
205
	}
206
	if (inode->i_size & (sb->s_blocksize - 1)) {
207
		fatx_fs_panic(sb, "Odd directory size");
208
		inode->i_size = (inode->i_size + sb->s_blocksize)
209
			& ~(sb->s_blocksize - 1);
210
	}
211
	inode->i_size += 1 << FATX_SB(sb)->cluster_bits;
212
	FATX_I(inode)->mmu_private += 1 << FATX_SB(sb)->cluster_bits;
213
	mark_inode_dirty(inode);
214
215
	return res;
216
}
217
218
/* Returns the inode number of the directory entry at offset pos. If bh is
219
   non-NULL, it is brelse'd before. Pos is incremented. The buffer header is
220
   returned in bh.
221
   AV. Most often we do it item-by-item. Makes sense to optimize.
222
   AV. OK, there we go: if both bh and de are non-NULL we assume that we just
223
   AV. want the next entry (took one explicit de=NULL in vfat/namei.c).
224
   AV. It's done in fatx_get_entry() (inlined), here the slow case lives.
225
   AV. Additionally, when we return -1 (i.e. reached the end of directory)
226
   AV. we make bh NULL. 
227
 */
228
229
int fatx_get_entry(struct inode *dir, loff_t *pos,struct buffer_head **bh,
230
    struct fatx_dir_entry **de, int *ino)
231
{
232
	struct super_block *sb = dir->i_sb;
233
	struct fatx_sb_info *sbi = FATX_SB(sb);
234
	int sector, offset;
235
236
	while (1) {
237
		offset = *pos;
238
		PRINTK("get_entry offset %d\n",offset);
239
		if (*bh)
240
			if(*bh) brelse(*bh);
241
		*bh = NULL;
242
		if ((sector = fatx_bmap(dir,offset >> sb->s_blocksize_bits)) == -1)
243
			return -1;
244
		PRINTK("FATX: get_entry sector %d %p\n",sector,*bh);
245
		PRINTK("FATX: get_entry sector apres brelse\n");
246
		if (!sector)
247
			return -1; /* beyond EOF */
248
		*pos += sizeof(struct fatx_dir_entry);
249
		if (!(*bh = sb_bread(sb, sector))) {
250
			printk("Directory sread (sector 0x%x) failed\n",sector);
251
			continue;
252
		}
253
		PRINTK("FATX: get_entry apres sread\n");
254
255
		offset &= sb->s_blocksize - 1;
256
		*de = (struct fatx_dir_entry *) ((*bh)->b_data + offset);
257
		*ino = (sector << sbi->dir_per_block_bits) + (offset >> FATX_DIR_BITS);
258
259
		return 0;
260
	}
261
}
262
263
void lock_fatx(struct super_block *sb)
264
{
265
	down(&(FATX_SB(sb)->fat_lock));
266
}
267
268
void unlock_fatx(struct super_block *sb)
269
{
270
	up(&(FATX_SB(sb)->fat_lock));
271
}
272
(-)linux-2.4.26/fs/fatx/namei.c (+409 lines)
Line 0 Link Here
1
/*
2
 *  linux/fs/fatx/namei.c
3
 *
4
 *  Written 2003 by Edgar Hucek and Lehner Franz
5
 *
6
 */
7
8
#define __NO_VERSION__
9
#include <linux/module.h>
10
11
#include <linux/sched.h>
12
#include <linux/fatx_fs.h>
13
#include <linux/errno.h>
14
#include <linux/string.h>
15
16
#include <asm/uaccess.h>
17
18
#define PRINTK(format, args...) do { if (fatx_debug) printk( format, ##args ); } while(0)
19
20
/* Characters that are undesirable in an MS-DOS file name */
21
  
22
static char bad_chars[] = "*?<>|\";";
23
24
/*
25
 * Formats a FATX file name. Rejects invalid names. 
26
 */
27
28
static int fatx_format_name( const char *name,int len,char *out_name )
29
{
30
	int i;
31
	char trash[FATX_MAX_NAME_LENGTH];
32
33
	if (len > FATX_MAX_NAME_LENGTH) return -EINVAL;
34
	
35
	if (out_name == NULL) out_name = trash;
36
	
37
	memset(out_name,0xFF,FATX_MAX_NAME_LENGTH);
38
	
39
	//check for bad characters in name
40
	for(i=0; i<len; i++) {
41
		if (strchr(bad_chars,name[i])) return -EINVAL;
42
		out_name[i] = name[i];
43
	}
44
45
	return 0;
46
}
47
48
/*
49
 * Locates a directory entry.  Uses unformatted name. 
50
 */
51
52
static int fatx_find( struct inode *dir, const char *name, int len, struct buffer_head **bh, 
53
		struct fatx_dir_entry **de, int *ino )
54
{
55
	//verify its a valid name
56
	if (fatx_format_name(name,len,NULL) < 0) return -ENOENT;
57
58
	PRINTK("FATX: fatx_find\n");
59
	
60
	//find the name in the directory
61
	return fatx_scan(dir,name,len,bh,de,ino);
62
63
}
64
65
/* 
66
 * Get inode using directory and name 
67
 */
68
69
struct dentry *fatx_lookup(struct inode *dir,struct dentry *dentry)
70
{
71
	struct super_block *sb = dir->i_sb;
72
	struct inode *inode = NULL;
73
	struct fatx_dir_entry *de;
74
	struct buffer_head *bh = NULL;
75
	int ino,res;
76
	
77
	PRINTK("FATX: fatx_lookup\n");
78
79
	res = fatx_find(dir, dentry->d_name.name, dentry->d_name.len, &bh,
80
			&de, &ino);
81
82
	if (res == -ENOENT)
83
		goto add;
84
	if (res < 0)
85
		goto out;
86
	inode = fatx_build_inode(sb, de, ino, &res);
87
	if (res)
88
		goto out;
89
add:
90
	d_add(dentry, inode);
91
	res = 0;
92
out:
93
	if (bh) brelse(bh);
94
	return ERR_PTR(res);
95
}
96
97
/* 
98
 * Creates a directory entry (name is already formatted). 
99
 */
100
101
static int fatx_add_entry(
102
		struct inode *dir, 
103
		const char *name,
104
		int len,
105
		struct buffer_head **bh,
106
		struct fatx_dir_entry **de,
107
		int *ino,
108
		int is_dir )
109
{
110
	int res;
111
112
	if ((res = fatx_do_add_entry(dir, bh, de, ino))<0)
113
		return res;
114
	dir->i_ctime = dir->i_mtime = CURRENT_TIME;
115
	mark_inode_dirty(dir);
116
	memset((*de)->name,0xFF,FATX_MAX_NAME_LENGTH);
117
	memcpy((*de)->name,name,len);
118
	(*de)->name_length = len;
119
	(*de)->attr = is_dir ? ATTR_DIR : ATTR_ARCH;
120
	(*de)->start = 0;
121
	fatx_date_unix2dos(dir->i_mtime,&(*de)->time,&(*de)->date);
122
	(*de)->size = 0;
123
	mark_buffer_dirty(*bh);
124
	return 0;
125
}
126
127
/* 
128
 * Create a file 
129
 */
130
131
int fatx_create(struct inode *dir,struct dentry *dentry,int mode)
132
{
133
	struct buffer_head *bh;
134
	struct fatx_dir_entry *de;
135
	struct inode *inode;
136
	int ino,res;
137
	const char *name = dentry->d_name.name;
138
	int name_length = dentry->d_name.len;
139
	char szFormatName[FATX_MAX_NAME_LENGTH];
140
	
141
	res = fatx_format_name(name,name_length,szFormatName);
142
	if (res < 0)
143
		return res;
144
	
145
	if (fatx_scan(dir,name,name_length,&bh,&de,&ino) >= 0) {
146
		if(bh) brelse(bh);
147
		return -EINVAL;
148
 	}
149
	inode = NULL;
150
	res = fatx_add_entry(dir, szFormatName, name_length, &bh, &de, &ino, 0);
151
	if (res)
152
		return res;
153
	inode = fatx_build_inode(dir->i_sb, de, ino, &res);
154
	if(bh) brelse(bh);
155
	if (!inode)
156
		return res;
157
	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
158
	mark_inode_dirty(inode);
159
	d_instantiate(dentry, inode);
160
	return 0;
161
}
162
163
/*
164
 * Remove a directory 
165
 */
166
167
int fatx_rmdir(struct inode *dir, struct dentry *dentry)
168
{
169
	struct inode *inode = dentry->d_inode;
170
	int res,ino;
171
	struct buffer_head *bh;
172
	struct fatx_dir_entry *de;
173
174
	bh = NULL;
175
	res = fatx_find(dir, dentry->d_name.name, dentry->d_name.len,
176
				&bh, &de, &ino);
177
	if (res < 0)
178
		goto rmdir_done;
179
	/*
180
	 * Check whether the directory is not in use, then check
181
	 * whether it is empty.
182
	 */
183
	res = fatx_dir_empty(inode);
184
	if (res)
185
		goto rmdir_done;
186
187
	de->name_length = DELETED_FLAG;
188
	mark_buffer_dirty(bh);
189
	fatx_detach(inode);
190
	inode->i_nlink = 0;
191
	inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
192
	dir->i_nlink--;
193
	mark_inode_dirty(inode);
194
	mark_inode_dirty(dir);
195
	res = 0;
196
197
rmdir_done:
198
	if(bh) brelse(bh);
199
	return res;
200
}
201
202
/*
203
 * Make a directory 
204
 */
205
206
int fatx_mkdir(struct inode *dir,struct dentry *dentry,int mode)
207
{
208
	struct buffer_head *bh;
209
	struct fatx_dir_entry *de;
210
	struct inode *inode;
211
	int res;
212
	const char *name = dentry->d_name.name;
213
	int name_length = dentry->d_name.len;
214
	int ino;
215
	char szFormatName[FATX_MAX_NAME_LENGTH];
216
	
217
	res = fatx_format_name(name,name_length,szFormatName);
218
	if (res < 0)
219
		return res;
220
	if (fatx_scan(dir,name,name_length,&bh,&de,&ino) >= 0)
221
		goto out_exist;
222
223
	res = fatx_add_entry(dir, szFormatName, name_length, &bh, &de, &ino, 1);
224
	if (res)
225
		goto out_unlock;
226
	inode = fatx_build_inode(dir->i_sb, de, ino, &res);
227
	if (!inode) {
228
		if(bh) brelse(bh);
229
		goto out_unlock;
230
	}
231
	res = 0;
232
233
	dir->i_nlink++;
234
	inode->i_nlink = 2; /* no need to mark them dirty */
235
236
	res = fatx_new_dir(inode, dir);
237
	if (res)
238
		goto mkdir_error;
239
240
	if(bh) brelse(bh);
241
	d_instantiate(dentry, inode);
242
	res = 0;
243
244
out_unlock:
245
	return res;
246
247
mkdir_error:
248
	printk(KERN_WARNING "fatx_mkdir: error=%d, attempting cleanup\n", res);
249
	inode->i_nlink = 0;
250
	inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
251
	dir->i_nlink--;
252
	mark_inode_dirty(inode);
253
	mark_inode_dirty(dir);
254
	de->name_length = DELETED_FLAG;
255
	mark_buffer_dirty(bh);
256
	if(bh) brelse(bh);
257
	fatx_detach(inode);
258
	iput(inode);
259
	goto out_unlock;
260
261
out_exist:
262
	if(bh) brelse(bh);
263
	res = -EINVAL;
264
	goto out_unlock;
265
}
266
267
/*
268
 * Unlink a file 
269
 */
270
271
int fatx_unlink( struct inode *dir, struct dentry *dentry)
272
{
273
	struct inode *inode = dentry->d_inode;
274
	int res,ino;
275
	struct buffer_head *bh;
276
	struct fatx_dir_entry *de;
277
278
	bh = NULL;
279
	res = fatx_find(dir, dentry->d_name.name, dentry->d_name.len,
280
			&bh, &de, &ino);
281
	if (res < 0)
282
		goto unlink_done;
283
284
	de->name_length = DELETED_FLAG;
285
	mark_buffer_dirty(bh);
286
	fatx_detach(inode);
287
	if(bh) brelse(bh);
288
	inode->i_nlink = 0;
289
	inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
290
	mark_inode_dirty(inode);
291
	mark_inode_dirty(dir);
292
	res = 0;
293
unlink_done:
294
	return res;
295
}
296
297
static int do_fatx_rename(struct inode *old_dir, struct dentry *old_dentry,
298
		struct inode *new_dir, struct dentry *new_dentry,
299
		struct buffer_head *old_bh, struct fatx_dir_entry *old_de,
300
		int old_ino )
301
{
302
	struct buffer_head *new_bh=NULL,*dotdot_bh=NULL;
303
	struct fatx_dir_entry *new_de,*dotdot_de;
304
	struct inode *old_inode,*new_inode;
305
	int new_ino, dotdot_ino;
306
	int error;
307
	int is_dir;
308
	const char *new_name = new_dentry->d_name.name;
309
	int new_name_len = new_dentry->d_name.len;
310
311
	PRINTK("FATX: do_fatx_rename: entered\n");
312
	
313
	old_inode = old_dentry->d_inode;
314
	new_inode = new_dentry->d_inode;
315
	is_dir = S_ISDIR(old_inode->i_mode);
316
317
	error = fatx_scan(new_dir,new_name,new_name_len,&new_bh,&new_de,&new_ino);
318
	if (error>=0 &&!new_inode)
319
		goto degenerate_case;
320
321
	if (!new_bh) {
322
		error = fatx_add_entry(	new_dir, new_name, new_name_len, &new_bh, 
323
				&new_de, &new_ino, is_dir );
324
		if (error)
325
			goto out;
326
	}
327
	new_dir->i_version = ++event;
328
329
	/* There we go */
330
331
	if (new_inode)
332
		fatx_detach(new_inode);
333
	old_de->name_length = DELETED_FLAG;
334
	mark_buffer_dirty(old_bh);
335
	fatx_detach(old_inode);
336
	fatx_attach(old_inode, new_ino);
337
	FATX_I(old_inode)->i_attrs &= ~ATTR_HIDDEN;
338
	mark_inode_dirty(old_inode);
339
	old_dir->i_version = ++event;
340
	old_dir->i_ctime = old_dir->i_mtime = old_dir->i_atime = CURRENT_TIME;
341
	mark_inode_dirty(old_dir);
342
	if (new_inode) {
343
		new_inode->i_nlink--;
344
		new_inode->i_ctime = new_inode->i_atime = CURRENT_TIME;
345
		mark_inode_dirty(new_inode);
346
	}
347
	if (dotdot_bh) {
348
		dotdot_de->start = CT_LE_W(FATX_I(new_dir)->i_logstart);
349
350
		mark_buffer_dirty(dotdot_bh);
351
		old_dir->i_nlink--;
352
		mark_inode_dirty(old_dir);
353
		if (new_inode) {
354
			new_inode->i_nlink--;
355
			mark_inode_dirty(new_inode);
356
		} else {
357
			new_dir->i_nlink++;
358
			mark_inode_dirty(new_dir);
359
		}
360
	}
361
	error = 0;
362
out:
363
	if(new_bh) brelse(new_bh);
364
	if(dotdot_bh) brelse(dotdot_bh);
365
	PRINTK("FATX: do_fatx_rename: leaving (normal)\n");
366
	return error;
367
368
degenerate_case:
369
	error = -EINVAL;
370
	if (new_de!=old_de)
371
		goto out;
372
	FATX_I(old_inode)->i_attrs &= ~ATTR_HIDDEN;
373
	mark_inode_dirty(old_inode);
374
	old_dir->i_version = ++event;
375
	old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
376
	mark_inode_dirty(old_dir);
377
	PRINTK("FATX: do_fatx_rename: leaving (degenerate)\n");
378
	return 0;
379
}
380
381
/*
382
 * Rename, a wrapper for rename_same_dir & rename_diff_dir 
383
 */
384
385
int fatx_rename(struct inode *old_dir,struct dentry *old_dentry,
386
		 struct inode *new_dir,struct dentry *new_dentry)
387
{
388
	struct buffer_head *old_bh;
389
	struct fatx_dir_entry *old_de;
390
	int old_ino, error;
391
392
	error = fatx_format_name(old_dentry->d_name.name,old_dentry->d_name.len,NULL);
393
	if (error < 0)
394
		goto rename_done;
395
	error = fatx_format_name(new_dentry->d_name.name,new_dentry->d_name.len,NULL);
396
	if (error < 0)
397
		goto rename_done;
398
399
	error = fatx_scan(old_dir, old_dentry->d_name.name, old_dentry->d_name.len, &old_bh, &old_de, &old_ino );
400
	if (error < 0)
401
		goto rename_done;
402
403
	error = do_fatx_rename( old_dir, old_dentry, new_dir, new_dentry,
404
			old_bh, old_de, (ino_t)old_ino );
405
	if(old_bh) brelse(old_bh);
406
407
rename_done:
408
	return error;
409
}
(-)linux-2.4.26/fs/nls/CVS/Entries (+2 lines)
Line 0 Link Here
1
/Config.in/1.2/Sat Sep 13 20:36:11 2003//
2
D
(-)linux-2.4.26/fs/nls/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/fs/nls
(-)linux-2.4.26/fs/nls/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/fs/nls/Config.in (-1 / +2 lines)
Lines 13-19 Link Here
13
if [ "$CONFIG_JOLIET" = "y" -o "$CONFIG_FAT_FS" != "n" \
13
if [ "$CONFIG_JOLIET" = "y" -o "$CONFIG_FAT_FS" != "n" \
14
	-o "$CONFIG_NTFS_FS" != "n" -o "$CONFIG_NCPFS_NLS" = "y" \
14
	-o "$CONFIG_NTFS_FS" != "n" -o "$CONFIG_NCPFS_NLS" = "y" \
15
	-o "$CONFIG_SMB_NLS" = "y" -o "$CONFIG_JFS_FS" != "n" \
15
	-o "$CONFIG_SMB_NLS" = "y" -o "$CONFIG_JFS_FS" != "n" \
16
	-o "$CONFIG_BEFS_FS" != "n" -o "$CONFIG_HFSPLUS_FS" != "n" ]; then
16
	-o "$CONFIG_BEFS_FS" != "n" -o "$CONFIG_HFSPLUS_FS" != "n" \
17
	-o "$CONFIG_FATX_FS" != "n" ]; then
17
  define_bool CONFIG_NLS y
18
  define_bool CONFIG_NLS y
18
else
19
else
19
  define_bool CONFIG_NLS n
20
  define_bool CONFIG_NLS n
(-)linux-2.4.26/fs/partitions/CVS/Entries (+6 lines)
Line 0 Link Here
1
/Config.in/1.4/Fri Oct  3 16:15:57 2003//
2
/Makefile/1.3/Tue Dec  3 09:24:25 2002//
3
/check.c/1.8/Wed Feb 18 23:45:59 2004//
4
/xbox.c/1.18/Sun Mar 14 22:16:19 2004//
5
/xbox.h/1.3/Fri Mar 14 17:59:24 2003//
6
D
(-)linux-2.4.26/fs/partitions/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/fs/partitions
(-)linux-2.4.26/fs/partitions/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/fs/partitions/Config.in (+1 lines)
Lines 18-23 Link Here
18
      bool '  IBM disk label and partition support' CONFIG_IBM_PARTITION
18
      bool '  IBM disk label and partition support' CONFIG_IBM_PARTITION
19
   fi
19
   fi
20
   bool '  Macintosh partition map support' CONFIG_MAC_PARTITION
20
   bool '  Macintosh partition map support' CONFIG_MAC_PARTITION
21
   bool '  Xbox partition support' CONFIG_XBOX_PARTITION
21
   bool '  PC BIOS (MSDOS partition tables) support' CONFIG_MSDOS_PARTITION
22
   bool '  PC BIOS (MSDOS partition tables) support' CONFIG_MSDOS_PARTITION
22
   if [ "$CONFIG_MSDOS_PARTITION" = "y" ]; then
23
   if [ "$CONFIG_MSDOS_PARTITION" = "y" ]; then
23
      bool '    BSD disklabel (FreeBSD partition tables) support' CONFIG_BSD_DISKLABEL
24
      bool '    BSD disklabel (FreeBSD partition tables) support' CONFIG_BSD_DISKLABEL
(-)linux-2.4.26/fs/partitions/Makefile (+1 lines)
Lines 19-24 Link Here
19
obj-$(CONFIG_MAC_PARTITION) += mac.o
19
obj-$(CONFIG_MAC_PARTITION) += mac.o
20
obj-$(CONFIG_LDM_PARTITION) += ldm.o
20
obj-$(CONFIG_LDM_PARTITION) += ldm.o
21
obj-$(CONFIG_MSDOS_PARTITION) += msdos.o
21
obj-$(CONFIG_MSDOS_PARTITION) += msdos.o
22
obj-$(CONFIG_XBOX_PARTITION) += xbox.o
22
obj-$(CONFIG_OSF_PARTITION) += osf.o
23
obj-$(CONFIG_OSF_PARTITION) += osf.o
23
obj-$(CONFIG_SGI_PARTITION) += sgi.o
24
obj-$(CONFIG_SGI_PARTITION) += sgi.o
24
obj-$(CONFIG_SUN_PARTITION) += sun.o
25
obj-$(CONFIG_SUN_PARTITION) += sun.o
(-)linux-2.4.26/fs/partitions/check.c (-1 / +9 lines)
Lines 34-40 Link Here
34
#include "ibm.h"
34
#include "ibm.h"
35
#include "ultrix.h"
35
#include "ultrix.h"
36
#include "efi.h"
36
#include "efi.h"
37
37
#ifdef CONFIG_XBOX_PARTITION
38
#include "xbox.h"
39
#endif
38
extern int *blk_size[];
40
extern int *blk_size[];
39
41
40
int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
42
int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
Lines 268-273 Link Here
268
270
269
	printk(" unknown partition table\n");
271
	printk(" unknown partition table\n");
270
setup_devfs:
272
setup_devfs:
273
/* if the drive is Xbox-formatted, add partitions 50+ to the existing
274
   partitions - this way, an Xbox HD can have 2 partitioning systems
275
   systems: the implicit Xbox one (50+) and the explicit one (1+) */
276
#ifdef CONFIG_XBOX_PARTITION
277
        xbox_partition(hd, bdev, first_sector, first_part_minor);
278
#endif
271
	invalidate_bdev(bdev, 1);
279
	invalidate_bdev(bdev, 1);
272
	truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
280
	truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
273
	bdput(bdev);
281
	bdput(bdev);
(-)linux-2.4.26/fs/partitions/xbox.c (+141 lines)
Line 0 Link Here
1
/*
2
 *  fs/partitions/xbox.c
3
 *
4
 *  Created in June 2002 by SpeedBump
5
 *  additions/policy changes/cleanups
6
 *  by Edgar Hucek and Michael Steil
7
 */
8
9
#include <linux/config.h>
10
#include <linux/delay.h>
11
#include <linux/fs.h>
12
#include <linux/genhd.h>
13
#include <linux/kernel.h>
14
#include <linux/major.h>
15
#include <linux/string.h>
16
#include <linux/blk.h>
17
18
#ifdef CONFIG_BLK_DEV_IDE
19
#include <linux/ide.h>	/* IDE xlate */
20
#endif /* CONFIG_BLK_DEV_IDE */
21
22
#include <asm/system.h>
23
24
#include "check.h"
25
#include "xbox.h"
26
27
#define XBOX_SECTOR_STORE	(0x0055F400L)
28
#define XBOX_SECTOR_SYSTEM	(0x00465400L)
29
#define XBOX_SECTOR_CONFIG	(0x00000000L)
30
#define XBOX_SECTOR_CACHE1	(0x00000400L)
31
#define XBOX_SECTOR_CACHE2	(0x00177400L)
32
#define XBOX_SECTOR_CACHE3	(0x002EE400L)
33
//#define XBOX_SECTOR_EXTEND	(0x00EEEC00L)
34
#define XBOX_SECTOR_EXTEND	(0x00EE8AB0L)
35
#define XBOX_SECTORS_CONFIG	(XBOX_SECTOR_CACHE1 - XBOX_SECTOR_CONFIG)
36
37
#define XBOX_SECTORS_STORE	(XBOX_SECTOR_EXTEND - XBOX_SECTOR_STORE)
38
#define XBOX_SECTORS_SYSTEM	(XBOX_SECTOR_STORE  - XBOX_SECTOR_SYSTEM)
39
#define XBOX_SECTORS_CACHE1	(XBOX_SECTOR_CACHE2 - XBOX_SECTOR_CACHE1)
40
#define XBOX_SECTORS_CACHE2	(XBOX_SECTOR_CACHE3 - XBOX_SECTOR_CACHE2)
41
#define XBOX_SECTORS_CACHE3	(XBOX_SECTOR_SYSTEM - XBOX_SECTOR_CACHE3)
42
#define XBOX_SECTORS_CONFIG	(XBOX_SECTOR_CACHE1 - XBOX_SECTOR_CONFIG)
43
44
#define XBOX_SECTOR_MAGIC	(3L)
45
46
static int
47
xbox_sig_string_match(	struct block_device *bdev, 
48
			unsigned long at_sector,
49
			char *expect )
50
{
51
	Sector sect;
52
	int retv;
53
	char *data;
54
55
	data = read_dev_sector(bdev, at_sector, &sect);
56
	
57
	if (!data) return 0;
58
	
59
	if (*(u32*)expect == *(u32*)data) retv = 1; else retv = 0;
60
	
61
	put_dev_sector(sect);
62
	
63
	/*
64
	if (!retv) {
65
		printk("xbox_sig_string_match: %s not found...found %c%c%c%c\n",
66
			expect,data[0],data[1],data[2],data[3]);
67
		for(i = 1; i<=512; i++) {
68
			printk(((i%32)?"%02X ":"%02X\n"),(unsigned char)data[i]);
69
		}
70
	}
71
	*/
72
	return retv;
73
}
74
75
static inline int
76
xbox_drive_detect(struct block_device *bdev)
77
{
78
	
79
	/** 
80
	* "BRFR" is apparently the magic number in the config area
81
	* the others are just paranoid checks to assure the expected
82
	* "FATX" tags for the other xbox partitions
83
	*
84
	* the odds against a non-xbox drive having random data to match is
85
	* astronomical...but it's possible I guess...you should only include
86
	* this check if you actually *have* an xbox drive...since it has to
87
	* be detected first
88
	*
89
	* @see check.c
90
	*/
91
	if (	(xbox_sig_string_match(bdev,XBOX_SECTOR_MAGIC ,"BRFR")) &&
92
		(xbox_sig_string_match(bdev,XBOX_SECTOR_SYSTEM,"FATX")) &&
93
		(xbox_sig_string_match(bdev,XBOX_SECTOR_STORE ,"FATX"))) {
94
		return 1; //success
95
	}
96
	
97
	return 0; // no xbox drive
98
}
99
100
int xbox_partition(struct gendisk *hd, struct block_device *bdev,
101
		   unsigned long first_sector, int first_part_minor)
102
{
103
	kdev_t dev;
104
	ide_drive_t *drive;
105
	unsigned long last_sector;
106
	unsigned long last_lba28_sector;
107
	int minor = first_part_minor;
108
	int retv;
109
	
110
	// return if not hda, avoiding NULL pointers and Oopses
111
	// if (hd->major != 3) return 0;
112
113
	dev = to_kdev_t(bdev->bd_dev);
114
	drive = ide_info_ptr(dev, 0);
115
	if (drive == NULL)
116
		return 0;
117
	else
118
		last_sector = drive->capacity - 1;
119
120
	if (first_sector != 0) {
121
		//we only accept whole ide drives...no partials
122
		printk("xbox_partition: failed...first_sector != 0 == %ld\n",first_sector);
123
		return 0;
124
	}
125
	
126
	retv = xbox_drive_detect(bdev);
127
	if (retv > 0) {
128
		/* trying to find the first free partition */
129
		minor = 50;
130
		add_gd_partition(hd,minor++,XBOX_SECTOR_STORE ,XBOX_SECTORS_STORE );
131
		add_gd_partition(hd,minor++,XBOX_SECTOR_SYSTEM,XBOX_SECTORS_SYSTEM);
132
		add_gd_partition(hd,minor++,XBOX_SECTOR_CACHE1,XBOX_SECTORS_CACHE1);
133
		add_gd_partition(hd,minor++,XBOX_SECTOR_CACHE2,XBOX_SECTORS_CACHE2);
134
		add_gd_partition(hd,minor++,XBOX_SECTOR_CACHE3,XBOX_SECTORS_CACHE3);
135
		if (xbox_sig_string_match(bdev,XBOX_SECTOR_EXTEND ,"FATX")) 
136
			add_gd_partition(hd,minor++,XBOX_SECTOR_EXTEND,last_sector-XBOX_SECTOR_EXTEND);
137
	} else {
138
		//not an xbox drive
139
		return 0;
140
	}
141
}
(-)linux-2.4.26/fs/partitions/xbox.h (+7 lines)
Line 0 Link Here
1
/*
2
 *  fs/partitions/xbox.h
3
 */
4
5
int xbox_partition(struct gendisk *hd, struct block_device *bdev,
6
		   unsigned long first_sector, int first_part_minor);
7
(-)linux-2.4.26/include/CVS/Entries (+3 lines)
Line 0 Link Here
1
D/asm-i386////
2
D/linux////
3
D/video////
(-)linux-2.4.26/include/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/include
(-)linux-2.4.26/include/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/include/asm-i386/CVS/Entries (+2 lines)
Line 0 Link Here
1
/timex.h/1.5/Thu Aug  7 01:29:16 2003//
2
D
(-)linux-2.4.26/include/asm-i386/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/include/asm-i386
(-)linux-2.4.26/include/asm-i386/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/include/asm-i386/timex.h (-3 / +7 lines)
Lines 9-18 Link Here
9
#include <linux/config.h>
9
#include <linux/config.h>
10
#include <asm/msr.h>
10
#include <asm/msr.h>
11
11
12
#ifdef CONFIG_MELAN
12
#ifdef CONFIG_XBOX
13
#  define CLOCK_TICK_RATE 1189200 /* AMD Elan has different frequency! */
13
extern int CLOCK_TICK_RATE;
14
#else
14
#else
15
#  define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
15
#  ifdef CONFIG_MELAN
16
#    define CLOCK_TICK_RATE 1189200 /* AMD Elan has different frequency! */
17
#  else
18
#    define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
19
#  endif
16
#endif
20
#endif
17
21
18
#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
22
#define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
(-)linux-2.4.26/include/linux/CVS/Entries (+8 lines)
Line 0 Link Here
1
/fatx_fs.h/1.5/Sat Mar 15 07:19:45 2003//
2
/fatx_fs_i.h/1.1/Wed Mar 12 09:06:46 2003//
3
/fatx_fs_sb.h/1.1/Wed Mar 12 09:06:47 2003//
4
/fs.h/1.5/Wed Feb 18 23:45:59 2004//
5
/i2c-id.h/1.5/Wed Feb 18 23:45:59 2004//
6
/xbox.h/1.9/Thu Mar 18 07:13:55 2004//
7
/xboxfbctl.h/1.1/Thu Feb 12 23:05:41 2004//
8
D
(-)linux-2.4.26/include/linux/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/include/linux
(-)linux-2.4.26/include/linux/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/include/linux/fatx_fs.h (+238 lines)
Line 0 Link Here
1
#ifndef _LINUX_FATX_FS_H
2
#define _LINUX_FATX_FS_H
3
4
#ifdef __KERNEL__
5
6
/*
7
 *
8
 *  The FATX filesystem constants/structures
9
 *
10
 *  Written 2003 by Edgar Hucek and Lehner Franz
11
 *
12
 */
13
14
#include <linux/fs.h>
15
#include <linux/stat.h>
16
#include <linux/fd.h>
17
#include <linux/dcache.h>
18
#include <linux/nls.h>
19
20
#include <asm/byteorder.h>
21
22
#define FATX_ROOT_INO  1 /* == MINIX_ROOT_INO */
23
24
#define FATX_CACHE    8 /* FAT cache size */
25
26
#define FATX_SB(s) (&((s)->u.fatx_sb))
27
#define FATX_I(i) (&((i)->u.fatx_i))
28
29
//#define FATX32_MAX_NON_LFS     ((1ULL<<32) - 1)
30
#define FATX32_MAX_NON_LFS     ((1UL<<32) - 1)
31
#define FATX16_MAX_NON_LFS     ((1UL<<30) - 1)
32
	
33
#define CLUSTER_SIZE 32
34
#define ATTR_RO      1  /* read-only */
35
#define ATTR_HIDDEN  2  /* hidden */
36
#define ATTR_SYS     4  /* system */
37
#define ATTR_DIR     16 /* directory */
38
#define ATTR_ARCH    0  /* archived */
39
#define ATTR_UNUSED  (ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
40
41
#define ATTR_NONE    0 /* no attribute bits */
42
43
#define FATX_BOOTBLOCK_MAGIC cpu_to_le32(0x58544146)
44
#define FATX_MAX_NAME_LENGTH 42
45
#define FATX_DIR_BITS 6
46
47
#define DELETED_FLAG 0xe5 /* marks file as deleted when in name_length */
48
49
//FF == end of directory info, E5 == deleted entry
50
#define FATX_IS_FREE(de) ((de)->name_length==DELETED_FLAG)
51
#define FATX_END_OF_DIR(de) ((de)->name_length==0xFF)
52
53
#define IS_FREE(n) (!*(n) || *(const unsigned char *) (n) == DELETED_FLAG)
54
55
#define CF_LE_W(v) le16_to_cpu(v)
56
#define CF_LE_L(v) le32_to_cpu(v)
57
#define CT_LE_W(v) cpu_to_le16(v)
58
#define CT_LE_L(v) cpu_to_le32(v)
59
60
#define EOC_FAT16 0xFFF8	// end of chain marker
61
#define EOC_FAT32 0xFFFFFFF8	// end of chain marker
62
#define EOF_FAT16 0xFFF8	// end of file marker
63
#define EOF_FAT32 0xFFFFFFF8	// end of file marker
64
#define EOF_FAT(s) (FATX_SB(s)->fat_bits == 32 ? EOF_FAT32 : EOF_FAT16)
65
66
#define FATX_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
67
68
/* Convert attribute bits and a mask to the UNIX mode. */
69
#define FATX_MKMODE(a,m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
70
71
/* Convert the UNIX mode to FATX attribute bits. */
72
#define FATX_MKATTR(m) ((m & S_IWUGO) ? ATTR_NONE : ATTR_RO)
73
74
struct fatx_boot_sector {
75
        __u32	magic;		/* "FATX" */
76
	__u32	volume_id;	/* Volume ID */
77
        __u32	cluster_size;	/* sectors/cluster */
78
	__u16	fats;		/* number of FATs */
79
	__u32	unknown;
80
};
81
82
struct fatx_dir_entry {
83
        __u8	name_length;	/* length of filename (bytes) */
84
	__u8	attr;		/* attribute bits */
85
        __s8	name[42];	/* filename */
86
	__u32	start;		/* first cluster */
87
	__u32	size;		/* file size (in bytes) */
88
	__u16	time,date;	/* time, date */
89
	__u16	ctime,cdate;	/* Creation time */
90
	__u16	atime,adate;	/* Last access time */
91
};
92
93
struct fatx_boot_fsinfo {
94
	__u32   signature1;	/* 0x41615252L */
95
	__u32   reserved1[120];	/* Nothing as far as I can tell */
96
	__u32   signature2;	/* 0x61417272L */
97
	__u32   free_clusters;	/* Free cluster count.  -1 if unknown */
98
	__u32   next_cluster;	/* Most recently allocated cluster.
99
				 * Unused under Linux. */
100
	__u32   reserved2[4];
101
};
102
103
struct fatx_cache {
104
	kdev_t device; /* device number. 0 means unused. */
105
	int start_cluster; /* first cluster of the chain. */
106
	int file_cluster; /* cluster number in the file. */
107
	int disk_cluster; /* cluster number on disk. */
108
	struct fatx_cache *next; /* next cache entry */
109
};
110
111
/* fatx/cache.c */
112
extern int fatx_access(struct super_block *sb, int nr, int new_value);
113
extern unsigned long fatx_bmap(struct inode *inode, unsigned long sector);
114
extern void fatx_cache_init(void);
115
extern void fatx_cache_lookup(struct inode *inode, int cluster, int *f_clu,
116
			     int *d_clu);
117
extern void fatx_cache_add(struct inode *inode, int f_clu, int d_clu);
118
extern void fatx_cache_inval_inode(struct inode *inode);
119
extern void fatx_cache_inval_dev(kdev_t device);
120
extern int fatx_get_cluster(struct inode *inode, int cluster);
121
extern int fatx_free(struct inode *inode, int skip);
122
123
/* fatx/dir.c */
124
extern struct file_operations fat_dir_operations;
125
extern int fatx_readdir(struct file *filp, void *dirent, filldir_t filldir);
126
extern int fatx_dir_empty(struct inode *dir);
127
extern int fatx_add_entries(struct inode *dir, int slots, struct buffer_head **bh,
128
			   struct fatx_dir_entry **de, int *ino);
129
extern int fatx_new_dir(struct inode *dir, struct inode *parent);
130
131
/* fat/file.c */
132
extern struct file_operations fatx_file_operations;
133
extern struct inode_operations fatx_file_inode_operations;
134
extern ssize_t fatx_file_read(struct file *filp, char *buf, size_t count,
135
			     loff_t *ppos);
136
extern int fatx_get_block(struct inode *inode, long iblock,
137
			 struct buffer_head *bh_result, int create);
138
extern ssize_t fatx_file_write(struct file *filp, const char *buf, size_t count,
139
			      loff_t *ppos);
140
extern void fatx_truncate(struct inode *inode);
141
142
/* fat/inode.c */
143
extern void fatx_hash_init(void);
144
extern void fatx_attach(struct inode *inode, int i_pos);
145
extern void fatx_detach(struct inode *inode);
146
extern struct inode *fatx_iget(struct super_block *sb, int i_pos);
147
extern struct inode *fatx_build_inode(
148
		struct super_block *sb,
149
		struct fatx_dir_entry *de, 
150
		int ino, 
151
		int *res);
152
153
extern void fatx_delete_inode(struct inode *inode);
154
extern void fatx_clear_inode(struct inode *inode);
155
extern void fatx_put_super(struct super_block *sb);
156
157
typedef int (*fatx_boot_block_parse_func)(
158
		struct super_block *sb, 
159
		struct buffer_head *bh );
160
typedef void (*fatx_read_root_func)(struct inode *inode);
161
162
extern int fatx_statfs(struct super_block *sb, struct statfs *buf);
163
extern void fatx_write_inode(struct inode *inode, int wait);
164
extern int fatx_notify_change(struct dentry * dentry, struct iattr * attr);
165
166
extern struct address_space_operations fatx_aops;
167
extern spinlock_t fatx_inode_lock;
168
169
170
/* fatx/namei.c - these are for the xbox's FATX */
171
extern struct dentry *fatx_lookup(struct inode *dir, struct dentry *);
172
extern int fatx_create(struct inode *dir, struct dentry *dentry, int mode);
173
extern int fatx_rmdir(struct inode *dir, struct dentry *dentry);
174
extern int fatx_unlink(struct inode *dir, struct dentry *dentry);
175
extern int fatx_mkdir(struct inode *dir, struct dentry *dentry, int mode);
176
extern int fatx_rename(struct inode *old_dir, struct dentry *old_dentry,
177
		       struct inode *new_dir, struct dentry *new_dentry);
178
extern struct super_block *fatx_read_super(struct super_block *sb, void *data,
179
					   int silent);
180
181
/* fatx/fatxfs_syms.c */
182
extern unsigned int fatx_debug;
183
184
extern struct file_system_type fatx_fs_type;
185
186
extern int fatx_get_entry(struct inode *dir,loff_t *pos,struct buffer_head **bh,
187
		struct fatx_dir_entry **de,int *ino );
188
189
extern int fatx_scan(struct inode *dir, const char *name, int name_length,
190
		struct buffer_head **res_bh,struct fatx_dir_entry **res_de,
191
		int *ino);
192
		
193
/* miscelaneous support code for fatx fs */
194
extern int fatx_date_dos2unix( unsigned short, unsigned short );
195
extern void fatx_date_unix2dos( int, unsigned short *, unsigned short * );
196
197
static inline unsigned char fatx_tolower(struct nls_table *t, unsigned char c)
198
{
199
	unsigned char nc = t->charset2lower[c];
200
201
	return nc ? nc : c;
202
}
203
204
static inline unsigned char fatx_toupper(struct nls_table *t, unsigned char c)
205
{
206
	unsigned char nc = t->charset2upper[c];
207
208
	return nc ? nc : c;
209
}
210
211
static inline int fatx_strnicmp(struct nls_table *t, const unsigned char *s1,
212
		const unsigned char *s2, int len )
213
{
214
	while(len--) {
215
		if (fatx_tolower(t, *s1++) != fatx_tolower(t, *s2++))
216
			return 1;
217
	}
218
	return 0;
219
}
220
221
/* directory code for fatx fs */
222
extern int fatx_do_add_entry(struct inode *dir,	struct buffer_head **bh,
223
		struct fatx_dir_entry **de, int *ino);
224
		
225
extern int fatx_dir_empty(struct inode *dir);
226
extern int fatx_subdirs(struct inode *dir);
227
		
228
extern struct file_operations fatx_dir_operations;
229
#endif /* __KERNEL__ */
230
231
extern int fatx_access(struct super_block *sb, int nr, int new_value);
232
extern void fatx_fs_panic(struct super_block *s, const char *msg);
233
extern struct buffer_head *fatx_extend_dir(struct inode *inode);
234
extern int fatx_add_cluster(struct inode *inode);
235
extern void lock_fatx(struct super_block *sb);
236
extern void unlock_fatx(struct super_block *sb);
237
238
#endif /* _LINUX_FATX_FS_H */
(-)linux-2.4.26/include/linux/fatx_fs_i.h (+23 lines)
Line 0 Link Here
1
#ifndef _FATX_FS_I
2
#define _FATX_FS_I
3
4
/*
5
 * 
6
 *  FATX file system inode data in memory
7
 *
8
 *  Written 2003 by Edgar Hucek and Lehner Franz
9
 *
10
 */
11
12
struct fatx_inode_info {
13
	unsigned long mmu_private;
14
	int i_start;	/* first cluster or 0 */
15
	int i_logstart;	/* logical first cluster */
16
	int i_attrs;	/* unused attribute bits */
17
	int i_ctime_ms;	/* unused change time in milliseconds */
18
	int i_location;	/* on-disk position of directory entry or 0 */
19
	struct inode *i_fat_inode;	/* struct inode of this one */
20
	struct list_head i_fat_hash;	/* hash by i_location */
21
};
22
23
#endif
(-)linux-2.4.26/include/linux/fatx_fs_sb.h (+46 lines)
Line 0 Link Here
1
#ifndef _FATX_FS_SB
2
#define _FATX_FS_SB
3
4
/*
5
 *  FATX file system in-core superblock data
6
 *
7
 *  Written 2003 by Edgar Hucek and Lehner Franz
8
 *
9
 */
10
11
struct fatx_mount_options {
12
	uid_t fs_uid;
13
	gid_t fs_gid;
14
	unsigned short fs_umask;
15
	unsigned short codepage;  /* Codepage for shortname conversions */
16
	unsigned short shortname; /* flags for shortname display/create rule */
17
	unsigned char name_check; /* r = relaxed, n = normal, s = strict */
18
	unsigned char conversion; /* b = binary, t = text, a = auto */
19
	unsigned quiet:1;         /* set = fake successful chmods and chowns */
20
};
21
22
struct fatx_sb_info {
23
	unsigned short cluster_size; /* sectors/cluster */
24
	unsigned short cluster_bits; /* sectors/cluster */
25
	unsigned char fats,fat_bits; /* number of FATs, FAT bits (12 or 16) */
26
	unsigned short fat_start;
27
	unsigned long fat_length;    /* FAT start & length (sec.) */
28
	unsigned long dir_start;
29
	unsigned short dir_entries;  /* root dir start & entries */
30
	unsigned long data_start;    /* first data sector */
31
	unsigned long clusters;      /* number of clusters */
32
	unsigned long root_cluster;  /* first cluster of the root directory */
33
	unsigned long fsinfo_sector; /* FAT32 fsinfo offset from start of disk */
34
	struct semaphore fat_lock;
35
	int prev_free;               /* previously returned free cluster number */
36
	int free_clusters;           /* -1 if undefined */
37
	struct fatx_mount_options options;
38
	struct nls_table *nls_disk;  /* Codepage used on disk */
39
	struct nls_table *nls_io;    /* Charset used for input and display */
40
	void *dir_ops;		     /* Opaque; default directory operations */
41
	void *private_data;
42
	int dir_per_block;	     /* dir entries per block */
43
	int dir_per_block_bits;	     /* log2(dir_per_block) */
44
};
45
46
#endif
(-)linux-2.4.26/include/linux/fs.h (+4 lines)
Lines 324-329 Link Here
324
#include <linux/usbdev_fs_i.h>
324
#include <linux/usbdev_fs_i.h>
325
#include <linux/jffs2_fs_i.h>
325
#include <linux/jffs2_fs_i.h>
326
#include <linux/cramfs_fs_sb.h>
326
#include <linux/cramfs_fs_sb.h>
327
#include <linux/fatx_fs_i.h>
327
328
328
/*
329
/*
329
 * Attribute flags.  These should be or-ed together to figure out what
330
 * Attribute flags.  These should be or-ed together to figure out what
Lines 519-524 Link Here
519
		struct socket			socket_i;
520
		struct socket			socket_i;
520
		struct usbdev_inode_info        usbdev_i;
521
		struct usbdev_inode_info        usbdev_i;
521
		struct jffs2_inode_info		jffs2_i;
522
		struct jffs2_inode_info		jffs2_i;
523
		struct fatx_inode_info          fatx_i;
522
		void				*generic_ip;
524
		void				*generic_ip;
523
	} u;
525
	} u;
524
};
526
};
Lines 733-738 Link Here
733
#include <linux/usbdev_fs_sb.h>
735
#include <linux/usbdev_fs_sb.h>
734
#include <linux/cramfs_fs_sb.h>
736
#include <linux/cramfs_fs_sb.h>
735
#include <linux/jffs2_fs_sb.h>
737
#include <linux/jffs2_fs_sb.h>
738
#include <linux/fatx_fs_sb.h>
736
739
737
extern struct list_head super_blocks;
740
extern struct list_head super_blocks;
738
extern spinlock_t sb_lock;
741
extern spinlock_t sb_lock;
Lines 792-797 Link Here
792
		struct usbdev_sb_info   usbdevfs_sb;
795
		struct usbdev_sb_info   usbdevfs_sb;
793
		struct jffs2_sb_info	jffs2_sb;
796
		struct jffs2_sb_info	jffs2_sb;
794
		struct cramfs_sb_info	cramfs_sb;
797
		struct cramfs_sb_info	cramfs_sb;
798
		struct fatx_sb_info     fatx_sb;
795
		void			*generic_sbp;
799
		void			*generic_sbp;
796
	} u;
800
	} u;
797
	/*
801
	/*
(-)linux-2.4.26/include/linux/i2c-id.h (-1 / +2 lines)
Lines 20-26 Link Here
20
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.		     */
20
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.		     */
21
/* ------------------------------------------------------------------------- */
21
/* ------------------------------------------------------------------------- */
22
22
23
/* $Id: i2c-id.h,v 1.35 2001/08/12 17:22:20 mds Exp $ */
23
/* $Id: i2c-id.h,v 1.5 2004/02/18 23:45:59 aothieno Exp $ */
24
24
25
#ifndef I2C_ID_H
25
#ifndef I2C_ID_H
26
#define I2C_ID_H
26
#define I2C_ID_H
Lines 102-107 Link Here
102
102
103
#define I2C_DRIVERID_I2CDEV	900
103
#define I2C_DRIVERID_I2CDEV	900
104
#define I2C_DRIVERID_I2CPROC	901
104
#define I2C_DRIVERID_I2CPROC	901
105
#define I2C_DRIVERID_XBOX_NVNET	904	/* XBox nvnet network driver	*/
105
106
106
/* IDs --   Use DRIVERIDs 1000-1999 for sensors. 
107
/* IDs --   Use DRIVERIDs 1000-1999 for sensors. 
107
   These were originally in sensors.h in the lm_sensors package */
108
   These were originally in sensors.h in the lm_sensors package */
(-)linux-2.4.26/include/linux/xbox.h (+135 lines)
Line 0 Link Here
1
#ifndef _XBOX_H_
2
#define _XBOX_H_
3
4
#define XBOX_SMB_IO_BASE 0xC000
5
#define XBOX_SMB_HOST_ADDRESS       (0x4 + XBOX_SMB_IO_BASE)
6
#define XBOX_SMB_HOST_COMMAND       (0x8 + XBOX_SMB_IO_BASE)
7
#define XBOX_SMB_HOST_DATA          (0x6 + XBOX_SMB_IO_BASE)
8
#define XBOX_SMB_GLOBAL_ENABLE       (0x2 + XBOX_SMB_IO_BASE)
9
#define XBOX_GE_CYC_TYPE_MASK (7)
10
#define XBOX_BYTE_DATA    0x02
11
12
#define XBOX_SMC_ADDRESS 0x10
13
#define XBOX_TV_ADDRESS 0x45
14
15
#define SMC_CMD_POWER 0x02
16
#define SMC_CMD_TRAY_STATE 0x03
17
#define SMC_CMD_AV_PACK 0x04
18
#define SMC_CMD_LED_MODE 0x07
19
#define SMC_CMD_LED_REGISTER 0x08
20
#define SMC_CMD_EJECT 0x0C
21
#define SMC_CMD_INTERRUPT_RESPOND 0x0D
22
#define SMC_CMD_INTERRUPT_REASON 0x11
23
#define SMC_CMD_RESET_ON_EJECT 0x19
24
#define SMC_CMD_SCRATCH_REGISTER 0x1B
25
// I think commands 20 and 21 are used for bootup authentication, but
26
// I don't know those commands.  The CROM people know.
27
//
28
#define SMC_SUBCMD_POWER_RESET 0x01
29
#define SMC_SUBCMD_POWER_CYCLE 0x40
30
#define SMC_SUBCMD_POWER_OFF 0x80
31
//
32
#define SMC_SUBCMD_RESPOND_CONTINUE 0x04
33
//
34
// These are from recent posts to this list (except MISSING)
35
#define SMC_VALUE_AV_SCART 0x00
36
#define SMC_VALUE_AV_HDTV 0x01
37
#define SMC_VALUE_AV_VGA 0x02
38
#define SMC_VALUE_AV_RFU 0x03
39
#define SMC_VALUE_AV_SVIDEO 0x04
40
#define SMC_VALUE_AV_STANDARD 0x06
41
#define SMC_VALUE_AV_UNDEFINED 0x05
42
#define SMC_VALUE_AV_MISSING 0x07
43
//
44
#define SMC_SUBCMD_LED_MODE_DEFAULT 0x00
45
#define SMC_SUBCMD_LED_MODE_CUSTOM 0x01
46
47
#define SMC_SUBCMD_EJECT_EJECT 0x00
48
#define SMC_SUBCMD_EJECT_LOAD 0x01
49
50
// Bits 01...40 all have meaning but I don't know them all.
51
#define SMC_VALUE_INTERRUPT_POWER_BUTTON 0x01
52
#define SMC_VALUE_INTERRUPT_AV_REMOVED 0x10
53
#define SMC_VALUE_INTERRUPT_EJECT_BUTTON 0x20
54
55
#define SMC_SUBCMD_RESET_ON_EJECT_ENABLE 0x00
56
#define SMC_SUBCMD_RESET_ON_EJECT_DISABLE 0x01
57
58
// These are defined by the *kernel*, not the SMC.
59
#define SMC_SCRATCH_EJECT_AFTER_BOOT 0x01
60
#define SMC_SCRATCH_DISPLAY_ERROR 0x02
61
#define SMC_SCRATCH_NO_ANIMATION 0x04
62
#define SMC_SCRATCH_RUN_DASHBOARD 0x08
63
64
/* interrupt causes */
65
#define POWERDOWN_MASK (1<<0)
66
#define TRAYCLOSED_MASK (1<<1)
67
#define TRAYOPENING_MASK (1<<2)
68
#define AVPLUGGED_MASK (1<<3)
69
#define AVUNPLUGGED_MASK (1<<4)
70
#define TRAYBUTTON_MASK (1<<5)
71
#define TRAYCLOSING_MASK (1<<6)
72
#define UNKNOWN_MASK (1<<7)
73
74
extern int machine_is_xbox;
75
76
#define XBOX_I2C_IO_BASE 0xc000
77
static inline void Xbox_SMC_write(u8 d1,u8 d2) {
78
	int c=4;
79
	u8 b=0;
80
	u32 dwSpinsToLive = 0x8000000;
81
82
	/*
83
	while(inw(XBOX_I2C_IO_BASE+0)&0x0800);
84
	*/
85
	while(c--) {
86
		outb(XBOX_SMC_ADDRESS<<1, XBOX_SMB_HOST_ADDRESS);
87
		outb((u8)d1, XBOX_SMB_HOST_COMMAND);
88
		outb((u8)d2, XBOX_SMB_HOST_DATA);
89
		outw(0xffff, XBOX_I2C_IO_BASE+0);
90
		outb(0x0a, XBOX_SMB_GLOBAL_ENABLE);
91
		{
92
			while((b !=0x10) && ((b&0x26)==0) && (dwSpinsToLive--)) {
93
				b=inb(XBOX_I2C_IO_BASE);
94
			}
95
			if(b&0x2) continue;
96
			if(b&0x24) continue;
97
			if(!(b&0x10)) continue;
98
			break;
99
		}
100
	}
101
}
102
103
static inline int Xbox_SMC_read(u8 d) {
104
        int c=4;
105
	u8 b=0;
106
	u32 dwSpinsToLive = 0x8000000;
107
	
108
	/*
109
	while(inw(XBOX_I2C_IO_BASE+0)&0x0800);
110
	*/
111
        while(c--) {
112
		outb((XBOX_SMC_ADDRESS<<1)|1, XBOX_SMB_HOST_ADDRESS);
113
                outb(d, XBOX_SMB_HOST_COMMAND);
114
                outw(0xffff, XBOX_I2C_IO_BASE+0);
115
                outb(0x0a, XBOX_SMB_GLOBAL_ENABLE);
116
		{
117
			while((b !=0x10) && ((b&0x26)==0) && (dwSpinsToLive--)) {
118
				b=inb(XBOX_I2C_IO_BASE);
119
			}
120
			if(b&0x2) continue;
121
			if(b&0x24) continue;
122
			if(!(b&0x10)) continue;
123
			break;	
124
		}
125
	}
126
	return (int)inb(XBOX_SMB_HOST_DATA);
127
}
128
129
#define Xbox_tray_load() Xbox_SMC_write(SMC_CMD_EJECT, SMC_SUBCMD_EJECT_LOAD);
130
#define Xbox_tray_eject() Xbox_SMC_write(SMC_CMD_EJECT, SMC_SUBCMD_EJECT_EJECT);
131
132
#define Xbox_power_off() Xbox_SMC_write(SMC_CMD_POWER, SMC_SUBCMD_POWER_OFF);
133
#define Xbox_reset() Xbox_SMC_write(SMC_CMD_POWER, SMC_SUBCMD_POWER_CYCLE);
134
135
#endif /* _XBOX_H_ */
(-)linux-2.4.26/include/linux/xboxfbctl.h (+66 lines)
Line 0 Link Here
1
/*
2
 * linux/include/video/xboxfbctl.h
3
 * - Type definitions for ioctls of Xbox video driver
4
 *
5
 * Maintainer: Oliver Schwartz <Oliver.Schwartz@gmx.de>
6
 *
7
 * Contributors:
8
 *
9
 * This file is subject to the terms and conditions of the GNU General Public
10
 * License.  See the file COPYING in the main directory of this archive
11
 * for more details.
12
 *
13
 * Known bugs and issues:
14
 *
15
 *      none
16
 */
17
18
#ifndef xbofbctl_h
19
#define xbofbctl_h
20
21
typedef enum enumVideoStandards {
22
	TV_ENC_INVALID=-1,
23
	TV_ENC_NTSC=0,
24
	TV_ENC_NTSC60,
25
	TV_ENC_PALBDGHI,
26
	TV_ENC_PALN,
27
	TV_ENC_PALNC,
28
	TV_ENC_PALM,
29
	TV_ENC_PAL60
30
} xbox_tv_encoding;
31
32
typedef enum enumAvTypes {
33
	AV_INVALID=-1,
34
	AV_SCART_RGB,
35
	AV_SVIDEO,
36
	AV_VGA_SOG,
37
	AV_HDTV,
38
	AV_COMPOSITE,
39
	AV_VGA
40
} xbox_av_type;
41
42
typedef enum enumEncoderType {
43
	ENCODER_CONEXANT,
44
	ENCODER_FOCUS
45
} xbox_encoder_type;
46
47
typedef struct _xboxOverscan {
48
	double hoc;
49
	double voc;
50
} xbox_overscan;
51
52
typedef struct _xboxFbConfig {
53
	xbox_av_type av_type;
54
	xbox_encoder_type encoder_type;
55
} xboxfb_config;
56
57
#define FBIO_XBOX_GET_OVERSCAN  _IOR('x', 1, xbox_overscan)
58
/* in param: double  hoc (0.0-0.2), double voc (0.0 - 0.2) */
59
#define FBIO_XBOX_SET_OVERSCAN  _IOW('x', 2, xbox_overscan)
60
61
#define FBIO_XBOX_GET_TV_ENCODING  _IOR('x', 3, xbox_tv_encoding)
62
#define FBIO_XBOX_SET_TV_ENCODING  _IOW('x', 4, xbox_tv_encoding)
63
64
#define FBIO_XBOX_GET_CONFIG  _IOR('x', 5, xboxfb_config)
65
66
#endif
(-)linux-2.4.26/include/video/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)linux-2.4.26/include/video/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/include/video
(-)linux-2.4.26/include/video/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/init/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)linux-2.4.26/init/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/init
(-)linux-2.4.26/init/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/kernel.config (+1028 lines)
Line 0 Link Here
1
#
2
# Automatically generated make config: don't edit
3
#
4
CONFIG_X86=y
5
# CONFIG_SBUS is not set
6
CONFIG_UID16=y
7
8
#
9
# Code maturity level options
10
#
11
CONFIG_EXPERIMENTAL=y
12
13
#
14
# Loadable module support
15
#
16
CONFIG_MODULES=y
17
# CONFIG_MODVERSIONS is not set
18
CONFIG_KMOD=y
19
20
#
21
# Processor type and features
22
#
23
# CONFIG_M386 is not set
24
# CONFIG_M486 is not set
25
# CONFIG_M586 is not set
26
# CONFIG_M586TSC is not set
27
# CONFIG_M586MMX is not set
28
# CONFIG_M686 is not set
29
CONFIG_MPENTIUMIII=y
30
# CONFIG_MPENTIUM4 is not set
31
# CONFIG_MK6 is not set
32
# CONFIG_MK7 is not set
33
# CONFIG_MK8 is not set
34
# CONFIG_MELAN is not set
35
# CONFIG_MCRUSOE is not set
36
# CONFIG_MWINCHIPC6 is not set
37
# CONFIG_MWINCHIP2 is not set
38
# CONFIG_MWINCHIP3D is not set
39
# CONFIG_MCYRIXIII is not set
40
# CONFIG_MVIAC3_2 is not set
41
CONFIG_X86_WP_WORKS_OK=y
42
CONFIG_X86_INVLPG=y
43
CONFIG_X86_CMPXCHG=y
44
CONFIG_X86_XADD=y
45
CONFIG_X86_BSWAP=y
46
CONFIG_X86_POPAD_OK=y
47
# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
48
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
49
CONFIG_X86_L1_CACHE_SHIFT=5
50
CONFIG_X86_HAS_TSC=y
51
CONFIG_X86_GOOD_APIC=y
52
CONFIG_X86_PGE=y
53
CONFIG_X86_USE_PPRO_CHECKSUM=y
54
CONFIG_X86_F00F_WORKS_OK=y
55
# CONFIG_X86_MCE is not set
56
# CONFIG_TOSHIBA is not set
57
# CONFIG_I8K is not set
58
# CONFIG_MICROCODE is not set
59
# CONFIG_X86_MSR is not set
60
# CONFIG_X86_CPUID is not set
61
# CONFIG_EDD is not set
62
CONFIG_NOHIGHMEM=y
63
# CONFIG_HIGHMEM4G is not set
64
# CONFIG_HIGHMEM64G is not set
65
# CONFIG_HIGHMEM is not set
66
CONFIG_XBOX=y
67
CONFIG_XBOX_EJECT=y
68
# CONFIG_MATH_EMULATION is not set
69
CONFIG_MTRR=y
70
# CONFIG_SMP is not set
71
CONFIG_X86_UP_APIC=y
72
CONFIG_X86_UP_IOAPIC=y
73
CONFIG_X86_LOCAL_APIC=y
74
CONFIG_X86_IO_APIC=y
75
# CONFIG_X86_TSC_DISABLE is not set
76
CONFIG_X86_TSC=y
77
78
#
79
# General setup
80
#
81
CONFIG_NET=y
82
CONFIG_PCI=y
83
# CONFIG_PCI_GOBIOS is not set
84
CONFIG_PCI_GODIRECT=y
85
# CONFIG_PCI_GOANY is not set
86
CONFIG_PCI_DIRECT=y
87
# CONFIG_ISA is not set
88
CONFIG_PCI_NAMES=y
89
# CONFIG_EISA is not set
90
# CONFIG_MCA is not set
91
CONFIG_HOTPLUG=y
92
93
#
94
# PCMCIA/CardBus support
95
#
96
# CONFIG_PCMCIA is not set
97
98
#
99
# PCI Hotplug Support
100
#
101
# CONFIG_HOTPLUG_PCI is not set
102
# CONFIG_HOTPLUG_PCI_COMPAQ is not set
103
# CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM is not set
104
# CONFIG_HOTPLUG_PCI_IBM is not set
105
CONFIG_SYSVIPC=y
106
# CONFIG_BSD_PROCESS_ACCT is not set
107
CONFIG_SYSCTL=y
108
CONFIG_KCORE_ELF=y
109
# CONFIG_KCORE_AOUT is not set
110
CONFIG_BINFMT_AOUT=m
111
CONFIG_BINFMT_ELF=y
112
CONFIG_BINFMT_MISC=m
113
# CONFIG_OOM_KILLER is not set
114
# CONFIG_PM is not set
115
# CONFIG_APM is not set
116
117
#
118
# ACPI Support
119
#
120
# CONFIG_ACPI is not set
121
122
#
123
# Memory Technology Devices (MTD)
124
#
125
# CONFIG_MTD is not set
126
127
#
128
# Parallel port support
129
#
130
# CONFIG_PARPORT is not set
131
132
#
133
# Plug and Play configuration
134
#
135
# CONFIG_PNP is not set
136
# CONFIG_ISAPNP is not set
137
138
#
139
# Block devices
140
#
141
# CONFIG_BLK_DEV_FD is not set
142
# CONFIG_BLK_DEV_XD is not set
143
# CONFIG_PARIDE is not set
144
# CONFIG_BLK_CPQ_DA is not set
145
# CONFIG_BLK_CPQ_CISS_DA is not set
146
# CONFIG_CISS_SCSI_TAPE is not set
147
# CONFIG_CISS_MONITOR_THREAD is not set
148
# CONFIG_BLK_DEV_DAC960 is not set
149
# CONFIG_BLK_DEV_UMEM is not set
150
CONFIG_BLK_DEV_LOOP=y
151
CONFIG_BLK_DEV_NBD=m
152
CONFIG_BLK_DEV_RAM=y
153
CONFIG_BLK_DEV_RAM_SIZE=4096
154
CONFIG_BLK_DEV_INITRD=y
155
# CONFIG_BLK_STATS is not set
156
157
#
158
# Multi-device support (RAID and LVM)
159
#
160
# CONFIG_MD is not set
161
# CONFIG_BLK_DEV_MD is not set
162
# CONFIG_MD_LINEAR is not set
163
# CONFIG_MD_RAID0 is not set
164
# CONFIG_MD_RAID1 is not set
165
# CONFIG_MD_RAID5 is not set
166
# CONFIG_MD_MULTIPATH is not set
167
# CONFIG_BLK_DEV_LVM is not set
168
169
#
170
# Networking options
171
#
172
CONFIG_PACKET=y
173
# CONFIG_PACKET_MMAP is not set
174
# CONFIG_NETLINK_DEV is not set
175
# CONFIG_NETFILTER is not set
176
CONFIG_FILTER=y
177
CONFIG_UNIX=y
178
CONFIG_INET=y
179
CONFIG_IP_MULTICAST=y
180
# CONFIG_IP_ADVANCED_ROUTER is not set
181
# CONFIG_IP_PNP is not set
182
# CONFIG_NET_IPIP is not set
183
# CONFIG_NET_IPGRE is not set
184
# CONFIG_IP_MROUTE is not set
185
# CONFIG_ARPD is not set
186
# CONFIG_INET_ECN is not set
187
# CONFIG_SYN_COOKIES is not set
188
# CONFIG_IPV6 is not set
189
# CONFIG_KHTTPD is not set
190
191
#
192
#    SCTP Configuration (EXPERIMENTAL)
193
#
194
# CONFIG_IP_SCTP is not set
195
# CONFIG_ATM is not set
196
# CONFIG_VLAN_8021Q is not set
197
198
#
199
#  
200
#
201
# CONFIG_IPX is not set
202
# CONFIG_ATALK is not set
203
204
#
205
# Appletalk devices
206
#
207
# CONFIG_DEV_APPLETALK is not set
208
# CONFIG_DECNET is not set
209
# CONFIG_BRIDGE is not set
210
# CONFIG_X25 is not set
211
# CONFIG_LAPB is not set
212
# CONFIG_LLC is not set
213
# CONFIG_NET_DIVERT is not set
214
# CONFIG_ECONET is not set
215
# CONFIG_WAN_ROUTER is not set
216
# CONFIG_NET_FASTROUTE is not set
217
# CONFIG_NET_HW_FLOWCONTROL is not set
218
219
#
220
# QoS and/or fair queueing
221
#
222
# CONFIG_NET_SCHED is not set
223
224
#
225
# Network testing
226
#
227
# CONFIG_NET_PKTGEN is not set
228
229
#
230
# Telephony Support
231
#
232
# CONFIG_PHONE is not set
233
# CONFIG_PHONE_IXJ is not set
234
# CONFIG_PHONE_IXJ_PCMCIA is not set
235
236
#
237
# ATA/IDE/MFM/RLL support
238
#
239
CONFIG_IDE=y
240
241
#
242
# IDE, ATA and ATAPI Block devices
243
#
244
CONFIG_BLK_DEV_IDE=y
245
246
#
247
# Please see Documentation/ide.txt for help/info on IDE drives
248
#
249
# CONFIG_BLK_DEV_HD_IDE is not set
250
# CONFIG_BLK_DEV_HD is not set
251
CONFIG_BLK_DEV_IDEDISK=y
252
CONFIG_IDEDISK_MULTI_MODE=y
253
# CONFIG_IDEDISK_STROKE is not set
254
# CONFIG_BLK_DEV_IDECS is not set
255
CONFIG_BLK_DEV_IDECD=y
256
# CONFIG_BLK_DEV_IDETAPE is not set
257
# CONFIG_BLK_DEV_IDEFLOPPY is not set
258
# CONFIG_BLK_DEV_IDESCSI is not set
259
# CONFIG_IDE_TASK_IOCTL is not set
260
261
#
262
# IDE chipset support/bugfixes
263
#
264
# CONFIG_BLK_DEV_CMD640 is not set
265
# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
266
# CONFIG_BLK_DEV_ISAPNP is not set
267
CONFIG_BLK_DEV_IDEPCI=y
268
CONFIG_BLK_DEV_GENERIC=y
269
CONFIG_IDEPCI_SHARE_IRQ=y
270
CONFIG_BLK_DEV_IDEDMA_PCI=y
271
# CONFIG_BLK_DEV_OFFBOARD is not set
272
# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
273
CONFIG_IDEDMA_PCI_AUTO=y
274
# CONFIG_IDEDMA_ONLYDISK is not set
275
CONFIG_BLK_DEV_IDEDMA=y
276
# CONFIG_IDEDMA_PCI_WIP is not set
277
# CONFIG_BLK_DEV_ADMA100 is not set
278
# CONFIG_BLK_DEV_AEC62XX is not set
279
# CONFIG_BLK_DEV_ALI15X3 is not set
280
# CONFIG_WDC_ALI15X3 is not set
281
CONFIG_BLK_DEV_AMD74XX=y
282
# CONFIG_AMD74XX_OVERRIDE is not set
283
# CONFIG_BLK_DEV_ATIIXP is not set
284
# CONFIG_BLK_DEV_CMD64X is not set
285
# CONFIG_BLK_DEV_TRIFLEX is not set
286
# CONFIG_BLK_DEV_CY82C693 is not set
287
# CONFIG_BLK_DEV_CS5530 is not set
288
# CONFIG_BLK_DEV_HPT34X is not set
289
# CONFIG_HPT34X_AUTODMA is not set
290
# CONFIG_BLK_DEV_HPT366 is not set
291
# CONFIG_BLK_DEV_PIIX is not set
292
# CONFIG_BLK_DEV_NS87415 is not set
293
# CONFIG_BLK_DEV_OPTI621 is not set
294
# CONFIG_BLK_DEV_PDC202XX_OLD is not set
295
# CONFIG_PDC202XX_BURST is not set
296
# CONFIG_BLK_DEV_PDC202XX_NEW is not set
297
# CONFIG_BLK_DEV_RZ1000 is not set
298
# CONFIG_BLK_DEV_SC1200 is not set
299
# CONFIG_BLK_DEV_SVWKS is not set
300
# CONFIG_BLK_DEV_SIIMAGE is not set
301
# CONFIG_BLK_DEV_SIS5513 is not set
302
# CONFIG_BLK_DEV_SLC90E66 is not set
303
# CONFIG_BLK_DEV_TRM290 is not set
304
# CONFIG_BLK_DEV_VIA82CXXX is not set
305
# CONFIG_IDE_CHIPSETS is not set
306
CONFIG_IDEDMA_AUTO=y
307
# CONFIG_IDEDMA_IVB is not set
308
# CONFIG_DMA_NONPCI is not set
309
# CONFIG_BLK_DEV_ATARAID is not set
310
# CONFIG_BLK_DEV_ATARAID_PDC is not set
311
# CONFIG_BLK_DEV_ATARAID_HPT is not set
312
# CONFIG_BLK_DEV_ATARAID_MEDLEY is not set
313
# CONFIG_BLK_DEV_ATARAID_SII is not set
314
315
#
316
# SCSI support
317
#
318
# CONFIG_SCSI is not set
319
320
#
321
# Fusion MPT device support
322
#
323
# CONFIG_FUSION is not set
324
# CONFIG_FUSION_BOOT is not set
325
# CONFIG_FUSION_ISENSE is not set
326
# CONFIG_FUSION_CTL is not set
327
# CONFIG_FUSION_LAN is not set
328
329
#
330
# IEEE 1394 (FireWire) support (EXPERIMENTAL)
331
#
332
# CONFIG_IEEE1394 is not set
333
334
#
335
# I2O device support
336
#
337
# CONFIG_I2O is not set
338
# CONFIG_I2O_PCI is not set
339
# CONFIG_I2O_BLOCK is not set
340
# CONFIG_I2O_LAN is not set
341
# CONFIG_I2O_SCSI is not set
342
# CONFIG_I2O_PROC is not set
343
344
#
345
# Network device support
346
#
347
CONFIG_NETDEVICES=y
348
349
#
350
# ARCnet devices
351
#
352
# CONFIG_ARCNET is not set
353
CONFIG_DUMMY=m
354
# CONFIG_BONDING is not set
355
# CONFIG_EQUALIZER is not set
356
# CONFIG_TUN is not set
357
# CONFIG_ETHERTAP is not set
358
359
#
360
# Ethernet (10 or 100Mbit)
361
#
362
CONFIG_NET_ETHERNET=y
363
# CONFIG_SUNLANCE is not set
364
# CONFIG_HAPPYMEAL is not set
365
# CONFIG_SUNBMAC is not set
366
# CONFIG_SUNQE is not set
367
# CONFIG_SUNGEM is not set
368
# CONFIG_NET_VENDOR_3COM is not set
369
# CONFIG_LANCE is not set
370
# CONFIG_NET_VENDOR_SMC is not set
371
# CONFIG_NET_VENDOR_RACAL is not set
372
# CONFIG_HP100 is not set
373
# CONFIG_NET_ISA is not set
374
CONFIG_NET_PCI=y
375
# CONFIG_PCNET32 is not set
376
# CONFIG_AMD8111_ETH is not set
377
# CONFIG_ADAPTEC_STARFIRE is not set
378
# CONFIG_APRICOT is not set
379
# CONFIG_B44 is not set
380
# CONFIG_CS89x0 is not set
381
# CONFIG_TULIP is not set
382
# CONFIG_DE4X5 is not set
383
# CONFIG_DGRS is not set
384
# CONFIG_DM9102 is not set
385
# CONFIG_EEPRO100 is not set
386
# CONFIG_EEPRO100_PIO is not set
387
# CONFIG_E100 is not set
388
# CONFIG_LNE390 is not set
389
# CONFIG_FEALNX is not set
390
# CONFIG_NATSEMI is not set
391
# CONFIG_NE2K_PCI is not set
392
CONFIG_FORCEDETH=m
393
# CONFIG_NE3210 is not set
394
# CONFIG_ES3210 is not set
395
# CONFIG_8139CP is not set
396
# CONFIG_8139TOO is not set
397
# CONFIG_8139TOO_PIO is not set
398
# CONFIG_8139TOO_TUNE_TWISTER is not set
399
# CONFIG_8139TOO_8129 is not set
400
# CONFIG_8139_OLD_RX_RESET is not set
401
# CONFIG_SIS900 is not set
402
# CONFIG_EPIC100 is not set
403
# CONFIG_SUNDANCE is not set
404
# CONFIG_SUNDANCE_MMIO is not set
405
# CONFIG_TLAN is not set
406
# CONFIG_VIA_RHINE is not set
407
# CONFIG_VIA_RHINE_MMIO is not set
408
# CONFIG_WINBOND_840 is not set
409
# CONFIG_NET_POCKET is not set
410
411
#
412
# Ethernet (1000 Mbit)
413
#
414
# CONFIG_ACENIC is not set
415
# CONFIG_DL2K is not set
416
# CONFIG_E1000 is not set
417
# CONFIG_MYRI_SBUS is not set
418
# CONFIG_NS83820 is not set
419
# CONFIG_HAMACHI is not set
420
# CONFIG_YELLOWFIN is not set
421
# CONFIG_R8169 is not set
422
# CONFIG_SK98LIN is not set
423
# CONFIG_TIGON3 is not set
424
# CONFIG_FDDI is not set
425
# CONFIG_HIPPI is not set
426
# CONFIG_PLIP is not set
427
# CONFIG_PPP is not set
428
# CONFIG_SLIP is not set
429
430
#
431
# Wireless LAN (non-hamradio)
432
#
433
# CONFIG_NET_RADIO is not set
434
435
#
436
# Token Ring devices
437
#
438
# CONFIG_TR is not set
439
# CONFIG_NET_FC is not set
440
# CONFIG_RCPCI is not set
441
# CONFIG_SHAPER is not set
442
443
#
444
# Wan interfaces
445
#
446
# CONFIG_WAN is not set
447
448
#
449
# Amateur Radio support
450
#
451
# CONFIG_HAMRADIO is not set
452
453
#
454
# IrDA (infrared) support
455
#
456
CONFIG_IRDA=m
457
458
#
459
# IrDA protocols
460
#
461
CONFIG_IRLAN=m
462
# CONFIG_IRNET is not set
463
CONFIG_IRCOMM=m
464
CONFIG_IRDA_ULTRA=y
465
466
#
467
# IrDA options
468
#
469
CONFIG_IRDA_CACHE_LAST_LSAP=y
470
CONFIG_IRDA_FAST_RR=y
471
# CONFIG_IRDA_DEBUG is not set
472
473
#
474
# Infrared-port device drivers
475
#
476
477
#
478
# SIR device drivers
479
#
480
# CONFIG_IRTTY_SIR is not set
481
# CONFIG_IRPORT_SIR is not set
482
483
#
484
# Dongle support
485
#
486
# CONFIG_DONGLE is not set
487
488
#
489
# FIR device drivers
490
#
491
# CONFIG_USB_IRDA is not set
492
# CONFIG_NSC_FIR is not set
493
# CONFIG_WINBOND_FIR is not set
494
# CONFIG_TOSHIBA_OLD is not set
495
# CONFIG_TOSHIBA_FIR is not set
496
# CONFIG_SMC_IRCC_FIR is not set
497
# CONFIG_ALI_FIR is not set
498
# CONFIG_VLSI_FIR is not set
499
# CONFIG_VIA_IRCC_FIR is not set
500
501
#
502
# ISDN subsystem
503
#
504
# CONFIG_ISDN is not set
505
506
#
507
# Input core support
508
#
509
CONFIG_INPUT=m
510
CONFIG_INPUT_KEYBDEV=m
511
CONFIG_INPUT_MOUSEDEV=m
512
CONFIG_INPUT_MOUSEDEV_SCREEN_X=640
513
CONFIG_INPUT_MOUSEDEV_SCREEN_Y=576
514
CONFIG_INPUT_JOYDEV=m
515
CONFIG_INPUT_EVDEV=m
516
# CONFIG_INPUT_UINPUT is not set
517
518
#
519
# Character devices
520
#
521
CONFIG_VT=y
522
CONFIG_VT_CONSOLE=y
523
# CONFIG_SERIAL is not set
524
# CONFIG_SERIAL_EXTENDED is not set
525
# CONFIG_SERIAL_NONSTANDARD is not set
526
CONFIG_UNIX98_PTYS=y
527
CONFIG_UNIX98_PTY_COUNT=256
528
529
#
530
# I2C support
531
#
532
CONFIG_I2C=y
533
# CONFIG_I2C_ALGOBIT is not set
534
# CONFIG_SCx200_ACB is not set
535
# CONFIG_I2C_ALGOPCF is not set
536
CONFIG_I2C_CHARDEV=y
537
CONFIG_I2C_PROC=y
538
CONFIG_I2C_XBOX=y
539
CONFIG_I2C_EXTSMI=y
540
541
#
542
# Mice
543
#
544
# CONFIG_BUSMOUSE is not set
545
# CONFIG_MOUSE is not set
546
547
#
548
# Joysticks
549
#
550
# CONFIG_INPUT_GAMEPORT is not set
551
# CONFIG_INPUT_NS558 is not set
552
# CONFIG_INPUT_LIGHTNING is not set
553
# CONFIG_INPUT_PCIGAME is not set
554
# CONFIG_INPUT_CS461X is not set
555
# CONFIG_INPUT_EMU10K1 is not set
556
# CONFIG_INPUT_SERIO is not set
557
# CONFIG_INPUT_SERPORT is not set
558
559
#
560
# Joysticks
561
#
562
# CONFIG_INPUT_ANALOG is not set
563
# CONFIG_INPUT_A3D is not set
564
# CONFIG_INPUT_ADI is not set
565
# CONFIG_INPUT_COBRA is not set
566
# CONFIG_INPUT_GF2K is not set
567
# CONFIG_INPUT_GRIP is not set
568
# CONFIG_INPUT_INTERACT is not set
569
# CONFIG_INPUT_TMDC is not set
570
# CONFIG_INPUT_SIDEWINDER is not set
571
# CONFIG_INPUT_IFORCE_USB is not set
572
# CONFIG_INPUT_IFORCE_232 is not set
573
# CONFIG_INPUT_WARRIOR is not set
574
# CONFIG_INPUT_MAGELLAN is not set
575
# CONFIG_INPUT_SPACEORB is not set
576
# CONFIG_INPUT_SPACEBALL is not set
577
# CONFIG_INPUT_STINGER is not set
578
# CONFIG_INPUT_DB9 is not set
579
# CONFIG_INPUT_GAMECON is not set
580
# CONFIG_INPUT_TURBOGRAFX is not set
581
# CONFIG_QIC02_TAPE is not set
582
# CONFIG_IPMI_HANDLER is not set
583
# CONFIG_IPMI_PANIC_EVENT is not set
584
# CONFIG_IPMI_DEVICE_INTERFACE is not set
585
# CONFIG_IPMI_KCS is not set
586
# CONFIG_IPMI_WATCHDOG is not set
587
588
#
589
# Watchdog Cards
590
#
591
# CONFIG_WATCHDOG is not set
592
# CONFIG_SCx200 is not set
593
# CONFIG_SCx200_GPIO is not set
594
# CONFIG_AMD_RNG is not set
595
# CONFIG_INTEL_RNG is not set
596
# CONFIG_HW_RANDOM is not set
597
# CONFIG_AMD_PM768 is not set
598
CONFIG_NVRAM=m
599
CONFIG_RTC=y
600
# CONFIG_DTLK is not set
601
# CONFIG_R3964 is not set
602
# CONFIG_APPLICOM is not set
603
# CONFIG_SONYPI is not set
604
605
#
606
# Ftape, the floppy tape device driver
607
#
608
# CONFIG_FTAPE is not set
609
CONFIG_AGP=m
610
# CONFIG_AGP_INTEL is not set
611
# CONFIG_AGP_I810 is not set
612
# CONFIG_AGP_VIA is not set
613
CONFIG_AGP_AMD=y
614
# CONFIG_AGP_AMD_K8 is not set
615
# CONFIG_AGP_SIS is not set
616
# CONFIG_AGP_ALI is not set
617
# CONFIG_AGP_SWORKS is not set
618
CONFIG_AGP_NVIDIA=y
619
# CONFIG_AGP_ATI is not set
620
621
#
622
# Direct Rendering Manager (XFree86 DRI support)
623
#
624
CONFIG_DRM=y
625
# CONFIG_DRM_OLD is not set
626
627
#
628
# DRM 4.1 drivers
629
#
630
CONFIG_DRM_NEW=y
631
# CONFIG_DRM_TDFX is not set
632
# CONFIG_DRM_GAMMA is not set
633
# CONFIG_DRM_R128 is not set
634
# CONFIG_DRM_RADEON is not set
635
# CONFIG_DRM_I810 is not set
636
# CONFIG_DRM_I810_XFREE_41 is not set
637
# CONFIG_DRM_I830 is not set
638
# CONFIG_DRM_MGA is not set
639
# CONFIG_DRM_SIS is not set
640
# CONFIG_MWAVE is not set
641
# CONFIG_OBMOUSE is not set
642
643
#
644
# Multimedia devices
645
#
646
# CONFIG_VIDEO_DEV is not set
647
648
#
649
# File systems
650
#
651
# CONFIG_QUOTA is not set
652
# CONFIG_QFMT_V2 is not set
653
# CONFIG_AUTOFS_FS is not set
654
# CONFIG_AUTOFS4_FS is not set
655
CONFIG_REISERFS_FS=y
656
# CONFIG_REISERFS_CHECK is not set
657
# CONFIG_REISERFS_PROC_INFO is not set
658
# CONFIG_ADFS_FS is not set
659
# CONFIG_ADFS_FS_RW is not set
660
# CONFIG_AFFS_FS is not set
661
# CONFIG_HFS_FS is not set
662
# CONFIG_HFSPLUS_FS is not set
663
# CONFIG_BEFS_FS is not set
664
# CONFIG_BEFS_DEBUG is not set
665
# CONFIG_BFS_FS is not set
666
CONFIG_EXT3_FS=y
667
CONFIG_JBD=y
668
# CONFIG_JBD_DEBUG is not set
669
CONFIG_FAT_FS=m
670
CONFIG_MSDOS_FS=m
671
# CONFIG_UMSDOS_FS is not set
672
CONFIG_VFAT_FS=m
673
CONFIG_FATX_FS=y
674
# CONFIG_EFS_FS is not set
675
# CONFIG_JFFS_FS is not set
676
# CONFIG_JFFS2_FS is not set
677
CONFIG_CRAMFS=y
678
CONFIG_TMPFS=y
679
CONFIG_RAMFS=y
680
CONFIG_ISO9660_FS=y
681
CONFIG_JOLIET=y
682
CONFIG_ZISOFS=y
683
# CONFIG_JFS_FS is not set
684
# CONFIG_JFS_DEBUG is not set
685
# CONFIG_JFS_STATISTICS is not set
686
# CONFIG_MINIX_FS is not set
687
# CONFIG_VXFS_FS is not set
688
# CONFIG_NTFS_FS is not set
689
# CONFIG_NTFS_RW is not set
690
# CONFIG_HPFS_FS is not set
691
CONFIG_PROC_FS=y
692
CONFIG_DEVFS_FS=y
693
CONFIG_DEVFS_MOUNT=y
694
# CONFIG_DEVFS_DEBUG is not set
695
CONFIG_DEVPTS_FS=y
696
# CONFIG_QNX4FS_FS is not set
697
# CONFIG_QNX4FS_RW is not set
698
# CONFIG_ROMFS_FS is not set
699
CONFIG_EXT2_FS=y
700
# CONFIG_SYSV_FS is not set
701
CONFIG_UDF_FS=m
702
# CONFIG_UDF_RW is not set
703
# CONFIG_UFS_FS is not set
704
# CONFIG_UFS_FS_WRITE is not set
705
# CONFIG_XFS_FS is not set
706
# CONFIG_XFS_QUOTA is not set
707
# CONFIG_XFS_RT is not set
708
# CONFIG_XFS_TRACE is not set
709
# CONFIG_XFS_DEBUG is not set
710
711
#
712
# Network File Systems
713
#
714
# CONFIG_CODA_FS is not set
715
# CONFIG_INTERMEZZO_FS is not set
716
# CONFIG_NFS_FS is not set
717
# CONFIG_NFS_V3 is not set
718
# CONFIG_NFS_DIRECTIO is not set
719
# CONFIG_ROOT_NFS is not set
720
# CONFIG_NFSD is not set
721
# CONFIG_NFSD_V3 is not set
722
# CONFIG_NFSD_TCP is not set
723
# CONFIG_SUNRPC is not set
724
# CONFIG_LOCKD is not set
725
# CONFIG_SMB_FS is not set
726
# CONFIG_NCP_FS is not set
727
# CONFIG_NCPFS_PACKET_SIGNING is not set
728
# CONFIG_NCPFS_IOCTL_LOCKING is not set
729
# CONFIG_NCPFS_STRONG is not set
730
# CONFIG_NCPFS_NFS_NS is not set
731
# CONFIG_NCPFS_OS2_NS is not set
732
# CONFIG_NCPFS_SMALLDOS is not set
733
# CONFIG_NCPFS_NLS is not set
734
# CONFIG_NCPFS_EXTRAS is not set
735
CONFIG_ZISOFS_FS=y
736
737
#
738
# Partition Types
739
#
740
CONFIG_PARTITION_ADVANCED=y
741
# CONFIG_ACORN_PARTITION is not set
742
# CONFIG_OSF_PARTITION is not set
743
# CONFIG_AMIGA_PARTITION is not set
744
# CONFIG_ATARI_PARTITION is not set
745
# CONFIG_MAC_PARTITION is not set
746
CONFIG_XBOX_PARTITION=y
747
CONFIG_MSDOS_PARTITION=y
748
# CONFIG_BSD_DISKLABEL is not set
749
# CONFIG_MINIX_SUBPARTITION is not set
750
# CONFIG_SOLARIS_X86_PARTITION is not set
751
# CONFIG_UNIXWARE_DISKLABEL is not set
752
# CONFIG_LDM_PARTITION is not set
753
# CONFIG_SGI_PARTITION is not set
754
# CONFIG_ULTRIX_PARTITION is not set
755
# CONFIG_SUN_PARTITION is not set
756
# CONFIG_EFI_PARTITION is not set
757
# CONFIG_SMB_NLS is not set
758
CONFIG_NLS=y
759
760
#
761
# Native Language Support
762
#
763
CONFIG_NLS_DEFAULT="iso8859-15"
764
CONFIG_NLS_CODEPAGE_437=m
765
# CONFIG_NLS_CODEPAGE_737 is not set
766
# CONFIG_NLS_CODEPAGE_775 is not set
767
# CONFIG_NLS_CODEPAGE_850 is not set
768
# CONFIG_NLS_CODEPAGE_852 is not set
769
# CONFIG_NLS_CODEPAGE_855 is not set
770
# CONFIG_NLS_CODEPAGE_857 is not set
771
# CONFIG_NLS_CODEPAGE_860 is not set
772
# CONFIG_NLS_CODEPAGE_861 is not set
773
# CONFIG_NLS_CODEPAGE_862 is not set
774
# CONFIG_NLS_CODEPAGE_863 is not set
775
# CONFIG_NLS_CODEPAGE_864 is not set
776
# CONFIG_NLS_CODEPAGE_865 is not set
777
# CONFIG_NLS_CODEPAGE_866 is not set
778
# CONFIG_NLS_CODEPAGE_869 is not set
779
# CONFIG_NLS_CODEPAGE_936 is not set
780
# CONFIG_NLS_CODEPAGE_950 is not set
781
# CONFIG_NLS_CODEPAGE_932 is not set
782
# CONFIG_NLS_CODEPAGE_949 is not set
783
# CONFIG_NLS_CODEPAGE_874 is not set
784
# CONFIG_NLS_ISO8859_8 is not set
785
# CONFIG_NLS_CODEPAGE_1250 is not set
786
# CONFIG_NLS_CODEPAGE_1251 is not set
787
CONFIG_NLS_ISO8859_1=m
788
# CONFIG_NLS_ISO8859_2 is not set
789
# CONFIG_NLS_ISO8859_3 is not set
790
# CONFIG_NLS_ISO8859_4 is not set
791
# CONFIG_NLS_ISO8859_5 is not set
792
# CONFIG_NLS_ISO8859_6 is not set
793
# CONFIG_NLS_ISO8859_7 is not set
794
# CONFIG_NLS_ISO8859_9 is not set
795
# CONFIG_NLS_ISO8859_13 is not set
796
# CONFIG_NLS_ISO8859_14 is not set
797
# CONFIG_NLS_ISO8859_15 is not set
798
# CONFIG_NLS_KOI8_R is not set
799
# CONFIG_NLS_KOI8_U is not set
800
# CONFIG_NLS_UTF8 is not set
801
802
#
803
# Console drivers
804
#
805
# CONFIG_VGA_CONSOLE is not set
806
CONFIG_VIDEO_SELECT=y
807
# CONFIG_MDA_CONSOLE is not set
808
809
#
810
# Frame-buffer support
811
#
812
CONFIG_FB=y
813
CONFIG_DUMMY_CONSOLE=y
814
# CONFIG_FB_RIVA is not set
815
CONFIG_FB_XBOX=y
816
# CONFIG_FB_CLGEN is not set
817
# CONFIG_FB_PM2 is not set
818
# CONFIG_FB_PM3 is not set
819
# CONFIG_FB_CYBER2000 is not set
820
CONFIG_FB_VESA=y
821
# CONFIG_FB_VGA16 is not set
822
# CONFIG_FB_HGA is not set
823
CONFIG_VIDEO_SELECT=y
824
# CONFIG_FB_MATROX is not set
825
# CONFIG_FB_ATY is not set
826
# CONFIG_FB_RADEON is not set
827
# CONFIG_FB_ATY128 is not set
828
# CONFIG_FB_INTEL is not set
829
# CONFIG_FB_SIS is not set
830
# CONFIG_FB_NEOMAGIC is not set
831
# CONFIG_FB_3DFX is not set
832
# CONFIG_FB_VOODOO1 is not set
833
# CONFIG_FB_TRIDENT is not set
834
# CONFIG_FB_IT8181 is not set
835
# CONFIG_FB_VIRTUAL is not set
836
CONFIG_FBCON_ADVANCED=y
837
# CONFIG_FBCON_MFB is not set
838
# CONFIG_FBCON_CFB2 is not set
839
# CONFIG_FBCON_CFB4 is not set
840
CONFIG_FBCON_CFB8=y
841
CONFIG_FBCON_CFB16=y
842
CONFIG_FBCON_CFB24=y
843
CONFIG_FBCON_CFB32=y
844
# CONFIG_FBCON_AFB is not set
845
# CONFIG_FBCON_ILBM is not set
846
# CONFIG_FBCON_IPLAN2P2 is not set
847
# CONFIG_FBCON_IPLAN2P4 is not set
848
# CONFIG_FBCON_IPLAN2P8 is not set
849
# CONFIG_FBCON_MAC is not set
850
# CONFIG_FBCON_VGA_PLANES is not set
851
# CONFIG_FBCON_VGA is not set
852
# CONFIG_FBCON_HGA is not set
853
# CONFIG_FBCON_FONTWIDTH8_ONLY is not set
854
CONFIG_FBCON_FONTS=y
855
CONFIG_FONT_8x8=y
856
CONFIG_FONT_8x16=y
857
# CONFIG_FONT_SUN8x16 is not set
858
# CONFIG_FONT_SUN12x22 is not set
859
# CONFIG_FONT_6x11 is not set
860
# CONFIG_FONT_PEARL_8x8 is not set
861
# CONFIG_FONT_ACORN_8x8 is not set
862
863
#
864
# Sound
865
#
866
CONFIG_SOUND=m
867
# CONFIG_SOUND_ALI5455 is not set
868
# CONFIG_SOUND_BT878 is not set
869
# CONFIG_SOUND_CMPCI is not set
870
# CONFIG_SOUND_EMU10K1 is not set
871
# CONFIG_MIDI_EMU10K1 is not set
872
# CONFIG_SOUND_FUSION is not set
873
# CONFIG_SOUND_CS4281 is not set
874
# CONFIG_SOUND_ES1370 is not set
875
CONFIG_SOUND_ES1371=m
876
# CONFIG_SOUND_ESSSOLO1 is not set
877
# CONFIG_SOUND_MAESTRO is not set
878
# CONFIG_SOUND_MAESTRO3 is not set
879
# CONFIG_SOUND_FORTE is not set
880
CONFIG_SOUND_ICH=m
881
# CONFIG_SOUND_RME96XX is not set
882
# CONFIG_SOUND_SONICVIBES is not set
883
# CONFIG_SOUND_TRIDENT is not set
884
# CONFIG_SOUND_MSNDCLAS is not set
885
# CONFIG_SOUND_MSNDPIN is not set
886
# CONFIG_SOUND_VIA82CXXX is not set
887
# CONFIG_MIDI_VIA82CXXX is not set
888
# CONFIG_SOUND_OSS is not set
889
# CONFIG_SOUND_TVMIXER is not set
890
# CONFIG_SOUND_AD1980 is not set
891
# CONFIG_SOUND_WM97XX is not set
892
893
#
894
# USB support
895
#
896
CONFIG_USB=m
897
# CONFIG_USB_DEBUG is not set
898
899
#
900
# Miscellaneous USB options
901
#
902
CONFIG_USB_DEVICEFS=y
903
CONFIG_USB_BANDWIDTH=y
904
905
#
906
# USB Host Controller Drivers
907
#
908
CONFIG_USB_EHCI_HCD=m
909
CONFIG_USB_UHCI=m
910
CONFIG_USB_UHCI_ALT=m
911
CONFIG_USB_OHCI=m
912
# CONFIG_USB_SL811HS_ALT is not set
913
# CONFIG_USB_SL811HS is not set
914
915
#
916
# USB Device Class drivers
917
#
918
# CONFIG_USB_AUDIO is not set
919
# CONFIG_USB_EMI26 is not set
920
# CONFIG_USB_BLUETOOTH is not set
921
# CONFIG_USB_MIDI is not set
922
923
#
924
#   SCSI support is needed for USB Storage
925
#
926
# CONFIG_USB_STORAGE is not set
927
# CONFIG_USB_STORAGE_DEBUG is not set
928
# CONFIG_USB_STORAGE_DATAFAB is not set
929
# CONFIG_USB_STORAGE_FREECOM is not set
930
# CONFIG_USB_STORAGE_ISD200 is not set
931
# CONFIG_USB_STORAGE_DPCM is not set
932
# CONFIG_USB_STORAGE_HP8200e is not set
933
# CONFIG_USB_STORAGE_SDDR09 is not set
934
# CONFIG_USB_STORAGE_SDDR55 is not set
935
# CONFIG_USB_STORAGE_JUMPSHOT is not set
936
# CONFIG_USB_ACM is not set
937
# CONFIG_USB_PRINTER is not set
938
939
#
940
# USB Human Interface Devices (HID)
941
#
942
CONFIG_USB_HID=m
943
CONFIG_USB_HIDINPUT=y
944
CONFIG_USB_HIDDEV=y
945
# CONFIG_USB_KBD is not set
946
# CONFIG_USB_MOUSE is not set
947
# CONFIG_USB_AIPTEK is not set
948
# CONFIG_USB_WACOM is not set
949
CONFIG_USB_XPAD=m
950
CONFIG_USB_XPAD_MOUSE=y
951
CONFIG_USB_XIR=m
952
# CONFIG_USB_KBTAB is not set
953
# CONFIG_USB_POWERMATE is not set
954
955
#
956
# USB Imaging devices
957
#
958
# CONFIG_USB_DC2XX is not set
959
# CONFIG_USB_MDC800 is not set
960
# CONFIG_USB_SCANNER is not set
961
# CONFIG_USB_MICROTEK is not set
962
# CONFIG_USB_HPUSBSCSI is not set
963
964
#
965
# USB Multimedia devices
966
#
967
968
#
969
#   Video4Linux support is needed for USB Multimedia device support
970
#
971
972
#
973
# USB Network adaptors
974
#
975
# CONFIG_USB_PEGASUS is not set
976
# CONFIG_USB_RTL8150 is not set
977
# CONFIG_USB_KAWETH is not set
978
# CONFIG_USB_CATC is not set
979
# CONFIG_USB_CDCETHER is not set
980
# CONFIG_USB_USBNET is not set
981
982
#
983
# USB port drivers
984
#
985
# CONFIG_USB_USS720 is not set
986
987
#
988
# USB Serial Converter support
989
#
990
# CONFIG_USB_SERIAL is not set
991
992
#
993
# USB Miscellaneous drivers
994
#
995
# CONFIG_USB_RIO500 is not set
996
# CONFIG_USB_AUERSWALD is not set
997
# CONFIG_USB_TIGL is not set
998
# CONFIG_USB_BRLVGER is not set
999
# CONFIG_USB_LCD is not set
1000
1001
#
1002
# Support for USB gadgets
1003
#
1004
# CONFIG_USB_GADGET is not set
1005
1006
#
1007
# Bluetooth support
1008
#
1009
# CONFIG_BLUEZ is not set
1010
1011
#
1012
# Kernel hacking
1013
#
1014
# CONFIG_DEBUG_KERNEL is not set
1015
CONFIG_LOG_BUF_SHIFT=0
1016
1017
#
1018
# Cryptographic options
1019
#
1020
# CONFIG_CRYPTO is not set
1021
1022
#
1023
# Library routines
1024
#
1025
# CONFIG_CRC32 is not set
1026
CONFIG_ZLIB_INFLATE=y
1027
# CONFIG_ZLIB_DEFLATE is not set
1028
# CONFIG_FW_LOADER is not set
(-)linux-2.4.26/scripts/CVS/Entries (+2 lines)
Line 0 Link Here
1
D/mkpatch////
2
D/tologo////
(-)linux-2.4.26/scripts/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/scripts
(-)linux-2.4.26/scripts/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/scripts/mkpatch/CVS/Entries (+10 lines)
Line 0 Link Here
1
/README/1.1/Mon Aug 11 00:32:52 2003//
2
/disabled-filelist.txt/1.3/Thu Nov 13 16:01:34 2003//
3
/filelist.fatx_file_system/1.1/Mon Aug 11 00:32:52 2003//
4
/filelist.xbox_docs/1.1/Mon Aug 11 00:32:52 2003//
5
/filelist.xbox_oss/1.1/Mon Aug 11 00:32:52 2003//
6
/filelist.xbox_support/1.1/Mon Aug 11 00:32:52 2003//
7
/filelist.xbox_usb_devices/1.1/Mon Aug 11 00:32:52 2003//
8
/filelist.xboxfb/1.1/Sat Aug 16 16:26:58 2003//
9
/mkpatch/1.2/Mon Aug 11 00:56:13 2003//
10
D
(-)linux-2.4.26/scripts/mkpatch/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/scripts/mkpatch
(-)linux-2.4.26/scripts/mkpatch/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/scripts/mkpatch/README (+36 lines)
Line 0 Link Here
1
Xbox Linux mkpatch
2
~~~~~~~~~~~~~~~~~~
3
Michael Steil <mist@c64.org>, 2003/08/11
4
5
The Xbox Linux kernel CVS contains many different patches to the Linux
6
kernel, such as basic Xbox support, the FATX file system or additional
7
USB device drivers.
8
9
The mkpatch script downloads the plain vanilla Linux kernel as well as
10
the SF CVS kernel and creates a set of patches:
11
12
* kernel-2.4.?-?_fatx_file_system.patch
13
  The FATX file system driver and Xbox partitioning support
14
15
* kernel-2.4.?-?_nvnet_network_driver.patch
16
  The nvnet network driver
17
18
* kernel-2.4.?-?_xbox_docs.patch
19
  Documentation additions
20
21
* kernel-2.4.?-?_xbox_oss.patch
22
  A patch for the i810 OSS driver to enable sound on the Xbox
23
24
* kernel-2.4.?-?_xbox_support.patch
25
  This patch is needed to add Xbox compatibility to the kernel
26
27
* kernel-2.4.?-?_xbox_usb_devices.patch
28
  Xbox controller and Xbox IR dongle drivers
29
30
All you have to do is add your name after the
31
sfuser=...
32
line and run the script. It will then create the above files for you.
33
If you don't have an SF account, change the cvs co line to anonymous
34
checkout as suggested on the SF site.
35
36
  Michael
(-)linux-2.4.26/scripts/mkpatch/disabled-filelist.txt (+43 lines)
Line 0 Link Here
1
#NO: developer only / experimental
2
drivers/video
3
drivers/video/riva
4
drivers/video/riva/conexant-i2c.c
5
drivers/video/riva/conexant-i2c.h
6
drivers/video/riva/Makefile
7
drivers/video/riva/fbdev.c
8
drivers/video/riva/riva_hw.c
9
drivers/video/riva/riva_hw.h
10
drivers/video/riva/conexant.c
11
drivers/video/riva/conexant.h
12
drivers/video/riva/conexant-types.h
13
drivers/video/riva/rivafb.h
14
drivers/video/riva/riva_tbl.h
15
init
16
Makefile
17
scripts
18
scripts/tologo
19
drivers
20
drivers/i2c
21
drivers/i2c/Makefile
22
drivers/i2c/extsmi.c
23
drivers/i2c/i2c-xbox.c
24
drivers/i2c/adm1021.c
25
drivers/i2c/Config.in
26
include/linux/i2c.h
27
include/linux/i2c-proc.h
28
include/linux/sensors.h
29
kernel.config
30
Documentation/README.xbox
31
drivers/usb/hub.c
32
drivers/usb/storage
33
drivers/usb/storage/usb.c
34
drivers/usb/storage/usb.h
35
drivers/usb/storage/README
36
drivers/usb/storage/protocol.c
37
drivers/usb/storage/protocol.h
38
drivers/usb/readme.txt
39
drivers/pci
40
drivers/pci/pci.ids
41
drivers/usb/ult.c
42
fs/fatx/README
43
(-)linux-2.4.26/scripts/mkpatch/filelist.fatx_file_system (+21 lines)
Line 0 Link Here
1
fs/nls/Config.in
2
fs/fatx
3
fs/fatx/Makefile
4
fs/fatx/dir.c
5
fs/fatx/namei.c
6
fs/fatx/file.c
7
fs/fatx/misc.c
8
fs/fatx/cache.c
9
fs/fatx/fatxfs_syms.c
10
fs/fatx/inode.c
11
fs/Makefile
12
fs/partitions/Makefile
13
fs/partitions/xbox.c
14
fs/partitions/xbox.h
15
fs/partitions/Config.in
16
fs/partitions/check.c
17
fs/Config.in
18
include/linux/fs.h
19
include/linux/fatx_fs_i.h
20
include/linux/fatx_fs.h
21
include/linux/fatx_fs_sb.h
(-)linux-2.4.26/scripts/mkpatch/filelist.xbox_docs (+2 lines)
Line 0 Link Here
1
Documentation/input/xpad.txt
2
Documentation/Configure.help
(-)linux-2.4.26/scripts/mkpatch/filelist.xbox_oss (+2 lines)
Line 0 Link Here
1
drivers/sound/ac97_codec.c
2
drivers/sound/i810_audio.c
(-)linux-2.4.26/scripts/mkpatch/filelist.xbox_support (+12 lines)
Line 0 Link Here
1
arch/i386/boot/compressed/Makefile
2
arch/i386/config.in
3
arch/i386/kernel/Makefile
4
arch/i386/kernel/setup.c
5
arch/i386/kernel/pci-pc.c
6
arch/i386/kernel/xboxejectfix.c
7
arch/i386/kernel/process.c
8
drivers/char/pc_keyb.c
9
include/asm-i386/timex.h
10
include/linux/xbox.h
11
drivers/ide/ide-cd.c
12
drivers/ide/ide-cd.h
(-)linux-2.4.26/scripts/mkpatch/filelist.xbox_usb_devices (+7 lines)
Line 0 Link Here
1
drivers/usb/Makefile
2
drivers/usb/usb-xboxir.c
3
drivers/usb/usb-xboxir.h
4
drivers/usb/xpad.c
5
drivers/usb/xpad.h
6
drivers/usb/Config.in
7
include/linux/input.h
(-)linux-2.4.26/scripts/mkpatch/filelist.xboxfb (+18 lines)
Line 0 Link Here
1
drivers/video/xbox
2
drivers/video/xbox/conexant-i2c.c
3
drivers/video/xbox/conexant-i2c.h
4
drivers/video/xbox/Makefile
5
drivers/video/xbox/xboxfb.h
6
drivers/video/xbox/fbdev.c
7
drivers/video/xbox/nv4ref.h
8
drivers/video/xbox/riva_hw.c
9
drivers/video/xbox/riva_hw.h
10
drivers/video/xbox/conexant.c
11
drivers/video/xbox/conexant.h
12
drivers/video/xbox/accel.c
13
drivers/video/xbox/conexant-types.h
14
drivers/video/xbox/nvreg.h
15
drivers/video/xbox/riva_tbl.h
16
drivers/video/Makefile
17
drivers/video/fbmem.c
18
drivers/video/Config.in
(-)linux-2.4.26/scripts/mkpatch/mkpatch (+33 lines)
Line 0 Link Here
1
#!/bin/bash
2
kernelversion=2.4.21
3
patchversion=0.9.0
4
sfuser=mist
5
6
kv=`echo $kernelversion|sed 's/\./_/g'`
7
pv=`echo $patchversion|sed 's/\./_/g'`
8
kernel=linux-$kernelversion
9
kernelorig=$kernel.orig
10
11
wget -c http://www.kernel.org/pub/linux/kernel/v2.4/$kernel.tar.bz2
12
tar xjf $kernel.tar.bz2
13
mv $kernel $kernelorig
14
cvs -z3 -d:ext:$sfuser@cvs.sf.net:/cvsroot/xbox-linux co kernel
15
16
for l in filelist*; do
17
	patchname=`echo $l|sed 's/filelist\.//'`
18
	echo Creating patch $patchname...
19
	rm -rf $kernel
20
	cp -al $kernelorig $kernel
21
	for i in `cat $l`; do
22
		#echo copying file: $i;
23
		if [ -d kernel/$i ]; then
24
			mkdir $kernel/$i;
25
		else
26
			rm -f $kernel/$i;
27
			cp -p kernel/$i $kernel/$i;
28
		fi
29
	done
30
	diff -ruN $kernelorig $kernel > kernel-$kv-$pv_$patchname.patch;
31
done
32
rm -rf $kernel
33
#rm -rf $kernel.orig
(-)linux-2.4.26/scripts/tologo/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)linux-2.4.26/scripts/tologo/CVS/Repository (+1 lines)
Line 0 Link Here
1
kernel/scripts/tologo
(-)linux-2.4.26/scripts/tologo/CVS/Root (+1 lines)
Line 0 Link Here
1
:ext:huceke@cvs.sf.net:/cvsroot/xbox-linux
(-)linux-2.4.26/stamp-building (+1 lines)
Line 0 Link Here
1
Building Package
(-)linux-2.4.26/stamp-configure (+1 lines)
Line 0 Link Here
1
done
(-)linux-2.4.26/stamp-debian (+1 lines)
Line 0 Link Here
1
done
(-)linux-2.4.26/stamp-image (+1 lines)
Line 0 Link Here
1
done
(-)linux-2.4.26/stamp-kernel-configure (+1 lines)
Line 0 Link Here
1
done

Return to bug 45100