media: ti: cal: use CSI-2 frame number for seq number
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tue, 26 Apr 2022 07:06:16 +0000 (09:06 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Tue, 30 Aug 2022 05:43:39 +0000 (07:43 +0200)
commitebdb28a55da1248d6dfe3bcde9c9f6198f770b2d
tree544dcdf73247f9c9705ca15054fb83987c9c0a90
parentb1b93d36c385436742ce4ddf412faaa0383529a5
media: ti: cal: use CSI-2 frame number for seq number

The userspace needs a way to match received metadata buffers to pixel
data buffers. The obvious way to do this is to use the CSI-2 frame
number, as both the metadata and the pixel data have the same frame
number as they come from the same frame.

However, we don't have means to convey the frame number to userspace. We
do have the 'sequence' field, which with a few tricks can be used for
this purpose.

To achieve this, track the frame number for each virtual channel and
increase the sequence for each virtual channel by frame-number -
previous-frame-number, also taking into account the eventual wrap of the
CSI-2 frame number. If the CSI-2 peripheral does not support frame
numbers, CAL increases the frame number register by one each frame.

This way we get a monotonically increasing sequence number which is
common to all streams using the same virtual channel.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/ti/cal/cal-camerarx.c
drivers/media/platform/ti/cal/cal.c
drivers/media/platform/ti/cal/cal.h