103b705cfSriastradh#ifdef HAVE_CONFIG_H 203b705cfSriastradh#include "config.h" 303b705cfSriastradh#endif 403b705cfSriastradh 5fe8aea9eSmrg#include <xorg-server.h> 6fe8aea9eSmrg#include <xorgVersion.h> 7fe8aea9eSmrg#include <xf86Parser.h> 8fe8aea9eSmrg 903b705cfSriastradh#include "intel_options.h" 1003b705cfSriastradh 1103b705cfSriastradhconst OptionInfoRec intel_options[] = { 12fe8aea9eSmrg {OPTION_ACCEL_ENABLE, "Accel", OPTV_BOOLEAN, {0}, 0}, 1303b705cfSriastradh {OPTION_ACCEL_METHOD, "AccelMethod", OPTV_STRING, {0}, 0}, 1403b705cfSriastradh {OPTION_BACKLIGHT, "Backlight", OPTV_STRING, {0}, 0}, 15fe8aea9eSmrg {OPTION_EDID, "CustomEDID", OPTV_STRING, {0}, 0}, 1603b705cfSriastradh {OPTION_DRI, "DRI", OPTV_STRING, {0}, 0}, 1742542f5fSchristos {OPTION_PRESENT, "Present", OPTV_BOOLEAN, {0}, 1}, 1803b705cfSriastradh {OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, 0}, 1903b705cfSriastradh {OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, 0}, 2003b705cfSriastradh {OPTION_TILING_2D, "Tiling", OPTV_BOOLEAN, {0}, 1}, 2103b705cfSriastradh {OPTION_TILING_FB, "LinearFramebuffer", OPTV_BOOLEAN, {0}, 0}, 22fe8aea9eSmrg {OPTION_ROTATION, "HWRotation", OPTV_BOOLEAN, {0}, 1}, 2342542f5fSchristos {OPTION_VSYNC, "VSync", OPTV_BOOLEAN, {0}, 1}, 2442542f5fSchristos {OPTION_PAGEFLIP, "PageFlip", OPTV_BOOLEAN, {0}, 1}, 2503b705cfSriastradh {OPTION_SWAPBUFFERS_WAIT, "SwapbuffersWait", OPTV_BOOLEAN, {0}, 1}, 2603b705cfSriastradh {OPTION_TRIPLE_BUFFER, "TripleBuffer", OPTV_BOOLEAN, {0}, 1}, 2703b705cfSriastradh {OPTION_PREFER_OVERLAY, "XvPreferOverlay", OPTV_BOOLEAN, {0}, 0}, 2803b705cfSriastradh {OPTION_HOTPLUG, "HotPlug", OPTV_BOOLEAN, {0}, 1}, 2903b705cfSriastradh {OPTION_REPROBE, "ReprobeOutputs", OPTV_BOOLEAN, {0}, 0}, 3003b705cfSriastradh#ifdef INTEL_XVMC 3142542f5fSchristos {OPTION_XVMC, "XvMC", OPTV_BOOLEAN, {0}, 1}, 3203b705cfSriastradh#endif 3303b705cfSriastradh#ifdef USE_SNA 3403b705cfSriastradh {OPTION_ZAPHOD, "ZaphodHeads", OPTV_STRING, {0}, 0}, 3542542f5fSchristos {OPTION_VIRTUAL, "VirtualHeads", OPTV_INTEGER, {0}, 0}, 3603b705cfSriastradh {OPTION_TEAR_FREE, "TearFree", OPTV_BOOLEAN, {0}, 0}, 3703b705cfSriastradh {OPTION_CRTC_PIXMAPS, "PerCrtcPixmaps", OPTV_BOOLEAN, {0}, 0}, 3803b705cfSriastradh#endif 3903b705cfSriastradh#ifdef USE_UXA 4003b705cfSriastradh {OPTION_FALLBACKDEBUG, "FallbackDebug",OPTV_BOOLEAN, {0}, 0}, 4103b705cfSriastradh {OPTION_DEBUG_FLUSH_BATCHES, "DebugFlushBatches", OPTV_BOOLEAN, {0}, 0}, 4203b705cfSriastradh {OPTION_DEBUG_FLUSH_CACHES, "DebugFlushCaches", OPTV_BOOLEAN, {0}, 0}, 4303b705cfSriastradh {OPTION_DEBUG_WAIT, "DebugWait", OPTV_BOOLEAN, {0}, 0}, 4403b705cfSriastradh {OPTION_BUFFER_CACHE, "BufferCache", OPTV_BOOLEAN, {0}, 1}, 4503b705cfSriastradh#endif 4603b705cfSriastradh {-1, NULL, OPTV_NONE, {0}, 0} 4703b705cfSriastradh}; 4803b705cfSriastradh 4903b705cfSriastradhOptionInfoPtr intel_options_get(ScrnInfoPtr scrn) 5003b705cfSriastradh{ 5103b705cfSriastradh OptionInfoPtr options; 5203b705cfSriastradh 5303b705cfSriastradh xf86CollectOptions(scrn, NULL); 5403b705cfSriastradh if (!(options = malloc(sizeof(intel_options)))) 5503b705cfSriastradh return NULL; 5603b705cfSriastradh 5703b705cfSriastradh memcpy(options, intel_options, sizeof(intel_options)); 5803b705cfSriastradh xf86ProcessOptions(scrn->scrnIndex, scrn->options, options); 5903b705cfSriastradh 6003b705cfSriastradh return options; 6103b705cfSriastradh} 62fe8aea9eSmrg 63fe8aea9eSmrgBool intel_option_cast_to_bool(OptionInfoPtr options, int id, Bool val) 64fe8aea9eSmrg{ 65fe8aea9eSmrg#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,99,901,0) 66fe8aea9eSmrg xf86getBoolValue(&val, xf86GetOptValString(options, id)); 67fe8aea9eSmrg#endif 68fe8aea9eSmrg return val; 69fe8aea9eSmrg} 70fe8aea9eSmrg 71fe8aea9eSmrgstatic int 72fe8aea9eSmrgnamecmp(const char *s1, const char *s2) 73fe8aea9eSmrg{ 74fe8aea9eSmrg char c1, c2; 75fe8aea9eSmrg 76fe8aea9eSmrg if (!s1 || *s1 == 0) { 77fe8aea9eSmrg if (!s2 || *s2 == 0) 78fe8aea9eSmrg return 0; 79fe8aea9eSmrg else 80fe8aea9eSmrg return 1; 81fe8aea9eSmrg } 82fe8aea9eSmrg 83fe8aea9eSmrg while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') 84fe8aea9eSmrg s1++; 85fe8aea9eSmrg 86fe8aea9eSmrg while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') 87fe8aea9eSmrg s2++; 88fe8aea9eSmrg 89fe8aea9eSmrg c1 = isupper(*s1) ? tolower(*s1) : *s1; 90fe8aea9eSmrg c2 = isupper(*s2) ? tolower(*s2) : *s2; 91fe8aea9eSmrg while (c1 == c2) { 92fe8aea9eSmrg if (c1 == '\0') 93fe8aea9eSmrg return 0; 94fe8aea9eSmrg 95fe8aea9eSmrg s1++; 96fe8aea9eSmrg while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') 97fe8aea9eSmrg s1++; 98fe8aea9eSmrg 99fe8aea9eSmrg s2++; 100fe8aea9eSmrg while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') 101fe8aea9eSmrg s2++; 102fe8aea9eSmrg 103fe8aea9eSmrg c1 = isupper(*s1) ? tolower(*s1) : *s1; 104fe8aea9eSmrg c2 = isupper(*s2) ? tolower(*s2) : *s2; 105fe8aea9eSmrg } 106fe8aea9eSmrg 107fe8aea9eSmrg return c1 - c2; 108fe8aea9eSmrg} 109fe8aea9eSmrg 110fe8aea9eSmrgunsigned intel_option_cast_to_unsigned(OptionInfoPtr options, int id, unsigned val) 111fe8aea9eSmrg{ 112fe8aea9eSmrg#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,99,901,0) 113fe8aea9eSmrg const char *str = xf86GetOptValString(options, id); 114fe8aea9eSmrg#else 115fe8aea9eSmrg const char *str = NULL; 116fe8aea9eSmrg#endif 117fe8aea9eSmrg unsigned v; 118fe8aea9eSmrg 119fe8aea9eSmrg if (str == NULL || *str == '\0') 120fe8aea9eSmrg return val; 121fe8aea9eSmrg 122fe8aea9eSmrg if (namecmp(str, "on") == 0) 123fe8aea9eSmrg return val; 124fe8aea9eSmrg if (namecmp(str, "true") == 0) 125fe8aea9eSmrg return val; 126fe8aea9eSmrg if (namecmp(str, "yes") == 0) 127fe8aea9eSmrg return val; 128fe8aea9eSmrg 129fe8aea9eSmrg if (namecmp(str, "0") == 0) 130fe8aea9eSmrg return 0; 131fe8aea9eSmrg if (namecmp(str, "off") == 0) 132fe8aea9eSmrg return 0; 133fe8aea9eSmrg if (namecmp(str, "false") == 0) 134fe8aea9eSmrg return 0; 135fe8aea9eSmrg if (namecmp(str, "no") == 0) 136fe8aea9eSmrg return 0; 137fe8aea9eSmrg 138fe8aea9eSmrg v = atoi(str); 139fe8aea9eSmrg if (v) 140fe8aea9eSmrg return v; 141fe8aea9eSmrg 142fe8aea9eSmrg return val; 143fe8aea9eSmrg} 144