media: rockchip: Add the rkvdec driver
Subsystems (7)
v3 cover media: rockchip: Add the rkvdec driver
Hello,
This is v3 of the rkvdec driver adding both the core of the driver and a backend to decode H24 streams.
The most notable change in this version is the addition of generic helpers to build the reflists, along with Jonas' patch adding new DPB flags to express the field being referenced by each DPB entry.
Driver-wise, a few things have been reworked/clarified, but most of the code is unchanged. See the changelog attached to each patch for more details.
Regards,
Boris
Boris Brezillon (6):
media: vb2: Add a helper to get the vb2 buffer attached to a request
media: v4l2-core: Add helpers to build the H264 P/B0/B1 reflists
media: hantro: h264: Use the generic H264 reflist builder
media: dt-bindings: rockchip: Document RK3399 Video Decoder bindings
media: rkvdec: Add the rkvdec driver
arm64: dts: rockchip: rk3399: Define the rockchip Video Decoder node
Jonas Karlman (1):
media: uapi: h264: Add DPB entry field reference flags
.../bindings/media/rockchip,vdec.yaml | 71 + .../media/uapi/v4l/ext-ctrls-codec.rst | 16 + arch/arm64/boot/dts/rockchip/rk3399.dtsi | 14 +- .../media/common/videobuf2/videobuf2-core.c | 23 + drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-h264.c | 258 ++++ drivers/staging/media/Kconfig | 2 + drivers/staging/media/Makefile | 1 + drivers/staging/media/hantro/hantro_h264.c | 237 +--- drivers/staging/media/rkvdec/Kconfig | 15 + drivers/staging/media/rkvdec/Makefile | 3 + drivers/staging/media/rkvdec/rkvdec-h264.c | 1154 +++++++++++++++++ drivers/staging/media/rkvdec/rkvdec-regs.h | 239 ++++ drivers/staging/media/rkvdec/rkvdec.c | 1130 ++++++++++++++++ drivers/staging/media/rkvdec/rkvdec.h | 124 ++ include/media/h264-ctrls.h | 2 + include/media/v4l2-h264.h | 86 ++ include/media/videobuf2-core.h | 11 + 19 files changed, 3161 insertions(+), 230 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/rockchip,vdec.yaml create mode 100644 drivers/media/v4l2-core/v4l2-h264.c create mode 100644 drivers/staging/media/rkvdec/Kconfig create mode 100644 drivers/staging/media/rkvdec/Makefile create mode 100644 drivers/staging/media/rkvdec/rkvdec-h264.c create mode 100644 drivers/staging/media/rkvdec/rkvdec-regs.h create mode 100644 drivers/staging/media/rkvdec/rkvdec.c create mode 100644 drivers/staging/media/rkvdec/rkvdec.h create mode 100644 include/media/v4l2-h264.h
Signature · 1 line
2.23.0
PATCH v3 1/7 media: vb2: Add a helper to get the vb2 buffer attached to a request
vb2_request_get_buf() returns the N-th buffer attached to a media request.
---
Changes in v3:
* None
Changes in v2:
* Adjust the kernel doc as suggested by Hans
--- .../media/common/videobuf2/videobuf2-core.c | 23 +++++++++++++++++++ include/media/videobuf2-core.h | 11 +++++++++ 2 files changed, 34 insertions(+)
drivers/media/common/videobuf2/videobuf2-core.c +23 -0
@@ -1416,6 +1416,29 @@ unsigned int vb2_request_buffer_cnt(struct media_request *req) }EXPORT_SYMBOL_GPL (vb2_request_buffer_cnt); +struct vb2_buffer *vb2_request_get_buf (struct media_request *req, +unsigned int n) +{ +struct media_request_object *obj; +struct vb2_buffer *buf =NULL ; +unsigned int nbufs =0 ; +unsigned long flags; + +spin_lock_irqsave (&req->lock, flags); +list_for_each_entry (obj, &req->objects, list) { +if (!vb2_request_object_is_buffer (obj) || + nbufs++ < n) +continue ; + + buf = container_of(obj, struct vb2_buffer, req_obj); +break ; + } +spin_unlock_irqrestore (&req->lock, flags); + +return buf; +} +EXPORT_SYMBOL_GPL (vb2_request_get_buf); +int vb2_core_prepare_buf (struct vb2_queue *q,unsigned int index,void *pb) {struct vb2_buffer *vb;
include/media/videobuf2-core.h +11 -0
@@ -1225,4 +1225,15 @@ bool vb2_request_object_is_buffer(struct media_request_object *obj);*/ unsigned int vb2_request_buffer_cnt (struct media_request *req); +/** +* vb2_request_get_buf() - return the buffer at index @idx +* +* @req: the request. +* @n: search for the Nth buffer in the req object list +* +* Return a vb2 buffer or NULL if there's no buffer at the specified position +*/ +struct vb2_buffer *vb2_request_get_buf (struct media_request *req, +unsigned int n); +#endif /* _MEDIA_VIDEOBUF2_CORE_H */
Signature · 1 line
2.23.0
Re: [PATCH v3 1/7] media: vb2: Add a helper to get the vb2 buffer attached to a request
Hi Boris,
Quoted 54 lines · Boris Brezillon
vb2_request_get_buf()returns the N-th buffer attached to a media request.---
Changes in v3:
* NoneChanges in v2:
* Adjust the kernel doc as suggested by Hans--- .../media/common/videobuf2/videobuf2-core.c | 23 +++++++++++++++++++ include/media/videobuf2-core.h | 11 +++++++++ 2 files changed, 34 insertions(+)drivers/media/common/videobuf2/videobuf2-core.c +23
-0@@ -1416,6 +1416,29 @@ unsigned int vb2_request_buffer_cnt(struct media_request *req) }EXPORT_SYMBOL_GPL (vb2_request_buffer_cnt); +struct vb2_buffer *vb2_request_get_buf (struct media_request *req, +unsigned int n) +{ +struct media_request_object *obj; +struct vb2_buffer *buf =NULL ; +unsigned int nbufs =0 ; +unsigned long flags; + +spin_lock_irqsave (&req->lock, flags); +list_for_each_entry (obj, &req->objects, list) { +if (!vb2_request_object_is_buffer (obj) || + nbufs++ < n) +continue ; + + buf = container_of(obj, struct vb2_buffer, req_obj); +break ; + } +spin_unlock_irqrestore (&req->lock, flags); + +return buf; +} +EXPORT_SYMBOL_GPL (vb2_request_get_buf); +int vb2_core_prepare_buf (struct vb2_queue *q,unsigned int index,void *pb) {struct vb2_buffer *vb;include/media/videobuf2-core.h +0
-0
include/media/videobuf2-core.h bool vb2_request_object_is_buffer(struct media_request_object *obj); · line 1232
Quoted 8 lines
include/media/videobuf2-core.h +5
-0@@ -1225,4 +1225,15 @@ bool vb2_request_object_is_buffer(struct media_request_object *obj);*/ unsigned int vb2_request_buffer_cnt (struct media_request *req); +/** +* vb2_request_get_buf() - return the buffer at index @idx +* +* @req: the request. +* @n: search for the Nth buffer in the req object list
It's not very clear to me what "n" is here. Wouldn't it be better to pass the queue pointer instead, to get a buffer for a given queue ?
Quoted 7 lines
include/media/videobuf2-core.h +6
-0+* +* Return a vb2 buffer or NULL if there's no buffer at the specified position +*/ +struct vb2_buffer *vb2_request_get_buf (struct media_request *req, +unsigned int n); +#endif /* _MEDIA_VIDEOBUF2_CORE_H */
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v3 1/7] media: vb2: Add a helper to get the vb2 buffer attached to a request
Quoted 60 lines · On Fri, 13 Dec 2019 17:09:35 +0200 Laurent Pinchart…
Hi Boris,
Quoted 57 lines · Boris Brezillon
vb2_request_get_buf()returns the N-th buffer attached to a media request.---
Changes in v3:
* NoneChanges in v2:
* Adjust the kernel doc as suggested by Hans--- .../media/common/videobuf2/videobuf2-core.c | 23 +++++++++++++++++++ include/media/videobuf2-core.h | 11 +++++++++ 2 files changed, 34 insertions(+)drivers/media/common/videobuf2/videobuf2-core.c +23
-0@@ -1416,6 +1416,29 @@ unsigned int vb2_request_buffer_cnt(struct media_request *req) }EXPORT_SYMBOL_GPL (vb2_request_buffer_cnt); +struct vb2_buffer *vb2_request_get_buf (struct media_request *req, +unsigned int n) +{ +struct media_request_object *obj; +struct vb2_buffer *buf =NULL ; +unsigned int nbufs =0 ; +unsigned long flags; + +spin_lock_irqsave (&req->lock, flags); +list_for_each_entry (obj, &req->objects, list) { +if (!vb2_request_object_is_buffer (obj) || + nbufs++ < n) +continue ; + + buf = container_of(obj, struct vb2_buffer, req_obj); +break ; + } +spin_unlock_irqrestore (&req->lock, flags); + +return buf; +} +EXPORT_SYMBOL_GPL (vb2_request_get_buf); +int vb2_core_prepare_buf (struct vb2_queue *q,unsigned int index,void *pb) {struct vb2_buffer *vb;include/media/videobuf2-core.h +0
-0@@ -1225,4 +1225,15 @@ bool vb2_request_object_is_buffer(struct media_request_object *obj);*/ unsigned int vb2_request_buffer_cnt (struct media_request *req);
Quoted 8 lines
include/media/videobuf2-core.h bool vb2_request_object_is_buffer(struct media_request_object *obj); · line 1232
Quoted 5 lines
include/media/videobuf2-core.h +5
-0+/** +* vb2_request_get_buf() - return the buffer at index @idx +* +* @req: the request. +* @n: search for the Nth buffer in the req object list It's not very clear to me what "n" is here. Wouldn't it be better to pass the queue pointer instead, to get a buffer for a given queue ?
Yep, that would work too and would be much clearer. I'll do that, thanks for the suggestion.
PATCH v3 2/7 media: uapi: h264: Add DPB entry field reference flags
In reply to Boris BrezillonFrom: Jonas Karlman <[email protected]>
Using the field information attached to v4l2 buffers is not enough to determine the type of field referenced by a DPB entry: the decoded frame might contain the full picture (both top and bottom fields) but the reference only point to one of them.
Let's add new V4L2_H264_DPB_ENTRY_FLAG_ flags to express that.
---
Changes in v3:
* This patch was previously part of https://lkml.org/lkml/2019/10/28/956
* Kept the FIELD and BOTTOM_FIELD flags
* Updated the doc with more details
--- Documentation/media/uapi/v4l/ext-ctrls-codec.rst | 16 ++++++++++++++++ include/media/h264-ctrls.h | 2 ++ 2 files changed, 18 insertions(+)
Documentation/media/uapi/v4l/ext-ctrls-codec.rst +16 -0
@@ -2028,6 +2028,22 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - ``V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM`` - 0x00000004 - The DPB entry is a long term reference frame + * - ``V4L2_H264_DPB_ENTRY_FLAG_FIELD`` + - 0x00000008 + - The DPB entry is a field reference, which means only one of the field + will be used when decoding the new frame/field. When not set the DPB + entry is a frame reference (both fields will be used). Note that this + flag does not say anything about the number of fields contained in the + reference frame, it just describes the one used to decode the new + field/frame + * - ``V4L2_H264_DPB_ENTRY_FLAG_BOTTOM_FIELD`` + - 0x00000010 + - The DPB entry is a bottom field reference (only the bottom field of the + reference frame is needed to decode the new frame/field). Only valid if + V4L2_H264_DPB_ENTRY_FLAG_FIELD is set. When + V4L2_H264_DPB_ENTRY_FLAG_FIELD is set but + V4L2_H264_DPB_ENTRY_FLAG_BOTTOM_FIELD is not, that means the + DPB entry is a top field reference ``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (enum)`` Specifies the decoding mode to use. Currently exposes slice-based and
include/media/h264-ctrls.h +2 -0
@@ -185,6 +185,8 @@ struct v4l2_ctrl_h264_slice_params {#define V4L2_H264_DPB_ENTRY_FLAG_VALID 0x01#define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x02#define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x04 +#define V4L2_H264_DPB_ENTRY_FLAG_FIELD 0x08 +#define V4L2_H264_DPB_ENTRY_FLAG_BOTTOM_FIELD 0x10struct v4l2_h264_dpb_entry {__u64 reference_ts;
Signature · 1 line
2.23.0
PATCH v3 3/7 media: v4l2-core: Add helpers to build the H264 P/B0/B1 reflists
In reply to Boris BrezillonBuilding those list is a standard procedure described in section '8.2.4 Decoding process for reference picture lists construction' of the H264 specification.
We already have 2 drivers needing the same logic (hantro and rkvdec) and I suspect we will soon have more.
Let's provide generic helpers to create those lists.
---
Changes in v3:
* New patch
--- drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-h264.c | 258 ++++++++++++++++++++++++++++ include/media/v4l2-h264.h | 86 ++++++++++ 4 files changed, 349 insertions(+) create mode 100644 drivers/media/v4l2-core/v4l2-h264.c create mode 100644 include/media/v4l2-h264.h
drivers/media/v4l2-core/Kconfig +4 -0
@@ -45,6 +45,10 @@ config VIDEO_PCI_SKELETON config VIDEO_TUNER tristate +# Used by drivers that need v4l2-h264.ko +config V4L2_H264 + tristate + # Used by drivers that need v4l2-mem2mem.ko config V4L2_MEM2MEM_DEV tristate
drivers/media/v4l2-core/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_VIDEO_V4L2) += v4l2-dv-timings.o obj-$(CONFIG_VIDEO_TUNER) += tuner.o obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o +obj-$(CONFIG_V4L2_H264) += v4l2-h264.o obj-$(CONFIG_V4L2_FLASH_LED_CLASS) += v4l2-flash-led-class.o
drivers/media/v4l2-core/v4l2-h264.c new file +258 -0
258 lines not on this page · raw message
include/media/v4l2-h264.h new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH v3 4/7 media: hantro: h264: Use the generic H264 reflist builder
In reply to Boris BrezillonNow that the core provides generic reflist builders, we can use them instead of implementing our own.
---
Changes in v3:
* New patch
--- drivers/staging/media/hantro/hantro_h264.c | 237 +-------------------- 1 file changed, 8 insertions(+), 229 deletions(-)
drivers/staging/media/hantro/hantro_h264.c +8 -229
@@ -11,7 +11,7 @@*/ #include <linux/types.h> -#include <linux/sort.h> +#include <media/v4l2-h264.h> #include <media/v4l2-mem2mem.h> #include "hantro.h"
@@ -240,229 +240,6 @@ static void prepare_table(struct hantro_ctx *ctx)reorder_scaling_list (ctx); } -struct hantro_h264_reflist_builder { -const struct v4l2_h264_dpb_entry *dpb; -s32 pocs[HANTRO_H264_DPB_SIZE ]; -u8 unordered_reflist[HANTRO_H264_DPB_SIZE ]; -int frame_nums[HANTRO_H264_DPB_SIZE ]; -s32 curpoc; -u8 num_valid; -}; - -static s32 get_poc (enum v4l2_field field,s32 top_field_order_cnt, -s32 bottom_field_order_cnt) -{ -switch (field) { -case V4L2_FIELD_TOP : -return top_field_order_cnt; -case V4L2_FIELD_BOTTOM : -return bottom_field_order_cnt; -default : -break ; - } - -return min (top_field_order_cnt, bottom_field_order_cnt); -} - -static void -init_reflist_builder (struct hantro_ctx *ctx, -struct hantro_h264_reflist_builder *b) -{ -const struct v4l2_ctrl_h264_slice_params *slice_params; -const struct v4l2_ctrl_h264_decode_params *dec_param; -const struct v4l2_ctrl_h264_sps *sps; -struct vb2_v4l2_buffer *buf =hantro_get_dst_buf (ctx); -const struct v4l2_h264_dpb_entry *dpb = ctx->h264_dec.dpb; -struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q; -int cur_frame_num, max_frame_num; -unsigned int i; - - dec_param = ctx->h264_dec.ctrls.decode; - slice_params = &ctx->h264_dec.ctrls.slices[0 ]; - sps = ctx->h264_dec.ctrls.sps; - max_frame_num =1 << (sps->log2_max_frame_num_minus4 +4 ); - cur_frame_num = slice_params->frame_num; - -memset (b,0 ,sizeof (*b)); - b->dpb = dpb; - b->curpoc =get_poc (buf->field, dec_param->top_field_order_cnt, - dec_param->bottom_field_order_cnt); - -for (i =0 ; i <ARRAY_SIZE (ctx->h264_dec.dpb); i++) { -int buf_idx; - -if (!(dpb[i].flags &V4L2_H264_DPB_ENTRY_FLAG_ACTIVE )) -continue ; - - buf_idx =vb2_find_timestamp (cap_q, dpb[i].reference_ts,0 ); -if (buf_idx <0 ) -continue ; - - buf =to_vb2_v4l2_buffer (vb2_get_buffer (cap_q, buf_idx)); - -/* -* Handle frame_num wraparound as described in section -* '8.2.4.1 Decoding process for picture numbers' of the spec. -* TODO: This logic will have to be adjusted when we start -* supporting interlaced content. -*/ -if (dpb[i].frame_num > cur_frame_num) - b->frame_nums[i] = (int )dpb[i].frame_num - max_frame_num; -else - b->frame_nums[i] = dpb[i].frame_num; - - b->pocs[i] =get_poc (buf->field, dpb[i].top_field_order_cnt, - dpb[i].bottom_field_order_cnt); - b->unordered_reflist[b->num_valid] = i; - b->num_valid++; - } - -for (i = b->num_valid; i <ARRAY_SIZE (ctx->h264_dec.dpb); i++) - b->unordered_reflist[i] = i; -} - -static int p_ref_list_cmp (const void *ptra,const void *ptrb,const void *data) -{ -const struct hantro_h264_reflist_builder *builder = data; -const struct v4l2_h264_dpb_entry *a, *b; -u8 idxa, idxb; - - idxa = *((u8 *)ptra); - idxb = *((u8 *)ptrb); - a = &builder->dpb[idxa]; - b = &builder->dpb[idxb]; - -if ((a->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM ) != - (b->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM )) { -/* Short term pics firt. */ -if (!(a->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM )) -return -1 ; -else -return 1 ; - } - -/* -* Short term pics in descending pic num order, long term ones in -* ascending order. -*/ -if (!(a->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM )) -return HANTRO_CMP (builder->frame_nums[idxb], - builder->frame_nums[idxa]); - -return HANTRO_CMP (a->pic_num, b->pic_num); -} - -static int b0_ref_list_cmp (const void *ptra,const void *ptrb,const void *data) -{ -const struct hantro_h264_reflist_builder *builder = data; -const struct v4l2_h264_dpb_entry *a, *b; -s32 poca, pocb; -u8 idxa, idxb; - - idxa = *((u8 *)ptra); - idxb = *((u8 *)ptrb); - a = &builder->dpb[idxa]; - b = &builder->dpb[idxb]; - -if ((a->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM ) != - (b->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM )) { -/* Short term pics firt. */ -if (!(a->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM )) -return -1 ; -else -return 1 ; - } - -/* Long term pics in ascending pic num order. */ -if (a->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM ) -return HANTRO_CMP (a->pic_num, b->pic_num); - - poca = builder->pocs[idxa]; - pocb = builder->pocs[idxb]; - -/* -* Short term pics with POC < cur POC first in POC descending order -* followed by short term pics with POC > cur POC in POC ascending -* order. -*/ -if ((poca < builder->curpoc) != (pocb < builder->curpoc)) -return HANTRO_CMP (poca, pocb); -else if (poca < builder->curpoc) -return HANTRO_CMP (pocb, poca); - -return HANTRO_CMP (poca, pocb); -} - -static int b1_ref_list_cmp (const void *ptra,const void *ptrb,const void *data) -{ -const struct hantro_h264_reflist_builder *builder = data; -const struct v4l2_h264_dpb_entry *a, *b; -s32 poca, pocb; -u8 idxa, idxb; - - idxa = *((u8 *)ptra); - idxb = *((u8 *)ptrb); - a = &builder->dpb[idxa]; - b = &builder->dpb[idxb]; - -if ((a->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM ) != - (b->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM )) { -/* Short term pics firt. */ -if (!(a->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM )) -return -1 ; -else -return 1 ; - } - -/* Long term pics in ascending pic num order. */ -if (a->flags &V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM ) -return HANTRO_CMP (a->pic_num, b->pic_num); - - poca = builder->pocs[idxa]; - pocb = builder->pocs[idxb]; - -/* -* Short term pics with POC > cur POC first in POC ascending order -* followed by short term pics with POC < cur POC in POC descending -* order. -*/ -if ((poca < builder->curpoc) != (pocb < builder->curpoc)) -return HANTRO_CMP (pocb, poca); -else if (poca < builder->curpoc) -return HANTRO_CMP (pocb, poca); - -return HANTRO_CMP (poca, pocb); -} - -static void -build_p_ref_list (const struct hantro_h264_reflist_builder *builder, -u8 *reflist) -{ -memcpy (reflist, builder->unordered_reflist, -sizeof (builder->unordered_reflist)); -sort_r (reflist, builder->num_valid,sizeof (*reflist), - p_ref_list_cmp,NULL , builder); -} - -static void -build_b_ref_lists (const struct hantro_h264_reflist_builder *builder, -u8 *b0_reflist,u8 *b1_reflist) -{ -memcpy (b0_reflist, builder->unordered_reflist, -sizeof (builder->unordered_reflist)); -sort_r (b0_reflist, builder->num_valid,sizeof (*b0_reflist), - b0_ref_list_cmp,NULL , builder); - -memcpy (b1_reflist, builder->unordered_reflist, -sizeof (builder->unordered_reflist)); -sort_r (b1_reflist, builder->num_valid,sizeof (*b1_reflist), - b1_ref_list_cmp,NULL , builder); - -if (builder->num_valid >1 && - !memcmp (b1_reflist, b0_reflist, builder->num_valid)) -swap (b1_reflist[0 ], b1_reflist[1 ]); -} -static bool dpb_entry_match (const struct v4l2_h264_dpb_entry *a,const struct v4l2_h264_dpb_entry *b) {
@@ -560,7 +337,7 @@ int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx) {struct hantro_h264_dec_hw_ctx *h264_ctx = &ctx->h264_dec;struct hantro_h264_dec_ctrls *ctrls = &h264_ctx->ctrls; -struct hantro_h264_reflist_builder reflist_builder; +struct v4l2_h264_reflist_builder reflist_builder;hantro_prepare_run (ctx);
@@ -596,10 +373,12 @@ int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx)prepare_table (ctx);/* Build the P/B{0,1} ref lists. */ -init_reflist_builder (ctx, &reflist_builder); -build_p_ref_list (&reflist_builder, h264_ctx->reflists.p); -build_b_ref_lists (&reflist_builder, h264_ctx->reflists.b0, - h264_ctx->reflists.b1); +v4l2_h264_init_reflist_builder (&reflist_builder, ctrls->decode, + &ctrls->slices[0 ], ctrls->sps, + ctx->h264_dec.dpb); +v4l2_h264_build_p_ref_list (&reflist_builder, h264_ctx->reflists.p); +v4l2_h264_build_b_ref_lists (&reflist_builder, h264_ctx->reflists.b0, + h264_ctx->reflists.b1);return 0 ; }
Signature · 1 line
2.23.0
Re: [PATCH v3 4/7] media: hantro: h264: Use the generic H264 reflist builder
Hi Boris,
Quoted 18 lines · Boris Brezillon
Now that the core provides generic reflist builders, we can use them instead of implementing our own.
---
Changes in v3:
* New patch
---drivers/staging/media/hantro/hantro_h264.c| 237 +--------------------1 file changed, 8 insertions(+), 229 deletions(-)drivers/staging/media/hantro/hantro_h264.c +0
-0
drivers/staging/media/hantro/hantro_h264.c line 14
Quoted 5 lines
drivers/staging/media/hantro/hantro_h264.c +1
-1@@ -11,7 +11,7 @@*/ #include <linux/types.h> -#include <linux/sort.h> +#include <media/v4l2-h264.h>
With this patch, CONFIG_VIDEO_HANTRO needs to depend on CONFIG_V4L2_H264, without that it can encounter linking errors due to missing symbols for v4l2_h264_init_reflist_builder, etc.
drivers/staging/media/hantro/hantro_h264.c static void prepare_table(struct hantro_ctx *ctx) · line 241
Quoted 6 lines
drivers/staging/media/hantro/hantro_h264.c +0
-0#include <media/v4l2-mem2mem.h> #include "hantro.h" @@ -240,229 +240,6 @@ static void prepare_table(struct hantro_ctx *ctx)reorder_scaling_list (ctx); }
--
Regards,
Hugh Cole-Baker
Re: [PATCH v3 4/7] media: hantro: h264: Use the generic H264 reflist builder
Quoted 22 lines · On Sat, 14 Dec 2019 15:46:35 +0000 Hugh Cole-Baker…
Hi Boris,
Quoted 20 lines · Boris Brezillon
Now that the core provides generic reflist builders, we can use them instead of implementing our own.
---
Changes in v3:
* New patch
---drivers/staging/media/hantro/hantro_h264.c| 237 +--------------------1 file changed, 8 insertions(+), 229 deletions(-)drivers/staging/media/hantro/hantro_h264.c +0
-0@@ -11,7 +11,7 @@*/
Quoted 7 lines
drivers/staging/media/hantro/hantro_h264.c line 14
Quoted 3 lines
drivers/staging/media/hantro/hantro_h264.c +1
-1#include <linux/types.h> -#include <linux/sort.h> +#include <media/v4l2-h264.h> With this patch,
CONFIG_VIDEO_HANTROneeds to depend onCONFIG_V4L2_H264, without that it can encounter linking errors due to missing symbols forv4l2_h264_init_reflist_builder, etc.
Oops, you're right (I didn't notice it since I had it selected by CONFIG_VIDEO_ROCKCHIP_VDEC). I'll fix that in v4.
Thanks,
Boris
PATCH v3 5/7 media: dt-bindings: rockchip: Document RK3399 Video Decoder bindings
In reply to Boris BrezillonDocument the Rockchip RK3399 Video Decoder bindings.
---
Changes in v3:
* Fix dtbs_check failures
--- .../bindings/media/rockchip,vdec.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip,vdec.yaml
Documentation/devicetree/bindings/media/rockchip,vdec.yaml new file +71 -0
@@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/rockchip,vdec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip Video Decoder (VDec) Device Tree Bindings + +maintainers: + - Heiko Stuebner <[email protected]> + +description: |- + The Rockchip rk3399 has a stateless Video Decoder that can decodes H.264, + HEVC an VP9 streams. + +properties: + compatible: + const: rockchip,rk3399-vdec + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: The Video Decoder AXI interface clock + - description: The Video Decoder AHB interface clock + - description: The Video Decoded CABAC clock + - description: The Video Decoder core clock + + clock-names: + items: + - const: aclk + - const: iface + - const: cabac + - const: core + + power-domains: + maxItems: 1 + + iommus: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - power-domains + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + vdec: video-codec@ff660000 { + compatible = "rockchip,rk3399-vdec"; + reg = <0x0 0xff660000 0x0 0x400>; + interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&cru ACLK_VDU>, <&cru HCLK_VDU>, + <&cru SCLK_VDU_CA>, <&cru SCLK_VDU_CORE>; + clock-names = "aclk", "iface", "cabac", "core"; + power-domains = <&power RK3399_PD_VDU>; + iommus = <&vdec_mmu>; + }; + +...
Signature · 1 line
2.23.0
Re: [PATCH v3 5/7] media: dt-bindings: rockchip: Document RK3399 Video Decoder bindings
Hi Boris,
Thank you for the patch.
Quoted 42 lines · Boris Brezillon
Document the Rockchip RK3399 Video Decoder bindings.
---
Changes in v3:
* Fixdtbs_checkfailures--- .../bindings/media/rockchip,vdec.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip,vdec.yamlDocumentation/devicetree/bindings/media/rockchip,vdec.yaml new file +25
-0@@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/rockchip,vdec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip Video Decoder (VDec) Device Tree Bindings + +maintainers: + - Heiko Stuebner <[email protected]> + +description: |- + The Rockchip rk3399 has a stateless Video Decoder that can decodes H.264, + HEVC an VP9 streams. + +properties: + compatible: + const: rockchip,rk3399-vdec + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 +
Documentation/devicetree/bindings/media/rockchip,vdec.yaml line 35
Quoted 10 lines
Documentation/devicetree/bindings/media/rockchip,vdec.yaml new file +10
-0+ clocks: + items: + - description: The Video Decoder AXI interface clock + - description: The Video Decoder AHB interface clock + - description: The Video Decoded CABAC clock + - description: The Video Decoder core clock + + clock-names: + items: + - const: aclk
How about calling it "axi" ? None of the other clock names have "clk".
Documentation/devicetree/bindings/media/rockchip,vdec.yaml line 36
Quoted 1 line
Documentation/devicetree/bindings/media/rockchip,vdec.yaml new file +1
-0+ - const: iface
And "ahb" here, as the AXI interface clock is also an interface clock ?
Quoted 35 lines
Documentation/devicetree/bindings/media/rockchip,vdec.yaml new file +35
-0+ - const: cabac + - const: core + + power-domains: + maxItems: 1 + + iommus: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - power-domains + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + vdec: video-codec@ff660000 { + compatible = "rockchip,rk3399-vdec"; + reg = <0x0 0xff660000 0x0 0x400>; + interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&cru ACLK_VDU>, <&cru HCLK_VDU>, + <&cru SCLK_VDU_CA>, <&cru SCLK_VDU_CORE>; + clock-names = "aclk", "iface", "cabac", "core"; + power-domains = <&power RK3399_PD_VDU>; + iommus = <&vdec_mmu>; + }; + +...
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v3 5/7] media: dt-bindings: rockchip: Document RK3399 Video Decoder bindings
Quoted 60 lines · On Fri, 13 Dec 2019 17:23:32 +0200 Laurent Pinchart…
Hi Boris,
Thank you for the patch.
Quoted 42 lines · Boris Brezillon
Document the Rockchip RK3399 Video Decoder bindings.
---
Changes in v3:
* Fixdtbs_checkfailures--- .../bindings/media/rockchip,vdec.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip,vdec.yamlDocumentation/devicetree/bindings/media/rockchip,vdec.yaml new file +25
-0@@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/rockchip,vdec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip Video Decoder (VDec) Device Tree Bindings + +maintainers: + - Heiko Stuebner <[email protected]> + +description: |- + The Rockchip rk3399 has a stateless Video Decoder that can decodes H.264, + HEVC an VP9 streams. + +properties: + compatible: + const: rockchip,rk3399-vdec + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 +Documentation/devicetree/bindings/media/rockchip,vdec.yaml line 35
Quoted 10 lines
Documentation/devicetree/bindings/media/rockchip,vdec.yaml new file +10
-0+ clocks: + items: + - description: The Video Decoder AXI interface clock + - description: The Video Decoder AHB interface clock + - description: The Video Decoded CABAC clock + - description: The Video Decoder core clock + + clock-names: + items: + - const: aclkHow about calling it "axi" ? None of the other clock names have "clk".
Quoted 3 lines
Documentation/devicetree/bindings/media/rockchip,vdec.yaml line 36
Quoted 1 line
Documentation/devicetree/bindings/media/rockchip,vdec.yaml new file +1
-0+ - const: ifaceAnd "ahb" here, as the AXI interface clock is also an interface clock ?
Sure, I can do that.
Re: [PATCH v3 5/7] media: dt-bindings: rockchip: Document RK3399 Video Decoder bindings
Quoted 64 lines · Boris Brezillon
Quoted 60 lines · On Fri, 13 Dec 2019 17:23:32 +0200 Laurent Pinchart…
Hi Boris,
Thank you for the patch.
Quoted 42 lines · Boris Brezillon
Document the Rockchip RK3399 Video Decoder bindings.
---
Changes in v3:
* Fixdtbs_checkfailures--- .../bindings/media/rockchip,vdec.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip,vdec.yamlDocumentation/devicetree/bindings/media/rockchip,vdec.yaml new file +25
-0@@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/rockchip,vdec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip Video Decoder (VDec) Device Tree Bindings + +maintainers: + - Heiko Stuebner <[email protected]> + +description: |- + The Rockchip rk3399 has a stateless Video Decoder that can decodes H.264, + HEVC an VP9 streams. + +properties: + compatible: + const: rockchip,rk3399-vdec + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 +Documentation/devicetree/bindings/media/rockchip,vdec.yaml line 35
Quoted 10 lines
Documentation/devicetree/bindings/media/rockchip,vdec.yaml new file +10
-0+ clocks: + items: + - description: The Video Decoder AXI interface clock + - description: The Video Decoder AHB interface clock + - description: The Video Decoded CABAC clock + - description: The Video Decoder core clock + + clock-names: + items: + - const: aclkHow about calling it "axi" ? None of the other clock names have "clk".
Quoted 5 lines
Quoted 3 lines
Documentation/devicetree/bindings/media/rockchip,vdec.yaml line 36
Quoted 1 line
Documentation/devicetree/bindings/media/rockchip,vdec.yaml new file +1
-0+ - const: ifaceAnd "ahb" here, as the AXI interface clock is also an interface clock ?
Sure, I can do that.
Another possibility: "master" for the AXI clock, and "slave" for the AHB clock. The AXI interface is likely the DMA master, while the AHB interface is a slave interface for the control registers.
This is mostly based on hints from the crypto block.
ChenYu
Re: [PATCH v3 5/7] media: dt-bindings: rockchip: Document RK3399 Video Decoder bindings
In reply to Boris BrezillonQuoted 11 lines · Boris Brezillon
Document the Rockchip RK3399 Video Decoder bindings.
---
Changes in v3:
* Fixdtbs_checkfailures--- .../bindings/media/rockchip,vdec.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip,vdec.yaml
PATCH v3 6/7 media: rkvdec: Add the rkvdec driver
In reply to Boris BrezillonThe rockchip vdec block is a stateless decoder that's able to decode H264, HEVC and VP9 content. This commit adds the core infrastructure and the H264 backend. Support for VP9 and HEVS will be added later on.
---
Changes in v3:
* Move the driver to drivers/staging/media/rkvdec/
* Fix copy&paste error in the Kconfig desc
* Use REC709 color space when resetting the capture format
* Prepare things to support VP9
* Move H264 priv-table field definition out of rkvdec-regs.h
* Clarify the provenance of the CABAC table
* Ease RPS,PPS_FIELD() definition/manipulation
* Take DPB field flags into account
* Use the generic H264 helpers to build the reflists
--- drivers/staging/media/Kconfig | 2 + drivers/staging/media/Makefile | 1 + drivers/staging/media/rkvdec/Kconfig | 15 + drivers/staging/media/rkvdec/Makefile | 3 + drivers/staging/media/rkvdec/rkvdec-h264.c | 1154 ++++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec-regs.h | 239 ++++ drivers/staging/media/rkvdec/rkvdec.c | 1130 +++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec.h | 124 +++ 8 files changed, 2668 insertions(+) create mode 100644 drivers/staging/media/rkvdec/Kconfig create mode 100644 drivers/staging/media/rkvdec/Makefile create mode 100644 drivers/staging/media/rkvdec/rkvdec-h264.c create mode 100644 drivers/staging/media/rkvdec/rkvdec-regs.h create mode 100644 drivers/staging/media/rkvdec/rkvdec.c create mode 100644 drivers/staging/media/rkvdec/rkvdec.h
drivers/staging/media/Kconfig +2 -0
@@ -30,6 +30,8 @@ source "drivers/staging/media/meson/vdec/Kconfig" source "drivers/staging/media/omap4iss/Kconfig" +source "drivers/staging/media/rkvdec/Kconfig" + source "drivers/staging/media/sunxi/Kconfig" source "drivers/staging/media/tegra-vde/Kconfig"
drivers/staging/media/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_VIDEO_ALLEGRO_DVT) += allegro-dvt/ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx/ obj-$(CONFIG_VIDEO_MESON_VDEC) += meson/vdec/ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ +obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rkvdec/ obj-$(CONFIG_VIDEO_SUNXI) += sunxi/ obj-$(CONFIG_TEGRA_VDE) += tegra-vde/ obj-$(CONFIG_VIDEO_HANTRO) += hantro/
drivers/staging/media/rkvdec/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0 +config VIDEO_ROCKCHIP_VDEC + tristate "Rockchip Video Decoder driver" + depends on ARCH_ROCKCHIP || COMPILE_TEST + depends on VIDEO_DEV && VIDEO_V4L2 && MEDIA_CONTROLLER + depends on MEDIA_CONTROLLER_REQUEST_API + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_VMALLOC + select V4L2_MEM2MEM_DEV + select V4L2_H264 + help + Support for the Rockchip Video Decoder IP present on Rockchip SoCs, + which accelerates video decoding. + To compile this driver as a module, choose M here: the module + will be called rockchip-vdec.
drivers/staging/media/rkvdec/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rockchip-vdec.o + +rockchip-vdec-y += rkvdec.o rkvdec-h264.o
drivers/staging/media/rkvdec/rkvdec-h264.c new file +1154 -0
1,154 lines not on this page · raw message
drivers/staging/media/rkvdec/rkvdec-regs.h new file +239 -0
239 lines not on this page · raw message
drivers/staging/media/rkvdec/rkvdec.c new file +1130 -0
1,130 lines not on this page · raw message
drivers/staging/media/rkvdec/rkvdec.h new file +124 -0
124 lines not on this page · raw message
Signature · 7 lines
2.23.0 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: [PATCH v3 6/7] media: rkvdec: Add the rkvdec driver
Hi Boris,
A few small comments:
Quoted 33 lines · Boris Brezillon
The rockchip vdec block is a stateless decoder that's able to decode H264, HEVC and VP9 content. This commit adds the core infrastructure and the H264 backend. Support for VP9 and HEVS will be added later on.
---
Changes in v3:
* Move the driver todrivers/staging/media/rkvdec/
* Fix copy&paste error in theKconfigdesc
* Use REC709 color space when resetting the capture format
* Prepare things to support VP9
* Move H264 priv-table field definition out ofrkvdec-regs.h
* Clarify the provenance of the CABAC table
* Ease RPS,PPS_FIELD() definition/manipulation
* Take DPB field flags into account
* Use the generic H264 helpers to build the reflists--- drivers/staging/media/Kconfig | 2 + drivers/staging/media/Makefile | 1 + drivers/staging/media/rkvdec/Kconfig | 15 + drivers/staging/media/rkvdec/Makefile | 3 + drivers/staging/media/rkvdec/rkvdec-h264.c | 1154 ++++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec-regs.h | 239 ++++ drivers/staging/media/rkvdec/rkvdec.c | 1130 +++++++++++++++++++ drivers/staging/media/rkvdec/rkvdec.h | 124 +++ 8 files changed, 2668 insertions(+) create mode 100644 drivers/staging/media/rkvdec/Kconfig create mode 100644 drivers/staging/media/rkvdec/Makefile create mode 100644 drivers/staging/media/rkvdec/rkvdec-h264.c create mode 100644 drivers/staging/media/rkvdec/rkvdec-regs.h create mode 100644 drivers/staging/media/rkvdec/rkvdec.c create mode 100644 drivers/staging/media/rkvdec/rkvdec.h
<snip>
Quoted 5 lines
drivers/staging/media/rkvdec/rkvdec-h264.c new file +0
-0
<snip>
Quoted 3 lines
+/*
+ * dpb poc related registers table
+ */
Shouldn't the next two arrays be const?
Quoted 37 lines
drivers/staging/media/rkvdec/rkvdec-h264.c new file +37
-0+static 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 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 ) +};
<snip>
Quoted 6 lines
drivers/staging/media/rkvdec/rkvdec.c new file +0
-0@@ -0,0 +1,1130 @@
<snip>
Quoted 12 lines
drivers/staging/media/rkvdec/rkvdec.c new file +12
-0+static int rkvdec_queue_setup (struct vb2_queue *vq,unsigned int *num_buffers, +unsigned int *num_planes,unsigned int sizes[], +struct device *alloc_devs[]) +{ +struct rkvdec_ctx *ctx =vb2_get_drv_priv (vq); +struct v4l2_pix_format_mplane *pixfmt; +struct v4l2_format *f; +unsigned int i; + +if (V4L2_TYPE_IS_OUTPUT (vq->type)) + f = &ctx->coded_fmt; +else
drivers/staging/media/rkvdec/rkvdec.c line 447
Quoted 10 lines
drivers/staging/media/rkvdec/rkvdec.c new file +10
-0+ f = &ctx->decoded_fmt; + +if (*num_planes) { +if (*num_planes != f->fmt.pix_mp.num_planes) +return -EINVAL ; + +for (i =0 ; i < f->fmt.pix_mp.num_planes; i++) { +if (sizes[i] < f->fmt.pix_mp.plane_fmt[i].sizeimage) +return -EINVAL ; + }
Shouldn't there be a 'return 0' here? In the CREATE_BUFS case all you do is check if the given size is large enough, and if so then you are done.
Quoted 4 lines
drivers/staging/media/rkvdec/rkvdec.c new file +4
-0+ }else { + *num_planes = f->fmt.pix_mp.num_planes; +for (i =0 ; i < f->fmt.pix_mp.num_planes; i++) + sizes[i] = f->fmt.pix_mp.plane_fmt[i].sizeimage;
drivers/staging/media/rkvdec/rkvdec.c line 461
Quoted 10 lines
drivers/staging/media/rkvdec/rkvdec.c new file +10
-0+ } + +if (V4L2_TYPE_IS_OUTPUT (vq->type)) +return 0 ; + + pixfmt = &ctx->decoded_fmt.fmt.pix_mp; + sizes[0 ] +=128 *DIV_ROUND_UP (pixfmt->width,16 ) * +DIV_ROUND_UP (pixfmt->height,16 ); +return 0 ; +}
<snip>
Regards,
Hans
Re: [PATCH v3 6/7] media: rkvdec: Add the rkvdec driver
Quoted 6 lines · On Fri, 13 Dec 2019 15:21:05 +0100 Hans Verkuil…
Quoted 4 lines
+/*
+ * dpb poc related registers table
+ */Shouldn't the next two arrays be const?
Absolutely. I'll fix that in v4.
Quoted 38 lines
Quoted 38 lines
drivers/staging/media/rkvdec/rkvdec-h264.c new file +37
-0+static 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 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 ) +};
[...]
Quoted 17 lines
Quoted 17 lines
drivers/staging/media/rkvdec/rkvdec.c new file +17
-0+static int rkvdec_queue_setup (struct vb2_queue *vq,unsigned int *num_buffers, +unsigned int *num_planes,unsigned int sizes[], +struct device *alloc_devs[]) +{ +struct rkvdec_ctx *ctx =vb2_get_drv_priv (vq); +struct v4l2_pix_format_mplane *pixfmt; +struct v4l2_format *f; +unsigned int i; + +if (V4L2_TYPE_IS_OUTPUT (vq->type)) + f = &ctx->coded_fmt; +else + f = &ctx->decoded_fmt; + +if (*num_planes) { +if (*num_planes != f->fmt.pix_mp.num_planes) +return -EINVAL ;
Quoted 8 lines
drivers/staging/media/rkvdec/rkvdec.c line 447
Quoted 5 lines
drivers/staging/media/rkvdec/rkvdec.c new file +5
-0+ +for (i =0 ; i < f->fmt.pix_mp.num_planes; i++) { +if (sizes[i] < f->fmt.pix_mp.plane_fmt[i].sizeimage) +return -EINVAL ; + }Shouldn't there be a 'return 0' here? In the
CREATE_BUFScase all you do is check if the given size is large enough, and if so then you are done.
I end up returning 0 anyway, it's just that size[0] is updated to account for the extra MV size, is that a problem?
Quoted 13 lines
drivers/staging/media/rkvdec/rkvdec.c line 459
Quoted 13 lines
drivers/staging/media/rkvdec/rkvdec.c new file +12
-0+ }else { + *num_planes = f->fmt.pix_mp.num_planes; +for (i =0 ; i < f->fmt.pix_mp.num_planes; i++) + sizes[i] = f->fmt.pix_mp.plane_fmt[i].sizeimage; + } + +if (V4L2_TYPE_IS_OUTPUT (vq->type)) +return 0 ; + + pixfmt = &ctx->decoded_fmt.fmt.pix_mp; + sizes[0 ] +=128 *DIV_ROUND_UP (pixfmt->width,16 ) * +DIV_ROUND_UP (pixfmt->height,16 );
This makes me realize we decided to take the MV extra size into account in our ->sizeimage calculation in the hantro driver, so I should probably move this code to try_s_capture_fmt().
Re: [PATCH v3 6/7] media: rkvdec: Add the rkvdec driver
In reply to Boris BrezillonQuoted 34 lines · On Fri, 13 Dec 2019 13:54:13 +0100 Boris Brezillon…
drivers/staging/media/rkvdec/rkvdec.c new file +34
-0+static int rkvdec_try_capture_fmt (struct file *file,void *priv, +struct v4l2_format *f) +{ +struct rkvdec_ctx *ctx =fh_to_rkvdec_ctx (priv); +const struct rkvdec_coded_fmt_desc *coded_desc; +u32 fourcc, width, height; +unsigned int i; + +/* +* The codec context should point to a coded format desc, if the format +* on the coded end has not been set yet, it should point to the +* default value. +*/ + coded_desc = ctx->coded_fmt_desc; +if (WARN_ON (!coded_desc)) +return -EINVAL ; + + fourcc = f->fmt.pix_mp.pixelformat; +for (i =0 ; i < coded_desc->num_decoded_fmts; i++) { +if (coded_desc->decoded_fmts[i] == fourcc) +break ; + } + +if (i == coded_desc->num_decoded_fmts) +return -EINVAL ; + +/* Save the original width/height before aligning them. */ + width = f->fmt.pix_mp.width; + height = f->fmt.pix_mp.height; + +/* Always apply the frmsize constraint of the coded end. */ +v4l2_apply_frmsize_constraints (&f->fmt.pix_mp.width, + &f->fmt.pix_mp.height, + &coded_desc->frmsize);
drivers/staging/media/rkvdec/rkvdec.c line 228
Quoted 10 lines
drivers/staging/media/rkvdec/rkvdec.c new file +10
-0+ +v4l2_fill_pixfmt_mp (&f->fmt.pix_mp, fourcc, f->fmt.pix_mp.width, + f->fmt.pix_mp.height); + +/* +* Now that we have computed sizeimage and bytesperline we can restore +* the original width/height (before macro block alignment). +*/ + f->fmt.pix_mp.width = width; + f->fmt.pix_mp.height = height;
Looks like restoring the original width/height was a bad idea (it breaks the odd_size tests of the VP9 testsuite [1]). I'll adjust the test in validate_dec_params() [2] to align the ctrl width/height params on a superblock size (64 pixels) instead.
drivers/staging/media/rkvdec/rkvdec.c line 169
Quoted 5 lines
drivers/staging/media/rkvdec/rkvdec.c new file +5
-0+ + f->fmt.pix_mp.field =V4L2_FIELD_NONE ; + +return 0 ; +}
[1]https://storage.googleapis.com/downloads.webmproject.org/vp9/decoder-test-streams/Profile_0_8bit.zip [2]https://patchwork.kernel.org/patch/11290603/
PATCH v3 7/7 arm64: dts: rockchip: rk3399: Define the rockchip Video Decoder node
In reply to Boris BrezillonRK3399 has a Video decoder, define the node in the dtsi. We also add the missing power-domain in mmu node and enable the block.
---
Changes in v3:
* None
--- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +13 -1
@@ -1277,8 +1277,20 @@ interrupt-names = "vdec_mmu"; clocks = <&cru ACLK_VDU>, <&cru HCLK_VDU>; clock-names = "aclk", "iface"; + power-domains = <&power RK3399_PD_VDU>; #iommu-cells = <0>; - status = "disabled"; + }; + + vdec: video-codec@ff660000 { + compatible = "rockchip,rk3399-vdec"; + reg = <0x0 0xff660000 0x0 0x400>; + interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH 0>; + interrupt-names = "vdpu"; + clocks = <&cru ACLK_VDU>, <&cru HCLK_VDU>, + <&cru SCLK_VDU_CA>, <&cru SCLK_VDU_CORE>; + clock-names = "aclk", "iface", "cabac", "core"; + power-domains = <&power RK3399_PD_VDU>; + iommus = <&vdec_mmu>; }; iep_mmu: iommu@ff670800 {
Signature · 1 line
2.23.0