2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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.
24 * Authors: Dave Airlie
31 /* TODO: Here are things that needs to be done :
32 * - surface allocator & initializer : (bit like scratch reg) should
33 * initialize HDP_ stuff on RS600, R600, R700 hw, well anythings
35 * - WB : write back stuff (do it bit like scratch reg things)
36 * - Vblank : look at Jesse's rework and what we should do
37 * - r600/r700: gart & cp
38 * - cs : clean cs ioctl use bitmap & things like that.
39 * - power management stuff
40 * - Barrier in gart code
41 * - Unmappabled vram ?
42 * - TESTING, TESTING, TESTING
45 /* Initialization path:
46 * We expect that acceleration initialization might fail for various
47 * reasons even thought we work hard to make it works on most
48 * configurations. In order to still have a working userspace in such
49 * situation the init path must succeed up to the memory controller
50 * initialization point. Failure before this point are considered as
51 * fatal error. Here is the init callchain :
52 * radeon_device_init perform common structure, mutex initialization
53 * asic_init setup the GPU memory layout and perform all
54 * one time initialization (failure in this
55 * function are considered fatal)
56 * asic_startup setup the GPU acceleration, in order to
57 * follow guideline the first thing this
58 * function should do is setting the GPU
59 * memory controller (only MC setup failure
60 * are considered as fatal)
63 #include <linux/atomic.h>
64 #include <linux/wait.h>
65 #include <linux/list.h>
66 #include <linux/kref.h>
68 #include <ttm/ttm_bo_api.h>
69 #include <ttm/ttm_bo_driver.h>
70 #include <ttm/ttm_placement.h>
71 #include <ttm/ttm_module.h>
72 #include <ttm/ttm_execbuf_util.h>
74 #include "radeon_family.h"
75 #include "radeon_mode.h"
76 #include "radeon_reg.h"
81 extern int radeon_no_wb
;
82 extern int radeon_modeset
;
83 extern int radeon_dynclks
;
84 extern int radeon_r4xx_atom
;
85 extern int radeon_agpmode
;
86 extern int radeon_vram_limit
;
87 extern int radeon_gart_size
;
88 extern int radeon_benchmarking
;
89 extern int radeon_testing
;
90 extern int radeon_connector_table
;
92 extern int radeon_audio
;
93 extern int radeon_disp_priority
;
94 extern int radeon_hw_i2c
;
95 extern int radeon_pcie_gen2
;
96 extern int radeon_msi
;
97 extern int radeon_lockup_timeout
;
98 extern int radeon_fastfb
;
101 * Copy from radeon_drv.h so we don't have to include both and have conflicting
104 #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
105 #define RADEON_FENCE_JIFFIES_TIMEOUT (HZ / 2)
106 /* RADEON_IB_POOL_SIZE must be a power of 2 */
107 #define RADEON_IB_POOL_SIZE 16
108 #define RADEON_DEBUGFS_MAX_COMPONENTS 32
109 #define RADEONFB_CONN_LIMIT 4
110 #define RADEON_BIOS_NUM_SCRATCH 8
112 /* max number of rings */
113 #define RADEON_NUM_RINGS 6
115 /* fence seq are set to this number when signaled */
116 #define RADEON_FENCE_SIGNALED_SEQ 0LL
118 /* internal ring indices */
119 /* r1xx+ has gfx CP ring */
120 #define RADEON_RING_TYPE_GFX_INDEX 0
122 /* cayman has 2 compute CP rings */
123 #define CAYMAN_RING_TYPE_CP1_INDEX 1
124 #define CAYMAN_RING_TYPE_CP2_INDEX 2
126 /* R600+ has an async dma ring */
127 #define R600_RING_TYPE_DMA_INDEX 3
128 /* cayman add a second async dma ring */
129 #define CAYMAN_RING_TYPE_DMA1_INDEX 4
132 #define R600_RING_TYPE_UVD_INDEX 5
134 /* hardcode those limit for now */
135 #define RADEON_VA_IB_OFFSET (1 << 20)
136 #define RADEON_VA_RESERVED_SIZE (8 << 20)
137 #define RADEON_IB_VM_MAX_SIZE (64 << 10)
140 #define RADEON_RESET_GFX (1 << 0)
141 #define RADEON_RESET_COMPUTE (1 << 1)
142 #define RADEON_RESET_DMA (1 << 2)
143 #define RADEON_RESET_CP (1 << 3)
144 #define RADEON_RESET_GRBM (1 << 4)
145 #define RADEON_RESET_DMA1 (1 << 5)
146 #define RADEON_RESET_RLC (1 << 6)
147 #define RADEON_RESET_SEM (1 << 7)
148 #define RADEON_RESET_IH (1 << 8)
149 #define RADEON_RESET_VMC (1 << 9)
150 #define RADEON_RESET_MC (1 << 10)
151 #define RADEON_RESET_DISPLAY (1 << 11)
153 /* max cursor sizes (in pixels) */
154 #define CURSOR_WIDTH 64
155 #define CURSOR_HEIGHT 64
157 #define CIK_CURSOR_WIDTH 128
158 #define CIK_CURSOR_HEIGHT 128
161 * Errata workarounds.
163 enum radeon_pll_errata
{
164 CHIP_ERRATA_R300_CG
= 0x00000001,
165 CHIP_ERRATA_PLL_DUMMYREADS
= 0x00000002,
166 CHIP_ERRATA_PLL_DELAY
= 0x00000004
170 struct radeon_device
;
176 bool radeon_get_bios(struct radeon_device
*rdev
);
181 struct radeon_dummy_page
{
185 int radeon_dummy_page_init(struct radeon_device
*rdev
);
186 void radeon_dummy_page_fini(struct radeon_device
*rdev
);
192 struct radeon_clock
{
193 struct radeon_pll p1pll
;
194 struct radeon_pll p2pll
;
195 struct radeon_pll dcpll
;
196 struct radeon_pll spll
;
197 struct radeon_pll mpll
;
199 uint32_t default_mclk
;
200 uint32_t default_sclk
;
201 uint32_t default_dispclk
;
203 uint32_t max_pixel_clock
;
209 int radeon_pm_init(struct radeon_device
*rdev
);
210 void radeon_pm_fini(struct radeon_device
*rdev
);
211 void radeon_pm_compute_clocks(struct radeon_device
*rdev
);
212 void radeon_pm_suspend(struct radeon_device
*rdev
);
213 void radeon_pm_resume(struct radeon_device
*rdev
);
214 void radeon_combios_get_power_modes(struct radeon_device
*rdev
);
215 void radeon_atombios_get_power_modes(struct radeon_device
*rdev
);
216 int radeon_atom_get_clock_dividers(struct radeon_device
*rdev
,
220 struct atom_clock_dividers
*dividers
);
221 void radeon_atom_set_voltage(struct radeon_device
*rdev
, u16 voltage_level
, u8 voltage_type
);
222 void rs690_pm_info(struct radeon_device
*rdev
);
223 extern void evergreen_tiling_fields(unsigned tiling_flags
, unsigned *bankw
,
224 unsigned *bankh
, unsigned *mtaspect
,
225 unsigned *tile_split
);
230 struct radeon_fence_driver
{
231 uint32_t scratch_reg
;
233 volatile uint32_t *cpu_addr
;
234 /* sync_seq is protected by ring emission lock */
235 uint64_t sync_seq
[RADEON_NUM_RINGS
];
237 unsigned long last_activity
;
241 struct radeon_fence
{
242 struct radeon_device
*rdev
;
244 /* protected by radeon_fence.lock */
250 int radeon_fence_driver_start_ring(struct radeon_device
*rdev
, int ring
);
251 int radeon_fence_driver_init(struct radeon_device
*rdev
);
252 void radeon_fence_driver_fini(struct radeon_device
*rdev
);
253 void radeon_fence_driver_force_completion(struct radeon_device
*rdev
);
254 int radeon_fence_emit(struct radeon_device
*rdev
, struct radeon_fence
**fence
, int ring
);
255 void radeon_fence_process(struct radeon_device
*rdev
, int ring
);
256 bool radeon_fence_signaled(struct radeon_fence
*fence
);
257 int radeon_fence_wait(struct radeon_fence
*fence
, bool interruptible
);
258 int radeon_fence_wait_next_locked(struct radeon_device
*rdev
, int ring
);
259 int radeon_fence_wait_empty_locked(struct radeon_device
*rdev
, int ring
);
260 int radeon_fence_wait_any(struct radeon_device
*rdev
,
261 struct radeon_fence
**fences
,
263 struct radeon_fence
*radeon_fence_ref(struct radeon_fence
*fence
);
264 void radeon_fence_unref(struct radeon_fence
**fence
);
265 unsigned radeon_fence_count_emitted(struct radeon_device
*rdev
, int ring
);
266 bool radeon_fence_need_sync(struct radeon_fence
*fence
, int ring
);
267 void radeon_fence_note_sync(struct radeon_fence
*fence
, int ring
);
268 static inline struct radeon_fence
*radeon_fence_later(struct radeon_fence
*a
,
269 struct radeon_fence
*b
)
279 BUG_ON(a
->ring
!= b
->ring
);
281 if (a
->seq
> b
->seq
) {
288 static inline bool radeon_fence_is_earlier(struct radeon_fence
*a
,
289 struct radeon_fence
*b
)
299 BUG_ON(a
->ring
!= b
->ring
);
301 return a
->seq
< b
->seq
;
307 struct radeon_surface_reg
{
308 struct radeon_bo
*bo
;
311 #define RADEON_GEM_MAX_SURFACES 8
317 struct ttm_bo_global_ref bo_global_ref
;
318 struct drm_global_reference mem_global_ref
;
319 struct ttm_bo_device bdev
;
320 bool mem_global_referenced
;
324 /* bo virtual address in a specific vm */
325 struct radeon_bo_va
{
326 /* protected by bo being reserved */
327 struct list_head bo_list
;
334 /* protected by vm mutex */
335 struct list_head vm_list
;
337 /* constant after initialization */
338 struct radeon_vm
*vm
;
339 struct radeon_bo
*bo
;
343 /* Protected by gem.mutex */
344 struct list_head list
;
345 /* Protected by tbo.reserved */
347 struct ttm_placement placement
;
348 struct ttm_buffer_object tbo
;
349 struct ttm_bo_kmap_obj kmap
;
355 /* list of all virtual address to which this bo
359 /* Constant after initialization */
360 struct radeon_device
*rdev
;
361 struct drm_gem_object gem_base
;
363 struct ttm_bo_kmap_obj dma_buf_vmap
;
366 #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
368 struct radeon_bo_list
{
369 struct ttm_validate_buffer tv
;
370 struct radeon_bo
*bo
;
378 int radeon_gem_debugfs_init(struct radeon_device
*rdev
);
380 /* sub-allocation manager, it has to be protected by another lock.
381 * By conception this is an helper for other part of the driver
382 * like the indirect buffer or semaphore, which both have their
385 * Principe is simple, we keep a list of sub allocation in offset
386 * order (first entry has offset == 0, last entry has the highest
389 * When allocating new object we first check if there is room at
390 * the end total_size - (last_object_offset + last_object_size) >=
391 * alloc_size. If so we allocate new object there.
393 * When there is not enough room at the end, we start waiting for
394 * each sub object until we reach object_offset+object_size >=
395 * alloc_size, this object then become the sub object we return.
397 * Alignment can't be bigger than page size.
399 * Hole are not considered for allocation to keep things simple.
400 * Assumption is that there won't be hole (all object on same
403 struct radeon_sa_manager
{
404 wait_queue_head_t wq
;
405 struct radeon_bo
*bo
;
406 struct list_head
*hole
;
407 struct list_head flist
[RADEON_NUM_RINGS
];
408 struct list_head olist
;
417 /* sub-allocation buffer */
418 struct radeon_sa_bo
{
419 struct list_head olist
;
420 struct list_head flist
;
421 struct radeon_sa_manager
*manager
;
424 struct radeon_fence
*fence
;
432 struct list_head objects
;
435 int radeon_gem_init(struct radeon_device
*rdev
);
436 void radeon_gem_fini(struct radeon_device
*rdev
);
437 int radeon_gem_object_create(struct radeon_device
*rdev
, int size
,
438 int alignment
, int initial_domain
,
439 bool discardable
, bool kernel
,
440 struct drm_gem_object
**obj
);
442 int radeon_mode_dumb_create(struct drm_file
*file_priv
,
443 struct drm_device
*dev
,
444 struct drm_mode_create_dumb
*args
);
445 int radeon_mode_dumb_mmap(struct drm_file
*filp
,
446 struct drm_device
*dev
,
447 uint32_t handle
, uint64_t *offset_p
);
448 int radeon_mode_dumb_destroy(struct drm_file
*file_priv
,
449 struct drm_device
*dev
,
455 /* everything here is constant */
456 struct radeon_semaphore
{
457 struct radeon_sa_bo
*sa_bo
;
462 int radeon_semaphore_create(struct radeon_device
*rdev
,
463 struct radeon_semaphore
**semaphore
);
464 void radeon_semaphore_emit_signal(struct radeon_device
*rdev
, int ring
,
465 struct radeon_semaphore
*semaphore
);
466 void radeon_semaphore_emit_wait(struct radeon_device
*rdev
, int ring
,
467 struct radeon_semaphore
*semaphore
);
468 int radeon_semaphore_sync_rings(struct radeon_device
*rdev
,
469 struct radeon_semaphore
*semaphore
,
470 int signaler
, int waiter
);
471 void radeon_semaphore_free(struct radeon_device
*rdev
,
472 struct radeon_semaphore
**semaphore
,
473 struct radeon_fence
*fence
);
476 * GART structures, functions & helpers
480 #define RADEON_GPU_PAGE_SIZE 4096
481 #define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
482 #define RADEON_GPU_PAGE_SHIFT 12
483 #define RADEON_GPU_PAGE_ALIGN(a) (((a) + RADEON_GPU_PAGE_MASK) & ~RADEON_GPU_PAGE_MASK)
486 dma_addr_t table_addr
;
487 struct radeon_bo
*robj
;
489 unsigned num_gpu_pages
;
490 unsigned num_cpu_pages
;
493 dma_addr_t
*pages_addr
;
497 int radeon_gart_table_ram_alloc(struct radeon_device
*rdev
);
498 void radeon_gart_table_ram_free(struct radeon_device
*rdev
);
499 int radeon_gart_table_vram_alloc(struct radeon_device
*rdev
);
500 void radeon_gart_table_vram_free(struct radeon_device
*rdev
);
501 int radeon_gart_table_vram_pin(struct radeon_device
*rdev
);
502 void radeon_gart_table_vram_unpin(struct radeon_device
*rdev
);
503 int radeon_gart_init(struct radeon_device
*rdev
);
504 void radeon_gart_fini(struct radeon_device
*rdev
);
505 void radeon_gart_unbind(struct radeon_device
*rdev
, unsigned offset
,
507 int radeon_gart_bind(struct radeon_device
*rdev
, unsigned offset
,
508 int pages
, struct page
**pagelist
,
509 dma_addr_t
*dma_addr
);
510 void radeon_gart_restore(struct radeon_device
*rdev
);
514 * GPU MC structures, functions & helpers
517 resource_size_t aper_size
;
518 resource_size_t aper_base
;
519 resource_size_t agp_base
;
520 /* for some chips with <= 32MB we need to lie
521 * about vram size near mc fb location */
523 u64 visible_vram_size
;
533 bool igp_sideport_enabled
;
538 bool radeon_combios_sideport_present(struct radeon_device
*rdev
);
539 bool radeon_atombios_sideport_present(struct radeon_device
*rdev
);
542 * GPU scratch registers structures, functions & helpers
544 struct radeon_scratch
{
551 int radeon_scratch_get(struct radeon_device
*rdev
, uint32_t *reg
);
552 void radeon_scratch_free(struct radeon_device
*rdev
, uint32_t reg
);
555 * GPU doorbell structures, functions & helpers
557 struct radeon_doorbell
{
561 resource_size_t base
;
562 resource_size_t size
;
566 int radeon_doorbell_get(struct radeon_device
*rdev
, u32
*page
);
567 void radeon_doorbell_free(struct radeon_device
*rdev
, u32 doorbell
);
573 struct radeon_unpin_work
{
574 struct work_struct work
;
575 struct radeon_device
*rdev
;
577 struct radeon_fence
*fence
;
578 struct drm_pending_vblank_event
*event
;
579 struct radeon_bo
*old_rbo
;
583 struct r500_irq_stat_regs
{
588 struct r600_irq_stat_regs
{
598 struct evergreen_irq_stat_regs
{
619 struct cik_irq_stat_regs
{
629 union radeon_irq_stat_regs
{
630 struct r500_irq_stat_regs r500
;
631 struct r600_irq_stat_regs r600
;
632 struct evergreen_irq_stat_regs evergreen
;
633 struct cik_irq_stat_regs cik
;
636 #define RADEON_MAX_HPD_PINS 6
637 #define RADEON_MAX_CRTCS 6
638 #define RADEON_MAX_AFMT_BLOCKS 6
643 atomic_t ring_int
[RADEON_NUM_RINGS
];
644 bool crtc_vblank_int
[RADEON_MAX_CRTCS
];
645 atomic_t pflip
[RADEON_MAX_CRTCS
];
646 wait_queue_head_t vblank_queue
;
647 bool hpd
[RADEON_MAX_HPD_PINS
];
648 bool afmt
[RADEON_MAX_AFMT_BLOCKS
];
649 union radeon_irq_stat_regs stat_regs
;
652 int radeon_irq_kms_init(struct radeon_device
*rdev
);
653 void radeon_irq_kms_fini(struct radeon_device
*rdev
);
654 void radeon_irq_kms_sw_irq_get(struct radeon_device
*rdev
, int ring
);
655 void radeon_irq_kms_sw_irq_put(struct radeon_device
*rdev
, int ring
);
656 void radeon_irq_kms_pflip_irq_get(struct radeon_device
*rdev
, int crtc
);
657 void radeon_irq_kms_pflip_irq_put(struct radeon_device
*rdev
, int crtc
);
658 void radeon_irq_kms_enable_afmt(struct radeon_device
*rdev
, int block
);
659 void radeon_irq_kms_disable_afmt(struct radeon_device
*rdev
, int block
);
660 void radeon_irq_kms_enable_hpd(struct radeon_device
*rdev
, unsigned hpd_mask
);
661 void radeon_irq_kms_disable_hpd(struct radeon_device
*rdev
, unsigned hpd_mask
);
668 struct radeon_sa_bo
*sa_bo
;
673 struct radeon_fence
*fence
;
674 struct radeon_vm
*vm
;
676 struct radeon_fence
*sync_to
[RADEON_NUM_RINGS
];
677 struct radeon_semaphore
*semaphore
;
681 struct radeon_bo
*ring_obj
;
682 volatile uint32_t *ring
;
686 unsigned rptr_save_reg
;
687 u64 next_rptr_gpu_addr
;
688 volatile u32
*next_rptr_cpu_addr
;
693 unsigned ring_free_dw
;
695 unsigned long last_activity
;
705 u64 last_semaphore_signal_addr
;
706 u64 last_semaphore_wait_addr
;
711 struct radeon_bo
*mqd_obj
;
712 u32 doorbell_page_num
;
718 struct radeon_bo
*hpd_eop_obj
;
719 u64 hpd_eop_gpu_addr
;
729 /* maximum number of VMIDs */
730 #define RADEON_NUM_VM 16
732 /* defines number of bits in page table versus page directory,
733 * a page is 4KB so we have 12 bits offset, 9 bits in the page
734 * table and the remaining 19 bits are in the page directory */
735 #define RADEON_VM_BLOCK_SIZE 9
737 /* number of entries in page table */
738 #define RADEON_VM_PTE_COUNT (1 << RADEON_VM_BLOCK_SIZE)
741 struct list_head list
;
745 /* contains the page directory */
746 struct radeon_sa_bo
*page_directory
;
747 uint64_t pd_gpu_addr
;
749 /* array of page tables, one for each page directory entry */
750 struct radeon_sa_bo
**page_tables
;
753 /* last fence for cs using this vm */
754 struct radeon_fence
*fence
;
755 /* last flush or NULL if we still need to flush */
756 struct radeon_fence
*last_flush
;
759 struct radeon_vm_manager
{
761 struct list_head lru_vm
;
762 struct radeon_fence
*active
[RADEON_NUM_VM
];
763 struct radeon_sa_manager sa_manager
;
765 /* number of VMIDs */
767 /* vram base address for page table entry */
768 u64 vram_base_offset
;
774 * file private structure
776 struct radeon_fpriv
{
784 struct radeon_bo
*ring_obj
;
785 volatile uint32_t *ring
;
794 struct r600_blit_cp_primitives
{
795 void (*set_render_target
)(struct radeon_device
*rdev
, int format
,
796 int w
, int h
, u64 gpu_addr
);
797 void (*cp_set_surface_sync
)(struct radeon_device
*rdev
,
798 u32 sync_type
, u32 size
,
800 void (*set_shaders
)(struct radeon_device
*rdev
);
801 void (*set_vtx_resource
)(struct radeon_device
*rdev
, u64 gpu_addr
);
802 void (*set_tex_resource
)(struct radeon_device
*rdev
,
803 int format
, int w
, int h
, int pitch
,
804 u64 gpu_addr
, u32 size
);
805 void (*set_scissors
)(struct radeon_device
*rdev
, int x1
, int y1
,
807 void (*draw_auto
)(struct radeon_device
*rdev
);
808 void (*set_default_state
)(struct radeon_device
*rdev
);
812 struct radeon_bo
*shader_obj
;
813 struct r600_blit_cp_primitives primitives
;
815 int ring_size_common
;
816 int ring_size_per_loop
;
818 u32 vs_offset
, ps_offset
;
827 /* for power gating */
828 struct radeon_bo
*save_restore_obj
;
829 uint64_t save_restore_gpu_addr
;
830 /* for clear state */
831 struct radeon_bo
*clear_state_obj
;
832 uint64_t clear_state_gpu_addr
;
835 int radeon_ib_get(struct radeon_device
*rdev
, int ring
,
836 struct radeon_ib
*ib
, struct radeon_vm
*vm
,
838 void radeon_ib_free(struct radeon_device
*rdev
, struct radeon_ib
*ib
);
839 void radeon_ib_sync_to(struct radeon_ib
*ib
, struct radeon_fence
*fence
);
840 int radeon_ib_schedule(struct radeon_device
*rdev
, struct radeon_ib
*ib
,
841 struct radeon_ib
*const_ib
);
842 int radeon_ib_pool_init(struct radeon_device
*rdev
);
843 void radeon_ib_pool_fini(struct radeon_device
*rdev
);
844 int radeon_ib_ring_tests(struct radeon_device
*rdev
);
845 /* Ring access between begin & end cannot sleep */
846 bool radeon_ring_supports_scratch_reg(struct radeon_device
*rdev
,
847 struct radeon_ring
*ring
);
848 void radeon_ring_free_size(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
849 int radeon_ring_alloc(struct radeon_device
*rdev
, struct radeon_ring
*cp
, unsigned ndw
);
850 int radeon_ring_lock(struct radeon_device
*rdev
, struct radeon_ring
*cp
, unsigned ndw
);
851 void radeon_ring_commit(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
852 void radeon_ring_unlock_commit(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
853 void radeon_ring_undo(struct radeon_ring
*ring
);
854 void radeon_ring_unlock_undo(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
855 int radeon_ring_test(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
856 void radeon_ring_force_activity(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
857 void radeon_ring_lockup_update(struct radeon_ring
*ring
);
858 bool radeon_ring_test_lockup(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
859 unsigned radeon_ring_backup(struct radeon_device
*rdev
, struct radeon_ring
*ring
,
861 int radeon_ring_restore(struct radeon_device
*rdev
, struct radeon_ring
*ring
,
862 unsigned size
, uint32_t *data
);
863 int radeon_ring_init(struct radeon_device
*rdev
, struct radeon_ring
*cp
, unsigned ring_size
,
864 unsigned rptr_offs
, unsigned rptr_reg
, unsigned wptr_reg
,
865 u32 ptr_reg_shift
, u32 ptr_reg_mask
, u32 nop
);
866 void radeon_ring_fini(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
870 void r600_dma_stop(struct radeon_device
*rdev
);
871 int r600_dma_resume(struct radeon_device
*rdev
);
872 void r600_dma_fini(struct radeon_device
*rdev
);
874 void cayman_dma_stop(struct radeon_device
*rdev
);
875 int cayman_dma_resume(struct radeon_device
*rdev
);
876 void cayman_dma_fini(struct radeon_device
*rdev
);
881 struct radeon_cs_reloc
{
882 struct drm_gem_object
*gobj
;
883 struct radeon_bo
*robj
;
884 struct radeon_bo_list lobj
;
889 struct radeon_cs_chunk
{
895 void __user
*user_ptr
;
896 int last_copied_page
;
900 struct radeon_cs_parser
{
902 struct radeon_device
*rdev
;
903 struct drm_file
*filp
;
906 struct radeon_cs_chunk
*chunks
;
907 uint64_t *chunks_array
;
912 struct radeon_cs_reloc
*relocs
;
913 struct radeon_cs_reloc
**relocs_ptr
;
914 struct list_head validated
;
915 unsigned dma_reloc_idx
;
916 /* indices of various chunks */
918 int chunk_relocs_idx
;
920 int chunk_const_ib_idx
;
922 struct radeon_ib const_ib
;
931 extern int radeon_cs_finish_pages(struct radeon_cs_parser
*p
);
932 extern u32
radeon_get_ib_value(struct radeon_cs_parser
*p
, int idx
);
934 struct radeon_cs_packet
{
943 typedef int (*radeon_packet0_check_t
)(struct radeon_cs_parser
*p
,
944 struct radeon_cs_packet
*pkt
,
945 unsigned idx
, unsigned reg
);
946 typedef int (*radeon_packet3_check_t
)(struct radeon_cs_parser
*p
,
947 struct radeon_cs_packet
*pkt
);
953 int radeon_agp_init(struct radeon_device
*rdev
);
954 void radeon_agp_resume(struct radeon_device
*rdev
);
955 void radeon_agp_suspend(struct radeon_device
*rdev
);
956 void radeon_agp_fini(struct radeon_device
*rdev
);
963 struct radeon_bo
*wb_obj
;
964 volatile uint32_t *wb
;
970 #define RADEON_WB_SCRATCH_OFFSET 0
971 #define RADEON_WB_RING0_NEXT_RPTR 256
972 #define RADEON_WB_CP_RPTR_OFFSET 1024
973 #define RADEON_WB_CP1_RPTR_OFFSET 1280
974 #define RADEON_WB_CP2_RPTR_OFFSET 1536
975 #define R600_WB_DMA_RPTR_OFFSET 1792
976 #define R600_WB_IH_WPTR_OFFSET 2048
977 #define CAYMAN_WB_DMA1_RPTR_OFFSET 2304
978 #define R600_WB_UVD_RPTR_OFFSET 2560
979 #define R600_WB_EVENT_OFFSET 3072
980 #define CIK_WB_CP1_WPTR_OFFSET 3328
981 #define CIK_WB_CP2_WPTR_OFFSET 3584
984 * struct radeon_pm - power management datas
985 * @max_bandwidth: maximum bandwidth the gpu has (MByte/s)
986 * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880)
987 * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880)
988 * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880)
989 * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880)
990 * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP)
991 * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
992 * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP)
993 * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP)
994 * @sclk: GPU clock Mhz (core bandwidth depends of this clock)
995 * @needed_bandwidth: current bandwidth needs
997 * It keeps track of various data needed to take powermanagement decision.
998 * Bandwidth need is used to determine minimun clock of the GPU and memory.
999 * Equation between gpu/memory clock and available bandwidth is hw dependent
1000 * (type of memory, bus size, efficiency, ...)
1003 enum radeon_pm_method
{
1008 enum radeon_dynpm_state
{
1009 DYNPM_STATE_DISABLED
,
1010 DYNPM_STATE_MINIMUM
,
1013 DYNPM_STATE_SUSPENDED
,
1015 enum radeon_dynpm_action
{
1017 DYNPM_ACTION_MINIMUM
,
1018 DYNPM_ACTION_DOWNCLOCK
,
1019 DYNPM_ACTION_UPCLOCK
,
1020 DYNPM_ACTION_DEFAULT
1023 enum radeon_voltage_type
{
1030 enum radeon_pm_state_type
{
1031 POWER_STATE_TYPE_DEFAULT
,
1032 POWER_STATE_TYPE_POWERSAVE
,
1033 POWER_STATE_TYPE_BATTERY
,
1034 POWER_STATE_TYPE_BALANCED
,
1035 POWER_STATE_TYPE_PERFORMANCE
,
1038 enum radeon_pm_profile_type
{
1046 #define PM_PROFILE_DEFAULT_IDX 0
1047 #define PM_PROFILE_LOW_SH_IDX 1
1048 #define PM_PROFILE_MID_SH_IDX 2
1049 #define PM_PROFILE_HIGH_SH_IDX 3
1050 #define PM_PROFILE_LOW_MH_IDX 4
1051 #define PM_PROFILE_MID_MH_IDX 5
1052 #define PM_PROFILE_HIGH_MH_IDX 6
1053 #define PM_PROFILE_MAX 7
1055 struct radeon_pm_profile
{
1056 int dpms_off_ps_idx
;
1058 int dpms_off_cm_idx
;
1062 enum radeon_int_thermal_type
{
1066 THERMAL_TYPE_EVERGREEN
,
1073 struct radeon_voltage
{
1074 enum radeon_voltage_type type
;
1076 struct radeon_gpio_rec gpio
;
1077 u32 delay
; /* delay in usec from voltage drop to sclk change */
1078 bool active_high
; /* voltage drop is active when bit is high */
1080 u8 vddc_id
; /* index into vddc voltage table */
1081 u8 vddci_id
; /* index into vddci voltage table */
1085 /* evergreen+ vddci */
1089 /* clock mode flags */
1090 #define RADEON_PM_MODE_NO_DISPLAY (1 << 0)
1092 struct radeon_pm_clock_info
{
1098 struct radeon_voltage voltage
;
1099 /* standardized clock flags */
1104 #define RADEON_PM_STATE_SINGLE_DISPLAY_ONLY (1 << 0)
1106 struct radeon_power_state
{
1107 enum radeon_pm_state_type type
;
1108 struct radeon_pm_clock_info
*clock_info
;
1109 /* number of valid clock modes in this power state */
1110 int num_clock_modes
;
1111 struct radeon_pm_clock_info
*default_clock_mode
;
1112 /* standardized state flags */
1114 u32 misc
; /* vbios specific flags */
1115 u32 misc2
; /* vbios specific flags */
1116 int pcie_lanes
; /* pcie lanes */
1120 * Some modes are overclocked by very low value, accept them
1122 #define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */
1126 /* write locked while reprogramming mclk */
1127 struct rw_semaphore mclk_lock
;
1129 int active_crtc_count
;
1132 fixed20_12 max_bandwidth
;
1133 fixed20_12 igp_sideport_mclk
;
1134 fixed20_12 igp_system_mclk
;
1135 fixed20_12 igp_ht_link_clk
;
1136 fixed20_12 igp_ht_link_width
;
1137 fixed20_12 k8_bandwidth
;
1138 fixed20_12 sideport_bandwidth
;
1139 fixed20_12 ht_bandwidth
;
1140 fixed20_12 core_bandwidth
;
1143 fixed20_12 needed_bandwidth
;
1144 struct radeon_power_state
*power_state
;
1145 /* number of valid power states */
1146 int num_power_states
;
1147 int current_power_state_index
;
1148 int current_clock_mode_index
;
1149 int requested_power_state_index
;
1150 int requested_clock_mode_index
;
1151 int default_power_state_index
;
1160 struct radeon_i2c_chan
*i2c_bus
;
1161 /* selected pm method */
1162 enum radeon_pm_method pm_method
;
1163 /* dynpm power management */
1164 struct delayed_work dynpm_idle_work
;
1165 enum radeon_dynpm_state dynpm_state
;
1166 enum radeon_dynpm_action dynpm_planned_action
;
1167 unsigned long dynpm_action_timeout
;
1168 bool dynpm_can_upclock
;
1169 bool dynpm_can_downclock
;
1170 /* profile-based power management */
1171 enum radeon_pm_profile_type profile
;
1173 struct radeon_pm_profile profiles
[PM_PROFILE_MAX
];
1174 /* internal thermal controller on rv6xx+ */
1175 enum radeon_int_thermal_type int_thermal_type
;
1176 struct device
*int_hwmon_dev
;
1179 int radeon_pm_get_type_index(struct radeon_device
*rdev
,
1180 enum radeon_pm_state_type ps_type
,
1185 #define RADEON_MAX_UVD_HANDLES 10
1186 #define RADEON_UVD_STACK_SIZE (1024*1024)
1187 #define RADEON_UVD_HEAP_SIZE (1024*1024)
1190 struct radeon_bo
*vcpu_bo
;
1193 atomic_t handles
[RADEON_MAX_UVD_HANDLES
];
1194 struct drm_file
*filp
[RADEON_MAX_UVD_HANDLES
];
1195 struct delayed_work idle_work
;
1198 int radeon_uvd_init(struct radeon_device
*rdev
);
1199 void radeon_uvd_fini(struct radeon_device
*rdev
);
1200 int radeon_uvd_suspend(struct radeon_device
*rdev
);
1201 int radeon_uvd_resume(struct radeon_device
*rdev
);
1202 int radeon_uvd_get_create_msg(struct radeon_device
*rdev
, int ring
,
1203 uint32_t handle
, struct radeon_fence
**fence
);
1204 int radeon_uvd_get_destroy_msg(struct radeon_device
*rdev
, int ring
,
1205 uint32_t handle
, struct radeon_fence
**fence
);
1206 void radeon_uvd_force_into_uvd_segment(struct radeon_bo
*rbo
);
1207 void radeon_uvd_free_handles(struct radeon_device
*rdev
,
1208 struct drm_file
*filp
);
1209 int radeon_uvd_cs_parse(struct radeon_cs_parser
*parser
);
1210 void radeon_uvd_note_usage(struct radeon_device
*rdev
);
1211 int radeon_uvd_calc_upll_dividers(struct radeon_device
*rdev
,
1212 unsigned vclk
, unsigned dclk
,
1213 unsigned vco_min
, unsigned vco_max
,
1214 unsigned fb_factor
, unsigned fb_mask
,
1215 unsigned pd_min
, unsigned pd_max
,
1217 unsigned *optimal_fb_div
,
1218 unsigned *optimal_vclk_div
,
1219 unsigned *optimal_dclk_div
);
1220 int radeon_uvd_send_upll_ctlreq(struct radeon_device
*rdev
,
1221 unsigned cg_upll_func_cntl
);
1226 int bits_per_sample
;
1234 void radeon_benchmark(struct radeon_device
*rdev
, int test_number
);
1240 void radeon_test_moves(struct radeon_device
*rdev
);
1241 void radeon_test_ring_sync(struct radeon_device
*rdev
,
1242 struct radeon_ring
*cpA
,
1243 struct radeon_ring
*cpB
);
1244 void radeon_test_syncing(struct radeon_device
*rdev
);
1250 struct radeon_debugfs
{
1251 struct drm_info_list
*files
;
1255 int radeon_debugfs_add_files(struct radeon_device
*rdev
,
1256 struct drm_info_list
*files
,
1258 int radeon_debugfs_fence_init(struct radeon_device
*rdev
);
1262 * ASIC specific functions.
1264 struct radeon_asic
{
1265 int (*init
)(struct radeon_device
*rdev
);
1266 void (*fini
)(struct radeon_device
*rdev
);
1267 int (*resume
)(struct radeon_device
*rdev
);
1268 int (*suspend
)(struct radeon_device
*rdev
);
1269 void (*vga_set_state
)(struct radeon_device
*rdev
, bool state
);
1270 int (*asic_reset
)(struct radeon_device
*rdev
);
1271 /* ioctl hw specific callback. Some hw might want to perform special
1272 * operation on specific ioctl. For instance on wait idle some hw
1273 * might want to perform and HDP flush through MMIO as it seems that
1274 * some R6XX/R7XX hw doesn't take HDP flush into account if programmed
1277 void (*ioctl_wait_idle
)(struct radeon_device
*rdev
, struct radeon_bo
*bo
);
1278 /* check if 3D engine is idle */
1279 bool (*gui_idle
)(struct radeon_device
*rdev
);
1280 /* wait for mc_idle */
1281 int (*mc_wait_for_idle
)(struct radeon_device
*rdev
);
1282 /* get the reference clock */
1283 u32 (*get_xclk
)(struct radeon_device
*rdev
);
1284 /* get the gpu clock counter */
1285 uint64_t (*get_gpu_clock_counter
)(struct radeon_device
*rdev
);
1288 void (*tlb_flush
)(struct radeon_device
*rdev
);
1289 int (*set_page
)(struct radeon_device
*rdev
, int i
, uint64_t addr
);
1292 int (*init
)(struct radeon_device
*rdev
);
1293 void (*fini
)(struct radeon_device
*rdev
);
1296 void (*set_page
)(struct radeon_device
*rdev
,
1297 struct radeon_ib
*ib
,
1299 uint64_t addr
, unsigned count
,
1300 uint32_t incr
, uint32_t flags
);
1302 /* ring specific callbacks */
1304 void (*ib_execute
)(struct radeon_device
*rdev
, struct radeon_ib
*ib
);
1305 int (*ib_parse
)(struct radeon_device
*rdev
, struct radeon_ib
*ib
);
1306 void (*emit_fence
)(struct radeon_device
*rdev
, struct radeon_fence
*fence
);
1307 void (*emit_semaphore
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
,
1308 struct radeon_semaphore
*semaphore
, bool emit_wait
);
1309 int (*cs_parse
)(struct radeon_cs_parser
*p
);
1310 void (*ring_start
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
1311 int (*ring_test
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
1312 int (*ib_test
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
1313 bool (*is_lockup
)(struct radeon_device
*rdev
, struct radeon_ring
*cp
);
1314 void (*vm_flush
)(struct radeon_device
*rdev
, int ridx
, struct radeon_vm
*vm
);
1316 u32 (*get_rptr
)(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
1317 u32 (*get_wptr
)(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
1318 void (*set_wptr
)(struct radeon_device
*rdev
, struct radeon_ring
*ring
);
1319 } ring
[RADEON_NUM_RINGS
];
1322 int (*set
)(struct radeon_device
*rdev
);
1323 int (*process
)(struct radeon_device
*rdev
);
1327 /* display watermarks */
1328 void (*bandwidth_update
)(struct radeon_device
*rdev
);
1329 /* get frame count */
1330 u32 (*get_vblank_counter
)(struct radeon_device
*rdev
, int crtc
);
1331 /* wait for vblank */
1332 void (*wait_for_vblank
)(struct radeon_device
*rdev
, int crtc
);
1333 /* set backlight level */
1334 void (*set_backlight_level
)(struct radeon_encoder
*radeon_encoder
, u8 level
);
1335 /* get backlight level */
1336 u8 (*get_backlight_level
)(struct radeon_encoder
*radeon_encoder
);
1337 /* audio callbacks */
1338 void (*hdmi_enable
)(struct drm_encoder
*encoder
, bool enable
);
1339 void (*hdmi_setmode
)(struct drm_encoder
*encoder
, struct drm_display_mode
*mode
);
1341 /* copy functions for bo handling */
1343 int (*blit
)(struct radeon_device
*rdev
,
1344 uint64_t src_offset
,
1345 uint64_t dst_offset
,
1346 unsigned num_gpu_pages
,
1347 struct radeon_fence
**fence
);
1348 u32 blit_ring_index
;
1349 int (*dma
)(struct radeon_device
*rdev
,
1350 uint64_t src_offset
,
1351 uint64_t dst_offset
,
1352 unsigned num_gpu_pages
,
1353 struct radeon_fence
**fence
);
1355 /* method used for bo copy */
1356 int (*copy
)(struct radeon_device
*rdev
,
1357 uint64_t src_offset
,
1358 uint64_t dst_offset
,
1359 unsigned num_gpu_pages
,
1360 struct radeon_fence
**fence
);
1361 /* ring used for bo copies */
1362 u32 copy_ring_index
;
1366 int (*set_reg
)(struct radeon_device
*rdev
, int reg
,
1367 uint32_t tiling_flags
, uint32_t pitch
,
1368 uint32_t offset
, uint32_t obj_size
);
1369 void (*clear_reg
)(struct radeon_device
*rdev
, int reg
);
1371 /* hotplug detect */
1373 void (*init
)(struct radeon_device
*rdev
);
1374 void (*fini
)(struct radeon_device
*rdev
);
1375 bool (*sense
)(struct radeon_device
*rdev
, enum radeon_hpd_id hpd
);
1376 void (*set_polarity
)(struct radeon_device
*rdev
, enum radeon_hpd_id hpd
);
1378 /* power management */
1380 void (*misc
)(struct radeon_device
*rdev
);
1381 void (*prepare
)(struct radeon_device
*rdev
);
1382 void (*finish
)(struct radeon_device
*rdev
);
1383 void (*init_profile
)(struct radeon_device
*rdev
);
1384 void (*get_dynpm_state
)(struct radeon_device
*rdev
);
1385 uint32_t (*get_engine_clock
)(struct radeon_device
*rdev
);
1386 void (*set_engine_clock
)(struct radeon_device
*rdev
, uint32_t eng_clock
);
1387 uint32_t (*get_memory_clock
)(struct radeon_device
*rdev
);
1388 void (*set_memory_clock
)(struct radeon_device
*rdev
, uint32_t mem_clock
);
1389 int (*get_pcie_lanes
)(struct radeon_device
*rdev
);
1390 void (*set_pcie_lanes
)(struct radeon_device
*rdev
, int lanes
);
1391 void (*set_clock_gating
)(struct radeon_device
*rdev
, int enable
);
1392 int (*set_uvd_clocks
)(struct radeon_device
*rdev
, u32 vclk
, u32 dclk
);
1393 int (*get_temperature
)(struct radeon_device
*rdev
);
1397 void (*pre_page_flip
)(struct radeon_device
*rdev
, int crtc
);
1398 u32 (*page_flip
)(struct radeon_device
*rdev
, int crtc
, u64 crtc_base
);
1399 void (*post_page_flip
)(struct radeon_device
*rdev
, int crtc
);
1407 const unsigned *reg_safe_bm
;
1408 unsigned reg_safe_bm_size
;
1413 const unsigned *reg_safe_bm
;
1414 unsigned reg_safe_bm_size
;
1421 unsigned max_tile_pipes
;
1423 unsigned max_backends
;
1425 unsigned max_threads
;
1426 unsigned max_stack_entries
;
1427 unsigned max_hw_contexts
;
1428 unsigned max_gs_threads
;
1429 unsigned sx_max_export_size
;
1430 unsigned sx_max_export_pos_size
;
1431 unsigned sx_max_export_smx_size
;
1432 unsigned sq_num_cf_insts
;
1433 unsigned tiling_nbanks
;
1434 unsigned tiling_npipes
;
1435 unsigned tiling_group_size
;
1436 unsigned tile_config
;
1437 unsigned backend_map
;
1442 unsigned max_tile_pipes
;
1444 unsigned max_backends
;
1446 unsigned max_threads
;
1447 unsigned max_stack_entries
;
1448 unsigned max_hw_contexts
;
1449 unsigned max_gs_threads
;
1450 unsigned sx_max_export_size
;
1451 unsigned sx_max_export_pos_size
;
1452 unsigned sx_max_export_smx_size
;
1453 unsigned sq_num_cf_insts
;
1454 unsigned sx_num_of_sets
;
1455 unsigned sc_prim_fifo_size
;
1456 unsigned sc_hiz_tile_fifo_size
;
1457 unsigned sc_earlyz_tile_fifo_fize
;
1458 unsigned tiling_nbanks
;
1459 unsigned tiling_npipes
;
1460 unsigned tiling_group_size
;
1461 unsigned tile_config
;
1462 unsigned backend_map
;
1465 struct evergreen_asic
{
1468 unsigned max_tile_pipes
;
1470 unsigned max_backends
;
1472 unsigned max_threads
;
1473 unsigned max_stack_entries
;
1474 unsigned max_hw_contexts
;
1475 unsigned max_gs_threads
;
1476 unsigned sx_max_export_size
;
1477 unsigned sx_max_export_pos_size
;
1478 unsigned sx_max_export_smx_size
;
1479 unsigned sq_num_cf_insts
;
1480 unsigned sx_num_of_sets
;
1481 unsigned sc_prim_fifo_size
;
1482 unsigned sc_hiz_tile_fifo_size
;
1483 unsigned sc_earlyz_tile_fifo_size
;
1484 unsigned tiling_nbanks
;
1485 unsigned tiling_npipes
;
1486 unsigned tiling_group_size
;
1487 unsigned tile_config
;
1488 unsigned backend_map
;
1491 struct cayman_asic
{
1492 unsigned max_shader_engines
;
1493 unsigned max_pipes_per_simd
;
1494 unsigned max_tile_pipes
;
1495 unsigned max_simds_per_se
;
1496 unsigned max_backends_per_se
;
1497 unsigned max_texture_channel_caches
;
1499 unsigned max_threads
;
1500 unsigned max_gs_threads
;
1501 unsigned max_stack_entries
;
1502 unsigned sx_num_of_sets
;
1503 unsigned sx_max_export_size
;
1504 unsigned sx_max_export_pos_size
;
1505 unsigned sx_max_export_smx_size
;
1506 unsigned max_hw_contexts
;
1507 unsigned sq_num_cf_insts
;
1508 unsigned sc_prim_fifo_size
;
1509 unsigned sc_hiz_tile_fifo_size
;
1510 unsigned sc_earlyz_tile_fifo_size
;
1512 unsigned num_shader_engines
;
1513 unsigned num_shader_pipes_per_simd
;
1514 unsigned num_tile_pipes
;
1515 unsigned num_simds_per_se
;
1516 unsigned num_backends_per_se
;
1517 unsigned backend_disable_mask_per_asic
;
1518 unsigned backend_map
;
1519 unsigned num_texture_channel_caches
;
1520 unsigned mem_max_burst_length_bytes
;
1521 unsigned mem_row_size_in_kb
;
1522 unsigned shader_engine_tile_size
;
1524 unsigned multi_gpu_tile_size
;
1526 unsigned tile_config
;
1530 unsigned max_shader_engines
;
1531 unsigned max_tile_pipes
;
1532 unsigned max_cu_per_sh
;
1533 unsigned max_sh_per_se
;
1534 unsigned max_backends_per_se
;
1535 unsigned max_texture_channel_caches
;
1537 unsigned max_gs_threads
;
1538 unsigned max_hw_contexts
;
1539 unsigned sc_prim_fifo_size_frontend
;
1540 unsigned sc_prim_fifo_size_backend
;
1541 unsigned sc_hiz_tile_fifo_size
;
1542 unsigned sc_earlyz_tile_fifo_size
;
1544 unsigned num_tile_pipes
;
1545 unsigned num_backends_per_se
;
1546 unsigned backend_disable_mask_per_asic
;
1547 unsigned backend_map
;
1548 unsigned num_texture_channel_caches
;
1549 unsigned mem_max_burst_length_bytes
;
1550 unsigned mem_row_size_in_kb
;
1551 unsigned shader_engine_tile_size
;
1553 unsigned multi_gpu_tile_size
;
1555 unsigned tile_config
;
1556 uint32_t tile_mode_array
[32];
1560 unsigned max_shader_engines
;
1561 unsigned max_tile_pipes
;
1562 unsigned max_cu_per_sh
;
1563 unsigned max_sh_per_se
;
1564 unsigned max_backends_per_se
;
1565 unsigned max_texture_channel_caches
;
1567 unsigned max_gs_threads
;
1568 unsigned max_hw_contexts
;
1569 unsigned sc_prim_fifo_size_frontend
;
1570 unsigned sc_prim_fifo_size_backend
;
1571 unsigned sc_hiz_tile_fifo_size
;
1572 unsigned sc_earlyz_tile_fifo_size
;
1574 unsigned num_tile_pipes
;
1575 unsigned num_backends_per_se
;
1576 unsigned backend_disable_mask_per_asic
;
1577 unsigned backend_map
;
1578 unsigned num_texture_channel_caches
;
1579 unsigned mem_max_burst_length_bytes
;
1580 unsigned mem_row_size_in_kb
;
1581 unsigned shader_engine_tile_size
;
1583 unsigned multi_gpu_tile_size
;
1585 unsigned tile_config
;
1586 uint32_t tile_mode_array
[32];
1589 union radeon_asic_config
{
1590 struct r300_asic r300
;
1591 struct r100_asic r100
;
1592 struct r600_asic r600
;
1593 struct rv770_asic rv770
;
1594 struct evergreen_asic evergreen
;
1595 struct cayman_asic cayman
;
1597 struct cik_asic cik
;
1601 * asic initizalization from radeon_asic.c
1603 void radeon_agp_disable(struct radeon_device
*rdev
);
1604 int radeon_asic_init(struct radeon_device
*rdev
);
1610 int radeon_gem_info_ioctl(struct drm_device
*dev
, void *data
,
1611 struct drm_file
*filp
);
1612 int radeon_gem_create_ioctl(struct drm_device
*dev
, void *data
,
1613 struct drm_file
*filp
);
1614 int radeon_gem_pin_ioctl(struct drm_device
*dev
, void *data
,
1615 struct drm_file
*file_priv
);
1616 int radeon_gem_unpin_ioctl(struct drm_device
*dev
, void *data
,
1617 struct drm_file
*file_priv
);
1618 int radeon_gem_pwrite_ioctl(struct drm_device
*dev
, void *data
,
1619 struct drm_file
*file_priv
);
1620 int radeon_gem_pread_ioctl(struct drm_device
*dev
, void *data
,
1621 struct drm_file
*file_priv
);
1622 int radeon_gem_set_domain_ioctl(struct drm_device
*dev
, void *data
,
1623 struct drm_file
*filp
);
1624 int radeon_gem_mmap_ioctl(struct drm_device
*dev
, void *data
,
1625 struct drm_file
*filp
);
1626 int radeon_gem_busy_ioctl(struct drm_device
*dev
, void *data
,
1627 struct drm_file
*filp
);
1628 int radeon_gem_wait_idle_ioctl(struct drm_device
*dev
, void *data
,
1629 struct drm_file
*filp
);
1630 int radeon_gem_va_ioctl(struct drm_device
*dev
, void *data
,
1631 struct drm_file
*filp
);
1632 int radeon_cs_ioctl(struct drm_device
*dev
, void *data
, struct drm_file
*filp
);
1633 int radeon_gem_set_tiling_ioctl(struct drm_device
*dev
, void *data
,
1634 struct drm_file
*filp
);
1635 int radeon_gem_get_tiling_ioctl(struct drm_device
*dev
, void *data
,
1636 struct drm_file
*filp
);
1638 /* VRAM scratch page for HDP bug, default vram page */
1639 struct r600_vram_scratch
{
1640 struct radeon_bo
*robj
;
1641 volatile uint32_t *ptr
;
1648 struct radeon_atif_notification_cfg
{
1653 struct radeon_atif_notifications
{
1654 bool display_switch
;
1655 bool expansion_mode_change
;
1657 bool forced_power_state
;
1658 bool system_power_state
;
1659 bool display_conf_change
;
1661 bool brightness_change
;
1662 bool dgpu_display_event
;
1665 struct radeon_atif_functions
{
1667 bool sbios_requests
;
1668 bool select_active_disp
;
1670 bool get_tv_standard
;
1671 bool set_tv_standard
;
1672 bool get_panel_expansion_mode
;
1673 bool set_panel_expansion_mode
;
1674 bool temperature_change
;
1675 bool graphics_device_types
;
1678 struct radeon_atif
{
1679 struct radeon_atif_notifications notifications
;
1680 struct radeon_atif_functions functions
;
1681 struct radeon_atif_notification_cfg notification_cfg
;
1682 struct radeon_encoder
*encoder_for_bl
;
1685 struct radeon_atcs_functions
{
1689 bool pcie_bus_width
;
1692 struct radeon_atcs
{
1693 struct radeon_atcs_functions functions
;
1697 * Core structure, functions and helpers.
1699 typedef uint32_t (*radeon_rreg_t
)(struct radeon_device
*, uint32_t);
1700 typedef void (*radeon_wreg_t
)(struct radeon_device
*, uint32_t, uint32_t);
1702 struct radeon_device
{
1704 struct drm_device
*ddev
;
1705 struct pci_dev
*pdev
;
1706 struct rw_semaphore exclusive_lock
;
1708 union radeon_asic_config config
;
1709 enum radeon_family family
;
1710 unsigned long flags
;
1712 enum radeon_pll_errata pll_errata
;
1719 uint16_t bios_header_start
;
1720 struct radeon_bo
*stollen_vga_memory
;
1722 resource_size_t rmmio_base
;
1723 resource_size_t rmmio_size
;
1724 /* protects concurrent MM_INDEX/DATA based register access */
1725 spinlock_t mmio_idx_lock
;
1726 void __iomem
*rmmio
;
1727 radeon_rreg_t mc_rreg
;
1728 radeon_wreg_t mc_wreg
;
1729 radeon_rreg_t pll_rreg
;
1730 radeon_wreg_t pll_wreg
;
1731 uint32_t pcie_reg_mask
;
1732 radeon_rreg_t pciep_rreg
;
1733 radeon_wreg_t pciep_wreg
;
1735 void __iomem
*rio_mem
;
1736 resource_size_t rio_mem_size
;
1737 struct radeon_clock clock
;
1738 struct radeon_mc mc
;
1739 struct radeon_gart gart
;
1740 struct radeon_mode_info mode_info
;
1741 struct radeon_scratch scratch
;
1742 struct radeon_doorbell doorbell
;
1743 struct radeon_mman mman
;
1744 struct radeon_fence_driver fence_drv
[RADEON_NUM_RINGS
];
1745 wait_queue_head_t fence_queue
;
1746 struct mutex ring_lock
;
1747 struct radeon_ring ring
[RADEON_NUM_RINGS
];
1749 struct radeon_sa_manager ring_tmp_bo
;
1750 struct radeon_irq irq
;
1751 struct radeon_asic
*asic
;
1752 struct radeon_gem gem
;
1753 struct radeon_pm pm
;
1754 struct radeon_uvd uvd
;
1755 uint32_t bios_scratch
[RADEON_BIOS_NUM_SCRATCH
];
1756 struct radeon_wb wb
;
1757 struct radeon_dummy_page dummy_page
;
1762 bool fastfb_working
; /* IGP feature*/
1763 struct radeon_surface_reg surface_regs
[RADEON_GEM_MAX_SURFACES
];
1764 const struct firmware
*me_fw
; /* all family ME firmware */
1765 const struct firmware
*pfp_fw
; /* r6/700 PFP firmware */
1766 const struct firmware
*rlc_fw
; /* r6/700 RLC firmware */
1767 const struct firmware
*mc_fw
; /* NI MC firmware */
1768 const struct firmware
*ce_fw
; /* SI CE firmware */
1769 const struct firmware
*uvd_fw
; /* UVD firmware */
1770 const struct firmware
*mec_fw
; /* CIK MEC firmware */
1771 const struct firmware
*sdma_fw
; /* CIK SDMA firmware */
1772 struct r600_blit r600_blit
;
1773 struct r600_vram_scratch vram_scratch
;
1774 int msi_enabled
; /* msi enabled */
1775 struct r600_ih ih
; /* r6/700 interrupt ring */
1777 struct radeon_mec mec
;
1778 struct work_struct hotplug_work
;
1779 struct work_struct audio_work
;
1780 struct work_struct reset_work
;
1781 int num_crtc
; /* number of crtcs */
1782 struct mutex dc_hw_i2c_mutex
; /* display controller hw i2c mutex */
1785 struct r600_audio audio_status
; /* audio stuff */
1786 struct notifier_block acpi_nb
;
1787 /* only one userspace can use Hyperz features or CMASK at a time */
1788 struct drm_file
*hyperz_filp
;
1789 struct drm_file
*cmask_filp
;
1791 struct radeon_i2c_chan
*i2c_bus
[RADEON_MAX_I2C_BUS
];
1793 struct radeon_debugfs debugfs
[RADEON_DEBUGFS_MAX_COMPONENTS
];
1794 unsigned debugfs_count
;
1795 /* virtual memory */
1796 struct radeon_vm_manager vm_manager
;
1797 struct mutex gpu_clock_mutex
;
1798 /* ACPI interface */
1799 struct radeon_atif atif
;
1800 struct radeon_atcs atcs
;
1803 int radeon_device_init(struct radeon_device
*rdev
,
1804 struct drm_device
*ddev
,
1805 struct pci_dev
*pdev
,
1807 void radeon_device_fini(struct radeon_device
*rdev
);
1808 int radeon_gpu_wait_for_idle(struct radeon_device
*rdev
);
1810 uint32_t r100_mm_rreg(struct radeon_device
*rdev
, uint32_t reg
,
1811 bool always_indirect
);
1812 void r100_mm_wreg(struct radeon_device
*rdev
, uint32_t reg
, uint32_t v
,
1813 bool always_indirect
);
1814 u32
r100_io_rreg(struct radeon_device
*rdev
, u32 reg
);
1815 void r100_io_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
);
1817 u32
cik_mm_rdoorbell(struct radeon_device
*rdev
, u32 offset
);
1818 void cik_mm_wdoorbell(struct radeon_device
*rdev
, u32 offset
, u32 v
);
1823 #define to_radeon_fence(p) ((struct radeon_fence *)(p))
1826 * Registers read & write functions.
1828 #define RREG8(reg) readb((rdev->rmmio) + (reg))
1829 #define WREG8(reg, v) writeb(v, (rdev->rmmio) + (reg))
1830 #define RREG16(reg) readw((rdev->rmmio) + (reg))
1831 #define WREG16(reg, v) writew(v, (rdev->rmmio) + (reg))
1832 #define RREG32(reg) r100_mm_rreg(rdev, (reg), false)
1833 #define RREG32_IDX(reg) r100_mm_rreg(rdev, (reg), true)
1834 #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg), false))
1835 #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v), false)
1836 #define WREG32_IDX(reg, v) r100_mm_wreg(rdev, (reg), (v), true)
1837 #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
1838 #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
1839 #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
1840 #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
1841 #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
1842 #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
1843 #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
1844 #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
1845 #define RREG32_PCIE_PORT(reg) rdev->pciep_rreg(rdev, (reg))
1846 #define WREG32_PCIE_PORT(reg, v) rdev->pciep_wreg(rdev, (reg), (v))
1847 #define RREG32_SMC(reg) tn_smc_rreg(rdev, (reg))
1848 #define WREG32_SMC(reg, v) tn_smc_wreg(rdev, (reg), (v))
1849 #define RREG32_RCU(reg) r600_rcu_rreg(rdev, (reg))
1850 #define WREG32_RCU(reg, v) r600_rcu_wreg(rdev, (reg), (v))
1851 #define RREG32_CG(reg) eg_cg_rreg(rdev, (reg))
1852 #define WREG32_CG(reg, v) eg_cg_wreg(rdev, (reg), (v))
1853 #define WREG32_P(reg, val, mask) \
1855 uint32_t tmp_ = RREG32(reg); \
1857 tmp_ |= ((val) & ~(mask)); \
1858 WREG32(reg, tmp_); \
1860 #define WREG32_AND(reg, and) WREG32_P(reg, 0, and)
1861 #define WREG32_OR(reg, or) WREG32_P(reg, or, ~or)
1862 #define WREG32_PLL_P(reg, val, mask) \
1864 uint32_t tmp_ = RREG32_PLL(reg); \
1866 tmp_ |= ((val) & ~(mask)); \
1867 WREG32_PLL(reg, tmp_); \
1869 #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg), false))
1870 #define RREG32_IO(reg) r100_io_rreg(rdev, (reg))
1871 #define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v))
1873 #define RDOORBELL32(offset) cik_mm_rdoorbell(rdev, (offset))
1874 #define WDOORBELL32(offset, v) cik_mm_wdoorbell(rdev, (offset), (v))
1877 * Indirect registers accessor
1879 static inline uint32_t rv370_pcie_rreg(struct radeon_device
*rdev
, uint32_t reg
)
1883 WREG32(RADEON_PCIE_INDEX
, ((reg
) & rdev
->pcie_reg_mask
));
1884 r
= RREG32(RADEON_PCIE_DATA
);
1888 static inline void rv370_pcie_wreg(struct radeon_device
*rdev
, uint32_t reg
, uint32_t v
)
1890 WREG32(RADEON_PCIE_INDEX
, ((reg
) & rdev
->pcie_reg_mask
));
1891 WREG32(RADEON_PCIE_DATA
, (v
));
1894 static inline u32
tn_smc_rreg(struct radeon_device
*rdev
, u32 reg
)
1898 WREG32(TN_SMC_IND_INDEX_0
, (reg
));
1899 r
= RREG32(TN_SMC_IND_DATA_0
);
1903 static inline void tn_smc_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
1905 WREG32(TN_SMC_IND_INDEX_0
, (reg
));
1906 WREG32(TN_SMC_IND_DATA_0
, (v
));
1909 static inline u32
r600_rcu_rreg(struct radeon_device
*rdev
, u32 reg
)
1913 WREG32(R600_RCU_INDEX
, ((reg
) & 0x1fff));
1914 r
= RREG32(R600_RCU_DATA
);
1918 static inline void r600_rcu_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
1920 WREG32(R600_RCU_INDEX
, ((reg
) & 0x1fff));
1921 WREG32(R600_RCU_DATA
, (v
));
1924 static inline u32
eg_cg_rreg(struct radeon_device
*rdev
, u32 reg
)
1928 WREG32(EVERGREEN_CG_IND_ADDR
, ((reg
) & 0xffff));
1929 r
= RREG32(EVERGREEN_CG_IND_DATA
);
1933 static inline void eg_cg_wreg(struct radeon_device
*rdev
, u32 reg
, u32 v
)
1935 WREG32(EVERGREEN_CG_IND_ADDR
, ((reg
) & 0xffff));
1936 WREG32(EVERGREEN_CG_IND_DATA
, (v
));
1939 void r100_pll_errata_after_index(struct radeon_device
*rdev
);
1945 #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
1946 (rdev->pdev->device == 0x5969))
1947 #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
1948 (rdev->family == CHIP_RV200) || \
1949 (rdev->family == CHIP_RS100) || \
1950 (rdev->family == CHIP_RS200) || \
1951 (rdev->family == CHIP_RV250) || \
1952 (rdev->family == CHIP_RV280) || \
1953 (rdev->family == CHIP_RS300))
1954 #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \
1955 (rdev->family == CHIP_RV350) || \
1956 (rdev->family == CHIP_R350) || \
1957 (rdev->family == CHIP_RV380) || \
1958 (rdev->family == CHIP_R420) || \
1959 (rdev->family == CHIP_R423) || \
1960 (rdev->family == CHIP_RV410) || \
1961 (rdev->family == CHIP_RS400) || \
1962 (rdev->family == CHIP_RS480))
1963 #define ASIC_IS_X2(rdev) ((rdev->ddev->pdev->device == 0x9441) || \
1964 (rdev->ddev->pdev->device == 0x9443) || \
1965 (rdev->ddev->pdev->device == 0x944B) || \
1966 (rdev->ddev->pdev->device == 0x9506) || \
1967 (rdev->ddev->pdev->device == 0x9509) || \
1968 (rdev->ddev->pdev->device == 0x950F) || \
1969 (rdev->ddev->pdev->device == 0x689C) || \
1970 (rdev->ddev->pdev->device == 0x689D))
1971 #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
1972 #define ASIC_IS_DCE2(rdev) ((rdev->family == CHIP_RS600) || \
1973 (rdev->family == CHIP_RS690) || \
1974 (rdev->family == CHIP_RS740) || \
1975 (rdev->family >= CHIP_R600))
1976 #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
1977 #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
1978 #define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR))
1979 #define ASIC_IS_DCE41(rdev) ((rdev->family >= CHIP_PALM) && \
1980 (rdev->flags & RADEON_IS_IGP))
1981 #define ASIC_IS_DCE5(rdev) ((rdev->family >= CHIP_BARTS))
1982 #define ASIC_IS_DCE6(rdev) ((rdev->family >= CHIP_ARUBA))
1983 #define ASIC_IS_DCE61(rdev) ((rdev->family >= CHIP_ARUBA) && \
1984 (rdev->flags & RADEON_IS_IGP))
1985 #define ASIC_IS_DCE64(rdev) ((rdev->family == CHIP_OLAND))
1986 #define ASIC_IS_NODCE(rdev) ((rdev->family == CHIP_HAINAN))
1987 #define ASIC_IS_DCE8(rdev) ((rdev->family >= CHIP_BONAIRE))
1992 #define RBIOS8(i) (rdev->bios[i])
1993 #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
1994 #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
1996 int radeon_combios_init(struct radeon_device
*rdev
);
1997 void radeon_combios_fini(struct radeon_device
*rdev
);
1998 int radeon_atombios_init(struct radeon_device
*rdev
);
1999 void radeon_atombios_fini(struct radeon_device
*rdev
);
2005 #if DRM_DEBUG_CODE == 0
2006 static inline void radeon_ring_write(struct radeon_ring
*ring
, uint32_t v
)
2008 ring
->ring
[ring
->wptr
++] = v
;
2009 ring
->wptr
&= ring
->ptr_mask
;
2011 ring
->ring_free_dw
--;
2014 /* With debugging this is just too big to inline */
2015 void radeon_ring_write(struct radeon_ring
*ring
, uint32_t v
);
2021 #define radeon_init(rdev) (rdev)->asic->init((rdev))
2022 #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
2023 #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
2024 #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
2025 #define radeon_cs_parse(rdev, r, p) (rdev)->asic->ring[(r)].cs_parse((p))
2026 #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
2027 #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
2028 #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev))
2029 #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart.set_page((rdev), (i), (p))
2030 #define radeon_asic_vm_init(rdev) (rdev)->asic->vm.init((rdev))
2031 #define radeon_asic_vm_fini(rdev) (rdev)->asic->vm.fini((rdev))
2032 #define radeon_asic_vm_set_page(rdev, ib, pe, addr, count, incr, flags) ((rdev)->asic->vm.set_page((rdev), (ib), (pe), (addr), (count), (incr), (flags)))
2033 #define radeon_ring_start(rdev, r, cp) (rdev)->asic->ring[(r)].ring_start((rdev), (cp))
2034 #define radeon_ring_test(rdev, r, cp) (rdev)->asic->ring[(r)].ring_test((rdev), (cp))
2035 #define radeon_ib_test(rdev, r, cp) (rdev)->asic->ring[(r)].ib_test((rdev), (cp))
2036 #define radeon_ring_ib_execute(rdev, r, ib) (rdev)->asic->ring[(r)].ib_execute((rdev), (ib))
2037 #define radeon_ring_ib_parse(rdev, r, ib) (rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
2038 #define radeon_ring_is_lockup(rdev, r, cp) (rdev)->asic->ring[(r)].is_lockup((rdev), (cp))
2039 #define radeon_ring_vm_flush(rdev, r, vm) (rdev)->asic->ring[(r)].vm_flush((rdev), (r), (vm))
2040 #define radeon_ring_get_rptr(rdev, r) (rdev)->asic->ring[(r)->idx].get_rptr((rdev), (r))
2041 #define radeon_ring_get_wptr(rdev, r) (rdev)->asic->ring[(r)->idx].get_wptr((rdev), (r))
2042 #define radeon_ring_set_wptr(rdev, r) (rdev)->asic->ring[(r)->idx].set_wptr((rdev), (r))
2043 #define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
2044 #define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
2045 #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->display.get_vblank_counter((rdev), (crtc))
2046 #define radeon_set_backlight_level(rdev, e, l) (rdev)->asic->display.set_backlight_level((e), (l))
2047 #define radeon_get_backlight_level(rdev, e) (rdev)->asic->display.get_backlight_level((e))
2048 #define radeon_hdmi_enable(rdev, e, b) (rdev)->asic->display.hdmi_enable((e), (b))
2049 #define radeon_hdmi_setmode(rdev, e, m) (rdev)->asic->display.hdmi_setmode((e), (m))
2050 #define radeon_fence_ring_emit(rdev, r, fence) (rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
2051 #define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) (rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
2052 #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy.blit((rdev), (s), (d), (np), (f))
2053 #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy.dma((rdev), (s), (d), (np), (f))
2054 #define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy.copy((rdev), (s), (d), (np), (f))
2055 #define radeon_copy_blit_ring_index(rdev) (rdev)->asic->copy.blit_ring_index
2056 #define radeon_copy_dma_ring_index(rdev) (rdev)->asic->copy.dma_ring_index
2057 #define radeon_copy_ring_index(rdev) (rdev)->asic->copy.copy_ring_index
2058 #define radeon_get_engine_clock(rdev) (rdev)->asic->pm.get_engine_clock((rdev))
2059 #define radeon_set_engine_clock(rdev, e) (rdev)->asic->pm.set_engine_clock((rdev), (e))
2060 #define radeon_get_memory_clock(rdev) (rdev)->asic->pm.get_memory_clock((rdev))
2061 #define radeon_set_memory_clock(rdev, e) (rdev)->asic->pm.set_memory_clock((rdev), (e))
2062 #define radeon_get_pcie_lanes(rdev) (rdev)->asic->pm.get_pcie_lanes((rdev))
2063 #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), (l))
2064 #define radeon_set_clock_gating(rdev, e) (rdev)->asic->pm.set_clock_gating((rdev), (e))
2065 #define radeon_set_uvd_clocks(rdev, v, d) (rdev)->asic->pm.set_uvd_clocks((rdev), (v), (d))
2066 #define radeon_get_temperature(rdev) (rdev)->asic->pm.get_temperature((rdev))
2067 #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
2068 #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->surface.clear_reg((rdev), (r)))
2069 #define radeon_bandwidth_update(rdev) (rdev)->asic->display.bandwidth_update((rdev))
2070 #define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
2071 #define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
2072 #define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
2073 #define radeon_hpd_set_polarity(rdev, h) (rdev)->asic->hpd.set_polarity((rdev), (h))
2074 #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
2075 #define radeon_pm_misc(rdev) (rdev)->asic->pm.misc((rdev))
2076 #define radeon_pm_prepare(rdev) (rdev)->asic->pm.prepare((rdev))
2077 #define radeon_pm_finish(rdev) (rdev)->asic->pm.finish((rdev))
2078 #define radeon_pm_init_profile(rdev) (rdev)->asic->pm.init_profile((rdev))
2079 #define radeon_pm_get_dynpm_state(rdev) (rdev)->asic->pm.get_dynpm_state((rdev))
2080 #define radeon_pre_page_flip(rdev, crtc) (rdev)->asic->pflip.pre_page_flip((rdev), (crtc))
2081 #define radeon_page_flip(rdev, crtc, base) (rdev)->asic->pflip.page_flip((rdev), (crtc), (base))
2082 #define radeon_post_page_flip(rdev, crtc) (rdev)->asic->pflip.post_page_flip((rdev), (crtc))
2083 #define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc))
2084 #define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev))
2085 #define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev))
2086 #define radeon_get_gpu_clock_counter(rdev) (rdev)->asic->get_gpu_clock_counter((rdev))
2088 /* Common functions */
2090 extern int radeon_gpu_reset(struct radeon_device
*rdev
);
2091 extern void r600_set_bios_scratch_engine_hung(struct radeon_device
*rdev
, bool hung
);
2092 extern void radeon_agp_disable(struct radeon_device
*rdev
);
2093 extern int radeon_modeset_init(struct radeon_device
*rdev
);
2094 extern void radeon_modeset_fini(struct radeon_device
*rdev
);
2095 extern bool radeon_card_posted(struct radeon_device
*rdev
);
2096 extern void radeon_update_bandwidth_info(struct radeon_device
*rdev
);
2097 extern void radeon_update_display_priority(struct radeon_device
*rdev
);
2098 extern bool radeon_boot_test_post_card(struct radeon_device
*rdev
);
2099 extern void radeon_scratch_init(struct radeon_device
*rdev
);
2100 extern void radeon_wb_fini(struct radeon_device
*rdev
);
2101 extern int radeon_wb_init(struct radeon_device
*rdev
);
2102 extern void radeon_wb_disable(struct radeon_device
*rdev
);
2103 extern void radeon_surface_init(struct radeon_device
*rdev
);
2104 extern int radeon_cs_parser_init(struct radeon_cs_parser
*p
, void *data
);
2105 extern void radeon_legacy_set_clock_gating(struct radeon_device
*rdev
, int enable
);
2106 extern void radeon_atom_set_clock_gating(struct radeon_device
*rdev
, int enable
);
2107 extern void radeon_ttm_placement_from_domain(struct radeon_bo
*rbo
, u32 domain
);
2108 extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object
*bo
);
2109 extern void radeon_vram_location(struct radeon_device
*rdev
, struct radeon_mc
*mc
, u64 base
);
2110 extern void radeon_gtt_location(struct radeon_device
*rdev
, struct radeon_mc
*mc
);
2111 extern int radeon_resume_kms(struct drm_device
*dev
);
2112 extern int radeon_suspend_kms(struct drm_device
*dev
, pm_message_t state
);
2113 extern void radeon_ttm_set_active_vram_size(struct radeon_device
*rdev
, u64 size
);
2114 extern void radeon_program_register_sequence(struct radeon_device
*rdev
,
2115 const u32
*registers
,
2116 const u32 array_size
);
2121 int radeon_vm_manager_init(struct radeon_device
*rdev
);
2122 void radeon_vm_manager_fini(struct radeon_device
*rdev
);
2123 void radeon_vm_init(struct radeon_device
*rdev
, struct radeon_vm
*vm
);
2124 void radeon_vm_fini(struct radeon_device
*rdev
, struct radeon_vm
*vm
);
2125 int radeon_vm_alloc_pt(struct radeon_device
*rdev
, struct radeon_vm
*vm
);
2126 void radeon_vm_add_to_lru(struct radeon_device
*rdev
, struct radeon_vm
*vm
);
2127 struct radeon_fence
*radeon_vm_grab_id(struct radeon_device
*rdev
,
2128 struct radeon_vm
*vm
, int ring
);
2129 void radeon_vm_fence(struct radeon_device
*rdev
,
2130 struct radeon_vm
*vm
,
2131 struct radeon_fence
*fence
);
2132 uint64_t radeon_vm_map_gart(struct radeon_device
*rdev
, uint64_t addr
);
2133 int radeon_vm_bo_update_pte(struct radeon_device
*rdev
,
2134 struct radeon_vm
*vm
,
2135 struct radeon_bo
*bo
,
2136 struct ttm_mem_reg
*mem
);
2137 void radeon_vm_bo_invalidate(struct radeon_device
*rdev
,
2138 struct radeon_bo
*bo
);
2139 struct radeon_bo_va
*radeon_vm_bo_find(struct radeon_vm
*vm
,
2140 struct radeon_bo
*bo
);
2141 struct radeon_bo_va
*radeon_vm_bo_add(struct radeon_device
*rdev
,
2142 struct radeon_vm
*vm
,
2143 struct radeon_bo
*bo
);
2144 int radeon_vm_bo_set_addr(struct radeon_device
*rdev
,
2145 struct radeon_bo_va
*bo_va
,
2148 int radeon_vm_bo_rmv(struct radeon_device
*rdev
,
2149 struct radeon_bo_va
*bo_va
);
2152 void r600_audio_update_hdmi(struct work_struct
*work
);
2155 * R600 vram scratch functions
2157 int r600_vram_scratch_init(struct radeon_device
*rdev
);
2158 void r600_vram_scratch_fini(struct radeon_device
*rdev
);
2161 * r600 cs checking helper
2163 unsigned r600_mip_minify(unsigned size
, unsigned level
);
2164 bool r600_fmt_is_valid_color(u32 format
);
2165 bool r600_fmt_is_valid_texture(u32 format
, enum radeon_family family
);
2166 int r600_fmt_get_blocksize(u32 format
);
2167 int r600_fmt_get_nblocksx(u32 format
, u32 w
);
2168 int r600_fmt_get_nblocksy(u32 format
, u32 h
);
2171 * r600 functions used by radeon_encoder.c
2173 struct radeon_hdmi_acr
{
2187 extern struct radeon_hdmi_acr
r600_hdmi_acr(uint32_t clock
);
2189 extern u32
r6xx_remap_render_backend(struct radeon_device
*rdev
,
2190 u32 tiling_pipe_num
,
2192 u32 total_max_rb_num
,
2193 u32 enabled_rb_mask
);
2196 * evergreen functions used by radeon_encoder.c
2199 extern int ni_init_microcode(struct radeon_device
*rdev
);
2200 extern int ni_mc_load_microcode(struct radeon_device
*rdev
);
2203 #if defined(CONFIG_ACPI)
2204 extern int radeon_acpi_init(struct radeon_device
*rdev
);
2205 extern void radeon_acpi_fini(struct radeon_device
*rdev
);
2207 static inline int radeon_acpi_init(struct radeon_device
*rdev
) { return 0; }
2208 static inline void radeon_acpi_fini(struct radeon_device
*rdev
) { }
2211 int radeon_cs_packet_parse(struct radeon_cs_parser
*p
,
2212 struct radeon_cs_packet
*pkt
,
2214 bool radeon_cs_packet_next_is_pkt3_nop(struct radeon_cs_parser
*p
);
2215 void radeon_cs_dump_packet(struct radeon_cs_parser
*p
,
2216 struct radeon_cs_packet
*pkt
);
2217 int radeon_cs_packet_next_reloc(struct radeon_cs_parser
*p
,
2218 struct radeon_cs_reloc
**cs_reloc
,
2220 int r600_cs_common_vline_parse(struct radeon_cs_parser
*p
,
2221 uint32_t *vline_start_end
,
2222 uint32_t *vline_status
);
2224 #include "radeon_object.h"