#include <linux/videodev2.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
+#include <media/v4l2-event.h>
 #include "videocodec.h"
 
 #include <asm/byteorder.h>
                res = -ENOMEM;
                goto fail_unlock;
        }
+       v4l2_fh_init(&fh->fh, video_devdata(file));
+
        /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows
         * on norm-change! */
        fh->overlay_mask =
        file->private_data = fh;
        fh->zr = zr;
        zoran_open_init_session(fh);
+       v4l2_fh_add(&fh->fh);
        mutex_unlock(&zr->lock);
 
        return 0;
        }
        mutex_unlock(&zr->lock);
 
+       v4l2_fh_del(&fh->fh);
+       v4l2_fh_exit(&fh->fh);
        kfree(fh->overlay_mask);
        kfree(fh);
 
        }
        return res;
 }
-
-static int zoran_queryctrl(struct file *file, void *__fh,
-                                       struct v4l2_queryctrl *ctrl)
-{
-       struct zoran_fh *fh = __fh;
-       struct zoran *zr = fh->zr;
-
-       /* we only support hue/saturation/contrast/brightness */
-       if (ctrl->id < V4L2_CID_BRIGHTNESS ||
-           ctrl->id > V4L2_CID_HUE)
-               return -EINVAL;
-
-       decoder_call(zr, core, queryctrl, ctrl);
-
-       return 0;
-}
-
-static int zoran_g_ctrl(struct file *file, void *__fh, struct v4l2_control *ctrl)
-{
-       struct zoran_fh *fh = __fh;
-       struct zoran *zr = fh->zr;
-
-       /* we only support hue/saturation/contrast/brightness */
-       if (ctrl->id < V4L2_CID_BRIGHTNESS ||
-           ctrl->id > V4L2_CID_HUE)
-               return -EINVAL;
-
-       decoder_call(zr, core, g_ctrl, ctrl);
-
-       return 0;
-}
-
-static int zoran_s_ctrl(struct file *file, void *__fh, struct v4l2_control *ctrl)
-{
-       struct zoran_fh *fh = __fh;
-       struct zoran *zr = fh->zr;
-
-       /* we only support hue/saturation/contrast/brightness */
-       if (ctrl->id < V4L2_CID_BRIGHTNESS ||
-           ctrl->id > V4L2_CID_HUE)
-               return -EINVAL;
-
-       decoder_call(zr, core, s_ctrl, ctrl);
-
-       return 0;
-}
-
 static int zoran_g_std(struct file *file, void *__fh, v4l2_std_id *std)
 {
        struct zoran_fh *fh = __fh;
 {
        struct zoran_fh *fh = file->private_data;
        struct zoran *zr = fh->zr;
-       int res = 0, frame;
+       int res = v4l2_ctrl_poll(file, wait);
+       int frame;
        unsigned long flags;
 
        /* we should check whether buffers are ready to be synced on
                if (fh->buffers.active != ZORAN_FREE &&
                    /* Buffer ready to DQBUF? */
                    zr->v4l_buffers.buffer[frame].state == BUZ_STATE_DONE)
-                       res = POLLIN | POLLRDNORM;
+                       res |= POLLIN | POLLRDNORM;
                spin_unlock_irqrestore(&zr->spinlock, flags);
 
                break;
                if (fh->buffers.active != ZORAN_FREE &&
                    zr->jpg_buffers.buffer[frame].state == BUZ_STATE_DONE) {
                        if (fh->map_mode == ZORAN_MAP_MODE_JPG_REC)
-                               res = POLLIN | POLLRDNORM;
+                               res |= POLLIN | POLLRDNORM;
                        else
-                               res = POLLOUT | POLLWRNORM;
+                               res |= POLLOUT | POLLWRNORM;
                }
                spin_unlock_irqrestore(&zr->spinlock, flags);
 
                        KERN_ERR
                        "%s: %s - internal error, unknown map_mode=%d\n",
                        ZR_DEVNAME(zr), __func__, fh->map_mode);
-               res = POLLNVAL;
+               res |= POLLERR;
        }
 
        return res;
        .vidioc_try_fmt_vid_cap             = zoran_try_fmt_vid_cap,
        .vidioc_try_fmt_vid_out             = zoran_try_fmt_vid_out,
        .vidioc_try_fmt_vid_overlay         = zoran_try_fmt_vid_overlay,
-       .vidioc_queryctrl                   = zoran_queryctrl,
-       .vidioc_s_ctrl                      = zoran_s_ctrl,
-       .vidioc_g_ctrl                      = zoran_g_ctrl,
+       .vidioc_subscribe_event             = v4l2_ctrl_subscribe_event,
+       .vidioc_unsubscribe_event           = v4l2_event_unsubscribe,
 };
 
 static const struct v4l2_file_operations zoran_fops = {