qemu/include/hw/display/macfb.h
Mark Cave-Ayland df8abbbadf macfb: add common monitor modes supported by the MacOS toolbox ROM
The monitor modes table is found by experimenting with the Monitors Control
Panel in MacOS and analysing the reads/writes. From this it can be found that
the mode is controlled by writes to the DAFB_MODE_CTRL1 and DAFB_MODE_CTRL2
registers.

Implement the first block of DAFB registers as a register array including the
existing sense register, the newly discovered control registers above, and also
the DAFB_MODE_VADDR1 and DAFB_MODE_VADDR2 registers which are used by NetBSD to
determine the current video mode.

These experiments also show that the offset of the start of video RAM and the
stride can change depending upon the monitor mode, so update macfb_draw_graphic()
and both the BI_MAC_VADDR and BI_MAC_VROW bootinfo for the q800 machine
accordingly.

Finally update macfb_common_realize() so that only the resolution and depth
supported by the display type can be specified on the command line, and add an
error hint showing the list of supported resolutions and depths if the user tries
to specify an invalid display mode.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20211007221253.29024-10-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2021-10-08 13:31:03 +02:00

93 lines
2.1 KiB
C

/*
* 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 "ui/console.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_NUM_REGS 8
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;
} 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;
};
struct MacfbNubusState {
NubusDevice busdev;
MacfbState macfb;
};
#endif