]> err.no Git - linux-2.6/blobdiff - drivers/media/video/pvrusb2/pvrusb2-hdw.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux-2.6] / drivers / media / video / pvrusb2 / pvrusb2-hdw.c
index 4ffaf3faff5b32ce2f77c43aaca27c06bf7a871c..2404053a4d8585b5eda3f4822d9ad816e3c3f90a 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/firmware.h>
 #include <linux/videodev2.h>
 #include <media/v4l2-common.h>
-#include <asm/semaphore.h>
 #include "pvrusb2.h"
 #include "pvrusb2-std.h"
 #include "pvrusb2-util.h"
@@ -1093,7 +1092,10 @@ static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
 
        if (!hdw->hdw_desc->fx2_firmware.cnt) {
                hdw->fw1_state = FW1_STATE_OK;
-               return 0;
+               pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+                          "Connected device type defines"
+                          " no firmware to upload; ignoring firmware");
+               return -ENOTTY;
        }
 
        hdw->fw1_state = FW1_STATE_FAILED; // default result
@@ -1425,6 +1427,7 @@ static int get_default_tuner_type(struct pvr2_hdw *hdw)
        }
        if (tp < 0) return -EINVAL;
        hdw->tuner_type = tp;
+       hdw->tuner_updated = !0;
        return 0;
 }
 
@@ -1435,8 +1438,9 @@ static v4l2_std_id get_default_standard(struct pvr2_hdw *hdw)
        int tp = 0;
        if ((unit_number >= 0) && (unit_number < PVR_NUM)) {
                tp = video_std[unit_number];
+               if (tp) return tp;
        }
-       return tp;
+       return 0;
 }
 
 
@@ -1510,7 +1514,7 @@ const static struct pvr2_std_hack std_eeprom_maps[] = {
        },
        {       /* PAL(D/D1/K) */
                .pat = V4L2_STD_DK,
-               .std = V4L2_STD_PAL_D/V4L2_STD_PAL_D1|V4L2_STD_PAL_K,
+               .std = V4L2_STD_PAL_D|V4L2_STD_PAL_D1|V4L2_STD_PAL_K,
        },
 };
 
@@ -1518,18 +1522,20 @@ static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw)
 {
        char buf[40];
        unsigned int bcnt;
-       v4l2_std_id std1,std2;
+       v4l2_std_id std1,std2,std3;
 
        std1 = get_default_standard(hdw);
+       std3 = std1 ? 0 : hdw->hdw_desc->default_std_mask;
 
        bcnt = pvr2_std_id_to_str(buf,sizeof(buf),hdw->std_mask_eeprom);
        pvr2_trace(PVR2_TRACE_STD,
-                  "Supported video standard(s) reported by eeprom: %.*s",
+                  "Supported video standard(s) reported available"
+                  " in hardware: %.*s",
                   bcnt,buf);
 
        hdw->std_mask_avail = hdw->std_mask_eeprom;
 
-       std2 = std1 & ~hdw->std_mask_avail;
+       std2 = (std1|std3) & ~hdw->std_mask_avail;
        if (std2) {
                bcnt = pvr2_std_id_to_str(buf,sizeof(buf),std2);
                pvr2_trace(PVR2_TRACE_STD,
@@ -1551,6 +1557,16 @@ static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw)
                pvr2_hdw_internal_find_stdenum(hdw);
                return;
        }
+       if (std3) {
+               bcnt = pvr2_std_id_to_str(buf,sizeof(buf),std3);
+               pvr2_trace(PVR2_TRACE_STD,
+                          "Initial video standard"
+                          " (determined by device type): %.*s",bcnt,buf);
+               hdw->std_mask_cur = std3;
+               hdw->std_dirty = !0;
+               pvr2_hdw_internal_find_stdenum(hdw);
+               return;
+       }
 
        {
                unsigned int idx;
@@ -1665,15 +1681,22 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
        // thread-safe against the normal pvr2_send_request() mechanism.
        // (We should make it thread safe).
 
-       ret = pvr2_hdw_get_eeprom_addr(hdw);
-       if (!pvr2_hdw_dev_ok(hdw)) return;
-       if (ret < 0) {
-               pvr2_trace(PVR2_TRACE_ERROR_LEGS,
-                          "Unable to determine location of eeprom, skipping");
-       } else {
-               hdw->eeprom_addr = ret;
-               pvr2_eeprom_analyze(hdw);
+       if (hdw->hdw_desc->flag_has_hauppauge_rom) {
+               ret = pvr2_hdw_get_eeprom_addr(hdw);
                if (!pvr2_hdw_dev_ok(hdw)) return;
+               if (ret < 0) {
+                       pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+                                  "Unable to determine location of eeprom,"
+                                  " skipping");
+               } else {
+                       hdw->eeprom_addr = ret;
+                       pvr2_eeprom_analyze(hdw);
+                       if (!pvr2_hdw_dev_ok(hdw)) return;
+               }
+       } else {
+               hdw->tuner_type = hdw->hdw_desc->default_tuner_type;
+               hdw->tuner_updated = !0;
+               hdw->std_mask_eeprom = V4L2_STD_ALL;
        }
 
        pvr2_hdw_setup_std(hdw);
@@ -1684,7 +1707,6 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
                           hdw->tuner_type);
        }
 
-       hdw->tuner_updated = !0;
        pvr2_i2c_core_check_stale(hdw);
        hdw->tuner_updated = 0;
 
@@ -1790,7 +1812,6 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
 {
        unsigned int idx,cnt1,cnt2;
        struct pvr2_hdw *hdw;
-       unsigned int hdw_type;
        int valid_std_mask;
        struct pvr2_ctrl *cptr;
        const struct pvr2_device_desc *hdw_desc;
@@ -1798,13 +1819,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
        struct v4l2_queryctrl qctrl;
        struct pvr2_ctl_info *ciptr;
 
-       hdw_type = devid - pvr2_device_table;
-       if (hdw_type >= pvr2_device_count) {
-               pvr2_trace(PVR2_TRACE_ERROR_LEGS,
-                          "Bogus device type of %u reported",hdw_type);
-               return NULL;
-       }
-       hdw_desc = pvr2_device_descriptions + hdw_type;
+       hdw_desc = (const struct pvr2_device_desc *)(devid->driver_info);
 
        hdw = kzalloc(sizeof(*hdw),GFP_KERNEL);
        pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_create: hdw=%p, type \"%s\"",
@@ -2275,7 +2290,7 @@ static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw)
 
        for (idx = 0; idx < hdw->control_cnt; idx++) {
                cptr = hdw->controls + idx;
-               if (cptr->info->is_dirty == 0) continue;
+               if (!cptr->info->is_dirty) continue;
                if (!cptr->info->is_dirty(cptr)) continue;
                commit_flag = !0;
 
@@ -2630,7 +2645,7 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw,
        u16 address;
        unsigned int pipe;
        LOCK_TAKE(hdw->big_lock); do {
-               if ((hdw->fw_buffer == 0) == !enable_flag) break;
+               if ((hdw->fw_buffer == NULL) == !enable_flag) break;
 
                if (!enable_flag) {
                        pvr2_trace(PVR2_TRACE_FIRMWARE,
@@ -2699,7 +2714,7 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw,
 /* Return true if we're in a mode for retrieval CPU firmware */
 int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw)
 {
-       return hdw->fw_buffer != 0;
+       return hdw->fw_buffer != NULL;
 }