From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD6D7C43461 for ; Sun, 13 Sep 2020 10:07:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F2382098B for ; Sun, 13 Sep 2020 10:07:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599991624; bh=KXdxCYDiKlr81+I8wmYDTghlMjmlgpNnbUAixwUlnmU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=nv8Hp77QD8PVgExtCv8O25UPDkU4+lqNHJqxnmKId1qi2mFP9T60CDZm3uP8LZMNg k678r8ccAO0ml0xMm9kPtoRcAGa8AP7qptvRNGA1fuO+HVs31sUNWiRoCbLsZlMSjs WoCT6GnKqkS5WBn3uaBaqr/nzmnqQqIWNZ/8iskc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725919AbgIMKHB (ORCPT ); Sun, 13 Sep 2020 06:07:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:53290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbgIMKHB (ORCPT ); Sun, 13 Sep 2020 06:07:01 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D93BF20639; Sun, 13 Sep 2020 10:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599991620; bh=KXdxCYDiKlr81+I8wmYDTghlMjmlgpNnbUAixwUlnmU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oWnRC0MA1tZzk3+HAAh3lNwBon3skOniT6dmaDIBU3lyMMHFK/PEuZkUwYO01bxRs ypaf9S5nVZ0Le2oFg55Av8f9htPljjC/y1zy5yuyYxwIKfaR9dvTAoztCyKT/7pTFe RaL6ZRiuIRJePBherhqOHQvWRUO4BvtrxRtEFwJg= Date: Sun, 13 Sep 2020 11:06:54 +0100 From: Jonathan Cameron To: Dmitry Baryshkov Cc: Andy Gross , Bjorn Andersson , Rob Herring , Zhang Rui , Daniel Lezcano , Amit Kucheria , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Manivannan Sadhasivam , Craig Tatlor Subject: Re: [PATCH v4 03/10] fixp-arith: add a linear interpolation function Message-ID: <20200913110654.1702b03c@archlinux> In-Reply-To: <20200910140000.324091-4-dmitry.baryshkov@linaro.org> References: <20200910140000.324091-1-dmitry.baryshkov@linaro.org> <20200910140000.324091-4-dmitry.baryshkov@linaro.org> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Thu, 10 Sep 2020 16:59:53 +0300 Dmitry Baryshkov wrote: > From: Craig Tatlor > > Adds a function to interpolate against two points, > this is carried arount as a helper function by tons of drivers. > > Signed-off-by: Craig Tatlor > Signed-off-by: Dmitry Baryshkov Seems sensible to have this. Acked-by: Jonathan Cameron > --- > include/linux/fixp-arith.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/include/linux/fixp-arith.h b/include/linux/fixp-arith.h > index 8396013785ef..281cb4f83dbe 100644 > --- a/include/linux/fixp-arith.h > +++ b/include/linux/fixp-arith.h > @@ -141,4 +141,23 @@ static inline s32 fixp_sin32_rad(u32 radians, u32 twopi) > #define fixp_cos32_rad(rad, twopi) \ > fixp_sin32_rad(rad + twopi / 4, twopi) > > +/** > + * fixp_linear_interpolate() - interpolates a value from two known points > + * > + * @x0: x value of point 0 > + * @y0: y value of point 0 > + * @x1: x value of point 1 > + * @y1: y value of point 1 > + * @x: the linear interpolant > + */ > +static inline int fixp_linear_interpolate(int x0, int y0, int x1, int y1, int x) > +{ > + if (y0 == y1 || x == x0) > + return y0; > + if (x1 == x0 || x == x1) > + return y1; > + > + return y0 + ((y1 - y0) * (x - x0) / (x1 - x0)); > +} > + > #endif