aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-hdw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-hdw.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c75
1 files changed, 60 insertions, 15 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 0a868888f389..a5217a2cf4c0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * 2 *
3 * $Id$
4 * 3 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com> 4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * 5 *
@@ -40,6 +39,23 @@
40#define TV_MIN_FREQ 55250000L 39#define TV_MIN_FREQ 55250000L
41#define TV_MAX_FREQ 850000000L 40#define TV_MAX_FREQ 850000000L
42 41
42/* This defines a minimum interval that the decoder must remain quiet
43 before we are allowed to start it running. */
44#define TIME_MSEC_DECODER_WAIT 50
45
46/* This defines a minimum interval that the encoder must remain quiet
47 before we are allowed to configure it. I had this originally set to
48 50msec, but Martin Dauskardt <martin.dauskardt@gmx.de> reports that
49 things work better when it's set to 100msec. */
50#define TIME_MSEC_ENCODER_WAIT 100
51
52/* This defines the minimum interval that the encoder must successfully run
53 before we consider that the encoder has run at least once since its
54 firmware has been loaded. This measurement is in important for cases
55 where we can't do something until we know that the encoder has been run
56 at least once. */
57#define TIME_MSEC_ENCODER_OK 250
58
43static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; 59static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
44static DEFINE_MUTEX(pvr2_unit_mtx); 60static DEFINE_MUTEX(pvr2_unit_mtx);
45 61
@@ -67,6 +83,16 @@ MODULE_PARM_DESC(video_std,"specify initial video standard");
67module_param_array(tolerance, int, NULL, 0444); 83module_param_array(tolerance, int, NULL, 0444);
68MODULE_PARM_DESC(tolerance,"specify stream error tolerance"); 84MODULE_PARM_DESC(tolerance,"specify stream error tolerance");
69 85
86/* US Broadcast channel 7 (175.25 MHz) */
87static int default_tv_freq = 175250000L;
88/* 104.3 MHz, a usable FM station for my area */
89static int default_radio_freq = 104300000L;
90
91module_param_named(tv_freq, default_tv_freq, int, 0444);
92MODULE_PARM_DESC(tv_freq, "specify initial television frequency");
93module_param_named(radio_freq, default_radio_freq, int, 0444);
94MODULE_PARM_DESC(radio_freq, "specify initial radio frequency");
95
70#define PVR2_CTL_WRITE_ENDPOINT 0x01 96#define PVR2_CTL_WRITE_ENDPOINT 0x01
71#define PVR2_CTL_READ_ENDPOINT 0x81 97#define PVR2_CTL_READ_ENDPOINT 0x81
72 98
@@ -1701,10 +1727,8 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
1701 are, but I set them to something usable in the Chicago area just 1727 are, but I set them to something usable in the Chicago area just
1702 to make driver testing a little easier. */ 1728 to make driver testing a little easier. */
1703 1729
1704 /* US Broadcast channel 7 (175.25 MHz) */ 1730 hdw->freqValTelevision = default_tv_freq;
1705 hdw->freqValTelevision = 175250000L; 1731 hdw->freqValRadio = default_radio_freq;
1706 /* 104.3 MHz, a usable FM station for my area */
1707 hdw->freqValRadio = 104300000L;
1708 1732
1709 // Do not use pvr2_reset_ctl_endpoints() here. It is not 1733 // Do not use pvr2_reset_ctl_endpoints() here. It is not
1710 // thread-safe against the normal pvr2_send_request() mechanism. 1734 // thread-safe against the normal pvr2_send_request() mechanism.
@@ -1989,7 +2013,8 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1989 case V4L2_CTRL_TYPE_MENU: 2013 case V4L2_CTRL_TYPE_MENU:
1990 ciptr->type = pvr2_ctl_enum; 2014 ciptr->type = pvr2_ctl_enum;
1991 ciptr->def.type_enum.value_names = 2015 ciptr->def.type_enum.value_names =
1992 cx2341x_ctrl_get_menu(ciptr->v4l_id); 2016 cx2341x_ctrl_get_menu(&hdw->enc_ctl_state,
2017 ciptr->v4l_id);
1993 for (cnt1 = 0; 2018 for (cnt1 = 0;
1994 ciptr->def.type_enum.value_names[cnt1] != NULL; 2019 ciptr->def.type_enum.value_names[cnt1] != NULL;
1995 cnt1++) { } 2020 cnt1++) { }
@@ -2428,22 +2453,38 @@ static int pvr2_hdw_commit_execute(struct pvr2_hdw *hdw)
2428 struct pvr2_ctrl *cptr; 2453 struct pvr2_ctrl *cptr;
2429 int disruptive_change; 2454 int disruptive_change;
2430 2455
2431 /* When video standard changes, reset the hres and vres values - 2456 /* Handle some required side effects when the video standard is
2432 but if the user has pending changes there, then let the changes 2457 changed.... */
2433 take priority. */
2434 if (hdw->std_dirty) { 2458 if (hdw->std_dirty) {
2435 /* Rewrite the vertical resolution to be appropriate to the
2436 video standard that has been selected. */
2437 int nvres; 2459 int nvres;
2460 int gop_size;
2438 if (hdw->std_mask_cur & V4L2_STD_525_60) { 2461 if (hdw->std_mask_cur & V4L2_STD_525_60) {
2439 nvres = 480; 2462 nvres = 480;
2463 gop_size = 15;
2440 } else { 2464 } else {
2441 nvres = 576; 2465 nvres = 576;
2466 gop_size = 12;
2442 } 2467 }
2468 /* Rewrite the vertical resolution to be appropriate to the
2469 video standard that has been selected. */
2443 if (nvres != hdw->res_ver_val) { 2470 if (nvres != hdw->res_ver_val) {
2444 hdw->res_ver_val = nvres; 2471 hdw->res_ver_val = nvres;
2445 hdw->res_ver_dirty = !0; 2472 hdw->res_ver_dirty = !0;
2446 } 2473 }
2474 /* Rewrite the GOP size to be appropriate to the video
2475 standard that has been selected. */
2476 if (gop_size != hdw->enc_ctl_state.video_gop_size) {
2477 struct v4l2_ext_controls cs;
2478 struct v4l2_ext_control c1;
2479 memset(&cs, 0, sizeof(cs));
2480 memset(&c1, 0, sizeof(c1));
2481 cs.controls = &c1;
2482 cs.count = 1;
2483 c1.id = V4L2_CID_MPEG_VIDEO_GOP_SIZE;
2484 c1.value = gop_size;
2485 cx2341x_ext_ctrls(&hdw->enc_ctl_state, 0, &cs,
2486 VIDIOC_S_EXT_CTRLS);
2487 }
2447 } 2488 }
2448 2489
2449 if (hdw->input_dirty && hdw->state_pathway_ok && 2490 if (hdw->input_dirty && hdw->state_pathway_ok &&
@@ -3421,7 +3462,7 @@ static void pvr2_hdw_cmd_modeswitch(struct pvr2_hdw *hdw,int digitalFl)
3421} 3462}
3422 3463
3423 3464
3424void pvr2_led_ctrl_hauppauge(struct pvr2_hdw *hdw, int onoff) 3465static void pvr2_led_ctrl_hauppauge(struct pvr2_hdw *hdw, int onoff)
3425{ 3466{
3426 /* change some GPIO data 3467 /* change some GPIO data
3427 * 3468 *
@@ -3601,7 +3642,9 @@ static int state_eval_encoder_config(struct pvr2_hdw *hdw)
3601 the encoder. */ 3642 the encoder. */
3602 if (!hdw->state_encoder_waitok) { 3643 if (!hdw->state_encoder_waitok) {
3603 hdw->encoder_wait_timer.expires = 3644 hdw->encoder_wait_timer.expires =
3604 jiffies + (HZ*50/1000); 3645 jiffies +
3646 (HZ * TIME_MSEC_ENCODER_WAIT
3647 / 1000);
3605 add_timer(&hdw->encoder_wait_timer); 3648 add_timer(&hdw->encoder_wait_timer);
3606 } 3649 }
3607 } 3650 }
@@ -3725,7 +3768,7 @@ static int state_eval_encoder_run(struct pvr2_hdw *hdw)
3725 hdw->state_encoder_run = !0; 3768 hdw->state_encoder_run = !0;
3726 if (!hdw->state_encoder_runok) { 3769 if (!hdw->state_encoder_runok) {
3727 hdw->encoder_run_timer.expires = 3770 hdw->encoder_run_timer.expires =
3728 jiffies + (HZ*250/1000); 3771 jiffies + (HZ * TIME_MSEC_ENCODER_OK / 1000);
3729 add_timer(&hdw->encoder_run_timer); 3772 add_timer(&hdw->encoder_run_timer);
3730 } 3773 }
3731 } 3774 }
@@ -3800,7 +3843,9 @@ static int state_eval_decoder_run(struct pvr2_hdw *hdw)
3800 but before we did the pending check. */ 3843 but before we did the pending check. */
3801 if (!hdw->state_decoder_quiescent) { 3844 if (!hdw->state_decoder_quiescent) {
3802 hdw->quiescent_timer.expires = 3845 hdw->quiescent_timer.expires =
3803 jiffies + (HZ*50/1000); 3846 jiffies +
3847 (HZ * TIME_MSEC_DECODER_WAIT
3848 / 1000);
3804 add_timer(&hdw->quiescent_timer); 3849 add_timer(&hdw->quiescent_timer);
3805 } 3850 }
3806 } 3851 }