diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-12 08:32:50 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:09 -0400 |
commit | c49cb361dbc5a33f35f8d7eb26f0bddd83019e97 (patch) | |
tree | 80546d73692c2efd07b938eec641fdb9e7d1b6d0 /drivers/media/video/vino.c | |
parent | 49a53750b266899f259b1734a4a2c80d4376ba75 (diff) |
V4L/DVB (10858): vino: convert to video_ioctl2.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/vino.c')
-rw-r--r-- | drivers/media/video/vino.c | 490 |
1 files changed, 173 insertions, 317 deletions
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c index 88bf845a3d56..2ce2fe594cdf 100644 --- a/drivers/media/video/vino.c +++ b/drivers/media/video/vino.c | |||
@@ -2884,35 +2884,7 @@ static int vino_find_data_format(__u32 pixelformat) | |||
2884 | return VINO_DATA_FMT_NONE; | 2884 | return VINO_DATA_FMT_NONE; |
2885 | } | 2885 | } |
2886 | 2886 | ||
2887 | static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index) | 2887 | static int vino_int_enum_input(struct vino_channel_settings *vcs, __u32 index) |
2888 | { | ||
2889 | int data_norm = VINO_DATA_NORM_NONE; | ||
2890 | unsigned long flags; | ||
2891 | |||
2892 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | ||
2893 | switch(vcs->input) { | ||
2894 | case VINO_INPUT_COMPOSITE: | ||
2895 | case VINO_INPUT_SVIDEO: | ||
2896 | if (index == 0) { | ||
2897 | data_norm = VINO_DATA_NORM_PAL; | ||
2898 | } else if (index == 1) { | ||
2899 | data_norm = VINO_DATA_NORM_NTSC; | ||
2900 | } else if (index == 2) { | ||
2901 | data_norm = VINO_DATA_NORM_SECAM; | ||
2902 | } | ||
2903 | break; | ||
2904 | case VINO_INPUT_D1: | ||
2905 | if (index == 0) { | ||
2906 | data_norm = VINO_DATA_NORM_D1; | ||
2907 | } | ||
2908 | break; | ||
2909 | } | ||
2910 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
2911 | |||
2912 | return data_norm; | ||
2913 | } | ||
2914 | |||
2915 | static int vino_enum_input(struct vino_channel_settings *vcs, __u32 index) | ||
2916 | { | 2888 | { |
2917 | int input = VINO_INPUT_NONE; | 2889 | int input = VINO_INPUT_NONE; |
2918 | unsigned long flags; | 2890 | unsigned long flags; |
@@ -2991,7 +2963,8 @@ static __u32 vino_find_input_index(struct vino_channel_settings *vcs) | |||
2991 | 2963 | ||
2992 | /* V4L2 ioctls */ | 2964 | /* V4L2 ioctls */ |
2993 | 2965 | ||
2994 | static void vino_v4l2_querycap(struct v4l2_capability *cap) | 2966 | static int vino_querycap(struct file *file, void *__fh, |
2967 | struct v4l2_capability *cap) | ||
2995 | { | 2968 | { |
2996 | memset(cap, 0, sizeof(struct v4l2_capability)); | 2969 | memset(cap, 0, sizeof(struct v4l2_capability)); |
2997 | 2970 | ||
@@ -3003,16 +2976,18 @@ static void vino_v4l2_querycap(struct v4l2_capability *cap) | |||
3003 | V4L2_CAP_VIDEO_CAPTURE | | 2976 | V4L2_CAP_VIDEO_CAPTURE | |
3004 | V4L2_CAP_STREAMING; | 2977 | V4L2_CAP_STREAMING; |
3005 | // V4L2_CAP_OVERLAY, V4L2_CAP_READWRITE | 2978 | // V4L2_CAP_OVERLAY, V4L2_CAP_READWRITE |
2979 | return 0; | ||
3006 | } | 2980 | } |
3007 | 2981 | ||
3008 | static int vino_v4l2_enuminput(struct vino_channel_settings *vcs, | 2982 | static int vino_enum_input(struct file *file, void *__fh, |
3009 | struct v4l2_input *i) | 2983 | struct v4l2_input *i) |
3010 | { | 2984 | { |
2985 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3011 | __u32 index = i->index; | 2986 | __u32 index = i->index; |
3012 | int input; | 2987 | int input; |
3013 | dprintk("requested index = %d\n", index); | 2988 | dprintk("requested index = %d\n", index); |
3014 | 2989 | ||
3015 | input = vino_enum_input(vcs, index); | 2990 | input = vino_int_enum_input(vcs, index); |
3016 | if (input == VINO_INPUT_NONE) | 2991 | if (input == VINO_INPUT_NONE) |
3017 | return -EINVAL; | 2992 | return -EINVAL; |
3018 | 2993 | ||
@@ -3034,9 +3009,10 @@ static int vino_v4l2_enuminput(struct vino_channel_settings *vcs, | |||
3034 | return 0; | 3009 | return 0; |
3035 | } | 3010 | } |
3036 | 3011 | ||
3037 | static int vino_v4l2_g_input(struct vino_channel_settings *vcs, | 3012 | static int vino_g_input(struct file *file, void *__fh, |
3038 | unsigned int *i) | 3013 | unsigned int *i) |
3039 | { | 3014 | { |
3015 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3040 | __u32 index; | 3016 | __u32 index; |
3041 | int input; | 3017 | int input; |
3042 | unsigned long flags; | 3018 | unsigned long flags; |
@@ -3057,52 +3033,24 @@ static int vino_v4l2_g_input(struct vino_channel_settings *vcs, | |||
3057 | return 0; | 3033 | return 0; |
3058 | } | 3034 | } |
3059 | 3035 | ||
3060 | static int vino_v4l2_s_input(struct vino_channel_settings *vcs, | 3036 | static int vino_s_input(struct file *file, void *__fh, |
3061 | unsigned int *i) | 3037 | unsigned int i) |
3062 | { | 3038 | { |
3039 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3063 | int input; | 3040 | int input; |
3064 | dprintk("requested input = %d\n", *i); | 3041 | dprintk("requested input = %d\n", i); |
3065 | 3042 | ||
3066 | input = vino_enum_input(vcs, *i); | 3043 | input = vino_int_enum_input(vcs, i); |
3067 | if (input == VINO_INPUT_NONE) | 3044 | if (input == VINO_INPUT_NONE) |
3068 | return -EINVAL; | 3045 | return -EINVAL; |
3069 | 3046 | ||
3070 | return vino_set_input(vcs, input); | 3047 | return vino_set_input(vcs, input); |
3071 | } | 3048 | } |
3072 | 3049 | ||
3073 | static int vino_v4l2_enumstd(struct vino_channel_settings *vcs, | 3050 | static int vino_querystd(struct file *file, void *__fh, |
3074 | struct v4l2_standard *s) | ||
3075 | { | ||
3076 | int index = s->index; | ||
3077 | int data_norm; | ||
3078 | |||
3079 | data_norm = vino_enum_data_norm(vcs, index); | ||
3080 | dprintk("standard index = %d\n", index); | ||
3081 | |||
3082 | if (data_norm == VINO_DATA_NORM_NONE) | ||
3083 | return -EINVAL; | ||
3084 | |||
3085 | dprintk("standard name = %s\n", | ||
3086 | vino_data_norms[data_norm].description); | ||
3087 | |||
3088 | memset(s, 0, sizeof(struct v4l2_standard)); | ||
3089 | s->index = index; | ||
3090 | |||
3091 | s->id = vino_data_norms[data_norm].std; | ||
3092 | s->frameperiod.numerator = 1; | ||
3093 | s->frameperiod.denominator = | ||
3094 | vino_data_norms[data_norm].fps_max; | ||
3095 | s->framelines = | ||
3096 | vino_data_norms[data_norm].framelines; | ||
3097 | strcpy(s->name, | ||
3098 | vino_data_norms[data_norm].description); | ||
3099 | |||
3100 | return 0; | ||
3101 | } | ||
3102 | |||
3103 | static int vino_v4l2_querystd(struct vino_channel_settings *vcs, | ||
3104 | v4l2_std_id *std) | 3051 | v4l2_std_id *std) |
3105 | { | 3052 | { |
3053 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3106 | unsigned long flags; | 3054 | unsigned long flags; |
3107 | int err = 0; | 3055 | int err = 0; |
3108 | 3056 | ||
@@ -3138,9 +3086,10 @@ static int vino_v4l2_querystd(struct vino_channel_settings *vcs, | |||
3138 | return err; | 3086 | return err; |
3139 | } | 3087 | } |
3140 | 3088 | ||
3141 | static int vino_v4l2_g_std(struct vino_channel_settings *vcs, | 3089 | static int vino_g_std(struct file *file, void *__fh, |
3142 | v4l2_std_id *std) | 3090 | v4l2_std_id *std) |
3143 | { | 3091 | { |
3092 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3144 | unsigned long flags; | 3093 | unsigned long flags; |
3145 | 3094 | ||
3146 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | 3095 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
@@ -3153,9 +3102,10 @@ static int vino_v4l2_g_std(struct vino_channel_settings *vcs, | |||
3153 | return 0; | 3102 | return 0; |
3154 | } | 3103 | } |
3155 | 3104 | ||
3156 | static int vino_v4l2_s_std(struct vino_channel_settings *vcs, | 3105 | static int vino_s_std(struct file *file, void *__fh, |
3157 | v4l2_std_id *std) | 3106 | v4l2_std_id *std) |
3158 | { | 3107 | { |
3108 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3159 | unsigned long flags; | 3109 | unsigned long flags; |
3160 | int ret = 0; | 3110 | int ret = 0; |
3161 | 3111 | ||
@@ -3207,185 +3157,152 @@ out: | |||
3207 | return ret; | 3157 | return ret; |
3208 | } | 3158 | } |
3209 | 3159 | ||
3210 | static int vino_v4l2_enum_fmt(struct vino_channel_settings *vcs, | 3160 | static int vino_enum_fmt_vid_cap(struct file *file, void *__fh, |
3211 | struct v4l2_fmtdesc *fd) | 3161 | struct v4l2_fmtdesc *fd) |
3212 | { | 3162 | { |
3213 | enum v4l2_buf_type type = fd->type; | 3163 | enum v4l2_buf_type type = fd->type; |
3214 | int index = fd->index; | 3164 | int index = fd->index; |
3165 | |||
3215 | dprintk("format index = %d\n", index); | 3166 | dprintk("format index = %d\n", index); |
3216 | 3167 | ||
3217 | switch (fd->type) { | 3168 | if ((fd->index < 0) || |
3218 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 3169 | (fd->index >= VINO_DATA_FMT_COUNT)) |
3219 | if ((fd->index < 0) || | ||
3220 | (fd->index >= VINO_DATA_FMT_COUNT)) | ||
3221 | return -EINVAL; | ||
3222 | dprintk("format name = %s\n", | ||
3223 | vino_data_formats[index].description); | ||
3224 | |||
3225 | memset(fd, 0, sizeof(struct v4l2_fmtdesc)); | ||
3226 | fd->index = index; | ||
3227 | fd->type = type; | ||
3228 | fd->pixelformat = vino_data_formats[index].pixelformat; | ||
3229 | strcpy(fd->description, vino_data_formats[index].description); | ||
3230 | break; | ||
3231 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
3232 | default: | ||
3233 | return -EINVAL; | 3170 | return -EINVAL; |
3234 | } | 3171 | dprintk("format name = %s\n", |
3235 | 3172 | vino_data_formats[index].description); | |
3173 | |||
3174 | memset(fd, 0, sizeof(struct v4l2_fmtdesc)); | ||
3175 | fd->index = index; | ||
3176 | fd->type = type; | ||
3177 | fd->pixelformat = vino_data_formats[index].pixelformat; | ||
3178 | strcpy(fd->description, vino_data_formats[index].description); | ||
3236 | return 0; | 3179 | return 0; |
3237 | } | 3180 | } |
3238 | 3181 | ||
3239 | static int vino_v4l2_try_fmt(struct vino_channel_settings *vcs, | 3182 | static int vino_try_fmt_vid_cap(struct file *file, void *__fh, |
3240 | struct v4l2_format *f) | 3183 | struct v4l2_format *f) |
3241 | { | 3184 | { |
3185 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3242 | struct vino_channel_settings tempvcs; | 3186 | struct vino_channel_settings tempvcs; |
3243 | unsigned long flags; | 3187 | unsigned long flags; |
3188 | struct v4l2_pix_format *pf = &f->fmt.pix; | ||
3244 | 3189 | ||
3245 | switch (f->type) { | 3190 | dprintk("requested: w = %d, h = %d\n", |
3246 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { | 3191 | pf->width, pf->height); |
3247 | struct v4l2_pix_format *pf = &f->fmt.pix; | ||
3248 | 3192 | ||
3249 | dprintk("requested: w = %d, h = %d\n", | 3193 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3250 | pf->width, pf->height); | 3194 | memcpy(&tempvcs, vcs, sizeof(struct vino_channel_settings)); |
3251 | 3195 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | |
3252 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | ||
3253 | memcpy(&tempvcs, vcs, sizeof(struct vino_channel_settings)); | ||
3254 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
3255 | 3196 | ||
3256 | tempvcs.data_format = vino_find_data_format(pf->pixelformat); | 3197 | tempvcs.data_format = vino_find_data_format(pf->pixelformat); |
3257 | if (tempvcs.data_format == VINO_DATA_FMT_NONE) { | 3198 | if (tempvcs.data_format == VINO_DATA_FMT_NONE) { |
3258 | tempvcs.data_format = VINO_DATA_FMT_GREY; | 3199 | tempvcs.data_format = VINO_DATA_FMT_GREY; |
3259 | pf->pixelformat = | 3200 | pf->pixelformat = |
3260 | vino_data_formats[tempvcs.data_format]. | 3201 | vino_data_formats[tempvcs.data_format]. |
3261 | pixelformat; | 3202 | pixelformat; |
3262 | } | 3203 | } |
3263 | 3204 | ||
3264 | /* data format must be set before clipping/scaling */ | 3205 | /* data format must be set before clipping/scaling */ |
3265 | vino_set_scaling(&tempvcs, pf->width, pf->height); | 3206 | vino_set_scaling(&tempvcs, pf->width, pf->height); |
3266 | 3207 | ||
3267 | dprintk("data format = %s\n", | 3208 | dprintk("data format = %s\n", |
3268 | vino_data_formats[tempvcs.data_format].description); | 3209 | vino_data_formats[tempvcs.data_format].description); |
3269 | 3210 | ||
3270 | pf->width = (tempvcs.clipping.right - tempvcs.clipping.left) / | 3211 | pf->width = (tempvcs.clipping.right - tempvcs.clipping.left) / |
3271 | tempvcs.decimation; | 3212 | tempvcs.decimation; |
3272 | pf->height = (tempvcs.clipping.bottom - tempvcs.clipping.top) / | 3213 | pf->height = (tempvcs.clipping.bottom - tempvcs.clipping.top) / |
3273 | tempvcs.decimation; | 3214 | tempvcs.decimation; |
3274 | 3215 | ||
3275 | pf->field = V4L2_FIELD_INTERLACED; | 3216 | pf->field = V4L2_FIELD_INTERLACED; |
3276 | pf->bytesperline = tempvcs.line_size; | 3217 | pf->bytesperline = tempvcs.line_size; |
3277 | pf->sizeimage = tempvcs.line_size * | 3218 | pf->sizeimage = tempvcs.line_size * |
3278 | (tempvcs.clipping.bottom - tempvcs.clipping.top) / | 3219 | (tempvcs.clipping.bottom - tempvcs.clipping.top) / |
3279 | tempvcs.decimation; | 3220 | tempvcs.decimation; |
3280 | pf->colorspace = | 3221 | pf->colorspace = |
3281 | vino_data_formats[tempvcs.data_format].colorspace; | 3222 | vino_data_formats[tempvcs.data_format].colorspace; |
3282 | |||
3283 | pf->priv = 0; | ||
3284 | break; | ||
3285 | } | ||
3286 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
3287 | default: | ||
3288 | return -EINVAL; | ||
3289 | } | ||
3290 | 3223 | ||
3224 | pf->priv = 0; | ||
3291 | return 0; | 3225 | return 0; |
3292 | } | 3226 | } |
3293 | 3227 | ||
3294 | static int vino_v4l2_g_fmt(struct vino_channel_settings *vcs, | 3228 | static int vino_g_fmt_vid_cap(struct file *file, void *__fh, |
3295 | struct v4l2_format *f) | 3229 | struct v4l2_format *f) |
3296 | { | 3230 | { |
3231 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3297 | unsigned long flags; | 3232 | unsigned long flags; |
3233 | struct v4l2_pix_format *pf = &f->fmt.pix; | ||
3298 | 3234 | ||
3299 | switch (f->type) { | 3235 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3300 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { | ||
3301 | struct v4l2_pix_format *pf = &f->fmt.pix; | ||
3302 | |||
3303 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | ||
3304 | 3236 | ||
3305 | pf->width = (vcs->clipping.right - vcs->clipping.left) / | 3237 | pf->width = (vcs->clipping.right - vcs->clipping.left) / |
3306 | vcs->decimation; | 3238 | vcs->decimation; |
3307 | pf->height = (vcs->clipping.bottom - vcs->clipping.top) / | 3239 | pf->height = (vcs->clipping.bottom - vcs->clipping.top) / |
3308 | vcs->decimation; | 3240 | vcs->decimation; |
3309 | pf->pixelformat = | 3241 | pf->pixelformat = |
3310 | vino_data_formats[vcs->data_format].pixelformat; | 3242 | vino_data_formats[vcs->data_format].pixelformat; |
3311 | 3243 | ||
3312 | pf->field = V4L2_FIELD_INTERLACED; | 3244 | pf->field = V4L2_FIELD_INTERLACED; |
3313 | pf->bytesperline = vcs->line_size; | 3245 | pf->bytesperline = vcs->line_size; |
3314 | pf->sizeimage = vcs->line_size * | 3246 | pf->sizeimage = vcs->line_size * |
3315 | (vcs->clipping.bottom - vcs->clipping.top) / | 3247 | (vcs->clipping.bottom - vcs->clipping.top) / |
3316 | vcs->decimation; | 3248 | vcs->decimation; |
3317 | pf->colorspace = | 3249 | pf->colorspace = |
3318 | vino_data_formats[vcs->data_format].colorspace; | 3250 | vino_data_formats[vcs->data_format].colorspace; |
3319 | 3251 | ||
3320 | pf->priv = 0; | 3252 | pf->priv = 0; |
3321 | |||
3322 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
3323 | break; | ||
3324 | } | ||
3325 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
3326 | default: | ||
3327 | return -EINVAL; | ||
3328 | } | ||
3329 | 3253 | ||
3254 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
3330 | return 0; | 3255 | return 0; |
3331 | } | 3256 | } |
3332 | 3257 | ||
3333 | static int vino_v4l2_s_fmt(struct vino_channel_settings *vcs, | 3258 | static int vino_s_fmt_vid_cap(struct file *file, void *__fh, |
3334 | struct v4l2_format *f) | 3259 | struct v4l2_format *f) |
3335 | { | 3260 | { |
3261 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3336 | int data_format; | 3262 | int data_format; |
3337 | unsigned long flags; | 3263 | unsigned long flags; |
3264 | struct v4l2_pix_format *pf = &f->fmt.pix; | ||
3338 | 3265 | ||
3339 | switch (f->type) { | 3266 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3340 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { | ||
3341 | struct v4l2_pix_format *pf = &f->fmt.pix; | ||
3342 | |||
3343 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | ||
3344 | |||
3345 | data_format = vino_find_data_format(pf->pixelformat); | ||
3346 | 3267 | ||
3347 | if (data_format == VINO_DATA_FMT_NONE) { | 3268 | data_format = vino_find_data_format(pf->pixelformat); |
3348 | vcs->data_format = VINO_DATA_FMT_GREY; | ||
3349 | pf->pixelformat = | ||
3350 | vino_data_formats[vcs->data_format]. | ||
3351 | pixelformat; | ||
3352 | } else { | ||
3353 | vcs->data_format = data_format; | ||
3354 | } | ||
3355 | 3269 | ||
3356 | /* data format must be set before clipping/scaling */ | 3270 | if (data_format == VINO_DATA_FMT_NONE) { |
3357 | vino_set_scaling(vcs, pf->width, pf->height); | 3271 | vcs->data_format = VINO_DATA_FMT_GREY; |
3272 | pf->pixelformat = | ||
3273 | vino_data_formats[vcs->data_format]. | ||
3274 | pixelformat; | ||
3275 | } else { | ||
3276 | vcs->data_format = data_format; | ||
3277 | } | ||
3358 | 3278 | ||
3359 | dprintk("data format = %s\n", | 3279 | /* data format must be set before clipping/scaling */ |
3360 | vino_data_formats[vcs->data_format].description); | 3280 | vino_set_scaling(vcs, pf->width, pf->height); |
3361 | 3281 | ||
3362 | pf->width = vcs->clipping.right - vcs->clipping.left; | 3282 | dprintk("data format = %s\n", |
3363 | pf->height = vcs->clipping.bottom - vcs->clipping.top; | 3283 | vino_data_formats[vcs->data_format].description); |
3364 | 3284 | ||
3365 | pf->field = V4L2_FIELD_INTERLACED; | 3285 | pf->width = vcs->clipping.right - vcs->clipping.left; |
3366 | pf->bytesperline = vcs->line_size; | 3286 | pf->height = vcs->clipping.bottom - vcs->clipping.top; |
3367 | pf->sizeimage = vcs->line_size * | ||
3368 | (vcs->clipping.bottom - vcs->clipping.top) / | ||
3369 | vcs->decimation; | ||
3370 | pf->colorspace = | ||
3371 | vino_data_formats[vcs->data_format].colorspace; | ||
3372 | 3287 | ||
3373 | pf->priv = 0; | 3288 | pf->field = V4L2_FIELD_INTERLACED; |
3289 | pf->bytesperline = vcs->line_size; | ||
3290 | pf->sizeimage = vcs->line_size * | ||
3291 | (vcs->clipping.bottom - vcs->clipping.top) / | ||
3292 | vcs->decimation; | ||
3293 | pf->colorspace = | ||
3294 | vino_data_formats[vcs->data_format].colorspace; | ||
3374 | 3295 | ||
3375 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | 3296 | pf->priv = 0; |
3376 | break; | ||
3377 | } | ||
3378 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
3379 | default: | ||
3380 | return -EINVAL; | ||
3381 | } | ||
3382 | 3297 | ||
3298 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
3383 | return 0; | 3299 | return 0; |
3384 | } | 3300 | } |
3385 | 3301 | ||
3386 | static int vino_v4l2_cropcap(struct vino_channel_settings *vcs, | 3302 | static int vino_cropcap(struct file *file, void *__fh, |
3387 | struct v4l2_cropcap *ccap) | 3303 | struct v4l2_cropcap *ccap) |
3388 | { | 3304 | { |
3305 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3389 | const struct vino_data_norm *norm; | 3306 | const struct vino_data_norm *norm; |
3390 | unsigned long flags; | 3307 | unsigned long flags; |
3391 | 3308 | ||
@@ -3415,9 +3332,10 @@ static int vino_v4l2_cropcap(struct vino_channel_settings *vcs, | |||
3415 | return 0; | 3332 | return 0; |
3416 | } | 3333 | } |
3417 | 3334 | ||
3418 | static int vino_v4l2_g_crop(struct vino_channel_settings *vcs, | 3335 | static int vino_g_crop(struct file *file, void *__fh, |
3419 | struct v4l2_crop *c) | 3336 | struct v4l2_crop *c) |
3420 | { | 3337 | { |
3338 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3421 | unsigned long flags; | 3339 | unsigned long flags; |
3422 | 3340 | ||
3423 | switch (c->type) { | 3341 | switch (c->type) { |
@@ -3439,9 +3357,10 @@ static int vino_v4l2_g_crop(struct vino_channel_settings *vcs, | |||
3439 | return 0; | 3357 | return 0; |
3440 | } | 3358 | } |
3441 | 3359 | ||
3442 | static int vino_v4l2_s_crop(struct vino_channel_settings *vcs, | 3360 | static int vino_s_crop(struct file *file, void *__fh, |
3443 | struct v4l2_crop *c) | 3361 | struct v4l2_crop *c) |
3444 | { | 3362 | { |
3363 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3445 | unsigned long flags; | 3364 | unsigned long flags; |
3446 | 3365 | ||
3447 | switch (c->type) { | 3366 | switch (c->type) { |
@@ -3461,9 +3380,10 @@ static int vino_v4l2_s_crop(struct vino_channel_settings *vcs, | |||
3461 | return 0; | 3380 | return 0; |
3462 | } | 3381 | } |
3463 | 3382 | ||
3464 | static int vino_v4l2_g_parm(struct vino_channel_settings *vcs, | 3383 | static int vino_g_parm(struct file *file, void *__fh, |
3465 | struct v4l2_streamparm *sp) | 3384 | struct v4l2_streamparm *sp) |
3466 | { | 3385 | { |
3386 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3467 | unsigned long flags; | 3387 | unsigned long flags; |
3468 | 3388 | ||
3469 | switch (sp->type) { | 3389 | switch (sp->type) { |
@@ -3491,9 +3411,10 @@ static int vino_v4l2_g_parm(struct vino_channel_settings *vcs, | |||
3491 | return 0; | 3411 | return 0; |
3492 | } | 3412 | } |
3493 | 3413 | ||
3494 | static int vino_v4l2_s_parm(struct vino_channel_settings *vcs, | 3414 | static int vino_s_parm(struct file *file, void *__fh, |
3495 | struct v4l2_streamparm *sp) | 3415 | struct v4l2_streamparm *sp) |
3496 | { | 3416 | { |
3417 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3497 | unsigned long flags; | 3418 | unsigned long flags; |
3498 | 3419 | ||
3499 | switch (sp->type) { | 3420 | switch (sp->type) { |
@@ -3524,9 +3445,10 @@ static int vino_v4l2_s_parm(struct vino_channel_settings *vcs, | |||
3524 | return 0; | 3445 | return 0; |
3525 | } | 3446 | } |
3526 | 3447 | ||
3527 | static int vino_v4l2_reqbufs(struct vino_channel_settings *vcs, | 3448 | static int vino_reqbufs(struct file *file, void *__fh, |
3528 | struct v4l2_requestbuffers *rb) | 3449 | struct v4l2_requestbuffers *rb) |
3529 | { | 3450 | { |
3451 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3530 | if (vcs->reading) | 3452 | if (vcs->reading) |
3531 | return -EBUSY; | 3453 | return -EBUSY; |
3532 | 3454 | ||
@@ -3606,9 +3528,10 @@ static void vino_v4l2_get_buffer_status(struct vino_channel_settings *vcs, | |||
3606 | fb->id, fb->size, fb->data_size, fb->offset); | 3528 | fb->id, fb->size, fb->data_size, fb->offset); |
3607 | } | 3529 | } |
3608 | 3530 | ||
3609 | static int vino_v4l2_querybuf(struct vino_channel_settings *vcs, | 3531 | static int vino_querybuf(struct file *file, void *__fh, |
3610 | struct v4l2_buffer *b) | 3532 | struct v4l2_buffer *b) |
3611 | { | 3533 | { |
3534 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3612 | if (vcs->reading) | 3535 | if (vcs->reading) |
3613 | return -EBUSY; | 3536 | return -EBUSY; |
3614 | 3537 | ||
@@ -3641,9 +3564,10 @@ static int vino_v4l2_querybuf(struct vino_channel_settings *vcs, | |||
3641 | return 0; | 3564 | return 0; |
3642 | } | 3565 | } |
3643 | 3566 | ||
3644 | static int vino_v4l2_qbuf(struct vino_channel_settings *vcs, | 3567 | static int vino_qbuf(struct file *file, void *__fh, |
3645 | struct v4l2_buffer *b) | 3568 | struct v4l2_buffer *b) |
3646 | { | 3569 | { |
3570 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3647 | if (vcs->reading) | 3571 | if (vcs->reading) |
3648 | return -EBUSY; | 3572 | return -EBUSY; |
3649 | 3573 | ||
@@ -3679,10 +3603,11 @@ static int vino_v4l2_qbuf(struct vino_channel_settings *vcs, | |||
3679 | return 0; | 3603 | return 0; |
3680 | } | 3604 | } |
3681 | 3605 | ||
3682 | static int vino_v4l2_dqbuf(struct vino_channel_settings *vcs, | 3606 | static int vino_dqbuf(struct file *file, void *__fh, |
3683 | struct v4l2_buffer *b, | 3607 | struct v4l2_buffer *b) |
3684 | unsigned int nonblocking) | ||
3685 | { | 3608 | { |
3609 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3610 | unsigned int nonblocking = file->f_flags & O_NONBLOCK; | ||
3686 | if (vcs->reading) | 3611 | if (vcs->reading) |
3687 | return -EBUSY; | 3612 | return -EBUSY; |
3688 | 3613 | ||
@@ -3754,8 +3679,10 @@ static int vino_v4l2_dqbuf(struct vino_channel_settings *vcs, | |||
3754 | return 0; | 3679 | return 0; |
3755 | } | 3680 | } |
3756 | 3681 | ||
3757 | static int vino_v4l2_streamon(struct vino_channel_settings *vcs) | 3682 | static int vino_streamon(struct file *file, void *__fh, |
3683 | enum v4l2_buf_type i) | ||
3758 | { | 3684 | { |
3685 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3759 | unsigned int incoming; | 3686 | unsigned int incoming; |
3760 | int ret; | 3687 | int ret; |
3761 | if (vcs->reading) | 3688 | if (vcs->reading) |
@@ -3792,8 +3719,10 @@ static int vino_v4l2_streamon(struct vino_channel_settings *vcs) | |||
3792 | return 0; | 3719 | return 0; |
3793 | } | 3720 | } |
3794 | 3721 | ||
3795 | static int vino_v4l2_streamoff(struct vino_channel_settings *vcs) | 3722 | static int vino_streamoff(struct file *file, void *__fh, |
3723 | enum v4l2_buf_type i) | ||
3796 | { | 3724 | { |
3725 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3797 | if (vcs->reading) | 3726 | if (vcs->reading) |
3798 | return -EBUSY; | 3727 | return -EBUSY; |
3799 | 3728 | ||
@@ -3806,9 +3735,10 @@ static int vino_v4l2_streamoff(struct vino_channel_settings *vcs) | |||
3806 | return 0; | 3735 | return 0; |
3807 | } | 3736 | } |
3808 | 3737 | ||
3809 | static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs, | 3738 | static int vino_queryctrl(struct file *file, void *__fh, |
3810 | struct v4l2_queryctrl *queryctrl) | 3739 | struct v4l2_queryctrl *queryctrl) |
3811 | { | 3740 | { |
3741 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3812 | unsigned long flags; | 3742 | unsigned long flags; |
3813 | int i; | 3743 | int i; |
3814 | int err = 0; | 3744 | int err = 0; |
@@ -3855,9 +3785,10 @@ static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs, | |||
3855 | return err; | 3785 | return err; |
3856 | } | 3786 | } |
3857 | 3787 | ||
3858 | static int vino_v4l2_g_ctrl(struct vino_channel_settings *vcs, | 3788 | static int vino_g_ctrl(struct file *file, void *__fh, |
3859 | struct v4l2_control *control) | 3789 | struct v4l2_control *control) |
3860 | { | 3790 | { |
3791 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3861 | unsigned long flags; | 3792 | unsigned long flags; |
3862 | int i; | 3793 | int i; |
3863 | int err = 0; | 3794 | int err = 0; |
@@ -3928,9 +3859,10 @@ out: | |||
3928 | return err; | 3859 | return err; |
3929 | } | 3860 | } |
3930 | 3861 | ||
3931 | static int vino_v4l2_s_ctrl(struct vino_channel_settings *vcs, | 3862 | static int vino_s_ctrl(struct file *file, void *__fh, |
3932 | struct v4l2_control *control) | 3863 | struct v4l2_control *control) |
3933 | { | 3864 | { |
3865 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
3934 | unsigned long flags; | 3866 | unsigned long flags; |
3935 | int i; | 3867 | int i; |
3936 | int err = 0; | 3868 | int err = 0; |
@@ -4237,112 +4169,6 @@ error: | |||
4237 | return ret; | 4169 | return ret; |
4238 | } | 4170 | } |
4239 | 4171 | ||
4240 | static long vino_do_ioctl(struct file *file, unsigned int cmd, void *arg) | ||
4241 | { | ||
4242 | struct vino_channel_settings *vcs = video_drvdata(file); | ||
4243 | |||
4244 | #ifdef VINO_DEBUG | ||
4245 | switch (_IOC_TYPE(cmd)) { | ||
4246 | case 'v': | ||
4247 | dprintk("ioctl(): V4L1 unsupported (0x%08x)\n", cmd); | ||
4248 | break; | ||
4249 | case 'V': | ||
4250 | dprintk("ioctl(): V4L2 %s (0x%08x)\n", | ||
4251 | v4l2_ioctl_names[_IOC_NR(cmd)], cmd); | ||
4252 | break; | ||
4253 | default: | ||
4254 | dprintk("ioctl(): unsupported command 0x%08x\n", cmd); | ||
4255 | } | ||
4256 | #endif | ||
4257 | |||
4258 | switch (cmd) { | ||
4259 | /* V4L2 interface */ | ||
4260 | case VIDIOC_QUERYCAP: { | ||
4261 | vino_v4l2_querycap(arg); | ||
4262 | break; | ||
4263 | } | ||
4264 | case VIDIOC_ENUMINPUT: { | ||
4265 | return vino_v4l2_enuminput(vcs, arg); | ||
4266 | } | ||
4267 | case VIDIOC_G_INPUT: { | ||
4268 | return vino_v4l2_g_input(vcs, arg); | ||
4269 | } | ||
4270 | case VIDIOC_S_INPUT: { | ||
4271 | return vino_v4l2_s_input(vcs, arg); | ||
4272 | } | ||
4273 | case VIDIOC_ENUMSTD: { | ||
4274 | return vino_v4l2_enumstd(vcs, arg); | ||
4275 | } | ||
4276 | case VIDIOC_QUERYSTD: { | ||
4277 | return vino_v4l2_querystd(vcs, arg); | ||
4278 | } | ||
4279 | case VIDIOC_G_STD: { | ||
4280 | return vino_v4l2_g_std(vcs, arg); | ||
4281 | } | ||
4282 | case VIDIOC_S_STD: { | ||
4283 | return vino_v4l2_s_std(vcs, arg); | ||
4284 | } | ||
4285 | case VIDIOC_ENUM_FMT: { | ||
4286 | return vino_v4l2_enum_fmt(vcs, arg); | ||
4287 | } | ||
4288 | case VIDIOC_TRY_FMT: { | ||
4289 | return vino_v4l2_try_fmt(vcs, arg); | ||
4290 | } | ||
4291 | case VIDIOC_G_FMT: { | ||
4292 | return vino_v4l2_g_fmt(vcs, arg); | ||
4293 | } | ||
4294 | case VIDIOC_S_FMT: { | ||
4295 | return vino_v4l2_s_fmt(vcs, arg); | ||
4296 | } | ||
4297 | case VIDIOC_CROPCAP: { | ||
4298 | return vino_v4l2_cropcap(vcs, arg); | ||
4299 | } | ||
4300 | case VIDIOC_G_CROP: { | ||
4301 | return vino_v4l2_g_crop(vcs, arg); | ||
4302 | } | ||
4303 | case VIDIOC_S_CROP: { | ||
4304 | return vino_v4l2_s_crop(vcs, arg); | ||
4305 | } | ||
4306 | case VIDIOC_G_PARM: { | ||
4307 | return vino_v4l2_g_parm(vcs, arg); | ||
4308 | } | ||
4309 | case VIDIOC_S_PARM: { | ||
4310 | return vino_v4l2_s_parm(vcs, arg); | ||
4311 | } | ||
4312 | case VIDIOC_REQBUFS: { | ||
4313 | return vino_v4l2_reqbufs(vcs, arg); | ||
4314 | } | ||
4315 | case VIDIOC_QUERYBUF: { | ||
4316 | return vino_v4l2_querybuf(vcs, arg); | ||
4317 | } | ||
4318 | case VIDIOC_QBUF: { | ||
4319 | return vino_v4l2_qbuf(vcs, arg); | ||
4320 | } | ||
4321 | case VIDIOC_DQBUF: { | ||
4322 | return vino_v4l2_dqbuf(vcs, arg, file->f_flags & O_NONBLOCK); | ||
4323 | } | ||
4324 | case VIDIOC_STREAMON: { | ||
4325 | return vino_v4l2_streamon(vcs); | ||
4326 | } | ||
4327 | case VIDIOC_STREAMOFF: { | ||
4328 | return vino_v4l2_streamoff(vcs); | ||
4329 | } | ||
4330 | case VIDIOC_QUERYCTRL: { | ||
4331 | return vino_v4l2_queryctrl(vcs, arg); | ||
4332 | } | ||
4333 | case VIDIOC_G_CTRL: { | ||
4334 | return vino_v4l2_g_ctrl(vcs, arg); | ||
4335 | } | ||
4336 | case VIDIOC_S_CTRL: { | ||
4337 | return vino_v4l2_s_ctrl(vcs, arg); | ||
4338 | } | ||
4339 | default: | ||
4340 | return -ENOIOCTLCMD; | ||
4341 | } | ||
4342 | |||
4343 | return 0; | ||
4344 | } | ||
4345 | |||
4346 | static long vino_ioctl(struct file *file, | 4172 | static long vino_ioctl(struct file *file, |
4347 | unsigned int cmd, unsigned long arg) | 4173 | unsigned int cmd, unsigned long arg) |
4348 | { | 4174 | { |
@@ -4352,7 +4178,7 @@ static long vino_ioctl(struct file *file, | |||
4352 | if (mutex_lock_interruptible(&vcs->mutex)) | 4178 | if (mutex_lock_interruptible(&vcs->mutex)) |
4353 | return -EINTR; | 4179 | return -EINTR; |
4354 | 4180 | ||
4355 | ret = video_usercopy(file, cmd, arg, vino_do_ioctl); | 4181 | ret = video_ioctl2(file, cmd, arg); |
4356 | 4182 | ||
4357 | mutex_unlock(&vcs->mutex); | 4183 | mutex_unlock(&vcs->mutex); |
4358 | 4184 | ||
@@ -4364,6 +4190,34 @@ static long vino_ioctl(struct file *file, | |||
4364 | /* __initdata */ | 4190 | /* __initdata */ |
4365 | static int vino_init_stage; | 4191 | static int vino_init_stage; |
4366 | 4192 | ||
4193 | const struct v4l2_ioctl_ops vino_ioctl_ops = { | ||
4194 | .vidioc_enum_fmt_vid_cap = vino_enum_fmt_vid_cap, | ||
4195 | .vidioc_g_fmt_vid_cap = vino_g_fmt_vid_cap, | ||
4196 | .vidioc_s_fmt_vid_cap = vino_s_fmt_vid_cap, | ||
4197 | .vidioc_try_fmt_vid_cap = vino_try_fmt_vid_cap, | ||
4198 | .vidioc_querycap = vino_querycap, | ||
4199 | .vidioc_enum_input = vino_enum_input, | ||
4200 | .vidioc_g_input = vino_g_input, | ||
4201 | .vidioc_s_input = vino_s_input, | ||
4202 | .vidioc_g_std = vino_g_std, | ||
4203 | .vidioc_s_std = vino_s_std, | ||
4204 | .vidioc_querystd = vino_querystd, | ||
4205 | .vidioc_cropcap = vino_cropcap, | ||
4206 | .vidioc_s_crop = vino_s_crop, | ||
4207 | .vidioc_g_crop = vino_g_crop, | ||
4208 | .vidioc_s_parm = vino_s_parm, | ||
4209 | .vidioc_g_parm = vino_g_parm, | ||
4210 | .vidioc_reqbufs = vino_reqbufs, | ||
4211 | .vidioc_querybuf = vino_querybuf, | ||
4212 | .vidioc_qbuf = vino_qbuf, | ||
4213 | .vidioc_dqbuf = vino_dqbuf, | ||
4214 | .vidioc_streamon = vino_streamon, | ||
4215 | .vidioc_streamoff = vino_streamoff, | ||
4216 | .vidioc_queryctrl = vino_queryctrl, | ||
4217 | .vidioc_g_ctrl = vino_g_ctrl, | ||
4218 | .vidioc_s_ctrl = vino_s_ctrl, | ||
4219 | }; | ||
4220 | |||
4367 | static const struct v4l2_file_operations vino_fops = { | 4221 | static const struct v4l2_file_operations vino_fops = { |
4368 | .owner = THIS_MODULE, | 4222 | .owner = THIS_MODULE, |
4369 | .open = vino_open, | 4223 | .open = vino_open, |
@@ -4376,6 +4230,8 @@ static const struct v4l2_file_operations vino_fops = { | |||
4376 | static struct video_device v4l_device_template = { | 4230 | static struct video_device v4l_device_template = { |
4377 | .name = "NOT SET", | 4231 | .name = "NOT SET", |
4378 | .fops = &vino_fops, | 4232 | .fops = &vino_fops, |
4233 | .ioctl_ops = &vino_ioctl_ops, | ||
4234 | .tvnorms = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM, | ||
4379 | .minor = -1, | 4235 | .minor = -1, |
4380 | }; | 4236 | }; |
4381 | 4237 | ||