add getfb ioctl

main
Dave Airlie 2007-04-12 08:45:40 +10:00
parent 9d7160c43a
commit a81558d8b3
6 changed files with 61 additions and 52 deletions

View File

@ -215,53 +215,35 @@ int drmModeRmFB(int fd, uint32_t bufferId)
return ioctl(fd, DRM_IOCTL_MODE_RMFB, bufferId);
}
drmModeFrameBufferPtr drmModeGetFB(int fd, uint32_t buf)
{
struct drm_mode_fb_cmd info;
drmModeFrameBufferPtr r;
info.buffer_id = buf;
if (ioctl(fd, DRM_IOCTL_MODE_GETFB, &info))
return NULL;
if (!(r = drmMalloc(sizeof(*r))))
return NULL;
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;
}
#if 0
int drmModeForceProbe(int fd, uint32_t outputId)
{
/* TODO impl/keep? */
}
drmModeFrameBufferPtr drmModeGetFrameBuffer(int fd, uint32_t buf)
{
// struct drm_mode_fb_cmd info;
drmModeFrameBufferPtr r;
// if (ioctl(fd, DRM_IOCTL_MODE_GETFRAMEBUFFER, &info))
return 0;
if (!(r = drmMalloc(sizeof(*r))))
return 0;
/* TODO change to new code
r->minWidth = info.minWidth;
r->maxWidth = info.maxWidth;
r->minHeight = info.minHeight;
r->maxHeight = info.maxHeight;*/
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)
{
// return ioctl(fd, DRM_IOCTL_MODE_DESFRAMEBUFFER, bufferId);
}
#endif
/*
* Crtc function.

View File

@ -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.
*/

View File

@ -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;
}

View File

@ -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__ */

View File

@ -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 )

View File

@ -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)
/*@}*/
/**