Skip to content

Commit

Permalink
staging: bcm2835-codec: Add support for H&V Flips to ISP
Browse files Browse the repository at this point in the history
The ISP can do H & V flips whilst resizing or converting
the image, so expose that via V4L2_CID_[H|V]FLIP.

Signed-off-by: Dave Stevenson <[email protected]>
  • Loading branch information
6by9 committed Sep 22, 2021
1 parent eb71546 commit 0dcf5b9
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,9 @@ struct bcm2835_codec_ctx {
enum v4l2_xfer_func xfer_func;
enum v4l2_quantization quant;

int hflip;
int vflip;

/* Source and destination queue data */
struct bcm2835_codec_q_data q_data[2];
s32 bitrate;
Expand Down Expand Up @@ -2201,6 +2204,34 @@ static int bcm2835_codec_s_ctrl(struct v4l2_ctrl *ctrl)
sizeof(mmal_bool));
break;
}
case V4L2_CID_HFLIP:
case V4L2_CID_VFLIP: {
u32 u32_value;

if (ctrl->id == V4L2_CID_HFLIP)
ctx->hflip = ctrl->val;
else
ctx->vflip = ctrl->val;

if (!ctx->component)
break;

if (ctx->hflip && ctx->vflip)
u32_value = MMAL_PARAM_MIRROR_BOTH;
else if (ctx->hflip)
u32_value = MMAL_PARAM_MIRROR_HORIZONTAL;
else if (ctx->vflip)
u32_value = MMAL_PARAM_MIRROR_VERTICAL;
else
u32_value = MMAL_PARAM_MIRROR_NONE;

ret = vchiq_mmal_port_parameter_set(ctx->dev->instance,
&ctx->component->input[0],
MMAL_PARAMETER_MIRROR,
&u32_value,
sizeof(u32_value));
break;
}

default:
v4l2_err(&ctx->dev->v4l2_dev, "Invalid control\n");
Expand Down Expand Up @@ -3151,6 +3182,23 @@ static int bcm2835_codec_open(struct file *file)
}
break;
case ISP:
{
v4l2_ctrl_handler_init(hdl, 2);

v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
V4L2_CID_HFLIP,
1, 0, 1, 0);
v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
V4L2_CID_VFLIP,
1, 0, 1, 0);
if (hdl->error) {
rc = hdl->error;
goto free_ctrl_handler;
}
ctx->fh.ctrl_handler = hdl;
v4l2_ctrl_handler_setup(hdl);
}
break;
case DEINTERLACE:
{
v4l2_ctrl_handler_init(hdl, 0);
Expand Down

0 comments on commit 0dcf5b9

Please sign in to comment.