1117N/A/*
1385N/A * Copyright (c) 2006, 2014, 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
1385N/A#include "libvtsSUNWast.h" /* VTS library definitions for ast device */
1385N/A
1385N/A/*
1385N/A * ast_test_chip()
1385N/A *
1385N/A * Test Chip, functional tests.
1385N/A */
1385N/A
1385N/Areturn_packet *
1385N/Aast_test_chip(
1385N/A register int const fd)
1385N/A{
1385N/A static return_packet rp;
1117N/A
1385N/A memset(&rp, 0, sizeof (return_packet));
1385N/A
1385N/A if (gfx_vts_debug_mask & GRAPHICS_VTS_CHIP_OFF)
1385N/A return (&rp);
1385N/A
1385N/A TraceMessage(VTS_DEBUG, "ast_test_chip",
1385N/A "ast_test_chip running\n");
1385N/A
1385N/A ast_block_signals();
1385N/A
1385N/A ast_lock_display();
1385N/A
1385N/A chip_test(&rp, fd);
1117N/A
1385N/A ast_unlock_display();
1385N/A
1385N/A ast_restore_signals();
1385N/A
1385N/A TraceMessage(VTS_DEBUG, "ast_test_chip",
1385N/A "ast_test_chip completed\n");
1385N/A
1385N/A return (&rp);
1385N/A
1385N/A} /* ast_test_chip() */
1385N/A
1117N/A
1385N/Aint
1385N/Achip_test(
1385N/A register return_packet *const rp,
1385N/A register int const fd)
1385N/A{
1385N/A register uint_t black;
1385N/A register uint_t white;
1385N/A
1385N/A memset(&ast_info, 0, sizeof (ast_info));
1385N/A ast_info.ast_fd = fd;
1385N/A
1385N/A if (ast_map_mem(rp, GRAPHICS_ERR_CHIP) != 0)
1385N/A return (-1);
1385N/A
1385N/A if (ast_init_info(rp, GRAPHICS_ERR_CHIP) != 0) {
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1117N/A }
1117N/A
1385N/A if (ast_init_graphics() < 0) {
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (0);
1385N/A }
1117N/A
1385N/A if (ast_save_palet() < 0) {
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (0);
1385N/A }
1117N/A
1385N/A if (ast_set_palet() < 0) {
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (0);
1385N/A }
1385N/A
1385N/A /* Clear screen black */
1117N/A
1385N/A black = ast_color(0x00, 0x00, 0x00);
1385N/A if (!ast_fill_solid_rect(0, 0,
1385N/A ast_info.ast_width, ast_info.ast_height, black)) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1117N/A }
1117N/A
1385N/A if (!ast_wait_idle()) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1385N/A }
1117N/A
1385N/A /* line test */
1117N/A
1385N/A if (!draw_lines(ast_info.ast_width, ast_info.ast_height)) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1385N/A }
1117N/A
1385N/A if (!ast_wait_idle()) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1385N/A }
1117N/A
1385N/A if (ast_sleep(2)) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1117N/A }
1117N/A
1385N/A /* fill rectangle test */
1117N/A
1385N/A if (!draw_cascaded_box(ast_info.ast_width, ast_info.ast_height)) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1117N/A }
1117N/A
1385N/A if (!ast_wait_idle()) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1385N/A }
1385N/A
1385N/A if (ast_sleep(2)) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1385N/A }
1117N/A
1385N/A /* Clear screen white */
1117N/A
1385N/A white = ast_color(0xff, 0xff, 0xff);
1385N/A if (!ast_fill_solid_rect(0, 0,
1385N/A ast_info.ast_width, ast_info.ast_height, white)) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1385N/A }
1117N/A
1385N/A if (!ast_wait_idle()) {
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
1385N/A return (-1);
1385N/A }
1117N/A
1385N/A ast_sleep(2);
1385N/A
1385N/A ast_restore_palet();
1385N/A ast_finish_graphics();
1117N/A
1117N/A /*
1385N/A * Unmap the registers & frame buffers memory
1117N/A */
1385N/A
1385N/A if (ast_unmap_mem(rp, GRAPHICS_ERR_CHIP) != 0)
1385N/A return (-1);
1117N/A
1385N/A return (0);
1385N/A}
1385N/Aint
1385N/Adraw_lines(
1385N/A register uint_t const width,
1385N/A register uint_t const height)
1385N/A{
1385N/A register uint_t x1;
1385N/A register uint_t y1;
1385N/A register uint_t x2;
1385N/A register uint_t y2;
1385N/A register uint_t color;
1385N/A register uint_t lineon;
1385N/A register uint_t const numlines = 128;
1385N/A
1385N/A for (lineon = 0; lineon < numlines; lineon++) {
1385N/A color = ast_color(0xaf, lineon, lineon);
1385N/A
1385N/A x1 = (uint_t)((width * lineon) / numlines);
1385N/A x2 = x1;
1385N/A y1 = 0;
1385N/A y2 = height;
1385N/A
1385N/A if (!ast_draw_solid_line(x1, y1, x2, y2, color))
1385N/A return (0);
1117N/A }
1117N/A
1385N/A for (lineon = 0; lineon < numlines; lineon++) {
1385N/A color = ast_color(0xaf, lineon, lineon);
1117N/A
1385N/A x1 = 0;
1385N/A x2 = width;
1385N/A y1 = (uint_t)((height * lineon) / numlines);
1385N/A y2 = y1;
1117N/A
1385N/A if (!ast_draw_solid_line(x1, y1, x2, y2, color))
1385N/A return (0);
1385N/A }
1385N/A return (1);
1385N/A}
1117N/A
1385N/Aint
1385N/Adraw_cascaded_box(
1385N/A register uint_t const width,
1385N/A register uint_t const height)
1385N/A{
1385N/A register uint_t x1;
1385N/A register uint_t y1;
1385N/A register uint_t x2;
1385N/A register uint_t y2;
1385N/A register uint_t color;
1385N/A register uint_t recton;
1385N/A register uint_t const numrects = 256;
1117N/A
1385N/A for (recton = 0; recton < numrects; recton++) {
1385N/A
1385N/A x1 = (uint_t)((width * recton) / 512);
1385N/A x2 = width - x1;
1117N/A
1385N/A y1 = (uint_t)((height * recton) / 512);
1385N/A y2 = height - y1;
1117N/A
1385N/A color = ast_color(recton, recton, recton);
1117N/A
1385N/A if (!ast_fill_solid_rect(x1, y1, x2, y2, color))
1385N/A return (0);
1117N/A }
1117N/A
1385N/A return (1);
1385N/A}