pnozz_driver.c revision 1b41fcf5
1a6b33934Smacallan/* 2a6b33934Smacallan * SBus Weitek P9100 driver 3a6b33934Smacallan * 4a6b33934Smacallan * Copyright (C) 2005, 2006 Michael Lorenz 5a6b33934Smacallan * 6a6b33934Smacallan * Permission is hereby granted, free of charge, to any person obtaining a copy 7a6b33934Smacallan * of this software and associated documentation files (the "Software"), to deal 8a6b33934Smacallan * in the Software without restriction, including without limitation the rights 9a6b33934Smacallan * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10a6b33934Smacallan * copies of the Software, and to permit persons to whom the Software is 11a6b33934Smacallan * furnished to do so, subject to the following conditions: 12a6b33934Smacallan * 13a6b33934Smacallan * The above copyright notice and this permission notice shall be included in 14a6b33934Smacallan * all copies or substantial portions of the Software. 15a6b33934Smacallan * 16a6b33934Smacallan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17a6b33934Smacallan * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18a6b33934Smacallan * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19a6b33934Smacallan * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20a6b33934Smacallan * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21a6b33934Smacallan * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22a6b33934Smacallan */ 231b41fcf5Smrg/* $NetBSD: pnozz_driver.c,v 1.2 2010/11/23 22:21:16 mrg Exp $ */ 24a6b33934Smacallan 25a6b33934Smacallan/* 26a6b33934Smacallan * this driver has been tested on SPARCbook 3GX and 3TX, it supports full 27a6b33934Smacallan * acceleration in 8, 16 and 24 bit colour 28a6b33934Smacallan */ 29a6b33934Smacallan 30a6b33934Smacallan#include <fcntl.h> 31a6b33934Smacallan#include <sys/time.h> 32a6b33934Smacallan#include <sys/types.h> 33a6b33934Smacallan#include <dev/sun/fbio.h> 34a6b33934Smacallan#include <dev/wscons/wsconsio.h> 35a6b33934Smacallan 36a6b33934Smacallan#include "xf86.h" 37a6b33934Smacallan#include "xf86_OSproc.h" 38a6b33934Smacallan 39a6b33934Smacallan#include "xf86Resources.h" 40a6b33934Smacallan#include "xf86sbusBus.h" 41a6b33934Smacallan 42a6b33934Smacallan#include "mipointer.h" 43a6b33934Smacallan#include "mibstore.h" 44a6b33934Smacallan#include "micmap.h" 45a6b33934Smacallan 46a6b33934Smacallan#define DEBUG 0 47a6b33934Smacallan 48a6b33934Smacallan#include "fb.h" 49a6b33934Smacallan#include "xf86cmap.h" 50a6b33934Smacallan#include "pnozz.h" 51a6b33934Smacallan 521b41fcf5Smrg#if HAVE_XORG_SERVER_1_7_0 531b41fcf5Smrg#define xf86LoaderReqSymLists(...) do {} while (0) 541b41fcf5Smrg#define LoaderRefSymLists(...) do {} while (0) 551b41fcf5Smrg#endif 561b41fcf5Smrg 57a6b33934Smacallanstatic const OptionInfoRec * PnozzAvailableOptions(int chipid, int busid); 58a6b33934Smacallanstatic void PnozzIdentify(int flags); 59a6b33934Smacallanstatic Bool PnozzProbe(DriverPtr drv, int flags); 60a6b33934Smacallanstatic Bool PnozzPreInit(ScrnInfoPtr pScrn, int flags); 61a6b33934Smacallanstatic Bool PnozzScreenInit(int Index, ScreenPtr pScreen, int argc, 62a6b33934Smacallan char **argv); 63a6b33934Smacallanstatic Bool PnozzEnterVT(int scrnIndex, int flags); 64a6b33934Smacallanstatic void PnozzLeaveVT(int scrnIndex, int flags); 65a6b33934Smacallanstatic Bool PnozzCloseScreen(int scrnIndex, ScreenPtr pScreen); 66a6b33934Smacallanstatic Bool PnozzSaveScreen(ScreenPtr pScreen, int mode); 67a6b33934Smacallan 68a6b33934Smacallan/* Required if the driver supports mode switching */ 69a6b33934Smacallanstatic Bool PnozzSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); 70a6b33934Smacallan/* Required if the driver supports moving the viewport */ 71a6b33934Smacallanstatic void PnozzAdjustFrame(int scrnIndex, int x, int y, int flags); 72a6b33934Smacallan 73a6b33934Smacallan/* Optional functions */ 74a6b33934Smacallanstatic void PnozzFreeScreen(int scrnIndex, int flags); 75a6b33934Smacallanstatic ModeStatus PnozzValidMode(int scrnIndex, DisplayModePtr mode, 76a6b33934Smacallan Bool verbose, int flags); 77a6b33934Smacallan 78a6b33934Smacallanvoid PnozzSync(ScrnInfoPtr); 79a6b33934Smacallanvoid PnozzSave(PnozzPtr); 80a6b33934Smacallanvoid PnozzRestore(PnozzPtr); 81a6b33934Smacallanint PnozzSetDepth(PnozzPtr, int); /* return true or false */ 82a6b33934Smacallanvoid DumpSCR(unsigned int); 83a6b33934Smacallan 84a6b33934Smacallanstatic void PnozzLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); 85a6b33934Smacallan 86a6b33934Smacallan#define VERSION 4000 87a6b33934Smacallan#define PNOZZ_NAME "p9100" 88a6b33934Smacallan#define PNOZZ_DRIVER_NAME "pnozz" 89a6b33934Smacallan#define PNOZZ_MAJOR_VERSION 1 90a6b33934Smacallan#define PNOZZ_MINOR_VERSION 0 91a6b33934Smacallan#define PNOZZ_PATCHLEVEL 0 92a6b33934Smacallan 93a6b33934Smacallan/* 94a6b33934Smacallan * This contains the functions needed by the server after loading the driver 95a6b33934Smacallan * module. It must be supplied, and gets passed back by the SetupProc 96a6b33934Smacallan * function in the dynamic case. In the static case, a reference to this 97a6b33934Smacallan * is compiled in, and this requires that the name of this DriverRec be 98a6b33934Smacallan * an upper-case version of the driver name. 99a6b33934Smacallan */ 100a6b33934Smacallan 101a6b33934SmacallanDriverRec PNOZZ = { 102a6b33934Smacallan VERSION, 103a6b33934Smacallan PNOZZ_DRIVER_NAME, 104a6b33934Smacallan PnozzIdentify, 105a6b33934Smacallan PnozzProbe, 106a6b33934Smacallan PnozzAvailableOptions, 107a6b33934Smacallan NULL, 108a6b33934Smacallan 0 109a6b33934Smacallan}; 110a6b33934Smacallan 111a6b33934Smacallantypedef enum { 112a6b33934Smacallan OPTION_SW_CURSOR, 113a6b33934Smacallan OPTION_HW_CURSOR, 114a6b33934Smacallan OPTION_NOACCEL 115a6b33934Smacallan} PnozzOpts; 116a6b33934Smacallan 117a6b33934Smacallanstatic const OptionInfoRec PnozzOptions[] = { 118a6b33934Smacallan { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, 119a6b33934Smacallan { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, 120a6b33934Smacallan { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, 121a6b33934Smacallan { -1, NULL, OPTV_NONE, {0}, FALSE } 122a6b33934Smacallan}; 123a6b33934Smacallan 124a6b33934Smacallanstatic const char *ramdacSymbols[] = { 125a6b33934Smacallan "xf86CreateCursorInfoRec", 126a6b33934Smacallan "xf86DestroyCursorInfoRec", 127a6b33934Smacallan "xf86InitCursor", 128a6b33934Smacallan NULL 129a6b33934Smacallan}; 130a6b33934Smacallan 131a6b33934Smacallanstatic const char *fbSymbols[] = { 132a6b33934Smacallan "fbScreenInit", 133a6b33934Smacallan "fbPictureInit", 134a6b33934Smacallan NULL 135a6b33934Smacallan}; 136a6b33934Smacallan 137a6b33934Smacallanstatic const char *xaaSymbols[] = 138a6b33934Smacallan{ 139a6b33934Smacallan "XAACreateInfoRec", 140a6b33934Smacallan "XAADestroyInfoRec", 141a6b33934Smacallan "XAAInit", 142a6b33934Smacallan NULL 143a6b33934Smacallan}; 144a6b33934Smacallan#ifdef XFree86LOADER 145a6b33934Smacallan 146a6b33934Smacallanstatic MODULESETUPPROTO(PnozzSetup); 147a6b33934Smacallan 148a6b33934Smacallanstatic XF86ModuleVersionInfo PnozzVersRec = 149a6b33934Smacallan{ 150a6b33934Smacallan "pnozz", 151a6b33934Smacallan MODULEVENDORSTRING, 152a6b33934Smacallan MODINFOSTRING1, 153a6b33934Smacallan MODINFOSTRING2, 154a6b33934Smacallan XORG_VERSION_CURRENT, 155a6b33934Smacallan PNOZZ_MAJOR_VERSION, PNOZZ_MINOR_VERSION, PNOZZ_PATCHLEVEL, 156a6b33934Smacallan ABI_CLASS_VIDEODRV, 157a6b33934Smacallan ABI_VIDEODRV_VERSION, 158a6b33934Smacallan MOD_CLASS_VIDEODRV, 159a6b33934Smacallan {0,0,0,0} 160a6b33934Smacallan}; 161a6b33934Smacallan 162a6b33934SmacallanXF86ModuleData pnozzModuleData = { &PnozzVersRec, PnozzSetup, NULL }; 163a6b33934Smacallan 164a6b33934Smacallanpointer 165a6b33934SmacallanPnozzSetup(pointer module, pointer opts, int *errmaj, int *errmin) 166a6b33934Smacallan{ 167a6b33934Smacallan static Bool setupDone = FALSE; 168a6b33934Smacallan 169a6b33934Smacallan if (!setupDone) { 170a6b33934Smacallan setupDone = TRUE; 171a6b33934Smacallan xf86AddDriver(&PNOZZ, module, 0); 172a6b33934Smacallan 173a6b33934Smacallan LoaderRefSymLists(xaaSymbols, ramdacSymbols, fbSymbols, NULL); 174a6b33934Smacallan /* 175a6b33934Smacallan * Modules that this driver always requires can be loaded here 176a6b33934Smacallan * by calling LoadSubModule(). 177a6b33934Smacallan */ 178a6b33934Smacallan 179a6b33934Smacallan /* 180a6b33934Smacallan * The return value must be non-NULL on success even though there 181a6b33934Smacallan * is no TearDownProc. 182a6b33934Smacallan */ 183a6b33934Smacallan return (pointer)TRUE; 184a6b33934Smacallan } else { 185a6b33934Smacallan if (errmaj) *errmaj = LDR_ONCEONLY; 186a6b33934Smacallan return NULL; 187a6b33934Smacallan } 188a6b33934Smacallan} 189a6b33934Smacallan 190a6b33934Smacallan#endif /* XFree86LOADER */ 191a6b33934Smacallan 192a6b33934Smacallanstatic volatile unsigned int scratch32; 193a6b33934Smacallan 194a6b33934Smacallanvoid pnozz_write_4(PnozzPtr p, int offset, unsigned int value) 195a6b33934Smacallan{ 196a6b33934Smacallan if ((offset & 0xffffff80) != p->offset_mask) { 197a6b33934Smacallan p->offset_mask = offset & 0xffffff80; 198a6b33934Smacallan scratch32 = *(volatile unsigned int *)(p->fb + offset); 199a6b33934Smacallan } 200a6b33934Smacallan *((volatile unsigned int *)(p->fbc + offset)) = value; 201a6b33934Smacallan} 202a6b33934Smacallan 203a6b33934Smacallanunsigned int pnozz_read_4(PnozzPtr p, int offset) 204a6b33934Smacallan{ 205a6b33934Smacallan if ((offset & 0xffffff80) != p->offset_mask) { 206a6b33934Smacallan p->offset_mask = offset & 0xffffff80; 207a6b33934Smacallan scratch32 = *(volatile unsigned int *)(p->fb + offset); 208a6b33934Smacallan } 209a6b33934Smacallan return *(volatile unsigned int *)(p->fbc + offset); 210a6b33934Smacallan} 211a6b33934Smacallan 212a6b33934Smacallanvoid pnozz_write_dac(PnozzPtr p, int offset, unsigned char value) 213a6b33934Smacallan{ 214a6b33934Smacallan CARD32 val = ((CARD32)value) << 16; 215a6b33934Smacallan 216a6b33934Smacallan scratch32 = pnozz_read_4(p, PWRUP_CNFG); 217a6b33934Smacallan if ((offset != DAC_INDX_DATA) && (offset != DAC_CMAP_DATA)) { 218a6b33934Smacallan do { 219a6b33934Smacallan pnozz_write_4(p, offset, val); 220a6b33934Smacallan } while (pnozz_read_4(p, offset) != val); 221a6b33934Smacallan } else { 222a6b33934Smacallan pnozz_write_4(p, offset, val); 223a6b33934Smacallan } 224a6b33934Smacallan} 225a6b33934Smacallan 226a6b33934Smacallanunsigned char pnozz_read_dac(PnozzPtr p, int offset) 227a6b33934Smacallan{ 228a6b33934Smacallan scratch32 = pnozz_read_4(p, PWRUP_CNFG); 229a6b33934Smacallan return ((pnozz_read_4(p, offset) >> 16) & 0xff); 230a6b33934Smacallan} 231a6b33934Smacallan 232a6b33934Smacallanvoid pnozz_write_dac_ctl_reg(PnozzPtr p, int offset, unsigned char val) 233a6b33934Smacallan{ 234a6b33934Smacallan 235a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_HI, (offset & 0xff00) >> 8); 236a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_LO, (offset & 0xff)); 237a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_DATA, val); 238a6b33934Smacallan} 239a6b33934Smacallan 240a6b33934Smacallanvoid pnozz_write_dac_ctl_reg_2(PnozzPtr p, int offset, unsigned short val) 241a6b33934Smacallan{ 242a6b33934Smacallan 243a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_HI, (offset & 0xff00) >> 8); 244a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_LO, (offset & 0xff)); 245a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_CTL, DAC_INDX_AUTOINCR); 246a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_DATA, val & 0xff); 247a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_DATA, (val & 0xff00) >> 8); 248a6b33934Smacallan} 249a6b33934Smacallan 250a6b33934Smacallanunsigned char pnozz_read_dac_ctl_reg(PnozzPtr p, int offset) 251a6b33934Smacallan{ 252a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_HI, (offset & 0xff00) >> 8); 253a6b33934Smacallan pnozz_write_dac(p, DAC_INDX_LO, (offset & 0xff)); 254a6b33934Smacallan return pnozz_read_dac(p, DAC_INDX_DATA); 255a6b33934Smacallan} 256a6b33934Smacallan 257a6b33934Smacallanvoid pnozz_write_dac_cmap_reg(PnozzPtr p, int offset, unsigned int val) 258a6b33934Smacallan{ 259a6b33934Smacallan pnozz_write_dac(p, DAC_CMAP_WRIDX,(offset & 0xff)); 260a6b33934Smacallan pnozz_write_dac(p, DAC_CMAP_DATA,(val & 0xff)); 261a6b33934Smacallan pnozz_write_dac(p, DAC_CMAP_DATA,(val & 0xff00) >> 8); 262a6b33934Smacallan pnozz_write_dac(p, DAC_CMAP_DATA,(val & 0xff0000) >> 16); 263a6b33934Smacallan} 264a6b33934Smacallan 265a6b33934Smacallanstatic void 266a6b33934SmacallanPnozzLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, 267a6b33934Smacallan VisualPtr pVisual) 268a6b33934Smacallan{ 269a6b33934Smacallan PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 270a6b33934Smacallan int i, index; 271a6b33934Smacallan 272a6b33934Smacallan PnozzSync(pScrn); 273a6b33934Smacallan pnozz_write_dac(pPnozz, DAC_INDX_CTL, DAC_INDX_AUTOINCR); 274a6b33934Smacallan 275a6b33934Smacallan for (i = 0; i < numColors; i++) 276a6b33934Smacallan { 277a6b33934Smacallan index = indices[i]; 278a6b33934Smacallan if (index >= 0) { 279a6b33934Smacallan pnozz_write_dac(pPnozz, DAC_CMAP_WRIDX, index); 280a6b33934Smacallan pnozz_write_dac(pPnozz, DAC_CMAP_DATA, colors[index].red); 281a6b33934Smacallan pnozz_write_dac(pPnozz, DAC_CMAP_DATA, colors[index].green); 282a6b33934Smacallan pnozz_write_dac(pPnozz, DAC_CMAP_DATA, colors[index].blue); 283a6b33934Smacallan } 284a6b33934Smacallan } 285a6b33934Smacallan PnozzSync(pScrn); 286a6b33934Smacallan} 287a6b33934Smacallan 288a6b33934Smacallanstatic Bool 289a6b33934SmacallanPnozzGetRec(ScrnInfoPtr pScrn) 290a6b33934Smacallan{ 291a6b33934Smacallan /* 292a6b33934Smacallan * Allocate an PnozzRec, and hook it into pScrn->driverPrivate. 293a6b33934Smacallan * pScrn->driverPrivate is initialised to NULL, so we can check if 294a6b33934Smacallan * the allocation has already been done. 295a6b33934Smacallan */ 296a6b33934Smacallan if (pScrn->driverPrivate != NULL) 297a6b33934Smacallan return TRUE; 298a6b33934Smacallan 299a6b33934Smacallan pScrn->driverPrivate = xnfcalloc(sizeof(PnozzRec), 1); 300a6b33934Smacallan return TRUE; 301a6b33934Smacallan} 302a6b33934Smacallan 303a6b33934Smacallanstatic void 304a6b33934SmacallanPnozzFreeRec(ScrnInfoPtr pScrn) 305a6b33934Smacallan{ 306a6b33934Smacallan PnozzPtr pPnozz; 307a6b33934Smacallan 308a6b33934Smacallan if (pScrn->driverPrivate == NULL) 309a6b33934Smacallan return; 310a6b33934Smacallan 311a6b33934Smacallan pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 312a6b33934Smacallan 313a6b33934Smacallan xfree(pScrn->driverPrivate); 314a6b33934Smacallan pScrn->driverPrivate = NULL; 315a6b33934Smacallan 316a6b33934Smacallan return; 317a6b33934Smacallan} 318a6b33934Smacallan 319a6b33934Smacallanstatic const OptionInfoRec * 320a6b33934SmacallanPnozzAvailableOptions(int chipid, int busid) 321a6b33934Smacallan{ 322a6b33934Smacallan return PnozzOptions; 323a6b33934Smacallan} 324a6b33934Smacallan 325a6b33934Smacallan/* Mandatory */ 326a6b33934Smacallanstatic void 327a6b33934SmacallanPnozzIdentify(int flags) 328a6b33934Smacallan{ 329a6b33934Smacallan xf86Msg(X_INFO, "%s: driver for Weitek P9100 found in Tadpole SPARCbook 3GX and others\n", PNOZZ_NAME); 330a6b33934Smacallan} 331a6b33934Smacallan 332a6b33934Smacallan 333a6b33934Smacallan/* Mandatory */ 334a6b33934Smacallanstatic Bool 335a6b33934SmacallanPnozzProbe(DriverPtr drv, int flags) 336a6b33934Smacallan{ 337a6b33934Smacallan int i; 338a6b33934Smacallan GDevPtr *devSections; 339a6b33934Smacallan int *usedChips; 340a6b33934Smacallan int numDevSections; 341a6b33934Smacallan int numUsed; 342a6b33934Smacallan Bool foundScreen = FALSE; 343a6b33934Smacallan EntityInfoPtr pEnt; 344a6b33934Smacallan 345a6b33934Smacallan /* 346a6b33934Smacallan * The aim here is to find all cards that this driver can handle, 347a6b33934Smacallan * and for the ones not already claimed by another driver, claim the 348a6b33934Smacallan * slot, and allocate a ScrnInfoRec. 349a6b33934Smacallan * 350a6b33934Smacallan * This should be a minimal probe, and it should under no circumstances 351a6b33934Smacallan * change the state of the hardware. Because a device is found, don't 352a6b33934Smacallan * assume that it will be used. Don't do any initialisations other than 353a6b33934Smacallan * the required ScrnInfoRec initialisations. Don't allocate any new 354a6b33934Smacallan * data structures. 355a6b33934Smacallan */ 356a6b33934Smacallan 357a6b33934Smacallan /* 358a6b33934Smacallan * Next we check, if there has been a chipset override in the config file. 359a6b33934Smacallan * For this we must find out if there is an active device section which 360a6b33934Smacallan * is relevant, i.e., which has no driver specified or has THIS driver 361a6b33934Smacallan * specified. 362a6b33934Smacallan */ 363a6b33934Smacallan 364a6b33934Smacallan if ((numDevSections = xf86MatchDevice(PNOZZ_DRIVER_NAME, 365a6b33934Smacallan &devSections)) <= 0) { 366a6b33934Smacallan /* 367a6b33934Smacallan * There's no matching device section in the config file, so quit 368a6b33934Smacallan * now. 369a6b33934Smacallan */ 370a6b33934Smacallan return FALSE; 371a6b33934Smacallan } 372a6b33934Smacallan 373a6b33934Smacallan /* 374a6b33934Smacallan * We need to probe the hardware first. We then need to see how this 375a6b33934Smacallan * fits in with what is given in the config file, and allow the config 376a6b33934Smacallan * file info to override any contradictions. 377a6b33934Smacallan */ 378a6b33934Smacallan 379a6b33934Smacallan numUsed = xf86MatchSbusInstances(PNOZZ_NAME, SBUS_DEVICE_P9100, 380a6b33934Smacallan devSections, numDevSections, 381a6b33934Smacallan drv, &usedChips); 382a6b33934Smacallan 383a6b33934Smacallan xfree(devSections); 384a6b33934Smacallan if (numUsed <= 0) 385a6b33934Smacallan return FALSE; 386a6b33934Smacallan 387a6b33934Smacallan if (flags & PROBE_DETECT) 388a6b33934Smacallan foundScreen = TRUE; 389a6b33934Smacallan else 390a6b33934Smacallan for (i = 0; i < numUsed; i++) { 391a6b33934Smacallan pEnt = xf86GetEntityInfo(usedChips[i]); 392a6b33934Smacallan 393a6b33934Smacallan /* 394a6b33934Smacallan * Check that nothing else has claimed the slots. 395a6b33934Smacallan */ 396a6b33934Smacallan if(pEnt->active) { 397a6b33934Smacallan ScrnInfoPtr pScrn; 398a6b33934Smacallan 399a6b33934Smacallan /* Allocate a ScrnInfoRec and claim the slot */ 400a6b33934Smacallan pScrn = xf86AllocateScreen(drv, 0); 401a6b33934Smacallan 402a6b33934Smacallan /* Fill in what we can of the ScrnInfoRec */ 403a6b33934Smacallan pScrn->driverVersion = VERSION; 404a6b33934Smacallan pScrn->driverName = PNOZZ_DRIVER_NAME; 405a6b33934Smacallan pScrn->name = PNOZZ_NAME; 406a6b33934Smacallan pScrn->Probe = PnozzProbe; 407a6b33934Smacallan pScrn->PreInit = PnozzPreInit; 408a6b33934Smacallan pScrn->ScreenInit = PnozzScreenInit; 409a6b33934Smacallan pScrn->SwitchMode = PnozzSwitchMode; 410a6b33934Smacallan pScrn->AdjustFrame = PnozzAdjustFrame; 411a6b33934Smacallan pScrn->EnterVT = PnozzEnterVT; 412a6b33934Smacallan pScrn->LeaveVT = PnozzLeaveVT; 413a6b33934Smacallan pScrn->FreeScreen = PnozzFreeScreen; 414a6b33934Smacallan pScrn->ValidMode = PnozzValidMode; 415a6b33934Smacallan xf86AddEntityToScreen(pScrn, pEnt->index); 416a6b33934Smacallan foundScreen = TRUE; 417a6b33934Smacallan } 418a6b33934Smacallan xfree(pEnt); 419a6b33934Smacallan } 420a6b33934Smacallan xfree(usedChips); 421a6b33934Smacallan return foundScreen; 422a6b33934Smacallan} 423a6b33934Smacallan 424a6b33934Smacallan/* Mandatory */ 425a6b33934Smacallanstatic Bool 426a6b33934SmacallanPnozzPreInit(ScrnInfoPtr pScrn, int flags) 427a6b33934Smacallan{ 428a6b33934Smacallan PnozzPtr pPnozz; 429a6b33934Smacallan sbusDevicePtr psdp; 430a6b33934Smacallan MessageType from; 431a6b33934Smacallan rgb defaultWeight = {0, 0, 0}; 432a6b33934Smacallan int i; 433a6b33934Smacallan 434a6b33934Smacallan if (flags & PROBE_DETECT) return FALSE; 435a6b33934Smacallan 436a6b33934Smacallan /* 437a6b33934Smacallan * Note: This function is only called once at server startup, and 438a6b33934Smacallan * not at the start of each server generation. This means that 439a6b33934Smacallan * only things that are persistent across server generations can 440a6b33934Smacallan * be initialised here. xf86Screens[] is (pScrn is a pointer to one 441a6b33934Smacallan * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex() 442a6b33934Smacallan * are too, and should be used for data that must persist across 443a6b33934Smacallan * server generations. 444a6b33934Smacallan * 445a6b33934Smacallan * Per-generation data should be allocated with 446a6b33934Smacallan * AllocateScreenPrivateIndex() from the ScreenInit() function. 447a6b33934Smacallan */ 448a6b33934Smacallan 449a6b33934Smacallan /* Allocate the PnozzRec driverPrivate */ 450a6b33934Smacallan if (!PnozzGetRec(pScrn)) { 451a6b33934Smacallan return FALSE; 452a6b33934Smacallan } 453a6b33934Smacallan pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 454a6b33934Smacallan 455a6b33934Smacallan /* always mismatch on first access */ 456a6b33934Smacallan pPnozz->offset_mask = 0xffffffff; 457a6b33934Smacallan 458a6b33934Smacallan /* Set pScrn->monitor */ 459a6b33934Smacallan pScrn->monitor = pScrn->confScreen->monitor; 460a6b33934Smacallan 461a6b33934Smacallan /* This driver doesn't expect more than one entity per screen */ 462a6b33934Smacallan if (pScrn->numEntities > 1) 463a6b33934Smacallan return FALSE; 464a6b33934Smacallan /* This is the general case */ 465a6b33934Smacallan for (i = 0; i < pScrn->numEntities; i++) { 466a6b33934Smacallan EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]); 467a6b33934Smacallan 468a6b33934Smacallan /* PNOZZ is purely SBUS */ 469a6b33934Smacallan if (pEnt->location.type == BUS_SBUS) { 470a6b33934Smacallan psdp = xf86GetSbusInfoForEntity(pEnt->index); 471a6b33934Smacallan pPnozz->psdp = psdp; 472a6b33934Smacallan } else 473a6b33934Smacallan return FALSE; 474a6b33934Smacallan } 475a6b33934Smacallan 476a6b33934Smacallan /********************* 477a6b33934Smacallan deal with depth 478a6b33934Smacallan *********************/ 479a6b33934Smacallan if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb)) { 480a6b33934Smacallan return FALSE; 481a6b33934Smacallan } else { 482a6b33934Smacallan /* Check that the returned depth is one we support */ 483a6b33934Smacallan#ifdef DEBUG 484a6b33934Smacallan xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, 485a6b33934Smacallan "Depth requested: %d\n", pScrn->depth); 486a6b33934Smacallan#endif 487a6b33934Smacallan switch (pScrn->depth) { 488a6b33934Smacallan case 8: 489a6b33934Smacallan case 16: 490a6b33934Smacallan case 24: 491a6b33934Smacallan /* OK */ 492a6b33934Smacallan break; 493a6b33934Smacallan default: 494a6b33934Smacallan xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 495a6b33934Smacallan "Given depth (%d) is not supported by this driver\n", 496a6b33934Smacallan pScrn->depth); 497a6b33934Smacallan return FALSE; 498a6b33934Smacallan } 499a6b33934Smacallan } 500a6b33934Smacallan xf86PrintDepthBpp(pScrn); 501a6b33934Smacallan 502a6b33934Smacallan /* We use a programmable clock */ 503a6b33934Smacallan pScrn->progClock = TRUE; 504a6b33934Smacallan 505a6b33934Smacallan /* Set the bits per RGB for 8bpp mode */ 506a6b33934Smacallan if (pScrn->depth == 8) 507a6b33934Smacallan pScrn->rgbBits = 8; 508a6b33934Smacallan 509a6b33934Smacallan if (pScrn->depth > 8) { 510a6b33934Smacallan if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) 511a6b33934Smacallan return FALSE; 512a6b33934Smacallan } 513a6b33934Smacallan 514a6b33934Smacallan if (!xf86SetDefaultVisual(pScrn, -1)) { 515a6b33934Smacallan return FALSE; 516a6b33934Smacallan } else { 517a6b33934Smacallan /* We don't currently support DirectColor at > 8bpp */ 518a6b33934Smacallan if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { 519a6b33934Smacallan xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" 520a6b33934Smacallan " (%s) is not supported at depth %d\n", 521a6b33934Smacallan xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); 522a6b33934Smacallan return FALSE; 523a6b33934Smacallan } 524a6b33934Smacallan } 525a6b33934Smacallan 526a6b33934Smacallan /* Collect all of the relevant option flags (fill in pScrn->options) */ 527a6b33934Smacallan xf86CollectOptions(pScrn, NULL); 528a6b33934Smacallan 529a6b33934Smacallan /* Process the options */ 530a6b33934Smacallan if (!(pPnozz->Options = xalloc(sizeof(PnozzOptions)))) 531a6b33934Smacallan return FALSE; 532a6b33934Smacallan 533a6b33934Smacallan memcpy(pPnozz->Options, PnozzOptions, sizeof(PnozzOptions)); 534a6b33934Smacallan xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pPnozz->Options); 535a6b33934Smacallan 536a6b33934Smacallan /* 537a6b33934Smacallan * The new cmap code requires this to be initialised. 538a6b33934Smacallan */ 539a6b33934Smacallan 540a6b33934Smacallan { 541a6b33934Smacallan Gamma zeros = {0.0, 0.0, 0.0}; 542a6b33934Smacallan 543a6b33934Smacallan if (!xf86SetGamma(pScrn, zeros)) { 544a6b33934Smacallan return FALSE; 545a6b33934Smacallan } 546a6b33934Smacallan } 547a6b33934Smacallan 548a6b33934Smacallan /* Set the bits per RGB for 8bpp mode */ 549a6b33934Smacallan from = X_DEFAULT; 550a6b33934Smacallan 551a6b33934Smacallan /* determine whether we use hardware or software cursor */ 552a6b33934Smacallan pPnozz->HWCursor = TRUE; 553a6b33934Smacallan if (xf86GetOptValBool(pPnozz->Options, OPTION_HW_CURSOR, &pPnozz->HWCursor)) 554a6b33934Smacallan from = X_CONFIG; 555a6b33934Smacallan if (xf86ReturnOptValBool(pPnozz->Options, OPTION_SW_CURSOR, FALSE)) { 556a6b33934Smacallan from = X_CONFIG; 557a6b33934Smacallan pPnozz->HWCursor = FALSE; 558a6b33934Smacallan } 559a6b33934Smacallan 560a6b33934Smacallan xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", 561a6b33934Smacallan pPnozz->HWCursor ? "HW" : "SW"); 562a6b33934Smacallan 563a6b33934Smacallan if (xf86ReturnOptValBool(pPnozz->Options, OPTION_NOACCEL, FALSE)) { 564a6b33934Smacallan pPnozz->NoAccel = TRUE; 565a6b33934Smacallan xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); 566a6b33934Smacallan } 567a6b33934Smacallan 568a6b33934Smacallan if (xf86LoadSubModule(pScrn, "fb") == NULL) { 569a6b33934Smacallan PnozzFreeRec(pScrn); 570a6b33934Smacallan return FALSE; 571a6b33934Smacallan } 572a6b33934Smacallan 573a6b33934Smacallan if (xf86LoadSubModule(pScrn, "ramdac") == NULL) { 574a6b33934Smacallan PnozzFreeRec(pScrn); 575a6b33934Smacallan return FALSE; 576a6b33934Smacallan } 577a6b33934Smacallan xf86LoaderReqSymLists(ramdacSymbols, NULL); 578a6b33934Smacallan 579a6b33934Smacallan if (xf86LoadSubModule(pScrn, "xaa") == NULL) { 580a6b33934Smacallan PnozzFreeRec(pScrn); 581a6b33934Smacallan return FALSE; 582a6b33934Smacallan } 583a6b33934Smacallan xf86LoaderReqSymLists(xaaSymbols, NULL); 584a6b33934Smacallan 585a6b33934Smacallan /********************* 586a6b33934Smacallan set up clock and mode stuff 587a6b33934Smacallan *********************/ 588a6b33934Smacallan 589a6b33934Smacallan pScrn->progClock = TRUE; 590a6b33934Smacallan 591a6b33934Smacallan if(pScrn->display->virtualX || pScrn->display->virtualY) { 592a6b33934Smacallan xf86DrvMsg(pScrn->scrnIndex, X_WARNING, 593a6b33934Smacallan "Pnozz does not support a virtual desktop\n"); 594a6b33934Smacallan pScrn->display->virtualX = 0; 595a6b33934Smacallan pScrn->display->virtualY = 0; 596a6b33934Smacallan } 597a6b33934Smacallan 598a6b33934Smacallan xf86SbusUseBuiltinMode(pScrn, pPnozz->psdp); 599a6b33934Smacallan pScrn->currentMode = pScrn->modes; 600a6b33934Smacallan pScrn->displayWidth = pScrn->virtualX; 601a6b33934Smacallan 602a6b33934Smacallan /* Set display resolution */ 603a6b33934Smacallan xf86SetDpi(pScrn, 0, 0); 604a6b33934Smacallan 605a6b33934Smacallan return TRUE; 606a6b33934Smacallan} 607a6b33934Smacallan 608a6b33934Smacallan/* Mandatory */ 609a6b33934Smacallan 610a6b33934Smacallan/* This gets called at the start of each server generation */ 611a6b33934Smacallan 612a6b33934Smacallanstatic Bool 613a6b33934SmacallanPnozzScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) 614a6b33934Smacallan{ 615a6b33934Smacallan ScrnInfoPtr pScrn; 616a6b33934Smacallan PnozzPtr pPnozz; 617a6b33934Smacallan VisualPtr visual; 618a6b33934Smacallan int ret,len=0,i; 619a6b33934Smacallan unsigned int *regs, pctl, pfb, *fb; 620a6b33934Smacallan 621a6b33934Smacallan /* 622a6b33934Smacallan * First get the ScrnInfoRec 623a6b33934Smacallan */ 624a6b33934Smacallan pScrn = xf86Screens[pScreen->myNum]; 625a6b33934Smacallan 626a6b33934Smacallan pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 627a6b33934Smacallan 628a6b33934Smacallan /* 629a6b33934Smacallan * XXX 630a6b33934Smacallan * figure out how much video RAM we really have - 2MB is just by far the 631a6b33934Smacallan * most common size 632a6b33934Smacallan */ 633a6b33934Smacallan pPnozz->fb = 634a6b33934Smacallan xf86MapSbusMem (pPnozz->psdp, 0, 0x200000); /* map 2MB */ 635a6b33934Smacallan fb=(unsigned int *)pPnozz->fb; 636a6b33934Smacallan 637a6b33934Smacallan pPnozz->fbc = 638a6b33934Smacallan xf86MapSbusMem (pPnozz->psdp, 0x200000,0x8000); /* map registers */ 639a6b33934Smacallan 640a6b33934Smacallan if (! pPnozz->fbc) 641a6b33934Smacallan return FALSE; 642a6b33934Smacallan 643a6b33934Smacallan /* 644a6b33934Smacallan * The next step is to setup the screen's visuals, and initialise the 645a6b33934Smacallan * framebuffer code. In cases where the framebuffer's default 646a6b33934Smacallan * choices for things like visual layouts and bits per RGB are OK, 647a6b33934Smacallan * this may be as simple as calling the framebuffer's ScreenInit() 648a6b33934Smacallan * function. If not, the visuals will need to be setup before calling 649a6b33934Smacallan * a fb ScreenInit() function and fixed up after. 650a6b33934Smacallan */ 651a6b33934Smacallan 652a6b33934Smacallan /* 653a6b33934Smacallan * Reset visual list. 654a6b33934Smacallan */ 655a6b33934Smacallan miClearVisualTypes(); 656a6b33934Smacallan 657a6b33934Smacallan#ifdef DEBUG 658a6b33934Smacallan xf86Msg(X_ERROR, "depth: %d, bpp: %d\n", pScrn->depth, pScrn->bitsPerPixel); 659a6b33934Smacallan#endif 660a6b33934Smacallan switch (pScrn->bitsPerPixel) { 661a6b33934Smacallan case 8: 662a6b33934Smacallan pPnozz->depthshift = 0; 663a6b33934Smacallan break; 664a6b33934Smacallan case 16: 665a6b33934Smacallan pPnozz->depthshift = 1; 666a6b33934Smacallan break; 667a6b33934Smacallan case 32: 668a6b33934Smacallan pPnozz->depthshift = 2; 669a6b33934Smacallan break; 670a6b33934Smacallan default: 671a6b33934Smacallan return FALSE; 672a6b33934Smacallan } 673a6b33934Smacallan pPnozz->width = pScrn->virtualX; 674a6b33934Smacallan pPnozz->height = pScrn->virtualY; 675a6b33934Smacallan pPnozz->scanlinesize = pScrn->virtualX << pPnozz->depthshift; 676a6b33934Smacallan 677a6b33934Smacallan PnozzSave(pPnozz); 678a6b33934Smacallan 679a6b33934Smacallan /* 680a6b33934Smacallan * ok, let's switch to whatever depth That Guy Out There wants. 681a6b33934Smacallan * We won't switch video mode, only colour depth - 682a6b33934Smacallan */ 683a6b33934Smacallan if(!PnozzSetDepth(pPnozz, pScrn->bitsPerPixel)) 684a6b33934Smacallan return FALSE; 685a6b33934Smacallan 686a6b33934Smacallan /* Setup the visuals we support. */ 687a6b33934Smacallan 688a6b33934Smacallan if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), 689a6b33934Smacallan pScrn->rgbBits, pScrn->defaultVisual)) 690a6b33934Smacallan return FALSE; 691a6b33934Smacallan 692a6b33934Smacallan miSetPixmapDepths(); 693a6b33934Smacallan 694a6b33934Smacallan /* 695a6b33934Smacallan * Call the framebuffer layer's ScreenInit function, and fill in other 696a6b33934Smacallan * pScreen fields. 697a6b33934Smacallan */ 698a6b33934Smacallan#if DEBUG 699a6b33934Smacallan xf86Msg(X_ERROR, "sls: %d\n", pPnozz->scanlinesize); 700a6b33934Smacallan#endif 701a6b33934Smacallan ret = fbScreenInit(pScreen, pPnozz->fb, pScrn->virtualX, 702a6b33934Smacallan pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, 703a6b33934Smacallan pScrn->displayWidth, pScrn->bitsPerPixel); 704a6b33934Smacallan 705a6b33934Smacallan /* should be set by PnozzSetDepth() */ 706a6b33934Smacallan pPnozz->maxheight = (0x200000 / pPnozz->scanlinesize) & 0xffff; 707a6b33934Smacallan#if DEBUG 708a6b33934Smacallan xf86Msg(X_ERROR, "max scanlines: %d\n", pPnozz->maxheight); 709a6b33934Smacallan#endif 710a6b33934Smacallan if (!ret) 711a6b33934Smacallan return FALSE; 712a6b33934Smacallan 713a6b33934Smacallan if (pScrn->bitsPerPixel > 8) { 714a6b33934Smacallan visual = pScreen->visuals + pScreen->numVisuals; 715a6b33934Smacallan while (--visual >= pScreen->visuals) { 716a6b33934Smacallan if ((visual->class | DynamicClass) == DirectColor) { 717a6b33934Smacallan visual->offsetRed = pScrn->offset.red; 718a6b33934Smacallan visual->offsetGreen = pScrn->offset.green; 719a6b33934Smacallan visual->offsetBlue = pScrn->offset.blue; 720a6b33934Smacallan visual->redMask = pScrn->mask.red; 721a6b33934Smacallan visual->greenMask = pScrn->mask.green; 722a6b33934Smacallan visual->blueMask = pScrn->mask.blue; 723a6b33934Smacallan } 724a6b33934Smacallan } 725a6b33934Smacallan } 726a6b33934Smacallan 727a6b33934Smacallan fbPictureInit(pScreen, 0, 0); 728a6b33934Smacallan 729a6b33934Smacallan miInitializeBackingStore(pScreen); 730a6b33934Smacallan xf86SetBackingStore(pScreen); 731a6b33934Smacallan xf86SetSilkenMouse(pScreen); 732a6b33934Smacallan xf86SetBlackWhitePixels(pScreen); 733a6b33934Smacallan 734a6b33934Smacallan if (!pPnozz->NoAccel) { 735a6b33934Smacallan BoxRec bx; 736a6b33934Smacallan pPnozz->pXAA = XAACreateInfoRec(); 737a6b33934Smacallan PnozzAccelInit(pScrn); 738a6b33934Smacallan bx.x1 = bx.y1 = 0; 739a6b33934Smacallan bx.x2 = pPnozz->width; 740a6b33934Smacallan bx.y2 = pPnozz->maxheight; 741a6b33934Smacallan xf86InitFBManager(pScreen, &bx); 742a6b33934Smacallan if(!XAAInit(pScreen, pPnozz->pXAA)) 743a6b33934Smacallan return FALSE; 744a6b33934Smacallan xf86Msg(X_INFO, "%s: Using acceleration\n", pPnozz->psdp->device); 745a6b33934Smacallan } 746a6b33934Smacallan 747a6b33934Smacallan /* Initialise cursor functions */ 748a6b33934Smacallan miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); 749a6b33934Smacallan 750a6b33934Smacallan /* 751a6b33934Smacallan * Initialize HW cursor layer. 752a6b33934Smacallan * Must follow software cursor initialization 753a6b33934Smacallan */ 754a6b33934Smacallan xf86SbusHideOsHwCursor(pPnozz->psdp); 755a6b33934Smacallan if (pPnozz->HWCursor) { 756a6b33934Smacallan extern Bool PnozzHWCursorInit(ScreenPtr pScreen); 757a6b33934Smacallan 758a6b33934Smacallan if(!PnozzHWCursorInit(pScreen)) { 759a6b33934Smacallan xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 760a6b33934Smacallan "Hardware cursor initialization failed\n"); 761a6b33934Smacallan return(FALSE); 762a6b33934Smacallan } 763a6b33934Smacallan } 764a6b33934Smacallan 765a6b33934Smacallan /* Initialise default colourmap */ 766a6b33934Smacallan if (!miCreateDefColormap(pScreen)) 767a6b33934Smacallan return FALSE; 768a6b33934Smacallan#if 1 769a6b33934Smacallan if(!xf86SbusHandleColormaps(pScreen, pPnozz->psdp)) 770a6b33934Smacallan#else 771a6b33934Smacallan if(!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits, PnozzLoadPalette, NULL, 772a6b33934Smacallan /*CMAP_PALETTED_TRUECOLOR|*/CMAP_RELOAD_ON_MODE_SWITCH)) 773a6b33934Smacallan#endif 774a6b33934Smacallan return FALSE; 775a6b33934Smacallan pPnozz->CloseScreen = pScreen->CloseScreen; 776a6b33934Smacallan pScreen->CloseScreen = PnozzCloseScreen; 777a6b33934Smacallan pScreen->SaveScreen = PnozzSaveScreen; 778a6b33934Smacallan 779a6b33934Smacallan /* Report any unused options (only for the first generation) */ 780a6b33934Smacallan if (serverGeneration == 1) { 781a6b33934Smacallan xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); 782a6b33934Smacallan } 783a6b33934Smacallan 784a6b33934Smacallan /* unblank the screen */ 785a6b33934Smacallan PnozzSaveScreen(pScreen, SCREEN_SAVER_OFF); 786a6b33934Smacallan 787a6b33934Smacallan /* Done */ 788a6b33934Smacallan return TRUE; 789a6b33934Smacallan} 790a6b33934Smacallan 791a6b33934Smacallan 792a6b33934Smacallan/* Usually mandatory */ 793a6b33934Smacallanstatic Bool 794a6b33934SmacallanPnozzSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) 795a6b33934Smacallan{ 796a6b33934Smacallan xf86Msg(X_ERROR, "SwitchMode: %d %d %d %d\n", mode->CrtcHTotal, 797a6b33934Smacallan mode->CrtcHSyncStart, mode->CrtcHSyncEnd, mode->CrtcHDisplay); 798a6b33934Smacallan return TRUE; 799a6b33934Smacallan} 800a6b33934Smacallan 801a6b33934Smacallan 802a6b33934Smacallan/* 803a6b33934Smacallan * This function is used to initialize the Start Address - the first 804a6b33934Smacallan * displayed location in the video memory. 805a6b33934Smacallan */ 806a6b33934Smacallan/* Usually mandatory */ 807a6b33934Smacallanstatic void 808a6b33934SmacallanPnozzAdjustFrame(int scrnIndex, int x, int y, int flags) 809a6b33934Smacallan{ 810a6b33934Smacallan /* we don't support virtual desktops for now */ 811a6b33934Smacallan return; 812a6b33934Smacallan} 813a6b33934Smacallan 814a6b33934Smacallan/* 815a6b33934Smacallan * This is called when VT switching back to the X server. Its job is 816a6b33934Smacallan * to reinitialise the video mode. 817a6b33934Smacallan */ 818a6b33934Smacallan 819a6b33934Smacallan/* Mandatory */ 820a6b33934Smacallanstatic Bool 821a6b33934SmacallanPnozzEnterVT(int scrnIndex, int flags) 822a6b33934Smacallan{ 823a6b33934Smacallan ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; 824a6b33934Smacallan PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 825a6b33934Smacallan 826a6b33934Smacallan xf86SbusHideOsHwCursor (pPnozz->psdp); 827a6b33934Smacallan return TRUE; 828a6b33934Smacallan} 829a6b33934Smacallan 830a6b33934Smacallan 831a6b33934Smacallan/* 832a6b33934Smacallan * This is called when VT switching away from the X server. 833a6b33934Smacallan */ 834a6b33934Smacallan 835a6b33934Smacallan/* Mandatory */ 836a6b33934Smacallanstatic void 837a6b33934SmacallanPnozzLeaveVT(int scrnIndex, int flags) 838a6b33934Smacallan{ 839a6b33934Smacallan return; 840a6b33934Smacallan} 841a6b33934Smacallan 842a6b33934Smacallan 843a6b33934Smacallan/* 844a6b33934Smacallan * This is called at the end of each server generation. It restores the 845a6b33934Smacallan * original (text) mode. It should really also unmap the video memory too. 846a6b33934Smacallan */ 847a6b33934Smacallan 848a6b33934Smacallan/* Mandatory */ 849a6b33934Smacallanstatic Bool 850a6b33934SmacallanPnozzCloseScreen(int scrnIndex, ScreenPtr pScreen) 851a6b33934Smacallan{ 852a6b33934Smacallan ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; 853a6b33934Smacallan PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 854a6b33934Smacallan int state = 1; 855a6b33934Smacallan 856a6b33934Smacallan pScrn->vtSema = FALSE; 857a6b33934Smacallan 858a6b33934Smacallan if (pPnozz->HWCursor) 859a6b33934Smacallan PnozzHideCursor(pScrn); 860a6b33934Smacallan 861a6b33934Smacallan PnozzRestore(pPnozz); /* restore colour depth */ 862a6b33934Smacallan 863a6b33934Smacallan xf86UnmapSbusMem(pPnozz->psdp, pPnozz->fb,0x200000); 864a6b33934Smacallan xf86UnmapSbusMem(pPnozz->psdp, pPnozz->fbc,0x8000); 865a6b33934Smacallan 866a6b33934Smacallan /* make sure video is turned on */ 867a6b33934Smacallan ioctl(pPnozz->psdp->fd, FBIOSVIDEO, &state); 868a6b33934Smacallan 869a6b33934Smacallan pScreen->CloseScreen = pPnozz->CloseScreen; 870a6b33934Smacallan return (*pScreen->CloseScreen)(scrnIndex, pScreen); 871a6b33934Smacallan return FALSE; 872a6b33934Smacallan} 873a6b33934Smacallan 874a6b33934Smacallan 875a6b33934Smacallan/* Free up any per-generation data structures */ 876a6b33934Smacallan 877a6b33934Smacallan/* Optional */ 878a6b33934Smacallanstatic void 879a6b33934SmacallanPnozzFreeScreen(int scrnIndex, int flags) 880a6b33934Smacallan{ 881a6b33934Smacallan PnozzFreeRec(xf86Screens[scrnIndex]); 882a6b33934Smacallan} 883a6b33934Smacallan 884a6b33934Smacallan 885a6b33934Smacallan/* Checks if a mode is suitable for the selected chipset. */ 886a6b33934Smacallan 887a6b33934Smacallan/* Optional */ 888a6b33934Smacallanstatic ModeStatus 889a6b33934SmacallanPnozzValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) 890a6b33934Smacallan{ 891a6b33934Smacallan if (mode->Flags & V_INTERLACE) 892a6b33934Smacallan return(MODE_BAD); 893a6b33934Smacallan 894a6b33934Smacallan return(MODE_OK); 895a6b33934Smacallan} 896a6b33934Smacallan 897a6b33934Smacallan/* Do screen blanking */ 898a6b33934Smacallan 899a6b33934Smacallan/* Mandatory */ 900a6b33934Smacallanstatic Bool 901a6b33934SmacallanPnozzSaveScreen(ScreenPtr pScreen, int mode) 902a6b33934Smacallan{ 903a6b33934Smacallan ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 904a6b33934Smacallan PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn); 905a6b33934Smacallan int fd = pPnozz->psdp->fd, state; 906a6b33934Smacallan 907a6b33934Smacallan /* 908a6b33934Smacallan * we're using ioctl() instead of just whacking the DAC because the 909a6b33934Smacallan * underlying driver will also turn off the backlight which we couldn't do 910a6b33934Smacallan * from here without adding lots more hardware dependencies 911a6b33934Smacallan */ 912a6b33934Smacallan switch(mode) 913a6b33934Smacallan { 914a6b33934Smacallan case SCREEN_SAVER_ON: 915a6b33934Smacallan case SCREEN_SAVER_CYCLE: 916a6b33934Smacallan state = 0; 917a6b33934Smacallan if(ioctl(fd, FBIOSVIDEO, &state) == -1) 918a6b33934Smacallan { 919a6b33934Smacallan /* complain */ 920a6b33934Smacallan } 921a6b33934Smacallan break; 922a6b33934Smacallan case SCREEN_SAVER_OFF: 923a6b33934Smacallan case SCREEN_SAVER_FORCER: 924a6b33934Smacallan state = 1; 925a6b33934Smacallan if(ioctl(fd, FBIOSVIDEO, &state) == -1) 926a6b33934Smacallan { 927a6b33934Smacallan /* complain */ 928a6b33934Smacallan } 929a6b33934Smacallan break; 930a6b33934Smacallan default: 931a6b33934Smacallan return FALSE; 932a6b33934Smacallan } 933a6b33934Smacallan return TRUE; 934a6b33934Smacallan} 935a6b33934Smacallan 936a6b33934Smacallanint shift_1(int b) 937a6b33934Smacallan{ 938a6b33934Smacallan if (b > 0) 939a6b33934Smacallan return (16 << b); 940a6b33934Smacallan return 0; 941a6b33934Smacallan} 942a6b33934Smacallan 943a6b33934Smacallanint shift_2(int b) 944a6b33934Smacallan{ 945a6b33934Smacallan if (b > 0) 946a6b33934Smacallan return (512 << b); 947a6b33934Smacallan return 0; 948a6b33934Smacallan} 949a6b33934Smacallan 950a6b33934Smacallanvoid 951a6b33934SmacallanPnozzSave(PnozzPtr pPnozz) 952a6b33934Smacallan{ 953a6b33934Smacallan int i; 954a6b33934Smacallan pPnozz->SvSysConf = pnozz_read_4(pPnozz, SYS_CONF); 955a6b33934Smacallan pPnozz->SvDAC_MC3 = pnozz_read_dac_ctl_reg(pPnozz, DAC_MISC_3); 956a6b33934Smacallan pPnozz->SvDAC_MCCR = pnozz_read_dac_ctl_reg(pPnozz, DAC_MISC_CLK); 957a6b33934Smacallan pPnozz->SvDAC_PF = pnozz_read_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT); 958a6b33934Smacallan pPnozz->SvPLL = pnozz_read_dac_ctl_reg(pPnozz, DAC_PLL0); 959a6b33934Smacallan pPnozz->SvVCO = pnozz_read_dac_ctl_reg(pPnozz, DAC_VCO_DIV); 960a6b33934Smacallan pPnozz->SvMemCtl = pnozz_read_4(pPnozz, VID_MEM_CONFIG); 961a6b33934Smacallan for (i = 0; i < 4; i++) 962a6b33934Smacallan pPnozz->CRTC[i] = pnozz_read_4(pPnozz, VID_HTOTAL + (i << 2)); 963a6b33934Smacallan pPnozz->DidSave = 1; 964a6b33934Smacallan#if DEBUG 965a6b33934Smacallan xf86Msg(X_ERROR, "Saved: %x %x %x %x\n", pPnozz->SvSysConf, 966a6b33934Smacallan pPnozz->SvDAC_MCCR, pPnozz->SvDAC_PF, pPnozz->SvDAC_MC3); 967a6b33934Smacallan DumpSCR(pPnozz->SvSysConf); 968a6b33934Smacallan#endif 969a6b33934Smacallan} 970a6b33934Smacallan 971a6b33934Smacallanvoid DumpSCR(unsigned int scr) 972a6b33934Smacallan{ 973a6b33934Smacallan#if DEBUG 974a6b33934Smacallan int s0, s1, s2, s3, ps; 975a6b33934Smacallan int width; 976a6b33934Smacallan ps = (scr >> PIXEL_SHIFT) & 7; 977a6b33934Smacallan s0 = (scr >> SHIFT_0) & 7; 978a6b33934Smacallan s1 = (scr >> SHIFT_1) & 7; 979a6b33934Smacallan s2 = (scr >> SHIFT_2) & 7; 980a6b33934Smacallan s3 = (scr >> SHIFT_3) & 3; 981a6b33934Smacallan width = shift_1(s0) + shift_1(s1) + shift_1(s2) + shift_2(s3); 982a6b33934Smacallan xf86Msg(X_ERROR, "ps: %d wi: %d\n", ps, width); 983a6b33934Smacallan#endif 984a6b33934Smacallan} 985a6b33934Smacallan 986a6b33934Smacallanvoid DumpDAC(PnozzPtr pPnozz) 987a6b33934Smacallan{ 988a6b33934Smacallan#if DEBUG 989a6b33934Smacallan int addr, i, val; 990a6b33934Smacallan char line[256], buffer[16]; 991a6b33934Smacallan pnozz_write_dac(pPnozz, DAC_INDX_LO, 0); 992a6b33934Smacallan pnozz_write_dac(pPnozz, DAC_INDX_HI, 0); 993a6b33934Smacallan for (addr = 0; addr < 0x100; addr += 16) { 994a6b33934Smacallan snprintf(line, 16, "%02x:", addr); 995a6b33934Smacallan for (i=0;i<16;i++) { 996a6b33934Smacallan val = pnozz_read_dac(pPnozz, DAC_INDX_DATA); 997a6b33934Smacallan snprintf(buffer, 16, " %02x", val); 998a6b33934Smacallan strcat(line, buffer); 999a6b33934Smacallan } 1000a6b33934Smacallan xf86Msg(X_ERROR, "%s\n", line); 1001a6b33934Smacallan } 1002a6b33934Smacallan#endif 1003a6b33934Smacallan} 1004a6b33934Smacallan 1005a6b33934Smacallanvoid DumpCRTC(PnozzPtr pPnozz) 1006a6b33934Smacallan{ 1007a6b33934Smacallan#if DEBUG 1008a6b33934Smacallan int i; 1009a6b33934Smacallan unsigned int reg; 1010a6b33934Smacallan for (i = 0x108; i<0x140; i += 4) { 1011a6b33934Smacallan reg = pnozz_read_4(pPnozz, i); 1012a6b33934Smacallan xf86Msg(X_ERROR, "%x / %d ", reg, reg); 1013a6b33934Smacallan } 1014a6b33934Smacallan reg = pnozz_read_4(pPnozz, VID_MEM_CONFIG); 1015a6b33934Smacallan xf86Msg(X_ERROR, "memcfg: %08x\n", reg); 1016a6b33934Smacallan xf86Msg(X_ERROR, "shiftclk: %x\n", (reg >> 10) & 7); 1017a6b33934Smacallan xf86Msg(X_ERROR, "shiftmode: %x\n", (reg >> 22) & 3); 1018a6b33934Smacallan xf86Msg(X_ERROR, "crtc_clk: %x\n", (reg >> 13) & 7); 1019a6b33934Smacallan#endif 1020a6b33934Smacallan} 1021a6b33934Smacallan 1022a6b33934Smacallanvoid 1023a6b33934SmacallanPnozzRestore(PnozzPtr pPnozz) 1024a6b33934Smacallan{ 1025a6b33934Smacallan int i; 1026a6b33934Smacallan if(pPnozz->DidSave == 1) { 1027a6b33934Smacallan pnozz_write_4(pPnozz, SYS_CONF, pPnozz->SvSysConf); 1028a6b33934Smacallan pnozz_write_4(pPnozz, VID_MEM_CONFIG, pPnozz->SvMemCtl); 1029a6b33934Smacallan for (i = 0; i < 4; i++) 1030a6b33934Smacallan pnozz_write_4(pPnozz, VID_HTOTAL + (i << 2), pPnozz->CRTC[i]); 1031a6b33934Smacallan 1032a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_PLL0, pPnozz->SvPLL); 1033a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_3, pPnozz->SvDAC_MC3); 1034a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_CLK, pPnozz->SvDAC_MCCR); 1035a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT, pPnozz->SvDAC_PF); 1036a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_VCO_DIV, pPnozz->SvVCO); 1037a6b33934Smacallan } 1038a6b33934Smacallan} 1039a6b33934Smacallan 1040a6b33934Smacallanunsigned int upper_bit(unsigned int b) 1041a6b33934Smacallan{ 1042a6b33934Smacallan unsigned int mask=0x80000000; 1043a6b33934Smacallan int cnt = 31; 1044a6b33934Smacallan if (b == 0) 1045a6b33934Smacallan return -1; 1046a6b33934Smacallan while ((mask != 0) && ((b & mask) == 0)) { 1047a6b33934Smacallan mask = mask >> 1; 1048a6b33934Smacallan cnt--; 1049a6b33934Smacallan } 1050a6b33934Smacallan return cnt; 1051a6b33934Smacallan} 1052a6b33934Smacallan 1053a6b33934Smacallan/* 1054a6b33934Smacallan * To switch colour depth we need to: 1055a6b33934Smacallan * - double or quadruple both crtc and shift clock ( for 16 or 32 bit ) 1056a6b33934Smacallan * - double or quadruple scanline length 1057a6b33934Smacallan * - switch the DAC to the appropriate pixel format 1058a6b33934Smacallan * - tell the drawing engine about new line length / pixel size 1059a6b33934Smacallan */ 1060a6b33934Smacallan 1061a6b33934Smacallanint 1062a6b33934SmacallanPnozzSetDepth(PnozzPtr pPnozz, int depth) 1063a6b33934Smacallan{ 1064a6b33934Smacallan int new_sls; 1065a6b33934Smacallan unsigned int bits, scr, sscr, memctl, mem; 1066a6b33934Smacallan int s0, s1, s2, s3, ps, crtcline; 1067a6b33934Smacallan unsigned char pf, mc3, es; 1068a6b33934Smacallan 1069a6b33934Smacallan#if DEBUG 1070a6b33934Smacallan DumpDAC(pPnozz); 1071a6b33934Smacallan DumpCRTC(pPnozz); 1072a6b33934Smacallan#endif 1073a6b33934Smacallan 1074a6b33934Smacallan switch (depth) { 1075a6b33934Smacallan case 8: 1076a6b33934Smacallan pPnozz->depthshift = 0; 1077a6b33934Smacallan ps = 2; 1078a6b33934Smacallan pf = 3; 1079a6b33934Smacallan mc3 = 0; 1080a6b33934Smacallan es = 0; /* no swapping */ 1081a6b33934Smacallan memctl = 3; 1082a6b33934Smacallan break; 1083a6b33934Smacallan case 16: 1084a6b33934Smacallan pPnozz->depthshift = 1; 1085a6b33934Smacallan ps = 3; 1086a6b33934Smacallan pf = 4; 1087a6b33934Smacallan mc3 = 0; 1088a6b33934Smacallan es = 2; /* swap bytes in 16bit words */ 1089a6b33934Smacallan memctl = 2; 1090a6b33934Smacallan break; 1091a6b33934Smacallan case 24: 1092a6b33934Smacallan /* boo */ 1093a6b33934Smacallan xf86Msg(X_ERROR, "We don't DO 24bit pixels dammit!\n"); 1094a6b33934Smacallan return 0; 1095a6b33934Smacallan case 32: 1096a6b33934Smacallan pPnozz->depthshift = 2; 1097a6b33934Smacallan ps = 5; 1098a6b33934Smacallan pf = 6; 1099a6b33934Smacallan mc3 = 0; 1100a6b33934Smacallan es = 6; /* swap both half-words and bytes */ 1101a6b33934Smacallan memctl = 1; /* 0 */ 1102a6b33934Smacallan break; 1103a6b33934Smacallan } 1104a6b33934Smacallan /* 1105a6b33934Smacallan * this could be done a lot shorter and faster but then nobody would 1106a6b33934Smacallan * understand what the hell we're doing here without getting a major 1107a6b33934Smacallan * headache. Scanline size is encoded as 4 shift values, 3 of them 3 bits 1108a6b33934Smacallan * wide, 16 << n for n>0, one 2 bits, 512 << n for n>0. n==0 means 0 1109a6b33934Smacallan */ 1110a6b33934Smacallan new_sls = pPnozz->width << pPnozz->depthshift; 1111a6b33934Smacallan pPnozz->scanlinesize = new_sls; 1112a6b33934Smacallan bits = new_sls; 1113a6b33934Smacallan s3 = upper_bit(bits); 1114a6b33934Smacallan if (s3 > 9) { 1115a6b33934Smacallan bits &= ~(1 << s3); 1116a6b33934Smacallan s3 -= 9; 1117a6b33934Smacallan } else s3 = 0; 1118a6b33934Smacallan s2 = upper_bit(bits); 1119a6b33934Smacallan if (s2 > 0) { 1120a6b33934Smacallan bits &= ~(1 << s2); 1121a6b33934Smacallan s2 -= 4; 1122a6b33934Smacallan } else s2 = 0; 1123a6b33934Smacallan s1 = upper_bit(bits); 1124a6b33934Smacallan if (s1 > 0) { 1125a6b33934Smacallan bits &= ~(1 << s1); 1126a6b33934Smacallan s1 -= 4; 1127a6b33934Smacallan } else s1 = 0; 1128a6b33934Smacallan s0 = upper_bit(bits); 1129a6b33934Smacallan if (s0 > 0) { 1130a6b33934Smacallan bits &= ~(1 << s0); 1131a6b33934Smacallan s0 -= 4; 1132a6b33934Smacallan } else s0 = 0; 1133a6b33934Smacallan 1134a6b33934Smacallan#if DEBUG 1135a6b33934Smacallan xf86Msg(X_ERROR, "sls: %x sh: %d %d %d %d leftover: %x\n", new_sls, s0, s1, 1136a6b33934Smacallan s2, s3, bits); 1137a6b33934Smacallan#endif 1138a6b33934Smacallan 1139a6b33934Smacallan /* 1140a6b33934Smacallan * now let's put these values into the System Config Register. No need to 1141a6b33934Smacallan * read it here since we (hopefully) just saved the content 1142a6b33934Smacallan */ 1143a6b33934Smacallan scr = pnozz_read_4(pPnozz, SYS_CONF); 1144a6b33934Smacallan scr = (s0 << SHIFT_0) | (s1 << SHIFT_1) | (s2 << SHIFT_2) | 1145a6b33934Smacallan (s3 << SHIFT_3) | (ps << PIXEL_SHIFT) | (es << SWAP_SHIFT); 1146a6b33934Smacallan#if DEBUG 1147a6b33934Smacallan xf86Msg(X_ERROR, "new scr: %x DAC %x %x\n", scr, pf, mc3); 1148a6b33934Smacallan DumpSCR(scr); 1149a6b33934Smacallan#endif 1150a6b33934Smacallan 1151a6b33934Smacallan mem = pnozz_read_4(pPnozz, VID_MEM_CONFIG); 1152a6b33934Smacallan#if DEBUG 1153a6b33934Smacallan xf86Msg(X_ERROR, "old memctl: %08x\n", mem); 1154a6b33934Smacallan#endif 1155a6b33934Smacallan /* set shift and crtc clock */ 1156a6b33934Smacallan mem &= ~(0x0000fc00); 1157a6b33934Smacallan mem |= (memctl << 10) | (memctl << 13); 1158a6b33934Smacallan pnozz_write_4(pPnozz, VID_MEM_CONFIG, mem); 1159a6b33934Smacallan#if DEBUG 1160a6b33934Smacallan xf86Msg(X_ERROR, "new memctl: %08x\n", mem); 1161a6b33934Smacallan#endif 1162a6b33934Smacallan /* whack the engine... */ 1163a6b33934Smacallan pnozz_write_4(pPnozz, SYS_CONF, scr); 1164a6b33934Smacallan 1165a6b33934Smacallan /* ok, whack the DAC */ 1166a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_1, 0x11); 1167a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_2, 0x45); 1168a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_3, mc3); 1169a6b33934Smacallan /* 1170a6b33934Smacallan * despite the 3GX manual saying otherwise we don't need to mess with any 1171a6b33934Smacallan * clock dividers here 1172a6b33934Smacallan */ 1173a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_MISC_CLK, 1); 1174a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, 3, 0); 1175a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, 4, 0); 1176a6b33934Smacallan 1177a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_POWER_MGT, 0); 1178a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_OPERATION, 0); 1179a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_PALETTE_CTRL, 0); 1180a6b33934Smacallan 1181a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_PIXEL_FMT, pf); 1182a6b33934Smacallan 1183a6b33934Smacallan /* TODO: distinguish between 15 and 16 bit */ 1184a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_8BIT_CTRL, 0); 1185a6b33934Smacallan /* direct colour, linear, 565 */ 1186a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_16BIT_CTRL, 0xc6); 1187a6b33934Smacallan /* direct colour */ 1188a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, DAC_32BIT_CTRL, 3); 1189a6b33934Smacallan 1190a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, 0x10, 2); 1191a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, 0x11, 0); 1192a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, 0x14, 5); 1193a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, 0x08, 1); 1194a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, 0x15, 5); 1195a6b33934Smacallan pnozz_write_dac_ctl_reg(pPnozz, 0x16, 0x63); 1196a6b33934Smacallan 1197a6b33934Smacallan /* whack the CRTC */ 1198a6b33934Smacallan /* we always transfer 64bit in one go */ 1199a6b33934Smacallan crtcline = pPnozz->scanlinesize >> 3; 1200a6b33934Smacallan#if DEBUG 1201a6b33934Smacallan xf86Msg(X_ERROR, "crtcline: %d\n", crtcline); 1202a6b33934Smacallan#endif 1203a6b33934Smacallan pnozz_write_4(pPnozz, VID_HTOTAL, (24 << pPnozz->depthshift) + crtcline); 1204a6b33934Smacallan pnozz_write_4(pPnozz, VID_HSRE, 8 << pPnozz->depthshift); 1205a6b33934Smacallan pnozz_write_4(pPnozz, VID_HBRE, 18 << pPnozz->depthshift); 1206a6b33934Smacallan pnozz_write_4(pPnozz, VID_HBFE, (18 << pPnozz->depthshift) + crtcline); 1207a6b33934Smacallan 1208a6b33934Smacallan#if DEBUG 1209a6b33934Smacallan sscr = pnozz_read_4(pPnozz, SYS_CONF); 1210a6b33934Smacallan xf86Msg(X_ERROR, "scr: %x\n", sscr); 1211a6b33934Smacallan#endif 1212a6b33934Smacallan return TRUE; 1213a6b33934Smacallan} 1214