1 /**************************************************************************
3 xserver-xorg-video-emulfb
5 Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: SooChan Lim <sc1.lim@samsung.com>
9 Permission is hereby granted, free of charge, to any person obtaining a
10 copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sub license, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial portions
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
24 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
25 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 **************************************************************************/
36 #include "fbdev_mode.h"
38 typedef struct _FBDevDisplayModeRec
40 char name[32]; /* identifier for the mode */
42 /* These are the values that the user sees/provides */
43 int Clock; /* pixel clock freq (kHz) */
44 int HDisplay; /* horizontal timing */
49 int VDisplay; /* vertical timing */
56 } FBDevDisplayModeRec, *FBDevDisplayModePtr;
58 /* [soolim: 20100206][TODO] : it has to be recalculated when it comes to change the target framebuffer
59 * The display mode data has to be changed whenever the target is changed
60 * Always check it out.
62 const FBDevDisplayModeRec fbdevDisplayModes[] =
64 /* CGA ( 320 x 200 ) */
65 {"320x200", 38, 320, 336, 338, 354, 0, 200, 203, 205, 233, 0, 0,},
66 /* QVGA ( 320 x 240 ) */
67 {"320x240", 38, 320, 336, 338, 354, 0, 240, 243, 245, 273, 0, 0,},
68 /* XX ( 240 x 400 ) */
69 {"240x400", 38, 240, 256, 258, 274, 0, 400, 428, 430, 433, 0, 0,},
70 /* HVGA (320 x 480 ) */
71 {"320x480", 38, 320, 336, 338, 354, 0, 480, 483, 485, 513, 0, 0,},
72 /* WVGA ( 480 x 720 ) */
73 {"480x720", 38, 480, 496, 498, 514, 0, 720, 723, 725, 753, 0, 0},
74 /* WVGA ( 480 x 800 ) */
75 {"480x800", 38, 480, 496, 498, 514, 0, 800, 803, 805, 833, 0, 0},
76 /* VGA ( 640 x 480 ) */
77 {"640x480", 19, 640, 840, 880, 959, 0, 480, 491, 501, 511, 0, 0,},
78 /* NTSC ( 720 x 480 ) */
79 {"720x480", 19, 720, 920, 960, 1039, 0, 480, 491, 501, 511, 0, 0,},
80 /* PAL ( 768 x 576 ) */
81 {"768x576", 19, 768, 968, 1008, 1087, 0, 576, 587, 597, 607, 0, 0,},
82 /* WVGA ( 800 x 480 ) */
83 {"800x480", 19, 800, 1000, 1040, 1119, 0, 480, 491, 501, 511, 0, 0},
84 /* WVGA ( 854 x 480 ) */
85 {"854x480", 19, 854, 1054, 1094, 1173, 0, 480, 491, 501, 511, 0, 0,},
86 /* WSVGA ( 600 x 1024 ) */
87 {"600x1024", 19, 600, 611, 621, 631, 0, 1024, 1224, 1264, 1343, 0, 0},
88 /* WSVGA ( 1024 x 600 ) */
89 {"1024x600", 19, 1024, 1224, 1264, 1343, 0, 600, 611, 621, 631, 0, 0},
91 /* XGA ( 1024 x 768 ) */
92 {"1024x768", 19, 1024, 1224, 1264, 1343, 600, 611, 621, 631, 0,},
97 #define NUM_DISPLAY_MODES (sizeof(fbdevDisplayModes)/sizeof(fbdevDisplayModes[0]))
99 const int fbdevNumDisplayModes = NUM_DISPLAY_MODES;
103 FBDevGetSupportModes(DisplayModePtr builtin_mode)
105 DisplayModePtr pMode = NULL;
106 DisplayModePtr prev_pMode = NULL;
107 DisplayModePtr ret_pMode = NULL;
111 clock = builtin_mode->Clock;
115 for(i=0; i< fbdevNumDisplayModes; i++)
117 pMode = calloc(1, sizeof(DisplayModeRec));
120 pMode->name = calloc(1, sizeof(char)*32);
121 sprintf(pMode->name,"%s", fbdevDisplayModes[i].name);
122 pMode->status = MODE_OK;
123 pMode->type = M_T_DRIVER | M_T_PREFERRED;
125 pMode->Clock = clock;
126 pMode->HDisplay = fbdevDisplayModes[i].HDisplay;
127 pMode->HSyncStart = fbdevDisplayModes[i].HSyncStart;
128 pMode->HSyncEnd = fbdevDisplayModes[i].HSyncEnd;
129 pMode->HTotal = fbdevDisplayModes[i].HTotal;
130 pMode->HSkew = fbdevDisplayModes[i].HSkew;
131 pMode->VDisplay = fbdevDisplayModes[i].VDisplay;
132 pMode->VSyncStart = fbdevDisplayModes[i].VSyncStart;
133 pMode->VSyncEnd = fbdevDisplayModes[i].VSyncEnd;
134 pMode->VTotal = fbdevDisplayModes[i].VTotal;
135 pMode->VScan = fbdevDisplayModes[i].VScan;
136 pMode->Flags = fbdevDisplayModes[i].Flags;
140 pMode->prev = prev_pMode;
141 prev_pMode->next = pMode;
142 prev_pMode = prev_pMode->next;
156 #define OPTION_PREFERRED_MODE 0
159 FBDevCheckPreferredMode(ScrnInfoPtr pScrn, xf86OutputPtr output)
161 char *preferred_mode = NULL;
163 /* Check for a configured preference for a particular mode */
164 preferred_mode = xf86GetOptValString (output->options,
165 OPTION_PREFERRED_MODE);
167 return preferred_mode;
169 if (pScrn->display->modes && *pScrn->display->modes)
170 preferred_mode = *pScrn->display->modes;
172 return preferred_mode;