blob: 3de2e2284f48dd277e93412bcf858fdd0c863012
1 | #ifndef __HW_CAMERA_HW_H__ |
2 | #define __HW_CAMERA_HW_H__ |
3 | #include <linux/videodev2.h> |
4 | |
5 | #include <stdio.h> |
6 | #include <stdlib.h> |
7 | #include <string.h> |
8 | #include <assert.h> |
9 | |
10 | #include <getopt.h> /* getopt_long() */ |
11 | |
12 | #include <fcntl.h> /* low-level i/o */ |
13 | #include <unistd.h> |
14 | #include <errno.h> |
15 | #include <sys/stat.h> |
16 | #include <sys/types.h> |
17 | #include <sys/time.h> |
18 | #include <sys/mman.h> |
19 | #include <sys/ioctl.h> |
20 | #include <stdbool.h> |
21 | |
22 | #include <linux/videodev2.h> |
23 | #include <DebugUtils.h> |
24 | |
25 | #define NB_BUFFER 6 |
26 | #define NB_PIC_BUFFER 2 |
27 | #define CLEAR(x) memset(&(x), 0, sizeof(x)) |
28 | |
29 | #define V4L2_ROTATE_ID 0x980922 //V4L2_CID_ROTATE |
30 | typedef struct FrameV4L2Info { |
31 | struct v4l2_format format; |
32 | struct v4l2_buffer buf; |
33 | struct v4l2_requestbuffers rb; |
34 | }FrameV4L2Info; |
35 | |
36 | struct VideoInfo { |
37 | struct v4l2_capability cap; |
38 | FrameV4L2Info preview; |
39 | FrameV4L2Info picture; |
40 | void *mem[NB_BUFFER]; |
41 | void *mem_pic[NB_PIC_BUFFER]; |
42 | unsigned int canvas[NB_BUFFER]; |
43 | bool isStreaming; |
44 | bool isPicture; |
45 | bool canvas_mode; |
46 | int width; |
47 | int height; |
48 | int formatIn; |
49 | int framesizeIn; |
50 | uint32_t idVendor; |
51 | uint32_t idProduct; |
52 | |
53 | int idx; |
54 | int fd; |
55 | |
56 | int tempbuflen; |
57 | int dev_status; |
58 | }; |
59 | |
60 | extern int camera_open(struct VideoInfo *cam_dev); |
61 | extern void camera_close(struct VideoInfo *vinfo); |
62 | extern int setBuffersFormat(struct VideoInfo *cam_dev); |
63 | extern int start_capturing(struct VideoInfo *vinfo); |
64 | extern int start_picture(struct VideoInfo *vinfo,int rotate); |
65 | extern void stop_picture(struct VideoInfo *vinfo); |
66 | extern void releasebuf_and_stop_picture(struct VideoInfo *vinfo); |
67 | extern int stop_capturing(struct VideoInfo *vinfo); |
68 | extern int releasebuf_and_stop_capturing(struct VideoInfo *vinfo); |
69 | |
70 | extern uintptr_t get_frame_phys(struct VideoInfo *vinfo); |
71 | extern void set_device_status(struct VideoInfo *vinfo); |
72 | extern int get_device_status(struct VideoInfo *vinfo); |
73 | |
74 | extern void *get_frame(struct VideoInfo *vinfo); |
75 | extern void *get_picture(struct VideoInfo *vinfo); |
76 | extern int putback_frame(struct VideoInfo *vinfo); |
77 | extern int putback_picture_frame(struct VideoInfo *vinfo); |
78 | #endif |
79 |