From patchwork Sat Jan 30 08:54:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang Liu X-Patchwork-Id: 8170211 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7C2769F818 for ; Sat, 30 Jan 2016 09:05:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DF8D20396 for ; Sat, 30 Jan 2016 09:05:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC04020383 for ; Sat, 30 Jan 2016 09:05:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aPRSC-0005N5-8S; Sat, 30 Jan 2016 09:04:24 +0000 Received: from mail-vk0-x232.google.com ([2607:f8b0:400c:c05::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aPRMg-0007zZ-Pd for linux-arm-kernel@lists.infradead.org; Sat, 30 Jan 2016 08:59:03 +0000 Received: by mail-vk0-x232.google.com with SMTP id e185so54100024vkb.1 for ; Sat, 30 Jan 2016 00:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zWBnaVxxkHD/w5s1/MkfYhTSgFmlbDgYiW5e1/cezKE=; b=KlR4NxDJqbnUHht2WoicjRMaNK+7c1hrxIxQepo9+ZtvSO6DH0i71OYUxlw77qcTRK MOQtEpmZFRR5gYbA1ExQkS/hAgIp5FwFe0Eb2vrHdUeZXDpcehAC6tr3BcaBKakcZPsh STimCeXMsQTpYofh+XWmAMsz7mk4+2haHh7mg= 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=zWBnaVxxkHD/w5s1/MkfYhTSgFmlbDgYiW5e1/cezKE=; b=Jx+MbI1oA3ZyhDZfoRiHIQP7lGM48nb/XLQJC0qVEAHPmoSMGDA16C5K7d2MP/4IiH dj3euis+frMB0St7YWjubS7apAmQJ+6WNtsrcuubu6xgrmZm/MCBBATxICcSs4M8/XqY w/ap5V0kNpj35R9GqKlnBoWRmg0r4qVr0h9qH1SDS6Ge9+ljKwZhn075AnP1buhATBI6 d1KOSyhGEiP22cvWqQWlr38ZWfaB5PgGOeVHbC09bQiXLKHat5A+1I7O7sOLkDqWcPD2 i4VRp9thwxwpUlUTiYgReAu2dyNdLTsyDE3yk98ES4HzYuCTmXGjNlVYhJUAodD+zVHK 3FBg== X-Gm-Message-State: AG10YOTmHseyx2vThcRyb7enfvPCLhNojf3AFnbC6fRt36v1S6JDykimCsQ5x51lDp4cS6dZ X-Received: by 10.31.108.83 with SMTP id h80mr6815664vkc.24.1454144301713; Sat, 30 Jan 2016 00:58:21 -0800 (PST) Received: from localhost.localdomain ([113.97.185.10]) by smtp.gmail.com with ESMTPSA id 79sm2742487vkj.21.2016.01.30.00.58.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Jan 2016 00:58:21 -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, emil.l.velikov@gmail.com Subject: [PATCH v3 06/10] drm/hisilicon: Add cma fbdev and hotplug Date: Sat, 30 Jan 2016 16:54:31 +0800 Message-Id: <1454144075-74361-7-git-send-email-xinliang.liu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454144075-74361-1-git-send-email-xinliang.liu@linaro.org> References: <1454144075-74361-1-git-send-email-xinliang.liu@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160130_005843_295174_B2B475A1 X-CRM114-Status: GOOD ( 13.58 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andy.green@linaro.org, xuyiping@hisilicon.com, guodong.xu@linaro.org, linux-doc@vger.kernel.org, Xinliang Liu , w.f@huawei.com, zourongrong@huawei.com, linuxarm@huawei.com, xuwei5@hisilicon.com, kong.kongxinwei@hisilicon.com, bintian.wang@huawei.com, haojian.zhuang@linaro.org, benjamin.gaignard@linaro.org, puck.chen@hisilicon.com, lijianhua@huawei.com, liguozhu@hisilicon.com, sumit.semwal@linaro.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 v3: None v2: - Use CONFIG_DRM_FBDEV_EMULATION instead of CONFIG_DRM_HISI_FBDEV. --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 34 +++++++++++++++++++++++++ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index 723888feb760..d57b9fa0ce3e 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "kirin_drm_drv.h" @@ -32,6 +33,13 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev) { struct kirin_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); dc_ops->cleanup(dev); drm_mode_config_cleanup(dev); @@ -41,8 +49,28 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev) return 0; } +#ifdef CONFIG_DRM_FBDEV_EMULATION +static void kirin_fbdev_output_poll_changed(struct drm_device *dev) +{ + struct kirin_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 kirin_drm_mode_config_funcs = { .fb_create = drm_fb_cma_create, +#ifdef CONFIG_DRM_FBDEV_EMULATION + .output_poll_changed = kirin_fbdev_output_poll_changed, +#endif .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, }; @@ -98,6 +126,12 @@ static int kirin_drm_kms_init(struct drm_device *dev) /* 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/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 5a05ad6a81db..1a07caf8e7f4 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -21,6 +21,9 @@ struct kirin_dc_ops { struct kirin_drm_private { struct drm_crtc *crtc[MAX_CRTC]; +#ifdef CONFIG_DRM_FBDEV_EMULATION + struct drm_fbdev_cma *fbdev; +#endif }; extern const struct kirin_dc_ops ade_dc_ops;