]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
driver: media: tegra: add sensor mode cid
authoresen chen <esenc@nvidia.com>
Tue, 26 Jul 2016 04:54:46 +0000 (12:54 +0800)
committermobile promotions <svcmobile_promotions@nvidia.com>
Wed, 27 Jul 2016 04:38:45 +0000 (21:38 -0700)
Add V4L2_CID_SENSOR_MODE_ID to help sensor modes setting
Using use_sensor_mode_id in dt enable PCL to set mode id

Bug 200168141

Change-Id: I6d90fcbcb709e9e5d8cc8fe2bbd906005f8d4e70
Signed-off-by: esen chen <esenc@nvidia.com>
Reviewed-on: http://git-master/r/1190587
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jihoon Bang <jbang@nvidia.com>
drivers/media/platform/tegra/camera/camera_common.c
include/media/camera_common.h

index a7f0e521f7940e74de8f2f2b1de07e2949899bf1..b14dc0ecd1fc6e44c2ad3d0adf5e434f0873a460 100644 (file)
@@ -428,28 +428,39 @@ int camera_common_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
        s_data->fmt_height = s_data->def_height;
        s_data->fmt_maxfps = s_data->def_maxfps;
 
-       for (i = 0; i < s_data->numfmts; i++) {
-               if (mf->width == frmfmt[i].size.width &&
-                   mf->height == frmfmt[i].size.height &&
-                   mf->maxframerate == frmfmt[i].framerates[0] &&
-                   hdr_en == frmfmt[i].hdr_en) {
-                       s_data->mode = frmfmt[i].mode;
-                       s_data->fmt_width = mf->width;
-                       s_data->fmt_height = mf->height;
-                       s_data->fmt_maxfps = mf->maxframerate;
-                       break;
+       if (s_data->use_sensor_mode_id &&
+               s_data->sensor_mode_id >= 0 &&
+               s_data->sensor_mode_id < s_data->numfmts) {
+               dev_dbg(&client->dev, "%s: use_sensor_mode_id %d\n",
+                               __func__, s_data->sensor_mode_id);
+               s_data->mode = frmfmt[s_data->sensor_mode_id].mode;
+               s_data->fmt_width = mf->width;
+               s_data->fmt_height = mf->height;
+               s_data->fmt_maxfps = mf->maxframerate;
+       } else {
+               for (i = 0; i < s_data->numfmts; i++) {
+                       if (mf->width == frmfmt[i].size.width &&
+                               mf->height == frmfmt[i].size.height &&
+                               mf->maxframerate == frmfmt[i].framerates[0] &&
+                               hdr_en == frmfmt[i].hdr_en) {
+                               s_data->mode = frmfmt[i].mode;
+                               s_data->fmt_width = mf->width;
+                               s_data->fmt_height = mf->height;
+                               s_data->fmt_maxfps = mf->maxframerate;
+                               break;
+                       }
                }
-       }
 
-       if (i == s_data->numfmts) {
-               mf->width = s_data->fmt_width;
-               mf->height = s_data->fmt_height;
-               mf->maxframerate = s_data->fmt_maxfps;
-               dev_dbg(&client->dev,
-                       "%s: invalid resolution supplied(set mode) %d %d %d\n",
-                       __func__, mf->width, mf->height, mf->maxframerate);
+               if (i == s_data->numfmts) {
+                       mf->width = s_data->fmt_width;
+                       mf->height = s_data->fmt_height;
+                       mf->maxframerate = s_data->fmt_maxfps;
+                       dev_dbg(&client->dev,
+                               "%s: invalid resolution supplied(set mode) %d %d %d\n",
+                               __func__, mf->width,
+                               mf->height, mf->maxframerate);
+               }
        }
-
        if (mf->code != V4L2_MBUS_FMT_SRGGB8_1X8 &&
                mf->code != V4L2_MBUS_FMT_SRGGB10_1X10) {
                mf->code = V4L2_MBUS_FMT_SRGGB10_1X10;
index effb71bae0923be825b73f1cf5f85717d41c4b4e..51a051dbd9baf2b949c650f8578fb2d583322a34 100644 (file)
@@ -57,6 +57,7 @@
 #define V4L2_CID_GAIN                          (V4L2_CID_TEGRA_CAMERA_BASE+10)
 #define V4L2_CID_EXPOSURE                      (V4L2_CID_TEGRA_CAMERA_BASE+11)
 #define V4L2_CID_FRAME_RATE                    (V4L2_CID_TEGRA_CAMERA_BASE+12)
+#define V4L2_CID_SENSOR_MODE_ID                (V4L2_CID_TEGRA_CAMERA_BASE+13)
 
 #define MAX_BUFFER_SIZE                        32
 #define MAX_CID_CONTROLS               16
@@ -202,6 +203,8 @@ struct camera_common_data {
        int     def_mode, def_width, def_height, def_maxfps;
        int     def_clk_freq;
        int     fmt_width, fmt_height, fmt_maxfps;
+       int     sensor_mode_id;
+       bool    use_sensor_mode_id;
 };
 
 struct camera_common_focuser_data;