OSDN Git Service
(root)
/
android-x86
/
external-minigbm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Android.bp: fix mesa include path
[android-x86/external-minigbm.git]
/
helpers.c
diff --git
a/helpers.c
b/helpers.c
index
fed4af9
..
326dddf
100644
(file)
--- a/
helpers.c
+++ b/
helpers.c
@@
-10,6
+10,8
@@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <xf86drm.h>
#include "drv_priv.h"
#include <xf86drm.h>
#include "drv_priv.h"
@@
-92,6
+94,9
@@
static const struct planar_layout *layout_from_format(uint32_t format)
case DRM_FORMAT_RGB332:
return &packed_1bpp_layout;
case DRM_FORMAT_RGB332:
return &packed_1bpp_layout;
+ case DRM_FORMAT_R16:
+ return &packed_2bpp_layout;
+
case DRM_FORMAT_YVU420:
case DRM_FORMAT_YVU420_ANDROID:
return &triplanar_yuv_420_layout;
case DRM_FORMAT_YVU420:
case DRM_FORMAT_YVU420_ANDROID:
return &triplanar_yuv_420_layout;
@@
-184,7
+189,8
@@
size_t drv_num_planes_from_modifier(struct driver *drv, uint32_t format, uint64_
if (!planes)
return 0;
if (!planes)
return 0;
- if (drv->backend->num_planes_from_modifier && modifier != DRM_FORMAT_MOD_INVALID)
+ if (drv->backend->num_planes_from_modifier && modifier != DRM_FORMAT_MOD_INVALID &&
+ modifier != DRM_FORMAT_MOD_LINEAR)
return drv->backend->num_planes_from_modifier(drv, format, modifier);
return planes;
return drv->backend->num_planes_from_modifier(drv, format, modifier);
return planes;
@@
-307,11
+313,16
@@
int drv_dumb_bo_create_ex(struct bo *bo, uint32_t width, uint32_t height, uint32
int ret;
size_t plane;
uint32_t aligned_width, aligned_height;
int ret;
size_t plane;
uint32_t aligned_width, aligned_height;
- struct drm_mode_create_dumb create_dumb;
+ struct drm_mode_create_dumb create_dumb
= { 0 }
;
aligned_width = width;
aligned_height = height;
switch (format) {
aligned_width = width;
aligned_height = height;
switch (format) {
+ case DRM_FORMAT_R16:
+ /* HAL_PIXEL_FORMAT_Y16 requires that the buffer's width be 16 pixel
+ * aligned. See hardware/interfaces/graphics/common/1.0/types.hal. */
+ aligned_width = ALIGN(width, 16);
+ break;
case DRM_FORMAT_YVU420_ANDROID:
/* HAL_PIXEL_FORMAT_YV12 requires that the buffer's height not
* be aligned. Update 'height' so that drv_bo_from_format below
case DRM_FORMAT_YVU420_ANDROID:
/* HAL_PIXEL_FORMAT_YV12 requires that the buffer's height not
* be aligned. Update 'height' so that drv_bo_from_format below
@@
-327,6
+338,7
@@
int drv_dumb_bo_create_ex(struct bo *bo, uint32_t width, uint32_t height, uint32
break;
case DRM_FORMAT_YVU420:
case DRM_FORMAT_NV12:
break;
case DRM_FORMAT_YVU420:
case DRM_FORMAT_NV12:
+ case DRM_FORMAT_NV21:
/* Adjust the height to include room for chroma planes */
aligned_height = 3 * DIV_ROUND_UP(height, 2);
break;
/* Adjust the height to include room for chroma planes */
aligned_height = 3 * DIV_ROUND_UP(height, 2);
break;
@@
-334,7
+346,6
@@
int drv_dumb_bo_create_ex(struct bo *bo, uint32_t width, uint32_t height, uint32
break;
}
break;
}
- memset(&create_dumb, 0, sizeof(create_dumb));
if (quirks & BO_QUIRK_DUMB32BPP) {
aligned_width =
DIV_ROUND_UP(aligned_width * layout_from_format(format)->bytes_per_pixel[0], 4);
if (quirks & BO_QUIRK_DUMB32BPP) {
aligned_width =
DIV_ROUND_UP(aligned_width * layout_from_format(format)->bytes_per_pixel[0], 4);
@@
-369,12
+380,10
@@
int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t
int drv_dumb_bo_destroy(struct bo *bo)
{
int drv_dumb_bo_destroy(struct bo *bo)
{
- struct drm_mode_destroy_dumb destroy_dumb;
int ret;
int ret;
+ struct drm_mode_destroy_dumb destroy_dumb = { 0 };
- memset(&destroy_dumb, 0, sizeof(destroy_dumb));
destroy_dumb.handle = bo->handles[0].u32;
destroy_dumb.handle = bo->handles[0].u32;
-
ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
if (ret) {
drv_log("DRM_IOCTL_MODE_DESTROY_DUMB failed (handle=%x)\n", bo->handles[0].u32);
ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
if (ret) {
drv_log("DRM_IOCTL_MODE_DESTROY_DUMB failed (handle=%x)\n", bo->handles[0].u32);
@@
-440,6
+449,7
@@
int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data)
bo->handles[plane].u32 = prime_handle.handle;
}
bo->handles[plane].u32 = prime_handle.handle;
}
+ bo->meta.tiling = data->tiling;
return 0;
}
return 0;
}
@@
-629,3
+639,11
@@
bool drv_has_modifier(const uint64_t *list, uint32_t count, uint64_t modifier)
return false;
}
return false;
}
+
+/*
+ * Map internal fourcc codes back to standard fourcc codes.
+ */
+uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal)
+{
+ return (fourcc_internal == DRM_FORMAT_YVU420_ANDROID) ? DRM_FORMAT_YVU420 : fourcc_internal;
+}