From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
Tsuchiya Yuto <kitakar@gmail.com>,
Andy Shevchenko <andy@kernel.org>,
Yury Luneff <yury.lunev@gmail.com>,
Nable <nable.maininbox@googlemail.com>,
andrey.i.trufanov@gmail.com, Fabio Aiuto <fabioaiuto83@gmail.com>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev
Subject: Re: [PATCH v2 12/17] media: atomisp: Fix VIDIOC_REQBUFS failing when VIDIOC_S_FMT has not been called yet
Date: Mon, 14 Nov 2022 20:38:19 +0000 [thread overview]
Message-ID: <20221114203819.44e7baad@sal.lan> (raw)
In-Reply-To: <20221020195533.114049-13-hdegoede@redhat.com>
Em Thu, 20 Oct 2022 21:55:28 +0200
Hans de Goede <hdegoede@redhat.com> escreveu:
> camorama calls VIDIOC_REQBUFS(V4L2_MEMORY_MMAP) to test if MMAP support
> works (this was added specifically because of the previously broken
> MMAP support in atomisp).
>
> Currently this fails because atomisp_get_css_frame_info() fails in this
> case. Although it is weird to call VIDIOC_REQBUFS before VIDIOC_S_FMT,
> it is allowed to do this.
>
> Fix this not working by doing a S_FMT to V4L2_PIX_FMT_YUV420 + the highest
> supported resolution.
>
> Note this will cause camorama to use mmap mode, which means it will also
> use libv4l2 to do format conversion. libv4l2 will pick V4L2_PIX_FMT_RGB565
> as input format and this will lead to a garbled video display. This is
> a libv4lconvert bug, the RGB565 -> RGB24 path in libv4lconvert assumes
> that stride == width which is not true on the atomisp.
Hmm... should we add a patch on Camorama for it to not use libv4l2 if
format == V4L2_PIX_FMT_RGB565?
>
> I've already send out a libv4lconvert fix for this. Also this can be worked
> around by passing --dont-use-libv4l2 as argument to camorama.
Was the patch already applied? The better would be to apply it at
libv4l2 upstream, as a fix, porting it to old versions, and mentioning
on what versions this got fixed on this changeset.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> .../media/atomisp/pci/atomisp_compat_css20.c | 2 +-
> .../staging/media/atomisp/pci/atomisp_fops.c | 25 +++++++++++++++++--
> 2 files changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
> index ea6114679c53..f282572d69da 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
> @@ -2688,7 +2688,7 @@ int atomisp_get_css_frame_info(struct atomisp_sub_device *asd,
>
> if (0 != ia_css_pipe_get_info(asd->stream_env[stream_index]
> .pipes[pipe_index], &info)) {
> - dev_err(isp->dev, "ia_css_pipe_get_info FAILED");
> + dev_dbg(isp->dev, "ia_css_pipe_get_info FAILED");
> return -EINVAL;
> }
>
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_fops.c b/drivers/staging/media/atomisp/pci/atomisp_fops.c
> index bc47a092a8af..f539df09ebd9 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_fops.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_fops.c
> @@ -50,15 +50,36 @@ static int atomisp_queue_setup(struct vb2_queue *vq,
> u16 source_pad = atomisp_subdev_source_pad(&pipe->vdev);
> int ret;
>
> + mutex_lock(&pipe->asd->isp->mutex); /* for get_css_frame_info() / set_fmt() */
> +
> + /*
> + * When VIDIOC_S_FMT has not been called before VIDIOC_REQBUFS, then
> + * this will fail. Call atomisp_set_fmt() ourselves and try again.
> + */
> ret = atomisp_get_css_frame_info(pipe->asd, source_pad, &pipe->frame_info);
> - if (ret)
> - return ret;
> + if (ret) {
> + struct v4l2_format f = {
> + .fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420,
> + .fmt.pix.width = 10000,
> + .fmt.pix.height = 10000,
> + };
> +
> + ret = atomisp_set_fmt(&pipe->vdev, &f);
> + if (ret)
> + goto out;
> +
> + ret = atomisp_get_css_frame_info(pipe->asd, source_pad, &pipe->frame_info);
> + if (ret)
> + goto out;
> + }
>
> atomisp_alloc_css_stat_bufs(pipe->asd, ATOMISP_INPUT_STREAM_GENERAL);
>
> *nplanes = 1;
> sizes[0] = PAGE_ALIGN(pipe->pix.sizeimage);
>
> +out:
> + mutex_unlock(&pipe->asd->isp->mutex);
> return 0;
> }
>
next prev parent reply other threads:[~2022-11-14 20:38 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 19:55 [PATCH v2 00/17] media: atomisp: Convert to videobuf2 Hans de Goede
2022-10-20 19:55 ` [PATCH v2 01/17] media: atomisp: Add hmm_create_from_vmalloc_buf() function Hans de Goede
2022-10-20 19:55 ` [PATCH v2 02/17] media: atomisp: Add ia_css_frame_init_from_info() function Hans de Goede
2022-10-20 19:55 ` [PATCH v2 03/17] media: atomisp: Make atomisp_q_video_buffers_to_css() static Hans de Goede
2022-10-20 19:55 ` [PATCH v2 04/17] media: atomisp: On streamoff wait for buffers owned by the CSS to be given back Hans de Goede
2022-11-14 10:38 ` Andy Shevchenko
2022-11-20 21:55 ` Hans de Goede
2022-10-20 19:55 ` [PATCH v2 05/17] media: atomisp: Remove unused atomisp_buffers_queued[_pipe] functions Hans de Goede
2022-10-20 19:55 ` [PATCH v2 06/17] media: atomisp: Also track buffers in a list when submitted to the ISP Hans de Goede
2022-11-14 11:53 ` Andy Shevchenko
2022-11-20 21:59 ` Hans de Goede
2022-10-20 19:55 ` [PATCH v2 07/17] media: atomisp: Add an index helper variable to atomisp_buf_done() Hans de Goede
2022-10-20 19:55 ` [PATCH v2 08/17] media: atomisp: Use new atomisp_flush_video_pipe() helper in atomisp_streamoff() Hans de Goede
2022-10-20 19:55 ` [PATCH v2 09/17] media: atomisp: Add ia_css_frame_get_info() helper Hans de Goede
2022-11-14 12:00 ` Andy Shevchenko
2022-10-20 19:55 ` [PATCH v2 10/17] media: atomisp: Convert to videobuf2 Hans de Goede
2022-11-14 12:14 ` Andy Shevchenko
2022-11-20 22:11 ` Hans de Goede
2022-10-20 19:55 ` [PATCH v2 11/17] media: atomisp: Make it possible to call atomisp_set_fmt() without a file handle Hans de Goede
2022-10-20 19:55 ` [PATCH v2 12/17] media: atomisp: Fix VIDIOC_REQBUFS failing when VIDIOC_S_FMT has not been called yet Hans de Goede
2022-11-14 12:17 ` Andy Shevchenko
2022-11-20 22:21 ` Hans de Goede
2022-11-14 20:38 ` Mauro Carvalho Chehab [this message]
2022-11-20 22:17 ` Hans de Goede
2022-11-20 23:29 ` Mauro Carvalho Chehab
2022-10-20 19:55 ` [PATCH v2 13/17] media: atomisp: Refactor atomisp_adjust_fmt() Hans de Goede
2022-10-20 19:55 ` [PATCH v2 14/17] media: atomisp: Fix atomisp_try_fmt_cap() always returning YUV420 pixelformat Hans de Goede
2022-10-20 19:55 ` [PATCH v2 15/17] media: atomisp: Make atomisp_g_fmt_cap() default to YUV420 Hans de Goede
2022-11-14 12:18 ` Andy Shevchenko
2022-10-20 19:55 ` [PATCH v2 16/17] media: atomisp: Remove __atomisp_get_pipe() helper Hans de Goede
2022-10-20 19:55 ` [PATCH v2 17/17] media: atomisp: gc0310: Power on sensor from set_fmt() callback Hans de Goede
2022-11-14 12:20 ` Andy Shevchenko
2022-11-20 22:24 ` Hans de Goede
2022-11-14 20:57 ` Mauro Carvalho Chehab
2022-11-14 12:22 ` [PATCH v2 00/17] media: atomisp: Convert to videobuf2 Andy Shevchenko
2022-11-20 22:39 ` Hans de Goede
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=20221114203819.44e7baad@sal.lan \
--to=mchehab@kernel.org \
--cc=andrey.i.trufanov@gmail.com \
--cc=andy@kernel.org \
--cc=fabioaiuto83@gmail.com \
--cc=hdegoede@redhat.com \
--cc=kitakar@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=nable.maininbox@googlemail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=yury.lunev@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.