Surajit Podder | 0d812bf | 2018-02-02 13:37:24 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef _MSM_VIDC_INTERNAL_H_ |
| 15 | #define _MSM_VIDC_INTERNAL_H_ |
| 16 | |
| 17 | #include <linux/atomic.h> |
| 18 | #include <linux/list.h> |
| 19 | #include <linux/time.h> |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/completion.h> |
| 22 | #include <linux/wait.h> |
| 23 | #include <linux/workqueue.h> |
| 24 | #include <linux/msm-bus.h> |
| 25 | #include <linux/msm-bus-board.h> |
| 26 | #include <linux/kref.h> |
| 27 | #include <media/v4l2-dev.h> |
| 28 | #include <media/v4l2-device.h> |
| 29 | #include <media/v4l2-ioctl.h> |
| 30 | #include <media/v4l2-event.h> |
| 31 | #include <media/v4l2-ctrls.h> |
| 32 | #include <media/videobuf2-core.h> |
| 33 | #include <media/videobuf2-v4l2.h> |
| 34 | #include <media/msm_vidc.h> |
| 35 | #include <media/msm_media_info.h> |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 36 | #include "vidc_hfi_api.h" |
| 37 | |
| 38 | #define MSM_VIDC_DRV_NAME "msm_vidc_driver" |
| 39 | #define MSM_VIDC_VERSION KERNEL_VERSION(0, 0, 1) |
| 40 | #define MAX_DEBUGFS_NAME 50 |
| 41 | #define DEFAULT_TIMEOUT 3 |
| 42 | #define DEFAULT_HEIGHT 1088 |
| 43 | #define DEFAULT_WIDTH 1920 |
| 44 | #define MIN_SUPPORTED_WIDTH 32 |
| 45 | #define MIN_SUPPORTED_HEIGHT 32 |
| 46 | #define DEFAULT_FPS 15 |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 47 | #define MIN_NUM_OUTPUT_BUFFERS 1 |
Surajit Podder | 26e12f8a | 2017-10-13 14:11:42 +0530 | [diff] [blame] | 48 | #define MIN_NUM_OUTPUT_BUFFERS_VP9 6 |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 49 | #define MIN_NUM_CAPTURE_BUFFERS 1 |
| 50 | #define MAX_NUM_OUTPUT_BUFFERS VIDEO_MAX_FRAME // same as VB2_MAX_FRAME |
| 51 | #define MAX_NUM_CAPTURE_BUFFERS VIDEO_MAX_FRAME // same as VB2_MAX_FRAME |
| 52 | |
Karthikeyan Periasamy | 4b5e733 | 2017-07-28 12:07:42 -0700 | [diff] [blame] | 53 | #define MAX_SUPPORTED_INSTANCES 16 |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 54 | |
| 55 | /* Maintains the number of FTB's between each FBD over a window */ |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 56 | #define DCVS_FTB_WINDOW 16 |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 57 | |
| 58 | #define V4L2_EVENT_VIDC_BASE 10 |
| 59 | |
| 60 | #define SYS_MSG_START HAL_SYS_INIT_DONE |
| 61 | #define SYS_MSG_END HAL_SYS_ERROR |
| 62 | #define SESSION_MSG_START HAL_SESSION_EVENT_CHANGE |
| 63 | #define SESSION_MSG_END HAL_SESSION_ERROR |
| 64 | #define SYS_MSG_INDEX(__msg) (__msg - SYS_MSG_START) |
| 65 | #define SESSION_MSG_INDEX(__msg) (__msg - SESSION_MSG_START) |
| 66 | |
| 67 | |
| 68 | #define MAX_NAME_LENGTH 64 |
| 69 | |
| 70 | #define EXTRADATA_IDX(__num_planes) ((__num_planes) ? (__num_planes) - 1 : 0) |
| 71 | |
| 72 | #define NUM_MBS_PER_SEC(__height, __width, __fps) \ |
| 73 | (NUM_MBS_PER_FRAME(__height, __width) * __fps) |
| 74 | |
| 75 | #define NUM_MBS_PER_FRAME(__height, __width) \ |
| 76 | ((ALIGN(__height, 16) / 16) * (ALIGN(__width, 16) / 16)) |
| 77 | |
| 78 | enum vidc_ports { |
| 79 | OUTPUT_PORT, |
| 80 | CAPTURE_PORT, |
| 81 | MAX_PORT_NUM |
| 82 | }; |
| 83 | |
| 84 | enum vidc_core_state { |
| 85 | VIDC_CORE_UNINIT = 0, |
| 86 | VIDC_CORE_INIT, |
| 87 | VIDC_CORE_INIT_DONE, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | /* |
| 91 | * Do not change the enum values unless |
| 92 | * you know what you are doing |
| 93 | */ |
| 94 | enum instance_state { |
| 95 | MSM_VIDC_CORE_UNINIT_DONE = 0x0001, |
| 96 | MSM_VIDC_CORE_INIT, |
| 97 | MSM_VIDC_CORE_INIT_DONE, |
| 98 | MSM_VIDC_OPEN, |
| 99 | MSM_VIDC_OPEN_DONE, |
| 100 | MSM_VIDC_LOAD_RESOURCES, |
| 101 | MSM_VIDC_LOAD_RESOURCES_DONE, |
| 102 | MSM_VIDC_START, |
| 103 | MSM_VIDC_START_DONE, |
| 104 | MSM_VIDC_STOP, |
| 105 | MSM_VIDC_STOP_DONE, |
| 106 | MSM_VIDC_RELEASE_RESOURCES, |
| 107 | MSM_VIDC_RELEASE_RESOURCES_DONE, |
| 108 | MSM_VIDC_CLOSE, |
| 109 | MSM_VIDC_CLOSE_DONE, |
| 110 | MSM_VIDC_CORE_UNINIT, |
| 111 | MSM_VIDC_CORE_INVALID |
| 112 | }; |
| 113 | |
| 114 | struct buf_info { |
| 115 | struct list_head list; |
| 116 | struct vb2_buffer *buf; |
| 117 | }; |
| 118 | |
| 119 | struct msm_vidc_list { |
| 120 | struct list_head list; |
| 121 | struct mutex lock; |
| 122 | }; |
| 123 | |
| 124 | static inline void INIT_MSM_VIDC_LIST(struct msm_vidc_list *mlist) |
| 125 | { |
| 126 | mutex_init(&mlist->lock); |
| 127 | INIT_LIST_HEAD(&mlist->list); |
| 128 | } |
| 129 | |
| 130 | static inline void DEINIT_MSM_VIDC_LIST(struct msm_vidc_list *mlist) |
| 131 | { |
| 132 | mutex_destroy(&mlist->lock); |
| 133 | } |
| 134 | |
| 135 | enum buffer_owner { |
| 136 | DRIVER, |
| 137 | FIRMWARE, |
| 138 | CLIENT, |
| 139 | MAX_OWNER |
| 140 | }; |
| 141 | |
Praneeth Paladugu | b71968b | 2015-08-19 20:47:57 -0700 | [diff] [blame] | 142 | struct vidc_freq_data { |
| 143 | struct list_head list; |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 144 | u32 device_addr; |
Praneeth Paladugu | b71968b | 2015-08-19 20:47:57 -0700 | [diff] [blame] | 145 | unsigned long freq; |
Uma Mehta | 509471e | 2017-12-20 11:33:57 +0530 | [diff] [blame] | 146 | bool turbo; |
Praneeth Paladugu | b71968b | 2015-08-19 20:47:57 -0700 | [diff] [blame] | 147 | }; |
| 148 | |
Praneeth Paladugu | 7722b4e | 2017-07-07 11:01:56 -0700 | [diff] [blame] | 149 | struct vidc_input_cr_data { |
| 150 | struct list_head list; |
| 151 | u32 index; |
| 152 | u32 input_cr; |
| 153 | }; |
| 154 | |
Praneeth Paladugu | 319e792 | 2017-03-16 11:09:06 -0700 | [diff] [blame] | 155 | struct recon_buf { |
| 156 | struct list_head list; |
| 157 | u32 buffer_index; |
| 158 | u32 CR; |
| 159 | u32 CF; |
| 160 | }; |
| 161 | |
Praneeth Paladugu | f9ef817 | 2017-07-18 22:55:59 -0700 | [diff] [blame] | 162 | struct eos_buf { |
| 163 | struct list_head list; |
| 164 | struct msm_smem smem; |
| 165 | }; |
| 166 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 167 | struct internal_buf { |
| 168 | struct list_head list; |
| 169 | enum hal_buffer buffer_type; |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 170 | struct msm_smem smem; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 171 | enum buffer_owner buffer_ownership; |
| 172 | }; |
| 173 | |
Chinmay Sawarkar | ddd1d97 | 2017-08-15 10:10:06 -0700 | [diff] [blame] | 174 | struct msm_vidc_csc_coeff { |
| 175 | u32 *vpe_csc_custom_matrix_coeff; |
| 176 | u32 *vpe_csc_custom_bias_coeff; |
| 177 | u32 *vpe_csc_custom_limit_coeff; |
| 178 | }; |
| 179 | |
Qiwei Liu | 551a2222 | 2017-08-23 15:28:29 +0800 | [diff] [blame] | 180 | struct msm_vidc_buf_data { |
| 181 | struct list_head list; |
| 182 | u32 index; |
| 183 | u32 mark_data; |
| 184 | u32 mark_target; |
| 185 | }; |
| 186 | |
Praneeth Paladugu | d5bf7bc | 2017-05-29 23:41:04 -0700 | [diff] [blame] | 187 | struct msm_vidc_common_data { |
| 188 | char key[128]; |
| 189 | int value; |
| 190 | }; |
| 191 | |
| 192 | struct msm_vidc_codec_data { |
| 193 | u32 fourcc; |
| 194 | enum session_type session_type; |
| 195 | int vpp_cycles; |
| 196 | int vsp_cycles; |
| 197 | int low_power_cycles; |
| 198 | }; |
| 199 | |
Manikanta Kanamarlapudi | 0ff858d | 2017-08-28 17:35:11 +0530 | [diff] [blame] | 200 | enum efuse_purpose { |
| 201 | SKU_VERSION = 0, |
| 202 | }; |
| 203 | |
| 204 | enum sku_version { |
| 205 | SKU_VERSION_0 = 0, |
| 206 | SKU_VERSION_1, |
| 207 | SKU_VERSION_2, |
| 208 | }; |
| 209 | |
| 210 | struct msm_vidc_efuse_data { |
| 211 | u32 start_address; |
| 212 | u32 size; |
| 213 | u32 mask; |
| 214 | u32 shift; |
| 215 | enum efuse_purpose purpose; |
| 216 | }; |
| 217 | |
Praneeth Paladugu | d5bf7bc | 2017-05-29 23:41:04 -0700 | [diff] [blame] | 218 | struct msm_vidc_platform_data { |
| 219 | struct msm_vidc_common_data *common_data; |
| 220 | unsigned int common_data_length; |
| 221 | struct msm_vidc_codec_data *codec_data; |
| 222 | unsigned int codec_data_length; |
Chinmay Sawarkar | ddd1d97 | 2017-08-15 10:10:06 -0700 | [diff] [blame] | 223 | struct msm_vidc_csc_coeff csc_data; |
Manikanta Kanamarlapudi | 0ff858d | 2017-08-28 17:35:11 +0530 | [diff] [blame] | 224 | struct msm_vidc_efuse_data *efuse_data; |
| 225 | unsigned int efuse_data_length; |
| 226 | unsigned int sku_version; |
Praneeth Paladugu | d5bf7bc | 2017-05-29 23:41:04 -0700 | [diff] [blame] | 227 | }; |
| 228 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 229 | struct msm_vidc_format { |
| 230 | char name[MAX_NAME_LENGTH]; |
| 231 | u8 description[32]; |
| 232 | u32 fourcc; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 233 | int type; |
| 234 | u32 (*get_frame_size)(int plane, u32 height, u32 width); |
Vaibhav Deshu Venkatesh | 8c9b6db | 2017-02-08 11:22:36 -0800 | [diff] [blame] | 235 | bool defer_outputs; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 236 | }; |
| 237 | |
| 238 | struct msm_vidc_drv { |
| 239 | struct mutex lock; |
| 240 | struct list_head cores; |
| 241 | int num_cores; |
| 242 | struct dentry *debugfs_root; |
| 243 | int thermal_level; |
Manikanta Kanamarlapudi | 0ff858d | 2017-08-28 17:35:11 +0530 | [diff] [blame] | 244 | u32 sku_version; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | struct msm_video_device { |
| 248 | int type; |
| 249 | struct video_device vdev; |
| 250 | }; |
| 251 | |
Praneeth Paladugu | 520e9b2 | 2017-05-31 13:25:18 -0700 | [diff] [blame] | 252 | struct session_crop { |
| 253 | u32 left; |
| 254 | u32 top; |
| 255 | u32 width; |
| 256 | u32 height; |
| 257 | }; |
| 258 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 259 | struct session_prop { |
| 260 | u32 width[MAX_PORT_NUM]; |
| 261 | u32 height[MAX_PORT_NUM]; |
Praneeth Paladugu | 520e9b2 | 2017-05-31 13:25:18 -0700 | [diff] [blame] | 262 | struct session_crop crop_info; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 263 | u32 fps; |
| 264 | u32 bitrate; |
| 265 | }; |
| 266 | |
| 267 | struct buf_queue { |
| 268 | struct vb2_queue vb2_bufq; |
| 269 | struct mutex lock; |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 270 | unsigned int plane_sizes[VB2_MAX_PLANES]; |
| 271 | int num_planes; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 272 | }; |
| 273 | |
| 274 | enum profiling_points { |
| 275 | SYS_INIT = 0, |
| 276 | SESSION_INIT, |
| 277 | LOAD_RESOURCES, |
| 278 | FRAME_PROCESSING, |
| 279 | FW_IDLE, |
| 280 | MAX_PROFILING_POINTS, |
| 281 | }; |
| 282 | |
| 283 | struct buf_count { |
| 284 | int etb; |
| 285 | int ftb; |
| 286 | int fbd; |
| 287 | int ebd; |
| 288 | }; |
| 289 | |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 290 | struct clock_data { |
Praneeth Paladugu | 75cf18e | 2016-12-08 16:12:11 -0800 | [diff] [blame] | 291 | int buffer_counter; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 292 | int load; |
| 293 | int load_low; |
Praneeth Paladugu | 04e7772 | 2017-06-21 11:38:31 -0700 | [diff] [blame] | 294 | int load_norm; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 295 | int load_high; |
| 296 | int min_threshold; |
| 297 | int max_threshold; |
Praneeth Paladugu | 1f9d1d9 | 2017-04-11 10:36:16 -0700 | [diff] [blame] | 298 | unsigned int extra_capture_buffer_count; |
| 299 | unsigned int extra_output_buffer_count; |
Praneeth Paladugu | 75cf18e | 2016-12-08 16:12:11 -0800 | [diff] [blame] | 300 | enum hal_buffer buffer_type; |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 301 | bool dcvs_mode; |
| 302 | unsigned long bitrate; |
| 303 | unsigned long min_freq; |
| 304 | unsigned long curr_freq; |
| 305 | u32 operating_rate; |
Praneeth Paladugu | d5bf7bc | 2017-05-29 23:41:04 -0700 | [diff] [blame] | 306 | struct msm_vidc_codec_data *entry; |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 307 | u32 core_id; |
Praneeth Paladugu | 319e792 | 2017-03-16 11:09:06 -0700 | [diff] [blame] | 308 | u32 dpb_fourcc; |
| 309 | u32 opb_fourcc; |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 310 | enum hal_work_mode work_mode; |
| 311 | bool low_latency_mode; |
Saurabh Kothawade | 501be79 | 2017-08-29 11:41:38 -0700 | [diff] [blame] | 312 | bool turbo_mode; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 313 | }; |
| 314 | |
| 315 | struct profile_data { |
| 316 | int start; |
| 317 | int stop; |
| 318 | int cumulative; |
| 319 | char name[64]; |
| 320 | int sampling; |
| 321 | int average; |
| 322 | }; |
| 323 | |
| 324 | struct msm_vidc_debug { |
| 325 | struct profile_data pdata[MAX_PROFILING_POINTS]; |
| 326 | int profile; |
| 327 | int samples; |
| 328 | }; |
| 329 | |
| 330 | enum msm_vidc_modes { |
| 331 | VIDC_SECURE = BIT(0), |
| 332 | VIDC_TURBO = BIT(1), |
| 333 | VIDC_THUMBNAIL = BIT(2), |
| 334 | VIDC_LOW_POWER = BIT(3), |
| 335 | VIDC_REALTIME = BIT(4), |
| 336 | }; |
| 337 | |
| 338 | struct msm_vidc_core { |
| 339 | struct list_head list; |
| 340 | struct mutex lock; |
| 341 | int id; |
| 342 | struct hfi_device *device; |
Praneeth Paladugu | d5bf7bc | 2017-05-29 23:41:04 -0700 | [diff] [blame] | 343 | struct msm_vidc_platform_data *platform_data; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 344 | struct msm_video_device vdev[MSM_VIDC_MAX_DEVICES]; |
| 345 | struct v4l2_device v4l2_dev; |
| 346 | struct list_head instances; |
| 347 | struct dentry *debugfs_root; |
| 348 | enum vidc_core_state state; |
| 349 | struct completion completions[SYS_MSG_END - SYS_MSG_START + 1]; |
| 350 | enum msm_vidc_hfi_type hfi_type; |
| 351 | struct msm_vidc_platform_resources resources; |
| 352 | u32 enc_codec_supported; |
| 353 | u32 dec_codec_supported; |
| 354 | u32 codec_count; |
| 355 | struct msm_vidc_capability *capabilities; |
| 356 | struct delayed_work fw_unload_work; |
| 357 | bool smmu_fault_handled; |
Maheshwar Ajja | 8382bec | 2017-08-11 13:41:35 -0700 | [diff] [blame] | 358 | bool trigger_ssr; |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 359 | unsigned long min_freq; |
| 360 | unsigned long curr_freq; |
Praneeth Paladugu | 319e792 | 2017-03-16 11:09:06 -0700 | [diff] [blame] | 361 | struct vidc_bus_vote_data *vote_data; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 362 | }; |
| 363 | |
| 364 | struct msm_vidc_inst { |
| 365 | struct list_head list; |
Surajit Podder | 0d812bf | 2018-02-02 13:37:24 +0530 | [diff] [blame] | 366 | struct mutex sync_lock, lock, flush_lock; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 367 | struct msm_vidc_core *core; |
| 368 | enum session_type session_type; |
| 369 | void *session; |
| 370 | struct session_prop prop; |
| 371 | enum instance_state state; |
| 372 | struct msm_vidc_format fmts[MAX_PORT_NUM]; |
| 373 | struct buf_queue bufq[MAX_PORT_NUM]; |
Praneeth Paladugu | b71968b | 2015-08-19 20:47:57 -0700 | [diff] [blame] | 374 | struct msm_vidc_list freqs; |
Praneeth Paladugu | 7722b4e | 2017-07-07 11:01:56 -0700 | [diff] [blame] | 375 | struct msm_vidc_list input_crs; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 376 | struct msm_vidc_list scratchbufs; |
| 377 | struct msm_vidc_list persistbufs; |
| 378 | struct msm_vidc_list pending_getpropq; |
| 379 | struct msm_vidc_list outputbufs; |
Praneeth Paladugu | 319e792 | 2017-03-16 11:09:06 -0700 | [diff] [blame] | 380 | struct msm_vidc_list reconbufs; |
Praneeth Paladugu | f9ef817 | 2017-07-18 22:55:59 -0700 | [diff] [blame] | 381 | struct msm_vidc_list eosbufs; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 382 | struct msm_vidc_list registeredbufs; |
Qiwei Liu | 551a2222 | 2017-08-23 15:28:29 +0800 | [diff] [blame] | 383 | struct msm_vidc_list etb_data; |
| 384 | struct msm_vidc_list fbd_data; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 385 | struct buffer_requirements buff_req; |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 386 | struct smem_client *mem_client; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 387 | struct v4l2_ctrl_handler ctrl_handler; |
| 388 | struct completion completions[SESSION_MSG_END - SESSION_MSG_START + 1]; |
| 389 | struct v4l2_ctrl **cluster; |
| 390 | struct v4l2_fh event_handler; |
| 391 | struct msm_smem *extradata_handle; |
| 392 | bool in_reconfig; |
| 393 | u32 reconfig_width; |
| 394 | u32 reconfig_height; |
| 395 | struct dentry *debugfs_root; |
| 396 | void *priv; |
| 397 | struct msm_vidc_debug debug; |
| 398 | struct buf_count count; |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 399 | struct clock_data clk_data; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 400 | enum msm_vidc_modes flags; |
| 401 | struct msm_vidc_capability capability; |
| 402 | u32 buffer_size_limit; |
| 403 | enum buffer_mode_type buffer_mode_set[MAX_PORT_NUM]; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 404 | struct v4l2_ctrl **ctrls; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 405 | enum msm_vidc_pixel_depth bit_depth; |
| 406 | struct kref kref; |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 407 | bool in_flush; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 408 | u32 pic_struct; |
| 409 | u32 colour_space; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 410 | u32 profile; |
| 411 | u32 level; |
| 412 | u32 entropy_mode; |
Praneeth Paladugu | d5bf7bc | 2017-05-29 23:41:04 -0700 | [diff] [blame] | 413 | struct msm_vidc_codec_data *codec_data; |
Praneeth Paladugu | db53d1c | 2017-12-06 19:18:27 -0800 | [diff] [blame] | 414 | struct hal_hdr10_pq_sei hdr10_sei_params; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 415 | }; |
| 416 | |
| 417 | extern struct msm_vidc_drv *vidc_driver; |
| 418 | |
| 419 | struct msm_vidc_ctrl_cluster { |
| 420 | struct v4l2_ctrl **cluster; |
| 421 | struct list_head list; |
| 422 | }; |
| 423 | |
| 424 | struct msm_vidc_ctrl { |
| 425 | u32 id; |
| 426 | char name[MAX_NAME_LENGTH]; |
| 427 | enum v4l2_ctrl_type type; |
Umesh Pandey | 3224e80 | 2017-10-12 20:18:58 -0700 | [diff] [blame] | 428 | s64 minimum; |
| 429 | s64 maximum; |
| 430 | s64 default_value; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 431 | u32 step; |
| 432 | u32 menu_skip_mask; |
| 433 | u32 flags; |
| 434 | const char * const *qmenu; |
| 435 | }; |
| 436 | |
| 437 | void handle_cmd_response(enum hal_command_response cmd, void *data); |
| 438 | int msm_vidc_trigger_ssr(struct msm_vidc_core *core, |
| 439 | enum hal_ssr_trigger_type type); |
Maheshwar Ajja | 9ff81a2 | 2017-08-05 13:25:55 -0700 | [diff] [blame] | 440 | int msm_vidc_noc_error_info(struct msm_vidc_core *core); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 441 | int msm_vidc_check_session_supported(struct msm_vidc_inst *inst); |
| 442 | int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst); |
| 443 | void msm_vidc_queue_v4l2_event(struct msm_vidc_inst *inst, int event_type); |
| 444 | |
Maheshwar Ajja | e5765bd | 2017-08-08 11:59:38 -0700 | [diff] [blame] | 445 | enum msm_vidc_flags { |
| 446 | MSM_VIDC_FLAG_DEFERRED = BIT(0), |
| 447 | MSM_VIDC_FLAG_RBR_PENDING = BIT(1), |
| 448 | }; |
| 449 | |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 450 | struct msm_vidc_buffer { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 451 | struct list_head list; |
Maheshwar Ajja | cca0405 | 2017-07-12 17:59:45 -0700 | [diff] [blame] | 452 | struct kref kref; |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 453 | struct msm_smem smem[VIDEO_MAX_PLANES]; |
| 454 | struct vb2_v4l2_buffer vvb; |
Maheshwar Ajja | e5765bd | 2017-08-08 11:59:38 -0700 | [diff] [blame] | 455 | enum msm_vidc_flags flags; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 456 | }; |
| 457 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 458 | void msm_comm_handle_thermal_event(void); |
| 459 | void *msm_smem_new_client(enum smem_type mtype, |
| 460 | void *platform_resources, enum session_type stype); |
Surajit Podder | 3f543d2 | 2017-10-13 13:54:36 +0530 | [diff] [blame] | 461 | void msm_smem_set_tme_encode_mode(struct smem_client *client, bool enable); |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 462 | int msm_smem_alloc(struct smem_client *client, |
| 463 | size_t size, u32 align, u32 flags, enum hal_buffer buffer_type, |
| 464 | int map_kernel, struct msm_smem *smem); |
| 465 | int msm_smem_free(void *clt, struct msm_smem *mem); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 466 | void msm_smem_delete_client(void *clt); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 467 | struct context_bank_info *msm_smem_get_context_bank(void *clt, |
| 468 | bool is_secure, enum hal_buffer buffer_type); |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 469 | int msm_smem_map_dma_buf(struct msm_vidc_inst *inst, struct msm_smem *smem); |
| 470 | int msm_smem_unmap_dma_buf(struct msm_vidc_inst *inst, struct msm_smem *smem); |
| 471 | void *msm_smem_get_dma_buf(int fd); |
| 472 | void msm_smem_put_dma_buf(void *dma_buf); |
| 473 | void *msm_smem_get_handle(struct smem_client *client, void *dma_buf); |
| 474 | void msm_smem_put_handle(struct smem_client *client, void *handle); |
| 475 | int msm_smem_cache_operations(struct smem_client *client, |
| 476 | void *handle, unsigned long offset, unsigned long size, |
| 477 | enum smem_cache_ops cache_op); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 478 | void msm_vidc_fw_unload_handler(struct work_struct *work); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 479 | /* |
| 480 | * XXX: normally should be in msm_vidc.h, but that's meant for public APIs, |
| 481 | * whereas this is private |
| 482 | */ |
| 483 | int msm_vidc_destroy(struct msm_vidc_inst *inst); |
Praneeth Paladugu | d5bf7bc | 2017-05-29 23:41:04 -0700 | [diff] [blame] | 484 | void *vidc_get_drv_data(struct device *dev); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 485 | #endif |