Skip to content

Commit c8b75bc

Browse files
committed
drm/vc4: Add KMS support for Raspberry Pi.
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 <[email protected]> Acked-by: Daniel Vetter <[email protected]>
1 parent 1f95732 commit c8b75bc

14 files changed

+2920
-0
lines changed

drivers/gpu/drm/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,5 @@ source "drivers/gpu/drm/sti/Kconfig"
264264
source "drivers/gpu/drm/amd/amdkfd/Kconfig"
265265

266266
source "drivers/gpu/drm/imx/Kconfig"
267+
268+
source "drivers/gpu/drm/vc4/Kconfig"

drivers/gpu/drm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ obj-$(CONFIG_DRM_MGA) += mga/
4242
obj-$(CONFIG_DRM_I810) += i810/
4343
obj-$(CONFIG_DRM_I915) += i915/
4444
obj-$(CONFIG_DRM_MGAG200) += mgag200/
45+
obj-$(CONFIG_DRM_VC4) += vc4/
4546
obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
4647
obj-$(CONFIG_DRM_SIS) += sis/
4748
obj-$(CONFIG_DRM_SAVAGE)+= savage/

drivers/gpu/drm/vc4/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
config DRM_VC4
2+
tristate "Broadcom VC4 Graphics"
3+
depends on ARCH_BCM2835 || COMPILE_TEST
4+
depends on DRM
5+
select DRM_KMS_HELPER
6+
select DRM_KMS_CMA_HELPER
7+
help
8+
Choose this option if you have a system that has a Broadcom
9+
VC4 GPU, such as the Raspberry Pi or other BCM2708/BCM2835.
10+
11+
This driver requires that "avoid_warnings=2" be present in
12+
the config.txt for the firmware, to keep it from smashing
13+
our display setup.

drivers/gpu/drm/vc4/Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ccflags-y := -Iinclude/drm
2+
3+
# Please keep these build lists sorted!
4+
5+
# core driver code
6+
vc4-y := \
7+
vc4_bo.o \
8+
vc4_crtc.o \
9+
vc4_drv.o \
10+
vc4_kms.o \
11+
vc4_hdmi.o \
12+
vc4_hvs.o \
13+
vc4_plane.o
14+
15+
vc4-$(CONFIG_DEBUG_FS) += vc4_debugfs.o
16+
17+
obj-$(CONFIG_DRM_VC4) += vc4.o

drivers/gpu/drm/vc4/vc4_bo.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright © 2015 Broadcom
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
/* DOC: VC4 GEM BO management support.
10+
*
11+
* The VC4 GPU architecture (both scanout and rendering) has direct
12+
* access to system memory with no MMU in between. To support it, we
13+
* use the GEM CMA helper functions to allocate contiguous ranges of
14+
* physical memory for our BOs.
15+
*/
16+
17+
#include "vc4_drv.h"
18+
19+
struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size)
20+
{
21+
struct drm_gem_cma_object *cma_obj;
22+
23+
cma_obj = drm_gem_cma_create(dev, size);
24+
if (IS_ERR(cma_obj))
25+
return NULL;
26+
else
27+
return to_vc4_bo(&cma_obj->base);
28+
}
29+
30+
int vc4_dumb_create(struct drm_file *file_priv,
31+
struct drm_device *dev,
32+
struct drm_mode_create_dumb *args)
33+
{
34+
int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
35+
struct vc4_bo *bo = NULL;
36+
int ret;
37+
38+
if (args->pitch < min_pitch)
39+
args->pitch = min_pitch;
40+
41+
if (args->size < args->pitch * args->height)
42+
args->size = args->pitch * args->height;
43+
44+
bo = vc4_bo_create(dev, roundup(args->size, PAGE_SIZE));
45+
if (!bo)
46+
return -ENOMEM;
47+
48+
ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
49+
drm_gem_object_unreference_unlocked(&bo->base.base);
50+
51+
return ret;
52+
}

0 commit comments

Comments
 (0)