video: driver: add enumerate format support
Add below configuration - format enumeration - set format for encoder - get inst capabilities based on codec from core Change-Id: I2484056ae688cf7b634c5137631197a83c382950 Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
static int msm_vdec_codec_change(struct msm_vidc_inst *inst, u32 codec)
|
||||
{
|
||||
int rc = 0;
|
||||
int i;
|
||||
struct msm_vidc_core *core;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
@@ -27,6 +28,20 @@ static int msm_vdec_codec_change(struct msm_vidc_inst *inst, u32 codec)
|
||||
}
|
||||
core = inst->core;
|
||||
|
||||
inst->capabilities = NULL;
|
||||
for (i = 0; i < core->codecs_count; i++) {
|
||||
if (core->inst_caps[i].domain == MSM_VIDC_DECODER &&
|
||||
core->inst_caps[i].codec == get_vidc_codec_from_v4l2(
|
||||
inst->fmts[INPUT_PORT].fmt.pix.pixelformat)) {
|
||||
s_vpr_h(inst->sid, "%s: changed capabilities to %#x caps\n",
|
||||
__func__, inst->fmts[INPUT_PORT].fmt.pix.pixelformat);
|
||||
inst->capabilities = &core->inst_caps[i];
|
||||
}
|
||||
}
|
||||
if (!inst->capabilities) {
|
||||
s_vpr_e(inst->sid, "%s: capabilities not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -300,7 +315,7 @@ 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
|
||||
/* update crop dimensions */
|
||||
inst->crop.x = inst->crop.y = 0;
|
||||
inst->crop.width = f->fmt.pix.width;
|
||||
inst->crop.height = f->fmt.pix.height;
|
||||
@@ -351,10 +366,10 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
fmt->type = OUTPUT_PLANE;
|
||||
fmt->fmt.pix.pixelformat = f->fmt.pix.pixelformat;
|
||||
fmt->fmt.pix.width = VENUS_Y_STRIDE(
|
||||
msm_vidc_convert_color_fmt(fmt->fmt.pix.pixelformat),
|
||||
get_media_colorformat_from_v4l2(fmt->fmt.pix.pixelformat),
|
||||
f->fmt.pix.width);
|
||||
fmt->fmt.pix.height = VENUS_Y_SCANLINES(
|
||||
msm_vidc_convert_color_fmt(fmt->fmt.pix.pixelformat),
|
||||
get_media_colorformat_from_v4l2(fmt->fmt.pix.pixelformat),
|
||||
f->fmt.pix.height);
|
||||
fmt->fmt.pix.bytesperline = fmt->fmt.pix.width;
|
||||
fmt->fmt.pix.sizeimage = call_session_op(core, buffer_size,
|
||||
@@ -416,7 +431,7 @@ err_invalid_fmt:
|
||||
int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
{
|
||||
int rc = 0;
|
||||
u32 index;
|
||||
int port;
|
||||
|
||||
d_vpr_h("%s()\n", __func__);
|
||||
if (!inst) {
|
||||
@@ -424,19 +439,58 @@ int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (f->type == OUTPUT_PLANE) {
|
||||
index = OUTPUT_PORT;
|
||||
} else if (f->type == INPUT_PLANE) {
|
||||
index = OUTPUT_PORT;
|
||||
} else if (f->type == OUTPUT_META_PLANE) {
|
||||
index = OUTPUT_PORT;
|
||||
} else if (f->type == OUTPUT_META_PLANE) {
|
||||
index = OUTPUT_PORT;
|
||||
} else {
|
||||
d_vpr_e("%s: invalid type %d\n", __func__, f->type);
|
||||
port = msm_vidc_get_port_from_v4l2_type(f->type);
|
||||
if (port < 0) {
|
||||
d_vpr_e("%s: invalid format type %d\n", __func__, f->type);
|
||||
return -EINVAL;
|
||||
}
|
||||
memcpy(f, &inst->fmts[index], sizeof(struct v4l2_format));
|
||||
memcpy(f, &inst->fmts[port], sizeof(struct v4l2_format));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_vdec_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
|
||||
{
|
||||
int rc = 0;
|
||||
enum msm_vidc_codec_type codec;
|
||||
enum msm_vidc_colorformat_type colorformat;
|
||||
struct msm_vidc_core *core;
|
||||
|
||||
if (!inst || !inst->core || !inst->capabilities || !f) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
core = inst->core;
|
||||
|
||||
if (f->index >=
|
||||
sizeof(inst->capabilities->cap[PIX_FMTS].step_or_mask) * 8) {
|
||||
d_vpr_e("%s: invalid index %d\n", __func__, f->index);
|
||||
return -EINVAL;
|
||||
}
|
||||
memset(f->reserved, 0, sizeof(f->reserved));
|
||||
|
||||
if (f->type == INPUT_PLANE) {
|
||||
codec = core->capabilities[DEC_CODECS].value & f->index;
|
||||
f->pixelformat = get_v4l2_codec_from_vidc(codec);
|
||||
if (!f->pixelformat)
|
||||
return -EINVAL;
|
||||
f->flags = V4L2_FMT_FLAG_COMPRESSED;
|
||||
strlcpy(f->description, "codec", sizeof(f->description));
|
||||
} else if (f->type == OUTPUT_PLANE) {
|
||||
colorformat = f->index &
|
||||
inst->capabilities->cap[PIX_FMTS].step_or_mask;
|
||||
f->pixelformat = get_v4l2_colorformat_from_vidc(colorformat);
|
||||
if (!f->pixelformat)
|
||||
return -EINVAL;
|
||||
strlcpy(f->description, "colorformat", sizeof(f->description));
|
||||
} else if (f->type == INPUT_META_PLANE || f->type == OUTPUT_META_PLANE) {
|
||||
if (!f->index) {
|
||||
f->pixelformat = V4L2_PIX_FMT_VIDC_META;
|
||||
strlcpy(f->description, "metadata", sizeof(f->description));
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -444,6 +498,7 @@ int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
int msm_vdec_inst_init(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
int i;
|
||||
struct msm_vidc_core *core;
|
||||
struct v4l2_format *f;
|
||||
|
||||
@@ -473,6 +528,10 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
|
||||
inst->buffers.input.extra_count;
|
||||
inst->buffers.input.size = f->fmt.pix.sizeimage;
|
||||
|
||||
inst->crop.x = inst->crop.y = 0;
|
||||
inst->crop.width = f->fmt.pix.width;
|
||||
inst->crop.height = f->fmt.pix.height;
|
||||
|
||||
f = &inst->fmts[INPUT_META_PORT];
|
||||
f->type = INPUT_META_PLANE;
|
||||
f->fmt.meta.dataformat = V4L2_PIX_FMT_VIDC_META;
|
||||
@@ -487,9 +546,9 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
|
||||
f->type = OUTPUT_PLANE;
|
||||
f->fmt.pix.pixelformat = V4L2_PIX_FMT_NV12_UBWC;
|
||||
f->fmt.pix.width = VENUS_Y_STRIDE(
|
||||
msm_vidc_convert_color_fmt(f->fmt.pix.pixelformat), DEFAULT_WIDTH);
|
||||
get_media_colorformat_from_v4l2(f->fmt.pix.pixelformat), DEFAULT_WIDTH);
|
||||
f->fmt.pix.height = VENUS_Y_SCANLINES(
|
||||
msm_vidc_convert_color_fmt(f->fmt.pix.pixelformat), DEFAULT_HEIGHT);
|
||||
get_media_colorformat_from_v4l2(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_BUF_OUTPUT);
|
||||
@@ -515,6 +574,21 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
|
||||
inst->prop.frame_rate = DEFAULT_FPS << 16;
|
||||
inst->prop.operating_rate = DEFAULT_FPS << 16;
|
||||
|
||||
inst->capabilities = NULL;
|
||||
for (i = 0; i < core->codecs_count; i++) {
|
||||
if (core->inst_caps[i].domain == MSM_VIDC_DECODER &&
|
||||
core->inst_caps[i].codec == get_vidc_codec_from_v4l2(
|
||||
inst->fmts[INPUT_PORT].fmt.pix.pixelformat)) {
|
||||
s_vpr_h(inst->sid, "%s: assigned capabilities with %#x caps\n",
|
||||
__func__, inst->fmts[INPUT_PORT].fmt.pix.pixelformat);
|
||||
inst->capabilities = &core->inst_caps[i];
|
||||
}
|
||||
}
|
||||
if (!inst->capabilities) {
|
||||
s_vpr_e(inst->sid, "%s: capabilities not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Referens i nytt ärende
Block a user