Deleted Added
full compact
vesa.c (198911) vesa.c (198964)
1/*-
2 * Copyright (c) 1998 Kazutaka YOKOTA and Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 Kazutaka YOKOTA and Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/fb/vesa.c 198911 2009-11-04 17:30:48Z jkim $");
28__FBSDID("$FreeBSD: head/sys/dev/fb/vesa.c 198964 2009-11-05 22:58:50Z jkim $");
29
30#include "opt_vga.h"
31#include "opt_vesa.h"
32
33#ifndef VGA_NO_MODE_CHANGE
34
35#include <sys/param.h>
36#include <sys/bus.h>

--- 122 unchanged lines hidden (view full) ---

159static char *vesa_revstr = NULL;
160
161/* local macros and functions */
162#define BIOS_SADDRTOLADDR(p) ((((p) & 0xffff0000) >> 12) + ((p) & 0x0000ffff))
163
164static int int10_set_mode(int mode);
165static int vesa_bios_post(void);
166static int vesa_bios_get_mode(int mode, struct vesa_mode *vmode);
29
30#include "opt_vga.h"
31#include "opt_vesa.h"
32
33#ifndef VGA_NO_MODE_CHANGE
34
35#include <sys/param.h>
36#include <sys/bus.h>

--- 122 unchanged lines hidden (view full) ---

159static char *vesa_revstr = NULL;
160
161/* local macros and functions */
162#define BIOS_SADDRTOLADDR(p) ((((p) & 0xffff0000) >> 12) + ((p) & 0x0000ffff))
163
164static int int10_set_mode(int mode);
165static int vesa_bios_post(void);
166static int vesa_bios_get_mode(int mode, struct vesa_mode *vmode);
167static int vesa_bios_get_current_mode(void);
168static int vesa_bios_set_mode(int mode);
169static int vesa_bios_get_dac(void);
170static int vesa_bios_set_dac(int bits);
171static int vesa_bios_save_palette(int start, int colors, u_char *palette,
172 int bits);
173static int vesa_bios_save_palette2(int start, int colors, u_char *r, u_char *g,
174 u_char *b, int bits);
175static int vesa_bios_load_palette(int start, int colors, u_char *palette,

--- 138 unchanged lines hidden (view full) ---

314
315 bcopy(buf, vmode, sizeof(*vmode));
316 x86bios_free(buf, sizeof(*vmode));
317
318 return (0);
319}
320
321static int
167static int vesa_bios_set_mode(int mode);
168static int vesa_bios_get_dac(void);
169static int vesa_bios_set_dac(int bits);
170static int vesa_bios_save_palette(int start, int colors, u_char *palette,
171 int bits);
172static int vesa_bios_save_palette2(int start, int colors, u_char *r, u_char *g,
173 u_char *b, int bits);
174static int vesa_bios_load_palette(int start, int colors, u_char *palette,

--- 138 unchanged lines hidden (view full) ---

313
314 bcopy(buf, vmode, sizeof(*vmode));
315 x86bios_free(buf, sizeof(*vmode));
316
317 return (0);
318}
319
320static int
322vesa_bios_get_current_mode(void)
323{
324 x86regs_t regs;
325
326 x86bios_init_regs(&regs);
327 regs.R_AX = 0x4f03;
328
329 x86bios_intr(&regs, 0x10);
330
331 if (regs.R_AX != 0x004f)
332 return (-1);
333
334 return (regs.R_BX);
335}
336
337static int
338vesa_bios_set_mode(int mode)
339{
340 x86regs_t regs;
341
342 x86bios_init_regs(&regs);
343 regs.R_AX = 0x4f02;
344 regs.R_BX = mode;
345

--- 1087 unchanged lines hidden (view full) ---

1433 bzero(((adp_state_t *)p)->regs, vesa_state_buf_size);
1434 return (vesa_bios_save_restore(STATE_SAVE, ((adp_state_t *)p)->regs,
1435 vesa_state_buf_size));
1436}
1437
1438static int
1439vesa_load_state(video_adapter_t *adp, void *p)
1440{
321vesa_bios_set_mode(int mode)
322{
323 x86regs_t regs;
324
325 x86bios_init_regs(&regs);
326 regs.R_AX = 0x4f02;
327 regs.R_BX = mode;
328

--- 1087 unchanged lines hidden (view full) ---

1416 bzero(((adp_state_t *)p)->regs, vesa_state_buf_size);
1417 return (vesa_bios_save_restore(STATE_SAVE, ((adp_state_t *)p)->regs,
1418 vesa_state_buf_size));
1419}
1420
1421static int
1422vesa_load_state(video_adapter_t *adp, void *p)
1423{
1441 int flags, mode, ret;
1442
1443 if ((adp != vesa_adp) || (((adp_state_t *)p)->sig != V_STATE_SIG))
1444 return ((*prevvidsw->load_state)(adp, p));
1445
1446 if (vesa_state_buf_size <= 0)
1447 return (1);
1448
1424
1425 if ((adp != vesa_adp) || (((adp_state_t *)p)->sig != V_STATE_SIG))
1426 return ((*prevvidsw->load_state)(adp, p));
1427
1428 if (vesa_state_buf_size <= 0)
1429 return (1);
1430
1449 /*
1450 * If the current mode is not the same, probably it was powered down.
1451 * Try BIOS POST to restore a sane state.
1452 */
1453 if (VESA_MODE(adp->va_mode)) {
1454 mode = vesa_bios_get_current_mode();
1455 if (mode >= 0 && (mode & 0x1ff) != adp->va_mode)
1456 (void)vesa_bios_post();
1457 }
1431 /* Try BIOS POST to restore a sane state. */
1432 (void)vesa_bios_post();
1433 (void)int10_set_mode(adp->va_initial_bios_mode);
1458
1434
1459 ret = vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs,
1460 vesa_state_buf_size);
1461
1462 /*
1463 * If the desired mode is not restored, force setting the mode.
1464 */
1465 if (VESA_MODE(adp->va_mode)) {
1466 mode = vesa_bios_get_current_mode();
1467 if (mode < 0 || (mode & 0x1ff) == adp->va_mode)
1468 return (ret);
1469 mode = adp->va_mode;
1470 flags = adp->va_info.vi_flags;
1471 if ((flags & V_INFO_GRAPHICS) != 0 &&
1472 (flags & V_INFO_LINEAR) != 0)
1473 mode |= 0x4000;
1474 (void)vesa_bios_set_mode(mode);
1475 if ((vesa_adp_info->v_flags & V_DAC8) != 0)
1476 (void)vesa_bios_set_dac(8);
1477 (void)(*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
1478 }
1479
1480 return (ret);
1435 return (vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs,
1436 vesa_state_buf_size));
1481}
1482
1483#if 0
1484static int
1485vesa_get_origin(video_adapter_t *adp, off_t *offset)
1486{
1487 x86regs_t regs;
1488

--- 464 unchanged lines hidden ---
1437}
1438
1439#if 0
1440static int
1441vesa_get_origin(video_adapter_t *adp, off_t *offset)
1442{
1443 x86regs_t regs;
1444

--- 464 unchanged lines hidden ---