NV-CONTROL-API.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. NV-CONTROL X Extension - API specificiation v 1.6
  2. 1. INTRODUCTION
  3. The NV-CONTROL X extension provides a mechanism for X clients to
  4. query and set configuration parameters of the NVIDIA X driver.
  5. State set by the NV-CONTROL X extension is assumed to be persistent
  6. only for the current server generation.
  7. Attributes are configurable on a per X screen basis, and some
  8. attributes are also configurable on a per display device basis.
  9. Addtionally, some attributes can only be queried, though most can
  10. be both queried and modified. The NV-CONTROL extension provides
  11. a mechanism to determine what values are valid for an attribute,
  12. if an attribute is read-only, if it can be read and written, if it
  13. requires a display device qualifier, and if the the attribute is
  14. available on the specified X screen.
  15. Finally, NV-CONTROL clients may also request to be notified when an
  16. attribute is changed by any other NV-CONTROL client.
  17. 2. DISPLAY DEVICES
  18. A "Display Device" refers to some piece of hardware capable of
  19. displaying an image. Display devices are separated into the three
  20. general categories: analog CRTs, digital flatpanels, and TVs.
  21. Note that analog flatpanels fall under the category of analog CRTs.
  22. The NVIDIA X driver allows multiple display devices to display
  23. portions of the same X screen; this is configured through the
  24. TwinView feature of the NVIDIA X driver. TwinView is described in
  25. the Appendix on TwinView in the NVIDIA Linux driver text README file.
  26. A consequence of TwinView is that an X screen does not necessarily
  27. uniquely identify a display device.
  28. While most attributes controlled by the NV-CONTROL X extension
  29. apply to an entire X screen, some attributes can be controlled per
  30. display device. When querying and assigning such attributes, the
  31. particular display device is specified via a display device mask.
  32. A "display device mask" is an unsigned 32 bit value that identifies
  33. one or more display devices: the first 8 bits each identify a CRT, the
  34. next 8 bits each identify a TV, and the next 8 each identify a DFP.
  35. For example, 0x1 refers to CRT-0, 0x3 refers to CRT-0 and CRT-1,
  36. 0x10001 refers to CRT-0 and DFP-0, etc.
  37. 3. QUERYING THE EXTENSION
  38. NV-CONTROL clients can query for the existence of the NV-CONTROL X
  39. extension with:
  40. Bool XNVCTRLQueryExtension (Display *dpy,
  41. int *event_basep, int *error_basep);
  42. This function returns True if the extension exists, and returns False
  43. if the extension does not. It also returns the error and event bases.
  44. The arguments are:
  45. dpy - The connection to the X server.
  46. event_basep - The returned event base. Currently, only one
  47. extension specific event is defined.
  48. error_basep - The returned error base. Currently, no extension
  49. specific errors are defined.
  50. The version of the NV-CONTROL extension can be queried with:
  51. Bool XNVCTRLQueryVersion (Display *dpy, int *major, int *minor);
  52. This function returns True if the extension exists, and returns
  53. False if it does not. It also returns the major and minor version
  54. numbers of the extension. The arguments are:
  55. dpy - The connection to the X server.
  56. major - The returned major version number of the extension.
  57. minor - The returned minor version number of the extension.
  58. You can determine if a particular X screen is controlled by the
  59. NVIDIA X driver (and thus supports the NV-CONTROL X extension) with:
  60. Bool XNVCTRLIsNvScreen (Display *dpy, int screen);
  61. This function returns True if the specified screen is controlled by
  62. the NVIDIA driver, and thus supports the NV-CONTROL X extension.
  63. It returns False if the specified screen does not support the
  64. NV-CONTROL X extension. The arguments are:
  65. dpy - The connection to the X server.
  66. screen - the X screen to query.
  67. 4. QUERYING VALID ATTRIBUTE VALUES
  68. NV-CONTROL clients can query the valid values for any integer
  69. attribute with:
  70. Bool XNVCTRLQueryValidAttributeValues (Display *dpy,
  71. int screen,
  72. unsigned int display_mask,
  73. unsigned int attribute,
  74. NVCTRLAttributeValidValuesRec
  75. *values);
  76. This function returns True if the attribute exists on the specified
  77. X screen, or False if the attribute is not available on the specified
  78. X screen.
  79. The arguments are:
  80. dpy - The connection to the X server.
  81. screen - the X screen to query.
  82. display_mask - for attributes that can be controlled on a per
  83. display device basis, the display_mask should
  84. uniquely identify a single display device.
  85. This argument is ignored for attributes that
  86. apply to the entire X screen.
  87. attribute - the integer attribute to query
  88. values - the returned NVCTRLAttributeValidValuesRec structure.
  89. The NVCTRLAttributeValidValuesRec structure is defined as:
  90. typedef struct _NVCTRLAttributeValidValues {
  91. int type;
  92. union {
  93. struct {
  94. int min;
  95. int max;
  96. } range;
  97. struct {
  98. unsigned int ints;
  99. } bits;
  100. } u;
  101. unsigned int permissions;
  102. } NVCTRLAttributeValidValuesRec;
  103. Where type can be one of:
  104. #define ATTRIBUTE_TYPE_UNKNOWN 0
  105. #define ATTRIBUTE_TYPE_INTEGER 1
  106. #define ATTRIBUTE_TYPE_BITMASK 2
  107. #define ATTRIBUTE_TYPE_BOOL 3
  108. #define ATTRIBUTE_TYPE_RANGE 4
  109. #define ATTRIBUTE_TYPE_INT_BITS 5
  110. ATTRIBUTE_TYPE_INTEGER indicates that the attribute is an integer
  111. value; any integer may be specified when setting this attribute.
  112. ATTRIBUTE_TYPE_BITMASK indicates that the attribute is an integer
  113. value, interpretted as a bitmask. This is the type, for example,
  114. of the NV_CTRL_CONNECTED_DISPLAYS attribute.
  115. ATTRIBUTE_TYPE_BOOL indicates that the attribute is a boolean;
  116. valid values are 1 (on/true) and 0 (off/false).
  117. ATTRIBUTE_TYPE_RANGE indicates that the attribute can have any
  118. integer value between NVCTRLAttributeValidValues.u.range.min and
  119. NVCTRLAttributeValidValues.u.range.max (inclusive).
  120. ATTRIBUTE_TYPE_INT_BITS indicates that the attribute can
  121. only have certain integer values, indicated by which bits in
  122. NVCTRLAttributeValidValues.u.bits.ints are on (for example: if bit
  123. 0 is on, then 0 is a valid value; if bit 5 is on, then 5 is a valid
  124. value, etc). This is the type, for example, of NV_CTRL_FSAA_MODE.
  125. The permissions field in NVCTRLAttributeValidValuesRec is a bitmask
  126. that can contain any of:
  127. #define ATTRIBUTE_TYPE_READ 0x1
  128. #define ATTRIBUTE_TYPE_WRITE 0x2
  129. #define ATTRIBUTE_TYPE_DISPLAY 0x4
  130. ATTRIBUTE_TYPE_READ indicates that the attribute is readable; in
  131. general, all attributes will be readable.
  132. ATTRIBUTE_TYPE_WRITE indicates that the attribute is writable;
  133. attributes may not be writable for various reasons: they represent
  134. static system information, they can only be changed by changing an
  135. XF86Config option, etc.
  136. ATTRIBUTE_TYPE_DISPLAY indicates that the attribute can be
  137. controlled on a per display device basis, and thus
  138. XNVCTRLQueryAttribute() and XNVCTRLSetAttribute() require that a
  139. display device be specified.
  140. The XNVCTRLQueryValidAttributeValues() function can cause the
  141. following X protocol errors:
  142. BadValue - The screen does not exist.
  143. BadMatch - The NVIDIA driver is not present on that screen.
  144. 5. QUERYING ATTRIBUTE VALUES
  145. NV-CONTROL clients can query the current value of an integer
  146. attribute with:
  147. Bool XNVCTRLQueryAttribute (Display *dpy,
  148. int screen,
  149. unsigned int display_mask,
  150. unsigned int attribute,
  151. int *value);
  152. This function returns True if the attribute exists, and stores the
  153. current attribute value in the memory pointed to by the value
  154. argument. False is returned if the attribute does not exist on the
  155. specified X screen.
  156. The arguments are:
  157. dpy - The connection to the X server.
  158. screen - the X screen to query.
  159. display_mask - if the attribute requires a display device,
  160. then this indicates the display device to query;
  161. this field is ignored if the attribute is not
  162. display device specific. You can determine
  163. if an attribute is display device specific by
  164. querying the valid values and checking for the
  165. ATTRIBUTE_TYPE_DISPLAY bit in the permissions
  166. field.
  167. attribute - the attribute to query.
  168. value - the returned attribute value.
  169. This function can cause the following X protocol errors:
  170. BadValue - The screen does not exist.
  171. BadMatch - The NVIDIA driver is not present on that screen.
  172. NV-CONTROL clients can query the read-only string attributes with:
  173. Bool XNVCTRLQueryStringAttribute (Display *dpy,
  174. int screen,
  175. unsigned int display_mask,
  176. unsigned int attribute,
  177. char **ptr);
  178. This function returns True if the string attribute exists;
  179. or it returns False if the string attribute does not exist. If
  180. XNVCTRLQueryStringAttribute returns True, *ptr will point to an
  181. allocated string containing the string attribute requested. It is
  182. the caller's responsibility to free the string with XFree().
  183. The arguments are:
  184. dpy - The connection to the X server.
  185. screen - the X screen to query.
  186. display_mask - if the attribute requires a display device,
  187. then this indicates the display device to query;
  188. this field is ignored if the attribute is not
  189. display device specific.
  190. attribute - the string attribute to query
  191. ptr - the returned allocated string
  192. This function can cause the following X protocol errors:
  193. BadValue - The screen does not exist.
  194. BadMatch - The NVIDIA driver is not present on that screen.
  195. BadAlloc - Insufficient resources to fulfill the request.
  196. See NVCtrl.h (distributed in the src/libXNVCtrl/ directory of
  197. the nvidia-settings source package) for a list of possible string
  198. attributes.
  199. 6. ASSIGNING ATTRIBUTE VALUES
  200. An integer attribute can be assigned a value with:
  201. void XNVCTRLSetAttribute (Display *dpy,
  202. int screen,
  203. unsigned int display_mask,
  204. unsigned int attribute,
  205. int value);
  206. This function sets the attribute to the given value. This function
  207. does not have a return value. Note that, because it does not
  208. return a value, XNVCTRLSetAttribute() only queues the request in
  209. the X command stream. The command will not actually be sent to
  210. the server until an X command that flushes the X command stream
  211. (such as XFlush(), or any API command that queries a value from the
  212. server) is called.
  213. The arguments are:
  214. dpy - The connection to the X server.
  215. screen - the X screen to query.
  216. display_mask - if the attribute requires a display device,
  217. then this indicates the display device to set;
  218. this field is ignored if the attribute is not
  219. display device specific. You can determine
  220. if an attribute is display device specific by
  221. querying the valid values and checking for the
  222. ATTRIBUTE_TYPE_DISPLAY bit in the permissions
  223. field.
  224. attribute - the attribute to set.
  225. value - the value the attribute should be set to.
  226. See NVCtrl.h (distributed in the src/libXNVCtrl/ directory of
  227. the nvidia-settings source package) for a list of possible integer
  228. attributes.
  229. This function can cause the following X protocol errors:
  230. BadMatch - The NVIDIA driver is not present on that screen.
  231. BadValue - The screen does not exist, or an invalid value is
  232. specified, or the attribute does not exist on the
  233. specified X screen, or the attribute requires a
  234. display device and display_mask does not uniquely
  235. identify a display device.
  236. Before calling XNVCTRLSetAttribute(), an NV-CONTROL client should
  237. use XNVCTRLQueryAttribute() or XNVCTRLQueryValidAttributeValues()
  238. to determine if the attribute exists on the specified X screen;
  239. if the attribute does not exist and XNVCTRLSetAttribute()
  240. is called for that attribute, then a BadValue X protocol error will
  241. be triggered.
  242. 7. SELECTING EVENT NOTIFICATION
  243. NV-CONTROL clients can enable NV-CONTROL events with:
  244. Bool XNVCtrlSelectNotify (Display *dpy,
  245. int screen,
  246. int type,
  247. Bool onoff);
  248. This function returns True if the extension exists, or False if the
  249. extension does not exist. The arguments are:
  250. dpy - The connection to the X server.
  251. screen - the X screen on which to enable events.
  252. type - the type of event to enable; currently, the only NV-CONTROL
  253. event type is ATTRIBUTE_CHANGED_EVENT.
  254. onoff - whether to enable (True) or disable (False) receiving
  255. this event type.
  256. This function can cause the following X protocol errors:
  257. BadValue - The screen does not exist.
  258. BadMatch - The NVIDIA driver is not present on that screen.
  259. When an NV-CONTROL client changes an integer attribute value, all
  260. other NV-CONTROL clients with ATTRIBUTE_CHANGED_EVENT notificaion
  261. enabled will receive an XEvent where XEvent.type is equal to:
  262. event_base + ATTRIBUTE_CHANGED_EVENT
  263. where event_base is the event base returned by
  264. XNVCTRLQueryExtension(). The XEvent can then be cast as an
  265. XNVCtrlAttributeChangedEvent structure:
  266. typedef struct {
  267. int type;
  268. unsigned long serial;
  269. Bool send_event; /* always FALSE, we don't allow send_events */
  270. Display *display;
  271. Time time;
  272. int screen;
  273. unsigned int display_mask;
  274. unsigned int attribute;
  275. int value;
  276. } XNVCtrlAttributeChangedEvent;
  277. The screen, display_mask, attribute, and value fields correspond to
  278. the arguments passed to XNVCTRLSetAttribute().
  279. 8. NV-CONTROL EXTENSION HISTORY
  280. 1.0 - 1.5 NVIDIA Internal development versions
  281. 1.6 Initial public version