Lines Matching refs:state

48 static void save_vga_text(struct vgastate *state, void __iomem *fbbase)  in save_vga_text()  argument
50 struct regstate *saved = (struct regstate *) state->vidstate; in save_vga_text()
56 misc = vga_r(state->vgabase, VGA_MIS_R); in save_vga_text()
59 vga_r(state->vgabase, iobase + 0xa); in save_vga_text()
60 vga_w(state->vgabase, VGA_ATT_W, 0x00); in save_vga_text()
61 attr10 = vga_rattr(state->vgabase, 0x10); in save_vga_text()
62 vga_r(state->vgabase, iobase + 0xa); in save_vga_text()
63 vga_w(state->vgabase, VGA_ATT_W, 0x20); in save_vga_text()
69 gr4 = vga_rgfx(state->vgabase, VGA_GFX_PLANE_READ); in save_vga_text()
70 gr5 = vga_rgfx(state->vgabase, VGA_GFX_MODE); in save_vga_text()
71 gr6 = vga_rgfx(state->vgabase, VGA_GFX_MISC); in save_vga_text()
72 seq2 = vga_rseq(state->vgabase, VGA_SEQ_PLANE_WRITE); in save_vga_text()
73 seq4 = vga_rseq(state->vgabase, VGA_SEQ_MEMORY_MODE); in save_vga_text()
76 seq1 = vga_rseq(state->vgabase, VGA_SEQ_CLOCK_MODE); in save_vga_text()
77 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x1); in save_vga_text()
78 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, seq1 | 1 << 5); in save_vga_text()
79 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x3); in save_vga_text()
82 if (state->flags & VGA_SAVE_FONT0) { in save_vga_text()
83 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x4); in save_vga_text()
84 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x6); in save_vga_text()
85 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x2); in save_vga_text()
86 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x0); in save_vga_text()
87 vga_wgfx(state->vgabase, VGA_GFX_MISC, 0x5); in save_vga_text()
93 if (state->flags & VGA_SAVE_FONT1) { in save_vga_text()
94 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x8); in save_vga_text()
95 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x6); in save_vga_text()
96 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x3); in save_vga_text()
97 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x0); in save_vga_text()
98 vga_wgfx(state->vgabase, VGA_GFX_MISC, 0x5); in save_vga_text()
99 for (i = 0; i < state->memsize; i++) in save_vga_text()
104 if (state->flags & VGA_SAVE_TEXT) { in save_vga_text()
105 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x1); in save_vga_text()
106 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x6); in save_vga_text()
107 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x0); in save_vga_text()
108 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x0); in save_vga_text()
109 vga_wgfx(state->vgabase, VGA_GFX_MISC, 0x5); in save_vga_text()
113 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x2); in save_vga_text()
114 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x6); in save_vga_text()
115 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x1); in save_vga_text()
116 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x0); in save_vga_text()
117 vga_wgfx(state->vgabase, VGA_GFX_MISC, 0x5); in save_vga_text()
123 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, seq2); in save_vga_text()
124 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, seq4); in save_vga_text()
126 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, gr4); in save_vga_text()
127 vga_wgfx(state->vgabase, VGA_GFX_MODE, gr5); in save_vga_text()
128 vga_wgfx(state->vgabase, VGA_GFX_MISC, gr6); in save_vga_text()
131 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x1); in save_vga_text()
132 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, seq1 & ~(1 << 5)); in save_vga_text()
133 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x3); in save_vga_text()
135 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, seq1); in save_vga_text()
138 static void restore_vga_text(struct vgastate *state, void __iomem *fbbase) in restore_vga_text() argument
140 struct regstate *saved = (struct regstate *) state->vidstate; in restore_vga_text()
146 gr1 = vga_rgfx(state->vgabase, VGA_GFX_SR_ENABLE); in restore_vga_text()
147 gr3 = vga_rgfx(state->vgabase, VGA_GFX_DATA_ROTATE); in restore_vga_text()
148 gr4 = vga_rgfx(state->vgabase, VGA_GFX_PLANE_READ); in restore_vga_text()
149 gr5 = vga_rgfx(state->vgabase, VGA_GFX_MODE); in restore_vga_text()
150 gr6 = vga_rgfx(state->vgabase, VGA_GFX_MISC); in restore_vga_text()
151 gr8 = vga_rgfx(state->vgabase, VGA_GFX_BIT_MASK); in restore_vga_text()
152 seq2 = vga_rseq(state->vgabase, VGA_SEQ_PLANE_WRITE); in restore_vga_text()
153 seq4 = vga_rseq(state->vgabase, VGA_SEQ_MEMORY_MODE); in restore_vga_text()
156 seq1 = vga_rseq(state->vgabase, VGA_SEQ_CLOCK_MODE); in restore_vga_text()
157 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x1); in restore_vga_text()
158 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, seq1 | 1 << 5); in restore_vga_text()
159 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x3); in restore_vga_text()
161 if (state->depth == 4) { in restore_vga_text()
162 vga_wgfx(state->vgabase, VGA_GFX_DATA_ROTATE, 0x0); in restore_vga_text()
163 vga_wgfx(state->vgabase, VGA_GFX_BIT_MASK, 0xff); in restore_vga_text()
164 vga_wgfx(state->vgabase, VGA_GFX_SR_ENABLE, 0x00); in restore_vga_text()
168 if (state->flags & VGA_SAVE_FONT0) { in restore_vga_text()
169 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x4); in restore_vga_text()
170 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x6); in restore_vga_text()
171 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x2); in restore_vga_text()
172 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x0); in restore_vga_text()
173 vga_wgfx(state->vgabase, VGA_GFX_MISC, 0x5); in restore_vga_text()
179 if (state->flags & VGA_SAVE_FONT1) { in restore_vga_text()
180 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x8); in restore_vga_text()
181 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x6); in restore_vga_text()
182 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x3); in restore_vga_text()
183 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x0); in restore_vga_text()
184 vga_wgfx(state->vgabase, VGA_GFX_MISC, 0x5); in restore_vga_text()
185 for (i = 0; i < state->memsize; i++) in restore_vga_text()
190 if (state->flags & VGA_SAVE_TEXT) { in restore_vga_text()
191 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x1); in restore_vga_text()
192 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x6); in restore_vga_text()
193 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x0); in restore_vga_text()
194 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x0); in restore_vga_text()
195 vga_wgfx(state->vgabase, VGA_GFX_MISC, 0x5); in restore_vga_text()
199 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, 0x2); in restore_vga_text()
200 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, 0x6); in restore_vga_text()
201 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, 0x1); in restore_vga_text()
202 vga_wgfx(state->vgabase, VGA_GFX_MODE, 0x0); in restore_vga_text()
203 vga_wgfx(state->vgabase, VGA_GFX_MISC, 0x5); in restore_vga_text()
209 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x1); in restore_vga_text()
210 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, seq1 & ~(1 << 5)); in restore_vga_text()
211 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x3); in restore_vga_text()
214 vga_wgfx(state->vgabase, VGA_GFX_SR_ENABLE, gr1); in restore_vga_text()
215 vga_wgfx(state->vgabase, VGA_GFX_DATA_ROTATE, gr3); in restore_vga_text()
216 vga_wgfx(state->vgabase, VGA_GFX_PLANE_READ, gr4); in restore_vga_text()
217 vga_wgfx(state->vgabase, VGA_GFX_MODE, gr5); in restore_vga_text()
218 vga_wgfx(state->vgabase, VGA_GFX_MISC, gr6); in restore_vga_text()
219 vga_wgfx(state->vgabase, VGA_GFX_BIT_MASK, gr8); in restore_vga_text()
221 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, seq1); in restore_vga_text()
222 vga_wseq(state->vgabase, VGA_SEQ_PLANE_WRITE, seq2); in restore_vga_text()
223 vga_wseq(state->vgabase, VGA_SEQ_MEMORY_MODE, seq4); in restore_vga_text()
226 static void save_vga_mode(struct vgastate *state) in save_vga_mode() argument
228 struct regstate *saved = (struct regstate *) state->vidstate; in save_vga_mode()
232 saved->misc = vga_r(state->vgabase, VGA_MIS_R); in save_vga_mode()
238 for (i = 0; i < state->num_crtc; i++) in save_vga_mode()
239 saved->crtc[i] = vga_rcrtcs(state->vgabase, iobase, i); in save_vga_mode()
241 vga_r(state->vgabase, iobase + 0xa); in save_vga_mode()
242 vga_w(state->vgabase, VGA_ATT_W, 0x00); in save_vga_mode()
243 for (i = 0; i < state->num_attr; i++) { in save_vga_mode()
244 vga_r(state->vgabase, iobase + 0xa); in save_vga_mode()
245 saved->attr[i] = vga_rattr(state->vgabase, i); in save_vga_mode()
247 vga_r(state->vgabase, iobase + 0xa); in save_vga_mode()
248 vga_w(state->vgabase, VGA_ATT_W, 0x20); in save_vga_mode()
250 for (i = 0; i < state->num_gfx; i++) in save_vga_mode()
251 saved->gfx[i] = vga_rgfx(state->vgabase, i); in save_vga_mode()
253 for (i = 0; i < state->num_seq; i++) in save_vga_mode()
254 saved->seq[i] = vga_rseq(state->vgabase, i); in save_vga_mode()
257 static void restore_vga_mode(struct vgastate *state) in restore_vga_mode() argument
259 struct regstate *saved = (struct regstate *) state->vidstate; in restore_vga_mode()
263 vga_w(state->vgabase, VGA_MIS_W, saved->misc); in restore_vga_mode()
271 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, in restore_vga_mode()
275 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x01); in restore_vga_mode()
278 vga_r(state->vgabase, iobase + 0xa); in restore_vga_mode()
279 vga_w(state->vgabase, VGA_ATT_W, 0x00); in restore_vga_mode()
281 for (i = 2; i < state->num_seq; i++) in restore_vga_mode()
282 vga_wseq(state->vgabase, i, saved->seq[i]); in restore_vga_mode()
286 vga_wcrtcs(state->vgabase, iobase, 17, saved->crtc[17] & ~0x80); in restore_vga_mode()
287 for (i = 0; i < state->num_crtc; i++) in restore_vga_mode()
288 vga_wcrtcs(state->vgabase, iobase, i, saved->crtc[i]); in restore_vga_mode()
290 for (i = 0; i < state->num_gfx; i++) in restore_vga_mode()
291 vga_wgfx(state->vgabase, i, saved->gfx[i]); in restore_vga_mode()
293 for (i = 0; i < state->num_attr; i++) { in restore_vga_mode()
294 vga_r(state->vgabase, iobase + 0xa); in restore_vga_mode()
295 vga_wattr(state->vgabase, i, saved->attr[i]); in restore_vga_mode()
299 vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x03); in restore_vga_mode()
301 vga_wseq(state->vgabase, VGA_SEQ_CLOCK_MODE, in restore_vga_mode()
305 vga_r(state->vgabase, iobase + 0xa); in restore_vga_mode()
306 vga_w(state->vgabase, VGA_ATT_W, 0x20); in restore_vga_mode()
309 static void save_vga_cmap(struct vgastate *state) in save_vga_cmap() argument
311 struct regstate *saved = (struct regstate *) state->vidstate; in save_vga_cmap()
314 vga_w(state->vgabase, VGA_PEL_MSK, 0xff); in save_vga_cmap()
317 vga_w(state->vgabase, VGA_PEL_IR, 0x00); in save_vga_cmap()
319 saved->vga_cmap[i] = vga_r(state->vgabase, VGA_PEL_D); in save_vga_cmap()
322 static void restore_vga_cmap(struct vgastate *state) in restore_vga_cmap() argument
324 struct regstate *saved = (struct regstate *) state->vidstate; in restore_vga_cmap()
327 vga_w(state->vgabase, VGA_PEL_MSK, 0xff); in restore_vga_cmap()
330 vga_w(state->vgabase, VGA_PEL_IW, 0x00); in restore_vga_cmap()
332 vga_w(state->vgabase, VGA_PEL_D, saved->vga_cmap[i]); in restore_vga_cmap()
335 static void vga_cleanup(struct vgastate *state) in vga_cleanup() argument
337 if (state->vidstate != NULL) { in vga_cleanup()
338 struct regstate *saved = (struct regstate *) state->vidstate; in vga_cleanup()
346 state->vidstate = NULL; in vga_cleanup()
350 int save_vga(struct vgastate *state) in save_vga() argument
359 state->vidstate = (void *)saved; in save_vga()
361 if (state->flags & VGA_SAVE_CMAP) { in save_vga()
364 vga_cleanup(state); in save_vga()
367 save_vga_cmap(state); in save_vga()
370 if (state->flags & VGA_SAVE_MODE) { in save_vga()
373 if (state->num_attr < 21) in save_vga()
374 state->num_attr = 21; in save_vga()
375 if (state->num_crtc < 25) in save_vga()
376 state->num_crtc = 25; in save_vga()
377 if (state->num_gfx < 9) in save_vga()
378 state->num_gfx = 9; in save_vga()
379 if (state->num_seq < 5) in save_vga()
380 state->num_seq = 5; in save_vga()
381 total = state->num_attr + state->num_crtc + in save_vga()
382 state->num_gfx + state->num_seq; in save_vga()
386 vga_cleanup(state); in save_vga()
389 saved->crtc = saved->attr + state->num_attr; in save_vga()
390 saved->gfx = saved->crtc + state->num_crtc; in save_vga()
391 saved->seq = saved->gfx + state->num_gfx; in save_vga()
393 save_vga_mode(state); in save_vga()
396 if (state->flags & VGA_SAVE_FONTS) { in save_vga()
400 if (state->memsize && state->memsize < 4 * 8192) { in save_vga()
401 vga_cleanup(state); in save_vga()
404 if (!state->memsize) in save_vga()
405 state->memsize = 8 * 8192; in save_vga()
407 if (!state->membase) in save_vga()
408 state->membase = 0xA0000; in save_vga()
410 fbbase = ioremap(state->membase, state->memsize); in save_vga()
413 vga_cleanup(state); in save_vga()
420 if (state->flags & VGA_SAVE_FONT0) { in save_vga()
424 vga_cleanup(state); in save_vga()
432 if (state->flags & VGA_SAVE_FONT1) { in save_vga()
433 saved->vga_font1 = vmalloc(state->memsize); in save_vga()
436 vga_cleanup(state); in save_vga()
443 if (state->flags & VGA_SAVE_TEXT) { in save_vga()
447 vga_cleanup(state); in save_vga()
452 save_vga_text(state, fbbase); in save_vga()
458 int restore_vga(struct vgastate *state) in restore_vga() argument
460 if (state->vidstate == NULL) in restore_vga()
463 if (state->flags & VGA_SAVE_MODE) in restore_vga()
464 restore_vga_mode(state); in restore_vga()
466 if (state->flags & VGA_SAVE_FONTS) { in restore_vga()
467 void __iomem *fbbase = ioremap(state->membase, state->memsize); in restore_vga()
470 vga_cleanup(state); in restore_vga()
473 restore_vga_text(state, fbbase); in restore_vga()
477 if (state->flags & VGA_SAVE_CMAP) in restore_vga()
478 restore_vga_cmap(state); in restore_vga()
480 vga_cleanup(state); in restore_vga()