/*
*
* 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,
* 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.
*/
#include "libvtsSUNWmga.h" /* Common VTS library definitions */
#if !defined(_BIG_ENDIAN)
int mga_big_endian = 0;
#else /* defined(_BIG_ENDIAN) */
#endif /* defined(_BIG_ENDIAN) */
int
register return_packet *const rp,
register int const test)
{
if (mga_get_pci_info() != 0) {
return (-1);
}
if (mga_map_fb() != 0) {
return (-1);
}
if (mga_map_control() != 0) {
return (-1);
}
if (mga_map_iload() != 0) {
return (-1);
}
return (0);
}
int
void)
{
&pciconfig) != 0)
return (-1);
if (gfx_vts_debug_mask & VTS_DEBUG) {
printf("mga_vendor = 0x%04x, mga_device = 0x%04x\n",
printf("fb_addr = 0x%08llx, mga_fb_size = 0x%08lx\n",
(unsigned long long) mga_info.mga_fb_addr,
(unsigned long) mga_info.mga_fb_size);
printf("control_addr = 0x%08llx, mga_control_size = 0x%08lx\n",
(unsigned long long) mga_info.mga_control_addr,
(unsigned long) mga_info.mga_control_size);
printf("iload_addr = 0x%08llx, mga_iload_size = 0x%08lx\n",
(unsigned long long) mga_info.mga_iload_addr,
(unsigned long) mga_info.mga_iload_size);
}
return (0);
}
int
void)
{
register void *ptr;
if (ptr == MAP_FAILED)
return (-1);
}
if (gfx_vts_debug_mask & VTS_DEBUG)
printf("mga_fb_ptr = 0x%llx\n",
(unsigned long long) mga_info.mga_fb_ptr);
return (0);
}
int
void)
{
register void *ptr;
if (ptr == MAP_FAILED)
return (-1);
}
if (gfx_vts_debug_mask & VTS_DEBUG)
printf("mga_control_ptr = 0x%llx\n",
(unsigned long long) mga_info.mga_control_ptr);
return (0);
}
int
void)
{
register void *ptr;
if (ptr == MAP_FAILED)
return (-1);
}
if (gfx_vts_debug_mask & VTS_DEBUG)
printf("mga_iload_ptr = 0x%llx\n",
(unsigned long long) mga_info.mga_iload_ptr);
return (0);
}
int
register return_packet *const rp,
register int const test)
{
if (mga_get_fb_size() == 0) {
return (-1);
}
if (mga_get_screen_size() == 0) {
return (-1);
}
return (0);
}
void)
{
break;
}
break;
}
if (gfx_vts_debug_mask & VTS_DEBUG)
return (offset);
}
int
void)
{
register uint8_t m;
register uint8_t n;
register uint8_t p;
/* Get the miscellaneous output register */
/* Save the crtc index. */
/* Get the horizontal total */
/* Get the horizontal display end. */
/* Get the vertical total */
/* Get the vertical display end. */
/* Get the overflow */
/* Get the offset */
/* Restore the crtc index. */
/* Save the crtcext index. */
/* Get the address generator extensions */
/* Get the horizontal counter extensions */
/* Get the vertical counter extensions */
/* Get the miscellaneous register */
/* Restore the crtcext index. */
/* Save the dac index. */
/* Get the multiplex control. */
/* Get the appropriate clock values */
switch (miscout & MGA_MISCOUT_CLKSEL_MASK) {
case MGA_MISCOUT_CLKSEL_25MHZ: /* 0x00 */
/* Get pixpllam register */
m = mgaptr->mga_x_datareg;
/* Get pixpllan register */
n = mgaptr->mga_x_datareg;
/* Get pixpllap register */
p = mgaptr->mga_x_datareg;
break;
case MGA_MISCOUT_CLKSEL_28MHZ: /* 0x04 */
/* Get pixpllbm register */
m = mgaptr->mga_x_datareg;
/* Get pixpllbn register */
n = mgaptr->mga_x_datareg;
/* Get pixpllbp register */
p = mgaptr->mga_x_datareg;
break;
case MGA_MISCOUT_CLKSEL_MGAPIXEL0: /* 0x08 */
case MGA_MISCOUT_CLKSEL_MGAPIXEL1: /* 0x0c */
/* Get pixpllcm register */
m = mgaptr->mga_x_datareg;
/* Get pixpllcn register */
n = mgaptr->mga_x_datareg;
/* Get pixpllcp register */
p = mgaptr->mga_x_datareg;
break;
}
/* Restore the dac index. */
/* Save the gctl index. */
/* Get the graphic mode register. */
/* Get the miscellaneous register */
/* Restore the gctl index. */
/* Compute the width. */
/* Compute the height. */
height++;
height *= 2;
if (!(misc & MGA_CRTCEXT_MISC_MGAMODE)) {
if (!(miscellaneous & MGA_GCTL_MISC_GCGRMODE)) {
depth = 4;
width /= 8;
height /= 16;
pixelsize = 2;
} else {
if (!(graphic_mode & MGA_GCTL_GRMODE_MODE256))
depth = 4;
else
depth = 8;
pixelsize = 1;
}
} else {
/* Compute the depth. */
switch (xmulctrl & MGA_XMULCTRL_DEPTH_MASK) {
case MGA_XMULCTRL_DEPTH_8BPP: /* 0x00 */
depth = 8;
pixelsize = 1;
break;
case MGA_XMULCTRL_DEPTH_15BPP_1BPP_OVERLAY: /* 0x01 */
depth = 15;
pixelsize = 2;
break;
case MGA_XMULCTRL_DEPTH_16BPP: /* 0x02 */
depth = 16;
pixelsize = 2;
break;
case MGA_XMULCTRL_DEPTH_24BPP: /* 0x03 */
depth = 24;
pixelsize = 3;
break;
case MGA_XMULCTRL_DEPTH_32BPP_8BPP_OVERLAY: /* 0x04 */
case MGA_XMULCTRL_DEPTH_32BPP_8BPP_UNUSED: /* 0x07 */
depth = 32;
pixelsize = 4;
break;
default:
return (0);
}
}
(unsigned long long) (n + 1) /
(unsigned long long) ((m & MGA_XPIXPLLM_MASK) + 1) /
(unsigned long long) ((p & MGA_XPIXPLLP_PIXPLLP_MASK) + 1);
htotal = ((horiz_total |
vtotal = (vert_total |
return (1);
}
int
void)
{
/* Save the crtcext index. */
/* Get the miscellaneous register */
/* Restore the crtcext index. */
if (!(misc & MGA_CRTCEXT_MISC_MGAMODE))
return (0);
else
return (1);
}
int
void)
{
if (!mga_wait_fifo(11))
return (0);
case 8:
break;
case 15:
case 16:
if (!*(char const *)&endian) /* big endian */
break;
case 24:
break;
case 32:
if (!*(char const *)&endian) /* big endian */
break;
}
return (1);
}
void
void)
{
mgaptr->mga_palrdadd = 0;
}
}
int
void)
{
case 8: /* 3, 3, 2 */
}
break;
case 15: /* 5, 5, 5 */
}
break;
case 16: /* 5, 6, 5 */
}
break;
default: /* 8, 8, 8 */
}
break;
}
/* Don't set the palet if it matches what we will set. */
break;
}
if (coloron == 256)
return (0);
mgaptr->mga_palwtadd = 0;
}
return (1);
}
int
void)
{
if (!mga_info.mga_palet_changed)
return (0);
mgaptr->mga_palwtadd = 0;
}
return (1);
}
{
case 8: /* 3, 3, 2 */
break;
case 15: /* 5, 5, 5 */
break;
case 16: /* 5, 6, 5 */
break;
default: /* 8, 8, 8 */
break;
}
return (value);
}
void
void)
{
}
int
register int const x1,
register int const y1,
register int const x2,
register int const y2,
{
if (!mga_wait_fifo(5))
return (0);
return (1);
}
int
register int const x1,
register int const y1,
register int const x2,
register int const y2,
{
register int x;
register int y;
register int status;
if (!mga_wait_fifo(11))
return (0);
height - 1);
for (y = 0; y < height; y++) {
value = 0;
for (x = 0; x < width; x++) {
iloadptr++;
else {
iloadon = 0;
}
value = 0;
}
}
}
status = mga_wait_idle();
return (status);
}
int
register int const x1,
register int const y1,
register int const x2,
register int const y2,
{
if (!mga_wait_fifo(5))
return (0);
return (1);
}
int
register int const fifocount)
{
do {
count++;
break;
count++;
}
return (0);
return (1);
}
int
void)
{
do {
count++;
if (fifostatus & MGA_FIFOSTATUS_BEMPTY)
break;
if (!(fifostatus & MGA_FIFOSTATUS_BEMPTY)) {
count++;
}
if (!(fifostatus & MGA_FIFOSTATUS_BEMPTY))
return (0);
return (1);
}
int
register return_packet *const rp,
register int const test)
{
if (mga_unmap_fb() != 0) {
return (-1);
}
if (mga_unmap_control() != 0) {
return (-1);
}
if (mga_unmap_iload() != 0) {
return (-1);
}
return (0);
}
int
void)
{
register int status;
return (0);
return (status);
}
int
void)
{
register int status;
return (0);
return (status);
}
int
void)
{
register int status;
return (0);
return (status);
}
{
if (!mga_big_endian)
return (value);
else
}
void
{
if (!mga_big_endian)
else
}