xref: /haiku/src/add-ons/accelerants/via/GetModeInfo.c (revision 35bf20db0fcbf91a0f47b6d7e765bc403cc47481)
1*35bf20dbSRudolf Cornelissen /*
2*35bf20dbSRudolf Cornelissen 	Copyright 1999, Be Incorporated.   All Rights Reserved.
3*35bf20dbSRudolf Cornelissen 	This file may be used under the terms of the Be Sample Code License.
4*35bf20dbSRudolf Cornelissen 
5*35bf20dbSRudolf Cornelissen 	Other authors:
6*35bf20dbSRudolf Cornelissen 	Mark Watson
7*35bf20dbSRudolf Cornelissen 	Rudolf Cornelissen 9/2002-5/2003
8*35bf20dbSRudolf Cornelissen */
9*35bf20dbSRudolf Cornelissen 
10*35bf20dbSRudolf Cornelissen #define MODULE_BIT 0x02000000
11*35bf20dbSRudolf Cornelissen 
12*35bf20dbSRudolf Cornelissen #include "acc_std.h"
13*35bf20dbSRudolf Cornelissen 
14*35bf20dbSRudolf Cornelissen /*
15*35bf20dbSRudolf Cornelissen 	Return the current display mode.  The only time you might return an
16*35bf20dbSRudolf Cornelissen 	error is if a mode hasn't been set. Or if the system hands you a NULL pointer.
17*35bf20dbSRudolf Cornelissen */
GET_DISPLAY_MODE(display_mode * current_mode)18*35bf20dbSRudolf Cornelissen status_t GET_DISPLAY_MODE(display_mode *current_mode)
19*35bf20dbSRudolf Cornelissen {
20*35bf20dbSRudolf Cornelissen 	/* check for NULL pointer */
21*35bf20dbSRudolf Cornelissen 	if (current_mode == NULL) return B_ERROR;
22*35bf20dbSRudolf Cornelissen 
23*35bf20dbSRudolf Cornelissen 	*current_mode = si->dm;
24*35bf20dbSRudolf Cornelissen 	return B_OK;
25*35bf20dbSRudolf Cornelissen }
26*35bf20dbSRudolf Cornelissen 
27*35bf20dbSRudolf Cornelissen /* Return the frame buffer configuration information. */
GET_FRAME_BUFFER_CONFIG(frame_buffer_config * afb)28*35bf20dbSRudolf Cornelissen status_t GET_FRAME_BUFFER_CONFIG(frame_buffer_config *afb)
29*35bf20dbSRudolf Cornelissen {
30*35bf20dbSRudolf Cornelissen 	/* check for NULL pointer */
31*35bf20dbSRudolf Cornelissen 	if (afb == NULL) return B_ERROR;
32*35bf20dbSRudolf Cornelissen 
33*35bf20dbSRudolf Cornelissen 	*afb = si->fbc;
34*35bf20dbSRudolf Cornelissen 	return B_OK;
35*35bf20dbSRudolf Cornelissen }
36*35bf20dbSRudolf Cornelissen 
37*35bf20dbSRudolf Cornelissen /* Return the maximum and minium pixelclock limits for the specified mode. */
38*35bf20dbSRudolf Cornelissen /* NOTE:
39*35bf20dbSRudolf Cornelissen  * Due to BeOS constraints output for all heads will be limited to the head with
40*35bf20dbSRudolf Cornelissen  * the least capabilities. */
GET_PIXEL_CLOCK_LIMITS(display_mode * dm,uint32 * low,uint32 * high)41*35bf20dbSRudolf Cornelissen status_t GET_PIXEL_CLOCK_LIMITS(display_mode *dm, uint32 *low, uint32 *high)
42*35bf20dbSRudolf Cornelissen {
43*35bf20dbSRudolf Cornelissen 	uint32 max_pclk = 0;
44*35bf20dbSRudolf Cornelissen 	uint32 min_pclk = 0;
45*35bf20dbSRudolf Cornelissen 
46*35bf20dbSRudolf Cornelissen 	/* check for NULL pointers */
47*35bf20dbSRudolf Cornelissen 	if ((dm == NULL) || (low == NULL) || (high == NULL)) return B_ERROR;
48*35bf20dbSRudolf Cornelissen 
49*35bf20dbSRudolf Cornelissen 	/* specify requested info */
50*35bf20dbSRudolf Cornelissen 	if (dm->flags & DUALHEAD_BITS)
51*35bf20dbSRudolf Cornelissen 	{
52*35bf20dbSRudolf Cornelissen 		/* dualhead mode */
53*35bf20dbSRudolf Cornelissen 		/* find min. value */
54*35bf20dbSRudolf Cornelissen 		switch (si->ps.card_type)
55*35bf20dbSRudolf Cornelissen 		{
56*35bf20dbSRudolf Cornelissen 			default:
57*35bf20dbSRudolf Cornelissen 				*low = ((si->ps.min_video_vco * 1000) / 16);
58*35bf20dbSRudolf Cornelissen 				break;
59*35bf20dbSRudolf Cornelissen 		}
60*35bf20dbSRudolf Cornelissen 		/* find max. value:
61*35bf20dbSRudolf Cornelissen 		 * using decondary DAC specs because they could be narrower (twinview) */
62*35bf20dbSRudolf Cornelissen 		switch (dm->space)
63*35bf20dbSRudolf Cornelissen 		{
64*35bf20dbSRudolf Cornelissen 			case B_CMAP8:
65*35bf20dbSRudolf Cornelissen 				max_pclk = si->ps.max_dac2_clock_8;
66*35bf20dbSRudolf Cornelissen 				break;
67*35bf20dbSRudolf Cornelissen 			case B_RGB15_LITTLE:
68*35bf20dbSRudolf Cornelissen 			case B_RGB16_LITTLE:
69*35bf20dbSRudolf Cornelissen 				max_pclk = si->ps.max_dac2_clock_16;
70*35bf20dbSRudolf Cornelissen 				break;
71*35bf20dbSRudolf Cornelissen 			case B_RGB24_LITTLE:
72*35bf20dbSRudolf Cornelissen 				max_pclk = si->ps.max_dac2_clock_24;
73*35bf20dbSRudolf Cornelissen 				break;
74*35bf20dbSRudolf Cornelissen 			case B_RGB32_LITTLE:
75*35bf20dbSRudolf Cornelissen 				/* specially noted because of RAM speed constraints! */
76*35bf20dbSRudolf Cornelissen 				max_pclk = si->ps.max_dac2_clock_32dh;
77*35bf20dbSRudolf Cornelissen 				break;
78*35bf20dbSRudolf Cornelissen 			default:
79*35bf20dbSRudolf Cornelissen 				/* use fail-safe value */
80*35bf20dbSRudolf Cornelissen 				max_pclk = si->ps.max_dac2_clock_32dh;
81*35bf20dbSRudolf Cornelissen 				break;
82*35bf20dbSRudolf Cornelissen 		}
83*35bf20dbSRudolf Cornelissen 		/* return values in kHz */
84*35bf20dbSRudolf Cornelissen 		*high = max_pclk * 1000;
85*35bf20dbSRudolf Cornelissen 	}
86*35bf20dbSRudolf Cornelissen 	else
87*35bf20dbSRudolf Cornelissen 	{
88*35bf20dbSRudolf Cornelissen 		/* singlehead mode */
89*35bf20dbSRudolf Cornelissen 		/* find min. value */
90*35bf20dbSRudolf Cornelissen 		switch (si->ps.card_type)
91*35bf20dbSRudolf Cornelissen 		{
92*35bf20dbSRudolf Cornelissen 			default:
93*35bf20dbSRudolf Cornelissen 				*low = ((si->ps.min_pixel_vco * 1000) / 16);
94*35bf20dbSRudolf Cornelissen 				break;
95*35bf20dbSRudolf Cornelissen 		}
96*35bf20dbSRudolf Cornelissen 		/* find max. value: depends on which head is used as primary head */
97*35bf20dbSRudolf Cornelissen 		if (!si->ps.crtc2_prim)
98*35bf20dbSRudolf Cornelissen 		{
99*35bf20dbSRudolf Cornelissen 			switch (dm->space)
100*35bf20dbSRudolf Cornelissen 			{
101*35bf20dbSRudolf Cornelissen 				case B_CMAP8:
102*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac1_clock_8;
103*35bf20dbSRudolf Cornelissen 					break;
104*35bf20dbSRudolf Cornelissen 				case B_RGB15_LITTLE:
105*35bf20dbSRudolf Cornelissen 				case B_RGB16_LITTLE:
106*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac1_clock_16;
107*35bf20dbSRudolf Cornelissen 					break;
108*35bf20dbSRudolf Cornelissen 				case B_RGB24_LITTLE:
109*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac1_clock_24;
110*35bf20dbSRudolf Cornelissen 					break;
111*35bf20dbSRudolf Cornelissen 				case B_RGB32_LITTLE:
112*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac1_clock_32;
113*35bf20dbSRudolf Cornelissen 					break;
114*35bf20dbSRudolf Cornelissen 				default:
115*35bf20dbSRudolf Cornelissen 					/* use fail-safe value */
116*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac1_clock_32;
117*35bf20dbSRudolf Cornelissen 					break;
118*35bf20dbSRudolf Cornelissen 			}
119*35bf20dbSRudolf Cornelissen 		}
120*35bf20dbSRudolf Cornelissen 		else
121*35bf20dbSRudolf Cornelissen 		{
122*35bf20dbSRudolf Cornelissen 			switch (dm->space)
123*35bf20dbSRudolf Cornelissen 			{
124*35bf20dbSRudolf Cornelissen 				case B_CMAP8:
125*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac2_clock_8;
126*35bf20dbSRudolf Cornelissen 					break;
127*35bf20dbSRudolf Cornelissen 				case B_RGB15_LITTLE:
128*35bf20dbSRudolf Cornelissen 				case B_RGB16_LITTLE:
129*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac2_clock_16;
130*35bf20dbSRudolf Cornelissen 					break;
131*35bf20dbSRudolf Cornelissen 				case B_RGB24_LITTLE:
132*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac2_clock_24;
133*35bf20dbSRudolf Cornelissen 					break;
134*35bf20dbSRudolf Cornelissen 				case B_RGB32_LITTLE:
135*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac2_clock_32;
136*35bf20dbSRudolf Cornelissen 					break;
137*35bf20dbSRudolf Cornelissen 				default:
138*35bf20dbSRudolf Cornelissen 					/* use fail-safe value */
139*35bf20dbSRudolf Cornelissen 					max_pclk = si->ps.max_dac2_clock_32;
140*35bf20dbSRudolf Cornelissen 					break;
141*35bf20dbSRudolf Cornelissen 			}
142*35bf20dbSRudolf Cornelissen 		}
143*35bf20dbSRudolf Cornelissen 		/* return values in kHz */
144*35bf20dbSRudolf Cornelissen 		*high = max_pclk * 1000;
145*35bf20dbSRudolf Cornelissen 	}
146*35bf20dbSRudolf Cornelissen 
147*35bf20dbSRudolf Cornelissen 	/* clamp lower limit to 48Hz vertical refresh for now.
148*35bf20dbSRudolf Cornelissen 	 * Apparantly the BeOS screenprefs app does limit the upper refreshrate to 90Hz,
149*35bf20dbSRudolf Cornelissen 	 * while it does not limit the lower refreshrate. */
150*35bf20dbSRudolf Cornelissen 	min_pclk = ((uint32)dm->timing.h_total * (uint32)dm->timing.v_total * 48) / 1000;
151*35bf20dbSRudolf Cornelissen 	if (min_pclk > *low) *low = min_pclk;
152*35bf20dbSRudolf Cornelissen 
153*35bf20dbSRudolf Cornelissen 	return B_OK;
154*35bf20dbSRudolf Cornelissen }
155*35bf20dbSRudolf Cornelissen 
156*35bf20dbSRudolf Cornelissen /* Return the semaphore id that will be used to signal a vertical sync occured.  */
ACCELERANT_RETRACE_SEMAPHORE(void)157*35bf20dbSRudolf Cornelissen sem_id ACCELERANT_RETRACE_SEMAPHORE(void)
158*35bf20dbSRudolf Cornelissen {
159*35bf20dbSRudolf Cornelissen //	return si->vblank;
160*35bf20dbSRudolf Cornelissen return B_ERROR;
161*35bf20dbSRudolf Cornelissen }
162