diff options
Diffstat (limited to 'linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c')
-rw-r--r-- | linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c | 267 |
1 files changed, 96 insertions, 171 deletions
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c index 51491e67c..f4284f927 100644 --- a/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c +++ b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c @@ -33,14 +33,6 @@ #include <linux/videodev2.h> #include <media/v4l2-common.h> - -#define PVR_WIDTH_DVD 720 -#define PVR_WIDTH_SVCD 480 -#define PVR_WIDTH_VCD 352 - -#define PVR_HEIGHT_PAL 480 -#define PVR_HEIGHT_NTSC 576 - struct pvr2_v4l2_dev; struct pvr2_v4l2_fh; struct pvr2_v4l2; @@ -246,46 +238,25 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, case VIDIOC_ENUMSTD: { struct v4l2_standard *vs = (struct v4l2_standard *)arg; - const struct v4l2_standard *src; int idx = vs->index; - - src = pvr2_hdw_get_stdenum_value(hdw,idx); - if (!src) break; - - memcpy(vs, src, sizeof(struct v4l2_standard)); - vs->index = idx; - - ret = 0; + ret = pvr2_hdw_get_stdenum_value(hdw,vs,idx+1); break; } case VIDIOC_G_STD: { - struct pvr2_ctrl *cptr; - v4l2_std_id *vs = (v4l2_std_id *)arg; - cptr = pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_STDCUR); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - - *vs = pvr2_ctrl_get_value(cptr); - ret = 0; + int val = 0; + ret = pvr2_ctrl_get_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR),&val); + *(v4l2_std_id *)arg = val; break; } case VIDIOC_S_STD: { - struct pvr2_ctrl *cptr; - v4l2_std_id *vs = (v4l2_std_id *)arg; - cptr = pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_STDCUR); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - - pvr2_ctrl_set_value(cptr,*vs); - ret = 0; + ret = pvr2_ctrl_set_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR), + *(v4l2_std_id *)arg); break; } @@ -294,16 +265,13 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, struct pvr2_ctrl *cptr; struct v4l2_input *vi = (struct v4l2_input *)arg; struct v4l2_input tmp; + unsigned int cnt; - if ((vi->index > PVR2_CVAL_INPUT_MAX) || - (vi->index < PVR2_CVAL_INPUT_MIN)) { - break; - } - - cptr = pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_INPUT); + cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT); memset(&tmp,0,sizeof(tmp)); tmp.index = vi->index; + ret = 0; switch (vi->index) { case PVR2_CVAL_INPUT_TV: case PVR2_CVAL_INPUT_RADIO: @@ -313,11 +281,16 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, case PVR2_CVAL_INPUT_COMPOSITE: tmp.type = V4L2_INPUT_TYPE_CAMERA; break; + default: + ret = -EINVAL; + break; } + if (ret < 0) break; - strlcpy(tmp.name, - pvr2_ctrl_get_value_name(cptr,vi->index), - sizeof(tmp.name)); + cnt = 0; + pvr2_ctrl_get_valname(cptr,vi->index, + tmp.name,sizeof(tmp.name)-1,&cnt); + tmp.name[cnt] = 0; /* Don't bother with audioset, since this driver currently always switches the audio whenever the video is @@ -339,31 +312,20 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, { struct pvr2_ctrl *cptr; struct v4l2_input *vi = (struct v4l2_input *)arg; - cptr = pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_INPUT); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - - vi->index = pvr2_ctrl_get_value(cptr); - ret = 0; + int val; + cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT); + val = 0; + ret = pvr2_ctrl_get_value(cptr,&val); + vi->index = val; break; } case VIDIOC_S_INPUT: { - struct pvr2_ctrl *cptr; struct v4l2_input *vi = (struct v4l2_input *)arg; - cptr = pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_INPUT); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - - ret = 0; - if (pvr2_ctrl_set_value(cptr,vi->index)) { - ret = -EINVAL; - } + ret = pvr2_ctrl_set_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT), + vi->index); break; } @@ -386,9 +348,9 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, } case VIDIOC_G_TUNER: { - struct pvr2_ctrl *cptr; struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; unsigned int status_mask; + int val; if (vt->index !=0) break; status_mask = pvr2_hdw_get_signal_status(hdw); @@ -410,66 +372,44 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, vt->signal = 65535; } - cptr = pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_AUDIOMODE); - vt->audmode = pvr2_ctrl_get_value(cptr); - - ret = 0; + val = 0; + ret = pvr2_ctrl_get_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_AUDIOMODE), + &val); + vt->audmode = val; break; } case VIDIOC_S_TUNER: { - struct pvr2_ctrl *cptr; struct v4l2_tuner *vt=(struct v4l2_tuner *)arg; if (vt->index != 0) break; - cptr = pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_AUDIOMODE); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - - pvr2_ctrl_set_value(cptr,vt->audmode); - ret = 0; + ret = pvr2_ctrl_set_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_AUDIOMODE), + vt->audmode); } case VIDIOC_S_FREQUENCY: { - struct pvr2_ctrl *cptr; const struct v4l2_frequency *vf = (struct v4l2_frequency *)arg; - - cptr = pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_FREQUENCY); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - - pvr2_ctrl_set_value(cptr,vf->frequency * 62500); - - ret = 0; + ret = pvr2_ctrl_set_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_FREQUENCY), + vf->frequency * 62500); break; } case VIDIOC_G_FREQUENCY: { - struct pvr2_ctrl *cptr; struct v4l2_frequency *vf = (struct v4l2_frequency *)arg; - int val; - - cptr = pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_FREQUENCY); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - - val = pvr2_ctrl_get_value(cptr); - + int val = 0; + ret = pvr2_ctrl_get_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_FREQUENCY), + &val); val /= 62500; vf->frequency = val; - - ret = 0; break; } @@ -489,24 +429,27 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, case VIDIOC_G_FMT: { struct v4l2_format *vf = (struct v4l2_format *)arg; - + int val; switch(vf->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: memcpy(vf, &pvr_format[PVR_FORMAT_PIX], sizeof(struct v4l2_format)); - vf->fmt.pix.width = - pvr2_ctrl_get_value( - pvr2_hdw_get_ctrl(hdw, - V4L2_CID_PVR_HRES)); - if (pvr2_ctrl_get_value( - pvr2_hdw_get_ctrl( - hdw,V4L2_CID_PVR_INTERLACE))) { - vf->fmt.pix.width /= 2; - } - vf->fmt.pix.height = - pvr2_ctrl_get_value( - pvr2_hdw_get_ctrl(hdw, - V4L2_CID_PVR_VRES)); + val = 0; + pvr2_ctrl_get_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_HRES), + &val); + vf->fmt.pix.width = val; + val = 0; + pvr2_ctrl_get_value( + pvr2_hdw_get_ctrl_by_id(hdw, + PVR2_CID_INTERLACE), + &val); + if (val) vf->fmt.pix.width /= 2; + val = 0; + pvr2_ctrl_get_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_VRES), + &val); + vf->fmt.pix.height = val; ret = 0; break; case V4L2_BUF_TYPE_VBI_CAPTURE: @@ -532,8 +475,10 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, int w = vf->fmt.pix.width; int vd_std, hf, hh; - vd_std = pvr2_ctrl_get_value( - pvr2_hdw_get_ctrl(hdw,V4L2_CID_PVR_STDCUR)); + vd_std = 0; + pvr2_ctrl_get_value( + pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR), + &vd_std); if (vd_std & V4L2_STD_525_60) { hf=480; } else { @@ -548,18 +493,18 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, vf->fmt.pix.width &= 0xff0; vf->fmt.pix.height = (h > hh) ? hf : hh; - if (cmd == VIDIOC_S_FMT){ + if (cmd == VIDIOC_S_FMT) { pvr2_ctrl_set_value( - pvr2_hdw_get_ctrl(hdw, - V4L2_CID_PVR_HRES), + pvr2_hdw_get_ctrl_by_id(hdw, + PVR2_CID_HRES), vf->fmt.pix.width); pvr2_ctrl_set_value( - pvr2_hdw_get_ctrl(hdw, - V4L2_CID_PVR_VRES), + pvr2_hdw_get_ctrl_by_id(hdw, + PVR2_CID_VRES), vf->fmt.pix.height); pvr2_ctrl_set_value( - pvr2_hdw_get_ctrl( - hdw,V4L2_CID_PVR_INTERLACE), + pvr2_hdw_get_ctrl_by_id( + hdw,PVR2_CID_INTERLACE), vf->fmt.pix.height != hf); } } break; @@ -592,82 +537,62 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, { struct pvr2_ctrl *cptr; struct v4l2_queryctrl *vc = (struct v4l2_queryctrl *)arg; - cptr = pvr2_hdw_get_ctrl(hdw,vc->id); - - if (!pvr2_ctrl_is_valid(cptr)) { + ret = 0; + cptr = pvr2_hdw_get_ctrl_v4l(hdw,vc->id); + if (!cptr) { ret = -EINVAL; break; } + strlcpy(vc->name,pvr2_ctrl_get_name(cptr),sizeof(vc->name)); + vc->default_value = pvr2_ctrl_get_def(cptr); switch (pvr2_ctrl_get_type(cptr)) { - case PVR2_CTRL_TYPE_ENUM: + case pvr2_ctl_enum: vc->type = V4L2_CTRL_TYPE_MENU; + vc->minimum = 0; + vc->maximum = pvr2_ctrl_get_cnt(cptr) - 1; + vc->step = 1; break; - case PVR2_CTRL_TYPE_INT: + case pvr2_ctl_int: vc->type = V4L2_CTRL_TYPE_INTEGER; + vc->minimum = pvr2_ctrl_get_min(cptr); + vc->maximum = pvr2_ctrl_get_max(cptr); + vc->step = 1; break; default: ret = -EINVAL; break; } - - strlcpy(vc->name,pvr2_ctrl_get_desc(cptr),sizeof(vc->name)); - vc->minimum = pvr2_ctrl_get_min_value(cptr); - vc->maximum = pvr2_ctrl_get_max_value(cptr); - vc->default_value = pvr2_ctrl_get_default_value(cptr); - vc->step = 1; - ret = 0; break; } case VIDIOC_QUERYMENU: { - struct pvr2_ctrl *cptr; struct v4l2_querymenu *vm = (struct v4l2_querymenu *)arg; - const char *value_name; - cptr = pvr2_hdw_get_ctrl(hdw,vm->id); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - value_name = pvr2_ctrl_get_value_name(cptr,vm->index); - if (value_name) { - strlcpy(vm->name,value_name,sizeof(vm->name)); - ret = 0; - } else { - ret = -EINVAL; - } - + unsigned int cnt = 0; + ret = pvr2_ctrl_get_valname(pvr2_hdw_get_ctrl_v4l(hdw,vm->id), + vm->index, + vm->name,sizeof(vm->name)-1, + &cnt); + vm->name[cnt] = 0; break; } case VIDIOC_G_CTRL: { - struct pvr2_ctrl *cptr; struct v4l2_control *vc = (struct v4l2_control *)arg; - - cptr = pvr2_hdw_get_ctrl(hdw,vc->id); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - ret = 0; - vc->value = pvr2_ctrl_get_value(cptr); + int val = 0; + ret = pvr2_ctrl_get_value(pvr2_hdw_get_ctrl_v4l(hdw,vc->id), + &val); + vc->value = val; break; } case VIDIOC_S_CTRL: { - struct pvr2_ctrl *cptr; struct v4l2_control *vc = (struct v4l2_control *)arg; - - cptr = pvr2_hdw_get_ctrl(hdw,vc->id); - if (!pvr2_ctrl_is_valid(cptr)) { - ret = -EINVAL; - break; - } - - ret = pvr2_ctrl_set_value(cptr,vc->value); + ret = pvr2_ctrl_set_value(pvr2_hdw_get_ctrl_v4l(hdw,vc->id), + vc->value); break; } |