aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/staging/media/imx/imx-media-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/media/imx/imx-media-utils.c')
-rw-r--r--drivers/staging/media/imx/imx-media-utils.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c
index c2088f7ceef5..5128915a5d6f 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -283,9 +283,11 @@ EXPORT_SYMBOL_GPL(imx_media_find_mbus_format);
* @index: The requested match index.
* @fmt_sel: Include in the enumeration entries with the given selection
* criteria.
+ * @code: If non-zero, only include in the enumeration entries matching this
+ * media bus code.
*/
int imx_media_enum_pixel_formats(u32 *fourcc, u32 index,
- enum imx_pixfmt_sel fmt_sel)
+ enum imx_pixfmt_sel fmt_sel, u32 code)
{
bool sel_ipu = fmt_sel & PIXFMT_SEL_IPU;
unsigned int i;
@@ -306,6 +308,25 @@ int imx_media_enum_pixel_formats(u32 *fourcc, u32 index,
if (!(fmt_sel & sel))
continue;
+ /*
+ * If a media bus code is specified, only consider formats that
+ * match it.
+ */
+ if (code) {
+ unsigned int j;
+
+ if (!fmt->codes)
+ continue;
+
+ for (j = 0; fmt->codes[j]; j++) {
+ if (code == fmt->codes[j])
+ break;
+ }
+
+ if (!fmt->codes[j])
+ continue;
+ }
+
if (index == 0) {
*fourcc = fmt->fourcc;
return 0;