Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1398039pxb; Wed, 4 Nov 2020 07:56:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWWkS9cNFl3nr+1PTAXoeor68hZVma8mW8x6Wy4B+mGe5M2PisA3Z30tVkyoLVG1wl9ewh X-Received: by 2002:a17:906:1253:: with SMTP id u19mr19545736eja.288.1604505406867; Wed, 04 Nov 2020 07:56:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604505406; cv=none; d=google.com; s=arc-20160816; b=enLZpMS6tVucPakmEhwE9rGjDxcE3+t35p/emxN+RK8F9Ps4ZA/15kTcIs0gnpKde+ r3VS96kfCWX9b/3RgCfPtGfJPfMdOYUcrK8ZkzjRIZlL9ZZNYB6Wtn3hmUIc9VX6oEtc czI+TpsnGOnleI3PrwXxdA3DzFHzAKX+W/gTZaz0kwOjcZQhvdw/Z/bJzXxCl5Jg/tTT 5pbcMyClGLYd+n0BZiPLdlc/HapJbi1VPrg099nGTshElgnZ1oT3LQH55kZ0m1F+z+Jj vEtsR8wm4A26yXwjkZx70CQ9qZ0TguHjHaLuhS0UKdpJRiAUm+t+vJmuAjaaS15tQ8oI N6Wg== 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=cpjrvx5xa5Fub2SmSs5NxCIt1AtREI63BVQTX9fsjLc=; b=vtgHPZ/xjadRBfh9d4g1PSO4ZC0c2syYMNCstNhvoU/FN38ic8fhO4TIia1MRPgFve dZqxUq1I4oZz7RxsIWG95QvJL3tOMc0l6X0E3kpKb4AXs3Ed3vdNPQHEXLDAIMEkozK+ z9VFzNivEkOED4rE1xVceNL+DrUfBC5GPzHpW5sdrSGm2tihgfhjsJCmPvY6ytJrGTQQ HcHQv/B4xsb95XdEfhcYMpGaCCkA7be+gJri/TVua31/5R4AxTvJwdWP6jUdp3iYU/2y 4qKurT9fANVaKzG6sLPnNBhGx3OuGbHP4xm0KQTW9ABcSw2ouuX59nn3BA6HF6byQdXX 1cPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kmf1Z0ye; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si1732806ejb.287.2020.11.04.07.56.24; Wed, 04 Nov 2020 07:56:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kmf1Z0ye; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731252AbgKDPyV (ORCPT + 99 others); Wed, 4 Nov 2020 10:54:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731285AbgKDPyR (ORCPT ); Wed, 4 Nov 2020 10:54:17 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 972A5C0613D4 for ; Wed, 4 Nov 2020 07:54:16 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id x7so22604115wrl.3 for ; Wed, 04 Nov 2020 07:54:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=cpjrvx5xa5Fub2SmSs5NxCIt1AtREI63BVQTX9fsjLc=; b=kmf1Z0yeNpYCwPXqysU9kiSujnzjdXKIk8+vE0x44SjNDiibKhNKdvM5DYwJvPv9BP uyTmaIN6g08I7LE1TSotYiRlsqez5OlMd8VdA7Wvqt1o94N7yywzGxi18DlbPu2frcbU UPX4K6ffl5hpw/wWewB4vegS9SjGz/YB1Sag9vLtCsmWpxdvdjJLW4LZUj09EXiUZd15 BCZWtGxHuAJBWzgOusXVeUzhNClzoyi4/4FJDp8BdlfPbeMW9yVwD21iRSg8e0O6iycV QKF+XTr/zgsxmxz8jW9vwtA3usnrYac8tlSTIij782QzZwWQGrv1xkhb0om5/c81EElx ZmwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=cpjrvx5xa5Fub2SmSs5NxCIt1AtREI63BVQTX9fsjLc=; b=poEyYBthDOaun1muDhLg53L2HoGW/J9gJqpVbjAorP+f1pjt+OHwbt8oESlMiq6Ue7 UpKGMMGWMDX5iR0HWCW6DesOk3ahnaD5Ges9lDnUNTCrVlk8IFun+RLkP1i/Su9Uhztu jA+ISZ/e4ZvgUcAUHsuHDR0o2QygjemknvkAewOtKu+3MFM8wrtVFQVXWEJoWrlRYc47 esfETPJ+KUs+lnPkVUyLJzlYDyFzJ6J4/ASkIUghggbFWVIYOwoJ2OPK7deYgV/fe5pZ jaBKFrxr647Pfgm828mwLwtjs+yzxT6Je4y7AlOmncZUihKFD4dhR6kmbe1Wkewdklrq Eu3w== X-Gm-Message-State: AOAM531pKy3Hm7Q/wpWyjNXWP4eRPozXSAtRkjTEg0X94n3DiezikDYG hHHxTIvy5Yd9EWFjcEYi+bZo2A== X-Received: by 2002:adf:dd90:: with SMTP id x16mr19148018wrl.47.1604505255361; Wed, 04 Nov 2020 07:54:15 -0800 (PST) Received: from dell ([91.110.221.242]) by smtp.gmail.com with ESMTPSA id w11sm3022885wmg.36.2020.11.04.07.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 07:54:14 -0800 (PST) Date: Wed, 4 Nov 2020 15:54:12 +0000 From: Lee Jones To: Alexandru Stan Cc: Heiko Stuebner , Rob Herring , Andy Gross , Bjorn Andersson , Thierry Reding , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Douglas Anderson , Matthias Kaehlcke , Enric Balletbo i Serra , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org Subject: Re: [PATCH v3 3/3] backlight: pwm_bl: Fix interpolation Message-ID: <20201104155412.GR4488@dell> References: <20201022050445.930403-1-amstan@chromium.org> <20201021220404.v3.3.I4dcea1c90e9da3902d466033aa73351e19e49c49@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201021220404.v3.3.I4dcea1c90e9da3902d466033aa73351e19e49c49@changeid> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 21 Oct 2020, Alexandru Stan wrote: > The previous behavior was a little unexpected, its properties/problems: > 1. It was designed to generate strictly increasing values (no repeats) > 2. It had quantization errors when calculating step size. Resulting in > unexpected jumps near the end of some segments. > > Example settings: > brightness-levels = <0 1 2 4 8 16 32 64 128 256>; > num-interpolated-steps = <16>; > > Whenever num-interpolated-steps was larger than the distance > between 2 consecutive brightness levels the table would get really > discontinuous. The slope of the interpolation would stick with > integers only and if it was 0 the whole line segment would get skipped. > > The distances between 1 2 4 and 8 would be 1 (property #1 fighting us), > and only starting with 16 it would start to interpolate properly. > > Property #1 is not enough. The goal here is more than just monotonically > increasing. We should still care about the shape of the curve. Repeated > points might be desired if we're in the part of the curve where we want > to go slow (aka slope near 0). > > Problem #2 is plainly a bug. Imagine if the 64 entry was 63 instead, > the calculated slope on the 32-63 segment will be almost half as it > should be. > > The most expected and simplest algorithm for interpolation is linear > interpolation, which would handle both problems. > Let's just implement that! > > Take pairs of points from the brightness-levels array and linearly > interpolate between them. On the X axis (what userspace sees) we'll > now have equally sized intervals (num-interpolated-steps sized, > as opposed to before where we were at the mercy of quantization). > > END I removed this. > Signed-off-by: Alexandru Stan > --- > > drivers/video/backlight/pwm_bl.c | 70 ++++++++++++++------------------ > 1 file changed, 31 insertions(+), 39 deletions(-) Applied, thanks. -- Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog