Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54931
b: refs/heads/master
c: 09aaf26
h: refs/heads/master
i:
  54929: 3c6ca7e
  54927: 62ba6e2
v: v3
  • Loading branch information
Antonino A. Daplas authored and Linus Torvalds committed May 8, 2007
1 parent 6f771ec commit b5aa0f0
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3f9b0880e4a96b02bc0131451f2f6231cd90bd94
refs/heads/master: 09aaf268eb1d22eee690d26a913f660e2081597f
5 changes: 5 additions & 0 deletions trunk/drivers/video/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ config FB_SYS_IMAGEBLIT
blitting. This is used by drivers that don't provide their own
(accelerated) version and the framebuffer is in system RAM.

config FB_SYS_FOPS
tristate
depends on FB
default n

config FB_DEFERRED_IO
bool
depends on FB
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/video/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ obj-$(CONFIG_FB_CFB_IMAGEBLIT) += cfbimgblt.o
obj-$(CONFIG_FB_SYS_FILLRECT) += sysfillrect.o
obj-$(CONFIG_FB_SYS_COPYAREA) += syscopyarea.o
obj-$(CONFIG_FB_SYS_IMAGEBLIT) += sysimgblt.o
obj-$(CONFIG_FB_SYS_FOPS) += fb_sys_fops.o
obj-$(CONFIG_FB_SVGALIB) += svgalib.o
obj-$(CONFIG_FB_MACMODES) += macmodes.o
obj-$(CONFIG_FB_DDC) += fb_ddc.o
Expand Down
104 changes: 104 additions & 0 deletions trunk/drivers/video/fb_sys_fops.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* linux/drivers/video/fb_sys_read.c - Generic file operations where
* framebuffer is in system RAM
*
* Copyright (C) 2007 Antonino Daplas <adaplas@pol.net>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*
*/
#include <linux/fb.h>
#include <linux/module.h>
#include <asm/uaccess.h>

ssize_t fb_sys_read(struct fb_info *info, char __user *buf, size_t count,
loff_t *ppos)
{
unsigned long p = *ppos;
void *src;
int err = 0;
unsigned long total_size;

if (info->state != FBINFO_STATE_RUNNING)
return -EPERM;

total_size = info->screen_size;

if (total_size == 0)
total_size = info->fix.smem_len;

if (p >= total_size)
return 0;

if (count >= total_size)
count = total_size;

if (count + p > total_size)
count = total_size - p;

src = (void __force *)(info->screen_base + p);

if (info->fbops->fb_sync)
info->fbops->fb_sync(info);

if (copy_to_user(buf, src, count))
err = -EFAULT;

if (!err)
*ppos += count;

return (err) ? err : count;
}
EXPORT_SYMBOL_GPL(fb_sys_read);

ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
size_t count, loff_t *ppos)
{
unsigned long p = *ppos;
void *dst;
int err = 0;
unsigned long total_size;

if (info->state != FBINFO_STATE_RUNNING)
return -EPERM;

total_size = info->screen_size;

if (total_size == 0)
total_size = info->fix.smem_len;

if (p > total_size)
return -EFBIG;

if (count > total_size) {
err = -EFBIG;
count = total_size;
}

if (count + p > total_size) {
if (!err)
err = -ENOSPC;

count = total_size - p;
}

dst = (void __force *) (info->screen_base + p);

if (info->fbops->fb_sync)
info->fbops->fb_sync(info);

if (copy_from_user(dst, buf, count))
err = -EFAULT;

if (!err)
*ppos += count;

return (err) ? err : count;
}
EXPORT_SYMBOL_GPL(fb_sys_write);

MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
MODULE_DESCRIPTION("Generic file read (fb in system RAM)");
MODULE_LICENSE("GPL");
4 changes: 4 additions & 0 deletions trunk/include/linux/fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,10 @@ extern void cfb_imageblit(struct fb_info *info, const struct fb_image *image);
extern void sys_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
extern void sys_copyarea(struct fb_info *info, const struct fb_copyarea *area);
extern void sys_imageblit(struct fb_info *info, const struct fb_image *image);
extern ssize_t fb_sys_read(struct fb_info *info, char __user *buf,
size_t count, loff_t *ppos);
extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
size_t count, loff_t *ppos);

/* drivers/video/fbmem.c */
extern int register_framebuffer(struct fb_info *fb_info);
Expand Down

0 comments on commit b5aa0f0

Please sign in to comment.