xref: /haiku/src/add-ons/accelerants/neomagic/GetModeInfo.c (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
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-1/2006
7 */
8 
9 #define MODULE_BIT 0x02000000
10 
11 #include "acc_std.h"
12 
13 /*
14 	Return the current display mode.  The only time you might return an
15 	error is if a mode hasn't been set. Or if the system hands you a NULL pointer.
16 */
17 status_t GET_DISPLAY_MODE(display_mode *current_mode)
18 {
19 	/* check for NULL pointer */
20 	if (current_mode == NULL) return B_ERROR;
21 
22 	*current_mode = si->dm;
23 	return B_OK;
24 }
25 
26 /* Return the frame buffer configuration information. */
27 status_t GET_FRAME_BUFFER_CONFIG(frame_buffer_config *afb)
28 {
29 	/* check for NULL pointer */
30 	if (afb == NULL) return B_ERROR;
31 
32 	*afb = si->fbc;
33 	return B_OK;
34 }
35 
36 /* Return the maximum and minium pixelclock limits for the specified mode. */
37 status_t GET_PIXEL_CLOCK_LIMITS(display_mode *dm, uint32 *low, uint32 *high)
38 {
39 	uint32 max_pclk = 0;
40 	uint32 min_pclk = 0;
41 
42 	/* check for NULL pointers */
43 	if ((dm == NULL) || (low == NULL) || (high == NULL)) return B_ERROR;
44 
45 	/* specify requested info assuming CRT-only mode
46 	 * (if panel is active, CRTC and pixelclock are not programmed!) */
47 	{
48 		/* find min. value */
49 		switch (si->ps.card_type)
50 		{
51 			default:
52 				*low = (si->ps.min_pixel_vco * 1000);
53 				break;
54 		}
55 		/* find max. value */
56 		switch (dm->space)
57 		{
58 			case B_CMAP8:
59 				max_pclk = si->ps.max_dac1_clock_8;
60 				break;
61 			case B_RGB15_LITTLE:
62 			case B_RGB16_LITTLE:
63 				max_pclk = si->ps.max_dac1_clock_16;
64 				break;
65 			case B_RGB24_LITTLE:
66 				max_pclk = si->ps.max_dac1_clock_24;
67 				break;
68 			default:
69 				/* use fail-safe value */
70 				max_pclk = si->ps.max_dac1_clock_24;
71 				break;
72 		}
73 		/* return values in kHz */
74 		*high = max_pclk * 1000;
75 	}
76 
77 	/* clamp lower limit to 48Hz vertical refresh for now.
78 	 * Apparantly the BeOS screenprefs app does limit the upper refreshrate to 90Hz,
79 	 * while it does not limit the lower refreshrate. */
80 	min_pclk = ((uint32)dm->timing.h_total * (uint32)dm->timing.v_total * 48) / 1000;
81 	if (min_pclk > *low) *low = min_pclk;
82 
83 	return B_OK;
84 }
85 
86 /* Return the semaphore id that will be used to signal a vertical sync occured.  */
87 sem_id ACCELERANT_RETRACE_SEMAPHORE(void)
88 {
89 	if (si->ps.int_assigned)
90 //		return si->vblank;
91 //temp:
92 		return B_ERROR;
93 	else
94 		return B_ERROR;
95 }
96