diff options
author | Mike Isely <isely@pobox.com> | 2007-01-19 22:09:47 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 10:34:38 -0500 |
commit | 18103c57b0168ebc0401702d483fe131f0aecc7a (patch) | |
tree | 1d57e73217254121f0c023009c510a4936332d64 /drivers/media/video/pvrusb2/pvrusb2-v4l2.c | |
parent | af78a48b69231e129db0e1db24053da22f8eed6d (diff) |
V4L/DVB (5081): Pvrusb2: VIDIOC_G_TUNER cleanup
Clean up use of VIDIOC_G_TUNER; we now correctly gather info from all
the I2C client modules. Also abide by V4L2_TUNER_CAP_LOW
appropriately.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-v4l2.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-v4l2.c | 85 |
1 files changed, 32 insertions, 53 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c index 655a722289ed..2a6763865266 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c | |||
@@ -95,25 +95,6 @@ static struct v4l2_capability pvr_capability ={ | |||
95 | .reserved = {0,0,0,0} | 95 | .reserved = {0,0,0,0} |
96 | }; | 96 | }; |
97 | 97 | ||
98 | static struct v4l2_tuner pvr_v4l2_tuners[]= { | ||
99 | { | ||
100 | .index = 0, | ||
101 | .name = "TV Tuner", | ||
102 | .type = V4L2_TUNER_ANALOG_TV, | ||
103 | .capability = (V4L2_TUNER_CAP_NORM | | ||
104 | V4L2_TUNER_CAP_STEREO | | ||
105 | V4L2_TUNER_CAP_LANG1 | | ||
106 | V4L2_TUNER_CAP_LANG2), | ||
107 | .rangelow = 0, | ||
108 | .rangehigh = 0, | ||
109 | .rxsubchans = V4L2_TUNER_SUB_STEREO, | ||
110 | .audmode = V4L2_TUNER_MODE_STEREO, | ||
111 | .signal = 0, | ||
112 | .afc = 0, | ||
113 | .reserved = {0,0,0,0} | ||
114 | } | ||
115 | }; | ||
116 | |||
117 | static struct v4l2_fmtdesc pvr_fmtdesc [] = { | 98 | static struct v4l2_fmtdesc pvr_fmtdesc [] = { |
118 | { | 99 | { |
119 | .index = 0, | 100 | .index = 0, |
@@ -358,34 +339,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
358 | case VIDIOC_G_TUNER: | 339 | case VIDIOC_G_TUNER: |
359 | { | 340 | { |
360 | struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; | 341 | struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; |
361 | unsigned int status_mask; | 342 | pvr2_hdw_execute_tuner_poll(hdw); |
362 | int val; | 343 | ret = pvr2_hdw_get_tuner_status(hdw,vt); |
363 | if (vt->index !=0) break; | ||
364 | |||
365 | status_mask = pvr2_hdw_get_signal_status(hdw); | ||
366 | |||
367 | memcpy(vt, &pvr_v4l2_tuners[vt->index], | ||
368 | sizeof(struct v4l2_tuner)); | ||
369 | |||
370 | vt->signal = 0; | ||
371 | if (status_mask & PVR2_SIGNAL_OK) { | ||
372 | if (status_mask & PVR2_SIGNAL_STEREO) { | ||
373 | vt->rxsubchans = V4L2_TUNER_SUB_STEREO; | ||
374 | } else { | ||
375 | vt->rxsubchans = V4L2_TUNER_SUB_MONO; | ||
376 | } | ||
377 | if (status_mask & PVR2_SIGNAL_SAP) { | ||
378 | vt->rxsubchans |= (V4L2_TUNER_SUB_LANG1 | | ||
379 | V4L2_TUNER_SUB_LANG2); | ||
380 | } | ||
381 | vt->signal = 65535; | ||
382 | } | ||
383 | |||
384 | val = 0; | ||
385 | ret = pvr2_ctrl_get_value( | ||
386 | pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_AUDIOMODE), | ||
387 | &val); | ||
388 | vt->audmode = val; | ||
389 | break; | 344 | break; |
390 | } | 345 | } |
391 | 346 | ||
@@ -405,8 +360,27 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
405 | { | 360 | { |
406 | const struct v4l2_frequency *vf = (struct v4l2_frequency *)arg; | 361 | const struct v4l2_frequency *vf = (struct v4l2_frequency *)arg; |
407 | unsigned long fv; | 362 | unsigned long fv; |
408 | fv = vf->frequency; | 363 | struct v4l2_tuner vt; |
364 | int cur_input; | ||
365 | struct pvr2_ctrl *ctrlp; | ||
366 | ret = pvr2_hdw_get_tuner_status(hdw,&vt); | ||
367 | if (ret != 0) break; | ||
368 | ctrlp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT); | ||
369 | ret = pvr2_ctrl_get_value(ctrlp,&cur_input); | ||
370 | if (ret != 0) break; | ||
409 | if (vf->type == V4L2_TUNER_RADIO) { | 371 | if (vf->type == V4L2_TUNER_RADIO) { |
372 | if (cur_input != PVR2_CVAL_INPUT_RADIO) { | ||
373 | pvr2_ctrl_set_value(ctrlp, | ||
374 | PVR2_CVAL_INPUT_RADIO); | ||
375 | } | ||
376 | } else { | ||
377 | if (cur_input == PVR2_CVAL_INPUT_RADIO) { | ||
378 | pvr2_ctrl_set_value(ctrlp, | ||
379 | PVR2_CVAL_INPUT_TV); | ||
380 | } | ||
381 | } | ||
382 | fv = vf->frequency; | ||
383 | if (vt.capability & V4L2_TUNER_CAP_LOW) { | ||
410 | fv = (fv * 125) / 2; | 384 | fv = (fv * 125) / 2; |
411 | } else { | 385 | } else { |
412 | fv = fv * 62500; | 386 | fv = fv * 62500; |
@@ -420,7 +394,10 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
420 | { | 394 | { |
421 | struct v4l2_frequency *vf = (struct v4l2_frequency *)arg; | 395 | struct v4l2_frequency *vf = (struct v4l2_frequency *)arg; |
422 | int val = 0; | 396 | int val = 0; |
423 | int cur_input = PVR2_CVAL_INPUT_TV; | 397 | int cur_input; |
398 | struct v4l2_tuner vt; | ||
399 | ret = pvr2_hdw_get_tuner_status(hdw,&vt); | ||
400 | if (ret != 0) break; | ||
424 | ret = pvr2_ctrl_get_value( | 401 | ret = pvr2_ctrl_get_value( |
425 | pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_FREQUENCY), | 402 | pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_FREQUENCY), |
426 | &val); | 403 | &val); |
@@ -429,14 +406,16 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
429 | pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT), | 406 | pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT), |
430 | &cur_input); | 407 | &cur_input); |
431 | if (cur_input == PVR2_CVAL_INPUT_RADIO) { | 408 | if (cur_input == PVR2_CVAL_INPUT_RADIO) { |
432 | val = (val * 2) / 125; | ||
433 | vf->frequency = val; | ||
434 | vf->type = V4L2_TUNER_RADIO; | 409 | vf->type = V4L2_TUNER_RADIO; |
435 | } else { | 410 | } else { |
436 | val /= 62500; | ||
437 | vf->frequency = val; | ||
438 | vf->type = V4L2_TUNER_ANALOG_TV; | 411 | vf->type = V4L2_TUNER_ANALOG_TV; |
439 | } | 412 | } |
413 | if (vt.capability & V4L2_TUNER_CAP_LOW) { | ||
414 | val = (val * 2) / 125; | ||
415 | } else { | ||
416 | val /= 62500; | ||
417 | } | ||
418 | vf->frequency = val; | ||
440 | break; | 419 | break; |
441 | } | 420 | } |
442 | 421 | ||