From mboxrd@z Thu Jan 1 00:00:00 1970 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 A52581090242 for ; Thu, 19 Mar 2026 16:02:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0366310E95D; Thu, 19 Mar 2026 16:02:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="MMqVRhd1"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Hvd2/Quo"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Vyyi6WAK"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Z5qMeX57"; 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 B1CDB10E8DB for ; Thu, 19 Mar 2026 16:01:58 +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 1454D5BD69; Thu, 19 Mar 2026 16:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1773936081; 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=SVJ+NucxTnLAQlpz8m83R9aofftUw3ivdHmllqxjq2k=; b=MMqVRhd1V+x0i+QTGpF9uboFMx0FEOpk9t8tPAYk5HRKvObHizozy+RVaBKpnK0haNjgI4 tWauUDaWVWJ1JVHzYufbkNo+yE6Wk71AUaMlblxAY95hkcMq1bHa3hMnIHXQBp8lhADGVq rN/e8kHthypM6g1RnwEx0WEfMUaS4GM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1773936081; 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=SVJ+NucxTnLAQlpz8m83R9aofftUw3ivdHmllqxjq2k=; b=Hvd2/Quo5xZdPNElzlfXJj3TNZKw4lcfWdfUmcDvaXcA9ngLsAwaSxBzgrtNnan7qZTO3p h30XzC+pEYoxUYDg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Vyyi6WAK; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Z5qMeX57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1773936076; 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=SVJ+NucxTnLAQlpz8m83R9aofftUw3ivdHmllqxjq2k=; b=Vyyi6WAK7J/qyI1QwkbeBbN4bibtHiL2vjis0ajicHy+SGbJ9qtKSGdRHuNE7U/4nPZq8w MkkoSMYA/hOH6KQw1BcoAvikC3Q3DfjfgaviOkptIFTThPase74E002QN+dIITsQ/fVNMu Uf9U2FuRO3TpN327DX/3C4PA0kBir8Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1773936076; 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=SVJ+NucxTnLAQlpz8m83R9aofftUw3ivdHmllqxjq2k=; b=Z5qMeX57ga+4ULea9NIJnAinOlscHW0VQxtkfTK8ehQxPXXFDom/7607laSVxIAwN4EM8V C1I4HLFhRBt3+FCA== 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 B4CCC4274E; Thu, 19 Mar 2026 16:01:15 +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 UGryKssdvGn0WQAAD6G6ig (envelope-from ); Thu, 19 Mar 2026 16:01:15 +0000 From: Thomas Zimmermann To: david@lechnology.com, javierm@redhat.com, lanzano.alex@gmail.com, kamlesh.gurudasani@gmail.com, architanant5@gmail.com, wens@kernel.org, mripard@kernel.org, maarten.lankhorst@linux.intel.com, simona@ffwll.ch, airlied@gmail.com Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v3 04/16] drm/hx8357d: Use regular atomic helpers; drop simple-display helpers Date: Thu, 19 Mar 2026 16:59:40 +0100 Message-ID: <20260319160110.109610-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260319160110.109610-1-tzimmermann@suse.de> References: <20260319160110.109610-1-tzimmermann@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-1.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWELVE(0.00)[12]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_TO(0.00)[lechnology.com,redhat.com,gmail.com,kernel.org,linux.intel.com,ffwll.ch]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; TAGGED_RCPT(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; R_RATELIMIT(0.00)[to_ip_from(RLqtkr6cif1ebgurukgmwdm7xc)]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Queue-Id: 1454D5BD69 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" Replace simple-display helpers with regular atomic helpers. Store the pipeline elements in struct hx8357d_device and initialize them as part of probing the device. Use mipi-dbi's existing helpers and initializer macros where possible. Effectively open-codes the modesetting code in the initializer helpers of mipi-dbi and simple-display. Hx8357d requires a custom helper for CRTC enablement, and non-freeing cleanup of the pipeline. v2: - fix connector initialization Signed-off-by: Thomas Zimmermann Acked-by: David Lechner --- drivers/gpu/drm/tiny/hx8357d.c | 135 +++++++++++++++++++++++++++++---- 1 file changed, 122 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/tiny/hx8357d.c b/drivers/gpu/drm/tiny/hx8357d.c index 5115be8854bb..53b152fc6b04 100644 --- a/drivers/gpu/drm/tiny/hx8357d.c +++ b/drivers/gpu/drm/tiny/hx8357d.c @@ -46,16 +46,48 @@ #define HX8357D_MADCTL_BGR 0x08 #define HX8357D_MADCTL_MH 0x04 -static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, - struct drm_crtc_state *crtc_state, - struct drm_plane_state *plane_state) +struct hx8357d_device { + struct mipi_dbi_dev dbidev; + + struct drm_plane plane; + struct drm_crtc crtc; + struct drm_encoder encoder; + struct drm_connector connector; +}; + +static struct hx8357d_device *to_hx8357d_device(struct drm_device *dev) { - struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); + return container_of(drm_to_mipi_dbi_dev(dev), struct hx8357d_device, dbidev); +} + +static const u32 hx8357d_plane_formats[] = { + DRM_MIPI_DBI_PLANE_FORMATS, +}; + +static const u64 hx8357d_plane_format_modifiers[] = { + DRM_MIPI_DBI_PLANE_FORMAT_MODIFIERS, +}; + +static const struct drm_plane_helper_funcs hx8357d_plane_helper_funcs = { + DRM_MIPI_DBI_PLANE_HELPER_FUNCS, +}; + +static const struct drm_plane_funcs hx8357d_plane_funcs = { + DRM_MIPI_DBI_PLANE_FUNCS, + .destroy = drm_plane_cleanup, +}; + +static void hx8357d_crtc_helper_atomic_enable(struct drm_crtc *crtc, + struct drm_atomic_state *state) +{ + struct drm_device *drm = crtc->dev; + struct hx8357d_device *hx8357d = to_hx8357d_device(drm); + struct mipi_dbi_dev *dbidev = &hx8357d->dbidev; struct mipi_dbi *dbi = &dbidev->dbi; u8 addr_mode; int ret, idx; - if (!drm_dev_enter(pipe->crtc.dev, &idx)) + if (!drm_dev_enter(drm, &idx)) return; DRM_DEBUG_KMS("\n"); @@ -183,8 +215,35 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe, drm_dev_exit(idx); } -static const struct drm_simple_display_pipe_funcs hx8357d_pipe_funcs = { - DRM_MIPI_DBI_SIMPLE_DISPLAY_PIPE_FUNCS(yx240qv29_enable), +static const struct drm_crtc_helper_funcs hx8357d_crtc_helper_funcs = { + DRM_MIPI_DBI_CRTC_HELPER_FUNCS, + .atomic_enable = hx8357d_crtc_helper_atomic_enable, +}; + +static const struct drm_crtc_funcs hx8357d_crtc_funcs = { + DRM_MIPI_DBI_CRTC_FUNCS, + .destroy = drm_crtc_cleanup, +}; + +static const struct drm_encoder_funcs hx8357d_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; + +static const struct drm_connector_helper_funcs hx8357d_connector_helper_funcs = { + DRM_MIPI_DBI_CONNECTOR_HELPER_FUNCS, +}; + +static const struct drm_connector_funcs hx8357d_connector_funcs = { + DRM_MIPI_DBI_CONNECTOR_FUNCS, + .destroy = drm_connector_cleanup, +}; + +static const struct drm_mode_config_helper_funcs hx8357d_mode_config_helper_funcs = { + DRM_MIPI_DBI_MODE_CONFIG_HELPER_FUNCS, +}; + +static const struct drm_mode_config_funcs hx8357d_mode_config_funcs = { + DRM_MIPI_DBI_MODE_CONFIG_FUNCS, }; static const struct drm_display_mode yx350hv15_mode = { @@ -220,17 +279,21 @@ MODULE_DEVICE_TABLE(spi, hx8357d_id); static int hx8357d_probe(struct spi_device *spi) { struct device *dev = &spi->dev; + struct hx8357d_device *hx8357d; struct mipi_dbi_dev *dbidev; struct drm_device *drm; struct gpio_desc *dc; + struct drm_plane *plane; + struct drm_crtc *crtc; + struct drm_encoder *encoder; + struct drm_connector *connector; u32 rotation = 0; int ret; - dbidev = devm_drm_dev_alloc(dev, &hx8357d_driver, - struct mipi_dbi_dev, drm); - if (IS_ERR(dbidev)) - return PTR_ERR(dbidev); - + hx8357d = devm_drm_dev_alloc(dev, &hx8357d_driver, struct hx8357d_device, dbidev.drm); + if (IS_ERR(hx8357d)) + return PTR_ERR(hx8357d); + dbidev = &hx8357d->dbidev; drm = &dbidev->drm; dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW); @@ -247,7 +310,53 @@ static int hx8357d_probe(struct spi_device *spi) if (ret) return ret; - ret = mipi_dbi_dev_init(dbidev, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation); + ret = drm_mipi_dbi_dev_init(dbidev, &yx350hv15_mode, hx8357d_plane_formats[0], + rotation, 0); + if (ret) + return ret; + + ret = drmm_mode_config_init(drm); + if (ret) + return ret; + + drm->mode_config.min_width = dbidev->mode.hdisplay; + drm->mode_config.max_width = dbidev->mode.hdisplay; + drm->mode_config.min_height = dbidev->mode.vdisplay; + drm->mode_config.max_height = dbidev->mode.vdisplay; + drm->mode_config.funcs = &hx8357d_mode_config_funcs; + drm->mode_config.preferred_depth = 16; + drm->mode_config.helper_private = &hx8357d_mode_config_helper_funcs; + + plane = &hx8357d->plane; + ret = drm_universal_plane_init(drm, plane, 0, &hx8357d_plane_funcs, + hx8357d_plane_formats, ARRAY_SIZE(hx8357d_plane_formats), + hx8357d_plane_format_modifiers, + DRM_PLANE_TYPE_PRIMARY, NULL); + if (ret) + return ret; + drm_plane_helper_add(plane, &hx8357d_plane_helper_funcs); + drm_plane_enable_fb_damage_clips(plane); + + crtc = &hx8357d->crtc; + ret = drm_crtc_init_with_planes(drm, crtc, plane, NULL, &hx8357d_crtc_funcs, NULL); + if (ret) + return ret; + drm_crtc_helper_add(crtc, &hx8357d_crtc_helper_funcs); + + encoder = &hx8357d->encoder; + ret = drm_encoder_init(drm, encoder, &hx8357d_encoder_funcs, DRM_MODE_ENCODER_NONE, NULL); + if (ret) + return ret; + encoder->possible_crtcs = drm_crtc_mask(crtc); + + connector = &hx8357d->connector; + ret = drm_connector_init(drm, connector, &hx8357d_connector_funcs, + DRM_MODE_CONNECTOR_SPI); + if (ret) + return ret; + drm_connector_helper_add(connector, &hx8357d_connector_helper_funcs); + + ret = drm_connector_attach_encoder(connector, encoder); if (ret) return ret; -- 2.53.0