xref: /haiku/src/add-ons/accelerants/et6x00/GetModeInfo.c (revision 2600324b57fa31cdea1627d584d314f2a579c4a8)
1 /*****************************************************************************\
2  * Tseng Labs ET6000, ET6100 and ET6300 graphics driver for BeOS 5.
3  * Copyright (c) 2003-2004, Evgeniy Vladimirovich Bobkov.
4 \*****************************************************************************/
5 
6 #include "GlobalData.h"
7 #include "generic.h"
8 
9 
10 /*****************************************************************************/
11 /*
12  * Return the current display mode.  The only time you
13  * might return an error is if a mode hasn't been set.
14  */
15 status_t GET_DISPLAY_MODE(display_mode *current_mode) {
16     /* easy for us, we return the last mode we set */
17     *current_mode = si->dm;
18     return B_OK;
19 }
20 /*****************************************************************************/
21 /*
22  * Return the frame buffer configuration information.
23  */
24 status_t GET_FRAME_BUFFER_CONFIG(frame_buffer_config *afb) {
25     /* easy again, as the last mode set stored the info in a convienient form */
26     *afb = si->fbc;
27     return B_OK;
28 }
29 /*****************************************************************************/
30 /*
31  * Return the maximum and minium pixel clock limits for the specified mode.
32  * Note that we're not making any guarantees about the ability of the
33  * attached display to handle pixel clocks within the limits we return.
34  * A future monitor capablilities database will post-process this
35  * information.
36  */
37 status_t GET_PIXEL_CLOCK_LIMITS(display_mode *dm, uint32 *low, uint32 *high) {
38 uint32 clockLimit;
39 uint32 totalPix = (uint32)dm->timing.h_total * (uint32)dm->timing.v_total;
40 
41     /* max pixel clock is pixel depth dependant */
42     switch (dm->space & ~0x3000) {
43  	case B_RGB24: clockLimit = si->pixelClockMax24; break;
44 	case B_RGB15:
45 	case B_RGB16: clockLimit = si->pixelClockMax16; break;
46 	default:
47 	    clockLimit = 0;
48     }
49 
50     /* lower limit of about 48Hz vertical refresh */
51     *low = (totalPix * 48L) / 1000L;
52     if (*low > clockLimit) return B_ERROR;
53     *high = clockLimit;
54 
55     return B_OK;
56 }
57 /*****************************************************************************/
58