Skip to content

Commit

Permalink
support cma fbdev
Browse files Browse the repository at this point in the history
  • Loading branch information
alik authored and Your Name committed May 16, 2018
1 parent b7f67d6 commit 046e298
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/hisilicon/kirin970-drm.dtsi
@@ -1,6 +1,7 @@
/{
dpe: dpe@E8600000 {
compatible = "hisilicon,kirin970-dpe";
memory-region = <&drm_dma_reserved>;
status = "ok";
dss_version_tag = <0x40>;
// DSS, PERI_CRG, SCTRL, PCTRL, NOC_DSS_Service_Target, PMCTRL, MEDIA_CRG
Expand Down
7 changes: 7 additions & 0 deletions arch/arm64/boot/dts/hisilicon/kirin970-hikey970.dts
Expand Up @@ -73,6 +73,13 @@
no-map;
};

drm_dma_reserved: drm_dma_mem_region {
compatible = "shared-dma-pool";
reg = <0 0x32200000 0 0x8000000>;
alignment = <0x400000>;
no-map;
};

hifi-base {
reg = <0x0 0x8D500000 0x0 0xC00000>;
no-map;
Expand Down
11 changes: 8 additions & 3 deletions arch/arm64/configs/hikey970_defconfig
@@ -1,5 +1,6 @@
CONFIG_POSIX_MQUEUE=y
# CONFIG_FHANDLE is not set
CONFIG_FHANDLE=y
CONFIG_ANDROID_PARANOID_NETWORK=n
CONFIG_AUDIT=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
Expand All @@ -12,7 +13,7 @@ CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=14
CONFIG_LOG_BUF_SHIFT=100
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_PIDS=y
CONFIG_CGROUP_DEVICE=y
Expand Down Expand Up @@ -350,7 +351,11 @@ CONFIG_INPUT_GPIO=y
CONFIG_INPUT_HISI_POWERKEY=y
# CONFIG_SERIO_SERPORT is not set
CONFIG_SERIO_AMBAKMI=y
# CONFIG_VT is not set
CONFIG_VT=y
CONFIG_TTY=y
CONFIG_CONSOLE_TRANSLATIONS=y
CONFIG_VT_CONSOLE=y
CONFIG_VT_CONSOLE_SLEEP=y
# CONFIG_LEGACY_PTYS is not set
# CONFIG_DEVMEM is not set
# CONFIG_DEVKMEM is not set
Expand Down
23 changes: 20 additions & 3 deletions drivers/gpu/drm/hisilicon/kirin9xx/kirin_drm_drv.c
Expand Up @@ -25,9 +25,17 @@
#include <drm/drm_crtc_helper.h>

#include "kirin_drm_drv.h"
#define CMA_POOL
#ifdef CMA_POOL
#include <linux/of_reserved_mem.h>
#endif

#ifdef CONFIG_DRM_FBDEV_EMULATION
#ifdef CMA_POOL
static bool fbdev;
#else
static bool fbdev = true;
#endif
MODULE_PARM_DESC(fbdev, "Enable fbdev compat layer");
module_param(fbdev, bool, 0600);
#endif
Expand Down Expand Up @@ -140,6 +148,8 @@ static int kirin_drm_kms_init(struct drm_device *dev)

if (fbdev)
priv->fbdev = kirin_drm_fbdev_init(dev);
else
priv->fbdev = drm_fbdev_cma_init(dev, 32, 1, 1);

/* init kms poll for handling hpd */
drm_kms_helper_poll_init(dev);
Expand Down Expand Up @@ -344,7 +354,7 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
struct device_node *np = dev->of_node;
struct component_match *match = NULL;
struct device_node *remote;

int ret = 0;
dc_ops = (struct kirin_dc_ops *)of_device_get_match_data(dev);
if (!dc_ops) {
DRM_ERROR("failed to get dt id data\n");
Expand All @@ -359,14 +369,21 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
DRM_INFO("the device remote node is %s\n", remote->name);

component_match_add(dev, &match, compare_of, remote);
#ifdef CMA_POOL
ret = of_reserved_mem_device_init(dev);

if (ret)
DRM_ERROR("cma device init failed!");
#endif
return component_master_add_with_match(dev, &kirin_drm_ops, match);

return 0;
}

static int kirin_drm_platform_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
#ifdef CMA_POOL
of_reserved_mem_device_release(dev);
#endif
component_master_del(&pdev->dev, &kirin_drm_ops);
dc_ops = NULL;
return 0;
Expand Down
6 changes: 5 additions & 1 deletion drivers/gpu/drm/hisilicon/kirin9xx/kirin_drm_drv.h
Expand Up @@ -22,7 +22,7 @@

#define MAX_CRTC 2

//#define CMA_BUFFER_USED
#define CMA_BUFFER_USED
#define to_kirin_fbdev(x) container_of(x, struct kirin_fbdev, fb_helper)

/* display controller init/cleanup ops */
Expand All @@ -35,7 +35,11 @@ struct kirin_dc_ops {

struct kirin_drm_private {
struct drm_fb_helper *fb_helper;
#ifdef CMA_BUFFER_USED
struct drm_fbdev_cma *fbdev;
#else
struct drm_fb_helper *fbdev;
#endif
struct drm_crtc *crtc[MAX_CRTC];
};

Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/hisilicon/kirin9xx/kirin_drm_overlay_utils.c
Expand Up @@ -1534,7 +1534,11 @@ void hisi_fb_pan_display(struct drm_plane *plane)
#endif

bool afbcd = false;
#ifndef CMA_BUFFER_USED
bool mmu_enable = true;
#else
bool mmu_enable = false;
#endif
dss_rect_ltrb_t rect;
u32 bpp;
u32 stride;
Expand Down

0 comments on commit 046e298

Please sign in to comment.