Source-Changes-HG archive

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

[xsrc/trunk]: xsrc/external/mit/xorg-server.old/dist/hw/sun Cherry-pick non-X...



details:   https://anonhg.NetBSD.org/xsrc/rev/eb98bcefc8e1
branches:  trunk
changeset: 10526:eb98bcefc8e1
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Aug 01 13:40:55 2020 +0000

description:
Cherry-pick non-Xorg-1.20-specific fixes from xorg-server dir.

 Use proper ANSI offsetof(3) to specify framebuffer offset in struct.
 Add prototype declarations for CG2 functions.
 Implement functions to restore palette settings on exiting Xserver.
 Explicitly initialize origColormapValid for readability.
 Fix LED defintions to match xkb/xkbInit.c.
 Remove unused functions required to handle non-XKB autorepeat.
 Initialize ModMap dynamically using keymap data per each keyboard.
 Remove now unused ModMap data for each keyboard.
 Use "empty" for rmlvo model and layout to avoid lingering default settings.
 Trailing whitespace.

Note it looks there is some serious performance regression
between Xorg 1.10 and 1.20 on rendering root_weave to root window
on 3/60 bwtwo mono server.

diffstat:

 external/mit/xorg-server.old/dist/hw/sun/sun.h       |   14 +-
 external/mit/xorg-server.old/dist/hw/sun/sunCfb.c    |   81 +++-
 external/mit/xorg-server.old/dist/hw/sun/sunFbs.c    |    7 +-
 external/mit/xorg-server.old/dist/hw/sun/sunInit.c   |    1 -
 external/mit/xorg-server.old/dist/hw/sun/sunKbd.c    |  142 ++++++-
 external/mit/xorg-server.old/dist/hw/sun/sunKeyMap.c |  359 -------------------
 6 files changed, 201 insertions(+), 403 deletions(-)

diffs (truncated from 1247 to 300 lines):

diff -r 6cc6b4c49a7b -r eb98bcefc8e1 external/mit/xorg-server.old/dist/hw/sun/sun.h
--- a/external/mit/xorg-server.old/dist/hw/sun/sun.h    Sat Aug 01 13:15:57 2020 +0000
+++ b/external/mit/xorg-server.old/dist/hw/sun/sun.h    Sat Aug 01 13:40:55 2020 +0000
@@ -247,11 +247,21 @@
     CursorPtr      pCursor;            /* current cursor */
 } sunCursorRec, *sunCursorPtr;
 
+#define NCMAP  256
+typedef struct {
+    u_char         origRed[NCMAP];
+    u_char         origGreen[NCMAP];
+    u_char         origBlue[NCMAP];
+} sunCmapRec, *sunCmapPtr;
+
 typedef struct {
     ColormapPtr            installedMap;
     CloseScreenProcPtr CloseScreen;
     void           (*UpdateColormap)(ScreenPtr, int, int, u_char *, u_char *, u_char *);
     void           (*GetColormap)(ScreenPtr, int, int, u_char *, u_char *, u_char *);
+    Bool           origColormapValid;
+    sunCmapRec     origColormap;
+    void           (*RestoreColormap)(ScreenPtr);
     sunCursorRec    hardwareCursor;
     Bool           hasHardwareCursor;
 } sunScreenRec, *sunScreenPtr;
@@ -296,10 +306,8 @@
 
 /* sunKeyMap.c */
 extern KeySymsRec      sunKeySyms[];
-extern const SunModmapRec *sunModMaps[];
 extern const int       sunMaxLayout;
 extern KeySym          *sunType4KeyMaps[];
-extern const SunModmapRec *sunType4ModMaps[];
 
 /* sunKbd.c */
 extern long            sunAutoRepeatInitiate;
@@ -351,8 +359,6 @@
 extern void sunKbdEnqueueEvent(DeviceIntPtr, Firm_event *);
 extern int sunKbdProc(DeviceIntPtr, int);
 extern void sunKbdWait(void);
-void sunBlockHandler(int, pointer, pointer, pointer);
-void sunWakeupHandler(int, pointer, unsigned long, pointer);
 
 /* sunMouse.c */
 extern Firm_event* sunMouseGetEvents(int, Bool, int *, Bool *);
diff -r 6cc6b4c49a7b -r eb98bcefc8e1 external/mit/xorg-server.old/dist/hw/sun/sunCfb.c
--- a/external/mit/xorg-server.old/dist/hw/sun/sunCfb.c Sat Aug 01 13:15:57 2020 +0000
+++ b/external/mit/xorg-server.old/dist/hw/sun/sunCfb.c Sat Aug 01 13:40:55 2020 +0000
@@ -94,8 +94,18 @@
 static void CGUpdateColormap(ScreenPtr, int, int, u_char *, u_char *, u_char *);
 static void CGGetColormap(ScreenPtr, int, int, u_char *, u_char *, u_char *);
 static void CGStoreColors(ColormapPtr, int, xColorItem *);
+static void CGSaveColormap(ScreenPtr);
+static void CGRestoreColormap(ScreenPtr);
+static void CGScreenInitCommon(ScreenPtr);
 static void CGScreenInit(ScreenPtr);
 static void checkMono(int, char **);
+#ifdef INCLUDE_CG2_HEADER
+static void CG2UpdateColormap(ScreenPtr, int, int, u_char *, u_char *, u_char *);
+static void CG2GetColormap(ScreenPtr, int, int, u_char *, u_char *, u_char *);
+static void CG2RestoreColormap(ScreenPtr);
+static Bool CG2SaveScreen(ScreenPtr, int);
+static void CG2ScreenInit(ScreenPtr pScreen);
+#endif
 static void CG4Switch(ScreenPtr, int);
 
 static void
@@ -239,22 +249,61 @@
 }
 
 static void
-CGScreenInit(ScreenPtr pScreen)
+CGSaveColormap(ScreenPtr pScreen)
+{
+    sunScreenPtr pPrivate = sunGetScreenPrivate(pScreen);
+    sunCmapPtr origColormap;
+    u_char *rmap, *gmap, *bmap;
+
+    origColormap = &pPrivate->origColormap;
+    rmap = origColormap->origRed;
+    gmap = origColormap->origGreen;
+    bmap = origColormap->origBlue;
+    (*pPrivate->GetColormap)(pScreen, 0, NCMAP, rmap, gmap, bmap);
+}
+
+static void
+CGRestoreColormap(ScreenPtr pScreen)
 {
-#ifndef STATIC_COLOR /* { */
     sunScreenPtr pPrivate = sunGetScreenPrivate(pScreen);
+    sunCmapPtr origColormap;
+    u_char *rmap, *gmap, *bmap;
+
+    if (pPrivate->origColormapValid) {
+       origColormap = &pPrivate->origColormap;
+       rmap = origColormap->origRed;
+       gmap = origColormap->origGreen;
+       bmap = origColormap->origBlue;
+       (*pPrivate->UpdateColormap)(pScreen, 0, NCMAP, rmap, gmap, bmap);
+    }
+}
+
+static void
+CGScreenInitCommon(ScreenPtr pScreen)
+{
     pScreen->InstallColormap = sunInstallColormap;
     pScreen->UninstallColormap = sunUninstallColormap;
     pScreen->ListInstalledColormaps = sunListInstalledColormaps;
     pScreen->StoreColors = CGStoreColors;
-    pPrivate->UpdateColormap = CGUpdateColormap;
-    pPrivate->GetColormap = CGGetColormap;
     if (sunFlipPixels) {
        Pixel pixel = pScreen->whitePixel;
        pScreen->whitePixel = pScreen->blackPixel;
        pScreen->blackPixel = pixel;
     }
-#endif /* } */
+}
+
+static void
+CGScreenInit(ScreenPtr pScreen)
+{
+    sunScreenPtr pPrivate = sunGetScreenPrivate(pScreen);
+
+    CGScreenInitCommon(pScreen);
+    pPrivate->UpdateColormap = CGUpdateColormap;
+    pPrivate->GetColormap = CGGetColormap;
+    pPrivate->RestoreColormap = CGRestoreColormap;
+
+    CGSaveColormap(pScreen);
+    pPrivate->origColormapValid = TRUE;
 }
 
 static void
@@ -363,6 +412,15 @@
     }
 }
 
+static void
+CG2RestoreColormap(ScreenPtr pScreen)
+{
+    int screen = pScreen->myNum;
+
+    CGRestoreColormap(pScreen);
+    ((CG2Ptr)sunFbs[screen].fb)->regs.ppmask.reg = 1;
+}
+
 static Bool
 CG2SaveScreen(ScreenPtr pScreen, int on)
 {
@@ -378,9 +436,14 @@
 CG2ScreenInit(ScreenPtr pScreen)
 {
     sunScreenPtr pPrivate = sunGetScreenPrivate(pScreen);
-    CGScreenInit (pScreen);
+
+    CGScreenInitCommon(pScreen);
     pPrivate->UpdateColormap = CG2UpdateColormap;
     pPrivate->GetColormap = CG2GetColormap;
+    pPrivate->RestoreColormap = CG2RestoreColormap;
+
+    CGSaveColormap(pScreen);
+    pPrivate->origColormapValid = TRUE;
 }
 
 Bool
@@ -415,7 +478,7 @@
        ret = sunInitCommon (screen, pScreen, (off_t) 0,
                        sunCfbScreenInit, CG2ScreenInit,
                        fbCreateDefColormap, CG2SaveScreen,
-                       (int) &((struct cg2memfb *) 0)->pixplane);
+                       offsetof(struct cg2memfb, pixplane));
        ((CG2Ptr) sunFbs[screen].fb)->regs.ppmask.reg = 0xFF;
 #ifndef LOWMEMFTPT
     }
@@ -433,7 +496,7 @@
     u_char mpixel[CG4_MELEN];          /* bit-per-pixel memory */
     u_char epixel[CG4_MELEN];          /* enable plane */
     u_char cpixel[CG4_HEIGHT][CG4_WIDTH];      /* byte-per-pixel memory */
-} *CG4Ptr;
+} *CG4Ptr, CG4Rec;
 
 static void
 CG4Switch(ScreenPtr pScreen, int select)
@@ -458,7 +521,7 @@
        sunFbs[screen].EnterLeave = CG4Switch;
     return sunInitCommon (screen, pScreen, (off_t) 0,
        sunCfbScreenInit, CGScreenInit,
-       fbCreateDefColormap, sunSaveScreen, (int) ((CG4Ptr) 0)->cpixel);
+       fbCreateDefColormap, sunSaveScreen, offsetof(CG4Rec, cpixel));
 }
 
 #ifdef FBTYPE_SUNFAST_COLOR /* { */
diff -r 6cc6b4c49a7b -r eb98bcefc8e1 external/mit/xorg-server.old/dist/hw/sun/sunFbs.c
--- a/external/mit/xorg-server.old/dist/hw/sun/sunFbs.c Sat Aug 01 13:15:57 2020 +0000
+++ b/external/mit/xorg-server.old/dist/hw/sun/sunFbs.c Sat Aug 01 13:40:55 2020 +0000
@@ -137,10 +137,11 @@
        Error("dixRegisterPrivateKey failed");
        return FALSE;
     }
-    pPrivate = (sunScreenPtr) xalloc (sizeof (sunScreenRec));
+    pPrivate = calloc(1, sizeof (sunScreenRec));
     if (!pPrivate)
        return FALSE;
 
+    pPrivate->origColormapValid = FALSE;
     sunSetScreenPrivate(pScreen, pPrivate);
     return TRUE;
 }
@@ -171,10 +172,12 @@
 #if 0  /* XXX GX is disabled for now */
     sunDisableCursor (pScreen);
 #endif
+    if (pPrivate->origColormapValid)
+       (*pPrivate->RestoreColormap)(pScreen);
     pScreen->CloseScreen = pPrivate->CloseScreen;
     ret = (*pScreen->CloseScreen) (i, pScreen);
     (void) (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
-    xfree ((pointer) pPrivate);
+    free ((pointer) pPrivate);
     return ret;
 }
 
diff -r 6cc6b4c49a7b -r eb98bcefc8e1 external/mit/xorg-server.old/dist/hw/sun/sunInit.c
--- a/external/mit/xorg-server.old/dist/hw/sun/sunInit.c        Sat Aug 01 13:15:57 2020 +0000
+++ b/external/mit/xorg-server.old/dist/hw/sun/sunInit.c        Sat Aug 01 13:40:55 2020 +0000
@@ -511,7 +511,6 @@
                FatalError ("Unsupported keyboard type 4 layout %d\n",
                            sunKbdPriv.layout);
            sunKeySyms[KB_SUN4].map = sunType4KeyMaps[sunKbdPriv.layout];
-           sunModMaps[KB_SUN4] = sunType4ModMaps[sunKbdPriv.layout];
         }
        inited = 1;
     }
diff -r 6cc6b4c49a7b -r eb98bcefc8e1 external/mit/xorg-server.old/dist/hw/sun/sunKbd.c
--- a/external/mit/xorg-server.old/dist/hw/sun/sunKbd.c Sat Aug 01 13:15:57 2020 +0000
+++ b/external/mit/xorg-server.old/dist/hw/sun/sunKbd.c Sat Aug 01 13:40:55 2020 +0000
@@ -51,13 +51,24 @@
 #include "xkbsrv.h"
 #include "xkbstr.h"
 
+#ifdef __sun
 #define SUN_LED_MASK   0x0f
+#else
+#define SUN_LED_MASK   0x07
+#endif
 #define MIN_KEYCODE    7       /* necessary to avoid the mouse buttons */
 #define MAX_KEYCODE    255     /* limited by the protocol */
+#define NUM_KEYCODES   (MAX_KEYCODE - MIN_KEYCODE + 1)
 #ifndef KB_SUN4
 #define KB_SUN4                4
 #endif
 
+#define Meta_Mask      Mod1Mask
+#define Mode_switch_Mask Mod2Mask
+#define Alt_Mask       Mod3Mask
+#define Num_Lock_Mask  Mod4Mask
+#define ScrollLockMask Mod5Mask
+
 #define tvminus(tv, tv1, tv2)   /* tv = tv1 - tv2 */ \
                if ((tv1).tv_usec < (tv2).tv_usec) { \
                    (tv1).tv_usec += 1000000; \
@@ -74,6 +85,7 @@
                    (tv).tv_sec += 1; \
                }
 
+static void sunInitModMap(const KeySymsRec *, CARD8 *);
 static void SwapLKeys(KeySymsRec *);
 static void SetLights(KeybdCtrl *, int);
 static KeyCode LookupKeyCode(KeySym, XkbDescPtr, KeySymsPtr);
@@ -138,6 +150,7 @@
 #ifdef KIOCSLED
     static unsigned char led_tab[16] = {
        0,
+#ifdef __sun
        LED_NUM_LOCK,
        LED_SCROLL_LOCK,
        LED_SCROLL_LOCK | LED_NUM_LOCK,
@@ -153,9 +166,26 @@
        LED_CAPS_LOCK | LED_COMPOSE | LED_NUM_LOCK,
        LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK,
        LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK
+#else
+       LED_CAPS_LOCK,
+       LED_NUM_LOCK,
+       LED_NUM_LOCK | LED_CAPS_LOCK,
+       LED_SCROLL_LOCK,
+       LED_SCROLL_LOCK | LED_CAPS_LOCK,
+       LED_SCROLL_LOCK | LED_NUM_LOCK,
+       LED_SCROLL_LOCK | LED_NUM_LOCK | LED_CAPS_LOCK,
+       LED_COMPOSE,
+       LED_COMPOSE | LED_CAPS_LOCK,
+       LED_COMPOSE | LED_NUM_LOCK,
+       LED_COMPOSE | LED_NUM_LOCK | LED_CAPS_LOCK,
+       LED_COMPOSE | LED_SCROLL_LOCK,
+       LED_COMPOSE | LED_SCROLL_LOCK | LED_CAPS_LOCK,
+       LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK,
+       LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK | LED_CAPS_LOCK,
+#endif
     };



Home | Main Index | Thread Index | Old Index