xref: /haiku/src/add-ons/accelerants/radeon/GetModeInfo.c (revision 1e36cfc2721ef13a187c6f7354dc9cbc485e89d3)
1 /*
2 	Copyright (c) 2002, Thomas Kurschel
3 
4 
5 	Part of Radeon accelerant
6 
7 	Public mode-specific info functions
8 */
9 
10 
11 #include "radeon_accelerant.h"
12 #include "GlobalData.h"
13 #include "generic.h"
14 #include <GraphicsDefs.h>
15 
16 
17 // public function: return current display mode
18 status_t GET_DISPLAY_MODE( display_mode *current_mode )
19 {
20 	virtual_card *vc = ai->vc;
21 
22 	// TBD: there is a race condition if someone else is just setting it
23 	//      we won't lock up but return non-sense
24 
25 	*current_mode = vc->mode;
26 
27 	// we hide multi-monitor-mode because :-
28 	// - we want to look like an ordinary single-screen driver
29 	// - the multi-mode is already adapted to current screen configuration,
30 	//   and the mode should be configuration-independant
31 	Radeon_HideMultiMode( vc, current_mode );
32 
33 	return B_OK;
34 }
35 
36 // public function: return configuration of frame buffer
37 status_t GET_FRAME_BUFFER_CONFIG( frame_buffer_config *afb )
38 {
39 	virtual_card *vc = ai->vc;
40 
41 	// TBD: race condition again
42 
43 	// easy again, as the last mode set stored the info in a convienient form
44 	*afb = vc->fbc;
45 	return B_OK;
46 }
47 
48 // public function: return clock limits for given display mode
49 status_t GET_PIXEL_CLOCK_LIMITS(display_mode *dm, uint32 *low, uint32 *high)
50 {
51 	// we ignore stuff like DVI/LCD restrictions -
52 	// they are handled	automatically on set_display_mode
53 	uint32 total_pix = (uint32)dm->timing.h_total * (uint32)dm->timing.v_total;
54 	uint32 clock_limit = ai->si->pll.max_pll_freq * 10;
55 
56 	/* lower limit of about 48Hz vertical refresh */
57 	*low = (total_pix * 48L) / 1000L;
58 	if (*low > clock_limit)
59 		return B_ERROR;
60 
61 	*high = clock_limit;
62 	return B_OK;
63 }
64 
65 /*
66 	Return the semaphore id that will be used to signal a vertical retrace
67 	occured.
68 */
69 sem_id ACCELERANT_RETRACE_SEMAPHORE(void)
70 {
71 	virtual_card *vc = ai->vc;
72 
73 	/*
74 	NOTE:
75 		The kernel driver created this for us.  We don't know if the system is
76 		using real interrupts, or if we're faking it, and we don't care.
77 		If we choose not to support this at all, we'd just return B_ERROR here,
78 		and the user wouldn't get any kind of vertical retrace support.
79 	*/
80 	// with multi-monitor mode, we have two vertical blanks!
81 	// until we find a better solution, we always return virtual port 0,
82 	// which may be either physical port 0 or 1
83 	int crtc_idx;
84 
85 	if( vc->used_crtc[0] )
86 		crtc_idx = 0;
87 	else
88 		crtc_idx = 1;
89 
90 	//SHOW_INFO( 3, "semaphore: %x", ai->si->ports[physical_port].vblank );
91 
92 	return ai->si->crtc[crtc_idx].vblank;
93 	//return B_ERROR;
94 }
95