Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp844238imm; Wed, 13 Jun 2018 09:08:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKILtRd4sCyKCe41sZj/6ifrcnEVHK5zSSxJgrD4bF77hmdrzBldzzu2bDqm5bpsNLnogHHP X-Received: by 2002:a63:343:: with SMTP id 64-v6mr4695104pgd.354.1528906095551; Wed, 13 Jun 2018 09:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528906095; cv=none; d=google.com; s=arc-20160816; b=k8eYCjuJxQNddjF5LRXpeJicCKfARGA620s8YgCNuYSTezBP1vx8NyvkdAVpECWBEN 5yUe3GJLjcQUmy71/ib8lnASfh1c9TDlE1pudslVCtvQ9a8y8I3Dm03co56ilXGSvKLd THxCZhvYDgvGMztSLIg2B/zXfowXKbxZ49TxPhR4E+V5mm0tsjPRddDIEFLmEhABAxcA i7HJVRUBvJnYLH+yDAnszgKU2fk3B9hobWLR/+o2mK+zwRNv11bwidfzi8xp54cb3EO5 2ekApY3THyPlpLZT90UBQ+Waq+ZQqtQxdKAior/8OVhR/w9bNjHapglkiM8TvfvplpJV 8PXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature:arc-authentication-results; bh=dcjfljfyhlrqZwWH1+9gew4bvxQUwNYXgP36XZgaDEo=; b=ccaGUZK7juNlrZF+3Pnhi3IY3W1C35Mcyh5oR1IVx3rIbaaHssYKPXHqNahqjwCemM DSU8+GU+ZXnP6iwj0Ax9kpqEMpHMC6vBUOeI2CYAoDyGFxI9cEzyHOZ1WVmkm8HZiWPE 5f7mXYfl5i2ADUDKNnHS7nwMEBr3Qy13R/MKl3SGpYlDgrDdKJjnph0OFqLWSHodcS5Y xRrI0U2L9OzFcXCvHZKUXJsymjPIukxfHV5Afo1RKbxMRCDaIW0uS3XIBmd/7HeOAgik oin45zX2QdaadG0OfW3FuoUzLJ98TWajiSMJe7N0isawl6uVoqYEuJHXyyAwgOuj52Uq zcmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=WWwYymag; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g66-v6si3228996pfd.86.2018.06.13.09.07.56; Wed, 13 Jun 2018 09:08:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=WWwYymag; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935987AbeFMQHV (ORCPT + 99 others); Wed, 13 Jun 2018 12:07:21 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33021 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935500AbeFMQHT (ORCPT ); Wed, 13 Jun 2018 12:07:19 -0400 Received: by mail-pf0-f195.google.com with SMTP id b17-v6so1669424pfi.0; Wed, 13 Jun 2018 09:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dcjfljfyhlrqZwWH1+9gew4bvxQUwNYXgP36XZgaDEo=; b=WWwYymagRz/Q4ENRHjfHZS3hactL7l5WHHXAi7mTP/070uEW0lvXKadmu5aOMHAROq GIrAbDKB1EqNbhFm+vREOt/3lb8k7zgnSq+1lSpEIzD8iGiUGlBGQfDzN5jyukN6rm0W tLjB/oaej7Mt/c5z6SpBOSiyXK4++Opuelm6xPI5cYvK9wle7E4K+RaGQXZSy8eCgcji 1ams8GN1hwcTyq0Zn2bXBZCDP5X3mwIOnHLP2hh53+ko4DdggxQ4p4oGSnlfwnu7sYbj IYdrRqHNAFudhD1qyhyMZgTrycQIlF6bc97jmFefnNZW/jbDch1wDfr9tmINvg+994lx ScuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dcjfljfyhlrqZwWH1+9gew4bvxQUwNYXgP36XZgaDEo=; b=kNUDOpxT/4TnHB3XC/6ZVQhbB3+C/aw58c2pcrB2bc1a2AnbvrMzBOHJpX1GCkIUoe LZ6o6XrBME4kgKZC0h4mYyeI53u6ol3k0CBeWNfTN4A05Lpj+TQFyt/Pem1cie2PGq6e UElnhl8T+bIoNxt1q4v8VpTY69xjfyYgoyS7JPHzUijjdtshQsg+N8cdinM1zwf21dY4 vVd+VElEtxqTSv0psE0ZWy+Atv/TUCMZZ4rQui/h9s0fyrvFcq8ZHIAeOXC5edN0ei2U wUc/Nve4wvDMqNn30i7sEr/sluY3xc4nmo1mCjsMPPIdY/GjE6IcemwZFyP69Tt31200 iRnw== X-Gm-Message-State: APt69E0diaRYvNBQbEleMCLuJBFaRqUfO4vu+XtndJCqpK5i3wuSOy+Q MzfAHgTyxhaBq5Rd5bka7g== X-Received: by 2002:a63:b705:: with SMTP id t5-v6mr4575433pgf.343.1528906038831; Wed, 13 Jun 2018 09:07:18 -0700 (PDT) Received: from localhost.localdomain (host81-131-105-100.range81-131.btcentralplus.com. [81.131.105.100]) by smtp.googlemail.com with ESMTPSA id z19-v6sm4459577pfe.163.2018.06.13.09.07.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 09:07:18 -0700 (PDT) From: Craig Tatlor Cc: ctatlor97@gmail.com, linux-arm-msm@vger.kernel.org, Sebastian Reichel , Rob Herring , Mark Rutland , Mauro Carvalho Chehab , "David S. Miller" , Andrew Morton , Greg Kroah-Hartman , Linus Walleij , Randy Dunlap , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/4] fixp-arith: add a linear interpolation function Date: Wed, 13 Jun 2018 17:06:22 +0100 Message-Id: <20180613160643.12638-1-ctatlor97@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180407135934.26122-1-ctatlor97@gmail.com> References: <20180407135934.26122-1-ctatlor97@gmail.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- include/linux/fixp-arith.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/fixp-arith.h b/include/linux/fixp-arith.h index d4686fe1cac7..c21de4f358dd 100644 --- a/include/linux/fixp-arith.h +++ b/include/linux/fixp-arith.h @@ -153,4 +153,24 @@ 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 -- 2.17.0