summaryrefslogtreecommitdiffstats
path: root/src/broadcom/cle/v3d_packet_helpers.h
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2016-12-30 11:07:34 -0800
committerEric Anholt <[email protected]>2017-07-13 11:28:28 -0700
commitee170c9d83e623e19fb07fed50f3d82b8a035bf4 (patch)
treee7709e657e91ea566228cdae0a22c3d10411344d /src/broadcom/cle/v3d_packet_helpers.h
parent655a32f729a46176c1fc0c1727b33c15c69cad78 (diff)
broadcom/genxml: Support unpacking fixed-point fractional values.
This was an oversight in the original XML support, because unpacking wasn't used much. The new XML-based CL dumper will want it, though.
Diffstat (limited to 'src/broadcom/cle/v3d_packet_helpers.h')
-rw-r--r--src/broadcom/cle/v3d_packet_helpers.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/broadcom/cle/v3d_packet_helpers.h b/src/broadcom/cle/v3d_packet_helpers.h
index d01ff6ef0ad..c86cad85266 100644
--- a/src/broadcom/cle/v3d_packet_helpers.h
+++ b/src/broadcom/cle/v3d_packet_helpers.h
@@ -177,6 +177,22 @@ __gen_unpack_sint(const uint8_t *restrict cl, uint32_t start, uint32_t end)
}
static inline float
+__gen_unpack_sfixed(const uint8_t *restrict cl, uint32_t start, uint32_t end,
+ uint32_t fractional_size)
+{
+ int32_t bits = __gen_unpack_sint(cl, start, end);
+ return (float)bits / (1 << fractional_size);
+}
+
+static inline float
+__gen_unpack_ufixed(const uint8_t *restrict cl, uint32_t start, uint32_t end,
+ uint32_t fractional_size)
+{
+ int32_t bits = __gen_unpack_uint(cl, start, end);
+ return (float)bits / (1 << fractional_size);
+}
+
+static inline float
__gen_unpack_float(const uint8_t *restrict cl, uint32_t start, uint32_t end)
{
assert(start % 8 == 0);