nouveau_drm.h 5.2 KB

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