nouveau_drm.h 5.2 KB

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