2 Copyright 1999, Be Incorporated. All Rights Reserved.
3 This file may be used under the terms of the Be Sample Code License.
6 Rudolf Cornelissen 4/2003-1/2006
9 #ifndef DRIVERINTERFACE_H
10 #define DRIVERINTERFACE_H
12 #include <Accelerant.h>
13 #include "video_overlay.h"
18 #define DRIVER_PREFIX "neomagic"
21 Internal driver state (also for sharing info between driver and accelerant)
23 #if defined(__cplusplus)
32 #define INIT_BEN(x) x.sem = create_sem(0, "NM "#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);
38 #define NM_PRIVATE_DATA_MAGIC 0x0009 /* a private driver rev, of sorts */
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)
50 #define TV_NTSC (2<<9)
51 #define TV_CAPABLE (1<<11)
52 #define TV_VIDEO (1<<12)
53 #define TV_PRIMARY (1<<13)
55 #define SKD_MOVE_CURSOR 0x00000001
56 #define SKD_PROGRAM_CLUT 0x00000002
57 #define SKD_SET_START_ADDR 0x00000004
58 #define SKD_SET_CURSOR 0x00000008
59 #define SKD_HANDLER_INSTALLED 0x80000000
62 NM_GET_PRIVATE_DATA
= B_DEVICE_OP_CODES_END
+ 1,
72 /* max. number of overlay buffers */
75 /* internal used info on overlay buffers */
82 typedef struct settings
{ // apsed, see comments in nm.settings
84 char accelerant
[B_FILE_NAME_LENGTH
];
96 uint16 vendor_id
; /* PCI vendor ID, from pci_info */
97 uint16 device_id
; /* PCI device ID, from pci_info */
98 uint8 revision
; /* PCI device revsion, from pci_info */
100 /* used to return status for INIT_ACCELERANT and CLONE_ACCELERANT */
101 bool accelerant_in_use
;
103 /* bug workaround for 4.5.0 */
104 uint32 use_clone_bugfix
; /*for 4.5.0, cloning of physical memory does not work*/
105 uint32
* clone_bugfix_regs
;
106 uint32
* clone_bugfix_regs2
;
108 /* old cards have their registers mapped inside the framebuffer area */
112 area_id regs_area
, regs2_area
; /* Kernel's area_id for the memory mapped registers.
113 It will be cloned into the accelerant's address
116 area_id fb_area
; /* Frame buffer's area_id. The addresses are shared with all teams. */
117 area_id pseudo_dma_area
; /* Pseudo dma area_id. Shared by all teams. */
118 area_id dma_buffer_area
; /* Area assigned for dma*/
120 void *framebuffer
; /* As viewed from virtual memory */
121 void *framebuffer_pci
; /* As viewed from the PCI bus (for DMA) */
123 void *pseudo_dma
; /* As viewed from virtual memory */
125 void *dma_buffer
; /* buffer for dma*/
126 void *dma_buffer_pci
; /* buffer for dma - from PCI bus*/
129 area_id mode_area
; /* Contains the list of display modes the driver supports */
130 uint32 mode_count
; /* Number of display modes in the list */
132 /*flags - used by driver*/
136 sem_id vblank
; /* The vertical blank semaphore. Ownership will be
137 transfered to the team opening the device first */
138 /*cursor information*/
140 uint16 hot_x
; /* Cursor hot spot. The top left corner of the cursor */
141 uint16 hot_y
; /* is 0,0 */
142 uint16 x
; /* The location of the cursor hot spot on the */
143 uint16 y
; /* desktop */
144 uint16 width
; /* Width and height of the cursor shape (always 16!) */
146 bool is_visible
; /* Is the cursor currently displayed? */
149 /*colour lookup table*/
150 uint8 color_data
[3 * 256]; /* Colour lookup table - as used by DAC */
152 /*more display mode stuff*/
153 display_mode dm
; /* current display mode configuration: head1 */
154 uint32 dpms_flags
; /* current DPMS mode */
155 bool acc_mode
; /* signals (non)accelerated mode */
157 /*frame buffer config - for BDirectScreen*/
158 frame_buffer_config fbc
; /* bytes_per_row and start of frame buffer: head1 */
159 accelerant_device_info adi
; /* as returned by hook GET_ACCELERANT_DEVICE_INFO */
161 /*acceleration engine*/
163 uint32 count
; /* last dwgsync slot used */
164 uint32 last_idle
; /* last dwgsync slot we *know* the engine was idle after */
165 benaphore lock
; /* for serializing access to the acceleration engine */
166 uint32 control
; /* colordepth, memory pitch and other config stuff */
167 uint8 depth
; /* bytes per pixel used */
170 /* card info - information gathered from PINS (and other sources) */
172 { // card_type in order of date of nm chip design
185 /* specialised registers for predefined cardspecs */
187 /* general card information */
188 uint32 card_type
; /* see card_type enum above */
189 bool int_assigned
; /* card has a useable INT assigned to it */
192 float f_ref
; /* PLL reference-oscillator frequency (Mhz) */
193 uint32 max_system_vco
; /* graphics engine PLL VCO limits (Mhz) */
194 uint32 min_system_vco
;
195 uint32 max_pixel_vco
; /* dac1 PLL VCO limits (Mhz) */
196 uint32 min_pixel_vco
;
197 uint32 std_engine_clock
; /* graphics engine clock speed needed (Mhz) */
198 uint32 max_dac1_clock
; /* dac1 limits (Mhz) */
199 uint32 max_dac1_clock_8
; /* dac1 limits correlated to RAMspeed limits (Mhz) */
200 uint32 max_dac1_clock_16
;
201 uint32 max_dac1_clock_24
;
202 uint32 memory_size
; /* memory (Kbytes) */
203 uint32 curmem_size
; /* memory (bytes) */
204 uint16 max_crtc_width
; /* CRTC max constraints */
205 uint16 max_crtc_height
;
206 uint8 panel_type
; /* panel type */
207 uint16 panel_width
; /* panel size */
209 uint8 outputs
; /* in BIOS preselected output(s) */
212 /*mirror of the ROM (copied in driver, because may not be mapped permanently - only over fb)*/
213 uint8 rom_mirror
[65536];
215 /* apsed: some configuration settings from ~/config/settings/kernel/drivers/nm.settings if exists */
220 overlay_buffer myBuffer
[MAXBUFFERS
];/* scaler input buffers */
221 int_buf_info myBufInfo
[MAXBUFFERS
]; /* extra info on scaler input buffers */
222 overlay_token myToken
; /* scaler is free/in use */
223 benaphore lock
; /* for creating buffers and aquiring overlay unit routines */
224 /* variables needed for virtualscreens (move_overlay()): */
225 bool active
; /* true is overlay currently in use */
226 overlay_window ow
; /* current position of overlay output window */
227 overlay_buffer ob
; /* current inputbuffer in use */
228 overlay_view my_ov
; /* current corrected view in inputbuffer */
229 uint32 h_ifactor
; /* current 'unclipped' horizontal inverse scaling factor */
230 uint32 v_ifactor
; /* current 'unclipped' vertical inverse scaling factor */
234 /* Read or write a value in PCI configuration space */
236 uint32 magic
; /* magic number to make sure the caller groks us */
237 uint32 offset
; /* Offset to read/write */
238 uint32 size
; /* Number of bytes to transfer */
239 uint32 value
; /* The value read or written */
242 /* Read or write a value in ISA I/O space */
244 uint32 magic
; /* magic number to make sure the caller groks us */
245 uint16 adress
; /* Offset to read/write */
246 uint8 size
; /* Number of bytes to transfer */
247 uint16 data
; /* The value read or written */
250 /* move_overlay related info */
252 uint32 hcoordv
; /* left and right edges of video output window */
253 uint32 vcoordv
; /* top and bottom edges of video output window */
254 uint32 hsrcendv
; /* horizontal source end in source buffer (clipping) */
255 uint32 a1orgv
; /* vertical source clipping via startadress of source buffer */
258 /* setup ISA BES registers for overlay on ISA cards */
260 uint32 magic
; /* magic number to make sure the caller groks us */
261 uint32 card_type
; /* see card_type enum above */
270 move_overlay_info moi
;
274 /* Set some boolean condition (like enabling or disabling interrupts) */
276 uint32 magic
; /* magic number to make sure the caller groks us */
277 bool do_it
; /* state to set */
280 /* Retrieve the area_id of the kernel/accelerant shared info */
282 uint32 magic
; /* magic number to make sure the caller groks us */
283 area_id shared_info_area
; /* area_id containing the shared information */
284 } nm_get_private_data
;
286 /* Retrieve the device name. Usefull for when we have a file handle, but want
287 to know the device name (like when we are cloning the accelerant) */
289 uint32 magic
; /* magic number to make sure the caller groks us */
290 char *name
; /* The name of the device, less the /dev root */
295 _WAIT_FOR_VBLANK
= (1 << 0)
298 #if defined(__cplusplus)