nouveau_drm.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #ifndef __NOUVEAU_DRMCLI_H__
  2. #define __NOUVEAU_DRMCLI_H__
  3. #define DRIVER_AUTHOR "Nouveau Project"
  4. #define DRIVER_EMAIL "nouveau@lists.freedesktop.org"
  5. #define DRIVER_NAME "nouveau"
  6. #define DRIVER_DESC "nVidia Riva/TNT/GeForce/Quadro/Tesla"
  7. #define DRIVER_DATE "20120801"
  8. #define DRIVER_MAJOR 1
  9. #define DRIVER_MINOR 2
  10. #define DRIVER_PATCHLEVEL 1
  11. /*
  12. * 1.1.1:
  13. * - added support for tiled system memory buffer objects
  14. * - added support for NOUVEAU_GETPARAM_GRAPH_UNITS on [nvc0,nve0].
  15. * - added support for compressed memory storage types on [nvc0,nve0].
  16. * - added support for software methods 0x600,0x644,0x6ac on nvc0
  17. * to control registers on the MPs to enable performance counters,
  18. * and to control the warp error enable mask (OpenGL requires out of
  19. * bounds access to local memory to be silently ignored / return 0).
  20. * 1.1.2:
  21. * - fixes multiple bugs in flip completion events and timestamping
  22. * 1.2.0:
  23. * - object api exposed to userspace
  24. * - fermi,kepler,maxwell zbc
  25. * 1.2.1:
  26. * - allow concurrent access to bo's mapped read/write.
  27. */
  28. #include <nvif/client.h>
  29. #include <nvif/device.h>
  30. #include <drmP.h>
  31. #include <drm/ttm/ttm_bo_api.h>
  32. #include <drm/ttm/ttm_bo_driver.h>
  33. #include <drm/ttm/ttm_placement.h>
  34. #include <drm/ttm/ttm_memory.h>
  35. #include <drm/ttm/ttm_module.h>
  36. #include <drm/ttm/ttm_page_alloc.h>
  37. #include "uapi/drm/nouveau_drm.h"
  38. struct nouveau_channel;
  39. struct platform_device;
  40. #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
  41. #include "nouveau_fence.h"
  42. #include "nouveau_bios.h"
  43. struct nouveau_drm_tile {
  44. struct nouveau_fence *fence;
  45. bool used;
  46. };
  47. enum nouveau_drm_object_route {
  48. NVDRM_OBJECT_NVIF = 0,
  49. NVDRM_OBJECT_USIF,
  50. NVDRM_OBJECT_ABI16,
  51. };
  52. enum nouveau_drm_notify_route {
  53. NVDRM_NOTIFY_NVIF = 0,
  54. NVDRM_NOTIFY_USIF
  55. };
  56. enum nouveau_drm_handle {
  57. NVDRM_CLIENT = 0xffffffff,
  58. NVDRM_DEVICE = 0xdddddddd,
  59. NVDRM_CONTROL = 0xdddddddc,
  60. NVDRM_DISPLAY = 0xd1500000,
  61. NVDRM_PUSH = 0xbbbb0000, /* |= client chid */
  62. NVDRM_CHAN = 0xcccc0000, /* |= client chid */
  63. NVDRM_NVSW = 0x55550000,
  64. };
  65. struct nouveau_cli {
  66. struct nvif_client base;
  67. struct nouveau_vm *vm; /*XXX*/
  68. struct list_head head;
  69. struct mutex mutex;
  70. void *abi16;
  71. struct list_head objects;
  72. struct list_head notifys;
  73. };
  74. static inline struct nouveau_cli *
  75. nouveau_cli(struct drm_file *fpriv)
  76. {
  77. return fpriv ? fpriv->driver_priv : NULL;
  78. }
  79. #include <nvif/object.h>
  80. #include <nvif/device.h>
  81. extern int nouveau_runtime_pm;
  82. struct nouveau_drm {
  83. struct nouveau_cli client;
  84. struct drm_device *dev;
  85. struct nvif_device device;
  86. struct list_head clients;
  87. struct {
  88. enum {
  89. UNKNOWN = 0,
  90. DISABLE = 1,
  91. ENABLED = 2
  92. } stat;
  93. u32 base;
  94. u32 size;
  95. } agp;
  96. /* TTM interface support */
  97. struct {
  98. struct drm_global_reference mem_global_ref;
  99. struct ttm_bo_global_ref bo_global_ref;
  100. struct ttm_bo_device bdev;
  101. atomic_t validate_sequence;
  102. int (*move)(struct nouveau_channel *,
  103. struct ttm_buffer_object *,
  104. struct ttm_mem_reg *, struct ttm_mem_reg *);
  105. struct nouveau_channel *chan;
  106. struct nvif_object copy;
  107. int mtrr;
  108. } ttm;
  109. /* GEM interface support */
  110. struct {
  111. u64 vram_available;
  112. u64 gart_available;
  113. } gem;
  114. /* synchronisation */
  115. void *fence;
  116. /* context for accelerated drm-internal operations */
  117. struct nouveau_channel *cechan;
  118. struct nouveau_channel *channel;
  119. struct nouveau_gpuobj *notify;
  120. struct nouveau_fbdev *fbcon;
  121. struct nvif_object nvsw;
  122. struct nvif_object ntfy;
  123. /* nv10-nv40 tiling regions */
  124. struct {
  125. struct nouveau_drm_tile reg[15];
  126. spinlock_t lock;
  127. } tile;
  128. /* modesetting */
  129. struct nvbios vbios;
  130. struct nouveau_display *display;
  131. struct backlight_device *backlight;
  132. /* power management */
  133. struct nouveau_hwmon *hwmon;
  134. struct nouveau_sysfs *sysfs;
  135. /* display power reference */
  136. bool have_disp_power_ref;
  137. struct dev_pm_domain vga_pm_domain;
  138. struct pci_dev *hdmi_device;
  139. };
  140. static inline struct nouveau_drm *
  141. nouveau_drm(struct drm_device *dev)
  142. {
  143. return dev->dev_private;
  144. }
  145. int nouveau_pmops_suspend(struct device *);
  146. int nouveau_pmops_resume(struct device *);
  147. #define nouveau_platform_device_create(p, u) \
  148. nouveau_platform_device_create_(p, sizeof(**u), (void **)u)
  149. struct drm_device *
  150. nouveau_platform_device_create_(struct platform_device *pdev,
  151. int size, void **pobject);
  152. void nouveau_drm_device_remove(struct drm_device *dev);
  153. #define NV_PRINTK(l,c,f,a...) do { \
  154. struct nouveau_cli *_cli = (c); \
  155. nv_##l(_cli->base.base.priv, f, ##a); \
  156. } while(0)
  157. #define NV_FATAL(drm,f,a...) NV_PRINTK(fatal, &(drm)->client, f, ##a)
  158. #define NV_ERROR(drm,f,a...) NV_PRINTK(error, &(drm)->client, f, ##a)
  159. #define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a)
  160. #define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a)
  161. #define NV_DEBUG(drm,f,a...) NV_PRINTK(debug, &(drm)->client, f, ##a)
  162. extern int nouveau_modeset;
  163. #endif