media: rkvdec: Add support for VDPU381 and VDPU383
Subsystems (3)
Detlev Casanova
maintainerv3 cover media: rkvdec: Add support for VDPU381 and VDPU383
These variants are found respectively in the RK3588 and RK3576 SoCs. This patch only adds support for H264 and H265 in both variants.
As there is a considerable part of the code that can be shared with the already supported rkvdec decoder driver, the support for these variants is added here rather than writing a new driver.
This patch set uses the newly introduced hevc_ext_sps_[ls]t_rps v4l2 controls for HEVC.
Therefore, a patched version of userpace tools is needed for HEVC support (added for GStreamer[1] and in an early stage for FFmpeg[2]).
The patchset is based on Kwiboo's HEVC support for rk3399[3].
[1]: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9355
[2]: https://gitlab.collabora.com/detlev/ffmpeg
[3]: https://lore.kernel.org/all/[email protected]/
Changes since v2:
- Rebased on Kwiboo's HEVC support for rk3399
- Include hevc_ext_sps_[ls]t_rps v4l2 controls commits
- Remove empty lines at end of files
- Rename RKVDEC2_ALLOC_* to RKVDEC_ALLOC_*
- Set min_with and min_height to 64
- Remove vdpu38x_fill_pixfmt_mp() function
- Handle userspace not supporting hevc_ext_sps_[ls]t_rps
- Make all config structs static const
Changes since v1:
- Add parsing of the short and long term ref frame sets from the new v4l2 controls
- Add RPS cache to avoid parsing the same data again
- Fix HEVC pixel formats selection
- Fix multiple indentation errors
Detlev Casanova (15):
media: uapi: HEVC: Add v4l2_ctrl_hevc_ext_sps_[ls]t_rps controls
media: v4l2-ctrls: Add hevc_ext_sps_[ls]t_rps controls
media: rkvdec: Switch to using structs instead of writel
media: rkvdec: Move cabac tables to their own source file
media: rkvdec: Use structs to represent the HW RPS
media: rkvdec: Move h264 functions to common file
media: rkvdec: Move hevc functions to common file
media: rkvdec: Add generic configuration for variants
media: rkvdec: Add RCB and SRAM support
media: rkvdec: Support per-variant interrupt handler
media: rkvdec: Enable all clocks without naming them
media: rkvdec: Add H264 support for the VDPU381 variant
media: rkvdec: Add H264 support for the VDPU383 variant
media: rkvdec: Add HEVC support for the VDPU381 variant
media: rkvdec: Add HEVC support for the VDPU383 variant
.../media/v4l/ext-ctrls-codec-stateless.rst | 114 +++
.../media/v4l/videodev2.h.rst.exceptions | 2 +
.../media/v4l/vidioc-queryctrl.rst | 12 +
.../media/platform/rockchip/rkvdec/Kconfig | 1 +
.../media/platform/rockchip/rkvdec/Makefile | 14 +-
.../{rkvdec-hevc-data.c => rkvdec-cabac.c} | 506 +++++++++-
.../rockchip/rkvdec/rkvdec-h264-common.c | 252 +++++
.../rockchip/rkvdec/rkvdec-h264-common.h | 83 ++
.../platform/rockchip/rkvdec/rkvdec-h264.c | 891 ++----------------
.../rockchip/rkvdec/rkvdec-hevc-common.c | 531 +++++++++++
.../rockchip/rkvdec/rkvdec-hevc-common.h | 112 +++
.../platform/rockchip/rkvdec/rkvdec-hevc.c | 306 +-----
.../platform/rockchip/rkvdec/rkvdec-rcb.c | 173 ++++
.../platform/rockchip/rkvdec/rkvdec-rcb.h | 29 +
.../platform/rockchip/rkvdec/rkvdec-regs.h | 571 +++++++----
.../rockchip/rkvdec/rkvdec-vdpu381-h264.c | 469 +++++++++
.../rockchip/rkvdec/rkvdec-vdpu381-hevc.c | 595 ++++++++++++
.../rockchip/rkvdec/rkvdec-vdpu381-regs.h | 427 +++++++++
.../rockchip/rkvdec/rkvdec-vdpu383-h264.c | 582 ++++++++++++
.../rockchip/rkvdec/rkvdec-vdpu383-hevc.c | 690 ++++++++++++++
.../rockchip/rkvdec/rkvdec-vdpu383-regs.h | 284 ++++++
.../platform/rockchip/rkvdec/rkvdec-vp9.c | 231 ++---
.../media/platform/rockchip/rkvdec/rkvdec.c | 536 ++++++++++-
.../media/platform/rockchip/rkvdec/rkvdec.h | 39 +
drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +
drivers/media/v4l2-core/v4l2-ctrls-defs.c | 10 +
include/uapi/linux/v4l2-controls.h | 61 ++
include/uapi/linux/videodev2.h | 2 +
28 files changed, 6080 insertions(+), 1461 deletions(-)
rename drivers/media/platform/rockchip/rkvdec/{rkvdec-hevc-data.c => rkvdec-cabac.c} (86%)
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-h264-common.c
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-h264-common.h
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.h
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-rcb.c
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-rcb.h
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-h264.c
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-regs.h
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c
create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-regs.hSignature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 1/15 media: uapi: HEVC: Add v4l2_ctrl_hevc_ext_sps_[ls]t_rps controls
Some hardware (e.g.: Rockchip's rk3588 hevc decoder) need the long and short term reference information for HEVC decoding.
Add controls to provide it as the raw data form the stream.
--- .../media/v4l/ext-ctrls-codec-stateless.rst | 114 ++++++++++++++++++ .../media/v4l/videodev2.h.rst.exceptions | 2 + .../media/v4l/vidioc-queryctrl.rst | 12 ++ 3 files changed, 128 insertions(+)
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +114 -0
@@ -2958,6 +2958,120 @@ This structure contains all loop filter related parameters. See sections - 0x00000004 - +``V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS (struct)`` + Specifies the list of Long-Term reference sets parameters from the SPS. + These parameters are defined according to :ref:`hevc`. + They are described in section 7.4.3.2.1 "General sequence parameter set + RBSP semantics" of the specification. + This control is a dynamically sized 1-dimensional array, + V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it. + +.. c:type:: v4l2_ctrl_hevc_ext_sps_lt_rps + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_ctrl_hevc_ext_sps_lt_rps + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u16 + - ``lt_ref_pic_poc_lsb_sps`` + - Long term reference picture order count as described in section 7.4.3.2.1 + "General sequence parameter set RBSP semantics" of the specification. + * - __u8 + - ``flags`` + - See :ref:`Extended Long-Term RPS Flags <hevc_ext_sps_lt_rps_flags>` + +.. _hevc_ext_sps_lt_rps_flags: + +``Extended SPS Long-Term RPS Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_USED_LT`` + - 0x00000001 + - Specifies if the long-term reference picture is used 7.4.3.2.1 "General sequence parameter + set RBSP semantics" of the specification. + +``V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS (struct)`` + Specifies the list of Short-Term reference sets parameters from the SPS. + These parameters are defined according to :ref:`hevc`. + They are described in section 7.4.8 "Short-term reference picture set + semantics" of the specification. + This control is a dynamically sized 1-dimensional array, + V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it. + +.. c:type:: v4l2_ctrl_hevc_ext_sps_st_rps + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_ctrl_hevc_ext_sps_st_rps + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u8 + - ``delta_idx_minus1`` + - Specifies the delta compare to the index. See details in section 7.4.8 "Short-term + reference picture set semantics" of the specification. + * - __u8 + - ``delta_rps_sign`` + - Sign of the delta as specified in section 7.4.8 "Short-term reference picture set + semantics" of the specification. + * - __u16 + - ``abs_delta_rps_minus1`` + - Absolute delta RPS as specified in section 7.4.8 "Short-term reference picture set + semantics" of the specification. + * - __u8 + - ``num_negative_pics`` + - Number of short-term RPS entries that have picture order count values less than the + picture order count value of the current picture. + * - __u8 + - ``num_positive_pics`` + - Number of short-term RPS entries that have picture order count values greater than the + picture order count value of the current picture. + * - __u32 + - ``used_by_curr_pic`` + - Bit i specifies if short-term RPS i is used by the current picture. + * - __u32 + - ``use_delta_flag`` + - Bit i specifies if short-term RPS i is included in the short-term RPS entries. + * - __u16 + - ``delta_poc_s0_minus1[16]`` + - Specifies the negative picture order count delta for the i-th entry in the short-term RPS. + See details in section 7.4.8 "Short-term reference picture set semantics" of the + specification. + * - __u16 + - ``delta_poc_s1_minus1[16]`` + - Specifies the positive picture order count delta for the i-th entry in the short-term RPS. + See details in section 7.4.8 "Short-term reference picture set semantics" of the + specification. + * - __u8 + - ``flags`` + - See :ref:`Extended Short-Term RPS Flags <hevc_ext_sps_st_rps_flags>` + +.. _hevc_ext_sps_st_rps_flags: + +``Extended SPS Short-Term RPS Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED`` + - 0x00000001 + - Specifies if the short-term RPS is predicted from another short term RPS. See details in + section 7.4.8 "Short-term reference picture set semantics" of the specification. + .. _v4l2-codec-stateless-av1: ``V4L2_CID_STATELESS_AV1_SEQUENCE (struct)``
Documentation/userspace-api/media/v4l/videodev2.h.rst.exceptions +2 -0
@@ -149,6 +149,8 @@ replace symbol V4L2_CTRL_TYPE_H264_DECODE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_SPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_RECT :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type`
Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +12 -0
@@ -523,6 +523,18 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_ctrl_hevc_decode_params`, containing HEVC decoding parameters for stateless video decoders. + * - ``V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_hevc_ext_sps_lt_rps`, containing HEVC + extended Long-Term RPS for stateless video decoders. + * - ``V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_hevc_ext_sps_st_rps`, containing HEVC + extended Short-Term RPS for stateless video decoders. * - ``V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR`` - n/a - n/a
Signature · 1 line
2.51.1.dirty
Re: [PATCH v3 01/15] media: uapi: HEVC: Add v4l2_ctrl_hevc_ext_sps_[ls]t_rps controls
Hi,
Le mercredi 22 octobre 2025 à 12:22 -0400, Detlev Casanova a écrit :
Quoted 2 lines
Some hardware (e.g.: Rockchip's rk3588 hevc decoder) need the long and short term reference information for HEVC decoding.
That's seems a bit short and incomplete. My understanding is that the decoder on this hardware needs to full parse the slice headers, and cannot be passed with the slice information. It also does not implement a a skip method similar to Hantro.
So in short, I think the justification for this API is that these parameters are needed to fully parse HEVC slice headers. You should perhaps say that similar paramters ares passed in Vulkan Video API ?
Quoted 17 lines
Add controls to provide it as the raw data form the stream.
Signed-off-by Detlev Casanova <[email protected]>---
.../media/v4l/ext-ctrls-codec-stateless.rst | 114 ++++++++++++++++++ .../media/v4l/videodev2.h.rst.exceptions | 2 + .../media/v4l/vidioc-queryctrl.rst | 12 ++3 files changed, 128 insertions(+)Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +0
-0@@ -2958,6 +2958,120 @@ This structure contains all loop filter related parameters. See sections-
0x00000004
-
Quoted 8 lines
+``V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS (struct)``
+ Specifies the list of Long-Term reference sets parameters from the SPS. + These parameters are defined according to :ref:hevc.
+ They are described in section 7.4.3.2.1 "General sequence parameter set + RBSP semantics" of the specification.
+ This control is a dynamically sized 1-dimensional array,
+V4L2_CTRL_FLAG_DYNAMIC_ARRAYflag must be set when using it.
Can we making a bit clearer that this is a subset of the SPS (perhaps use the term subset). And this is user to extend another control (mention this other control) ?
Quoted 31 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +31
-0+ +.. c:type:: v4l2_ctrl_hevc_ext_sps_lt_rps + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_ctrl_hevc_ext_sps_lt_rps + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u16 + - ``lt_ref_pic_poc_lsb_sps`` + - Long term reference picture order count as described in section 7.4.3.2.1 + "General sequence parameter set RBSP semantics" of the specification. + * - __u8 + - ``flags`` + - See :ref:`Extended Long-Term RPS Flags <hevc_ext_sps_lt_rps_flags>` + +.. _hevc_ext_sps_lt_rps_flags: + +``Extended SPS Long-Term RPS Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_USED_LT`` + - 0x00000001
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst This structure contains all loop filter related parameters. See sections · line 3008
Quoted 10 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +10
-0+ - Specifies if the long-term reference picture is used 7.4.3.2.1 "General sequence parameter + set RBSP semantics" of the specification. + +``V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS (struct)`` + Specifies the list of Short-Term reference sets parameters from the SPS. + These parameters are defined according to :ref:`hevc`. + They are described in section 7.4.8 "Short-term reference picture set + semantics" of the specification. + This control is a dynamically sized 1-dimensional array, + V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it.
Déjà vue, this is a duplicate right ?
Quoted 102 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +66
-0+ +.. c:type:: v4l2_ctrl_hevc_ext_sps_st_rps + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_ctrl_hevc_ext_sps_st_rps + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u8 + - ``delta_idx_minus1`` + - Specifies the delta compare to the index. See details in section 7.4.8 "Short-term + reference picture set semantics" of the specification. + * - __u8 + - ``delta_rps_sign`` + - Sign of the delta as specified in section 7.4.8 "Short-term reference picture set + semantics" of the specification. + * - __u16 + - ``abs_delta_rps_minus1`` + - Absolute delta RPS as specified in section 7.4.8 "Short-term reference picture set + semantics" of the specification. + * - __u8 + - ``num_negative_pics`` + - Number of short-term RPS entries that have picture order count values less than the + picture order count value of the current picture. + * - __u8 + - ``num_positive_pics`` + - Number of short-term RPS entries that have picture order count values greater than the + picture order count value of the current picture. + * - __u32 + - ``used_by_curr_pic`` + - Bit i specifies if short-term RPS i is used by the current picture. + * - __u32 + - ``use_delta_flag`` + - Bit i specifies if short-term RPS i is included in the short-term RPS entries. + * - __u16 + - ``delta_poc_s0_minus1[16]`` + - Specifies the negative picture order count delta for the i-th entry in the short-term RPS. + See details in section 7.4.8 "Short-term reference picture set semantics" of the + specification. + * - __u16 + - ``delta_poc_s1_minus1[16]`` + - Specifies the positive picture order count delta for the i-th entry in the short-term RPS. + See details in section 7.4.8 "Short-term reference picture set semantics" of the + specification. + * - __u8 + - ``flags`` + - See :ref:`Extended Short-Term RPS Flags <hevc_ext_sps_st_rps_flags>` + +.. _hevc_ext_sps_st_rps_flags: + +``Extended SPS Short-Term RPS Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED`` + - 0x00000001 + - Specifies if the short-term RPS is predicted from another short term RPS. See details in + section 7.4.8 "Short-term reference picture set semantics" of the specification. +.. _v4l2-codec-stateless-av1:
``V4L2_CID_STATELESS_AV1_SEQUENCE (struct)``Documentation/userspace-api/media/v4l/videodev2.h.rst.exceptions +0
-0@@ -149,6 +149,8 @@ replace symbol V4L2_CTRL_TYPE_H264_DECODE_PARAMS :c:type:`v4l2_ctrl_type`replace symbol
V4L2_CTRL_TYPE_HEVC_SPS:c:type:v4l2_ctrl_typereplace symbolV4L2_CTRL_TYPE_HEVC_PPS:c:type:v4l2_ctrl_typereplace symbolV4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:c:type:v4l2_ctrl_typeDocumentation/userspace-api/media/v4l/videodev2.h.rst.exceptions +2
-0+replace symbol V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS :c:type:`v4l2_ctrl_type`replace symbol
V4L2_CTRL_TYPE_AREA:c:type:v4l2_ctrl_typereplace symbolV4L2_CTRL_TYPE_RECT:c:type:v4l2_ctrl_typereplace symbolV4L2_CTRL_TYPE_FWHT_PARAMS:c:type:v4l2_ctrl_typeDocumentation/userspace-api/media/v4l/vidioc-queryctrl.rst +0
-0@@ -523,6 +523,18 @@ See also the examples in :ref:`control`.- n/a
- A struct :c:type:v4l2_ctrl_hevc_decode_params, containing HEVC decoding parameters for stateless video decoders.
+ * - ``V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS``
+ - n/a
+ - n/a
+ - n/a
+ - A struct :c:type:v4l2_ctrl_hevc_ext_sps_lt_rps, containing HEVCDocumentation/userspace-api/media/v4l/vidioc-queryctrl.rst +7
-0+ extended Long-Term RPS for stateless video decoders. + * - ``V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_hevc_ext_sps_st_rps`, containing HEVC + extended Short-Term RPS for stateless video decoders.
Quoted 3 lines
* - ``V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR``
- n/a
- n/a
cheers,
Nicolas
Detlev Casanova
maintainerRe: [PATCH v3 01/15] media: uapi: HEVC: Add v4l2_ctrl_hevc_ext_sps_[ls]t_rps controls
Hi Nicolas,
Quoted 5 lines · Nicolas Dufresne
Hi,
Le mercredi 22 octobre 2025 à 12:22 -0400, Detlev Casanova a écrit :
Quoted 2 lines
Some hardware (e.g.: Rockchip's rk3588 hevc decoder) need the long and short term reference information for HEVC decoding.
Quoted 8 lines
That's seems a bit short and incomplete. My understanding is that the decoder on this hardware needs to full parse the slice headers, and cannot be passed with the slice information. It also does not implement a a skip method similar to Hantro.
So in short, I think the justification for this API is that these parameters are needed to fully parse HEVC slice headers. You should perhaps say that similar paramters ares passed in Vulkan Video API ?
Yes, I will clarify
Quoted 62 lines
Quoted 14 lines
Add controls to provide it as the raw data form the stream.
Signed-off-by Detlev Casanova <[email protected]>--- .../media/v4l/ext-ctrls-codec-stateless.rst | 114 ++++++++++++++++++ .../media/v4l/videodev2.h.rst.exceptions | 2 + .../media/v4l/vidioc-queryctrl.rst | 12 ++ 3 files changed, 128 insertions(+)Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +0
-0Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst This structure contains all loop filter related parameters. See sections · line 2967
Quoted 10 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +7
-0@@ -2958,6 +2958,120 @@ This structure contains all loop filter related parameters. See sections - 0x00000004 - +``V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS (struct)`` + Specifies the list of Long-Term reference sets parameters from the SPS. + These parameters are defined according to :ref:`hevc`. + They are described in section 7.4.3.2.1 "General sequence parameter set + RBSP semantics" of the specification. + This control is a dynamically sized 1-dimensional array, + V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it.Can we making a bit clearer that this is a subset of the SPS (perhaps use the term subset). And this is user to extend another control (mention this other control) ?
Quoted 34 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +34
-0+ +.. c:type:: v4l2_ctrl_hevc_ext_sps_lt_rps + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_ctrl_hevc_ext_sps_lt_rps + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u16 + - ``lt_ref_pic_poc_lsb_sps`` + - Long term reference picture order count as described in section 7.4.3.2.1 + "General sequence parameter set RBSP semantics" of the specification. + * - __u8 + - ``flags`` + - See :ref:`Extended Long-Term RPS Flags <hevc_ext_sps_lt_rps_flags>` + +.. _hevc_ext_sps_lt_rps_flags: + +``Extended SPS Long-Term RPS Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_USED_LT`` + - 0x00000001 + - Specifies if the long-term reference picture is used 7.4.3.2.1 "General sequence parameter + set RBSP semantics" of the specification. +
Quoted 8 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst This structure contains all loop filter related parameters. See sections · line 3008
Quoted 7 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +7
-0+``V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS (struct)`` + Specifies the list of Short-Term reference sets parameters from the SPS. + These parameters are defined according to :ref:`hevc`. + They are described in section 7.4.8 "Short-term reference picture set + semantics" of the specification. + This control is a dynamically sized 1-dimensional array, + V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it.Déjà vue, this is a duplicate right ?
Almost, you saw the description of the Long term sets before, this is for the Short term.
Only the name and specification section have changed in the description.
Quoted 107 lines
Quoted 95 lines
Documentation/userspace-api/media/v4l/ext-ctrls-codec-stateless.rst +66
-0+ +.. c:type:: v4l2_ctrl_hevc_ext_sps_st_rps + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_ctrl_hevc_ext_sps_st_rps + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u8 + - ``delta_idx_minus1`` + - Specifies the delta compare to the index. See details in section 7.4.8 "Short-term + reference picture set semantics" of the specification. + * - __u8 + - ``delta_rps_sign`` + - Sign of the delta as specified in section 7.4.8 "Short-term reference picture set + semantics" of the specification. + * - __u16 + - ``abs_delta_rps_minus1`` + - Absolute delta RPS as specified in section 7.4.8 "Short-term reference picture set + semantics" of the specification. + * - __u8 + - ``num_negative_pics`` + - Number of short-term RPS entries that have picture order count values less than the + picture order count value of the current picture. + * - __u8 + - ``num_positive_pics`` + - Number of short-term RPS entries that have picture order count values greater than the + picture order count value of the current picture. + * - __u32 + - ``used_by_curr_pic`` + - Bit i specifies if short-term RPS i is used by the current picture. + * - __u32 + - ``use_delta_flag`` + - Bit i specifies if short-term RPS i is included in the short-term RPS entries. + * - __u16 + - ``delta_poc_s0_minus1[16]`` + - Specifies the negative picture order count delta for the i-th entry in the short-term RPS. + See details in section 7.4.8 "Short-term reference picture set semantics" of the + specification. + * - __u16 + - ``delta_poc_s1_minus1[16]`` + - Specifies the positive picture order count delta for the i-th entry in the short-term RPS. + See details in section 7.4.8 "Short-term reference picture set semantics" of the + specification. + * - __u8 + - ``flags`` + - See :ref:`Extended Short-Term RPS Flags <hevc_ext_sps_st_rps_flags>` + +.. _hevc_ext_sps_st_rps_flags: + +``Extended SPS Short-Term RPS Flags`` + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - ``V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED`` + - 0x00000001 + - Specifies if the short-term RPS is predicted from another short term RPS. See details in + section 7.4.8 "Short-term reference picture set semantics" of the specification. + .. _v4l2-codec-stateless-av1: ``V4L2_CID_STATELESS_AV1_SEQUENCE (struct)``Documentation/userspace-api/media/v4l/videodev2.h.rst.exceptions +2
-0@@ -149,6 +149,8 @@ replace symbol V4L2_CTRL_TYPE_H264_DECODE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_SPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_PPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_AREA :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_RECT :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_FWHT_PARAMS :c:type:`v4l2_ctrl_type`Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +5
-0@@ -523,6 +523,18 @@ See also the examples in :ref:`control`. - n/a - A struct :c:type:`v4l2_ctrl_hevc_decode_params`, containing HEVC decoding parameters for stateless video decoders. + * - ``V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_hevc_ext_sps_lt_rps`, containing HEVCDocumentation/userspace-api/media/v4l/vidioc-queryctrl.rst See also the examples in :ref:`control`. · line 540
Quoted 10 lines
Documentation/userspace-api/media/v4l/vidioc-queryctrl.rst +7
-0+ extended Long-Term RPS for stateless video decoders. + * - ``V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS`` + - n/a + - n/a + - n/a + - A struct :c:type:`v4l2_ctrl_hevc_ext_sps_st_rps`, containing HEVC + extended Short-Term RPS for stateless video decoders. * - ``V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR`` - n/a - n/acheers,
Nicolas
Detlev Casanova
maintainerPATCH v3 2/15 media: v4l2-ctrls: Add hevc_ext_sps_[ls]t_rps controls
In reply to Detlev CasanovaThe vdpu381 decoder found on newer Rockchip SoC need the information from the long term and short term ref pic sets from the SPS.
So far, it wasn't included in the v4l2 API, so add it with new dynamic sized controls.
Each element of the hevc_ext_sps_lt_rps array contains the long term ref pic set at that index.
Each element of the hevc_ext_sps_st_rps contains the short term ref pic set at that index, as the raw data.
It is the role of the drivers to calculate the reference sets values.
--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 10 ++++ include/uapi/linux/v4l2-controls.h | 61 +++++++++++++++++++++++ include/uapi/linux/videodev2.h | 2 + 4 files changed, 91 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls-core.c +18 -0
@@ -418,6 +418,12 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl)case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :pr_cont ("HEVC_SLICE_PARAMS" );break ; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS : +pr_cont ("HEVC_EXT_SPS_ST_RPS" ); +break ; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS : +pr_cont ("HEVC_EXT_SPS_LT_RPS" ); +break ;case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX :pr_cont ("HEVC_SCALING_MATRIX" );break ;
@@ -1173,6 +1179,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS :break ; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS : +break ; + +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS : +break ; +case V4L2_CTRL_TYPE_HDR10_CLL_INFO :break ;
@@ -1925,6 +1937,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS : elem_size =sizeof (struct v4l2_ctrl_hevc_slice_params );break ; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS : + elem_size =sizeof (struct v4l2_ctrl_hevc_ext_sps_st_rps ); +break ; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS : + elem_size =sizeof (struct v4l2_ctrl_hevc_ext_sps_lt_rps ); +break ;case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX : elem_size =sizeof (struct v4l2_ctrl_hevc_scaling_matrix );break ;
drivers/media/v4l2-core/v4l2-ctrls-defs.c +10 -0
@@ -1233,6 +1233,8 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_STATELESS_HEVC_DECODE_MODE :return "HEVC Decode Mode" ;case V4L2_CID_STATELESS_HEVC_START_CODE :return "HEVC Start Code" ;case V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS :return "HEVC Entry Point Offsets" ; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS :return "HEVC Short Term Ref Sets" ; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS :return "HEVC Long Term Ref Sets" ;case V4L2_CID_STATELESS_AV1_SEQUENCE :return "AV1 Sequence Parameters" ;case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY :return "AV1 Tile Group Entry" ;case V4L2_CID_STATELESS_AV1_FRAME :return "AV1 Frame Parameters" ;
@@ -1578,6 +1580,14 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *type =V4L2_CTRL_TYPE_U32 ; *flags |=V4L2_CTRL_FLAG_DYNAMIC_ARRAY ;break ; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS : + *type =V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS ; + *flags |=V4L2_CTRL_FLAG_DYNAMIC_ARRAY ; +break ; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS : + *type =V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS ; + *flags |=V4L2_CTRL_FLAG_DYNAMIC_ARRAY ; +break ;case V4L2_CID_STATELESS_VP9_COMPRESSED_HDR : *type =V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR ;break ;
include/uapi/linux/v4l2-controls.h +61 -0
73 lines not on this page · raw message
include/uapi/linux/videodev2.h +2 -0
@@ -1981,6 +1981,8 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS =0x0272 ,V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX =0x0273 ,V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS =0x0274 , +V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS =0x0275 , +V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS =0x0276 ,V4L2_CTRL_TYPE_AV1_SEQUENCE =0x280 , V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281,
Signature · 1 line
2.51.1.dirty
Re: [PATCH v3 02/15] media: v4l2-ctrls: Add hevc_ext_sps_[ls]t_rps controls
Hi,
Le mercredi 22 octobre 2025 à 12:22 -0400, Detlev Casanova a écrit :
Quoted 134 lines
The vdpu381 decoder found on newer Rockchip SoC need the information from the long term and short term ref pic sets from the SPS.
So far, it wasn't included in the v4l2 API, so add it with new dynamic sized controls.
Each element of the
hevc_ext_sps_lt_rpsarray contains the long term ref pic set at that index.
Each element of thehevc_ext_sps_st_rpscontains the short term ref pic set at that index, as the raw data.
It is the role of the drivers to calculate the reference sets values.Signed-off-by Detlev Casanova <[email protected]>---
drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +++++++drivers/media/v4l2-core/v4l2-ctrls-defs.c| 10 ++++ include/uapi/linux/v4l2-controls.h | 61 +++++++++++++++++++++++ include/uapi/linux/videodev2.h | 2 +4 files changed, 91 insertions(+)drivers/media/v4l2-core/v4l2-ctrls-core.c +0
-0@@ -418,6 +418,12 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl)case
V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
pr_cont("HEVC_SLICE_PARAMS");
break;drivers/media/v4l2-core/v4l2-ctrls-core.c +6
-0+case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS : +pr_cont ("HEVC_EXT_SPS_ST_RPS" ); +break ; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS : +pr_cont ("HEVC_EXT_SPS_LT_RPS" ); +break ;case
V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
pr_cont("HEVC_SCALING_MATRIX");
break;drivers/media/v4l2-core/v4l2-ctrls-core.c +0
-0@@ -1173,6 +1179,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,case
V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
break;drivers/media/v4l2-core/v4l2-ctrls-core.c +6
-0+case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS : +break ; + +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS : +break ; +case
V4L2_CTRL_TYPE_HDR10_CLL_INFO:
break;drivers/media/v4l2-core/v4l2-ctrls-core.c +0
-0@@ -1925,6 +1937,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,case
V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
elem_size=sizeof(struct v4l2_ctrl_hevc_slice_params); break;drivers/media/v4l2-core/v4l2-ctrls-core.c +6
-0+case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS : + elem_size =sizeof (struct v4l2_ctrl_hevc_ext_sps_st_rps ); +break ; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS : + elem_size =sizeof (struct v4l2_ctrl_hevc_ext_sps_lt_rps ); +break ;case
V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
elem_size=sizeof(struct v4l2_ctrl_hevc_scaling_matrix); break;drivers/media/v4l2-core/v4l2-ctrls-defs.c +10
-0@@ -1233,6 +1233,8 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_STATELESS_HEVC_DECODE_MODE: return "HEVC Decode Mode"; case V4L2_CID_STATELESS_HEVC_START_CODE: return "HEVC Start Code"; case V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS: return "HEVC Entry Point Offsets"; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS :return "HEVC Short Term Ref Sets" ; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS :return "HEVC Long Term Ref Sets" ; case V4L2_CID_STATELESS_AV1_SEQUENCE: return "AV1 Sequence Parameters"; case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY: return "AV1 Tile Group Entry"; case V4L2_CID_STATELESS_AV1_FRAME: return "AV1 Frame Parameters";@@ -1578,6 +1580,14 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *type = V4L2_CTRL_TYPE_U32; *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY; break; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS : + *type =V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS ; + *flags |=V4L2_CTRL_FLAG_DYNAMIC_ARRAY ; +break ; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS : + *type =V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS ; + *flags |=V4L2_CTRL_FLAG_DYNAMIC_ARRAY ; +break ;case
V4L2_CID_STATELESS_VP9_COMPRESSED_HDR:
*type =V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR; break;include/uapi/linux/v4l2-controls.h +2
-0@@ -2093,6 +2093,8 @@ struct v4l2_ctrl_mpeg2_quantisation { #define V4L2_CID_STATELESS_HEVC_DECODE_MODE (V4L2_CID_CODEC_STATELESS_BASE + 405) #define V4L2_CID_STATELESS_HEVC_START_CODE (V4L2_CID_CODEC_STATELESS_BASE + 406) #define V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS (V4L2_CID_CODEC_STATELESS_BASE + 407) +#define V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS (V4L2_CID_CODEC_STATELESS_BASE + 408) +#define V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS (V4L2_CID_CODEC_STATELESS_BASE + 409)
enumv4l2_stateless_hevc_decode_mode{V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED,include/uapi/linux/v4l2-controls.h +0
-0@@ -2548,6 +2550,65 @@ struct v4l2_ctrl_hevc_scaling_matrix { __u8 scaling_list_dc_coef_32x32[2]; };include/uapi/linux/v4l2-controls.h +26
-0+#define V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED 0x1 + +/* +* struct v4l2_ctrl_hevc_ext_sps_st_rps - HEVC short term RPS parameters +* +* Dynamic size 1-dimension array for short term RPS. The number of elements +* is v4l2_ctrl_hevc_sps::num_short_term_ref_pic_sets. It can contain up to 65 elements. +* +* @delta_idx_minus1: Specifies the delta compare to the index. See details in section 7.4.8 +* "Short-term reference picture set semantics" of the specification. +* @delta_rps_sign: Sign of the delta as specified in section 7.4.8 "Short-term reference picture +* set semantics" of the specification. +* @abs_delta_rps_minus1: Absolute delta RPS as specified in section 7.4.8 "Short-term reference +* picture set semantics" of the specification. +* @num_negative_pics: Number of short-term RPS entries that have picture order count values less +* than the picture order count value of the current picture. +* @num_positive_pics: Number of short-term RPS entries that have picture order count values +* greater than the picture order count value of the current picture. +* @used_by_curr_pic: Bit j specifies if short-term RPS j is used by the current picture. +* @use_delta_flag: Bit j equals to 1 specifies that the j-th entry in the source candidate +* short-term RPS is included in this candidate short-term RPS. +* @delta_poc_s0_minus1: Specifies the negative picture order count delta for the i-th entry in +* the short-term RPS. See details in section 7.4.8 "Short-term reference +* picture set semantics" of the specification. +* @delta_poc_s1_minus1: Specifies the positive picture order count delta for the i-th entry in +* the short-term RPS. See details in section 7.4.8 "Short-term reference
include/uapi/linux/v4l2-controls.h struct v4l2_ctrl_hevc_scaling_matrix { · line 2588
Quoted 10 lines
include/uapi/linux/v4l2-controls.h +10
-0+* picture set semantics" of the specification. +* @flags: See V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_{} +*/ +struct v4l2_ctrl_hevc_ext_sps_st_rps { +__u8 delta_idx_minus1; +__u8 delta_rps_sign; +__u16 abs_delta_rps_minus1; +__u8 num_negative_pics; +__u8 num_positive_pics; +__u32 used_by_curr_pic;
Did you run pahole ? This one does not seem to align, it starts with 16bit offset. The remark is because 32bit and 64bit platform, and all compiler should have the same binary representation, otherwise it will break in some ways.
regards,
Nicolas
Quoted 39 lines
include/uapi/linux/v4l2-controls.h +23
-0+__u32 use_delta_flag; +__u16 delta_poc_s0_minus1[16 ]; +__u16 delta_poc_s1_minus1[16 ]; +__u8 flags; +}; + +#define V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_USED_LT 0x1 + +/* +* struct v4l2_ctrl_hevc_ext_sps_lt_rps - HEVC long term RPS parameters +* +* Dynamic size 1-dimension array for long term RPS. The number of elements +* is v4l2_ctrl_hevc_sps::num_long_term_ref_pics_sps. It can contain up to 65 elements. +* +* @lt_ref_pic_poc_lsb_sps: picture order count modulo MaxPicOrderCntLsb of the i-th candidate +* long-term reference picture. +* @flags: See V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_{} +*/ +struct v4l2_ctrl_hevc_ext_sps_lt_rps { +__u16 lt_ref_pic_poc_lsb_sps; +__u8 flags; +}; +/* Stateless VP9 controls */
#defineV4L2_VP9_LOOP_FILTER_FLAG_DELTA_ENABLED0x1include/uapi/linux/videodev2.h +2
-0@@ -1981,6 +1981,8 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS = 0x0272, V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX = 0x0273, V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS = 0x0274, +V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS =0x0275 , + V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS = 0x0276,
V4L2_CTRL_TYPE_AV1_SEQUENCE=0x280,
V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY=0x281,
Detlev Casanova
maintainerRe: [PATCH v3 02/15] media: v4l2-ctrls: Add hevc_ext_sps_[ls]t_rps controls
Hi Nicolas,
Quoted 142 lines · Nicolas Dufresne
Hi,
Le mercredi 22 octobre 2025 à 12:22 -0400, Detlev Casanova a écrit :
Quoted 139 lines
The vdpu381 decoder found on newer Rockchip SoC need the information from the long term and short term ref pic sets from the SPS.
So far, it wasn't included in the v4l2 API, so add it with new dynamic sized controls.
Each element of the
hevc_ext_sps_lt_rpsarray contains the long term ref pic set at that index.
Each element of thehevc_ext_sps_st_rpscontains the short term ref pic set at that index, as the raw data.
It is the role of the drivers to calculate the reference sets values.Signed-off-by Detlev Casanova <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 10 ++++ include/uapi/linux/v4l2-controls.h | 61 +++++++++++++++++++++++ include/uapi/linux/videodev2.h | 2 + 4 files changed, 91 insertions(+)drivers/media/v4l2-core/v4l2-ctrls-core.c +18
-0@@ -418,6 +418,12 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl) case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS: pr_cont("HEVC_SLICE_PARAMS"); break; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS : +pr_cont ("HEVC_EXT_SPS_ST_RPS" ); +break ; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS : +pr_cont ("HEVC_EXT_SPS_LT_RPS" ); +break ; case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX: pr_cont("HEVC_SCALING_MATRIX"); break;@@ -1173,6 +1179,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS: break; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS : +break ; + +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS : +break ; + case V4L2_CTRL_TYPE_HDR10_CLL_INFO: break;@@ -1925,6 +1937,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS: elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params); break; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS : + elem_size =sizeof (struct v4l2_ctrl_hevc_ext_sps_st_rps ); +break ; +case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS : + elem_size =sizeof (struct v4l2_ctrl_hevc_ext_sps_lt_rps ); +break ; case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX: elem_size = sizeof(struct v4l2_ctrl_hevc_scaling_matrix); break;drivers/media/v4l2-core/v4l2-ctrls-defs.c +10
-0@@ -1233,6 +1233,8 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_STATELESS_HEVC_DECODE_MODE: return "HEVC Decode Mode"; case V4L2_CID_STATELESS_HEVC_START_CODE: return "HEVC Start Code"; case V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS: return "HEVC Entry Point Offsets"; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS :return "HEVC Short Term Ref Sets" ; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS :return "HEVC Long Term Ref Sets" ; case V4L2_CID_STATELESS_AV1_SEQUENCE: return "AV1 Sequence Parameters"; case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY: return "AV1 Tile Group Entry"; case V4L2_CID_STATELESS_AV1_FRAME: return "AV1 Frame Parameters";@@ -1578,6 +1580,14 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *type = V4L2_CTRL_TYPE_U32; *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY; break; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS : + *type =V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS ; + *flags |=V4L2_CTRL_FLAG_DYNAMIC_ARRAY ; +break ; +case V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS : + *type =V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS ; + *flags |=V4L2_CTRL_FLAG_DYNAMIC_ARRAY ; +break ; case V4L2_CID_STATELESS_VP9_COMPRESSED_HDR: *type = V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR; break;include/uapi/linux/v4l2-controls.h +33
-0@@ -2093,6 +2093,8 @@ struct v4l2_ctrl_mpeg2_quantisation { #define V4L2_CID_STATELESS_HEVC_DECODE_MODE (V4L2_CID_CODEC_STATELESS_BASE + 405) #define V4L2_CID_STATELESS_HEVC_START_CODE (V4L2_CID_CODEC_STATELESS_BASE + 406) #define V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS (V4L2_CID_CODEC_STATELESS_BASE + 407) +#define V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS (V4L2_CID_CODEC_STATELESS_BASE + 408) +#define V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS (V4L2_CID_CODEC_STATELESS_BASE + 409) enum v4l2_stateless_hevc_decode_mode { V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED,@@ -2548,6 +2550,65 @@ struct v4l2_ctrl_hevc_scaling_matrix { __u8 scaling_list_dc_coef_32x32[2]; }; +#define V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED 0x1 + +/* +* struct v4l2_ctrl_hevc_ext_sps_st_rps - HEVC short term RPS parameters +* +* Dynamic size 1-dimension array for short term RPS. The number of elements +* is v4l2_ctrl_hevc_sps::num_short_term_ref_pic_sets. It can contain up to 65 elements. +* +* @delta_idx_minus1: Specifies the delta compare to the index. See details in section 7.4.8 +* "Short-term reference picture set semantics" of the specification. +* @delta_rps_sign: Sign of the delta as specified in section 7.4.8 "Short-term reference picture +* set semantics" of the specification. +* @abs_delta_rps_minus1: Absolute delta RPS as specified in section 7.4.8 "Short-term reference +* picture set semantics" of the specification. +* @num_negative_pics: Number of short-term RPS entries that have picture order count values less +* than the picture order count value of the current picture. +* @num_positive_pics: Number of short-term RPS entries that have picture order count values +* greater than the picture order count value of the current picture. +* @used_by_curr_pic: Bit j specifies if short-term RPS j is used by the current picture. +* @use_delta_flag: Bit j equals to 1 specifies that the j-th entry in the source candidate +* short-term RPS is included in this candidate short-term RPS. +* @delta_poc_s0_minus1: Specifies the negative picture order count delta for the i-th entry in +* the short-term RPS. See details in section 7.4.8 "Short-term reference +* picture set semantics" of the specification. +* @delta_poc_s1_minus1: Specifies the positive picture order count delta for the i-th entry in +* the short-term RPS. See details in section 7.4.8 "Short-term reference +* picture set semantics" of the specification. +* @flags: See V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_{} +*/ +struct v4l2_ctrl_hevc_ext_sps_st_rps { +__u8 delta_idx_minus1;
Quoted 8 lines
include/uapi/linux/v4l2-controls.h struct v4l2_ctrl_hevc_scaling_matrix { · line 2588
Quoted 5 lines
include/uapi/linux/v4l2-controls.h +5
-0+__u8 delta_rps_sign; +__u16 abs_delta_rps_minus1; +__u8 num_negative_pics; +__u8 num_positive_pics; +__u32 used_by_curr_pic;Did you run pahole ? This one does not seem to align, it starts with 16bit offset. The remark is because 32bit and 64bit platform, and all compiler should have the same binary representation, otherwise it will break in some ways.
That's a good point. I moved abs_delta_rps_minus1 with the other __u16 fields and changed flags to be 16 bits too.
Also changed flags to 16 bits in v4l2_ctrl_hevc_ext_sps_lt_rps.
Quoted 42 lines
regards,
NicolasQuoted 39 lines
include/uapi/linux/v4l2-controls.h +23
-0+__u32 use_delta_flag; +__u16 delta_poc_s0_minus1[16 ]; +__u16 delta_poc_s1_minus1[16 ]; +__u8 flags; +}; + +#define V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_USED_LT 0x1 + +/* +* struct v4l2_ctrl_hevc_ext_sps_lt_rps - HEVC long term RPS parameters +* +* Dynamic size 1-dimension array for long term RPS. The number of elements +* is v4l2_ctrl_hevc_sps::num_long_term_ref_pics_sps. It can contain up to 65 elements. +* +* @lt_ref_pic_poc_lsb_sps: picture order count modulo MaxPicOrderCntLsb of the i-th candidate +* long-term reference picture. +* @flags: See V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_{} +*/ +struct v4l2_ctrl_hevc_ext_sps_lt_rps { +__u16 lt_ref_pic_poc_lsb_sps; +__u8 flags; +}; + /* Stateless VP9 controls */ #define V4L2_VP9_LOOP_FILTER_FLAG_DELTA_ENABLED 0x1include/uapi/linux/videodev2.h +2
-0@@ -1981,6 +1981,8 @@ enum v4l2_ctrl_type { V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS = 0x0272, V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX = 0x0273, V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS = 0x0274, +V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS =0x0275 , +V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS =0x0276 , V4L2_CTRL_TYPE_AV1_SEQUENCE = 0x280, V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281,
Detlev Casanova
maintainerPATCH v3 3/15 media: rkvdec: Switch to using structs instead of writel
In reply to Detlev CasanovaIn an effort to merge the rkvdec2 driver [1] with this one, switch from writel() calls to using structs to represent the register mappings.
This is done in order to have all supported decoders use the same format in the future and ease reading of the code.
Using structs also improves stability as the hardware is tested and validated downstream using a similar method.
It was noticed, on decoders, that:
- Some registers require to be writen in increasing order [2]
- Some registers, even if unrelated, need to be written to their reset values (it was the case here for axi_ddr_[rw]data).
Using structs can also help improving performance later when, e.g. multicore support is added on RK3588.
Performance seems to be slightly improved, but at least, not made worse. Running fluster's JVT-AVC_V1 test suite with GStreamer on the Radxa ROCK PI 4 SE gives the following times:
Before this patch:
- --jobs 1: Ran 129/135 tests successfully in 77.167 secs
- --jobs 6: Ran 129/135 tests successfully in 23.046 secs
With this patch:
- --jobs 1: Ran 129/135 tests successfully in 70.698 secs
- --jobs 6: Ran 129/135 tests successfully in 22.917 secs
This also shows that the fluster score hasn't changed.
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
--- .../platform/rockchip/rkvdec/rkvdec-h264.c | 165 +++-- .../platform/rockchip/rkvdec/rkvdec-hevc.c | 63 +- .../platform/rockchip/rkvdec/rkvdec-regs.h | 571 ++++++++++++------ .../platform/rockchip/rkvdec/rkvdec-vp9.c | 231 +++---- .../media/platform/rockchip/rkvdec/rkvdec.c | 10 +- .../media/platform/rockchip/rkvdec/rkvdec.h | 1 + 6 files changed, 587 insertions(+), 454 deletions(-)
drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +70 -95
@@ -115,6 +115,7 @@ struct rkvdec_h264_run {struct rkvdec_h264_ctx {struct rkvdec_aux_buf priv_tbl;struct rkvdec_h264_reflists reflists; +struct rkvdec_regs regs; }; #define CABAC_ENTRY(ctxidx, idc0_m, idc0_n, idc1_m, idc1_n, \
@@ -841,45 +842,41 @@ static void assemble_hw_scaling_list(struct rkvdec_ctx *ctx, }/* -* dpb poc related registers table +* Set the ref POC in the correct register. +* +* The 32 registers are spread across 3 regions, each alternating top and bottom ref POCs: +* - 1: ref 0 to 14 contain top 0 to 7 and bottoms 0 to 6 +* - 2: ref 15 to 29 contain top 8 to 14 and bottoms 7 to 14 +* - 3: ref 30 and 31 which correspond to top 15 and bottom 15 respectively. */ -static const u32 poc_reg_tbl_top_field[16 ] = { -RKVDEC_REG_H264_POC_REFER0 (0 ), -RKVDEC_REG_H264_POC_REFER0 (2 ), -RKVDEC_REG_H264_POC_REFER0 (4 ), -RKVDEC_REG_H264_POC_REFER0 (6 ), -RKVDEC_REG_H264_POC_REFER0 (8 ), -RKVDEC_REG_H264_POC_REFER0 (10 ), -RKVDEC_REG_H264_POC_REFER0 (12 ), -RKVDEC_REG_H264_POC_REFER0 (14 ), -RKVDEC_REG_H264_POC_REFER1 (1 ), -RKVDEC_REG_H264_POC_REFER1 (3 ), -RKVDEC_REG_H264_POC_REFER1 (5 ), -RKVDEC_REG_H264_POC_REFER1 (7 ), -RKVDEC_REG_H264_POC_REFER1 (9 ), -RKVDEC_REG_H264_POC_REFER1 (11 ), -RKVDEC_REG_H264_POC_REFER1 (13 ), -RKVDEC_REG_H264_POC_REFER2 (0 ) -}; - -static const u32 poc_reg_tbl_bottom_field[16 ] = { -RKVDEC_REG_H264_POC_REFER0 (1 ), -RKVDEC_REG_H264_POC_REFER0 (3 ), -RKVDEC_REG_H264_POC_REFER0 (5 ), -RKVDEC_REG_H264_POC_REFER0 (7 ), -RKVDEC_REG_H264_POC_REFER0 (9 ), -RKVDEC_REG_H264_POC_REFER0 (11 ), -RKVDEC_REG_H264_POC_REFER0 (13 ), -RKVDEC_REG_H264_POC_REFER1 (0 ), -RKVDEC_REG_H264_POC_REFER1 (2 ), -RKVDEC_REG_H264_POC_REFER1 (4 ), -RKVDEC_REG_H264_POC_REFER1 (6 ), -RKVDEC_REG_H264_POC_REFER1 (8 ), -RKVDEC_REG_H264_POC_REFER1 (10 ), -RKVDEC_REG_H264_POC_REFER1 (12 ), -RKVDEC_REG_H264_POC_REFER1 (14 ), -RKVDEC_REG_H264_POC_REFER2 (1 ) -}; +static void set_poc_reg (struct rkvdec_regs *regs,uint32_t poc,int id,bool bottom) +{ +if (!bottom) { +switch (id) { + case 0 ... 7: + regs->h26x.ref0_14_poc[id *2 ] = poc; +break ; + case 8 ... 14: + regs->h26x.ref15_29_poc[(id -8 ) *2 +1 ] = poc; +break ; +case 15 : + regs->h26x.ref30_poc = poc; +break ; + } + }else { +switch (id) { + case 0 ... 6: + regs->h26x.ref0_14_poc[id *2 +1 ] = poc; +break ; + case 7 ... 14: + regs->h26x.ref15_29_poc[(id -7 ) *2 ] = poc; +break ; +case 15 : + regs->h26x.ref31_poc = poc; +break ; + } + } +}static void config_registers (struct rkvdec_ctx *ctx,struct rkvdec_h264_run *run)
@@ -894,6 +891,7 @@ static void config_registers(struct rkvdec_ctx *ctx,struct vb2_v4l2_buffer *src_buf = run->base.bufs.src;struct vb2_v4l2_buffer *dst_buf = run->base.bufs.dst;const struct v4l2_format *f; +struct rkvdec_regs *regs = &h264_ctx->regs;dma_addr_t rlc_addr;dma_addr_t refer_addr;u32 rlc_len;
@@ -903,10 +901,11 @@ static void config_registers(struct rkvdec_ctx *ctx,u32 yuv_virstride =0 ;u32 offset;dma_addr_t dst_addr; -u32 reg, i; +u32 i; - reg =RKVDEC_MODE (RKVDEC_MODE_H264 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_SYSCTRL ); +memset (regs,0 ,sizeof (*regs)); + + regs->common.reg02.dec_mode =RKVDEC_MODE_H264 ; f = &ctx->decoded_fmt; dst_fmt = &f->fmt.pix_mp;
@@ -921,39 +920,35 @@ static void config_registers(struct rkvdec_ctx *ctx,else if (sps->chroma_format_idc ==2 ) yuv_virstride =2 * y_virstride; - reg =RKVDEC_Y_HOR_VIRSTRIDE (hor_virstride /16 ) | -RKVDEC_UV_HOR_VIRSTRIDE (hor_virstride /16 ) | -RKVDEC_SLICE_NUM_HIGHBIT | -RKVDEC_SLICE_NUM_LOWBITS (0x7ff ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_PICPAR ); + regs->common.reg03.uv_hor_virstride = hor_virstride /16 ; + regs->common.reg03.y_hor_virstride = hor_virstride /16 ; + regs->common.reg03.slice_num_highbit =1 ; + regs->common.reg03.slice_num_lowbits =0x7ff ;/* config rlc base address */ rlc_addr =vb2_dma_contig_plane_dma_addr (&src_buf->vb2_buf,0 ); -writel_relaxed (rlc_addr, rkvdec->regs +RKVDEC_REG_STRM_RLC_BASE ); -writel_relaxed (rlc_addr, rkvdec->regs +RKVDEC_REG_RLCWRITE_BASE ); + regs->common.strm_rlc_base = rlc_addr; + regs->h26x.rlcwrite_base = rlc_addr; rlc_len =vb2_get_plane_payload (&src_buf->vb2_buf,0 ); - reg =RKVDEC_STRM_LEN (rlc_len); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_STRM_LEN ); + regs->common.stream_len = rlc_len;/* config cabac table */ offset = offsetof(struct rkvdec_h264_priv_tbl , cabac_table); -writel_relaxed (priv_start_addr + offset, - rkvdec->regs +RKVDEC_REG_CABACTBL_PROB_BASE ); + regs->common.cabactbl_base = priv_start_addr + offset;/* config output base address */ dst_addr =vb2_dma_contig_plane_dma_addr (&dst_buf->vb2_buf,0 ); -writel_relaxed (dst_addr, rkvdec->regs +RKVDEC_REG_DECOUT_BASE ); + regs->common.decout_base = dst_addr; - reg =RKVDEC_Y_VIRSTRIDE (y_virstride /16 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_Y_VIRSTRIDE ); + regs->common.reg08.y_virstride = y_virstride /16 ; - reg =RKVDEC_YUV_VIRSTRIDE (yuv_virstride /16 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_YUV_VIRSTRIDE ); + regs->common.reg09.yuv_virstride = yuv_virstride /16 ;/* config ref pic address & poc */ for (i =0 ; i <ARRAY_SIZE (dec_params->dpb); i++) {struct vb2_buffer *vb_buf = run->ref_buf[i]; +struct ref_base *base;/* * If a DPB entry is unused or invalid, address of current destination
@@ -963,54 +958,36 @@ static void config_registers(struct rkvdec_ctx *ctx, vb_buf = &dst_buf->vb2_buf; refer_addr =vb2_dma_contig_plane_dma_addr (vb_buf,0 ); -if (dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ) - refer_addr |=RKVDEC_COLMV_USED_FLAG_REF ; -if (dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_FIELD ) - refer_addr |=RKVDEC_FIELD_REF ; - -if (dpb[i].fields &V4L2_H264_TOP_FIELD_REF ) - refer_addr |=RKVDEC_TOPFIELD_USED_REF ; -if (dpb[i].fields &V4L2_H264_BOTTOM_FIELD_REF ) - refer_addr |=RKVDEC_BOTFIELD_USED_REF ; - -writel_relaxed (dpb[i].top_field_order_cnt, - rkvdec->regs + poc_reg_tbl_top_field[i]); -writel_relaxed (dpb[i].bottom_field_order_cnt, - rkvdec->regs + poc_reg_tbl_bottom_field[i]); -if (i <V4L2_H264_NUM_DPB_ENTRIES -1 ) -writel_relaxed (refer_addr, - rkvdec->regs +RKVDEC_REG_H264_BASE_REFER (i)); + base = ®s->h26x.ref0_14_base[i];else -writel_relaxed (refer_addr, - rkvdec->regs +RKVDEC_REG_H264_BASE_REFER15 ); - } + base = ®s->h26x.ref15_base; - reg =RKVDEC_CUR_POC (dec_params->top_field_order_cnt); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_CUR_POC0 ); + base->field_ref = !!(dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_FIELD ); + base->colmv_used_flag_ref = !!(dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ); + base->topfield_used_ref = !!(dpb[i].fields &V4L2_H264_TOP_FIELD_REF ); + base->botfield_used_ref = !!(dpb[i].fields &V4L2_H264_BOTTOM_FIELD_REF ); + base->base_addr = refer_addr >>4 ; - reg =RKVDEC_CUR_POC (dec_params->bottom_field_order_cnt); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_CUR_POC1 ); +set_poc_reg (regs, dpb[i].top_field_order_cnt, i, false); +set_poc_reg (regs, dpb[i].bottom_field_order_cnt, i, true); + } + + regs->h26x.cur_poc = dec_params->top_field_order_cnt; + regs->h26x.cur_poc1 = dec_params->bottom_field_order_cnt;/* config hw pps address */ offset = offsetof(struct rkvdec_h264_priv_tbl , param_set); -writel_relaxed (priv_start_addr + offset, - rkvdec->regs +RKVDEC_REG_PPS_BASE ); + regs->h26x.pps_base = priv_start_addr + offset;/* config hw rps address */ offset = offsetof(struct rkvdec_h264_priv_tbl , rps); -writel_relaxed (priv_start_addr + offset, - rkvdec->regs +RKVDEC_REG_RPS_BASE ); - - reg =RKVDEC_AXI_DDR_RDATA (0 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_AXI_DDR_RDATA ); - - reg =RKVDEC_AXI_DDR_WDATA (0 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_AXI_DDR_WDATA ); + regs->h26x.rps_base = priv_start_addr + offset; offset = offsetof(struct rkvdec_h264_priv_tbl , err_info); -writel_relaxed (priv_start_addr + offset, - rkvdec->regs +RKVDEC_REG_H264_ERRINFO_BASE ); + regs->h26x.errorinfo_base = priv_start_addr + offset; + +rkvdec_memcpy_toio (rkvdec->regs, regs,MIN (sizeof (*regs),4 * rkvdec->variant->num_regs)); }#define RKVDEC_H264_MAX_DEPTH_IN_BYTES 2
@@ -1181,8 +1158,6 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx)schedule_delayed_work (&rkvdec->watchdog_work,msecs_to_jiffies (2000 )); -writel (0 , rkvdec->regs +RKVDEC_REG_STRMD_ERR_EN ); -writel (0 , rkvdec->regs +RKVDEC_REG_H264_ERR_E );writel (1 , rkvdec->regs +RKVDEC_REG_PREF_LUMA_CACHE_COMMAND );writel (1 , rkvdec->regs +RKVDEC_REG_PREF_CHR_CACHE_COMMAND );
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +27 -36
121 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h +381 -190
586 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +99 -132
358 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec.c +9 -1
@@ -914,6 +914,15 @@ void rkvdec_quirks_disable_qos(struct rkvdec_ctx *ctx)writel (reg, rkvdec->regs +RKVDEC_REG_QOS_CTRL ); } +void rkvdec_memcpy_toio (void __iomem *dst,void *src,size_t len) +{ +#ifdef CONFIG_ARM64 +__iowrite32_copy (dst, src, len /4 ); +#else +memcpy_toio (dst, src, len); +#endif +} +static void rkvdec_device_run (void *priv) {struct rkvdec_ctx *ctx = priv;
@@ -1227,7 +1236,6 @@ static void rkvdec_watchdog_func(struct work_struct *work)if (ctx) {dev_err (rkvdec->dev,"Frame processing timed out!\n" );writel (RKVDEC_IRQ_DIS , rkvdec->regs +RKVDEC_REG_INTERRUPT ); -writel (0 , rkvdec->regs +RKVDEC_REG_SYSCTRL );rkvdec_job_finish (ctx,VB2_BUF_STATE_ERROR ); } }
drivers/media/platform/rockchip/rkvdec/rkvdec.h +1 -0
@@ -151,6 +151,7 @@ struct rkvdec_aux_buf {void rkvdec_run_preamble (struct rkvdec_ctx *ctx,struct rkvdec_run *run);void rkvdec_run_postamble (struct rkvdec_ctx *ctx,struct rkvdec_run *run); +void rkvdec_memcpy_toio (void __iomem *dst,void *src,size_t len);void rkvdec_quirks_disable_qos (struct rkvdec_ctx *ctx);
Signature · 1 line
2.51.1.dirty
Re: [PATCH v3 03/15] media: rkvdec: Switch to using structs instead of writel
Hi,
Le mercredi 22 octobre 2025 à 12:22 -0400, Detlev Casanova a écrit :
Quoted 29 lines
In an effort to merge the rkvdec2 driver [1] with this one, switch from
writel()calls to using structs to represent the register mappings.This is done in order to have all supported decoders use the same format in the future and ease reading of the code.
Using structs also improves stability as the hardware is tested and validated downstream using a similar method.
It was noticed, on decoders, that:
- Some registers require to be writen in increasing order [2]
- Some registers, even if unrelated, need to be written to their reset values (it was the case here for axi_ddr_[rw]data).Using structs can also help improving performance later when, e.g. multicore support is added on RK3588.
Performance seems to be slightly improved, but at least, not made worse. Running fluster's JVT-AVC_V1 test suite with GStreamer on the Radxa ROCK PI 4 SE gives the following times:
Before this patch:
- --jobs 1: Ran 129/135 tests successfully in 77.167 secs
- --jobs 6: Ran 129/135 tests successfully in 23.046 secsWith this patch:
- --jobs 1: Ran 129/135 tests successfully in 70.698 secs
- --jobs 6: Ran 129/135 tests successfully in 22.917 secs
Quoted 7 lines
This also shows that the fluster score hasn't changed.
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/Signed-off-by Detlev Casanova <[email protected]>
Quoted 1,395 lines
---
.../platform/rockchip/rkvdec/rkvdec-h264.c | 165 +++-- .../platform/rockchip/rkvdec/rkvdec-hevc.c | 63 +- .../platform/rockchip/rkvdec/rkvdec-regs.h | 571 ++++++++++++------ .../platform/rockchip/rkvdec/rkvdec-vp9.c | 231 +++---- .../media/platform/rockchip/rkvdec/rkvdec.c | 10 +- .../media/platform/rockchip/rkvdec/rkvdec.h | 1 + 6 files changed, 587 insertions(+), 454 deletions(-)drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-0@@ -115,6 +115,7 @@ struct rkvdec_h264_run { struct rkvdec_h264_ctx { struct rkvdec_aux_buf priv_tbl; struct rkvdec_h264_reflists reflists; +struct rkvdec_regs regs; };
#define CABAC_ENTRY(ctxidx,idc0_m,idc0_n,idc1_m,idc1_n, \drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +0
-0@@ -841,45 +842,41 @@ static void assemble_hw_scaling_list(struct rkvdec_ctx *ctx, }
/*
- * dpb poc related registers table
+ * Set the ref POC in the correct register.
+ *
+ * The 32 registers are spread across 3 regions, each alternating top and bottom ref POCs:
+ * - 1: ref 0 to 14 contain top 0 to 7 and bottoms 0 to 6
+ * - 2: ref 15 to 29 contain top 8 to 14 and bottoms 7 to 14
+ * - 3: ref 30 and 31 which correspond to top 15 and bottom 15 respectively. */drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +28
-37-static const u32 poc_reg_tbl_top_field[16 ] = { -RKVDEC_REG_H264_POC_REFER0 (0 ), -RKVDEC_REG_H264_POC_REFER0 (2 ), -RKVDEC_REG_H264_POC_REFER0 (4 ), -RKVDEC_REG_H264_POC_REFER0 (6 ), -RKVDEC_REG_H264_POC_REFER0 (8 ), -RKVDEC_REG_H264_POC_REFER0 (10 ), -RKVDEC_REG_H264_POC_REFER0 (12 ), -RKVDEC_REG_H264_POC_REFER0 (14 ), -RKVDEC_REG_H264_POC_REFER1 (1 ), -RKVDEC_REG_H264_POC_REFER1 (3 ), -RKVDEC_REG_H264_POC_REFER1 (5 ), -RKVDEC_REG_H264_POC_REFER1 (7 ), -RKVDEC_REG_H264_POC_REFER1 (9 ), -RKVDEC_REG_H264_POC_REFER1 (11 ), -RKVDEC_REG_H264_POC_REFER1 (13 ), -RKVDEC_REG_H264_POC_REFER2 (0 ) -}; - -static const u32 poc_reg_tbl_bottom_field[16 ] = { -RKVDEC_REG_H264_POC_REFER0 (1 ), -RKVDEC_REG_H264_POC_REFER0 (3 ), -RKVDEC_REG_H264_POC_REFER0 (5 ), -RKVDEC_REG_H264_POC_REFER0 (7 ), -RKVDEC_REG_H264_POC_REFER0 (9 ), -RKVDEC_REG_H264_POC_REFER0 (11 ), -RKVDEC_REG_H264_POC_REFER0 (13 ), -RKVDEC_REG_H264_POC_REFER1 (0 ), -RKVDEC_REG_H264_POC_REFER1 (2 ), -RKVDEC_REG_H264_POC_REFER1 (4 ), -RKVDEC_REG_H264_POC_REFER1 (6 ), -RKVDEC_REG_H264_POC_REFER1 (8 ), -RKVDEC_REG_H264_POC_REFER1 (10 ), -RKVDEC_REG_H264_POC_REFER1 (12 ), -RKVDEC_REG_H264_POC_REFER1 (14 ), -RKVDEC_REG_H264_POC_REFER2 (1 ) -}; +static void set_poc_reg (struct rkvdec_regs *regs,uint32_t poc,int id,bool bottom) +{ +if (!bottom) { +switch (id) { + case 0 ... 7: + regs->h26x.ref0_14_poc[id *2 ] = poc; +break ; + case 8 ... 14: + regs->h26x.ref15_29_poc[(id -8 ) *2 +1 ] = poc; +break ; +case 15 : + regs->h26x.ref30_poc = poc; +break ; + } + }else { +switch (id) { + case 0 ... 6: + regs->h26x.ref0_14_poc[id *2 +1 ] = poc; +break ; + case 7 ... 14: + regs->h26x.ref15_29_poc[(id -7 ) *2 ] = poc; +break ; +case 15 : + regs->h26x.ref31_poc = poc; +break ; + } + } +}
static voidconfig_registers(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run)drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +2
-1@@ -894,6 +891,7 @@ static void config_registers(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *src_buf = run->base.bufs.src; struct vb2_v4l2_buffer *dst_buf = run->base.bufs.dst; const struct v4l2_format *f; +struct rkvdec_regs *regs = &h264_ctx->regs; dma_addr_t rlc_addr; dma_addr_t refer_addr; u32 rlc_len;@@ -903,10 +901,11 @@ static void config_registers(struct rkvdec_ctx *ctx, u32 yuv_virstride = 0; u32 offset; dma_addr_t dst_addr; -u32 reg, i; +u32 i;drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +3
-2- reg =RKVDEC_MODE (RKVDEC_MODE_H264 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_SYSCTRL ); +memset (regs,0 ,sizeof (*regs)); + + regs->common.reg02.dec_mode =RKVDEC_MODE_H264 ;
f =&ctx->decoded_fmt;
dst_fmt=&f->fmt.pix_mp;drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +0
-0@@ -921,39 +920,35 @@ static void config_registers(struct rkvdec_ctx *ctx, else if (sps->chroma_format_idc == 2) yuv_virstride = 2 * y_virstride;drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +4
-5- reg =RKVDEC_Y_HOR_VIRSTRIDE (hor_virstride /16 ) | - RKVDEC_UV_HOR_VIRSTRIDE(hor_virstride / 16) | - RKVDEC_SLICE_NUM_HIGHBIT | - RKVDEC_SLICE_NUM_LOWBITS(0x7ff); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_PICPAR ); + regs->common.reg03.uv_hor_virstride = hor_virstride /16 ; + regs->common.reg03.y_hor_virstride = hor_virstride /16 ; + regs->common.reg03.slice_num_highbit =1 ; + regs->common.reg03.slice_num_lowbits =0x7ff ;
/* config rlc base address */
rlc_addr=vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +2
-2-writel_relaxed (rlc_addr, rkvdec->regs +RKVDEC_REG_STRM_RLC_BASE ); -writel_relaxed (rlc_addr, rkvdec->regs +RKVDEC_REG_RLCWRITE_BASE ); + regs->common.strm_rlc_base = rlc_addr; + regs->h26x.rlcwrite_base = rlc_addr;
rlc_len=vb2_get_plane_payload(&src_buf->vb2_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-2- reg =RKVDEC_STRM_LEN (rlc_len); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_STRM_LEN ); + regs->common.stream_len = rlc_len;
/* config cabac table */
offset =offsetof(struct rkvdec_h264_priv_tbl, cabac_table);drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-2-writel_relaxed (priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_CABACTBL_PROB_BASE); + regs->common.cabactbl_base = priv_start_addr + offset;
/* config output base address */
dst_addr=vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-1-writel_relaxed (dst_addr, rkvdec->regs +RKVDEC_REG_DECOUT_BASE ); + regs->common.decout_base = dst_addr;drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-2- reg =RKVDEC_Y_VIRSTRIDE (y_virstride /16 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_Y_VIRSTRIDE ); + regs->common.reg08.y_virstride = y_virstride /16 ;drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-2- reg =RKVDEC_YUV_VIRSTRIDE (yuv_virstride /16 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_YUV_VIRSTRIDE ); + regs->common.reg09.yuv_virstride = yuv_virstride /16 ;
/* config ref pic address & poc */
for (i = 0; i <ARRAY_SIZE(dec_params->dpb); i++) { structvb2_buffer*vb_buf= run->ref_buf[i];drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-0+struct ref_base *base;
/*
* If a DPB entry is unused or invalid, address of current destinationdrivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +0
-0@@ -963,54 +958,36 @@ static void config_registers(struct rkvdec_ctx *ctx, vb_buf = &dst_buf->vb2_buf; refer_addr = vb2_dma_contig_plane_dma_addr(vb_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +0
-15-if (dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ) - refer_addr |=RKVDEC_COLMV_USED_FLAG_REF ; -if (dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_FIELD ) - refer_addr |=RKVDEC_FIELD_REF ; - -if (dpb[i].fields &V4L2_H264_TOP_FIELD_REF ) - refer_addr |=RKVDEC_TOPFIELD_USED_REF ; -if (dpb[i].fields &V4L2_H264_BOTTOM_FIELD_REF ) - refer_addr |=RKVDEC_BOTFIELD_USED_REF ; - -writel_relaxed (dpb[i].top_field_order_cnt, - rkvdec->regs + poc_reg_tbl_top_field[i]); -writel_relaxed (dpb[i].bottom_field_order_cnt, - rkvdec->regs + poc_reg_tbl_bottom_field[i]); -if (i <
V4L2_H264_NUM_DPB_ENTRIES- 1)drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-2-writel_relaxed (refer_addr, - rkvdec->regs + RKVDEC_REG_H264_BASE_REFER(i)); + base = ®s->h26x.ref0_14_base[i];else
drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-3-writel_relaxed (refer_addr, - rkvdec->regs + RKVDEC_REG_H264_BASE_REFER15); - } + base = ®s->h26x.ref15_base;drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +5
-2- reg =RKVDEC_CUR_POC (dec_params->top_field_order_cnt); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_CUR_POC0 ); + base->field_ref = !!(dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_FIELD ); + base->colmv_used_flag_ref = !!(dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ); + base->topfield_used_ref = !!(dpb[i].fields &V4L2_H264_TOP_FIELD_REF ); + base->botfield_used_ref = !!(dpb[i].fields &V4L2_H264_BOTTOM_FIELD_REF ); + base->base_addr = refer_addr >>4 ;drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +6
-2- reg =RKVDEC_CUR_POC (dec_params->bottom_field_order_cnt); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_CUR_POC1 ); +set_poc_reg (regs, dpb[i].top_field_order_cnt, i, false); +set_poc_reg (regs, dpb[i].bottom_field_order_cnt, i, true); + } + + regs->h26x.cur_poc = dec_params->top_field_order_cnt; + regs->h26x.cur_poc1 = dec_params->bottom_field_order_cnt;
/* config hw pps address */
offset =offsetof(struct rkvdec_h264_priv_tbl, param_set);drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-2-writel_relaxed (priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_PPS_BASE); + regs->h26x.pps_base = priv_start_addr + offset;
/* config hw rps address */
offset =offsetof(struct rkvdec_h264_priv_tbl, rps);drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +1
-8-writel_relaxed (priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_RPS_BASE); - - reg =RKVDEC_AXI_DDR_RDATA (0 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_AXI_DDR_RDATA ); - - reg =RKVDEC_AXI_DDR_WDATA (0 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_AXI_DDR_WDATA ); + regs->h26x.rps_base = priv_start_addr + offset;
offset =offsetof(struct rkvdec_h264_priv_tbl, err_info);drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +3
-2-writel_relaxed (priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_H264_ERRINFO_BASE); + regs->h26x.errorinfo_base = priv_start_addr + offset; + +rkvdec_memcpy_toio (rkvdec->regs, regs,MIN (sizeof (*regs),4 * rkvdec->variant->num_regs));}
#defineRKVDEC_H264_MAX_DEPTH_IN_BYTES2drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +0
-0@@ -1181,8 +1158,6 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx)
schedule_delayed_work(&rkvdec->watchdog_work, msecs_to_jiffies(2000));drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +0
-2-writel (0 , rkvdec->regs +RKVDEC_REG_STRMD_ERR_EN ); -writel (0 , rkvdec->regs +RKVDEC_REG_H264_ERR_E );
writel(1, rkvdec->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND);writel(1, rkvdec->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND);drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-0@@ -129,6 +129,7 @@ struct rkvdec_hevc_run { struct rkvdec_hevc_ctx { struct rkvdec_aux_buf priv_tbl; struct v4l2_ctrl_hevc_scaling_matrix scaling_matrix_cache; +struct rkvdec_regs regs; };
structscaling_factor{drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-0@@ -548,6 +549,7 @@ static void config_registers(struct rkvdec_ctx *ctx, const struct v4l2_ctrl_hevc_slice_params *sl_params = &run->slices_params[0]; const struct v4l2_hevc_dpb_entry *dpb = decode_params->dpb; struct rkvdec_hevc_ctx *hevc_ctx = ctx->priv; +struct rkvdec_regs *regs = &hevc_ctx->regs; dma_addr_t priv_start_addr = hevc_ctx->priv_tbl.dma; const struct v4l2_pix_format_mplane *dst_fmt; struct vb2_v4l2_buffer *src_buf = run->base.bufs.src;@@ -564,8 +566,9 @@ static void config_registers(struct rkvdec_ctx *ctx, dma_addr_t dst_addr; u32 reg, i;drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +3
-2- reg =RKVDEC_MODE (RKVDEC_MODE_HEVC ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_SYSCTRL ); +memset (regs,0 ,sizeof (*regs)); + + regs->common.reg02.dec_mode =RKVDEC_MODE_HEVC ;
f =&ctx->decoded_fmt;
dst_fmt=&f->fmt.pix_mp;drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +0
-0@@ -580,33 +583,27 @@ static void config_registers(struct rkvdec_ctx *ctx, else if (sps->chroma_format_idc == 2) yuv_virstride = 2 * y_virstride;drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +3
-4- reg =RKVDEC_Y_HOR_VIRSTRIDE (hor_virstride /16 ) | - RKVDEC_UV_HOR_VIRSTRIDE(hor_virstride / 16) | - RKVDEC_SLICE_NUM_LOWBITS(run->num_slices); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_PICPAR ); + regs->common.reg03.slice_num_lowbits = run->num_slices; + regs->common.reg03.uv_hor_virstride = hor_virstride /16 ; + regs->common.reg03.y_hor_virstride = hor_virstride /16 ;
/* config rlc base address */
rlc_addr=vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-1-writel_relaxed (rlc_addr, rkvdec->regs +RKVDEC_REG_STRM_RLC_BASE ); + regs->common.strm_rlc_base = rlc_addr;
rlc_len=vb2_get_plane_payload(&src_buf->vb2_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-2- reg =RKVDEC_STRM_LEN (round_up (rlc_len,16 ) +64 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_STRM_LEN ); + regs->common.stream_len =round_up (rlc_len,16 ) +64 ;
/* config cabac table */
offset =offsetof(struct rkvdec_hevc_priv_tbl, cabac_table);drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-2-writel_relaxed (priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_CABACTBL_PROB_BASE); + regs->common.cabactbl_base = priv_start_addr + offset;
/* config output base address */
dst_addr=vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-4-writel_relaxed (dst_addr, rkvdec->regs +RKVDEC_REG_DECOUT_BASE ); - - reg =RKVDEC_Y_VIRSTRIDE (y_virstride /16 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_Y_VIRSTRIDE ); + regs->common.decout_base = dst_addr;drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +2
-2- reg =RKVDEC_YUV_VIRSTRIDE (yuv_virstride /16 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_YUV_VIRSTRIDE ); + regs->common.reg08.y_virstride = y_virstride /16 ; + regs->common.reg09.yuv_virstride = yuv_virstride /16 ;
/* config ref pic address */
for (i = 0; i < 15; i++) {drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +0
-0@@ -620,33 +617,29 @@ static void config_registers(struct rkvdec_ctx *ctx, }
refer_addr=vb2_dma_contig_plane_dma_addr(vb_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +0
-2-writel_relaxed (refer_addr | reg, - rkvdec->regs + RKVDEC_REG_H264_BASE_REFER(i));drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +9
-4- reg =RKVDEC_POC_REFER (i < decode_params->num_active_dpb_entries ? - dpb[i].pic_order_cnt_val :0 ); -writel_relaxed (reg, - rkvdec->regs + RKVDEC_REG_H264_POC_REFER0(i)); + regs->h26x.ref0_14_base[i].base_addr = refer_addr >>4 ; + regs->h26x.ref0_14_base[i].field_ref = !!(reg &1 ); + regs->h26x.ref0_14_base[i].topfield_used_ref = !!(reg &2 ); + regs->h26x.ref0_14_base[i].botfield_used_ref = !!(reg &4 ); + regs->h26x.ref0_14_base[i].colmv_used_flag_ref = !!(reg &8 ); + + regs->h26x.ref0_14_poc[i] = i < decode_params->num_active_dpb_entries + ? dpb[i].pic_order_cnt_val + : 0;}
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-2- reg =RKVDEC_CUR_POC (sl_params->slice_pic_order_cnt); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_CUR_POC0 ); + regs->h26x.cur_poc = sl_params->slice_pic_order_cnt;
/* config hw pps address */
offset =offsetof(struct rkvdec_hevc_priv_tbl, param_set);drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-2-writel_relaxed (priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_PPS_BASE); + regs->h26x.pps_base = priv_start_addr + offset;
/* config hw rps address */
offset =offsetof(struct rkvdec_hevc_priv_tbl, rps);drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-5-writel_relaxed (priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_RPS_BASE); - - reg =RKVDEC_AXI_DDR_RDATA (0 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_AXI_DDR_RDATA ); + regs->h26x.rps_base = priv_start_addr + offset;drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-2- reg =RKVDEC_AXI_DDR_WDATA (0 ); -writel_relaxed (reg, rkvdec->regs +RKVDEC_REG_AXI_DDR_WDATA ); +rkvdec_memcpy_toio (rkvdec->regs, regs,MIN (sizeof (*regs),4 * rkvdec->variant->num_regs));}
#defineRKVDEC_HEVC_MAX_DEPTH_IN_BYTES2drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +0
-0@@ -784,8 +777,6 @@ static int rkvdec_hevc_run(struct rkvdec_ctx *ctx)
schedule_delayed_work(&rkvdec->watchdog_work, msecs_to_jiffies(2000));drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +0
-2-writel (0 , rkvdec->regs +RKVDEC_REG_STRMD_ERR_EN ); -writel (0 , rkvdec->regs +RKVDEC_REG_H264_ERR_E );
writel(1, rkvdec->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND);writel(1, rkvdec->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND);drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h +0
-0@@ -3,7 +3,12 @@ #ifndef RKVDEC_REGS_H_ #define RKVDEC_REGS_H_drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h +6
-1-/* rkvcodec registers */ +#include <linux/types.h> + +/* +* REG_INTERRUPT is accessed via writel to enable the decoder after +* configuring it and clear interrupt strmd_error_status +*/ #define
RKVDEC_REG_INTERRUPT0x004
#defineRKVDEC_INTERRUPT_DEC_EBIT(0)
#defineRKVDEC_CONFIG_DEC_CLK_GATE_EBIT(1)drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h +0
-0@@ -30,198 +35,384 @@ #define RKVDEC_SOFTRESET_RDY BIT(22) #define RKVDEC_WR_DDR_ALIGN_EN BIT(23)drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h +0
-189-#define RKVDEC_REG_SYSCTRL 0x008 -#define RKVDEC_IN_ENDIAN BIT(0) -#define RKVDEC_IN_SWAP32_E BIT(1) -#define RKVDEC_IN_SWAP64_E BIT(2) -#define RKVDEC_STR_ENDIAN BIT(3) -#define RKVDEC_STR_SWAP32_E BIT(4) -#define RKVDEC_STR_SWAP64_E BIT(5) -#define RKVDEC_OUT_ENDIAN BIT(6) -#define RKVDEC_OUT_SWAP32_E BIT(7) -#define RKVDEC_OUT_CBCR_SWAP BIT(8) -#define RKVDEC_RLC_MODE_DIRECT_WRITE BIT(10) -#define RKVDEC_RLC_MODE BIT(11) -#define RKVDEC_STRM_START_BIT (x) (((x) & 0x7f) << 12) -#define RKVDEC_MODE (x) (((x) & 0x03) << 20) -#define RKVDEC_MODE_HEVC 0 -#define RKVDEC_MODE_H264 1 -#define RKVDEC_MODE_VP9 2 -#define RKVDEC_RPS_MODE BIT(24) -#define RKVDEC_STRM_MODE BIT(25) -#define RKVDEC_H264_STRM_LASTPKT BIT(26) -#define RKVDEC_H264_FIRSTSLICE_FLAG BIT(27) -#define RKVDEC_H264_FRAME_ORSLICE BIT(28) -#define RKVDEC_BUSPR_SLOT_DIS BIT(29) - -#define RKVDEC_REG_PICPAR 0x00C -#define RKVDEC_Y_HOR_VIRSTRIDE (x) ((x) & 0x1ff) -#define RKVDEC_SLICE_NUM_HIGHBIT BIT(11) -#define RKVDEC_UV_HOR_VIRSTRIDE (x) (((x) & 0x1ff) << 12) -#define RKVDEC_SLICE_NUM_LOWBITS (x) (((x) & 0x7ff) << 21) - -#define RKVDEC_REG_STRM_RLC_BASE 0x010 - -#define RKVDEC_REG_STRM_LEN 0x014 -#define RKVDEC_STRM_LEN (x) ((x) & 0x7ffffff) - -#define RKVDEC_REG_CABACTBL_PROB_BASE 0x018 -#define RKVDEC_REG_DECOUT_BASE 0x01C - -#define RKVDEC_REG_Y_VIRSTRIDE 0x020 -#define RKVDEC_Y_VIRSTRIDE (x) ((x) & 0xfffff) - -#define RKVDEC_REG_YUV_VIRSTRIDE 0x024 -#define RKVDEC_YUV_VIRSTRIDE (x) ((x) & 0x1fffff) -#define RKVDEC_REG_H264_BASE_REFER (i) (((i) * 0x04) + 0x028) - -#define RKVDEC_REG_H264_BASE_REFER15 0x0C0 -#define RKVDEC_FIELD_REF BIT(0) -#define RKVDEC_TOPFIELD_USED_REF BIT(1) -#define RKVDEC_BOTFIELD_USED_REF BIT(2) -#define RKVDEC_COLMV_USED_FLAG_REF BIT(3) - -#define RKVDEC_REG_VP9_LAST_FRAME_BASE 0x02c -#define RKVDEC_REG_VP9_GOLDEN_FRAME_BASE 0x030 -#define RKVDEC_REG_VP9_ALTREF_FRAME_BASE 0x034 - -#define RKVDEC_REG_VP9_CPRHEADER_OFFSET 0x028 -#define RKVDEC_VP9_CPRHEADER_OFFSET (x) ((x) & 0xffff) - -#define RKVDEC_REG_VP9_REFERLAST_BASE 0x02C -#define RKVDEC_REG_VP9_REFERGOLDEN_BASE 0x030 -#define RKVDEC_REG_VP9_REFERALFTER_BASE 0x034 - -#define RKVDEC_REG_VP9COUNT_BASE 0x038 -#define RKVDEC_VP9COUNT_UPDATE_EN BIT(0) - -#define RKVDEC_REG_VP9_SEGIDLAST_BASE 0x03C -#define RKVDEC_REG_VP9_SEGIDCUR_BASE 0x040 -#define RKVDEC_REG_VP9_FRAME_SIZE (i) ((i) * 0x04 + 0x044) -#define RKVDEC_VP9_FRAMEWIDTH (x) (((x) & 0xffff) << 0) -#define RKVDEC_VP9_FRAMEHEIGHT (x) (((x) & 0xffff) << 16) - -#define RKVDEC_VP9_SEGID_GRP (i) ((i) * 0x04 + 0x050) -#define RKVDEC_SEGID_ABS_DELTA (x) ((x) & 0x1) -#define RKVDEC_SEGID_FRAME_QP_DELTA_EN (x) (((x) & 0x1) << 1) -#define RKVDEC_SEGID_FRAME_QP_DELTA (x) (((x) & 0x1ff) << 2) -#define RKVDEC_SEGID_FRAME_LOOPFILTER_VALUE_EN (x) (((x) & 0x1) << 11) -#define RKVDEC_SEGID_FRAME_LOOPFILTER_VALUE (x) (((x) & 0x7f) << 12) -#define RKVDEC_SEGID_REFERINFO_EN (x) (((x) & 0x1) << 19) -#define RKVDEC_SEGID_REFERINFO (x) (((x) & 0x03) << 20) -#define RKVDEC_SEGID_FRAME_SKIP_EN (x) (((x) & 0x1) << 22) - -#define RKVDEC_VP9_CPRHEADER_CONFIG 0x070 -#define RKVDEC_VP9_TX_MODE (x) ((x) & 0x07) -#define RKVDEC_VP9_FRAME_REF_MODE (x) (((x) & 0x03) << 3) - -#define RKVDEC_VP9_REF_SCALE (i) ((i) * 0x04 + 0x074) -#define RKVDEC_VP9_REF_HOR_SCALE (x) ((x) & 0xffff) -#define RKVDEC_VP9_REF_VER_SCALE (x) (((x) & 0xffff) << 16) - -#define RKVDEC_VP9_REF_DELTAS_LASTFRAME 0x080 -#define RKVDEC_REF_DELTAS_LASTFRAME (pos, val) (((val) & 0x7f) << ((pos) * 7)) - -#define RKVDEC_VP9_INFO_LASTFRAME 0x084 -#define RKVDEC_MODE_DELTAS_LASTFRAME (pos, val) (((val) & 0x7f) << ((pos) * 7)) -#define RKVDEC_SEG_EN_LASTFRAME BIT(16) -#define RKVDEC_LAST_SHOW_FRAME BIT(17) -#define RKVDEC_LAST_INTRA_ONLY BIT(18) -#define RKVDEC_LAST_WIDHHEIGHT_EQCUR BIT(19) -#define RKVDEC_COLOR_SPACE_LASTKEYFRAME (x) (((x) & 0x07) << 20) - -#define RKVDEC_VP9_INTERCMD_BASE 0x088 - -#define RKVDEC_VP9_INTERCMD_NUM 0x08C -#define RKVDEC_INTERCMD_NUM (x) ((x) & 0xffffff) - -#define RKVDEC_VP9_LASTTILE_SIZE 0x090 -#define RKVDEC_LASTTILE_SIZE (x) ((x) & 0xffffff) - -#define RKVDEC_VP9_HOR_VIRSTRIDE (i) ((i) * 0x04 + 0x094) -#define RKVDEC_HOR_Y_VIRSTRIDE (x) ((x) & 0x1ff) -#define RKVDEC_HOR_UV_VIRSTRIDE (x) (((x) & 0x1ff) << 16) - -#define RKVDEC_REG_H264_POC_REFER0 (i) (((i) * 0x04) + 0x064) -#define RKVDEC_REG_H264_POC_REFER1 (i) (((i) * 0x04) + 0x0C4) -#define RKVDEC_REG_H264_POC_REFER2 (i) (((i) * 0x04) + 0x120) -#define RKVDEC_POC_REFER (x) ((x) & 0xffffffff) - -#define RKVDEC_REG_CUR_POC0 0x0A0 -#define RKVDEC_REG_CUR_POC1 0x128 -#define RKVDEC_CUR_POC (x) ((x) & 0xffffffff) - -#define RKVDEC_REG_RLCWRITE_BASE 0x0A4 -#define RKVDEC_REG_PPS_BASE 0x0A8 -#define RKVDEC_REG_RPS_BASE 0x0AC - -#define RKVDEC_REG_STRMD_ERR_EN 0x0B0 -#define RKVDEC_STRMD_ERR_EN (x) ((x) & 0xffffffff) - -#define RKVDEC_REG_STRMD_ERR_STA 0x0B4 -#define RKVDEC_STRMD_ERR_STA (x) ((x) & 0xfffffff) -#define RKVDEC_COLMV_ERR_REF_PICIDX (x) (((x) & 0x0f) << 28) - -#define RKVDEC_REG_STRMD_ERR_CTU 0x0B8 -#define RKVDEC_STRMD_ERR_CTU (x) ((x) & 0xff) -#define RKVDEC_STRMD_ERR_CTU_YOFFSET (x) (((x) & 0xff) << 8) -#define RKVDEC_STRMFIFO_SPACE2FULL (x) (((x) & 0x7f) << 16) -#define RKVDEC_VP9_ERR_EN_CTU0 BIT(24) - -#define RKVDEC_REG_SAO_CTU_POS 0x0BC -#define RKVDEC_SAOWR_XOFFSET (x) ((x) & 0x1ff) -#define RKVDEC_SAOWR_YOFFSET (x) (((x) & 0x3ff) << 16) - -#define RKVDEC_VP9_LAST_FRAME_YSTRIDE 0x0C0 -#define RKVDEC_VP9_GOLDEN_FRAME_YSTRIDE 0x0C4 -#define RKVDEC_VP9_ALTREF_FRAME_YSTRIDE 0x0C8 -#define RKVDEC_VP9_REF_YSTRIDE (x) (((x) & 0xfffff) << 0) - -#define RKVDEC_VP9_LAST_FRAME_YUVSTRIDE 0x0CC -#define RKVDEC_VP9_REF_YUVSTRIDE (x) (((x) & 0x1fffff) << 0) - -#define RKVDEC_VP9_REF_COLMV_BASE 0x0D0 - -#define RKVDEC_REG_PERFORMANCE_CYCLE 0x100 -#define RKVDEC_PERFORMANCE_CYCLE (x) ((x) & 0xffffffff) - -#define RKVDEC_REG_AXI_DDR_RDATA 0x104 -#define RKVDEC_AXI_DDR_RDATA (x) ((x) & 0xffffffff) - -#define RKVDEC_REG_AXI_DDR_WDATA 0x108 -#define RKVDEC_AXI_DDR_WDATA (x) ((x) & 0xffffffff) - -#define RKVDEC_REG_FPGADEBUG_RESET 0x10C -#define RKVDEC_BUSIFD_RESETN BIT(0) -#define RKVDEC_CABAC_RESETN BIT(1) -#define RKVDEC_DEC_CTRL_RESETN BIT(2) -#define RKVDEC_TRANSD_RESETN BIT(3) -#define RKVDEC_INTRA_RESETN BIT(4) -#define RKVDEC_INTER_RESETN BIT(5) -#define RKVDEC_RECON_RESETN BIT(6) -#define RKVDEC_FILER_RESETN BIT(7) - -#define RKVDEC_REG_PERFORMANCE_SEL 0x110 -#define RKVDEC_PERF_SEL_CNT0 (x) ((x) & 0x3f) -#define RKVDEC_PERF_SEL_CNT1 (x) (((x) & 0x3f) << 8) -#define RKVDEC_PERF_SEL_CNT2 (x) (((x) & 0x3f) << 16) - -#define RKVDEC_REG_PERFORMANCE_CNT (i) ((i) * 0x04 + 0x114) -#define RKVDEC_PERF_CNT (x) ((x) & 0xffffffff) - -#define RKVDEC_REG_H264_ERRINFO_BASE 0x12C - -#define RKVDEC_REG_H264_ERRINFO_NUM 0x130 -#define RKVDEC_SLICEDEC_NUM (x) ((x) & 0x3fff) -#define RKVDEC_STRMD_DECT_ERR_FLAG BIT(15) -#define RKVDEC_ERR_PKT_NUM (x) (((x) & 0x3fff) << 16) - -#define RKVDEC_REG_H264_ERR_E 0x134 -#define RKVDEC_H264_ERR_EN_HIGHBITS (x) ((x) & 0x3fffffff) -#define
RKVDEC_REG_QOS_CTRL0x18C
+/*
+ * Cache configuration is not covered in the range of the register struct
+ */
#defineRKVDEC_REG_PREF_LUMA_CACHE_COMMAND0x410
#defineRKVDEC_REG_PREF_CHR_CACHE_COMMAND0x450drivers/media/platform/rockchip/rkvdec/rkvdec-regs.h +372
-0+/* +* Define the mode values +*/ +#define RKVDEC_MODE_HEVC 0 +#define RKVDEC_MODE_H264 1 +#define RKVDEC_MODE_VP9 2 + +/* rkvcodec registers */ +struct rkvdec_common_regs { +struct rkvdec_id { +u32 minor_ver :8 ; +u32 level :1 ; +u32 dec_support :3 ; +u32 profile :1 ; +u32 reserved0 :1 ; +u32 codec_flag :1 ; +u32 reserved1 :1 ; +u32 prod_num :16 ; + } reg00; + +struct rkvdec_int { +u32 dec_e :1 ; +u32 dec_clkgate_e :1 ; +u32 reserved0 :1 ; +u32 timeout_mode :1 ; +u32 dec_irq_dis :1 ; +u32 dec_timeout_e :1 ; +u32 buf_empty_en :1 ; +u32 stmerror_waitdecfifo_empty :1 ; +u32 dec_irq :1 ; +u32 dec_irq_raw :1 ; +u32 reserved2 :2 ; +u32 dec_rdy_sta :1 ; +u32 dec_bus_sta :1 ; +u32 dec_error_sta :1 ; +u32 dec_timeout_sta :1 ; +u32 dec_empty_sta :1 ; +u32 colmv_ref_error_sta :1 ; +u32 cabu_end_sta :1 ; +u32 h264orvp9_error_mode :1 ; +u32 softrst_en_p :1 ; +u32 force_softreset_valid :1 ; +u32 softreset_rdy :1 ; +u32 reserved1 :9 ; + } reg01; + +struct rkvdec_sysctrl { +u32 in_endian :1 ; +u32 in_swap32_e :1 ; +u32 in_swap64_e :1 ; +u32 str_endian :1 ; +u32 str_swap32_e :1 ; +u32 str_swap64_e :1 ; +u32 out_endian :1 ; +u32 out_swap32_e :1 ; +u32 out_cbcr_swap :1 ; +u32 reserved0 :1 ; +u32 rlc_mode_direct_write :1 ; +u32 rlc_mode :1 ; +u32 strm_start_bit :7 ; +u32 reserved1 :1 ; +u32 dec_mode :2 ; +u32 reserved2 :2 ; +u32 rps_mode :1 ; +u32 stream_mode :1 ; +u32 stream_lastpacket :1 ; +u32 firstslice_flag :1 ; +u32 frame_orslice :1 ; +u32 buspr_slot_disable :1 ; +u32 reserved3 :2 ; + } reg02; + +struct rkvdec_picpar { +u32 y_hor_virstride :9 ; +u32 reserved :2 ; +u32 slice_num_highbit :1 ; +u32 uv_hor_virstride :9 ; +u32 slice_num_lowbits :11 ; + } reg03; + +u32 strm_rlc_base; +u32 stream_len; +u32 cabactbl_base; +u32 decout_base; + +struct rkvdec_y_virstride { +u32 y_virstride :20 ; +u32 reserved0 :12 ; + } reg08; + +struct rkvdec_yuv_virstride { +u32 yuv_virstride :21 ; +u32 reserved0 :11 ; + } reg09; +} __packed; + +struct ref_base { +u32 field_ref :1 ; +u32 topfield_used_ref :1 ; +u32 botfield_used_ref :1 ; +u32 colmv_used_flag_ref :1 ; +u32 base_addr :28 ; +}; + +struct rkvdec_h26x_regs { +struct ref_base ref0_14_base[15 ]; +u32 ref0_14_poc[15 ]; + +u32 cur_poc; +u32 rlcwrite_base; +u32 pps_base; +u32 rps_base; + +u32 strmd_error_e; + +struct { +u32 strmd_error_status :28 ; +u32 colmv_error_ref_picidx :4 ; + } reg45; + +struct { +u32 strmd_error_ctu_xoffset :8 ; +u32 strmd_error_ctu_yoffset :8 ; +u32 streamfifo_space2full :7 ; +u32 reserved0 :1 ; +u32 vp9_error_ctu0_en :1 ; +u32 reserved1 :7 ; + } reg46; + +struct { +u32 saowr_xoffet :9 ; +u32 reserved0 :7 ; +u32 saowr_yoffset :10 ; +u32 reserved1 :6 ; + } reg47; + +struct ref_base ref15_base; + +u32 ref15_29_poc[15 ]; + +u32 performance_cycle; +u32 axi_ddr_rdata; +u32 axi_ddr_wdata; + +struct { +u32 busifd_resetn :1 ; +u32 cabac_resetn :1 ; +u32 dec_ctrl_resetn :1 ; +u32 transd_resetn :1 ; +u32 intra_resetn :1 ; +u32 inter_resetn :1 ; +u32 recon_resetn :1 ; +u32 filer_resetn :1 ; +u32 reserved0 :24 ; + } reg67; + +struct { +u32 perf_cnt0_sel :6 ; +u32 reserved0 :2 ; +u32 perf_cnt1_sel :6 ; +u32 reserved1 :2 ; +u32 perf_cnt2_sel :6 ; +u32 reserved2 :10 ; + } reg68; + +u32 perf_cnt0; +u32 perf_cnt1; +u32 perf_cnt2; +u32 ref30_poc; +u32 ref31_poc; +u32 cur_poc1; +u32 errorinfo_base; + +struct { +u32 slicedec_num :14 ; +u32 reserved0 :1 ; +u32 strmd_detect_error_flag :1 ; +u32 error_packet_num :14 ; +u32 reserved1 :2 ; + } reg76; + +struct { +u32 error_en_highbits :30 ; +u32 reserved :2 ; + } reg77; +} __packed; + +struct rkvdec_vp9_regs { +struct cprheader_offset { +u32 cprheader_offset :16 ; +u32 reserved :16 ; + } reg10; + +u32 refer_bases[3 ]; +u32 count_base; +u32 segidlast_base; +u32 segidcur_base; + +struct frame_sizes { +u32 framewidth :16 ; +u32 frameheight :16 ; + } reg17_19[3 ]; + +struct segid_grp { +u32 segid_abs_delta :1 ; +u32 segid_frame_qp_delta_en :1 ; +u32 segid_frame_qp_delta :9 ; +u32 segid_frame_loopfilter_value_en :1 ; +u32 segid_frame_loopfilter_value :7 ; +u32 segid_referinfo_en :1 ; +u32 segid_referinfo :2 ; +u32 segid_frame_skip_en :1 ; +u32 reserved :9 ; + } reg20_27[8 ]; + +struct cprheader_config { +u32 tx_mode :3 ; +u32 frame_reference_mode :2 ; +u32 reserved :27 ; + } reg28; + +struct ref_scale { +u32 ref_hor_scale :16 ; +u32 ref_ver_scale :16 ; + } reg29_31[3 ]; + +struct ref_deltas_lastframe { +u32 ref_deltas_lastframe0 :7 ; +u32 ref_deltas_lastframe1 :7 ; +u32 ref_deltas_lastframe2 :7 ; +u32 ref_deltas_lastframe3 :7 ; +u32 reserved :4 ; + } reg32; + +struct info_lastframe { +u32 mode_deltas_lastframe0 :7 ; +u32 mode_deltas_lastframe1 :7 ; +u32 reserved0 :2 ; +u32 segmentation_enable_lstframe :1 ; +u32 last_show_frame :1 ; +u32 last_intra_only :1 ; +u32 last_widthheight_eqcur :1 ; +u32 color_space_lastkeyframe :3 ; +u32 reserved1 :9 ; + } reg33; + +u32 intercmd_base; + +struct intercmd_num { +u32 intercmd_num :24 ; +u32 reserved :8 ; + } reg35; + +struct lasttile_size { +u32 lasttile_size :24 ; +u32 reserved :8 ; + } reg36; + +struct hor_virstride { +u32 y_hor_virstride :9 ; +u32 reserved0 :7 ; +u32 uv_hor_virstride :9 ; +u32 reserved1 :7 ; + } reg37_39[3 ]; + +u32 cur_poc; + +struct rlcwrite_base { +u32 reserved :3 ; +u32 rlcwrite_base :29 ; + } reg41; + +struct pps_base { +u32 reserved :4 ; +u32 pps_base :28 ; + } reg42; + +struct rps_base { +u32 reserved :4 ; +u32 rps_base :28 ; + } reg43; + +struct strmd_error_en { +u32 strmd_error_e :28 ; +u32 reserved :4 ; + } reg44; + +u32 vp9_error_info0; + +struct strmd_error_ctu { +u32 strmd_error_ctu_xoffset :8 ; +u32 strmd_error_ctu_yoffset :8 ; +u32 streamfifo_space2full :7 ; +u32 reserved0 :1 ; +u32 error_ctu0_en :1 ; +u32 reserved1 :7 ; + } reg46; + +struct sao_ctu_position { +u32 saowr_xoffet :9 ; +u32 reserved0 :7 ; +u32 saowr_yoffset :10 ; +u32 reserved1 :6 ; + } reg47; + +struct ystride { +u32 virstride :20 ; +u32 reserved :12 ; + } reg48_50[3 ]; + +struct lastref_yuvstride { +u32 lastref_yuv_virstride :21 ; +u32 reserved :11 ; + } reg51; + +u32 refcolmv_base; + +u32 reserved0[11 ]; + +u32 performance_cycle; +u32 axi_ddr_rdata; +u32 axi_ddr_wdata; + +struct fpgadebug_reset { +u32 busifd_resetn :1 ; +u32 cabac_resetn :1 ; +u32 dec_ctrl_resetn :1 ; +u32 transd_resetn :1 ; +u32 intra_resetn :1 ; +u32 inter_resetn :1 ; +u32 recon_resetn :1 ; +u32 filer_resetn :1 ; +u32 reserved :24 ; + } reg67; + +struct performance_sel { +u32 perf_cnt0_sel :6 ; +u32 reserved0 :2 ; +u32 perf_cnt1_sel :6 ; +u32 reserved1 :2 ; +u32 perf_cnt2_sel :6 ; +u32 reserved :10 ; + } reg68; + +u32 perf_cnt0; +u32 perf_cnt1; +u32 perf_cnt2; + +u32 reserved1[3 ]; + +u32 vp9_error_info1; + +struct error_ctu1 { +u32 vp9_error_ctu1_x :6 ; +u32 reserved0 :2 ; +u32 vp9_error_ctu1_y :6 ; +u32 reserved1 :1 ; +u32 vp9_error_ctu1_en :1 ; +u32 reserved2 :16 ; + } reg76; + +u32 reserved2; +} __packed; + +struct rkvdec_regs { +struct rkvdec_common_regs common; +union { +struct rkvdec_h26x_regs h26x; + struct rkvdec_vp9_regs vp9; + }; +} __packed; +#endif /*
RKVDEC_REGS_H_*/drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +1
-0@@ -163,6 +163,7 @@ struct rkvdec_vp9_ctx { struct v4l2_vp9_frame_context frame_context[4]; struct rkvdec_vp9_frame_info cur; struct rkvdec_vp9_frame_info last; +struct rkvdec_regs regs; };
static voidwrite_coeff_plane(const u8 coef[6][6][3], u8 *coeff_plane)drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-0@@ -347,38 +348,6 @@ static void init_probs(struct rkvdec_ctx *ctx, init_inter_probs(ctx, run); }drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-32-struct rkvdec_vp9_ref_reg { -u32 reg_frm_size; -u32 reg_hor_stride; -u32 reg_y_stride; -u32 reg_yuv_stride; -u32 reg_ref_base; -}; - -static struct rkvdec_vp9_ref_reg ref_regs[] = { - { - .reg_frm_size =RKVDEC_REG_VP9_FRAME_SIZE (0 ), - .reg_hor_stride =RKVDEC_VP9_HOR_VIRSTRIDE (0 ), - .reg_y_stride =RKVDEC_VP9_LAST_FRAME_YSTRIDE , - .reg_yuv_stride =RKVDEC_VP9_LAST_FRAME_YUVSTRIDE , - .reg_ref_base =RKVDEC_REG_VP9_LAST_FRAME_BASE , - }, - { - .reg_frm_size =RKVDEC_REG_VP9_FRAME_SIZE (1 ), - .reg_hor_stride =RKVDEC_VP9_HOR_VIRSTRIDE (1 ), - .reg_y_stride =RKVDEC_VP9_GOLDEN_FRAME_YSTRIDE , - .reg_yuv_stride =0 , - .reg_ref_base =RKVDEC_REG_VP9_GOLDEN_FRAME_BASE , - }, - { - .reg_frm_size =RKVDEC_REG_VP9_FRAME_SIZE (2 ), - .reg_hor_stride =RKVDEC_VP9_HOR_VIRSTRIDE (2 ), - .reg_y_stride =RKVDEC_VP9_ALTREF_FRAME_YSTRIDE , - .reg_yuv_stride =0 , - .reg_ref_base =RKVDEC_REG_VP9_ALTREF_FRAME_BASE , - } -}; -static struct
rkvdec_decoded_buffer*
get_ref_buf(structrkvdec_ctx*ctx, structvb2_v4l2_buffer*dst, u64 timestamp) {drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +3
-2@@ -412,18 +381,17 @@ static dma_addr_t get_mv_base_addr(struct rkvdec_decoded_buffer *buf) static void config_ref_registers(struct rkvdec_ctx *ctx, const struct rkvdec_vp9_run *run, struct rkvdec_decoded_buffer *ref_buf, -struct rkvdec_vp9_ref_reg *ref_reg) +int i) { unsigned int aligned_pitch, aligned_height, y_len, yuv_len; -struct rkvdec_dev *rkvdec = ctx->dev; +struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; +struct rkvdec_regs *regs = &vp9_ctx->regs;
aligned_height=round_up(ref_buf->vp9.height, 64);drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-3-writel_relaxed (RKVDEC_VP9_FRAMEWIDTH (ref_buf->vp9.width) | - RKVDEC_VP9_FRAMEHEIGHT(ref_buf->vp9.height), - rkvdec->regs + ref_reg->reg_frm_size); + regs->vp9.reg17_19[i].frameheight = ref_buf->vp9.height; + regs->vp9.reg17_19[i].framewidth = ref_buf->vp9.width;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +1
-2-writel_relaxed (vb2_dma_contig_plane_dma_addr (&ref_buf->base.vb.vb2_buf,0 ), - rkvdec->regs + ref_reg->reg_ref_base); + regs->vp9.refer_bases[i] =vb2_dma_contig_plane_dma_addr (&ref_buf->base.vb.vb2_buf,0 );
if (&ref_buf->base.vb==run->base.bufs.dst) return;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-0@@ -432,59 +400,50 @@ static void config_ref_registers(struct rkvdec_ctx *ctx, y_len = aligned_height * aligned_pitch; yuv_len = (y_len * 3) / 2;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +3
-8-writel_relaxed (RKVDEC_HOR_Y_VIRSTRIDE (aligned_pitch /16 ) | - RKVDEC_HOR_UV_VIRSTRIDE(aligned_pitch / 16), - rkvdec->regs + ref_reg->reg_hor_stride); -writel_relaxed (RKVDEC_VP9_REF_YSTRIDE (y_len /16 ), - rkvdec->regs + ref_reg->reg_y_stride); - -if (!ref_reg->reg_yuv_stride) -return ; + regs->vp9.reg37_39[i].y_hor_virstride = aligned_pitch /16 ; + regs->vp9.reg37_39[i].uv_hor_virstride = aligned_pitch /16 ; + regs->vp9.reg48_50[i].virstride = y_len /16 ;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-2-writel_relaxed (RKVDEC_VP9_REF_YUVSTRIDE (yuv_len /16 ), - rkvdec->regs + ref_reg->reg_yuv_stride); +if (!i) + regs->vp9.reg51.lastref_yuv_virstride = yuv_len /16 ;}
static voidconfig_seg_registers(struct rkvdec_ctx *ctx, unsigned int segid){
structrkvdec_vp9_ctx*vp9_ctx=ctx->priv;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +1
-0+struct rkvdec_regs *regs = &vp9_ctx->regs;const struct
v4l2_vp9_segmentation*seg;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-1-struct rkvdec_dev *rkvdec = ctx->dev;s16
feature_val;
intfeature_id;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-1-u32 val =0 ;
seg =vp9_ctx->last.valid?&vp9_ctx->last.seg:&vp9_ctx->cur.seg;feature_id=V4L2_VP9_SEG_LVL_ALT_Q;
if (v4l2_vp9_seg_feat_enabled(seg->feature_enabled, feature_id, segid)) {feature_val= seg->feature_data[segid][feature_id];drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-2- val |=RKVDEC_SEGID_FRAME_QP_DELTA_EN (1 ) | - RKVDEC_SEGID_FRAME_QP_DELTA(feature_val); + regs->vp9.reg20_27[segid].segid_frame_qp_delta_en =1 ; + regs->vp9.reg20_27[segid].segid_frame_qp_delta = feature_val;}
feature_id=V4L2_VP9_SEG_LVL_ALT_L;
if (v4l2_vp9_seg_feat_enabled(seg->feature_enabled, feature_id, segid)) {feature_val= seg->feature_data[segid][feature_id];drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-2- val |=RKVDEC_SEGID_FRAME_LOOPFILTER_VALUE_EN (1 ) | - RKVDEC_SEGID_FRAME_LOOPFILTER_VALUE(feature_val); + regs->vp9.reg20_27[segid].segid_frame_loopfilter_value_en =1 ; + regs->vp9.reg20_27[segid].segid_frame_loopfilter_value = feature_val;}
feature_id=V4L2_VP9_SEG_LVL_REF_FRAME;
if (v4l2_vp9_seg_feat_enabled(seg->feature_enabled, feature_id, segid)) {feature_val= seg->feature_data[segid][feature_id];drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-2- val |=RKVDEC_SEGID_REFERINFO_EN (1 ) | - RKVDEC_SEGID_REFERINFO(feature_val); + regs->vp9.reg20_27[segid].segid_referinfo_en =1 ; + regs->vp9.reg20_27[segid].segid_referinfo = feature_val;}
feature_id=V4L2_VP9_SEG_LVL_SKIP;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-6-if (v4l2_vp9_seg_feat_enabled (seg->feature_enabled, feature_id, segid)) - val |=RKVDEC_SEGID_FRAME_SKIP_EN (1 ); - -if (!segid && - (seg->flags & V4L2_VP9_SEGMENTATION_FLAG_ABS_OR_DELTA_UPDATE)) - val |=RKVDEC_SEGID_ABS_DELTA (1 ); + regs->vp9.reg20_27[segid].segid_frame_skip_en = +v4l2_vp9_seg_feat_enabled (seg->feature_enabled, feature_id, segid);drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-1-writel_relaxed (val, rkvdec->regs +RKVDEC_VP9_SEGID_GRP (segid)); + regs->vp9.reg20_27[segid].segid_abs_delta = !segid && + (seg->flags &V4L2_VP9_SEGMENTATION_FLAG_ABS_OR_DELTA_UPDATE );}
static void update_dec_buf_info(structrkvdec_decoded_buffer*buf,drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-1@@ -521,7 +480,8 @@ static void config_registers(struct rkvdec_ctx *ctx, struct rkvdec_decoded_buffer *ref_bufs[3]; struct rkvdec_decoded_buffer *dst, *last, *mv_ref; struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; -u32 val, last_frame_info =0 ; +struct rkvdec_regs *regs = &vp9_ctx->regs; +u32 val; const struct v4l2_vp9_segmentation *seg; struct rkvdec_dev *rkvdec = ctx->dev; dma_addr_t addr;@@ -547,8 +507,7 @@ static void config_registers(struct rkvdec_ctx *ctx,(
V4L2_VP9_FRAME_FLAG_KEY_FRAME|V4L2_VP9_FRAME_FLAG_INTRA_ONLY));drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +1
-2-writel_relaxed (RKVDEC_MODE (RKVDEC_MODE_VP9 ), - rkvdec->regs + RKVDEC_REG_SYSCTRL); + regs->common.reg02.dec_mode =RKVDEC_MODE_VP9 ;
bit_depth=dec_params->bit_depth;
aligned_height=round_up(ctx->decoded_fmt.fmt.pix_mp.height, 64);drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-0@@ -560,17 +519,14 @@ static void config_registers(struct rkvdec_ctx *ctx, uv_len = y_len / 2; yuv_len = y_len + uv_len;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +4
-7-writel_relaxed (RKVDEC_Y_HOR_VIRSTRIDE (aligned_pitch /16 ) | - RKVDEC_UV_HOR_VIRSTRIDE(aligned_pitch / 16), - rkvdec->regs + RKVDEC_REG_PICPAR); -writel_relaxed (RKVDEC_Y_VIRSTRIDE (y_len /16 ), - rkvdec->regs + RKVDEC_REG_Y_VIRSTRIDE); -writel_relaxed (RKVDEC_YUV_VIRSTRIDE (yuv_len /16 ), - rkvdec->regs + RKVDEC_REG_YUV_VIRSTRIDE); + regs->common.reg03.y_hor_virstride = aligned_pitch /16 ; + regs->common.reg03.uv_hor_virstride = aligned_pitch /16 ; + regs->common.reg08.y_virstride = y_len /16 ; + regs->common.reg09.yuv_virstride = yuv_len /16 ;
stream_len=vb2_get_plane_payload(&run->base.bufs.src->vb2_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-2-writel_relaxed (RKVDEC_STRM_LEN (stream_len), - rkvdec->regs + RKVDEC_REG_STRM_LEN); + + regs->common.stream_len = stream_len;
/*
* Reset count buffer, because decoder only output intra related syntaxdrivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-0@@ -588,14 +544,13 @@ static void config_registers(struct rkvdec_ctx *ctx, vp9_ctx->cur.segmapid++;
for (i = 0; i <ARRAY_SIZE(ref_bufs); i++)drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +1
-1-config_ref_registers (ctx, run, ref_bufs[i], &ref_regs[i]); +config_ref_registers (ctx, run, ref_bufs[i], i);
for (i = 0; i < 8; i++)
config_seg_registers(ctx, i);drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +2
-3-writel_relaxed (RKVDEC_VP9_TX_MODE (vp9_ctx->cur.tx_mode) | - RKVDEC_VP9_FRAME_REF_MODE(dec_params->reference_mode), - rkvdec->regs + RKVDEC_VP9_CPRHEADER_CONFIG); + regs->vp9.reg28.tx_mode = vp9_ctx->cur.tx_mode; + regs->vp9.reg28.frame_reference_mode = dec_params->reference_mode;
if (!intra_only) {
const structv4l2_vp9_loop_filter*lf;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +14
-1@@ -609,43 +564,56 @@ static void config_registers(struct rkvdec_ctx *ctx, val = 0; for (i = 0; i < ARRAY_SIZE(lf->ref_deltas); i++) { delta = lf->ref_deltas[i]; - val |=RKVDEC_REF_DELTAS_LASTFRAME (i, delta); +switch (i) { +case 0 : + regs->vp9.reg32.ref_deltas_lastframe0 = delta; +break ; +case 1 : + regs->vp9.reg32.ref_deltas_lastframe1 = delta; +break ; +case 2 : + regs->vp9.reg32.ref_deltas_lastframe2 = delta; +break ; +case 3 : + regs->vp9.reg32.ref_deltas_lastframe3 = delta; +break ; + } }drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-3-writel_relaxed (val, - rkvdec->regs + RKVDEC_VP9_REF_DELTAS_LASTFRAME); -for (i = 0; i <
ARRAY_SIZE(lf->mode_deltas); i++) { delta = lf->mode_deltas[i];drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +8
-2- last_frame_info |=RKVDEC_MODE_DELTAS_LASTFRAME (i, - delta); +switch (i) { +case 0 : + regs->vp9.reg33.mode_deltas_lastframe0 = delta; +break ; +case 1 : + regs->vp9.reg33.mode_deltas_lastframe1 = delta; +break ; + }}
}drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +3
-3-if (vp9_ctx->last.valid && !intra_only && - vp9_ctx->last.seg.flags & V4L2_VP9_SEGMENTATION_FLAG_ENABLED) - last_frame_info |=RKVDEC_SEG_EN_LASTFRAME ; + regs->vp9.reg33.segmentation_enable_lstframe = + vp9_ctx->last.valid && !intra_only && + vp9_ctx->last.seg.flags &V4L2_VP9_SEGMENTATION_FLAG_ENABLED ;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +3
-3-if (vp9_ctx->last.valid && - vp9_ctx->last.flags & V4L2_VP9_FRAME_FLAG_SHOW_FRAME) - last_frame_info |=RKVDEC_LAST_SHOW_FRAME ; + regs->vp9.reg33.last_show_frame = + vp9_ctx->last.valid && + vp9_ctx->last.flags &V4L2_VP9_FRAME_FLAG_SHOW_FRAME ;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +4
-4-if (vp9_ctx->last.valid && - vp9_ctx->last.flags & - (V4L2_VP9_FRAME_FLAG_KEY_FRAME | V4L2_VP9_FRAME_FLAG_INTRA_ONLY)) - last_frame_info |=RKVDEC_LAST_INTRA_ONLY ; + regs->vp9.reg33.last_intra_only = + vp9_ctx->last.valid && + vp9_ctx->last.flags & + (V4L2_VP9_FRAME_FLAG_KEY_FRAME |V4L2_VP9_FRAME_FLAG_INTRA_ONLY );drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +4
-4-if (vp9_ctx->last.valid && - last->vp9.width == dst->vp9.width && - last->vp9.height == dst->vp9.height) - last_frame_info |=RKVDEC_LAST_WIDHHEIGHT_EQCUR ; + regs->vp9.reg33.last_widthheight_eqcur = + vp9_ctx->last.valid && + last->vp9.width == dst->vp9.width && + last->vp9.height == dst->vp9.height;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +3
-6-writel_relaxed (last_frame_info, - rkvdec->regs + RKVDEC_VP9_INFO_LASTFRAME); - -writel_relaxed (stream_len - dec_params->compressed_header_size - - dec_params->uncompressed_header_size, - rkvdec->regs + RKVDEC_VP9_LASTTILE_SIZE); + regs->vp9.reg36.lasttile_size = + stream_len - dec_params->compressed_header_size - + dec_params->uncompressed_header_size;
for (i = 0; !intra_only && i <ARRAY_SIZE(ref_bufs); i++) { unsigned int refw = ref_bufs[i]->vp9.width;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-0@@ -654,29 +622,28 @@ static void config_registers(struct rkvdec_ctx *ctx,
hscale = (refw << 14) /dst->vp9.width;
vscale = (refh << 14) /dst->vp9.height;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +3
-3-writel_relaxed (RKVDEC_VP9_REF_HOR_SCALE (hscale) | - RKVDEC_VP9_REF_VER_SCALE(vscale), - rkvdec->regs + RKVDEC_VP9_REF_SCALE(i)); + + regs->vp9.reg29_31[i].ref_hor_scale = hscale; + regs->vp9.reg29_31[i].ref_ver_scale = vscale;}
addr =vb2_dma_contig_plane_dma_addr(&dst->base.vb.vb2_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +1
-1-writel_relaxed (addr, rkvdec->regs +RKVDEC_REG_DECOUT_BASE ); + regs->common.decout_base = addr;addr =
vb2_dma_contig_plane_dma_addr(&run->base.bufs.src->vb2_buf, 0);drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +14
-15-writel_relaxed (addr, rkvdec->regs +RKVDEC_REG_STRM_RLC_BASE ); -writel_relaxed (vp9_ctx->priv_tbl.dma + - offsetof(struct rkvdec_vp9_priv_tbl, probs), - rkvdec->regs + RKVDEC_REG_CABACTBL_PROB_BASE); -writel_relaxed (vp9_ctx->count_tbl.dma, - rkvdec->regs + RKVDEC_REG_VP9COUNT_BASE); - -writel_relaxed (vp9_ctx->priv_tbl.dma + - offsetof(struct rkvdec_vp9_priv_tbl, segmap) + - (RKVDEC_VP9_MAX_SEGMAP_SIZE * vp9_ctx->cur.segmapid), - rkvdec->regs + RKVDEC_REG_VP9_SEGIDCUR_BASE); -writel_relaxed (vp9_ctx->priv_tbl.dma + - offsetof(struct rkvdec_vp9_priv_tbl, segmap) + - (RKVDEC_VP9_MAX_SEGMAP_SIZE * (!vp9_ctx->cur.segmapid)), - rkvdec->regs + RKVDEC_REG_VP9_SEGIDLAST_BASE); + regs->common.strm_rlc_base = addr; + + regs->common.cabactbl_base = vp9_ctx->priv_tbl.dma + + offsetof(struct rkvdec_vp9_priv_tbl , probs); + + regs->vp9.count_base = vp9_ctx->count_tbl.dma; + + regs->vp9.segidlast_base = vp9_ctx->priv_tbl.dma + + offsetof(struct rkvdec_vp9_priv_tbl , segmap) + + (RKVDEC_VP9_MAX_SEGMAP_SIZE * (!vp9_ctx->cur.segmapid)); + + regs->vp9.segidcur_base = vp9_ctx->priv_tbl.dma + + offsetof(struct rkvdec_vp9_priv_tbl , segmap) + + (RKVDEC_VP9_MAX_SEGMAP_SIZE * vp9_ctx->cur.segmapid);
if (!intra_only &&
!(dec_params->flags &V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT) &&drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-0@@ -685,12 +652,14 @@ static void config_registers(struct rkvdec_ctx *ctx,else
mv_ref= dst;drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +1
-2-writel_relaxed (get_mv_base_addr (mv_ref), - rkvdec->regs + RKVDEC_VP9_REF_COLMV_BASE); + regs->vp9.refcolmv_base =get_mv_base_addr (mv_ref);drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +6
-3-writel_relaxed (ctx->decoded_fmt.fmt.pix_mp.width | - (ctx->decoded_fmt.fmt.pix_mp.height << 16), - rkvdec->regs + RKVDEC_REG_PERFORMANCE_CYCLE); + regs->vp9.performance_cycle = ctx->decoded_fmt.fmt.pix_mp.width | + (ctx->decoded_fmt.fmt.pix_mp.height << 16); + + regs->vp9.reg44.strmd_error_e =0xe ; + +rkvdec_memcpy_toio (rkvdec->regs, regs,MIN (sizeof (*regs), rkvdec->variant->num_regs));}
static int validate_dec_params(structrkvdec_ctx*ctx,drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-0@@ -823,8 +792,6 @@ static int rkvdec_vp9_run(struct rkvdec_ctx *ctx) writel(1, rkvdec->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND); writel(1, rkvdec->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND);drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c +0
-2-writel (0xe , rkvdec->regs +RKVDEC_REG_STRMD_ERR_EN ); -if (
rkvdec->variant->quirks&RKVDEC_QUIRK_DISABLE_QOS)rkvdec_quirks_disable_qos(ctx);drivers/media/platform/rockchip/rkvdec/rkvdec.c +0
-0@@ -914,6 +914,15 @@ void rkvdec_quirks_disable_qos(struct rkvdec_ctx *ctx) writel(reg, rkvdec->regs + RKVDEC_REG_QOS_CTRL); }drivers/media/platform/rockchip/rkvdec/rkvdec.c +9
-0+void rkvdec_memcpy_toio (void __iomem *dst,void *src,size_t len) +{ +#ifdef CONFIG_ARM64 +__iowrite32_copy (dst, src, len /4 ); +#else +memcpy_toio (dst, src, len); +#endif +} +static void
rkvdec_device_run(void *priv)
{
structrkvdec_ctx*ctx = priv;drivers/media/platform/rockchip/rkvdec/rkvdec.c +0
-1@@ -1227,7 +1236,6 @@ static void rkvdec_watchdog_func(struct work_struct *work) if (ctx) { dev_err(rkvdec->dev, "Frame processing timed out!\n"); writel(RKVDEC_IRQ_DIS, rkvdec->regs + RKVDEC_REG_INTERRUPT); -writel (0 , rkvdec->regs +RKVDEC_REG_SYSCTRL ); rkvdec_job_finish(ctx, VB2_BUF_STATE_ERROR); } }drivers/media/platform/rockchip/rkvdec/rkvdec.h +0
-0@@ -151,6 +151,7 @@ struct rkvdec_aux_buf {
voidrkvdec_run_preamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run); voidrkvdec_run_postamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run); +voidrkvdec_memcpy_toio(void __iomem *dst, void *src, size_t len);
voidrkvdec_quirks_disable_qos(struct rkvdec_ctx *ctx);
Detlev Casanova
maintainerPATCH v3 4/15 media: rkvdec: Move cabac tables to their own source file
In reply to Detlev CasanovaThis is in preparation to add support for new variants that will use the same tables.
---
.../media/platform/rockchip/rkvdec/Makefile | 7 +-
.../{rkvdec-hevc-data.c => rkvdec-cabac.c} | 506 +++++++++++++++++-
.../platform/rockchip/rkvdec/rkvdec-h264.c | 501 +----------------
.../platform/rockchip/rkvdec/rkvdec-hevc.c | 6 +-
4 files changed, 514 insertions(+), 506 deletions(-)
rename drivers/media/platform/rockchip/rkvdec/{rkvdec-hevc-data.c => rkvdec-cabac.c} (86%)drivers/media/platform/rockchip/rkvdec/Makefile +6 -1
@@ -1,3 +1,8 @@ obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rockchip-vdec.o -rockchip-vdec-y += rkvdec.o rkvdec-h264.o rkvdec-hevc.o rkvdec-vp9.o +rockchip-vdec-y += \ + rkvdec.o \ + rkvdec-cabac.o \ + rkvdec-h264.o \ + rkvdec-hevc.o \ + rkvdec-vp9.o
drivers/media/platform/rockchip/rkvdec/rkvdec-cabac.c renamed from drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-data.c +502 -4
521 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +2 -499
513 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +4 -2
@@ -16,7 +16,6 @@#include "rkvdec.h" #include "rkvdec-regs.h" -#include "rkvdec-hevc-data.c" /* Size in u8/u32 units. */ #define RKV_SCALING_LIST_SIZE 1360
@@ -25,6 +24,9 @@#define RKV_RPS_SIZE (32 / 4)#define RKV_RPS_LEN 600 +#define RKV_HEVC_CABAC_TABLE_SIZE 27456 +extern const u8 rkvdec_hevc_cabac_table[RKV_HEVC_CABAC_TABLE_SIZE ]; +struct rkvdec_sps_pps_packet {u32 info[RKV_PPS_SIZE ]; };
@@ -110,7 +112,7 @@ struct rkvdec_ps_field {/* Data structure describing auxiliary buffer format. */ struct rkvdec_hevc_priv_tbl { -u8 cabac_table[RKV_CABAC_TABLE_SIZE ]; +u8 cabac_table[RKV_HEVC_CABAC_TABLE_SIZE ];u8 scaling_list[RKV_SCALING_LIST_SIZE ];struct rkvdec_sps_pps_packet param_set[RKV_PPS_LEN ];struct rkvdec_rps_packet rps[RKV_RPS_LEN ];
Signature · 1 line
2.51.1.dirty
Re: [PATCH v3 04/15] media: rkvdec: Move cabac tables to their own source file
Le mercredi 22 octobre 2025 à 12:22 -0400, Detlev Casanova a écrit :
Quoted 5 lines
This is in preparation to add support for new variants that will use the same tables.
Signed-off-by Detlev Casanova <[email protected]>
Quoted 1,101 lines
---
.../media/platform/rockchip/rkvdec/Makefile | 7 +-.../{rkvdec-hevc-data.c => rkvdec-cabac.c} | 506 +++++++++++++++++- .../platform/rockchip/rkvdec/rkvdec-h264.c | 501 +---------------- .../platform/rockchip/rkvdec/rkvdec-hevc.c | 6 +- 4 files changed, 514 insertions(+), 506 deletions(-)rename
drivers/media/platform/rockchip/rkvdec/{rkvdec-hevc-data.c=>rkvdec-cabac.c} (86%)drivers/media/platform/rockchip/rkvdec/Makefile +0
-0@@ -1,3 +1,8 @@obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rockchip-vdec.o
drivers/media/platform/rockchip/rkvdec/Makefile +6
-1-rockchip-vdec-y += rkvdec.o rkvdec-h264.o rkvdec-hevc.o rkvdec-vp9.o +rockchip-vdec-y += \ + rkvdec.o \ + rkvdec-cabac.o \ + rkvdec-h264.o \ + rkvdec-hevc.o \ + rkvdec-vp9.odrivers/media/platform/rockchip/rkvdec/rkvdec-cabac.c renamed from drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-data.c +3
-1@@ -1,19 +1,517 @@ // SPDX-License-Identifier: GPL-2.0 /* -* Rockchip Video Decoder driver +* Rockchip Video Decoder CABAC tables * * Copyright (C) 2023 Collabora, Ltd. * Sebastian Fricke <[email protected]> +* Copyright (C) 2019 Collabora, Ltd. +* Boris Brezillon <[email protected]> */
#include <linux/types.h>drivers/media/platform/rockchip/rkvdec/rkvdec-cabac.c renamed from drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-data.c +6
-1-#define RKV_CABAC_TABLE_SIZE 27456 +#define CABAC_ENTRY (ctxidx, idc0_m, idc0_n, idc1_m, idc1_n, \ + idc2_m, idc2_n, intra_m, intra_n) \ + [0][(ctxidx)] = {idc0_m, idc0_n}, \ + [1][(ctxidx)] = {idc1_m, idc1_n}, \ + [2][(ctxidx)] = {idc2_m, idc2_n}, \ + [3][(ctxidx)] = {intra_m, intra_n}
/*
- * This file is #include fromrkvdec-hevc.cand not compiled.
+ * Constant CABAC table.
+ * Built from the tables described in section '9.3.1.1 Initialisation process
+ * for context variables' of the H264 spec.
*/drivers/media/platform/rockchip/rkvdec/rkvdec-cabac.c renamed from drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-data.c +490
-1-static const u8 rkvdec_hevc_cabac_table[RKV_CABAC_TABLE_SIZE ] = { +const s8 rkvdec_h264_cabac_table[4 ][464 ][2 ] = { +/* Table 9-12 – Values of variables m and n for ctxIdx from 0 to 10 */ +CABAC_ENTRY (0 ,20 ,-15 ,20 ,-15 ,20 ,-15 ,20 ,-15 ), +CABAC_ENTRY (1 ,2 ,54 ,2 ,54 ,2 ,54 ,2 ,54 ), +CABAC_ENTRY (2 ,3 ,74 ,3 ,74 ,3 ,74 ,3 ,74 ), +CABAC_ENTRY (3 ,20 ,-15 ,20 ,-15 ,20 ,-15 ,20 ,-15 ), +CABAC_ENTRY (4 ,2 ,54 ,2 ,54 ,2 ,54 ,2 ,54 ), +CABAC_ENTRY (5 ,3 ,74 ,3 ,74 ,3 ,74 ,3 ,74 ), +CABAC_ENTRY (6 ,-28 ,127 ,-28 ,127 ,-28 ,127 ,-28 ,127 ), +CABAC_ENTRY (7 ,-23 ,104 ,-23 ,104 ,-23 ,104 ,-23 ,104 ), +CABAC_ENTRY (8 ,-6 ,53 ,-6 ,53 ,-6 ,53 ,-6 ,53 ), +CABAC_ENTRY (9 ,-1 ,54 ,-1 ,54 ,-1 ,54 ,-1 ,54 ), +CABAC_ENTRY (10 ,7 ,51 ,7 ,51 ,7 ,51 ,7 ,51 ), + +/* Table 9-13 – Values of variables m and n for ctxIdx from 11 to 23 */ +CABAC_EN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TRY (51 ,4 ,69 ,-3 ,81 ,6 ,75 ,0 ,0 ), +CABAC_ENTRY (52 ,-3 ,81 ,-7 ,86 ,-3 ,90 ,0 ,0 ), +CABAC_ENTRY (53 ,0 ,88 ,-5 ,95 ,-1 ,101 ,0 ,0 ), + +/* Table 9-16 – Values of variables m and n for ctxIdx from 54 to 59 */ +CABAC_ENTRY (54 ,-7 ,67 ,-1 ,66 ,3 ,55 ,0 ,0 ), +CABAC_ENTRY (55 ,-5 ,74 ,-1 ,77 ,-4 ,79 ,0 ,0 ), +CABAC_ENTRY (56 ,-4 ,74 ,1 ,70 ,-2 ,75 ,0 ,0 ), +CABAC_ENTRY (57 ,-5 ,80 ,-2 ,86 ,-12 ,97 ,0 ,0 ), +CABAC_ENTRY (58 ,-7 ,72 ,-5 ,72 ,-7 ,50 ,0 ,0 ), +CABAC_ENTRY (59 ,1 ,58 ,0 ,61 ,1 ,60 ,0 ,0 ), + +/* Table 9-17 – Values of variables m and n for ctxIdx from 60 to 69 */ +CABAC_ENTRY (60 ,0 ,41 ,0 ,41 ,0 ,41 ,0 ,41 ), +CABAC_ENTRY (61 ,0 ,63 ,0 ,63 ,0 ,63 ,0 ,63 ), +CABAC_ENTRY (62 ,0 ,63 ,0 ,63 ,0 ,63 ,0 ,63 ), +CABAC_ENTRY (63 ,0 ,63 ,0 ,63 ,0 ,63 ,0 ,63 ), +CABAC_ENTRY (64 ,-9 ,83 ,-9 ,83 ,-9 ,83 ,-9 ,83 ), +CABAC_ENTRY (65 ,4 ,86 ,4 ,86 ,4 ,86 ,4 ,86 ), +CABAC_ENTRY (66 ,0 ,97 ,0 ,97 ,0 ,97 ,0 ,97 ), +CABAC_ENTRY (67 ,-7 ,72 ,-7 ,72 ,-7 ,72 ,-7 ,72 ), +CABAC_ENTRY (68 ,13 ,41 ,13 ,41 ,13 ,41 ,13 ,41 ), +CABAC_ENTRY (69 ,3 ,62 ,3 ,62 ,3 ,62 ,3 ,62 ), + +/* Table 9-18 – Values of variables m and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5 ,59 ,2 ,72 ,19 ,31 ,27 ,3 ), +CABAC_ENTRY (212 ,9 ,67 ,8 ,77 ,27 ,44 ,26 ,22 ), +CABAC_ENTRY (213 ,16 ,30 ,14 ,35 ,19 ,16 ,37 ,-16 ), +CABAC_ENTRY (214 ,18 ,32 ,18 ,31 ,15 ,36 ,35 ,-4 ), +CABAC_ENTRY (215 ,18 ,35 ,17 ,35 ,15 ,36 ,38 ,-8 ), +CABAC_ENTRY (216 ,22 ,29 ,21 ,30 ,21 ,28 ,38 ,-3 ), +CABAC_ENTRY (217 ,24 ,31 ,17 ,45 ,25 ,21 ,37 ,3 ), +CABAC_ENTRY (218 ,23 ,38 ,20 ,42 ,30 ,20 ,38 ,5 ), +CABAC_ENTRY (219 ,18 ,43 ,18 ,45 ,31 ,12 ,42 ,0 ), +CABAC_ENTRY (220 ,20 ,41 ,27 ,26 ,27 ,16 ,35 ,16 ), +CABAC_ENTRY (221 ,11 ,63 ,16 ,54 ,24 ,42 ,39 ,22 ), +CABAC_ENTRY (222 ,9 ,59 ,7 ,66 ,0 ,93 ,14 ,48 ), +CABAC_ENTRY (223 ,9 ,64 ,16 ,56 ,14 ,56 ,27 ,37 ), +CABAC_ENTRY (224 ,-1 ,94 ,11 ,73 ,15 ,57 ,21 ,60 ), +CABAC_ENTRY (225 ,-2 ,89 ,10 ,67 ,26 ,38 ,12 ,68 ), +CABAC_ENTRY (226 ,-9 ,108 ,-10 ,116 ,-24 ,127 ,2 ,97 ), + +/* Table 9-21 – Values of variables m and n for ctxIdx from 227 to 275 */ +CABAC_ENTRY (227 ,-6 ,76 ,-23 ,112 ,-24 ,115 ,-3 ,71 ), +CABAC_ENTRY (228 ,-2 ,44 ,-15 ,71 ,-22 ,82 ,-6 ,42 ), +CABAC_ENTRY (229 ,0 ,45 ,-7 ,61 ,-9 ,62 ,-5 ,50 ), +CABAC_ENTRY (230 ,0 ,52 ,0 ,53 ,0 ,53 ,-3 ,54 ), +CABAC_ENTRY (231 ,-3 ,64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,3 ,37 ,-16 ,73 ,-13 ,71 ), +CABAC_ENTRY (272 ,0 ,58 ,-1 ,61 ,-10 ,76 ,-10 ,79 ), +CABAC_ENTRY (273 ,-3 ,70 ,-5 ,73 ,-13 ,86 ,-12 ,86 ), +CABAC_ENTRY (274 ,-6 ,79 ,-1 ,70 ,-9 ,83 ,-13 ,90 ), +CABAC_ENTRY (275 ,-8 ,85 ,-4 ,78 ,-10 ,87 ,-14 ,97 ), + +/* Table 9-22 – Values of variables m and n for ctxIdx from 277 to 337 */ +CABAC_ENTRY (277 ,-13 ,106 ,-21 ,126 ,-22 ,127 ,-6 ,93 ), +CABAC_ENTRY (278 ,-16 ,106 ,-23 ,124 ,-25 ,127 ,-6 ,84 ), +CABAC_ENTRY (279 ,-10 ,87 ,-20 ,110 ,-25 ,120 ,-8 ,79 ), +CABAC_ENTRY (280 ,-21 ,114 ,-26 ,126 ,-27 ,127 ,0 ,66 ), +CABAC_ENTRY (281 ,-18 ,110 ,-25 ,124 ,-19 ,114 ,-1 ,71 ), +CABAC_ENTRY (282 ,-14 ,98 ,-17 ,105 ,-23 ,117 ,0 ,62 ), +CABAC_ENTRY (283 ,-22 ,110 ,-27 ,121 ,-25 ,118 ,-2 ,60 ), +CABAC_ENTRY (284 ,-21 ,106 ,-27 ,117 ,-26 ,117 ,-2 ,59 ), +CABAC_ENTRY (285 ,-18 ,103 ,-17 ,102 ,-24 ,113 ,-5 ,75 ), +CABAC_ENTRY (286 ,-21 ,107 ,-26 ,117 ,-28 ,118 ,-3 ,62 ), +CABAC_ENTRY (287 ,-23 ,108 ,-27 ,116 ,-31 ,120 ,-4 ,58 ), +CABAC_ENTRY (288 ,-26 ,112 ,-33 ,122 ,-37 ,124 ,-9 ,66 ), +CABAC_ENTRY (289 ,-10 ,96 ,-10 ,95 ,-10 ,94 ,-1 ,79 ), +CABAC_ENTRY (290 ,-12 ,95 ,-14 ,100 ,-15 ,102 ,0 ,71 ), +CABAC_ENTRY (291 ,-5 ,91 ,-8 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4 ,62 ), +CABAC_ENTRY (333 ,7 ,44 ,0 ,59 ,-6 ,76 ,-1 ,68 ), +CABAC_ENTRY (334 ,7 ,38 ,3 ,50 ,-11 ,82 ,-13 ,75 ), +CABAC_ENTRY (335 ,13 ,50 ,19 ,40 ,-2 ,77 ,11 ,55 ), +CABAC_ENTRY (336 ,10 ,57 ,3 ,66 ,-2 ,77 ,5 ,64 ), +CABAC_ENTRY (337 ,26 ,43 ,18 ,50 ,25 ,42 ,12 ,70 ), + +/* Table 9-23 – Values of variables m and n for ctxIdx from 338 to 398 */ +CABAC_ENTRY (338 ,14 ,11 ,19 ,-6 ,17 ,-13 ,15 ,6 ), +CABAC_ENTRY (339 ,11 ,14 ,18 ,-6 ,16 ,-9 ,6 ,19 ), +CABAC_ENTRY (340 ,9 ,11 ,14 ,0 ,17 ,-12 ,7 ,16 ), +CABAC_ENTRY (341 ,18 ,11 ,26 ,-12 ,27 ,-21 ,12 ,14 ), +CABAC_ENTRY (342 ,21 ,9 ,31 ,-16 ,37 ,-30 ,18 ,13 ), +CABAC_ENTRY (343 ,23 ,-2 ,33 ,-25 ,41 ,-40 ,13 ,11 ), +CABAC_ENTRY (344 ,32 ,-15 ,33 ,-22 ,42 ,-41 ,13 ,15 ), +CABAC_ENTRY (345 ,32 ,-15 ,37 ,-28 ,48 ,-47 ,15 ,16 ), +CABAC_ENTRY (346 ,34 ,-21 ,39 ,-30 ,39 ,-32 ,12 ,23 ), +CABAC_ENTRY (347 ,39 ,-23 ,42 ,-30 ,46 ,-40 ,13 ,23 ), +CABAC_ENTRY (348 ,42 ,-33 ,47 ,-42 ,52 ,-51 ,15 ,20 ), +CABAC_ENTRY (349 ,41 ,-31 ,45 ,-36 ,46 ,-41 ,14 ,26 ), +CABAC_ENTRY (350 ,46 ,-28 ,49 ,-34 ,52 ,-39 ,14 ,44 ), +CABAC_ENTRY (351 ,38 ,-12 ,41 ,-17 ,43 ,-19 ,17 ,40 ), +CABAC_ENTRY (352 ,21 ,29 ,32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), +CABAC_ENTRY (394 ,23 ,42 ,18 ,50 ,3 ,78 ,39 ,11 ), +CABAC_ENTRY (395 ,19 ,57 ,12 ,70 ,-16 ,123 ,30 ,29 ), +CABAC_ENTRY (396 ,22 ,53 ,21 ,54 ,21 ,53 ,34 ,26 ), +CABAC_ENTRY (397 ,22 ,61 ,14 ,71 ,22 ,56 ,29 ,39 ), +CABAC_ENTRY (398 ,11 ,86 ,11 ,83 ,25 ,61 ,19 ,66 ), + +/* Values of variables m and n for ctxIdx from 399 to 463 (not documented) */ +CABAC_ENTRY (399 ,12 ,40 ,25 ,32 ,21 ,33 ,31 ,21 ), +CABAC_ENTRY (400 ,11 ,51 ,21 ,49 ,19 ,50 ,31 ,31 ), +CABAC_ENTRY (401 ,14 ,59 ,21 ,54 ,17 ,61 ,25 ,50 ), +CABAC_ENTRY (402 ,-4 ,79 ,-5 ,85 ,-3 ,78 ,-17 ,120 ), +CABAC_ENTRY (403 ,-7 ,71 ,-6 ,81 ,-8 ,74 ,-20 ,112 ), +CABAC_ENTRY (404 ,-5 ,69 ,-10 ,77 ,-9 ,72 ,-18 ,114 ), +CABAC_ENTRY (405 ,-9 ,70 ,-7 ,81 ,-10 ,72 ,-11 ,85 ), +CABAC_ENTRY (406 ,-8 ,66 ,-17 ,80 ,-18 ,75 ,-15 ,92 ), +CABAC_ENTRY (407 ,-10 ,68 ,-18 ,73 ,-12 ,71 ,-14 ,89 ), +CABAC_ENTRY (408 ,-19 ,73 ,-4 ,74 ,-11 ,63 ,-26 ,71 ), +CABAC_ENTRY (409 ,-12 ,69 ,-10 ,83 ,-5 ,70 ,-15 ,81 ), +CABAC_ENTRY (410 ,-16 ,70 ,-9 ,71 ,-17 ,75 ,-14 ,80 ), +CABAC_ENTRY (411 ,-15 ,67 ,-9 ,67 ,-14 ,72 ,0 ,68 ), +CABAC_ENTRY (412 ,-20 ,62 ,-1 ,61 ,-16 ,67 ,-14 ,70 ), +CABAC_ENTRY (413 ,-19 ,70 ,-8 ,66 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31 ,-4 ,28 ,-8 ), +CABAC_ENTRY (454 ,46 ,-2 ,49 ,-5 ,33 ,-1 ,28 ,-1 ), +CABAC_ENTRY (455 ,51 ,2 ,53 ,0 ,33 ,7 ,29 ,3 ), +CABAC_ENTRY (456 ,60 ,6 ,64 ,3 ,31 ,12 ,29 ,9 ), +CABAC_ENTRY (457 ,61 ,17 ,68 ,10 ,37 ,23 ,35 ,20 ), +CABAC_ENTRY (458 ,55 ,34 ,66 ,27 ,31 ,38 ,29 ,36 ), +CABAC_ENTRY (459 ,42 ,62 ,47 ,57 ,20 ,64 ,14 ,67 ), +}; + +#define RKV_HEVC_CABAC_TABLE_SIZE 27456 + +const u8 rkvdec_hevc_cabac_table[RKV_HEVC_CABAC_TABLE_SIZE ] = {
0x07,0x0f,0x48,0x58,0x58,0x40,0x40,0x40,0x40,0x40,0x0f,0x40,0x40,0x40,0x0f,0x68,0x48,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x07,0x40,0x40,0x68,0x58,0x60,0x40,0x1f,0x40,0x40,0x40,0x40,0x40,0x40,0x48,0x48,0x60,drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +0
-0@@ -15,6 +15,8 @@ #include "rkvdec.h" #include "rkvdec-regs.h"drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +2
-0+extern const s8 rkvdec_h264_cabac_table[4 ][464 ][2 ]; +/* Size with u32 units. */
#defineRKV_CABAC_INIT_BUFFER_SIZE(3680 + 128)
#defineRKV_RPS_SIZE((128 + 128) / 4)drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +0
-0@@ -118,505 +120,6 @@ struct rkvdec_h264_ctx { struct rkvdec_regs regs; };drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +0
-499-#define CABAC_ENTRY (ctxidx, idc0_m, idc0_n, idc1_m, idc1_n, \ - idc2_m, idc2_n, intra_m, intra_n) \ - [0][(ctxidx)] = {idc0_m, idc0_n}, \ - [1][(ctxidx)] = {idc1_m, idc1_n}, \ - [2][(ctxidx)] = {idc2_m, idc2_n}, \ - [3][(ctxidx)] = {intra_m, intra_n} - -/* -* Constant CABAC table. -* Built from the tables described in section '9.3.1.1 Initialisation process -* for context variables' of the H264 spec. -*/ -static const s8 rkvdec_h264_cabac_table[4 ][464 ][2 ] = { -/* Table 9-12 – Values of variables m and n for ctxIdx from 0 to 10 */ -CABAC_ENTRY (0 ,20 ,-15 ,20 ,-15 ,20 ,-15 ,20 ,-15 ), -CABAC_ENTRY (1 ,2 ,54 ,2 ,54 ,2 ,54 ,2 ,54 ), -CABAC_ENTRY (2 ,3 ,74 ,3 ,74 ,3 ,74 ,3 ,74 ), -CABAC_ENTRY (3 ,20 ,-15 ,20 ,-15 ,20 ,-15 ,20 ,-15 ), -CABAC_ENTRY (4 ,2 ,54 ,2 ,54 ,2 ,54 ,2 ,54 ), -CABAC_ENTRY (5 ,3 ,74 ,3 ,74 ,3 ,74 ,3 ,74 ), -CABAC_ENTRY (6 ,-28 ,127 ,-28 ,127 ,-28 ,127 ,-28 ,127 ), -CABAC_ENTRY (7 ,-23 ,104 ,-23 ,104 ,-23 ,104 ,-23 ,104 ), -CABAC_ENTRY (8 ,-6 ,53 ,-6 ,53 ,-6 ,53 ,-6 ,53 ), -CABAC_ENTRY (9 ,-1 ,54 ,-1 ,54 ,-1 ,54 ,-1 ,54 ), -CABAC_ENTRY (10 ,7 ,51 ,7 ,51 ,7 ,51 ,7 ,51 ), - -/* Table 9-13 – Values of variables m and n for ctxIdx from 11 to 23 */ -CABAC_ENTRY (11 ,23 ,33 ,22 ,25 ,29 ,16 ,0 ,0 ), -CABAC_ENTRY (12 ,23 ,2 ,34 ,0 ,25 ,0 ,0 ,0 ), -CABAC_ENTRY (13 ,21 ,0 ,16 ,0 ,14 ,0 ,0 ,0 ), -CABAC_ENTRY (14 ,1 ,9 ,-2 ,9 ,-10 ,51 ,0 ,0 ), -CABAC_ENTRY (15 ,0 ,49 ,4 ,41 ,-3 ,62 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), -CABAC_ENTRY (216 ,22 ,29 ,21 ,30 ,21 ,28 ,38 ,-3 ), -CABAC_ENTRY (217 ,24 ,31 ,17 ,45 ,25 ,21 ,37 ,3 ), -CABAC_ENTRY (218 ,23 ,38 ,20 ,42 ,30 ,20 ,38 ,5 ), -CABAC_ENTRY (219 ,18 ,43 ,18 ,45 ,31 ,12 ,42 ,0 ), -CABAC_ENTRY (220 ,20 ,41 ,27 ,26 ,27 ,16 ,35 ,16 ), -CABAC_ENTRY (221 ,11 ,63 ,16 ,54 ,24 ,42 ,39 ,22 ), -CABAC_ENTRY (222 ,9 ,59 ,7 ,66 ,0 ,93 ,14 ,48 ), -CABAC_ENTRY (223 ,9 ,64 ,16 ,56 ,14 ,56 ,27 ,37 ), -CABAC_ENTRY (224 ,-1 ,94 ,11 ,73 ,15 ,57 ,21 ,60 ), -CABAC_ENTRY (225 ,-2 ,89 ,10 ,67 ,26 ,38 ,12 ,68 ), -CABAC_ENTRY (226 ,-9 ,108 ,-10 ,116 ,-24 ,127 ,2 ,97 ), - -/* Table 9-21 – Values of variables m and n for ctxIdx from 227 to 275 */ -CABAC_ENTRY (227 ,-6 ,76 ,-23 ,112 ,-24 ,115 ,-3 ,71 ), -CABAC_ENTRY (228 ,-2 ,44 ,-15 ,71 ,-22 ,82 ,-6 ,42 ), -CABAC_ENTRY (229 ,0 ,45 ,-7 ,61 ,-9 ,62 ,-5 ,50 ), -CABAC_ENTRY (230 ,0 ,52 ,0 ,53 ,0 ,53 ,-3 ,54 ), -CABAC_ENTRY (231 ,-3 ,64 ,-5 ,66 ,0 ,59 ,-2 ,62 ), -CABAC_ENTRY (232 ,-2 ,59 ,-11 ,77 ,-14 ,85 ,0 ,58 ), -CABAC_ENTRY (233 ,-4 ,70 ,-9 ,80 ,-13 ,89 ,1 ,63 ), -CABAC_ENTRY (234 ,-4 ,75 ,-9 ,84 ,-13 ,94 ,-2 ,72 ), -CABAC_ENTRY (235 ,-8 ,82 ,-10 ,87 ,-11 ,92 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-14 ,97 ), - -/* Table 9-22 – Values of variables m and n for ctxIdx from 277 to 337 */ -CABAC_ENTRY (277 ,-13 ,106 ,-21 ,126 ,-22 ,127 ,-6 ,93 ), -CABAC_ENTRY (278 ,-16 ,106 ,-23 ,124 ,-25 ,127 ,-6 ,84 ), -CABAC_ENTRY (279 ,-10 ,87 ,-20 ,110 ,-25 ,120 ,-8 ,79 ), -CABAC_ENTRY (280 ,-21 ,114 ,-26 ,126 ,-27 ,127 ,0 ,66 ), -CABAC_ENTRY (281 ,-18 ,110 ,-25 ,124 ,-19 ,114 ,-1 ,71 ), -CABAC_ENTRY (282 ,-14 ,98 ,-17 ,105 ,-23 ,117 ,0 ,62 ), -CABAC_ENTRY (283 ,-22 ,110 ,-27 ,121 ,-25 ,118 ,-2 ,60 ), -CABAC_ENTRY (284 ,-21 ,106 ,-27 ,117 ,-26 ,117 ,-2 ,59 ), -CABAC_ENTRY (285 ,-18 ,103 ,-17 ,102 ,-24 ,113 ,-5 ,75 ), -CABAC_ENTRY (286 ,-21 ,107 ,-26 ,117 ,-28 ,118 ,-3 ,62 ), -CABAC_ENTRY (287 ,-23 ,108 ,-27 ,116 ,-31 ,120 ,-4 ,58 ), -CABAC_ENTRY (288 ,-26 ,112 ,-33 ,122 ,-37 ,124 ,-9 ,66 ), -CABAC_ENTRY (289 ,-10 ,96 ,-10 ,95 ,-10 ,94 ,-1 ,79 ), -CABAC_ENTRY (290 ,-12 ,95 ,-14 ,100 ,-15 ,102 ,0 ,71 ), -CABAC_ENTRY (291 ,-5 ,91 ,-8 ,95 ,-10 ,99 ,3 ,68 ), -CABAC_ENTRY (292 ,-9 ,93 ,-17 ,111 ,-13 ,106 ,10 ,44 ), -CABAC_ENTRY (293 ,-22 ,94 ,-28 ,114 ,-50 ,127 ,-7 ,62 ), -CABAC_ENTRY (294 ,-5 ,86 ,-6 ,89 ,-5 ,92 ,15 ,36 ), -CABAC_ENTRY (295 ,9 ,67 ,-2 ,80 ,17 ,57 ,14 ,40 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,43 ,18 ,50 ,25 ,42 ,12 ,70 ), - -/* Table 9-23 – Values of variables m and n for ctxIdx from 338 to 398 */ -CABAC_ENTRY (338 ,14 ,11 ,19 ,-6 ,17 ,-13 ,15 ,6 ), -CABAC_ENTRY (339 ,11 ,14 ,18 ,-6 ,16 ,-9 ,6 ,19 ), -CABAC_ENTRY (340 ,9 ,11 ,14 ,0 ,17 ,-12 ,7 ,16 ), -CABAC_ENTRY (341 ,18 ,11 ,26 ,-12 ,27 ,-21 ,12 ,14 ), -CABAC_ENTRY (342 ,21 ,9 ,31 ,-16 ,37 ,-30 ,18 ,13 ), -CABAC_ENTRY (343 ,23 ,-2 ,33 ,-25 ,41 ,-40 ,13 ,11 ), -CABAC_ENTRY (344 ,32 ,-15 ,33 ,-22 ,42 ,-41 ,13 ,15 ), -CABAC_ENTRY (345 ,32 ,-15 ,37 ,-28 ,48 ,-47 ,15 ,16 ), -CABAC_ENTRY (346 ,34 ,-21 ,39 ,-30 ,39 ,-32 ,12 ,23 ), -CABAC_ENTRY (347 ,39 ,-23 ,42 ,-30 ,46 ,-40 ,13 ,23 ), -CABAC_ENTRY (348 ,42 ,-33 ,47 ,-42 ,52 ,-51 ,15 ,20 ), -CABAC_ENTRY (349 ,41 ,-31 ,45 ,-36 ,46 ,-41 ,14 ,26 ), -CABAC_ENTRY (350 ,46 ,-28 ,49 ,-34 ,52 ,-39 ,14 ,44 ), -CABAC_ENTRY (351 ,38 ,-12 ,41 ,-17 ,43 ,-19 ,17 ,40 ), -CABAC_ENTRY (352 ,21 ,29 ,32 ,9 ,32 ,11 ,17 ,47 ), -CABAC_ENTRY (353 ,45 ,-24 ,69 ,-71 ,61 ,-55 ,24 ,17 ), -CABAC_ENTRY (354 ,53 ,-45 ,63 ,-63 ,56 ,-46 ,21 ,21 ), -CABAC_ENTRY (355 ,48 ,-26 ,66 ,-64 ,62 ,-50 ,25 ,22 ), -CABAC_ENTRY (356 ,65 ,-43 ,77 ,-74 ,81 ,-67 ,31 ,27 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,25 ,61 ,19 ,66 ), - -/* Values of variables m and n for ctxIdx from 399 to 463 (not documented) */ -CABAC_ENTRY (399 ,12 ,40 ,25 ,32 ,21 ,33 ,31 ,21 ), -CABAC_ENTRY (400 ,11 ,51 ,21 ,49 ,19 ,50 ,31 ,31 ), -CABAC_ENTRY (401 ,14 ,59 ,21 ,54 ,17 ,61 ,25 ,50 ), -CABAC_ENTRY (402 ,-4 ,79 ,-5 ,85 ,-3 ,78 ,-17 ,120 ), -CABAC_ENTRY (403 ,-7 ,71 ,-6 ,81 ,-8 ,74 ,-20 ,112 ), -CABAC_ENTRY (404 ,-5 ,69 ,-10 ,77 ,-9 ,72 ,-18 ,114 ), -CABAC_ENTRY (405 ,-9 ,70 ,-7 ,81 ,-10 ,72 ,-11 ,85 ), -CABAC_ENTRY (406 ,-8 ,66 ,-17 ,80 ,-18 ,75 ,-15 ,92 ), -CABAC_ENTRY (407 ,-10 ,68 ,-18 ,73 ,-12 ,71 ,-14 ,89 ), -CABAC_ENTRY (408 ,-19 ,73 ,-4 ,74 ,-11 ,63 ,-26 ,71 ), -CABAC_ENTRY (409 ,-12 ,69 ,-10 ,83 ,-5 ,70 ,-15 ,81 ), -CABAC_ENTRY (410 ,-16 ,70 ,-9 ,71 ,-17 ,75 ,-14 ,80 ), -CABAC_ENTRY (411 ,-15 ,67 ,-9 ,67 ,-14 ,72 ,0 ,68 ), -CABAC_ENTRY (412 ,-20 ,62 ,-1 ,61 ,-16 ,67 ,-14 ,70 ), -CABAC_ENTRY (413 ,-19 ,70 ,-8 ,66 ,-8 ,53 ,-24 ,56 ), -CABAC_ENTRY (414 ,-16 ,66 ,-14 ,66 ,-14 ,59 ,-23 ,68 ), -CABAC_ENTRY (415 ,-22 ,65 ,0 ,59 ,-9 ,52 ,-24 ,50 ), -CABAC_ENTRY (416 ,-20 ,63 ,2 ,59 ,-11 ,68 ,-11 ,74 ), -CABAC_ENTRY (417 ,9 ,-2 ,17 ,-10 ,9 ,-2 ,23 ,-13 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(458 ,55 ,34 ,66 ,27 ,31 ,38 ,29 ,36 ), -CABAC_ENTRY (459 ,42 ,62 ,47 ,57 ,20 ,64 ,14 ,67 ), -}; -static void
set_ps_field(u32 *buf, struct rkvdec_ps_field field, u32 value){
u8 bit = field.offset % 32, word = field.offset / 32;drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +0
-0@@ -16,7 +16,6 @@
#include "rkvdec.h"
#include "rkvdec-regs.h"
-#include "rkvdec-hevc-data.c"
/* Size in u8/u32 units. */
#defineRKV_SCALING_LIST_SIZE1360drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +0
-0@@ -25,6 +24,9 @@ #define RKV_RPS_SIZE (32 / 4) #define RKV_RPS_LEN 600drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +3
-0+#define RKV_HEVC_CABAC_TABLE_SIZE 27456 +extern const u8 rkvdec_hevc_cabac_table[RKV_HEVC_CABAC_TABLE_SIZE ]; +struct
rkvdec_sps_pps_packet{
u32 info[RKV_PPS_SIZE];
};drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +0
-0@@ -110,7 +112,7 @@ struct rkvdec_ps_field {
/* Data structure describing auxiliary buffer format. */ structrkvdec_hevc_priv_tbl{drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1
-1-u8 cabac_table[RKV_CABAC_TABLE_SIZE ]; +u8 cabac_table[RKV_HEVC_CABAC_TABLE_SIZE ];u8 scaling_list[RKV_SCALING_LIST_SIZE]; struct
rkvdec_sps_pps_packetparam_set[RKV_PPS_LEN]; structrkvdec_rps_packetrps[RKV_RPS_LEN];
Detlev Casanova
maintainerPATCH v3 5/15 media: rkvdec: Use structs to represent the HW RPS
In reply to Detlev CasanovaThis is in preparation to add support for other variants of the decoder.
Moving to struct representation is mainly to prepare for multicore support that is present in e.g. rk3588.
--- .../platform/rockchip/rkvdec/rkvdec-h264.c | 93 +++++++++++++++++-- 1 file changed, 84 insertions(+), 9 deletions(-)
drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +84 -9
@@ -19,7 +19,6 @@ extern const s8 rkvdec_h264_cabac_table[4][464][2];/* Size with u32 units. */ #define RKV_CABAC_INIT_BUFFER_SIZE (3680 + 128) -#define RKV_RPS_SIZE ((128 + 128) / 4)#define RKV_ERROR_INFO_SIZE (256 * 144 * 4)#define RKVDEC_NUM_REFLIST 3
@@ -34,6 +33,40 @@ struct rkvdec_sps_pps_packet {u32 info[8 ]; }; +struct rkvdec_rps_entry { +u32 dpb_info0:5 ; +u32 bottom_flag0:1 ; +u32 view_index_off0:1 ; +u32 dpb_info1:5 ; +u32 bottom_flag1:1 ; +u32 view_index_off1:1 ; +u32 dpb_info2:5 ; +u32 bottom_flag2:1 ; +u32 view_index_off2:1 ; +u32 dpb_info3:5 ; +u32 bottom_flag3:1 ; +u32 view_index_off3:1 ; +u32 dpb_info4:5 ; +u32 bottom_flag4:1 ; +u32 view_index_off4:1 ; +u32 dpb_info5:5 ; +u32 bottom_flag5:1 ; +u32 view_index_off5:1 ; +u32 dpb_info6:5 ; +u32 bottom_flag6:1 ; +u32 view_index_off6:1 ; +u32 dpb_info7:5 ; +u32 bottom_flag7:1 ; +u32 view_index_off7:1 ; +} __packed; + +struct rkvdec_rps { +u16 frame_num[16 ]; +u32 reserved0; +struct rkvdec_rps_entry entries[12 ]; +u32 reserved1[66 ]; +} __packed; +struct rkvdec_ps_field {u16 offset;u8 len;
@@ -94,7 +127,7 @@ struct rkvdec_ps_field {struct rkvdec_h264_priv_tbl {s8 cabac_table[4 ][464 ][2 ];struct rkvdec_h264_scaling_list scaling_list; -u32 rps[RKV_RPS_SIZE ]; +struct rkvdec_rps rps;struct rkvdec_sps_pps_packet param_set[256 ];u8 err_info[RKV_ERROR_INFO_SIZE ]; };
@@ -260,6 +293,51 @@ static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx, } } +static void set_dpb_info (struct rkvdec_rps_entry *entries, +u8 reflist, +u8 refnum, +u8 info, +bool bottom) +{ +struct rkvdec_rps_entry *entry = &entries[(reflist *4 ) + refnum /8 ]; +u8 idx = refnum %8 ; + +switch (idx) { +case 0 : + entry->dpb_info0 = info; + entry->bottom_flag0 = bottom; +break ; +case 1 : + entry->dpb_info1 = info; + entry->bottom_flag1 = bottom; +break ; +case 2 : + entry->dpb_info2 = info; + entry->bottom_flag2 = bottom; +break ; +case 3 : + entry->dpb_info3 = info; + entry->bottom_flag3 = bottom; +break ; +case 4 : + entry->dpb_info4 = info; + entry->bottom_flag4 = bottom; +break ; +case 5 : + entry->dpb_info5 = info; + entry->bottom_flag5 = bottom; +break ; +case 6 : + entry->dpb_info6 = info; + entry->bottom_flag6 = bottom; +break ; +case 7 : + entry->dpb_info7 = info; + entry->bottom_flag7 = bottom; +break ; + } +} +static void assemble_hw_rps (struct rkvdec_ctx *ctx,struct v4l2_h264_reflist_builder *builder,struct rkvdec_h264_run *run)
@@ -269,11 +347,10 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx,struct rkvdec_h264_ctx *h264_ctx = ctx->priv;struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu; -u32 *hw_rps = priv_tbl->rps; +struct rkvdec_rps *hw_rps = &priv_tbl->rps;u32 i, j; -u16 *p = (u16 *)hw_rps; -memset (hw_rps,0 ,sizeof (priv_tbl->rps)); +memset (hw_rps,0 ,sizeof (*hw_rps));/* * Assign an invalid pic_num if DPB entry at that position is inactive.
@@ -285,7 +362,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx,if (!(dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ))continue ; - p[i] = builder->refs[i].frame_num; + hw_rps->frame_num[i] = builder->refs[i].frame_num; }for (j =0 ; j <RKVDEC_NUM_REFLIST ; j++) {
@@ -312,9 +389,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, dpb_valid = run->ref_buf[ref->index] !=NULL ; bottom = ref->fields ==V4L2_H264_BOTTOM_FIELD_REF ; -set_ps_field (hw_rps,DPB_INFO (i, j), - ref->index | dpb_valid <<4 ); -set_ps_field (hw_rps,BOTTOM_FLAG (i, j), bottom); +set_dpb_info (hw_rps->entries, j, i, ref->index | (dpb_valid <<4 ), bottom); } } }
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 6/15 media: rkvdec: Move h264 functions to common file
In reply to Detlev CasanovaThis is a preparation commit to add support for new variants of the decoder.
The functions will later be shared with vdpu381 (rk3588) and vdpu383 (rk3576).
--- .../media/platform/rockchip/rkvdec/Makefile | 1 + .../rockchip/rkvdec/rkvdec-h264-common.c | 252 ++++++++++++++ .../rockchip/rkvdec/rkvdec-h264-common.h | 81 +++++ .../platform/rockchip/rkvdec/rkvdec-h264.c | 310 +----------------- 4 files changed, 338 insertions(+), 306 deletions(-) create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-h264-common.c create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-h264-common.h
drivers/media/platform/rockchip/rkvdec/Makefile +1 -0
@@ -4,5 +4,6 @@ rockchip-vdec-y += \ rkvdec.o \ rkvdec-cabac.o \ rkvdec-h264.o \ + rkvdec-h264-common.o \ rkvdec-hevc.o \ rkvdec-vp9.o
drivers/media/platform/rockchip/rkvdec/rkvdec-h264-common.c new file +252 -0
252 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-h264-common.h new file +81 -0
81 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c +4 -306
369 lines not on this page · raw message
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 7/15 media: rkvdec: Move hevc functions to common file
In reply to Detlev CasanovaThis is a preparation commit to add support for new variants of the decoder.
The functions will later be shared with vdpu381 (rk3588) and vdpu383 (rk3576).
--- .../media/platform/rockchip/rkvdec/Makefile | 1 + .../rockchip/rkvdec/rkvdec-hevc-common.c | 233 +++++++++++++++++ .../rockchip/rkvdec/rkvdec-hevc-common.h | 51 ++++ .../platform/rockchip/rkvdec/rkvdec-hevc.c | 243 +----------------- 4 files changed, 291 insertions(+), 237 deletions(-) create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.h
drivers/media/platform/rockchip/rkvdec/Makefile +1 -0
@@ -6,4 +6,5 @@ rockchip-vdec-y += \ rkvdec-h264.o \ rkvdec-h264-common.o \ rkvdec-hevc.o \ + rkvdec-hevc-common.o \ rkvdec-vp9.o
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c new file +233 -0
233 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.h new file +51 -0
51 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +6 -237
303 lines not on this page · raw message
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 8/15 media: rkvdec: Add generic configuration for variants
In reply to Detlev CasanovaThis is to prepare for adding new versions of the decoder and support specific formats and ops per version.
Different rkvdec_variant instances will be able to share generic decoder configs.
--- .../media/platform/rockchip/rkvdec/rkvdec.c | 37 ++++++++++++------- .../media/platform/rockchip/rkvdec/rkvdec.h | 6 +++ 2 files changed, 30 insertions(+), 13 deletions(-)
drivers/media/platform/rockchip/rkvdec/rkvdec.c +24 -13
@@ -373,15 +373,16 @@ static bool rkvdec_is_capable(struct rkvdec_ctx *ctx, unsigned int capability)static const struct rkvdec_coded_fmt_desc *rkvdec_enum_coded_fmt_desc (struct rkvdec_ctx *ctx,int index) { +const struct rkvdec_config *cfg = ctx->dev->variant->config;int fmt_idx =-1 ;unsigned int i; -for (i =0 ; i <ARRAY_SIZE (rkvdec_coded_fmts); i++) { -if (!rkvdec_is_capable (ctx, rkvdec_coded_fmts[i].capability)) +for (i =0 ; i < cfg->coded_fmts_num; i++) { +if (!rkvdec_is_capable (ctx, cfg->coded_fmts[i].capability))continue ; fmt_idx++;if (index == fmt_idx) -return &rkvdec_coded_fmts[i]; +return &cfg->coded_fmts[i]; }return NULL ;
@@ -390,12 +391,13 @@ rkvdec_enum_coded_fmt_desc(struct rkvdec_ctx *ctx, int index)static const struct rkvdec_coded_fmt_desc *rkvdec_find_coded_fmt_desc (struct rkvdec_ctx *ctx,u32 fourcc) { +const struct rkvdec_config *cfg = ctx->dev->variant->config;unsigned int i; -for (i =0 ; i <ARRAY_SIZE (rkvdec_coded_fmts); i++) { -if (rkvdec_is_capable (ctx, rkvdec_coded_fmts[i].capability) && - rkvdec_coded_fmts[i].fourcc == fourcc) -return &rkvdec_coded_fmts[i]; +for (i =0 ; i < cfg->coded_fmts_num; i++) { +if (rkvdec_is_capable (ctx, cfg->coded_fmts[i].capability) && + cfg->coded_fmts[i].fourcc == fourcc) +return &cfg->coded_fmts[i]; }return NULL ;
@@ -1014,18 +1016,19 @@ static int rkvdec_add_ctrls(struct rkvdec_ctx *ctx,static int rkvdec_init_ctrls (struct rkvdec_ctx *ctx) { +const struct rkvdec_config *cfg = ctx->dev->variant->config;unsigned int i, nctrls =0 ;int ret; -for (i =0 ; i <ARRAY_SIZE (rkvdec_coded_fmts); i++) -if (rkvdec_is_capable (ctx, rkvdec_coded_fmts[i].capability)) - nctrls += rkvdec_coded_fmts[i].ctrls->num_ctrls; +for (i =0 ; i < cfg->coded_fmts_num; i++) +if (rkvdec_is_capable (ctx, cfg->coded_fmts[i].capability)) + nctrls += cfg->coded_fmts[i].ctrls->num_ctrls;v4l2_ctrl_handler_init (&ctx->ctrl_hdl, nctrls); -for (i =0 ; i <ARRAY_SIZE (rkvdec_coded_fmts); i++) { -if (rkvdec_is_capable (ctx, rkvdec_coded_fmts[i].capability)) { - ret =rkvdec_add_ctrls (ctx, rkvdec_coded_fmts[i].ctrls); +for (i =0 ; i < cfg->coded_fmts_num; i++) { +if (rkvdec_is_capable (ctx, cfg->coded_fmts[i].capability)) { + ret =rkvdec_add_ctrls (ctx, cfg->coded_fmts[i].ctrls);if (ret) goto err_free_handler; }
@@ -1240,13 +1243,20 @@ static void rkvdec_watchdog_func(struct work_struct *work) } } +static const struct rkvdec_config config_rkvdec = { + .coded_fmts = rkvdec_coded_fmts, + .coded_fmts_num =ARRAY_SIZE (rkvdec_coded_fmts), +}; +static const struct rkvdec_variant rk3288_rkvdec_variant = { .num_regs =68 , + .config = &config_rkvdec, .capabilities =RKVDEC_CAPABILITY_HEVC , };static const struct rkvdec_variant rk3328_rkvdec_variant = { .num_regs =109 , + .config = &config_rkvdec, .capabilities =RKVDEC_CAPABILITY_HEVC |RKVDEC_CAPABILITY_H264 |RKVDEC_CAPABILITY_VP9 ,
@@ -1255,6 +1265,7 @@ static const struct rkvdec_variant rk3328_rkvdec_variant = {static const struct rkvdec_variant rk3399_rkvdec_variant = { .num_regs =78 , + .config = &config_rkvdec, .capabilities =RKVDEC_CAPABILITY_HEVC |RKVDEC_CAPABILITY_H264 |RKVDEC_CAPABILITY_VP9 ,
drivers/media/platform/rockchip/rkvdec/rkvdec.h +6 -0
@@ -71,6 +71,7 @@ vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf)struct rkvdec_variant {unsigned int num_regs; +const struct rkvdec_config *config;unsigned int capabilities;unsigned int quirks; };
@@ -113,6 +114,11 @@ struct rkvdec_coded_fmt_desc {unsigned int capability; }; +struct rkvdec_config { +const struct rkvdec_coded_fmt_desc *coded_fmts; +size_t coded_fmts_num; +}; +struct rkvdec_dev {struct v4l2_device v4l2_dev;struct media_device mdev;
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 9/15 media: rkvdec: Add RCB and SRAM support
In reply to Detlev CasanovaThe RCB (Rows and Cols Buffers) are a set of buffers used by other variations of the decoder to store temporary data.
Those variation come with a dedicated SRAM area used to store those buffers for better performances.
The buffer sizes are either the width or height of the frame being decoded multiplied by a documented factor and can be stored either in SRAM or RAM.
A fallback to RAM is provided if the SRAM is full (e.g.: multiple streams are being decoded at the same time).
To manage the different kind of allocation, an enum is added to the rkvdec_aux_buf struct to specify how the buffer was allocated, and so, how to free it.
This commit is in preparation of other variants support.
--- .../media/platform/rockchip/rkvdec/Makefile | 1 + .../platform/rockchip/rkvdec/rkvdec-rcb.c | 173 ++++++++++++++++++ .../platform/rockchip/rkvdec/rkvdec-rcb.h | 29 +++ .../media/platform/rockchip/rkvdec/rkvdec.c | 27 ++- .../media/platform/rockchip/rkvdec/rkvdec.h | 13 ++ 5 files changed, 241 insertions(+), 2 deletions(-) create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-rcb.c create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-rcb.h
drivers/media/platform/rockchip/rkvdec/Makefile +1 -0
@@ -7,4 +7,5 @@ rockchip-vdec-y += \ rkvdec-h264-common.o \ rkvdec-hevc.o \ rkvdec-hevc-common.o \ + rkvdec-rcb.o \ rkvdec-vp9.o
drivers/media/platform/rockchip/rkvdec/rkvdec-rcb.c new file +173 -0
173 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-rcb.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Rockchip video decoder Rows and Cols Buffers manager +* +* Copyright (C) 2025 Collabora, Ltd. +* Detlev Casanova <[email protected]> +*/ + +#include <linux/types.h> + +struct rkvdec_ctx ; + +enum rcb_axis { +PIC_WIDTH =0 , +PIC_HEIGHT =1 +}; + +struct rcb_size_info { +u8 multiplier; +enum rcb_axis axis; +}; + +int rkvdec_allocate_rcb (struct rkvdec_ctx *ctx, +const struct rcb_size_info *size_info, +size_t rcb_count); +dma_addr_t rkvdec_rcb_buf_dma_addr (struct rkvdec_ctx *ctx,int id); +size_t rkvdec_rcb_buf_size (struct rkvdec_ctx *ctx,int id); +int rkvdec_rcb_buf_count (struct rkvdec_ctx *ctx); +void rkvdec_free_rcb (struct rkvdec_ctx *ctx);
drivers/media/platform/rockchip/rkvdec/rkvdec.c +25 -2
@@ -10,6 +10,7 @@*/ #include <linux/clk.h> +#include <linux/genalloc.h> #include <linux/interrupt.h> #include <linux/iommu.h> #include <linux/module.h>
@@ -28,6 +29,7 @@#include "rkvdec.h" #include "rkvdec-regs.h" +#include "rkvdec-rcb.h" static bool rkvdec_image_fmt_match (enum rkvdec_image_fmt fmt1,enum rkvdec_image_fmt fmt2)
@@ -771,6 +773,7 @@ static int rkvdec_start_streaming(struct vb2_queue *q, unsigned int count) {struct rkvdec_ctx *ctx =vb2_get_drv_priv (q);const struct rkvdec_coded_fmt_desc *desc; +const struct rkvdec_config *cfg = ctx->dev->variant->config;int ret;if (V4L2_TYPE_IS_CAPTURE (q->type))
@@ -780,13 +783,22 @@ static int rkvdec_start_streaming(struct vb2_queue *q, unsigned int count)if (WARN_ON (!desc))return -EINVAL ; + ret =rkvdec_allocate_rcb (ctx, cfg->rcb_size_info, cfg->rcb_num); +if (ret) +return ret; +if (desc->ops->start) { ret = desc->ops->start (ctx);if (ret) -return ret; + goto err_ops_start; }return 0 ; + +err_ops_start: +rkvdec_free_rcb (ctx); + +return ret; }static void rkvdec_queue_cleanup (struct vb2_queue *vq,u32 state)
@@ -822,6 +834,8 @@ static void rkvdec_stop_streaming(struct vb2_queue *q)if (desc->ops->stop) desc->ops->stop (ctx); + +rkvdec_free_rcb (ctx); }rkvdec_queue_cleanup (q,VB2_BUF_STATE_ERROR );
@@ -1350,6 +1364,10 @@ static int rkvdec_probe(struct platform_device *pdev)return ret; } + rkvdec->sram_pool =of_gen_pool_get (pdev->dev.of_node,"sram" ,0 ); +if (!rkvdec->sram_pool && rkvdec->variant->config->rcb_num >0 ) +dev_info (&pdev->dev,"No sram node, RCB will be stored in RAM\n" ); +pm_runtime_set_autosuspend_delay (&pdev->dev,100 );pm_runtime_use_autosuspend (&pdev->dev);pm_runtime_enable (&pdev->dev);
@@ -1358,7 +1376,8 @@ static int rkvdec_probe(struct platform_device *pdev)if (ret) goto err_disable_runtime_pm; -if (iommu_get_domain_for_dev (&pdev->dev)) { + rkvdec->iommu_domain =iommu_get_domain_for_dev (&pdev->dev); +if (rkvdec->iommu_domain) { rkvdec->empty_domain =iommu_paging_domain_alloc (rkvdec->dev);if (IS_ERR (rkvdec->empty_domain)) {
@@ -1372,6 +1391,10 @@ static int rkvdec_probe(struct platform_device *pdev) err_disable_runtime_pm:pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_disable (&pdev->dev); + +if (rkvdec->sram_pool) +gen_pool_destroy (rkvdec->sram_pool); +return ret; }
drivers/media/platform/rockchip/rkvdec/rkvdec.h +13 -0
@@ -19,6 +19,7 @@#include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-ioctl.h> +#include <media/v4l2-mem2mem.h> #include <media/videobuf2-core.h> #include <media/videobuf2-dma-contig.h>
@@ -29,6 +30,7 @@#define RKVDEC_QUIRK_DISABLE_QOS BIT(0)struct rkvdec_ctx ; +struct rkvdec_rcb_config ;struct rkvdec_ctrl_desc {struct v4l2_ctrl_config cfg;
@@ -117,6 +119,8 @@ struct rkvdec_coded_fmt_desc {struct rkvdec_config {const struct rkvdec_coded_fmt_desc *coded_fmts;size_t coded_fmts_num; +const struct rcb_size_info *rcb_size_info; +size_t rcb_num; };struct rkvdec_dev {
@@ -129,6 +133,8 @@ struct rkvdec_dev {void __iomem *regs;struct mutex vdev_lock;/* serializes ioctls */ struct delayed_work watchdog_work; +struct gen_pool *sram_pool; +struct iommu_domain *iommu_domain;struct iommu_domain *empty_domain;const struct rkvdec_variant *variant; };
@@ -141,6 +147,7 @@ struct rkvdec_ctx {struct v4l2_ctrl_handler ctrl_hdl;struct rkvdec_dev *dev;enum rkvdec_image_fmt image_fmt; +struct rkvdec_rcb_config *rcb_config;void *priv; };
@@ -149,10 +156,16 @@ static inline struct rkvdec_ctx *file_to_rkvdec_ctx(struct file *filp) return container_of(file_to_v4l2_fh(filp), struct rkvdec_ctx, fh); } +enum rkvdec_alloc_type { +RKVDEC_ALLOC_DMA =0 , +RKVDEC_ALLOC_SRAM =1 , +}; +struct rkvdec_aux_buf {void *cpu;dma_addr_t dma;size_t size; +enum rkvdec_alloc_type type; };void rkvdec_run_preamble (struct rkvdec_ctx *ctx,struct rkvdec_run *run);
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 10/15 media: rkvdec: Support per-variant interrupt handler
In reply to Detlev CasanovaPreparation commit for supporting different variants with different interrupt management.
--- drivers/media/platform/rockchip/rkvdec/rkvdec.c | 15 ++++++++++++--- drivers/media/platform/rockchip/rkvdec/rkvdec.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/media/platform/rockchip/rkvdec/rkvdec.c +12 -3
@@ -1218,10 +1218,9 @@ static void rkvdec_iommu_restore(struct rkvdec_dev *rkvdec) } } -static irqreturn_t rkvdec_irq_handler (int irq,void *priv) +static irqreturn_t rk3399_irq_handler (struct rkvdec_ctx *ctx) { -struct rkvdec_dev *rkvdec = priv; -struct rkvdec_ctx *ctx =v4l2_m2m_get_curr_priv (rkvdec->m2m_dev); +struct rkvdec_dev *rkvdec = ctx->dev;enum vb2_buffer_state state;u32 status;
@@ -1242,6 +1241,15 @@ static irqreturn_t rkvdec_irq_handler(int irq, void *priv)return IRQ_HANDLED ; } +static irqreturn_t rkvdec_irq_handler (int irq,void *priv) +{ +struct rkvdec_dev *rkvdec = priv; +struct rkvdec_ctx *ctx =v4l2_m2m_get_curr_priv (rkvdec->m2m_dev); +const struct rkvdec_config *cfg = rkvdec->variant->config; + +return cfg->irq_handler (ctx); +} +static void rkvdec_watchdog_func (struct work_struct *work) {struct rkvdec_dev *rkvdec;
@@ -1260,6 +1268,7 @@ static void rkvdec_watchdog_func(struct work_struct *work)static const struct rkvdec_config config_rkvdec = { .coded_fmts = rkvdec_coded_fmts, .coded_fmts_num =ARRAY_SIZE (rkvdec_coded_fmts), + .irq_handler = rk3399_irq_handler, };static const struct rkvdec_variant rk3288_rkvdec_variant = {
drivers/media/platform/rockchip/rkvdec/rkvdec.h +1 -0
@@ -121,6 +121,7 @@ struct rkvdec_config {size_t coded_fmts_num;const struct rcb_size_info *rcb_size_info;size_t rcb_num; +irqreturn_t (*irq_handler)(struct rkvdec_ctx *ctx); };struct rkvdec_dev {
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 11/15 media: rkvdec: Enable all clocks without naming them
In reply to Detlev CasanovaFor other variants, the clock names and number will differ.
There is no need to keep track of the clock names in the driver so drop them to avoid having a list for each variant.
--- .../media/platform/rockchip/rkvdec/rkvdec.c | 24 +++++-------------- .../media/platform/rockchip/rkvdec/rkvdec.h | 1 + 2 files changed, 7 insertions(+), 18 deletions(-)
drivers/media/platform/rockchip/rkvdec/rkvdec.c +6 -18
@@ -1311,15 +1311,10 @@ static const struct of_device_id of_rkvdec_match[] = { };MODULE_DEVICE_TABLE (of, of_rkvdec_match); -static const char *const rkvdec_clk_names[] = { -"axi" ,"ahb" ,"cabac" ,"core" -}; -static int rkvdec_probe (struct platform_device *pdev) {const struct rkvdec_variant *variant;struct rkvdec_dev *rkvdec; -unsigned int i;int ret, irq; variant =of_device_get_match_data (&pdev->dev);
@@ -1336,19 +1331,12 @@ static int rkvdec_probe(struct platform_device *pdev)mutex_init (&rkvdec->vdev_lock);INIT_DELAYED_WORK (&rkvdec->watchdog_work, rkvdec_watchdog_func); - rkvdec->clocks =devm_kcalloc (&pdev->dev,ARRAY_SIZE (rkvdec_clk_names), -sizeof (*rkvdec->clocks),GFP_KERNEL ); -if (!rkvdec->clocks) -return -ENOMEM ; - -for (i =0 ; i <ARRAY_SIZE (rkvdec_clk_names); i++) - rkvdec->clocks[i].id = rkvdec_clk_names[i]; - - ret =devm_clk_bulk_get (&pdev->dev,ARRAY_SIZE (rkvdec_clk_names), - rkvdec->clocks); -if (ret) + ret =devm_clk_bulk_get_all_enabled (&pdev->dev, &rkvdec->clocks); +if (ret <0 )return ret; + rkvdec->clk_count = ret; + rkvdec->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (rkvdec->regs))return PTR_ERR (rkvdec->regs);
@@ -1426,7 +1414,7 @@ static int rkvdec_runtime_resume(struct device *dev) {struct rkvdec_dev *rkvdec =dev_get_drvdata (dev); -return clk_bulk_prepare_enable (ARRAY_SIZE (rkvdec_clk_names), +return clk_bulk_prepare_enable (rkvdec->clk_count, rkvdec->clocks); }
@@ -1434,7 +1422,7 @@ static int rkvdec_runtime_suspend(struct device *dev) {struct rkvdec_dev *rkvdec =dev_get_drvdata (dev); -clk_bulk_disable_unprepare (ARRAY_SIZE (rkvdec_clk_names), +clk_bulk_disable_unprepare (rkvdec->clk_count, rkvdec->clocks);return 0 ; }
drivers/media/platform/rockchip/rkvdec/rkvdec.h +1 -0
@@ -131,6 +131,7 @@ struct rkvdec_dev {struct v4l2_m2m_dev *m2m_dev;struct device *dev;struct clk_bulk_data *clocks; +unsigned int clk_count;void __iomem *regs;struct mutex vdev_lock;/* serializes ioctls */ struct delayed_work watchdog_work;
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 12/15 media: rkvdec: Add H264 support for the VDPU381 variant
In reply to Detlev CasanovaThis decoder variant is found in Rockchip RK3588 SoC family.
Like for rkvdec on rk3399, it supports the NV12, NV15, NV16 and NV20 output formats and level up to 5.1.
The maximum width and height have been significantly increased supporting up to 65520 pixels for both.
Also make sure to only expose the first core and ignore the other until mutli-core is supported.
Fluster score for JVT-AVC_V1 is 129/135.
--- .../media/platform/rockchip/rkvdec/Makefile | 1 + .../rockchip/rkvdec/rkvdec-h264-common.h | 2 + .../rockchip/rkvdec/rkvdec-vdpu381-h264.c | 469 ++++++++++++++++++ .../rockchip/rkvdec/rkvdec-vdpu381-regs.h | 427 ++++++++++++++++ .../media/platform/rockchip/rkvdec/rkvdec.c | 131 +++++ .../media/platform/rockchip/rkvdec/rkvdec.h | 4 + 6 files changed, 1034 insertions(+) create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-h264.c create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-regs.h
drivers/media/platform/rockchip/rkvdec/Makefile +1 -0
@@ -8,4 +8,5 @@ rockchip-vdec-y += \ rkvdec-hevc.o \ rkvdec-hevc-common.o \ rkvdec-rcb.o \ + rkvdec-vdpu381-h264.o \ rkvdec-vp9.o
drivers/media/platform/rockchip/rkvdec/rkvdec-h264-common.h +2 -0
@@ -68,6 +68,8 @@ struct rkvdec_rps {u32 reserved1[66 ]; } __packed; +extern const s8 rkvdec_h264_cabac_table[4 ][464 ][2 ]; +void lookup_ref_buf_idx (struct rkvdec_ctx *ctx,struct rkvdec_h264_run *run); void assemble_hw_rps(struct v4l2_h264_reflist_builder *builder, struct rkvdec_h264_run *run,
drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-h264.c new file +469 -0
469 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-regs.h new file +427 -0
427 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec.c +131 -0
190 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec.h +4 -0
@@ -132,6 +132,7 @@ struct rkvdec_dev {struct device *dev;struct clk_bulk_data *clocks;unsigned int clk_count; +struct clk *axi_clk;void __iomem *regs;struct mutex vdev_lock;/* serializes ioctls */ struct delayed_work watchdog_work;
@@ -150,6 +151,7 @@ struct rkvdec_ctx {struct rkvdec_dev *dev;enum rkvdec_image_fmt image_fmt;struct rkvdec_rcb_config *rcb_config; +u32 colmv_offset;void *priv; };
@@ -180,4 +182,6 @@ extern const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops;extern const struct rkvdec_coded_fmt_ops rkvdec_hevc_fmt_ops;extern const struct rkvdec_coded_fmt_ops rkvdec_vp9_fmt_ops; +extern const struct rkvdec_coded_fmt_ops rkvdec_vdpu381_h264_fmt_ops; +#endif /* RKVDEC_H_ */
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 13/15 media: rkvdec: Add H264 support for the VDPU383 variant
In reply to Detlev CasanovaThis variant is used on the RK3576 SoC.
The moving vectors size requirements are slightly different so support for a colmv_size function per variant is added.
Also, the link registers are used to start the decoder and read IRQ status. Per variant support for named register sections is added.
The fluster score is 128/135 for JVT-AVC_V1, with MPS_MW_A failing in addition to the usual ones.
The other test suites are not supported yet.
--- .../media/platform/rockchip/rkvdec/Makefile | 1 + .../rockchip/rkvdec/rkvdec-vdpu383-h264.c | 582 ++++++++++++++++++ .../rockchip/rkvdec/rkvdec-vdpu383-regs.h | 284 +++++++++ .../media/platform/rockchip/rkvdec/rkvdec.c | 118 +++- .../media/platform/rockchip/rkvdec/rkvdec.h | 8 + 5 files changed, 987 insertions(+), 6 deletions(-) create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-regs.h
drivers/media/platform/rockchip/rkvdec/Makefile +1 -0
@@ -9,4 +9,5 @@ rockchip-vdec-y += \ rkvdec-hevc-common.o \ rkvdec-rcb.o \ rkvdec-vdpu381-h264.o \ + rkvdec-vdpu383-h264.o \ rkvdec-vp9.o
drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c new file +582 -0
582 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-regs.h new file +284 -0
284 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec.c +112 -6
186 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec.h +8 -0
@@ -122,6 +122,8 @@ struct rkvdec_config {const struct rcb_size_info *rcb_size_info;size_t rcb_num;irqreturn_t (*irq_handler)(struct rkvdec_ctx *ctx); +u32 (*colmv_size)(u16 width,u16 height); +bool named_regs; };struct rkvdec_dev {
@@ -134,6 +136,7 @@ struct rkvdec_dev {unsigned int clk_count;struct clk *axi_clk;void __iomem *regs; +void __iomem *link;struct mutex vdev_lock;/* serializes ioctls */ struct delayed_work watchdog_work;struct gen_pool *sram_pool;
@@ -178,10 +181,15 @@ void rkvdec_memcpy_toio(void __iomem *dst, void *src, size_t len);void rkvdec_quirks_disable_qos (struct rkvdec_ctx *ctx); +/* RKVDEC ops */ extern const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops;extern const struct rkvdec_coded_fmt_ops rkvdec_hevc_fmt_ops;extern const struct rkvdec_coded_fmt_ops rkvdec_vp9_fmt_ops; +/* VDPU381 ops */ extern const struct rkvdec_coded_fmt_ops rkvdec_vdpu381_h264_fmt_ops; +/* VDPU383 ops */ +extern const struct rkvdec_coded_fmt_ops rkvdec_vdpu383_h264_fmt_ops; +#endif /* RKVDEC_H_ */
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 14/15 media: rkvdec: Add HEVC support for the VDPU381 variant
In reply to Detlev CasanovaThe VDPU381 supports HEVC decoding up to 7680x4320@30fps. It could double that when using both decoder cores.
It support YUV420 (8 and 10 bits) as well as AFBC (not implemented here)
The fluster score is 146/147 for JCT-VC-HEVC_V1, tested on ROCK 5B. None of the other test suites works.
--- .../media/platform/rockchip/rkvdec/Kconfig | 1 + .../media/platform/rockchip/rkvdec/Makefile | 1 + .../rockchip/rkvdec/rkvdec-hevc-common.c | 392 +++++++++++- .../rockchip/rkvdec/rkvdec-hevc-common.h | 74 ++- .../rockchip/rkvdec/rkvdec-vdpu381-hevc.c | 596 ++++++++++++++++++ .../media/platform/rockchip/rkvdec/rkvdec.c | 86 ++- .../media/platform/rockchip/rkvdec/rkvdec.h | 3 + 7 files changed, 1114 insertions(+), 39 deletions(-) create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
drivers/media/platform/rockchip/rkvdec/Kconfig +1 -0
@@ -8,6 +8,7 @@ config VIDEO_ROCKCHIP_VDEC select VIDEOBUF2_VMALLOC select V4L2_MEM2MEM_DEV select V4L2_H264 + select V4L2_HEVC select V4L2_VP9 help Support for the Rockchip Video Decoder IP present on Rockchip SoCs,
drivers/media/platform/rockchip/rkvdec/Makefile +1 -0
@@ -9,5 +9,6 @@ rockchip-vdec-y += \ rkvdec-hevc-common.o \ rkvdec-rcb.o \ rkvdec-vdpu381-h264.o \ + rkvdec-vdpu381-hevc.o \ rkvdec-vdpu383-h264.o \ rkvdec-vp9.o
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c +361 -31
441 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.h +67 -7
97 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c new file +596 -0
596 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec.c +85 -1
110 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec.h +3 -0
@@ -156,6 +156,8 @@ struct rkvdec_ctx {struct rkvdec_rcb_config *rcb_config;u32 colmv_offset;void *priv; + u8 has_sps_st_rps: 1; + u8 has_sps_lt_rps: 1; };static inline struct rkvdec_ctx *file_to_rkvdec_ctx (struct file *filp)
@@ -188,6 +190,7 @@ extern const struct rkvdec_coded_fmt_ops rkvdec_vp9_fmt_ops;/* VDPU381 ops */ extern const struct rkvdec_coded_fmt_ops rkvdec_vdpu381_h264_fmt_ops; +extern const struct rkvdec_coded_fmt_ops rkvdec_vdpu381_hevc_fmt_ops;/* VDPU383 ops */ extern const struct rkvdec_coded_fmt_ops rkvdec_vdpu383_h264_fmt_ops;
Signature · 1 line
2.51.1.dirty
Detlev Casanova
maintainerPATCH v3 15/15 media: rkvdec: Add HEVC support for the VDPU383 variant
In reply to Detlev CasanovaThe VDPU383 decoder is used on the RK3576 SoC and has support for HEVC.
This patch also moves some functions to a common rkvdec-hevc-common.c file and adds a specific scaling matrix flatten function.
The fluster score for JCT-VC-HEVC_V1 is 146/147.
--- .../media/platform/rockchip/rkvdec/Makefile | 1 + .../rockchip/rkvdec/rkvdec-hevc-common.c | 60 +- .../rockchip/rkvdec/rkvdec-hevc-common.h | 3 +- .../platform/rockchip/rkvdec/rkvdec-hevc.c | 2 +- .../rockchip/rkvdec/rkvdec-vdpu381-hevc.c | 3 +- .../rockchip/rkvdec/rkvdec-vdpu383-hevc.c | 690 ++++++++++++++++++ .../media/platform/rockchip/rkvdec/rkvdec.c | 94 ++- .../media/platform/rockchip/rkvdec/rkvdec.h | 2 + 8 files changed, 804 insertions(+), 51 deletions(-) create mode 100644 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c
drivers/media/platform/rockchip/rkvdec/Makefile +1 -0
@@ -11,4 +11,5 @@ rockchip-vdec-y += \ rkvdec-vdpu381-h264.o \ rkvdec-vdpu381-hevc.o \ rkvdec-vdpu383-h264.o \ + rkvdec-vdpu383-hevc.o \ rkvdec-vp9.o
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c +14 -46
95 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.h +2 -1
@@ -99,7 +99,8 @@ void compute_tiles_non_uniform(struct rkvdec_hevc_run *run, u16 log2_min_cb_size s32 pic_in_cts_height, u16 *column_width, u16 *row_height);void rkvdec_hevc_assemble_hw_rps (struct rkvdec_hevc_run *run,struct rkvdec_rps *rps,struct v4l2_ctrl_hevc_ext_sps_st_rps *st_cache); -void rkvdec_hevc_assemble_hw_scaling_list (struct rkvdec_hevc_run *run, +void rkvdec_hevc_assemble_hw_scaling_list (struct rkvdec_ctx *ctx, +struct rkvdec_hevc_run *run,struct scaling_factor *scaling_factor,struct v4l2_ctrl_hevc_scaling_matrix *cache); struct vb2_buffer *get_ref_buf(struct rkvdec_ctx *ctx,
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c +1 -1
@@ -546,7 +546,7 @@ static int rkvdec_hevc_run(struct rkvdec_ctx *ctx)rkvdec_hevc_run_preamble (ctx, &run); -rkvdec_hevc_assemble_hw_scaling_list (&run, &tbl->scaling_list, +rkvdec_hevc_assemble_hw_scaling_list (ctx, &run, &tbl->scaling_list, &hevc_ctx->scaling_matrix_cache);assemble_hw_pps (ctx, &run);assemble_sw_rps (ctx, &run);
drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c +1 -2
@@ -568,8 +568,7 @@ static int rkvdec_hevc_run(struct rkvdec_ctx *ctx)dev_warn_ratelimited (rkvdec->dev,"Long and short term RPS not set\n" ); } -rkvdec_hevc_assemble_hw_scaling_list (&run, - &tbl->scaling_list, +rkvdec_hevc_assemble_hw_scaling_list (ctx, &run, &tbl->scaling_list, &hevc_ctx->scaling_matrix_cache);assemble_hw_pps (ctx, &run);rkvdec_hevc_assemble_hw_rps (&run, &tbl->rps, &hevc_ctx->st_cache);
drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c new file +690 -0
690 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec.c +93 -1
130 lines not on this page · raw message
drivers/media/platform/rockchip/rkvdec/rkvdec.h +2 -0
@@ -123,6 +123,7 @@ struct rkvdec_config {size_t rcb_num;irqreturn_t (*irq_handler)(struct rkvdec_ctx *ctx);u32 (*colmv_size)(u16 width,u16 height); +void (*flatten_matrices)(u8 *output,const u8 *input,int matrices,int row_length);bool named_regs; };
@@ -194,5 +195,6 @@ extern const struct rkvdec_coded_fmt_ops rkvdec_vdpu381_hevc_fmt_ops;/* VDPU383 ops */ extern const struct rkvdec_coded_fmt_ops rkvdec_vdpu383_h264_fmt_ops; +extern const struct rkvdec_coded_fmt_ops rkvdec_vdpu383_hevc_fmt_ops;#endif /* RKVDEC_H_ */
Signature · 1 line
2.51.1.dirty