hnd->magic = cros_gralloc_magic();
hnd->pixel_stride = hnd->strides[0];
- hnd->pixel_stride /= drv_stride_from_format(hnd->format, 1, 0);
+ hnd->pixel_stride /= drv_bytes_per_pixel(hnd->format, 0);
return hnd;
}
return format;
}
-/*
- * This function returns the stride for a given format, width and plane.
- */
-int drv_stride_from_format(uint32_t format, uint32_t width, size_t plane)
-{
- int stride = DIV_ROUND_UP(width * drv_bpp_from_format(format, plane),
- 8);
-
- /*
- * Only downsample for certain multiplanar formats which have horizontal
- * subsampling for chroma planes. Only formats supported by our drivers
- * are listed here -- add more as needed.
- */
- if (plane != 0) {
- switch (format) {
- case DRM_FORMAT_NV12:
- case DRM_FORMAT_YVU420:
- case DRM_FORMAT_YVU420_ANDROID:
- stride = DIV_ROUND_UP(stride, 2);
- break;
- }
- }
-
- /*
- * The stride of Android YV12 buffers is required to be aligned to 16 bytes
- * (see <system/graphics.h>).
- */
- if (format == DRM_FORMAT_YVU420_ANDROID)
- stride = ALIGN(stride, 16);
-
- return stride;
-}
-
size_t drv_num_planes_from_format(uint32_t format)
{
switch (format) {
return 0;
}
+uint32_t
+drv_bytes_per_pixel(uint32_t format, size_t plane)
+{
+ return DIV_ROUND_UP(drv_bpp_from_format(format, plane), 8);
+}
+
uint32_t drv_size_from_format(uint32_t format, uint32_t stride,
uint32_t height, size_t plane)
{
uint32_t
drv_resolve_format(struct driver *drv, uint32_t format);
-int
-drv_stride_from_format(uint32_t format, uint32_t width, size_t plane);
-
size_t
drv_num_planes_from_format(uint32_t format);
uint32_t
+drv_bytes_per_pixel(uint32_t format, size_t plane);
+
+uint32_t
drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height,
size_t plane);
}
/*
+ * This function returns the stride for a given format, width and plane.
+ */
+uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane)
+{
+ uint32_t stride = DIV_ROUND_UP(width * drv_bpp_from_format(format, plane),
+ 8);
+
+ /*
+ * Only downsample for certain multiplanar formats which have horizontal
+ * subsampling for chroma planes. Only formats supported by our drivers
+ * are listed here -- add more as needed.
+ */
+ if (plane != 0) {
+ switch (format) {
+ case DRM_FORMAT_NV12:
+ case DRM_FORMAT_YVU420:
+ case DRM_FORMAT_YVU420_ANDROID:
+ stride = DIV_ROUND_UP(stride, 2);
+ break;
+ }
+ }
+
+ /*
+ * The stride of Android YV12 buffers is required to be aligned to 16 bytes
+ * (see <system/graphics.h>).
+ */
+ if (format == DRM_FORMAT_YVU420_ANDROID)
+ stride = ALIGN(stride, 16);
+
+ return stride;
+}
+
+/*
* This function fills in the buffer object given driver aligned dimensions
* (in pixels) and a format. This function assumes there is just one kernel
* buffer per buffer object.
aligned_width = width;
aligned_height = height;
- bytes_per_pixel = DIV_ROUND_UP(drv_bpp_from_format(format, 0), 8);
+ bytes_per_pixel = drv_bytes_per_pixel(format, 0);
if (format == DRM_FORMAT_YVU420_ANDROID) {
/*
* Align width to 16 pixels, so chroma strides are 16 bytes as
#include "drv.h"
int drv_bpp_from_format(uint32_t format, size_t plane);
+uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane);
int drv_bo_from_format(struct bo *bo, uint32_t aligned_width,
uint32_t aligned_height, uint32_t format);
int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height,