]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/media/video/pvrusb2/pvrusb2-hdw.c
V4L/DVB (4595): Remove CONFIG_VIDEO_PVRUSB2_24XXX from pvrusb2 driver
[karo-tx-linux.git] / drivers / media / video / pvrusb2 / pvrusb2-hdw.c
index 2fd40e061ccc9b643f908c5aba1b47ddc80d243c..6ab6fd187340db617583cd63326074225fedba69 100644 (file)
@@ -38,9 +38,7 @@
 
 struct usb_device_id pvr2_device_table[] = {
        [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) },
-#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
        [PVR2_HDW_TYPE_24XXX] = { USB_DEVICE(0x2040, 0x2400) },
-#endif
        { }
 };
 
@@ -48,9 +46,7 @@ MODULE_DEVICE_TABLE(usb, pvr2_device_table);
 
 static const char *pvr2_device_names[] = {
        [PVR2_HDW_TYPE_29XXX] = "WinTV PVR USB2 Model Category 29xxxx",
-#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
        [PVR2_HDW_TYPE_24XXX] = "WinTV PVR USB2 Model Category 24xxxx",
-#endif
 };
 
 struct pvr2_string_table {
@@ -58,22 +54,18 @@ struct pvr2_string_table {
        unsigned int cnt;
 };
 
-#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
 // Names of other client modules to request for 24xxx model hardware
 static const char *pvr2_client_24xxx[] = {
        "cx25840",
        "tuner",
-       "tda9887",
        "wm8775",
 };
-#endif
 
 // Names of other client modules to request for 29xxx model hardware
 static const char *pvr2_client_29xxx[] = {
        "msp3400",
        "saa7115",
        "tuner",
-       "tda9887",
 };
 
 static struct pvr2_string_table pvr2_client_lists[] = {
@@ -81,16 +73,14 @@ static struct pvr2_string_table pvr2_client_lists[] = {
                pvr2_client_29xxx,
                sizeof(pvr2_client_29xxx)/sizeof(pvr2_client_29xxx[0]),
        },
-#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
        [PVR2_HDW_TYPE_24XXX] = {
                pvr2_client_24xxx,
                sizeof(pvr2_client_24xxx)/sizeof(pvr2_client_24xxx[0]),
        },
-#endif
 };
 
-static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = 0};
-DECLARE_MUTEX(pvr2_unit_sem);
+static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
+static DECLARE_MUTEX(pvr2_unit_sem);
 
 static int ctlchg = 0;
 static int initusbreset = 1;
@@ -223,14 +213,15 @@ static const struct pvr2_mpeg_ids mpeg_ids[] = {
 };
 #define MPEGDEF_COUNT (sizeof(mpeg_ids)/sizeof(mpeg_ids[0]))
 
+
 static const char *control_values_srate[] = {
-       [PVR2_CVAL_SRATE_48]   = "48KHz",
-       [PVR2_CVAL_SRATE_44_1] = "44.1KHz",
+       [V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100]   = "44.1 kHz",
+       [V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000]   = "48 kHz",
+       [V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000]   = "32 kHz",
 };
 
 
 
-
 static const char *control_values_input[] = {
        [PVR2_CVAL_INPUT_TV]        = "television",  /*xawtv needs this name*/
        [PVR2_CVAL_INPUT_RADIO]     = "radio",
@@ -263,6 +254,25 @@ static const char *control_values_subsystem[] = {
        [PVR2_SUBSYS_B_ENC_RUN] = "enc_run",
 };
 
+static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
+static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
+static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw);
+static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw);
+static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
+static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);
+static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw);
+static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
+                                           unsigned long msk,
+                                           unsigned long val);
+static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
+                                                  unsigned long msk,
+                                                  unsigned long val);
+static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
+                               unsigned int timeout,int probe_fl,
+                               void *write_data,unsigned int write_len,
+                               void *read_data,unsigned int read_len);
+static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res);
+static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res);
 
 static int ctrl_channelfreq_get(struct pvr2_ctrl *cptr,int *vp)
 {
@@ -345,6 +355,28 @@ static int ctrl_freq_set(struct pvr2_ctrl *cptr,int m,int v)
        return 0;
 }
 
+static int ctrl_hres_max_get(struct pvr2_ctrl *cptr,int *vp)
+{
+       /* If we're dealing with a 24xxx device, force the horizontal
+          maximum to be 720 no matter what, since we can't get the device
+          to work properly with any other value.  Otherwise just return
+          the normal value. */
+       *vp = cptr->info->def.type_int.max_value;
+       if (cptr->hdw->hdw_type == PVR2_HDW_TYPE_24XXX) *vp = 720;
+       return 0;
+}
+
+static int ctrl_hres_min_get(struct pvr2_ctrl *cptr,int *vp)
+{
+       /* If we're dealing with a 24xxx device, force the horizontal
+          minimum to be 720 no matter what, since we can't get the device
+          to work properly with any other value.  Otherwise just return
+          the normal value. */
+       *vp = cptr->info->def.type_int.min_value;
+       if (cptr->hdw->hdw_type == PVR2_HDW_TYPE_24XXX) *vp = 720;
+       return 0;
+}
+
 static int ctrl_cx2341x_is_dirty(struct pvr2_ctrl *cptr)
 {
        return cptr->hdw->enc_stale != 0;
@@ -405,7 +437,7 @@ static unsigned int ctrl_cx2341x_getv4lflags(struct pvr2_ctrl *cptr)
        info = (struct pvr2_ctl_info *)(cptr->info);
        if (qctrl.flags & V4L2_CTRL_FLAG_READ_ONLY) {
                if (info->set_value) {
-                       info->set_value = 0;
+                       info->set_value = NULL;
                }
        } else {
                if (!(info->set_value)) {
@@ -703,6 +735,10 @@ static const struct pvr2_ctl_info control_defs[] = {
                .default_value = 720,
                DEFREF(res_hor),
                DEFINT(320,720),
+               /* Hook in check for clamp on horizontal resolution in
+                  order to avoid unsolved problem involving cx25840. */
+               .get_max_value = ctrl_hres_max_get,
+               .get_min_value = ctrl_hres_min_get,
        },{
                .desc = "Vertical capture resolution",
                .name = "resolution_ver",
@@ -712,9 +748,9 @@ static const struct pvr2_ctl_info control_defs[] = {
                DEFINT(200,625),
        },{
                .v4l_id = V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ,
-               .desc = "Sample rate",
+               .default_value = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000,
+               .desc = "Audio Sampling Frequency",
                .name = "srate",
-               .default_value = PVR2_CVAL_SRATE_48,
                DEFREF(srate),
                DEFENUM(control_values_srate),
        },{
@@ -835,15 +871,6 @@ unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *hdw)
        return hdw->serial_number;
 }
 
-
-struct pvr2_hdw *pvr2_hdw_find(int unit_number)
-{
-       if (unit_number < 0) return 0;
-       if (unit_number >= PVR_NUM) return 0;
-       return unit_pointers[unit_number];
-}
-
-
 int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw)
 {
        return hdw->unit_number;
@@ -917,9 +944,9 @@ static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
  * is not suitable for an usb transaction.
  *
  */
-int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
+static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
 {
-       const struct firmware *fw_entry = 0;
+       const struct firmware *fw_entry = NULL;
        void  *fw_ptr;
        unsigned int pipe;
        int ret;
@@ -927,22 +954,18 @@ int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
        static const char *fw_files_29xxx[] = {
                "v4l-pvrusb2-29xxx-01.fw",
        };
-#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
        static const char *fw_files_24xxx[] = {
                "v4l-pvrusb2-24xxx-01.fw",
        };
-#endif
        static const struct pvr2_string_table fw_file_defs[] = {
                [PVR2_HDW_TYPE_29XXX] = {
                        fw_files_29xxx,
                        sizeof(fw_files_29xxx)/sizeof(fw_files_29xxx[0]),
                },
-#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
                [PVR2_HDW_TYPE_24XXX] = {
                        fw_files_24xxx,
                        sizeof(fw_files_24xxx)/sizeof(fw_files_24xxx[0]),
                },
-#endif
        };
        hdw->fw1_state = FW1_STATE_FAILED; // default result
 
@@ -1015,7 +1038,7 @@ int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
 
 int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
 {
-       const struct firmware *fw_entry = 0;
+       const struct firmware *fw_entry = NULL;
        void  *fw_ptr;
        unsigned int pipe, fw_len, fw_done;
        int actual_length;
@@ -1166,8 +1189,9 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
   reconfigure and start over.
 
 */
-void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
-                                    unsigned long msk,unsigned long val)
+static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
+                                           unsigned long msk,
+                                           unsigned long val)
 {
        unsigned long nmsk;
        unsigned long vmsk;
@@ -1318,18 +1342,6 @@ void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
 }
 
 
-void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk)
-{
-       pvr2_hdw_subsys_bit_chg(hdw,msk,msk);
-}
-
-
-void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk)
-{
-       pvr2_hdw_subsys_bit_chg(hdw,msk,0);
-}
-
-
 unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *hdw)
 {
        return hdw->subsys_enabled_mask;
@@ -1342,9 +1354,9 @@ unsigned long pvr2_hdw_subsys_stream_get(struct pvr2_hdw *hdw)
 }
 
 
-void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
-                                           unsigned long msk,
-                                           unsigned long val)
+static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
+                                                  unsigned long msk,
+                                                  unsigned long val)
 {
        unsigned long val2;
        msk &= PVR2_SUBSYS_ALL;
@@ -1366,7 +1378,7 @@ void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw,
 }
 
 
-int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl)
+static int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl)
 {
        if ((!enableFl) == !(hdw->flag_streaming_enabled)) return 0;
        if (enableFl) {
@@ -1400,8 +1412,8 @@ int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag)
 }
 
 
-int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
-                                    enum pvr2_config config)
+static int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
+                                           enum pvr2_config config)
 {
        unsigned long sm = hdw->subsys_enabled_mask;
        if (!hdw->flag_ok) return -EIO;
@@ -1741,7 +1753,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
            sizeof(pvr2_device_names)/sizeof(pvr2_device_names[0])) {
                pvr2_trace(PVR2_TRACE_ERROR_LEGS,
                           "Bogus device type of %u reported",hdw_type);
-               return 0;
+               return NULL;
        }
 
        hdw = kmalloc(sizeof(*hdw),GFP_KERNEL);
@@ -1922,38 +1934,38 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
                if (hdw->mpeg_ctrl_info) kfree(hdw->mpeg_ctrl_info);
                kfree(hdw);
        }
-       return 0;
+       return NULL;
 }
 
 
 /* Remove _all_ associations between this driver and the underlying USB
    layer. */
-void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw)
+static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw)
 {
        if (hdw->flag_disconnected) return;
        pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw);
        if (hdw->ctl_read_urb) {
                usb_kill_urb(hdw->ctl_read_urb);
                usb_free_urb(hdw->ctl_read_urb);
-               hdw->ctl_read_urb = 0;
+               hdw->ctl_read_urb = NULL;
        }
        if (hdw->ctl_write_urb) {
                usb_kill_urb(hdw->ctl_write_urb);
                usb_free_urb(hdw->ctl_write_urb);
-               hdw->ctl_write_urb = 0;
+               hdw->ctl_write_urb = NULL;
        }
        if (hdw->ctl_read_buffer) {
                kfree(hdw->ctl_read_buffer);
-               hdw->ctl_read_buffer = 0;
+               hdw->ctl_read_buffer = NULL;
        }
        if (hdw->ctl_write_buffer) {
                kfree(hdw->ctl_write_buffer);
-               hdw->ctl_write_buffer = 0;
+               hdw->ctl_write_buffer = NULL;
        }
        pvr2_hdw_render_useless_unlocked(hdw);
        hdw->flag_disconnected = !0;
-       hdw->usb_dev = 0;
-       hdw->usb_intf = 0;
+       hdw->usb_dev = NULL;
+       hdw->usb_intf = NULL;
 }
 
 
@@ -1963,11 +1975,11 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
        pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw);
        if (hdw->fw_buffer) {
                kfree(hdw->fw_buffer);
-               hdw->fw_buffer = 0;
+               hdw->fw_buffer = NULL;
        }
        if (hdw->vid_stream) {
                pvr2_stream_destroy(hdw->vid_stream);
-               hdw->vid_stream = 0;
+               hdw->vid_stream = NULL;
        }
        if (hdw->audio_stat) {
                hdw->audio_stat->detach(hdw->audio_stat->ctxt);
@@ -1981,7 +1993,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
                if ((hdw->unit_number >= 0) &&
                    (hdw->unit_number < PVR_NUM) &&
                    (unit_pointers[hdw->unit_number] == hdw)) {
-                       unit_pointers[hdw->unit_number] = 0;
+                       unit_pointers[hdw->unit_number] = NULL;
                }
        } while (0); up(&pvr2_unit_sem);
        if (hdw->controls) kfree(hdw->controls);
@@ -2018,7 +2030,7 @@ void pvr2_hdw_disconnect(struct pvr2_hdw *hdw)
 
 // Attempt to autoselect an appropriate value for std_enum_cur given
 // whatever is currently in std_mask_cur
-void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
+static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
 {
        unsigned int idx;
        for (idx = 1; idx < hdw->std_enum_cnt; idx++) {
@@ -2033,7 +2045,7 @@ void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
 
 // Calculate correct set of enumerated standards based on currently known
 // set of available standards bits.
-void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
+static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
 {
        struct v4l2_standard *newstd;
        unsigned int std_cnt;
@@ -2043,12 +2055,12 @@ void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
 
        if (hdw->std_defs) {
                kfree(hdw->std_defs);
-               hdw->std_defs = 0;
+               hdw->std_defs = NULL;
        }
        hdw->std_enum_cnt = 0;
        if (hdw->std_enum_names) {
                kfree(hdw->std_enum_names);
-               hdw->std_enum_names = 0;
+               hdw->std_enum_names = NULL;
        }
 
        if (!std_cnt) {
@@ -2099,7 +2111,7 @@ unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw)
 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw,
                                             unsigned int idx)
 {
-       if (idx >= hdw->control_cnt) return 0;
+       if (idx >= hdw->control_cnt) return NULL;
        return hdw->controls + idx;
 }
 
@@ -2118,7 +2130,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw,
                i = cptr->info->internal_id;
                if (i && (i == ctl_id)) return cptr;
        }
-       return 0;
+       return NULL;
 }
 
 
@@ -2135,7 +2147,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id
                i = cptr->info->v4l_id;
                if (i && (i == ctl_id)) return cptr;
        }
-       return 0;
+       return NULL;
 }
 
 
@@ -2149,7 +2161,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw,
        int i;
 
        /* This could be made a lot more efficient, but for now... */
-       cp2 = 0;
+       cp2 = NULL;
        for (idx = 0; idx < hdw->control_cnt; idx++) {
                cptr = hdw->controls + idx;
                i = cptr->info->v4l_id;
@@ -2159,7 +2171,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw,
                cp2 = cptr;
        }
        return cp2;
-       return 0;
+       return NULL;
 }
 
 
@@ -2182,7 +2194,7 @@ static const char *get_ctrl_typename(enum pvr2_ctl_type tp)
    state(s) back to their previous value before this function was called.
    Thus we can automatically reconfigure affected pieces of the driver as
    controls are changed. */
-int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
+static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
 {
        unsigned long saved_subsys_mask = hdw->subsys_enabled_mask;
        unsigned long stale_subsys_mask = 0;
@@ -2240,11 +2252,14 @@ int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
        }
 
        if (hdw->std_dirty ||
+           hdw->enc_stale ||
+           hdw->srate_dirty ||
+           hdw->res_ver_dirty ||
+           hdw->res_hor_dirty ||
            0) {
                /* If any of this changes, then the encoder needs to be
                   reconfigured, and we need to reset the stream. */
                stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG);
-               stale_subsys_mask |= hdw->subsys_stream_mask;
        }
 
        if (hdw->srate_dirty) {
@@ -2320,15 +2335,6 @@ void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *hdw)
        }
 }
 
-
-void pvr2_hdw_poll_trigger(struct pvr2_hdw *hdw)
-{
-       LOCK_TAKE(hdw->big_lock); do {
-               pvr2_hdw_poll_trigger_unlocked(hdw);
-       } while (0); LOCK_GIVE(hdw->big_lock);
-}
-
-
 /* Return name for this driver instance */
 const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
 {
@@ -2337,7 +2343,7 @@ const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
 
 
 /* Return bit mask indicating signal status */
-unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw)
+static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw)
 {
        unsigned int msk = 0;
        switch (hdw->input_val) {
@@ -2407,7 +2413,7 @@ void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw)
                hdw->log_requested = 0;
                pvr2_i2c_core_sync(hdw);
                pvr2_trace(PVR2_TRACE_INFO,"cx2341x config:");
-               cx2341x_log_status(&hdw->enc_ctl_state,0);
+               cx2341x_log_status(&hdw->enc_ctl_state, "pvrusb2");
                printk(KERN_INFO "pvrusb2: ==================  END STATUS CARD #%d  ==================\n", nr);
        } while (0); LOCK_GIVE(hdw->big_lock);
 }
@@ -2424,7 +2430,7 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw, int enable_flag)
                        pvr2_trace(PVR2_TRACE_FIRMWARE,
                                   "Cleaning up after CPU firmware fetch");
                        kfree(hdw->fw_buffer);
-                       hdw->fw_buffer = 0;
+                       hdw->fw_buffer = NULL;
                        hdw->fw_size = 0;
                        /* Now release the CPU.  It will disconnect and
                           reconnect later. */
@@ -2519,22 +2525,6 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int v)
 }
 
 
-void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw)
-{
-       if (!hdw->usb_dev) return;
-       usb_settoggle(hdw->usb_dev, PVR2_CTL_WRITE_ENDPOINT & 0xf,
-                     !(PVR2_CTL_WRITE_ENDPOINT & USB_DIR_IN), 0);
-       usb_settoggle(hdw->usb_dev, PVR2_CTL_READ_ENDPOINT & 0xf,
-                     !(PVR2_CTL_READ_ENDPOINT & USB_DIR_IN), 0);
-       usb_clear_halt(hdw->usb_dev,
-                      usb_rcvbulkpipe(hdw->usb_dev,
-                                      PVR2_CTL_READ_ENDPOINT & 0x7f));
-       usb_clear_halt(hdw->usb_dev,
-                      usb_sndbulkpipe(hdw->usb_dev,
-                                      PVR2_CTL_WRITE_ENDPOINT & 0x7f));
-}
-
-
 static void pvr2_ctl_write_complete(struct urb *urb, struct pt_regs *regs)
 {
        struct pvr2_hdw *hdw = urb->context;
@@ -2568,10 +2558,14 @@ static void pvr2_ctl_timeout(unsigned long data)
 }
 
 
-int pvr2_send_request_ex(struct pvr2_hdw *hdw,
-                        unsigned int timeout,int probe_fl,
-                        void *write_data,unsigned int write_len,
-                        void *read_data,unsigned int read_len)
+/* Issue a command and get a response from the device.  This extended
+   version includes a probe flag (which if set means that device errors
+   should not be logged or treated as fatal) and a timeout in jiffies.
+   This can be used to non-lethally probe the health of endpoint 1. */
+static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
+                               unsigned int timeout,int probe_fl,
+                               void *write_data,unsigned int write_len,
+                               void *read_data,unsigned int read_len)
 {
        unsigned int idx;
        int status = 0;
@@ -2826,7 +2820,7 @@ int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data)
 }
 
 
-int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
+static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
 {
        int ret = 0;
 
@@ -2850,7 +2844,7 @@ int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
 }
 
 
-int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
+static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
 {
        int ret;
 
@@ -2867,7 +2861,7 @@ int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
 }
 
 
-int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
+static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
 {
        int ret;
 
@@ -2883,13 +2877,13 @@ int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
 }
 
 
-void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw)
+static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw)
 {
        if (!hdw->flag_ok) return;
        pvr2_trace(PVR2_TRACE_INIT,"render_useless");
        hdw->flag_ok = 0;
        if (hdw->vid_stream) {
-               pvr2_stream_setup(hdw->vid_stream,0,0,0);
+               pvr2_stream_setup(hdw->vid_stream,NULL,0,0);
        }
        hdw->flag_streaming_enabled = 0;
        hdw->subsys_enabled_mask = 0;
@@ -2908,7 +2902,7 @@ void pvr2_hdw_device_reset(struct pvr2_hdw *hdw)
 {
        int ret;
        pvr2_trace(PVR2_TRACE_INIT,"Performing a device reset...");
-       ret = usb_lock_device_for_reset(hdw->usb_dev,0);
+       ret = usb_lock_device_for_reset(hdw->usb_dev,NULL);
        if (ret == 1) {
                ret = usb_reset_device(hdw->usb_dev);
                usb_unlock_device(hdw->usb_dev);
@@ -2957,7 +2951,7 @@ int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw)
                pvr2_trace(PVR2_TRACE_INIT,"Requesting uproc hard reset");
                hdw->flag_ok = !0;
                hdw->cmd_buffer[0] = 0xdd;
-               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0);
+               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
        } while (0); LOCK_GIVE(hdw->ctl_lock);
        return status;
 }
@@ -2969,7 +2963,7 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw)
        LOCK_TAKE(hdw->ctl_lock); do {
                pvr2_trace(PVR2_TRACE_INIT,"Requesting powerup");
                hdw->cmd_buffer[0] = 0xde;
-               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0);
+               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
        } while (0); LOCK_GIVE(hdw->ctl_lock);
        return status;
 }
@@ -2996,12 +2990,13 @@ int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw)
 }
 
 
-int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
+/* Stop / start video stream transport */
+static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
 {
        int status;
        LOCK_TAKE(hdw->ctl_lock); do {
                hdw->cmd_buffer[0] = (runFl ? 0x36 : 0x37);
-               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0);
+               status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
        } while (0); LOCK_GIVE(hdw->ctl_lock);
        if (!status) {
                hdw->subsys_enabled_mask =
@@ -3094,7 +3089,8 @@ int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val)
 }
 
 
-int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
+/* Find I2C address of eeprom */
+static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
 {
        int result;
        LOCK_TAKE(hdw->ctl_lock); do {