Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
video.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freek van Tienen <freek.v.tienen@gmail.com>
3  *
4  * This file is part of Paparazzi.
5  *
6  * Paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * Paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  *
20  */
21 
27 #include "video.h"
28 #include "std.h"
29 #include "mt9f002.h"
30 
31 #include <stdio.h>
32 #include <time.h>
33 #include <fcntl.h>
34 #include <unistd.h>
35 #include <sys/ioctl.h>
36 #include <mcu_periph/i2c.h>
37 #include <linux/i2c-dev.h>
38 #include <linux/types.h>
39 
40 #include "boards/bebop.h"
41 
43  .w = 640,
44  .h = 480,
45  .dev_name = "/dev/video0",
46  .subdev_name = NULL,
47  .format = V4L2_PIX_FMT_UYVY,
48  .buf_cnt = 60,
49  .filters = 0
50 };
51 
53  .w = 1408,
54  .h = 2112,
55  .dev_name = "/dev/video1",
56  .subdev_name = "/dev/v4l-subdev1",
57  .format = V4L2_PIX_FMT_SGBRG10,
58  .buf_cnt = 10,
59  .filters = VIDEO_FILTER_DEBAYER
60 };
61 
62 static bool_t write_reg(int fd, char *addr_val, uint8_t cnt)
63 {
64  char resp[cnt - 2];
65  uint8_t i;
66 
67  if (write(fd, addr_val, cnt) != cnt) {
68  printf("Write failed!\n");
69  return FALSE;
70  }
71  if (write(fd, addr_val, 2) != 2) {
72  printf("Write2 failed!\n");
73  return FALSE;
74  }
75  while (read(fd, resp, cnt - 2) != cnt - 2) { ; }
76  for (i = 0; i < cnt - 2; i++) {
77  if (resp[i] != addr_val[i + 2]) {
78  printf("[video] Could not write register %X%X\n", addr_val[0], addr_val[1]);
79  return write_reg(fd, addr_val, cnt);
80  }
81  }
82  return TRUE;
83 }
84 
85 static bool_t _write(int fd, char *data, uint8_t cnt)
86 {
87  if (write(fd, data, cnt) != cnt) {
88  printf("Failed!\n");
89  }
90  return TRUE;
91 }
92 
93 #pragma GCC diagnostic push
94 #pragma GCC diagnostic ignored "-Wunused-result"
95 
100 void mt9v117_init(void)
101 {
102  struct timespec tim;
103  char test[2];
104 
105  /* Start PWM 9 (Which probably is the clock of the MT9V117) */
106  int pwm9 = open("/sys/class/pwm/pwm_9/run", O_WRONLY | O_CREAT | O_TRUNC, 0666);
107  write(pwm9, "0", 1);
108  write(pwm9, "1", 1);
109  close(pwm9);
110 
111  tim.tv_sec = 0;
112  tim.tv_nsec = 50000000;
113  nanosleep(&tim, NULL);
114 
115  /* We open the i2c-0 (because else I needed to convert the strace) */
116  int fd_i2c = open("/dev/i2c-0", O_RDWR);
117  if (fd_i2c < 0) {
118  printf("[MT9V117] Could not open i2c-0\n");
119  return;
120  }
121  if (ioctl(fd_i2c, 0x703, 0x5d) < 0) {
122  printf("[MT9V117] Could not change the i2c address to 0x5d\n");
123  return;
124  }
125 
126  /* First reset the device */
127  write_reg(fd_i2c, "\x00\x1a\x00\x01", 4);
128  write_reg(fd_i2c, "\x00\x1a\x00\x00", 4);
129  tim.tv_sec = 0;
130  tim.tv_nsec = 100000000;
131  nanosleep(&tim, NULL);
132 
133  /* Now initialize the device */
134  write_reg(fd_i2c, "\x30\x1a\x10\xd0", 4);
135  write_reg(fd_i2c, "\x31\xc0\x14\x04", 4);
136  write_reg(fd_i2c, "\x3e\xd8\x87\x9c", 4);
137  write_reg(fd_i2c, "\x30\x42\x20\xe1", 4);
138  write_reg(fd_i2c, "\x30\xd4\x80\x20", 4);
139  write_reg(fd_i2c, "\x30\xc0\x00\x26", 4);
140  write_reg(fd_i2c, "\x30\x1a\x10\xd4", 4);
141  write_reg(fd_i2c, "\xa8\x02\x00\xd3", 4);
142  write_reg(fd_i2c, "\xc8\x78\x00\xa0", 4);
143  write_reg(fd_i2c, "\xc8\x76\x01\x40", 4);
144  write_reg(fd_i2c, "\xbc\x04\x00\xfc", 4);
145  write_reg(fd_i2c, "\xbc\x38\x00\x7f", 4);
146  write_reg(fd_i2c, "\xbc\x3a\x00\x7f", 4);
147  write_reg(fd_i2c, "\xbc\x3c\x00\x7f", 4);
148  write_reg(fd_i2c, "\xbc\x04\x00\xf4", 4);
149 
150  _write(fd_i2c, "\x09\x82\x00\x01", 4);
151  _write(fd_i2c, "\x09\x8a\x70\x00", 4);
152  _write(fd_i2c,
153  "\xf0\x00\x72\xcf\xff\x00\x3e\xd0\x92\x00\x71\xcf\xff\xff\xf2\x18\xb1\x10\x92\x05\xb1\x11\x92\x04\xb1\x12\x70\xcf\xff\x00\x30\xc0\x90\x00\x7f\xe0\xb1\x13\x70\xcf\xff\xff\xe7\x1c\x88\x36\x09\x0f\x00\xb3",
154  50);
155  _write(fd_i2c,
156  "\xf0\x30\x69\x13\xe1\x80\xd8\x08\x20\xca\x03\x22\x71\xcf\xff\xff\xe5\x68\x91\x35\x22\x0a\x1f\x80\xff\xff\xf2\x18\x29\x05\x00\x3e\x12\x22\x11\x01\x21\x04\x0f\x81\x00\x00\xff\xf0\x21\x8c\xf0\x10\x1a\x22",
157  50);
158  _write(fd_i2c,
159  "\xf0\x60\x10\x44\x12\x20\x11\x02\xf7\x87\x22\x4f\x03\x83\x1a\x20\x10\xc4\xf0\x09\xba\xae\x7b\x50\x1a\x20\x10\x84\x21\x45\x01\xc1\x1a\x22\x10\x44\x70\xcf\xff\x00\x3e\xd0\xb0\x60\xb0\x25\x7e\xe0\x78\xe0",
160  50);
161  _write(fd_i2c,
162  "\xf0\x90\x71\xcf\xff\xff\xf2\x18\x91\x12\x72\xcf\xff\xff\xe7\x1c\x8a\x57\x20\x04\x0f\x80\x00\x00\xff\xf0\xe2\x80\x20\xc5\x01\x61\x20\xc5\x03\x22\xb1\x12\x71\xcf\xff\x00\x3e\xd0\xb1\x04\x7e\xe0\x78\xe0",
163  50);
164  _write(fd_i2c,
165  "\xf0\xc0\x70\xcf\xff\xff\xe7\x1c\x88\x57\x71\xcf\xff\xff\xf2\x18\x91\x13\xea\x84\xb8\xa9\x78\x10\xf0\x03\xb8\x89\xb8\x8c\xb1\x13\x71\xcf\xff\x00\x30\xc0\xb1\x00\x7e\xe0\xc0\xf1\x09\x1e\x03\xc0\xc1\xa1",
166  50);
167  _write(fd_i2c,
168  "\xf0\xf0\x75\x08\x76\x28\x77\x48\xc2\x40\xd8\x20\x71\xcf\x00\x03\x20\x67\xda\x02\x08\xae\x03\xa0\x73\xc9\x0e\x25\x13\xc0\x0b\x5e\x01\x60\xd8\x06\xff\xbc\x0c\xce\x01\x00\xd8\x00\xb8\x9e\x0e\x5a\x03\x20",
169  50);
170  _write(fd_i2c,
171  "\xf1\x20\xd9\x01\xd8\x00\xb8\x9e\x0e\xb6\x03\x20\xd9\x01\x8d\x14\x08\x17\x01\x91\x8d\x16\xe8\x07\x0b\x36\x01\x60\xd8\x07\x0b\x52\x01\x60\xd8\x11\x8d\x14\xe0\x87\xd8\x00\x20\xca\x02\x62\x00\xc9\x03\xe0",
172  50);
173  _write(fd_i2c,
174  "\xf1\x50\xc0\xa1\x78\xe0\xc0\xf1\x08\xb2\x03\xc0\x76\xcf\xff\xff\xe5\x40\x75\xcf\xff\xff\xe5\x68\x95\x17\x96\x40\x77\xcf\xff\xff\xe5\x42\x95\x38\x0a\x0d\x00\x01\x97\x40\x0a\x11\x00\x40\x0b\x0a\x01\x00",
175  50);
176  _write(fd_i2c,
177  "\xf1\x80\x95\x17\xb6\x00\x95\x18\xb7\x00\x76\xcf\xff\xff\xe5\x44\x96\x20\x95\x15\x08\x13\x00\x40\x0e\x1e\x01\x20\xd9\x00\x95\x15\xb6\x00\xff\xa1\x75\xcf\xff\xff\xe7\x1c\x77\xcf\xff\xff\xe5\x46\x97\x40",
178  50);
179  _write(fd_i2c,
180  "\xf1\xb0\x8d\x16\x76\xcf\xff\xff\xe5\x48\x8d\x37\x08\x0d\x00\x81\x96\x40\x09\x15\x00\x80\x0f\xd6\x01\x00\x8d\x16\xb7\x00\x8d\x17\xb6\x00\xff\xb0\xff\xbc\x00\x41\x03\xc0\xc0\xf1\x0d\x9e\x01\x00\xe8\x04",
181  50);
182  _write(fd_i2c,
183  "\xf1\xe0\xff\x88\xf0\x0a\x0d\x6a\x01\x00\x0d\x8e\x01\x00\xe8\x7e\xff\x85\x0d\x72\x01\x00\xff\x8c\xff\xa7\xff\xb2\xd8\x00\x73\xcf\xff\xff\xf2\x40\x23\x15\x00\x01\x81\x41\xe0\x02\x81\x20\x08\xf7\x81\x34",
184  50);
185  _write(fd_i2c,
186  "\xf2\x10\xa1\x40\xd8\x00\xc0\xd1\x7e\xe0\x53\x51\x30\x34\x20\x6f\x6e\x5f\x73\x74\x61\x72\x74\x5f\x73\x74\x72\x65\x61\x6d\x69\x6e\x67\x20\x25\x64\x20\x25\x64\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
187  50);
188  _write(fd_i2c, "\xf2\x40\xff\xff\xe8\x28\xff\xff\xf0\xe8\xff\xff\xe8\x08\xff\xff\xf1\x54", 18);
189  _write(fd_i2c, "\x09\x8e\x00\x00", 4);
190  _write(fd_i2c, "\xe0\x00\x05\xd8", 4);
191  _write(fd_i2c, "\xe0\x02\x04\x03", 4);
192  _write(fd_i2c, "\xe0\x04\x00\x43\x01\x04", 6);
193 
194  // Do while succeeded?
195  _write(fd_i2c, "\x00\x40\x80\x01", 4);
196  while (test[0] != 0xFF || test[1] != 0XF8) {
197  tim.tv_sec = 0;
198  tim.tv_nsec = 100000000;
199  nanosleep(&tim, NULL);
200  write(fd_i2c, "\x00\x40", 2);
201  read(fd_i2c, test, 2);
202  printf("Da: %X%X\n", test[0], test[1]);
203 
204  /*if(test[1] == 0XFB) {
205  // restart all over??
206  mt9v117_init();
207  return;
208  }*/
209  }
210 
211  _write(fd_i2c, "\xac\x40\x00\x00\xc3\x50", 6);
212  write_reg(fd_i2c, "\xa4\x04\x00\x00", 4);
213  //write(fd_i2c, "\x00\x30", 2);
214  //read(fd_i2c, "\x04\x00", 2);
215 
216  write_reg(fd_i2c, "\x00\x30\x06\x01", 4);
217  write_reg(fd_i2c, "\xc8\x00\x00\x0c", 4); //0x0008
218  write_reg(fd_i2c, "\xc8\x02\x00\x10", 4);
219  write_reg(fd_i2c, "\xc8\x04\x01\xf3", 4); //0x01f5
220  write_reg(fd_i2c, "\xc8\x06\x02\x97", 4);
221  write_reg(fd_i2c, "\xc8\x08\x01\x11", 4);
222  write_reg(fd_i2c, "\xc8\x0a\x00\xa4", 4);
223  write_reg(fd_i2c, "\xc8\x0c\x02\xfa", 4);
224  write_reg(fd_i2c, "\xc8\x12\x00\x31", 4);
225  write_reg(fd_i2c, "\xc8\x14\x01\xe3", 4); //0x00f3
226  write_reg(fd_i2c, "\xc8\x28\x00\x03", 4); //0x0007
227  write_reg(fd_i2c, "\xc8\x4c\x02\x80", 4);
228  write_reg(fd_i2c, "\xc8\x4e\x01\xe0", 4); //240 (0x00f0)
229  write_reg(fd_i2c, "\xc8\x50\x03", 3);
230 
231  write_reg(fd_i2c, "\xc8\x54\x02\x80", 4); //320 (0x0140)
232  write_reg(fd_i2c, "\xc8\x56\x01\xe0", 4); //240 (0x00f0)
233 
234  write_reg(fd_i2c, "\xc8\xec\x00\x00", 4);
235  write_reg(fd_i2c, "\xc8\xee\x00\x00", 4);
236  write_reg(fd_i2c, "\xc8\xf0\x02\x7f", 4); //0x013f
237  write_reg(fd_i2c, "\xc8\xf2\x01\xdf", 4); //0x00ef
238  write_reg(fd_i2c, "\xc8\xf4\x00\x02", 4);
239  write_reg(fd_i2c, "\xc8\xf6\x00\x02", 4);
240  write_reg(fd_i2c, "\xc8\xf8\x00\x7f", 4); //0x003f
241  write_reg(fd_i2c, "\xc8\xfa\x00\x5f", 4); //0x002f
242  write_reg(fd_i2c, "\xc8\x10\x03\x52", 4); //0x0400 (0x045e??)
243  write_reg(fd_i2c, "\xc8\x0e\x01\xff", 4); //0x0140 (0x0143??)
244  write_reg(fd_i2c, "\xc8\x16\x00\xd4", 4); //0x00b0 (0x00a1??)
245  write_reg(fd_i2c, "\xc8\x18\x00\xfe", 4); //0x00d3 (0x00c1??)
246  write_reg(fd_i2c, "\xc8\x1a\x00\x01", 4);
247  write_reg(fd_i2c, "\xc8\x1c\x00\x02", 4); //0x0001
248  write_reg(fd_i2c, "\xc8\x1e\x00\x01", 4);
249  write_reg(fd_i2c, "\xc8\x20\x00\x02", 4); //0x0001
250 
251  write(fd_i2c, "\xc8\x58", 2);
252  read(fd_i2c, test, 2);
253  write_reg(fd_i2c, "\xc8\x58\x00\x18", 4);
254  write_reg(fd_i2c, "\xdc\x00\x28", 3);
255 
256  // Dow while succeeded?
257  _write(fd_i2c, "\x00\x40\x80\x02", 4);
258  test[0] = 0;
259  test[1] = 0;
260  while (test[0] != 0xFF || test[1] != 0XF8) {
261  tim.tv_sec = 0;
262  tim.tv_nsec = 100000000;
263  nanosleep(&tim, NULL);
264  write(fd_i2c, "\x00\x40", 2);
265  read(fd_i2c, test, 2);
266  printf("Dt: %X%X\n", test[0], test[1]);
267  }
268 
269  printf("Done!\n");
270  close(fd_i2c);
271 }
272 
274 
275 void mt9f002_open(void);
276 void mt9f002_close(void);
277 void mt9f002_set_address(uint8_t address);
282 
283 void mt9f002_open(void)
284 {
285  mt9f002_i2c_port = open("/dev/i2c-0", O_RDWR);
286  if (mt9f002_i2c_port < 0) {
287  printf("mt9f002_open");
288  // exit(1);
289  }
290 }
291 
292 void mt9f002_close(void)
293 {
294  close(mt9f002_i2c_port);
295 }
296 
298 {
299  if (ioctl(mt9f002_i2c_port, I2C_SLAVE_FORCE, address) < 0) {
300  printf("mt9f002_set_address");
301  // exit(1);
302  }
303 }
304 
306 {
307  mt9f002_open();
308  mt9f002_set_address(0x10);
309 
310  uint8_t data[3];
311  data[0] = (uint8_t)(reg >> 8) ;
312  data[1] = (uint8_t)reg & 0xFF;
313  data[2] = value;
314  // if(i2c_smbus_write_byte_data(mt9f002_i2c_port,reg,value) < 0) {
315  if (write(mt9f002_i2c_port, data, 3) < 0) {
316  printf("mt9f002_write_reg8");
317  // exit(1);
318  }
319 
320  mt9f002_close();
321 
322  usleep(100);
323 }
324 
326 {
327  mt9f002_open();
328  mt9f002_set_address(0x10);
329 
330  uint8_t data[4];
331  data[0] = (uint8_t)(reg >> 8);
332  data[1] = (uint8_t)reg & 0xFF;
333  data[2] = (uint8_t)(value >> 8);
334  data[3] = value & 0xFF;
335  if (write(mt9f002_i2c_port, data, 4) < 0) {
336  printf("mt9f002_write_reg16");
337  // exit(1);
338  }
339 
340  mt9f002_close();
341 
342  usleep(100);
343 }
344 
346 {
347  mt9f002_open();
348  mt9f002_set_address(0x10);
349 
350  uint8_t data[2];
351  data[0] = (uint8_t)(reg >> 8);
352  data[1] = (uint8_t)reg & 0xFF;
353  write(mt9f002_i2c_port, data, 2);
354  usleep(10);
355  read(mt9f002_i2c_port, data, 1);
356 
357  mt9f002_close();
358 
359  return data[0];
360 }
361 
362 
364 {
365  mt9f002_open();
366  mt9f002_set_address(0x10);
367 
368  uint8_t data[2];
369  data[0] = (uint8_t)(reg >> 8);
370  data[1] = (uint8_t)reg & 0xFF;
371  write(mt9f002_i2c_port, data, 2);
372  usleep(10);
373  read(mt9f002_i2c_port, data, 2);
374 
375  mt9f002_close();
376 
377  return data[1] | (data[0] << 8);
378 }
379 
384 void mt9f002_init(void)
385 {
386  /* Change to standby mode */
388 
389  /* Change registers */
489 
515 
521 
526 
529  mt9f002_write_reg16(MT9F002_X_ADDR_END_, 4527); // 4383 cols
530  mt9f002_write_reg16(MT9F002_Y_ADDR_END_, 3319); // 3287 rows
533  mt9f002_write_reg16(MT9F002_Y_ODD_INC, 3); // Sample 1, skip 7 -> /8
534 
537 
538 
539  /* Stream mode */
540  mt9f002_write_reg8(MT9F002_MODE_SELECT, 0x01); // Stream mode on
541 
542 }
543 
544 #pragma GCC diagnostic pop /* end disable -Wunused-result */
#define MT9F002_P_GR_P3Q2
Definition: mt9f002.h:327
#define MT9F002_P_GB_P3Q1
Definition: mt9f002.h:341
#define MT9F002_P_GB_P1Q0
Definition: mt9f002.h:300
unsigned short uint16_t
Definition: types.h:16
#define MT9F002_P_RD_P3Q4
Definition: mt9f002.h:334
#define MT9F002_P_GR_P4Q2
Definition: mt9f002.h:347
#define MT9F002_P_GB_P1Q2
Definition: mt9f002.h:302
#define MT9F002_X_ADDR_END_
Definition: mt9f002.h:168
#define MT9F002_P_GR_P4Q4
Definition: mt9f002.h:349
#define MT9F002_RED_GAIN
Definition: mt9f002.h:202
void mt9f002_init(void)
Initialisation of the Aptina MT9F002 CMOS sensor (1/2.3 inch 14Mp, front camera)
Definition: video.c:384
#define MT9F002_P_RD_P1Q1
Definition: mt9f002.h:291
#define MT9F002_GREEN2_GAIN
Definition: mt9f002.h:203
#define MT9F002_P_BL_P3Q4
Definition: mt9f002.h:339
#define MT9F002_P_BL_P0Q1
Definition: mt9f002.h:276
#define MT9F002_P_RD_P3Q1
Definition: mt9f002.h:331
#define MT9F002_P_GR_P4Q0
Definition: mt9f002.h:345
#define MT9F002_P_GR_P3Q4
Definition: mt9f002.h:329
#define MT9F002_P_BL_P4Q0
Definition: mt9f002.h:355
int w
Width.
Definition: video_device.h:38
uint16_t value
Definition: adc_arch.c:586
#define MT9F002_Y_ADDR_END_
Definition: mt9f002.h:167
#define MT9F002_CALIB_GREEN2
Definition: mt9f002.h:226
#define MT9F002_P_GB_P1Q1
Definition: mt9f002.h:301
#define MT9F002_P_GR_P1Q0
Definition: mt9f002.h:285
#define MT9F002_P_BL_P4Q3
Definition: mt9f002.h:358
#define MT9F002_P_GB_P3Q2
Definition: mt9f002.h:342
#define MT9F002_P_GB_Q5
Definition: mt9f002.h:371
#define MT9F002_X_ODD_INC
Definition: mt9f002.h:83
#define MT9F002_P_GR_P3Q3
Definition: mt9f002.h:328
#define MT9F002_P_BL_P3Q1
Definition: mt9f002.h:336
#define MT9F002_P_BL_P2Q2
Definition: mt9f002.h:317
#define MT9F002_P_BL_P2Q3
Definition: mt9f002.h:318
#define MT9F002_P_BL_P2Q4
Definition: mt9f002.h:319
#define MT9F002_P_BL_P1Q1
Definition: mt9f002.h:296
#define MT9F002_P_GB_P1Q4
Definition: mt9f002.h:304
#define MT9F002_HISPI_TIMING
Definition: mt9f002.h:257
#define MT9F002_ANALOG_GAIN_CODE_RED
Definition: mt9f002.h:61
#define MT9F002_P_RD_P1Q3
Definition: mt9f002.h:293
#define MT9F002_P_RD_P1Q4
Definition: mt9f002.h:294
#define MT9F002_POLY_ORIGIN_R
Definition: mt9f002.h:367
#define MT9F002_P_BL_P2Q1
Definition: mt9f002.h:316
#define MT9F002_P_RD_P0Q2
Definition: mt9f002.h:272
#define MT9F002_P_BL_P3Q3
Definition: mt9f002.h:338
static bool_t write_reg(int fd, char *addr_val, uint8_t cnt)
Definition: video.c:62
#define MT9F002_ANALOG_GAIN_CODE_GREENB
Definition: mt9f002.h:63
#define MT9F002_P_GR_Q5
Definition: mt9f002.h:368
#define MT9F002_P_GB_P0Q4
Definition: mt9f002.h:284
#define MT9F002_P_RD_P2Q1
Definition: mt9f002.h:311
#define MT9F002_P_BL_P0Q4
Definition: mt9f002.h:279
#define MT9F002_P_GB_P2Q0
Definition: mt9f002.h:320
#define MT9F002_P_RD_P3Q2
Definition: mt9f002.h:332
uint16_t mt9f002_read_reg16(uint16_t reg)
Definition: video.c:363
#define MT9F002_ROW_SPEED
Definition: mt9f002.h:174
Initialization of the video specific parts of the Bebop.
#define MT9F002_P_RD_P0Q1
Definition: mt9f002.h:271
#define MT9F002_P_BL_P0Q3
Definition: mt9f002.h:278
#define MT9F002_P_GB_P4Q1
Definition: mt9f002.h:361
#define FALSE
Definition: std.h:5
struct video_config_t front_camera
Definition: video.c:52
#define MT9F002_P_BL_P0Q0
Definition: mt9f002.h:275
#define MT9F002_CALIB_RED_ASC1
Definition: mt9f002.h:219
#define MT9F002_P_RD_P2Q0
Definition: mt9f002.h:310
#define MT9F002_P_BL_P1Q0
Definition: mt9f002.h:295
#define MT9F002_CALIB_GREEN1
Definition: mt9f002.h:223
#define MT9F002_X_ADDR_START_
Definition: mt9f002.h:166
#define MT9F002_P_GB_P3Q0
Definition: mt9f002.h:340
#define MT9F002_P_RD_P1Q2
Definition: mt9f002.h:292
#define MT9F002_BLUE_GAIN
Definition: mt9f002.h:201
#define MT9F002_CALIB_GREEN2_ASC1
Definition: mt9f002.h:220
#define TRUE
Definition: std.h:4
#define MT9F002_P_GB_P3Q3
Definition: mt9f002.h:343
#define MT9F002_P_BL_P2Q0
Definition: mt9f002.h:315
#define MT9F002_P_GR_P1Q2
Definition: mt9f002.h:287
#define MT9F002_P_GR_P2Q4
Definition: mt9f002.h:309
#define MT9F002_P_GB_P2Q4
Definition: mt9f002.h:324
#define MT9F002_P_GR_P0Q0
Definition: mt9f002.h:265
#define MT9F002_P_BL_P1Q3
Definition: mt9f002.h:298
#define MT9F002_P_GB_P4Q3
Definition: mt9f002.h:363
#define MT9F002_P_RD_P2Q4
Definition: mt9f002.h:314
void mt9f002_open(void)
Definition: video.c:283
#define MT9F002_P_GB_P2Q2
Definition: mt9f002.h:322
#define MT9F002_P_GR_P0Q3
Definition: mt9f002.h:268
#define MT9F002_P_RD_P3Q0
Definition: mt9f002.h:330
#define MT9F002_PLL_MULTIPLIER
Definition: mt9f002.h:71
#define MT9F002_READ_MODE
Definition: mt9f002.h:197
#define MT9F002_ANALOG_GAIN_CODE_BLUE
Definition: mt9f002.h:62
#define MT9F002_Y_ODD_INC
Definition: mt9f002.h:85
#define MT9F002_ANALOG_GAIN_CODE_GLOBAL
Definition: mt9f002.h:59
#define MT9F002_P_GR_P2Q3
Definition: mt9f002.h:308
void mt9f002_write_reg8(uint16_t reg, uint8_t value)
Definition: video.c:305
#define MT9F002_P_GB_P0Q3
Definition: mt9f002.h:283
#define MT9F002_CALIB_RED
Definition: mt9f002.h:225
#define MT9F002_P_BL_P1Q4
Definition: mt9f002.h:299
#define MT9F002_P_RD_P4Q0
Definition: mt9f002.h:350
#define VIDEO_FILTER_DEBAYER
Definition: video_device.h:34
#define MT9F002_CALIB_BLUE_ASC1
Definition: mt9f002.h:218
#define MT9F002_P_GB_P4Q4
Definition: mt9f002.h:364
#define MT9F002_P_GR_P3Q0
Definition: mt9f002.h:325
#define MT9F002_MIPI_TIMING_2
Definition: mt9f002.h:254
#define MT9F002_P_BL_P4Q1
Definition: mt9f002.h:356
#define MT9F002_MODE_SELECT
Definition: mt9f002.h:48
#define MT9F002_CALIB_GREEN1_ASC1
Definition: mt9f002.h:217
#define MT9F002_P_RD_P4Q2
Definition: mt9f002.h:352
void mt9v117_init(void)
Initialisation of the Aptina MT9V117 CMOS sensor (1/6 inch VGA, bottom camera)
Definition: video.c:100
#define MT9F002_P_GB_P2Q1
Definition: mt9f002.h:321
#define I2C_SLAVE_FORCE
Definition: i2c_smbus.h:131
#define MT9F002_P_GR_P0Q4
Definition: mt9f002.h:269
#define MT9F002_P_BL_P4Q4
Definition: mt9f002.h:359
#define MT9F002_P_BL_P3Q0
Definition: mt9f002.h:335
#define MT9F002_P_GB_P2Q3
Definition: mt9f002.h:323
#define MT9F002_P_GR_P2Q0
Definition: mt9f002.h:305
#define MT9F002_P_GR_P1Q4
Definition: mt9f002.h:289
#define MT9F002_P_RD_P2Q2
Definition: mt9f002.h:312
struct video_config_t bottom_camera
Definition: video.c:42
#define MT9F002_ANALOG_GAIN_CODE_GREENR
Definition: mt9f002.h:60
#define MT9F002_P_RD_P4Q4
Definition: mt9f002.h:354
#define MT9F002_P_GR_P1Q1
Definition: mt9f002.h:286
#define MT9F002_OP_PIX_CLK_DIV
Definition: mt9f002.h:72
unsigned char uint8_t
Definition: types.h:14
#define MT9F002_LINE_LENGTH_PCK
Definition: mt9f002.h:75
static bool_t _write(int fd, char *data, uint8_t cnt)
Definition: video.c:85
#define MT9F002_P_GR_P3Q1
Definition: mt9f002.h:326
#define MT9F002_P_GB_P0Q1
Definition: mt9f002.h:281
#define MT9F002_FRAME_LENGTH_LINES
Definition: mt9f002.h:74
int fd
Definition: serial.c:26
#define MT9F002_CALIB_BLUE
Definition: mt9f002.h:224
#define MT9F002_P_GB_P4Q0
Definition: mt9f002.h:360
void mt9f002_close(void)
Definition: video.c:292
#define MT9F002_P_GR_P2Q1
Definition: mt9f002.h:306
uint8_t mt9f002_read_reg8(uint16_t reg)
Definition: video.c:345
#define MT9F002_GLOBAL_GAIN
Definition: mt9f002.h:204
#define MT9F002_P_GB_P4Q2
Definition: mt9f002.h:362
#define MT9F002_P_RD_P2Q3
Definition: mt9f002.h:313
#define MT9F002_P_RD_P0Q3
Definition: mt9f002.h:273
#define MT9F002_VT_PIX_CLK_DIV
Definition: mt9f002.h:68
#define MT9F002_P_GR_P4Q3
Definition: mt9f002.h:348
#define MT9F002_Y_ADDR_START_
Definition: mt9f002.h:165
#define MT9F002_P_GR_P2Q2
Definition: mt9f002.h:307
#define MT9F002_P_RD_P4Q1
Definition: mt9f002.h:351
void mt9f002_write_reg16(uint16_t reg, uint16_t value)
Definition: video.c:325
#define MT9F002_SCALE_M
Definition: mt9f002.h:88
#define MT9F002_P_RD_P4Q3
Definition: mt9f002.h:353
#define MT9F002_P_RD_P0Q0
Definition: mt9f002.h:270
#define MT9F002_PRE_PLL_CLK_DIV
Definition: mt9f002.h:70
#define MT9F002_GREEN1_GAIN
Definition: mt9f002.h:200
#define MT9F002_P_GB_P3Q4
Definition: mt9f002.h:344
void mt9f002_set_address(uint8_t address)
Definition: video.c:297
#define MT9F002_P_GB_P0Q2
Definition: mt9f002.h:282
#define MT9F002_P_RD_P1Q0
Definition: mt9f002.h:290
#define MT9F002_P_BL_P3Q2
Definition: mt9f002.h:337
#define MT9F002_P_GR_P0Q2
Definition: mt9f002.h:267
#define MT9F002_P_BL_P0Q2
Definition: mt9f002.h:277
#define MT9F002_P_BL_P4Q2
Definition: mt9f002.h:357
#define MT9F002_DAC_ID_FBIAS
Definition: mt9f002.h:372
#define MT9F002_P_BL_P1Q2
Definition: mt9f002.h:297
#define MT9F002_SCALING_MODE
Definition: mt9f002.h:86
#define MT9F002_P_GR_P4Q1
Definition: mt9f002.h:346
#define MT9F002_POLY_ORIGIN_C
Definition: mt9f002.h:366
#define MT9F002_P_RD_P0Q4
Definition: mt9f002.h:274
V4L2 device settings.
Definition: video_device.h:37
#define MT9F002_P_GB_P0Q0
Definition: mt9f002.h:280
#define MT9F002_P_RD_P3Q3
Definition: mt9f002.h:333
#define MT9F002_P_RD_Q5
Definition: mt9f002.h:369
#define MT9F002_P_GR_P1Q3
Definition: mt9f002.h:288
#define MT9F002_P_BL_Q5
Definition: mt9f002.h:370
int mt9f002_i2c_port
Definition: video.c:273
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
#define MT9F002_P_GB_P1Q3
Definition: mt9f002.h:303