aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca
diff options
context:
space:
mode:
authorErik Andrén <erik.andren@gmail.com>2009-01-21 11:39:17 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:20:47 -0400
commitea8f74b168aa4d725c6d1ab98ef4eb4f6f3f3358 (patch)
tree4093756eaa7afdab2af32ac290a6cd4679598503 /drivers/media/video/gspca
parent4763fa84d9942137b011629be2e7547a23cdfbc6 (diff)
V4L/DVB (11636): gspca - m5602-ov7660: Design probe function
Signed-off-by: Erik Andrén <erik.andren@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov7660.c61
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov7660.h4
-rw-r--r--drivers/media/video/gspca/m5602/m5602_sensor.h3
3 files changed, 67 insertions, 1 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.c b/drivers/media/video/gspca/m5602/m5602_ov7660.c
index 466de667a60d..a5953d828389 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov7660.c
+++ b/drivers/media/video/gspca/m5602/m5602_ov7660.c
@@ -38,7 +38,68 @@ static void ov7660_dump_registers(struct sd *sd);
38 38
39int ov7660_probe(struct sd *sd) 39int ov7660_probe(struct sd *sd)
40{ 40{
41 int err = 0, i;
42 u8 prod_id = 0, ver_id = 0;
43
44 s32 *sensor_settings;
45
46 if (force_sensor) {
47 if (force_sensor == OV7660_SENSOR) {
48 info("Forcing an %s sensor", ov7660.name);
49 goto sensor_found;
50 }
51 /* If we want to force another sensor,
52 don't try to probe this one */
53 return -ENODEV;
54 }
55
56 /* Do the preinit */
57 for (i = 0; i < ARRAY_SIZE(preinit_ov7660) && !err; i++) {
58 u8 data[2];
59
60 if (preinit_ov7660[i][0] == BRIDGE) {
61 err = m5602_write_bridge(sd,
62 preinit_ov7660[i][1],
63 preinit_ov7660[i][2]);
64 } else {
65 data[0] = preinit_ov7660[i][2];
66 err = m5602_write_sensor(sd,
67 preinit_ov7660[i][1], data, 1);
68 }
69 }
70 if (err < 0)
71 return err;
72
73 if (m5602_read_sensor(sd, OV7660_PID, &prod_id, 1))
74 return -ENODEV;
75
76 if (m5602_read_sensor(sd, OV7660_VER, &ver_id, 1))
77 return -ENODEV;
78
79 info("Sensor reported 0x%x%x", prod_id, ver_id);
80
81 if ((prod_id == 0x76) && (ver_id == 0x60)) {
82 info("Detected a ov7660 sensor");
83 goto sensor_found;
84 }
41 return -ENODEV; 85 return -ENODEV;
86
87sensor_found:
88 sensor_settings = kmalloc(
89 ARRAY_SIZE(ov7660_ctrls) * sizeof(s32), GFP_KERNEL);
90 if (!sensor_settings)
91 return -ENOMEM;
92
93 sd->gspca_dev.cam.cam_mode = ov7660_modes;
94 sd->gspca_dev.cam.nmodes = ARRAY_SIZE(ov7660_modes);
95 sd->desc->ctrls = ov7660_ctrls;
96 sd->desc->nctrls = ARRAY_SIZE(ov7660_ctrls);
97
98 for (i = 0; i < ARRAY_SIZE(ov7660_ctrls); i++)
99 sensor_settings[i] = ov7660_ctrls[i].qctrl.default_value;
100 sd->sensor_priv = sensor_settings;
101
102 return 0;
42} 103}
43 104
44int ov7660_init(struct sd *sd) 105int ov7660_init(struct sd *sd)
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.h b/drivers/media/video/gspca/m5602/m5602_ov7660.h
index 67bde9bb28c8..71103ede8851 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov7660.h
+++ b/drivers/media/video/gspca/m5602/m5602_ov7660.h
@@ -84,6 +84,10 @@
84#define DEFAULT_SATURATION 0x00 84#define DEFAULT_SATURATION 0x00
85#define DEFAULT_EXPOSURE 0x20 85#define DEFAULT_EXPOSURE 0x20
86 86
87/* Kernel module parameters */
88extern int force_sensor;
89extern int dump_sensor;
90
87int ov7660_probe(struct sd *sd); 91int ov7660_probe(struct sd *sd);
88int ov7660_init(struct sd *sd); 92int ov7660_init(struct sd *sd);
89int ov7660_start(struct sd *sd); 93int ov7660_start(struct sd *sd);
diff --git a/drivers/media/video/gspca/m5602/m5602_sensor.h b/drivers/media/video/gspca/m5602/m5602_sensor.h
index c3a72117b39c..edff4f1f586f 100644
--- a/drivers/media/video/gspca/m5602/m5602_sensor.h
+++ b/drivers/media/video/gspca/m5602/m5602_sensor.h
@@ -30,7 +30,8 @@ enum sensors {
30 S5K83A_SENSOR = 2, 30 S5K83A_SENSOR = 2,
31 S5K4AA_SENSOR = 3, 31 S5K4AA_SENSOR = 3,
32 MT9M111_SENSOR = 4, 32 MT9M111_SENSOR = 4,
33 PO1030_SENSOR = 5 33 PO1030_SENSOR = 5,
34 OV7660_SENSOR = 6,
34}; 35};
35 36
36/* Enumerates all possible instruction types */ 37/* Enumerates all possible instruction types */