Commit ab97a3fb authored by Stanimir Varbanov's avatar Stanimir Varbanov Committed by Mauro Carvalho Chehab

media: venus: helpers: add a new helper to set raw format

The new helper will has one more argument for buffer type, that
way the decoder can configure the format on it's secondary
output.
Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Reviewed-by: default avatarTomasz Figa <tfiga@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Tested-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 404054e1
...@@ -412,6 +412,20 @@ static int session_register_bufs(struct venus_inst *inst) ...@@ -412,6 +412,20 @@ static int session_register_bufs(struct venus_inst *inst)
return ret; return ret;
} }
static u32 to_hfi_raw_fmt(u32 v4l2_fmt)
{
switch (v4l2_fmt) {
case V4L2_PIX_FMT_NV12:
return HFI_COLOR_FORMAT_NV12;
case V4L2_PIX_FMT_NV21:
return HFI_COLOR_FORMAT_NV21;
default:
break;
}
return 0;
}
int venus_helper_get_bufreq(struct venus_inst *inst, u32 type, int venus_helper_get_bufreq(struct venus_inst *inst, u32 type,
struct hfi_buffer_requirements *req) struct hfi_buffer_requirements *req)
{ {
...@@ -493,35 +507,35 @@ int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs, ...@@ -493,35 +507,35 @@ int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
} }
EXPORT_SYMBOL_GPL(venus_helper_set_num_bufs); EXPORT_SYMBOL_GPL(venus_helper_set_num_bufs);
int venus_helper_set_color_format(struct venus_inst *inst, u32 pixfmt) int venus_helper_set_raw_format(struct venus_inst *inst, u32 hfi_format,
u32 buftype)
{ {
const u32 ptype = HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT;
struct hfi_uncompressed_format_select fmt; struct hfi_uncompressed_format_select fmt;
u32 ptype = HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT;
int ret; fmt.buffer_type = buftype;
fmt.format = hfi_format;
return hfi_session_set_property(inst, ptype, &fmt);
}
EXPORT_SYMBOL_GPL(venus_helper_set_raw_format);
int venus_helper_set_color_format(struct venus_inst *inst, u32 pixfmt)
{
u32 hfi_format, buftype;
if (inst->session_type == VIDC_SESSION_TYPE_DEC) if (inst->session_type == VIDC_SESSION_TYPE_DEC)
fmt.buffer_type = HFI_BUFFER_OUTPUT; buftype = HFI_BUFFER_OUTPUT;
else if (inst->session_type == VIDC_SESSION_TYPE_ENC) else if (inst->session_type == VIDC_SESSION_TYPE_ENC)
fmt.buffer_type = HFI_BUFFER_INPUT; buftype = HFI_BUFFER_INPUT;
else else
return -EINVAL; return -EINVAL;
switch (pixfmt) { hfi_format = to_hfi_raw_fmt(pixfmt);
case V4L2_PIX_FMT_NV12: if (!hfi_format)
fmt.format = HFI_COLOR_FORMAT_NV12;
break;
case V4L2_PIX_FMT_NV21:
fmt.format = HFI_COLOR_FORMAT_NV21;
break;
default:
return -EINVAL; return -EINVAL;
}
ret = hfi_session_set_property(inst, ptype, &fmt); return venus_helper_set_raw_format(inst, hfi_format, buftype);
if (ret)
return ret;
return 0;
} }
EXPORT_SYMBOL_GPL(venus_helper_set_color_format); EXPORT_SYMBOL_GPL(venus_helper_set_color_format);
......
...@@ -40,6 +40,8 @@ int venus_helper_set_output_resolution(struct venus_inst *inst, ...@@ -40,6 +40,8 @@ int venus_helper_set_output_resolution(struct venus_inst *inst,
u32 buftype); u32 buftype);
int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs, int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
unsigned int output_bufs); unsigned int output_bufs);
int venus_helper_set_raw_format(struct venus_inst *inst, u32 hfi_format,
u32 buftype);
int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt);
int venus_helper_set_dyn_bufmode(struct venus_inst *inst); int venus_helper_set_dyn_bufmode(struct venus_inst *inst);
int venus_helper_set_bufsize(struct venus_inst *inst, u32 bufsize, u32 buftype); int venus_helper_set_bufsize(struct venus_inst *inst, u32 bufsize, u32 buftype);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment