Paul Menzel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/38647 )
Change subject: drivers/intel/gma/edid: Use byte swap function ......................................................................
drivers/intel/gma/edid: Use byte swap function
Instead of open coding the byte swapping (endianess), use the built-in.
The compiler can use the instruction `bswap` now. As EDID data is not big, the difference in execution time won’t be measurable.
With gcc (Debian 9.2.1-25) 9.2.1 20200123:
.LBE128: .LBE127: - .loc 1 94 3 is_stmt 1 discriminator 3 view .LVU157 - addl $4, %ebp - .loc 1 94 15 is_stmt 0 discriminator 3 view .LVU158 - movb %al, -4(%ebp) - .loc 1 95 3 is_stmt 1 discriminator 3 view .LVU159 - .loc 1 96 28 is_stmt 0 discriminator 3 view .LVU160 - movl %eax, %edx - .loc 1 95 19 discriminator 3 view .LVU161 - movb %ah, -3(%ebp) - .loc 1 96 3 is_stmt 1 discriminator 3 view .LVU162 - .loc 1 96 28 is_stmt 0 discriminator 3 view .LVU163 - shrl $16, %edx - .loc 1 96 19 discriminator 3 view .LVU164 - movb %dl, -2(%ebp) - .loc 1 97 3 is_stmt 1 discriminator 3 view .LVU165 - .loc 1 97 35 is_stmt 0 discriminator 3 view .LVU166 - shrl $24, %eax + .loc 1 96 3 is_stmt 1 discriminator 3 view .LVU159 + .loc 1 96 15 is_stmt 0 discriminator 3 view .LVU160 + movl 76(%esp), %edx + .loc 1 96 17 discriminator 3 view .LVU161 + bswap %eax
Change-Id: I818318361a83b2b3f0c6d8637dd3b6917590c836 Signed-off-by: Paul Menzel pmenzel@molgen.mpg.de --- M src/drivers/intel/gma/edid.c 1 file changed, 3 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/47/38647/1
diff --git a/src/drivers/intel/gma/edid.c b/src/drivers/intel/gma/edid.c index 6885f98..5f1cfe8 100644 --- a/src/drivers/intel/gma/edid.c +++ b/src/drivers/intel/gma/edid.c @@ -15,6 +15,7 @@ #include <device/mmio.h> #include <console/console.h> #include <delay.h> +#include <swab.h> #include <timer.h>
#include "i915_reg.h" @@ -91,10 +92,8 @@ u32 reg32; wait_rdy(mmio); reg32 = read32(GMBUS3_ADDR); - edid[4 * i] = reg32 & 0xff; - edid[4 * i + 1] = (reg32 >> 8) & 0xff; - edid[4 * i + 2] = (reg32 >> 16) & 0xff; - edid[4 * i + 3] = (reg32 >> 24) & 0xff; + /* Writes 4 * i to (4 * i) + 3 */ + edid[4 * i] = swab32(reg32); } wait_rdy(mmio); write32(GMBUS1_ADDR, GMBUS_SW_RDY