Skip to main content

[xwin-commits] [solaris-x11~x-s11-update-clone:1368] 15758019 SUNBT7116629 Screen turned to BLUE after running VTS graphicstes

  • From:
  • To:
  • Subject: [xwin-commits] [solaris-x11~x-s11-update-clone:1368] 15758019 SUNBT7116629 Screen turned to BLUE after running VTS graphicstes
  • Date: Tue, 24 Sep 2013 21:04:10 +0000

Project:    solaris-x11
Repository: x-s11-update-clone
Revision:   1368
Author:     x-hg
Date:       2013-09-24 21:01:59 UTC
Link:       

Log Message:
------------
15758019 SUNBT7116629 Screen turned to BLUE after running VTS graphicstest on 
Xorg w/efb
17207515 unable to interrupt vts efb graphicstest


Revisions:
----------
1368


Modified Paths:
---------------
open-src/app/gfx-utils/sun-src/vts/efb/chip.c
open-src/app/gfx-utils/sun-src/vts/efb/efb.h
open-src/app/gfx-utils/sun-src/vts/efb/libvtsSUNWefb.c
open-src/app/gfx-utils/sun-src/vts/efb/libvtsSUNWefb.h
open-src/app/gfx-utils/sun-src/vts/efb/mapfile
open-src/app/gfx-utils/sun-src/vts/efb/mapper.c
open-src/app/gfx-utils/sun-src/vts/efb/memory.c
open-src/app/gfx-utils/sun-src/vts/efb/tools.c


Diffs:
------
diff -r f94011dda343 -r 475ce9398539 
open-src/app/gfx-utils/sun-src/vts/efb/chip.c
--- a/open-src/app/gfx-utils/sun-src/vts/efb/chip.c     Wed Sep 18 11:01:17 
2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/efb/chip.c     Tue Sep 24 14:01:59 
2013 -0700
@@ -1,6 +1,5 @@
-
 /*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights 
reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights 
reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -22,315 +21,239 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include <sys/types.h>
-#include <errno.h>
-#include <signal.h>            /* signal() */
-#include <stdio.h>
-#include <stropts.h>           /* ioctl() */
-#include <unistd.h>            /* ioctl(), sleep() */
-#include <sys/mman.h>
+#include "libvtsSUNWefb.h"
 
-#include "gfx_common.h"                /* VTS Graphics Test common routines 
*/
-#include "graphicstest.h"
-#include "gfx_vts.h"           /* VTS Graphics Test common routines */
-#include "efb.h"               
+/*
+ * efb_test_chip()
+ *
+ *    Test Chip, functional tests.
+ */
 
-void
-box(struct efb_info *pEFB, int x1, int y1, int x2, int y2, unsigned int 
color)
+return_packet *
+efb_test_chip(
+    register int const fd)
 {
-       int             tmp;
-       int             width;
-       int             height;
-       unsigned int    v;
+       static return_packet rp;
 
-       width  = x2 - x1;
-       height = y2 - y1;
+       memset(&rp, 0, sizeof (return_packet));
 
-       if ((width <= 0) || (height <= 0)) {
-#ifdef DEBUG
-               printf("x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
-#endif
-               return;
+       if (gfx_vts_debug_mask & GRAPHICS_VTS_CHIP_OFF)
+               return (&rp);
+
+       TraceMessage(VTS_DEBUG, "efb_test_chip", "efb_test_chip running\n");
+
+       efb_block_signals();
+
+       efb_lock_display();
+
+       chip_test(&rp, fd);
+
+       efb_unlock_display();
+
+       efb_restore_signals();
+
+       TraceMessage(VTS_DEBUG, "efb_test_chip", "efb_test_chip completed\n");
+
+       return (&rp);
+
+}      /* efb_test_chip() */
+
+
+int
+chip_test(
+    register return_packet *const rp,
+    register int const fd)
+{
+       register uint_t black;
+       register uint_t white;
+
+       memset(&efb_info, 0, sizeof (efb_info));
+       efb_info.efb_fd = fd;
+
+       /*
+        * map the registers & frame buffers memory
+        */
+       if (efb_map_mem(rp, GRAPHICS_ERR_CHIP) != 0)
+               return (-1);
+
+       if (efb_init_info(rp, GRAPHICS_ERR_CHIP) != 0) {
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
        }
 
-       efb_wait_for_fifo(pEFB, 5);
-
-       REGW(RADEON_DP_WRITE_MASK, 0xffffffff);
-       REGW(RADEON_DP_CNTL,    
-               (RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM));
-
-       REGW(RADEON_DP_BRUSH_FRGD_CLR, color);
-        REGW(DST_Y_X,  x1 << DST_Y_X__DST_X__SHIFT |
-                       y1 << DST_Y_X__DST_Y__SHIFT) ;
-        REGW(DST_WIDTH_HEIGHT,
-              height << DST_WIDTH_HEIGHT__DST_HEIGHT__SHIFT |
-              width << DST_WIDTH_HEIGHT__DST_WIDTH__SHIFT ) ;
-
-}      /* box() */
-
-void
-line(struct efb_info *pEFB,
-       int             x1,
-       int             y1,
-       int             x2,
-       int             y2,
-       unsigned int    color
-       )
-{
-       efb_wait_for_fifo(pEFB, 5);
-
-       REGW(RADEON_DP_WRITE_MASK, 0xffffffff);
-       REGW(RADEON_DP_CNTL,    
-               (RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM));
-
-       REGW(RADEON_DP_BRUSH_FRGD_CLR, color);
-        REGW(DST_LINE_START,  
-               (x1 << DST_LINE_START__DST_START_X__SHIFT | y1 << 
DST_LINE_START__DST_START_Y__SHIFT));
-        REGW(DST_LINE_END,  
-               (x2 << DST_LINE_END__DST_END_X__SHIFT | y2 << 
DST_LINE_END__DST_END_Y__SHIFT));
-
-}      /* line() */
-
-#define NBOX 100
-
-void
-draw_cascaded_box(struct efb_info *pEFB, int width, int height)
-{
-       unsigned int    x1;
-       unsigned int    y1;
-       unsigned int    x2;
-       unsigned int    y2;
-       unsigned int    w;
-       unsigned int    h;
-       unsigned int    i, j;
-       unsigned int    k = 0;
-       unsigned int    cinc = 0;
-       unsigned int    xinc, yinc;
-
-       cinc = 256 / NBOX;
-       xinc = width / (NBOX * 2);
-       yinc = height / (NBOX * 2);
-       x1 = y1 = 0;
-
-       for (i = 0; i < NBOX; i++) {
-
-           x2 = width - x1;
-           y2 = height - y1;
-
-           j = i * cinc;
-
-           k = (j<<24 | j<<16 | j<<8 | j);
-
-           box(pEFB, x1, y1, x2, y2, k);
-
-           x1 += xinc;
-           y1 += yinc;
+       if (!efb_init_graphics()) {
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
        }
 
-}      /* draw_cascaded_box() */
+       efb_save_palet();
+       efb_set_palet();
 
-
-#define NLINE 128
-
-void
-draw_lines(struct efb_info *pEFB, int width, int height)
-{
-       unsigned int    x1;
-       unsigned int    y1;
-       unsigned int    x2;
-       unsigned int    y2;
-       int             k;
-       int             i;
-       unsigned int    xinc, yinc;
-
-       xinc = width / NLINE;
-       yinc = height / NLINE;
-       x1 = y1 = 0;
-
-
-       k = 0;
-       x1 = 0;
-       y1 = 0;
-       y2 = height;
-       for (i = 0; i < NLINE; i++) {
-           k  = 0x00af0000 | (i << 8) | i;
-
-           x2 = x1;
-
-           line(pEFB, x1, y1, x2, y2, k);
-       
-           x1 += xinc;
+       /*
+        * Clear screen black
+        */
+       black = efb_color(0x00, 0x00, 0x00);
+       if (!efb_fill_solid_rect(0, 0,
+           efb_info.efb_width, efb_info.efb_height, black)) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
        }
 
-       x1 = 0;
-       x2 = width;
-       y1 = 0;
-
-       for (i = 0; i < NLINE; i++) {
-           k  = 0x00af0000 | (i << 8) | i;
-
-           y2 = y1;
-
-           line(pEFB, x1, y1, x2, y2, k);
-
-           y1 += yinc;
-       }
-}
-
-int
-efb_init_2D(struct efb_info *pEFB)
-{
-       unsigned int pitch_offset;
-       unsigned int pitch;
-       unsigned int offset;
-       unsigned int bytepp;
-       unsigned int gmc_bpp;
-       unsigned int dp_datatype;
-       unsigned int v;
-       int i;
-
-       switch (pEFB->bitsPerPixel) {
-       case 8:
-               gmc_bpp = GMC_DST_8BPP;
-               dp_datatype = DST_8BPP | BRUSH_SOLIDCOLOR | SRC_DSTCOLOR;
-               bytepp = 1;
-               break;
-       case 32:
-               gmc_bpp = GMC_DST_32BPP;
-               dp_datatype = DST_32BPP | BRUSH_SOLIDCOLOR | SRC_DSTCOLOR;
-               bytepp = 4;
-               break;
+       if (!efb_wait_idle()) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
        }
 
-       offset = REGR(CRTC_OFFSET) & 0x7ffffff;
-       pitch = REGR(CRTC_PITCH) & 0x7ff;
-
-       pitch = pitch * 8;      // was in groups of 8 pixels
-
-       pitch_offset = 
-               ((pitch * bytepp / 64) << 22) |
-               (offset / 1024);
-
-        /*
-         * Initialize GUI engine
-         */
-        efb_wait_for_idle(pEFB);
-
-       efb_wait_for_fifo(pEFB, 5);
-
-
-        REGW(DEFAULT_PITCH_OFFSET, pitch_offset);
-        REGW(RADEON_DST_PITCH_OFFSET, pitch_offset);
-        REGW(RADEON_SRC_PITCH_OFFSET, pitch_offset);
-
-        REGW(DEFAULT_SC_BOTTOM_RIGHT,  
-               (pEFB->screenHeight << 16) |
-               (pEFB->screenWidth));
-
-        v = (
-           GMC_SRC_PITCH_OFFSET_DEFAULT |
-           GMC_DST_PITCH_OFFSET_LEAVE |
-           GMC_SRC_CLIP_DEFAULT        |
-           GMC_DST_CLIP_DEFAULT        |
-            GMC_BRUSH_SOLIDCOLOR        |
-            gmc_bpp                     |
-            GMC_SRC_DSTCOLOR            |
-            RADEON_ROP3_P               |
-            GMC_WRITE_MASK_LEAVE);
-
-        REGW(RADEON_DP_GUI_MASTER_CNTL,  v);
-
-#ifdef DEBUG
-       printf("v=0x%x\n", v);
-#endif
-}
-
-
-
-
-void
-chip_test(return_packet *rp, int fd)
-{
-        struct efb_info  efb_info;
-        struct efb_info  *pEFB;
-        unsigned int red;
-        unsigned char *fbaddr;
-        int i;
-        int bytepp;
-        int fb_offset, fb_pitch, fb_height, fb_width;
-
-        pEFB = &efb_info;
-        pEFB->fd = fd;
-
-        /*
-         * map the registers & frame buffers memory
-         */
-        if (efb_map_mem(pEFB, rp, GRAPHICS_ERR_CHIP) == -1) {
-            return;
-        }
-
-        /*
-         * initialize efb info
-         */
-        if (efb_init_info(pEFB) == -1) {
-            return;
-        }
-
-       if (efb_init_2D(pEFB) == -1) {
-           return;
-       }
-
-
-       /* 
-        * Clear screen 
-        */
-       box(pEFB, 0, 0, pEFB->screenWidth, pEFB->screenHeight, 0);
-       efb_wait_for_idle(pEFB);
-       efb_flush_pixel_cache(pEFB);
-       sleep(2);
+       efb_flush_pixel_cache();
 
        /*
         * line test
         */
-       draw_lines(pEFB, pEFB->screenWidth, pEFB->screenHeight);
-       efb_wait_for_idle(pEFB);
-       efb_flush_pixel_cache(pEFB);
-       sleep(1);
+       if (!draw_lines(efb_info.efb_width, efb_info.efb_height)) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
+       }
+
+       if (!efb_wait_idle()) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
+       }
+
+       efb_flush_pixel_cache();
+
+       if (efb_sleep(2)) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
+       }
 
        /*
-        * fill test
+        * fill rectangle test
         */
-       draw_cascaded_box(pEFB, pEFB->screenWidth, pEFB->screenHeight);
-       efb_wait_for_idle(pEFB);
-       efb_flush_pixel_cache(pEFB);
-       sleep(1);
-       efb_wait_for_idle(pEFB);
-       efb_flush_pixel_cache(pEFB);
-
-       /* 
-        * Clear screen 
-        */
-       box(pEFB, 0, 0, pEFB->screenWidth, pEFB->screenHeight, 0xff);
-       efb_wait_for_idle(pEFB);
-       efb_flush_pixel_cache(pEFB);
-       sleep(2);
-
-
-done:
-        /*
-         * Unmap the registers & frame buffers memory
-         */
-        if (efb_unmap_mem(pEFB, rp, GRAPHICS_ERR_CHIP) == -1) {
-            return;
-        }
-
-
-       if (close(fd) == -1) {
-           gfx_vts_set_message(rp, 1, GRAPHICS_ERR_CHIP, "error closing 
device\n");
-           return;
+       if (!draw_cascaded_box(efb_info.efb_width, efb_info.efb_height)) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
        }
 
+       if (!efb_wait_idle()) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
+       }
+
+       efb_flush_pixel_cache();
+
+       if (efb_sleep(2)) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
+       }
+
+       /* Clear screen white */
+
+       white = efb_color(0xff, 0xff, 0xff);
+
+       /*
+        * Clear screen
+        */
+       if (!efb_fill_solid_rect(0, 0,
+           efb_info.efb_width, efb_info.efb_height, white)) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
+       }
+
+       if (!efb_wait_idle()) {
+               efb_restore_palet();
+               efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+               return (-1);
+       }
+
+       efb_flush_pixel_cache();
+
+       efb_sleep(2);
+
+       efb_restore_palet();
+
+       if (efb_unmap_mem(rp, GRAPHICS_ERR_CHIP) != 0)
+               return (-1);
+
+       return (0);
 }      /* chip_test() */
 
 
+int
+draw_lines(
+    register uint_t const width,
+    register uint_t const height)
+{
+       register uint_t x1;
+       register uint_t y1;
+       register uint_t x2;
+       register uint_t y2;
+       register uint_t color;
+       register uint_t lineon;
+       register uint_t const numlines = 128;
+
+       for (lineon = 0; lineon < numlines; lineon++) {
+               color = efb_color(0xaf, lineon, lineon);
+
+               x1 = (uint_t)((width * lineon) / numlines);
+               x2 = x1;
+               y1 = 0;
+               y2 = height;
+
+               if (!efb_draw_solid_line(x1, y1, x2, y2, color))
+                       return (0);
+       }
+
+       for (lineon = 0; lineon < numlines; lineon++) {
+               color = efb_color(0xaf, lineon, lineon);
+
+               x1 = 0;
+               x2 = width;
+               y1 = (uint_t)((height * lineon) / numlines);
+               y2 = y1;
+
+               if (!efb_draw_solid_line(x1, y1, x2, y2, color))
+                       return (0);
+       }
+       return (1);
+}
+
+int
+draw_cascaded_box(
+    register uint_t const width,
+    register uint_t const height)
+{
+       register uint_t x1;
+       register uint_t y1;
+       register uint_t x2;
+       register uint_t y2;
+       register uint_t color;
+       register uint_t recton;
+       register uint_t const numrects = 256;
+
+       for (recton = 0; recton < numrects; recton++) {
+
+               x1 = (uint_t)((width * recton) / 512);
+               x2 = width - x1;
+
+               y1 = (uint_t)((height * recton) / 512);
+               y2 = height - y1;
+
+               color = efb_color(recton, recton, recton);
+
+               if (!efb_fill_solid_rect(x1, y1, x2, y2, color))
+                       return (0);
+       }
+
+       return (1);
+}
+
 /* End of chip.c */

diff -r f94011dda343 -r 475ce9398539 
open-src/app/gfx-utils/sun-src/vts/efb/chip.h
--- a/open-src/app/gfx-utils/sun-src/vts/efb/chip.h     Wed Sep 18 11:01:17 
2013 -0700
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-
-/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights 
reserved.
- *
- * 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.
- */
-
-
-#ifndef        _CHIP_H
-#define        _CHIP_H
-
-
-#include "libvtsSUNWxfb.h"     /* Common VTS library definitions */
-
-
-void chip_test_reset(void);
-
-void chip_test(return_packet *rp, int fd);
-
-
-#endif /* _CHIP_H */
-
-
-/* End of chip.h */

diff -r f94011dda343 -r 475ce9398539 
open-src/app/gfx-utils/sun-src/vts/efb/efb.h
--- a/open-src/app/gfx-utils/sun-src/vts/efb/efb.h      Wed Sep 18 11:01:17 
2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/efb/efb.h      Tue Sep 24 14:01:59 
2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights 
reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights 
reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -21,98 +21,52 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#ifndef EFB_H
-#define EFB_H
+#ifndef        _EFB_H
+#define        _EFB_H
 
-#include <sys/types.h>
-#include <stdio.h>
-#include <sys/mman.h>
-
-#include "gfx_common.h"                /* GFX Common definitions */
-#include "graphicstest.h"
-#include "libvtsSUNWefb.h"     /* Common VTS library definitions */
-
-#include "X11/Xlib.h"
-#include "gfx_vts.h"           /* VTS Graphics Test common routines */
 #include "radeon_reg.h"
 #include "efb_reg.h"
 
-#define EFB_REG_SIZE_LOG2      18
+#define        EFB_REG_SIZE_LOG2       18
 
-struct pci_info {
-       unsigned long   memBase[6];
-       unsigned long   ioBase[6];
-       unsigned int    type [6];
-       unsigned int    size [6];
-       unsigned int    deviceID;
-};
+#define        READ_MMIO_UINT(addr)            *((uint_t volatile *)(addr))
+#define        WRITE_MMIO_UINT(addr, val)      *((uint_t volatile *)(addr)) 
= \
+       (val)
 
+#define        INREG(offset)           READ_MMIO_UINT(efb_info.efb_mmio_ptr 
+ \
+       (offset))
+#define        REGW(offset, value)     WRITE_MMIO_UINT(efb_info.efb_mmio_ptr 
+ \
+       (offset), (value))
+#define        REGR(offset)            READ_MMIO_UINT(efb_info.efb_mmio_ptr 
+ \
+       (offset))
 
-#define READ_MMIO_UINT(addr)           *((unsigned int *)(addr))
-#define WRITE_MMIO_UINT(addr, val)     *((unsigned int *)(addr)) = (val)
+#define        PCI_MAP_MEMORY                  0x00000000
+#define        PCI_MAP_IO                      0x00000001
 
-#define INREG(offset)          READ_MMIO_UINT(pEFB->MMIOvaddr + (offset))
-#define REGW(offset, value)    WRITE_MMIO_UINT(pEFB->MMIOvaddr + (offset), 
(value))
-#define REGR(offset)           READ_MMIO_UINT(pEFB->MMIOvaddr + (offset))
+#define        PCI_MAP_MEMORY_TYPE             0x00000007
+#define        PCI_MAP_IO_TYPE                 0x00000003
 
-typedef unsigned int (*PFNRead32)  (unsigned char *);
-typedef void         (*PFNWrite32) (unsigned char *, unsigned int);
+#define        PCI_MAP_MEMORY_TYPE_32BIT       0x00000000
+#define        PCI_MAP_MEMORY_TYPE_32BIT_1M    0x00000002
+#define        PCI_MAP_MEMORY_TYPE_64BIT       0x00000004
+#define        PCI_MAP_MEMORY_TYPE_MASK        0x00000006
+#define        PCI_MAP_MEMORY_CACHABLE         0x00000008
+#define        PCI_MAP_MEMORY_ATTR_MASK        0x0000000e
+#define        PCI_MAP_MEMORY_ADDRESS_MASK     0xfffffff0
 
-struct efb_info {
-       int             fd;
+#define        PCI_MAP_IO_ATTR_MASK            0x00000003
+#define        PCI_MAP_IS_IO(b)                ((b) & PCI_MAP_IO)
+#define        PCI_MAP_IO_ADDRESS_MASK         0xfffffffc
 
-       int             screenWidth;
-       int             screenHeight;
-       int             screenPitch;
-       int             bitsPerPixel;
+#define        PCIGETIO(b)                     ((b) & 
PCI_MAP_IO_ADDRESS_MASK)
 
-       unsigned int    ChipSet;
+#define        PCI_MAP_IS64BITMEM(b) \
+       (((b) & PCI_MAP_MEMORY_TYPE) == PCI_MAP_MEMORY_TYPE_64BIT)
 
-       unsigned long   FBPhysAddr;
-       unsigned long   MMIOPhysAddr;
-       unsigned long   RelocateIO;
-       unsigned long   fbLocation;
+#define        PCIGETMEMORY(b)                 ((b) & 
PCI_MAP_MEMORY_ADDRESS_MASK)
 
-       int             FBMapSize;
-       int             MMIOMapSize;
+#define        PCI_REGION_BASE(_pcidev, _b, _type)                     \
+       (((_type) == REGION_MEM) ? (_pcidev)->memBase[(_b)] :   \
+       (_pcidev)->ioBase[(_b)])
 
-       unsigned char   *FBvaddr;
-       unsigned char   *MMIOvaddr;
-};
-
-#define PCI_MAP_MEMORY                  0x00000000
-#define PCI_MAP_IO                     0x00000001
-
-#define PCI_MAP_MEMORY_TYPE             0x00000007
-#define PCI_MAP_IO_TYPE                 0x00000003
-
-#define PCI_MAP_MEMORY_TYPE_32BIT       0x00000000
-#define PCI_MAP_MEMORY_TYPE_32BIT_1M    0x00000002
-#define PCI_MAP_MEMORY_TYPE_64BIT       0x00000004
-#define PCI_MAP_MEMORY_TYPE_MASK        0x00000006
-#define PCI_MAP_MEMORY_CACHABLE         0x00000008
-#define PCI_MAP_MEMORY_ATTR_MASK        0x0000000e
-#define PCI_MAP_MEMORY_ADDRESS_MASK     0xfffffff0
-
-#define PCI_MAP_IO_ATTR_MASK           0x00000003
-#define PCI_MAP_IS_IO(b)               ((b) & PCI_MAP_IO)
-#define PCI_MAP_IO_ADDRESS_MASK                0xfffffffc
-
-#define PCIGETIO(b)                    ((b) & PCI_MAP_IO_ADDRESS_MASK)
-
-#define PCI_MAP_IS64BITMEM(b)   \
-        (((b) & PCI_MAP_MEMORY_TYPE) == PCI_MAP_MEMORY_TYPE_64BIT)
-
-#define PCIGETMEMORY(b)                ((b) & PCI_MAP_MEMORY_ADDRESS_MASK)
-
-#define PCI_REGION_BASE(_pcidev, _b, _type)             \
-    (((_type) == REGION_MEM) ? (_pcidev)->memBase[(_b)] \
-                             : (_pcidev)->ioBase[(_b)])
-
-int efb_get_pci_info(int fd, struct pci_info *pci_info); 
-int efb_get_mem_info(struct pci_info *pci_info, struct efb_info *pEFB); 
-int efb_map_mem(struct efb_info *pEFB, return_packet *rp, int test);
-int efb_unmap_mem(struct efb_info *pEFB, return_packet *rp, int test);
-int efb_init_info(struct efb_info *);
-
-#endif /* EFB_H */
+#endif /* _EFB_H */

diff -r f94011dda343 -r 475ce9398539 
open-src/app/gfx-utils/sun-src/vts/efb/libvtsSUNWefb.c
--- a/open-src/app/gfx-utils/sun-src/vts/efb/libvtsSUNWefb.c    Wed Sep 18 
11:01:17 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/efb/libvtsSUNWefb.c    Tue Sep 24 
14:01:59 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights 
reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -21,53 +21,24 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include <sys/types.h>
-#include <sys/param.h>         /* MAXPATHLEN */
-#include <errno.h>
-#include <pwd.h>               /* getpwuid() */
-#include <signal.h>
-#include <stdio.h>             /* snprintf() */
-#include <stdlib.h>            /* exit(), malloc() */
-#include <string.h>            /* strcat(), strcpy() */
-#include <unistd.h>            /* sleep() */
-#include <sys/fbio.h>
-#include <sys/mman.h>
-#include <sys/systeminfo.h>    /* sysinfo() */
-#include <sys/visual_io.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
+#include "libvtsSUNWefb.h"
 
-#include "graphicstest.h"
-#include "gfx_vts.h"           /* VTS Graphics Test common routines */
+efb_info_t efb_info;
 
-#include "libvtsSUNWefb.h"     /* VTS library definitions for efb device */
+efb_xw_t efb_xw;
 
-
-#if (0)        /* Unused */
-#define        NO_DMA                  0
-#define        USE_DMA                 1
-#endif
-
-#define        MAX_DISPLAY_LEN         261
-
-
-static int             no_window = 1;
-static gfxtest_info    *tests_info;
-static int             received_control_c = 0;
-static int             need_screen_lock = 1;
-static Display         *dpy = NULL;
-
+static gfxtest_info *tests_info;
 
 /* Declarations needed for get_tests() */
 
-static unsigned int efb_mask_list[] = {
+static uint_t efb_mask_list[] = {
        GRAPHICS_TEST_OPEN,
        GRAPHICS_TEST_DMA,
        GRAPHICS_TEST_MEM,
        GRAPHICS_TEST_CHIP
 };
 
-static unsigned int efb_mesg_list[] = {
+static uint_t efb_mesg_list[] = {
        GRAPHICS_TEST_OPEN_MESG,
        GRAPHICS_TEST_DMA_MESG,
        GRAPHICS_TEST_MEM_MESG,
@@ -82,219 +53,33 @@
 };
 
 
-static void
-disable_pm(Display *dpy)
-{
-       int             dummy;
-
-       XSetScreenSaver(dpy, 0, 0, 0, 0);
-       if (DPMSQueryExtension(dpy, &dummy, &dummy)) {
-           DPMSDisable(dpy);
-       }
-       if (FBPMQueryExtension(dpy, &dummy, &dummy)) {
-           FBPMDisable(dpy);
-       }
-
-}      /* disable_pm() */
-
-
-int
-lock_display(int fd, Display** current_display)
-{
-       char            env_buf[5 + MAXPATHLEN]; /* "HOME=<pw_dir>" */
-       int             i;
-       int             screen;
-       Display         *dpy;
-       Window          win;
-       XSetWindowAttributes xswa;
-       char            hostname[MAX_DISPLAY_LEN];
-       char            display[MAX_DISPLAY_LEN];
-       struct sigaction act;
-       int             current_screen;
-       struct hostent  *Host;
-       struct passwd   *pw_entry;
-       int             status;
-       char            no_bits[] = { 0 };
-       XColor          dumcolor;
-       Pixmap          lockc;
-       Pixmap          lockm;
-       Cursor          cursor;
-
-       pw_entry = getpwuid(0);
-       if (strlen(pw_entry->pw_dir) >= MAXPATHLEN) {
-           TraceMessage(VTS_DEBUG, __func__,
-                           "HOME= directory path is too long\n");
-           return (1);
-       }
-       strcpy(env_buf, "HOME=");
-       strcat(env_buf, pw_entry->pw_dir);
-       if (putenv(env_buf) != 0) {
-           TraceMessage(VTS_DEBUG, __func__,
-                           "putenv( HOME= ) failed, errno:%d\n", errno);
-           return (1);
-       }
-
-       dpy = NULL;
-
-       if (gfx_vts_debug_mask & GRAPHICS_VTS_SLOCK_OFF) {
-           TraceMessage(VTS_DEBUG, __func__, "lock_display() DISABLED\n");
-           need_screen_lock = 0;
-           *current_display = NULL;
-           return (0);
-       }
-
-       current_screen = 0;
-
-       TraceMessage(VTS_DEBUG, __func__, "locking X screen %d\n",
-                   current_screen);
-
-#if (0)
-       /* Get the host machine name */
-       if (sysinfo(SI_HOSTNAME, hostname, MAX_DISPLAY_LEN) == -1) {
-           TraceMessage(VTS_DEBUG, __func__,
-                       "sysinfo(2) failed getting hostname\n");
-           hostname[0] = '\0';
-       }
-#else
-       hostname[0] = '\0';
-#endif
-
-       snprintf(display, sizeof (display), "%s:0.%d",
-               hostname, current_screen);
-       dpy = XOpenDisplay(display);
-       TraceMessage(VTS_DEBUG, __func__,
-                   "XOpenDisplay, display = %s, dpy = 0x%p\n", display, dpy);
-
-       if (dpy == NULL) {
-           TraceMessage(VTS_DEBUG, __func__, "Assuming no window_system\n");
-           return (0);
-       }
-
-       TraceMessage(VTS_DEBUG, __func__,
-                   "XOpenDisplay successful, display = %s, dpy = 0x%p\n",
-                   display, dpy);
-
-       screen = DefaultScreen(dpy);
-
-       /*
-        * Flush request buffer and wait for all requests to be processed
-        */
-       XSync(dpy, False);
-
-       /* Tell server to report events as they occur */
-       XSynchronize(dpy, True);
-
-       disable_pm(dpy);
-
-       /* Create a blank cursor */
-       lockc = XCreateBitmapFromData(dpy, RootWindow(dpy, 0),
-                                       no_bits, 1, 1);
-       lockm = XCreateBitmapFromData(dpy, RootWindow(dpy, 0),
-                                       no_bits, 1, 1);
-       cursor = XCreatePixmapCursor(dpy, lockc, lockm, &dumcolor,
-                                       &dumcolor, 0, 0);
-
-       XFreePixmap(dpy, lockc);
-       XFreePixmap(dpy, lockm);
-
-       xswa.cursor = cursor;
-       xswa.override_redirect = True;
-       xswa.event_mask = (KeyPressMask | KeyReleaseMask | ExposureMask);
-       no_window = 0;
-       win = XCreateWindow(dpy,
-                           RootWindow(dpy, screen),
-                           0, 0,
-                           DisplayWidth(dpy, current_screen),
-                           DisplayHeight(dpy, current_screen),
-                           0,
-                           CopyFromParent,
-                           InputOutput,
-                           CopyFromParent,
-                           CWOverrideRedirect | CWEventMask, &xswa);
-
-       TraceMessage(VTS_DEBUG, __func__, " XCreateWindow win=%d\n", win);
-
-       XMapWindow(dpy, win);
-       XRaiseWindow(dpy, win);
-       TraceMessage(VTS_DEBUG, __func__, " no_window=%d\n", no_window);
-
-       if (!no_window) {
-           /* Disable server from handling any requests */
-           XGrabServer(dpy);
-           /* Gain control of keyboard */
-           status = XGrabKeyboard(dpy, win, False, GrabModeAsync,
-                                  GrabModeAsync, CurrentTime);
-
-           if (status != GrabSuccess) {
-               TraceMessage(VTS_DEBUG, __func__,
-                           "Cannot gain control of keyboard\n");
-           }
-
-           status = XGrabPointer(dpy,
-                               win,
-                               False,
-                               ResizeRedirectMask,
-                               GrabModeAsync,
-                               GrabModeAsync,
-                               None,
-                               cursor,
-                               CurrentTime);
-           if (status != GrabSuccess) {
-               TraceMessage(VTS_DEBUG, __func__,
-                           "Cannot gain control of pointer\n");
-           }
-       }
-
-       sleep(4);
-       *current_display = dpy;
-       return (0);
-
-}      /* lock_display() */
-
-void
-unlock_display(Display *dpy)
-{
-       if (dpy) {
-               XUngrabPointer(dpy, CurrentTime);
-               XUngrabKeyboard(dpy, CurrentTime);
-               XUngrabServer(dpy);
-       }
-}
-
-
 /* *** PUBLIC *** */
 
 /* These library functions are public and are expected to exist */
 
 int
-get_tests(gfxtest_info *tests)
+get_tests(
+    register gfxtest_info *const tests)
 {
-       return_packet *efb_test_open(int fd);
-
        /*
         * Set the gfx_vts_debug_mask bits according to environment variables
         */
        gfx_vts_set_debug_mask();
 
        /*
-        * Disable screen lock by default
-        */
-       gfx_vts_debug_mask |= GRAPHICS_VTS_SLOCK_OFF;
-
-       /*
         * Construct the list of tests to be performed
         */
        tests->count = sizeof (efb_test_list) / sizeof (gfxtest_function);
        tests->this_test_mask = (int *)malloc(sizeof (efb_mask_list));
        tests->this_test_mesg = (int *)malloc(sizeof (efb_mesg_list));
        tests->this_test_function =
-                       (gfxtest_function *)malloc(sizeof (efb_test_list));
+           (gfxtest_function *)malloc(sizeof (efb_test_list));
 
-       if ((tests->this_test_mask     == NULL) ||
-           (tests->this_test_mesg     == NULL) ||
+       if ((tests->this_test_mask == NULL) ||
+           (tests->this_test_mesg == NULL) ||
            (tests->this_test_function == NULL)) {
-           gfx_vts_free_tests(tests);
-           return (GRAPHICS_ERR_MALLOC_FAIL);
+               gfx_vts_free_tests(tests);
+               return (GRAPHICS_ERR_MALLOC_FAIL);
        }
 
        tests->connection_test_function = efb_test_open;
@@ -302,7 +87,7 @@
        memcpy(tests->this_test_mask, efb_mask_list, sizeof (efb_mask_list));
        memcpy(tests->this_test_mesg, efb_mesg_list, sizeof (efb_mesg_list));
        memcpy(tests->this_test_function, efb_test_list,
-                                               sizeof (efb_test_list));
+           sizeof (efb_test_list));
 
        tests_info = tests;
        return (0);
@@ -311,69 +96,613 @@
 
 
 int
-cleanup_tests(gfxtest_info *tests)
+cleanup_tests(
+    register gfxtest_info *const tests)
 {
 
-       TraceMessage(VTS_DEBUG, __func__, "call cleanup_tests\n");
+       TraceMessage(VTS_DEBUG, "cleanup_tests", "call cleanup_tests\n");
        gfx_vts_free_tests(tests);
 
-       if (need_screen_lock) {
-           unlock_display(dpy);
+       return (0);
+}      /* cleanup_tests() */
+
+
+void
+efb_block_signals(
+    void)
+{
+       sigset_t newprocmask;
+
+       sigemptyset(&newprocmask);
+       sigaddset(&newprocmask, SIGHUP);
+       sigaddset(&newprocmask, SIGINT);
+       sigaddset(&newprocmask, SIGTERM);
+       sigaddset(&newprocmask, SIGALRM);
+
+       sigprocmask(SIG_BLOCK, &newprocmask, &efb_xw.xw_procmask);
+}
+
+
+void
+efb_restore_signals(
+    void)
+{
+       sigprocmask(SIG_SETMASK, &efb_xw.xw_procmask, (sigset_t *)NULL);
+}
+
+
+int
+efb_lock_display(
+    void)
+{
+       if (gfx_vts_debug_mask & GRAPHICS_VTS_SLOCK_OFF) {
+               TraceMessage(VTS_DEBUG, "efb_lock_display",
+                   "efb_lock_display() DISABLED\n");
+               return (0);
        }
 
-}      /* cleanup_tests() */
-
-
-/*
- * efb_test_open()
- *
- *    This test will open the device, read and write some registers
- *    after mmaping in the register and frame buffer spaces.
- */
-
-return_packet *
-efb_test_open(int fd)
-{
-       static return_packet rp;
-       int             rc = 0;
-       struct vis_identifier vis_identifier;
-
-       if (need_screen_lock) {
-           lock_display(fd, &dpy);
+       if (!efb_open_display()) {
+               return (0);
        }
 
-       /* setup */
-       memset(&rp, 0, sizeof (return_packet));
+       efb_create_cursor();
 
-       if (gfx_vts_check_fd(fd, &rp)) {
-           return (&rp);
+       efb_create_window();
+
+       XMapRaised(efb_xw.xw_display, efb_xw.xw_window);
+
+       TraceMessage(VTS_DEBUG, "efb_lock_display",
+           "XMapRaised(display, 0x%lx)\n",
+           (ulong_t)efb_xw.xw_window);
+
+       /* Disable server from handling any requests */
+       efb_grab_server();
+
+       /* Gain control of keyboard */
+       efb_grab_keyboard();
+
+       /* Gain control of pointer */
+       efb_grab_pointer();
+
+       efb_disable_screensaver();
+
+       efb_disable_dpms();
+
+       XSync(efb_xw.xw_display, False);
+
+       return (1);
+
+}       /* efb_lock_display() */
+
+
+int
+efb_unlock_display(
+    void)
+{
+       if (efb_xw.xw_display == NULL)
+               return (0);
+
+       XUnmapWindow(efb_xw.xw_display, efb_xw.xw_window);
+
+       TraceMessage(VTS_DEBUG, "efb_unlock_display",
+           "XUnmapWindow(display, 0x%lx)\n",
+           (ulong_t)efb_xw.xw_window);
+
+       efb_restore_dpms();
+
+       efb_restore_screensaver();
+
+       efb_ungrab_pointer();
+
+       efb_ungrab_keyboard();
+
+       efb_ungrab_server();
+
+       XSync(efb_xw.xw_display, False);
+
+       efb_check_for_interrupt();
+
+       return (1);
+}
+
+
+int
+efb_open_display(
+    void)
+{
+       if (efb_xw.xw_dispname == NULL)
+               efb_xw.xw_dispname = ":0.0";
+
+       if (efb_xw.xw_display == NULL) {
+               efb_xw.xw_display = XOpenDisplay(efb_xw.xw_dispname);
+
+               if (efb_xw.xw_display == NULL) {
+                       TraceMessage(VTS_DEBUG, "efb_open_display",
+                           "XOpenDisplay(\"%s\") = NULL\n"
+                           "Assuming no window system.\n",
+                           efb_xw.xw_dispname);
+
+                       return (0);
+               }
+
+               TraceMessage(VTS_DEBUG, "efb_open_display",
+                   "XOpenDisplay(\"%s\") = 0x%p\n"
+                   "Assuming a window system.\n",
+                   efb_xw.xw_dispname, efb_xw.xw_display);
        }
 
-       TraceMessage(VTS_TEST_STATUS, __func__, "check_fd passed.\n");
+       /* Tell server to report events as they occur */
+       XSynchronize(efb_xw.xw_display, True);
 
-       /* vis identifier will do this */
-       rc = ioctl(fd, VIS_GETIDENTIFIER, &vis_identifier);
+       TraceMessage(VTS_DEBUG, "efb_open_display",
+           "XSynchronize(display, True).\n");
 
-       TraceMessage(VTS_TEST_STATUS, __func__, "rc = %d\n", rc);
+       return (1);
+}
 
-       if (rc != 0) {
-           gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
-           return (&rp);
+
+int
+efb_create_cursor(
+    void)
+{
+       register Window const root = RootWindow(efb_xw.xw_display,
+           efb_xw.xw_screen);
+       register Pixmap emptypixmap;
+       XColor dummy_color = {0, 0, 0, 0, 0, 0};
+
+       if (efb_xw.xw_cursor != 0)
+               return (0);
+
+       emptypixmap = XCreateBitmapFromData(efb_xw.xw_display, root, "", 1, 
1);
+
+       efb_xw.xw_cursor = XCreatePixmapCursor(efb_xw.xw_display,
+           emptypixmap, emptypixmap, &dummy_color, &dummy_color, 0, 0);
+
+       TraceMessage(VTS_DEBUG, "efb_create_cursor",
+           "XCreatePixmapCursor(display, 0x%lx, 0x%lx, &dummy_color, "
+           "&dummy_color, 0, 0) = 0x%lx\n",
+           (ulong_t)emptypixmap, (ulong_t)emptypixmap,
+           (ulong_t)efb_xw.xw_cursor);
+
+       XFreePixmap(efb_xw.xw_display, emptypixmap);
+
+       return (1);
+}
+
+
+int
+efb_create_window(
+    void)
+{
+       register Window const root = RootWindow(efb_xw.xw_display,
+           efb_xw.xw_screen);
+       register int const width = DisplayWidth(efb_xw.xw_display,
+           efb_xw.xw_screen);
+       register int const height = DisplayHeight(efb_xw.xw_display,
+           efb_xw.xw_screen);
+       XSetWindowAttributes xswa;
+
+       if (efb_xw.xw_window != NULL)
+               return (0);
+
+       memset(&xswa, 0, sizeof (xswa));
+       xswa.cursor = efb_xw.xw_cursor;
+       xswa.background_pixmap = None;
+       xswa.override_redirect = True;
+       xswa.backing_store = NotUseful;
+       xswa.save_under = False;
+       xswa.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask;
+
+       efb_xw.xw_window = XCreateWindow(efb_xw.xw_display,
+           root, 0, 0, width, height,
+           0, CopyFromParent, InputOutput, CopyFromParent,
+           CWBackPixmap | CWOverrideRedirect | CWBackingStore |
+           CWSaveUnder | CWEventMask | CWCursor, &xswa);
+
+       TraceMessage(VTS_DEBUG, "efb_create_window",
+           "XCreateWindow(display, 0x%lx, %d, %d, %d, %d, "
+           "%d, %d, %d, %d, 0x%lx, &xswa) = 0x%lx\n",
+           (ulong_t)root, 0, 0, width, height,
+           0, CopyFromParent, InputOutput, CopyFromParent,
+           (ulong_t)(CWBackPixmap | CWOverrideRedirect |
+           CWBackingStore | CWSaveUnder | CWEventMask | CWCursor),
+           (ulong_t)efb_xw.xw_window);
+
+       XStoreName(efb_xw.xw_display, efb_xw.xw_window, "libvtsSUNWefb");
+
+       return (1);
+}
+
+
+int
+efb_grab_server(
+    void)
+{
+       if (efb_xw.xw_grab_server == True)
+               return (0);
+
+       efb_xw.xw_grab_server = XGrabServer(efb_xw.xw_display);
+
+       TraceMessage(VTS_DEBUG, "efb_grab_server",
+           "XGrabServer(display)\n");
+
+       return (1);
+}
+
+
+int
+efb_ungrab_server(
+    void)
+{
+       if (efb_xw.xw_grab_server != True)
+               return (0);
+
+       efb_xw.xw_grab_server = !XUngrabServer(efb_xw.xw_display);
+
+       TraceMessage(VTS_DEBUG, "efb_ungrab_server",
+           "XUngrabServer(display)\n");
+
+       return (1);
+}
+
+
+int
+efb_grab_keyboard(
+    void)
+{
+       register int status;
+
+       if (efb_xw.xw_grab_keyboard == True)
+               return (0);
+
+       status = XGrabKeyboard(efb_xw.xw_display, efb_xw.xw_window,
+           False, GrabModeAsync, GrabModeAsync, CurrentTime);
+       efb_xw.xw_grab_keyboard = status == GrabSuccess;
+
+       TraceMessage(VTS_DEBUG, "efb_grab_keyboard",
+           "XGrabKeyboard(display, 0x%lx, %d, %d, %d, %ld) = %d\n",
+           (ulong_t)efb_xw.xw_window,
+           False, GrabModeAsync, GrabModeAsync, CurrentTime,
+           status);
+
+       if (status != GrabSuccess) {
+               TraceMessage(VTS_DEBUG, "efb_grab_keyboard",
+                   "Cannot gain control of keyboard\n");
+               return (-1);
+
+       } else {
+               return (1);
+       }
+}
+
+
+int
+efb_ungrab_keyboard(
+    void)
+{
+       register int status;
+
+       if (efb_xw.xw_grab_keyboard != True)
+               return (0);
+
+       status = XUngrabKeyboard(efb_xw.xw_display, CurrentTime);
+
+       efb_xw.xw_grab_keyboard = False;
+       TraceMessage(VTS_DEBUG, "efb_ungrab_keyboard",
+           "XGrabKeyboard(display, %ld) = %d\n",
+           CurrentTime, status);
+
+       return (1);
+}
+
+
+int
+efb_grab_pointer(
+    void)
+{
+       register int status;
+
+       if (efb_xw.xw_grab_pointer == True)
+               return (0);
+
+       status = XGrabPointer(efb_xw.xw_display, efb_xw.xw_window,
+           False, ResizeRedirectMask, GrabModeAsync, GrabModeAsync,
+           None, efb_xw.xw_cursor, CurrentTime);
+
+       efb_xw.xw_grab_pointer = status == GrabSuccess;
+
+       TraceMessage(VTS_DEBUG, "efb_grab_pointer",
+           "XGrabPointer(display, 0x%lx, %d, 0x%lx, %d, %d, "
+           "%d, %d, %ld) = %d\n",
+           (ulong_t)efb_xw.xw_window,
+           False, ResizeRedirectMask,
+           GrabModeAsync, GrabModeAsync,
+           None, None, CurrentTime,
+           status);
+
+       if (status != GrabSuccess) {
+               TraceMessage(VTS_DEBUG, "efb_grab_pointer",
+                   "Cannot gain control of pointer\n");
+               return (-1);
+
+       } else {
+               return (1);
+       }
+}
+
+
+int
+efb_ungrab_pointer(
+    void)
+{
+       register int status;
+
+       if (efb_xw.xw_grab_pointer != True)
+               return (0);
+
+       status = XUngrabPointer(efb_xw.xw_display, CurrentTime);
+
+       efb_xw.xw_grab_pointer = False;
+
+       TraceMessage(VTS_DEBUG, "efb_ungrab_pointer",
+           "XGrabPointer(display, %ld) = %d\n",
+           CurrentTime, status);
+
+       return (1);
+}
+
+
+int
+efb_disable_screensaver(
+    void)
+{
+       XGetScreenSaver(efb_xw.xw_display,
+           &efb_xw.xw_ss_timeout,
+           &efb_xw.xw_ss_interval,
+           &efb_xw.xw_ss_prefer_blanking,
+           &efb_xw.xw_ss_allow_exposures);
+
+       efb_xw.xw_ss_saved = True;
+
+       TraceMessage(VTS_DEBUG, "efb_disable_screensaver",
+           "XGetScreenSaver(display) = %d, %d, %d, %d\n",
+           efb_xw.xw_ss_timeout,
+           efb_xw.xw_ss_interval,
+           efb_xw.xw_ss_prefer_blanking,
+           efb_xw.xw_ss_allow_exposures);
+
+       /* Reset the screen saver to reset its time. */
+
+       XResetScreenSaver(efb_xw.xw_display);
+
+       efb_xw.xw_ss_disabled = True;
+
+       XSetScreenSaver(efb_xw.xw_display,
+           DisableScreenSaver,
+           efb_xw.xw_ss_interval,
+           efb_xw.xw_ss_prefer_blanking,
+           efb_xw.xw_ss_allow_exposures);
+
+       TraceMessage(VTS_DEBUG, "efb_disable_screensaver",
+           "XSetScreenSaver(display, %d, %d, %d, %d)\n",
+           DisableScreenSaver,
+           efb_xw.xw_ss_interval,
+           efb_xw.xw_ss_prefer_blanking,
+           efb_xw.xw_ss_allow_exposures);
+
+       return (1);
+}
+
+
+int
+efb_restore_screensaver(
+    void)
+{
+       if (efb_xw.xw_ss_saved != True ||
+           efb_xw.xw_ss_disabled != True) {
+               efb_xw.xw_ss_disabled = False;
+               efb_xw.xw_ss_saved = False;
+               return (0);
+
+       } else {
+               XSetScreenSaver(efb_xw.xw_display,
+                   efb_xw.xw_ss_timeout,
+                   efb_xw.xw_ss_interval,
+                   efb_xw.xw_ss_prefer_blanking,
+                   efb_xw.xw_ss_allow_exposures);
+
+               efb_xw.xw_ss_disabled = False;
+
+               TraceMessage(VTS_DEBUG, "efb_restore_screensaver",
+                   "XSetScreenSaver(display, %d, %d, %d, %d)\n",
+                   efb_xw.xw_ss_timeout,
+                   efb_xw.xw_ss_interval,
+                   efb_xw.xw_ss_prefer_blanking,
+                   efb_xw.xw_ss_allow_exposures);
+
+               efb_xw.xw_ss_saved = False;
+
+               return (1);
+       }
+}
+
+
+int
+efb_disable_dpms(
+    void)
+{
+       /* Disable the X Display Power Management Signaling. */
+
+       int status;
+       int dpms_error = 0;
+       int dpms_event = 0;
+
+       status = DPMSQueryExtension(efb_xw.xw_display,
+           &dpms_event, &dpms_error);
+
+       TraceMessage(VTS_DEBUG, "efb_disable_dpms",
+           "DPMSQueryExtension(display) = %d, %d, %d\n",
+           status,
+           dpms_event,
+           dpms_error);
+
+       if (status != True)
+               return (-1);
+
+       efb_xw.xw_dpms_saved = DPMSInfo(efb_xw.xw_display,
+           &efb_xw.xw_dpms_power, &efb_xw.xw_dpms_state);
+
+       TraceMessage(VTS_DEBUG, "efb_disable_dpms",
+           "DPMSInfo(display) = %d, %d, %d\n",
+           efb_xw.xw_dpms_saved,
+           efb_xw.xw_dpms_power,
+           efb_xw.xw_dpms_state);
+
+       if (efb_xw.xw_dpms_saved != True ||
+           efb_xw.xw_dpms_state != True)
+               return (0);
+
+       else {
+               efb_xw.xw_dpms_disabled = True;
+
+               DPMSDisable(efb_xw.xw_display);
+
+               TraceMessage(VTS_DEBUG, "efb_disable_dpms",
+                   "DPMSDisable(display)\n");
+
+               return (1);
+       }
+}
+
+
+int
+efb_restore_dpms(
+    void)
+{
+       /* Restore the X Display Power Management Signaling. */
+
+       if (efb_xw.xw_dpms_saved != True ||
+           efb_xw.xw_dpms_disabled != True) {
+               efb_xw.xw_dpms_disabled = False;
+               efb_xw.xw_dpms_saved = False;
+               return (0);
+
+       } else {
+               DPMSEnable(efb_xw.xw_display);
+
+               efb_xw.xw_dpms_disabled = False;
+
+               TraceMessage(VTS_DEBUG, "efb_restore_dpms",
+                   "DPMSEnable(display)\n");
+
+               efb_xw.xw_dpms_saved = False;
+               return (1);
+       }
+}
+
+
+int
+efb_sleep(
+    uint_t const seconds)
+{
+       register int signo;
+       struct sigaction oldhup;
+       struct sigaction oldint;
+       struct sigaction oldalrm;
+       struct sigaction oldterm;
+       struct sigaction newsigact;
+       sigset_t oldprocmask;
+
+       /*
+        * Allow a SIGHUP, SIGINT, SIGALRM, or SIGTERM to interrupt our
+        * sleep.  These signals should already be masked from a
+        * call to efb_block_signals.
+        */
+
+       /* Save the current signals. */
+
+       sigaction(SIGHUP, NULL, &oldhup);
+       sigaction(SIGINT, NULL, &oldint);
+       sigaction(SIGALRM, NULL, &oldalrm);
+       sigaction(SIGTERM, NULL, &oldterm);
+
+       /* Setup up new signal action. */
+
+       newsigact.sa_handler = efb_signal_routine;
+       sigemptyset(&newsigact.sa_mask);
+       newsigact.sa_flags = 0;
+
+       signo = sigsetjmp(efb_xw.xw_sigjmpbuf, 1);
+       if (!signo) {
+               /* First time goes here. */
+
+               /* Set signal routines. */
+
+               if (oldhup.sa_handler != SIG_IGN)
+                       sigaction(SIGHUP, &newsigact, NULL);
+               if (oldint.sa_handler != SIG_IGN)
+                       sigaction(SIGINT, &newsigact, NULL);
+               if (oldalrm.sa_handler != SIG_IGN)
+                       sigaction(SIGALRM, &newsigact, NULL);
+               if (oldterm.sa_handler != SIG_IGN)
+                       sigaction(SIGTERM, &newsigact, NULL);
+
+               /* Unmask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+               sigprocmask(SIG_SETMASK, &efb_xw.xw_procmask, &oldprocmask);
+
+               sleep(seconds);
+
+               /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+               sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+               /* Restore the signals. */
+
+               if (oldhup.sa_handler != SIG_IGN)
+                       sigaction(SIGHUP, &oldhup, NULL);
+               if (oldint.sa_handler != SIG_IGN)
+                       sigaction(SIGINT, &oldint, NULL);
+               if (oldalrm.sa_handler != SIG_IGN)
+                       sigaction(SIGALRM, &oldalrm, NULL);
+               if (oldterm.sa_handler != SIG_IGN)
+                       sigaction(SIGTERM, &oldterm, NULL);
+               }
+
+       else {
+               /* We come here from the siglongjmp in efb_signal_routine. */
+
+               /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+               sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+               /* Restore the signals. */
+
+               if (oldhup.sa_handler != SIG_IGN)
+                       sigaction(SIGHUP, &oldhup, NULL);
+               if (oldint.sa_handler != SIG_IGN)
+                       sigaction(SIGINT, &oldint, NULL);
+               if (oldalrm.sa_handler != SIG_IGN)
+                       sigaction(SIGALRM, &oldalrm, NULL);
+               if (oldterm.sa_handler != SIG_IGN)
+                       sigaction(SIGTERM, &oldterm, NULL);
+
+               /* Cause us to get the signal, when we unmask the signals. */
+               kill(getpid(), signo);
+               return (signo);
        }
 
-       if (strncmp(vis_identifier.name, "SUNWefb", 7) != 0) {
-           gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
-           return (&rp);
-       }
+       signo = efb_check_for_interrupt();
+       return (signo);
+}
 
-       map_me(&rp, fd);
 
-       TraceMessage(VTS_DEBUG, __func__, "Open completed OK\n");
-
-       check4abort(dpy);
-       return (&rp);
-
-}      /* efb_test_open() */
+void
+efb_signal_routine(
+    register int const signo)
+{
+       siglongjmp(efb_xw.xw_sigjmpbuf, signo);
+}
 
 
 /*
@@ -384,92 +713,30 @@
  */
 
 return_packet *
-efb_test_dma(int fd)
+efb_test_dma(
+    register int const fd)
 {
        static return_packet rp;
-       int             i;
 
-       TraceMessage(VTS_DEBUG, __func__, "Not a DMA device\n");
+       memset(&rp, 0, sizeof (rp));
 
-       check4abort(dpy);
+       TraceMessage(VTS_DEBUG, "efb_test_dma", "Not a DMA device\n");
+
        return (&rp);
 
 }      /* efb_test_dma() */
 
 
-/*
- * efb_test_memory()
- *
- *    This test will open the device and read and write to all memory
- *    addresses.
- */
-
-return_packet *
-efb_test_memory(int fd)
-{
-       static return_packet rp;
-
-       TraceMessage(VTS_DEBUG, __func__, " efb_test_memory running\n");
-
-       if (gfx_vts_debug_mask & GRAPHICS_VTS_MEM_OFF) {
-           return (&rp);
-       }
-
-       if (need_screen_lock) {
-           lock_display(fd, &dpy);
-       }
-
-       memory_test(&rp, fd);
-
-       TraceMessage(VTS_DEBUG, __func__, " efb_test_memory completed\n");
-
-       sleep(2);
-
-       check4abort(dpy);
-       return (&rp);
-
-}      /* efb_test_memory() */
-
-
-/*
- * efb_test_chip()
- *
- *    Test Chip, functional tests.
- */
-
-return_packet *
-efb_test_chip(int fd)
-{
-       static return_packet rp;
-
-       if (gfx_vts_debug_mask & GRAPHICS_VTS_CHIP_OFF) {
-           return (&rp);
-       }
-       TraceMessage(VTS_DEBUG, __func__, " efb_test_chip running\n");
-
-       if (need_screen_lock) {
-           lock_display(fd, &dpy);
-       }
-
-       chip_test(&rp, fd);
-
-       TraceMessage(VTS_DEBUG, __func__, " efb_test_chip completed\n");
-
-       sleep(2);
-
-       check4abort(dpy);
-       return (&rp);
-
-}      /* efb_test_chip() */
-
-
 void
-graphicstest_finish(int flag)
+graphicstest_finish(
+    register int const flag)
 {
 
-       TraceMessage(VTS_DEBUG, __func__, "call graphicstest_finish\n");
+       TraceMessage(VTS_DEBUG, "graphicstest_finish",
+           "call graphicstest_finish\n");
 
-       TraceMessage(VTS_DEBUG, __func__, "call reset_memory_state\n");
+       TraceMessage(VTS_DEBUG, "graphicstest_finish",
+           "call reset_memory_state\n");
 
        cleanup_tests(tests_info);
 
@@ -477,54 +744,50 @@
 
 }      /* graphicstest_finish() */
 
+#define        CTRL(x) ((x) & 0x1f)
 
-/*
- * check4abort()
- *
- *    This function sends a KILL signal to the program if it detects
- *    that the user has pressed ^C.  This functionality is usually
- *    performed by the Command Tool which spawned a program, but in this
- *    case we need to do it because we have grabbed all keyboard events.
- *    It should be called anywhere where it's safe to end the program.
- */
 
-void
-check4abort(Display *dpy)
+int
+efb_check_for_interrupt(
+    void)
 {
-#define        CTRL_C  '\003'                  /* Ctrl-C (^C) */
+       register size_t inputlength;
+       register size_t inputon;
+       register int ch;
+       struct sigaction oldint;
+       struct sigaction oldquit;
+       XEvent event;
+       char inputstring[16];
 
-       /*
-        * If necessary, restore the original state following a test
-        */
-#if !defined(VTS_STUBS)
-       chip_test_reset();
-#endif
+       if (efb_xw.xw_display == NULL)
+               return (0);
 
-       if (dpy != NULL) {
-#if !defined(VTS_STUBS)
-           while (XPending(dpy)) {
-               XEvent  event;          /* Key event structure */
-               int     i;              /* Loop counter / keystr[] index */
-               char    keystr[5] = ""; /* Buffer for returned string */
-               int     len;            /* Length of returned string */
+       while (XPending(efb_xw.xw_display)) {
+               XNextEvent(efb_xw.xw_display, &event);
+               if (event.type == KeyPress) {
+                       inputlength = XLookupString(&event.xkey, inputstring,
+                           sizeof (inputstring), NULL, NULL);
+                       for (inputon = 0; inputon < inputlength; inputon++) {
+                               ch = inputstring[inputon];
 
-               XNextEvent(dpy, &event);
-               if (event.type == KeyPress) {
-                   len = XLookupString((XKeyEvent *)&event,
-                                       keystr, sizeof (keystr),
-                                       NULL, NULL);
-                   for (i = 0; i < len; i++) {
-                       if (keystr[i] == CTRL_C) {
-                           kill(getpid(), SIGINT);
-                           graphicstest_finish(0);
+                               if (ch == CTRL('c')) {
+                                       sigaction(SIGINT, NULL, &oldint);
+                                       if (oldint.sa_handler != SIG_IGN) {
+                                               kill(getpid(), SIGINT);
+                                               return (SIGINT);
+                                       }
+
+                               } else if (ch == CTRL('\\')) {
+                                       sigaction(SIGQUIT, NULL, &oldquit);
+                                       if (oldquit.sa_handler != SIG_IGN) {
+                                               kill(getpid(), SIGQUIT);
+                                               return (SIGQUIT);
+                                       }
+                               }
                        }
-                   }
                }
-           }
-#endif /* VTS_STUBS */
        }
-
-}      /* check4abort() */
-
+       return (0);
+}
 
 /* End of libvtsSUNWefb.c */

diff -r f94011dda343 -r 475ce9398539 
open-src/app/gfx-utils/sun-src/vts/efb/libvtsSUNWefb.h
--- a/open-src/app/gfx-utils/sun-src/vts/efb/libvtsSUNWefb.h    Wed Sep 18 
11:01:17 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/efb/libvtsSUNWefb.h    Tue Sep 24 
14:01:59 2013 -0700
@@ -1,6 +1,5 @@
-
 /*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights 
reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights 
reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -22,35 +21,300 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-
 #ifndef _LIBVTSSUNWEFB_H
 #define        _LIBVTSSUNWEFB_H
 
+#include <sys/types.h>
+#include <sys/param.h>         /* MAXPATHLEN */
+#include <errno.h>
+#include <memory.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <setjmp.h>
+#include <stropts.h>           /* ioctl() */
+#include <sys/fbio.h>
+#include <sys/mman.h>
+#include <sys/systeminfo.h>    /* sysinfo() */
+#include <sys/pci.h>
+#include <sys/time.h>
+#include <sys/visual_io.h>
+#include <X11/Xmd.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/dpms.h>
+#include "libvtsSUNWxfb.h"     /* Common VTS library definitions */
+#undef Status
+#define        Status pciStatus
+#include "gfx_common.h"
+#undef Status
+#define        Status int
+#include "graphicstest.h"
+#include "gfx_vts.h"
 
-#include "libvtsSUNWxfb.h"     /* Common VTS library definitions */
+typedef struct efb_info {
+       char const *efb_name;
+       int efb_fd;
+       uint16_t efb_vendor;
+       uint16_t efb_device;
+       uint_t efb_width;
+       uint_t efb_height;
+       uint_t efb_depth;
+       uint_t efb_pixelsize;
+       uint_t efb_linesize;
+       offset_t efb_fb_addr;
+       size_t efb_fb_size;
+       uchar_t *efb_fb_ptr;
+       offset_t efb_mmio_addr;
+       size_t efb_mmio_size;
+       uchar_t *efb_mmio_ptr;
+       int efb_palet_changed;
+       uint32_t efb_palet[256];
+       } efb_info_t;
 
+typedef struct efb_xw_struct {
+       sigset_t xw_procmask;
+       sigjmp_buf xw_sigjmpbuf;
+       char const *xw_dispname;
+       Display *xw_display;
+       int xw_screen;
+       Window xw_window;
+       Cursor xw_cursor;
+       Bool xw_grab_server;
+       Bool xw_grab_keyboard;
+       Bool xw_grab_pointer;
+       Bool xw_ss_saved;
+       Bool xw_ss_disabled;
+       int xw_ss_timeout;
+       int xw_ss_interval;
+       int xw_ss_prefer_blanking;
+       int xw_ss_allow_exposures;
+       Status xw_dpms_saved;
+       CARD16 xw_dpms_power;
+       BOOL xw_dpms_state;
+       Bool xw_dpms_disabled;
+       } efb_xw_t;
 
-/* Test Open, initialization & read back; basic ability to talk to device */
-return_packet *efb_test_open(int fd);
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-/* Test DMA, read/write via dma, memory and, chip tests will use DMA */
-return_packet *efb_test_dma(int fd);
+/* chip.c */
 
-/* Test Memory, various address, data, and, random patterns */
-return_packet *efb_test_memory(int fd);
+extern return_packet *efb_test_chip(
+    int const fd);
 
-/* Test Chip, functional tests */
-return_packet *efb_test_chip(int fd);
+extern int chip_test(
+    return_packet *const rp,
+    int const fd);
 
-void check4abort();
-int get_processHandle(int, void **);
+extern int draw_lines(
+    uint_t const width,
+    uint_t const height);
 
-extern int backup_clut_init;
-extern struct fbcmap backup_clut;
-extern int myfd;
+extern int draw_cascaded_box(
+    uint_t const width,
+    uint_t const height);
 
+/* mapper.c */
+
+extern return_packet *efb_test_open(
+    int const fd);
+
+extern int map_me(
+    return_packet *const rp,
+    int const fd);
+
+extern int efb_test_semaphore(
+    return_packet *const rp,
+    int const test);
+
+/* memory.c */
+
+extern return_packet *efb_test_memory(
+    int const fd);
+
+extern int memory_test(
+    return_packet *const rp,
+    int const fd);
+
+extern void check_plane(
+    int const num_planes,
+    int const access_mode,
+    int const fb_pitch,
+    int const fb_height,
+    int const fb_width,
+    int const bytepp,
+    caddr_t const base);
+
+extern void init_data(
+    int const num_planes);
+
+extern uint_t test_data(
+    void);
+
+extern boolean_t write_read(
+    int const xoff,
+    int const yoff,
+    boolean_t const complement,
+    int const access_mode,
+    boolean_t const pass,
+    int const fb_pitch,
+    int const bytepp,
+    caddr_t const base);
+
+/* tools.c */
+
+extern int efb_map_mem(
+    return_packet *const rp,
+    int const test);
+
+extern int efb_get_pci_info(
+    void);
+
+extern int efb_map_mmio(
+    void);
+
+extern int efb_map_fb(
+    void);
+
+extern int efb_init_info(
+    return_packet *const rp,
+    int const test);
+
+extern int efb_unmap_mem(
+    return_packet *const rp,
+    int const test);
+
+extern int efb_unmap_fb(
+    void);
+
+extern int efb_unmap_mmio(
+    void);
+
+extern int efb_init_graphics(
+    void);
+
+extern void efb_save_palet(
+    void);
+
+extern int efb_set_palet(
+    void);
+
+extern int efb_restore_palet(
+    void);
+
+extern uint_t efb_color(
+    uint_t const red,
+    uint_t const green,
+    uint_t const blue);
+
+extern int efb_fill_solid_rect(
+    uint_t const x1,
+    uint_t const y1,
+    uint_t const x2,
+    uint_t const y2,
+    uint_t const fg);
+
+extern int efb_draw_solid_line(
+    uint_t const x1,
+    uint_t const y1,
+    uint_t const x2,
+    uint_t const y2,
+    uint_t const fg);
+
+extern int efb_flush_pixel_cache(
+    void);
+
+extern void efb_reset_engine(
+    void);
+
+extern int efb_wait_fifo(
+    int const c);
+
+extern int efb_wait_idle(
+    void);
+
+/* libvtsSUNWefb.c */
+
+extern efb_info_t efb_info;
+
+extern efb_xw_t efb_xw;
+
+extern void efb_block_signals(
+    void);
+
+extern void efb_restore_signals(
+    void);
+
+extern int efb_lock_display(
+    void);
+
+extern int efb_unlock_display(
+    void);
+
+extern int efb_open_display(
+    void);
+
+extern int efb_create_cursor(
+    void);
+
+extern int efb_create_window(
+    void);
+
+extern int efb_grab_server(
+    void);
+
+extern int efb_ungrab_server(
+    void);
+
+extern int efb_grab_keyboard(
+    void);
+
+extern int efb_ungrab_keyboard(
+    void);
+
+extern int efb_grab_pointer(
+    void);
+
+extern int efb_ungrab_pointer(
+    void);
+
+extern int efb_disable_screensaver(
+    void);
+
+extern int efb_restore_screensa
[truncated due to length]



[xwin-commits] [solaris-x11~x-s11-update-clone:1368] 15758019 SUNBT7116629 Screen turned to BLUE after running VTS graphicstes

x-hg 09/24/2013
 
 
Close
loading
Please Confirm
Close