aboutsummaryrefslogtreecommitdiff
path: root/include/hw/display/macfb.h
blob: 55a50d3fb0421dd503e229cc4138a3d876a3ca0d (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * QEMU Motorola 680x0 Macintosh Video Card Emulation
 *                 Copyright (c) 2012-2018 Laurent Vivier
 *
 * some parts from QEMU G364 framebuffer Emulator.
 *                 Copyright (c) 2007-2011 Herve Poussineau
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 *
 */

#ifndef MACFB_H
#define MACFB_H

#include "exec/memory.h"
#include "hw/irq.h"
#include "ui/console.h"
#include "qemu/timer.h"
#include "qom/object.h"

typedef enum  {
    MACFB_DISPLAY_APPLE_21_COLOR = 0,
    MACFB_DISPLAY_APPLE_PORTRAIT = 1,
    MACFB_DISPLAY_APPLE_12_RGB = 2,
    MACFB_DISPLAY_APPLE_2PAGE_MONO = 3,
    MACFB_DISPLAY_NTSC_UNDERSCAN = 4,
    MACFB_DISPLAY_NTSC_OVERSCAN = 5,
    MACFB_DISPLAY_APPLE_12_MONO = 6,
    MACFB_DISPLAY_APPLE_13_RGB = 7,
    MACFB_DISPLAY_16_COLOR = 8,
    MACFB_DISPLAY_PAL1_UNDERSCAN = 9,
    MACFB_DISPLAY_PAL1_OVERSCAN = 10,
    MACFB_DISPLAY_PAL2_UNDERSCAN = 11,
    MACFB_DISPLAY_PAL2_OVERSCAN = 12,
    MACFB_DISPLAY_VGA = 13,
    MACFB_DISPLAY_SVGA = 14,
} MacfbDisplayType;

typedef struct MacFbMode {
    uint8_t type;
    uint8_t depth;
    uint32_t mode_ctrl1;
    uint32_t mode_ctrl2;
    uint32_t width;
    uint32_t height;
    uint32_t stride;
    uint32_t offset;
} MacFbMode;

#define MACFB_CTRL_TOPADDR  0x200
#define MACFB_NUM_REGS      (MACFB_CTRL_TOPADDR / sizeof(uint32_t))

typedef struct MacfbState {
    MemoryRegion mem_vram;
    MemoryRegion mem_ctrl;
    QemuConsole *con;

    uint8_t *vram;
    uint32_t vram_bit_mask;
    uint32_t palette_current;
    uint8_t color_palette[256 * 3];
    uint32_t width, height; /* in pixels */
    uint8_t depth;
    uint8_t type;

    uint32_t regs[MACFB_NUM_REGS];
    MacFbMode *mode;

    QEMUTimer *vbl_timer;
    qemu_irq irq;
} MacfbState;

#define TYPE_MACFB "sysbus-macfb"
OBJECT_DECLARE_SIMPLE_TYPE(MacfbSysBusState, MACFB)

struct MacfbSysBusState {
    SysBusDevice busdev;

    MacfbState macfb;
};

#define TYPE_NUBUS_MACFB "nubus-macfb"
OBJECT_DECLARE_TYPE(MacfbNubusState, MacfbNubusDeviceClass, NUBUS_MACFB)

struct MacfbNubusDeviceClass {
    DeviceClass parent_class;

    DeviceRealize parent_realize;
    DeviceUnrealize parent_unrealize;
};


struct MacfbNubusState {
    NubusDevice busdev;

    MacfbState macfb;
};

#endif