bcm2708_fb: Add framebuffer driver

Signed-off-by: popcornmix <popcornmix@gmail.com>

bcm2708_fb : Implement blanking support using the mailbox property interface

bcm2708_fb: Add pan and vsync controls

bcm2708_fb: DMA acceleration for fb_copyarea

Based on http://www.raspberrypi.org/phpBB3/viewtopic.php?p=62425#p62425
Also used Simon's dmaer_master module as a reference for tweaking DMA
settings for better performance.

For now busylooping only. IRQ support might be added later.
With non-overclocked Raspberry Pi, the performance is ~360 MB/s
for simple copy or ~260 MB/s for two-pass copy (used when dragging
windows to the right).

In the case of using DMA channel 0, the performance improves
to ~440 MB/s.

For comparison, VFP optimized CPU copy can only do ~114 MB/s in
the same conditions (hindered by reading uncached source buffer).

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>

bcm2708_fb: report number of dma copies

Add a counter (exported via debugfs) reporting the
number of dma copies that the framebuffer driver
has done, in order to help evaluate different
optimization strategies.

Signed-off-by: Luke Diamand <luked@broadcom.com>

bcm2708_fb: use IRQ for DMA copies

The copyarea ioctl() uses DMA to speed things along. This
was busy-waiting for completion. This change supports using
an interrupt instead for larger transfers. For small
transfers, busy-waiting is still likely to be faster.

Signed-off-by: Luke Diamand <luke@diamand.org>

bcm2708: Make ioctl logging quieter

video: fbdev: bcm2708_fb: Don't panic on error

No need to panic the kernel if the video driver fails.
Just print a message and return an error.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

fbdev: bcm2708_fb: Add ARCH_BCM2835 support

Add Device Tree support.
Pass the device to dma_alloc_coherent() in order to get the
correct bus address on ARCH_BCM2835.
Use the new DMA legacy API header file.
Including <mach/platform.h> is not necessary.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

BCM270x_DT: Add bcm2708-fb device

Add bcm2708-fb to Device Tree and don't add the
platform device when booting in DT mode.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

Cleanup of bcm2708_fb file to kernel coding standards

Some minor change to function - remove a use of
in_atomic, plus replacing various debug messages
that manually specify the function name with
("%s",.__func__)

Signed-off-by: James Hughes <james.hughes@raspberrypi.org>

video: bcm2708_fb: Try allocating on the ARM and passing to VPU

Currently the VPU allocates the contiguous buffer for the
framebuffer.
Try an alternate path first where we use dma_alloc_coherent
and pass the buffer to the VPU. Should the VPU firmware not
support that path, then free the buffer and revert to the
old behaviour of using the VPU allocation.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>

Pulled in the multi frame buffer support from the Pi3 repo

fbdev: add FBIOCOPYAREA ioctl

Based on the patch authored by Ali Gholami Rudi at
    https://lkml.org/lkml/2009/7/13/153

Provide an ioctl for userspace applications, but only if this operation
is hardware accelerated (otherwide it does not make any sense).

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>

bcm2708_fb: Add ioctl for reading gpu memory through dma

video: bcm2708_fb: Add compat_ioctl support.

When using a 64 bit kernel with 32 bit userspace we need
compat ioctl handling for FBIODMACOPY as one of the
parameters is a pointer.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>

video: fbdev: bcm2708_fb: Use common compat header

The definition of compat_ptr is now common for most platforms, but
requires the inclusion of <linux/compat.h>.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>

video: bcm2708_fb: Disable FB if no displays found

If the firmware hasn't detected a display, the driver would assume
one display was available, but because it had failed to retrieve the
display size it would try to allocate a zero-sized buffer.

Avoid the allocation failure by bailing out early if no display is
found.

See: https://github.com/raspberrypi/linux/issues/3598

Signed-off-by: Phil Elwell <phil@raspberrypi.com>

bcm2708_fb: Fix a build warning

Signed-off-by: Phil Elwell <phil@raspberrypi.com>

bcm2708_fb: Explicitly initialise the IOMEM ops

Prior to [1], an fb_ops member of 0 was intepreted as a request for a
default value. This saves source code but requires special handling by
the framework, slowing down all accesses for no runtime benefit.

Use the new __FB_DEFAULT_ macros to explicitly select default handlers
in the bcm2708_fb driver. Also remove the pointless wrappers around
cfb_fillrect and cfb_imageblit - call them directly.

Link: https://forums.raspberrypi.com/viewtopic.php?p=2286016#p2286016
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
[1] 8813e86f6d ("fbdev: Remove default file-I/O implementations")
This commit is contained in:
popcornmix
2015-06-17 17:06:34 +01:00
committed by Dom Cobley
parent 9994124639
commit 1e8d6a09d9
6 changed files with 2204 additions and 1602 deletions

View File

@@ -61,6 +61,19 @@ config FB_MACMODES
tristate
depends on FB
config FB_BCM2708
tristate "BCM2708 framebuffer support"
depends on FB && RASPBERRYPI_FIRMWARE
select FB_DEVICE
select FB_IOMEM_HELPERS
help
This framebuffer device driver is for the BCM2708 framebuffer.
If you want to compile this as a module (=code which can be
inserted into and removed from the running kernel), say M
here and read <file:Documentation/kbuild/modules.txt>. The module
will be called bcm2708_fb.
config FB_GRVGA
tristate "Aeroflex Gaisler framebuffer support"
depends on FB && SPARC

View File

@@ -12,6 +12,7 @@ obj-$(CONFIG_FB_SBUS) += sbuslib.o
obj-$(CONFIG_FB_WMT_GE_ROPS) += wmt_ge_rops.o
# Hardware specific drivers go first
obj-$(CONFIG_FB_BCM2708) += bcm2708_fb.o
obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o
obj-$(CONFIG_FB_ARC) += arcfb.o
obj-$(CONFIG_FB_CLPS711X) += clps711x-fb.o

File diff suppressed because it is too large Load Diff

View File

@@ -59,6 +59,30 @@ static ssize_t fb_write(struct file *file, const char __user *buf, size_t count,
return info->fbops->fb_write(info, buf, count, ppos);
}
static int fb_copyarea_user(struct fb_info *info,
struct fb_copyarea *copy)
{
int ret = 0;
lock_fb_info(info);
if (copy->dx >= info->var.xres ||
copy->sx >= info->var.xres ||
copy->width > info->var.xres ||
copy->dy >= info->var.yres ||
copy->sy >= info->var.yres ||
copy->height > info->var.yres ||
copy->dx + copy->width > info->var.xres ||
copy->sx + copy->width > info->var.xres ||
copy->dy + copy->height > info->var.yres ||
copy->sy + copy->height > info->var.yres) {
ret = -EINVAL;
goto out;
}
info->fbops->fb_copyarea(info, copy);
out:
unlock_fb_info(info);
return ret;
}
static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
unsigned long arg)
{
@@ -67,6 +91,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
struct fb_fix_screeninfo fix;
struct fb_cmap cmap_from;
struct fb_cmap_user cmap;
struct fb_copyarea copy;
void __user *argp = (void __user *)arg;
long ret = 0;
@@ -148,6 +173,15 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
unlock_fb_info(info);
console_unlock();
break;
case FBIOCOPYAREA:
if (info->flags & FBINFO_HWACCEL_COPYAREA) {
/* only provide this ioctl if it is accelerated */
if (copy_from_user(&copy, argp, sizeof(copy)))
return -EFAULT;
ret = fb_copyarea_user(info, &copy);
break;
}
fallthrough;
default:
lock_fb_info(info);
fb = info->fbops;
@@ -287,6 +321,7 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd,
case FBIOPAN_DISPLAY:
case FBIOGET_CON2FBMAP:
case FBIOPUT_CON2FBMAP:
case FBIOCOPYAREA:
arg = (unsigned long) compat_ptr(arg);
fallthrough;
case FBIOBLANK:

File diff suppressed because it is too large Load Diff

View File

@@ -36,6 +36,12 @@
#define FBIOPUT_MODEINFO 0x4617
#define FBIOGET_DISPINFO 0x4618
#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
/*
* HACK: use 'z' in order not to clash with any other ioctl numbers which might
* be concurrently added to the mainline kernel
*/
#define FBIOCOPYAREA _IOW('z', 0x21, struct fb_copyarea)
#define FBIODMACOPY _IOW('z', 0x22, struct fb_dmacopy)
#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
#define FB_TYPE_PLANES 1 /* Non interleaved planes */
@@ -342,6 +348,12 @@ struct fb_copyarea {
__u32 sy;
};
struct fb_dmacopy {
void *dst;
__u32 src;
__u32 length;
};
struct fb_fillrect {
__u32 dx; /* screen-relative */
__u32 dy;