radeon.h 38 KB

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