[media] smiapp: Set valid link frequency range
authorSakari Ailus <sakari.ailus@iki.fi>
Fri, 26 Sep 2014 13:19:43 +0000 (10:19 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 28 Oct 2014 15:44:06 +0000 (13:44 -0200)
Set supported link frequencies in the menu in control initialisation and
when the bpp changes.

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 416b7bd1142c462f87b0bc98e57755abd2b4ac24..f1a9f82dd44acd3dc623ef712c276f655eaaff93 100644 (file)
@@ -523,6 +523,8 @@ static const struct v4l2_ctrl_ops smiapp_ctrl_ops = {
 static int smiapp_init_controls(struct smiapp_sensor *sensor)
 {
        struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+       unsigned long *valid_link_freqs = &sensor->valid_link_freqs[
+               sensor->csi_format->compressed - SMIAPP_COMPRESSED_BASE];
        unsigned int max, i;
        int rval;
 
@@ -605,8 +607,8 @@ static int smiapp_init_controls(struct smiapp_sensor *sensor)
 
        sensor->link_freq = v4l2_ctrl_new_int_menu(
                &sensor->src->ctrl_handler, &smiapp_ctrl_ops,
-               V4L2_CID_LINK_FREQ, max, 0,
-               sensor->platform_data->op_sys_clock);
+               V4L2_CID_LINK_FREQ, __fls(*valid_link_freqs),
+               __ffs(*valid_link_freqs), sensor->platform_data->op_sys_clock);
 
        sensor->pixel_rate_csi = v4l2_ctrl_new_std(
                &sensor->src->ctrl_handler, &smiapp_ctrl_ops,
@@ -1735,6 +1737,7 @@ static int smiapp_set_format_source(struct v4l2_subdev *subdev,
        struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
        const struct smiapp_csi_data_format *csi_format,
                *old_csi_format = sensor->csi_format;
+       unsigned long *valid_link_freqs;
        u32 code = fmt->format.code;
        unsigned int i;
        int rval;
@@ -1765,6 +1768,18 @@ static int smiapp_set_format_source(struct v4l2_subdev *subdev,
                                sensor->test_data[i], 0,
                                (1 << csi_format->width) - 1, 1, 0);
 
+       if (csi_format->compressed == old_csi_format->compressed)
+               return 0;
+
+       valid_link_freqs = 
+               &sensor->valid_link_freqs[sensor->csi_format->compressed
+                                         - SMIAPP_COMPRESSED_BASE];
+
+       __v4l2_ctrl_modify_range(
+               sensor->link_freq, 0,
+               __fls(*valid_link_freqs), ~*valid_link_freqs,
+               __ffs(*valid_link_freqs));
+
        return 0;
 }