summaryrefslogtreecommitdiff
path: root/hw/kdrive/neomagic/backend.c
blob: 3fb502d717ed5921697c137f26dd9dd3e68fb62c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Generic card driving functions.
 * Essentially, cascades calls to fbdev and vesa to initialize cards that
 * do not have hardware-specific routines yet. Copied from the ati driver.
 *
 * Copyright (c) 2004 Brent Cook <busterb@mail.utexas.edu>
 *
 * This code is licensed under the GPL.  See the file COPYING in the root
 * directory of the sources for details.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "backend.h"

Bool
backendInitialize(KdCardInfo *card, BackendCard *backend)
{
    Bool success = FALSE;

#ifdef KDRIVEFBDEV
    if (!success && fbdevInitialize(card, &backend->priv.fbdev)) {
        success = TRUE;
        backend->type = FBDEV;
        backend->cardfini = fbdevCardFini;
        backend->scrfini = fbdevScreenFini;
        backend->initScreen = fbdevInitScreen;
        backend->finishInitScreen = fbdevFinishInitScreen;
        backend->createRes = fbdevCreateResources;
        backend->preserve = fbdevPreserve;
        backend->restore = fbdevRestore;
        backend->dpms = fbdevDPMS;
        backend->enable = fbdevEnable;
        backend->disable = fbdevDisable;
        backend->getColors = fbdevGetColors;
        backend->putColors = fbdevPutColors;
    }
#endif
#ifdef KDRIVEVESA
    if (!success && vesaInitialize(card, &backend->priv.vesa)) {
        success = TRUE;
        backend->type = VESA;
        backend->cardfini = vesaCardFini;
        backend->scrfini = vesaScreenFini;
        backend->initScreen = vesaInitScreen;
        backend->finishInitScreen = vesaFinishInitScreen;
        backend->createRes = vesaCreateResources;
        backend->preserve = vesaPreserve;
        backend->restore = vesaRestore;
        backend->dpms = vesaDPMS;
        backend->enable = vesaEnable;
        backend->disable = vesaDisable;
        backend->getColors = vesaGetColors;
        backend->putColors = vesaPutColors;
    }
#endif
    return success;
}

Bool
backendScreenInitialize(KdScreenInfo *screen, BackendScreen *backendScreen,
                        BackendCard *backendCard)
{
    Bool success = FALSE;

#ifdef KDRIVEFBDEV
    if (backendCard->type == FBDEV) {
        screen->card->driver = &backendCard->priv.fbdev;
        success = fbdevScreenInitialize(screen, &backendScreen->fbdev);
        screen->memory_size = backendCard->priv.fbdev.fix.smem_len;
        screen->off_screen_base = backendCard->priv.fbdev.var.yres_virtual
                                * screen->fb[0].byteStride;
    }
#endif
#ifdef KDRIVEVESA
    if (backendCard->type == VESA) {
		screen->card->driver = &backendCard->priv.vesa;
        if (screen->fb[0].depth == 0) {
            screen->fb[0].depth = 16;
        }
        success = vesaScreenInitialize(screen, &backendScreen->vesa);
    }
#endif
    return success;
}