chip.c revision 1368
1117N/A/*
1368N/A * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice (including the next
1117N/A * paragraph) shall be included in all copies or substantial portions of the
1117N/A * Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1117N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1117N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1117N/A * DEALINGS IN THE SOFTWARE.
1117N/A */
1117N/A
1368N/A#include "libvtsSUNWefb.h"
1117N/A
1368N/A/*
1368N/A * efb_test_chip()
1368N/A *
1368N/A * Test Chip, functional tests.
1368N/A */
1117N/A
1368N/Areturn_packet *
1368N/Aefb_test_chip(
1368N/A register int const fd)
1368N/A{
1368N/A static return_packet rp;
1117N/A
1368N/A memset(&rp, 0, sizeof (return_packet));
1117N/A
1368N/A if (gfx_vts_debug_mask & GRAPHICS_VTS_CHIP_OFF)
1368N/A return (&rp);
1117N/A
1368N/A TraceMessage(VTS_DEBUG, "efb_test_chip", "efb_test_chip running\n");
1117N/A
1368N/A efb_block_signals();
1117N/A
1368N/A efb_lock_display();
1117N/A
1368N/A chip_test(&rp, fd);
1117N/A
1368N/A efb_unlock_display();
1117N/A
1368N/A efb_restore_signals();
1117N/A
1368N/A TraceMessage(VTS_DEBUG, "efb_test_chip", "efb_test_chip completed\n");
1117N/A
1368N/A return (&rp);
1117N/A
1368N/A} /* efb_test_chip() */
1117N/A
1117N/A
1368N/Aint
1368N/Achip_test(
1368N/A register return_packet *const rp,
1368N/A register int const fd)
1368N/A{
1368N/A register uint_t black;
1368N/A register uint_t white;
1117N/A
1368N/A memset(&efb_info, 0, sizeof (efb_info));
1368N/A efb_info.efb_fd = fd;
1117N/A
1368N/A /*
1368N/A * map the registers & frame buffers memory
1368N/A */
1368N/A if (efb_map_mem(rp, GRAPHICS_ERR_CHIP) != 0)
1368N/A return (-1);
1117N/A
1368N/A if (efb_init_info(rp, GRAPHICS_ERR_CHIP) != 0) {
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1117N/A }
1117N/A
1368N/A if (!efb_init_graphics()) {
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1117N/A }
1117N/A
1368N/A efb_save_palet();
1368N/A efb_set_palet();
1117N/A
1368N/A /*
1368N/A * Clear screen black
1117N/A */
1368N/A black = efb_color(0x00, 0x00, 0x00);
1368N/A if (!efb_fill_solid_rect(0, 0,
1368N/A efb_info.efb_width, efb_info.efb_height, black)) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1368N/A }
1368N/A
1368N/A if (!efb_wait_idle()) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1368N/A }
1368N/A
1368N/A efb_flush_pixel_cache();
1117N/A
1117N/A /*
1117N/A * line test
1117N/A */
1368N/A if (!draw_lines(efb_info.efb_width, efb_info.efb_height)) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1368N/A }
1368N/A
1368N/A if (!efb_wait_idle()) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1368N/A }
1368N/A
1368N/A efb_flush_pixel_cache();
1368N/A
1368N/A if (efb_sleep(2)) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1368N/A }
1117N/A
1117N/A /*
1368N/A * fill rectangle test
1117N/A */
1368N/A if (!draw_cascaded_box(efb_info.efb_width, efb_info.efb_height)) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1368N/A }
1117N/A
1368N/A if (!efb_wait_idle()) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1368N/A }
1117N/A
1368N/A efb_flush_pixel_cache();
1117N/A
1368N/A if (efb_sleep(2)) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1117N/A }
1117N/A
1368N/A /* Clear screen white */
1368N/A
1368N/A white = efb_color(0xff, 0xff, 0xff);
1368N/A
1368N/A /*
1368N/A * Clear screen
1368N/A */
1368N/A if (!efb_fill_solid_rect(0, 0,
1368N/A efb_info.efb_width, efb_info.efb_height, white)) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1368N/A }
1368N/A
1368N/A if (!efb_wait_idle()) {
1368N/A efb_restore_palet();
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1368N/A return (-1);
1368N/A }
1368N/A
1368N/A efb_flush_pixel_cache();
1368N/A
1368N/A efb_sleep(2);
1368N/A
1368N/A efb_restore_palet();
1368N/A
1368N/A if (efb_unmap_mem(rp, GRAPHICS_ERR_CHIP) != 0)
1368N/A return (-1);
1368N/A
1368N/A return (0);
1117N/A} /* chip_test() */
1117N/A
1117N/A
1368N/Aint
1368N/Adraw_lines(
1368N/A register uint_t const width,
1368N/A register uint_t const height)
1368N/A{
1368N/A register uint_t x1;
1368N/A register uint_t y1;
1368N/A register uint_t x2;
1368N/A register uint_t y2;
1368N/A register uint_t color;
1368N/A register uint_t lineon;
1368N/A register uint_t const numlines = 128;
1368N/A
1368N/A for (lineon = 0; lineon < numlines; lineon++) {
1368N/A color = efb_color(0xaf, lineon, lineon);
1368N/A
1368N/A x1 = (uint_t)((width * lineon) / numlines);
1368N/A x2 = x1;
1368N/A y1 = 0;
1368N/A y2 = height;
1368N/A
1368N/A if (!efb_draw_solid_line(x1, y1, x2, y2, color))
1368N/A return (0);
1368N/A }
1368N/A
1368N/A for (lineon = 0; lineon < numlines; lineon++) {
1368N/A color = efb_color(0xaf, lineon, lineon);
1368N/A
1368N/A x1 = 0;
1368N/A x2 = width;
1368N/A y1 = (uint_t)((height * lineon) / numlines);
1368N/A y2 = y1;
1368N/A
1368N/A if (!efb_draw_solid_line(x1, y1, x2, y2, color))
1368N/A return (0);
1368N/A }
1368N/A return (1);
1368N/A}
1368N/A
1368N/Aint
1368N/Adraw_cascaded_box(
1368N/A register uint_t const width,
1368N/A register uint_t const height)
1368N/A{
1368N/A register uint_t x1;
1368N/A register uint_t y1;
1368N/A register uint_t x2;
1368N/A register uint_t y2;
1368N/A register uint_t color;
1368N/A register uint_t recton;
1368N/A register uint_t const numrects = 256;
1368N/A
1368N/A for (recton = 0; recton < numrects; recton++) {
1368N/A
1368N/A x1 = (uint_t)((width * recton) / 512);
1368N/A x2 = width - x1;
1368N/A
1368N/A y1 = (uint_t)((height * recton) / 512);
1368N/A y2 = height - y1;
1368N/A
1368N/A color = efb_color(recton, recton, recton);
1368N/A
1368N/A if (!efb_fill_solid_rect(x1, y1, x2, y2, color))
1368N/A return (0);
1368N/A }
1368N/A
1368N/A return (1);
1368N/A}
1368N/A
1117N/A/* End of chip.c */