summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJamie Nicol <jamie.nicol@arm.com>2014-08-22 17:08:47 +0100
committerHuang, Tao <huangtao@rock-chips.com>2017-06-21 15:13:01 +0800
commit1f6daacebe0358bdfb78a35186cbb308ca117b8a (patch)
treeabb04a58da8870aa83aff74c37e8e85ffbc1adfb /drivers
parentf917a54ff7b441685d4a19601993f174c08ebf11 (diff)
FROMLIST: fb: add dma-buf support
Add support for the dma-buf exporter role to the frame buffer API. The importer role isn't meaningful for frame buffer devices, as the frame buffer device model doesn't allow using externally allocated memory. taken from an RFC on the linaro-mm-sig mailing list: http://lists.linaro.org/pipermail/linaro-mm-sig/2012-June/002167.html Fixes by Mark Yao: add FBIOGET_DMABUF to compat_ioctl. Change-Id: I39c9bbdd6b88c6d5ba7524abfc5b560dceb4633e Signed-off-by: Guillaume Tucker <guillaume.tucker@arm.com> Signed-off-by: Mark Yao <mark.yao@rock-chips.com> (am from https://patchwork.linuxtv.org/patch/12980)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/fbdev/core/fbmem.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 0705d8883ede..bf348a6e6517 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -28,6 +28,7 @@
#include <linux/seq_file.h>
#include <linux/console.h>
#include <linux/kmod.h>
+#include <linux/dma-buf.h>
#include <linux/err.h>
#include <linux/device.h>
#include <linux/efi.h>
@@ -1084,6 +1085,24 @@ fb_blank(struct fb_info *info, int blank)
}
EXPORT_SYMBOL(fb_blank);
+int fb_get_dmabuf(struct fb_info *info, int flags)
+{
+#ifdef CONFIG_DMA_SHARED_BUFFER
+ struct dma_buf *dmabuf;
+
+ if (!info->fbops->fb_dmabuf_export)
+ return -ENOTTY;
+
+ dmabuf = info->fbops->fb_dmabuf_export(info);
+ if (IS_ERR(dmabuf))
+ return PTR_ERR(dmabuf);
+
+ return dma_buf_fd(dmabuf, flags);
+#else
+ return -ENOTTY;
+#endif
+}
+
static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
unsigned long arg)
{
@@ -1094,6 +1113,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
struct fb_cmap cmap_from;
struct fb_cmap_user cmap;
struct fb_event event;
+ struct fb_dmabuf_export dmaexp;
void __user *argp = (void __user *)arg;
long ret = 0;
@@ -1211,6 +1231,21 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
unlock_fb_info(info);
console_unlock();
break;
+ case FBIOGET_DMABUF:
+ if (copy_from_user(&dmaexp, argp, sizeof(dmaexp)))
+ return -EFAULT;
+
+ if (!lock_fb_info(info))
+ return -ENODEV;
+ ret = fb_get_dmabuf(info, dmaexp.flags);
+ unlock_fb_info(info);
+
+ if (ret < 0)
+ return ret;
+ dmaexp.fd = ret;
+
+ ret = copy_to_user(argp, &dmaexp, sizeof(dmaexp)) ? -EFAULT : 0;
+ break;
default:
if (!lock_fb_info(info))
return -ENODEV;
@@ -1365,6 +1400,7 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd,
case FBIOPAN_DISPLAY:
case FBIOGET_CON2FBMAP:
case FBIOPUT_CON2FBMAP:
+ case FBIOGET_DMABUF:
arg = (unsigned long) compat_ptr(arg);
case FBIOBLANK:
ret = do_fb_ioctl(info, cmd, arg);