Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2069381imm; Thu, 14 Jun 2018 08:17:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKJOfh4wnPJaVUp8tlDAtkPT2QuxF30XcU2CgDcEdSToclrqpDRZfiGFNGYZ19XIdQoht/z X-Received: by 2002:a17:902:24c7:: with SMTP id l7-v6mr3515914plg.170.1528989419983; Thu, 14 Jun 2018 08:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528989419; cv=none; d=google.com; s=arc-20160816; b=T/6igcLhRCrGUQPD6joEVpYblL5qCdoFGnuJEJmZIph1zQ8ItIBmGyQLMcJ9/6kLdt o+2cG275R4XuqFl3JtlprychaCXXk11Jdcgl82z/g/qJ2y3YDSqQMhcyEw/6Rw5Xnh5l XF7SWFJ84ksJvYsOo1v1a9cINa6kPfrJ/iWLFATIAWSI0nLCJuHk6/8exeeN25qdy7xh P8VIebUaBu7015pZwcjnjR2mxIJcLK6ENiQHY2+EZnKboT7YChUmGN8zKHP7VWTMhHP0 ad7czfdNNWB5rUBw2XkgIxoJEV//K2lX9w4JphKCUt/WRA8wNxtJV5HFzMaHLoeuPpuM onXw== 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=QEDFBPLVkzjxg0xef+ST22+znpQbaduoWPWawiwbdJY=; b=lZmGlc43tyfS9mR6uYlIK6RZPVRxRk4Dm/vdWcn/GDQbnSFlpxiZKHWyJj1fXTtRJQ f7+eeCTISuaZtS2SpPdrVGLCY4bLS5DurLJP2DYnlvW/M0UKDny6YJI/3zhuMgFr1OWD ETobeOm6M2KbQeldKIrJuTsFuduoXa041l7hjP8geXxyWN4ypP2G2VJFVJ2CMLMaC+HF 2BL9JIJP9n7mqnwGgQS5nHQQhdonAQP7iysz1B7Dh/mvRoMzli4/t1DYFaeZDiT6sNZj cqtzyQEj+nR+arcqAaiVIw0Hm/hQBVUuciPHByDoyO9ExRd2VxlJIS3b41NhaudsmXaG pDJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZpY7bkkD; 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 34-v6si5624223plz.479.2018.06.14.08.16.45; Thu, 14 Jun 2018 08:16:59 -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=ZpY7bkkD; 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 S964853AbeFNPPQ (ORCPT + 99 others); Thu, 14 Jun 2018 11:15:16 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:45293 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964807AbeFNPPO (ORCPT ); Thu, 14 Jun 2018 11:15:14 -0400 Received: by mail-pl0-f68.google.com with SMTP id c23-v6so3709795plz.12; Thu, 14 Jun 2018 08:15:14 -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=QEDFBPLVkzjxg0xef+ST22+znpQbaduoWPWawiwbdJY=; b=ZpY7bkkDUK1UyPRGoSWCIIJMIJxtWksQW5zrzgrOMgV9S4ZOEpJHmZ1vsZqBgq4wd4 rlTti81TVcCSiTLmNr2oaDiTc4xFrbHC4SBC7N5YnA+bZvGDc3F33TrOXu4xeepctlMM hO4ac1vy4JgG+WMYNeh8Z0n6oASgmjXBajzmfouL5z07SIbINNhKCOJfZTtylqVI0XKh lw9uJbYcI0VjzCZfXTFZFD7hZGQuEfHe54d3k2gUL68d8ISA2cTgAfUS/hMLe/fZSM0y iB4mkGafoNnWjZvQjvHMQouEcUuCzOZnpA2zqmqpxaYNMQLDhwhQMaXa41fT+XF1aXYC glAA== 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=QEDFBPLVkzjxg0xef+ST22+znpQbaduoWPWawiwbdJY=; b=YeFbrGivclb40KXe4K1Mc862/xibJdRLSV1hHm9XPWg29ghFZGmse2zX0wqmW2JI4e QavLVm9c6SwIydJVVthkoQkRWrSZD0Lsf07y4xbOvuYaMVEy/fGF5HMoGA40+M66gGjJ ikg/pWl2NxfIxvuon4TZ6BXkQUn6zPOq8SIqXevhDhkHFneTolvKdJ3WY3UouTnPya/f ELY/fpCn3Yq/8k4r8Z/NejhQqPv8qWt3JgHRd5jTj5PyLnCkbShtcDt87sjfumrfcsJG uq62rxLac841wdwRI2cFMMG4xLM2hEgX5i1tF/STiUyxcB8R+isY+cy0HqyfH0Iu2G7+ Btew== X-Gm-Message-State: APt69E2ttZ75DMTISdLd2tCU6mc9pOYa5KKs2TYBRehXLcINqnLGU2Kc 3tFcmE19uyWBztlVsrcTq4kJ X-Received: by 2002:a17:902:722:: with SMTP id 31-v6mr3553738pli.3.1528989313904; Thu, 14 Jun 2018 08:15:13 -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 u63-v6sm8337276pgd.65.2018.06.14.08.15.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 08:15:13 -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 v7 1/4] fixp-arith: add a linear interpolation function Date: Thu, 14 Jun 2018 16:14:14 +0100 Message-Id: <20180614151435.6471-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 Reviewed-by: Linus Walleij --- 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..b9e2bb59a734 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