[media] smiapp: Take valid link frequencies into account in supported mbus codes
authorSakari Ailus <sakari.ailus@iki.fi>
Tue, 16 Sep 2014 21:08:30 +0000 (18:08 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 28 Oct 2014 15:42:55 +0000 (13:42 -0200)
Some media bus codes may be unavailable depending on the available media bus
codes.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/i2c/smiapp/smiapp-core.c

index d65521abf0cc5491ed31152a36efe675f03d1fd1..926f60c00ba172088d767795610d6827fd1a42f7 100644 (file)
@@ -806,14 +806,6 @@ static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor)
                        dev_dbg(&client->dev, "jolly good! %d\n", j);
 
                        sensor->default_mbus_frame_fmts |= 1 << j;
-                       if (!sensor->csi_format
-                           || f->width > sensor->csi_format->width
-                           || (f->width == sensor->csi_format->width
-                               && f->compressed
-                               > sensor->csi_format->compressed)) {
-                               sensor->csi_format = f;
-                               sensor->internal_csi_format = f;
-                       }
                }
        }
 
@@ -850,6 +842,22 @@ static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor)
 
                        set_bit(j, valid_link_freqs);
                }
+
+               if (!*valid_link_freqs) {
+                       dev_info(&client->dev,
+                                "no valid link frequencies for %u bpp\n",
+                                f->compressed);
+                       sensor->default_mbus_frame_fmts &= ~BIT(i);
+                       continue;
+               }
+
+               if (!sensor->csi_format
+                   || f->width > sensor->csi_format->width
+                   || (f->width == sensor->csi_format->width
+                       && f->compressed > sensor->csi_format->compressed)) {
+                       sensor->csi_format = f;
+                       sensor->internal_csi_format = f;
+               }
        }
 
        if (!sensor->csi_format) {