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"
1385N/A
1385N/A
1385N/A/*
1385N/A * ast_test_open()
1385N/A *
1385N/A * This test will open the device, read and write some registers
1385N/A * after mmaping in the register and frame buffer spaces.
1385N/A */
1385N/A
1385N/Areturn_packet *
1385N/Aast_test_open(
1385N/A register int const fd)
1385N/A{
1385N/A static return_packet rp;
1385N/A int rc = 0;
1385N/A struct vis_identifier vis_identifier;
1385N/A
1385N/A memset(&rp, 0, sizeof (return_packet));
1385N/A
1385N/A if (gfx_vts_check_fd(fd, &rp))
1385N/A return (&rp);
1385N/A
1385N/A TraceMessage(VTS_TEST_STATUS, "ast_test_open", "check_fd passed.\n");
1385N/A
1385N/A /* vis identifier will do this */
1385N/A rc = ioctl(fd, VIS_GETIDENTIFIER, &vis_identifier);
1117N/A
1385N/A TraceMessage(VTS_TEST_STATUS, "ast_test_open", "rc = %d\n", rc);
1385N/A
1385N/A if (rc != 0) {
1385N/A gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
1385N/A return (&rp);
1385N/A }
1385N/A
1385N/A if (strncmp(vis_identifier.name, "SUNWast", 7) != 0 &&
1385N/A strncmp(vis_identifier.name, "ORCLast", 7) != 0) {
1385N/A gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
1385N/A return (&rp);
1385N/A }
1117N/A
1385N/A ast_block_signals();
1385N/A
1385N/A ast_lock_display();
1385N/A
1385N/A map_me(&rp, fd);
1385N/A
1385N/A ast_unlock_display();
1385N/A
1385N/A ast_restore_signals();
1385N/A
1385N/A TraceMessage(VTS_DEBUG, "ast_test_open", "Open completed OK\n");
1385N/A
1385N/A return (&rp);
1385N/A
1385N/A} /* ast_test_open() */
1117N/A
1117N/A
1117N/A/*
1117N/A * map_me()
1117N/A */
1117N/A
1385N/Aint
1385N/Amap_me(
1385N/A register return_packet *const rp,
1385N/A register int const fd)
1117N/A{
1117N/A unsigned int value, chipType;
1117N/A
1385N/A memset(&ast_info, 0, sizeof (ast_info));
1385N/A ast_info.ast_fd = fd;
1117N/A
1117N/A /*
1117N/A * map the registers & frame buffers memory
1117N/A */
1385N/A if (ast_map_mem(rp, GRAPHICS_ERR_OPEN) != 0)
1385N/A return (-1);
1117N/A
1385N/A if (ast_test_scratch(rp, GRAPHICS_ERR_OPEN) != 0) {
1385N/A ast_unmap_mem(NULL, GRAPHICS_ERR_OPEN);
1385N/A return (-1);
1117N/A }
1385N/A value = ast_mmio_read32(0x1207c);
1385N/A chipType = value & 0x0300;
1385N/A TraceMessage(VTS_DEBUG, "ast_test_chip",
1385N/A "chip type 0x%x\n", chipType);
1117N/A
1117N/A /*
1117N/A * Unmap the registers & frame buffers memory
1117N/A */
1385N/A if (ast_unmap_mem(rp, GRAPHICS_ERR_OPEN) != 0)
1385N/A return (-1);
1117N/A
1385N/A return (0);
1117N/A} /* map_me() */
1117N/A
1117N/A
1385N/Aint
1385N/Aast_test_scratch(
1385N/A register return_packet *const rp,
1385N/A register int const test)
1385N/A{
1385N/A uchar_t scratch;
1385N/A uchar_t newscratch;
1385N/A
1385N/A if (ast_get_index_reg(&scratch, CRTC_PORT, 0x90) != 0) {
1385N/A gfx_vts_set_message(rp, 1, test, "unable to get scratch");
1385N/A return (-1);
1385N/A }
1385N/A
1385N/A if (ast_set_index_reg(CRTC_PORT, 0x90, scratch ^ 0x33) != 0) {
1385N/A gfx_vts_set_message(rp, 1, test, "unable to set scratch");
1385N/A return (-1);
1385N/A }
1385N/A
1385N/A if (ast_get_index_reg(&newscratch, CRTC_PORT, 0x90) != 0) {
1385N/A gfx_vts_set_message(rp, 1, test, "unable to get newscratch");
1385N/A return (-1);
1385N/A }
1385N/A
1385N/A if ((scratch ^ 0x33) != newscratch) {
1385N/A gfx_vts_set_message(rp, 1, test, "scratch mismatch");
1385N/A return (-1);
1385N/A }
1385N/A
1385N/A if (ast_set_index_reg(CRTC_PORT, 0x90, scratch) != 0) {
1385N/A gfx_vts_set_message(rp, 1, test, "unable to set scratch");
1385N/A return (-1);
1385N/A }
1385N/A
1385N/A return (1);
1385N/A}
1385N/A
1385N/A
1117N/A/* End of mapper.c */