diff options
author | Dave Airlie <airlied@redhat.com> | 2008-05-27 23:52:28 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2008-06-18 21:27:40 -0400 |
commit | c0beb2a723d69934a53f51a9d664c5b1dbbf634b (patch) | |
tree | a0057cb846b1935fd2303fb352b30730509952b5 /drivers | |
parent | 5b92c4045eaa42441b7ec249a406e4110ea400d4 (diff) |
drm/radeon: add initial r500 support.
This contains all the command buffer processing for the r500 cards.
It doesn't yet contain vblank support.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/drm/r300_cmdbuf.c | 93 | ||||
-rw-r--r-- | drivers/char/drm/r300_reg.h | 16 | ||||
-rw-r--r-- | drivers/char/drm/radeon_drm.h | 7 | ||||
-rw-r--r-- | drivers/char/drm/radeon_drv.h | 31 |
4 files changed, 135 insertions, 12 deletions
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c index f535812e4057..329733a48b64 100644 --- a/drivers/char/drm/r300_cmdbuf.c +++ b/drivers/char/drm/r300_cmdbuf.c | |||
@@ -189,18 +189,12 @@ void r300_init_reg_flags(struct drm_device *dev) | |||
189 | ADD_RANGE(R300_RE_CULL_CNTL, 1); | 189 | ADD_RANGE(R300_RE_CULL_CNTL, 1); |
190 | ADD_RANGE(0x42C0, 2); | 190 | ADD_RANGE(0x42C0, 2); |
191 | ADD_RANGE(R300_RS_CNTL_0, 2); | 191 | ADD_RANGE(R300_RS_CNTL_0, 2); |
192 | ADD_RANGE(R300_RS_INTERP_0, 8); | 192 | |
193 | ADD_RANGE(R300_RS_ROUTE_0, 8); | ||
194 | ADD_RANGE(0x43A4, 2); | 193 | ADD_RANGE(0x43A4, 2); |
195 | ADD_RANGE(0x43E8, 1); | 194 | ADD_RANGE(0x43E8, 1); |
196 | ADD_RANGE(R300_PFS_CNTL_0, 3); | 195 | |
197 | ADD_RANGE(R300_PFS_NODE_0, 4); | ||
198 | ADD_RANGE(R300_PFS_TEXI_0, 64); | ||
199 | ADD_RANGE(0x46A4, 5); | 196 | ADD_RANGE(0x46A4, 5); |
200 | ADD_RANGE(R300_PFS_INSTR0_0, 64); | 197 | |
201 | ADD_RANGE(R300_PFS_INSTR1_0, 64); | ||
202 | ADD_RANGE(R300_PFS_INSTR2_0, 64); | ||
203 | ADD_RANGE(R300_PFS_INSTR3_0, 64); | ||
204 | ADD_RANGE(R300_RE_FOG_STATE, 1); | 198 | ADD_RANGE(R300_RE_FOG_STATE, 1); |
205 | ADD_RANGE(R300_FOG_COLOR_R, 3); | 199 | ADD_RANGE(R300_FOG_COLOR_R, 3); |
206 | ADD_RANGE(R300_PP_ALPHA_TEST, 2); | 200 | ADD_RANGE(R300_PP_ALPHA_TEST, 2); |
@@ -241,7 +235,25 @@ void r300_init_reg_flags(struct drm_device *dev) | |||
241 | ADD_RANGE(R300_VAP_INPUT_ROUTE_1_0, 8); | 235 | ADD_RANGE(R300_VAP_INPUT_ROUTE_1_0, 8); |
242 | 236 | ||
243 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RV515) { | 237 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RV515) { |
244 | ADD_RANGE(0x4074, 16); | 238 | ADD_RANGE(R500_VAP_INDEX_OFFSET, 1); |
239 | ADD_RANGE(R500_US_CONFIG, 2); | ||
240 | ADD_RANGE(R500_US_CODE_ADDR, 3); | ||
241 | ADD_RANGE(R500_US_FC_CTRL, 1); | ||
242 | ADD_RANGE(R500_RS_IP_0, 16); | ||
243 | ADD_RANGE(R500_RS_INST_0, 16); | ||
244 | ADD_RANGE(R500_RB3D_COLOR_CLEAR_VALUE_AR, 2); | ||
245 | ADD_RANGE(R500_RB3D_CONSTANT_COLOR_AR, 2); | ||
246 | } else { | ||
247 | ADD_RANGE(R300_PFS_CNTL_0, 3); | ||
248 | ADD_RANGE(R300_PFS_NODE_0, 4); | ||
249 | ADD_RANGE(R300_PFS_TEXI_0, 64); | ||
250 | ADD_RANGE(R300_PFS_INSTR0_0, 64); | ||
251 | ADD_RANGE(R300_PFS_INSTR1_0, 64); | ||
252 | ADD_RANGE(R300_PFS_INSTR2_0, 64); | ||
253 | ADD_RANGE(R300_PFS_INSTR3_0, 64); | ||
254 | ADD_RANGE(R300_RS_INTERP_0, 8); | ||
255 | ADD_RANGE(R300_RS_ROUTE_0, 8); | ||
256 | |||
245 | } | 257 | } |
246 | } | 258 | } |
247 | 259 | ||
@@ -829,6 +841,54 @@ static int r300_scratch(drm_radeon_private_t *dev_priv, | |||
829 | } | 841 | } |
830 | 842 | ||
831 | /** | 843 | /** |
844 | * Uploads user-supplied vertex program instructions or parameters onto | ||
845 | * the graphics card. | ||
846 | * Called by r300_do_cp_cmdbuf. | ||
847 | */ | ||
848 | static inline int r300_emit_r500fp(drm_radeon_private_t *dev_priv, | ||
849 | drm_radeon_kcmd_buffer_t *cmdbuf, | ||
850 | drm_r300_cmd_header_t header) | ||
851 | { | ||
852 | int sz; | ||
853 | int addr; | ||
854 | int type; | ||
855 | int clamp; | ||
856 | int stride; | ||
857 | RING_LOCALS; | ||
858 | |||
859 | sz = header.r500fp.count; | ||
860 | /* address is 9 bits 0 - 8, bit 1 of flags is part of address */ | ||
861 | addr = ((header.r500fp.adrhi_flags & 1) << 8) | header.r500fp.adrlo; | ||
862 | |||
863 | type = !!(header.r500fp.adrhi_flags & R500FP_CONSTANT_TYPE); | ||
864 | clamp = !!(header.r500fp.adrhi_flags & R500FP_CONSTANT_CLAMP); | ||
865 | |||
866 | addr |= (type << 16); | ||
867 | addr |= (clamp << 17); | ||
868 | |||
869 | stride = type ? 4 : 6; | ||
870 | |||
871 | DRM_DEBUG("r500fp %d %d type: %d\n", sz, addr, type); | ||
872 | if (!sz) | ||
873 | return 0; | ||
874 | if (sz * stride * 4 > cmdbuf->bufsz) | ||
875 | return -EINVAL; | ||
876 | |||
877 | BEGIN_RING(3 + sz * stride); | ||
878 | OUT_RING_REG(R500_GA_US_VECTOR_INDEX, addr); | ||
879 | OUT_RING(CP_PACKET0_TABLE(R500_GA_US_VECTOR_DATA, sz * stride - 1)); | ||
880 | OUT_RING_TABLE((int *)cmdbuf->buf, sz * stride); | ||
881 | |||
882 | ADVANCE_RING(); | ||
883 | |||
884 | cmdbuf->buf += sz * stride * 4; | ||
885 | cmdbuf->bufsz -= sz * stride * 4; | ||
886 | |||
887 | return 0; | ||
888 | } | ||
889 | |||
890 | |||
891 | /** | ||
832 | * Parses and validates a user-supplied command buffer and emits appropriate | 892 | * Parses and validates a user-supplied command buffer and emits appropriate |
833 | * commands on the DMA ring buffer. | 893 | * commands on the DMA ring buffer. |
834 | * Called by the ioctl handler function radeon_cp_cmdbuf. | 894 | * Called by the ioctl handler function radeon_cp_cmdbuf. |
@@ -963,6 +1023,19 @@ int r300_do_cp_cmdbuf(struct drm_device *dev, | |||
963 | } | 1023 | } |
964 | break; | 1024 | break; |
965 | 1025 | ||
1026 | case R300_CMD_R500FP: | ||
1027 | if ((dev_priv->flags & RADEON_FAMILY_MASK) < CHIP_RV515) { | ||
1028 | DRM_ERROR("Calling r500 command on r300 card\n"); | ||
1029 | ret = -EINVAL; | ||
1030 | goto cleanup; | ||
1031 | } | ||
1032 | DRM_DEBUG("R300_CMD_R500FP\n"); | ||
1033 | ret = r300_emit_r500fp(dev_priv, cmdbuf, header); | ||
1034 | if (ret) { | ||
1035 | DRM_ERROR("r300_emit_r500fp failed\n"); | ||
1036 | goto cleanup; | ||
1037 | } | ||
1038 | break; | ||
966 | default: | 1039 | default: |
967 | DRM_ERROR("bad cmd_type %i at %p\n", | 1040 | DRM_ERROR("bad cmd_type %i at %p\n", |
968 | header.header.cmd_type, | 1041 | header.header.cmd_type, |
diff --git a/drivers/char/drm/r300_reg.h b/drivers/char/drm/r300_reg.h index a72c70322483..a883d10c40b1 100644 --- a/drivers/char/drm/r300_reg.h +++ b/drivers/char/drm/r300_reg.h | |||
@@ -1623,4 +1623,20 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
1623 | */ | 1623 | */ |
1624 | #define R300_CP_CMD_BITBLT_MULTI 0xC0009B00 | 1624 | #define R300_CP_CMD_BITBLT_MULTI 0xC0009B00 |
1625 | 1625 | ||
1626 | #define R500_VAP_INDEX_OFFSET 0x208c | ||
1627 | |||
1628 | #define R500_GA_US_VECTOR_INDEX 0x4250 | ||
1629 | #define R500_GA_US_VECTOR_DATA 0x4254 | ||
1630 | |||
1631 | #define R500_RS_IP_0 0x4074 | ||
1632 | #define R500_RS_INST_0 0x4320 | ||
1633 | |||
1634 | #define R500_US_CONFIG 0x4600 | ||
1635 | |||
1636 | #define R500_US_FC_CTRL 0x4624 | ||
1637 | #define R500_US_CODE_ADDR 0x4630 | ||
1638 | |||
1639 | #define R500_RB3D_COLOR_CLEAR_VALUE_AR 0x46c0 | ||
1640 | #define R500_RB3D_CONSTANT_COLOR_AR 0x4ef8 | ||
1641 | |||
1626 | #endif /* _R300_REG_H */ | 1642 | #endif /* _R300_REG_H */ |
diff --git a/drivers/char/drm/radeon_drm.h b/drivers/char/drm/radeon_drm.h index 68b0608e01c9..73ff51f12311 100644 --- a/drivers/char/drm/radeon_drm.h +++ b/drivers/char/drm/radeon_drm.h | |||
@@ -240,6 +240,7 @@ typedef union { | |||
240 | # define R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN 0x8 | 240 | # define R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN 0x8 |
241 | 241 | ||
242 | #define R300_CMD_SCRATCH 8 | 242 | #define R300_CMD_SCRATCH 8 |
243 | #define R300_CMD_R500FP 9 | ||
243 | 244 | ||
244 | typedef union { | 245 | typedef union { |
245 | unsigned int u; | 246 | unsigned int u; |
@@ -268,6 +269,9 @@ typedef union { | |||
268 | struct { | 269 | struct { |
269 | unsigned char cmd_type, reg, n_bufs, flags; | 270 | unsigned char cmd_type, reg, n_bufs, flags; |
270 | } scratch; | 271 | } scratch; |
272 | struct { | ||
273 | unsigned char cmd_type, count, adrlo, adrhi_flags; | ||
274 | } r500fp; | ||
271 | } drm_r300_cmd_header_t; | 275 | } drm_r300_cmd_header_t; |
272 | 276 | ||
273 | #define RADEON_FRONT 0x1 | 277 | #define RADEON_FRONT 0x1 |
@@ -278,6 +282,9 @@ typedef union { | |||
278 | #define RADEON_USE_HIERZ 0x40000000 | 282 | #define RADEON_USE_HIERZ 0x40000000 |
279 | #define RADEON_USE_COMP_ZBUF 0x20000000 | 283 | #define RADEON_USE_COMP_ZBUF 0x20000000 |
280 | 284 | ||
285 | #define R500FP_CONSTANT_TYPE (1 << 1) | ||
286 | #define R500FP_CONSTANT_CLAMP (1 << 2) | ||
287 | |||
281 | /* Primitive types | 288 | /* Primitive types |
282 | */ | 289 | */ |
283 | #define RADEON_POINTS 0x1 | 290 | #define RADEON_POINTS 0x1 |
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h index c3615cf20b85..d0dc47cee6c9 100644 --- a/drivers/char/drm/radeon_drv.h +++ b/drivers/char/drm/radeon_drv.h | |||
@@ -38,7 +38,7 @@ | |||
38 | 38 | ||
39 | #define DRIVER_NAME "radeon" | 39 | #define DRIVER_NAME "radeon" |
40 | #define DRIVER_DESC "ATI Radeon" | 40 | #define DRIVER_DESC "ATI Radeon" |
41 | #define DRIVER_DATE "20060524" | 41 | #define DRIVER_DATE "20080528" |
42 | 42 | ||
43 | /* Interface history: | 43 | /* Interface history: |
44 | * | 44 | * |
@@ -98,9 +98,10 @@ | |||
98 | * 1.26- Add support for variable size PCI(E) gart aperture | 98 | * 1.26- Add support for variable size PCI(E) gart aperture |
99 | * 1.27- Add support for IGP GART | 99 | * 1.27- Add support for IGP GART |
100 | * 1.28- Add support for VBL on CRTC2 | 100 | * 1.28- Add support for VBL on CRTC2 |
101 | * 1.29- R500 3D cmd buffer support | ||
101 | */ | 102 | */ |
102 | #define DRIVER_MAJOR 1 | 103 | #define DRIVER_MAJOR 1 |
103 | #define DRIVER_MINOR 28 | 104 | #define DRIVER_MINOR 29 |
104 | #define DRIVER_PATCHLEVEL 0 | 105 | #define DRIVER_PATCHLEVEL 0 |
105 | 106 | ||
106 | /* | 107 | /* |
@@ -294,6 +295,7 @@ typedef struct drm_radeon_private { | |||
294 | int vblank_crtc; | 295 | int vblank_crtc; |
295 | uint32_t irq_enable_reg; | 296 | uint32_t irq_enable_reg; |
296 | int irq_enabled; | 297 | int irq_enabled; |
298 | uint32_t r500_disp_irq_reg; | ||
297 | 299 | ||
298 | struct radeon_surface surfaces[RADEON_MAX_SURFACES]; | 300 | struct radeon_surface surfaces[RADEON_MAX_SURFACES]; |
299 | struct radeon_virt_surface virt_surfaces[2 * RADEON_MAX_SURFACES]; | 301 | struct radeon_virt_surface virt_surfaces[2 * RADEON_MAX_SURFACES]; |
@@ -1103,6 +1105,31 @@ extern int r300_do_cp_cmdbuf(struct drm_device * dev, | |||
1103 | 1105 | ||
1104 | #define R200_VAP_PVS_CNTL_1 0x22D0 | 1106 | #define R200_VAP_PVS_CNTL_1 0x22D0 |
1105 | 1107 | ||
1108 | #define R500_D1CRTC_STATUS 0x609c | ||
1109 | #define R500_D2CRTC_STATUS 0x689c | ||
1110 | #define R500_CRTC_V_BLANK (1<<0) | ||
1111 | |||
1112 | #define R500_D1CRTC_FRAME_COUNT 0x60a4 | ||
1113 | #define R500_D2CRTC_FRAME_COUNT 0x68a4 | ||
1114 | |||
1115 | #define R500_D1MODE_V_COUNTER 0x6530 | ||
1116 | #define R500_D2MODE_V_COUNTER 0x6d30 | ||
1117 | |||
1118 | #define R500_D1MODE_VBLANK_STATUS 0x6534 | ||
1119 | #define R500_D2MODE_VBLANK_STATUS 0x6d34 | ||
1120 | #define R500_VBLANK_OCCURED (1<<0) | ||
1121 | #define R500_VBLANK_ACK (1<<4) | ||
1122 | #define R500_VBLANK_STAT (1<<12) | ||
1123 | #define R500_VBLANK_INT (1<<16) | ||
1124 | |||
1125 | #define R500_DxMODE_INT_MASK 0x6540 | ||
1126 | #define R500_D1MODE_INT_MASK (1<<0) | ||
1127 | #define R500_D2MODE_INT_MASK (1<<8) | ||
1128 | |||
1129 | #define R500_DISP_INTERRUPT_STATUS 0x7edc | ||
1130 | #define R500_D1_VBLANK_INTERRUPT (1 << 4) | ||
1131 | #define R500_D2_VBLANK_INTERRUPT (1 << 5) | ||
1132 | |||
1106 | /* Constants */ | 1133 | /* Constants */ |
1107 | #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ | 1134 | #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ |
1108 | 1135 | ||