Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp11226789rwb; Fri, 25 Nov 2022 12:44:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf525//hQuM7Sm3FNuFGxPUebb9VHkbekV4dzWhmoDTJgs58oS6qLl6MEEbwUqo/RwJca4qI X-Received: by 2002:a17:902:b692:b0:188:fc5f:84f2 with SMTP id c18-20020a170902b69200b00188fc5f84f2mr21103427pls.137.1669409048226; Fri, 25 Nov 2022 12:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669409048; cv=none; d=google.com; s=arc-20160816; b=QmQjG2SJOofxZUbaro8Dc+oEByZ0iompiCiq4xiSQvJ+/rLwQ4o6QxfU2uldEb+Gqs bi9Jg6OZJf2wsMfwKZ326eDPb5l+9UtKS7d/qYGXbv8TUVHommeX9ZWVxr5DaI1GO7zx MNfpg6N17mdfiBmomyBRsO5d7mx0UKMBk+v+LW37f+4XAY4rB7yOuW7oJ+35W6DIFD87 cSKy41AcOWEnFoHDw6HQ0UMErHZdKHjm0sRymhScN555ImhYvfskxMAXeJ3+ewSsy0YL ayMfofFOIdQYR2AOKsudlJ5HyP4VzUiR4IShbkBoFTT1IcRX6u93H//d0dR8iCnTQW1K 2L0A== 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=MFrjH+Rx2A5lb6Hx0mPdKgvIJ8gvk+sIL9MrhNKnu5E=; b=K0xNTnPmKEjsz/RWlRNnsnYkh1phL1gKZ/vAatJzVeDBA0M3180Nt7moMAwxmaPVH6 g91wQzCsF192wKqW2WIF/ReYlmSkcdUo9XsKEaO+7ATQKP3Byf/5iaDn2+g5PgOwMEjX ZIh9mVi426M8xmdiw+D3z4V2jjVS+7olBP5lDoWiCicvpvU8CuKU2fHUGvyA0KK+jhaa AljOoOZeGfJ18BS/IySg3nhBirIl6cX+lzEaWbSEFgQpca4rTH1kLxnDOzbNQr2wIjhg VyxNP8hq2AstxPp9s9z7wtodgBmgRTEq8UiVfpONtuIoofRPedYoHVYORqb+1lremjxY hcdQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v15-20020a63150f000000b00463dbc5cebfsi5312296pgl.67.2022.11.25.12.43.57; Fri, 25 Nov 2022 12:44:08 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230024AbiKYUbg (ORCPT + 85 others); Fri, 25 Nov 2022 15:31:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbiKYUbW (ORCPT ); Fri, 25 Nov 2022 15:31:22 -0500 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83FFD52148 for ; Fri, 25 Nov 2022 12:31:20 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed10:d898:271f:7512:e47f]) by albert.telenet-ops.be with bizsmtp id okXG2800P4su47u06kXGQj; Fri, 25 Nov 2022 21:31:18 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1oyfLw-001aQv-5Z; Fri, 25 Nov 2022 21:31:16 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1oyfLv-003Kz0-Bf; Fri, 25 Nov 2022 21:31:15 +0100 From: Geert Uytterhoeven To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: Helge Deller , Michael Schmitz , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC 2/3] drm/simple-kms-helper: Add mode_fixup() to simple display pipe Date: Fri, 25 Nov 2022 21:31:09 +0100 Message-Id: <3b0862187f1c8910089cb0d06a8669caa985042e.1669406382.git.geert@linux-m68k.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 From: Thomas Zimmermann The mode fix-up function for simple display helpers is equivalent to the regular pipeline's CRTC mode fix-up function. It's called to adjust the CRTC's display mode for the encoder. Add this function for DRM fbconv helpers. Signed-off-by: Thomas Zimmermann Signed-off-by: Geert Uytterhoeven --- drivers/gpu/drm/drm_simple_kms_helper.c | 15 +++++++++ include/drm/drm_simple_kms_helper.h | 43 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c index 3ef420ec4534aab5..3d7f859ac9de6814 100644 --- a/drivers/gpu/drm/drm_simple_kms_helper.c +++ b/drivers/gpu/drm/drm_simple_kms_helper.c @@ -96,6 +96,20 @@ drm_simple_kms_crtc_mode_valid(struct drm_crtc *crtc, return pipe->funcs->mode_valid(pipe, mode); } +static bool +drm_simple_kms_crtc_mode_fixup(struct drm_crtc *crtc, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + struct drm_simple_display_pipe *pipe; + + pipe = container_of(crtc, struct drm_simple_display_pipe, crtc); + if (!pipe->funcs || !pipe->funcs->mode_fixup) + return true; + + return pipe->funcs->mode_fixup(crtc, mode, adjusted_mode); +} + static int drm_simple_kms_crtc_check(struct drm_crtc *crtc, struct drm_atomic_state *state) { @@ -141,6 +155,7 @@ static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc, static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = { .mode_valid = drm_simple_kms_crtc_mode_valid, + .mode_fixup = drm_simple_kms_crtc_mode_fixup, .atomic_check = drm_simple_kms_crtc_check, .atomic_enable = drm_simple_kms_crtc_enable, .atomic_disable = drm_simple_kms_crtc_disable, diff --git a/include/drm/drm_simple_kms_helper.h b/include/drm/drm_simple_kms_helper.h index 2298fe3af4cd7abb..2312d089ae85a2b6 100644 --- a/include/drm/drm_simple_kms_helper.h +++ b/include/drm/drm_simple_kms_helper.h @@ -52,6 +52,49 @@ struct drm_simple_display_pipe_funcs { enum drm_mode_status (*mode_valid)(struct drm_simple_display_pipe *pipe, const struct drm_display_mode *mode); + /** + * @mode_fixup: + * + * This callback is used to validate a mode. The parameter mode is the + * display mode that userspace requested, adjusted_mode is the mode the + * encoders need to be fed with. Note that this is the inverse semantics + * of the meaning for the &drm_encoder and &drm_bridge_funcs.mode_fixup + * vfunc. If the CRTC of the simple display pipe cannot support the + * requested conversion from mode to adjusted_mode it should reject the + * modeset. + * + * This function is optional. + * + * NOTE: + * + * This function is called in the check phase of atomic modesets, which + * can be aborted for any reason (including on userspace's request to + * just check whether a configuration would be possible). Atomic drivers + * MUST NOT touch any persistent state (hardware or software) or data + * structures except the passed in adjusted_mode parameter. + * + * Atomic drivers which need to inspect and adjust more state should + * instead use the @atomic_check callback, but note that they're not + * perfectly equivalent: @mode_valid is called from + * drm_atomic_helper_check_modeset(), but @atomic_check is called from + * drm_atomic_helper_check_planes(), because originally it was meant for + * plane update checks only. + * + * Also beware that userspace can request its own custom modes, neither + * core nor helpers filter modes to the list of probe modes reported by + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure + * that modes are filtered consistently put any CRTC constraints and + * limits checks into @mode_valid. + * + * RETURNS: + * + * True if an acceptable configuration is possible, false if the modeset + * operation should be rejected. + */ + bool (*mode_fixup)(struct drm_crtc *crtc, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode); + /** * @enable: * -- 2.25.1