radeon.h 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597
  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 <linux/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 <ttm/ttm_execbuf_util.h>
  69. #include "radeon_family.h"
  70. #include "radeon_mode.h"
  71. #include "radeon_reg.h"
  72. /*
  73. * Modules parameters.
  74. */
  75. extern int radeon_no_wb;
  76. extern int radeon_modeset;
  77. extern int radeon_dynclks;
  78. extern int radeon_r4xx_atom;
  79. extern int radeon_agpmode;
  80. extern int radeon_vram_limit;
  81. extern int radeon_gart_size;
  82. extern int radeon_benchmarking;
  83. extern int radeon_testing;
  84. extern int radeon_connector_table;
  85. extern int radeon_tv;
  86. extern int radeon_audio;
  87. extern int radeon_disp_priority;
  88. extern int radeon_hw_i2c;
  89. extern int radeon_pcie_gen2;
  90. extern int radeon_msi;
  91. /*
  92. * Copy from radeon_drv.h so we don't have to include both and have conflicting
  93. * symbol;
  94. */
  95. #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
  96. #define RADEON_FENCE_JIFFIES_TIMEOUT (HZ / 2)
  97. /* RADEON_IB_POOL_SIZE must be a power of 2 */
  98. #define RADEON_IB_POOL_SIZE 16
  99. #define RADEON_DEBUGFS_MAX_COMPONENTS 32
  100. #define RADEONFB_CONN_LIMIT 4
  101. #define RADEON_BIOS_NUM_SCRATCH 8
  102. /*
  103. * Errata workarounds.
  104. */
  105. enum radeon_pll_errata {
  106. CHIP_ERRATA_R300_CG = 0x00000001,
  107. CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002,
  108. CHIP_ERRATA_PLL_DELAY = 0x00000004
  109. };
  110. struct radeon_device;
  111. /*
  112. * BIOS.
  113. */
  114. #define ATRM_BIOS_PAGE 4096
  115. #if defined(CONFIG_VGA_SWITCHEROO)
  116. bool radeon_atrm_supported(struct pci_dev *pdev);
  117. int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len);
  118. #else
  119. static inline bool radeon_atrm_supported(struct pci_dev *pdev)
  120. {
  121. return false;
  122. }
  123. static inline int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len){
  124. return -EINVAL;
  125. }
  126. #endif
  127. bool radeon_get_bios(struct radeon_device *rdev);
  128. /*
  129. * Dummy page
  130. */
  131. struct radeon_dummy_page {
  132. struct page *page;
  133. dma_addr_t addr;
  134. };
  135. int radeon_dummy_page_init(struct radeon_device *rdev);
  136. void radeon_dummy_page_fini(struct radeon_device *rdev);
  137. /*
  138. * Clocks
  139. */
  140. struct radeon_clock {
  141. struct radeon_pll p1pll;
  142. struct radeon_pll p2pll;
  143. struct radeon_pll dcpll;
  144. struct radeon_pll spll;
  145. struct radeon_pll mpll;
  146. /* 10 Khz units */
  147. uint32_t default_mclk;
  148. uint32_t default_sclk;
  149. uint32_t default_dispclk;
  150. uint32_t dp_extclk;
  151. uint32_t max_pixel_clock;
  152. };
  153. /*
  154. * Power management
  155. */
  156. int radeon_pm_init(struct radeon_device *rdev);
  157. void radeon_pm_fini(struct radeon_device *rdev);
  158. void radeon_pm_compute_clocks(struct radeon_device *rdev);
  159. void radeon_pm_suspend(struct radeon_device *rdev);
  160. void radeon_pm_resume(struct radeon_device *rdev);
  161. void radeon_combios_get_power_modes(struct radeon_device *rdev);
  162. void radeon_atombios_get_power_modes(struct radeon_device *rdev);
  163. void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type);
  164. int radeon_atom_get_max_vddc(struct radeon_device *rdev, u16 *voltage);
  165. void rs690_pm_info(struct radeon_device *rdev);
  166. extern int rv6xx_get_temp(struct radeon_device *rdev);
  167. extern int rv770_get_temp(struct radeon_device *rdev);
  168. extern int evergreen_get_temp(struct radeon_device *rdev);
  169. extern int sumo_get_temp(struct radeon_device *rdev);
  170. /*
  171. * Fences.
  172. */
  173. struct radeon_fence_driver {
  174. uint32_t scratch_reg;
  175. uint64_t gpu_addr;
  176. volatile uint32_t *cpu_addr;
  177. atomic_t seq;
  178. uint32_t last_seq;
  179. unsigned long last_jiffies;
  180. unsigned long last_timeout;
  181. wait_queue_head_t queue;
  182. struct list_head created;
  183. struct list_head emitted;
  184. struct list_head signaled;
  185. bool initialized;
  186. };
  187. struct radeon_fence {
  188. struct radeon_device *rdev;
  189. struct kref kref;
  190. struct list_head list;
  191. /* protected by radeon_fence.lock */
  192. uint32_t seq;
  193. bool emitted;
  194. bool signaled;
  195. /* RB, DMA, etc. */
  196. int ring;
  197. };
  198. int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring);
  199. int radeon_fence_driver_init(struct radeon_device *rdev);
  200. void radeon_fence_driver_fini(struct radeon_device *rdev);
  201. int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence, int ring);
  202. int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence);
  203. void radeon_fence_process(struct radeon_device *rdev, int ring);
  204. bool radeon_fence_signaled(struct radeon_fence *fence);
  205. int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
  206. int radeon_fence_wait_next(struct radeon_device *rdev, int ring);
  207. int radeon_fence_wait_last(struct radeon_device *rdev, int ring);
  208. struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
  209. void radeon_fence_unref(struct radeon_fence **fence);
  210. int radeon_fence_count_emitted(struct radeon_device *rdev, int ring);
  211. /*
  212. * Semaphores.
  213. */
  214. struct radeon_ring;
  215. struct radeon_semaphore_driver {
  216. rwlock_t lock;
  217. struct list_head free;
  218. };
  219. struct radeon_semaphore {
  220. struct radeon_bo *robj;
  221. struct list_head list;
  222. uint64_t gpu_addr;
  223. };
  224. void radeon_semaphore_driver_fini(struct radeon_device *rdev);
  225. int radeon_semaphore_create(struct radeon_device *rdev,
  226. struct radeon_semaphore **semaphore);
  227. void radeon_semaphore_emit_signal(struct radeon_device *rdev, int ring,
  228. struct radeon_semaphore *semaphore);
  229. void radeon_semaphore_emit_wait(struct radeon_device *rdev, int ring,
  230. struct radeon_semaphore *semaphore);
  231. void radeon_semaphore_free(struct radeon_device *rdev,
  232. struct radeon_semaphore *semaphore);
  233. /*
  234. * Tiling registers
  235. */
  236. struct radeon_surface_reg {
  237. struct radeon_bo *bo;
  238. };
  239. #define RADEON_GEM_MAX_SURFACES 8
  240. /*
  241. * TTM.
  242. */
  243. struct radeon_mman {
  244. struct ttm_bo_global_ref bo_global_ref;
  245. struct drm_global_reference mem_global_ref;
  246. struct ttm_bo_device bdev;
  247. bool mem_global_referenced;
  248. bool initialized;
  249. };
  250. struct radeon_bo {
  251. /* Protected by gem.mutex */
  252. struct list_head list;
  253. /* Protected by tbo.reserved */
  254. u32 placements[3];
  255. struct ttm_placement placement;
  256. struct ttm_buffer_object tbo;
  257. struct ttm_bo_kmap_obj kmap;
  258. unsigned pin_count;
  259. void *kptr;
  260. u32 tiling_flags;
  261. u32 pitch;
  262. int surface_reg;
  263. /* Constant after initialization */
  264. struct radeon_device *rdev;
  265. struct drm_gem_object gem_base;
  266. };
  267. #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
  268. struct radeon_bo_list {
  269. struct ttm_validate_buffer tv;
  270. struct radeon_bo *bo;
  271. uint64_t gpu_offset;
  272. unsigned rdomain;
  273. unsigned wdomain;
  274. u32 tiling_flags;
  275. };
  276. /*
  277. * GEM objects.
  278. */
  279. struct radeon_gem {
  280. struct mutex mutex;
  281. struct list_head objects;
  282. };
  283. int radeon_gem_init(struct radeon_device *rdev);
  284. void radeon_gem_fini(struct radeon_device *rdev);
  285. int radeon_gem_object_create(struct radeon_device *rdev, int size,
  286. int alignment, int initial_domain,
  287. bool discardable, bool kernel,
  288. struct drm_gem_object **obj);
  289. int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain,
  290. uint64_t *gpu_addr);
  291. void radeon_gem_object_unpin(struct drm_gem_object *obj);
  292. int radeon_mode_dumb_create(struct drm_file *file_priv,
  293. struct drm_device *dev,
  294. struct drm_mode_create_dumb *args);
  295. int radeon_mode_dumb_mmap(struct drm_file *filp,
  296. struct drm_device *dev,
  297. uint32_t handle, uint64_t *offset_p);
  298. int radeon_mode_dumb_destroy(struct drm_file *file_priv,
  299. struct drm_device *dev,
  300. uint32_t handle);
  301. /*
  302. * GART structures, functions & helpers
  303. */
  304. struct radeon_mc;
  305. #define RADEON_GPU_PAGE_SIZE 4096
  306. #define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
  307. #define RADEON_GPU_PAGE_SHIFT 12
  308. struct radeon_gart {
  309. dma_addr_t table_addr;
  310. struct radeon_bo *robj;
  311. void *ptr;
  312. unsigned num_gpu_pages;
  313. unsigned num_cpu_pages;
  314. unsigned table_size;
  315. struct page **pages;
  316. dma_addr_t *pages_addr;
  317. bool ready;
  318. };
  319. int radeon_gart_table_ram_alloc(struct radeon_device *rdev);
  320. void radeon_gart_table_ram_free(struct radeon_device *rdev);
  321. int radeon_gart_table_vram_alloc(struct radeon_device *rdev);
  322. void radeon_gart_table_vram_free(struct radeon_device *rdev);
  323. int radeon_gart_table_vram_pin(struct radeon_device *rdev);
  324. void radeon_gart_table_vram_unpin(struct radeon_device *rdev);
  325. int radeon_gart_init(struct radeon_device *rdev);
  326. void radeon_gart_fini(struct radeon_device *rdev);
  327. void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
  328. int pages);
  329. int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
  330. int pages, struct page **pagelist,
  331. dma_addr_t *dma_addr);
  332. void radeon_gart_restore(struct radeon_device *rdev);
  333. /*
  334. * GPU MC structures, functions & helpers
  335. */
  336. struct radeon_mc {
  337. resource_size_t aper_size;
  338. resource_size_t aper_base;
  339. resource_size_t agp_base;
  340. /* for some chips with <= 32MB we need to lie
  341. * about vram size near mc fb location */
  342. u64 mc_vram_size;
  343. u64 visible_vram_size;
  344. u64 gtt_size;
  345. u64 gtt_start;
  346. u64 gtt_end;
  347. u64 vram_start;
  348. u64 vram_end;
  349. unsigned vram_width;
  350. u64 real_vram_size;
  351. int vram_mtrr;
  352. bool vram_is_ddr;
  353. bool igp_sideport_enabled;
  354. u64 gtt_base_align;
  355. };
  356. bool radeon_combios_sideport_present(struct radeon_device *rdev);
  357. bool radeon_atombios_sideport_present(struct radeon_device *rdev);
  358. /*
  359. * GPU scratch registers structures, functions & helpers
  360. */
  361. struct radeon_scratch {
  362. unsigned num_reg;
  363. uint32_t reg_base;
  364. bool free[32];
  365. uint32_t reg[32];
  366. };
  367. int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg);
  368. void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg);
  369. /*
  370. * IRQS.
  371. */
  372. struct radeon_unpin_work {
  373. struct work_struct work;
  374. struct radeon_device *rdev;
  375. int crtc_id;
  376. struct radeon_fence *fence;
  377. struct drm_pending_vblank_event *event;
  378. struct radeon_bo *old_rbo;
  379. u64 new_crtc_base;
  380. };
  381. struct r500_irq_stat_regs {
  382. u32 disp_int;
  383. };
  384. struct r600_irq_stat_regs {
  385. u32 disp_int;
  386. u32 disp_int_cont;
  387. u32 disp_int_cont2;
  388. u32 d1grph_int;
  389. u32 d2grph_int;
  390. };
  391. struct evergreen_irq_stat_regs {
  392. u32 disp_int;
  393. u32 disp_int_cont;
  394. u32 disp_int_cont2;
  395. u32 disp_int_cont3;
  396. u32 disp_int_cont4;
  397. u32 disp_int_cont5;
  398. u32 d1grph_int;
  399. u32 d2grph_int;
  400. u32 d3grph_int;
  401. u32 d4grph_int;
  402. u32 d5grph_int;
  403. u32 d6grph_int;
  404. };
  405. union radeon_irq_stat_regs {
  406. struct r500_irq_stat_regs r500;
  407. struct r600_irq_stat_regs r600;
  408. struct evergreen_irq_stat_regs evergreen;
  409. };
  410. #define RADEON_MAX_HPD_PINS 6
  411. #define RADEON_MAX_CRTCS 6
  412. #define RADEON_MAX_HDMI_BLOCKS 2
  413. struct radeon_irq {
  414. bool installed;
  415. bool sw_int;
  416. bool crtc_vblank_int[RADEON_MAX_CRTCS];
  417. bool pflip[RADEON_MAX_CRTCS];
  418. wait_queue_head_t vblank_queue;
  419. bool hpd[RADEON_MAX_HPD_PINS];
  420. bool gui_idle;
  421. bool gui_idle_acked;
  422. wait_queue_head_t idle_queue;
  423. bool hdmi[RADEON_MAX_HDMI_BLOCKS];
  424. spinlock_t sw_lock;
  425. int sw_refcount;
  426. union radeon_irq_stat_regs stat_regs;
  427. spinlock_t pflip_lock[RADEON_MAX_CRTCS];
  428. int pflip_refcount[RADEON_MAX_CRTCS];
  429. };
  430. int radeon_irq_kms_init(struct radeon_device *rdev);
  431. void radeon_irq_kms_fini(struct radeon_device *rdev);
  432. void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev);
  433. void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev);
  434. void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc);
  435. void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc);
  436. /*
  437. * CP & rings.
  438. */
  439. /* max number of rings */
  440. #define RADEON_NUM_RINGS 3
  441. /* internal ring indices */
  442. /* r1xx+ has gfx CP ring */
  443. #define RADEON_RING_TYPE_GFX_INDEX 0
  444. /* cayman has 2 compute CP rings */
  445. #define CAYMAN_RING_TYPE_CP1_INDEX 1
  446. #define CAYMAN_RING_TYPE_CP2_INDEX 2
  447. struct radeon_ib {
  448. struct list_head list;
  449. unsigned idx;
  450. uint64_t gpu_addr;
  451. struct radeon_fence *fence;
  452. uint32_t *ptr;
  453. uint32_t length_dw;
  454. bool free;
  455. };
  456. /*
  457. * locking -
  458. * mutex protects scheduled_ibs, ready, alloc_bm
  459. */
  460. struct radeon_ib_pool {
  461. struct mutex mutex;
  462. struct radeon_bo *robj;
  463. struct list_head bogus_ib;
  464. struct radeon_ib ibs[RADEON_IB_POOL_SIZE];
  465. bool ready;
  466. unsigned head_id;
  467. };
  468. struct radeon_ring {
  469. struct radeon_bo *ring_obj;
  470. volatile uint32_t *ring;
  471. unsigned rptr;
  472. unsigned rptr_offs;
  473. unsigned rptr_reg;
  474. unsigned wptr;
  475. unsigned wptr_old;
  476. unsigned wptr_reg;
  477. unsigned ring_size;
  478. unsigned ring_free_dw;
  479. int count_dw;
  480. uint64_t gpu_addr;
  481. uint32_t align_mask;
  482. uint32_t ptr_mask;
  483. struct mutex mutex;
  484. bool ready;
  485. u32 ptr_reg_shift;
  486. u32 ptr_reg_mask;
  487. u32 nop;
  488. };
  489. /*
  490. * R6xx+ IH ring
  491. */
  492. struct r600_ih {
  493. struct radeon_bo *ring_obj;
  494. volatile uint32_t *ring;
  495. unsigned rptr;
  496. unsigned rptr_offs;
  497. unsigned wptr;
  498. unsigned wptr_old;
  499. unsigned ring_size;
  500. uint64_t gpu_addr;
  501. uint32_t ptr_mask;
  502. spinlock_t lock;
  503. bool enabled;
  504. };
  505. struct r600_blit_cp_primitives {
  506. void (*set_render_target)(struct radeon_device *rdev, int format,
  507. int w, int h, u64 gpu_addr);
  508. void (*cp_set_surface_sync)(struct radeon_device *rdev,
  509. u32 sync_type, u32 size,
  510. u64 mc_addr);
  511. void (*set_shaders)(struct radeon_device *rdev);
  512. void (*set_vtx_resource)(struct radeon_device *rdev, u64 gpu_addr);
  513. void (*set_tex_resource)(struct radeon_device *rdev,
  514. int format, int w, int h, int pitch,
  515. u64 gpu_addr, u32 size);
  516. void (*set_scissors)(struct radeon_device *rdev, int x1, int y1,
  517. int x2, int y2);
  518. void (*draw_auto)(struct radeon_device *rdev);
  519. void (*set_default_state)(struct radeon_device *rdev);
  520. };
  521. struct r600_blit {
  522. struct mutex mutex;
  523. struct radeon_bo *shader_obj;
  524. struct r600_blit_cp_primitives primitives;
  525. int max_dim;
  526. int ring_size_common;
  527. int ring_size_per_loop;
  528. u64 shader_gpu_addr;
  529. u32 vs_offset, ps_offset;
  530. u32 state_offset;
  531. u32 state_len;
  532. u32 vb_used, vb_total;
  533. struct radeon_ib *vb_ib;
  534. };
  535. void r600_blit_suspend(struct radeon_device *rdev);
  536. int radeon_ib_get(struct radeon_device *rdev, int ring, struct radeon_ib **ib);
  537. void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib);
  538. int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib);
  539. int radeon_ib_pool_init(struct radeon_device *rdev);
  540. void radeon_ib_pool_fini(struct radeon_device *rdev);
  541. int radeon_ib_test(struct radeon_device *rdev);
  542. extern void radeon_ib_bogus_add(struct radeon_device *rdev, struct radeon_ib *ib);
  543. /* Ring access between begin & end cannot sleep */
  544. int radeon_ring_index(struct radeon_device *rdev, struct radeon_ring *cp);
  545. void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *cp);
  546. int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
  547. int radeon_ring_lock(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
  548. void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *cp);
  549. void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *cp);
  550. void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *cp);
  551. int radeon_ring_test(struct radeon_device *rdev, struct radeon_ring *cp);
  552. int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ring_size,
  553. unsigned rptr_offs, unsigned rptr_reg, unsigned wptr_reg,
  554. u32 ptr_reg_shift, u32 ptr_reg_mask, u32 nop);
  555. void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *cp);
  556. /*
  557. * CS.
  558. */
  559. struct radeon_cs_reloc {
  560. struct drm_gem_object *gobj;
  561. struct radeon_bo *robj;
  562. struct radeon_bo_list lobj;
  563. uint32_t handle;
  564. uint32_t flags;
  565. };
  566. struct radeon_cs_chunk {
  567. uint32_t chunk_id;
  568. uint32_t length_dw;
  569. int kpage_idx[2];
  570. uint32_t *kpage[2];
  571. uint32_t *kdata;
  572. void __user *user_ptr;
  573. int last_copied_page;
  574. int last_page_index;
  575. };
  576. struct radeon_cs_parser {
  577. struct device *dev;
  578. struct radeon_device *rdev;
  579. struct drm_file *filp;
  580. /* chunks */
  581. unsigned nchunks;
  582. struct radeon_cs_chunk *chunks;
  583. uint64_t *chunks_array;
  584. /* IB */
  585. unsigned idx;
  586. /* relocations */
  587. unsigned nrelocs;
  588. struct radeon_cs_reloc *relocs;
  589. struct radeon_cs_reloc **relocs_ptr;
  590. struct list_head validated;
  591. /* indices of various chunks */
  592. int chunk_ib_idx;
  593. int chunk_relocs_idx;
  594. struct radeon_ib *ib;
  595. void *track;
  596. unsigned family;
  597. int parser_error;
  598. bool keep_tiling_flags;
  599. };
  600. extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx);
  601. extern int radeon_cs_finish_pages(struct radeon_cs_parser *p);
  602. extern u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx);
  603. struct radeon_cs_packet {
  604. unsigned idx;
  605. unsigned type;
  606. unsigned reg;
  607. unsigned opcode;
  608. int count;
  609. unsigned one_reg_wr;
  610. };
  611. typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p,
  612. struct radeon_cs_packet *pkt,
  613. unsigned idx, unsigned reg);
  614. typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p,
  615. struct radeon_cs_packet *pkt);
  616. /*
  617. * AGP
  618. */
  619. int radeon_agp_init(struct radeon_device *rdev);
  620. void radeon_agp_resume(struct radeon_device *rdev);
  621. void radeon_agp_suspend(struct radeon_device *rdev);
  622. void radeon_agp_fini(struct radeon_device *rdev);
  623. /*
  624. * Writeback
  625. */
  626. struct radeon_wb {
  627. struct radeon_bo *wb_obj;
  628. volatile uint32_t *wb;
  629. uint64_t gpu_addr;
  630. bool enabled;
  631. bool use_event;
  632. };
  633. #define RADEON_WB_SCRATCH_OFFSET 0
  634. #define RADEON_WB_CP_RPTR_OFFSET 1024
  635. #define RADEON_WB_CP1_RPTR_OFFSET 1280
  636. #define RADEON_WB_CP2_RPTR_OFFSET 1536
  637. #define R600_WB_IH_WPTR_OFFSET 2048
  638. #define R600_WB_EVENT_OFFSET 3072
  639. /**
  640. * struct radeon_pm - power management datas
  641. * @max_bandwidth: maximum bandwidth the gpu has (MByte/s)
  642. * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880)
  643. * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880)
  644. * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880)
  645. * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880)
  646. * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP)
  647. * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
  648. * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP)
  649. * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP)
  650. * @sclk: GPU clock Mhz (core bandwidth depends of this clock)
  651. * @needed_bandwidth: current bandwidth needs
  652. *
  653. * It keeps track of various data needed to take powermanagement decision.
  654. * Bandwidth need is used to determine minimun clock of the GPU and memory.
  655. * Equation between gpu/memory clock and available bandwidth is hw dependent
  656. * (type of memory, bus size, efficiency, ...)
  657. */
  658. enum radeon_pm_method {
  659. PM_METHOD_PROFILE,
  660. PM_METHOD_DYNPM,
  661. };
  662. enum radeon_dynpm_state {
  663. DYNPM_STATE_DISABLED,
  664. DYNPM_STATE_MINIMUM,
  665. DYNPM_STATE_PAUSED,
  666. DYNPM_STATE_ACTIVE,
  667. DYNPM_STATE_SUSPENDED,
  668. };
  669. enum radeon_dynpm_action {
  670. DYNPM_ACTION_NONE,
  671. DYNPM_ACTION_MINIMUM,
  672. DYNPM_ACTION_DOWNCLOCK,
  673. DYNPM_ACTION_UPCLOCK,
  674. DYNPM_ACTION_DEFAULT
  675. };
  676. enum radeon_voltage_type {
  677. VOLTAGE_NONE = 0,
  678. VOLTAGE_GPIO,
  679. VOLTAGE_VDDC,
  680. VOLTAGE_SW
  681. };
  682. enum radeon_pm_state_type {
  683. POWER_STATE_TYPE_DEFAULT,
  684. POWER_STATE_TYPE_POWERSAVE,
  685. POWER_STATE_TYPE_BATTERY,
  686. POWER_STATE_TYPE_BALANCED,
  687. POWER_STATE_TYPE_PERFORMANCE,
  688. };
  689. enum radeon_pm_profile_type {
  690. PM_PROFILE_DEFAULT,
  691. PM_PROFILE_AUTO,
  692. PM_PROFILE_LOW,
  693. PM_PROFILE_MID,
  694. PM_PROFILE_HIGH,
  695. };
  696. #define PM_PROFILE_DEFAULT_IDX 0
  697. #define PM_PROFILE_LOW_SH_IDX 1
  698. #define PM_PROFILE_MID_SH_IDX 2
  699. #define PM_PROFILE_HIGH_SH_IDX 3
  700. #define PM_PROFILE_LOW_MH_IDX 4
  701. #define PM_PROFILE_MID_MH_IDX 5
  702. #define PM_PROFILE_HIGH_MH_IDX 6
  703. #define PM_PROFILE_MAX 7
  704. struct radeon_pm_profile {
  705. int dpms_off_ps_idx;
  706. int dpms_on_ps_idx;
  707. int dpms_off_cm_idx;
  708. int dpms_on_cm_idx;
  709. };
  710. enum radeon_int_thermal_type {
  711. THERMAL_TYPE_NONE,
  712. THERMAL_TYPE_RV6XX,
  713. THERMAL_TYPE_RV770,
  714. THERMAL_TYPE_EVERGREEN,
  715. THERMAL_TYPE_SUMO,
  716. THERMAL_TYPE_NI,
  717. };
  718. struct radeon_voltage {
  719. enum radeon_voltage_type type;
  720. /* gpio voltage */
  721. struct radeon_gpio_rec gpio;
  722. u32 delay; /* delay in usec from voltage drop to sclk change */
  723. bool active_high; /* voltage drop is active when bit is high */
  724. /* VDDC voltage */
  725. u8 vddc_id; /* index into vddc voltage table */
  726. u8 vddci_id; /* index into vddci voltage table */
  727. bool vddci_enabled;
  728. /* r6xx+ sw */
  729. u16 voltage;
  730. /* evergreen+ vddci */
  731. u16 vddci;
  732. };
  733. /* clock mode flags */
  734. #define RADEON_PM_MODE_NO_DISPLAY (1 << 0)
  735. struct radeon_pm_clock_info {
  736. /* memory clock */
  737. u32 mclk;
  738. /* engine clock */
  739. u32 sclk;
  740. /* voltage info */
  741. struct radeon_voltage voltage;
  742. /* standardized clock flags */
  743. u32 flags;
  744. };
  745. /* state flags */
  746. #define RADEON_PM_STATE_SINGLE_DISPLAY_ONLY (1 << 0)
  747. struct radeon_power_state {
  748. enum radeon_pm_state_type type;
  749. struct radeon_pm_clock_info *clock_info;
  750. /* number of valid clock modes in this power state */
  751. int num_clock_modes;
  752. struct radeon_pm_clock_info *default_clock_mode;
  753. /* standardized state flags */
  754. u32 flags;
  755. u32 misc; /* vbios specific flags */
  756. u32 misc2; /* vbios specific flags */
  757. int pcie_lanes; /* pcie lanes */
  758. };
  759. /*
  760. * Some modes are overclocked by very low value, accept them
  761. */
  762. #define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */
  763. struct radeon_pm {
  764. struct mutex mutex;
  765. u32 active_crtcs;
  766. int active_crtc_count;
  767. int req_vblank;
  768. bool vblank_sync;
  769. bool gui_idle;
  770. fixed20_12 max_bandwidth;
  771. fixed20_12 igp_sideport_mclk;
  772. fixed20_12 igp_system_mclk;
  773. fixed20_12 igp_ht_link_clk;
  774. fixed20_12 igp_ht_link_width;
  775. fixed20_12 k8_bandwidth;
  776. fixed20_12 sideport_bandwidth;
  777. fixed20_12 ht_bandwidth;
  778. fixed20_12 core_bandwidth;
  779. fixed20_12 sclk;
  780. fixed20_12 mclk;
  781. fixed20_12 needed_bandwidth;
  782. struct radeon_power_state *power_state;
  783. /* number of valid power states */
  784. int num_power_states;
  785. int current_power_state_index;
  786. int current_clock_mode_index;
  787. int requested_power_state_index;
  788. int requested_clock_mode_index;
  789. int default_power_state_index;
  790. u32 current_sclk;
  791. u32 current_mclk;
  792. u16 current_vddc;
  793. u16 current_vddci;
  794. u32 default_sclk;
  795. u32 default_mclk;
  796. u16 default_vddc;
  797. u16 default_vddci;
  798. struct radeon_i2c_chan *i2c_bus;
  799. /* selected pm method */
  800. enum radeon_pm_method pm_method;
  801. /* dynpm power management */
  802. struct delayed_work dynpm_idle_work;
  803. enum radeon_dynpm_state dynpm_state;
  804. enum radeon_dynpm_action dynpm_planned_action;
  805. unsigned long dynpm_action_timeout;
  806. bool dynpm_can_upclock;
  807. bool dynpm_can_downclock;
  808. /* profile-based power management */
  809. enum radeon_pm_profile_type profile;
  810. int profile_index;
  811. struct radeon_pm_profile profiles[PM_PROFILE_MAX];
  812. /* internal thermal controller on rv6xx+ */
  813. enum radeon_int_thermal_type int_thermal_type;
  814. struct device *int_hwmon_dev;
  815. };
  816. int radeon_pm_get_type_index(struct radeon_device *rdev,
  817. enum radeon_pm_state_type ps_type,
  818. int instance);
  819. /*
  820. * Benchmarking
  821. */
  822. void radeon_benchmark(struct radeon_device *rdev, int test_number);
  823. /*
  824. * Testing
  825. */
  826. void radeon_test_moves(struct radeon_device *rdev);
  827. void radeon_test_ring_sync(struct radeon_device *rdev,
  828. struct radeon_ring *cpA,
  829. struct radeon_ring *cpB);
  830. void radeon_test_syncing(struct radeon_device *rdev);
  831. /*
  832. * Debugfs
  833. */
  834. struct radeon_debugfs {
  835. struct drm_info_list *files;
  836. unsigned num_files;
  837. };
  838. int radeon_debugfs_add_files(struct radeon_device *rdev,
  839. struct drm_info_list *files,
  840. unsigned nfiles);
  841. int radeon_debugfs_fence_init(struct radeon_device *rdev);
  842. /*
  843. * ASIC specific functions.
  844. */
  845. struct radeon_asic {
  846. int (*init)(struct radeon_device *rdev);
  847. void (*fini)(struct radeon_device *rdev);
  848. int (*resume)(struct radeon_device *rdev);
  849. int (*suspend)(struct radeon_device *rdev);
  850. void (*vga_set_state)(struct radeon_device *rdev, bool state);
  851. bool (*gpu_is_lockup)(struct radeon_device *rdev, struct radeon_ring *cp);
  852. int (*asic_reset)(struct radeon_device *rdev);
  853. void (*gart_tlb_flush)(struct radeon_device *rdev);
  854. int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr);
  855. int (*cp_init)(struct radeon_device *rdev, unsigned ring_size);
  856. void (*cp_fini)(struct radeon_device *rdev);
  857. void (*cp_disable)(struct radeon_device *rdev);
  858. void (*ring_start)(struct radeon_device *rdev);
  859. struct {
  860. void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib);
  861. void (*emit_fence)(struct radeon_device *rdev, struct radeon_fence *fence);
  862. void (*emit_semaphore)(struct radeon_device *rdev, struct radeon_ring *cp,
  863. struct radeon_semaphore *semaphore, bool emit_wait);
  864. } ring[RADEON_NUM_RINGS];
  865. int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
  866. int (*irq_set)(struct radeon_device *rdev);
  867. int (*irq_process)(struct radeon_device *rdev);
  868. u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
  869. int (*cs_parse)(struct radeon_cs_parser *p);
  870. int (*copy_blit)(struct radeon_device *rdev,
  871. uint64_t src_offset,
  872. uint64_t dst_offset,
  873. unsigned num_gpu_pages,
  874. struct radeon_fence *fence);
  875. int (*copy_dma)(struct radeon_device *rdev,
  876. uint64_t src_offset,
  877. uint64_t dst_offset,
  878. unsigned num_gpu_pages,
  879. struct radeon_fence *fence);
  880. int (*copy)(struct radeon_device *rdev,
  881. uint64_t src_offset,
  882. uint64_t dst_offset,
  883. unsigned num_gpu_pages,
  884. struct radeon_fence *fence);
  885. uint32_t (*get_engine_clock)(struct radeon_device *rdev);
  886. void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
  887. uint32_t (*get_memory_clock)(struct radeon_device *rdev);
  888. void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock);
  889. int (*get_pcie_lanes)(struct radeon_device *rdev);
  890. void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
  891. void (*set_clock_gating)(struct radeon_device *rdev, int enable);
  892. int (*set_surface_reg)(struct radeon_device *rdev, int reg,
  893. uint32_t tiling_flags, uint32_t pitch,
  894. uint32_t offset, uint32_t obj_size);
  895. void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
  896. void (*bandwidth_update)(struct radeon_device *rdev);
  897. void (*hpd_init)(struct radeon_device *rdev);
  898. void (*hpd_fini)(struct radeon_device *rdev);
  899. bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
  900. void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
  901. /* ioctl hw specific callback. Some hw might want to perform special
  902. * operation on specific ioctl. For instance on wait idle some hw
  903. * might want to perform and HDP flush through MMIO as it seems that
  904. * some R6XX/R7XX hw doesn't take HDP flush into account if programmed
  905. * through ring.
  906. */
  907. void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo *bo);
  908. bool (*gui_idle)(struct radeon_device *rdev);
  909. /* power management */
  910. void (*pm_misc)(struct radeon_device *rdev);
  911. void (*pm_prepare)(struct radeon_device *rdev);
  912. void (*pm_finish)(struct radeon_device *rdev);
  913. void (*pm_init_profile)(struct radeon_device *rdev);
  914. void (*pm_get_dynpm_state)(struct radeon_device *rdev);
  915. /* pageflipping */
  916. void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
  917. u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
  918. void (*post_page_flip)(struct radeon_device *rdev, int crtc);
  919. };
  920. /*
  921. * Asic structures
  922. */
  923. struct r100_gpu_lockup {
  924. unsigned long last_jiffies;
  925. u32 last_cp_rptr;
  926. };
  927. struct r100_asic {
  928. const unsigned *reg_safe_bm;
  929. unsigned reg_safe_bm_size;
  930. u32 hdp_cntl;
  931. struct r100_gpu_lockup lockup;
  932. };
  933. struct r300_asic {
  934. const unsigned *reg_safe_bm;
  935. unsigned reg_safe_bm_size;
  936. u32 resync_scratch;
  937. u32 hdp_cntl;
  938. struct r100_gpu_lockup lockup;
  939. };
  940. struct r600_asic {
  941. unsigned max_pipes;
  942. unsigned max_tile_pipes;
  943. unsigned max_simds;
  944. unsigned max_backends;
  945. unsigned max_gprs;
  946. unsigned max_threads;
  947. unsigned max_stack_entries;
  948. unsigned max_hw_contexts;
  949. unsigned max_gs_threads;
  950. unsigned sx_max_export_size;
  951. unsigned sx_max_export_pos_size;
  952. unsigned sx_max_export_smx_size;
  953. unsigned sq_num_cf_insts;
  954. unsigned tiling_nbanks;
  955. unsigned tiling_npipes;
  956. unsigned tiling_group_size;
  957. unsigned tile_config;
  958. unsigned backend_map;
  959. struct r100_gpu_lockup lockup;
  960. };
  961. struct rv770_asic {
  962. unsigned max_pipes;
  963. unsigned max_tile_pipes;
  964. unsigned max_simds;
  965. unsigned max_backends;
  966. unsigned max_gprs;
  967. unsigned max_threads;
  968. unsigned max_stack_entries;
  969. unsigned max_hw_contexts;
  970. unsigned max_gs_threads;
  971. unsigned sx_max_export_size;
  972. unsigned sx_max_export_pos_size;
  973. unsigned sx_max_export_smx_size;
  974. unsigned sq_num_cf_insts;
  975. unsigned sx_num_of_sets;
  976. unsigned sc_prim_fifo_size;
  977. unsigned sc_hiz_tile_fifo_size;
  978. unsigned sc_earlyz_tile_fifo_fize;
  979. unsigned tiling_nbanks;
  980. unsigned tiling_npipes;
  981. unsigned tiling_group_size;
  982. unsigned tile_config;
  983. unsigned backend_map;
  984. struct r100_gpu_lockup lockup;
  985. };
  986. struct evergreen_asic {
  987. unsigned num_ses;
  988. unsigned max_pipes;
  989. unsigned max_tile_pipes;
  990. unsigned max_simds;
  991. unsigned max_backends;
  992. unsigned max_gprs;
  993. unsigned max_threads;
  994. unsigned max_stack_entries;
  995. unsigned max_hw_contexts;
  996. unsigned max_gs_threads;
  997. unsigned sx_max_export_size;
  998. unsigned sx_max_export_pos_size;
  999. unsigned sx_max_export_smx_size;
  1000. unsigned sq_num_cf_insts;
  1001. unsigned sx_num_of_sets;
  1002. unsigned sc_prim_fifo_size;
  1003. unsigned sc_hiz_tile_fifo_size;
  1004. unsigned sc_earlyz_tile_fifo_size;
  1005. unsigned tiling_nbanks;
  1006. unsigned tiling_npipes;
  1007. unsigned tiling_group_size;
  1008. unsigned tile_config;
  1009. unsigned backend_map;
  1010. struct r100_gpu_lockup lockup;
  1011. };
  1012. struct cayman_asic {
  1013. unsigned max_shader_engines;
  1014. unsigned max_pipes_per_simd;
  1015. unsigned max_tile_pipes;
  1016. unsigned max_simds_per_se;
  1017. unsigned max_backends_per_se;
  1018. unsigned max_texture_channel_caches;
  1019. unsigned max_gprs;
  1020. unsigned max_threads;
  1021. unsigned max_gs_threads;
  1022. unsigned max_stack_entries;
  1023. unsigned sx_num_of_sets;
  1024. unsigned sx_max_export_size;
  1025. unsigned sx_max_export_pos_size;
  1026. unsigned sx_max_export_smx_size;
  1027. unsigned max_hw_contexts;
  1028. unsigned sq_num_cf_insts;
  1029. unsigned sc_prim_fifo_size;
  1030. unsigned sc_hiz_tile_fifo_size;
  1031. unsigned sc_earlyz_tile_fifo_size;
  1032. unsigned num_shader_engines;
  1033. unsigned num_shader_pipes_per_simd;
  1034. unsigned num_tile_pipes;
  1035. unsigned num_simds_per_se;
  1036. unsigned num_backends_per_se;
  1037. unsigned backend_disable_mask_per_asic;
  1038. unsigned backend_map;
  1039. unsigned num_texture_channel_caches;
  1040. unsigned mem_max_burst_length_bytes;
  1041. unsigned mem_row_size_in_kb;
  1042. unsigned shader_engine_tile_size;
  1043. unsigned num_gpus;
  1044. unsigned multi_gpu_tile_size;
  1045. unsigned tile_config;
  1046. struct r100_gpu_lockup lockup;
  1047. };
  1048. union radeon_asic_config {
  1049. struct r300_asic r300;
  1050. struct r100_asic r100;
  1051. struct r600_asic r600;
  1052. struct rv770_asic rv770;
  1053. struct evergreen_asic evergreen;
  1054. struct cayman_asic cayman;
  1055. };
  1056. /*
  1057. * asic initizalization from radeon_asic.c
  1058. */
  1059. void radeon_agp_disable(struct radeon_device *rdev);
  1060. int radeon_asic_init(struct radeon_device *rdev);
  1061. /*
  1062. * IOCTL.
  1063. */
  1064. int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
  1065. struct drm_file *filp);
  1066. int radeon_gem_create_ioctl(struct drm_device *dev, void *data,
  1067. struct drm_file *filp);
  1068. int radeon_gem_pin_ioctl(struct drm_device *dev, void *data,
  1069. struct drm_file *file_priv);
  1070. int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data,
  1071. struct drm_file *file_priv);
  1072. int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data,
  1073. struct drm_file *file_priv);
  1074. int radeon_gem_pread_ioctl(struct drm_device *dev, void *data,
  1075. struct drm_file *file_priv);
  1076. int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
  1077. struct drm_file *filp);
  1078. int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
  1079. struct drm_file *filp);
  1080. int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
  1081. struct drm_file *filp);
  1082. int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
  1083. struct drm_file *filp);
  1084. int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
  1085. int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
  1086. struct drm_file *filp);
  1087. int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
  1088. struct drm_file *filp);
  1089. /* VRAM scratch page for HDP bug, default vram page */
  1090. struct r600_vram_scratch {
  1091. struct radeon_bo *robj;
  1092. volatile uint32_t *ptr;
  1093. u64 gpu_addr;
  1094. };
  1095. /*
  1096. * Mutex which allows recursive locking from the same process.
  1097. */
  1098. struct radeon_mutex {
  1099. struct mutex mutex;
  1100. struct task_struct *owner;
  1101. int level;
  1102. };
  1103. static inline void radeon_mutex_init(struct radeon_mutex *mutex)
  1104. {
  1105. mutex_init(&mutex->mutex);
  1106. mutex->owner = NULL;
  1107. mutex->level = 0;
  1108. }
  1109. static inline void radeon_mutex_lock(struct radeon_mutex *mutex)
  1110. {
  1111. if (mutex_trylock(&mutex->mutex)) {
  1112. /* The mutex was unlocked before, so it's ours now */
  1113. mutex->owner = current;
  1114. } else if (mutex->owner != current) {
  1115. /* Another process locked the mutex, take it */
  1116. mutex_lock(&mutex->mutex);
  1117. mutex->owner = current;
  1118. }
  1119. /* Otherwise the mutex was already locked by this process */
  1120. mutex->level++;
  1121. }
  1122. static inline void radeon_mutex_unlock(struct radeon_mutex *mutex)
  1123. {
  1124. if (--mutex->level > 0)
  1125. return;
  1126. mutex->owner = NULL;
  1127. mutex_unlock(&mutex->mutex);
  1128. }
  1129. /*
  1130. * Core structure, functions and helpers.
  1131. */
  1132. typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
  1133. typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
  1134. struct radeon_device {
  1135. struct device *dev;
  1136. struct drm_device *ddev;
  1137. struct pci_dev *pdev;
  1138. /* ASIC */
  1139. union radeon_asic_config config;
  1140. enum radeon_family family;
  1141. unsigned long flags;
  1142. int usec_timeout;
  1143. enum radeon_pll_errata pll_errata;
  1144. int num_gb_pipes;
  1145. int num_z_pipes;
  1146. int disp_priority;
  1147. /* BIOS */
  1148. uint8_t *bios;
  1149. bool is_atom_bios;
  1150. uint16_t bios_header_start;
  1151. struct radeon_bo *stollen_vga_memory;
  1152. /* Register mmio */
  1153. resource_size_t rmmio_base;
  1154. resource_size_t rmmio_size;
  1155. void __iomem *rmmio;
  1156. radeon_rreg_t mc_rreg;
  1157. radeon_wreg_t mc_wreg;
  1158. radeon_rreg_t pll_rreg;
  1159. radeon_wreg_t pll_wreg;
  1160. uint32_t pcie_reg_mask;
  1161. radeon_rreg_t pciep_rreg;
  1162. radeon_wreg_t pciep_wreg;
  1163. /* io port */
  1164. void __iomem *rio_mem;
  1165. resource_size_t rio_mem_size;
  1166. struct radeon_clock clock;
  1167. struct radeon_mc mc;
  1168. struct radeon_gart gart;
  1169. struct radeon_mode_info mode_info;
  1170. struct radeon_scratch scratch;
  1171. struct radeon_mman mman;
  1172. rwlock_t fence_lock;
  1173. struct radeon_fence_driver fence_drv[RADEON_NUM_RINGS];
  1174. struct radeon_semaphore_driver semaphore_drv;
  1175. struct radeon_ring ring[RADEON_NUM_RINGS];
  1176. struct radeon_ib_pool ib_pool;
  1177. struct radeon_irq irq;
  1178. struct radeon_asic *asic;
  1179. struct radeon_gem gem;
  1180. struct radeon_pm pm;
  1181. uint32_t bios_scratch[RADEON_BIOS_NUM_SCRATCH];
  1182. struct radeon_mutex cs_mutex;
  1183. struct radeon_wb wb;
  1184. struct radeon_dummy_page dummy_page;
  1185. bool gpu_lockup;
  1186. bool shutdown;
  1187. bool suspend;
  1188. bool need_dma32;
  1189. bool accel_working;
  1190. struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
  1191. const struct firmware *me_fw; /* all family ME firmware */
  1192. const struct firmware *pfp_fw; /* r6/700 PFP firmware */
  1193. const struct firmware *rlc_fw; /* r6/700 RLC firmware */
  1194. const struct firmware *mc_fw; /* NI MC firmware */
  1195. struct r600_blit r600_blit;
  1196. struct r600_vram_scratch vram_scratch;
  1197. int msi_enabled; /* msi enabled */
  1198. struct r600_ih ih; /* r6/700 interrupt ring */
  1199. struct work_struct hotplug_work;
  1200. int num_crtc; /* number of crtcs */
  1201. struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
  1202. struct mutex vram_mutex;
  1203. /* audio stuff */
  1204. bool audio_enabled;
  1205. struct timer_list audio_timer;
  1206. int audio_channels;
  1207. int audio_rate;
  1208. int audio_bits_per_sample;
  1209. uint8_t audio_status_bits;
  1210. uint8_t audio_category_code;
  1211. struct notifier_block acpi_nb;
  1212. /* only one userspace can use Hyperz features or CMASK at a time */
  1213. struct drm_file *hyperz_filp;
  1214. struct drm_file *cmask_filp;
  1215. /* i2c buses */
  1216. struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS];
  1217. /* debugfs */
  1218. struct radeon_debugfs debugfs[RADEON_DEBUGFS_MAX_COMPONENTS];
  1219. unsigned debugfs_count;
  1220. };
  1221. int radeon_device_init(struct radeon_device *rdev,
  1222. struct drm_device *ddev,
  1223. struct pci_dev *pdev,
  1224. uint32_t flags);
  1225. void radeon_device_fini(struct radeon_device *rdev);
  1226. int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
  1227. uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg);
  1228. void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
  1229. u32 r100_io_rreg(struct radeon_device *rdev, u32 reg);
  1230. void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  1231. /*
  1232. * Cast helper
  1233. */
  1234. #define to_radeon_fence(p) ((struct radeon_fence *)(p))
  1235. /*
  1236. * Registers read & write functions.
  1237. */
  1238. #define RREG8(reg) readb((rdev->rmmio) + (reg))
  1239. #define WREG8(reg, v) writeb(v, (rdev->rmmio) + (reg))
  1240. #define RREG16(reg) readw((rdev->rmmio) + (reg))
  1241. #define WREG16(reg, v) writew(v, (rdev->rmmio) + (reg))
  1242. #define RREG32(reg) r100_mm_rreg(rdev, (reg))
  1243. #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg)))
  1244. #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v))
  1245. #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  1246. #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  1247. #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
  1248. #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
  1249. #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
  1250. #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
  1251. #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
  1252. #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
  1253. #define RREG32_PCIE_P(reg) rdev->pciep_rreg(rdev, (reg))
  1254. #define WREG32_PCIE_P(reg, v) rdev->pciep_wreg(rdev, (reg), (v))
  1255. #define WREG32_P(reg, val, mask) \
  1256. do { \
  1257. uint32_t tmp_ = RREG32(reg); \
  1258. tmp_ &= (mask); \
  1259. tmp_ |= ((val) & ~(mask)); \
  1260. WREG32(reg, tmp_); \
  1261. } while (0)
  1262. #define WREG32_PLL_P(reg, val, mask) \
  1263. do { \
  1264. uint32_t tmp_ = RREG32_PLL(reg); \
  1265. tmp_ &= (mask); \
  1266. tmp_ |= ((val) & ~(mask)); \
  1267. WREG32_PLL(reg, tmp_); \
  1268. } while (0)
  1269. #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg)))
  1270. #define RREG32_IO(reg) r100_io_rreg(rdev, (reg))
  1271. #define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v))
  1272. /*
  1273. * Indirect registers accessor
  1274. */
  1275. static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
  1276. {
  1277. uint32_t r;
  1278. WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
  1279. r = RREG32(RADEON_PCIE_DATA);
  1280. return r;
  1281. }
  1282. static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
  1283. {
  1284. WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
  1285. WREG32(RADEON_PCIE_DATA, (v));
  1286. }
  1287. void r100_pll_errata_after_index(struct radeon_device *rdev);
  1288. /*
  1289. * ASICs helpers.
  1290. */
  1291. #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
  1292. (rdev->pdev->device == 0x5969))
  1293. #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
  1294. (rdev->family == CHIP_RV200) || \
  1295. (rdev->family == CHIP_RS100) || \
  1296. (rdev->family == CHIP_RS200) || \
  1297. (rdev->family == CHIP_RV250) || \
  1298. (rdev->family == CHIP_RV280) || \
  1299. (rdev->family == CHIP_RS300))
  1300. #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \
  1301. (rdev->family == CHIP_RV350) || \
  1302. (rdev->family == CHIP_R350) || \
  1303. (rdev->family == CHIP_RV380) || \
  1304. (rdev->family == CHIP_R420) || \
  1305. (rdev->family == CHIP_R423) || \
  1306. (rdev->family == CHIP_RV410) || \
  1307. (rdev->family == CHIP_RS400) || \
  1308. (rdev->family == CHIP_RS480))
  1309. #define ASIC_IS_X2(rdev) ((rdev->ddev->pdev->device == 0x9441) || \
  1310. (rdev->ddev->pdev->device == 0x9443) || \
  1311. (rdev->ddev->pdev->device == 0x944B) || \
  1312. (rdev->ddev->pdev->device == 0x9506) || \
  1313. (rdev->ddev->pdev->device == 0x9509) || \
  1314. (rdev->ddev->pdev->device == 0x950F) || \
  1315. (rdev->ddev->pdev->device == 0x689C) || \
  1316. (rdev->ddev->pdev->device == 0x689D))
  1317. #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
  1318. #define ASIC_IS_DCE2(rdev) ((rdev->family == CHIP_RS600) || \
  1319. (rdev->family == CHIP_RS690) || \
  1320. (rdev->family == CHIP_RS740) || \
  1321. (rdev->family >= CHIP_R600))
  1322. #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
  1323. #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
  1324. #define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR))
  1325. #define ASIC_IS_DCE41(rdev) ((rdev->family >= CHIP_PALM) && \
  1326. (rdev->flags & RADEON_IS_IGP))
  1327. #define ASIC_IS_DCE5(rdev) ((rdev->family >= CHIP_BARTS))
  1328. /*
  1329. * BIOS helpers.
  1330. */
  1331. #define RBIOS8(i) (rdev->bios[i])
  1332. #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
  1333. #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
  1334. int radeon_combios_init(struct radeon_device *rdev);
  1335. void radeon_combios_fini(struct radeon_device *rdev);
  1336. int radeon_atombios_init(struct radeon_device *rdev);
  1337. void radeon_atombios_fini(struct radeon_device *rdev);
  1338. /*
  1339. * RING helpers.
  1340. */
  1341. #if DRM_DEBUG_CODE == 0
  1342. static inline void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
  1343. {
  1344. ring->ring[ring->wptr++] = v;
  1345. ring->wptr &= ring->ptr_mask;
  1346. ring->count_dw--;
  1347. ring->ring_free_dw--;
  1348. }
  1349. #else
  1350. /* With debugging this is just too big to inline */
  1351. void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
  1352. #endif
  1353. /*
  1354. * ASICs macro.
  1355. */
  1356. #define radeon_init(rdev) (rdev)->asic->init((rdev))
  1357. #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
  1358. #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
  1359. #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
  1360. #define radeon_cs_parse(p) rdev->asic->cs_parse((p))
  1361. #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
  1362. #define radeon_gpu_is_lockup(rdev, cp) (rdev)->asic->gpu_is_lockup((rdev), (cp))
  1363. #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
  1364. #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev))
  1365. #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart_set_page((rdev), (i), (p))
  1366. #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev))
  1367. #define radeon_ring_test(rdev, cp) (rdev)->asic->ring_test((rdev), (cp))
  1368. #define radeon_ring_ib_execute(rdev, r, ib) (rdev)->asic->ring[(r)].ib_execute((rdev), (ib))
  1369. #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev))
  1370. #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev))
  1371. #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc))
  1372. #define radeon_fence_ring_emit(rdev, r, fence) (rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
  1373. #define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) (rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
  1374. #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f))
  1375. #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f))
  1376. #define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy((rdev), (s), (d), (np), (f))
  1377. #define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev))
  1378. #define radeon_set_engine_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e))
  1379. #define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev))
  1380. #define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_memory_clock((rdev), (e))
  1381. #define radeon_get_pcie_lanes(rdev) (rdev)->asic->get_pcie_lanes((rdev))
  1382. #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l))
  1383. #define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e))
  1384. #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
  1385. #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r)))
  1386. #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
  1387. #define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev))
  1388. #define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev))
  1389. #define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd))
  1390. #define radeon_hpd_set_polarity(rdev, hpd) (rdev)->asic->hpd_set_polarity((rdev), (hpd))
  1391. #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
  1392. #define radeon_pm_misc(rdev) (rdev)->asic->pm_misc((rdev))
  1393. #define radeon_pm_prepare(rdev) (rdev)->asic->pm_prepare((rdev))
  1394. #define radeon_pm_finish(rdev) (rdev)->asic->pm_finish((rdev))
  1395. #define radeon_pm_init_profile(rdev) (rdev)->asic->pm_init_profile((rdev))
  1396. #define radeon_pm_get_dynpm_state(rdev) (rdev)->asic->pm_get_dynpm_state((rdev))
  1397. #define radeon_pre_page_flip(rdev, crtc) rdev->asic->pre_page_flip((rdev), (crtc))
  1398. #define radeon_page_flip(rdev, crtc, base) rdev->asic->page_flip((rdev), (crtc), (base))
  1399. #define radeon_post_page_flip(rdev, crtc) rdev->asic->post_page_flip((rdev), (crtc))
  1400. /* Common functions */
  1401. /* AGP */
  1402. extern int radeon_gpu_reset(struct radeon_device *rdev);
  1403. extern void radeon_agp_disable(struct radeon_device *rdev);
  1404. extern int radeon_modeset_init(struct radeon_device *rdev);
  1405. extern void radeon_modeset_fini(struct radeon_device *rdev);
  1406. extern bool radeon_card_posted(struct radeon_device *rdev);
  1407. extern void radeon_update_bandwidth_info(struct radeon_device *rdev);
  1408. extern void radeon_update_display_priority(struct radeon_device *rdev);
  1409. extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
  1410. extern void radeon_scratch_init(struct radeon_device *rdev);
  1411. extern void radeon_wb_fini(struct radeon_device *rdev);
  1412. extern int radeon_wb_init(struct radeon_device *rdev);
  1413. extern void radeon_wb_disable(struct radeon_device *rdev);
  1414. extern void radeon_surface_init(struct radeon_device *rdev);
  1415. extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
  1416. extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
  1417. extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
  1418. extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
  1419. extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
  1420. extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base);
  1421. extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
  1422. extern int radeon_resume_kms(struct drm_device *dev);
  1423. extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
  1424. extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size);
  1425. /*
  1426. * R600 vram scratch functions
  1427. */
  1428. int r600_vram_scratch_init(struct radeon_device *rdev);
  1429. void r600_vram_scratch_fini(struct radeon_device *rdev);
  1430. /*
  1431. * r600 functions used by radeon_encoder.c
  1432. */
  1433. extern void r600_hdmi_enable(struct drm_encoder *encoder);
  1434. extern void r600_hdmi_disable(struct drm_encoder *encoder);
  1435. extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
  1436. extern int ni_init_microcode(struct radeon_device *rdev);
  1437. extern int ni_mc_load_microcode(struct radeon_device *rdev);
  1438. /* radeon_acpi.c */
  1439. #if defined(CONFIG_ACPI)
  1440. extern int radeon_acpi_init(struct radeon_device *rdev);
  1441. #else
  1442. static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; }
  1443. #endif
  1444. #include "radeon_object.h"
  1445. #endif