From patchwork Sat Feb 6 03:24:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang Liu X-Patchwork-Id: 61367 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp321413lbl; Fri, 5 Feb 2016 19:26:07 -0800 (PST) X-Received: by 10.98.64.202 with SMTP id f71mr24922368pfd.113.1454729165824; Fri, 05 Feb 2016 19:26:05 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id vr3si28122343pab.48.2016.02.05.19.26.05; Fri, 05 Feb 2016 19:26:05 -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 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8329720DF; Fri, 5 Feb 2016 19:26:04 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7337F720DF for ; Fri, 5 Feb 2016 19:26:03 -0800 (PST) Received: by mail-pa0-f41.google.com with SMTP id yy13so43708263pab.3 for ; Fri, 05 Feb 2016 19:26:03 -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=g+ecQOPdq6ydAk4L7EQV2/ci0ZyP+6falpBYMtlh/HQ=; b=K/XOrUVbnhTIkgJcD1OAZ0RHmK5zFz48WXIJn8fxdt424HvRnomRwVpjkatnqrhLzy ESAfPa9Cu3ManUZwYSMUUIt+TyyVlar/Ahj/mT3y90KfBpiJr3OmDtMO9dmsfysMEMRF duI6YazEb9po2rVA5TqpXoow6piqK4e8KSamA= 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=g+ecQOPdq6ydAk4L7EQV2/ci0ZyP+6falpBYMtlh/HQ=; b=CoZR2bPRlURxg1sGZChRVlN+2GU7aVVuRxap+SGI+2skjVF9tComPlIGJnLYAs3ZQ5 WCifgFVkPsDcQ4k780+6/dHGq/A+qOgWNiW+VT91PPsz9e/fFaGa6btm/XjQEx0HATor Z+1l+GkT7rhDVRJK2GnfgcU1yr+jYNCBlViaVgT573u9S0xDgC9WUZjpHYFitfZv8yA4 3coM8AfkZrc/ddiKokN6pNHY78nhHjM7EQQHblQV0IJpMuXqei+7IHdZtPDRsDW81i7O frYBeF4KBOOmW2gz7gT1J4DOWrgM935aIo9RIMOGGmtpxY8ICNjgCn2XJwLAanCVT/ZQ v2OQ== X-Gm-Message-State: AG10YOTTK3UF5kdwzHRKDwoLs+ec3mY+1iKBQ7ODvUIvzPzVtFSXrwH+WRIT9Cc5C4Tnb2es X-Received: by 10.66.253.137 with SMTP id aa9mr24741333pad.139.1454729163058; Fri, 05 Feb 2016 19:26:03 -0800 (PST) Received: from localhost.localdomain ([219.134.80.72]) by smtp.gmail.com with ESMTPSA id a21sm27472023pfj.40.2016.02.05.19.25.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Feb 2016 19:26:02 -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 v4 06/11] drm/hisilicon: Add cma fbdev and hotplug Date: Sat, 6 Feb 2016 11:24:53 +0800 Message-Id: <1454729098-79807-7-git-send-email-xinliang.liu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454729098-79807-1-git-send-email-xinliang.liu@linaro.org> References: <1454729098-79807-1-git-send-email-xinliang.liu@linaro.org> Cc: andy.green@linaro.org, xuyiping@hisilicon.com, guodong.xu@linaro.org, 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, 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. v4: None. v3: None. v2: - Use CONFIG_DRM_FBDEV_EMULATION instead of CONFIG_DRM_HISI_FBDEV. Signed-off-by: Xinliang Liu --- 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;