long css2600_psys_compat_ioctl32(struct file *file, unsigned int cmd,
					unsigned long arg)
{
	union {
		struct css2600_psys_buffer buf;
		struct css2600_psys_command cmd;
		struct css2600_psys_event ev;
	} karg;
	int compatible_arg = 1;
	int err = 0;
	void __user *up = compat_ptr(arg);

	switch (cmd) {
	case CSS2600_IOC_GETBUF32:
		cmd = CSS2600_IOC_GETBUF;
		break;
	case CSS2600_IOC_PUTBUF32:
		cmd = CSS2600_IOC_PUTBUF;
		break;
	case CSS2600_IOC_QCMD32:
		cmd = CSS2600_IOC_QCMD;
		break;
	}

	switch (cmd) {
	case CSS2600_IOC_GETBUF:
	case CSS2600_IOC_PUTBUF:
		err = get_css2600_psys_buffer32(&karg.buf, up);
		compatible_arg = 0;
		break;
	case CSS2600_IOC_QCMD:
		err = get_css2600_psys_command32(&karg.cmd, up);
		compatible_arg = 0;
		break;
	}
	if (err)
		return err;

	if (compatible_arg) {
		err = native_ioctl(file, cmd, (unsigned long)up);
	} else {
		mm_segment_t old_fs = get_fs();

		set_fs(KERNEL_DS);
		err = native_ioctl(file, cmd, (unsigned long)&karg);
		set_fs(old_fs);
	}

	if (err)
		return err;

	switch (cmd) {
	case CSS2600_IOC_GETBUF:
		err = put_css2600_psys_buffer32(&karg.buf, up);
		break;
	}
	return err;
}
Exemplo n.º 2
0
static int do_set_window(struct file *file, unsigned int cmd, unsigned long arg)
{
    struct video_window32 __user *up = compat_ptr(arg);
    struct video_window __user *vw;
    struct video_clip __user *p;
    int nclips;
    u32 n;

    if (!access_ok(VERIFY_READ, up, sizeof(struct video_window32)))
        return -EFAULT;

    if (get_user(nclips, &up->clipcount))
        return -EFAULT;

    /* Peculiar interface... */
    if (nclips < 0)
        nclips = VIDEO_CLIPMAP_SIZE;

    if (nclips > MaxClips)
        return -ENOMEM;

    vw = compat_alloc_user_space(sizeof(struct video_window) +
                    nclips * sizeof(struct video_clip));

    p = nclips ? (struct video_clip __user *)(vw + 1) : NULL;

    if (get_user(n, &up->x) || put_user(n, &vw->x) ||
        get_user(n, &up->y) || put_user(n, &vw->y) ||
        get_user(n, &up->width) || put_user(n, &vw->width) ||
        get_user(n, &up->height) || put_user(n, &vw->height) ||
        get_user(n, &up->chromakey) || put_user(n, &vw->chromakey) ||
        get_user(n, &up->flags) || put_user(n, &vw->flags) ||
        get_user(n, &up->clipcount) || put_user(n, &vw->clipcount) ||
        get_user(n, &up->clips) || put_user(p, &vw->clips))
        return -EFAULT;

    if (nclips) {
        struct video_clip32 __user *u = compat_ptr(n);
        int i;
        if (!u)
            return -EINVAL;
        for (i = 0; i < nclips; i++, u++, p++) {
            s32 v;
            if (!access_ok(VERIFY_READ, u, sizeof(struct video_clip32)) ||
                !access_ok(VERIFY_WRITE, p, sizeof(struct video_clip32)) ||
                get_user(v, &u->x) ||
                put_user(v, &p->x) ||
                get_user(v, &u->y) ||
                put_user(v, &p->y) ||
                get_user(v, &u->width) ||
                put_user(v, &p->width) ||
                get_user(v, &u->height) ||
                put_user(v, &p->height) ||
                put_user(NULL, &p->next))
                return -EFAULT;
        }
    }

    return native_ioctl(file, VIDIOCSWIN, (unsigned long)vw);
}
Exemplo n.º 3
0
long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
{
    int ret = -ENOIOCTLCMD;

    if (!file->f_op->ioctl)
        return ret;

    switch (cmd) {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
    case VIDIOCSWIN32:
        ret = do_set_window(file, cmd, arg);
        break;
    case VIDIOCGTUNER32:
    case VIDIOCSTUNER32:
    case VIDIOCGWIN32:
    case VIDIOCGFBUF32:
    case VIDIOCSFBUF32:
    case VIDIOCGFREQ32:
    case VIDIOCSFREQ32:
    case VIDIOCGAUDIO:
    case VIDIOCSAUDIO:
    case VIDIOCGVBIFMT:
    case VIDIOCSVBIFMT:
#endif
    case VIDIOC_QUERYCAP:
    case VIDIOC_ENUM_FMT:
    case VIDIOC_G_FMT32:
    case VIDIOC_CROPCAP:
    case VIDIOC_S_CROP:
    case VIDIOC_S_FMT32:
    case VIDIOC_REQBUFS:
    case VIDIOC_QUERYBUF32:
    case VIDIOC_G_FBUF32:
    case VIDIOC_S_FBUF32:
    case VIDIOC_OVERLAY32:
    case VIDIOC_QBUF32:
    case VIDIOC_DQBUF32:
    case VIDIOC_STREAMON32:
    case VIDIOC_STREAMOFF32:
    case VIDIOC_G_PARM:
    case VIDIOC_G_STD:
    case VIDIOC_S_STD:
    case VIDIOC_G_TUNER:
    case VIDIOC_S_TUNER:
    case VIDIOC_ENUMSTD:
    case VIDIOC_ENUMSTD32:
    case VIDIOC_ENUMINPUT:
    case VIDIOC_ENUMINPUT32:
    case VIDIOC_G_CTRL:
    case VIDIOC_S_CTRL:
    case VIDIOC_S_CTRL32:
    case VIDIOC_S_FREQUENCY:
    case VIDIOC_G_FREQUENCY:
    case VIDIOC_QUERYCTRL:
    case VIDIOC_G_INPUT32:
    case VIDIOC_S_INPUT32:
    case VIDIOC_TRY_FMT32:
        ret = do_video_ioctl(file, cmd, arg);
        break;

#ifdef CONFIG_VIDEO_V4L1_COMPAT
    /* Little v, the video4linux ioctls (conflict?) */
    case VIDIOCGCAP:
    case VIDIOCGCHAN:
    case VIDIOCSCHAN:
    case VIDIOCGPICT:
    case VIDIOCSPICT:
    case VIDIOCCAPTURE:
    case VIDIOCKEY:
    case VIDIOCSYNC:
    case VIDIOCMCAPTURE:
    case VIDIOCGMBUF:
    case VIDIOCGUNIT:
    case VIDIOCGCAPTURE:
    case VIDIOCSCAPTURE:

    /* BTTV specific... */
    case _IOW('v',  BASE_VIDIOCPRIVATE+0, char [256]):
    case _IOR('v',  BASE_VIDIOCPRIVATE+1, char [256]):
    case _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int):
    case _IOW('v' , BASE_VIDIOCPRIVATE+3, char [16]): /* struct bttv_pll_info */
    case _IOR('v' , BASE_VIDIOCPRIVATE+4, int):
    case _IOR('v' , BASE_VIDIOCPRIVATE+5, int):
    case _IOR('v' , BASE_VIDIOCPRIVATE+6, int):
    case _IOR('v' , BASE_VIDIOCPRIVATE+7, int):
        ret = native_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
        break;
#endif
    default:
        v4l_print_ioctl("compat_ioctl32", cmd);
    }
    return ret;
}
Exemplo n.º 4
0
static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
    union {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
        struct video_tuner vt;
        struct video_buffer vb;
        struct video_window vw;
        struct video_code vc;
        struct video_audio va;
#endif
        struct v4l2_format v2f;
        struct v4l2_buffer v2b;
        struct v4l2_framebuffer v2fb;
        struct v4l2_standard v2s;
        struct v4l2_input v2i;
        struct v4l2_tuner v2t;
        unsigned long vx;
    } karg;
    void __user *up = compat_ptr(arg);
    int compatible_arg = 1;
    int err = 0;
    int realcmd = cmd;

    /* First, convert the command. */
    switch(cmd) {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
    case VIDIOCGTUNER32: realcmd = cmd = VIDIOCGTUNER; break;
    case VIDIOCSTUNER32: realcmd = cmd = VIDIOCSTUNER; break;
    case VIDIOCGWIN32: realcmd = cmd = VIDIOCGWIN; break;
    case VIDIOCGFBUF32: realcmd = cmd = VIDIOCGFBUF; break;
    case VIDIOCSFBUF32: realcmd = cmd = VIDIOCSFBUF; break;
    case VIDIOCGFREQ32: realcmd = cmd = VIDIOCGFREQ; break;
    case VIDIOCSFREQ32: realcmd = cmd = VIDIOCSFREQ; break;
    case VIDIOCSMICROCODE32: realcmd = cmd = VIDIOCSMICROCODE; break;
#endif
    case VIDIOC_G_FMT32: realcmd = cmd = VIDIOC_G_FMT; break;
    case VIDIOC_S_FMT32: realcmd = cmd = VIDIOC_S_FMT; break;
    case VIDIOC_QUERYBUF32: realcmd = cmd = VIDIOC_QUERYBUF; break;
    case VIDIOC_QBUF32: realcmd = cmd = VIDIOC_QBUF; break;
    case VIDIOC_DQBUF32: realcmd = cmd = VIDIOC_DQBUF; break;
    case VIDIOC_STREAMON32: realcmd = cmd = VIDIOC_STREAMON; break;
    case VIDIOC_STREAMOFF32: realcmd = cmd = VIDIOC_STREAMOFF; break;
    case VIDIOC_G_FBUF32: realcmd = cmd = VIDIOC_G_FBUF; break;
    case VIDIOC_S_FBUF32: realcmd = cmd = VIDIOC_S_FBUF; break;
    case VIDIOC_OVERLAY32: realcmd = cmd = VIDIOC_OVERLAY; break;
    case VIDIOC_ENUMSTD32: realcmd = VIDIOC_ENUMSTD; break;
    case VIDIOC_ENUMINPUT32: realcmd = VIDIOC_ENUMINPUT; break;
    case VIDIOC_S_CTRL32: realcmd = cmd = VIDIOC_S_CTRL; break;
    case VIDIOC_G_INPUT32: realcmd = cmd = VIDIOC_G_INPUT; break;
    case VIDIOC_S_INPUT32: realcmd = cmd = VIDIOC_S_INPUT; break;
    case VIDIOC_TRY_FMT32: realcmd = cmd = VIDIOC_TRY_FMT; break;
    };

    switch(cmd) {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
    case VIDIOCSTUNER:
    case VIDIOCGTUNER:
        err = get_video_tuner32(&karg.vt, up);
        compatible_arg = 0;

        break;

    case VIDIOCSFBUF:
        err = get_video_buffer32(&karg.vb, up);
        compatible_arg = 0;
        break;


    case VIDIOCSFREQ:
#endif
    case VIDIOC_S_INPUT:
    case VIDIOC_OVERLAY:
    case VIDIOC_STREAMON:
    case VIDIOC_STREAMOFF:
        err = get_user(karg.vx, (u32 __user *)up);
        compatible_arg = 1;
        break;

    case VIDIOC_S_FBUF:
        err = get_v4l2_framebuffer32(&karg.v2fb, up);
        compatible_arg = 0;
        break;

    case VIDIOC_G_FMT:
    case VIDIOC_S_FMT:
    case VIDIOC_TRY_FMT:
        err = get_v4l2_format32(&karg.v2f, up);
        compatible_arg = 0;
        break;

    case VIDIOC_QUERYBUF:
    case VIDIOC_QBUF:
    case VIDIOC_DQBUF:
        err = get_v4l2_buffer32(&karg.v2b, up);
        compatible_arg = 0;
        break;

    case VIDIOC_ENUMSTD:
        err = get_v4l2_standard(&karg.v2s, up);
        compatible_arg = 0;
        break;

    case VIDIOC_ENUMSTD32:
        err = get_v4l2_standard32(&karg.v2s, up);
        compatible_arg = 0;
        break;

    case VIDIOC_ENUMINPUT:
        err = get_v4l2_input(&karg.v2i, up);
        compatible_arg = 0;
        break;

    case VIDIOC_ENUMINPUT32:
        err = get_v4l2_input32(&karg.v2i, up);
        compatible_arg = 0;
        break;

    case VIDIOC_G_TUNER:
    case VIDIOC_S_TUNER:
        err = get_v4l2_tuner(&karg.v2t, up);
        compatible_arg = 0;
        break;

#ifdef CONFIG_VIDEO_V4L1_COMPAT
    case VIDIOCGWIN:
    case VIDIOCGFBUF:
    case VIDIOCGFREQ:
#endif
    case VIDIOC_G_FBUF:
    case VIDIOC_G_INPUT:
        compatible_arg = 0;
        break;
#ifdef CONFIG_VIDEO_V4L1_COMPAT
    case VIDIOCSMICROCODE:
        err = microcode32(&karg.vc, up);
        compatible_arg = 0;
        break;
#endif
    };
    if(err)
        goto out;

    if(compatible_arg)
        err = native_ioctl(file, realcmd, (unsigned long)up);
    else {
        mm_segment_t old_fs = get_fs();

        set_fs(KERNEL_DS);
        err = native_ioctl(file, realcmd, (unsigned long) &karg);
        set_fs(old_fs);
    }
    if(err == 0) {
        switch(cmd) {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
        case VIDIOCGTUNER:
            err = put_video_tuner32(&karg.vt, up);
            break;

        case VIDIOCGWIN:
            err = put_video_window32(&karg.vw, up);
            break;

        case VIDIOCGFBUF:
            err = put_video_buffer32(&karg.vb, up);
            break;

#endif
        case VIDIOC_G_FBUF:
            err = put_v4l2_framebuffer32(&karg.v2fb, up);
            break;

        case VIDIOC_G_FMT:
        case VIDIOC_S_FMT:
        case VIDIOC_TRY_FMT:
            err = put_v4l2_format32(&karg.v2f, up);
            break;

        case VIDIOC_QUERYBUF:
        case VIDIOC_QBUF:
        case VIDIOC_DQBUF:
            err = put_v4l2_buffer32(&karg.v2b, up);
            break;

        case VIDIOC_ENUMSTD:
            err = put_v4l2_standard(&karg.v2s, up);
            break;

        case VIDIOC_ENUMSTD32:
            err = put_v4l2_standard32(&karg.v2s, up);
            break;

        case VIDIOC_G_TUNER:
        case VIDIOC_S_TUNER:
            err = put_v4l2_tuner(&karg.v2t, up);
            break;

        case VIDIOC_ENUMINPUT:
            err = put_v4l2_input(&karg.v2i, up);
            break;

        case VIDIOC_ENUMINPUT32:
            err = put_v4l2_input32(&karg.v2i, up);
            break;

#ifdef CONFIG_VIDEO_V4L1_COMPAT
        case VIDIOCGFREQ:
#endif
        case VIDIOC_G_INPUT:
            err = put_user(((u32)karg.vx), (u32 __user *)up);
            break;
        };
    }
out:
    return err;
}
Exemplo n.º 5
0
long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
{
	long ret = -ENOIOCTLCMD;

	if (!file->f_op->unlocked_ioctl)
		return ret;

	switch (cmd) {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
	case VIDIOCGCAP:
	case VIDIOCGCHAN:
	case VIDIOCSCHAN:
	case VIDIOCGTUNER32:
	case VIDIOCSTUNER32:
	case VIDIOCGPICT:
	case VIDIOCSPICT:
	case VIDIOCCAPTURE32:
	case VIDIOCGWIN32:
	case VIDIOCSWIN32:
	case VIDIOCGFBUF32:
	case VIDIOCSFBUF32:
	case VIDIOCKEY:
	case VIDIOCGFREQ32:
	case VIDIOCSFREQ32:
	case VIDIOCGAUDIO:
	case VIDIOCSAUDIO:
	case VIDIOCSYNC32:
	case VIDIOCMCAPTURE:
	case VIDIOCGMBUF:
	case VIDIOCGUNIT:
	case VIDIOCGCAPTURE:
	case VIDIOCSCAPTURE:
	case VIDIOCSPLAYMODE:
	case VIDIOCSWRITEMODE32:
	case VIDIOCGPLAYINFO:
	case VIDIOCSMICROCODE32:
	case VIDIOCGVBIFMT:
	case VIDIOCSVBIFMT:
#endif
#ifdef __OLD_VIDIOC_
	case VIDIOC_OVERLAY32_OLD:
	case VIDIOC_S_PARM_OLD:
	case VIDIOC_S_CTRL_OLD:
	case VIDIOC_G_AUDIO_OLD:
	case VIDIOC_G_AUDOUT_OLD:
	case VIDIOC_CROPCAP_OLD:
#endif
	case VIDIOC_QUERYCAP:
	case VIDIOC_RESERVED:
	case VIDIOC_ENUM_FMT:
	case VIDIOC_G_FMT32:
	case VIDIOC_S_FMT32:
	case VIDIOC_REQBUFS:
	case VIDIOC_QUERYBUF32:
	case VIDIOC_G_FBUF32:
	case VIDIOC_S_FBUF32:
	case VIDIOC_OVERLAY32:
	case VIDIOC_QBUF32:
	case VIDIOC_DQBUF32:
	case VIDIOC_STREAMON32:
	case VIDIOC_STREAMOFF32:
	case VIDIOC_G_PARM:
	case VIDIOC_S_PARM:
	case VIDIOC_G_STD:
	case VIDIOC_S_STD:
	case VIDIOC_ENUMSTD32:
	case VIDIOC_ENUMINPUT32:
	case VIDIOC_G_CTRL:
	case VIDIOC_S_CTRL:
	case VIDIOC_G_TUNER:
	case VIDIOC_S_TUNER:
	case VIDIOC_G_AUDIO:
	case VIDIOC_S_AUDIO:
	case VIDIOC_QUERYCTRL:
	case VIDIOC_QUERYMENU:
	case VIDIOC_G_INPUT32:
	case VIDIOC_S_INPUT32:
	case VIDIOC_G_OUTPUT32:
	case VIDIOC_S_OUTPUT32:
	case VIDIOC_ENUMOUTPUT:
	case VIDIOC_G_AUDOUT:
	case VIDIOC_S_AUDOUT:
	case VIDIOC_G_MODULATOR:
	case VIDIOC_S_MODULATOR:
	case VIDIOC_S_FREQUENCY:
	case VIDIOC_G_FREQUENCY:
	case VIDIOC_CROPCAP:
	case VIDIOC_G_CROP:
	case VIDIOC_S_CROP:
	case VIDIOC_G_JPEGCOMP:
	case VIDIOC_S_JPEGCOMP:
	case VIDIOC_QUERYSTD:
	case VIDIOC_TRY_FMT32:
	case VIDIOC_ENUMAUDIO:
	case VIDIOC_ENUMAUDOUT:
	case VIDIOC_G_PRIORITY:
	case VIDIOC_S_PRIORITY:
	case VIDIOC_G_SLICED_VBI_CAP:
	case VIDIOC_LOG_STATUS:
	case VIDIOC_G_EXT_CTRLS32:
	case VIDIOC_S_EXT_CTRLS32:
	case VIDIOC_TRY_EXT_CTRLS32:
	case VIDIOC_ENUM_FRAMESIZES:
	case VIDIOC_ENUM_FRAMEINTERVALS:
	case VIDIOC_G_ENC_INDEX:
	case VIDIOC_ENCODER_CMD:
	case VIDIOC_TRY_ENCODER_CMD:
	case VIDIOC_DBG_S_REGISTER:
	case VIDIOC_DBG_G_REGISTER:
	case VIDIOC_DBG_G_CHIP_IDENT:
	case VIDIOC_S_HW_FREQ_SEEK:
	case VIDIOC_ENUM_DV_PRESETS:
	case VIDIOC_S_DV_PRESET:
	case VIDIOC_G_DV_PRESET:
	case VIDIOC_QUERY_DV_PRESET:
	case VIDIOC_S_DV_TIMINGS:
	case VIDIOC_G_DV_TIMINGS:
	case VIDIOC_DQEVENT:
	case VIDIOC_SUBSCRIBE_EVENT:
	case VIDIOC_UNSUBSCRIBE_EVENT:
		ret = do_video_ioctl(file, cmd, arg);
		break;

#ifdef CONFIG_VIDEO_V4L1_COMPAT
	/* BTTV specific... */
	case _IOW('v',  BASE_VIDIOCPRIVATE+0, char [256]):
	case _IOR('v',  BASE_VIDIOCPRIVATE+1, char [256]):
	case _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int):
	case _IOW('v' , BASE_VIDIOCPRIVATE+3, char [16]): /* struct bttv_pll_info */
	case _IOR('v' , BASE_VIDIOCPRIVATE+4, int):
	case _IOR('v' , BASE_VIDIOCPRIVATE+5, int):
	case _IOR('v' , BASE_VIDIOCPRIVATE+6, int):
	case _IOR('v' , BASE_VIDIOCPRIVATE+7, int):
		ret = native_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
		break;
#endif
	default:
		printk(KERN_WARNING "compat_ioctl32: "
			"unknown ioctl '%c', dir=%d, #%d (0x%08x)\n",
			_IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd), cmd);
		break;
	}
	return ret;
}
Exemplo n.º 6
0
static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	union {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
		struct video_tuner vt;
		struct video_buffer vb;
		struct video_window vw;
		struct video_code vc;
		struct video_audio va;
#endif
		struct v4l2_format v2f;
		struct v4l2_buffer v2b;
		struct v4l2_framebuffer v2fb;
		struct v4l2_input v2i;
		struct v4l2_standard v2s;
		struct v4l2_ext_controls v2ecs;
		unsigned long vx;
		int vi;
	} karg;
	void __user *up = compat_ptr(arg);
	int compatible_arg = 1;
	long err = 0;

	/* First, convert the command. */
	switch (cmd) {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
	case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;
	case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;
	case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;
	case VIDIOCSWIN32: cmd = VIDIOCSWIN; break;
	case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break;
	case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;
	case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;
	case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;
	case VIDIOCSMICROCODE32: cmd = VIDIOCSMICROCODE; break;
#endif
	case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break;
	case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break;
	case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break;
	case VIDIOC_G_FBUF32: cmd = VIDIOC_G_FBUF; break;
	case VIDIOC_S_FBUF32: cmd = VIDIOC_S_FBUF; break;
	case VIDIOC_QBUF32: cmd = VIDIOC_QBUF; break;
	case VIDIOC_DQBUF32: cmd = VIDIOC_DQBUF; break;
	case VIDIOC_ENUMSTD32: cmd = VIDIOC_ENUMSTD; break;
	case VIDIOC_ENUMINPUT32: cmd = VIDIOC_ENUMINPUT; break;
	case VIDIOC_TRY_FMT32: cmd = VIDIOC_TRY_FMT; break;
	case VIDIOC_G_EXT_CTRLS32: cmd = VIDIOC_G_EXT_CTRLS; break;
	case VIDIOC_S_EXT_CTRLS32: cmd = VIDIOC_S_EXT_CTRLS; break;
	case VIDIOC_TRY_EXT_CTRLS32: cmd = VIDIOC_TRY_EXT_CTRLS; break;
	case VIDIOC_OVERLAY32: cmd = VIDIOC_OVERLAY; break;
#ifdef __OLD_VIDIOC_
	case VIDIOC_OVERLAY32_OLD: cmd = VIDIOC_OVERLAY; break;
#endif
	case VIDIOC_STREAMON32: cmd = VIDIOC_STREAMON; break;
	case VIDIOC_STREAMOFF32: cmd = VIDIOC_STREAMOFF; break;
	case VIDIOC_G_INPUT32: cmd = VIDIOC_G_INPUT; break;
	case VIDIOC_S_INPUT32: cmd = VIDIOC_S_INPUT; break;
	case VIDIOC_G_OUTPUT32: cmd = VIDIOC_G_OUTPUT; break;
	case VIDIOC_S_OUTPUT32: cmd = VIDIOC_S_OUTPUT; break;
	}

	switch (cmd) {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
	case VIDIOCSTUNER:
	case VIDIOCGTUNER:
		err = get_video_tuner32(&karg.vt, up);
		compatible_arg = 0;
		break;

	case VIDIOCSFBUF:
		err = get_video_buffer32(&karg.vb, up);
		compatible_arg = 0;
		break;

	case VIDIOCSWIN:
		err = get_video_window32(&karg.vw, up);
		compatible_arg = 0;
		break;

	case VIDIOCGWIN:
	case VIDIOCGFBUF:
	case VIDIOCGFREQ:
		compatible_arg = 0;
		break;

	case VIDIOCSMICROCODE:
		err = get_microcode32(&karg.vc, up);
		compatible_arg = 0;
		break;

	case VIDIOCSFREQ:
		err = get_user(karg.vx, (u32 __user *)up);
		compatible_arg = 0;
		break;

	case VIDIOCCAPTURE:
	case VIDIOCSYNC:
	case VIDIOCSWRITEMODE:
#endif
	case VIDIOC_OVERLAY:
	case VIDIOC_STREAMON:
	case VIDIOC_STREAMOFF:
	case VIDIOC_S_INPUT:
	case VIDIOC_S_OUTPUT:
		err = get_user(karg.vi, (s32 __user *)up);
		compatible_arg = 0;
		break;

	case VIDIOC_G_INPUT:
	case VIDIOC_G_OUTPUT:
		compatible_arg = 0;
		break;

	case VIDIOC_G_FMT:
	case VIDIOC_S_FMT:
	case VIDIOC_TRY_FMT:
		err = get_v4l2_format32(&karg.v2f, up);
		compatible_arg = 0;
		break;

	case VIDIOC_QUERYBUF:
	case VIDIOC_QBUF:
	case VIDIOC_DQBUF:
		err = get_v4l2_buffer32(&karg.v2b, up);
		compatible_arg = 0;
		break;

	case VIDIOC_S_FBUF:
		err = get_v4l2_framebuffer32(&karg.v2fb, up);
		compatible_arg = 0;
		break;

	case VIDIOC_G_FBUF:
		compatible_arg = 0;
		break;

	case VIDIOC_ENUMSTD:
		err = get_v4l2_standard32(&karg.v2s, up);
		compatible_arg = 0;
		break;

	case VIDIOC_ENUMINPUT:
		err = get_v4l2_input32(&karg.v2i, up);
		compatible_arg = 0;
		break;

	case VIDIOC_G_EXT_CTRLS:
	case VIDIOC_S_EXT_CTRLS:
	case VIDIOC_TRY_EXT_CTRLS:
		err = get_v4l2_ext_controls32(&karg.v2ecs, up);
		compatible_arg = 0;
		break;
	}
	if (err)
		return err;

	if (compatible_arg)
		err = native_ioctl(file, cmd, (unsigned long)up);
	else {
		mm_segment_t old_fs = get_fs();

		set_fs(KERNEL_DS);
		err = native_ioctl(file, cmd, (unsigned long)&karg);
		set_fs(old_fs);
	}

	/* Special case: even after an error we need to put the
	   results back for these ioctls since the error_idx will
	   contain information on which control failed. */
	switch (cmd) {
	case VIDIOC_G_EXT_CTRLS:
	case VIDIOC_S_EXT_CTRLS:
	case VIDIOC_TRY_EXT_CTRLS:
		if (put_v4l2_ext_controls32(&karg.v2ecs, up))
			err = -EFAULT;
		break;
	}
	if (err)
		return err;

	switch (cmd) {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
	case VIDIOCGTUNER:
		err = put_video_tuner32(&karg.vt, up);
		break;

	case VIDIOCGWIN:
		err = put_video_window32(&karg.vw, up);
		break;

	case VIDIOCGFBUF:
		err = put_video_buffer32(&karg.vb, up);
		break;

	case VIDIOCGFREQ:
		err = put_user(((u32)karg.vx), (u32 __user *)up);
		break;
#endif
	case VIDIOC_S_INPUT:
	case VIDIOC_S_OUTPUT:
	case VIDIOC_G_INPUT:
	case VIDIOC_G_OUTPUT:
		err = put_user(((s32)karg.vi), (s32 __user *)up);
		break;

	case VIDIOC_G_FBUF:
		err = put_v4l2_framebuffer32(&karg.v2fb, up);
		break;

	case VIDIOC_G_FMT:
	case VIDIOC_S_FMT:
	case VIDIOC_TRY_FMT:
		err = put_v4l2_format32(&karg.v2f, up);
		break;

	case VIDIOC_QUERYBUF:
	case VIDIOC_QBUF:
	case VIDIOC_DQBUF:
		err = put_v4l2_buffer32(&karg.v2b, up);
		break;

	case VIDIOC_ENUMSTD:
		err = put_v4l2_standard32(&karg.v2s, up);
		break;

	case VIDIOC_ENUMINPUT:
		err = put_v4l2_input32(&karg.v2i, up);
		break;
	}
	return err;
}
long atomisp_do_compat_ioctl(struct file *file,
			    unsigned int cmd, unsigned long arg)
{
	union {
		struct atomisp_histogram his;
		struct atomisp_dis_statistics dis_s;
		struct atomisp_dis_coefficients dis_c;
		struct atomisp_dvs_6axis_config dvs_c;
		struct atomisp_3a_statistics s3a_s;
		struct atomisp_morph_table mor_t;
		struct v4l2_framebuffer v4l2_buf;
		struct atomisp_overlay overlay;
		struct atomisp_calibration_group cal_grp;
		struct atomisp_acc_fw_load acc_fw_load;
		struct atomisp_acc_fw_arg acc_fw_arg;
		struct v4l2_private_int_data v4l2_pri_data;
		struct atomisp_shading_table shd_tbl;
		struct atomisp_acc_map acc_map;
		struct atomisp_acc_s_mapped_arg acc_map_arg;
		struct atomisp_parameters param;
		struct atomisp_acc_fw_load_to_pipe acc_fw_to_pipe;
	} karg;
	mm_segment_t old_fs;
	void __user *up = compat_ptr(arg);
	long err = -ENOIOCTLCMD;

	/* First, convert the command. */
	switch (cmd) {
	case ATOMISP_IOC_G_HISTOGRAM32:
		cmd = ATOMISP_IOC_G_HISTOGRAM;
		break;
	case ATOMISP_IOC_S_HISTOGRAM32:
		cmd = ATOMISP_IOC_S_HISTOGRAM;
		break;
	case ATOMISP_IOC_G_DIS_STAT32:
		cmd = ATOMISP_IOC_G_DIS_STAT;
		break;
	case ATOMISP_IOC_S_DIS_COEFS32:
		cmd = ATOMISP_IOC_S_DIS_COEFS;
		break;
	case ATOMISP_IOC_S_DIS_VECTOR32:
		cmd = ATOMISP_IOC_S_DIS_VECTOR;
		break;
	case ATOMISP_IOC_G_3A_STAT32:
		cmd = ATOMISP_IOC_G_3A_STAT;
		break;
	case ATOMISP_IOC_G_ISP_GDC_TAB32:
		cmd = ATOMISP_IOC_G_ISP_GDC_TAB;
		break;
	case ATOMISP_IOC_S_ISP_GDC_TAB32:
		cmd = ATOMISP_IOC_S_ISP_GDC_TAB;
		break;
	case ATOMISP_IOC_S_ISP_FPN_TABLE32:
		cmd = ATOMISP_IOC_S_ISP_FPN_TABLE;
		break;
	case ATOMISP_IOC_G_ISP_OVERLAY32:
		cmd = ATOMISP_IOC_G_ISP_OVERLAY;
		break;
	case ATOMISP_IOC_S_ISP_OVERLAY32:
		cmd = ATOMISP_IOC_S_ISP_OVERLAY;
		break;
	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP32:
		cmd = ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP;
		break;
	case ATOMISP_IOC_ACC_LOAD32:
		cmd = ATOMISP_IOC_ACC_LOAD;
		break;
	case ATOMISP_IOC_ACC_S_ARG32:
		cmd = ATOMISP_IOC_ACC_S_ARG;
		break;
	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA32:
		cmd = ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA;
		break;
	case ATOMISP_IOC_S_ISP_SHD_TAB32:
		cmd = ATOMISP_IOC_S_ISP_SHD_TAB;
		break;
	case ATOMISP_IOC_ACC_DESTAB32:
		cmd = ATOMISP_IOC_ACC_DESTAB;
		break;
	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA32:
		cmd = ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA;
		break;
	case ATOMISP_IOC_ACC_MAP32:
		cmd = ATOMISP_IOC_ACC_MAP;
		break;
	case ATOMISP_IOC_ACC_UNMAP32:
		cmd = ATOMISP_IOC_ACC_UNMAP;
		break;
	case ATOMISP_IOC_ACC_S_MAPPED_ARG32:
		cmd = ATOMISP_IOC_ACC_S_MAPPED_ARG;
		break;
	case ATOMISP_IOC_S_PARAMETERS32:
		cmd = ATOMISP_IOC_S_PARAMETERS;
		break;
	case ATOMISP_IOC_ACC_LOAD_TO_PIPE32:
		cmd = ATOMISP_IOC_ACC_LOAD_TO_PIPE;
		break;
	}

	switch (cmd) {
	case ATOMISP_IOC_G_HISTOGRAM:
	case ATOMISP_IOC_S_HISTOGRAM:
		err = get_atomisp_histogram32(&karg.his, up);
		break;
	case ATOMISP_IOC_G_DIS_STAT:
		err = get_atomisp_dis_statistics32(&karg.dis_s, up);
		break;
	case ATOMISP_IOC_S_DIS_COEFS:
		err = get_atomisp_dis_coefficients32(&karg.dis_c, up);
		break;
	case ATOMISP_IOC_S_DIS_VECTOR:
		err = get_atomisp_dvs_6axis_config32(&karg.dvs_c, up);
		break;
	case ATOMISP_IOC_G_3A_STAT:
		err = get_atomisp_3a_statistics32(&karg.s3a_s, up);
		break;
	case ATOMISP_IOC_G_ISP_GDC_TAB:
	case ATOMISP_IOC_S_ISP_GDC_TAB:
		err = get_atomisp_morph_table32(&karg.mor_t, up);
		break;
	case ATOMISP_IOC_S_ISP_FPN_TABLE:
		err = get_v4l2_framebuffer32(&karg.v4l2_buf, up);
		break;
	case ATOMISP_IOC_G_ISP_OVERLAY:
	case ATOMISP_IOC_S_ISP_OVERLAY:
		err = get_atomisp_overlay32(&karg.overlay, up);
		break;
	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP:
		err = get_atomisp_calibration_group32(&karg.cal_grp, up);
		break;
	case ATOMISP_IOC_ACC_LOAD:
		err = get_atomisp_acc_fw_load32(&karg.acc_fw_load, up);
		break;
	case ATOMISP_IOC_ACC_S_ARG:
	case ATOMISP_IOC_ACC_DESTAB:
		err = get_atomisp_acc_fw_arg32(&karg.acc_fw_arg, up);
		break;
	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA:
	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA:
		err = get_v4l2_private_int_data32(&karg.v4l2_pri_data, up);
		break;
	case ATOMISP_IOC_S_ISP_SHD_TAB:
		err = get_atomisp_shading_table32(&karg.shd_tbl, up);
		break;
	case ATOMISP_IOC_ACC_MAP:
	case ATOMISP_IOC_ACC_UNMAP:
		err = get_atomisp_acc_map32(&karg.acc_map, up);
		break;
	case ATOMISP_IOC_ACC_S_MAPPED_ARG:
		err = get_atomisp_acc_s_mapped_arg32(&karg.acc_map_arg, up);
		break;
	case ATOMISP_IOC_S_PARAMETERS:
		err = get_atomisp_parameters32(&karg.param, up);
		break;
	case ATOMISP_IOC_ACC_LOAD_TO_PIPE:
		err = get_atomisp_acc_fw_load_to_pipe32(&karg.acc_fw_to_pipe,
							up);
		break;
	}
	if (err)
		return err;

	old_fs = get_fs();
	set_fs(KERNEL_DS);
	err = native_ioctl(file, cmd, (unsigned long)&karg);
	set_fs(old_fs);
	if (err)
		return err;

	switch (cmd) {
	case ATOMISP_IOC_G_HISTOGRAM:
		err = put_atomisp_histogram32(&karg.his, up);
		break;
	case ATOMISP_IOC_G_DIS_STAT:
		err = put_atomisp_dis_statistics32(&karg.dis_s, up);
		break;
	case ATOMISP_IOC_G_3A_STAT:
		err = put_atomisp_3a_statistics32(&karg.s3a_s, up);
		break;
	case ATOMISP_IOC_G_ISP_GDC_TAB:
		err = put_atomisp_morph_table32(&karg.mor_t, up);
		break;
	case ATOMISP_IOC_G_ISP_OVERLAY:
		err = put_atomisp_overlay32(&karg.overlay, up);
		break;
	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP:
		err = put_atomisp_calibration_group32(&karg.cal_grp, up);
		break;
	case ATOMISP_IOC_ACC_LOAD:
		err = put_atomisp_acc_fw_load32(&karg.acc_fw_load, up);
		break;
	case ATOMISP_IOC_ACC_S_ARG:
	case ATOMISP_IOC_ACC_DESTAB:
		err = put_atomisp_acc_fw_arg32(&karg.acc_fw_arg, up);
		break;
	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA:
	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA:
		err = put_v4l2_private_int_data32(&karg.v4l2_pri_data, up);
		break;
	case ATOMISP_IOC_ACC_MAP:
	case ATOMISP_IOC_ACC_UNMAP:
		err = put_atomisp_acc_map32(&karg.acc_map, up);
		break;
	case ATOMISP_IOC_ACC_S_MAPPED_ARG:
		err = put_atomisp_acc_s_mapped_arg32(&karg.acc_map_arg, up);
		break;
	case ATOMISP_IOC_ACC_LOAD_TO_PIPE:
		err = put_atomisp_acc_fw_load_to_pipe32(&karg.acc_fw_to_pipe,
							up);
		break;
	}

	return err;
}
long atomisp_compat_ioctl32(struct file *file,
			    unsigned int cmd, unsigned long arg)
{

	struct video_device *vdev = video_devdata(file);
	struct atomisp_device *isp = video_get_drvdata(vdev);
	long ret = -ENOIOCTLCMD;

	if (!file->f_op->unlocked_ioctl)
		return ret;

	switch (cmd) {
	case ATOMISP_IOC_G_XNR:
	case ATOMISP_IOC_S_XNR:
	case ATOMISP_IOC_G_NR:
	case ATOMISP_IOC_S_NR:
	case ATOMISP_IOC_G_TNR:
	case ATOMISP_IOC_S_TNR:
	case ATOMISP_IOC_G_BLACK_LEVEL_COMP:
	case ATOMISP_IOC_S_BLACK_LEVEL_COMP:
	case ATOMISP_IOC_G_EE:
	case ATOMISP_IOC_S_EE:
	case ATOMISP_IOC_S_DIS_VECTOR:
	case ATOMISP_IOC_G_ISP_PARM:
	case ATOMISP_IOC_S_ISP_PARM:
	case ATOMISP_IOC_G_ISP_GAMMA:
	case ATOMISP_IOC_S_ISP_GAMMA:
	case ATOMISP_IOC_ISP_MAKERNOTE:
	case ATOMISP_IOC_G_ISP_MACC:
	case ATOMISP_IOC_S_ISP_MACC:
	case ATOMISP_IOC_G_ISP_BAD_PIXEL_DETECTION:
	case ATOMISP_IOC_S_ISP_BAD_PIXEL_DETECTION:
	case ATOMISP_IOC_G_ISP_FALSE_COLOR_CORRECTION:
	case ATOMISP_IOC_S_ISP_FALSE_COLOR_CORRECTION:
	case ATOMISP_IOC_G_ISP_CTC:
	case ATOMISP_IOC_S_ISP_CTC:
	case ATOMISP_IOC_G_ISP_WHITE_BALANCE:
	case ATOMISP_IOC_S_ISP_WHITE_BALANCE:
	case ATOMISP_IOC_CAMERA_BRIDGE:
	case ATOMISP_IOC_G_SENSOR_MODE_DATA:
	case ATOMISP_IOC_S_BINNING_SUM:
	case ATOMISP_IOC_S_EXPOSURE:
	case ATOMISP_IOC_G_3A_CONFIG:
	case ATOMISP_IOC_S_3A_CONFIG:
	case ATOMISP_IOC_ACC_UNLOAD:
	case ATOMISP_IOC_ACC_START:
	case ATOMISP_IOC_ACC_WAIT:
	case ATOMISP_IOC_ACC_ABORT:
	case ATOMISP_IOC_G_ISP_GAMMA_CORRECTION:
	case ATOMISP_IOC_S_ISP_GAMMA_CORRECTION:
	case ATOMISP_IOC_S_CONT_CAPTURE_CONFIG:
		ret = native_ioctl(file, cmd, arg);
		break;

	case ATOMISP_IOC_G_HISTOGRAM32:
	case ATOMISP_IOC_S_HISTOGRAM32:
	case ATOMISP_IOC_G_DIS_STAT32:
	case ATOMISP_IOC_S_DIS_COEFS32:
	case ATOMISP_IOC_S_DIS_VECTOR32:
	case ATOMISP_IOC_G_3A_STAT32:
	case ATOMISP_IOC_G_ISP_GDC_TAB32:
	case ATOMISP_IOC_S_ISP_GDC_TAB32:
	case ATOMISP_IOC_S_ISP_FPN_TABLE32:
	case ATOMISP_IOC_G_ISP_OVERLAY32:
	case ATOMISP_IOC_S_ISP_OVERLAY32:
	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP32:
	case ATOMISP_IOC_ACC_LOAD32:
	case ATOMISP_IOC_ACC_S_ARG32:
	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA32:
	case ATOMISP_IOC_S_ISP_SHD_TAB32:
	case ATOMISP_IOC_ACC_DESTAB32:
	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA32:
	case ATOMISP_IOC_ACC_MAP32:
	case ATOMISP_IOC_ACC_UNMAP32:
	case ATOMISP_IOC_ACC_S_MAPPED_ARG32:
	case ATOMISP_IOC_S_PARAMETERS32:
	case ATOMISP_IOC_ACC_LOAD_TO_PIPE32:
		ret = atomisp_do_compat_ioctl(file, cmd, arg);
		break;

	default:
		dev_warn(isp->dev,
			"%s: unknown ioctl '%c', dir=%d, #%d (0x%08x)\n",
			__func__, _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd),
			cmd);
		break;
	}
	return ret;
}
Exemplo n.º 9
0
int ioctl(int fd, unsigned long int command, ...)
#endif
{
	va_list ap;
	char *data;
	char *vdesock;
	int pid;
	int callerpid=getpid();

	va_start(ap, command);
	data = va_arg(ap, char *);
	va_end(ap);

	if (fd == tapfd[0]) {
		if (command == TUNSETIFF) {
			struct ifreq *ifr = (struct ifreq *) data;
			char num[5];
			char name[10];
			char scallerpid[6];

			ifr->ifr_name[IFNAMSIZ-1] = '\0';
			if (ifr->ifr_name[0] == 0) {
				if (ifr->ifr_flags & IFF_TAP) 
					sprintf(name,"tap%d",tapcount++);
				else
					sprintf(name,"tun%d",tuncount++);
				strncpy(ifr->ifr_name,name,IFNAMSIZ);
			}
			else if (strchr(ifr->ifr_name, '%') != NULL) {
				sprintf(name,ifr->ifr_name,tapcount++);
				strncpy(ifr->ifr_name,name,IFNAMSIZ);
			}
			if ((ifr->ifr_flags & IFF_TAP) && (
					/* from env: single interface or VDEALLTAP */
					((vdesock=getenv(ifr->ifr_name)) != NULL) ||
						(vdesock=getenv(VDEALLTAP)) != NULL)
				 ){
				if ((pid=fork()) < 0) { 
					close(tapfd[1]);
					errno=EINVAL;
					return -1;
				} else if (pid > 0) { /*father*/
					if((pid=addpid(pid)) < 0) {
						close(tapfd[0]);
						close(tapfd[1]);
						return -1;
					} else {
						close(tapfd[1]);
						return 0;
					}
				} else { /*son*/
					plh=NULL;
					close(tapfd[0]);
					sprintf(num,"%d",tapfd[1]);
					sprintf(scallerpid,"%d",callerpid);
					return execlp(VDETAPEXEC,"-",num,vdesock,ifr->ifr_name,
							scallerpid,
							getvdeopt(ifr,"port"),
							getvdeopt(ifr,"group"),
							getvdeopt(ifr,"mode"),
							(char *) 0);
				}
			}
			else /*roll back to the native tuntap*/
			{
				int newfd;
				int saverrno;
				int resultioctl;
				close(tapfd[1]);
				if ((newfd=native_open(TUNTAPPATH,  O_RDWR, 0)) < 0) {
					saverrno=errno;
					close(tapfd[0]);
					errno=saverrno;
					return -1;
				} else
				{
					resultioctl=native_ioctl(fd, command, data);
					if (resultioctl < 0) {
						saverrno=errno;
						close(tapfd[0]);
						errno=saverrno;
						return -1;
					} else {
						dup2(newfd,tapfd[0]);
						return resultioctl;
					}
				}
			}
		} else  
			return 0;
	} else 
		return (native_ioctl(fd, command, data));
}
Exemplo n.º 10
0
static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	union {
		struct v4l2_format v2f;
		struct v4l2_buffer v2b;
		struct v4l2_framebuffer v2fb;
		struct v4l2_input v2i;
		struct v4l2_standard v2s;
		struct v4l2_ext_controls v2ecs;
		unsigned long vx;
		int vi;
	} karg;
	void __user *up = compat_ptr(arg);
	int compatible_arg = 1;
	long err = 0;

	/* First, convert the command. */
	switch (cmd) {
	case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break;
	case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break;
	case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break;
	case VIDIOC_G_FBUF32: cmd = VIDIOC_G_FBUF; break;
	case VIDIOC_S_FBUF32: cmd = VIDIOC_S_FBUF; break;
	case VIDIOC_QBUF32: cmd = VIDIOC_QBUF; break;
	case VIDIOC_DQBUF32: cmd = VIDIOC_DQBUF; break;
	case VIDIOC_ENUMSTD32: cmd = VIDIOC_ENUMSTD; break;
	case VIDIOC_ENUMINPUT32: cmd = VIDIOC_ENUMINPUT; break;
	case VIDIOC_TRY_FMT32: cmd = VIDIOC_TRY_FMT; break;
	case VIDIOC_G_EXT_CTRLS32: cmd = VIDIOC_G_EXT_CTRLS; break;
	case VIDIOC_S_EXT_CTRLS32: cmd = VIDIOC_S_EXT_CTRLS; break;
	case VIDIOC_TRY_EXT_CTRLS32: cmd = VIDIOC_TRY_EXT_CTRLS; break;
	case VIDIOC_OVERLAY32: cmd = VIDIOC_OVERLAY; break;
	case VIDIOC_STREAMON32: cmd = VIDIOC_STREAMON; break;
	case VIDIOC_STREAMOFF32: cmd = VIDIOC_STREAMOFF; break;
	case VIDIOC_G_INPUT32: cmd = VIDIOC_G_INPUT; break;
	case VIDIOC_S_INPUT32: cmd = VIDIOC_S_INPUT; break;
	case VIDIOC_G_OUTPUT32: cmd = VIDIOC_G_OUTPUT; break;
	case VIDIOC_S_OUTPUT32: cmd = VIDIOC_S_OUTPUT; break;
	}

	switch (cmd) {
	case VIDIOC_OVERLAY:
	case VIDIOC_STREAMON:
	case VIDIOC_STREAMOFF:
	case VIDIOC_S_INPUT:
	case VIDIOC_S_OUTPUT:
		err = get_user(karg.vi, (s32 __user *)up);
		compatible_arg = 0;
		break;

	case VIDIOC_G_INPUT:
	case VIDIOC_G_OUTPUT:
		compatible_arg = 0;
		break;

	case VIDIOC_G_FMT:
	case VIDIOC_S_FMT:
	case VIDIOC_TRY_FMT:
		err = get_v4l2_format32(&karg.v2f, up);
		compatible_arg = 0;
		break;

	case VIDIOC_QUERYBUF:
	case VIDIOC_QBUF:
	case VIDIOC_DQBUF:
		err = get_v4l2_buffer32(&karg.v2b, up);
		compatible_arg = 0;
		break;

	case VIDIOC_S_FBUF:
		err = get_v4l2_framebuffer32(&karg.v2fb, up);
		compatible_arg = 0;
		break;

	case VIDIOC_G_FBUF:
		compatible_arg = 0;
		break;

	case VIDIOC_ENUMSTD:
		err = get_v4l2_standard32(&karg.v2s, up);
		compatible_arg = 0;
		break;

	case VIDIOC_ENUMINPUT:
		err = get_v4l2_input32(&karg.v2i, up);
		compatible_arg = 0;
		break;

	case VIDIOC_G_EXT_CTRLS:
	case VIDIOC_S_EXT_CTRLS:
	case VIDIOC_TRY_EXT_CTRLS:
		err = get_v4l2_ext_controls32(&karg.v2ecs, up);
		compatible_arg = 0;
		break;
	}
	if (err)
		return err;

	if (compatible_arg)
		err = native_ioctl(file, cmd, (unsigned long)up);
	else {
		mm_segment_t old_fs = get_fs();

		set_fs(KERNEL_DS);
		err = native_ioctl(file, cmd, (unsigned long)&karg);
		set_fs(old_fs);
	}

	/* Special case: even after an error we need to put the
	   results back for these ioctls since the error_idx will
	   contain information on which control failed. */
	switch (cmd) {
	case VIDIOC_G_EXT_CTRLS:
	case VIDIOC_S_EXT_CTRLS:
	case VIDIOC_TRY_EXT_CTRLS:
		if (put_v4l2_ext_controls32(&karg.v2ecs, up))
			err = -EFAULT;
		break;
	}
	if (err)
		return err;

	switch (cmd) {
	case VIDIOC_S_INPUT:
	case VIDIOC_S_OUTPUT:
	case VIDIOC_G_INPUT:
	case VIDIOC_G_OUTPUT:
		err = put_user(((s32)karg.vi), (s32 __user *)up);
		break;

	case VIDIOC_G_FBUF:
		err = put_v4l2_framebuffer32(&karg.v2fb, up);
		break;

	case VIDIOC_G_FMT:
	case VIDIOC_S_FMT:
	case VIDIOC_TRY_FMT:
		err = put_v4l2_format32(&karg.v2f, up);
		break;

	case VIDIOC_QUERYBUF:
	case VIDIOC_QBUF:
	case VIDIOC_DQBUF:
		err = put_v4l2_buffer32(&karg.v2b, up);
		break;

	case VIDIOC_ENUMSTD:
		err = put_v4l2_standard32(&karg.v2s, up);
		break;

	case VIDIOC_ENUMINPUT:
		err = put_v4l2_input32(&karg.v2i, up);
		break;
	}
	return err;
}