diff options
Diffstat (limited to 'extras/recipes-kernel/linux/linux-omap-psp-2.6.32/cam/0032-MT9V113-Fixed-sensor-nitialization-issues.patch')
-rw-r--r-- | extras/recipes-kernel/linux/linux-omap-psp-2.6.32/cam/0032-MT9V113-Fixed-sensor-nitialization-issues.patch | 294 |
1 files changed, 294 insertions, 0 deletions
diff --git a/extras/recipes-kernel/linux/linux-omap-psp-2.6.32/cam/0032-MT9V113-Fixed-sensor-nitialization-issues.patch b/extras/recipes-kernel/linux/linux-omap-psp-2.6.32/cam/0032-MT9V113-Fixed-sensor-nitialization-issues.patch new file mode 100644 index 00000000..72d9aa66 --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap-psp-2.6.32/cam/0032-MT9V113-Fixed-sensor-nitialization-issues.patch | |||
@@ -0,0 +1,294 @@ | |||
1 | From d35c02203462b5c94c7be1abeba9be2a175646fe Mon Sep 17 00:00:00 2001 | ||
2 | From: Vaibhav Hiremath <hvaibhav@ti.com> | ||
3 | Date: Fri, 9 Jul 2010 17:38:09 +0530 | ||
4 | Subject: [PATCH 32/75] MT9V113: Fixed sensor nitialization issues | ||
5 | |||
6 | With this patch sensor is now able to generate HS, VS and pixel clock, also | ||
7 | CCDC is able to generate HS/VS, VD0, VD1 interrupts. | ||
8 | |||
9 | There are some issues with Buffer processing in ISR routine because of which | ||
10 | DQBUF still hangs. | ||
11 | --- | ||
12 | drivers/media/video/mt9v113.c | 155 ++++++++++++++++++++---------------- | ||
13 | drivers/media/video/omap34xxcam.c | 2 +- | ||
14 | 2 files changed, 87 insertions(+), 70 deletions(-) | ||
15 | |||
16 | diff --git a/drivers/media/video/mt9v113.c b/drivers/media/video/mt9v113.c | ||
17 | index 755a88a..8f8ba35 100644 | ||
18 | --- a/drivers/media/video/mt9v113.c | ||
19 | +++ b/drivers/media/video/mt9v113.c | ||
20 | @@ -389,8 +389,8 @@ static int mt9v113_read_reg(struct i2c_client *client, unsigned short reg) | ||
21 | err = -ENODEV; | ||
22 | return err; | ||
23 | }else { | ||
24 | - // TODO: addr should be set up where else | ||
25 | - msg->addr = MT9V113_I2C_ADDR;//client->addr; | ||
26 | + /* TODO: addr should be set up where else client->addr */ | ||
27 | + msg->addr = MT9V113_I2C_ADDR; | ||
28 | msg->flags = 0; | ||
29 | msg->len = I2C_TWO_BYTE_TRANSFER; | ||
30 | msg->buf = data; | ||
31 | @@ -432,8 +432,8 @@ static int mt9v113_write_reg(struct i2c_client *client, unsigned short reg, unsi | ||
32 | if (!client->adapter) { | ||
33 | err = -ENODEV; | ||
34 | } else { | ||
35 | - // TODO: addr should be set up where else | ||
36 | - msg->addr = MT9V113_I2C_ADDR;//client->addr; | ||
37 | + /* TODO:addr should be set up where else client->addr */ | ||
38 | + msg->addr = MT9V113_I2C_ADDR; | ||
39 | msg->flags = 0; | ||
40 | msg->len = I2C_FOUR_BYTE_TRANSFER; | ||
41 | msg->buf = data; | ||
42 | @@ -446,51 +446,11 @@ static int mt9v113_write_reg(struct i2c_client *client, unsigned short reg, unsi | ||
43 | err = i2c_transfer(client->adapter, msg, 1); | ||
44 | } | ||
45 | } | ||
46 | - if (err < 0) { | ||
47 | + if (err < 0) | ||
48 | printk(KERN_INFO "\n I2C write failed"); | ||
49 | - } | ||
50 | - return err; | ||
51 | -} | ||
52 | - | ||
53 | -/* configure mux, for DM355 EVM only */ | ||
54 | -#ifndef CONFIG_MACH_DM355_LEOPARD | ||
55 | -static int mt9v113_en_mux(struct i2c_client *client) | ||
56 | -{ | ||
57 | - int err = 0; | ||
58 | - int trycnt = 0; | ||
59 | - /* unsigned short readval = 0;*/ | ||
60 | - | ||
61 | - struct i2c_msg msg[1]; | ||
62 | - unsigned char data[4]; | ||
63 | - err = -1; | ||
64 | - printk(KERN_INFO | ||
65 | - "\n entering mt9v113_en_mux \n"); | ||
66 | - | ||
67 | - while ((err < 0) && (trycnt < 5)) { | ||
68 | - trycnt++; | ||
69 | - if (!client->adapter) { | ||
70 | - err = -ENODEV; | ||
71 | - } else { | ||
72 | - msg->addr = 0x25; | ||
73 | - msg->flags = 0; | ||
74 | - msg->len = I2C_TWO_BYTE_TRANSFER; | ||
75 | - msg->buf = data; | ||
76 | - data[0] = (unsigned char)(0x08 & I2C_TXRX_DATA_MASK); | ||
77 | - data[1] = (unsigned char)(0x80 & I2C_TXRX_DATA_MASK); | ||
78 | |||
79 | - err = i2c_transfer(client->adapter, msg, 1); | ||
80 | - if (err < 0) { | ||
81 | - printk(KERN_INFO | ||
82 | - "\n ERROR in ECP register write\n"); | ||
83 | - } | ||
84 | - } | ||
85 | - } | ||
86 | - if (err < 0) { | ||
87 | - printk(KERN_INFO "\n I2C write failed"); | ||
88 | - } | ||
89 | return err; | ||
90 | } | ||
91 | -#endif | ||
92 | |||
93 | /* | ||
94 | * mt9v113_write_regs : Initializes a list of registers | ||
95 | @@ -550,9 +510,10 @@ static int mt9v113_configure(struct mt9v113_decoder *decoder) | ||
96 | if (err) | ||
97 | return err; | ||
98 | |||
99 | -// if (debug) | ||
100 | -// mt9v113_reg_dump(decoder); | ||
101 | - | ||
102 | +#if 0 | ||
103 | + if (debug) | ||
104 | + mt9v113_reg_dump(decoder); | ||
105 | +#endif | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | @@ -573,6 +534,62 @@ static int mt9v113_vga_mode(struct mt9v113_decoder *decoder) | ||
110 | } | ||
111 | |||
112 | |||
113 | +/** | ||
114 | + * ioctl_enum_framesizes - V4L2 sensor if handler for vidioc_int_enum_framesizes | ||
115 | + * @s: pointer to standard V4L2 device structure | ||
116 | + * @frms: pointer to standard V4L2 framesizes enumeration structure | ||
117 | + * | ||
118 | + * Returns possible framesizes depending on choosen pixel format | ||
119 | + **/ | ||
120 | +static int ioctl_enum_framesizes(struct v4l2_int_device *s, | ||
121 | + struct v4l2_frmsizeenum *frms) | ||
122 | +{ | ||
123 | + struct mt9v113_decoder *decoder = s->priv; | ||
124 | + int ifmt; | ||
125 | + | ||
126 | + for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) { | ||
127 | + if (frms->pixel_format == decoder->fmt_list[ifmt].pixelformat) | ||
128 | + break; | ||
129 | + } | ||
130 | + /* Is requested pixelformat not found on sensor? */ | ||
131 | + if (ifmt == decoder->num_fmts) | ||
132 | + return -EINVAL; | ||
133 | + | ||
134 | + /* Do we already reached all discrete framesizes? */ | ||
135 | + if (frms->index >= decoder->num_stds) | ||
136 | + return -EINVAL; | ||
137 | + | ||
138 | + frms->type = V4L2_FRMSIZE_TYPE_DISCRETE; | ||
139 | + frms->discrete.width = decoder->std_list[frms->index].width; | ||
140 | + frms->discrete.height = decoder->std_list[frms->index].height; | ||
141 | + | ||
142 | + return 0; | ||
143 | + | ||
144 | +} | ||
145 | + | ||
146 | +static int ioctl_enum_frameintervals(struct v4l2_int_device *s, | ||
147 | + struct v4l2_frmivalenum *frmi) | ||
148 | +{ | ||
149 | + struct mt9v113_decoder *decoder = s->priv; | ||
150 | + int ifmt; | ||
151 | + | ||
152 | + if (frmi->index >= 1) | ||
153 | + return -EINVAL; | ||
154 | + | ||
155 | + for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) { | ||
156 | + if (frmi->pixel_format == decoder->fmt_list[ifmt].pixelformat) | ||
157 | + break; | ||
158 | + } | ||
159 | + /* Is requested pixelformat not found on sensor? */ | ||
160 | + if (ifmt == decoder->num_fmts) | ||
161 | + return -EINVAL; | ||
162 | + | ||
163 | + frmi->type = V4L2_FRMSIZE_TYPE_DISCRETE; | ||
164 | + frmi->discrete.numerator = 1; | ||
165 | + frmi->discrete.denominator = 10; | ||
166 | + return 0; | ||
167 | +} | ||
168 | + | ||
169 | /* | ||
170 | * Detect if an mt9v113 is present, and if so which revision. | ||
171 | * A device is considered to be detected if the chip ID (LSB and MSB) | ||
172 | @@ -585,15 +602,9 @@ static int mt9v113_detect(struct mt9v113_decoder *decoder) | ||
173 | { | ||
174 | unsigned short val=0; | ||
175 | |||
176 | -#ifndef CONFIG_MACH_DM355_LEOPARD | ||
177 | -// mt9v113_en_mux(decoder->client); | ||
178 | -#endif | ||
179 | - | ||
180 | val = mt9v113_read_reg(decoder->client, REG_CHIP_ID); | ||
181 | |||
182 | - v4l_dbg(1, debug, decoder->client, | ||
183 | - "chip id detected 0x%x\n", | ||
184 | - val); | ||
185 | + v4l_dbg(1, debug, decoder->client, "chip id detected 0x%x\n", val); | ||
186 | |||
187 | if (MT9V113_CHIP_ID != val) { | ||
188 | /* We didn't read the values we expected, so this must not be | ||
189 | @@ -1042,7 +1053,7 @@ ioctl_s_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | ||
190 | if (rval) | ||
191 | return rval; | ||
192 | |||
193 | - decoder->pix = *pix; | ||
194 | + decoder->pix = *pix; | ||
195 | |||
196 | return rval; | ||
197 | } | ||
198 | @@ -1177,7 +1188,7 @@ static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p) | ||
199 | return rval; | ||
200 | } | ||
201 | |||
202 | - p->u.bt656.clock_curr = 27000000; // TODO: read clock rate from sensor | ||
203 | + p->u.bt656.clock_curr = 27000000; /* TODO:read clock rate from sensor */ | ||
204 | |||
205 | return 0; | ||
206 | } | ||
207 | @@ -1211,12 +1222,17 @@ static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on) | ||
208 | struct mt9v113_decoder *decoder = s->priv; | ||
209 | int err = 0; | ||
210 | |||
211 | + if (decoder->state == STATE_DETECTED) | ||
212 | + return 0; | ||
213 | + | ||
214 | switch (on) { | ||
215 | case V4L2_POWER_OFF: | ||
216 | /* Power Down Sequence */ | ||
217 | - err = | ||
218 | - mt9v113_write_reg(decoder->client, REG_OPERATION_MODE, | ||
219 | - 0x01); | ||
220 | +/* TODO: FIXME: implement proper OFF and Standby code here */ | ||
221 | +#if 0 | ||
222 | + err = mt9v113_write_reg(decoder->client, REG_OPERATION_MODE, | ||
223 | + 0x01); | ||
224 | +#endif | ||
225 | /* Disable mux for mt9v113 data path */ | ||
226 | if (decoder->pdata->power_set) | ||
227 | err |= decoder->pdata->power_set(s, on); | ||
228 | @@ -1242,9 +1258,10 @@ static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on) | ||
229 | "Unable to detect decoder\n"); | ||
230 | return err; | ||
231 | } | ||
232 | + /* Only VGA mode for now */ | ||
233 | + err |= mt9v113_configure(decoder); | ||
234 | + err |= mt9v113_vga_mode(decoder); | ||
235 | } | ||
236 | - // Only VGA mode for now | ||
237 | - err |= mt9v113_vga_mode(decoder); | ||
238 | break; | ||
239 | |||
240 | default: | ||
241 | @@ -1263,14 +1280,11 @@ static int ioctl_s_power(struct v4l2_int_device *s, enum v4l2_power on) | ||
242 | */ | ||
243 | static int ioctl_init(struct v4l2_int_device *s) | ||
244 | { | ||
245 | -// struct mt9v113_decoder *decoder = s->priv; | ||
246 | + struct mt9v113_decoder *decoder = s->priv; | ||
247 | int err = 0; | ||
248 | |||
249 | - /* Set default standard to auto */ | ||
250 | - //mt9v113_reg_list[REG_VIDEO_STD].val = | ||
251 | - // VIDEO_STD_AUTO_SWITCH_BIT; | ||
252 | -// err |= mt9v113_configure(decoder); | ||
253 | -// err |= mt9v113_vga_mode(decoder); | ||
254 | + err |= mt9v113_configure(decoder); | ||
255 | + err |= mt9v113_vga_mode(decoder); | ||
256 | |||
257 | return err; | ||
258 | } | ||
259 | @@ -1298,7 +1312,6 @@ static int ioctl_dev_init(struct v4l2_int_device *s) | ||
260 | struct mt9v113_decoder *decoder = s->priv; | ||
261 | int err; | ||
262 | |||
263 | - printk("%s: %d\n", __func__, __LINE__); | ||
264 | err = mt9v113_detect(decoder); | ||
265 | if (err < 0) { | ||
266 | v4l_err(decoder->client, | ||
267 | @@ -1340,6 +1353,10 @@ static struct v4l2_int_ioctl_desc mt9v113_ioctl_desc[] = { | ||
268 | {vidioc_int_s_std_num, (v4l2_int_ioctl_func *) ioctl_s_std}, | ||
269 | {vidioc_int_s_video_routing_num, | ||
270 | (v4l2_int_ioctl_func *) ioctl_s_routing}, | ||
271 | + {vidioc_int_enum_framesizes_num, | ||
272 | + (v4l2_int_ioctl_func *)ioctl_enum_framesizes}, | ||
273 | + {vidioc_int_enum_frameintervals_num, | ||
274 | + (v4l2_int_ioctl_func *)ioctl_enum_frameintervals}, | ||
275 | }; | ||
276 | |||
277 | static struct v4l2_int_slave mt9v113_slave = { | ||
278 | diff --git a/drivers/media/video/omap34xxcam.c b/drivers/media/video/omap34xxcam.c | ||
279 | index 6301ed3..2e8153b 100644 | ||
280 | --- a/drivers/media/video/omap34xxcam.c | ||
281 | +++ b/drivers/media/video/omap34xxcam.c | ||
282 | @@ -1852,8 +1852,8 @@ static int omap34xxcam_open(struct file *file) | ||
283 | vdev->slave_config[OMAP34XXCAM_SLAVE_SENSOR] | ||
284 | .cur_input = route.input; | ||
285 | } | ||
286 | - sensor_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
287 | } | ||
288 | + sensor_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
289 | |||
290 | /* Get the format the sensor is using. */ | ||
291 | rval = vidioc_int_g_fmt_cap(vdev->vdev_sensor, &sensor_format); | ||
292 | -- | ||
293 | 1.6.6.1 | ||
294 | |||