1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#define V4L2_CTRL_COUNT 29
17
18enum {
19 COMP_CAMERA = 0,
20 COMP_PREVIEW,
21 COMP_IMAGE_ENCODE,
22 COMP_VIDEO_ENCODE,
23 COMP_COUNT
24};
25
26enum {
27 CAM_PORT_PREVIEW = 0,
28 CAM_PORT_VIDEO,
29 CAM_PORT_CAPTURE,
30 CAM_PORT_COUNT
31};
32
33extern int bcm2835_v4l2_debug;
34
35struct bm2835_mmal_dev {
36
37 struct v4l2_device v4l2_dev;
38 struct video_device vdev;
39 struct mutex mutex;
40
41
42 struct v4l2_ctrl_handler ctrl_handler;
43 struct v4l2_ctrl *ctrls[V4L2_CTRL_COUNT];
44 enum v4l2_scene_mode scene_mode;
45 struct mmal_colourfx colourfx;
46 int hflip;
47 int vflip;
48 int red_gain;
49 int blue_gain;
50 enum mmal_parameter_exposuremode exposure_mode_user;
51 enum v4l2_exposure_auto_type exposure_mode_v4l2_user;
52
53 enum mmal_parameter_exposuremode exposure_mode_active;
54 enum mmal_parameter_exposuremeteringmode metering_mode;
55 unsigned int manual_shutter_speed;
56 bool exp_auto_priority;
57 bool manual_iso_enabled;
58 u32 iso;
59
60
61 struct vchiq_mmal_instance *instance;
62 struct vchiq_mmal_component *component[COMP_COUNT];
63 int camera_use_count;
64
65 struct v4l2_window overlay;
66
67 struct {
68 unsigned int width;
69 unsigned int height;
70 unsigned int stride;
71 unsigned int buffersize;
72 struct mmal_fmt *fmt;
73 struct v4l2_fract timeperframe;
74
75
76 int encode_bitrate;
77
78 int encode_bitrate_mode;
79
80 enum v4l2_mpeg_video_h264_profile enc_profile;
81
82 enum v4l2_mpeg_video_h264_level enc_level;
83
84 int q_factor;
85
86 struct vb2_queue vb_vidq;
87
88
89 s64 vc_start_timestamp;
90
91 ktime_t kernel_start_ts;
92
93 u32 sequence;
94
95 struct vchiq_mmal_port *port;
96
97 struct vchiq_mmal_port *camera_port;
98
99 struct vchiq_mmal_component *encode_component;
100
101 unsigned int frame_count;
102
103 struct completion frame_cmplt;
104
105 } capture;
106
107 unsigned int camera_num;
108 unsigned int max_width;
109 unsigned int max_height;
110 unsigned int rgb_bgr_swapped;
111};
112
113int bm2835_mmal_init_controls(
114 struct bm2835_mmal_dev *dev,
115 struct v4l2_ctrl_handler *hdl);
116
117int bm2835_mmal_set_all_camera_controls(struct bm2835_mmal_dev *dev);
118int set_framerate_params(struct bm2835_mmal_dev *dev);
119
120
121
122#define v4l2_dump_pix_format(level, debug, dev, pix_fmt, desc) \
123{ \
124 v4l2_dbg(level, debug, dev, \
125"%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n", \
126 desc, \
127 (pix_fmt)->width, (pix_fmt)->height, (pix_fmt)->field, \
128 (pix_fmt)->pixelformat, (pix_fmt)->bytesperline, \
129 (pix_fmt)->sizeimage, (pix_fmt)->colorspace, (pix_fmt)->priv); \
130}
131
132#define v4l2_dump_win_format(level, debug, dev, win_fmt, desc) \
133{ \
134 v4l2_dbg(level, debug, dev, \
135"%s: w %u h %u l %u t %u field %u chromakey %06X clip %p " \
136"clipcount %u bitmap %p\n", \
137 desc, \
138 (win_fmt)->w.width, (win_fmt)->w.height, \
139 (win_fmt)->w.left, (win_fmt)->w.top, \
140 (win_fmt)->field, \
141 (win_fmt)->chromakey, \
142 (win_fmt)->clips, (win_fmt)->clipcount, \
143 (win_fmt)->bitmap); \
144}
145