2
* nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
5
* Copyright (C) 2004 NVIDIA Corporation.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of Version 2 of the GNU General Public
9
* License as published by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See Version 2
14
* of the GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the:
19
* Free Software Foundation, Inc.
20
* 59 Temple Place - Suite 330
21
* Boston, MA 02111-1307, USA
26
#include "NvCtrlAttributes.h"
30
#include "big_banner_penguin.h"
31
#include "big_banner_bsd.h"
35
#include "ctkdevice.h"
38
static void add_table_row(GtkWidget *table,
40
const gint value_alignment,
44
#define N_GDK_PIXBUFS 45
47
GType ctk_device_get_type(
51
static GType ctk_device_type = 0;
53
if (!ctk_device_type) {
54
static const GTypeInfo info_ctk_device = {
55
sizeof (CtkDeviceClass),
57
NULL, /* base_finalize */
58
NULL, /* class_init */
59
NULL, /* class_finalize */
60
NULL, /* class_data */
63
NULL, /* instance_init */
67
g_type_register_static(GTK_TYPE_VBOX,
68
"CtkDevice", &info_ctk_device, 0);
71
return ctk_device_type;
76
GtkWidget* ctk_device_new(
77
NvCtrlAttributeHandle *handle
81
CtkDevice *ctk_device;
87
GtkWidget *hseparator;
91
guint8 *image_buffer = NULL;
92
const nv_image_t *img;
94
char *product_name, *bus_type, *vbios_version, *video_ram, *irq;
95
char *os, *arch, *version;
100
gchar *__unknown = "Unknown";
103
* get the data that we will display below
105
* XXX should be able to update any of this if an attribute
109
/* NV_CTRL_STRING_PRODUCT_NAME */
111
ret = NvCtrlGetStringAttribute(handle, NV_CTRL_STRING_PRODUCT_NAME,
113
if (ret != NvCtrlSuccess) product_name = "Unknown GPU";
115
/* NV_CTRL_BUS_TYPE */
117
ret = NvCtrlGetAttribute(handle, NV_CTRL_BUS_TYPE, &tmp);
119
if (ret == NvCtrlSuccess) {
120
if (tmp == NV_CTRL_BUS_TYPE_AGP) bus_type = "AGP";
121
if (tmp == NV_CTRL_BUS_TYPE_PCI) bus_type = "PCI";
122
if (tmp == NV_CTRL_BUS_TYPE_PCI_EXPRESS) bus_type = "PCI Express";
124
if (!bus_type) bus_type = __unknown;
126
/* NV_CTRL_STRING_VBIOS_VERSION */
128
ret = NvCtrlGetStringAttribute(handle, NV_CTRL_STRING_VBIOS_VERSION,
130
if (ret != NvCtrlSuccess) vbios_version = __unknown;
132
/* NV_CTRL_VIDEO_RAM */
134
ret = NvCtrlGetAttribute(handle, NV_CTRL_VIDEO_RAM, &tmp);
135
if (ret != NvCtrlSuccess) tmp = 0;
136
video_ram = g_strdup_printf("%d MB", tmp >> 10);
140
ret = NvCtrlGetAttribute(handle, NV_CTRL_IRQ, &tmp);
141
if (ret != NvCtrlSuccess) tmp = 0;
142
irq = g_strdup_printf("%d", tmp);
144
/* NV_CTRL_OPERATING_SYSTEM */
146
os_val = NV_CTRL_OPERATING_SYSTEM_LINUX;
147
ret = NvCtrlGetAttribute(handle, NV_CTRL_OPERATING_SYSTEM, &os_val);
149
if (ret == NvCtrlSuccess) {
150
if (os_val == NV_CTRL_OPERATING_SYSTEM_LINUX) os = "Linux";
151
if (os_val == NV_CTRL_OPERATING_SYSTEM_FREEBSD) os = "FreeBSD";
153
if (!os) os = __unknown;
155
/* NV_CTRL_ARCHITECTURE */
157
ret = NvCtrlGetAttribute(handle, NV_CTRL_ARCHITECTURE, &tmp);
159
if (ret == NvCtrlSuccess) {
160
if (tmp == NV_CTRL_ARCHITECTURE_X86) arch = "x86";
161
if (tmp == NV_CTRL_ARCHITECTURE_X86_64) arch = "amd64";
162
if (tmp == NV_CTRL_ARCHITECTURE_IA64) arch = "ia64";
164
if (!arch) arch = __unknown;
166
snprintf(scratch, 64, "%s-%s", os, arch);
168
/* NV_CTRL_STRING_NVIDIA_DRIVER_VERSION */
170
ret = NvCtrlGetStringAttribute(handle,
171
NV_CTRL_STRING_NVIDIA_DRIVER_VERSION,
173
if (ret != NvCtrlSuccess) version = __unknown;
177
/* now, create the object */
179
object = g_object_new(CTK_TYPE_DEVICE, NULL);
180
ctk_device = CTK_DEVICE(object);
182
/* cache the attribute handle */
184
ctk_device->handle = handle;
186
/* set container properties of the object */
188
gtk_box_set_spacing(GTK_BOX(ctk_device), 10);
192
alignment = gtk_alignment_new(0, 0, 0, 0);
193
gtk_box_pack_start(GTK_BOX(ctk_device), alignment, FALSE, FALSE, 0);
195
frame = gtk_frame_new(NULL);
196
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
197
gtk_container_add(GTK_CONTAINER(alignment), frame);
199
if (os_val == NV_CTRL_OPERATING_SYSTEM_LINUX) {
200
img = &big_banner_penguin_image;
202
img = &big_banner_bsd_image;
205
image_buffer = decompress_image_data(img);
207
image = gtk_image_new_from_pixbuf
208
(gdk_pixbuf_new_from_data(image_buffer, GDK_COLORSPACE_RGB,
209
FALSE, 8, img->width, img->height,
210
img->width * img->bytes_per_pixel,
211
free_decompressed_image, NULL));
213
gtk_container_add(GTK_CONTAINER(frame), image);
216
* Device information: TOP->MIDDLE - LEFT->RIGHT
218
* This displays basic display adatper information, including
219
* product name, bios version, bus type, video ram and interrupt
223
vbox = gtk_vbox_new(FALSE, 5);
224
gtk_box_pack_start(GTK_BOX(ctk_device), vbox, TRUE, TRUE, 0);
226
hbox = gtk_hbox_new(FALSE, 0);
227
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
229
label = gtk_label_new("Graphics Card Information");
230
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
232
hseparator = gtk_hseparator_new();
233
gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5);
235
table = gtk_table_new(7, 2, FALSE);
236
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
238
gtk_table_set_row_spacings(GTK_TABLE(table), 3);
239
gtk_table_set_col_spacings(GTK_TABLE(table), 15);
241
gtk_container_set_border_width(GTK_CONTAINER(table), 5);
244
add_table_row(table, 0, 0, "Graphics Processor:", product_name);
245
add_table_row(table, 1, 0, "Bus Type:", bus_type);
246
add_table_row(table, 2, 0, "VBIOS Version:", vbios_version);
247
add_table_row(table, 3, 0, "Video Memory:", video_ram);
248
add_table_row(table, 4, 0, "IRQ:", irq);
249
add_table_row(table, 5, 0, "Operating System:", scratch);
250
add_table_row(table, 6, 0, "NVIDIA Driver Version:", version);
254
gtk_widget_show_all(GTK_WIDGET(object));
256
return GTK_WIDGET(object);
260
static void add_table_row(GtkWidget *table,
262
const gint value_alignment,
268
label = gtk_label_new(name);
269
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
270
gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1,
271
GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
273
label = gtk_label_new(value);
274
gtk_misc_set_alignment(GTK_MISC(label), value_alignment, 0.5);
275
gtk_table_attach(GTK_TABLE(table), label, 1, 2, row, row + 1,
276
GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
280
GtkTextBuffer *ctk_device_create_help(GtkTextTagTable *table,
281
const gchar *screen_name)
286
b = gtk_text_buffer_new(table);
288
gtk_text_buffer_get_iter_at_offset(b, &i, 0);
290
ctk_help_title(b, &i, "Graphics Card Information Help");
292
ctk_help_para(b, &i, "This page in the NVIDIA "
293
"X Server Control Panel describes basic "
294
"information about the Graphics Processing Unit "
295
"(GPU) on which the X screen '%s' is running.",
298
ctk_help_heading(b, &i, "Graphics Processor");
299
ctk_help_para(b, &i, "This is the product name of the GPU.");
301
ctk_help_heading(b, &i, "Bus Type");
302
ctk_help_para(b, &i, "This is the bus type which is "
303
"used to connect the NVIDIA GPU to the rest of "
304
"your computer; possible values are AGP, PCI, or "
307
ctk_help_heading(b, &i, "VBIOS Version");
308
ctk_help_para(b, &i, "This is the Video BIOS version.");
311
ctk_help_heading(b, &i, "Video Memory");
312
ctk_help_para(b, &i, "This is the amount of video memory on your "
315
ctk_help_heading(b, &i, "IRQ");
316
ctk_help_para(b, &i, "This is the interrupt request line assigned to "
319
ctk_help_heading(b, &i, "Operating System");
320
ctk_help_para(b, &i, "This is the operating system on which the NVIDIA "
321
"X driver is running; possible values are "
322
"'Linux' and 'FreeBSD'. This also specifies the platform "
323
"on which the operating system is running, such as x86, "
326
ctk_help_heading(b, &i, "NVIDIA Driver Version");
327
ctk_help_para(b, &i, "This is the version of the NVIDIA Accelerated "
328
"Graphics Driver currently in use.");