gralloc0: resource_info to return the correct strides and offsets

When format plane is single, it's still possible for the host image
memory to have multiple planes for auxiliary planes for non-linear
modifiers.

Relying on the non-zero stride to retrieve the actual strides and
offsets info.

BUG=b:197899093
TEST=run Vulkan apps on zork-arc-r
TEST=run guest video/camera apps
TEST=CtsNativeHardwareTestCases and related CtsGraphicsTestCases

Change-Id: Id80f143de114bbe9252c40b46dcfb835085c754d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3120411
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
diff --git a/cros_gralloc/gralloc0/gralloc0.cc b/cros_gralloc/gralloc0/gralloc0.cc
index 7140966..c310006 100644
--- a/cros_gralloc/gralloc0/gralloc0.cc
+++ b/cros_gralloc/gralloc0/gralloc0.cc
@@ -294,20 +294,20 @@
 		memset(info, 0, sizeof(*info));
 		info->drm_fourcc = drv_get_standard_fourcc(hnd->format);
 		info->num_fds = hnd->num_planes;
+		for (uint32_t i = 0; i < info->num_fds; i++)
+			info->fds[i] = hnd->fds[i];
+
 		ret = mod->driver->resource_info(handle, strides, offsets, &format_modifier);
 		if (ret)
 			break;
 
 		info->modifier = format_modifier ? format_modifier : hnd->format_modifier;
-		for (uint32_t i = 0; i < hnd->num_planes; i++) {
-			info->fds[i] = hnd->fds[i];
-			if (strides[i]) {
-				info->stride[i] = strides[i];
-				info->offset[i] = offsets[i];
-			} else {
-				info->stride[i] = hnd->strides[i];
-				info->offset[i] = hnd->offsets[i];
-			}
+		for (uint32_t i = 0; i < DRV_MAX_PLANES; i++) {
+			if (!strides[i])
+				break;
+
+			info->stride[i] = strides[i];
+			info->offset[i] = offsets[i];
 		}
 		break;
 	case GRALLOC_DRM_GET_USAGE: