Return-path: Received: from mail-wi0-f172.google.com ([209.85.212.172]:38520 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932282Ab2EONRN (ORCPT ); Tue, 15 May 2012 09:17:13 -0400 Received: by wibhj8 with SMTP id hj8so2791199wib.1 for ; Tue, 15 May 2012 06:17:12 -0700 (PDT) From: Gianluca Gennari To: linux-media@vger.kernel.org, mchehab@redhat.com, hans.verkuil@cisco.com Cc: Gianluca Gennari Subject: [PATCH] media_build: add fixp-arith.h in linux/include/linux Date: Tue, 15 May 2012 15:16:41 +0200 Message-Id: <1337087801-31527-1-git-send-email-gennarone@gmail.com> Sender: linux-media-owner@vger.kernel.org List-ID: This patch: http://patchwork.linuxtv.org/patch/10824/ moved the file fixp-arith.h from drivers/input/ to include/linux/ . To make this file available to old kernels, we must include it in the media_build package. The version included here comes from kernel 3.4-rc7. This patch corrects the following build error: media_build/v4l/ov534.c:38:30: error: linux/fixp-arith.h: No such file or directory media_build/v4l/ov534.c: In function 'sethue': media_build/v4l/ov534.c:1000: error: implicit declaration of function 'fixp_sin' media_build/v4l/ov534.c:1001: error: implicit declaration of function 'fixp_cos' Tested on kernel 2.6.32-41-generic-pae (Ubuntu 10.04). Signed-off-by: Gianluca Gennari + */ + +#include + +/* The type representing fixed-point values */ +typedef s16 fixp_t; + +#define FRAC_N 8 +#define FRAC_MASK ((1< 123.0 */ +static inline fixp_t fixp_new(s16 a) +{ + return a< -1.0 + 0x8000 -> 1.0 + 0x0000 -> 0.0 +*/ +static inline fixp_t fixp_new16(s16 a) +{ + return ((s32)a)>>(16-FRAC_N); +} + +static inline fixp_t fixp_cos(unsigned int degrees) +{ + int quadrant = (degrees / 90) & 3; + unsigned int i = degrees % 90; + + if (quadrant == 1 || quadrant == 3) + i = 90 - i; + + i >>= 1; + + return (quadrant == 1 || quadrant == 2)? -cos_table[i] : cos_table[i]; +} + +static inline fixp_t fixp_sin(unsigned int degrees) +{ + return -fixp_cos(degrees + 90); +} + +static inline fixp_t fixp_mult(fixp_t a, fixp_t b) +{ + return ((s32)(a*b))>>FRAC_N; +} + +#endif -- 1.7.0.4