nouveau_drv.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #ifndef __NOUVEAU_DRV_H__
  2. #define __NOUVEAU_DRV_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 <linux/notifier.h>
  36. #include <nvif/client.h>
  37. #include <nvif/device.h>
  38. #include <nvif/ioctl.h>
  39. #include <drmP.h>
  40. #include <drm/ttm/ttm_bo_api.h>
  41. #include <drm/ttm/ttm_bo_driver.h>
  42. #include <drm/ttm/ttm_placement.h>
  43. #include <drm/ttm/ttm_memory.h>
  44. #include <drm/ttm/ttm_module.h>
  45. #include <drm/ttm/ttm_page_alloc.h>
  46. #include "uapi/drm/nouveau_drm.h"
  47. struct nouveau_channel;
  48. struct platform_device;
  49. #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
  50. #include "nouveau_fence.h"
  51. #include "nouveau_bios.h"
  52. struct nouveau_drm_tile {
  53. struct nouveau_fence *fence;
  54. bool used;
  55. };
  56. enum nouveau_drm_object_route {
  57. NVDRM_OBJECT_NVIF = NVIF_IOCTL_V0_OWNER_NVIF,
  58. NVDRM_OBJECT_USIF,
  59. NVDRM_OBJECT_ABI16,
  60. NVDRM_OBJECT_ANY = NVIF_IOCTL_V0_OWNER_ANY,
  61. };
  62. enum nouveau_drm_notify_route {
  63. NVDRM_NOTIFY_NVIF = 0,
  64. NVDRM_NOTIFY_USIF
  65. };
  66. enum nouveau_drm_handle {
  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. struct list_head bl_connectors;
  138. struct work_struct hpd_work;
  139. #ifdef CONFIG_ACPI
  140. struct notifier_block acpi_nb;
  141. #endif
  142. /* power management */
  143. struct nouveau_hwmon *hwmon;
  144. struct nouveau_debugfs *debugfs;
  145. /* led management */
  146. struct nouveau_led *led;
  147. /* display power reference */
  148. bool have_disp_power_ref;
  149. struct dev_pm_domain vga_pm_domain;
  150. struct pci_dev *hdmi_device;
  151. };
  152. static inline struct nouveau_drm *
  153. nouveau_drm(struct drm_device *dev)
  154. {
  155. return dev->dev_private;
  156. }
  157. int nouveau_pmops_suspend(struct device *);
  158. int nouveau_pmops_resume(struct device *);
  159. #include <nvkm/core/tegra.h>
  160. struct drm_device *
  161. nouveau_platform_device_create(const struct nvkm_device_tegra_func *,
  162. struct platform_device *, struct nvkm_device **);
  163. void nouveau_drm_device_remove(struct drm_device *dev);
  164. #define NV_PRINTK(l,c,f,a...) do { \
  165. struct nouveau_cli *_cli = (c); \
  166. dev_##l(_cli->dev->dev, "%s: "f, _cli->name, ##a); \
  167. } while(0)
  168. #define NV_FATAL(drm,f,a...) NV_PRINTK(crit, &(drm)->client, f, ##a)
  169. #define NV_ERROR(drm,f,a...) NV_PRINTK(err, &(drm)->client, f, ##a)
  170. #define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a)
  171. #define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a)
  172. #define NV_DEBUG(drm,f,a...) do { \
  173. if (unlikely(drm_debug & DRM_UT_DRIVER)) \
  174. NV_PRINTK(info, &(drm)->client, f, ##a); \
  175. } while(0)
  176. #define NV_ATOMIC(drm,f,a...) do { \
  177. if (unlikely(drm_debug & DRM_UT_ATOMIC)) \
  178. NV_PRINTK(info, &(drm)->client, f, ##a); \
  179. } while(0)
  180. extern int nouveau_modeset;
  181. #endif