diff options
author | Jerome Glisse <jglisse@redhat.com> | 2009-09-07 20:10:24 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-09-07 21:15:52 -0400 |
commit | 3ce0a23d2d253185df24e22e3d5f89800bb3dd1c (patch) | |
tree | 4b4defdbe33aec7317101cce0f89c33083f8d17b /drivers/gpu/drm/radeon/radeon.h | |
parent | 4ce001abafafe77e5dd943d1480fc9f87894e96f (diff) |
drm/radeon/kms: add r600 KMS support
This adds the r600 KMS + CS support to the Linux kernel.
The r600 TTM support is quite basic and still needs more
work esp around using interrupts, but the polled fencing
should work okay for now.
Also currently TTM is using memcpy to do VRAM moves,
the code is here to use a 3D blit to do this, but
isn't fully debugged yet.
Authors:
Alex Deucher <alexdeucher@gmail.com>
Dave Airlie <airlied@redhat.com>
Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon.h')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 120 |
1 files changed, 66 insertions, 54 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index e47f2fc294ce..3299733ac300 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -50,8 +50,8 @@ | |||
50 | #include <linux/kref.h> | 50 | #include <linux/kref.h> |
51 | 51 | ||
52 | #include "radeon_mode.h" | 52 | #include "radeon_mode.h" |
53 | #include "radeon_share.h" | ||
53 | #include "radeon_reg.h" | 54 | #include "radeon_reg.h" |
54 | #include "r300.h" | ||
55 | 55 | ||
56 | /* | 56 | /* |
57 | * Modules parameters. | 57 | * Modules parameters. |
@@ -112,10 +112,11 @@ enum radeon_family { | |||
112 | CHIP_RV635, | 112 | CHIP_RV635, |
113 | CHIP_RV670, | 113 | CHIP_RV670, |
114 | CHIP_RS780, | 114 | CHIP_RS780, |
115 | CHIP_RS880, | ||
115 | CHIP_RV770, | 116 | CHIP_RV770, |
116 | CHIP_RV730, | 117 | CHIP_RV730, |
117 | CHIP_RV710, | 118 | CHIP_RV710, |
118 | CHIP_RS880, | 119 | CHIP_RV740, |
119 | CHIP_LAST, | 120 | CHIP_LAST, |
120 | }; | 121 | }; |
121 | 122 | ||
@@ -152,10 +153,21 @@ struct radeon_device; | |||
152 | */ | 153 | */ |
153 | bool radeon_get_bios(struct radeon_device *rdev); | 154 | bool radeon_get_bios(struct radeon_device *rdev); |
154 | 155 | ||
156 | |||
155 | /* | 157 | /* |
156 | * Clocks | 158 | * Dummy page |
157 | */ | 159 | */ |
160 | struct radeon_dummy_page { | ||
161 | struct page *page; | ||
162 | dma_addr_t addr; | ||
163 | }; | ||
164 | int radeon_dummy_page_init(struct radeon_device *rdev); | ||
165 | void radeon_dummy_page_fini(struct radeon_device *rdev); | ||
166 | |||
158 | 167 | ||
168 | /* | ||
169 | * Clocks | ||
170 | */ | ||
159 | struct radeon_clock { | 171 | struct radeon_clock { |
160 | struct radeon_pll p1pll; | 172 | struct radeon_pll p1pll; |
161 | struct radeon_pll p2pll; | 173 | struct radeon_pll p2pll; |
@@ -166,6 +178,7 @@ struct radeon_clock { | |||
166 | uint32_t default_sclk; | 178 | uint32_t default_sclk; |
167 | }; | 179 | }; |
168 | 180 | ||
181 | |||
169 | /* | 182 | /* |
170 | * Fences. | 183 | * Fences. |
171 | */ | 184 | */ |
@@ -332,14 +345,18 @@ struct radeon_mc { | |||
332 | resource_size_t aper_size; | 345 | resource_size_t aper_size; |
333 | resource_size_t aper_base; | 346 | resource_size_t aper_base; |
334 | resource_size_t agp_base; | 347 | resource_size_t agp_base; |
335 | unsigned gtt_location; | ||
336 | unsigned gtt_size; | ||
337 | unsigned vram_location; | ||
338 | /* for some chips with <= 32MB we need to lie | 348 | /* for some chips with <= 32MB we need to lie |
339 | * about vram size near mc fb location */ | 349 | * about vram size near mc fb location */ |
340 | unsigned mc_vram_size; | 350 | u64 mc_vram_size; |
351 | u64 gtt_location; | ||
352 | u64 gtt_size; | ||
353 | u64 gtt_start; | ||
354 | u64 gtt_end; | ||
355 | u64 vram_location; | ||
356 | u64 vram_start; | ||
357 | u64 vram_end; | ||
341 | unsigned vram_width; | 358 | unsigned vram_width; |
342 | unsigned real_vram_size; | 359 | u64 real_vram_size; |
343 | int vram_mtrr; | 360 | int vram_mtrr; |
344 | bool vram_is_ddr; | 361 | bool vram_is_ddr; |
345 | }; | 362 | }; |
@@ -411,6 +428,16 @@ struct radeon_cp { | |||
411 | bool ready; | 428 | bool ready; |
412 | }; | 429 | }; |
413 | 430 | ||
431 | struct r600_blit { | ||
432 | struct radeon_object *shader_obj; | ||
433 | u64 shader_gpu_addr; | ||
434 | u32 vs_offset, ps_offset; | ||
435 | u32 state_offset; | ||
436 | u32 state_len; | ||
437 | u32 vb_used, vb_total; | ||
438 | struct radeon_ib *vb_ib; | ||
439 | }; | ||
440 | |||
414 | int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib); | 441 | int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib); |
415 | void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib); | 442 | void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib); |
416 | int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib); | 443 | int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib); |
@@ -463,6 +490,7 @@ struct radeon_cs_parser { | |||
463 | int chunk_relocs_idx; | 490 | int chunk_relocs_idx; |
464 | struct radeon_ib *ib; | 491 | struct radeon_ib *ib; |
465 | void *track; | 492 | void *track; |
493 | unsigned family; | ||
466 | }; | 494 | }; |
467 | 495 | ||
468 | struct radeon_cs_packet { | 496 | struct radeon_cs_packet { |
@@ -559,6 +587,9 @@ int r100_debugfs_cp_init(struct radeon_device *rdev); | |||
559 | */ | 587 | */ |
560 | struct radeon_asic { | 588 | struct radeon_asic { |
561 | int (*init)(struct radeon_device *rdev); | 589 | int (*init)(struct radeon_device *rdev); |
590 | void (*fini)(struct radeon_device *rdev); | ||
591 | int (*resume)(struct radeon_device *rdev); | ||
592 | int (*suspend)(struct radeon_device *rdev); | ||
562 | void (*errata)(struct radeon_device *rdev); | 593 | void (*errata)(struct radeon_device *rdev); |
563 | void (*vram_info)(struct radeon_device *rdev); | 594 | void (*vram_info)(struct radeon_device *rdev); |
564 | int (*gpu_reset)(struct radeon_device *rdev); | 595 | int (*gpu_reset)(struct radeon_device *rdev); |
@@ -573,7 +604,11 @@ struct radeon_asic { | |||
573 | int (*cp_init)(struct radeon_device *rdev, unsigned ring_size); | 604 | int (*cp_init)(struct radeon_device *rdev, unsigned ring_size); |
574 | void (*cp_fini)(struct radeon_device *rdev); | 605 | void (*cp_fini)(struct radeon_device *rdev); |
575 | void (*cp_disable)(struct radeon_device *rdev); | 606 | void (*cp_disable)(struct radeon_device *rdev); |
607 | void (*cp_commit)(struct radeon_device *rdev); | ||
576 | void (*ring_start)(struct radeon_device *rdev); | 608 | void (*ring_start)(struct radeon_device *rdev); |
609 | int (*ring_test)(struct radeon_device *rdev); | ||
610 | void (*ring_ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib); | ||
611 | int (*ib_test)(struct radeon_device *rdev); | ||
577 | int (*irq_set)(struct radeon_device *rdev); | 612 | int (*irq_set)(struct radeon_device *rdev); |
578 | int (*irq_process)(struct radeon_device *rdev); | 613 | int (*irq_process)(struct radeon_device *rdev); |
579 | u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc); | 614 | u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc); |
@@ -613,6 +648,8 @@ struct r100_asic { | |||
613 | union radeon_asic_config { | 648 | union radeon_asic_config { |
614 | struct r300_asic r300; | 649 | struct r300_asic r300; |
615 | struct r100_asic r100; | 650 | struct r100_asic r100; |
651 | struct r600_asic r600; | ||
652 | struct rv770_asic rv770; | ||
616 | }; | 653 | }; |
617 | 654 | ||
618 | 655 | ||
@@ -698,12 +735,16 @@ struct radeon_device { | |||
698 | struct radeon_pm pm; | 735 | struct radeon_pm pm; |
699 | struct mutex cs_mutex; | 736 | struct mutex cs_mutex; |
700 | struct radeon_wb wb; | 737 | struct radeon_wb wb; |
738 | struct radeon_dummy_page dummy_page; | ||
701 | bool gpu_lockup; | 739 | bool gpu_lockup; |
702 | bool shutdown; | 740 | bool shutdown; |
703 | bool suspend; | 741 | bool suspend; |
704 | bool need_dma32; | 742 | bool need_dma32; |
743 | bool new_init_path; | ||
705 | struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES]; | 744 | struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES]; |
706 | const struct firmware *fw; /* firmware */ | 745 | const struct firmware *me_fw; /* all family ME firmware */ |
746 | const struct firmware *pfp_fw; /* r6/700 PFP firmware */ | ||
747 | struct r600_blit r600_blit; | ||
707 | }; | 748 | }; |
708 | 749 | ||
709 | int radeon_device_init(struct radeon_device *rdev, | 750 | int radeon_device_init(struct radeon_device *rdev, |
@@ -713,6 +754,13 @@ int radeon_device_init(struct radeon_device *rdev, | |||
713 | void radeon_device_fini(struct radeon_device *rdev); | 754 | void radeon_device_fini(struct radeon_device *rdev); |
714 | int radeon_gpu_wait_for_idle(struct radeon_device *rdev); | 755 | int radeon_gpu_wait_for_idle(struct radeon_device *rdev); |
715 | 756 | ||
757 | /* r600 blit */ | ||
758 | int r600_blit_prepare_copy(struct radeon_device *rdev, int size_bytes); | ||
759 | void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence); | ||
760 | void r600_kms_blit_copy(struct radeon_device *rdev, | ||
761 | u64 src_gpu_addr, u64 dst_gpu_addr, | ||
762 | int size_bytes); | ||
763 | |||
716 | static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg) | 764 | static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg) |
717 | { | 765 | { |
718 | if (reg < 0x10000) | 766 | if (reg < 0x10000) |
@@ -740,6 +788,7 @@ static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32 | |||
740 | #define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg)) | 788 | #define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg)) |
741 | #define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg)) | 789 | #define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg)) |
742 | #define RREG32(reg) r100_mm_rreg(rdev, (reg)) | 790 | #define RREG32(reg) r100_mm_rreg(rdev, (reg)) |
791 | #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg))) | ||
743 | #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v)) | 792 | #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v)) |
744 | #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) | 793 | #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) |
745 | #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) | 794 | #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) |
@@ -763,6 +812,7 @@ static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32 | |||
763 | tmp_ |= ((val) & ~(mask)); \ | 812 | tmp_ |= ((val) & ~(mask)); \ |
764 | WREG32_PLL(reg, tmp_); \ | 813 | WREG32_PLL(reg, tmp_); \ |
765 | } while (0) | 814 | } while (0) |
815 | #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg))) | ||
766 | 816 | ||
767 | /* | 817 | /* |
768 | * Indirect registers accessor | 818 | * Indirect registers accessor |
@@ -827,51 +877,6 @@ void radeon_atombios_fini(struct radeon_device *rdev); | |||
827 | /* | 877 | /* |
828 | * RING helpers. | 878 | * RING helpers. |
829 | */ | 879 | */ |
830 | #define CP_PACKET0 0x00000000 | ||
831 | #define PACKET0_BASE_INDEX_SHIFT 0 | ||
832 | #define PACKET0_BASE_INDEX_MASK (0x1ffff << 0) | ||
833 | #define PACKET0_COUNT_SHIFT 16 | ||
834 | #define PACKET0_COUNT_MASK (0x3fff << 16) | ||
835 | #define CP_PACKET1 0x40000000 | ||
836 | #define CP_PACKET2 0x80000000 | ||
837 | #define PACKET2_PAD_SHIFT 0 | ||
838 | #define PACKET2_PAD_MASK (0x3fffffff << 0) | ||
839 | #define CP_PACKET3 0xC0000000 | ||
840 | #define PACKET3_IT_OPCODE_SHIFT 8 | ||
841 | #define PACKET3_IT_OPCODE_MASK (0xff << 8) | ||
842 | #define PACKET3_COUNT_SHIFT 16 | ||
843 | #define PACKET3_COUNT_MASK (0x3fff << 16) | ||
844 | /* PACKET3 op code */ | ||
845 | #define PACKET3_NOP 0x10 | ||
846 | #define PACKET3_3D_DRAW_VBUF 0x28 | ||
847 | #define PACKET3_3D_DRAW_IMMD 0x29 | ||
848 | #define PACKET3_3D_DRAW_INDX 0x2A | ||
849 | #define PACKET3_3D_LOAD_VBPNTR 0x2F | ||
850 | #define PACKET3_INDX_BUFFER 0x33 | ||
851 | #define PACKET3_3D_DRAW_VBUF_2 0x34 | ||
852 | #define PACKET3_3D_DRAW_IMMD_2 0x35 | ||
853 | #define PACKET3_3D_DRAW_INDX_2 0x36 | ||
854 | #define PACKET3_BITBLT_MULTI 0x9B | ||
855 | |||
856 | #define PACKET0(reg, n) (CP_PACKET0 | \ | ||
857 | REG_SET(PACKET0_BASE_INDEX, (reg) >> 2) | \ | ||
858 | REG_SET(PACKET0_COUNT, (n))) | ||
859 | #define PACKET2(v) (CP_PACKET2 | REG_SET(PACKET2_PAD, (v))) | ||
860 | #define PACKET3(op, n) (CP_PACKET3 | \ | ||
861 | REG_SET(PACKET3_IT_OPCODE, (op)) | \ | ||
862 | REG_SET(PACKET3_COUNT, (n))) | ||
863 | |||
864 | #define PACKET_TYPE0 0 | ||
865 | #define PACKET_TYPE1 1 | ||
866 | #define PACKET_TYPE2 2 | ||
867 | #define PACKET_TYPE3 3 | ||
868 | |||
869 | #define CP_PACKET_GET_TYPE(h) (((h) >> 30) & 3) | ||
870 | #define CP_PACKET_GET_COUNT(h) (((h) >> 16) & 0x3FFF) | ||
871 | #define CP_PACKET0_GET_REG(h) (((h) & 0x1FFF) << 2) | ||
872 | #define CP_PACKET0_GET_ONE_REG_WR(h) (((h) >> 15) & 1) | ||
873 | #define CP_PACKET3_GET_OPCODE(h) (((h) >> 8) & 0xFF) | ||
874 | |||
875 | static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v) | 880 | static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v) |
876 | { | 881 | { |
877 | #if DRM_DEBUG_CODE | 882 | #if DRM_DEBUG_CODE |
@@ -890,6 +895,9 @@ static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v) | |||
890 | * ASICs macro. | 895 | * ASICs macro. |
891 | */ | 896 | */ |
892 | #define radeon_init(rdev) (rdev)->asic->init((rdev)) | 897 | #define radeon_init(rdev) (rdev)->asic->init((rdev)) |
898 | #define radeon_fini(rdev) (rdev)->asic->fini((rdev)) | ||
899 | #define radeon_resume(rdev) (rdev)->asic->resume((rdev)) | ||
900 | #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev)) | ||
893 | #define radeon_cs_parse(p) rdev->asic->cs_parse((p)) | 901 | #define radeon_cs_parse(p) rdev->asic->cs_parse((p)) |
894 | #define radeon_errata(rdev) (rdev)->asic->errata((rdev)) | 902 | #define radeon_errata(rdev) (rdev)->asic->errata((rdev)) |
895 | #define radeon_vram_info(rdev) (rdev)->asic->vram_info((rdev)) | 903 | #define radeon_vram_info(rdev) (rdev)->asic->vram_info((rdev)) |
@@ -905,7 +913,11 @@ static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v) | |||
905 | #define radeon_cp_init(rdev,rsize) (rdev)->asic->cp_init((rdev), (rsize)) | 913 | #define radeon_cp_init(rdev,rsize) (rdev)->asic->cp_init((rdev), (rsize)) |
906 | #define radeon_cp_fini(rdev) (rdev)->asic->cp_fini((rdev)) | 914 | #define radeon_cp_fini(rdev) (rdev)->asic->cp_fini((rdev)) |
907 | #define radeon_cp_disable(rdev) (rdev)->asic->cp_disable((rdev)) | 915 | #define radeon_cp_disable(rdev) (rdev)->asic->cp_disable((rdev)) |
916 | #define radeon_cp_commit(rdev) (rdev)->asic->cp_commit((rdev)) | ||
908 | #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev)) | 917 | #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev)) |
918 | #define radeon_ring_test(rdev) (rdev)->asic->ring_test((rdev)) | ||
919 | #define radeon_ring_ib_execute(rdev, ib) (rdev)->asic->ring_ib_execute((rdev), (ib)) | ||
920 | #define radeon_ib_test(rdev) (rdev)->asic->ib_test((rdev)) | ||
909 | #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev)) | 921 | #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev)) |
910 | #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev)) | 922 | #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev)) |
911 | #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc)) | 923 | #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc)) |