summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2021-03-10 13:56:00 -0800
committerIan Romanick <ian.d.romanick@intel.com>2021-04-02 14:29:14 -0700
commit74a55169114d7305eb61d4a864c0f478b5f3f9da (patch)
tree4e6353bacf69abfdab4839d38329a2c6a3a43f95
parent20f3e5fa39a3377d8143a420126dfac5bfa955c1 (diff)
ext_image_dma_buf_import/sample_yuv: Fix endianess problems in P0XX tests
drm_fourcc.h clearly says this data is little endian. Future commits will add more tests for little-endian formats from drm_fourcc.h. Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/501>
-rw-r--r--CMakeLists.txt1
-rw-r--r--tests/spec/ext_image_dma_buf_import/sample_yuv.c29
-rw-r--r--tests/util/config.h.in1
3 files changed, 23 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5bf1875d5..01cdf2ebb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -461,6 +461,7 @@ endif()
check_function_exists(setrlimit HAVE_SETRLIMIT)
check_symbol_exists(htobe32 "endian.h" HAVE_HTOBE32)
+check_symbol_exists(htole16 "endian.h" HAVE_HTOLE16)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
diff --git a/tests/spec/ext_image_dma_buf_import/sample_yuv.c b/tests/spec/ext_image_dma_buf_import/sample_yuv.c
index 3a40a5108..c08efc440 100644
--- a/tests/spec/ext_image_dma_buf_import/sample_yuv.c
+++ b/tests/spec/ext_image_dma_buf_import/sample_yuv.c
@@ -21,6 +21,7 @@
* IN THE SOFTWARE.
*/
+#include <endian.h>
#include "sample_common.h"
#include "image_common.h"
@@ -53,19 +54,29 @@ format_has_alpha(int fourcc)
}
}
+#ifndef __BIG_ENDIAN__
+/* Assume __LITTLE_ENDIAN__ */
+# ifndef HAVE_HTOLE16
+# define htole16(x) (uint16_t)(x)
+# define HAVE_HTOLE16
+# endif
+#endif
+
enum piglit_result
piglit_display(void)
{
+#ifdef HAVE_HTOLE16
uint16_t p0xx[] = {
/* Y */
- 12850, 17990, 23130, 28270,
- 12850, 17990, 23130, 28270,
- 12850, 17990, 23130, 28270,
- 12850, 17990, 23130, 28270,
+ htole16(12850), htole16(17990), htole16(23130), htole16(28270),
+ htole16(12850), htole16(17990), htole16(23130), htole16(28270),
+ htole16(12850), htole16(17990), htole16(23130), htole16(28270),
+ htole16(12850), htole16(17990), htole16(23130), htole16(28270),
/* UV */
- 30840, 33410, 35980, 33410,
- 30840, 41120, 35980, 41120,
+ htole16(30840), htole16(33410), htole16(35980), htole16(33410),
+ htole16(30840), htole16(41120), htole16(35980), htole16(41120),
};
+#endif
static const unsigned char nv12[] = {
/* Y */
@@ -169,19 +180,21 @@ piglit_display(void)
enum piglit_result res;
switch (fourcc) {
+#ifdef HAVE_HTOLE16
case DRM_FORMAT_P010:
for (uint32_t i = 0; i < ARRAY_SIZE(p0xx); i++)
- p0xx[i] &= (1023 << 6);
+ p0xx[i] &= htole16(1023 << 6);
t = (unsigned char *) p0xx;
break;
case DRM_FORMAT_P012:
for (uint32_t i = 0; i < ARRAY_SIZE(p0xx); i++)
- p0xx[i] &= (4095 << 4);
+ p0xx[i] &= htole16(4095 << 4);
t = (unsigned char *) p0xx;
break;
case DRM_FORMAT_P016:
t = (unsigned char *) p0xx;
break;
+#endif
case DRM_FORMAT_NV12:
t = nv12;
break;
diff --git a/tests/util/config.h.in b/tests/util/config.h.in
index a368c3dab..c1922d540 100644
--- a/tests/util/config.h.in
+++ b/tests/util/config.h.in
@@ -5,6 +5,7 @@
#cmakedefine HAVE_SETRLIMIT 1
#cmakedefine HAVE_STRNDUP 1
#cmakedefine HAVE_HTOBE32 1
+#cmakedefine HAVE_HTOLE16 1
#cmakedefine HAVE_FCNTL_H 1
#cmakedefine HAVE_SYS_STAT_H 1