diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_kms.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_kms.c | 64 |
1 files changed, 48 insertions, 16 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index 8fbbe1c6ebbd..28a53e4a925f 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -96,9 +96,27 @@ out: | |||
96 | return r; | 96 | return r; |
97 | } | 97 | } |
98 | 98 | ||
99 | static void radeon_set_filp_rights(struct drm_device *dev, | ||
100 | struct drm_file **owner, | ||
101 | struct drm_file *applier, | ||
102 | uint32_t *value) | ||
103 | { | ||
104 | mutex_lock(&dev->struct_mutex); | ||
105 | if (*value == 1) { | ||
106 | /* wants rights */ | ||
107 | if (!*owner) | ||
108 | *owner = applier; | ||
109 | } else if (*value == 0) { | ||
110 | /* revokes rights */ | ||
111 | if (*owner == applier) | ||
112 | *owner = NULL; | ||
113 | } | ||
114 | *value = *owner == applier ? 1 : 0; | ||
115 | mutex_unlock(&dev->struct_mutex); | ||
116 | } | ||
99 | 117 | ||
100 | /* | 118 | /* |
101 | * Userspace get informations ioctl | 119 | * Userspace get information ioctl |
102 | */ | 120 | */ |
103 | int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | 121 | int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) |
104 | { | 122 | { |
@@ -173,18 +191,15 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
173 | DRM_DEBUG_KMS("WANT_HYPERZ: invalid value %d\n", value); | 191 | DRM_DEBUG_KMS("WANT_HYPERZ: invalid value %d\n", value); |
174 | return -EINVAL; | 192 | return -EINVAL; |
175 | } | 193 | } |
176 | mutex_lock(&dev->struct_mutex); | 194 | radeon_set_filp_rights(dev, &rdev->hyperz_filp, filp, &value); |
177 | if (value == 1) { | 195 | break; |
178 | /* wants hyper-z */ | 196 | case RADEON_INFO_WANT_CMASK: |
179 | if (!rdev->hyperz_filp) | 197 | /* The same logic as Hyper-Z. */ |
180 | rdev->hyperz_filp = filp; | 198 | if (value >= 2) { |
181 | } else if (value == 0) { | 199 | DRM_DEBUG_KMS("WANT_CMASK: invalid value %d\n", value); |
182 | /* revokes hyper-z */ | 200 | return -EINVAL; |
183 | if (rdev->hyperz_filp == filp) | ||
184 | rdev->hyperz_filp = NULL; | ||
185 | } | 201 | } |
186 | value = rdev->hyperz_filp == filp ? 1 : 0; | 202 | radeon_set_filp_rights(dev, &rdev->cmask_filp, filp, &value); |
187 | mutex_unlock(&dev->struct_mutex); | ||
188 | break; | 203 | break; |
189 | default: | 204 | default: |
190 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); | 205 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); |
@@ -203,10 +218,6 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
203 | */ | 218 | */ |
204 | int radeon_driver_firstopen_kms(struct drm_device *dev) | 219 | int radeon_driver_firstopen_kms(struct drm_device *dev) |
205 | { | 220 | { |
206 | struct radeon_device *rdev = dev->dev_private; | ||
207 | |||
208 | if (rdev->powered_down) | ||
209 | return -EINVAL; | ||
210 | return 0; | 221 | return 0; |
211 | } | 222 | } |
212 | 223 | ||
@@ -277,6 +288,27 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc) | |||
277 | radeon_irq_set(rdev); | 288 | radeon_irq_set(rdev); |
278 | } | 289 | } |
279 | 290 | ||
291 | int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc, | ||
292 | int *max_error, | ||
293 | struct timeval *vblank_time, | ||
294 | unsigned flags) | ||
295 | { | ||
296 | struct drm_crtc *drmcrtc; | ||
297 | struct radeon_device *rdev = dev->dev_private; | ||
298 | |||
299 | if (crtc < 0 || crtc >= dev->num_crtcs) { | ||
300 | DRM_ERROR("Invalid crtc %d\n", crtc); | ||
301 | return -EINVAL; | ||
302 | } | ||
303 | |||
304 | /* Get associated drm_crtc: */ | ||
305 | drmcrtc = &rdev->mode_info.crtcs[crtc]->base; | ||
306 | |||
307 | /* Helper routine in DRM core does all the work: */ | ||
308 | return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error, | ||
309 | vblank_time, flags, | ||
310 | drmcrtc); | ||
311 | } | ||
280 | 312 | ||
281 | /* | 313 | /* |
282 | * IOCTL. | 314 | * IOCTL. |