diff options
| author | Bhanu Murthy V <bmurthyv@nvidia.com> | 2018-10-31 23:00:26 -0400 |
|---|---|---|
| committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2019-02-01 02:28:02 -0500 |
| commit | 00baf48dcdb76c94d12ec2457b608e17f2a9f1ac (patch) | |
| tree | 01a563768b8e247a70ecbf7e5aacc32f74731873 | |
| parent | d67df23b0aa8740daee98386b6fe09ce0afc4ea5 (diff) | |
drivers: camera: Support sensor blobs in controls
Add mode and control blobs for sensor safety architecture.
Add support for tvcf to expose control context apis to
prepare control blobs.
Bug 2433156
Change-Id: If2ada23eb52f7b55545db8cd1d4bf29efc333af1
Signed-off-by: Bhanu Murthy V <bmurthyv@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1941463
(cherry picked from commit cc9b60122046565200fb42c1159d612764d1bca8)
Reviewed-on: https://git-master.nvidia.com/r/2006763
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Tested-by: Ian Kaszubski <ikaszubski@nvidia.com>
Reviewed-by: Vincent Chung <vincentc@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
| -rw-r--r-- | drivers/media/platform/tegra/camera/tegracam_core.c | 2 | ||||
| -rw-r--r-- | drivers/media/platform/tegra/camera/tegracam_ctrls.c | 62 | ||||
| -rw-r--r-- | drivers/media/platform/tegra/camera/tegracam_v4l2.c | 16 | ||||
| -rw-r--r-- | include/media/camera_common.h | 16 |
4 files changed, 87 insertions, 9 deletions
diff --git a/drivers/media/platform/tegra/camera/tegracam_core.c b/drivers/media/platform/tegra/camera/tegracam_core.c index 9df1c3ea4..0165749f6 100644 --- a/drivers/media/platform/tegra/camera/tegracam_core.c +++ b/drivers/media/platform/tegra/camera/tegracam_core.c | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | /* use semantic versioning convention */ | 22 | /* use semantic versioning convention */ |
| 23 | #define TEGRACAM_MAJOR_VERSION 2 | 23 | #define TEGRACAM_MAJOR_VERSION 2 |
| 24 | #define TEGRACAM_MINOR_VERSION 0 | 24 | #define TEGRACAM_MINOR_VERSION 0 |
| 25 | #define TEGRACAM_PATCH_VERSION 2 | 25 | #define TEGRACAM_PATCH_VERSION 3 |
| 26 | 26 | ||
| 27 | u32 tegracam_version(u8 major, u8 minor, u8 patch) | 27 | u32 tegracam_version(u8 major, u8 minor, u8 patch) |
| 28 | { | 28 | { |
diff --git a/drivers/media/platform/tegra/camera/tegracam_ctrls.c b/drivers/media/platform/tegra/camera/tegracam_ctrls.c index 1b4542770..06bc8c941 100644 --- a/drivers/media/platform/tegra/camera/tegracam_ctrls.c +++ b/drivers/media/platform/tegra/camera/tegracam_ctrls.c | |||
| @@ -218,18 +218,17 @@ static int tegracam_setup_string_ctrls(struct tegracam_device *tc_dev, | |||
| 218 | return 0; | 218 | return 0; |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | static int tegracam_s_ctrl(struct v4l2_ctrl *ctrl) | 221 | static int tegracam_set_ctrls(struct tegracam_ctrl_handler *handler, |
| 222 | struct v4l2_ctrl *ctrl) | ||
| 222 | { | 223 | { |
| 223 | struct tegracam_ctrl_handler *handler = | ||
| 224 | container_of(ctrl->handler, | ||
| 225 | struct tegracam_ctrl_handler, ctrl_handler); | ||
| 226 | const struct tegracam_ctrl_ops *ops = handler->ctrl_ops; | 224 | const struct tegracam_ctrl_ops *ops = handler->ctrl_ops; |
| 227 | struct tegracam_device *tc_dev = handler->tc_dev; | 225 | struct tegracam_device *tc_dev = handler->tc_dev; |
| 228 | struct camera_common_data *s_data = tc_dev->s_data; | 226 | struct camera_common_data *s_data = tc_dev->s_data; |
| 229 | int err = 0; | 227 | int err = 0; |
| 230 | u32 status = 0; | 228 | u32 status = 0; |
| 231 | 229 | ||
| 232 | if (v4l2_subdev_call(&s_data->subdev, video, g_input_status, &status)) { | 230 | if (v4l2_subdev_call(&s_data->subdev, video, |
| 231 | g_input_status, &status)) { | ||
| 233 | dev_err(s_data->dev, "power status query unsupported\n"); | 232 | dev_err(s_data->dev, "power status query unsupported\n"); |
| 234 | return -ENOTTY; | 233 | return -ENOTTY; |
| 235 | } | 234 | } |
| @@ -256,6 +255,7 @@ static int tegracam_s_ctrl(struct v4l2_ctrl *ctrl) | |||
| 256 | break; | 255 | break; |
| 257 | case TEGRA_CAMERA_CID_SENSOR_MODE_ID: | 256 | case TEGRA_CAMERA_CID_SENSOR_MODE_ID: |
| 258 | s_data->sensor_mode_id = (int) (*ctrl->p_new.p_s64); | 257 | s_data->sensor_mode_id = (int) (*ctrl->p_new.p_s64); |
| 258 | break; | ||
| 259 | case TEGRA_CAMERA_CID_HDR_EN: | 259 | case TEGRA_CAMERA_CID_HDR_EN: |
| 260 | break; | 260 | break; |
| 261 | default: | 261 | default: |
| @@ -266,6 +266,58 @@ static int tegracam_s_ctrl(struct v4l2_ctrl *ctrl) | |||
| 266 | return err; | 266 | return err; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | static int tegracam_set_ctrls_ex(struct tegracam_ctrl_handler *handler, | ||
| 270 | struct v4l2_ctrl *ctrl) | ||
| 271 | { | ||
| 272 | const struct tegracam_ctrl_ops *ops = handler->ctrl_ops; | ||
| 273 | struct tegracam_device *tc_dev = handler->tc_dev; | ||
| 274 | struct camera_common_data *s_data = tc_dev->s_data; | ||
| 275 | struct tegracam_sensor_data *sensor_data = &handler->sensor_data; | ||
| 276 | struct sensor_blob *blob = &sensor_data->ctrls_blob; | ||
| 277 | int err = 0; | ||
| 278 | |||
| 279 | switch (ctrl->id) { | ||
| 280 | case TEGRA_CAMERA_CID_GAIN: | ||
| 281 | err = ops->set_gain_ex(tc_dev, blob, *ctrl->p_new.p_s64); | ||
| 282 | break; | ||
| 283 | case TEGRA_CAMERA_CID_FRAME_RATE: | ||
| 284 | err = ops->set_frame_rate_ex(tc_dev, blob, *ctrl->p_new.p_s64); | ||
| 285 | break; | ||
| 286 | case TEGRA_CAMERA_CID_EXPOSURE: | ||
| 287 | err = ops->set_exposure_ex(tc_dev, blob, *ctrl->p_new.p_s64); | ||
| 288 | break; | ||
| 289 | case TEGRA_CAMERA_CID_GROUP_HOLD: | ||
| 290 | err = ops->set_group_hold_ex(tc_dev, blob, ctrl->val); | ||
| 291 | break; | ||
| 292 | case TEGRA_CAMERA_CID_SENSOR_MODE_ID: | ||
| 293 | s_data->sensor_mode_id = (int) (*ctrl->p_new.p_s64); | ||
| 294 | break; | ||
| 295 | case TEGRA_CAMERA_CID_HDR_EN: | ||
| 296 | break; | ||
| 297 | default: | ||
| 298 | pr_err("%s: unknown ctrl id.\n", __func__); | ||
| 299 | return -EINVAL; | ||
| 300 | } | ||
| 301 | |||
| 302 | return err; | ||
| 303 | } | ||
| 304 | |||
| 305 | |||
| 306 | static int tegracam_s_ctrl(struct v4l2_ctrl *ctrl) | ||
| 307 | { | ||
| 308 | struct tegracam_ctrl_handler *handler = | ||
| 309 | container_of(ctrl->handler, | ||
| 310 | struct tegracam_ctrl_handler, ctrl_handler); | ||
| 311 | const struct tegracam_ctrl_ops *ops = handler->ctrl_ops; | ||
| 312 | |||
| 313 | if (ops->is_blob_supported) | ||
| 314 | return tegracam_set_ctrls_ex(handler, ctrl); | ||
| 315 | else | ||
| 316 | return tegracam_set_ctrls(handler, ctrl); | ||
| 317 | |||
| 318 | return 0; | ||
| 319 | } | ||
| 320 | |||
| 269 | int tegracam_ctrl_set_overrides(struct tegracam_ctrl_handler *hdl) | 321 | int tegracam_ctrl_set_overrides(struct tegracam_ctrl_handler *hdl) |
| 270 | { | 322 | { |
| 271 | struct v4l2_ext_controls ctrls; | 323 | struct v4l2_ext_controls ctrls; |
diff --git a/drivers/media/platform/tegra/camera/tegracam_v4l2.c b/drivers/media/platform/tegra/camera/tegracam_v4l2.c index 1c40746e6..5ea18298a 100644 --- a/drivers/media/platform/tegra/camera/tegracam_v4l2.c +++ b/drivers/media/platform/tegra/camera/tegracam_v4l2.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * tegracam_core - tegra camera framework initialization | 2 | * tegracam_v4l2 - tegra camera framework for v4l2 support |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. | 4 | * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. |
| 5 | * | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, | 7 | * under the terms and conditions of the GNU General Public License, |
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 19 | #include <media/tegra-v4l2-camera.h> | 19 | #include <media/tegra-v4l2-camera.h> |
| 20 | #include <media/tegracam_core.h> | 20 | #include <media/tegracam_core.h> |
| 21 | #include <media/tegracam_utils.h> | ||
| 21 | 22 | ||
| 22 | static int v4l2sd_stream(struct v4l2_subdev *sd, int enable) | 23 | static int v4l2sd_stream(struct v4l2_subdev *sd, int enable) |
| 23 | { | 24 | { |
| @@ -25,10 +26,16 @@ static int v4l2sd_stream(struct v4l2_subdev *sd, int enable) | |||
| 25 | struct camera_common_data *s_data = to_camera_common_data(&client->dev); | 26 | struct camera_common_data *s_data = to_camera_common_data(&client->dev); |
| 26 | struct camera_common_sensor_ops *sensor_ops = s_data->ops; | 27 | struct camera_common_sensor_ops *sensor_ops = s_data->ops; |
| 27 | struct tegracam_device *tc_dev = to_tegracam_device(s_data); | 28 | struct tegracam_device *tc_dev = to_tegracam_device(s_data); |
| 29 | struct tegracam_sensor_data *sensor_data = &s_data->tegracam_ctrl_hdl->sensor_data; | ||
| 30 | struct sensor_blob *ctrl_blob = &sensor_data->ctrls_blob; | ||
| 31 | struct sensor_blob *mode_blob = &sensor_data->mode_blob; | ||
| 28 | int err; | 32 | int err; |
| 29 | 33 | ||
| 30 | dev_dbg(&client->dev, "%s++ enable %d\n", __func__, enable); | 34 | dev_dbg(&client->dev, "%s++ enable %d\n", __func__, enable); |
| 31 | 35 | ||
| 36 | /* reset control packet at start/stop streaming */ | ||
| 37 | memset(ctrl_blob, 0, sizeof(struct sensor_blob)); | ||
| 38 | memset(mode_blob, 0, sizeof(struct sensor_blob)); | ||
| 32 | if (enable) { | 39 | if (enable) { |
| 33 | err = sensor_ops->set_mode(tc_dev); | 40 | err = sensor_ops->set_mode(tc_dev); |
| 34 | if (err) { | 41 | if (err) { |
| @@ -51,12 +58,17 @@ static int v4l2sd_stream(struct v4l2_subdev *sd, int enable) | |||
| 51 | dev_err(&client->dev, "Error turning on streaming\n"); | 58 | dev_err(&client->dev, "Error turning on streaming\n"); |
| 52 | return err; | 59 | return err; |
| 53 | } | 60 | } |
| 61 | /* add done command for blobs */ | ||
| 62 | prepare_done_cmd(mode_blob); | ||
| 63 | prepare_done_cmd(ctrl_blob); | ||
| 54 | } else { | 64 | } else { |
| 55 | err = sensor_ops->stop_streaming(tc_dev); | 65 | err = sensor_ops->stop_streaming(tc_dev); |
| 56 | if (err) { | 66 | if (err) { |
| 57 | dev_err(&client->dev, "Error turning off streaming\n"); | 67 | dev_err(&client->dev, "Error turning off streaming\n"); |
