2 Copyright 1999, Be Incorporated. All Rights Reserved.
3 This file may be used under the terms of the Be Sample Code License.
8 Rudolf Cornelissen 10/2002-1/2016.
11 #ifndef DRIVERINTERFACE_H
12 #define DRIVERINTERFACE_H
14 #include <Accelerant.h>
15 #include "video_overlay.h"
21 #define DRIVER_PREFIX "via"
24 Internal driver state (also for sharing info between driver and accelerant)
26 #if defined(__cplusplus)
35 #define INIT_BEN(x) x.sem = create_sem(0, "NV "#x" benaphore"); x.ben = 0;
36 #define AQUIRE_BEN(x) if((atomic_add(&(x.ben), 1)) >= 1) acquire_sem(x.sem);
37 #define RELEASE_BEN(x) if((atomic_add(&(x.ben), -1)) > 1) release_sem(x.sem);
38 #define DELETE_BEN(x) delete_sem(x.sem);
41 #define VIA_PRIVATE_DATA_MAGIC 0x0009 /* a private driver rev, of sorts */
43 /*dualhead extensions to flags*/
44 #define DUALHEAD_OFF (0<<6)
45 #define DUALHEAD_CLONE (1<<6)
46 #define DUALHEAD_ON (2<<6)
47 #define DUALHEAD_SWITCH (3<<6)
48 #define DUALHEAD_BITS (3<<6)
49 #define DUALHEAD_CAPABLE (1<<8)
50 #define TV_BITS (3<<9)
53 #define TV_NTSC (2<<9)
54 #define TV_CAPABLE (1<<11)
55 #define TV_VIDEO (1<<12)
57 #define SKD_MOVE_CURSOR 0x00000001
58 #define SKD_PROGRAM_CLUT 0x00000002
59 #define SKD_SET_START_ADDR 0x00000004
60 #define SKD_SET_CURSOR 0x00000008
61 #define SKD_HANDLER_INSTALLED 0x80000000
64 ENG_GET_PRIVATE_DATA
= B_DEVICE_OP_CODES_END
+ 1,
75 /* max. number of overlay buffers */
78 /* internal used info on overlay buffers */
85 typedef struct settings
{ // apsed, see comments in skel.settings
87 char accelerant
[B_FILE_NAME_LENGTH
];
100 /* card info - information gathered from PINS (and other sources) */
102 { // card_type in order of date of VIA chip design (fixme: check order)
136 { // card_arch in order of date of VIA chip design
147 { // tvout_chip_type in order of capability (more or less)
170 uint16 vendor_id
; /* PCI vendor ID, from pci_info */
171 uint16 device_id
; /* PCI device ID, from pci_info */
172 uint8 revision
; /* PCI device revsion, from pci_info */
173 uint8 bus
; /* PCI bus number, from pci_info */
174 uint8 device
; /* PCI device number on bus, from pci_info */
175 uint8 function
; /* PCI function number in device, from pci_info */
177 /* bug workaround for 4.5.0 */
178 uint32 use_clone_bugfix
; /*for 4.5.0, cloning of physical memory does not work*/
179 uint32
* clone_bugfix_regs
;
182 area_id regs_area
; /* Kernel's area_id for the memory mapped registers.
183 It will be cloned into the accelerant's address
186 area_id fb_area
; /* Frame buffer's area_id. The addresses are shared with all teams. */
187 area_id pseudo_dma_area
; /* Pseudo dma area_id. Shared by all teams. */
188 area_id dma_buffer_area
; /* Area assigned for dma*/
190 void *framebuffer
; /* As viewed from virtual memory */
191 void *framebuffer_pci
; /* As viewed from the PCI bus (for DMA) */
193 void *pseudo_dma
; /* As viewed from virtual memory */
195 void *dma_buffer
; /* buffer for dma*/
196 void *dma_buffer_pci
; /* buffer for dma - from PCI bus*/
199 area_id mode_area
; /* Contains the list of display modes the driver supports */
200 uint32 mode_count
; /* Number of display modes in the list */
202 /*flags - used by driver*/
206 sem_id vblank
; /* The vertical blank semaphore. Ownership will be
207 transfered to the team opening the device first */
208 /*cursor information*/
210 uint16 hot_x
; /* Cursor hot spot. The top left corner of the cursor */
211 uint16 hot_y
; /* is 0,0 */
212 uint16 x
; /* The location of the cursor hot spot on the */
213 uint16 y
; /* desktop */
214 uint16 width
; /* Width and height of the cursor shape (always 16!) */
216 bool is_visible
; /* Is the cursor currently displayed? */
217 bool dh_right
; /* Is cursor on right side of stretched screen? */
220 /*colour lookup table*/
221 uint8 color_data
[3 * 256]; /* Colour lookup table - as used by DAC */
223 /*more display mode stuff*/
224 display_mode dm
; /* current display mode configuration: head1 */
225 display_mode dm2
; /* current display mode configuration: head2 */
226 bool acc_mode
; /* signals (non)accelerated mode */
227 bool interlaced_tv_mode
;/* signals interlaced CRTC TV output mode */
228 bool crtc_switch_mode
; /* signals dualhead switch mode if panels are used */
230 /*frame buffer config - for BDirectScreen*/
231 frame_buffer_config fbc
; /* bytes_per_row and start of frame buffer: head1 */
232 frame_buffer_config fbc2
; /* bytes_per_row and start of frame buffer: head2 */
234 /*acceleration engine*/
236 uint32 count
; /* last dwgsync slot used */
237 uint32 last_idle
; /* last dwgsync slot we *know* the engine was idle after */
238 benaphore lock
; /* for serializing access to the acceleration engine */
243 /* specialised registers for card initialisation read from NV BIOS (pins) */
245 /* general card information */
246 uint32 card_type
; /* see card_type enum above */
247 uint32 card_arch
; /* see card_arch enum above */
248 uint8 chip_rev
; /* chip revision number */
249 bool laptop
; /* mobile chipset or not ('internal' flatpanel!) */
250 bool slaved_tmds1
; /* external TMDS encoder active on CRTC1 */
251 bool slaved_tmds2
; /* external TMDS encoder active on CRTC2 */
252 bool master_tmds1
; /* on die TMDS encoder active on CRTC1 */
253 bool master_tmds2
; /* on die TMDS encoder active on CRTC2 */
254 bool tmds1_active
; /* found panel on CRTC1 that is active */
255 bool tmds2_active
; /* found panel on CRTC2 that is active */
256 display_timing p1_timing
; /* 'modeline' fetched for panel 1 */
257 display_timing p2_timing
; /* 'modeline' fetched for panel 2 */
258 float panel1_aspect
; /* panel's aspect ratio */
259 float panel2_aspect
; /* panel's aspect ratio */
260 bool crtc2_prim
; /* using CRTC2 as primary CRTC */
261 uint32 tvout_chip_type
; /* see tvchip_type enum above */
262 uint8 monitors
; /* output devices connection matrix */
263 status_t pins_status
; /* B_OK if read correctly, B_ERROR if faked */
266 float f_ref
; /* PLL reference-oscillator frequency (Mhz) */
267 bool ext_pll
; /* the extended PLL contains more dividers */
268 uint32 max_system_vco
; /* graphics engine PLL VCO limits (Mhz) */
269 uint32 min_system_vco
;
270 uint32 max_pixel_vco
; /* dac1 PLL VCO limits (Mhz) */
271 uint32 min_pixel_vco
;
272 uint32 max_video_vco
; /* dac2 PLL VCO limits (Mhz) */
273 uint32 min_video_vco
;
274 uint32 std_engine_clock
; /* graphics engine clock speed needed (Mhz) */
275 uint32 std_memory_clock
; /* card memory clock speed needed (Mhz) */
276 uint32 max_dac1_clock
; /* dac1 limits (Mhz) */
277 uint32 max_dac1_clock_8
; /* dac1 limits correlated to RAMspeed limits (Mhz) */
278 uint32 max_dac1_clock_16
;
279 uint32 max_dac1_clock_24
;
280 uint32 max_dac1_clock_32
;
281 uint32 max_dac1_clock_32dh
;
282 uint32 max_dac2_clock
; /* dac2 limits (Mhz) */
283 uint32 max_dac2_clock_8
; /* dac2, maven limits correlated to RAMspeed limits (Mhz) */
284 uint32 max_dac2_clock_16
;
285 uint32 max_dac2_clock_24
;
286 uint32 max_dac2_clock_32
;
287 uint32 max_dac2_clock_32dh
;
288 bool secondary_head
; /* presence of functions */
292 uint32 memory_size
; /* memory (in bytes) */
295 /* mirror of the ROM (copied in driver, because may not be mapped permanently) */
296 uint8 rom_mirror
[65536];
298 /* some configuration settings from ~/config/settings/kernel/drivers/skel.settings if exists */
303 overlay_buffer myBuffer
[MAXBUFFERS
];/* scaler input buffers */
304 int_buf_info myBufInfo
[MAXBUFFERS
]; /* extra info on scaler input buffers */
305 overlay_token myToken
; /* scaler is free/in use */
306 benaphore lock
; /* for creating buffers and aquiring overlay unit routines */
307 bool crtc
; /* location of overlay unit */
308 /* variables needed for virtualscreens (move_overlay()): */
309 bool active
; /* true is overlay currently in use */
310 overlay_window ow
; /* current position of overlay output window */
311 overlay_buffer ob
; /* current inputbuffer in use */
312 overlay_view my_ov
; /* current corrected view in inputbuffer */
313 uint32 h_ifactor
; /* current 'unclipped' horizontal inverse scaling factor */
314 uint32 v_ifactor
; /* current 'unclipped' vertical inverse scaling factor */
319 /* Read or write a value in PCI configuration space */
321 uint32 magic
; /* magic number to make sure the caller groks us */
322 uint32 offset
; /* Offset to read/write */
323 uint32 size
; /* Number of bytes to transfer */
324 uint32 value
; /* The value read or written */
327 /* Set some boolean condition (like enabling or disabling interrupts) */
329 uint32 magic
; /* magic number to make sure the caller groks us */
330 bool do_it
; /* state to set */
331 } eng_set_bool_state
;
333 /* Retrieve the area_id of the kernel/accelerant shared info */
335 uint32 magic
; /* magic number to make sure the caller groks us */
336 area_id shared_info_area
; /* area_id containing the shared information */
337 } eng_get_private_data
;
339 /* Retrieve the device name. Usefull for when we have a file handle, but want
340 to know the device name (like when we are cloning the accelerant) */
342 uint32 magic
; /* magic number to make sure the caller groks us */
343 char *name
; /* The name of the device, less the /dev root */
346 /* Retrieve an AGP device interface if there. Usefull to find the AGP speed scheme
347 used (pre 3.x or 3.x) */
349 uint32 magic
; /* magic number to make sure the caller groks us */
350 bool agp_bus
;/* indicates if we have access to the AGP busmanager */
351 uint8 index
; /* device index in list of devices found */
352 bool exist
; /* we got AGP device info */
353 agp_info agpi
; /* AGP interface info of a device */
356 /* Execute an AGP command */
358 uint32 magic
; /* magic number to make sure the caller groks us */
359 bool agp_bus
;/* indicates if we have access to the AGP busmanager */
360 uint32 cmd
; /* actual command to execute */
363 /* Read or write a value in ISA I/O space */
365 uint32 magic
; /* magic number to make sure the caller groks us */
366 uint16 adress
; /* Offset to read/write */
367 uint8 size
; /* Number of bytes to transfer */
368 uint16 data
; /* The value read or written */
373 _WAIT_FOR_VBLANK
= (1 << 0)
376 #if defined(__cplusplus)