minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16

This is needed to support the following CTS test:

android.graphics.cts.BitmapColorSpaceTest#test16bitHardware

There have been some rumblings about adding 64-bit formats to <drm_fourcc.h>:

https://lists.freedesktop.org/archives/intel-gvt-dev/2017-July/001469.html

However, nothing has landed, so let's just define our own format
for the time being.

BUG=b:77973662
TEST=Compile for kevin and kevin-arcnext
     Unfortunately, my P setup refuses to work, so let the lab
     test.

Change-Id: I1fea16400ba6632a8ef17105e27bc7799d2af515
Reviewed-on: https://chromium-review.googlesource.com/1029355
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
Gurchetan Singh 2018-04-25 17:36:59 -07:00 committed by chrome-bot
parent 2eeaf5a03c
commit 292da5365a
8 changed files with 32 additions and 16 deletions

View file

@ -33,9 +33,9 @@ struct amdgpu_priv {
int drm_version;
};
const static uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
DRM_FORMAT_XRGB8888 };
const static uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
DRM_FORMAT_XBGR16161616, DRM_FORMAT_XRGB8888 };
const static uint32_t texture_source_formats[] = { DRM_FORMAT_GR88, DRM_FORMAT_R8, DRM_FORMAT_NV21,
DRM_FORMAT_NV12, DRM_FORMAT_YVU420_ANDROID };

View file

@ -26,6 +26,8 @@ uint32_t cros_gralloc_convert_format(int format)
return DRM_FORMAT_RGB888;
case HAL_PIXEL_FORMAT_RGBA_8888:
return DRM_FORMAT_ABGR8888;
case HAL_PIXEL_FORMAT_RGBA_FP16:
return DRM_FORMAT_XBGR16161616;
case HAL_PIXEL_FORMAT_RGBX_8888:
return DRM_FORMAT_XBGR8888;
case HAL_PIXEL_FORMAT_YCbCr_420_888:

View file

@ -14,6 +14,10 @@
#include <system/graphics.h>
#include <system/window.h>
#if ANDROID_VERSION < 0x0900
#define HAL_PIXEL_FORMAT_RGBA_FP16 0x16
#endif
constexpr uint32_t cros_gralloc_magic = 0xABCDDCBA;
constexpr uint32_t handle_data_size =
((sizeof(struct cros_gralloc_handle) - offsetof(cros_gralloc_handle, fds[0])) / sizeof(int));

1
drv.h
View file

@ -50,6 +50,7 @@ extern "C" {
*/
#define DRM_FORMAT_NONE fourcc_code('0', '0', '0', '0')
#define DRM_FORMAT_XBGR16161616 fourcc_code('9', '9', '9', '6')
#define DRM_FORMAT_YVU420_ANDROID fourcc_code('9', '9', '9', '7')
#define DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED fourcc_code('9', '9', '9', '8')
#define DRM_FORMAT_FLEX_YCbCr_420_888 fourcc_code('9', '9', '9', '9')

View file

@ -55,6 +55,13 @@ static const struct planar_layout packed_4bpp_layout = {
.bytes_per_pixel = { 4 }
};
static const struct planar_layout packed_8bpp_layout = {
.num_planes = 1,
.horizontal_subsampling = { 1 },
.vertical_subsampling = { 1 },
.bytes_per_pixel = { 8 }
};
static const struct planar_layout biplanar_yuv_420_layout = {
.num_planes = 2,
.horizontal_subsampling = { 1, 2 },
@ -137,6 +144,9 @@ static const struct planar_layout *layout_from_format(uint32_t format)
case DRM_FORMAT_XRGB8888:
return &packed_4bpp_layout;
case DRM_FORMAT_XBGR16161616:
return &packed_8bpp_layout;
default:
drv_log("UNKNOWN FORMAT %d\n", format);
return NULL;
@ -189,8 +199,7 @@ uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane)
const struct planar_layout *layout = layout_from_format(format);
assert(plane < layout->num_planes);
uint32_t plane_width =
DIV_ROUND_UP(width, layout->horizontal_subsampling[plane]);
uint32_t plane_width = DIV_ROUND_UP(width, layout->horizontal_subsampling[plane]);
uint32_t stride = plane_width * layout->bytes_per_pixel[plane];
/*

10
i915.c
View file

@ -21,11 +21,11 @@
#define I915_CACHELINE_SIZE 64
#define I915_CACHELINE_MASK (I915_CACHELINE_SIZE - 1)
static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB1555,
DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
DRM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR8888,
DRM_FORMAT_XRGB1555, DRM_FORMAT_XRGB2101010,
DRM_FORMAT_XRGB8888 };
static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB1555,
DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
DRM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR8888,
DRM_FORMAT_XBGR16161616, DRM_FORMAT_XRGB1555,
DRM_FORMAT_XRGB2101010, DRM_FORMAT_XRGB8888 };
static const uint32_t tileable_texture_source_formats[] = { DRM_FORMAT_GR88, DRM_FORMAT_R8,
DRM_FORMAT_UYVY, DRM_FORMAT_YUYV };

View file

@ -23,9 +23,9 @@ struct mediatek_private_map_data {
void *gem_addr;
};
static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
DRM_FORMAT_XRGB8888 };
static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
DRM_FORMAT_XBGR16161616, DRM_FORMAT_XRGB8888 };
static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_YVU420,
DRM_FORMAT_YVU420_ANDROID };

View file

@ -23,9 +23,9 @@ struct rockchip_private_map_data {
void *gem_addr;
};
static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
DRM_FORMAT_XRGB8888 };
static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
DRM_FORMAT_XBGR16161616, DRM_FORMAT_XRGB8888 };
static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_NV12,
DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID };