diff options
author | Arnd Bergmann <arnd@arndb.de> | 2012-02-22 09:20:07 -0500 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2012-02-22 09:20:18 -0500 |
commit | 2daa79ec2126f8e710391e9d8e8f0d31d7c91d5f (patch) | |
tree | ab89c74c09c2986fa01c25ad8e45989a48a18899 /drivers/gpu/drm/radeon/r600_blit_kms.c | |
parent | 7dae8c5209147ad06d424928a5f1ec45caa87691 (diff) | |
parent | 678a0222edc9da43a22145d68647500ee85e6c04 (diff) |
Merge branch 'lpc32xx/drivers' into next/drivers
* lpc32xx/drivers: (566 commits)
ARM: LPC32xx: ADC support for mach-lpc32xx
Includes an update to Linux 3.3-rc4
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/gpu/drm/radeon/r600_blit_kms.c')
-rw-r--r-- | drivers/gpu/drm/radeon/r600_blit_kms.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c index d996f4381130..accc032c103f 100644 --- a/drivers/gpu/drm/radeon/r600_blit_kms.c +++ b/drivers/gpu/drm/radeon/r600_blit_kms.c | |||
@@ -468,27 +468,42 @@ set_default_state(struct radeon_device *rdev) | |||
468 | radeon_ring_write(ring, sq_stack_resource_mgmt_2); | 468 | radeon_ring_write(ring, sq_stack_resource_mgmt_2); |
469 | } | 469 | } |
470 | 470 | ||
471 | #define I2F_MAX_BITS 15 | ||
472 | #define I2F_MAX_INPUT ((1 << I2F_MAX_BITS) - 1) | ||
473 | #define I2F_SHIFT (24 - I2F_MAX_BITS) | ||
474 | |||
475 | /* | ||
476 | * Converts unsigned integer into 32-bit IEEE floating point representation. | ||
477 | * Conversion is not universal and only works for the range from 0 | ||
478 | * to 2^I2F_MAX_BITS-1. Currently we only use it with inputs between | ||
479 | * 0 and 16384 (inclusive), so I2F_MAX_BITS=15 is enough. If necessary, | ||
480 | * I2F_MAX_BITS can be increased, but that will add to the loop iterations | ||
481 | * and slow us down. Conversion is done by shifting the input and counting | ||
482 | * down until the first 1 reaches bit position 23. The resulting counter | ||
483 | * and the shifted input are, respectively, the exponent and the fraction. | ||
484 | * The sign is always zero. | ||
485 | */ | ||
471 | static uint32_t i2f(uint32_t input) | 486 | static uint32_t i2f(uint32_t input) |
472 | { | 487 | { |
473 | u32 result, i, exponent, fraction; | 488 | u32 result, i, exponent, fraction; |
474 | 489 | ||
475 | if ((input & 0x3fff) == 0) | 490 | WARN_ON_ONCE(input > I2F_MAX_INPUT); |
476 | result = 0; /* 0 is a special case */ | 491 | |
492 | if ((input & I2F_MAX_INPUT) == 0) | ||
493 | result = 0; | ||
477 | else { | 494 | else { |
478 | exponent = 140; /* exponent biased by 127; */ | 495 | exponent = 126 + I2F_MAX_BITS; |
479 | fraction = (input & 0x3fff) << 10; /* cheat and only | 496 | fraction = (input & I2F_MAX_INPUT) << I2F_SHIFT; |
480 | handle numbers below 2^^15 */ | 497 | |
481 | for (i = 0; i < 14; i++) { | 498 | for (i = 0; i < I2F_MAX_BITS; i++) { |
482 | if (fraction & 0x800000) | 499 | if (fraction & 0x800000) |
483 | break; | 500 | break; |
484 | else { | 501 | else { |
485 | fraction = fraction << 1; /* keep | 502 | fraction = fraction << 1; |
486 | shifting left until top bit = 1 */ | ||
487 | exponent = exponent - 1; | 503 | exponent = exponent - 1; |
488 | } | 504 | } |
489 | } | 505 | } |
490 | result = exponent << 23 | (fraction & 0x7fffff); /* mask | 506 | result = exponent << 23 | (fraction & 0x7fffff); |
491 | off top bit; assumed 1 */ | ||
492 | } | 507 | } |
493 | return result; | 508 | return result; |
494 | } | 509 | } |