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/r600_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/r600_cs.c')
-rw-r--r-- | drivers/gpu/drm/radeon/r600_cs.c | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c index 6e6fa97043d0..e61a013e63fc 100644 --- a/drivers/gpu/drm/radeon/r600_cs.c +++ b/drivers/gpu/drm/radeon/r600_cs.c | |||
@@ -877,9 +877,30 @@ static int r600_cs_packet_next_reloc_nomm(struct radeon_cs_parser *p, | |||
877 | } | 877 | } |
878 | 878 | ||
879 | /** | 879 | /** |
880 | * r600_cs_packet_next_vline() - parse userspace VLINE packet | 880 | * r600_cs_packet_parse_vline() - parse userspace VLINE packet |
881 | * @parser: parser structure holding parsing context. | 881 | * @parser: parser structure holding parsing context. |
882 | * | 882 | * |
883 | * This is an R600-specific function for parsing VLINE packets. | ||
884 | * Real work is done by r600_cs_common_vline_parse function. | ||
885 | * Here we just set up ASIC-specific register table and call | ||
886 | * the common implementation function. | ||
887 | */ | ||
888 | static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p) | ||
889 | { | ||
890 | static uint32_t vline_start_end[2] = {AVIVO_D1MODE_VLINE_START_END, | ||
891 | AVIVO_D2MODE_VLINE_START_END}; | ||
892 | static uint32_t vline_status[2] = {AVIVO_D1MODE_VLINE_STATUS, | ||
893 | AVIVO_D2MODE_VLINE_STATUS}; | ||
894 | |||
895 | return r600_cs_common_vline_parse(p, vline_start_end, vline_status); | ||
896 | } | ||
897 | |||
898 | /** | ||
899 | * r600_cs_common_vline_parse() - common vline parser | ||
900 | * @parser: parser structure holding parsing context. | ||
901 | * @vline_start_end: table of vline_start_end registers | ||
902 | * @vline_status: table of vline_status registers | ||
903 | * | ||
883 | * Userspace sends a special sequence for VLINE waits. | 904 | * Userspace sends a special sequence for VLINE waits. |
884 | * PACKET0 - VLINE_START_END + value | 905 | * PACKET0 - VLINE_START_END + value |
885 | * PACKET3 - WAIT_REG_MEM poll vline status reg | 906 | * PACKET3 - WAIT_REG_MEM poll vline status reg |
@@ -888,9 +909,16 @@ static int r600_cs_packet_next_reloc_nomm(struct radeon_cs_parser *p, | |||
888 | * This function parses this and relocates the VLINE START END | 909 | * This function parses this and relocates the VLINE START END |
889 | * and WAIT_REG_MEM packets to the correct crtc. | 910 | * and WAIT_REG_MEM packets to the correct crtc. |
890 | * It also detects a switched off crtc and nulls out the | 911 | * It also detects a switched off crtc and nulls out the |
891 | * wait in that case. | 912 | * wait in that case. This function is common for all ASICs that |
913 | * are R600 and newer. The parsing algorithm is the same, and only | ||
914 | * differs in which registers are used. | ||
915 | * | ||
916 | * Caller is the ASIC-specific function which passes the parser | ||
917 | * context and ASIC-specific register table | ||
892 | */ | 918 | */ |
893 | static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p) | 919 | int r600_cs_common_vline_parse(struct radeon_cs_parser *p, |
920 | uint32_t *vline_start_end, | ||
921 | uint32_t *vline_status) | ||
894 | { | 922 | { |
895 | struct drm_mode_object *obj; | 923 | struct drm_mode_object *obj; |
896 | struct drm_crtc *crtc; | 924 | struct drm_crtc *crtc; |
@@ -918,7 +946,7 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p) | |||
918 | wait_reg_mem_info = radeon_get_ib_value(p, wait_reg_mem.idx + 1); | 946 | wait_reg_mem_info = radeon_get_ib_value(p, wait_reg_mem.idx + 1); |
919 | /* bit 4 is reg (0) or mem (1) */ | 947 | /* bit 4 is reg (0) or mem (1) */ |
920 | if (wait_reg_mem_info & 0x10) { | 948 | if (wait_reg_mem_info & 0x10) { |
921 | DRM_ERROR("vline WAIT_REG_MEM waiting on MEM rather than REG\n"); | 949 | DRM_ERROR("vline WAIT_REG_MEM waiting on MEM instead of REG\n"); |
922 | return -EINVAL; | 950 | return -EINVAL; |
923 | } | 951 | } |
924 | /* waiting for value to be equal */ | 952 | /* waiting for value to be equal */ |
@@ -926,12 +954,12 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p) | |||
926 | DRM_ERROR("vline WAIT_REG_MEM function not equal\n"); | 954 | DRM_ERROR("vline WAIT_REG_MEM function not equal\n"); |
927 | return -EINVAL; | 955 | return -EINVAL; |
928 | } | 956 | } |
929 | if ((radeon_get_ib_value(p, wait_reg_mem.idx + 2) << 2) != AVIVO_D1MODE_VLINE_STATUS) { | 957 | if ((radeon_get_ib_value(p, wait_reg_mem.idx + 2) << 2) != vline_status[0]) { |
930 | DRM_ERROR("vline WAIT_REG_MEM bad reg\n"); | 958 | DRM_ERROR("vline WAIT_REG_MEM bad reg\n"); |
931 | return -EINVAL; | 959 | return -EINVAL; |
932 | } | 960 | } |
933 | 961 | ||
934 | if (radeon_get_ib_value(p, wait_reg_mem.idx + 5) != AVIVO_D1MODE_VLINE_STAT) { | 962 | if (radeon_get_ib_value(p, wait_reg_mem.idx + 5) != RADEON_VLINE_STAT) { |
935 | DRM_ERROR("vline WAIT_REG_MEM bad bit mask\n"); | 963 | DRM_ERROR("vline WAIT_REG_MEM bad bit mask\n"); |
936 | return -EINVAL; | 964 | return -EINVAL; |
937 | } | 965 | } |
@@ -959,7 +987,7 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p) | |||
959 | crtc_id = radeon_crtc->crtc_id; | 987 | crtc_id = radeon_crtc->crtc_id; |
960 | 988 | ||
961 | if (!crtc->enabled) { | 989 | if (!crtc->enabled) { |
962 | /* if the CRTC isn't enabled - we need to nop out the WAIT_REG_MEM */ | 990 | /* CRTC isn't enabled - we need to nop out the WAIT_REG_MEM */ |
963 | ib[h_idx + 2] = PACKET2(0); | 991 | ib[h_idx + 2] = PACKET2(0); |
964 | ib[h_idx + 3] = PACKET2(0); | 992 | ib[h_idx + 3] = PACKET2(0); |
965 | ib[h_idx + 4] = PACKET2(0); | 993 | ib[h_idx + 4] = PACKET2(0); |
@@ -967,20 +995,15 @@ static int r600_cs_packet_parse_vline(struct radeon_cs_parser *p) | |||
967 | ib[h_idx + 6] = PACKET2(0); | 995 | ib[h_idx + 6] = PACKET2(0); |
968 | ib[h_idx + 7] = PACKET2(0); | 996 | ib[h_idx + 7] = PACKET2(0); |
969 | ib[h_idx + 8] = PACKET2(0); | 997 | ib[h_idx + 8] = PACKET2(0); |
970 | } else if (crtc_id == 1) { | 998 | } else if (reg == vline_start_end[0]) { |
971 | switch (reg) { | 999 | header &= ~R600_CP_PACKET0_REG_MASK; |
972 | case AVIVO_D1MODE_VLINE_START_END: | 1000 | header |= vline_start_end[crtc_id] >> 2; |
973 | header &= ~R600_CP_PACKET0_REG_MASK; | ||
974 | header |= AVIVO_D2MODE_VLINE_START_END >> 2; | ||
975 | break; | ||
976 | default: | ||
977 | DRM_ERROR("unknown crtc reloc\n"); | ||
978 | return -EINVAL; | ||
979 | } | ||
980 | ib[h_idx] = header; | 1001 | ib[h_idx] = header; |
981 | ib[h_idx + 4] = AVIVO_D2MODE_VLINE_STATUS >> 2; | 1002 | ib[h_idx + 4] = vline_status[crtc_id] >> 2; |
1003 | } else { | ||
1004 | DRM_ERROR("unknown crtc reloc\n"); | ||
1005 | return -EINVAL; | ||
982 | } | 1006 | } |
983 | |||
984 | return 0; | 1007 | return 0; |
985 | } | 1008 | } |
986 | 1009 | ||