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 <darshana@codeaurora.org>
This commit is contained in:
Darshana Patil
2020-12-02 15:15:23 -08:00
parent 3858225faf
commit bff6f56a28
6 changed files with 68 additions and 3 deletions

View File

@@ -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_inst_init(struct msm_vidc_inst *inst);
int msm_vdec_input_port_settings_change(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_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_ #endif // _MSM_VDEC_H_

View File

@@ -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_start_input(struct msm_vidc_inst *inst);
int msm_venc_stop_output(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_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_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_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); int msm_venc_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f);

View File

@@ -1117,7 +1117,7 @@ int msm_vdec_input_port_settings_change(struct msm_vidc_inst *inst)
if (rc) if (rc)
return 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; event.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION;
v4l2_event_queue_fh(&inst->event_handler, &event); 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; 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 msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
{ {
int rc = 0; int rc = 0;

View File

@@ -613,6 +613,31 @@ error:
return rc; 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 msm_venc_stop_output(struct msm_vidc_inst *inst)
{ {
int rc = 0; int rc = 0;

View File

@@ -610,6 +610,19 @@ EXPORT_SYMBOL(msm_vidc_streamoff);
int msm_vidc_cmd(void *instance, union msm_v4l2_cmd *cmd) 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; return 0;
} }
EXPORT_SYMBOL(msm_vidc_cmd); EXPORT_SYMBOL(msm_vidc_cmd);

View File

@@ -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 msm_vidc_decoder_input_size(struct msm_vidc_inst *inst)
{ {
u32 size = ALIGN(15 * 1024 * 1024, SZ_4K); u32 size = ALIGN(1 * 1024 * 1024, SZ_4K);
size = 4; // TODO
return size; return size;
} }