nouveau_drm.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 2
  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. * 1.2.2:
  28. * - add NOUVEAU_GEM_DOMAIN_COHERENT flag
  29. */
  30. #include <nvif/client.h>
  31. #include <nvif/device.h>
  32. #include <drmP.h>
  33. #include <drm/ttm/ttm_bo_api.h>
  34. #include <drm/ttm/ttm_bo_driver.h>
  35. #include <drm/ttm/ttm_placement.h>
  36. #include <drm/ttm/ttm_memory.h>
  37. #include <drm/ttm/ttm_module.h>
  38. #include <drm/ttm/ttm_page_alloc.h>
  39. #include "uapi/drm/nouveau_drm.h"
  40. struct nouveau_channel;
  41. struct platform_device;
  42. #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
  43. #include "nouveau_fence.h"
  44. #include "nouveau_bios.h"
  45. struct nouveau_drm_tile {
  46. struct nouveau_fence *fence;
  47. bool used;
  48. };
  49. enum nouveau_drm_object_route {
  50. NVDRM_OBJECT_NVIF = 0,
  51. NVDRM_OBJECT_USIF,
  52. NVDRM_OBJECT_ABI16,
  53. };
  54. enum nouveau_drm_notify_route {
  55. NVDRM_NOTIFY_NVIF = 0,
  56. NVDRM_NOTIFY_USIF
  57. };
  58. enum nouveau_drm_handle {
  59. NVDRM_CLIENT = 0xffffffff,
  60. NVDRM_DEVICE = 0xdddddddd,
  61. NVDRM_CONTROL = 0xdddddddc,
  62. NVDRM_DISPLAY = 0xd1500000,
  63. NVDRM_PUSH = 0xbbbb0000, /* |= client chid */
  64. NVDRM_CHAN = 0xcccc0000, /* |= client chid */
  65. NVDRM_NVSW = 0x55550000,
  66. };
  67. struct nouveau_cli {
  68. struct nvif_client base;
  69. struct nvkm_vm *vm; /*XXX*/
  70. struct list_head head;
  71. struct mutex mutex;
  72. void *abi16;
  73. struct list_head objects;
  74. struct list_head notifys;
  75. };
  76. static inline struct nouveau_cli *
  77. nouveau_cli(struct drm_file *fpriv)
  78. {
  79. return fpriv ? fpriv->driver_priv : NULL;
  80. }
  81. #include <nvif/object.h>
  82. #include <nvif/device.h>
  83. extern int nouveau_runtime_pm;
  84. struct nouveau_drm {
  85. struct nouveau_cli client;
  86. struct drm_device *dev;
  87. struct nvif_device device;
  88. struct list_head clients;
  89. struct {
  90. enum {
  91. UNKNOWN = 0,
  92. DISABLE = 1,
  93. ENABLED = 2
  94. } stat;
  95. u32 base;
  96. u32 size;
  97. } agp;
  98. /* TTM interface support */
  99. struct {
  100. struct drm_global_reference mem_global_ref;
  101. struct ttm_bo_global_ref bo_global_ref;
  102. struct ttm_bo_device bdev;
  103. atomic_t validate_sequence;
  104. int (*move)(struct nouveau_channel *,
  105. struct ttm_buffer_object *,
  106. struct ttm_mem_reg *, struct ttm_mem_reg *);
  107. struct nouveau_channel *chan;
  108. struct nvif_object copy;
  109. int mtrr;
  110. } ttm;
  111. /* GEM interface support */
  112. struct {
  113. u64 vram_available;
  114. u64 gart_available;
  115. } gem;
  116. /* synchronisation */
  117. void *fence;
  118. /* context for accelerated drm-internal operations */
  119. struct nouveau_channel *cechan;
  120. struct nouveau_channel *channel;
  121. struct nvkm_gpuobj *notify;
  122. struct nouveau_fbdev *fbcon;
  123. struct nvif_object nvsw;
  124. struct nvif_object ntfy;
  125. /* nv10-nv40 tiling regions */
  126. struct {
  127. struct nouveau_drm_tile reg[15];
  128. spinlock_t lock;
  129. } tile;
  130. /* modesetting */
  131. struct nvbios vbios;
  132. struct nouveau_display *display;
  133. struct backlight_device *backlight;
  134. /* power management */
  135. struct nouveau_hwmon *hwmon;
  136. struct nouveau_sysfs *sysfs;
  137. /* display power reference */
  138. bool have_disp_power_ref;
  139. struct dev_pm_domain vga_pm_domain;
  140. struct pci_dev *hdmi_device;
  141. };
  142. static inline struct nouveau_drm *
  143. nouveau_drm(struct drm_device *dev)
  144. {
  145. return dev->dev_private;
  146. }
  147. int nouveau_pmops_suspend(struct device *);
  148. int nouveau_pmops_resume(struct device *);
  149. #define nouveau_platform_device_create(p, u) \
  150. nouveau_platform_device_create_(p, sizeof(**u), (void **)u)
  151. struct drm_device *
  152. nouveau_platform_device_create_(struct platform_device *pdev,
  153. int size, void **pobject);
  154. void nouveau_drm_device_remove(struct drm_device *dev);
  155. #define NV_PRINTK(l,c,f,a...) do { \
  156. struct nouveau_cli *_cli = (c); \
  157. nv_##l(_cli->base.base.priv, f, ##a); \
  158. } while(0)
  159. #define NV_FATAL(drm,f,a...) NV_PRINTK(fatal, &(drm)->client, f, ##a)
  160. #define NV_ERROR(drm,f,a...) NV_PRINTK(error, &(drm)->client, f, ##a)
  161. #define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a)
  162. #define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a)
  163. #define NV_DEBUG(drm,f,a...) NV_PRINTK(debug, &(drm)->client, f, ##a)
  164. extern int nouveau_modeset;
  165. #endif