Subversion Repositories shark

Rev

Rev 54 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 pj 1
/* VGAlib version 1.2 - (c) 1993 Tommy Frandsen                    */
2
/*                                                                 */
3
/* This library is free software; you can redistribute it and/or   */
4
/* modify it without any restrictions. This library is distributed */
5
/* in the hope that it will be useful, but without any warranty.   */
6
 
7
/* Multi-chipset support Copyright 1993 Harm Hanemaayer */
8
/* partially copyrighted (C) 1993 by Hartmut Schirmer */
9
 
10
#include <stdlib.h>
11
 
12
#include "vga.h"
13
#include "libvga.h"
14
#include "driver.h"
15
#include "svgalib_helper.h"
16
 
17
vga_cardinfo *vga_getcardinfo(void) {
18
    vga_cardinfo *vci;
19
 
20
    vci = malloc(sizeof(vga_cardinfo));
21
    if(vci==NULL) return vci;
22
    vci->version = 0x100;
23
    vci->size = sizeof(vga_cardinfo);
24
    vci->chipset = __svgalib_chipset;
25
    vci->physmem = __svgalib_linear_mem_base;
26
 
27
    return vci;
28
}
29
 
30
void vga_waitretrace(void)
31
{
32
    if (__svgalib_driverspecs->emul && __svgalib_driverspecs->emul->waitretrace) {
33
        __svgalib_driverspecs->emul->waitretrace();
34
    } else {
35
        while (!(__svgalib_inis1() & 8));
36
        while (__svgalib_inis1() & 8);
37
    }
38
}
39
 
40
static void *__svgalib_linearframebuffer;
41
/*
42
 * The way IS_LINEAR gets indicated is rather convoluted; if the driver
43
 * has EXT_INFO_AVAILABLE, setlinearaddressing will enable
44
 * the flag in __svgalib_linearset which gets set in the modeinfo by
45
 * vga_getmodeinfo(). The driver must turn off the flag in
46
 * __svgalib_linearset if linear addressing gets disabled (e.g. when
47
 * setting another mode).
48
 *
49
 * For any driver, the chipset getmodeinfo flag can examine a hardware
50
 * register and set the IS_LINEAR flag if linear addressing is enabled.
51
 */
52
 
53
unsigned char *
54
 vga_getgraphmem(void)
55
{
56
 
81 giacomo 57
    DTP(("getgraphmem\n"));
54 pj 58
 
59
    if (__svgalib_modeinfo_linearset & LINEAR_MODE )
60
        return __svgalib_linearframebuffer;
61
    return GM;
62
}
63
 
64
/*
65
 * This function is to be called after a SVGA graphics mode set
66
 * in banked mode. Probing in VGA-compatible textmode is not a good
67
 * idea.
68
 */
69
 
70
/* cf. vga_waitretrace, M.Weller */
71
int vga_setlinearaddressing(void)
72
{
73
    int (*lfn) (int op, int param) = __svgalib_driverspecs->linear;
74
    vga_modeinfo *modeinfo;
75
 
76
    printk(KERN_INFO "Setlinearaddressing\n");
77
 
78
    modeinfo = vga_getmodeinfo(CM);
79
    if (!(modeinfo->flags&CAPABLE_LINEAR)) return -1;
80
 
81
    (*lfn) (LINEAR_ENABLE, 0);
82
    __svgalib_linearframebuffer = LINEAR_POINTER;
83
 
84
    if ((long) __svgalib_linearframebuffer == -1) {
85
        /* Shouldn't happen. */
86
        (*lfn) (LINEAR_DISABLE, 0);
87
        return -1;
88
    }
89
 
90
    __svgalib_modeinfo_linearset |= IS_LINEAR | LINEAR_MODE;
91
 
92
    graph_mem = LINEAR_POINTER;
93
 
94
    return __svgalib_linear_mem_size; /* Who cares? */
95
}