From patchwork Thu Mar 30 08:36:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CCEBDC761AF for ; Thu, 30 Mar 2023 08:36:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2CE9D10ED38; Thu, 30 Mar 2023 08:36:11 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A43F10ED33 for ; Thu, 30 Mar 2023 08:36:10 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E034C1FE3F; Thu, 30 Mar 2023 08:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680165368; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8LJhYdSttK0TcaPL/eKycs9QEmV9BoB+aTOFq1uIB8U=; b=HOZKS6QgaKLvRegakVC+lQ6QRwllpFcPjaAWMzpr9Ckt8zkcbay78A3HY4m86dfrFlN0mE pmUnq29EPBdr6Kr1dWquljsO3V23rCmoeuWZtux0tHhSNttGFD6SNSt5M0U/qD7DU+TWQE YcucFqfkzryTlTwtaoBaoIoM3F0D2AU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680165368; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8LJhYdSttK0TcaPL/eKycs9QEmV9BoB+aTOFq1uIB8U=; b=EgJbgSuQhh4bJ5nqkh/yY1vpaMu6Sc8ML29CLmCvEypvXI88xvGc2mSgNn07wHJQkR6pZ9 1IrPC0+N7KLnskDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B0EC11390D; Thu, 30 Mar 2023 08:36:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AIVQKvhJJWQHHAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 08:36:08 +0000 From: Thomas Zimmermann To: thierry.reding@gmail.com, jonathanh@nvidia.com, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 1/7] drm/tegra: Include Date: Thu, 30 Mar 2023 10:36:01 +0200 Message-Id: <20230330083607.12834-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330083607.12834-1-tzimmermann@suse.de> References: <20230330083607.12834-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Include to get the contained declarations. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Sui Jingfeng --- drivers/gpu/drm/tegra/output.c | 2 ++ drivers/gpu/drm/tegra/rgb.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c index a8925dcd7edd..d31c87f48da0 100644 --- a/drivers/gpu/drm/tegra/output.c +++ b/drivers/gpu/drm/tegra/output.c @@ -4,6 +4,8 @@ * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. */ +#include + #include #include #include diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c index ff8fce36d2aa..3f060282cd8d 100644 --- a/drivers/gpu/drm/tegra/rgb.c +++ b/drivers/gpu/drm/tegra/rgb.c @@ -5,6 +5,7 @@ */ #include +#include #include #include From patchwork Thu Mar 30 08:36:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95DCCC77B6D for ; Thu, 30 Mar 2023 08:36:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ADEC510ED33; Thu, 30 Mar 2023 08:36:19 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9FCF110ED2F for ; Thu, 30 Mar 2023 08:36:10 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2A00B21A7A; Thu, 30 Mar 2023 08:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680165369; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nk+nWx0KuXQrQdvYfALbavBeBHQWRBm/i1IoakkJR4Q=; b=PXxBjEoMcwcZsmfNzzwkpRm/A3jNRQHanWsQSAHWnXCkMJa8d0AF2uOPYzS11xgfe1dm8+ FHCGSejDQsGXRpPHbm2Khy/cEVRxfdKpF/vfYXfXGrK3HQ9sP3E5izFJYkXSr4H5cXeSsB KPq8VQJ/BNf/VxeVifcEGWfYgBPzAcQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680165369; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nk+nWx0KuXQrQdvYfALbavBeBHQWRBm/i1IoakkJR4Q=; b=Z3x6Y2nWqE7BC+lcELM6IJKxxXZI3CLYvaH7vDwnMjwxYpZeNMmhvtSmgNEsECdVf3iWbK gM7CUi5iu1JEeRCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E2424138FF; Thu, 30 Mar 2023 08:36:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MENlNvhJJWQHHAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 08:36:08 +0000 From: Thomas Zimmermann To: thierry.reding@gmail.com, jonathanh@nvidia.com, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 2/7] drm/tegra: Include Date: Thu, 30 Mar 2023 10:36:02 +0200 Message-Id: <20230330083607.12834-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330083607.12834-1-tzimmermann@suse.de> References: <20230330083607.12834-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Include to get the contained declarations. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Sui Jingfeng #include #include From patchwork Thu Mar 30 08:36:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7313C761AF for ; Thu, 30 Mar 2023 08:36:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9FA6B10ED39; Thu, 30 Mar 2023 08:36:23 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by gabe.freedesktop.org (Postfix) with ESMTPS id DC59110ED33 for ; Thu, 30 Mar 2023 08:36:10 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5D2E01FE40; Thu, 30 Mar 2023 08:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680165369; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/EU6h6Dsiu+n+4OWK8LFmV2yPf0DZhExmmr6TalEWRk=; b=lv3ArszGRKZGO7wx6myTMuf463ZoH3mpH/xnRRe6T0QJ5KgIitsNUZG29t3mnt9kJoaonO lRhpCDzPbIK/wEpBvg0DF1V6c9YKjuLtrNjZj4F+MrzhcnQ8aHVZtUvaJsXaD4yiyTCgAU uVvvD5Na4k/bmDfR/+zuqKSdsWjXHgI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680165369; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/EU6h6Dsiu+n+4OWK8LFmV2yPf0DZhExmmr6TalEWRk=; b=XdpmRVM1h5Bm5KuU8IWvwNruwE93bQi+I9M9wMnLTuQeeJ2AjUYOU/ubYccBk62bA1oxaB 1yhZU9jf1jRMZaDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2CFBC1390D; Thu, 30 Mar 2023 08:36:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ENH7CflJJWQHHAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 08:36:09 +0000 From: Thomas Zimmermann To: thierry.reding@gmail.com, jonathanh@nvidia.com, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 3/7] drm/tegra: Removed fb from struct tegra_fbdev Date: Thu, 30 Mar 2023 10:36:03 +0200 Message-Id: <20230330083607.12834-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330083607.12834-1-tzimmermann@suse.de> References: <20230330083607.12834-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Fbdev's struct fb_helper stores a pointer to the framebuffer. Remove struct tegra_fbdev.fb, which contains the same value. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/tegra/drm.h | 1 - drivers/gpu/drm/tegra/fb.c | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index 845e60f144c7..8f8e5cda78da 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -32,7 +32,6 @@ struct reset_control; #ifdef CONFIG_DRM_FBDEV_EMULATION struct tegra_fbdev { struct drm_fb_helper base; - struct drm_framebuffer *fb; }; #endif diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index bfebe2786d61..1ee4771b77d3 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -217,7 +217,6 @@ static const struct fb_ops tegra_fb_ops = { static int tegra_fbdev_probe(struct drm_fb_helper *helper, struct drm_fb_helper_surface_size *sizes) { - struct tegra_fbdev *fbdev = to_tegra_fbdev(helper); struct tegra_drm *tegra = helper->dev->dev_private; struct drm_device *drm = helper->dev; struct drm_mode_fb_cmd2 cmd = { 0 }; @@ -252,16 +251,15 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper, return PTR_ERR(info); } - fbdev->fb = tegra_fb_alloc(drm, &cmd, &bo, 1); - if (IS_ERR(fbdev->fb)) { - err = PTR_ERR(fbdev->fb); + fb = tegra_fb_alloc(drm, &cmd, &bo, 1); + if (IS_ERR(fb)) { + err = PTR_ERR(fb); dev_err(drm->dev, "failed to allocate DRM framebuffer: %d\n", err); drm_gem_object_put(&bo->gem); - return PTR_ERR(fbdev->fb); + return PTR_ERR(fb); } - fb = fbdev->fb; helper->fb = fb; helper->info = info; @@ -349,10 +347,13 @@ static int tegra_fbdev_init(struct tegra_fbdev *fbdev, static void tegra_fbdev_exit(struct tegra_fbdev *fbdev) { - drm_fb_helper_unregister_info(&fbdev->base); + struct drm_fb_helper *helper = &fbdev->base; + struct drm_framebuffer *fb = helper->fb; - if (fbdev->fb) { - struct tegra_bo *bo = tegra_fb_get_plane(fbdev->fb, 0); + drm_fb_helper_unregister_info(helper); + + if (fb) { + struct tegra_bo *bo = tegra_fb_get_plane(fb, 0); /* Undo the special mapping we made in fbdev probe. */ if (bo && bo->pages) { @@ -360,10 +361,10 @@ static void tegra_fbdev_exit(struct tegra_fbdev *fbdev) bo->vaddr = NULL; } - drm_framebuffer_remove(fbdev->fb); + drm_framebuffer_remove(fb); } - drm_fb_helper_fini(&fbdev->base); + drm_fb_helper_fini(helper); tegra_fbdev_free(fbdev); } #endif From patchwork Thu Mar 30 08:36:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 538C0C761AF for ; Thu, 30 Mar 2023 08:36:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCC8E10ED51; Thu, 30 Mar 2023 08:36:25 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0FD9710ED2F for ; Thu, 30 Mar 2023 08:36:11 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 971411FE7F; Thu, 30 Mar 2023 08:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680165369; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DFEjP46DiBZ4uxKnGZYyXU+dBULAFBIzXv2KmBEmlBE=; b=pZpPPXQI0Sv+dSpk6IBOfWs2qirQ894hN94r+VSIXSRcsXXtF8uvJNdIXZjp84JQ1cha86 IkV2Js0olEoMyFDry/+e33mNOb+89MrnWAIRkmaj4BPSRMURkHjJ78N0yWxLjL1q6WbtSg wSJ5P1jynl1YwCSNe6/0hVQLhBky8iU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680165369; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DFEjP46DiBZ4uxKnGZYyXU+dBULAFBIzXv2KmBEmlBE=; b=chW7mPD7J6EY+Rx7LxI9K64nfgqyndEc6x0+uAZGOPOgZ9y6/MzPgqItWdT8/akWW470m/ HmImQ3UZfQZibjBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 61930138FF; Thu, 30 Mar 2023 08:36:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OIv9FvlJJWQHHAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 08:36:09 +0000 From: Thomas Zimmermann To: thierry.reding@gmail.com, jonathanh@nvidia.com, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 4/7] drm/tegra: Remove struct tegra_fbdev Date: Thu, 30 Mar 2023 10:36:04 +0200 Message-Id: <20230330083607.12834-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330083607.12834-1-tzimmermann@suse.de> References: <20230330083607.12834-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Remove struct tegra_fbdev, which is an empty wrapper around struct drm_fb_helper. Use the latter directly. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/tegra/drm.h | 10 ------- drivers/gpu/drm/tegra/fb.c | 59 ++++++++++++++----------------------- 2 files changed, 22 insertions(+), 47 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index 8f8e5cda78da..593a60b03189 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -29,12 +29,6 @@ struct reset_control; -#ifdef CONFIG_DRM_FBDEV_EMULATION -struct tegra_fbdev { - struct drm_fb_helper base; -}; -#endif - struct tegra_drm { struct drm_device *drm; @@ -52,10 +46,6 @@ struct tegra_drm { struct mutex clients_lock; struct list_head clients; -#ifdef CONFIG_DRM_FBDEV_EMULATION - struct tegra_fbdev *fbdev; -#endif - unsigned int hmask, vmask; unsigned int pitch_align; unsigned int num_crtcs; diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index 1ee4771b77d3..12eb260d9f51 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -17,13 +17,6 @@ #include "drm.h" #include "gem.h" -#ifdef CONFIG_DRM_FBDEV_EMULATION -static inline struct tegra_fbdev *to_tegra_fbdev(struct drm_fb_helper *helper) -{ - return container_of(helper, struct tegra_fbdev, base); -} -#endif - struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer, unsigned int index) { @@ -296,42 +289,42 @@ static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = { .fb_probe = tegra_fbdev_probe, }; -static struct tegra_fbdev *tegra_fbdev_create(struct drm_device *drm) +static struct drm_fb_helper *tegra_fbdev_create(struct drm_device *drm) { - struct tegra_fbdev *fbdev; + struct drm_fb_helper *helper; - fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); - if (!fbdev) { + helper = kzalloc(sizeof(*helper), GFP_KERNEL); + if (!helper) { dev_err(drm->dev, "failed to allocate DRM fbdev\n"); return ERR_PTR(-ENOMEM); } - drm_fb_helper_prepare(drm, &fbdev->base, 32, &tegra_fb_helper_funcs); + drm_fb_helper_prepare(drm, helper, 32, &tegra_fb_helper_funcs); - return fbdev; + return helper; } -static void tegra_fbdev_free(struct tegra_fbdev *fbdev) +static void tegra_fbdev_free(struct drm_fb_helper *helper) { - drm_fb_helper_unprepare(&fbdev->base); - kfree(fbdev); + drm_fb_helper_unprepare(helper); + kfree(helper); } -static int tegra_fbdev_init(struct tegra_fbdev *fbdev, +static int tegra_fbdev_init(struct drm_fb_helper *helper, unsigned int num_crtc, unsigned int max_connectors) { - struct drm_device *drm = fbdev->base.dev; + struct drm_device *drm = helper->dev; int err; - err = drm_fb_helper_init(drm, &fbdev->base); + err = drm_fb_helper_init(drm, helper); if (err < 0) { dev_err(drm->dev, "failed to initialize DRM FB helper: %d\n", err); return err; } - err = drm_fb_helper_initial_config(&fbdev->base); + err = drm_fb_helper_initial_config(helper); if (err < 0) { dev_err(drm->dev, "failed to set initial configuration: %d\n", err); @@ -341,13 +334,12 @@ static int tegra_fbdev_init(struct tegra_fbdev *fbdev, return 0; fini: - drm_fb_helper_fini(&fbdev->base); + drm_fb_helper_fini(helper); return err; } -static void tegra_fbdev_exit(struct tegra_fbdev *fbdev) +static void tegra_fbdev_exit(struct drm_fb_helper *helper) { - struct drm_fb_helper *helper = &fbdev->base; struct drm_framebuffer *fb = helper->fb; drm_fb_helper_unregister_info(helper); @@ -365,18 +357,16 @@ static void tegra_fbdev_exit(struct tegra_fbdev *fbdev) } drm_fb_helper_fini(helper); - tegra_fbdev_free(fbdev); + tegra_fbdev_free(helper); } #endif int tegra_drm_fb_prepare(struct drm_device *drm) { #ifdef CONFIG_DRM_FBDEV_EMULATION - struct tegra_drm *tegra = drm->dev_private; - - tegra->fbdev = tegra_fbdev_create(drm); - if (IS_ERR(tegra->fbdev)) - return PTR_ERR(tegra->fbdev); + drm->fb_helper = tegra_fbdev_create(drm); + if (IS_ERR(drm->fb_helper)) + return PTR_ERR(drm->fb_helper); #endif return 0; @@ -385,19 +375,16 @@ int tegra_drm_fb_prepare(struct drm_device *drm) void tegra_drm_fb_free(struct drm_device *drm) { #ifdef CONFIG_DRM_FBDEV_EMULATION - struct tegra_drm *tegra = drm->dev_private; - - tegra_fbdev_free(tegra->fbdev); + tegra_fbdev_free(drm->fb_helper); #endif } int tegra_drm_fb_init(struct drm_device *drm) { #ifdef CONFIG_DRM_FBDEV_EMULATION - struct tegra_drm *tegra = drm->dev_private; int err; - err = tegra_fbdev_init(tegra->fbdev, drm->mode_config.num_crtc, + err = tegra_fbdev_init(drm->fb_helper, drm->mode_config.num_crtc, drm->mode_config.num_connector); if (err < 0) return err; @@ -409,8 +396,6 @@ int tegra_drm_fb_init(struct drm_device *drm) void tegra_drm_fb_exit(struct drm_device *drm) { #ifdef CONFIG_DRM_FBDEV_EMULATION - struct tegra_drm *tegra = drm->dev_private; - - tegra_fbdev_exit(tegra->fbdev); + tegra_fbdev_exit(drm->fb_helper); #endif } From patchwork Thu Mar 30 08:36:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193592 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AE20C77B61 for ; Thu, 30 Mar 2023 08:36:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B466A10ED58; Thu, 30 Mar 2023 08:36:26 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41C8610ED33 for ; Thu, 30 Mar 2023 08:36:11 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D21841FEA0; Thu, 30 Mar 2023 08:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680165369; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RAK5DFara2lzZ9XnGKIu36712/QL2/u0vZ2Y5jUr2h8=; b=z4s1k77AFCmPNAIkKsv47/Q8PGPdFSGT9d9CIDAodGf9DzkftO2979YteP4nbzGbcpTJn7 AUEctZeL8ef9fTn+QR3lmp7Dy/g5nDgzfearfe/T1dqY489rpt4G2wXXtwY99v5sNJYxo0 T7FsJ8i7uxlb4IRiL3rI/ROZrTcfSs8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680165369; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RAK5DFara2lzZ9XnGKIu36712/QL2/u0vZ2Y5jUr2h8=; b=5bBoNMP0OTJlPkJfl52foIDBZMIOy2yg4k1zf3h5XEmLbYRJuR1qqSdNu0WT7SiPEBqVW8 FCw0RQz0DMhasBCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 99DA61390D; Thu, 30 Mar 2023 08:36:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eEq5JPlJJWQHHAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 08:36:09 +0000 From: Thomas Zimmermann To: thierry.reding@gmail.com, jonathanh@nvidia.com, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 5/7] drm/tegra: Hide fbdev support behind config option Date: Thu, 30 Mar 2023 10:36:05 +0200 Message-Id: <20230330083607.12834-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330083607.12834-1-tzimmermann@suse.de> References: <20230330083607.12834-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Only build tegra's fbdev emulation if CONFIG_DRM_FBDEV_EMULATION has been enabled. As part of this change, move the code into its own source file. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/tegra/Makefile | 2 + drivers/gpu/drm/tegra/drm.h | 20 +++ drivers/gpu/drm/tegra/fb.c | 228 +-------------------------------- drivers/gpu/drm/tegra/fbdev.c | 226 ++++++++++++++++++++++++++++++++ 4 files changed, 252 insertions(+), 224 deletions(-) create mode 100644 drivers/gpu/drm/tegra/fbdev.c diff --git a/drivers/gpu/drm/tegra/Makefile b/drivers/gpu/drm/tegra/Makefile index bb0d2c144b55..6fc4b504e786 100644 --- a/drivers/gpu/drm/tegra/Makefile +++ b/drivers/gpu/drm/tegra/Makefile @@ -29,4 +29,6 @@ tegra-drm-y := \ tegra-drm-y += trace.o +tegra-drm-$(CONFIG_DRM_FBDEV_EMULATION) += fbdev.o + obj-$(CONFIG_DRM_TEGRA) += tegra-drm.o diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index 593a60b03189..576f03b8434e 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -185,13 +185,33 @@ struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer, bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer); int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer, struct tegra_bo_tiling *tiling); +struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, + const struct drm_mode_fb_cmd2 *mode_cmd, + struct tegra_bo **planes, + unsigned int num_planes); struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, struct drm_file *file, const struct drm_mode_fb_cmd2 *cmd); + +#ifdef CONFIG_DRM_FBDEV_EMULATION int tegra_drm_fb_prepare(struct drm_device *drm); void tegra_drm_fb_free(struct drm_device *drm); int tegra_drm_fb_init(struct drm_device *drm); void tegra_drm_fb_exit(struct drm_device *drm); +#else +static inline int tegra_drm_fb_prepare(struct drm_device *drm) +{ + return 0; +} +static inline void tegra_drm_fb_free(struct drm_device *drm) +{ } +static inline int tegra_drm_fb_init(struct drm_device *drm) +{ + return 0; +} +static inline void tegra_drm_fb_exit(struct drm_device *drm) +{ } +#endif extern struct platform_driver tegra_display_hub_driver; extern struct platform_driver tegra_dc_driver; diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index 12eb260d9f51..a719af1dc9a5 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -101,10 +101,10 @@ static const struct drm_framebuffer_funcs tegra_fb_funcs = { .create_handle = drm_gem_fb_create_handle, }; -static struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, - const struct drm_mode_fb_cmd2 *mode_cmd, - struct tegra_bo **planes, - unsigned int num_planes) +struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, + const struct drm_mode_fb_cmd2 *mode_cmd, + struct tegra_bo **planes, + unsigned int num_planes) { struct drm_framebuffer *fb; unsigned int i; @@ -179,223 +179,3 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, return ERR_PTR(err); } - -#ifdef CONFIG_DRM_FBDEV_EMULATION -static int tegra_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) -{ - struct drm_fb_helper *helper = info->par; - struct tegra_bo *bo; - int err; - - bo = tegra_fb_get_plane(helper->fb, 0); - - err = drm_gem_mmap_obj(&bo->gem, bo->gem.size, vma); - if (err < 0) - return err; - - return __tegra_gem_mmap(&bo->gem, vma); -} - -static const struct fb_ops tegra_fb_ops = { - .owner = THIS_MODULE, - DRM_FB_HELPER_DEFAULT_OPS, - .fb_read = drm_fb_helper_sys_read, - .fb_write = drm_fb_helper_sys_write, - .fb_fillrect = drm_fb_helper_sys_fillrect, - .fb_copyarea = drm_fb_helper_sys_copyarea, - .fb_imageblit = drm_fb_helper_sys_imageblit, - .fb_mmap = tegra_fb_mmap, -}; - -static int tegra_fbdev_probe(struct drm_fb_helper *helper, - struct drm_fb_helper_surface_size *sizes) -{ - struct tegra_drm *tegra = helper->dev->dev_private; - struct drm_device *drm = helper->dev; - struct drm_mode_fb_cmd2 cmd = { 0 }; - unsigned int bytes_per_pixel; - struct drm_framebuffer *fb; - unsigned long offset; - struct fb_info *info; - struct tegra_bo *bo; - size_t size; - int err; - - bytes_per_pixel = DIV_ROUND_UP(sizes->surface_bpp, 8); - - cmd.width = sizes->surface_width; - cmd.height = sizes->surface_height; - cmd.pitches[0] = round_up(sizes->surface_width * bytes_per_pixel, - tegra->pitch_align); - - cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, - sizes->surface_depth); - - size = cmd.pitches[0] * cmd.height; - - bo = tegra_bo_create(drm, size, 0); - if (IS_ERR(bo)) - return PTR_ERR(bo); - - info = drm_fb_helper_alloc_info(helper); - if (IS_ERR(info)) { - dev_err(drm->dev, "failed to allocate framebuffer info\n"); - drm_gem_object_put(&bo->gem); - return PTR_ERR(info); - } - - fb = tegra_fb_alloc(drm, &cmd, &bo, 1); - if (IS_ERR(fb)) { - err = PTR_ERR(fb); - dev_err(drm->dev, "failed to allocate DRM framebuffer: %d\n", - err); - drm_gem_object_put(&bo->gem); - return PTR_ERR(fb); - } - - helper->fb = fb; - helper->info = info; - - info->fbops = &tegra_fb_ops; - - drm_fb_helper_fill_info(info, helper, sizes); - - offset = info->var.xoffset * bytes_per_pixel + - info->var.yoffset * fb->pitches[0]; - - if (bo->pages) { - bo->vaddr = vmap(bo->pages, bo->num_pages, VM_MAP, - pgprot_writecombine(PAGE_KERNEL)); - if (!bo->vaddr) { - dev_err(drm->dev, "failed to vmap() framebuffer\n"); - err = -ENOMEM; - goto destroy; - } - } - - info->screen_base = (void __iomem *)bo->vaddr + offset; - info->screen_size = size; - info->fix.smem_start = (unsigned long)(bo->iova + offset); - info->fix.smem_len = size; - - return 0; - -destroy: - drm_framebuffer_remove(fb); - return err; -} - -static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = { - .fb_probe = tegra_fbdev_probe, -}; - -static struct drm_fb_helper *tegra_fbdev_create(struct drm_device *drm) -{ - struct drm_fb_helper *helper; - - helper = kzalloc(sizeof(*helper), GFP_KERNEL); - if (!helper) { - dev_err(drm->dev, "failed to allocate DRM fbdev\n"); - return ERR_PTR(-ENOMEM); - } - - drm_fb_helper_prepare(drm, helper, 32, &tegra_fb_helper_funcs); - - return helper; -} - -static void tegra_fbdev_free(struct drm_fb_helper *helper) -{ - drm_fb_helper_unprepare(helper); - kfree(helper); -} - -static int tegra_fbdev_init(struct drm_fb_helper *helper, - unsigned int num_crtc, - unsigned int max_connectors) -{ - struct drm_device *drm = helper->dev; - int err; - - err = drm_fb_helper_init(drm, helper); - if (err < 0) { - dev_err(drm->dev, "failed to initialize DRM FB helper: %d\n", - err); - return err; - } - - err = drm_fb_helper_initial_config(helper); - if (err < 0) { - dev_err(drm->dev, "failed to set initial configuration: %d\n", - err); - goto fini; - } - - return 0; - -fini: - drm_fb_helper_fini(helper); - return err; -} - -static void tegra_fbdev_exit(struct drm_fb_helper *helper) -{ - struct drm_framebuffer *fb = helper->fb; - - drm_fb_helper_unregister_info(helper); - - if (fb) { - struct tegra_bo *bo = tegra_fb_get_plane(fb, 0); - - /* Undo the special mapping we made in fbdev probe. */ - if (bo && bo->pages) { - vunmap(bo->vaddr); - bo->vaddr = NULL; - } - - drm_framebuffer_remove(fb); - } - - drm_fb_helper_fini(helper); - tegra_fbdev_free(helper); -} -#endif - -int tegra_drm_fb_prepare(struct drm_device *drm) -{ -#ifdef CONFIG_DRM_FBDEV_EMULATION - drm->fb_helper = tegra_fbdev_create(drm); - if (IS_ERR(drm->fb_helper)) - return PTR_ERR(drm->fb_helper); -#endif - - return 0; -} - -void tegra_drm_fb_free(struct drm_device *drm) -{ -#ifdef CONFIG_DRM_FBDEV_EMULATION - tegra_fbdev_free(drm->fb_helper); -#endif -} - -int tegra_drm_fb_init(struct drm_device *drm) -{ -#ifdef CONFIG_DRM_FBDEV_EMULATION - int err; - - err = tegra_fbdev_init(drm->fb_helper, drm->mode_config.num_crtc, - drm->mode_config.num_connector); - if (err < 0) - return err; -#endif - - return 0; -} - -void tegra_drm_fb_exit(struct drm_device *drm) -{ -#ifdef CONFIG_DRM_FBDEV_EMULATION - tegra_fbdev_exit(drm->fb_helper); -#endif -} diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c new file mode 100644 index 000000000000..2400d42f82e4 --- /dev/null +++ b/drivers/gpu/drm/tegra/fbdev.c @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2012-2013 Avionic Design GmbH + * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. + * + * Based on the KMS/FB DMA helpers + * Copyright (C) 2012 Analog Devices Inc. + */ + +#include + +#include +#include +#include +#include + +#include "drm.h" +#include "gem.h" + +static int tegra_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) +{ + struct drm_fb_helper *helper = info->par; + struct tegra_bo *bo; + int err; + + bo = tegra_fb_get_plane(helper->fb, 0); + + err = drm_gem_mmap_obj(&bo->gem, bo->gem.size, vma); + if (err < 0) + return err; + + return __tegra_gem_mmap(&bo->gem, vma); +} + +static const struct fb_ops tegra_fb_ops = { + .owner = THIS_MODULE, + DRM_FB_HELPER_DEFAULT_OPS, + .fb_read = drm_fb_helper_sys_read, + .fb_write = drm_fb_helper_sys_write, + .fb_fillrect = drm_fb_helper_sys_fillrect, + .fb_copyarea = drm_fb_helper_sys_copyarea, + .fb_imageblit = drm_fb_helper_sys_imageblit, + .fb_mmap = tegra_fb_mmap, +}; + +static int tegra_fbdev_probe(struct drm_fb_helper *helper, + struct drm_fb_helper_surface_size *sizes) +{ + struct tegra_drm *tegra = helper->dev->dev_private; + struct drm_device *drm = helper->dev; + struct drm_mode_fb_cmd2 cmd = { 0 }; + unsigned int bytes_per_pixel; + struct drm_framebuffer *fb; + unsigned long offset; + struct fb_info *info; + struct tegra_bo *bo; + size_t size; + int err; + + bytes_per_pixel = DIV_ROUND_UP(sizes->surface_bpp, 8); + + cmd.width = sizes->surface_width; + cmd.height = sizes->surface_height; + cmd.pitches[0] = round_up(sizes->surface_width * bytes_per_pixel, + tegra->pitch_align); + + cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, + sizes->surface_depth); + + size = cmd.pitches[0] * cmd.height; + + bo = tegra_bo_create(drm, size, 0); + if (IS_ERR(bo)) + return PTR_ERR(bo); + + info = drm_fb_helper_alloc_info(helper); + if (IS_ERR(info)) { + dev_err(drm->dev, "failed to allocate framebuffer info\n"); + drm_gem_object_put(&bo->gem); + return PTR_ERR(info); + } + + fb = tegra_fb_alloc(drm, &cmd, &bo, 1); + if (IS_ERR(fb)) { + err = PTR_ERR(fb); + dev_err(drm->dev, "failed to allocate DRM framebuffer: %d\n", + err); + drm_gem_object_put(&bo->gem); + return PTR_ERR(fb); + } + + helper->fb = fb; + helper->info = info; + + info->fbops = &tegra_fb_ops; + + drm_fb_helper_fill_info(info, helper, sizes); + + offset = info->var.xoffset * bytes_per_pixel + + info->var.yoffset * fb->pitches[0]; + + if (bo->pages) { + bo->vaddr = vmap(bo->pages, bo->num_pages, VM_MAP, + pgprot_writecombine(PAGE_KERNEL)); + if (!bo->vaddr) { + dev_err(drm->dev, "failed to vmap() framebuffer\n"); + err = -ENOMEM; + goto destroy; + } + } + + info->screen_base = (void __iomem *)bo->vaddr + offset; + info->screen_size = size; + info->fix.smem_start = (unsigned long)(bo->iova + offset); + info->fix.smem_len = size; + + return 0; + +destroy: + drm_framebuffer_remove(fb); + return err; +} + +static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = { + .fb_probe = tegra_fbdev_probe, +}; + +static struct drm_fb_helper *tegra_fbdev_create(struct drm_device *drm) +{ + struct drm_fb_helper *helper; + + helper = kzalloc(sizeof(*helper), GFP_KERNEL); + if (!helper) + return ERR_PTR(-ENOMEM); + + drm_fb_helper_prepare(drm, helper, 32, &tegra_fb_helper_funcs); + + return helper; +} + +static void tegra_fbdev_free(struct drm_fb_helper *helper) +{ + drm_fb_helper_unprepare(helper); + kfree(helper); +} + +static int tegra_fbdev_init(struct drm_fb_helper *helper, + unsigned int num_crtc, + unsigned int max_connectors) +{ + struct drm_device *drm = helper->dev; + int err; + + err = drm_fb_helper_init(drm, helper); + if (err < 0) { + dev_err(drm->dev, "failed to initialize DRM FB helper: %d\n", + err); + return err; + } + + err = drm_fb_helper_initial_config(helper); + if (err < 0) { + dev_err(drm->dev, "failed to set initial configuration: %d\n", + err); + goto fini; + } + + return 0; + +fini: + drm_fb_helper_fini(helper); + return err; +} + +static void tegra_fbdev_exit(struct drm_fb_helper *helper) +{ + struct drm_framebuffer *fb = helper->fb; + + drm_fb_helper_unregister_info(helper); + + if (fb) { + struct tegra_bo *bo = tegra_fb_get_plane(fb, 0); + + /* Undo the special mapping we made in fbdev probe. */ + if (bo && bo->pages) { + vunmap(bo->vaddr); + bo->vaddr = NULL; + } + + drm_framebuffer_remove(fb); + } + + drm_fb_helper_fini(helper); + tegra_fbdev_free(helper); +} + +int tegra_drm_fb_prepare(struct drm_device *drm) +{ + drm->fb_helper = tegra_fbdev_create(drm); + if (IS_ERR(drm->fb_helper)) + return PTR_ERR(drm->fb_helper); + + return 0; +} + +void tegra_drm_fb_free(struct drm_device *drm) +{ + tegra_fbdev_free(drm->fb_helper); +} + +int tegra_drm_fb_init(struct drm_device *drm) +{ + int err; + + err = tegra_fbdev_init(drm->fb_helper, drm->mode_config.num_crtc, + drm->mode_config.num_connector); + if (err < 0) + return err; + + return 0; +} + +void tegra_drm_fb_exit(struct drm_device *drm) +{ + tegra_fbdev_exit(drm->fb_helper); +} From patchwork Thu Mar 30 08:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29919C6FD1D for ; Thu, 30 Mar 2023 08:36:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B097D10ED57; Thu, 30 Mar 2023 08:36:26 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6CE6310ED2F for ; Thu, 30 Mar 2023 08:36:11 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0FECD21A7E; Thu, 30 Mar 2023 08:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680165370; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H2Ext+W82fQQ2w7SqDir609zbPpKyhgFa4BXMGt/wso=; b=ZPd7q+qsoGN04zvGDgoBQIm/fHnEtSJ55xP+HZdjTJTnh9nBR3H/qOn7GpJg3S5uVelVVb Sy5FQmxmrxRQnYfWrtdhuxARhV5BmgtCBb7oAHBlK/5J27lZ99eZUlUDrM4a/oEUPYFf2F OFsHr8Zfe4sy8DX2TmxNj52BPQgaEDs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680165370; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H2Ext+W82fQQ2w7SqDir609zbPpKyhgFa4BXMGt/wso=; b=i9rdo3Gziu4DUp4Su/dBMaqF4m3tOYt0L9eTiFPBm3OXKk6c4cSsoYkrA8WprOJbK54oH9 wFUE5RclYdJOveBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D4C0D138FF; Thu, 30 Mar 2023 08:36:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iGT5MvlJJWQHHAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 08:36:09 +0000 From: Thomas Zimmermann To: thierry.reding@gmail.com, jonathanh@nvidia.com, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 6/7] drm/tegra: Initialize fbdev DRM client Date: Thu, 30 Mar 2023 10:36:06 +0200 Message-Id: <20230330083607.12834-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330083607.12834-1-tzimmermann@suse.de> References: <20230330083607.12834-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Initialize the fbdev client in the fbdev code with empty helper functions. Also clean up the client. The helpers will later implement various functionality of the DRM client. No functional changes. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/tegra/fbdev.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c index 2400d42f82e4..31a95a955efb 100644 --- a/drivers/gpu/drm/tegra/fbdev.c +++ b/drivers/gpu/drm/tegra/fbdev.c @@ -125,6 +125,30 @@ static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = { .fb_probe = tegra_fbdev_probe, }; +/* + * struct drm_client + */ + +static void tegra_fbdev_client_unregister(struct drm_client_dev *client) +{ } + +static int tregra_fbdev_client_restore(struct drm_client_dev *client) +{ + return 0; +} + +static int tegra_fbdev_client_hotplug(struct drm_client_dev *client) +{ + return 0; +} + +static const struct drm_client_funcs tegra_fbdev_client_funcs = { + .owner = THIS_MODULE, + .unregister = tegra_fbdev_client_unregister, + .restore = tegra_fbdev_client_restore, + .hotplug = tegra_fbdev_client_hotplug, +}; + static struct drm_fb_helper *tegra_fbdev_create(struct drm_device *drm) { struct drm_fb_helper *helper; @@ -151,11 +175,15 @@ static int tegra_fbdev_init(struct drm_fb_helper *helper, struct drm_device *drm = helper->dev; int err; + err = drm_client_init(dev, &helper->client, "fbdev", &tegra_fbdev_client_funcs); + if (err) + return err; + err = drm_fb_helper_init(drm, helper); if (err < 0) { dev_err(drm->dev, "failed to initialize DRM FB helper: %d\n", err); - return err; + goto err_drm_client_release; } err = drm_fb_helper_initial_config(helper); @@ -169,6 +197,8 @@ static int tegra_fbdev_init(struct drm_fb_helper *helper, fini: drm_fb_helper_fini(helper); +err_drm_client_release: + drm_client_release(&helper->client); return err; } @@ -191,6 +221,7 @@ static void tegra_fbdev_exit(struct drm_fb_helper *helper) } drm_fb_helper_fini(helper); + drm_client_release(&helper->client); tegra_fbdev_free(helper); } From patchwork Thu Mar 30 08:36:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13193590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6C9FC6FD1D for ; Thu, 30 Mar 2023 08:36:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 98E0E10ED41; Thu, 30 Mar 2023 08:36:24 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 989CF10ED39 for ; Thu, 30 Mar 2023 08:36:11 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 43A4221A98; Thu, 30 Mar 2023 08:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680165370; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tyAsvLxxSPqqEMN8Gwy8wMJEbceObIlovA8CqeT0y+Q=; b=giwPQGS3vm4BpGpDGSflHaF1pqxz7lBuM8F3XcijfWLVEN37pLoiOruz2Qha9t70087EqZ 1io08d+q8XGaJa1AGXQREV4Tpib6+bVXYkxJZLkygPxHVZgiTwOmdmeQrmIOJy2u/7eyO9 G029+V7pgGaKN8m/9lW7ILwqB5zqNro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680165370; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tyAsvLxxSPqqEMN8Gwy8wMJEbceObIlovA8CqeT0y+Q=; b=AicTgmMexa0A+z8APTIrq971nngVtsL1cOB4/ncUCTtjAq+hjH3JcNSrYX0eu+xC+44ppT 6Lx3mqwLhNo7u2Ag== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 182A0138FF; Thu, 30 Mar 2023 08:36:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MC/EBPpJJWQHHAAAMHmgww (envelope-from ); Thu, 30 Mar 2023 08:36:10 +0000 From: Thomas Zimmermann To: thierry.reding@gmail.com, jonathanh@nvidia.com, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH 7/7] drm/tegra: Implement fbdev emulation as in-kernel client Date: Thu, 30 Mar 2023 10:36:07 +0200 Message-Id: <20230330083607.12834-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330083607.12834-1-tzimmermann@suse.de> References: <20230330083607.12834-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move code from ad-hoc fbdev callbacks into DRM client functions and remove the old callbacks. The functions instruct the client to poll for changed output or restore the display. The DRM core calls both, the old callbacks and the new client helpers, from the same places. The new functions perform the same operation as before, so there's no change in functionality. Replace all code that initializes or releases fbdev emulation throughout the driver. Instead initialize the fbdev client by a single call to tegra_fbdev_setup() after tegra has registered its DRM device. As in most drivers, tegra's fbdev emulation now acts like a regular DRM client. The fbdev client setup consists of the initial preparation and the hot-plugging of the display. The latter creates the fbdev device and sets up the fbdev framebuffer. The setup performs display hot-plugging once. If no display can be detected, DRM probe helpers re-run the detection on each hotplug event. A call to drm_dev_unregister() releases the client automatically. No further action is required within tegra. If the fbdev framebuffer has been fully set up, struct fb_ops.fb_destroy implements the release. For partially initialized emulation, the fbdev client reverts the initial setup. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/tegra/drm.c | 23 +---- drivers/gpu/drm/tegra/drm.h | 18 +--- drivers/gpu/drm/tegra/fbdev.c | 177 +++++++++++++++------------------- 3 files changed, 86 insertions(+), 132 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 6ca9f396e55b..85ba96cddd51 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -56,9 +56,6 @@ static int tegra_atomic_check(struct drm_device *drm, static const struct drm_mode_config_funcs tegra_drm_mode_config_funcs = { .fb_create = tegra_fb_create, -#ifdef CONFIG_DRM_FBDEV_EMULATION - .output_poll_changed = drm_fb_helper_output_poll_changed, -#endif .atomic_check = tegra_atomic_check, .atomic_commit = drm_atomic_helper_commit, }; @@ -885,7 +882,6 @@ static const struct drm_driver tegra_drm_driver = { DRIVER_ATOMIC | DRIVER_RENDER | DRIVER_SYNCOBJ, .open = tegra_drm_open, .postclose = tegra_drm_postclose, - .lastclose = drm_fb_helper_lastclose, #if defined(CONFIG_DEBUG_FS) .debugfs_init = tegra_debugfs_init, @@ -1185,15 +1181,11 @@ static int host1x_drm_probe(struct host1x_device *dev) drm->mode_config.funcs = &tegra_drm_mode_config_funcs; drm->mode_config.helper_private = &tegra_drm_mode_config_helpers; - err = tegra_drm_fb_prepare(drm); - if (err < 0) - goto config; - drm_kms_helper_poll_init(drm); err = host1x_device_init(dev); if (err < 0) - goto fbdev; + goto poll; /* * Now that all display controller have been initialized, the maximum @@ -1256,18 +1248,14 @@ static int host1x_drm_probe(struct host1x_device *dev) if (err < 0) goto hub; - err = tegra_drm_fb_init(drm); + err = drm_dev_register(drm, 0); if (err < 0) goto hub; - err = drm_dev_register(drm, 0); - if (err < 0) - goto fb; + tegra_fbdev_setup(drm); return 0; -fb: - tegra_drm_fb_exit(drm); hub: if (tegra->hub) tegra_display_hub_cleanup(tegra->hub); @@ -1280,10 +1268,8 @@ static int host1x_drm_probe(struct host1x_device *dev) } host1x_device_exit(dev); -fbdev: +poll: drm_kms_helper_poll_fini(drm); - tegra_drm_fb_free(drm); -config: drm_mode_config_cleanup(drm); domain: if (tegra->domain) @@ -1304,7 +1290,6 @@ static int host1x_drm_remove(struct host1x_device *dev) drm_dev_unregister(drm); drm_kms_helper_poll_fini(drm); - tegra_drm_fb_exit(drm); drm_atomic_helper_shutdown(drm); drm_mode_config_cleanup(drm); diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index 576f03b8434e..f9d18e8cf6ab 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -194,22 +193,9 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, const struct drm_mode_fb_cmd2 *cmd); #ifdef CONFIG_DRM_FBDEV_EMULATION -int tegra_drm_fb_prepare(struct drm_device *drm); -void tegra_drm_fb_free(struct drm_device *drm); -int tegra_drm_fb_init(struct drm_device *drm); -void tegra_drm_fb_exit(struct drm_device *drm); +void tegra_fbdev_setup(struct drm_device *drm); #else -static inline int tegra_drm_fb_prepare(struct drm_device *drm) -{ - return 0; -} -static inline void tegra_drm_fb_free(struct drm_device *drm) -{ } -static inline int tegra_drm_fb_init(struct drm_device *drm) -{ - return 0; -} -static inline void tegra_drm_fb_exit(struct drm_device *drm) +static inline void tegra_fbdev_setup(struct drm_device *drm) { } #endif diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c index 31a95a955efb..dc6dda641d1c 100644 --- a/drivers/gpu/drm/tegra/fbdev.c +++ b/drivers/gpu/drm/tegra/fbdev.c @@ -9,6 +9,9 @@ #include +#include +#include +#include #include #include #include @@ -32,6 +35,26 @@ static int tegra_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) return __tegra_gem_mmap(&bo->gem, vma); } +static void tegra_fbdev_fb_destroy(struct fb_info *info) +{ + struct drm_fb_helper *helper = info->par; + struct drm_framebuffer *fb = helper->fb; + struct tegra_bo *bo = tegra_fb_get_plane(fb, 0); + + drm_fb_helper_fini(helper); + + /* Undo the special mapping we made in fbdev probe. */ + if (bo->pages) { + vunmap(bo->vaddr); + bo->vaddr = NULL; + } + drm_framebuffer_remove(fb); + + drm_client_release(&helper->client); + drm_fb_helper_unprepare(helper); + kfree(helper); +} + static const struct fb_ops tegra_fb_ops = { .owner = THIS_MODULE, DRM_FB_HELPER_DEFAULT_OPS, @@ -41,6 +64,7 @@ static const struct fb_ops tegra_fb_ops = { .fb_copyarea = drm_fb_helper_sys_copyarea, .fb_imageblit = drm_fb_helper_sys_imageblit, .fb_mmap = tegra_fb_mmap, + .fb_destroy = tegra_fbdev_fb_destroy, }; static int tegra_fbdev_probe(struct drm_fb_helper *helper, @@ -130,16 +154,52 @@ static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = { */ static void tegra_fbdev_client_unregister(struct drm_client_dev *client) -{ } +{ + struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client); + + if (fb_helper->info) { + drm_fb_helper_unregister_info(fb_helper); + } else { + drm_client_release(&fb_helper->client); + drm_fb_helper_unprepare(fb_helper); + kfree(fb_helper); + } +} -static int tregra_fbdev_client_restore(struct drm_client_dev *client) +static int tegra_fbdev_client_restore(struct drm_client_dev *client) { + drm_fb_helper_lastclose(client->dev); + return 0; } static int tegra_fbdev_client_hotplug(struct drm_client_dev *client) { + struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client); + struct drm_device *dev = client->dev; + int ret; + + if (dev->fb_helper) + return drm_fb_helper_hotplug_event(dev->fb_helper); + + ret = drm_fb_helper_init(dev, fb_helper); + if (ret) + goto err_drm_err; + + if (!drm_drv_uses_atomic_modeset(dev)) + drm_helper_disable_unused_functions(dev); + + ret = drm_fb_helper_initial_config(fb_helper); + if (ret) + goto err_drm_fb_helper_fini; + return 0; + +err_drm_fb_helper_fini: + drm_fb_helper_fini(fb_helper); +err_drm_err: + drm_err(dev, "Failed to setup fbdev emulation (ret=%d)\n", ret); + return ret; } static const struct drm_client_funcs tegra_fbdev_client_funcs = { @@ -149,109 +209,32 @@ static const struct drm_client_funcs tegra_fbdev_client_funcs = { .hotplug = tegra_fbdev_client_hotplug, }; -static struct drm_fb_helper *tegra_fbdev_create(struct drm_device *drm) +void tegra_fbdev_setup(struct drm_device *dev) { struct drm_fb_helper *helper; + int ret; + + drm_WARN(dev, !dev->registered, "Device has not been registered.\n"); + drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n"); helper = kzalloc(sizeof(*helper), GFP_KERNEL); if (!helper) - return ERR_PTR(-ENOMEM); - - drm_fb_helper_prepare(drm, helper, 32, &tegra_fb_helper_funcs); - - return helper; -} - -static void tegra_fbdev_free(struct drm_fb_helper *helper) -{ - drm_fb_helper_unprepare(helper); - kfree(helper); -} - -static int tegra_fbdev_init(struct drm_fb_helper *helper, - unsigned int num_crtc, - unsigned int max_connectors) -{ - struct drm_device *drm = helper->dev; - int err; - - err = drm_client_init(dev, &helper->client, "fbdev", &tegra_fbdev_client_funcs); - if (err) - return err; - - err = drm_fb_helper_init(drm, helper); - if (err < 0) { - dev_err(drm->dev, "failed to initialize DRM FB helper: %d\n", - err); - goto err_drm_client_release; - } + return; + drm_fb_helper_prepare(dev, helper, 32, &tegra_fb_helper_funcs); - err = drm_fb_helper_initial_config(helper); - if (err < 0) { - dev_err(drm->dev, "failed to set initial configuration: %d\n", - err); - goto fini; - } + ret = drm_client_init(dev, &helper->client, "fbdev", &tegra_fbdev_client_funcs); + if (ret) + goto err_drm_client_init; - return 0; + ret = tegra_fbdev_client_hotplug(&helper->client); + if (ret) + drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); -fini: - drm_fb_helper_fini(helper); -err_drm_client_release: - drm_client_release(&helper->client); - return err; -} + drm_client_register(&helper->client); -static void tegra_fbdev_exit(struct drm_fb_helper *helper) -{ - struct drm_framebuffer *fb = helper->fb; - - drm_fb_helper_unregister_info(helper); - - if (fb) { - struct tegra_bo *bo = tegra_fb_get_plane(fb, 0); - - /* Undo the special mapping we made in fbdev probe. */ - if (bo && bo->pages) { - vunmap(bo->vaddr); - bo->vaddr = NULL; - } - - drm_framebuffer_remove(fb); - } - - drm_fb_helper_fini(helper); - drm_client_release(&helper->client); - tegra_fbdev_free(helper); -} + return; -int tegra_drm_fb_prepare(struct drm_device *drm) -{ - drm->fb_helper = tegra_fbdev_create(drm); - if (IS_ERR(drm->fb_helper)) - return PTR_ERR(drm->fb_helper); - - return 0; -} - -void tegra_drm_fb_free(struct drm_device *drm) -{ - tegra_fbdev_free(drm->fb_helper); -} - -int tegra_drm_fb_init(struct drm_device *drm) -{ - int err; - - err = tegra_fbdev_init(drm->fb_helper, drm->mode_config.num_crtc, - drm->mode_config.num_connector); - if (err < 0) - return err; - - return 0; -} - -void tegra_drm_fb_exit(struct drm_device *drm) -{ - tegra_fbdev_exit(drm->fb_helper); +err_drm_client_init: + drm_fb_helper_unprepare(helper); + kfree(helper); }