diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-02-27 20:06:09 +0100 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2007-02-27 20:06:09 +0100 |
commit | ef5e52021856647afdbf2f88b5564cb22250290b (patch) | |
tree | 066a0a5ba8a5e5051ce91868dc830c39ceab7624 /linux/drivers/media | |
parent | 89332c1ec9b859922645e86f2fef316ebdc3ff28 (diff) | |
download | mediapointer-dvb-s2-ef5e52021856647afdbf2f88b5564cb22250290b.tar.gz mediapointer-dvb-s2-ef5e52021856647afdbf2f88b5564cb22250290b.tar.bz2 |
Improve VIDIOC_G_CHIP_IDENT (better diagnostics)
From: Hans Verkuil <hverkuil@xs4all.nl>
Simplify the VIDIOC_G_CHIP_IDENT implementation by adding a single
common function. The ident can now also return NONE: not found, UNKNOWN:
found, but we don't know what chip it is, and AMBIGUOUS: multiple
chips were matched so the match values were too general.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'linux/drivers/media')
-rw-r--r-- | linux/drivers/media/video/cx25840/cx25840-core.c | 10 | ||||
-rw-r--r-- | linux/drivers/media/video/ov7670.c | 10 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7115.c | 10 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7127.c | 10 | ||||
-rw-r--r-- | linux/drivers/media/video/v4l2-common.c | 18 |
5 files changed, 22 insertions, 36 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); /* |