@@ -97,13 +97,10 @@ struct rkvdec_h264_priv_tbl {
97
97
u8 err_info [RKV_ERROR_INFO_SIZE ];
98
98
};
99
99
100
- #define RKVDEC_H264_DPB_SIZE 16
101
-
102
100
struct rkvdec_h264_reflists {
103
101
struct v4l2_h264_reference p [V4L2_H264_REF_LIST_LEN ];
104
102
struct v4l2_h264_reference b0 [V4L2_H264_REF_LIST_LEN ];
105
103
struct v4l2_h264_reference b1 [V4L2_H264_REF_LIST_LEN ];
106
- u8 num_valid ;
107
104
};
108
105
109
106
struct rkvdec_h264_run {
@@ -747,23 +744,26 @@ static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx,
747
744
struct vb2_queue * cap_q = & m2m_ctx -> cap_q_ctx .q ;
748
745
int buf_idx = -1 ;
749
746
750
- if (dpb [i ].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE )
747
+ if (dpb [i ].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ) {
751
748
buf_idx = vb2_find_timestamp (cap_q ,
752
749
dpb [i ].reference_ts , 0 );
750
+ if (buf_idx < 0 )
751
+ pr_debug ("No buffer for reference_ts %llu" ,
752
+ dpb [i ].reference_ts );
753
+ }
753
754
754
755
run -> ref_buf_idx [i ] = buf_idx ;
755
756
}
756
757
}
757
758
758
759
static void assemble_hw_rps (struct rkvdec_ctx * ctx ,
760
+ struct v4l2_h264_reflist_builder * builder ,
759
761
struct rkvdec_h264_run * run )
760
762
{
761
763
const struct v4l2_ctrl_h264_decode_params * dec_params = run -> decode_params ;
762
764
const struct v4l2_h264_dpb_entry * dpb = dec_params -> dpb ;
763
765
struct rkvdec_h264_ctx * h264_ctx = ctx -> priv ;
764
- const struct v4l2_ctrl_h264_sps * sps = run -> sps ;
765
766
struct rkvdec_h264_priv_tbl * priv_tbl = h264_ctx -> priv_tbl .cpu ;
766
- u32 max_frame_num = 1 << (sps -> log2_max_frame_num_minus4 + 4 );
767
767
768
768
u32 * hw_rps = priv_tbl -> rps ;
769
769
u32 i , j ;
@@ -781,37 +781,36 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx,
781
781
if (!(dpb [i ].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ))
782
782
continue ;
783
783
784
- if (dpb [i ].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM ||
785
- dpb [i ].frame_num <= dec_params -> frame_num ) {
786
- p [i ] = dpb [i ].frame_num ;
787
- continue ;
788
- }
789
-
790
- p [i ] = dpb [i ].frame_num - max_frame_num ;
784
+ p [i ] = builder -> refs [i ].frame_num ;
791
785
}
792
786
793
787
for (j = 0 ; j < RKVDEC_NUM_REFLIST ; j ++ ) {
794
- for (i = 0 ; i < h264_ctx -> reflists .num_valid ; i ++ ) {
795
- bool dpb_valid = run -> ref_buf_idx [i ] >= 0 ;
796
- u8 idx = 0 ;
788
+ for (i = 0 ; i < builder -> num_valid ; i ++ ) {
789
+ struct v4l2_h264_reference * ref ;
790
+ bool dpb_valid ;
791
+ bool bottom ;
797
792
798
793
switch (j ) {
799
794
case 0 :
800
- idx = h264_ctx -> reflists .p [i ]. index ;
795
+ ref = & h264_ctx -> reflists .p [i ];
801
796
break ;
802
797
case 1 :
803
- idx = h264_ctx -> reflists .b0 [i ]. index ;
798
+ ref = & h264_ctx -> reflists .b0 [i ];
804
799
break ;
805
800
case 2 :
806
- idx = h264_ctx -> reflists .b1 [i ]. index ;
801
+ ref = & h264_ctx -> reflists .b1 [i ];
807
802
break ;
808
803
}
809
804
810
- if (idx >= ARRAY_SIZE (dec_params -> dpb ))
805
+ if (WARN_ON ( ref -> index >= ARRAY_SIZE (dec_params -> dpb ) ))
811
806
continue ;
812
807
808
+ dpb_valid = run -> ref_buf_idx [ref -> index ] >= 0 ;
809
+ bottom = ref -> fields == V4L2_H264_BOTTOM_FIELD_REF ;
810
+
813
811
set_ps_field (hw_rps , DPB_INFO (i , j ),
814
- idx | dpb_valid << 4 );
812
+ ref -> index | dpb_valid << 4 );
813
+ set_ps_field (hw_rps , BOTTOM_FLAG (i , j ), bottom );
815
814
}
816
815
}
817
816
}
@@ -999,10 +998,6 @@ static void config_registers(struct rkvdec_ctx *ctx,
999
998
rkvdec -> regs + RKVDEC_REG_H264_BASE_REFER15 );
1000
999
}
1001
1000
1002
- /*
1003
- * Since support frame mode only
1004
- * top_field_order_cnt is the same as bottom_field_order_cnt
1005
- */
1006
1001
reg = RKVDEC_CUR_POC (dec_params -> top_field_order_cnt );
1007
1002
writel_relaxed (reg , rkvdec -> regs + RKVDEC_REG_CUR_POC0 );
1008
1003
@@ -1166,15 +1161,14 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx)
1166
1161
/* Build the P/B{0,1} ref lists. */
1167
1162
v4l2_h264_init_reflist_builder (& reflist_builder , run .decode_params ,
1168
1163
run .sps , run .decode_params -> dpb );
1169
- h264_ctx -> reflists .num_valid = reflist_builder .num_valid ;
1170
1164
v4l2_h264_build_p_ref_list (& reflist_builder , h264_ctx -> reflists .p );
1171
1165
v4l2_h264_build_b_ref_lists (& reflist_builder , h264_ctx -> reflists .b0 ,
1172
1166
h264_ctx -> reflists .b1 );
1173
1167
1174
1168
assemble_hw_scaling_list (ctx , & run );
1175
1169
assemble_hw_pps (ctx , & run );
1176
1170
lookup_ref_buf_idx (ctx , & run );
1177
- assemble_hw_rps (ctx , & run );
1171
+ assemble_hw_rps (ctx , & reflist_builder , & run );
1178
1172
config_registers (ctx , & run );
1179
1173
1180
1174
rkvdec_run_postamble (ctx , & run .base );
0 commit comments