From patchwork Wed Mar 19 07:45:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022255 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 A78F5C35FFF for ; Wed, 19 Mar 2025 08:34:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0CD8B10E0BD; Wed, 19 Mar 2025 08:34:07 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 48E9810E0BD for ; Wed, 19 Mar 2025 08:34:03 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C24C81F831; Wed, 19 Mar 2025 08:33:52 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 821A713A38; Wed, 19 Mar 2025 08:33:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8GqBHnCB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:52 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 01/18] drm/ofdrm: Remove struct ofdrm_device.pdev Date: Wed, 19 Mar 2025 08:45:00 +0100 Message-ID: <20250319083021.6472-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: C24C81F831 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The field pdev is unused. Remove it. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/tiny/ofdrm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/tiny/ofdrm.c index 13491c0e704a..7469dd281083 100644 --- a/drivers/gpu/drm/tiny/ofdrm.c +++ b/drivers/gpu/drm/tiny/ofdrm.c @@ -291,7 +291,6 @@ struct ofdrm_device_funcs { struct ofdrm_device { struct drm_device dev; - struct platform_device *pdev; const struct ofdrm_device_funcs *funcs; From patchwork Wed Mar 19 07:45:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022254 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 2A665C35FFF for ; Wed, 19 Mar 2025 08:34:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D5EB10E1BE; Wed, 19 Mar 2025 08:34:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="HbUNm/mu"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CxNcKa7C"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="HbUNm/mu"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CxNcKa7C"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 61C4810E095 for ; Wed, 19 Mar 2025 08:33:54 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 07B9721746; Wed, 19 Mar 2025 08:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373233; 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=Gji/B6k8kGDDQ+zOisUtIu8WLbeHIGCG+8BKo+krpaU=; b=HbUNm/muCIxZyFnX77SbfXXv3vCIMiTs7YBGIukBT+KOZbAvA7k5TNnW1onjJv2P3pyXZg m34ha+ZHqM8lrn+o441clISebeBmIR3CkFG0zMTWc9qDXCHa2XS8doNsHMAqiOWezR1xYd t13FC8f3SgTzvw9yfsMlSFoGQaZQQ8Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373233; 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=Gji/B6k8kGDDQ+zOisUtIu8WLbeHIGCG+8BKo+krpaU=; b=CxNcKa7CyMWNRGLYgIXK4I6EkEB/UiqfHz3Wot2IOOb2Yw1oSEPRJAmryuuOclpUDPViCA /R6x6PIewTsfkYCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373233; 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=Gji/B6k8kGDDQ+zOisUtIu8WLbeHIGCG+8BKo+krpaU=; b=HbUNm/muCIxZyFnX77SbfXXv3vCIMiTs7YBGIukBT+KOZbAvA7k5TNnW1onjJv2P3pyXZg m34ha+ZHqM8lrn+o441clISebeBmIR3CkFG0zMTWc9qDXCHa2XS8doNsHMAqiOWezR1xYd t13FC8f3SgTzvw9yfsMlSFoGQaZQQ8Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373233; 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=Gji/B6k8kGDDQ+zOisUtIu8WLbeHIGCG+8BKo+krpaU=; b=CxNcKa7CyMWNRGLYgIXK4I6EkEB/UiqfHz3Wot2IOOb2Yw1oSEPRJAmryuuOclpUDPViCA /R6x6PIewTsfkYCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C8D7613A2C; Wed, 19 Mar 2025 08:33:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WOzML3CB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:52 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 02/18] drm/ofdrm: Open-code drm_simple_encoder_init() Date: Wed, 19 Mar 2025 08:45:01 +0100 Message-ID: <20250319083021.6472-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_TO(0.00)[redhat.com,ffwll.ch,gmail.com,linux.intel.com,kernel.org]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The helper drm_simple_encoder_init() is a trivial helper around drm_encoder_init() and therefore deprecated. Open-code the function and remove the dependency. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/tiny/ofdrm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/tiny/ofdrm.c index 7469dd281083..7d5beaf6a42c 100644 --- a/drivers/gpu/drm/tiny/ofdrm.c +++ b/drivers/gpu/drm/tiny/ofdrm.c @@ -21,7 +21,6 @@ #include #include #include -#include #define DRIVER_NAME "ofdrm" #define DRIVER_DESC "DRM driver for OF platform devices" @@ -999,6 +998,10 @@ static const struct drm_crtc_funcs ofdrm_crtc_funcs = { .atomic_destroy_state = ofdrm_crtc_atomic_destroy_state, }; +static const struct drm_encoder_funcs ofdrm_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; + static int ofdrm_connector_helper_get_modes(struct drm_connector *connector) { struct ofdrm_device *odev = ofdrm_device_of_dev(connector->dev); @@ -1309,7 +1312,7 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, /* Encoder */ encoder = &odev->encoder; - ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_NONE); + ret = drm_encoder_init(dev, encoder, &ofdrm_encoder_funcs, DRM_MODE_ENCODER_NONE, NULL); if (ret) return ERR_PTR(ret); encoder->possible_crtcs = drm_crtc_mask(crtc); From patchwork Wed Mar 19 07:45:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022257 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 D6C22C35FFA for ; Wed, 19 Mar 2025 08:34:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4424410E2E9; Wed, 19 Mar 2025 08:34:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="hUvbpzsr"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="/mN41iX+"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hUvbpzsr"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="/mN41iX+"; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 49EDE10E23C for ; Wed, 19 Mar 2025 08:34:07 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4A56E1F7DC; Wed, 19 Mar 2025 08:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373233; 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=zFKmhiV3UY1x5J2Kz5pe10eb4ArIAZD2AsviU5s+itc=; b=hUvbpzsrtuW6Dej7ZhgFirCZtgJgXjT7mbqF5mXxD+DKO4yCiVgUvpRPiLgtfLUnqMBi9W IgOJQQBucenRHEzH5m4tAUm/Vff3r5fbF+g2h+tvrLcrWEO+OqOmCdCDfbVapXiBLb5Wpe TX1C0KzARFvewo7/zZfRPN0do0AZOGg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373233; 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=zFKmhiV3UY1x5J2Kz5pe10eb4ArIAZD2AsviU5s+itc=; b=/mN41iX+ir/3/2aa9BBvumhAu1qFBITiccpR8bhZlwGonvPKpmSlBmFc0OdHNUJI2vEKf6 1eqGr2iRikuPazDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373233; 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=zFKmhiV3UY1x5J2Kz5pe10eb4ArIAZD2AsviU5s+itc=; b=hUvbpzsrtuW6Dej7ZhgFirCZtgJgXjT7mbqF5mXxD+DKO4yCiVgUvpRPiLgtfLUnqMBi9W IgOJQQBucenRHEzH5m4tAUm/Vff3r5fbF+g2h+tvrLcrWEO+OqOmCdCDfbVapXiBLb5Wpe TX1C0KzARFvewo7/zZfRPN0do0AZOGg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373233; 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=zFKmhiV3UY1x5J2Kz5pe10eb4ArIAZD2AsviU5s+itc=; b=/mN41iX+ir/3/2aa9BBvumhAu1qFBITiccpR8bhZlwGonvPKpmSlBmFc0OdHNUJI2vEKf6 1eqGr2iRikuPazDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0DBF313A38; Wed, 19 Mar 2025 08:33:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KIAjAnGB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:53 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 03/18] drm/simpledrm: Remove struct simpledrm_device.nformats Date: Wed, 19 Mar 2025 08:45:02 +0100 Message-ID: <20250319083021.6472-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_TO(0.00)[redhat.com,ffwll.ch,gmail.com,linux.intel.com,kernel.org]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The field nformats is unused. Remove it. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/tiny/simpledrm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c index 5d9ab8adf800..d949713f5ff6 100644 --- a/drivers/gpu/drm/tiny/simpledrm.c +++ b/drivers/gpu/drm/tiny/simpledrm.c @@ -246,7 +246,6 @@ struct simpledrm_device { /* modesetting */ uint32_t formats[8]; - size_t nformats; struct drm_plane primary_plane; struct drm_crtc crtc; struct drm_encoder encoder; From patchwork Wed Mar 19 07:45:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022256 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 8B0EDC35FFA for ; Wed, 19 Mar 2025 08:34:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 850D410E2E8; Wed, 19 Mar 2025 08:34:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="PKwhMwdE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="nb1AukRi"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="PKwhMwdE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="nb1AukRi"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 811A710E23C for ; Wed, 19 Mar 2025 08:34:03 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 86B012174F; Wed, 19 Mar 2025 08:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373233; 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=IkiDZKgtChK2EG4JCBmvhfevaGE+EkkVGm6oM93LU/E=; b=PKwhMwdE8zDmtwl781CbFpMMEsXMsaaM+DQfxGYIQzUDcuz7m9EBpfg7ejwxyeCjcFMPdB 1fBsqTo1u826kkK53hSRsKbwywy/owNSw3j44fiT0Sf7DSsi2UtY1N0bko0I+rb7YhDJDu B9QhAtzO/mUOzV5bq5EeI2szFO1JuG0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373233; 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=IkiDZKgtChK2EG4JCBmvhfevaGE+EkkVGm6oM93LU/E=; b=nb1AukRiBj/JhqwkxIx+0rkjW8kYsm0SyeldaAU150xbo0l3bauNeeApqTa2fM7FbJRQSl daUuYEKHp2wBqvDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373233; 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=IkiDZKgtChK2EG4JCBmvhfevaGE+EkkVGm6oM93LU/E=; b=PKwhMwdE8zDmtwl781CbFpMMEsXMsaaM+DQfxGYIQzUDcuz7m9EBpfg7ejwxyeCjcFMPdB 1fBsqTo1u826kkK53hSRsKbwywy/owNSw3j44fiT0Sf7DSsi2UtY1N0bko0I+rb7YhDJDu B9QhAtzO/mUOzV5bq5EeI2szFO1JuG0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373233; 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=IkiDZKgtChK2EG4JCBmvhfevaGE+EkkVGm6oM93LU/E=; b=nb1AukRiBj/JhqwkxIx+0rkjW8kYsm0SyeldaAU150xbo0l3bauNeeApqTa2fM7FbJRQSl daUuYEKHp2wBqvDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 51A6013A2C; Wed, 19 Mar 2025 08:33:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eKjCEnGB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:53 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 04/18] drm: Move sysfb drivers into separate subdirectory Date: Wed, 19 Mar 2025 08:45:03 +0100 Message-ID: <20250319083021.6472-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ffwll.ch,gmail.com,linux.intel.com,kernel.org]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The ofdrm and simpledrm drivers are special as they operate on externally provided framebuffers. Move them into their own sub- directory. Will let them share common code. Signed-off-by: Thomas Zimmermann --- MAINTAINERS | 3 +- drivers/gpu/drm/Kconfig | 2 ++ drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/sysfb/Kconfig | 38 +++++++++++++++++++++ drivers/gpu/drm/sysfb/Makefile | 4 +++ drivers/gpu/drm/{tiny => sysfb}/ofdrm.c | 0 drivers/gpu/drm/{tiny => sysfb}/simpledrm.c | 0 drivers/gpu/drm/tiny/Kconfig | 32 ----------------- drivers/gpu/drm/tiny/Makefile | 2 -- 9 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 drivers/gpu/drm/sysfb/Kconfig create mode 100644 drivers/gpu/drm/sysfb/Makefile rename drivers/gpu/drm/{tiny => sysfb}/ofdrm.c (100%) rename drivers/gpu/drm/{tiny => sysfb}/simpledrm.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 9df9b25fffc3..588cea0e8630 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7247,8 +7247,7 @@ M: Javier Martinez Canillas L: dri-devel@lists.freedesktop.org S: Maintained T: git https://gitlab.freedesktop.org/drm/misc/kernel.git -F: drivers/gpu/drm/tiny/ofdrm.c -F: drivers/gpu/drm/tiny/simpledrm.c +F: drivers/gpu/drm/sysfb/ F: drivers/video/aperture.c F: drivers/video/nomodeset.c F: include/linux/aperture.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 1be14d8634f4..200bfbb9f093 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -335,6 +335,8 @@ config DRM_SCHED tristate depends on DRM +source "drivers/gpu/drm/sysfb/Kconfig" + source "drivers/gpu/drm/arm/Kconfig" source "drivers/gpu/drm/radeon/Kconfig" diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index ed54a546bbe2..bf5cb7936a1d 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -204,6 +204,7 @@ obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/ obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/ obj-y += hisilicon/ obj-y += mxsfb/ +obj-y += sysfb/ obj-y += tiny/ obj-$(CONFIG_DRM_PL111) += pl111/ obj-$(CONFIG_DRM_TVE200) += tve200/ diff --git a/drivers/gpu/drm/sysfb/Kconfig b/drivers/gpu/drm/sysfb/Kconfig new file mode 100644 index 000000000000..9eafc06b7192 --- /dev/null +++ b/drivers/gpu/drm/sysfb/Kconfig @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: GPL-2.0-only + +menu "Drivers for system framebuffers" + depends on DRM + +config DRM_OFDRM + tristate "Open Firmware display driver" + depends on DRM && MMU && OF && (PPC || COMPILE_TEST) + select APERTURE_HELPERS + select DRM_CLIENT_SELECTION + select DRM_GEM_SHMEM_HELPER + select DRM_KMS_HELPER + help + DRM driver for Open Firmware framebuffers. + + This driver assumes that the display hardware has been initialized + by the Open Firmware before the kernel boots. Scanout buffer, size, + and display format must be provided via device tree. + +config DRM_SIMPLEDRM + tristate "Simple framebuffer driver" + depends on DRM && MMU + select APERTURE_HELPERS + select DRM_CLIENT_SELECTION + select DRM_GEM_SHMEM_HELPER + select DRM_KMS_HELPER + help + DRM driver for simple platform-provided framebuffers. + + This driver assumes that the display hardware has been initialized + by the firmware or bootloader before the kernel boots. Scanout + buffer, size, and display format must be provided via device tree, + UEFI, VESA, etc. + + On x86 BIOS or UEFI systems, you should also select SYSFB_SIMPLEFB + to use UEFI and VESA framebuffers. + +endmenu diff --git a/drivers/gpu/drm/sysfb/Makefile b/drivers/gpu/drm/sysfb/Makefile new file mode 100644 index 000000000000..f6c03629accb --- /dev/null +++ b/drivers/gpu/drm/sysfb/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_DRM_OFDRM) += ofdrm.o +obj-$(CONFIG_DRM_SIMPLEDRM) += simpledrm.o diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c similarity index 100% rename from drivers/gpu/drm/tiny/ofdrm.c rename to drivers/gpu/drm/sysfb/ofdrm.c diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c similarity index 100% rename from drivers/gpu/drm/tiny/simpledrm.c rename to drivers/gpu/drm/sysfb/simpledrm.c diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig index 54c84c9801c1..95c1457d7730 100644 --- a/drivers/gpu/drm/tiny/Kconfig +++ b/drivers/gpu/drm/tiny/Kconfig @@ -65,20 +65,6 @@ config DRM_GM12U320 This is a KMS driver for projectors which use the GM12U320 chipset for video transfer over USB2/3, such as the Acer C120 mini projector. -config DRM_OFDRM - tristate "Open Firmware display driver" - depends on DRM && MMU && OF && (PPC || COMPILE_TEST) - select APERTURE_HELPERS - select DRM_CLIENT_SELECTION - select DRM_GEM_SHMEM_HELPER - select DRM_KMS_HELPER - help - DRM driver for Open Firmware framebuffers. - - This driver assumes that the display hardware has been initialized - by the Open Firmware before the kernel boots. Scanout buffer, size, - and display format must be provided via device tree. - config DRM_PANEL_MIPI_DBI tristate "DRM support for MIPI DBI compatible panels" depends on DRM && SPI @@ -95,24 +81,6 @@ config DRM_PANEL_MIPI_DBI https://github.com/notro/panel-mipi-dbi/wiki. To compile this driver as a module, choose M here. -config DRM_SIMPLEDRM - tristate "Simple framebuffer driver" - depends on DRM && MMU - select APERTURE_HELPERS - select DRM_CLIENT_SELECTION - select DRM_GEM_SHMEM_HELPER - select DRM_KMS_HELPER - help - DRM driver for simple platform-provided framebuffers. - - This driver assumes that the display hardware has been initialized - by the firmware or bootloader before the kernel boots. Scanout - buffer, size, and display format must be provided via device tree, - UEFI, VESA, etc. - - On x86 BIOS or UEFI systems, you should also select SYSFB_SIMPLEFB - to use UEFI and VESA framebuffers. - config TINYDRM_HX8357D tristate "DRM support for HX8357D display panels" depends on DRM && SPI diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile index 0a3a7837a58b..ba4a60bb72bd 100644 --- a/drivers/gpu/drm/tiny/Makefile +++ b/drivers/gpu/drm/tiny/Makefile @@ -5,9 +5,7 @@ obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o obj-$(CONFIG_DRM_BOCHS) += bochs.o obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus-qemu.o obj-$(CONFIG_DRM_GM12U320) += gm12u320.o -obj-$(CONFIG_DRM_OFDRM) += ofdrm.o obj-$(CONFIG_DRM_PANEL_MIPI_DBI) += panel-mipi-dbi.o -obj-$(CONFIG_DRM_SIMPLEDRM) += simpledrm.o obj-$(CONFIG_TINYDRM_HX8357D) += hx8357d.o obj-$(CONFIG_TINYDRM_ILI9163) += ili9163.o obj-$(CONFIG_TINYDRM_ILI9225) += ili9225.o From patchwork Wed Mar 19 07:45:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022258 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 DD73BC35FFA for ; Wed, 19 Mar 2025 08:34:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48A4410E2EB; Wed, 19 Mar 2025 08:34:14 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 43C2810E232 for ; Wed, 19 Mar 2025 08:34:07 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C3A5721A22; Wed, 19 Mar 2025 08:33:53 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8CAAD13A38; Wed, 19 Mar 2025 08:33:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id cE0rIXGB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:53 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 05/18] drm/sysfb: Add struct drm_sysfb_device Date: Wed, 19 Mar 2025 08:45:04 +0100 Message-ID: <20250319083021.6472-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: C3A5721A22 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add struct drm_sysfb_device that stores the system display's hardware settings. Further helpers for the mode-setting pipeline will use these fields. Convert ofdrm and simpledrm by embedding the sysfb device in their device structs. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/Kconfig | 6 ++ drivers/gpu/drm/sysfb/Makefile | 2 + drivers/gpu/drm/sysfb/drm_sysfb_helper.c | 8 +++ drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 35 +++++++++ drivers/gpu/drm/sysfb/ofdrm.c | 78 ++++++++++---------- drivers/gpu/drm/sysfb/simpledrm.c | 90 ++++++++++++------------ 6 files changed, 135 insertions(+), 84 deletions(-) create mode 100644 drivers/gpu/drm/sysfb/drm_sysfb_helper.c create mode 100644 drivers/gpu/drm/sysfb/drm_sysfb_helper.h diff --git a/drivers/gpu/drm/sysfb/Kconfig b/drivers/gpu/drm/sysfb/Kconfig index 9eafc06b7192..87094da417f6 100644 --- a/drivers/gpu/drm/sysfb/Kconfig +++ b/drivers/gpu/drm/sysfb/Kconfig @@ -3,6 +3,10 @@ menu "Drivers for system framebuffers" depends on DRM +config DRM_SYSFB_HELPER + tristate + depends on DRM + config DRM_OFDRM tristate "Open Firmware display driver" depends on DRM && MMU && OF && (PPC || COMPILE_TEST) @@ -10,6 +14,7 @@ config DRM_OFDRM select DRM_CLIENT_SELECTION select DRM_GEM_SHMEM_HELPER select DRM_KMS_HELPER + select DRM_SYSFB_HELPER help DRM driver for Open Firmware framebuffers. @@ -24,6 +29,7 @@ config DRM_SIMPLEDRM select DRM_CLIENT_SELECTION select DRM_GEM_SHMEM_HELPER select DRM_KMS_HELPER + select DRM_SYSFB_HELPER help DRM driver for simple platform-provided framebuffers. diff --git a/drivers/gpu/drm/sysfb/Makefile b/drivers/gpu/drm/sysfb/Makefile index f6c03629accb..f1e8700c3e35 100644 --- a/drivers/gpu/drm/sysfb/Makefile +++ b/drivers/gpu/drm/sysfb/Makefile @@ -1,4 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_DRM_SYSFB_HELPER) += drm_sysfb_helper.o + obj-$(CONFIG_DRM_OFDRM) += ofdrm.o obj-$(CONFIG_DRM_SIMPLEDRM) += simpledrm.o diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c new file mode 100644 index 000000000000..c083d21fd9ca --- /dev/null +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include + +#include "drm_sysfb_helper.h" + +MODULE_DESCRIPTION("Helpers for DRM sysfb drivers"); +MODULE_LICENSE("GPL"); diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h new file mode 100644 index 000000000000..8f05eee7f49e --- /dev/null +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef DRM_SYSFB_HELPER_H +#define DRM_SYSFB_HELPER_H + +#include +#include + +#include +#include + +struct drm_format_info; + +/* + * Device + */ + +struct drm_sysfb_device { + struct drm_device dev; + + /* hardware settings */ + struct drm_display_mode fb_mode; + const struct drm_format_info *fb_format; + unsigned int fb_pitch; + + /* hardware-framebuffer kernel address */ + struct iosys_map fb_addr; +}; + +static inline struct drm_sysfb_device *to_drm_sysfb_device(struct drm_device *dev) +{ + return container_of(dev, struct drm_sysfb_device, dev); +} + +#endif diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c index 7d5beaf6a42c..d42704facb45 100644 --- a/drivers/gpu/drm/sysfb/ofdrm.c +++ b/drivers/gpu/drm/sysfb/ofdrm.c @@ -22,6 +22,8 @@ #include #include +#include "drm_sysfb_helper.h" + #define DRIVER_NAME "ofdrm" #define DRIVER_DESC "DRM driver for OF platform devices" #define DRIVER_MAJOR 1 @@ -289,16 +291,10 @@ struct ofdrm_device_funcs { }; struct ofdrm_device { - struct drm_device dev; + struct drm_sysfb_device sysfb; const struct ofdrm_device_funcs *funcs; - /* firmware-buffer settings */ - struct iosys_map screen_base; - struct drm_display_mode mode; - const struct drm_format_info *format; - unsigned int pitch; - /* colormap */ void __iomem *cmap_base; @@ -312,7 +308,7 @@ struct ofdrm_device { static struct ofdrm_device *ofdrm_device_of_dev(struct drm_device *dev) { - return container_of(dev, struct ofdrm_device, dev); + return container_of(to_drm_sysfb_device(dev), struct ofdrm_device, sysfb); } /* @@ -352,7 +348,7 @@ static void ofdrm_pci_release(void *data) static int ofdrm_device_init_pci(struct ofdrm_device *odev) { - struct drm_device *dev = &odev->dev; + struct drm_device *dev = &odev->sysfb.dev; struct platform_device *pdev = to_platform_device(dev->dev); struct device_node *of_node = pdev->dev.of_node; struct pci_dev *pcidev; @@ -395,7 +391,7 @@ static int ofdrm_device_init_pci(struct ofdrm_device *odev) static struct resource *ofdrm_find_fb_resource(struct ofdrm_device *odev, struct resource *fb_res) { - struct platform_device *pdev = to_platform_device(odev->dev.dev); + struct platform_device *pdev = to_platform_device(odev->sysfb.dev.dev); struct resource *res, *max_res = NULL; u32 i; @@ -421,7 +417,7 @@ static struct resource *ofdrm_find_fb_resource(struct ofdrm_device *odev, static void __iomem *get_cmap_address_of(struct ofdrm_device *odev, struct device_node *of_node, int bar_no, unsigned long offset, unsigned long size) { - struct drm_device *dev = &odev->dev; + struct drm_device *dev = &odev->sysfb.dev; const __be32 *addr_p; u64 max_size, address; unsigned int flags; @@ -454,7 +450,7 @@ static void __iomem *ofdrm_mach64_cmap_ioremap(struct ofdrm_device *odev, struct device_node *of_node, u64 fb_base) { - struct drm_device *dev = &odev->dev; + struct drm_device *dev = &odev->sysfb.dev; u64 address; void __iomem *cmap_base; @@ -616,7 +612,7 @@ static void __iomem *ofdrm_qemu_cmap_ioremap(struct ofdrm_device *odev, cpu_to_be32(0x00), }; - struct drm_device *dev = &odev->dev; + struct drm_device *dev = &odev->sysfb.dev; u64 address; void __iomem *cmap_base; @@ -646,7 +642,7 @@ static void ofdrm_qemu_cmap_write(struct ofdrm_device *odev, unsigned char index static void ofdrm_device_set_gamma_linear(struct ofdrm_device *odev, const struct drm_format_info *format) { - struct drm_device *dev = &odev->dev; + struct drm_device *dev = &odev->sysfb.dev; int i; switch (format->format) { @@ -685,7 +681,7 @@ static void ofdrm_device_set_gamma(struct ofdrm_device *odev, const struct drm_format_info *format, struct drm_color_lut *lut) { - struct drm_device *dev = &odev->dev; + struct drm_device *dev = &odev->sysfb.dev; int i; switch (format->format) { @@ -756,7 +752,7 @@ static int ofdrm_primary_plane_helper_atomic_check(struct drm_plane *plane, struct drm_atomic_state *new_state) { struct drm_device *dev = plane->dev; - struct ofdrm_device *odev = ofdrm_device_of_dev(dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(new_state, plane); struct drm_shadow_plane_state *new_shadow_plane_state = to_drm_shadow_plane_state(new_plane_state); @@ -778,12 +774,12 @@ static int ofdrm_primary_plane_helper_atomic_check(struct drm_plane *plane, else if (!new_plane_state->visible) return 0; - if (new_fb->format != odev->format) { + if (new_fb->format != sysfb->fb_format) { void *buf; /* format conversion necessary; reserve buffer */ buf = drm_format_conv_state_reserve(&new_shadow_plane_state->fmtcnv_state, - odev->pitch, GFP_KERNEL); + sysfb->fb_pitch, GFP_KERNEL); if (!buf) return -ENOMEM; } @@ -800,13 +796,13 @@ static void ofdrm_primary_plane_helper_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state) { struct drm_device *dev = plane->dev; - struct ofdrm_device *odev = ofdrm_device_of_dev(dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane); struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane); struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); struct drm_framebuffer *fb = plane_state->fb; - unsigned int dst_pitch = odev->pitch; - const struct drm_format_info *dst_format = odev->format; + unsigned int dst_pitch = sysfb->fb_pitch; + const struct drm_format_info *dst_format = sysfb->fb_format; struct drm_atomic_helper_damage_iter iter; struct drm_rect damage; int ret, idx; @@ -820,7 +816,7 @@ static void ofdrm_primary_plane_helper_atomic_update(struct drm_plane *plane, drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state); drm_atomic_for_each_plane_damage(&iter, &damage) { - struct iosys_map dst = odev->screen_base; + struct iosys_map dst = sysfb->fb_addr; struct drm_rect dst_clip = plane_state->dst; if (!drm_rect_intersect(&dst_clip, &damage)) @@ -840,12 +836,12 @@ static void ofdrm_primary_plane_helper_atomic_disable(struct drm_plane *plane, struct drm_atomic_state *state) { struct drm_device *dev = plane->dev; - struct ofdrm_device *odev = ofdrm_device_of_dev(dev); - struct iosys_map dst = odev->screen_base; + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); + struct iosys_map dst = sysfb->fb_addr; struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane); void __iomem *dst_vmap = dst.vaddr_iomem; /* TODO: Use mapping abstraction */ - unsigned int dst_pitch = odev->pitch; - const struct drm_format_info *dst_format = odev->format; + unsigned int dst_pitch = sysfb->fb_pitch; + const struct drm_format_info *dst_format = sysfb->fb_format; struct drm_rect dst_clip; unsigned long lines, linepixels, i; int idx; @@ -887,9 +883,9 @@ static const struct drm_plane_funcs ofdrm_primary_plane_funcs = { static enum drm_mode_status ofdrm_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode) { - struct ofdrm_device *odev = ofdrm_device_of_dev(crtc->dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(crtc->dev); - return drm_crtc_helper_mode_valid_fixed(crtc, mode, &odev->mode); + return drm_crtc_helper_mode_valid_fixed(crtc, mode, &sysfb->fb_mode); } static int ofdrm_crtc_helper_atomic_check(struct drm_crtc *crtc, @@ -1004,9 +1000,9 @@ static const struct drm_encoder_funcs ofdrm_encoder_funcs = { static int ofdrm_connector_helper_get_modes(struct drm_connector *connector) { - struct ofdrm_device *odev = ofdrm_device_of_dev(connector->dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(connector->dev); - return drm_connector_helper_get_modes_fixed(connector, &odev->mode); + return drm_connector_helper_get_modes_fixed(connector, &sysfb->fb_mode); } static const struct drm_connector_helper_funcs ofdrm_connector_helper_funcs = { @@ -1094,6 +1090,7 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, { struct device_node *of_node = pdev->dev.of_node; struct ofdrm_device *odev; + struct drm_sysfb_device *sysfb; struct drm_device *dev; enum ofdrm_model model; bool big_endian; @@ -1111,10 +1108,11 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, size_t nformats; int ret; - odev = devm_drm_dev_alloc(&pdev->dev, drv, struct ofdrm_device, dev); + odev = devm_drm_dev_alloc(&pdev->dev, drv, struct ofdrm_device, sysfb.dev); if (IS_ERR(odev)) return ERR_CAST(odev); - dev = &odev->dev; + sysfb = &odev->sysfb; + dev = &sysfb->dev; platform_set_drvdata(pdev, dev); ret = ofdrm_device_init_pci(odev); @@ -1252,12 +1250,12 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, * Firmware framebuffer */ - iosys_map_set_vaddr_iomem(&odev->screen_base, screen_base); - odev->mode = ofdrm_mode(width, height); - odev->format = format; - odev->pitch = linebytes; + iosys_map_set_vaddr_iomem(&sysfb->fb_addr, screen_base); + sysfb->fb_mode = ofdrm_mode(width, height); + sysfb->fb_format = format; + sysfb->fb_pitch = linebytes; - drm_dbg(dev, "display mode={" DRM_MODE_FMT "}\n", DRM_MODE_ARG(&odev->mode)); + drm_dbg(dev, "display mode={" DRM_MODE_FMT "}\n", DRM_MODE_ARG(&sysfb->fb_mode)); drm_dbg(dev, "framebuffer format=%p4cc, size=%dx%d, linebytes=%d byte\n", &format->format, width, height, linebytes); @@ -1362,19 +1360,21 @@ static struct drm_driver ofdrm_driver = { static int ofdrm_probe(struct platform_device *pdev) { struct ofdrm_device *odev; + struct drm_sysfb_device *sysfb; struct drm_device *dev; int ret; odev = ofdrm_device_create(&ofdrm_driver, pdev); if (IS_ERR(odev)) return PTR_ERR(odev); - dev = &odev->dev; + sysfb = &odev->sysfb; + dev = &sysfb->dev; ret = drm_dev_register(dev, 0); if (ret) return ret; - drm_client_setup(dev, odev->format); + drm_client_setup(dev, sysfb->fb_format); return 0; } diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c index d949713f5ff6..f258d8cdb6b6 100644 --- a/drivers/gpu/drm/sysfb/simpledrm.c +++ b/drivers/gpu/drm/sysfb/simpledrm.c @@ -29,6 +29,8 @@ #include #include +#include "drm_sysfb_helper.h" + #define DRIVER_NAME "simpledrm" #define DRIVER_DESC "DRM driver for simple-framebuffer platform devices" #define DRIVER_MAJOR 1 @@ -217,7 +219,7 @@ simplefb_get_memory_of(struct drm_device *dev, struct device_node *of_node) */ struct simpledrm_device { - struct drm_device dev; + struct drm_sysfb_device sysfb; /* clocks */ #if defined CONFIG_OF && defined CONFIG_COMMON_CLK @@ -236,14 +238,6 @@ struct simpledrm_device { struct device_link **pwr_dom_links; #endif - /* simplefb settings */ - struct drm_display_mode mode; - const struct drm_format_info *format; - unsigned int pitch; - - /* memory management */ - struct iosys_map screen_base; - /* modesetting */ uint32_t formats[8]; struct drm_plane primary_plane; @@ -254,7 +248,7 @@ struct simpledrm_device { static struct simpledrm_device *simpledrm_device_of_dev(struct drm_device *dev) { - return container_of(dev, struct simpledrm_device, dev); + return container_of(to_drm_sysfb_device(dev), struct simpledrm_device, sysfb); } /* @@ -296,7 +290,7 @@ static void simpledrm_device_release_clocks(void *res) static int simpledrm_device_init_clocks(struct simpledrm_device *sdev) { - struct drm_device *dev = &sdev->dev; + struct drm_device *dev = &sdev->sysfb.dev; struct platform_device *pdev = to_platform_device(dev->dev); struct device_node *of_node = pdev->dev.of_node; struct clk *clock; @@ -394,7 +388,7 @@ static void simpledrm_device_release_regulators(void *res) static int simpledrm_device_init_regulators(struct simpledrm_device *sdev) { - struct drm_device *dev = &sdev->dev; + struct drm_device *dev = &sdev->sysfb.dev; struct platform_device *pdev = to_platform_device(dev->dev); struct device_node *of_node = pdev->dev.of_node; struct property *prop; @@ -515,7 +509,7 @@ static void simpledrm_device_detach_genpd(void *res) static int simpledrm_device_attach_genpd(struct simpledrm_device *sdev) { - struct device *dev = sdev->dev.dev; + struct device *dev = sdev->sysfb.dev.dev; int i; sdev->pwr_dom_count = of_count_phandle_with_args(dev->of_node, "power-domains", @@ -547,7 +541,7 @@ static int simpledrm_device_attach_genpd(struct simpledrm_device *sdev) simpledrm_device_detach_genpd(sdev); return ret; } - drm_warn(&sdev->dev, + drm_warn(&sdev->sysfb.dev, "pm_domain_attach_by_id(%u) failed: %d\n", i, ret); continue; } @@ -558,7 +552,7 @@ static int simpledrm_device_attach_genpd(struct simpledrm_device *sdev) DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); if (!sdev->pwr_dom_links[i]) - drm_warn(&sdev->dev, "failed to link power-domain %d\n", i); + drm_warn(&sdev->sysfb.dev, "failed to link power-domain %d\n", i); } return devm_add_action_or_reset(dev, simpledrm_device_detach_genpd, sdev); @@ -589,7 +583,7 @@ static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane, struct drm_crtc *new_crtc = new_plane_state->crtc; struct drm_crtc_state *new_crtc_state = NULL; struct drm_device *dev = plane->dev; - struct simpledrm_device *sdev = simpledrm_device_of_dev(dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); int ret; if (new_crtc) @@ -604,12 +598,12 @@ static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane, else if (!new_plane_state->visible) return 0; - if (new_fb->format != sdev->format) { + if (new_fb->format != sysfb->fb_format) { void *buf; /* format conversion necessary; reserve buffer */ buf = drm_format_conv_state_reserve(&new_shadow_plane_state->fmtcnv_state, - sdev->pitch, GFP_KERNEL); + sysfb->fb_pitch, GFP_KERNEL); if (!buf) return -ENOMEM; } @@ -625,7 +619,7 @@ static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); struct drm_framebuffer *fb = plane_state->fb; struct drm_device *dev = plane->dev; - struct simpledrm_device *sdev = simpledrm_device_of_dev(dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); struct drm_atomic_helper_damage_iter iter; struct drm_rect damage; int ret, idx; @@ -640,13 +634,15 @@ static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state); drm_atomic_for_each_plane_damage(&iter, &damage) { struct drm_rect dst_clip = plane_state->dst; - struct iosys_map dst = sdev->screen_base; + struct iosys_map dst = sysfb->fb_addr; if (!drm_rect_intersect(&dst_clip, &damage)) continue; - iosys_map_incr(&dst, drm_fb_clip_offset(sdev->pitch, sdev->format, &dst_clip)); - drm_fb_blit(&dst, &sdev->pitch, sdev->format->format, shadow_plane_state->data, + iosys_map_incr(&dst, drm_fb_clip_offset(sysfb->fb_pitch, sysfb->fb_format, + &dst_clip)); + drm_fb_blit(&dst, &sysfb->fb_pitch, sysfb->fb_format->format, + shadow_plane_state->data, fb, &damage, &shadow_plane_state->fmtcnv_state); } @@ -659,14 +655,14 @@ static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *plan struct drm_atomic_state *state) { struct drm_device *dev = plane->dev; - struct simpledrm_device *sdev = simpledrm_device_of_dev(dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(plane->dev); int idx; if (!drm_dev_enter(dev, &idx)) return; /* Clear screen to black if disabled */ - iosys_map_memset(&sdev->screen_base, 0, 0, sdev->pitch * sdev->mode.vdisplay); + iosys_map_memset(&sysfb->fb_addr, 0, 0, sysfb->fb_pitch * sysfb->fb_mode.vdisplay); drm_dev_exit(idx); } @@ -674,13 +670,13 @@ static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *plan static int simpledrm_primary_plane_helper_get_scanout_buffer(struct drm_plane *plane, struct drm_scanout_buffer *sb) { - struct simpledrm_device *sdev = simpledrm_device_of_dev(plane->dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(plane->dev); - sb->width = sdev->mode.hdisplay; - sb->height = sdev->mode.vdisplay; - sb->format = sdev->format; - sb->pitch[0] = sdev->pitch; - sb->map[0] = sdev->screen_base; + sb->width = sysfb->fb_mode.hdisplay; + sb->height = sysfb->fb_mode.vdisplay; + sb->format = sysfb->fb_format; + sb->pitch[0] = sysfb->fb_pitch; + sb->map[0] = sysfb->fb_addr; return 0; } @@ -703,9 +699,9 @@ static const struct drm_plane_funcs simpledrm_primary_plane_funcs = { static enum drm_mode_status simpledrm_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode) { - struct simpledrm_device *sdev = simpledrm_device_of_dev(crtc->dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(crtc->dev); - return drm_crtc_helper_mode_valid_fixed(crtc, mode, &sdev->mode); + return drm_crtc_helper_mode_valid_fixed(crtc, mode, &sysfb->fb_mode); } /* @@ -733,9 +729,9 @@ static const struct drm_encoder_funcs simpledrm_encoder_funcs = { static int simpledrm_connector_helper_get_modes(struct drm_connector *connector) { - struct simpledrm_device *sdev = simpledrm_device_of_dev(connector->dev); + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(connector->dev); - return drm_connector_helper_get_modes_fixed(connector, &sdev->mode); + return drm_connector_helper_get_modes_fixed(connector, &sysfb->fb_mode); } static const struct drm_connector_helper_funcs simpledrm_connector_helper_funcs = { @@ -778,6 +774,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, const struct simplefb_platform_data *pd = dev_get_platdata(&pdev->dev); struct device_node *of_node = pdev->dev.of_node; struct simpledrm_device *sdev; + struct drm_sysfb_device *sysfb; struct drm_device *dev; int width, height, stride; int width_mm = 0, height_mm = 0; @@ -792,10 +789,11 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, size_t nformats; int ret; - sdev = devm_drm_dev_alloc(&pdev->dev, drv, struct simpledrm_device, dev); + sdev = devm_drm_dev_alloc(&pdev->dev, drv, struct simpledrm_device, sysfb.dev); if (IS_ERR(sdev)) return ERR_CAST(sdev); - dev = &sdev->dev; + sysfb = &sdev->sysfb; + dev = &sysfb->dev; platform_set_drvdata(pdev, sdev); /* @@ -866,11 +864,11 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, if (!height_mm) height_mm = DRM_MODE_RES_MM(height, 96ul); - sdev->mode = simpledrm_mode(width, height, width_mm, height_mm); - sdev->format = format; - sdev->pitch = stride; + sysfb->fb_mode = simpledrm_mode(width, height, width_mm, height_mm); + sysfb->fb_format = format; + sysfb->fb_pitch = stride; - drm_dbg(dev, "display mode={" DRM_MODE_FMT "}\n", DRM_MODE_ARG(&sdev->mode)); + drm_dbg(dev, "display mode={" DRM_MODE_FMT "}\n", DRM_MODE_ARG(&sysfb->fb_mode)); drm_dbg(dev, "framebuffer format=%p4cc, size=%dx%d, stride=%d byte\n", &format->format, width, height, stride); @@ -894,7 +892,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, if (IS_ERR(screen_base)) return screen_base; - iosys_map_set_vaddr(&sdev->screen_base, screen_base); + iosys_map_set_vaddr(&sysfb->fb_addr, screen_base); } else { void __iomem *screen_base; @@ -927,7 +925,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, if (!screen_base) return ERR_PTR(-ENOMEM); - iosys_map_set_vaddr_iomem(&sdev->screen_base, screen_base); + iosys_map_set_vaddr_iomem(&sysfb->fb_addr, screen_base); } /* @@ -1026,19 +1024,21 @@ static struct drm_driver simpledrm_driver = { static int simpledrm_probe(struct platform_device *pdev) { struct simpledrm_device *sdev; + struct drm_sysfb_device *sysfb; struct drm_device *dev; int ret; sdev = simpledrm_device_create(&simpledrm_driver, pdev); if (IS_ERR(sdev)) return PTR_ERR(sdev); - dev = &sdev->dev; + sysfb = &sdev->sysfb; + dev = &sysfb->dev; ret = drm_dev_register(dev, 0); if (ret) return ret; - drm_client_setup(dev, sdev->format); + drm_client_setup(dev, sdev->sysfb.fb_format); return 0; } @@ -1046,7 +1046,7 @@ static int simpledrm_probe(struct platform_device *pdev) static void simpledrm_remove(struct platform_device *pdev) { struct simpledrm_device *sdev = platform_get_drvdata(pdev); - struct drm_device *dev = &sdev->dev; + struct drm_device *dev = &sdev->sysfb.dev; drm_dev_unplug(dev); } From patchwork Wed Mar 19 07:45:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022259 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 0C6BEC36000 for ; Wed, 19 Mar 2025 08:34:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5954810E2ED; Wed, 19 Mar 2025 08:34:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="GeykS0a5"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="noD0ezDD"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="GeykS0a5"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="noD0ezDD"; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id EF04910E2EB for ; Wed, 19 Mar 2025 08:34:11 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 084051F842; Wed, 19 Mar 2025 08:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373234; 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=zCUpTQguZPkphpefLyu/RAFkbFGUntgaxK6dTDlbU64=; b=GeykS0a5zOCj52XmCRGtIGVpVhmFhupsm6gt98kFVOjoYWfqqFXni4+iXOIX15AnY3MwNF 7MF5TgjQDyyoJa4xSvACiQZo8v1741QT72k0OHiw8YkkGHdIPyDCKfL7Egb9BtAVfz76Tr uRtnNxgAb7+zqHdJuLOqFufnGjtdjVQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373234; 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=zCUpTQguZPkphpefLyu/RAFkbFGUntgaxK6dTDlbU64=; b=noD0ezDDbdqTX/C6Dil72lNUUaiKvWomllintihbJPNZ64r8VNta+n5+r22u4bXdGVpW1F BX5zHeBjCN/B/FDw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373234; 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=zCUpTQguZPkphpefLyu/RAFkbFGUntgaxK6dTDlbU64=; b=GeykS0a5zOCj52XmCRGtIGVpVhmFhupsm6gt98kFVOjoYWfqqFXni4+iXOIX15AnY3MwNF 7MF5TgjQDyyoJa4xSvACiQZo8v1741QT72k0OHiw8YkkGHdIPyDCKfL7Egb9BtAVfz76Tr uRtnNxgAb7+zqHdJuLOqFufnGjtdjVQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373234; 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=zCUpTQguZPkphpefLyu/RAFkbFGUntgaxK6dTDlbU64=; b=noD0ezDDbdqTX/C6Dil72lNUUaiKvWomllintihbJPNZ64r8VNta+n5+r22u4bXdGVpW1F BX5zHeBjCN/B/FDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C8D5213A2C; Wed, 19 Mar 2025 08:33:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 2GDEL3GB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:53 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 06/18] drm/sysfb: Provide single mode-init helper Date: Wed, 19 Mar 2025 08:45:05 +0100 Message-ID: <20250319083021.6472-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ffwll.ch,gmail.com,linux.intel.com,kernel.org]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Merge the mode-init functions of ofdrm and simpledrm to the new helper drm_sysfb_mode(). Also implement the DPI defaults there. Replace the code in each driver with the shared helper. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/drm_sysfb_helper.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 5 +++++ drivers/gpu/drm/sysfb/ofdrm.c | 17 +---------------- drivers/gpu/drm/sysfb/simpledrm.c | 23 +---------------------- 4 files changed, 31 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c index c083d21fd9ca..6deeac81a41d 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c @@ -6,3 +6,27 @@ MODULE_DESCRIPTION("Helpers for DRM sysfb drivers"); MODULE_LICENSE("GPL"); + +struct drm_display_mode drm_sysfb_mode(unsigned int width, + unsigned int height, + unsigned int width_mm, + unsigned int height_mm) +{ + /* + * Assume a monitor resolution of 96 dpi to + * get a somewhat reasonable screen size. + */ + if (!width_mm) + width_mm = DRM_MODE_RES_MM(width, 96ul); + if (!height_mm) + height_mm = DRM_MODE_RES_MM(height, 96ul); + + { + const struct drm_display_mode mode = { + DRM_MODE_INIT(60, width, height, width_mm, height_mm) + }; + + return mode; + } +} +EXPORT_SYMBOL(drm_sysfb_mode); diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h index 8f05eee7f49e..8b4cc4af702b 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h @@ -11,6 +11,11 @@ struct drm_format_info; +struct drm_display_mode drm_sysfb_mode(unsigned int width, + unsigned int height, + unsigned int width_mm, + unsigned int height_mm); + /* * Device */ diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c index d42704facb45..7df6901157fb 100644 --- a/drivers/gpu/drm/sysfb/ofdrm.c +++ b/drivers/gpu/drm/sysfb/ofdrm.c @@ -1070,21 +1070,6 @@ static const struct ofdrm_device_funcs ofdrm_qemu_device_funcs = { .cmap_write = ofdrm_qemu_cmap_write, }; -static struct drm_display_mode ofdrm_mode(unsigned int width, unsigned int height) -{ - /* - * Assume a monitor resolution of 96 dpi to - * get a somewhat reasonable screen size. - */ - const struct drm_display_mode mode = { - DRM_MODE_INIT(60, width, height, - DRM_MODE_RES_MM(width, 96ul), - DRM_MODE_RES_MM(height, 96ul)) - }; - - return mode; -} - static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, struct platform_device *pdev) { @@ -1251,7 +1236,7 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, */ iosys_map_set_vaddr_iomem(&sysfb->fb_addr, screen_base); - sysfb->fb_mode = ofdrm_mode(width, height); + sysfb->fb_mode = drm_sysfb_mode(width, height, 0, 0); sysfb->fb_format = format; sysfb->fb_pitch = linebytes; diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c index f258d8cdb6b6..149df6941b6c 100644 --- a/drivers/gpu/drm/sysfb/simpledrm.c +++ b/drivers/gpu/drm/sysfb/simpledrm.c @@ -756,18 +756,6 @@ static const struct drm_mode_config_funcs simpledrm_mode_config_funcs = { * Init / Cleanup */ -static struct drm_display_mode simpledrm_mode(unsigned int width, - unsigned int height, - unsigned int width_mm, - unsigned int height_mm) -{ - const struct drm_display_mode mode = { - DRM_MODE_INIT(60, width, height, width_mm, height_mm) - }; - - return mode; -} - static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, struct platform_device *pdev) { @@ -855,16 +843,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, return ERR_PTR(-EINVAL); } - /* - * Assume a monitor resolution of 96 dpi if physical dimensions - * are not specified to get a somewhat reasonable screen size. - */ - if (!width_mm) - width_mm = DRM_MODE_RES_MM(width, 96ul); - if (!height_mm) - height_mm = DRM_MODE_RES_MM(height, 96ul); - - sysfb->fb_mode = simpledrm_mode(width, height, width_mm, height_mm); + sysfb->fb_mode = drm_sysfb_mode(width, height, width_mm, height_mm); sysfb->fb_format = format; sysfb->fb_pitch = stride; From patchwork Wed Mar 19 07:45:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022261 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 49021C35FFA for ; Wed, 19 Mar 2025 08:34:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE9E810E2EC; Wed, 19 Mar 2025 08:34:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="TMuBk+31"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CDffV7Wz"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="TMuBk+31"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CDffV7Wz"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 46D8A10E2EB for ; Wed, 19 Mar 2025 08:34:11 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7CE7121A5D; Wed, 19 Mar 2025 08:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373234; 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=xAO+JsJMxWZgTnRVhxwjpgZeQwuEsPtNDoKpcxHqNVI=; b=TMuBk+318+IS1lDe3S9sTLCNEVdg/qg4pRWDKX1hrzy1R7mS+czNeMeJOfoivnH7UClali y6hjQ9YIMiUXZhQCztBpgVo/ILM/TXKTV5+LweVdzYT2NNxv7yN7EdvRPOdUBDR3hK5LZf zPhAzmzca/5OHbZmcPUJYSn/siVj2Ts= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373234; 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=xAO+JsJMxWZgTnRVhxwjpgZeQwuEsPtNDoKpcxHqNVI=; b=CDffV7Wzay8WPelc9c5y7hNmNRBsZ88V31pBSHeWcsVbqBkbYTK+3t9lk+HTCpRB3F5WQn Xt3Rp8AWcfgnUaBA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373234; 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=xAO+JsJMxWZgTnRVhxwjpgZeQwuEsPtNDoKpcxHqNVI=; b=TMuBk+318+IS1lDe3S9sTLCNEVdg/qg4pRWDKX1hrzy1R7mS+czNeMeJOfoivnH7UClali y6hjQ9YIMiUXZhQCztBpgVo/ILM/TXKTV5+LweVdzYT2NNxv7yN7EdvRPOdUBDR3hK5LZf zPhAzmzca/5OHbZmcPUJYSn/siVj2Ts= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373234; 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=xAO+JsJMxWZgTnRVhxwjpgZeQwuEsPtNDoKpcxHqNVI=; b=CDffV7Wzay8WPelc9c5y7hNmNRBsZ88V31pBSHeWcsVbqBkbYTK+3t9lk+HTCpRB3F5WQn Xt3Rp8AWcfgnUaBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 18FC913A38; Wed, 19 Mar 2025 08:33:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8LrmBHKB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:54 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 07/18] drm/sysfb: Merge mode-config functions Date: Wed, 19 Mar 2025 08:45:06 +0100 Message-ID: <20250319083021.6472-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ffwll.ch,gmail.com,linux.intel.com,kernel.org]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Provide initializer to set struct drm_mode_config_funcs. Convert ofdrm and simpledrm. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 9 +++++++++ drivers/gpu/drm/sysfb/ofdrm.c | 4 +--- drivers/gpu/drm/sysfb/simpledrm.c | 4 +--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h index 8b4cc4af702b..cf80b291014a 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h @@ -37,4 +37,13 @@ static inline struct drm_sysfb_device *to_drm_sysfb_device(struct drm_device *de return container_of(dev, struct drm_sysfb_device, dev); } +/* + * Mode config + */ + +#define DRM_SYSFB_MODE_CONFIG_FUNCS \ + .fb_create = drm_gem_fb_create_with_dirty, \ + .atomic_check = drm_atomic_helper_check, \ + .atomic_commit = drm_atomic_helper_commit + #endif diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c index 7df6901157fb..470b93f0f791 100644 --- a/drivers/gpu/drm/sysfb/ofdrm.c +++ b/drivers/gpu/drm/sysfb/ofdrm.c @@ -1018,9 +1018,7 @@ static const struct drm_connector_funcs ofdrm_connector_funcs = { }; static const struct drm_mode_config_funcs ofdrm_mode_config_funcs = { - .fb_create = drm_gem_fb_create_with_dirty, - .atomic_check = drm_atomic_helper_check, - .atomic_commit = drm_atomic_helper_commit, + DRM_SYSFB_MODE_CONFIG_FUNCS, }; /* diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c index 149df6941b6c..0cee8e1b2108 100644 --- a/drivers/gpu/drm/sysfb/simpledrm.c +++ b/drivers/gpu/drm/sysfb/simpledrm.c @@ -747,9 +747,7 @@ static const struct drm_connector_funcs simpledrm_connector_funcs = { }; static const struct drm_mode_config_funcs simpledrm_mode_config_funcs = { - .fb_create = drm_gem_fb_create_with_dirty, - .atomic_check = drm_atomic_helper_check, - .atomic_commit = drm_atomic_helper_commit, + DRM_SYSFB_MODE_CONFIG_FUNCS, }; /* From patchwork Wed Mar 19 07:45:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022262 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 27561C36002 for ; Wed, 19 Mar 2025 08:34:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 042C210E2F0; Wed, 19 Mar 2025 08:34:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="kTf9Zzh9"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="omOp+j3B"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kTf9Zzh9"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="omOp+j3B"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6FE3C10E2ED for ; Wed, 19 Mar 2025 08:34:15 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D19C821A9F; Wed, 19 Mar 2025 08:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373234; 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=zbkoLSIfGz3AjAwgE0bvmRfP464GXqdScQJ9OTaCgDg=; b=kTf9Zzh9VdqK9/46yTQ93NMKo6iw8Feod5ehQDwB5gMhE61r13mXT/YOpFPHQS+1yuqMBg Q96rKsgvPorpBl4dbDWXeRieQWvUL93EDHTAKTKtOJUPmNCEK8DiVXjg3SSaxt4vRU4gzT mpNepGToq1ALqv7nTqABixUc7g3js+Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373234; 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=zbkoLSIfGz3AjAwgE0bvmRfP464GXqdScQJ9OTaCgDg=; b=omOp+j3BLvHvnLFo13zXVARh3pNjynCluM7GkZ0l6WrKDokMwx/j07IJOUGaRWCkBB7a6+ aWl0jVcm8eg7PrCQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373234; 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=zbkoLSIfGz3AjAwgE0bvmRfP464GXqdScQJ9OTaCgDg=; b=kTf9Zzh9VdqK9/46yTQ93NMKo6iw8Feod5ehQDwB5gMhE61r13mXT/YOpFPHQS+1yuqMBg Q96rKsgvPorpBl4dbDWXeRieQWvUL93EDHTAKTKtOJUPmNCEK8DiVXjg3SSaxt4vRU4gzT mpNepGToq1ALqv7nTqABixUc7g3js+Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373234; 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=zbkoLSIfGz3AjAwgE0bvmRfP464GXqdScQJ9OTaCgDg=; b=omOp+j3BLvHvnLFo13zXVARh3pNjynCluM7GkZ0l6WrKDokMwx/j07IJOUGaRWCkBB7a6+ aWl0jVcm8eg7PrCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8118613A2C; Wed, 19 Mar 2025 08:33:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id GPBHHnKB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:54 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 08/18] drm/sysfb: Merge connector functions Date: Wed, 19 Mar 2025 08:45:07 +0100 Message-ID: <20250319083021.6472-9-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ffwll.ch,gmail.com,linux.intel.com,kernel.org]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Merge the connector functions of ofdrm and simpledrm. Replace the code in each driver with the shared helpers. Set up callbacks with initializer macros. No effective code changes. The sysfb connector only returns the preconfigured display mode. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/drm_sysfb_helper.c | 14 ++++++++++++++ drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 15 +++++++++++++++ drivers/gpu/drm/sysfb/ofdrm.c | 14 ++------------ drivers/gpu/drm/sysfb/simpledrm.c | 14 ++------------ 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c index 6deeac81a41d..355e025c7c62 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c @@ -2,6 +2,8 @@ #include +#include + #include "drm_sysfb_helper.h" MODULE_DESCRIPTION("Helpers for DRM sysfb drivers"); @@ -30,3 +32,15 @@ struct drm_display_mode drm_sysfb_mode(unsigned int width, } } EXPORT_SYMBOL(drm_sysfb_mode); + +/* + * Connector + */ + +int drm_sysfb_connector_helper_get_modes(struct drm_connector *connector) +{ + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(connector->dev); + + return drm_connector_helper_get_modes_fixed(connector, &sysfb->fb_mode); +} +EXPORT_SYMBOL(drm_sysfb_connector_helper_get_modes); diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h index cf80b291014a..7e3fe9fa5cff 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h @@ -37,6 +37,21 @@ static inline struct drm_sysfb_device *to_drm_sysfb_device(struct drm_device *de return container_of(dev, struct drm_sysfb_device, dev); } +/* + * Connector + */ + +int drm_sysfb_connector_helper_get_modes(struct drm_connector *connector); + +#define DRM_SYSFB_CONNECTOR_HELPER_FUNCS \ + .get_modes = drm_sysfb_connector_helper_get_modes + +#define DRM_SYSFB_CONNECTOR_FUNCS \ + .reset = drm_atomic_helper_connector_reset, \ + .fill_modes = drm_helper_probe_single_connector_modes, \ + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, \ + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state + /* * Mode config */ diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c index 470b93f0f791..85db7441d1bf 100644 --- a/drivers/gpu/drm/sysfb/ofdrm.c +++ b/drivers/gpu/drm/sysfb/ofdrm.c @@ -998,23 +998,13 @@ static const struct drm_encoder_funcs ofdrm_encoder_funcs = { .destroy = drm_encoder_cleanup, }; -static int ofdrm_connector_helper_get_modes(struct drm_connector *connector) -{ - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(connector->dev); - - return drm_connector_helper_get_modes_fixed(connector, &sysfb->fb_mode); -} - static const struct drm_connector_helper_funcs ofdrm_connector_helper_funcs = { - .get_modes = ofdrm_connector_helper_get_modes, + DRM_SYSFB_CONNECTOR_HELPER_FUNCS, }; static const struct drm_connector_funcs ofdrm_connector_funcs = { - .reset = drm_atomic_helper_connector_reset, - .fill_modes = drm_helper_probe_single_connector_modes, + DRM_SYSFB_CONNECTOR_FUNCS, .destroy = drm_connector_cleanup, - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; static const struct drm_mode_config_funcs ofdrm_mode_config_funcs = { diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c index 0cee8e1b2108..6d76d125d126 100644 --- a/drivers/gpu/drm/sysfb/simpledrm.c +++ b/drivers/gpu/drm/sysfb/simpledrm.c @@ -727,23 +727,13 @@ static const struct drm_encoder_funcs simpledrm_encoder_funcs = { .destroy = drm_encoder_cleanup, }; -static int simpledrm_connector_helper_get_modes(struct drm_connector *connector) -{ - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(connector->dev); - - return drm_connector_helper_get_modes_fixed(connector, &sysfb->fb_mode); -} - static const struct drm_connector_helper_funcs simpledrm_connector_helper_funcs = { - .get_modes = simpledrm_connector_helper_get_modes, + DRM_SYSFB_CONNECTOR_HELPER_FUNCS, }; static const struct drm_connector_funcs simpledrm_connector_funcs = { - .reset = drm_atomic_helper_connector_reset, - .fill_modes = drm_helper_probe_single_connector_modes, + DRM_SYSFB_CONNECTOR_FUNCS, .destroy = drm_connector_cleanup, - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; static const struct drm_mode_config_funcs simpledrm_mode_config_funcs = { From patchwork Wed Mar 19 07:45:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022260 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 4219BC35FFF for ; Wed, 19 Mar 2025 08:34:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 84F0910E2EE; Wed, 19 Mar 2025 08:34:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="kf/QqXuZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="JfuLXd9/"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kf/QqXuZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="JfuLXd9/"; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7479C10E2ED for ; Wed, 19 Mar 2025 08:34:16 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5842D1F890; Wed, 19 Mar 2025 08:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373235; 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=k3O/o5ACSEd0uAUZkX1hzXCwDcmZjeMZ1XBgy+kE9s4=; b=kf/QqXuZ45lMkbEWqlcJiQEIKyYSLFBL6DKl/kTpZ1tqiXt8eec1PO2aTTzkjarbktMUsu jQNt7hSJ6iaV3qe1r25YsZzj7MwhirVBQ5JuXYoyNIoYwH3oBNS2Q0kN2Za4FCv9EMo/lA oZNxQK26/mVvMu7oiTEgcRq5rWkcln4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373235; 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=k3O/o5ACSEd0uAUZkX1hzXCwDcmZjeMZ1XBgy+kE9s4=; b=JfuLXd9/lMnDZC7xvnyZl1TDNmfXYgTSNU8jAIuAispq9XMiTCtvJh+o/ohybmRvhk/MVx LBAriMopW7vD14Dg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373235; 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=k3O/o5ACSEd0uAUZkX1hzXCwDcmZjeMZ1XBgy+kE9s4=; b=kf/QqXuZ45lMkbEWqlcJiQEIKyYSLFBL6DKl/kTpZ1tqiXt8eec1PO2aTTzkjarbktMUsu jQNt7hSJ6iaV3qe1r25YsZzj7MwhirVBQ5JuXYoyNIoYwH3oBNS2Q0kN2Za4FCv9EMo/lA oZNxQK26/mVvMu7oiTEgcRq5rWkcln4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373235; 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=k3O/o5ACSEd0uAUZkX1hzXCwDcmZjeMZ1XBgy+kE9s4=; b=JfuLXd9/lMnDZC7xvnyZl1TDNmfXYgTSNU8jAIuAispq9XMiTCtvJh+o/ohybmRvhk/MVx LBAriMopW7vD14Dg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E5C4D13A38; Wed, 19 Mar 2025 08:33:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8LnJNnKB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:54 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 09/18] drm/sysfb: Maintain CRTC state in struct drm_sysfb_crtc_state Date: Wed, 19 Mar 2025 08:45:08 +0100 Message-ID: <20250319083021.6472-10-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ffwll.ch,gmail.com,linux.intel.com,kernel.org]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move ofdrm's struct ofdrm_crtc_state plus functions to sysfb helpers and rename everything to drm_sysfb_crtc_state. The sysfb CRTC state is a regular CRTC state with information on the primary plane's color format, as required for color management. Helpers for sysfb planes will later set this up automatically. In ofdrm and simpledrm, replace existing code with the new helpers. Ofdrm continues to use the CRTC state for color management. This has no effect on simpledrm. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/drm_sysfb_helper.c | 59 ++++++++++++++++++ drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 29 +++++++++ drivers/gpu/drm/sysfb/ofdrm.c | 76 ++---------------------- drivers/gpu/drm/sysfb/simpledrm.c | 6 +- 4 files changed, 95 insertions(+), 75 deletions(-) diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c index 355e025c7c62..368061b6f514 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c @@ -1,7 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-only +#include +#include #include +#include +#include #include #include "drm_sysfb_helper.h" @@ -33,6 +37,61 @@ struct drm_display_mode drm_sysfb_mode(unsigned int width, } EXPORT_SYMBOL(drm_sysfb_mode); +/* + * CRTC + */ + +static void drm_sysfb_crtc_state_destroy(struct drm_sysfb_crtc_state *sysfb_crtc_state) +{ + __drm_atomic_helper_crtc_destroy_state(&sysfb_crtc_state->base); + + kfree(sysfb_crtc_state); +} + +void drm_sysfb_crtc_reset(struct drm_crtc *crtc) +{ + struct drm_sysfb_crtc_state *sysfb_crtc_state; + + if (crtc->state) + drm_sysfb_crtc_state_destroy(to_drm_sysfb_crtc_state(crtc->state)); + + sysfb_crtc_state = kzalloc(sizeof(*sysfb_crtc_state), GFP_KERNEL); + if (sysfb_crtc_state) + __drm_atomic_helper_crtc_reset(crtc, &sysfb_crtc_state->base); + else + __drm_atomic_helper_crtc_reset(crtc, NULL); +} +EXPORT_SYMBOL(drm_sysfb_crtc_reset); + +struct drm_crtc_state *drm_sysfb_crtc_atomic_duplicate_state(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + struct drm_crtc_state *crtc_state = crtc->state; + struct drm_sysfb_crtc_state *new_sysfb_crtc_state; + struct drm_sysfb_crtc_state *sysfb_crtc_state; + + if (drm_WARN_ON(dev, !crtc_state)) + return NULL; + + new_sysfb_crtc_state = kzalloc(sizeof(*new_sysfb_crtc_state), GFP_KERNEL); + if (!new_sysfb_crtc_state) + return NULL; + + sysfb_crtc_state = to_drm_sysfb_crtc_state(crtc_state); + + __drm_atomic_helper_crtc_duplicate_state(crtc, &new_sysfb_crtc_state->base); + new_sysfb_crtc_state->format = sysfb_crtc_state->format; + + return &new_sysfb_crtc_state->base; +} +EXPORT_SYMBOL(drm_sysfb_crtc_atomic_duplicate_state); + +void drm_sysfb_crtc_atomic_destroy_state(struct drm_crtc *crtc, struct drm_crtc_state *crtc_state) +{ + drm_sysfb_crtc_state_destroy(to_drm_sysfb_crtc_state(crtc_state)); +} +EXPORT_SYMBOL(drm_sysfb_crtc_atomic_destroy_state); + /* * Connector */ diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h index 7e3fe9fa5cff..91da27405a46 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -37,6 +38,34 @@ static inline struct drm_sysfb_device *to_drm_sysfb_device(struct drm_device *de return container_of(dev, struct drm_sysfb_device, dev); } +/* + * CRTC + */ + +struct drm_sysfb_crtc_state { + struct drm_crtc_state base; + + /* Primary-plane format; required for color mgmt. */ + const struct drm_format_info *format; +}; + +static inline struct drm_sysfb_crtc_state * +to_drm_sysfb_crtc_state(struct drm_crtc_state *base) +{ + return container_of(base, struct drm_sysfb_crtc_state, base); +} + +void drm_sysfb_crtc_reset(struct drm_crtc *crtc); +struct drm_crtc_state *drm_sysfb_crtc_atomic_duplicate_state(struct drm_crtc *crtc); +void drm_sysfb_crtc_atomic_destroy_state(struct drm_crtc *crtc, struct drm_crtc_state *crtc_state); + +#define DRM_SYSFB_CRTC_FUNCS \ + .reset = drm_sysfb_crtc_reset, \ + .set_config = drm_atomic_helper_set_config, \ + .page_flip = drm_atomic_helper_page_flip, \ + .atomic_duplicate_state = drm_sysfb_crtc_atomic_duplicate_state, \ + .atomic_destroy_state = drm_sysfb_crtc_atomic_destroy_state + /* * Connector */ diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c index 85db7441d1bf..faaf35ba17f3 100644 --- a/drivers/gpu/drm/sysfb/ofdrm.c +++ b/drivers/gpu/drm/sysfb/ofdrm.c @@ -725,24 +725,6 @@ static void ofdrm_device_set_gamma(struct ofdrm_device *odev, * Modesetting */ -struct ofdrm_crtc_state { - struct drm_crtc_state base; - - /* Primary-plane format; required for color mgmt. */ - const struct drm_format_info *format; -}; - -static struct ofdrm_crtc_state *to_ofdrm_crtc_state(struct drm_crtc_state *base) -{ - return container_of(base, struct ofdrm_crtc_state, base); -} - -static void ofdrm_crtc_state_destroy(struct ofdrm_crtc_state *ofdrm_crtc_state) -{ - __drm_atomic_helper_crtc_destroy_state(&ofdrm_crtc_state->base); - kfree(ofdrm_crtc_state); -} - static const uint64_t ofdrm_primary_plane_format_modifiers[] = { DRM_FORMAT_MOD_LINEAR, DRM_FORMAT_MOD_INVALID @@ -759,7 +741,7 @@ static int ofdrm_primary_plane_helper_atomic_check(struct drm_plane *plane, struct drm_framebuffer *new_fb = new_plane_state->fb; struct drm_crtc *new_crtc = new_plane_state->crtc; struct drm_crtc_state *new_crtc_state = NULL; - struct ofdrm_crtc_state *new_ofdrm_crtc_state; + struct drm_sysfb_crtc_state *new_sysfb_crtc_state; int ret; if (new_crtc) @@ -786,8 +768,8 @@ static int ofdrm_primary_plane_helper_atomic_check(struct drm_plane *plane, new_crtc_state = drm_atomic_get_new_crtc_state(new_state, new_plane_state->crtc); - new_ofdrm_crtc_state = to_ofdrm_crtc_state(new_crtc_state); - new_ofdrm_crtc_state->format = new_fb->format; + new_sysfb_crtc_state = to_drm_sysfb_crtc_state(new_crtc_state); + new_sysfb_crtc_state->format = new_fb->format; return 0; } @@ -920,10 +902,10 @@ static void ofdrm_crtc_helper_atomic_flush(struct drm_crtc *crtc, struct drm_ato { struct ofdrm_device *odev = ofdrm_device_of_dev(crtc->dev); struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc); - struct ofdrm_crtc_state *ofdrm_crtc_state = to_ofdrm_crtc_state(crtc_state); + struct drm_sysfb_crtc_state *sysfb_crtc_state = to_drm_sysfb_crtc_state(crtc_state); if (crtc_state->enable && crtc_state->color_mgmt_changed) { - const struct drm_format_info *format = ofdrm_crtc_state->format; + const struct drm_format_info *format = sysfb_crtc_state->format; if (crtc_state->gamma_lut) ofdrm_device_set_gamma(odev, format, crtc_state->gamma_lut->data); @@ -943,55 +925,9 @@ static const struct drm_crtc_helper_funcs ofdrm_crtc_helper_funcs = { .atomic_flush = ofdrm_crtc_helper_atomic_flush, }; -static void ofdrm_crtc_reset(struct drm_crtc *crtc) -{ - struct ofdrm_crtc_state *ofdrm_crtc_state = - kzalloc(sizeof(*ofdrm_crtc_state), GFP_KERNEL); - - if (crtc->state) - ofdrm_crtc_state_destroy(to_ofdrm_crtc_state(crtc->state)); - - if (ofdrm_crtc_state) - __drm_atomic_helper_crtc_reset(crtc, &ofdrm_crtc_state->base); - else - __drm_atomic_helper_crtc_reset(crtc, NULL); -} - -static struct drm_crtc_state *ofdrm_crtc_atomic_duplicate_state(struct drm_crtc *crtc) -{ - struct drm_device *dev = crtc->dev; - struct drm_crtc_state *crtc_state = crtc->state; - struct ofdrm_crtc_state *new_ofdrm_crtc_state; - struct ofdrm_crtc_state *ofdrm_crtc_state; - - if (drm_WARN_ON(dev, !crtc_state)) - return NULL; - - new_ofdrm_crtc_state = kzalloc(sizeof(*new_ofdrm_crtc_state), GFP_KERNEL); - if (!new_ofdrm_crtc_state) - return NULL; - - ofdrm_crtc_state = to_ofdrm_crtc_state(crtc_state); - - __drm_atomic_helper_crtc_duplicate_state(crtc, &new_ofdrm_crtc_state->base); - new_ofdrm_crtc_state->format = ofdrm_crtc_state->format; - - return &new_ofdrm_crtc_state->base; -} - -static void ofdrm_crtc_atomic_destroy_state(struct drm_crtc *crtc, - struct drm_crtc_state *crtc_state) -{ - ofdrm_crtc_state_destroy(to_ofdrm_crtc_state(crtc_state)); -} - static const struct drm_crtc_funcs ofdrm_crtc_funcs = { - .reset = ofdrm_crtc_reset, + DRM_SYSFB_CRTC_FUNCS, .destroy = drm_crtc_cleanup, - .set_config = drm_atomic_helper_set_config, - .page_flip = drm_atomic_helper_page_flip, - .atomic_duplicate_state = ofdrm_crtc_atomic_duplicate_state, - .atomic_destroy_state = ofdrm_crtc_atomic_destroy_state, }; static const struct drm_encoder_funcs ofdrm_encoder_funcs = { diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c index 6d76d125d126..986177e4a0f0 100644 --- a/drivers/gpu/drm/sysfb/simpledrm.c +++ b/drivers/gpu/drm/sysfb/simpledrm.c @@ -715,12 +715,8 @@ static const struct drm_crtc_helper_funcs simpledrm_crtc_helper_funcs = { }; static const struct drm_crtc_funcs simpledrm_crtc_funcs = { - .reset = drm_atomic_helper_crtc_reset, + DRM_SYSFB_CRTC_FUNCS, .destroy = drm_crtc_cleanup, - .set_config = drm_atomic_helper_set_config, - .page_flip = drm_atomic_helper_page_flip, - .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, }; static const struct drm_encoder_funcs simpledrm_encoder_funcs = { From patchwork Wed Mar 19 07:45:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022265 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 7F248C36001 for ; Wed, 19 Mar 2025 08:34:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D054310E2F4; Wed, 19 Mar 2025 08:34:26 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4C8CA10E23C for ; Wed, 19 Mar 2025 08:34:20 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EE5351FC0D; Wed, 19 Mar 2025 08:33:55 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5F18613A2C; Wed, 19 Mar 2025 08:33:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id cEfxFXOB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:55 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 10/18] drm/sysfb: Merge CRTC functions Date: Wed, 19 Mar 2025 08:45:09 +0100 Message-ID: <20250319083021.6472-11-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: EE5351FC0D X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Merge the CRTC functions of ofdrm and simpledrm. Replace the code in each driver with the shared helpers. Set up callbacks with initializer macros. Ofdrm supports a gamma LUT, while simpledrm does not. So far ofdrm's LUT size has been hard-coded in the driver CRTC's atomic_check helper. Now pass the size of the LUT to the sysfb device. Ofdrm's custom atomic_flush is still required to apply changes to the LUT. Simpledrm passes a LUT size of 0, which disables the gamma LUT. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/drm_sysfb_helper.c | 40 ++++++++++++++++++ drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 9 ++++ drivers/gpu/drm/sysfb/ofdrm.c | 53 ++++-------------------- drivers/gpu/drm/sysfb/simpledrm.c | 17 +------- 4 files changed, 57 insertions(+), 62 deletions(-) diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c index 368061b6f514..ed9139f56e59 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c @@ -4,6 +4,8 @@ #include #include +#include +#include #include #include #include @@ -48,6 +50,44 @@ static void drm_sysfb_crtc_state_destroy(struct drm_sysfb_crtc_state *sysfb_crtc kfree(sysfb_crtc_state); } +enum drm_mode_status drm_sysfb_crtc_helper_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode) +{ + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(crtc->dev); + + return drm_crtc_helper_mode_valid_fixed(crtc, mode, &sysfb->fb_mode); +} +EXPORT_SYMBOL(drm_sysfb_crtc_helper_mode_valid); + +int drm_sysfb_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *new_state) +{ + struct drm_device *dev = crtc->dev; + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); + struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(new_state, crtc); + int ret; + + if (!new_crtc_state->enable) + return 0; + + ret = drm_atomic_helper_check_crtc_primary_plane(new_crtc_state); + if (ret) + return ret; + + if (new_crtc_state->color_mgmt_changed) { + const size_t gamma_lut_length = + sysfb->fb_gamma_lut_size * sizeof(struct drm_color_lut); + const struct drm_property_blob *gamma_lut = new_crtc_state->gamma_lut; + + if (gamma_lut && (gamma_lut->length != gamma_lut_length)) { + drm_dbg(dev, "Incorrect gamma_lut length %zu\n", gamma_lut->length); + return -EINVAL; + } + } + + return 0; +} +EXPORT_SYMBOL(drm_sysfb_crtc_helper_atomic_check); + void drm_sysfb_crtc_reset(struct drm_crtc *crtc) { struct drm_sysfb_crtc_state *sysfb_crtc_state; diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h index 91da27405a46..c8e5ac6b9b63 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h @@ -28,6 +28,7 @@ struct drm_sysfb_device { struct drm_display_mode fb_mode; const struct drm_format_info *fb_format; unsigned int fb_pitch; + unsigned int fb_gamma_lut_size; /* hardware-framebuffer kernel address */ struct iosys_map fb_addr; @@ -55,6 +56,14 @@ to_drm_sysfb_crtc_state(struct drm_crtc_state *base) return container_of(base, struct drm_sysfb_crtc_state, base); } +enum drm_mode_status drm_sysfb_crtc_helper_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode); +int drm_sysfb_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *new_state); + +#define DRM_SYSFB_CRTC_HELPER_FUNCS \ + .mode_valid = drm_sysfb_crtc_helper_mode_valid, \ + .atomic_check = drm_sysfb_crtc_helper_atomic_check + void drm_sysfb_crtc_reset(struct drm_crtc *crtc); struct drm_crtc_state *drm_sysfb_crtc_atomic_duplicate_state(struct drm_crtc *crtc); void drm_sysfb_crtc_atomic_destroy_state(struct drm_crtc *crtc, struct drm_crtc_state *crtc_state); diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c index faaf35ba17f3..29dbb69dd7ac 100644 --- a/drivers/gpu/drm/sysfb/ofdrm.c +++ b/drivers/gpu/drm/sysfb/ofdrm.c @@ -862,42 +862,6 @@ static const struct drm_plane_funcs ofdrm_primary_plane_funcs = { DRM_GEM_SHADOW_PLANE_FUNCS, }; -static enum drm_mode_status ofdrm_crtc_helper_mode_valid(struct drm_crtc *crtc, - const struct drm_display_mode *mode) -{ - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(crtc->dev); - - return drm_crtc_helper_mode_valid_fixed(crtc, mode, &sysfb->fb_mode); -} - -static int ofdrm_crtc_helper_atomic_check(struct drm_crtc *crtc, - struct drm_atomic_state *new_state) -{ - static const size_t gamma_lut_length = OFDRM_GAMMA_LUT_SIZE * sizeof(struct drm_color_lut); - - struct drm_device *dev = crtc->dev; - struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(new_state, crtc); - int ret; - - if (!new_crtc_state->enable) - return 0; - - ret = drm_atomic_helper_check_crtc_primary_plane(new_crtc_state); - if (ret) - return ret; - - if (new_crtc_state->color_mgmt_changed) { - struct drm_property_blob *gamma_lut = new_crtc_state->gamma_lut; - - if (gamma_lut && (gamma_lut->length != gamma_lut_length)) { - drm_dbg(dev, "Incorrect gamma_lut length %zu\n", gamma_lut->length); - return -EINVAL; - } - } - - return 0; -} - static void ofdrm_crtc_helper_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_state *state) { struct ofdrm_device *odev = ofdrm_device_of_dev(crtc->dev); @@ -914,14 +878,8 @@ static void ofdrm_crtc_helper_atomic_flush(struct drm_crtc *crtc, struct drm_ato } } -/* - * The CRTC is always enabled. Screen updates are performed by - * the primary plane's atomic_update function. Disabling clears - * the screen in the primary plane's atomic_disable function. - */ static const struct drm_crtc_helper_funcs ofdrm_crtc_helper_funcs = { - .mode_valid = ofdrm_crtc_helper_mode_valid, - .atomic_check = ofdrm_crtc_helper_atomic_check, + DRM_SYSFB_CRTC_HELPER_FUNCS, .atomic_flush = ofdrm_crtc_helper_atomic_flush, }; @@ -1163,6 +1121,8 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, sysfb->fb_mode = drm_sysfb_mode(width, height, 0, 0); sysfb->fb_format = format; sysfb->fb_pitch = linebytes; + if (odev->cmap_base) + sysfb->fb_gamma_lut_size = OFDRM_GAMMA_LUT_SIZE; drm_dbg(dev, "display mode={" DRM_MODE_FMT "}\n", DRM_MODE_ARG(&sysfb->fb_mode)); drm_dbg(dev, "framebuffer format=%p4cc, size=%dx%d, linebytes=%d byte\n", @@ -1211,9 +1171,10 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, return ERR_PTR(ret); drm_crtc_helper_add(crtc, &ofdrm_crtc_helper_funcs); - if (odev->cmap_base) { - drm_mode_crtc_set_gamma_size(crtc, OFDRM_GAMMA_LUT_SIZE); - drm_crtc_enable_color_mgmt(crtc, 0, false, OFDRM_GAMMA_LUT_SIZE); + if (sysfb->fb_gamma_lut_size) { + ret = drm_mode_crtc_set_gamma_size(crtc, sysfb->fb_gamma_lut_size); + if (!ret) + drm_crtc_enable_color_mgmt(crtc, 0, false, sysfb->fb_gamma_lut_size); } /* Encoder */ diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c index 986177e4a0f0..9616e67ea42c 100644 --- a/drivers/gpu/drm/sysfb/simpledrm.c +++ b/drivers/gpu/drm/sysfb/simpledrm.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -696,22 +695,8 @@ static const struct drm_plane_funcs simpledrm_primary_plane_funcs = { DRM_GEM_SHADOW_PLANE_FUNCS, }; -static enum drm_mode_status simpledrm_crtc_helper_mode_valid(struct drm_crtc *crtc, - const struct drm_display_mode *mode) -{ - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(crtc->dev); - - return drm_crtc_helper_mode_valid_fixed(crtc, mode, &sysfb->fb_mode); -} - -/* - * The CRTC is always enabled. Screen updates are performed by - * the primary plane's atomic_update function. Disabling clears - * the screen in the primary plane's atomic_disable function. - */ static const struct drm_crtc_helper_funcs simpledrm_crtc_helper_funcs = { - .mode_valid = simpledrm_crtc_helper_mode_valid, - .atomic_check = drm_crtc_helper_atomic_check, + DRM_SYSFB_CRTC_HELPER_FUNCS, }; static const struct drm_crtc_funcs simpledrm_crtc_funcs = { From patchwork Wed Mar 19 07:45:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022264 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 E2814C36000 for ; Wed, 19 Mar 2025 08:34:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2446C10E2C6; Wed, 19 Mar 2025 08:34:26 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6CF4510E2EF for ; Wed, 19 Mar 2025 08:34:19 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7AD6C211EA; Wed, 19 Mar 2025 08:33:56 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F143713A38; Wed, 19 Mar 2025 08:33:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AM+6OXOB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:55 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 11/18] drm/sysfb: Merge primary-plane functions Date: Wed, 19 Mar 2025 08:45:10 +0100 Message-ID: <20250319083021.6472-12-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 7AD6C211EA X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Merge the primary plane code of ofdrm and simpledrm. Replace the plane implementation in each driver with the shared helpers. Set up driver callbacks and format modifiers with initializer macros. The plane code in ofdrm and simpledrm is very similar. Ofdrm has a more sophisticated implementation of atomic_disable, which clears individual scanlines. The code in simpledrm clears the whole buffer at once. Take the ofdrm version. Simpledrm supports get_scanout_buffer. Import it into the shared helpers, which makes it available in ofdrm. The supported formats are all native formats plus an optional enulated XRGB8888 if that's not already a native format. Provide an initializer macro that computes the size of the formats array. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/drm_sysfb_helper.c | 145 +++++++++++++++++++++++ drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 32 +++++ drivers/gpu/drm/sysfb/ofdrm.c | 134 +-------------------- drivers/gpu/drm/sysfb/simpledrm.c | 126 +------------------- 4 files changed, 187 insertions(+), 250 deletions(-) diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c index ed9139f56e59..b48e06b25305 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c @@ -7,6 +7,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -39,6 +46,144 @@ struct drm_display_mode drm_sysfb_mode(unsigned int width, } EXPORT_SYMBOL(drm_sysfb_mode); +/* + * Plane + */ + +int drm_sysfb_plane_helper_atomic_check(struct drm_plane *plane, + struct drm_atomic_state *new_state) +{ + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(plane->dev); + struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(new_state, plane); + struct drm_shadow_plane_state *new_shadow_plane_state = + to_drm_shadow_plane_state(new_plane_state); + struct drm_framebuffer *new_fb = new_plane_state->fb; + struct drm_crtc *new_crtc = new_plane_state->crtc; + struct drm_crtc_state *new_crtc_state = NULL; + struct drm_sysfb_crtc_state *new_sysfb_crtc_state; + int ret; + + if (new_crtc) + new_crtc_state = drm_atomic_get_new_crtc_state(new_state, new_plane_state->crtc); + + ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state, + DRM_PLANE_NO_SCALING, + DRM_PLANE_NO_SCALING, + false, false); + if (ret) + return ret; + else if (!new_plane_state->visible) + return 0; + + if (new_fb->format != sysfb->fb_format) { + void *buf; + + /* format conversion necessary; reserve buffer */ + buf = drm_format_conv_state_reserve(&new_shadow_plane_state->fmtcnv_state, + sysfb->fb_pitch, GFP_KERNEL); + if (!buf) + return -ENOMEM; + } + + new_crtc_state = drm_atomic_get_new_crtc_state(new_state, new_plane_state->crtc); + + new_sysfb_crtc_state = to_drm_sysfb_crtc_state(new_crtc_state); + new_sysfb_crtc_state->format = new_fb->format; + + return 0; +} +EXPORT_SYMBOL(drm_sysfb_plane_helper_atomic_check); + +void drm_sysfb_plane_helper_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state) +{ + struct drm_device *dev = plane->dev; + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); + struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane); + struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane); + struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); + struct drm_framebuffer *fb = plane_state->fb; + unsigned int dst_pitch = sysfb->fb_pitch; + const struct drm_format_info *dst_format = sysfb->fb_format; + struct drm_atomic_helper_damage_iter iter; + struct drm_rect damage; + int ret, idx; + + ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE); + if (ret) + return; + + if (!drm_dev_enter(dev, &idx)) + goto out_drm_gem_fb_end_cpu_access; + + drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state); + drm_atomic_for_each_plane_damage(&iter, &damage) { + struct iosys_map dst = sysfb->fb_addr; + struct drm_rect dst_clip = plane_state->dst; + + if (!drm_rect_intersect(&dst_clip, &damage)) + continue; + + iosys_map_incr(&dst, drm_fb_clip_offset(dst_pitch, dst_format, &dst_clip)); + drm_fb_blit(&dst, &dst_pitch, dst_format->format, shadow_plane_state->data, fb, + &damage, &shadow_plane_state->fmtcnv_state); + } + + drm_dev_exit(idx); +out_drm_gem_fb_end_cpu_access: + drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE); +} +EXPORT_SYMBOL(drm_sysfb_plane_helper_atomic_update); + +void drm_sysfb_plane_helper_atomic_disable(struct drm_plane *plane, + struct drm_atomic_state *state) +{ + struct drm_device *dev = plane->dev; + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); + struct iosys_map dst = sysfb->fb_addr; + struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane); + void __iomem *dst_vmap = dst.vaddr_iomem; /* TODO: Use mapping abstraction */ + unsigned int dst_pitch = sysfb->fb_pitch; + const struct drm_format_info *dst_format = sysfb->fb_format; + struct drm_rect dst_clip; + unsigned long lines, linepixels, i; + int idx; + + drm_rect_init(&dst_clip, + plane_state->src_x >> 16, plane_state->src_y >> 16, + plane_state->src_w >> 16, plane_state->src_h >> 16); + + lines = drm_rect_height(&dst_clip); + linepixels = drm_rect_width(&dst_clip); + + if (!drm_dev_enter(dev, &idx)) + return; + + /* Clear buffer to black if disabled */ + dst_vmap += drm_fb_clip_offset(dst_pitch, dst_format, &dst_clip); + for (i = 0; i < lines; ++i) { + memset_io(dst_vmap, 0, linepixels * dst_format->cpp[0]); + dst_vmap += dst_pitch; + } + + drm_dev_exit(idx); +} +EXPORT_SYMBOL(drm_sysfb_plane_helper_atomic_disable); + +int drm_sysfb_plane_helper_get_scanout_buffer(struct drm_plane *plane, + struct drm_scanout_buffer *sb) +{ + struct drm_sysfb_device *sysfb = to_drm_sysfb_device(plane->dev); + + sb->width = sysfb->fb_mode.hdisplay; + sb->height = sysfb->fb_mode.vdisplay; + sb->format = sysfb->fb_format; + sb->pitch[0] = sysfb->fb_pitch; + sb->map[0] = sysfb->fb_addr; + + return 0; +} +EXPORT_SYMBOL(drm_sysfb_plane_helper_get_scanout_buffer); + /* * CRTC */ diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h index c8e5ac6b9b63..45e396bf74b7 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h @@ -39,6 +39,38 @@ static inline struct drm_sysfb_device *to_drm_sysfb_device(struct drm_device *de return container_of(dev, struct drm_sysfb_device, dev); } +/* + * Plane + */ + +int drm_sysfb_plane_helper_atomic_check(struct drm_plane *plane, + struct drm_atomic_state *new_state); +void drm_sysfb_plane_helper_atomic_update(struct drm_plane *plane, + struct drm_atomic_state *state); +void drm_sysfb_plane_helper_atomic_disable(struct drm_plane *plane, + struct drm_atomic_state *state); +int drm_sysfb_plane_helper_get_scanout_buffer(struct drm_plane *plane, + struct drm_scanout_buffer *sb); + +#define DRM_SYSFB_PLANE_NFORMATS(_num_native) \ + ((_num_native) + 1) + +#define DRM_SYSFB_PLANE_FORMAT_MODIFIERS \ + DRM_FORMAT_MOD_LINEAR, \ + DRM_FORMAT_MOD_INVALID + +#define DRM_SYSFB_PLANE_HELPER_FUNCS \ + DRM_GEM_SHADOW_PLANE_HELPER_FUNCS, \ + .atomic_check = drm_sysfb_plane_helper_atomic_check, \ + .atomic_update = drm_sysfb_plane_helper_atomic_update, \ + .atomic_disable = drm_sysfb_plane_helper_atomic_disable, \ + .get_scanout_buffer = drm_sysfb_plane_helper_get_scanout_buffer + +#define DRM_SYSFB_PLANE_FUNCS \ + .update_plane = drm_atomic_helper_update_plane, \ + .disable_plane = drm_atomic_helper_disable_plane, \ + DRM_GEM_SHADOW_PLANE_FUNCS + /* * CRTC */ diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c index 29dbb69dd7ac..71e661ba9329 100644 --- a/drivers/gpu/drm/sysfb/ofdrm.c +++ b/drivers/gpu/drm/sysfb/ofdrm.c @@ -299,7 +299,7 @@ struct ofdrm_device { void __iomem *cmap_base; /* modesetting */ - uint32_t formats[8]; + u32 formats[DRM_SYSFB_PLANE_NFORMATS(1)]; struct drm_plane primary_plane; struct drm_crtc crtc; struct drm_encoder encoder; @@ -725,141 +725,17 @@ static void ofdrm_device_set_gamma(struct ofdrm_device *odev, * Modesetting */ -static const uint64_t ofdrm_primary_plane_format_modifiers[] = { - DRM_FORMAT_MOD_LINEAR, - DRM_FORMAT_MOD_INVALID +static const u64 ofdrm_primary_plane_format_modifiers[] = { + DRM_SYSFB_PLANE_FORMAT_MODIFIERS, }; -static int ofdrm_primary_plane_helper_atomic_check(struct drm_plane *plane, - struct drm_atomic_state *new_state) -{ - struct drm_device *dev = plane->dev; - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); - struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(new_state, plane); - struct drm_shadow_plane_state *new_shadow_plane_state = - to_drm_shadow_plane_state(new_plane_state); - struct drm_framebuffer *new_fb = new_plane_state->fb; - struct drm_crtc *new_crtc = new_plane_state->crtc; - struct drm_crtc_state *new_crtc_state = NULL; - struct drm_sysfb_crtc_state *new_sysfb_crtc_state; - int ret; - - if (new_crtc) - new_crtc_state = drm_atomic_get_new_crtc_state(new_state, new_plane_state->crtc); - - ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state, - DRM_PLANE_NO_SCALING, - DRM_PLANE_NO_SCALING, - false, false); - if (ret) - return ret; - else if (!new_plane_state->visible) - return 0; - - if (new_fb->format != sysfb->fb_format) { - void *buf; - - /* format conversion necessary; reserve buffer */ - buf = drm_format_conv_state_reserve(&new_shadow_plane_state->fmtcnv_state, - sysfb->fb_pitch, GFP_KERNEL); - if (!buf) - return -ENOMEM; - } - - new_crtc_state = drm_atomic_get_new_crtc_state(new_state, new_plane_state->crtc); - - new_sysfb_crtc_state = to_drm_sysfb_crtc_state(new_crtc_state); - new_sysfb_crtc_state->format = new_fb->format; - - return 0; -} - -static void ofdrm_primary_plane_helper_atomic_update(struct drm_plane *plane, - struct drm_atomic_state *state) -{ - struct drm_device *dev = plane->dev; - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); - struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane); - struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane); - struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); - struct drm_framebuffer *fb = plane_state->fb; - unsigned int dst_pitch = sysfb->fb_pitch; - const struct drm_format_info *dst_format = sysfb->fb_format; - struct drm_atomic_helper_damage_iter iter; - struct drm_rect damage; - int ret, idx; - - ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE); - if (ret) - return; - - if (!drm_dev_enter(dev, &idx)) - goto out_drm_gem_fb_end_cpu_access; - - drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state); - drm_atomic_for_each_plane_damage(&iter, &damage) { - struct iosys_map dst = sysfb->fb_addr; - struct drm_rect dst_clip = plane_state->dst; - - if (!drm_rect_intersect(&dst_clip, &damage)) - continue; - - iosys_map_incr(&dst, drm_fb_clip_offset(dst_pitch, dst_format, &dst_clip)); - drm_fb_blit(&dst, &dst_pitch, dst_format->format, shadow_plane_state->data, fb, - &damage, &shadow_plane_state->fmtcnv_state); - } - - drm_dev_exit(idx); -out_drm_gem_fb_end_cpu_access: - drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE); -} - -static void ofdrm_primary_plane_helper_atomic_disable(struct drm_plane *plane, - struct drm_atomic_state *state) -{ - struct drm_device *dev = plane->dev; - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); - struct iosys_map dst = sysfb->fb_addr; - struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane); - void __iomem *dst_vmap = dst.vaddr_iomem; /* TODO: Use mapping abstraction */ - unsigned int dst_pitch = sysfb->fb_pitch; - const struct drm_format_info *dst_format = sysfb->fb_format; - struct drm_rect dst_clip; - unsigned long lines, linepixels, i; - int idx; - - drm_rect_init(&dst_clip, - plane_state->src_x >> 16, plane_state->src_y >> 16, - plane_state->src_w >> 16, plane_state->src_h >> 16); - - lines = drm_rect_height(&dst_clip); - linepixels = drm_rect_width(&dst_clip); - - if (!drm_dev_enter(dev, &idx)) - return; - - /* Clear buffer to black if disabled */ - dst_vmap += drm_fb_clip_offset(dst_pitch, dst_format, &dst_clip); - for (i = 0; i < lines; ++i) { - memset_io(dst_vmap, 0, linepixels * dst_format->cpp[0]); - dst_vmap += dst_pitch; - } - - drm_dev_exit(idx); -} - static const struct drm_plane_helper_funcs ofdrm_primary_plane_helper_funcs = { - DRM_GEM_SHADOW_PLANE_HELPER_FUNCS, - .atomic_check = ofdrm_primary_plane_helper_atomic_check, - .atomic_update = ofdrm_primary_plane_helper_atomic_update, - .atomic_disable = ofdrm_primary_plane_helper_atomic_disable, + DRM_SYSFB_PLANE_HELPER_FUNCS, }; static const struct drm_plane_funcs ofdrm_primary_plane_funcs = { - .update_plane = drm_atomic_helper_update_plane, - .disable_plane = drm_atomic_helper_disable_plane, + DRM_SYSFB_PLANE_FUNCS, .destroy = drm_plane_cleanup, - DRM_GEM_SHADOW_PLANE_FUNCS, }; static void ofdrm_crtc_helper_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_state *state) diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c index 9616e67ea42c..cfb1fe07704d 100644 --- a/drivers/gpu/drm/sysfb/simpledrm.c +++ b/drivers/gpu/drm/sysfb/simpledrm.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include "drm_sysfb_helper.h" @@ -238,7 +237,7 @@ struct simpledrm_device { #endif /* modesetting */ - uint32_t formats[8]; + u32 formats[DRM_SYSFB_PLANE_NFORMATS(1)]; struct drm_plane primary_plane; struct drm_crtc crtc; struct drm_encoder encoder; @@ -567,132 +566,17 @@ static int simpledrm_device_attach_genpd(struct simpledrm_device *sdev) * Modesetting */ -static const uint64_t simpledrm_primary_plane_format_modifiers[] = { - DRM_FORMAT_MOD_LINEAR, - DRM_FORMAT_MOD_INVALID +static const u64 simpledrm_primary_plane_format_modifiers[] = { + DRM_SYSFB_PLANE_FORMAT_MODIFIERS, }; -static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane, - struct drm_atomic_state *state) -{ - struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); - struct drm_shadow_plane_state *new_shadow_plane_state = - to_drm_shadow_plane_state(new_plane_state); - struct drm_framebuffer *new_fb = new_plane_state->fb; - struct drm_crtc *new_crtc = new_plane_state->crtc; - struct drm_crtc_state *new_crtc_state = NULL; - struct drm_device *dev = plane->dev; - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); - int ret; - - if (new_crtc) - new_crtc_state = drm_atomic_get_new_crtc_state(state, new_crtc); - - ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state, - DRM_PLANE_NO_SCALING, - DRM_PLANE_NO_SCALING, - false, false); - if (ret) - return ret; - else if (!new_plane_state->visible) - return 0; - - if (new_fb->format != sysfb->fb_format) { - void *buf; - - /* format conversion necessary; reserve buffer */ - buf = drm_format_conv_state_reserve(&new_shadow_plane_state->fmtcnv_state, - sysfb->fb_pitch, GFP_KERNEL); - if (!buf) - return -ENOMEM; - } - - return 0; -} - -static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane, - struct drm_atomic_state *state) -{ - struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane); - struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane); - struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); - struct drm_framebuffer *fb = plane_state->fb; - struct drm_device *dev = plane->dev; - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev); - struct drm_atomic_helper_damage_iter iter; - struct drm_rect damage; - int ret, idx; - - ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE); - if (ret) - return; - - if (!drm_dev_enter(dev, &idx)) - goto out_drm_gem_fb_end_cpu_access; - - drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state); - drm_atomic_for_each_plane_damage(&iter, &damage) { - struct drm_rect dst_clip = plane_state->dst; - struct iosys_map dst = sysfb->fb_addr; - - if (!drm_rect_intersect(&dst_clip, &damage)) - continue; - - iosys_map_incr(&dst, drm_fb_clip_offset(sysfb->fb_pitch, sysfb->fb_format, - &dst_clip)); - drm_fb_blit(&dst, &sysfb->fb_pitch, sysfb->fb_format->format, - shadow_plane_state->data, - fb, &damage, &shadow_plane_state->fmtcnv_state); - } - - drm_dev_exit(idx); -out_drm_gem_fb_end_cpu_access: - drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE); -} - -static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *plane, - struct drm_atomic_state *state) -{ - struct drm_device *dev = plane->dev; - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(plane->dev); - int idx; - - if (!drm_dev_enter(dev, &idx)) - return; - - /* Clear screen to black if disabled */ - iosys_map_memset(&sysfb->fb_addr, 0, 0, sysfb->fb_pitch * sysfb->fb_mode.vdisplay); - - drm_dev_exit(idx); -} - -static int simpledrm_primary_plane_helper_get_scanout_buffer(struct drm_plane *plane, - struct drm_scanout_buffer *sb) -{ - struct drm_sysfb_device *sysfb = to_drm_sysfb_device(plane->dev); - - sb->width = sysfb->fb_mode.hdisplay; - sb->height = sysfb->fb_mode.vdisplay; - sb->format = sysfb->fb_format; - sb->pitch[0] = sysfb->fb_pitch; - sb->map[0] = sysfb->fb_addr; - - return 0; -} - static const struct drm_plane_helper_funcs simpledrm_primary_plane_helper_funcs = { - DRM_GEM_SHADOW_PLANE_HELPER_FUNCS, - .atomic_check = simpledrm_primary_plane_helper_atomic_check, - .atomic_update = simpledrm_primary_plane_helper_atomic_update, - .atomic_disable = simpledrm_primary_plane_helper_atomic_disable, - .get_scanout_buffer = simpledrm_primary_plane_helper_get_scanout_buffer, + DRM_SYSFB_PLANE_HELPER_FUNCS, }; static const struct drm_plane_funcs simpledrm_primary_plane_funcs = { - .update_plane = drm_atomic_helper_update_plane, - .disable_plane = drm_atomic_helper_disable_plane, + DRM_SYSFB_PLANE_FUNCS, .destroy = drm_plane_cleanup, - DRM_GEM_SHADOW_PLANE_FUNCS, }; static const struct drm_crtc_helper_funcs simpledrm_crtc_helper_funcs = { From patchwork Wed Mar 19 07:45:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022266 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 B3B06C35FFF for ; Wed, 19 Mar 2025 08:34:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B676610E2EF; Wed, 19 Mar 2025 08:34:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="bzhUZAAf"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="t1I5O7vb"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bzhUZAAf"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="t1I5O7vb"; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D76F10E23C for ; Wed, 19 Mar 2025 08:34:24 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4847C1F84B; Wed, 19 Mar 2025 08:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373237; 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=JPaoeYUBBXi4RDQAzIkfzs2lI/kIbsPcJ4TkutvdANA=; b=bzhUZAAfv940oCQmJ9X0g73UFQpbxYdUydkhT1K2IVxul8COQyohHRYUnmZlozQhYzcF2A rhKLQLgibp5HN5fusXGOiPr2XOOA9CsYGdcUXa5IMb8h0WFfy6BXiIyTorO2gSgiv3i0Ai nAPuqUOfuSjkHlP/00msklVm5pN2Td8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373237; 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=JPaoeYUBBXi4RDQAzIkfzs2lI/kIbsPcJ4TkutvdANA=; b=t1I5O7vb2GxR5JD2j6sa3B1EGu76D3zKY/ajv457VgeTZ4av6eHms/WzPpgSWIR7o7Q1i8 1GM3GjrpaJSBAfDg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373237; 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=JPaoeYUBBXi4RDQAzIkfzs2lI/kIbsPcJ4TkutvdANA=; b=bzhUZAAfv940oCQmJ9X0g73UFQpbxYdUydkhT1K2IVxul8COQyohHRYUnmZlozQhYzcF2A rhKLQLgibp5HN5fusXGOiPr2XOOA9CsYGdcUXa5IMb8h0WFfy6BXiIyTorO2gSgiv3i0Ai nAPuqUOfuSjkHlP/00msklVm5pN2Td8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373237; 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=JPaoeYUBBXi4RDQAzIkfzs2lI/kIbsPcJ4TkutvdANA=; b=t1I5O7vb2GxR5JD2j6sa3B1EGu76D3zKY/ajv457VgeTZ4av6eHms/WzPpgSWIR7o7Q1i8 1GM3GjrpaJSBAfDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A886F13A2C; Wed, 19 Mar 2025 08:33:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +MlqHnSB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:56 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 12/18] drm/sysfb: ofdrm: Add EDID support Date: Wed, 19 Mar 2025 08:45:11 +0100 Message-ID: <20250319083021.6472-13-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ffwll.ch,gmail.com,linux.intel.com,kernel.org]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add EDID support to sysfb connector helpers. Read the EDID property from the OF node in ofdrm. Without EDID, this does nothing. Some systems with OF display, such as 32-bit PPC Macintoshs, provide the system display's EDID data as node property in their DT. Exporting this information allows compositors to implement correct DPI and meaningful color management. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/drm_sysfb_helper.c | 29 ++++++++++++++++++++++++ drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 2 ++ drivers/gpu/drm/sysfb/ofdrm.c | 20 ++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c index b48e06b25305..cb65c618f8d3 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.c +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -281,10 +282,38 @@ EXPORT_SYMBOL(drm_sysfb_crtc_atomic_destroy_state); * Connector */ +static int drm_sysfb_get_edid_block(void *data, u8 *buf, unsigned int block, size_t len) +{ + const u8 *edid = data; + size_t off = block * EDID_LENGTH; + size_t end = off + len; + + if (!edid) + return -1; + if (end > EDID_LENGTH) + return -1; + memcpy(buf, &edid[off], len); + + return 0; +} + int drm_sysfb_connector_helper_get_modes(struct drm_connector *connector) { struct drm_sysfb_device *sysfb = to_drm_sysfb_device(connector->dev); + const struct drm_edid *drm_edid; + + if (sysfb->edid) { + drm_edid = drm_edid_read_custom(connector, drm_sysfb_get_edid_block, + (void *)sysfb->edid); + if (drm_edid) { + drm_edid_connector_update(connector, drm_edid); + drm_edid_free(drm_edid); + } else { + drm_edid_connector_update(connector, NULL); + } + } + /* Return the fixed mode even with EDID */ return drm_connector_helper_get_modes_fixed(connector, &sysfb->fb_mode); } EXPORT_SYMBOL(drm_sysfb_connector_helper_get_modes); diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h index 45e396bf74b7..3684bd0ef085 100644 --- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h +++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h @@ -24,6 +24,8 @@ struct drm_display_mode drm_sysfb_mode(unsigned int width, struct drm_sysfb_device { struct drm_device dev; + const u8 *edid; /* can be NULL */ + /* hardware settings */ struct drm_display_mode fb_mode; const struct drm_format_info *fb_format; diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c index 71e661ba9329..86c1a0c80ceb 100644 --- a/drivers/gpu/drm/sysfb/ofdrm.c +++ b/drivers/gpu/drm/sysfb/ofdrm.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -227,6 +228,16 @@ static u64 display_get_address_of(struct drm_device *dev, struct device_node *of return address; } +static const u8 *display_get_edid_of(struct drm_device *dev, struct device_node *of_node, + u8 buf[EDID_LENGTH]) +{ + int ret = of_property_read_u8_array(of_node, "EDID", buf, EDID_LENGTH); + + if (ret) + return NULL; + return buf; +} + static bool is_avivo(u32 vendor, u32 device) { /* This will match most R5xx */ @@ -298,6 +309,8 @@ struct ofdrm_device { /* colormap */ void __iomem *cmap_base; + u8 edid[EDID_LENGTH]; + /* modesetting */ u32 formats[DRM_SYSFB_PLANE_NFORMATS(1)]; struct drm_plane primary_plane; @@ -840,6 +853,7 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, int width, height, depth, linebytes; const struct drm_format_info *format; u64 address; + const u8 *edid; resource_size_t fb_size, fb_base, fb_pgbase, fb_pgsize; struct resource *res, *mem; void __iomem *screen_base; @@ -989,6 +1003,9 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, } } + /* EDID is optional */ + edid = display_get_edid_of(dev, of_node, odev->edid); + /* * Firmware framebuffer */ @@ -999,6 +1016,7 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, sysfb->fb_pitch = linebytes; if (odev->cmap_base) sysfb->fb_gamma_lut_size = OFDRM_GAMMA_LUT_SIZE; + sysfb->edid = edid; drm_dbg(dev, "display mode={" DRM_MODE_FMT "}\n", DRM_MODE_ARG(&sysfb->fb_mode)); drm_dbg(dev, "framebuffer format=%p4cc, size=%dx%d, linebytes=%d byte\n", @@ -1072,6 +1090,8 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv, drm_connector_set_panel_orientation_with_quirk(connector, DRM_MODE_PANEL_ORIENTATION_UNKNOWN, width, height); + if (edid) + drm_connector_attach_edid_property(connector); ret = drm_connector_attach_encoder(connector, encoder); if (ret) From patchwork Wed Mar 19 07:45:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022263 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 721E3C35FFA for ; Wed, 19 Mar 2025 08:34:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CDA2A10E23C; Wed, 19 Mar 2025 08:34:25 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3EE6F10E23C for ; Wed, 19 Mar 2025 08:34:23 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CA93C21752; Wed, 19 Mar 2025 08:33:57 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4F17D13A38; Wed, 19 Mar 2025 08:33:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id oPIAEnWB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:57 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 13/18] firmware: sysfb: Move bpp-depth calculation into screen_info helper Date: Wed, 19 Mar 2025 08:45:12 +0100 Message-ID: <20250319083021.6472-14-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: CA93C21752 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move the calculation of the bits per pixels for screen_info into a helper function. This will make it available to other callers besides the firmware code. Signed-off-by: Thomas Zimmermann --- drivers/firmware/sysfb_simplefb.c | 31 +------------------------ drivers/video/screen_info_generic.c | 36 +++++++++++++++++++++++++++++ include/linux/screen_info.h | 2 ++ 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/drivers/firmware/sysfb_simplefb.c b/drivers/firmware/sysfb_simplefb.c index 75a186bf8f8e..592d8a644619 100644 --- a/drivers/firmware/sysfb_simplefb.c +++ b/drivers/firmware/sysfb_simplefb.c @@ -35,36 +35,7 @@ __init bool sysfb_parse_mode(const struct screen_info *si, if (type != VIDEO_TYPE_VLFB && type != VIDEO_TYPE_EFI) return false; - /* - * The meaning of depth and bpp for direct-color formats is - * inconsistent: - * - * - DRM format info specifies depth as the number of color - * bits; including alpha, but not including filler bits. - * - Linux' EFI platform code computes lfb_depth from the - * individual color channels, including the reserved bits. - * - VBE 1.1 defines lfb_depth for XRGB1555 as 16, but later - * versions use 15. - * - On the kernel command line, 'bpp' of 32 is usually - * XRGB8888 including the filler bits, but 15 is XRGB1555 - * not including the filler bit. - * - * It's not easily possible to fix this in struct screen_info, - * as this could break UAPI. The best solution is to compute - * bits_per_pixel from the color bits, reserved bits and - * reported lfb_depth, whichever is highest. In the loop below, - * ignore simplefb formats with alpha bits, as EFI and VESA - * don't specify alpha channels. - */ - if (si->lfb_depth > 8) { - bits_per_pixel = max(max3(si->red_size + si->red_pos, - si->green_size + si->green_pos, - si->blue_size + si->blue_pos), - si->rsvd_size + si->rsvd_pos); - bits_per_pixel = max_t(u32, bits_per_pixel, si->lfb_depth); - } else { - bits_per_pixel = si->lfb_depth; - } + bits_per_pixel = __screen_info_lfb_bits_per_pixel(si); for (i = 0; i < ARRAY_SIZE(formats); ++i) { const struct simplefb_format *f = &formats[i]; diff --git a/drivers/video/screen_info_generic.c b/drivers/video/screen_info_generic.c index 64117c6367ab..900e9386eceb 100644 --- a/drivers/video/screen_info_generic.c +++ b/drivers/video/screen_info_generic.c @@ -144,3 +144,39 @@ ssize_t screen_info_resources(const struct screen_info *si, struct resource *r, return pos - r; } EXPORT_SYMBOL(screen_info_resources); + +/* + * The meaning of depth and bpp for direct-color formats is + * inconsistent: + * + * - DRM format info specifies depth as the number of color + * bits; including alpha, but not including filler bits. + * - Linux' EFI platform code computes lfb_depth from the + * individual color channels, including the reserved bits. + * - VBE 1.1 defines lfb_depth for XRGB1555 as 16, but later + * versions use 15. + * - On the kernel command line, 'bpp' of 32 is usually + * XRGB8888 including the filler bits, but 15 is XRGB1555 + * not including the filler bit. + * + * It is not easily possible to fix this in struct screen_info, + * as this could break UAPI. The best solution is to compute + * bits_per_pixel from the color bits, reserved bits and + * reported lfb_depth, whichever is highest. + */ + +u32 __screen_info_lfb_bits_per_pixel(const struct screen_info *si) +{ + u32 bits_per_pixel = si->lfb_depth; + + if (bits_per_pixel > 8) { + bits_per_pixel = max(max3(si->red_size + si->red_pos, + si->green_size + si->green_pos, + si->blue_size + si->blue_pos), + si->rsvd_size + si->rsvd_pos); + bits_per_pixel = max_t(u32, bits_per_pixel, si->lfb_depth); + } + + return bits_per_pixel; +} +EXPORT_SYMBOL(__screen_info_lfb_bits_per_pixel); diff --git a/include/linux/screen_info.h b/include/linux/screen_info.h index 6a4a3cec4638..ab3cffbb58b7 100644 --- a/include/linux/screen_info.h +++ b/include/linux/screen_info.h @@ -128,6 +128,8 @@ static inline unsigned int screen_info_video_type(const struct screen_info *si) ssize_t screen_info_resources(const struct screen_info *si, struct resource *r, size_t num); +u32 __screen_info_lfb_bits_per_pixel(const struct screen_info *si); + #if defined(CONFIG_PCI) void screen_info_apply_fixups(void); struct pci_dev *screen_info_pci_dev(const struct screen_info *si); From patchwork Wed Mar 19 07:45:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 14022268 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 4F015C35FFA for ; Wed, 19 Mar 2025 08:34:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A5E8210E2F5; Wed, 19 Mar 2025 08:34:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="lJWyi75g"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="SERGhz1H"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="lJWyi75g"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="SERGhz1H"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7446C10E2F5 for ; Wed, 19 Mar 2025 08:34:27 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 78F8C219BA; Wed, 19 Mar 2025 08:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373238; 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=qSDFU9WnaD9moDWU7aQMD/uYp34mBoFi3xcdPJUmXgc=; b=lJWyi75gy9QZOvqEAeDvFYIMFk4aTuw3e5WL6aLaxKXJKmkgy3n9PRtEarKEeDd5gf5QFY q0huRRX0RCjool/HcdmnThsN5Vsd8ABCbC0vLzZs5UTY7lVwLBzRggjmGgEGXMbZZrVBg9 ofdxwVaphq4cpfUrDRMNQsA6HEaDpd4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373238; 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=qSDFU9WnaD9moDWU7aQMD/uYp34mBoFi3xcdPJUmXgc=; b=SERGhz1H72ZWV6welDKt8HI+2tYbLuoKhMbDodK+6ZhdboWdHXLsDC6UDiqlwnk0x4RbNZ twXwrU/BQULz7MCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1742373238; 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=qSDFU9WnaD9moDWU7aQMD/uYp34mBoFi3xcdPJUmXgc=; b=lJWyi75gy9QZOvqEAeDvFYIMFk4aTuw3e5WL6aLaxKXJKmkgy3n9PRtEarKEeDd5gf5QFY q0huRRX0RCjool/HcdmnThsN5Vsd8ABCbC0vLzZs5UTY7lVwLBzRggjmGgEGXMbZZrVBg9 ofdxwVaphq4cpfUrDRMNQsA6HEaDpd4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1742373238; 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=qSDFU9WnaD9moDWU7aQMD/uYp34mBoFi3xcdPJUmXgc=; b=SERGhz1H72ZWV6welDKt8HI+2tYbLuoKhMbDodK+6ZhdboWdHXLsDC6UDiqlwnk0x4RbNZ twXwrU/BQULz7MCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0054C13A2C; Wed, 19 Mar 2025 08:33:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id EI9dOnWB2mc+OQAAD6G6ig (envelope-from ); Wed, 19 Mar 2025 08:33:57 +0000 From: Thomas Zimmermann To: javierm@redhat.com, simona@ffwll.ch, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 14/18] drm/sysfb: Add efidrm for EFI displays Date: Wed, 19 Mar 2025 08:45:13 +0100 Message-ID: <20250319083021.6472-15-tzimmermann@suse.de> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319083021.6472-1-tzimmermann@suse.de> References: <20250319083021.6472-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[redhat.com,ffwll.ch,gmail.com,linux.intel.com,kernel.org]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLqirfcw6gnbcr9a9yhi49fhi6)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add support for screen_info setups with VIDEO_TYPE_EFI. Provide the minimum functionality of reading modes, updating and clearing the display. There is existing support for these displays provided by simpledrm with CONFIG_SYSFB_SIMPLEFB=y. Using efidrm over simpledrm will allows for the mapping of video memory with correct caching. Simpledrm always assumes WC caching, while fully cached memory is possible with efidrm. Efidrm will also allow for the use of additional functionality provided by EFI, such as EDID information. In addition to efidrm, add struct pixel_format plus initializer macros. The type and macros describe pixel formats in a generic way on order to find the DRM format from the screen_info settings. Similar existing code in SIMPLEFB_FORMATS and fbdev is not really what is needed in efidrm, but SIMPLEFB_FORMATS can later be converted to struct pixel_format. Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/Kconfig | 16 ++ drivers/gpu/drm/sysfb/Makefile | 1 + drivers/gpu/drm/sysfb/efidrm.c | 487 +++++++++++++++++++++++++++++++++ include/video/pixel_format.h | 41 +++ 4 files changed, 545 insertions(+) create mode 100644 drivers/gpu/drm/sysfb/efidrm.c create mode 100644 include/video/pixel_format.h diff --git a/drivers/gpu/drm/sysfb/Kconfig b/drivers/gpu/drm/sysfb/Kconfig index 87094da417f6..3ffd8da1224c 100644 --- a/drivers/gpu/drm/sysfb/Kconfig +++ b/drivers/gpu/drm/sysfb/Kconfig @@ -7,6 +7,22 @@ config DRM_SYSFB_HELPER tristate depends on DRM +config DRM_EFIDRM + tristate "EFI framebuffer driver" + depends on DRM && MMU + select APERTURE_HELPERS + select DRM_CLIENT_SELECTION + select DRM_GEM_SHMEM_HELPER + select DRM_KMS_HELPER + select DRM_SYSFB_HELPER + select SYSFB + help + DRM driver for EFI framebuffers. + + This driver assumes that the display hardware has been initialized + by the firmware or bootloader before the kernel boots. Scanout + buffer, size, and display format must be provided via EFI interfaces. + config DRM_OFDRM tristate "Open Firmware display driver" depends on DRM && MMU && OF && (PPC || COMPILE_TEST) diff --git a/drivers/gpu/drm/sysfb/Makefile b/drivers/gpu/drm/sysfb/Makefile index f1e8700c3e35..2f96f52842e6 100644 --- a/drivers/gpu/drm/sysfb/Makefile +++ b/drivers/gpu/drm/sysfb/Makefile @@ -2,5 +2,6 @@ obj-$(CONFIG_DRM_SYSFB_HELPER) += drm_sysfb_helper.o +obj-$(CONFIG_DRM_EFIDRM) += efidrm.o obj-$(CONFIG_DRM_OFDRM) += ofdrm.o obj-$(CONFIG_DRM_SIMPLEDRM) += simpledrm.o diff --git a/drivers/gpu/drm/sysfb/efidrm.c b/drivers/gpu/drm/sysfb/efidrm.c new file mode 100644 index 000000000000..5c1876e34a04 --- /dev/null +++ b/drivers/gpu/drm/sysfb/efidrm.c @@ -0,0 +1,487 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include