1091b52d5Sshatty/*
2091b52d5Sshatty	Copyright 1999, Be Incorporated.   All Rights Reserved.
3091b52d5Sshatty	This file may be used under the terms of the Be Sample Code License.
4091b52d5Sshatty
5091b52d5Sshatty	Other authors:
6091b52d5Sshatty	Mark Watson
78fe19e2fSRudolf Cornelissen	Rudolf Cornelissen 9-11/2005
8091b52d5Sshatty*/
9091b52d5Sshatty
10091b52d5Sshatty#define MODULE_BIT 0x02000000
11091b52d5Sshatty
12091b52d5Sshatty#include "acc_std.h"
13091b52d5Sshatty
14091b52d5Sshatty/*
15091b52d5Sshatty	Return the current display mode.  The only time you might return an
16091b52d5Sshatty	error is if a mode hasn't been set. Or if the system hands you a NULL pointer.
17091b52d5Sshatty*/
18091b52d5Sshattystatus_t GET_DISPLAY_MODE(display_mode *current_mode)
19091b52d5Sshatty{
20091b52d5Sshatty	/* check for NULL pointer */
21091b52d5Sshatty	if (current_mode == NULL) return B_ERROR;
22091b52d5Sshatty
2371194a68Sshatty	LOG(4, ("GET_DISPLAY_MODE: returning current mode\n"));
2471194a68Sshatty
25091b52d5Sshatty	*current_mode = si->dm;
26091b52d5Sshatty	return B_OK;
27091b52d5Sshatty}
28091b52d5Sshatty
29091b52d5Sshatty/* Return the frame buffer configuration information. */
30091b52d5Sshattystatus_t GET_FRAME_BUFFER_CONFIG(frame_buffer_config *afb)
31091b52d5Sshatty{
32091b52d5Sshatty	/* check for NULL pointer */
33091b52d5Sshatty	if (afb == NULL) return B_ERROR;
34091b52d5Sshatty
35091b52d5Sshatty	*afb = si->fbc;
36091b52d5Sshatty	return B_OK;
37091b52d5Sshatty}
38091b52d5Sshatty
39091b52d5Sshatty/* Return the maximum and minium pixelclock limits for the specified mode. */
40091b52d5Sshatty/* Rewritten / fixed by Rudolf */
41091b52d5Sshatty/* NOTE:
42091b52d5Sshatty * Due to BeOS constraints output for all heads will be limited to the head with
43091b52d5Sshatty * the least capabilities. (BeOS should ask for seperate constraints for all heads.) */
44091b52d5Sshattystatus_t GET_PIXEL_CLOCK_LIMITS(display_mode *dm, uint32 *low, uint32 *high)
45091b52d5Sshatty{
46091b52d5Sshatty	uint32 max_pclk = 0;
47f36d53a4Sshatty	uint32 min_pclk = 0;
48091b52d5Sshatty
49091b52d5Sshatty	/* check for NULL pointers */
50091b52d5Sshatty	if ((dm == NULL) || (low == NULL) || (high == NULL)) return B_ERROR;
51091b52d5Sshatty
52091b52d5Sshatty	/* specify requested info */
53091b52d5Sshatty	if (dm->flags & DUALHEAD_BITS)
54091b52d5Sshatty	{
55091b52d5Sshatty		/* dualhead mode */
56091b52d5Sshatty		/* find min. value */
57091b52d5Sshatty		switch (si->ps.card_type)
58091b52d5Sshatty		{
59091b52d5Sshatty			case G550:
60091b52d5Sshatty			case G450:
61091b52d5Sshatty				*low = ((si->ps.min_video_vco * 1000) / 16);
62091b52d5Sshatty				break;
63091b52d5Sshatty			default:
64091b52d5Sshatty				*low = ((si->ps.min_video_vco * 1000) / 8);
65091b52d5Sshatty				break;
66091b52d5Sshatty		}
67091b52d5Sshatty		/* find max. value */
68091b52d5Sshatty		switch (dm->space)
69091b52d5Sshatty		{
70091b52d5Sshatty			case B_CMAP8:
71091b52d5Sshatty				max_pclk = si->ps.max_dac2_clock_8;
72091b52d5Sshatty				break;
73091b52d5Sshatty			case B_RGB15_LITTLE:
74091b52d5Sshatty			case B_RGB16_LITTLE:
75091b52d5Sshatty				max_pclk = si->ps.max_dac2_clock_16;
76091b52d5Sshatty				break;
77091b52d5Sshatty			case B_RGB24_LITTLE:
78091b52d5Sshatty				max_pclk = si->ps.max_dac2_clock_24;
79091b52d5Sshatty				break;
80091b52d5Sshatty			case B_RGB32_LITTLE:
81091b52d5Sshatty				/* specially noted because of RAM speed constraints! */
82091b52d5Sshatty				max_pclk = si->ps.max_dac2_clock_32dh;
83091b52d5Sshatty				break;
84091b52d5Sshatty			default:
85091b52d5Sshatty				/* use fail-safe value */
86091b52d5Sshatty				max_pclk = si->ps.max_dac2_clock_32dh;
87091b52d5Sshatty				break;
88091b52d5Sshatty		}
89091b52d5Sshatty		/* return values in kHz */
90091b52d5Sshatty		*high = max_pclk * 1000;
91091b52d5Sshatty	}
92091b52d5Sshatty	else
93091b52d5Sshatty	{
94091b52d5Sshatty		/* singlehead mode */
95091b52d5Sshatty		/* find min. value */
96091b52d5Sshatty		switch (si->ps.card_type)
97091b52d5Sshatty		{
98091b52d5Sshatty			case G550:
99091b52d5Sshatty			case G450:
100091b52d5Sshatty				*low = ((si->ps.min_pixel_vco * 1000) / 16);
101091b52d5Sshatty				break;
102091b52d5Sshatty			default:
103091b52d5Sshatty				*low = ((si->ps.min_pixel_vco * 1000) / 8);
104091b52d5Sshatty				break;
105091b52d5Sshatty		}
106091b52d5Sshatty		/* find max. value */
107091b52d5Sshatty		switch (dm->space)
108091b52d5Sshatty		{
109091b52d5Sshatty			case B_CMAP8:
110091b52d5Sshatty				max_pclk = si->ps.max_dac1_clock_8;
111091b52d5Sshatty				break;
112091b52d5Sshatty			case B_RGB15_LITTLE:
113091b52d5Sshatty			case B_RGB16_LITTLE:
114091b52d5Sshatty				max_pclk = si->ps.max_dac1_clock_16;
115091b52d5Sshatty				break;
116091b52d5Sshatty			case B_RGB24_LITTLE:
117091b52d5Sshatty				max_pclk = si->ps.max_dac1_clock_24;
118091b52d5Sshatty				break;
119091b52d5Sshatty			case B_RGB32_LITTLE:
120091b52d5Sshatty				max_pclk = si->ps.max_dac1_clock_32;
121091b52d5Sshatty				break;
122091b52d5Sshatty			default:
123091b52d5Sshatty				/* use fail-safe value */
124091b52d5Sshatty				max_pclk = si->ps.max_dac1_clock_32;
125091b52d5Sshatty				break;
126091b52d5Sshatty		}
127091b52d5Sshatty		/* return values in kHz */
128091b52d5Sshatty		*high = max_pclk * 1000;
129f36d53a4Sshatty	}
130f36d53a4Sshatty
131f36d53a4Sshatty	/* clamp lower limit to 48Hz vertical refresh for now.
132f36d53a4Sshatty	 * Apparantly the BeOS screenprefs app does limit the upper refreshrate to 90Hz,
133f36d53a4Sshatty	 * while it does not limit the lower refreshrate. */
134f36d53a4Sshatty	min_pclk = ((uint32)dm->timing.h_total * (uint32)dm->timing.v_total * 48) / 1000;
135f36d53a4Sshatty	if (min_pclk > *low) *low = min_pclk;
136f36d53a4Sshatty
137091b52d5Sshatty	return B_OK;
138091b52d5Sshatty}
139091b52d5Sshatty
140091b52d5Sshatty/* Return the semaphore id that will be used to signal a vertical sync occured.  */
141091b52d5Sshattysem_id ACCELERANT_RETRACE_SEMAPHORE(void)
142091b52d5Sshatty{
1438fe19e2fSRudolf Cornelissen	if (si->ps.int_assigned)
1448fe19e2fSRudolf Cornelissen		return si->vblank;
1458fe19e2fSRudolf Cornelissen	else
1468fe19e2fSRudolf Cornelissen		return B_ERROR;
147091b52d5Sshatty}
148