Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[xsrc/trunk]: xsrc/external/mit/xf86-video-mgx/dist crude beginnings of a dri...



details:   https://anonhg.NetBSD.org/xsrc/rev/125d9a5f4be9
branches:  trunk
changeset: 10814:125d9a5f4be9
user:      macallan <macallan%NetBSD.org@localhost>
date:      Fri Nov 12 18:58:14 2021 +0000

description:
crude beginnings of a driver for the Southland Media / Quantum 3D MGX
basic acceleration mostly works in 24bit colour
needs native hw cursor code
windowmaker produces visible artifacts, but it's good enough to run amiwm and
a few xterms

diffstat:

 external/mit/xf86-video-mgx/dist/configure        |    8 +
 external/mit/xf86-video-mgx/dist/src/compat-api.h |   99 ++
 external/mit/xf86-video-mgx/dist/src/mgx.h        |   91 ++
 external/mit/xf86-video-mgx/dist/src/mgx_accel.c  |  393 ++++++++++
 external/mit/xf86-video-mgx/dist/src/mgx_cursor.c |  183 +++++
 external/mit/xf86-video-mgx/dist/src/mgx_driver.c |  796 ++++++++++++++++++++++
 6 files changed, 1570 insertions(+), 0 deletions(-)

diffs (truncated from 1594 to 300 lines):

diff -r 92a362ee26ed -r 125d9a5f4be9 external/mit/xf86-video-mgx/dist/configure
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/mit/xf86-video-mgx/dist/configure        Fri Nov 12 18:58:14 2021 +0000
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+# Identity of this package.
+PACKAGE_NAME='xf86-video-mgx'
+PACKAGE_TARNAME='xf86-video-mgx'
+PACKAGE_VERSION='0.0.1'
+PACKAGE_STRING='xf86-video-mgx 0.0.1'
+PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg'
diff -r 92a362ee26ed -r 125d9a5f4be9 external/mit/xf86-video-mgx/dist/src/compat-api.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/mit/xf86-video-mgx/dist/src/compat-api.h Fri Nov 12 18:58:14 2021 +0000
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Author: Dave Airlie <airlied%redhat.com@localhost>
+ */
+
+/* this file provides API compat between server post 1.13 and pre it,
+   it should be reused inside as many drivers as possible */
+#ifndef COMPAT_API_H
+#define COMPAT_API_H
+
+#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
+#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
+#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
+#endif
+
+#ifndef XF86_HAS_SCRN_CONV
+#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
+#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
+#endif
+
+#ifndef XF86_SCRN_INTERFACE
+
+#define SCRN_ARG_TYPE int
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)]
+
+#define SCREEN_ARG_TYPE int
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
+
+#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
+
+#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS scrnIndex, pScreen
+
+#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
+#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0
+
+#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
+#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0
+
+#define FREE_SCREEN_ARGS_DECL int arg, int flags
+
+#define VT_FUNC_ARGS_DECL int arg, int flags
+#define VT_FUNC_ARGS pScrn->scrnIndex, 0
+
+#define XF86_SCRN_ARG(x) ((x)->scrnIndex)
+#else
+#define SCRN_ARG_TYPE ScrnInfoPtr
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1)
+
+#define SCREEN_ARG_TYPE ScreenPtr
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1)
+
+#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask
+
+#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS pScreen
+
+#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
+#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
+
+#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
+#define SWITCH_MODE_ARGS(arg, m) arg, m
+
+#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
+
+#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
+#define VT_FUNC_ARGS pScrn
+
+#define XF86_SCRN_ARG(x) (x)
+
+#endif
+
+#endif
diff -r 92a362ee26ed -r 125d9a5f4be9 external/mit/xf86-video-mgx/dist/src/mgx.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/mit/xf86-video-mgx/dist/src/mgx.h        Fri Nov 12 18:58:14 2021 +0000
@@ -0,0 +1,91 @@
+/*
+ * TCX framebuffer - defines.
+ *
+ * Copyright (C) 2000 Jakub Jelinek (jakub%redhat.com@localhost)
+ *
+ * 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
+ * JAKUB JELINEK 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.
+ */
+
+#ifndef MGX_H
+#define MGX_H
+
+#define MMIO_IS_BE
+
+#include "xorg-server.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "compiler.h"
+#include "xf86RamDac.h"
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "xf86sbusBus.h"
+#include "exa.h"
+
+#include <dev/wscons/wsconsio.h>
+
+#include "compat-api.h"
+
+typedef struct {
+       uint8_t         *fb;
+       uint8_t         *blt;
+       sbusDevicePtr   psdp;
+       CloseScreenProcPtr CloseScreen;
+       struct wsdisplay_cursor cursor;
+       Bool            HWCursor, NoAccel;
+       int             vramsize;       /* size of the fb */
+       int             maskoffset;
+       xf86CursorInfoPtr CursorInfoRec;
+       OptionInfoPtr   Options;
+       ExaDriverPtr    pExa;
+       uint32_t        dec;
+       int             offset;
+} MgxRec, *MgxPtr;
+
+Bool MgxInitAccel(ScreenPtr);
+Bool MgxSetupCursor(ScreenPtr);
+
+#define GET_MGX_FROM_SCRN(p)    ((MgxPtr)((p)->driverPrivate))
+
+static inline void MgxWrite1(MgxPtr pMgx, int offset, uint8_t val)
+{
+       MMIO_OUT8(pMgx->blt, offset ^ 3, val);
+}
+
+static inline void MgxWrite2(MgxPtr pMgx, int offset, uint16_t val)
+{
+       MMIO_OUT16(pMgx->blt, offset ^ 2, val);
+}
+
+static inline void MgxWrite4(MgxPtr pMgx, int offset, uint32_t val)
+{
+       MMIO_OUT32(pMgx->blt, offset, val);
+}
+
+static inline uint8_t MgxRead1(MgxPtr pMgx, int offset)
+{
+       uint8_t val = MMIO_IN8(pMgx->blt, offset ^ 3);
+       return val;
+}
+
+static inline uint32_t MgxRead4(MgxPtr pMgx, int offset)
+{
+       uint32_t val = MMIO_IN32(pMgx->blt, offset);
+       return val;
+}
+
+#endif /* MGX_H */
diff -r 92a362ee26ed -r 125d9a5f4be9 external/mit/xf86-video-mgx/dist/src/mgx_accel.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/mit/xf86-video-mgx/dist/src/mgx_accel.c  Fri Nov 12 18:58:14 2021 +0000
@@ -0,0 +1,393 @@
+/*
+ * Southland Media MGX - hardware acceleration.
+ *
+ * Copyright (C) 2021 Michael Lorenz
+ *
+ * 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
+ * MICHAEL LORENZ 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.
+ */
+
+/* $NetBSD: mgx_accel.c,v 1.1 2021/11/12 18:58:14 macallan Exp $ */
+
+#include <sys/types.h>
+
+#include "mgx.h"
+#include <dev/sbus/mgxreg.h>
+
+//#define DEBUG
+
+#ifdef DEBUG
+#define ENTER xf86Msg(X_ERROR, "%s\n", __func__)
+#define LEAVE xf86Msg(X_ERROR, "%s done\n", __func__)
+#define DBGMSG xf86Msg
+#else
+#define ENTER
+#define DBGMSG if (0) xf86Msg
+#define LEAVE
+#endif
+
+/* Translation from X ROP's to APM ROP's. */
+static unsigned char apmROP[] = {
+  0,
+  0x88,
+  0x44,
+  0xCC,
+  0x22,
+  0xAA,
+  0x66,
+  0xEE,
+  0x11,
+  0x99,
+  0x55,
+  0xDD,
+  0x33,
+  0xBB,
+  0x77,
+  0xFF
+};
+
+static void
+MgxWaitMarker(ScreenPtr pScreen, int Marker)
+{
+       ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+       MgxPtr pMgx = GET_MGX_FROM_SCRN(pScrn);
+       int bail = 0x0fffffff;
+       uint8_t stat;
+
+       ENTER;
+       do {
+               stat = MgxRead1(pMgx, ATR_BLT_STATUS);
+               if ((stat & (BLT_HOST_BUSY | BLT_ENGINE_BUSY)) == 0)
+                       break;
+               bail--;
+       } while (bail < 0);
+       if (bail == 0) DBGMSG(X_ERROR, "%s timed out\n", __func__);
+       LEAVE;
+}
+
+static void
+MgxWait(MgxPtr pMgx)
+{
+       int bail = 10000;
+       uint8_t stat;



Home | Main Index | Thread Index | Old Index