From patchwork Thu Nov 2 13:08:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13443754 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 F39F2C4167B for ; Thu, 2 Nov 2023 13:11:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A9E110E88F; Thu, 2 Nov 2023 13:11:05 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 55C4910E88D; Thu, 2 Nov 2023 13:11:01 +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 E57FD21A5D; Thu, 2 Nov 2023 13:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1698930659; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e5j1wpnB+M/lEbe86L9vJRsjGYnUxtbiyBnDOUViINA=; b=g6Aeh0lTazJz5YrdqlxY6YtHWqoWm+L1SR486IaCpRfcffEK7QN+uEbiWz2ehMH0R3xtrJ nevc2xGRXt9JydzE+ekdXJddEAhVIIe4voyev4A6NrbOm5MQNREtgEuQHt5pURoawy4lwS R/Tn/bfGlBT4A5cZZTP4PLcO78Jzayg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1698930659; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e5j1wpnB+M/lEbe86L9vJRsjGYnUxtbiyBnDOUViINA=; b=+An7uvyKa/yb6hdSDVkHxhM9vm79/svHKX8vbjx2Zvcgll6DA6e25VKLDdKFUpcfxC4xpF jvEE+ED9HzgwRUAA== 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 A28EC13584; Thu, 2 Nov 2023 13:10:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0ACpJuOfQ2VRXwAAMHmgww (envelope-from ); Thu, 02 Nov 2023 13:10:59 +0000 From: Thomas Zimmermann To: jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com, ville.syrjala@linux.intel.com, imre.deak@intel.com, tejas.upadhyay@intel.com, jouni.hogander@intel.com, javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch Date: Thu, 2 Nov 2023 14:08:09 +0100 Message-ID: <20231102131056.7256-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231102131056.7256-1-tzimmermann@suse.de> References: <20231102131056.7256-1-tzimmermann@suse.de> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v6 4/7] drm/i915: Move fbdev functions X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Move functions within intel_fbdev.c to simplify later updates. Minor style fixes to make checkpatch happy, but no functional changes. v5: * style fixes (checkpatch) Signed-off-by: Thomas Zimmermann Reviewed-by: Jouni Högander --- drivers/gpu/drm/i915/display/intel_fbdev.c | 154 ++++++++++----------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c index 31d0d695d5671..2695c65b55ddc 100644 --- a/drivers/gpu/drm/i915/display/intel_fbdev.c +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c @@ -545,58 +545,6 @@ static void intel_fbdev_suspend_worker(struct work_struct *work) true); } -int intel_fbdev_init(struct drm_device *dev) -{ - struct drm_i915_private *dev_priv = to_i915(dev); - struct intel_fbdev *ifbdev; - int ret; - - if (drm_WARN_ON(dev, !HAS_DISPLAY(dev_priv))) - return -ENODEV; - - ifbdev = kzalloc(sizeof(struct intel_fbdev), GFP_KERNEL); - if (ifbdev == NULL) - return -ENOMEM; - - mutex_init(&ifbdev->hpd_lock); - drm_fb_helper_prepare(dev, &ifbdev->helper, 32, &intel_fb_helper_funcs); - - if (intel_fbdev_init_bios(dev, ifbdev)) - ifbdev->helper.preferred_bpp = ifbdev->preferred_bpp; - else - ifbdev->preferred_bpp = ifbdev->helper.preferred_bpp; - - ret = drm_fb_helper_init(dev, &ifbdev->helper); - if (ret) { - kfree(ifbdev); - return ret; - } - - dev_priv->display.fbdev.fbdev = ifbdev; - INIT_WORK(&dev_priv->display.fbdev.suspend_work, intel_fbdev_suspend_worker); - - return 0; -} - -static void intel_fbdev_initial_config(void *data, async_cookie_t cookie) -{ - struct intel_fbdev *ifbdev = data; - - /* Due to peculiar init order wrt to hpd handling this is separate. */ - if (drm_fb_helper_initial_config(&ifbdev->helper)) - intel_fbdev_unregister(to_i915(ifbdev->helper.dev)); -} - -void intel_fbdev_initial_config_async(struct drm_i915_private *dev_priv) -{ - struct intel_fbdev *ifbdev = dev_priv->display.fbdev.fbdev; - - if (!ifbdev) - return; - - ifbdev->cookie = async_schedule(intel_fbdev_initial_config, ifbdev); -} - static void intel_fbdev_sync(struct intel_fbdev *ifbdev) { if (!ifbdev->cookie) @@ -607,31 +555,6 @@ static void intel_fbdev_sync(struct intel_fbdev *ifbdev) ifbdev->cookie = 0; } -void intel_fbdev_unregister(struct drm_i915_private *dev_priv) -{ - struct intel_fbdev *ifbdev = dev_priv->display.fbdev.fbdev; - - if (!ifbdev) - return; - - intel_fbdev_set_suspend(&dev_priv->drm, FBINFO_STATE_SUSPENDED, true); - - if (!current_is_async()) - intel_fbdev_sync(ifbdev); - - drm_fb_helper_unregister_info(&ifbdev->helper); -} - -void intel_fbdev_fini(struct drm_i915_private *dev_priv) -{ - struct intel_fbdev *ifbdev = fetch_and_zero(&dev_priv->display.fbdev.fbdev); - - if (!ifbdev) - return; - - intel_fbdev_destroy(ifbdev); -} - /* Suspends/resumes fbdev processing of incoming HPD events. When resuming HPD * processing, fbdev will perform a full connector reprobe if a hotplug event * was received while HPD was suspended. @@ -748,6 +671,83 @@ void intel_fbdev_restore_mode(struct drm_i915_private *dev_priv) intel_fbdev_invalidate(ifbdev); } +int intel_fbdev_init(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = to_i915(dev); + struct intel_fbdev *ifbdev; + int ret; + + if (drm_WARN_ON(dev, !HAS_DISPLAY(dev_priv))) + return -ENODEV; + + ifbdev = kzalloc(sizeof(*ifbdev), GFP_KERNEL); + if (!ifbdev) + return -ENOMEM; + + mutex_init(&ifbdev->hpd_lock); + drm_fb_helper_prepare(dev, &ifbdev->helper, 32, &intel_fb_helper_funcs); + + if (intel_fbdev_init_bios(dev, ifbdev)) + ifbdev->helper.preferred_bpp = ifbdev->preferred_bpp; + else + ifbdev->preferred_bpp = ifbdev->helper.preferred_bpp; + + ret = drm_fb_helper_init(dev, &ifbdev->helper); + if (ret) { + kfree(ifbdev); + return ret; + } + + dev_priv->display.fbdev.fbdev = ifbdev; + INIT_WORK(&dev_priv->display.fbdev.suspend_work, intel_fbdev_suspend_worker); + + return 0; +} + +static void intel_fbdev_initial_config(void *data, async_cookie_t cookie) +{ + struct intel_fbdev *ifbdev = data; + + /* Due to peculiar init order wrt to hpd handling this is separate. */ + if (drm_fb_helper_initial_config(&ifbdev->helper)) + intel_fbdev_unregister(to_i915(ifbdev->helper.dev)); +} + +void intel_fbdev_initial_config_async(struct drm_i915_private *dev_priv) +{ + struct intel_fbdev *ifbdev = dev_priv->display.fbdev.fbdev; + + if (!ifbdev) + return; + + ifbdev->cookie = async_schedule(intel_fbdev_initial_config, ifbdev); +} + +void intel_fbdev_unregister(struct drm_i915_private *dev_priv) +{ + struct intel_fbdev *ifbdev = dev_priv->display.fbdev.fbdev; + + if (!ifbdev) + return; + + intel_fbdev_set_suspend(&dev_priv->drm, FBINFO_STATE_SUSPENDED, true); + + if (!current_is_async()) + intel_fbdev_sync(ifbdev); + + drm_fb_helper_unregister_info(&ifbdev->helper); +} + +void intel_fbdev_fini(struct drm_i915_private *dev_priv) +{ + struct intel_fbdev *ifbdev = fetch_and_zero(&dev_priv->display.fbdev.fbdev); + + if (!ifbdev) + return; + + intel_fbdev_destroy(ifbdev); +} + struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev) { if (!fbdev || !fbdev->helper.fb)