[1/2] V4L: soc-camera: add a function to lookup xlate by mediabus code
Commit Message
In addition to a helper function, performing a format translation table
lookup by a fourcc value, a similar function is now needed to lookup
translation table entries by mediabus codes.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
drivers/media/video/soc_camera.c | 14 +++++++++++++-
include/media/soc_camera.h | 5 ++++-
2 files changed, 17 insertions(+), 2 deletions(-)
@@ -112,7 +112,7 @@ static int soc_camera_power_off(struct soc_camera_device *icd,
}
const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
- struct soc_camera_device *icd, unsigned int fourcc)
+ const struct soc_camera_device *icd, unsigned int fourcc)
{
unsigned int i;
@@ -123,6 +123,18 @@ const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
}
EXPORT_SYMBOL(soc_camera_xlate_by_fourcc);
+const struct soc_camera_format_xlate *soc_camera_xlate_by_mcode(
+ const struct soc_camera_device *icd, enum v4l2_mbus_pixelcode code)
+{
+ unsigned int i;
+
+ for (i = 0; i < icd->num_user_formats; i++)
+ if (icd->user_formats[i].code == code)
+ return icd->user_formats + i;
+ return NULL;
+}
+EXPORT_SYMBOL(soc_camera_xlate_by_mcode);
+
/**
* soc_camera_apply_board_flags() - apply platform SOCAM_SENSOR_INVERT_* flags
* @icl: camera platform parameters
@@ -174,7 +174,10 @@ int soc_camera_host_register(struct soc_camera_host *ici);
void soc_camera_host_unregister(struct soc_camera_host *ici);
const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
- struct soc_camera_device *icd, unsigned int fourcc);
+ const struct soc_camera_device *icd, unsigned int fourcc);
+
+const struct soc_camera_format_xlate *soc_camera_xlate_by_mcode(
+ const struct soc_camera_device *icd, enum v4l2_mbus_pixelcode code);
/**
* struct soc_camera_format_xlate - match between host and sensor formats