Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp948433rdb; Fri, 20 Oct 2023 04:27:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGT0xvXQDoSuWdnYJwE+ap5ev+Ugua5+tMCZIAtX+SRSCSFDb2Unk38tqlbydXUrG9ojbST X-Received: by 2002:a05:6a00:2295:b0:6bd:66ce:21d4 with SMTP id f21-20020a056a00229500b006bd66ce21d4mr1495202pfe.23.1697801272230; Fri, 20 Oct 2023 04:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697801272; cv=none; d=google.com; s=arc-20160816; b=uDEsy3J6fIfTlP2/mF3+QfHuuIud29ndffT3dQinBph+19cVa9/89khsNqqZARiSLk oZ4zlJic8/qxYD3DiMHG7KV/dbmjSlo4IwSF7POVZs4fxnUfO92u296tdEuhPNByiYW8 jLaPGHiUOX2egBK9yuJ/WBxXShlsRURZpNw+MgC+CYETUZ33dXg1kRrO8tXpNsOHPWMG IRyoKtQcQ0/Hr9t1xOhvAPbKeBQSEYB2n3J9JpcFbXEWr3zCmeuaFqjXCTD5OFZ2fQa+ JNXo37lRYYw05AQFqDv5qV9DqpM75SYerZbuqVk1CLyYZ6ztU2jahhsIK+LfGWtmLHGn SrKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cMmNFqskfyUOXpQegXuQzmiikeYo6k8K/89VdvccPyY=; fh=+XkLwDPQV7rONp4bmHf0iI+mhP02sV1JRBgbjgS/KAE=; b=cz9YZaa+gl/NxfJt5ZV13wcwz/wrmiT0Z8cU5H7C6TmO9nGKpu5hUNe9sbYZaitlz0 c0ouXew6q6Jgq9VKHRHBb5EWjG7lr6cEUQKhten2lfgRGOzs735WYsAD3+U86MpKaZmv gp3KsFwWzeYeUyqzbLuSlZefD+km0ubojlvlITb+JBD9a528kHQs4vv2CYldDPe9Mguj vuG/GYA700zfgb3IUzGnVB8PBI2IgQt5VmCXvC8bn1EYmmKVwW0eMH0k5j20G9d8UVXR EPAJabCFejb2wzKlvA5pDkFxqcCVMsaa9uGYBtyRm1bNOFxvQgfHam5X7GTPzXuVLpzB lr6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V7jMwcp8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q21-20020a632a15000000b00577f65baa3esi1688013pgq.775.2023.10.20.04.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:27:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V7jMwcp8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 501AB82ECB07; Fri, 20 Oct 2023 04:27:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376935AbjJTL1h (ORCPT + 99 others); Fri, 20 Oct 2023 07:27:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376883AbjJTL1g (ORCPT ); Fri, 20 Oct 2023 07:27:36 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E759BC2 for ; Fri, 20 Oct 2023 04:27:31 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2c504a5e1deso11192601fa.2 for ; Fri, 20 Oct 2023 04:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697801250; x=1698406050; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=cMmNFqskfyUOXpQegXuQzmiikeYo6k8K/89VdvccPyY=; b=V7jMwcp8I6tDHGfkUpaYKQytTUshyfYOcR3VIrM4Vkte3JKiOUFyv/1fY0f6QQioh+ KUSmplFsXbZKKI1A0IcK+SdAwZYl3BoCARVqLaCnROmBuQ5Nfpg45vypZql0/4XR9wqb X/qDr//smzBinnqI6BMr77gphAxDeYjFmlUOa2DNLOThuUvQUQO+Tz/RKsiPHrc+jQIV XD+ubwrZClTBV6hCnu1AfTLSQmuFi+hFTWGBvEuB/tkyVjxZegp9WuEcTtc9PLKNNCvN wH6ISrOsW7sbwQ0xfDy51uvZLoTlaIOQkfnqqx+DQyt0gEZuDsGWLHF3sYvpP9q9deeG EHAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697801250; x=1698406050; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cMmNFqskfyUOXpQegXuQzmiikeYo6k8K/89VdvccPyY=; b=jWjbOQ65MvEuxLMdbGC3TapAVO/okb2WDvtU0Z+7YspRUO6T1gPmKT8HwPctetUfjr XyCfDbTYeoVL7gnwslQgxNwvfHBMqYTiIyv669MhyRJxesdoMPvJWO8ljVl6HL3cixZv RRZ9U4wa9kCargQ+KlMLIh+xIpvFcw8lRZJ7TL/JMDuOrHbtLhOC5sQw3Zg9zDTH7gAd HaIzE2IgkpK11wkSRjS3EslCNzdfUd1xNENYtalRKjIyZ64X32kUkKM2DE8r8XEO1sGg EnngrACs6TAQRmhio+fATYqxwVXGuC2EF3PXXfhBe61A1y9ViaC1qqa73e3yQuLHhydk 8ZUg== X-Gm-Message-State: AOJu0Yxj7kUn2nmIrigFZ+6Vyzg+qc4eitibE6ptmaKygeIIO1SVh3pa Duh/efiHHnkvpmJK/h1KthKPQA== X-Received: by 2002:a2e:a99b:0:b0:2b9:3684:165 with SMTP id x27-20020a2ea99b000000b002b936840165mr1279776ljq.8.1697801250111; Fri, 20 Oct 2023 04:27:30 -0700 (PDT) Received: from aspen.lan (aztw-34-b2-v4wan-166919-cust780.vm26.cable.virginm.net. [82.37.195.13]) by smtp.gmail.com with ESMTPSA id bi9-20020a05600c3d8900b003fc16ee2864sm1912171wmb.48.2023.10.20.04.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:27:29 -0700 (PDT) Date: Fri, 20 Oct 2023 12:27:27 +0100 From: Daniel Thompson To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Philipp Zabel , Thierry Reding , Lee Jones , Jingoo Han , Helge Deller , linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] backlight: pwm_bl: Avoid backlight flicker applying initial PWM state Message-ID: <20231020112727.GF23755@aspen.lan> References: <20230608-backlight-pwm-avoid-flicker-v1-1-afd380d50174@pengutronix.de> <20231018210741.6t3yfj6qgmpwhhlo@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231018210741.6t3yfj6qgmpwhhlo@pengutronix.de> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 04:27:51 -0700 (PDT) On Wed, Oct 18, 2023 at 11:07:41PM +0200, Uwe Kleine-K?nig wrote: > Hello Philipp, > > On Thu, Jun 08, 2023 at 04:11:14PM +0200, Philipp Zabel wrote: > > The initial PWM state returned by pwm_init_state() has a duty cycle > > of 0 ns. > > This is only true for drivers without a .get_state() callback, isn't it? pwm_init_state() explicitly zeros the duty-cycle in order to avoid problems when the default args have a different period to the currently applied config: https://elixir.bootlin.com/linux/latest/source/include/linux/pwm.h#L174 Daniel. > > To avoid backlight flicker when taking over an enabled > > display from the bootloader, skip the initial pwm_apply_state() > > and leave the PWM be until backlight_update_state() will apply the > > state with the desired brightness. > > > > Signed-off-by: Philipp Zabel > > --- > > With a PWM driver that allows to inherit PWM state from the bootloader, > > postponing the initial pwm_apply_state() with 0 ns duty cycle allows to > > set the desired duty cycle before the PWM is set, avoiding a short flicker > > if the backlight was previously enabled and will be enabled again. > > --- > > drivers/video/backlight/pwm_bl.c | 16 ++++++++-------- > > 1 file changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c > > index fce412234d10..47a917038f58 100644 > > --- a/drivers/video/backlight/pwm_bl.c > > +++ b/drivers/video/backlight/pwm_bl.c > > @@ -531,12 +531,10 @@ static int pwm_backlight_probe(struct platform_device *pdev) > > if (!state.period && (data->pwm_period_ns > 0)) > > state.period = data->pwm_period_ns; > > > > - ret = pwm_apply_state(pb->pwm, &state); > > - if (ret) { > > - dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n", > > - ret); > > - goto err_alloc; > > - } > > + /* > > + * No need to apply initial state, except in the error path. > > Why do you want to modify the PWM in the error path? I would have > expected not touching it at all in .probe() is fine?! > > > + * State will be applied by backlight_update_status() on success. > > + */ > > > > memset(&props, 0, sizeof(struct backlight_properties)); > > > > Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-K?nig | > Industrial Linux Solutions | https://www.pengutronix.de/ |