Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4252904rwi; Mon, 17 Oct 2022 03:53:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7dk/MUHcvW8OEEW874Q3fy3QcCyUFiCnZchhCm71vU5tiz+XK3muiITgyBMOvfHUqeLMKs X-Received: by 2002:a17:90b:1c11:b0:20d:459b:ef0e with SMTP id oc17-20020a17090b1c1100b0020d459bef0emr32628510pjb.129.1666004011053; Mon, 17 Oct 2022 03:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666004011; cv=none; d=google.com; s=arc-20160816; b=BGEbXpYbZ3PxqAFtoT1LTQMuYpFGqfTi0SdjFFmRTW8aEnbYYP3weQhJJbtioh0Dla Ny6zeFSP5BJ8uYY1m0cMTV8dyD4XU6ZWsbs0pTfBOS5JH6LqPsJDRXz55Jx301GFPfNP hhAG7GQqh+oHBoF2qHnAlnLqMvNSQWgIt7d40ULD/6Q8/wWGMKnl1vgYU3Tjdz1pUKoU s1swXJCwn1A6sWKIOQVlO1/ngB0cvNBnKZfH6845LiEIY7/KHvvaUzIoLawNP/kA9mQ8 LtyiuDm2jzVVhZrV8X24p23Pyqa/XicX4HtXQ0mYbT4hk/hVS8fzHbduMs6GjS0sp+2F 7RkA== 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=4stdZmnnjzcJfTIv6rX9y4Ktpwm0v2vziI9Ogexmn4M=; b=VAHADkBXznEKUUHVLomOC1BHzHvSyigJKH7eo1+21918E3PiC5mO2fuJoKfVHpbBEg kvu0m99RAjyh6qV9MkDAOwJAm0z7BWXcKMX71/vXkF1QP8Po+O0senKsou9038kW4GS0 k8tu2aJkNIXbEG2rsZ87DinC7lbgY4dl724hITYqT2Gl0mBVXJvlGydjTtU9R9vRKkTy aECc4NSLzdQyGt+1B5wqWNpuHn+Gy/iyvfkSLbxVq4egjRh2MI8ttb2Y2yiyuw8YOyru dWIjkE+JafaM2q2AbV+FSX9mV/7rgTvNEnJ045ll9tptAWfN/SVEDTIow/2PZjC5lu/Y 9wtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@tronnes.org header.s=ds202112 header.b=JTuh8gNn; 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 b6-20020a170902d88600b00178af7f1832si10975042plz.216.2022.10.17.03.53.19; Mon, 17 Oct 2022 03:53:31 -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=JTuh8gNn; 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 S230234AbiJQKbj (ORCPT + 99 others); Mon, 17 Oct 2022 06:31:39 -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 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 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 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.