1*a56bc488SPhilippe Houdoin /* 2*a56bc488SPhilippe Houdoin * Copyright 2007-2010 Haiku, Inc. All rights reserved. 3*a56bc488SPhilippe Houdoin * Distributed under the terms of the MIT license. 4*a56bc488SPhilippe Houdoin * 5*a56bc488SPhilippe Houdoin * Authors: 6*a56bc488SPhilippe Houdoin * Gerald Zajac 7*a56bc488SPhilippe Houdoin */ 8*a56bc488SPhilippe Houdoin 9*a56bc488SPhilippe Houdoin #ifndef DRIVERINTERFACE_H 10*a56bc488SPhilippe Houdoin #define DRIVERINTERFACE_H 11*a56bc488SPhilippe Houdoin 12*a56bc488SPhilippe Houdoin 13*a56bc488SPhilippe Houdoin #include <Accelerant.h> 14*a56bc488SPhilippe Houdoin #include <GraphicsDefs.h> 15*a56bc488SPhilippe Houdoin #include <Drivers.h> 16*a56bc488SPhilippe Houdoin #include <edid.h> 17*a56bc488SPhilippe Houdoin #include <video_overlay.h> 18*a56bc488SPhilippe Houdoin 19*a56bc488SPhilippe Houdoin 20*a56bc488SPhilippe Houdoin // This file contains info that is shared between the kernel driver and the 21*a56bc488SPhilippe Houdoin // accelerant, and info that is shared among the source files of the accelerant. 22*a56bc488SPhilippe Houdoin 23*a56bc488SPhilippe Houdoin 24*a56bc488SPhilippe Houdoin #define ENABLE_DEBUG_TRACE // if defined, turns on debug output to syslog 25*a56bc488SPhilippe Houdoin 26*a56bc488SPhilippe Houdoin 27*a56bc488SPhilippe Houdoin struct Benaphore { 28*a56bc488SPhilippe Houdoin sem_id sem; 29*a56bc488SPhilippe Houdoin int32 count; 30*a56bc488SPhilippe Houdoin InitBenaphore31*a56bc488SPhilippe Houdoin status_t Init(const char* name) 32*a56bc488SPhilippe Houdoin { 33*a56bc488SPhilippe Houdoin count = 0; 34*a56bc488SPhilippe Houdoin sem = create_sem(0, name); 35*a56bc488SPhilippe Houdoin return sem < 0 ? sem : B_OK; 36*a56bc488SPhilippe Houdoin } 37*a56bc488SPhilippe Houdoin AcquireBenaphore38*a56bc488SPhilippe Houdoin status_t Acquire() 39*a56bc488SPhilippe Houdoin { 40*a56bc488SPhilippe Houdoin if (atomic_add(&count, 1) > 0) 41*a56bc488SPhilippe Houdoin return acquire_sem(sem); 42*a56bc488SPhilippe Houdoin return B_OK; 43*a56bc488SPhilippe Houdoin } 44*a56bc488SPhilippe Houdoin ReleaseBenaphore45*a56bc488SPhilippe Houdoin status_t Release() 46*a56bc488SPhilippe Houdoin { 47*a56bc488SPhilippe Houdoin if (atomic_add(&count, -1) > 1) 48*a56bc488SPhilippe Houdoin return release_sem(sem); 49*a56bc488SPhilippe Houdoin return B_OK; 50*a56bc488SPhilippe Houdoin } 51*a56bc488SPhilippe Houdoin DeleteBenaphore52*a56bc488SPhilippe Houdoin void Delete() { delete_sem(sem); } 53*a56bc488SPhilippe Houdoin }; 54*a56bc488SPhilippe Houdoin 55*a56bc488SPhilippe Houdoin 56*a56bc488SPhilippe Houdoin #define TDFX_PRIVATE_DATA_MAGIC 0x5042 57*a56bc488SPhilippe Houdoin 58*a56bc488SPhilippe Houdoin 59*a56bc488SPhilippe Houdoin enum { 60*a56bc488SPhilippe Houdoin TDFX_GET_SHARED_DATA = B_DEVICE_OP_CODES_END + 123, 61*a56bc488SPhilippe Houdoin TDFX_DEVICE_NAME, 62*a56bc488SPhilippe Houdoin TDFX_GET_PIO_REG, 63*a56bc488SPhilippe Houdoin TDFX_SET_PIO_REG 64*a56bc488SPhilippe Houdoin }; 65*a56bc488SPhilippe Houdoin 66*a56bc488SPhilippe Houdoin 67*a56bc488SPhilippe Houdoin // Chip type numbers. These are used to group the chips into related 68*a56bc488SPhilippe Houdoin // groups. See table chipTable in driver.c 69*a56bc488SPhilippe Houdoin 70*a56bc488SPhilippe Houdoin enum ChipType { 71*a56bc488SPhilippe Houdoin TDFX_NONE = 0, 72*a56bc488SPhilippe Houdoin 73*a56bc488SPhilippe Houdoin BANSHEE, 74*a56bc488SPhilippe Houdoin VOODOO_3, 75*a56bc488SPhilippe Houdoin VOODOO_5, 76*a56bc488SPhilippe Houdoin }; 77*a56bc488SPhilippe Houdoin 78*a56bc488SPhilippe Houdoin 79*a56bc488SPhilippe Houdoin struct PIORegInfo { 80*a56bc488SPhilippe Houdoin uint32 magic; // magic number 81*a56bc488SPhilippe Houdoin uint32 offset; // offset of register in PIO register area 82*a56bc488SPhilippe Houdoin int16 index; // index of value to read/write; < 0 if not indexed reg 83*a56bc488SPhilippe Houdoin uint8 value; // value to write or value that was read 84*a56bc488SPhilippe Houdoin }; 85*a56bc488SPhilippe Houdoin 86*a56bc488SPhilippe Houdoin 87*a56bc488SPhilippe Houdoin struct DisplayModeEx : display_mode { 88*a56bc488SPhilippe Houdoin uint8 bitsPerPixel; 89*a56bc488SPhilippe Houdoin uint8 bytesPerPixel; 90*a56bc488SPhilippe Houdoin uint16 bytesPerRow; // number of bytes in one line/row 91*a56bc488SPhilippe Houdoin }; 92*a56bc488SPhilippe Houdoin 93*a56bc488SPhilippe Houdoin 94*a56bc488SPhilippe Houdoin struct OverlayBuffer : overlay_buffer { 95*a56bc488SPhilippe Houdoin OverlayBuffer* nextBuffer; // pointer to next buffer in chain, NULL = none 96*a56bc488SPhilippe Houdoin uint32 size; // size of overlay buffer 97*a56bc488SPhilippe Houdoin }; 98*a56bc488SPhilippe Houdoin 99*a56bc488SPhilippe Houdoin 100*a56bc488SPhilippe Houdoin struct SharedInfo { 101*a56bc488SPhilippe Houdoin // Device ID info. 102*a56bc488SPhilippe Houdoin uint16 vendorID; // PCI vendor ID, from pci_info 103*a56bc488SPhilippe Houdoin uint16 deviceID; // PCI device ID, from pci_info 104*a56bc488SPhilippe Houdoin uint8 revision; // PCI device revsion, from pci_info 105*a56bc488SPhilippe Houdoin ChipType chipType; // indicates group in which chip belongs (a group has similar functionality) 106*a56bc488SPhilippe Houdoin char chipName[32]; // user recognizable name of chip 107*a56bc488SPhilippe Houdoin 108*a56bc488SPhilippe Houdoin bool bAccelerantInUse; // true = accelerant has been initialized 109*a56bc488SPhilippe Houdoin 110*a56bc488SPhilippe Houdoin // Memory mappings. 111*a56bc488SPhilippe Houdoin area_id regsArea; // area_id for the memory mapped registers. It will 112*a56bc488SPhilippe Houdoin // be cloned into accelerant's address space. 113*a56bc488SPhilippe Houdoin area_id videoMemArea; // video memory area_id. The addresses are shared with all teams. 114*a56bc488SPhilippe Houdoin addr_t videoMemAddr; // video memory addr as viewed from virtual memory 115*a56bc488SPhilippe Houdoin phys_addr_t videoMemPCI; // video memory addr as viewed from the PCI bus (for DMA) 116*a56bc488SPhilippe Houdoin uint32 videoMemSize; // video memory size in bytes. 117*a56bc488SPhilippe Houdoin 118*a56bc488SPhilippe Houdoin uint32 cursorOffset; // offset of cursor in video memory 119*a56bc488SPhilippe Houdoin uint32 frameBufferOffset; // offset of frame buffer in video memory 120*a56bc488SPhilippe Houdoin uint32 maxFrameBufferSize; // max available video memory for frame buffer 121*a56bc488SPhilippe Houdoin 122*a56bc488SPhilippe Houdoin // Color spaces supported by current video chip/driver. 123*a56bc488SPhilippe Houdoin color_space colorSpaces[6]; 124*a56bc488SPhilippe Houdoin uint32 colorSpaceCount; // number of color spaces in array colorSpaces 125*a56bc488SPhilippe Houdoin 126*a56bc488SPhilippe Houdoin uint32 maxPixelClock; // max pixel clock of current chip in KHz 127*a56bc488SPhilippe Houdoin 128*a56bc488SPhilippe Houdoin // List of screen modes. 129*a56bc488SPhilippe Houdoin area_id modeArea; // area containing list of display modes the driver supports 130*a56bc488SPhilippe Houdoin uint32 modeCount; // number of display modes in the list 131*a56bc488SPhilippe Houdoin 132*a56bc488SPhilippe Houdoin DisplayModeEx displayMode; // current display mode configuration 133*a56bc488SPhilippe Houdoin 134*a56bc488SPhilippe Houdoin uint16 cursorHotX; // Cursor hot spot. Top left corner of the cursor 135*a56bc488SPhilippe Houdoin uint16 cursorHotY; // is 0,0 136*a56bc488SPhilippe Houdoin 137*a56bc488SPhilippe Houdoin edid1_info edidInfo; 138*a56bc488SPhilippe Houdoin bool bHaveEDID; // true = EDID info from device is in edidInfo 139*a56bc488SPhilippe Houdoin 140*a56bc488SPhilippe Houdoin Benaphore engineLock; // for access to the acceleration engine 141*a56bc488SPhilippe Houdoin Benaphore overlayLock; // for overlay operations 142*a56bc488SPhilippe Houdoin 143*a56bc488SPhilippe Houdoin int32 overlayAllocated; // non-zero if overlay is allocated 144*a56bc488SPhilippe Houdoin uint32 overlayToken; 145*a56bc488SPhilippe Houdoin OverlayBuffer* overlayBuffer; // pointer to linked list of buffers; NULL = none 146*a56bc488SPhilippe Houdoin }; 147*a56bc488SPhilippe Houdoin 148*a56bc488SPhilippe Houdoin 149*a56bc488SPhilippe Houdoin #endif // DRIVERINTERFACE_H 150