summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux/drivers/media/video/cx25840/cx25840-core.c10
-rw-r--r--linux/drivers/media/video/ov7670.c10
-rw-r--r--linux/drivers/media/video/saa7115.c10
-rw-r--r--linux/drivers/media/video/saa7127.c10
-rw-r--r--linux/drivers/media/video/v4l2-common.c18
-rw-r--r--linux/include/media/v4l2-chip-ident.h4
-rw-r--r--linux/include/media/v4l2-common.h2
7 files changed, 27 insertions, 37 deletions
diff --git a/linux/drivers/media/video/cx25840/cx25840-core.c b/linux/drivers/media/video/cx25840/cx25840-core.c
index d5a0789bc..c401c1ee7 100644
--- a/linux/drivers/media/video/cx25840/cx25840-core.c
+++ b/linux/drivers/media/video/cx25840/cx25840-core.c
@@ -840,15 +840,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
break;
case VIDIOC_G_CHIP_IDENT:
- {
- struct v4l2_chip_ident *chip = arg;
-
- if (!v4l2_chip_match_i2c_client(client, chip->match_type, chip->match_chip))
- return -EINVAL;
- chip->ident = state->id;
- chip->revision = state->rev;
- break;
- }
+ return v4l2_chip_ident_i2c_client(client, arg, state->id, state->rev);
default:
return -EINVAL;
diff --git a/linux/drivers/media/video/ov7670.c b/linux/drivers/media/video/ov7670.c
index d68f36851..b033bf334 100644
--- a/linux/drivers/media/video/ov7670.c
+++ b/linux/drivers/media/video/ov7670.c
@@ -1316,15 +1316,7 @@ static int ov7670_command(struct i2c_client *client, unsigned int cmd,
{
switch (cmd) {
case VIDIOC_G_CHIP_IDENT:
- {
- struct v4l2_chip_ident *chip = arg;
-
- if (!v4l2_chip_match_i2c_client(client, chip->match_type, chip->match_chip))
- return -EINVAL;
- chip->ident = V4L2_IDENT_OV7670;
- chip->revision = 0;
- return 0;
- }
+ return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_OV7670, 0);
case VIDIOC_INT_RESET:
ov7670_reset(client);
diff --git a/linux/drivers/media/video/saa7115.c b/linux/drivers/media/video/saa7115.c
index 8b4abb3a1..064a81334 100644
--- a/linux/drivers/media/video/saa7115.c
+++ b/linux/drivers/media/video/saa7115.c
@@ -1449,15 +1449,7 @@ static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *ar
#endif
case VIDIOC_G_CHIP_IDENT:
- {
- struct v4l2_chip_ident *chip = arg;
-
- if (!v4l2_chip_match_i2c_client(client, chip->match_type, chip->match_chip))
- return -EINVAL;
- chip->ident = state->ident;
- chip->revision = 0;
- break;
- }
+ return v4l2_chip_ident_i2c_client(client, arg, state->ident, 0);
default:
return -EINVAL;
diff --git a/linux/drivers/media/video/saa7127.c b/linux/drivers/media/video/saa7127.c
index 28306f15d..185eb7e9d 100644
--- a/linux/drivers/media/video/saa7127.c
+++ b/linux/drivers/media/video/saa7127.c
@@ -664,15 +664,7 @@ static int saa7127_command(struct i2c_client *client,
}
case VIDIOC_G_CHIP_IDENT:
- {
- struct v4l2_chip_ident *chip = arg;
-
- if (!v4l2_chip_match_i2c_client(client, chip->match_type, chip->match_chip))
- return -EINVAL;
- chip->ident = state->ident;
- chip->revision = 0;
- break;
- }
+ return v4l2_chip_ident_i2c_client(client, arg, state->ident, 0);
default:
return -EINVAL;
diff --git a/linux/drivers/media/video/v4l2-common.c b/linux/drivers/media/video/v4l2-common.c
index 60c56a8b0..0a45e19cb 100644
--- a/linux/drivers/media/video/v4l2-common.c
+++ b/linux/drivers/media/video/v4l2-common.c
@@ -60,6 +60,7 @@
#include <linux/video_decoder.h>
#define __OLD_VIDIOC_ /* To allow fixing old calls*/
#include <media/v4l2-common.h>
+#include <media/v4l2-chip-ident.h>
#ifdef CONFIG_KMOD
#include <linux/kmod.h>
@@ -1605,6 +1606,22 @@ int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_c
}
}
+int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip,
+ u32 ident, u32 revision)
+{
+ if (!v4l2_chip_match_i2c_client(c, chip->match_type, chip->match_chip))
+ return 0;
+ if (chip->ident == V4L2_IDENT_NONE) {
+ chip->ident = ident;
+ chip->revision = revision;
+ }
+ else {
+ chip->ident = V4L2_IDENT_AMBIGUOUS;
+ chip->revision = 0;
+ }
+ return 0;
+}
+
int v4l2_chip_match_host(u32 match_type, u32 match_chip)
{
switch (match_type) {
@@ -1639,6 +1656,7 @@ EXPORT_SYMBOL(v4l2_ctrl_query_fill);
EXPORT_SYMBOL(v4l2_ctrl_query_fill_std);
EXPORT_SYMBOL(v4l2_chip_match_i2c_client);
+EXPORT_SYMBOL(v4l2_chip_ident_i2c_client);
EXPORT_SYMBOL(v4l2_chip_match_host);
/*
diff --git a/linux/include/media/v4l2-chip-ident.h b/linux/include/media/v4l2-chip-ident.h
index 5698fcd1d..7d0c65413 100644
--- a/linux/include/media/v4l2-chip-ident.h
+++ b/linux/include/media/v4l2-chip-ident.h
@@ -27,7 +27,9 @@
/* VIDIOC_G_CHIP_IDENT: identifies the actual chip installed on the board */
enum {
/* general idents: reserved range 0-49 */
- V4L2_IDENT_UNKNOWN = 0,
+ V4L2_IDENT_NONE = 0, /* No chip matched */
+ V4L2_IDENT_AMBIGUOUS = 1, /* Match too general, multiple chips matched */
+ V4L2_IDENT_UNKNOWN = 2, /* Chip found, but cannot identify */
/* module saa7110: just ident= 100 */
V4L2_IDENT_SAA7110 = 100,
diff --git a/linux/include/media/v4l2-common.h b/linux/include/media/v4l2-common.h
index cc2ab055a..579835f92 100644
--- a/linux/include/media/v4l2-common.h
+++ b/linux/include/media/v4l2-common.h
@@ -104,6 +104,8 @@ u32 v4l2_ctrl_next(const u32 * const *ctrl_classes, u32 id);
struct i2c_client; /* forward reference */
int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 id_type, u32 chip_id);
+int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip,
+ u32 ident, u32 revision);
int v4l2_chip_match_host(u32 id_type, u32 chip_id);
/* ------------------------------------------------------------------------- */