diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2011-07-26 10:38:01 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-03 16:27:13 -0400 |
commit | 32c69fcc785a2f8122c73d44ad160d9cfc4c9615 (patch) | |
tree | c5a15bcfb69436d9da99369b1bdec17999f89849 | |
parent | 7cd74ffb04e05c115ebe53a59f83a73e677a2c63 (diff) |
[media] V4L: soc-camera: add helper functions for new bus configuration type
Add helper functions to process the new media bus configuration type
similar to soc_camera_apply_sensor_flags() and
soc_camera_bus_param_compatible().
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/soc_camera.c | 34 | ||||
-rw-r--r-- | drivers/media/video/soc_mediabus.c | 33 | ||||
-rw-r--r-- | include/media/soc_camera.h | 6 | ||||
-rw-r--r-- | include/media/soc_mediabus.h | 2 |
4 files changed, 73 insertions, 2 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 5bdfe7e16bc1..8b16152f52fe 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -108,6 +108,40 @@ const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc( | |||
108 | EXPORT_SYMBOL(soc_camera_xlate_by_fourcc); | 108 | EXPORT_SYMBOL(soc_camera_xlate_by_fourcc); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * soc_camera_apply_board_flags() - apply platform SOCAM_SENSOR_INVERT_* flags | ||
112 | * @icl: camera platform parameters | ||
113 | * @cfg: media bus configuration | ||
114 | * @return: resulting flags | ||
115 | */ | ||
116 | unsigned long soc_camera_apply_board_flags(struct soc_camera_link *icl, | ||
117 | const struct v4l2_mbus_config *cfg) | ||
118 | { | ||
119 | unsigned long f, flags = cfg->flags; | ||
120 | |||
121 | /* If only one of the two polarities is supported, switch to the opposite */ | ||
122 | if (icl->flags & SOCAM_SENSOR_INVERT_HSYNC) { | ||
123 | f = flags & (V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_LOW); | ||
124 | if (f == V4L2_MBUS_HSYNC_ACTIVE_HIGH || f == V4L2_MBUS_HSYNC_ACTIVE_LOW) | ||
125 | flags ^= V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_LOW; | ||
126 | } | ||
127 | |||
128 | if (icl->flags & SOCAM_SENSOR_INVERT_VSYNC) { | ||
129 | f = flags & (V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW); | ||
130 | if (f == V4L2_MBUS_VSYNC_ACTIVE_HIGH || f == V4L2_MBUS_VSYNC_ACTIVE_LOW) | ||
131 | flags ^= V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW; | ||
132 | } | ||
133 | |||
134 | if (icl->flags & SOCAM_SENSOR_INVERT_PCLK) { | ||
135 | f = flags & (V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING); | ||
136 | if (f == V4L2_MBUS_PCLK_SAMPLE_RISING || f == V4L2_MBUS_PCLK_SAMPLE_FALLING) | ||
137 | flags ^= V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING; | ||
138 | } | ||
139 | |||
140 | return flags; | ||
141 | } | ||
142 | EXPORT_SYMBOL(soc_camera_apply_board_flags); | ||
143 | |||
144 | /** | ||
111 | * soc_camera_apply_sensor_flags() - apply platform SOCAM_SENSOR_INVERT_* flags | 145 | * soc_camera_apply_sensor_flags() - apply platform SOCAM_SENSOR_INVERT_* flags |
112 | * @icl: camera platform parameters | 146 | * @icl: camera platform parameters |
113 | * @flags: flags to be inverted according to platform configuration | 147 | * @flags: flags to be inverted according to platform configuration |
diff --git a/drivers/media/video/soc_mediabus.c b/drivers/media/video/soc_mediabus.c index bea7c9cf4f88..cf7f2194ded4 100644 --- a/drivers/media/video/soc_mediabus.c +++ b/drivers/media/video/soc_mediabus.c | |||
@@ -383,6 +383,39 @@ const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( | |||
383 | } | 383 | } |
384 | EXPORT_SYMBOL(soc_mbus_get_fmtdesc); | 384 | EXPORT_SYMBOL(soc_mbus_get_fmtdesc); |
385 | 385 | ||
386 | unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg, | ||
387 | unsigned int flags) | ||
388 | { | ||
389 | unsigned long common_flags; | ||
390 | bool hsync = true, vsync = true, pclk, data, mode; | ||
391 | bool mipi_lanes, mipi_clock; | ||
392 | |||
393 | common_flags = cfg->flags & flags; | ||
394 | |||
395 | switch (cfg->type) { | ||
396 | case V4L2_MBUS_PARALLEL: | ||
397 | hsync = common_flags & (V4L2_MBUS_HSYNC_ACTIVE_HIGH | | ||
398 | V4L2_MBUS_HSYNC_ACTIVE_LOW); | ||
399 | vsync = common_flags & (V4L2_MBUS_VSYNC_ACTIVE_HIGH | | ||
400 | V4L2_MBUS_VSYNC_ACTIVE_LOW); | ||
401 | case V4L2_MBUS_BT656: | ||
402 | pclk = common_flags & (V4L2_MBUS_PCLK_SAMPLE_RISING | | ||
403 | V4L2_MBUS_PCLK_SAMPLE_FALLING); | ||
404 | data = common_flags & (V4L2_MBUS_DATA_ACTIVE_HIGH | | ||
405 | V4L2_MBUS_DATA_ACTIVE_LOW); | ||
406 | mode = common_flags & (V4L2_MBUS_MASTER | V4L2_MBUS_SLAVE); | ||
407 | return (!hsync || !vsync || !pclk || !data || !mode) ? | ||
408 | 0 : common_flags; | ||
409 | case V4L2_MBUS_CSI2: | ||
410 | mipi_lanes = common_flags & V4L2_MBUS_CSI2_LANES; | ||
411 | mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK | | ||
412 | V4L2_MBUS_CSI2_CONTINUOUS_CLOCK); | ||
413 | return (!mipi_lanes || !mipi_clock) ? 0 : common_flags; | ||
414 | } | ||
415 | return 0; | ||
416 | } | ||
417 | EXPORT_SYMBOL(soc_mbus_config_compatible); | ||
418 | |||
386 | static int __init soc_mbus_init(void) | 419 | static int __init soc_mbus_init(void) |
387 | { | 420 | { |
388 | return 0; | 421 | return 0; |
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 7582952dceae..936a504f0bac 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h | |||
@@ -300,8 +300,10 @@ static inline void soc_camera_limit_side(int *start, int *length, | |||
300 | *start = start_min + length_max - *length; | 300 | *start = start_min + length_max - *length; |
301 | } | 301 | } |
302 | 302 | ||
303 | extern unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl, | 303 | unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl, |
304 | unsigned long flags); | 304 | unsigned long flags); |
305 | unsigned long soc_camera_apply_board_flags(struct soc_camera_link *icl, | ||
306 | const struct v4l2_mbus_config *cfg); | ||
305 | 307 | ||
306 | /* This is only temporary here - until v4l2-subdev begins to link to video_device */ | 308 | /* This is only temporary here - until v4l2-subdev begins to link to video_device */ |
307 | #include <linux/i2c.h> | 309 | #include <linux/i2c.h> |
diff --git a/include/media/soc_mediabus.h b/include/media/soc_mediabus.h index fae432544b41..73f1e7eb60f3 100644 --- a/include/media/soc_mediabus.h +++ b/include/media/soc_mediabus.h | |||
@@ -82,5 +82,7 @@ const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( | |||
82 | s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf); | 82 | s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf); |
83 | int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf, | 83 | int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf, |
84 | unsigned int *numerator, unsigned int *denominator); | 84 | unsigned int *numerator, unsigned int *denominator); |
85 | unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg, | ||
86 | unsigned int flags); | ||
85 | 87 | ||
86 | #endif | 88 | #endif |