diff options
author | Ilija Hadzic <ihadzic@research.bell-labs.com> | 2013-01-02 18:27:43 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2013-01-31 16:24:43 -0500 |
commit | 40592a17b8747903be95338f461573916a71d739 (patch) | |
tree | 0255123d601f1be2c11322ecabdcc368b81a1b16 /drivers/gpu/drm/radeon/evergreen_cs.c | |
parent | 9ffb7a6dca4fd260db91c808efd4d5c56057600c (diff) |
drm/radeon: refactor vline packet parsing function
vline packet parsing function for R600 and Evergreen+ are
the same, except that they use different registers. Factor
out the algorithm into a common function that uses register
table passed from ASIC-specific caller.
This reduces ASIC-specific function to (trivial) setup
of register table and call into the common function.
Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/evergreen_cs.c')
-rw-r--r-- | drivers/gpu/drm/radeon/evergreen_cs.c | 120 |
1 files changed, 23 insertions, 97 deletions
diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c index 883b9f76a495..26905322d8e7 100644 --- a/drivers/gpu/drm/radeon/evergreen_cs.c +++ b/drivers/gpu/drm/radeon/evergreen_cs.c | |||
@@ -1055,109 +1055,35 @@ static int evergreen_cs_packet_next_reloc(struct radeon_cs_parser *p, | |||
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | /** | 1057 | /** |
1058 | * evergreen_cs_packet_next_vline() - parse userspace VLINE packet | 1058 | * evergreen_cs_packet_parse_vline() - parse userspace VLINE packet |
1059 | * @parser: parser structure holding parsing context. | 1059 | * @parser: parser structure holding parsing context. |
1060 | * | 1060 | * |
1061 | * Userspace sends a special sequence for VLINE waits. | 1061 | * This is an Evergreen(+)-specific function for parsing VLINE packets. |
1062 | * PACKET0 - VLINE_START_END + value | 1062 | * Real work is done by r600_cs_common_vline_parse function. |
1063 | * PACKET3 - WAIT_REG_MEM poll vline status reg | 1063 | * Here we just set up ASIC-specific register table and call |
1064 | * RELOC (P3) - crtc_id in reloc. | 1064 | * the common implementation function. |
1065 | * | ||
1066 | * This function parses this and relocates the VLINE START END | ||
1067 | * and WAIT_REG_MEM packets to the correct crtc. | ||
1068 | * It also detects a switched off crtc and nulls out the | ||
1069 | * wait in that case. | ||
1070 | */ | 1065 | */ |
1071 | static int evergreen_cs_packet_parse_vline(struct radeon_cs_parser *p) | 1066 | static int evergreen_cs_packet_parse_vline(struct radeon_cs_parser *p) |
1072 | { | 1067 | { |
1073 | struct drm_mode_object *obj; | ||
1074 | struct drm_crtc *crtc; | ||
1075 | struct radeon_crtc *radeon_crtc; | ||
1076 | struct radeon_cs_packet p3reloc, wait_reg_mem; | ||
1077 | int crtc_id; | ||
1078 | int r; | ||
1079 | uint32_t header, h_idx, reg, wait_reg_mem_info; | ||
1080 | volatile uint32_t *ib; | ||
1081 | |||
1082 | ib = p->ib.ptr; | ||
1083 | |||
1084 | /* parse the WAIT_REG_MEM */ | ||
1085 | r = radeon_cs_packet_parse(p, &wait_reg_mem, p->idx); | ||
1086 | if (r) | ||
1087 | return r; | ||
1088 | |||
1089 | /* check its a WAIT_REG_MEM */ | ||
1090 | if (wait_reg_mem.type != PACKET_TYPE3 || | ||
1091 | wait_reg_mem.opcode != PACKET3_WAIT_REG_MEM) { | ||
1092 | DRM_ERROR("vline wait missing WAIT_REG_MEM segment\n"); | ||
1093 | return -EINVAL; | ||
1094 | } | ||
1095 | |||
1096 | wait_reg_mem_info = radeon_get_ib_value(p, wait_reg_mem.idx + 1); | ||
1097 | /* bit 4 is reg (0) or mem (1) */ | ||
1098 | if (wait_reg_mem_info & 0x10) { | ||
1099 | DRM_ERROR("vline WAIT_REG_MEM waiting on MEM rather than REG\n"); | ||
1100 | return -EINVAL; | ||
1101 | } | ||
1102 | /* waiting for value to be equal */ | ||
1103 | if ((wait_reg_mem_info & 0x7) != 0x3) { | ||
1104 | DRM_ERROR("vline WAIT_REG_MEM function not equal\n"); | ||
1105 | return -EINVAL; | ||
1106 | } | ||
1107 | if ((radeon_get_ib_value(p, wait_reg_mem.idx + 2) << 2) != EVERGREEN_VLINE_STATUS) { | ||
1108 | DRM_ERROR("vline WAIT_REG_MEM bad reg\n"); | ||
1109 | return -EINVAL; | ||
1110 | } | ||
1111 | 1068 | ||
1112 | if (radeon_get_ib_value(p, wait_reg_mem.idx + 5) != EVERGREEN_VLINE_STAT) { | 1069 | static uint32_t vline_start_end[6] = { |
1113 | DRM_ERROR("vline WAIT_REG_MEM bad bit mask\n"); | 1070 | EVERGREEN_VLINE_START_END + EVERGREEN_CRTC0_REGISTER_OFFSET, |
1114 | return -EINVAL; | 1071 | EVERGREEN_VLINE_START_END + EVERGREEN_CRTC1_REGISTER_OFFSET, |
1115 | } | 1072 | EVERGREEN_VLINE_START_END + EVERGREEN_CRTC2_REGISTER_OFFSET, |
1116 | 1073 | EVERGREEN_VLINE_START_END + EVERGREEN_CRTC3_REGISTER_OFFSET, | |
1117 | /* jump over the NOP */ | 1074 | EVERGREEN_VLINE_START_END + EVERGREEN_CRTC4_REGISTER_OFFSET, |
1118 | r = radeon_cs_packet_parse(p, &p3reloc, p->idx + wait_reg_mem.count + 2); | 1075 | EVERGREEN_VLINE_START_END + EVERGREEN_CRTC5_REGISTER_OFFSET |
1119 | if (r) | 1076 | }; |
1120 | return r; | 1077 | static uint32_t vline_status[6] = { |
1121 | 1078 | EVERGREEN_VLINE_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, | |
1122 | h_idx = p->idx - 2; | 1079 | EVERGREEN_VLINE_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, |
1123 | p->idx += wait_reg_mem.count + 2; | 1080 | EVERGREEN_VLINE_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, |
1124 | p->idx += p3reloc.count + 2; | 1081 | EVERGREEN_VLINE_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, |
1125 | 1082 | EVERGREEN_VLINE_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, | |
1126 | header = radeon_get_ib_value(p, h_idx); | 1083 | EVERGREEN_VLINE_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET |
1127 | crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1); | 1084 | }; |
1128 | reg = CP_PACKET0_GET_REG(header); | 1085 | |
1129 | obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC); | 1086 | return r600_cs_common_vline_parse(p, vline_start_end, vline_status); |
1130 | if (!obj) { | ||
1131 | DRM_ERROR("cannot find crtc %d\n", crtc_id); | ||
1132 | return -EINVAL; | ||
1133 | } | ||
1134 | crtc = obj_to_crtc(obj); | ||
1135 | radeon_crtc = to_radeon_crtc(crtc); | ||
1136 | crtc_id = radeon_crtc->crtc_id; | ||
1137 | |||
1138 | if (!crtc->enabled) { | ||
1139 | /* if the CRTC isn't enabled - we need to nop out the WAIT_REG_MEM */ | ||
1140 | ib[h_idx + 2] = PACKET2(0); | ||
1141 | ib[h_idx + 3] = PACKET2(0); | ||
1142 | ib[h_idx + 4] = PACKET2(0); | ||
1143 | ib[h_idx + 5] = PACKET2(0); | ||
1144 | ib[h_idx + 6] = PACKET2(0); | ||
1145 | ib[h_idx + 7] = PACKET2(0); | ||
1146 | ib[h_idx + 8] = PACKET2(0); | ||
1147 | } else { | ||
1148 | switch (reg) { | ||
1149 | case EVERGREEN_VLINE_START_END: | ||
1150 | header &= ~R600_CP_PACKET0_REG_MASK; | ||
1151 | header |= (EVERGREEN_VLINE_START_END + radeon_crtc->crtc_offset) >> 2; | ||
1152 | ib[h_idx] = header; | ||
1153 | ib[h_idx + 4] = (EVERGREEN_VLINE_STATUS + radeon_crtc->crtc_offset) >> 2; | ||
1154 | break; | ||
1155 | default: | ||
1156 | DRM_ERROR("unknown crtc reloc\n"); | ||
1157 | return -EINVAL; | ||
1158 | } | ||
1159 | } | ||
1160 | return 0; | ||
1161 | } | 1087 | } |
1162 | 1088 | ||
1163 | static int evergreen_packet0_check(struct radeon_cs_parser *p, | 1089 | static int evergreen_packet0_check(struct radeon_cs_parser *p, |