aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson2010-07-01 16:38:54 -0500
committerChris Wilson2010-07-01 16:51:33 -0500
commitb803918f3f77c62edf22e78cb2095be399753423 (patch)
tree7b7e5de8b1c71dd8155e78bb9f2fe1da0e37c797 /xf86drmMode.c
parentc570b4b97b8ff71da9294aaf8242ed665f0c09c3 (diff)
downloadexternal-libgbm-b803918f3f77c62edf22e78cb2095be399753423.tar.gz
external-libgbm-b803918f3f77c62edf22e78cb2095be399753423.tar.xz
external-libgbm-b803918f3f77c62edf22e78cb2095be399753423.zip
drm mode: Return -errno on drmIoctl() failure
The high layers expect to receive a status code on error (on the pessimistic assumption that the errno value will have been overwritten by the time the failure is propagated all the way up), so convert xf86drmMode.c to return -errno on an ioctl error and be consistent with the rest of the libdrm API. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index f330e6f2..ecb1fd5e 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -52,6 +52,12 @@
52#define U642VOID(x) ((void *)(unsigned long)(x)) 52#define U642VOID(x) ((void *)(unsigned long)(x))
53#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) 53#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
54 54
55static inline DRM_IOCTL(int fd, int cmd, void *arg)
56{
57 int ret = drmIoctl(fd, cmd, arg);
58 return ret < 0 ? -errno : ret;
59}
60
55/* 61/*
56 * Util functions 62 * Util functions
57 */ 63 */
@@ -242,7 +248,7 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
242 f.depth = depth; 248 f.depth = depth;
243 f.handle = bo_handle; 249 f.handle = bo_handle;
244 250
245 if ((ret = drmIoctl(fd, DRM_IOCTL_MODE_ADDFB, &f))) 251 if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB, &f)))
246 return ret; 252 return ret;
247 253
248 *buf_id = f.fb_id; 254 *buf_id = f.fb_id;
@@ -251,7 +257,7 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
251 257
252int drmModeRmFB(int fd, uint32_t bufferId) 258int drmModeRmFB(int fd, uint32_t bufferId)
253{ 259{
254 return drmIoctl(fd, DRM_IOCTL_MODE_RMFB, &bufferId); 260 return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
255 261
256 262
257} 263}
@@ -289,7 +295,7 @@ int drmModeDirtyFB(int fd, uint32_t bufferId,
289 dirty.clips_ptr = VOID2U64(clips); 295 dirty.clips_ptr = VOID2U64(clips);
290 dirty.num_clips = num_clips; 296 dirty.num_clips = num_clips;
291 297
292 return drmIoctl(fd, DRM_IOCTL_MODE_DIRTYFB, &dirty); 298 return DRM_IOCTL(fd, DRM_IOCTL_MODE_DIRTYFB, &dirty);
293} 299}
294 300
295 301
@@ -344,7 +350,7 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
344 } else 350 } else
345 crtc.mode_valid = 0; 351 crtc.mode_valid = 0;
346 352
347 return drmIoctl(fd, DRM_IOCTL_MODE_SETCRTC, &crtc); 353 return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETCRTC, &crtc);
348} 354}
349 355
350/* 356/*
@@ -361,7 +367,7 @@ int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width
361 arg.height = height; 367 arg.height = height;
362 arg.handle = bo_handle; 368 arg.handle = bo_handle;
363 369
364 return drmIoctl(fd, DRM_IOCTL_MODE_CURSOR, &arg); 370 return DRM_IOCTL(fd, DRM_IOCTL_MODE_CURSOR, &arg);
365} 371}
366 372
367int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y) 373int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y)
@@ -373,7 +379,7 @@ int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y)
373 arg.x = x; 379 arg.x = x;
374 arg.y = y; 380 arg.y = y;
375 381
376 return drmIoctl(fd, DRM_IOCTL_MODE_CURSOR, &arg); 382 return DRM_IOCTL(fd, DRM_IOCTL_MODE_CURSOR, &arg);
377} 383}
378 384
379/* 385/*
@@ -510,7 +516,7 @@ int drmModeAttachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_inf
510 memcpy(&res.mode, mode_info, sizeof(struct drm_mode_modeinfo)); 516 memcpy(&res.mode, mode_info, sizeof(struct drm_mode_modeinfo));
511 res.connector_id = connector_id; 517 res.connector_id = connector_id;
512 518
513 return drmIoctl(fd, DRM_IOCTL_MODE_ATTACHMODE, &res); 519 return DRM_IOCTL(fd, DRM_IOCTL_MODE_ATTACHMODE, &res);
514} 520}
515 521
516int drmModeDetachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_info) 522int drmModeDetachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_info)
@@ -520,7 +526,7 @@ int drmModeDetachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_inf
520 memcpy(&res.mode, mode_info, sizeof(struct drm_mode_modeinfo)); 526 memcpy(&res.mode, mode_info, sizeof(struct drm_mode_modeinfo));
521 res.connector_id = connector_id; 527 res.connector_id = connector_id;
522 528
523 return drmIoctl(fd, DRM_IOCTL_MODE_DETACHMODE, &res); 529 return DRM_IOCTL(fd, DRM_IOCTL_MODE_DETACHMODE, &res);
524} 530}
525 531
526 532
@@ -637,16 +643,12 @@ int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property
637 uint64_t value) 643 uint64_t value)
638{ 644{
639 struct drm_mode_connector_set_property osp; 645 struct drm_mode_connector_set_property osp;
640 int ret;
641 646
642 osp.connector_id = connector_id; 647 osp.connector_id = connector_id;
643 osp.prop_id = property_id; 648 osp.prop_id = property_id;
644 osp.value = value; 649 osp.value = value;
645 650
646 if ((ret = drmIoctl(fd, DRM_IOCTL_MODE_SETPROPERTY, &osp))) 651 return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETPROPERTY, &osp);
647 return ret;
648
649 return 0;
650} 652}
651 653
652/* 654/*
@@ -715,7 +717,6 @@ int drmCheckModesettingSupported(const char *busid)
715int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size, 717int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
716 uint16_t *red, uint16_t *green, uint16_t *blue) 718 uint16_t *red, uint16_t *green, uint16_t *blue)
717{ 719{
718 int ret;
719 struct drm_mode_crtc_lut l; 720 struct drm_mode_crtc_lut l;
720 721
721 l.crtc_id = crtc_id; 722 l.crtc_id = crtc_id;
@@ -724,16 +725,12 @@ int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
724 l.green = VOID2U64(green); 725 l.green = VOID2U64(green);
725 l.blue = VOID2U64(blue); 726 l.blue = VOID2U64(blue);
726 727
727 if ((ret = drmIoctl(fd, DRM_IOCTL_MODE_GETGAMMA, &l))) 728 return DRM_IOCTL(fd, DRM_IOCTL_MODE_GETGAMMA, &l);
728 return ret;
729
730 return 0;
731} 729}
732 730
733int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, 731int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
734 uint16_t *red, uint16_t *green, uint16_t *blue) 732 uint16_t *red, uint16_t *green, uint16_t *blue)
735{ 733{
736 int ret;
737 struct drm_mode_crtc_lut l; 734 struct drm_mode_crtc_lut l;
738 735
739 l.crtc_id = crtc_id; 736 l.crtc_id = crtc_id;
@@ -742,10 +739,7 @@ int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
742 l.green = VOID2U64(green); 739 l.green = VOID2U64(green);
743 l.blue = VOID2U64(blue); 740 l.blue = VOID2U64(blue);
744 741
745 if ((ret = drmIoctl(fd, DRM_IOCTL_MODE_SETGAMMA, &l))) 742 return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETGAMMA, &l);
746 return ret;
747
748 return 0;
749} 743}
750 744
751int drmHandleEvent(int fd, drmEventContextPtr evctx) 745int drmHandleEvent(int fd, drmEventContextPtr evctx)
@@ -810,5 +804,5 @@ int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
810 flip.flags = flags; 804 flip.flags = flags;
811 flip.reserved = 0; 805 flip.reserved = 0;
812 806
813 return drmIoctl(fd, DRM_IOCTL_MODE_PAGE_FLIP, &flip); 807 return DRM_IOCTL(fd, DRM_IOCTL_MODE_PAGE_FLIP, &flip);
814} 808}