From: Helen Koike <helen.koike@collabora.com>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl, mchehab@kernel.org, hans.verkuil@cisco.com,
laurent.pinchart@ideasonboard.com, sakari.ailus@iki.fi,
boris.brezillon@collabora.com, hiroh@chromium.org,
nicolas@ndufresne.ca, Brian.Starkey@arm.com,
kernel@collabora.com, narmstrong@baylibre.com,
linux-kernel@vger.kernel.org, frkoenig@chromium.org,
stanimir.varbanov@linaro.org, tfiga@chromium.org
Subject: [RFC PATCH v6 10/11] media: vimc: Convert to v4l2_ext_pix_format
Date: Thu, 14 Jan 2021 15:07:37 -0300 [thread overview]
Message-ID: <20210114180738.1758707-11-helen.koike@collabora.com> (raw)
In-Reply-To: <20210114180738.1758707-1-helen.koike@collabora.com>
Simplify Multi/Single planer API handling by converting to v4l2_ext_pix_format.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Helen Koike <helen.koike@collabora.com>
---
Changes in v6:
- Update with new format and buffer structs
Changes in v4:
- Update with new format and buffer structs
- Rebased on top of media/master (post 5.8-rc1)
Changes in v3:
- Rebased on top of media/master (post 5.4-rc1)
Changes in v2:
- New patch
---
.../media/test-drivers/vimc/vimc-capture.c | 54 ++++++++++---------
drivers/media/test-drivers/vimc/vimc-common.c | 6 +--
drivers/media/test-drivers/vimc/vimc-common.h | 2 +-
3 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c
index 729614d19002..51191dc9661b 100644
--- a/drivers/media/test-drivers/vimc/vimc-capture.c
+++ b/drivers/media/test-drivers/vimc/vimc-capture.c
@@ -15,7 +15,7 @@
struct vimc_cap_device {
struct vimc_ent_device ved;
struct video_device vdev;
- struct v4l2_pix_format format;
+ struct v4l2_ext_pix_format format;
struct vb2_queue queue;
struct list_head buf_list;
/*
@@ -32,7 +32,8 @@ struct vimc_cap_device {
struct media_pad pad;
};
-static const struct v4l2_pix_format fmt_default = {
+static const struct v4l2_ext_pix_format fmt_default = {
+ .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.width = 640,
.height = 480,
.pixelformat = V4L2_PIX_FMT_RGB24,
@@ -63,7 +64,7 @@ static int vimc_cap_querycap(struct file *file, void *priv,
}
static void vimc_cap_get_format(struct vimc_ent_device *ved,
- struct v4l2_pix_format *fmt)
+ struct v4l2_ext_pix_format *fmt)
{
struct vimc_cap_device *vcap = container_of(ved, struct vimc_cap_device,
ved);
@@ -72,19 +73,18 @@ static void vimc_cap_get_format(struct vimc_ent_device *ved,
}
static int vimc_cap_g_fmt_vid_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_ext_pix_format *f)
{
struct vimc_cap_device *vcap = video_drvdata(file);
- f->fmt.pix = vcap->format;
+ *f = vcap->format;
return 0;
}
static int vimc_cap_try_fmt_vid_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_ext_pix_format *format)
{
- struct v4l2_pix_format *format = &f->fmt.pix;
const struct vimc_pix_map *vpix;
format->width = clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH,
@@ -99,8 +99,10 @@ static int vimc_cap_try_fmt_vid_cap(struct file *file, void *priv,
vpix = vimc_pix_map_by_pixelformat(format->pixelformat);
}
/* TODO: Add support for custom bytesperline values */
- format->bytesperline = format->width * vpix->bpp;
- format->sizeimage = format->bytesperline * format->height;
+ memset(format->plane_fmt, 0, sizeof(format->plane_fmt));
+ format->plane_fmt[0].bytesperline = format->width * vpix->bpp;
+ format->plane_fmt[0].sizeimage = format->plane_fmt[0].bytesperline *
+ format->height;
if (format->field == V4L2_FIELD_ANY)
format->field = fmt_default.field;
@@ -114,7 +116,7 @@ static int vimc_cap_try_fmt_vid_cap(struct file *file, void *priv,
}
static int vimc_cap_s_fmt_vid_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+ struct v4l2_ext_pix_format *f)
{
struct vimc_cap_device *vcap = video_drvdata(file);
int ret;
@@ -136,12 +138,10 @@ static int vimc_cap_s_fmt_vid_cap(struct file *file, void *priv,
vcap->format.quantization, vcap->format.xfer_func,
vcap->format.ycbcr_enc,
/* new */
- f->fmt.pix.width, f->fmt.pix.height,
- f->fmt.pix.pixelformat, f->fmt.pix.colorspace,
- f->fmt.pix.quantization, f->fmt.pix.xfer_func,
- f->fmt.pix.ycbcr_enc);
+ f->width, f->height, f->pixelformat, f->colorspace,
+ f->quantization, f->xfer_func, f->ycbcr_enc);
- vcap->format = f->fmt.pix;
+ vcap->format = *f;
return 0;
}
@@ -205,9 +205,9 @@ static const struct v4l2_file_operations vimc_cap_fops = {
static const struct v4l2_ioctl_ops vimc_cap_ioctl_ops = {
.vidioc_querycap = vimc_cap_querycap,
- .vidioc_g_fmt_vid_cap = vimc_cap_g_fmt_vid_cap,
- .vidioc_s_fmt_vid_cap = vimc_cap_s_fmt_vid_cap,
- .vidioc_try_fmt_vid_cap = vimc_cap_try_fmt_vid_cap,
+ .vidioc_g_ext_pix_fmt_vid_cap = vimc_cap_g_fmt_vid_cap,
+ .vidioc_s_ext_pix_fmt_vid_cap = vimc_cap_s_fmt_vid_cap,
+ .vidioc_try_ext_pix_fmt_vid_cap = vimc_cap_try_fmt_vid_cap,
.vidioc_enum_fmt_vid_cap = vimc_cap_enum_fmt_vid_cap,
.vidioc_enum_framesizes = vimc_cap_enum_framesizes,
@@ -300,10 +300,11 @@ static int vimc_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
struct vimc_cap_device *vcap = vb2_get_drv_priv(vq);
if (*nplanes)
- return sizes[0] < vcap->format.sizeimage ? -EINVAL : 0;
+ return sizes[0] < vcap->format.plane_fmt[0].sizeimage ?
+ -EINVAL : 0;
/* We don't support multiplanes for now */
*nplanes = 1;
- sizes[0] = vcap->format.sizeimage;
+ sizes[0] = vcap->format.plane_fmt[0].sizeimage;
return 0;
}
@@ -311,7 +312,7 @@ static int vimc_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
static int vimc_cap_buffer_prepare(struct vb2_buffer *vb)
{
struct vimc_cap_device *vcap = vb2_get_drv_priv(vb->vb2_queue);
- unsigned long size = vcap->format.sizeimage;
+ unsigned long size = vcap->format.plane_fmt[0].sizeimage;
if (vb2_plane_size(vb, 0) < size) {
dev_err(vcap->ved.dev, "%s: buffer too small (%lu < %lu)\n",
@@ -386,11 +387,11 @@ static void *vimc_cap_process_frame(struct vimc_ent_device *ved,
vbuf = vb2_plane_vaddr(&vimc_buf->vb2.vb2_buf, 0);
- memcpy(vbuf, frame, vcap->format.sizeimage);
+ memcpy(vbuf, frame, vcap->format.plane_fmt[0].sizeimage);
/* Set it as ready */
vb2_set_plane_payload(&vimc_buf->vb2.vb2_buf, 0,
- vcap->format.sizeimage);
+ vcap->format.plane_fmt[0].sizeimage);
vb2_set_pixelformat(&vimc_buf->vb2.vb2_buf, vcap->format.pixelformat);
vb2_buffer_done(&vimc_buf->vb2.vb2_buf, VB2_BUF_STATE_DONE);
return NULL;
@@ -449,9 +450,10 @@ static struct vimc_ent_device *vimc_cap_add(struct vimc_device *vimc,
/* Set default frame format */
vcap->format = fmt_default;
vpix = vimc_pix_map_by_pixelformat(vcap->format.pixelformat);
- vcap->format.bytesperline = vcap->format.width * vpix->bpp;
- vcap->format.sizeimage = vcap->format.bytesperline *
- vcap->format.height;
+ memset(vcap->format.plane_fmt, 0, sizeof(vcap->format.plane_fmt));
+ vcap->format.plane_fmt[0].bytesperline = vcap->format.width * vpix->bpp;
+ vcap->format.plane_fmt[0].sizeimage = vcap->format.plane_fmt[0].bytesperline *
+ vcap->format.height;
/* Fill the vimc_ent_device struct */
vcap->ved.ent = &vcap->vdev.entity;
diff --git a/drivers/media/test-drivers/vimc/vimc-common.c b/drivers/media/test-drivers/vimc/vimc-common.c
index 7b27153c0728..8bbf80f2acb9 100644
--- a/drivers/media/test-drivers/vimc/vimc-common.c
+++ b/drivers/media/test-drivers/vimc/vimc-common.c
@@ -236,7 +236,7 @@ const struct vimc_pix_map *vimc_pix_map_by_pixelformat(u32 pixelformat)
}
static int vimc_get_pix_format(struct media_pad *pad,
- struct v4l2_pix_format *fmt)
+ struct v4l2_ext_pix_format *fmt)
{
if (is_media_entity_v4l2_subdev(pad->entity)) {
struct v4l2_subdev *sd =
@@ -252,7 +252,7 @@ static int vimc_get_pix_format(struct media_pad *pad,
if (ret)
return ret;
- v4l2_fill_pix_format(fmt, &sd_fmt.format);
+ v4l2_fill_ext_pix_format_from_mbus(fmt, &sd_fmt.format);
pix_map = vimc_pix_map_by_code(sd_fmt.format.code);
fmt->pixelformat = pix_map->pixelformat;
} else if (is_media_entity_v4l2_video_device(pad->entity)) {
@@ -274,7 +274,7 @@ static int vimc_get_pix_format(struct media_pad *pad,
int vimc_vdev_link_validate(struct media_link *link)
{
- struct v4l2_pix_format source_fmt, sink_fmt;
+ struct v4l2_ext_pix_format source_fmt, sink_fmt;
int ret;
ret = vimc_get_pix_format(link->source, &source_fmt);
diff --git a/drivers/media/test-drivers/vimc/vimc-common.h b/drivers/media/test-drivers/vimc/vimc-common.h
index a289434e75ba..42fa60350d87 100644
--- a/drivers/media/test-drivers/vimc/vimc-common.h
+++ b/drivers/media/test-drivers/vimc/vimc-common.h
@@ -104,7 +104,7 @@ struct vimc_ent_device {
void * (*process_frame)(struct vimc_ent_device *ved,
const void *frame);
void (*vdev_get_format)(struct vimc_ent_device *ved,
- struct v4l2_pix_format *fmt);
+ struct v4l2_ext_pix_format *fmt);
};
/**
--
2.29.2
next prev parent reply other threads:[~2021-01-14 18:09 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 18:07 [RFC PATCH v6 00/11] media: v4l2: Add extended fmt and buffer ioctls Helen Koike
2021-01-14 18:07 ` [RFC PATCH v6 01/11] media: v4l2-common: add normalized pixelformat field to struct v4l2_format_info Helen Koike
2021-02-10 12:37 ` Dafna Hirschfeld
2021-01-14 18:07 ` [RFC PATCH v6 02/11] media: v4l2: Extend pixel formats to unify single/multi-planar handling (and more) Helen Koike
2021-02-10 15:02 ` Dafna Hirschfeld
2021-02-23 12:35 ` Hans Verkuil
2021-02-24 15:12 ` Helen Koike
2022-11-05 15:19 ` Hsia-Jun Li
2022-11-06 19:24 ` Laurent Pinchart
2022-11-07 1:54 ` Hsia-Jun Li
2022-11-07 8:28 ` Laurent Pinchart
2022-11-07 8:49 ` Hsia-Jun Li
2022-11-06 22:11 ` Dmitry Osipenko
2022-11-07 2:04 ` Hsia-Jun Li
2022-11-07 8:30 ` Laurent Pinchart
2022-11-08 14:58 ` Dmitry Osipenko
2022-11-07 16:50 ` Fritz Koenig
2022-11-07 8:42 ` Hans Verkuil
2022-11-10 17:06 ` Nicolas Dufresne
2022-11-11 3:03 ` Hsia-Jun Li
2022-11-11 5:48 ` Tomasz Figa
2022-11-11 6:30 ` Hsia-Jun Li
2022-11-11 8:52 ` Tomasz Figa
2022-11-11 9:13 ` Hsia-Jun Li
2022-11-15 16:03 ` Nicolas Dufresne
2022-11-16 12:38 ` ayaka
2022-11-11 8:42 ` Laurent Pinchart
2022-11-11 8:54 ` Tomasz Figa
2022-11-15 16:19 ` Nicolas Dufresne
2022-11-15 15:57 ` Nicolas Dufresne
2021-01-14 18:07 ` [RFC PATCH v6 03/11] media: v4l2: Add extended buffer (de)queue operations for video types Helen Koike
2021-02-23 12:58 ` Hans Verkuil
2023-01-26 7:07 ` ayaka
[not found] ` <20230125200026.16643-1-ayaka@soulik.info>
2023-01-26 8:57 ` Hans Verkuil
2023-01-26 11:02 ` Laurent Pinchart
2023-01-26 18:36 ` ayaka
2023-01-27 8:11 ` Hans Verkuil
2023-01-30 10:07 ` Hsia-Jun Li
2023-01-30 12:17 ` Hans Verkuil
2021-01-14 18:07 ` [RFC PATCH v6 04/11] media: videobuf2-v4l2: reorganize flags handling Helen Koike
2021-01-14 18:07 ` [RFC PATCH v6 05/11] media: videobuf2: Expose helpers for Ext qbuf/dqbuf Helen Koike
2021-01-14 18:07 ` [RFC PATCH v6 06/11] media: vivid: use vb2_ioctls_ext_{d}qbuf hooks Helen Koike
2021-01-14 18:07 ` [RFC PATCH v6 07/11] media: vimc: " Helen Koike
2021-01-14 18:07 ` [RFC PATCH v6 08/11] media: mediabus: Add helpers to convert a ext_pix format to/from a mbus_fmt Helen Koike
2021-01-14 18:07 ` [RFC PATCH v6 09/11] media: vivid: Convert to v4l2_ext_pix_format Helen Koike
2021-01-14 18:07 ` Helen Koike [this message]
2021-01-14 18:07 ` [RFC PATCH v6 11/11] media: docs: add documentation for the Extended API Helen Koike
2021-02-05 18:39 ` [RFC PATCH v6 00/11] media: v4l2: Add extended fmt and buffer ioctls Helen Koike
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210114180738.1758707-11-helen.koike@collabora.com \
--to=helen.koike@collabora.com \
--cc=Brian.Starkey@arm.com \
--cc=boris.brezillon@collabora.com \
--cc=frkoenig@chromium.org \
--cc=hans.verkuil@cisco.com \
--cc=hiroh@chromium.org \
--cc=hverkuil@xs4all.nl \
--cc=kernel@collabora.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=narmstrong@baylibre.com \
--cc=nicolas@ndufresne.ca \
--cc=sakari.ailus@iki.fi \
--cc=stanimir.varbanov@linaro.org \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).