Commit d421ba0c authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: vicodec: always return a valid format.

Rather than returning width/height values of 0, just default to
a format. Formats in V4L2 are always supposed to be valid, there
is no concept of an invalid format.
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent e5bc0e1d
...@@ -1742,11 +1742,13 @@ static const struct v4l2_ctrl_config vicodec_ctrl_stateless_state = { ...@@ -1742,11 +1742,13 @@ static const struct v4l2_ctrl_config vicodec_ctrl_stateless_state = {
*/ */
static int vicodec_open(struct file *file) static int vicodec_open(struct file *file)
{ {
const struct v4l2_fwht_pixfmt_info *info = v4l2_fwht_get_pixfmt(0);
struct video_device *vfd = video_devdata(file); struct video_device *vfd = video_devdata(file);
struct vicodec_dev *dev = video_drvdata(file); struct vicodec_dev *dev = video_drvdata(file);
struct vicodec_ctx *ctx = NULL; struct vicodec_ctx *ctx = NULL;
struct v4l2_ctrl_handler *hdl; struct v4l2_ctrl_handler *hdl;
unsigned int size; unsigned int raw_size;
unsigned int comp_size;
int rc = 0; int rc = 0;
if (mutex_lock_interruptible(vfd->lock)) if (mutex_lock_interruptible(vfd->lock))
...@@ -1785,7 +1787,7 @@ static int vicodec_open(struct file *file) ...@@ -1785,7 +1787,7 @@ static int vicodec_open(struct file *file)
v4l2_ctrl_handler_setup(hdl); v4l2_ctrl_handler_setup(hdl);
if (ctx->is_enc) if (ctx->is_enc)
ctx->q_data[V4L2_M2M_SRC].info = v4l2_fwht_get_pixfmt(0); ctx->q_data[V4L2_M2M_SRC].info = info;
else if (ctx->is_stateless) else if (ctx->is_stateless)
ctx->q_data[V4L2_M2M_SRC].info = &pixfmt_stateless_fwht; ctx->q_data[V4L2_M2M_SRC].info = &pixfmt_stateless_fwht;
else else
...@@ -1794,22 +1796,22 @@ static int vicodec_open(struct file *file) ...@@ -1794,22 +1796,22 @@ static int vicodec_open(struct file *file)
ctx->q_data[V4L2_M2M_SRC].coded_height = 720; ctx->q_data[V4L2_M2M_SRC].coded_height = 720;
ctx->q_data[V4L2_M2M_SRC].visible_width = 1280; ctx->q_data[V4L2_M2M_SRC].visible_width = 1280;
ctx->q_data[V4L2_M2M_SRC].visible_height = 720; ctx->q_data[V4L2_M2M_SRC].visible_height = 720;
size = 1280 * 720 * ctx->q_data[V4L2_M2M_SRC].info->sizeimage_mult / raw_size = 1280 * 720 * info->sizeimage_mult / info->sizeimage_div;
ctx->q_data[V4L2_M2M_SRC].info->sizeimage_div; comp_size = 1280 * 720 * pixfmt_fwht.sizeimage_mult /
pixfmt_fwht.sizeimage_div;
if (ctx->is_enc || ctx->is_stateless) if (ctx->is_enc || ctx->is_stateless)
ctx->q_data[V4L2_M2M_SRC].sizeimage = size; ctx->q_data[V4L2_M2M_SRC].sizeimage = raw_size;
else else
ctx->q_data[V4L2_M2M_SRC].sizeimage = ctx->q_data[V4L2_M2M_SRC].sizeimage =
size + sizeof(struct fwht_cframe_hdr); comp_size + sizeof(struct fwht_cframe_hdr);
ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC];
if (ctx->is_enc) { if (ctx->is_enc) {
ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC];
ctx->q_data[V4L2_M2M_DST].info = &pixfmt_fwht; ctx->q_data[V4L2_M2M_DST].info = &pixfmt_fwht;
ctx->q_data[V4L2_M2M_DST].sizeimage = 1280 * 720 * ctx->q_data[V4L2_M2M_DST].sizeimage =
ctx->q_data[V4L2_M2M_DST].info->sizeimage_mult / comp_size + sizeof(struct fwht_cframe_hdr);
ctx->q_data[V4L2_M2M_DST].info->sizeimage_div +
sizeof(struct fwht_cframe_hdr);
} else { } else {
ctx->q_data[V4L2_M2M_DST].info = NULL; ctx->q_data[V4L2_M2M_DST].info = info;
ctx->q_data[V4L2_M2M_DST].sizeimage = raw_size;
} }
ctx->state.colorspace = V4L2_COLORSPACE_REC709; ctx->state.colorspace = V4L2_COLORSPACE_REC709;
......
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