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