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
* parse.h - prototypes and definitions for the parser.
34
* Flag values used in the flags field of the ParsedAttribute struct.
37
#define NV_PARSER_HAS_X_DISPLAY (1<<0)
38
#define NV_PARSER_HAS_X_SCREEN (1<<2)
39
#define NV_PARSER_HAS_DISPLAY_DEVICE (1<<3)
40
#define NV_PARSER_HAS_VAL (1<<4)
43
* Flag values used in the flags field of the AttributeTableEntry struct.
46
#define NV_PARSER_TYPE_FRAMELOCK (1<<16)
47
#define NV_PARSER_TYPE_COLOR_ATTRIBUTE (1<<17)
48
#define NV_PARSER_TYPE_NO_CONFIG_WRITE (1<<18)
49
#define NV_PARSER_TYPE_GUI_ATTRIUBUTE (1<<19)
50
#define NV_PARSER_TYPE_XVIDEO_ATTRIBUTE (1<<20)
52
#define NV_PARSER_ASSIGNMENT 0
53
#define NV_PARSER_QUERY 1
55
#define NV_PARSER_MAX_NAME_LEN 256
57
#define DISPLAY_NAME_SEPARATOR '/'
61
* error codes returned by nv_parse_attribute_string().
64
#define NV_PARSER_STATUS_SUCCESS 0
65
#define NV_PARSER_STATUS_BAD_ARGUMENT 1
66
#define NV_PARSER_STATUS_EMPTY_STRING 2
67
#define NV_PARSER_STATUS_ATTR_NAME_TOO_LONG 3
68
#define NV_PARSER_STATUS_ATTR_NAME_MISSING 4
69
#define NV_PARSER_STATUS_BAD_DISPLAY_DEVICE 5
70
#define NV_PARSER_STATUS_MISSING_EQUAL_SIGN 6
71
#define NV_PARSER_STATUS_NO_VALUE 7
72
#define NV_PARSER_STATUS_TRAILING_GARBAGE 8
73
#define NV_PARSER_STATUS_UNKNOWN_ATTR_NAME 9
79
typedef unsigned int uint32;
83
* The valid attribute names, and their corresponding protocol
84
* attribute identifiers are stored in an array of
85
* AttributeTableEntries.
88
typedef struct _AttributeTableEntry {
92
} AttributeTableEntry;
96
* ParsedAttribute - struct filled out by
97
* nv_ParseAttributeString().
100
typedef struct _ParsedAttribute {
106
float fval; /* XXX put in a union with val? */
107
uint32 display_device_mask;
109
struct _ParsedAttribute *next;
115
* Attribute table; defined in parse.c
118
extern AttributeTableEntry attributeTable[];
121
* nv_parse_attribute_string() - this function parses an attribute
122
* string, the syntax for which is:
124
* {host}:{display}.{screen}/{attribute name}[{display devices}]={value}
126
* {host}:{display}.{screen} indicates which X server and X screen to
127
* interact with; this is optional. If no X server is specified, then
128
* the default X server is used. If no X screen is specified, then
129
* all X screens on the X server are used.
131
* {screen}/ may be specified by itself (ie: without the
132
* "{host}:{display}." part).
134
* {attribute name} should be a string without any whitespace (a case
135
* insensitive compare will be done to find a match in the
136
* attributeTable in parse.c). {value} should be an integer.
138
* {display devices} is optional. If no display mask is specified,
139
* then all display devices are assumed.
141
* The query parameter controls whether the attribute string is parsed
142
* for setting or querying. If query == NV_PARSER_SET, then the
143
* attribute string will be interpretted as described above. If query
144
* == NV_PARSER_QUERY, the "={value}" portion of the string should be
147
* If successful, NV_PARSER_STATUS_SUCCESS will be returned and the
148
* ParsedAttribute struct will contain the attribute id corresponding
149
* to the attribute name. If the X server or display devices were
150
* given in the string, then those fields will be appropriately
151
* assigned in the ParsedAttribute struct, and the
152
* NV_PARSER_HAS_X_SERVER and NV_PARSER_HAS_DISPLAY_DEVICE_MASK bits
153
* will be set in the flags field.
156
int nv_parse_attribute_string(const char *, int, ParsedAttribute *);
160
* nv_assign_default_display() - assigns the display name to the
161
* ParsedAttribute struct. As a side affect, also assigns the screen
162
* field, if a screen is specified in the display name.
165
void nv_assign_default_display(ParsedAttribute *a, const char *display);
169
* nv_parse_strerror() - given the error status returned by
170
* nv_parse_attribute_string(), this function returns a string
171
* describing the error.
174
char *nv_parse_strerror(int);
176
int nv_strcasecmp(const char *, const char *);
179
char *remove_spaces(const char *o);
182
* diaplay_mask/display_name conversions: the NV-CONTROL X extension
183
* identifies a display device by a bit in a display device mask. The
184
* below functions translate between a display mask, and a string
185
* describing the display devices.
188
#define BITSHIFT_CRT 0
189
#define BITSHIFT_TV 8
190
#define BITSHIFT_DFP 16
192
#define BITMASK_ALL_CRT (0xff << BITSHIFT_CRT)
193
#define BITMASK_ALL_TV (0xff << BITSHIFT_TV)
194
#define BITMASK_ALL_DFP (0xff << BITSHIFT_DFP)
196
#define INVALID_DISPLAY_DEVICE_MASK (0xffffffff)
198
#define VALID_DISPLAY_DEVICES_MASK (0x00ffffff)
199
#define DISPLAY_DEVICES_WILDCARD_MASK (0xff000000)
201
#define DISPLAY_DEVICES_WILDCARD_CRT (1 << 24)
202
#define DISPLAY_DEVICES_WILDCARD_TV (1 << 25)
203
#define DISPLAY_DEVICES_WILDCARD_DFP (1 << 26)
207
char *display_device_mask_to_display_device_name(const uint32);
208
uint32 display_device_name_to_display_device_mask(const char *);
210
uint32 expand_display_device_mask_wildcards(const uint32, const uint32);
212
ParsedAttribute *nv_parsed_attribute_init(void);
214
void nv_parsed_attribute_add(ParsedAttribute *head, ParsedAttribute *a);
216
void nv_parsed_attribute_free(ParsedAttribute *p);
217
void nv_parsed_attribute_clean(ParsedAttribute *p);
219
char *nv_get_attribute_name(const int attr);
221
char *nv_standardize_screen_name(const char *display_name, int screen);
223
#endif /* __PARSE_H__ */