[media] media: coda: add horizontal / vertical flipping support
authorPhilipp Zabel <p.zabel@pengutronix.de>
Mon, 9 Jul 2012 07:25:52 +0000 (04:25 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 26 Sep 2012 19:55:22 +0000 (16:55 -0300)
The hardware can also rotate in 90° steps, but there is no
corresponding V4L2_CID defined yet.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Tested-by: Javier Martin <javier.martin@vista-silicon.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/platform/coda.c
drivers/media/platform/coda.h

index 2e046d057e66f4a694803c7318fd0a7c4c6b7c1f..23985b3447ac29f7913d846aa3a8858b8fd8569d 100644 (file)
@@ -141,6 +141,7 @@ struct coda_dev {
 };
 
 struct coda_params {
+       u8                      rot_mode;
        u8                      h264_intra_qp;
        u8                      h264_inter_qp;
        u8                      mpeg4_intra_qp;
@@ -700,7 +701,7 @@ static void coda_device_run(void *m2m_priv)
        }
 
        /* submit */
-       coda_write(dev, 0, CODA_CMD_ENC_PIC_ROT_MODE);
+       coda_write(dev, CODA_ROT_MIR_ENABLE | ctx->params.rot_mode, CODA_CMD_ENC_PIC_ROT_MODE);
        coda_write(dev, quant_param, CODA_CMD_ENC_PIC_QS);
 
 
@@ -1276,6 +1277,18 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl)
                 "s_ctrl: id = %d, val = %d\n", ctrl->id, ctrl->val);
 
        switch (ctrl->id) {
+       case V4L2_CID_HFLIP:
+               if (ctrl->val)
+                       ctx->params.rot_mode |= CODA_MIR_HOR;
+               else
+                       ctx->params.rot_mode &= ~CODA_MIR_HOR;
+               break;
+       case V4L2_CID_VFLIP:
+               if (ctrl->val)
+                       ctx->params.rot_mode |= CODA_MIR_VER;
+               else
+                       ctx->params.rot_mode &= ~CODA_MIR_VER;
+               break;
        case V4L2_CID_MPEG_VIDEO_BITRATE:
                ctx->params.bitrate = ctrl->val / 1000;
                break;
@@ -1320,6 +1333,10 @@ static int coda_ctrls_setup(struct coda_ctx *ctx)
 {
        v4l2_ctrl_handler_init(&ctx->ctrls, 9);
 
+       v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
+               V4L2_CID_HFLIP, 0, 1, 1, 0);
+       v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
+               V4L2_CID_VFLIP, 0, 1, 1, 0);
        v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
                V4L2_CID_MPEG_VIDEO_BITRATE, 0, 32767000, 1, 0);
        v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
index 332401033194ea801b7f7b5b5a0d342e462a1886..f3f5e43c1ac23b2ac056ab598910c745d19320e5 100644 (file)
 #define CODA_CMD_ENC_PIC_SRC_ADDR_CR   0x188
 #define CODA_CMD_ENC_PIC_QS            0x18c
 #define CODA_CMD_ENC_PIC_ROT_MODE      0x190
+#define                CODA_ROT_MIR_ENABLE                             (1 << 4)
+#define                CODA_ROT_0                                      (0x0 << 0)
+#define                CODA_ROT_90                                     (0x1 << 0)
+#define                CODA_ROT_180                                    (0x2 << 0)
+#define                CODA_ROT_270                                    (0x3 << 0)
+#define                CODA_MIR_NONE                                   (0x0 << 2)
+#define                CODA_MIR_VER                                    (0x1 << 2)
+#define                CODA_MIR_HOR                                    (0x2 << 2)
+#define                CODA_MIR_VER_HOR                                (0x3 << 2)
 #define CODA_CMD_ENC_PIC_OPTION        0x194
 #define CODA_CMD_ENC_PIC_BB_START      0x198
 #define CODA_CMD_ENC_PIC_BB_SIZE       0x19c