From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E680C433FE for ; Mon, 17 Oct 2022 10:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbiJQKbk (ORCPT ); Mon, 17 Oct 2022 06:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbiJQKbi (ORCPT ); Mon, 17 Oct 2022 06:31:38 -0400 Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D82CB1C90C for ; Mon, 17 Oct 2022 03:31:37 -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=4stdZmnnjzcJfTIv6rX9y4Ktpwm0v2vziI9Ogexmn4M=; b=JTuh8gNnaSkR+5LHWdYqs3GbB1 ZHTKRsHYL2Hwd506N3u16pSrtZpDVzxuSO7U0YcYZMN/CHexTltSaNhqyFAtGAJCPUV4V0b8nZ3J0 MGXR+vIMKn64zMJYCMljgm7u5lRp0nf7NBcZ7zr7aV2s+jSrsEZgQCKC0dPn+Yw66geVhRH6bVeZc Gzdem6BNhYGvtZbsJI4bfYo5I/grPpluNd1h9zuwTo/xoj/QGbegYU3yW4i4KSEBhxB/sXpqu4h6p 9gJSysyAKSm1TQM1nSWpbf0JEhuGpMy0U86hC40/GYjpCPhyMJLKilWX9SIAKnUzU7Om4NhJmBb0J K0jnVmWA==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:60899 helo=[192.168.10.61]) by smtp.domeneshop.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okNPD-0001a2-7h; Mon, 17 Oct 2022 12:31:35 +0200 Message-ID: <81936381-ae37-8c84-4681-9eff19f653b5@tronnes.org> Date: Mon, 17 Oct 2022 12:31:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH v5 20/22] drm/vc4: vec: Convert to the new TV mode property To: kfyatek+publicgit@gmail.com, Maxime Ripard , Karol Herbst , Jani Nikula , Tvrtko Ursulin , Daniel Vetter , Maarten Lankhorst , David Airlie , Joonas Lahtinen , Lyude Paul , Maxime Ripard , Emma Anholt , Chen-Yu Tsai , Samuel Holland , Ben Skeggs , Thomas Zimmermann , Rodrigo Vivi , Jernej Skrabec Cc: Dom Cobley , linux-sunxi@lists.linux.dev, Dave Stevenson , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Hans de Goede , Phil Elwell , =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= References: <20220728-rpi-analog-tv-properties-v5-0-d841cc64fe4b@cerno.tech> <20220728-rpi-analog-tv-properties-v5-20-d841cc64fe4b@cerno.tech> From: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Den 16.10.2022 20.52, skrev Mateusz Kwiatkowski: > Hi Maxime, > >> static int vc4_vec_connector_get_modes(struct drm_connector *connector) >> { >> - struct drm_connector_state *state = connector->state; >> struct drm_display_mode *mode; >> >> - mode = drm_mode_duplicate(connector->dev, >> - vc4_vec_tv_modes[state->tv.legacy_mode].mode); >> + mode = drm_mode_analog_ntsc_480i(connector->dev); >> if (!mode) { >> DRM_ERROR("Failed to create a new display mode\n"); >> return -ENOMEM; >> } >> >> + mode->type |= DRM_MODE_TYPE_PREFERRED; >> drm_mode_probed_add(connector, mode); >> >> - return 1; >> + mode = drm_mode_analog_pal_576i(connector->dev); >> + if (!mode) { >> + DRM_ERROR("Failed to create a new display mode\n"); >> + return -ENOMEM; >> + } >> + >> + drm_mode_probed_add(connector, mode); >> + >> + return 2; >> +} > > Referencing those previous discussions: > - https://lore.kernel.org/dri-devel/0255f7c6-0484-6456-350d-cf24f3fee5d6@tronnes.org/ > - https://lore.kernel.org/dri-devel/c8f8015a-75da-afa8-ca7f-b2b134cacd16@gmail.com/ > > Unconditionally setting the 480i mode as DRM_MODE_TYPE_PREFERRED causes Xorg > (at least on current Raspberry Pi OS) to display garbage when > video=Composite1:PAL is specified on the command line, so I'm afraid this won't > do. > > As I see it, there are three viable solutions for this issue: > > a) Somehow query the video= command line option from this function, and set > DRM_MODE_TYPE_PREFERRED appropriately. This would break the abstraction > provided by global DRM code, but should work fine. > > b) Modify drm_helper_probe_add_cmdline_mode() so that it sets > DRM_MODE_TYPE_PREFERRED in addition to DRM_MODE_TYPE_USERDEF. This seems > pretty robust, but affects the entire DRM subsystem, which may break > userspace in different ways. > > - Maybe this could be mitigated by adding some additional conditions, e.g. > setting the PREFERRED flag only if no modes are already flagged as such > and/or only if the cmdline mode is a named one (~= analog TV mode) > > c) Forcing userspace (Xorg / Raspberry Pi OS) to get fixed and honor the USERDEF > flag. > > Either way, hardcoding 480i as PREFERRED does not seem right. > My solution for this is to look at tv.mode to know which mode to mark as preferred. Maxime didn't like this since it changes things behind userspace's back. I don't see how that can cause any problems for userspace. If userspace uses atomic and sets tv_mode, it has to know which mode to use before hand, so it doesn't look at the preferreded flag. If it uses legacy and sets tv_mode, it can end up with a stale preferred flag, but no worse than not having the flag or that ntsc is always preferred. If it doesn't change tv_mode, there's no problem, the preferred flag doesn't change. Noralf.