diff options
Diffstat (limited to 'include/media/soc_camera.h')
-rw-r--r-- | include/media/soc_camera.h | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 2ce957301f77..238bd334fd83 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h | |||
@@ -17,16 +17,21 @@ | |||
17 | #include <linux/pm.h> | 17 | #include <linux/pm.h> |
18 | #include <linux/videodev2.h> | 18 | #include <linux/videodev2.h> |
19 | #include <media/videobuf-core.h> | 19 | #include <media/videobuf-core.h> |
20 | #include <media/videobuf2-core.h> | ||
20 | #include <media/v4l2-device.h> | 21 | #include <media/v4l2-device.h> |
21 | 22 | ||
22 | extern struct bus_type soc_camera_bus_type; | 23 | extern struct bus_type soc_camera_bus_type; |
23 | 24 | ||
25 | struct file; | ||
26 | |||
24 | struct soc_camera_device { | 27 | struct soc_camera_device { |
25 | struct list_head list; | 28 | struct list_head list; |
26 | struct device dev; | 29 | struct device dev; |
27 | struct device *pdev; /* Platform device */ | 30 | struct device *pdev; /* Platform device */ |
28 | s32 user_width; | 31 | s32 user_width; |
29 | s32 user_height; | 32 | s32 user_height; |
33 | u32 bytesperline; /* for padding, zero if unused */ | ||
34 | u32 sizeimage; | ||
30 | enum v4l2_colorspace colorspace; | 35 | enum v4l2_colorspace colorspace; |
31 | unsigned char iface; /* Host number */ | 36 | unsigned char iface; /* Host number */ |
32 | unsigned char devnum; /* Device number per host */ | 37 | unsigned char devnum; /* Device number per host */ |
@@ -41,11 +46,11 @@ struct soc_camera_device { | |||
41 | /* soc_camera.c private count. Only accessed with .video_lock held */ | 46 | /* soc_camera.c private count. Only accessed with .video_lock held */ |
42 | int use_count; | 47 | int use_count; |
43 | struct mutex video_lock; /* Protects device data */ | 48 | struct mutex video_lock; /* Protects device data */ |
44 | }; | 49 | struct file *streamer; /* stream owner */ |
45 | 50 | union { | |
46 | struct soc_camera_file { | 51 | struct videobuf_queue vb_vidq; |
47 | struct soc_camera_device *icd; | 52 | struct vb2_queue vb2_vidq; |
48 | struct videobuf_queue vb_vidq; | 53 | }; |
49 | }; | 54 | }; |
50 | 55 | ||
51 | struct soc_camera_host { | 56 | struct soc_camera_host { |
@@ -75,17 +80,25 @@ struct soc_camera_host_ops { | |||
75 | int (*cropcap)(struct soc_camera_device *, struct v4l2_cropcap *); | 80 | int (*cropcap)(struct soc_camera_device *, struct v4l2_cropcap *); |
76 | int (*get_crop)(struct soc_camera_device *, struct v4l2_crop *); | 81 | int (*get_crop)(struct soc_camera_device *, struct v4l2_crop *); |
77 | int (*set_crop)(struct soc_camera_device *, struct v4l2_crop *); | 82 | int (*set_crop)(struct soc_camera_device *, struct v4l2_crop *); |
83 | /* | ||
84 | * The difference to .set_crop() is, that .set_livecrop is not allowed | ||
85 | * to change the output sizes | ||
86 | */ | ||
87 | int (*set_livecrop)(struct soc_camera_device *, struct v4l2_crop *); | ||
78 | int (*set_fmt)(struct soc_camera_device *, struct v4l2_format *); | 88 | int (*set_fmt)(struct soc_camera_device *, struct v4l2_format *); |
79 | int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *); | 89 | int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *); |
80 | void (*init_videobuf)(struct videobuf_queue *, | 90 | void (*init_videobuf)(struct videobuf_queue *, |
81 | struct soc_camera_device *); | 91 | struct soc_camera_device *); |
82 | int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *); | 92 | int (*init_videobuf2)(struct vb2_queue *, |
93 | struct soc_camera_device *); | ||
94 | int (*reqbufs)(struct soc_camera_device *, struct v4l2_requestbuffers *); | ||
83 | int (*querycap)(struct soc_camera_host *, struct v4l2_capability *); | 95 | int (*querycap)(struct soc_camera_host *, struct v4l2_capability *); |
84 | int (*set_bus_param)(struct soc_camera_device *, __u32); | 96 | int (*set_bus_param)(struct soc_camera_device *, __u32); |
85 | int (*get_ctrl)(struct soc_camera_device *, struct v4l2_control *); | 97 | int (*get_ctrl)(struct soc_camera_device *, struct v4l2_control *); |
86 | int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); | 98 | int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); |
87 | int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); | 99 | int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); |
88 | int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); | 100 | int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); |
101 | int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *); | ||
89 | unsigned int (*poll)(struct file *, poll_table *); | 102 | unsigned int (*poll)(struct file *, poll_table *); |
90 | const struct v4l2_queryctrl *controls; | 103 | const struct v4l2_queryctrl *controls; |
91 | int num_controls; | 104 | int num_controls; |
@@ -96,8 +109,15 @@ struct soc_camera_host_ops { | |||
96 | #define SOCAM_SENSOR_INVERT_HSYNC (1 << 2) | 109 | #define SOCAM_SENSOR_INVERT_HSYNC (1 << 2) |
97 | #define SOCAM_SENSOR_INVERT_VSYNC (1 << 3) | 110 | #define SOCAM_SENSOR_INVERT_VSYNC (1 << 3) |
98 | #define SOCAM_SENSOR_INVERT_DATA (1 << 4) | 111 | #define SOCAM_SENSOR_INVERT_DATA (1 << 4) |
112 | #define SOCAM_MIPI_1LANE (1 << 5) | ||
113 | #define SOCAM_MIPI_2LANE (1 << 6) | ||
114 | #define SOCAM_MIPI_3LANE (1 << 7) | ||
115 | #define SOCAM_MIPI_4LANE (1 << 8) | ||
116 | #define SOCAM_MIPI (SOCAM_MIPI_1LANE | SOCAM_MIPI_2LANE | \ | ||
117 | SOCAM_MIPI_3LANE | SOCAM_MIPI_4LANE) | ||
99 | 118 | ||
100 | struct i2c_board_info; | 119 | struct i2c_board_info; |
120 | struct regulator_bulk_data; | ||
101 | 121 | ||
102 | struct soc_camera_link { | 122 | struct soc_camera_link { |
103 | /* Camera bus id, used to match a camera and a bus */ | 123 | /* Camera bus id, used to match a camera and a bus */ |
@@ -109,6 +129,10 @@ struct soc_camera_link { | |||
109 | const char *module_name; | 129 | const char *module_name; |
110 | void *priv; | 130 | void *priv; |
111 | 131 | ||
132 | /* Optional regulators that have to be managed on power on/off events */ | ||
133 | struct regulator_bulk_data *regulators; | ||
134 | int num_regulators; | ||
135 | |||
112 | /* | 136 | /* |
113 | * For non-I2C devices platform platform has to provide methods to | 137 | * For non-I2C devices platform platform has to provide methods to |
114 | * add a device to the system and to remove | 138 | * add a device to the system and to remove |
@@ -255,6 +279,7 @@ static inline unsigned long soc_camera_bus_param_compatible( | |||
255 | unsigned long camera_flags, unsigned long bus_flags) | 279 | unsigned long camera_flags, unsigned long bus_flags) |
256 | { | 280 | { |
257 | unsigned long common_flags, hsync, vsync, pclk, data, buswidth, mode; | 281 | unsigned long common_flags, hsync, vsync, pclk, data, buswidth, mode; |
282 | unsigned long mipi; | ||
258 | 283 | ||
259 | common_flags = camera_flags & bus_flags; | 284 | common_flags = camera_flags & bus_flags; |
260 | 285 | ||
@@ -264,8 +289,9 @@ static inline unsigned long soc_camera_bus_param_compatible( | |||
264 | data = common_flags & (SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_LOW); | 289 | data = common_flags & (SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_LOW); |
265 | mode = common_flags & (SOCAM_MASTER | SOCAM_SLAVE); | 290 | mode = common_flags & (SOCAM_MASTER | SOCAM_SLAVE); |
266 | buswidth = common_flags & SOCAM_DATAWIDTH_MASK; | 291 | buswidth = common_flags & SOCAM_DATAWIDTH_MASK; |
292 | mipi = common_flags & SOCAM_MIPI; | ||
267 | 293 | ||
268 | return (!hsync || !vsync || !pclk || !data || !mode || !buswidth) ? 0 : | 294 | return ((!hsync || !vsync || !pclk || !data || !mode || !buswidth) && !mipi) ? 0 : |
269 | common_flags; | 295 | common_flags; |
270 | } | 296 | } |
271 | 297 | ||
@@ -295,4 +321,17 @@ static inline struct video_device *soc_camera_i2c_to_vdev(struct i2c_client *cli | |||
295 | return icd->vdev; | 321 | return icd->vdev; |
296 | } | 322 | } |
297 | 323 | ||
324 | static inline struct soc_camera_device *soc_camera_from_vb2q(struct vb2_queue *vq) | ||
325 | { | ||
326 | return container_of(vq, struct soc_camera_device, vb2_vidq); | ||
327 | } | ||
328 | |||
329 | static inline struct soc_camera_device *soc_camera_from_vbq(struct videobuf_queue *vq) | ||
330 | { | ||
331 | return container_of(vq, struct soc_camera_device, vb_vidq); | ||
332 | } | ||
333 | |||
334 | void soc_camera_lock(struct vb2_queue *vq); | ||
335 | void soc_camera_unlock(struct vb2_queue *vq); | ||
336 | |||
298 | #endif | 337 | #endif |