15758019 SUNBT7116629 Screen turned to BLUE after running VTS graphicstest on Xorg w/efb
17207515 unable to interrupt vts efb graphicstest
--- 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"
-
-void
-box(struct efb_info *pEFB, int x1, int y1, int x2, int y2, unsigned int color)
-{
- int tmp;
- int width;
- int height;
- unsigned int v;
-
- width = x2 - x1;
- height = y2 - y1;
+/*
+ * efb_test_chip()
+ *
+ * Test Chip, functional tests.
+ */
- if ((width <= 0) || (height <= 0)) {
-#ifdef DEBUG
- printf("x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
-#endif
- return;
- }
-
- 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));
+return_packet *
+efb_test_chip(
+ register int const fd)
+{
+ static return_packet rp;
- 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));
+ memset(&rp, 0, sizeof (return_packet));
- 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
+ if (gfx_vts_debug_mask & GRAPHICS_VTS_CHIP_OFF)
+ return (&rp);
-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;
+ TraceMessage(VTS_DEBUG, "efb_test_chip", "efb_test_chip running\n");
- cinc = 256 / NBOX;
- xinc = width / (NBOX * 2);
- yinc = height / (NBOX * 2);
- x1 = y1 = 0;
+ efb_block_signals();
- for (i = 0; i < NBOX; i++) {
+ efb_lock_display();
- x2 = width - x1;
- y2 = height - y1;
-
- j = i * cinc;
-
- k = (j<<24 | j<<16 | j<<8 | j);
+ chip_test(&rp, fd);
- box(pEFB, x1, y1, x2, y2, k);
+ efb_unlock_display();
- x1 += xinc;
- y1 += yinc;
- }
-
-} /* draw_cascaded_box() */
-
+ efb_restore_signals();
-#define NLINE 128
+ TraceMessage(VTS_DEBUG, "efb_test_chip", "efb_test_chip completed\n");
-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;
+ return (&rp);
- xinc = width / NLINE;
- yinc = height / NLINE;
- x1 = y1 = 0;
+} /* efb_test_chip() */
- 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;
- }
-
- 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);
+int
+chip_test(
+ register return_packet *const rp,
+ register int const fd)
+{
+ register uint_t black;
+ register uint_t white;
- y1 += yinc;
- }
-}
+ memset(&efb_info, 0, sizeof (efb_info));
+ efb_info.efb_fd = fd;
-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;
+ /*
+ * map the registers & frame buffers memory
+ */
+ if (efb_map_mem(rp, GRAPHICS_ERR_CHIP) != 0)
+ return (-1);
- 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_init_info(rp, GRAPHICS_ERR_CHIP) != 0) {
+ 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;
+ if (!efb_init_graphics()) {
+ efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
}
+ efb_save_palet();
+ efb_set_palet();
- /*
- * Clear screen
+ /*
+ * Clear screen black
*/
- box(pEFB, 0, 0, pEFB->screenWidth, pEFB->screenHeight, 0);
- efb_wait_for_idle(pEFB);
- efb_flush_pixel_cache(pEFB);
- sleep(2);
+ 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);
+ }
+
+ if (!efb_wait_idle()) {
+ efb_restore_palet();
+ efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
+
+ 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
- */
- 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
+ * fill rectangle test
*/
- box(pEFB, 0, 0, pEFB->screenWidth, pEFB->screenHeight, 0xff);
- efb_wait_for_idle(pEFB);
- efb_flush_pixel_cache(pEFB);
- sleep(2);
-
+ if (!draw_cascaded_box(efb_info.efb_width, efb_info.efb_height)) {
+ efb_restore_palet();
+ efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
-done:
- /*
- * Unmap the registers & frame buffers memory
- */
- if (efb_unmap_mem(pEFB, rp, GRAPHICS_ERR_CHIP) == -1) {
- return;
- }
+ if (!efb_wait_idle()) {
+ efb_restore_palet();
+ efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
+ efb_flush_pixel_cache();
- if (close(fd) == -1) {
- gfx_vts_set_message(rp, 1, GRAPHICS_ERR_CHIP, "error closing device\n");
- return;
+ 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 */
--- 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 */
--- 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
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <sys/mman.h>
+#ifndef _EFB_H
+#define _EFB_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) *((unsigned int *)(addr))
-#define WRITE_MMIO_UINT(addr, val) *((unsigned int *)(addr)) = (val)
-
-#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 READ_MMIO_UINT(addr) *((uint_t volatile *)(addr))
+#define WRITE_MMIO_UINT(addr, val) *((uint_t volatile *)(addr)) = \
+ (val)
-typedef unsigned int (*PFNRead32) (unsigned char *);
-typedef void (*PFNWrite32) (unsigned char *, unsigned int);
-
-struct efb_info {
- int fd;
+#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))
- int screenWidth;
- int screenHeight;
- int screenPitch;
- int bitsPerPixel;
-
- unsigned int ChipSet;
+#define PCI_MAP_MEMORY 0x00000000
+#define PCI_MAP_IO 0x00000001
- unsigned long FBPhysAddr;
- unsigned long MMIOPhysAddr;
- unsigned long RelocateIO;
- unsigned long fbLocation;
-
- int FBMapSize;
- int MMIOMapSize;
+#define PCI_MAP_MEMORY_TYPE 0x00000007
+#define PCI_MAP_IO_TYPE 0x00000003
- unsigned char *FBvaddr;
- unsigned char *MMIOvaddr;
-};
-
-#define PCI_MAP_MEMORY 0x00000000
-#define PCI_MAP_IO 0x00000001
+#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_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 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 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_MAP_IS64BITMEM(b) \
+ (((b) & PCI_MAP_MEMORY_TYPE) == PCI_MAP_MEMORY_TYPE_64BIT)
-#define PCI_REGION_BASE(_pcidev, _b, _type) \
- (((_type) == REGION_MEM) ? (_pcidev)->memBase[(_b)] \
- : (_pcidev)->ioBase[(_b)])
+#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK)
-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 *);
+#define PCI_REGION_BASE(_pcidev, _b, _type) \
+ (((_type) == REGION_MEM) ? (_pcidev)->memBase[(_b)] : \
+ (_pcidev)->ioBase[(_b)])
-#endif /* EFB_H */
+#endif /* _EFB_H */
--- 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"
+
+efb_info_t efb_info;
-#include "graphicstest.h"
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
-
-#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() */
-/*
- * efb_test_open()
- *
- * This test will open the device, read and write some registers
- * after mmaping in the register and frame buffer spaces.
- */
+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);
+}
+
-return_packet *
-efb_test_open(int fd)
+void
+efb_restore_signals(
+ void)
{
- static return_packet rp;
- int rc = 0;
- struct vis_identifier vis_identifier;
+ sigprocmask(SIG_SETMASK, &efb_xw.xw_procmask, (sigset_t *)NULL);
+}
+
- if (need_screen_lock) {
- lock_display(fd, &dpy);
+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);
+ }
+
+ if (!efb_open_display()) {
+ return (0);
}
- /* setup */
- memset(&rp, 0, sizeof (return_packet));
+ efb_create_cursor();
+
+ 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);
- if (gfx_vts_check_fd(fd, &rp)) {
- return (&rp);
+ 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);
+
+ TraceMessage(VTS_DEBUG, "efb_open_display",
+ "XSynchronize(display, True).\n");
+
+ return (1);
+}
+
+
+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);
- /* vis identifier will do this */
- rc = ioctl(fd, VIS_GETIDENTIFIER, &vis_identifier);
+ 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);
+}
+
- TraceMessage(VTS_TEST_STATUS, __func__, "rc = %d\n", rc);
+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");
- if (rc != 0) {
- gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
- return (&rp);
+ 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;
+
+ memset(&rp, 0, sizeof (rp));
- TraceMessage(VTS_DEBUG, __func__, "Not a DMA device\n");
+ TraceMessage(VTS_DEBUG, "efb_test_dma", "Not a DMA device\n");
- check4abort(dpy);
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() */
-
-/*
- * 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)
-{
-#define CTRL_C '\003' /* Ctrl-C (^C) */
-
- /*
- * If necessary, restore the original state following a test
- */
-#if !defined(VTS_STUBS)
- chip_test_reset();
-#endif
-
- 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 */
-
- 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);
- }
- }
- }
- }
-#endif /* VTS_STUBS */
- }
-
-} /* check4abort() */
+#define CTRL(x) ((x) & 0x1f)
+int
+efb_check_for_interrupt(
+ void)
+{
+ register size_t inputlength;
+ register size_t inputon;
+ register int ch;
+ struct sigaction oldint;
+ struct sigaction oldquit;
+ XEvent event;
+ char inputstring[16];
+
+ if (efb_xw.xw_display == NULL)
+ return (0);
+
+ 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];
+
+ 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);
+ }
+ }
+ }
+ }
+ }
+ return (0);
+}
+
/* End of libvtsSUNWefb.c */
--- 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"
+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;
-/* Test Open, initialization & read back; basic ability to talk to device */
-return_packet *efb_test_open(int fd);
+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;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* chip.c */
+
+extern return_packet *efb_test_chip(
+ int const fd);
+
+extern int chip_test(
+ return_packet *const rp,
+ int const fd);
+
+extern int draw_lines(
+ uint_t const width,
+ uint_t const height);
+
+extern int draw_cascaded_box(
+ uint_t const width,
+ uint_t const height);
+
+/* mapper.c */
-/* Test DMA, read/write via dma, memory and, chip tests will use DMA */
-return_packet *efb_test_dma(int fd);
+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 */
-/* Test Memory, various address, data, and, random patterns */
-return_packet *efb_test_memory(int fd);
+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);
-/* Test Chip, functional tests */
-return_packet *efb_test_chip(int fd);
+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;
-void check4abort();
-int get_processHandle(int, void **);
+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 backup_clut_init;
-extern struct fbcmap backup_clut;
-extern int myfd;
+extern int efb_grab_pointer(
+ void);
+
+extern int efb_ungrab_pointer(
+ void);
+
+extern int efb_disable_screensaver(
+ void);
+
+extern int efb_restore_screensaver(
+ void);
+
+extern int efb_disable_dpms(
+ void);
+
+extern int efb_restore_dpms(
+ void);
+extern int efb_sleep(
+ uint_t const seconds);
+
+extern void efb_signal_routine(
+ int const signo);
+
+extern int efb_check_for_interrupt(
+ void);
+
+extern void graphicstest_finish(
+ int const flag);
+
+/* dma.c */
+
+extern return_packet *efb_test_dma(
+ int const fd);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBVTSSUNWEFB_H */
-
/* End of libvtsSUNWefb.h */
--- a/open-src/app/gfx-utils/sun-src/vts/efb/mapfile Wed Sep 18 11:01:17 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/efb/mapfile Tue Sep 24 14:01:59 2013 -0700
@@ -1,7 +1,46 @@
-SUNW_1.1 {
- global:
- get_tests;
- cleanup_tests;
- local:
- *;
+#
+# 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"),
+# 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.
+#
+
+#
+# MAPFILE HEADER START
+#
+# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
+# Object versioning must comply with the rules detailed in
+#
+# usr/src/lib/README.mapfiles
+#
+# You should not be making modifications here until you've read the most current
+# copy of that file. If you need help, contact a gatekeeper for guidance.
+#
+# MAPFILE HEADER END
+#
+
+$mapfile_version 2
+
+SYMBOL_VERSION SUNW_1.1 {
+ global:
+ get_tests;
+ cleanup_tests;
+ local:
+ *;
};
--- a/open-src/app/gfx-utils/sun-src/vts/efb/mapper.c Wed Sep 18 11:01:17 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/efb/mapper.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,50 +21,139 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <sys/types.h>
-#include <stdio.h>
-#include <sys/mman.h>
+#include "libvtsSUNWefb.h" /* Common VTS library definitions */
+#include "efb.h"
+
+/*
+ * 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(
+ register int const fd)
+{
+ static return_packet rp;
+ int rc = 0;
+ struct vis_identifier vis_identifier;
+
+ memset(&rp, 0, sizeof (return_packet));
+
+ if (gfx_vts_check_fd(fd, &rp))
+ return (&rp);
+
+ TraceMessage(VTS_TEST_STATUS, "efb_test_open", "check_fd passed.\n");
+
+ /* vis identifier will do this */
+ rc = ioctl(fd, VIS_GETIDENTIFIER, &vis_identifier);
-#include "gfx_common.h" /* GFX Common definitions */
-#include "graphicstest.h"
-#include "libvtsSUNWefb.h" /* Common VTS library definitions */
+ TraceMessage(VTS_TEST_STATUS, "efb_test_open", "rc = %d\n", rc);
+
+ if (rc != 0) {
+ gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
+ return (&rp);
+ }
+
+ if (strncmp(vis_identifier.name, "SUNWefb", 7) != 0 &&
+ strncmp(vis_identifier.name, "ORCLefb", 7) != 0) {
+ gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
+ return (&rp);
+ }
-#include "X11/Xlib.h"
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
-#include "efb.h"
+ efb_block_signals();
+
+ efb_lock_display();
+
+ map_me(&rp, fd);
+
+ efb_unlock_display();
+
+ efb_restore_signals();
+
+ TraceMessage(VTS_DEBUG, "efb_test_open", "Open completed OK\n");
+
+ return (&rp);
+
+} /* efb_test_open() */
/*
* map_me()
*/
-void
-map_me(return_packet *rp, int fd)
+int
+map_me(
+ register return_packet *const rp,
+ register int const fd)
{
- struct efb_info efb_info;
- struct efb_info *pEFB;
- unsigned int value, chipType;
-
+ memset(&efb_info, 0, sizeof (efb_info));
+ efb_info.efb_fd = fd;
- pEFB = &efb_info;
- pEFB->fd = fd;
+ if (efb_map_mem(rp, GRAPHICS_ERR_OPEN) != 0)
+ return (-1);
- /*
- * map the registers & frame buffers memory
- */
- if (efb_map_mem(pEFB, rp, GRAPHICS_ERR_OPEN) == -1) {
- return;
+ if (efb_test_semaphore(rp, GRAPHICS_ERR_OPEN) != 0) {
+ efb_unmap_mem(NULL, GRAPHICS_ERR_OPEN);
+ return (-1);
}
-done:
/*
* Unmap the registers & frame buffers memory
*/
- if (efb_unmap_mem(pEFB, rp, GRAPHICS_ERR_OPEN) == -1) {
- return;
- }
+ if (efb_unmap_mem(rp, GRAPHICS_ERR_OPEN) != 0)
+ return (-1);
+ return (0);
} /* map_me() */
+#define RADEON_SW_SEMAPHORE_MASK 0xffff
+#define SEMAPHORE_XOR_VALUE 0x5555
+
+int
+efb_test_semaphore(
+ register return_packet *const rp,
+ register int const test)
+{
+ register uint_t save_semaphore;
+ register uint_t new_semaphore;
+
+ /*
+ * Test the software bits of the semaphore register.
+ * Complement the bits, and see if they read back
+ * complemented.
+ */
+
+ /* Save the original semaphore. */
+
+ save_semaphore = REGR(RADEON_SW_SEMAPHORE);
+
+ /* Write the semaphore with the software bits complemented. */
+ REGW(RADEON_SW_SEMAPHORE,
+ save_semaphore ^ SEMAPHORE_XOR_VALUE);
+
+ /* Get the new semaphore. */
+
+ new_semaphore = REGR(RADEON_SW_SEMAPHORE);
+
+ /* Restore the old semaphore. */
+
+ REGW(RADEON_SW_SEMAPHORE, save_semaphore);
+
+ /* Check if the software bits did complement. */
+
+ if ((save_semaphore & RADEON_SW_SEMAPHORE_MASK) !=
+ ((new_semaphore ^ SEMAPHORE_XOR_VALUE) &
+ RADEON_SW_SEMAPHORE_MASK)) {
+ printf("semaphore 0x%08x 0x%08x 0x%08x\n",
+ save_semaphore, new_semaphore,
+ save_semaphore ^ SEMAPHORE_XOR_VALUE);
+
+ gfx_vts_set_message(rp, 1, test, "semaphore test failed");
+ return (0);
+ }
+ return (1);
+}
/* End of mapper.c */
--- a/open-src/app/gfx-utils/sun-src/vts/efb/memory.c Wed Sep 18 11:01:17 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/efb/memory.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,20 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <sys/types.h>
-#include <errno.h> /* errno */
-#include <stdio.h>
-#include <string.h> /* strerror() */
-#include <stropts.h> /* ioctl() */
-#include <unistd.h> /* ioctl() */
-#include <sys/mman.h>
-#include <stdlib.h>
-
-#include "gfx_common.h"
-#include "graphicstest.h"
-#include "libvtsSUNWxfb.h" /* Common VTS library definitions */
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
-#include "efb.h"
+#include "libvtsSUNWefb.h" /* Common VTS library definitions */
typedef union MemType {
uint64_t val[8];
@@ -48,306 +34,402 @@
1, 2, 4, 8, 0
};
-static const char *const access_tname[] = {
- "\tverifying byte access mode...",
- "\tverifying short access mode...",
- "\tverifying word access mode...",
- "\tverifying long long access mode...",
-};
+static MemType data[32 * 8];
+static MemType cdata[32 * 8];
+static MemType rdval[4];
-void
-Write8(void *addr, uint8_t data) {
- *(uint8_t *)addr = data;
-}
+/*
+ * efb_test_memory()
+ *
+ * This test will open the device and read and write to all memory
+ * addresses.
+ */
-void
-Write16(void *addr, uint16_t data) {
- *(uint16_t *)addr = data;
-}
+return_packet *
+efb_test_memory(
+ register int const fd)
+{
+ static return_packet rp;
-void
-Write32(void *addr, uint32_t data) {
- *(uint32_t *)addr = data;
-}
+ memset(&rp, 0, sizeof (return_packet));
-void
-Write64(void *addr, uint64_t data) {
- *(uint64_t *)addr = data;
-}
+ if (gfx_vts_debug_mask & GRAPHICS_VTS_MEM_OFF)
+ return (&rp);
-uint8_t
-read8(void *addr) {
- return (*(uint8_t *)addr);
-}
+ TraceMessage(VTS_DEBUG, "efb_test_memory",
+ "efb_test_memory running\n");
+
+ efb_block_signals();
+
+ efb_lock_display();
-uint16_t
-read16(void *addr) {
- return (*(uint16_t *)addr);
-}
+ memory_test(&rp, fd);
+
+ efb_unlock_display();
+
+ efb_restore_signals();
-uint32_t
-read32(void *addr) {
- return (*(uint32_t *)addr);
-}
+ TraceMessage(VTS_DEBUG, "efb_test_memory",
+ "efb_test_memory completed\n");
-uint64_t
-read64(void *addr) {
- return (*(uint64_t *)addr);
-}
+ return (&rp);
+} /* efb_test_memory() */
-u_int
-test_data() {
- u_int ret;
+int
+memory_test(
+ register return_packet *const rp,
+ register int const fd)
+{
+ register size_t i;
+ register int signo;
+ struct sigaction oldhup;
+ struct sigaction oldint;
+ struct sigaction oldalrm;
+ struct sigaction oldterm;
+ struct sigaction newsigact;
+ sigset_t oldprocmask;
+
+ memset(&efb_info, 0, sizeof (efb_info));
+ efb_info.efb_fd = fd;
+
+ if (efb_map_mem(rp, GRAPHICS_ERR_MEMORY_MSG) != 0)
+ return (-1);
+
+ if (efb_init_info(rp, GRAPHICS_ERR_MEMORY_MSG) != 0) {
+ efb_unmap_mem(NULL, GRAPHICS_ERR_MEMORY_MSG);
+ return (-1);
+ }
+
+ efb_save_palet();
+ efb_set_palet();
+
+ /*
+ * Allow a SIGHUP, SIGINT, SIGALRM, or SIGTERM to interrupt our
+ * memory_test. 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);
- ret = (u_int)mrand48();
- return (ret);
+ for (i = 0; access_mode[i] != 0; i++) {
+ /* Unmask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &efb_xw.xw_procmask,
+ &oldprocmask);
+
+ check_plane(efb_info.efb_pixelsize * 8,
+ access_mode[i],
+ efb_info.efb_linesize / efb_info.efb_pixelsize,
+ efb_info.efb_height,
+ efb_info.efb_width,
+ efb_info.efb_pixelsize,
+ (caddr_t)efb_info.efb_fb_ptr);
+
+ /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+ signo = efb_check_for_interrupt();
+ if (signo != 0)
+ break;
+ }
+
+ /* 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);
+ }
+
+ efb_restore_palet();
+
+ if (efb_unmap_mem(rp, GRAPHICS_ERR_MEMORY_MSG) != 0)
+ return (-1);
+
+ return (0);
}
-MemType *data;
-MemType *cdata;
-
void
-plane_change(int num_planes_, caddr_t base_, int sh, int sw)
+check_plane(
+ register int const num_planes,
+ register int const access_mode,
+ register int const fb_pitch,
+ register int const fb_height,
+ register int const fb_width,
+ register int const bytepp,
+ register caddr_t const base)
{
- int num_planes = num_planes_;
- caddr_t base = base_;
- int i;
- int j;
+ register int x;
+ register int y;
+ register int complement;
+
+ /* Set up raster for this plane group */
+
+ init_data(num_planes);
+
+ /* Cover each 64x64 chunk of screen space */
+
+ y = 0;
+ while (y < fb_height) {
+ x = 0;
+ while (x < fb_width) {
+ if (x + 63 > fb_width)
+ x = fb_width - 64;
+ if (y + 63 > fb_height)
+ y = fb_height - 64;
+
+ /* Do each chunk twice - once normal, once complement */
- int pix_per_write, old_pix_per_write;
+ for (complement = B_FALSE;
+ complement <= B_TRUE;
+ complement++) {
+ write_read(x, y,
+ (boolean_t)complement,
+ access_mode,
+ B_TRUE,
+ fb_pitch,
+ bytepp,
+ base) ||
+ write_read(x, y,
+ (boolean_t)complement,
+ access_mode,
+ B_FALSE,
+ fb_pitch,
+ bytepp,
+ base);
+ }
+
+ /* Move over one 64x64 chunk */
+
+ x += 64;
+ }
+
+ /* Move down one 64x64 chunk */
+
+ y += 64;
+ }
+}
+
+
+void
+init_data(
+ register int const num_planes)
+{
+ register int i;
+ register int j;
/* Get memory to store data */
- int memcount = num_planes * 8;
+ /* Write data to memory */
- if (data) free(data);
- if (cdata) free(cdata);
+ for (i = 0; i < num_planes * 8; i++) {
+ for (j = 0; j < 8; j++) {
- data = (MemType *)memalign(64, memcount * sizeof (MemType));
- cdata = (MemType *)memalign(64, memcount * sizeof (MemType));
+ /* Figure out the value to write */
- /* Write data to memory */
- for (i = 0; i < memcount; i++) {
- for (j = 0; j < 8; j++) {
- /* Figure out the value to write */
- data[i].val[j] = ((unsigned long long)test_data() << 32)
- | test_data();
- cdata[i].val[j] = ~data[i].val[j];
- }
+ data[i].val[j] = ((unsigned long long)
+ test_data() << 32) | test_data();
+ cdata[i].val[j] = ~data[i].val[j];
+ }
}
+}
-} /* plane_change() */
+
+
+uint_t
+test_data(
+ void)
+{
+ register uint_t ret;
+
+ ret = (uint_t)mrand48();
+ return (ret);
+}
boolean_t
-write_read(int xoff, int yoff, boolean_t complement, int access_mode,
- boolean_t pass, int fb_pitch, int bytepp, caddr_t base)
+write_read(
+ register int const xoff,
+ register int const yoff,
+ register boolean_t const complement,
+ register int const access_mode,
+ register boolean_t const pass,
+ register int const fb_pitch,
+ register int const bytepp,
+ register caddr_t const base)
{
- MemType *dp;
- int pitch = fb_pitch;
- int x;
- int y;
- int i;
- caddr_t mem_addr;
- caddr_t dp_addr;
- u_int second_rdval;
- MemType *rdval;
- int subscr = 0;
-
- if (complement) {
- dp = cdata;
- } else {
- dp = data;
- }
+ register MemType *const dp = complement ? cdata : data;
+ register int const pitch = fb_pitch;
+ register int x;
+ register int y;
+ register int i;
+ register caddr_t mem_addr;
+ register int subscr = 0;
/* Write Data to Screen */
+
for (y = yoff; y < yoff + 64; y++) {
- for (x = xoff * bytepp, i = 0;
- x < ((xoff + 64) *bytepp);
- x += access_mode, i++) {
- mem_addr = (y*pitch*bytepp) + x + base;
- /* Check which access mode to use for write */
- switch (access_mode) {
- case 8: /* long long (8-byte) access mode */
- Write64(mem_addr, dp[subscr].val[i]);
- break;
- case 4: /* word (4-byte) access mode */
- Write32(mem_addr, dp[subscr].word[i]);
- break;
- case 2: /* short (2-byte) access mode */
- Write16(mem_addr, dp[subscr].halfwd[i]);
- break;
- default: /* default to byte access */
- Write8(mem_addr, dp[subscr].byte[i]);
- break;
+ for (x = xoff * bytepp, i = 0;
+ x < ((xoff + 64) * bytepp);
+ x += access_mode, i++) {
+ mem_addr = (y * pitch * bytepp) + x + base;
+
+ /* Check which access mode to use for write */
+
+ switch (access_mode) {
+ case 8: /* long long (8-byte) access mode */
+ *(uint64_t volatile *)mem_addr =
+ dp[subscr].val[i];
+ break;
+
+ case 4: /* word (4-byte) access mode */
+ *(uint32_t volatile *)mem_addr =
+ dp[subscr].word[i];
+ break;
+
+ case 2: /* short (2-byte) access mode */
+ *(uint16_t volatile *)mem_addr =
+ dp[subscr].halfwd[i];
+ break;
+
+ default: /* default to byte access */
+ *(uint8_t volatile *)mem_addr =
+ dp[subscr].byte[i];
+ break;
+ }
}
- }
- subscr++;
+ subscr++;
}
/* Read the Data From the Screen */
- rdval = (MemType *)memalign(64, (sizeof (MemType) * bytepp));
+ for (y = yoff; y < yoff + 64; y++) {
+ for (x = xoff * bytepp, i = 0;
+ x < ((xoff + 64) * bytepp);
+ x += access_mode, i++) {
+ mem_addr = (y * pitch * bytepp) + x + base;
- for (y = yoff; y < yoff + 64; y++) {
- for (x = xoff * bytepp, i = 0;
- x < ((xoff + 64) * bytepp);
- x += access_mode, i++) {
- mem_addr = (y*pitch*bytepp) + x + base;
+ switch (access_mode) {
+ case 8: /* long long (8-byte) access mode */
+ rdval[0].val[i] =
+ *(uint64_t volatile const *)mem_addr;
+ break;
- switch (access_mode) {
- case 8: /* long long (8-byte) access mode */
- rdval->val[i] = read64(mem_addr);
- break;
- case 4: /* word (4-byte) access mode */
- rdval->word[i] = read32(mem_addr);
- break;
- case 2: /* short (2-byte) access mode */
- rdval->halfwd[i] = read16(mem_addr);
- break;
- default: /* default to byte access */
- rdval->byte[i] = read8(mem_addr);
- break;
+ case 4: /* word (4-byte) access mode */
+ rdval[0].word[i] =
+ *(uint32_t volatile const *)mem_addr;
+ break;
+
+ case 2: /* short (2-byte) access mode */
+ rdval[0].halfwd[i] =
+ *(uint16_t volatile const *)mem_addr;
+ break;
+
+ default: /* default to byte access */
+ rdval[0].byte[i] =
+ *(uint8_t volatile const *)mem_addr;
+ break;
+ }
}
- }
/* TODO: verification */
- if (memcmp(rdval, dp[subscr].byte, 64 * bytepp) != 0) {
- switch (access_mode) {
- case 8: /* long long (8-byte) access mode */
- for (i = 0; i < (16 * bytepp); i++) {
- if (rdval->word[i] != dp[subscr].word[i]) {
- free(rdval);
- return (B_FALSE);
- }
- }
- break;
- case 4: /* word (4-byte) access mode */
- for (i = 0; i < (16 * bytepp); i++) {
- if (rdval->word[i] != dp[subscr].word[i]) {
- free(rdval);
- return (B_FALSE);
- }
+
+ if (memcmp(rdval, dp[subscr].byte, 64 * bytepp) != 0) {
+ switch (access_mode) {
+ case 8: /* long long (8-byte) access mode */
+ for (i = 0; i < (8 * bytepp); i++) {
+ if (rdval[0].val[i] !=
+ dp[subscr].val[i])
+ return (B_FALSE);
+ }
+ break;
+
+ case 4: /* word (4-byte) access mode */
+ for (i = 0; i < (16 * bytepp); i++) {
+ if (rdval[0].word[i] !=
+ dp[subscr].word[i])
+ return (B_FALSE);
+ }
+ break;
+
+ case 2: /* short (2-byte) access mode */
+ for (i = 0; i < (32 * bytepp); i++) {
+ if (rdval[0].halfwd[i] !=
+ dp[subscr].halfwd[i])
+ return (B_FALSE);
+ }
+ break;
+
+ default: /* default to byte access */
+ for (i = 0; i < (64 * bytepp); i++) {
+ if (rdval[0].byte[i] !=
+ dp[subscr].byte[i])
+ return (B_FALSE);
+ }
+ break;
}
- break;
- case 2: /* short (2-byte) access mode */
- for (i = 0; i < (32 * bytepp); i++) {
- if (rdval->halfwd[i] != dp[subscr].halfwd[i]) {
- free(rdval);
- return (B_FALSE);
- }
- }
- break;
- default: /* default to byte access */
- for (i = 0; i < (64 * bytepp); i++) {
- if (rdval->byte[i] != dp[subscr].byte[i]) {
- free(rdval);
- return (B_FALSE);
- }
- }
- break;
}
- }
- subscr ++;
+ subscr++;
}
return (B_TRUE);
-
-} /* write_read() */
-
-
-void
-check_plane(int num_planes, int access_mode, char *test_name,
- int fb_offset, int fb_pitch, int fb_height,
- int fb_width, int bytepp, caddr_t base)
-{
- int x;
- int y;
- int complement;
-
- /* Set up refber for this plane group */
- plane_change(num_planes, base + fb_offset, fb_width, fb_height);
-
- /* Cover each 64x64 chunk of screen space */
- y = 0;
- while (y < fb_height) {
- x = 0;
- while (x < fb_width) {
- if (x + 63 > fb_width) x = fb_width - 64;
- if (y + 63 > fb_height) y = fb_height - 64;
-
- /* Do each chunk twice - once normal, once complement */
- for (complement = B_FALSE;
- complement <= B_TRUE;
- complement++) {
- write_read(x, y,
- (boolean_t)complement,
- access_mode,
- B_TRUE,
- fb_pitch,
- bytepp,
- base) ||
- write_read(x, y,
- (boolean_t)complement,
- access_mode,
- B_FALSE,
- fb_pitch,
- bytepp,
- base);
- }
-
- /* Move over one 64x64 chunk */
- x += 64;
- }
-
- /* Move down one 64x64 chunk */
- y += 64;
- }
-
-} /* check_plane() */
-
-
-void
-memory_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_MEMORY_MSG) == -1) {
- return;
- }
-
- if (efb_init_info(pEFB) == -1) {
- return;
- }
-
- for (i = 0; access_mode[i] != 0; i++) {
- check_plane((size_t) pEFB->bitsPerPixel, access_mode[i],
- (char *)"Memory Test",
- 0, pEFB->screenWidth, pEFB->screenHeight, pEFB->screenWidth,
- pEFB->bitsPerPixel/8, (caddr_t)pEFB->FBvaddr);
- }
-
- /*
- * Unmap the registers & frame buffers memory
- */
- if (efb_unmap_mem(pEFB, rp, GRAPHICS_ERR_MEMORY_MSG) == -1) {
- return;
- }
-} /* memory_test() */
+}
/* End of memory.c */
--- a/open-src/app/gfx-utils/sun-src/vts/efb/tools.c Wed Sep 18 11:01:17 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/efb/tools.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,318 +21,753 @@
* DEALINGS IN THE SOFTWARE.
*/
-#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 "efb.h"
int
-efb_get_pci_info(int fd, struct pci_info *pciInfo)
+efb_map_mem(
+ register return_packet *const rp,
+ register int const test)
{
- struct gfx_pci_cfg pciCfg;
- int i;
- unsigned int bar;
+ register int const pagesize = getpagesize();
+
+ if (efb_get_pci_info() != 0) {
+ gfx_vts_set_message(rp, 1, test, "get pci info failed");
+ return (-1);
+ }
- if (ioctl(fd, GFX_IOCTL_GET_PCI_CONFIG, &pciCfg) == -1) {
- return -1;
+ /*
+ * Map MMIO
+ */
+ efb_info.efb_mmio_size = (efb_info.efb_mmio_size + pagesize - 1) /
+ pagesize * pagesize;
+
+ if (efb_map_mmio() != 0) {
+ gfx_vts_set_message(rp, 1, test, "map MMIO failed");
+ return (-1);
}
- pciInfo->deviceID = pciCfg.DeviceID;
+ switch (efb_info.efb_device) {
+ case 20825:
+ case 20830:
+ case 23396:
+ efb_info.efb_fb_size = REGR(RADEON_CONFIG_MEMSIZE);
+ break;
+ default:
+ efb_info.efb_fb_size = REGR(R600_CONFIG_MEMSIZE);
+ break;
+ }
+ efb_info.efb_fb_size = (efb_info.efb_fb_size + (pagesize - 1)) /
+ pagesize * pagesize;
+
+ /*
+ * Map framebuffer
+ */
+
+ if (efb_map_fb() != 0) {
+ gfx_vts_set_message(rp, 1, test, "map framebuffer failed");
+ return (-1);
+ }
+
+ return (0);
+}
+
+int
+efb_get_pci_info(
+ void)
+{
+ struct gfx_pci_cfg pciconfig;
+ int i;
+ uint_t bar;
+ uint_t bar_hi;
+ offset_t mem_base[6];
+ offset_t io_base[6];
+ int type[6];
+
+ if (ioctl(efb_info.efb_fd, GFX_IOCTL_GET_PCI_CONFIG,
+ &pciconfig) != 0) {
+ return (-1);
+ }
+
+ efb_info.efb_vendor = pciconfig.VendorID;
+ efb_info.efb_device = pciconfig.DeviceID;
for (i = 0; i < 6; i++) {
- bar = pciCfg.bar[i];
- if (bar != 0) {
- if (bar & PCI_MAP_IO) {
- pciInfo->ioBase[i] = PCIGETIO(bar);
- pciInfo->type[i] = bar & PCI_MAP_IO_ATTR_MASK;
- } else {
- pciInfo->type[i] = bar & PCI_MAP_MEMORY_ATTR_MASK;
- pciInfo->memBase[i] = PCIGETMEMORY(bar);
- if (PCI_MAP_IS64BITMEM(bar)) {
- if (i == 5) {
- pciInfo->memBase[i] = 0;
+ type[i] = 0;
+ mem_base[i] = 0;
+ io_base[i] = 0;
+ }
+
+ for (i = 0; i < 6; i++) {
+ bar = pciconfig.bar[i];
+ if (bar != 0) {
+ if (bar & PCI_MAP_IO) {
+ io_base[i] = PCIGETIO(bar);
+ type[i] = bar & PCI_MAP_IO_ATTR_MASK;
} else {
- int bar_hi = pciCfg.bar[i+1];
- pciInfo->memBase[i] |= (bar_hi << 32);
- ++i;
+ type[i] = bar & PCI_MAP_MEMORY_ATTR_MASK;
+ mem_base[i] = PCIGETMEMORY(bar);
+ if (PCI_MAP_IS64BITMEM(bar)) {
+ if (i == 5) {
+ mem_base[i] = 0;
+ } else {
+ bar_hi = pciconfig.bar[i+1];
+ mem_base[i] |=
+ ((offset_t)bar_hi << 32);
+ ++i;
+ }
+ }
}
- }
- pciInfo->size[i] = EFB_REG_SIZE_LOG2;
}
- }
}
- return 0;
+ efb_info.efb_fb_addr = mem_base[0] & 0xfff00000;
+ efb_info.efb_fb_size = 0;
+
+ efb_info.efb_mmio_addr = mem_base[2] & 0xffff0000;
+ efb_info.efb_mmio_size = 1 << EFB_REG_SIZE_LOG2;
+
+ if (gfx_vts_debug_mask & VTS_DEBUG) {
+ printf("efb_vendor = 0x%04x, efb_device = 0x%04x\n",
+ efb_info.efb_vendor, efb_info.efb_device);
+ printf("efb_fb_addr 0x%llx, efb_fb_size 0x%lx\n",
+ (unsigned long long)efb_info.efb_fb_addr,
+ (unsigned long)efb_info.efb_fb_size);
+ printf("efb_mmio_addr 0x%llx, efb_mmio_size 0x%lx\n",
+ (unsigned long long)efb_info.efb_mmio_addr,
+ (unsigned long)efb_info.efb_mmio_size);
+ }
+
+ return (0);
+}
+
+int
+efb_map_mmio(
+ void)
+{
+ register void *ptr;
+
+ if (efb_info.efb_mmio_ptr == NULL) {
+ ptr = mmap(NULL, efb_info.efb_mmio_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ efb_info.efb_fd, efb_info.efb_mmio_addr);
+
+ if (ptr == MAP_FAILED)
+ return (-1);
+ }
+
+ efb_info.efb_mmio_ptr = (uchar_t *)ptr;
+
+ if (gfx_vts_debug_mask & VTS_DEBUG)
+ printf("efb_mmio_ptr = 0x%llx\n",
+ (unsigned long long)efb_info.efb_mmio_ptr);
+
+ return (0);
}
int
-efb_get_mem_info(struct pci_info *pci_info, struct efb_info *pEFB)
+efb_map_fb(
+ void)
{
- unsigned char reg;
+ register void *ptr;
+
+ if (efb_info.efb_fb_ptr == NULL) {
+ ptr = mmap(NULL, efb_info.efb_fb_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ efb_info.efb_fd, efb_info.efb_fb_addr);
+
+ if (ptr == MAP_FAILED)
+ return (-1);
+
+ efb_info.efb_fb_ptr = (uchar_t *)ptr;
+ }
+
+ if (gfx_vts_debug_mask & VTS_DEBUG)
+ printf("efb_fb_ptr = 0x%llx\n",
+ (unsigned long long)efb_info.efb_fb_ptr);
+
+ return (0);
+}
+
- pEFB->FBPhysAddr = pci_info->memBase[0] & 0xfff00000;
- pEFB->FBMapSize = 0;
+int
+efb_init_info(
+ register return_packet *const rp,
+ register int const test)
+{
+ register uint32_t crtc_h_total_disp;
+ register uint32_t crtc_v_total_disp;
+ register uint32_t crtc_gen_cntl;
+ register uint32_t crtc_pitch;
+ register uint_t width;
+ register uint_t height;
+ register uint_t depth;
+ register uint_t pixelsize;
+ register uint_t pitch;
+
+ /* Get the gen cntl */
+
+ crtc_gen_cntl = REGR(CRTC_GEN_CNTL);
+
+ /* Get the horizontal total display end */
+
+ crtc_h_total_disp = REGR(CRTC_H_TOTAL_DISP);
+
+ /* Get the vertical total display end */
- pEFB->MMIOPhysAddr = pci_info->memBase[2] & 0xffff0000;
- pEFB->MMIOMapSize = 1 << pci_info->size[2];
+ crtc_v_total_disp = REGR(CRTC_V_TOTAL_DISP);
+
+ /* Get the pitch */
+
+ crtc_pitch = REGR(CRTC_PITCH);
+
+ /* Compute the width. */
+
+ width = (((crtc_h_total_disp & CRTC_H_TOTAL_DISP__CRTC_H_DISP_MASK) >>
+ CRTC_H_TOTAL_DISP__CRTC_H_DISP__SHIFT) + 1) * 8;
+
+ /* Compute the height. */
+
+ height = ((crtc_v_total_disp & CRTC_V_TOTAL_DISP__CRTC_V_DISP_MASK) >>
+ CRTC_V_TOTAL_DISP__CRTC_V_DISP__SHIFT) + 1;
+
+ if (crtc_gen_cntl & CRTC_GEN_CNTL__CRTC_INTERLACE_EN_MASK)
+ height *= 2;
+
+ /* Compute the pitch */
+
+ pitch = crtc_pitch & CRTC_PITCH__CRTC_PITCH_MASK;
+
+ /* Compute the depth. */
+
+ switch ((crtc_gen_cntl & CRTC_GEN_CNTL__CRTC_PIX_WIDTH_MASK) >>
+ CRTC_GEN_CNTL__CRTC_PIX_WIDTH__SHIFT) {
- pEFB->RelocateIO = pci_info->ioBase[1];
+ case 2:
+ depth = 8;
+ pixelsize = 1;
+ pitch *= 8;
+ break;
+
+ case 3:
+ depth = 15;
+ pixelsize = 2;
+ pitch *= 16;
+ break;
+
+ case 4:
+ depth = 16;
+ pixelsize = 2;
+ pitch *= 16;
+ break;
- pEFB->ChipSet = pci_info->deviceID;
+ case 5:
+ depth = 24;
+ pixelsize = 3;
+ pitch *= 24;
+ break;
+
+ case 6:
+ depth = 32;
+ pixelsize = 4;
+ pitch *= 32;
+ break;
+
+ default:
+ gfx_vts_set_message(rp, 1, test, "unsupported depth");
+ return (-1);
+ }
+
+ efb_info.efb_width = width;
+ efb_info.efb_height = height;
+ efb_info.efb_depth = depth;
+ efb_info.efb_pixelsize = pixelsize;
+ efb_info.efb_linesize = pitch;
-#ifdef DEBUG
- printf("FBPhysAddr=0x%x FBMapSize=0x%x\n", pEFB->FBPhysAddr, pEFB->FBMapSize);
- printf("MMIOPhysAddr=0x%x MMIOMapSize=0x%x\n", pEFB->MMIOPhysAddr, pEFB->MMIOMapSize);
- printf("RelocateIO=0x%x\n", pEFB->RelocateIO);
-#endif
+ if (gfx_vts_debug_mask & VTS_DEBUG) {
+ printf("width=%d height=%d depth=%d pitch=%d\n",
+ efb_info.efb_width, efb_info.efb_height,
+ efb_info.efb_depth, efb_info.efb_linesize);
+ }
+ return (0);
+}
+
+int
+efb_unmap_mem(
+ register return_packet *const rp,
+ register int const test)
+{
+ if (efb_unmap_fb() != 0) {
+ gfx_vts_set_message(rp, 1, test, "unmap framebuffer failed");
+ return (-1);
+ }
- return 0;
+ if (efb_unmap_mmio() != 0) {
+ gfx_vts_set_message(rp, 1, test, "unmap MMIO failed");
+ return (-1);
+ }
+
+ return (0);
+}
+
+
+int
+efb_unmap_fb(
+ void)
+{
+ register int status;
+
+ if (efb_info.efb_fb_ptr == NULL)
+ return (0);
+
+ status = munmap((char *)efb_info.efb_fb_ptr, efb_info.efb_fb_size);
+ efb_info.efb_fb_ptr = NULL;
+
+ return (status);
}
int
-efb_init_info(struct efb_info *pEFB)
+efb_unmap_mmio(
+ void)
{
- unsigned int v, v2;
- unsigned int status = 0;
-
-
-#if 0
- /*
- * first check if the hardware is already initialized.
- * If not, abort
- */
- ioctl(pEFB->fd, EFB_GET_STATUS_FLAGS, &status);
- if (!(status & EFB_STATUS_HW_INITIALIZED))
- return -1;
-#endif
-
+ register int status;
- v = REGR(CRTC_GEN_CNTL);
- v2 = (v & CRTC_GEN_CNTL__CRTC_PIX_WIDTH_MASK) >> CRTC_GEN_CNTL__CRTC_PIX_WIDTH__SHIFT;
- if (v2 <= 2)
- pEFB->bitsPerPixel = 8;
- else if (v2 <= 4)
- pEFB->bitsPerPixel = 16;
- else
- pEFB->bitsPerPixel = 32;
-
-
- v = REGR(CRTC_H_TOTAL_DISP);
- v2 = (v & CRTC_H_TOTAL_DISP__CRTC_H_DISP_MASK) >> CRTC_H_TOTAL_DISP__CRTC_H_DISP__SHIFT;
- pEFB->screenWidth = (v2 + 1) * 8;
+ if (efb_info.efb_mmio_ptr == NULL)
+ return (0);
- v = REGR(CRTC_V_TOTAL_DISP);
- v2 = (v & CRTC_V_TOTAL_DISP__CRTC_V_DISP_MASK) >> CRTC_V_TOTAL_DISP__CRTC_V_DISP__SHIFT;
- pEFB->screenHeight = (v2 + 1);
- pEFB->screenPitch = pEFB->screenWidth * pEFB->bitsPerPixel / 8;
-
+ status = munmap((char *)efb_info.efb_mmio_ptr,
+ efb_info.efb_mmio_size);
+ efb_info.efb_mmio_ptr = NULL;
- pEFB->fbLocation = REGR(RADEON_MC_FB_LOCATION);
-
-#ifdef DEBUG
- printf("bpp=%d width=%d height=%d pitch=%d fbLoc=0x%x\n",
- pEFB->bitsPerPixel, pEFB->screenWidth, pEFB->screenHeight, pEFB->screenPitch,
- pEFB->fbLocation);
-#endif
- return 0;
+ return (status);
}
int
-efb_map_mem(struct efb_info *pEFB, return_packet *rp, int test)
+efb_init_graphics(void)
{
- struct pci_info pci_info;
- int pageSize, size;
- int fd = pEFB->fd;
+ uint_t pitch_offset;
+ uint_t pitch;
+ uint_t offset;
+ uint_t gmc_bpp;
+ uint_t v;
+
+ switch (efb_info.efb_depth) {
+ case 8:
+ gmc_bpp = GMC_DST_8BPP;
+ break;
+ case 15:
+ gmc_bpp = GMC_DST_15BPP;
+ break;
+
+ case 16:
+ gmc_bpp = GMC_DST_16BPP;
+ break;
+
+ case 24:
+ gmc_bpp = GMC_DST_24BPP;
+ break;
+
+ case 32:
+ gmc_bpp = GMC_DST_32BPP;
+ break;
+ }
+
+ offset = REGR(CRTC_OFFSET) & 0x7ffffff;
+ pitch = REGR(CRTC_PITCH) & 0x7ff;
+
+ pitch = pitch * 8; /* was in groups of 8 pixels */
+
+ pitch_offset =
+ ((pitch * efb_info.efb_pixelsize / 64) << 22) |
+ (offset / 1024);
+
+ /*
+ * Initialize GUI engine
+ */
+ if (!efb_wait_idle())
+ return (0);
- if (efb_get_pci_info(fd, &pci_info) == -1) {
- TraceMessage(VTS_DEBUG, __func__, "get pci info failed\n");
- gfx_vts_set_message(rp, 1, test, "get pci info failed");
- return -1;
- }
+ if (!efb_wait_fifo(5))
+ return (0);
+
+ 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,
+ (efb_info.efb_height << 16) | (efb_info.efb_width));
+
+ 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
+ return (1);
+}
+
+
+void
+efb_save_palet(
+ void)
+{
+ register uint_t coloron;
+ register uint_t const save_palette_index =
+ REGR(RADEON_PALETTE_INDEX);
+
+ REGW(RADEON_PALETTE_INDEX, 0);
+
+ for (coloron = 0; coloron < 256; coloron++)
+ efb_info.efb_palet[coloron] = REGR(RADEON_PALETTE_30_DATA);
+
+ REGW(RADEON_PALETTE_INDEX, save_palette_index);
+}
- if (efb_get_mem_info(&pci_info, pEFB) == -1) {
- TraceMessage(VTS_DEBUG, __func__, "get mem info failed\n");
- gfx_vts_set_message(rp, 1, test, "get mem info failed");
- return -1;
- }
+int
+efb_set_palet(
+ void)
+{
+ register uint_t coloron;
+ register uint_t save_palette_index;
+ uint_t new_red;
+ uint_t new_green;
+ uint_t new_blue;
+ uint_t new_palet[256];
- /*
- * Map MMIO
- */
- pageSize = getpagesize();
- size = pEFB->MMIOMapSize + (pageSize - 1) & (~(pageSize - 1));
-
- pEFB->MMIOvaddr = (unsigned char *)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED,
- fd, pEFB->MMIOPhysAddr);
+ switch (efb_info.efb_depth) {
+ case 8: /* 3, 3, 2 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red = ((coloron >> 5) & 0x7) * 1023 / 7;
+ new_green = ((coloron >> 2) & 0x7) * 1023 / 7;
+ new_blue = (coloron & 0x3) * 1023 / 3;
+ new_palet[coloron] =
+ (new_red <<
+ PALETTE_30_DATA__PALETTE_DATA_R__SHIFT) |
+ (new_green <<
+ PALETTE_30_DATA__PALETTE_DATA_G__SHIFT) |
+ (new_blue <<
+ PALETTE_30_DATA__PALETTE_DATA_B__SHIFT);
+ }
+ break;
- if (pEFB->MMIOvaddr == MAP_FAILED) {
- TraceMessage(VTS_DEBUG, __func__, "map MMIO failed\n");
- gfx_vts_set_message(rp, 1, test, "map MMIO failed");
- return -1;
- }
-
-
+ case 15: /* 5, 5, 5 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red = (coloron / 8) * 1023 / 31;
+ new_green = (coloron / 8) * 1023 / 31;
+ new_blue = (coloron / 8) * 1023 / 31;
+ new_palet[coloron] =
+ (new_red <<
+ PALETTE_30_DATA__PALETTE_DATA_R__SHIFT) |
+ (new_green <<
+ PALETTE_30_DATA__PALETTE_DATA_G__SHIFT) |
+ (new_blue <<
+ PALETTE_30_DATA__PALETTE_DATA_B__SHIFT);
+ }
+ break;
- switch (pEFB->ChipSet) {
- case 20825:
- case 20830:
- case 23396:
- pEFB->FBMapSize = REGR(RADEON_CONFIG_MEMSIZE);
+ case 16: /* 5, 6, 5 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red = (coloron / 8) * 1023 / 31;
+ new_green = (coloron / 4) * 1023 / 63;
+ new_blue = (coloron / 8) * 1023 / 31;
+ new_palet[coloron] =
+ (new_red <<
+ PALETTE_30_DATA__PALETTE_DATA_R__SHIFT) |
+ (new_green <<
+ PALETTE_30_DATA__PALETTE_DATA_G__SHIFT) |
+ (new_blue <<
+ PALETTE_30_DATA__PALETTE_DATA_B__SHIFT);
+ }
break;
- default:
- pEFB->FBMapSize = REGR(R600_CONFIG_MEMSIZE);
+
+ default: /* 8, 8, 8 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red = (coloron * 1023) / 255;
+ new_green = (coloron * 1023) / 255;
+ new_blue = (coloron * 1023) / 255;
+ new_palet[coloron] =
+ (new_red <<
+ PALETTE_30_DATA__PALETTE_DATA_R__SHIFT) |
+ (new_green <<
+ PALETTE_30_DATA__PALETTE_DATA_G__SHIFT) |
+ (new_blue <<
+ PALETTE_30_DATA__PALETTE_DATA_B__SHIFT);
+ }
break;
}
-
- /*
- * Map framebuffer
- */
- pageSize = getpagesize();
- size = pEFB->FBMapSize + (pageSize - 1) & (~(pageSize - 1));
+ /* Don't set the palet if it matches what we will set. */
- pEFB->FBvaddr = (unsigned char *)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED,
- fd, pEFB->FBPhysAddr);
+ for (coloron = 0; coloron < 256; coloron++) {
+ if ((efb_info.efb_palet[coloron] &
+ (PALETTE_30_DATA__PALETTE_DATA_R_MASK |
+ PALETTE_30_DATA__PALETTE_DATA_G_MASK |
+ PALETTE_30_DATA__PALETTE_DATA_B_MASK)) !=
+ (new_palet[coloron] &
+ (PALETTE_30_DATA__PALETTE_DATA_R_MASK |
+ PALETTE_30_DATA__PALETTE_DATA_G_MASK |
+ PALETTE_30_DATA__PALETTE_DATA_B_MASK)))
+ break;
+ }
- if (pEFB->FBvaddr == MAP_FAILED) {
- TraceMessage(VTS_DEBUG, __func__, "map framebuffer failed\n");
- gfx_vts_set_message(rp, 1, test, "map framebuffer failed");
- return -1;
- }
+ if (coloron == 256)
+ return (0);
+
+ efb_info.efb_palet_changed = 1;
+ save_palette_index = REGR(RADEON_PALETTE_INDEX);
+ REGW(RADEON_PALETTE_INDEX, 0);
- return 0;
+ for (coloron = 0; coloron < 256; coloron++)
+ REGW(RADEON_PALETTE_30_DATA, new_palet[coloron]);
+
+ REGW(RADEON_PALETTE_INDEX, save_palette_index);
+ return (1);
}
int
-efb_unmap_mem(struct efb_info *pEFB, return_packet *rp, int test)
+efb_restore_palet(
+ void)
{
- /*
- * Unmap Frame Buffer
- */
+ register uint_t coloron;
+ register uint_t save_palette_index;
+
+ if (!efb_info.efb_palet_changed)
+ return (0);
+
+ save_palette_index = REGR(RADEON_PALETTE_INDEX);
+
+ REGW(RADEON_PALETTE_INDEX, 0);
+
+ for (coloron = 0; coloron < 256; coloron++)
+ REGW(RADEON_PALETTE_30_DATA, efb_info.efb_palet[coloron]);
+
+ REGW(RADEON_PALETTE_INDEX, save_palette_index);
+
+ efb_info.efb_palet_changed = 0;
+ return (1);
+}
+
- if (munmap((void *)pEFB->FBvaddr, pEFB->FBMapSize) == -1) {
- TraceMessage(VTS_DEBUG, __func__, "unmap framebuffer failed\n");
- gfx_vts_set_message(rp, 1, test, "unmap framebuffer failed");
- return -1;
- }
+uint_t
+efb_color(
+ register uint_t const red,
+ register uint_t const green,
+ register uint_t const blue)
+{
+ register uint_t value;
+
+ switch (efb_info.efb_depth) {
+ case 8: /* 3, 3, 2 */
+ value = ((red >> 5) & 0x7) << 5;
+ value |= ((green >> 5) & 0x7) << 2;
+ value |= (blue >> 6) & 0x3;
+ break;
- if (munmap((void *)pEFB->MMIOvaddr, pEFB->MMIOMapSize) == -1) {
- TraceMessage(VTS_DEBUG, __func__, "unmap MMIO failed\n");
- gfx_vts_set_message(rp, 1, test, "unmap MMIO failed");
- return -1;
- }
+ case 15: /* 5, 5, 5 */
+ value = ((red >> 3) & 0x1f) << 10;
+ value |= ((green >> 3) & 0x1f) << 5;
+ value |= (blue >> 3) & 0x1f;
+ break;
- return 0;
+ case 16: /* 5, 6, 5 */
+ value = ((red >> 3) & 0x1f) << 11;
+ value |= ((green >> 2) & 0x3f) << 5;
+ value |= (blue >> 3) & 0x1f;
+ break;
+
+ default: /* 8, 8, 8 */
+ value = (red & 0xff) << 16;
+ value |= (green & 0xff) << 8;
+ value |= blue & 0xff;
+ break;
+ }
+
+ return (value);
}
-#define MASK RBBM_STATUS__CMDFIFO_AVAIL_MASK
-
-uint32_t
-getBPPValue (int bpp)
+int
+efb_fill_solid_rect(
+ register uint_t const x1,
+ register uint_t const y1,
+ register uint_t const x2,
+ register uint_t const y2,
+ register uint_t const fg)
{
- switch (bpp) {
- case 8: return (DST_8BPP);
- case 15: return (DST_15BPP);
- case 16: return (DST_16BPP);
- case 32: return (DST_32BPP);
- default: return (0);
- }
+ register int width;
+ register int height;
+
+ width = x2 - x1;
+ height = y2 - y1;
+
+ if ((width <= 0) || (height <= 0)) {
+#ifdef DEBUG
+ printf("x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
+#endif
+ return (0);
+ }
+
+ if (!efb_wait_fifo(5))
+ return (0);
+
+ 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, fg);
+ 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));
+
+ return (1);
}
-void
-efb_flush_pixel_cache(struct efb_info *pEFB)
+int
+efb_draw_solid_line(
+ register uint_t const x1,
+ register uint_t const y1,
+ register uint_t const x2,
+ register uint_t const y2,
+ register uint_t const fg)
{
- int i ;
+ if (!efb_wait_fifo(5))
+ return (0);
+
+ REGW(RADEON_DP_WRITE_MASK, 0xffffffff);
+ REGW(RADEON_DP_CNTL,
+ (RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM));
- // initiate flush
- REGW(RADEON_RB2D_DSTCACHE_CTLSTAT, REGR(RADEON_RB2D_DSTCACHE_CTLSTAT) | 0xf);
+ REGW(RADEON_DP_BRUSH_FRGD_CLR, fg);
+ 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));
+
+ return (1);
+} /* line() */
- // check for completion but limit looping to 16384 reads
- i = 16384;
- while((REGR(RADEON_RB2D_DSTCACHE_CTLSTAT) & RADEON_RB2D_DC_BUSY) == RADEON_RB2D_DC_BUSY &&
- --i >= 0 ) ;
+int
+efb_flush_pixel_cache(
+ void)
+{
+ register int i;
+
+ /* initiate flush */
+ REGW(RADEON_RB2D_DSTCACHE_CTLSTAT,
+ REGR(RADEON_RB2D_DSTCACHE_CTLSTAT) | 0xf);
+
+ /* check for completion but limit looping to 16384 reads */
+ for (i = 16384; i > 0; i--) {
+ if ((REGR(RADEON_RB2D_DSTCACHE_CTLSTAT) &
+ (uint_t)RADEON_RB2D_DC_BUSY) != (uint_t)RADEON_RB2D_DC_BUSY)
+ break;
+ }
+ return ((REGR(RADEON_RB2D_DSTCACHE_CTLSTAT) &
+ (uint_t)RADEON_RB2D_DC_BUSY) != (uint_t)RADEON_RB2D_DC_BUSY);
}
-void
-efb_reset_engine (struct efb_info *pEFB)
+void
+efb_reset_engine(
+ void)
{
- uint32_t save_genresetcntl, save_clockcntlindex, save_mclkcntl;
- long term_count;
+ register uint_t save_genresetcntl;
+ register uint_t save_clockcntlindex;
+ static ulong_t term_count;
- efb_flush_pixel_cache(pEFB) ;
+ efb_flush_pixel_cache();
save_clockcntlindex = REGR(RADEON_CLOCK_CNTL_INDEX);
- // save GEN_RESET_CNTL register
+ /* save GEN_RESET_CNTL register */
save_genresetcntl = REGR(RADEON_DISP_MISC_CNTL);
- // reset by setting bit, add read delay, then clear bit,
- // add read delay
+ /* reset by setting bit, add read delay, then clear bit, */
+ /* add read delay */
REGW(RADEON_DISP_MISC_CNTL, save_genresetcntl |
- RADEON_DISP_MISC_CNTL__SOFT_RESET_GRPH_PP);
+ RADEON_DISP_MISC_CNTL__SOFT_RESET_GRPH_PP);
REGR(RADEON_DISP_MISC_CNTL);
REGW(RADEON_DISP_MISC_CNTL, save_genresetcntl &
- ~(RADEON_DISP_MISC_CNTL__SOFT_RESET_GRPH_PP));
+ ~(RADEON_DISP_MISC_CNTL__SOFT_RESET_GRPH_PP));
REGR(RADEON_DISP_MISC_CNTL);
- // restore the two registers we changed
+ /* restore the two registers we changed */
REGW(RADEON_CLOCK_CNTL_INDEX, save_clockcntlindex);
REGW(RADEON_DISP_MISC_CNTL, save_genresetcntl);
- term_count++; // for monitoring engine hangs
-}
-
-void
-efb_wait_for_fifo(struct efb_info *pEFB, int c)
-{
- uint32_t i;
- long limit;
-
- /* First a short loop, just in case fifo clears out quickly */
- for(limit=100; (REGR(RBBM_STATUS) & MASK) < c && --limit > 0; ) ;
-
- if((REGR(RBBM_STATUS) & MASK) < c ) {
- hrtime_t timeout = gethrtime() + (hrtime_t)3000000000;
- while((REGR(RBBM_STATUS) & MASK) < c &&
- gethrtime() < timeout )
- yield();
-
- if((REGR(RBBM_STATUS) & MASK) < c )
- efb_reset_engine(pEFB) ;
- }
+ term_count++; /* for monitoring engine hangs */
}
-void
-efb_wait_for_idle(struct efb_info *pEFB)
+int
+efb_wait_fifo(
+ register int const c)
{
- uint32_t i;
- long limit;
+ register int limit;
+ register hrtime_t timeout;
- efb_wait_for_fifo(pEFB, 64) ;
-
- for(limit=10000; (REGR(RBBM_STATUS) & GUI_ACTIVE) && --limit > 0; ) ;
+ /* First a short loop, just in case fifo clears out quickly */
+ for (limit = 100; limit >= 0; limit--) {
+ if ((REGR(RBBM_STATUS) &
+ RBBM_STATUS__CMDFIFO_AVAIL_MASK) >= c)
+ break;
+ }
- if( REGR(RBBM_STATUS) & GUI_ACTIVE ) {
- hrtime_t timeout = gethrtime() + (hrtime_t)3000000000;
- while( (REGR(RBBM_STATUS) & GUI_ACTIVE) &&
- gethrtime() < timeout )
- yield();
-
- if( (REGR(RBBM_STATUS) & GUI_ACTIVE) != 0 )
- efb_reset_engine(pEFB) ;
+ if ((REGR(RBBM_STATUS) & RBBM_STATUS__CMDFIFO_AVAIL_MASK) < c) {
+ timeout = gethrtime() + 3 * (hrtime_t)1000000000;
+ while (gethrtime() < timeout) {
+ if ((REGR(RBBM_STATUS) &
+ RBBM_STATUS__CMDFIFO_AVAIL_MASK) >= c)
+ break;
+ yield();
+ }
+ if ((REGR(RBBM_STATUS) &
+ RBBM_STATUS__CMDFIFO_AVAIL_MASK) < c)
+ efb_reset_engine();
}
+ return ((REGR(RBBM_STATUS) &
+ RBBM_STATUS__CMDFIFO_AVAIL_MASK) >= c);
}
+int
+efb_wait_idle(
+ void)
+{
+ register int limit;
+ register hrtime_t timeout;
+ efb_wait_fifo(64);
+
+ for (limit = 10000; limit > 0; limit--) {
+ if (!(REGR(RBBM_STATUS) & GUI_ACTIVE))
+ break;
+ }
+
+ if (REGR(RBBM_STATUS) & GUI_ACTIVE) {
+ timeout = gethrtime() + 3 * (hrtime_t)1000000000;
+ while (gethrtime() < timeout) {
+ if (!(REGR(RBBM_STATUS) & GUI_ACTIVE))
+ break;
+ yield();
+ }
+
+ if ((REGR(RBBM_STATUS) & GUI_ACTIVE) != 0)
+ efb_reset_engine();
+ }
+ return ((REGR(RBBM_STATUS) & GUI_ACTIVE) == 0);
+}