#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>
}
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)
{
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;
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;
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);
/* called at KDB enter and leave time to prepare the console */
int (*fb_debug_enter)(struct fb_info *info);
int (*fb_debug_leave)(struct fb_info *info);
+
+ /* Export the frame buffer as a dmabuf object */
+ struct dma_buf *(*fb_dmabuf_export)(struct fb_info *info);
};
#ifdef CONFIG_FB_TILEBLITTING
#define FBIOPUT_MODEINFO 0x4617
#define FBIOGET_DISPINFO 0x4618
#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
+#define FBIOGET_DMABUF _IOR('F', 0x21, struct fb_dmabuf_export)
#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
#define FB_TYPE_PLANES 1 /* Non interleaved planes */
#define FB_BACKLIGHT_MAX 0xFF
#endif
+struct fb_dmabuf_export {
+ __u32 fd;
+ __u32 flags;
+};
#endif /* _UAPI_LINUX_FB_H */