]> Pileus Git - ~andy/linux/blobdiff - drivers/media/video/pvrusb2/pvrusb2-hdw.c
V4L/DVB (11189): pvrusb2: Deal with space-after-comma coding style idiocy
[~andy/linux] / drivers / media / video / pvrusb2 / pvrusb2-hdw.c
index ff7af062002b3db8c3ce454154691dd8d654559e..029cdf411df00808e606ad938363265a059df029 100644 (file)
@@ -38,6 +38,7 @@
 #include "pvrusb2-fx2-cmd.h"
 #include "pvrusb2-wm8775.h"
 #include "pvrusb2-video-v4l.h"
+#include "pvrusb2-cx2584x-v4l.h"
 #include "pvrusb2-audio.h"
 
 #define TV_MIN_FREQ     55250000L
@@ -115,6 +116,7 @@ static const pvr2_subdev_update_func pvr2_module_update_functions[] = {
        [PVR2_CLIENT_ID_WM8775] = pvr2_wm8775_subdev_update,
        [PVR2_CLIENT_ID_SAA7115] = pvr2_saa7115_subdev_update,
        [PVR2_CLIENT_ID_MSP3400] = pvr2_msp3400_subdev_update,
+       [PVR2_CLIENT_ID_CX25840] = pvr2_cx25840_subdev_update,
 };
 
 static const char *module_names[] = {
@@ -129,6 +131,7 @@ static const char *module_names[] = {
 
 static const unsigned char *module_i2c_addresses[] = {
        [PVR2_CLIENT_ID_TUNER] = "\x60\x61\x62\x63",
+       [PVR2_CLIENT_ID_WM8775] = "\x1b",
 };
 
 
@@ -1976,7 +1979,7 @@ static unsigned int pvr2_copy_i2c_addr_list(
        unsigned short *dst, const unsigned char *src,
        unsigned int dst_max)
 {
-       unsigned int cnt;
+       unsigned int cnt = 0;
        if (!src) return 0;
        while (src[cnt] && (cnt + 1) < dst_max) {
                dst[cnt] = src[cnt];
@@ -2007,6 +2010,10 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
                           hdw->hdw_desc->description);
                return -EINVAL;
        }
+       pvr2_trace(PVR2_TRACE_INIT,
+                  "Module ID %u (%s) for device %s being loaded...",
+                  mid, fname,
+                  hdw->hdw_desc->description);
 
        i2ccnt = pvr2_copy_i2c_addr_list(i2caddr, cd->i2c_address_list,
                                         ARRAY_SIZE(i2caddr));
@@ -2015,6 +2022,12 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
                /* Second chance: Try default i2c address list */
                i2ccnt = pvr2_copy_i2c_addr_list(i2caddr, p,
                                                 ARRAY_SIZE(i2caddr));
+               if (i2ccnt) {
+                       pvr2_trace(PVR2_TRACE_INIT,
+                                  "Module ID %u:"
+                                  " Using default i2c address list",
+                                  mid);
+               }
        }
 
        if (!i2ccnt) {
@@ -2032,15 +2045,25 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
         * and every other place where I can find examples of this, the
         * "chipid" appears to just be the module name again.  So here we
         * just do the same thing. */
+       hdw->i2c_adap.class = 0;
        if (i2ccnt == 1) {
+               pvr2_trace(PVR2_TRACE_INIT,
+                          "Module ID %u:"
+                          " Setting up with specified i2c address 0x%x",
+                          mid, i2caddr[0]);
                sd = v4l2_i2c_new_subdev(&hdw->i2c_adap,
                                         fname, fname,
                                         i2caddr[0]);
        } else {
+               pvr2_trace(PVR2_TRACE_INIT,
+                          "Module ID %u:"
+                          " Setting up with address probe list",
+                          mid);
                sd = v4l2_i2c_new_probed_subdev(&hdw->i2c_adap,
                                                fname, fname,
                                                i2caddr);
        }
+       hdw->i2c_adap.class = I2C_CLASS_TV_ANALOG;
 
        if (!sd) {
                pvr2_trace(PVR2_TRACE_ERROR_LEGS,
@@ -2059,7 +2082,7 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
           aid, in normal situations there's no reason for both mechanisms
           to be enabled. */
        pvr2_i2c_untrack_subdev(hdw, sd);
-       pvr2_trace(PVR2_TRACE_INIT, "Attached sub-driver %s", fname);
+       pvr2_trace(PVR2_TRACE_INFO, "Attached sub-driver %s", fname);
 
 
        /* client-specific setup... */
@@ -2079,6 +2102,10 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
                          up.
                        */
                        struct v4l2_format fmt;
+                       pvr2_trace(PVR2_TRACE_INIT,
+                                  "Module ID %u:"
+                                  " Executing cx25840 VBI hack",
+                                  mid);
                        memset(&fmt, 0, sizeof(fmt));
                        fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
                        v4l2_device_call_all(&hdw->v4l2_dev, mid,
@@ -2109,7 +2136,7 @@ static void pvr2_hdw_load_modules(struct pvr2_hdw *hdw)
 
        ct = &hdw->hdw_desc->client_table;
        for (idx = 0; idx < ct->cnt; idx++) {
-               if (!pvr2_hdw_load_subdev(hdw, &ct->lst[idx])) okFl = 0;
+               if (pvr2_hdw_load_subdev(hdw, &ct->lst[idx]) < 0) okFl = 0;
        }
        if (!okFl) pvr2_hdw_render_useless(hdw);
 }
@@ -2918,7 +2945,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw)
        pvr2_subdev_update_func fp;
 
        if (hdw->input_dirty || hdw->std_dirty) {
-               pvr2_trace(PVR2_TRACE_CHIPS,"subdev v4l2 set_standard");
+               pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_standard");
                if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) {
                        v4l2_device_call_all(&hdw->v4l2_dev, 0,
                                             tuner, s_radio);
@@ -3211,15 +3238,15 @@ static int pvr2_hdw_commit_execute(struct pvr2_hdw *hdw)
                }
        }
 
+       /* Check and update state for all sub-devices. */
+       pvr2_subdev_update(hdw);
+
        for (idx = 0; idx < hdw->control_cnt; idx++) {
                cptr = hdw->controls + idx;
                if (!cptr->info->clear_dirty) continue;
                cptr->info->clear_dirty(cptr);
        }
 
-       /* Check and update state for all sub-devices. */
-       pvr2_subdev_update(hdw);
-
        /* Now execute i2c core update */
        pvr2_i2c_core_sync(hdw);
 
@@ -4830,7 +4857,7 @@ static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which,
                unsigned int id;
                ccnt = scnprintf(buf,
                                 acnt,
-                                "Associted v4l2_subdev drivers:");
+                                "Associated v4l2_subdev drivers:");
                tcnt += ccnt;
                v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) {
                        id = sd->grp_id;
@@ -4838,10 +4865,16 @@ static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which,
                        if (id < ARRAY_SIZE(module_names)) {
                                p = module_names[id];
                        }
-                       if (!p) p = "(unknown)";
-                       ccnt = scnprintf(buf + tcnt,
-                                        acnt - tcnt,
-                                        " %s (%u)", p, id);
+                       if (p) {
+                               ccnt = scnprintf(buf + tcnt,
+                                                acnt - tcnt,
+                                                " %s", p);
+                       } else {
+                               ccnt = scnprintf(buf + tcnt,
+                                                acnt - tcnt,
+                                                " (unknown id=%u)", id);
+                       }
+                       tcnt += ccnt;
                }
                return tcnt;
        }