diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2009-07-28 15:27:53 -0700 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2009-07-28 15:27:53 -0700 |
commit | a014af5716bb40c6c2181c74db991000a8340975 (patch) | |
tree | 9a9ed4ba510315eff52c3e9ff5a5488f47d95cb6 | |
parent | 37c32510db16c92d802991f0137ded02b8cc8058 (diff) |
-rw-r--r-- | samples/nv-control-framelock.c | 27 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkgpu.c | 89 | ||||
-rw-r--r-- | src/libXNVCtrl/NVCtrl.h | 10 | ||||
-rw-r--r-- | src/parse.c | 2 | ||||
-rw-r--r-- | src/query-assign.c | 4 |
5 files changed, 71 insertions, 61 deletions
diff --git a/samples/nv-control-framelock.c b/samples/nv-control-framelock.c index 813b922..d92b6c8 100644 --- a/samples/nv-control-framelock.c +++ b/samples/nv-control-framelock.c @@ -166,7 +166,7 @@ static void do_query(Display *dpy) if (!ret) { printf("Failed to query enabled displays.\n"); } else { - printf("0x%08u\n", mask); + printf("0x%08x\n", mask); } /* Query GPU server (master) */ @@ -181,7 +181,7 @@ static void do_query(Display *dpy) if (!ret) { printf("Failed to query server mask.\n"); } else { - printf("0x%08u\n", mask); + printf("0x%08x\n", mask); } /* Query GPU clients (slaves) */ @@ -196,7 +196,7 @@ static void do_query(Display *dpy) if (!ret) { printf("Failed to query clients mask.\n"); } else { - printf("0x%08u\n", mask); + printf("0x%08x\n", mask); } } /* Done disabling GPUs */ @@ -313,7 +313,9 @@ static void do_enable(Display *dpy) continue; } - /* Query if this GPU can be set as master */ + /* Query if any of the enabled displays can be set as a + * master on this GPU. + */ ret = XNVCTRLQueryTargetAttribute(dpy, NV_CTRL_TARGET_TYPE_GPU, @@ -328,7 +330,7 @@ static void do_enable(Display *dpy) /* Clear the master setting if any */ - if (masterable == NV_CTRL_FRAMELOCK_MASTERABLE_TRUE) { + if (masterable) { XNVCTRLSetTargetAttribute(dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, // target_id @@ -350,13 +352,12 @@ static void do_enable(Display *dpy) /* Pick the first available/capable display device as master */ - if (pick_server && - masterable == NV_CTRL_FRAMELOCK_MASTERABLE_TRUE) { + if (pick_server && masterable) { /* Just pick the first enabled display */ unsigned int master = (1<<31); - while (master && !(master & mask)) { + while (master && !(master & masterable)) { master >>= 1; } @@ -381,7 +382,7 @@ static void do_enable(Display *dpy) NV_CTRL_FRAMELOCK_MASTER, master); - printf(" - Set Server Display : 0x%08u\n", master); + printf(" - Set Server Display : 0x%08x\n", master); pick_server = 0; server_set = 1; } @@ -396,7 +397,7 @@ static void do_enable(Display *dpy) 0, // display_mask NV_CTRL_FRAMELOCK_SLAVES, mask); - printf(" - Set Client Display(s) : 0x%08u\n", mask); + printf(" - Set Client Display(s) : 0x%08x\n", mask); } /* Enable frame lock */ @@ -552,6 +553,12 @@ int main(int argc, char *argv[]) printf("Using NV-CONTROL extension %d.%d on %s\n\n", major, minor, XDisplayName(NULL)); + + if ((major < 1) || (major == 1 && minor < 9)) { + printf("The NV-CONTROL X extension is too old. Version 1.9 or above " + " is required for configuring Frame Lock via target types.\n"); + return 1; + } /* Do what the user wants */ diff --git a/src/gtk+-2.x/ctkgpu.c b/src/gtk+-2.x/ctkgpu.c index d3ad614..e90c42f 100644 --- a/src/gtk+-2.x/ctkgpu.c +++ b/src/gtk+-2.x/ctkgpu.c @@ -154,6 +154,7 @@ GtkWidget* ctk_gpu_new( gchar *screens; gchar *displays; + gchar *tmp_str; unsigned int display_devices; int xinerama_enabled; @@ -269,52 +270,58 @@ GtkWidget* ctk_gpu_new( irq = g_strdup_printf("%d", tmp); } - /* List of X Screens using GPU */ - - if (xinerama_enabled) { - - /* In Xinerama, there is only one logical X screen */ - - screens = g_strdup("Screen 0 (Xinerama)"); - - } else { - gchar *tmp_str; - screens = NULL; - - ret = NvCtrlGetBinaryAttribute(handle, - 0, - NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU, - (unsigned char **)(&pData), - &len); - if (ret == NvCtrlSuccess) { - for (i = 1; i <= pData[0]; i++) { - - if (screens) { - tmp_str = g_strdup_printf("%s,\nScreen %d", - screens, pData[i]); - } else { - tmp_str = g_strdup_printf("Screen %d", pData[i]); - } - g_free(screens); - screens = tmp_str; - } - if (!screens) { - screens = g_strdup("None"); - - } else if (pData[0] > 0) { - - ret = NvCtrlGetAttribute(t[pData[1]].h, - NV_CTRL_SHOW_SLI_HUD, - &tmp); - - if (ret == NvCtrlSuccess) { - tmp_str = g_strdup_printf("%s (SLI)", screens); + /* List of X Screens using the GPU */ + + screens = NULL; + ret = NvCtrlGetBinaryAttribute(handle, + 0, + NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU, + (unsigned char **)(&pData), + &len); + if (ret == NvCtrlSuccess) { + if (pData[0] == 0) { + screens = g_strdup("None"); + } else { + NvCtrlAttributeHandle *screen_handle; + + if (xinerama_enabled) { + screens = g_strdup("Screen 0 (Xinerama)"); + /* XXX Use the only screen handle we have. + * This is currently OK since we only + * query xinerama attributes with this + * handle below. If we needed to query + * a screen-specific attribute below, + * then we would need to get a handle + * for the correct screen instead. + */ + screen_handle = t[0].h; + } else { + for (i = 1; i <= pData[0]; i++) { + if (screens) { + tmp_str = g_strdup_printf("%s,\nScreen %d", + screens, pData[i]); + } else { + tmp_str = g_strdup_printf("Screen %d", pData[i]); + } g_free(screens); screens = tmp_str; } + screen_handle = t[pData[1]].h; + } + + ret = NvCtrlGetAttribute(screen_handle, + NV_CTRL_SHOW_SLI_HUD, + &tmp); + if (ret == NvCtrlSuccess) { + tmp_str = g_strdup_printf("%s (SLI)", screens); + g_free(screens); + screens = tmp_str; } - XFree(pData); } + XFree(pData); + } + if (!screens) { + screens = g_strdup("Unknown"); } /* List of Display Device connected on GPU */ diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h index 32798e6..69b470d 100644 --- a/src/libXNVCtrl/NVCtrl.h +++ b/src/libXNVCtrl/NVCtrl.h @@ -1591,10 +1591,9 @@ #define NV_CTRL_FRAMELOCK_SLAVES 232 /* RW-G */ /* - * NV_CTRL_FRAMELOCK_MASTERABLE - Can this Display Device be set - * as the master of the frame lock group. Returns MASTERABLE_TRUE if - * the GPU driving the display device is connected to the "primary" - * connector on the frame lock board. + * NV_CTRL_FRAMELOCK_MASTERABLE - Can any of the given display devices + * be set as master of the frame lock group. Returns a bitmask of the + * corresponding display devices that can be set as master. * * This attribute can only be queried through XNVCTRLQueryTargetAttribute() * using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be @@ -1602,9 +1601,6 @@ */ #define NV_CTRL_FRAMELOCK_MASTERABLE 233 /* R-DG */ -#define NV_CTRL_FRAMELOCK_MASTERABLE_FALSE 0 -#define NV_CTRL_FRAMELOCK_MASTERABLE_TRUE 1 - /* * NV_CTRL_PROBE_DISPLAYS - re-probes the hardware to detect what diff --git a/src/parse.c b/src/parse.c index 612a467..e15edb9 100644 --- a/src/parse.c +++ b/src/parse.c @@ -175,7 +175,7 @@ AttributeTableEntry attributeTable[] = { { "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." }, + { "FrameLockMasterable", NV_CTRL_FRAMELOCK_MASTERABLE, N|F|G|D, "Returns whether the display device(s) can be set as the master of the frame lock group. Returns a bitmask indicating which of the given display devices can be set as a frame lock master." }, { "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.)" }, diff --git a/src/query-assign.c b/src/query-assign.c index 87a8878..3a6555f 100644 --- a/src/query-assign.c +++ b/src/query-assign.c @@ -731,8 +731,8 @@ static void print_valid_values(char *name, int attr, uint32 flags, } if (flags & NV_PARSER_TYPE_PACKED_ATTRIBUTE) { - nv_msg(INDENT, "Valid values for '%s' are: [%s], [%s].", name, str, - str2); + nv_msg(INDENT, "Valid values for '%s' are: [%s], [%s].", name, str2, + str); } else { nv_msg(INDENT, "Valid values for '%s' are: %s.", name, str); } |