Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / drivers / sgi / char / newport.c
blob74c9f294c6bdb75370e9e723b677c4d79f0387f5
1 /*
2 * newport.c: context switching the newport graphics card and
3 * newport graphics support.
5 * Author: Miguel de Icaza
6 */
8 #include <linux/errno.h>
9 #include <linux/sched.h>
10 #include <asm/types.h>
11 #include <asm/gfx.h>
12 #include <asm/ng1.h>
13 #include <asm/uaccess.h>
14 #include <video/newport.h>
15 #include <linux/module.h>
17 struct newport_regs *npregs;
19 /* Kernel routines for supporting graphics context switching */
21 void newport_save (void *y)
23 newport_ctx *x = y;
24 newport_wait ();
26 #define LOAD(val) x->val = npregs->set.val;
27 #define LOADI(val) x->val = npregs->set.val.word;
28 #define LOADC(val) x->val = npregs->cset.val;
30 LOAD(drawmode1);
31 LOAD(drawmode0);
32 LOAD(lsmode);
33 LOAD(lspattern);
34 LOAD(lspatsave);
35 LOAD(zpattern);
36 LOAD(colorback);
37 LOAD(colorvram);
38 LOAD(alpharef);
39 LOAD(smask0x);
40 LOAD(smask0y);
41 LOADI(_xstart);
42 LOADI(_ystart);
43 LOADI(_xend);
44 LOADI(_yend);
45 LOAD(xsave);
46 LOAD(xymove);
47 LOADI(bresd);
48 LOADI(bress1);
49 LOAD(bresoctinc1);
50 LOAD(bresrndinc2);
51 LOAD(brese1);
52 LOAD(bress2);
53 LOAD(aweight0);
54 LOAD(aweight1);
55 LOADI(colorred);
56 LOADI(coloralpha);
57 LOADI(colorgrn);
58 LOADI(colorblue);
59 LOADI(slopered);
60 LOADI(slopealpha);
61 LOADI(slopegrn);
62 LOADI(slopeblue);
63 LOAD(wrmask);
64 LOAD(hostrw0);
65 LOAD(hostrw1);
67 /* configregs */
69 LOADC(smask1x);
70 LOADC(smask1y);
71 LOADC(smask2x);
72 LOADC(smask2y);
73 LOADC(smask3x);
74 LOADC(smask3y);
75 LOADC(smask4x);
76 LOADC(smask4y);
77 LOADC(topscan);
78 LOADC(xywin);
79 LOADC(clipmode);
80 LOADC(config);
82 /* Mhm, maybe I am missing something, but it seems that
83 * saving/restoring the DCB is only a matter of saving these
84 * registers
87 newport_bfwait ();
88 LOAD (dcbmode);
89 newport_bfwait ();
90 x->dcbdata0 = npregs->set.dcbdata0.byword;
91 newport_bfwait ();
92 LOAD(dcbdata1);
96 * Importat things to keep in mind when restoring the newport context:
98 * 1. slopered register is stored as a 2's complete (s12.11);
99 * needs to be converted to a signed magnitude (s(8)12.11).
101 * 2. xsave should be stored after xstart.
103 * 3. None of the registers should be written with the GO address.
104 * (read the docs for more details on this).
106 void newport_restore (void *y)
108 newport_ctx *x = y;
109 #define STORE(val) npregs->set.val = x->val
110 #define STOREI(val) npregs->set.val.word = x->val
111 #define STOREC(val) npregs->cset.val = x->val
112 newport_wait ();
114 STORE(drawmode1);
115 STORE(drawmode0);
116 STORE(lsmode);
117 STORE(lspattern);
118 STORE(lspatsave);
119 STORE(zpattern);
120 STORE(colorback);
121 STORE(colorvram);
122 STORE(alpharef);
123 STORE(smask0x);
124 STORE(smask0y);
125 STOREI(_xstart);
126 STOREI(_ystart);
127 STOREI(_xend);
128 STOREI(_yend);
129 STORE(xsave);
130 STORE(xymove);
131 STOREI(bresd);
132 STOREI(bress1);
133 STORE(bresoctinc1);
134 STORE(bresrndinc2);
135 STORE(brese1);
136 STORE(bress2);
137 STORE(aweight0);
138 STORE(aweight1);
139 STOREI(colorred);
140 STOREI(coloralpha);
141 STOREI(colorgrn);
142 STOREI(colorblue);
143 STOREI(slopered);
144 STOREI(slopealpha);
145 STOREI(slopegrn);
146 STOREI(slopeblue);
147 STORE(wrmask);
148 STORE(hostrw0);
149 STORE(hostrw1);
151 /* configregs */
153 STOREC(smask1x);
154 STOREC(smask1y);
155 STOREC(smask2x);
156 STOREC(smask2y);
157 STOREC(smask3x);
158 STOREC(smask3y);
159 STOREC(smask4x);
160 STOREC(smask4y);
161 STOREC(topscan);
162 STOREC(xywin);
163 STOREC(clipmode);
164 STOREC(config);
166 /* FIXME: restore dcb thingies */
170 newport_ioctl (int card, int cmd, unsigned long arg)
172 switch (cmd){
173 case NG1_SETDISPLAYMODE: {
174 struct ng1_setdisplaymode_args request;
176 if (copy_from_user (&request, (void *) arg, sizeof (request)))
177 return -EFAULT;
179 newport_wait ();
180 newport_bfwait ();
181 npregs->set.dcbmode = DCB_XMAP0 | XM9_CRS_FIFO_AVAIL |
182 DCB_DATAWIDTH_1 | R_DCB_XMAP9_PROTOCOL;
183 xmap9FIFOWait (npregs);
185 /* FIXME: timing is wrong, just be extracted from
186 * the per-board timing table. I still have to figure
187 * out where this comes from
189 * This is used to select the protocol used to talk to
190 * the xmap9. For now I am using 60, selecting the
191 * WSLOW_DCB_XMAP9_PROTOCOL.
193 * Robert Tray comments on this issue:
195 * cfreq refers to the frequency of the monitor
196 * (ie. the refresh rate). Our monitors run typically
197 * between 60 Hz and 76 Hz. But it will be as low as
198 * 50 Hz if you're displaying NTSC/PAL and as high as
199 * 120 Hz if you are runining in stereo mode. You
200 * might want to try the WSLOW values.
202 xmap9SetModeReg (npregs, request.wid, request.mode, 60);
203 return 0;
205 case NG1_SET_CURSOR_HOTSPOT: {
206 struct ng1_set_cursor_hotspot request;
208 if (copy_from_user (&request, (void *) arg, sizeof (request)))
209 return -EFAULT;
210 /* FIXME: make request.xhot, request.yhot the hot spot */
211 return 0;
214 case NG1_SETGAMMARAMP0:
215 /* FIXME: load the gamma ramps :-) */
216 return 0;
219 return -EINVAL;