]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
v4l: xilinx-multi-scaler: ENUM_FMT map index with enabled format
authorSuresh Gupta <suresh.gupta@xilinx.com>
Fri, 5 Oct 2018 14:12:57 +0000 (19:42 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 8 Oct 2018 08:58:40 +0000 (10:58 +0200)
Returns formats which are enabled in DT.

Signed-off-by: Suresh Gupta <suresh.gupta@xilinx.com>
Reviewed-by: Hyun Kwon <hyun.kwon@xilinx.com>
Reviewed-by: Satish Kumar Nagireddy <satish.nagireddy.nagireddy@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/media/platform/xilinx/xilinx-multi-scaler.c

index d6cf76d9c81f4203c32b86c28b6190fac8f28a0b..96d7c013c148f808d3bb10e5ad927be1f019c4fb 100644 (file)
@@ -1233,14 +1233,19 @@ static int xm2msc_g_fmt_vid_cap(struct file *file, void *fh,
 static int enum_fmt(struct xm2m_msc_dev *xm2msc, struct v4l2_fmtdesc *f)
 {
        const struct xm2msc_fmt *fmt;
+       unsigned int i, enabled = 0;
 
-       if (f->index == ARRAY_SIZE(formats) ||
-           !xm2msc_chk_fmt(xm2msc, f->index))
+       for (i = 0; i < ARRAY_SIZE(formats); i++) {
+               if (xm2msc_chk_fmt(xm2msc, i) && enabled++ == f->index)
+                       break;
+       }
+
+       if (i == ARRAY_SIZE(formats))
                /* Format not found */
                return -EINVAL;
 
        /* Format found */
-       fmt = &formats[f->index];
+       fmt = &formats[i];
        strlcpy(f->description, fmt->name,
                sizeof(f->description));
        f->pixelformat = fmt->fourcc;