Skip to content

Commit

Permalink
drm/vc4: Add KMS support for Raspberry Pi.
Browse files Browse the repository at this point in the history
This is enough for fbcon and bringing up X using
xf86-video-modesetting.  It doesn't support the 3D accelerator or
power management yet.

v2: Drop FB_HELPER select thanks to Archit's patches.  Do manual init
    ordering instead of using the .load hook.  Structure registration
    more like tegra's, but still using the typical "component" code.
    Drop no-op hooks for atomic_begin and mode_fixup() now that
    they're optional.  Drop sentinel in Makefile.  Fix minor style
    nits I noticed on another reread.

v3: Use the new bcm2835 clk driver to manage pixel/HSM clocks instead
    of having a fixed video mode.  Use exynos-style component driver
    matching instead of devicetree nodes to list the component driver
    instances.  Rename compatibility strings to say bcm2835, and
    distinguish pv0/1/2.  Clean up some h/vsync code, and add in
    interlaced mode setup.  Fix up probe/bind error paths.  Use
    bitops.h macros for vc4_regs.h

v4: Include i2c.h, allow building under COMPILE_TEST, drop msleep now
    that other bugs have been fixed, add timeouts to cpu_relax()
    loops, rename hpd-gpio to hpd-gpios.

Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
  • Loading branch information
anholt committed Oct 21, 2015
1 parent 1f95732 commit c8b75bc
Show file tree
Hide file tree
Showing 14 changed files with 2,920 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,5 @@ source "drivers/gpu/drm/sti/Kconfig"
source "drivers/gpu/drm/amd/amdkfd/Kconfig"

source "drivers/gpu/drm/imx/Kconfig"

source "drivers/gpu/drm/vc4/Kconfig"
1 change: 1 addition & 0 deletions drivers/gpu/drm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ obj-$(CONFIG_DRM_MGA) += mga/
obj-$(CONFIG_DRM_I810) += i810/
obj-$(CONFIG_DRM_I915) += i915/
obj-$(CONFIG_DRM_MGAG200) += mgag200/
obj-$(CONFIG_DRM_VC4) += vc4/
obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
obj-$(CONFIG_DRM_SIS) += sis/
obj-$(CONFIG_DRM_SAVAGE)+= savage/
Expand Down
13 changes: 13 additions & 0 deletions drivers/gpu/drm/vc4/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
config DRM_VC4
tristate "Broadcom VC4 Graphics"
depends on ARCH_BCM2835 || COMPILE_TEST
depends on DRM
select DRM_KMS_HELPER
select DRM_KMS_CMA_HELPER
help
Choose this option if you have a system that has a Broadcom
VC4 GPU, such as the Raspberry Pi or other BCM2708/BCM2835.

This driver requires that "avoid_warnings=2" be present in
the config.txt for the firmware, to keep it from smashing
our display setup.
17 changes: 17 additions & 0 deletions drivers/gpu/drm/vc4/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ccflags-y := -Iinclude/drm

# Please keep these build lists sorted!

# core driver code
vc4-y := \
vc4_bo.o \
vc4_crtc.o \
vc4_drv.o \
vc4_kms.o \
vc4_hdmi.o \
vc4_hvs.o \
vc4_plane.o

vc4-$(CONFIG_DEBUG_FS) += vc4_debugfs.o

obj-$(CONFIG_DRM_VC4) += vc4.o
52 changes: 52 additions & 0 deletions drivers/gpu/drm/vc4/vc4_bo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright © 2015 Broadcom
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

/* DOC: VC4 GEM BO management support.
*
* The VC4 GPU architecture (both scanout and rendering) has direct
* access to system memory with no MMU in between. To support it, we
* use the GEM CMA helper functions to allocate contiguous ranges of
* physical memory for our BOs.
*/

#include "vc4_drv.h"

struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size)
{
struct drm_gem_cma_object *cma_obj;

cma_obj = drm_gem_cma_create(dev, size);
if (IS_ERR(cma_obj))
return NULL;
else
return to_vc4_bo(&cma_obj->base);
}

int vc4_dumb_create(struct drm_file *file_priv,
struct drm_device *dev,
struct drm_mode_create_dumb *args)
{
int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
struct vc4_bo *bo = NULL;
int ret;

if (args->pitch < min_pitch)
args->pitch = min_pitch;

if (args->size < args->pitch * args->height)
args->size = args->pitch * args->height;

bo = vc4_bo_create(dev, roundup(args->size, PAGE_SIZE));
if (!bo)
return -ENOMEM;

ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
drm_gem_object_unreference_unlocked(&bo->base.base);

return ret;
}
Loading

0 comments on commit c8b75bc

Please sign in to comment.