Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5380180rwl; Tue, 11 Apr 2023 04:48:47 -0700 (PDT) X-Google-Smtp-Source: AKy350YMXNbcKplnw0vAsqutf6mgoeGwCmK+60pXCIzfISxWJEJ2l+3vsv0htZfj2DROyc5p7Zkq X-Received: by 2002:a05:6402:181a:b0:500:5627:a20b with SMTP id g26-20020a056402181a00b005005627a20bmr1433563edy.1.1681213727362; Tue, 11 Apr 2023 04:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681213727; cv=none; d=google.com; s=arc-20160816; b=gztwrPpqtnaKJp0507ln1viFAGkLVq6il6AIZjIspjJBoU77H9vIX1WvP+/EcFZr/5 fEDl7khFYgKO20wqUs1STSK6XoWYO1EsvdM/Yio1Xi1vp/P3NKLk7nOP0phgwdw/J4C0 AkTPnASwu8p0MQKDXR34UzJ+CAPm/17H6xhn1BZ3bCh2CkEc+zmJDy6ax+Ob+f49WKev uXP3fEv4smek7YLdLLv4+ut/GNmEX/dlSCQx6U82gZnWSu3MEeJGbLd11mKxg1BhA8lO KZnKmRz/XOCKpSq+kPJiM5H/mbEKPgyquQV8RTNTrSEyf3fuCNbppOLmsIkHIda+3f5Z MaeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IEb9nfZWukphOYEw0YdsdRw0yiG5dVQHlYevF8I/MR8=; b=ueWeozvozcB0FrY4MWGtiUMdafodETGESjr0obMF2q4Q0yYnTmXTrKMoqUb9P2uG9u 9tJwyfYBPNF+gw+LpdonXU4W/DvrSjYz3pAcP1LAfNcELcieMrcebKW8XrL4CZnp+qfz tvdlq3ry+lPJCFbQoHPaf0qMgvZZRNQHmvP3j1IXLW+469N8RjClat92gLhSocWZAg2x /B6Yntrz85tkZ0yc/05rPSRbbdlZs9q1odE1JvLMMwYyLMlupNu8EE9ciUpBeMv0Fm5n PoeIt752Ceb+q89Iqb4o+8xNaFpd6FewvfF103Nlu0gmxDci67GuPJFNiWVuC5uS4wrn qfUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg35-20020a170907a42300b0094a4f918517si2701439ejc.710.2023.04.11.04.48.22; Tue, 11 Apr 2023 04:48:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230111AbjDKLpA (ORCPT + 99 others); Tue, 11 Apr 2023 07:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbjDKLo4 (ORCPT ); Tue, 11 Apr 2023 07:44:56 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 89BF549CF; Tue, 11 Apr 2023 04:44:35 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,336,1673881200"; d="scan'208";a="159045249" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 Apr 2023 20:43:53 +0900 Received: from localhost.localdomain (unknown [10.226.93.123]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 936CA4000A93; Tue, 11 Apr 2023 20:43:48 +0900 (JST) From: Biju Das To: David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v7 14/17] drm: rcar-du: Add rcar_du_lib_mode_cfg_helper_get() Date: Tue, 11 Apr 2023 12:42:32 +0100 Message-Id: <20230411114235.366042-15-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> References: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add rcar_du_lib_mode_cfg_helper_get() in RCar DU kms lib to get the pointer to rcar_du_mode_config_helper, so that both rcar_du_atomic_ commit_tail() and rcar_du_mode_config_helper can be reused by rcar_du_modeset_init() and rzg2l_du_modeset_init(). Signed-off-by: Biju Das --- v6->v7: * Rebased to drm-tip. v1->v6: * Rebased on drm-misc-next and DU-next. v1: * Created the lib suggested by Laurent. Ref: https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220316131100.30685-6-biju.das.jz@bp.renesas.com/ --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 46 +----------------- drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c | 59 +++++++++++++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h | 3 ++ 3 files changed, 63 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 74845d8bad9d..b0b40b1cc37d 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -7,9 +7,7 @@ * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) */ -#include #include -#include #include #include #include @@ -61,52 +59,10 @@ static int rcar_du_atomic_check(struct drm_device *dev, return rcar_du_atomic_check_planes(dev, state); } -static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) -{ - struct drm_device *dev = old_state->dev; - struct rcar_du_device *rcdu = to_rcar_du_device(dev); - struct drm_crtc_state *crtc_state; - struct drm_crtc *crtc; - unsigned int i; - - /* - * Store RGB routing to DPAD0 and DPAD1, the hardware will be configured - * when starting the CRTCs. - */ - rcdu->dpad1_source = -1; - - for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) { - struct rcar_du_crtc_state *rcrtc_state = - to_rcar_crtc_state(crtc_state); - struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); - - if (rcrtc_state->outputs & BIT(RCAR_DU_OUTPUT_DPAD0)) - rcdu->dpad0_source = rcrtc->index; - - if (rcrtc_state->outputs & BIT(RCAR_DU_OUTPUT_DPAD1)) - rcdu->dpad1_source = rcrtc->index; - } - - /* Apply the atomic update. */ - drm_atomic_helper_commit_modeset_disables(dev, old_state); - drm_atomic_helper_commit_planes(dev, old_state, - DRM_PLANE_COMMIT_ACTIVE_ONLY); - drm_atomic_helper_commit_modeset_enables(dev, old_state); - - drm_atomic_helper_commit_hw_done(old_state); - drm_atomic_helper_wait_for_flip_done(dev, old_state); - - drm_atomic_helper_cleanup_planes(dev, old_state); -} - /* ----------------------------------------------------------------------------- * Initialization */ -static const struct drm_mode_config_helper_funcs rcar_du_mode_config_helper = { - .atomic_commit_tail = rcar_du_atomic_commit_tail, -}; - static const struct drm_mode_config_funcs rcar_du_mode_config_funcs = { .fb_create = rcar_du_fb_create, .atomic_check = rcar_du_atomic_check, @@ -412,7 +368,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) dev->mode_config.min_height = 0; dev->mode_config.normalize_zpos = true; dev->mode_config.funcs = &rcar_du_mode_config_funcs; - dev->mode_config.helper_private = &rcar_du_mode_config_helper; + dev->mode_config.helper_private = rcar_du_lib_mode_cfg_helper_get(); if (rcdu->info->gen < 3) { dev->mode_config.max_width = 4095; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c index f092d8e4aa16..13d033009c9f 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c @@ -7,6 +7,9 @@ * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) */ +#include +#include +#include #include #include #include @@ -476,3 +479,59 @@ rcar_du_lib_fb_create(struct drm_device *dev, struct drm_file *file_priv, return drm_gem_fb_create(dev, file_priv, mode_cmd); } + +/* ----------------------------------------------------------------------------- + * Atomic Check and Update + */ + +static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) +{ + struct drm_device *dev = old_state->dev; + struct rcar_du_device *rcdu = to_rcar_du_device(dev); + struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc; + unsigned int i; + + /* + * Store RGB routing to DPAD0 and DPAD1, the hardware will be configured + * when starting the CRTCs. + */ + rcdu->dpad1_source = -1; + + for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) { + struct rcar_du_crtc_state *rcrtc_state = + to_rcar_crtc_state(crtc_state); + struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); + + if (rcrtc_state->outputs & BIT(RCAR_DU_OUTPUT_DPAD0)) + rcdu->dpad0_source = rcrtc->index; + + if (rcrtc_state->outputs & BIT(RCAR_DU_OUTPUT_DPAD1)) + rcdu->dpad1_source = rcrtc->index; + } + + /* Apply the atomic update. */ + drm_atomic_helper_commit_modeset_disables(dev, old_state); + drm_atomic_helper_commit_planes(dev, old_state, + DRM_PLANE_COMMIT_ACTIVE_ONLY); + drm_atomic_helper_commit_modeset_enables(dev, old_state); + + drm_atomic_helper_commit_hw_done(old_state); + drm_atomic_helper_wait_for_flip_done(dev, old_state); + + drm_atomic_helper_cleanup_planes(dev, old_state); +} + +/* ----------------------------------------------------------------------------- + * Initialization + */ + +static const struct drm_mode_config_helper_funcs rcar_du_mode_config_helper = { + .atomic_commit_tail = rcar_du_atomic_commit_tail, +}; + +const struct drm_mode_config_helper_funcs * +rcar_du_lib_mode_cfg_helper_get(void) +{ + return &rcar_du_mode_config_helper; +} diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h index f264e0415d53..be36b98b2d5d 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h @@ -42,4 +42,7 @@ struct drm_framebuffer * rcar_du_lib_fb_create(struct drm_device *dev, struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd); +const struct drm_mode_config_helper_funcs * +rcar_du_lib_mode_cfg_helper_get(void); + #endif /* __RCAR_DU_KMS_LIB_H__ */ -- 2.25.1