xref: /openbmc/qemu/include/hw/display/macfb.h (revision e4082063)
1 /*
2  * QEMU Motorola 680x0 Macintosh Video Card Emulation
3  *                 Copyright (c) 2012-2018 Laurent Vivier
4  *
5  * some parts from QEMU G364 framebuffer Emulator.
6  *                 Copyright (c) 2007-2011 Herve Poussineau
7  *
8  * This work is licensed under the terms of the GNU GPL, version 2 or later.
9  * See the COPYING file in the top-level directory.
10  *
11  */
12 
13 #ifndef MACFB_H
14 #define MACFB_H
15 
16 #include "exec/memory.h"
17 #include "hw/irq.h"
18 #include "ui/console.h"
19 #include "qemu/timer.h"
20 #include "qom/object.h"
21 
22 typedef enum  {
23     MACFB_DISPLAY_APPLE_21_COLOR = 0,
24     MACFB_DISPLAY_APPLE_PORTRAIT = 1,
25     MACFB_DISPLAY_APPLE_12_RGB = 2,
26     MACFB_DISPLAY_APPLE_2PAGE_MONO = 3,
27     MACFB_DISPLAY_NTSC_UNDERSCAN = 4,
28     MACFB_DISPLAY_NTSC_OVERSCAN = 5,
29     MACFB_DISPLAY_APPLE_12_MONO = 6,
30     MACFB_DISPLAY_APPLE_13_RGB = 7,
31     MACFB_DISPLAY_16_COLOR = 8,
32     MACFB_DISPLAY_PAL1_UNDERSCAN = 9,
33     MACFB_DISPLAY_PAL1_OVERSCAN = 10,
34     MACFB_DISPLAY_PAL2_UNDERSCAN = 11,
35     MACFB_DISPLAY_PAL2_OVERSCAN = 12,
36     MACFB_DISPLAY_VGA = 13,
37     MACFB_DISPLAY_SVGA = 14,
38 } MacfbDisplayType;
39 
40 typedef struct MacFbMode {
41     uint8_t type;
42     uint8_t depth;
43     uint32_t mode_ctrl1;
44     uint32_t mode_ctrl2;
45     uint32_t width;
46     uint32_t height;
47     uint32_t stride;
48     uint32_t offset;
49 } MacFbMode;
50 
51 #define MACFB_CTRL_TOPADDR  0x200
52 #define MACFB_NUM_REGS      (MACFB_CTRL_TOPADDR / sizeof(uint32_t))
53 
54 typedef struct MacfbState {
55     MemoryRegion mem_vram;
56     MemoryRegion mem_ctrl;
57     QemuConsole *con;
58 
59     uint8_t *vram;
60     uint32_t vram_bit_mask;
61     uint32_t palette_current;
62     uint8_t color_palette[256 * 3];
63     uint32_t width, height; /* in pixels */
64     uint8_t depth;
65     uint8_t type;
66 
67     uint32_t regs[MACFB_NUM_REGS];
68     MacFbMode *mode;
69 
70     QEMUTimer *vbl_timer;
71     qemu_irq irq;
72 } MacfbState;
73 
74 #define TYPE_MACFB "sysbus-macfb"
75 OBJECT_DECLARE_SIMPLE_TYPE(MacfbSysBusState, MACFB)
76 
77 struct MacfbSysBusState {
78     SysBusDevice busdev;
79 
80     MacfbState macfb;
81 };
82 
83 #define TYPE_NUBUS_MACFB "nubus-macfb"
84 OBJECT_DECLARE_TYPE(MacfbNubusState, MacfbNubusDeviceClass, NUBUS_MACFB)
85 
86 struct MacfbNubusDeviceClass {
87     DeviceClass parent_class;
88 
89     DeviceRealize parent_realize;
90     DeviceUnrealize parent_unrealize;
91 };
92 
93 
94 struct MacfbNubusState {
95     NubusDevice busdev;
96 
97     MacfbState macfb;
98 };
99 
100 #endif
101