[media] bdisp: composing support
Support the composing (at VIDEO_CAPTURE) with the _selection API. v4l2-compliance successfully run ("test Composing: OK") Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
d3194520e2
commit
3d8bffe883
2 changed files with 55 additions and 29 deletions
|
@ -336,8 +336,8 @@ static int bdisp_hw_get_hv_inc(struct bdisp_ctx *ctx, u16 *h_inc, u16 *v_inc)
|
||||||
|
|
||||||
src_w = ctx->src.crop.width;
|
src_w = ctx->src.crop.width;
|
||||||
src_h = ctx->src.crop.height;
|
src_h = ctx->src.crop.height;
|
||||||
dst_w = ctx->dst.width;
|
dst_w = ctx->dst.crop.width;
|
||||||
dst_h = ctx->dst.height;
|
dst_h = ctx->dst.crop.height;
|
||||||
|
|
||||||
if (bdisp_hw_get_inc(src_w, dst_w, h_inc) ||
|
if (bdisp_hw_get_inc(src_w, dst_w, h_inc) ||
|
||||||
bdisp_hw_get_inc(src_h, dst_h, v_inc)) {
|
bdisp_hw_get_inc(src_h, dst_h, v_inc)) {
|
||||||
|
@ -483,9 +483,9 @@ static void bdisp_hw_build_node(struct bdisp_ctx *ctx,
|
||||||
src_rect.width -= src_x_offset;
|
src_rect.width -= src_x_offset;
|
||||||
src_rect.width = min_t(__s32, MAX_SRC_WIDTH, src_rect.width);
|
src_rect.width = min_t(__s32, MAX_SRC_WIDTH, src_rect.width);
|
||||||
|
|
||||||
dst_x_offset = (src_x_offset * dst->width) / ctx->src.crop.width;
|
dst_x_offset = (src_x_offset * dst_width) / ctx->src.crop.width;
|
||||||
dst_rect.left += dst_x_offset;
|
dst_rect.left += dst_x_offset;
|
||||||
dst_rect.width = (src_rect.width * dst->width) / ctx->src.crop.width;
|
dst_rect.width = (src_rect.width * dst_width) / ctx->src.crop.width;
|
||||||
|
|
||||||
/* General */
|
/* General */
|
||||||
src_fmt = src->fmt->pixelformat;
|
src_fmt = src->fmt->pixelformat;
|
||||||
|
|
|
@ -851,33 +851,56 @@ static int bdisp_g_selection(struct file *file, void *fh,
|
||||||
struct bdisp_frame *frame;
|
struct bdisp_frame *frame;
|
||||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||||
|
|
||||||
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
|
|
||||||
/* Composing / capture is not supported */
|
|
||||||
dev_dbg(ctx->bdisp_dev->dev, "Not supported for capture\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame = ctx_get_frame(ctx, s->type);
|
frame = ctx_get_frame(ctx, s->type);
|
||||||
if (IS_ERR(frame)) {
|
if (IS_ERR(frame)) {
|
||||||
dev_err(ctx->bdisp_dev->dev, "Invalid frame (%p)\n", frame);
|
dev_err(ctx->bdisp_dev->dev, "Invalid frame (%p)\n", frame);
|
||||||
return PTR_ERR(frame);
|
return PTR_ERR(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (s->target) {
|
switch (s->type) {
|
||||||
case V4L2_SEL_TGT_CROP:
|
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
|
||||||
/* cropped frame */
|
switch (s->target) {
|
||||||
s->r = frame->crop;
|
case V4L2_SEL_TGT_CROP:
|
||||||
|
/* cropped frame */
|
||||||
|
s->r = frame->crop;
|
||||||
|
break;
|
||||||
|
case V4L2_SEL_TGT_CROP_DEFAULT:
|
||||||
|
case V4L2_SEL_TGT_CROP_BOUNDS:
|
||||||
|
/* complete frame */
|
||||||
|
s->r.left = 0;
|
||||||
|
s->r.top = 0;
|
||||||
|
s->r.width = frame->width;
|
||||||
|
s->r.height = frame->height;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dev_err(ctx->bdisp_dev->dev, "Invalid target\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case V4L2_SEL_TGT_CROP_DEFAULT:
|
|
||||||
case V4L2_SEL_TGT_CROP_BOUNDS:
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
||||||
/* complete frame */
|
switch (s->target) {
|
||||||
s->r.left = 0;
|
case V4L2_SEL_TGT_COMPOSE:
|
||||||
s->r.top = 0;
|
case V4L2_SEL_TGT_COMPOSE_PADDED:
|
||||||
s->r.width = frame->width;
|
/* composed (cropped) frame */
|
||||||
s->r.height = frame->height;
|
s->r = frame->crop;
|
||||||
|
break;
|
||||||
|
case V4L2_SEL_TGT_COMPOSE_DEFAULT:
|
||||||
|
case V4L2_SEL_TGT_COMPOSE_BOUNDS:
|
||||||
|
/* complete frame */
|
||||||
|
s->r.left = 0;
|
||||||
|
s->r.top = 0;
|
||||||
|
s->r.width = frame->width;
|
||||||
|
s->r.height = frame->height;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dev_err(ctx->bdisp_dev->dev, "Invalid target\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dev_dbg(ctx->bdisp_dev->dev, "Invalid target\n");
|
dev_err(ctx->bdisp_dev->dev, "Invalid type\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,15 +929,18 @@ static int bdisp_s_selection(struct file *file, void *fh,
|
||||||
struct bdisp_frame *frame;
|
struct bdisp_frame *frame;
|
||||||
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
struct bdisp_ctx *ctx = fh_to_ctx(fh);
|
||||||
struct v4l2_rect *in, out;
|
struct v4l2_rect *in, out;
|
||||||
|
bool valid = false;
|
||||||
|
|
||||||
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
|
if ((s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) &&
|
||||||
/* Composing / capture is not supported */
|
(s->target == V4L2_SEL_TGT_CROP))
|
||||||
dev_dbg(ctx->bdisp_dev->dev, "Not supported for capture\n");
|
valid = true;
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->target != V4L2_SEL_TGT_CROP) {
|
if ((s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
|
||||||
dev_dbg(ctx->bdisp_dev->dev, "Invalid target\n");
|
(s->target == V4L2_SEL_TGT_COMPOSE))
|
||||||
|
valid = true;
|
||||||
|
|
||||||
|
if (!valid) {
|
||||||
|
dev_err(ctx->bdisp_dev->dev, "Invalid type / target\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue