Revert "CHROMIUM: drivers: media: virtio: fix reported V4L2 planes layout"
This reverts commit 82e4012a8ae5c8468ee5b84cda09134a10167dd5.
Reason for revert: ARCVM encoder stops functioning because it still expects the old (incorrect) format description.
BUG=b:205488531
BUG=b:205356442
TEST=ARCVM encoder works again.
Original change's description:
> CHROMIUM: drivers: media: virtio: fix reported V4L2 planes layout
>
> There is a mismatch between the way virtio-video and V4L2 define their
> planes. For virtio-video, a plane is always a color plane, and whether
> color planes are grouped together in a single buffer is set by an
> attribute. For V4L2, a plane is a buffer that can contain one or several
> color planes.
>
> V4L2 uses this latter definition for the "planes" it reports to
> user-space, but the driver currently unconditionally maps the virtio
> color planes to V4L2 plane buffers, despite always using the
> SINGLE_BUFFER layout when communicating formats to the host. This
> results in incorrect information being given to user-space, e.g. the
> NV12 pixel format having 3 planes (NV12 in V4L2 is always single buffer,
> its multi-buffer variant is called NV12M).
>
> Fix this by aggregating the virtio-planes into a single buffer to
> conform to what V4L2 expects.
>
> Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
>
> BUG=b:161774071
> TEST=Android Youtube can play videos on Hatch.
>
> Change-Id: I99c8a7dde58c9048a4f7a08c3925bc6a2626f543
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3247492
> Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
> Tested-by: Alexandre Courbot <acourbot@chromium.org>
> Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: b:161774071
Change-Id: I8ed8bf6fae1e89a053fce1e7d8b6c78ddf4d17df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3271531
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
diff --git a/drivers/media/virtio/virtio_video_device.c b/drivers/media/virtio/virtio_video_device.c
index 0e5cfaa..1cef520 100644
--- a/drivers/media/virtio/virtio_video_device.c
+++ b/drivers/media/virtio/virtio_video_device.c
@@ -34,7 +34,6 @@
int i;
struct virtio_video_stream *stream = vb2_get_drv_priv(vq);
struct video_format_info *p_info;
- u32 plane_size = 0;
if (*num_planes)
return 0;
@@ -44,15 +43,10 @@
else
p_info = &stream->out_info;
- /*
- * The driver only supports single-planar (in the V4L2 sense, i.e. one
- * buffer for all color planes) formats at the moment, so aggregate all
- * the color planes into a single buffer.
- */
- *num_planes = 1;
+ *num_planes = p_info->num_planes;
+
for (i = 0; i < p_info->num_planes; i++)
- plane_size += p_info->plane_format[i].plane_size;
- sizes[0] = plane_size;
+ sizes[i] = p_info->plane_format[i].plane_size;
return 0;
}
@@ -735,7 +729,6 @@
struct virtio_video_stream *stream = vb2_get_drv_priv(vb2_queue);
struct virtio_video_device *vvd = to_virtio_vd(stream->video_dev);
struct video_format_info *p_info;
- u32 bytesused = 0;
virtio_vb->queued = false;
@@ -788,16 +781,9 @@
break;
case VIRTIO_VIDEO_DEVICE_DECODER:
p_info = &stream->out_info;
- /*
- * The driver only supports single-planar (in the V4L2
- * sense, i.e. one buffer for all color planes) formats
- * at the moment. All color planes have been written
- * one after the other in a single buffer.
- */
for (i = 0; i < p_info->num_planes; i++)
- bytesused +=
+ vb->planes[i].bytesused =
p_info->plane_format[i].plane_size;
- vb->planes[0].bytesused = bytesused;
break;
}
diff --git a/drivers/media/virtio/virtio_video_helpers.c b/drivers/media/virtio/virtio_video_helpers.c
index 2194bd2..3435ec0 100644
--- a/drivers/media/virtio/virtio_video_helpers.c
+++ b/drivers/media/virtio/virtio_video_helpers.c
@@ -237,7 +237,6 @@
struct v4l2_pix_format_mplane *pix_mp)
{
int i;
- int plane_size;
pix_mp->width = info->frame_width;
pix_mp->height = info->frame_height;
@@ -250,19 +249,15 @@
memset(pix_mp->plane_fmt[0].reserved, 0,
sizeof(pix_mp->plane_fmt[0].reserved));
+ pix_mp->num_planes = info->num_planes;
pix_mp->pixelformat = info->fourcc_format;
- /*
- * The driver only supports single-planar (in the V4L2 sense, i.e. one
- * buffer for all color planes) formats at the moment, so aggregate all
- * the color planes into a single buffer.
- */
- pix_mp->num_planes = 1;
- plane_size = 0;
- for (i = 0; i < info->num_planes; i++)
- plane_size += info->plane_format[i].plane_size;
- pix_mp->plane_fmt[0].bytesperline = info->plane_format[0].stride;
- pix_mp->plane_fmt[0].sizeimage = plane_size;
+ for (i = 0; i < info->num_planes; i++) {
+ pix_mp->plane_fmt[i].bytesperline =
+ info->plane_format[i].stride;
+ pix_mp->plane_fmt[i].sizeimage =
+ info->plane_format[i].plane_size;
+ }
}
void virtio_video_format_fill_default_info(struct video_format_info *dst_info,