Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4567292rwe; Tue, 30 Aug 2022 12:30:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Z8KtUR7FyTi+hHNpo85cNnrglbyCDtxVCHcIWDc2Y58KTbfv/L3Hr1x/172lNRSak0v3S X-Received: by 2002:a65:4cc7:0:b0:41a:4df2:4839 with SMTP id n7-20020a654cc7000000b0041a4df24839mr19866444pgt.37.1661887833404; Tue, 30 Aug 2022 12:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661887833; cv=none; d=google.com; s=arc-20160816; b=zVlaFGwb2yc5KO7xwmlL3Ob4bfEY4Q0FEwje4Zb5IVGSAU5BFSQbrkGlXA/j0ci6pd 5laLLqKK7pyEmF3s+mboTw89hr/J0lO8l/aICMTHLdJpvi9h3uw1cLO1AyCLuwVQ5V8/ I4v7ekDJf+rFCi4M2oJVzUZGU+DTIskpCHDEilJW4m+1KLXkBxpVxz3Oi9DmYnoNLGOo o/IpwFHTVmD507/Ek3Mgks9dv+ySHFZq5Ipg8R7bUPZ+seLKdvBTSsrdA38bdYW2nX96 jWO47Y7MIeNrJGxciDVtLOefu6mfRvLsWQDqt1HvYILdvQ5Q+81lWG1nUzol0G+8wP6M nR0w== 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=Rllac/XBbPbgc0gXaatB94fUM3CKp+p+IW8GoH/lPX8=; b=H893KBDYElSxRuntW7qPXgpvUMyL5RhzFaz0LKMWezkivRKkU2DwjOk7EAbdd44IMt R21hs5Wibnfzq+OLF+tHhKu5cTrV+YDxQ49dAeFP3UvJFNirKb0Ck29SOQ3Mxxq13KzU i9koaqIquuaVz3nG0P7q9V2vFC8MqKiN5VI8JgbAfjA+AoFOWaxVcv5qvmA43NPyDM74 OkwQsqBrIpMt4D2s0JF2pPO4pjNt7ktxrQy2CkCxaJiV7Fa2fhfoT8jnRQnYfn3ZGxO/ 4HHeXPkdcucjvHmkrmWBq7lUiOmxpXAaLrduXxDIKDXW2WBl1K0IqnacknAF4hxWZKYz mehw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@tronnes.org header.s=ds202112 header.b=JVyR6ILG; 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 85-20020a621658000000b0053864fa87basi4366302pfw.0.2022.08.30.12.30.21; Tue, 30 Aug 2022 12:30:33 -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=JVyR6ILG; 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 S229848AbiH3TBV (ORCPT + 99 others); Tue, 30 Aug 2022 15:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbiH3TBS (ORCPT ); Tue, 30 Aug 2022 15:01:18 -0400 Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06ABE543FE for ; Tue, 30 Aug 2022 12:01:17 -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=Rllac/XBbPbgc0gXaatB94fUM3CKp+p+IW8GoH/lPX8=; b=JVyR6ILGL5tXGtsY/mj8MZRAtl ml2JCOZF22V4aySHRZaADzfFTFWNoHLi3MyzwokAbfdOA1uauqNPjjDS4/i3XTzlgKnYBAsw36vYb tJF7QCR7MWAL5ErWDQg64sfKTlxTkcSimRhrzhxOb1BuPl8yFrbBaUzqonjjc8ZPezh17iLL2yEhJ Q/BU4R8sKuIR2tlMffCI2Ttglr57w7F6U7khQ2sSDlaHmHrR11DOmp+amCXXWeLau14MniH0u3QdF n9w/mAKmdSN6E8uJvyURSmrdse6FJTsb3xOLAzDZ6Ojd6qu4E93AxkgPjPUx4yM+DWUmM77foeYQZ 9vkumwxg==; Received: from [2a01:799:961:d200:cca0:57ac:c55d:a485] (port=63560) by smtp.domeneshop.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oT6U7-0004Rm-3e; Tue, 30 Aug 2022 21:01:15 +0200 Message-ID: <199cf4b3-8ace-e047-3050-b810cf0c6b63@tronnes.org> Date: Tue, 30 Aug 2022 21:01:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH v2 32/41] drm/vc4: vec: Convert to the new TV mode property To: Maxime Ripard , Maxime Ripard , Ben Skeggs , David Airlie , Chen-Yu Tsai , Thomas Zimmermann , Jani Nikula , Lyude Paul , Philipp Zabel , Maarten Lankhorst , Rodrigo Vivi , Tvrtko Ursulin , Jernej Skrabec , Samuel Holland , Karol Herbst , Emma Anholt , Daniel Vetter , Joonas Lahtinen Cc: Hans de Goede , linux-arm-kernel@lists.infradead.org, Phil Elwell , intel-gfx@lists.freedesktop.org, Dave Stevenson , dri-devel@lists.freedesktop.org, Dom Cobley , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, linux-sunxi@lists.linux.dev, Mateusz Kwiatkowski , Geert Uytterhoeven , =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= References: <20220728-rpi-analog-tv-properties-v2-0-459522d653a7@cerno.tech> <20220728-rpi-analog-tv-properties-v2-32-459522d653a7@cerno.tech> From: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= In-Reply-To: <20220728-rpi-analog-tv-properties-v2-32-459522d653a7@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.08.2022 15.11, skrev Maxime Ripard: > Now that the core can deal fine with analog TV modes, let's convert the vc4 > > VEC driver to leverage those new features. > > > > We've added some backward compatibility to support the old TV mode property > > and translate it into the new TV norm property. > > > > Signed-off-by: Maxime Ripard > > > > diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c > > index ba6f81908923..58286acf4b9e 100644 > > --- a/drivers/gpu/drm/vc4/vc4_vec.c > > +++ b/drivers/gpu/drm/vc4/vc4_vec.c > @@ -192,7 +200,7 @@ enum vc4_vec_tv_mode_id { > > }; > > > > struct vc4_vec_tv_mode { > > - const struct drm_display_mode *mode; > > + unsigned int mode; > > u32 config0; > > u32 config1; > > u32 custom_freq; > > @@ -226,28 +234,50 @@ static const struct debugfs_reg32 vec_regs[] = { > > }; > > > > static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { > > - [VC4_VEC_TV_MODE_NTSC] = { > > - .mode = &drm_mode_480i, > > + { > > + .mode = DRM_MODE_TV_MODE_NTSC_M, > > .config0 = VEC_CONFIG0_NTSC_STD | VEC_CONFIG0_PDEN, > > .config1 = VEC_CONFIG1_C_CVBS_CVBS, > > }, > > - [VC4_VEC_TV_MODE_NTSC_J] = { > > - .mode = &drm_mode_480i, > > + { > > + .mode = DRM_MODE_TV_MODE_NTSC_J, > > .config0 = VEC_CONFIG0_NTSC_STD, > > .config1 = VEC_CONFIG1_C_CVBS_CVBS, > > }, > > - [VC4_VEC_TV_MODE_PAL] = { > > - .mode = &drm_mode_576i, > > + { > > + .mode = DRM_MODE_TV_MODE_PAL_B, > > .config0 = VEC_CONFIG0_PAL_BDGHI_STD, > > .config1 = VEC_CONFIG1_C_CVBS_CVBS, > > }, > > - [VC4_VEC_TV_MODE_PAL_M] = { > > - .mode = &drm_mode_480i, > > + { > > + .mode = DRM_MODE_TV_MODE_PAL_M, > > .config0 = VEC_CONFIG0_PAL_M_STD, > > .config1 = VEC_CONFIG1_C_CVBS_CVBS, > > }, > > }; > > > > +static inline const struct vc4_vec_tv_mode * > > +vc4_vec_tv_mode_lookup(unsigned int mode) > > +{ > > + unsigned int i; > > + > > + for (i = 0; i < ARRAY_SIZE(vc4_vec_tv_modes); i++) { > > + const struct vc4_vec_tv_mode *tv_mode = &vc4_vec_tv_modes[i]; > > + > > + if (tv_mode->mode == mode) > > + return tv_mode; > > + } > > + > > + return NULL; > > +} > > + > > +static const struct drm_prop_enum_list tv_mode_names[] = { Maybe call it legacy_tv_mode_enums? > > + { VC4_VEC_TV_MODE_NTSC, "NTSC", }, > > + { VC4_VEC_TV_MODE_NTSC_J, "NTSC-J", }, > > + { VC4_VEC_TV_MODE_PAL, "PAL", }, > > + { VC4_VEC_TV_MODE_PAL_M, "PAL-M", }, If you use DRM_MODE_TV_MODE_* here you don't need to translate the value using the switch statement in get/set property, you can use the value directly to get/set tv.mode. Noralf. > > +};