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/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_AMD756 (I2C support for nForce chipsets).
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/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/i386/boot/compressed/Makefile (+5 lines)
Lines 34-39 Link Here
34
34
35
comma	:= ,
35
comma	:= ,
36
36
37
# we don't know why, but newer (v1.1+) Xbox only boot
38
ifeq ($(CONFIG_XBOX),y)
39
 	CFLAGS := -O0 -D__KERNEL__ -I../../../../include -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i386
40
endif
41
37
misc.o: misc.c
42
misc.o: misc.c
38
	$(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c misc.c
43
	$(CC) $(CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -c misc.c
39
44
(-)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/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 (+15 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
		Xbox_reset();
422
	}
423
#endif
424
415
	if(!reboot_thru_bios) {
425
	if(!reboot_thru_bios) {
416
		/* rebooting needs to touch the page at absolute addr 0 */
426
		/* rebooting needs to touch the page at absolute addr 0 */
417
		*((unsigned short *)__va(0x472)) = reboot_mode;
427
		*((unsigned short *)__va(0x472)) = reboot_mode;
Lines 438-443 Link Here
438
448
439
void machine_power_off(void)
449
void machine_power_off(void)
440
{
450
{
451
#ifdef CONFIG_XBOX
452
	if (machine_is_xbox) {
453
		Xbox_power_off();
454
	}
455
#endif
441
	if (pm_power_off)
456
	if (pm_power_off)
442
		pm_power_off();
457
		pm_power_off();
443
}
458
}
(-)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 = 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/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/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 AMD/XBOX' CONFIG_I2C_AMD756 $CONFIG_I2C
68
      dep_tristate '  I2C XBOX EXTSMI' CONFIG_I2C_EXTSMI $CONFIG_I2C_AMD756
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-amd756.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_AMD756)	+= i2c-amd756.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-amd756.c (+428 lines)
Line 0 Link Here
1
/*
2
    amd756.c - Part of lm_sensors, Linux kernel modules for hardware
3
              monitoring
4
5
    Copyright (c) 1999-2002 Merlin Hughes <merlin@merlin.org>
6
7
    Shamelessly ripped from i2c-piix4.c:
8
9
    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl> and
10
    Philip Edelbrock <phil@netroedge.com>
11
12
    This program is free software; you can redistribute it and/or modify
13
    it under the terms of the GNU General Public License as published by
14
    the Free Software Foundation; either version 2 of the License, or
15
    (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., 675 Mass Ave, Cambridge, MA 02139, USA.
25
*/
26
27
/*
28
    2002-04-08: Added nForce support. (Csaba Halasz)
29
    2002-10-03: Fixed nForce PnP I/O port. (Michael Steil)
30
    2002-12-28: Rewritten into something that resembles a Linux driver (hch)
31
    2003-11-29: Added back AMD8111 removed by the previous rewrite.
32
                (Philip Pokorny)
33
    2004-02-15: Don't register driver to avoid driver conflicts.
34
                (Daniel Rune Jensen)
35
*/
36
37
/*
38
   Supports AMD756, AMD766, AMD768, AMD8111 and nVidia nForce
39
   Note: we assume there can only be one device, with one SMBus interface.
40
*/
41
42
#include <linux/module.h>
43
#include <linux/pci.h>
44
#include <linux/kernel.h>
45
#include <linux/stddef.h>
46
#include <linux/sched.h>
47
#include <linux/ioport.h>
48
#include <linux/i2c.h>
49
#include <linux/init.h>
50
#include <asm/io.h>
51
#include <linux/delay.h>
52
53
#define DRV_NAME	"i2c-amd756"
54
55
/* AMD756 SMBus address offsets */
56
#define SMB_ADDR_OFFSET        0xE0
57
#define SMB_IOSIZE             16
58
#define SMB_GLOBAL_STATUS      (0x0 + amd756_ioport)
59
#define SMB_GLOBAL_ENABLE      (0x2 + amd756_ioport)
60
#define SMB_HOST_ADDRESS       (0x4 + amd756_ioport)
61
#define SMB_HOST_DATA          (0x6 + amd756_ioport)
62
#define SMB_HOST_COMMAND       (0x8 + amd756_ioport)
63
#define SMB_HOST_BLOCK_DATA    (0x9 + amd756_ioport)
64
#define SMB_HAS_DATA           (0xA + amd756_ioport)
65
#define SMB_HAS_DEVICE_ADDRESS (0xC + amd756_ioport)
66
#define SMB_HAS_HOST_ADDRESS   (0xE + amd756_ioport)
67
#define SMB_SNOOP_ADDRESS      (0xF + amd756_ioport)
68
69
/* PCI Address Constants */
70
71
/* address of I/O space */
72
#define SMBBA     0x058		/* mh */
73
#define SMBBANFORCE     0x014
74
75
/* general configuration */
76
#define SMBGCFG   0x041		/* mh */
77
78
/* silicon revision code */
79
#define SMBREV    0x008
80
81
/* Other settings */
82
#define MAX_TIMEOUT 500
83
84
/* AMD756 constants */
85
#define AMD756_QUICK        0x00
86
#define AMD756_BYTE         0x01
87
#define AMD756_BYTE_DATA    0x02
88
#define AMD756_WORD_DATA    0x03
89
#define AMD756_PROCESS_CALL 0x04
90
#define AMD756_BLOCK_DATA   0x05
91
92
93
static unsigned short amd756_ioport = 0;
94
95
/* 
96
  SMBUS event = I/O 28-29 bit 11
97
     see E0 for the status bits and enabled in E2
98
     
99
*/
100
101
#define GS_ABRT_STS (1 << 0)
102
#define GS_COL_STS (1 << 1)
103
#define GS_PRERR_STS (1 << 2)
104
#define GS_HST_STS (1 << 3)
105
#define GS_HCYC_STS (1 << 4)
106
#define GS_TO_STS (1 << 5)
107
#define GS_SMB_STS (1 << 11)
108
109
#define GS_CLEAR_STS (GS_ABRT_STS | GS_COL_STS | GS_PRERR_STS | \
110
  GS_HCYC_STS | GS_TO_STS )
111
112
#define GE_CYC_TYPE_MASK (7)
113
#define GE_HOST_STC (1 << 3)
114
#define GE_ABORT (1 << 5)
115
116
117
static int amd756_transaction(void)
118
{
119
	int temp;
120
	int result = 0;
121
	int timeout = 0;
122
123
	pr_debug(DRV_NAME
124
	       ": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
125
	       inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE),
126
	       inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA));
127
128
	/* Make sure the SMBus host is ready to start transmitting */
129
	if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) {
130
		pr_debug(DRV_NAME ": SMBus busy (%04x). Waiting... \n", temp);
131
		do {
132
			udelay(100);
133
			temp = inw_p(SMB_GLOBAL_STATUS);
134
		} while ((temp & (GS_HST_STS | GS_SMB_STS)) &&
135
		         (timeout++ < MAX_TIMEOUT));
136
		/* If the SMBus is still busy, we give up */
137
		if (timeout >= MAX_TIMEOUT) {
138
			pr_debug(DRV_NAME ": Busy wait timeout (%04x)\n", temp);
139
			goto abort;
140
		}
141
		timeout = 0;
142
	}
143
144
	/* start the transaction by setting the start bit */
145
	outw_p(inw(SMB_GLOBAL_ENABLE) | GE_HOST_STC, SMB_GLOBAL_ENABLE);
146
147
	/* We will always wait for a fraction of a second! */
148
	do {
149
		udelay(100);
150
		temp = inw_p(SMB_GLOBAL_STATUS);
151
	} while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT));
152
153
	/* If the SMBus is still busy, we give up */
154
	if (timeout >= MAX_TIMEOUT) {
155
		pr_debug(DRV_NAME ": Completion timeout!\n");
156
		goto abort;
157
	}
158
159
	if (temp & GS_PRERR_STS) {
160
		result = -1;
161
		pr_debug(DRV_NAME ": SMBus Protocol error (no response)!\n");
162
	}
163
164
	if (temp & GS_COL_STS) {
165
		result = -1;
166
		printk(KERN_WARNING DRV_NAME ": SMBus collision!\n");
167
	}
168
169
	if (temp & GS_TO_STS) {
170
		result = -1;
171
		pr_debug(DRV_NAME ": SMBus protocol timeout!\n");
172
	}
173
174
	if (temp & GS_HCYC_STS)
175
		pr_debug(DRV_NAME ": SMBus protocol success!\n");
176
177
	outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
178
179
#ifdef DEBUG
180
	if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) {
181
		pr_debug(DRV_NAME
182
		         ": Failed reset at end of transaction (%04x)\n", temp);
183
	}
184
185
	pr_debug(DRV_NAME
186
		 ": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
187
		 inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE),
188
		 inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA));
189
#endif
190
191
	return result;
192
193
 abort:
194
	printk(KERN_WARNING DRV_NAME ": Sending abort.\n");
195
	outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
196
	udelay(100);
197
	outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
198
	return -1;
199
}
200
201
/* Return -1 on error. */
202
203
static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
204
		  unsigned short flags, char read_write,
205
		  u8 command, int size, union i2c_smbus_data * data)
206
{
207
	int i, len;
208
209
	/** TODO: Should I supporte the 10-bit transfers? */
210
	switch (size) {
211
	/* TODO: proc call is supported, I'm just not sure what to do here... */
212
	case I2C_SMBUS_QUICK:
213
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
214
		       SMB_HOST_ADDRESS);
215
		size = AMD756_QUICK;
216
		break;
217
	case I2C_SMBUS_BYTE:
218
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
219
		       SMB_HOST_ADDRESS);
220
		if (read_write == I2C_SMBUS_WRITE)
221
			outb_p(command, SMB_HOST_DATA);
222
		size = AMD756_BYTE;
223
		break;
224
	case I2C_SMBUS_BYTE_DATA:
225
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
226
		       SMB_HOST_ADDRESS);
227
		outb_p(command, SMB_HOST_COMMAND);
228
		if (read_write == I2C_SMBUS_WRITE)
229
			outw_p(data->byte, SMB_HOST_DATA);
230
		size = AMD756_BYTE_DATA;
231
		break;
232
	case I2C_SMBUS_WORD_DATA:
233
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
234
		       SMB_HOST_ADDRESS);
235
		outb_p(command, SMB_HOST_COMMAND);
236
		if (read_write == I2C_SMBUS_WRITE)
237
			outw_p(data->word, SMB_HOST_DATA);	/* TODO: endian???? */
238
		size = AMD756_WORD_DATA;
239
		break;
240
	case I2C_SMBUS_BLOCK_DATA:
241
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
242
		       SMB_HOST_ADDRESS);
243
		outb_p(command, SMB_HOST_COMMAND);
244
		if (read_write == I2C_SMBUS_WRITE) {
245
			len = data->block[0];
246
			if (len < 0)
247
				len = 0;
248
			if (len > 32)
249
				len = 32;
250
			outw_p(len, SMB_HOST_DATA);
251
			/* i = inw_p(SMBHSTCNT); Reset SMBBLKDAT */
252
			for (i = 1; i <= len; i++)
253
				outb_p(data->block[i],
254
				       SMB_HOST_BLOCK_DATA);
255
		}
256
		size = AMD756_BLOCK_DATA;
257
		break;
258
	default:
259
		printk
260
		    (KERN_WARNING "i2c-amd756.o: Unsupported transaction %d\n", size);
261
		return -1;
262
	}
263
264
	/* How about enabling interrupts... */
265
	outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE);
266
267
	if (amd756_transaction())	/* Error in transaction */
268
		return -1;
269
270
	if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK))
271
		return 0;
272
273
274
	switch (size) {
275
	case AMD756_BYTE:
276
		data->byte = inw_p(SMB_HOST_DATA);
277
		break;
278
	case AMD756_BYTE_DATA:
279
		data->byte = inw_p(SMB_HOST_DATA);
280
		break;
281
	case AMD756_WORD_DATA:
282
		data->word = inw_p(SMB_HOST_DATA);	/* TODO: endian???? */
283
		break;
284
	case AMD756_BLOCK_DATA:
285
		data->block[0] = inw_p(SMB_HOST_DATA) & 0x3f;
286
		if(data->block[0] > 32)
287
			data->block[0] = 32;
288
		/* i = inw_p(SMBHSTCNT); Reset SMBBLKDAT */
289
		for (i = 1; i <= data->block[0]; i++)
290
			data->block[i] = inb_p(SMB_HOST_BLOCK_DATA);
291
		break;
292
	}
293
294
	return 0;
295
}
296
297
static u32 amd756_func(struct i2c_adapter *adapter)
298
{
299
	return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
300
	    I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
301
	    I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL;
302
}
303
304
static struct i2c_algorithm smbus_algorithm = {
305
	.name		= "Non-I2C SMBus adapter",
306
	.id		= I2C_ALGO_SMBUS,
307
	.smbus_xfer	= amd756_access,
308
	.functionality	= amd756_func,
309
};
310
311
static struct i2c_adapter amd756_adapter = {
312
	"unset",
313
	I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756,
314
	&smbus_algorithm,
315
};
316
317
enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 };
318
319
static struct pci_device_id amd756_ids[] __devinitdata = {
320
	{PCI_VENDOR_ID_AMD, 0x740B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD756 },
321
	{PCI_VENDOR_ID_AMD, 0x7413, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD766 },
322
	{PCI_VENDOR_ID_AMD, 0x7443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD768 },
323
	{PCI_VENDOR_ID_AMD, 0x746B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD8111 },
324
	{PCI_VENDOR_ID_NVIDIA, 0x01B4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE },
325
	{ 0, }
326
};
327
328
static int __devinit amd756_probe(struct pci_dev *pdev,
329
				  const struct pci_device_id *id)
330
{
331
	int nforce = (id->driver_data == NFORCE);
332
	int error;
333
	u8 temp;
334
	
335
	if (amd756_ioport) {
336
		printk(KERN_ERR DRV_NAME ": Only one device supported. "
337
		       "(you have a strange motherboard, btw..)\n");
338
		return -ENODEV;
339
	}
340
341
	if (nforce) {
342
		if (PCI_FUNC(pdev->devfn) != 1)
343
			return -ENODEV;
344
345
		pci_read_config_word(pdev, SMBBANFORCE, &amd756_ioport);
346
		amd756_ioport &= 0xfffc;
347
	} else { /* amd */
348
		if (PCI_FUNC(pdev->devfn) != 3)
349
			return -ENODEV;
350
351
		pci_read_config_byte(pdev, SMBGCFG, &temp);
352
		if ((temp & 128) == 0) {
353
			printk(KERN_ERR DRV_NAME
354
			       ": Error: SMBus controller I/O not enabled!\n");
355
			return -ENODEV;
356
		}
357
358
		/* Determine the address of the SMBus areas */
359
		/* Technically it is a dword but... */
360
		pci_read_config_word(pdev, SMBBA, &amd756_ioport);
361
		amd756_ioport &= 0xff00;
362
		amd756_ioport += SMB_ADDR_OFFSET;
363
	}
364
365
	if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) {
366
		printk(KERN_ERR DRV_NAME
367
		       ": SMB region 0x%x already in use!\n", amd756_ioport);
368
		return -ENODEV;
369
	}
370
371
#ifdef DEBUG
372
	pci_read_config_byte(pdev, SMBREV, &temp);
373
	printk(KERN_DEBUG DRV_NAME ": SMBREV = 0x%X\n", temp);
374
	printk(KERN_DEBUG DRV_NAME ": AMD756_smba = 0x%X\n", amd756_ioport);
375
#endif
376
377
	sprintf(amd756_adapter.name,
378
		"SMBus AMD756 adapter at %04x", amd756_ioport);
379
380
	error = i2c_add_adapter(&amd756_adapter);
381
	if (error) {
382
		printk(KERN_ERR DRV_NAME
383
		       ": Adapter registration failed, module not inserted.\n");
384
		goto out_err;
385
	}
386
387
	return 0;
388
389
 out_err:
390
	release_region(amd756_ioport, SMB_IOSIZE);
391
	return error;
392
}
393
394
395
int __init i2c_amd756_init(void)
396
{
397
	struct pci_dev *dev;
398
	const struct pci_device_id *id;
399
400
	printk(KERN_INFO "i2c-amd756.o version 2.8.6\n");
401
402
 	pci_for_each_dev(dev) {
403
		id = pci_match_device(amd756_ids, dev);
404
		if (id && amd756_probe(dev, id) >= 0)
405
			return 0; 
406
	}
407
408
	return -ENODEV;
409
}
410
411
void __exit i2c_amd756_exit(void)
412
{
413
	i2c_del_adapter(&amd756_adapter);
414
	release_region(amd756_ioport, SMB_IOSIZE);
415
}
416
417
EXPORT_SYMBOL(i2c_amd756_init);
418
419
#ifdef MODULE
420
421
MODULE_AUTHOR("Merlin Hughes <merlin@merlin.org>");
422
MODULE_DESCRIPTION("AMD756/766/768/8111 and nVidia nForce SMBus driver");
423
MODULE_LICENSE("GPL");
424
425
module_init(i2c_amd756_init)
426
module_exit(i2c_amd756_exit)
427
428
#endif
(-)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/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/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/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/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/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_AMD756
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/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 conexant.o focus.o xlb.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 (+642 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
	int dotClock,
85
	unsigned char * regs
86
){
87
	unsigned char pll_int = (unsigned char)((double)dotClock * 6.0 / 13.5e3 + 0.5);
88
			
89
	memset(regs, 0, NUM_CONEXANT_REGS);
90
	// Protect against overclocking
91
	if (pll_int > 36) {
92
		pll_int = 36; // 36 / 6 * 13.5 MHz = 81 MHz, just above the limit.
93
	}
94
	if (pll_int == 0) {
95
		pll_int = 1;  // 0 will cause a burnout ...
96
	}
97
	if (av_type == AV_VGA) {
98
		// use internal sync signals
99
		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
100
	}
101
	else {
102
 		// use sync on green
103
		regs[ADR(0x2e)] = 0xad; // HDTV_EN = 1, RPR_SYNC_DIS = 1, BPB_SYNC_DIS = 1, HD_SYNC_EDGE = 1, RASTER_SEL = 01
104
	}
105
	regs[ADR(0x32)] = 0x48; // DRVS = 2, IN_MODE[3] = 1;
106
	regs[ADR(0x3c)] = 0x80; // MCOMPY
107
	regs[ADR(0x3e)] = 0x80; // MCOMPU
108
	regs[ADR(0x40)] = 0x80; // MCOMPV
109
	regs[ADR(0xc6)] = 0x98; // IN_MODE = 24 bit RGB multiplexed
110
	regs[ADR(0x6c)] = 0x46; // FLD_MODE = 10, EACTIVE = 1, EN_SCART = 0, EN_REG_RD = 1
111
	regs[ADR(0x9c)] = 0x00; // PLL_FRACT
112
	regs[ADR(0x9e)] = 0x00; // PLL_FRACT
113
	regs[ADR(0xa0)] = pll_int; // PLL_INT
114
	regs[ADR(0xba)] = 0x28; // SLAVER = 1, DACDISD = 1
115
	regs[ADR(0xce)] = 0xe1; // OUT_MUXA = 01, OUT_MUXB = 00, OUT_MUXC = 10, OUT_MUXD = 11
116
	regs[ADR(0xd6)] = 0x0c; // OUT_MODE = 11 (RGB / SCART / HDTV)
117
118
	return 1;
119
}
120
121
int conexant_calc_hdtv_mode(
122
	xbox_hdtv_mode hdtv_mode,
123
	int dotClock,
124
	unsigned char * regs
125
){
126
	unsigned char pll_int = (unsigned char)((double)dotClock * 6.0 / 13.5e3 + 0.5);
127
	memset(regs, 0, NUM_CONEXANT_REGS);
128
	// Protect against overclocking
129
	if (pll_int > 36) {
130
		pll_int = 36; // 36 / 6 * 13.5 MHz = 81 MHz, just above the limit.
131
	}
132
	if (pll_int == 0) {
133
		pll_int = 1;  // 0 will cause a burnout ...
134
	}
135
	switch (hdtv_mode) {
136
		case HDTV_480p:
137
			// use sync on green
138
			regs[ADR(0x2e)] = 0xed; // HDTV_EN = 1, RGB2PRPB = 1, RPR_SYNC_DIS = 1, BPB_SYNC_DIS = 1, HD_SYNC_EDGE = 1, RASTER_SEL = 01
139
			regs[ADR(0x32)] = 0x48; // DRVS = 2, IN_MODE[3] = 1;
140
			regs[ADR(0x3e)] = 0x45; // MCOMPU
141
			regs[ADR(0x40)] = 0x51; // MCOMPV
142
			break;
143
		case HDTV_720p:
144
			// use sync on green
145
			regs[ADR(0x2e)] = 0xea; // HDTV_EN = 1, RGB2PRPB = 1, RPR_SYNC_DIS = 1, BPB_SYNC_DIS = 1, HD_SYNC_EDGE = 1, RASTER_SEL = 01
146
			regs[ADR(0x32)] = 0x49; // DRVS = 2, IN_MODE[3] = 1, CSC_SEL=1;
147
			regs[ADR(0x3e)] = 0x45; // MCOMPU
148
			regs[ADR(0x40)] = 0x51; // MCOMPV
149
			break;
150
		case HDTV_1080i:
151
			// use sync on green
152
			regs[ADR(0x2e)] = 0xeb; // HDTV_EN = 1, RGB2PRPB = 1, RPR_SYNC_DIS = 1, BPB_SYNC_DIS = 1, HD_SYNC_EDGE = 1, RASTER_SEL = 01
153
			regs[ADR(0x32)] = 0x49; // DRVS = 2, IN_MODE[3] = 1, CSC_SEL=1;
154
			regs[ADR(0x3e)] = 0x48; // MCOMPU
155
			regs[ADR(0x40)] = 0x5b; // MCOMPV
156
			break;
157
	}
158
	regs[ADR(0x3c)] = 0x80; // MCOMPY
159
	regs[ADR(0xa0)] = pll_int; // PLL_INT
160
	regs[ADR(0xc6)] = 0x98; // IN_MODE = 24 bit RGB multiplexed
161
	regs[ADR(0x6c)] = 0x46; // FLD_MODE = 10, EACTIVE = 1, EN_SCART = 0, EN_REG_RD = 1
162
	regs[ADR(0x9c)] = 0x00; // PLL_FRACT
163
	regs[ADR(0x9e)] = 0x00; // PLL_FRACT
164
	regs[ADR(0xba)] = 0x28; // SLAVER = 1, DACDISD = 1
165
	regs[ADR(0xce)] = 0xe1; // OUT_MUXA = 01, OUT_MUXB = 00, OUT_MUXC = 10, OUT_MUXD = 11
166
	regs[ADR(0xd6)] = 0x0c; // OUT_MODE = 11 (RGB / SCART / HDTV)
167
168
	return 1;
169
}
170
171
int conexant_calc_mode(xbox_video_mode * mode, struct riva_regs * riva_out)
172
{
173
	unsigned char b;
174
	unsigned int m = 0;
175
	double dPllOutputFrequency;
176
	xbox_tv_mode_parameter param;
177
	char* regs = riva_out->encoder_mode;
178
179
	if (conexant_calc_mode_params(mode, &param))
180
	{
181
		// copy default mode settings
182
		memcpy(regs,default_mode,sizeof(default_mode));
183
184
		regs[ADR(0x32)] = 0x28; // DRVS = 1, IN_MODE[3] = 1;
185
186
		// H_CLKI
187
		b=regs[ADR(0x8e)]&(~0x07);
188
		regs[ADR(0x8e)] = ((param.h_clki>>8)&0x07)|b;
189
		regs[ADR(0x8a)] = ((param.h_clki)&0xff);
190
		// H_CLKO
191
		b=regs[ADR(0x86)]&(~0x0f);
192
		regs[ADR(0x86)] = ((param.h_clko>>8)&0x0f)|b;
193
		regs[ADR(0x76)] = ((param.h_clko)&0xff);
194
		// V_LINESI
195
		b=regs[ADR(0x38)]&(~0x02);
196
		regs[ADR(0x38)] = ((param.v_linesi>>9)&0x02)|b;
197
		b=regs[ADR(0x96)]&(~0x03);
198
		regs[ADR(0x96)] = ((param.v_linesi>>8)&0x03)|b;
199
		regs[ADR(0x90)] = ((param.v_linesi)&0xff);
200
		// V_ACTIVEO
201
		/* TODO: Absolutely not sure about other modes than plain NTSC / PAL */
202
		switch(mode->tv_encoding) {
203
			case TV_ENC_NTSC:
204
			case TV_ENC_NTSC60:
205
			case TV_ENC_PALM:
206
			case TV_ENC_PAL60:
207
				m=param.v_activeo + 1;
208
				break;
209
			case TV_ENC_PALBDGHI:
210
				m=param.v_activeo + 2;
211
				break;
212
			default:
213
				m=param.v_activeo + 2;
214
				break;
215
		}
216
		b=regs[ADR(0x86)]&(~0x80);
217
		regs[ADR(0x86)] = ((m>>1)&0x80)|b;
218
		regs[ADR(0x84)] = ((m)&0xff);
219
		// H_ACTIVE
220
		b=regs[ADR(0x86)]&(~0x70);
221
		regs[ADR(0x86)] = (((mode->xres + 5)>>4)&0x70)|b;
222
		regs[ADR(0x78)] = ((mode->xres + 5)&0xff);
223
		// V_ACTIVEI
224
		b=regs[ADR(0x96)]&(~0x0c);
225
		regs[ADR(0x96)] = ((mode->yres>>6)&0x0c)|b;
226
		regs[ADR(0x94)] = ((mode->yres)&0xff);
227
		// H_BLANKI
228
		b=regs[ADR(0x38)]&(~0x01);
229
		regs[ADR(0x38)] = ((param.h_blanki>>9)&0x01)|b;
230
		b=regs[ADR(0x8e)]&(~0x08);
231
		regs[ADR(0x8e)] = ((param.h_blanki>>5)&0x08)|b;
232
		regs[ADR(0x8c)] = ((param.h_blanki)&0xff);
233
		// H_BLANKO
234
		b=regs[ADR(0x9a)]&(~0xc0);
235
		regs[ADR(0x9a)] = ((param.h_blanko>>2)&0xc0)|b;
236
		regs[ADR(0x80)] = ((param.h_blanko)&0xff);
237
238
		// V_SCALE
239
		b=regs[ADR(0x9a)]&(~0x3f);
240
		regs[ADR(0x9a)] = ((param.vscale>>8)&0x3f)|b;
241
		regs[ADR(0x98)] = ((param.vscale)&0xff);
242
		// V_BLANKO
243
		regs[ADR(0x82)] = ((param.v_blanko)&0xff);
244
		// V_BLANKI
245
		regs[ADR(0x92)] = ((param.v_blanki)&0xff);
246
		{
247
			unsigned int dwPllRatio, dwFract, dwInt;
248
			// adjust PLL
249
			dwPllRatio = (int)(6.0 * ((double)param.h_clko / vidstda[mode->tv_encoding].m_dSecHsyncPeriod) *
250
				param.clk_ratio * 0x10000 / pll_base + 0.5);
251
			dwInt = dwPllRatio / 0x10000;
252
			dwFract = dwPllRatio - (dwInt * 0x10000);
253
			b=regs[ADR(0xa0)]&(~0x3f);
254
			regs[ADR(0xa0)] = ((dwInt)&0x3f)|b;
255
			regs[ADR(0x9e)] = ((dwFract>>8)&0xff);
256
			regs[ADR(0x9c)] = ((dwFract)&0xff);
257
			// recalc value
258
			dPllOutputFrequency = ((double)dwInt + ((double)dwFract)/65536.0)/(6 * param.clk_ratio / pll_base);
259
			// enable 3:2 clocking mode
260
			b=regs[ADR(0x38)]&(~0x20);
261
			if (param.clk_ratio > 1.1) {
262
				b |= 0x20;
263
			}
264
			regs[ADR(0x38)] = b;
265
266
			// update burst start position
267
			m=(vidstda[mode->tv_encoding].m_dSecBurstStart) * dPllOutputFrequency + 0.5;
268
			b=regs[ADR(0x38)]&(~0x04);
269
			regs[ADR(0x38)] = ((m>>6)&0x04)|b;
270
			regs[ADR(0x7c)] = (m&0xff);
271
			// update burst end position (note +128 is in hardware)
272
			m=(vidstda[mode->tv_encoding].m_dSecBurstEnd) * dPllOutputFrequency + 0.5;
273
			if(m<128) m=128;
274
			b=regs[ADR(0x38)]&(~0x08);
275
			regs[ADR(0x38)] = (((m-128)>>5)&0x08)|b;
276
			regs[ADR(0x7e)] = ((m-128)&0xff);
277
			// update HSYNC width
278
			m=(vidstda[mode->tv_encoding].m_dSecHsyncWidth) * dPllOutputFrequency + 0.5;
279
			regs[ADR(0x7a)] = ((m)&0xff);
280
		}
281
		// adjust Subcarrier generation increment
282
		{
283
			unsigned int dwSubcarrierIncrement = (unsigned int) (
284
				(65536.0 * 65536.0) * (
285
					vidstda[mode->tv_encoding].m_dHzBurstFrequency
286
					* vidstda[mode->tv_encoding].m_dSecHsyncPeriod
287
					/ (double)param.h_clko
288
				) + 0.5
289
			);
290
			regs[ADR(0xae)] = (dwSubcarrierIncrement&0xff);
291
			regs[ADR(0xb0)] = ((dwSubcarrierIncrement>>8)&0xff);
292
			regs[ADR(0xb2)] = ((dwSubcarrierIncrement>>16)&0xff);
293
			regs[ADR(0xb4)] = ((dwSubcarrierIncrement>>24)&0xff);
294
		}
295
		// adjust WSS increment
296
		{
297
			unsigned int dwWssIncrement = 0;
298
299
			switch(mode->tv_encoding) {
300
				case TV_ENC_NTSC:
301
				case TV_ENC_NTSC60:
302
					dwWssIncrement=(unsigned int) ((1048576.0 / ( 0.000002234 * dPllOutputFrequency))+0.5);
303
					break;
304
				case TV_ENC_PALBDGHI:
305
				case TV_ENC_PALN:
306
				case TV_ENC_PALNC:
307
				case TV_ENC_PALM:
308
				case TV_ENC_PAL60:
309
					dwWssIncrement=(unsigned int) ((1048576.0 / ( 0.0000002 * dPllOutputFrequency))+0.5);
310
					break;
311
				default:
312
					break;
313
				}
314
315
			regs[ADR(0x66)] = (dwWssIncrement&0xff);
316
			regs[ADR(0x68)] = ((dwWssIncrement>>8)&0xff);
317
			regs[ADR(0x6a)] = ((dwWssIncrement>>16)&0xf);
318
		}
319
		// set mode register
320
		b=regs[ADR(0xa2)]&(0x41);
321
		switch(mode->tv_encoding) {
322
				case TV_ENC_NTSC:
323
					b |= 0x0a; // SETUP + VSYNC_DUR
324
					break;
325
				case TV_ENC_NTSC60:
326
					b |= 0x08; // VSYNC_DUR
327
					break;
328
				case TV_ENC_PALBDGHI:
329
				case TV_ENC_PALNC:
330
						b |= 0x24; // PAL_MD + 625LINE
331
					break;
332
				case TV_ENC_PALN:
333
					b |= 0x2e; // PAL_MD + SETUP + 625LINE + VSYNC_DUR
334
					break;
335
				case TV_ENC_PALM:
336
					b |= 0x2a; // PAL_MD + SETUP + VSYNC_DUR
337
					break;
338
				case TV_ENC_PAL60:
339
					b |= 0x28; // PAL_MD + VSYNC_DUR
340
					break;
341
				default:
342
					break;
343
		}
344
		regs[ADR(0xa2)] = b;
345
		regs[ADR(0xc6)] = 0x98; // IN_MODE = 24 bit RGB multiplexed
346
		switch(mode->av_type) {
347
			case AV_COMPOSITE:
348
			case AV_SVIDEO:
349
				regs[ADR(0x2e)] |= 0x40; // RGB2YPRPB = 1
350
				regs[ADR(0x6c)] = 0x46; // FLD_MODE = 10, EACTIVE = 1, EN_SCART = 0, EN_REG_RD = 1
351
				regs[ADR(0x5a)] = 0x00; // Y_OFF (Brightness)
352
				regs[ADR(0xa4)] = 0xe5; // SYNC_AMP
353
				regs[ADR(0xa6)] = 0x74; // BST_AMP
354
				regs[ADR(0xba)] = 0x24; // SLAVER = 1, DACDISC = 1
355
				regs[ADR(0xce)] = 0x19; // OUT_MUXA = 01, OUT_MUXB = 10, OUT_MUXC = 10, OUT_MUXD = 00
356
				regs[ADR(0xd6)] = 0x00; // OUT_MODE = 00 (CVBS)
357
				break;
358
			case AV_SCART_RGB:
359
				regs[ADR(0x6c)] = 0x4e; // FLD_MODE = 10, EACTIVE = 1, EN_SCART = 1, EN_REG_RD = 1
360
				regs[ADR(0x5a)] = 0xff; // Y_OFF (Brightness)
361
				regs[ADR(0xa4)] = 0xe7; // SYNC_AMP
362
				regs[ADR(0xa6)] = 0x77; // BST_AMP
363
				regs[ADR(0xba)] = 0x20; // SLAVER = 1, enable all DACs
364
				regs[ADR(0xce)] = 0xe1; // OUT_MUXA = 01, OUT_MUXB = 00, OUT_MUXC = 10, OUT_MUXD = 11
365
				regs[ADR(0xd6)] = 0x0c; // OUT_MODE = 11 (RGB / SCART / HDTV)
366
				break;
367
			default:
368
				break;
369
		}
370
		riva_out->ext.vend = mode->yres;
371
		riva_out->ext.vtotal = param.v_linesi - 1;
372
		riva_out->ext.vcrtc = mode->yres;
373
		riva_out->ext.vsyncstart = param.v_linesi - param.v_blanki;
374
		riva_out->ext.vsyncend = riva_out->ext.vsyncstart + 3;
375
		riva_out->ext.vvalidstart = 0;
376
		riva_out->ext.vvalidend = mode->yres;
377
		riva_out->ext.hend = mode->xres + 7;
378
		riva_out->ext.htotal = param.h_clki - 1;
379
		riva_out->ext.hcrtc = mode->xres - 1;
380
		riva_out->ext.hsyncstart = param.h_clki - param.h_blanki - 7;
381
		riva_out->ext.hsyncend = riva_out->ext.hsyncstart + 32;
382
		riva_out->ext.hvalidstart = 0;
383
		riva_out->ext.hvalidend = mode->xres - 1;
384
		riva_out->ext.crtchdispend = mode->xres + 8;
385
		riva_out->ext.crtcvstart = mode->yres + 34;
386
		riva_out->ext.crtcvtotal = param.v_linesi + 32;
387
		return 1;
388
	}
389
	else
390
	{
391
		return 0;
392
	}
393
}
394
395
static int conexant_calc_mode_params(
396
	xbox_video_mode * mode,
397
	xbox_tv_mode_parameter * param
398
){
399
	const double dMinHBT = 2.5e-6; // 2.5uSec time for horizontal syncing
400
	const double invalidMetric = 1000;
401
402
	/* algorithm shamelessly ripped from nvtv/calc_bt.c */
403
	double dTempVOC = 0;
404
	double dTempHOC = 0;
405
	double dBestMetric = invalidMetric;
406
	double dTempVSR = 0;
407
	double dBestVSR = 0;
408
	double dTempCLKRATIO = 1;
409
	double dBestCLKRATIO = 1;
410
	unsigned int  minTLI = 0;
411
	unsigned int  maxTLI = 0;
412
	unsigned int  tempTLI = 0;
413
	unsigned int  bestTLI = 0;
414
	unsigned int  minHCLKO = 0;
415
	unsigned int  maxHCLKO = 0;
416
	unsigned int  minHCLKI = 0;
417
	unsigned int  tempHCLKI = 0;
418
	unsigned int  bestHCLKI = 0;
419
	int    actCLKRATIO;
420
	unsigned int  dTempHCLKO = 0;
421
	double dTempVACTIVEO = 0;
422
	double dDelta = 0;
423
	double dMetric = 0;
424
	double alo =  vidstda[mode->tv_encoding].m_dwALO;
425
	double tlo =  vidstda[mode->tv_encoding].m_TotalLinesOut;
426
	double tto = vidstda[mode->tv_encoding].m_dSecHsyncPeriod;
427
	double ato = tto - (vidstda[mode->tv_encoding].m_dSecBlankBeginToHsync + vidstda[mode->tv_encoding].m_dSecActiveBegin);
428
429
	/* Range to search */
430
	double dMinHOC = mode->hoc - 0.02;
431
	double dMaxHOC = mode->hoc + 0.02;
432
	double dMinVOC = mode->voc - 0.02;
433
	double dMaxVOC = mode->voc + 0.02;
434
435
	if (dMinHOC < 0) dMinHOC = 0;
436
	if (dMinVOC < 0) dMinVOC = 0;
437
438
	minTLI= (unsigned int)(mode->yres / ((1 - dMinVOC) * alo) * tlo);
439
	maxTLI = min((unsigned int)(mode->yres / ((1 - dMaxVOC) * alo) * tlo), (unsigned int)1023);
440
	minHCLKO = (unsigned int) ((mode->xres * 2) /
441
				((1 - dMinHOC) * (ato / tto)));
442
	maxHCLKO = (unsigned int) ((mode->xres * 2) /
443
				((1 - dMaxHOC) * (ato / tto)));
444
	for (actCLKRATIO = 0; actCLKRATIO <= 1; actCLKRATIO++)
445
	{
446
		dTempCLKRATIO = 1.0;
447
		if (actCLKRATIO) dTempCLKRATIO = 3.0/2.0;
448
		for(tempTLI = minTLI; tempTLI <= maxTLI; tempTLI++)
449
		{
450
			dTempVSR = (double)tempTLI / tlo;
451
			dTempVACTIVEO = (int)((((double)mode->yres * tlo) +
452
						(tempTLI - 1)) / tempTLI);
453
			dTempVOC = 1 - dTempVACTIVEO / alo;
454
455
			for(dTempHCLKO = minHCLKO; dTempHCLKO <= maxHCLKO; dTempHCLKO++)
456
			{
457
				tempHCLKI = (unsigned int)((dTempHCLKO * dTempCLKRATIO) * (tlo / tempTLI) + 0.5);
458
				minHCLKI = ((dMinHBT / tto) * tempHCLKI) + mode->xres;
459
				// check if solution is valid
460
				if ((fabs((double)(tempTLI * tempHCLKI) - (tlo * dTempHCLKO * dTempCLKRATIO)) < 1e-3) &&
461
					(tempHCLKI >= minHCLKI) && (tempHCLKI < 2048))
462
				{
463
					dTempHOC = 1 - (((double)mode->xres / ((double)dTempHCLKO / 2)) /
464
						(ato / tto));
465
					dDelta = fabs(dTempHOC - mode->hoc) + fabs(dTempVOC - mode->voc);
466
					dMetric = ((dTempHOC - mode->hoc) * (dTempHOC - mode->hoc)) +
467
						((dTempVOC - mode->voc) * (dTempVOC - mode->voc)) +
468
						(2 * dDelta * dDelta);
469
					if(dMetric < dBestMetric)
470
					{
471
						dBestVSR = dTempVSR;
472
						dBestMetric = dMetric;
473
						bestTLI = tempTLI;
474
						bestHCLKI = tempHCLKI;
475
						dBestCLKRATIO = dTempCLKRATIO;
476
					}
477
				} /* valid solution */
478
			} /* dTempHCLKO loop */
479
		} /* tempTLI loop */
480
	} /* CLKRATIO loop */
481
482
	if(dBestMetric != invalidMetric)
483
	{
484
		param->v_linesi = bestTLI;
485
		param->h_clki = bestHCLKI;
486
		param->clk_ratio = dBestCLKRATIO;
487
		param->v_activeo = (unsigned int)(
488
			(
489
				(mode->yres * vidstda[mode->tv_encoding].m_TotalLinesOut)
490
				+ param->v_linesi - 1
491
			) / param->v_linesi
492
		);
493
		param->h_clko = (unsigned int)(
494
			(
495
				(param->v_linesi * param->h_clki) /
496
				(vidstda[mode->tv_encoding].m_TotalLinesOut * param->clk_ratio)
497
			)
498
			+ 0.5
499
		);
500
		conexant_calc_blankings(mode, param);
501
		return 1;
502
	}
503
	else
504
	{
505
		return 0;
506
	}
507
}
508
509
static void conexant_calc_blankings(
510
	xbox_video_mode * mode,
511
	xbox_tv_mode_parameter * param
512
){
513
	double dTotalHBlankI;
514
	double dFrontPorchIn;
515
	double dFrontPorchOut;
516
	double dMinFrontPorchIn;
517
	double dBackPorchIn;
518
	double dBackPorchOut;
519
	double dTotalHBlankO;
520
	double dHeadRoom;
521
	double dMaxHsyncDrift;
522
	double dFifoMargin;
523
	double vsrq;
524
	double dMaxHR;
525
	double tlo =  vidstda[mode->tv_encoding].m_TotalLinesOut;
526
	const int MFP = 14; // Minimum front porch
527
	const int MBP = 4;  // Minimum back porch
528
	const int FIFO_SIZE = 1024;
529
	double vsr = (double)param->v_linesi / vidstda[mode->tv_encoding].m_TotalLinesOut;
530
531
	// H_BLANKO
532
	param->h_blanko = 2 * (int)(
533
		vidstda[mode->tv_encoding].m_dSecImageCentre / (2 * vidstda[mode->tv_encoding].m_dSecHsyncPeriod) *
534
		param->h_clko
535
		+ 0.5
536
	) - mode->xres + 15;
537
538
	// V_BLANKO
539
	switch (mode->tv_encoding) {
540
		case TV_ENC_NTSC:
541
		case TV_ENC_NTSC60:
542
		case TV_ENC_PAL60:
543
		case TV_ENC_PALM:
544
			param->v_blanko = (int)( 140 - ( param->v_activeo / 2.0 ) + 0.5 );
545
			break;
546
		default:
547
			param->v_blanko = (int)( 167 - ( param->v_activeo / 2.0 ) + 0.5 );
548
			break;
549
	}
550
551
	// V_BLANKI
552
	vsrq = ( (int)( vsr * 4096.0 + .5 ) ) / 4096.0;
553
	param->vscale = (int)( ( vsr - 1 ) * 4096 + 0.5 );
554
	if( vsrq < vsr )
555
	{
556
	// These calculations are in units of dHCLKO
557
		dMaxHsyncDrift = ( vsrq - vsr ) * tlo / vsr * param->h_clko;
558
		dMinFrontPorchIn = MFP / ( (double)param->h_clki * vsr ) * param->h_clko;
559
		dFrontPorchOut = param->h_clko - param->h_blanko - mode->xres * 2;
560
		dFifoMargin = ( FIFO_SIZE - mode->xres ) * 2;
561
562
		// Check for fifo overflow
563
		if( dFrontPorchOut + dFifoMargin < -dMaxHsyncDrift + dMinFrontPorchIn )
564
		{
565
			dTotalHBlankO = param->h_clko - mode->xres * 2;
566
			dTotalHBlankI = ( (double)param->h_clki - (double)mode->xres ) / param->h_clki / vsr * param->h_clko;
567
568
			// Try forcing the Hsync drift the opposite direction
569
			dMaxHsyncDrift = ( vsrq + 1.0 / 4096 - vsr ) * tlo / vsr * param->h_clko;
570
571
			// Check that fifo overflow and underflow can be avoided
572
			if( dTotalHBlankO + dFifoMargin >= dTotalHBlankI + dMaxHsyncDrift )
573
			{
574
				vsrq = vsrq + 1.0 / 4096;
575
				param->vscale = (int)( ( vsrq - 1 ) * 4096 );
576
			}
577
578
			// NOTE: If fifo overflow and underflow can't be avoided,
579
			//       alternative overscan compensation ratios should
580
			//       be selected and all calculations repeated.  If
581
			//       that is not feasible, the calculations for
582
			//       H_BLANKI below will delay the overflow or under-
583
			//       flow as much as possible, to minimize the visible
584
			//       artifacts.
585
		}
586
	}
587
588
	param->v_blanki = (int)( ( param->v_blanko - 1 ) * vsrq );
589
590
	// H_BLANKI
591
592
	// These calculations are in units of dHCLKI
593
	dTotalHBlankI = param->h_clki - mode->xres;
594
	dFrontPorchIn = max( (double)MFP, min( dTotalHBlankI / 8.0, dTotalHBlankI - (double)MBP ) );
595
	dBackPorchIn = dTotalHBlankI - dFrontPorchIn;
596
	dMaxHsyncDrift = ( vsrq - vsr ) * tlo * param->h_clki;
597
	dTotalHBlankO = ( param->h_clko - mode->xres * 2.0 ) / param->h_clko * vsr * param->h_clki;
598
	dBackPorchOut = ((double)param->h_blanko) / (double)param->h_clko * vsr * param->h_clki;
599
	dFrontPorchOut = dTotalHBlankO - dBackPorchOut;
600
	dFifoMargin = ( FIFO_SIZE - mode->xres ) * 2.0 / param->h_clko * vsr * param->h_clki;
601
	// This may be excessive, but is adjusted by the code.
602
	dHeadRoom = 32.0;
603
604
	// Check that fifo overflow and underflow can be avoided
605
	if( ( dTotalHBlankO + dFifoMargin ) >= ( dTotalHBlankI + fabs( dMaxHsyncDrift ) ) )
606
	{
607
		dMaxHR = ( dTotalHBlankO + dFifoMargin ) - ( dTotalHBlankI - fabs( dMaxHsyncDrift ) );
608
		if( dMaxHR < ( dHeadRoom * 2.0 ) )
609
		{
610
			dHeadRoom = (int)( dMaxHR / 2.0);
611
		}
612
613
		// Check for overflow
614
		if( ( ( dFrontPorchOut + dFifoMargin ) - dHeadRoom ) < ( dFrontPorchIn - min( dMaxHsyncDrift, 0.0 ) ) )
615
		{
616
			dFrontPorchIn = max( (double)MFP, ( dFrontPorchOut + dFifoMargin + min( dMaxHsyncDrift, 0.0 ) - dHeadRoom ) );
617
			dBackPorchIn = dTotalHBlankI - dFrontPorchIn;
618
		}
619
620
		// Check for underflow
621
		if( dBackPorchOut - dHeadRoom < dBackPorchIn + max( dMaxHsyncDrift, 0.0 ) )
622
		{
623
			dBackPorchIn = max( (double)MBP, ( dBackPorchOut - max( dMaxHsyncDrift, 0.0 ) - dHeadRoom ) );
624
			dFrontPorchIn = dTotalHBlankI - dBackPorchIn;
625
		}
626
	}
627
	else if( dMaxHsyncDrift < 0 )
628
	{
629
		// Delay the overflow as long as possible
630
		dBackPorchIn = min( ( dBackPorchOut - 1 ), ( dTotalHBlankI - MFP ) );
631
		dFrontPorchIn = dTotalHBlankI - dBackPorchIn;
632
	}
633
	else
634
	{
635
		// Delay the underflow as long as possible
636
		dFrontPorchIn = min( ( dFrontPorchOut + dFifoMargin - 1 ), ( dTotalHBlankI - MBP ) );
637
		dBackPorchIn = dTotalHBlankI - dFrontPorchIn;
638
	}
639
640
	param->h_blanki = (int)( dBackPorchIn );
641
642
}
(-)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, int dotClock, unsigned char * mode_out);
26
int conexant_calc_hdtv_mode(xbox_hdtv_mode hdtv_mode, int dotClock, unsigned char * mode_out);
27
28
#endif
(-)linux-2.4.26/drivers/video/xbox/encoder-i2c.c (+229 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
#include <linux/xbox.h>
24
25
#define CONEXANT_ADDRESS 0x45
26
#define FOCUS_ADDRESS 0x6a
27
#define XLB_ADDRESS 0x70
28
#define EEPROM_ADDRESS 0x54
29
#define PIC_ADDRESS 0x10
30
31
#define DRIVER_NAME "xbox-tv-i2c"
32
33
extern int __init i2c_amd756_init(void);
34
35
static int tv_attach_adapter(struct i2c_adapter *adap);
36
37
static struct i2c_driver tv_driver = {
38
	.name		= "i2c xbox conexant driver",
39
	.id		= I2C_DRIVERID_I2CDEV,
40
	.flags		= I2C_DF_NOTIFY,
41
	.attach_adapter	= tv_attach_adapter,
42
};
43
44
static struct i2c_client pic_client = {
45
	.name		= "I2C xbox pic client",
46
	.id		= 2,
47
	.flags		= 0,
48
	.addr		= PIC_ADDRESS,
49
	.adapter	= NULL,
50
	.driver		= &tv_driver,
51
};
52
53
static struct i2c_client conexant_client = {
54
	.name		= "I2C xbox conexant client",
55
	.id		= 1,
56
	.flags		= 0,
57
	.addr		= CONEXANT_ADDRESS,
58
	.adapter	= NULL,
59
	.driver		= &tv_driver,
60
};
61
62
static struct i2c_client focus_client = {
63
	.name		= "I2C xbox focus client",
64
	.id		= 1,
65
	.flags		= 0,
66
	.addr		= FOCUS_ADDRESS,
67
	.adapter	= NULL,
68
	.driver		= &tv_driver,
69
};
70
71
static struct i2c_client xlb_client = {
72
	.name		= "I2C xbox XLB client",
73
	.id		= 1,
74
	.flags		= 0,
75
	.addr		= XLB_ADDRESS,
76
	.adapter	= NULL,
77
	.driver		= &tv_driver,
78
};
79
80
static struct i2c_client eeprom_client = {
81
	.name		= "I2C xbox eeprom client",
82
	.id		= 3,
83
	.flags		= 0,
84
	.addr		= EEPROM_ADDRESS,
85
	.adapter	= NULL,
86
	.driver		= &tv_driver,
87
};
88
89
static int tv_attach_adapter(struct i2c_adapter *adap)
90
{
91
	int i;
92
93
	if ((i = i2c_adapter_id(adap)) < 0) {
94
		printk("i2c-dev.o: Unknown adapter ?!?\n");
95
		return -ENODEV;
96
	}
97
98
	printk(KERN_INFO DRIVER_NAME ": Using '%s'!\n",adap->name);
99
	conexant_client.adapter = adap;
100
	focus_client.adapter = adap;
101
	xlb_client.adapter = adap;
102
	pic_client.adapter = adap;
103
	eeprom_client.adapter = adap;
104
	i2c_attach_client(&conexant_client);
105
	i2c_attach_client(&focus_client);
106
	i2c_attach_client(&xlb_client);
107
	i2c_attach_client(&pic_client);
108
	i2c_attach_client(&eeprom_client);
109
110
	return 0;
111
}
112
113
int tv_i2c_init(void) {
114
	int res;
115
	i2c_amd756_init();
116
	if ((res = i2c_add_driver(&tv_driver))) {
117
		printk(KERN_ERR DRIVER_NAME ": XBox tv driver registration failed.\n");
118
		return res;
119
	}
120
	return 0;
121
}
122
123
int conexant_i2c_read_reg(unsigned char adr) {
124
	if (!conexant_client.adapter) {
125
		printk(KERN_ERR DRIVER_NAME " : No conexant client attached.\n");
126
		return -1;
127
	}
128
	udelay(500);
129
	return i2c_smbus_read_byte_data(&conexant_client, adr);
130
}
131
132
int conexant_i2c_write_reg(unsigned char adr, unsigned char value) {
133
	if (!conexant_client.adapter) {
134
		printk(KERN_ERR DRIVER_NAME " : No conexant client attached.\n");
135
		return -1;
136
	}
137
	udelay(500);
138
	return i2c_smbus_write_byte_data(&conexant_client, adr, value);
139
}
140
141
int focus_i2c_read_reg(unsigned char adr) {
142
	if (!focus_client.adapter) {
143
		printk(KERN_ERR DRIVER_NAME " : No focus client attached.\n");
144
		return -1;
145
	}
146
	udelay(500);
147
	return i2c_smbus_read_byte_data(&focus_client, adr);
148
}
149
150
int focus_i2c_write_reg(unsigned char adr, unsigned char value) {
151
	if (!focus_client.adapter) {
152
		printk(KERN_ERR DRIVER_NAME " : No focus client attached.\n");
153
		return -1;
154
	}
155
	udelay(500);
156
	return i2c_smbus_write_byte_data(&focus_client, adr, value);
157
}
158
159
int xlb_i2c_read_reg(unsigned char adr) {
160
	if (!xlb_client.adapter) {
161
		printk(KERN_ERR DRIVER_NAME " : No XLB client attached.\n");
162
		return -1;
163
	}
164
	udelay(500);
165
	return i2c_smbus_read_byte_data(&xlb_client, adr);
166
}
167
168
int xlb_i2c_read_block(unsigned char adr, unsigned char *data) {
169
	if (!xlb_client.adapter) {
170
		printk(KERN_ERR DRIVER_NAME " : No XLB client attached.\n");
171
		return -1;
172
	}
173
	udelay(500);
174
	return i2c_smbus_read_block_data(&xlb_client, adr, data);
175
}
176
177
int xlb_i2c_write_block(unsigned char adr, unsigned char *data, int len) {
178
	if (!xlb_client.adapter) {
179
		printk(KERN_ERR DRIVER_NAME " : No XLB client attached.\n");
180
		return -1;
181
	}
182
	udelay(500);
183
	return i2c_smbus_write_block_data(&xlb_client, adr, len, data);
184
}
185
186
187
unsigned char pic_i2c_read_reg(unsigned char adr) {
188
	if (!pic_client.adapter) {
189
		printk(KERN_ERR DRIVER_NAME " : No pic client attached.\n");
190
		return 0;
191
	}
192
	udelay(500);
193
	return (unsigned char)i2c_smbus_read_byte_data(&pic_client, adr);
194
}
195
196
int pic_i2c_write_reg(unsigned char adr, unsigned char value) {
197
	if (!pic_client.adapter) {
198
		printk(KERN_ERR DRIVER_NAME " : No pic client attached.\n");
199
		return -1;
200
	}
201
	udelay(500);
202
	i2c_smbus_write_byte_data(&pic_client, adr, value);
203
	udelay(500);
204
}
205
206
unsigned char set_led(unsigned char mode, unsigned char color) {
207
	pic_i2c_write_reg(SMC_CMD_LED_MODE,mode);
208
        return pic_i2c_write_reg(SMC_CMD_LED_REGISTER,color);
209
}
210
211
unsigned char eeprom_i2c_read(unsigned char adr) {
212
	if (!eeprom_client.adapter) {
213
		printk(KERN_ERR DRIVER_NAME " : No eeprom client attached.\n");
214
		return 0;
215
	}
216
	udelay(500);
217
	return (unsigned char)i2c_smbus_read_byte_data(&eeprom_client, adr);
218
}
219
220
void tv_i2c_exit(void){
221
	int res;
222
	
223
	if ((res = i2c_del_driver(&tv_driver))) {
224
		printk(KERN_ERR DRIVER_NAME ": XBox tv Driver deregistration failed, "
225
		       "module not removed.\n");
226
	}
227
	return;
228
}
229
(-)linux-2.4.26/drivers/video/xbox/encoder-i2c.h (+33 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
int xlb_i2c_read_reg(unsigned char adr);
27
int xlb_i2c_read_block(unsigned char adr, unsigned char *data);
28
int xlb_i2c_write_block(unsigned char adr, unsigned char *data, int len);
29
unsigned char pic_i2c_read_reg(unsigned char adr);
30
unsigned char set_led(unsigned char mode, unsigned char color);
31
unsigned char eeprom_i2c_read(unsigned char adr);
32
33
#endif
(-)linux-2.4.26/drivers/video/xbox/encoder.c (+195 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 "xcalibur.h"
21
#include <asm/io.h>
22
23
#define ADR(x) (x / 2 - 0x17)
24
25
static const conexant_video_parameter vidstda[] = {
26
	{ 3579545.00, 0.0000053, 0.00000782, 0.0000047, 0.000063555, 0.0000094, 0.000035667, 0.0000015, 243, 262.5, 0.0000092 },
27
	{ 3579545.00, 0.0000053, 0.00000782, 0.0000047, 0.000064000, 0.0000094, 0.000035667, 0.0000015, 243, 262.5, 0.0000092 },
28
	{ 4433618.75, 0.0000056, 0.00000785, 0.0000047, 0.000064000, 0.0000105, 0.000036407, 0.0000015, 288, 312.5, 0.0000105 },
29
	{ 4433618.75, 0.0000056, 0.00000785, 0.0000047, 0.000064000, 0.0000094, 0.000035667, 0.0000015, 288, 312.5, 0.0000092 },
30
	{ 3582056.25, 0.0000056, 0.00000811, 0.0000047, 0.000064000, 0.0000105, 0.000036407, 0.0000015, 288, 312.5, 0.0000105 },
31
	{ 3575611.88, 0.0000058, 0.00000832, 0.0000047, 0.000063555, 0.0000094, 0.000035667, 0.0000015, 243, 262.5, 0.0000092 },
32
	{ 4433619.49, 0.0000053, 0.00000755, 0.0000047, 0.000063555, 0.0000105, 0.000036407, 0.0000015, 243, 262.5, 0.0000092 }
33
};
34
35
36
static const double pll_base = 13.5e6;
37
38
xbox_encoder_type tv_get_video_encoder(void) {
39
	unsigned char b = 0;
40
	
41
	b = conexant_i2c_read_reg(0x00);
42
	if(b != 255) {
43
		return ENCODER_CONEXANT;
44
	}
45
	b = focus_i2c_read_reg(0x00);
46
	if(b != 255) {
47
		return ENCODER_FOCUS;
48
	}
49
	b = xlb_i2c_read_reg(0x01);
50
	if(b != 255) {
51
		return ENCODER_XLB;
52
	}
53
	return 0;
54
}
55
56
int tv_init(void) {
57
	return tv_i2c_init();
58
}
59
60
void tv_exit(void) {
61
	tv_i2c_exit();
62
}
63
64
void tv_load_mode(unsigned char * mode) {
65
	int n, n1;
66
	unsigned char b;
67
	unsigned char data[4];
68
	
69
	switch (tv_get_video_encoder()) {
70
		case ENCODER_CONEXANT:
71
			conexant_i2c_write_reg(0xc4, 0x00); // EN_OUT = 1
72
			// Conexant init (starts at register 0x2e)
73
			n1=0;
74
			for(n=0x2e;n<0x100;n+=2) {
75
				switch(n) {
76
					case 0x6c: // reset
77
						conexant_i2c_write_reg(n, mode[n1] & 0x7f);
78
						break;
79
					case 0xc4: // EN_OUT
80
						conexant_i2c_write_reg(n, mode[n1] & 0xfe);
81
						break;
82
					case 0xb8: // autoconfig
83
						break;
84
	
85
					default:
86
						conexant_i2c_write_reg(n, mode[n1]);
87
						break;
88
				}
89
				n1++;
90
			}
91
			// Timing Reset
92
			b=conexant_i2c_read_reg(0x6c) & (0x7f);
93
			conexant_i2c_write_reg(0x6c, 0x80|b);
94
			b=conexant_i2c_read_reg(0xc4) & (0xfe);
95
			conexant_i2c_write_reg(0xc4, 0x01|b); // EN_OUT = 1
96
		
97
			/*
98
			conexant_i2c_write_reg(0xA8, (0xD9/1.3));
99
			conexant_i2c_write_reg(0xAA, (0x9A/1.3));
100
			conexant_i2c_write_reg(0xAC, (0xA4/1.3));
101
			*/
102
		
103
			conexant_i2c_write_reg(0xA8, 0x81);
104
			conexant_i2c_write_reg(0xAA, 0x49);
105
			conexant_i2c_write_reg(0xAC, 0x8C);
106
			break;
107
			
108
		case ENCODER_FOCUS:
109
			//Set the command register soft reset
110
			focus_i2c_write_reg(0x0c,0x03);
111
			focus_i2c_write_reg(0x0d,0x21);
112
		
113
			for (n = 0; n<0xc4; n++) {
114
				focus_i2c_write_reg(n,mode[n]);
115
			}
116
			//Clear soft reset flag
117
			b = focus_i2c_read_reg(0x0c);
118
			b &= ~0x01;
119
			focus_i2c_write_reg(0x0c,b);
120
			b = focus_i2c_read_reg(0x0d);
121
			focus_i2c_write_reg(0x0d,b);
122
			break;
123
124
		case ENCODER_XLB:
125
			switch(get_tv_encoding()) {
126
				case TV_ENC_PALBDGHI:
127
					for(n = 0; n < sizeof(xlb_regs); n++) {
128
						memset(data, 0x00, 0x04);
129
						memcpy(data, &XCal_Vals_PAL[n], 0x04);
130
						xlb_i2c_write_block(xlb_regs[n], data, 0x04);
131
					}
132
					break;
133
				case TV_ENC_NTSC:
134
				default:	// Default to NTSC
135
					for(n = 0; n < sizeof(xlb_regs); n++) {
136
						memset(data, 0x00, 0x04);
137
						memcpy(data, &XCal_Vals_NTSC[n], 0x04);
138
						xlb_i2c_write_block(xlb_regs[n], data, 0x04);
139
					}
140
					break;
141
			}
142
			break;
143
	}
144
}
145
146
void tv_save_mode(unsigned char * mode) {
147
	int n, n1;
148
	
149
	switch (tv_get_video_encoder()) {
150
		case ENCODER_CONEXANT:
151
			// Conexant init (starts at register 0x2e)
152
			n1=0;
153
			for(n=0x2e;n<0x100;n+=2) {
154
				mode[n1] = conexant_i2c_read_reg(n);
155
				n1++;
156
			}
157
			break;
158
		case ENCODER_FOCUS:
159
			for (n=0;n<0xc4;n++) {
160
				mode[n] = focus_i2c_read_reg(n);
161
			}
162
			break;
163
	 	case ENCODER_XLB:
164
			break;
165
	}
166
}
167
168
xbox_tv_encoding get_tv_encoding(void) {
169
	unsigned char eeprom_value;
170
	xbox_tv_encoding enc = TV_ENC_PALBDGHI;
171
	eeprom_value = eeprom_i2c_read(0x5a);
172
//	if (eeprom_value == 0x40) {
173
	if (eeprom_value == 0x80) {
174
		enc = TV_ENC_PALBDGHI;
175
	}
176
	else {
177
		enc = TV_ENC_NTSC;
178
	}
179
	return enc;
180
}
181
182
xbox_av_type detect_av_type(void) {
183
	xbox_av_type avType;
184
	switch (pic_i2c_read_reg(0x04)) {
185
		case 0: avType = AV_SCART_RGB; break;
186
		case 1: avType = AV_HDTV; break;
187
		case 2: avType = AV_VGA_SOG; break;
188
		case 4: avType = AV_SVIDEO; break;
189
		case 6: avType = AV_COMPOSITE; break;
190
		case 7: avType = AV_VGA; break;
191
		default: avType = AV_COMPOSITE; break;
192
	}
193
	return avType;
194
}
195
(-)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 (+2635 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
static const struct riva_regs xlbRegs[] = {
374
{
375
	{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,	/* ATTR */
376
	 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
377
	 0x41, 0x01, 0x0F, 0x00, 0x00},
378
	 
379
	{0x5d ,0x4f ,0x4f ,0x9c ,0x54 ,0x35 ,0x0b ,0x3e ,0x00 ,0x40 , // NTSC
380
	0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0xe9 ,0x0e ,0xdf ,0x40 ,
381
	0x00 ,0xdf ,0x0c ,0xe3 ,0xff ,0x30 ,0x3a ,0x05 ,0x00 ,0x00 ,
382
	0x00 ,0x03 ,0x29 ,0xfe ,0x9b ,0xa1 ,0x80 ,0x10 ,0x14 ,0xd3 ,
383
	0x83 ,0x00 ,0x00 ,0x7d ,0x9c ,0xe0 ,0x00 ,0x00 ,0x00 ,0x00 ,
384
	0x00 ,0x11 ,0x02 ,0x02 ,0x21 ,0x30 ,0x00 ,0xff ,0xf3 ,0xdf ,
385
	0xef ,0x00 ,0x23 ,0x30 ,0x00 ,
386
	},
387
	
388
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,	/* GRA  */
389
	 0xFF},
390
	{0x03, 0x01, 0x0F, 0x00, 0x0E},				/* SEQ  */
391
	0xEB							/* MISC */
392
},
393
{
394
	{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,	/* ATTR */
395
	 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
396
	 0x41, 0x01, 0x0F, 0x00, 0x00},
397
398
	 {0x5f ,0x4f ,0x4f ,0x80 ,0x55 ,0xb9 ,0x06 ,0x3e ,0x00 ,0x40 ,	//PAL
399
	0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0xeb ,0x0e ,0xdf ,0x40 ,
400
	0x00 ,0xdf ,0x0c ,0xe3 ,0xff ,0x30 ,0x3a ,0x05 ,0x00 ,0x00 ,
401
	0x00 ,0x03 ,0x29 ,0xfe ,0xdb ,0xa1 ,0x00 ,0x10 ,0x20 ,0xd3 ,
402
	0x83 ,0x00 ,0x00 ,0x7d ,0x9c ,0xe0 ,0x00 ,0x00 ,0x00 ,0x00 ,
403
	0x00 ,0x11 ,0x02 ,0x02 ,0x21 ,0x30 ,0x00 ,0xff ,0xf3 ,0xcf ,
404
	0xef ,0x00 ,0x23 ,0x30 ,0x00 ,
405
	 },
406
407
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,	/* GRA  */
408
	 0xFF},
409
	{0x03, 0x01, 0x0F, 0x00, 0x0E},				/* SEQ  */
410
	0xEB							/* MISC */
411
}
412
};
413
414
/* ------------------------------------------------------------------------- *
415
 *
416
 * MMIO access macros
417
 *
418
 * ------------------------------------------------------------------------- */
419
420
static inline void CRTCout(struct rivafb_info *rinfo, unsigned char index,
421
			   unsigned char val)
422
{
423
	VGA_WR08(rinfo->riva.PCIO, 0x3d4, index);
424
	VGA_WR08(rinfo->riva.PCIO, 0x3d5, val);
425
}
426
427
static inline unsigned char CRTCin(struct rivafb_info *rinfo,
428
				   unsigned char index)
429
{
430
	VGA_WR08(rinfo->riva.PCIO, 0x3d4, index);
431
	return (VGA_RD08(rinfo->riva.PCIO, 0x3d5));
432
}
433
434
static inline void GRAout(struct rivafb_info *rinfo, unsigned char index,
435
			  unsigned char val)
436
{
437
	VGA_WR08(rinfo->riva.PVIO, 0x3ce, index);
438
	VGA_WR08(rinfo->riva.PVIO, 0x3cf, val);
439
}
440
441
static inline unsigned char GRAin(struct rivafb_info *rinfo,
442
				  unsigned char index)
443
{
444
	VGA_WR08(rinfo->riva.PVIO, 0x3ce, index);
445
	return (VGA_RD08(rinfo->riva.PVIO, 0x3cf));
446
}
447
448
static inline void SEQout(struct rivafb_info *rinfo, unsigned char index,
449
			  unsigned char val)
450
{
451
	VGA_WR08(rinfo->riva.PVIO, 0x3c4, index);
452
	VGA_WR08(rinfo->riva.PVIO, 0x3c5, val);
453
}
454
455
static inline unsigned char SEQin(struct rivafb_info *rinfo,
456
				  unsigned char index)
457
{
458
	VGA_WR08(rinfo->riva.PVIO, 0x3c4, index);
459
	return (VGA_RD08(rinfo->riva.PVIO, 0x3c5));
460
}
461
462
static inline void ATTRout(struct rivafb_info *rinfo, unsigned char index,
463
			   unsigned char val)
464
{
465
	VGA_WR08(rinfo->riva.PCIO, 0x3c0, index);
466
	VGA_WR08(rinfo->riva.PCIO, 0x3c0, val);
467
}
468
469
static inline unsigned char ATTRin(struct rivafb_info *rinfo,
470
				   unsigned char index)
471
{
472
	VGA_WR08(rinfo->riva.PCIO, 0x3c0, index);
473
	return (VGA_RD08(rinfo->riva.PCIO, 0x3c1));
474
}
475
476
static inline void MISCout(struct rivafb_info *rinfo, unsigned char val)
477
{
478
	VGA_WR08(rinfo->riva.PVIO, 0x3c2, val);
479
}
480
481
static inline unsigned char MISCin(struct rivafb_info *rinfo)
482
{
483
	return (VGA_RD08(rinfo->riva.PVIO, 0x3cc));
484
}
485
486
487
488
/* ------------------------------------------------------------------------- *
489
 *
490
 * cursor stuff
491
 *
492
 * ------------------------------------------------------------------------- */
493
494
/**
495
 * riva_cursor_timer_handler - blink timer
496
 * @dev_addr: pointer to rivafb_info object containing info for current riva board
497
 *
498
 * DESCRIPTION:
499
 * Cursor blink timer.
500
 */
501
static void riva_cursor_timer_handler(unsigned long dev_addr)
502
{
503
	struct rivafb_info *rinfo = (struct rivafb_info *)dev_addr;
504
505
	if (!rinfo->cursor) return;
506
507
	if (!rinfo->cursor->enable) goto out;
508
509
	if (rinfo->cursor->last_move_delay < 1000)
510
		rinfo->cursor->last_move_delay++;
511
512
	if (rinfo->cursor->vbl_cnt && --rinfo->cursor->vbl_cnt == 0) {
513
		rinfo->cursor->on ^= 1;
514
		if (rinfo->cursor->on)
515
			*(rinfo->riva.CURSORPOS) = (rinfo->cursor->pos.x & 0xFFFF)
516
						   | (rinfo->cursor->pos.y << 16);
517
		rinfo->riva.ShowHideCursor(&rinfo->riva, rinfo->cursor->on);
518
		if (!noblink)
519
			rinfo->cursor->vbl_cnt = rinfo->cursor->blink_rate;
520
	}
521
out:
522
	rinfo->cursor->timer->expires = jiffies + (HZ / 100);
523
	add_timer(rinfo->cursor->timer);
524
}
525
526
/**
527
 * rivafb_init_cursor - allocates cursor structure and starts blink timer
528
 * @rinfo: pointer to rivafb_info object containing info for current riva board
529
 *
530
 * DESCRIPTION:
531
 * Allocates cursor structure and starts blink timer.
532
 *
533
 * RETURNS:
534
 * Pointer to allocated cursor structure.
535
 *
536
 * CALLED FROM:
537
 * rivafb_init_one()
538
 */
539
static struct riva_cursor * __init rivafb_init_cursor(struct rivafb_info *rinfo)
540
{
541
	struct riva_cursor *cursor;
542
543
	cursor = kmalloc(sizeof(struct riva_cursor), GFP_KERNEL);
544
	if (!cursor) return 0;
545
	memset(cursor, 0, sizeof(*cursor));
546
547
	cursor->timer = kmalloc(sizeof(*cursor->timer), GFP_KERNEL);
548
	if (!cursor->timer) {
549
		kfree(cursor);
550
		return 0;
551
	}
552
	memset(cursor->timer, 0, sizeof(*cursor->timer));
553
554
	cursor->blink_rate = DEFAULT_CURSOR_BLINK_RATE;
555
556
	init_timer(cursor->timer);
557
	cursor->timer->expires = jiffies + (HZ / 100);
558
	cursor->timer->data = (unsigned long)rinfo;
559
	cursor->timer->function = riva_cursor_timer_handler;
560
	add_timer(cursor->timer);
561
562
	return cursor;
563
}
564
565
/**
566
 * rivafb_exit_cursor - stops blink timer and releases cursor structure
567
 * @rinfo: pointer to rivafb_info object containing info for current riva board
568
 *
569
 * DESCRIPTION:
570
 * Stops blink timer and releases cursor structure.
571
 *
572
 * CALLED FROM:
573
 * rivafb_init_one()
574
 * rivafb_remove_one()
575
 */
576
static void rivafb_exit_cursor(struct rivafb_info *rinfo)
577
{
578
	struct riva_cursor *cursor = rinfo->cursor;
579
580
	if (cursor) {
581
		if (cursor->timer) {
582
			del_timer_sync(cursor->timer);
583
			kfree(cursor->timer);
584
		}
585
		kfree(cursor);
586
		rinfo->cursor = 0;
587
	}
588
}
589
590
/**
591
 * rivafb_download_cursor - writes cursor shape into card registers
592
 * @rinfo: pointer to rivafb_info object containing info for current riva board
593
 *
594
 * DESCRIPTION:
595
 * Writes cursor shape into card registers.
596
 *
597
 * CALLED FROM:
598
 * riva_load_video_mode()
599
 */
600
static void rivafb_download_cursor(struct rivafb_info *rinfo)
601
{
602
	int i, save;
603
	int *image;
604
	
605
	if (!rinfo->cursor) return;
606
607
	image = (int *)rinfo->cursor->image;
608
	save = rinfo->riva.ShowHideCursor(&rinfo->riva, 0);
609
	for (i = 0; i < (MAX_CURS*MAX_CURS*2)/sizeof(int); i++)
610
		writel(image[i], rinfo->riva.CURSOR + i);
611
612
	rinfo->riva.ShowHideCursor(&rinfo->riva, save);
613
}
614
615
/**
616
 * rivafb_create_cursor - sets rectangular cursor
617
 * @rinfo: pointer to rivafb_info object containing info for current riva board
618
 * @width: cursor width in pixels
619
 * @height: cursor height in pixels
620
 *
621
 * DESCRIPTION:
622
 * Sets rectangular cursor.
623
 *
624
 * CALLED FROM:
625
 * rivafb_set_font()
626
 * rivafb_set_var()
627
 */
628
static void rivafb_create_cursor(struct rivafb_info *rinfo, int width, int height)
629
{
630
	struct riva_cursor *c = rinfo->cursor;
631
	int i, j, idx;
632
633
	if (c) {
634
		if (width <= 0 || height <= 0) {
635
			width = 8;
636
			height = 16;
637
		}
638
		if (width > MAX_CURS) width = MAX_CURS;
639
		if (height > MAX_CURS) height = MAX_CURS;
640
641
		c->size.x = width;
642
		c->size.y = height;
643
		
644
		idx = 0;
645
646
		for (i = 0; i < height; i++) {
647
			for (j = 0; j < width; j++,idx++)
648
				c->image[idx] = CURSOR_COLOR;
649
			for (j = width; j < MAX_CURS; j++,idx++)
650
				c->image[idx] = TRANSPARENT_COLOR;
651
		}
652
		for (i = height; i < MAX_CURS; i++)
653
			for (j = 0; j < MAX_CURS; j++,idx++)
654
				c->image[idx] = TRANSPARENT_COLOR;
655
	}
656
}
657
658
/**
659
 * rivafb_set_font - change font size
660
 * @p: pointer to display object
661
 * @width: font width in pixels
662
 * @height: font height in pixels
663
 *
664
 * DESCRIPTION:
665
 * Callback function called if font settings changed.
666
 *
667
 * RETURNS:
668
 * 1 (Always succeeds.)
669
 */
670
static int rivafb_set_font(struct display *p, int width, int height)
671
{
672
	struct rivafb_info *fb = (struct rivafb_info *)(p->fb_info);
673
674
	rivafb_create_cursor(fb, width, height);
675
	return 1;
676
}
677
678
/**
679
 * rivafb_cursor - cursor handler
680
 * @p: pointer to display object
681
 * @mode: cursor mode (see CM_*)
682
 * @x: cursor x coordinate in characters
683
 * @y: cursor y coordinate in characters
684
 *
685
 * DESCRIPTION:
686
 * Cursor handler.
687
 */
688
static void rivafb_cursor(struct display *p, int mode, int x, int y)
689
{
690
	struct rivafb_info *rinfo = (struct rivafb_info *)(p->fb_info);
691
	struct riva_cursor *c = rinfo->cursor;
692
693
	if (!c)	return;
694
695
	x = x * fontwidth(p) - p->var.xoffset;
696
	y = y * fontheight(p) - p->var.yoffset;
697
698
	if (c->pos.x == x && c->pos.y == y && (mode == CM_ERASE) == !c->enable)
699
		return;
700
701
	c->enable = 0;
702
	if (c->on) rinfo->riva.ShowHideCursor(&rinfo->riva, 0);
703
704
	c->pos.x = x;
705
	c->pos.y = y;
706
707
	switch (mode) {
708
	case CM_ERASE:
709
		c->on = 0;
710
		break;
711
	case CM_DRAW:
712
	case CM_MOVE:
713
		if (c->last_move_delay <= 1) { /* rapid cursor movement */
714
			c->vbl_cnt = CURSOR_SHOW_DELAY;
715
		} else {
716
			*(rinfo->riva.CURSORPOS) = (x & 0xFFFF) | (y << 16);
717
			rinfo->riva.ShowHideCursor(&rinfo->riva, 1);
718
			if (!noblink) c->vbl_cnt = CURSOR_HIDE_DELAY;
719
			c->on = 1;
720
		}
721
		c->last_move_delay = 0;
722
		c->enable = 1;
723
		break;
724
	}
725
}
726
727
728
729
/* ------------------------------------------------------------------------- *
730
 *
731
 * general utility functions
732
 *
733
 * ------------------------------------------------------------------------- */
734
735
/**
736
 * riva_set_dispsw - sets dispsw
737
 * @rinfo: pointer to internal driver struct for a given Riva card
738
 * @disp: pointer to display object
739
 *
740
  DESCRIPTION:
741
 * Sets up console low level operations depending on the current? color depth
742
 * of the display.
743
 *
744
 * CALLED FROM:
745
 * rivafb_set_var()
746
 * rivafb_switch()
747
 * riva_init_disp()
748
 */
749
static void riva_set_dispsw(struct rivafb_info *rinfo, struct display *disp)
750
{
751
	int accel = disp->var.accel_flags & FB_ACCELF_TEXT;
752
753
	DPRINTK("ENTER\n");
754
755
	assert(rinfo != NULL);
756
757
	disp->dispsw_data = NULL;
758
759
	disp->screen_base = rinfo->fb_base;
760
	disp->type = FB_TYPE_PACKED_PIXELS;
761
	disp->type_aux = 0;
762
	disp->ypanstep = 1;
763
	disp->ywrapstep = 0;
764
	disp->can_soft_blank = 1;
765
	disp->inverse = 0;
766
767
	switch (disp->var.bits_per_pixel) {
768
#ifdef FBCON_HAS_CFB8
769
	case 8:
770
		rinfo->dispsw = accel ? fbcon_riva8 : fbcon_cfb8;
771
		disp->dispsw = &rinfo->dispsw;
772
		disp->line_length = disp->var.xres_virtual;
773
		disp->visual = FB_VISUAL_PSEUDOCOLOR;
774
		break;
775
#endif
776
#ifdef FBCON_HAS_CFB16
777
	case 16:
778
		rinfo->dispsw = accel ? fbcon_riva16 : fbcon_cfb16;
779
		disp->dispsw_data = &rinfo->con_cmap.cfb16;
780
		disp->dispsw = &rinfo->dispsw;
781
		disp->line_length = disp->var.xres_virtual * 2;
782
		disp->visual = FB_VISUAL_DIRECTCOLOR;
783
		break;
784
#endif
785
#ifdef FBCON_HAS_CFB32
786
	case 32:
787
		rinfo->dispsw = accel ? fbcon_riva32 : fbcon_cfb32;
788
		disp->dispsw_data = rinfo->con_cmap.cfb32;
789
		disp->dispsw = &rinfo->dispsw;
790
		disp->line_length = disp->var.xres_virtual * 4;
791
		disp->visual = FB_VISUAL_DIRECTCOLOR;
792
		break;
793
#endif
794
	default:
795
		DPRINTK("Setting fbcon_dummy renderer\n");
796
		rinfo->dispsw = fbcon_dummy;
797
		disp->dispsw = &rinfo->dispsw;
798
	}
799
800
	/* FIXME: verify that the above code sets dsp->* fields correctly */
801
802
	if (rinfo->cursor) {
803
		rinfo->dispsw.cursor = rivafb_cursor;
804
		rinfo->dispsw.set_font = rivafb_set_font;
805
	}
806
807
	DPRINTK("EXIT\n");
808
}
809
810
/**
811
 * riva_wclut - set CLUT entry
812
 * @chip: pointer to RIVA_HW_INST object
813
 * @regnum: register number
814
 * @red: red component
815
 * @green: green component
816
 * @blue: blue component
817
 *
818
 * DESCRIPTION:
819
 * Sets color register @regnum.
820
 *
821
 * CALLED FROM:
822
 * riva_setcolreg()
823
 */
824
static void riva_wclut(RIVA_HW_INST *chip,
825
		       unsigned char regnum, unsigned char red,
826
		       unsigned char green, unsigned char blue)
827
{
828
	VGA_WR08(chip->PDIO, 0x3c8, regnum);
829
	VGA_WR08(chip->PDIO, 0x3c9, red);
830
	VGA_WR08(chip->PDIO, 0x3c9, green);
831
	VGA_WR08(chip->PDIO, 0x3c9, blue);
832
}
833
834
/**
835
 * riva_save_state - saves current chip state
836
 * @rinfo: pointer to rivafb_info object containing info for current riva board
837
 * @regs: pointer to riva_regs object
838
 *
839
 * DESCRIPTION:
840
 * Saves current chip state to @regs.
841
 *
842
 * CALLED FROM:
843
 * rivafb_init_one()
844
 */
845
/* from GGI */
846
static void riva_save_state(struct rivafb_info *rinfo, struct riva_regs *regs)
847
{
848
	int i;
849
850
	rinfo->riva.LockUnlock(&rinfo->riva, 0);
851
852
	rinfo->riva.UnloadStateExt(&rinfo->riva, &regs->ext);
853
854
	regs->misc_output = MISCin(rinfo);
855
856
	for (i = 0; i < NUM_CRT_REGS; i++) {
857
		regs->crtc[i] = CRTCin(rinfo, i);
858
	}
859
860
	for (i = 0; i < NUM_ATC_REGS; i++) {
861
		regs->attr[i] = ATTRin(rinfo, i);
862
	}
863
864
	for (i = 0; i < NUM_GRC_REGS; i++) {
865
		regs->gra[i] = GRAin(rinfo, i);
866
	}
867
868
	for (i = 0; i < NUM_SEQ_REGS; i++) {
869
		regs->seq[i] = SEQin(rinfo, i);
870
	}
871
	tv_save_mode(regs->encoder_mode);
872
}
873
874
/**
875
 * riva_load_state - loads current chip state
876
 * @rinfo: pointer to rivafb_info object containing info for current riva board
877
 * @regs: pointer to riva_regs object
878
 *
879
 * DESCRIPTION:
880
 * Loads chip state from @regs.
881
 *
882
 * CALLED FROM:
883
 * riva_load_video_mode()
884
 * rivafb_init_one()
885
 * rivafb_remove_one()
886
 */
887
/* from GGI */
888
static void riva_load_state(struct rivafb_info *rinfo, struct riva_regs *regs)
889
{
890
	int i;
891
	RIVA_HW_STATE *state = &regs->ext;
892
893
	CRTCout(rinfo, 0x11, 0x00);
894
895
	rinfo->riva.LockUnlock(&rinfo->riva, 0);
896
897
	rinfo->riva.LoadStateExt(&rinfo->riva, state);
898
899
	rinfo->riva.PCRTC[0x00000800/4] = rinfo->riva_fb_start; 
900
	rinfo->riva.PGRAPH[0x00000820/4] = rinfo->riva_fb_start;
901
	rinfo->riva.PGRAPH[0x00000824/4] = rinfo->riva_fb_start;
902
	rinfo->riva.PGRAPH[0x00000828/4] = rinfo->riva_fb_start;
903
	rinfo->riva.PGRAPH[0x0000082c/4] = rinfo->riva_fb_start;
904
905
	rinfo->riva.PGRAPH[0x00000684/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
906
	rinfo->riva.PGRAPH[0x00000688/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
907
	rinfo->riva.PGRAPH[0x0000068c/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
908
	rinfo->riva.PGRAPH[0x00000690/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
909
	rinfo->riva.PRAMDAC[0x00000848/4] = 0x10100111;
910
	if(rinfo->video_encoder == ENCODER_XLB) {
911
		rinfo->riva.PRAMDAC[0x00000880/4] = 0x21101100;
912
	} else {
913
		rinfo->riva.PRAMDAC[0x00000880/4] = 0;
914
	}
915
	rinfo->riva.PRAMDAC[0x000008a0/4] = 0;
916
	rinfo->riva.PMC[0x00008908/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
917
	rinfo->riva.PMC[0x0000890c/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
918
	/* It has been decided to leave the GPU in RGB mode always, and handle
919
	 * the scaling in the encoder, if necessary. This sidesteps the 2.6 
920
	 * kernel cursor issue seen with YUV output */
921
	if(rinfo->video_encoder == ENCODER_XLB) {
922
		rinfo->riva.PRAMDAC[0x00000630/4] = 2; // switch GPU to YCrCb
923
		/* YUV values: */
924
		rinfo->riva.PRAMDAC[0x0000084c/4] = 0x00801080;
925
		rinfo->riva.PRAMDAC[0x000008c4/4] = 0x40801080;
926
	} else {
927
		rinfo->riva.PRAMDAC[0x00000630/4] = 0;
928
		/* These two need to be 0 on RGB to fix the maroon 
929
		 * borders issue */
930
		rinfo->riva.PRAMDAC[0x0000084c/4] = 0;
931
		rinfo->riva.PRAMDAC[0x000008c4/4] = 0;
932
	}
933
934
	MISCout(rinfo, regs->misc_output);
935
936
	for (i = 0; i < NUM_CRT_REGS; i++) {
937
		switch (i) {
938
		case 0x0c:
939
		case 0x0d:
940
		case 0x19:
941
		case 0x20 ... 0x40:
942
			break;
943
		default:
944
			CRTCout(rinfo, i, regs->crtc[i]);
945
		}
946
	}
947
948
	for (i = 0; i < NUM_ATC_REGS; i++) {
949
		ATTRout(rinfo, i, regs->attr[i]);
950
	}
951
952
	for (i = 0; i < NUM_GRC_REGS; i++) {
953
		GRAout(rinfo, i, regs->gra[i]);
954
	}
955
956
	for (i = 0; i < NUM_SEQ_REGS; i++) {
957
		SEQout(rinfo, i, regs->seq[i]);
958
	}
959
}
960
961
static inline unsigned long xbox_memory_size(void) {
962
	/* make a guess on the xbox memory size. There are just
963
	   two possibilities */
964
	if ((num_physpages << PAGE_SHIFT) > 64*1024*1024) {
965
		return 128*1024*1024;
966
	} else {
967
		return 64*1024*1024;
968
	}
969
}
970
971
static inline unsigned long available_framebuffer_memory(void) {
972
	return xbox_memory_size() - (num_physpages << PAGE_SHIFT);
973
}
974
975
/**
976
 * xbox_load_video_mode - calculate timings for Xbox
977
 * @rinfo: pointer to rivafb_info object containing info for current riva board
978
 * @video_mode: video mode to set
979
 *
980
 * DESCRIPTION:
981
 * Calculate some timings and then send em off to riva_load_state().
982
 *
983
 * CALLED FROM:
984
 * rivafb_set_var()
985
 */
986
static void xbox_load_video_mode(struct rivafb_info *rinfo,
987
				 struct fb_var_screeninfo *video_mode)
988
{
989
	struct riva_regs newmode;
990
	int bpp, width, hDisplaySize, crtc_hDisplay, crtc_hStart,
991
	    crtc_hEnd, crtc_hTotal, height, crtc_vDisplay, crtc_vStart,
992
		crtc_vEnd, crtc_vTotal, dotClock,
993
		hStart, hTotal, vStart, vTotal;
994
	int crtc_hBlankStart, crtc_hBlankEnd, crtc_vBlankStart, crtc_vBlankEnd;
995
	int encoder_ok = 0;
996
997
	/* time to calculate */
998
	bpp = video_mode->bits_per_pixel;
999
	if (bpp == 16 && video_mode->green.length == 5)
1000
		bpp = 15;
1001
	dotClock = 1000000000 / video_mode->pixclock;
1002
	hDisplaySize = video_mode->xres;
1003
	hStart = hDisplaySize + video_mode->right_margin;
1004
	hTotal = hDisplaySize + video_mode->right_margin +
1005
		  video_mode->hsync_len + video_mode->left_margin;
1006
	vStart = video_mode->yres + video_mode->lower_margin;
1007
	vTotal = video_mode->yres + video_mode->lower_margin +
1008
		 video_mode->vsync_len + video_mode->upper_margin;
1009
1010
	rivafb_blank(1, (struct fb_info *)rinfo);
1011
	memcpy(&newmode, &reg_template, sizeof(struct riva_regs));
1012
1013
	width = video_mode->xres_virtual;
1014
	height = video_mode->yres_virtual;
1015
1016
	crtc_hDisplay = (hDisplaySize / 8) - 1;
1017
	crtc_hStart = (hTotal - 32) / 8;
1018
	crtc_hEnd = crtc_hStart + 1;
1019
	crtc_hTotal = (hTotal) / 8 - 5;
1020
	crtc_hBlankStart = crtc_hDisplay;
1021
	crtc_hBlankEnd = crtc_hTotal + 4;
1022
	
1023
	crtc_vDisplay = video_mode->yres - 1;
1024
	crtc_vStart = vStart;
1025
	crtc_vEnd = crtc_vStart + 2;
1026
	crtc_vTotal = vTotal + 2;
1027
	crtc_vBlankStart = crtc_vDisplay;
1028
	crtc_vBlankEnd = crtc_vTotal + 1;
1029
1030
	if ((video_mode->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
1031
		crtc_vTotal |= 1;
1032
1033
	newmode.ext.bpp = bpp;
1034
	newmode.ext.fb_start = rinfo->riva_fb_start;
1035
1036
	/* time to calculate */
1037
	if((rinfo->av_type == AV_VGA) || (rinfo->av_type == AV_VGA_SOG) || (rinfo->av_type == AV_HDTV)) {
1038
		if (rinfo->av_type == AV_HDTV) {
1039
			xbox_hdtv_mode hdtv_mode = HDTV_480p;
1040
			if (video_mode->yres > 800) {
1041
				hdtv_mode = HDTV_1080i;
1042
				crtc_vStart = vStart + 31;
1043
				crtc_vEnd = crtc_vStart + 2;
1044
			}
1045
			else if (video_mode->yres > 600) {
1046
				hdtv_mode = HDTV_720p;
1047
			}
1048
			switch (rinfo->video_encoder) {
1049
				case ENCODER_CONEXANT:
1050
					encoder_ok = conexant_calc_hdtv_mode(hdtv_mode, dotClock, newmode.encoder_mode);
1051
					break;
1052
				case ENCODER_FOCUS:
1053
					encoder_ok = focus_calc_hdtv_mode(hdtv_mode, dotClock, newmode.encoder_mode);
1054
					break;
1055
				case ENCODER_XLB:
1056
					encoder_ok = xlb_calc_hdtv_mode(hdtv_mode, dotClock, newmode.encoder_mode);	
1057
					break;
1058
				default:
1059
					printk("Error - unknown encoder type detected\n");
1060
			}
1061
		}
1062
		else {
1063
			switch (rinfo->video_encoder) {
1064
				case ENCODER_CONEXANT:
1065
					encoder_ok = conexant_calc_vga_mode(rinfo->av_type, dotClock, newmode.encoder_mode);
1066
					break;
1067
				case ENCODER_FOCUS:
1068
					//No vga functions as yet - so set up for 480p otherwise we dont boot at all. 
1069
					encoder_ok = focus_calc_hdtv_mode(HDTV_480p, dotClock, newmode.encoder_mode);
1070
					break;
1071
				case ENCODER_XLB:
1072
					encoder_ok = xlb_calc_hdtv_mode(HDTV_480p, dotClock, newmode.encoder_mode);
1073
					break;
1074
				default:
1075
					printk("Error - unknown encoder type detected\n");
1076
			}
1077
		}
1078
		newmode.ext.vend = video_mode->yres - 1;
1079
		newmode.ext.vtotal = vTotal;
1080
		newmode.ext.vcrtc = video_mode->yres - 1;
1081
		newmode.ext.vsyncstart = vStart;
1082
		newmode.ext.vsyncend = vStart + 3;
1083
		newmode.ext.vvalidstart = 0;
1084
		newmode.ext.vvalidend = video_mode->yres - 1;
1085
		newmode.ext.hend = video_mode->xres - 1;
1086
		newmode.ext.htotal = hTotal;
1087
		newmode.ext.hcrtc = video_mode->xres - 1;
1088
		newmode.ext.hsyncstart = hStart;
1089
		newmode.ext.hsyncend = hStart + 32;
1090
		newmode.ext.hvalidstart = 0;
1091
		newmode.ext.hvalidend = video_mode->xres - 1;
1092
	}
1093
1094
	/* Normal composite */
1095
	else {
1096
		xbox_video_mode encoder_mode;
1097
		encoder_mode.xres = video_mode->xres;
1098
		encoder_mode.yres = video_mode->yres;
1099
		encoder_mode.tv_encoding = rinfo->tv_encoding;
1100
		encoder_mode.bpp = bpp;
1101
		encoder_mode.hoc = rinfo->hoc;
1102
		encoder_mode.voc = rinfo->voc;
1103
		encoder_mode.av_type = rinfo->av_type;
1104
		encoder_mode.tv_encoding = rinfo->tv_encoding;
1105
		
1106
		switch (rinfo->video_encoder) {
1107
			case ENCODER_CONEXANT:
1108
				encoder_ok = conexant_calc_mode(&encoder_mode, &newmode);
1109
				break;
1110
			case ENCODER_FOCUS:
1111
				encoder_ok = focus_calc_mode(&encoder_mode, &newmode);
1112
				break;
1113
			case ENCODER_XLB:
1114
				switch(rinfo->tv_encoding) {
1115
					case TV_ENC_PALBDGHI:
1116
						rinfo->current_state = xlbRegs[1];
1117
						memcpy(&newmode, &xlbRegs[1], sizeof(struct riva_regs));
1118
						break;
1119
					case TV_ENC_NTSC:
1120
					default:	// Default to NTSC
1121
						rinfo->current_state = xlbRegs[0];
1122
						memcpy(&newmode, &xlbRegs[0], sizeof(struct riva_regs));
1123
						break;
1124
				}
1125
				encoder_ok = xlb_calc_mode(&encoder_mode, &newmode, rinfo->tv_encoding);
1126
				break;
1127
			default:
1128
				printk("Error - unknown encoder type detected\n");
1129
		}
1130
		if((rinfo->video_encoder == ENCODER_CONEXANT) || (rinfo->video_encoder == ENCODER_FOCUS)) {
1131
			crtc_hDisplay = (newmode.ext.crtchdispend / 8) - 1;
1132
			crtc_hStart = (newmode.ext.htotal - 32) / 8;
1133
			crtc_hEnd = crtc_hStart + 1;
1134
			crtc_hTotal = (newmode.ext.htotal) / 8 - 1;
1135
			crtc_hBlankStart = crtc_hDisplay;
1136
			crtc_hBlankEnd = (newmode.ext.htotal) / 8 - 1;
1137
			
1138
			crtc_vDisplay = video_mode->yres - 1;
1139
			crtc_vStart = newmode.ext.crtcvstart;
1140
			crtc_vEnd = newmode.ext.crtcvstart + 3;
1141
			crtc_vTotal = newmode.ext.crtcvtotal;
1142
			crtc_vBlankStart = crtc_vDisplay;
1143
			crtc_vBlankEnd = crtc_vTotal + 1;
1144
		}
1145
		if(rinfo->video_encoder == ENCODER_XLB) {
1146
			crtc_hTotal = Set8Bits(newmode.crtc[0x00])
1147
				| SetBitField(newmode.crtc[0x2d],0:0,8:8);
1148
			crtc_hDisplay = Set8Bits(newmode.crtc[0x01])
1149
				| SetBitField(newmode.crtc[0x2d],1:1,8:8);
1150
			crtc_hBlankStart = Set8Bits(newmode.crtc[0x02])
1151
				| SetBitField(newmode.crtc[0x2d],2:2,8:8);
1152
			crtc_hBlankEnd = SetBitField(newmode.crtc[0x03],4:0,4:0)
1153
				| SetBitField(newmode.crtc[0x05],7:7,5:5)
1154
				| SetBitField(newmode.crtc[0x25],4:4,6:6);
1155
			crtc_hStart = Set8Bits(newmode.crtc[0x04])
1156
				| SetBitField(newmode.crtc[0x2d],3:3,8:8);
1157
			crtc_hEnd = SetBitField(newmode.crtc[0x05],4:0,4:0);
1158
			crtc_vTotal = Set8Bits(newmode.crtc[0x06])
1159
				| SetBitField(newmode.crtc[0x07],0:0,8:8)
1160
				| SetBitField(newmode.crtc[0x07],5:5,9:9)
1161
				| SetBitField(newmode.crtc[0x25],0:0,10:10);
1162
			crtc_vDisplay = Set8Bits(newmode.crtc[0x12])
1163
				| SetBitField(newmode.crtc[0x07],1:1,8:8)
1164
				| SetBitField(newmode.crtc[0x07],6:6,9:9)
1165
				| SetBitField(newmode.crtc[0x25],1:1,10:10);
1166
			crtc_vBlankStart = Set8Bits(newmode.crtc[0x15])
1167
				| SetBitField(newmode.crtc[0x07],3:3,8:8)
1168
				| SetBitField(newmode.crtc[0x09],5:5,9:9)
1169
				| SetBitField(newmode.crtc[0x25],3:3,10:10);
1170
			crtc_vBlankEnd = Set8Bits(newmode.crtc[0x16]);
1171
			crtc_vStart = Set8Bits(newmode.crtc[0x10])
1172
				| SetBitField(newmode.crtc[0x07],2:2,8:8)
1173
				| SetBitField(newmode.crtc[0x07],7:7,9:9)
1174
				| SetBitField(newmode.crtc[0x25],2:2,10:10);
1175
			crtc_vEnd = SetBitField(newmode.crtc[0x11],3:0,3:0);
1176
		}
1177
	}
1178
1179
	if (encoder_ok) {
1180
		newmode.crtc[0x0] = Set8Bits (crtc_hTotal);
1181
		newmode.crtc[0x1] = Set8Bits (crtc_hDisplay);
1182
		newmode.crtc[0x2] = Set8Bits (crtc_hBlankStart);
1183
		newmode.crtc[0x3] = SetBitField (crtc_hBlankEnd, 4: 0, 4:0) | SetBit (7);
1184
		newmode.crtc[0x4] = Set8Bits (crtc_hStart);
1185
		newmode.crtc[0x5] = SetBitField (crtc_hBlankEnd, 5: 5, 7:7)
1186
			| SetBitField (crtc_hEnd, 4: 0, 4:0);
1187
		newmode.crtc[0x6] = SetBitField (crtc_vTotal, 7: 0, 7:0);
1188
		newmode.crtc[0x7] = SetBitField (crtc_vTotal, 8: 8, 0:0)
1189
			| SetBitField (crtc_vDisplay, 8: 8, 1:1)
1190
			| SetBitField (crtc_vStart, 8: 8, 2:2)
1191
			| SetBitField (crtc_vBlankStart, 8: 8, 3:3)
1192
			| SetBit (4)
1193
			| SetBitField (crtc_vTotal, 9: 9, 5:5)
1194
			| SetBitField (crtc_vDisplay, 9: 9, 6:6)
1195
			| SetBitField (crtc_vStart, 9: 9, 7:7);
1196
		newmode.crtc[0x9] = SetBitField (crtc_vBlankStart, 9: 9, 5:5)
1197
			| SetBit (6);
1198
		newmode.crtc[0x10] = Set8Bits (crtc_vStart);
1199
		newmode.crtc[0x11] = SetBitField (crtc_vEnd, 3: 0, 3:0)
1200
			| SetBit (5);
1201
		newmode.crtc[0x12] = Set8Bits (crtc_vDisplay);
1202
		newmode.crtc[0x13] = ((width / 8) * ((bpp + 1) / 8)) & 0xFF;
1203
		newmode.crtc[0x15] = Set8Bits (crtc_vBlankStart);
1204
		newmode.crtc[0x16] = Set8Bits (crtc_vBlankEnd);
1205
		newmode.ext.screen = SetBitField(crtc_hBlankEnd,6:6,4:4)
1206
			| SetBitField(crtc_vBlankStart,10:10,3:3)
1207
			| SetBitField(crtc_vStart,10:10,2:2)
1208
			| SetBitField(crtc_vDisplay,10:10,1:1)
1209
			| SetBitField(crtc_vTotal,10:10,0:0);
1210
		newmode.ext.horiz  = SetBitField(crtc_hTotal,8:8,0:0) 
1211
			| SetBitField(crtc_hDisplay,8:8,1:1)
1212
			| SetBitField(crtc_hBlankStart,8:8,2:2)
1213
			| SetBitField(crtc_hStart,8:8,3:3);
1214
		newmode.ext.extra  = SetBitField(crtc_vTotal,11:11,0:0)
1215
			| SetBitField(crtc_vDisplay,11:11,2:2)
1216
			| SetBitField(crtc_vStart,11:11,4:4)
1217
			| SetBitField(crtc_vBlankStart,11:11,6:6); 
1218
1219
		if ((video_mode->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
1220
			int tmp = (crtc_hTotal >> 1) & ~1;
1221
			newmode.ext.interlace = Set8Bits(tmp);
1222
			newmode.ext.horiz |= SetBitField(tmp, 8:8,4:4);
1223
		} else 
1224
			newmode.ext.interlace = 0xff; /* interlace off */
1225
1226
		rinfo->riva.CalcStateExt(&rinfo->riva, &newmode.ext, bpp, width,
1227
					hDisplaySize, height, dotClock);
1228
		rinfo->current_state = newmode;
1229
		riva_load_state(rinfo, &rinfo->current_state);
1230
		tv_load_mode(newmode.encoder_mode);
1231
		rinfo->riva.LockUnlock(&rinfo->riva, 0); /* important for HW cursor */
1232
		rivafb_download_cursor(rinfo);
1233
	}
1234
	else {
1235
		printk("Error: Unable to set encoder resolution %dx%d\n",video_mode->xres, video_mode->yres);
1236
	}
1237
}
1238
/**
1239
 * riva_board_list_add - maintains board list
1240
 * @board_list: root node of list of boards
1241
 * @new_node: new node to be added
1242
 *
1243
 * DESCRIPTION:
1244
 * Adds @new_node to the list referenced by @board_list.
1245
 *
1246
 * RETURNS:
1247
 * New root node
1248
 *
1249
 * CALLED FROM:
1250
 * rivafb_init_one()
1251
 */
1252
static struct rivafb_info *riva_board_list_add(struct rivafb_info *board_list,
1253
					       struct rivafb_info *new_node)
1254
{
1255
	struct rivafb_info *i_p = board_list;
1256
1257
	new_node->next = NULL;
1258
1259
	if (board_list == NULL)
1260
		return new_node;
1261
1262
	while (i_p->next != NULL)
1263
		i_p = i_p->next;
1264
	i_p->next = new_node;
1265
1266
	return board_list;
1267
}
1268
1269
/**
1270
 * riva_board_list_del - maintains board list
1271
 * @board_list: root node of list of boards
1272
 * @del_node: node to be removed
1273
 *
1274
 * DESCRIPTION:
1275
 * Removes @del_node from the list referenced by @board_list.
1276
 *
1277
 * RETURNS:
1278
 * New root node
1279
 *
1280
 * CALLED FROM:
1281
 * rivafb_remove_one()
1282
 */
1283
static struct rivafb_info *riva_board_list_del(struct rivafb_info *board_list,
1284
					       struct rivafb_info *del_node)
1285
{
1286
	struct rivafb_info *i_p = board_list;
1287
1288
	if (board_list == del_node)
1289
		return del_node->next;
1290
1291
	while (i_p->next != del_node)
1292
		i_p = i_p->next;
1293
	i_p->next = del_node->next;
1294
1295
	return board_list;
1296
}
1297
1298
/**
1299
 * rivafb_do_maximize -
1300
 * @rinfo: pointer to rivafb_info object containing info for current riva board
1301
 * @var:
1302
 * @v:
1303
 * @nom:
1304
 * @den:
1305
 *
1306
 * DESCRIPTION:
1307
 * .
1308
 *
1309
 * RETURNS:
1310
 * -EINVAL on failure, 0 on success
1311
 * 
1312
 *
1313
 * CALLED FROM:
1314
 * rivafb_set_var()
1315
 */
1316
static int rivafb_do_maximize(struct rivafb_info *rinfo,
1317
			      struct fb_var_screeninfo *var,
1318
			      struct fb_var_screeninfo *v,
1319
			      int nom, int den)
1320
{
1321
	static struct {
1322
		int xres, yres;
1323
	} modes[] = {
1324
		{1600, 1280},
1325
		{1280, 1024},
1326
		{1024, 768},
1327
		{800, 600},
1328
		{640, 480},
1329
		{-1, -1}
1330
	};
1331
	int i;
1332
1333
	/* use highest possible virtual resolution */
1334
	if (v->xres_virtual == -1 && v->yres_virtual == -1) {
1335
		printk(KERN_WARNING PFX
1336
		       "using maximum available virtual resolution\n");
1337
		for (i = 0; modes[i].xres != -1; i++) {
1338
			if (modes[i].xres * nom / den * modes[i].yres <
1339
			    rinfo->ram_amount / 2)
1340
				break;
1341
		}
1342
		if (modes[i].xres == -1) {
1343
			printk(KERN_ERR PFX
1344
			       "could not find a virtual resolution that fits into video memory!!\n");
1345
			DPRINTK("EXIT - EINVAL error\n");
1346
			return -EINVAL;
1347
		}
1348
		v->xres_virtual = modes[i].xres;
1349
		v->yres_virtual = modes[i].yres;
1350
1351
		printk(KERN_INFO PFX
1352
		       "virtual resolution set to maximum of %dx%d\n",
1353
		       v->xres_virtual, v->yres_virtual);
1354
	} else if (v->xres_virtual == -1) {
1355
		v->xres_virtual = (rinfo->ram_amount * den /
1356
			(nom * v->yres_virtual * 2)) & ~15;
1357
		printk(KERN_WARNING PFX
1358
		       "setting virtual X resolution to %d\n", v->xres_virtual);
1359
	} else if (v->yres_virtual == -1) {
1360
		v->xres_virtual = (v->xres_virtual + 15) & ~15;
1361
		v->yres_virtual = rinfo->ram_amount * den /
1362
			(nom * v->xres_virtual * 2);
1363
		printk(KERN_WARNING PFX
1364
		       "setting virtual Y resolution to %d\n", v->yres_virtual);
1365
	} else {
1366
		v->xres_virtual = (v->xres_virtual + 15) & ~15;
1367
		if (v->xres_virtual * nom / den * v->yres_virtual > rinfo->ram_amount) {
1368
			printk(KERN_ERR PFX
1369
			       "mode %dx%dx%d rejected...resolution too high to fit into video memory!\n",
1370
			       var->xres, var->yres, var->bits_per_pixel);
1371
			DPRINTK("EXIT - EINVAL error\n");
1372
			return -EINVAL;
1373
		}
1374
	}
1375
1376
	if (v->xres_virtual * nom / den >= 8192) {
1377
		printk(KERN_WARNING PFX
1378
		       "virtual X resolution (%d) is too high, lowering to %d\n",
1379
		       v->xres_virtual, 8192 * den / nom - 16);
1380
		v->xres_virtual = 8192 * den / nom - 16;
1381
	}
1382
	
1383
	if (v->xres_virtual < v->xres) {
1384
		printk(KERN_ERR PFX
1385
		       "virtual X resolution (%d) is smaller than real\n", v->xres_virtual);
1386
		return -EINVAL;
1387
	}
1388
1389
	if (v->yres_virtual < v->yres) {
1390
		printk(KERN_ERR PFX
1391
		       "virtual Y resolution (%d) is smaller than real\n", v->yres_virtual);
1392
		return -EINVAL;
1393
	}
1394
	
1395
	return 0;
1396
}
1397
1398
1399
1400
/* ------------------------------------------------------------------------- *
1401
 *
1402
 * internal fb_ops helper functions
1403
 *
1404
 * ------------------------------------------------------------------------- */
1405
1406
/**
1407
 * riva_get_cmap_len - query current color map length
1408
 * @var: standard kernel fb changeable data
1409
 *
1410
 * DESCRIPTION:
1411
 * Get current color map length.
1412
 *
1413
 * RETURNS:
1414
 * Length of color map
1415
 *
1416
 * CALLED FROM:
1417
 * riva_getcolreg()
1418
 * riva_setcolreg()
1419
 * rivafb_get_cmap()
1420
 * rivafb_set_cmap()
1421
 */
1422
static int riva_get_cmap_len(const struct fb_var_screeninfo *var)
1423
{
1424
	int rc = 16;		/* reasonable default */
1425
1426
	assert(var != NULL);
1427
1428
	switch (var->bits_per_pixel) {
1429
#ifdef FBCON_HAS_CFB8
1430
	case 8:
1431
		rc = 256;	/* pseudocolor... 256 entries HW palette */
1432
		break;
1433
#endif
1434
#ifdef FBCON_HAS_CFB16
1435
	case 15:
1436
		rc = 15;	/* fix for 15 bpp depths on Riva 128 based cards */
1437
		break;
1438
	case 16:
1439
		rc = 16;	/* directcolor... 16 entries SW palette */
1440
		break;		/* Mystique: truecolor, 16 entries SW palette, HW palette hardwired into 1:1 mapping */
1441
#endif
1442
#ifdef FBCON_HAS_CFB32
1443
	case 32:
1444
		rc = 16;	/* directcolor... 16 entries SW palette */
1445
		break;		/* Mystique: truecolor, 16 entries SW palette, HW palette hardwired into 1:1 mapping */
1446
#endif
1447
	default:
1448
		/* should not occur */
1449
		break;
1450
	}
1451
1452
	return rc;
1453
}
1454
1455
/**
1456
 * riva_getcolreg
1457
 * @regno: register index
1458
 * @red: red component
1459
 * @green: green component
1460
 * @blue: blue component
1461
 * @transp: transparency
1462
 * @info: pointer to rivafb_info object containing info for current riva board
1463
 *
1464
 * DESCRIPTION:
1465
 * Read a single color register and split it into colors/transparent.
1466
 * The return values must have a 16 bit magnitude.
1467
 *
1468
 * RETURNS:
1469
 * Return != 0 for invalid regno.
1470
 *
1471
 * CALLED FROM:
1472
 * rivafb_get_cmap()
1473
 * rivafb_switch()
1474
 * fbcmap.c:fb_get_cmap()
1475
 *	fbgen.c:fbgen_get_cmap()
1476
 *	fbgen.c:fbgen_switch()
1477
 */
1478
static int riva_getcolreg(unsigned regno, unsigned *red, unsigned *green,
1479
			  unsigned *blue, unsigned *transp,
1480
			  struct fb_info *info)
1481
{
1482
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1483
1484
	if (regno >= riva_get_cmap_len(&rivainfo->currcon_display->var))
1485
		return 1;
1486
1487
	*red = rivainfo->palette[regno].red;
1488
	*green = rivainfo->palette[regno].green;
1489
	*blue = rivainfo->palette[regno].blue;
1490
	*transp = 0;
1491
1492
	return 0;
1493
}
1494
1495
/**
1496
 * riva_setcolreg
1497
 * @regno: register index
1498
 * @red: red component
1499
 * @green: green component
1500
 * @blue: blue component
1501
 * @transp: transparency
1502
 * @info: pointer to rivafb_info object containing info for current riva board
1503
 *
1504
 * DESCRIPTION:
1505
 * Set a single color register. The values supplied have a 16 bit
1506
 * magnitude.
1507
 *
1508
 * RETURNS:
1509
 * Return != 0 for invalid regno.
1510
 *
1511
 * CALLED FROM:
1512
 * rivafb_set_cmap()
1513
 * fbcmap.c:fb_set_cmap()
1514
 *	fbgen.c:fbgen_get_cmap()
1515
 *	fbgen.c:fbgen_install_cmap()
1516
 *		fbgen.c:fbgen_set_var()
1517
 *		fbgen.c:fbgen_switch()
1518
 *		fbgen.c:fbgen_blank()
1519
 *	fbgen.c:fbgen_blank()
1520
 */
1521
static int riva_setcolreg(unsigned regno, unsigned red, unsigned green,
1522
			  unsigned blue, unsigned transp,
1523
			  struct fb_info *info)
1524
{
1525
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1526
	RIVA_HW_INST *chip = &rivainfo->riva;
1527
	struct display *p;
1528
1529
	DPRINTK("ENTER\n");
1530
1531
	assert(rivainfo != NULL);
1532
	assert(rivainfo->currcon_display != NULL);
1533
1534
	p = rivainfo->currcon_display;
1535
1536
	if (regno >= riva_get_cmap_len(&p->var))
1537
		return -EINVAL;
1538
1539
	rivainfo->palette[regno].red = red;
1540
	rivainfo->palette[regno].green = green;
1541
	rivainfo->palette[regno].blue = blue;
1542
1543
	if (p->var.grayscale) {
1544
		/* gray = 0.30*R + 0.59*G + 0.11*B */
1545
		red = green = blue =
1546
		    (red * 77 + green * 151 + blue * 28) >> 8;
1547
	}
1548
1549
	switch (p->var.bits_per_pixel) {
1550
#ifdef FBCON_HAS_CFB8
1551
	case 8:
1552
		/* "transparent" stuff is completely ignored. */
1553
		riva_wclut(chip, regno, red >> 8, green >> 8, blue >> 8);
1554
		break;
1555
#endif /* FBCON_HAS_CFB8 */
1556
#ifdef FBCON_HAS_CFB16
1557
	case 16:
1558
		assert(regno < 16);
1559
		if (p->var.green.length == 5) {
1560
			/* 0rrrrrgg gggbbbbb */
1561
			rivainfo->con_cmap.cfb16[regno] =
1562
			    ((red & 0xf800) >> 1) |
1563
			    ((green & 0xf800) >> 6) | ((blue & 0xf800) >> 11);
1564
		} else {
1565
			/* rrrrrggg gggbbbbb */
1566
			rivainfo->con_cmap.cfb16[regno] =
1567
			    ((red & 0xf800) >> 0) |
1568
			    ((green & 0xf800) >> 5) | ((blue & 0xf800) >> 11);
1569
		}
1570
		break;
1571
#endif /* FBCON_HAS_CFB16 */
1572
#ifdef FBCON_HAS_CFB32
1573
	case 32:
1574
		assert(regno < 16);
1575
		rivainfo->con_cmap.cfb32[regno] =
1576
		    ((red & 0xff00) << 8) |
1577
		    ((green & 0xff00)) | ((blue & 0xff00) >> 8);
1578
		break;
1579
#endif /* FBCON_HAS_CFB32 */
1580
	default:
1581
		/* do nothing */
1582
		break;
1583
	}
1584
1585
	return 0;
1586
}
1587
1588
1589
1590
/* ------------------------------------------------------------------------- *
1591
 *
1592
 * framebuffer operations
1593
 *
1594
 * ------------------------------------------------------------------------- */
1595
1596
static int rivafb_get_fix(struct fb_fix_screeninfo *fix, int con,
1597
			  struct fb_info *info)
1598
{
1599
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1600
	struct display *p;
1601
1602
	DPRINTK("ENTER\n");
1603
1604
	assert(fix != NULL);
1605
	assert(info != NULL);
1606
	assert(rivainfo->drvr_name && rivainfo->drvr_name[0]);
1607
	assert(rivainfo->fb_base_phys > 0);
1608
	assert(rivainfo->ram_amount > 0);
1609
1610
	p = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1611
1612
	memset(fix, 0, sizeof(struct fb_fix_screeninfo));
1613
	sprintf(fix->id, "nVidia %s", rivainfo->drvr_name);
1614
1615
	fix->type = p->type;
1616
	fix->type_aux = p->type_aux;
1617
	fix->visual = p->visual;
1618
1619
	fix->xpanstep = 1;
1620
	fix->ypanstep = 1;
1621
	fix->ywrapstep = 0;	/* FIXME: no ywrap for now */
1622
1623
	fix->line_length = p->line_length;
1624
1625
	fix->mmio_start = rivainfo->ctrl_base_phys;
1626
	fix->mmio_len = rivainfo->base0_region_size;
1627
	fix->smem_start = rivainfo->fb_base_phys;
1628
	fix->smem_len = rivainfo->ram_amount;
1629
1630
	switch (rivainfo->riva.Architecture) {
1631
	case NV_ARCH_03:
1632
		fix->accel = FB_ACCEL_NV3;
1633
		break;
1634
	case NV_ARCH_04:	/* riva_hw.c now doesn't distinguish between TNT & TNT2 */
1635
		fix->accel = FB_ACCEL_NV4;
1636
		break;
1637
	case NV_ARCH_10:	/* FIXME: ID for GeForce */
1638
	case NV_ARCH_20:
1639
		fix->accel = FB_ACCEL_NV4;
1640
		break;
1641
1642
	}
1643
1644
	DPRINTK("EXIT, returning 0\n");
1645
1646
	return 0;
1647
}
1648
1649
static int rivafb_get_var(struct fb_var_screeninfo *var, int con,
1650
			  struct fb_info *info)
1651
{
1652
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1653
1654
	DPRINTK("ENTER\n");
1655
1656
	assert(info != NULL);
1657
	assert(var != NULL);
1658
1659
	*var = (con < 0) ? rivainfo->disp.var : fb_display[con].var;
1660
1661
	DPRINTK("EXIT, returning 0\n");
1662
1663
	return 0;
1664
}
1665
1666
static int rivafb_set_var(struct fb_var_screeninfo *var, int con,
1667
			  struct fb_info *info)
1668
{
1669
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1670
	struct display *dsp;
1671
	struct fb_var_screeninfo v;
1672
	int nom, den;		/* translating from pixels->bytes */
1673
	int accel;
1674
	unsigned chgvar = 0;
1675
1676
	DPRINTK("ENTER\n");
1677
1678
	assert(info != NULL);
1679
	assert(var != NULL);
1680
1681
	DPRINTK("Requested: %dx%dx%d\n", var->xres, var->yres,
1682
		var->bits_per_pixel);
1683
	DPRINTK("  virtual: %dx%d\n", var->xres_virtual,
1684
		var->yres_virtual);
1685
	DPRINTK("   offset: (%d,%d)\n", var->xoffset, var->yoffset);
1686
	DPRINTK("grayscale: %d\n", var->grayscale);
1687
1688
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1689
	assert(dsp != NULL);
1690
1691
	/* if var has changed, we should call changevar() later */
1692
	if (con >= 0) {
1693
		chgvar = ((dsp->var.xres != var->xres) ||
1694
			  (dsp->var.yres != var->yres) ||
1695
			  (dsp->var.xres_virtual != var->xres_virtual) ||
1696
			  (dsp->var.yres_virtual != var->yres_virtual) ||
1697
			  (dsp->var.accel_flags != var->accel_flags) ||
1698
			  (dsp->var.bits_per_pixel != var->bits_per_pixel)
1699
			  || memcmp(&dsp->var.red, &var->red,
1700
				    sizeof(var->red))
1701
			  || memcmp(&dsp->var.green, &var->green,
1702
				    sizeof(var->green))
1703
			  || memcmp(&dsp->var.blue, &var->blue,
1704
				    sizeof(var->blue)));
1705
	}
1706
1707
	memcpy(&v, var, sizeof(v));
1708
1709
	accel = v.accel_flags & FB_ACCELF_TEXT;
1710
1711
	switch (v.bits_per_pixel) {
1712
#ifdef FBCON_HAS_CFB8
1713
	case 1 ... 8:
1714
		v.bits_per_pixel = 8;
1715
		nom = 1;
1716
		den = 1;
1717
		v.red.offset = 0;
1718
		v.red.length = 8;
1719
		v.green.offset = 0;
1720
		v.green.length = 8;
1721
		v.blue.offset = 0;
1722
		v.blue.length = 8;
1723
		break;
1724
#endif
1725
#ifdef FBCON_HAS_CFB16
1726
	case 9 ... 15:
1727
		v.green.length = 5;
1728
		/* fall through */
1729
	case 16:
1730
		v.bits_per_pixel = 16;
1731
		nom = 2;
1732
		den = 1;
1733
		if (v.green.length == 5) {
1734
			/* 0rrrrrgg gggbbbbb */
1735
			v.red.offset = 10;
1736
			v.green.offset = 5;
1737
			v.blue.offset = 0;
1738
			v.red.length = 5;
1739
			v.green.length = 5;
1740
			v.blue.length = 5;
1741
		} else {
1742
			/* rrrrrggg gggbbbbb */
1743
			v.red.offset = 11;
1744
			v.green.offset = 5;
1745
			v.blue.offset = 0;
1746
			v.red.length = 5;
1747
			v.green.length = 6;
1748
			v.blue.length = 5;
1749
		}
1750
		break;
1751
#endif
1752
#ifdef FBCON_HAS_CFB32
1753
	case 17 ... 32:
1754
		v.bits_per_pixel = 32;
1755
		nom = 4;
1756
		den = 1;
1757
		v.red.offset = 16;
1758
		v.green.offset = 8;
1759
		v.blue.offset = 0;
1760
		v.red.length = 8;
1761
		v.green.length = 8;
1762
		v.blue.length = 8;
1763
		break;
1764
#endif
1765
	default:
1766
		printk(KERN_ERR PFX
1767
		       "mode %dx%dx%d rejected...color depth not supported.\n",
1768
		       var->xres, var->yres, var->bits_per_pixel);
1769
		DPRINTK("EXIT, returning -EINVAL\n");
1770
		return -EINVAL;
1771
	}
1772
1773
	if (rivafb_do_maximize(rivainfo, var, &v, nom, den) < 0)
1774
		return -EINVAL;
1775
1776
	if (v.xoffset < 0)
1777
		v.xoffset = 0;
1778
	if (v.yoffset < 0)
1779
		v.yoffset = 0;
1780
1781
	/* truncate xoffset and yoffset to maximum if too high */
1782
	if (v.xoffset > v.xres_virtual - v.xres)
1783
		v.xoffset = v.xres_virtual - v.xres - 1;
1784
1785
	if (v.yoffset > v.yres_virtual - v.yres)
1786
		v.yoffset = v.yres_virtual - v.yres - 1;
1787
1788
	v.red.msb_right =
1789
	    v.green.msb_right =
1790
	    v.blue.msb_right =
1791
	    v.transp.offset = v.transp.length = v.transp.msb_right = 0;
1792
1793
	switch (v.activate & FB_ACTIVATE_MASK) {
1794
	case FB_ACTIVATE_TEST:
1795
		DPRINTK("EXIT - FB_ACTIVATE_TEST\n");
1796
		return 0;
1797
	case FB_ACTIVATE_NXTOPEN:	/* ?? */
1798
	case FB_ACTIVATE_NOW:
1799
		break;		/* continue */
1800
	default:
1801
		DPRINTK("EXIT - unknown activation type\n");
1802
		return -EINVAL;	/* unknown */
1803
	}
1804
1805
	memcpy(&dsp->var, &v, sizeof(v));
1806
	if (chgvar) {
1807
		riva_set_dispsw(rivainfo, dsp);
1808
1809
		if (accel) {
1810
			if (nomove)
1811
				dsp->scrollmode = SCROLL_YNOMOVE;
1812
			else
1813
				dsp->scrollmode = 0;
1814
		} else
1815
			dsp->scrollmode = SCROLL_YREDRAW;
1816
1817
		if (info && info->changevar)
1818
			info->changevar(con);
1819
	}
1820
1821
	rivafb_create_cursor(rivainfo, fontwidth(dsp), fontheight(dsp));
1822
	xbox_load_video_mode(rivainfo, &v);
1823
	if (accel) riva_setup_accel(rivainfo);
1824
1825
	DPRINTK("EXIT, returning 0\n");
1826
	return 0;
1827
}
1828
1829
static int rivafb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
1830
			   struct fb_info *info)
1831
{
1832
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1833
	struct display *dsp;
1834
1835
	DPRINTK("ENTER\n");
1836
1837
	assert(rivainfo != NULL);
1838
	assert(cmap != NULL);
1839
1840
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1841
1842
	if (con == rivainfo->currcon) {	/* current console? */
1843
		int rc = fb_get_cmap(cmap, kspc, riva_getcolreg, info);
1844
		DPRINTK("EXIT - returning %d\n", rc);
1845
		return rc;
1846
	} else if (dsp->cmap.len)	/* non default colormap? */
1847
		fb_copy_cmap(&dsp->cmap, cmap, kspc ? 0 : 2);
1848
	else
1849
		fb_copy_cmap(fb_default_cmap
1850
			     (riva_get_cmap_len(&dsp->var)), cmap,
1851
			     kspc ? 0 : 2);
1852
1853
	DPRINTK("EXIT, returning 0\n");
1854
1855
	return 0;
1856
}
1857
1858
static int rivafb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
1859
			   struct fb_info *info)
1860
{
1861
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1862
	struct display *dsp;
1863
	unsigned int cmap_len;
1864
1865
	DPRINTK("ENTER\n");
1866
	
1867
	assert(rivainfo != NULL);
1868
	assert(cmap != NULL);
1869
1870
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1871
1872
	cmap_len = riva_get_cmap_len(&dsp->var);
1873
	if (dsp->cmap.len != cmap_len) {
1874
		int err = fb_alloc_cmap(&dsp->cmap, cmap_len, 0);
1875
		if (err) {
1876
			DPRINTK("EXIT - returning %d\n", err);
1877
			return err;
1878
		}
1879
	}
1880
	if (con == rivainfo->currcon) {	/* current console? */
1881
		int rc = fb_set_cmap(cmap, kspc, riva_setcolreg, info);
1882
		DPRINTK("EXIT - returning %d\n", rc);
1883
		return rc;
1884
	} else
1885
		fb_copy_cmap(cmap, &dsp->cmap, kspc ? 0 : 1);
1886
1887
	DPRINTK("EXIT, returning 0\n");
1888
1889
	return 0;
1890
}
1891
1892
/**
1893
 * rivafb_pan_display
1894
 * @var: standard kernel fb changeable data
1895
 * @con: TODO
1896
 * @info: pointer to rivafb_info object containing info for current riva board
1897
 *
1898
 * DESCRIPTION:
1899
 * Pan (or wrap, depending on the `vmode' field) the display using the
1900
 * `xoffset' and `yoffset' fields of the `var' structure.
1901
 * If the values don't fit, return -EINVAL.
1902
 *
1903
 * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
1904
 */
1905
static int rivafb_pan_display(struct fb_var_screeninfo *var, int con,
1906
			      struct fb_info *info)
1907
{
1908
	unsigned int base;
1909
	struct display *dsp;
1910
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1911
1912
	DPRINTK("ENTER\n");
1913
1914
	assert(rivainfo != NULL);
1915
1916
	if (var->xoffset > (var->xres_virtual - var->xres))
1917
		return -EINVAL;
1918
	if (var->yoffset > (var->yres_virtual - var->yres))
1919
		return -EINVAL;
1920
1921
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
1922
1923
	if (var->vmode & FB_VMODE_YWRAP) {
1924
		if (var->yoffset < 0
1925
		    || var->yoffset >= dsp->var.yres_virtual
1926
		    || var->xoffset) return -EINVAL;
1927
	} else {
1928
		if (var->xoffset + dsp->var.xres > dsp->var.xres_virtual ||
1929
		    var->yoffset + dsp->var.yres > dsp->var.yres_virtual)
1930
			return -EINVAL;
1931
	}
1932
1933
	base = var->yoffset * dsp->line_length + var->xoffset;
1934
	base += rivainfo->riva_fb_start;
1935
1936
	if (con == rivainfo->currcon) {
1937
		rivainfo->riva.SetStartAddress(&rivainfo->riva, base);
1938
	}
1939
1940
	dsp->var.xoffset = var->xoffset;
1941
	dsp->var.yoffset = var->yoffset;
1942
1943
	if (var->vmode & FB_VMODE_YWRAP)
1944
		dsp->var.vmode |= FB_VMODE_YWRAP;
1945
	else
1946
		dsp->var.vmode &= ~FB_VMODE_YWRAP;
1947
1948
	DPRINTK("EXIT, returning 0\n");
1949
1950
	return 0;
1951
}
1952
1953
static int rivafb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
1954
			unsigned long arg, int con, struct fb_info *info)
1955
{
1956
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
1957
	struct fb_var_screeninfo *var = (con < 0) ? &rivainfo->disp.var : &fb_display[con].var;
1958
1959
	xbox_overscan overscan;
1960
	xboxfb_config config;
1961
	xbox_tv_encoding encoding;
1962
	int ret = 0;
1963
1964
	assert(rivainfo != NULL);
1965
1966
	switch (cmd) {
1967
	case FBIO_XBOX_SET_OVERSCAN:
1968
		if(!copy_from_user(&overscan, (xbox_overscan*)arg, sizeof(overscan))) {
1969
			rivainfo->hoc = overscan.hoc;
1970
			rivainfo->voc = overscan.voc;
1971
			xbox_load_video_mode (rivainfo, var);
1972
			if (var->accel_flags & FB_ACCELF_TEXT) {
1973
				riva_setup_accel(rivainfo);
1974
			}
1975
1976
		}
1977
		else {
1978
			ret = -EFAULT;
1979
		}
1980
	break;
1981
	case FBIO_XBOX_GET_OVERSCAN:
1982
		overscan.hoc = rivainfo->hoc;
1983
		overscan.voc = rivainfo->voc;
1984
		if (copy_to_user((xbox_overscan*)arg, &overscan, sizeof(overscan))) {
1985
			ret = -EFAULT;
1986
		}
1987
	break;
1988
	case FBIO_XBOX_GET_CONFIG:
1989
		config.av_type = rivainfo->av_type;
1990
		config.encoder_type = rivainfo->video_encoder;
1991
		if (copy_to_user((xboxfb_config*)arg, &config, sizeof(config))) {
1992
			ret = -EFAULT;
1993
		}
1994
	break;
1995
	case FBIO_XBOX_GET_TV_ENCODING:
1996
		encoding = rivainfo->tv_encoding;
1997
		if (copy_to_user((xbox_tv_encoding*)arg, &encoding, sizeof(encoding))) {
1998
			ret = -EFAULT;
1999
		}
2000
	break;
2001
	case FBIO_XBOX_SET_TV_ENCODING:
2002
		if(!copy_from_user(&encoding, (xbox_tv_encoding*)arg, sizeof(encoding))) {
2003
			rivainfo->tv_encoding = encoding;
2004
			xbox_load_video_mode (rivainfo, var);
2005
			if (var->accel_flags & FB_ACCELF_TEXT) {
2006
				riva_setup_accel(rivainfo);
2007
			}
2008
		}
2009
		else {
2010
			ret = -EFAULT;
2011
		}
2012
	break;
2013
	default:
2014
		ret = -EINVAL;
2015
	}
2016
	return ret;
2017
}
2018
2019
static int rivafb_rasterimg(struct fb_info *info, int start)
2020
{
2021
	struct rivafb_info *rinfo = (struct rivafb_info *)info;
2022
2023
	wait_for_idle(rinfo);
2024
2025
	return 0;
2026
}
2027
2028
static int rivafb_switch(int con, struct fb_info *info)
2029
{
2030
	struct rivafb_info *rivainfo = (struct rivafb_info *)info;
2031
	struct fb_cmap *cmap;
2032
	struct display *dsp;
2033
2034
	DPRINTK("ENTER\n");
2035
2036
	assert(rivainfo != NULL);
2037
2038
	dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con];
2039
2040
	if (rivainfo->currcon >= 0) {
2041
		/* Do we have to save the colormap? */
2042
		cmap = &(rivainfo->currcon_display->cmap);
2043
		DPRINTK("switch1: con = %d, cmap.len = %d\n",
2044
			 rivainfo->currcon, cmap->len);
2045
2046
		if (cmap->len) {
2047
			DPRINTK("switch1a: %p %p %p %p\n", cmap->red,
2048
				 cmap->green, cmap->blue, cmap->transp);
2049
			fb_get_cmap(cmap, 1, riva_getcolreg, info);
2050
		}
2051
	}
2052
	rivainfo->currcon = con;
2053
	rivainfo->currcon_display = dsp;
2054
2055
	rivafb_set_var(&dsp->var, con, info);
2056
	riva_set_dispsw(rivainfo, dsp);
2057
2058
	DPRINTK("EXIT, returning 0\n");
2059
	return 0;
2060
}
2061
2062
static int rivafb_updatevar(int con, struct fb_info *info)
2063
{
2064
	int rc;
2065
2066
	DPRINTK("ENTER\n");
2067
2068
	rc = (con < 0) ? -EINVAL : rivafb_pan_display(&fb_display[con].var,
2069
						      con, info);
2070
	DPRINTK("EXIT, returning %d\n", rc);
2071
	return rc;
2072
}
2073
2074
static void rivafb_blank(int blank, struct fb_info *info)
2075
{
2076
	unsigned char tmp, vesa;
2077
	struct rivafb_info *rinfo = (struct rivafb_info *)info;
2078
2079
	DPRINTK("ENTER\n");
2080
2081
	assert(rinfo != NULL);
2082
2083
	tmp = SEQin(rinfo, 0x01) & ~0x20;	/* screen on/off */
2084
	vesa = CRTCin(rinfo, 0x1a) & ~0xc0;	/* sync on/off */
2085
2086
	if (blank) {
2087
		tmp |= 0x20;
2088
		switch (blank - 1) {
2089
		case VESA_NO_BLANKING:
2090
			break;
2091
		case VESA_VSYNC_SUSPEND:
2092
			vesa |= 0x80;
2093
			break;
2094
		case VESA_HSYNC_SUSPEND:
2095
			vesa |= 0x40;
2096
			break;
2097
		case VESA_POWERDOWN:
2098
			vesa |= 0xc0;
2099
			break;
2100
		}
2101
	}
2102
2103
	SEQout(rinfo, 0x01, tmp);
2104
	CRTCout(rinfo, 0x1a, vesa);
2105
2106
	DPRINTK("EXIT\n");
2107
}
2108
2109
2110
2111
/* ------------------------------------------------------------------------- *
2112
 *
2113
 * initialization helper functions
2114
 *
2115
 * ------------------------------------------------------------------------- */
2116
2117
/* kernel interface */
2118
static struct fb_ops riva_fb_ops = {
2119
	.owner		= THIS_MODULE,
2120
	.fb_get_fix	= rivafb_get_fix,
2121
	.fb_get_var	= rivafb_get_var,
2122
	.fb_set_var	= rivafb_set_var,
2123
	.fb_get_cmap	= rivafb_get_cmap,
2124
	.fb_set_cmap	= rivafb_set_cmap,
2125
	.fb_pan_display	= rivafb_pan_display,
2126
	.fb_ioctl	= rivafb_ioctl,
2127
	.fb_rasterimg	= rivafb_rasterimg,
2128
};
2129
2130
static int __devinit riva_init_disp_var(struct rivafb_info *rinfo)
2131
{
2132
#ifndef MODULE
2133
	if (mode_option)
2134
	{
2135
		if (!strncmp(mode_option, "640x480", 7)) {
2136
			rinfo->disp.var = xboxfb_mode_640x480;
2137
		}
2138
		else if (!strncmp(mode_option, "800x600", 7)) {
2139
			rinfo->disp.var = xboxfb_mode_800x600;
2140
		}
2141
		else if (!strncmp(mode_option, "480p", 4)) {
2142
			rinfo->disp.var = xboxfb_mode_480p;
2143
		}
2144
		else if (!strncmp(mode_option, "720p", 4)) {
2145
			rinfo->disp.var = xboxfb_mode_720p;
2146
		}
2147
		else if ((rinfo->av_type == AV_VGA) || (rinfo->av_type == AV_VGA_SOG))
2148
		{
2149
			fb_find_mode(&rinfo->disp.var, &rinfo->info, mode_option,
2150
				NULL, 0, NULL, 8);
2151
		}
2152
	}
2153
#endif
2154
	return 0;
2155
}
2156
2157
static int __devinit riva_init_disp(struct rivafb_info *rinfo)
2158
{
2159
	struct fb_info *info;
2160
	struct display *disp;
2161
2162
	DPRINTK("ENTER\n");
2163
2164
	assert(rinfo != NULL);
2165
2166
	info = &rinfo->info;
2167
	disp = &rinfo->disp;
2168
2169
	disp->var = xboxfb_mode_640x480;
2170
2171
	if (noaccel)
2172
		disp->var.accel_flags &= ~FB_ACCELF_TEXT;
2173
	else
2174
		disp->var.accel_flags |= FB_ACCELF_TEXT;
2175
2176
	info->disp = disp;
2177
2178
	/* FIXME: assure that disp->cmap is completely filled out */
2179
2180
	rinfo->currcon_display = disp;
2181
2182
	if ((riva_init_disp_var(rinfo)) < 0) {
2183
		DPRINTK("EXIT, returning -1\n");
2184
		return -1;
2185
	}
2186
2187
	riva_set_dispsw(rinfo, disp);
2188
2189
	DPRINTK("EXIT, returning 0\n");
2190
	return 0;
2191
2192
}
2193
2194
static int __devinit riva_set_fbinfo(struct rivafb_info *rinfo)
2195
{
2196
	struct fb_info *info;
2197
2198
	assert(rinfo != NULL);
2199
2200
	info = &rinfo->info;
2201
2202
	strcpy(info->modename, rinfo->drvr_name);
2203
	info->node = -1;
2204
	info->flags = FBINFO_FLAG_DEFAULT;
2205
	info->fbops = &riva_fb_ops;
2206
2207
	/* FIXME: set monspecs to what??? */
2208
2209
	info->display_fg = NULL;
2210
	strncpy(info->fontname, fontname, sizeof(info->fontname));
2211
	info->fontname[sizeof(info->fontname) - 1] = 0;
2212
2213
	info->changevar = NULL;
2214
	info->switch_con = rivafb_switch;
2215
	info->updatevar = rivafb_updatevar;
2216
	info->blank = rivafb_blank;
2217
2218
	if (riva_init_disp(rinfo) < 0)	/* must be done last */
2219
		return -1;
2220
2221
	return 0;
2222
}
2223
2224
2225
2226
/* ------------------------------------------------------------------------- *
2227
 *
2228
 * PCI bus
2229
 *
2230
 * ------------------------------------------------------------------------- */
2231
2232
static int __devinit rivafb_init_one(struct pci_dev *pd,
2233
				     const struct pci_device_id *ent)
2234
{
2235
	struct rivafb_info *rinfo;
2236
	struct riva_chip_info *rci = &riva_chip_info[ent->driver_data];
2237
2238
	assert(pd != NULL);
2239
	assert(rci != NULL);
2240
2241
	rinfo = kmalloc(sizeof(struct rivafb_info), GFP_KERNEL);
2242
	if (!rinfo)
2243
		goto err_out;
2244
2245
	memset(rinfo, 0, sizeof(struct rivafb_info));
2246
2247
	rinfo->drvr_name = rci->name;
2248
	rinfo->riva.Architecture = rci->arch_rev;
2249
2250
	rinfo->pd = pd;
2251
	rinfo->base0_region_size = pci_resource_len(pd, 0);
2252
	rinfo->base1_region_size = pci_resource_len(pd, 1);
2253
2254
	rinfo->ctrl_base_phys = pci_resource_start(rinfo->pd, 0);
2255
	rinfo->fb_base_phys = pci_resource_start(rinfo->pd, 1);
2256
2257
	if (xbox_memory_size() == 64*1024*1024) printk(KERN_INFO PFX "Detected 64MB of system RAM\n");
2258
	else printk(KERN_INFO PFX "Detected 128MB of system RAM\n");
2259
2260
	if (!fb_size) {
2261
		fb_size = available_framebuffer_memory();
2262
		fb_start = xbox_memory_size() - fb_size;
2263
		printk(KERN_INFO PFX "Using maximum available framebuffer %dM\n", (int)(fb_size/(1024*1024)));
2264
	}
2265
	rinfo->riva_fb_start = fb_start;
2266
	rinfo->fb_base_phys += fb_start;
2267
	tv_init();
2268
	if (tv_encoding == TV_ENC_INVALID) {
2269
		tv_encoding = get_tv_encoding();
2270
		printk(KERN_INFO PFX "Setting TV mode from EEPROM (%s)\n", tvEncodingNames[tv_encoding]);
2271
	}
2272
	rinfo->tv_encoding = tv_encoding;
2273
	rinfo->video_encoder = tv_get_video_encoder();
2274
	switch(rinfo->video_encoder) {
2275
		case ENCODER_CONEXANT:
2276
			printk(KERN_INFO PFX "detected conexant encoder\n");
2277
			break;
2278
		case ENCODER_FOCUS:
2279
			printk(KERN_INFO PFX "detected focus encoder\n");
2280
			break;
2281
		case ENCODER_XLB:
2282
			printk(KERN_INFO PFX "detected XLB encoder\n");
2283
			break;
2284
	}
2285
2286
2287
	if (av_type == AV_INVALID) {
2288
		av_type = detect_av_type();
2289
		printk(KERN_INFO PFX "Setting cable type from AVIP ID: %s\n", avTypeNames[av_type]);
2290
	}
2291
	rinfo->av_type = av_type;
2292
	if ((hoc < 0) || (hoc > 20)) {
2293
		hoc = 10;
2294
	}
2295
	rinfo->hoc = hoc / 100.0;
2296
	if ((voc < 0) || (voc > 20)) {
2297
		voc = 10;
2298
	}
2299
	rinfo->voc = voc / 100.0;
2300
	if (!request_mem_region(rinfo->ctrl_base_phys,
2301
				rinfo->base0_region_size, "rivafb")) {
2302
		printk(KERN_ERR PFX "cannot reserve MMIO region\n");
2303
		goto err_out_kfree;
2304
	}
2305
2306
	rinfo->ctrl_base = ioremap(rinfo->ctrl_base_phys,
2307
				   rinfo->base0_region_size);
2308
	if (!rinfo->ctrl_base) {
2309
		printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
2310
		goto err_out_free_base1;
2311
	}
2312
2313
	rinfo->riva.EnableIRQ = 0;
2314
	rinfo->riva.PRAMDAC = (unsigned *)(rinfo->ctrl_base + 0x00680000);
2315
	rinfo->riva.PFB = (unsigned *)(rinfo->ctrl_base + 0x00100000);
2316
	rinfo->riva.PFIFO = (unsigned *)(rinfo->ctrl_base + 0x00002000);
2317
	rinfo->riva.PGRAPH = (unsigned *)(rinfo->ctrl_base + 0x00400000);
2318
	rinfo->riva.PEXTDEV = (unsigned *)(rinfo->ctrl_base + 0x00101000);
2319
	rinfo->riva.PTIMER = (unsigned *)(rinfo->ctrl_base + 0x00009000);
2320
	rinfo->riva.PMC = (unsigned *)(rinfo->ctrl_base + 0x00000000);
2321
	rinfo->riva.FIFO = (unsigned *)(rinfo->ctrl_base + 0x00800000);
2322
2323
	rinfo->riva.PCIO = (U008 *)(rinfo->ctrl_base + 0x00601000);
2324
	rinfo->riva.PDIO = (U008 *)(rinfo->ctrl_base + 0x00681000);
2325
	rinfo->riva.PVIO = (U008 *)(rinfo->ctrl_base + 0x000C0000);
2326
2327
	rinfo->riva.IO = (MISCin(rinfo) & 0x01) ? 0x3D0 : 0x3B0;
2328
2329
	if (rinfo->riva.Architecture == NV_ARCH_03) {
2330
		/*
2331
		 * We have to map the full BASE_1 aperture for Riva128's
2332
		 * because they use the PRAMIN set in "framebuffer" space
2333
		 */
2334
		if (!request_mem_region(rinfo->fb_base_phys,
2335
					rinfo->base1_region_size, "rivafb")) {
2336
			printk(KERN_ERR PFX "cannot reserve FB region\n");
2337
			goto err_out_free_base0;
2338
		}
2339
2340
		rinfo->fb_base = ioremap(rinfo->fb_base_phys,
2341
					 rinfo->base1_region_size);
2342
		if (!rinfo->fb_base) {
2343
			printk(KERN_ERR PFX "cannot ioremap FB base\n");
2344
			goto err_out_iounmap_ctrl;
2345
		}
2346
	}
2347
2348
2349
	switch (rinfo->riva.Architecture) {
2350
	case NV_ARCH_03:
2351
		rinfo->riva.PRAMIN = (unsigned *)(rinfo->fb_base + 0x00C00000);
2352
		break;
2353
	case NV_ARCH_04:
2354
	case NV_ARCH_10:
2355
	case NV_ARCH_20:
2356
		rinfo->riva.PCRTC = (unsigned *)(rinfo->ctrl_base + 0x00600000);
2357
		rinfo->riva.PRAMIN = (unsigned *)(rinfo->ctrl_base + 0x00710000);
2358
		break;
2359
	}
2360
2361
	RivaGetConfig(&rinfo->riva);
2362
2363
	rinfo->ram_amount = fb_size;
2364
2365
	rinfo->dclk_max = rinfo->riva.MaxVClockFreqKHz * 1000;
2366
2367
	if (rinfo->riva.Architecture != NV_ARCH_03) {
2368
		/*
2369
		 * Now the _normal_ chipsets can just map the amount of
2370
		 * real physical ram instead of the whole aperture
2371
		 */
2372
		if (!request_mem_region(rinfo->fb_base_phys,
2373
					rinfo->ram_amount, "rivafb")) {
2374
			printk(KERN_ERR PFX "cannot reserve FB region\n");
2375
			goto err_out_free_base0;
2376
		}
2377
	
2378
		rinfo->fb_base = ioremap(rinfo->fb_base_phys,
2379
					 rinfo->ram_amount);
2380
		if (!rinfo->fb_base) {
2381
			printk(KERN_ERR PFX "cannot ioremap FB base\n");
2382
			goto err_out_iounmap_ctrl;
2383
		}
2384
	}
2385
#ifdef CONFIG_MTRR
2386
	if (!nomtrr) {
2387
		rinfo->mtrr.vram = mtrr_add(rinfo->fb_base_phys,
2388
					    rinfo->ram_amount,
2389
					    MTRR_TYPE_WRCOMB, 1);
2390
		if (rinfo->mtrr.vram < 0) {
2391
			printk(KERN_ERR PFX "unable to setup MTRR\n");
2392
		} else {
2393
			rinfo->mtrr.vram_valid = 1;
2394
			/* let there be speed */
2395
			printk(KERN_INFO PFX "RIVA MTRR set to ON\n");
2396
		}
2397
	}
2398
#endif /* CONFIG_MTRR */
2399
	rinfo->riva.CURSOR = (U032*)(rinfo->fb_base + fb_size - 128 * 1024);
2400
	rinfo->riva.PCRTC[0x00000800/4] = rinfo->riva_fb_start;	
2401
	rinfo->riva.PGRAPH[0x00000820/4] = rinfo->riva_fb_start;
2402
	rinfo->riva.PGRAPH[0x00000824/4] = rinfo->riva_fb_start;
2403
	rinfo->riva.PGRAPH[0x00000828/4] = rinfo->riva_fb_start;
2404
	rinfo->riva.PGRAPH[0x0000082c/4] = rinfo->riva_fb_start;
2405
2406
	rinfo->riva.PGRAPH[0x00000684/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2407
	rinfo->riva.PGRAPH[0x00000688/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2408
	rinfo->riva.PGRAPH[0x0000068c/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2409
	rinfo->riva.PGRAPH[0x00000690/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2410
	rinfo->riva.PMC[0x00008908/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2411
	rinfo->riva.PMC[0x0000890c/4] = rinfo->riva.RamAmountKBytes * 1024 - 1;
2412
2413
	/* unlock io */
2414
	CRTCout(rinfo, 0x11, 0xFF);	/* vgaHWunlock() + riva unlock (0x7F) */
2415
	rinfo->riva.LockUnlock(&rinfo->riva, 0);
2416
2417
	riva_save_state(rinfo, &rinfo->initial_state);
2418
2419
	if (!nohwcursor) rinfo->cursor = rivafb_init_cursor(rinfo);
2420
	else rinfo->cursor = 0;
2421
2422
	if (riva_set_fbinfo(rinfo) < 0) {
2423
		printk(KERN_ERR PFX "error setting initial video mode\n");
2424
		goto err_out_cursor;
2425
	}
2426
2427
	if (register_framebuffer((struct fb_info *)rinfo) < 0) {
2428
		printk(KERN_ERR PFX
2429
			"error registering riva framebuffer\n");
2430
		goto err_out_load_state;
2431
	}
2432
2433
	riva_boards = riva_board_list_add(riva_boards, rinfo);
2434
2435
	pci_set_drvdata(pd, rinfo);
2436
2437
	printk(KERN_INFO PFX
2438
		"PCI nVidia NV%x framebuffer ver %s (%s, %dMB @ 0x%lX)\n",
2439
		rinfo->riva.Architecture,
2440
		RIVAFB_VERSION,
2441
		rinfo->drvr_name,
2442
		rinfo->ram_amount / (1024 * 1024),
2443
		rinfo->fb_base_phys);
2444
2445
	return 0;
2446
2447
err_out_load_state:
2448
	riva_load_state(rinfo, &rinfo->initial_state);
2449
err_out_cursor:
2450
	rivafb_exit_cursor(rinfo);
2451
/* err_out_iounmap_fb: */
2452
	iounmap(rinfo->fb_base);
2453
err_out_iounmap_ctrl:
2454
	iounmap(rinfo->ctrl_base);
2455
err_out_free_base1:
2456
	release_mem_region(rinfo->fb_base_phys, rinfo->base1_region_size);
2457
err_out_free_base0:
2458
	release_mem_region(rinfo->ctrl_base_phys, rinfo->base0_region_size);
2459
err_out_kfree:
2460
	kfree(rinfo);
2461
err_out:
2462
	return -ENODEV;
2463
}
2464
2465
static void __devexit rivafb_remove_one(struct pci_dev *pd)
2466
{
2467
	struct rivafb_info *board = pci_get_drvdata(pd);
2468
	
2469
	if (!board)
2470
		return;
2471
2472
	riva_boards = riva_board_list_del(riva_boards, board);
2473
2474
	riva_load_state(board, &board->initial_state);
2475
2476
	unregister_framebuffer((struct fb_info *)board);
2477
2478
	rivafb_exit_cursor(board);
2479
2480
#ifdef CONFIG_MTRR
2481
	if (board->mtrr.vram_valid)
2482
		mtrr_del(board->mtrr.vram, board->fb_base_phys,
2483
			 board->ram_amount);
2484
#endif /* CONFIG_MTRR */
2485
2486
	iounmap(board->ctrl_base);
2487
	iounmap(board->fb_base);
2488
2489
	release_mem_region(board->ctrl_base_phys,
2490
			   board->base0_region_size);
2491
	release_mem_region(board->fb_base_phys,
2492
			   board->ram_amount);
2493
2494
	kfree(board);
2495
2496
	pci_set_drvdata(pd, NULL);
2497
}
2498
2499
2500
2501
/* ------------------------------------------------------------------------- *
2502
 *
2503
 * initialization
2504
 *
2505
 * ------------------------------------------------------------------------- */
2506
2507
#ifndef MODULE
2508
int __init xboxfb_setup(char *options)
2509
{
2510
	char *this_opt;
2511
2512
	if (!options || !*options)
2513
		return 0;
2514
2515
	while ((this_opt = strsep(&options, ",")) != NULL) {
2516
		if (!*this_opt)
2517
			continue;
2518
		if (!strncmp(this_opt, "font:", 5)) {
2519
			char *p;
2520
			int i;
2521
2522
			p = this_opt + 5;
2523
			for (i = 0; i < sizeof(fontname) - 1; i++)
2524
				if (!*p || *p == ' ' || *p == ',')
2525
					break;
2526
			memcpy(fontname, this_opt + 5, i);
2527
			fontname[i] = 0;
2528
2529
		} else if (!strncmp(this_opt, "noblink", 7)) {
2530
			noblink = 1;
2531
		} else if (!strncmp(this_opt, "noaccel", 7)) {
2532
			noaccel = 1;
2533
		} else if (!strncmp(this_opt, "nomove", 6)) {
2534
			nomove = 1;
2535
#ifdef CONFIG_MTRR
2536
		} else if (!strncmp(this_opt, "nomtrr", 6)) {
2537
			nomtrr = 1;
2538
#endif
2539
		} else if (!strncmp(this_opt, "nohwcursor", 10)) {
2540
			nohwcursor = 1;
2541
2542
		} else if (!strncmp(this_opt, "fb_mem=", 7)) {
2543
			char *p;
2544
			fb_size = memparse(this_opt+7, &p);
2545
			if (*p == '@') {
2546
				fb_start = memparse(p+1, &p);
2547
			}
2548
			else {
2549
				fb_start = xbox_memory_size() - fb_size;
2550
			} 
2551
		} else if (!strncmp(this_opt, "tv=", 3)) {
2552
			if(!strncmp(this_opt + 3, "PAL", 3)) {
2553
				tv_encoding = TV_ENC_PALBDGHI;
2554
			}
2555
			else if(!strncmp(this_opt + 3, "NTSC", 4)) {
2556
				tv_encoding = TV_ENC_NTSC;
2557
			}
2558
			else if(!strncmp(this_opt + 3, "VGA", 3)) {
2559
				av_type = AV_VGA_SOG;
2560
			}
2561
		} else if (!strncmp(this_opt, "hoc=", 4)) {
2562
			sscanf(this_opt+4, "%d", &hoc);
2563
		} else if (!strncmp(this_opt, "voc=", 4)) {
2564
			sscanf(this_opt+4, "%d", &voc);
2565
		} else
2566
			mode_option = this_opt;
2567
	}
2568
	return 0;
2569
}
2570
#endif /* !MODULE */
2571
2572
static struct pci_driver rivafb_driver = {
2573
	.name		= "rivafb",
2574
	.id_table	= rivafb_pci_tbl,
2575
	.probe		= rivafb_init_one,
2576
	.remove		= __devexit_p(rivafb_remove_one),
2577
};
2578
2579
2580
2581
/* ------------------------------------------------------------------------- *
2582
 *
2583
 * modularization
2584
 *
2585
 * ------------------------------------------------------------------------- */
2586
2587
int __init xboxfb_init(void)
2588
{
2589
	int err;
2590
2591
	err = pci_module_init(&rivafb_driver);
2592
	if (err)
2593
		return err;
2594
	return 0;
2595
}
2596
2597
2598
#ifdef MODULE
2599
static void __exit rivafb_exit(void)
2600
{
2601
	pci_unregister_driver(&rivafb_driver);
2602
}
2603
2604
module_init(xboxfb_init);
2605
module_exit(rivafb_exit);
2606
2607
MODULE_PARM(font, "s");
2608
MODULE_PARM_DESC(font, "Specifies one of the compiled-in fonts (default=none)");
2609
MODULE_PARM(noaccel, "i");
2610
MODULE_PARM_DESC(noaccel, "Disables hardware acceleration (0 or 1=disabled) (default=0)");
2611
MODULE_PARM(nomove, "i");
2612
MODULE_PARM_DESC(nomove, "Enables YSCROLL_NOMOVE (0 or 1=enabled) (default=0)");
2613
MODULE_PARM(nohwcursor, "i");
2614
MODULE_PARM_DESC(nohwcursor, "Disables hardware cursor (0 or 1=disabled) (default=0)");
2615
MODULE_PARM(noblink, "i");
2616
MODULE_PARM_DESC(noblink, "Disables hardware cursor blinking (0 or 1=disabled) (default=0)");
2617
#ifdef CONFIG_MTRR
2618
MODULE_PARM(nomtrr, "i");
2619
MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)");
2620
#endif
2621
2622
MODULE_PARM(fb_mem, "s");
2623
MODULE_PARM_DESC(fb_mem, "Specifies the size and optionally the location of the framebuffer memory");
2624
MODULE_PARM(tv, "s");
2625
MODULE_PARM_DESC(tv, "Specifies the TV encoding (\"PAL\", \"NTSC\" or \"VGA\").");
2626
MODULE_PARM(hoc, "i");
2627
MODULE_PARM_DESC(hoc, "Horizontal overscan compensation ratio, in % (0-20)");
2628
MODULE_PARM(voc, "i");
2629
MODULE_PARM_DESC(voc, "Vertical overscan compensation ratio, in % (0-20)");
2630
2631
#endif /* MODULE */
2632
2633
MODULE_AUTHOR("Oliver Schwartz, maintainer");
2634
MODULE_DESCRIPTION("Framebuffer driver for Xbox");
2635
MODULE_LICENSE("GPL");
(-)linux-2.4.26/drivers/video/xbox/focus.c (+385 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
typedef struct _focus_pll_settings{
18
	long dotclock;
19
	int vga_htotal;
20
	int vga_vtotal;
21
	int tv_htotal;
22
	int tv_vtotal;
23
} focus_pll_settings;
24
25
static const unsigned char focus_defaults[0xc4] = {
26
	/*0x00*/ 0x00,0x00,0x00,0x00,0x80,0x02,0xaa,0x0a,
27
	/*0x08*/ 0x00,0x10,0x00,0x00,0x03,0x21,0x15,0x04,
28
	/*0x10*/ 0x00,0xe9,0x07,0x00,0x80,0xf5,0x20,0x00,
29
	/*0x18*/ 0xef,0x21,0x1f,0x00,0x03,0x03,0x00,0x00,
30
	/*0x20*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
31
	/*0x28*/ 0x0c,0x01,0x00,0x00,0x00,0x00,0x08,0x11,
32
	/*0x30*/ 0x00,0x0f,0x05,0xfe,0x0b,0x80,0x00,0x00,
33
	/*0x38*/ 0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
34
	/*0x40*/ 0x2a,0x09,0x8a,0xcb,0x00,0x00,0x8d,0x00,
35
	/*0x48*/ 0x7c,0x3c,0x9a,0x2f,0x21,0x01,0x3f,0x00,
36
	/*0x50*/ 0x3e,0x03,0x17,0x21,0x1b,0x1b,0x24,0x9c,
37
	/*0x58*/ 0x01,0x3e,0x0f,0x0f,0x60,0x05,0xc8,0x00,
38
	/*0x60*/ 0x9d,0x04,0x9d,0x01,0x02,0x00,0x0a,0x05,
39
	/*0x68*/ 0x00,0x1a,0xff,0x03,0x1e,0x0f,0x78,0x00,
40
	/*0x70*/ 0x00,0xb1,0x04,0x15,0x49,0x10,0x00,0xa3,
41
	/*0x78*/ 0xc8,0x15,0x05,0x15,0x3e,0x03,0x00,0x20,
42
	/*0x80*/ 0x57,0x2f,0x07,0x00,0x00,0x08,0x00,0x00,
43
	/*0x88*/ 0x08,0x16,0x16,0x9c,0x03,0x00,0x00,0x00,
44
	/*0x90*/ 0x00,0x00,0xc4,0x48,0x00,0x00,0x00,0x00,
45
	/*0x98*/ 0x00,0x00,0x00,0x80,0x00,0x00,0xe4,0x00,
46
	/*0xa0*/ 0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
47
	/*0xa8*/ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0x00,
48
	/*0xb0*/ 0x00,0x00,0xd7,0x05,0x00,0x00,0xf0,0x00,
49
	/*0xb8*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
50
	/*0xc0*/ 0x00,0x00,0xee,0x00
51
};
52
53
int focus_calc_hdtv_mode(
54
	xbox_hdtv_mode hdtv_mode,
55
	unsigned char pll_int,
56
	unsigned char * regs
57
	){
58
	memcpy(regs,focus_defaults,sizeof(focus_defaults));	
59
	/* Uncomment for HDTV 480p colour bars */
60
	//regs[0x0d]|=0x02;
61
	
62
	/* Turn on bridge bypass */
63
	regs[0x0a] |= 0x10;
64
	/* Turn on the HDTV clock, and turn off the SDTV one */	
65
	regs[0xa1] = 0x04;
66
	
67
	/* HDTV Hor start */
68
	regs[0xb8] = 0xbe;
69
	
70
	/*Set up video mode to HDTV, progressive, 
71
	 * and disable YUV matrix bypass */
72
	regs[0x92] = 0x1a;	
73
	regs[0x93] &= ~0x40;
74
	
75
	switch (hdtv_mode) {
76
		case HDTV_480p:
77
			/* PLL settings */
78
			regs[0x10] = 0x00;
79
			regs[0x11] = 0x00;
80
			regs[0x12] = 0x00;
81
			regs[0x13] = 0x00;
82
			regs[0x14] = 0x00;
83
			regs[0x15] = 0x00;
84
			regs[0x16] = 0x00;
85
			regs[0x17] = 0x00;
86
			regs[0x18] = 0xD7;
87
			regs[0x19] = 0x03;
88
			regs[0x1A] = 0x7C;
89
			regs[0x1B] = 0x00;
90
			regs[0x1C] = 0x07;
91
			regs[0x1D] = 0x07;
92
			/* Porches/HSync width/Luma offset */
93
			regs[0x94] = 0x3F;
94
			regs[0x95] = 0x2D;
95
			regs[0x96] = 0x3B;
96
			regs[0x97] = 0x00;
97
			regs[0x98] = 0x1B;
98
			regs[0x99] = 0x03;
99
			/* Colour scaling */
100
			regs[0xA2] = 0x4D;
101
			regs[0xA4] = 0x96;
102
			regs[0xA6] = 0x1D;
103
			regs[0xA8] = 0x58;
104
			regs[0xAA] = 0x8A;
105
			regs[0xAC] = 0x4A;
106
			break;
107
		case HDTV_720p:
108
			/* PLL settings */
109
			regs[0x10] = 0x00;
110
			regs[0x11] = 0x00;
111
			regs[0x12] = 0x00;
112
			regs[0x13] = 0x00;
113
			regs[0x14] = 0x00;
114
			regs[0x15] = 0x00;
115
			regs[0x16] = 0x00;
116
			regs[0x17] = 0x00;
117
			regs[0x18] = 0x3B;
118
			regs[0x19] = 0x04;
119
			regs[0x1A] = 0xC7;
120
			regs[0x1B] = 0x00;
121
			regs[0x1C] = 0x01;
122
			regs[0x1D] = 0x01;
123
			/* Porches/HSync width/Luma offset */
124
			regs[0x94] = 0x28;
125
			regs[0x95] = 0x46;
126
			regs[0x96] = 0xDC;
127
			regs[0x97] = 0x00;
128
			regs[0x98] = 0x2C;
129
			regs[0x99] = 0x06;
130
			/* Colour scaling */
131
			regs[0xA2] = 0x36;
132
			regs[0xA4] = 0xB7;
133
			regs[0xA6] = 0x13;
134
			regs[0xA8] = 0x58;
135
			regs[0xAA] = 0x8A;
136
			regs[0xAC] = 0x4A;
137
			/* HSync timing invert - needed to centre picture */
138
			regs[0x93] |= 0x01;
139
			
140
			break;
141
		case HDTV_1080i:
142
			/* PLL settings */
143
			regs[0x10] = 0x00;
144
			regs[0x11] = 0x00;
145
			regs[0x12] = 0x00;
146
			regs[0x13] = 0x00;
147
			regs[0x14] = 0x00;
148
			regs[0x15] = 0x00;
149
			regs[0x16] = 0x00;
150
			regs[0x17] = 0x00;
151
			regs[0x18] = 0x3B;
152
			regs[0x19] = 0x04;
153
			regs[0x1A] = 0xC7;
154
			regs[0x1B] = 0x00;
155
			regs[0x1C] = 0x01;
156
			regs[0x1D] = 0x01;
157
			/* Porches/HSync width/Luma offset */
158
			regs[0x94] = 0x2C;
159
			regs[0x95] = 0x2C;
160
			regs[0x96] = 0x58;
161
			regs[0x97] = 0x00;
162
			regs[0x98] = 0x6C;
163
			regs[0x99] = 0x08;
164
			/* Colour scaling */
165
			regs[0xA2] = 0x36;
166
			regs[0xA4] = 0xB7;
167
			regs[0xA6] = 0x13;
168
			regs[0xA8] = 0x58;
169
			regs[0xAA] = 0x8A;
170
			regs[0xAC] = 0x4A;
171
			/* Set mode to interlaced */
172
			regs[0x92] |= 0x80;
173
			break;
174
	}
175
	return 1;
176
}
177
178
int focus_calc_mode(xbox_video_mode * mode, struct riva_regs * riva_out)
179
{
180
	unsigned char b;
181
	char* regs = riva_out->encoder_mode;
182
	int tv_htotal, tv_vtotal, tv_vactive, tv_hactive;
183
	int vga_htotal, vga_vtotal;
184
	int vsc, hsc;
185
186
	long dotclock;
187
	focus_pll_settings pll_settings;
188
	
189
	memcpy(regs,focus_defaults,sizeof(focus_defaults));
190
	
191
	/* Uncomment for SDTV colour bars */
192
	//regs[0x45]=0x02;
193
	
194
	switch(mode->tv_encoding) {
195
		case TV_ENC_NTSC:
196
			tv_vtotal=525;
197
			tv_vactive=480;			
198
			tv_hactive = 710;
199
			tv_htotal  = 858;
200
			regs[0x0d] &= ~0x01;
201
			regs[0x40] = 0x21;
202
			regs[0x41] = 0xF0;
203
			regs[0x42] = 0x7C;
204
			regs[0x43] = 0x1F;
205
			regs[0x49] = 0x44;
206
			regs[0x4a] = 0x76;
207
			regs[0x4b] = 0x3B;
208
			regs[0x4c] = 0x00;
209
			regs[0x60] = 0x89;
210
			regs[0x62] = 0x89;
211
			regs[0x69] = 0x16;
212
			regs[0x6C] = 0x20;
213
			regs[0x74] = 0x04;		
214
			regs[0x75] = 0x10;
215
			regs[0x80] = 0x67; 
216
			regs[0x81] = 0x21; 
217
			regs[0x82] = 0x0C;
218
			regs[0x83] = 0x18;
219
			regs[0x86] = 0x18;
220
			regs[0x89] = 0x13;
221
			regs[0x8A] = 0x13;
222
			break;
223
		case TV_ENC_PALBDGHI:
224
			tv_vtotal = 625;
225
			tv_vactive = 576;
226
			tv_hactive = 702;
227
			tv_htotal = 864;
228
			break;
229
		default:
230
			/* Default to PAL */
231
			tv_vtotal = 625;
232
			tv_vactive = 576;
233
			tv_hactive = 702;
234
			tv_htotal = 864;
235
			break;
236
	}
237
238
	/* Video control  - set to RGB input*/
239
	b = (regs[0x92] &= ~0x04);
240
	regs[0x92] = (b|= 0x01);
241
	regs[0x93] &= ~0x40;
242
	/* Colour scaling */
243
	regs[0xA2] = 0x4D;
244
	regs[0xA4] = 0x96;
245
	regs[0xA6] = 0x1D;
246
	regs[0xA8] = 0xA0;
247
	regs[0xAA] = 0xDB;
248
	regs[0xAC] = 0x7E;
249
	
250
	tv_vactive = tv_vactive * (1.0f-mode->voc);
251
	vga_vtotal = mode->yres * ((float)tv_vtotal/tv_vactive);
252
	vga_htotal = mode->xres * 1.25f;
253
	tv_hactive = tv_hactive * (1.0f-mode->hoc);
254
255
	regs[0x04] = (mode->xres+64)&0xFF;
256
	regs[0x05] = ((mode->xres+64)>>8)&0xFF;
257
258
	if (tv_vtotal>vga_vtotal) {
259
		/* Upscaling */
260
		vsc = ((((float)tv_vtotal/(float)vga_vtotal)-1)*65536);
261
		/* For upscaling, adjust FIFO_LAT (FIFO latency) */
262
		regs[0x38] = 0x82;
263
	}
264
	else {
265
		/* Downscaling */
266
		vsc = ((((float)tv_vtotal/(float)vga_vtotal))*65536);
267
	}
268
	regs[0x06] = (vsc)&0xFF;
269
	regs[0x07] = (vsc>>8)&0xFF;
270
271
	hsc = 128*((float)tv_hactive/(float)mode->xres-1);
272
	if (tv_hactive > mode->xres) {
273
		/* Upscaling */
274
		regs[0x08] = 0;
275
		regs[0x09] = hsc&0xFF;
276
	}
277
	else {  /* Downscaling */
278
		hsc = 256 + hsc;
279
		regs[0x08] = hsc&0xFF;
280
		regs[0x09] = 0;
281
	}
282
283
	//PLL calculations
284
	if (mode->tv_encoding==TV_ENC_NTSC) dotclock = (vga_htotal * vga_vtotal) / ((float)1/60);
285
	else dotclock = (vga_htotal * vga_vtotal) / ((float)1/50);
286
287
	pll_settings.dotclock = dotclock;
288
	pll_settings.vga_htotal = vga_htotal;
289
	pll_settings.vga_vtotal = vga_vtotal;
290
	pll_settings.tv_htotal = tv_htotal;
291
	pll_settings.tv_vtotal = tv_vtotal;
292
	
293
	if (!focus_calc_pll_settings(&pll_settings,regs)) {
294
		//Unable to calculate a valid PLL solution	
295
		return 1;
296
	}
297
298
	/* Guesswork */
299
	riva_out->ext.vsyncstart = vga_vtotal * 0.95;
300
	riva_out->ext.hsyncstart = vga_htotal * 0.95;
301
	
302
	riva_out->ext.width = mode->xres;
303
	riva_out->ext.height = mode->yres;
304
	riva_out->ext.htotal = vga_htotal - 1;
305
	riva_out->ext.vend = mode->yres - 1;
306
	riva_out->ext.vtotal = vga_vtotal- 1;
307
	riva_out->ext.vcrtc = mode->yres - 1;
308
	riva_out->ext.vsyncend = riva_out->ext.vsyncstart + 3;
309
        riva_out->ext.vvalidstart = 0;
310
	riva_out->ext.vvalidend = mode->yres - 1;
311
	riva_out->ext.hend = mode->xres + 7 ;
312
	riva_out->ext.hcrtc = mode->xres - 1;
313
        riva_out->ext.hsyncend = riva_out->ext.hsyncstart + 32;
314
        riva_out->ext.hvalidstart = 0;
315
        riva_out->ext.hvalidend = mode->xres - 1;
316
	riva_out->ext.crtchdispend = mode->xres;
317
        riva_out->ext.crtcvstart = mode->yres + 32;
318
	//increased from 32
319
	riva_out->ext.crtcvtotal = mode->yres + 64;
320
321
	return 1;
322
}
323
324
int focus_calc_pll_settings(focus_pll_settings *settings, char *regs) {
325
        int m, n, p;
326
	long dotclock = (*settings).dotclock;
327
	int pll_multiplier;
328
	long ncon, ncod;
329
	
330
	ncon = (*settings).vga_htotal * (*settings).vga_vtotal;
331
332
	//Multipliers between 1 and 6 are the limit as output clock cant be >150MHz
333
	//The lower the multiplier, the more stable the PLL (theoretically)
334
	for (pll_multiplier=4; pll_multiplier<6; pll_multiplier++) {
335
		float nco_out_clk;
336
		ncod = (*settings).tv_htotal * (*settings).tv_vtotal * pll_multiplier;
337
		//NCO output clock is the reference clock (27MHz) multiplied by
338
		//the ncon/ncod fraction.
339
		nco_out_clk = 27000000*(ncon/(float)ncod);
340
	
341
		for (n=2; n<270;++n) {
342
			//PLL input clock is NCO output clock divided by N
343
			//Valid range is 100kHz to 1000kHz
344
			float pll_in_clk = nco_out_clk/n;
345
			if ( pll_in_clk >=100000 && pll_in_clk <=1000000) {
346
				for (m=2; m<3000;++m) {
347
					//PLL output clock is PLL input clock multiplied
348
					//by M. Valid range is 100MHz to 300MHz
349
					float pll_out_clk = pll_in_clk * m;
350
					if (pll_out_clk >=100000000 && pll_out_clk <= 300000000) {
351
						for (p=1; p<128; ++p) {
352
							//Output clocks are PLL output clock divided by P.
353
							//Valid range is anything LESS than 150MHz, but
354
							//it must match the incoming pixel clock rate.
355
							float output_clk = pll_out_clk/p;
356
							if (output_clk == dotclock) {
357
								//Got it - the pll is now correctly aligned
358
								//Set up the PLL registers
359
								regs[0x10] = (ncon)&0xFF;
360
								regs[0x11] = (ncon>>8)&0xFF ;
361
								regs[0x12] = (ncon>>16)&0xFF ;
362
								regs[0x13] = (ncon>>24)&0xFF ;
363
								regs[0x14] = (ncod)&0xFF ;
364
								regs[0x15] = (ncod>>8)&0xFF ;
365
								regs[0x16] = (ncod>>16)&0xFF ;
366
								regs[0x17] = (ncod>>24)&0xFF ;
367
	
368
								regs[0x18] = (m-17)&0xFF;
369
								regs[0x19] = ((m-17)>>8)&0xFF;
370
								regs[0x1A] = (n-1)&0xFF ;
371
								regs[0x1B] = ((n-1)>>8)&0xFF ;
372
								regs[0x1C] = (p-1)&0xFF;
373
								regs[0x1D] = (p-1)&0xFF;
374
								return 1;
375
							}
376
						}
377
					}
378
				}
379
			}
380
		}	
381
	}
382
	//Seems no valid solution was possible 
383
	return 0;
384
}
385
(-)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/video/xbox/xcalibur.h (+188 lines)
Line 0 Link Here
1
#ifndef _XCALIBUR_H_
2
#define _XCALIBUR_H_
3
4
unsigned char xlb_regs[] = {
5
	0x00,0x01,0x0F,0x1B,0x50,0x51,0x52,0x54,0x55,0x56,
6
	0x58,0x59,0x5A,0x5B,0x60,0x61,0x62,0x63,0x64,0x65,
7
	0x66,0x80,0x81,0x45,0x46,0x47,0x48,0x42,0x43,0x44,
8
	0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
9
	0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,
10
	0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,
11
	0x3D,0x3E,0x3F,0x40,0x41,0x09,0x00,0x0C,0x0D,0x0E,
12
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x04,0x07,0x04
13
};
14
15
typedef struct {
16
	char Val1;
17
	char Val2;
18
	char Val3;
19
	char Val4;
20
} VALS;
21
22
const VALS XCal_Vals_PAL[] = { 
23
	{ 0x02, 0x00, 0x00, 0x00 }, 
24
	{ 0x36, 0x00, 0x50, 0x03 }, 
25
	{ 0x01, 0x00, 0x00, 0x00 }, 
26
	{ 0x00, 0x00, 0x00, 0x00 }, 
27
	{ 0x71, 0x82, 0x00, 0x03 }, 
28
	{ 0x2e, 0xbc, 0x00, 0x24 }, 
29
	{ 0x48, 0x00, 0x00, 0x28 }, 
30
	{ 0x08, 0x02, 0x20, 0x03 }, 
31
	{ 0x27, 0x9c, 0x10, 0x1e }, 
32
	{ 0x60, 0x00, 0x00, 0x28 }, 
33
	{ 0x10, 0x80, 0x80, 0x00 }, 
34
	{ 0xf0, 0x00, 0x00, 0x00 }, 
35
	{ 0xac, 0x05, 0x00, 0x00 }, 
36
	{ 0x02, 0x20, 0x00, 0x00 }, 
37
	{ 0x12, 0x02, 0x92, 0x81 }, 
38
	{ 0x69, 0xca, 0xc8, 0x00 }, 
39
	{ 0x57, 0xd0, 0x04, 0x01 }, 
40
	{ 0x51, 0xd0, 0x1c, 0x01 }, 
41
	{ 0x47, 0xd0, 0x44, 0x01 }, 
42
	{ 0x41, 0xd0, 0x5c, 0x01 }, 
43
	{ 0x32, 0xca, 0xa4, 0x01 }, 
44
	{ 0x0c, 0x00, 0x00, 0x00 }, 
45
	{ 0x0f, 0x00, 0x00, 0x00 }, 
46
	{ 0x04, 0x00, 0x00, 0x00 }, 
47
	{ 0x04, 0x6e, 0x55, 0x78 }, 
48
	{ 0x41, 0x41, 0x78, 0x55 }, 
49
	{ 0x6e, 0x04, 0x00, 0x00 }, 
50
	{ 0x04, 0x00, 0x00, 0x00 }, 
51
	{ 0x0a, 0x0d, 0x02, 0x10 }, 
52
	{ 0x1b, 0x23, 0x00, 0x00 }, 
53
	{ 0x04, 0x00, 0x00, 0x00 }, 
54
	{ 0xfd, 0x00, 0x0c, 0x00 }, 
55
	{ 0xe7, 0x01, 0x3b, 0x00 }, 
56
	{ 0xf1, 0x00, 0x00, 0x00 }, 
57
	{ 0xfb, 0x01, 0x03, 0x00 }, 
58
	{ 0xfc, 0x00, 0x0f, 0x00 }, 
59
	{ 0xd9, 0x01, 0x86, 0x00 }, 
60
	{ 0xcb, 0x00, 0xdf, 0x01 }, 
61
	{ 0x09, 0x00, 0xfe, 0x00 }, 
62
	{ 0xfe, 0x00, 0x09, 0x00 }, 
63
	{ 0xdf, 0x01, 0xca, 0x00 }, 
64
	{ 0x87, 0x00, 0xd9, 0x01 }, 
65
	{ 0x0f, 0x00, 0xfc, 0x00 }, 
66
	{ 0x03, 0x00, 0xfb, 0x01 }, 
67
	{ 0x00, 0x00, 0xf0, 0x00 }, 
68
	{ 0x3c, 0x00, 0xe7, 0x01 }, 
69
	{ 0x0b, 0x00, 0xfe, 0x00 }, 
70
	{ 0x00, 0x00, 0x00, 0x00 }, 
71
	{ 0x00, 0x00, 0x00, 0x00 }, 
72
	{ 0x00, 0x00, 0x00, 0x00 }, 
73
	{ 0x00, 0x00, 0x00, 0x00 }, 
74
	{ 0x00, 0x00, 0x00, 0x00 }, 
75
	{ 0x00, 0x00, 0x00, 0x00 }, 
76
	{ 0x00, 0x00, 0x00, 0x00 }, 
77
	{ 0x00, 0x00, 0x00, 0x00 }, 
78
	{ 0x00, 0x00, 0x00, 0x00 }, 
79
	{ 0x00, 0x00, 0x00, 0x00 }, 
80
	{ 0x00, 0x00, 0x00, 0x00 }, 
81
	{ 0x00, 0x00, 0x00, 0x00 }, 
82
	{ 0x00, 0x00, 0x00, 0x00 }, 
83
	{ 0x00, 0x00, 0x00, 0x00 }, 
84
	{ 0x00, 0x00, 0x00, 0x00 }, 
85
	{ 0x00, 0x00, 0x00, 0x00 }, 
86
	{ 0x00, 0x00, 0x00, 0x00 }, 
87
	{ 0x00, 0x00, 0x00, 0x00 }, 
88
	{ 0x00, 0x00, 0x00, 0x00 }, 
89
	{ 0x02, 0x00, 0x00, 0x00 }, 
90
	{ 0x0f, 0x00, 0x00, 0x00 }, 
91
	{ 0x00, 0x00, 0x00, 0x00 }, 
92
	{ 0xff, 0xff, 0xff, 0xff }, 
93
	{ 0x12, 0x02, 0x92, 0x81 }, 
94
	{ 0x69, 0xca, 0xc8, 0x00 }, 
95
	{ 0x57, 0xd0, 0x04, 0x01 }, 
96
	{ 0x51, 0xd0, 0x1c, 0x01 }, 
97
	{ 0x47, 0xd0, 0x44, 0x01 }, 
98
	{ 0x41, 0xd0, 0x5c, 0x01 }, 
99
	{ 0x32, 0xca, 0xa4, 0x01 }, 
100
	{ 0x04, 0x00, 0x00, 0x00 }, 
101
	{ 0x10, 0x00, 0x00, 0x03 }, 
102
	{ 0x04, 0x00, 0x00, 0x00 },
103
};
104
105
const VALS XCal_Vals_NTSC[] = {
106
	{ 0x02, 0x00, 0x00, 0x00 }, 
107
	{ 0x10, 0x80, 0x40, 0x03 }, 
108
	{ 0x01, 0x00, 0x00, 0x00 }, 
109
	{ 0x00, 0x00, 0x00, 0x00 }, 
110
	{ 0x0d, 0x82, 0x0c, 0x03 }, 
111
	{ 0x27, 0xa0, 0x00, 0x1e }, 
112
	{ 0x49, 0x00, 0x00, 0x28 }, 
113
	{ 0x0d, 0x02, 0x0c, 0x03 }, 
114
	{ 0x26, 0x98, 0x10, 0x1e }, 
115
	{ 0x60, 0x00, 0x00, 0x28 }, 
116
	{ 0x10, 0x80, 0x80, 0x00 }, 
117
	{ 0xf0, 0x00, 0x00, 0x00 }, 
118
	{ 0x8c, 0x00, 0x00, 0x00 }, 
119
	{ 0x01, 0x10, 0x00, 0x00 }, 
120
	{ 0x10, 0x00, 0x41, 0x01 }, 
121
	{ 0x24, 0x70, 0x90, 0x00 }, 
122
	{ 0x24, 0x70, 0x90, 0x00 }, 
123
	{ 0x24, 0x70, 0x90, 0x00 }, 
124
	{ 0x24, 0x70, 0x90, 0x00 }, 
125
	{ 0x24, 0x70, 0x90, 0x00 }, 
126
	{ 0x24, 0x70, 0x90, 0x00 }, 
127
	{ 0x05, 0x00, 0x00, 0x00 }, 
128
	{ 0x0f, 0x00, 0x00, 0x00 }, 
129
	{ 0x04, 0x00, 0x00, 0x00 }, 
130
	{ 0x38, 0x65, 0x61, 0x08 }, 
131
	{ 0x3a, 0x3a, 0x08, 0x61 }, 
132
	{ 0x65, 0x38, 0x00, 0x00 }, 
133
	{ 0x04, 0x00, 0x00, 0x00 }, 
134
	{ 0x0a, 0x0d, 0x02, 0x10 }, 
135
	{ 0x1b, 0x23, 0x00, 0x00 }, 
136
	{ 0x04, 0x00, 0x00, 0x00 }, 
137
	{ 0xfe, 0x00, 0x0a, 0x00 }, 
138
	{ 0xe9, 0x01, 0x37, 0x00 }, 
139
	{ 0xe4, 0x00, 0x00, 0x00 }, 
140
	{ 0xfb, 0x01, 0x03, 0x00 }, 
141
	{ 0xfc, 0x00, 0x0f, 0x00 }, 
142
	{ 0xdb, 0x01, 0x7e, 0x00 }, 
143
	{ 0xc0, 0x00, 0xe1, 0x01 }, 
144
	{ 0x08, 0x00, 0xff, 0x00 }, 
145
	{ 0xfd, 0x00, 0x09, 0x00 }, 
146
	{ 0xe1, 0x01, 0xbe, 0x00 }, 
147
	{ 0x80, 0x00, 0xdb, 0x01 }, 
148
	{ 0x0e, 0x00, 0xfc, 0x00 }, 
149
	{ 0x03, 0x00, 0xfc, 0x01 }, 
150
	{ 0x00, 0x00, 0xe2, 0x00 }, 
151
	{ 0x39, 0x00, 0xe8, 0x01 }, 
152
	{ 0x0b, 0x00, 0xfe, 0x00 }, 
153
	{ 0x00, 0x00, 0x00, 0x00 }, 
154
	{ 0x00, 0x00, 0x00, 0x00 }, 
155
	{ 0x00, 0x00, 0x00, 0x00 }, 
156
	{ 0x00, 0x00, 0x00, 0x00 }, 
157
	{ 0x00, 0x00, 0x00, 0x00 }, 
158
	{ 0x00, 0x00, 0x00, 0x00 }, 
159
	{ 0x00, 0x00, 0x00, 0x00 }, 
160
	{ 0x00, 0x00, 0x00, 0x00 }, 
161
	{ 0x00, 0x00, 0x00, 0x00 }, 
162
	{ 0x00, 0x00, 0x00, 0x00 }, 
163
	{ 0x00, 0x00, 0x00, 0x00 }, 
164
	{ 0x00, 0x00, 0x00, 0x00 }, 
165
	{ 0x00, 0x00, 0x00, 0x00 }, 
166
	{ 0x00, 0x00, 0x00, 0x00 }, 
167
	{ 0x00, 0x00, 0x00, 0x00 }, 
168
	{ 0x00, 0x00, 0x00, 0x00 }, 
169
	{ 0x00, 0x00, 0x00, 0x00 }, 
170
	{ 0x00, 0x00, 0x00, 0x00 }, 
171
	{ 0x00, 0x00, 0x00, 0x00 }, 
172
	{ 0x02, 0x00, 0x00, 0x00 }, 
173
	{ 0x0f, 0x00, 0x00, 0x00 }, 
174
	{ 0x00, 0x00, 0x00, 0x00 }, 
175
	{ 0xff, 0xff, 0xff, 0xff }, 
176
	{ 0x10, 0x00, 0x41, 0x01 }, 
177
	{ 0x24, 0x70, 0x90, 0x00 }, 
178
	{ 0x24, 0x70, 0x90, 0x00 }, 
179
	{ 0x24, 0x70, 0x90, 0x00 }, 
180
	{ 0x24, 0x70, 0x90, 0x00 }, 
181
	{ 0x24, 0x70, 0x90, 0x00 }, 
182
	{ 0x24, 0x70, 0x90, 0x00 }, 
183
	{ 0x04, 0x00, 0x00, 0x00 }, 
184
	{ 0x00, 0x00, 0x03, 0x03 }, 
185
	{ 0x04, 0x00, 0x00, 0x00 }, 
186
};
187
188
#endif
(-)linux-2.4.26/drivers/video/xbox/xlb.c (+80 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/focus.c - Xbox driver for Xcalibur 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
 * It doesnt DO anything yet!
13
*/
14
#include "xlb.h"
15
#include "encoder.h"
16
17
typedef struct _xlb_sync {
18
	U032	htotal;
19
	U032	vtotal;
20
	U032	hsyncstart;
21
	U032 	hsyncend;
22
	U032	vsyncstart;
23
	U032	vsyncend;
24
} XLB_SYNC;
25
26
static const XLB_SYNC xlb_sync[2][1] = {
27
{	// NTSC MODES
28
	{780, 525, 682, 684, 486, 488},
29
},
30
{	// PAL MODES
31
	{800, 520, 702, 726, 480, 490},
32
}
33
};
34
35
int xlb_calc_hdtv_mode(
36
	xbox_hdtv_mode hdtv_mode,
37
	int dotClock,
38
	unsigned char * regs
39
	){
40
	return 1;
41
}
42
43
int xlb_calc_mode(xbox_video_mode * mode, struct riva_regs * riva_out, int tv_encoding)
44
{
45
46
	XLB_SYNC *sync;
47
	int syncindex;
48
	
49
	switch(tv_encoding) {
50
		case TV_ENC_PALBDGHI:
51
			syncindex = 1;
52
			break;
53
		case TV_ENC_NTSC:
54
		default: // Default to NTSC
55
			syncindex = 0;
56
			break;
57
	}
58
59
	sync = (XLB_SYNC *)&xlb_sync[syncindex];
60
61
	riva_out->ext.vsyncstart = sync->vsyncstart + 1;
62
	riva_out->ext.hsyncstart = sync->hsyncstart + 1;
63
	
64
	riva_out->ext.width = mode->xres;
65
	riva_out->ext.height = mode->yres;
66
	riva_out->ext.htotal = sync->htotal - 1;
67
	riva_out->ext.vend = mode->yres - 1;
68
	riva_out->ext.vtotal = sync->vtotal- 1;
69
	riva_out->ext.vcrtc = mode->yres - 1;
70
	riva_out->ext.vsyncend = sync->vsyncend + 1;
71
	riva_out->ext.vvalidstart = 0;
72
	riva_out->ext.vvalidend = mode->yres - 1;
73
	riva_out->ext.hend = mode->xres - 1;
74
	riva_out->ext.hcrtc = 599;
75
	riva_out->ext.hsyncend = sync->hsyncend + 1;
76
	riva_out->ext.hvalidstart = 0;
77
	riva_out->ext.hvalidend = mode->xres - 1;
78
79
	return 1;
80
}
(-)linux-2.4.26/drivers/video/xbox/xlb.h (+24 lines)
Line 0 Link Here
1
/*
2
 * linux/drivers/video/riva/xlb.c - Xbox driver for Xcalibur 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 xlb_h_
17
#define xlb_h_
18
19
#include "encoder.h"
20
#include "xboxfb.h"
21
22
int xlb_calc_mode(xbox_video_mode * mode, struct riva_regs * riva_out , int tv_encoding);
23
int xlb_calc_hdtv_mode(xbox_hdtv_mode hdtv_mode, int dotClock, unsigned char * mode_out);
24
#endif
(-)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/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/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/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/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/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 (+142 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() __cli();\
133
Xbox_SMC_write(SMC_CMD_POWER, SMC_SUBCMD_POWER_OFF);\
134
for (;;)\
135
	__asm__ __volatile__ ("hlt");
136
137
#define Xbox_reset() __cli();\
138
Xbox_SMC_write(SMC_CMD_POWER, SMC_SUBCMD_POWER_CYCLE);\
139
for (;;)\
140
	__asm__ __volatile__ ("hlt");
141
142
#endif /* _XBOX_H_ */
(-)linux-2.4.26/include/linux/xboxfbctl.h (+67 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
	ENCODER_XLB
46
} xbox_encoder_type;
47
48
typedef struct _xboxOverscan {
49
	double hoc;
50
	double voc;
51
} xbox_overscan;
52
53
typedef struct _xboxFbConfig {
54
	xbox_av_type av_type;
55
	xbox_encoder_type encoder_type;
56
} xboxfb_config;
57
58
#define FBIO_XBOX_GET_OVERSCAN  _IOR('x', 1, xbox_overscan)
59
/* in param: double  hoc (0.0-0.2), double voc (0.0 - 0.2) */
60
#define FBIO_XBOX_SET_OVERSCAN  _IOW('x', 2, xbox_overscan)
61
62
#define FBIO_XBOX_GET_TV_ENCODING  _IOR('x', 3, xbox_tv_encoding)
63
#define FBIO_XBOX_SET_TV_ENCODING  _IOW('x', 4, xbox_tv_encoding)
64
65
#define FBIO_XBOX_GET_CONFIG  _IOR('x', 5, xboxfb_config)
66
67
#endif
(-)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_AMD756=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/lib/inflate.c (-1 / +3 lines)
Lines 114-119 Link Here
114
#  include <stdlib.h>
114
#  include <stdlib.h>
115
#endif
115
#endif
116
116
117
117
#include "gzip.h"
118
#include "gzip.h"
118
#define STATIC
119
#define STATIC
119
#endif /* !STATIC */
120
#endif /* !STATIC */
Lines 892-899 Link Here
892
DEBG("dyn6 ");
893
DEBG("dyn6 ");
893
894
894
  /* decompress until an end-of-block code */
895
  /* decompress until an end-of-block code */
895
  if (inflate_codes(tl, td, bl, bd))
896
  if (inflate_codes(tl, td, bl, bd)) {
896
    return 1;
897
    return 1;
898
  }
897
899
898
DEBG("dyn7 ");
900
DEBG("dyn7 ");
899
901
(-)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

Return to bug 45100