Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp740917rwa; Sat, 20 Aug 2022 13:19:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4zZxbGK69wRXzkhJGLvMQpnmuY4ciSlb0Vr/rLxTjbred1McSBCMvgtiraMF1+9+5Itzou X-Received: by 2002:a17:907:3d89:b0:73d:6a08:b03b with SMTP id he9-20020a1709073d8900b0073d6a08b03bmr1805773ejc.458.1661026781433; Sat, 20 Aug 2022 13:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661026781; cv=none; d=google.com; s=arc-20160816; b=Dp6tKRkHAbTZo4YlD+BzcAYdLK5a4xbYFzqxgrlpIkJa5bplPraKJ72TeFht1js2ug JwywGh4FpyrMal/xADAevzFRK+jfffs84kECVXiumvC+g9nhQH4nsWvGfo4XmsXiRruI uNclx42x07JbHKv/8BYOFf3Sd6+jHUfDYycOR9KjioWOLk8rU9TUj606uw/+hbm8KPTb Kue7vI7G77EzuPeKNoNgUjgiYNkTqy09/eEhoO8lLXHND38xlMZ8HvgSMzzDKwqhaOMO BlKIDYA77u9OpuBLb6ExNClWyy4uYWzCD6LlH7JGvixlJPbJvGBkUVYgzqgGGMsHKzZz qxjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=4hOW8ikp9BlC16NkIWVeHbEV6qbT3qh1PghkZPE+sv4=; b=w469ZcAvowmbFzzSTnz37UuEpS3eSEK3EdDQlghPmNnBOrOoibw2ZV0zVTLIMo5bgd 6LBqJ70qwnHAf6lxF8hvSwO9qbRsASs8D6ot0i9AowdRkwpP37R3RSVZoZQaj5pbWTsT Y3KZqaf9z6OC6uFD2xXfMDurpVS7k0dXfY3RrE3qIvBYIgWbjXgFXDEu5UfuAIYfnUSS iULQl5R7FkBCEk0Qatl2PLaa1RFBWCoh4rwR4U2MPRHuppe4rqkRWKzl7PKbqH9mC5NC q7R8gU49E4qUuwPPbvCkHXhhpcLulz759LRk8WOyUXUmJQB0ehEnsN7XGeIEU6HTrcSm oopQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@tronnes.org header.s=ds202112 header.b=EYQWVkjS; 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=tronnes.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he16-20020a1709073d9000b0073c732a9ec9si5083063ejc.192.2022.08.20.13.19.15; Sat, 20 Aug 2022 13:19:41 -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=fail header.i=@tronnes.org header.s=ds202112 header.b=EYQWVkjS; 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=tronnes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233037AbiHTUM7 (ORCPT + 99 others); Sat, 20 Aug 2022 16:12:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbiHTUM6 (ORCPT ); Sat, 20 Aug 2022 16:12:58 -0400 Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C8DE2CDD3 for ; Sat, 20 Aug 2022 13:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org ; s=ds202112; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=4hOW8ikp9BlC16NkIWVeHbEV6qbT3qh1PghkZPE+sv4=; b=EYQWVkjSwqrvFkoX1JvIf//bPD rEItT472ljcmmgsALoCO69D1USt7lV7NN2hoP+xsAD1Ah5OswP5WxP1JOXL4tm3urS5R5B87k+xg0 zdzgMRBcKw0hntPg1U1qPeb34xYNx6wvUjZZLk8qIBk9b21bNrGuH8J5CwJIX6lUvd93VZia83lcZ aqbUvKktpq2As8oMbi9WVjKaNVhiosQO71HL0ngBhKzpdjmFKkH0kQ3Xnwp1HWDDW4M1WUCJvSmvx oRXT91l9CG7GKNY2Yu61jbnX4tRSwQ6qIgVKWglKp6ugPYKi3ldjZNkNQUJjrMhZti2PA1LT13BsH bgZyDBKw==; Received: from [2a01:799:961:d200:cca0:57ac:c55d:a485] (port=62329) by smtp.domeneshop.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oPUpx-0005wt-AI; Sat, 20 Aug 2022 22:12:53 +0200 Message-ID: <37a76651-a457-e50d-9a05-00ca9ed5d729@tronnes.org> Date: Sat, 20 Aug 2022 22:12:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v1 05/35] drm/connector: Add TV standard property To: Maxime Ripard , Jernej Skrabec , Martin Blumenstingl , Chen-Yu Tsai , Philipp Zabel , Jerome Brunet , Samuel Holland , Thomas Zimmermann , Daniel Vetter , Emma Anholt , David Airlie , Maarten Lankhorst , Kevin Hilman , Neil Armstrong , Maxime Ripard Cc: 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 , =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= References: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> <20220728-rpi-analog-tv-properties-v1-5-3d53ae722097@cerno.tech> From: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= In-Reply-To: <20220728-rpi-analog-tv-properties-v1-5-3d53ae722097@cerno.tech> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Den 29.07.2022 18.34, skrev Maxime Ripard: > 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) > + This is an area where DRM overlaps with v4l2, see: - include/dt-bindings/display/sdtv-standards.h - v4l2_norm_to_name() Maybe we should follow suit, but if we do our own thing please mention why in the commit message. Noralf. > /** > * 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. >