summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
authorDavid Airlie <airlied@asimov.stargames.com.au>2007-04-11 13:19:30 +1000
committerDave Airlie <airlied@airlied2.(none)>2007-04-11 13:26:21 +1000
commit44be9c9d5950d3b2ba4d5527189abec8dac0686f (patch)
tree1ec6a732243fa19bd6a468f75049a3c276c79c1d /libdrm
parent3e994a56be1bfc633e49434c9e4a3e3262070248 (diff)
add an fb count + id get to the get resources code path
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/xf86drmMode.c25
-rw-r--r--libdrm/xf86drmMode.h15
2 files changed, 19 insertions, 21 deletions
diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c
index c0444e65..7f0252ce 100644
--- a/libdrm/xf86drmMode.c
+++ b/libdrm/xf86drmMode.c
@@ -144,14 +144,13 @@ drmModeResPtr drmModeGetResources(int fd)
int i;
drmModeResPtr r = 0;
- res.count_crtcs = 0;
- res.count_outputs = 0;
- res.count_modes = 0;
- res.modes = 0;
+ memset(&res, 0, sizeof(struct drm_mode_card_res));
if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
return 0;
+ if (res.count_fbs)
+ res.fb_id = drmMalloc(res.count_fbs*sizeof(uint32_t));
if (res.count_crtcs)
res.crtc_id = drmMalloc(res.count_crtcs*sizeof(uint32_t));
if (res.count_outputs)
@@ -159,8 +158,10 @@ drmModeResPtr drmModeGetResources(int fd)
if (res.count_modes)
res.modes = drmMalloc(res.count_modes*sizeof(*res.modes));
- if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
+ if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res)) {
+ r = NULL;
goto err_allocs;
+ }
/*
* return
@@ -170,27 +171,23 @@ drmModeResPtr drmModeGetResources(int fd)
if (!(r = drmMalloc(sizeof(*r))))
return 0;
- r->frameBufferId = res.fb_id;
+ r->count_fbs = res.count_fbs;
r->count_crtcs = res.count_crtcs;
r->count_outputs = res.count_outputs;
r->count_modes = res.count_modes;
/* TODO we realy should test if these allocs fails. */
+ r->fbs = drmAllocCpy(res.fb_id, res.count_fbs, sizeof(uint32_t));
r->crtcs = drmAllocCpy(res.crtc_id, res.count_crtcs, sizeof(uint32_t));
r->outputs = drmAllocCpy(res.output_id, res.count_outputs, sizeof(uint32_t));
r->modes = drmAllocCpy(res.modes, res.count_modes, sizeof(struct drm_mode_modeinfo));
- drmFree(res.crtc_id);
- drmFree(res.output_id);
- drmFree(res.modes);
-
- return r;
-
err_allocs:
+ drmFree(res.fb_id);
drmFree(res.crtc_id);
drmFree(res.output_id);
drmFree(res.modes);
- return 0;
+ return r;
}
int drmModeAddFB(int fd, uint32_t width, uint32_t height,
@@ -214,7 +211,7 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height,
int drmModeRmFB(int fd, uint32_t bufferId)
{
- return ioctl(fd, DRM_IOCTL_MODE_RMFB, bufferId);
+ return ioctl(fd, DRM_IOCTL_MODE_RMFB, bufferId);
}
#if 0
diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h
index 594eb487..4ca9e407 100644
--- a/libdrm/xf86drmMode.h
+++ b/libdrm/xf86drmMode.h
@@ -62,7 +62,8 @@ typedef struct _drmModeGammaTriple {
typedef struct _drmModeRes {
- uint32_t frameBufferId;
+ int count_fbs;
+ uint32_t *fbs;
int count_crtcs;
uint32_t *crtcs;
@@ -77,10 +78,10 @@ typedef struct _drmModeRes {
typedef struct _drmModeFrameBuffer {
- uint32_t width;
- uint32_t height;
- uint32_t pitch;
- uint8_t bpp;
+ uint32_t width;
+ uint32_t height;
+ uint32_t pitch;
+ uint8_t bpp;
} drmModeFrameBuffer, *drmModeFrameBufferPtr;
@@ -208,14 +209,14 @@ extern int drmModeForceProbe(int fd, uint32_t outputId);
/**
* Retrive information about framebuffer bufferId
*/
-extern drmModeFrameBufferPtr drmModeGetFramebuffer(int fd,
+extern drmModeFrameBufferPtr drmModeGetFB(int fd,
uint32_t bufferId);
/**
* Creates a new framebuffer with an buffer object as its scanout buffer.
*/
extern int drmModeAddFB(int fd, uint32_t width, uint32_t height,
- uint8_t bpp, uint32_t pitch, drmBO *bo, uint32_t *buf_id);
+ uint8_t bpp, uint32_t pitch, drmBO *bo, uint32_t *buf_id);
/**
* Destroies the given framebuffer.
*/