diff options
| author | Bhanu Murthy V <bmurthyv@nvidia.com> | 2017-12-05 20:56:46 -0500 |
|---|---|---|
| committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-12-13 20:20:49 -0500 |
| commit | 07857ffeb5a350e6d5fc9d5c4b3d56ff4434d7ab (patch) | |
| tree | 1dc3fb7db0008f8ec82f52b9f417219dc0850e03 /include/media | |
| parent | d00c9880a68fb83d1696e74f841d8226681ce586 (diff) | |
drivers: media: tegra: Tegra Camera framework
Tegra camera device register - Takes care of
necessary initialization to work with common
framework for tegra
Tegra camera v4l2device register - Takes care of
v4l2 subdevice initialization and Async framework
initialization to bind with v4l2device.
In addition, tegra camera control layer is setup
for the sensor drivers to add controls selectively.
As next step all the v4l2 controls in tegra camera
drivers will be added here.
The common framework initializes the drivers based
on the device tree properties to setup for each
sensor mode.
Bug 1946718
Change-Id: I1f8dbce452248e9749c473bb83c4ea86e42ef531
Signed-off-by: Bhanu Murthy V <bmurthyv@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1611726
Reviewed-by: Frank Chen <frankc@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jihoon Bang <jbang@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'include/media')
| -rw-r--r-- | include/media/camera_common.h | 42 | ||||
| -rw-r--r-- | include/media/tegra-v4l2-camera.h | 13 | ||||
| -rw-r--r-- | include/media/tegracam_core.h | 49 |
3 files changed, 104 insertions, 0 deletions
diff --git a/include/media/camera_common.h b/include/media/camera_common.h index 674a29e6c..6c3ae9531 100644 --- a/include/media/camera_common.h +++ b/include/media/camera_common.h | |||
| @@ -158,16 +158,42 @@ struct camera_common_framesync { | |||
| 158 | struct camera_common_data; | 158 | struct camera_common_data; |
| 159 | 159 | ||
| 160 | struct camera_common_sensor_ops { | 160 | struct camera_common_sensor_ops { |
| 161 | u32 numfrmfmts; | ||
| 162 | const struct camera_common_frmfmt *frmfmt_table; | ||
| 161 | int (*power_on)(struct camera_common_data *s_data); | 163 | int (*power_on)(struct camera_common_data *s_data); |
| 162 | int (*power_off)(struct camera_common_data *s_data); | 164 | int (*power_off)(struct camera_common_data *s_data); |
| 163 | int (*write_reg)(struct camera_common_data *s_data, | 165 | int (*write_reg)(struct camera_common_data *s_data, |
| 164 | u16 addr, u8 val); | 166 | u16 addr, u8 val); |
| 165 | int (*read_reg)(struct camera_common_data *s_data, | 167 | int (*read_reg)(struct camera_common_data *s_data, |
| 166 | u16 addr, u8 *val); | 168 | u16 addr, u8 *val); |
| 169 | struct camera_common_pdata *(*parse_dt)(struct device *dev); | ||
| 170 | int (*power_get)(struct camera_common_data *s_data); | ||
| 171 | int (*power_put)(struct camera_common_data *s_data); | ||
| 167 | int (*get_framesync)(struct camera_common_data *s_data, | 172 | int (*get_framesync)(struct camera_common_data *s_data, |
| 168 | struct camera_common_framesync *vshs); | 173 | struct camera_common_framesync *vshs); |
| 169 | }; | 174 | }; |
| 170 | 175 | ||
| 176 | struct tegracam_ctrl_ops { | ||
| 177 | u32 numctrls; | ||
| 178 | u32 string_ctrl_size[TEGRA_CAM_MAX_STRING_CONTROLS]; | ||
| 179 | const u32 *ctrl_cid_list; | ||
| 180 | int (*set_gain)(struct camera_common_data *s_data, s64 val); | ||
| 181 | int (*set_exposure)(struct camera_common_data *s_data, s64 val); | ||
| 182 | int (*set_frame_rate)(struct camera_common_data *s_data, s64 val); | ||
| 183 | int (*set_group_hold)(struct camera_common_data *s_data, bool val); | ||
| 184 | int (*fill_string_ctrl)(struct camera_common_data *s_data, | ||
| 185 | struct v4l2_ctrl *ctrl); | ||
| 186 | }; | ||
| 187 | |||
| 188 | struct tegracam_ctrl_handler { | ||
| 189 | struct v4l2_ctrl_handler ctrl_handler; | ||
| 190 | const struct tegracam_ctrl_ops *ctrl_ops; | ||
| 191 | struct camera_common_data *s_data; | ||
| 192 | |||
| 193 | int numctrls; | ||
| 194 | struct v4l2_ctrl *ctrls[MAX_CID_CONTROLS]; | ||
| 195 | }; | ||
| 196 | |||
| 171 | struct camera_common_data { | 197 | struct camera_common_data { |
| 172 | struct camera_common_sensor_ops *ops; | 198 | struct camera_common_sensor_ops *ops; |
| 173 | struct v4l2_ctrl_handler *ctrl_handler; | 199 | struct v4l2_ctrl_handler *ctrl_handler; |
| @@ -181,6 +207,10 @@ struct camera_common_data { | |||
| 181 | struct v4l2_ctrl **ctrls; | 207 | struct v4l2_ctrl **ctrls; |
| 182 | 208 | ||
| 183 | struct sensor_properties sensor_props; | 209 | struct sensor_properties sensor_props; |
| 210 | /* TODO: cleanup neeeded once all the sensors adapt new framework */ | ||
| 211 | struct tegracam_ctrl_handler *tegracam_ctrl_hdl; | ||
| 212 | struct regmap *regmap; | ||
| 213 | struct camera_common_pdata *pdata; | ||
| 184 | 214 | ||
| 185 | void *priv; | 215 | void *priv; |
| 186 | int numctrls; | 216 | int numctrls; |
| @@ -247,6 +277,9 @@ int camera_common_parse_clocks(struct device *dev, | |||
| 247 | struct camera_common_pdata *pdata); | 277 | struct camera_common_pdata *pdata); |
| 248 | int camera_common_parse_ports(struct device *dev, | 278 | int camera_common_parse_ports(struct device *dev, |
| 249 | struct camera_common_data *s_data); | 279 | struct camera_common_data *s_data); |
| 280 | int camera_common_mclk_enable(struct camera_common_data *s_data); | ||
| 281 | void camera_common_mclk_disable(struct camera_common_data *s_data); | ||
| 282 | |||
| 250 | 283 | ||
| 251 | int camera_common_debugfs_show(struct seq_file *s, void *unused); | 284 | int camera_common_debugfs_show(struct seq_file *s, void *unused); |
| 252 | ssize_t camera_common_debugfs_write( | 285 | ssize_t camera_common_debugfs_write( |
| @@ -294,6 +327,15 @@ void camera_common_cleanup(struct camera_common_data *s_data); | |||
| 294 | int camera_common_focuser_init(struct camera_common_focuser_data *s_data); | 327 | int camera_common_focuser_init(struct camera_common_focuser_data *s_data); |
| 295 | int camera_common_focuser_s_power(struct v4l2_subdev *sd, int on); | 328 | int camera_common_focuser_s_power(struct v4l2_subdev *sd, int on); |
| 296 | 329 | ||
| 330 | const struct camera_common_colorfmt *camera_common_find_pixelfmt( | ||
| 331 | unsigned int pix_fmt); | ||
| 332 | |||
| 333 | /* common control layer init */ | ||
| 334 | int tegracam_ctrl_handler_init(struct tegracam_ctrl_handler *handler); | ||
| 335 | int tegracam_init_ctrl_ranges_by_mode( | ||
| 336 | struct tegracam_ctrl_handler *handler, | ||
| 337 | u32 modeidx); | ||
| 338 | |||
| 297 | /* Regmap / RTCPU I2C driver interface */ | 339 | /* Regmap / RTCPU I2C driver interface */ |
| 298 | struct tegra_i2c_rtcpu_sensor; | 340 | struct tegra_i2c_rtcpu_sensor; |
| 299 | struct tegra_i2c_rtcpu_config; | 341 | struct tegra_i2c_rtcpu_config; |
diff --git a/include/media/tegra-v4l2-camera.h b/include/media/tegra-v4l2-camera.h index 5c5e2da75..4b6b54e47 100644 --- a/include/media/tegra-v4l2-camera.h +++ b/include/media/tegra-v4l2-camera.h | |||
| @@ -67,6 +67,11 @@ | |||
| 67 | */ | 67 | */ |
| 68 | #define FIXED_POINT_SCALING_FACTOR (1ULL << 22) | 68 | #define FIXED_POINT_SCALING_FACTOR (1ULL << 22) |
| 69 | 69 | ||
| 70 | #define TEGRA_CAM_MAX_STRING_CONTROLS 8 | ||
| 71 | #define TEGRA_CAM_STRING_CTRL_EEPROM_INDEX 0 | ||
| 72 | #define TEGRA_CAM_STRING_CTRL_FUSEID_INDEX 1 | ||
| 73 | #define TEGRA_CAM_STRING_CTRL_OTP_INDEX 2 | ||
| 74 | |||
| 70 | struct unpackedU64 { | 75 | struct unpackedU64 { |
| 71 | __u32 high; | 76 | __u32 high; |
| 72 | __u32 low; | 77 | __u32 low; |
| @@ -86,6 +91,7 @@ struct sensor_signal_properties { | |||
| 86 | __u32 discontinuous_clk; | 91 | __u32 discontinuous_clk; |
| 87 | __u32 dpcm_enable; | 92 | __u32 dpcm_enable; |
| 88 | __u32 tegra_sinterface; | 93 | __u32 tegra_sinterface; |
| 94 | __u32 reserved[7]; | ||
| 89 | }; | 95 | }; |
| 90 | 96 | ||
| 91 | struct sensor_image_properties { | 97 | struct sensor_image_properties { |
| @@ -94,6 +100,7 @@ struct sensor_image_properties { | |||
| 94 | __u32 line_length; | 100 | __u32 line_length; |
| 95 | __u32 pixel_format; | 101 | __u32 pixel_format; |
| 96 | __u32 embedded_metadata_height; | 102 | __u32 embedded_metadata_height; |
| 103 | __u32 reserved[11]; | ||
| 97 | }; | 104 | }; |
| 98 | 105 | ||
| 99 | struct sensor_dv_timings { | 106 | struct sensor_dv_timings { |
| @@ -103,6 +110,7 @@ struct sensor_dv_timings { | |||
| 103 | __u32 vfrontporch; | 110 | __u32 vfrontporch; |
| 104 | __u32 vsync; | 111 | __u32 vsync; |
| 105 | __u32 vbackporch; | 112 | __u32 vbackporch; |
| 113 | __u32 reserved[10]; | ||
| 106 | }; | 114 | }; |
| 107 | 115 | ||
| 108 | struct sensor_control_properties { | 116 | struct sensor_control_properties { |
| @@ -117,6 +125,11 @@ struct sensor_control_properties { | |||
| 117 | __u32 max_framerate; | 125 | __u32 max_framerate; |
| 118 | union __u64val min_exp_time; | 126 | union __u64val min_exp_time; |
| 119 | union __u64val max_exp_time; | 127 | union __u64val max_exp_time; |
| 128 | __u32 step_gain_val; | ||
| 129 | __u32 step_framerate; | ||
| 130 | __u32 exposure_factor; | ||
| 131 | union __u64val step_exp_time; | ||
| 132 | __u32 reserved[14]; | ||
| 120 | }; | 133 | }; |
| 121 | 134 | ||
| 122 | struct sensor_mode_properties { | 135 | struct sensor_mode_properties { |
diff --git a/include/media/tegracam_core.h b/include/media/tegracam_core.h new file mode 100644 index 000000000..1a1e8a2f5 --- /dev/null +++ b/include/media/tegracam_core.h | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | /** | ||
| 2 | * tegracam_core.h - tegra camera framework core utilities | ||
| 3 | * | ||
| 4 | * Copyright (c) 2017, NVIDIA Corporation. All rights reserved. | ||
| 5 | * | ||
| 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, | ||
| 8 | * version 2, as published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 13 | * more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef __TEGRACAM_CORE_H__ | ||
| 20 | #define __TEGRACAM_CORE_H__ | ||
| 21 | |||
| 22 | #include <media/camera_common.h> | ||
| 23 | |||
| 24 | struct tegracam_device { | ||
| 25 | struct camera_common_data *s_data; | ||
| 26 | struct media_pad pad; | ||
| 27 | /* variables to be filled by the driver to register */ | ||
| 28 | char name[32]; | ||
| 29 | struct i2c_client *client; | ||
| 30 | struct device *dev; | ||
| 31 | u32 numctrls; | ||
| 32 | const u32 *ctrl_cid_list; | ||
| 33 | const struct regmap_config *dev_regmap_config; | ||
| 34 | struct camera_common_sensor_ops *sensor_ops; | ||
| 35 | const struct v4l2_subdev_ops *v4l2sd_ops; | ||
| 36 | const struct v4l2_subdev_internal_ops *v4l2sd_internal_ops; | ||
| 37 | const struct media_entity_operations *media_ops; | ||
| 38 | const struct tegracam_ctrl_ops *tcctrl_ops; | ||
| 39 | }; | ||
| 40 | |||
| 41 | void tegracam_set_privdata(struct tegracam_device *tc_dev, void *priv); | ||
| 42 | void *tegracam_get_privdata(struct tegracam_device *tc_dev); | ||
| 43 | |||
| 44 | int tegracam_v4l2subdev_register(struct tegracam_device *tc_dev, | ||
| 45 | bool is_sensor); | ||
| 46 | void tegracam_v4l2subdev_unregister(struct tegracam_device *tc_dev); | ||
| 47 | int tegracam_device_register(struct tegracam_device *tc_dev); | ||
| 48 | void tegracam_device_unregister(struct tegracam_device *tc_dev); | ||
| 49 | #endif | ||
