#include <linux/device.h>
 #include <linux/gfp.h>
-#include <linux/vsp1.h>
 
 #include <media/v4l2-subdev.h>
 
 }
 
 /* -----------------------------------------------------------------------------
- * V4L2 Subdevice Core Operations
+ * Controls
  */
 
-static int lut_set_table(struct vsp1_lut *lut, struct vsp1_lut_config *config)
+#define V4L2_CID_VSP1_LUT_TABLE                        (V4L2_CID_USER_BASE | 0x1001)
+
+static int lut_set_table(struct vsp1_lut *lut, struct v4l2_ctrl *ctrl)
 {
        struct vsp1_dl_body *dlb;
        unsigned int i;
 
-       dlb = vsp1_dl_fragment_alloc(lut->entity.vsp1, ARRAY_SIZE(config->lut));
+       dlb = vsp1_dl_fragment_alloc(lut->entity.vsp1, 256);
        if (!dlb)
                return -ENOMEM;
 
-       for (i = 0; i < ARRAY_SIZE(config->lut); ++i)
+       for (i = 0; i < 256; ++i)
                vsp1_dl_fragment_write(dlb, VI6_LUT_TABLE + 4 * i,
-                                      config->lut[i]);
+                                      ctrl->p_new.p_u32[i]);
 
-       mutex_lock(&lut->lock);
        swap(lut->lut, dlb);
-       mutex_unlock(&lut->lock);
 
        vsp1_dl_fragment_free(dlb);
        return 0;
 }
 
-static long lut_ioctl(struct v4l2_subdev *subdev, unsigned int cmd, void *arg)
+static int lut_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-       struct vsp1_lut *lut = to_lut(subdev);
-
-       switch (cmd) {
-       case VIDIOC_VSP1_LUT_CONFIG:
-               return lut_set_table(lut, arg);
+       struct vsp1_lut *lut =
+               container_of(ctrl->handler, struct vsp1_lut, ctrls);
 
-       default:
-               return -ENOIOCTLCMD;
+       switch (ctrl->id) {
+       case V4L2_CID_VSP1_LUT_TABLE:
+               lut_set_table(lut, ctrl);
+               break;
        }
+
+       return 0;
 }
 
+static const struct v4l2_ctrl_ops lut_ctrl_ops = {
+       .s_ctrl = lut_s_ctrl,
+};
+
+static const struct v4l2_ctrl_config lut_table_control = {
+       .ops = &lut_ctrl_ops,
+       .id = V4L2_CID_VSP1_LUT_TABLE,
+       .name = "Look-Up Table",
+       .type = V4L2_CTRL_TYPE_U32,
+       .min = 0x00000000,
+       .max = 0x00ffffff,
+       .step = 1,
+       .def = 0,
+       .dims = { 256},
+};
+
 /* -----------------------------------------------------------------------------
  * V4L2 Subdevice Pad Operations
  */
  * V4L2 Subdevice Operations
  */
 
-static const struct v4l2_subdev_core_ops lut_core_ops = {
-       .ioctl = lut_ioctl,
-};
-
 static const struct v4l2_subdev_pad_ops lut_pad_ops = {
        .init_cfg = vsp1_entity_init_cfg,
        .enum_mbus_code = lut_enum_mbus_code,
 };
 
 static const struct v4l2_subdev_ops lut_ops = {
-       .core   = &lut_core_ops,
        .pad    = &lut_pad_ops,
 };
 
 
        vsp1_lut_write(lut, dl, VI6_LUT_CTRL, VI6_LUT_CTRL_EN);
 
-       mutex_lock(&lut->lock);
+       mutex_lock(lut->ctrls.lock);
+
        if (lut->lut) {
                vsp1_dl_list_add_fragment(dl, lut->lut);
                lut->lut = NULL;
        }
-       mutex_unlock(&lut->lock);
+
+       mutex_unlock(lut->ctrls.lock);
 }
 
 static const struct vsp1_entity_operations lut_entity_ops = {
        if (lut == NULL)
                return ERR_PTR(-ENOMEM);
 
-       mutex_init(&lut->lock);
-
        lut->entity.ops = &lut_entity_ops;
        lut->entity.type = VSP1_ENTITY_LUT;
 
        if (ret < 0)
                return ERR_PTR(ret);
 
+       /* Initialize the control handler. */
+       v4l2_ctrl_handler_init(&lut->ctrls, 1);
+       v4l2_ctrl_new_custom(&lut->ctrls, &lut_table_control, NULL);
+
+       lut->entity.subdev.ctrl_handler = &lut->ctrls;
+
+       if (lut->ctrls.error) {
+               dev_err(vsp1->dev, "lut: failed to initialize controls\n");
+               ret = lut->ctrls.error;
+               vsp1_entity_destroy(&lut->entity);
+               return ERR_PTR(ret);
+       }
+
+       v4l2_ctrl_handler_setup(&lut->ctrls);
+
        return lut;
 }
 
+++ /dev/null
-/*
- * vsp1.h
- *
- * Renesas R-Car VSP1 - User-space API
- *
- * Copyright (C) 2013 Renesas Corporation
- *
- * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef __VSP1_USER_H__
-#define __VSP1_USER_H__
-
-#include <linux/types.h>
-#include <linux/videodev2.h>
-
-/*
- * Private IOCTLs
- *
- * VIDIOC_VSP1_LUT_CONFIG - Configure the lookup table
- */
-
-#define VIDIOC_VSP1_LUT_CONFIG \
-       _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct vsp1_lut_config)
-
-struct vsp1_lut_config {
-       __u32 lut[256];
-};
-
-#endif /* __VSP1_USER_H__ */