From: "Dr. David Alan Gilbert" <dave@treblig.org>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>, a.j.buxton@gmail.com
Cc: linux-media@vger.kernel.org,
Deborah Brouwer <deborah.brouwer@collabora.com>
Subject: Re: [PATCH 2/3] media: bttv: add back vbi hack
Date: Sun, 3 Dec 2023 16:17:31 +0000 [thread overview]
Message-ID: <ZWyqG2XEYrYUB7X_@gallifrey> (raw)
In-Reply-To: <16f3b2a896e2a3788e8e33ab7a0e55cbad4bbd81.1701349092.git.hverkuil-cisco@xs4all.nl>
* Hans Verkuil (hverkuil-cisco@xs4all.nl) wrote:
> The old (now removed) videobuf framework had an optional vbi hack where
> the sequence number of the frame counter was copied in the last 4 bytes
> of the buffer. This hack was active only for the read() interface
> (so not for streaming I/O), and it was enabled by bttv. This allowed
> applications that used read() for the VBI data to match it with the
> corresponding video frame.
>
> When bttv was converted to vb2 this hack was forgotten, but some old
> applications rely on this.
>
> So add this back, but this time in the bttv driver rather than in the
> vb2 framework.
>
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Fixes: b7ec3212a73a ("media: bttv: convert to vb2")
Thanks; this seems to fix the sequence number errors I was getting,
so:
Tested-by: Dr. David Alan Gilbert <dave@treblig.org>
> ---
> drivers/media/pci/bt8xx/bttv-driver.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index 8e8c9dada67a..49a3dd70ec0f 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -2772,6 +2772,27 @@ bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup,
> return;
> wakeup->vbuf.vb2_buf.timestamp = ktime_get_ns();
> wakeup->vbuf.sequence = btv->field_count >> 1;
> +
> + /*
> + * Ugly hack for backwards compatibility.
> + * Some applications expect that the last 4 bytes of
> + * the VBI data contains the sequence number.
> + *
> + * This makes it possible to associate the VBI data
> + * with the video frame if you use read() to get the
> + * VBI data.
> + */
> + if (vb2_fileio_is_active(wakeup->vbuf.vb2_buf.vb2_queue)) {
> + u32 *vaddr = vb2_plane_vaddr(&wakeup->vbuf.vb2_buf, 0);
> + unsigned long size =
> + vb2_get_plane_payload(&wakeup->vbuf.vb2_buf, 0) / 4;
> +
> + if (vaddr && size) {
> + vaddr += size - 1;
> + *vaddr = wakeup->vbuf.sequence;
> + }
> + }
> +
> vb2_buffer_done(&wakeup->vbuf.vb2_buf, state);
> if (btv->field_count == 0)
> btor(BT848_INT_VSYNC, BT848_INT_MASK);
> --
> 2.42.0
>
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/
next prev parent reply other threads:[~2023-12-03 16:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 12:58 [PATCH 0/3] media: bttv: three post-vb2 fixes Hans Verkuil
2023-11-30 12:58 ` [PATCH 1/3] media: bttv: start_streaming should return a proper error code Hans Verkuil
2023-11-30 12:58 ` [PATCH 2/3] media: bttv: add back vbi hack Hans Verkuil
2023-12-03 16:17 ` Dr. David Alan Gilbert [this message]
2023-11-30 12:58 ` [PATCH 3/3] media: videobuf2: request more buffers for vb2_read Hans Verkuil
2023-12-03 16:46 ` Dr. David Alan Gilbert
2023-12-04 8:48 ` Hans Verkuil
2023-11-30 14:26 ` [PATCH 0/3] media: bttv: three post-vb2 fixes Dr. David Alan Gilbert
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=ZWyqG2XEYrYUB7X_@gallifrey \
--to=dave@treblig.org \
--cc=a.j.buxton@gmail.com \
--cc=deborah.brouwer@collabora.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-media@vger.kernel.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