#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <xf86drm.h>
#include "drv_priv.h"
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;
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) {
+ 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
+ * uses the non-aligned height. */
+ height = bo->meta.height;
+
/* Align width to 32 pixels, so chroma strides are 16 bytes as
* Android requires. */
aligned_width = ALIGN(width, 32);
- /* Adjust the height to include room for chroma planes.
- *
- * HAL_PIXEL_FORMAT_YV12 requires that the buffer's height not
- * be aligned. */
- aligned_height = 3 * DIV_ROUND_UP(bo->meta.height, 2);
+
+ /* Adjust the height to include room for chroma planes. */
+ aligned_height = 3 * DIV_ROUND_UP(height, 2);
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;
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);
int drv_dumb_bo_destroy(struct bo *bo)
{
- struct drm_mode_destroy_dumb destroy_dumb;
int ret;
+ struct drm_mode_destroy_dumb destroy_dumb = { 0 };
- memset(&destroy_dumb, 0, sizeof(destroy_dumb));
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);
bo->handles[plane].u32 = prime_handle.handle;
}
+ bo->meta.tiling = data->tiling;
return 0;
}