浏览代码

driver: video: handle drain command

handle decoder and encoder drain command.
send hfi drain command to firmware.

Change-Id: I94835ce0b2a8b06e7a9ad64f7cc8642913987659
Signed-off-by: Darshana Patil <[email protected]>
Darshana Patil 4 年之前
父节点
当前提交
bff6f56a28

+ 1 - 0
driver/vidc/inc/msm_vdec.h

@@ -20,5 +20,6 @@ int msm_vdec_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f);
 int msm_vdec_inst_init(struct msm_vidc_inst *inst);
 int msm_vdec_input_port_settings_change(struct msm_vidc_inst *inst);
 int msm_vdec_output_port_settings_change(struct msm_vidc_inst *inst);
+int msm_vdec_process_cmd(struct msm_vidc_inst *inst, u32 cmd);
 
 #endif // _MSM_VDEC_H_

+ 1 - 0
driver/vidc/inc/msm_venc.h

@@ -13,6 +13,7 @@ int msm_venc_stop_input(struct msm_vidc_inst *inst);
 int msm_venc_start_input(struct msm_vidc_inst *inst);
 int msm_venc_stop_output(struct msm_vidc_inst *inst);
 int msm_venc_start_output(struct msm_vidc_inst *inst);
+int msm_venc_process_cmd(struct msm_vidc_inst *inst, u32 cmd);
 int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f);
 int msm_venc_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f);
 int msm_venc_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f);

+ 27 - 1
driver/vidc/src/msm_vdec.c

@@ -1117,7 +1117,7 @@ int msm_vdec_input_port_settings_change(struct msm_vidc_inst *inst)
 	if (rc)
 		return rc;
 
-	event.type = V4L2_EVENT_SRC_CH_RESOLUTION;//todo
+	event.type = V4L2_EVENT_SOURCE_CHANGE;
 	event.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION;
 	v4l2_event_queue_fh(&inst->event_handler, &event);
 
@@ -1313,6 +1313,32 @@ int msm_vdec_qbuf(struct msm_vidc_inst *inst, struct vb2_buffer *vb2)
 	return rc;
 }
 
+int msm_vdec_process_cmd(struct msm_vidc_inst *inst, u32 cmd)
+{
+	int rc = 0;
+
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	if (cmd == V4L2_DEC_CMD_STOP) {
+		rc = venus_hfi_session_command(inst,
+				HFI_CMD_DRAIN,
+				INPUT_PORT,
+				HFI_PAYLOAD_NONE,
+				NULL,
+				0);
+		if (rc)
+			return rc;
+	} else {
+		d_vpr_e("%s: unknown cmd %d\n", __func__, cmd);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
 {
 	int rc = 0;

+ 25 - 0
driver/vidc/src/msm_venc.c

@@ -613,6 +613,31 @@ error:
 	return rc;
 }
 
+int msm_venc_process_cmd(struct msm_vidc_inst *inst, u32 cmd)
+{
+	int rc = 0;
+
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	if (cmd == V4L2_ENC_CMD_STOP) {
+		rc = venus_hfi_session_command(inst,
+				HFI_CMD_DRAIN,
+				INPUT_PORT,
+				HFI_PAYLOAD_NONE,
+				NULL,
+				0);
+		if (rc)
+			return rc;
+	} else {
+		d_vpr_e("%s: unknown cmd %d\n", __func__, cmd);
+		return -EINVAL;
+	}
+	return 0;
+}
+
 int msm_venc_stop_output(struct msm_vidc_inst *inst)
 {
 	int rc = 0;

+ 13 - 0
driver/vidc/src/msm_vidc.c

@@ -610,6 +610,19 @@ EXPORT_SYMBOL(msm_vidc_streamoff);
 
 int msm_vidc_cmd(void *instance, union msm_v4l2_cmd *cmd)
 {
+	int rc = 0;
+	struct msm_vidc_inst *inst = instance;
+	struct v4l2_decoder_cmd *dec = NULL;
+	struct v4l2_encoder_cmd *enc = NULL;
+
+	if (is_decode_session(inst)) {
+		dec = (struct v4l2_decoder_cmd *)cmd;
+		rc = msm_vdec_process_cmd(inst, dec->cmd);
+	} else if (is_encode_session(inst)) {
+		enc = (struct v4l2_encoder_cmd *)cmd;
+		rc = msm_venc_process_cmd(inst, enc->cmd);
+	}
+
 	return 0;
 }
 EXPORT_SYMBOL(msm_vidc_cmd);

+ 1 - 2
driver/vidc/src/msm_vidc_buffer.c

@@ -140,8 +140,7 @@ u32 msm_vidc_output_extra_count(struct msm_vidc_inst *inst)
 
 u32 msm_vidc_decoder_input_size(struct msm_vidc_inst *inst)
 {
-	u32 size = ALIGN(15 * 1024 * 1024, SZ_4K);
-	size = 4; // TODO
+	u32 size = ALIGN(1 * 1024 * 1024, SZ_4K);
 	return size;
 }