Commit Graph

323 Commits

Author SHA1 Message Date
Paul Kocialkowski 829abae895 surface: Add basic support for CreateSurfaces2
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-18 14:40:36 +02:00
Maxime Ripard 3119125a2a tree: add the driver_data parameter to the IMAGE macro as well
The IMAGE macro takes an implicit driver_data argument. In order to make
it obvious that we need it, let's put it as an explicit parameter.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-18 14:37:33 +02:00
Paul Kocialkowski b4605a08bd README: Update supported codecs
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-17 17:49:17 +02:00
Maxime Ripard 4173013493 libva: Change the vendor string
The vendor string needs to be updated to match the new name. Do so.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 17:02:23 +02:00
Maxime Ripard 59c4a6e034 libva: Change the environment variables name
Change the environment variables for the media and video path to match the
libva name.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 17:02:23 +02:00
Maxime Ripard 4dbfe44c9b README: Update with the new name
Convert the README to the new name for the libva.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 17:02:23 +02:00
Maxime Ripard 22e0c6c3e1 tree: Rename the libva name for real
Change the autotools files, and with them the name of the libva.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 17:02:23 +02:00
Maxime Ripard 791428e2c0 buffer: Remove the sunxi_cedrus_destroy buffer prototype
That function isn't defined anywhere, remove its prototype.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 17:02:23 +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 d43854dfd9 tree: Change sunxi_cedrus_log for request_log
As part of the ongoing switch to a generic name, let's start with log
function.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 15:54:55 +02:00
Maxime Ripard 2d1bce38c2 h264: Don't set num_slices anymore
The num_slices parameter was improperly set to the number of reference
frames, which is incorrect.

Add a counter for the number of slices per surface, and set num_slices to
that value.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 15:28:55 +02:00
Maxime Ripard 38d38134c7 h264: Set PPS pic_init_qp_minus26 field
The pic_init_qp_minus26 must be set but was not until now. Fix this.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 15:28:55 +02:00
Maxime Ripard 1fca951c05 h264: Fix prediction weight table
The current code sets the prediction weight table by doing a memcpy of the
libva structure to the v4l2's structure.

However, for the offset and weight parameters, libva's structure uses
16-bits integer, while v4l2 uses 8-bits, which obviously doesn't work well
with memcpy.

Create a function to copy those arrays and matrices instead that follows
the algorithm defined in the H264 spec, and use it so that it works
properly.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 15:28:55 +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 dadb3d344f h264: Pass the context to the sub-control functions
Some functions setting the controls in the H264 code will need the context
in order to access the DPB. Make sure that we pass it as an argument.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 15:29:28 +02:00
Maxime Ripard acc0cf3475 codecs: pass the context to the controls function as well
Some functions setting the controls will need the context in the future.
Make sure that we provide it as an argument.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 15:28:55 +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 f831082a09 config: Add missing header
The object_config structure embeds some cedrus.h defines, without including
its header, resulting in a compilation breakage if we don't include
sunxi_cedrus.h before config.h. Fix this.

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 6f8697cb1b cedrus: remove useless cast
malloc returns a void pointer that can be casted to any pointer type
without any warning. Remove that cast.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 09:33:34 +02:00
Maxime Ripard 23be0e66a3 video: Make video_v4l2_format function private
The video_v4l2_format function is defined as inline in the header, but not
static. This will lead to a linker failure when you have multiple files
including the header.

Since it's not used anywhere but in video.c, move it there.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 09:32:19 +02:00
Maxime Ripard 2208d57b8f h264: shorten the surface_object parameter name
Using the same words but not in the same order for both the type and the
variable name isn't particularly helpful, and prevents to stay within 80
characters. Shorten the name a bit.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 09:31:17 +02:00
Maxime Ripard 5b50ce871e mpeg2: remove unused includes from header
The MPEG2 header doesn't need any header, since it's only using pointers.
Remove them, and add them to the mpeg2 file when needed.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 09:30:35 +02:00
Maxime Ripard e968914819 h264: define properly the set controls function
The h264_fill_controls isn't used anywhere, but the h264_set_controls
function is. Since the one defined in the header is _fill_controls, this
leads to a warning at compile time. Fix it.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 09:29:32 +02:00
Maxime Ripard 5aa1604a6c tree: add the driver_data parameter to the BUFFER macro as well
The BUFFER macro takes an implicit driver_data argument. In order to make
it obvious that we need it, let's put it as an explicit parameter.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-17 09:27:57 +02:00
Maxime Ripard 6194f1e7da h264: Adjust for the latest h264 API changes
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-13 16:10:21 +02:00
Maxime Ripard 22b51f5ced h264: Fix build failure introduced by previous commit
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-07-13 16:10:02 +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
Paul Kocialkowski 18331ff41d video: Removed unused macro
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-07-11 17:47:22 +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
Maxime Ripard d7d8fc744b Abstract away MPEG2 support
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 40fdba5c48 Fix deprecated type use for iterator
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-06-22 10:31:06 +02:00
Paul Kocialkowski 000ca7239a object_heap: Sanitize coding style
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-06-22 10:06:14 +02:00
Paul Kocialkowski e23807f928 Add dummy vaPutSurface implementation
As it turns out vaPutSurface is one of the required core functions.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-06-21 09:55:44 +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 c0a3cd8fcd Remove X11 support with vaPutSurface
Using VAAPI as a video output (through vaPutSurface) is deprecated and
definitely not recommended for any use case. Since we're starting to
support non-X11 pipelines, remove X11 support altogether.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-06-21 09:30:06 +02:00
Paul Kocialkowski 5bedd8d898 v4l2: Update to the latest request API definition
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2018-05-19 15:57:11 +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 a412ee8b42 picture: Always sync surface in EndPicture
The libVA API expects rendering to be done after calling EndPicture.
Since SyncSurface calls are generally not issued in a way compatible
with dequeuing buffers (they might be called too early or too late),
always call SyncSurface from EndPicture.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-26 10:00:09 +02:00
Paul Kocialkowski d59da24fd9 Separate Rendering and Dsiplaying surface status
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-26 09:51:30 +02:00
Paul Kocialkowski 27b72100b9 surface: Shortcut when the surface is already ready
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2018-04-25 15:33:22 +02:00