From 8387170d1b202052db47f3b92777becf86594fcd Mon Sep 17 00:00:00 2001 From: Chunmei Xu Date: Wed, 19 Apr 2023 14:52:07 +0800 Subject: [PATCH] make build fit ld -z now and make modesetting link gbm Signed-off-by: Chunmei Xu --- 1000-meson-Fix-libshadow.so-linkage.patch | 30 + 1001-xfree86-Link-fb-statically.patch | 152 + 1002-xfree86-Merge-vbe-into-int10.patch | 4393 +++++++++++++++++ ...LoaderSymbolFromModule-to-public-API.patch | 40 + ...rect-the-shadow-API-through-LoaderSy.patch | 143 + ...rect-the-glamor-API-through-LoaderSy.patch | 322 ++ 1006-link-gbm-lib.patch | 26 + 1007-do-not-link-glamor-directly.patch | 66 + ...clear_pixmap-in-drmmode_clear_pixmap.patch | 60 + 1009-Fix-build-with-glamor-disabled.patch | 93 + ...ymbolFromModule-take-a-ModuleDescPtr.patch | 48 + xorg-x11-server.spec | 22 +- 12 files changed, 5392 insertions(+), 3 deletions(-) create mode 100644 1000-meson-Fix-libshadow.so-linkage.patch create mode 100644 1001-xfree86-Link-fb-statically.patch create mode 100644 1002-xfree86-Merge-vbe-into-int10.patch create mode 100644 1003-loader-Move-LoaderSymbolFromModule-to-public-API.patch create mode 100644 1004-modesetting-Indirect-the-shadow-API-through-LoaderSy.patch create mode 100644 1005-modesetting-Indirect-the-glamor-API-through-LoaderSy.patch create mode 100644 1006-link-gbm-lib.patch create mode 100644 1007-do-not-link-glamor-directly.patch create mode 100644 1008-Use-glamor_clear_pixmap-in-drmmode_clear_pixmap.patch create mode 100644 1009-Fix-build-with-glamor-disabled.patch create mode 100644 1010-Make-LoaderSymbolFromModule-take-a-ModuleDescPtr.patch diff --git a/1000-meson-Fix-libshadow.so-linkage.patch b/1000-meson-Fix-libshadow.so-linkage.patch new file mode 100644 index 0000000..733a8d3 --- /dev/null +++ b/1000-meson-Fix-libshadow.so-linkage.patch @@ -0,0 +1,30 @@ +From e064488cdcfd57ececf820716a3264ac9073b6ca Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Tue, 30 Apr 2019 18:01:27 -0400 +Subject: [PATCH 1000/1005] meson: Fix libshadow.so linkage + +Don't link against fb, it's the driver's responsibility to load that +first. Underlinking like this is unpleasant but this matches what +autotools does. + +Fixes: xorg/xserver#540 +--- + hw/xfree86/dixmods/meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/xfree86/dixmods/meson.build b/hw/xfree86/dixmods/meson.build +index 835d232..0562b63 100644 +--- a/hw/xfree86/dixmods/meson.build ++++ b/hw/xfree86/dixmods/meson.build +@@ -34,7 +34,7 @@ shared_module( + c_args: xorg_c_args, + dependencies: common_dep, + link_whole: libxserver_miext_shadow, +- link_with: [fb, e], ++ link_with: e, + + install: true, + install_dir: module_dir, +-- +1.8.3.1 + diff --git a/1001-xfree86-Link-fb-statically.patch b/1001-xfree86-Link-fb-statically.patch new file mode 100644 index 0000000..60c4711 --- /dev/null +++ b/1001-xfree86-Link-fb-statically.patch @@ -0,0 +1,152 @@ +From 2dd9804720bb4a7d5d9295240a4d070e1569d863 Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Tue, 23 Jul 2019 11:54:15 -0400 +Subject: [PATCH 1001/1005] xfree86: Link fb statically + +There's no real benefit to leaving this loadable, virtually every driver +is going to load it. + +Reviewed-by: Jon Turney +--- + hw/xfree86/Makefile.am | 1 + + hw/xfree86/dixmods/Makefile.am | 8 +------- + hw/xfree86/dixmods/meson.build | 14 -------------- + hw/xfree86/drivers/modesetting/meson.build | 1 - + hw/xfree86/loader/loadmod.c | 1 + + hw/xfree86/meson.build | 1 + + hw/xfree86/sdksyms.sh | 6 +++--- + test/Makefile.am | 1 + + 8 files changed, 8 insertions(+), 25 deletions(-) + +diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am +index 9aeaea1..1d494cd 100644 +--- a/hw/xfree86/Makefile.am ++++ b/hw/xfree86/Makefile.am +@@ -75,6 +75,7 @@ LOCAL_LIBS = \ + $(DRI2_LIB) \ + $(DRI3_LIB) \ + $(GLXVND_LIB) \ ++ $(top_builddir)/fb/libfb.la \ + $(top_builddir)/miext/sync/libsync.la \ + $(top_builddir)/mi/libmi.la \ + $(top_builddir)/os/libos.la \ +diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am +index 856659f..a1f9705 100644 +--- a/hw/xfree86/dixmods/Makefile.am ++++ b/hw/xfree86/dixmods/Makefile.am +@@ -4,8 +4,7 @@ if GLX + GLXMODS = libglx.la + endif + +-module_LTLIBRARIES = libfb.la \ +- libwfb.la \ ++module_LTLIBRARIES = libwfb.la \ + libshadow.la + + extsmoduledir = $(moduledir)/extensions +@@ -17,11 +16,6 @@ AM_CPPFLAGS = @XORG_INCS@ \ + -I$(top_srcdir)/miext/shadow \ + -I$(top_srcdir)/glx + +-libfb_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG) +-libfb_la_LIBADD = $(top_builddir)/fb/libfb.la +-libfb_la_SOURCES = fbmodule.c +-libfb_la_CFLAGS = $(AM_CFLAGS) +- + libwfb_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG) + libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la + libwfb_la_SOURCES = fbmodule.c +diff --git a/hw/xfree86/dixmods/meson.build b/hw/xfree86/dixmods/meson.build +index 0562b63..e4ac022 100644 +--- a/hw/xfree86/dixmods/meson.build ++++ b/hw/xfree86/dixmods/meson.build +@@ -1,17 +1,3 @@ +-fb = shared_module( +- 'fb', +- 'fbmodule.c', +- +- include_directories: [inc, xorg_inc], +- c_args: xorg_c_args, +- dependencies: common_dep, +- link_whole: libxserver_fb, +- link_with: e, +- +- install: true, +- install_dir: module_dir, +-) +- + shared_module( + 'wfb', + 'fbmodule.c', +diff --git a/hw/xfree86/drivers/modesetting/meson.build b/hw/xfree86/drivers/modesetting/meson.build +index 5e13f1a..02852a7 100644 +--- a/hw/xfree86/drivers/modesetting/meson.build ++++ b/hw/xfree86/drivers/modesetting/meson.build +@@ -30,7 +30,6 @@ shared_module( + xorg_build_root = join_paths(meson.build_root(), 'hw', 'xfree86') + symbol_test_args = [] + symbol_test_args += join_paths(xorg_build_root, 'libxorgserver.so') +-symbol_test_args += join_paths(xorg_build_root, 'dixmods', 'libfb.so') + symbol_test_args += join_paths(xorg_build_root, 'dixmods', 'libshadow.so') + if gbm_dep.found() + symbol_test_args += join_paths(xorg_build_root, 'glamor_egl', 'libglamoregl.so') +diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c +index a6356bd..f0983b2 100644 +--- a/hw/xfree86/loader/loadmod.c ++++ b/hw/xfree86/loader/loadmod.c +@@ -621,6 +621,7 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) + + static const char *compiled_in_modules[] = { + "ddc", ++ "fb", + "i2c", + "ramdac", + "dbe", +diff --git a/hw/xfree86/meson.build b/hw/xfree86/meson.build +index cacf56d..c80964e 100644 +--- a/hw/xfree86/meson.build ++++ b/hw/xfree86/meson.build +@@ -61,6 +61,7 @@ xorg_link = [ + xorg_os_support, + xorg_parser, + xorg_ramdac, ++ libxserver_fb, + libxserver_xext_vidmode, + libxserver_main, + libxserver_config, +diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh +index 7897aae..2ebc4c0 100755 +--- a/hw/xfree86/sdksyms.sh ++++ b/hw/xfree86/sdksyms.sh +@@ -21,13 +21,13 @@ cat > sdksyms.c << EOF + #include "picturestr.h" + + +-/* fb/Makefile.am -- module */ +-/* ++/* fb/Makefile.am */ + #include "fb.h" + #include "fbrop.h" + #include "fboverlay.h" +-#include "wfbrename.h" + #include "fbpict.h" ++/* wfb is still a module ++#include "wfbrename.h" + */ + + +diff --git a/test/Makefile.am b/test/Makefile.am +index 12ac327..ce07c35 100644 +--- a/test/Makefile.am ++++ b/test/Makefile.am +@@ -146,6 +146,7 @@ tests_LDADD += \ + $(top_builddir)/hw/xfree86/i2c/libi2c.la \ + $(top_builddir)/hw/xfree86/xkb/libxorgxkb.la \ + $(top_builddir)/Xext/libXvidmode.la \ ++ $(top_builddir)/fb/libfb.la \ + $(XSERVER_LIBS) \ + $(XORG_LIBS) + +-- +1.8.3.1 + diff --git a/1002-xfree86-Merge-vbe-into-int10.patch b/1002-xfree86-Merge-vbe-into-int10.patch new file mode 100644 index 0000000..58c3b84 --- /dev/null +++ b/1002-xfree86-Merge-vbe-into-int10.patch @@ -0,0 +1,4393 @@ +From bad0f343a077a0f70c6c8498444731488b0b6ee2 Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Tue, 23 Jul 2019 14:33:45 -0400 +Subject: [PATCH 1002/1005] xfree86: Merge vbe into int10 + +There's not really a good reason to keep these separate, the vbe code +requires int10 and is not very large. This change eliminates the +build-time options for vbe; if you build int10, you get vbe. + +Gitlab: https://gitlab.freedesktop.org/xorg/xserver/issues/692 +Reviewed-by: Emil Velikov +--- + Makefile.am | 1 - + configure.ac | 5 - + hw/xfree86/Makefile.am | 8 +- + hw/xfree86/int10/Makefile.am | 7 +- + hw/xfree86/int10/meson.build | 4 + + hw/xfree86/int10/vbe.c | 1096 ++++++++++++++++++++++++++++++++++++++++++ + hw/xfree86/int10/vbe.h | 357 ++++++++++++++ + hw/xfree86/int10/vbeModes.c | 453 +++++++++++++++++ + hw/xfree86/int10/vbeModes.h | 94 ++++ + hw/xfree86/loader/loadmod.c | 4 + + hw/xfree86/meson.build | 4 - + hw/xfree86/sdksyms.sh | 9 +- + hw/xfree86/vbe/Makefile.am | 14 - + hw/xfree86/vbe/meson.build | 10 - + hw/xfree86/vbe/vbe.c | 1096 ------------------------------------------ + hw/xfree86/vbe/vbe.h | 357 -------------- + hw/xfree86/vbe/vbeModes.c | 453 ----------------- + hw/xfree86/vbe/vbeModes.h | 94 ---- + hw/xfree86/vbe/vbe_module.c | 22 - + meson.build | 11 - + meson_options.txt | 2 - + 21 files changed, 2017 insertions(+), 2084 deletions(-) + create mode 100644 hw/xfree86/int10/vbe.c + create mode 100644 hw/xfree86/int10/vbe.h + create mode 100644 hw/xfree86/int10/vbeModes.c + create mode 100644 hw/xfree86/int10/vbeModes.h + delete mode 100644 hw/xfree86/vbe/Makefile.am + delete mode 100644 hw/xfree86/vbe/meson.build + delete mode 100644 hw/xfree86/vbe/vbe.c + delete mode 100644 hw/xfree86/vbe/vbe.h + delete mode 100644 hw/xfree86/vbe/vbeModes.c + delete mode 100644 hw/xfree86/vbe/vbeModes.h + delete mode 100644 hw/xfree86/vbe/vbe_module.c + +diff --git a/Makefile.am b/Makefile.am +index 19511f7..0c557c4 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -181,7 +181,6 @@ EXTRA_DIST += \ + hw/xfree86/parser/meson.build \ + hw/xfree86/ramdac/meson.build \ + hw/xfree86/shadowfb/meson.build \ +- hw/xfree86/vbe/meson.build \ + hw/xfree86/vgahw/meson.build \ + hw/xfree86/x86emu/meson.build \ + hw/xfree86/xkb/meson.build \ +diff --git a/configure.ac b/configure.ac +index 2349320..1f0e42d 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -577,7 +577,6 @@ AC_ARG_ENABLE(config-hal, AS_HELP_STRING([--disable-config-hal], [Build HAL + AC_ARG_ENABLE(config-wscons, AS_HELP_STRING([--enable-config-wscons], [Build wscons config support (default: auto)]), [CONFIG_WSCONS=$enableval], [CONFIG_WSCONS=auto]) + AC_ARG_ENABLE(xfree86-utils, AS_HELP_STRING([--enable-xfree86-utils], [Build xfree86 DDX utilities (default: enabled)]), [XF86UTILS=$enableval], [XF86UTILS=yes]) + AC_ARG_ENABLE(vgahw, AS_HELP_STRING([--enable-vgahw], [Build Xorg with vga access (default: enabled)]), [VGAHW=$enableval], [VGAHW=yes]) +-AC_ARG_ENABLE(vbe, AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), [VBE=$enableval], [VBE=yes]) + AC_ARG_ENABLE(int10-module, AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes]) + AC_ARG_ENABLE(windowswm, AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no]) + AC_ARG_ENABLE(windowsdri, AS_HELP_STRING([--enable-windowsdri], [Build XWin with WindowsDRI extension (default: auto)]), [WINDOWSDRI=$enableval], [WINDOWSDRI=auto]) +@@ -669,7 +668,6 @@ case $host_os in + INT10MODULE=no + PCI=no + VGAHW=no +- VBE=no + XF86UTILS=no + XF86VIDMODE=no + XSELINUX=no +@@ -679,7 +677,6 @@ case $host_os in + PCI=no + INT10MODULE=no + VGAHW=no +- VBE=no + DRM=no + DRI2=no + DRI3=no +@@ -1353,7 +1350,6 @@ XI_INC='-I$(top_srcdir)/Xi' + + AM_CONDITIONAL(XF86UTILS, test "x$XF86UTILS" = xyes) + AM_CONDITIONAL(VGAHW, test "x$VGAHW" = xyes) +-AM_CONDITIONAL(VBE, test "x$VBE" = xyes) + AM_CONDITIONAL(INT10MODULE, test "x$INT10MODULE" = xyes) + + AC_DEFINE(SHAPE, 1, [Support SHAPE extension]) +@@ -2509,7 +2505,6 @@ hw/xfree86/os-support/stub/Makefile + hw/xfree86/parser/Makefile + hw/xfree86/ramdac/Makefile + hw/xfree86/shadowfb/Makefile +-hw/xfree86/vbe/Makefile + hw/xfree86/vgahw/Makefile + hw/xfree86/x86emu/Makefile + hw/xfree86/xkb/Makefile +diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am +index 1d494cd..baf380d 100644 +--- a/hw/xfree86/Makefile.am ++++ b/hw/xfree86/Makefile.am +@@ -30,22 +30,18 @@ if VGAHW + VGAHW_SUBDIR = vgahw + endif + +-if VBE +-VBE_SUBDIR = vbe +-endif +- + if INT10MODULE + INT10_SUBDIR = int10 + endif + + SUBDIRS = common ddc x86emu $(INT10_SUBDIR) os-support parser \ + ramdac $(VGAHW_SUBDIR) loader modes $(DRI_SUBDIR) \ +- $(DRI2_SUBDIR) . $(VBE_SUBDIR) i2c dixmods xkb \ ++ $(DRI2_SUBDIR) . i2c dixmods xkb \ + fbdevhw shadowfb exa $(XF86UTILS_SUBDIR) doc man \ + $(GLAMOR_EGL_SUBDIR) drivers + + DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \ +- parser ramdac shadowfb vbe vgahw \ ++ parser ramdac shadowfb vgahw \ + loader dixmods xkb dri dri2 exa modes \ + utils doc man glamor_egl drivers + +diff --git a/hw/xfree86/int10/Makefile.am b/hw/xfree86/int10/Makefile.am +index 66cb14d..0248dc7 100644 +--- a/hw/xfree86/int10/Makefile.am ++++ b/hw/xfree86/int10/Makefile.am +@@ -1,6 +1,6 @@ + module_LTLIBRARIES = libint10.la + +-sdk_HEADERS = xf86int10.h ++sdk_HEADERS = xf86int10.h vbe.h vbeModes.h + + EXTRA_CFLAGS = + +@@ -8,6 +8,8 @@ libint10_la_LDFLAGS = -avoid-version + libint10_la_LIBADD = $(PCIACCESS_LIBS) + + COMMON_SOURCES = \ ++ vbe.c \ ++ vbeModes.c \ + helper_exec.c \ + helper_mem.c \ + xf86int10.c \ +@@ -17,7 +19,8 @@ if I386_VIDEO + I386_VIDEO_CFLAGS = -D_PC + endif + +-AM_CPPFLAGS = $(XORG_INCS) ++AM_CPPFLAGS = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../modes -I$(srcdir)/../i2c \ ++ -I$(srcdir)/../parser + + if INT10_VM86 + AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) +diff --git a/hw/xfree86/int10/meson.build b/hw/xfree86/int10/meson.build +index b1ead9c..a309e9b 100644 +--- a/hw/xfree86/int10/meson.build ++++ b/hw/xfree86/int10/meson.build +@@ -1,4 +1,6 @@ + srcs_xorg_int10 = [ ++ 'vbe.c', ++ 'vbeModes.c', + 'helper_exec.c', + 'helper_mem.c', + 'xf86int10.c', +@@ -58,3 +60,5 @@ xorg_int10 = shared_module('int10', + ) + + install_data('xf86int10.h', install_dir: xorgsdkdir) ++install_data('vbe.h', install_dir: xorgsdkdir) ++install_data('vbeModes.h', install_dir: xorgsdkdir) +diff --git a/hw/xfree86/int10/vbe.c b/hw/xfree86/int10/vbe.c +new file mode 100644 +index 0000000..d23e0f5 +--- /dev/null ++++ b/hw/xfree86/int10/vbe.c +@@ -0,0 +1,1096 @@ ++ ++/* ++ * XFree86 vbe module ++ * Copyright 2000 Egbert Eich ++ * ++ * The mode query/save/set/restore functions from the vesa driver ++ * have been moved here. ++ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) ++ * Authors: Paulo César Pereira de Andrade ++ */ ++ ++#ifdef HAVE_XORG_CONFIG_H ++#include ++#endif ++ ++#include ++ ++#include "xf86.h" ++#include "xf86Modes.h" ++#include "vbe.h" ++#include ++ ++#define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x) ++ ++#if X_BYTE_ORDER == X_LITTLE_ENDIAN ++#define B_O16(x) (x) ++#define B_O32(x) (x) ++#else ++#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8)) ++#define B_O32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \ ++ | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24)) ++#endif ++#define L_ADD(x) (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00) ++ ++#define FARP(p) (((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff)) ++#define R16(v) ((v) & 0xffff) ++ ++static unsigned char *vbeReadEDID(vbeInfoPtr pVbe); ++static Bool vbeProbeDDC(vbeInfoPtr pVbe); ++ ++static const char vbeVersionString[] = "VBE2"; ++ ++vbeInfoPtr ++VBEInit(xf86Int10InfoPtr pInt, int entityIndex) ++{ ++ return VBEExtendedInit(pInt, entityIndex, 0); ++} ++ ++vbeInfoPtr ++VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags) ++{ ++ int RealOff; ++ void *page = NULL; ++ ScrnInfoPtr pScrn = xf86FindScreenForEntity(entityIndex); ++ vbeControllerInfoPtr vbe = NULL; ++ Bool init_int10 = FALSE; ++ vbeInfoPtr vip = NULL; ++ int screen; ++ ++ if (!pScrn) ++ return NULL; ++ screen = pScrn->scrnIndex; ++ ++ if (!pInt) { ++ if (!xf86LoadSubModule(pScrn, "int10")) ++ goto error; ++ ++ xf86DrvMsg(screen, X_INFO, "initializing int10\n"); ++ pInt = xf86ExtendedInitInt10(entityIndex, Flags); ++ if (!pInt) ++ goto error; ++ init_int10 = TRUE; ++ } ++ ++ page = xf86Int10AllocPages(pInt, 1, &RealOff); ++ if (!page) ++ goto error; ++ vbe = (vbeControllerInfoPtr) page; ++ memcpy(vbe->VbeSignature, vbeVersionString, 4); ++ ++ pInt->ax = 0x4F00; ++ pInt->es = SEG_ADDR(RealOff); ++ pInt->di = SEG_OFF(RealOff); ++ pInt->num = 0x10; ++ ++ xf86ExecX86int10(pInt); ++ ++ if ((pInt->ax & 0xff) != 0x4f) { ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA BIOS not detected\n"); ++ goto error; ++ } ++ ++ switch (pInt->ax & 0xff00) { ++ case 0: ++ xf86DrvMsg(screen, X_INFO, "VESA BIOS detected\n"); ++ break; ++ case 0x100: ++ xf86DrvMsg(screen, X_INFO, "VESA BIOS function failed\n"); ++ goto error; ++ case 0x200: ++ xf86DrvMsg(screen, X_INFO, "VESA BIOS not supported\n"); ++ goto error; ++ case 0x300: ++ xf86DrvMsg(screen, X_INFO, "VESA BIOS not supported in current mode\n"); ++ goto error; ++ default: ++ xf86DrvMsg(screen, X_INFO, "Invalid\n"); ++ goto error; ++ } ++ ++ xf86DrvMsgVerb(screen, X_INFO, 4, ++ "VbeVersion is %d, OemStringPtr is 0x%08lx,\n" ++ "\tOemVendorNamePtr is 0x%08lx, OemProductNamePtr is 0x%08lx,\n" ++ "\tOemProductRevPtr is 0x%08lx\n", ++ vbe->VbeVersion, (unsigned long) vbe->OemStringPtr, ++ (unsigned long) vbe->OemVendorNamePtr, ++ (unsigned long) vbe->OemProductNamePtr, ++ (unsigned long) vbe->OemProductRevPtr); ++ ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE Version %i.%i\n", ++ VERSION(vbe->VbeVersion)); ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE Total Mem: %i kB\n", ++ vbe->TotalMem * 64); ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM: %s\n", ++ (CARD8 *) xf86int10Addr(pInt, L_ADD(vbe->OemStringPtr))); ++ ++ if (B_O16(vbe->VbeVersion) >= 0x200) { ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Software Rev: %i.%i\n", ++ VERSION(vbe->OemSoftwareRev)); ++ if (vbe->OemVendorNamePtr) ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Vendor: %s\n", ++ (CARD8 *) xf86int10Addr(pInt, ++ L_ADD(vbe-> ++ OemVendorNamePtr))); ++ if (vbe->OemProductNamePtr) ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Product: %s\n", ++ (CARD8 *) xf86int10Addr(pInt, ++ L_ADD(vbe-> ++ OemProductNamePtr))); ++ if (vbe->OemProductRevPtr) ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Product Rev: %s\n", ++ (CARD8 *) xf86int10Addr(pInt, ++ L_ADD(vbe-> ++ OemProductRevPtr))); ++ } ++ vip = (vbeInfoPtr) xnfalloc(sizeof(vbeInfoRec)); ++ vip->version = B_O16(vbe->VbeVersion); ++ vip->pInt10 = pInt; ++ vip->ddc = DDC_UNCHECKED; ++ vip->memory = page; ++ vip->real_mode_base = RealOff; ++ vip->num_pages = 1; ++ vip->init_int10 = init_int10; ++ ++ return vip; ++ ++ error: ++ if (page) ++ xf86Int10FreePages(pInt, page, 1); ++ if (init_int10) ++ xf86FreeInt10(pInt); ++ return NULL; ++} ++ ++void ++vbeFree(vbeInfoPtr pVbe) ++{ ++ if (!pVbe) ++ return; ++ ++ xf86Int10FreePages(pVbe->pInt10, pVbe->memory, pVbe->num_pages); ++ /* If we have initalized int10 we ought to free it, too */ ++ if (pVbe->init_int10) ++ xf86FreeInt10(pVbe->pInt10); ++ free(pVbe); ++ return; ++} ++ ++static Bool ++vbeProbeDDC(vbeInfoPtr pVbe) ++{ ++ const char *ddc_level; ++ int screen = pVbe->pInt10->pScrn->scrnIndex; ++ ++ if (pVbe->ddc == DDC_NONE) ++ return FALSE; ++ if (pVbe->ddc != DDC_UNCHECKED) ++ return TRUE; ++ ++ pVbe->pInt10->ax = 0x4F15; ++ pVbe->pInt10->bx = 0; ++ pVbe->pInt10->cx = 0; ++ pVbe->pInt10->es = 0; ++ pVbe->pInt10->di = 0; ++ pVbe->pInt10->num = 0x10; ++ ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if ((pVbe->pInt10->ax & 0xff) != 0x4f) { ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC not supported\n"); ++ pVbe->ddc = DDC_NONE; ++ return FALSE; ++ } ++ ++ switch ((pVbe->pInt10->ax >> 8) & 0xff) { ++ case 0: ++ xf86DrvMsg(screen, X_INFO, "VESA VBE DDC supported\n"); ++ switch (pVbe->pInt10->bx & 0x3) { ++ case 0: ++ ddc_level = " none"; ++ pVbe->ddc = DDC_NONE; ++ break; ++ case 1: ++ ddc_level = " 1"; ++ pVbe->ddc = DDC_1; ++ break; ++ case 2: ++ ddc_level = " 2"; ++ pVbe->ddc = DDC_2; ++ break; ++ case 3: ++ ddc_level = " 1 + 2"; ++ pVbe->ddc = DDC_1_2; ++ break; ++ default: ++ ddc_level = ""; ++ pVbe->ddc = DDC_NONE; ++ break; ++ } ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC Level%s\n", ddc_level); ++ if (pVbe->pInt10->bx & 0x4) { ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC Screen blanked" ++ "for data transfer\n"); ++ pVbe->ddc_blank = TRUE; ++ } ++ else ++ pVbe->ddc_blank = FALSE; ++ ++ xf86DrvMsgVerb(screen, X_INFO, 3, ++ "VESA VBE DDC transfer in appr. %x sec.\n", ++ (pVbe->pInt10->bx >> 8) & 0xff); ++ } ++ ++ return TRUE; ++} ++ ++typedef enum { ++ VBEOPT_NOVBE, ++ VBEOPT_NODDC ++} VBEOpts; ++ ++static const OptionInfoRec VBEOptions[] = { ++ {VBEOPT_NOVBE, "NoVBE", OPTV_BOOLEAN, {0}, FALSE}, ++ {VBEOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE}, ++ {-1, NULL, OPTV_NONE, {0}, FALSE}, ++}; ++ ++static unsigned char * ++vbeReadEDID(vbeInfoPtr pVbe) ++{ ++ int RealOff = pVbe->real_mode_base; ++ void *page = pVbe->memory; ++ unsigned char *tmp = NULL; ++ Bool novbe = FALSE; ++ Bool noddc = FALSE; ++ ScrnInfoPtr pScrn = pVbe->pInt10->pScrn; ++ int screen = pScrn->scrnIndex; ++ OptionInfoPtr options; ++ ++ if (!page) ++ return NULL; ++ ++ options = xnfalloc(sizeof(VBEOptions)); ++ (void) memcpy(options, VBEOptions, sizeof(VBEOptions)); ++ xf86ProcessOptions(screen, pScrn->options, options); ++ xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe); ++ xf86GetOptValBool(options, VBEOPT_NODDC, &noddc); ++ free(options); ++ if (novbe || noddc) ++ return NULL; ++ ++ if (!vbeProbeDDC(pVbe)) ++ goto error; ++ ++ memset(page, 0, sizeof(vbeInfoPtr)); ++ strcpy(page, vbeVersionString); ++ ++ pVbe->pInt10->ax = 0x4F15; ++ pVbe->pInt10->bx = 0x01; ++ pVbe->pInt10->cx = 0; ++ pVbe->pInt10->dx = 0; ++ pVbe->pInt10->es = SEG_ADDR(RealOff); ++ pVbe->pInt10->di = SEG_OFF(RealOff); ++ pVbe->pInt10->num = 0x10; ++ ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if ((pVbe->pInt10->ax & 0xff) != 0x4f) { ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC invalid\n"); ++ goto error; ++ } ++ switch (pVbe->pInt10->ax & 0xff00) { ++ case 0x0: ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC read successfully\n"); ++ tmp = (unsigned char *) xnfalloc(128); ++ memcpy(tmp, page, 128); ++ break; ++ case 0x100: ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC read failed\n"); ++ break; ++ default: ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC unkown failure %i\n", ++ pVbe->pInt10->ax & 0xff00); ++ break; ++ } ++ ++ error: ++ return tmp; ++} ++ ++xf86MonPtr ++vbeDoEDID(vbeInfoPtr pVbe, void *unused) ++{ ++ unsigned char *DDC_data = NULL; ++ ++ if (!pVbe) ++ return NULL; ++ if (pVbe->version < 0x102) ++ return NULL; ++ ++ DDC_data = vbeReadEDID(pVbe); ++ ++ if (!DDC_data) ++ return NULL; ++ ++ return xf86InterpretEDID(pVbe->pInt10->pScrn->scrnIndex, DDC_data); ++} ++ ++#define GET_UNALIGNED2(x) \ ++ ((*(CARD16*)(x)) | (*(((CARD16*)(x) + 1))) << 16) ++ ++VbeInfoBlock * ++VBEGetVBEInfo(vbeInfoPtr pVbe) ++{ ++ VbeInfoBlock *block = NULL; ++ int i, pStr, pModes; ++ char *str; ++ CARD16 major, *modes; ++ ++ memset(pVbe->memory, 0, sizeof(VbeInfoBlock)); ++ ++ /* ++ Input: ++ AH := 4Fh Super VGA support ++ AL := 00h Return Super VGA information ++ ES:DI := Pointer to buffer ++ ++ Output: ++ AX := status ++ (All other registers are preserved) ++ */ ++ ++ ((char *) pVbe->memory)[0] = 'V'; ++ ((char *) pVbe->memory)[1] = 'B'; ++ ((char *) pVbe->memory)[2] = 'E'; ++ ((char *) pVbe->memory)[3] = '2'; ++ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f00; ++ pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); ++ pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return NULL; ++ ++ block = calloc(sizeof(VbeInfoBlock), 1); ++ block->VESASignature[0] = ((char *) pVbe->memory)[0]; ++ block->VESASignature[1] = ((char *) pVbe->memory)[1]; ++ block->VESASignature[2] = ((char *) pVbe->memory)[2]; ++ block->VESASignature[3] = ((char *) pVbe->memory)[3]; ++ ++ block->VESAVersion = *(CARD16 *) (((char *) pVbe->memory) + 4); ++ major = (unsigned) block->VESAVersion >> 8; ++ ++ pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 6)); ++ str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); ++ block->OEMStringPtr = strdup(str); ++ ++ block->Capabilities[0] = ((char *) pVbe->memory)[10]; ++ block->Capabilities[1] = ((char *) pVbe->memory)[11]; ++ block->Capabilities[2] = ((char *) pVbe->memory)[12]; ++ block->Capabilities[3] = ((char *) pVbe->memory)[13]; ++ ++ pModes = GET_UNALIGNED2((((char *) pVbe->memory) + 14)); ++ modes = xf86int10Addr(pVbe->pInt10, FARP(pModes)); ++ i = 0; ++ while (modes[i] != 0xffff) ++ i++; ++ block->VideoModePtr = xallocarray(i + 1, sizeof(CARD16)); ++ memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i); ++ block->VideoModePtr[i] = 0xffff; ++ ++ block->TotalMemory = *(CARD16 *) (((char *) pVbe->memory) + 18); ++ ++ if (major < 2) ++ memcpy(&block->OemSoftwareRev, ((char *) pVbe->memory) + 20, 236); ++ else { ++ block->OemSoftwareRev = *(CARD16 *) (((char *) pVbe->memory) + 20); ++ pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 22)); ++ str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); ++ block->OemVendorNamePtr = strdup(str); ++ pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 26)); ++ str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); ++ block->OemProductNamePtr = strdup(str); ++ pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 30)); ++ str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); ++ block->OemProductRevPtr = strdup(str); ++ memcpy(&block->Reserved, ((char *) pVbe->memory) + 34, 222); ++ memcpy(&block->OemData, ((char *) pVbe->memory) + 256, 256); ++ } ++ ++ return block; ++} ++ ++void ++VBEFreeVBEInfo(VbeInfoBlock * block) ++{ ++ free(block->OEMStringPtr); ++ free(block->VideoModePtr); ++ if (((unsigned) block->VESAVersion >> 8) >= 2) { ++ free(block->OemVendorNamePtr); ++ free(block->OemProductNamePtr); ++ free(block->OemProductRevPtr); ++ } ++ free(block); ++} ++ ++Bool ++VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock * block) ++{ ++ /* ++ Input: ++ AH := 4Fh Super VGA support ++ AL := 02h Set Super VGA video mode ++ BX := Video mode ++ D0-D8 := Mode number ++ D9-D10 := Reserved (must be 0) ++ D11 := 0 Use current default refresh rate ++ := 1 Use user specified CRTC values for refresh rate ++ D12-13 Reserved for VBE/AF (must be 0) ++ D14 := 0 Use windowed frame buffer model ++ := 1 Use linear/flat frame buffer model ++ D15 := 0 Clear video memory ++ := 1 Don't clear video memory ++ ES:DI := Pointer to VbeCRTCInfoBlock structure ++ ++ Output: AX = Status ++ (All other registers are preserved) ++ */ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f02; ++ pVbe->pInt10->bx = mode; ++ if (block) { ++ pVbe->pInt10->bx |= 1 << 11; ++ memcpy(pVbe->memory, block, sizeof(VbeCRTCInfoBlock)); ++ pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); ++ pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); ++ } ++ else ++ pVbe->pInt10->bx &= ~(1 << 11); ++ ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ return (R16(pVbe->pInt10->ax) == 0x4f); ++} ++ ++Bool ++VBEGetVBEMode(vbeInfoPtr pVbe, int *mode) ++{ ++ /* ++ Input: ++ AH := 4Fh Super VGA support ++ AL := 03h Return current video mode ++ ++ Output: ++ AX := Status ++ BX := Current video mode ++ (All other registers are preserved) ++ */ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f03; ++ ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) == 0x4f) { ++ *mode = R16(pVbe->pInt10->bx); ++ ++ return TRUE; ++ } ++ ++ return FALSE; ++} ++ ++VbeModeInfoBlock * ++VBEGetModeInfo(vbeInfoPtr pVbe, int mode) ++{ ++ VbeModeInfoBlock *block = NULL; ++ ++ memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock)); ++ ++ /* ++ Input: ++ AH := 4Fh Super VGA support ++ AL := 01h Return Super VGA mode information ++ CX := Super VGA video mode ++ (mode number must be one of those returned by Function 0) ++ ES:DI := Pointer to buffer ++ ++ Output: ++ AX := status ++ (All other registers are preserved) ++ */ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f01; ++ pVbe->pInt10->cx = mode; ++ pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); ++ pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); ++ xf86ExecX86int10(pVbe->pInt10); ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return NULL; ++ ++ block = malloc(sizeof(VbeModeInfoBlock)); ++ if (block) ++ memcpy(block, pVbe->memory, sizeof(*block)); ++ ++ return block; ++} ++ ++void ++VBEFreeModeInfo(VbeModeInfoBlock * block) ++{ ++ free(block); ++} ++ ++Bool ++VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function, ++ void **memory, int *size, int *real_mode_pages) ++{ ++ /* ++ Input: ++ AH := 4Fh Super VGA support ++ AL := 04h Save/restore Super VGA video state ++ DL := 00h Return save/restore state buffer size ++ CX := Requested states ++ D0 = Save/restore video hardware state ++ D1 = Save/restore video BIOS data state ++ D2 = Save/restore video DAC state ++ D3 = Save/restore Super VGA state ++ ++ Output: ++ AX = Status ++ BX = Number of 64-byte blocks to hold the state buffer ++ (All other registers are preserved) ++ ++ Input: ++ AH := 4Fh Super VGA support ++ AL := 04h Save/restore Super VGA video state ++ DL := 01h Save Super VGA video state ++ CX := Requested states (see above) ++ ES:BX := Pointer to buffer ++ ++ Output: ++ AX := Status ++ (All other registers are preserved) ++ ++ Input: ++ AH := 4Fh Super VGA support ++ AL := 04h Save/restore Super VGA video state ++ DL := 02h Restore Super VGA video state ++ CX := Requested states (see above) ++ ES:BX := Pointer to buffer ++ ++ Output: ++ AX := Status ++ (All other registers are preserved) ++ */ ++ ++ if ((pVbe->version & 0xff00) > 0x100) { ++ int screen = pVbe->pInt10->pScrn->scrnIndex; ++ ++ if (function == MODE_QUERY || (function == MODE_SAVE && !*memory)) { ++ /* Query amount of memory to save state */ ++ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f04; ++ pVbe->pInt10->dx = 0; ++ pVbe->pInt10->cx = 0x000f; ++ xf86ExecX86int10(pVbe->pInt10); ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return FALSE; ++ ++ if (function == MODE_SAVE) { ++ int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1; ++ ++ if ((*memory = xf86Int10AllocPages(pVbe->pInt10, npages, ++ real_mode_pages)) == NULL) { ++ xf86DrvMsg(screen, X_ERROR, ++ "Cannot allocate memory to save SVGA state.\n"); ++ return FALSE; ++ } ++ } ++ *size = pVbe->pInt10->bx * 64; ++ } ++ ++ /* Save/Restore Super VGA state */ ++ if (function != MODE_QUERY) { ++ ++ if (!*memory) ++ return FALSE; ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f04; ++ switch (function) { ++ case MODE_SAVE: ++ pVbe->pInt10->dx = 1; ++ break; ++ case MODE_RESTORE: ++ pVbe->pInt10->dx = 2; ++ break; ++ case MODE_QUERY: ++ return FALSE; ++ } ++ pVbe->pInt10->cx = 0x000f; ++ ++ pVbe->pInt10->es = SEG_ADDR(*real_mode_pages); ++ pVbe->pInt10->bx = SEG_OFF(*real_mode_pages); ++ xf86ExecX86int10(pVbe->pInt10); ++ return (R16(pVbe->pInt10->ax) == 0x4f); ++ ++ } ++ } ++ return TRUE; ++} ++ ++Bool ++VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window) ++{ ++ /* ++ Input: ++ AH := 4Fh Super VGA support ++ AL := 05h ++ ++ Output: ++ */ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f05; ++ pVbe->pInt10->bx = window; ++ pVbe->pInt10->dx = iBank; ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return FALSE; ++ ++ return TRUE; ++} ++ ++Bool ++VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command, ++ int width, int *pixels, int *bytes, int *max) ++{ ++ if (command < SCANWID_SET || command > SCANWID_GET_MAX) ++ return FALSE; ++ ++ /* ++ Input: ++ AX := 4F06h VBE Set/Get Logical Scan Line Length ++ BL := 00h Set Scan Line Length in Pixels ++ := 01h Get Scan Line Length ++ := 02h Set Scan Line Length in Bytes ++ := 03h Get Maximum Scan Line Length ++ CX := If BL=00h Desired Width in Pixels ++ If BL=02h Desired Width in Bytes ++ (Ignored for Get Functions) ++ ++ Output: ++ AX := VBE Return Status ++ BX := Bytes Per Scan Line ++ CX := Actual Pixels Per Scan Line ++ (truncated to nearest complete pixel) ++ DX := Maximum Number of Scan Lines ++ */ ++ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f06; ++ pVbe->pInt10->bx = command; ++ if (command == SCANWID_SET || command == SCANWID_SET_BYTES) ++ pVbe->pInt10->cx = width; ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return FALSE; ++ ++ if (command == SCANWID_GET || command == SCANWID_GET_MAX) { ++ if (pixels) ++ *pixels = R16(pVbe->pInt10->cx); ++ if (bytes) ++ *bytes = R16(pVbe->pInt10->bx); ++ if (max) ++ *max = R16(pVbe->pInt10->dx); ++ } ++ ++ return TRUE; ++} ++ ++Bool ++VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace) ++{ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f07; ++ pVbe->pInt10->bx = wait_retrace ? 0x80 : 0x00; ++ pVbe->pInt10->cx = x; ++ pVbe->pInt10->dx = y; ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return FALSE; ++ ++ return TRUE; ++} ++ ++Bool ++VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y) ++{ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f07; ++ pVbe->pInt10->bx = 0x01; ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return FALSE; ++ ++ *x = pVbe->pInt10->cx; ++ *y = pVbe->pInt10->dx; ++ ++ return TRUE; ++} ++ ++int ++VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits) ++{ ++ /* ++ Input: ++ AX := 4F08h VBE Set/Get Palette Format ++ BL := 00h Set DAC Palette Format ++ := 01h Get DAC Palette Format ++ BH := Desired bits of color per primary ++ (Set DAC Palette Format only) ++ ++ Output: ++ AX := VBE Return Status ++ BH := Current number of bits of color per primary ++ */ ++ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f08; ++ if (!bits) ++ pVbe->pInt10->bx = 0x01; ++ else ++ pVbe->pInt10->bx = (bits & 0x00ff) << 8; ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return 0; ++ ++ return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff); ++} ++ ++CARD32 * ++VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num, ++ CARD32 *data, Bool secondary, Bool wait_retrace) ++{ ++ /* ++ Input: ++ (16-bit) ++ AX := 4F09h VBE Load/Unload Palette Data ++ BL := 00h Set Palette Data ++ := 01h Get Palette Data ++ := 02h Set Secondary Palette Data ++ := 03h Get Secondary Palette Data ++ := 80h Set Palette Data during Vertical Retrace ++ CX := Number of palette registers to update (to a maximum of 256) ++ DX := First of the palette registers to update (start) ++ ES:DI := Table of palette values (see below for format) ++ ++ Output: ++ AX := VBE Return Status ++ ++ Input: ++ (32-bit) ++ BL := 00h Set Palette Data ++ := 80h Set Palette Data during Vertical Retrace ++ CX := Number of palette registers to update (to a maximum of 256) ++ DX := First of the palette registers to update (start) ++ ES:EDI := Table of palette values (see below for format) ++ DS := Selector for memory mapped registers ++ */ ++ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f09; ++ if (!secondary) ++ pVbe->pInt10->bx = set && wait_retrace ? 0x80 : set ? 0 : 1; ++ else ++ pVbe->pInt10->bx = set ? 2 : 3; ++ pVbe->pInt10->cx = num; ++ pVbe->pInt10->dx = first; ++ pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); ++ pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); ++ if (set) ++ memcpy(pVbe->memory, data, num * sizeof(CARD32)); ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return NULL; ++ ++ if (set) ++ return data; ++ ++ data = xallocarray(num, sizeof(CARD32)); ++ memcpy(data, pVbe->memory, num * sizeof(CARD32)); ++ ++ return data; ++} ++ ++VBEpmi * ++VBEGetVBEpmi(vbeInfoPtr pVbe) ++{ ++ VBEpmi *pmi; ++ ++ /* ++ Input: ++ AH := 4Fh Super VGA support ++ AL := 0Ah Protected Mode Interface ++ BL := 00h Return Protected Mode Table ++ ++ Output: ++ AX := Status ++ ES := Real Mode Segment of Table ++ DI := Offset of Table ++ CX := Lenght of Table including protected mode code in bytes (for copying purposes) ++ (All other registers are preserved) ++ */ ++ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f0a; ++ pVbe->pInt10->bx = 0; ++ pVbe->pInt10->di = 0; ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return NULL; ++ ++ pmi = malloc(sizeof(VBEpmi)); ++ pmi->seg_tbl = R16(pVbe->pInt10->es); ++ pmi->tbl_off = R16(pVbe->pInt10->di); ++ pmi->tbl_len = R16(pVbe->pInt10->cx); ++ ++ return pmi; ++} ++ ++#if 0 ++vbeModeInfoPtr ++VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock * vbe) ++{ ++ vbeModeInfoPtr ModeList = NULL; ++ ++ int i = 0; ++ ++ while (vbe->VideoModePtr[i] != 0xffff) { ++ vbeModeInfoPtr m; ++ VbeModeInfoBlock *mode; ++ int id = vbe->VideoModePtr[i++]; ++ int bpp; ++ ++ if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) ++ continue; ++ ++ bpp = mode->BitsPerPixel; ++ ++ m = xnfcalloc(sizeof(vbeModeInfoRec), 1); ++ m->width = mode->XResolution; ++ m->height = mode->YResolution; ++ m->bpp = bpp; ++ m->n = id; ++ m->next = ModeList; ++ ++ xf86DrvMsgVerb(pVbe->pInt10->pScrn->scrnIndex, X_PROBED, 3, ++ "BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n", ++ m->n, m->width, m->height, m->bpp); ++ ++ ModeList = m; ++ ++ VBEFreeModeInfo(mode); ++ } ++ return ModeList; ++} ++ ++unsigned short ++VBECalcVbeModeIndex(vbeModeInfoPtr m, DisplayModePtr mode, int bpp) ++{ ++ while (m) { ++ if (bpp == m->bpp ++ && mode->HDisplay == m->width && mode->VDisplay == m->height) ++ return m->n; ++ m = m->next; ++ } ++ return 0; ++} ++#endif ++ ++void ++VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr, ++ vbeSaveRestoreFunction function) ++{ ++ Bool SaveSucc = FALSE; ++ ++ if (VBE_VERSION_MAJOR(pVbe->version) > 1 ++ && (function == MODE_SAVE || vbe_sr->pstate)) { ++ if (function == MODE_RESTORE) ++ memcpy(vbe_sr->state, vbe_sr->pstate, vbe_sr->stateSize); ++ ErrorF("VBESaveRestore\n"); ++ if ((VBESaveRestore(pVbe, function, ++ (void *) &vbe_sr->state, ++ &vbe_sr->stateSize, &vbe_sr->statePage))) { ++ if (function == MODE_SAVE) { ++ SaveSucc = TRUE; ++ vbe_sr->stateMode = -1; /* invalidate */ ++ /* don't rely on the memory not being touched */ ++ if (vbe_sr->pstate == NULL) ++ vbe_sr->pstate = malloc(vbe_sr->stateSize); ++ memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize); ++ } ++ ErrorF("VBESaveRestore done with success\n"); ++ return; ++ } ++ ErrorF("VBESaveRestore done\n"); ++ } ++ ++ if (function == MODE_SAVE && !SaveSucc) ++ (void) VBEGetVBEMode(pVbe, &vbe_sr->stateMode); ++ ++ if (function == MODE_RESTORE && vbe_sr->stateMode != -1) ++ VBESetVBEMode(pVbe, vbe_sr->stateMode, NULL); ++ ++} ++ ++int ++VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock) ++{ ++ /* ++ Input: ++ AX := 4F0Bh VBE Get Pixel Clock ++ BL := 00h Get Pixel Clock ++ ECX := pixel clock in units of Hz ++ DX := mode number ++ ++ Output: ++ AX := VBE Return Status ++ ECX := Closest pixel clock ++ */ ++ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f0b; ++ pVbe->pInt10->bx = 0x00; ++ pVbe->pInt10->cx = clock; ++ pVbe->pInt10->dx = mode; ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if (R16(pVbe->pInt10->ax) != 0x4f) ++ return 0; ++ ++ return pVbe->pInt10->cx; ++} ++ ++Bool ++VBEDPMSSet(vbeInfoPtr pVbe, int mode) ++{ ++ /* ++ Input: ++ AX := 4F10h DPMS ++ BL := 01h Set Display Power State ++ BH := requested power state ++ ++ Output: ++ AX := VBE Return Status ++ */ ++ ++ pVbe->pInt10->num = 0x10; ++ pVbe->pInt10->ax = 0x4f10; ++ pVbe->pInt10->bx = 0x01; ++ switch (mode) { ++ case DPMSModeOn: ++ break; ++ case DPMSModeStandby: ++ pVbe->pInt10->bx |= 0x100; ++ break; ++ case DPMSModeSuspend: ++ pVbe->pInt10->bx |= 0x200; ++ break; ++ case DPMSModeOff: ++ pVbe->pInt10->bx |= 0x400; ++ break; ++ } ++ xf86ExecX86int10(pVbe->pInt10); ++ return (R16(pVbe->pInt10->ax) == 0x4f); ++} ++ ++void ++VBEInterpretPanelID(ScrnInfoPtr pScrn, struct vbePanelID *data) ++{ ++ DisplayModePtr mode; ++ const float PANEL_HZ = 60.0; ++ ++ if (!data) ++ return; ++ ++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PanelID returned panel resolution %dx%d\n", ++ data->hsize, data->vsize); ++ ++ if (pScrn->monitor->nHsync || pScrn->monitor->nVrefresh) ++ return; ++ ++ if (data->hsize < 320 || data->vsize < 240) { ++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "...which I refuse to believe\n"); ++ return; ++ } ++ ++ mode = xf86CVTMode(data->hsize, data->vsize, PANEL_HZ, 1, 0); ++ ++ pScrn->monitor->nHsync = 1; ++ pScrn->monitor->hsync[0].lo = 29.37; ++ pScrn->monitor->hsync[0].hi = (float) mode->Clock / (float) mode->HTotal; ++ pScrn->monitor->nVrefresh = 1; ++ pScrn->monitor->vrefresh[0].lo = 56.0; ++ pScrn->monitor->vrefresh[0].hi = ++ (float) mode->Clock * 1000.0 / (float) mode->HTotal / ++ (float) mode->VTotal; ++ ++ if (pScrn->monitor->vrefresh[0].hi < 59.47) ++ pScrn->monitor->vrefresh[0].hi = 59.47; ++ ++ free(mode); ++} ++ ++struct vbePanelID * ++VBEReadPanelID(vbeInfoPtr pVbe) ++{ ++ int RealOff = pVbe->real_mode_base; ++ void *page = pVbe->memory; ++ void *tmp = NULL; ++ int screen = pVbe->pInt10->pScrn->scrnIndex; ++ ++ pVbe->pInt10->ax = 0x4F11; ++ pVbe->pInt10->bx = 0x01; ++ pVbe->pInt10->cx = 0; ++ pVbe->pInt10->dx = 0; ++ pVbe->pInt10->es = SEG_ADDR(RealOff); ++ pVbe->pInt10->di = SEG_OFF(RealOff); ++ pVbe->pInt10->num = 0x10; ++ ++ xf86ExecX86int10(pVbe->pInt10); ++ ++ if ((pVbe->pInt10->ax & 0xff) != 0x4f) { ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE PanelID invalid\n"); ++ goto error; ++ } ++ ++ switch (pVbe->pInt10->ax & 0xff00) { ++ case 0x0: ++ xf86DrvMsgVerb(screen, X_INFO, 3, ++ "VESA VBE PanelID read successfully\n"); ++ tmp = xnfalloc(32); ++ memcpy(tmp, page, 32); ++ break; ++ case 0x100: ++ xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE PanelID read failed\n"); ++ break; ++ default: ++ xf86DrvMsgVerb(screen, X_INFO, 3, ++ "VESA VBE PanelID unknown failure %i\n", ++ pVbe->pInt10->ax & 0xff00); ++ break; ++ } ++ ++ error: ++ return tmp; ++} +diff --git a/hw/xfree86/int10/vbe.h b/hw/xfree86/int10/vbe.h +new file mode 100644 +index 0000000..c8fb4e4 +--- /dev/null ++++ b/hw/xfree86/int10/vbe.h +@@ -0,0 +1,357 @@ ++ ++/* ++ * XFree86 vbe module ++ * Copyright 2000 Egbert Eich ++ * ++ * The mode query/save/set/restore functions from the vesa driver ++ * have been moved here. ++ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) ++ * Authors: Paulo César Pereira de Andrade ++ */ ++ ++#ifndef _VBE_H ++#define _VBE_H ++#include "xf86int10.h" ++#include "xf86DDC.h" ++ ++typedef enum { ++ DDC_UNCHECKED, ++ DDC_NONE, ++ DDC_1, ++ DDC_2, ++ DDC_1_2 ++} ddc_lvl; ++ ++typedef struct { ++ xf86Int10InfoPtr pInt10; ++ int version; ++ void *memory; ++ int real_mode_base; ++ int num_pages; ++ Bool init_int10; ++ ddc_lvl ddc; ++ Bool ddc_blank; ++} vbeInfoRec, *vbeInfoPtr; ++ ++#define VBE_VERSION_MAJOR(x) *((CARD8*)(&x) + 1) ++#define VBE_VERSION_MINOR(x) (CARD8)(x) ++ ++extern _X_EXPORT vbeInfoPtr VBEInit(xf86Int10InfoPtr pInt, int entityIndex); ++extern _X_EXPORT vbeInfoPtr VBEExtendedInit(xf86Int10InfoPtr pInt, ++ int entityIndex, int Flags); ++extern _X_EXPORT void vbeFree(vbeInfoPtr pVbe); ++extern _X_EXPORT xf86MonPtr vbeDoEDID(vbeInfoPtr pVbe, void *pDDCModule); ++ ++#pragma pack(1) ++ ++typedef struct vbeControllerInfoBlock { ++ CARD8 VbeSignature[4]; ++ CARD16 VbeVersion; ++ CARD32 OemStringPtr; ++ CARD8 Capabilities[4]; ++ CARD32 VideoModePtr; ++ CARD16 TotalMem; ++ CARD16 OemSoftwareRev; ++ CARD32 OemVendorNamePtr; ++ CARD32 OemProductNamePtr; ++ CARD32 OemProductRevPtr; ++ CARD8 Scratch[222]; ++ CARD8 OemData[256]; ++} vbeControllerInfoRec, *vbeControllerInfoPtr; ++ ++#if defined(__GNUC__) || defined(__USLC__) || defined(__SUNPRO_C) ++#pragma pack() /* All GCC versions recognise this syntax */ ++#else ++#pragma pack(0) ++#endif ++ ++#if !( defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) ) ++#define __attribute__(a) ++#endif ++ ++typedef struct _VbeInfoBlock VbeInfoBlock; ++typedef struct _VbeModeInfoBlock VbeModeInfoBlock; ++typedef struct _VbeCRTCInfoBlock VbeCRTCInfoBlock; ++ ++/* ++ * INT 0 ++ */ ++ ++struct _VbeInfoBlock { ++ /* VESA 1.2 fields */ ++ CARD8 VESASignature[4]; /* VESA */ ++ CARD16 VESAVersion; /* Higher byte major, lower byte minor */ ++ /*CARD32 */ char *OEMStringPtr; ++ /* Pointer to OEM string */ ++ CARD8 Capabilities[4]; /* Capabilities of the video environment */ ++ ++ /*CARD32 */ CARD16 *VideoModePtr; ++ /* pointer to supported Super VGA modes */ ++ ++ CARD16 TotalMemory; /* Number of 64kb memory blocks on board */ ++ /* if not VESA 2, 236 scratch bytes follow (256 bytes total size) */ ++ ++ /* VESA 2 fields */ ++ CARD16 OemSoftwareRev; /* VBE implementation Software revision */ ++ /*CARD32 */ char *OemVendorNamePtr; ++ /* Pointer to Vendor Name String */ ++ /*CARD32 */ char *OemProductNamePtr; ++ /* Pointer to Product Name String */ ++ /*CARD32 */ char *OemProductRevPtr; ++ /* Pointer to Product Revision String */ ++ CARD8 Reserved[222]; /* Reserved for VBE implementation */ ++ CARD8 OemData[256]; /* Data Area for OEM Strings */ ++} __attribute__ ((packed)); ++ ++/* Return Super VGA Information */ ++extern _X_EXPORT VbeInfoBlock *VBEGetVBEInfo(vbeInfoPtr pVbe); ++extern _X_EXPORT void VBEFreeVBEInfo(VbeInfoBlock * block); ++ ++/* ++ * INT 1 ++ */ ++ ++struct _VbeModeInfoBlock { ++ CARD16 ModeAttributes; /* mode attributes */ ++ CARD8 WinAAttributes; /* window A attributes */ ++ CARD8 WinBAttributes; /* window B attributes */ ++ CARD16 WinGranularity; /* window granularity */ ++ CARD16 WinSize; /* window size */ ++ CARD16 WinASegment; /* window A start segment */ ++ CARD16 WinBSegment; /* window B start segment */ ++ CARD32 WinFuncPtr; /* real mode pointer to window function */ ++ CARD16 BytesPerScanline; /* bytes per scanline */ ++ ++ /* Mandatory information for VBE 1.2 and above */ ++ CARD16 XResolution; /* horizontal resolution in pixels or characters */ ++ CARD16 YResolution; /* vertical resolution in pixels or characters */ ++ CARD8 XCharSize; /* character cell width in pixels */ ++ CARD8 YCharSize; /* character cell height in pixels */ ++ CARD8 NumberOfPlanes; /* number of memory planes */ ++ CARD8 BitsPerPixel; /* bits per pixel */ ++ CARD8 NumberOfBanks; /* number of banks */ ++ CARD8 MemoryModel; /* memory model type */ ++ CARD8 BankSize; /* bank size in KB */ ++ CARD8 NumberOfImages; /* number of images */ ++ CARD8 Reserved; /* 1 *//* reserved for page function */ ++ ++ /* Direct color fields (required for direct/6 and YUV/7 memory models) */ ++ CARD8 RedMaskSize; /* size of direct color red mask in bits */ ++ CARD8 RedFieldPosition; /* bit position of lsb of red mask */ ++ CARD8 GreenMaskSize; /* size of direct color green mask in bits */ ++ CARD8 GreenFieldPosition; /* bit position of lsb of green mask */ ++ CARD8 BlueMaskSize; /* size of direct color blue mask in bits */ ++ CARD8 BlueFieldPosition; /* bit position of lsb of blue mask */ ++ CARD8 RsvdMaskSize; /* size of direct color reserved mask in bits */ ++ CARD8 RsvdFieldPosition; /* bit position of lsb of reserved mask */ ++ CARD8 DirectColorModeInfo; /* direct color mode attributes */ ++ ++ /* Mandatory information for VBE 2.0 and above */ ++ CARD32 PhysBasePtr; /* physical address for flat memory frame buffer */ ++ CARD32 Reserved32; /* 0 *//* Reserved - always set to 0 */ ++ CARD16 Reserved16; /* 0 *//* Reserved - always set to 0 */ ++ ++ /* Mandatory information for VBE 3.0 and above */ ++ CARD16 LinBytesPerScanLine; /* bytes per scan line for linear modes */ ++ CARD8 BnkNumberOfImagePages; /* number of images for banked modes */ ++ CARD8 LinNumberOfImagePages; /* number of images for linear modes */ ++ CARD8 LinRedMaskSize; /* size of direct color red mask (linear modes) */ ++ CARD8 LinRedFieldPosition; /* bit position of lsb of red mask (linear modes) */ ++ CARD8 LinGreenMaskSize; /* size of direct color green mask (linear modes) */ ++ CARD8 LinGreenFieldPosition; /* bit position of lsb of green mask (linear modes) */ ++ CARD8 LinBlueMaskSize; /* size of direct color blue mask (linear modes) */ ++ CARD8 LinBlueFieldPosition; /* bit position of lsb of blue mask (linear modes) */ ++ CARD8 LinRsvdMaskSize; /* size of direct color reserved mask (linear modes) */ ++ CARD8 LinRsvdFieldPosition; /* bit position of lsb of reserved mask (linear modes) */ ++ CARD32 MaxPixelClock; /* maximum pixel clock (in Hz) for graphics mode */ ++ CARD8 Reserved2[189]; /* remainder of VbeModeInfoBlock */ ++} __attribute__ ((packed)); ++ ++/* Return VBE Mode Information */ ++extern _X_EXPORT VbeModeInfoBlock *VBEGetModeInfo(vbeInfoPtr pVbe, int mode); ++extern _X_EXPORT void VBEFreeModeInfo(VbeModeInfoBlock * block); ++ ++/* ++ * INT2 ++ */ ++ ++#define CRTC_DBLSCAN (1<<0) ++#define CRTC_INTERLACE (1<<1) ++#define CRTC_NHSYNC (1<<2) ++#define CRTC_NVSYNC (1<<3) ++ ++struct _VbeCRTCInfoBlock { ++ CARD16 HorizontalTotal; /* Horizontal total in pixels */ ++ CARD16 HorizontalSyncStart; /* Horizontal sync start in pixels */ ++ CARD16 HorizontalSyncEnd; /* Horizontal sync end in pixels */ ++ CARD16 VerticalTotal; /* Vertical total in lines */ ++ CARD16 VerticalSyncStart; /* Vertical sync start in lines */ ++ CARD16 VerticalSyncEnd; /* Vertical sync end in lines */ ++ CARD8 Flags; /* Flags (Interlaced, Double Scan etc) */ ++ CARD32 PixelClock; /* Pixel clock in units of Hz */ ++ CARD16 RefreshRate; /* Refresh rate in units of 0.01 Hz */ ++ CARD8 Reserved[40]; /* remainder of ModeInfoBlock */ ++} __attribute__ ((packed)); ++ ++/* VbeCRTCInfoBlock is in the VESA 3.0 specs */ ++ ++extern _X_EXPORT Bool VBESetVBEMode(vbeInfoPtr pVbe, int mode, ++ VbeCRTCInfoBlock * crtc); ++ ++/* ++ * INT 3 ++ */ ++ ++extern _X_EXPORT Bool VBEGetVBEMode(vbeInfoPtr pVbe, int *mode); ++ ++/* ++ * INT 4 ++ */ ++ ++/* Save/Restore Super VGA video state */ ++/* function values are (values stored in VESAPtr): ++ * 0 := query & allocate amount of memory to save state ++ * 1 := save state ++ * 2 := restore state ++ * ++ * function 0 called automatically if function 1 called without ++ * a previous call to function 0. ++ */ ++ ++typedef enum { ++ MODE_QUERY, ++ MODE_SAVE, ++ MODE_RESTORE ++} vbeSaveRestoreFunction; ++ ++extern _X_EXPORT Bool ++ ++VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction fuction, ++ void **memory, int *size, int *real_mode_pages); ++ ++/* ++ * INT 5 ++ */ ++ ++extern _X_EXPORT Bool ++ VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window); ++ ++/* ++ * INT 6 ++ */ ++ ++typedef enum { ++ SCANWID_SET, ++ SCANWID_GET, ++ SCANWID_SET_BYTES, ++ SCANWID_GET_MAX ++} vbeScanwidthCommand; ++ ++#define VBESetLogicalScanline(pVbe, width) \ ++ VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET, width, \ ++ NULL, NULL, NULL) ++#define VBESetLogicalScanlineBytes(pVbe, width) \ ++ VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET_BYTES, width, \ ++ NULL, NULL, NULL) ++#define VBEGetLogicalScanline(pVbe, pixels, bytes, max) \ ++ VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET, 0, \ ++ pixels, bytes, max) ++#define VBEGetMaxLogicalScanline(pVbe, pixels, bytes, max) \ ++ VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET_MAX, 0, \ ++ pixels, bytes, max) ++extern _X_EXPORT Bool VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, ++ vbeScanwidthCommand ++ command, int width, ++ int *pixels, int *bytes, ++ int *max); ++ ++/* ++ * INT 7 ++ */ ++ ++/* 16 bit code */ ++extern _X_EXPORT Bool VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, ++ Bool wait_retrace); ++extern _X_EXPORT Bool VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y); ++ ++/* ++ * INT 8 ++ */ ++ ++/* if bits is 0, then it is a GET */ ++extern _X_EXPORT int VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits); ++ ++/* ++ * INT 9 ++ */ ++ ++/* ++ * If getting a palette, the data argument is not used. It will return ++ * the data. ++ * If setting a palette, it will return the pointer received on success, ++ * NULL on failure. ++ */ ++extern _X_EXPORT CARD32 *VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, ++ int first, int num, CARD32 *data, ++ Bool secondary, ++ Bool wait_retrace); ++#define VBEFreePaletteData(data) free(data) ++ ++/* ++ * INT A ++ */ ++ ++typedef struct _VBEpmi { ++ int seg_tbl; ++ int tbl_off; ++ int tbl_len; ++} VBEpmi; ++ ++extern _X_EXPORT VBEpmi *VBEGetVBEpmi(vbeInfoPtr pVbe); ++ ++#define VESAFreeVBEpmi(pmi) free(pmi) ++ ++/* high level helper functions */ ++ ++typedef struct _vbeModeInfoRec { ++ int width; ++ int height; ++ int bpp; ++ int n; ++ struct _vbeModeInfoRec *next; ++} vbeModeInfoRec, *vbeModeInfoPtr; ++ ++typedef struct { ++ CARD8 *state; ++ CARD8 *pstate; ++ int statePage; ++ int stateSize; ++ int stateMode; ++} vbeSaveRestoreRec, *vbeSaveRestorePtr; ++ ++extern _X_EXPORT void ++ ++VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr, ++ vbeSaveRestoreFunction function); ++ ++extern _X_EXPORT int VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int Clock); ++extern _X_EXPORT Bool VBEDPMSSet(vbeInfoPtr pVbe, int mode); ++ ++struct vbePanelID { ++ short hsize; ++ short vsize; ++ short fptype; ++ char redbpp; ++ char greenbpp; ++ char bluebpp; ++ char reservedbpp; ++ int reserved_offscreen_mem_size; ++ int reserved_offscreen_mem_pointer; ++ char reserved[14]; ++}; ++ ++extern _X_EXPORT void VBEInterpretPanelID(ScrnInfoPtr pScrn, ++ struct vbePanelID *data); ++extern _X_EXPORT struct vbePanelID *VBEReadPanelID(vbeInfoPtr pVbe); ++ ++#endif +diff --git a/hw/xfree86/int10/vbeModes.c b/hw/xfree86/int10/vbeModes.c +new file mode 100644 +index 0000000..50ac50d +--- /dev/null ++++ b/hw/xfree86/int10/vbeModes.c +@@ -0,0 +1,453 @@ ++#define DEBUG_VERB 2 ++/* ++ * Copyright © 2002 David Dawes ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the "Software"), ++ * to deal in the Software without restriction, including without limitation ++ * the rights to use, copy, modify, merge, publish, distribute, sublicense, ++ * and/or sell copies of the Software, and to permit persons to whom the ++ * Software is furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ++ * THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF ++ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ * SOFTWARE. ++ * ++ * Except as contained in this notice, the name of the author(s) shall ++ * not be used in advertising or otherwise to promote the sale, use or other ++ * dealings in this Software without prior written authorization from ++ * the author(s). ++ * ++ * Authors: David Dawes ++ * ++ */ ++ ++#ifdef HAVE_XORG_CONFIG_H ++#include ++#endif ++ ++#include ++#include ++ ++#include "xf86.h" ++#include "vbe.h" ++#include "vbeModes.h" ++ ++static int ++GetDepthFlag(vbeInfoPtr pVbe, int id) ++{ ++ VbeModeInfoBlock *mode; ++ int bpp; ++ ++ if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) ++ return 0; ++ ++ if (VBE_MODE_USABLE(mode, 0)) { ++ int depth; ++ ++ if (VBE_MODE_COLOR(mode)) { ++ depth = mode->RedMaskSize + mode->GreenMaskSize + ++ mode->BlueMaskSize; ++ } ++ else { ++ depth = 1; ++ } ++ bpp = mode->BitsPerPixel; ++ VBEFreeModeInfo(mode); ++ mode = NULL; ++ switch (depth) { ++ case 1: ++ return V_DEPTH_1; ++ case 4: ++ return V_DEPTH_4; ++ case 8: ++ return V_DEPTH_8; ++ case 15: ++ return V_DEPTH_15; ++ case 16: ++ return V_DEPTH_16; ++ case 24: ++ switch (bpp) { ++ case 24: ++ return V_DEPTH_24_24; ++ case 32: ++ return V_DEPTH_24_32; ++ } ++ } ++ } ++ if (mode) ++ VBEFreeModeInfo(mode); ++ return 0; ++} ++ ++/* ++ * Find supported mode depths. ++ */ ++int ++VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock * vbe, int *flags24, ++ int modeTypes) ++{ ++ int i = 0; ++ int depths = 0; ++ ++ if (modeTypes & V_MODETYPE_VBE) { ++ while (vbe->VideoModePtr[i] != 0xffff) { ++ depths |= GetDepthFlag(pVbe, vbe->VideoModePtr[i++]); ++ } ++ } ++ ++ /* ++ * XXX This possibly only works with VBE 3.0 and later. ++ */ ++ if (modeTypes & V_MODETYPE_VGA) { ++ for (i = 0; i < 0x7F; i++) { ++ depths |= GetDepthFlag(pVbe, i); ++ } ++ } ++ ++ if (flags24) { ++ if (depths & V_DEPTH_24_24) ++ *flags24 |= Support24bppFb; ++ if (depths & V_DEPTH_24_32) ++ *flags24 |= Support32bppFb; ++ } ++ ++ return depths; ++} ++ ++static DisplayModePtr ++CheckMode(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe, int id, ++ int flags) ++{ ++ CARD16 major; ++ VbeModeInfoBlock *mode; ++ DisplayModePtr pMode; ++ VbeModeInfoData *data; ++ Bool modeOK = FALSE; ++ ++ major = (unsigned) (vbe->VESAVersion >> 8); ++ ++ if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) ++ return NULL; ++ ++ /* Does the mode match the depth/bpp? */ ++ /* Some BIOS's set BitsPerPixel to 15 instead of 16 for 15/16 */ ++ if (VBE_MODE_USABLE(mode, flags) && ++ ((pScrn->bitsPerPixel == 1 && !VBE_MODE_COLOR(mode)) || ++ (mode->BitsPerPixel > 8 && ++ (mode->RedMaskSize + mode->GreenMaskSize + ++ mode->BlueMaskSize) == pScrn->depth && ++ mode->BitsPerPixel == pScrn->bitsPerPixel) || ++ (mode->BitsPerPixel == 15 && pScrn->depth == 15) || ++ (mode->BitsPerPixel <= 8 && ++ mode->BitsPerPixel == pScrn->bitsPerPixel))) { ++ modeOK = TRUE; ++ xf86ErrorFVerb(DEBUG_VERB, "*"); ++ } ++ ++ xf86ErrorFVerb(DEBUG_VERB, ++ "Mode: %x (%dx%d)\n", id, mode->XResolution, ++ mode->YResolution); ++ xf86ErrorFVerb(DEBUG_VERB, " ModeAttributes: 0x%x\n", ++ mode->ModeAttributes); ++ xf86ErrorFVerb(DEBUG_VERB, " WinAAttributes: 0x%x\n", ++ mode->WinAAttributes); ++ xf86ErrorFVerb(DEBUG_VERB, " WinBAttributes: 0x%x\n", ++ mode->WinBAttributes); ++ xf86ErrorFVerb(DEBUG_VERB, " WinGranularity: %d\n", ++ mode->WinGranularity); ++ xf86ErrorFVerb(DEBUG_VERB, " WinSize: %d\n", mode->WinSize); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " WinASegment: 0x%x\n", mode->WinASegment); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " WinBSegment: 0x%x\n", mode->WinBSegment); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " WinFuncPtr: 0x%lx\n", (unsigned long) mode->WinFuncPtr); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " BytesPerScanline: %d\n", mode->BytesPerScanline); ++ xf86ErrorFVerb(DEBUG_VERB, " XResolution: %d\n", mode->XResolution); ++ xf86ErrorFVerb(DEBUG_VERB, " YResolution: %d\n", mode->YResolution); ++ xf86ErrorFVerb(DEBUG_VERB, " XCharSize: %d\n", mode->XCharSize); ++ xf86ErrorFVerb(DEBUG_VERB, " YCharSize: %d\n", mode->YCharSize); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " NumberOfPlanes: %d\n", mode->NumberOfPlanes); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " BitsPerPixel: %d\n", mode->BitsPerPixel); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " NumberOfBanks: %d\n", mode->NumberOfBanks); ++ xf86ErrorFVerb(DEBUG_VERB, " MemoryModel: %d\n", mode->MemoryModel); ++ xf86ErrorFVerb(DEBUG_VERB, " BankSize: %d\n", mode->BankSize); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " NumberOfImages: %d\n", mode->NumberOfImages); ++ xf86ErrorFVerb(DEBUG_VERB, " RedMaskSize: %d\n", mode->RedMaskSize); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " RedFieldPosition: %d\n", mode->RedFieldPosition); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " GreenMaskSize: %d\n", mode->GreenMaskSize); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " GreenFieldPosition: %d\n", mode->GreenFieldPosition); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " BlueMaskSize: %d\n", mode->BlueMaskSize); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " BlueFieldPosition: %d\n", mode->BlueFieldPosition); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " RsvdMaskSize: %d\n", mode->RsvdMaskSize); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " RsvdFieldPosition: %d\n", mode->RsvdFieldPosition); ++ xf86ErrorFVerb(DEBUG_VERB, ++ " DirectColorModeInfo: %d\n", mode->DirectColorModeInfo); ++ if (major >= 2) { ++ xf86ErrorFVerb(DEBUG_VERB, ++ " PhysBasePtr: 0x%lx\n", ++ (unsigned long) mode->PhysBasePtr); ++ if (major >= 3) { ++ xf86ErrorFVerb(DEBUG_VERB, ++ " LinBytesPerScanLine: %d\n", ++ mode->LinBytesPerScanLine); ++ xf86ErrorFVerb(DEBUG_VERB, " BnkNumberOfImagePages: %d\n", ++ mode->BnkNumberOfImagePages); ++ xf86ErrorFVerb(DEBUG_VERB, " LinNumberOfImagePages: %d\n", ++ mode->LinNumberOfImagePages); ++ xf86ErrorFVerb(DEBUG_VERB, " LinRedMaskSize: %d\n", ++ mode->LinRedMaskSize); ++ xf86ErrorFVerb(DEBUG_VERB, " LinRedFieldPosition: %d\n", ++ mode->LinRedFieldPosition); ++ xf86ErrorFVerb(DEBUG_VERB, " LinGreenMaskSize: %d\n", ++ mode->LinGreenMaskSize); ++ xf86ErrorFVerb(DEBUG_VERB, " LinGreenFieldPosition: %d\n", ++ mode->LinGreenFieldPosition); ++ xf86ErrorFVerb(DEBUG_VERB, " LinBlueMaskSize: %d\n", ++ mode->LinBlueMaskSize); ++ xf86ErrorFVerb(DEBUG_VERB, " LinBlueFieldPosition: %d\n", ++ mode->LinBlueFieldPosition); ++ xf86ErrorFVerb(DEBUG_VERB, " LinRsvdMaskSize: %d\n", ++ mode->LinRsvdMaskSize); ++ xf86ErrorFVerb(DEBUG_VERB, " LinRsvdFieldPosition: %d\n", ++ mode->LinRsvdFieldPosition); ++ xf86ErrorFVerb(DEBUG_VERB, " MaxPixelClock: %ld\n", ++ (unsigned long) mode->MaxPixelClock); ++ } ++ } ++ ++ if (!modeOK) { ++ VBEFreeModeInfo(mode); ++ return NULL; ++ } ++ pMode = xnfcalloc(sizeof(DisplayModeRec), 1); ++ ++ pMode->status = MODE_OK; ++ pMode->type = M_T_BUILTIN; ++ ++ /* for adjust frame */ ++ pMode->HDisplay = mode->XResolution; ++ pMode->VDisplay = mode->YResolution; ++ ++ data = xnfcalloc(sizeof(VbeModeInfoData), 1); ++ data->mode = id; ++ data->data = mode; ++ pMode->PrivSize = sizeof(VbeModeInfoData); ++ pMode->Private = (INT32 *) data; ++ pMode->next = NULL; ++ return pMode; ++} ++ ++/* ++ * Check the available BIOS modes, and extract those that match the ++ * requirements into the modePool. Note: modePool is a NULL-terminated ++ * list. ++ */ ++ ++DisplayModePtr ++VBEGetModePool(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe, ++ int modeTypes) ++{ ++ DisplayModePtr pMode, p = NULL, modePool = NULL; ++ int i = 0; ++ ++ if (modeTypes & V_MODETYPE_VBE) { ++ while (vbe->VideoModePtr[i] != 0xffff) { ++ int id = vbe->VideoModePtr[i++]; ++ ++ if ((pMode = CheckMode(pScrn, pVbe, vbe, id, modeTypes)) != NULL) { ++ ModeStatus status = MODE_OK; ++ ++ /* Check the mode against a specified virtual size (if any) */ ++ if (pScrn->display->virtualX > 0 && ++ pMode->HDisplay > pScrn->display->virtualX) { ++ status = MODE_VIRTUAL_X; ++ } ++ if (pScrn->display->virtualY > 0 && ++ pMode->VDisplay > pScrn->display->virtualY) { ++ status = MODE_VIRTUAL_Y; ++ } ++ if (status != MODE_OK) { ++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, ++ "Not using mode \"%dx%d\" (%s)\n", ++ pMode->HDisplay, pMode->VDisplay, ++ xf86ModeStatusToString(status)); ++ } ++ else { ++ if (p == NULL) { ++ modePool = pMode; ++ } ++ else { ++ p->next = pMode; ++ } ++ pMode->prev = NULL; ++ p = pMode; ++ } ++ } ++ } ++ } ++ if (modeTypes & V_MODETYPE_VGA) { ++ for (i = 0; i < 0x7F; i++) { ++ if ((pMode = CheckMode(pScrn, pVbe, vbe, i, modeTypes)) != NULL) { ++ ModeStatus status = MODE_OK; ++ ++ /* Check the mode against a specified virtual size (if any) */ ++ if (pScrn->display->virtualX > 0 && ++ pMode->HDisplay > pScrn->display->virtualX) { ++ status = MODE_VIRTUAL_X; ++ } ++ if (pScrn->display->virtualY > 0 && ++ pMode->VDisplay > pScrn->display->virtualY) { ++ status = MODE_VIRTUAL_Y; ++ } ++ if (status != MODE_OK) { ++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, ++ "Not using mode \"%dx%d\" (%s)\n", ++ pMode->HDisplay, pMode->VDisplay, ++ xf86ModeStatusToString(status)); ++ } ++ else { ++ if (p == NULL) { ++ modePool = pMode; ++ } ++ else { ++ p->next = pMode; ++ } ++ pMode->prev = NULL; ++ p = pMode; ++ } ++ } ++ } ++ } ++ return modePool; ++} ++ ++void ++VBESetModeNames(DisplayModePtr pMode) ++{ ++ if (!pMode) ++ return; ++ ++ do { ++ if (!pMode->name) { ++ /* Catch "bad" modes. */ ++ if (pMode->HDisplay > 10000 || pMode->HDisplay < 0 || ++ pMode->VDisplay > 10000 || pMode->VDisplay < 0) { ++ pMode->name = strdup("BADMODE"); ++ } ++ else { ++ char *tmp; ++ XNFasprintf(&tmp, "%dx%d", ++ pMode->HDisplay, pMode->VDisplay); ++ pMode->name = tmp; ++ } ++ } ++ pMode = pMode->next; ++ } while (pMode); ++} ++ ++/* ++ * Go through the monitor modes and selecting the best set of ++ * parameters for each BIOS mode. Note: This is only supported in ++ * VBE version 3.0 or later. ++ */ ++void ++VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe) ++{ ++ DisplayModePtr pMode; ++ VbeModeInfoData *data; ++ ++ pMode = pScrn->modes; ++ do { ++ DisplayModePtr p, best = NULL; ++ ModeStatus status; ++ ++ for (p = pScrn->monitor->Modes; p != NULL; p = p->next) { ++ if ((p->HDisplay != pMode->HDisplay) || ++ (p->VDisplay != pMode->VDisplay) || ++ (p->Flags & (V_INTERLACE | V_DBLSCAN | V_CLKDIV2))) ++ continue; ++ /* XXX could support the various V_ flags */ ++ status = xf86CheckModeForMonitor(p, pScrn->monitor); ++ if (status != MODE_OK) ++ continue; ++ if (!best || (p->Clock > best->Clock)) ++ best = p; ++ } ++ ++ if (best) { ++ int clock; ++ ++ data = (VbeModeInfoData *) pMode->Private; ++ pMode->HSync = (float) best->Clock * 1000.0 / best->HTotal + 0.5; ++ pMode->VRefresh = pMode->HSync / best->VTotal + 0.5; ++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, ++ "Attempting to use %dHz refresh for mode \"%s\" (%x)\n", ++ (int) pMode->VRefresh, pMode->name, data->mode); ++ data->block = calloc(sizeof(VbeCRTCInfoBlock), 1); ++ data->block->HorizontalTotal = best->HTotal; ++ data->block->HorizontalSyncStart = best->HSyncStart; ++ data->block->HorizontalSyncEnd = best->HSyncEnd; ++ data->block->VerticalTotal = best->VTotal; ++ data->block->VerticalSyncStart = best->VSyncStart; ++ data->block->VerticalSyncEnd = best->VSyncEnd; ++ data->block->Flags = ((best->Flags & V_NHSYNC) ? CRTC_NHSYNC : 0) | ++ ((best->Flags & V_NVSYNC) ? CRTC_NVSYNC : 0); ++ data->block->PixelClock = best->Clock * 1000; ++ /* XXX May not have this. */ ++ clock = VBEGetPixelClock(pVbe, data->mode, data->block->PixelClock); ++ DebugF("Setting clock %.2fMHz, closest is %.2fMHz\n", ++ (double) data->block->PixelClock / 1000000.0, ++ (double) clock / 1000000.0); ++ if (clock) ++ data->block->PixelClock = clock; ++ data->mode |= (1 << 11); ++ data->block->RefreshRate = ((double) (data->block->PixelClock) / ++ (double) (best->HTotal * ++ best->VTotal)) * 100; ++ } ++ pMode = pMode->next; ++ } while (pMode != pScrn->modes); ++} ++ ++/* ++ * These wrappers are to allow (temporary) funtionality divergences. ++ */ ++int ++VBEValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, ++ const char **modeNames, ClockRangePtr clockRanges, ++ int *linePitches, int minPitch, int maxPitch, int pitchInc, ++ int minHeight, int maxHeight, int virtualX, int virtualY, ++ int apertureSize, LookupModeFlags strategy) ++{ ++ return xf86ValidateModes(scrp, availModes, modeNames, clockRanges, ++ linePitches, minPitch, maxPitch, pitchInc, ++ minHeight, maxHeight, virtualX, virtualY, ++ apertureSize, strategy); ++} ++ ++void ++VBEPrintModes(ScrnInfoPtr scrp) ++{ ++ xf86PrintModes(scrp); ++} +diff --git a/hw/xfree86/int10/vbeModes.h b/hw/xfree86/int10/vbeModes.h +new file mode 100644 +index 0000000..ee0257c +--- /dev/null ++++ b/hw/xfree86/int10/vbeModes.h +@@ -0,0 +1,94 @@ ++/* ++ * Copyright © 2002 David Dawes ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the "Software"), ++ * to deal in the Software without restriction, including without limitation ++ * the rights to use, copy, modify, merge, publish, distribute, sublicense, ++ * and/or sell copies of the Software, and to permit persons to whom the ++ * Software is furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ++ * THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF ++ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ * SOFTWARE. ++ * ++ * Except as contained in this notice, the name of the author(s) shall ++ * not be used in advertising or otherwise to promote the sale, use or other ++ * dealings in this Software without prior written authorization from ++ * the author(s). ++ * ++ * Authors: David Dawes ++ * ++ */ ++ ++#ifndef _VBE_MODES_H ++ ++/* ++ * This is intended to be stored in the DisplayModeRec's private area. ++ * It includes all the information necessary to VBE information. ++ */ ++typedef struct _VbeModeInfoData { ++ int mode; ++ VbeModeInfoBlock *data; ++ VbeCRTCInfoBlock *block; ++} VbeModeInfoData; ++ ++#define V_DEPTH_1 0x001 ++#define V_DEPTH_4 0x002 ++#define V_DEPTH_8 0x004 ++#define V_DEPTH_15 0x008 ++#define V_DEPTH_16 0x010 ++#define V_DEPTH_24_24 0x020 ++#define V_DEPTH_24_32 0x040 ++#define V_DEPTH_24 (V_DEPTH_24_24 | V_DEPTH_24_32) ++#define V_DEPTH_30 0x080 ++#define V_DEPTH_32 0x100 ++ ++#define VBE_MODE_SUPPORTED(m) (((m)->ModeAttributes & 0x01) != 0) ++#define VBE_MODE_COLOR(m) (((m)->ModeAttributes & 0x08) != 0) ++#define VBE_MODE_GRAPHICS(m) (((m)->ModeAttributes & 0x10) != 0) ++#define VBE_MODE_VGA(m) (((m)->ModeAttributes & 0x40) == 0) ++#define VBE_MODE_LINEAR(m) (((m)->ModeAttributes & 0x80) != 0 && \ ++ ((m)->PhysBasePtr != 0)) ++ ++#define VBE_MODE_USABLE(m, f) (VBE_MODE_SUPPORTED(m) || \ ++ (f & V_MODETYPE_BAD)) && \ ++ VBE_MODE_GRAPHICS(m) && \ ++ (VBE_MODE_VGA(m) || VBE_MODE_LINEAR(m)) ++ ++#define V_MODETYPE_VBE 0x01 ++#define V_MODETYPE_VGA 0x02 ++#define V_MODETYPE_BAD 0x04 ++ ++extern _X_EXPORT int VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock * vbe, ++ int *flags24, int modeTypes); ++extern _X_EXPORT DisplayModePtr VBEGetModePool(ScrnInfoPtr pScrn, ++ vbeInfoPtr pVbe, ++ VbeInfoBlock * vbe, ++ int modeTypes); ++extern _X_EXPORT void VBESetModeNames(DisplayModePtr pMode); ++extern _X_EXPORT void VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe); ++ ++/* ++ * Note: These are alternatives to the standard helpers. They should ++ * usually just wrap the standard helpers. ++ */ ++extern _X_EXPORT int VBEValidateModes(ScrnInfoPtr scrp, ++ DisplayModePtr availModes, ++ const char **modeNames, ++ ClockRangePtr clockRanges, ++ int *linePitches, int minPitch, ++ int maxPitch, int pitchInc, int minHeight, ++ int maxHeight, int virtualX, int virtualY, ++ int apertureSize, ++ LookupModeFlags strategy); ++extern _X_EXPORT void VBEPrintModes(ScrnInfoPtr scrp); ++ ++#endif /* VBE_MODES_H */ +diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c +index f0983b2..a93a76a 100644 +--- a/hw/xfree86/loader/loadmod.c ++++ b/hw/xfree86/loader/loadmod.c +@@ -697,6 +697,10 @@ LoadModule(const char *module, void *options, const XF86ModReqInfo *modreq, + m = (char *) module; + } + ++ /* Backward compatibility, vbe and int10 are merged into int10 now */ ++ if (!strcmp(m, "vbe")) ++ m = name = "int10"; ++ + for (cim = compiled_in_modules; *cim; cim++) + if (!strcmp(m, *cim)) { + LogMessageVerb(X_INFO, 3, "Module \"%s\" already built-in\n", m); +diff --git a/hw/xfree86/meson.build b/hw/xfree86/meson.build +index c80964e..c5847c6 100644 +--- a/hw/xfree86/meson.build ++++ b/hw/xfree86/meson.build +@@ -10,7 +10,6 @@ xorg_inc = include_directories( + 'os-support/bus', + 'parser', + 'ramdac', +- 'vbe', + 'vgahw', + ) + +@@ -126,9 +125,6 @@ if int10 != 'false' + subdir('int10') + endif + subdir('shadowfb') +-if build_vbe +- subdir('vbe') +-endif + if build_vgahw + subdir('vgahw') + endif +diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh +index 2ebc4c0..ad95646 100755 +--- a/hw/xfree86/sdksyms.sh ++++ b/hw/xfree86/sdksyms.sh +@@ -71,6 +71,8 @@ cat > sdksyms.c << EOF + /* hw/xfree86/int10/Makefile.am -- module */ + /* + #include "xf86int10.h" ++#include "vbe.h" ++#include "vbeModes.h" + */ + + +@@ -185,13 +187,6 @@ cat > sdksyms.c << EOF + #include "xf86Optrec.h" + + +-/* hw/xfree86/vbe/Makefile.am -- module */ +-/* +-#include "vbe.h" +-#include "vbeModes.h" +- */ +- +- + /* hw/xfree86/dri/Makefile.am -- module */ + #ifdef XF86DRI + # include "dri.h" +diff --git a/hw/xfree86/vbe/Makefile.am b/hw/xfree86/vbe/Makefile.am +deleted file mode 100644 +index 041b47a..0000000 +--- a/hw/xfree86/vbe/Makefile.am ++++ /dev/null +@@ -1,14 +0,0 @@ +-module_LTLIBRARIES = libvbe.la +-libvbe_la_LDFLAGS = -module -avoid-version $(LD_NO_UNDEFINED_FLAG) +-libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c +-if NO_UNDEFINED +-libvbe_la_LIBADD = ../int10/libint10.la +-endif +- +-sdk_HEADERS = vbe.h vbeModes.h +- +-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +- +-AM_CPPFLAGS = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ +- -I$(srcdir)/../modes -I$(srcdir)/../parser \ +- -I$(srcdir)/../int10 +diff --git a/hw/xfree86/vbe/meson.build b/hw/xfree86/vbe/meson.build +deleted file mode 100644 +index d13991e..0000000 +--- a/hw/xfree86/vbe/meson.build ++++ /dev/null +@@ -1,10 +0,0 @@ +-shared_module('vbe', +- [ 'vbe.c', 'vbeModes.c', 'vbe_module.c' ], +- include_directories: [ inc, xorg_inc ], +- dependencies: common_dep, +- c_args: xorg_c_args, +- install: true, +- install_dir: module_dir, +-) +- +-install_data(['vbe.h', 'vbeModes.h'], install_dir: xorgsdkdir) +diff --git a/hw/xfree86/vbe/vbe.c b/hw/xfree86/vbe/vbe.c +deleted file mode 100644 +index d23e0f5..0000000 +--- a/hw/xfree86/vbe/vbe.c ++++ /dev/null +@@ -1,1096 +0,0 @@ +- +-/* +- * XFree86 vbe module +- * Copyright 2000 Egbert Eich +- * +- * The mode query/save/set/restore functions from the vesa driver +- * have been moved here. +- * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) +- * Authors: Paulo César Pereira de Andrade +- */ +- +-#ifdef HAVE_XORG_CONFIG_H +-#include +-#endif +- +-#include +- +-#include "xf86.h" +-#include "xf86Modes.h" +-#include "vbe.h" +-#include +- +-#define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x) +- +-#if X_BYTE_ORDER == X_LITTLE_ENDIAN +-#define B_O16(x) (x) +-#define B_O32(x) (x) +-#else +-#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8)) +-#define B_O32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \ +- | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24)) +-#endif +-#define L_ADD(x) (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00) +- +-#define FARP(p) (((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff)) +-#define R16(v) ((v) & 0xffff) +- +-static unsigned char *vbeReadEDID(vbeInfoPtr pVbe); +-static Bool vbeProbeDDC(vbeInfoPtr pVbe); +- +-static const char vbeVersionString[] = "VBE2"; +- +-vbeInfoPtr +-VBEInit(xf86Int10InfoPtr pInt, int entityIndex) +-{ +- return VBEExtendedInit(pInt, entityIndex, 0); +-} +- +-vbeInfoPtr +-VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags) +-{ +- int RealOff; +- void *page = NULL; +- ScrnInfoPtr pScrn = xf86FindScreenForEntity(entityIndex); +- vbeControllerInfoPtr vbe = NULL; +- Bool init_int10 = FALSE; +- vbeInfoPtr vip = NULL; +- int screen; +- +- if (!pScrn) +- return NULL; +- screen = pScrn->scrnIndex; +- +- if (!pInt) { +- if (!xf86LoadSubModule(pScrn, "int10")) +- goto error; +- +- xf86DrvMsg(screen, X_INFO, "initializing int10\n"); +- pInt = xf86ExtendedInitInt10(entityIndex, Flags); +- if (!pInt) +- goto error; +- init_int10 = TRUE; +- } +- +- page = xf86Int10AllocPages(pInt, 1, &RealOff); +- if (!page) +- goto error; +- vbe = (vbeControllerInfoPtr) page; +- memcpy(vbe->VbeSignature, vbeVersionString, 4); +- +- pInt->ax = 0x4F00; +- pInt->es = SEG_ADDR(RealOff); +- pInt->di = SEG_OFF(RealOff); +- pInt->num = 0x10; +- +- xf86ExecX86int10(pInt); +- +- if ((pInt->ax & 0xff) != 0x4f) { +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA BIOS not detected\n"); +- goto error; +- } +- +- switch (pInt->ax & 0xff00) { +- case 0: +- xf86DrvMsg(screen, X_INFO, "VESA BIOS detected\n"); +- break; +- case 0x100: +- xf86DrvMsg(screen, X_INFO, "VESA BIOS function failed\n"); +- goto error; +- case 0x200: +- xf86DrvMsg(screen, X_INFO, "VESA BIOS not supported\n"); +- goto error; +- case 0x300: +- xf86DrvMsg(screen, X_INFO, "VESA BIOS not supported in current mode\n"); +- goto error; +- default: +- xf86DrvMsg(screen, X_INFO, "Invalid\n"); +- goto error; +- } +- +- xf86DrvMsgVerb(screen, X_INFO, 4, +- "VbeVersion is %d, OemStringPtr is 0x%08lx,\n" +- "\tOemVendorNamePtr is 0x%08lx, OemProductNamePtr is 0x%08lx,\n" +- "\tOemProductRevPtr is 0x%08lx\n", +- vbe->VbeVersion, (unsigned long) vbe->OemStringPtr, +- (unsigned long) vbe->OemVendorNamePtr, +- (unsigned long) vbe->OemProductNamePtr, +- (unsigned long) vbe->OemProductRevPtr); +- +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE Version %i.%i\n", +- VERSION(vbe->VbeVersion)); +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE Total Mem: %i kB\n", +- vbe->TotalMem * 64); +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM: %s\n", +- (CARD8 *) xf86int10Addr(pInt, L_ADD(vbe->OemStringPtr))); +- +- if (B_O16(vbe->VbeVersion) >= 0x200) { +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Software Rev: %i.%i\n", +- VERSION(vbe->OemSoftwareRev)); +- if (vbe->OemVendorNamePtr) +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Vendor: %s\n", +- (CARD8 *) xf86int10Addr(pInt, +- L_ADD(vbe-> +- OemVendorNamePtr))); +- if (vbe->OemProductNamePtr) +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Product: %s\n", +- (CARD8 *) xf86int10Addr(pInt, +- L_ADD(vbe-> +- OemProductNamePtr))); +- if (vbe->OemProductRevPtr) +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Product Rev: %s\n", +- (CARD8 *) xf86int10Addr(pInt, +- L_ADD(vbe-> +- OemProductRevPtr))); +- } +- vip = (vbeInfoPtr) xnfalloc(sizeof(vbeInfoRec)); +- vip->version = B_O16(vbe->VbeVersion); +- vip->pInt10 = pInt; +- vip->ddc = DDC_UNCHECKED; +- vip->memory = page; +- vip->real_mode_base = RealOff; +- vip->num_pages = 1; +- vip->init_int10 = init_int10; +- +- return vip; +- +- error: +- if (page) +- xf86Int10FreePages(pInt, page, 1); +- if (init_int10) +- xf86FreeInt10(pInt); +- return NULL; +-} +- +-void +-vbeFree(vbeInfoPtr pVbe) +-{ +- if (!pVbe) +- return; +- +- xf86Int10FreePages(pVbe->pInt10, pVbe->memory, pVbe->num_pages); +- /* If we have initalized int10 we ought to free it, too */ +- if (pVbe->init_int10) +- xf86FreeInt10(pVbe->pInt10); +- free(pVbe); +- return; +-} +- +-static Bool +-vbeProbeDDC(vbeInfoPtr pVbe) +-{ +- const char *ddc_level; +- int screen = pVbe->pInt10->pScrn->scrnIndex; +- +- if (pVbe->ddc == DDC_NONE) +- return FALSE; +- if (pVbe->ddc != DDC_UNCHECKED) +- return TRUE; +- +- pVbe->pInt10->ax = 0x4F15; +- pVbe->pInt10->bx = 0; +- pVbe->pInt10->cx = 0; +- pVbe->pInt10->es = 0; +- pVbe->pInt10->di = 0; +- pVbe->pInt10->num = 0x10; +- +- xf86ExecX86int10(pVbe->pInt10); +- +- if ((pVbe->pInt10->ax & 0xff) != 0x4f) { +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC not supported\n"); +- pVbe->ddc = DDC_NONE; +- return FALSE; +- } +- +- switch ((pVbe->pInt10->ax >> 8) & 0xff) { +- case 0: +- xf86DrvMsg(screen, X_INFO, "VESA VBE DDC supported\n"); +- switch (pVbe->pInt10->bx & 0x3) { +- case 0: +- ddc_level = " none"; +- pVbe->ddc = DDC_NONE; +- break; +- case 1: +- ddc_level = " 1"; +- pVbe->ddc = DDC_1; +- break; +- case 2: +- ddc_level = " 2"; +- pVbe->ddc = DDC_2; +- break; +- case 3: +- ddc_level = " 1 + 2"; +- pVbe->ddc = DDC_1_2; +- break; +- default: +- ddc_level = ""; +- pVbe->ddc = DDC_NONE; +- break; +- } +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC Level%s\n", ddc_level); +- if (pVbe->pInt10->bx & 0x4) { +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC Screen blanked" +- "for data transfer\n"); +- pVbe->ddc_blank = TRUE; +- } +- else +- pVbe->ddc_blank = FALSE; +- +- xf86DrvMsgVerb(screen, X_INFO, 3, +- "VESA VBE DDC transfer in appr. %x sec.\n", +- (pVbe->pInt10->bx >> 8) & 0xff); +- } +- +- return TRUE; +-} +- +-typedef enum { +- VBEOPT_NOVBE, +- VBEOPT_NODDC +-} VBEOpts; +- +-static const OptionInfoRec VBEOptions[] = { +- {VBEOPT_NOVBE, "NoVBE", OPTV_BOOLEAN, {0}, FALSE}, +- {VBEOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE}, +- {-1, NULL, OPTV_NONE, {0}, FALSE}, +-}; +- +-static unsigned char * +-vbeReadEDID(vbeInfoPtr pVbe) +-{ +- int RealOff = pVbe->real_mode_base; +- void *page = pVbe->memory; +- unsigned char *tmp = NULL; +- Bool novbe = FALSE; +- Bool noddc = FALSE; +- ScrnInfoPtr pScrn = pVbe->pInt10->pScrn; +- int screen = pScrn->scrnIndex; +- OptionInfoPtr options; +- +- if (!page) +- return NULL; +- +- options = xnfalloc(sizeof(VBEOptions)); +- (void) memcpy(options, VBEOptions, sizeof(VBEOptions)); +- xf86ProcessOptions(screen, pScrn->options, options); +- xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe); +- xf86GetOptValBool(options, VBEOPT_NODDC, &noddc); +- free(options); +- if (novbe || noddc) +- return NULL; +- +- if (!vbeProbeDDC(pVbe)) +- goto error; +- +- memset(page, 0, sizeof(vbeInfoPtr)); +- strcpy(page, vbeVersionString); +- +- pVbe->pInt10->ax = 0x4F15; +- pVbe->pInt10->bx = 0x01; +- pVbe->pInt10->cx = 0; +- pVbe->pInt10->dx = 0; +- pVbe->pInt10->es = SEG_ADDR(RealOff); +- pVbe->pInt10->di = SEG_OFF(RealOff); +- pVbe->pInt10->num = 0x10; +- +- xf86ExecX86int10(pVbe->pInt10); +- +- if ((pVbe->pInt10->ax & 0xff) != 0x4f) { +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC invalid\n"); +- goto error; +- } +- switch (pVbe->pInt10->ax & 0xff00) { +- case 0x0: +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC read successfully\n"); +- tmp = (unsigned char *) xnfalloc(128); +- memcpy(tmp, page, 128); +- break; +- case 0x100: +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC read failed\n"); +- break; +- default: +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC unkown failure %i\n", +- pVbe->pInt10->ax & 0xff00); +- break; +- } +- +- error: +- return tmp; +-} +- +-xf86MonPtr +-vbeDoEDID(vbeInfoPtr pVbe, void *unused) +-{ +- unsigned char *DDC_data = NULL; +- +- if (!pVbe) +- return NULL; +- if (pVbe->version < 0x102) +- return NULL; +- +- DDC_data = vbeReadEDID(pVbe); +- +- if (!DDC_data) +- return NULL; +- +- return xf86InterpretEDID(pVbe->pInt10->pScrn->scrnIndex, DDC_data); +-} +- +-#define GET_UNALIGNED2(x) \ +- ((*(CARD16*)(x)) | (*(((CARD16*)(x) + 1))) << 16) +- +-VbeInfoBlock * +-VBEGetVBEInfo(vbeInfoPtr pVbe) +-{ +- VbeInfoBlock *block = NULL; +- int i, pStr, pModes; +- char *str; +- CARD16 major, *modes; +- +- memset(pVbe->memory, 0, sizeof(VbeInfoBlock)); +- +- /* +- Input: +- AH := 4Fh Super VGA support +- AL := 00h Return Super VGA information +- ES:DI := Pointer to buffer +- +- Output: +- AX := status +- (All other registers are preserved) +- */ +- +- ((char *) pVbe->memory)[0] = 'V'; +- ((char *) pVbe->memory)[1] = 'B'; +- ((char *) pVbe->memory)[2] = 'E'; +- ((char *) pVbe->memory)[3] = '2'; +- +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f00; +- pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); +- pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return NULL; +- +- block = calloc(sizeof(VbeInfoBlock), 1); +- block->VESASignature[0] = ((char *) pVbe->memory)[0]; +- block->VESASignature[1] = ((char *) pVbe->memory)[1]; +- block->VESASignature[2] = ((char *) pVbe->memory)[2]; +- block->VESASignature[3] = ((char *) pVbe->memory)[3]; +- +- block->VESAVersion = *(CARD16 *) (((char *) pVbe->memory) + 4); +- major = (unsigned) block->VESAVersion >> 8; +- +- pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 6)); +- str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); +- block->OEMStringPtr = strdup(str); +- +- block->Capabilities[0] = ((char *) pVbe->memory)[10]; +- block->Capabilities[1] = ((char *) pVbe->memory)[11]; +- block->Capabilities[2] = ((char *) pVbe->memory)[12]; +- block->Capabilities[3] = ((char *) pVbe->memory)[13]; +- +- pModes = GET_UNALIGNED2((((char *) pVbe->memory) + 14)); +- modes = xf86int10Addr(pVbe->pInt10, FARP(pModes)); +- i = 0; +- while (modes[i] != 0xffff) +- i++; +- block->VideoModePtr = xallocarray(i + 1, sizeof(CARD16)); +- memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i); +- block->VideoModePtr[i] = 0xffff; +- +- block->TotalMemory = *(CARD16 *) (((char *) pVbe->memory) + 18); +- +- if (major < 2) +- memcpy(&block->OemSoftwareRev, ((char *) pVbe->memory) + 20, 236); +- else { +- block->OemSoftwareRev = *(CARD16 *) (((char *) pVbe->memory) + 20); +- pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 22)); +- str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); +- block->OemVendorNamePtr = strdup(str); +- pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 26)); +- str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); +- block->OemProductNamePtr = strdup(str); +- pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 30)); +- str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); +- block->OemProductRevPtr = strdup(str); +- memcpy(&block->Reserved, ((char *) pVbe->memory) + 34, 222); +- memcpy(&block->OemData, ((char *) pVbe->memory) + 256, 256); +- } +- +- return block; +-} +- +-void +-VBEFreeVBEInfo(VbeInfoBlock * block) +-{ +- free(block->OEMStringPtr); +- free(block->VideoModePtr); +- if (((unsigned) block->VESAVersion >> 8) >= 2) { +- free(block->OemVendorNamePtr); +- free(block->OemProductNamePtr); +- free(block->OemProductRevPtr); +- } +- free(block); +-} +- +-Bool +-VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock * block) +-{ +- /* +- Input: +- AH := 4Fh Super VGA support +- AL := 02h Set Super VGA video mode +- BX := Video mode +- D0-D8 := Mode number +- D9-D10 := Reserved (must be 0) +- D11 := 0 Use current default refresh rate +- := 1 Use user specified CRTC values for refresh rate +- D12-13 Reserved for VBE/AF (must be 0) +- D14 := 0 Use windowed frame buffer model +- := 1 Use linear/flat frame buffer model +- D15 := 0 Clear video memory +- := 1 Don't clear video memory +- ES:DI := Pointer to VbeCRTCInfoBlock structure +- +- Output: AX = Status +- (All other registers are preserved) +- */ +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f02; +- pVbe->pInt10->bx = mode; +- if (block) { +- pVbe->pInt10->bx |= 1 << 11; +- memcpy(pVbe->memory, block, sizeof(VbeCRTCInfoBlock)); +- pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); +- pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); +- } +- else +- pVbe->pInt10->bx &= ~(1 << 11); +- +- xf86ExecX86int10(pVbe->pInt10); +- +- return (R16(pVbe->pInt10->ax) == 0x4f); +-} +- +-Bool +-VBEGetVBEMode(vbeInfoPtr pVbe, int *mode) +-{ +- /* +- Input: +- AH := 4Fh Super VGA support +- AL := 03h Return current video mode +- +- Output: +- AX := Status +- BX := Current video mode +- (All other registers are preserved) +- */ +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f03; +- +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) == 0x4f) { +- *mode = R16(pVbe->pInt10->bx); +- +- return TRUE; +- } +- +- return FALSE; +-} +- +-VbeModeInfoBlock * +-VBEGetModeInfo(vbeInfoPtr pVbe, int mode) +-{ +- VbeModeInfoBlock *block = NULL; +- +- memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock)); +- +- /* +- Input: +- AH := 4Fh Super VGA support +- AL := 01h Return Super VGA mode information +- CX := Super VGA video mode +- (mode number must be one of those returned by Function 0) +- ES:DI := Pointer to buffer +- +- Output: +- AX := status +- (All other registers are preserved) +- */ +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f01; +- pVbe->pInt10->cx = mode; +- pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); +- pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); +- xf86ExecX86int10(pVbe->pInt10); +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return NULL; +- +- block = malloc(sizeof(VbeModeInfoBlock)); +- if (block) +- memcpy(block, pVbe->memory, sizeof(*block)); +- +- return block; +-} +- +-void +-VBEFreeModeInfo(VbeModeInfoBlock * block) +-{ +- free(block); +-} +- +-Bool +-VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function, +- void **memory, int *size, int *real_mode_pages) +-{ +- /* +- Input: +- AH := 4Fh Super VGA support +- AL := 04h Save/restore Super VGA video state +- DL := 00h Return save/restore state buffer size +- CX := Requested states +- D0 = Save/restore video hardware state +- D1 = Save/restore video BIOS data state +- D2 = Save/restore video DAC state +- D3 = Save/restore Super VGA state +- +- Output: +- AX = Status +- BX = Number of 64-byte blocks to hold the state buffer +- (All other registers are preserved) +- +- Input: +- AH := 4Fh Super VGA support +- AL := 04h Save/restore Super VGA video state +- DL := 01h Save Super VGA video state +- CX := Requested states (see above) +- ES:BX := Pointer to buffer +- +- Output: +- AX := Status +- (All other registers are preserved) +- +- Input: +- AH := 4Fh Super VGA support +- AL := 04h Save/restore Super VGA video state +- DL := 02h Restore Super VGA video state +- CX := Requested states (see above) +- ES:BX := Pointer to buffer +- +- Output: +- AX := Status +- (All other registers are preserved) +- */ +- +- if ((pVbe->version & 0xff00) > 0x100) { +- int screen = pVbe->pInt10->pScrn->scrnIndex; +- +- if (function == MODE_QUERY || (function == MODE_SAVE && !*memory)) { +- /* Query amount of memory to save state */ +- +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f04; +- pVbe->pInt10->dx = 0; +- pVbe->pInt10->cx = 0x000f; +- xf86ExecX86int10(pVbe->pInt10); +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return FALSE; +- +- if (function == MODE_SAVE) { +- int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1; +- +- if ((*memory = xf86Int10AllocPages(pVbe->pInt10, npages, +- real_mode_pages)) == NULL) { +- xf86DrvMsg(screen, X_ERROR, +- "Cannot allocate memory to save SVGA state.\n"); +- return FALSE; +- } +- } +- *size = pVbe->pInt10->bx * 64; +- } +- +- /* Save/Restore Super VGA state */ +- if (function != MODE_QUERY) { +- +- if (!*memory) +- return FALSE; +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f04; +- switch (function) { +- case MODE_SAVE: +- pVbe->pInt10->dx = 1; +- break; +- case MODE_RESTORE: +- pVbe->pInt10->dx = 2; +- break; +- case MODE_QUERY: +- return FALSE; +- } +- pVbe->pInt10->cx = 0x000f; +- +- pVbe->pInt10->es = SEG_ADDR(*real_mode_pages); +- pVbe->pInt10->bx = SEG_OFF(*real_mode_pages); +- xf86ExecX86int10(pVbe->pInt10); +- return (R16(pVbe->pInt10->ax) == 0x4f); +- +- } +- } +- return TRUE; +-} +- +-Bool +-VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window) +-{ +- /* +- Input: +- AH := 4Fh Super VGA support +- AL := 05h +- +- Output: +- */ +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f05; +- pVbe->pInt10->bx = window; +- pVbe->pInt10->dx = iBank; +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return FALSE; +- +- return TRUE; +-} +- +-Bool +-VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command, +- int width, int *pixels, int *bytes, int *max) +-{ +- if (command < SCANWID_SET || command > SCANWID_GET_MAX) +- return FALSE; +- +- /* +- Input: +- AX := 4F06h VBE Set/Get Logical Scan Line Length +- BL := 00h Set Scan Line Length in Pixels +- := 01h Get Scan Line Length +- := 02h Set Scan Line Length in Bytes +- := 03h Get Maximum Scan Line Length +- CX := If BL=00h Desired Width in Pixels +- If BL=02h Desired Width in Bytes +- (Ignored for Get Functions) +- +- Output: +- AX := VBE Return Status +- BX := Bytes Per Scan Line +- CX := Actual Pixels Per Scan Line +- (truncated to nearest complete pixel) +- DX := Maximum Number of Scan Lines +- */ +- +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f06; +- pVbe->pInt10->bx = command; +- if (command == SCANWID_SET || command == SCANWID_SET_BYTES) +- pVbe->pInt10->cx = width; +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return FALSE; +- +- if (command == SCANWID_GET || command == SCANWID_GET_MAX) { +- if (pixels) +- *pixels = R16(pVbe->pInt10->cx); +- if (bytes) +- *bytes = R16(pVbe->pInt10->bx); +- if (max) +- *max = R16(pVbe->pInt10->dx); +- } +- +- return TRUE; +-} +- +-Bool +-VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace) +-{ +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f07; +- pVbe->pInt10->bx = wait_retrace ? 0x80 : 0x00; +- pVbe->pInt10->cx = x; +- pVbe->pInt10->dx = y; +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return FALSE; +- +- return TRUE; +-} +- +-Bool +-VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y) +-{ +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f07; +- pVbe->pInt10->bx = 0x01; +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return FALSE; +- +- *x = pVbe->pInt10->cx; +- *y = pVbe->pInt10->dx; +- +- return TRUE; +-} +- +-int +-VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits) +-{ +- /* +- Input: +- AX := 4F08h VBE Set/Get Palette Format +- BL := 00h Set DAC Palette Format +- := 01h Get DAC Palette Format +- BH := Desired bits of color per primary +- (Set DAC Palette Format only) +- +- Output: +- AX := VBE Return Status +- BH := Current number of bits of color per primary +- */ +- +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f08; +- if (!bits) +- pVbe->pInt10->bx = 0x01; +- else +- pVbe->pInt10->bx = (bits & 0x00ff) << 8; +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return 0; +- +- return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff); +-} +- +-CARD32 * +-VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num, +- CARD32 *data, Bool secondary, Bool wait_retrace) +-{ +- /* +- Input: +- (16-bit) +- AX := 4F09h VBE Load/Unload Palette Data +- BL := 00h Set Palette Data +- := 01h Get Palette Data +- := 02h Set Secondary Palette Data +- := 03h Get Secondary Palette Data +- := 80h Set Palette Data during Vertical Retrace +- CX := Number of palette registers to update (to a maximum of 256) +- DX := First of the palette registers to update (start) +- ES:DI := Table of palette values (see below for format) +- +- Output: +- AX := VBE Return Status +- +- Input: +- (32-bit) +- BL := 00h Set Palette Data +- := 80h Set Palette Data during Vertical Retrace +- CX := Number of palette registers to update (to a maximum of 256) +- DX := First of the palette registers to update (start) +- ES:EDI := Table of palette values (see below for format) +- DS := Selector for memory mapped registers +- */ +- +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f09; +- if (!secondary) +- pVbe->pInt10->bx = set && wait_retrace ? 0x80 : set ? 0 : 1; +- else +- pVbe->pInt10->bx = set ? 2 : 3; +- pVbe->pInt10->cx = num; +- pVbe->pInt10->dx = first; +- pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); +- pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); +- if (set) +- memcpy(pVbe->memory, data, num * sizeof(CARD32)); +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return NULL; +- +- if (set) +- return data; +- +- data = xallocarray(num, sizeof(CARD32)); +- memcpy(data, pVbe->memory, num * sizeof(CARD32)); +- +- return data; +-} +- +-VBEpmi * +-VBEGetVBEpmi(vbeInfoPtr pVbe) +-{ +- VBEpmi *pmi; +- +- /* +- Input: +- AH := 4Fh Super VGA support +- AL := 0Ah Protected Mode Interface +- BL := 00h Return Protected Mode Table +- +- Output: +- AX := Status +- ES := Real Mode Segment of Table +- DI := Offset of Table +- CX := Lenght of Table including protected mode code in bytes (for copying purposes) +- (All other registers are preserved) +- */ +- +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f0a; +- pVbe->pInt10->bx = 0; +- pVbe->pInt10->di = 0; +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return NULL; +- +- pmi = malloc(sizeof(VBEpmi)); +- pmi->seg_tbl = R16(pVbe->pInt10->es); +- pmi->tbl_off = R16(pVbe->pInt10->di); +- pmi->tbl_len = R16(pVbe->pInt10->cx); +- +- return pmi; +-} +- +-#if 0 +-vbeModeInfoPtr +-VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock * vbe) +-{ +- vbeModeInfoPtr ModeList = NULL; +- +- int i = 0; +- +- while (vbe->VideoModePtr[i] != 0xffff) { +- vbeModeInfoPtr m; +- VbeModeInfoBlock *mode; +- int id = vbe->VideoModePtr[i++]; +- int bpp; +- +- if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) +- continue; +- +- bpp = mode->BitsPerPixel; +- +- m = xnfcalloc(sizeof(vbeModeInfoRec), 1); +- m->width = mode->XResolution; +- m->height = mode->YResolution; +- m->bpp = bpp; +- m->n = id; +- m->next = ModeList; +- +- xf86DrvMsgVerb(pVbe->pInt10->pScrn->scrnIndex, X_PROBED, 3, +- "BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n", +- m->n, m->width, m->height, m->bpp); +- +- ModeList = m; +- +- VBEFreeModeInfo(mode); +- } +- return ModeList; +-} +- +-unsigned short +-VBECalcVbeModeIndex(vbeModeInfoPtr m, DisplayModePtr mode, int bpp) +-{ +- while (m) { +- if (bpp == m->bpp +- && mode->HDisplay == m->width && mode->VDisplay == m->height) +- return m->n; +- m = m->next; +- } +- return 0; +-} +-#endif +- +-void +-VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr, +- vbeSaveRestoreFunction function) +-{ +- Bool SaveSucc = FALSE; +- +- if (VBE_VERSION_MAJOR(pVbe->version) > 1 +- && (function == MODE_SAVE || vbe_sr->pstate)) { +- if (function == MODE_RESTORE) +- memcpy(vbe_sr->state, vbe_sr->pstate, vbe_sr->stateSize); +- ErrorF("VBESaveRestore\n"); +- if ((VBESaveRestore(pVbe, function, +- (void *) &vbe_sr->state, +- &vbe_sr->stateSize, &vbe_sr->statePage))) { +- if (function == MODE_SAVE) { +- SaveSucc = TRUE; +- vbe_sr->stateMode = -1; /* invalidate */ +- /* don't rely on the memory not being touched */ +- if (vbe_sr->pstate == NULL) +- vbe_sr->pstate = malloc(vbe_sr->stateSize); +- memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize); +- } +- ErrorF("VBESaveRestore done with success\n"); +- return; +- } +- ErrorF("VBESaveRestore done\n"); +- } +- +- if (function == MODE_SAVE && !SaveSucc) +- (void) VBEGetVBEMode(pVbe, &vbe_sr->stateMode); +- +- if (function == MODE_RESTORE && vbe_sr->stateMode != -1) +- VBESetVBEMode(pVbe, vbe_sr->stateMode, NULL); +- +-} +- +-int +-VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock) +-{ +- /* +- Input: +- AX := 4F0Bh VBE Get Pixel Clock +- BL := 00h Get Pixel Clock +- ECX := pixel clock in units of Hz +- DX := mode number +- +- Output: +- AX := VBE Return Status +- ECX := Closest pixel clock +- */ +- +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f0b; +- pVbe->pInt10->bx = 0x00; +- pVbe->pInt10->cx = clock; +- pVbe->pInt10->dx = mode; +- xf86ExecX86int10(pVbe->pInt10); +- +- if (R16(pVbe->pInt10->ax) != 0x4f) +- return 0; +- +- return pVbe->pInt10->cx; +-} +- +-Bool +-VBEDPMSSet(vbeInfoPtr pVbe, int mode) +-{ +- /* +- Input: +- AX := 4F10h DPMS +- BL := 01h Set Display Power State +- BH := requested power state +- +- Output: +- AX := VBE Return Status +- */ +- +- pVbe->pInt10->num = 0x10; +- pVbe->pInt10->ax = 0x4f10; +- pVbe->pInt10->bx = 0x01; +- switch (mode) { +- case DPMSModeOn: +- break; +- case DPMSModeStandby: +- pVbe->pInt10->bx |= 0x100; +- break; +- case DPMSModeSuspend: +- pVbe->pInt10->bx |= 0x200; +- break; +- case DPMSModeOff: +- pVbe->pInt10->bx |= 0x400; +- break; +- } +- xf86ExecX86int10(pVbe->pInt10); +- return (R16(pVbe->pInt10->ax) == 0x4f); +-} +- +-void +-VBEInterpretPanelID(ScrnInfoPtr pScrn, struct vbePanelID *data) +-{ +- DisplayModePtr mode; +- const float PANEL_HZ = 60.0; +- +- if (!data) +- return; +- +- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PanelID returned panel resolution %dx%d\n", +- data->hsize, data->vsize); +- +- if (pScrn->monitor->nHsync || pScrn->monitor->nVrefresh) +- return; +- +- if (data->hsize < 320 || data->vsize < 240) { +- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "...which I refuse to believe\n"); +- return; +- } +- +- mode = xf86CVTMode(data->hsize, data->vsize, PANEL_HZ, 1, 0); +- +- pScrn->monitor->nHsync = 1; +- pScrn->monitor->hsync[0].lo = 29.37; +- pScrn->monitor->hsync[0].hi = (float) mode->Clock / (float) mode->HTotal; +- pScrn->monitor->nVrefresh = 1; +- pScrn->monitor->vrefresh[0].lo = 56.0; +- pScrn->monitor->vrefresh[0].hi = +- (float) mode->Clock * 1000.0 / (float) mode->HTotal / +- (float) mode->VTotal; +- +- if (pScrn->monitor->vrefresh[0].hi < 59.47) +- pScrn->monitor->vrefresh[0].hi = 59.47; +- +- free(mode); +-} +- +-struct vbePanelID * +-VBEReadPanelID(vbeInfoPtr pVbe) +-{ +- int RealOff = pVbe->real_mode_base; +- void *page = pVbe->memory; +- void *tmp = NULL; +- int screen = pVbe->pInt10->pScrn->scrnIndex; +- +- pVbe->pInt10->ax = 0x4F11; +- pVbe->pInt10->bx = 0x01; +- pVbe->pInt10->cx = 0; +- pVbe->pInt10->dx = 0; +- pVbe->pInt10->es = SEG_ADDR(RealOff); +- pVbe->pInt10->di = SEG_OFF(RealOff); +- pVbe->pInt10->num = 0x10; +- +- xf86ExecX86int10(pVbe->pInt10); +- +- if ((pVbe->pInt10->ax & 0xff) != 0x4f) { +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE PanelID invalid\n"); +- goto error; +- } +- +- switch (pVbe->pInt10->ax & 0xff00) { +- case 0x0: +- xf86DrvMsgVerb(screen, X_INFO, 3, +- "VESA VBE PanelID read successfully\n"); +- tmp = xnfalloc(32); +- memcpy(tmp, page, 32); +- break; +- case 0x100: +- xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE PanelID read failed\n"); +- break; +- default: +- xf86DrvMsgVerb(screen, X_INFO, 3, +- "VESA VBE PanelID unknown failure %i\n", +- pVbe->pInt10->ax & 0xff00); +- break; +- } +- +- error: +- return tmp; +-} +diff --git a/hw/xfree86/vbe/vbe.h b/hw/xfree86/vbe/vbe.h +deleted file mode 100644 +index c8fb4e4..0000000 +--- a/hw/xfree86/vbe/vbe.h ++++ /dev/null +@@ -1,357 +0,0 @@ +- +-/* +- * XFree86 vbe module +- * Copyright 2000 Egbert Eich +- * +- * The mode query/save/set/restore functions from the vesa driver +- * have been moved here. +- * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) +- * Authors: Paulo César Pereira de Andrade +- */ +- +-#ifndef _VBE_H +-#define _VBE_H +-#include "xf86int10.h" +-#include "xf86DDC.h" +- +-typedef enum { +- DDC_UNCHECKED, +- DDC_NONE, +- DDC_1, +- DDC_2, +- DDC_1_2 +-} ddc_lvl; +- +-typedef struct { +- xf86Int10InfoPtr pInt10; +- int version; +- void *memory; +- int real_mode_base; +- int num_pages; +- Bool init_int10; +- ddc_lvl ddc; +- Bool ddc_blank; +-} vbeInfoRec, *vbeInfoPtr; +- +-#define VBE_VERSION_MAJOR(x) *((CARD8*)(&x) + 1) +-#define VBE_VERSION_MINOR(x) (CARD8)(x) +- +-extern _X_EXPORT vbeInfoPtr VBEInit(xf86Int10InfoPtr pInt, int entityIndex); +-extern _X_EXPORT vbeInfoPtr VBEExtendedInit(xf86Int10InfoPtr pInt, +- int entityIndex, int Flags); +-extern _X_EXPORT void vbeFree(vbeInfoPtr pVbe); +-extern _X_EXPORT xf86MonPtr vbeDoEDID(vbeInfoPtr pVbe, void *pDDCModule); +- +-#pragma pack(1) +- +-typedef struct vbeControllerInfoBlock { +- CARD8 VbeSignature[4]; +- CARD16 VbeVersion; +- CARD32 OemStringPtr; +- CARD8 Capabilities[4]; +- CARD32 VideoModePtr; +- CARD16 TotalMem; +- CARD16 OemSoftwareRev; +- CARD32 OemVendorNamePtr; +- CARD32 OemProductNamePtr; +- CARD32 OemProductRevPtr; +- CARD8 Scratch[222]; +- CARD8 OemData[256]; +-} vbeControllerInfoRec, *vbeControllerInfoPtr; +- +-#if defined(__GNUC__) || defined(__USLC__) || defined(__SUNPRO_C) +-#pragma pack() /* All GCC versions recognise this syntax */ +-#else +-#pragma pack(0) +-#endif +- +-#if !( defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) ) +-#define __attribute__(a) +-#endif +- +-typedef struct _VbeInfoBlock VbeInfoBlock; +-typedef struct _VbeModeInfoBlock VbeModeInfoBlock; +-typedef struct _VbeCRTCInfoBlock VbeCRTCInfoBlock; +- +-/* +- * INT 0 +- */ +- +-struct _VbeInfoBlock { +- /* VESA 1.2 fields */ +- CARD8 VESASignature[4]; /* VESA */ +- CARD16 VESAVersion; /* Higher byte major, lower byte minor */ +- /*CARD32 */ char *OEMStringPtr; +- /* Pointer to OEM string */ +- CARD8 Capabilities[4]; /* Capabilities of the video environment */ +- +- /*CARD32 */ CARD16 *VideoModePtr; +- /* pointer to supported Super VGA modes */ +- +- CARD16 TotalMemory; /* Number of 64kb memory blocks on board */ +- /* if not VESA 2, 236 scratch bytes follow (256 bytes total size) */ +- +- /* VESA 2 fields */ +- CARD16 OemSoftwareRev; /* VBE implementation Software revision */ +- /*CARD32 */ char *OemVendorNamePtr; +- /* Pointer to Vendor Name String */ +- /*CARD32 */ char *OemProductNamePtr; +- /* Pointer to Product Name String */ +- /*CARD32 */ char *OemProductRevPtr; +- /* Pointer to Product Revision String */ +- CARD8 Reserved[222]; /* Reserved for VBE implementation */ +- CARD8 OemData[256]; /* Data Area for OEM Strings */ +-} __attribute__ ((packed)); +- +-/* Return Super VGA Information */ +-extern _X_EXPORT VbeInfoBlock *VBEGetVBEInfo(vbeInfoPtr pVbe); +-extern _X_EXPORT void VBEFreeVBEInfo(VbeInfoBlock * block); +- +-/* +- * INT 1 +- */ +- +-struct _VbeModeInfoBlock { +- CARD16 ModeAttributes; /* mode attributes */ +- CARD8 WinAAttributes; /* window A attributes */ +- CARD8 WinBAttributes; /* window B attributes */ +- CARD16 WinGranularity; /* window granularity */ +- CARD16 WinSize; /* window size */ +- CARD16 WinASegment; /* window A start segment */ +- CARD16 WinBSegment; /* window B start segment */ +- CARD32 WinFuncPtr; /* real mode pointer to window function */ +- CARD16 BytesPerScanline; /* bytes per scanline */ +- +- /* Mandatory information for VBE 1.2 and above */ +- CARD16 XResolution; /* horizontal resolution in pixels or characters */ +- CARD16 YResolution; /* vertical resolution in pixels or characters */ +- CARD8 XCharSize; /* character cell width in pixels */ +- CARD8 YCharSize; /* character cell height in pixels */ +- CARD8 NumberOfPlanes; /* number of memory planes */ +- CARD8 BitsPerPixel; /* bits per pixel */ +- CARD8 NumberOfBanks; /* number of banks */ +- CARD8 MemoryModel; /* memory model type */ +- CARD8 BankSize; /* bank size in KB */ +- CARD8 NumberOfImages; /* number of images */ +- CARD8 Reserved; /* 1 *//* reserved for page function */ +- +- /* Direct color fields (required for direct/6 and YUV/7 memory models) */ +- CARD8 RedMaskSize; /* size of direct color red mask in bits */ +- CARD8 RedFieldPosition; /* bit position of lsb of red mask */ +- CARD8 GreenMaskSize; /* size of direct color green mask in bits */ +- CARD8 GreenFieldPosition; /* bit position of lsb of green mask */ +- CARD8 BlueMaskSize; /* size of direct color blue mask in bits */ +- CARD8 BlueFieldPosition; /* bit position of lsb of blue mask */ +- CARD8 RsvdMaskSize; /* size of direct color reserved mask in bits */ +- CARD8 RsvdFieldPosition; /* bit position of lsb of reserved mask */ +- CARD8 DirectColorModeInfo; /* direct color mode attributes */ +- +- /* Mandatory information for VBE 2.0 and above */ +- CARD32 PhysBasePtr; /* physical address for flat memory frame buffer */ +- CARD32 Reserved32; /* 0 *//* Reserved - always set to 0 */ +- CARD16 Reserved16; /* 0 *//* Reserved - always set to 0 */ +- +- /* Mandatory information for VBE 3.0 and above */ +- CARD16 LinBytesPerScanLine; /* bytes per scan line for linear modes */ +- CARD8 BnkNumberOfImagePages; /* number of images for banked modes */ +- CARD8 LinNumberOfImagePages; /* number of images for linear modes */ +- CARD8 LinRedMaskSize; /* size of direct color red mask (linear modes) */ +- CARD8 LinRedFieldPosition; /* bit position of lsb of red mask (linear modes) */ +- CARD8 LinGreenMaskSize; /* size of direct color green mask (linear modes) */ +- CARD8 LinGreenFieldPosition; /* bit position of lsb of green mask (linear modes) */ +- CARD8 LinBlueMaskSize; /* size of direct color blue mask (linear modes) */ +- CARD8 LinBlueFieldPosition; /* bit position of lsb of blue mask (linear modes) */ +- CARD8 LinRsvdMaskSize; /* size of direct color reserved mask (linear modes) */ +- CARD8 LinRsvdFieldPosition; /* bit position of lsb of reserved mask (linear modes) */ +- CARD32 MaxPixelClock; /* maximum pixel clock (in Hz) for graphics mode */ +- CARD8 Reserved2[189]; /* remainder of VbeModeInfoBlock */ +-} __attribute__ ((packed)); +- +-/* Return VBE Mode Information */ +-extern _X_EXPORT VbeModeInfoBlock *VBEGetModeInfo(vbeInfoPtr pVbe, int mode); +-extern _X_EXPORT void VBEFreeModeInfo(VbeModeInfoBlock * block); +- +-/* +- * INT2 +- */ +- +-#define CRTC_DBLSCAN (1<<0) +-#define CRTC_INTERLACE (1<<1) +-#define CRTC_NHSYNC (1<<2) +-#define CRTC_NVSYNC (1<<3) +- +-struct _VbeCRTCInfoBlock { +- CARD16 HorizontalTotal; /* Horizontal total in pixels */ +- CARD16 HorizontalSyncStart; /* Horizontal sync start in pixels */ +- CARD16 HorizontalSyncEnd; /* Horizontal sync end in pixels */ +- CARD16 VerticalTotal; /* Vertical total in lines */ +- CARD16 VerticalSyncStart; /* Vertical sync start in lines */ +- CARD16 VerticalSyncEnd; /* Vertical sync end in lines */ +- CARD8 Flags; /* Flags (Interlaced, Double Scan etc) */ +- CARD32 PixelClock; /* Pixel clock in units of Hz */ +- CARD16 RefreshRate; /* Refresh rate in units of 0.01 Hz */ +- CARD8 Reserved[40]; /* remainder of ModeInfoBlock */ +-} __attribute__ ((packed)); +- +-/* VbeCRTCInfoBlock is in the VESA 3.0 specs */ +- +-extern _X_EXPORT Bool VBESetVBEMode(vbeInfoPtr pVbe, int mode, +- VbeCRTCInfoBlock * crtc); +- +-/* +- * INT 3 +- */ +- +-extern _X_EXPORT Bool VBEGetVBEMode(vbeInfoPtr pVbe, int *mode); +- +-/* +- * INT 4 +- */ +- +-/* Save/Restore Super VGA video state */ +-/* function values are (values stored in VESAPtr): +- * 0 := query & allocate amount of memory to save state +- * 1 := save state +- * 2 := restore state +- * +- * function 0 called automatically if function 1 called without +- * a previous call to function 0. +- */ +- +-typedef enum { +- MODE_QUERY, +- MODE_SAVE, +- MODE_RESTORE +-} vbeSaveRestoreFunction; +- +-extern _X_EXPORT Bool +- +-VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction fuction, +- void **memory, int *size, int *real_mode_pages); +- +-/* +- * INT 5 +- */ +- +-extern _X_EXPORT Bool +- VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window); +- +-/* +- * INT 6 +- */ +- +-typedef enum { +- SCANWID_SET, +- SCANWID_GET, +- SCANWID_SET_BYTES, +- SCANWID_GET_MAX +-} vbeScanwidthCommand; +- +-#define VBESetLogicalScanline(pVbe, width) \ +- VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET, width, \ +- NULL, NULL, NULL) +-#define VBESetLogicalScanlineBytes(pVbe, width) \ +- VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET_BYTES, width, \ +- NULL, NULL, NULL) +-#define VBEGetLogicalScanline(pVbe, pixels, bytes, max) \ +- VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET, 0, \ +- pixels, bytes, max) +-#define VBEGetMaxLogicalScanline(pVbe, pixels, bytes, max) \ +- VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET_MAX, 0, \ +- pixels, bytes, max) +-extern _X_EXPORT Bool VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, +- vbeScanwidthCommand +- command, int width, +- int *pixels, int *bytes, +- int *max); +- +-/* +- * INT 7 +- */ +- +-/* 16 bit code */ +-extern _X_EXPORT Bool VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, +- Bool wait_retrace); +-extern _X_EXPORT Bool VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y); +- +-/* +- * INT 8 +- */ +- +-/* if bits is 0, then it is a GET */ +-extern _X_EXPORT int VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits); +- +-/* +- * INT 9 +- */ +- +-/* +- * If getting a palette, the data argument is not used. It will return +- * the data. +- * If setting a palette, it will return the pointer received on success, +- * NULL on failure. +- */ +-extern _X_EXPORT CARD32 *VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, +- int first, int num, CARD32 *data, +- Bool secondary, +- Bool wait_retrace); +-#define VBEFreePaletteData(data) free(data) +- +-/* +- * INT A +- */ +- +-typedef struct _VBEpmi { +- int seg_tbl; +- int tbl_off; +- int tbl_len; +-} VBEpmi; +- +-extern _X_EXPORT VBEpmi *VBEGetVBEpmi(vbeInfoPtr pVbe); +- +-#define VESAFreeVBEpmi(pmi) free(pmi) +- +-/* high level helper functions */ +- +-typedef struct _vbeModeInfoRec { +- int width; +- int height; +- int bpp; +- int n; +- struct _vbeModeInfoRec *next; +-} vbeModeInfoRec, *vbeModeInfoPtr; +- +-typedef struct { +- CARD8 *state; +- CARD8 *pstate; +- int statePage; +- int stateSize; +- int stateMode; +-} vbeSaveRestoreRec, *vbeSaveRestorePtr; +- +-extern _X_EXPORT void +- +-VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr, +- vbeSaveRestoreFunction function); +- +-extern _X_EXPORT int VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int Clock); +-extern _X_EXPORT Bool VBEDPMSSet(vbeInfoPtr pVbe, int mode); +- +-struct vbePanelID { +- short hsize; +- short vsize; +- short fptype; +- char redbpp; +- char greenbpp; +- char bluebpp; +- char reservedbpp; +- int reserved_offscreen_mem_size; +- int reserved_offscreen_mem_pointer; +- char reserved[14]; +-}; +- +-extern _X_EXPORT void VBEInterpretPanelID(ScrnInfoPtr pScrn, +- struct vbePanelID *data); +-extern _X_EXPORT struct vbePanelID *VBEReadPanelID(vbeInfoPtr pVbe); +- +-#endif +diff --git a/hw/xfree86/vbe/vbeModes.c b/hw/xfree86/vbe/vbeModes.c +deleted file mode 100644 +index 50ac50d..0000000 +--- a/hw/xfree86/vbe/vbeModes.c ++++ /dev/null +@@ -1,453 +0,0 @@ +-#define DEBUG_VERB 2 +-/* +- * Copyright © 2002 David Dawes +- * +- * Permission is hereby granted, free of charge, to any person obtaining a +- * copy of this software and associated documentation files (the "Software"), +- * to deal in the Software without restriction, including without limitation +- * the rights to use, copy, modify, merge, publish, distribute, sublicense, +- * and/or sell copies of the Software, and to permit persons to whom the +- * Software is furnished to do so, subject to the following conditions: +- * +- * The above copyright notice and this permission notice shall be included in +- * all copies or substantial portions of the Software. +- * +- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +- * THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +- * SOFTWARE. +- * +- * Except as contained in this notice, the name of the author(s) shall +- * not be used in advertising or otherwise to promote the sale, use or other +- * dealings in this Software without prior written authorization from +- * the author(s). +- * +- * Authors: David Dawes +- * +- */ +- +-#ifdef HAVE_XORG_CONFIG_H +-#include +-#endif +- +-#include +-#include +- +-#include "xf86.h" +-#include "vbe.h" +-#include "vbeModes.h" +- +-static int +-GetDepthFlag(vbeInfoPtr pVbe, int id) +-{ +- VbeModeInfoBlock *mode; +- int bpp; +- +- if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) +- return 0; +- +- if (VBE_MODE_USABLE(mode, 0)) { +- int depth; +- +- if (VBE_MODE_COLOR(mode)) { +- depth = mode->RedMaskSize + mode->GreenMaskSize + +- mode->BlueMaskSize; +- } +- else { +- depth = 1; +- } +- bpp = mode->BitsPerPixel; +- VBEFreeModeInfo(mode); +- mode = NULL; +- switch (depth) { +- case 1: +- return V_DEPTH_1; +- case 4: +- return V_DEPTH_4; +- case 8: +- return V_DEPTH_8; +- case 15: +- return V_DEPTH_15; +- case 16: +- return V_DEPTH_16; +- case 24: +- switch (bpp) { +- case 24: +- return V_DEPTH_24_24; +- case 32: +- return V_DEPTH_24_32; +- } +- } +- } +- if (mode) +- VBEFreeModeInfo(mode); +- return 0; +-} +- +-/* +- * Find supported mode depths. +- */ +-int +-VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock * vbe, int *flags24, +- int modeTypes) +-{ +- int i = 0; +- int depths = 0; +- +- if (modeTypes & V_MODETYPE_VBE) { +- while (vbe->VideoModePtr[i] != 0xffff) { +- depths |= GetDepthFlag(pVbe, vbe->VideoModePtr[i++]); +- } +- } +- +- /* +- * XXX This possibly only works with VBE 3.0 and later. +- */ +- if (modeTypes & V_MODETYPE_VGA) { +- for (i = 0; i < 0x7F; i++) { +- depths |= GetDepthFlag(pVbe, i); +- } +- } +- +- if (flags24) { +- if (depths & V_DEPTH_24_24) +- *flags24 |= Support24bppFb; +- if (depths & V_DEPTH_24_32) +- *flags24 |= Support32bppFb; +- } +- +- return depths; +-} +- +-static DisplayModePtr +-CheckMode(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe, int id, +- int flags) +-{ +- CARD16 major; +- VbeModeInfoBlock *mode; +- DisplayModePtr pMode; +- VbeModeInfoData *data; +- Bool modeOK = FALSE; +- +- major = (unsigned) (vbe->VESAVersion >> 8); +- +- if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) +- return NULL; +- +- /* Does the mode match the depth/bpp? */ +- /* Some BIOS's set BitsPerPixel to 15 instead of 16 for 15/16 */ +- if (VBE_MODE_USABLE(mode, flags) && +- ((pScrn->bitsPerPixel == 1 && !VBE_MODE_COLOR(mode)) || +- (mode->BitsPerPixel > 8 && +- (mode->RedMaskSize + mode->GreenMaskSize + +- mode->BlueMaskSize) == pScrn->depth && +- mode->BitsPerPixel == pScrn->bitsPerPixel) || +- (mode->BitsPerPixel == 15 && pScrn->depth == 15) || +- (mode->BitsPerPixel <= 8 && +- mode->BitsPerPixel == pScrn->bitsPerPixel))) { +- modeOK = TRUE; +- xf86ErrorFVerb(DEBUG_VERB, "*"); +- } +- +- xf86ErrorFVerb(DEBUG_VERB, +- "Mode: %x (%dx%d)\n", id, mode->XResolution, +- mode->YResolution); +- xf86ErrorFVerb(DEBUG_VERB, " ModeAttributes: 0x%x\n", +- mode->ModeAttributes); +- xf86ErrorFVerb(DEBUG_VERB, " WinAAttributes: 0x%x\n", +- mode->WinAAttributes); +- xf86ErrorFVerb(DEBUG_VERB, " WinBAttributes: 0x%x\n", +- mode->WinBAttributes); +- xf86ErrorFVerb(DEBUG_VERB, " WinGranularity: %d\n", +- mode->WinGranularity); +- xf86ErrorFVerb(DEBUG_VERB, " WinSize: %d\n", mode->WinSize); +- xf86ErrorFVerb(DEBUG_VERB, +- " WinASegment: 0x%x\n", mode->WinASegment); +- xf86ErrorFVerb(DEBUG_VERB, +- " WinBSegment: 0x%x\n", mode->WinBSegment); +- xf86ErrorFVerb(DEBUG_VERB, +- " WinFuncPtr: 0x%lx\n", (unsigned long) mode->WinFuncPtr); +- xf86ErrorFVerb(DEBUG_VERB, +- " BytesPerScanline: %d\n", mode->BytesPerScanline); +- xf86ErrorFVerb(DEBUG_VERB, " XResolution: %d\n", mode->XResolution); +- xf86ErrorFVerb(DEBUG_VERB, " YResolution: %d\n", mode->YResolution); +- xf86ErrorFVerb(DEBUG_VERB, " XCharSize: %d\n", mode->XCharSize); +- xf86ErrorFVerb(DEBUG_VERB, " YCharSize: %d\n", mode->YCharSize); +- xf86ErrorFVerb(DEBUG_VERB, +- " NumberOfPlanes: %d\n", mode->NumberOfPlanes); +- xf86ErrorFVerb(DEBUG_VERB, +- " BitsPerPixel: %d\n", mode->BitsPerPixel); +- xf86ErrorFVerb(DEBUG_VERB, +- " NumberOfBanks: %d\n", mode->NumberOfBanks); +- xf86ErrorFVerb(DEBUG_VERB, " MemoryModel: %d\n", mode->MemoryModel); +- xf86ErrorFVerb(DEBUG_VERB, " BankSize: %d\n", mode->BankSize); +- xf86ErrorFVerb(DEBUG_VERB, +- " NumberOfImages: %d\n", mode->NumberOfImages); +- xf86ErrorFVerb(DEBUG_VERB, " RedMaskSize: %d\n", mode->RedMaskSize); +- xf86ErrorFVerb(DEBUG_VERB, +- " RedFieldPosition: %d\n", mode->RedFieldPosition); +- xf86ErrorFVerb(DEBUG_VERB, +- " GreenMaskSize: %d\n", mode->GreenMaskSize); +- xf86ErrorFVerb(DEBUG_VERB, +- " GreenFieldPosition: %d\n", mode->GreenFieldPosition); +- xf86ErrorFVerb(DEBUG_VERB, +- " BlueMaskSize: %d\n", mode->BlueMaskSize); +- xf86ErrorFVerb(DEBUG_VERB, +- " BlueFieldPosition: %d\n", mode->BlueFieldPosition); +- xf86ErrorFVerb(DEBUG_VERB, +- " RsvdMaskSize: %d\n", mode->RsvdMaskSize); +- xf86ErrorFVerb(DEBUG_VERB, +- " RsvdFieldPosition: %d\n", mode->RsvdFieldPosition); +- xf86ErrorFVerb(DEBUG_VERB, +- " DirectColorModeInfo: %d\n", mode->DirectColorModeInfo); +- if (major >= 2) { +- xf86ErrorFVerb(DEBUG_VERB, +- " PhysBasePtr: 0x%lx\n", +- (unsigned long) mode->PhysBasePtr); +- if (major >= 3) { +- xf86ErrorFVerb(DEBUG_VERB, +- " LinBytesPerScanLine: %d\n", +- mode->LinBytesPerScanLine); +- xf86ErrorFVerb(DEBUG_VERB, " BnkNumberOfImagePages: %d\n", +- mode->BnkNumberOfImagePages); +- xf86ErrorFVerb(DEBUG_VERB, " LinNumberOfImagePages: %d\n", +- mode->LinNumberOfImagePages); +- xf86ErrorFVerb(DEBUG_VERB, " LinRedMaskSize: %d\n", +- mode->LinRedMaskSize); +- xf86ErrorFVerb(DEBUG_VERB, " LinRedFieldPosition: %d\n", +- mode->LinRedFieldPosition); +- xf86ErrorFVerb(DEBUG_VERB, " LinGreenMaskSize: %d\n", +- mode->LinGreenMaskSize); +- xf86ErrorFVerb(DEBUG_VERB, " LinGreenFieldPosition: %d\n", +- mode->LinGreenFieldPosition); +- xf86ErrorFVerb(DEBUG_VERB, " LinBlueMaskSize: %d\n", +- mode->LinBlueMaskSize); +- xf86ErrorFVerb(DEBUG_VERB, " LinBlueFieldPosition: %d\n", +- mode->LinBlueFieldPosition); +- xf86ErrorFVerb(DEBUG_VERB, " LinRsvdMaskSize: %d\n", +- mode->LinRsvdMaskSize); +- xf86ErrorFVerb(DEBUG_VERB, " LinRsvdFieldPosition: %d\n", +- mode->LinRsvdFieldPosition); +- xf86ErrorFVerb(DEBUG_VERB, " MaxPixelClock: %ld\n", +- (unsigned long) mode->MaxPixelClock); +- } +- } +- +- if (!modeOK) { +- VBEFreeModeInfo(mode); +- return NULL; +- } +- pMode = xnfcalloc(sizeof(DisplayModeRec), 1); +- +- pMode->status = MODE_OK; +- pMode->type = M_T_BUILTIN; +- +- /* for adjust frame */ +- pMode->HDisplay = mode->XResolution; +- pMode->VDisplay = mode->YResolution; +- +- data = xnfcalloc(sizeof(VbeModeInfoData), 1); +- data->mode = id; +- data->data = mode; +- pMode->PrivSize = sizeof(VbeModeInfoData); +- pMode->Private = (INT32 *) data; +- pMode->next = NULL; +- return pMode; +-} +- +-/* +- * Check the available BIOS modes, and extract those that match the +- * requirements into the modePool. Note: modePool is a NULL-terminated +- * list. +- */ +- +-DisplayModePtr +-VBEGetModePool(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock * vbe, +- int modeTypes) +-{ +- DisplayModePtr pMode, p = NULL, modePool = NULL; +- int i = 0; +- +- if (modeTypes & V_MODETYPE_VBE) { +- while (vbe->VideoModePtr[i] != 0xffff) { +- int id = vbe->VideoModePtr[i++]; +- +- if ((pMode = CheckMode(pScrn, pVbe, vbe, id, modeTypes)) != NULL) { +- ModeStatus status = MODE_OK; +- +- /* Check the mode against a specified virtual size (if any) */ +- if (pScrn->display->virtualX > 0 && +- pMode->HDisplay > pScrn->display->virtualX) { +- status = MODE_VIRTUAL_X; +- } +- if (pScrn->display->virtualY > 0 && +- pMode->VDisplay > pScrn->display->virtualY) { +- status = MODE_VIRTUAL_Y; +- } +- if (status != MODE_OK) { +- xf86DrvMsg(pScrn->scrnIndex, X_INFO, +- "Not using mode \"%dx%d\" (%s)\n", +- pMode->HDisplay, pMode->VDisplay, +- xf86ModeStatusToString(status)); +- } +- else { +- if (p == NULL) { +- modePool = pMode; +- } +- else { +- p->next = pMode; +- } +- pMode->prev = NULL; +- p = pMode; +- } +- } +- } +- } +- if (modeTypes & V_MODETYPE_VGA) { +- for (i = 0; i < 0x7F; i++) { +- if ((pMode = CheckMode(pScrn, pVbe, vbe, i, modeTypes)) != NULL) { +- ModeStatus status = MODE_OK; +- +- /* Check the mode against a specified virtual size (if any) */ +- if (pScrn->display->virtualX > 0 && +- pMode->HDisplay > pScrn->display->virtualX) { +- status = MODE_VIRTUAL_X; +- } +- if (pScrn->display->virtualY > 0 && +- pMode->VDisplay > pScrn->display->virtualY) { +- status = MODE_VIRTUAL_Y; +- } +- if (status != MODE_OK) { +- xf86DrvMsg(pScrn->scrnIndex, X_INFO, +- "Not using mode \"%dx%d\" (%s)\n", +- pMode->HDisplay, pMode->VDisplay, +- xf86ModeStatusToString(status)); +- } +- else { +- if (p == NULL) { +- modePool = pMode; +- } +- else { +- p->next = pMode; +- } +- pMode->prev = NULL; +- p = pMode; +- } +- } +- } +- } +- return modePool; +-} +- +-void +-VBESetModeNames(DisplayModePtr pMode) +-{ +- if (!pMode) +- return; +- +- do { +- if (!pMode->name) { +- /* Catch "bad" modes. */ +- if (pMode->HDisplay > 10000 || pMode->HDisplay < 0 || +- pMode->VDisplay > 10000 || pMode->VDisplay < 0) { +- pMode->name = strdup("BADMODE"); +- } +- else { +- char *tmp; +- XNFasprintf(&tmp, "%dx%d", +- pMode->HDisplay, pMode->VDisplay); +- pMode->name = tmp; +- } +- } +- pMode = pMode->next; +- } while (pMode); +-} +- +-/* +- * Go through the monitor modes and selecting the best set of +- * parameters for each BIOS mode. Note: This is only supported in +- * VBE version 3.0 or later. +- */ +-void +-VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe) +-{ +- DisplayModePtr pMode; +- VbeModeInfoData *data; +- +- pMode = pScrn->modes; +- do { +- DisplayModePtr p, best = NULL; +- ModeStatus status; +- +- for (p = pScrn->monitor->Modes; p != NULL; p = p->next) { +- if ((p->HDisplay != pMode->HDisplay) || +- (p->VDisplay != pMode->VDisplay) || +- (p->Flags & (V_INTERLACE | V_DBLSCAN | V_CLKDIV2))) +- continue; +- /* XXX could support the various V_ flags */ +- status = xf86CheckModeForMonitor(p, pScrn->monitor); +- if (status != MODE_OK) +- continue; +- if (!best || (p->Clock > best->Clock)) +- best = p; +- } +- +- if (best) { +- int clock; +- +- data = (VbeModeInfoData *) pMode->Private; +- pMode->HSync = (float) best->Clock * 1000.0 / best->HTotal + 0.5; +- pMode->VRefresh = pMode->HSync / best->VTotal + 0.5; +- xf86DrvMsg(pScrn->scrnIndex, X_INFO, +- "Attempting to use %dHz refresh for mode \"%s\" (%x)\n", +- (int) pMode->VRefresh, pMode->name, data->mode); +- data->block = calloc(sizeof(VbeCRTCInfoBlock), 1); +- data->block->HorizontalTotal = best->HTotal; +- data->block->HorizontalSyncStart = best->HSyncStart; +- data->block->HorizontalSyncEnd = best->HSyncEnd; +- data->block->VerticalTotal = best->VTotal; +- data->block->VerticalSyncStart = best->VSyncStart; +- data->block->VerticalSyncEnd = best->VSyncEnd; +- data->block->Flags = ((best->Flags & V_NHSYNC) ? CRTC_NHSYNC : 0) | +- ((best->Flags & V_NVSYNC) ? CRTC_NVSYNC : 0); +- data->block->PixelClock = best->Clock * 1000; +- /* XXX May not have this. */ +- clock = VBEGetPixelClock(pVbe, data->mode, data->block->PixelClock); +- DebugF("Setting clock %.2fMHz, closest is %.2fMHz\n", +- (double) data->block->PixelClock / 1000000.0, +- (double) clock / 1000000.0); +- if (clock) +- data->block->PixelClock = clock; +- data->mode |= (1 << 11); +- data->block->RefreshRate = ((double) (data->block->PixelClock) / +- (double) (best->HTotal * +- best->VTotal)) * 100; +- } +- pMode = pMode->next; +- } while (pMode != pScrn->modes); +-} +- +-/* +- * These wrappers are to allow (temporary) funtionality divergences. +- */ +-int +-VBEValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, +- const char **modeNames, ClockRangePtr clockRanges, +- int *linePitches, int minPitch, int maxPitch, int pitchInc, +- int minHeight, int maxHeight, int virtualX, int virtualY, +- int apertureSize, LookupModeFlags strategy) +-{ +- return xf86ValidateModes(scrp, availModes, modeNames, clockRanges, +- linePitches, minPitch, maxPitch, pitchInc, +- minHeight, maxHeight, virtualX, virtualY, +- apertureSize, strategy); +-} +- +-void +-VBEPrintModes(ScrnInfoPtr scrp) +-{ +- xf86PrintModes(scrp); +-} +diff --git a/hw/xfree86/vbe/vbeModes.h b/hw/xfree86/vbe/vbeModes.h +deleted file mode 100644 +index ee0257c..0000000 +--- a/hw/xfree86/vbe/vbeModes.h ++++ /dev/null +@@ -1,94 +0,0 @@ +-/* +- * Copyright © 2002 David Dawes +- * +- * Permission is hereby granted, free of charge, to any person obtaining a +- * copy of this software and associated documentation files (the "Software"), +- * to deal in the Software without restriction, including without limitation +- * the rights to use, copy, modify, merge, publish, distribute, sublicense, +- * and/or sell copies of the Software, and to permit persons to whom the +- * Software is furnished to do so, subject to the following conditions: +- * +- * The above copyright notice and this permission notice shall be included in +- * all copies or substantial portions of the Software. +- * +- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +- * THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +- * SOFTWARE. +- * +- * Except as contained in this notice, the name of the author(s) shall +- * not be used in advertising or otherwise to promote the sale, use or other +- * dealings in this Software without prior written authorization from +- * the author(s). +- * +- * Authors: David Dawes +- * +- */ +- +-#ifndef _VBE_MODES_H +- +-/* +- * This is intended to be stored in the DisplayModeRec's private area. +- * It includes all the information necessary to VBE information. +- */ +-typedef struct _VbeModeInfoData { +- int mode; +- VbeModeInfoBlock *data; +- VbeCRTCInfoBlock *block; +-} VbeModeInfoData; +- +-#define V_DEPTH_1 0x001 +-#define V_DEPTH_4 0x002 +-#define V_DEPTH_8 0x004 +-#define V_DEPTH_15 0x008 +-#define V_DEPTH_16 0x010 +-#define V_DEPTH_24_24 0x020 +-#define V_DEPTH_24_32 0x040 +-#define V_DEPTH_24 (V_DEPTH_24_24 | V_DEPTH_24_32) +-#define V_DEPTH_30 0x080 +-#define V_DEPTH_32 0x100 +- +-#define VBE_MODE_SUPPORTED(m) (((m)->ModeAttributes & 0x01) != 0) +-#define VBE_MODE_COLOR(m) (((m)->ModeAttributes & 0x08) != 0) +-#define VBE_MODE_GRAPHICS(m) (((m)->ModeAttributes & 0x10) != 0) +-#define VBE_MODE_VGA(m) (((m)->ModeAttributes & 0x40) == 0) +-#define VBE_MODE_LINEAR(m) (((m)->ModeAttributes & 0x80) != 0 && \ +- ((m)->PhysBasePtr != 0)) +- +-#define VBE_MODE_USABLE(m, f) (VBE_MODE_SUPPORTED(m) || \ +- (f & V_MODETYPE_BAD)) && \ +- VBE_MODE_GRAPHICS(m) && \ +- (VBE_MODE_VGA(m) || VBE_MODE_LINEAR(m)) +- +-#define V_MODETYPE_VBE 0x01 +-#define V_MODETYPE_VGA 0x02 +-#define V_MODETYPE_BAD 0x04 +- +-extern _X_EXPORT int VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock * vbe, +- int *flags24, int modeTypes); +-extern _X_EXPORT DisplayModePtr VBEGetModePool(ScrnInfoPtr pScrn, +- vbeInfoPtr pVbe, +- VbeInfoBlock * vbe, +- int modeTypes); +-extern _X_EXPORT void VBESetModeNames(DisplayModePtr pMode); +-extern _X_EXPORT void VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe); +- +-/* +- * Note: These are alternatives to the standard helpers. They should +- * usually just wrap the standard helpers. +- */ +-extern _X_EXPORT int VBEValidateModes(ScrnInfoPtr scrp, +- DisplayModePtr availModes, +- const char **modeNames, +- ClockRangePtr clockRanges, +- int *linePitches, int minPitch, +- int maxPitch, int pitchInc, int minHeight, +- int maxHeight, int virtualX, int virtualY, +- int apertureSize, +- LookupModeFlags strategy); +-extern _X_EXPORT void VBEPrintModes(ScrnInfoPtr scrp); +- +-#endif /* VBE_MODES_H */ +diff --git a/hw/xfree86/vbe/vbe_module.c b/hw/xfree86/vbe/vbe_module.c +deleted file mode 100644 +index 3fb8695..0000000 +--- a/hw/xfree86/vbe/vbe_module.c ++++ /dev/null +@@ -1,22 +0,0 @@ +-#ifdef HAVE_XORG_CONFIG_H +-#include +-#endif +- +-#include "xf86.h" +-#include "xf86str.h" +-#include "vbe.h" +- +-static XF86ModuleVersionInfo vbeVersRec = { +- "vbe", +- MODULEVENDORSTRING, +- MODINFOSTRING1, +- MODINFOSTRING2, +- XORG_VERSION_CURRENT, +- 1, 1, 0, +- ABI_CLASS_VIDEODRV, /* needs the video driver ABI */ +- ABI_VIDEODRV_VERSION, +- MOD_CLASS_NONE, +- {0, 0, 0, 0} +-}; +- +-_X_EXPORT XF86ModuleData vbeModuleData = { &vbeVersRec, NULL, NULL }; +diff --git a/meson.build b/meson.build +index ea45ca3..2fa3f86 100644 +--- a/meson.build ++++ b/meson.build +@@ -350,17 +350,6 @@ endif + + build_modesetting = libdrm_dep.found() and dri2proto_dep.found() + +-build_vbe = false +-if get_option('vbe') == 'auto' +- if (host_machine.system() != 'darwin' and +- host_machine.system() != 'windows' and +- host_machine.system() != 'cygwin') +- build_vbe = true +- endif +-else +- build_vbe = get_option('vbe') == 'true' +-endif +- + build_vgahw = false + if get_option('vgahw') == 'auto' + if (host_machine.system() != 'darwin' and +diff --git a/meson_options.txt b/meson_options.txt +index 3453b8d..5782aba 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -64,8 +64,6 @@ option('hal', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', + description: 'Enable HAL integration') + option('systemd_logind', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', + description: 'Enable systemd-logind integration') +-option('vbe', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', +- description: 'Xorg VBE module') + option('vgahw', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', + description: 'Xorg VGA access module') + option('dpms', type: 'boolean', value: true, +-- +1.8.3.1 + diff --git a/1003-loader-Move-LoaderSymbolFromModule-to-public-API.patch b/1003-loader-Move-LoaderSymbolFromModule-to-public-API.patch new file mode 100644 index 0000000..7c4d4ab --- /dev/null +++ b/1003-loader-Move-LoaderSymbolFromModule-to-public-API.patch @@ -0,0 +1,40 @@ +From ea3823107aad5940f711b1f58bb9e43d624d55d9 Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Tue, 8 Oct 2019 13:29:22 -0400 +Subject: [PATCH 1003/1005] loader: Move LoaderSymbolFromModule() to public API + +Bare LoaderSymbol() isn't really a great API, this is more of a direct +map to dlsym like you want. + +Gitlab: https://gitlab.freedesktop.org/xorg/xserver/issues/692 +--- + hw/xfree86/common/xf86Module.h | 1 + + hw/xfree86/loader/loader.h | 1 - + 2 files changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h +index 00aa84a..fab8842 100644 +--- a/hw/xfree86/common/xf86Module.h ++++ b/hw/xfree86/common/xf86Module.h +@@ -156,6 +156,7 @@ extern _X_EXPORT void *LoadSubModule(void *, const char *, const char **, + extern _X_EXPORT void UnloadSubModule(void *); + extern _X_EXPORT void UnloadModule(void *); + extern _X_EXPORT void *LoaderSymbol(const char *); ++extern _X_EXPORT void *LoaderSymbolFromModule(void *, const char *); + extern _X_EXPORT void LoaderErrorMsg(const char *, const char *, int, int); + extern _X_EXPORT Bool LoaderShouldIgnoreABI(void); + extern _X_EXPORT int LoaderGetABIVersion(const char *abiclass); +diff --git a/hw/xfree86/loader/loader.h b/hw/xfree86/loader/loader.h +index 5a2fe6c..4e83730 100644 +--- a/hw/xfree86/loader/loader.h ++++ b/hw/xfree86/loader/loader.h +@@ -72,6 +72,5 @@ extern unsigned long LoaderOptions; + + /* Internal Functions */ + void *LoaderOpen(const char *, int *); +-void *LoaderSymbolFromModule(void *, const char *); + + #endif /* _LOADER_H */ +-- +1.8.3.1 + diff --git a/1004-modesetting-Indirect-the-shadow-API-through-LoaderSy.patch b/1004-modesetting-Indirect-the-shadow-API-through-LoaderSy.patch new file mode 100644 index 0000000..f71fece --- /dev/null +++ b/1004-modesetting-Indirect-the-shadow-API-through-LoaderSy.patch @@ -0,0 +1,143 @@ +From 0ee3947ee9eb6a5417cbf702f495585d5d304efc Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Tue, 8 Oct 2019 12:52:28 -0400 +Subject: [PATCH 1004/1005] modesetting: Indirect the shadow API through + LoaderSymbol + +Prerequisite for building all of xserver with -z now. + +Gitlab: https://gitlab.freedesktop.org/xorg/xserver/issues/692 +--- + hw/xfree86/drivers/modesetting/driver.c | 34 +++++++++++++++------------------ + hw/xfree86/drivers/modesetting/driver.h | 12 +++++++++++- + 2 files changed, 26 insertions(+), 20 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index 5dc8e20..b3e913a 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -50,7 +50,6 @@ + #include "xf86Crtc.h" + #include "miscstruct.h" + #include "dixstruct.h" +-#include "shadow.h" + #include "xf86xv.h" + #include + #include +@@ -60,7 +59,6 @@ + #ifdef XSERVER_LIBPCIACCESS + #include + #endif +- + #include "driver.h" + + static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y); +@@ -1092,9 +1090,16 @@ PreInit(ScrnInfoPtr pScrn, int flags) + } + + if (ms->drmmode.shadow_enable) { +- if (!xf86LoadSubModule(pScrn, "shadow")) { ++ void *mod = xf86LoadSubModule(pScrn, "shadow"); ++ ++ if (!mod) + return FALSE; +- } ++ ++ ms->shadow.Setup = LoaderSymbolFromModule(mod, "shadowSetup"); ++ ms->shadow.Add = LoaderSymbolFromModule(mod, "shadowAdd"); ++ ms->shadow.Remove = LoaderSymbolFromModule(mod, "shadowRemove"); ++ ms->shadow.Update32to24 = LoaderSymbolFromModule(mod, "shadowUpdate32to24"); ++ ms->shadow.UpdatePacked = LoaderSymbolFromModule(mod, "shadowUpdatePacked"); + } + + return TRUE; +@@ -1199,9 +1204,9 @@ msUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf) + } while (0); + + if (use_3224) +- shadowUpdate32to24(pScreen, pBuf); ++ ms->shadow.Update32to24(pScreen, pBuf); + else +- shadowUpdatePacked(pScreen, pBuf); ++ ms->shadow.UpdatePacked(pScreen, pBuf); + } + + static Bool +@@ -1388,8 +1393,8 @@ CreateScreenResources(ScreenPtr pScreen) + FatalError("Couldn't adjust screen pixmap\n"); + + if (ms->drmmode.shadow_enable) { +- if (!shadowAdd(pScreen, rootPixmap, msUpdatePacked, msShadowWindow, +- 0, 0)) ++ if (!ms->shadow.Add(pScreen, rootPixmap, msUpdatePacked, msShadowWindow, ++ 0, 0)) + return FALSE; + } + +@@ -1424,15 +1429,6 @@ CreateScreenResources(ScreenPtr pScreen) + } + + static Bool +-msShadowInit(ScreenPtr pScreen) +-{ +- if (!shadowSetup(pScreen)) { +- return FALSE; +- } +- return TRUE; +-} +- +-static Bool + msSharePixmapBacking(PixmapPtr ppix, ScreenPtr screen, void **handle) + { + #ifdef GLAMOR_HAS_GBM +@@ -1651,7 +1647,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) + return FALSE; + } + +- if (ms->drmmode.shadow_enable && !msShadowInit(pScreen)) { ++ if (ms->drmmode.shadow_enable && !ms->shadow.Setup(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "shadow fb init failed\n"); + return FALSE; + } +@@ -1895,7 +1891,7 @@ CloseScreen(ScreenPtr pScreen) + } + + if (ms->drmmode.shadow_enable) { +- shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen)); ++ ms->shadow.Remove(pScreen, pScreen->GetScreenPixmap(pScreen)); + free(ms->drmmode.shadow_fb); + ms->drmmode.shadow_fb = NULL; + free(ms->drmmode.shadow_fb2); +diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h +index 28810c0..91b8f1f 100644 +--- a/hw/xfree86/drivers/modesetting/driver.h ++++ b/hw/xfree86/drivers/modesetting/driver.h +@@ -33,7 +33,7 @@ + #include + #include + #include +- ++#include + #ifdef GLAMOR_HAS_GBM + #define GLAMOR_FOR_XORG 1 + #include "glamor.h" +@@ -123,6 +123,16 @@ typedef struct _modesettingRec { + + Bool kms_has_modifiers; + ++ /* shadow API */ ++ struct { ++ Bool (*Setup)(ScreenPtr); ++ Bool (*Add)(ScreenPtr, PixmapPtr, ShadowUpdateProc, ShadowWindowProc, ++ int, void *); ++ void (*Remove)(ScreenPtr, PixmapPtr); ++ void (*Update32to24)(ScreenPtr, shadowBufPtr); ++ void (*UpdatePacked)(ScreenPtr, shadowBufPtr); ++ } shadow; ++ + } modesettingRec, *modesettingPtr; + + #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) +-- +1.8.3.1 + diff --git a/1005-modesetting-Indirect-the-glamor-API-through-LoaderSy.patch b/1005-modesetting-Indirect-the-glamor-API-through-LoaderSy.patch new file mode 100644 index 0000000..84efec4 --- /dev/null +++ b/1005-modesetting-Indirect-the-glamor-API-through-LoaderSy.patch @@ -0,0 +1,322 @@ +From 2acec1ff38d80a317181453c78ae7a5c5d110285 Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Tue, 8 Oct 2019 13:11:09 -0400 +Subject: [PATCH 1005/1005] modesetting: Indirect the glamor API through + LoaderSymbol + +Prerequisite for building all of xserver with -z now. + +Gitlab: https://gitlab.freedesktop.org/xorg/xserver/issues/692 +--- + hw/xfree86/drivers/modesetting/dri2.c | 10 +++-- + hw/xfree86/drivers/modesetting/driver.c | 49 ++++++++++++++++++------ + hw/xfree86/drivers/modesetting/driver.h | 24 ++++++++++++ + hw/xfree86/drivers/modesetting/drmmode_display.c | 15 +++++--- + hw/xfree86/drivers/modesetting/pageflip.c | 4 +- + hw/xfree86/drivers/modesetting/present.c | 4 +- + 6 files changed, 81 insertions(+), 25 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c +index d89904b..724d9d3 100644 +--- a/hw/xfree86/drivers/modesetting/dri2.c ++++ b/hw/xfree86/drivers/modesetting/dri2.c +@@ -123,6 +123,7 @@ ms_dri2_create_buffer2(ScreenPtr screen, DrawablePtr drawable, + unsigned int attachment, unsigned int format) + { + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); ++ modesettingPtr ms = modesettingPTR(scrn); + DRI2Buffer2Ptr buffer; + PixmapPtr pixmap; + CARD32 size; +@@ -200,7 +201,7 @@ ms_dri2_create_buffer2(ScreenPtr screen, DrawablePtr drawable, + */ + buffer->flags = 0; + +- buffer->name = glamor_name_from_pixmap(pixmap, &pitch, &size); ++ buffer->name = ms->glamor.name_from_pixmap(pixmap, &pitch, &size); + buffer->pitch = pitch; + if (buffer->name == -1) { + xf86DrvMsg(scrn->scrnIndex, X_ERROR, +@@ -509,11 +510,12 @@ update_front(DrawablePtr draw, DRI2BufferPtr front) + ScreenPtr screen = draw->pScreen; + PixmapPtr pixmap = get_drawable_pixmap(draw); + ms_dri2_buffer_private_ptr priv = front->driverPrivate; ++ modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen)); + CARD32 size; + CARD16 pitch; + int name; + +- name = glamor_name_from_pixmap(pixmap, &pitch, &size); ++ name = ms->glamor.name_from_pixmap(pixmap, &pitch, &size); + if (name < 0) + return FALSE; + +@@ -617,7 +619,7 @@ ms_dri2_exchange_buffers(DrawablePtr draw, DRI2BufferPtr front, + *front_pix = *back_pix; + *back_pix = tmp_pix; + +- glamor_egl_exchange_buffers(front_priv->pixmap, back_priv->pixmap); ++ ms->glamor.egl_exchange_buffers(front_priv->pixmap, back_priv->pixmap); + + /* Post damage on the front buffer so that listeners, such + * as DisplayLink know take a copy and shove it over the USB. +@@ -1036,7 +1038,7 @@ ms_dri2_screen_init(ScreenPtr screen) + DRI2InfoRec info; + const char *driver_names[2] = { NULL, NULL }; + +- if (!glamor_supports_pixmap_import_export(screen)) { ++ if (!ms->glamor.supports_pixmap_import_export(screen)) { + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "DRI2: glamor lacks support for pixmap import/export\n"); + } +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index b3e913a..6cb723f 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -615,7 +615,7 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty, int *timeout) + * the shared pixmap, but not all). + */ + if (ms->drmmode.glamor) +- glamor_finish(screen); ++ ms->glamor.finish(screen); + #endif + /* Ensure the slave processes the damage immediately */ + if (timeout) +@@ -744,6 +744,26 @@ FreeRec(ScrnInfoPtr pScrn) + } + + static void ++bind_glamor_api(void *mod, modesettingPtr ms) ++{ ++ ms->glamor.back_pixmap_from_fd = LoaderSymbolFromModule(mod, "glamor_back_pixmap_from_fd"); ++ ms->glamor.block_handler = LoaderSymbolFromModule(mod, "glamor_block_handler"); ++ ms->glamor.egl_create_textured_pixmap = LoaderSymbolFromModule(mod, "glamor_egl_create_textured_pixmap"); ++ ms->glamor.egl_create_textured_pixmap_from_gbm_bo = LoaderSymbolFromModule(mod, "glamor_egl_create_textured_pixmap_from_gbm_bo"); ++ ms->glamor.egl_exchange_buffers = LoaderSymbolFromModule(mod, "glamor_egl_exchange_buffers"); ++ ms->glamor.egl_get_gbm_device = LoaderSymbolFromModule(mod, "glamor_egl_get_gbm_device"); ++ ms->glamor.egl_init = LoaderSymbolFromModule(mod, "glamor_egl_init"); ++ ms->glamor.finish = LoaderSymbolFromModule(mod, "glamor_finish"); ++ ms->glamor.gbm_bo_from_pixmap = LoaderSymbolFromModule(mod, "glamor_gbm_bo_from_pixmap"); ++ ms->glamor.init = LoaderSymbolFromModule(mod, "glamor_init"); ++ ms->glamor.name_from_pixmap = LoaderSymbolFromModule(mod, "glamor_name_from_pixmap"); ++ ms->glamor.set_drawable_modifiers_func = LoaderSymbolFromModule(mod, "glamor_set_drawable_modifiers_func"); ++ ms->glamor.shareable_fd_from_pixmap = LoaderSymbolFromModule(mod, "glamor_shareable_fd_from_pixmap"); ++ ms->glamor.supports_pixmap_import_export = LoaderSymbolFromModule(mod, "glamor_supports_pixmap_import_export"); ++ ms->glamor.xv_init = LoaderSymbolFromModule(mod, "glamor_xv_init"); ++} ++ ++static void + try_enable_glamor(ScrnInfoPtr pScrn) + { + modesettingPtr ms = modesettingPTR(pScrn); +@@ -751,6 +771,7 @@ try_enable_glamor(ScrnInfoPtr pScrn) + OPTION_ACCEL_METHOD); + Bool do_glamor = (!accel_method_str || + strcmp(accel_method_str, "glamor") == 0); ++ void *mod; + + ms->drmmode.glamor = FALSE; + +@@ -765,8 +786,10 @@ try_enable_glamor(ScrnInfoPtr pScrn) + return; + } + +- if (xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME)) { +- if (glamor_egl_init(pScrn, ms->fd)) { ++ mod = xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME); ++ if (mod) { ++ bind_glamor_api(mod, ms); ++ if (ms->glamor.egl_init(pScrn, ms->fd)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n"); + ms->drmmode.glamor = TRUE; + } else { +@@ -1432,11 +1455,12 @@ static Bool + msSharePixmapBacking(PixmapPtr ppix, ScreenPtr screen, void **handle) + { + #ifdef GLAMOR_HAS_GBM ++ modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen)); + int ret; + CARD16 stride; + CARD32 size; +- ret = glamor_shareable_fd_from_pixmap(ppix->drawable.pScreen, ppix, +- &stride, &size); ++ ret = ms->glamor.shareable_fd_from_pixmap(ppix->drawable.pScreen, ppix, ++ &stride, &size); + if (ret == -1) + return FALSE; + +@@ -1461,11 +1485,12 @@ msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle) + return drmmode_SetSlaveBO(ppix, &ms->drmmode, ihandle, 0, 0); + + if (ms->drmmode.reverse_prime_offload_mode) { +- ret = glamor_back_pixmap_from_fd(ppix, ihandle, +- ppix->drawable.width, +- ppix->drawable.height, +- ppix->devKind, ppix->drawable.depth, +- ppix->drawable.bitsPerPixel); ++ ret = ms->glamor.back_pixmap_from_fd(ppix, ihandle, ++ ppix->drawable.width, ++ ppix->drawable.height, ++ ppix->devKind, ++ ppix->drawable.depth, ++ ppix->drawable.bitsPerPixel); + } else { + int size = ppix->devKind * ppix->drawable.height; + ret = drmmode_SetSlaveBO(ppix, &ms->drmmode, ihandle, ppix->devKind, size); +@@ -1582,7 +1607,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) + + #ifdef GLAMOR_HAS_GBM + if (ms->drmmode.glamor) +- ms->drmmode.gbm = glamor_egl_get_gbm_device(pScreen); ++ ms->drmmode.gbm = ms->glamor.egl_get_gbm_device(pScreen); + #endif + + /* HW dependent - FIXME */ +@@ -1726,7 +1751,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) + if (ms->drmmode.glamor) { + XF86VideoAdaptorPtr glamor_adaptor; + +- glamor_adaptor = glamor_xv_init(pScreen, 16); ++ glamor_adaptor = ms->glamor.xv_init(pScreen, 16); + if (glamor_adaptor != NULL) + xf86XVScreenInit(pScreen, &glamor_adaptor, 1); + else +diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h +index 91b8f1f..dffac7f 100644 +--- a/hw/xfree86/drivers/modesetting/driver.h ++++ b/hw/xfree86/drivers/modesetting/driver.h +@@ -133,6 +133,30 @@ typedef struct _modesettingRec { + void (*UpdatePacked)(ScreenPtr, shadowBufPtr); + } shadow; + ++ /* glamor API */ ++ struct { ++ Bool (*back_pixmap_from_fd)(PixmapPtr, int, CARD16, CARD16, CARD16, ++ CARD8, CARD8); ++ void (*block_handler)(ScreenPtr); ++ Bool (*egl_create_textured_pixmap)(PixmapPtr, int, int); ++ Bool (*egl_create_textured_pixmap_from_gbm_bo)(PixmapPtr, ++ struct gbm_bo *, ++ Bool); ++ void (*egl_exchange_buffers)(PixmapPtr, PixmapPtr); ++ struct gbm_device *(*egl_get_gbm_device)(ScreenPtr); ++ Bool (*egl_init)(ScrnInfoPtr, int); ++ void (*finish)(ScreenPtr); ++ struct gbm_bo *(*gbm_bo_from_pixmap)(ScreenPtr, PixmapPtr); ++ Bool (*init)(ScreenPtr, unsigned int); ++ int (*name_from_pixmap)(PixmapPtr, CARD16 *, CARD32 *); ++ void (*set_drawable_modifiers_func)(ScreenPtr, ++ GetDrawableModifiersFuncPtr); ++ int (*shareable_fd_from_pixmap)(ScreenPtr, PixmapPtr, CARD16 *, ++ CARD32 *); ++ Bool (*supports_pixmap_import_export)(ScreenPtr); ++ XF86VideoAdaptorPtr (*xv_init)(ScreenPtr, int); ++ } glamor; ++ + } modesettingRec, *modesettingPtr; + + #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c +index 6f5f8ca..6516fac 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c +@@ -1385,6 +1385,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode, ScrnInfoPtr pScrn, int fbcon_id) + PixmapPtr pixmap = drmmode->fbcon_pixmap; + drmModeFBPtr fbcon; + ScreenPtr pScreen = xf86ScrnToScreen(pScrn); ++ modesettingPtr ms = modesettingPTR(pScrn); + Bool ret; + + if (pixmap) +@@ -1405,7 +1406,8 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode, ScrnInfoPtr pScrn, int fbcon_id) + if (!pixmap) + goto out_free_fb; + +- ret = glamor_egl_create_textured_pixmap(pixmap, fbcon->handle, fbcon->pitch); ++ ret = ms->glamor.egl_create_textured_pixmap(pixmap, fbcon->handle, ++ fbcon->pitch); + if (!ret) { + FreePixmap(pixmap); + pixmap = NULL; +@@ -1424,6 +1426,7 @@ drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) + #ifdef GLAMOR_HAS_GBM + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + ScreenPtr pScreen = xf86ScrnToScreen(pScrn); ++ modesettingPtr ms = modesettingPTR(pScrn); + PixmapPtr src, dst; + int fbcon_id = 0; + GCPtr gc; +@@ -3108,12 +3111,13 @@ drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr pixmap, drmmode_bo *bo) + { + #ifdef GLAMOR_HAS_GBM + ScrnInfoPtr scrn = drmmode->scrn; ++ modesettingPtr ms = modesettingPTR(scrn); + + if (!drmmode->glamor) + return TRUE; + +- if (!glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo->gbm, +- bo->used_modifiers)) { ++ if (!ms->glamor.egl_create_textured_pixmap_from_gbm_bo(pixmap, bo->gbm, ++ bo->used_modifiers)) { + xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create pixmap\n"); + return FALSE; + } +@@ -3436,13 +3440,14 @@ drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode) + { + #ifdef GLAMOR_HAS_GBM + ScreenPtr pScreen = xf86ScrnToScreen(pScrn); ++ modesettingPtr ms = modesettingPTR(pScrn); + + if (drmmode->glamor) { +- if (!glamor_init(pScreen, GLAMOR_USE_EGL_SCREEN)) { ++ if (!ms->glamor.init(pScreen, GLAMOR_USE_EGL_SCREEN)) { + return FALSE; + } + #ifdef GBM_BO_WITH_MODIFIERS +- glamor_set_drawable_modifiers_func(pScreen, get_drawable_modifiers); ++ ms->glamor.set_drawable_modifiers_func(pScreen, get_drawable_modifiers); + #endif + } + #endif +diff --git a/hw/xfree86/drivers/modesetting/pageflip.c b/hw/xfree86/drivers/modesetting/pageflip.c +index 1d54816..841fa91 100644 +--- a/hw/xfree86/drivers/modesetting/pageflip.c ++++ b/hw/xfree86/drivers/modesetting/pageflip.c +@@ -243,9 +243,9 @@ ms_do_pageflip(ScreenPtr screen, + uint32_t flags; + int i; + struct ms_flipdata *flipdata; +- glamor_block_handler(screen); ++ ms->glamor.block_handler(screen); + +- new_front_bo.gbm = glamor_gbm_bo_from_pixmap(screen, new_front); ++ new_front_bo.gbm = ms->glamor.gbm_bo_from_pixmap(screen, new_front); + new_front_bo.dumb = NULL; + + if (!new_front_bo.gbm) { +diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c +index f7a4753..2f683a1 100644 +--- a/hw/xfree86/drivers/modesetting/present.c ++++ b/hw/xfree86/drivers/modesetting/present.c +@@ -166,7 +166,7 @@ ms_present_flush(WindowPtr window) + modesettingPtr ms = modesettingPTR(scrn); + + if (ms->drmmode.glamor) +- glamor_block_handler(screen); ++ ms->glamor.block_handler(screen); + #endif + } + +@@ -265,7 +265,7 @@ ms_present_check_unflip(RRCrtcPtr crtc, + + #ifdef GBM_BO_WITH_MODIFIERS + /* Check if buffer format/modifier is supported by all active CRTCs */ +- gbm = glamor_gbm_bo_from_pixmap(screen, pixmap); ++ gbm = ms->glamor.gbm_bo_from_pixmap(screen, pixmap); + if (gbm) { + uint32_t format; + uint64_t modifier; +-- +1.8.3.1 + diff --git a/1006-link-gbm-lib.patch b/1006-link-gbm-lib.patch new file mode 100644 index 0000000..b787104 --- /dev/null +++ b/1006-link-gbm-lib.patch @@ -0,0 +1,26 @@ +From 29fbc931b510371c25015f6f031756ee086e813e Mon Sep 17 00:00:00 2001 +From: Liwei Ge +Date: Thu, 13 Apr 2023 18:35:47 +0800 +Subject: [PATCH] link gbm lib + +Signed-off-by: Liwei Ge +--- + hw/xfree86/drivers/modesetting/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/xfree86/drivers/modesetting/Makefile.am b/hw/xfree86/drivers/modesetting/Makefile.am +index 961c574..ac5091b 100644 +--- a/hw/xfree86/drivers/modesetting/Makefile.am ++++ b/hw/xfree86/drivers/modesetting/Makefile.am +@@ -41,7 +41,7 @@ AM_CPPFLAGS = \ + + modesetting_drv_la_LTLIBRARIES = modesetting_drv.la + modesetting_drv_la_LDFLAGS = -module -avoid-version +-modesetting_drv_la_LIBADD = $(UDEV_LIBS) $(DRM_LIBS) ++modesetting_drv_la_LIBADD = $(UDEV_LIBS) $(DRM_LIBS) $(GBM_LIBS) + modesetting_drv_ladir = @moduledir@/drivers + + modesetting_drv_la_SOURCES = \ +-- +1.8.3.1 + diff --git a/1007-do-not-link-glamor-directly.patch b/1007-do-not-link-glamor-directly.patch new file mode 100644 index 0000000..24ce37e --- /dev/null +++ b/1007-do-not-link-glamor-directly.patch @@ -0,0 +1,66 @@ +From 1e4531aec20f604a6e13cc65d91393fe8d6d7839 Mon Sep 17 00:00:00 2001 +From: Liwei Ge +Date: Fri, 14 Apr 2023 20:30:42 +0800 +Subject: [PATCH] do not link glamor directly + +Signed-off-by: Liwei Ge +--- + hw/xfree86/drivers/modesetting/dri2.c | 2 +- + hw/xfree86/drivers/modesetting/driver.c | 1 + + hw/xfree86/drivers/modesetting/driver.h | 1 + + hw/xfree86/drivers/modesetting/drmmode_display.c | 2 +- + 4 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c +index 724d9d3..c484d36 100644 +--- a/hw/xfree86/drivers/modesetting/dri2.c ++++ b/hw/xfree86/drivers/modesetting/dri2.c +@@ -1076,7 +1076,7 @@ ms_dri2_screen_init(ScreenPtr screen) + info.CopyRegion2 = ms_dri2_copy_region2; + + /* Ask Glamor to obtain the DRI driver name via EGL_MESA_query_driver. */ +- driver_names[0] = glamor_egl_get_driver_name(screen); ++ driver_names[0] = ms->glamor.egl_get_driver_name(screen); + + if (driver_names[0]) { + /* There is no VDPAU driver for Intel, fallback to the generic +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index 6cb723f..aef0993 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -761,6 +761,7 @@ bind_glamor_api(void *mod, modesettingPtr ms) + ms->glamor.shareable_fd_from_pixmap = LoaderSymbolFromModule(mod, "glamor_shareable_fd_from_pixmap"); + ms->glamor.supports_pixmap_import_export = LoaderSymbolFromModule(mod, "glamor_supports_pixmap_import_export"); + ms->glamor.xv_init = LoaderSymbolFromModule(mod, "glamor_xv_init"); ++ ms->glamor.egl_get_driver_name = LoaderSymbolFromModule(mod, "glamor_egl_get_driver_name"); + } + + static void +diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h +index dffac7f..bde4f7a 100644 +--- a/hw/xfree86/drivers/modesetting/driver.h ++++ b/hw/xfree86/drivers/modesetting/driver.h +@@ -155,6 +155,7 @@ typedef struct _modesettingRec { + CARD32 *); + Bool (*supports_pixmap_import_export)(ScreenPtr); + XF86VideoAdaptorPtr (*xv_init)(ScreenPtr, int); ++ const char *(*egl_get_driver_name)(ScreenPtr); + } glamor; + + } modesettingRec, *modesettingPtr; +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c +index 6516fac..28609db 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c +@@ -770,7 +770,7 @@ drmmode_crtc_set_mode(xf86CrtcPtr crtc, Bool test_only) + #ifdef GLAMOR_HAS_GBM + /* Make sure any pending drawing will be visible in a new scanout buffer */ + if (drmmode->glamor) +- glamor_finish(screen); ++ ms->glamor.finish(screen); + #endif + + if (ms->atomic_modeset) { +-- +1.8.3.1 + diff --git a/1008-Use-glamor_clear_pixmap-in-drmmode_clear_pixmap.patch b/1008-Use-glamor_clear_pixmap-in-drmmode_clear_pixmap.patch new file mode 100644 index 0000000..b804ec6 --- /dev/null +++ b/1008-Use-glamor_clear_pixmap-in-drmmode_clear_pixmap.patch @@ -0,0 +1,60 @@ +From 60003023fa5b301dd621da4797f8a93035ebeeca Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michel=20D=C3=A4nzer?= +Date: Fri, 22 Nov 2019 18:32:38 +0100 +Subject: [PATCH] modesetting: Use glamor_clear_pixmap in drmmode_clear_pixmap + +Should be slightly more efficient. + +Reviewed-by: Adam Jackson +--- + hw/xfree86/drivers/modesetting/driver.c | 1 + + hw/xfree86/drivers/modesetting/driver.h | 1 + + hw/xfree86/drivers/modesetting/drmmode_display.c | 8 ++++++++ + 3 files changed, 10 insertions(+) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index 386e33460d..6c7d7eaf06 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -748,6 +748,7 @@ bind_glamor_api(void *mod, modesettingPtr ms) + { + ms->glamor.back_pixmap_from_fd = LoaderSymbolFromModule(mod, "glamor_back_pixmap_from_fd"); + ms->glamor.block_handler = LoaderSymbolFromModule(mod, "glamor_block_handler"); ++ ms->glamor.clear_pixmap = LoaderSymbolFromModule(mod, "glamor_clear_pixmap"); + ms->glamor.egl_create_textured_pixmap = LoaderSymbolFromModule(mod, "glamor_egl_create_textured_pixmap"); + ms->glamor.egl_create_textured_pixmap_from_gbm_bo = LoaderSymbolFromModule(mod, "glamor_egl_create_textured_pixmap_from_gbm_bo"); + ms->glamor.egl_exchange_buffers = LoaderSymbolFromModule(mod, "glamor_egl_exchange_buffers"); +diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h +index 4c524c4eb3..5909829a04 100644 +--- a/hw/xfree86/drivers/modesetting/driver.h ++++ b/hw/xfree86/drivers/modesetting/driver.h +@@ -137,6 +137,7 @@ typedef struct _modesettingRec { + Bool (*back_pixmap_from_fd)(PixmapPtr, int, CARD16, CARD16, CARD16, + CARD8, CARD8); + void (*block_handler)(ScreenPtr); ++ void (*clear_pixmap)(PixmapPtr); + Bool (*egl_create_textured_pixmap)(PixmapPtr, int, int); + Bool (*egl_create_textured_pixmap_from_gbm_bo)(PixmapPtr, + struct gbm_bo *, +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c +index 8a9dc2d800..9a6abc2498 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c +@@ -1804,6 +1804,14 @@ drmmode_clear_pixmap(PixmapPtr pixmap) + { + ScreenPtr screen = pixmap->drawable.pScreen; + GCPtr gc; ++#ifdef GLAMOR_HAS_GBM ++ modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen)); ++ ++ if (ms->drmmode.glamor) { ++ ms->glamor.clear_pixmap(pixmap); ++ return; ++ } ++#endif + + gc = GetScratchGC(pixmap->drawable.depth, screen); + if (gc) { +-- +GitLab + diff --git a/1009-Fix-build-with-glamor-disabled.patch b/1009-Fix-build-with-glamor-disabled.patch new file mode 100644 index 0000000..5119346 --- /dev/null +++ b/1009-Fix-build-with-glamor-disabled.patch @@ -0,0 +1,93 @@ +From 0cb9fa7949d6c5398de220fbdbe1e262e943fcbb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michel=20D=C3=A4nzer?= +Date: Mon, 10 Feb 2020 18:41:44 +0100 +Subject: [PATCH] modesetting: Fix build with glamor disabled + +Fixes: cb1b1e184723 "modesetting: Indirect the glamor API through + LoaderSymbol" +Reviewed-by: Adam Jackson +--- + hw/xfree86/drivers/modesetting/driver.c | 21 +++++++++++++++------ + hw/xfree86/drivers/modesetting/driver.h | 3 ++- + 2 files changed, 17 insertions(+), 7 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index d00e4a739e..0c1867f02d 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -743,9 +743,17 @@ FreeRec(ScrnInfoPtr pScrn) + + } + +-static void +-bind_glamor_api(void *mod, modesettingPtr ms) ++#ifdef GLAMOR_HAS_GBM ++ ++static Bool ++load_glamor(ScrnInfoPtr pScrn) + { ++ void *mod = xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME); ++ modesettingPtr ms = modesettingPTR(pScrn); ++ ++ if (!mod) ++ return FALSE; ++ + ms->glamor.back_pixmap_from_fd = LoaderSymbolFromModule(mod, "glamor_back_pixmap_from_fd"); + ms->glamor.block_handler = LoaderSymbolFromModule(mod, "glamor_block_handler"); + ms->glamor.clear_pixmap = LoaderSymbolFromModule(mod, "glamor_clear_pixmap"); +@@ -763,8 +771,12 @@ bind_glamor_api(void *mod, modesettingPtr ms) + ms->glamor.supports_pixmap_import_export = LoaderSymbolFromModule(mod, "glamor_supports_pixmap_import_export"); + ms->glamor.xv_init = LoaderSymbolFromModule(mod, "glamor_xv_init"); + ms->glamor.egl_get_driver_name = LoaderSymbolFromModule(mod, "glamor_egl_get_driver_name"); ++ ++ return TRUE; + } + ++#endif ++ + static void + try_enable_glamor(ScrnInfoPtr pScrn) + { +@@ -773,7 +785,6 @@ try_enable_glamor(ScrnInfoPtr pScrn) + OPTION_ACCEL_METHOD); + Bool do_glamor = (!accel_method_str || + strcmp(accel_method_str, "glamor") == 0); +- void *mod; + + ms->drmmode.glamor = FALSE; + +@@ -788,9 +799,7 @@ try_enable_glamor(ScrnInfoPtr pScrn) + return; + } + +- mod = xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME); +- if (mod) { +- bind_glamor_api(mod, ms); ++ if (load_glamor(pScrn)) { + if (ms->glamor.egl_init(pScrn, ms->fd)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n"); + ms->drmmode.glamor = TRUE; +diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h +index 60e4aaa96b..7ee9f6827f 100644 +--- a/hw/xfree86/drivers/modesetting/driver.h ++++ b/hw/xfree86/drivers/modesetting/driver.h +@@ -132,6 +132,7 @@ typedef struct _modesettingRec { + void (*UpdatePacked)(ScreenPtr, shadowBufPtr); + } shadow; + ++#ifdef GLAMOR_HAS_GBM + /* glamor API */ + struct { + Bool (*back_pixmap_from_fd)(PixmapPtr, int, CARD16, CARD16, CARD16, +@@ -157,7 +158,7 @@ typedef struct _modesettingRec { + XF86VideoAdaptorPtr (*xv_init)(ScreenPtr, int); + const char *(*egl_get_driver_name)(ScreenPtr); + } glamor; +- ++#endif + } modesettingRec, *modesettingPtr; + + #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) +-- +GitLab + diff --git a/1010-Make-LoaderSymbolFromModule-take-a-ModuleDescPtr.patch b/1010-Make-LoaderSymbolFromModule-take-a-ModuleDescPtr.patch new file mode 100644 index 0000000..610fea2 --- /dev/null +++ b/1010-Make-LoaderSymbolFromModule-take-a-ModuleDescPtr.patch @@ -0,0 +1,48 @@ +From ab61c16ef07fde6eb7110c63c344c54eb2a2d117 Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Mon, 18 Nov 2019 16:43:50 -0500 +Subject: [PATCH] loader: Make LoaderSymbolFromModule take a ModuleDescPtr +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The thing you get back from xf86LoadSubModule is a ModuleDescPtr, not a +dlsym handle. We don't expose ModuleDescPtr to the drivers, so change +LoaderSymbolFromModule to cast its void * argument to a ModuleDescPtr. + +Reviewed-by: Michel Dänzer +--- + hw/xfree86/loader/loader.c | 3 ++- + hw/xfree86/loader/loadmod.c | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c +index 503c47e3ab..2580e93d9b 100644 +--- a/hw/xfree86/loader/loader.c ++++ b/hw/xfree86/loader/loader.c +@@ -135,7 +135,8 @@ LoaderSymbol(const char *name) + void * + LoaderSymbolFromModule(void *handle, const char *name) + { +- return dlsym(handle, name); ++ ModuleDescPtr mod = handle; ++ return dlsym(mod->handle, name); + } + + void +diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c +index a93a76aa90..81a3a1dd94 100644 +--- a/hw/xfree86/loader/loadmod.c ++++ b/hw/xfree86/loader/loadmod.c +@@ -776,7 +776,7 @@ LoadModule(const char *module, void *options, const XF86ModReqInfo *modreq, + *errmaj = LDR_NOMEM; + goto LoadModule_fail; + } +- initdata = LoaderSymbolFromModule(ret->handle, p); ++ initdata = LoaderSymbolFromModule(ret, p); + if (initdata) { + ModuleSetupProc setup; + ModuleTearDownProc teardown; +-- +GitLab + diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index c6cccb7..5f6df15 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -1,4 +1,4 @@ -%define anolis_release 6 +%define anolis_release 8 %undefine _hardened_build %undefine _strict_symbol_defs_build %global ansic_major 0 @@ -58,6 +58,18 @@ Patch123: 0001-Xi-fix-potential-use-after-free-in-DeepCopyPointerCl.patch Patch200: 0001-Disallow-byte-swapped-clients-by-default.patch +Patch1000: 1000-meson-Fix-libshadow.so-linkage.patch +Patch1001: 1001-xfree86-Link-fb-statically.patch +Patch1002: 1002-xfree86-Merge-vbe-into-int10.patch +Patch1003: 1003-loader-Move-LoaderSymbolFromModule-to-public-API.patch +Patch1004: 1004-modesetting-Indirect-the-shadow-API-through-LoaderSy.patch +Patch1005: 1005-modesetting-Indirect-the-glamor-API-through-LoaderSy.patch +Patch1006: 1006-link-gbm-lib.patch +Patch1007: 1007-do-not-link-glamor-directly.patch +Patch1008: 1008-Use-glamor_clear_pixmap-in-drmmode_clear_pixmap.patch +Patch1009: 1009-Fix-build-with-glamor-disabled.patch +Patch1010: 1010-Make-LoaderSymbolFromModule-take-a-ModuleDescPtr.patch + BuildRequires: automake make autoconf libtool pkgconfig BuildRequires: dbus-devel libepoxy-devel libudev-devel systemd-devel systemtap-sdt-devel BuildRequires: libXfont2-devel libXau-devel libxkbfile-devel libXres-devel libXpm-devel @@ -296,7 +308,6 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/xorg/modules/lib{int10,vbe}.so %{_libdir}/xorg/modules/extensions/libglx.so %{_libdir}/xorg/modules/libfbdevhw.so %{_libdir}/xorg/modules/libexa.so -%{_libdir}/xorg/modules/libfb.so %{_libdir}/xorg/modules/libglamoregl.so %{_libdir}/xorg/modules/libshadow.so %{_libdir}/xorg/modules/libshadowfb.so @@ -304,7 +315,6 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/xorg/modules/lib{int10,vbe}.so %{_libdir}/xorg/modules/libwfb.so %ifarch x86_64 %{_libdir}/xorg/modules/libint10.so -%{_libdir}/xorg/modules/libvbe.so %endif %dir %{_datadir}/X11/xorg.conf.d %{_datadir}/X11/xorg.conf.d/10-quirks.conf @@ -364,6 +374,12 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/xorg/modules/lib{int10,vbe}.so %{_datadir}/xorg-x11-server-source %changelog +* Wed Apr 19 2023 Liwei Ge - 1:1.20.14-8 +- make modesetting link gbm + +* Wed Apr 19 2023 Liwei Ge - 1:1.20.14-7 +- make build fit ld -z now + * Fri Apr 14 2023 Yuanhong Peng - 1:1.20.14-6 - Refactor the specfile -- Gitee