radeon.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the 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. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #ifndef __RADEON_H__
  29. #define __RADEON_H__
  30. /* TODO: Here are things that needs to be done :
  31. * - surface allocator & initializer : (bit like scratch reg) should
  32. * initialize HDP_ stuff on RS600, R600, R700 hw, well anythings
  33. * related to surface
  34. * - WB : write back stuff (do it bit like scratch reg things)
  35. * - Vblank : look at Jesse's rework and what we should do
  36. * - r600/r700: gart & cp
  37. * - cs : clean cs ioctl use bitmap & things like that.
  38. * - power management stuff
  39. * - Barrier in gart code
  40. * - Unmappabled vram ?
  41. * - TESTING, TESTING, TESTING
  42. */
  43. /* Initialization path:
  44. * We expect that acceleration initialization might fail for various
  45. * reasons even thought we work hard to make it works on most
  46. * configurations. In order to still have a working userspace in such
  47. * situation the init path must succeed up to the memory controller
  48. * initialization point. Failure before this point are considered as
  49. * fatal error. Here is the init callchain :
  50. * radeon_device_init perform common structure, mutex initialization
  51. * asic_init setup the GPU memory layout and perform all
  52. * one time initialization (failure in this
  53. * function are considered fatal)
  54. * asic_startup setup the GPU acceleration, in order to
  55. * follow guideline the first thing this
  56. * function should do is setting the GPU
  57. * memory controller (only MC setup failure
  58. * are considered as fatal)
  59. */
  60. #include <asm/atomic.h>
  61. #include <linux/wait.h>
  62. #include <linux/list.h>
  63. #include <linux/kref.h>
  64. #include <ttm/ttm_bo_api.h>
  65. #include <ttm/ttm_bo_driver.h>
  66. #include <ttm/ttm_placement.h>
  67. #include <ttm/ttm_module.h>
  68. #include "radeon_family.h"
  69. #include "radeon_mode.h"
  70. #include "radeon_reg.h"
  71. /*
  72. * Modules parameters.
  73. */
  74. extern int radeon_no_wb;
  75. extern int radeon_modeset;
  76. extern int radeon_dynclks;
  77. extern int radeon_r4xx_atom;
  78. extern int radeon_agpmode;
  79. extern int radeon_vram_limit;
  80. extern int radeon_gart_size;
  81. extern int radeon_benchmarking;
  82. extern int radeon_testing;
  83. extern int radeon_connector_table;
  84. extern int radeon_tv;
  85. extern int radeon_new_pll;
  86. extern int radeon_audio;
  87. /*
  88. * Copy from radeon_drv.h so we don't have to include both and have conflicting
  89. * symbol;
  90. */
  91. #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
  92. /* RADEON_IB_POOL_SIZE must be a power of 2 */
  93. #define RADEON_IB_POOL_SIZE 16
  94. #define RADEON_DEBUGFS_MAX_NUM_FILES 32
  95. #define RADEONFB_CONN_LIMIT 4
  96. #define RADEON_BIOS_NUM_SCRATCH 8
  97. /*
  98. * Errata workarounds.
  99. */
  100. enum radeon_pll_errata {
  101. CHIP_ERRATA_R300_CG = 0x00000001,
  102. CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002,
  103. CHIP_ERRATA_PLL_DELAY = 0x00000004
  104. };
  105. struct radeon_device;
  106. /*
  107. * BIOS.
  108. */
  109. bool radeon_get_bios(struct radeon_device *rdev);
  110. /*
  111. * Dummy page
  112. */
  113. struct radeon_dummy_page {
  114. struct page *page;
  115. dma_addr_t addr;
  116. };
  117. int radeon_dummy_page_init(struct radeon_device *rdev);
  118. void radeon_dummy_page_fini(struct radeon_device *rdev);
  119. /*
  120. * Clocks
  121. */
  122. struct radeon_clock {
  123. struct radeon_pll p1pll;
  124. struct radeon_pll p2pll;
  125. struct radeon_pll spll;
  126. struct radeon_pll mpll;
  127. /* 10 Khz units */
  128. uint32_t default_mclk;
  129. uint32_t default_sclk;
  130. };
  131. /*
  132. * Power management
  133. */
  134. int radeon_pm_init(struct radeon_device *rdev);
  135. /*
  136. * Fences.
  137. */
  138. struct radeon_fence_driver {
  139. uint32_t scratch_reg;
  140. atomic_t seq;
  141. uint32_t last_seq;
  142. unsigned long count_timeout;
  143. wait_queue_head_t queue;
  144. rwlock_t lock;
  145. struct list_head created;
  146. struct list_head emited;
  147. struct list_head signaled;
  148. bool initialized;
  149. };
  150. struct radeon_fence {
  151. struct radeon_device *rdev;
  152. struct kref kref;
  153. struct list_head list;
  154. /* protected by radeon_fence.lock */
  155. uint32_t seq;
  156. unsigned long timeout;
  157. bool emited;
  158. bool signaled;
  159. };
  160. int radeon_fence_driver_init(struct radeon_device *rdev);
  161. void radeon_fence_driver_fini(struct radeon_device *rdev);
  162. int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence);
  163. int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence);
  164. void radeon_fence_process(struct radeon_device *rdev);
  165. bool radeon_fence_signaled(struct radeon_fence *fence);
  166. int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
  167. int radeon_fence_wait_next(struct radeon_device *rdev);
  168. int radeon_fence_wait_last(struct radeon_device *rdev);
  169. struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
  170. void radeon_fence_unref(struct radeon_fence **fence);
  171. /*
  172. * Tiling registers
  173. */
  174. struct radeon_surface_reg {
  175. struct radeon_bo *bo;
  176. };
  177. #define RADEON_GEM_MAX_SURFACES 8
  178. /*
  179. * TTM.
  180. */
  181. struct radeon_mman {
  182. struct ttm_bo_global_ref bo_global_ref;
  183. struct ttm_global_reference mem_global_ref;
  184. struct ttm_bo_device bdev;
  185. bool mem_global_referenced;
  186. bool initialized;
  187. };
  188. struct radeon_bo {
  189. /* Protected by gem.mutex */
  190. struct list_head list;
  191. /* Protected by tbo.reserved */
  192. u32 placements[3];
  193. struct ttm_placement placement;
  194. struct ttm_buffer_object tbo;
  195. struct ttm_bo_kmap_obj kmap;
  196. unsigned pin_count;
  197. void *kptr;
  198. u32 tiling_flags;
  199. u32 pitch;
  200. int surface_reg;
  201. /* Constant after initialization */
  202. struct radeon_device *rdev;
  203. struct drm_gem_object *gobj;
  204. };
  205. struct radeon_bo_list {
  206. struct list_head list;
  207. struct radeon_bo *bo;
  208. uint64_t gpu_offset;
  209. unsigned rdomain;
  210. unsigned wdomain;
  211. u32 tiling_flags;
  212. };
  213. /*
  214. * GEM objects.
  215. */
  216. struct radeon_gem {
  217. struct mutex mutex;
  218. struct list_head objects;
  219. };
  220. int radeon_gem_init(struct radeon_device *rdev);
  221. void radeon_gem_fini(struct radeon_device *rdev);
  222. int radeon_gem_object_create(struct radeon_device *rdev, int size,
  223. int alignment, int initial_domain,
  224. bool discardable, bool kernel,
  225. struct drm_gem_object **obj);
  226. int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain,
  227. uint64_t *gpu_addr);
  228. void radeon_gem_object_unpin(struct drm_gem_object *obj);
  229. /*
  230. * GART structures, functions & helpers
  231. */
  232. struct radeon_mc;
  233. struct radeon_gart_table_ram {
  234. volatile uint32_t *ptr;
  235. };
  236. struct radeon_gart_table_vram {
  237. struct radeon_bo *robj;
  238. volatile uint32_t *ptr;
  239. };
  240. union radeon_gart_table {
  241. struct radeon_gart_table_ram ram;
  242. struct radeon_gart_table_vram vram;
  243. };
  244. #define RADEON_GPU_PAGE_SIZE 4096
  245. struct radeon_gart {
  246. dma_addr_t table_addr;
  247. unsigned num_gpu_pages;
  248. unsigned num_cpu_pages;
  249. unsigned table_size;
  250. union radeon_gart_table table;
  251. struct page **pages;
  252. dma_addr_t *pages_addr;
  253. bool ready;
  254. };
  255. int radeon_gart_table_ram_alloc(struct radeon_device *rdev);
  256. void radeon_gart_table_ram_free(struct radeon_device *rdev);
  257. int radeon_gart_table_vram_alloc(struct radeon_device *rdev);
  258. void radeon_gart_table_vram_free(struct radeon_device *rdev);
  259. int radeon_gart_init(struct radeon_device *rdev);
  260. void radeon_gart_fini(struct radeon_device *rdev);
  261. void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
  262. int pages);
  263. int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
  264. int pages, struct page **pagelist);
  265. /*
  266. * GPU MC structures, functions & helpers
  267. */
  268. struct radeon_mc {
  269. resource_size_t aper_size;
  270. resource_size_t aper_base;
  271. resource_size_t agp_base;
  272. /* for some chips with <= 32MB we need to lie
  273. * about vram size near mc fb location */
  274. u64 mc_vram_size;
  275. u64 gtt_location;
  276. u64 gtt_size;
  277. u64 gtt_start;
  278. u64 gtt_end;
  279. u64 vram_location;
  280. u64 vram_start;
  281. u64 vram_end;
  282. unsigned vram_width;
  283. u64 real_vram_size;
  284. int vram_mtrr;
  285. bool vram_is_ddr;
  286. bool igp_sideport_enabled;
  287. };
  288. int radeon_mc_setup(struct radeon_device *rdev);
  289. bool radeon_combios_sideport_present(struct radeon_device *rdev);
  290. bool radeon_atombios_sideport_present(struct radeon_device *rdev);
  291. /*
  292. * GPU scratch registers structures, functions & helpers
  293. */
  294. struct radeon_scratch {
  295. unsigned num_reg;
  296. bool free[32];
  297. uint32_t reg[32];
  298. };
  299. int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg);
  300. void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg);
  301. /*
  302. * IRQS.
  303. */
  304. struct radeon_irq {
  305. bool installed;
  306. bool sw_int;
  307. /* FIXME: use a define max crtc rather than hardcode it */
  308. bool crtc_vblank_int[2];
  309. /* FIXME: use defines for max hpd/dacs */
  310. bool hpd[6];
  311. spinlock_t sw_lock;
  312. int sw_refcount;
  313. };
  314. int radeon_irq_kms_init(struct radeon_device *rdev);
  315. void radeon_irq_kms_fini(struct radeon_device *rdev);
  316. void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev);
  317. void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev);
  318. /*
  319. * CP & ring.
  320. */
  321. struct radeon_ib {
  322. struct list_head list;
  323. unsigned idx;
  324. uint64_t gpu_addr;
  325. struct radeon_fence *fence;
  326. uint32_t *ptr;
  327. uint32_t length_dw;
  328. bool free;
  329. };
  330. /*
  331. * locking -
  332. * mutex protects scheduled_ibs, ready, alloc_bm
  333. */
  334. struct radeon_ib_pool {
  335. struct mutex mutex;
  336. struct radeon_bo *robj;
  337. struct radeon_ib ibs[RADEON_IB_POOL_SIZE];
  338. bool ready;
  339. unsigned head_id;
  340. };
  341. struct radeon_cp {
  342. struct radeon_bo *ring_obj;
  343. volatile uint32_t *ring;
  344. unsigned rptr;
  345. unsigned wptr;
  346. unsigned wptr_old;
  347. unsigned ring_size;
  348. unsigned ring_free_dw;
  349. int count_dw;
  350. uint64_t gpu_addr;
  351. uint32_t align_mask;
  352. uint32_t ptr_mask;
  353. struct mutex mutex;
  354. bool ready;
  355. };
  356. /*
  357. * R6xx+ IH ring
  358. */
  359. struct r600_ih {
  360. struct radeon_bo *ring_obj;
  361. volatile uint32_t *ring;
  362. unsigned rptr;
  363. unsigned wptr;
  364. unsigned wptr_old;
  365. unsigned ring_size;
  366. uint64_t gpu_addr;
  367. uint32_t ptr_mask;
  368. spinlock_t lock;
  369. bool enabled;
  370. };
  371. struct r600_blit {
  372. struct mutex mutex;
  373. struct radeon_bo *shader_obj;
  374. u64 shader_gpu_addr;
  375. u32 vs_offset, ps_offset;
  376. u32 state_offset;
  377. u32 state_len;
  378. u32 vb_used, vb_total;
  379. struct radeon_ib *vb_ib;
  380. };
  381. int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib);
  382. void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib);
  383. int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib);
  384. int radeon_ib_pool_init(struct radeon_device *rdev);
  385. void radeon_ib_pool_fini(struct radeon_device *rdev);
  386. int radeon_ib_test(struct radeon_device *rdev);
  387. /* Ring access between begin & end cannot sleep */
  388. void radeon_ring_free_size(struct radeon_device *rdev);
  389. int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw);
  390. void radeon_ring_unlock_commit(struct radeon_device *rdev);
  391. void radeon_ring_unlock_undo(struct radeon_device *rdev);
  392. int radeon_ring_test(struct radeon_device *rdev);
  393. int radeon_ring_init(struct radeon_device *rdev, unsigned ring_size);
  394. void radeon_ring_fini(struct radeon_device *rdev);
  395. /*
  396. * CS.
  397. */
  398. struct radeon_cs_reloc {
  399. struct drm_gem_object *gobj;
  400. struct radeon_bo *robj;
  401. struct radeon_bo_list lobj;
  402. uint32_t handle;
  403. uint32_t flags;
  404. };
  405. struct radeon_cs_chunk {
  406. uint32_t chunk_id;
  407. uint32_t length_dw;
  408. int kpage_idx[2];
  409. uint32_t *kpage[2];
  410. uint32_t *kdata;
  411. void __user *user_ptr;
  412. int last_copied_page;
  413. int last_page_index;
  414. };
  415. struct radeon_cs_parser {
  416. struct device *dev;
  417. struct radeon_device *rdev;
  418. struct drm_file *filp;
  419. /* chunks */
  420. unsigned nchunks;
  421. struct radeon_cs_chunk *chunks;
  422. uint64_t *chunks_array;
  423. /* IB */
  424. unsigned idx;
  425. /* relocations */
  426. unsigned nrelocs;
  427. struct radeon_cs_reloc *relocs;
  428. struct radeon_cs_reloc **relocs_ptr;
  429. struct list_head validated;
  430. /* indices of various chunks */
  431. int chunk_ib_idx;
  432. int chunk_relocs_idx;
  433. struct radeon_ib *ib;
  434. void *track;
  435. unsigned family;
  436. int parser_error;
  437. };
  438. extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx);
  439. extern int radeon_cs_finish_pages(struct radeon_cs_parser *p);
  440. static inline u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
  441. {
  442. struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx];
  443. u32 pg_idx, pg_offset;
  444. u32 idx_value = 0;
  445. int new_page;
  446. pg_idx = (idx * 4) / PAGE_SIZE;
  447. pg_offset = (idx * 4) % PAGE_SIZE;
  448. if (ibc->kpage_idx[0] == pg_idx)
  449. return ibc->kpage[0][pg_offset/4];
  450. if (ibc->kpage_idx[1] == pg_idx)
  451. return ibc->kpage[1][pg_offset/4];
  452. new_page = radeon_cs_update_pages(p, pg_idx);
  453. if (new_page < 0) {
  454. p->parser_error = new_page;
  455. return 0;
  456. }
  457. idx_value = ibc->kpage[new_page][pg_offset/4];
  458. return idx_value;
  459. }
  460. struct radeon_cs_packet {
  461. unsigned idx;
  462. unsigned type;
  463. unsigned reg;
  464. unsigned opcode;
  465. int count;
  466. unsigned one_reg_wr;
  467. };
  468. typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p,
  469. struct radeon_cs_packet *pkt,
  470. unsigned idx, unsigned reg);
  471. typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p,
  472. struct radeon_cs_packet *pkt);
  473. /*
  474. * AGP
  475. */
  476. int radeon_agp_init(struct radeon_device *rdev);
  477. void radeon_agp_resume(struct radeon_device *rdev);
  478. void radeon_agp_fini(struct radeon_device *rdev);
  479. /*
  480. * Writeback
  481. */
  482. struct radeon_wb {
  483. struct radeon_bo *wb_obj;
  484. volatile uint32_t *wb;
  485. uint64_t gpu_addr;
  486. };
  487. /**
  488. * struct radeon_pm - power management datas
  489. * @max_bandwidth: maximum bandwidth the gpu has (MByte/s)
  490. * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880)
  491. * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880)
  492. * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880)
  493. * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880)
  494. * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP)
  495. * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
  496. * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP)
  497. * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP)
  498. * @sclk: GPU clock Mhz (core bandwith depends of this clock)
  499. * @needed_bandwidth: current bandwidth needs
  500. *
  501. * It keeps track of various data needed to take powermanagement decision.
  502. * Bandwith need is used to determine minimun clock of the GPU and memory.
  503. * Equation between gpu/memory clock and available bandwidth is hw dependent
  504. * (type of memory, bus size, efficiency, ...)
  505. */
  506. struct radeon_pm {
  507. fixed20_12 max_bandwidth;
  508. fixed20_12 igp_sideport_mclk;
  509. fixed20_12 igp_system_mclk;
  510. fixed20_12 igp_ht_link_clk;
  511. fixed20_12 igp_ht_link_width;
  512. fixed20_12 k8_bandwidth;
  513. fixed20_12 sideport_bandwidth;
  514. fixed20_12 ht_bandwidth;
  515. fixed20_12 core_bandwidth;
  516. fixed20_12 sclk;
  517. fixed20_12 needed_bandwidth;
  518. };
  519. /*
  520. * Benchmarking
  521. */
  522. void radeon_benchmark(struct radeon_device *rdev);
  523. /*
  524. * Testing
  525. */
  526. void radeon_test_moves(struct radeon_device *rdev);
  527. /*
  528. * Debugfs
  529. */
  530. int radeon_debugfs_add_files(struct radeon_device *rdev,
  531. struct drm_info_list *files,
  532. unsigned nfiles);
  533. int radeon_debugfs_fence_init(struct radeon_device *rdev);
  534. int r100_debugfs_rbbm_init(struct radeon_device *rdev);
  535. int r100_debugfs_cp_init(struct radeon_device *rdev);
  536. /*
  537. * ASIC specific functions.
  538. */
  539. struct radeon_asic {
  540. int (*init)(struct radeon_device *rdev);
  541. void (*fini)(struct radeon_device *rdev);
  542. int (*resume)(struct radeon_device *rdev);
  543. int (*suspend)(struct radeon_device *rdev);
  544. void (*vga_set_state)(struct radeon_device *rdev, bool state);
  545. int (*gpu_reset)(struct radeon_device *rdev);
  546. void (*gart_tlb_flush)(struct radeon_device *rdev);
  547. int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr);
  548. int (*cp_init)(struct radeon_device *rdev, unsigned ring_size);
  549. void (*cp_fini)(struct radeon_device *rdev);
  550. void (*cp_disable)(struct radeon_device *rdev);
  551. void (*cp_commit)(struct radeon_device *rdev);
  552. void (*ring_start)(struct radeon_device *rdev);
  553. int (*ring_test)(struct radeon_device *rdev);
  554. void (*ring_ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib);
  555. int (*irq_set)(struct radeon_device *rdev);
  556. int (*irq_process)(struct radeon_device *rdev);
  557. u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
  558. void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence);
  559. int (*cs_parse)(struct radeon_cs_parser *p);
  560. int (*copy_blit)(struct radeon_device *rdev,
  561. uint64_t src_offset,
  562. uint64_t dst_offset,
  563. unsigned num_pages,
  564. struct radeon_fence *fence);
  565. int (*copy_dma)(struct radeon_device *rdev,
  566. uint64_t src_offset,
  567. uint64_t dst_offset,
  568. unsigned num_pages,
  569. struct radeon_fence *fence);
  570. int (*copy)(struct radeon_device *rdev,
  571. uint64_t src_offset,
  572. uint64_t dst_offset,
  573. unsigned num_pages,
  574. struct radeon_fence *fence);
  575. uint32_t (*get_engine_clock)(struct radeon_device *rdev);
  576. void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
  577. uint32_t (*get_memory_clock)(struct radeon_device *rdev);
  578. void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock);
  579. void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
  580. void (*set_clock_gating)(struct radeon_device *rdev, int enable);
  581. int (*set_surface_reg)(struct radeon_device *rdev, int reg,
  582. uint32_t tiling_flags, uint32_t pitch,
  583. uint32_t offset, uint32_t obj_size);
  584. int (*clear_surface_reg)(struct radeon_device *rdev, int reg);
  585. void (*bandwidth_update)(struct radeon_device *rdev);
  586. void (*hpd_init)(struct radeon_device *rdev);
  587. void (*hpd_fini)(struct radeon_device *rdev);
  588. bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
  589. void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
  590. /* ioctl hw specific callback. Some hw might want to perform special
  591. * operation on specific ioctl. For instance on wait idle some hw
  592. * might want to perform and HDP flush through MMIO as it seems that
  593. * some R6XX/R7XX hw doesn't take HDP flush into account if programmed
  594. * through ring.
  595. */
  596. void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo *bo);
  597. };
  598. /*
  599. * Asic structures
  600. */
  601. struct r100_asic {
  602. const unsigned *reg_safe_bm;
  603. unsigned reg_safe_bm_size;
  604. u32 hdp_cntl;
  605. };
  606. struct r300_asic {
  607. const unsigned *reg_safe_bm;
  608. unsigned reg_safe_bm_size;
  609. u32 resync_scratch;
  610. u32 hdp_cntl;
  611. };
  612. struct r600_asic {
  613. unsigned max_pipes;
  614. unsigned max_tile_pipes;
  615. unsigned max_simds;
  616. unsigned max_backends;
  617. unsigned max_gprs;
  618. unsigned max_threads;
  619. unsigned max_stack_entries;
  620. unsigned max_hw_contexts;
  621. unsigned max_gs_threads;
  622. unsigned sx_max_export_size;
  623. unsigned sx_max_export_pos_size;
  624. unsigned sx_max_export_smx_size;
  625. unsigned sq_num_cf_insts;
  626. };
  627. struct rv770_asic {
  628. unsigned max_pipes;
  629. unsigned max_tile_pipes;
  630. unsigned max_simds;
  631. unsigned max_backends;
  632. unsigned max_gprs;
  633. unsigned max_threads;
  634. unsigned max_stack_entries;
  635. unsigned max_hw_contexts;
  636. unsigned max_gs_threads;
  637. unsigned sx_max_export_size;
  638. unsigned sx_max_export_pos_size;
  639. unsigned sx_max_export_smx_size;
  640. unsigned sq_num_cf_insts;
  641. unsigned sx_num_of_sets;
  642. unsigned sc_prim_fifo_size;
  643. unsigned sc_hiz_tile_fifo_size;
  644. unsigned sc_earlyz_tile_fifo_fize;
  645. };
  646. union radeon_asic_config {
  647. struct r300_asic r300;
  648. struct r100_asic r100;
  649. struct r600_asic r600;
  650. struct rv770_asic rv770;
  651. };
  652. /*
  653. * IOCTL.
  654. */
  655. int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
  656. struct drm_file *filp);
  657. int radeon_gem_create_ioctl(struct drm_device *dev, void *data,
  658. struct drm_file *filp);
  659. int radeon_gem_pin_ioctl(struct drm_device *dev, void *data,
  660. struct drm_file *file_priv);
  661. int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data,
  662. struct drm_file *file_priv);
  663. int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data,
  664. struct drm_file *file_priv);
  665. int radeon_gem_pread_ioctl(struct drm_device *dev, void *data,
  666. struct drm_file *file_priv);
  667. int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
  668. struct drm_file *filp);
  669. int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
  670. struct drm_file *filp);
  671. int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
  672. struct drm_file *filp);
  673. int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
  674. struct drm_file *filp);
  675. int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
  676. int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
  677. struct drm_file *filp);
  678. int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
  679. struct drm_file *filp);
  680. /*
  681. * Core structure, functions and helpers.
  682. */
  683. typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
  684. typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
  685. struct radeon_device {
  686. struct device *dev;
  687. struct drm_device *ddev;
  688. struct pci_dev *pdev;
  689. /* ASIC */
  690. union radeon_asic_config config;
  691. enum radeon_family family;
  692. unsigned long flags;
  693. int usec_timeout;
  694. enum radeon_pll_errata pll_errata;
  695. int num_gb_pipes;
  696. int num_z_pipes;
  697. int disp_priority;
  698. /* BIOS */
  699. uint8_t *bios;
  700. bool is_atom_bios;
  701. uint16_t bios_header_start;
  702. struct radeon_bo *stollen_vga_memory;
  703. struct fb_info *fbdev_info;
  704. struct radeon_bo *fbdev_rbo;
  705. struct radeon_framebuffer *fbdev_rfb;
  706. /* Register mmio */
  707. resource_size_t rmmio_base;
  708. resource_size_t rmmio_size;
  709. void *rmmio;
  710. radeon_rreg_t mc_rreg;
  711. radeon_wreg_t mc_wreg;
  712. radeon_rreg_t pll_rreg;
  713. radeon_wreg_t pll_wreg;
  714. uint32_t pcie_reg_mask;
  715. radeon_rreg_t pciep_rreg;
  716. radeon_wreg_t pciep_wreg;
  717. struct radeon_clock clock;
  718. struct radeon_mc mc;
  719. struct radeon_gart gart;
  720. struct radeon_mode_info mode_info;
  721. struct radeon_scratch scratch;
  722. struct radeon_mman mman;
  723. struct radeon_fence_driver fence_drv;
  724. struct radeon_cp cp;
  725. struct radeon_ib_pool ib_pool;
  726. struct radeon_irq irq;
  727. struct radeon_asic *asic;
  728. struct radeon_gem gem;
  729. struct radeon_pm pm;
  730. uint32_t bios_scratch[RADEON_BIOS_NUM_SCRATCH];
  731. struct mutex cs_mutex;
  732. struct radeon_wb wb;
  733. struct radeon_dummy_page dummy_page;
  734. bool gpu_lockup;
  735. bool shutdown;
  736. bool suspend;
  737. bool need_dma32;
  738. bool accel_working;
  739. struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
  740. const struct firmware *me_fw; /* all family ME firmware */
  741. const struct firmware *pfp_fw; /* r6/700 PFP firmware */
  742. const struct firmware *rlc_fw; /* r6/700 RLC firmware */
  743. struct r600_blit r600_blit;
  744. int msi_enabled; /* msi enabled */
  745. struct r600_ih ih; /* r6/700 interrupt ring */
  746. struct workqueue_struct *wq;
  747. struct work_struct hotplug_work;
  748. /* audio stuff */
  749. struct timer_list audio_timer;
  750. int audio_channels;
  751. int audio_rate;
  752. int audio_bits_per_sample;
  753. uint8_t audio_status_bits;
  754. uint8_t audio_category_code;
  755. };
  756. int radeon_device_init(struct radeon_device *rdev,
  757. struct drm_device *ddev,
  758. struct pci_dev *pdev,
  759. uint32_t flags);
  760. void radeon_device_fini(struct radeon_device *rdev);
  761. int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
  762. /* r600 blit */
  763. int r600_blit_prepare_copy(struct radeon_device *rdev, int size_bytes);
  764. void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence);
  765. void r600_kms_blit_copy(struct radeon_device *rdev,
  766. u64 src_gpu_addr, u64 dst_gpu_addr,
  767. int size_bytes);
  768. static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg)
  769. {
  770. if (reg < rdev->rmmio_size)
  771. return readl(((void __iomem *)rdev->rmmio) + reg);
  772. else {
  773. writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
  774. return readl(((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
  775. }
  776. }
  777. static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
  778. {
  779. if (reg < rdev->rmmio_size)
  780. writel(v, ((void __iomem *)rdev->rmmio) + reg);
  781. else {
  782. writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
  783. writel(v, ((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
  784. }
  785. }
  786. /*
  787. * Cast helper
  788. */
  789. #define to_radeon_fence(p) ((struct radeon_fence *)(p))
  790. /*
  791. * Registers read & write functions.
  792. */
  793. #define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg))
  794. #define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg))
  795. #define RREG32(reg) r100_mm_rreg(rdev, (reg))
  796. #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg)))
  797. #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v))
  798. #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  799. #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  800. #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
  801. #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
  802. #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
  803. #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
  804. #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
  805. #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
  806. #define WREG32_P(reg, val, mask) \
  807. do { \
  808. uint32_t tmp_ = RREG32(reg); \
  809. tmp_ &= (mask); \
  810. tmp_ |= ((val) & ~(mask)); \
  811. WREG32(reg, tmp_); \
  812. } while (0)
  813. #define WREG32_PLL_P(reg, val, mask) \
  814. do { \
  815. uint32_t tmp_ = RREG32_PLL(reg); \
  816. tmp_ &= (mask); \
  817. tmp_ |= ((val) & ~(mask)); \
  818. WREG32_PLL(reg, tmp_); \
  819. } while (0)
  820. #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg)))
  821. /*
  822. * Indirect registers accessor
  823. */
  824. static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
  825. {
  826. uint32_t r;
  827. WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
  828. r = RREG32(RADEON_PCIE_DATA);
  829. return r;
  830. }
  831. static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
  832. {
  833. WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
  834. WREG32(RADEON_PCIE_DATA, (v));
  835. }
  836. void r100_pll_errata_after_index(struct radeon_device *rdev);
  837. /*
  838. * ASICs helpers.
  839. */
  840. #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
  841. (rdev->pdev->device == 0x5969))
  842. #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
  843. (rdev->family == CHIP_RV200) || \
  844. (rdev->family == CHIP_RS100) || \
  845. (rdev->family == CHIP_RS200) || \
  846. (rdev->family == CHIP_RV250) || \
  847. (rdev->family == CHIP_RV280) || \
  848. (rdev->family == CHIP_RS300))
  849. #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \
  850. (rdev->family == CHIP_RV350) || \
  851. (rdev->family == CHIP_R350) || \
  852. (rdev->family == CHIP_RV380) || \
  853. (rdev->family == CHIP_R420) || \
  854. (rdev->family == CHIP_R423) || \
  855. (rdev->family == CHIP_RV410) || \
  856. (rdev->family == CHIP_RS400) || \
  857. (rdev->family == CHIP_RS480))
  858. #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
  859. #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
  860. #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
  861. /*
  862. * BIOS helpers.
  863. */
  864. #define RBIOS8(i) (rdev->bios[i])
  865. #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
  866. #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
  867. int radeon_combios_init(struct radeon_device *rdev);
  868. void radeon_combios_fini(struct radeon_device *rdev);
  869. int radeon_atombios_init(struct radeon_device *rdev);
  870. void radeon_atombios_fini(struct radeon_device *rdev);
  871. /*
  872. * RING helpers.
  873. */
  874. static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
  875. {
  876. #if DRM_DEBUG_CODE
  877. if (rdev->cp.count_dw <= 0) {
  878. DRM_ERROR("radeon: writting more dword to ring than expected !\n");
  879. }
  880. #endif
  881. rdev->cp.ring[rdev->cp.wptr++] = v;
  882. rdev->cp.wptr &= rdev->cp.ptr_mask;
  883. rdev->cp.count_dw--;
  884. rdev->cp.ring_free_dw--;
  885. }
  886. /*
  887. * ASICs macro.
  888. */
  889. #define radeon_init(rdev) (rdev)->asic->init((rdev))
  890. #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
  891. #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
  892. #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
  893. #define radeon_cs_parse(p) rdev->asic->cs_parse((p))
  894. #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
  895. #define radeon_gpu_reset(rdev) (rdev)->asic->gpu_reset((rdev))
  896. #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev))
  897. #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart_set_page((rdev), (i), (p))
  898. #define radeon_cp_commit(rdev) (rdev)->asic->cp_commit((rdev))
  899. #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev))
  900. #define radeon_ring_test(rdev) (rdev)->asic->ring_test((rdev))
  901. #define radeon_ring_ib_execute(rdev, ib) (rdev)->asic->ring_ib_execute((rdev), (ib))
  902. #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev))
  903. #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev))
  904. #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc))
  905. #define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence))
  906. #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f))
  907. #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f))
  908. #define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy((rdev), (s), (d), (np), (f))
  909. #define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev))
  910. #define radeon_set_engine_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e))
  911. #define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev))
  912. #define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_memory_clock((rdev), (e))
  913. #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l))
  914. #define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e))
  915. #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
  916. #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r)))
  917. #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
  918. #define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev))
  919. #define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev))
  920. #define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd))
  921. #define radeon_hpd_set_polarity(rdev, hpd) (rdev)->asic->hpd_set_polarity((rdev), (hpd))
  922. /* Common functions */
  923. /* AGP */
  924. extern void radeon_agp_disable(struct radeon_device *rdev);
  925. extern int radeon_gart_table_vram_pin(struct radeon_device *rdev);
  926. extern int radeon_modeset_init(struct radeon_device *rdev);
  927. extern void radeon_modeset_fini(struct radeon_device *rdev);
  928. extern bool radeon_card_posted(struct radeon_device *rdev);
  929. extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
  930. extern int radeon_clocks_init(struct radeon_device *rdev);
  931. extern void radeon_clocks_fini(struct radeon_device *rdev);
  932. extern void radeon_scratch_init(struct radeon_device *rdev);
  933. extern void radeon_surface_init(struct radeon_device *rdev);
  934. extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
  935. extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
  936. extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
  937. extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
  938. extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
  939. /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */
  940. struct r100_mc_save {
  941. u32 GENMO_WT;
  942. u32 CRTC_EXT_CNTL;
  943. u32 CRTC_GEN_CNTL;
  944. u32 CRTC2_GEN_CNTL;
  945. u32 CUR_OFFSET;
  946. u32 CUR2_OFFSET;
  947. };
  948. extern void r100_cp_disable(struct radeon_device *rdev);
  949. extern int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
  950. extern void r100_cp_fini(struct radeon_device *rdev);
  951. extern void r100_pci_gart_tlb_flush(struct radeon_device *rdev);
  952. extern int r100_pci_gart_init(struct radeon_device *rdev);
  953. extern void r100_pci_gart_fini(struct radeon_device *rdev);
  954. extern int r100_pci_gart_enable(struct radeon_device *rdev);
  955. extern void r100_pci_gart_disable(struct radeon_device *rdev);
  956. extern int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
  957. extern int r100_debugfs_mc_info_init(struct radeon_device *rdev);
  958. extern int r100_gui_wait_for_idle(struct radeon_device *rdev);
  959. extern void r100_ib_fini(struct radeon_device *rdev);
  960. extern int r100_ib_init(struct radeon_device *rdev);
  961. extern void r100_irq_disable(struct radeon_device *rdev);
  962. extern int r100_irq_set(struct radeon_device *rdev);
  963. extern void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save);
  964. extern void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save);
  965. extern void r100_vram_init_sizes(struct radeon_device *rdev);
  966. extern void r100_wb_disable(struct radeon_device *rdev);
  967. extern void r100_wb_fini(struct radeon_device *rdev);
  968. extern int r100_wb_init(struct radeon_device *rdev);
  969. extern void r100_hdp_reset(struct radeon_device *rdev);
  970. extern int r100_rb2d_reset(struct radeon_device *rdev);
  971. extern int r100_cp_reset(struct radeon_device *rdev);
  972. extern void r100_vga_render_disable(struct radeon_device *rdev);
  973. extern int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p,
  974. struct radeon_cs_packet *pkt,
  975. struct radeon_bo *robj);
  976. extern int r100_cs_parse_packet0(struct radeon_cs_parser *p,
  977. struct radeon_cs_packet *pkt,
  978. const unsigned *auth, unsigned n,
  979. radeon_packet0_check_t check);
  980. extern int r100_cs_packet_parse(struct radeon_cs_parser *p,
  981. struct radeon_cs_packet *pkt,
  982. unsigned idx);
  983. extern void r100_enable_bm(struct radeon_device *rdev);
  984. extern void r100_set_common_regs(struct radeon_device *rdev);
  985. /* rv200,rv250,rv280 */
  986. extern void r200_set_safe_registers(struct radeon_device *rdev);
  987. /* r300,r350,rv350,rv370,rv380 */
  988. extern void r300_set_reg_safe(struct radeon_device *rdev);
  989. extern void r300_mc_program(struct radeon_device *rdev);
  990. extern void r300_vram_info(struct radeon_device *rdev);
  991. extern void r300_clock_startup(struct radeon_device *rdev);
  992. extern int r300_mc_wait_for_idle(struct radeon_device *rdev);
  993. extern int rv370_pcie_gart_init(struct radeon_device *rdev);
  994. extern void rv370_pcie_gart_fini(struct radeon_device *rdev);
  995. extern int rv370_pcie_gart_enable(struct radeon_device *rdev);
  996. extern void rv370_pcie_gart_disable(struct radeon_device *rdev);
  997. /* r420,r423,rv410 */
  998. extern int r420_mc_init(struct radeon_device *rdev);
  999. extern u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg);
  1000. extern void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  1001. extern int r420_debugfs_pipes_info_init(struct radeon_device *rdev);
  1002. extern void r420_pipes_init(struct radeon_device *rdev);
  1003. /* rv515 */
  1004. struct rv515_mc_save {
  1005. u32 d1vga_control;
  1006. u32 d2vga_control;
  1007. u32 vga_render_control;
  1008. u32 vga_hdp_control;
  1009. u32 d1crtc_control;
  1010. u32 d2crtc_control;
  1011. };
  1012. extern void rv515_bandwidth_avivo_update(struct radeon_device *rdev);
  1013. extern void rv515_vga_render_disable(struct radeon_device *rdev);
  1014. extern void rv515_set_safe_registers(struct radeon_device *rdev);
  1015. extern void rv515_mc_stop(struct radeon_device *rdev, struct rv515_mc_save *save);
  1016. extern void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save);
  1017. extern void rv515_clock_startup(struct radeon_device *rdev);
  1018. extern void rv515_debugfs(struct radeon_device *rdev);
  1019. extern int rv515_suspend(struct radeon_device *rdev);
  1020. /* rs400 */
  1021. extern int rs400_gart_init(struct radeon_device *rdev);
  1022. extern int rs400_gart_enable(struct radeon_device *rdev);
  1023. extern void rs400_gart_adjust_size(struct radeon_device *rdev);
  1024. extern void rs400_gart_disable(struct radeon_device *rdev);
  1025. extern void rs400_gart_fini(struct radeon_device *rdev);
  1026. /* rs600 */
  1027. extern void rs600_set_safe_registers(struct radeon_device *rdev);
  1028. extern int rs600_irq_set(struct radeon_device *rdev);
  1029. extern void rs600_irq_disable(struct radeon_device *rdev);
  1030. /* rs690, rs740 */
  1031. extern void rs690_line_buffer_adjust(struct radeon_device *rdev,
  1032. struct drm_display_mode *mode1,
  1033. struct drm_display_mode *mode2);
  1034. /* r600, rv610, rv630, rv620, rv635, rv670, rs780, rs880 */
  1035. extern bool r600_card_posted(struct radeon_device *rdev);
  1036. extern void r600_cp_stop(struct radeon_device *rdev);
  1037. extern void r600_ring_init(struct radeon_device *rdev, unsigned ring_size);
  1038. extern int r600_cp_resume(struct radeon_device *rdev);
  1039. extern void r600_cp_fini(struct radeon_device *rdev);
  1040. extern int r600_count_pipe_bits(uint32_t val);
  1041. extern int r600_gart_clear_page(struct radeon_device *rdev, int i);
  1042. extern int r600_mc_wait_for_idle(struct radeon_device *rdev);
  1043. extern int r600_pcie_gart_init(struct radeon_device *rdev);
  1044. extern void r600_pcie_gart_tlb_flush(struct radeon_device *rdev);
  1045. extern int r600_ib_test(struct radeon_device *rdev);
  1046. extern int r600_ring_test(struct radeon_device *rdev);
  1047. extern void r600_wb_fini(struct radeon_device *rdev);
  1048. extern int r600_wb_enable(struct radeon_device *rdev);
  1049. extern void r600_wb_disable(struct radeon_device *rdev);
  1050. extern void r600_scratch_init(struct radeon_device *rdev);
  1051. extern int r600_blit_init(struct radeon_device *rdev);
  1052. extern void r600_blit_fini(struct radeon_device *rdev);
  1053. extern int r600_init_microcode(struct radeon_device *rdev);
  1054. extern int r600_gpu_reset(struct radeon_device *rdev);
  1055. /* r600 irq */
  1056. extern int r600_irq_init(struct radeon_device *rdev);
  1057. extern void r600_irq_fini(struct radeon_device *rdev);
  1058. extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size);
  1059. extern int r600_irq_set(struct radeon_device *rdev);
  1060. extern void r600_irq_suspend(struct radeon_device *rdev);
  1061. /* r600 audio */
  1062. extern int r600_audio_init(struct radeon_device *rdev);
  1063. extern int r600_audio_tmds_index(struct drm_encoder *encoder);
  1064. extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock);
  1065. extern void r600_audio_fini(struct radeon_device *rdev);
  1066. extern void r600_hdmi_init(struct drm_encoder *encoder);
  1067. extern void r600_hdmi_enable(struct drm_encoder *encoder, int enable);
  1068. extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
  1069. extern int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder);
  1070. extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder,
  1071. int channels,
  1072. int rate,
  1073. int bps,
  1074. uint8_t status_bits,
  1075. uint8_t category_code);
  1076. #include "radeon_object.h"
  1077. #endif