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 E5C58C79FAD for ; Wed, 9 Sep 2026 09:25:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC16910F051; Wed, 9 Sep 2026 09:25:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="f/YHux2d"; dkim-atps=neutral Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 50F5A10F051 for ; Wed, 9 Sep 2026 09:25:00 +0000 (UTC) Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-498028b3d5eso53475745e9.1 for ; Wed, 09 Sep 2026 02:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788945899; x=1789550699; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=uW8e13fLmaOUq+ENkx3+OyQ8aiaAEP5oYemn6Ymb3kI=; b=f/YHux2dMQ64X+HwS+cIrQINvzc/GjHXtl/OtbMTVAxof7R2VeRsidDv9R7a/ViEic Kj9/OBj3ZLAIHW83sw5TNCz1Qq/2XXQBo/iyPqKHVnxAkip4DWkMq14AKa4SnaTRFoBb FkVRlA9WNsSH4KAKycnpv7KziS0eXboh4Xw7/blx+bEX3dNE4ans47eMoCqFG85zEMVS lvJARTSKC3VPXni5KWT/gq5LJLf7wJHzf90ynMsJurqSndoD3JKemVCtFpQ7reoVmZRv gsfXER9O81/OQuA1jk443qDtncTfMclkrS9Y20hl1sQfOdqz5ALnd17InTs9AtezEDme fVAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788945899; x=1789550699; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uW8e13fLmaOUq+ENkx3+OyQ8aiaAEP5oYemn6Ymb3kI=; b=ErGxlNLtEvkHZD/HfxfagWPE2y8cykNZFD2AgcYw51EKbNz75mfjcei5Q1XJ1pTaBq H4/VpQiOLFsHhOFw19XbdVA2slSZ0KfCYV+oYRwn2mQ2t/cc7/nWzhtpjwnNdca9GGKF XdMVTm6pkq709+X8UaPdLW9KEB4kK2khiGsBQS/4a1pkNvw+PC8Os4NfogF5acUsTOGb eJ6yYyWY7iOfUhJxfkHXsPg3sFFD6Sf4AjtfcKI62iLyJb2jQRPvj1Z9iCz0NbegYmkD biODleoS+AgKQf305z3f+JDd345vLhrwxEkix4kUwpoMd/E1+2T3V8x14br2F7gCadTj JYVQ== X-Forwarded-Encrypted: i=1; AKwUvBxeeyaCJmczoW4w9jNN8R+/r+lpItHTDkt9Pw+/ngYBVpRXfc3WrAxmZRcxytwzhxxGxCfvxAMoZtg=@lists.freedesktop.org X-Gm-Message-State: AFuF++mZuTTN3mwz7Rhn+UBWlrzErVZJs9ROYD+VBD15IvMYlfOjINjD NIBLGCnbuUlgEJvewKk2JJW8F+MrWRqr6vL4BkzLOiqQdCbcaN3fjNrb X-Gm-Gg: AYBFou3jJ5WEaZ034DKf/r9OVVFWIo8OtrhoOW+fBAhI8/1GmAA+DVYt4FxWBCSjRQX YWMUyeZLbSf3oBaMKZxxpk8TBNmOkQ1suVQbn0Xfo8m7EJnPMZITmQKaXwUIfmZ8f1PBkAllJAS Sal4Dxr2iGJf5HZ35m6CsHRWe9eR/Nz/llowXh6v76iNdLZvXRzPZJWZLdJsbbm7oOxPGuDuOo2 fqKQSWReyxCLViL8+l/+ZHXVYlJyMMQpl4dbyLUHmGMXa9hS621QXxpRsyXmuCxPcimCbEamFLV jQJckLZBmiJFlChgGqCsoJI/rYwIr9GTYDIMB2Oqas9d17TGJb6X4/1eVJP338xL5N6INrXVswK AK5PMxITSW71BGoQhrHuL+egGBwkefmGN4Z/yDLgKhz1notldzk6J6rYWraJrebO0FtCCEHgXCa /gxAavlZmL3HJm3Wdi1kM56mk4Hk09yPh0WswiS20gdysOhsB1i/U13wGO8lukSUAGkwiPB+SyD C9wix3kOIzXoMwGdULQ6BFlD3Cmj3QNaexZE/479Bn6BVXj8LVErnq3YDJRjwLmublboU9k3dfM P/HRo1R1e2RhZ/J1RL+6SOHZl4rQlabzhoRmcw== X-Received: by 2002:a05:600c:4e89:b0:49c:fa21:1c81 with SMTP id 5b1f17b1804b1-49cfa211d6bmr305239225e9.22.1788945898598; Wed, 09 Sep 2026 02:24:58 -0700 (PDT) Received: from PC-Davide.homenet.telecomitalia.it (host-79-24-252-102.retail.telecomitalia.it. [79.24.252.102]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-485958f1493sm31191342f8f.37.2026.09.09.02.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 02:24:58 -0700 (PDT) From: Davide Bonatto To: Alexey Brodkin , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list) Cc: Davide Bonatto Subject: [PATCH] drm/tiny: arcpgu: Replace simple display pipe with regular atomic helpers Date: Wed, 9 Sep 2026 11:24:49 +0200 Message-ID: <20260909092455.131962-1-bonatto.davide@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 drm_simple_display_pipe helper is considered legacy/deprecated in favor of explicitly managing individual plane, CRTC, and encoder objects using standard atomic helpers. Migrate arcpgu to initialize its primary plane, CRTC, and encoder explicitly, and route mode validation, enable, and disable hooks through drm_crtc_helper_funcs, and plane updates through drm_plane_helper_funcs. Signed-off-by: Davide Bonatto --- drivers/gpu/drm/tiny/arcpgu.c | 124 ++++++++++++++++++++++++---------- 1 file changed, 90 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c index c93d61ac0bb7..bd2404984535 100644 --- a/drivers/gpu/drm/tiny/arcpgu.c +++ b/drivers/gpu/drm/tiny/arcpgu.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -52,13 +54,17 @@ struct arcpgu_drm_private { struct drm_device drm; void __iomem *regs; struct clk *clk; - struct drm_simple_display_pipe pipe; + struct drm_plane plane; + struct drm_crtc crtc; + struct drm_encoder encoder; struct drm_connector sim_conn; }; #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm) -#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe) +#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc) + +#define plane_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, plane) static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu, unsigned int reg, u32 value) @@ -117,8 +123,8 @@ static const u32 arc_pgu_supported_formats[] = { static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu) { - const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb; - uint32_t pixel_format = fb->format->format; + const struct drm_framebuffer *fb = arcpgu->plane.state->fb; + u32 pixel_format = fb->format->format; u32 format = DRM_FORMAT_INVALID; int i; u32 reg_ctrl; @@ -139,10 +145,10 @@ static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu) arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl); } -static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe, - const struct drm_display_mode *mode) +static enum drm_mode_status arc_pgu_crtc_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode) { - struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe); + struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc); long rate, clk_rate = mode->clock * 1000; long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */ @@ -155,7 +161,7 @@ static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *p static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu) { - struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode; + struct drm_display_mode *m = &arcpgu->crtc.state->adjusted_mode; u32 val; arc_pgu_write(arcpgu, ARCPGU_REG_FMT, @@ -194,49 +200,74 @@ static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu) clk_set_rate(arcpgu->clk, m->crtc_clock * 1000); } -static void arc_pgu_enable(struct drm_simple_display_pipe *pipe, - struct drm_crtc_state *crtc_state, - struct drm_plane_state *plane_state) +static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc, + struct drm_atomic_commit *state) { - struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe); + struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc); arc_pgu_mode_set(arcpgu); clk_prepare_enable(arcpgu->clk); arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) | - ARCPGU_CTRL_ENABLE_MASK); + ARCPGU_CTRL_ENABLE_MASK); } -static void arc_pgu_disable(struct drm_simple_display_pipe *pipe) +static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc, + struct drm_atomic_commit *state) { - struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe); + struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc); clk_disable_unprepare(arcpgu->clk); arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, - arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) & - ~ARCPGU_CTRL_ENABLE_MASK); + arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) & + ~ARCPGU_CTRL_ENABLE_MASK); } -static void arc_pgu_update(struct drm_simple_display_pipe *pipe, - struct drm_plane_state *state) +static void arc_pgu_plane_atomic_update(struct drm_plane *plane, + struct drm_atomic_commit *state) { - struct arcpgu_drm_private *arcpgu; + struct arcpgu_drm_private *arcpgu = plane_to_arcpgu(plane); + struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); struct drm_gem_dma_object *gem; - if (!pipe->plane.state->fb) + if (!new_plane_state->fb) return; - arcpgu = pipe_to_arcpgu_priv(pipe); - gem = drm_fb_dma_get_gem_obj(pipe->plane.state->fb, 0); + gem = drm_fb_dma_get_gem_obj(new_plane_state->fb, 0); arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->dma_addr); } -static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = { - .update = arc_pgu_update, - .mode_valid = arc_pgu_mode_valid, - .enable = arc_pgu_enable, - .disable = arc_pgu_disable, +static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = { + .mode_valid = arc_pgu_crtc_mode_valid, + .atomic_enable = arc_pgu_crtc_atomic_enable, + .atomic_disable = arc_pgu_crtc_atomic_disable, +}; + +static const struct drm_crtc_funcs arc_pgu_crtc_funcs = { + .reset = drm_atomic_helper_crtc_reset, + .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_plane_helper_funcs arc_pgu_plane_helper_funcs = { + .atomic_update = arc_pgu_plane_atomic_update, +}; + +static const struct drm_plane_funcs arc_pgu_plane_funcs = { + .update_plane = drm_atomic_helper_update_plane, + .disable_plane = drm_atomic_helper_disable_plane, + .destroy = drm_plane_cleanup, + .reset = drm_atomic_helper_plane_reset, + .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, +}; + +static const struct drm_encoder_funcs arc_pgu_encoder_funcs = { + .destroy = drm_encoder_cleanup }; static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = { @@ -301,13 +332,38 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) return ret; } - ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs, - arc_pgu_supported_formats, - ARRAY_SIZE(arc_pgu_supported_formats), - NULL, connector); + ret = drm_universal_plane_init(drm, &arcpgu->plane, 0, + &arc_pgu_plane_funcs, arc_pgu_supported_formats, + ARRAY_SIZE(arc_pgu_supported_formats), NULL, + DRM_PLANE_TYPE_PRIMARY, NULL); + + if (ret) + return ret; + + drm_plane_helper_add(&arcpgu->plane, &arc_pgu_plane_helper_funcs); + + ret = drm_crtc_init_with_planes(drm, &arcpgu->crtc, &arcpgu->plane, NULL, + &arc_pgu_crtc_funcs, NULL); + if (ret) return ret; + drm_crtc_helper_add(&arcpgu->crtc, &arc_pgu_crtc_helper_funcs); + + ret = drm_encoder_init(drm, &arcpgu->encoder, &arc_pgu_encoder_funcs, + DRM_MODE_ENCODER_NONE, NULL); + + if (ret) + return ret; + + arcpgu->encoder.possible_crtcs = drm_crtc_mask(&arcpgu->crtc); + + if (connector) { + ret = drm_connector_attach_encoder(connector, &arcpgu->encoder); + if (ret) + return ret; + } + if (encoder_node) { /* Locate drm bridge from the hdmi encoder DT node */ struct drm_bridge *bridge __free(drm_bridge_put) = @@ -315,7 +371,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) if (!bridge) return -EPROBE_DEFER; - ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge); + ret = drm_bridge_attach(&arcpgu->encoder, bridge, NULL, 0); if (ret) return ret; } @@ -342,7 +398,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg) struct drm_device *drm = node->minor->dev; struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm); unsigned long clkrate = clk_get_rate(arcpgu->clk); - unsigned long mode_clock = arcpgu->pipe.crtc.mode.crtc_clock * 1000; + unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000; seq_printf(m, "hw : %lu\n", clkrate); seq_printf(m, "mode: %lu\n", mode_clock); -- 2.43.0