Commit Graph

48 Commits

Author SHA1 Message Date
Paul Kocialkowski 7ff2543e64 Add support for the single-planar V4L2 API
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2018-09-07 16:43:13 +02:00
Paul Kocialkowski 13eaae060e Add support for H265 decoding, including predictive frames
Some features are missing, such as scaling lists (quantization) and
10-bit output.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-08-31 10:13:52 +02:00
Paul Kocialkowski c9327dd55a Grab the base index when allocating buffers and mapping them
Because there might be more than a single call to CreateSurfaces,
we cannot assume that the index relative to the number of surfaces
requested in a single call matches the v4l2 index.

Grab the base index (as returned by the kernel) when allocating
buffers and use it for memory mapping and addressing them in v4l2.
This avoids memory-mapping the first (index 0) buffer multiple times
in that scenario instead of the n-th allocated buffer (in the n-th
call in the sequence).

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-20 13:48:51 +02:00
Paul Kocialkowski fa7ab6a251 context: Liberate output and capture buffers at ContextDestroy
The V4L2 API does not currently provide a way to liberate allocated
buffers one by one (which would fit well with DestroySurfaces in
VAAPI). Moreover, streaming needs to be off before liberating
buffers is allowed.

As a result, output an capture buffers can only be liberated when
destroying the decoding context, all at once, such as implemented
in this patch.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-20 13:47:48 +02:00
Paul Kocialkowski d2357862f8 Rename request_buffer helper to query_buffer
Since the V4L2 ioctl is called QUERYBUF, it makes more sense to
call the associated function with the same name.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-20 13:47:48 +02:00
Maxime Ripard 92f6546596 tree: Remove void * casts
void * can be assigned from and stored to any pointer type without any
warning. Remove the explicit casts.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 17:02:23 +02:00
Maxime Ripard 111f5b209a tree: Rename cedrus_data to request_data
The cedrus_data structure carries the old name. In order to migrate to the
new name, let's rename it to request_data.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 17:02:23 +02:00
Maxime Ripard 4ad990e087 tree: Rename the header and defines
The sunxi_cedrus.h header contains a bunch of defines prefixed with
SUNXI_CEDRUS.

As part as the ongoing migration to a more generic name, change that prefix
for V4L2_REQUEST, and the header file to request.h

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 17:02:23 +02:00
Maxime Ripard 913e1e642c tree: Rename the libva hooks
As part of our renaming effort, Rename the libva hooks names to mention
request instead of SunxiCedrus

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 17:02:23 +02:00
Maxime Ripard e7c09a336f h264: Implement local cache of the latest decoded pictures
The libva only provides the reference images needed to decode the current
picture, but not the full DPB. However, some codecs need that whole DPB in
order to decode a picture.

For example, the Allwinner hardware codec has an internal SRAM, with each
picture getting a slot in that SRAM, and during each decoding process, some
metadata will then be generated from that SRAM content to a separate
buffer. Therefore, each frames must be located at the same SRAM position
each time so that the metadata are then re-used properly.

However, since libva will only pass a few reference images, we can end up
in a situation where multiple, subsequent, frames will have the same
reference images set, but might all be used as reference later on and
cannot therefore be located at the same position.

And from a more theorical point of view, Linux expects a full blown DPB in
its H264 control.

In order to work around this, we can create a shadow of the DPB by simply
maintaining a list of 16 decoded images, each associated with their
VAPictureH264 and an age. This age is the last time we used that frame as
reference. When a new picture is decoded, either we assign it to a free
slot, or we reuse the slot from the frame that hasn't been used as a
reference for the longest time.

This is a much simpler approach than the one documented in the H264 spec,
but this shouldn't really be a problem since we don't handle the reference
frames ourselves, but just re-use the one from the libva, and taken from
the bitstream before. As such, frames that are not supposed to be used for
reference will not be anymore, their age will not increase, and therefore
after a while we will garbage-collect their slot to store a much newer
frame.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 15:30:33 +02:00
Maxime Ripard 5aeb07f8bf tree: Run clang-format to conform to the kernel coding style
The coding style has been a bit erratic. Enforce the linux kernel coding
style by reusing their .clang-format file, running clang-format on the
source, and ignoring the few shortcomings that clang-format has at the
moment (especially on aligning the define values).

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 10:12:15 +02:00
Maxime Ripard b938824c48 tree: Shorten struct sunxi_cedrus_driver_data name
This long structure name makes it quite difficult to fit within the 80
characters limit. Shorten it.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 09:34:15 +02:00
Maxime Ripard fd263773cc tree: Change the macros to take the actual arguments they are using
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-13 16:00:08 +02:00
Maxime Ripard 1efa9d877e Add support for H264 decoding
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-11 17:07:15 +02:00
Paul Kocialkowski 03fd51b3b3 Reduce switch/case indentation
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-11 15:32:52 +02:00
Paul Kocialkowski a9f3129298 context: Use proper error path
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-11 15:21:17 +02:00
Maxime Ripard 53a8c6e1cf context: Make it clear why we copy the ids
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-11 15:20:05 +02:00
Paul Kocialkowski 9f2c069f76 Rework buffer management to be more generic and support untiled format
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-11 15:16:52 +02:00
Paul Kocialkowski 2ca67372f8 Set surface destination index at context time for consistency
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-10 10:45:35 +02:00
Paul Kocialkowski bb73d363a3 Sync with latest definitions from the Cedrus driver and requests API
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-06-21 09:30:06 +02:00
Paul Kocialkowski 00c190c740 context: Include missing utils header
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-05-02 16:42:35 +02:00
Paul Kocialkowski 26536a0d8b context: Add warning about index mismatch when allocating source buffers
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2018-05-02 14:53:42 +02:00
Paul Kocialkowski ebd5a845b1 context: Register context parameter with object
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-25 15:05:37 +02:00
Paul Kocialkowski b01a66dcd8 context: Add missing new line
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-25 11:12:21 +02:00
Paul Kocialkowski 294a6c958a Use all-caps macros instead of object_heap_lookup (for now)
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-25 11:03:58 +02:00
Paul Kocialkowski f872e345d0 Centralize buffer-related ressources in surface object and avoid dynamic indexes
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-25 10:48:17 +02:00
Paul Kocialkowski 58b15c25c9 context: Resolve various trivial build issues
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-25 09:19:00 +02:00
Paul Kocialkowski a8c191b544 Rename mem2mem_fd to video_fd to prepare for media introduction
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-24 16:40:42 +02:00
Paul Kocialkowski c7f0d7684a Introduce and use dedicated v4l2 helpers to replace inline ioctls
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-24 15:39:31 +02:00
Paul Kocialkowski 2399515b84 context: Harmonize coding style
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-24 10:03:58 +02:00
Paul Kocialkowski cd31cb568c Rename va_config to config for consistency
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 17:09:19 +02:00
Paul Kocialkowski 4b7e71668e Reorder functions, with a straightforward logic
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 16:51:15 +02:00
Paul Kocialkowski a5354efe43 Rework comments by splitting them into README and removing redundant ones
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 16:40:00 +02:00
Paul Kocialkowski 104eb22462 context: Rename target structure elements to make them explicit
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 14:55:18 +02:00
Paul Kocialkowski b00ffa00d1 context: Rename functions arguments for more clarity
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 11:55:25 +02:00
Paul Kocialkowski 8fd01b54b6 context: Rename object context structure fields for more clarity
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 11:51:28 +02:00
Paul Kocialkowski 90dbf3e6a5 Remove partial MPEG4 support, that is missing from the driver
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 11:24:49 +02:00
Paul Kocialkowski d8a51f0cd4 Use libVA naming style for public API functions
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 11:23:10 +02:00
Paul Kocialkowski b0a8023644 Remove INIT_DRIVER_DATA and replace it with explicit definition
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 11:22:49 +02:00
Paul Kocialkowski 4354922570 Drop the _drv_video suffix from sunxi_cedrus files for conciseness
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 10:56:11 +02:00
Paul Kocialkowski 36b7bba14f config: Use object config structure directly instead of abstract type
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 10:56:11 +02:00
Paul Kocialkowski 6a06b4570b context: Use object context structure directly instead of abstract type
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-23 10:04:58 +02:00
Maxime Ripard fdf8c591e0 context: call streamoff when destroying the context
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-04-20 10:21:54 +02:00
Maxime Ripard 30154c81c5 context: Increase v4l2 sizeimage to take the buffer numbers into account
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-04-20 10:19:42 +02:00
Maxime Ripard 4d0a5d8178 context: cosmetic change
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-04-20 10:08:47 +02:00
Florent Revest f645948921 Add MPEG 4 codec
This patch introduces the support of MPEG4 video decoding. It basically
just copies data from VA's frame/slice headers data structures to v4l's
MPEG4 frame header extended controls data structures.
2016-08-25 16:24:45 +02:00
Florent Revest 728b1b41b9 Add MPEG 2 codec
This patch introduces the support of MPEG2 video decoding. It basically
just copies data from VA's frame/slice headers data structures to v4l's
MPEG2 frame header extended controls data structures.
2016-08-25 16:21:42 +02:00
Florent Revest e263c9542c Adds a sunxi-cedrus-drv-video libVA backend
This VA backend uses v4l2's Frame API proposal to interface with the
"sunxi-cedrus" video driver on Allwinner SoC. Only a few parts of the
code are really dependent on sunxi-cedrus and this VA backend could be
reused for other v4l drivers using the Frame API.
2016-08-25 16:19:34 +02:00