Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1784443rwb; Fri, 12 Aug 2022 06:53:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR5c3ElRh/o8Df0aEhRWj4ddq18atKRbMT5zHAM1vPNBXsngXYawaUwH7CzfTtlzoE8e/K7b X-Received: by 2002:aa7:d8d1:0:b0:43c:ce93:ff67 with SMTP id k17-20020aa7d8d1000000b0043cce93ff67mr3647736eds.295.1660312398015; Fri, 12 Aug 2022 06:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660312398; cv=none; d=google.com; s=arc-20160816; b=G9W58+2GXudyRKLQ112Rur5n7AUZ4WSX6ue5AerWQmS2W735GGTPrQPKStN4/xVEDC kgw0u2QH3aLv6zjmWgk5ACSrRGFLRggmTsMmPe/li6u9H0ddWSJeZEEphlVXCEvIYetK Z9yb+4RLVsucIaWq1isZKJEEK5Bef6l2TfRB8Cix+FbAFCshIbNsK19UBizBPB50g/zA +eJ42j2QF2s5RejUF6779Z3SCMl9YmEMcVBRaRyne3kQHiQm7CyvMz4SjLahKm3jiWJT THF1VCcc3IUOS3QTTyYQpuHIFUwn7Mx5KLo+gw/uo3dKkMRLuug1Ai1SIp5dSDXRPkWa 3AHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=aaWmraAyVdsxzOKXcrqOwgi0BA7kWyk0fbcE3gB04Gk=; b=T2hb0AyZjJ5jW8q/styLt602uzP3vM9sf//iRK0T20ahoyG8Tn6Jig8y2OGsUBJ6Oz oTll0lUIQi4LsLSiOpRX17QW3itOHIwNw9KsMpoDYyTra0RXdD6zKW1IRzyVJ+D9cg8f kUYgw/RhdwSeaA7CsJ61otw6+Z3/2bWt8XXOruzIr95Z7upF39qcUv8Z7HxDikiRMFyf bGDxQQaiQd1KVLY9ItkPBoibmm61WG7HqT/EXPMY/5vkipxKtsq9EzuyTvDYFFsIGOuP aGUSf+i1aepRigyGY43Zlj6VPpqb3YRFp+nRq6xAWivJ6fzVHOkLzH49lH77DIQql8yX BL8w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b69-20020a509f4b000000b0043ccb3ed897si2243933edf.213.2022.08.12.06.52.52; Fri, 12 Aug 2022 06:53:18 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236682AbiHLN1f (ORCPT + 99 others); Fri, 12 Aug 2022 09:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232434AbiHLN1d (ORCPT ); Fri, 12 Aug 2022 09:27:33 -0400 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 001129676C for ; Fri, 12 Aug 2022 06:27:32 -0700 (PDT) Received: by mail-qv1-f45.google.com with SMTP id h8so586074qvs.6 for ; Fri, 12 Aug 2022 06:27:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=aaWmraAyVdsxzOKXcrqOwgi0BA7kWyk0fbcE3gB04Gk=; b=CnJS18zm7gCJ3LpQ39+SgwHq25pNeqJqiwKAf+ZUZNwEn61CCKWLv5GpNfG1GhOCu5 PaPmCoKHt5Q8ekT35I+ikm6a+VA3/jAXGto0Wr6MVFPFOto2R5ayBgTlCJ3gBTgWzHPR jSXUt7cVbYQxHYVsfHib9TwD68CclXGrS5yzrVW7JRgYDexcrK2O7GQluTQjAnOcktDg QjWjWS9r5+hl7LKy582Jl7bX60TBW9JCgIOc3SXD+MAOEe/NYcViiRxJCOfrvjae2tZt 3z4iGU5GC3G86buXdS0qApaQQ+Pwkr4foaHiafr7tHY+p5Sm34dT/a3DXJB7+uYk6Are sZVw== X-Gm-Message-State: ACgBeo0qjeFB/7ad4jojsytCJjCrJ6dCjc6GaBHEem4ecWFypC/F5u4O C0oJejGlXUdStjYDU8V++Satw1zjV93oNQ== X-Received: by 2002:ad4:5be4:0:b0:47b:4bdd:b1c7 with SMTP id k4-20020ad45be4000000b0047b4bddb1c7mr3460252qvc.64.1660310851743; Fri, 12 Aug 2022 06:27:31 -0700 (PDT) Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com. [209.85.219.173]) by smtp.gmail.com with ESMTPSA id k20-20020ac84754000000b003435f947d9fsm1706037qtp.74.2022.08.12.06.27.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Aug 2022 06:27:30 -0700 (PDT) Received: by mail-yb1-f173.google.com with SMTP id g5so1445386ybg.11 for ; Fri, 12 Aug 2022 06:27:29 -0700 (PDT) X-Received: by 2002:a25:da0b:0:b0:67a:7fb6:8ae with SMTP id n11-20020a25da0b000000b0067a7fb608aemr3414026ybf.89.1660310848820; Fri, 12 Aug 2022 06:27:28 -0700 (PDT) MIME-Version: 1.0 References: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> <20220728-rpi-analog-tv-properties-v1-9-3d53ae722097@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v1-9-3d53ae722097@cerno.tech> From: Geert Uytterhoeven Date: Fri, 12 Aug 2022 15:27:17 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 09/35] drm/modes: Move named modes parsing to a separate function To: Maxime Ripard Cc: 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=C3=B8nnes?= , Kevin Hilman , Neil Armstrong , Maxime Ripard , linux-sunxi@lists.linux.dev, Linux Kernel Mailing List , Phil Elwell , Mateusz Kwiatkowski , Linux ARM , Dave Stevenson , "open list:ARM/Amlogic Meson..." , DRI Development , Dom Cobley Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Maxime, On Fri, Jul 29, 2022 at 6:36 PM Maxime Ripard wrote: > The current construction of the named mode parsing doesn't allow to extend > it easily. Let's move it to a separate function so we can add more > parameters and modes. > > Signed-off-by: Maxime Ripard Thanks for your patch, which looks similar to my "[PATCH v2 2/5] drm/modes: Extract drm_mode_parse_cmdline_named_mode()" (https://lore.kernel.org/dri-devel/1371554419ae63cb54c2a377db0c1016fcf200bb.1657788997.git.geert@linux-m68k.org ;-) > --- a/drivers/gpu/drm/drm_modes.c > +++ b/drivers/gpu/drm/drm_modes.c > @@ -1773,6 +1773,28 @@ static const char * const drm_named_modes_whitelist[] = { > "PAL", > }; > > +static bool drm_mode_parse_cmdline_named_mode(const char *name, > + unsigned int name_end, > + struct drm_cmdline_mode *cmdline_mode) > +{ > + unsigned int i; > + > + for (i = 0; i < ARRAY_SIZE(drm_named_modes_whitelist); i++) { > + int ret; > + > + ret = str_has_prefix(name, drm_named_modes_whitelist[i]); > + if (ret != name_end) > + continue; > + > + strcpy(cmdline_mode->name, drm_named_modes_whitelist[i]); > + cmdline_mode->specified = true; > + > + return true; > + } > + > + return false; What's the point in returning a value, if it is never checked? Just make this function return void? > +} > + > /** > * drm_mode_parse_command_line_for_connector - parse command line modeline for connector > * @mode_option: optional per connector mode option > @@ -1848,18 +1870,14 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option, > parse_extras = true; > } > > - /* First check for a named mode */ > - for (i = 0; i < ARRAY_SIZE(drm_named_modes_whitelist); i++) { > - ret = str_has_prefix(name, drm_named_modes_whitelist[i]); > - if (ret == mode_end) { > - if (refresh_ptr) > - return false; /* named + refresh is invalid */ > + /* > + * Having a mode that starts by a letter (and thus is named) and > + * an at-sign (used to specify a refresh rate) is disallowed. > + */ > + if (!isdigit(name[0]) && refresh_ptr) This condition may have to be relaxed, if we want to support e.g. "hd720p@50", cfr. my comments on "[PATCH v1 05/35] drm/connector: Add TV standard property". > + return false; > > - strcpy(mode->name, drm_named_modes_whitelist[i]); > - mode->specified = true; > - break; > - } > - } > + drm_mode_parse_cmdline_named_mode(name, mode_end, mode); This call needs to be conditional on mode_end being non-zero, cfr. my patch "[PATCH v2 1/5] drm/modes: parse_cmdline: Handle empty mode name part" (https://lore.kernel.org/dri-devel/302d0737539daa2053134e8f24fdf37e3d939e1e.1657788997.git.geert@linux-m68k.org). > > /* No named mode? Check for a normal mode argument, e.g. 1024x768 */ > if (!mode->specified && isdigit(name[0])) { Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds