nouveau_drv.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. /*
  2. * Copyright 2005 Stephane Marchesin.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the next
  13. * paragraph) shall be included in all copies or substantial portions of the
  14. * Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. #ifndef __NOUVEAU_DRV_H__
  25. #define __NOUVEAU_DRV_H__
  26. #define DRIVER_AUTHOR "Stephane Marchesin"
  27. #define DRIVER_EMAIL "nouveau@lists.freedesktop.org"
  28. #define DRIVER_NAME "nouveau"
  29. #define DRIVER_DESC "nVidia Riva/TNT/GeForce"
  30. #define DRIVER_DATE "20120316"
  31. #define DRIVER_MAJOR 1
  32. #define DRIVER_MINOR 0
  33. #define DRIVER_PATCHLEVEL 0
  34. #define NOUVEAU_FAMILY 0x0000FFFF
  35. #define NOUVEAU_FLAGS 0xFFFF0000
  36. #include "ttm/ttm_bo_api.h"
  37. #include "ttm/ttm_bo_driver.h"
  38. #include "ttm/ttm_placement.h"
  39. #include "ttm/ttm_memory.h"
  40. #include "ttm/ttm_module.h"
  41. #define XXX_THIS_IS_A_HACK
  42. #include <subdev/vm.h>
  43. #include <subdev/fb.h>
  44. #include <core/gpuobj.h>
  45. enum blah {
  46. NV_MEM_TYPE_UNKNOWN = 0,
  47. NV_MEM_TYPE_STOLEN,
  48. NV_MEM_TYPE_SGRAM,
  49. NV_MEM_TYPE_SDRAM,
  50. NV_MEM_TYPE_DDR1,
  51. NV_MEM_TYPE_DDR2,
  52. NV_MEM_TYPE_DDR3,
  53. NV_MEM_TYPE_GDDR2,
  54. NV_MEM_TYPE_GDDR3,
  55. NV_MEM_TYPE_GDDR4,
  56. NV_MEM_TYPE_GDDR5
  57. };
  58. struct nouveau_fpriv {
  59. spinlock_t lock;
  60. struct list_head channels;
  61. struct nouveau_vm *vm;
  62. };
  63. static inline struct nouveau_fpriv *
  64. nouveau_fpriv(struct drm_file *file_priv)
  65. {
  66. return file_priv ? file_priv->driver_priv : NULL;
  67. }
  68. #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
  69. #include <nouveau_drm.h>
  70. #include "nouveau_reg.h"
  71. #include <nouveau_bios.h>
  72. #include "nouveau_util.h"
  73. struct nouveau_grctx;
  74. struct nouveau_mem;
  75. #include <subdev/bios/pll.h>
  76. #include "nouveau_compat.h"
  77. #define nouveau_gpuobj_new(d,c,s,a,f,o) \
  78. _nouveau_gpuobj_new((d), (c) ? ((struct nouveau_channel *)(c))->ramin : NULL, \
  79. (s), (a), (f), (o))
  80. #define nouveau_vm_new(d,o,l,m,v) \
  81. _nouveau_vm_new((d), (o), (l), (m), (v))
  82. #define nv50_vm_flush_engine(d,e) \
  83. _nv50_vm_flush_engine((d), (e))
  84. #define MAX_NUM_DCB_ENTRIES 16
  85. #define NOUVEAU_MAX_CHANNEL_NR 4096
  86. #define NOUVEAU_MAX_TILE_NR 15
  87. #include "nouveau_bo.h"
  88. #define nouveau_bo_tile_layout(nvbo) \
  89. ((nvbo)->tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK)
  90. static inline struct nouveau_bo *
  91. nouveau_gem_object(struct drm_gem_object *gem)
  92. {
  93. return gem ? gem->driver_private : NULL;
  94. }
  95. /* TODO: submit equivalent to TTM generic API upstream? */
  96. static inline void __iomem *
  97. nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo)
  98. {
  99. bool is_iomem;
  100. void __iomem *ioptr = (void __force __iomem *)ttm_kmap_obj_virtual(
  101. &nvbo->kmap, &is_iomem);
  102. WARN_ON_ONCE(ioptr && !is_iomem);
  103. return ioptr;
  104. }
  105. enum nouveau_flags {
  106. NV_NFORCE = 0x10000000,
  107. NV_NFORCE2 = 0x20000000
  108. };
  109. #define NVOBJ_ENGINE_SW 0
  110. #define NVOBJ_ENGINE_GR 1
  111. #define NVOBJ_ENGINE_CRYPT 2
  112. #define NVOBJ_ENGINE_COPY0 3
  113. #define NVOBJ_ENGINE_COPY1 4
  114. #define NVOBJ_ENGINE_MPEG 5
  115. #define NVOBJ_ENGINE_PPP NVOBJ_ENGINE_MPEG
  116. #define NVOBJ_ENGINE_BSP 6
  117. #define NVOBJ_ENGINE_VP 7
  118. #define NVOBJ_ENGINE_FIFO 14
  119. #define NVOBJ_ENGINE_FENCE 15
  120. #define NVOBJ_ENGINE_NR 16
  121. #define NVOBJ_ENGINE_DISPLAY (NVOBJ_ENGINE_NR + 0) /*XXX*/
  122. struct nouveau_page_flip_state {
  123. struct list_head head;
  124. struct drm_pending_vblank_event *event;
  125. int crtc, bpp, pitch, x, y;
  126. uint64_t offset;
  127. };
  128. enum nouveau_channel_mutex_class {
  129. NOUVEAU_UCHANNEL_MUTEX,
  130. NOUVEAU_KCHANNEL_MUTEX
  131. };
  132. struct nouveau_channel {
  133. struct drm_device *dev;
  134. struct list_head list;
  135. int id;
  136. /* references to the channel data structure */
  137. struct kref ref;
  138. /* users of the hardware channel resources, the hardware
  139. * context will be kicked off when it reaches zero. */
  140. atomic_t users;
  141. struct mutex mutex;
  142. /* owner of this fifo */
  143. struct drm_file *file_priv;
  144. /* mapping of the fifo itself */
  145. struct drm_local_map *map;
  146. /* mapping of the regs controlling the fifo */
  147. void __iomem *user;
  148. uint32_t user_get;
  149. uint32_t user_get_hi;
  150. uint32_t user_put;
  151. /* DMA push buffer */
  152. struct nouveau_gpuobj *pushbuf;
  153. struct nouveau_bo *pushbuf_bo;
  154. struct nouveau_vma pushbuf_vma;
  155. uint64_t pushbuf_base;
  156. /* Notifier memory */
  157. struct nouveau_bo *notifier_bo;
  158. struct nouveau_vma notifier_vma;
  159. struct drm_mm notifier_heap;
  160. /* PFIFO context */
  161. struct nouveau_gpuobj *engptr;
  162. struct nouveau_gpuobj *ramfc;
  163. /* Execution engine contexts */
  164. void *engctx[NVOBJ_ENGINE_NR];
  165. /* NV50 VM */
  166. struct nouveau_vm *vm;
  167. struct nouveau_gpuobj *vm_pd;
  168. /* Objects */
  169. struct nouveau_gpuobj *ramin; /* Private instmem */
  170. struct nouveau_ramht *ramht; /* Hash table */
  171. /* GPU object info for stuff used in-kernel (mm_enabled) */
  172. uint32_t m2mf_ntfy;
  173. uint32_t vram_handle;
  174. uint32_t gart_handle;
  175. bool accel_done;
  176. /* Push buffer state (only for drm's channel on !mm_enabled) */
  177. struct {
  178. int max;
  179. int free;
  180. int cur;
  181. int put;
  182. /* access via pushbuf_bo */
  183. int ib_base;
  184. int ib_max;
  185. int ib_free;
  186. int ib_put;
  187. } dma;
  188. struct {
  189. bool active;
  190. char name[32];
  191. struct drm_info_list info;
  192. } debugfs;
  193. };
  194. struct nouveau_exec_engine {
  195. void (*destroy)(struct drm_device *, int engine);
  196. int (*init)(struct drm_device *, int engine);
  197. int (*fini)(struct drm_device *, int engine, bool suspend);
  198. int (*context_new)(struct nouveau_channel *, int engine);
  199. void (*context_del)(struct nouveau_channel *, int engine);
  200. int (*object_new)(struct nouveau_channel *, int engine,
  201. u32 handle, u16 class);
  202. void (*set_tile_region)(struct drm_device *dev, int i);
  203. void (*tlb_flush)(struct drm_device *, int engine);
  204. };
  205. struct nouveau_display_engine {
  206. void *priv;
  207. int (*early_init)(struct drm_device *);
  208. void (*late_takedown)(struct drm_device *);
  209. int (*create)(struct drm_device *);
  210. void (*destroy)(struct drm_device *);
  211. int (*init)(struct drm_device *);
  212. void (*fini)(struct drm_device *);
  213. struct drm_property *dithering_mode;
  214. struct drm_property *dithering_depth;
  215. struct drm_property *underscan_property;
  216. struct drm_property *underscan_hborder_property;
  217. struct drm_property *underscan_vborder_property;
  218. /* not really hue and saturation: */
  219. struct drm_property *vibrant_hue_property;
  220. struct drm_property *color_vibrance_property;
  221. };
  222. struct nouveau_pm_voltage_level {
  223. u32 voltage; /* microvolts */
  224. u8 vid;
  225. };
  226. struct nouveau_pm_voltage {
  227. bool supported;
  228. u8 version;
  229. u8 vid_mask;
  230. struct nouveau_pm_voltage_level *level;
  231. int nr_level;
  232. };
  233. /* Exclusive upper limits */
  234. #define NV_MEM_CL_DDR2_MAX 8
  235. #define NV_MEM_WR_DDR2_MAX 9
  236. #define NV_MEM_CL_DDR3_MAX 17
  237. #define NV_MEM_WR_DDR3_MAX 17
  238. #define NV_MEM_CL_GDDR3_MAX 16
  239. #define NV_MEM_WR_GDDR3_MAX 18
  240. #define NV_MEM_CL_GDDR5_MAX 21
  241. #define NV_MEM_WR_GDDR5_MAX 20
  242. struct nouveau_pm_memtiming {
  243. int id;
  244. u32 reg[9];
  245. u32 mr[4];
  246. u8 tCWL;
  247. u8 odt;
  248. u8 drive_strength;
  249. };
  250. struct nouveau_pm_tbl_header {
  251. u8 version;
  252. u8 header_len;
  253. u8 entry_cnt;
  254. u8 entry_len;
  255. };
  256. struct nouveau_pm_tbl_entry {
  257. u8 tWR;
  258. u8 tWTR;
  259. u8 tCL;
  260. u8 tRC;
  261. u8 empty_4;
  262. u8 tRFC; /* Byte 5 */
  263. u8 empty_6;
  264. u8 tRAS; /* Byte 7 */
  265. u8 empty_8;
  266. u8 tRP; /* Byte 9 */
  267. u8 tRCDRD;
  268. u8 tRCDWR;
  269. u8 tRRD;
  270. u8 tUNK_13;
  271. u8 RAM_FT1; /* 14, a bitmask of random RAM features */
  272. u8 empty_15;
  273. u8 tUNK_16;
  274. u8 empty_17;
  275. u8 tUNK_18;
  276. u8 tCWL;
  277. u8 tUNK_20, tUNK_21;
  278. };
  279. struct nouveau_pm_profile;
  280. struct nouveau_pm_profile_func {
  281. void (*destroy)(struct nouveau_pm_profile *);
  282. void (*init)(struct nouveau_pm_profile *);
  283. void (*fini)(struct nouveau_pm_profile *);
  284. struct nouveau_pm_level *(*select)(struct nouveau_pm_profile *);
  285. };
  286. struct nouveau_pm_profile {
  287. const struct nouveau_pm_profile_func *func;
  288. struct list_head head;
  289. char name[8];
  290. };
  291. #define NOUVEAU_PM_MAX_LEVEL 8
  292. struct nouveau_pm_level {
  293. struct nouveau_pm_profile profile;
  294. struct device_attribute dev_attr;
  295. char name[32];
  296. int id;
  297. struct nouveau_pm_memtiming timing;
  298. u32 memory;
  299. u16 memscript;
  300. u32 core;
  301. u32 shader;
  302. u32 rop;
  303. u32 copy;
  304. u32 daemon;
  305. u32 vdec;
  306. u32 dom6;
  307. u32 unka0; /* nva3:nvc0 */
  308. u32 hub01; /* nvc0- */
  309. u32 hub06; /* nvc0- */
  310. u32 hub07; /* nvc0- */
  311. u32 volt_min; /* microvolts */
  312. u32 volt_max;
  313. u8 fanspeed;
  314. };
  315. struct nouveau_pm_temp_sensor_constants {
  316. u16 offset_constant;
  317. s16 offset_mult;
  318. s16 offset_div;
  319. s16 slope_mult;
  320. s16 slope_div;
  321. };
  322. struct nouveau_pm_threshold_temp {
  323. s16 critical;
  324. s16 down_clock;
  325. s16 fan_boost;
  326. };
  327. struct nouveau_pm_fan {
  328. u32 percent;
  329. u32 min_duty;
  330. u32 max_duty;
  331. u32 pwm_freq;
  332. u32 pwm_divisor;
  333. };
  334. struct nouveau_pm_engine {
  335. struct nouveau_pm_voltage voltage;
  336. struct nouveau_pm_level perflvl[NOUVEAU_PM_MAX_LEVEL];
  337. int nr_perflvl;
  338. struct nouveau_pm_temp_sensor_constants sensor_constants;
  339. struct nouveau_pm_threshold_temp threshold_temp;
  340. struct nouveau_pm_fan fan;
  341. struct nouveau_pm_profile *profile_ac;
  342. struct nouveau_pm_profile *profile_dc;
  343. struct nouveau_pm_profile *profile;
  344. struct list_head profiles;
  345. struct nouveau_pm_level boot;
  346. struct nouveau_pm_level *cur;
  347. struct device *hwmon;
  348. struct notifier_block acpi_nb;
  349. int (*clocks_get)(struct drm_device *, struct nouveau_pm_level *);
  350. void *(*clocks_pre)(struct drm_device *, struct nouveau_pm_level *);
  351. int (*clocks_set)(struct drm_device *, void *);
  352. int (*voltage_get)(struct drm_device *);
  353. int (*voltage_set)(struct drm_device *, int voltage);
  354. int (*pwm_get)(struct drm_device *, int line, u32*, u32*);
  355. int (*pwm_set)(struct drm_device *, int line, u32, u32);
  356. int (*temp_get)(struct drm_device *);
  357. };
  358. struct nouveau_engine {
  359. struct nouveau_display_engine display;
  360. struct nouveau_pm_engine pm;
  361. };
  362. enum nouveau_card_type {
  363. NV_04 = 0x04,
  364. NV_10 = 0x10,
  365. NV_20 = 0x20,
  366. NV_30 = 0x30,
  367. NV_40 = 0x40,
  368. NV_50 = 0x50,
  369. NV_C0 = 0xc0,
  370. NV_D0 = 0xd0,
  371. NV_E0 = 0xe0,
  372. };
  373. struct drm_nouveau_private {
  374. struct drm_device *dev;
  375. bool noaccel;
  376. void *newpriv;
  377. /* the card type, takes NV_* as values */
  378. enum nouveau_card_type card_type;
  379. /* exact chipset, derived from NV_PMC_BOOT_0 */
  380. int chipset;
  381. int flags;
  382. u32 crystal;
  383. struct nouveau_exec_engine *eng[NVOBJ_ENGINE_NR];
  384. struct list_head classes;
  385. struct nouveau_bo *vga_ram;
  386. /* interrupt handling */
  387. void (*irq_handler[32])(struct drm_device *);
  388. bool msi_enabled;
  389. struct {
  390. struct drm_global_reference mem_global_ref;
  391. struct ttm_bo_global_ref bo_global_ref;
  392. struct ttm_bo_device bdev;
  393. atomic_t validate_sequence;
  394. int (*move)(struct nouveau_channel *,
  395. struct ttm_buffer_object *,
  396. struct ttm_mem_reg *, struct ttm_mem_reg *);
  397. } ttm;
  398. struct {
  399. spinlock_t lock;
  400. struct drm_mm heap;
  401. struct nouveau_bo *bo;
  402. } fence;
  403. struct {
  404. spinlock_t lock;
  405. struct nouveau_channel *ptr[NOUVEAU_MAX_CHANNEL_NR];
  406. } channels;
  407. struct nouveau_engine engine;
  408. struct nouveau_channel *channel;
  409. /* For PFIFO and PGRAPH. */
  410. spinlock_t context_switch_lock;
  411. /* VM/PRAMIN flush, legacy PRAMIN aperture */
  412. spinlock_t vm_lock;
  413. /* RAMIN configuration, RAMFC, RAMHT and RAMRO offsets */
  414. struct nouveau_ramht *ramht;
  415. struct {
  416. enum {
  417. NOUVEAU_GART_NONE = 0,
  418. NOUVEAU_GART_AGP, /* AGP */
  419. NOUVEAU_GART_PDMA, /* paged dma object */
  420. NOUVEAU_GART_HW /* on-chip gart/vm */
  421. } type;
  422. uint64_t aper_base;
  423. uint64_t aper_size;
  424. uint64_t aper_free;
  425. struct ttm_backend_func *func;
  426. struct nouveau_gpuobj *sg_ctxdma;
  427. } gart_info;
  428. /* nv10-nv40 tiling regions */
  429. struct {
  430. struct nouveau_tile_reg reg[NOUVEAU_MAX_TILE_NR];
  431. spinlock_t lock;
  432. } tile;
  433. uint64_t fb_available_size;
  434. uint64_t fb_mappable_pages;
  435. uint64_t fb_aper_free;
  436. int fb_mtrr;
  437. /* G8x/G9x virtual address space */
  438. struct nouveau_vm *chan_vm;
  439. struct nvbios vbios;
  440. u8 *mxms;
  441. struct list_head i2c_ports;
  442. struct backlight_device *backlight;
  443. struct {
  444. struct dentry *channel_root;
  445. } debugfs;
  446. struct nouveau_fbdev *nfbdev;
  447. struct apertures_struct *apertures;
  448. };
  449. static inline struct drm_nouveau_private *
  450. nouveau_private(struct drm_device *dev)
  451. {
  452. return dev->dev_private;
  453. }
  454. static inline struct drm_nouveau_private *
  455. nouveau_bdev(struct ttm_bo_device *bd)
  456. {
  457. return container_of(bd, struct drm_nouveau_private, ttm.bdev);
  458. }
  459. /* nouveau_drv.c */
  460. extern int nouveau_modeset;
  461. extern int nouveau_duallink;
  462. extern int nouveau_uscript_lvds;
  463. extern int nouveau_uscript_tmds;
  464. extern int nouveau_vram_pushbuf;
  465. extern int nouveau_vram_notify;
  466. extern char *nouveau_vram_type;
  467. extern int nouveau_fbpercrtc;
  468. extern int nouveau_tv_disable;
  469. extern char *nouveau_tv_norm;
  470. extern int nouveau_reg_debug;
  471. extern int nouveau_ignorelid;
  472. extern int nouveau_nofbaccel;
  473. extern int nouveau_noaccel;
  474. extern int nouveau_force_post;
  475. extern int nouveau_override_conntype;
  476. extern char *nouveau_perflvl;
  477. extern int nouveau_perflvl_wr;
  478. extern int nouveau_msi;
  479. extern int nouveau_ctxfw;
  480. extern int nouveau_mxmdcb;
  481. extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state);
  482. extern int nouveau_pci_resume(struct pci_dev *pdev);
  483. /* nouveau_state.c */
  484. extern int nouveau_open(struct drm_device *, struct drm_file *);
  485. extern void nouveau_preclose(struct drm_device *dev, struct drm_file *);
  486. extern void nouveau_postclose(struct drm_device *, struct drm_file *);
  487. extern int nouveau_load(struct drm_device *, unsigned long flags);
  488. extern int nouveau_firstopen(struct drm_device *);
  489. extern void nouveau_lastclose(struct drm_device *);
  490. extern int nouveau_unload(struct drm_device *);
  491. extern bool nouveau_wait_for_idle(struct drm_device *);
  492. extern int nouveau_card_init(struct drm_device *);
  493. /* nouveau_mem.c */
  494. extern int nouveau_mem_vram_init(struct drm_device *);
  495. extern void nouveau_mem_vram_fini(struct drm_device *);
  496. extern int nouveau_mem_gart_init(struct drm_device *);
  497. extern void nouveau_mem_gart_fini(struct drm_device *);
  498. extern void nouveau_mem_close(struct drm_device *);
  499. extern bool nouveau_mem_flags_valid(struct drm_device *, u32 tile_flags);
  500. extern int nouveau_mem_timing_calc(struct drm_device *, u32 freq,
  501. struct nouveau_pm_memtiming *);
  502. extern void nouveau_mem_timing_read(struct drm_device *,
  503. struct nouveau_pm_memtiming *);
  504. extern int nouveau_mem_vbios_type(struct drm_device *);
  505. extern struct nouveau_tile_reg *nv10_mem_set_tiling(
  506. struct drm_device *dev, uint32_t addr, uint32_t size,
  507. uint32_t pitch, uint32_t flags);
  508. extern void nv10_mem_put_tile_region(struct drm_device *dev,
  509. struct nouveau_tile_reg *tile,
  510. struct nouveau_fence *fence);
  511. extern const struct ttm_mem_type_manager_func nouveau_vram_manager;
  512. extern const struct ttm_mem_type_manager_func nouveau_gart_manager;
  513. extern const struct ttm_mem_type_manager_func nv04_gart_manager;
  514. /* nouveau_notifier.c */
  515. extern int nouveau_notifier_init_channel(struct nouveau_channel *);
  516. extern void nouveau_notifier_takedown_channel(struct nouveau_channel *);
  517. extern int nouveau_notifier_alloc(struct nouveau_channel *, uint32_t handle,
  518. int cout, uint32_t start, uint32_t end,
  519. uint32_t *offset);
  520. /* nouveau_channel.c */
  521. extern void nouveau_channel_cleanup(struct drm_device *, struct drm_file *);
  522. extern int nouveau_channel_alloc(struct drm_device *dev,
  523. struct nouveau_channel **chan,
  524. struct drm_file *file_priv,
  525. uint32_t fb_ctxdma, uint32_t tt_ctxdma);
  526. extern struct nouveau_channel *
  527. nouveau_channel_get_unlocked(struct nouveau_channel *);
  528. extern struct nouveau_channel *
  529. nouveau_channel_get(struct drm_file *, int id);
  530. extern void nouveau_channel_put_unlocked(struct nouveau_channel **);
  531. extern void nouveau_channel_put(struct nouveau_channel **);
  532. extern void nouveau_channel_ref(struct nouveau_channel *chan,
  533. struct nouveau_channel **pchan);
  534. extern int nouveau_channel_idle(struct nouveau_channel *chan);
  535. /* nouveau_gpuobj.c */
  536. #define NVOBJ_ENGINE_ADD(d, e, p) do { \
  537. struct drm_nouveau_private *dev_priv = (d)->dev_private; \
  538. dev_priv->eng[NVOBJ_ENGINE_##e] = (p); \
  539. } while (0)
  540. #define NVOBJ_ENGINE_DEL(d, e) do { \
  541. struct drm_nouveau_private *dev_priv = (d)->dev_private; \
  542. dev_priv->eng[NVOBJ_ENGINE_##e] = NULL; \
  543. } while (0)
  544. #define NVOBJ_CLASS(d, c, e) do { \
  545. int ret = nouveau_gpuobj_class_new((d), (c), NVOBJ_ENGINE_##e); \
  546. if (ret) \
  547. return ret; \
  548. } while (0)
  549. #define NVOBJ_MTHD(d, c, m, e) do { \
  550. int ret = nouveau_gpuobj_mthd_new((d), (c), (m), (e)); \
  551. if (ret) \
  552. return ret; \
  553. } while (0)
  554. extern int nouveau_gpuobj_class_new(struct drm_device *, u32 class, u32 eng);
  555. extern int nouveau_gpuobj_mthd_new(struct drm_device *, u32 class, u32 mthd,
  556. int (*exec)(struct nouveau_channel *,
  557. u32 class, u32 mthd, u32 data));
  558. extern int nouveau_gpuobj_mthd_call(struct nouveau_channel *, u32, u32, u32);
  559. extern int nouveau_gpuobj_mthd_call2(struct drm_device *, int, u32, u32, u32);
  560. extern int nouveau_gpuobj_channel_init(struct nouveau_channel *,
  561. uint32_t vram_h, uint32_t tt_h);
  562. extern void nouveau_gpuobj_channel_takedown(struct nouveau_channel *);
  563. extern int nouveau_gpuobj_dma_new(struct nouveau_channel *, int class,
  564. uint64_t offset, uint64_t size, int access,
  565. int target, struct nouveau_gpuobj **);
  566. extern int nouveau_gpuobj_gr_new(struct nouveau_channel *, u32 handle, int class);
  567. extern int nv50_gpuobj_dma_new(struct nouveau_channel *, int class, u64 base,
  568. u64 size, int target, int access, u32 type,
  569. u32 comp, struct nouveau_gpuobj **pobj);
  570. extern void nv50_gpuobj_dma_init(struct nouveau_gpuobj *, u32 offset,
  571. int class, u64 base, u64 size, int target,
  572. int access, u32 type, u32 comp);
  573. int nouveau_gpuobj_map_vm(struct nouveau_gpuobj *gpuobj, struct nouveau_vm *vm,
  574. u32 flags, struct nouveau_vma *vma);
  575. void nouveau_gpuobj_unmap(struct nouveau_vma *vma);
  576. /* nouveau_irq.c */
  577. extern int nouveau_irq_init(struct drm_device *);
  578. extern void nouveau_irq_fini(struct drm_device *);
  579. extern irqreturn_t nouveau_irq_handler(DRM_IRQ_ARGS);
  580. extern void nouveau_irq_register(struct drm_device *, int status_bit,
  581. void (*)(struct drm_device *));
  582. extern void nouveau_irq_unregister(struct drm_device *, int status_bit);
  583. extern void nouveau_irq_preinstall(struct drm_device *);
  584. extern int nouveau_irq_postinstall(struct drm_device *);
  585. extern void nouveau_irq_uninstall(struct drm_device *);
  586. /* nouveau_sgdma.c */
  587. extern int nouveau_sgdma_init(struct drm_device *);
  588. extern void nouveau_sgdma_takedown(struct drm_device *);
  589. extern uint32_t nouveau_sgdma_get_physical(struct drm_device *,
  590. uint32_t offset);
  591. extern struct ttm_tt *nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
  592. unsigned long size,
  593. uint32_t page_flags,
  594. struct page *dummy_read_page);
  595. /* nouveau_debugfs.c */
  596. #if defined(CONFIG_DRM_NOUVEAU_DEBUG)
  597. extern int nouveau_debugfs_init(struct drm_minor *);
  598. extern void nouveau_debugfs_takedown(struct drm_minor *);
  599. extern int nouveau_debugfs_channel_init(struct nouveau_channel *);
  600. extern void nouveau_debugfs_channel_fini(struct nouveau_channel *);
  601. #else
  602. static inline int
  603. nouveau_debugfs_init(struct drm_minor *minor)
  604. {
  605. return 0;
  606. }
  607. static inline void nouveau_debugfs_takedown(struct drm_minor *minor)
  608. {
  609. }
  610. static inline int
  611. nouveau_debugfs_channel_init(struct nouveau_channel *chan)
  612. {
  613. return 0;
  614. }
  615. static inline void
  616. nouveau_debugfs_channel_fini(struct nouveau_channel *chan)
  617. {
  618. }
  619. #endif
  620. /* nouveau_dma.c */
  621. extern void nouveau_dma_init(struct nouveau_channel *);
  622. extern int nouveau_dma_wait(struct nouveau_channel *, int slots, int size);
  623. /* nouveau_acpi.c */
  624. #define ROM_BIOS_PAGE 4096
  625. #if defined(CONFIG_ACPI)
  626. void nouveau_register_dsm_handler(void);
  627. void nouveau_unregister_dsm_handler(void);
  628. void nouveau_switcheroo_optimus_dsm(void);
  629. int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len);
  630. bool nouveau_acpi_rom_supported(struct pci_dev *pdev);
  631. int nouveau_acpi_edid(struct drm_device *, struct drm_connector *);
  632. #else
  633. static inline void nouveau_register_dsm_handler(void) {}
  634. static inline void nouveau_unregister_dsm_handler(void) {}
  635. static inline void nouveau_switcheroo_optimus_dsm(void) {}
  636. static inline bool nouveau_acpi_rom_supported(struct pci_dev *pdev) { return false; }
  637. static inline int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len) { return -EINVAL; }
  638. static inline int nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return -EINVAL; }
  639. #endif
  640. /* nouveau_backlight.c */
  641. #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
  642. extern int nouveau_backlight_init(struct drm_device *);
  643. extern void nouveau_backlight_exit(struct drm_device *);
  644. #else
  645. static inline int nouveau_backlight_init(struct drm_device *dev)
  646. {
  647. return 0;
  648. }
  649. static inline void nouveau_backlight_exit(struct drm_device *dev) { }
  650. #endif
  651. /* nouveau_bios.c */
  652. extern int nouveau_bios_init(struct drm_device *);
  653. extern void nouveau_bios_takedown(struct drm_device *dev);
  654. extern int nouveau_run_vbios_init(struct drm_device *);
  655. extern struct dcb_connector_table_entry *
  656. nouveau_bios_connector_entry(struct drm_device *, int index);
  657. extern int nouveau_bios_run_display_table(struct drm_device *, u16 id, int clk,
  658. struct dcb_output *, int crtc);
  659. extern bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *);
  660. extern uint8_t *nouveau_bios_embedded_edid(struct drm_device *);
  661. extern int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk,
  662. bool *dl, bool *if_is_24bit);
  663. extern int run_tmds_table(struct drm_device *, struct dcb_output *,
  664. int head, int pxclk);
  665. extern int call_lvds_script(struct drm_device *, struct dcb_output *, int head,
  666. enum LVDS_script, int pxclk);
  667. bool bios_encoder_match(struct dcb_output *, u32 hash);
  668. /* nouveau_mxm.c */
  669. int nouveau_mxm_init(struct drm_device *dev);
  670. void nouveau_mxm_fini(struct drm_device *dev);
  671. /* nouveau_ttm.c */
  672. int nouveau_ttm_global_init(struct drm_nouveau_private *);
  673. void nouveau_ttm_global_release(struct drm_nouveau_private *);
  674. int nouveau_ttm_mmap(struct file *, struct vm_area_struct *);
  675. /* nouveau_hdmi.c */
  676. void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
  677. /* nv04_graph.c */
  678. extern int nv04_graph_create(struct drm_device *);
  679. extern int nv04_graph_object_new(struct nouveau_channel *, int, u32, u16);
  680. extern int nv04_graph_mthd_page_flip(struct nouveau_channel *chan,
  681. u32 class, u32 mthd, u32 data);
  682. extern struct nouveau_bitfield nv04_graph_nsource[];
  683. /* nv10_graph.c */
  684. extern int nv10_graph_create(struct drm_device *);
  685. extern struct nouveau_channel *nv10_graph_channel(struct drm_device *);
  686. extern struct nouveau_bitfield nv10_graph_intr[];
  687. extern struct nouveau_bitfield nv10_graph_nstatus[];
  688. /* nv20_graph.c */
  689. extern int nv20_graph_create(struct drm_device *);
  690. /* nv40_graph.c */
  691. extern int nv40_graph_create(struct drm_device *);
  692. extern void nv40_grctx_init(struct drm_device *, u32 *size);
  693. extern void nv40_grctx_fill(struct drm_device *, struct nouveau_gpuobj *);
  694. /* nv50_graph.c */
  695. extern int nv50_graph_create(struct drm_device *);
  696. extern struct nouveau_enum nv50_data_error_names[];
  697. extern int nv50_graph_isr_chid(struct drm_device *dev, u64 inst);
  698. extern int nv50_grctx_init(struct drm_device *, u32 *, u32, u32 *, u32 *);
  699. extern void nv50_grctx_fill(struct drm_device *, struct nouveau_gpuobj *);
  700. /* nvc0_graph.c */
  701. extern int nvc0_graph_create(struct drm_device *);
  702. extern int nvc0_graph_isr_chid(struct drm_device *dev, u64 inst);
  703. /* nve0_graph.c */
  704. extern int nve0_graph_create(struct drm_device *);
  705. /* nv84_crypt.c */
  706. extern int nv84_crypt_create(struct drm_device *);
  707. /* nv98_crypt.c */
  708. extern int nv98_crypt_create(struct drm_device *dev);
  709. /* nva3_copy.c */
  710. extern int nva3_copy_create(struct drm_device *dev);
  711. /* nvc0_copy.c */
  712. extern int nvc0_copy_create(struct drm_device *dev, int engine);
  713. /* nv31_mpeg.c */
  714. extern int nv31_mpeg_create(struct drm_device *dev);
  715. /* nv50_mpeg.c */
  716. extern int nv50_mpeg_create(struct drm_device *dev);
  717. /* nv84_bsp.c */
  718. /* nv98_bsp.c */
  719. extern int nv84_bsp_create(struct drm_device *dev);
  720. /* nv84_vp.c */
  721. /* nv98_vp.c */
  722. extern int nv84_vp_create(struct drm_device *dev);
  723. /* nv98_ppp.c */
  724. extern int nv98_ppp_create(struct drm_device *dev);
  725. extern long nouveau_compat_ioctl(struct file *file, unsigned int cmd,
  726. unsigned long arg);
  727. /* nvd0_display.c */
  728. extern int nvd0_display_create(struct drm_device *);
  729. extern void nvd0_display_destroy(struct drm_device *);
  730. extern int nvd0_display_init(struct drm_device *);
  731. extern void nvd0_display_fini(struct drm_device *);
  732. struct nouveau_bo *nvd0_display_crtc_sema(struct drm_device *, int crtc);
  733. void nvd0_display_flip_stop(struct drm_crtc *);
  734. int nvd0_display_flip_next(struct drm_crtc *, struct drm_framebuffer *,
  735. struct nouveau_channel *, u32 swap_interval);
  736. /* nouveau_gem.c */
  737. extern int nouveau_gem_new(struct drm_device *, int size, int align,
  738. uint32_t domain, uint32_t tile_mode,
  739. uint32_t tile_flags, struct nouveau_bo **);
  740. extern int nouveau_gem_object_new(struct drm_gem_object *);
  741. extern void nouveau_gem_object_del(struct drm_gem_object *);
  742. extern int nouveau_gem_object_open(struct drm_gem_object *, struct drm_file *);
  743. extern void nouveau_gem_object_close(struct drm_gem_object *,
  744. struct drm_file *);
  745. extern int nouveau_gem_ioctl_new(struct drm_device *, void *,
  746. struct drm_file *);
  747. extern int nouveau_gem_ioctl_pushbuf(struct drm_device *, void *,
  748. struct drm_file *);
  749. extern int nouveau_gem_ioctl_cpu_prep(struct drm_device *, void *,
  750. struct drm_file *);
  751. extern int nouveau_gem_ioctl_cpu_fini(struct drm_device *, void *,
  752. struct drm_file *);
  753. extern int nouveau_gem_ioctl_info(struct drm_device *, void *,
  754. struct drm_file *);
  755. extern struct dma_buf *nouveau_gem_prime_export(struct drm_device *dev,
  756. struct drm_gem_object *obj, int flags);
  757. extern struct drm_gem_object *nouveau_gem_prime_import(struct drm_device *dev,
  758. struct dma_buf *dma_buf);
  759. /* nouveau_display.c */
  760. int nouveau_display_create(struct drm_device *dev);
  761. void nouveau_display_destroy(struct drm_device *dev);
  762. int nouveau_display_init(struct drm_device *dev);
  763. void nouveau_display_fini(struct drm_device *dev);
  764. int nouveau_vblank_enable(struct drm_device *dev, int crtc);
  765. void nouveau_vblank_disable(struct drm_device *dev, int crtc);
  766. int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
  767. struct drm_pending_vblank_event *event);
  768. int nouveau_finish_page_flip(struct nouveau_channel *,
  769. struct nouveau_page_flip_state *);
  770. int nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
  771. struct drm_mode_create_dumb *args);
  772. int nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
  773. uint32_t handle, uint64_t *offset);
  774. int nouveau_display_dumb_destroy(struct drm_file *, struct drm_device *,
  775. uint32_t handle);
  776. #ifndef ioread32_native
  777. #ifdef __BIG_ENDIAN
  778. #define ioread16_native ioread16be
  779. #define iowrite16_native iowrite16be
  780. #define ioread32_native ioread32be
  781. #define iowrite32_native iowrite32be
  782. #else /* def __BIG_ENDIAN */
  783. #define ioread16_native ioread16
  784. #define iowrite16_native iowrite16
  785. #define ioread32_native ioread32
  786. #define iowrite32_native iowrite32
  787. #endif /* def __BIG_ENDIAN else */
  788. #endif /* !ioread32_native */
  789. /* channel control reg access */
  790. static inline u32 nvchan_rd32(struct nouveau_channel *chan, unsigned reg)
  791. {
  792. return ioread32_native(chan->user + reg);
  793. }
  794. static inline void nvchan_wr32(struct nouveau_channel *chan,
  795. unsigned reg, u32 val)
  796. {
  797. iowrite32_native(val, chan->user + reg);
  798. }
  799. /* register access */
  800. #define nv_rd08 _nv_rd08
  801. #define nv_wr08 _nv_wr08
  802. #define nv_rd32 _nv_rd32
  803. #define nv_wr32 _nv_wr32
  804. #define nv_mask _nv_mask
  805. #define nv_wait(dev, reg, mask, val) \
  806. nouveau_wait_eq(dev, 2000000000ULL, (reg), (mask), (val))
  807. #define nv_wait_ne(dev, reg, mask, val) \
  808. nouveau_wait_ne(dev, 2000000000ULL, (reg), (mask), (val))
  809. #define nv_wait_cb(dev, func, data) \
  810. nouveau_wait_cb(dev, 2000000000ULL, (func), (data))
  811. /*
  812. * Logging
  813. * Argument d is (struct drm_device *).
  814. */
  815. #define NV_PRINTK(level, d, fmt, arg...) \
  816. printk(level "[" DRM_NAME "] " DRIVER_NAME " %s: " fmt, \
  817. pci_name(d->pdev), ##arg)
  818. #ifndef NV_DEBUG_NOTRACE
  819. #define NV_DEBUG(d, fmt, arg...) do { \
  820. if (drm_debug & DRM_UT_DRIVER) { \
  821. NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \
  822. __LINE__, ##arg); \
  823. } \
  824. } while (0)
  825. #define NV_DEBUG_KMS(d, fmt, arg...) do { \
  826. if (drm_debug & DRM_UT_KMS) { \
  827. NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \
  828. __LINE__, ##arg); \
  829. } \
  830. } while (0)
  831. #else
  832. #define NV_DEBUG(d, fmt, arg...) do { \
  833. if (drm_debug & DRM_UT_DRIVER) \
  834. NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \
  835. } while (0)
  836. #define NV_DEBUG_KMS(d, fmt, arg...) do { \
  837. if (drm_debug & DRM_UT_KMS) \
  838. NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \
  839. } while (0)
  840. #endif
  841. #define NV_ERROR(d, fmt, arg...) NV_PRINTK(KERN_ERR, d, fmt, ##arg)
  842. #define NV_INFO(d, fmt, arg...) NV_PRINTK(KERN_INFO, d, fmt, ##arg)
  843. #define NV_TRACEWARN(d, fmt, arg...) NV_PRINTK(KERN_NOTICE, d, fmt, ##arg)
  844. #define NV_TRACE(d, fmt, arg...) NV_PRINTK(KERN_INFO, d, fmt, ##arg)
  845. #define NV_WARN(d, fmt, arg...) NV_PRINTK(KERN_WARNING, d, fmt, ##arg)
  846. #define NV_WARNONCE(d, fmt, arg...) do { \
  847. static int _warned = 0; \
  848. if (!_warned) { \
  849. NV_WARN(d, fmt, ##arg); \
  850. _warned = 1; \
  851. } \
  852. } while(0)
  853. /* nouveau_reg_debug bitmask */
  854. enum {
  855. NOUVEAU_REG_DEBUG_MC = 0x1,
  856. NOUVEAU_REG_DEBUG_VIDEO = 0x2,
  857. NOUVEAU_REG_DEBUG_FB = 0x4,
  858. NOUVEAU_REG_DEBUG_EXTDEV = 0x8,
  859. NOUVEAU_REG_DEBUG_CRTC = 0x10,
  860. NOUVEAU_REG_DEBUG_RAMDAC = 0x20,
  861. NOUVEAU_REG_DEBUG_VGACRTC = 0x40,
  862. NOUVEAU_REG_DEBUG_RMVIO = 0x80,
  863. NOUVEAU_REG_DEBUG_VGAATTR = 0x100,
  864. NOUVEAU_REG_DEBUG_EVO = 0x200,
  865. NOUVEAU_REG_DEBUG_AUXCH = 0x400
  866. };
  867. #define NV_REG_DEBUG(type, dev, fmt, arg...) do { \
  868. if (nouveau_reg_debug & NOUVEAU_REG_DEBUG_##type) \
  869. NV_PRINTK(KERN_DEBUG, dev, "%s: " fmt, __func__, ##arg); \
  870. } while (0)
  871. static inline bool
  872. nv_two_heads(struct drm_device *dev)
  873. {
  874. struct drm_nouveau_private *dev_priv = dev->dev_private;
  875. const int impl = dev->pci_device & 0x0ff0;
  876. if (dev_priv->card_type >= NV_10 && impl != 0x0100 &&
  877. impl != 0x0150 && impl != 0x01a0 && impl != 0x0200)
  878. return true;
  879. return false;
  880. }
  881. static inline bool
  882. nv_gf4_disp_arch(struct drm_device *dev)
  883. {
  884. return nv_two_heads(dev) && (dev->pci_device & 0x0ff0) != 0x0110;
  885. }
  886. static inline bool
  887. nv_two_reg_pll(struct drm_device *dev)
  888. {
  889. struct drm_nouveau_private *dev_priv = dev->dev_private;
  890. const int impl = dev->pci_device & 0x0ff0;
  891. if (impl == 0x0310 || impl == 0x0340 || dev_priv->card_type >= NV_40)
  892. return true;
  893. return false;
  894. }
  895. static inline bool
  896. nv_match_device(struct drm_device *dev, unsigned device,
  897. unsigned sub_vendor, unsigned sub_device)
  898. {
  899. return dev->pdev->device == device &&
  900. dev->pdev->subsystem_vendor == sub_vendor &&
  901. dev->pdev->subsystem_device == sub_device;
  902. }
  903. static inline void *
  904. nv_engine(struct drm_device *dev, int engine)
  905. {
  906. struct drm_nouveau_private *dev_priv = dev->dev_private;
  907. return (void *)dev_priv->eng[engine];
  908. }
  909. /* returns 1 if device is one of the nv4x using the 0x4497 object class,
  910. * helpful to determine a number of other hardware features
  911. */
  912. static inline int
  913. nv44_graph_class(struct drm_device *dev)
  914. {
  915. struct drm_nouveau_private *dev_priv = dev->dev_private;
  916. if ((dev_priv->chipset & 0xf0) == 0x60)
  917. return 1;
  918. return !(0x0baf & (1 << (dev_priv->chipset & 0x0f)));
  919. }
  920. /* memory type/access flags, do not match hardware values */
  921. #define NV_MEM_ACCESS_RO 1
  922. #define NV_MEM_ACCESS_WO 2
  923. #define NV_MEM_ACCESS_RW (NV_MEM_ACCESS_RO | NV_MEM_ACCESS_WO)
  924. #define NV_MEM_ACCESS_SYS 4
  925. #define NV_MEM_ACCESS_VM 8
  926. #define NV_MEM_ACCESS_NOSNOOP 16
  927. #define NV_MEM_TARGET_VRAM 0
  928. #define NV_MEM_TARGET_PCI 1
  929. #define NV_MEM_TARGET_PCI_NOSNOOP 2
  930. #define NV_MEM_TARGET_VM 3
  931. #define NV_MEM_TARGET_GART 4
  932. #define NV_MEM_TYPE_VM 0x7f
  933. #define NV_MEM_COMP_VM 0x03
  934. /* FIFO methods */
  935. #define NV01_SUBCHAN_OBJECT 0x00000000
  936. #define NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH 0x00000010
  937. #define NV84_SUBCHAN_SEMAPHORE_ADDRESS_LOW 0x00000014
  938. #define NV84_SUBCHAN_SEMAPHORE_SEQUENCE 0x00000018
  939. #define NV84_SUBCHAN_SEMAPHORE_TRIGGER 0x0000001c
  940. #define NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL 0x00000001
  941. #define NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG 0x00000002
  942. #define NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_GEQUAL 0x00000004
  943. #define NVC0_SUBCHAN_SEMAPHORE_TRIGGER_YIELD 0x00001000
  944. #define NV84_SUBCHAN_NOTIFY_INTR 0x00000020
  945. #define NV84_SUBCHAN_WRCACHE_FLUSH 0x00000024
  946. #define NV10_SUBCHAN_REF_CNT 0x00000050
  947. #define NVSW_SUBCHAN_PAGE_FLIP 0x00000054
  948. #define NV11_SUBCHAN_DMA_SEMAPHORE 0x00000060
  949. #define NV11_SUBCHAN_SEMAPHORE_OFFSET 0x00000064
  950. #define NV11_SUBCHAN_SEMAPHORE_ACQUIRE 0x00000068
  951. #define NV11_SUBCHAN_SEMAPHORE_RELEASE 0x0000006c
  952. #define NV40_SUBCHAN_YIELD 0x00000080
  953. /* NV_SW object class */
  954. #define NV_SW 0x0000506e
  955. #define NV_SW_DMA_VBLSEM 0x0000018c
  956. #define NV_SW_VBLSEM_OFFSET 0x00000400
  957. #define NV_SW_VBLSEM_RELEASE_VALUE 0x00000404
  958. #define NV_SW_VBLSEM_RELEASE 0x00000408
  959. #define NV_SW_PAGE_FLIP 0x00000500
  960. #endif /* __NOUVEAU_DRV_H__ */