diff options
author | Guennadi Liakhovetski <g.liakhovetski@pengutronix.de> | 2008-03-07 19:57:18 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:07:49 -0400 |
commit | ad5f2e859d76dccb7eb1aa942171b1a32211efc2 (patch) | |
tree | 1716d5c82322d55886de36dddd9535b90dd57630 /include/media/soc_camera.h | |
parent | 1c659689fe9959c017bfaaa8301243f7d99f1a46 (diff) |
V4L/DVB (7336): soc-camera: streamline hardware parameter negotiation
Improve hardware parameter negotiation between the camera host driver and
camera drivers. Parameters like horizontal and vertical synchronisation,
pixel clock polarity shall be set depending on capabilities of the
parties.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'include/media/soc_camera.h')
-rw-r--r-- | include/media/soc_camera.h | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index c886b1e64872..3e48e435b21a 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h | |||
@@ -34,7 +34,7 @@ struct soc_camera_device { | |||
34 | unsigned short exposure; | 34 | unsigned short exposure; |
35 | unsigned char iface; /* Host number */ | 35 | unsigned char iface; /* Host number */ |
36 | unsigned char devnum; /* Device number per host */ | 36 | unsigned char devnum; /* Device number per host */ |
37 | unsigned char cached_datawidth; /* See comment in .c */ | 37 | unsigned char buswidth; /* See comment in .c */ |
38 | struct soc_camera_ops *ops; | 38 | struct soc_camera_ops *ops; |
39 | struct video_device *vdev; | 39 | struct video_device *vdev; |
40 | const struct soc_camera_data_format *current_fmt; | 40 | const struct soc_camera_data_format *current_fmt; |
@@ -61,11 +61,13 @@ struct soc_camera_host { | |||
61 | char *drv_name; | 61 | char *drv_name; |
62 | int (*add)(struct soc_camera_device *); | 62 | int (*add)(struct soc_camera_device *); |
63 | void (*remove)(struct soc_camera_device *); | 63 | void (*remove)(struct soc_camera_device *); |
64 | int (*set_capture_format)(struct soc_camera_device *, __u32, | 64 | int (*set_fmt_cap)(struct soc_camera_device *, __u32, |
65 | struct v4l2_rect *); | 65 | struct v4l2_rect *); |
66 | int (*try_fmt_cap)(struct soc_camera_host *, struct v4l2_format *); | 66 | int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *); |
67 | int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *); | 67 | int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *); |
68 | int (*querycap)(struct soc_camera_host *, struct v4l2_capability *); | 68 | int (*querycap)(struct soc_camera_host *, struct v4l2_capability *); |
69 | int (*try_bus_param)(struct soc_camera_device *, __u32); | ||
70 | int (*set_bus_param)(struct soc_camera_device *, __u32); | ||
69 | unsigned int (*poll)(struct file *, poll_table *); | 71 | unsigned int (*poll)(struct file *, poll_table *); |
70 | }; | 72 | }; |
71 | 73 | ||
@@ -108,9 +110,11 @@ struct soc_camera_ops { | |||
108 | int (*release)(struct soc_camera_device *); | 110 | int (*release)(struct soc_camera_device *); |
109 | int (*start_capture)(struct soc_camera_device *); | 111 | int (*start_capture)(struct soc_camera_device *); |
110 | int (*stop_capture)(struct soc_camera_device *); | 112 | int (*stop_capture)(struct soc_camera_device *); |
111 | int (*set_capture_format)(struct soc_camera_device *, __u32, | 113 | int (*set_fmt_cap)(struct soc_camera_device *, __u32, |
112 | struct v4l2_rect *, unsigned int); | 114 | struct v4l2_rect *); |
113 | int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *); | 115 | int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *); |
116 | unsigned long (*query_bus_param)(struct soc_camera_device *); | ||
117 | int (*set_bus_param)(struct soc_camera_device *, unsigned long); | ||
114 | int (*get_chip_id)(struct soc_camera_device *, | 118 | int (*get_chip_id)(struct soc_camera_device *, |
115 | struct v4l2_chip_ident *); | 119 | struct v4l2_chip_ident *); |
116 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 120 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
@@ -123,7 +127,6 @@ struct soc_camera_ops { | |||
123 | int (*set_control)(struct soc_camera_device *, struct v4l2_control *); | 127 | int (*set_control)(struct soc_camera_device *, struct v4l2_control *); |
124 | const struct v4l2_queryctrl *controls; | 128 | const struct v4l2_queryctrl *controls; |
125 | int num_controls; | 129 | int num_controls; |
126 | unsigned int(*get_datawidth)(struct soc_camera_device *icd); | ||
127 | }; | 130 | }; |
128 | 131 | ||
129 | static inline struct v4l2_queryctrl const *soc_camera_find_qctrl( | 132 | static inline struct v4l2_queryctrl const *soc_camera_find_qctrl( |
@@ -138,12 +141,33 @@ static inline struct v4l2_queryctrl const *soc_camera_find_qctrl( | |||
138 | return NULL; | 141 | return NULL; |
139 | } | 142 | } |
140 | 143 | ||
141 | #define IS_MASTER (1<<0) | 144 | #define SOCAM_MASTER (1 << 0) |
142 | #define IS_HSYNC_ACTIVE_HIGH (1<<1) | 145 | #define SOCAM_SLAVE (1 << 1) |
143 | #define IS_VSYNC_ACTIVE_HIGH (1<<2) | 146 | #define SOCAM_HSYNC_ACTIVE_HIGH (1 << 2) |
144 | #define IS_DATAWIDTH_8 (1<<3) | 147 | #define SOCAM_HSYNC_ACTIVE_LOW (1 << 3) |
145 | #define IS_DATAWIDTH_9 (1<<4) | 148 | #define SOCAM_VSYNC_ACTIVE_HIGH (1 << 4) |
146 | #define IS_DATAWIDTH_10 (1<<5) | 149 | #define SOCAM_VSYNC_ACTIVE_LOW (1 << 5) |
147 | #define IS_PCLK_SAMPLE_RISING (1<<6) | 150 | #define SOCAM_DATAWIDTH_8 (1 << 6) |
151 | #define SOCAM_DATAWIDTH_9 (1 << 7) | ||
152 | #define SOCAM_DATAWIDTH_10 (1 << 8) | ||
153 | #define SOCAM_PCLK_SAMPLE_RISING (1 << 9) | ||
154 | #define SOCAM_PCLK_SAMPLE_FALLING (1 << 10) | ||
155 | |||
156 | #define SOCAM_DATAWIDTH_MASK (SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_9 | \ | ||
157 | SOCAM_DATAWIDTH_10) | ||
158 | |||
159 | static inline unsigned long soc_camera_bus_param_compatible( | ||
160 | unsigned long camera_flags, unsigned long bus_flags) | ||
161 | { | ||
162 | unsigned long common_flags, hsync, vsync, pclk; | ||
163 | |||
164 | common_flags = camera_flags & bus_flags; | ||
165 | |||
166 | hsync = common_flags & (SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW); | ||
167 | vsync = common_flags & (SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW); | ||
168 | pclk = common_flags & (SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING); | ||
169 | |||
170 | return (!hsync || !vsync || !pclk) ? 0 : common_flags; | ||
171 | } | ||
148 | 172 | ||
149 | #endif | 173 | #endif |