tools.c revision 1368
/*
*
* 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 "libvtsSUNWefb.h" /* Common VTS library definitions */
#include "efb.h"
int
register return_packet *const rp,
register int const test)
{
register int const pagesize = getpagesize();
if (efb_get_pci_info() != 0) {
return (-1);
}
/*
* Map MMIO
*/
if (efb_map_mmio() != 0) {
return (-1);
}
switch (efb_info.efb_device) {
case 20825:
case 20830:
case 23396:
break;
default:
break;
}
/*
* Map framebuffer
*/
if (efb_map_fb() != 0) {
return (-1);
}
return (0);
}
int
void)
{
struct gfx_pci_cfg pciconfig;
int i;
int type[6];
&pciconfig) != 0) {
return (-1);
}
for (i = 0; i < 6; i++) {
type[i] = 0;
mem_base[i] = 0;
io_base[i] = 0;
}
for (i = 0; i < 6; i++) {
if (bar != 0) {
if (bar & PCI_MAP_IO) {
} else {
if (PCI_MAP_IS64BITMEM(bar)) {
if (i == 5) {
mem_base[i] = 0;
} else {
mem_base[i] |=
++i;
}
}
}
}
}
efb_info.efb_fb_size = 0;
if (gfx_vts_debug_mask & VTS_DEBUG) {
printf("efb_vendor = 0x%04x, efb_device = 0x%04x\n",
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
void)
{
register void *ptr;
if (ptr == MAP_FAILED)
return (-1);
}
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
void)
{
register void *ptr;
if (ptr == MAP_FAILED)
return (-1);
}
if (gfx_vts_debug_mask & VTS_DEBUG)
printf("efb_fb_ptr = 0x%llx\n",
(unsigned long long)efb_info.efb_fb_ptr);
return (0);
}
int
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;
/* Get the gen cntl */
/* Get the horizontal total display end */
/* Get the vertical total display end */
/* Get the pitch */
/* Compute the width. */
/* Compute the height. */
height *= 2;
/* Compute the pitch */
/* Compute the depth. */
switch ((crtc_gen_cntl & CRTC_GEN_CNTL__CRTC_PIX_WIDTH_MASK) >>
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;
case 5:
depth = 24;
pixelsize = 3;
pitch *= 24;
break;
case 6:
depth = 32;
pixelsize = 4;
pitch *= 32;
break;
default:
return (-1);
}
if (gfx_vts_debug_mask & VTS_DEBUG) {
printf("width=%d height=%d depth=%d pitch=%d\n",
}
return (0);
}
int
register return_packet *const rp,
register int const test)
{
if (efb_unmap_fb() != 0) {
return (-1);
}
if (efb_unmap_mmio() != 0) {
return (-1);
}
return (0);
}
int
void)
{
register int status;
return (0);
return (status);
}
int
void)
{
register int status;
return (0);
return (status);
}
int
efb_init_graphics(void)
{
uint_t v;
case 8:
break;
case 15:
break;
case 16:
break;
case 24:
break;
case 32:
break;
}
(offset / 1024);
/*
* Initialize GUI engine
*/
if (!efb_wait_idle())
return (0);
if (!efb_wait_fifo(5))
return (0);
v = (GMC_SRC_PITCH_OFFSET_DEFAULT |
gmc_bpp |
#ifdef DEBUG
printf("v=0x%x\n", v);
#endif
return (1);
}
void
void)
{
register uint_t const save_palette_index =
REGW(RADEON_PALETTE_INDEX, 0);
}
int
void)
{
register uint_t save_palette_index;
case 8: /* 3, 3, 2 */
(new_red <<
(new_green <<
(new_blue <<
}
break;
case 15: /* 5, 5, 5 */
(new_red <<
(new_green <<
(new_blue <<
}
break;
case 16: /* 5, 6, 5 */
(new_red <<
(new_green <<
(new_blue <<
}
break;
default: /* 8, 8, 8 */
(new_red <<
(new_green <<
(new_blue <<
}
break;
}
/* Don't set the palet if it matches what we will set. */
break;
}
if (coloron == 256)
return (0);
REGW(RADEON_PALETTE_INDEX, 0);
return (1);
}
int
void)
{
register uint_t save_palette_index;
if (!efb_info.efb_palet_changed)
return (0);
REGW(RADEON_PALETTE_INDEX, 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);
}
int
{
register int width;
register int height;
#ifdef DEBUG
#endif
return (0);
}
if (!efb_wait_fifo(5))
return (0);
(y1 << DST_Y_X__DST_Y__SHIFT));
return (1);
}
int
{
if (!efb_wait_fifo(5))
return (0);
(x2 << DST_LINE_END__DST_END_X__SHIFT) |
(y2 << DST_LINE_END__DST_END_Y__SHIFT));
return (1);
} /* line() */
int
void)
{
register int i;
/* initiate flush */
/* check for completion but limit looping to 16384 reads */
for (i = 16384; i > 0; i--) {
if ((REGR(RADEON_RB2D_DSTCACHE_CTLSTAT) &
break;
}
return ((REGR(RADEON_RB2D_DSTCACHE_CTLSTAT) &
}
void
void)
{
register uint_t save_genresetcntl;
register uint_t save_clockcntlindex;
static ulong_t term_count;
/* save GEN_RESET_CNTL register */
/* reset by setting bit, add read delay, then clear bit, */
/* add read delay */
/* restore the two registers we changed */
term_count++; /* for monitoring engine hangs */
}
int
register int const c)
{
register int limit;
/* First a short loop, just in case fifo clears out quickly */
if ((REGR(RBBM_STATUS) &
break;
}
if ((REGR(RBBM_STATUS) &
break;
yield();
}
if ((REGR(RBBM_STATUS) &
}
return ((REGR(RBBM_STATUS) &
RBBM_STATUS__CMDFIFO_AVAIL_MASK) >= c);
}
int
void)
{
register int limit;
efb_wait_fifo(64);
break;
}
break;
yield();
}
}
}