@@ -54,6 +54,7 @@ int iris_vdec_inst_init(struct iris_inst *inst)
5454 f -> fmt .pix_mp .quantization = V4L2_QUANTIZATION_DEFAULT ;
5555 inst -> buffers [BUF_OUTPUT ].min_count = iris_vpu_buf_count (inst , BUF_OUTPUT );
5656 inst -> buffers [BUF_OUTPUT ].size = f -> fmt .pix_mp .plane_fmt [0 ].sizeimage ;
57+ inst -> frame_rate = MAXIMUM_FPS ;
5758
5859 memcpy (& inst -> fw_caps [0 ], & core -> inst_fw_caps_dec [0 ],
5960 INST_FW_CAP_MAX * sizeof (struct platform_inst_fw_cap ));
@@ -371,6 +372,8 @@ int iris_vdec_streamon_input(struct iris_inst *inst)
371372 if (ret )
372373 return ret ;
373374
375+ inst -> frame_counter = 0 ;
376+
374377 return iris_process_streamon_input (inst );
375378}
376379
@@ -413,6 +416,7 @@ int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf)
413416{
414417 struct iris_buffer * buf = to_iris_buffer (vbuf );
415418 struct vb2_buffer * vb2 = & vbuf -> vb2_buf ;
419+ u64 cur_buf_ns , delta_ns ;
416420 struct vb2_queue * q ;
417421 int ret ;
418422
@@ -429,6 +433,22 @@ int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf)
429433 return 0 ;
430434 }
431435
436+ if (buf -> type == BUF_INPUT ) {
437+ cur_buf_ns = ktime_get_ns ();
438+
439+ if (!inst -> frame_counter )
440+ inst -> last_buf_ns = cur_buf_ns ;
441+
442+ inst -> frame_counter ++ ;
443+ delta_ns = cur_buf_ns - inst -> last_buf_ns ;
444+
445+ if (delta_ns >= NSEC_PER_SEC ) {
446+ inst -> frame_rate = clamp_t (u32 , inst -> frame_counter , DEFAULT_FPS ,
447+ MAXIMUM_FPS );
448+ inst -> frame_counter = 0 ;
449+ }
450+ }
451+
432452 iris_scale_power (inst );
433453
434454 return iris_queue_buffer (inst , buf );
0 commit comments