Merge branch 'gpu-switcher' of /ssd/git//linux-2.6 into drm-next-stage
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / gpu / drm / radeon / radeon.h
blobad9d55f94398fdf3a47d42c3f433c71efa304d86
1 /*
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
25 * Alex Deucher
26 * Jerome Glisse
28 #ifndef __RADEON_H__
29 #define __RADEON_H__
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
34 * related to surface
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 <asm/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>
73 #include "radeon_family.h"
74 #include "radeon_mode.h"
75 #include "radeon_reg.h"
78 * Modules parameters.
80 extern int radeon_no_wb;
81 extern int radeon_modeset;
82 extern int radeon_dynclks;
83 extern int radeon_r4xx_atom;
84 extern int radeon_agpmode;
85 extern int radeon_vram_limit;
86 extern int radeon_gart_size;
87 extern int radeon_benchmarking;
88 extern int radeon_testing;
89 extern int radeon_connector_table;
90 extern int radeon_tv;
91 extern int radeon_new_pll;
92 extern int radeon_dynpm;
93 extern int radeon_audio;
96 * Copy from radeon_drv.h so we don't have to include both and have conflicting
97 * symbol;
99 #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
100 /* RADEON_IB_POOL_SIZE must be a power of 2 */
101 #define RADEON_IB_POOL_SIZE 16
102 #define RADEON_DEBUGFS_MAX_NUM_FILES 32
103 #define RADEONFB_CONN_LIMIT 4
104 #define RADEON_BIOS_NUM_SCRATCH 8
107 * Errata workarounds.
109 enum radeon_pll_errata {
110 CHIP_ERRATA_R300_CG = 0x00000001,
111 CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002,
112 CHIP_ERRATA_PLL_DELAY = 0x00000004
116 struct radeon_device;
120 * BIOS.
122 #define ATRM_BIOS_PAGE 4096
124 bool radeon_atrm_supported(struct pci_dev *pdev);
125 int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len);
126 bool radeon_get_bios(struct radeon_device *rdev);
130 * Dummy page
132 struct radeon_dummy_page {
133 struct page *page;
134 dma_addr_t addr;
136 int radeon_dummy_page_init(struct radeon_device *rdev);
137 void radeon_dummy_page_fini(struct radeon_device *rdev);
141 * Clocks
143 struct radeon_clock {
144 struct radeon_pll p1pll;
145 struct radeon_pll p2pll;
146 struct radeon_pll dcpll;
147 struct radeon_pll spll;
148 struct radeon_pll mpll;
149 /* 10 Khz units */
150 uint32_t default_mclk;
151 uint32_t default_sclk;
152 uint32_t default_dispclk;
153 uint32_t dp_extclk;
157 * Power management
159 int radeon_pm_init(struct radeon_device *rdev);
160 void radeon_pm_compute_clocks(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);
165 * Fences.
167 struct radeon_fence_driver {
168 uint32_t scratch_reg;
169 atomic_t seq;
170 uint32_t last_seq;
171 unsigned long count_timeout;
172 wait_queue_head_t queue;
173 rwlock_t lock;
174 struct list_head created;
175 struct list_head emited;
176 struct list_head signaled;
177 bool initialized;
180 struct radeon_fence {
181 struct radeon_device *rdev;
182 struct kref kref;
183 struct list_head list;
184 /* protected by radeon_fence.lock */
185 uint32_t seq;
186 unsigned long timeout;
187 bool emited;
188 bool signaled;
191 int radeon_fence_driver_init(struct radeon_device *rdev);
192 void radeon_fence_driver_fini(struct radeon_device *rdev);
193 int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence);
194 int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence);
195 void radeon_fence_process(struct radeon_device *rdev);
196 bool radeon_fence_signaled(struct radeon_fence *fence);
197 int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
198 int radeon_fence_wait_next(struct radeon_device *rdev);
199 int radeon_fence_wait_last(struct radeon_device *rdev);
200 struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
201 void radeon_fence_unref(struct radeon_fence **fence);
204 * Tiling registers
206 struct radeon_surface_reg {
207 struct radeon_bo *bo;
210 #define RADEON_GEM_MAX_SURFACES 8
213 * TTM.
215 struct radeon_mman {
216 struct ttm_bo_global_ref bo_global_ref;
217 struct ttm_global_reference mem_global_ref;
218 struct ttm_bo_device bdev;
219 bool mem_global_referenced;
220 bool initialized;
223 struct radeon_bo {
224 /* Protected by gem.mutex */
225 struct list_head list;
226 /* Protected by tbo.reserved */
227 u32 placements[3];
228 struct ttm_placement placement;
229 struct ttm_buffer_object tbo;
230 struct ttm_bo_kmap_obj kmap;
231 unsigned pin_count;
232 void *kptr;
233 u32 tiling_flags;
234 u32 pitch;
235 int surface_reg;
236 /* Constant after initialization */
237 struct radeon_device *rdev;
238 struct drm_gem_object *gobj;
241 struct radeon_bo_list {
242 struct list_head list;
243 struct radeon_bo *bo;
244 uint64_t gpu_offset;
245 unsigned rdomain;
246 unsigned wdomain;
247 u32 tiling_flags;
251 * GEM objects.
253 struct radeon_gem {
254 struct mutex mutex;
255 struct list_head objects;
258 int radeon_gem_init(struct radeon_device *rdev);
259 void radeon_gem_fini(struct radeon_device *rdev);
260 int radeon_gem_object_create(struct radeon_device *rdev, int size,
261 int alignment, int initial_domain,
262 bool discardable, bool kernel,
263 struct drm_gem_object **obj);
264 int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain,
265 uint64_t *gpu_addr);
266 void radeon_gem_object_unpin(struct drm_gem_object *obj);
270 * GART structures, functions & helpers
272 struct radeon_mc;
274 struct radeon_gart_table_ram {
275 volatile uint32_t *ptr;
278 struct radeon_gart_table_vram {
279 struct radeon_bo *robj;
280 volatile uint32_t *ptr;
283 union radeon_gart_table {
284 struct radeon_gart_table_ram ram;
285 struct radeon_gart_table_vram vram;
288 #define RADEON_GPU_PAGE_SIZE 4096
289 #define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
291 struct radeon_gart {
292 dma_addr_t table_addr;
293 unsigned num_gpu_pages;
294 unsigned num_cpu_pages;
295 unsigned table_size;
296 union radeon_gart_table table;
297 struct page **pages;
298 dma_addr_t *pages_addr;
299 bool ready;
302 int radeon_gart_table_ram_alloc(struct radeon_device *rdev);
303 void radeon_gart_table_ram_free(struct radeon_device *rdev);
304 int radeon_gart_table_vram_alloc(struct radeon_device *rdev);
305 void radeon_gart_table_vram_free(struct radeon_device *rdev);
306 int radeon_gart_init(struct radeon_device *rdev);
307 void radeon_gart_fini(struct radeon_device *rdev);
308 void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
309 int pages);
310 int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
311 int pages, struct page **pagelist);
315 * GPU MC structures, functions & helpers
317 struct radeon_mc {
318 resource_size_t aper_size;
319 resource_size_t aper_base;
320 resource_size_t agp_base;
321 /* for some chips with <= 32MB we need to lie
322 * about vram size near mc fb location */
323 u64 mc_vram_size;
324 u64 visible_vram_size;
325 u64 gtt_size;
326 u64 gtt_start;
327 u64 gtt_end;
328 u64 vram_start;
329 u64 vram_end;
330 unsigned vram_width;
331 u64 real_vram_size;
332 int vram_mtrr;
333 bool vram_is_ddr;
334 bool igp_sideport_enabled;
337 bool radeon_combios_sideport_present(struct radeon_device *rdev);
338 bool radeon_atombios_sideport_present(struct radeon_device *rdev);
341 * GPU scratch registers structures, functions & helpers
343 struct radeon_scratch {
344 unsigned num_reg;
345 bool free[32];
346 uint32_t reg[32];
349 int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg);
350 void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg);
354 * IRQS.
356 struct radeon_irq {
357 bool installed;
358 bool sw_int;
359 /* FIXME: use a define max crtc rather than hardcode it */
360 bool crtc_vblank_int[2];
361 wait_queue_head_t vblank_queue;
362 /* FIXME: use defines for max hpd/dacs */
363 bool hpd[6];
364 spinlock_t sw_lock;
365 int sw_refcount;
368 int radeon_irq_kms_init(struct radeon_device *rdev);
369 void radeon_irq_kms_fini(struct radeon_device *rdev);
370 void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev);
371 void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev);
374 * CP & ring.
376 struct radeon_ib {
377 struct list_head list;
378 unsigned idx;
379 uint64_t gpu_addr;
380 struct radeon_fence *fence;
381 uint32_t *ptr;
382 uint32_t length_dw;
383 bool free;
387 * locking -
388 * mutex protects scheduled_ibs, ready, alloc_bm
390 struct radeon_ib_pool {
391 struct mutex mutex;
392 struct radeon_bo *robj;
393 struct list_head bogus_ib;
394 struct radeon_ib ibs[RADEON_IB_POOL_SIZE];
395 bool ready;
396 unsigned head_id;
399 struct radeon_cp {
400 struct radeon_bo *ring_obj;
401 volatile uint32_t *ring;
402 unsigned rptr;
403 unsigned wptr;
404 unsigned wptr_old;
405 unsigned ring_size;
406 unsigned ring_free_dw;
407 int count_dw;
408 uint64_t gpu_addr;
409 uint32_t align_mask;
410 uint32_t ptr_mask;
411 struct mutex mutex;
412 bool ready;
416 * R6xx+ IH ring
418 struct r600_ih {
419 struct radeon_bo *ring_obj;
420 volatile uint32_t *ring;
421 unsigned rptr;
422 unsigned wptr;
423 unsigned wptr_old;
424 unsigned ring_size;
425 uint64_t gpu_addr;
426 uint32_t ptr_mask;
427 spinlock_t lock;
428 bool enabled;
431 struct r600_blit {
432 struct mutex mutex;
433 struct radeon_bo *shader_obj;
434 u64 shader_gpu_addr;
435 u32 vs_offset, ps_offset;
436 u32 state_offset;
437 u32 state_len;
438 u32 vb_used, vb_total;
439 struct radeon_ib *vb_ib;
442 int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib);
443 void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib);
444 int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib);
445 int radeon_ib_pool_init(struct radeon_device *rdev);
446 void radeon_ib_pool_fini(struct radeon_device *rdev);
447 int radeon_ib_test(struct radeon_device *rdev);
448 extern void radeon_ib_bogus_add(struct radeon_device *rdev, struct radeon_ib *ib);
449 /* Ring access between begin & end cannot sleep */
450 void radeon_ring_free_size(struct radeon_device *rdev);
451 int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw);
452 void radeon_ring_unlock_commit(struct radeon_device *rdev);
453 void radeon_ring_unlock_undo(struct radeon_device *rdev);
454 int radeon_ring_test(struct radeon_device *rdev);
455 int radeon_ring_init(struct radeon_device *rdev, unsigned ring_size);
456 void radeon_ring_fini(struct radeon_device *rdev);
460 * CS.
462 struct radeon_cs_reloc {
463 struct drm_gem_object *gobj;
464 struct radeon_bo *robj;
465 struct radeon_bo_list lobj;
466 uint32_t handle;
467 uint32_t flags;
470 struct radeon_cs_chunk {
471 uint32_t chunk_id;
472 uint32_t length_dw;
473 int kpage_idx[2];
474 uint32_t *kpage[2];
475 uint32_t *kdata;
476 void __user *user_ptr;
477 int last_copied_page;
478 int last_page_index;
481 struct radeon_cs_parser {
482 struct device *dev;
483 struct radeon_device *rdev;
484 struct drm_file *filp;
485 /* chunks */
486 unsigned nchunks;
487 struct radeon_cs_chunk *chunks;
488 uint64_t *chunks_array;
489 /* IB */
490 unsigned idx;
491 /* relocations */
492 unsigned nrelocs;
493 struct radeon_cs_reloc *relocs;
494 struct radeon_cs_reloc **relocs_ptr;
495 struct list_head validated;
496 /* indices of various chunks */
497 int chunk_ib_idx;
498 int chunk_relocs_idx;
499 struct radeon_ib *ib;
500 void *track;
501 unsigned family;
502 int parser_error;
505 extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx);
506 extern int radeon_cs_finish_pages(struct radeon_cs_parser *p);
509 static inline u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
511 struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx];
512 u32 pg_idx, pg_offset;
513 u32 idx_value = 0;
514 int new_page;
516 pg_idx = (idx * 4) / PAGE_SIZE;
517 pg_offset = (idx * 4) % PAGE_SIZE;
519 if (ibc->kpage_idx[0] == pg_idx)
520 return ibc->kpage[0][pg_offset/4];
521 if (ibc->kpage_idx[1] == pg_idx)
522 return ibc->kpage[1][pg_offset/4];
524 new_page = radeon_cs_update_pages(p, pg_idx);
525 if (new_page < 0) {
526 p->parser_error = new_page;
527 return 0;
530 idx_value = ibc->kpage[new_page][pg_offset/4];
531 return idx_value;
534 struct radeon_cs_packet {
535 unsigned idx;
536 unsigned type;
537 unsigned reg;
538 unsigned opcode;
539 int count;
540 unsigned one_reg_wr;
543 typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p,
544 struct radeon_cs_packet *pkt,
545 unsigned idx, unsigned reg);
546 typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p,
547 struct radeon_cs_packet *pkt);
551 * AGP
553 int radeon_agp_init(struct radeon_device *rdev);
554 void radeon_agp_resume(struct radeon_device *rdev);
555 void radeon_agp_fini(struct radeon_device *rdev);
559 * Writeback
561 struct radeon_wb {
562 struct radeon_bo *wb_obj;
563 volatile uint32_t *wb;
564 uint64_t gpu_addr;
568 * struct radeon_pm - power management datas
569 * @max_bandwidth: maximum bandwidth the gpu has (MByte/s)
570 * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880)
571 * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880)
572 * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880)
573 * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880)
574 * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP)
575 * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
576 * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP)
577 * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP)
578 * @sclk: GPU clock Mhz (core bandwith depends of this clock)
579 * @needed_bandwidth: current bandwidth needs
581 * It keeps track of various data needed to take powermanagement decision.
582 * Bandwith need is used to determine minimun clock of the GPU and memory.
583 * Equation between gpu/memory clock and available bandwidth is hw dependent
584 * (type of memory, bus size, efficiency, ...)
586 enum radeon_pm_state {
587 PM_STATE_DISABLED,
588 PM_STATE_MINIMUM,
589 PM_STATE_PAUSED,
590 PM_STATE_ACTIVE
592 enum radeon_pm_action {
593 PM_ACTION_NONE,
594 PM_ACTION_MINIMUM,
595 PM_ACTION_DOWNCLOCK,
596 PM_ACTION_UPCLOCK
599 enum radeon_voltage_type {
600 VOLTAGE_NONE = 0,
601 VOLTAGE_GPIO,
602 VOLTAGE_VDDC,
603 VOLTAGE_SW
606 enum radeon_pm_state_type {
607 POWER_STATE_TYPE_DEFAULT,
608 POWER_STATE_TYPE_POWERSAVE,
609 POWER_STATE_TYPE_BATTERY,
610 POWER_STATE_TYPE_BALANCED,
611 POWER_STATE_TYPE_PERFORMANCE,
614 enum radeon_pm_clock_mode_type {
615 POWER_MODE_TYPE_DEFAULT,
616 POWER_MODE_TYPE_LOW,
617 POWER_MODE_TYPE_MID,
618 POWER_MODE_TYPE_HIGH,
621 struct radeon_voltage {
622 enum radeon_voltage_type type;
623 /* gpio voltage */
624 struct radeon_gpio_rec gpio;
625 u32 delay; /* delay in usec from voltage drop to sclk change */
626 bool active_high; /* voltage drop is active when bit is high */
627 /* VDDC voltage */
628 u8 vddc_id; /* index into vddc voltage table */
629 u8 vddci_id; /* index into vddci voltage table */
630 bool vddci_enabled;
631 /* r6xx+ sw */
632 u32 voltage;
635 struct radeon_pm_non_clock_info {
636 /* pcie lanes */
637 int pcie_lanes;
638 /* standardized non-clock flags */
639 u32 flags;
642 struct radeon_pm_clock_info {
643 /* memory clock */
644 u32 mclk;
645 /* engine clock */
646 u32 sclk;
647 /* voltage info */
648 struct radeon_voltage voltage;
649 /* standardized clock flags - not sure we'll need these */
650 u32 flags;
653 struct radeon_power_state {
654 enum radeon_pm_state_type type;
655 /* XXX: use a define for num clock modes */
656 struct radeon_pm_clock_info clock_info[8];
657 /* number of valid clock modes in this power state */
658 int num_clock_modes;
659 struct radeon_pm_clock_info *default_clock_mode;
660 /* non clock info about this state */
661 struct radeon_pm_non_clock_info non_clock_info;
662 bool voltage_drop_active;
666 * Some modes are overclocked by very low value, accept them
668 #define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */
670 struct radeon_pm {
671 struct mutex mutex;
672 struct delayed_work idle_work;
673 enum radeon_pm_state state;
674 enum radeon_pm_action planned_action;
675 unsigned long action_timeout;
676 bool downclocked;
677 int active_crtcs;
678 int req_vblank;
679 fixed20_12 max_bandwidth;
680 fixed20_12 igp_sideport_mclk;
681 fixed20_12 igp_system_mclk;
682 fixed20_12 igp_ht_link_clk;
683 fixed20_12 igp_ht_link_width;
684 fixed20_12 k8_bandwidth;
685 fixed20_12 sideport_bandwidth;
686 fixed20_12 ht_bandwidth;
687 fixed20_12 core_bandwidth;
688 fixed20_12 sclk;
689 fixed20_12 needed_bandwidth;
690 /* XXX: use a define for num power modes */
691 struct radeon_power_state power_state[8];
692 /* number of valid power states */
693 int num_power_states;
694 struct radeon_power_state *current_power_state;
695 struct radeon_pm_clock_info *current_clock_mode;
696 struct radeon_power_state *requested_power_state;
697 struct radeon_pm_clock_info *requested_clock_mode;
698 struct radeon_power_state *default_power_state;
703 * Benchmarking
705 void radeon_benchmark(struct radeon_device *rdev);
709 * Testing
711 void radeon_test_moves(struct radeon_device *rdev);
715 * Debugfs
717 int radeon_debugfs_add_files(struct radeon_device *rdev,
718 struct drm_info_list *files,
719 unsigned nfiles);
720 int radeon_debugfs_fence_init(struct radeon_device *rdev);
721 int r100_debugfs_rbbm_init(struct radeon_device *rdev);
722 int r100_debugfs_cp_init(struct radeon_device *rdev);
726 * ASIC specific functions.
728 struct radeon_asic {
729 int (*init)(struct radeon_device *rdev);
730 void (*fini)(struct radeon_device *rdev);
731 int (*resume)(struct radeon_device *rdev);
732 int (*suspend)(struct radeon_device *rdev);
733 void (*vga_set_state)(struct radeon_device *rdev, bool state);
734 int (*gpu_reset)(struct radeon_device *rdev);
735 void (*gart_tlb_flush)(struct radeon_device *rdev);
736 int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr);
737 int (*cp_init)(struct radeon_device *rdev, unsigned ring_size);
738 void (*cp_fini)(struct radeon_device *rdev);
739 void (*cp_disable)(struct radeon_device *rdev);
740 void (*cp_commit)(struct radeon_device *rdev);
741 void (*ring_start)(struct radeon_device *rdev);
742 int (*ring_test)(struct radeon_device *rdev);
743 void (*ring_ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib);
744 int (*irq_set)(struct radeon_device *rdev);
745 int (*irq_process)(struct radeon_device *rdev);
746 u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
747 void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence);
748 int (*cs_parse)(struct radeon_cs_parser *p);
749 int (*copy_blit)(struct radeon_device *rdev,
750 uint64_t src_offset,
751 uint64_t dst_offset,
752 unsigned num_pages,
753 struct radeon_fence *fence);
754 int (*copy_dma)(struct radeon_device *rdev,
755 uint64_t src_offset,
756 uint64_t dst_offset,
757 unsigned num_pages,
758 struct radeon_fence *fence);
759 int (*copy)(struct radeon_device *rdev,
760 uint64_t src_offset,
761 uint64_t dst_offset,
762 unsigned num_pages,
763 struct radeon_fence *fence);
764 uint32_t (*get_engine_clock)(struct radeon_device *rdev);
765 void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
766 uint32_t (*get_memory_clock)(struct radeon_device *rdev);
767 void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock);
768 int (*get_pcie_lanes)(struct radeon_device *rdev);
769 void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
770 void (*set_clock_gating)(struct radeon_device *rdev, int enable);
771 int (*set_surface_reg)(struct radeon_device *rdev, int reg,
772 uint32_t tiling_flags, uint32_t pitch,
773 uint32_t offset, uint32_t obj_size);
774 int (*clear_surface_reg)(struct radeon_device *rdev, int reg);
775 void (*bandwidth_update)(struct radeon_device *rdev);
776 void (*hpd_init)(struct radeon_device *rdev);
777 void (*hpd_fini)(struct radeon_device *rdev);
778 bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
779 void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
780 /* ioctl hw specific callback. Some hw might want to perform special
781 * operation on specific ioctl. For instance on wait idle some hw
782 * might want to perform and HDP flush through MMIO as it seems that
783 * some R6XX/R7XX hw doesn't take HDP flush into account if programmed
784 * through ring.
786 void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo *bo);
790 * Asic structures
792 struct r100_asic {
793 const unsigned *reg_safe_bm;
794 unsigned reg_safe_bm_size;
795 u32 hdp_cntl;
798 struct r300_asic {
799 const unsigned *reg_safe_bm;
800 unsigned reg_safe_bm_size;
801 u32 resync_scratch;
802 u32 hdp_cntl;
805 struct r600_asic {
806 unsigned max_pipes;
807 unsigned max_tile_pipes;
808 unsigned max_simds;
809 unsigned max_backends;
810 unsigned max_gprs;
811 unsigned max_threads;
812 unsigned max_stack_entries;
813 unsigned max_hw_contexts;
814 unsigned max_gs_threads;
815 unsigned sx_max_export_size;
816 unsigned sx_max_export_pos_size;
817 unsigned sx_max_export_smx_size;
818 unsigned sq_num_cf_insts;
819 unsigned tiling_nbanks;
820 unsigned tiling_npipes;
821 unsigned tiling_group_size;
824 struct rv770_asic {
825 unsigned max_pipes;
826 unsigned max_tile_pipes;
827 unsigned max_simds;
828 unsigned max_backends;
829 unsigned max_gprs;
830 unsigned max_threads;
831 unsigned max_stack_entries;
832 unsigned max_hw_contexts;
833 unsigned max_gs_threads;
834 unsigned sx_max_export_size;
835 unsigned sx_max_export_pos_size;
836 unsigned sx_max_export_smx_size;
837 unsigned sq_num_cf_insts;
838 unsigned sx_num_of_sets;
839 unsigned sc_prim_fifo_size;
840 unsigned sc_hiz_tile_fifo_size;
841 unsigned sc_earlyz_tile_fifo_fize;
842 unsigned tiling_nbanks;
843 unsigned tiling_npipes;
844 unsigned tiling_group_size;
847 union radeon_asic_config {
848 struct r300_asic r300;
849 struct r100_asic r100;
850 struct r600_asic r600;
851 struct rv770_asic rv770;
856 * IOCTL.
858 int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
859 struct drm_file *filp);
860 int radeon_gem_create_ioctl(struct drm_device *dev, void *data,
861 struct drm_file *filp);
862 int radeon_gem_pin_ioctl(struct drm_device *dev, void *data,
863 struct drm_file *file_priv);
864 int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data,
865 struct drm_file *file_priv);
866 int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data,
867 struct drm_file *file_priv);
868 int radeon_gem_pread_ioctl(struct drm_device *dev, void *data,
869 struct drm_file *file_priv);
870 int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
871 struct drm_file *filp);
872 int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
873 struct drm_file *filp);
874 int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
875 struct drm_file *filp);
876 int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
877 struct drm_file *filp);
878 int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
879 int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
880 struct drm_file *filp);
881 int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
882 struct drm_file *filp);
886 * Core structure, functions and helpers.
888 typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
889 typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
891 struct radeon_device {
892 struct device *dev;
893 struct drm_device *ddev;
894 struct pci_dev *pdev;
895 /* ASIC */
896 union radeon_asic_config config;
897 enum radeon_family family;
898 unsigned long flags;
899 int usec_timeout;
900 enum radeon_pll_errata pll_errata;
901 int num_gb_pipes;
902 int num_z_pipes;
903 int disp_priority;
904 /* BIOS */
905 uint8_t *bios;
906 bool is_atom_bios;
907 uint16_t bios_header_start;
908 struct radeon_bo *stollen_vga_memory;
909 struct fb_info *fbdev_info;
910 struct radeon_bo *fbdev_rbo;
911 struct radeon_framebuffer *fbdev_rfb;
912 /* Register mmio */
913 resource_size_t rmmio_base;
914 resource_size_t rmmio_size;
915 void *rmmio;
916 radeon_rreg_t mc_rreg;
917 radeon_wreg_t mc_wreg;
918 radeon_rreg_t pll_rreg;
919 radeon_wreg_t pll_wreg;
920 uint32_t pcie_reg_mask;
921 radeon_rreg_t pciep_rreg;
922 radeon_wreg_t pciep_wreg;
923 struct radeon_clock clock;
924 struct radeon_mc mc;
925 struct radeon_gart gart;
926 struct radeon_mode_info mode_info;
927 struct radeon_scratch scratch;
928 struct radeon_mman mman;
929 struct radeon_fence_driver fence_drv;
930 struct radeon_cp cp;
931 struct radeon_ib_pool ib_pool;
932 struct radeon_irq irq;
933 struct radeon_asic *asic;
934 struct radeon_gem gem;
935 struct radeon_pm pm;
936 uint32_t bios_scratch[RADEON_BIOS_NUM_SCRATCH];
937 struct mutex cs_mutex;
938 struct radeon_wb wb;
939 struct radeon_dummy_page dummy_page;
940 bool gpu_lockup;
941 bool shutdown;
942 bool suspend;
943 bool need_dma32;
944 bool accel_working;
945 struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
946 const struct firmware *me_fw; /* all family ME firmware */
947 const struct firmware *pfp_fw; /* r6/700 PFP firmware */
948 const struct firmware *rlc_fw; /* r6/700 RLC firmware */
949 struct r600_blit r600_blit;
950 int msi_enabled; /* msi enabled */
951 struct r600_ih ih; /* r6/700 interrupt ring */
952 struct workqueue_struct *wq;
953 struct work_struct hotplug_work;
954 int num_crtc; /* number of crtcs */
955 struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
957 /* audio stuff */
958 struct timer_list audio_timer;
959 int audio_channels;
960 int audio_rate;
961 int audio_bits_per_sample;
962 uint8_t audio_status_bits;
963 uint8_t audio_category_code;
965 bool powered_down;
968 int radeon_device_init(struct radeon_device *rdev,
969 struct drm_device *ddev,
970 struct pci_dev *pdev,
971 uint32_t flags);
972 void radeon_device_fini(struct radeon_device *rdev);
973 int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
975 /* r600 blit */
976 int r600_blit_prepare_copy(struct radeon_device *rdev, int size_bytes);
977 void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence);
978 void r600_kms_blit_copy(struct radeon_device *rdev,
979 u64 src_gpu_addr, u64 dst_gpu_addr,
980 int size_bytes);
982 static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg)
984 if (reg < rdev->rmmio_size)
985 return readl(((void __iomem *)rdev->rmmio) + reg);
986 else {
987 writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
988 return readl(((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
992 static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
994 if (reg < rdev->rmmio_size)
995 writel(v, ((void __iomem *)rdev->rmmio) + reg);
996 else {
997 writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
998 writel(v, ((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
1003 * Cast helper
1005 #define to_radeon_fence(p) ((struct radeon_fence *)(p))
1008 * Registers read & write functions.
1010 #define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg))
1011 #define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg))
1012 #define RREG32(reg) r100_mm_rreg(rdev, (reg))
1013 #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg)))
1014 #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v))
1015 #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
1016 #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
1017 #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
1018 #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
1019 #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
1020 #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
1021 #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
1022 #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
1023 #define RREG32_PCIE_P(reg) rdev->pciep_rreg(rdev, (reg))
1024 #define WREG32_PCIE_P(reg, v) rdev->pciep_wreg(rdev, (reg), (v))
1025 #define WREG32_P(reg, val, mask) \
1026 do { \
1027 uint32_t tmp_ = RREG32(reg); \
1028 tmp_ &= (mask); \
1029 tmp_ |= ((val) & ~(mask)); \
1030 WREG32(reg, tmp_); \
1031 } while (0)
1032 #define WREG32_PLL_P(reg, val, mask) \
1033 do { \
1034 uint32_t tmp_ = RREG32_PLL(reg); \
1035 tmp_ &= (mask); \
1036 tmp_ |= ((val) & ~(mask)); \
1037 WREG32_PLL(reg, tmp_); \
1038 } while (0)
1039 #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg)))
1042 * Indirect registers accessor
1044 static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
1046 uint32_t r;
1048 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
1049 r = RREG32(RADEON_PCIE_DATA);
1050 return r;
1053 static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
1055 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
1056 WREG32(RADEON_PCIE_DATA, (v));
1059 void r100_pll_errata_after_index(struct radeon_device *rdev);
1063 * ASICs helpers.
1065 #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
1066 (rdev->pdev->device == 0x5969))
1067 #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
1068 (rdev->family == CHIP_RV200) || \
1069 (rdev->family == CHIP_RS100) || \
1070 (rdev->family == CHIP_RS200) || \
1071 (rdev->family == CHIP_RV250) || \
1072 (rdev->family == CHIP_RV280) || \
1073 (rdev->family == CHIP_RS300))
1074 #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \
1075 (rdev->family == CHIP_RV350) || \
1076 (rdev->family == CHIP_R350) || \
1077 (rdev->family == CHIP_RV380) || \
1078 (rdev->family == CHIP_R420) || \
1079 (rdev->family == CHIP_R423) || \
1080 (rdev->family == CHIP_RV410) || \
1081 (rdev->family == CHIP_RS400) || \
1082 (rdev->family == CHIP_RS480))
1083 #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
1084 #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
1085 #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
1086 #define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR))
1089 * BIOS helpers.
1091 #define RBIOS8(i) (rdev->bios[i])
1092 #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
1093 #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
1095 int radeon_combios_init(struct radeon_device *rdev);
1096 void radeon_combios_fini(struct radeon_device *rdev);
1097 int radeon_atombios_init(struct radeon_device *rdev);
1098 void radeon_atombios_fini(struct radeon_device *rdev);
1102 * RING helpers.
1104 static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
1106 #if DRM_DEBUG_CODE
1107 if (rdev->cp.count_dw <= 0) {
1108 DRM_ERROR("radeon: writting more dword to ring than expected !\n");
1110 #endif
1111 rdev->cp.ring[rdev->cp.wptr++] = v;
1112 rdev->cp.wptr &= rdev->cp.ptr_mask;
1113 rdev->cp.count_dw--;
1114 rdev->cp.ring_free_dw--;
1119 * ASICs macro.
1121 #define radeon_init(rdev) (rdev)->asic->init((rdev))
1122 #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
1123 #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
1124 #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
1125 #define radeon_cs_parse(p) rdev->asic->cs_parse((p))
1126 #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
1127 #define radeon_gpu_reset(rdev) (rdev)->asic->gpu_reset((rdev))
1128 #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev))
1129 #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart_set_page((rdev), (i), (p))
1130 #define radeon_cp_commit(rdev) (rdev)->asic->cp_commit((rdev))
1131 #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev))
1132 #define radeon_ring_test(rdev) (rdev)->asic->ring_test((rdev))
1133 #define radeon_ring_ib_execute(rdev, ib) (rdev)->asic->ring_ib_execute((rdev), (ib))
1134 #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev))
1135 #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev))
1136 #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc))
1137 #define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence))
1138 #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f))
1139 #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f))
1140 #define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy((rdev), (s), (d), (np), (f))
1141 #define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev))
1142 #define radeon_set_engine_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e))
1143 #define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev))
1144 #define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_memory_clock((rdev), (e))
1145 #define radeon_get_pcie_lanes(rdev) (rdev)->asic->get_pcie_lanes((rdev))
1146 #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l))
1147 #define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e))
1148 #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
1149 #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r)))
1150 #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
1151 #define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev))
1152 #define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev))
1153 #define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd))
1154 #define radeon_hpd_set_polarity(rdev, hpd) (rdev)->asic->hpd_set_polarity((rdev), (hpd))
1156 /* Common functions */
1157 /* AGP */
1158 extern void radeon_agp_disable(struct radeon_device *rdev);
1159 extern int radeon_gart_table_vram_pin(struct radeon_device *rdev);
1160 extern void radeon_gart_restore(struct radeon_device *rdev);
1161 extern int radeon_modeset_init(struct radeon_device *rdev);
1162 extern void radeon_modeset_fini(struct radeon_device *rdev);
1163 extern bool radeon_card_posted(struct radeon_device *rdev);
1164 extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
1165 extern int radeon_clocks_init(struct radeon_device *rdev);
1166 extern void radeon_clocks_fini(struct radeon_device *rdev);
1167 extern void radeon_scratch_init(struct radeon_device *rdev);
1168 extern void radeon_surface_init(struct radeon_device *rdev);
1169 extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
1170 extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
1171 extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
1172 extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
1173 extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
1174 extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base);
1175 extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
1176 extern int radeon_resume_kms(struct drm_device *dev);
1177 extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
1179 /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */
1180 struct r100_mc_save {
1181 u32 GENMO_WT;
1182 u32 CRTC_EXT_CNTL;
1183 u32 CRTC_GEN_CNTL;
1184 u32 CRTC2_GEN_CNTL;
1185 u32 CUR_OFFSET;
1186 u32 CUR2_OFFSET;
1188 extern void r100_cp_disable(struct radeon_device *rdev);
1189 extern int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
1190 extern void r100_cp_fini(struct radeon_device *rdev);
1191 extern void r100_pci_gart_tlb_flush(struct radeon_device *rdev);
1192 extern int r100_pci_gart_init(struct radeon_device *rdev);
1193 extern void r100_pci_gart_fini(struct radeon_device *rdev);
1194 extern int r100_pci_gart_enable(struct radeon_device *rdev);
1195 extern void r100_pci_gart_disable(struct radeon_device *rdev);
1196 extern int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
1197 extern int r100_debugfs_mc_info_init(struct radeon_device *rdev);
1198 extern int r100_gui_wait_for_idle(struct radeon_device *rdev);
1199 extern void r100_ib_fini(struct radeon_device *rdev);
1200 extern int r100_ib_init(struct radeon_device *rdev);
1201 extern void r100_irq_disable(struct radeon_device *rdev);
1202 extern int r100_irq_set(struct radeon_device *rdev);
1203 extern void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save);
1204 extern void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save);
1205 extern void r100_vram_init_sizes(struct radeon_device *rdev);
1206 extern void r100_wb_disable(struct radeon_device *rdev);
1207 extern void r100_wb_fini(struct radeon_device *rdev);
1208 extern int r100_wb_init(struct radeon_device *rdev);
1209 extern void r100_hdp_reset(struct radeon_device *rdev);
1210 extern int r100_rb2d_reset(struct radeon_device *rdev);
1211 extern int r100_cp_reset(struct radeon_device *rdev);
1212 extern void r100_vga_render_disable(struct radeon_device *rdev);
1213 extern int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p,
1214 struct radeon_cs_packet *pkt,
1215 struct radeon_bo *robj);
1216 extern int r100_cs_parse_packet0(struct radeon_cs_parser *p,
1217 struct radeon_cs_packet *pkt,
1218 const unsigned *auth, unsigned n,
1219 radeon_packet0_check_t check);
1220 extern int r100_cs_packet_parse(struct radeon_cs_parser *p,
1221 struct radeon_cs_packet *pkt,
1222 unsigned idx);
1223 extern void r100_enable_bm(struct radeon_device *rdev);
1224 extern void r100_set_common_regs(struct radeon_device *rdev);
1226 /* rv200,rv250,rv280 */
1227 extern void r200_set_safe_registers(struct radeon_device *rdev);
1229 /* r300,r350,rv350,rv370,rv380 */
1230 extern void r300_set_reg_safe(struct radeon_device *rdev);
1231 extern void r300_mc_program(struct radeon_device *rdev);
1232 extern void r300_mc_init(struct radeon_device *rdev);
1233 extern void r300_clock_startup(struct radeon_device *rdev);
1234 extern int r300_mc_wait_for_idle(struct radeon_device *rdev);
1235 extern int rv370_pcie_gart_init(struct radeon_device *rdev);
1236 extern void rv370_pcie_gart_fini(struct radeon_device *rdev);
1237 extern int rv370_pcie_gart_enable(struct radeon_device *rdev);
1238 extern void rv370_pcie_gart_disable(struct radeon_device *rdev);
1240 /* r420,r423,rv410 */
1241 extern u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg);
1242 extern void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v);
1243 extern int r420_debugfs_pipes_info_init(struct radeon_device *rdev);
1244 extern void r420_pipes_init(struct radeon_device *rdev);
1246 /* rv515 */
1247 struct rv515_mc_save {
1248 u32 d1vga_control;
1249 u32 d2vga_control;
1250 u32 vga_render_control;
1251 u32 vga_hdp_control;
1252 u32 d1crtc_control;
1253 u32 d2crtc_control;
1255 extern void rv515_bandwidth_avivo_update(struct radeon_device *rdev);
1256 extern void rv515_vga_render_disable(struct radeon_device *rdev);
1257 extern void rv515_set_safe_registers(struct radeon_device *rdev);
1258 extern void rv515_mc_stop(struct radeon_device *rdev, struct rv515_mc_save *save);
1259 extern void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save);
1260 extern void rv515_clock_startup(struct radeon_device *rdev);
1261 extern void rv515_debugfs(struct radeon_device *rdev);
1262 extern int rv515_suspend(struct radeon_device *rdev);
1264 /* rs400 */
1265 extern int rs400_gart_init(struct radeon_device *rdev);
1266 extern int rs400_gart_enable(struct radeon_device *rdev);
1267 extern void rs400_gart_adjust_size(struct radeon_device *rdev);
1268 extern void rs400_gart_disable(struct radeon_device *rdev);
1269 extern void rs400_gart_fini(struct radeon_device *rdev);
1271 /* rs600 */
1272 extern void rs600_set_safe_registers(struct radeon_device *rdev);
1273 extern int rs600_irq_set(struct radeon_device *rdev);
1274 extern void rs600_irq_disable(struct radeon_device *rdev);
1276 /* rs690, rs740 */
1277 extern void rs690_line_buffer_adjust(struct radeon_device *rdev,
1278 struct drm_display_mode *mode1,
1279 struct drm_display_mode *mode2);
1281 /* r600, rv610, rv630, rv620, rv635, rv670, rs780, rs880 */
1282 extern void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
1283 extern bool r600_card_posted(struct radeon_device *rdev);
1284 extern void r600_cp_stop(struct radeon_device *rdev);
1285 extern void r600_ring_init(struct radeon_device *rdev, unsigned ring_size);
1286 extern int r600_cp_resume(struct radeon_device *rdev);
1287 extern void r600_cp_fini(struct radeon_device *rdev);
1288 extern int r600_count_pipe_bits(uint32_t val);
1289 extern int r600_mc_wait_for_idle(struct radeon_device *rdev);
1290 extern int r600_pcie_gart_init(struct radeon_device *rdev);
1291 extern void r600_pcie_gart_tlb_flush(struct radeon_device *rdev);
1292 extern int r600_ib_test(struct radeon_device *rdev);
1293 extern int r600_ring_test(struct radeon_device *rdev);
1294 extern void r600_wb_fini(struct radeon_device *rdev);
1295 extern int r600_wb_enable(struct radeon_device *rdev);
1296 extern void r600_wb_disable(struct radeon_device *rdev);
1297 extern void r600_scratch_init(struct radeon_device *rdev);
1298 extern int r600_blit_init(struct radeon_device *rdev);
1299 extern void r600_blit_fini(struct radeon_device *rdev);
1300 extern int r600_init_microcode(struct radeon_device *rdev);
1301 extern int r600_gpu_reset(struct radeon_device *rdev);
1302 /* r600 irq */
1303 extern int r600_irq_init(struct radeon_device *rdev);
1304 extern void r600_irq_fini(struct radeon_device *rdev);
1305 extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size);
1306 extern int r600_irq_set(struct radeon_device *rdev);
1307 extern void r600_irq_suspend(struct radeon_device *rdev);
1308 /* r600 audio */
1309 extern int r600_audio_init(struct radeon_device *rdev);
1310 extern int r600_audio_tmds_index(struct drm_encoder *encoder);
1311 extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock);
1312 extern void r600_audio_fini(struct radeon_device *rdev);
1313 extern void r600_hdmi_init(struct drm_encoder *encoder);
1314 extern void r600_hdmi_enable(struct drm_encoder *encoder, int enable);
1315 extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
1316 extern int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder);
1317 extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder,
1318 int channels,
1319 int rate,
1320 int bps,
1321 uint8_t status_bits,
1322 uint8_t category_code);
1324 /* evergreen */
1325 struct evergreen_mc_save {
1326 u32 vga_control[6];
1327 u32 vga_render_control;
1328 u32 vga_hdp_control;
1329 u32 crtc_control[6];
1332 #include "radeon_object.h"
1334 #endif