Commit 1e7c16a9 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Remove floating point use in cpia.c

From: Duncan Haldane <f.duncan.m.haldane@worldnet.att.net>

Gerd Knorr noticed a small use of floating point math in the cpia driver
updates for 2.5.x I sent you a while ago, and this is not allowed in the
kernel.

This was in some code taken essentially verbatim from the Windows cpia
driver released under the GPL by STM inc.  that had been incorporated in
the later versions of the cpia drivera sourceforge.

It turns out that the use of floating point was quite inessential, and I've
reimplemented the couple of lines of code involved in integer arithmetic.
parent 0af6874c
...@@ -2427,10 +2427,20 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags, ...@@ -2427,10 +2427,20 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
#define FIRMWARE_VERSION(x,y) (params->version.firmwareVersion == (x) && \ #define FIRMWARE_VERSION(x,y) (params->version.firmwareVersion == (x) && \
params->version.firmwareRevision == (y)) params->version.firmwareRevision == (y))
/* define for compgain calculation */ /* define for compgain calculation */
#if 0
#define COMPGAIN(base, curexp, newexp) \ #define COMPGAIN(base, curexp, newexp) \
(u8) ((((float) base - 128.0) * ((float) curexp / (float) newexp)) + 128.5) (u8) ((((float) base - 128.0) * ((float) curexp / (float) newexp)) + 128.5)
#define EXP_FROM_COMP(basecomp, curcomp, curexp) \ #define EXP_FROM_COMP(basecomp, curcomp, curexp) \
(u16)((float)curexp * (float)(u8)(curcomp + 128) / (float)(u8)(basecomp - 128)) (u16)((float)curexp * (float)(u8)(curcomp + 128) / (float)(u8)(basecomp - 128))
#else
/* equivalent functions without floating point math */
#define COMPGAIN(base, curexp, newexp) \
(u8)(128 + (((u32)(2*(base-128)*curexp + newexp)) / (2* newexp)) )
#define EXP_FROM_COMP(basecomp, curcomp, curexp) \
(u16)(((u32)(curexp * (u8)(curcomp + 128)) / (u8)(basecomp - 128)))
#endif
int currentexp = params->exposure.coarseExpLo + int currentexp = params->exposure.coarseExpLo +
params->exposure.coarseExpHi*256; params->exposure.coarseExpHi*256;
int startexp; int startexp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment