video: driver: add decoder input streamon support
Add decoder input streamon functionality which include internal buffers support as well. Change-Id: Ifb5afa51a29270705863c273d1ae08310666895d Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
这个提交包含在:
@@ -13,6 +13,7 @@
|
||||
#include "msm_vidc_internal.h"
|
||||
#include "msm_vidc_platform.h"
|
||||
#include "msm_vidc_debug.h"
|
||||
#include "venus_hfi.h"
|
||||
|
||||
static int msm_vdec_codec_change(struct msm_vidc_inst *inst, u32 codec)
|
||||
{
|
||||
@@ -29,6 +30,222 @@ static int msm_vdec_codec_change(struct msm_vidc_inst *inst, u32 codec)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_vdec_set_input_properties(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_vdec_get_input_internal_buffers(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
struct msm_vidc_core *core;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst || !inst->core) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
core = inst->core;
|
||||
|
||||
inst->buffers.scratch.size = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_BUF_SCRATCH);
|
||||
inst->buffers.scratch_1.size = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_BUF_SCRATCH_1);
|
||||
inst->buffers.persist_1.size = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_BUF_PERSIST_1);
|
||||
|
||||
inst->buffers.scratch.min_count = call_session_op(core, min_count,
|
||||
inst, MSM_VIDC_BUF_SCRATCH);
|
||||
inst->buffers.scratch_1.min_count = call_session_op(core, min_count,
|
||||
inst, MSM_VIDC_BUF_SCRATCH_1);
|
||||
inst->buffers.persist_1.min_count = call_session_op(core, min_count,
|
||||
inst, MSM_VIDC_BUF_PERSIST_1);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_vdec_create_input_internal_buffers(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst || !inst->core) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_SCRATCH);
|
||||
if (rc)
|
||||
return rc;
|
||||
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_SCRATCH_1);
|
||||
if (rc)
|
||||
return rc;
|
||||
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_PERSIST_1);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_vdec_queue_input_internal_buffers(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst || !inst->core) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_SCRATCH);
|
||||
if (rc)
|
||||
return rc;
|
||||
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_SCRATCH_1);
|
||||
if (rc)
|
||||
return rc;
|
||||
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_PERSIST_1);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
static int msm_vdec_release_input_internal_buffers(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst || !inst->core) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = msm_vidc_release_internal_buffers(inst, MSM_VIDC_BUF_SCRATCH);
|
||||
if (rc)
|
||||
return rc;
|
||||
rc = msm_vidc_release_internal_buffers(inst, MSM_VIDC_BUF_SCRATCH_1);
|
||||
if (rc)
|
||||
return rc;
|
||||
rc = msm_vidc_release_internal_buffers(inst, MSM_VIDC_BUF_PERSIST_1);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
int msm_vdec_stop_input(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_vdec_start_input(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
struct msm_vidc_core *core;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst || !inst->core) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
core = inst->core;
|
||||
|
||||
//rc = msm_vidc_check_session_supported(inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
//rc = msm_vidc_check_scaling_supported(inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
rc = call_session_op(core, decide_work_mode, inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
rc = call_session_op(core, decide_work_route, inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
/* Decide bse vpp delay after work mode */
|
||||
//msm_vidc_set_bse_vpp_delay(inst);
|
||||
|
||||
rc = msm_vdec_get_input_internal_buffers(inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
/* check for memory after all buffers calculation */
|
||||
//rc = msm_vidc_check_memory_supported(inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
//msm_vidc_update_dcvs(inst);
|
||||
//msm_vidc_update_batching(inst);
|
||||
//msm_vidc_scale_power(inst);
|
||||
|
||||
rc = msm_vdec_set_input_properties(inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
rc = msm_vdec_create_input_internal_buffers(inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
rc = msm_vdec_queue_input_internal_buffers(inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
rc = venus_hfi_start_input(inst);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
rc = msm_vidc_change_inst_state(inst, MSM_VIDC_START_INPUT);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
d_vpr_h("%s: done\n", __func__);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
msm_vdec_stop_input(inst);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_vdec_stop_output(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_vdec_start_output(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -64,16 +281,16 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
}
|
||||
fmt = &inst->fmts[INPUT_PORT];
|
||||
fmt->type = INPUT_PLANE;
|
||||
fmt->fmt.pix.width = f->fmt.pix.width;
|
||||
fmt->fmt.pix.height = f->fmt.pix.height;
|
||||
fmt->fmt.pix.width = ALIGN(f->fmt.pix.width, 16);
|
||||
fmt->fmt.pix.height = ALIGN(f->fmt.pix.height, 16);
|
||||
fmt->fmt.pix.pixelformat = f->fmt.pix.pixelformat;
|
||||
fmt->fmt.pix.bytesperline = 0;
|
||||
fmt->fmt.pix.sizeimage = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_INPUT);
|
||||
inst, MSM_VIDC_BUF_INPUT);
|
||||
inst->buffers.input.min_count =
|
||||
call_session_op(core, min_count, inst, MSM_VIDC_INPUT);
|
||||
call_session_op(core, min_count, inst, MSM_VIDC_BUF_INPUT);
|
||||
inst->buffers.input.extra_count =
|
||||
call_session_op(core, extra_count, inst, MSM_VIDC_INPUT);
|
||||
call_session_op(core, extra_count, inst, MSM_VIDC_BUF_INPUT);
|
||||
if (inst->buffers.input.actual_count <
|
||||
inst->buffers.input.min_count +
|
||||
inst->buffers.input.extra_count) {
|
||||
@@ -83,6 +300,11 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
}
|
||||
inst->buffers.input.size = fmt->fmt.pix.sizeimage;
|
||||
|
||||
// update crop dimensions
|
||||
inst->crop.x = inst->crop.y = 0;
|
||||
inst->crop.width = f->fmt.pix.width;
|
||||
inst->crop.height = f->fmt.pix.height;
|
||||
|
||||
//rc = msm_vidc_check_session_supported(inst);
|
||||
if (rc)
|
||||
goto err_invalid_fmt;
|
||||
@@ -90,10 +312,14 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
// mplane->pixelformat);
|
||||
s_vpr_h(inst->sid,
|
||||
"%s: input: codec %#x width %d height %d size %d min_count %d extra_count %d\n",
|
||||
__func__, fmt->fmt.pix.pixelformat, fmt->fmt.pix.width,
|
||||
fmt->fmt.pix.height, fmt->fmt.pix.sizeimage,
|
||||
__func__, f->fmt.pix.pixelformat, f->fmt.pix.width,
|
||||
f->fmt.pix.height, fmt->fmt.pix.sizeimage,
|
||||
inst->buffers.input.min_count,
|
||||
inst->buffers.input.extra_count);
|
||||
|
||||
//msm_vidc_update_dcvs(inst);
|
||||
//msm_vidc_update_batching(inst);
|
||||
|
||||
} else if (f->type == INPUT_META_PLANE) {
|
||||
if (inst->state == MSM_VIDC_START_INPUT) {
|
||||
d_vpr_e("%s: invalid state %d\n", __func__, inst->state);
|
||||
@@ -103,7 +329,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
fmt->type = INPUT_META_PLANE;
|
||||
fmt->fmt.meta.dataformat = V4L2_PIX_FMT_VIDC_META;
|
||||
fmt->fmt.meta.buffersize = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_INPUT_META);
|
||||
inst, MSM_VIDC_BUF_INPUT_META);
|
||||
inst->buffers.input_meta.min_count =
|
||||
inst->buffers.input.min_count;
|
||||
inst->buffers.input_meta.extra_count =
|
||||
@@ -132,11 +358,11 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
f->fmt.pix.height);
|
||||
fmt->fmt.pix.bytesperline = fmt->fmt.pix.width;
|
||||
fmt->fmt.pix.sizeimage = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_OUTPUT);
|
||||
inst, MSM_VIDC_BUF_OUTPUT);
|
||||
inst->buffers.output.min_count =
|
||||
call_session_op(core, min_count, inst, MSM_VIDC_OUTPUT);
|
||||
call_session_op(core, min_count, inst, MSM_VIDC_BUF_OUTPUT);
|
||||
inst->buffers.output.extra_count =
|
||||
call_session_op(core, extra_count, inst, MSM_VIDC_OUTPUT);
|
||||
call_session_op(core, extra_count, inst, MSM_VIDC_BUF_OUTPUT);
|
||||
if (inst->buffers.output.actual_count <
|
||||
inst->buffers.output.min_count +
|
||||
inst->buffers.output.extra_count) {
|
||||
@@ -164,7 +390,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
fmt->type = OUTPUT_META_PLANE;
|
||||
fmt->fmt.meta.dataformat = V4L2_PIX_FMT_VIDC_META;
|
||||
fmt->fmt.meta.buffersize = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_OUTPUT_META);
|
||||
inst, MSM_VIDC_BUF_OUTPUT_META);
|
||||
inst->buffers.output_meta.min_count =
|
||||
inst->buffers.output.min_count;
|
||||
inst->buffers.output_meta.extra_count =
|
||||
@@ -177,7 +403,11 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
__func__, fmt->fmt.meta.buffersize,
|
||||
inst->buffers.output_meta.min_count,
|
||||
inst->buffers.output_meta.extra_count);
|
||||
} else {
|
||||
s_vpr_e(inst->sid, "%s: invalid type %d\n", __func__, f->type);
|
||||
goto err_invalid_fmt;
|
||||
}
|
||||
memcpy(f, fmt, sizeof(struct v4l2_format));
|
||||
|
||||
err_invalid_fmt:
|
||||
return rc;
|
||||
@@ -233,11 +463,11 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
|
||||
f->fmt.pix.pixelformat = V4L2_PIX_FMT_H264;
|
||||
f->fmt.pix.bytesperline = 0;
|
||||
f->fmt.pix.sizeimage = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_INPUT);
|
||||
inst, MSM_VIDC_BUF_INPUT);
|
||||
inst->buffers.input.min_count =
|
||||
call_session_op(core, min_count, inst, MSM_VIDC_INPUT);
|
||||
call_session_op(core, min_count, inst, MSM_VIDC_BUF_INPUT);
|
||||
inst->buffers.input.extra_count =
|
||||
call_session_op(core, extra_count, inst, MSM_VIDC_INPUT);
|
||||
call_session_op(core, extra_count, inst, MSM_VIDC_BUF_INPUT);
|
||||
inst->buffers.input.actual_count =
|
||||
inst->buffers.input.min_count +
|
||||
inst->buffers.input.extra_count;
|
||||
@@ -247,7 +477,7 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
|
||||
f->type = INPUT_META_PLANE;
|
||||
f->fmt.meta.dataformat = V4L2_PIX_FMT_VIDC_META;
|
||||
f->fmt.meta.buffersize = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_INPUT_META);
|
||||
inst, MSM_VIDC_BUF_INPUT_META);
|
||||
inst->buffers.input_meta.min_count = inst->buffers.input.min_count;
|
||||
inst->buffers.input_meta.extra_count = inst->buffers.input.extra_count;
|
||||
inst->buffers.input_meta.actual_count = inst->buffers.input.actual_count;
|
||||
@@ -262,11 +492,11 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
|
||||
msm_vidc_convert_color_fmt(f->fmt.pix.pixelformat), DEFAULT_HEIGHT);
|
||||
f->fmt.pix.bytesperline = f->fmt.pix.width;
|
||||
f->fmt.pix.sizeimage = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_OUTPUT);
|
||||
inst, MSM_VIDC_BUF_OUTPUT);
|
||||
inst->buffers.output.min_count =
|
||||
call_session_op(core, min_count, inst, MSM_VIDC_OUTPUT);
|
||||
call_session_op(core, min_count, inst, MSM_VIDC_BUF_OUTPUT);
|
||||
inst->buffers.output.extra_count =
|
||||
call_session_op(core, extra_count, inst, MSM_VIDC_OUTPUT);
|
||||
call_session_op(core, extra_count, inst, MSM_VIDC_BUF_OUTPUT);
|
||||
inst->buffers.output.actual_count =
|
||||
inst->buffers.output.min_count +
|
||||
inst->buffers.output.extra_count;
|
||||
@@ -276,7 +506,7 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
|
||||
f->type = OUTPUT_META_PLANE;
|
||||
f->fmt.meta.dataformat = V4L2_PIX_FMT_VIDC_META;
|
||||
f->fmt.meta.buffersize = call_session_op(core, buffer_size,
|
||||
inst, MSM_VIDC_OUTPUT_META);
|
||||
inst, MSM_VIDC_BUF_OUTPUT_META);
|
||||
inst->buffers.output_meta.min_count = inst->buffers.output.min_count;
|
||||
inst->buffers.output_meta.extra_count = inst->buffers.output.extra_count;
|
||||
inst->buffers.output_meta.actual_count = inst->buffers.output.actual_count;
|
||||
|
在新工单中引用
屏蔽一个用户