minigbm: remove buffer sizes when importing

CL:662919 started using lseek() and the buffer offsets when importing,
so let's remove buffer sizes here.

BUG=b:65566935
TEST=emerge-eve {minigbm, arc-cros-gralloc}

Change-Id: I43fda28bfe530139e8e0d68c6b9c213489077b4c
Reviewed-on: https://chromium-review.googlesource.com/691421
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc
index f6e65b7..805c123 100644
--- a/cros_gralloc/cros_gralloc_driver.cc
+++ b/cros_gralloc/cros_gralloc_driver.cc
@@ -124,7 +124,6 @@
 		hnd->fds[plane] = drv_bo_get_plane_fd(bo, plane);
 		hnd->strides[plane] = drv_bo_get_plane_stride(bo, plane);
 		hnd->offsets[plane] = drv_bo_get_plane_offset(bo, plane);
-		hnd->sizes[plane] = drv_bo_get_plane_size(bo, plane);
 
 		mod = drv_bo_get_plane_format_modifier(bo, plane);
 		hnd->format_modifiers[2 * plane] = static_cast<uint32_t>(mod >> 32);
@@ -189,7 +188,6 @@
 		memcpy(data.fds, hnd->fds, sizeof(data.fds));
 		memcpy(data.strides, hnd->strides, sizeof(data.strides));
 		memcpy(data.offsets, hnd->offsets, sizeof(data.offsets));
-		memcpy(data.sizes, hnd->sizes, sizeof(data.sizes));
 		for (uint32_t plane = 0; plane < DRV_MAX_PLANES; plane++) {
 			data.format_modifiers[plane] =
 			    static_cast<uint64_t>(hnd->format_modifiers[2 * plane]) << 32;
diff --git a/cros_gralloc/cros_gralloc_handle.h b/cros_gralloc/cros_gralloc_handle.h
index 4cb554d..bdd3f07 100644
--- a/cros_gralloc/cros_gralloc_handle.h
+++ b/cros_gralloc/cros_gralloc_handle.h
@@ -22,7 +22,6 @@
 	int32_t fds[DRV_MAX_PLANES];
 	uint32_t strides[DRV_MAX_PLANES];
 	uint32_t offsets[DRV_MAX_PLANES];
-	uint32_t sizes[DRV_MAX_PLANES];
 	uint32_t format_modifiers[2 * DRV_MAX_PLANES];
 	uint32_t width;
 	uint32_t height;
diff --git a/drv.c b/drv.c
index fab9958..8b8418b 100644
--- a/drv.c
+++ b/drv.c
@@ -580,24 +580,6 @@
 	return 0;
 }
 
-uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane)
-{
-	assert(plane < drv_num_planes_from_format(format));
-	uint32_t vertical_subsampling;
-
-	switch (format) {
-	case DRM_FORMAT_NV12:
-	case DRM_FORMAT_YVU420:
-	case DRM_FORMAT_YVU420_ANDROID:
-		vertical_subsampling = (plane == 0) ? 1 : 2;
-		break;
-	default:
-		vertical_subsampling = 1;
-	}
-
-	return stride * DIV_ROUND_UP(height, vertical_subsampling);
-}
-
 uint32_t drv_num_buffers_per_bo(struct bo *bo)
 {
 	uint32_t count = 0;
diff --git a/drv.h b/drv.h
index f9a7a87..8c132d3 100644
--- a/drv.h
+++ b/drv.h
@@ -71,7 +71,6 @@
 	int fds[DRV_MAX_PLANES];
 	uint32_t strides[DRV_MAX_PLANES];
 	uint32_t offsets[DRV_MAX_PLANES];
-	uint32_t sizes[DRV_MAX_PLANES];
 	uint64_t format_modifiers[DRV_MAX_PLANES];
 	uint32_t width;
 	uint32_t height;
@@ -145,8 +144,6 @@
 
 size_t drv_num_planes_from_format(uint32_t format);
 
-uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane);
-
 uint32_t drv_num_buffers_per_bo(struct bo *bo);
 
 #ifdef __cplusplus
diff --git a/gbm.c b/gbm.c
index 831dfbf..d54c975 100644
--- a/gbm.c
+++ b/gbm.c
@@ -179,7 +179,6 @@
 		drv_data.format = fd_data->format;
 		drv_data.fds[0] = fd_data->fd;
 		drv_data.strides[0] = fd_data->stride;
-		drv_data.sizes[0] = fd_data->height * fd_data->stride;
 		break;
 	case GBM_BO_IMPORT_FD_PLANAR:
 		gbm_format = fd_planar_data->format;
@@ -195,9 +194,6 @@
 			drv_data.offsets[i] = fd_planar_data->offsets[i];
 			drv_data.strides[i] = fd_planar_data->strides[i];
 			drv_data.format_modifiers[i] = fd_planar_data->format_modifiers[i];
-
-			drv_data.sizes[i] = drv_size_from_format(
-			    drv_data.format, drv_data.strides[i], drv_data.height, i);
 		}
 
 		for (i = num_planes; i < GBM_MAX_PLANES; i++)
diff --git a/helpers.c b/helpers.c
index 979521a..eed2b21 100644
--- a/helpers.c
+++ b/helpers.c
@@ -127,6 +127,24 @@
 	return stride;
 }
 
+uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane)
+{
+	assert(plane < drv_num_planes_from_format(format));
+	uint32_t vertical_subsampling;
+
+	switch (format) {
+	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_YVU420:
+	case DRM_FORMAT_YVU420_ANDROID:
+		vertical_subsampling = (plane == 0) ? 1 : 2;
+		break;
+	default:
+		vertical_subsampling = 1;
+	}
+
+	return stride * DIV_ROUND_UP(height, vertical_subsampling);
+}
+
 /*
  * This function fills in the buffer object given the driver aligned stride of
  * the first plane, height and a format. This function assumes there is just
diff --git a/helpers.h b/helpers.h
index 0cc1a17..d05e835 100644
--- a/helpers.h
+++ b/helpers.h
@@ -10,6 +10,7 @@
 #include "drv.h"
 
 uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane);
+uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane);
 int drv_bo_from_format(struct bo *bo, uint32_t stride, uint32_t aligned_height, uint32_t format);
 int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
 		       uint32_t flags);