summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2007-04-12 08:45:40 +1000
committerDave Airlie <airlied@linux.ie>2007-04-12 08:45:40 +1000
commita81558d8b3ee17fbf46e32b10732e22fcd997858 (patch)
tree95ea4879c442e38a316d3aa92fd821b8e545d2cc
parent9d7160c43a7475b9d2ab06c5c353acb9456efa12 (diff)
add getfb ioctl
-rw-r--r--libdrm/xf86drmMode.c52
-rw-r--r--libdrm/xf86drmMode.h15
-rw-r--r--linux-core/drm_crtc.c30
-rw-r--r--linux-core/drm_crtc.h2
-rw-r--r--linux-core/drm_drv.c1
-rw-r--r--shared-core/drm.h1
6 files changed, 55 insertions, 46 deletions
diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c
index 04fb07dc..6070ec6f 100644
--- a/libdrm/xf86drmMode.c
+++ b/libdrm/xf86drmMode.c
@@ -215,51 +215,33 @@ int drmModeRmFB(int fd, uint32_t bufferId)
return ioctl(fd, DRM_IOCTL_MODE_RMFB, bufferId);
}
-#if 0
-int drmModeForceProbe(int fd, uint32_t outputId)
-{
- /* TODO impl/keep? */
-}
-
-drmModeFrameBufferPtr drmModeGetFrameBuffer(int fd, uint32_t buf)
+drmModeFrameBufferPtr drmModeGetFB(int fd, uint32_t buf)
{
-// struct drm_mode_fb_cmd info;
+ struct drm_mode_fb_cmd info;
drmModeFrameBufferPtr r;
- // if (ioctl(fd, DRM_IOCTL_MODE_GETFRAMEBUFFER, &info))
- return 0;
+ info.buffer_id = buf;
+
+ if (ioctl(fd, DRM_IOCTL_MODE_GETFB, &info))
+ return NULL;
if (!(r = drmMalloc(sizeof(*r))))
- return 0;
+ return NULL;
- /* TODO change to new code
- r->minWidth = info.minWidth;
- r->maxWidth = info.maxWidth;
- r->minHeight = info.minHeight;
- r->maxHeight = info.maxHeight;*/
+ r->buffer_id = info.buffer_id;
+ r->width = info.width;
+ r->height = info.height;
+ r->pitch = info.pitch;
+ r->bpp = info.bpp;
+ r->handle = info.handle;
+ r->depth = info.depth;
return r;
}
-
-uint32_t drmModeNewFrameBuffer(int fd, uint32_t width, uint32_t height,
- uint8_t bpp, uint32_t pitch, drmBO *bo)
-{
- drm_mode_fb_cmd_t f;
-
- f.handle = bo->handle;
- f.width = width;
- f.height = height;
- f.pitch = pitch;
-
- // if (ioctl(fd, DRM_IOCTL_MODE_NEWFRAMEBUFFER, &f))
- return 0;
-
- return f.bufferId;
-}
-
-int drmModeDesFrameBuffer(int fd, uint32_t bufferId)
+#if 0
+int drmModeForceProbe(int fd, uint32_t outputId)
{
- // return ioctl(fd, DRM_IOCTL_MODE_DESFRAMEBUFFER, bufferId);
+ /* TODO impl/keep? */
}
#endif
diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h
index cdc82f7d..6a566c4d 100644
--- a/libdrm/xf86drmMode.h
+++ b/libdrm/xf86drmMode.h
@@ -76,14 +76,7 @@ typedef struct _drmModeRes {
} drmModeRes, *drmModeResPtr;
-typedef struct _drmModeFrameBuffer {
-
- uint32_t width;
- uint32_t height;
- uint32_t pitch;
- uint8_t bpp;
-
-} drmModeFrameBuffer, *drmModeFrameBufferPtr;
+typedef struct drm_mode_fb_cmd drmModeFrameBuffer, *drmModeFrameBufferPtr;
typedef struct _drmModeCrtc {
@@ -209,14 +202,14 @@ extern int drmModeForceProbe(int fd, uint32_t outputId);
/**
* Retrive information about framebuffer bufferId
*/
-extern drmModeFrameBufferPtr drmModeGetFB(int fd,
- uint32_t bufferId);
+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 depth,
- 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.
*/
diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c
index b349527d..d1f3c077 100644
--- a/linux-core/drm_crtc.c
+++ b/linux-core/drm_crtc.c
@@ -1058,3 +1058,33 @@ int drm_mode_rmfb(struct inode *inode, struct file *filp,
return 0;
}
+int drm_mode_getfb(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->head->dev;
+ struct drm_mode_fb_cmd __user *argp = (void __user *)arg;
+ struct drm_mode_fb_cmd r;
+ struct drm_framebuffer *fb;
+
+ if (copy_from_user(&r, argp, sizeof(r)))
+ return -EFAULT;
+
+ fb = idr_find(&dev->mode_config.crtc_idr, r.buffer_id);
+ if (!fb || (r.buffer_id != fb->id)) {
+ DRM_ERROR("invalid framebuffer id\n");
+ return -EINVAL;
+ }
+
+ r.height = fb->height;
+ r.width = fb->width;
+ r.depth = fb->depth;
+ r.bpp = fb->bits_per_pixel;
+ r.handle = fb->bo->base.hash.key;
+ r.pitch = fb->pitch;
+
+ if (copy_to_user(argp, &r, sizeof(r)))
+ return -EFAULT;
+
+ return 0;
+}
diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h
index 54c508c5..c02dcedc 100644
--- a/linux-core/drm_crtc.h
+++ b/linux-core/drm_crtc.h
@@ -474,5 +474,7 @@ extern int drm_mode_addfb(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int drm_mode_rmfb(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
+extern int drm_mode_getfb(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
#endif /* __DRM_CRTC_H__ */
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index b43af328..b7a7aded 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -129,6 +129,7 @@ static drm_ioctl_desc_t drm_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_MODE_SETCRTC)] = {drm_mode_setcrtc, DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB)] = {drm_mode_addfb, DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_MODE_RMFB)] = {drm_mode_rmfb, DRM_MASTER|DRM_ROOT_ONLY},
+ [DRM_IOCTL_NR(DRM_IOCTL_MODE_GETFB)] = {drm_mode_getfb, DRM_MASTER|DRM_ROOT_ONLY},
};
#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
diff --git a/shared-core/drm.h b/shared-core/drm.h
index 698f851b..b5b0aa52 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -1051,6 +1051,7 @@ struct drm_mode_fb_cmd {
#define DRM_IOCTL_MODE_SETCRTC DRM_IOWR(0xA3, struct drm_mode_crtc)
#define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xA4, struct drm_mode_fb_cmd)
#define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xA5, unsigned int)
+#define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xA6, struct drm_mode_fb_cmd)
/*@}*/
/**