2009-09-06 13:44:18 -06:00
|
|
|
|
/* $OpenBSD: wsfb.c,v 1.6 2009/09/06 19:44:25 matthieu Exp $ */
|
2007-05-25 09:33:32 -06:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2007 Matthieu Herrb <matthieu@openbsd.org>
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|
2007-05-29 14:14:43 -06:00
|
|
|
|
/* Copyright <20> 1999 Keith Packard
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
|
* the above copyright notice appear in all copies and that both that
|
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
|
* documentation, and that the name of Keith Packard not be used in
|
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
|
* specific, written prior permission. Keith Packard makes no
|
|
|
|
|
* representations about the suitability of this software for any purpose. It
|
|
|
|
|
* is provided "as is" without express or implied warranty.
|
|
|
|
|
*
|
|
|
|
|
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
|
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|
2007-05-25 09:33:32 -06:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <kdrive-config.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <dev/wscons/wsconsio.h>
|
2007-12-23 07:28:10 -07:00
|
|
|
|
#include <sys/ioctl.h>
|
2007-05-26 18:56:29 -06:00
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
#include <errno.h>
|
2007-05-25 09:33:32 -06:00
|
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
|
#include <X11/Xdefs.h>
|
|
|
|
|
|
|
|
|
|
#include "wsfb.h"
|
|
|
|
|
|
2007-05-26 18:56:29 -06:00
|
|
|
|
#define DEBUG 1
|
2007-05-25 13:10:43 -06:00
|
|
|
|
#define DBG(x) ErrorF x
|
|
|
|
|
|
2007-05-26 18:56:29 -06:00
|
|
|
|
extern int WsconsConsoleFd;
|
|
|
|
|
|
|
|
|
|
/* Map the framebuffer's memory */
|
|
|
|
|
static void *
|
|
|
|
|
wsfbMmap(size_t len, off_t off, int fd)
|
|
|
|
|
{
|
|
|
|
|
int pagemask, mapsize;
|
|
|
|
|
caddr_t addr;
|
|
|
|
|
pointer mapaddr;
|
|
|
|
|
|
|
|
|
|
pagemask = getpagesize() - 1;
|
|
|
|
|
mapsize = ((int) len + pagemask) & ~pagemask;
|
|
|
|
|
addr = 0;
|
|
|
|
|
|
|
|
|
|
mapaddr = (pointer) mmap(addr, mapsize,
|
|
|
|
|
PROT_READ | PROT_WRITE, MAP_SHARED,
|
|
|
|
|
fd, off);
|
|
|
|
|
if (mapaddr == (pointer) -1) {
|
|
|
|
|
mapaddr = NULL;
|
|
|
|
|
}
|
|
|
|
|
#if DEBUG
|
|
|
|
|
ErrorF("mmap returns: addr %p len 0x%x\n", mapaddr, mapsize);
|
|
|
|
|
#endif
|
|
|
|
|
return mapaddr;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-25 09:33:32 -06:00
|
|
|
|
Bool
|
2007-05-26 18:56:29 -06:00
|
|
|
|
wsfbMapFramebuffer(KdScreenInfo *screen)
|
|
|
|
|
{
|
|
|
|
|
WsfbScrPriv *scrPriv = screen->driver;
|
2007-12-23 07:28:10 -07:00
|
|
|
|
KdPointerMatrix m;
|
2007-05-26 18:56:29 -06:00
|
|
|
|
WsfbPriv *priv = screen->card->driver;
|
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
|
|
DBG(("wsfbMapFrameBuffer\n"));
|
2007-05-29 14:14:43 -06:00
|
|
|
|
|
|
|
|
|
if (scrPriv->mapped)
|
|
|
|
|
return TRUE;
|
2007-05-26 18:56:29 -06:00
|
|
|
|
if (scrPriv->randr != RR_Rotate_0)
|
|
|
|
|
scrPriv->shadow = TRUE;
|
|
|
|
|
else
|
|
|
|
|
scrPriv->shadow = FALSE;
|
|
|
|
|
|
2007-12-23 07:28:10 -07:00
|
|
|
|
KdComputePointerMatrix(&m, scrPriv->randr,
|
2007-05-26 18:56:29 -06:00
|
|
|
|
screen->width, screen->height);
|
2007-12-23 07:28:10 -07:00
|
|
|
|
KdSetPointerMatrix(&m);
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
|
|
|
|
DBG(("screen->width %d\n", screen->width));
|
|
|
|
|
DBG(("screen->height %d\n", screen->height));
|
|
|
|
|
len = priv->linebytes * screen->height;
|
|
|
|
|
priv->fb = wsfbMmap(len, 0, WsconsConsoleFd);
|
2007-05-29 14:14:43 -06:00
|
|
|
|
if (priv->fb == NULL)
|
|
|
|
|
FatalError("Can't mmap framebuffer\n");
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
|
|
|
|
screen->memory_base = (CARD8 *)(priv->fb);
|
|
|
|
|
screen->memory_size = len;
|
|
|
|
|
|
|
|
|
|
if (scrPriv->shadow) {
|
|
|
|
|
if (!KdShadowFbAlloc(screen, 0,
|
|
|
|
|
scrPriv->randr & (RR_Rotate_90|RR_Rotate_270)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
screen->off_screen_base = screen->memory_size;
|
|
|
|
|
} else {
|
|
|
|
|
screen->fb[0].byteStride = priv->linebytes;
|
|
|
|
|
screen->fb[0].pixelStride = priv->linebytes * 8 / priv->bpp;
|
|
|
|
|
screen->fb[0].frameBuffer = (CARD8 *)(priv->fb);
|
|
|
|
|
screen->off_screen_base =
|
|
|
|
|
screen->fb[0].byteStride * screen->height;
|
|
|
|
|
}
|
2007-05-29 14:14:43 -06:00
|
|
|
|
scrPriv->mapped = TRUE;
|
2007-05-26 18:56:29 -06:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
2007-05-25 09:33:32 -06:00
|
|
|
|
wsfbInitialize(KdCardInfo *card, WsfbPriv *priv)
|
|
|
|
|
{
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbInitialize\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
if (WsconsConsoleFd == -1) {
|
|
|
|
|
ErrorF("wsfbInitialize: WsconsConsoleFd == -1\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (ioctl(WsconsConsoleFd, WSDISPLAYIO_GTYPE, &priv->wstype) == -1) {
|
|
|
|
|
ErrorF("wsfbInitialize: WSDISPLAY_GTYPE: %s\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (ioctl(WsconsConsoleFd, WSDISPLAYIO_GETSUPPORTEDDEPTH,
|
|
|
|
|
&priv->supportedDepths) == -1) {
|
|
|
|
|
ErrorF("wsfbInitialize: WSDISPLAYIO_GETSUPPORTEDDEPTH: %s\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-25 09:33:32 -06:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbCardInit(KdCardInfo *card)
|
|
|
|
|
{
|
|
|
|
|
WsfbPriv *priv;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbCardInit\n"));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
priv = (WsfbPriv *)xalloc(sizeof(WsfbPriv));
|
|
|
|
|
if (priv == NULL)
|
|
|
|
|
return FALSE;
|
2007-05-26 18:56:29 -06:00
|
|
|
|
bzero(priv, sizeof(WsfbPriv));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
if (!wsfbInitialize(card, priv)) {
|
|
|
|
|
xfree(priv);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
card->driver = priv;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-26 18:56:29 -06:00
|
|
|
|
static Bool
|
2007-05-25 09:33:32 -06:00
|
|
|
|
wsfbScreenInitialize(KdScreenInfo *screen, WsfbScrPriv *scrpriv)
|
|
|
|
|
{
|
2007-05-26 18:56:29 -06:00
|
|
|
|
struct wsdisplay_gfx_mode gfxmode;
|
|
|
|
|
WsfbPriv *priv;
|
2007-12-23 07:28:10 -07:00
|
|
|
|
int depth = 24;
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
|
|
|
|
priv = screen->card->driver;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbScreenInitialize\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
DBG((" screen dimensions %dx%d\n", screen->width, screen->height));
|
|
|
|
|
DBG((" screen depth %d\n", screen->fb[0].depth));
|
|
|
|
|
DBG((" randr %d\n", screen->randr));
|
|
|
|
|
if (screen->width == 0 || screen->height == 0) {
|
|
|
|
|
ErrorF("wsfbScreenInitialize: forcing 640x480\n");
|
|
|
|
|
screen->width = 640;
|
|
|
|
|
screen->height = 480;
|
|
|
|
|
}
|
|
|
|
|
if (screen->fb[0].depth == 0) {
|
|
|
|
|
ErrorF("wsfbScreenInitialize: forcing depth 16\n");
|
|
|
|
|
depth = screen->fb[0].depth = 16;
|
|
|
|
|
}
|
|
|
|
|
DBG((" wstype: %d\n", priv->wstype));
|
|
|
|
|
if (priv->wstype == WSDISPLAY_TYPE_PCIVGA) {
|
|
|
|
|
gfxmode.depth = screen->fb[0].depth;
|
|
|
|
|
gfxmode.width = screen->width;
|
|
|
|
|
gfxmode.height = screen->height;
|
|
|
|
|
if (ioctl(WsconsConsoleFd, WSDISPLAYIO_SETGFXMODE,
|
|
|
|
|
&gfxmode) == -1) {
|
|
|
|
|
ErrorF("wsfbScreenInitialize: "
|
|
|
|
|
"WSDISPLAYIO_SETGFXMODE: %s\n", strerror(errno));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ioctl(WsconsConsoleFd, WSDISPLAYIO_GINFO, &priv->info) == -1) {
|
|
|
|
|
ErrorF("wsfbInitialize: WSDISPLAY_GINFO: %s\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (ioctl(WsconsConsoleFd, WSDISPLAYIO_LINEBYTES,
|
|
|
|
|
&priv->linebytes) == -1) {
|
|
|
|
|
ErrorF("wsfbInitialize: WSDISPLAYIO_LINEBYTES: %s\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
switch (depth) {
|
|
|
|
|
case 16:
|
|
|
|
|
screen->fb[0].visuals = (1 << TrueColor);
|
|
|
|
|
screen->fb[0].redMask = 0x1f << 11;
|
|
|
|
|
screen->fb[0].greenMask = 0x3f << 5;
|
|
|
|
|
screen->fb[0].blueMask = 0x1f;
|
|
|
|
|
break;
|
|
|
|
|
case 24:
|
|
|
|
|
screen->fb[0].visuals = (1 << TrueColor);
|
|
|
|
|
screen->fb[0].redMask = 0xff0000;
|
|
|
|
|
screen->fb[0].greenMask = 0x00ff00;
|
|
|
|
|
screen->fb[0].blueMask = 0x0000ff;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
screen->fb[0].redMask = 0;
|
|
|
|
|
screen->fb[0].greenMask = 0;
|
|
|
|
|
screen->fb[0].blueMask = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
screen->fb[0].bitsPerPixel = depth;
|
|
|
|
|
priv->bpp = depth; /* XXX */
|
|
|
|
|
screen->dumb = TRUE;
|
|
|
|
|
screen->rate = 72;
|
|
|
|
|
scrpriv->randr = screen->randr;
|
|
|
|
|
DBG(("wsfbScreenInitialize: done\n"));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbScreenInit(KdScreenInfo *screen)
|
|
|
|
|
{
|
|
|
|
|
WsfbScrPriv *scrPriv;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbScreenInit\n"));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
scrPriv = (WsfbScrPriv *)xalloc(sizeof(WsfbScrPriv));
|
|
|
|
|
if (scrPriv == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
bzero(scrPriv, sizeof(WsfbScrPriv));
|
|
|
|
|
screen->driver = scrPriv;
|
|
|
|
|
if (!wsfbScreenInitialize(screen, scrPriv)) {
|
2007-05-26 18:56:29 -06:00
|
|
|
|
ErrorF("wsfbScreenInitialize: failed to initialize screen\n");
|
2007-05-25 09:33:32 -06:00
|
|
|
|
screen->driver = NULL;
|
|
|
|
|
xfree(scrPriv);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbInitScreen(ScreenPtr pScreen)
|
|
|
|
|
{
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbInitScreen\n"));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
pScreen->CreateColormap = wsfbCreateColormap;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbFinishInitScreen(ScreenPtr pScreen)
|
|
|
|
|
{
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbFinishInitScreen\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
2007-05-25 09:33:32 -06:00
|
|
|
|
if (!shadowSetup(pScreen))
|
|
|
|
|
return FALSE;
|
|
|
|
|
#ifdef RANDR
|
|
|
|
|
if (!wsfbRandRInit(pScreen))
|
|
|
|
|
return FALSE;
|
|
|
|
|
#endif
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbCreateResources(ScreenPtr pScreen)
|
|
|
|
|
{
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbCreateResources\n"));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
return wsfbSetShadow(pScreen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
wsfbPreserve(KdCardInfo *card)
|
|
|
|
|
{
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbPreserve\n"));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbEnable(ScreenPtr pScreen)
|
|
|
|
|
{
|
2007-05-26 18:56:29 -06:00
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdScreenInfo *screen = pScreenPriv->screen;
|
|
|
|
|
int wsmode = WSDISPLAYIO_MODE_DUMBFB;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbEnable\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
/* Switch to graphics mode - required before mmap */
|
|
|
|
|
if (ioctl(WsconsConsoleFd, WSDISPLAYIO_SMODE, &wsmode) == -1) {
|
|
|
|
|
ErrorF("ioctl WSDISPLAYIO_SMODE: %s\n", strerror(errno));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (!wsfbMapFramebuffer(screen)) {
|
|
|
|
|
ErrorF("wsfbEnale: can't map framebuffer\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2007-05-29 14:14:43 -06:00
|
|
|
|
(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
|
|
|
|
|
pScreen->width,
|
|
|
|
|
pScreen->height,
|
|
|
|
|
screen->fb[0].depth,
|
|
|
|
|
screen->fb[0].bitsPerPixel,
|
|
|
|
|
screen->fb[0].byteStride,
|
|
|
|
|
screen->fb[0].frameBuffer);
|
2007-05-26 18:56:29 -06:00
|
|
|
|
DBG(("wsfbEnable done.\n"));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbDPMS(ScreenPtr pScreen, int mode)
|
|
|
|
|
{
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfb DPMS %d\n", mode));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
wsfbDisable(ScreenPtr pScreen)
|
|
|
|
|
{
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbDisable\n"));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
wsfbRestore(KdCardInfo *card)
|
|
|
|
|
{
|
2007-05-26 18:56:29 -06:00
|
|
|
|
int mode = WSDISPLAYIO_MODE_EMUL;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbRestore\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
|
|
|
|
if (ioctl(WsconsConsoleFd, WSDISPLAYIO_SMODE, &mode) == -1) {
|
|
|
|
|
ErrorF("WSDISPLAYIO_SMODE(EMUL): %s\n", strerror(errno));
|
|
|
|
|
}
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
wsfbScreenFini(KdScreenInfo *screen)
|
|
|
|
|
{
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbScreenFini\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
wsfbUnmapFramebuffer(screen);
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
wsfbCardFini(KdCardInfo *card)
|
|
|
|
|
{
|
|
|
|
|
WsfbPriv *priv = card->driver;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbCardFini\n"));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
/* unmap framebuffer */
|
|
|
|
|
/* close fd */
|
|
|
|
|
xfree(priv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
wsfbGetColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
|
|
|
|
|
{
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbGetColors %d\n", n));
|
2007-05-29 14:14:43 -06:00
|
|
|
|
|
|
|
|
|
while (n--) {
|
|
|
|
|
pdefs->red = 0;
|
|
|
|
|
pdefs->green = 0;
|
|
|
|
|
pdefs->blue = 0;
|
|
|
|
|
pdefs++;
|
|
|
|
|
}
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
wsfbPutColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
|
|
|
|
|
{
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbPutColors %d\n", n));
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *
|
|
|
|
|
wsfbWindowLinear(ScreenPtr pScreen,
|
|
|
|
|
CARD32 row,
|
|
|
|
|
CARD32 offset,
|
|
|
|
|
int mode,
|
|
|
|
|
CARD32 *size,
|
|
|
|
|
void *closure)
|
|
|
|
|
{
|
2007-05-26 18:56:29 -06:00
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
WsfbPriv *priv = pScreenPriv->card->driver;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbWindowLinear\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
|
|
|
|
if (!pScreenPriv->enabled)
|
|
|
|
|
return NULL;
|
|
|
|
|
*size = priv->linebytes;
|
|
|
|
|
return (CARD8 *)priv->fb + row * priv->linebytes + offset;
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
wsfbSetScreenSizes(ScreenPtr pScreen)
|
|
|
|
|
{
|
2007-05-29 14:14:43 -06:00
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdScreenInfo *screen = pScreenPriv->screen;
|
|
|
|
|
WsfbScrPriv *scrpriv = screen->driver;
|
|
|
|
|
WsfbPriv *priv = screen->card->driver;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbSetScreenSizes\n"));
|
2007-05-29 14:14:43 -06:00
|
|
|
|
|
|
|
|
|
if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180)) {
|
|
|
|
|
pScreen->width = priv->info.width;
|
|
|
|
|
pScreen->height = priv->info.height;
|
|
|
|
|
pScreen->mmWidth = screen->width_mm;
|
|
|
|
|
pScreen->mmHeight = screen->height_mm;
|
|
|
|
|
} else {
|
|
|
|
|
pScreen->width = priv->info.height;
|
|
|
|
|
pScreen->height = priv->info.width;
|
|
|
|
|
pScreen->mmWidth = screen->height_mm;
|
|
|
|
|
pScreen->mmHeight = screen->width_mm;
|
|
|
|
|
}
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-29 14:14:43 -06:00
|
|
|
|
void
|
2007-05-25 09:33:32 -06:00
|
|
|
|
wsfbUnmapFramebuffer(KdScreenInfo *screen)
|
|
|
|
|
{
|
2007-05-29 14:14:43 -06:00
|
|
|
|
WsfbScrPriv *scrPriv = screen->driver;
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbUnmapFramebuffer\n"));
|
2007-05-29 14:14:43 -06:00
|
|
|
|
if (!scrPriv->mapped)
|
|
|
|
|
return;
|
2007-05-25 09:33:32 -06:00
|
|
|
|
KdShadowFbFree(screen, 0);
|
2007-05-29 14:14:43 -06:00
|
|
|
|
return;
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbSetShadow(ScreenPtr pScreen)
|
|
|
|
|
{
|
2007-05-26 18:56:29 -06:00
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdScreenInfo *screen = pScreenPriv->screen;
|
|
|
|
|
WsfbScrPriv *scrPriv = screen->driver;
|
|
|
|
|
WsfbPriv *priv = screen->card->driver;
|
|
|
|
|
ShadowUpdateProc update;
|
|
|
|
|
ShadowWindowProc window;
|
|
|
|
|
int useXY = 0;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbSetShadow\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
window = wsfbWindowLinear;
|
|
|
|
|
update = NULL;
|
|
|
|
|
if (scrPriv->randr)
|
|
|
|
|
if (priv->bpp == 16) {
|
|
|
|
|
switch(scrPriv->randr) {
|
|
|
|
|
case RR_Rotate_90:
|
|
|
|
|
if (useXY)
|
|
|
|
|
update = shadowUpdateRotate16_90YX;
|
|
|
|
|
else
|
|
|
|
|
update = shadowUpdateRotate16_90;
|
|
|
|
|
break;
|
|
|
|
|
case RR_Rotate_180:
|
|
|
|
|
update = shadowUpdateRotate16_180;
|
|
|
|
|
break;
|
|
|
|
|
case RR_Rotate_270:
|
|
|
|
|
if (useXY)
|
|
|
|
|
update = shadowUpdateRotate16_270YX;
|
|
|
|
|
else
|
|
|
|
|
update = shadowUpdateRotate16_270;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
update = shadowUpdateRotate16;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
update = shadowUpdateRotatePacked;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
update = shadowUpdateRotatePacked;
|
|
|
|
|
|
|
|
|
|
return KdShadowSet(pScreen, scrPriv->randr, update, window);
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbCreateColormap(ColormapPtr pmap)
|
|
|
|
|
{
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbCreateColormap\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
return fbInitializeColormap(pmap);
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef RANDR
|
|
|
|
|
Bool
|
|
|
|
|
wsfbRandRGetInfo(ScreenPtr pScreen, Rotation *rotations)
|
|
|
|
|
{
|
2007-05-26 18:56:29 -06:00
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdScreenInfo *screen = pScreenPriv->screen;
|
|
|
|
|
WsfbScrPriv *scrPriv = screen->driver;
|
|
|
|
|
RRScreenSizePtr pSize;
|
|
|
|
|
Rotation randr;
|
|
|
|
|
int n;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbRandRGetInfo\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
*rotations = RR_Rotate_All|RR_Reflect_All;
|
|
|
|
|
|
|
|
|
|
for (n = 0; n < pScreen->numDepths; n++)
|
|
|
|
|
if (pScreen->allowedDepths[n].numVids != 0)
|
|
|
|
|
break;
|
|
|
|
|
if (n == pScreen->numDepths)
|
|
|
|
|
return FALSE;
|
|
|
|
|
pSize = RRRegisterSize(pScreen,
|
|
|
|
|
screen->width,
|
|
|
|
|
screen->height,
|
|
|
|
|
screen->width_mm,
|
|
|
|
|
screen->height_mm);
|
|
|
|
|
randr = KdSubRotation(scrPriv->randr, screen->randr);
|
|
|
|
|
RRSetCurrentConfig(pScreen, randr, 0, pSize);
|
|
|
|
|
|
2007-05-25 09:33:32 -06:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbRandRSetConfig(ScreenPtr pScreen,
|
|
|
|
|
Rotation randr,
|
|
|
|
|
int rate,
|
|
|
|
|
RRScreenSizePtr pSize)
|
|
|
|
|
{
|
2007-05-29 14:14:43 -06:00
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdScreenInfo *screen = pScreenPriv->screen;
|
|
|
|
|
WsfbScrPriv *scrpriv = screen->driver;
|
|
|
|
|
Bool wasEnabled = pScreenPriv->enabled;
|
|
|
|
|
WsfbScrPriv oldscr;
|
|
|
|
|
int oldwidth;
|
|
|
|
|
int oldheight;
|
|
|
|
|
int oldmmwidth;
|
|
|
|
|
int oldmmheight;
|
|
|
|
|
int newwidth, newheight;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbRandRSetConfig\n"));
|
2007-05-29 14:14:43 -06:00
|
|
|
|
|
|
|
|
|
if (screen->randr & (RR_Rotate_0|RR_Rotate_180)) {
|
|
|
|
|
newwidth = pSize->width;
|
|
|
|
|
newheight = pSize->height;
|
|
|
|
|
} else {
|
|
|
|
|
newwidth = pSize->height;
|
|
|
|
|
newheight = pSize->width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wasEnabled)
|
|
|
|
|
KdDisableScreen (pScreen);
|
|
|
|
|
|
|
|
|
|
oldscr = *scrpriv;
|
|
|
|
|
|
|
|
|
|
oldwidth = screen->width;
|
|
|
|
|
oldheight = screen->height;
|
|
|
|
|
oldmmwidth = pScreen->mmWidth;
|
|
|
|
|
oldmmheight = pScreen->mmHeight;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Set new configuration
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
scrpriv->randr = KdAddRotation (screen->randr, randr);
|
|
|
|
|
|
|
|
|
|
wsfbUnmapFramebuffer (screen);
|
|
|
|
|
|
|
|
|
|
if (!wsfbMapFramebuffer (screen))
|
|
|
|
|
goto bail4;
|
|
|
|
|
|
|
|
|
|
KdShadowUnset (screen->pScreen);
|
|
|
|
|
|
|
|
|
|
if (!wsfbSetShadow (screen->pScreen))
|
|
|
|
|
goto bail4;
|
|
|
|
|
|
|
|
|
|
wsfbSetScreenSizes (screen->pScreen);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Set frame buffer mapping
|
|
|
|
|
*/
|
|
|
|
|
(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
|
|
|
|
|
pScreen->width,
|
|
|
|
|
pScreen->height,
|
|
|
|
|
screen->fb[0].depth,
|
|
|
|
|
screen->fb[0].bitsPerPixel,
|
|
|
|
|
screen->fb[0].byteStride,
|
|
|
|
|
screen->fb[0].frameBuffer);
|
|
|
|
|
|
|
|
|
|
/* set the subpixel order */
|
|
|
|
|
|
|
|
|
|
KdSetSubpixelOrder (pScreen, scrpriv->randr);
|
|
|
|
|
if (wasEnabled)
|
|
|
|
|
KdEnableScreen (pScreen);
|
|
|
|
|
|
2007-05-25 09:33:32 -06:00
|
|
|
|
return TRUE;
|
2007-05-29 14:14:43 -06:00
|
|
|
|
|
|
|
|
|
bail4:
|
|
|
|
|
wsfbUnmapFramebuffer (screen);
|
|
|
|
|
*scrpriv = oldscr;
|
|
|
|
|
(void) wsfbMapFramebuffer (screen);
|
|
|
|
|
pScreen->width = oldwidth;
|
|
|
|
|
pScreen->height = oldheight;
|
|
|
|
|
pScreen->mmWidth = oldmmwidth;
|
|
|
|
|
pScreen->mmHeight = oldmmheight;
|
|
|
|
|
|
|
|
|
|
if (wasEnabled)
|
|
|
|
|
KdEnableScreen (pScreen);
|
|
|
|
|
return FALSE;
|
2007-05-25 09:33:32 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
wsfbRandRInit(ScreenPtr pScreen)
|
|
|
|
|
{
|
2007-05-26 18:56:29 -06:00
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
|
|
2007-05-25 13:10:43 -06:00
|
|
|
|
DBG(("wsfbRandRInit\n"));
|
2007-05-26 18:56:29 -06:00
|
|
|
|
|
|
|
|
|
if (!RRScreenInit (pScreen))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
|
|
|
|
pScrPriv->rrGetInfo = wsfbRandRGetInfo;
|
|
|
|
|
pScrPriv->rrSetConfig = wsfbRandRSetConfig;
|
2007-05-25 09:33:32 -06:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
#endif /* RANDR */
|