2a0380f5ed90e67271e27a0d4fd58c7d9d2520d5
[openwrt/staging/hauke.git] /
1 From 3df60f3d0615c011e91b7d6f39cb9123b2e96530 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Mon, 20 Sep 2021 14:37:17 +0100
4 Subject: [PATCH] staging: bcm2835-codec: Add support for H&V Flips to
5 ISP
6
7 The ISP can do H & V flips whilst resizing or converting
8 the image, so expose that via V4L2_CID_[H|V]FLIP.
9
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
11 ---
12 .../bcm2835-codec/bcm2835-v4l2-codec.c | 48 +++++++++++++++++++
13 1 file changed, 48 insertions(+)
14
15 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
16 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
17 @@ -679,6 +679,9 @@ struct bcm2835_codec_ctx {
18 enum v4l2_xfer_func xfer_func;
19 enum v4l2_quantization quant;
20
21 + int hflip;
22 + int vflip;
23 +
24 /* Source and destination queue data */
25 struct bcm2835_codec_q_data q_data[2];
26 s32 bitrate;
27 @@ -2202,6 +2205,34 @@ static int bcm2835_codec_s_ctrl(struct v
28 sizeof(mmal_bool));
29 break;
30 }
31 + case V4L2_CID_HFLIP:
32 + case V4L2_CID_VFLIP: {
33 + u32 u32_value;
34 +
35 + if (ctrl->id == V4L2_CID_HFLIP)
36 + ctx->hflip = ctrl->val;
37 + else
38 + ctx->vflip = ctrl->val;
39 +
40 + if (!ctx->component)
41 + break;
42 +
43 + if (ctx->hflip && ctx->vflip)
44 + u32_value = MMAL_PARAM_MIRROR_BOTH;
45 + else if (ctx->hflip)
46 + u32_value = MMAL_PARAM_MIRROR_HORIZONTAL;
47 + else if (ctx->vflip)
48 + u32_value = MMAL_PARAM_MIRROR_VERTICAL;
49 + else
50 + u32_value = MMAL_PARAM_MIRROR_NONE;
51 +
52 + ret = vchiq_mmal_port_parameter_set(ctx->dev->instance,
53 + &ctx->component->input[0],
54 + MMAL_PARAMETER_MIRROR,
55 + &u32_value,
56 + sizeof(u32_value));
57 + break;
58 + }
59
60 default:
61 v4l2_err(&ctx->dev->v4l2_dev, "Invalid control\n");
62 @@ -3152,6 +3183,23 @@ static int bcm2835_codec_open(struct fil
63 }
64 break;
65 case ISP:
66 + {
67 + v4l2_ctrl_handler_init(hdl, 2);
68 +
69 + v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
70 + V4L2_CID_HFLIP,
71 + 1, 0, 1, 0);
72 + v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
73 + V4L2_CID_VFLIP,
74 + 1, 0, 1, 0);
75 + if (hdl->error) {
76 + rc = hdl->error;
77 + goto free_ctrl_handler;
78 + }
79 + ctx->fh.ctrl_handler = hdl;
80 + v4l2_ctrl_handler_setup(hdl);
81 + }
82 + break;
83 case DEINTERLACE:
84 {
85 v4l2_ctrl_handler_init(hdl, 0);