Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp220264pxx; Thu, 29 Oct 2020 00:24:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh2vhjAh7kcicRqlLl5aNiTd9TGrt0ZYhAa3Gme/hh/b7Sa5vIglSs+WWbDwT6lpfcU+QG X-Received: by 2002:aa7:c2c4:: with SMTP id m4mr2770467edp.172.1603956278799; Thu, 29 Oct 2020 00:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603956278; cv=none; d=google.com; s=arc-20160816; b=z7tyN4CIsM9ymSL0GSEju6T45tZfSXAZy1FUTAh8OUgy06VH+AsYmnummJIRY1d4iL bdXrrT3cUFZYEUyiLgDVZo1Y/gOi+zZgT9i5opdkF5WRqBen3K/sMf2dd2Ser54VtdTV lbypuH7a4n1LxL3XYyjwbjFkgXJAFTLSr0anAPA7593L0vJWUBL25ApMV0VZM6nxrqzg PlfFS6gHVhSfB5jh3gR5RAR0EYBBsHXdZClFiciZFxk1v335S7jDeD/jI6ytlCUBqdw8 gr5EEs5Qlz0L+Yp29QOjWWI5WxewaRkLdghjubnhKW1yifdeBnReLw5cndewl2Xpu8f/ loEw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=l4u4x3wqcamFjVhNhf6xSDsxJDF4ia7ZULeYQGII8mw=; b=P2BptAWsho20XnPXnYwXnzRdyNjwmCtJ1lgX9eBDFqeTblwqKn7CXid8wax5CLnfS3 z8vnz1FYPQP0jzXvEdjI/iRsrUvjeKhhEjyrY62HInd7Q38PiEzkWwVHGE9qcW+eEhTW tKU9/hGLUHd9vzgz3jF1ovyMB1l/LzQGRwybbp/NRfxJ6s0yN6GTTiL00TDX0DhU06dk UuVZoty2vm3XpUBSdJ+Clj/RkRUSN96ahjQOIu1GgijhtieEfavgyenGbPfGz2OsnZFT Qq4pnkdj3KeTlqcms0IwneckiIUaz70e8HuGP+lPzNFkuBeV9ibWoR7k2KDsyFpVW9Sh P7jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ILXuE1Fu; 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 h12si1401233edq.232.2020.10.29.00.23.42; Thu, 29 Oct 2020 00:24:38 -0700 (PDT) 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=ILXuE1Fu; 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 S1730970AbgJ1WMs (ORCPT + 99 others); Wed, 28 Oct 2020 18:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730836AbgJ1WMa (ORCPT ); Wed, 28 Oct 2020 18:12:30 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187D5C0613CF for ; Wed, 28 Oct 2020 15:12:30 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id h6so799039lfj.3 for ; Wed, 28 Oct 2020 15:12:30 -0700 (PDT) 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:in-reply-to; bh=l4u4x3wqcamFjVhNhf6xSDsxJDF4ia7ZULeYQGII8mw=; b=ILXuE1FuPImvS0DqL5IMRBIlL6RZds+hGRxbUKX2fa3Jb+p0i0FfZNnJbTmkYt64BZ IkBsZrgp2cHPDVPsSjnIKqN1/P4dJLa0IwrECAb23FygPzfJRHZ/TqvwLlSC+OYLopST mfZn/1onAzkuNMiuX+7fJo9bwL6hP0R8JObt3U6IID7loQ4hX1w7QFMw3tUm6koym7hw EwdWEE7k8ny3zQeSSZLwuWBrKgTCDDAVsOg+Sjxd2sy3jS9T6gTXbCA2TZLmddXiOWUa PG9DUcWHtS11SC1hHzAy/UElkE9HmhHcxPVrEM9fBOj4yvK6Fill0qfq3iJIcENygqOT lu/w== 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:in-reply-to; bh=l4u4x3wqcamFjVhNhf6xSDsxJDF4ia7ZULeYQGII8mw=; b=tHNwVOJYjNew3ciG4GOJW8aOF3D7ZwWXN4kXt4rczTW1OC/k9D7suwJu7P8KV5QjLh Lr2I9gFKEzDRG2ubyBNSV89n/AkUV3fDME6lNA4PoU/be7asgIFIGR3bu3qB0WAPb4HV usaJHJhNCEaIBJiawVyy+GWaojmU2s1grXy9KDE7LAPuupC8LSP+dHQm2yJCgtMJ0Hdx W3yJCqMGXUvvBj0iaR0pFFvlo7CWdNKT+FZdVwVt6smtdOEfFwZpLov8D6Lnx3e6br4n MNGdKW789nFCbV6usCvTZ02PXRnqFDhC37iABRiOmbEZvwtXwtFw0a3ZammnFWTiTK3y 3Z2w== X-Gm-Message-State: AOAM532w/sAojXgIFLeC/Fs5LRYw3zTIifr+DpjjhnQDqUB7519gkKSM c7AtSkYZgq0Y07rvOTeY5XQLrgYzqZlWxQ== X-Received: by 2002:adf:80c8:: with SMTP id 66mr9768069wrl.415.1603897934446; Wed, 28 Oct 2020 08:12:14 -0700 (PDT) Received: from holly.lan (cpc141216-aztw34-2-0-cust174.18-1.cable.virginm.net. [80.7.220.175]) by smtp.gmail.com with ESMTPSA id u5sm8619996wru.63.2020.10.28.08.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 08:12:13 -0700 (PDT) Date: Wed, 28 Oct 2020 15:12:10 +0000 From: Daniel Thompson To: Alexandru Stan Cc: Heiko Stuebner , Rob Herring , Andy Gross , Bjorn Andersson , Thierry Reding , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , Lee Jones , 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: <20201028151210.7e765hbq2k7i3url@holly.lan> References: <20201022050445.930403-1-amstan@chromium.org> <20201021220404.v3.3.I4dcea1c90e9da3902d466033aa73351e19e49c49@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201021220404.v3.3.I4dcea1c90e9da3902d466033aa73351e19e49c49@changeid> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 21, 2020 at 10:04:45PM -0700, 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 INTERESTING. I guess this a copy 'n paste error from some internal log book? Better removed... but I won't lose sleep over it. > Signed-off-by: Alexandru Stan I've waited a bit to see how strong the feelings were w.r.t. getting rid of the division from the table initialization. It was something I was aware of during an earlier review but it was below my personal nitpicking threshold (which could be badly calibrated... hence waiting). However it's all been quiet so: Reviewed-by: Daniel Thompson Daniel.