<div>Rename i2f() to int2float(), and make it global so one copy can be removed.</div><div><br></div><div>Remove the copy of i2f() in r600_blit_kms.c</div><div>We rename the function to something longer now that it is a global</div>
<div>symbol. This reduces the likelyhood of unintended clashes later.</div><div><br></div><div>This might be a candidate for inclusion inside general drm infrastructure.</div><div>However, at the moment only the radeon driver uses it.</div>
<div><br></div><div>Signed-off-by: Steven Fuerst <<a href="mailto:svfuerst@gmail.com">svfuerst@gmail.com</a>></div><div>---</div><div> drivers/gpu/drm/radeon/r600_blit.c | 66 ++++++++++++++--------------</div>
<div> drivers/gpu/drm/radeon/r600_blit_kms.c | 45 +++----------------</div><div> drivers/gpu/drm/radeon/r600_blit_shaders.h | 1 +</div><div> 3 files changed, 40 insertions(+), 72 deletions(-)</div><div><br></div>
<div>diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c</div><div>index f0ce441..7c748ba 100644</div><div>--- a/drivers/gpu/drm/radeon/r600_blit.c</div><div>+++ b/drivers/gpu/drm/radeon/r600_blit.c</div>
<div>@@ -501,7 +501,7 @@ set_default_state(drm_radeon_private_t *dev_priv)</div><div> * This routine depends on the mod(32) behaviour of the rotate instructions</div><div> * on x86.</div><div> */</div><div>-static uint32_t i2f(uint32_t x)</div>
<div>+uint32_t int2float(uint32_t x)</div><div> {</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>uint32_t msb, exponent, fraction;</div><div> </div><div>@@ -640,20 +640,20 @@ r600_blit_copy(struct drm_device *dev,</div>
<div> <span class="Apple-tab-span" style="white-space:pre"> </span>vb = r600_nomm_get_vb_ptr(dev);</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[0] = i2f(dst_x);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[0] = int2float(dst_x);</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>vb[1] = 0;</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[2] = i2f(src_x);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[2] = int2float(src_x);</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>vb[3] = 0;</div><div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[4] = i2f(dst_x);</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[5] = i2f(h);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[6] = i2f(src_x);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[7] = i2f(h);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[4] = int2float(dst_x);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[5] = int2float(h);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[6] = int2float(src_x);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[7] = int2float(h);</div><div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[8] = i2f(dst_x + cur_size);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[9] = i2f(h);</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[10] = i2f(src_x + cur_size);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[11] = i2f(h);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[8] = int2float(dst_x + cur_size);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[9] = int2float(h);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[10] = int2float(src_x + cur_size);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[11] = int2float(h);</div>
<div> </div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>/* src */</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>set_tex_resource(dev_priv, FMT_8,</div><div>@@ -729,20 +729,20 @@ r600_blit_copy(struct drm_device *dev,</div>
<div> <span class="Apple-tab-span" style="white-space:pre"> </span>vb = r600_nomm_get_vb_ptr(dev);</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[0] = i2f(dst_x / 4);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[0] = int2float(dst_x / 4);</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>vb[1] = 0;</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[2] = i2f(src_x / 4);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[2] = int2float(src_x / 4);</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>vb[3] = 0;</div><div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[4] = i2f(dst_x / 4);</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[5] = i2f(h);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[6] = i2f(src_x / 4);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[7] = i2f(h);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[4] = int2float(dst_x / 4);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[5] = int2float(h);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[6] = int2float(src_x / 4);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[7] = int2float(h);</div><div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[8] = i2f((dst_x + cur_size) / 4);</div><div>
-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[9] = i2f(h);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[10] = i2f((src_x + cur_size) / 4);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[11] = i2f(h);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[8] = int2float((dst_x + cur_size) / 4);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[9] = int2float(h);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[10] = int2float((src_x + cur_size) / 4);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[11] = int2float(h);</div><div> </div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>/* src */</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>set_tex_resource(dev_priv, FMT_8_8_8_8,</div>
<div>@@ -812,20 +812,20 @@ r600_blit_swap(struct drm_device *dev,</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>dx2 = dx + w;</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>dy2 = dy + h;</div>
<div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[0] = i2f(dx);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[1] = i2f(dy);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[2] = i2f(sx);</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[3] = i2f(sy);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[0] = int2float(dx);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[1] = int2float(dy);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[2] = int2float(sx);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[3] = int2float(sy);</div><div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[4] = i2f(dx);</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[5] = i2f(dy2);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[6] = i2f(sx);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[7] = i2f(sy2);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[4] = int2float(dx);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[5] = int2float(dy2);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[6] = int2float(sx);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[7] = int2float(sy2);</div><div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[8] = i2f(dx2);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[9] = i2f(dy2);</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[10] = i2f(sx2);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb[11] = i2f(sy2);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[8] = int2float(dx2);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[9] = int2float(dy2);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[10] = int2float(sx2);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb[11] = int2float(sy2);</div>
<div> </div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>switch(cpp) {</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>case 4:</div><div>diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c</div>
<div>index 8307558..1c7ed3a 100644</div><div>--- a/drivers/gpu/drm/radeon/r600_blit_kms.c</div><div>+++ b/drivers/gpu/drm/radeon/r600_blit_kms.c</div><div>@@ -455,39 +455,6 @@ set_default_state(struct radeon_device *rdev)</div>
<div> <span class="Apple-tab-span" style="white-space:pre"> </span>radeon_ring_write(ring, sq_stack_resource_mgmt_2);</div><div> }</div><div> </div><div>-/* 23 bits of float fractional data */</div><div>-#define I2F_FRAC_BITS<span class="Apple-tab-span" style="white-space:pre"> </span>23</div>
<div>-#define I2F_MASK ((1 << I2F_FRAC_BITS) - 1)</div><div>-</div><div>-/*</div><div>- * Converts unsigned integer into 32-bit IEEE floating point representation.</div><div>- * Will be exact from 0 to 2^24. Above that, we round towards zero</div>
<div>- * as the fractional bits will not fit in a float. (It would be better to</div><div>- * round towards even as the fpu does, but that is slower.)</div><div>- * This routine depends on the mod(32) behaviour of the rotate instructions</div>
<div>- * on x86.</div><div>- */</div><div>-static uint32_t i2f(uint32_t x)</div><div>-{</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>uint32_t msb, exponent, fraction;</div><div>-</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>/* Zero is special */</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!x) return 0;</div><div>-</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>/* Get location of the most significant bit */</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>msb = __fls(x);</div><div>-</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>/*</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span> * Use a rotate instead of a shift because that works both leftwards</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span> * and rightwards due to the mod(32) beahviour. This means we don't</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span> * need to check to see if we are above 2^24 or not.</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span> */</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>fraction = ror32(x, msb - I2F_FRAC_BITS) & I2F_MASK;</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>exponent = (127 + msb) << I2F_FRAC_BITS;</div>
<div>-</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>return fraction + exponent;</div><div>-}</div><div>-</div><div> int r600_blit_init(struct radeon_device *rdev)</div><div> {</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>u32 obj_size;</div>
<div>@@ -759,14 +726,14 @@ void r600_kms_blit_copy(struct radeon_device *rdev,</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[3] = 0;</div><div> </div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[4] = 0;</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[5] = i2f(h);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[5] = int2float(h);</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[6] = 0;</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[7] = i2f(h);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[7] = int2float(h);</div><div> </div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[8] = i2f(w);</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[9] = i2f(h);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[10] = i2f(w);</div><div>-<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[11] = i2f(h);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[8] = int2float(w);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[9] = int2float(h);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[10] = int2float(w);</div>
<div>+<span class="Apple-tab-span" style="white-space:pre"> </span>vb_cpu_addr[11] = int2float(h);</div><div> </div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>rdev->r600_blit.primitives.set_tex_resource(rdev, FMT_8_8_8_8,</div>
<div> <span class="Apple-tab-span" style="white-space:pre"> </span> w, h, w, src_gpu_addr, size_in_bytes);</div><div>diff --git a/drivers/gpu/drm/radeon/r600_blit_shaders.h b/drivers/gpu/drm/radeon/r600_blit_shaders.h</div>
<div>index f437d36..e17c2cb 100644</div><div>--- a/drivers/gpu/drm/radeon/r600_blit_shaders.h</div><div>+++ b/drivers/gpu/drm/radeon/r600_blit_shaders.h</div><div>@@ -35,4 +35,5 @@ extern const u32 r6xx_default_state[];</div>
<div> extern const u32 r6xx_ps_size, r6xx_vs_size;</div><div> extern const u32 r6xx_default_size, r7xx_default_size;</div><div> </div><div>+uint32_t int2float(uint32_t x);</div><div> #endif</div>