1 /* 2 Copyright 1999, Be Incorporated. All Rights Reserved. 3 This file may be used under the terms of the Be Sample Code License. 4 5 Other authors: 6 Rudolf Cornelissen 4/2003-4/2004 7 */ 8 9 #ifndef DRIVERINTERFACE_H 10 #define DRIVERINTERFACE_H 11 12 #include <Accelerant.h> 13 #include "video_overlay.h" 14 #include <Drivers.h> 15 #include <PCI.h> 16 #include <OS.h> 17 18 #define DRIVER_PREFIX "nm" // apsed 19 20 /* 21 Internal driver state (also for sharing info between driver and accelerant) 22 */ 23 #if defined(__cplusplus) 24 extern "C" { 25 #endif 26 27 typedef struct { 28 sem_id sem; 29 int32 ben; 30 } benaphore; 31 32 #define INIT_BEN(x) x.sem = create_sem(0, "G400 "#x" benaphore"); x.ben = 0; 33 #define AQUIRE_BEN(x) if((atomic_add(&(x.ben), 1)) >= 1) acquire_sem(x.sem); 34 #define RELEASE_BEN(x) if((atomic_add(&(x.ben), -1)) > 1) release_sem(x.sem); 35 #define DELETE_BEN(x) delete_sem(x.sem); 36 37 38 #define NM_PRIVATE_DATA_MAGIC 0x0009 /* a private driver rev, of sorts */ 39 40 /*dualhead extensions to flags*/ 41 #define DUALHEAD_OFF (0<<6) 42 #define DUALHEAD_CLONE (1<<6) 43 #define DUALHEAD_ON (2<<6) 44 #define DUALHEAD_SWITCH (3<<6) 45 #define DUALHEAD_BITS (3<<6) 46 #define DUALHEAD_CAPABLE (1<<8) 47 #define TV_BITS (3<<9) 48 #define TV_MON (0<<9 49 #define TV_PAL (1<<9) 50 #define TV_NTSC (2<<9) 51 #define TV_CAPABLE (1<<11) 52 53 #define SKD_MOVE_CURSOR 0x00000001 54 #define SKD_PROGRAM_CLUT 0x00000002 55 #define SKD_SET_START_ADDR 0x00000004 56 #define SKD_SET_CURSOR 0x00000008 57 #define SKD_HANDLER_INSTALLED 0x80000000 58 59 enum { 60 NM_GET_PRIVATE_DATA = B_DEVICE_OP_CODES_END + 1, 61 NM_GET_PCI, 62 NM_SET_PCI, 63 NM_DEVICE_NAME, 64 NM_RUN_INTERRUPTS, 65 NM_ISA_OUT, 66 NM_ISA_IN, 67 NM_PGM_BES 68 }; 69 70 /* max. number of overlay buffers */ 71 #define MAXBUFFERS 3 72 73 /* internal used info on overlay buffers */ 74 typedef struct 75 { 76 uint16 slopspace; 77 uint32 size; 78 } int_buf_info; 79 80 typedef struct settings { // apsed, see comments in nm.settings 81 // for driver 82 char accelerant[B_FILE_NAME_LENGTH]; 83 bool dumprom; 84 // for accelerant 85 uint32 logmask; 86 uint32 memory; 87 bool usebios; 88 bool hardcursor; 89 } settings; 90 91 /*shared info*/ 92 typedef struct { 93 /*a few ID things*/ 94 uint16 vendor_id; /* PCI vendor ID, from pci_info */ 95 uint16 device_id; /* PCI device ID, from pci_info */ 96 uint8 revision; /* PCI device revsion, from pci_info */ 97 98 /* bug workaround for 4.5.0 */ 99 uint32 use_clone_bugfix; /*for 4.5.0, cloning of physical memory does not work*/ 100 uint32 * clone_bugfix_regs; 101 uint32 * clone_bugfix_regs2; 102 103 /* old cards have their registers mapped inside the framebuffer area */ 104 bool regs_in_fb; 105 106 /*memory mappings*/ 107 area_id regs_area, regs2_area; /* Kernel's area_id for the memory mapped registers. 108 It will be cloned into the accelerant's address 109 space. */ 110 111 area_id fb_area; /* Frame buffer's area_id. The addresses are shared with all teams. */ 112 area_id pseudo_dma_area; /* Pseudo dma area_id. Shared by all teams. */ 113 area_id dma_buffer_area; /* Area assigned for dma*/ 114 115 void *framebuffer; /* As viewed from virtual memory */ 116 void *framebuffer_pci; /* As viewed from the PCI bus (for DMA) */ 117 118 void *pseudo_dma; /* As viewed from virtual memory */ 119 120 void *dma_buffer; /* buffer for dma*/ 121 void *dma_buffer_pci; /* buffer for dma - from PCI bus*/ 122 123 /*screenmode list*/ 124 area_id mode_area; /* Contains the list of display modes the driver supports */ 125 uint32 mode_count; /* Number of display modes in the list */ 126 127 /*flags - used by driver*/ 128 uint32 flags; 129 130 /*vblank semaphore*/ 131 sem_id vblank; /* The vertical blank semaphore. Ownership will be 132 transfered to the team opening the device first */ 133 /*cursor information*/ 134 struct { 135 uint16 hot_x; /* Cursor hot spot. The top left corner of the cursor */ 136 uint16 hot_y; /* is 0,0 */ 137 uint16 x; /* The location of the cursor hot spot on the */ 138 uint16 y; /* desktop */ 139 uint16 width; /* Width and height of the cursor shape (always 16!) */ 140 uint16 height; 141 bool is_visible; /* Is the cursor currently displayed? */ 142 } cursor; 143 144 /*colour lookup table*/ 145 uint8 color_data[3 * 256]; /* Colour lookup table - as used by DAC */ 146 147 /*more display mode stuff*/ 148 display_mode dm; /* current display mode configuration: head1 */ 149 bool acc_mode; /* signals (non)accelerated mode */ 150 151 /*frame buffer config - for BDirectScreen*/ 152 frame_buffer_config fbc; /* bytes_per_row and start of frame buffer: head1 */ 153 154 /*acceleration engine*/ 155 struct { 156 uint32 count; /* last dwgsync slot used */ 157 uint32 last_idle; /* last dwgsync slot we *know* the engine was idle after */ 158 benaphore lock; /* for serializing access to the acceleration engine */ 159 uint32 control; /* colordepth, memory pitch and other config stuff */ 160 uint8 depth; /* bytes per pixel used */ 161 } engine; 162 163 /* card info - information gathered from PINS (and other sources) */ 164 enum 165 { // card_type in order of date of nm chip design 166 NM2070 = 0, 167 NM2090, 168 NM2093, 169 NM2097, 170 NM2160, 171 NM2200, 172 NM2230, 173 NM2360, 174 NM2380, 175 G100, 176 G200 177 }; 178 struct 179 { 180 /* specialised registers for predefined cardspecs */ 181 182 /* general card information */ 183 uint32 card_type; /* see card_type enum above */ 184 185 /* PINS */ 186 float f_ref; /* PLL reference-oscillator frequency (Mhz) */ 187 uint32 max_system_vco; /* graphics engine PLL VCO limits (Mhz) */ 188 uint32 min_system_vco; 189 uint32 max_pixel_vco; /* dac1 PLL VCO limits (Mhz) */ 190 uint32 min_pixel_vco; 191 uint32 std_engine_clock; /* graphics engine clock speed needed (Mhz) */ 192 uint32 max_dac1_clock; /* dac1 limits (Mhz) */ 193 uint32 max_dac1_clock_8; /* dac1 limits correlated to RAMspeed limits (Mhz) */ 194 uint32 max_dac1_clock_16; 195 uint32 max_dac1_clock_24; 196 uint32 memory_size; /* memory (Kbytes) */ 197 uint32 curmem_size; /* memory (bytes) */ 198 uint16 max_crtc_width; /* CRTC max constraints */ 199 uint16 max_crtc_height; 200 uint8 panel_type; /* panel type */ 201 uint16 panel_width; /* panel size */ 202 uint16 panel_height; 203 uint8 outputs; /* in BIOS preselected output(s) */ 204 } ps; 205 206 /*mirror of the ROM (copied in driver, because may not be mapped permanently - only over fb)*/ 207 uint8 rom_mirror[32768]; 208 209 /* apsed: some configuration settings from ~/config/settings/kernel/drivers/nm.settings if exists */ 210 settings settings; 211 212 struct 213 { 214 overlay_buffer myBuffer[MAXBUFFERS];/* scaler input buffers */ 215 int_buf_info myBufInfo[MAXBUFFERS]; /* extra info on scaler input buffers */ 216 overlay_token myToken; /* scaler is free/in use */ 217 benaphore lock; /* for creating buffers and aquiring overlay unit routines */ 218 } overlay; 219 220 } shared_info; 221 222 /* Read or write a value in PCI configuration space */ 223 typedef struct { 224 uint32 magic; /* magic number to make sure the caller groks us */ 225 uint32 offset; /* Offset to read/write */ 226 uint32 size; /* Number of bytes to transfer */ 227 uint32 value; /* The value read or written */ 228 } nm_get_set_pci; 229 230 /* Read or write a value in ISA I/O space */ 231 typedef struct { 232 uint32 magic; /* magic number to make sure the caller groks us */ 233 uint16 adress; /* Offset to read/write */ 234 uint8 size; /* Number of bytes to transfer */ 235 uint16 data; /* The value read or written */ 236 } nm_in_out_isa; 237 238 /* setup ISA BES registers for overlay on ISA cards */ 239 typedef struct { 240 uint32 magic; /* magic number to make sure the caller groks us */ 241 uint32 card_type; /* see card_type enum above */ 242 uint32 hcoordv; 243 uint32 vcoordv; 244 uint32 hiscalv; 245 uint32 viscalv; 246 uint32 hsrcstv; 247 uint32 hsrcendv; 248 uint32 hsrclstv; 249 uint32 a1orgv; 250 uint32 globctlv; 251 uint32 v1wghtv; 252 uint32 weight; 253 uint32 v1srclstv; 254 uint8 colkey_r; 255 uint8 colkey_g; 256 uint8 colkey_b; 257 uint16 ob_width; 258 } nm_bes_data; 259 260 /* Set some boolean condition (like enabling or disabling interrupts) */ 261 typedef struct { 262 uint32 magic; /* magic number to make sure the caller groks us */ 263 bool do_it; /* state to set */ 264 } nm_set_bool_state; 265 266 /* Retrieve the area_id of the kernel/accelerant shared info */ 267 typedef struct { 268 uint32 magic; /* magic number to make sure the caller groks us */ 269 area_id shared_info_area; /* area_id containing the shared information */ 270 } nm_get_private_data; 271 272 /* Retrieve the device name. Usefull for when we have a file handle, but want 273 to know the device name (like when we are cloning the accelerant) */ 274 typedef struct { 275 uint32 magic; /* magic number to make sure the caller groks us */ 276 char *name; /* The name of the device, less the /dev root */ 277 } nm_device_name; 278 279 enum { 280 281 _WAIT_FOR_VBLANK = (1 << 0) 282 }; 283 284 #if defined(__cplusplus) 285 } 286 #endif 287 288 289 #endif 290