diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2008-11-14 16:42:44 -0800 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2008-11-14 16:42:44 -0800 |
commit | c4e199b93eea189ec6bcab354de5aad850e6742d (patch) | |
tree | 14c77c57ce02749eabf3dcf7d28e825327ee7c82 /src | |
parent | edcf9edad9f52f9b10e63d4480bbe88b22dde884 (diff) |
Diffstat (limited to 'src')
48 files changed, 2134 insertions, 3254 deletions
diff --git a/src/XF86Config-parser/Configint.h b/src/XF86Config-parser/Configint.h index f91c6ee..b626bb2 100644 --- a/src/XF86Config-parser/Configint.h +++ b/src/XF86Config-parser/Configint.h @@ -97,24 +97,23 @@ LexRec, *LexPtr; #define HANDLE_LIST(field,func,type) \ { \ type p = func(); \ - if (p == NULL) \ - { \ - CLEANUP (ptr); \ + if (p == NULL) { \ + CLEANUP (&ptr); \ return (NULL); \ } else { \ - ptr->field = (type) \ - xconfigAddListItem((GenericListPtr) ptr->field, \ - (GenericListPtr) p); \ + xconfigAddListItem((GenericListPtr*)(&ptr->field), \ + (GenericListPtr) p); \ } \ } -#define Error(a,b) \ - do { \ +#define Error(a,b) \ + do { \ xconfigErrorMsg(ParseErrorMsg, a, b); \ - CLEANUP (ptr); \ - return NULL; \ - } while (0) \ + CLEANUP (&ptr); \ + return NULL; \ + } while (0) + /* * These are defines for error messages to promote consistency. diff --git a/src/XF86Config-parser/DRI.c b/src/XF86Config-parser/DRI.c index 9936830..b032ced 100644 --- a/src/XF86Config-parser/DRI.c +++ b/src/XF86Config-parser/DRI.c @@ -47,22 +47,24 @@ XConfigBuffersPtr xconfigParseBuffers (void) { int token; - PARSE_PROLOGUE (XConfigBuffersPtr, XConfigBuffersRec) + PARSE_PROLOGUE (XConfigBuffersPtr, XConfigBuffersRec); - if (xconfigGetSubToken (&(ptr->comment)) != NUMBER) - Error("Buffers count expected", NULL); + if (xconfigGetSubToken (&(ptr->comment)) != NUMBER) { + Error("Buffers count expected", NULL); + } ptr->count = val.num; - if (xconfigGetSubToken (&(ptr->comment)) != NUMBER) - Error("Buffers size expected", NULL); + if (xconfigGetSubToken (&(ptr->comment)) != NUMBER) { + Error("Buffers size expected", NULL); + } ptr->size = val.num; if ((token = xconfigGetSubToken (&(ptr->comment))) == STRING) { - ptr->flags = val.str; - if ((token = xconfigGetToken (NULL)) == COMMENT) - ptr->comment = xconfigAddComment(ptr->comment, val.str); - else - xconfigUnGetToken(token); + ptr->flags = val.str; + if ((token = xconfigGetToken (NULL)) == COMMENT) + ptr->comment = xconfigAddComment(ptr->comment, val.str); + else + xconfigUnGetToken(token); } return ptr; @@ -126,26 +128,30 @@ xconfigPrintDRISection (FILE * cf, XConfigDRIPtr ptr) } void -xconfigFreeDRI (XConfigDRIPtr ptr) +xconfigFreeDRI (XConfigDRIPtr *ptr) { - if (ptr == NULL) - return; + if (ptr == NULL || *ptr == NULL) + return; - xconfigFreeBuffersList (ptr->buffers); - TEST_FREE (ptr->comment); - free (ptr); + xconfigFreeBuffersList (&((*ptr)->buffers)); + TEST_FREE ((*ptr)->comment); + free (*ptr); + *ptr = NULL; } void -xconfigFreeBuffersList (XConfigBuffersPtr ptr) +xconfigFreeBuffersList (XConfigBuffersPtr *ptr) { XConfigBuffersPtr prev; - while (ptr) { - TEST_FREE (ptr->flags); - TEST_FREE (ptr->comment); - prev = ptr; - ptr = ptr->next; + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { + TEST_FREE ((*ptr)->flags); + TEST_FREE ((*ptr)->comment); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } diff --git a/src/XF86Config-parser/Device.c b/src/XF86Config-parser/Device.c index a4c3f62..a374fa4 100644 --- a/src/XF86Config-parser/Device.c +++ b/src/XF86Config-parser/Device.c @@ -329,25 +329,28 @@ xconfigPrintDeviceSection (FILE * cf, XConfigDevicePtr ptr) } void -xconfigFreeDeviceList (XConfigDevicePtr ptr) +xconfigFreeDeviceList (XConfigDevicePtr *ptr) { XConfigDevicePtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->vendor); - TEST_FREE (ptr->board); - TEST_FREE (ptr->chipset); - TEST_FREE (ptr->card); - TEST_FREE (ptr->driver); - TEST_FREE (ptr->ramdac); - TEST_FREE (ptr->clockchip); - TEST_FREE (ptr->comment); - xconfigOptionListFree (ptr->options); - - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->vendor); + TEST_FREE ((*ptr)->board); + TEST_FREE ((*ptr)->chipset); + TEST_FREE ((*ptr)->card); + TEST_FREE ((*ptr)->driver); + TEST_FREE ((*ptr)->ramdac); + TEST_FREE ((*ptr)->clockchip); + TEST_FREE ((*ptr)->comment); + xconfigFreeOptionList (&((*ptr)->options)); + + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } diff --git a/src/XF86Config-parser/Extensions.c b/src/XF86Config-parser/Extensions.c index 7482a6d..415ae17 100644 --- a/src/XF86Config-parser/Extensions.c +++ b/src/XF86Config-parser/Extensions.c @@ -91,12 +91,13 @@ xconfigPrintExtensionsSection (FILE * cf, XConfigExtensionsPtr ptr) } void -xconfigFreeExtensions (XConfigExtensionsPtr ptr) +xconfigFreeExtensions (XConfigExtensionsPtr *ptr) { - if (ptr == NULL) + if (ptr == NULL || *ptr == NULL) return; - xconfigOptionListFree (ptr->options); - TEST_FREE (ptr->comment); - free (ptr); + xconfigFreeOptionList (&((*ptr)->options)); + TEST_FREE ((*ptr)->comment); + free (*ptr); + *ptr = NULL; } diff --git a/src/XF86Config-parser/Files.c b/src/XF86Config-parser/Files.c index 6493cd1..dac9335 100644 --- a/src/XF86Config-parser/Files.c +++ b/src/XF86Config-parser/Files.c @@ -265,17 +265,18 @@ xconfigPrintFileSection (FILE * cf, XConfigFilesPtr ptr) } void -xconfigFreeFiles (XConfigFilesPtr p) +xconfigFreeFiles (XConfigFilesPtr *p) { - if (p == NULL) + if (p == NULL || *p == NULL) return; - TEST_FREE (p->logfile); - TEST_FREE (p->rgbpath); - TEST_FREE (p->modulepath); - TEST_FREE (p->inputdevs); - TEST_FREE (p->fontpath); - TEST_FREE (p->comment); + TEST_FREE ((*p)->logfile); + TEST_FREE ((*p)->rgbpath); + TEST_FREE ((*p)->modulepath); + TEST_FREE ((*p)->inputdevs); + TEST_FREE ((*p)->fontpath); + TEST_FREE ((*p)->comment); - free (p); + free (*p); + *p = NULL; } diff --git a/src/XF86Config-parser/Flags.c b/src/XF86Config-parser/Flags.c index b86b7a4..6eadae2 100644 --- a/src/XF86Config-parser/Flags.c +++ b/src/XF86Config-parser/Flags.c @@ -141,8 +141,8 @@ xconfigParseFlagsSection (void) valstr = buff; } } - ptr->options = xconfigAddNewOption - (ptr->options, ServerFlagsTab[i].name, valstr); + xconfigAddNewOption(&ptr->options, + ServerFlagsTab[i].name, valstr); } i++; } @@ -181,13 +181,16 @@ xconfigPrintServerFlagsSection (FILE * f, XConfigFlagsPtr flags) fprintf (f, "EndSection\n\n"); } -XConfigOptionPtr -xconfigAddNewOption (XConfigOptionPtr head, const char *name, const char *val) +void +xconfigAddNewOption (XConfigOptionPtr *pHead, const char *name, + const char *val) { - XConfigOptionPtr new, old = NULL; + XConfigOptionPtr new; + XConfigOptionPtr old = NULL; /* Don't allow duplicates */ - if (head != NULL && (old = xconfigFindOption(head, name)) != NULL) { + if (*pHead != NULL && + ((old = xconfigFindOption(*pHead, name)) != NULL)) { TEST_FREE(old->name); TEST_FREE(old->val); new = old; @@ -198,21 +201,21 @@ xconfigAddNewOption (XConfigOptionPtr head, const char *name, const char *val) new->name = xconfigStrdup(name); new->val = xconfigStrdup(val); - if (old == NULL) - return ((XConfigOptionPtr) xconfigAddListItem ((GenericListPtr) head, - (GenericListPtr) new)); - else - return head; + if (old == NULL) { + xconfigAddListItem((GenericListPtr *)(pHead), (GenericListPtr)new); + } } void -xconfigFreeFlags (XConfigFlagsPtr flags) +xconfigFreeFlags (XConfigFlagsPtr *flags) { - if (flags == NULL) + if (flags == NULL || *flags == NULL) return; - xconfigOptionListFree (flags->options); - TEST_FREE(flags->comment); - free (flags); + + xconfigFreeOptionList (&((*flags)->options)); + TEST_FREE((*flags)->comment); + free (*flags); + *flags = NULL; } XConfigOptionPtr @@ -220,27 +223,31 @@ xconfigOptionListDup (XConfigOptionPtr opt) { XConfigOptionPtr newopt = NULL; - while (opt) - { - newopt = xconfigAddNewOption(newopt, opt->name, opt->val); - newopt->comment = xconfigStrdup(opt->comment); + while (opt) { + xconfigAddNewOption(&newopt, opt->name, opt->val); + if (newopt) { + newopt->comment = xconfigStrdup(opt->comment); + } opt = opt->next; } return newopt; } void -xconfigOptionListFree (XConfigOptionPtr opt) +xconfigFreeOptionList (XConfigOptionPtr *opt) { XConfigOptionPtr prev; - while (opt) + if (opt == NULL || *opt == NULL) + return; + + while (*opt) { - TEST_FREE (opt->name); - TEST_FREE (opt->val); - TEST_FREE (opt->comment); - prev = opt; - opt = opt->next; + TEST_FREE ((*opt)->name); + TEST_FREE ((*opt)->val); + TEST_FREE ((*opt)->comment); + prev = *opt; + *opt = (*opt)->next; free (prev); } } @@ -277,28 +284,15 @@ xconfigNewOption(const char *name, const char *value) return opt; } -XConfigOptionPtr -xconfigRemoveOption(XConfigOptionPtr list, XConfigOptionPtr opt) +void +xconfigRemoveOption(XConfigOptionPtr *pHead, XConfigOptionPtr opt) { - XConfigOptionPtr prev = NULL; - XConfigOptionPtr p = list; - - while (p) { - if (p == opt) { - if (prev) prev->next = opt->next; - if (list == opt) list = opt->next; - - TEST_FREE(opt->name); - TEST_FREE(opt->val); - TEST_FREE(opt->comment); - free(opt); - break; - } - prev = p; - p = p->next; - } + xconfigRemoveListItem((GenericListPtr *)pHead, (GenericListPtr)opt); - return list; + TEST_FREE(opt->name); + TEST_FREE(opt->val); + TEST_FREE(opt->comment); + free(opt); } XConfigOptionPtr @@ -397,7 +391,7 @@ xconfigOptionListMerge (XConfigOptionPtr head, XConfigOptionPtr tail) ap->next = a->next; a->next = b->next; b->next = NULL; - xconfigOptionListFree (b); + xconfigFreeOptionList (&b); b = a->next; bp = a; a = tail; @@ -482,11 +476,11 @@ xconfigParseOption(XConfigOptionPtr head) else cnew = option; - if (old == NULL) - return ((XConfigOptionPtr)xconfigAddListItem((GenericListPtr)head, - (GenericListPtr)cnew)); + if (old == NULL) { + xconfigAddListItem((GenericListPtr *)(&head), (GenericListPtr)cnew); + } - return (head); + return head; } void diff --git a/src/XF86Config-parser/Generate.c b/src/XF86Config-parser/Generate.c index 22ce212..a45602e 100644 --- a/src/XF86Config-parser/Generate.c +++ b/src/XF86Config-parser/Generate.c @@ -122,8 +122,7 @@ XConfigScreenPtr xconfigGenerateAddScreen(XConfigPtr config, screen->defaultdepth = 24; - screen->displays = xconfigAddDisplay(screen->displays, - screen->defaultdepth); + xconfigAddDisplay(&screen->displays, screen->defaultdepth); /* append to the end of the screen list */ @@ -377,25 +376,25 @@ static void add_modules(GenerateOptions *gop, XConfigPtr config) config->modules = xconfigAlloc(sizeof(XConfigModuleRec)); - l = xconfigAddNewLoadDirective(l, xconfigStrdup("dbe"), - XCONFIG_LOAD_MODULE, NULL, FALSE); - l = xconfigAddNewLoadDirective(l, xconfigStrdup("extmod"), - XCONFIG_LOAD_MODULE, NULL, FALSE); - l = xconfigAddNewLoadDirective(l, xconfigStrdup("type1"), - XCONFIG_LOAD_MODULE, NULL, FALSE); + xconfigAddNewLoadDirective(&l, xconfigStrdup("dbe"), + XCONFIG_LOAD_MODULE, NULL, FALSE); + xconfigAddNewLoadDirective(&l, xconfigStrdup("extmod"), + XCONFIG_LOAD_MODULE, NULL, FALSE); + xconfigAddNewLoadDirective(&l, xconfigStrdup("type1"), + XCONFIG_LOAD_MODULE, NULL, FALSE); #if defined(NV_SUNOS) - l = xconfigAddNewLoadDirective(l, xconfigStrdup("IA"), - XCONFIG_LOAD_MODULE, NULL, FALSE); - l = xconfigAddNewLoadDirective(l, xconfigStrdup("bitstream"), - XCONFIG_LOAD_MODULE, NULL, FALSE); - l = xconfigAddNewLoadDirective(l, xconfigStrdup("xtsol"), - XCONFIG_LOAD_MODULE, NULL, FALSE); + xconfigAddNewLoadDirective(&l, xconfigStrdup("IA"), + XCONFIG_LOAD_MODULE, NULL, FALSE); + xconfigAddNewLoadDirective(&l, xconfigStrdup("bitstream"), + XCONFIG_LOAD_MODULE, NULL, FALSE); + xconfigAddNewLoadDirective(&l, xconfigStrdup("xtsol"), + XCONFIG_LOAD_MODULE, NULL, FALSE); #else - l = xconfigAddNewLoadDirective(l, xconfigStrdup("freetype"), - XCONFIG_LOAD_MODULE, NULL, FALSE); + xconfigAddNewLoadDirective(&l, xconfigStrdup("freetype"), + XCONFIG_LOAD_MODULE, NULL, FALSE); #endif - l = xconfigAddNewLoadDirective(l, xconfigStrdup("glx"), - XCONFIG_LOAD_MODULE, NULL, FALSE); + xconfigAddNewLoadDirective(&l, xconfigStrdup("glx"), + XCONFIG_LOAD_MODULE, NULL, FALSE); config->modules->loads = l; @@ -412,7 +411,6 @@ static void add_modules(GenerateOptions *gop, XConfigPtr config) XConfigMonitorPtr xconfigAddMonitor(XConfigPtr config, int count) { XConfigMonitorPtr monitor, m; - XConfigOptionPtr opt = NULL; /* XXX need to query resman for the EDID */ @@ -426,16 +424,15 @@ XConfigMonitorPtr xconfigAddMonitor(XConfigPtr config, int count) /* XXX check EDID for freq ranges */ monitor->n_hsync = 1; - monitor->hsync[0].lo = 30.0; - monitor->hsync[0].hi = 110.0; + monitor->hsync[0].lo = 28.0; + monitor->hsync[0].hi = 33.0; monitor->n_vrefresh = 1; - monitor->vrefresh[0].lo = 50.0; - monitor->vrefresh[0].hi = 150.0; + monitor->vrefresh[0].lo = 43.0; + monitor->vrefresh[0].hi = 72.0; - opt = xconfigAddNewOption(opt, "DPMS", NULL); - - monitor->options = opt; + monitor->options = NULL; + xconfigAddNewOption(&monitor->options, "DPMS", NULL); /* append to the end of the monitor list */ @@ -495,7 +492,7 @@ add_device(XConfigPtr config, int bus, int slot, char *boardname, int count) -XConfigDisplayPtr xconfigAddDisplay(XConfigDisplayPtr head, const int depth) +void xconfigAddDisplay(XConfigDisplayPtr *pHead, const int depth) { XConfigDisplayPtr display; @@ -507,9 +504,8 @@ XConfigDisplayPtr xconfigAddDisplay(XConfigDisplayPtr head, const int depth) display->black.red = -1; display->white.red = -1; - display->next = head; - - return display; + display->next = *pHead; + *pHead = display; } @@ -566,8 +562,8 @@ static void add_inputref(XConfigPtr config, XConfigLayoutPtr layout, inputRef = xconfigAlloc(sizeof(XConfigInputrefRec)); inputRef->input_name = xconfigStrdup(name); inputRef->input = xconfigFindInput(inputRef->input_name, config->inputs); - inputRef->options = - xconfigAddNewOption(NULL, coreKeyword, NULL); + inputRef->options = NULL; + xconfigAddNewOption(&inputRef->options, coreKeyword, NULL); inputRef->next = layout->inputs; layout->inputs = inputRef; @@ -918,7 +914,6 @@ int xconfigAddMouse(GenerateOptions *gop, XConfigPtr config) { const MouseEntry *entry = NULL; XConfigInputPtr input; - XConfigOptionPtr opt = NULL; char *device_path, *comment = "default"; /* if the user specified on the commandline, use that */ @@ -1015,9 +1010,10 @@ int xconfigAddMouse(GenerateOptions *gop, XConfigPtr config) device_path = xconfigStrcat("/dev/", entry->device, NULL); - opt = xconfigAddNewOption(opt, "Protocol", entry->Xproto); - opt = xconfigAddNewOption(opt, "Device", device_path); - opt = xconfigAddNewOption(opt, "Emulate3Buttons", + input->options = NULL; + xconfigAddNewOption(&input->options, "Protocol", entry->Xproto); + xconfigAddNewOption(&input->options, "Device", device_path); + xconfigAddNewOption(&input->options, "Emulate3Buttons", (entry->emulate3 ? "yes" : "no")); TEST_FREE(device_path); @@ -1027,9 +1023,7 @@ int xconfigAddMouse(GenerateOptions *gop, XConfigPtr config) * ignore ZAxisMapping */ - opt = xconfigAddNewOption(opt, "ZAxisMapping", "4 5"); - - input->options = opt; + xconfigAddNewOption(&input->options, "ZAxisMapping", "4 5"); input->next = config->inputs; config->inputs = input; @@ -1213,7 +1207,6 @@ int xconfigAddKeyboard(GenerateOptions *gop, XConfigPtr config) const KeyboardEntry *entry = NULL; XConfigInputPtr input; - XConfigOptionPtr opt = NULL; /* * if the user specified on the command line, use that @@ -1280,16 +1273,18 @@ int xconfigAddKeyboard(GenerateOptions *gop, XConfigPtr config) * entry we found above */ - if (entry && entry->layout) - opt = xconfigAddNewOption(opt, "XkbLayout", entry->layout); - if (entry && entry->model) - opt = xconfigAddNewOption(opt, "XkbModel", entry->model); - if (entry && entry->variant) - opt = xconfigAddNewOption(opt, "XkbVariant", entry->variant); - if (entry && entry->options) - opt = xconfigAddNewOption(opt, "XkbOptions", entry->options); - - input->options = opt; + input->options = NULL; + + if (entry) { + if (entry->layout) + xconfigAddNewOption(&input->options, "XkbLayout", entry->layout); + if (entry->model) + xconfigAddNewOption(&input->options, "XkbModel", entry->model); + if (entry->variant) + xconfigAddNewOption(&input->options, "XkbVariant", entry->variant); + if (entry->options) + xconfigAddNewOption(&input->options, "XkbOptions", entry->options); + } input->next = config->inputs; config->inputs = input; diff --git a/src/XF86Config-parser/Input.c b/src/XF86Config-parser/Input.c index 4b660f6..e016b4f 100644 --- a/src/XF86Config-parser/Input.c +++ b/src/XF86Config-parser/Input.c @@ -139,19 +139,22 @@ xconfigPrintInputSection (FILE * cf, XConfigInputPtr ptr) } void -xconfigFreeInputList (XConfigInputPtr ptr) +xconfigFreeInputList (XConfigInputPtr *ptr) { XConfigInputPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->driver); - TEST_FREE (ptr->comment); - xconfigOptionListFree (ptr->options); + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->driver); + TEST_FREE ((*ptr)->comment); + xconfigFreeOptionList (&((*ptr)->options)); - prev = ptr; - ptr = ptr->next; + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } @@ -242,10 +245,12 @@ static int getCoreInputDevice(GenerateOptions *gop, if (!core) { core = input; } else { - if (opt1) input->options = - xconfigRemoveOption(input->options, opt1); - if (opt2) inputRef->options = - xconfigRemoveOption(inputRef->options, opt2); + if (opt1) { + xconfigRemoveOption(&input->options, opt1); + } + if (opt2) { + xconfigRemoveOption(&inputRef->options, opt2); + } xconfigErrorMsg(WarnMsg, "Duplicate %s devices; removing %s " "attribute from \"%s\"\n", coreKeyword, coreKeyword, input->identifier); @@ -367,8 +372,7 @@ static int getCoreInputDevice(GenerateOptions *gop, opt2 = xconfigFindOption(inputRef->options, coreKeyword); if (!opt1 && !opt2) { - inputRef->options = xconfigAddNewOption(inputRef->options, - coreKeyword, NULL); + xconfigAddNewOption(&inputRef->options, coreKeyword, NULL); } break; } diff --git a/src/XF86Config-parser/Keyboard.c b/src/XF86Config-parser/Keyboard.c index 26bbb73..f282eb6 100644 --- a/src/XF86Config-parser/Keyboard.c +++ b/src/XF86Config-parser/Keyboard.c @@ -126,9 +126,7 @@ xconfigParseKeyboardSection (void) case KPROTOCOL: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "Protocol"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("Protocol"), - val.str); + xconfigAddNewOption(&ptr->options, "Protocol", val.str); break; case AUTOREPEAT: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER) @@ -142,9 +140,7 @@ xconfigParseKeyboardSection (void) sprintf(s, "%s %s", s1, s2); free(s1); free(s2); - ptr->options = - xconfigAddNewOption(ptr->options, - xconfigStrdup("AutoRepeat"), s); + xconfigAddNewOption(&ptr->options, "AutoRepeat", s); break; case XLEDS: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER) @@ -178,7 +174,7 @@ xconfigParseKeyboardSection (void) { case EOF_TOKEN: xconfigErrorMsg(ParseErrorMsg, UNEXPECTED_EOF_MSG); - CLEANUP (ptr); + CLEANUP (&ptr); return (NULL); break; @@ -197,93 +193,65 @@ xconfigParseKeyboardSection (void) MOVED_TO_FLAGS_MSG, "VTSysReq"); break; case XKBDISABLE: - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbDisable"), - NULL); + xconfigAddNewOption(&ptr->options, "XkbDisable", NULL); break; case XKBKEYMAP: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBKeymap"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbKeymap"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbKeymap", val.str); break; case XKBCOMPAT: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBCompat"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbCompat"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbCompat", val.str); break; case XKBTYPES: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBTypes"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbTypes"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbTypes", val.str); break; case XKBKEYCODES: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBKeycodes"); - ptr->options = - xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbKeycodes"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbKeycodes", val.str); break; case XKBGEOMETRY: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBGeometry"); - ptr->options = - xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbGeometry"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbGeometry", val.str); break; case XKBSYMBOLS: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBSymbols"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbSymbols"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbSymbols", val.str); break; case XKBRULES: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBRules"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbRules"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbRules", val.str); break; case XKBMODEL: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBModel"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbModel"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbModel", val.str); break; case XKBLAYOUT: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBLayout"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbLayout"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbLayout", val.str); break; case XKBVARIANT: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBVariant"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbVariant"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbVariant", val.str); break; case XKBOPTIONS: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "XKBOptions"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("XkbOptions"), - val.str); + xconfigAddNewOption(&ptr->options, "XkbOptions", val.str); break; case PANIX106: - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("Panix106"), - NULL); + xconfigAddNewOption(&ptr->options, "Panix106", NULL); break; case EOF_TOKEN: Error (UNEXPECTED_EOF_MSG, NULL); @@ -296,8 +264,7 @@ xconfigParseKeyboardSection (void) ptr->identifier = xconfigStrdup(CONF_IMPLICIT_KEYBOARD); ptr->driver = xconfigStrdup("keyboard"); - ptr->options = xconfigAddNewOption(ptr->options, - xconfigStrdup("CoreKeyboard"), NULL); + xconfigAddNewOption(&ptr->options, "CoreKeyboard", NULL); return ptr; } diff --git a/src/XF86Config-parser/Layout.c b/src/XF86Config-parser/Layout.c index 1e62d26..9f7c7ca 100644 --- a/src/XF86Config-parser/Layout.c +++ b/src/XF86Config-parser/Layout.c @@ -121,9 +121,8 @@ xconfigParseLayoutSection (void) if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (INACTIVE_MSG, NULL); iptr->device_name = val.str; - ptr->inactives = (XConfigInactivePtr) - xconfigAddListItem((GenericListPtr) ptr->inactives, - (GenericListPtr) iptr); + xconfigAddListItem((GenericListPtr *)(&ptr->inactives), + (GenericListPtr) iptr); } break; case SCREEN: @@ -240,9 +239,8 @@ xconfigParseLayoutSection (void) aptr->right_name = val.str; } - ptr->adjacencies = (XConfigAdjacencyPtr) - xconfigAddListItem((GenericListPtr) ptr->adjacencies, - (GenericListPtr) aptr); + xconfigAddListItem((GenericListPtr *)(&ptr->adjacencies), + (GenericListPtr) aptr); } break; case INPUTDEVICE: @@ -252,18 +250,15 @@ xconfigParseLayoutSection (void) iptr = calloc (1, sizeof (XConfigInputrefRec)); iptr->next = NULL; iptr->options = NULL; - if (xconfigGetSubToken (&(ptr->comment)) != STRING) + if (xconfigGetSubToken(&(ptr->comment)) != STRING) Error (INPUTDEV_MSG, NULL); iptr->input_name = val.str; - while ((token = xconfigGetSubToken (&(ptr->comment))) == STRING) - { - iptr->options = - xconfigAddNewOption (iptr->options, val.str, NULL); + while ((token = xconfigGetSubToken(&(ptr->comment))) == STRING) { + xconfigAddNewOption(&iptr->options, val.str, NULL); } - xconfigUnGetToken (token); - ptr->inputs = (XConfigInputrefPtr) - xconfigAddListItem((GenericListPtr) ptr->inputs, - (GenericListPtr) iptr); + xconfigUnGetToken(token); + xconfigAddListItem((GenericListPtr *)(&ptr->inputs), + (GenericListPtr) iptr); } break; case OPTION: @@ -360,53 +355,62 @@ xconfigPrintLayoutSection (FILE * cf, XConfigLayoutPtr ptr) } void -xconfigFreeLayoutList (XConfigLayoutPtr ptr) +xconfigFreeLayoutList (XConfigLayoutPtr *ptr) { XConfigLayoutPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->comment); - xconfigFreeAdjacencyList (ptr->adjacencies); - xconfigFreeInputrefList (ptr->inputs); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->comment); + xconfigFreeAdjacencyList (&((*ptr)->adjacencies)); + xconfigFreeInputrefList (&((*ptr)->inputs)); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } void -xconfigFreeAdjacencyList (XConfigAdjacencyPtr ptr) +xconfigFreeAdjacencyList (XConfigAdjacencyPtr *ptr) { XConfigAdjacencyPtr prev; - while (ptr) - { - TEST_FREE (ptr->screen_name); - TEST_FREE (ptr->top_name); - TEST_FREE (ptr->bottom_name); - TEST_FREE (ptr->left_name); - TEST_FREE (ptr->right_name); + if (ptr == NULL || *ptr == NULL) + return; - prev = ptr; - ptr = ptr->next; + while (*ptr) + { + TEST_FREE ((*ptr)->screen_name); + TEST_FREE ((*ptr)->top_name); + TEST_FREE ((*ptr)->bottom_name); + TEST_FREE ((*ptr)->left_name); + TEST_FREE ((*ptr)->right_name); + + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } void -xconfigFreeInputrefList (XConfigInputrefPtr ptr) +xconfigFreeInputrefList (XConfigInputrefPtr *ptr) { XConfigInputrefPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->input_name); - xconfigOptionListFree (ptr->options); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->input_name); + xconfigFreeOptionList (&((*ptr)->options)); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } diff --git a/src/XF86Config-parser/Merge.c b/src/XF86Config-parser/Merge.c index 7d8ab98..20da333 100644 --- a/src/XF86Config-parser/Merge.c +++ b/src/XF86Config-parser/Merge.c @@ -76,17 +76,17 @@ static void xconfigAddRemovedOptionComment(char **existing_comments, * list and (if specified) adds a comment to an existing comments string * */ -static void xconfigRemoveNamedOption(XConfigOptionPtr *head, char *name, - char **comments) +void xconfigRemoveNamedOption(XConfigOptionPtr *pHead, const char *name, + char **comments) { XConfigOptionPtr option; - option = xconfigFindOption(*head, name); + option = xconfigFindOption(*pHead, name); if (option) { if (comments) { xconfigAddRemovedOptionComment(comments, option); } - *head = xconfigRemoveOption(*head, option); + xconfigRemoveOption(pHead, option); } } /* xconfigRemoveNamedOption() */ @@ -153,12 +153,12 @@ static void xconfigMergeOption(XConfigOptionPtr *dstHead, if (!srcOption && dstOption) { /* option does not exist in src, but exists in dst: remove from dst */ - *dstHead = xconfigRemoveOption(*dstHead, dstOption); + xconfigRemoveOption(dstHead, dstOption); } else if (srcOption && !dstOption) { /* option exists in src but not in dst: add to dst */ - *dstHead = xconfigAddNewOption(*dstHead, name, srcValue); + xconfigAddNewOption(dstHead, name, srcValue); } else if (srcOption && dstOption) { @@ -173,7 +173,7 @@ static void xconfigMergeOption(XConfigOptionPtr *dstHead, if (comments) { xconfigAddRemovedOptionComment(comments, dstOption); } - *dstHead = xconfigAddNewOption(*dstHead, name, srcValue); + xconfigAddNewOption(dstHead, name, srcValue); } } @@ -259,8 +259,7 @@ static void xconfigMergeMonitors(XConfigMonitorPtr dstMonitor, /* XXX Remove the destination monitor's "UseModes" references to * avoid having the wrong modelines tied to the new monitor. */ - xconfigFreeModesLinkList(dstMonitor->modes_sections); - dstMonitor->modes_sections = NULL; + xconfigFreeModesLinkList(&dstMonitor->modes_sections); } /* xconfigMergeMonitors() */ @@ -295,9 +294,8 @@ static int xconfigMergeAllMonitors(XConfigPtr dstConfig, XConfigPtr srcConfig) dstMonitor->identifier = xconfigStrdup(srcMonitor->identifier); - dstConfig->monitors = (XConfigMonitorPtr) - xconfigAddListItem((GenericListPtr)dstConfig->monitors, - (GenericListPtr)dstMonitor); + xconfigAddListItem((GenericListPtr *)(&dstConfig->monitors), + (GenericListPtr)dstMonitor); } /* Do the merge */ @@ -386,9 +384,8 @@ static int xconfigMergeAllDevices(XConfigPtr dstConfig, XConfigPtr srcConfig) dstDevice->identifier = xconfigStrdup(srcDevice->identifier); - dstConfig->devices = (XConfigDevicePtr) - xconfigAddListItem((GenericListPtr)dstConfig->devices, - (GenericListPtr)dstDevice); + xconfigAddListItem((GenericListPtr *)(&dstConfig->devices), + (GenericListPtr)dstDevice); } /* Do the merge */ @@ -451,9 +448,8 @@ static int xconfigMergeDriverOptions(XConfigScreenPtr dstScreen, /* Add the option to the screen->options list */ - dstScreen->options = - xconfigAddNewOption(dstScreen->options, - name, xconfigOptionValue(option)); + xconfigAddNewOption(&dstScreen->options, + name, xconfigOptionValue(option)); option = option->next; } @@ -478,8 +474,7 @@ static int xconfigMergeDisplays(XConfigScreenPtr dstScreen, /* Free all the displays in the destination screen */ - xconfigFreeDisplayList(dstScreen->displays); - dstScreen->displays = NULL; + xconfigFreeDisplayList(&dstScreen->displays); /* Copy all te displays */ @@ -514,11 +509,12 @@ static int xconfigMergeDisplays(XConfigScreenPtr dstScreen, lastDstMode = NULL; srcMode = srcDisplay->modes; + dstMode = NULL; while (srcMode) { /* Copy the mode */ - - dstMode = xconfigAddMode(NULL, srcMode->mode_name); + + xconfigAddMode(&dstMode, srcMode->mode_name); /* Add mode at the end of the list */ @@ -532,9 +528,8 @@ static int xconfigMergeDisplays(XConfigScreenPtr dstScreen, srcMode = srcMode->next; } - dstScreen->displays = - (XConfigDisplayPtr)xconfigAddListItem((GenericListPtr)(dstScreen->displays), - (GenericListPtr)dstDisplay); + xconfigAddListItem((GenericListPtr *)(&dstScreen->displays), + (GenericListPtr)dstDisplay); } return 1; @@ -619,9 +614,8 @@ static int xconfigMergeAllScreens(XConfigPtr dstConfig, XConfigPtr srcConfig) dstScreen->identifier = xconfigStrdup(srcScreen->identifier); - dstConfig->screens = (XConfigScreenPtr) - xconfigAddListItem((GenericListPtr)dstConfig->screens, - (GenericListPtr)dstScreen); + xconfigAddListItem((GenericListPtr *)(&dstConfig->screens), + (GenericListPtr)dstScreen); } /* Do the merge */ @@ -650,7 +644,7 @@ static int xconfigMergeLayout(XConfigPtr dstConfig, XConfigPtr srcConfig) /* Clear the destination's adjacency list */ - xconfigFreeAdjacencyList(dstLayout->adjacencies); + xconfigFreeAdjacencyList(&dstLayout->adjacencies); /* Copy adjacencies over */ diff --git a/src/XF86Config-parser/Module.c b/src/XF86Config-parser/Module.c index 0605367..69dde1a 100644 --- a/src/XF86Config-parser/Module.c +++ b/src/XF86Config-parser/Module.c @@ -114,8 +114,8 @@ xconfigParseModuleSubSection (XConfigLoadPtr head, char *name) } - return ((XConfigLoadPtr) xconfigAddListItem ((GenericListPtr) head, - (GenericListPtr) ptr)); + xconfigAddListItem((GenericListPtr *)(&head), (GenericListPtr)ptr); + return head; } XConfigModulePtr @@ -134,16 +134,14 @@ xconfigParseModuleSection (void) case LOAD: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "Load"); - ptr->loads = - xconfigAddNewLoadDirective (ptr->loads, val.str, - XCONFIG_LOAD_MODULE, NULL, TRUE); + xconfigAddNewLoadDirective (&ptr->loads, val.str, + XCONFIG_LOAD_MODULE, NULL, TRUE); break; case LOAD_DRIVER: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "LoadDriver"); - ptr->loads = - xconfigAddNewLoadDirective (ptr->loads, val.str, - XCONFIG_LOAD_DRIVER, NULL, TRUE); + xconfigAddNewLoadDirective (&ptr->loads, val.str, + XCONFIG_LOAD_DRIVER, NULL, TRUE); break; case SUBSECTION: if (xconfigGetSubToken (&(ptr->comment)) != STRING) @@ -212,8 +210,8 @@ xconfigPrintModuleSection (FILE * cf, XConfigModulePtr ptr) } } -XConfigLoadPtr -xconfigAddNewLoadDirective (XConfigLoadPtr head, char *name, int type, +void +xconfigAddNewLoadDirective (XConfigLoadPtr *pHead, char *name, int type, XConfigOptionPtr opts, int do_token) { XConfigLoadPtr new; @@ -226,49 +224,37 @@ xconfigAddNewLoadDirective (XConfigLoadPtr head, char *name, int type, new->next = NULL; if (do_token) { - if ((token = xconfigGetToken(NULL)) == COMMENT) + if ((token = xconfigGetToken(NULL)) == COMMENT) { new->comment = xconfigAddComment(new->comment, val.str); - else + } else { xconfigUnGetToken(token); + } } - return ((XConfigLoadPtr) xconfigAddListItem ((GenericListPtr) head, - (GenericListPtr) new)); + xconfigAddListItem((GenericListPtr *)pHead, (GenericListPtr)new); } -XConfigLoadPtr -xconfigRemoveLoadDirective(XConfigLoadPtr head, XConfigLoadPtr load) +void +xconfigRemoveLoadDirective(XConfigLoadPtr *pHead, XConfigLoadPtr load) { - XConfigLoadPtr prev = NULL; - XConfigLoadPtr l = head; + xconfigRemoveListItem((GenericListPtr *)pHead, (GenericListPtr)load); - while (l) { - if (l == load) { - if (prev) prev->next = load->next; - if (head == load) head = load->next; - TEST_FREE(load->name); - TEST_FREE(load->comment); - xconfigOptionListFree(load->opt); - free(load); - break; - } - - prev = l; - l = l->next; - } - - return head; + TEST_FREE(load->name); + TEST_FREE(load->comment); + xconfigFreeOptionList(&(load->opt)); + free(load); } void -xconfigFreeModules (XConfigModulePtr ptr) +xconfigFreeModules (XConfigModulePtr *ptr) { XConfigLoadPtr lptr; XConfigLoadPtr prev; - if (ptr == NULL) + if (ptr == NULL || *ptr == NULL) return; - lptr = ptr->loads; + + lptr = (*ptr)->loads; while (lptr) { TEST_FREE (lptr->name); @@ -277,6 +263,7 @@ xconfigFreeModules (XConfigModulePtr ptr) lptr = lptr->next; free (prev); } - TEST_FREE (ptr->comment); - free (ptr); + TEST_FREE ((*ptr)->comment); + free (*ptr); + *ptr = NULL; } diff --git a/src/XF86Config-parser/Monitor.c b/src/XF86Config-parser/Monitor.c index 32080a9..6a8fd00 100644 --- a/src/XF86Config-parser/Monitor.c +++ b/src/XF86Config-parser/Monitor.c @@ -560,9 +560,8 @@ VertDone: mptr->next = NULL; mptr->modes_name = val.str; mptr->modes = NULL; - ptr->modes_sections = (XConfigModesLinkPtr) - xconfigAddListItem((GenericListPtr)ptr->modes_sections, - (GenericListPtr)mptr); + xconfigAddListItem((GenericListPtr *)(&ptr->modes_sections), + (GenericListPtr)mptr); } break; case EOF_TOKEN: @@ -571,7 +570,7 @@ VertDone: default: xconfigErrorMsg(ParseErrorMsg, INVALID_KEYWORD_MSG, xconfigTokenString()); - CLEANUP (ptr); + CLEANUP (&ptr); return NULL; break; } @@ -619,7 +618,7 @@ xconfigParseModesSection (void) default: xconfigErrorMsg(ParseErrorMsg, INVALID_KEYWORD_MSG, xconfigTokenString()); - CLEANUP (ptr); + CLEANUP (&ptr); return NULL; break; } @@ -785,65 +784,78 @@ xconfigPrintModesSection (FILE * cf, XConfigModesPtr ptr) } void -xconfigFreeMonitorList (XConfigMonitorPtr ptr) +xconfigFreeMonitorList (XConfigMonitorPtr *ptr) { XConfigMonitorPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->vendor); - TEST_FREE (ptr->modelname); - TEST_FREE (ptr->comment); - xconfigOptionListFree (ptr->options); - xconfigFreeModeLineList (ptr->modelines); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->vendor); + TEST_FREE ((*ptr)->modelname); + TEST_FREE ((*ptr)->comment); + xconfigFreeOptionList (&((*ptr)->options)); + xconfigFreeModeLineList (&((*ptr)->modelines)); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } void -xconfigFreeModesList (XConfigModesPtr ptr) +xconfigFreeModesList (XConfigModesPtr *ptr) { XConfigModesPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->comment); - xconfigFreeModeLineList (ptr->modelines); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->comment); + xconfigFreeModeLineList (&((*ptr)->modelines)); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } void -xconfigFreeModeLineList (XConfigModeLinePtr ptr) +xconfigFreeModeLineList (XConfigModeLinePtr *ptr) { XConfigModeLinePtr prev; - while (ptr) + + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->comment); - TEST_FREE (ptr->clock); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->comment); + TEST_FREE ((*ptr)->clock); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } void -xconfigFreeModesLinkList (XConfigModesLinkPtr ptr) +xconfigFreeModesLinkList (XConfigModesLinkPtr *ptr) { XConfigModesLinkPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->modes_name); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->modes_name); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } diff --git a/src/XF86Config-parser/Pointer.c b/src/XF86Config-parser/Pointer.c index ed49669..29e1c85 100644 --- a/src/XF86Config-parser/Pointer.c +++ b/src/XF86Config-parser/Pointer.c @@ -110,69 +110,59 @@ xconfigParsePointerSection (void) case PROTOCOL: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "Protocol"); - ptr->options = xconfigAddNewOption(ptr->options, - "Protocol", val.str); + xconfigAddNewOption(&ptr->options, "Protocol", val.str); break; case PDEVICE: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "Device"); - ptr->options = xconfigAddNewOption(ptr->options, - "Device", val.str); + xconfigAddNewOption(&ptr->options, "Device", val.str); break; case EMULATE3: - ptr->options = - xconfigAddNewOption(ptr->options, "Emulate3Buttons", NULL); + xconfigAddNewOption(&ptr->options, "Emulate3Buttons", NULL); break; case EM3TIMEOUT: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "Emulate3Timeout"); s = xconfigULongToString(val.num); - ptr->options = - xconfigAddNewOption(ptr->options, "Emulate3Timeout", s); + xconfigAddNewOption(&ptr->options, "Emulate3Timeout", s); TEST_FREE(s); break; case CHORDMIDDLE: - ptr->options = xconfigAddNewOption(ptr->options, "ChordMiddle", - NULL); + xconfigAddNewOption(&ptr->options, "ChordMiddle", NULL); break; case PBUTTONS: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "Buttons"); s = xconfigULongToString(val.num); - ptr->options = xconfigAddNewOption(ptr->options, "Buttons", s); + xconfigAddNewOption(&ptr->options, "Buttons", s); TEST_FREE(s); break; case BAUDRATE: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "BaudRate"); s = xconfigULongToString(val.num); - ptr->options = - xconfigAddNewOption(ptr->options, "BaudRate", s); + xconfigAddNewOption(&ptr->options, "BaudRate", s); TEST_FREE(s); break; case SAMPLERATE: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "SampleRate"); s = xconfigULongToString(val.num); - ptr->options = - xconfigAddNewOption(ptr->options, "SampleRate", s); + xconfigAddNewOption(&ptr->options, "SampleRate", s); TEST_FREE(s); break; case PRESOLUTION: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "Resolution"); s = xconfigULongToString(val.num); - ptr->options = - xconfigAddNewOption(ptr->options, "Resolution", s); + xconfigAddNewOption(&ptr->options, "Resolution", s); TEST_FREE(s); break; case CLEARDTR: - ptr->options = - xconfigAddNewOption(ptr->options, "ClearDTR", NULL); + xconfigAddNewOption(&ptr->options, "ClearDTR", NULL); break; case CLEARRTS: - ptr->options = - xconfigAddNewOption(ptr->options, "ClearRTS", NULL); + xconfigAddNewOption(&ptr->options, "ClearRTS", NULL); break; case ZAXISMAPPING: switch (xconfigGetToken(ZMapTab)) { @@ -200,8 +190,7 @@ xconfigParsePointerSection (void) Error (ZAXISMAPPING_MSG, NULL); break; } - ptr->options = - xconfigAddNewOption(ptr->options, "ZAxisMapping", s); + xconfigAddNewOption(&ptr->options, "ZAxisMapping", s); TEST_FREE(s); break; case ALWAYSCORE: @@ -217,7 +206,7 @@ xconfigParsePointerSection (void) ptr->identifier = xconfigStrdup(CONF_IMPLICIT_POINTER); ptr->driver = xconfigStrdup("mouse"); - ptr->options = xconfigAddNewOption(ptr->options, "CorePointer", NULL); + xconfigAddNewOption(&ptr->options, "CorePointer", NULL); return ptr; } diff --git a/src/XF86Config-parser/Read.c b/src/XF86Config-parser/Read.c index 7d21e44..28b0432 100644 --- a/src/XF86Config-parser/Read.c +++ b/src/XF86Config-parser/Read.c @@ -68,9 +68,9 @@ static XConfigSymTabRec TopLevelTab[] = #define CLEANUP xconfigFreeConfig -#define READ_HANDLE_RETURN(f,func) \ - if ((ptr->f=func) == NULL) { \ - xconfigFreeConfig(ptr); \ +#define READ_HANDLE_RETURN(f,func) \ + if ((ptr->f=func) == NULL) { \ + xconfigFreeConfig(&ptr); \ return XCONFIG_RETURN_PARSE_ERROR; \ } @@ -78,21 +78,20 @@ static XConfigSymTabRec TopLevelTab[] = { \ type p = func(); \ if (p == NULL) { \ - xconfigFreeConfig(ptr); \ - return XCONFIG_RETURN_PARSE_ERROR; \ + xconfigFreeConfig(&ptr); \ + return XCONFIG_RETURN_PARSE_ERROR; \ } else { \ - ptr->field = (type) \ - xconfigAddListItem((GenericListPtr) ptr->field, \ - (GenericListPtr) p); \ + xconfigAddListItem((GenericListPtr *)(&ptr->field), \ + (GenericListPtr) p); \ } \ } -#define READ_ERROR(a,b) \ - do { \ +#define READ_ERROR(a,b) \ + do { \ xconfigErrorMsg(ParseErrorMsg, a, b); \ - xconfigFreeConfig(ptr); \ + xconfigFreeConfig(&ptr); \ return XCONFIG_RETURN_PARSE_ERROR; \ - } while (0) \ + } while (0) @@ -121,7 +120,7 @@ XConfigError xconfigReadConfigFile(XConfigPtr *configPtr) case SECTION: if (xconfigGetSubToken(&(ptr->comment)) != STRING) { xconfigErrorMsg(ParseErrorMsg, QUOTE_MSG, "Section"); - xconfigFreeConfig(ptr); + xconfigFreeConfig(&ptr); return XCONFIG_RETURN_PARSE_ERROR; } @@ -248,7 +247,7 @@ XConfigError xconfigReadConfigFile(XConfigPtr *configPtr) *configPtr = ptr; return XCONFIG_RETURN_SUCCESS; } else { - xconfigFreeConfig(ptr); + xconfigFreeConfig(&ptr); return XCONFIG_RETURN_VALIDATION_ERROR; } } @@ -300,56 +299,47 @@ int xconfigSanitizeConfig(XConfigPtr p, /* * adds an item to the end of the linked list. Any record whose first field * is a GenericListRec can be cast to this type and used with this function. - * A pointer to the head of the list is returned to handle the addition of - * the first item. */ -GenericListPtr -xconfigAddListItem (GenericListPtr head, GenericListPtr new) +void xconfigAddListItem (GenericListPtr *pHead, GenericListPtr new) { - GenericListPtr p = head; + GenericListPtr p = *pHead; GenericListPtr last = NULL; - while (p) - { + while (p) { last = p; p = p->next; } - if (last) - { + if (last) { last->next = new; - return (head); + } else { + *pHead = new; } - else - return (new); } /* - * removes an item from the linked list. Any record whose first field - * is a GenericListRec can be cast to this type and used with this function. - * A pointer to the head of the list is returned to handle the removal of - * the first item. + * removes an item from the linked list (but does not delete it). Any record + * whose first field is a GenericListRec can be cast to this type and used + * with this function. */ -GenericListPtr -xconfigRemoveListItem (GenericListPtr head, GenericListPtr item) +void xconfigRemoveListItem (GenericListPtr *pHead, GenericListPtr item) { - GenericListPtr cur = head; + GenericListPtr cur = *pHead; GenericListPtr prev = NULL; - while (cur) - { - if (cur == item) - { - if (prev) prev->next = item->next; - if (head == item) head = item->next; - break; + while (cur) { + if (cur == item) { + if (prev) { + prev->next = item->next; + } else { + *pHead = item->next; + } + return; } prev = cur; cur = cur->next; } - - return head; } @@ -378,24 +368,25 @@ xconfigItemNotSublist(GenericListPtr list_1, GenericListPtr list_2) } void -xconfigFreeConfig (XConfigPtr p) +xconfigFreeConfig (XConfigPtr *p) { - if (p == NULL) + if (p == NULL || *p == NULL) return; - xconfigFreeFiles (p->files); - xconfigFreeModules (p->modules); - xconfigFreeFlags (p->flags); - xconfigFreeMonitorList (p->monitors); - xconfigFreeModesList (p->modes); - xconfigFreeVideoAdaptorList (p->videoadaptors); - xconfigFreeDeviceList (p->devices); - xconfigFreeScreenList (p->screens); - xconfigFreeLayoutList (p->layouts); - xconfigFreeInputList (p->inputs); - xconfigFreeVendorList (p->vendors); - xconfigFreeDRI (p->dri); - TEST_FREE(p->comment); - - free (p); + xconfigFreeFiles (&((*p)->files)); + xconfigFreeModules (&((*p)->modules)); + xconfigFreeFlags (&((*p)->flags)); + xconfigFreeMonitorList (&((*p)->monitors)); + xconfigFreeModesList (&((*p)->modes)); + xconfigFreeVideoAdaptorList (&((*p)->videoadaptors)); + xconfigFreeDeviceList (&((*p)->devices)); + xconfigFreeScreenList (&((*p)->screens)); + xconfigFreeLayoutList (&((*p)->layouts)); + xconfigFreeInputList (&((*p)->inputs)); + xconfigFreeVendorList (&((*p)->vendors)); + xconfigFreeDRI (&((*p)->dri)); + TEST_FREE((*p)->comment); + + free (*p); + *p = NULL; } diff --git a/src/XF86Config-parser/Screen.c b/src/XF86Config-parser/Screen.c index f58d76b..fbb155c 100644 --- a/src/XF86Config-parser/Screen.c +++ b/src/XF86Config-parser/Screen.c @@ -170,9 +170,8 @@ xconfigParseDisplaySubSection (void) mptr = calloc (1, sizeof (XConfigModeRec)); mptr->mode_name = val.str; mptr->next = NULL; - ptr->modes = (XConfigModePtr) - xconfigAddListItem ((GenericListPtr) ptr->modes, - (GenericListPtr) mptr); + xconfigAddListItem((GenericListPtr *)(&ptr->modes), + (GenericListPtr) mptr); } xconfigUnGetToken (token); } @@ -289,9 +288,8 @@ xconfigParseScreenSection (void) aptr = calloc (1, sizeof (XConfigAdaptorLinkRec)); aptr->next = NULL; aptr->adaptor_name = val.str; - ptr->adaptors = (XConfigAdaptorLinkPtr) - xconfigAddListItem ((GenericListPtr) ptr->adaptors, - (GenericListPtr) aptr); + xconfigAddListItem ((GenericListPtr *)(&ptr->adaptors), + (GenericListPtr) aptr); } } break; @@ -420,64 +418,76 @@ xconfigPrintScreenSection (FILE * cf, XConfigScreenPtr ptr) } void -xconfigFreeScreenList (XConfigScreenPtr ptr) +xconfigFreeScreenList (XConfigScreenPtr *ptr) { XConfigScreenPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->monitor_name); - TEST_FREE (ptr->device_name); - TEST_FREE (ptr->comment); - xconfigOptionListFree (ptr->options); - xconfigFreeAdaptorLinkList (ptr->adaptors); - xconfigFreeDisplayList (ptr->displays); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->monitor_name); + TEST_FREE ((*ptr)->device_name); + TEST_FREE ((*ptr)->comment); + xconfigFreeOptionList (&((*ptr)->options)); + xconfigFreeAdaptorLinkList (&((*ptr)->adaptors)); + xconfigFreeDisplayList (&((*ptr)->displays)); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } void -xconfigFreeAdaptorLinkList (XConfigAdaptorLinkPtr ptr) +xconfigFreeAdaptorLinkList (XConfigAdaptorLinkPtr *ptr) { XConfigAdaptorLinkPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->adaptor_name); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->adaptor_name); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } void -xconfigFreeDisplayList (XConfigDisplayPtr ptr) +xconfigFreeDisplayList (XConfigDisplayPtr *ptr) { XConfigDisplayPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - xconfigFreeModeList (ptr->modes); - xconfigOptionListFree (ptr->options); - prev = ptr; - ptr = ptr->next; + xconfigFreeModeList (&((*ptr)->modes)); + xconfigFreeOptionList (&((*ptr)->options)); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } void -xconfigFreeModeList (XConfigModePtr ptr) +xconfigFreeModeList (XConfigModePtr *ptr) { XConfigModePtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->mode_name); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->mode_name); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } @@ -639,40 +649,39 @@ xconfigFindMode (const char *name, XConfigModePtr p) return (NULL); } -XConfigModePtr -xconfigAddMode(XConfigModePtr head, const char *name) +void +xconfigAddMode(XConfigModePtr *pHead, const char *name) { XConfigModePtr mode; mode = xconfigAlloc(sizeof(XConfigModeRec)); mode->mode_name = xconfigStrdup(name); - mode->next = head; - - return mode; - + mode->next = *pHead; + *pHead = mode; } -XConfigModePtr -xconfigRemoveMode(XConfigModePtr head, const char *name) +void +xconfigRemoveMode(XConfigModePtr *pHead, const char *name) { - XConfigModePtr prev = NULL; - XConfigModePtr m = head; - - while (m) { - if (xconfigNameCompare(m->mode_name, name) == 0) { - if (prev) prev->next = m->next; - if (head == m) head = m->next; - free(m->mode_name); - free(m); - break; + XConfigModePtr p = *pHead; + XConfigModePtr last = NULL; + + while (p) { + if (xconfigNameCompare(p->mode_name, name) == 0) { + if (last) { + last->next = p->next; + } else { + *pHead = p->next; + } + free(p->mode_name); + free(p); + return; } - prev = m; - m = m->next; + last = p; + p = p->next; } - - return head; } diff --git a/src/XF86Config-parser/Vendor.c b/src/XF86Config-parser/Vendor.c index 7f6beba..ba0ca09 100644 --- a/src/XF86Config-parser/Vendor.c +++ b/src/XF86Config-parser/Vendor.c @@ -203,30 +203,35 @@ xconfigPrintVendorSection (FILE * cf, XConfigVendorPtr ptr) } void -xconfigFreeVendorList (XConfigVendorPtr p) +xconfigFreeVendorList (XConfigVendorPtr *p) { - if (p == NULL) + if (p == NULL || *p == NULL) return; - xconfigFreeVendorSubList (p->subs); - TEST_FREE (p->identifier); - TEST_FREE (p->comment); - xconfigOptionListFree (p->options); - free (p); + + xconfigFreeVendorSubList (&((*p)->subs)); + TEST_FREE ((*p)->identifier); + TEST_FREE ((*p)->comment); + xconfigFreeOptionList (&((*p)->options)); + free (*p); + *p = NULL; } void -xconfigFreeVendorSubList (XConfigVendSubPtr ptr) +xconfigFreeVendorSubList (XConfigVendSubPtr *ptr) { XConfigVendSubPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->name); - TEST_FREE (ptr->comment); - xconfigOptionListFree (ptr->options); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->name); + TEST_FREE ((*ptr)->comment); + xconfigFreeOptionList (&((*ptr)->options)); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } diff --git a/src/XF86Config-parser/Video.c b/src/XF86Config-parser/Video.c index a09d7f7..2a66dce 100644 --- a/src/XF86Config-parser/Video.c +++ b/src/XF86Config-parser/Video.c @@ -233,39 +233,45 @@ xconfigPrintVideoAdaptorSection (FILE * cf, XConfigVideoAdaptorPtr ptr) } void -xconfigFreeVideoAdaptorList (XConfigVideoAdaptorPtr ptr) +xconfigFreeVideoAdaptorList (XConfigVideoAdaptorPtr *ptr) { XConfigVideoAdaptorPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->vendor); - TEST_FREE (ptr->board); - TEST_FREE (ptr->busid); - TEST_FREE (ptr->driver); - TEST_FREE (ptr->fwdref); - TEST_FREE (ptr->comment); - xconfigFreeVideoPortList (ptr->ports); - xconfigOptionListFree (ptr->options); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->vendor); + TEST_FREE ((*ptr)->board); + TEST_FREE ((*ptr)->busid); + TEST_FREE ((*ptr)->driver); + TEST_FREE ((*ptr)->fwdref); + TEST_FREE ((*ptr)->comment); + xconfigFreeVideoPortList (&((*ptr)->ports)); + xconfigFreeOptionList (&((*ptr)->options)); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } void -xconfigFreeVideoPortList (XConfigVideoPortPtr ptr) +xconfigFreeVideoPortList (XConfigVideoPortPtr *ptr) { XConfigVideoPortPtr prev; - while (ptr) + if (ptr == NULL || *ptr == NULL) + return; + + while (*ptr) { - TEST_FREE (ptr->identifier); - TEST_FREE (ptr->comment); - xconfigOptionListFree (ptr->options); - prev = ptr; - ptr = ptr->next; + TEST_FREE ((*ptr)->identifier); + TEST_FREE ((*ptr)->comment); + xconfigFreeOptionList (&((*ptr)->options)); + prev = *ptr; + *ptr = (*ptr)->next; free (prev); } } diff --git a/src/XF86Config-parser/xf86Parser.h b/src/XF86Config-parser/xf86Parser.h index 6598d5e..7d34407 100644 --- a/src/XF86Config-parser/xf86Parser.h +++ b/src/XF86Config-parser/xf86Parser.h @@ -604,7 +604,7 @@ int xconfigSanitizeConfig(XConfigPtr p, const char *screenName, void xconfigCloseConfigFile(void); int xconfigWriteConfigFile(const char *, XConfigPtr); -void xconfigFreeConfig(XConfigPtr p); +void xconfigFreeConfig(XConfigPtr *p); /* * Functions for searching for entries in lists @@ -629,29 +629,30 @@ XConfigVideoAdaptorPtr xconfigFindVideoAdaptor(const char *ident, * Functions for freeing lists */ -void xconfigFreeDeviceList(XConfigDevicePtr ptr); -void xconfigFreeFiles(XConfigFilesPtr p); -void xconfigFreeFlags(XConfigFlagsPtr flags); -void xconfigFreeInputList(XConfigInputPtr ptr); -void xconfigFreeLayoutList(XConfigLayoutPtr ptr); -void xconfigFreeAdjacencyList(XConfigAdjacencyPtr ptr); -void xconfigFreeInputrefList(XConfigInputrefPtr ptr); -void xconfigFreeModules(XConfigModulePtr ptr); -void xconfigFreeMonitorList(XConfigMonitorPtr ptr); -void xconfigFreeModesList(XConfigModesPtr ptr); -void xconfigFreeModeLineList(XConfigModeLinePtr ptr); -void xconfigFreeScreenList(XConfigScreenPtr ptr); -void xconfigFreeAdaptorLinkList(XConfigAdaptorLinkPtr ptr); -void xconfigFreeDisplayList(XConfigDisplayPtr ptr); -void xconfigFreeModeList(XConfigModePtr ptr); -void xconfigFreeVendorList(XConfigVendorPtr p); -void xconfigFreeVendorSubList(XConfigVendSubPtr ptr); -void xconfigFreeVideoAdaptorList(XConfigVideoAdaptorPtr ptr); -void xconfigFreeVideoPortList(XConfigVideoPortPtr ptr); -void xconfigFreeBuffersList (XConfigBuffersPtr ptr); -void xconfigFreeDRI(XConfigDRIPtr ptr); -void xconfigFreeExtensions(XConfigExtensionsPtr ptr); -void xconfigFreeModesLinkList(XConfigModesLinkPtr ptr); +void xconfigFreeDeviceList(XConfigDevicePtr *ptr); +void xconfigFreeFiles(XConfigFilesPtr *p); +void xconfigFreeFlags(XConfigFlagsPtr *flags); +void xconfigFreeInputList(XConfigInputPtr *ptr); +void xconfigFreeLayoutList(XConfigLayoutPtr *ptr); +void xconfigFreeAdjacencyList(XConfigAdjacencyPtr *ptr); +void xconfigFreeInputrefList(XConfigInputrefPtr *ptr); +void xconfigFreeModules(XConfigModulePtr *ptr); +void xconfigFreeMonitorList(XConfigMonitorPtr *ptr); +void xconfigFreeModesList(XConfigModesPtr *ptr); +void xconfigFreeModeLineList(XConfigModeLinePtr *ptr); +void xconfigFreeOptionList(XConfigOptionPtr *opt); +void xconfigFreeScreenList(XConfigScreenPtr *ptr); +void xconfigFreeAdaptorLinkList(XConfigAdaptorLinkPtr *ptr); +void xconfigFreeDisplayList(XConfigDisplayPtr *ptr); +void xconfigFreeModeList(XConfigModePtr *ptr); +void xconfigFreeVendorList(XConfigVendorPtr *p); +void xconfigFreeVendorSubList(XConfigVendSubPtr *ptr); +void xconfigFreeVideoAdaptorList(XConfigVideoAdaptorPtr *ptr); +void xconfigFreeVideoPortList(XConfigVideoPortPtr *ptr); +void xconfigFreeBuffersList (XConfigBuffersPtr *ptr); +void xconfigFreeDRI(XConfigDRIPtr *ptr); +void xconfigFreeExtensions(XConfigExtensionsPtr *ptr); +void xconfigFreeModesLinkList(XConfigModesLinkPtr *ptr); @@ -659,26 +660,26 @@ void xconfigFreeModesLinkList(XConfigModesLinkPtr ptr); * item/list manipulation */ -GenericListPtr xconfigAddListItem(GenericListPtr head, GenericListPtr c_new); -GenericListPtr xconfigRemoveListItem(GenericListPtr list, GenericListPtr item); +void xconfigAddListItem(GenericListPtr *pHead, GenericListPtr c_new); +void xconfigRemoveListItem(GenericListPtr *pHead, GenericListPtr item); int xconfigItemNotSublist(GenericListPtr list_1, GenericListPtr list_2); char *xconfigAddComment(char *cur, char *add); -XConfigLoadPtr xconfigAddNewLoadDirective(XConfigLoadPtr head, - char *name, int type, - XConfigOptionPtr opts, int do_token); -XConfigLoadPtr xconfigRemoveLoadDirective(XConfigLoadPtr head, - XConfigLoadPtr load); +void xconfigAddNewLoadDirective(XConfigLoadPtr *pHead, + char *name, int type, + XConfigOptionPtr opts, int do_token); +void xconfigRemoveLoadDirective(XConfigLoadPtr *pHead, XConfigLoadPtr load); /* * Functions for manipulating Options */ -XConfigOptionPtr xconfigAddNewOption(XConfigOptionPtr head, - const char *name, const char *val); -XConfigOptionPtr xconfigRemoveOption(XConfigOptionPtr list, - XConfigOptionPtr opt); +void xconfigAddNewOption(XConfigOptionPtr *pHead, + const char *name, const char *val); +void xconfigRemoveOption(XConfigOptionPtr *pHead, XConfigOptionPtr opt); +void xconfigRemoveNamedOption(XConfigOptionPtr *head, const char *name, + char **comments); + XConfigOptionPtr xconfigOptionListDup(XConfigOptionPtr opt); -void xconfigOptionListFree(XConfigOptionPtr opt); char *xconfigOptionName(XConfigOptionPtr opt); char *xconfigOptionValue(XConfigOptionPtr opt); XConfigOptionPtr xconfigNewOption(const char *name, const char *value); @@ -705,15 +706,10 @@ void xconfigPrintOptionList(FILE *fp, XConfigOptionPtr list, int tabs); int xconfigParsePciBusString(const char *busID, int *bus, int *device, int *func); -XConfigDisplayPtr -xconfigAddDisplay(XConfigDisplayPtr head, const int depth); - -XConfigModePtr -xconfigAddMode(XConfigModePtr head, const char *name); - -XConfigModePtr -xconfigRemoveMode(XConfigModePtr head, const char *name); +void xconfigAddDisplay(XConfigDisplayPtr *pHead, const int depth); +void xconfigAddMode(XConfigModePtr *pHead, const char *name); +void xconfigRemoveMode(XConfigModePtr *pHead, const char *name); XConfigPtr xconfigGenerate(GenerateOptions *gop); diff --git a/src/command-line.c b/src/command-line.c index 67616a5..326092f 100644 --- a/src/command-line.c +++ b/src/command-line.c @@ -46,6 +46,7 @@ static void print_assign_help(void); static void print_query_help(void); +static void print_attribute_help(char *attr); static void print_help(void); static char *tilde_expansion(char *str); static char *nvstrcat(const char *str, ...); @@ -151,6 +152,11 @@ static const NVGetoptOption __options[] = { { "glxinfo", 'g', 0, NULL, "Print GLX Information for the X display and exit." }, + { "describe", 'e', NVGETOPT_HAS_ARGUMENT, NULL, + "Prints information about a particular attribute. Specify 'all' to " + "list the descriptions of all attributes. Specify 'list' to list the " + "attribute names without a descriptions." }, + { NULL, 0, 0, 0 }, }; @@ -247,6 +253,81 @@ static void print_query_help(void) /* + * print_attribute_help() - print information about the specified attribute. + */ + +static void print_attribute_help(char *attr) +{ + AttributeTableEntry *entry; + int found = 0; + int list_all = 0; + int show_desc = 1; + + + if (!strcasecmp(attr, "all")) { + list_all = 1; + + } else if (!strcasecmp(attr, "list")) { + list_all = 1; + show_desc = 0; + } + + nv_msg(NULL, ""); + + for (entry = attributeTable; entry->name; entry++) { + + if (list_all || !strcasecmp(attr, entry->name)) { + + if (show_desc) { + nv_msg(NULL, "Attribute '%s':", entry->name); + + if (entry->flags & NV_PARSER_TYPE_FRAMELOCK) + nv_msg(NULL, " - Is Frame Lock attribute."); + if (entry->flags & NV_PARSER_TYPE_NO_CONFIG_WRITE) + nv_msg(NULL, " - Attribute is not written to the rc file."); + if (entry->flags & NV_PARSER_TYPE_GUI_ATTRIBUTE) + nv_msg(NULL, " - Is GUI attribute."); + if (entry->flags & NV_PARSER_TYPE_XVIDEO_ATTRIBUTE) + nv_msg(NULL, " - Is X Video attribute."); + if (entry->flags & NV_PARSER_TYPE_PACKED_ATTRIBUTE) + nv_msg(NULL, " - Attribute value is packed integer."); + if (entry->flags & NV_PARSER_TYPE_VALUE_IS_DISPLAY) + nv_msg(NULL, " - Attribute value is a display mask."); + if (entry->flags & NV_PARSER_TYPE_NO_QUERY_ALL) + nv_msg(NULL, " - Attribute not queried in 'query all'."); + if (entry->flags & NV_PARSER_TYPE_NO_ZERO_VALUE) + nv_msg(NULL, " - Attribute cannot be zero."); + if (entry->flags & NV_PARSER_TYPE_100Hz) + nv_msg(NULL, " - Attribute value is in units of Centihertz (1/100Hz)."); + if (entry->flags & NV_PARSER_TYPE_1000Hz) + nv_msg(NULL, " - Attribute value is in units of Milihertz (1/1000 Hz)."); + if (entry->flags & NV_PARSER_TYPE_STRING_ATTRIBUTE) + nv_msg(NULL, " - Attribute value is string."); + if (entry->flags & NV_PARSER_TYPE_SDI) + nv_msg(NULL, " - Is SDI attribute."); + if (entry->flags & NV_PARSER_TYPE_VALUE_IS_SWITCH_DISPLAY) + nv_msg(NULL, " - Attribute value is switch display."); + + nv_msg(TAB, entry->desc); + nv_msg(NULL, ""); + } else { + nv_msg(NULL, "%s", entry->name); + } + + found = 1; + if (!list_all) break; + } + } + + if (!found && !list_all) { + nv_error_msg("Unrecognized attribute name '%s'.\n", attr); + } + +} /* print_attribute_help() */ + + + +/* * print_help() - loop through the __options[] table, and print the * description of each option. */ @@ -364,6 +445,7 @@ Options *parse_command_line(int argc, char *argv[], char *dpy) case 'g': print_glxinfo(NULL); exit(0); break; case 't': __terse = NV_TRUE; break; case 'd': __display_device_string = NV_TRUE; break; + case 'e': print_attribute_help(strval); exit(0); break; default: nv_error_msg("Invalid commandline, please run `%s --help` " "for usage information.\n", argv[0]); diff --git a/src/config-file.c b/src/config-file.c index df4d5b3..11e5664 100644 --- a/src/config-file.c +++ b/src/config-file.c @@ -318,8 +318,14 @@ int nv_write_config_file(const char *filename, CtrlHandles *h, for (bit = 0; bit < 24; bit++) { mask = 1 << bit; - - if ((t->d & mask) == 0x0) continue; + + /* + * if this bit is not present in the screens's enabled + * display device mask (and the X screen has enabled + * display devices), skip to the next bit + */ + + if (((t->d & mask) == 0x0) && (t->d)) continue; status = NvCtrlGetValidDisplayAttributeValues (t->h, mask, a->attr, &valid); @@ -644,7 +650,7 @@ static void save_gui_parsed_attributes(ParsedAttributeWrapper *w, int i; for (i = 0; w[i].line != -1; i++) { - if (w[i].a.flags & NV_PARSER_TYPE_GUI_ATTRIUBUTE) { + if (w[i].a.flags & NV_PARSER_TYPE_GUI_ATTRIBUTE) { nv_parsed_attribute_add(p, &w[i].a); } } diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.c b/src/gtk+-2.x/ctkdisplayconfig-utils.c index f7d9289..7e6914c 100644 --- a/src/gtk+-2.x/ctkdisplayconfig-utils.c +++ b/src/gtk+-2.x/ctkdisplayconfig-utils.c @@ -239,7 +239,8 @@ void apply_screen_info_token(char *token, char *value, void *data) * "mode_name" dot_clock timings flags * **/ -static nvModeLinePtr modeline_parse(const char *modeline_str, +static nvModeLinePtr modeline_parse(nvDisplayPtr display, + const char *modeline_str, const int broken_doublescan_modelines) { nvModeLinePtr modeline = NULL; @@ -356,39 +357,56 @@ static nvModeLinePtr modeline_parse(const char *modeline_str, free(tmp); } + modeline->refresh_rate = 0; + if (display->is_sdi && display->gpu->num_gvo_modes) { + /* Fetch the SDI refresh rate of the mode from the gvo mode table */ + int i; + for (i = 0; i < display->gpu->num_gvo_modes; i++) { + if (display->gpu->gvo_mode_data[i].id && + display->gpu->gvo_mode_data[i].name && + !strcmp(display->gpu->gvo_mode_data[i].name, + modeline->data.identifier)) { + modeline->refresh_rate = display->gpu->gvo_mode_data[i].rate; + modeline->refresh_rate /= 1000.0; + break; + } + } + } - /* - * Calculate the vertical refresh rate of the modeline in Hz; - * divide by two for double scan modes (if the double scan - * modeline isn't broken; i.e., already has a correct vtotal), and - * multiply by two for interlaced modes (so that we report the - * field rate, rather than the frame rate) - */ + if (modeline->refresh_rate == 0) { + /* + * Calculate the vertical refresh rate of the modeline in Hz; + * divide by two for double scan modes (if the double scan + * modeline isn't broken; i.e., already has a correct vtotal), and + * multiply by two for interlaced modes (so that we report the + * field rate, rather than the frame rate) + */ - htotal = (double) modeline->data.htotal; - vtotal = (double) modeline->data.vtotal; + htotal = (double) modeline->data.htotal; + vtotal = (double) modeline->data.vtotal; - pclk = strtod(modeline->data.clock, &nptr); + pclk = strtod(modeline->data.clock, &nptr); - if ((pclk == 0.0) || !nptr || *nptr != '\0' || ((htotal * vtotal) == 0)) { - nv_warning_msg("Failed to compute the refresh rate " - "for the modeline '%s'", str); - goto fail; - } + if ((pclk == 0.0) || !nptr || *nptr != '\0' || ((htotal * vtotal) == 0)) { + nv_warning_msg("Failed to compute the refresh rate " + "for the modeline '%s'", str); + goto fail; + } - modeline->refresh_rate = (pclk * 1000000.0) / (htotal * vtotal); + modeline->refresh_rate = (pclk * 1000000.0) / (htotal * vtotal); - factor = 1.0; + factor = 1.0; - if ((modeline->data.flags & V_DBLSCAN) && !broken_doublescan_modelines) { - factor *= 0.5; - } + if ((modeline->data.flags & V_DBLSCAN) && !broken_doublescan_modelines) { + factor *= 0.5; + } - if (modeline->data.flags & V_INTERLACE) { - factor *= 2.0; - } + if (modeline->data.flags & V_INTERLACE) { + factor *= 2.0; + } - modeline->refresh_rate *= factor; + modeline->refresh_rate *= factor; + } /* Restore the locale */ if (old_locale) { @@ -921,7 +939,7 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, gchar **err_str) str = modeline_strs; while (strlen(str)) { - modeline = modeline_parse(str, broken_doublescan_modelines); + modeline = modeline_parse(display, str, broken_doublescan_modelines); if (!modeline) { *err_str = g_strdup_printf("Failed to parse the following " "modeline of display device\n" @@ -937,8 +955,8 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, gchar **err_str) } /* Add the modeline at the end of the display's modeline list */ - display->modelines = (nvModeLinePtr)xconfigAddListItem - ((GenericListPtr)display->modelines, (GenericListPtr)modeline); + xconfigAddListItem((GenericListPtr *)(&display->modelines), + (GenericListPtr)modeline); display->num_modelines++; /* Get next modeline string */ @@ -1243,9 +1261,8 @@ static Bool screen_add_metamode(nvScreenPtr screen, char *metamode_str, /* Add the metamode at the end of the screen's metamode list */ - screen->metamodes = - (nvMetaModePtr)xconfigAddListItem((GenericListPtr)screen->metamodes, - (GenericListPtr)metamode); + xconfigAddListItem((GenericListPtr *)(&screen->metamodes), + (GenericListPtr)metamode); /* Split up the metamode into separate modes */ @@ -1316,9 +1333,8 @@ static Bool screen_add_metamode(nvScreenPtr screen, char *metamode_str, /* Add the mode at the end of the display's mode list */ - display->modes = - (nvModePtr)xconfigAddListItem((GenericListPtr)display->modes, - (GenericListPtr)mode); + xconfigAddListItem((GenericListPtr *)(&display->modes), + (GenericListPtr)mode); display->num_modes++; } /* Done parsing a single metamode */ @@ -1391,9 +1407,8 @@ static Bool screen_check_metamodes(nvScreenPtr screen) } /* Add the mode at the end of display's mode list */ - display->modes = - (nvModePtr)xconfigAddListItem((GenericListPtr)display->modes, - (GenericListPtr)mode); + xconfigAddListItem((GenericListPtr *)(&display->modes), + (GenericListPtr)mode); display->num_modes++; metamode = metamode->next; @@ -1651,9 +1666,8 @@ void gpu_remove_and_free_display(nvDisplayPtr display) } /* Remove the display from the GPU */ - gpu->displays = - (nvDisplayPtr)xconfigRemoveListItem((GenericListPtr)gpu->displays, - (GenericListPtr)display); + xconfigRemoveListItem((GenericListPtr *)(&gpu->displays), + (GenericListPtr)display); gpu->connected_displays &= ~(display->device_mask); gpu->num_displays--; } @@ -1688,6 +1702,48 @@ static void gpu_remove_displays(nvGpuPtr gpu) +/** gpu_query_gvo_mode_info() **************************************** + * + * Adds GVO mode information to the GPU's gvo mode data table at + * the given table index. + * + **/ +static Bool gpu_query_gvo_mode_info(nvGpuPtr gpu, int mode_id, int table_idx) +{ + ReturnStatus ret1, ret2; + GvoModeData *data; + int rate; + char *name; + + + if (!gpu || table_idx >= gpu->num_gvo_modes) { + return FALSE; + } + + data = &(gpu->gvo_mode_data[table_idx]); + + ret1 = NvCtrlGetDisplayAttribute(gpu->handle, + mode_id, + NV_CTRL_GVO_VIDEO_FORMAT_REFRESH_RATE, + &(rate)); + + ret2 = NvCtrlGetStringDisplayAttribute(gpu->handle, + mode_id, + NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME, + &(name)); + + if ((ret1 == NvCtrlSuccess) && (ret2 == NvCtrlSuccess)) { + data->id = mode_id; + data->rate = rate; + data->name = name; + return TRUE; + } + + XFree(name); + return FALSE; +} + + /** gpu_add_display_from_server() ************************************ * * Adds the display with the device mask given to the GPU structure. @@ -1726,6 +1782,81 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu, } + /* Query if this display is an SDI display */ + ret = NvCtrlGetDisplayAttribute(gpu->handle, device_mask, + NV_CTRL_IS_GVO_DISPLAY, + &(display->is_sdi)); + if (ret != NvCtrlSuccess) { + nv_warning_msg("Failed to query if display device\n" + "0x%08x connected to GPU-%d '%s' is an\n" + "SDI device.", + device_mask, NvCtrlGetTargetId(gpu->handle), + gpu->name); + display->is_sdi = FALSE; + } + + + /* Load the SDI mode table so we can report accurate refresh rates. */ + if (display->is_sdi && !gpu->gvo_mode_data) { + unsigned int valid1 = 0; + unsigned int valid2 = 0; + NVCTRLAttributeValidValuesRec valid; + + ret = NvCtrlGetValidAttributeValues(gpu->handle, + NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT, + &valid); + if ((ret != NvCtrlSuccess) || + (valid.type != ATTRIBUTE_TYPE_INT_BITS)) { + valid1 = 0; + } else { + valid1 = valid.u.bits.ints; + } + + ret = NvCtrlGetValidAttributeValues(gpu->handle, + NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2, + &valid); + if ((ret != NvCtrlSuccess) || + (valid.type != ATTRIBUTE_TYPE_INT_BITS)) { + valid2 = 0; + } else { + valid2 = valid.u.bits.ints; + } + + /* Count the number of valid modes there are */ + gpu->num_gvo_modes = count_number_of_bits(valid1); + gpu->num_gvo_modes += count_number_of_bits(valid2); + if (gpu->num_gvo_modes > 0) { + gpu->gvo_mode_data = (GvoModeData *)calloc(gpu->num_gvo_modes, + sizeof(GvoModeData)); + } + if (!gpu->gvo_mode_data) { + gpu->num_gvo_modes = 0; + } else { + // Gather all the bits and dump them into the array + int idx = 0; // Index into gvo_mode_data. + int id = 0; // Mode ID + while (valid1) { + if (valid1 & 1) { + if (gpu_query_gvo_mode_info(gpu, id, idx)) { + idx++; + } + } + valid1 >>= 1; + id++; + } + while (valid2) { + if (valid2 & 1) { + if (gpu_query_gvo_mode_info(gpu, id, idx)) { + idx++; + } + } + valid2 >>= 1; + id++; + } + } + } + + /* Query the modelines for the display device */ if (!display_add_modelines_from_server(display, err_str)) { nv_warning_msg("Failed to add modelines to display device 0x%08x " @@ -1737,9 +1868,8 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu, /* Add the display at the end of gpu's display list */ - gpu->displays = - (nvDisplayPtr)xconfigAddListItem((GenericListPtr)gpu->displays, - (GenericListPtr)display); + xconfigAddListItem((GenericListPtr *)(&gpu->displays), + (GenericListPtr)display); gpu->connected_displays |= device_mask; gpu->num_displays++; return display; @@ -1811,9 +1941,8 @@ void gpu_remove_and_free_screen(nvScreenPtr screen) /* Remove the screen from the GPU */ gpu = screen->gpu; - gpu->screens = - (nvScreenPtr)xconfigRemoveListItem((GenericListPtr)gpu->screens, - (GenericListPtr)screen); + xconfigRemoveListItem((GenericListPtr *)(&gpu->screens), + (GenericListPtr)screen); gpu->num_screens--; /* Make sure other screens in the layout aren't relative @@ -1963,9 +2092,8 @@ static int gpu_add_screen_from_server(nvGpuPtr gpu, int screen_id, } } /* Add the screen at the end of the gpu's screen list */ - gpu->screens = - (nvScreenPtr)xconfigAddListItem((GenericListPtr)gpu->screens, - (GenericListPtr)screen); + xconfigAddListItem((GenericListPtr *)(&gpu->screens), + (GenericListPtr)screen); gpu->num_screens++; return TRUE; @@ -2256,8 +2384,8 @@ static Bool layout_add_gpu_from_server(nvLayoutPtr layout, unsigned int gpu_id, /* Add the GPU at the end of the layout's GPU list */ - layout->gpus = (nvGpuPtr)xconfigAddListItem((GenericListPtr)layout->gpus, - (GenericListPtr)gpu); + xconfigAddListItem((GenericListPtr *)(&layout->gpus), + (GenericListPtr)gpu); layout->num_gpus++; return TRUE; diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c index 33c291e..6033397 100644 --- a/src/gtk+-2.x/ctkdisplayconfig.c +++ b/src/gtk+-2.x/ctkdisplayconfig.c @@ -1116,6 +1116,8 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle, ctk_object->advanced_mode = FALSE; + ctk_object->last_resolution_idx = -1; + /* Set container properties of the object & pack the banner */ gtk_box_set_spacing(GTK_BOX(ctk_object), 5); @@ -2233,7 +2235,6 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object) auto_modeline = NULL; for (modeline = modelines; modeline; modeline = modeline->next) { - float modeline_rate; nvModeLinePtr m; int count_ref; /* # modelines with similar refresh rates */ int num_ref; /* Modeline # in a group of similar refresh rates */ @@ -2252,12 +2253,11 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object) continue; } - modeline_rate = modeline->refresh_rate; is_doublescan = (modeline->data.flags & V_DBLSCAN); is_interlaced = (modeline->data.flags & V_INTERLACE); - name = g_strdup_printf("%.0f Hz", modeline_rate); - + name = g_strdup_printf("%0.*f Hz", (display->is_sdi ? 3 : 0), + modeline->refresh_rate); /* Get a unique number for this modeline */ count_ref = 0; /* # modelines with similar refresh rates */ @@ -2273,7 +2273,9 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object) m != auto_modeline) { count_ref++; - /* Modelines with similar refresh rates get a unique # (num_ref) */ + /* Modelines with similar refresh rates get a + * unique # (num_ref) + */ if (m == modeline) { num_ref = count_ref; /* This modeline's # */ } @@ -2282,7 +2284,7 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object) } /* Is default refresh rate for resolution */ - if (!ctk_object->refresh_table_len) { + if (!ctk_object->refresh_table_len && !display->is_sdi) { auto_modeline = modeline; g_free(name); name = g_strdup("Auto"); @@ -2341,7 +2343,7 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object) modeline->data.vdisplay == cur_modeline->data.vdisplay) { float prev_rate = ctk_object->refresh_table[cur_idx]->refresh_rate; - float rate = modeline->refresh_rate; + float rate = modeline->refresh_rate; if (ctk_object->refresh_table[cur_idx]->data.hdisplay != cur_modeline->data.hdisplay || ctk_object->refresh_table[cur_idx]->data.vdisplay != cur_modeline->data.vdisplay) { @@ -4176,9 +4178,8 @@ void do_enable_display_for_xscreen(CtkDisplayConfig *ctk_object, /* Add the screen at the end of the gpu's screen list */ gpu = display->gpu; - gpu->screens = - (nvScreenPtr)xconfigAddListItem((GenericListPtr)gpu->screens, - (GenericListPtr)screen); + xconfigAddListItem((GenericListPtr *)(&gpu->screens), + (GenericListPtr)screen); gpu->num_screens++; @@ -4390,9 +4391,8 @@ static void do_enable_display_for_twinview(CtkDisplayConfig *ctk_object, /* Add the mode at the end of the display's mode list */ - display->modes = - (nvModePtr)xconfigAddListItem((GenericListPtr)display->modes, - (GenericListPtr)mode); + xconfigAddListItem((GenericListPtr *)(&display->modes), + (GenericListPtr)mode); display->num_modes++; } @@ -4477,9 +4477,8 @@ static void do_configure_display_for_xscreen(CtkDisplayConfig *ctk_object, } /* Append the metamode */ - new_screen->metamodes = - (nvMetaModePtr)xconfigAddListItem((GenericListPtr)new_screen->metamodes, - (GenericListPtr)metamode); + xconfigAddListItem((GenericListPtr *)(&new_screen->metamodes), + (GenericListPtr)metamode); new_screen->num_metamodes++; } @@ -4495,9 +4494,8 @@ static void do_configure_display_for_xscreen(CtkDisplayConfig *ctk_object, } /* Append the screen to the gpu */ - gpu->screens = - (nvScreenPtr)xconfigAddListItem((GenericListPtr)gpu->screens, - (GenericListPtr)new_screen); + xconfigAddListItem((GenericListPtr *)(&gpu->screens), + (GenericListPtr)new_screen); gpu->num_screens++; /* Earlier display devices get first dibs on low screen numbers */ @@ -4574,9 +4572,8 @@ static void do_configure_display_for_twinview(CtkDisplayConfig *ctk_object, metamode->source = METAMODE_SOURCE_NVCONTROL; /* Add the metamode at the end of the screen's metamode list */ - screen->metamodes = - (nvMetaModePtr)xconfigAddListItem((GenericListPtr)screen->metamodes, - (GenericListPtr)metamode); + xconfigAddListItem((GenericListPtr *)(&screen->metamodes), + (GenericListPtr)metamode); screen->num_metamodes++; } } @@ -4650,9 +4647,8 @@ static void do_configure_display_for_twinview(CtkDisplayConfig *ctk_object, } /* Add the mode at the end of display's mode list */ - display->modes = - (nvModePtr)xconfigAddListItem((GenericListPtr)display->modes, - (GenericListPtr)mode); + xconfigAddListItem((GenericListPtr *)(&display->modes), + (GenericListPtr)mode); display->num_modes++; metamode = metamode->next; } @@ -5107,6 +5103,7 @@ static void display_resolution_changed(GtkWidget *widget, gpointer user_data) { CtkDisplayConfig *ctk_object = CTK_DISPLAY_CONFIG(user_data); gint idx; + gint last_idx; nvModeLinePtr modeline; nvDisplayPtr display; @@ -5118,8 +5115,12 @@ static void display_resolution_changed(GtkWidget *widget, gpointer user_data) (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout)); + /* cache the selected index */ + last_idx = ctk_object->last_resolution_idx; + ctk_object->last_resolution_idx = idx; + /* Ignore selecting same resolution */ - if (display->cur_mode->modeline == modeline) { + if (idx == last_idx) { return; } @@ -6607,9 +6608,8 @@ static gboolean update_xconfig_save_buffer(CtkDisplayConfig *ctk_object) /* If we're not actualy doing a merge, close the file */ if (!merge && mergeConfig) { - xconfigFreeConfig(mergeConfig); + xconfigFreeConfig(&mergeConfig); xconfigCloseConfigFile(); - mergeConfig = NULL; } } @@ -6642,16 +6642,16 @@ static gboolean update_xconfig_save_buffer(CtkDisplayConfig *ctk_object) /* Merge the two X config structures */ if (mergeConfig) { result = xconfigMergeConfigs(mergeConfig, config); - xconfigFreeConfig(config); + xconfigFreeConfig(&config); xconfigCloseConfigFile(); - config = mergeConfig; if (!result) { - xconfigFreeConfig(mergeConfig); + xconfigFreeConfig(&mergeConfig); err_msg = g_strdup_printf("Failed to merge current configuration " "with existing X config file '%s'!", filename); goto fail; } + config = mergeConfig; } @@ -6670,7 +6670,7 @@ static gboolean update_xconfig_save_buffer(CtkDisplayConfig *ctk_object) goto fail; } xconfigWriteConfigFile(tmp_filename, config); - xconfigFreeConfig(config); + xconfigFreeConfig(&config); lseek(tmp_fd, 0, SEEK_SET); fstat(tmp_fd, &st); @@ -6795,9 +6795,8 @@ static Bool add_modelines_to_monitor(XConfigMonitorPtr monitor, if (!modeline) continue; /* Append to the end of the modeline list */ - monitor->modelines = - (XConfigModeLinePtr)xconfigAddListItem((GenericListPtr)monitor->modelines, - (GenericListPtr)modeline); + xconfigAddListItem((GenericListPtr *)(&monitor->modelines), + (GenericListPtr)modeline); } return TRUE; @@ -6929,7 +6928,7 @@ static Bool add_monitor_to_xconfig(nvDisplayPtr display, XConfigPtr config, /* Add other options */ - opt = xconfigAddNewOption(opt, "DPMS", NULL); + xconfigAddNewOption(&opt, "DPMS", NULL); monitor->options = opt; /* Add modelines used by this display */ @@ -6938,9 +6937,8 @@ static Bool add_monitor_to_xconfig(nvDisplayPtr display, XConfigPtr config, /* Append the monitor to the end of the monitor list */ - config->monitors = - (XConfigMonitorPtr)xconfigAddListItem((GenericListPtr)config->monitors, - (GenericListPtr)monitor); + xconfigAddListItem((GenericListPtr *)(&config->monitors), + (GenericListPtr)monitor); display->conf_monitor = monitor; return TRUE; @@ -6951,7 +6949,7 @@ static Bool add_monitor_to_xconfig(nvDisplayPtr display, XConfigPtr config, free(h_source); free(v_source); if (monitor) { - xconfigFreeMonitorList(monitor); + xconfigFreeMonitorList(&monitor); } return FALSE; @@ -6997,15 +6995,14 @@ static XConfigDevicePtr add_device_to_xconfig(nvGpuPtr gpu, XConfigPtr config, /* Append to the end of the device list */ - config->devices = - (XConfigDevicePtr)xconfigAddListItem((GenericListPtr)config->devices, - (GenericListPtr)device); + xconfigAddListItem((GenericListPtr *)(&config->devices), + (GenericListPtr)device); return device; fail: if (device) { - xconfigFreeDeviceList(device); + xconfigFreeDeviceList(&device); } return NULL; @@ -7023,12 +7020,11 @@ static Bool add_display_to_screen(nvScreenPtr screen, XConfigScreenPtr conf_screen) { /* Clear the display list */ - xconfigFreeDisplayList(conf_screen->displays); - conf_screen->displays = NULL; + xconfigFreeDisplayList(&conf_screen->displays); /* Add a single display subsection for the default depth */ - conf_screen->displays = xconfigAddDisplay(NULL, conf_screen->defaultdepth); + xconfigAddDisplay(&conf_screen->displays, conf_screen->defaultdepth); if (!conf_screen->displays) goto fail; @@ -7041,8 +7037,7 @@ static Bool add_display_to_screen(nvScreenPtr screen, return TRUE; fail: - xconfigFreeDisplayList(conf_screen->displays); - conf_screen->displays = NULL; + xconfigFreeDisplayList(&conf_screen->displays); return FALSE; @@ -7116,11 +7111,8 @@ static int add_screen_to_xconfig(CtkDisplayConfig *ctk_object, } /* Set the TwinView option */ - conf_screen->options = xconfigAddNewOption(conf_screen->options, - "TwinView", - ((screen->num_displays > 1) ? - "1" : "0" )); - + xconfigAddNewOption(&conf_screen->options, "TwinView", + ((screen->num_displays > 1) ? "1" : "0" )); /* Set the TwinviewXineramaInfoOrder option */ @@ -7128,9 +7120,8 @@ static int add_screen_to_xconfig(CtkDisplayConfig *ctk_object, gchar *primary_str = display_get_type_str(screen->primaryDisplay->device_mask, 0); - conf_screen->options = xconfigAddNewOption(conf_screen->options, - "TwinViewXineramaInfoOrder", - primary_str); + xconfigAddNewOption(&conf_screen->options, "TwinViewXineramaInfoOrder", + primary_str); g_free(primary_str); } @@ -7147,9 +7138,7 @@ static int add_screen_to_xconfig(CtkDisplayConfig *ctk_object, } if (metamode_strs) { - conf_screen->options = - xconfigAddNewOption(conf_screen->options, "metamodes", - metamode_strs); + xconfigAddNewOption(&conf_screen->options, "metamodes", metamode_strs); free(metamode_strs); } @@ -7167,9 +7156,8 @@ static int add_screen_to_xconfig(CtkDisplayConfig *ctk_object, /* Append to the end of the screen list */ - config->screens = - (XConfigScreenPtr)xconfigAddListItem((GenericListPtr)config->screens, - (GenericListPtr)conf_screen); + xconfigAddListItem((GenericListPtr *)(&config->screens), + (GenericListPtr)conf_screen); screen->conf_screen = conf_screen; @@ -7182,7 +7170,7 @@ static int add_screen_to_xconfig(CtkDisplayConfig *ctk_object, ret = XCONFIG_GEN_ERROR; bail: if (conf_screen) { - xconfigFreeScreenList(conf_screen); + xconfigFreeScreenList(&conf_screen); } return ret; @@ -7206,12 +7194,9 @@ static int add_screens_to_xconfig(CtkDisplayConfig *ctk_object, /* Clear the screen list */ - xconfigFreeMonitorList(config->monitors); - config->monitors = NULL; - xconfigFreeDeviceList(config->devices); - config->devices = NULL; - xconfigFreeScreenList(config->screens); - config->screens = NULL; + xconfigFreeMonitorList(&config->monitors); + xconfigFreeDeviceList(&config->devices); + xconfigFreeScreenList(&config->screens); /* Don't print the bus ID in the case where we have a single * GPU driving a single X screen @@ -7267,12 +7252,9 @@ static int add_screens_to_xconfig(CtkDisplayConfig *ctk_object, fail: ret = XCONFIG_GEN_ERROR; bail: - xconfigFreeMonitorList(config->monitors); - config->monitors = NULL; - xconfigFreeDeviceList(config->devices); - config->devices = NULL; - xconfigFreeScreenList(config->screens); - config->screens = NULL; + xconfigFreeMonitorList(&config->monitors); + xconfigFreeDeviceList(&config->devices); + xconfigFreeScreenList(&config->screens); return ret; } /* add_screens_to_xconfig() */ @@ -7310,9 +7292,8 @@ static Bool add_adjacency_to_xconfig(nvScreenPtr screen, XConfigPtr config) } /* Append to the end of the screen list */ - conf_layout->adjacencies = - (XConfigAdjacencyPtr)xconfigAddListItem((GenericListPtr)conf_layout->adjacencies, - (GenericListPtr)adj); + xconfigAddListItem((GenericListPtr *)(&conf_layout->adjacencies), + (GenericListPtr)adj); return TRUE; @@ -7343,8 +7324,7 @@ static Bool add_layout_to_xconfig(nvLayoutPtr layout, XConfigPtr config) /* Clean up the adjacencies */ - xconfigFreeAdjacencyList(conf_layout->adjacencies); - conf_layout->adjacencies = NULL; + xconfigFreeAdjacencyList(&conf_layout->adjacencies); /* Assign the adjacencies (in order) */ @@ -7369,10 +7349,8 @@ static Bool add_layout_to_xconfig(nvLayoutPtr layout, XConfigPtr config) config->flags = (XConfigFlagsPtr) calloc(1, sizeof(XConfigFlagsRec)); if (!config->flags) goto fail; } - config->flags->options = - xconfigAddNewOption(config->flags->options, - "Xinerama", - (layout->xinerama_enabled ? "1" : "0")); + xconfigAddNewOption(&config->flags->options, "Xinerama", + (layout->xinerama_enabled ? "1" : "0")); layout->conf_layout = conf_layout; return TRUE; @@ -7478,7 +7456,7 @@ static int generateXConfig(CtkDisplayConfig *ctk_object, XConfigPtr *pConfig) ret = XCONFIG_GEN_ERROR; bail: if (config) { - xconfigFreeConfig(config); + xconfigFreeConfig(&config); } return ret; diff --git a/src/gtk+-2.x/ctkdisplayconfig.h b/src/gtk+-2.x/ctkdisplayconfig.h index e87e8ab..5155e36 100644 --- a/src/gtk+-2.x/ctkdisplayconfig.h +++ b/src/gtk+-2.x/ctkdisplayconfig.h @@ -189,6 +189,8 @@ typedef struct _CtkDisplayConfig gboolean advanced_mode; /* True if we are in advanced mode */ GtkWidget *btn_reset; + + int last_resolution_idx; } CtkDisplayConfig; diff --git a/src/gtk+-2.x/ctkdisplaylayout.c b/src/gtk+-2.x/ctkdisplaylayout.c index 6d8b620..62a2125 100644 --- a/src/gtk+-2.x/ctkdisplaylayout.c +++ b/src/gtk+-2.x/ctkdisplaylayout.c @@ -2107,10 +2107,11 @@ static char *get_display_tooltip(CtkDisplayLayout *ctk_object, /* Display has mode/modeline */ } else { float ref = display->cur_mode->modeline->refresh_rate; - tip = g_strdup_printf("%s : %dx%d @ %.0f Hz", + tip = g_strdup_printf("%s : %dx%d @ %.*f Hz", display->name, display->cur_mode->modeline->data.hdisplay, display->cur_mode->modeline->data.vdisplay, + (display->is_sdi ? 3 : 0), ref); } @@ -2136,11 +2137,12 @@ static char *get_display_tooltip(CtkDisplayLayout *ctk_object, /* Display has mode/modeline */ } else { float ref = display->cur_mode->modeline->refresh_rate; - tip = g_strdup_printf("%s : %dx%d @ %.0f Hz (Screen: %d) " + tip = g_strdup_printf("%s : %dx%d @ %.*f Hz (Screen: %d) " "(GPU: %s)", display->name, display->cur_mode->modeline->data.hdisplay, display->cur_mode->modeline->data.vdisplay, + (display->is_sdi ? 3 : 0), ref, display->screen->scrnum, display->gpu->name); diff --git a/src/gtk+-2.x/ctkdisplaylayout.h b/src/gtk+-2.x/ctkdisplaylayout.h index 580ca26..95bb229 100644 --- a/src/gtk+-2.x/ctkdisplaylayout.h +++ b/src/gtk+-2.x/ctkdisplaylayout.h @@ -186,6 +186,7 @@ typedef struct nvDisplayRec { unsigned int device_mask; /* Bit mask to identify the display */ char *name; /* Display name (from NV-CONTROL) */ + Bool is_sdi; /* Is an SDI display */ nvModeLinePtr modelines; /* Modelines validated by X */ int num_modelines; @@ -263,6 +264,15 @@ typedef struct nvScreenRec { +/* GVO Mode information */ +typedef struct GvoModeDataRec { + unsigned int id; /* NV-CONTROL ID */ + char *name; + unsigned int rate; /* Refresh rate */ +} GvoModeData; + + + /* GPU (Device) */ typedef struct nvGpuRec { struct nvGpuRec *next; @@ -285,6 +295,9 @@ typedef struct nvGpuRec { int pci_device; int pci_func; + GvoModeData *gvo_mode_data; /* Information about GVO modes available */ + unsigned int num_gvo_modes; + nvScreenPtr screens; /* List of screens this GPU drives */ int num_screens; diff --git a/src/gtk+-2.x/ctkevent.c b/src/gtk+-2.x/ctkevent.c index 08f5adb..f56fa10 100644 --- a/src/gtk+-2.x/ctkevent.c +++ b/src/gtk+-2.x/ctkevent.c @@ -256,10 +256,14 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) MAKE_SIGNAL(NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT); MAKE_SIGNAL(NV_CTRL_MODE_SET_EVENT); MAKE_SIGNAL(NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE); + MAKE_SIGNAL(NV_CTRL_FRAMELOCK_SLAVEABLE); MAKE_SIGNAL(NV_CTRL_DISPLAYPORT_LINK_RATE); MAKE_SIGNAL(NV_CTRL_STEREO_EYES_EXCHANGE); MAKE_SIGNAL(NV_CTRL_NO_SCANOUT); MAKE_SIGNAL(NV_CTRL_GVO_CSC_CHANGED_EVENT); + MAKE_SIGNAL(NV_CTRL_PIXMAP_CACHE); + MAKE_SIGNAL(NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB); + MAKE_SIGNAL(NV_CTRL_IS_GVO_DISPLAY); #undef MAKE_SIGNAL @@ -270,7 +274,7 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) * knows about. */ -#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GVO_SYNC_TO_DISPLAY +#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_IS_GVO_DISPLAY #warning "There are attributes that do not emit signals!" #endif @@ -289,8 +293,6 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) MAKE_STRING_SIGNAL(NV_CTRL_STRING_NVIDIA_DRIVER_VERSION); MAKE_STRING_SIGNAL(NV_CTRL_STRING_DISPLAY_DEVICE_NAME); MAKE_STRING_SIGNAL(NV_CTRL_STRING_TV_ENCODER_NAME); - MAKE_STRING_SIGNAL(NV_CTRL_STRING_DDCCI_MISC_TRANSMIT_DISPLAY_DESCRIPTOR); - MAKE_STRING_SIGNAL(NV_CTRL_STRING_DDCCI_MISC_AUXILIARY_DISPLAY_DATA); MAKE_STRING_SIGNAL(NV_CTRL_STRING_GVO_FIRMWARE_VERSION); MAKE_STRING_SIGNAL(NV_CTRL_STRING_CURRENT_MODELINE); MAKE_STRING_SIGNAL(NV_CTRL_STRING_ADD_MODELINE); @@ -313,9 +315,10 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) MAKE_STRING_SIGNAL(NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER); MAKE_STRING_SIGNAL(NV_CTRL_STRING_SLI_MODE); MAKE_STRING_SIGNAL(NV_CTRL_STRING_PERFORMANCE_MODES); + MAKE_STRING_SIGNAL(NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME); #undef MAKE_STRING_SIGNAL -#if NV_CTRL_STRING_LAST_ATTRIBUTE != NV_CTRL_STRING_PERFORMANCE_MODES +#if NV_CTRL_STRING_LAST_ATTRIBUTE != NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME #warning "There are attributes that do not emit signals!" #endif diff --git a/src/gtk+-2.x/ctkframelock.c b/src/gtk+-2.x/ctkframelock.c index 66705fc..f7cad7c 100644 --- a/src/gtk+-2.x/ctkframelock.c +++ b/src/gtk+-2.x/ctkframelock.c @@ -83,7 +83,7 @@ enum * that entry. */ -#define NUM_GPU_SIGNALS 6 +#define NUM_GPU_SIGNALS 7 const char *__GPUSignals[NUM_GPU_SIGNALS] = { @@ -92,7 +92,8 @@ const char *__GPUSignals[NUM_GPU_SIGNALS] = CTK_EVENT_NAME(NV_CTRL_FRAMELOCK_SYNC), CTK_EVENT_NAME(NV_CTRL_FRAMELOCK_TEST_SIGNAL), CTK_EVENT_NAME(NV_CTRL_REFRESH_RATE), - CTK_EVENT_NAME(NV_CTRL_REFRESH_RATE_3) + CTK_EVENT_NAME(NV_CTRL_REFRESH_RATE_3), + CTK_EVENT_NAME(NV_CTRL_FRAMELOCK_SLAVEABLE) }; /* @@ -178,6 +179,7 @@ struct _nvDisplayDataRec { GtkWidget *server_label; GtkWidget *server_checkbox; gboolean masterable; + gboolean slaveable; GtkWidget *client_label; GtkWidget *client_checkbox; @@ -1156,6 +1158,40 @@ static void list_entry_update_framelock_controls(CtkFramelock *ctk_framelock, +/** list_entry_update_gpu_controls() ********************************* + * + * Updates a GPU list entry's GUI controls based on the current + * frame lock status. + * + */ +static void list_entry_update_gpu_controls(CtkFramelock *ctk_framelock, + nvListEntryPtr entry) +{ + nvGPUDataPtr data = (nvGPUDataPtr)(entry->data); + unsigned int slaveables; + nvDisplayDataPtr display_data; + nvListEntryPtr child; + ReturnStatus ret; + + + ret = NvCtrlGetDisplayAttribute(data->handle, + ~0, /* Query all displays */ + NV_CTRL_FRAMELOCK_SLAVEABLE, + &slaveables); + + /* Update the slaveable flag of the GPU's display devices */ + child = entry->children; + while (child) { + display_data = (nvDisplayDataPtr)(child->data); + /* Assume device is slaveable if slaveable query fails. */ + display_data->slaveable = ((ret != NvCtrlSuccess) || + (display_data->device_mask & slaveables)); + child = child->next_sibling; + } +} + + + /** list_entry_update_display_controls() ***************************** * * Updates a display device list entry's GUI controls based on @@ -1188,7 +1224,7 @@ static void list_entry_update_display_controls(CtkFramelock *ctk_framelock, client_checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(data->client_checkbox)); - /* Server Checkbox is unavailable when framelock is disabled, + /* Server Checkbox is unavailable when framelock is enabled, * this display is set as client, this display cannot be master * (display is driven by GPU that is connected through a * secondary connector.), or another server is already selected. @@ -1201,18 +1237,23 @@ static void list_entry_update_display_controls(CtkFramelock *ctk_framelock, gtk_widget_set_sensitive(data->server_checkbox, sensitive); /* When a server is selected, this display can only become a - * client if its refresh rate matches that of the client. + * client if its refresh rate matches that of the client, + * and the X server reports that it can frame lock this client + * correctly. */ sensitive = (!framelock_enabled && !server_checked && + data->slaveable && (!server_data || data->rate == server_data->rate)); gtk_widget_set_sensitive(data->client_label, sensitive); gtk_widget_set_sensitive(data->client_checkbox, sensitive); /* Gray out the display device's refresh rate when it is not - * the same as the current server's. + * the same as the current server's, or the X server tells us + * the client cannot be frame locked. */ - sensitive = (!server_data || data->rate == server_data->rate); + sensitive = ((!server_data || data->rate == server_data->rate) && + data->slaveable); gtk_widget_set_sensitive(data->rate_label, sensitive); gtk_widget_set_sensitive(data->rate_text, sensitive); gtk_widget_set_sensitive(data->label, sensitive); @@ -1247,18 +1288,24 @@ static void list_entry_update_controls(CtkFramelock *ctk_framelock, { if (!entry) return; - list_entry_update_controls(ctk_framelock, entry->children); - if (entry->data_type == ENTRY_DATA_FRAMELOCK) { list_entry_update_framelock_controls(ctk_framelock, entry); } else if (entry->data_type == ENTRY_DATA_GPU) { - /* Do nothing */ + list_entry_update_gpu_controls(ctk_framelock, entry); } else if (entry->data_type == ENTRY_DATA_DISPLAY) { list_entry_update_display_controls(ctk_framelock, entry); } + /* + * It is important that we recurse into children _after_ processing the + * current node, since display entries may depend on data updated in GPU + * entries (display entries are children of GPU entries). + */ + + list_entry_update_controls(ctk_framelock, entry->children); + list_entry_update_controls(ctk_framelock, entry->next_sibling); } @@ -3998,6 +4045,12 @@ static void gpu_state_received(GtkObject *object, break; + case NV_CTRL_FRAMELOCK_SLAVEABLE: + /* Update slaveable relationships in the GUI */ + update_framelock_controls(ctk_framelock); + break; + + default: /* Oops */ break; diff --git a/src/gtk+-2.x/ctkgpu.c b/src/gtk+-2.x/ctkgpu.c index 4edca9c..0a5fe34 100644 --- a/src/gtk+-2.x/ctkgpu.c +++ b/src/gtk+-2.x/ctkgpu.c @@ -123,7 +123,7 @@ static gchar *make_display_device_list(NvCtrlAttributeHandle *handle, GtkWidget* ctk_gpu_new( NvCtrlAttributeHandle *handle, - NvCtrlAttributeHandle **screen_handles, + CtrlHandleTarget *t, CtkEvent *ctk_event ) { @@ -284,7 +284,7 @@ GtkWidget* ctk_gpu_new( } else if (pData[0] > 0) { - ret = NvCtrlGetAttribute(screen_handles[pData[1]], + ret = NvCtrlGetAttribute(t[pData[1]].h, NV_CTRL_SHOW_SLI_HUD, &tmp); diff --git a/src/gtk+-2.x/ctkgpu.h b/src/gtk+-2.x/ctkgpu.h index 60a6220..757ed88 100644 --- a/src/gtk+-2.x/ctkgpu.h +++ b/src/gtk+-2.x/ctkgpu.h @@ -26,6 +26,7 @@ #define __CTK_GPU_H__ #include <gtk/gtk.h> +#include <query-assign.h> #include "ctkevent.h" @@ -70,7 +71,7 @@ struct _CtkGpuClass GType ctk_gpu_get_type (void) G_GNUC_CONST; GtkWidget* ctk_gpu_new (NvCtrlAttributeHandle *handle, - NvCtrlAttributeHandle **screen_handles, + CtrlHandleTarget *t, CtkEvent *ctk_event); GtkTextBuffer *ctk_gpu_create_help(GtkTextTagTable *); diff --git a/src/gtk+-2.x/ctkgvo-csc.c b/src/gtk+-2.x/ctkgvo-csc.c index 341b26f..51433b0 100644 --- a/src/gtk+-2.x/ctkgvo-csc.c +++ b/src/gtk+-2.x/ctkgvo-csc.c @@ -759,6 +759,8 @@ static void make_entry(CtkGvoCsc *ctk_gvo_csc, 0.001, // climb rate 6); // number of digits + gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(*widget), TRUE); + g_signal_connect(G_OBJECT(*widget), "value-changed", G_CALLBACK(spin_button_value_changed), diff --git a/src/gtk+-2.x/ctkgvo-sync.c b/src/gtk+-2.x/ctkgvo-sync.c index 1ac2e12..8082329 100644 --- a/src/gtk+-2.x/ctkgvo-sync.c +++ b/src/gtk+-2.x/ctkgvo-sync.c @@ -1319,6 +1319,19 @@ static void gvo_sync_event_received(GtkObject *object, switch (attribute) { case NV_CTRL_GVO_SYNC_MODE: ctk_gvo_sync->sync_mode = value; + widget = ctk_gvo_sync->sync_mode_menu; + + g_signal_handlers_block_by_func(G_OBJECT(widget), + G_CALLBACK(sync_mode_changed), + (gpointer) ctk_gvo_sync); + + ctk_drop_down_menu_set_current_value + (CTK_DROP_DOWN_MENU(widget), value); + + g_signal_handlers_unblock_by_func(G_OBJECT(widget), + G_CALLBACK(sync_mode_changed), + (gpointer) ctk_gvo_sync); + post_sync_mode_menu_changed(ctk_gvo_sync, value); break; diff --git a/src/gtk+-2.x/ctkimagesliders.c b/src/gtk+-2.x/ctkimagesliders.c index 820f603..0f18970 100644 --- a/src/gtk+-2.x/ctkimagesliders.c +++ b/src/gtk+-2.x/ctkimagesliders.c @@ -336,9 +336,15 @@ static void scale_value_received(GtkObject *object, gpointer arg1, if (event_struct->availability == FALSE) { gtk_widget_set_sensitive(scale, FALSE); gtk_widget_hide(scale); + g_object_set_data(G_OBJECT(CTK_SCALE(scale)->gtk_adjustment), + "attribute active", + GINT_TO_POINTER(0)); } else if (event_struct->availability == TRUE) { gtk_widget_set_sensitive(scale, TRUE); gtk_widget_show(scale); + g_object_set_data(G_OBJECT(CTK_SCALE(scale)->gtk_adjustment), + "attribute active", + GINT_TO_POINTER(1)); } break; default: diff --git a/src/gtk+-2.x/ctkslimm.c b/src/gtk+-2.x/ctkslimm.c index 1f6b1bd..a75aa9e 100644 --- a/src/gtk+-2.x/ctkslimm.c +++ b/src/gtk+-2.x/ctkslimm.c @@ -59,8 +59,8 @@ static Bool other_displays_have_modeline(nvLayoutPtr layout, typedef struct GridConfigRec { - int x; - int y; + int rows; + int columns; }GridConfig; /** @@ -111,13 +111,13 @@ static void remove_slimm_options(CtkSLIMM *ctk_object) XConfigPtr configptr = NULL; gchar *filename; gchar *msg; - XConfigOptionPtr tmp = NULL; filename = (gchar *)xconfigOpenConfigFile(NULL, NULL); if (!filename) { msg = g_strdup_printf("Failed to open X config file!"); - ctk_display_warning_msg(ctk_get_parent_window(GTK_WIDGET(ctk_object)), msg); + ctk_display_warning_msg(ctk_get_parent_window(GTK_WIDGET(ctk_object)), + msg); g_free(msg); xconfigCloseConfigFile(); return; @@ -126,28 +126,23 @@ static void remove_slimm_options(CtkSLIMM *ctk_object) if (xconfigReadConfigFile(&configptr) != XCONFIG_RETURN_SUCCESS) { msg = g_strdup_printf("Failed to read X config file '%s'!", filename); - ctk_display_warning_msg(ctk_get_parent_window(GTK_WIDGET(ctk_object)), msg); + ctk_display_warning_msg(ctk_get_parent_window(GTK_WIDGET(ctk_object)), + msg); g_free(msg); xconfigCloseConfigFile(); return; } /* Remove SLI Mosaic Option */ - tmp = xconfigFindOption(configptr->layouts->adjacencies->screen->options, "SLI"); - if (tmp != NULL) { - configptr->layouts->adjacencies->screen->options = - xconfigRemoveOption(configptr->layouts->adjacencies->screen->options, tmp); - } + xconfigRemoveNamedOption(&configptr->layouts->adjacencies->screen->options, + "SLI", NULL); /* Remove MetaMode Option */ - tmp = xconfigFindOption(configptr->layouts->adjacencies->screen->options, "MetaModes"); - if (tmp != NULL) { - configptr->layouts->adjacencies->screen->options = - xconfigRemoveOption(configptr->layouts->adjacencies->screen->options, tmp); - } + xconfigRemoveNamedOption(&configptr->layouts->adjacencies->screen->options, + "MetaModes", NULL); xconfigWriteConfigFile(filename, configptr); - xconfigFreeConfig(configptr); + xconfigFreeConfig(&configptr); xconfigCloseConfigFile(); } @@ -182,14 +177,10 @@ static void write_slimm_options(CtkSLIMM *ctk_object, gchar *metamode_str) return; } - adj = configptr->layouts->adjacencies; - - if (adj->next) { - /* There are additional screens! Remove them all from Layout */ - adj = adj->next; - while ((adj = (XConfigAdjacencyPtr) - xconfigRemoveListItem((GenericListPtr)configptr->layouts->adjacencies, - (GenericListPtr)adj))); + /* Remove all but the first adjacency from the layout */ + while ((adj = configptr->layouts->adjacencies->next) != NULL) { + xconfigRemoveListItem((GenericListPtr *)(&configptr->layouts->adjacencies), + (GenericListPtr)adj); } /* @@ -200,19 +191,15 @@ static void write_slimm_options(CtkSLIMM *ctk_object, gchar *metamode_str) configptr->layouts->adjacencies->screen->device->screen = -1; /* Write out SLI Mosaic Option */ - configptr->layouts->adjacencies->screen->options = - xconfigAddNewOption(configptr->layouts->adjacencies->screen->options, - "SLI", - "Mosaic"); + xconfigAddNewOption(&configptr->layouts->adjacencies->screen->options, + "SLI", "Mosaic"); /* Write out MetaMode Option */ - configptr->layouts->adjacencies->screen->options = - xconfigAddNewOption(configptr->layouts->adjacencies->screen->options, - "MetaModes", - metamode_str); + xconfigAddNewOption(&configptr->layouts->adjacencies->screen->options, + "MetaModes", metamode_str); xconfigWriteConfigFile(tmp_filename, configptr); - xconfigFreeConfig(configptr); + xconfigFreeConfig(&configptr); xconfigCloseConfigFile(); } @@ -240,8 +227,8 @@ static void save_xconfig_button_clicked(GtkWidget *widget, gpointer user_data) /* Get grid configuration values from index */ - x_displays = gridConfigs[idx].x; - y_displays = gridConfigs[idx].y; + x_displays = gridConfigs[idx].columns; + y_displays = gridConfigs[idx].rows; h_overlap = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ctk_object->spbtn_hedge_overlap)); @@ -318,7 +305,10 @@ static void display_resolution_changed(GtkWidget *widget, gpointer user_data) modeline = ctk_object->resolution_table[idx]; /* Ignore selecting same resolution */ - if (ctk_object->cur_modeline == modeline) { + if (ctk_object->cur_modeline == modeline || + (ctk_object->cur_modeline && modeline && + ctk_object->cur_modeline->data.hdisplay == modeline->data.hdisplay && + ctk_object->cur_modeline->data.vdisplay == modeline->data.vdisplay)) { return; } @@ -326,11 +316,11 @@ static void display_resolution_changed(GtkWidget *widget, gpointer user_data) ctk_object->cur_modeline = modeline; /* Adjust H and V overlap maximums and redraw total size label */ - gtk_spin_button_set_range(GTK_SPIN_BUTTON(ctk_object->spbtn_hedge_overlap), + gtk_spin_button_set_range(GTK_SPIN_BUTTON(ctk_object->spbtn_hedge_overlap), -modeline->data.hdisplay, modeline->data.hdisplay); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(ctk_object->spbtn_vedge_overlap), + gtk_spin_button_set_range(GTK_SPIN_BUTTON(ctk_object->spbtn_vedge_overlap), -modeline->data.vdisplay, modeline->data.vdisplay); @@ -394,8 +384,13 @@ static void setup_total_size_label(CtkSLIMM *ctk_object) idx = gtk_option_menu_get_history(GTK_OPTION_MENU(ctk_object->mnu_display_config)); /* Get grid configuration values from index */ - x_displays = gridConfigs[idx].x; - y_displays = gridConfigs[idx].y; + x_displays = gridConfigs[idx].columns; + y_displays = gridConfigs[idx].rows; + + gtk_widget_set_sensitive(ctk_object->spbtn_hedge_overlap, + x_displays > 1 ? True : False); + gtk_widget_set_sensitive(ctk_object->spbtn_vedge_overlap, + y_displays > 1 ? True : False); h_overlap = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ctk_object->spbtn_hedge_overlap)); v_overlap = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ctk_object->spbtn_vedge_overlap)); @@ -435,7 +430,7 @@ static void setup_display_refresh_dropdown(CtkSLIMM *ctk_object) } - cur_rate = ctk_object->cur_modeline->refresh_rate; + cur_rate = ctk_object->cur_modeline->refresh_rate; /* Create the menu index -> modeline pointer lookup table */ @@ -527,7 +522,6 @@ static void setup_display_refresh_dropdown(CtkSLIMM *ctk_object) } - /* Keep track of the selected modeline */ if (ctk_object->cur_modeline == modeline) { cur_idx = ctk_object->refresh_table_len; @@ -536,14 +530,14 @@ static void setup_display_refresh_dropdown(CtkSLIMM *ctk_object) } else if (ctk_object->refresh_table_len && ctk_object->refresh_table[cur_idx] != ctk_object->cur_modeline) { - /* Found a better resolution */ + /* Resolution must match */ if (modeline->data.hdisplay == ctk_object->cur_modeline->data.hdisplay && modeline->data.vdisplay == ctk_object->cur_modeline->data.vdisplay) { float prev_rate = ctk_object->refresh_table[cur_idx]->refresh_rate; - float rate = modeline->refresh_rate; - + float rate = modeline->refresh_rate; + /* Found better resolution */ if (ctk_object->refresh_table[cur_idx]->data.hdisplay != ctk_object->cur_modeline->data.hdisplay || ctk_object->refresh_table[cur_idx]->data.vdisplay != @@ -572,6 +566,8 @@ static void setup_display_refresh_dropdown(CtkSLIMM *ctk_object) (G_OBJECT(ctk_object->mnu_display_refresh), G_CALLBACK(display_refresh_changed), (gpointer) ctk_object); + ctk_object->cur_modeline = ctk_object->refresh_table[cur_idx]; + gtk_option_menu_set_menu(GTK_OPTION_MENU(ctk_object->mnu_display_refresh), menu); gtk_option_menu_set_history(GTK_OPTION_MENU(ctk_object->mnu_display_refresh), cur_idx); gtk_widget_set_sensitive(ctk_object->mnu_display_refresh, True); @@ -951,7 +947,7 @@ GtkWidget* ctk_slimm_new(NvCtrlAttributeHandle *handle, gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); hbox = gtk_hbox_new(FALSE, 0); - label = gtk_label_new("Display Configuration"); + label = gtk_label_new("Display Configuration (rows x columns)"); hseparator = gtk_hseparator_new(); gtk_widget_show(hseparator); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 10); @@ -966,10 +962,10 @@ GtkWidget* ctk_slimm_new(NvCtrlAttributeHandle *handle, ctk_slimm->mnu_display_config = optionmenu; menu = gtk_menu_new(); - for (iter = 0; gridConfigs[iter].x && gridConfigs[iter].y; iter++) { + for (iter = 0; gridConfigs[iter].columns && gridConfigs[iter].rows; iter++) { tmp = g_strdup_printf("%d x %d grid", - gridConfigs[iter].x, - gridConfigs[iter].y); + gridConfigs[iter].columns, + gridConfigs[iter].rows); menuitem = gtk_menu_item_new_with_label(tmp); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); @@ -1181,7 +1177,8 @@ GtkTextBuffer *ctk_slimm_create_help(GtkTextTagTable *table, ctk_help_heading(b, &i, "Display Configuration"); ctk_help_para(b, &i, "This drop down menu allows selection of the display grid " - "configuration for SLI Mosaic Mode."); + "configuration for SLI Mosaic Mode; the possible configurations " + "are described as rows x columns."); ctk_help_heading(b, &i, "Resolution"); ctk_help_para(b, &i, "This drop down menu allows selection of the resolution to " diff --git a/src/gtk+-2.x/ctkui.c b/src/gtk+-2.x/ctkui.c index 02c6fec..80aad4c 100644 --- a/src/gtk+-2.x/ctkui.c +++ b/src/gtk+-2.x/ctkui.c @@ -42,22 +42,16 @@ char *ctk_get_display(void) return gdk_get_display(); } -void ctk_main(NvCtrlAttributeHandle **screen_handles, int num_screen_handles, - NvCtrlAttributeHandle **gpu_handles, int num_gpu_handles, - NvCtrlAttributeHandle **vcs_handles, int num_vcs_handles, - ParsedAttribute *p, ConfigProperties *conf, - CtrlHandles *pCtrlHandles) +void ctk_main(ParsedAttribute *p, ConfigProperties *conf, + CtrlHandles *h) { int i, has_nv_control = FALSE; GList *list = NULL; list = g_list_append (list, gdk_pixbuf_from_pixdata(&nvidia_icon_pixdata, TRUE, NULL)); gtk_window_set_default_icon_list(list); - ctk_window_new(screen_handles, num_screen_handles, - gpu_handles, num_gpu_handles, - vcs_handles, num_vcs_handles, - p, conf, pCtrlHandles); - for (i = 0; i < num_screen_handles; i++) { - if (screen_handles[i]) { + ctk_window_new(p, conf, h); + for (i = 0; i < h->targets[X_SCREEN_TARGET].n; i++) { + if (h->targets[X_SCREEN_TARGET].t[i].h) { has_nv_control = TRUE; break; } diff --git a/src/gtk+-2.x/ctkui.h b/src/gtk+-2.x/ctkui.h index e8a16de..08e3b01 100644 --- a/src/gtk+-2.x/ctkui.h +++ b/src/gtk+-2.x/ctkui.h @@ -33,10 +33,7 @@ int ctk_init_check(int *argc, char **argv[]); char *ctk_get_display(void); -void ctk_main(NvCtrlAttributeHandle **, int, - NvCtrlAttributeHandle **, int, - NvCtrlAttributeHandle **, int, - ParsedAttribute*, +void ctk_main(ParsedAttribute*, ConfigProperties*, CtrlHandles*); diff --git a/src/gtk+-2.x/ctkvcs.c b/src/gtk+-2.x/ctkvcs.c index 6a09cda..619a921 100644 --- a/src/gtk+-2.x/ctkvcs.c +++ b/src/gtk+-2.x/ctkvcs.c @@ -24,18 +24,88 @@ #include <stdlib.h> /* malloc */ #include <stdio.h> /* snprintf */ +#include <string.h> #include <gtk/gtk.h> #include <gdk/gdkx.h> #include <X11/Xlib.h> #include "ctkbanner.h" - +#include "msg.h" #include "ctkvcs.h" #include "ctkevent.h" #include "ctkhelp.h" #include "ctkutils.h" +#define DEFAULT_UPDATE_VCS_INFO_TIME_INTERVAL 5000 + +#define VCS_PSU_STATE_NORMAL 0 +#define VCS_PSU_STATE_ABNORMAL 1 + +static gboolean update_vcs_info(gpointer); +static gboolean update_fan_status(CtkVcs *ctk_object); + +static void apply_fan_entry_token(char *token, char *value, void *data) +{ + FanEntryPtr pFanEntry = (FanEntryPtr) data; + + if (!strcasecmp("fan", token)) { + pFanEntry->fan_number = atoi(value); + } else if (!strcasecmp("speed", token)) { + pFanEntry->fan_speed = atoi(value); + } else if (!strcasecmp("fail", token)) { + pFanEntry->fan_failed = atoi(value); + } else { + nv_warning_msg("Unknown Fan Entry token value pair: %s=%s", + token, value); + } +} + +static void apply_thermal_entry_token(char *token, char *value, void *data) +{ + ThermalEntryPtr pThermalEntry = (ThermalEntryPtr) data; + + if (!strcasecmp("intake", token)) { + pThermalEntry->intake_temp = atoi(value); + } else if (!strcasecmp("exhaust", token)) { + pThermalEntry->exhaust_temp = atoi(value); + } else if (!strcasecmp("board", token)) { + pThermalEntry->board_temp = atoi(value); + } else { + nv_warning_msg("Unknown Thermal Entry token value pair: %s=%s", + token, value); + } +} + +static void apply_psu_entry_token(char *token, char *value, void *data) +{ + PSUEntryPtr pPSUEntry = (PSUEntryPtr) data; + + if (!strcasecmp("current", token)) { + pPSUEntry->psu_current = atoi(value); + } else if (!strcasecmp("power", token)) { + if (!strcasecmp("unknown", value)) { + pPSUEntry->psu_power = -1; + } else { + pPSUEntry->psu_power = atoi(value); + } + } else if (!strcasecmp("voltage", token)) { + if (!strcasecmp("unknown", value)) { + pPSUEntry->psu_voltage = -1; + } else { + pPSUEntry->psu_voltage = atoi(value); + } + } else if (!strcasecmp("state", token)) { + if (!strcasecmp("normal", value)) { + pPSUEntry->psu_state = VCS_PSU_STATE_NORMAL; + } else { + pPSUEntry->psu_state = VCS_PSU_STATE_ABNORMAL; + } + } else { + nv_warning_msg("Unknown PSU Entry token value pair: %s=%s", + token, value); + } +} GType ctk_vcs_get_type(void) { @@ -62,6 +132,307 @@ GType ctk_vcs_get_type(void) } +static gboolean update_vcs_info(gpointer user_data) +{ + char output_str[16]; + char *temp_str = NULL; + char *psu_str = NULL; + CtkVcs *ctk_object = CTK_VCS(user_data); + ThermalEntry thermEntry; + PSUEntry psuEntry; + gboolean high_perf_mode; + + /* These queries should always succeed for Canoas 2.0 and above */ + if ((NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_VCSC_HIGH_PERF_MODE, + &high_perf_mode) != NvCtrlSuccess) || + (NvCtrlGetStringAttribute(ctk_object->handle, + NV_CTRL_STRING_VCSC_TEMPERATURES, + &temp_str) != NvCtrlSuccess) || + (NvCtrlGetStringAttribute(ctk_object->handle, + NV_CTRL_STRING_VCSC_PSU_INFO, + &psu_str) != NvCtrlSuccess)) { + return FALSE; + } + + /* Extract out thermal and PSU entry tokens */ + + /* First Invalidate thermal and psu entries */ + thermEntry.intake_temp = -1; + thermEntry.exhaust_temp = -1; + thermEntry.board_temp = -1; + + psuEntry.psu_current = -1; + psuEntry.psu_power = -1; + psuEntry.psu_voltage = -1; + psuEntry.psu_state = -1; + + if (temp_str) { + parse_token_value_pairs(temp_str, apply_thermal_entry_token, &thermEntry); + } + if (psu_str) { + parse_token_value_pairs(psu_str, apply_psu_entry_token, &psuEntry); + } + + if ((thermEntry.intake_temp != -1) && + (thermEntry.exhaust_temp != -1) && + (thermEntry.board_temp != -1)) { + if (ctk_object->intake_temp) { + g_snprintf(output_str, 16, "%d C", thermEntry.intake_temp); + gtk_label_set_text(GTK_LABEL(ctk_object->intake_temp), output_str); + } + if (ctk_object->exhaust_temp) { + g_snprintf(output_str, 16, "%d C", thermEntry.exhaust_temp); + gtk_label_set_text(GTK_LABEL(ctk_object->exhaust_temp), output_str); + } + if (ctk_object->board_temp) { + g_snprintf(output_str, 16, "%d C", thermEntry.board_temp); + gtk_label_set_text(GTK_LABEL(ctk_object->board_temp), output_str); + } + } + + if ((psuEntry.psu_current != -1) && + (psuEntry.psu_state != -1)) { + if (ctk_object->psu_current) { + g_snprintf(output_str, 16, "%d A", psuEntry.psu_current); + gtk_label_set_text(GTK_LABEL(ctk_object->psu_current), output_str); + } + if (ctk_object->psu_state) { + switch (psuEntry.psu_state) { + case VCS_PSU_STATE_NORMAL: + g_snprintf(output_str, 16, "Normal"); + break; + case VCS_PSU_STATE_ABNORMAL: + g_snprintf(output_str, 16, "Abnormal"); + break; + default: + g_snprintf(output_str, 16, "Unknown"); + break; + } + gtk_label_set_text(GTK_LABEL(ctk_object->psu_state), output_str); + } + } + if (ctk_object->psu_power && psuEntry.psu_power != -1) { + g_snprintf(output_str, 16, "%d W", psuEntry.psu_power); + gtk_label_set_text(GTK_LABEL(ctk_object->psu_power), output_str); + } + + if (ctk_object->psu_voltage && psuEntry.psu_voltage != -1) { + g_snprintf(output_str, 16, "%d V", psuEntry.psu_voltage); + gtk_label_set_text(GTK_LABEL(ctk_object->psu_voltage), output_str); + } + + if (!update_fan_status(ctk_object)) { + return FALSE; + } + + return TRUE; +} + + + +/** create_error_dialog() ********************************* + * + * Creates a generic error message dialog widget + * + **/ + +GtkWidget * create_error_dialog(CtkVcs *ctk_object) +{ + GtkWidget *dialog; + GtkWidget *image; + GtkWidget *hbox; + GtkWidget *vbox; + GtkWidget *label; + + /* Display validation override confirmation dialog */ + dialog = gtk_dialog_new_with_buttons + ("Cannot Apply", + GTK_WINDOW(gtk_widget_get_parent(GTK_WIDGET(ctk_object))), + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT, + NULL); + + /* Main horizontal box */ + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + hbox, TRUE, TRUE, 5); + + /* Pack the information icon */ + image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, + GTK_ICON_SIZE_DIALOG); + gtk_misc_set_alignment(GTK_MISC(image), 0.0f, 0.0f); + gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 5); + + /* Main vertical box */ + vbox = gtk_vbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 5); + + + label = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.0f); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + ctk_object->error_dialog_label = label; + + /* Action Buttons */ + gtk_dialog_add_button(GTK_DIALOG(dialog), "OK", + GTK_RESPONSE_ACCEPT); + + gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); + + return dialog; + +} /* create_error_dialog() */ + + +static void vcs_perf_checkbox_toggled(GtkWidget *widget, gpointer user_data) +{ + CtkVcs *ctk_object = CTK_VCS(user_data); + gint enabled; + gint ret; + + enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + + ret = NvCtrlSetAttribute(ctk_object->handle, NV_CTRL_VCSC_HIGH_PERF_MODE, enabled); + + if (ret != NvCtrlSuccess) { + if (ctk_object->error_dialog_label) { + gchar *str; + str = g_strdup_printf("Failed to %s High Performance mode!", + (enabled ? "enable" : "disable")); + gtk_label_set_text(GTK_LABEL(ctk_object->error_dialog_label), str); + gtk_window_set_resizable(GTK_WINDOW(ctk_object->error_dialog), FALSE); + gtk_window_set_transient_for + (GTK_WINDOW(ctk_object->error_dialog), + GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(ctk_object)))); + gtk_widget_show(ctk_object->error_dialog); + gtk_dialog_run(GTK_DIALOG(ctk_object->error_dialog)); + gtk_widget_hide(ctk_object->error_dialog); + } + goto fail; + } + return; + fail: + g_signal_handlers_block_by_func(G_OBJECT(widget), + G_CALLBACK(vcs_perf_checkbox_toggled), + (gpointer) ctk_object); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), !enabled); + gtk_widget_set_sensitive(widget, FALSE); + g_signal_handlers_unblock_by_func(G_OBJECT(widget), + G_CALLBACK(vcs_perf_checkbox_toggled), + (gpointer) ctk_object); +} + + + +static gboolean update_fan_status(CtkVcs *ctk_object) +{ + gint ret; + char *fan_entry_str = NULL; + char *tokens; + GtkWidget *table; + GtkWidget *label; + FanEntry current_fan; + gchar output_str[16]; + gint current_row; + + if (!ctk_object->fan_status_container) { + return FALSE; + } + ret = NvCtrlGetStringAttribute(ctk_object->handle, + NV_CTRL_STRING_VCSC_FAN_STATUS, + &fan_entry_str); + if (ret != NvCtrlSuccess) { + return FALSE; + } + + ctk_empty_container(ctk_object->fan_status_container); + + /* Generate the new table */ + + table = gtk_table_new(1, 3, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_table_set_col_spacings(GTK_TABLE(table), 15); + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + gtk_box_pack_start(GTK_BOX(ctk_object->fan_status_container), + table, FALSE, FALSE, 0); + + + label = gtk_label_new("Fan Number"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_widget_set_size_request(label, ctk_object->req.width, -1); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + label = gtk_label_new("Fan Speed"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + label = gtk_label_new("Fan Status"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + + /* Parse string of fan entries and populate table */ + current_row = 1; + for (tokens = strtok(fan_entry_str, ";"); + tokens; + tokens = strtok(NULL, ";")) { + + /* Invalidate fan entry */ + current_fan.fan_number = -1; + current_fan.fan_speed = -1; + current_fan.fan_failed = -1; + + parse_token_value_pairs(tokens, apply_fan_entry_token, ¤t_fan); + + if ((current_fan.fan_number != -1) && + (current_fan.fan_speed != -1) && + (current_fan.fan_failed != -1)) { + + gtk_table_resize(GTK_TABLE(table), current_row + 1, 3); + g_snprintf(output_str, 16, "%d", current_fan.fan_number); + label = gtk_label_new(output_str); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_widget_set_size_request(label, ctk_object->req.width, -1); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, current_row, + current_row + 1, GTK_FILL, + GTK_FILL | GTK_EXPAND, 5, 0); + + g_snprintf(output_str, 16, "%d rpm", current_fan.fan_speed); + label = gtk_label_new(output_str); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, current_row, + current_row + 1, GTK_FILL, + GTK_FILL | GTK_EXPAND, 5, 0); + + + if (!current_fan.fan_failed) { + g_snprintf(output_str, 16, "Ok"); + } else { + g_snprintf(output_str, 16, "Failed"); + } + label = gtk_label_new(output_str); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, current_row, + current_row + 1, GTK_FILL, + GTK_FILL | GTK_EXPAND, 5, 0); + + current_row++; + + } else { + nv_warning_msg("Incomplete Fan Entry (fan=%d, speed=%d, failFlag=%d)", + current_fan.fan_number, + current_fan.fan_speed, + current_fan.fan_failed); + } + } + gtk_widget_show_all(table); + XFree(fan_entry_str); + return TRUE; +} + /* * CTK VCS (Visual Computing System) widget creation @@ -75,9 +446,12 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle, GtkWidget *label; GtkWidget *vbox; GtkWidget *hbox; + GtkWidget *event; GtkWidget *banner; GtkWidget *hseparator; GtkWidget *table; + GtkWidget *scrollWin; + GtkWidget *checkbutton; gchar *product_name; gchar *serial_number; @@ -86,7 +460,15 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle, gchar *firmware_version; gchar *hardware_version; + gint current_row; + gboolean high_perf_mode; + ReturnStatus ret; + gchar *s; + char *psu_str = NULL; + PSUEntry psuEntry; + + GtkWidget *vbox_scroll, *hbox_scroll; /* * get the static string data that we will display below @@ -149,6 +531,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle, /* cache the attribute handle */ ctk_object->handle = handle; + ctk_object->ctk_config = ctk_config; /* set container properties of the object */ @@ -167,8 +550,40 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle, vbox = gtk_vbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(ctk_object), vbox, TRUE, TRUE, 0); + /* General purpose error dialog */ + ctk_object->error_dialog = create_error_dialog(ctk_object); + + if (NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_VCSC_HIGH_PERF_MODE, + &high_perf_mode) == NvCtrlSuccess) { + + hbox = gtk_hbox_new(FALSE, 0); + checkbutton = gtk_check_button_new_with_label("Enable High Performance Mode"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), high_perf_mode); + g_signal_connect(G_OBJECT(checkbutton), "toggled", + G_CALLBACK(vcs_perf_checkbox_toggled), + (gpointer) ctk_object); + gtk_box_pack_start(GTK_BOX(hbox), checkbutton, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + } + + /* Create the Scrolling Window */ + scrollWin = gtk_scrolled_window_new(NULL, NULL); + hbox_scroll = gtk_hbox_new(FALSE, 0); + vbox_scroll = gtk_vbox_new(FALSE, 5); + event = gtk_event_box_new(); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollWin), + GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); + gtk_widget_modify_fg(event, GTK_STATE_NORMAL, &(event->style->text[GTK_STATE_NORMAL])); + gtk_widget_modify_bg(event, GTK_STATE_NORMAL, &(event->style->base[GTK_STATE_NORMAL])); + gtk_container_add(GTK_CONTAINER(event), hbox_scroll); + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollWin), + event); + gtk_box_pack_start(GTK_BOX(hbox_scroll), vbox_scroll, TRUE, TRUE, 5); + gtk_widget_set_size_request(scrollWin, -1, 50); + gtk_box_pack_start(GTK_BOX(vbox), scrollWin, TRUE, TRUE, 0); + hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox_scroll), hbox, FALSE, FALSE, 0); label = gtk_label_new("VCS Information"); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); @@ -177,7 +592,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle, gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); table = gtk_table_new(5, 2, FALSE); - gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox_scroll), table, FALSE, FALSE, 0); gtk_table_set_row_spacings(GTK_TABLE(table), 3); gtk_table_set_col_spacings(GTK_TABLE(table), 15); @@ -204,6 +619,188 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle, g_free(firmware_version); g_free(hardware_version); + + /* Query Canoas 2.0 specific details */ + if ((NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_VCSC_HIGH_PERF_MODE, + &high_perf_mode) == NvCtrlSuccess) && + (NvCtrlGetStringAttribute(ctk_object->handle, + NV_CTRL_STRING_VCSC_PSU_INFO, + &psu_str) == NvCtrlSuccess)) { + GtkWidget *vbox_padding; + + /* Show the additonal queried information */ + + + /* Populate scrolling window with data */ + vbox_padding = gtk_vbox_new(FALSE, 0); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox_scroll), vbox_padding, FALSE, FALSE, 1); + gtk_box_pack_start(GTK_BOX(vbox_scroll), hbox, FALSE, FALSE, 0); + label = gtk_label_new("VCS Thermal Information"); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + hseparator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); + + table = gtk_table_new(3, 2, FALSE); + gtk_box_pack_start(GTK_BOX(vbox_scroll), table, FALSE, FALSE, 0); + + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_table_set_col_spacings(GTK_TABLE(table), 15); + + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + + label = gtk_label_new("Intake Temperature:"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + label = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + ctk_object->intake_temp = label; + + label = gtk_label_new("Exhaust Temperature:"); + /* This is the current largest label. Get its size */ + gtk_widget_size_request(label, &ctk_object->req); + + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + label = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 1, 2, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + ctk_object->exhaust_temp = label; + + label = gtk_label_new("Board Temperature:"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + label = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 2, 3, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + ctk_object->board_temp = label; + + /* Populate table for PSU information */ + + psuEntry.psu_current = -1; + psuEntry.psu_power = -1; + psuEntry.psu_voltage = -1; + psuEntry.psu_state = -1; + + if (psu_str) { + parse_token_value_pairs(psu_str, apply_psu_entry_token, &psuEntry); + } + + vbox_padding = gtk_vbox_new(FALSE, 0); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox_scroll), vbox_padding, FALSE, FALSE, 1); + gtk_box_pack_start(GTK_BOX(vbox_scroll), hbox, FALSE, FALSE, 0); + label = gtk_label_new("VCS Power Supply Unit Information"); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + hseparator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); + + table = gtk_table_new(4, 2, FALSE); + gtk_box_pack_start(GTK_BOX(vbox_scroll), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_table_set_col_spacings(GTK_TABLE(table), 15); + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + + label = gtk_label_new("PSU State:"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_widget_set_size_request(label, ctk_object->req.width, -1); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + + label = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + ctk_object->psu_state = label; + + label = gtk_label_new("PSU Current:"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_widget_set_size_request(label, ctk_object->req.width, -1); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + + label = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, 1, 2, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + ctk_object->psu_current = label; + + current_row = 2; + + if (psuEntry.psu_power != -1) { + label = gtk_label_new("PSU Power:"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_widget_set_size_request(label, ctk_object->req.width, -1); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, + current_row, current_row + 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + label = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, + current_row, current_row + 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + ctk_object->psu_power = label; + current_row++; + } + + if (psuEntry.psu_voltage != -1) { + label = gtk_label_new("PSU Voltage:"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_widget_set_size_request(label, ctk_object->req.width, -1); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, + current_row, current_row + 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + label = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 1, 2, + current_row, current_row + 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + ctk_object->psu_voltage = label; + } + + /* Create container for fan status table */ + + vbox_padding = gtk_vbox_new(FALSE, 0); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox_scroll), vbox_padding, FALSE, FALSE, 1); + gtk_box_pack_start(GTK_BOX(vbox_scroll), hbox, FALSE, FALSE, 0); + label = gtk_label_new("VCS Fan Status"); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + hseparator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox_scroll), hbox, FALSE, FALSE, 0); + ctk_object->fan_status_container = hbox; + + /* Register a timer callback to update the dynamic information */ + s = g_strdup_printf("VCS Monitor (VCS %d)", + NvCtrlGetTargetId(ctk_object->handle)); + + ctk_config_add_timer(ctk_object->ctk_config, + DEFAULT_UPDATE_VCS_INFO_TIME_INTERVAL, + s, + (GSourceFunc) update_vcs_info, + (gpointer) ctk_object); + g_free(s); + + update_vcs_info(ctk_object); + } + gtk_widget_show_all(GTK_WIDGET(object)); return GTK_WIDGET(object); @@ -251,3 +848,23 @@ GtkTextBuffer *ctk_vcs_create_help(GtkTextTagTable *table, return b; } +void ctk_vcs_start_timer(GtkWidget *widget) +{ + CtkVcs *ctk_vcs = CTK_VCS(widget); + + /* Start the VCS timer */ + ctk_config_start_timer(ctk_vcs->ctk_config, + (GSourceFunc) update_vcs_info, + (gpointer) ctk_vcs); +} + +void ctk_vcs_stop_timer(GtkWidget *widget) +{ + CtkVcs *ctk_vcs = CTK_VCS(widget); + + /* Stop the VCS timer */ + ctk_config_stop_timer(ctk_vcs->ctk_config, + (GSourceFunc) update_vcs_info, + (gpointer) ctk_vcs); +} + diff --git a/src/gtk+-2.x/ctkvcs.h b/src/gtk+-2.x/ctkvcs.h index 120ee10..5e3a352 100644 --- a/src/gtk+-2.x/ctkvcs.h +++ b/src/gtk+-2.x/ctkvcs.h @@ -51,6 +51,28 @@ G_BEGIN_DECLS CtkVcsClass)) +typedef struct FanEntry +{ + gint fan_number; + gint fan_speed; + gint fan_failed; +} FanEntry, *FanEntryPtr; + +typedef struct ThermalEntry +{ + gint intake_temp; + gint exhaust_temp; + gint board_temp; +} ThermalEntry, *ThermalEntryPtr; + +typedef struct PSUEntry +{ + gint psu_current; + gint psu_voltage; + gint psu_power; + gint psu_state; +} PSUEntry, *PSUEntryPtr; + typedef struct _CtkVcs { GtkVBox parent; @@ -58,6 +80,18 @@ typedef struct _CtkVcs CtkConfig *ctk_config; NvCtrlAttributeHandle *handle; + GtkWidget *intake_temp; + GtkWidget *exhaust_temp; + GtkWidget *board_temp; + GtkWidget *psu_state; + GtkWidget *psu_current; + GtkWidget *psu_voltage; + GtkWidget *psu_power; + GtkWidget *error_dialog_label; + GtkWidget *error_dialog; + GtkWidget *fan_status_container; + GtkRequisition req; + } CtkVcs; typedef struct _CtkVcsClass @@ -72,6 +106,9 @@ GtkWidget* ctk_vcs_new (NvCtrlAttributeHandle *, CtkConfig *); GtkTextBuffer *ctk_vcs_create_help(GtkTextTagTable *, CtkVcs *); +void ctk_vcs_start_timer(GtkWidget *widget); +void ctk_vcs_stop_timer(GtkWidget *widget); + G_END_DECLS #endif /* __CTK_VCS_H__ */ diff --git a/src/gtk+-2.x/ctkwindow.c b/src/gtk+-2.x/ctkwindow.c index cb93c33..1043b79 100644 --- a/src/gtk+-2.x/ctkwindow.c +++ b/src/gtk+-2.x/ctkwindow.c @@ -367,14 +367,8 @@ static gboolean tree_view_key_event(GtkWidget *tree_view, GdkEvent *event, * ctk_window_new() - create a new CtkWindow widget */ -GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, - gint num_screen_handles, - NvCtrlAttributeHandle **gpu_handles, - gint num_gpu_handles, - NvCtrlAttributeHandle **vcs_handles, - gint num_vcs_handles, - ParsedAttribute *p, ConfigProperties *conf, - CtrlHandles *pCtrlHandles) +GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, + CtrlHandles *h) { GObject *object; CtkWindow *ctk_window; @@ -416,7 +410,7 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, /* create the config object */ - ctk_window->ctk_config = CTK_CONFIG(ctk_config_new(conf, pCtrlHandles)); + ctk_window->ctk_config = CTK_CONFIG(ctk_config_new(conf, h)); ctk_config = ctk_window->ctk_config; /* create the quit dialog */ @@ -556,7 +550,7 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, /* X Server info & configuration */ - if (num_screen_handles) { + if (h->targets[X_SCREEN_TARGET].n) { NvCtrlAttributeHandle *screen_handle = NULL; GtkWidget *child; @@ -568,9 +562,9 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, * pages. */ - for (i = 0 ; i < num_screen_handles; i++) { - if (screen_handles[i]) { - screen_handle = screen_handles[i]; + for (i = 0 ; i < h->targets[X_SCREEN_TARGET].n; i++) { + if (h->targets[X_SCREEN_TARGET].t[i].h) { + screen_handle = h->targets[X_SCREEN_TARGET].t[i].h; break; } } @@ -603,11 +597,11 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, /* add the per-screen entries into the tree model */ - for (i = 0; i < num_screen_handles; i++) { + for (i = 0; i < h->targets[X_SCREEN_TARGET].n; i++) { gchar *screen_name; GtkWidget *child; - NvCtrlAttributeHandle *screen_handle = screen_handles[i]; + NvCtrlAttributeHandle *screen_handle = h->targets[X_SCREEN_TARGET].t[i].h; if (!screen_handle) continue; @@ -639,7 +633,7 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, CTK_WINDOW_CONFIG_FILE_ATTRIBUTES_FUNC_COLUMN, NULL, -1); - if (num_vcs_handles) { + if (h->targets[VCS_TARGET].n) { /* SLI Mosaic Mode information */ child = ctk_slimm_new(screen_handle, ctk_event, ctk_config); @@ -759,13 +753,13 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, /* add the per-gpu entries into the tree model */ - for (i = 0; i < num_gpu_handles; i++) { + for (i = 0; i < h->targets[GPU_TARGET].n; i++) { gchar *gpu_product_name; gchar *gpu_name; GtkWidget *child; ReturnStatus ret; - NvCtrlAttributeHandle *gpu_handle = gpu_handles[i]; + NvCtrlAttributeHandle *gpu_handle = h->targets[GPU_TARGET].t[i].h; UpdateDisplaysData *data; @@ -795,7 +789,7 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, gtk_tree_store_append(ctk_window->tree_store, &iter, NULL); gtk_tree_store_set(ctk_window->tree_store, &iter, CTK_WINDOW_LABEL_COLUMN, gpu_name, -1); - child = ctk_gpu_new(gpu_handle, screen_handles, ctk_event); + child = ctk_gpu_new(gpu_handle, h->targets[X_SCREEN_TARGET].t, ctk_event); gtk_object_ref(GTK_OBJECT(child)); gtk_tree_store_set(ctk_window->tree_store, &iter, CTK_WINDOW_WIDGET_COLUMN, child, -1); @@ -861,13 +855,13 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, /* add the per-vcs (e.g. Quadro Plex) entries into the tree model */ - for (i = 0; i < num_vcs_handles; i++) { + for (i = 0; i < h->targets[VCS_TARGET].n; i++) { gchar *vcs_product_name; gchar *vcs_name; GtkWidget *child; ReturnStatus ret; - NvCtrlAttributeHandle *vcs_handle = vcs_handles[i]; + NvCtrlAttributeHandle *vcs_handle = h->targets[VCS_TARGET].t[i].h; if (!vcs_handle) continue; @@ -905,6 +899,13 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, gtk_tree_store_set(ctk_window->tree_store, &iter, CTK_WINDOW_CONFIG_FILE_ATTRIBUTES_FUNC_COLUMN, NULL, -1); + gtk_tree_store_set(ctk_window->tree_store, &iter, + CTK_WINDOW_SELECT_WIDGET_FUNC_COLUMN, + ctk_vcs_start_timer, -1); + gtk_tree_store_set(ctk_window->tree_store, &iter, + CTK_WINDOW_UNSELECT_WIDGET_FUNC_COLUMN, + ctk_vcs_stop_timer, -1); + } /* @@ -912,9 +913,9 @@ GtkWidget *ctk_window_new(NvCtrlAttributeHandle **screen_handles, * frame lock */ - for (i = 0; i < num_screen_handles; i++) { + for (i = 0; i < h->targets[X_SCREEN_TARGET].n; i++) { - NvCtrlAttributeHandle *screen_handle = screen_handles[i]; + NvCtrlAttributeHandle *screen_handle = h->targets[X_SCREEN_TARGET].t[i].h; if (!screen_handle) continue; diff --git a/src/gtk+-2.x/ctkwindow.h b/src/gtk+-2.x/ctkwindow.h index 458327b..bd04b32 100644 --- a/src/gtk+-2.x/ctkwindow.h +++ b/src/gtk+-2.x/ctkwindow.h @@ -91,11 +91,8 @@ struct _CtkWindowClass }; GType ctk_window_get_type (void) G_GNUC_CONST; -GtkWidget* ctk_window_new (NvCtrlAttributeHandle**, gint, - NvCtrlAttributeHandle**, gint, - NvCtrlAttributeHandle**, gint, - ParsedAttribute *, ConfigProperties *conf, - CtrlHandles *pCtrlHandles); +GtkWidget* ctk_window_new (ParsedAttribute *, ConfigProperties *conf, + CtrlHandles *h); void add_special_config_file_attributes(CtkWindow *ctk_window); diff --git a/src/libXNVCtrl/NVCtrl.c b/src/libXNVCtrl/NVCtrl.c index 5f8bc8b..abdedb2 100644 --- a/src/libXNVCtrl/NVCtrl.c +++ b/src/libXNVCtrl/NVCtrl.c @@ -666,493 +666,6 @@ Bool XNVCtrlSelectNotify ( return True; } - -Bool XNVCTRLQueryDDCCILutSize ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int *red_entries, - unsigned int *green_entries, - unsigned int *blue_entries, - unsigned int *red_bits_per_entries, - unsigned int *green_bits_per_entries, - unsigned int *blue_bits_per_entries -) { - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlQueryDDCCILutSizeReply rep; - xnvCtrlQueryDDCCILutSizeReq *req; - unsigned int buf[6]; - Bool exists; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - - GetReq (nvCtrlQueryDDCCILutSize, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlQueryDDCCILutSize; - req->screen = screen; - req->display_mask = display_mask; - - if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - - _XRead(dpy, (char *)(&buf), 24); - - *red_entries = buf[0]; - *green_entries = buf[1]; - *blue_entries = buf[2]; - *red_bits_per_entries = buf[3]; - *green_bits_per_entries = buf[4]; - *blue_bits_per_entries = buf[5]; - - UnlockDisplay (dpy); - SyncHandle (); - exists = rep.flags; - return exists; -} - - -Bool XNVCTRLQueryDDCCISinglePointLutOperation ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int offset, - unsigned int *red_value, - unsigned int *green_value, - unsigned int *blue_value -) { - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlQueryDDCCISinglePointLutOperationReply rep; - xnvCtrlQueryDDCCISinglePointLutOperationReq *req; - unsigned int buf[4]; - Bool exists; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - - GetReq (nvCtrlQueryDDCCISinglePointLutOperation, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlQueryDDCCISinglePointLutOperation; - req->screen = screen; - req->display_mask = display_mask; - req->offset = offset; - - if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - - _XRead(dpy, (char *)(&buf), 12); - - *red_value = buf[0]; - *green_value = buf[1]; - *blue_value = buf[2]; - - UnlockDisplay (dpy); - SyncHandle (); - - exists=rep.flags; - return exists; -} - - -Bool XNVCTRLSetDDCCISinglePointLutOperation ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int offset, - unsigned int red_value, - unsigned int green_value, - unsigned int blue_value -) { - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlSetDDCCISinglePointLutOperationReply rep; - xnvCtrlSetDDCCISinglePointLutOperationReq *req; - Bool success; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - GetReq (nvCtrlSetDDCCISinglePointLutOperation, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlSetDDCCISinglePointLutOperation; - req->screen = screen; - req->display_mask = display_mask; - req->offset = offset; - req->red_value = red_value; - req->green_value = green_value; - req->blue_value = blue_value; - - if (!_XReply (dpy, (xReply *) &rep, 0, False)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - UnlockDisplay (dpy); - SyncHandle (); - - success = rep.flags; - return success; -} - - -Bool XNVCTRLQueryDDCCIBlockLutOperation ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int color, // NV_CTRL_DDCCI_RED_LUT, NV_CTRL_DDCCI_GREEN_LUT, NV_CTRL_DDCCI_BLUE_LUT - unsigned int offset, - unsigned int size, - unsigned int **value -) { - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlQueryDDCCIBlockLutOperationReply rep; - xnvCtrlQueryDDCCIBlockLutOperationReq *req; - Bool exists; - int length, slop; - char *ptr; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - GetReq (nvCtrlQueryDDCCIBlockLutOperation, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlQueryDDCCIBlockLutOperation; - req->screen = screen; - req->display_mask = display_mask; - req->color=color; - req->offset=offset; - req->size=size; - if (!_XReply (dpy, (xReply *) &rep, 0, False)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - length = rep.length; - slop = rep.num_bytes & 3; - ptr = (char *) Xmalloc(rep.num_bytes); - if (! ptr) { - _XEatData(dpy, length); - UnlockDisplay (dpy); - SyncHandle (); - return False; - } else { - _XRead(dpy, (char *) ptr, rep.num_bytes); - if (slop) _XEatData(dpy, 4-slop); - } - exists = rep.flags; - if(exists) { - *value=(unsigned int *)ptr; - } - UnlockDisplay (dpy); - SyncHandle (); - return exists; -} - - -Bool XNVCTRLSetDDCCIBlockLutOperation ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int color, // NV_CTRL_DDCCI_RED_LUT, NV_CTRL_DDCCI_GREEN_LUT, NV_CTRL_DDCCI_BLUE_LUT - unsigned int offset, - unsigned int size, - unsigned int *value -) { - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlSetDDCCIBlockLutOperationReq *req; - xnvCtrlSetDDCCIBlockLutOperationReply rep; - Bool success; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - GetReq (nvCtrlSetDDCCIBlockLutOperation, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlSetDDCCIBlockLutOperation; - req->screen = screen; - req->display_mask = display_mask; - req->color = color; - req->offset = offset; - req->size = size; - req->num_bytes = size << 2; - req->length += (req->num_bytes + 3) >> 2; - Data(dpy, (char *)value, req->num_bytes ); - - if (!_XReply (dpy, (xReply *) &rep, 0, False)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - UnlockDisplay (dpy); - SyncHandle (); - - success = rep.flags; - return success; -} - - -Bool XNVCTRLSetDDCCIRemoteProcedureCall ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int offset, - unsigned int size, - unsigned int *red_lut, - unsigned int *green_lut, - unsigned int *blue_lut, - unsigned int *increment -) { - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlSetDDCCIRemoteProcedureCallReq *req; - xnvCtrlSetDDCCIRemoteProcedureCallReply rep; - unsigned int nbytes; - Bool success; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - GetReq (nvCtrlSetDDCCIRemoteProcedureCall, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlSetDDCCIRemoteProcedureCall; - req->screen = screen; - req->display_mask = display_mask; - req->size = size; - nbytes= size << 2; - req->num_bytes = nbytes * 4; - req->length += (req->num_bytes + 3) >> 2; - req->offset = offset; - Data(dpy, (char *)red_lut, nbytes ); - Data(dpy, (char *)green_lut, nbytes ); - Data(dpy, (char *)blue_lut, nbytes ); - Data(dpy, (char *)increment, nbytes ); - - if (!_XReply (dpy, (xReply *) &rep, 0, False)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - UnlockDisplay (dpy); - SyncHandle (); - - success = rep.flags; - return success; -} - -/* XXXAlternative: Instead of getting the manufacturer string from the server, - * get the manufacturer Id instead, and have controller_manufacturer assigned - * to a static string that would not need to be malloc'ed and freed. - */ -Bool XNVCTRLQueryDDCCIDisplayControllerType ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned char **controller_manufacturer, - unsigned int *controller_type -) -{ - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlQueryDDCCIDisplayControllerTypeReply rep; - xnvCtrlQueryDDCCIDisplayControllerTypeReq *req; - Bool exists; - int length, numbytes, slop; - char *ptr; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - GetReq (nvCtrlQueryDDCCIDisplayControllerType, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlQueryDDCCIDisplayControllerType; - req->screen = screen; - req->display_mask = display_mask; - if (!_XReply (dpy, (xReply *) &rep, 0, False)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - length = rep.length; - numbytes = rep.size; - slop = numbytes & 3; - ptr = (char *) Xmalloc(numbytes); - if (! ptr) { - _XEatData(dpy, length); - UnlockDisplay (dpy); - SyncHandle (); - return False; - } else { - _XRead(dpy, (char *) ptr, numbytes); - if (slop) _XEatData(dpy, 4-slop); - } - exists = rep.flags; - if(exists) { - *controller_type=rep.controller_type; - *controller_manufacturer=ptr; - } - UnlockDisplay (dpy); - SyncHandle (); - return exists; -} - - -Bool NVCTRLQueryDDCCICapabilities ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int **nvctrl_vcp_supported, - unsigned int **possible_values_offset, - unsigned int **possible_values_size, - unsigned int **nvctrl_vcp_possible_values, - unsigned int **nvctrl_string_vcp_supported -) -{ - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlQueryDDCCICapabilitiesReply rep; - xnvCtrlQueryDDCCICapabilitiesReq *req; - Bool exists=1; - int length, numbytes, slop; - char *ptr, *p; - int len1, len2, len3, len4, len5; - - *nvctrl_vcp_supported=*nvctrl_vcp_possible_values=*possible_values_offset=*possible_values_size=*nvctrl_string_vcp_supported=NULL; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - - GetReq (nvCtrlQueryDDCCICapabilities, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlQueryDDCCICapabilities; - - req->screen = screen; - req->display_mask = display_mask; - if (!_XReply (dpy, (xReply *) &rep, 0, False)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - length = rep.length; - numbytes = rep.num_bytes; - slop = numbytes & 3; - ptr = (char *) Xmalloc(numbytes); - if (! ptr) { - _XEatData(dpy, length); - UnlockDisplay (dpy); - SyncHandle (); - return False; - } else { - _XRead(dpy, (char *) ptr, numbytes); - if (slop) _XEatData(dpy, 4-slop); - } - exists = rep.flags; - if(exists) { - p = ptr; - len1 = len2 = len3 = (NV_CTRL_DDCCI_LAST_VCP+1) << 2 ; - len4 = rep.possible_val_len << 2; - len5 = (NV_CTRL_STRING_LAST_ATTRIBUTE+1) << 2; - *nvctrl_vcp_supported=(unsigned int *) Xmalloc(len1); - *possible_values_offset=(unsigned int *) Xmalloc(len2); - *possible_values_size=(unsigned int *) Xmalloc(len3); - if(len4) - *nvctrl_vcp_possible_values=(unsigned int *) Xmalloc(len4); - *nvctrl_string_vcp_supported=(unsigned int *) Xmalloc(len5); - memcpy((char*)*nvctrl_vcp_supported, p, len1); p += len1; - memcpy((char*)*possible_values_offset, p, len2); p += len2; - memcpy((char*)*possible_values_size, p, len3); p += len3; - if(len4) { - memcpy((char*)*nvctrl_vcp_possible_values, p, len4); p += len4; - } - memcpy((char*)*nvctrl_string_vcp_supported, p, len5); - } - free(ptr); - UnlockDisplay (dpy); - SyncHandle (); - return exists; -} - -Bool XNVCTRLQueryDDCCITimingReport ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int *sync_freq_out_range, - unsigned int *unstable_count, - unsigned int *positive_h_sync, - unsigned int *positive_v_sync, - unsigned int *h_freq, - unsigned int *v_freq -) { - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlQueryDDCCITimingReportReply rep; - xnvCtrlQueryDDCCITimingReportReq *req; - unsigned int buf[6]; - Bool exists; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - - GetReq (nvCtrlQueryDDCCITimingReport, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlQueryDDCCITimingReport; - req->screen = screen; - req->display_mask = display_mask; - - if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - - _XRead(dpy, (char *)(&buf), 24); - - exists = rep.flags; - - *sync_freq_out_range = buf[0]; - *unstable_count = buf[1]; - *positive_h_sync = buf[2]; - *positive_v_sync = buf[3]; - *h_freq = buf[4]; - *v_freq = buf[5]; - - UnlockDisplay (dpy); - SyncHandle (); - - return exists; -} - Bool XNVCTRLQueryTargetBinaryData ( Display *dpy, int target_type, diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h index 8f1289a..79af282 100644 --- a/src/libXNVCtrl/NVCtrl.h +++ b/src/libXNVCtrl/NVCtrl.h @@ -1357,1205 +1357,6 @@ #define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY 1 - -/************************************************************************* - * DDC/CI VCP codes * - * From the VESA Monitor Control Command Set (MCCS) Standard - Version 2 * - *************************************************************************/ - -#define NV_CTRL_DDCCI_ON 1 -#define NV_CTRL_DDCCI_OFF 0 - -/************************************* - * DDC/CI VCP CODES: GEOMETRY ADJUST * - *************************************/ - -/* Increasing (decreasing) this value moves the image toward the right - * (left) side of the screen. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_HORIZONTAL_POSITION 97 /* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the width - * of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_HORIZONTAL_SIZE 98 /* RWD */ - -/* Increasing (decreasing) this value will cause the right and left sides - * of the image to become more (less) convex. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_HORIZONTAL_PINCUSHION 99 /* RWD */ - -/* Increasing (decreasing) this value will move the center section of the - * image towards the right(left) side of the display. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_HORIZONTAL_PINCUSHION_BALANCE 100/* RWD */ - -/* Increasing (decreasing) this value will shift the red pixels to the right - * (left) across the image and the blue pixels left (right) across the image - * with respect to the green pixels. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_HORIZONTAL_CONVERGENCE 101/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * density of pixels in the image center. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_HORIZONTAL_LINEARITY 102/* RWD */ - -/* Increasing (decreasing) this value shifts the density of pixels from - * the left (right) side to the right (left) side of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_HORIZONTAL_LINEARITY_BALANCE 103/* RWD */ - -/* Increasing (decreasing) this value moves the image toward the - * top (bottom) edge of the display. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_VERTICAL_POSITION 104/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * height of the image - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_VERTICAL_SIZE 105/* RWD */ - -/* Increasing (decreasing) this value will cause the top and bottom - * edges of the image to become more (less) convex. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_VERTICAL_PINCUSHION 106/* RWD */ - -/* Increasing (decreasing) this value will move the center section of - * the image toward the top (bottom) edge of the display. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_VERTICAL_PINCUSHION_BALANCE 107/* RWD */ - -/* Increasing (decreasing) this value shifts the red pixels up (down) - * across the image and the blue pixels down (up) across the image - * with respect to the green pixels. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_VERTICAL_CONVERGENCE 108/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * density of scan lines in the image center. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_VERTICAL_LINEARITY 109/* RWD */ - -/* Increasing (decreasing) this value shifts the density of scan lines - * from the top (bottom) end to the bottom (top) end of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_VERTICAL_LINEARITY_BALANCE 110/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * degree of keystone distortion in the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_KEYSTONE 111/* RWD */ - -/* Increasing (decreasing) this value shifts the top section of the - * image to the right (left) with respect to the bottom section of the - * image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_KEY_BALANCE 112/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * degree of trapezoid distortion in the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_TRAPEZOID 113/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * ratio between the horizontal size at the top of the image and the - * horizontal size at the bottom of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_HORIZONTAL_TRAPEZOID 114/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * ratio between the vertical size at the left of the image and the - * vertical size at the right of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_VERTICAL_TRAPEZOID 115/* RWD */ - -/* Increasing (decreasing) this value rotates the image (counter) - clockwise about the center point of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_TILT 116/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * distance between the left and right sides at the top of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_TOP_CORNER 117/* RWD */ - -/* Increasing (decreasing) this value moves the top end of the - * image to the right (left). - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_TOP_CORNER_BALANCE 118/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * distance between the left and right sides at the bottom of the - * image. - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_BOTTOM_CORNER 119/* RWD */ - -/* Increasing (decreasing) this value moves the bottom end of the - * image to the right (left). - * Type: Range - */ -#define NV_CTRL_DDCCI_GEOMETRY_BOTTOM_CORNER_BALANCE 120/* RWD */ - - -/************************************** - * DDC/CI VCP CODES: PRESET SELECTION * - **************************************/ - -/* Restore all factory presets including brightness / contrast, - * geometry, color and TV defaults. - * NV__CTRL_DDCCI_ON causes defaults to be restored - * A value of NV_CTRL_DDCCI_OFF shall be ignored - * Type: Boolean - */ -#define NV_CTRL_DDCCI_PRESET_RESTORE_DEFAULTS 121/* -WD */ - -/* Restores factory defaults for brightness and contrast adjustments. - * NV_CTRL_DDCCI_ON causes defaults to be restored - * A value of NV_CTRL_DDCCI_OFF shall be ignored - * Type: Boolean - */ -#define NV_CTRL_DDCCI_PRESET_RESTORE_DEFAULTS_BRIGHTNESS_CONTRAST 122/* -WD */ - -/* Restore factory defaults for geometry adjustments. - * NV_CTRL_DDCCI_ON causes defaults to be restored - * A value of NV_CTRL_DDCCI_OFF shall be ignored - * Type: Boolean - */ -#define NV_CTRL_DDCCI_PRESET_RESTORE_DEFAULTS_GEOMETRY 123/* -WD */ - -/* Restore factory defaults for color settings. - * NV_CTRL_DDCCI_ON causes defaults to be restored - * A value of NV_CTRL_DDCCI_OFF shall be ignored - * Type: Boolean - */ -#define NV_CTRL_DDCCI_PRESET_RESTORE_DEFAULTS_COLOR 124/* -WD */ - -/* Restore factory defaults for TV functions. - * NV_CTRL_DDCCI_ON causes defaults to be restored - * A value of NV_CTRL_DDCCI_OFF shall be ignored - * Type: Boolean - */ -#define NV_CTRL_DDCCI_PRESET_RESTORE_DEFAULTS_TV 125/* -WD */ - -/* Store / Restore the user saved values for current mode. - * - NV_CTRL_DDCCI_PRESET_SETTINGS_STORE_CURRENT: - * Store current settings in the monitor. - * - NV_CTRL_DDCCI_PRESET_SETTINGS_RESTORE_FACTORY_DEFAULTS: - * Restore factory defaults for current mode. If no factory - * defaults then restore user values for current mode. - * - All other values are reserved and shall be ignored. - * Type: Integer - */ -#define NV_CTRL_DDCCI_PRESET_SETTINGS 126/* -WD */ -#define NV_CTRL_DDCCI_PRESET_SETTINGS_STORE_CURRENT 1 -#define NV_CTRL_DDCCI_PRESET_SETTINGS_RESTORE_FACTORY_DEFAULTS 2 - - -/*************************************** - * DDC/CI VCP CODES: IMAGE ADJUSTMENTS * - ***************************************/ - -/* - * Increasing (decreasing) this value will increase (decrease) the - * Brightness of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_BRIGHTNESS 127/* RWD */ - -/* - * Increasing (decreasing) this value will increase (decrease) the - * Contrast of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_CONTRAST 128/* RWD */ - -/* - * Turn on / off an auto setup function (periodic or event driven) - * 0 and 3 : Shall be ignored - * NV_CTRL_DDCCI_IMAGE_AUTO_SETUP_TOGGLE_OFF : Turn auto setup off - * NV_CTRL_DDCCI_IMAGE_AUTO_SETUP_TOGGLE_ON : Turn auto setup on - * Type: Integer - */ -#define NV_CTRL_DDCCI_IMAGE_AUTO_SETUP_TOGGLE 129/* -WD */ -#define NV_CTRL_DDCCI_IMAGE_AUTO_SETUP_TOGGLE_OFF 1 -#define NV_CTRL_DDCCI_IMAGE_AUTO_SETUP_TOGGLE_ON 2 - -/* - * Perform autosetup function (H/V position, clock, clock phase, A/D - * converter, etc) - * NV_CTRL_OFF : Indicates that auto-setup is not active - * NV_CTRL_ON : Perform autosetup - * >=2 : Shall be ignored - * Type: Integer - */ -#define NV_CTRL_DDCCI_IMAGE_AUTO_SETUP 130/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * sampling clock frequency - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_CLOCK 131/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * phase shift of the sampling clock - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_CLOCK_PHASE 132/* RWD */ - -/* Allows the display to specify the minimum increment in which it - * can adjust the color temperature. - * This will be used in conjunction with - * NV_CTRL_DDCCI_IMAGE_COLOR_TEMPERATURE_REQUEST, Color temperature request. - * Values of 0 and > 5000 are invalid and shall be ignored. - * Type: Integer - */ -#define NV_CTRL_DDCCI_IMAGE_COLOR_TEMPERATURE_INCREMENT 133/* R-D */ - -/* Allows a specified color temperature (in °K) to be requested. If - * display is unable to achieve requested color temperature, then it - * should move to the closest possible temperature. - * A value of 0 shall be treated as a request for a color temperature - * of 3000°K. Values greater than 0 shall be used as a multiplier of - * the color temperature increment (read using - * NV_CTRL_DDCCI_IMAGE_COLOR_TEMPERATURE_INCREMENT) and the - * result added to the base value of 3000°K - * Example: - * If NV_CTRL_DDCCI_IMAGE_COLOR_TEMPERATURE_INCREMENT returns a value of - * 50°K and NV_CTRL_DDCCI_IMAGE_COLOR_TEMPERATURE_INCREMENT sends a - * value of 50 (decimal) then the display shall interpret this as a - * request to adjust the color temperature to 5500°K - * (3000 + (50 * 50))°K = 5500°K - * Notes: - * 1) Applications using this function are recommended to read the - * actual color temperature after using this command and taking - * appropriate action. - * 2) This control is only recommended if the display can produce a - * continuously (at defined increment, see VCP code 0Bh) variable - * color temperature. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_COLOR_TEMPERATURE_REQUEST 134/* RWD */ - -/* Select a specified color temperature. - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_SRGB : sRGB - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_NATIVE : Display native - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_4000K : 4000 K - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_5000K : 5000 K - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_6500K : 6500 K - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_7500K : 7500 K - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_8200K : 8200 K - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_9300K : 9300 K - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_10000K : 10000 K - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_USER1 : 11500 K - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_USER1 : User 1 - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_USER2 : User 2 - * NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_USER3 : User 3 - * 00 and >=0E shall be ignored - * Type: Integer - */ -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET 135/* RWD */ -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_SRGB 0x01 -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_NATIVE 0x02 -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_4000K 0x03 -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_5000K 0x04 -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_6500K 0x05 -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_7500K 0x06 -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_8200K 0x07 -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_9300K 0x08 -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_10000K 0x09 -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_11500K 0x0A -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_USER1 0x0B -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_USER2 0x0C -#define NV_CTRL_DDCCI_IMAGE_SELECT_COLOR_PRESET_USER3 0x0D - -/* - * Increasing (decreasing) this value will increase (decrease) the - * luminance of red pixels. - * The value returned shall be an indication of the actual red gain at - * the current color temperature and not be normalized. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_RED_VIDEO_GAIN 136/* RWD */ - -/* - * Increasing (decreasing) this value will increase (decrease) the - * luminance of green pixels. - * The value returned shall be an indication of the actual green gain at - * the current color temperature and not be normalized. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_GREEN_VIDEO_GAIN 137/* RWD */ - -/* - * Increasing (decreasing) this value will increase (decrease) the - * luminance of blue pixels. - * The value returned shall be an indication of the actual blue gain at - * the current color temperature and not be normalized. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_BLUE_VIDEO_GAIN 138/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * black level of red pixels. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_RED_VIDEO_BLACK_LEVEL 139/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * black level of green pixels. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_GREEN_VIDEO_BLACK_LEVEL 140/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * black level of blue pixels. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_BLUE_VIDEO_BLACK_LEVEL 141/* RWD */ - -/* Increasing (decreasing) this value will adjust the focus of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_FOCUS 142/* RWD */ - -/* Increasing (decreasing) this value controls the horizontal picture - * moiré cancellation. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_HORIZONTAL_MOIRE 143/* RWD */ - -/* Increasing (decreasing) this value controls the vertical picture - * moiré cancellation. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_VERTICAL_MOIRE 144/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * distance to the focal plane of the image. - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_ADJUST_FOCAL_PLANE 145/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * zoom function of the optics - * Type: Range - */ -#define NV_CTRL_DDCCI_IMAGE_ADJUST_ZOOM 146/* RWD */ - -/* This value will cause the picture to flip horizontally. - * NV_CTRL_DDCCI_ON : flip horizontally - * NV_CTRL_DDCCI_OFF : Shall be ignored - * Type: Boolean - */ -#define NV_CTRL_DDCCI_IMAGE_HOR_FLIP 147/* -WD */ - -/* This value will cause the picture to flip vertically. - * NV_CTRL_DDCCI_ON : flip vertically - * NV_CTRL_DDCCI_OFF : Shall be ignored - * Type: Boolean - */ -#define NV_CTRL_DDCCI_IMAGE_VER_FLIP 148/* -WD */ - -/* Changing this value will affect the scaling (input versus output) - * function of the display. - * NV_CTRL_DDCCI_IMAGE_DISPLAY_SCALING_NO_SCALING : No scaling, 1:1 relationship - * NV_CTRL_DDCCI_IMAGE_DISPLAY_SCALING_MAX_NO_DISTORT2 : Scale to maximum - * without AR distortion - * NV_CTRL_DDCCI_IMAGE_DISPLAY_SCALING_MAX_VERTICAL : Scale to maximum vertical - size - * NV_CTRL_DDCCI_IMAGE_DISPLAY_SCALING_MAX_HORIZONTAL ; Scale to maximum - horizontal size - * 0 and >=5 : Shall be ignored - * Type: Integer - */ -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_SCALING 149/* RWD */ -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_SCALING_NO_SCALING 1 -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_SCALING_MAX_NO_DISTORT 2 -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_SCALING_MAX_VERTICAL 3 -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_SCALING_MAX_HORIZONTAL 4 - -/* Allows one of several image expansion algorithms to be selecte - * to suit different types of image and/or different personal - * preference. - * NV_CTRL_DDCCI_IMAGE_SHARPNESS_FILTER_FUNC(1) : Filter function 1 - * NV_CTRL_DDCCI_IMAGE_SHARPNESS_FILTER_FUNC(2) : Filter function 2 - * NV_CTRL_DDCCI_IMAGE_SHARPNESS_FILTER_FUNC(3) : Filter function 3 - * NV_CTRL_DDCCI_IMAGE_SHARPNESS_FILTER_FUNC(4) : Filter function 4 - * 0 and 5 shall be ignored - * Type: Integer - */ -#define NV_CTRL_DDCCI_IMAGE_SHARPNESS 150/* RWD */ -#define NV_CTRL_DDCCI_IMAGE_SHARPNESS_FILTER_FUNC(n) n - -/* Indicates the orientation of the screen. - * NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_0 - * The normal landscape mode. - * NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_90 - * Portrait mode achieved by clockwise rotation of the display 90 degrees. - * NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_180 - * Landscape mode achieved by rotation of the display 180 degrees. - * NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_270 - * Portrait mode achieved by clockwise rotation of the display 270 degrees. - * NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_NA - * Indicates that the display cannot supply the current orientation - * Type: Integer - */ -#define NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION 151/* R-D */ -#define NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_0 0x01 -#define NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_90 0x02 -#define NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_180 0x03 -#define NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_270 0x04 -#define NV_CTRL_DDCCI_IMAGE_SCREEN_ORIENTATION_NA 0xFF - -/* Selects a scan format. - * NV_CTRL_DDCCI_IMAGE_SCAN_FORMAT_UNDERSCAN: Underscan - * NV_CTRL_DDCCI_IMAGE_SCAN_FORMAT_OVERSCAN: Overscan - * NV_CTRL_DDCCI_IMAGE_SCAN_FORMAT_WIDESCREEN: Widescreen - * Type: Integer - */ -#define NV_CTRL_DDCCI_IMAGE_SCAN_FORMAT 152/* RWD */ -#define NV_CTRL_DDCCI_IMAGE_SCAN_FORMAT_UNDERSCAN 1 -#define NV_CTRL_DDCCI_IMAGE_SCAN_FORMAT_OVERSCAN 2 -#define NV_CTRL_DDCCI_IMAGE_SCAN_FORMAT_WIDESCREEN 3 -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_MODE 153/* RWD */ - -/* Display mode: - * NV_CTRL_DDCCI_IMAGE_DISPLAY_MODE_PRODUCTIVITY : - * Productivity (e.g. office applications) - * NV_CTRL_DDCCI_IMAGE_DISPLAY_MODE_MIXED : Mixed (e.g. internet) - * NV_CTRL_DDCCI_IMAGE_DISPLAY_MODE_ENTERTAINMENT : - Entertainment (e.g. TV / movie) - * NV_CTRL_DDCCI_IMAGE_DISPLAY_MODE_USERDEFINED : User defined - * Note: - * The condition(s) associated with options 1, 2 and 3 are defined - * by the display manufacturer - * Type: Integer - */ -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_MODE_PRODUCTIVITY 1 -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_MODE_MIXED 2 -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_MODE_ENTERTAINMENT 3 -#define NV_CTRL_DDCCI_IMAGE_DISPLAY_MODE_USERDEFINED 4 - -/*********************************************** - * DDC/CI VCP CODES: WINDOWED IMAGE OPERATIONS * - ***********************************************/ - -/* Defines the top left X pixel of an area of the image. Specified in - * co-ordinates of incoming image before any scaling etc in the display. - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_POSITION_TOP_LEFT_X 154/* RWD */ - -/* Defines the top left Y pixel of an area of the image. Specified in - * co-ordinates of incoming image before any scaling etc in the display. - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_POSITION_TOP_LEFT_Y 155/* RWD */ - -/* Defines the bottom right X pixel of an area of the image. - * Specified in co-ordinates of incoming image before any scaling - * in the display. - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_POSITION_BOTTOM_RIGHT_X 156/* RWD */ - -/* Defines the bottom right Y pixel of an area of the image. - * Specified in co-ordinates of incoming image before any scaling - * in the display. - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_POSITION_BOTTOM_LEFT_X 157/* RWD */ - -/* Window control, enables the brightness and color within a - * window to be different from the desktop. - * NV_CTRL_DDCCI_WINDOWEDIMAGE_OLD_CONTROL_TOGGLE_OFF : Off - * NV_CTRL_DDCCI_WINDOWEDIMAGE_OLD_CONTROL_TOGGLE_ON: On - * All other values are reserved. - * Notes: - * 1. This control should be used in conjunction with - * NV_CTRL_DDCCI_WINDOWEDIMAGE_BACKGROUND - * 2. This command structure is not recommended for new designs, - * see NV_CTRL_DDCCI_WINDOWEDIMAGE_CONTROL_TOGGLE for alternate. - * Type: Integer - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_OLD_CONTROL_TOGGLE 158/* RWD */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_OLD_CONTROL_TOGGLE_OFF 1 -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_OLD_CONTROL_TOGGLE_ON 2 - -/* Changes the contrast ratio between the area of the window and - * the rest of the desktop - * Lower (higher) values will cause the desktop brightness to - * decrease (increase) - * Notes: - * 1. This contropl should be used in conjunction with - * NV_CTRL_DDCCI_WINDOWEDIMAGE_OLD_CONTROL_TOGGLE - * 2. This command structure is not recommended for new designs, - * see NV_CTRL_DDCCI_WINDOWEDIMAGE_WINDOW_SELECT for alternate. - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_BACKGROUND 159/* RWD */ - -/* A value of 127 shall have no effect. - * A value > 127 shall cause the color to shift towards yellow - * A value < 127 shall cause the color to shift towards magenta - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_6AXIS_COLOR_CONTROL_RED 160/* RWD */ - -/* A value of 127 shall have no effect. - * A value > 127 shall cause the color to shift towards green - * A value < 127 shall cause the color to shift towards red - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_6AXIS_COLOR_CONTROL_YELLOW 161/* RWD */ - -/* A value of 127 shall have no effect. - * A value > 127 shall cause the color to shift towards cyan - * A value < 127 shall cause the color to shift towards yellow - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_6AXIS_COLOR_CONTROL_GREEN 162/* RWD */ - -/* A value of 127 shall have no effect. - * A value > 127 shall cause the color to shift towards blue - * A value < 127 shall cause the color to shift towards green - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_6AXIS_COLOR_CONTROL_CYAN 163/* RWD */ - -/* A value of 127 shall have no effect. - * A value > 127 shall cause the color to shift towards magenta - * A value < 127 shall cause the color to shift towards cyan - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_6AXIS_COLOR_CONTROL_BLUE 164/* RWD */ - -/* A value of 127 shall have no effect. - * A value > 127 shall cause the color to shift towards red - * A value < 127 shall cause the color to shift towards blue - * Type: Range - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_6AXIS_COLOR_CONTROL_MAGENTA 165/* RWD */ - -/* Turn the selected window operation on / off. - * Bit: NV_CTRL_DDCCI_WINDOWEDIMAGE_CONTROL_TOGGLE_DPY_IMAGE - * 0 Window controls have no effect on the - * displayed image - * 1 Window controls effect the displayed image - * (full image area) - * Bit: NV_CTRL_DDCCI_WINDOWEDIMAGE_CONTROL_TOGGLE_WINDOW(n) - * 0 Window controls have no effect on the - * displayed image (window n) - * 1 Window controls effect the displayed image - * (window n) - * n is between 1 and 7 - * Note: This command structure is recommend, in conjunction with - * NV_CTRL_DDCCI_WINDOWEDIMAGE_WINDOW_SELECT, for all new designs. - * Type: Bitmask - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_CONTROL_TOGGLE 166/* RWD */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_CONTROL_TOGGLE_DPY_IMAGE 1 -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_CONTROL_TOGGLE_WINDOW(n) (1<<n) - -/* Change the selected window as defined with - * NV_CTRL_DDCCI_WINDOWEDIMAGE_CONTROL_TOGGLE - * When a window is selected then all commands that the display - * controller supports for window operations are valid, this may - * include but is not limited to: brightness, contrast, R/G/B gain, 6- - * axis color, sharpness, etc. - * meaning of value NV_CTRL_DDCCI_WINDOWEDIMAGE_WINDOW_SELECT_DPY_IMAGE: - * Full display image area is selected except for - * area(s) of active windows - * meaning of value NV_CTRL_DDCCI_WINDOWEDIMAGE_WINDOW_SELECT_WINDOW(n) - * Window n is selected - * If this command is not supported then the `full image area' shall - * be the default. - * This command structure is recommend, in conjunction with - * NV_CTRL_DDCCI_WINDOWEDIMAGE_CONTROL_TOGGLE, for all new designs. - * Type: Integer - */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_WINDOW_SELECT 167/* RWD */ -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_WINDOW_SELECT_DPY_IMAGE 0 -#define NV_CTRL_DDCCI_WINDOWEDIMAGE_WINDOW_SELECT_WINDOW(n) (1<<n) - - -/*************************************/ -/* DDC/CI VCP CODES: AUDIO FUNCTIONS */ -/*************************************/ - -/* Increasing (decreasing) this value will increase (decrease) the - * audio volume. - * Type: Range - */ -#define NV_CTRL_DDCCI_AUDIO_SPEAKER_VOLUME 168/* RWD */ - -/* Increasing (decreasing) this value will increase (decrease) the - * microphone gain. - * Type: Range - */ -#define NV_CTRL_DDCCI_AUDIO_MICROPHONE_VOLUME 169/* RWD */ - -/* Increasing (decreasing) this control will cause high frequency - * audio to be emphasized (de-emphasised). - * Type: Range - */ -#define NV_CTRL_DDCCI_AUDIO_TV_AUDIO_TREBLE 170/* RWD */ - -/* Increasing (decreasing) this control will cause low frequency - * audio to be emphasized (de-emphasised). - * Type: Range - */ -#define NV_CTRL_DDCCI_AUDIO_TV_AUDIO_BASS 171/* RWD */ - -/* This control affects the left right balance of audio output. - * Increasing (decreasing) the value will cause the balance to move - * to the right (left). - * Type: Range - */ -#define NV_CTRL_DDCCI_AUDIO_TV_AUDIO_BALANCE 172/* RWD */ - -/* This control allows one of several audio modes to be selected. - * NV_CTRL_DDCCI_AUDIO_TV_STEREO_MODE_SPEAKER_OFF: Display audio is disabled, - * NV_CTRL_DDCCI_AUDIO_TV_STEREO_MODE_SPEAKER_MONO: Both display audio channels, - * use the left audio channel - * NV_CTRL_DDCCI_AUDIO_TV_STEREO_MODE_SPEAKER_STEREO: Incoming left and right - * audio. Channels feed separate display output audio channels. - * NV_CTRL_DDCCI_AUDIO_TV_STEREO_MODE_SPEAKER_STEREO_EXPANDED: As defined - * by the manufacturer. - * Type: Integer - */ -#define NV_CTRL_DDCCI_AUDIO_TV_STEREO_MODE 173/* RWD */ -#define NV_CTRL_DDCCI_AUDIO_TV_STEREO_MODE_SPEAKER_OFF 0 -#define NV_CTRL_DDCCI_AUDIO_TV_STEREO_MODE_SPEAKER_MONO 1 -#define NV_CTRL_DDCCI_AUDIO_TV_STEREO_MODE_SPEAKER_STEREO 2 -#define NV_CTRL_DDCCI_AUDIO_TV_STEREO_MODE_SPEAKER_STEREO_EXPANDED 3 - - -/************************************/ -/* DDC/CI VCP CODES: DPVL Functions */ -/************************************/ - -/* Video mode and status of a DPVL capable monitor - * Bit Value Meaning - * 0 0 Raster scan mode - * 1 DPVL mode - * 1 0 Monitor is able to receive the next packet - * 1 Monitor is unable to accept another packet - * 2 0 No error detected in the last header received - * 1 Error detected in the last header received - * Other bits are reserved and shall be set to '0'. - * Type: Bitmask - */ -#define NV_CTRL_DDCCI_DPVL_MONITOR_STATUS 174/* R-D */ -#define NV_CTRL_DDCCI_DPVL_MONITOR_STATUS_DPVL_MODE (1<<0) -#define NV_CTRL_DDCCI_DPVL_MONITOR_STATUS_UNABLE_TO_RECEIVE_NEXT_PACKET (1<<1) -#define NV_CTRL_DDCCI_DPVL_MONITOR_STATUS_ERROR_DETECTED_IN_LAST_HEADER (1<<2) - -/* Counter for the DPVL packets received (valid and invalid ones). - * This value counts from 0000h to FFFFh and then rolls over to 0000h. - * The host can reset the value to 0000h. - * Type: Range - */ -#define NV_CTRL_DDCCI_DPVL_PACKET_COUNT 175/* RWD */ - -/* The X origin of the monitor in the virtual screen. The support of - * this command indicates the multi-display support of the display. If - * a display supports this command, the monitor must also support - * Monitor Y Origin command. - * Type: Range; "0000h" to "FFFFh" or 0 to 65535 - */ -#define NV_CTRL_DDCCI_DPVL_MONITOR_X_ORIGIN 176/* RWD */ - -/* The Y origin of the display in the virtual screen. The support of - * this command indicates the multi-display support of the display. If - * a display supports this command, the monitor must also support - * Monitor X Origin command. - * Type: Range; "0000h" to "FFFFh" or 0 to 65535 - */ -#define NV_CTRL_DDCCI_DPVL_MONITOR_Y_ORIGIN 177/* RWD */ - -/* Error Counter for the DPVL header. The counter value saturates - * at FFFFh. Host can reset to 0000h. - * Type: Range - */ -#define NV_CTRL_DDCCI_DPVL_HEADER_ERROR_COUNT 178/* RWD */ - -/* CRC error Counter for the DPVL body (containing video data). - * The counter value saturates at FFFFh. The Host can reset to 0000h - * Type: Range - */ -#define NV_CTRL_DDCCI_DPVL_BODY_CRC_ERROR_COUNT 179/* RWD */ - -/* Assigned identification number for the monitor. - * Type: Valid range is 0000h to FFFEh, FFFFh is reserved for broadcast. - */ -#define NV_CTRL_DDCCI_DPVL_CLIENT_ID 180/* RWD */ - -/* Indicates the status of the DVI link - * NV_CTRL_DDCCI_DPVL_LINK_CONTROL_DISABLED: Link shutdown is disabled - * NV_CTRL_DDCCI_DPVL_LINK_CONTROL_ENABLED: Link shutdown is enabled - * Type: Boolean - */ -#define NV_CTRL_DDCCI_DPVL_LINK_CONTROL 181/* RWD */ -#define NV_CTRL_DDCCI_DPVL_LINK_CONTROL_DISABLED 0 -#define NV_CTRL_DDCCI_DPVL_LINK_CONTROL_ENABLED 1 - -/**********************************************/ -/* DDC/CI VCP CODES: Miscellaneous Functions */ -/**********************************************/ - -/* Causes a CRT display to perform a degauss cycle with - * NV_CTRL_DDCCI_ON - * Type: Boolean - */ -#define NV_CTRL_DDCCI_MISC_DEGAUSS 182/* -WD */ - -/* Used to indicate that a display user control (excluding power - * controls) has been used to change and save (or autosave) a new value. - * NV_CTRL_DDCCI_MISC_NEW_CONTROL_VALUE_NO_NEW : No new control value - * NV_CTRL_DDCCI_MISC_NEW_CONTROL_VALUE_NO_USER_CONTROLS : A new control value - * has been saved - * NV_CTRL_DDCCI_MISC_NEW_CONTROL_VALUE_NO_USER_CONTROLS : No user controls are present - * Note: - * A value = NV_CTRL_DDCCI_MISC_NEW_CONTROL_VALUE_NEW should only be reset to - * a value = NV_CTRL_DDCCI_MISC_NEW_CONTROL_VALUE_NO_NEW by a host write - * operation and not by the display - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_NEW_CONTROL_VALUE 183/* RWD */ -#define NV_CTRL_DDCCI_MISC_NEW_CONTROL_VALUE_NO_NEW 0x01 -#define NV_CTRL_DDCCI_MISC_NEW_CONTROL_VALUE_NEW 0x02 -#define NV_CTRL_DDCCI_MISC_NEW_CONTROL_VALUE_NO_USER_CONTROLS 0xFF - -/* Allows display controls to be used as soft keys - * NV_CTRL_DDCCI_MISC_SOFT_CONTROLS_NO_BUTTON_ACTIVE : No button active - * NV_CTRL_DDCCI_MISC_SOFT_CONTROLS_BUTTON(n): Button n active - * n is between 1 and 7. - * NV_CTRL_DDCCI_MISC_SOFT_CONTROLS_NONE : No controls present - * Note: - * A `button active' value should only be reset to a value = 0 by - * host write operation and not by the display - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_SOFT_CONTROLS 184/* RWD */ -#define NV_CTRL_DDCCI_MISC_SOFT_CONTROLS_NO_BUTTON_ACTIVE 0 -#define NV_CTRL_DDCCI_MISC_SOFT_CONTROLS_BUTTON(n) n -#define NV_CTRL_DDCCI_MISC_SOFT_CONTROLS_NONE 0xFF - -/* When read this control returns the VCP code associated with - * the new control value reported using 02H - * Examples: - * If brightness has been changed then return value of 10h - * If red gain has been changed then return value of 16h. - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_ACTIVE_CONTROL 185/* R-D */ - -/* Used to select the active video source - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_ANALOG_1: Analog video (R/G/B) 1 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_ANALOG_2: Analog video (R/G/B) 2 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_DIGITAL_1: Digital video (TMDS) 1 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_DIGITAL_2: Digital video (TMDS) 2 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPOSITE_1: Composite video 1 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPOSITE_2: Composite video 2 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_SVIDEO_1: S-video 1 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_SVIDEO_2: S-video 2 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_TUNER_1: Tuner 1 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_TUNER_2: Tuner 2 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_TUNER_3: Tuner 3 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPONENT_1: Component video (YPrPb/YCrCb) 1 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPONENT_2: Component video (YPrPb/YCrCb) 2 - * NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPONENT_3: Component video (YPrPb/YCrCb) 3 - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE 186/* RWD */ -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_ANALOG_1 1 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_ANALOG_2 2 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_DIGITAL_1 3 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_DIGITAL_2 4 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPOSITE_1 5 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPOSITE_2 6 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_SVIDEO_1 7 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_SVIDEO_2 8 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_TUNER_1 9 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_TUNER_2 10 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_TUNER_3 11 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPONENT_1 12 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPONENT_2 13 -#define NV_CTRL_DDCCI_MISC_INPUT_SOURCE_COMPONENT_3 14 - -/* ncreasing (decreasing) this value will increase (decrease) the - * velocity modulation of the horizontal scan as a function of a - * change in the luminance level. - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_VELOCITY_SCAN_MODULATION 187/* RWD */ - -/* Increasing this control increases the amplitude of the color - * difference components of the video signal. - * The result is an increase in the amount of pure color relative to - * white in the video. This control does not affect the RGB input, - * only the TV video inputs. - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_TV_COLOR_SATURATION 188/* RWD */ - -/* Used to increment / decrement between TV-channels, the exact - * behavior is implementation specific (e.g. increment / decrement - * to next numeric channel or increment / decrement to next - * channel with a signal) - * NV_CTRL_DDCCI_MISC_TV_CHANNEL_UP_DOWN_INCREMENT: Increment channel - * NV_CTRL_DDCCI_MISC_TV_CHANNEL_UP_DOWN_DECREMENT: Decrement channel - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_TV_CHANNEL_UP_DOWN 189/* -WD */ -#define NV_CTRL_DDCCI_MISC_TV_CHANNEL_UP_DOWN_INCREMENT 1 -#define NV_CTRL_DDCCI_MISC_TV_CHANNEL_UP_DOWN_DECREMENT 2 - -/* Increasing this control increases the amplitude of the high - * frequency components of the video signal. - * This allows fine details to be accentuated. This control does not - * affect the RGB input, only the TV video inputs. - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_TV_SHARPNESS 190/* RWD */ - -/* Provides for the TV-audio to be muted or unmated. - * NV_CTRL_DDCCI_MISC_TV_AUDIO_MUTE_ON: Mute the audio - * NV_CTRL_DDCCI_MISC_TV_AUDIO_MUTE_OFF: Unmute the audio - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_TV_AUDIO_MUTE 191/* RWD */ -#define NV_CTRL_DDCCI_MISC_TV_AUDIO_MUTE_ON 1 -#define NV_CTRL_DDCCI_MISC_TV_AUDIO_MUTE_OFF 2 - -/* Increasing (decreasing) this control increases (decreases) the - * ratio between whites and blacks in the video. - * This control does not affect the RGB input, only the TV video - * inputs. - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_TV_CONTRAST 192/* RWD */ - -/* Also known as `tint' - * Increasing (decreasing) this control increases (decreases) the - * wavelength of the color component of the video signal. - * The result is a shift towards red (blue) in the hue of all colors. - * This control does not affect the RGB input, only the TV video - * inputs. - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_TV_HUE 193/* RWD */ - -/* Increasing this control increases the black level of the video, - * resulting in an increase of the luminance level of the video. - * A value of zero represents the darkest level possible. - * This control does not affect the RGB input, only the TV video - * inputs. - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_TV_BLACK_LEVEL_SHARPNESS 194/* RWD */ - -/* Horizontal synchronization signal frequency in Hz as determined - * by the display. - * FFh: Indicates that the display cannot supply this information - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_HORIZONTAL_FREQUENCY 195/* R-D */ - -/* Vertical synchronization signal frequency in 0.01Hz as - * determined by the display. - * FFh: Indicates that the display cannot supply this information - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_VERTICAL_FREQUENCY 196/* R-D */ - -/* Select a type of LCD sub-pixel structure - * NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_UNDEFINED: - * Sub-pixel layout is not defined - * NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_RGB_V: - * Red / Green / Blue vertical stripe - * NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_RGB_H: - * Red / Green / Blue horizontal stripe - * NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_BGR_V: - * Blue / Green / Red vertical stripe - * NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_BGR_H: - * Blue/ Green / Red horizontal stripe - * NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_QUAD_1: - * Quad-pixel, a 2 x 2 sub-pixel structure with red at top - * left, blue at bottom right and green at top right and - * bottom left - * NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_QUAD_2: - * Quad-pixel, a 2 x 2 sub-pixel structure with red at - * bottom left, blue at top right and green at top left and - * bottom right - * NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_DELTA: - * Delta (triad) - * NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_MOSAIC: - * Mosaic with red, green and blue fields overlayed - * (field sequential color) - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT 197/* R-D */ -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_UNDEFINED 0 -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_RGB_V 1 -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_RGB_H 2 -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_BGR_V 3 -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_BGR_H 4 -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_QUAD_1 5 -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_QUAD_2 6 -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_DELTA 7 -#define NV_CTRL_DDCCI_MISC_FLATPANEL_SUBPIXEL_LAYOUT_MOSAIC 8 - -/* Select the base technology type - * NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_CRT_SHADOWMASK: CRT (shadowmask) - * NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_CRT_APERTURE_GRILL: CRT (aperture - * grill) - * NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_TFT: TFT - * NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_LCOS: LCoS - * NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_PLASMA: Plasma - * NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_OLED: OLED - * NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_EL: EL - * NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_MEM: MEM - * Type: integer - */ -#define NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE 198/* R-D */ -#define NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_CRT_SHADOWMASK 1 -#define NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_CRT_APERTURE_GRILL 2 -#define NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_TFT 3 -#define NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_LCOS 4 -#define NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_PLASMA 5 -#define NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_OLED 6 -#define NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_EL 7 -#define NV_CTRL_DDCCI_MISC_DISPLAY_TECHNOLOGY_TYPE_MEM 8 - -/* Returns the current value (in hours) of `active power on' time - * accumulated by the display a 2 byte value. - * "Active power on" time is defined as the period when the - * emissive elements(s) of the display cathodes for a CRT, - * fluorescent lamps for a LCD, etc are active. - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_DISPLAY_USAGE_TIME 199/* R-D */ - -/* Returns the length (in bytes) of non-volatile storage in the display - * available for writing a display descriptor the maximum - * descriptor length is 256 bytes - * See - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_DISPLAY_DESCRIPTOR_LENGTH 200/* R-D */ - -/* If enabled (NV_CTRL_DDCCI_ON), the display descriptor written to the - * display using XNVCTRLSetDDCCIDisplayDescriptor() shall be displayed when - * no video is being received. - * The duration for which it is displayed is left to individual manufacturers. - * NV_CTRL_DDCCI_ON: Display is enabled - * NV_CTRL_DDCCI_OFF: The display descriptor shall not be displayed. - * Type: Boolean - */ -#define NV_CTRL_DDCCI_MISC_ENABLE_DISPLAY_OF_DISPLAY_DESCRIPTOR 201/* RWD */ - -/* A 2 byte value used to allow an application to only operate with - * known products. The display manufacturer and application author - * agree to a code such that application will only run when a valid - * code is present in the display. - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_APPLICATION_ENABLE_KEY 202/* R-D */ - -/* This VCP code provides allows a 2 byte value identifying the - * firmware level installed in the display to be determined. - * Type: Range - */ -#define NV_CTRL_DDCCI_MISC_DISPLAY_FIRMWARE_LEVEL 203/* R-D */ - -/* Indicates the current state of the display OSD - * NV_CTRL_DDCCI_MISC_OSD_DISABLED: OSD is disabled - * NV_CTRL_DDCCI_MISC_OSD_ENABLED: OSD is enabled - * NV_CTRL_DDCCI_MISC_OSD_CANNOT_SUPPLY: Indicates that the display cannot - * supply this information. - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_OSD 204/* RWD */ -#define NV_CTRL_DDCCI_MISC_OSD_DISABLED 1 -#define NV_CTRL_DDCCI_MISC_OSD_ENABLED 2 -#define NV_CTRL_DDCCI_MISC_OSD_CANNOT_SUPPLY 0xFF - -/* Allows the displayed OSD language to be selected. - * Type: Integer */ -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE 205/* RWD */ -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_CHINESE 1 -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_ENGLISH 2 -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_FRENCH 3 -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_GERMAN 4 -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_ITALIAN 5 -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_JAPANESE 6 -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_KOREAN 7 -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_PORTUGESE 8 -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_RUSSIAN 9 -#define NV_CTRL_DDCCI_MISC_OSD_LANGUAGE_SPANISH 10 - -/* An `auxiliary display' is a small alpha-numeric display associated - * with the primary display and able to be accessed via the primary - * display. - * This command returns a 1 byte value that defines the number of - * characters and the number of rows available. The format is: - * Bits 0 to 5 : The number of characters / row - * Bits 6 to 7 : The number of rows - * I.e. The maximum auxiliary display size is 4 rows each with 64 characters - * Type: Bitmask - */ -#define NV_CTRL_DDCCI_MISC_AUXILIARY_DISPLAY_SIZE 206/* R-D */ -#define NV_CTRL_DDCCI_MISC_AUXILIARY_DISPLAY_SIZE_COLUMNS_MASK 0x1F -#define NV_CTRL_DDCCI_MISC_AUXILIARY_DISPLAY_SIZE_ROWS_MASK 0x60 - -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT 207/* RWD */ - -/* Used to selects the active output. - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_ANALOG_1: Analog video (R/G/B) 1 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_ANALOG_2: Analog video (R/G/B) 2 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_DIGITAL_1: Digital video (TMDS) 1 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_DIGITAL_2: Digital video (TMDS) 2 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPOSITE_1: Composite video 1 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPOSITE_2: Composite video 2 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_SVIDEO_1: S-video 1 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_SVIDEO_2: S-video 2 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_TUNER_1: Tuner 1 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_TUNER_2: Tuner 2 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_TUNER_3: Tuner 3 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPONENT_1: Component video (YPrPb/YCrCb) 1 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPONENT_2: Component video (YPrPb/YCrCb) 2 - * NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPONENT_3: Component video (YPrPb/YCrCb) 3 - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_ANALOG_1 1 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_ANALOG_2 2 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_DIGITAL_1 3 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_DIGITAL_2 4 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPOSITE_1 5 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPOSITE_2 6 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_SVIDEO_1 7 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_SVIDEO_2 8 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_TUNER_1 9 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_TUNER_2 10 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_TUNER_3 11 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPONENT_1 12 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPONENT_2 13 -#define NV_CTRL_DDCCI_MISC_OUTPUT_SELECT_COMPONENT_3 14 - -/* Used to select the video mode with respect to 2D or 3D video. - * Here is the meaning of the bitmask: - * NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_FIELD_SEQUENTIAL_RIGHT_FIRST: - * Enable Field-Sequential Right Eye First - * NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_FIELD_SEQUENTIAL_LEFT_FIRST: - * Enable Field-Sequential Left Eye First - * NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_2WAY_INTERLEAVED_RIGHT_FIRST: - * Enable 2-Way Interleaved Right Eye First - * NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_2WAY_INTERLEAVED_LEFT_FIRST: - * Enable 2-Way Interleaved Left Eye First - * NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_4WAY_INTERLEAVED_ODD_LINES: - * Enable 4-Way Interleaved, Display Stereo Buffer 0 (even scan lines) - * NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_4WAY_INTERLEAVED_ODD_LINES: - * Enable 4-Way Interleaved, Display Stereo Buffer 1 (odd scan lines) - * NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_SIDE_BY_SIDE_INTERLEAVED: - * Enable Side-by-Side Interleaved - * Note: It is permissible, during a read operation, for a display to indicate - * support for 2 or more stereo modes - * Type: Bitmask - */ -#define NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE 208/* RWD */ -#define NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_FIELD_SEQUENTIAL_RIGHT_FIRST (1<<6) -#define NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_FIELD_SEQUENTIAL_LEFT_FIRST (1<<5) -#define NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_2WAY_INTERLEAVED_RIGHT_FIRST (1<<4) -#define NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_2WAY_INTERLEAVED_LEFT_FIRST (1<<3) -#define NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_4WAY_INTERLEAVED_EVEN_LINES (1<<2) -#define NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_4WAY_INTERLEAVED_ODD_LINES (1<<1) -#define NV_CTRL_DDCCI_MISC_STEREO_VIDEO_MODE_SIDE_BY_SIDE_INTERLEAVED (1<<0) - -/* Power Mode DPMS and DPM standards are supported. - * Value DPMS DPM - * NV_CTRL_DDCCI_MISC_POWER_MODE_ON On On - * NV_CTRL_DDCCI_MISC_POWER_MODE_STANDBY Standby Off - * NV_CTRL_DDCCI_MISC_POWER_MODE_SUSPEND Suspend Off - * NV_CTRL_DDCCI_MISC_POWER_MODE_OFF Off Off - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_POWER_MODE 209/* RWD */ -#define NV_CTRL_DDCCI_MISC_POWER_MODE_ON 1 -#define NV_CTRL_DDCCI_MISC_POWER_MODE_STANDBY 2 -#define NV_CTRL_DDCCI_MISC_POWER_MODE_SUSPEND 3 -#define NV_CTRL_DDCCI_MISC_POWER_MODE_OFF 4 - -/* Controls output of an auxiliary power output from a display to a host device. - * NV_CTRL_DDCCI_MISC_AUXILIARY_POWER_OUTPUT_DISABLE: - * Disable auxiliary output power - * NV_CTRL_DDCCI_MISC_AUXILIARY_POWER_OUTPUT_ENABLE: - * Enable auxiliary output power - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_AUXILIARY_POWER_OUTPUT 210/* RWD */ -#define NV_CTRL_DDCCI_MISC_AUXILIARY_POWER_OUTPUT_DISABLE 1 -#define NV_CTRL_DDCCI_MISC_AUXILIARY_POWER_OUTPUT_ENABLE 2 - -/* Operation mode - * NV_CTRL_DDCCI_MISC_OPERATION_MODE_STANDALONE: Stand alone - * NV_CTRL_DDCCI_MISC_OPERATION_MODE_SLAVE: Slave (full PC control) - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_OPERATION_MODE 211/* -WD */ -#define NV_CTRL_DDCCI_MISC_OPERATION_MODE_STANDALONE 1 -#define NV_CTRL_DDCCI_MISC_OPERATION_MODE_SLAVE 2 - -/* Define the version number of VCP list recognized by the display. - * This is a 2 byte value, byte 1 defines the version number and - * byte 2 defines the revision number - * e.g 02 00 (hex) defines Version 2, Revision 0 - * Type: Integer - */ -#define NV_CTRL_DDCCI_MISC_VCP_VERSION 212/* R-D */ - -/* Save the current adjustment data to EEPROM or other - * non-volatile storage inside the display - * Returns TRUE on success - * Type: Boolean - */ -#define NV_CTRL_DDCCI_SAVE_CURRENT_SETTINGS 213/* -WD */ - -/* Detects if the display is DDC/CI capable - * Returns TRUE on success - * Type: Boolean - */ -#define NV_CTRL_DDCCI_CAPABLE 214/* R-D*/ - -#define NV_CTRL_DDCCI_FIRST_VCP NV_CTRL_DDCCI_GEOMETRY_HORIZONTAL_POSITION -#define NV_CTRL_DDCCI_LAST_VCP NV_CTRL_DDCCI_CAPABLE -/**************************************************************************/ - /* * NV_CTRL_FLATPANEL_CHIP_LOCATION - for the specified display device, * report whether the flat panel is driven by the on-chip controller, @@ -2700,11 +1501,11 @@ #define NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 227 /* --- */ /* - * Override the SDI hardware's Color Space Conversion with the values - * controlled through XNVCTRLSetGvoColorConversion() and - * XNVCTRLGetGvoColorConversion(). If this attribute is FALSE, then - * the values specified through XNVCTRLSetGvoColorConversion() are - * ignored. + * NV_CTRL_GVO_OVERRIDE_HW_CSC - Override the SDI hardware's Color Space + * Conversion with the values controlled through + * XNVCTRLSetGvoColorConversion() and XNVCTRLGetGvoColorConversion(). If + * this attribute is FALSE, then the values specified through + * XNVCTRLSetGvoColorConversion() are ignored. */ #define NV_CTRL_GVO_OVERRIDE_HW_CSC 228 /* RW- */ @@ -3121,7 +1922,7 @@ #define NV_CTRL_HWOVERLAY_TRUE 1 /* - * NV_CTRL_NUM_GPU_ERRORS_RECOVERED - Returns the number of gpu errors + * NV_CTRL_NUM_GPU_ERRORS_RECOVERED - Returns the number of GPU errors * occured. This attribute may be queried through XNVCTRLQueryTargetAttribute() * using a NV_CTRL_TARGET_TYPE_X_SCREEN target. */ @@ -3318,15 +2119,18 @@ /* - * NV_CTRL_SWITCH_TO_DISPLAYS takes display to which - * user wants to switch. + * NV_CTRL_SWITCH_TO_DISPLAYS - Can be used to select which displays + * to switch to (as a hotkey event). */ #define NV_CTRL_SWITCH_TO_DISPLAYS 276 /* -W- */ + /* - * NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT can be used to send event - * to notify open/closure of the lid. + * NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT - Event that notifies + * when a notebook lid change occurs (i.e. when the lid is opened or + * closed.) This attribute can be queried to retrieve the current + * notebook lid status (opened/closed.) */ #define NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT 277 /* RW- */ @@ -3334,8 +2138,8 @@ #define NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT_OPEN 1 /* - * NV_CTRL_NOTEBOOK_INTERNAL_LCD returns intenal LCD - * of Notebook. + * NV_CTRL_NOTEBOOK_INTERNAL_LCD - Returns the display device mask of + * the intenal LCD of a notebook. */ #define NV_CTRL_NOTEBOOK_INTERNAL_LCD 278 /* R-- */ @@ -3347,6 +2151,7 @@ #define NV_CTRL_DEPTH_30_ALLOWED 279 /* R--G */ + /* * NV_CTRL_MODE_SET_EVENT This attribute is sent as an event * when hotkey, ctrl-alt-+/- or randr event occurs. Note that @@ -3357,6 +2162,26 @@ #define NV_CTRL_MODE_SET_EVENT 280 /* --- */ + +/* + * NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE - the gamma value used by + * OpenGL when NV_CTRL_OPENGL_AA_LINE_GAMMA is enabled + */ + +#define NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE 281 /* RW-X */ + + +/* + * NV_CTRL_VCSC_HIGH_PERF_MODE - Is used to both query High Performance Mode + * status on the Visual Computing System, and also to enable or disable High + * Performance Mode. + */ + +#define NV_CTRL_VCSC_HIGH_PERF_MODE 282 /* RW-V */ +#define NV_CTRL_VCSC_HIGH_PERF_MODE_DISABLE 0 +#define NV_CTRL_VCSC_HIGH_PERF_MODE_ENABLE 1 + + /* * NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE - the gamma value used by * OpenGL when NV_CTRL_OPENGL_AA_LINE_GAMMA is enabled @@ -3403,6 +2228,14 @@ #define NV_CTRL_GVO_CSC_CHANGED_EVENT 294 /* --- */ +/* + * NV_CTRL_FRAMELOCK_SLAVEABLE - Returns a bitmask of the display devices + * that are (currently) allowed to be selected as slave devices for the + * given GPU + */ + +#define NV_CTRL_FRAMELOCK_SLAVEABLE 295 /* R-DG */ + /* * NV_CTRL_GVO_SYNC_TO_DISPLAY This attribute controls whether or not * the non-SDI display device will be sync'ed to the SDI display device @@ -3414,8 +2247,37 @@ #define NV_CTRL_GVO_SYNC_TO_DISPLAY_DISABLE 0 #define NV_CTRL_GVO_SYNC_TO_DISPLAY_ENABLE 1 +/* + * NV_CTRL_PIXMAP_CACHE - This attribute controls whether the driver attempts to + * store video memory pixmaps in a cache. The cache speeds up allocation and + * deallocation of pixmaps, but could use more memory than when the cache is + * disabled. + */ + +#define NV_CTRL_PIXMAP_CACHE 298 /* RW-X */ +#define NV_CTRL_PIXMAP_CACHE_DISABLE 0 +#define NV_CTRL_PIXMAP_CACHE_ENABLE 1 + +/* + * NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB - When the pixmap cache is enabled and + * there is not enough free space in the cache to fit a new pixmap, the driver + * will round up to the next multiple of this number of kilobytes when + * allocating more memory for the cache. + */ + +#define NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB 299 /* RW-X */ + +/* + * NV_CTRL_IS_GVO_DISPLAY - returns whether or not a given display is an + * SDI device. + */ + +#define NV_CTRL_IS_GVO_DISPLAY 300 /* R-D */ +#define NV_CTRL_IS_GVO_DISPLAY_FALSE 0 +#define NV_CTRL_IS_GVO_DISPLAY_TRUE 1 + -#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_GVO_SYNC_TO_DISPLAY +#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_IS_GVO_DISPLAY /**************************************************************************/ @@ -3483,33 +2345,6 @@ #define NV_CTRL_STRING_TV_ENCODER_NAME 5 /* R-DG */ -/* NV_CTRL_STRING_DDCCI_MISC_TRANSMIT_DISPLAY_DESCRIPTOR - - * Allows a display descriptor (up to maximum length defined by the - * display (see NV_CTRL_DDCCI_MISC_DISPLAY_DESCRIPTOR_LENGTHC2h) to be written - * (read) to (from) non-volatile storage in the display. - * If an attempt is made to write beyond the maximum storage - * length, the descriptor shall be truncated with the excess bytes - * being discarded. - */ - -#define NV_CTRL_STRING_DDCCI_MISC_TRANSMIT_DISPLAY_DESCRIPTOR 6 /* RWD */ - - -/* NV_CTRL_STRING_DDCCI_MISC_AUXILIARY_DISPLAY_DATA - - * An `auxiliary display' is a small alpha-numeric display associated - * with the primary display and able to be accessed via the primary - * display. - * This command transmits a number of bytes of alpha-numeric - * data to be displayed on the auxiliary display. The data shall - * conform to ISO 8859-2 (Latin 1) code set. - * The auxiliary display will be written from the top left position, - * moving to right along each line and then starting at left end of the - * next line. - */ - -#define NV_CTRL_STRING_DDCCI_MISC_AUXILIARY_DISPLAY_DATA 7 /* -WD */ - - /* * NV_CTRL_STRING_GVO_FIRMWARE_VERSION - indicates the version of the * Firmware on the GVO device. @@ -3840,8 +2675,101 @@ #define NV_CTRL_STRING_PERFORMANCE_MODES 29 /* R--G */ + +/* + * NV_CTRL_STRING_VCSC_FAN_STATUS - returns a string with status of all the + * fans in the Visual Computing System, if such a query is supported. Fan + * information is reported along with its tachometer reading (in RPM) and a + * flag indicating whether the fan has failed or not. + * + * Valid tokens: + * + * Token Value + * "fan" integer - the Fan index + * "speed" integer - the tachometer reading of the fan in rpm + * "fail" integer - flag to indicate whether the fan has failed + * + * Example: + * + * fan=0, speed=694, fail=0 ; fan=1, speed=693, fail=0 + * + * This attribute must be queried through XNVCTRLQueryTargetStringAttribute() + * using a NV_CTRL_TARGET_TYPE_VCSC target. + * + */ + +#define NV_CTRL_STRING_VCSC_FAN_STATUS 30 /* R---V */ + + +/* + * NV_CTRL_STRING_VCSC_TEMPERATURES - returns a string with all Temperature + * readings in the Visual Computing System, if such a query is supported. + * Intake, Exhaust and Board Temperature values are reported in Celcius. + * + * Valid tokens: + * + * Token Value + * "intake" integer - the intake temperature for the VCS + * "exhaust" integer - the exhaust temperature for the VCS + * "board" integer - the board temperature of the VCS + * + * Example: + * + * intake=29, exhaust=46, board=41 + * + * This attribute must be queried through XNVCTRLQueryTargetStringAttribute() + * using a NV_CTRL_TARGET_TYPE_VCSC target. + * + */ + +#define NV_CTRL_STRING_VCSC_TEMPERATURES 31 /* R---V */ + + +/* + * NV_CTRL_STRING_VCSC_PSU_INFO - returns a string with all Power Supply Unit + * related readings in the Visual Computing System, if such a query is + * supported. Current in amperes, Power in watts, Voltage in volts and PSU + * state may be reported. Not all PSU types support all of these values, and + * therefore some readings may be unknown. + * + * Valid tokens: + * + * Token Value + * "current" integer - the current drawn in amperes by the VCS + * "power" integer - the power drawn in watts by the VCS + * "voltage" integer - the voltage reading of the VCS + * "state" integer - flag to indicate whether PSU is operating normally + * + * Example: + * + * current=10, power=15, voltage=unknown, state=normal + * + * This attribute must be queried through XNVCTRLQueryTargetStringAttribute() + * using a NV_CTRL_TARGET_TYPE_VCSC target. + * + */ + + +#define NV_CTRL_STRING_VCSC_PSU_INFO 32 /* R---V */ + + +/* + * NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME - query the name for the specified + * NV_CTRL_GVO_VIDEO_FORMAT_*. So that this can be queried with existing + * interfaces, XNVCTRLQueryStringAttribute() should be used, and the video + * format specified in the display_mask field; eg: + * + * XNVCTRLQueryStringAttribute(dpy, + * screen, + * NV_CTRL_GVO_VIDEO_FORMAT_720P_60_00_SMPTE296, + * NV_CTRL_GVO_VIDEO_FORMAT_NAME, + * &name); + */ + +#define NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME 33 /* R--- */ + #define NV_CTRL_STRING_LAST_ATTRIBUTE \ - NV_CTRL_STRING_PERFORMANCE_MODES + NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME /**************************************************************************/ diff --git a/src/libXNVCtrl/NVCtrlLib.h b/src/libXNVCtrl/NVCtrlLib.h index b1edba7..bd09410 100644 --- a/src/libXNVCtrl/NVCtrlLib.h +++ b/src/libXNVCtrl/NVCtrlLib.h @@ -413,225 +413,6 @@ Bool XNVCTRLQueryGvoColorConversion ( ); -/* SPECIAL HANDLING OF VCP CODES - * - * XNVCTRLQueryDDCCILutSize - * XNVCTRLQueryDDCCISinglePointLutOperation - * XNVCTRLSetDDCCISinglePointLutOperation - * XNVCTRLQueryDDCCIBlockLutOperation - * XNVCTRLSetDDCCIBlockLutOperation - * XNVCTRLSetDDCCIRemoteProcedureCall - * XNVCTRLQueryDDCCIDisplayControllerType - - * Some of DDC/CI VCP codes handle multiple values, - * therefore they need their own NV_CONTROL structure - */ - -/* XNVCTRLQueryDDCCILutSize - * Provides the size (number of entries and number of bits / entry) - * for the Red / Green and Blue LUT in the display - * - * red_entries: Number of Red LUT entries - * green_entries: Number of Green LUT entries - * blue_entries: Number of Blue LUT entries - * red_bits_per_entries: Number of bits / entry in Red LUT - * green_bits_per_entries: Number of bits / entry in Green LUT - * blue_bits_per_entries: Number of bits / entry in Blue LUT - * Returns TRUE on success - */ -Bool XNVCTRLQueryDDCCILutSize ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int *red_entries, - unsigned int *green_entries, - unsigned int *blue_entries, - unsigned int *red_bits_per_entries, - unsigned int *green_bits_per_entries, - unsigned int *blue_bits_per_entries -); - -/* XNVCTRLQueryDDCCISinglePointLutOperation - * Allows a single point within a display's color LUT to be read - * Input: - * offset: Offset into the LUT - * Output: - * red_value: Red LUT value read - * green_value: Green LUT value read - * blue_value: Blue LUT value read - * Returns TRUE on success - */ -Bool XNVCTRLQueryDDCCISinglePointLutOperation ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int offset, - unsigned int *red_value, - unsigned int *green_value, - unsigned int *blue_value -); - -/* XNVCTRLSetDDCCISinglePointLutOperation - * Allows a single point within a display's color LUT (look up table) - * to be loaded. - * offset: Offset into the LUT - * red_value: Red LUT value to be loaded - * green_value: Green LUT value to be loaded - * blue_value: Blue LUT value to be loaded - * Note: If display LUT cannot store 16 bit values then least significant - * bits are discarded - * Returns TRUE on success - */ -Bool XNVCTRLSetDDCCISinglePointLutOperation ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int offset, - unsigned int red_value, - unsigned int green_value, - unsigned int blue_value -); - -/* XNVCTRLQueryDDCCIBlockLutOperation - * Provides an efficient method for reading multiple values from a display's LUT - * color: is one of NV_CTRL_DDCCI_RED_LUT, NV_CTRL_DDCCI_GREEN_LUT, - * NV_CTRL_DDCCI_BLUE_LUT. Color to be read. - * size: Number of values to be read - * offset: Offset into Red or Green or Blue LUT - * value: Red or Green or Blue LUT contents. Needs to be freed when done. - * Returns TRUE on success - */ -Bool XNVCTRLQueryDDCCIBlockLutOperation ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int color, - unsigned int size, - unsigned int offset, - unsigned int **value -); - -/* XNVCTRLSetDDCCIBlockLutOperation - * Provides an efficient method for loading multiple values into a display's LUT - * size: Number of values to be loaded - * offset: Offset into Red or Green or Blue LUT - * value: R or G or B LUT values to be loaded - * color: NV_CTRL_DDCCI_RED_LUT, NV_CTRL_DDCCI_GREEN_LUT, NV_CTRL_DDCCI_BLUE_LUT - * Note: If display LUT cannot store 16 bit values then least significant - * bits are discarded - * Returns TRUE on success - */ -#define NV_CTRL_DDCCI_RED_LUT 1 -#define NV_CTRL_DDCCI_GREEN_LUT 2 -#define NV_CTRL_DDCCI_BLUE_LUT 3 -Bool XNVCTRLSetDDCCIBlockLutOperation ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int color, - unsigned int offset, - unsigned int size, - unsigned int *value -); - -/* XNVCTRLSetDDCCIRemoteProcedureCall - * Allows initiation of a routine / macro resident in the display. Only - * one RPC is defined at this time: - * A spline curve routine applied to the data (supplied in format - * below) and the resulting data used to derive a full set of values - * for the display color LUT which shall then be loaded. - * offset: Offset into the LUT - * size: Number of values to be loaded - * red_lut: Red LUT values - * green_lut: Green LUT value - * blue_lut: Blue LUT value - * increment: Increment to next LUT entry - * Values of E0h FFh inclusive are reserved for manufacturer - * specific routines / macros. - * All other values are reserved and shall be ignored. - * Returns TRUE on success - */ -Bool XNVCTRLSetDDCCIRemoteProcedureCall ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int offset, - unsigned int size, - unsigned int *red_lut, - unsigned int *green_lut, - unsigned int *blue_lut, - unsigned int *increment -); - -/* XNVCTRLQueryDDCCIDisplayControllerType: - * Provides the host with knowledge of the controller type being used by a - * particular display - * controller_manufacturer: Indicates controller manufacturer. (This string - * needs to be freed when done) (XXX This will be changed to a static string) - * controller_type: Provide a numeric indication of controller type - * Return TRUE on success - */ -Bool XNVCTRLQueryDDCCIDisplayControllerType ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned char **controller_manufacturer, - unsigned int *controller_type -); - -/* NVCTRLQueryDDCCICapabilities: - * Gets the capabilities of the display as a VCP string - * Returns : - * nvctrl_vcp_supported: a table of 0 (not supported) and 1 (supported) - * which index is the NV_CTRL_DDCI* values - * possible_value_offset; contains the offsets in the table - * nvctrl_vcp_possible_values. Index is the NV_CTRL_DDCI* values. - * -1 means no possible values are available. - * possible_value_size; contains the count in the table - * nvctrl_vcp_possible_values. Index is the NV_CTRL_DDCI* values. - * -1 means no possible values are available. - * nvctrl_vcp_possible_values: a table of possible values for the non - * continuous values. - * nvctrl_string_vcp_supported: a table or 0 (not supported) and 1 (supported) - * which index is the NV_CTRL_STRING_DDCI* values. - * - * Returns TRUE on success - */ -Bool NVCTRLQueryDDCCICapabilities ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int **nvctrl_vcp_supported, // Size is NV_CTRL_DDCCI_LAST_VCP+1 - unsigned int **possible_values_offset, // Size is NV_CTRL_DDCCI_LAST_VCP+1 - unsigned int **possible_values_size, // Size is NV_CTRL_DDCCI_LAST_VCP+1 - unsigned int **nvctrl_vcp_possible_values, - unsigned int **nvctrl_string_vcp_supported // Size is NV_CTRL_STRING_LAST_ATTRIBUTE+1 -); - -/* XNVCTRLQueryDDCCITimingReport - * Queries the currently operating video signal timing report data. - * - is_sync_freq_out_range: Sync. Freq. out of range (TRUE/FALSE) - * - is_unstable_count: Unstable Count (TRUE/FALSE) - * - is_positive_h_sync: Positive Horizontal sync polarity (TRUE/FALSE) - * - is_positive_v_sync: Positive Vertical sync polarity (TRUE/FALSE) - * - h_freq: Horizontal Frequency - * - v_freq: Vertical Frequency. - * - * Returns TRUE on success - */ -Bool XNVCTRLQueryDDCCITimingReport ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int *sync_freq_out_range, - unsigned int *unstable_count, - unsigned int *positive_h_sync, - unsigned int *positive_v_sync, - unsigned int *h_freq, - unsigned int *v_freq -); - - /* * XNVCTRLQueryBinaryData - * diff --git a/src/libXNVCtrl/nv_control.h b/src/libXNVCtrl/nv_control.h index 04deb2e..b424724 100644 --- a/src/libXNVCtrl/nv_control.h +++ b/src/libXNVCtrl/nv_control.h @@ -41,15 +41,15 @@ #define X_nvCtrlSetGvoColorConversion_deprecated 7 #define X_nvCtrlQueryGvoColorConversion_deprecated 8 #define X_nvCtrlSetStringAttribute 9 -#define X_nvCtrlQueryDDCCILutSize 10 -#define X_nvCtrlQueryDDCCISinglePointLutOperation 11 -#define X_nvCtrlSetDDCCISinglePointLutOperation 12 -#define X_nvCtrlQueryDDCCIBlockLutOperation 13 -#define X_nvCtrlSetDDCCIBlockLutOperation 14 -#define X_nvCtrlSetDDCCIRemoteProcedureCall 15 -#define X_nvCtrlQueryDDCCIDisplayControllerType 16 -#define X_nvCtrlQueryDDCCICapabilities 17 -#define X_nvCtrlQueryDDCCITimingReport 18 +/* STUB X_nvCtrlQueryDDCCILutSize 10 */ +/* STUB X_nvCtrlQueryDDCCISinglePointLutOperation 11 */ +/* STUB X_nvCtrlSetDDCCISinglePointLutOperation 12 */ +/* STUB X_nvCtrlQueryDDCCIBlockLutOperation 13 */ +/* STUB X_nvCtrlSetDDCCIBlockLutOperation 14 */ +/* STUB X_nvCtrlSetDDCCIRemoteProcedureCall 15 */ +/* STUB X_nvCtrlQueryDDCCIDisplayControllerType 16 */ +/* STUB X_nvCtrlQueryDDCCICapabilities 17 */ +/* STUB X_nvCtrlQueryDDCCITimingReport 18 */ #define X_nvCtrlSetAttributeAndGetStatus 19 #define X_nvCtrlQueryBinaryData 20 #define X_nvCtrlSetGvoColorConversion 21 @@ -371,231 +371,6 @@ typedef struct { } xnvCtrlQueryGvoColorConversionReply; #define sz_xnvCtrlQueryGvoColorConversionReply 32 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 display_mask B32; -} xnvCtrlQueryDDCCILutSizeReq; -#define sz_xnvCtrlQueryDDCCILutSizeReq 12 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 flags B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xnvCtrlQueryDDCCILutSizeReply; -#define sz_xnvCtrlQueryDDCCILutSizeReply 32 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 display_mask B32; - CARD32 offset B32; - CARD32 red_value B32; - CARD32 green_value B32; - CARD32 blue_value B32; -} xnvCtrlSetDDCCISinglePointLutOperationReq; -#define sz_xnvCtrlSetDDCCISinglePointLutOperationReq 28 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 flags B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xnvCtrlSetDDCCISinglePointLutOperationReply; -#define sz_xnvCtrlSetDDCCISinglePointLutOperationReply 32 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 display_mask B32; - CARD32 offset B32; -} xnvCtrlQueryDDCCISinglePointLutOperationReq; -#define sz_xnvCtrlQueryDDCCISinglePointLutOperationReq 16 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 flags B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xnvCtrlQueryDDCCISinglePointLutOperationReply; -#define sz_xnvCtrlQueryDDCCISinglePointLutOperationReply 32 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 display_mask B32; - CARD32 size B32; - CARD32 color B32; - CARD32 offset B32; -} xnvCtrlQueryDDCCIBlockLutOperationReq; -#define sz_xnvCtrlQueryDDCCIBlockLutOperationReq 24 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 num_bytes B32; - CARD32 flags B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xnvCtrlQueryDDCCIBlockLutOperationReply; -#define sz_xnvCtrlQueryDDCCIBlockLutOperationReply 32 - - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 display_mask B32; - CARD32 color B32; - CARD32 offset B32; - CARD32 size B32; - CARD32 num_bytes B32; -} xnvCtrlSetDDCCIBlockLutOperationReq; -#define sz_xnvCtrlSetDDCCIBlockLutOperationReq 28 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 num_bytes B32; - CARD32 flags B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xnvCtrlSetDDCCIBlockLutOperationReply; -#define sz_xnvCtrlSetDDCCIBlockLutOperationReply 32 - - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 display_mask B32; - CARD32 num_bytes B32; - CARD32 size B32; - CARD32 offset B32; -} xnvCtrlSetDDCCIRemoteProcedureCallReq; -#define sz_xnvCtrlSetDDCCIRemoteProcedureCallReq 24 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 num_bytes B32; - CARD32 flags B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xnvCtrlSetDDCCIRemoteProcedureCallReply; -#define sz_xnvCtrlSetDDCCIRemoteProcedureCallReply 32 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 display_mask B32; -} xnvCtrlQueryDDCCIDisplayControllerTypeReq; -#define sz_xnvCtrlQueryDDCCIDisplayControllerTypeReq 12 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 controller_type B32; - CARD32 size B32; - CARD32 flags B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; -} xnvCtrlQueryDDCCIDisplayControllerTypeReply; -#define sz_xnvCtrlQueryDDCCIDisplayControllerTypeReply 32 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 display_mask B32; -} xnvCtrlQueryDDCCICapabilitiesReq; -#define sz_xnvCtrlQueryDDCCICapabilitiesReq 12 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 num_bytes B32; - CARD32 flags B32; - CARD32 possible_val_len B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xnvCtrlQueryDDCCICapabilitiesReply; -#define sz_xnvCtrlQueryDDCCICapabilitiesReply 32 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 display_mask B32; -} xnvCtrlQueryDDCCITimingReportReq; -#define sz_xnvCtrlQueryDDCCITimingReportReq 12 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 flags B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xnvCtrlQueryDDCCITimingReportReply; -#define sz_xnvCtrlQueryDDCCITimingReportReply 32 - typedef struct { CARD8 reqType; CARD8 nvReqType; diff --git a/src/nvidia-settings.c b/src/nvidia-settings.c index df16753..c35d7ab 100644 --- a/src/nvidia-settings.c +++ b/src/nvidia-settings.c @@ -39,11 +39,8 @@ int main(int argc, char **argv) ConfigProperties conf; ParsedAttribute *p; CtrlHandles *h; - NvCtrlAttributeHandle **screen_handles = NULL; - NvCtrlAttributeHandle **gpu_handles = NULL; - NvCtrlAttributeHandle **vcs_handles = NULL; Options *op; - int ret, i, num_screen_handles, num_gpu_handles, num_vcs_handles; + int ret; char *dpy = NULL; int gui = 0; @@ -144,59 +141,9 @@ int main(int argc, char **argv) return 1; } - /* - * pull the screen and gpu handles out of the CtrlHandles so that we can - * pass them to the gui - */ - - num_screen_handles = h->targets[X_SCREEN_TARGET].n; - - if (num_screen_handles) { - screen_handles = - malloc(num_screen_handles * sizeof(NvCtrlAttributeHandle *)); - if (screen_handles) { - for (i = 0; i < num_screen_handles; i++) { - screen_handles[i] = h->targets[X_SCREEN_TARGET].t[i].h; - } - } else { - num_screen_handles = 0; - } - } - - num_gpu_handles = h->targets[GPU_TARGET].n; - - if (num_gpu_handles) { - gpu_handles = - malloc(num_gpu_handles * sizeof(NvCtrlAttributeHandle *)); - if (gpu_handles) { - for (i = 0; i < num_gpu_handles; i++) { - gpu_handles[i] = h->targets[GPU_TARGET].t[i].h; - } - } else { - num_gpu_handles = 0; - } - } - - num_vcs_handles = h->targets[VCS_TARGET].n; - - if (num_vcs_handles) { - vcs_handles = - malloc(num_vcs_handles * sizeof(NvCtrlAttributeHandle *)); - if (vcs_handles) { - for (i = 0; i < num_vcs_handles; i++) { - vcs_handles[i] = h->targets[VCS_TARGET].t[i].h; - } - } else { - num_vcs_handles = 0; - } - } - /* pass control to the gui */ - ctk_main(screen_handles, num_screen_handles, - gpu_handles, num_gpu_handles, - vcs_handles, num_vcs_handles, - p, &conf, h); + ctk_main(p, &conf, h); /* write the configuration file */ @@ -204,8 +151,6 @@ int main(int argc, char **argv) /* cleanup */ - if (screen_handles) free(screen_handles); - if (gpu_handles) free(gpu_handles); nv_free_ctrl_handles(h); nv_parsed_attribute_free(p); diff --git a/src/parse.c b/src/parse.c index 9a0aa87..95cd9e0 100644 --- a/src/parse.c +++ b/src/parse.c @@ -53,7 +53,7 @@ static char *nv_strndup(char *s, int n); #define F NV_PARSER_TYPE_FRAMELOCK #define C NV_PARSER_TYPE_COLOR_ATTRIBUTE #define N NV_PARSER_TYPE_NO_CONFIG_WRITE -#define G NV_PARSER_TYPE_GUI_ATTRIUBUTE +#define G NV_PARSER_TYPE_GUI_ATTRIBUTE #define V NV_PARSER_TYPE_XVIDEO_ATTRIBUTE #define P NV_PARSER_TYPE_PACKED_ATTRIBUTE #define D NV_PARSER_TYPE_VALUE_IS_DISPLAY @@ -67,179 +67,198 @@ static char *nv_strndup(char *s, int n); AttributeTableEntry attributeTable[] = { - /* name constant flags */ + /* name constant flags description */ + + /* Version information */ + { "OperatingSystem", NV_CTRL_OPERATING_SYSTEM, N, "The operating system on which the X server is running. (0-Linux, 1-FreeBSD, 2-SunOS.)" }, + { "NvidiaDriverVersion", NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, S|N, "The NVIDIA X driver version." }, + { "NvControlVersion", NV_CTRL_STRING_NV_CONTROL_VERSION, S|N, "The NV-CONTROL X driver extension version." }, + { "GLXServerVersion", NV_CTRL_STRING_GLX_SERVER_VERSION, S|N, "The GLX X server extension version." }, + { "GLXClientVersion", NV_CTRL_STRING_GLX_CLIENT_VERSION, S|N, "The GLX client version." }, + { "OpenGLVersion", NV_CTRL_STRING_GLX_OPENGL_VERSION, S|N, "The OpenGL version." }, + { "XRandRVersion", NV_CTRL_STRING_XRANDR_VERSION, S|N, "The X RandR version." }, + { "XF86VidModeVersion", NV_CTRL_STRING_XF86VIDMODE_VERSION, S|N, "The XF86 Video Mode X extension version." }, + { "XvVersion", NV_CTRL_STRING_XV_VERSION, S|N, "The Xv X extension version." }, - { "FlatpanelDithering", NV_CTRL_FLATPANEL_DITHERING, 0 }, - { "DigitalVibrance", NV_CTRL_DIGITAL_VIBRANCE, 0 }, - { "ImageSharpening", NV_CTRL_IMAGE_SHARPENING, 0 }, - { "BusType", NV_CTRL_BUS_TYPE, 0 }, - { "BusRate", NV_CTRL_BUS_RATE, 0 }, - { "VideoRam", NV_CTRL_VIDEO_RAM, 0 }, - { "Irq", NV_CTRL_IRQ, 0 }, - { "OperatingSystem", NV_CTRL_OPERATING_SYSTEM, 0 }, - { "SyncToVBlank", NV_CTRL_SYNC_TO_VBLANK, 0 }, - { "AllowFlipping", NV_CTRL_FLIPPING_ALLOWED, 0 }, - { "ForceStereoFlipping", NV_CTRL_FORCE_STEREO, 0 }, - { "XineramaStereoFlipping",NV_CTRL_XINERAMA_STEREO, 0 }, - { "LogAniso", NV_CTRL_LOG_ANISO, 0 }, - { "FSAA", NV_CTRL_FSAA_MODE, 0 }, - { "TextureSharpen", NV_CTRL_TEXTURE_SHARPEN, 0 }, - { "Ubb", NV_CTRL_UBB, 0 }, - { "Overlay", NV_CTRL_OVERLAY, 0 }, - { "HWOverlay", NV_CTRL_HWOVERLAY, 0 }, - { "Stereo", NV_CTRL_STEREO, 0 }, - { "StereoEyesExchange", NV_CTRL_STEREO_EYES_EXCHANGE, 0 }, - { "TwinView", NV_CTRL_TWINVIEW, 0 }, - { "ConnectedDisplays", NV_CTRL_CONNECTED_DISPLAYS, D }, - { "EnabledDisplays", NV_CTRL_ENABLED_DISPLAYS, D }, - { "NotebookInternalLCD", NV_CTRL_NOTEBOOK_INTERNAL_LCD, N|D }, - { "NotebookDisplayChangeLidEvent", NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT, N }, - { "SwitchToDisplays", NV_CTRL_SWITCH_TO_DISPLAYS, D|N|W }, - { "AssociatedDisplays", NV_CTRL_ASSOCIATED_DISPLAY_DEVICES, N|D }, - { "ProbeDisplays", NV_CTRL_PROBE_DISPLAYS, A }, - { "Depth30Allowed", NV_CTRL_DEPTH_30_ALLOWED, N }, - { "NoScanout", NV_CTRL_NO_SCANOUT, N }, - { "ForceGenericCpu", NV_CTRL_FORCE_GENERIC_CPU, N }, - { "GammaCorrectedAALinesValue", NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE, 0 }, - { "GammaCorrectedAALines", NV_CTRL_OPENGL_AA_LINE_GAMMA, 0 }, - { "ShowSLIHUD", NV_CTRL_SHOW_SLI_HUD, 0 }, - { "CursorShadow", NV_CTRL_CURSOR_SHADOW, 0 }, - { "CursorShadowXOffset", NV_CTRL_CURSOR_SHADOW_X_OFFSET, 0 }, - { "CursorShadowYOffset", NV_CTRL_CURSOR_SHADOW_Y_OFFSET, 0 }, - { "CursorShadowAlpha", NV_CTRL_CURSOR_SHADOW_ALPHA, 0 }, - { "CursorShadowRed", NV_CTRL_CURSOR_SHADOW_RED, 0 }, - { "CursorShadowGreen", NV_CTRL_CURSOR_SHADOW_GREEN, 0 }, - { "CursorShadowBlue", NV_CTRL_CURSOR_SHADOW_BLUE, 0 }, - { "FSAAAppControlled", NV_CTRL_FSAA_APPLICATION_CONTROLLED, 0 }, - { "LogAnisoAppControlled", NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED,0 }, - { "RefreshRate", NV_CTRL_REFRESH_RATE, N|H }, - { "RefreshRate3", NV_CTRL_REFRESH_RATE_3, N|K }, - { "InitialPixmapPlacement",NV_CTRL_INITIAL_PIXMAP_PLACEMENT, N }, - { "GlyphCache", NV_CTRL_GLYPH_CACHE, N }, - { "PCIBus", NV_CTRL_PCI_BUS, N }, - { "PCIDevice", NV_CTRL_PCI_DEVICE, N }, - { "PCIFunc", NV_CTRL_PCI_FUNCTION, N }, - { "DynamicTwinview", NV_CTRL_DYNAMIC_TWINVIEW, N }, - { "MultiGpuDisplayOwner", NV_CTRL_MULTIGPU_DISPLAY_OWNER, N }, - { "GPUScaling", NV_CTRL_GPU_SCALING, P }, - { "FrontendResolution", NV_CTRL_FRONTEND_RESOLUTION, N|P }, - { "BackendResolution", NV_CTRL_BACKEND_RESOLUTION, N|P }, - { "FlatpanelNativeResolution", NV_CTRL_FLATPANEL_NATIVE_RESOLUTION, N|P }, - { "FlatpanelBestFitResolution", NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION, N|P }, - { "GPUScalingActive", NV_CTRL_GPU_SCALING_ACTIVE, N }, - { "DFPScalingActive", NV_CTRL_DFP_SCALING_ACTIVE, N }, - { "FSAAAppEnhanced", NV_CTRL_FSAA_APPLICATION_ENHANCED, 0 }, - { "GPUErrors", NV_CTRL_NUM_GPU_ERRORS_RECOVERED, N }, - { "OnDemandVBlankInterrupts", NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS, 0 }, - - { "FrameLockMaster", NV_CTRL_FRAMELOCK_MASTER, N|F|G|D }, - { "FrameLockSlaves", NV_CTRL_FRAMELOCK_SLAVES, N|F|G|D }, - { "FramelockUseHouseSync", NV_CTRL_USE_HOUSE_SYNC, N|F|G }, - { "FrameLockSyncInterval", NV_CTRL_FRAMELOCK_SYNC_INTERVAL, N|F|G }, - { "FrameLockPolarity", NV_CTRL_FRAMELOCK_POLARITY, N|F|G }, - { "FrameLockVideoMode", NV_CTRL_FRAMELOCK_VIDEO_MODE, N|F|G }, - { "FrameLockSyncDelay", NV_CTRL_FRAMELOCK_SYNC_DELAY, N|F|G }, - { "FrameLockEnable", NV_CTRL_FRAMELOCK_SYNC, N|F|G }, - { "FrameLockAvailable", NV_CTRL_FRAMELOCK, N|F|G }, - { "FrameLockPort0Status", NV_CTRL_FRAMELOCK_PORT0_STATUS, N|F|G }, - { "FrameLockPort1Status", NV_CTRL_FRAMELOCK_PORT1_STATUS, N|F|G }, - { "FrameLockHouseStatus", NV_CTRL_FRAMELOCK_HOUSE_STATUS, N|F|G }, - { "FrameLockSyncReady", NV_CTRL_FRAMELOCK_SYNC_READY, N|F|G }, - { "FrameLockStereoSync", NV_CTRL_FRAMELOCK_STEREO_SYNC, N|F|G }, - { "FrameLockTestSignal", NV_CTRL_FRAMELOCK_TEST_SIGNAL, N|F|G }, - { "FrameLockEthDetected", NV_CTRL_FRAMELOCK_ETHERNET_DETECTED, N|F|G }, - { "FrameLockSyncRate", NV_CTRL_FRAMELOCK_SYNC_RATE, N|F|G }, - { "FrameLockSyncRate4", NV_CTRL_FRAMELOCK_SYNC_RATE_4, N|F|G }, - { "FrameLockTiming", NV_CTRL_FRAMELOCK_TIMING, N|F|G }, - { "FrameLockMasterable", NV_CTRL_FRAMELOCK_MASTERABLE, N|F|G }, - { "FrameLockFPGARevision", NV_CTRL_FRAMELOCK_FPGA_REVISION, N|F|G }, - - { "GvoSupported", NV_CTRL_GVO_SUPPORTED, I|N }, - { "GvoSyncMode", NV_CTRL_GVO_SYNC_MODE, I }, - { "GvoSyncSource", NV_CTRL_GVO_SYNC_SOURCE, I }, - { "GvoOutputVideoFormat", NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT, I }, - { "GvoInputVideoFormat", NV_CTRL_GVO_INPUT_VIDEO_FORMAT, I|N }, - { "GvoDataFormat", NV_CTRL_GVO_DATA_FORMAT, I }, - { "GvoDisplayXScreen", NV_CTRL_GVO_DISPLAY_X_SCREEN, I|N }, - { "GvoCompositeSyncInputDetected", NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED, I|N }, - { "GvoCompositeSyncInputDetectMode", NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE, I|N }, - { "GvoSdiSyncInputDetected", NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED, I|N }, - { "GvoVideoOutputs", NV_CTRL_GVO_VIDEO_OUTPUTS, I|N }, - { "GvoSyncDelayPixels", NV_CTRL_GVO_SYNC_DELAY_PIXELS, I }, - { "GvoSyncDelayLines", NV_CTRL_GVO_SYNC_DELAY_LINES, I }, - { "GvoGlxLocked", NV_CTRL_GVO_GLX_LOCKED, I|N }, - { "GvoXScreenPanX", NV_CTRL_GVO_X_SCREEN_PAN_X, I }, - { "GvoXScreenPanY", NV_CTRL_GVO_X_SCREEN_PAN_Y, I }, - { "GvoOverrideHwCsc", NV_CTRL_GVO_OVERRIDE_HW_CSC, I }, - { "GvoCapabilities", NV_CTRL_GVO_CAPABILITIES, I|N }, - { "GvoCompositeTermination", NV_CTRL_GVO_COMPOSITE_TERMINATION, I }, - { "GvoFlipQueueSize", NV_CTRL_GVO_FLIP_QUEUE_SIZE, I }, - { "GvoFirmwareVersion", NV_CTRL_STRING_GVO_FIRMWARE_VERSION, I|S|N }, - { "GvoLockOwner", NV_CTRL_GVO_LOCK_OWNER, I|N }, - { "GvoOutputVideoLocked", NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED, I|N }, - { "GvoSyncLockStatus", NV_CTRL_GVO_SYNC_LOCK_STATUS, I|N }, - { "GvoANCTimeCodeGeneration", NV_CTRL_GVO_ANC_TIME_CODE_GENERATION, I }, - { "GvoComposite", NV_CTRL_GVO_COMPOSITE, I }, - { "GvoCompositeAlphaKey", NV_CTRL_GVO_COMPOSITE_ALPHA_KEY, I }, - { "GvoCompositeNumKeyRanges", NV_CTRL_GVO_COMPOSITE_NUM_KEY_RANGES, I|N }, - { "GvoSyncToDisplay", NV_CTRL_GVO_SYNC_TO_DISPLAY, I|N }, - - { "Brightness", BRIGHTNESS_VALUE|ALL_CHANNELS, N|C|G }, - { "RedBrightness", BRIGHTNESS_VALUE|RED_CHANNEL, C|G }, - { "GreenBrightness", BRIGHTNESS_VALUE|GREEN_CHANNEL, C|G }, - { "BlueBrightness", BRIGHTNESS_VALUE|BLUE_CHANNEL, C|G }, - { "Contrast", CONTRAST_VALUE|ALL_CHANNELS, N|C|G }, - { "RedContrast", CONTRAST_VALUE|RED_CHANNEL, C|G }, - { "GreenContrast", CONTRAST_VALUE|GREEN_CHANNEL, C|G }, - { "BlueContrast", CONTRAST_VALUE|BLUE_CHANNEL, C|G }, - { "Gamma", GAMMA_VALUE|ALL_CHANNELS, N|C|G }, - { "RedGamma", GAMMA_VALUE|RED_CHANNEL, C|G }, - { "GreenGamma", GAMMA_VALUE|GREEN_CHANNEL, C|G }, - { "BlueGamma", GAMMA_VALUE|BLUE_CHANNEL, C|G }, - { "TVOverScan", NV_CTRL_TV_OVERSCAN, 0 }, - { "TVFlickerFilter", NV_CTRL_TV_FLICKER_FILTER, 0 }, - { "TVBrightness", NV_CTRL_TV_BRIGHTNESS, 0 }, - { "TVHue", NV_CTRL_TV_HUE, 0 }, - { "TVContrast", NV_CTRL_TV_CONTRAST, 0 }, - { "TVSaturation", NV_CTRL_TV_SATURATION, 0 }, - { "GPUCoreTemp", NV_CTRL_GPU_CORE_TEMPERATURE, N }, - { "GPUAmbientTemp", NV_CTRL_AMBIENT_TEMPERATURE, N }, - { "OpenGLImageSettings", NV_CTRL_IMAGE_SETTINGS, 0 }, - - { "XVideoOverlaySaturation", NV_CTRL_ATTR_XV_OVERLAY_SATURATION, V }, - { "XVideoOverlayContrast", NV_CTRL_ATTR_XV_OVERLAY_CONTRAST, V }, - { "XVideoOverlayBrightness", NV_CTRL_ATTR_XV_OVERLAY_BRIGHTNESS, V }, - { "XVideoOverlayHue", NV_CTRL_ATTR_XV_OVERLAY_HUE, V }, - { "XVideoTextureBrightness", NV_CTRL_ATTR_XV_TEXTURE_BRIGHTNESS, V }, - { "XVideoTextureContrast", NV_CTRL_ATTR_XV_TEXTURE_CONTRAST, V }, - { "XVideoTextureHue", NV_CTRL_ATTR_XV_TEXTURE_HUE, V }, - { "XVideoTextureSaturation", NV_CTRL_ATTR_XV_TEXTURE_SATURATION, V }, - { "XVideoTextureSyncToVBlank", NV_CTRL_ATTR_XV_TEXTURE_SYNC_TO_VBLANK, V }, - { "XVideoBlitterSyncToVBlank", NV_CTRL_ATTR_XV_BLITTER_SYNC_TO_VBLANK, V }, - { "XVideoSyncToDisplay", NV_CTRL_XV_SYNC_TO_DISPLAY, D|Z }, - - { "GPUOverclockingState", NV_CTRL_GPU_OVERCLOCKING_STATE, N }, - { "GPUDefault2DClockFreqs", NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS, N|P }, - { "GPUDefault3DClockFreqs", NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS, N|P }, - { "GPU2DClockFreqs", NV_CTRL_GPU_2D_CLOCK_FREQS, N|P }, - { "GPU3DClockFreqs", NV_CTRL_GPU_3D_CLOCK_FREQS, N|P }, - { "GPUCurrentClockFreqs", NV_CTRL_GPU_CURRENT_CLOCK_FREQS, N|P }, - { "GPUPerfModes", NV_CTRL_STRING_PERFORMANCE_MODES, S|N }, - - { "NvidiaDriverVersion", NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, S|N }, - { "NvControlVersion", NV_CTRL_STRING_NV_CONTROL_VERSION, S|N }, - { "GLXServerVersion", NV_CTRL_STRING_GLX_SERVER_VERSION, S|N }, - { "GLXClientVersion", NV_CTRL_STRING_GLX_CLIENT_VERSION, S|N }, - { "OpenGLVersion", NV_CTRL_STRING_GLX_OPENGL_VERSION, S|N }, - { "XRandRVersion", NV_CTRL_STRING_XRANDR_VERSION, S|N }, - { "XF86VidModeVersion", NV_CTRL_STRING_XF86VIDMODE_VERSION, S|N }, - { "XvVersion", NV_CTRL_STRING_XV_VERSION, S|N }, - { "SLIMode", NV_CTRL_STRING_SLI_MODE, S|N }, - { "GPUCurrentPerfMode", NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE, N }, - { "GPUCurrentPerfLevel", NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL, N }, - { "GPUAdaptiveClockState", NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE, N }, - { "GPUPowerSource", NV_CTRL_GPU_POWER_SOURCE, N }, - { NULL, 0, 0 } + /* X screen */ + { "Ubb", NV_CTRL_UBB, 0, "Is UBB enabled for the specified X screen." }, + { "Overlay", NV_CTRL_OVERLAY, 0, "Is the RGB overlay enabled for the specified X screen." }, + { "Stereo", NV_CTRL_STEREO, 0, "The stereo mode for the specified X screen." }, + { "TwinView", NV_CTRL_TWINVIEW, 0, "Is TwinView enabled for the specified X screen." }, + { "ConnectedDisplays", NV_CTRL_CONNECTED_DISPLAYS, D, "Display mask indicating the last cached state of the display devices connected to the GPU." }, + { "EnabledDisplays", NV_CTRL_ENABLED_DISPLAYS, D, "Display mask indicating what display devices are enabled for use on the specified X screen or GPU." }, + { "CursorShadow", NV_CTRL_CURSOR_SHADOW, 0, "Hardware cursor shadow." }, + { "CursorShadowAlpha", NV_CTRL_CURSOR_SHADOW_ALPHA, 0, "Hardware cursor shadow alpha (transparency) value." }, + { "CursorShadowRed", NV_CTRL_CURSOR_SHADOW_RED, 0, "Hardware cursor shadow red color." }, + { "CursorShadowGreen", NV_CTRL_CURSOR_SHADOW_GREEN, 0, "Hardware cursor shadow green color." }, + { "CursorShadowBlue", NV_CTRL_CURSOR_SHADOW_BLUE, 0, "Hardware cursor shadow blue color." }, + { "CursorShadowXOffset", NV_CTRL_CURSOR_SHADOW_X_OFFSET, 0, "Hardware cursor shadow X offset." }, + { "CursorShadowYOffset", NV_CTRL_CURSOR_SHADOW_Y_OFFSET, 0, "Hardware cursor shadow Y offset." }, + { "AssociatedDisplays", NV_CTRL_ASSOCIATED_DISPLAY_DEVICES, N|D, "Display device mask indicating which display devices are \"associated\" with the specified X screen (i.e., are available for displaying the desktop)." }, + { "ProbeDisplays", NV_CTRL_PROBE_DISPLAYS, A, "When this attribute is queried, the X driver re-probes the hardware to detect which display devices are connected to the GPU or DPU driving the specified X screen. Returns a display mask of the currently connected display devices." }, + { "InitialPixmapPlacement", NV_CTRL_INITIAL_PIXMAP_PLACEMENT, N, "Controls where X pixmaps are initially created." }, + { "DynamicTwinview", NV_CTRL_DYNAMIC_TWINVIEW, N, "Does the X screen support dynamic TwinView." }, + { "MultiGpuDisplayOwner", NV_CTRL_MULTIGPU_DISPLAY_OWNER, N, "GPU ID of the GPU that has the display device(s) used for showing the X screen." }, + { "HWOverlay", NV_CTRL_HWOVERLAY, 0, "When a workstation overlay is in use, this value is 1 if the hardware overlay is used, or 0 if the overlay is emulated." }, + { "OnDemandVBlankInterrupts", NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS, 0, "Enable/Disable/Query of on-demand vertical blanking interrupt control on the GPU. The 'OnDemandVBlankInterrupts' X server configuration option must be enabled for this option to be available." }, + { "GlyphCache", NV_CTRL_GLYPH_CACHE, N, "Enable or disable caching of glyphs (text) in video memory." }, + { "SwitchToDisplays", NV_CTRL_SWITCH_TO_DISPLAYS, D|N|W, "Used to set which displays should be active." }, + { "NotebookDisplayChangeLidEvent", NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT, N, "Reports notebook lid open/close events." }, + { "NotebookInternalLCD", NV_CTRL_NOTEBOOK_INTERNAL_LCD, N|D, "Returns the display device mask of the internal LCD of a notebook." }, + { "Depth30Allowed", NV_CTRL_DEPTH_30_ALLOWED, N, "Returns whether the NVIDIA X driver supports depth 30 on the specified X screen or GPU." }, + { "NoScanout", NV_CTRL_NO_SCANOUT, N, "Returns whether the special \"NoScanout\" mode is enabled on the specified X screen or GPU." }, + { "PixmapCache", NV_CTRL_PIXMAP_CACHE, N, "Controls whether pixmaps are allocated in a cache." }, + { "PixmapCacheRoundSizeKB", NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB, N, "Controls the number of kilobytes to add to the pixmap cache when there is not enough room." }, + + /* OpenGL */ + { "SyncToVBlank", NV_CTRL_SYNC_TO_VBLANK, 0, "Enables sync to vertical blanking for OpenGL clients. This setting only takes effect on OpenGL clients started after it is set." }, + { "LogAniso", NV_CTRL_LOG_ANISO, 0, "Enables anisotropic filtering for OpenGL clients; on some NVIDIA hardware, this can only be enabled or disabled; on other hardware different levels of anisotropic filtering can be specified. This setting only takes effect on OpenGL clients started after it is set." }, + { "FSAA", NV_CTRL_FSAA_MODE, 0, "The full screen antialiasing setting for OpenGL clients. This setting only takes effect on OpenGL clients started after it is set." }, + { "TextureSharpen", NV_CTRL_TEXTURE_SHARPEN, 0, "Enables texture sharpening for OpenGL clients. This setting only takes effect on OpenGL clients started after it is set." }, + { "ForceGenericCpu", NV_CTRL_FORCE_GENERIC_CPU, N, "Inhibit the use of CPU-specific features such as MMX, SSE, or 3DNOW! for OpenGL clients; this option may result in performance loss, but may be useful in conjunction with software such as the Valgrind memory debugger. This setting only takes effect on OpenGL clients started after it is set." }, + { "GammaCorrectedAALines", NV_CTRL_OPENGL_AA_LINE_GAMMA, 0, "For OpenGL clients, allow gamma-corrected antialiased lines to consider variances in the color display capabilities of output devices when rendering smooth lines. Only available on recent Quadro GPUs. This setting only takes effect on OpenGL clients started after it is set." }, + + { "AllowFlipping", NV_CTRL_FLIPPING_ALLOWED, 0, "Defines the swap behavior of OpenGL. When 1, OpenGL will swap by flipping when possible; When 0, OpenGL will always swap by blitting." }, + { "FSAAAppControlled", NV_CTRL_FSAA_APPLICATION_CONTROLLED, 0, "When Application Control for FSAA is enabled, then what the application requests is used, and the FSAA attribute is ignored. If this is disabled, then any application setting is overridden with the FSAA attribute." }, + { "LogAnisoAppControlled", NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED, 0, "When Application Control for LogAniso is enabled, then what the application requests is used, and the LogAniso attribute is ignored. If this is disabled, then any application setting is overridden with the LogAniso attribute." }, + { "ForceStereoFlipping", NV_CTRL_FORCE_STEREO, 0, "When 1, OpenGL will force stereo flipping even when no stereo drawables are visible (if the device is configured to support it, see the \"Stereo\" X config option). When 0, fall back to the default behavior of only flipping when a stereo drawable is visible." }, + { "OpenGLImageSettings", NV_CTRL_IMAGE_SETTINGS, 0, "The image quality setting for OpenGL clients. This setting only takes effect on OpenGL clients started after it is set." }, + { "XineramaStereoFlipping", NV_CTRL_XINERAMA_STEREO, 0, "When 1, OpenGL will allow stereo flipping on multiple X screens configured with Xinerama. When 0, flipping is allowed only on one X screen at a time." }, + { "ShowSLIHUD", NV_CTRL_SHOW_SLI_HUD, 0, "If this is enabled (1), the driver will draw information about the current SLI mode into a \"heads-up display\" inside OpenGL windows accelerated with SLI. This setting only takes effect on OpenGL clients started after it is set." }, + { "FSAAAppEnhanced", NV_CTRL_FSAA_APPLICATION_ENHANCED, 0, "Controls how the FSAA attribute is applied when FSAAAppControlled is disabled. When FSAAAppEnhanced is disabled, OpenGL applications will be forced to use the FSAA mode specified by the FSAA attribute. When the FSAAAppEnhanced attribute is enabled, only those applications that have selected a multisample FBConfig will be made to use the FSAA mode specified." }, + { "GammaCorrectedAALinesValue", NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE, 0, "Returns the gamma value used by OpenGL when gamma-corrected antialiased lines are enabled." }, + { "StereoEyesExchange", NV_CTRL_STEREO_EYES_EXCHANGE, 0, "Swaps the left and right eyes of stereo images." }, + { "SLIMode", NV_CTRL_STRING_SLI_MODE, S|N, "Returns a string describing the current SLI mode, if any." }, + + /* GPU */ + { "BusType", NV_CTRL_BUS_TYPE, 0, "Returns the type of bus connecting the GPU driving the specified X screen to the computer." }, + { "VideoRam", NV_CTRL_VIDEO_RAM, 0, "Returns the total amount of memory available to the specified GPU (or the GPU driving the specified X screen). Note: if the GPU supports TurboCache(TM), the value reported may exceed the amount of video memory installed on the GPU. The value reported for integrated GPUs may likewise exceed the amount of dedicated system memory set aside by the system BIOS for use by the integrated GPU." }, + { "Irq", NV_CTRL_IRQ, 0, "Returns the interrupt request line used by the GPU driving the specified X screen." }, + { "GPUCoreTemp", NV_CTRL_GPU_CORE_TEMPERATURE, N, "Reports the current core temperature in Celsius of the GPU driving the X screen." }, + { "GPUAmbientTemp", NV_CTRL_AMBIENT_TEMPERATURE, N, "Reports the current temperature in Celsius of the immediate neighborhood of the GPU driving the X screen." }, + { "GPUOverclockingState", NV_CTRL_GPU_OVERCLOCKING_STATE, N, "The current overclocking state; the value of this attribute controls the availability of additional overclocking attributes. Note that this attribute is unavailable unless overclocking support has been enabled by the system administrator." }, + { "GPU2DClockFreqs", NV_CTRL_GPU_2D_CLOCK_FREQS, N|P, "The GPU and memory clock frequencies when operating in 2D mode. New clock frequencies are tested before being applied, and may be rejected. Note that if the target clocks are too aggressive, their testing may render the system unresponsive. Also note that while this attribute may always be queried, it cannot be set unless GPUOverclockingState is set to MANUAL. Since the target clocks may be rejected, the requester should read this attribute after the set to determine success or failure." }, + { "GPU3DClockFreqs", NV_CTRL_GPU_3D_CLOCK_FREQS, N|P, "The GPU and memory clock frequencies when operating in 3D mode. New clock frequencies are tested before being applied, and may be rejected. Note that if the target clocks are too aggressive, their testing may render the system unresponsive. Also note that while this attribute may always be queried, it cannot be set unless GPUOverclockingState is set to MANUAL. Since the target clocks may be rejected, the requester should read this attribute after the set to determine success or failure." }, + { "GPUDefault2DClockFreqs", NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS, N|P, "Returns the default memory and GPU core clocks when operating in 2D mode." }, + { "GPUDefault3DClockFreqs", NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS, N|P, "Returns the default memory and GPU core clocks when operating in 3D mode." }, + { "GPUCurrentClockFreqs", NV_CTRL_GPU_CURRENT_CLOCK_FREQS, N|P, "Returns the current GPU and memory clocks of the graphics device driving the X screen." }, + { "BusRate", NV_CTRL_BUS_RATE, 0, "If the GPU is on an AGP bus, then BusRate returns the configured AGP rate. If the GPU is on a PCI Express bus, then this attribute returns the width of the physical link." }, + { "PCIBus", NV_CTRL_PCI_BUS, N, "Returns the PCI bus number the GPU is using." }, + { "PCIDevice", NV_CTRL_PCI_DEVICE, N, "Returns the PCI device number the GPU is using." }, + { "PCIFunc", NV_CTRL_PCI_FUNCTION, N, "Returns the PCI function number the GPU is using." }, + { "GPUErrors", NV_CTRL_NUM_GPU_ERRORS_RECOVERED, N, "Returns the number of GPU errors occurred." }, + { "GPUPowerSource", NV_CTRL_GPU_POWER_SOURCE, N, "Reports the type of power source of the GPU." }, + { "GPUCurrentPerfMode", NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE, N, "Reports the current performance mode of the GPU driving the X screen. Running a 3D app, for example, will change this performance mode if Adaptive Clocking is enabled." }, + { "GPUCurrentPerfLevel", NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL, N, "Reports the current Performance level of the GPU driving the X screen. Each Performance level has associated NVClock and Mem Clock values." }, + { "GPUAdaptiveClockState", NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE, N, "Reports if Adaptive Clocking is Enabled on the GPU driving the X screen." }, + { "GPUPerfModes", NV_CTRL_STRING_PERFORMANCE_MODES, S|N, "Returns a string with all the performance modes defined for this GPU along with their associated NV Clock and Memory Clock values." }, + + /* Framelock */ + { "FrameLockAvailable", NV_CTRL_FRAMELOCK, N|F|G, "Returns whether the underlying GPU supports Frame Lock. All of the other frame lock attributes are only applicable if this attribute is enabled (Supported)." }, + { "FrameLockMaster", NV_CTRL_FRAMELOCK_MASTER, N|F|G|D, "Get/set which display device to use as the frame lock master for the entire sync group. Note that only one node in the sync group should be configured as the master." }, + { "FrameLockPolarity", NV_CTRL_FRAMELOCK_POLARITY, N|F|G, "Sync to the rising edge of the Frame Lock pulse, the falling edge of the Frame Lock pulse, or both." }, + { "FrameLockSyncDelay", NV_CTRL_FRAMELOCK_SYNC_DELAY, N|F|G, "Returns the delay between the frame lock pulse and the GPU sync. This is an 11 bit value which is multiplied by 7.81 to determine the sync delay in microseconds." }, + { "FrameLockSyncInterval", NV_CTRL_FRAMELOCK_SYNC_INTERVAL, N|F|G, "This defines the number of house sync pulses for each Frame Lock sync period. This only applies to the server, and only when recieving house sync. A value of zero means every house sync pulse is one frame period." }, + { "FrameLockPort0Status", NV_CTRL_FRAMELOCK_PORT0_STATUS, N|F|G, "Input/Output status of the RJ45 port0." }, + { "FrameLockPort1Status", NV_CTRL_FRAMELOCK_PORT1_STATUS, N|F|G, "Input/Output status of the RJ45 port1." }, + { "FrameLockHouseStatus", NV_CTRL_FRAMELOCK_HOUSE_STATUS, N|F|G, "Returns whether or not the house sync signal was detected on the BNC connector of the frame lock board." }, + { "FrameLockEnable", NV_CTRL_FRAMELOCK_SYNC, N|F|G, "Enable/disable the syncing of display devices to the frame lock pulse as specified by previous calls to FrameLockMaster and FrameLockSlaves." }, + { "FrameLockSyncReady", NV_CTRL_FRAMELOCK_SYNC_READY, N|F|G, "Reports whether a slave frame lock board is receiving sync, whether or not any display devices are using the signal." }, + { "FrameLockStereoSync", NV_CTRL_FRAMELOCK_STEREO_SYNC, N|F|G, "This indicates that the GPU stereo signal is in sync with the frame lock stereo signal." }, + { "FrameLockTestSignal", NV_CTRL_FRAMELOCK_TEST_SIGNAL, N|F|G, "To test the connections in the sync group, tell the master to enable a test signal, then query port[01] status and sync_ready on all slaves. When done, tell the master to disable the test signal. Test signal should only be manipulated while FrameLockEnable is enabled. The FrameLockTestSignal is also used to reset the Universal Frame Count (as returned by the glXQueryFrameCountNV() function in the GLX_NV_swap_group extension). Note: for best accuracy of the Universal Frame Count, it is recommended to toggle the FrameLockTestSignal on and off after enabling frame lock." }, + { "FrameLockEthDetected", NV_CTRL_FRAMELOCK_ETHERNET_DETECTED, N|F|G, "The frame lock boards are cabled together using regular cat5 cable, connecting to RJ45 ports on the backplane of the card. There is some concern that users may think these are Ethernet ports and connect them to a router/hub/etc. The hardware can detect this and will shut off to prevent damage (either to itself or to the router). FrameLockEthDetected may be called to find out if Ethernet is connected to one of the RJ45 ports. An appropriate error message should then be displayed." }, + { "FrameLockVideoMode", NV_CTRL_FRAMELOCK_VIDEO_MODE, N|F|G, "Get/set what video mode is used to interpret the house sync signal. This should only be set on the master." }, + { "FrameLockSyncRate", NV_CTRL_FRAMELOCK_SYNC_RATE, N|F|G, "Returns the refresh rate that the frame lock board is sending to the GPU, in mHz (Millihertz) (i.e. to get the refresh rate in Hz, divide the returned value by 1000.)" }, + { "FrameLockTiming", NV_CTRL_FRAMELOCK_TIMING, N|F|G, "This is 1 when the GPU is both receiving and locked to an input timing signal. Timing information may come from the following places: Another frame lock device that is set to master, the house sync signal, or the GPU's internal timing from a display device." }, + { "FramelockUseHouseSync", NV_CTRL_USE_HOUSE_SYNC, N|F|G, "When 1, the server (master) frame lock device will propagate the incoming house sync signal as the outgoing frame lock sync signal. If the frame lock device cannot detect a frame lock sync signal, it will default to using the internal timings from the GPU connected to the primary connector." }, + { "FrameLockSlaves", NV_CTRL_FRAMELOCK_SLAVES, N|F|G|D, "Get/set whether the display device(s) given should listen or ignore the master's sync signal." }, + { "FrameLockMasterable", NV_CTRL_FRAMELOCK_MASTERABLE, N|F|G, "Returns whether the display device(s) can be set as the master of the frame lock group. Returns 1 if the GPU driving the display device is connected to the \"primary\" connector on the frame lock board." }, + { "FrameLockSlaveable", NV_CTRL_FRAMELOCK_SLAVEABLE, N|F|G|D, "Returns whether the display device(s) can be set as slave(s) of the frame lock group." }, + { "FrameLockFPGARevision", NV_CTRL_FRAMELOCK_FPGA_REVISION, N|F|G, "Returns the FPGA revision of the Frame Lock device." }, + { "FrameLockSyncRate4", NV_CTRL_FRAMELOCK_SYNC_RATE_4, N|F|G, "Returns the refresh rate that the frame lock board is sending to the GPU in 1/10000 Hz (i.e. to get the refresh rate in Hz, divide the returned value by 10000.)" }, + + /* GVO */ + { "GvoSupported", NV_CTRL_GVO_SUPPORTED, I|N, "Returns whether this X screen supports GVO; if this screen does not support GVO output, then all other GVO attributes are unavailable." }, + { "GvoSyncMode", NV_CTRL_GVO_SYNC_MODE, I, "Selects the GVO sync mode; possible values are: FREE_RUNNING - GVO does not sync to any external signal. GENLOCK - the GVO output is genlocked to an incoming sync signal; genlocking locks at hsync. This requires that the output video format exactly match the incoming sync video format. FRAMELOCK - the GVO output is frame locked to an incoming sync signal; frame locking locks at vsync. This requires that the output video format have the same refresh rate as the incoming sync video format." }, + { "GvoSyncSource", NV_CTRL_GVO_SYNC_SOURCE, I, "If the GVO sync mode is set to either GENLOCK or FRAMELOCK, this controls which sync source is used as the incoming sync signal (either Composite or SDI). If the GVO sync mode is FREE_RUNNING, this attribute has no effect." }, + { "GvoOutputVideoFormat", NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT, I, "Specifies the output video format coming out of the GVO device." }, + { "GvoInputVideoFormat", NV_CTRL_GVO_INPUT_VIDEO_FORMAT, I|N, "Returns the input video format detected by the GVO device." }, + { "GvoDataFormat", NV_CTRL_GVO_DATA_FORMAT, I, "Configures how the data in the source (either the X screen or the GLX pbuffer) is interpreted and displayed by the GVO device." }, + { "GvoDisplayXScreen", NV_CTRL_GVO_DISPLAY_X_SCREEN, I|N, "Enable/disable GVO output of the X screen (in Clone mode)." }, + { "GvoCompositeSyncInputDetected", NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED, I|N, "Indicates whether Composite Sync input is detected." }, + { "GvoCompositeSyncInputDetectMode", NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE, I|N, "Get/set the Composite Sync input detect mode." }, + { "GvoSdiSyncInputDetected", NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED, I|N, "Indicates whether SDI Sync input is detected, and what type." }, + { "GvoVideoOutputs", NV_CTRL_GVO_VIDEO_OUTPUTS, I|N, "Indicates which GVO video output connectors are currently transmitting data." }, + { "GvoSyncDelayPixels", NV_CTRL_GVO_SYNC_DELAY_PIXELS, I, "Controls the skew between the input sync and the output sync in numbers of pixels from hsync; this is a 12-bit value. If the GVO Capabilities has the Advanced Sync Skew bit set, then setting this value will set a sync advance instead of a delay." }, + { "GvoSyncDelayLines", NV_CTRL_GVO_SYNC_DELAY_LINES, I, "Controls the skew between the input sync and the output sync in numbers of lines from vsync; this is a 12-bit value. If the GVO Capabilities has the Advanced Sync Skew bit set, then setting this value will set a sync advance instead of a delay." }, + { "GvoInputVideoFormatReacquire", NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE, I|N, "Forces input detection to reacquire the input format." }, + { "GvoGlxLocked", NV_CTRL_GVO_GLX_LOCKED, I|N, "Indicates that GVO configuration is locked by GLX; this occurs when the GLX_NV_video_out function calls glXGetVideoDeviceNV(). All GVO output resources are locked until either glXReleaseVideoDeviceNV() is called or the X Display used when calling glXGetVideoDeviceNV() is closed." }, + { "GvoXScreenPanX", NV_CTRL_GVO_X_SCREEN_PAN_X, I, "When GVO output of the X screen is enabled, the pan x/y attributes control which portion of the X screen is displayed by GVO. These attributes can be updated while GVO output is enabled, or before enabling GVO output. The pan values will be clamped so that GVO output is not panned beyond the end of the X screen." }, + { "GvoXScreenPanY", NV_CTRL_GVO_X_SCREEN_PAN_Y, I, "When GVO output of the X screen is enabled, the pan x/y attributes control which portion of the X screen is displayed by GVO. These attributes can be updated while GVO output is enabled, or before enabling GVO output. The pan values will be clamped so that GVO output is not panned beyond the end of the X screen." }, + { "GvoOverrideHwCsc", NV_CTRL_GVO_OVERRIDE_HW_CSC, I, "Override the SDI hardware's Color Space Conversion with the values controlled through XNVCTRLSetGvoColorConversion() and XNVCTRLGetGvoColorConversion()." }, + { "GvoCapabilities", NV_CTRL_GVO_CAPABILITIES, I|N, "Returns a description of the GVO capabilities that differ between NVIDIA SDI products. This value is a bitmask where each bit indicates whether that capability is available." }, + { "GvoCompositeTermination", NV_CTRL_GVO_COMPOSITE_TERMINATION, I, "Enable or disable 75 ohm termination of the SDI composite input signal." }, + { "GvoFlipQueueSize", NV_CTRL_GVO_FLIP_QUEUE_SIZE, I, "Sets/Returns the GVO flip queue size. This value is used by the GLX_NV_video_out extension to determine the size of the internal flip queue when pbuffers are sent to the video device (via glXSendPbufferToVideoNV()). This attribute is applied to GLX when glXGetVideoDeviceNV() is called by the application." }, + { "GvoLockOwner", NV_CTRL_GVO_LOCK_OWNER, I|N, "Indicates that the GVO device is available or in use (by GLX, Clone Mode, TwinView etc.)" }, + { "GvoOutputVideoLocked", NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED, I|N, "Returns whether or not the GVO output video is locked to the GPU output signal." }, + { "GvoSyncLockStatus", NV_CTRL_GVO_SYNC_LOCK_STATUS, I|N, "Returns whether or not the GVO device is locked to the input reference signal." }, + { "GvoANCTimeCodeGeneration", NV_CTRL_GVO_ANC_TIME_CODE_GENERATION, I, "Controls whether the GVO device generates time codes in the ANC region of the SDI video output stream." }, + { "GvoComposite", NV_CTRL_GVO_COMPOSITE, I, "Enables/Disables SDI compositing. This attribute is only available when an SDI input source is detected and is in genlock mode." }, + { "GvoCompositeAlphaKey", NV_CTRL_GVO_COMPOSITE_ALPHA_KEY, I, "When SDI compositing is enabled, this enables/disables alpha blending." }, + { "GvoCompositeNumKeyRanges", NV_CTRL_GVO_COMPOSITE_NUM_KEY_RANGES, I|N, "Returns the number of ranges available for each channel (Y/Luma, Cr, and Cb) that are used SDI compositing through color keying." }, + { "GvoFirmwareVersion", NV_CTRL_STRING_GVO_FIRMWARE_VERSION, I|S|N, "Indicates the version of the firmware on the GVO device." }, + { "GvoSyncToDisplay", NV_CTRL_GVO_SYNC_TO_DISPLAY, I|N, "Controls synchronization of the non-SDI display to the SDI display when both are active." }, + { "IsGvoDisplay", NV_CTRL_IS_GVO_DISPLAY, N|D, "Returns whether or not the given display device is driven by the GVO device." }, + + /* Display */ + { "Brightness", BRIGHTNESS_VALUE|ALL_CHANNELS, N|C|G, "Controls the overall brightness of the display." }, + { "RedBrightness", BRIGHTNESS_VALUE|RED_CHANNEL, C|G, "Controls the brightness of the color red in the display." }, + { "GreenBrightness", BRIGHTNESS_VALUE|GREEN_CHANNEL, C|G, "Controls the brightness of the color green in the display." }, + { "BlueBrightness", BRIGHTNESS_VALUE|BLUE_CHANNEL, C|G, "Controls the brightness of the color blue in the display." }, + { "Contrast", CONTRAST_VALUE|ALL_CHANNELS, N|C|G, "Controls the overall contrast of the display." }, + { "RedContrast", CONTRAST_VALUE|RED_CHANNEL, C|G, "Controls the contrast of the color red in the display." }, + { "GreenContrast", CONTRAST_VALUE|GREEN_CHANNEL, C|G, "Controls the contrast of the color green in the display." }, + { "BlueContrast", CONTRAST_VALUE|BLUE_CHANNEL, C|G, "Controls the contrast of the color blue in the display." }, + { "Gamma", GAMMA_VALUE|ALL_CHANNELS, N|C|G, "Controls the overall gamma of the display." }, + { "RedGamma", GAMMA_VALUE|RED_CHANNEL, C|G, "Controls the gamma of the color red in the display." }, + { "GreenGamma", GAMMA_VALUE|GREEN_CHANNEL, C|G, "Controls the gamma of the color green in the display." }, + { "BlueGamma", GAMMA_VALUE|BLUE_CHANNEL, C|G, "Controls the gamma of the color blue in the display." }, + { "FlatpanelDithering", NV_CTRL_FLATPANEL_DITHERING, 0, "This is the current state of flat panel dithering. (This attribute has been deprecated.)" }, + { "DigitalVibrance", NV_CTRL_DIGITAL_VIBRANCE, 0, "Sets the digital vibrance level of the display device." }, + { "ImageSharpening", NV_CTRL_IMAGE_SHARPENING, 0, "Adjusts the sharpness of the display's image quality by amplifying high frequency content. Valid values will normally be in the range [0,32). Only available on GeForceFX or newer." }, + { "FrontendResolution", NV_CTRL_FRONTEND_RESOLUTION, N|P, "Returns the dimensions of the frontend (current) resolution as determined by the NVIDIA X Driver. This attribute is a packed integer; the width is packed in the upper 16 bits and the height is packed in the lower 16-bits." }, + { "BackendResolution", NV_CTRL_BACKEND_RESOLUTION, N|P, "Returns the dimensions of the backend resolution as determined by the NVIDIA X Driver. The backend resolution is the resolution (supported by the display device) the GPU is set to scale to. If this resolution matches the frontend resolution, GPU scaling will not be needed/used. This attribute is a packed integer; the width is packed in the upper 16-bits and the height is packed in the lower 16-bits." }, + { "FlatpanelNativeResolution", NV_CTRL_FLATPANEL_NATIVE_RESOLUTION, N|P, "Returns the dimensions of the native resolution of the flat panel as determined by the NVIDIA X Driver. The native resolution is the resolution at which a flat panel must display any image. All other resolutions must be scaled to this resolution through GPU scaling or the DFP's native scaling capabilities in order to be displayed. This attribute is only valid for flat panel (DFP) display devices. This attribute is a packed integer; the width is packed in the upper 16-bits and the height is packed in the lower 16-bits." }, + { "FlatpanelBestFitResolution", NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION, N|P, "Returns the dimensions of the resolution, selected by the X driver, from the DFP's EDID that most closely matches the frontend resolution of the current mode. The best fit resolution is selected on a per-mode basis. This attribute is only valid for flat panel (DFP) display devices. This attribute is a packed integer; the width is packed in the upper 16-bits and the height is packed in the lower 16-bits." }, + { "DFPScalingActive", NV_CTRL_DFP_SCALING_ACTIVE, N, "Returns the current state of DFP scaling. DFP scaling is mode-specific (meaning it may vary depending on which mode is currently set). DFP scaling is active if the GPU is set to scale to the best fit resolution (GPUScaling is set to use FlatpanelBestFitResolution) and the best fit and native resolutions are different." }, + { "GPUScaling", NV_CTRL_GPU_SCALING, P, "Controls what the GPU scales to and how. This attribute is a packed integer; the scaling target (native/best fit) is packed in the upper 16-bits and the scaling method is packed in the lower 16-bits." }, + { "GPUScalingActive", NV_CTRL_GPU_SCALING_ACTIVE, N, "Returns the current state of GPU scaling. GPU scaling is mode-specific (meaning it may vary depending on which mode is currently set). GPU scaling is active if the frontend timing (current resolution) is different than the target resolution. The target resolution is either the native resolution of the flat panel or the best fit resolution supported by the flat panel. What (and how) the GPU should scale to is controlled through the GPUScaling attribute." }, + { "RefreshRate", NV_CTRL_REFRESH_RATE, N|H, "Returns the refresh rate of the specified display device in cHz (Centihertz) (i.e. to get the refresh rate in Hz, divide the returned value by 100.)" }, + { "RefreshRate3", NV_CTRL_REFRESH_RATE_3, N|K, "Returns the refresh rate of the specified display device in mHz (Millihertz) (i.e. to get the refresh rate in Hz, divide the returned value by 1000.)" }, + + /* TV */ + { "TVOverScan", NV_CTRL_TV_OVERSCAN, 0, "Adjusts the amount of overscan on the specified display device." }, + { "TVFlickerFilter", NV_CTRL_TV_FLICKER_FILTER, 0, "Adjusts the amount of flicker filter on the specified display device." }, + { "TVBrightness", NV_CTRL_TV_BRIGHTNESS, 0, "Adjusts the amount of brightness on the specified display device." }, + { "TVHue", NV_CTRL_TV_HUE, 0, "Adjusts the amount of hue on the specified display device." }, + { "TVContrast", NV_CTRL_TV_CONTRAST, 0, "Adjusts the amount of contrast on the specified display device." }, + { "TVSaturation", NV_CTRL_TV_SATURATION, 0, "Adjusts the amount of saturation on the specified display device." }, + + /* X Video */ + { "XVideoOverlaySaturation", NV_CTRL_ATTR_XV_OVERLAY_SATURATION, V, "Controls the amount of saturation in the X video overlay." }, + { "XVideoOverlayContrast", NV_CTRL_ATTR_XV_OVERLAY_CONTRAST, V, "Controls the amount of contrast in the X video overlay." }, + { "XVideoOverlayBrightness", NV_CTRL_ATTR_XV_OVERLAY_BRIGHTNESS, V, "Controls the amount of brightness in the X video overlay." }, + { "XVideoOverlayHue", NV_CTRL_ATTR_XV_OVERLAY_HUE, V, "Controls the amount of hue in the X video overlay." }, + { "XVideoTextureBrightness", NV_CTRL_ATTR_XV_TEXTURE_BRIGHTNESS, V, "Controls the amount of brightness in the X video texture adaptor." }, + { "XVideoTextureContrast", NV_CTRL_ATTR_XV_TEXTURE_CONTRAST, V, "Controls the amount of contrast in the X video texture adaptor." }, + { "XVideoTextureHue", NV_CTRL_ATTR_XV_TEXTURE_HUE, V, "Controls the amount of hue in the X video texture adaptor." }, + { "XVideoTextureSaturation", NV_CTRL_ATTR_XV_TEXTURE_SATURATION, V, "Controls the amount of saturation in the X video texture adaptor." }, + + { "XVideoTextureSyncToVBlank", NV_CTRL_ATTR_XV_TEXTURE_SYNC_TO_VBLANK, V, "Enables sync to vertical blanking for X video texture adaptor." }, + { "XVideoBlitterSyncToVBlank", NV_CTRL_ATTR_XV_BLITTER_SYNC_TO_VBLANK, V, "Enables sync to vertical blanking for X video blitter adaptor." }, + { "XVideoSyncToDisplay", NV_CTRL_XV_SYNC_TO_DISPLAY, D|Z, "Controls which display device is synced to by the texture and blitter adaptors when they are set to synchronize to the vertical blanking." }, + + { NULL, 0, 0, NULL } }; #undef F @@ -264,7 +283,7 @@ AttributeTableEntry attributeTable[] = { * about. */ -#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GVO_SYNC_TO_DISPLAY +#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_IS_GVO_DISPLAY #warning "Have you forgotten to add a new integer attribute to attributeTable?" #endif @@ -1336,6 +1355,26 @@ static int count_number_of_chars(char *o, char d) /* + * count_number_of_bits() - return the number of bits set + * in the int. + */ + +int count_number_of_bits(unsigned int mask) +{ + int count = 0; + + while (mask) { + count++; + mask &= (mask-1); + } + + return count; + +} /* count_number_of_bits() */ + + + +/* * nv_strndup() - this function takes a pointer to a string and a * length n, mallocs a new string of n+1, copies the first n chars * from the original string into the new, and null terminates the new diff --git a/src/parse.h b/src/parse.h index 1e0d510..326531e 100644 --- a/src/parse.h +++ b/src/parse.h @@ -46,7 +46,7 @@ #define NV_PARSER_TYPE_FRAMELOCK (1<<16) #define NV_PARSER_TYPE_COLOR_ATTRIBUTE (1<<17) #define NV_PARSER_TYPE_NO_CONFIG_WRITE (1<<18) -#define NV_PARSER_TYPE_GUI_ATTRIUBUTE (1<<19) +#define NV_PARSER_TYPE_GUI_ATTRIBUTE (1<<19) #define NV_PARSER_TYPE_XVIDEO_ATTRIBUTE (1<<20) #define NV_PARSER_TYPE_PACKED_ATTRIBUTE (1<<21) #define NV_PARSER_TYPE_VALUE_IS_DISPLAY (1<<22) @@ -106,6 +106,7 @@ typedef struct _AttributeTableEntry { char *name; int attr; uint32 flags; + char *desc; } AttributeTableEntry; @@ -303,7 +304,7 @@ const char *parse_read_integer_pair(const char *str, const char *parse_read_name(const char *str, char **name, char term); const char *parse_read_display_name(const char *str, unsigned int *mask); int parse_read_float_range(char *str, float *min, float *max); - +int count_number_of_bits(unsigned int mask); /* Token parsing functions */ diff --git a/src/query-assign.c b/src/query-assign.c index f1d5d42..ad6d36a 100644 --- a/src/query-assign.c +++ b/src/query-assign.c @@ -938,7 +938,13 @@ static int query_all(const char *display_name) for (bit = 0; bit < 24; bit++) { mask = 1 << bit; - if ((t->d & mask) == 0x0) continue; + /* + * if this bit is not present in the screens's enabled + * display device mask (and the X screen has enabled + * display devices), skip to the next bit + */ + + if (((t->d & mask) == 0x0) && (t->d)) continue; if (a->flags & NV_PARSER_TYPE_STRING_ATTRIBUTE) { char *tmp_str = NULL; |