+ ret = kms_bo_map(plane_bo, &virtual);
+ if (ret) {
+ fprintf(stderr, "failed to map buffer: %s\n",
+ strerror(-ret));
+ kms_bo_destroy(&plane_bo);
+ return -1;
+ }
+
+ /* just testing a limited # of formats to test single
+ * and multi-planar path.. would be nice to add more..
+ */
+ if (!strcmp(p->format_str, "YUYV")) {
+ pitches[0] = p->w * 2;
+ offsets[0] = 0;
+ kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[0]);
+
+ fill422(virtual, 0, p->w, p->h, pitches[0]);
+
+ format = DRM_FORMAT_YUYV;
+ } else if (!strcmp(p->format_str, "NV12")) {
+ pitches[0] = p->w;
+ offsets[0] = 0;
+ kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[0]);
+ pitches[1] = p->w;
+ offsets[1] = p->w * p->h;
+ kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[1]);
+
+ fill420(virtual, virtual+offsets[1], virtual+offsets[1]+1,
+ 2, 0, p->w, p->h, pitches[0]);
+
+ format = DRM_FORMAT_NV12;
+ } else if (!strcmp(p->format_str, "YV12")) {
+ pitches[0] = p->w;
+ offsets[0] = 0;
+ kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[0]);
+ pitches[1] = p->w / 2;
+ offsets[1] = p->w * p->h;
+ kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[1]);
+ pitches[2] = p->w / 2;
+ offsets[2] = offsets[1] + (p->w * p->h) / 4;
+ kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[1]);
+
+ fill420(virtual, virtual+offsets[1], virtual+offsets[2],
+ 1, 0, p->w, p->h, pitches[0]);
+
+ format = DRM_FORMAT_YVU420;
+ } else {
+ fprintf(stderr, "Unknown format: %s\n", p->format_str);
+ return -1;
+ }
+
+ kms_bo_unmap(plane_bo);
+ }