diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-04-27 11:31:08 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:43:27 -0400 |
commit | 3434eb7e14d9587ee56f3462bcfa5726b62dadb9 (patch) | |
tree | 49afb0915dac8e7864f89582ddbb7a6453982e2c /drivers/media/video | |
parent | ced80c67cd1ed503c6fb72f02ac7342ab4ebf67a (diff) |
V4L/DVB (5306): Add support for VIDIOC_G_CHIP_IDENT
VIDIOC_G_CHIP_IDENT improves debugging of card problems: it can be
used to detect which chips are on the board and based on that information
selected register dumps can be made, making it easy to debug complicated
media chips containing tens or hundreds of registers.
This ioctl replaces the internal VIDIOC_INT_G_CHIP_IDENT ioctl.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/cafe_ccic.c | 8 | ||||
-rw-r--r-- | drivers/media/video/cx25840/cx25840-core.c | 9 | ||||
-rw-r--r-- | drivers/media/video/cx25840/cx25840-core.h | 3 | ||||
-rw-r--r-- | drivers/media/video/ov7670.c | 6 | ||||
-rw-r--r-- | drivers/media/video/saa7115.c | 9 | ||||
-rw-r--r-- | drivers/media/video/saa7127.c | 8 | ||||
-rw-r--r-- | drivers/media/video/v4l2-common.c | 21 | ||||
-rw-r--r-- | drivers/media/video/videodev.c | 10 |
8 files changed, 54 insertions, 20 deletions
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c index 710c11a68296..4d4db7b2b611 100644 --- a/drivers/media/video/cafe_ccic.c +++ b/drivers/media/video/cafe_ccic.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/spinlock.h> | 22 | #include <linux/spinlock.h> |
23 | #include <linux/videodev2.h> | 23 | #include <linux/videodev2.h> |
24 | #include <media/v4l2-common.h> | 24 | #include <media/v4l2-common.h> |
25 | #include <media/v4l2-chip-ident.h> | ||
25 | #include <linux/device.h> | 26 | #include <linux/device.h> |
26 | #include <linux/wait.h> | 27 | #include <linux/wait.h> |
27 | #include <linux/list.h> | 28 | #include <linux/list.h> |
@@ -164,7 +165,7 @@ struct cafe_camera | |||
164 | struct tasklet_struct s_tasklet; | 165 | struct tasklet_struct s_tasklet; |
165 | 166 | ||
166 | /* Current operating parameters */ | 167 | /* Current operating parameters */ |
167 | enum v4l2_chip_ident sensor_type; /* Currently ov7670 only */ | 168 | u32 sensor_type; /* Currently ov7670 only */ |
168 | struct v4l2_pix_format pix_format; | 169 | struct v4l2_pix_format pix_format; |
169 | 170 | ||
170 | /* Locks */ | 171 | /* Locks */ |
@@ -818,6 +819,7 @@ static int __cafe_cam_reset(struct cafe_camera *cam) | |||
818 | */ | 819 | */ |
819 | static int cafe_cam_init(struct cafe_camera *cam) | 820 | static int cafe_cam_init(struct cafe_camera *cam) |
820 | { | 821 | { |
822 | struct v4l2_chip_ident chip = { V4L2_CHIP_MATCH_I2C_ADDR, 0, 0, 0 }; | ||
821 | int ret; | 823 | int ret; |
822 | 824 | ||
823 | mutex_lock(&cam->s_mutex); | 825 | mutex_lock(&cam->s_mutex); |
@@ -827,9 +829,11 @@ static int cafe_cam_init(struct cafe_camera *cam) | |||
827 | ret = __cafe_cam_reset(cam); | 829 | ret = __cafe_cam_reset(cam); |
828 | if (ret) | 830 | if (ret) |
829 | goto out; | 831 | goto out; |
830 | ret = __cafe_cam_cmd(cam, VIDIOC_INT_G_CHIP_IDENT, &cam->sensor_type); | 832 | chip.match_chip = cam->sensor->addr; |
833 | ret = __cafe_cam_cmd(cam, VIDIOC_G_CHIP_IDENT, &chip); | ||
831 | if (ret) | 834 | if (ret) |
832 | goto out; | 835 | goto out; |
836 | cam->sensor_type = chip.ident; | ||
833 | // if (cam->sensor->addr != OV7xx0_SID) { | 837 | // if (cam->sensor->addr != OV7xx0_SID) { |
834 | if (cam->sensor_type != V4L2_IDENT_OV7670) { | 838 | if (cam->sensor_type != V4L2_IDENT_OV7670) { |
835 | cam_err(cam, "Unsupported sensor type %d", cam->sensor->addr); | 839 | cam_err(cam, "Unsupported sensor type %d", cam->sensor->addr); |
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 774d2536555b..1757a588970f 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/videodev2.h> | 35 | #include <linux/videodev2.h> |
36 | #include <linux/i2c.h> | 36 | #include <linux/i2c.h> |
37 | #include <media/v4l2-common.h> | 37 | #include <media/v4l2-common.h> |
38 | #include <media/v4l2-chip-ident.h> | ||
38 | #include <media/cx25840.h> | 39 | #include <media/cx25840.h> |
39 | 40 | ||
40 | #include "cx25840-core.h" | 41 | #include "cx25840-core.h" |
@@ -827,9 +828,8 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd, | |||
827 | cx25840_initialize(client, 0); | 828 | cx25840_initialize(client, 0); |
828 | break; | 829 | break; |
829 | 830 | ||
830 | case VIDIOC_INT_G_CHIP_IDENT: | 831 | case VIDIOC_G_CHIP_IDENT: |
831 | *(enum v4l2_chip_ident *)arg = state->id; | 832 | return v4l2_chip_ident_i2c_client(client, arg, state->id, state->rev); |
832 | break; | ||
833 | 833 | ||
834 | default: | 834 | default: |
835 | return -EINVAL; | 835 | return -EINVAL; |
@@ -847,7 +847,7 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address, | |||
847 | { | 847 | { |
848 | struct i2c_client *client; | 848 | struct i2c_client *client; |
849 | struct cx25840_state *state; | 849 | struct cx25840_state *state; |
850 | enum v4l2_chip_ident id; | 850 | u32 id; |
851 | u16 device_id; | 851 | u16 device_id; |
852 | 852 | ||
853 | /* Check if the adapter supports the needed features | 853 | /* Check if the adapter supports the needed features |
@@ -902,6 +902,7 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address, | |||
902 | state->audmode = V4L2_TUNER_MODE_LANG1; | 902 | state->audmode = V4L2_TUNER_MODE_LANG1; |
903 | state->vbi_line_offset = 8; | 903 | state->vbi_line_offset = 8; |
904 | state->id = id; | 904 | state->id = id; |
905 | state->rev = device_id; | ||
905 | 906 | ||
906 | i2c_attach_client(client); | 907 | i2c_attach_client(client); |
907 | 908 | ||
diff --git a/drivers/media/video/cx25840/cx25840-core.h b/drivers/media/video/cx25840/cx25840-core.h index 28049064dd7d..f4b56d2fd6b6 100644 --- a/drivers/media/video/cx25840/cx25840-core.h +++ b/drivers/media/video/cx25840/cx25840-core.h | |||
@@ -43,7 +43,8 @@ struct cx25840_state { | |||
43 | u32 audclk_freq; | 43 | u32 audclk_freq; |
44 | int audmode; | 44 | int audmode; |
45 | int vbi_line_offset; | 45 | int vbi_line_offset; |
46 | enum v4l2_chip_ident id; | 46 | u32 id; |
47 | u32 rev; | ||
47 | int is_cx25836; | 48 | int is_cx25836; |
48 | }; | 49 | }; |
49 | 50 | ||
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c index 5ed0adc4ca26..5234762c5427 100644 --- a/drivers/media/video/ov7670.c +++ b/drivers/media/video/ov7670.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/videodev.h> | 16 | #include <linux/videodev.h> |
17 | #include <media/v4l2-common.h> | 17 | #include <media/v4l2-common.h> |
18 | #include <media/v4l2-chip-ident.h> | ||
18 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
19 | 20 | ||
20 | 21 | ||
@@ -1270,9 +1271,8 @@ static int ov7670_command(struct i2c_client *client, unsigned int cmd, | |||
1270 | void *arg) | 1271 | void *arg) |
1271 | { | 1272 | { |
1272 | switch (cmd) { | 1273 | switch (cmd) { |
1273 | case VIDIOC_INT_G_CHIP_IDENT: | 1274 | case VIDIOC_G_CHIP_IDENT: |
1274 | * (enum v4l2_chip_ident *) arg = V4L2_IDENT_OV7670; | 1275 | return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_OV7670, 0); |
1275 | return 0; | ||
1276 | 1276 | ||
1277 | case VIDIOC_INT_RESET: | 1277 | case VIDIOC_INT_RESET: |
1278 | ov7670_reset(client); | 1278 | ov7670_reset(client); |
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index 4d5bbd859de1..26c9b64c748c 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/i2c.h> | 45 | #include <linux/i2c.h> |
46 | #include <linux/videodev2.h> | 46 | #include <linux/videodev2.h> |
47 | #include <media/v4l2-common.h> | 47 | #include <media/v4l2-common.h> |
48 | #include <media/v4l2-chip-ident.h> | ||
48 | #include <media/saa7115.h> | 49 | #include <media/saa7115.h> |
49 | #include <asm/div64.h> | 50 | #include <asm/div64.h> |
50 | 51 | ||
@@ -80,7 +81,7 @@ struct saa711x_state { | |||
80 | int sat; | 81 | int sat; |
81 | int width; | 82 | int width; |
82 | int height; | 83 | int height; |
83 | enum v4l2_chip_ident ident; | 84 | u32 ident; |
84 | u32 audclk_freq; | 85 | u32 audclk_freq; |
85 | u32 crystal_freq; | 86 | u32 crystal_freq; |
86 | u8 ucgc; | 87 | u8 ucgc; |
@@ -1232,7 +1233,6 @@ static void saa711x_decode_vbi_line(struct i2c_client *client, | |||
1232 | static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *arg) | 1233 | static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *arg) |
1233 | { | 1234 | { |
1234 | struct saa711x_state *state = i2c_get_clientdata(client); | 1235 | struct saa711x_state *state = i2c_get_clientdata(client); |
1235 | int *iarg = arg; | ||
1236 | 1236 | ||
1237 | /* ioctls to allow direct access to the saa7115 registers for testing */ | 1237 | /* ioctls to allow direct access to the saa7115 registers for testing */ |
1238 | switch (cmd) { | 1238 | switch (cmd) { |
@@ -1437,9 +1437,8 @@ static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *ar | |||
1437 | } | 1437 | } |
1438 | #endif | 1438 | #endif |
1439 | 1439 | ||
1440 | case VIDIOC_INT_G_CHIP_IDENT: | 1440 | case VIDIOC_G_CHIP_IDENT: |
1441 | *iarg = state->ident; | 1441 | return v4l2_chip_ident_i2c_client(client, arg, state->ident, 0); |
1442 | break; | ||
1443 | 1442 | ||
1444 | default: | 1443 | default: |
1445 | return -EINVAL; | 1444 | return -EINVAL; |
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c index 50dbb76d4a7f..9f986930490f 100644 --- a/drivers/media/video/saa7127.c +++ b/drivers/media/video/saa7127.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/i2c.h> | 54 | #include <linux/i2c.h> |
55 | #include <linux/videodev2.h> | 55 | #include <linux/videodev2.h> |
56 | #include <media/v4l2-common.h> | 56 | #include <media/v4l2-common.h> |
57 | #include <media/v4l2-chip-ident.h> | ||
57 | #include <media/saa7127.h> | 58 | #include <media/saa7127.h> |
58 | 59 | ||
59 | static int debug = 0; | 60 | static int debug = 0; |
@@ -234,7 +235,7 @@ static struct i2c_reg_value saa7127_init_config_50hz[] = { | |||
234 | 235 | ||
235 | struct saa7127_state { | 236 | struct saa7127_state { |
236 | v4l2_std_id std; | 237 | v4l2_std_id std; |
237 | enum v4l2_chip_ident ident; | 238 | u32 ident; |
238 | enum saa7127_input_type input_type; | 239 | enum saa7127_input_type input_type; |
239 | enum saa7127_output_type output_type; | 240 | enum saa7127_output_type output_type; |
240 | int video_enable; | 241 | int video_enable; |
@@ -650,9 +651,8 @@ static int saa7127_command(struct i2c_client *client, | |||
650 | break; | 651 | break; |
651 | } | 652 | } |
652 | 653 | ||
653 | case VIDIOC_INT_G_CHIP_IDENT: | 654 | case VIDIOC_G_CHIP_IDENT: |
654 | *(enum v4l2_chip_ident *)arg = state->ident; | 655 | return v4l2_chip_ident_i2c_client(client, arg, state->ident, 0); |
655 | break; | ||
656 | 656 | ||
657 | default: | 657 | default: |
658 | return -EINVAL; | 658 | return -EINVAL; |
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 4a3635cd6f9e..49f1df74aa21 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/video_decoder.h> | 60 | #include <linux/video_decoder.h> |
61 | #define __OLD_VIDIOC_ /* To allow fixing old calls*/ | 61 | #define __OLD_VIDIOC_ /* To allow fixing old calls*/ |
62 | #include <media/v4l2-common.h> | 62 | #include <media/v4l2-common.h> |
63 | #include <media/v4l2-chip-ident.h> | ||
63 | 64 | ||
64 | #ifdef CONFIG_KMOD | 65 | #ifdef CONFIG_KMOD |
65 | #include <linux/kmod.h> | 66 | #include <linux/kmod.h> |
@@ -383,6 +384,8 @@ static const char *v4l2_ioctls[] = { | |||
383 | 384 | ||
384 | [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", | 385 | [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", |
385 | [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", | 386 | [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", |
387 | |||
388 | [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT", | ||
386 | #endif | 389 | #endif |
387 | }; | 390 | }; |
388 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | 391 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) |
@@ -413,7 +416,6 @@ static const char *v4l2_int_ioctls[] = { | |||
413 | [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE", | 416 | [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE", |
414 | [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA", | 417 | [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA", |
415 | [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA", | 418 | [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA", |
416 | [_IOC_NR(VIDIOC_INT_G_CHIP_IDENT)] = "VIDIOC_INT_G_CHIP_IDENT", | ||
417 | [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ", | 419 | [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ", |
418 | [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY", | 420 | [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY", |
419 | [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING", | 421 | [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING", |
@@ -981,6 +983,22 @@ int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_c | |||
981 | } | 983 | } |
982 | } | 984 | } |
983 | 985 | ||
986 | int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip, | ||
987 | u32 ident, u32 revision) | ||
988 | { | ||
989 | if (!v4l2_chip_match_i2c_client(c, chip->match_type, chip->match_chip)) | ||
990 | return 0; | ||
991 | if (chip->ident == V4L2_IDENT_NONE) { | ||
992 | chip->ident = ident; | ||
993 | chip->revision = revision; | ||
994 | } | ||
995 | else { | ||
996 | chip->ident = V4L2_IDENT_AMBIGUOUS; | ||
997 | chip->revision = 0; | ||
998 | } | ||
999 | return 0; | ||
1000 | } | ||
1001 | |||
984 | int v4l2_chip_match_host(u32 match_type, u32 match_chip) | 1002 | int v4l2_chip_match_host(u32 match_type, u32 match_chip) |
985 | { | 1003 | { |
986 | switch (match_type) { | 1004 | switch (match_type) { |
@@ -1015,6 +1033,7 @@ EXPORT_SYMBOL(v4l2_ctrl_query_fill); | |||
1015 | EXPORT_SYMBOL(v4l2_ctrl_query_fill_std); | 1033 | EXPORT_SYMBOL(v4l2_ctrl_query_fill_std); |
1016 | 1034 | ||
1017 | EXPORT_SYMBOL(v4l2_chip_match_i2c_client); | 1035 | EXPORT_SYMBOL(v4l2_chip_match_i2c_client); |
1036 | EXPORT_SYMBOL(v4l2_chip_ident_i2c_client); | ||
1018 | EXPORT_SYMBOL(v4l2_chip_match_host); | 1037 | EXPORT_SYMBOL(v4l2_chip_match_host); |
1019 | 1038 | ||
1020 | /* | 1039 | /* |
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 5c9f2116d7bf..fdfef0b53315 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -1532,6 +1532,16 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
1532 | break; | 1532 | break; |
1533 | } | 1533 | } |
1534 | #endif | 1534 | #endif |
1535 | case VIDIOC_G_CHIP_IDENT: | ||
1536 | { | ||
1537 | struct v4l2_chip_ident *p=arg; | ||
1538 | if (!vfd->vidioc_g_chip_ident) | ||
1539 | break; | ||
1540 | ret=vfd->vidioc_g_chip_ident(file, fh, p); | ||
1541 | if (!ret) | ||
1542 | dbgarg (cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); | ||
1543 | break; | ||
1544 | } | ||
1535 | } /* switch */ | 1545 | } /* switch */ |
1536 | 1546 | ||
1537 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { | 1547 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { |