diff mbox series

[4/6] venus: venc: Add support for frame-skip mode v4l2 control

Message ID 20200720132313.4810-5-stanimir.varbanov@linaro.org (mailing list archive)
State New, archived
Headers show
Series Add new controls for CQ and Frame-skip | expand

Commit Message

Stanimir Varbanov July 20, 2020, 1:23 p.m. UTC
This adds support for frame-skip-mode standard v4l2 control in
encoder driver. The control is implemented based on the
combination of client selected bitrate-mode and frame-skip-mode.
Once The client selected bitrate-mode (constant or variable) and
the frame-skip-mode is not disabled we set variable framerate for
rate controller.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
---
 drivers/media/platform/qcom/venus/core.h       |  1 +
 drivers/media/platform/qcom/venus/venc.c       |  6 ++++--
 drivers/media/platform/qcom/venus/venc_ctrls.c | 11 ++++++++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

Comments

kernel test robot July 20, 2020, 3:51 p.m. UTC | #1
Hi Stanimir,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on linux/master soc/for-next linus/master v5.8-rc6 next-20200720]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Stanimir-Varbanov/Add-new-controls-for-CQ-and-Frame-skip/20200720-212608
base:   git://linuxtv.org/media_tree.git master
config: sparc-allyesconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sparc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/media/platform/qcom/venus/venc_ctrls.c: In function 'venc_op_s_ctrl':
>> drivers/media/platform/qcom/venus/venc_ctrls.c:206:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
     206 |   ctr->const_quality = ctrl->val;
         |   ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
   drivers/media/platform/qcom/venus/venc_ctrls.c:207:2: note: here
     207 |  case V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE:
         |  ^~~~

vim +206 drivers/media/platform/qcom/venus/venc_ctrls.c

8fc58186bb41ff Stanimir Varbanov 2017-12-01   68  
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   69  static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   70  {
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   71  	struct venus_inst *inst = ctrl_to_inst(ctrl);
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   72  	struct venc_controls *ctr = &inst->controls.enc;
c35f0b16537c15 Malathi Gottam    2018-11-02   73  	struct hfi_enable en = { .enable = 1 };
61df5aa325fec4 Malathi Gottam    2018-11-02   74  	struct hfi_bitrate brate;
8fc58186bb41ff Stanimir Varbanov 2017-12-01   75  	u32 bframes;
61df5aa325fec4 Malathi Gottam    2018-11-02   76  	u32 ptype;
8fc58186bb41ff Stanimir Varbanov 2017-12-01   77  	int ret;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   78  
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   79  	switch (ctrl->id) {
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   80  	case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   81  		ctr->bitrate_mode = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   82  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   83  	case V4L2_CID_MPEG_VIDEO_BITRATE:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   84  		ctr->bitrate = ctrl->val;
61df5aa325fec4 Malathi Gottam    2018-11-02   85  		mutex_lock(&inst->lock);
61df5aa325fec4 Malathi Gottam    2018-11-02   86  		if (inst->streamon_out && inst->streamon_cap) {
61df5aa325fec4 Malathi Gottam    2018-11-02   87  			ptype = HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE;
61df5aa325fec4 Malathi Gottam    2018-11-02   88  			brate.bitrate = ctr->bitrate;
61df5aa325fec4 Malathi Gottam    2018-11-02   89  			brate.layer_id = 0;
61df5aa325fec4 Malathi Gottam    2018-11-02   90  
61df5aa325fec4 Malathi Gottam    2018-11-02   91  			ret = hfi_session_set_property(inst, ptype, &brate);
61df5aa325fec4 Malathi Gottam    2018-11-02   92  			if (ret) {
61df5aa325fec4 Malathi Gottam    2018-11-02   93  				mutex_unlock(&inst->lock);
61df5aa325fec4 Malathi Gottam    2018-11-02   94  				return ret;
61df5aa325fec4 Malathi Gottam    2018-11-02   95  			}
61df5aa325fec4 Malathi Gottam    2018-11-02   96  		}
61df5aa325fec4 Malathi Gottam    2018-11-02   97  		mutex_unlock(&inst->lock);
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   98  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15   99  	case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  100  		ctr->bitrate_peak = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  101  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  102  	case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  103  		ctr->h264_entropy_mode = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  104  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  105  	case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  106  		ctr->profile.mpeg4 = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  107  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  108  	case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  109  		ctr->profile.h264 = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  110  		break;
cd396c8cbfcdd7 Kelvin Lawson     2018-12-10  111  	case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE:
cd396c8cbfcdd7 Kelvin Lawson     2018-12-10  112  		ctr->profile.hevc = ctrl->val;
cd396c8cbfcdd7 Kelvin Lawson     2018-12-10  113  		break;
5520b9467a39d5 Keiichi Watanabe  2018-06-18  114  	case V4L2_CID_MPEG_VIDEO_VP8_PROFILE:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  115  		ctr->profile.vpx = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  116  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  117  	case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  118  		ctr->level.mpeg4 = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  119  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  120  	case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  121  		ctr->level.h264 = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  122  		break;
cd396c8cbfcdd7 Kelvin Lawson     2018-12-10  123  	case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL:
cd396c8cbfcdd7 Kelvin Lawson     2018-12-10  124  		ctr->level.hevc = ctrl->val;
cd396c8cbfcdd7 Kelvin Lawson     2018-12-10  125  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  126  	case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  127  		ctr->h264_i_qp = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  128  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  129  	case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  130  		ctr->h264_p_qp = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  131  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  132  	case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  133  		ctr->h264_b_qp = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  134  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  135  	case V4L2_CID_MPEG_VIDEO_H264_MIN_QP:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  136  		ctr->h264_min_qp = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  137  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  138  	case V4L2_CID_MPEG_VIDEO_H264_MAX_QP:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  139  		ctr->h264_max_qp = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  140  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  141  	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  142  		ctr->multi_slice_mode = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  143  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  144  	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  145  		ctr->multi_slice_max_bytes = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  146  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  147  	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  148  		ctr->multi_slice_max_mb = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  149  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  150  	case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  151  		ctr->h264_loop_filter_alpha = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  152  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  153  	case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  154  		ctr->h264_loop_filter_beta = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  155  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  156  	case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  157  		ctr->h264_loop_filter_mode = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  158  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  159  	case V4L2_CID_MPEG_VIDEO_HEADER_MODE:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  160  		ctr->header_mode = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  161  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  162  	case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  163  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  164  	case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
8fc58186bb41ff Stanimir Varbanov 2017-12-01  165  		ret = venc_calc_bpframes(ctrl->val, ctr->num_b_frames, &bframes,
8fc58186bb41ff Stanimir Varbanov 2017-12-01  166  					 &ctr->num_p_frames);
8fc58186bb41ff Stanimir Varbanov 2017-12-01  167  		if (ret)
8fc58186bb41ff Stanimir Varbanov 2017-12-01  168  			return ret;
8fc58186bb41ff Stanimir Varbanov 2017-12-01  169  
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  170  		ctr->gop_size = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  171  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  172  	case V4L2_CID_MPEG_VIDEO_H264_I_PERIOD:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  173  		ctr->h264_i_period = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  174  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  175  	case V4L2_CID_MPEG_VIDEO_VPX_MIN_QP:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  176  		ctr->vp8_min_qp = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  177  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  178  	case V4L2_CID_MPEG_VIDEO_VPX_MAX_QP:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  179  		ctr->vp8_max_qp = ctrl->val;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  180  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  181  	case V4L2_CID_MPEG_VIDEO_B_FRAMES:
8fc58186bb41ff Stanimir Varbanov 2017-12-01  182  		ret = venc_calc_bpframes(ctr->gop_size, ctrl->val, &bframes,
8fc58186bb41ff Stanimir Varbanov 2017-12-01  183  					 &ctr->num_p_frames);
8fc58186bb41ff Stanimir Varbanov 2017-12-01  184  		if (ret)
8fc58186bb41ff Stanimir Varbanov 2017-12-01  185  			return ret;
8fc58186bb41ff Stanimir Varbanov 2017-12-01  186  
8fc58186bb41ff Stanimir Varbanov 2017-12-01  187  		ctr->num_b_frames = bframes;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  188  		break;
c35f0b16537c15 Malathi Gottam    2018-11-02  189  	case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
c35f0b16537c15 Malathi Gottam    2018-11-02  190  		mutex_lock(&inst->lock);
c35f0b16537c15 Malathi Gottam    2018-11-02  191  		if (inst->streamon_out && inst->streamon_cap) {
c35f0b16537c15 Malathi Gottam    2018-11-02  192  			ptype = HFI_PROPERTY_CONFIG_VENC_REQUEST_SYNC_FRAME;
c35f0b16537c15 Malathi Gottam    2018-11-02  193  			ret = hfi_session_set_property(inst, ptype, &en);
c35f0b16537c15 Malathi Gottam    2018-11-02  194  
c35f0b16537c15 Malathi Gottam    2018-11-02  195  			if (ret) {
c35f0b16537c15 Malathi Gottam    2018-11-02  196  				mutex_unlock(&inst->lock);
c35f0b16537c15 Malathi Gottam    2018-11-02  197  				return ret;
c35f0b16537c15 Malathi Gottam    2018-11-02  198  			}
c35f0b16537c15 Malathi Gottam    2018-11-02  199  		}
c35f0b16537c15 Malathi Gottam    2018-11-02  200  		mutex_unlock(&inst->lock);
c35f0b16537c15 Malathi Gottam    2018-11-02  201  		break;
6f704b2fbbde0c Jeffrey Kardatzke 2020-02-22  202  	case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
6f704b2fbbde0c Jeffrey Kardatzke 2020-02-22  203  		ctr->rc_enable = ctrl->val;
6f704b2fbbde0c Jeffrey Kardatzke 2020-02-22  204  		break;
1b66e2818e6ed3 Stanimir Varbanov 2020-07-20  205  	case V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY:
1b66e2818e6ed3 Stanimir Varbanov 2020-07-20 @206  		ctr->const_quality = ctrl->val;
0978d8244ce6b2 Stanimir Varbanov 2020-07-20  207  	case V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE:
0978d8244ce6b2 Stanimir Varbanov 2020-07-20  208  		ctr->frame_skip_mode = ctrl->val;
1b66e2818e6ed3 Stanimir Varbanov 2020-07-20  209  		break;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  210  	default:
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  211  		return -EINVAL;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  212  	}
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  213  
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  214  	return 0;
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  215  }
aaaa93eda64b00 Stanimir Varbanov 2017-06-15  216  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 1bac30d4cf50..72e171ee05a8 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -202,6 +202,7 @@  struct venc_controls {
 	u32 bitrate_peak;
 	u32 rc_enable;
 	u32 const_quality;
+	u32 frame_skip_mode;
 
 	u32 h264_i_period;
 	u32 h264_entropy_mode;
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 4c30c3f3369e..e4bbaae9975a 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -739,9 +739,11 @@  static int venc_set_properties(struct venus_inst *inst)
 	if (!ctr->rc_enable)
 		rate_control = HFI_RATE_CONTROL_OFF;
 	else if (ctr->bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR)
-		rate_control = HFI_RATE_CONTROL_VBR_CFR;
+		rate_control = ctr->frame_skip_mode ? HFI_RATE_CONTROL_VBR_VFR :
+						      HFI_RATE_CONTROL_VBR_CFR;
 	else if (ctr->bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR)
-		rate_control = HFI_RATE_CONTROL_CBR_CFR;
+		rate_control = ctr->frame_skip_mode ? HFI_RATE_CONTROL_CBR_VFR :
+						      HFI_RATE_CONTROL_CBR_CFR;
 	else if (ctr->bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ)
 		rate_control = HFI_RATE_CONTROL_CQ;
 
diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c
index 97a1e821c07e..4ac8da2ad061 100644
--- a/drivers/media/platform/qcom/venus/venc_ctrls.c
+++ b/drivers/media/platform/qcom/venus/venc_ctrls.c
@@ -204,6 +204,8 @@  static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
 		break;
 	case V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY:
 		ctr->const_quality = ctrl->val;
+	case V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE:
+		ctr->frame_skip_mode = ctrl->val;
 		break;
 	default:
 		return -EINVAL;
@@ -220,7 +222,7 @@  int venc_ctrl_init(struct venus_inst *inst)
 {
 	int ret;
 
-	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 32);
+	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 33);
 	if (ret)
 		return ret;
 
@@ -363,6 +365,13 @@  int venc_ctrl_init(struct venus_inst *inst)
 	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
 			  V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY, 0, 100, 1, 0);
 
+	v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &venc_ctrl_ops,
+			       V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE,
+			       V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT,
+			       ~((1 << V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED) |
+			       (1 << V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT)),
+			       V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED);
+
 	ret = inst->ctrl_handler.error;
 	if (ret)
 		goto err;