Rev 6105 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6105 | Rev 6938 | ||
---|---|---|---|
Line 47... | Line 47... | ||
47 | */ |
47 | */ |
48 | /** |
48 | /** |
49 | * radeon_get_vblank_counter_kms - get frame count |
49 | * radeon_get_vblank_counter_kms - get frame count |
50 | * |
50 | * |
51 | * @dev: drm dev pointer |
51 | * @dev: drm dev pointer |
52 | * @crtc: crtc to get the frame count from |
52 | * @pipe: crtc to get the frame count from |
53 | * |
53 | * |
54 | * Gets the frame count on the requested crtc (all asics). |
54 | * Gets the frame count on the requested crtc (all asics). |
55 | * Returns frame count on success, -EINVAL on failure. |
55 | * Returns frame count on success, -EINVAL on failure. |
56 | */ |
56 | */ |
57 | u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc) |
57 | u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe) |
58 | { |
58 | { |
59 | int vpos, hpos, stat; |
59 | int vpos, hpos, stat; |
60 | u32 count; |
60 | u32 count; |
61 | struct radeon_device *rdev = dev->dev_private; |
61 | struct radeon_device *rdev = dev->dev_private; |
Line 62... | Line 62... | ||
62 | 62 | ||
63 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
63 | if (pipe >= rdev->num_crtc) { |
64 | DRM_ERROR("Invalid crtc %d\n", crtc); |
64 | DRM_ERROR("Invalid crtc %u\n", pipe); |
65 | return -EINVAL; |
65 | return -EINVAL; |
Line 66... | Line 66... | ||
66 | } |
66 | } |
67 | 67 | ||
Line 71... | Line 71... | ||
71 | * incremented at start of vblank. We measure distance to start of |
71 | * incremented at start of vblank. We measure distance to start of |
72 | * vblank in vpos. vpos therefore will be >= 0 between start of vblank |
72 | * vblank in vpos. vpos therefore will be >= 0 between start of vblank |
73 | * and start of vsync, so vpos >= 0 means to bump the hw frame counter |
73 | * and start of vsync, so vpos >= 0 means to bump the hw frame counter |
74 | * result by 1 to give the proper appearance to caller. |
74 | * result by 1 to give the proper appearance to caller. |
75 | */ |
75 | */ |
76 | if (rdev->mode_info.crtcs[crtc]) { |
76 | if (rdev->mode_info.crtcs[pipe]) { |
77 | /* Repeat readout if needed to provide stable result if |
77 | /* Repeat readout if needed to provide stable result if |
78 | * we cross start of vsync during the queries. |
78 | * we cross start of vsync during the queries. |
79 | */ |
79 | */ |
80 | do { |
80 | do { |
81 | count = radeon_get_vblank_counter(rdev, crtc); |
81 | count = radeon_get_vblank_counter(rdev, pipe); |
82 | /* Ask radeon_get_crtc_scanoutpos to return vpos as |
82 | /* Ask radeon_get_crtc_scanoutpos to return vpos as |
83 | * distance to start of vblank, instead of regular |
83 | * distance to start of vblank, instead of regular |
84 | * vertical scanout pos. |
84 | * vertical scanout pos. |
85 | */ |
85 | */ |
86 | stat = radeon_get_crtc_scanoutpos( |
86 | stat = radeon_get_crtc_scanoutpos( |
87 | dev, crtc, GET_DISTANCE_TO_VBLANKSTART, |
87 | dev, pipe, GET_DISTANCE_TO_VBLANKSTART, |
88 | &vpos, &hpos, NULL, NULL, |
88 | &vpos, &hpos, NULL, NULL, |
89 | &rdev->mode_info.crtcs[crtc]->base.hwmode); |
89 | &rdev->mode_info.crtcs[pipe]->base.hwmode); |
90 | } while (count != radeon_get_vblank_counter(rdev, crtc)); |
90 | } while (count != radeon_get_vblank_counter(rdev, pipe)); |
Line 91... | Line 91... | ||
91 | 91 | ||
92 | if (((stat & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE)) != |
92 | if (((stat & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE)) != |
93 | (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE))) { |
93 | (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE))) { |
94 | DRM_DEBUG_VBL("Query failed! stat %d\n", stat); |
94 | DRM_DEBUG_VBL("Query failed! stat %d\n", stat); |
95 | } |
95 | } |
96 | else { |
96 | else { |
97 | DRM_DEBUG_VBL("crtc %d: dist from vblank start %d\n", |
97 | DRM_DEBUG_VBL("crtc %u: dist from vblank start %d\n", |
Line 98... | Line 98... | ||
98 | crtc, vpos); |
98 | pipe, vpos); |
99 | 99 | ||
100 | /* Bump counter if we are at >= leading edge of vblank, |
100 | /* Bump counter if we are at >= leading edge of vblank, |
101 | * but before vsync where vpos would turn negative and |
101 | * but before vsync where vpos would turn negative and |
Line 105... | Line 105... | ||
105 | count++; |
105 | count++; |
106 | } |
106 | } |
107 | } |
107 | } |
108 | else { |
108 | else { |
109 | /* Fallback to use value as is. */ |
109 | /* Fallback to use value as is. */ |
110 | count = radeon_get_vblank_counter(rdev, crtc); |
110 | count = radeon_get_vblank_counter(rdev, pipe); |
111 | DRM_DEBUG_VBL("NULL mode info! Returned count may be wrong.\n"); |
111 | DRM_DEBUG_VBL("NULL mode info! Returned count may be wrong.\n"); |
112 | } |
112 | } |
Line 113... | Line 113... | ||
113 | 113 | ||
114 | return count; |
114 | return count; |