@@ -96,6 +96,15 @@ static const struct v4l2_format fmt_default = {
.fmt.pix.colorspace = V4L2_COLORSPACE_DEFAULT,
};
+static const struct v4l2_format fmt_default_mp = {
+ .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
+ .fmt.pix_mp.width = 640,
+ .fmt.pix_mp.height = 480,
+ .fmt.pix_mp.pixelformat = V4L2_PIX_FMT_YVU420M,
+ .fmt.pix_mp.field = V4L2_FIELD_NONE,
+ .fmt.pix_mp.colorspace = V4L2_COLORSPACE_DEFAULT,
+};
+
struct vimc_cap_buffer {
/*
* struct vb2_v4l2_buffer must be the first element
@@ -160,7 +169,9 @@ static int vimc_cap_try_fmt_vid_cap(struct file *file, void *priv,
/* Don't accept a pixelformat that is not on the table */
if (!v4l2_format_info(format->pixelformat))
- format->pixelformat = fmt_default.fmt.pix.pixelformat;
+ format->pixelformat = multiplanar ?
+ fmt_default_mp.fmt.pix_mp.pixelformat :
+ fmt_default.fmt.pix.pixelformat;
return v4l2_fill_pixfmt_mp(format, format->pixelformat,
format->width, format->height);
@@ -627,11 +638,19 @@ static int vimc_cap_comp_bind(struct device *comp, struct device *master,
spin_lock_init(&vcap->qlock);
/* Set default frame format */
- vcap->format = fmt_default;
- v4l2_fill_pixfmt(&vcap->format.fmt.pix,
- vcap->format.fmt.pix.pixelformat,
- vcap->format.fmt.pix.width,
- vcap->format.fmt.pix.height);
+ if (multiplanar) {
+ vcap->format = fmt_default_mp;
+ v4l2_fill_pixfmt_mp(&vcap->format.fmt.pix_mp,
+ vcap->format.fmt.pix_mp.pixelformat,
+ vcap->format.fmt.pix_mp.width,
+ vcap->format.fmt.pix_mp.height);
+ } else {
+ vcap->format = fmt_default;
+ v4l2_fill_pixfmt(&vcap->format.fmt.pix,
+ vcap->format.fmt.pix.pixelformat,
+ vcap->format.fmt.pix.width,
+ vcap->format.fmt.pix.height);
+ }
/* Fill the vimc_ent_device struct */
vcap->ved.ent = &vcap->vdev.entity;
vimc already have a default single planar default format. Add a multiplanar default pixel format to perfom those same actions. Signed-off-by: André Almeida <andrealmeid@collabora.com> --- drivers/media/platform/vimc/vimc-capture.c | 31 +++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-)