From patchwork Sat Nov 28 10:39:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang Liu X-Patchwork-Id: 57382 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp366053lbb; Sat, 28 Nov 2015 02:41:11 -0800 (PST) X-Received: by 10.98.9.4 with SMTP id e4mr54410733pfd.18.1448707271035; Sat, 28 Nov 2015 02:41:11 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id ro16si22677249pab.99.2015.11.28.02.41.10; Sat, 28 Nov 2015 02:41:11 -0800 (PST) Received-SPF: pass (google.com: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E10BE6E212; Sat, 28 Nov 2015 02:41:09 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-vk0-f52.google.com (mail-vk0-f52.google.com [209.85.213.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id B7B636E212 for ; Sat, 28 Nov 2015 02:41:08 -0800 (PST) Received: by vkay187 with SMTP id y187so79399222vka.3 for ; Sat, 28 Nov 2015 02:41:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V+CNlLm8K1cfyiO+2gRSczI2Mvt02OlCwycLFuse67U=; b=GGGmcOAU5MxqsD4kB+Z4ni2sbUA56lx/e/AekjdEb1s67rbTDJAFwMdwZ8h6PfYxxs xprAORIifcqwX4643SaVaDVpit38BIeOXwVJi5vY/VFphRf3WmPluyPVgViOQh1oOMd2 P7ogAmspG+PxH11ZAtGQng0gl/hTkGpGNEXS501JyYsdCf4MDHlO2n3jkEuWpo8Vygb0 LS4wdjAMNWbQ5j+PDVtCw+UFyOkjDHLRW+aPQQgfSenbcAjLQPyjotyjh7EPWwNN4yuK oTD9Fj1eT7jbCi2URkFBjm5vfmO1jF6rGVBBDYp0QaU+x7/OOUgwDTngrSxfO3tHy38l EwZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V+CNlLm8K1cfyiO+2gRSczI2Mvt02OlCwycLFuse67U=; b=W7BtWwIUmi8Z4giu9bvhKAPNfbyIjRKwEYZTJbvgSt2vmXJHjoo5ajRFpnRzK6ddyh MupIh3wkVEpO7OkyPYanODTpyCg2wCs3HlmeQ6JTfa4UTfaN8zomFpDWwk8v48WEKfGn WJ5T0mMFEqbPCCc+zzQYR8AwYElGhPtB1P8txdte+jhmLRQqwAz+Yqt76xo+2UxhtmPd kb92pkse3sEhu0nr2Yn2XbV5f3fEjHb5Gb6MjU8zyevgDxmqdee342t1NNlQjWH4neSt geSxpNLPUpGcNrYre+6lkmann6RN6od2KElnM/738om3Sh69+21VYekopqbuoVd/QluX DXWg== X-Gm-Message-State: ALoCoQl3/mafA0ingBMSzIgqm7DYU0/swncMnoUsPGeG8yBlKIQolr/08WMciDlsDxWSljQSEVKf X-Received: by 10.31.190.211 with SMTP id o202mr47939802vkf.100.1448707267952; Sat, 28 Nov 2015 02:41:07 -0800 (PST) Received: from localhost.localdomain ([14.153.35.143]) by smtp.gmail.com with ESMTPSA id o135sm19989822vkd.3.2015.11.28.02.40.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 28 Nov 2015 02:41:07 -0800 (PST) From: Xinliang Liu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, daniel@ffwll.ch, robh@kernel.org, daniel@fooishbar.org, architt@codeaurora.org, airlied@linux.ie, corbet@lwn.net, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v2 07/10] drm/hisilicon: Add cma fbdev and hotplug Date: Sat, 28 Nov 2015 18:39:02 +0800 Message-Id: <1448707145-69348-8-git-send-email-xinliang.liu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448707145-69348-1-git-send-email-xinliang.liu@linaro.org> References: <1448707145-69348-1-git-send-email-xinliang.liu@linaro.org> Cc: andy.green@linaro.org, xuyiping@hisilicon.com, linux-doc@vger.kernel.org, w.f@huawei.com, zourongrong@huawei.com, linuxarm@huawei.com, xuwei5@hisilicon.com, bintian.wang@huawei.com, haojian.zhuang@linaro.org, benjamin.gaignard@linaro.org, puck.chen@hisilicon.com, lijianhua@huawei.com, liguozhu@hisilicon.com, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add cma Fbdev, Fbdev is legency and optional, you can enable/disable it by configuring DRM_FBDEV_EMULATION. Add hotplug. Signed-off-by: Xinliang Liu Signed-off-by: Xinwei Kong Signed-off-by: Andy Green --- drivers/gpu/drm/hisilicon/hisi_drm_drv.c | 34 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hisi_drm_drv.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/drivers/gpu/drm/hisilicon/hisi_drm_drv.c b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c index 13f59aa..76eb711 100644 --- a/drivers/gpu/drm/hisilicon/hisi_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "hisi_drm_ade.h" #include "hisi_drm_drv.h" @@ -30,6 +31,13 @@ static int hisi_drm_unload(struct drm_device *dev) { struct hisi_drm_private *priv = dev->dev_private; +#ifdef CONFIG_DRM_FBDEV_EMULATION + if (priv->fbdev) { + drm_fbdev_cma_fini(priv->fbdev); + priv->fbdev = NULL; + } +#endif + drm_kms_helper_poll_fini(dev); drm_vblank_cleanup(dev); drm_mode_config_cleanup(dev); devm_kfree(dev->dev, priv); @@ -38,8 +46,28 @@ static int hisi_drm_unload(struct drm_device *dev) return 0; } +#ifdef CONFIG_DRM_FBDEV_EMULATION +static void hisi_fbdev_output_poll_changed(struct drm_device *dev) +{ + struct hisi_drm_private *priv = dev->dev_private; + + if (priv->fbdev) { + drm_fbdev_cma_hotplug_event(priv->fbdev); + } else { + priv->fbdev = drm_fbdev_cma_init(dev, 32, + dev->mode_config.num_crtc, + dev->mode_config.num_connector); + if (IS_ERR(priv->fbdev)) + priv->fbdev = NULL; + } +} +#endif + static const struct drm_mode_config_funcs hisi_drm_mode_config_funcs = { .fb_create = drm_fb_cma_create, +#ifdef CONFIG_DRM_FBDEV_EMULATION + .output_poll_changed = hisi_fbdev_output_poll_changed, +#endif .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, }; @@ -90,6 +118,12 @@ static int hisi_drm_load(struct drm_device *dev, unsigned long flags) /* reset all the states of crtc/plane/encoder/connector */ drm_mode_config_reset(dev); + /* init kms poll for handling hpd */ + drm_kms_helper_poll_init(dev); + + /* force detection after connectors init */ + (void)drm_helper_hpd_irq_event(dev); + return 0; err_unbind_all: diff --git a/drivers/gpu/drm/hisilicon/hisi_drm_drv.h b/drivers/gpu/drm/hisilicon/hisi_drm_drv.h index a10229e..984121f 100644 --- a/drivers/gpu/drm/hisilicon/hisi_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/hisi_drm_drv.h @@ -11,6 +11,9 @@ #define __HISI_DRM_DRV_H__ struct hisi_drm_private { +#ifdef CONFIG_DRM_FBDEV_EMULATION + struct drm_fbdev_cma *fbdev; +#endif }; #endif /* __HISI_DRM_DRV_H__ */