Skip to contentSkip to conversation

media: venus: support frame rate control

PATCH In review Jeffrey Kardatzke 2 participants 6 messages Feb 13, 2020 – Feb 19, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: venus: support frame rate control

Frame rate control is always enabled in this driver, so make it silently support the V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE.

---
 drivers/media/platform/qcom/venus/venc_ctrls.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/platform/qcom/venus/venc_ctrls.c +6 -0
index 877c0b3299e9..9ede692f77c5 100644
@@ -199,6 +199,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
 		}
 		mutex_unlock(&inst->lock);
 		break;
+	case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
+		// Silently ignore, it's always enabled.
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -351,6 +354,9 @@ int venc_ctrl_init(struct venus_inst *inst)
 	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
 			  V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME, 0, 0, 0, 0);
 
+	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
+			  V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, 0, 1, 1, 1);
+
 	ret = inst->ctrl_handler.error;
 	if (ret)
 		goto err;
Signature · 1 line
2.25.0.225.g125e21ebc7-goog
#1 lore raw

Hi Jeff,

Thanks for the patch!

Quoted 13 lines · Jeffrey Kardatzke

Frame rate control is always enabled in this driver, so make it silently support the V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE.

---
 drivers/media/platform/qcom/venus/venc_ctrls.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/platform/qcom/venus/venc_ctrls.c +0 -0
index 877c0b3299e9..9ede692f77c5 100644

drivers/media/platform/qcom/venus/venc_ctrls.c static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) · line 203

Quoted 5 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +2 -0
@@ -199,6 +199,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
 		}
 		mutex_unlock(&inst->lock);
 		break;
+	case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
+		// Silently ignore, it's always enabled.

Please, use C comments and follow the kernel coding style.

I wonder shouldn't it be better to add rc_enable field in struct venc_controls and give the user choice to disable the rate control? We can keep the default to be "enabled".

drivers/media/platform/qcom/venus/venc_ctrls.c int venc_ctrl_init(struct venus_inst *inst) · line 359

Quoted 11 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +4 -0
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -351,6 +354,9 @@ int venc_ctrl_init(struct venus_inst *inst)
 	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
 			  V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME, 0, 0, 0, 0);
 
+	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
+			  V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, 0, 1, 1, 1);
+

you forgot to increment the number of controls in the call to v4l2_ctrl_handler_init.

Quoted 4 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +0 -0
 	ret = inst->ctrl_handler.error;
 	if (ret)
 		goto err;
Signature · 2 lines
regards,
Stan
#2 lore raw

Sorry for the duplicate, accidentally used HTML format and it got bounced from the mailing lists so resending.

Quoted 14 lines · Stanimir Varbanov

Hi Jeff,

Thanks for the patch!

Quoted 8 lines · Jeffrey Kardatzke

Frame rate control is always enabled in this driver, so make it silently support the V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE.

---
 drivers/media/platform/qcom/venus/venc_ctrls.c | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 12 lines

drivers/media/platform/qcom/venus/venc_ctrls.c static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) · line 203

Quoted 10 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +2 -0
index 877c0b3299e9..9ede692f77c5 100644
@@ -199,6 +199,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
              }
              mutex_unlock(&inst->lock);
              break;
+     case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
+             // Silently ignore, it's always enabled.

Please, use C comments and follow the kernel coding style.

OK, hopefully I've got that now. I didn't see any issues aside from the comment style though.
I'll upload a new patch shortly.

Quoted 6 lines

I wonder shouldn't it be better to add rc_enable field in struct venc_controls and give the user choice to disable the rate control? We can keep the default to be "enabled".

That'd be fine. Is there a way to actually disable the rate control though?

Quoted 9 lines
Quoted 9 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +1 -0
+             break;
      default:
              return -EINVAL;
      }
@@ -351,6 +354,9 @@ int venc_ctrl_init(struct venus_inst *inst)
      v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
                        V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME, 0, 0, 0, 0);
 
Quoted 7 lines

drivers/media/platform/qcom/venus/venc_ctrls.c int venc_ctrl_init(struct venus_inst *inst) · line 359

Quoted 3 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +3 -0
+     v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
+                       V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, 0, 1, 1, 1);
+

you forgot to increment the number of controls in the call to v4l2_ctrl_handler_init.

Done, thanks.

Quoted 9 lines

drivers/media/platform/qcom/venus/venc_ctrls.c int venc_ctrl_init(struct venus_inst *inst) · line 362

Quoted 5 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +0 -0
      ret = inst->ctrl_handler.error;
      if (ret)
              goto err;

--
regards,
Stan

#3 lore raw

Hi Jeff,

Quoted 37 lines · Jeffrey Kardatzke

Sorry for the duplicate, accidentally used HTML format and it got bounced from the mailing lists so resending.

Quoted 14 lines · Stanimir Varbanov

Hi Jeff,

Thanks for the patch!

Quoted 8 lines · Jeffrey Kardatzke

Frame rate control is always enabled in this driver, so make it silently support the V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE.

---
 drivers/media/platform/qcom/venus/venc_ctrls.c | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 12 lines

drivers/media/platform/qcom/venus/venc_ctrls.c static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) · line 203

Quoted 10 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +2 -0
index 877c0b3299e9..9ede692f77c5 100644
@@ -199,6 +199,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
              }
              mutex_unlock(&inst->lock);
              break;
+     case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
+             // Silently ignore, it's always enabled.

Please, use C comments and follow the kernel coding style.

OK, hopefully I've got that now. I didn't see any issues aside from the comment style though.
I'll upload a new patch shortly.

Quoted 2 lines
Quoted 5 lines
Quoted 4 lines

I wonder shouldn't it be better to add rc_enable field in struct venc_controls and give the user choice to disable the rate control? We can keep the default to be "enabled".

That'd be fine. Is there a way to actually disable the rate control though?

The rate control property values are here [1], and [2] is where we set the control.

Signature · 7 lines
regards,
Stan

[1]
https://elixir.bootlin.com/linux/v5.6-rc2/source/drivers/media/platform/qcom/venus/hfi_helper.h#L229
[2]
https://elixir.bootlin.com/linux/v5.6-rc2/source/drivers/media/platform/qcom/venus/venc.c#L734
#4 lore raw

Got it, thanks. I'll submit a new patch with that.

Quoted 58 lines · Stanimir Varbanov

Hi Jeff,

Quoted 37 lines · Jeffrey Kardatzke

Sorry for the duplicate, accidentally used HTML format and it got bounced from the mailing lists so resending.

Quoted 14 lines · Stanimir Varbanov

Hi Jeff,

Thanks for the patch!

Quoted 8 lines · Jeffrey Kardatzke

Frame rate control is always enabled in this driver, so make it silently support the V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE.

---
 drivers/media/platform/qcom/venus/venc_ctrls.c | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 12 lines

drivers/media/platform/qcom/venus/venc_ctrls.c static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) · line 203

Quoted 10 lines
drivers/media/platform/qcom/venus/venc_ctrls.c +2 -0
index 877c0b3299e9..9ede692f77c5 100644
@@ -199,6 +199,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
              }
              mutex_unlock(&inst->lock);
              break;
+     case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
+             // Silently ignore, it's always enabled.

Please, use C comments and follow the kernel coding style.

OK, hopefully I've got that now. I didn't see any issues aside from the comment style though.
I'll upload a new patch shortly.

Quoted 2 lines
Quoted 5 lines
Quoted 4 lines

I wonder shouldn't it be better to add rc_enable field in struct venc_controls and give the user choice to disable the rate control? We can keep the default to be "enabled".

That'd be fine. Is there a way to actually disable the rate control though?

The rate control property values are here [1], and [2] is where we set the control.

--
regards,
Stan

[1]
https://elixir.bootlin.com/linux/v5.6-rc2/source/drivers/media/platform/qcom/venus/hfi_helper.h#L229
[2]
https://elixir.bootlin.com/linux/v5.6-rc2/source/drivers/media/platform/qcom/venus/venc.c#L734

Signature · 3 lines
Jeffrey Kardatzke
[email protected]
Google, Inc.
#5 lore raw

PATCH 1/1 media: venus: support frame rate control

In reply to Jeffrey Kardatzke

Frame rate control is always enabled in this driver, so make it silently support the V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE.

---
 drivers/media/platform/qcom/venus/venc_ctrls.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/venus/venc_ctrls.c +7 -1
index 877c0b3299e9..15852bc26231 100644
@@ -199,6 +199,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
 		}
 		mutex_unlock(&inst->lock);
 		break;
+	case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
+		/* Silently ignore, it's always enabled. */
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -214,7 +217,7 @@ int venc_ctrl_init(struct venus_inst *inst)
 {
 	int ret;
 
-	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 30);
+	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 31);
 	if (ret)
 		return ret;
 
@@ -351,6 +354,9 @@ int venc_ctrl_init(struct venus_inst *inst)
 	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
 			  V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME, 0, 0, 0, 0);
 
+	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
+			  V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, 0, 1, 1, 1);
+
 	ret = inst->ctrl_handler.error;
 	if (ret)
 		goto err;
Signature · 1 line
2.25.0.265.gbab2e86ba0-goog