aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon
diff options
context:
space:
mode:
authorSteven Fuerst <svfuerst@gmail.com>2012-08-15 18:07:14 -0400
committerAlex Deucher <alexander.deucher@amd.com>2012-09-20 13:10:33 -0400
commit7ff64fcaa7b7ba62d12758e49643f31dd9e90ece (patch)
treee5deb48d04a5c5409cf960077918752147908293 /drivers/gpu/drm/radeon
parentee93b86be118dcdec1a8e29983ed1d010c71bfee (diff)
Rename i2f() to int2float(), and make it global so one copy can be removed.
Remove the copy of i2f() in r600_blit_kms.c We rename the function to something longer now that it is a global symbol. This reduces the likelyhood of unintended clashes later. This might be a candidate for inclusion inside general drm infrastructure. However, at the moment only the radeon driver uses it. Signed-off-by: Steven Fuerst <svfuerst@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/radeon')
-rw-r--r--drivers/gpu/drm/radeon/r600_blit.c66
-rw-r--r--drivers/gpu/drm/radeon/r600_blit_kms.c52
-rw-r--r--drivers/gpu/drm/radeon/r600_blit_shaders.h1
3 files changed, 40 insertions, 79 deletions
diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
index 3c031a48205d..ee1b815b5689 100644
--- a/drivers/gpu/drm/radeon/r600_blit.c
+++ b/drivers/gpu/drm/radeon/r600_blit.c
@@ -489,7 +489,7 @@ set_default_state(drm_radeon_private_t *dev_priv)
489 ADVANCE_RING(); 489 ADVANCE_RING();
490} 490}
491 491
492static uint32_t i2f(uint32_t input) 492uint32_t int2float(uint32_t input)
493{ 493{
494 u32 result, i, exponent, fraction; 494 u32 result, i, exponent, fraction;
495 495
@@ -632,20 +632,20 @@ r600_blit_copy(struct drm_device *dev,
632 vb = r600_nomm_get_vb_ptr(dev); 632 vb = r600_nomm_get_vb_ptr(dev);
633 } 633 }
634 634
635 vb[0] = i2f(dst_x); 635 vb[0] = int2float(dst_x);
636 vb[1] = 0; 636 vb[1] = 0;
637 vb[2] = i2f(src_x); 637 vb[2] = int2float(src_x);
638 vb[3] = 0; 638 vb[3] = 0;
639 639
640 vb[4] = i2f(dst_x); 640 vb[4] = int2float(dst_x);
641 vb[5] = i2f(h); 641 vb[5] = int2float(h);
642 vb[6] = i2f(src_x); 642 vb[6] = int2float(src_x);
643 vb[7] = i2f(h); 643 vb[7] = int2float(h);
644 644
645 vb[8] = i2f(dst_x + cur_size); 645 vb[8] = int2float(dst_x + cur_size);
646 vb[9] = i2f(h); 646 vb[9] = int2float(h);
647 vb[10] = i2f(src_x + cur_size); 647 vb[10] = int2float(src_x + cur_size);
648 vb[11] = i2f(h); 648 vb[11] = int2float(h);
649 649
650 /* src */ 650 /* src */
651 set_tex_resource(dev_priv, FMT_8, 651 set_tex_resource(dev_priv, FMT_8,
@@ -721,20 +721,20 @@ r600_blit_copy(struct drm_device *dev,
721 vb = r600_nomm_get_vb_ptr(dev); 721 vb = r600_nomm_get_vb_ptr(dev);
722 } 722 }
723 723
724 vb[0] = i2f(dst_x / 4); 724 vb[0] = int2float(dst_x / 4);
725 vb[1] = 0; 725 vb[1] = 0;
726 vb[2] = i2f(src_x / 4); 726 vb[2] = int2float(src_x / 4);
727 vb[3] = 0; 727 vb[3] = 0;
728 728
729 vb[4] = i2f(dst_x / 4); 729 vb[4] = int2float(dst_x / 4);
730 vb[5] = i2f(h); 730 vb[5] = int2float(h);
731 vb[6] = i2f(src_x / 4); 731 vb[6] = int2float(src_x / 4);
732 vb[7] = i2f(h); 732 vb[7] = int2float(h);
733 733
734 vb[8] = i2f((dst_x + cur_size) / 4); 734 vb[8] = int2float((dst_x + cur_size) / 4);
735 vb[9] = i2f(h); 735 vb[9] = int2float(h);
736 vb[10] = i2f((src_x + cur_size) / 4); 736 vb[10] = int2float((src_x + cur_size) / 4);
737 vb[11] = i2f(h); 737 vb[11] = int2float(h);
738 738
739 /* src */ 739 /* src */
740 set_tex_resource(dev_priv, FMT_8_8_8_8, 740 set_tex_resource(dev_priv, FMT_8_8_8_8,
@@ -804,20 +804,20 @@ r600_blit_swap(struct drm_device *dev,
804 dx2 = dx + w; 804 dx2 = dx + w;
805 dy2 = dy + h; 805 dy2 = dy + h;
806 806
807 vb[0] = i2f(dx); 807 vb[0] = int2float(dx);
808 vb[1] = i2f(dy); 808 vb[1] = int2float(dy);
809 vb[2] = i2f(sx); 809 vb[2] = int2float(sx);
810 vb[3] = i2f(sy); 810 vb[3] = int2float(sy);
811 811
812 vb[4] = i2f(dx); 812 vb[4] = int2float(dx);
813 vb[5] = i2f(dy2); 813 vb[5] = int2float(dy2);
814 vb[6] = i2f(sx); 814 vb[6] = int2float(sx);
815 vb[7] = i2f(sy2); 815 vb[7] = int2float(sy2);
816 816
817 vb[8] = i2f(dx2); 817 vb[8] = int2float(dx2);
818 vb[9] = i2f(dy2); 818 vb[9] = int2float(dy2);
819 vb[10] = i2f(sx2); 819 vb[10] = int2float(sx2);
820 vb[11] = i2f(sy2); 820 vb[11] = int2float(sy2);
821 821
822 switch(cpp) { 822 switch(cpp) {
823 case 4: 823 case 4:
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c
index 2bef8549ddfe..1c7ed3a5d045 100644
--- a/drivers/gpu/drm/radeon/r600_blit_kms.c
+++ b/drivers/gpu/drm/radeon/r600_blit_kms.c
@@ -455,46 +455,6 @@ set_default_state(struct radeon_device *rdev)
455 radeon_ring_write(ring, sq_stack_resource_mgmt_2); 455 radeon_ring_write(ring, sq_stack_resource_mgmt_2);
456} 456}
457 457
458#define I2F_MAX_BITS 15
459#define I2F_MAX_INPUT ((1 << I2F_MAX_BITS) - 1)
460#define I2F_SHIFT (24 - I2F_MAX_BITS)
461
462/*
463 * Converts unsigned integer into 32-bit IEEE floating point representation.
464 * Conversion is not universal and only works for the range from 0
465 * to 2^I2F_MAX_BITS-1. Currently we only use it with inputs between
466 * 0 and 16384 (inclusive), so I2F_MAX_BITS=15 is enough. If necessary,
467 * I2F_MAX_BITS can be increased, but that will add to the loop iterations
468 * and slow us down. Conversion is done by shifting the input and counting
469 * down until the first 1 reaches bit position 23. The resulting counter
470 * and the shifted input are, respectively, the exponent and the fraction.
471 * The sign is always zero.
472 */
473static uint32_t i2f(uint32_t input)
474{
475 u32 result, i, exponent, fraction;
476
477 WARN_ON_ONCE(input > I2F_MAX_INPUT);
478
479 if ((input & I2F_MAX_INPUT) == 0)
480 result = 0;
481 else {
482 exponent = 126 + I2F_MAX_BITS;
483 fraction = (input & I2F_MAX_INPUT) << I2F_SHIFT;
484
485 for (i = 0; i < I2F_MAX_BITS; i++) {
486 if (fraction & 0x800000)
487 break;
488 else {
489 fraction = fraction << 1;
490 exponent = exponent - 1;
491 }
492 }
493 result = exponent << 23 | (fraction & 0x7fffff);
494 }
495 return result;
496}
497
498int r600_blit_init(struct radeon_device *rdev) 458int r600_blit_init(struct radeon_device *rdev)
499{ 459{
500 u32 obj_size; 460 u32 obj_size;
@@ -766,14 +726,14 @@ void r600_kms_blit_copy(struct radeon_device *rdev,
766 vb_cpu_addr[3] = 0; 726 vb_cpu_addr[3] = 0;
767 727
768 vb_cpu_addr[4] = 0; 728 vb_cpu_addr[4] = 0;
769 vb_cpu_addr[5] = i2f(h); 729 vb_cpu_addr[5] = int2float(h);
770 vb_cpu_addr[6] = 0; 730 vb_cpu_addr[6] = 0;
771 vb_cpu_addr[7] = i2f(h); 731 vb_cpu_addr[7] = int2float(h);
772 732
773 vb_cpu_addr[8] = i2f(w); 733 vb_cpu_addr[8] = int2float(w);
774 vb_cpu_addr[9] = i2f(h); 734 vb_cpu_addr[9] = int2float(h);
775 vb_cpu_addr[10] = i2f(w); 735 vb_cpu_addr[10] = int2float(w);
776 vb_cpu_addr[11] = i2f(h); 736 vb_cpu_addr[11] = int2float(h);
777 737
778 rdev->r600_blit.primitives.set_tex_resource(rdev, FMT_8_8_8_8, 738 rdev->r600_blit.primitives.set_tex_resource(rdev, FMT_8_8_8_8,
779 w, h, w, src_gpu_addr, size_in_bytes); 739 w, h, w, src_gpu_addr, size_in_bytes);
diff --git a/drivers/gpu/drm/radeon/r600_blit_shaders.h b/drivers/gpu/drm/radeon/r600_blit_shaders.h
index f437d36dd98c..e17c2cbc6627 100644
--- a/drivers/gpu/drm/radeon/r600_blit_shaders.h
+++ b/drivers/gpu/drm/radeon/r600_blit_shaders.h
@@ -35,4 +35,5 @@ extern const u32 r6xx_default_state[];
35extern const u32 r6xx_ps_size, r6xx_vs_size; 35extern const u32 r6xx_ps_size, r6xx_vs_size;
36extern const u32 r6xx_default_size, r7xx_default_size; 36extern const u32 r6xx_default_size, r7xx_default_size;
37 37
38uint32_t int2float(uint32_t x);
38#endif 39#endif