media/gpu/v4l2: workaround VIDIOC_G_FMT bug in libtegrav4l2.so.

libtegrav4l2.so's implementation of V4L2_G_FMT has a bug which will make
it return 0 planes for single-plane multiplanar formats. We obviously
cannot have a multiplanar format with 0 planes, so add a workaround at
the fake-ioctl level. Implement it as a case-switch for future-proofing
against other workarounds we will likely have to add.

Also add a few recommendations in v4l2_device.cc against the temptation
to spare some memory by using an appropriately-sized array of
v4l2_planes: it turns out libv4l2 also likes to write above the number
of passed planes, and using anything shorter than VIDEO_MAX_PLANES will
result in memory corruption DCHECKS being raised.

BUG=893661
TEST=Checked that VDA unittest was passing on both hana and nyan_big.

Change-Id: I7ea638f19f5bf0bdfaa0a47885577eb9dec4c225
Reviewed-on: https://chromium-review.googlesource.com/c/1275727
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599135}
2 files changed