return 8;
case DRM_FORMAT_NV12:
+ case DRM_FORMAT_NV21:
return (plane == 0) ? 8 : 4;
case DRM_FORMAT_ABGR1555:
num_planes = drv_num_planes_from_format(format);
assert(num_planes);
- bo->total_size = 0;
+
+ /*
+ * HAL_PIXEL_FORMAT_YV12 requires that (see <system/graphics.h>):
+ * - the aligned height is same as the buffer's height.
+ * - the chroma stride is 16 bytes aligned, i.e., the luma's strides
+ * is 32 bytes aligned.
+ */
+ if (format == DRM_FORMAT_YVU420_ANDROID) {
+ assert(aligned_height == bo->height);
+ assert(stride == ALIGN(stride, 32));
+ }
for (p = 0; p < num_planes; p++) {
bo->strides[p] = subsample_stride(stride, format, p);
- bo->sizes[p] = drv_size_from_format(format, bo->strides[p], bo->height, p);
+ bo->sizes[p] = drv_size_from_format(format, bo->strides[p], aligned_height, p);
bo->offsets[p] = offset;
offset += bo->sizes[p];
- bo->total_size += drv_size_from_format(format, bo->strides[p], aligned_height, p);
}
+ bo->total_size = offset;
return 0;
}
* Android requires.
*/
aligned_width = ALIGN(width, 32);
+ }
+
+ if (format == DRM_FORMAT_YVU420_ANDROID || format == DRM_FORMAT_YVU420) {
aligned_height = 3 * DIV_ROUND_UP(height, 2);
}
return 0;
}
-void *drv_dumb_bo_map(struct bo *bo, struct map_info *data, size_t plane)
+void *drv_dumb_bo_map(struct bo *bo, struct map_info *data, size_t plane, int prot)
{
int ret;
size_t i;
if (bo->handles[i].u32 == bo->handles[plane].u32)
data->length += bo->sizes[i];
- return mmap(0, data->length, PROT_READ | PROT_WRITE, MAP_SHARED, bo->drv->fd,
- map_dumb.offset);
+ return mmap(0, data->length, prot, MAP_SHARED, bo->drv->fd, map_dumb.offset);
}
uintptr_t drv_get_reference_count(struct driver *drv, struct bo *bo, size_t plane)