]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/v4l2-common.c
V4L/DVB (10445): cx18: Process Raw VBI on a whole frame basis; fix VBI buffer size
[linux-2.6-omap-h63xx.git] / drivers / media / video / v4l2-common.c
index c676b0b0f708340f7644f69d3b6ceaab29fd8eea..26e162f13f7f58e209d76d5b563062d05deea303 100644 (file)
@@ -555,7 +555,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste
        qctrl->step = step;
        qctrl->default_value = def;
        qctrl->reserved[0] = qctrl->reserved[1] = 0;
-       snprintf(qctrl->name, sizeof(qctrl->name), name);
+       strlcpy(qctrl->name, name, sizeof(qctrl->name));
        return 0;
 }
 EXPORT_SYMBOL(v4l2_ctrl_query_fill);
@@ -720,7 +720,7 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc
        for (i = 0; i < qmenu->index && menu_items[i]; i++) ;
        if (menu_items[i] == NULL || menu_items[i][0] == '\0')
                return -EINVAL;
-       snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]);
+       strlcpy(qmenu->name, menu_items[qmenu->index], sizeof(qmenu->name));
        return 0;
 }
 EXPORT_SYMBOL(v4l2_ctrl_query_menu);
@@ -737,8 +737,8 @@ int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *id
                return -EINVAL;
        while (*ids != V4L2_CTRL_MENU_IDS_END) {
                if (*ids++ == qmenu->index) {
-                       snprintf(qmenu->name, sizeof(qmenu->name),
-                                      menu_items[qmenu->index]);
+                       strlcpy(qmenu->name, menu_items[qmenu->index],
+                                       sizeof(qmenu->name));
                        return 0;
                }
        }
@@ -797,11 +797,11 @@ u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id)
 }
 EXPORT_SYMBOL(v4l2_ctrl_next);
 
-int v4l2_chip_match_host(u32 match_type, u32 match_chip)
+int v4l2_chip_match_host(const struct v4l2_dbg_match *match)
 {
-       switch (match_type) {
+       switch (match->type) {
        case V4L2_CHIP_MATCH_HOST:
-               return match_chip == 0;
+               return match->addr == 0;
        default:
                return 0;
        }
@@ -809,23 +809,34 @@ int v4l2_chip_match_host(u32 match_type, u32 match_chip)
 EXPORT_SYMBOL(v4l2_chip_match_host);
 
 #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE))
-int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_chip)
+int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match *match)
 {
-       switch (match_type) {
+       int len;
+
+       if (c == NULL || match == NULL)
+               return 0;
+
+       switch (match->type) {
        case V4L2_CHIP_MATCH_I2C_DRIVER:
-               return (c != NULL && c->driver != NULL && c->driver->id == match_chip);
+               if (c->driver == NULL || c->driver->driver.name == NULL)
+                       return 0;
+               len = strlen(c->driver->driver.name);
+               /* legacy drivers have a ' suffix, don't try to match that */
+               if (len && c->driver->driver.name[len - 1] == '\'')
+                       len--;
+               return len && !strncmp(c->driver->driver.name, match->name, len);
        case V4L2_CHIP_MATCH_I2C_ADDR:
-               return (c != NULL && c->addr == match_chip);
+               return c->addr == match->addr;
        default:
                return 0;
        }
 }
 EXPORT_SYMBOL(v4l2_chip_match_i2c_client);
 
-int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip,
+int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_dbg_chip_ident *chip,
                u32 ident, u32 revision)
 {
-       if (!v4l2_chip_match_i2c_client(c, chip->match_type, chip->match_chip))
+       if (!v4l2_chip_match_i2c_client(c, &chip->match))
                return 0;
        if (chip->ident == V4L2_IDENT_NONE) {
                chip->ident = ident;
@@ -980,4 +991,40 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
 }
 EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev);
 
+/* Return a list of I2C tuner addresses to probe. Use only if the tuner
+   addresses are unknown. */
+const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type)
+{
+       static const unsigned short radio_addrs[] = {
+#if defined(CONFIG_MEDIA_TUNER_TEA5761) || defined(CONFIG_MEDIA_TUNER_TEA5761_MODULE)
+               0x10,
+#endif
+               0x60,
+               I2C_CLIENT_END
+       };
+       static const unsigned short demod_addrs[] = {
+               0x42, 0x43, 0x4a, 0x4b,
+               I2C_CLIENT_END
+       };
+       static const unsigned short tv_addrs[] = {
+               0x42, 0x43, 0x4a, 0x4b,         /* tda8290 */
+               0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+               0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+               I2C_CLIENT_END
+       };
+
+       switch (type) {
+       case ADDRS_RADIO:
+               return radio_addrs;
+       case ADDRS_DEMOD:
+               return demod_addrs;
+       case ADDRS_TV:
+               return tv_addrs;
+       case ADDRS_TV_WITH_DEMOD:
+               return tv_addrs + 4;
+       }
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(v4l2_i2c_tuner_addrs);
+
 #endif