From patchwork Fri Jul 29 16:34:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12932616 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E8346C00144 for ; Fri, 29 Jul 2022 16:39:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RQhjlIQzHpZBwowhyKkst88mh4hwlHNpiwSvr5U3D7w=; b=yMsYLnR6T/asIX udh8j04bWhd4tX71u5h3UMDiJfZZnn8H68cNFMI21ExIPAEMfUCcbBECI+j8hjxSl3GuB2xVz0+dC 5B4F7tx6eN0XQAgxyGwSTTJrNqm6Hrv3/FPKROdEbv00AECaEdiOd7suqEpSdMW5b/ASuo5Er6pRB zJU8kyR1GMGA+X8kG0iqboILdSYHl8oUPzxJdvZ0LpLICTmpxeNByxArNtinwFF8iEg61qGDZYpns PZMRHjipOLrL5nOtwdXbHaapMG88VbU906S5mpQ+6NLHS2hxRbeucdohvvVLa5IMq608L8moMWlJD s2ha+MPsFJh5QCV5d2XA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHT0x-006U8P-An; Fri, 29 Jul 2022 16:39:03 +0000 Received: from new4-smtp.messagingengine.com ([66.111.4.230]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHSxn-006RwV-BI; Fri, 29 Jul 2022 16:35:49 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id A131058092C; Fri, 29 Jul 2022 12:35:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 29 Jul 2022 12:35:46 -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=1659112546; x= 1659119746; bh=eMs+w/CffVwE2ame872l8/WaiNcHNKMJmaLvcqBWcoA=; b=S E+rW9gvtNFtb8V+V7ubutGHjhd9PmCzG+r64L/Yjsymx1qpIfZUGA7qwG0HfE84O BrWusApulAuKTaLSZN/C1YF6j4LGVSmjWcArgqH81DOuHamhlZV7bXzYHe21whvg 8Qqyy/oPKnM4LghOVatGhxb9zTLUS1pQOFMTktQhBzcQrCjlvcxnl2F8PCPVWNjm d+6PSvL30Kd1DEkH1KAEg5wD/1orsG1uwHBS5hwr3H5uq/hDX2u6jW0E96ID1gHT X/kXoykNUhdcw8BhCTkQMiDKkIRQhFb3PpuKyEAkvge2JCGpKcSGmopglHni/2HG wZyhZeG1qpl93ZzWhntOA== 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=1659112546; x= 1659119746; bh=eMs+w/CffVwE2ame872l8/WaiNcHNKMJmaLvcqBWcoA=; b=P ETyWHiCEk9Ru/BIg+QQQXIgCuA8tM7gbdN8R1rJl3ZcQFBBHJL79tNzhGcKSzODU V73KEqDL6fA56w8t/pmmAOffHlx7bB4TaAGdOJtqFZvopYoXjnVsc1lZXNXgDmcc OVVMZ6EEHAaVIFRjQgYIxkPnpbR8L+ef+b14QK02OIUu7HYqVGLEkdN+dluTyaOT 6bpBc7+Dbs3FNs8nLF/qX3BOqcxAGZIxGRRExZblAE8af2Bioy3xeLicPuAL6zQn Fmo4zbS8bPmePUVGmx5g1LSweaxo3z1DM6OZ6mLSxZ5MqV6Q+XXPQEDhs6QuVpIQ N6LEiKf+IkgAVPFYN2Erw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddujedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfgggtoffgsehtkeertdertdejnecuhfhrohhmpefo rgigihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecugg ftrfgrthhtvghrnhepgfffgfetffduudelhfevieffffduleevgfegkeeutefgffejheel leekjeefhfejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Jul 2022 12:35:45 -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_Tr?= =?utf-8?q?=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 05/35] drm/connector: Add TV standard property Date: Fri, 29 Jul 2022 18:34:48 +0200 Message-Id: <20220728-rpi-analog-tv-properties-v1-5-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 X-Mailer: b4 0.10.0-dev-49460 X-Developer-Signature: v=1; a=openpgp-sha256; l=8238; i=maxime@cerno.tech; h=from:subject:message-id; bh=jGJUS/VA2iyHNwRJXvB4FtOdyf/I7gunEXYaaarTrag=; b=owGbwMvMwCHc4XzqmfnC7acZT6slMSQ94VHiuhjjyKu6sbMwIPWU79r0t1d+xKXxFs1uEn64t/zk 7y3bO0pZGIQ5GGTFFFmuC7614wuLcovg+bAZZg4rE8gQBi5OAZjITD6Gf/aMS299rN5e0hj79qhWSf ckHvsLfD85L+0ScJixn3Pi190M/136CzTrXT4mSOcf3qafsPsQQ7ZQnPkXj/z/uTnOrC89dAA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220729_093547_520867_1BB5214C X-CRM114-Status: GOOD ( 15.38 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org The TV mode property has been around for a while now to select and get the current TV mode output on an analog TV connector. Despite that property name being generic, its content isn't and has been driver-specific which makes it hard to build any generic behaviour on top of it, both in kernel and user-space. Let's create a new bitmask tv norm property, that can contain any of the analog TV standards currently supported by kernel drivers. Each driver can then pass in a bitmask of the modes it supports. We'll then be able to phase out the older tv mode property. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index c06d0639d552..d7ff6c644c2f 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -700,6 +700,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, state->tv.margins.bottom = val; } else if (property == config->tv_mode_property) { state->tv.mode = val; + } else if (property == config->tv_norm_property) { + state->tv.norm = val; } else if (property == config->tv_brightness_property) { state->tv.brightness = val; } else if (property == config->tv_contrast_property) { @@ -810,6 +812,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->tv.margins.bottom; } else if (property == config->tv_mode_property) { *val = state->tv.mode; + } else if (property == config->tv_norm_property) { + *val = state->tv.norm; } else if (property == config->tv_brightness_property) { *val = state->tv.brightness; } else if (property == config->tv_contrast_property) { diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index e3142c8142b3..68a4e47f85a9 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -1637,6 +1637,7 @@ EXPORT_SYMBOL(drm_mode_create_tv_margin_properties); /** * drm_mode_create_tv_properties - create TV specific connector properties * @dev: DRM device + * @supported_tv_norms: Bitmask of TV norms supported (See DRM_MODE_TV_NORM_*) * @num_modes: number of different TV formats (modes) supported * @modes: array of pointers to strings containing name of each format * @@ -1649,11 +1650,40 @@ EXPORT_SYMBOL(drm_mode_create_tv_margin_properties); * 0 on success or a negative error code on failure. */ int drm_mode_create_tv_properties(struct drm_device *dev, + unsigned int supported_tv_norms, unsigned int num_modes, const char * const modes[]) { + static const struct drm_prop_enum_list tv_norm_values[] = { + { __builtin_ffs(DRM_MODE_TV_NORM_NTSC_443) - 1, "NTSC-443" }, + { __builtin_ffs(DRM_MODE_TV_NORM_NTSC_J) - 1, "NTSC-J" }, + { __builtin_ffs(DRM_MODE_TV_NORM_NTSC_M) - 1, "NTSC-M" }, + { __builtin_ffs(DRM_MODE_TV_NORM_PAL_60) - 1, "PAL-60" }, + { __builtin_ffs(DRM_MODE_TV_NORM_PAL_B) - 1, "PAL-B" }, + { __builtin_ffs(DRM_MODE_TV_NORM_PAL_D) - 1, "PAL-D" }, + { __builtin_ffs(DRM_MODE_TV_NORM_PAL_G) - 1, "PAL-G" }, + { __builtin_ffs(DRM_MODE_TV_NORM_PAL_H) - 1, "PAL-H" }, + { __builtin_ffs(DRM_MODE_TV_NORM_PAL_I) - 1, "PAL-I" }, + { __builtin_ffs(DRM_MODE_TV_NORM_PAL_M) - 1, "PAL-M" }, + { __builtin_ffs(DRM_MODE_TV_NORM_PAL_N) - 1, "PAL-N" }, + { __builtin_ffs(DRM_MODE_TV_NORM_PAL_NC) - 1, "PAL-Nc" }, + { __builtin_ffs(DRM_MODE_TV_NORM_SECAM_60) - 1, "SECAM-60" }, + { __builtin_ffs(DRM_MODE_TV_NORM_SECAM_B) - 1, "SECAM-B" }, + { __builtin_ffs(DRM_MODE_TV_NORM_SECAM_D) - 1, "SECAM-D" }, + { __builtin_ffs(DRM_MODE_TV_NORM_SECAM_G) - 1, "SECAM-G" }, + { __builtin_ffs(DRM_MODE_TV_NORM_SECAM_K) - 1, "SECAM-K" }, + { __builtin_ffs(DRM_MODE_TV_NORM_SECAM_K1) - 1, "SECAM-K1" }, + { __builtin_ffs(DRM_MODE_TV_NORM_SECAM_L) - 1, "SECAM-L" }, + { __builtin_ffs(DRM_MODE_TV_NORM_HD480I) - 1, "hd480i" }, + { __builtin_ffs(DRM_MODE_TV_NORM_HD480P) - 1, "hd480p" }, + { __builtin_ffs(DRM_MODE_TV_NORM_HD576I) - 1, "hd576i" }, + { __builtin_ffs(DRM_MODE_TV_NORM_HD576P) - 1, "hd576p" }, + { __builtin_ffs(DRM_MODE_TV_NORM_HD720P) - 1, "hd720p" }, + { __builtin_ffs(DRM_MODE_TV_NORM_HD1080I) - 1, "hd1080i" }, + }; struct drm_property *tv_selector; struct drm_property *tv_subconnector; + struct drm_property *tv_norm; unsigned int i; if (dev->mode_config.tv_select_subconnector_property) @@ -1686,6 +1716,13 @@ int drm_mode_create_tv_properties(struct drm_device *dev, if (drm_mode_create_tv_margin_properties(dev)) goto nomem; + tv_norm = drm_property_create_bitmask(dev, 0, "tv norm", + tv_norm_values, ARRAY_SIZE(tv_norm_values), + supported_tv_norms); + if (!tv_norm) + goto nomem; + dev->mode_config.tv_norm_property = tv_norm; + dev->mode_config.tv_mode_property = drm_property_create(dev, DRM_MODE_PROP_ENUM, "mode", num_modes); diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index 4a788c1c9058..457529e5d857 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -573,7 +573,9 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data) struct vc4_vec *vec; int ret; - ret = drm_mode_create_tv_properties(drm, ARRAY_SIZE(tv_mode_names), + ret = drm_mode_create_tv_properties(drm, + 0, + ARRAY_SIZE(tv_mode_names), tv_mode_names); if (ret) return ret; diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 1e9996b33cc8..78275e68ff66 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -143,6 +143,32 @@ enum subpixel_order { }; +#define DRM_MODE_TV_NORM_NTSC_443 (1 << 0) +#define DRM_MODE_TV_NORM_NTSC_J (1 << 1) +#define DRM_MODE_TV_NORM_NTSC_M (1 << 2) +#define DRM_MODE_TV_NORM_PAL_60 (1 << 3) +#define DRM_MODE_TV_NORM_PAL_B (1 << 4) +#define DRM_MODE_TV_NORM_PAL_D (1 << 5) +#define DRM_MODE_TV_NORM_PAL_G (1 << 6) +#define DRM_MODE_TV_NORM_PAL_H (1 << 7) +#define DRM_MODE_TV_NORM_PAL_I (1 << 8) +#define DRM_MODE_TV_NORM_PAL_M (1 << 9) +#define DRM_MODE_TV_NORM_PAL_N (1 << 10) +#define DRM_MODE_TV_NORM_PAL_NC (1 << 11) +#define DRM_MODE_TV_NORM_SECAM_60 (1 << 12) +#define DRM_MODE_TV_NORM_SECAM_B (1 << 13) +#define DRM_MODE_TV_NORM_SECAM_D (1 << 14) +#define DRM_MODE_TV_NORM_SECAM_G (1 << 15) +#define DRM_MODE_TV_NORM_SECAM_K (1 << 16) +#define DRM_MODE_TV_NORM_SECAM_K1 (1 << 17) +#define DRM_MODE_TV_NORM_SECAM_L (1 << 18) +#define DRM_MODE_TV_NORM_HD480I (1 << 19) +#define DRM_MODE_TV_NORM_HD480P (1 << 20) +#define DRM_MODE_TV_NORM_HD576I (1 << 21) +#define DRM_MODE_TV_NORM_HD576P (1 << 22) +#define DRM_MODE_TV_NORM_HD720P (1 << 23) +#define DRM_MODE_TV_NORM_HD1080I (1 << 24) + /** * struct drm_scrambling: sink's scrambling support. */ @@ -687,6 +713,7 @@ struct drm_tv_connector_state { enum drm_mode_subconnector subconnector; struct drm_connector_tv_margins margins; unsigned int mode; + unsigned int norm; unsigned int brightness; unsigned int contrast; unsigned int flicker_reduction; @@ -1779,6 +1806,7 @@ void drm_connector_attach_dp_subconnector_property(struct drm_connector *connect int drm_mode_create_tv_margin_properties(struct drm_device *dev); int drm_mode_create_tv_properties(struct drm_device *dev, + unsigned int supported_tv_norms, unsigned int num_modes, const char * const modes[]); void drm_connector_attach_tv_margin_properties(struct drm_connector *conn); diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 6b5e01295348..d9e79def8b92 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -704,6 +704,12 @@ struct drm_mode_config { */ struct drm_property *dp_subconnector_property; + /** + * @tv_norm_property: Optional TV property to select the TV + * standard output on the connector. + */ + struct drm_property *tv_norm_property; + /** * @tv_subconnector_property: Optional TV property to differentiate * between different TV connector types.