Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp388835imn; Fri, 29 Jul 2022 09:55:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR4IENZhXYyRGM9grEaO5VDD+N1zPjQpyT9Dq4QCOd908y8KbG7OeDt8/dMHr8cz1ItqQYHe X-Received: by 2002:a17:903:2451:b0:16d:9266:277b with SMTP id l17-20020a170903245100b0016d9266277bmr4868972pls.95.1659113736958; Fri, 29 Jul 2022 09:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659113736; cv=none; d=google.com; s=arc-20160816; b=Bv+6Ul86/+lo2ZasBYhPmJzXdI5Sw0f3J/JdiU5REROSysLfGYfOjw1cLx3fdIJVgh NEPh1LlKWqKutOAQqJ+S2GaxaRAlz4CnTowzZNQ9Gy727B49CLFA8c1BRORDAZB8IX02 TSujYKrgWVB84rRg4uz/dpIvJvobsllhw9e2OhR0UQOMlCXJk8sHUwo+wrHArMCw6KbM VaX4oc7PAjuCROmVoxv9/L8x2y8LDql113kgqwDkvHMI04lKLxwh2ziNNR7+hSW7ZiBl iy2Nq0SjFcLaqhINl27Hd8qWxEVBW1PvkFrVgqkCdePOSuE4To1O8WU3mgcHJZSBceiJ GYIg== 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 :feedback-id:dkim-signature:dkim-signature; bh=WMi8XIOWER3wpbQVpH8wVwWCJ4/RYaQCGvT7XxQHSyU=; b=CmgYBntCB/sIk4rjYGx6ISaCIfQQmuVZuzi/7b6tTNJBNGiZ3Aga4lZXuzNViJv5rL pxuVCd6oIEujL0sQ8KN+xnkdzKLDQfyowYOeu472TMm3XTzXxtp9Esd3t+FTpI74stpc tqDWKwU2ObM1ZOT1J4XV5LFuxx86OkYYIIXaE1+DAHMXQNcwlJSxBjFe1R9o9uvtmoe1 oZEo3DCjjrZPwWC1gb+TNp0e19SdFzQQg0XJAkES35dW0qhW8qLkmvA1mAyckEh+lmoT YMuGfgyoxHgmNzkeZhIHkz5GXvJiX22gtr5HI0tcCSJmrcokBTO/gMuIFqHLe22UIPK/ Uq3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=B4ax9evU; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=pyPkT9S1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a056a001a0d00b005251e17bcb2si4337580pfv.254.2022.07.29.09.55.21; Fri, 29 Jul 2022 09:55:36 -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; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=B4ax9evU; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=pyPkT9S1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238243AbiG2Qqm (ORCPT + 99 others); Fri, 29 Jul 2022 12:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238160AbiG2Qpu (ORCPT ); Fri, 29 Jul 2022 12:45:50 -0400 Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55F7F88F2C for ; Fri, 29 Jul 2022 09:45:49 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 3B6D7580949; Fri, 29 Jul 2022 12:36:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 29 Jul 2022 12:36:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1659112576; x= 1659119776; bh=WMi8XIOWER3wpbQVpH8wVwWCJ4/RYaQCGvT7XxQHSyU=; b=B 4ax9evUCqBTSCfQ8ar7yIeQHl3UM16fH/2o6nETKuuy2NmyD6v3Wrpph5P1ZZaeb MtbuVsTcUNG6rcxG30bubxvvx72kc7K49DiiMtlux2ntypCfzwhxfuRvtFta+yuN rYTRSj76sCU34Q43lrFjvnki0FYA0Y6EqCf1C7vYbWE3PATjLn2gnKZvl8qibdwk nwE45B22ZyG/Wbc0SYVXBq/19F6XlH4xibfy7US3WUlsp17UlpHXgo2igPDWf4Dp +Mh6GrrFuDPLliK8xDSYMmomHWntA2hDMFC4mSNO/qhdwCFYve1PjXXr8fOoEZ9t 4WguQ8bMboufRrGCanvvw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1659112576; x= 1659119776; bh=WMi8XIOWER3wpbQVpH8wVwWCJ4/RYaQCGvT7XxQHSyU=; b=p yPkT9S1MUihXebCXbRkPEvGjTAm8sR4/ddY/iDVvmnOxzIECrYeHuy1BF94le/+i ZO7BUdL2XKnabBofH1/H8LU9YJfnFJAFrOGjgsQYQfrl23qwTFt7v36Q5CvjTilL 5j18dDTKcc2AdrV3TYOByblmnuW4B+rnWH9qxcCkZVOMxPdp3z5/p3yoL1s9uplf kjrrFYhf9cPnqK7JvS22pVPdkSNO6dRGZV4q3SjAB9PSvbqbgf5HP0BZtFSVZY6f bp7zx1qfEcCIMDGoTWMRfyw2/PlJe5HDa0tDGOpE/EV2nX9hAgud0xRPcADTl2Um hiB1oVIG+mxJjUMYCnL5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddujedguddtgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfgggtoffgsehtkeertdertdejnecuhfhrohhmpefo rgigihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecugg ftrfgrthhtvghrnhepgfffgfetffduudelhfevieffffduleevgfegkeeutefgffejheel leekjeefhfejnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrh homhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Jul 2022 12:36:15 -0400 (EDT) From: Maxime Ripard To: Jernej Skrabec , Martin Blumenstingl , Chen-Yu Tsai , Philipp Zabel , Jerome Brunet , Samuel Holland , Thomas Zimmermann , Daniel Vetter , Emma Anholt , David Airlie , Maarten Lankhorst , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , Kevin Hilman , Neil Armstrong , Maxime Ripard Cc: Maxime Ripard , linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Phil Elwell , Mateusz Kwiatkowski , linux-arm-kernel@lists.infradead.org, Geert Uytterhoeven , Dave Stevenson , linux-amlogic@lists.infradead.org, dri-devel@lists.freedesktop.org, Dom Cobley Subject: [PATCH v1 14/35] drm/atomic-helper: Add an analog TV atomic_check implementation Date: Fri, 29 Jul 2022 18:34:57 +0200 Message-Id: <20220728-rpi-analog-tv-properties-v1-14-3d53ae722097@cerno.tech> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> References: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.10.0-dev-49460 X-Developer-Signature: v=1; a=openpgp-sha256; l=4069; i=maxime@cerno.tech; h=from:subject:message-id; bh=mddk/xQKK35DXd7zEHlpZoAU4iNlEj6U3dcQfuJB3RU=; b=owGbwMvMwCHc4XzqmfnC7acZT6slMSQ94VG6v/WYqwCDxI1bU1PN5rbfZLfvjkkO/f6U6XJLl8vr d9lMHaUsDMIcDLJiiizXBd/a8YVFuUXwfNgMM4eVCWQIAxenAEzEchLDP6uu70V5Ag/e7xSon+sfZ2 Ud6rkpOuPgnymT73NmqLxQY2X4w1O++uWVZOX93Mfnl4sxyP95ZbKjtpFhrkjyytA3BlNikwE= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham 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 The analog TV connector drivers share some atomic_check logic, and the new TV standard property have created a bunch of new constraints that needs to be shared across drivers too. Let's create an atomic_check helper for those use cases. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index 6d14cb0c64b1..fce5569bd66a 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -552,6 +552,93 @@ void drm_atomic_helper_connector_tv_reset(struct drm_connector *connector) } EXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset); +/** + * @drm_atomic_helper_connector_tv_check: Validate an analog TV connector state + * @connector: DRM Connector + * @state: the DRM State object + * + * Checks the state object to see if the requested state is valid for an + * analog TV connector. + * + * Returns: + * Zero for success, a negative error code on error. + */ +int drm_atomic_helper_connector_tv_check(struct drm_connector *connector, + struct drm_atomic_state *state) +{ + struct drm_connector_state *old_conn_state = + drm_atomic_get_old_connector_state(state, connector); + struct drm_connector_state *new_conn_state = + drm_atomic_get_new_connector_state(state, connector); + const struct drm_display_mode *mode; + struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc; + + crtc = new_conn_state->crtc; + if (!crtc) + return 0; + + crtc_state = drm_atomic_get_new_crtc_state(state, crtc); + if (!crtc_state) + return -EINVAL; + + switch (new_conn_state->tv.norm) { + case DRM_MODE_TV_NORM_NTSC_443: + fallthrough; + case DRM_MODE_TV_NORM_NTSC_J: + fallthrough; + case DRM_MODE_TV_NORM_NTSC_M: + fallthrough; + case DRM_MODE_TV_NORM_PAL_M: + mode = &drm_mode_480i; + break; + + case DRM_MODE_TV_NORM_PAL_60: + fallthrough; + case DRM_MODE_TV_NORM_PAL_B: + fallthrough; + case DRM_MODE_TV_NORM_PAL_D: + fallthrough; + case DRM_MODE_TV_NORM_PAL_G: + fallthrough; + case DRM_MODE_TV_NORM_PAL_H: + fallthrough; + case DRM_MODE_TV_NORM_PAL_I: + fallthrough; + case DRM_MODE_TV_NORM_PAL_N: + fallthrough; + case DRM_MODE_TV_NORM_PAL_NC: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_60: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_B: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_D: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_G: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_K: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_K1: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_L: + mode = &drm_mode_576i; + break; + + default: + return -EINVAL; + } + + if (!drm_mode_equal(mode, &crtc_state->mode)) + return -EINVAL; + + if (old_conn_state->tv.norm != new_conn_state->tv.norm) + crtc_state->mode_changed = true; + + return 0; +} +EXPORT_SYMBOL(drm_atomic_helper_connector_tv_check); + /** * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state * @connector: connector object diff --git a/include/drm/drm_atomic_state_helper.h b/include/drm/drm_atomic_state_helper.h index c8fbce795ee7..b9740edb2658 100644 --- a/include/drm/drm_atomic_state_helper.h +++ b/include/drm/drm_atomic_state_helper.h @@ -26,6 +26,7 @@ #include +struct drm_atomic_state; struct drm_bridge; struct drm_bridge_state; struct drm_crtc; @@ -71,6 +72,8 @@ void __drm_atomic_helper_connector_reset(struct drm_connector *connector, struct drm_connector_state *conn_state); void drm_atomic_helper_connector_reset(struct drm_connector *connector); void drm_atomic_helper_connector_tv_reset(struct drm_connector *connector); +int drm_atomic_helper_connector_tv_check(struct drm_connector *connector, + struct drm_atomic_state *state); void drm_atomic_helper_connector_tv_margins_reset(struct drm_connector *connector); void __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector, -- b4 0.10.0-dev-49460