Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. |
| 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 | #include <linux/slab.h> |
| 14 | #include "msm_vidc_internal.h" |
| 15 | #include "msm_vidc_common.h" |
| 16 | #include "vidc_hfi_api.h" |
| 17 | #include "msm_vidc_debug.h" |
| 18 | #include "msm_vidc_clocks.h" |
| 19 | |
| 20 | #define MSM_VENC_DVC_NAME "msm_venc_8974" |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 21 | #define MIN_BIT_RATE 32000 |
| 22 | #define MAX_BIT_RATE 300000000 |
| 23 | #define DEFAULT_BIT_RATE 64000 |
| 24 | #define BIT_RATE_STEP 100 |
| 25 | #define DEFAULT_FRAME_RATE 15 |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 26 | #define OPERATING_FRAME_RATE_STEP (1 << 16) |
| 27 | #define MAX_SLICE_BYTE_SIZE ((MAX_BIT_RATE)>>3) |
| 28 | #define MIN_SLICE_BYTE_SIZE 512 |
| 29 | #define MAX_SLICE_MB_SIZE ((4096 * 2304) >> 8) |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 30 | #define I_FRAME_QP 127 |
| 31 | #define P_FRAME_QP 127 |
| 32 | #define B_FRAME_QP 127 |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 33 | #define MAX_INTRA_REFRESH_MBS ((4096 * 2304) >> 8) |
| 34 | #define MAX_NUM_B_FRAMES 4 |
| 35 | #define MAX_LTR_FRAME_COUNT 10 |
| 36 | #define MAX_HYBRID_HIER_P_LAYERS 6 |
| 37 | |
| 38 | #define L_MODE V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 39 | #define MIN_TIME_RESOLUTION 1 |
| 40 | #define MAX_TIME_RESOLUTION 0xFFFFFF |
| 41 | #define DEFAULT_TIME_RESOLUTION 0x7530 |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 42 | #define MIN_NUM_ENC_OUTPUT_BUFFERS 4 |
| 43 | #define MIN_NUM_ENC_CAPTURE_BUFFERS 5 |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 44 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 45 | static const char *const mpeg_video_rate_control[] = { |
| 46 | "No Rate Control", |
| 47 | "VBR VFR", |
| 48 | "VBR CFR", |
| 49 | "CBR VFR", |
| 50 | "CBR CFR", |
| 51 | "MBR CFR", |
| 52 | "MBR VFR", |
| 53 | NULL |
| 54 | }; |
| 55 | |
| 56 | static const char *const mpeg_video_rotation[] = { |
| 57 | "No Rotation", |
| 58 | "90 Degree Rotation", |
| 59 | "180 Degree Rotation", |
| 60 | "270 Degree Rotation", |
| 61 | NULL |
| 62 | }; |
| 63 | |
| 64 | static const char *const h264_video_entropy_cabac_model[] = { |
| 65 | "Model 0", |
| 66 | "Model 1", |
| 67 | "Model 2", |
| 68 | NULL |
| 69 | }; |
| 70 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 71 | static const char *const hevc_tier_level[] = { |
| 72 | "Main Tier Level 1", |
| 73 | "Main Tier Level 2", |
| 74 | "Main Tier Level 2.1", |
| 75 | "Main Tier Level 3", |
| 76 | "Main Tier Level 3.1", |
| 77 | "Main Tier Level 4", |
| 78 | "Main Tier Level 4.1", |
| 79 | "Main Tier Level 5", |
| 80 | "Main Tier Level 5.1", |
| 81 | "Main Tier Level 5.2", |
| 82 | "Main Tier Level 6", |
| 83 | "Main Tier Level 6.1", |
| 84 | "Main Tier Level 6.2", |
| 85 | "High Tier Level 1", |
| 86 | "High Tier Level 2", |
| 87 | "High Tier Level 2.1", |
| 88 | "High Tier Level 3", |
| 89 | "High Tier Level 3.1", |
| 90 | "High Tier Level 4", |
| 91 | "High Tier Level 4.1", |
| 92 | "High Tier Level 5", |
| 93 | "High Tier Level 5.1", |
| 94 | "High Tier Level 5.2", |
| 95 | "High Tier Level 6", |
| 96 | "High Tier Level 6.1", |
| 97 | "High Tier Level 6.2", |
Vaibhav Deshu Venkatesh | ce58558 | 2017-05-18 13:45:33 -0700 | [diff] [blame] | 98 | "Level unknown", |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 99 | }; |
| 100 | |
Surajit Podder | e502daa | 2017-05-30 19:17:45 +0530 | [diff] [blame] | 101 | static const char *const tme_profile[] = { |
| 102 | "0", |
| 103 | "1", |
| 104 | "2", |
| 105 | "3", |
| 106 | }; |
| 107 | |
| 108 | static const char *const tme_level[] = { |
| 109 | "Integer", |
| 110 | }; |
| 111 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 112 | static const char *const hevc_profile[] = { |
| 113 | "Main", |
| 114 | "Main10", |
| 115 | "Main Still Pic", |
| 116 | }; |
| 117 | |
| 118 | static const char *const vp8_profile_level[] = { |
| 119 | "Unused", |
| 120 | "0.0", |
| 121 | "1.0", |
| 122 | "2.0", |
| 123 | "3.0", |
| 124 | }; |
| 125 | |
| 126 | static const char *const perf_level[] = { |
| 127 | "Nominal", |
| 128 | "Performance", |
| 129 | "Turbo" |
| 130 | }; |
| 131 | |
| 132 | static const char *const mbi_statistics[] = { |
| 133 | "Camcorder Default", |
| 134 | "Mode 1", |
| 135 | "Mode 2", |
| 136 | "Mode 3" |
| 137 | }; |
| 138 | |
| 139 | static const char *const intra_refresh_modes[] = { |
| 140 | "None", |
| 141 | "Cyclic", |
| 142 | "Adaptive", |
| 143 | "Cyclic Adaptive", |
| 144 | "Random" |
| 145 | }; |
| 146 | |
| 147 | static const char *const timestamp_mode[] = { |
| 148 | "Honor", |
| 149 | "Ignore", |
| 150 | }; |
| 151 | |
| 152 | static const char *const iframe_sizes[] = { |
| 153 | "Default", |
| 154 | "Medium", |
| 155 | "Huge", |
| 156 | "Unlimited" |
| 157 | }; |
| 158 | |
| 159 | static struct msm_vidc_ctrl msm_venc_ctrls[] = { |
| 160 | { |
| 161 | .id = V4L2_CID_MPEG_VIDC_VIDEO_IDR_PERIOD, |
| 162 | .name = "IDR Period", |
| 163 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 164 | .minimum = 1, |
| 165 | .maximum = INT_MAX, |
| 166 | .default_value = DEFAULT_FRAME_RATE, |
| 167 | .step = 1, |
| 168 | .menu_skip_mask = 0, |
| 169 | .qmenu = NULL, |
| 170 | }, |
| 171 | { |
| 172 | .id = V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES, |
| 173 | .name = "Intra Period for P frames", |
| 174 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 175 | .minimum = 0, |
| 176 | .maximum = INT_MAX, |
| 177 | .default_value = 2*DEFAULT_FRAME_RATE-1, |
| 178 | .step = 1, |
| 179 | .menu_skip_mask = 0, |
| 180 | .qmenu = NULL, |
| 181 | }, |
| 182 | { |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 183 | .id = V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP, |
| 184 | .name = "I Frame Quantization", |
| 185 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 186 | .minimum = 1, |
| 187 | .maximum = 127, |
| 188 | .default_value = I_FRAME_QP, |
| 189 | .step = 1, |
| 190 | .menu_skip_mask = 0, |
| 191 | .qmenu = NULL, |
| 192 | }, |
| 193 | { |
| 194 | .id = V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP, |
| 195 | .name = "P Frame Quantization", |
| 196 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 197 | .minimum = 1, |
| 198 | .maximum = 127, |
| 199 | .default_value = P_FRAME_QP, |
| 200 | .step = 1, |
| 201 | .menu_skip_mask = 0, |
| 202 | .qmenu = NULL, |
| 203 | }, |
| 204 | { |
| 205 | .id = V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP, |
| 206 | .name = "B Frame Quantization", |
| 207 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 208 | .minimum = 1, |
| 209 | .maximum = 127, |
| 210 | .default_value = B_FRAME_QP, |
| 211 | .step = 1, |
| 212 | .menu_skip_mask = 0, |
| 213 | .qmenu = NULL, |
| 214 | }, |
| 215 | { |
| 216 | .id = V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP_MIN, |
| 217 | .name = "I Frame Quantization Range Minimum", |
| 218 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 219 | .minimum = 1, |
| 220 | .maximum = 127, |
| 221 | .default_value = I_FRAME_QP, |
| 222 | .step = 1, |
| 223 | .menu_skip_mask = 0, |
| 224 | .qmenu = NULL, |
| 225 | }, |
| 226 | { |
| 227 | .id = V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP_MIN, |
| 228 | .name = "P Frame Quantization Range Minimum", |
| 229 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 230 | .minimum = 1, |
| 231 | .maximum = 127, |
| 232 | .default_value = P_FRAME_QP, |
| 233 | .step = 1, |
| 234 | .menu_skip_mask = 0, |
| 235 | .qmenu = NULL, |
| 236 | }, |
| 237 | { |
| 238 | .id = V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP_MIN, |
| 239 | .name = "B Frame Quantization Range Minimum", |
| 240 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 241 | .minimum = 1, |
| 242 | .maximum = 127, |
| 243 | .default_value = B_FRAME_QP, |
| 244 | .step = 1, |
| 245 | .menu_skip_mask = 0, |
| 246 | .qmenu = NULL, |
| 247 | }, |
| 248 | { |
| 249 | .id = V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP_MAX, |
| 250 | .name = "I Frame Quantization Range Maximum", |
| 251 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 252 | .minimum = 1, |
| 253 | .maximum = 127, |
| 254 | .default_value = I_FRAME_QP, |
| 255 | .step = 1, |
| 256 | .menu_skip_mask = 0, |
| 257 | .qmenu = NULL, |
| 258 | }, |
| 259 | { |
| 260 | .id = V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP_MAX, |
| 261 | .name = "P Frame Quantization Range Maximum", |
| 262 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 263 | .minimum = 1, |
| 264 | .maximum = 127, |
| 265 | .default_value = P_FRAME_QP, |
| 266 | .step = 1, |
| 267 | .menu_skip_mask = 0, |
| 268 | .qmenu = NULL, |
| 269 | }, |
| 270 | { |
| 271 | .id = V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP_MAX, |
| 272 | .name = "B Frame Quantization Range Maximum", |
| 273 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 274 | .minimum = 1, |
| 275 | .maximum = 127, |
| 276 | .default_value = B_FRAME_QP, |
| 277 | .step = 1, |
| 278 | .menu_skip_mask = 0, |
| 279 | .qmenu = NULL, |
| 280 | }, |
| 281 | { |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 282 | .id = V4L2_CID_MPEG_VIDC_VIDEO_QP_MASK, |
| 283 | .name = "QP mask for diff frame types", |
| 284 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 285 | .minimum = 1, |
| 286 | .maximum = 7, |
| 287 | .default_value = 7, |
| 288 | .step = 1, |
| 289 | .menu_skip_mask = 0, |
| 290 | .qmenu = NULL, |
| 291 | }, |
| 292 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 293 | .id = V4L2_CID_MPEG_VIDC_VIDEO_NUM_B_FRAMES, |
| 294 | .name = "Intra Period for B frames", |
| 295 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 296 | .minimum = 0, |
| 297 | .maximum = INT_MAX, |
| 298 | .default_value = 0, |
| 299 | .step = 1, |
| 300 | .menu_skip_mask = 0, |
| 301 | .qmenu = NULL, |
| 302 | }, |
| 303 | { |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 304 | .id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, |
| 305 | .name = "CAPTURE Count", |
| 306 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 307 | .minimum = MIN_NUM_CAPTURE_BUFFERS, |
| 308 | .maximum = MAX_NUM_CAPTURE_BUFFERS, |
| 309 | .default_value = MIN_NUM_CAPTURE_BUFFERS, |
| 310 | .step = 1, |
| 311 | .menu_skip_mask = 0, |
| 312 | .qmenu = NULL, |
| 313 | .flags = V4L2_CTRL_FLAG_VOLATILE, |
| 314 | }, |
| 315 | { |
| 316 | .id = V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, |
| 317 | .name = "OUTPUT Count", |
| 318 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 319 | .minimum = MIN_NUM_OUTPUT_BUFFERS, |
| 320 | .maximum = MAX_NUM_OUTPUT_BUFFERS, |
| 321 | .default_value = MIN_NUM_OUTPUT_BUFFERS, |
| 322 | .step = 1, |
| 323 | .menu_skip_mask = 0, |
| 324 | .qmenu = NULL, |
| 325 | .flags = V4L2_CTRL_FLAG_VOLATILE, |
| 326 | }, |
| 327 | |
| 328 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 329 | .id = V4L2_CID_MPEG_VIDC_VIDEO_REQUEST_IFRAME, |
| 330 | .name = "Request I Frame", |
| 331 | .type = V4L2_CTRL_TYPE_BUTTON, |
| 332 | .minimum = 0, |
| 333 | .maximum = 0, |
| 334 | .default_value = 0, |
| 335 | .step = 0, |
| 336 | .menu_skip_mask = 0, |
| 337 | .qmenu = NULL, |
| 338 | }, |
| 339 | { |
| 340 | .id = V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL, |
| 341 | .name = "Video Framerate and Bitrate Control", |
| 342 | .type = V4L2_CTRL_TYPE_MENU, |
| 343 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_OFF, |
| 344 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_MBR_VFR, |
| 345 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_OFF, |
| 346 | .step = 0, |
| 347 | .menu_skip_mask = ~( |
| 348 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_OFF) | |
| 349 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_VBR_VFR) | |
| 350 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_VBR_CFR) | |
| 351 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_VFR) | |
| 352 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_CFR) | |
| 353 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_MBR_CFR) | |
| 354 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_MBR_VFR) |
| 355 | ), |
| 356 | .qmenu = mpeg_video_rate_control, |
| 357 | }, |
| 358 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 359 | .id = V4L2_CID_MPEG_VIDEO_BITRATE, |
| 360 | .name = "Bit Rate", |
| 361 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 362 | .minimum = MIN_BIT_RATE, |
| 363 | .maximum = MAX_BIT_RATE, |
| 364 | .default_value = DEFAULT_BIT_RATE, |
| 365 | .step = BIT_RATE_STEP, |
| 366 | .menu_skip_mask = 0, |
| 367 | .qmenu = NULL, |
| 368 | }, |
| 369 | { |
| 370 | .id = V4L2_CID_MPEG_VIDEO_BITRATE_PEAK, |
| 371 | .name = "Peak Bit Rate", |
| 372 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 373 | .minimum = MIN_BIT_RATE, |
| 374 | .maximum = MAX_BIT_RATE, |
| 375 | .default_value = DEFAULT_BIT_RATE, |
| 376 | .step = BIT_RATE_STEP, |
| 377 | .menu_skip_mask = 0, |
| 378 | .qmenu = NULL, |
| 379 | }, |
| 380 | { |
| 381 | .id = V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, |
| 382 | .name = "Entropy Mode", |
| 383 | .type = V4L2_CTRL_TYPE_MENU, |
| 384 | .minimum = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, |
| 385 | .maximum = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC, |
| 386 | .default_value = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, |
| 387 | .menu_skip_mask = ~( |
| 388 | (1 << V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC) | |
| 389 | (1 << V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC) |
| 390 | ), |
| 391 | }, |
| 392 | { |
| 393 | .id = V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL, |
| 394 | .name = "CABAC Model", |
| 395 | .type = V4L2_CTRL_TYPE_MENU, |
| 396 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL_0, |
| 397 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL_1, |
| 398 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL_0, |
| 399 | .menu_skip_mask = ~( |
| 400 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL_0) | |
| 401 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL_1) | |
| 402 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL_2) |
| 403 | ), |
| 404 | .qmenu = h264_video_entropy_cabac_model, |
| 405 | }, |
| 406 | { |
| 407 | .id = V4L2_CID_MPEG_VIDEO_H264_PROFILE, |
| 408 | .name = "H264 Profile", |
| 409 | .type = V4L2_CTRL_TYPE_MENU, |
| 410 | .minimum = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, |
| 411 | .maximum = V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH, |
| 412 | .default_value = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, |
| 413 | .menu_skip_mask = 0, |
| 414 | }, |
| 415 | { |
| 416 | .id = V4L2_CID_MPEG_VIDEO_H264_LEVEL, |
| 417 | .name = "H264 Level", |
| 418 | .type = V4L2_CTRL_TYPE_MENU, |
| 419 | .minimum = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, |
Vaibhav Deshu Venkatesh | 234b4dc | 2017-03-21 16:54:28 -0700 | [diff] [blame] | 420 | .maximum = V4L2_MPEG_VIDEO_H264_LEVEL_UNKNOWN, |
| 421 | .default_value = V4L2_MPEG_VIDEO_H264_LEVEL_UNKNOWN, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 422 | .menu_skip_mask = 0, |
| 423 | }, |
| 424 | { |
| 425 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VP8_PROFILE_LEVEL, |
| 426 | .name = "VP8 Profile Level", |
| 427 | .type = V4L2_CTRL_TYPE_MENU, |
| 428 | .minimum = V4L2_MPEG_VIDC_VIDEO_VP8_UNUSED, |
Chinmay Sawarkar | 7f1cc15 | 2017-05-05 18:16:36 -0700 | [diff] [blame] | 429 | .maximum = V4L2_MPEG_VIDC_VIDEO_VP8_VERSION_3, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 430 | .default_value = V4L2_MPEG_VIDC_VIDEO_VP8_VERSION_0, |
Chinmay Sawarkar | 7f1cc15 | 2017-05-05 18:16:36 -0700 | [diff] [blame] | 431 | .menu_skip_mask = 0, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 432 | .qmenu = vp8_profile_level, |
| 433 | }, |
| 434 | { |
| 435 | .id = V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE, |
| 436 | .name = "HEVC Profile", |
| 437 | .type = V4L2_CTRL_TYPE_MENU, |
| 438 | .minimum = V4L2_MPEG_VIDC_VIDEO_HEVC_PROFILE_MAIN, |
| 439 | .maximum = V4L2_MPEG_VIDC_VIDEO_HEVC_PROFILE_MAIN_STILL_PIC, |
| 440 | .default_value = V4L2_MPEG_VIDC_VIDEO_HEVC_PROFILE_MAIN, |
| 441 | .menu_skip_mask = ~( |
| 442 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_PROFILE_MAIN) | |
| 443 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_PROFILE_MAIN10) | |
| 444 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_PROFILE_MAIN_STILL_PIC) |
| 445 | ), |
| 446 | .qmenu = hevc_profile, |
| 447 | }, |
| 448 | { |
| 449 | .id = V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL, |
| 450 | .name = "HEVC Tier and Level", |
| 451 | .type = V4L2_CTRL_TYPE_MENU, |
| 452 | .minimum = V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_1, |
Vaibhav Deshu Venkatesh | 234b4dc | 2017-03-21 16:54:28 -0700 | [diff] [blame] | 453 | .maximum = V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_UNKNOWN, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 454 | .default_value = |
Vaibhav Deshu Venkatesh | 234b4dc | 2017-03-21 16:54:28 -0700 | [diff] [blame] | 455 | V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_UNKNOWN, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 456 | .menu_skip_mask = ~( |
| 457 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_1) | |
| 458 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_2) | |
| 459 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_2_1) | |
| 460 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_3) | |
| 461 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_3_1) | |
| 462 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_4) | |
| 463 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_4_1) | |
| 464 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_5) | |
| 465 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_5_1) | |
| 466 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_HIGH_TIER_LEVEL_5_2) | |
| 467 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_1) | |
| 468 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_2) | |
| 469 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_2_1) | |
| 470 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_3) | |
| 471 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_3_1) | |
| 472 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_4) | |
| 473 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_4_1) | |
| 474 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_5) | |
Vaibhav Deshu Venkatesh | 234b4dc | 2017-03-21 16:54:28 -0700 | [diff] [blame] | 475 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_MAIN_TIER_LEVEL_5_1) | |
| 476 | (1 << V4L2_MPEG_VIDC_VIDEO_HEVC_LEVEL_UNKNOWN) |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 477 | ), |
| 478 | .qmenu = hevc_tier_level, |
| 479 | }, |
| 480 | { |
Surajit Podder | e502daa | 2017-05-30 19:17:45 +0530 | [diff] [blame] | 481 | .id = V4L2_CID_MPEG_VIDC_VIDEO_TME_PROFILE, |
| 482 | .name = "TME Profile", |
| 483 | .type = V4L2_CTRL_TYPE_MENU, |
| 484 | .minimum = V4L2_MPEG_VIDC_VIDEO_TME_PROFILE_0, |
| 485 | .maximum = V4L2_MPEG_VIDC_VIDEO_TME_PROFILE_3, |
| 486 | .default_value = |
| 487 | V4L2_MPEG_VIDC_VIDEO_TME_PROFILE_0, |
| 488 | .menu_skip_mask = ~( |
| 489 | (1 << V4L2_MPEG_VIDC_VIDEO_TME_PROFILE_0) | |
| 490 | (1 << V4L2_MPEG_VIDC_VIDEO_TME_PROFILE_1) | |
| 491 | (1 << V4L2_MPEG_VIDC_VIDEO_TME_PROFILE_2) | |
| 492 | (1 << V4L2_MPEG_VIDC_VIDEO_TME_PROFILE_3) |
| 493 | ), |
| 494 | .qmenu = tme_profile, |
| 495 | }, |
| 496 | { |
| 497 | .id = V4L2_CID_MPEG_VIDC_VIDEO_TME_LEVEL, |
| 498 | .name = "TME Level", |
| 499 | .type = V4L2_CTRL_TYPE_MENU, |
| 500 | .minimum = V4L2_MPEG_VIDC_VIDEO_TME_LEVEL_INTEGER, |
| 501 | .maximum = V4L2_MPEG_VIDC_VIDEO_TME_LEVEL_INTEGER, |
| 502 | .default_value = V4L2_MPEG_VIDC_VIDEO_TME_LEVEL_INTEGER, |
| 503 | .menu_skip_mask = ~( |
| 504 | (1 << V4L2_MPEG_VIDC_VIDEO_TME_LEVEL_INTEGER) |
| 505 | ), |
| 506 | .qmenu = tme_level, |
| 507 | }, |
| 508 | { |
| 509 | .id = V4L2_CID_MPEG_VIDC_VIDEO_TME_PAYLOAD_VERSION, |
| 510 | .name = "TME Payload Version", |
| 511 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 512 | .minimum = 0, |
| 513 | .maximum = 0xFFFFFFF, |
| 514 | .default_value = 0, |
| 515 | .step = 1, |
| 516 | .menu_skip_mask = 0, |
| 517 | .flags = V4L2_CTRL_FLAG_READ_ONLY, |
| 518 | .qmenu = NULL, |
| 519 | }, |
| 520 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 521 | .id = V4L2_CID_MPEG_VIDC_VIDEO_ROTATION, |
| 522 | .name = "Rotation", |
| 523 | .type = V4L2_CTRL_TYPE_MENU, |
| 524 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_NONE, |
| 525 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_270, |
| 526 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_NONE, |
| 527 | .menu_skip_mask = ~( |
| 528 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_NONE) | |
| 529 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_90) | |
| 530 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_180) | |
| 531 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_270) |
| 532 | ), |
| 533 | .qmenu = mpeg_video_rotation, |
| 534 | }, |
| 535 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 536 | .id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE, |
| 537 | .name = "Slice Mode", |
| 538 | .type = V4L2_CTRL_TYPE_MENU, |
| 539 | .minimum = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE, |
| 540 | .maximum = V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES, |
| 541 | .default_value = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE, |
| 542 | .menu_skip_mask = ~( |
| 543 | (1 << V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE) | |
| 544 | (1 << V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) | |
| 545 | (1 << V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES) |
| 546 | ), |
| 547 | }, |
| 548 | { |
| 549 | .id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES, |
| 550 | .name = "Slice Byte Size", |
| 551 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 552 | .minimum = MIN_SLICE_BYTE_SIZE, |
| 553 | .maximum = MAX_SLICE_BYTE_SIZE, |
| 554 | .default_value = MIN_SLICE_BYTE_SIZE, |
| 555 | .step = 1, |
| 556 | .menu_skip_mask = 0, |
| 557 | .qmenu = NULL, |
| 558 | }, |
| 559 | { |
| 560 | .id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB, |
| 561 | .name = "Slice MB Size", |
| 562 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 563 | .minimum = 1, |
| 564 | .maximum = MAX_SLICE_MB_SIZE, |
| 565 | .default_value = 1, |
| 566 | .step = 1, |
| 567 | .menu_skip_mask = 0, |
| 568 | .qmenu = NULL, |
| 569 | }, |
| 570 | { |
| 571 | .id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_DELIVERY_MODE, |
| 572 | .name = "Slice delivery mode", |
| 573 | .type = V4L2_CTRL_TYPE_BUTTON, |
| 574 | .minimum = 0, |
| 575 | .maximum = 1, |
| 576 | .default_value = 0, |
| 577 | .step = 1, |
| 578 | .menu_skip_mask = 0, |
| 579 | .qmenu = NULL, |
| 580 | }, |
| 581 | { |
| 582 | .id = V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_MODE, |
| 583 | .name = "Intra Refresh Mode", |
| 584 | .type = V4L2_CTRL_TYPE_MENU, |
| 585 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_NONE, |
| 586 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_RANDOM, |
| 587 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_NONE, |
| 588 | .menu_skip_mask = ~( |
| 589 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_NONE) | |
| 590 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_CYCLIC) | |
| 591 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_RANDOM) |
| 592 | ), |
| 593 | .qmenu = intra_refresh_modes, |
| 594 | }, |
| 595 | { |
| 596 | .id = V4L2_CID_MPEG_VIDC_VIDEO_IR_MBS, |
| 597 | .name = "Intra Refresh AIR MBS", |
| 598 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 599 | .minimum = 0, |
| 600 | .maximum = MAX_INTRA_REFRESH_MBS, |
| 601 | .default_value = 0, |
| 602 | .step = 1, |
| 603 | .menu_skip_mask = 0, |
| 604 | .qmenu = NULL, |
| 605 | }, |
| 606 | { |
| 607 | .id = V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA, |
| 608 | .name = "H.264 Loop Filter Alpha Offset", |
| 609 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 610 | .minimum = -6, |
| 611 | .maximum = 6, |
| 612 | .default_value = 0, |
| 613 | .step = 1, |
| 614 | .menu_skip_mask = 0, |
| 615 | .qmenu = NULL, |
| 616 | }, |
| 617 | { |
| 618 | .id = V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA, |
| 619 | .name = "H.264 Loop Filter Beta Offset", |
| 620 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 621 | .minimum = -6, |
| 622 | .maximum = 6, |
| 623 | .default_value = 0, |
| 624 | .step = 1, |
| 625 | .menu_skip_mask = 0, |
| 626 | .qmenu = NULL, |
| 627 | }, |
| 628 | { |
| 629 | .id = V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, |
| 630 | .name = "H.264 Loop Filter Mode", |
| 631 | .type = V4L2_CTRL_TYPE_MENU, |
| 632 | .minimum = V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED, |
| 633 | .maximum = L_MODE, |
| 634 | .default_value = V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED, |
| 635 | .menu_skip_mask = ~( |
| 636 | (1 << V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED) | |
| 637 | (1 << V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED) | |
| 638 | (1 << L_MODE) |
| 639 | ), |
| 640 | }, |
| 641 | { |
| 642 | .id = V4L2_CID_MPEG_VIDEO_HEADER_MODE, |
| 643 | .name = "Sequence Header Mode", |
| 644 | .type = V4L2_CTRL_TYPE_MENU, |
| 645 | .minimum = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE, |
| 646 | .maximum = V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, |
| 647 | .default_value = |
| 648 | V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, |
| 649 | .menu_skip_mask = ~( |
| 650 | (1 << V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) | |
| 651 | (1 << V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME) |
| 652 | ), |
| 653 | }, |
| 654 | { |
| 655 | .id = V4L2_CID_MPEG_VIDC_VIDEO_SECURE, |
| 656 | .name = "Secure mode", |
| 657 | .type = V4L2_CTRL_TYPE_BUTTON, |
| 658 | .minimum = 0, |
| 659 | .maximum = 0, |
| 660 | .default_value = 0, |
| 661 | .step = 0, |
| 662 | .menu_skip_mask = 0, |
| 663 | .qmenu = NULL, |
| 664 | }, |
| 665 | { |
| 666 | .id = V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA, |
| 667 | .name = "Extradata Type", |
| 668 | .type = V4L2_CTRL_TYPE_MENU, |
| 669 | .minimum = V4L2_MPEG_VIDC_EXTRADATA_NONE, |
| 670 | .maximum = V4L2_MPEG_VIDC_EXTRADATA_PQ_INFO, |
| 671 | .default_value = V4L2_MPEG_VIDC_EXTRADATA_NONE, |
| 672 | .menu_skip_mask = ~( |
| 673 | (1 << V4L2_MPEG_VIDC_EXTRADATA_NONE) | |
| 674 | (1 << V4L2_MPEG_VIDC_EXTRADATA_MB_QUANTIZATION) | |
| 675 | (1 << V4L2_MPEG_VIDC_EXTRADATA_INTERLACE_VIDEO) | |
| 676 | (1 << V4L2_MPEG_VIDC_EXTRADATA_TIMESTAMP) | |
| 677 | (1 << V4L2_MPEG_VIDC_EXTRADATA_S3D_FRAME_PACKING) | |
| 678 | (1 << V4L2_MPEG_VIDC_EXTRADATA_FRAME_RATE) | |
| 679 | (1 << V4L2_MPEG_VIDC_EXTRADATA_PANSCAN_WINDOW) | |
| 680 | (1 << V4L2_MPEG_VIDC_EXTRADATA_RECOVERY_POINT_SEI) | |
| 681 | (1 << V4L2_MPEG_VIDC_EXTRADATA_MULTISLICE_INFO) | |
| 682 | (1 << V4L2_MPEG_VIDC_EXTRADATA_NUM_CONCEALED_MB) | |
| 683 | (1 << V4L2_MPEG_VIDC_EXTRADATA_METADATA_FILLER) | |
| 684 | (1 << V4L2_MPEG_VIDC_EXTRADATA_INPUT_CROP) | |
| 685 | (1 << V4L2_MPEG_VIDC_EXTRADATA_DIGITAL_ZOOM) | |
| 686 | (1 << V4L2_MPEG_VIDC_EXTRADATA_ASPECT_RATIO) | |
| 687 | (1 << V4L2_MPEG_VIDC_EXTRADATA_LTR) | |
| 688 | (1 << V4L2_MPEG_VIDC_EXTRADATA_METADATA_MBI) | |
| 689 | (1 << V4L2_MPEG_VIDC_EXTRADATA_YUV_STATS)| |
| 690 | (1 << V4L2_MPEG_VIDC_EXTRADATA_ROI_QP) | |
| 691 | (1 << V4L2_MPEG_VIDC_EXTRADATA_PQ_INFO) |
| 692 | ), |
| 693 | .qmenu = mpeg_video_vidc_extradata, |
| 694 | }, |
| 695 | { |
| 696 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VUI_TIMING_INFO, |
| 697 | .name = "H264 VUI Timing Info", |
| 698 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 699 | .minimum = V4L2_MPEG_VIDC_VIDEO_VUI_TIMING_INFO_DISABLED, |
| 700 | .maximum = V4L2_MPEG_VIDC_VIDEO_VUI_TIMING_INFO_ENABLED, |
| 701 | .default_value = |
| 702 | V4L2_MPEG_VIDC_VIDEO_VUI_TIMING_INFO_DISABLED, |
| 703 | .step = 1, |
| 704 | }, |
| 705 | { |
| 706 | .id = V4L2_CID_MPEG_VIDC_VIDEO_AU_DELIMITER, |
Umesh Pandey | 7fce7ee | 2017-03-13 17:59:48 -0700 | [diff] [blame] | 707 | .name = "AU Delimiter", |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 708 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 709 | .minimum = V4L2_MPEG_VIDC_VIDEO_AU_DELIMITER_DISABLED, |
| 710 | .maximum = V4L2_MPEG_VIDC_VIDEO_AU_DELIMITER_ENABLED, |
| 711 | .step = 1, |
| 712 | .default_value = |
| 713 | V4L2_MPEG_VIDC_VIDEO_AU_DELIMITER_DISABLED, |
| 714 | }, |
| 715 | { |
| 716 | .id = V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB, |
| 717 | .name = "Intra Refresh CIR MBS", |
| 718 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 719 | .minimum = 0, |
| 720 | .maximum = MAX_INTRA_REFRESH_MBS, |
| 721 | .default_value = 0, |
| 722 | .step = 1, |
| 723 | .menu_skip_mask = 0, |
| 724 | .qmenu = NULL, |
| 725 | }, |
| 726 | { |
| 727 | .id = V4L2_CID_MPEG_VIDC_VIDEO_PRESERVE_TEXT_QUALITY, |
| 728 | .name = "Preserve Text Qualty", |
| 729 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 730 | .minimum = V4L2_MPEG_VIDC_VIDEO_PRESERVE_TEXT_QUALITY_DISABLED, |
| 731 | .maximum = V4L2_MPEG_VIDC_VIDEO_PRESERVE_TEXT_QUALITY_ENABLED, |
| 732 | .default_value = |
| 733 | V4L2_MPEG_VIDC_VIDEO_PRESERVE_TEXT_QUALITY_DISABLED, |
| 734 | .step = 1, |
| 735 | }, |
| 736 | { |
| 737 | .id = V4L2_CID_MPEG_VIDC_VIDEO_USELTRFRAME, |
| 738 | .name = "H264 Use LTR", |
| 739 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 740 | .minimum = 0, |
| 741 | .maximum = (MAX_LTR_FRAME_COUNT - 1), |
| 742 | .default_value = 0, |
| 743 | .step = 1, |
| 744 | .qmenu = NULL, |
| 745 | }, |
| 746 | { |
| 747 | .id = V4L2_CID_MPEG_VIDC_VIDEO_LTRCOUNT, |
| 748 | .name = "Ltr Count", |
| 749 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 750 | .minimum = 0, |
| 751 | .maximum = MAX_LTR_FRAME_COUNT, |
| 752 | .default_value = 0, |
| 753 | .step = 1, |
| 754 | .qmenu = NULL, |
| 755 | }, |
| 756 | { |
| 757 | .id = V4L2_CID_MPEG_VIDC_VIDEO_LTRMODE, |
| 758 | .name = "Ltr Mode", |
| 759 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 760 | .minimum = V4L2_MPEG_VIDC_VIDEO_LTR_MODE_DISABLE, |
| 761 | .maximum = V4L2_MPEG_VIDC_VIDEO_LTR_MODE_MANUAL, |
| 762 | .default_value = V4L2_MPEG_VIDC_VIDEO_LTR_MODE_DISABLE, |
| 763 | .step = 1, |
| 764 | .qmenu = NULL, |
| 765 | }, |
| 766 | { |
| 767 | .id = V4L2_CID_MPEG_VIDC_VIDEO_MARKLTRFRAME, |
| 768 | .name = "H264 Mark LTR", |
| 769 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 770 | .minimum = 0, |
| 771 | .maximum = (MAX_LTR_FRAME_COUNT - 1), |
| 772 | .default_value = 0, |
| 773 | .step = 1, |
| 774 | .qmenu = NULL, |
| 775 | }, |
| 776 | { |
| 777 | .id = V4L2_CID_MPEG_VIDC_VIDEO_HIER_P_NUM_LAYERS, |
| 778 | .name = "Set Hier P num layers", |
| 779 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 780 | .minimum = 0, |
| 781 | .maximum = 6, |
| 782 | .default_value = 0, |
| 783 | .step = 1, |
| 784 | .qmenu = NULL, |
| 785 | }, |
| 786 | { |
| 787 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VPX_ERROR_RESILIENCE, |
| 788 | .name = "VP8 Error Resilience mode", |
| 789 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 790 | .minimum = V4L2_MPEG_VIDC_VIDEO_VPX_ERROR_RESILIENCE_DISABLED, |
| 791 | .maximum = V4L2_MPEG_VIDC_VIDEO_VPX_ERROR_RESILIENCE_ENABLED, |
| 792 | .default_value = |
| 793 | V4L2_MPEG_VIDC_VIDEO_VPX_ERROR_RESILIENCE_DISABLED, |
| 794 | .step = 1, |
| 795 | .qmenu = NULL, |
| 796 | }, |
| 797 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 798 | .id = V4L2_CID_MPEG_VIDC_VIDEO_HIER_B_NUM_LAYERS, |
| 799 | .name = "Set Hier B num layers", |
| 800 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 801 | .minimum = 0, |
| 802 | .maximum = 3, |
| 803 | .default_value = 0, |
| 804 | .step = 1, |
| 805 | .qmenu = NULL, |
| 806 | }, |
| 807 | { |
| 808 | .id = V4L2_CID_MPEG_VIDC_VIDEO_HYBRID_HIERP_MODE, |
| 809 | .name = "Set Hybrid Hier P mode", |
| 810 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 811 | .minimum = 0, |
| 812 | .maximum = 5, |
| 813 | .default_value = 0, |
| 814 | .step = 1, |
| 815 | .qmenu = NULL, |
| 816 | }, |
| 817 | { |
| 818 | .id = V4L2_CID_VIDC_QBUF_MODE, |
| 819 | .name = "Allows batching of buffers for power savings", |
| 820 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 821 | .minimum = V4L2_VIDC_QBUF_STANDARD, |
| 822 | .maximum = V4L2_VIDC_QBUF_BATCHED, |
| 823 | .default_value = V4L2_VIDC_QBUF_STANDARD, |
| 824 | .step = 1, |
| 825 | }, |
| 826 | { |
| 827 | .id = V4L2_CID_MPEG_VIDC_VIDEO_MAX_HIERP_LAYERS, |
| 828 | .name = "Set Max Hier P num layers sessions", |
| 829 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 830 | .minimum = 0, |
| 831 | .maximum = 6, |
| 832 | .default_value = 0, |
| 833 | .step = 1, |
| 834 | .qmenu = NULL, |
| 835 | }, |
| 836 | { |
| 837 | .id = V4L2_CID_MPEG_VIDC_VIDEO_BASELAYER_ID, |
| 838 | .name = "Set Base Layer ID for Hier-P", |
| 839 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 840 | .minimum = 0, |
| 841 | .maximum = 6, |
| 842 | .default_value = 0, |
| 843 | .step = 1, |
| 844 | .qmenu = NULL, |
| 845 | }, |
| 846 | { |
Vaibhav Deshu Venkatesh | d0792bc | 2017-03-16 14:55:51 -0700 | [diff] [blame] | 847 | .id = V4L2_CID_MPEG_VIDC_VIDEO_LAYER_ID, |
| 848 | .name = "Layer ID for different settings", |
| 849 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 850 | .minimum = 0, |
Vaibhav Deshu Venkatesh | ea0a6a6 | 2017-04-20 13:16:44 -0700 | [diff] [blame] | 851 | .maximum = MSM_VIDC_ALL_LAYER_ID, |
Vaibhav Deshu Venkatesh | d0792bc | 2017-03-16 14:55:51 -0700 | [diff] [blame] | 852 | .default_value = 0, |
| 853 | .step = 1, |
| 854 | .qmenu = NULL, |
| 855 | }, |
| 856 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 857 | .id = V4L2_CID_MPEG_VIDC_VENC_PARAM_SAR_WIDTH, |
| 858 | .name = "SAR Width", |
| 859 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 860 | .minimum = 1, |
| 861 | .maximum = 4096, |
| 862 | .default_value = 1, |
| 863 | .step = 1, |
| 864 | .qmenu = NULL, |
| 865 | }, |
| 866 | { |
| 867 | .id = V4L2_CID_MPEG_VIDC_VENC_PARAM_SAR_HEIGHT, |
| 868 | .name = "SAR Height", |
| 869 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 870 | .minimum = 1, |
| 871 | .maximum = 2160, |
| 872 | .default_value = 1, |
| 873 | .step = 1, |
| 874 | .qmenu = NULL, |
| 875 | }, |
| 876 | { |
| 877 | .id = V4L2_CID_MPEG_VIDC_VIDEO_PRIORITY, |
| 878 | .name = "Session Priority", |
| 879 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 880 | .minimum = V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_ENABLE, |
| 881 | .maximum = V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_DISABLE, |
| 882 | .default_value = V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_DISABLE, |
| 883 | .step = 1, |
| 884 | }, |
| 885 | { |
| 886 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VQZIP_SEI, |
| 887 | .name = "VQZIP SEI", |
| 888 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 889 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_VQZIP_SEI_DISABLE, |
| 890 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_VQZIP_SEI_ENABLE, |
| 891 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_VQZIP_SEI_DISABLE, |
| 892 | .step = 1, |
| 893 | }, |
| 894 | { |
| 895 | .id = V4L2_CID_MPEG_VIDC_VENC_PARAM_LAYER_BITRATE, |
| 896 | .name = "Layer wise bitrate for H264/H265 Hybrid HP", |
| 897 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 898 | .minimum = MIN_BIT_RATE, |
| 899 | .maximum = MAX_BIT_RATE, |
| 900 | .default_value = DEFAULT_BIT_RATE, |
| 901 | .step = BIT_RATE_STEP, |
| 902 | .menu_skip_mask = 0, |
| 903 | .qmenu = NULL, |
| 904 | }, |
| 905 | { |
| 906 | .id = V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE, |
| 907 | .name = "Set Encoder Operating rate", |
| 908 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 909 | .minimum = 0, |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 910 | .maximum = INT_MAX, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 911 | .default_value = 0, |
| 912 | .step = OPERATING_FRAME_RATE_STEP, |
| 913 | }, |
| 914 | { |
| 915 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VENC_BITRATE_TYPE, |
| 916 | .name = "BITRATE TYPE", |
| 917 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 918 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_VENC_BITRATE_DISABLE, |
| 919 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_VENC_BITRATE_ENABLE, |
| 920 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_VENC_BITRATE_ENABLE, |
| 921 | .step = 1, |
| 922 | }, |
| 923 | { |
| 924 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC, |
| 925 | .name = "Set VPE Color space conversion coefficients", |
| 926 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 927 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC_DISABLE, |
| 928 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC_ENABLE, |
| 929 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC_DISABLE, |
| 930 | .step = 1, |
| 931 | }, |
| 932 | { |
| 933 | .id = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_MODE, |
| 934 | .name = "Low Latency Mode", |
| 935 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 936 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_DISABLE, |
| 937 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_ENABLE, |
| 938 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_DISABLE, |
| 939 | .step = 1, |
| 940 | }, |
| 941 | { |
| 942 | .id = V4L2_CID_MPEG_VIDC_VIDEO_BLUR_WIDTH, |
| 943 | .name = "Set Blur width", |
| 944 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 945 | .minimum = 0, |
| 946 | .maximum = 2048, |
| 947 | .default_value = 0, |
| 948 | .step = 1, |
| 949 | }, |
| 950 | { |
| 951 | .id = V4L2_CID_MPEG_VIDC_VIDEO_BLUR_HEIGHT, |
| 952 | .name = "Set Blur height", |
| 953 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 954 | .minimum = 0, |
| 955 | .maximum = 2048, |
| 956 | .default_value = 0, |
| 957 | .step = 1, |
| 958 | }, |
| 959 | { |
| 960 | .id = V4L2_CID_MPEG_VIDC_VIDEO_H264_TRANSFORM_8x8, |
| 961 | .name = "Transform 8x8", |
| 962 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 963 | .minimum = V4L2_MPEG_VIDC_VIDEO_H264_TRANSFORM_8x8_DISABLE, |
| 964 | .maximum = V4L2_MPEG_VIDC_VIDEO_H264_TRANSFORM_8x8_ENABLE, |
| 965 | .default_value = V4L2_MPEG_VIDC_VIDEO_H264_TRANSFORM_8x8_ENABLE, |
| 966 | .step = 1, |
| 967 | }, |
| 968 | { |
| 969 | .id = V4L2_CID_MPEG_VIDC_VIDEO_COLOR_SPACE, |
| 970 | .name = "Set Color space", |
| 971 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 972 | .minimum = MSM_VIDC_BT709_5, |
| 973 | .maximum = MSM_VIDC_BT2020, |
| 974 | .default_value = MSM_VIDC_BT601_6_625, |
| 975 | .step = 1, |
| 976 | .qmenu = NULL, |
| 977 | }, |
| 978 | { |
| 979 | .id = V4L2_CID_MPEG_VIDC_VIDEO_FULL_RANGE, |
| 980 | .name = "Set Color space range", |
| 981 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 982 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_FULL_RANGE_DISABLE, |
| 983 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_FULL_RANGE_ENABLE, |
| 984 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_FULL_RANGE_DISABLE, |
| 985 | .step = 1, |
| 986 | }, |
| 987 | { |
| 988 | .id = V4L2_CID_MPEG_VIDC_VIDEO_TRANSFER_CHARS, |
| 989 | .name = "Set Color space transfer characterstics", |
| 990 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 991 | .minimum = MSM_VIDC_TRANSFER_BT709_5, |
Umesh Pandey | f797f45 | 2017-06-15 16:52:38 -0700 | [diff] [blame] | 992 | .maximum = MSM_VIDC_TRANSFER_HLG, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 993 | .default_value = MSM_VIDC_TRANSFER_601_6_625, |
| 994 | .step = 1, |
| 995 | .qmenu = NULL, |
| 996 | }, |
| 997 | { |
| 998 | .id = V4L2_CID_MPEG_VIDC_VIDEO_MATRIX_COEFFS, |
| 999 | .name = "Set Color space matrix coefficients", |
| 1000 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 1001 | .minimum = MSM_VIDC_MATRIX_BT_709_5, |
| 1002 | .maximum = MSM_VIDC_MATRIX_BT_2020_CONST, |
| 1003 | .default_value = MSM_VIDC_MATRIX_601_6_625, |
| 1004 | .step = 1, |
| 1005 | .qmenu = NULL, |
| 1006 | }, |
| 1007 | { |
| 1008 | .id = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_TYPE, |
| 1009 | .name = "Bounds of I-frame size", |
| 1010 | .type = V4L2_CTRL_TYPE_MENU, |
| 1011 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_DEFAULT, |
| 1012 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_UNLIMITED, |
| 1013 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_DEFAULT, |
| 1014 | .menu_skip_mask = ~( |
| 1015 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_DEFAULT) | |
| 1016 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_MEDIUM) | |
| 1017 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_HUGE) | |
| 1018 | (1 << V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_UNLIMITED)), |
| 1019 | .qmenu = iframe_sizes, |
| 1020 | }, |
Chinmay Sawarkar | 0f7cf2e | 2017-05-04 11:35:56 -0700 | [diff] [blame] | 1021 | { |
| 1022 | .id = V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, |
| 1023 | .name = "Frame Rate based Rate Control", |
| 1024 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 1025 | .minimum = 0, |
| 1026 | .maximum = 1, |
| 1027 | .default_value = 0, |
| 1028 | .step = 1, |
| 1029 | }, |
Chinmay Sawarkar | ddd1d97 | 2017-08-15 10:10:06 -0700 | [diff] [blame] | 1030 | { |
| 1031 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC_CUSTOM_MATRIX, |
| 1032 | .name = "Enable/Disable CSC Custom Matrix", |
| 1033 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 1034 | .minimum = 0, |
| 1035 | .maximum = 1, |
| 1036 | .default_value = 0, |
| 1037 | .step = 1, |
| 1038 | }, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1039 | |
| 1040 | }; |
| 1041 | |
| 1042 | #define NUM_CTRLS ARRAY_SIZE(msm_venc_ctrls) |
| 1043 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1044 | static u32 get_frame_size_compressed(int plane, u32 height, u32 width) |
| 1045 | { |
| 1046 | int sz = ALIGN(height, 32) * ALIGN(width, 32) * 3 / 2; |
| 1047 | |
| 1048 | return ALIGN(sz, SZ_4K); |
| 1049 | } |
| 1050 | |
| 1051 | static struct msm_vidc_format venc_formats[] = { |
| 1052 | { |
| 1053 | .name = "YCbCr Semiplanar 4:2:0", |
| 1054 | .description = "Y/CbCr 4:2:0", |
| 1055 | .fourcc = V4L2_PIX_FMT_NV12, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1056 | .get_frame_size = get_frame_size_nv12, |
| 1057 | .type = OUTPUT_PORT, |
| 1058 | }, |
| 1059 | { |
| 1060 | .name = "UBWC YCbCr Semiplanar 4:2:0", |
| 1061 | .description = "UBWC Y/CbCr 4:2:0", |
| 1062 | .fourcc = V4L2_PIX_FMT_NV12_UBWC, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1063 | .get_frame_size = get_frame_size_nv12_ubwc, |
| 1064 | .type = OUTPUT_PORT, |
| 1065 | }, |
| 1066 | { |
| 1067 | .name = "RGBA 8:8:8:8", |
| 1068 | .description = "RGBA 8:8:8:8", |
| 1069 | .fourcc = V4L2_PIX_FMT_RGB32, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1070 | .get_frame_size = get_frame_size_rgba, |
| 1071 | .type = OUTPUT_PORT, |
| 1072 | }, |
| 1073 | { |
| 1074 | .name = "H264", |
| 1075 | .description = "H264 compressed format", |
| 1076 | .fourcc = V4L2_PIX_FMT_H264, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1077 | .get_frame_size = get_frame_size_compressed, |
| 1078 | .type = CAPTURE_PORT, |
| 1079 | }, |
| 1080 | { |
| 1081 | .name = "VP8", |
| 1082 | .description = "VP8 compressed format", |
| 1083 | .fourcc = V4L2_PIX_FMT_VP8, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1084 | .get_frame_size = get_frame_size_compressed, |
| 1085 | .type = CAPTURE_PORT, |
| 1086 | }, |
| 1087 | { |
| 1088 | .name = "HEVC", |
| 1089 | .description = "HEVC compressed format", |
| 1090 | .fourcc = V4L2_PIX_FMT_HEVC, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1091 | .get_frame_size = get_frame_size_compressed, |
| 1092 | .type = CAPTURE_PORT, |
| 1093 | }, |
| 1094 | { |
| 1095 | .name = "YCrCb Semiplanar 4:2:0", |
| 1096 | .description = "Y/CrCb 4:2:0", |
| 1097 | .fourcc = V4L2_PIX_FMT_NV21, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1098 | .get_frame_size = get_frame_size_nv21, |
| 1099 | .type = OUTPUT_PORT, |
| 1100 | }, |
Umesh Pandey | f2995f8 | 2017-05-01 16:44:45 -0700 | [diff] [blame] | 1101 | { |
| 1102 | .name = "TP10 UBWC 4:2:0", |
| 1103 | .description = "TP10 UBWC 4:2:0", |
| 1104 | .fourcc = V4L2_PIX_FMT_NV12_TP10_UBWC, |
| 1105 | .get_frame_size = get_frame_size_tp10_ubwc, |
| 1106 | .type = OUTPUT_PORT, |
| 1107 | }, |
Surajit Podder | e502daa | 2017-05-30 19:17:45 +0530 | [diff] [blame] | 1108 | { |
| 1109 | .name = "TME", |
| 1110 | .description = "TME MBI format", |
| 1111 | .fourcc = V4L2_PIX_FMT_TME, |
| 1112 | .get_frame_size = get_frame_size_compressed, |
| 1113 | .type = CAPTURE_PORT, |
| 1114 | }, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1115 | }; |
| 1116 | |
Chinmay Sawarkar | ddd1d97 | 2017-08-15 10:10:06 -0700 | [diff] [blame] | 1117 | static int msm_venc_set_csc(struct msm_vidc_inst *inst, |
| 1118 | u32 color_primaries, u32 custom_matrix); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1119 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1120 | static int msm_venc_toggle_hier_p(struct msm_vidc_inst *inst, int layers) |
| 1121 | { |
| 1122 | int num_enh_layers = 0; |
| 1123 | u32 property_id = 0; |
| 1124 | struct hfi_device *hdev = NULL; |
| 1125 | int rc = 0; |
| 1126 | |
| 1127 | if (!inst || !inst->core || !inst->core->device) { |
| 1128 | dprintk(VIDC_ERR, "%s invalid parameters\n", __func__); |
| 1129 | return -EINVAL; |
| 1130 | } |
| 1131 | |
| 1132 | if (inst->fmts[CAPTURE_PORT].fourcc != V4L2_PIX_FMT_VP8) |
| 1133 | return 0; |
| 1134 | |
Chinmay Sawarkar | cbd3f59 | 2017-04-10 15:42:30 -0700 | [diff] [blame] | 1135 | num_enh_layers = layers ? layers : 0; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1136 | dprintk(VIDC_DBG, "%s Hier-P in firmware\n", |
| 1137 | num_enh_layers ? "Enable" : "Disable"); |
| 1138 | |
| 1139 | hdev = inst->core->device; |
| 1140 | property_id = HAL_PARAM_VENC_HIER_P_MAX_ENH_LAYERS; |
| 1141 | rc = call_hfi_op(hdev, session_set_property, |
| 1142 | (void *)inst->session, property_id, |
| 1143 | (void *)&num_enh_layers); |
| 1144 | if (rc) { |
| 1145 | dprintk(VIDC_ERR, |
| 1146 | "%s: failed with error = %d\n", __func__, rc); |
| 1147 | } |
| 1148 | return rc; |
| 1149 | } |
| 1150 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1151 | static struct v4l2_ctrl *get_ctrl_from_cluster(int id, |
| 1152 | struct v4l2_ctrl **cluster, int ncontrols) |
| 1153 | { |
| 1154 | int c; |
| 1155 | |
| 1156 | for (c = 0; c < ncontrols; ++c) |
| 1157 | if (cluster[c]->id == id) |
| 1158 | return cluster[c]; |
| 1159 | return NULL; |
| 1160 | } |
| 1161 | |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 1162 | int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1163 | { |
| 1164 | int rc = 0; |
| 1165 | struct hal_request_iframe request_iframe; |
| 1166 | struct hal_bitrate bitrate; |
| 1167 | struct hal_profile_level profile_level; |
| 1168 | struct hal_h264_entropy_control h264_entropy_control; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1169 | struct hal_intra_period intra_period; |
| 1170 | struct hal_idr_period idr_period; |
Chinmay Sawarkar | 582c72a | 2017-05-24 14:29:12 -0700 | [diff] [blame] | 1171 | struct hal_vpe_rotation vpe_rotation; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1172 | struct hal_intra_refresh intra_refresh; |
| 1173 | struct hal_multi_slice_control multi_slice_control; |
| 1174 | struct hal_h264_db_control h264_db_control; |
| 1175 | struct hal_enable enable; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1176 | struct hal_quantization quant; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1177 | struct hal_preserve_text_quality preserve_text_quality; |
| 1178 | u32 property_id = 0, property_val = 0; |
| 1179 | void *pdata = NULL; |
| 1180 | struct v4l2_ctrl *temp_ctrl = NULL; |
| 1181 | struct hfi_device *hdev; |
| 1182 | struct hal_extradata_enable extra; |
| 1183 | struct hal_ltr_use use_ltr; |
| 1184 | struct hal_ltr_mark mark_ltr; |
| 1185 | struct hal_hybrid_hierp hyb_hierp; |
Vaibhav Deshu Venkatesh | a2cf1b3 | 2017-03-30 17:40:48 -0700 | [diff] [blame] | 1186 | u32 hier_p_layers = 0; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1187 | int max_hierp_layers; |
| 1188 | int baselayerid = 0; |
| 1189 | struct hal_video_signal_info signal_info = {0}; |
Chinmay Sawarkar | d005462 | 2017-05-04 13:50:59 -0700 | [diff] [blame] | 1190 | struct hal_vui_timing_info vui_timing_info = {0}; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1191 | enum hal_iframesize_type iframesize_type = HAL_IFRAMESIZE_TYPE_DEFAULT; |
Chinmay Sawarkar | ddd1d97 | 2017-08-15 10:10:06 -0700 | [diff] [blame] | 1192 | u32 color_primaries, custom_matrix; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1193 | |
| 1194 | if (!inst || !inst->core || !inst->core->device) { |
| 1195 | dprintk(VIDC_ERR, "%s invalid parameters\n", __func__); |
| 1196 | return -EINVAL; |
| 1197 | } |
| 1198 | hdev = inst->core->device; |
| 1199 | |
| 1200 | /* Small helper macro for quickly getting a control and err checking */ |
| 1201 | #define TRY_GET_CTRL(__ctrl_id) ({ \ |
| 1202 | struct v4l2_ctrl *__temp; \ |
| 1203 | __temp = get_ctrl_from_cluster( \ |
| 1204 | __ctrl_id, \ |
| 1205 | ctrl->cluster, ctrl->ncontrols); \ |
| 1206 | if (!__temp) { \ |
| 1207 | dprintk(VIDC_ERR, "Can't find %s (%x) in cluster\n", \ |
| 1208 | #__ctrl_id, __ctrl_id); \ |
| 1209 | /* Clusters are hardcoded, if we can't find */ \ |
| 1210 | /* something then things are massively screwed up */ \ |
| 1211 | MSM_VIDC_ERROR(1); \ |
| 1212 | } \ |
| 1213 | __temp; \ |
| 1214 | }) |
| 1215 | |
| 1216 | /* |
| 1217 | * Unlock the control prior to setting to the hardware. Otherwise |
| 1218 | * lower level code that attempts to do a get_ctrl() will end up |
| 1219 | * deadlocking. |
| 1220 | */ |
| 1221 | v4l2_ctrl_unlock(ctrl); |
| 1222 | |
| 1223 | switch (ctrl->id) { |
| 1224 | case V4L2_CID_MPEG_VIDC_VIDEO_IDR_PERIOD: |
| 1225 | if (inst->fmts[CAPTURE_PORT].fourcc != V4L2_PIX_FMT_H264 && |
| 1226 | inst->fmts[CAPTURE_PORT].fourcc != |
| 1227 | V4L2_PIX_FMT_H264_NO_SC && |
| 1228 | inst->fmts[CAPTURE_PORT].fourcc != |
| 1229 | V4L2_PIX_FMT_HEVC) { |
| 1230 | dprintk(VIDC_ERR, |
| 1231 | "Control %#x only valid for H264 and HEVC\n", |
| 1232 | ctrl->id); |
| 1233 | rc = -ENOTSUPP; |
| 1234 | break; |
| 1235 | } |
| 1236 | |
| 1237 | property_id = HAL_CONFIG_VENC_IDR_PERIOD; |
| 1238 | idr_period.idr_period = ctrl->val; |
| 1239 | pdata = &idr_period; |
| 1240 | break; |
| 1241 | case V4L2_CID_MPEG_VIDC_VIDEO_NUM_B_FRAMES: |
| 1242 | case V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES: |
| 1243 | { |
| 1244 | int num_p, num_b; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1245 | |
| 1246 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_NUM_B_FRAMES); |
| 1247 | num_b = temp_ctrl->val; |
| 1248 | |
| 1249 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES); |
| 1250 | num_p = temp_ctrl->val; |
| 1251 | |
| 1252 | if (ctrl->id == V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES) |
| 1253 | num_p = ctrl->val; |
| 1254 | else if (ctrl->id == V4L2_CID_MPEG_VIDC_VIDEO_NUM_B_FRAMES) |
| 1255 | num_b = ctrl->val; |
| 1256 | |
Saurabh Kothawade | b11d81c | 2017-05-18 19:07:17 -0700 | [diff] [blame] | 1257 | if ((num_b < inst->capability.bframe.min) || |
| 1258 | (num_b > inst->capability.bframe.max)) { |
| 1259 | dprintk(VIDC_ERR, |
| 1260 | "Error setting num b frames %d min, max supported is %d, %d\n", |
| 1261 | num_b, inst->capability.bframe.min, |
| 1262 | inst->capability.bframe.max); |
| 1263 | rc = -ENOTSUPP; |
| 1264 | break; |
| 1265 | } |
| 1266 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1267 | property_id = HAL_CONFIG_VENC_INTRA_PERIOD; |
| 1268 | intra_period.pframes = num_p; |
| 1269 | intra_period.bframes = num_b; |
| 1270 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1271 | pdata = &intra_period; |
| 1272 | break; |
| 1273 | } |
| 1274 | case V4L2_CID_MPEG_VIDC_VIDEO_REQUEST_IFRAME: |
| 1275 | property_id = HAL_CONFIG_VENC_REQUEST_IFRAME; |
| 1276 | request_iframe.enable = true; |
| 1277 | pdata = &request_iframe; |
| 1278 | break; |
| 1279 | case V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL: |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1280 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1281 | property_id = HAL_PARAM_VENC_RATE_CONTROL; |
Chinmay Sawarkar | 0a9cca3 | 2017-04-11 12:52:59 -0700 | [diff] [blame] | 1282 | property_val = ctrl->val; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1283 | pdata = &property_val; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1284 | break; |
| 1285 | } |
| 1286 | case V4L2_CID_MPEG_VIDEO_BITRATE: |
| 1287 | { |
| 1288 | property_id = HAL_CONFIG_VENC_TARGET_BITRATE; |
| 1289 | bitrate.bit_rate = ctrl->val; |
Vaibhav Deshu Venkatesh | 5115b46 | 2017-05-05 17:48:50 -0700 | [diff] [blame] | 1290 | bitrate.layer_id = MSM_VIDC_ALL_LAYER_ID; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1291 | pdata = &bitrate; |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 1292 | inst->clk_data.bitrate = ctrl->val; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1293 | break; |
| 1294 | } |
| 1295 | case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: |
| 1296 | { |
| 1297 | struct v4l2_ctrl *avg_bitrate = TRY_GET_CTRL( |
| 1298 | V4L2_CID_MPEG_VIDEO_BITRATE); |
| 1299 | |
| 1300 | if (ctrl->val < avg_bitrate->val) { |
| 1301 | dprintk(VIDC_ERR, |
| 1302 | "Peak bitrate (%d) is lower than average bitrate (%d)\n", |
| 1303 | ctrl->val, avg_bitrate->val); |
| 1304 | rc = -EINVAL; |
| 1305 | break; |
| 1306 | } else if (ctrl->val < avg_bitrate->val * 2) { |
| 1307 | dprintk(VIDC_WARN, |
| 1308 | "Peak bitrate (%d) ideally should be twice the average bitrate (%d)\n", |
| 1309 | ctrl->val, avg_bitrate->val); |
| 1310 | } |
| 1311 | |
| 1312 | property_id = HAL_CONFIG_VENC_MAX_BITRATE; |
| 1313 | bitrate.bit_rate = ctrl->val; |
Vaibhav Deshu Venkatesh | 5115b46 | 2017-05-05 17:48:50 -0700 | [diff] [blame] | 1314 | bitrate.layer_id = MSM_VIDC_ALL_LAYER_ID; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1315 | pdata = &bitrate; |
| 1316 | break; |
| 1317 | } |
| 1318 | case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: |
| 1319 | temp_ctrl = TRY_GET_CTRL( |
| 1320 | V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL); |
| 1321 | |
| 1322 | property_id = HAL_PARAM_VENC_H264_ENTROPY_CONTROL; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1323 | h264_entropy_control.entropy_mode = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1324 | V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, ctrl->val); |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1325 | h264_entropy_control.cabac_model = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1326 | V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL, |
| 1327 | temp_ctrl->val); |
| 1328 | pdata = &h264_entropy_control; |
| 1329 | break; |
| 1330 | case V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL: |
| 1331 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE); |
| 1332 | |
| 1333 | property_id = HAL_PARAM_VENC_H264_ENTROPY_CONTROL; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1334 | h264_entropy_control.cabac_model = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1335 | V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, ctrl->val); |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1336 | h264_entropy_control.entropy_mode = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1337 | V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL, |
| 1338 | temp_ctrl->val); |
| 1339 | pdata = &h264_entropy_control; |
| 1340 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1341 | case V4L2_CID_MPEG_VIDEO_H264_PROFILE: |
| 1342 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_H264_LEVEL); |
| 1343 | |
| 1344 | property_id = HAL_PARAM_PROFILE_LEVEL_CURRENT; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1345 | profile_level.profile = msm_comm_v4l2_to_hal(ctrl->id, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1346 | ctrl->val); |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1347 | profile_level.level = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1348 | V4L2_CID_MPEG_VIDEO_H264_LEVEL, |
| 1349 | temp_ctrl->val); |
| 1350 | pdata = &profile_level; |
| 1351 | dprintk(VIDC_DBG, "\nprofile: %d\n", |
| 1352 | profile_level.profile); |
| 1353 | break; |
| 1354 | case V4L2_CID_MPEG_VIDEO_H264_LEVEL: |
| 1355 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_H264_PROFILE); |
| 1356 | |
| 1357 | property_id = HAL_PARAM_PROFILE_LEVEL_CURRENT; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1358 | profile_level.level = msm_comm_v4l2_to_hal(ctrl->id, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1359 | ctrl->val); |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1360 | profile_level.profile = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1361 | V4L2_CID_MPEG_VIDEO_H264_PROFILE, |
| 1362 | temp_ctrl->val); |
| 1363 | pdata = &profile_level; |
| 1364 | dprintk(VIDC_DBG, "\nLevel: %d\n", |
| 1365 | profile_level.level); |
| 1366 | break; |
| 1367 | case V4L2_CID_MPEG_VIDC_VIDEO_VP8_PROFILE_LEVEL: |
| 1368 | property_id = HAL_PARAM_PROFILE_LEVEL_CURRENT; |
Vaibhav Deshu Venkatesh | 0ad53f0 | 2017-08-07 13:21:47 -0700 | [diff] [blame] | 1369 | profile_level.profile = HAL_VP8_PROFILE_MAIN; |
Chinmay Sawarkar | 7f1cc15 | 2017-05-05 18:16:36 -0700 | [diff] [blame] | 1370 | profile_level.level = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1371 | V4L2_CID_MPEG_VIDC_VIDEO_VP8_PROFILE_LEVEL, |
| 1372 | ctrl->val); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1373 | pdata = &profile_level; |
| 1374 | break; |
| 1375 | case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE: |
| 1376 | temp_ctrl = |
| 1377 | TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL); |
| 1378 | |
| 1379 | property_id = HAL_PARAM_PROFILE_LEVEL_CURRENT; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1380 | profile_level.profile = msm_comm_v4l2_to_hal(ctrl->id, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1381 | ctrl->val); |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1382 | profile_level.level = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1383 | V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL, |
| 1384 | temp_ctrl->val); |
| 1385 | pdata = &profile_level; |
| 1386 | break; |
| 1387 | case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL: |
| 1388 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE); |
| 1389 | |
| 1390 | property_id = HAL_PARAM_PROFILE_LEVEL_CURRENT; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1391 | profile_level.level = msm_comm_v4l2_to_hal(ctrl->id, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1392 | ctrl->val); |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1393 | profile_level.profile = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1394 | V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE, |
| 1395 | temp_ctrl->val); |
| 1396 | pdata = &profile_level; |
| 1397 | break; |
Surajit Podder | e502daa | 2017-05-30 19:17:45 +0530 | [diff] [blame] | 1398 | case V4L2_CID_MPEG_VIDC_VIDEO_TME_PROFILE: |
| 1399 | temp_ctrl = |
| 1400 | TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_TME_LEVEL); |
| 1401 | |
| 1402 | property_id = HAL_PARAM_PROFILE_LEVEL_CURRENT; |
| 1403 | profile_level.profile = msm_comm_v4l2_to_hal(ctrl->id, |
| 1404 | ctrl->val); |
| 1405 | profile_level.level = msm_comm_v4l2_to_hal( |
| 1406 | V4L2_CID_MPEG_VIDC_VIDEO_TME_LEVEL, |
| 1407 | temp_ctrl->val); |
| 1408 | pdata = &profile_level; |
| 1409 | break; |
| 1410 | case V4L2_CID_MPEG_VIDC_VIDEO_TME_LEVEL: |
| 1411 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_TME_PROFILE); |
| 1412 | |
| 1413 | property_id = HAL_PARAM_PROFILE_LEVEL_CURRENT; |
| 1414 | profile_level.level = msm_comm_v4l2_to_hal(ctrl->id, |
| 1415 | ctrl->val); |
| 1416 | profile_level.profile = msm_comm_v4l2_to_hal( |
| 1417 | V4L2_CID_MPEG_VIDC_VIDEO_TME_PROFILE, |
| 1418 | temp_ctrl->val); |
| 1419 | pdata = &profile_level; |
| 1420 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1421 | case V4L2_CID_MPEG_VIDC_VIDEO_ROTATION: |
| 1422 | { |
Chinmay Sawarkar | 582c72a | 2017-05-24 14:29:12 -0700 | [diff] [blame] | 1423 | property_id = HAL_PARAM_VPE_ROTATION; |
| 1424 | vpe_rotation.rotate = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1425 | V4L2_CID_MPEG_VIDC_VIDEO_ROTATION, |
| 1426 | ctrl->val); |
Chinmay Sawarkar | 582c72a | 2017-05-24 14:29:12 -0700 | [diff] [blame] | 1427 | vpe_rotation.flip = HAL_FLIP_NONE; |
| 1428 | pdata = &vpe_rotation; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1429 | break; |
| 1430 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1431 | case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: { |
| 1432 | int temp = 0; |
| 1433 | |
| 1434 | switch (ctrl->val) { |
| 1435 | case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB: |
| 1436 | temp = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB; |
| 1437 | break; |
| 1438 | case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES: |
| 1439 | temp = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES; |
| 1440 | break; |
| 1441 | case V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE: |
| 1442 | default: |
| 1443 | temp = 0; |
| 1444 | break; |
| 1445 | } |
| 1446 | |
| 1447 | if (temp) |
| 1448 | temp_ctrl = TRY_GET_CTRL(temp); |
| 1449 | |
| 1450 | property_id = HAL_PARAM_VENC_MULTI_SLICE_CONTROL; |
| 1451 | multi_slice_control.multi_slice = ctrl->val; |
| 1452 | multi_slice_control.slice_size = temp ? temp_ctrl->val : 0; |
| 1453 | |
| 1454 | pdata = &multi_slice_control; |
| 1455 | break; |
| 1456 | } |
| 1457 | case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES: |
| 1458 | case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB: |
| 1459 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE); |
| 1460 | |
| 1461 | property_id = HAL_PARAM_VENC_MULTI_SLICE_CONTROL; |
| 1462 | multi_slice_control.multi_slice = temp_ctrl->val; |
| 1463 | multi_slice_control.slice_size = ctrl->val; |
| 1464 | pdata = &multi_slice_control; |
| 1465 | break; |
| 1466 | case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_DELIVERY_MODE: { |
| 1467 | bool codec_avc = |
| 1468 | inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_H264 || |
| 1469 | inst->fmts[CAPTURE_PORT].fourcc == |
| 1470 | V4L2_PIX_FMT_H264_NO_SC; |
| 1471 | |
| 1472 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE); |
| 1473 | if (codec_avc && temp_ctrl->val == |
| 1474 | V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) { |
| 1475 | property_id = HAL_PARAM_VENC_SLICE_DELIVERY_MODE; |
| 1476 | enable.enable = true; |
| 1477 | } else { |
| 1478 | dprintk(VIDC_WARN, |
| 1479 | "Failed : slice delivery mode is not valid\n"); |
| 1480 | enable.enable = false; |
| 1481 | } |
| 1482 | pdata = &enable; |
| 1483 | break; |
| 1484 | } |
Saurabh Kothawade | abed16c | 2017-03-22 17:06:40 -0700 | [diff] [blame] | 1485 | case V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_MODE: |
| 1486 | { |
| 1487 | struct v4l2_ctrl *ir_mbs; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1488 | |
Saurabh Kothawade | abed16c | 2017-03-22 17:06:40 -0700 | [diff] [blame] | 1489 | ir_mbs = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_IR_MBS); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1490 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1491 | property_id = HAL_PARAM_VENC_INTRA_REFRESH; |
| 1492 | |
Saurabh Kothawade | abed16c | 2017-03-22 17:06:40 -0700 | [diff] [blame] | 1493 | intra_refresh.mode = ctrl->val; |
| 1494 | intra_refresh.ir_mbs = ir_mbs->val; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1495 | |
| 1496 | pdata = &intra_refresh; |
| 1497 | break; |
| 1498 | } |
Saurabh Kothawade | abed16c | 2017-03-22 17:06:40 -0700 | [diff] [blame] | 1499 | case V4L2_CID_MPEG_VIDC_VIDEO_IR_MBS: |
| 1500 | { |
| 1501 | struct v4l2_ctrl *ir_mode; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1502 | |
| 1503 | ir_mode = TRY_GET_CTRL( |
| 1504 | V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_MODE); |
| 1505 | |
| 1506 | property_id = HAL_PARAM_VENC_INTRA_REFRESH; |
| 1507 | |
Saurabh Kothawade | abed16c | 2017-03-22 17:06:40 -0700 | [diff] [blame] | 1508 | intra_refresh.mode = ir_mode->val; |
| 1509 | intra_refresh.ir_mbs = ctrl->val; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1510 | |
| 1511 | pdata = &intra_refresh; |
| 1512 | break; |
| 1513 | } |
| 1514 | case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE: |
| 1515 | { |
| 1516 | struct v4l2_ctrl *alpha, *beta; |
| 1517 | |
| 1518 | alpha = TRY_GET_CTRL( |
| 1519 | V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA); |
| 1520 | beta = TRY_GET_CTRL( |
| 1521 | V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA); |
| 1522 | |
| 1523 | property_id = HAL_PARAM_VENC_H264_DEBLOCK_CONTROL; |
| 1524 | h264_db_control.slice_alpha_offset = alpha->val; |
| 1525 | h264_db_control.slice_beta_offset = beta->val; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1526 | h264_db_control.mode = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1527 | V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, |
| 1528 | ctrl->val); |
| 1529 | pdata = &h264_db_control; |
| 1530 | break; |
| 1531 | } |
| 1532 | case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA: |
| 1533 | { |
| 1534 | struct v4l2_ctrl *mode, *beta; |
| 1535 | |
| 1536 | mode = TRY_GET_CTRL( |
| 1537 | V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE); |
| 1538 | beta = TRY_GET_CTRL( |
| 1539 | V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA); |
| 1540 | |
| 1541 | property_id = HAL_PARAM_VENC_H264_DEBLOCK_CONTROL; |
| 1542 | h264_db_control.slice_alpha_offset = ctrl->val; |
| 1543 | h264_db_control.slice_beta_offset = beta->val; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1544 | h264_db_control.mode = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1545 | V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, |
| 1546 | mode->val); |
| 1547 | pdata = &h264_db_control; |
| 1548 | break; |
| 1549 | } |
| 1550 | case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA: |
| 1551 | { |
| 1552 | struct v4l2_ctrl *mode, *alpha; |
| 1553 | |
| 1554 | mode = TRY_GET_CTRL( |
| 1555 | V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE); |
| 1556 | alpha = TRY_GET_CTRL( |
| 1557 | V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA); |
| 1558 | property_id = HAL_PARAM_VENC_H264_DEBLOCK_CONTROL; |
| 1559 | h264_db_control.slice_alpha_offset = alpha->val; |
| 1560 | h264_db_control.slice_beta_offset = ctrl->val; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1561 | h264_db_control.mode = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1562 | V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, |
| 1563 | mode->val); |
| 1564 | pdata = &h264_db_control; |
| 1565 | break; |
| 1566 | } |
| 1567 | case V4L2_CID_MPEG_VIDEO_HEADER_MODE: |
| 1568 | property_id = HAL_PARAM_VENC_SYNC_FRAME_SEQUENCE_HEADER; |
| 1569 | |
| 1570 | switch (ctrl->val) { |
| 1571 | case V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE: |
| 1572 | enable.enable = 0; |
| 1573 | break; |
| 1574 | case V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME: |
Saurabh Kothawade | 846b753 | 2017-03-29 17:17:19 -0700 | [diff] [blame] | 1575 | enable.enable = 1; |
Saurabh Kothawade | f4b7ff0 | 2017-04-04 17:24:04 -0700 | [diff] [blame] | 1576 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1577 | default: |
| 1578 | rc = -ENOTSUPP; |
| 1579 | break; |
| 1580 | } |
| 1581 | pdata = &enable; |
| 1582 | break; |
| 1583 | case V4L2_CID_MPEG_VIDC_VIDEO_SECURE: |
| 1584 | inst->flags |= VIDC_SECURE; |
Karthikeyan Periasamy | a0e4bad | 2017-04-26 12:51:10 -0700 | [diff] [blame] | 1585 | property_id = HAL_PARAM_SECURE; |
| 1586 | property_val = !!(inst->flags & VIDC_SECURE); |
| 1587 | pdata = &property_val; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1588 | dprintk(VIDC_INFO, "Setting secure mode to: %d\n", |
| 1589 | !!(inst->flags & VIDC_SECURE)); |
| 1590 | break; |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 1591 | case V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA: { |
| 1592 | struct hal_buffer_requirements *buff_req_buffer = NULL; |
| 1593 | int extra_idx = 0; |
| 1594 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1595 | property_id = HAL_PARAM_INDEX_EXTRADATA; |
| 1596 | extra.index = msm_comm_get_hal_extradata_index(ctrl->val); |
| 1597 | extra.enable = 1; |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 1598 | |
| 1599 | switch (ctrl->val) { |
| 1600 | case V4L2_MPEG_VIDC_EXTRADATA_INPUT_CROP: |
| 1601 | case V4L2_MPEG_VIDC_EXTRADATA_DIGITAL_ZOOM: |
| 1602 | case V4L2_MPEG_VIDC_EXTRADATA_ASPECT_RATIO: |
| 1603 | case V4L2_MPEG_VIDC_EXTRADATA_YUV_STATS: |
| 1604 | case V4L2_MPEG_VIDC_EXTRADATA_ROI_QP: |
| 1605 | case V4L2_MPEG_VIDC_EXTRADATA_PQ_INFO: |
| 1606 | inst->bufq[OUTPUT_PORT].num_planes = 2; |
| 1607 | break; |
| 1608 | case V4L2_MPEG_VIDC_EXTRADATA_MULTISLICE_INFO: |
| 1609 | case V4L2_MPEG_VIDC_EXTRADATA_LTR: |
| 1610 | case V4L2_MPEG_VIDC_EXTRADATA_METADATA_MBI: |
| 1611 | inst->bufq[CAPTURE_PORT].num_planes = 2; |
| 1612 | break; |
| 1613 | default: |
| 1614 | rc = -ENOTSUPP; |
| 1615 | break; |
| 1616 | } |
| 1617 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1618 | pdata = &extra; |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 1619 | rc = call_hfi_op(hdev, session_set_property, |
| 1620 | (void *)inst->session, property_id, pdata); |
| 1621 | |
| 1622 | rc = msm_comm_try_get_bufreqs(inst); |
| 1623 | if (rc) { |
| 1624 | dprintk(VIDC_ERR, |
| 1625 | "Failed to get buffer requirements: %d\n", rc); |
| 1626 | break; |
| 1627 | } |
| 1628 | |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 1629 | extra_idx = EXTRADATA_IDX(inst->bufq[OUTPUT_PORT].num_planes); |
Vikash Garodia | cd22b23 | 2017-07-26 20:41:40 +0530 | [diff] [blame] | 1630 | if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) { |
| 1631 | buff_req_buffer = get_buff_req_buffer(inst, |
| 1632 | HAL_BUFFER_EXTRADATA_INPUT); |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 1633 | |
Vikash Garodia | cd22b23 | 2017-07-26 20:41:40 +0530 | [diff] [blame] | 1634 | inst->bufq[OUTPUT_PORT].plane_sizes[extra_idx] = |
| 1635 | buff_req_buffer ? |
| 1636 | buff_req_buffer->buffer_size : 0; |
| 1637 | } |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 1638 | |
| 1639 | extra_idx = EXTRADATA_IDX(inst->bufq[CAPTURE_PORT].num_planes); |
Vikash Garodia | cd22b23 | 2017-07-26 20:41:40 +0530 | [diff] [blame] | 1640 | if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) { |
| 1641 | buff_req_buffer = get_buff_req_buffer(inst, |
| 1642 | HAL_BUFFER_EXTRADATA_OUTPUT); |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 1643 | |
Vikash Garodia | cd22b23 | 2017-07-26 20:41:40 +0530 | [diff] [blame] | 1644 | inst->bufq[CAPTURE_PORT].plane_sizes[extra_idx] = |
| 1645 | buff_req_buffer ? |
| 1646 | buff_req_buffer->buffer_size : 0; |
| 1647 | } |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 1648 | property_id = 0; |
| 1649 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1650 | break; |
| 1651 | case V4L2_CID_MPEG_VIDC_VIDEO_AU_DELIMITER: |
Umesh Pandey | 7fce7ee | 2017-03-13 17:59:48 -0700 | [diff] [blame] | 1652 | property_id = HAL_PARAM_VENC_GENERATE_AUDNAL; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1653 | |
| 1654 | switch (ctrl->val) { |
| 1655 | case V4L2_MPEG_VIDC_VIDEO_AU_DELIMITER_DISABLED: |
| 1656 | enable.enable = 0; |
| 1657 | break; |
| 1658 | case V4L2_MPEG_VIDC_VIDEO_AU_DELIMITER_ENABLED: |
| 1659 | enable.enable = 1; |
| 1660 | break; |
| 1661 | default: |
| 1662 | rc = -ENOTSUPP; |
| 1663 | break; |
| 1664 | } |
| 1665 | |
| 1666 | pdata = &enable; |
| 1667 | break; |
| 1668 | case V4L2_CID_MPEG_VIDC_VIDEO_PRESERVE_TEXT_QUALITY: |
| 1669 | property_id = HAL_PARAM_VENC_PRESERVE_TEXT_QUALITY; |
| 1670 | preserve_text_quality.enable = ctrl->val; |
| 1671 | pdata = &preserve_text_quality; |
| 1672 | break; |
| 1673 | case V4L2_CID_MPEG_VIDC_VIDEO_USELTRFRAME: |
| 1674 | property_id = HAL_CONFIG_VENC_USELTRFRAME; |
Chinmay Sawarkar | 73d6fbb | 2017-08-03 19:07:52 -0700 | [diff] [blame] | 1675 | use_ltr.ref_ltr = 0x1 << ctrl->val; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1676 | use_ltr.use_constraint = false; |
| 1677 | use_ltr.frames = 0; |
| 1678 | pdata = &use_ltr; |
| 1679 | break; |
| 1680 | case V4L2_CID_MPEG_VIDC_VIDEO_MARKLTRFRAME: |
| 1681 | property_id = HAL_CONFIG_VENC_MARKLTRFRAME; |
| 1682 | mark_ltr.mark_frame = ctrl->val; |
| 1683 | pdata = &mark_ltr; |
| 1684 | break; |
| 1685 | case V4L2_CID_MPEG_VIDC_VIDEO_HIER_P_NUM_LAYERS: |
| 1686 | property_id = HAL_CONFIG_VENC_HIER_P_NUM_FRAMES; |
| 1687 | hier_p_layers = ctrl->val; |
| 1688 | if (hier_p_layers > inst->capability.hier_p.max) { |
| 1689 | dprintk(VIDC_ERR, |
| 1690 | "Error setting hier p num layers %d max supported is %d\n", |
| 1691 | hier_p_layers, inst->capability.hier_p.max); |
| 1692 | rc = -ENOTSUPP; |
| 1693 | break; |
| 1694 | } |
| 1695 | pdata = &hier_p_layers; |
| 1696 | break; |
| 1697 | case V4L2_CID_MPEG_VIDC_VIDEO_VPX_ERROR_RESILIENCE: |
| 1698 | property_id = HAL_PARAM_VENC_VPX_ERROR_RESILIENCE_MODE; |
| 1699 | enable.enable = ctrl->val; |
| 1700 | pdata = &enable; |
| 1701 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1702 | case V4L2_CID_MPEG_VIDC_VIDEO_HYBRID_HIERP_MODE: |
| 1703 | property_id = HAL_PARAM_VENC_HIER_P_HYBRID_MODE; |
| 1704 | hyb_hierp.layers = ctrl->val; |
| 1705 | pdata = &hyb_hierp; |
| 1706 | break; |
| 1707 | case V4L2_CID_VIDC_QBUF_MODE: |
| 1708 | property_id = HAL_PARAM_SYNC_BASED_INTERRUPT; |
| 1709 | enable.enable = ctrl->val == V4L2_VIDC_QBUF_BATCHED; |
| 1710 | pdata = &enable; |
| 1711 | break; |
| 1712 | case V4L2_CID_MPEG_VIDC_VIDEO_MAX_HIERP_LAYERS: |
| 1713 | property_id = HAL_PARAM_VENC_HIER_P_MAX_ENH_LAYERS; |
| 1714 | max_hierp_layers = ctrl->val; |
| 1715 | if (max_hierp_layers > inst->capability.hier_p.max) { |
| 1716 | dprintk(VIDC_ERR, |
| 1717 | "Error max HP layers(%d)>max supported(%d)\n", |
| 1718 | max_hierp_layers, inst->capability.hier_p.max); |
| 1719 | rc = -ENOTSUPP; |
| 1720 | break; |
| 1721 | } |
| 1722 | pdata = &max_hierp_layers; |
| 1723 | break; |
| 1724 | case V4L2_CID_MPEG_VIDC_VIDEO_BASELAYER_ID: |
| 1725 | property_id = HAL_CONFIG_VENC_BASELAYER_PRIORITYID; |
| 1726 | baselayerid = ctrl->val; |
| 1727 | pdata = &baselayerid; |
| 1728 | break; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1729 | case V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP: { |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 1730 | struct v4l2_ctrl *qpp, *qpb, *mask; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1731 | |
| 1732 | property_id = HAL_CONFIG_VENC_FRAME_QP; |
| 1733 | qpp = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP); |
| 1734 | qpb = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP); |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 1735 | mask = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_QP_MASK); |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1736 | |
| 1737 | quant.qpi = ctrl->val; |
| 1738 | quant.qpp = qpp->val; |
| 1739 | quant.qpb = qpb->val; |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 1740 | quant.enable = mask->val; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1741 | quant.layer_id = MSM_VIDC_ALL_LAYER_ID; |
| 1742 | pdata = &quant; |
| 1743 | break; |
| 1744 | } |
| 1745 | case V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP: { |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 1746 | struct v4l2_ctrl *qpi, *qpb, *mask; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1747 | |
| 1748 | property_id = HAL_CONFIG_VENC_FRAME_QP; |
| 1749 | qpi = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP); |
| 1750 | qpb = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP); |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 1751 | mask = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_QP_MASK); |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1752 | |
| 1753 | quant.qpp = ctrl->val; |
| 1754 | quant.qpi = qpi->val; |
| 1755 | quant.qpb = qpb->val; |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 1756 | quant.enable = mask->val; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1757 | quant.layer_id = MSM_VIDC_ALL_LAYER_ID; |
| 1758 | pdata = &quant; |
| 1759 | break; |
| 1760 | } |
| 1761 | case V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP: { |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 1762 | struct v4l2_ctrl *qpp, *qpi, *mask; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1763 | |
| 1764 | property_id = HAL_CONFIG_VENC_FRAME_QP; |
| 1765 | qpp = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP); |
| 1766 | qpi = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP); |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 1767 | mask = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_QP_MASK); |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1768 | |
| 1769 | quant.qpb = ctrl->val; |
| 1770 | quant.qpp = qpp->val; |
| 1771 | quant.qpi = qpi->val; |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 1772 | quant.enable = mask->val; |
| 1773 | quant.layer_id = MSM_VIDC_ALL_LAYER_ID; |
| 1774 | pdata = &quant; |
| 1775 | break; |
| 1776 | } |
| 1777 | case V4L2_CID_MPEG_VIDC_VIDEO_QP_MASK: { |
| 1778 | struct v4l2_ctrl *qpi, *qpp, *qpb; |
| 1779 | |
| 1780 | property_id = HAL_CONFIG_VENC_FRAME_QP; |
| 1781 | qpi = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP); |
| 1782 | qpp = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP); |
| 1783 | qpb = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP); |
| 1784 | |
| 1785 | quant.qpi = qpi->val; |
| 1786 | quant.qpp = qpp->val; |
| 1787 | quant.qpb = qpb->val; |
| 1788 | quant.enable = ctrl->val; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 1789 | quant.layer_id = MSM_VIDC_ALL_LAYER_ID; |
| 1790 | pdata = &quant; |
| 1791 | break; |
| 1792 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1793 | case V4L2_CID_MPEG_VIDC_VIDEO_VQZIP_SEI: |
| 1794 | property_id = HAL_PARAM_VENC_VQZIP_SEI; |
| 1795 | enable.enable = ctrl->val; |
| 1796 | pdata = &enable; |
| 1797 | break; |
| 1798 | case V4L2_CID_MPEG_VIDC_VIDEO_PRIORITY: |
| 1799 | property_id = HAL_CONFIG_REALTIME; |
| 1800 | /* firmware has inverted values for realtime and |
| 1801 | * non-realtime priority |
| 1802 | */ |
| 1803 | enable.enable = !(ctrl->val); |
| 1804 | pdata = &enable; |
| 1805 | switch (ctrl->val) { |
| 1806 | case V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_DISABLE: |
| 1807 | inst->flags &= ~VIDC_REALTIME; |
| 1808 | break; |
| 1809 | case V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_ENABLE: |
| 1810 | inst->flags |= VIDC_REALTIME; |
| 1811 | break; |
| 1812 | default: |
| 1813 | dprintk(VIDC_WARN, |
| 1814 | "inst(%pK) invalid priority ctrl value %#x\n", |
| 1815 | inst, ctrl->val); |
| 1816 | break; |
| 1817 | } |
| 1818 | break; |
| 1819 | case V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE: |
| 1820 | dprintk(VIDC_DBG, |
| 1821 | "inst(%pK) operating rate changed from %d to %d\n", |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 1822 | inst, inst->clk_data.operating_rate >> 16, |
| 1823 | ctrl->val >> 16); |
| 1824 | inst->clk_data.operating_rate = ctrl->val; |
| 1825 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1826 | break; |
| 1827 | case V4L2_CID_MPEG_VIDC_VIDEO_VENC_BITRATE_TYPE: |
| 1828 | { |
| 1829 | property_id = HAL_PARAM_VENC_BITRATE_TYPE; |
| 1830 | enable.enable = ctrl->val; |
| 1831 | pdata = &enable; |
| 1832 | break; |
| 1833 | } |
| 1834 | case V4L2_CID_MPEG_VIDC_VIDEO_COLOR_SPACE: |
| 1835 | { |
| 1836 | signal_info.color_space = ctrl->val; |
| 1837 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_FULL_RANGE); |
| 1838 | signal_info.full_range = temp_ctrl ? temp_ctrl->val : 0; |
| 1839 | temp_ctrl = |
| 1840 | TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_TRANSFER_CHARS); |
| 1841 | signal_info.transfer_chars = temp_ctrl ? temp_ctrl->val : 0; |
| 1842 | temp_ctrl = |
| 1843 | TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_MATRIX_COEFFS); |
| 1844 | signal_info.matrix_coeffs = temp_ctrl ? temp_ctrl->val : 0; |
| 1845 | property_id = HAL_PARAM_VENC_VIDEO_SIGNAL_INFO; |
| 1846 | pdata = &signal_info; |
| 1847 | break; |
| 1848 | } |
| 1849 | case V4L2_CID_MPEG_VIDC_VIDEO_FULL_RANGE: |
| 1850 | { |
| 1851 | signal_info.full_range = ctrl->val; |
| 1852 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_COLOR_SPACE); |
| 1853 | signal_info.color_space = temp_ctrl ? temp_ctrl->val : 0; |
| 1854 | temp_ctrl = |
| 1855 | TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_TRANSFER_CHARS); |
| 1856 | signal_info.transfer_chars = temp_ctrl ? temp_ctrl->val : 0; |
| 1857 | temp_ctrl = |
| 1858 | TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_MATRIX_COEFFS); |
| 1859 | signal_info.matrix_coeffs = temp_ctrl ? temp_ctrl->val : 0; |
| 1860 | property_id = HAL_PARAM_VENC_VIDEO_SIGNAL_INFO; |
| 1861 | pdata = &signal_info; |
| 1862 | break; |
| 1863 | } |
| 1864 | case V4L2_CID_MPEG_VIDC_VIDEO_TRANSFER_CHARS: |
| 1865 | { |
| 1866 | signal_info.transfer_chars = ctrl->val; |
| 1867 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_FULL_RANGE); |
| 1868 | signal_info.full_range = temp_ctrl ? temp_ctrl->val : 0; |
| 1869 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_COLOR_SPACE); |
| 1870 | signal_info.color_space = temp_ctrl ? temp_ctrl->val : 0; |
| 1871 | temp_ctrl = |
| 1872 | TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_MATRIX_COEFFS); |
| 1873 | signal_info.matrix_coeffs = temp_ctrl ? temp_ctrl->val : 0; |
| 1874 | property_id = HAL_PARAM_VENC_VIDEO_SIGNAL_INFO; |
| 1875 | pdata = &signal_info; |
| 1876 | break; |
| 1877 | } |
| 1878 | case V4L2_CID_MPEG_VIDC_VIDEO_MATRIX_COEFFS: |
| 1879 | { |
| 1880 | signal_info.matrix_coeffs = ctrl->val; |
| 1881 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_FULL_RANGE); |
| 1882 | signal_info.full_range = temp_ctrl ? temp_ctrl->val : 0; |
| 1883 | temp_ctrl = |
| 1884 | TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_TRANSFER_CHARS); |
| 1885 | signal_info.transfer_chars = temp_ctrl ? temp_ctrl->val : 0; |
| 1886 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_COLOR_SPACE); |
| 1887 | signal_info.color_space = temp_ctrl ? temp_ctrl->val : 0; |
| 1888 | property_id = HAL_PARAM_VENC_VIDEO_SIGNAL_INFO; |
| 1889 | pdata = &signal_info; |
| 1890 | break; |
| 1891 | } |
| 1892 | case V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC: |
Chinmay Sawarkar | ddd1d97 | 2017-08-15 10:10:06 -0700 | [diff] [blame] | 1893 | if (ctrl->val != V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC_ENABLE) |
| 1894 | break; |
| 1895 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_COLOR_SPACE); |
| 1896 | color_primaries = temp_ctrl->val; |
| 1897 | temp_ctrl = |
| 1898 | TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC_CUSTOM_MATRIX); |
| 1899 | custom_matrix = temp_ctrl->val; |
| 1900 | rc = msm_venc_set_csc(inst, color_primaries, custom_matrix); |
| 1901 | if (rc) |
| 1902 | dprintk(VIDC_ERR, "fail to set csc: %d\n", rc); |
| 1903 | break; |
| 1904 | case V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC_CUSTOM_MATRIX: |
| 1905 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_COLOR_SPACE); |
| 1906 | color_primaries = temp_ctrl->val; |
| 1907 | rc = msm_venc_set_csc(inst, color_primaries, ctrl->val); |
| 1908 | if (rc) |
| 1909 | dprintk(VIDC_ERR, "fail to set csc: %d\n", rc); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1910 | break; |
| 1911 | case V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_MODE: |
| 1912 | { |
| 1913 | property_id = HAL_PARAM_VENC_LOW_LATENCY; |
| 1914 | if (ctrl->val == |
| 1915 | V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_ENABLE) |
| 1916 | enable.enable = 1; |
| 1917 | else |
| 1918 | enable.enable = 0; |
| 1919 | pdata = &enable; |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 1920 | inst->clk_data.low_latency_mode = (bool) enable.enable; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1921 | break; |
| 1922 | } |
| 1923 | case V4L2_CID_MPEG_VIDC_VIDEO_H264_TRANSFORM_8x8: |
| 1924 | property_id = HAL_PARAM_VENC_H264_TRANSFORM_8x8; |
| 1925 | switch (ctrl->val) { |
| 1926 | case V4L2_MPEG_VIDC_VIDEO_H264_TRANSFORM_8x8_ENABLE: |
| 1927 | enable.enable = 1; |
| 1928 | break; |
| 1929 | case V4L2_MPEG_VIDC_VIDEO_H264_TRANSFORM_8x8_DISABLE: |
| 1930 | enable.enable = 0; |
| 1931 | break; |
| 1932 | default: |
| 1933 | dprintk(VIDC_ERR, |
| 1934 | "Invalid H264 8x8 transform control value %d\n", |
| 1935 | ctrl->val); |
| 1936 | rc = -ENOTSUPP; |
| 1937 | break; |
| 1938 | } |
| 1939 | pdata = &enable; |
| 1940 | break; |
| 1941 | case V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_TYPE: |
| 1942 | property_id = HAL_PARAM_VENC_IFRAMESIZE_TYPE; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1943 | iframesize_type = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1944 | V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_TYPE, |
| 1945 | ctrl->val); |
| 1946 | pdata = &iframesize_type; |
| 1947 | break; |
Chinmay Sawarkar | 0f7cf2e | 2017-05-04 11:35:56 -0700 | [diff] [blame] | 1948 | case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE: |
| 1949 | { |
| 1950 | property_id = HAL_PARAM_VENC_DISABLE_RC_TIMESTAMP; |
| 1951 | enable.enable = ctrl->val; |
| 1952 | pdata = &enable; |
| 1953 | break; |
| 1954 | } |
Chinmay Sawarkar | d005462 | 2017-05-04 13:50:59 -0700 | [diff] [blame] | 1955 | case V4L2_CID_MPEG_VIDC_VIDEO_VUI_TIMING_INFO: |
| 1956 | { |
| 1957 | struct v4l2_ctrl *rc_mode; |
| 1958 | bool cfr = false; |
| 1959 | |
| 1960 | property_id = HAL_PARAM_VENC_VUI_TIMING_INFO; |
| 1961 | pdata = &vui_timing_info; |
| 1962 | |
| 1963 | if (ctrl->val != V4L2_MPEG_VIDC_VIDEO_VUI_TIMING_INFO_ENABLED) { |
| 1964 | vui_timing_info.enable = 0; |
| 1965 | break; |
| 1966 | } |
| 1967 | |
| 1968 | rc_mode = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL); |
| 1969 | |
| 1970 | switch (rc_mode->val) { |
| 1971 | case V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_VBR_CFR: |
| 1972 | case V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_CFR: |
| 1973 | case V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_MBR_CFR: |
| 1974 | cfr = true; |
| 1975 | break; |
| 1976 | default: |
| 1977 | cfr = false; |
| 1978 | } |
| 1979 | |
| 1980 | vui_timing_info.enable = 1; |
| 1981 | vui_timing_info.fixed_frame_rate = cfr; |
| 1982 | vui_timing_info.time_scale = NSEC_PER_SEC; |
| 1983 | break; |
| 1984 | } |
Maheshwar Ajja | 850be3c | 2017-07-06 17:47:40 -0700 | [diff] [blame] | 1985 | case V4L2_CID_MPEG_VIDC_VIDEO_LTRMODE: |
| 1986 | case V4L2_CID_MPEG_VIDC_VIDEO_LTRCOUNT: |
| 1987 | case V4L2_CID_MPEG_VIDC_VENC_PARAM_SAR_WIDTH: |
| 1988 | case V4L2_CID_MPEG_VIDC_VENC_PARAM_SAR_HEIGHT: |
| 1989 | case V4L2_CID_MPEG_VIDC_VIDEO_BLUR_WIDTH: |
| 1990 | case V4L2_CID_MPEG_VIDC_VIDEO_BLUR_HEIGHT: |
| 1991 | case V4L2_CID_MPEG_VIDC_VIDEO_LAYER_ID: |
| 1992 | case V4L2_CID_MPEG_VIDC_VENC_PARAM_LAYER_BITRATE: |
| 1993 | case V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP_MIN: |
| 1994 | case V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP_MIN: |
| 1995 | case V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP_MIN: |
| 1996 | case V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP_MAX: |
| 1997 | case V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP_MAX: |
| 1998 | case V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP_MAX: |
| 1999 | dprintk(VIDC_DBG, "Set the control : %#x using ext ctrl\n", |
| 2000 | ctrl->id); |
| 2001 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2002 | default: |
| 2003 | dprintk(VIDC_ERR, "Unsupported index: %x\n", ctrl->id); |
| 2004 | rc = -ENOTSUPP; |
| 2005 | break; |
| 2006 | } |
| 2007 | |
| 2008 | v4l2_ctrl_lock(ctrl); |
| 2009 | #undef TRY_GET_CTRL |
| 2010 | |
| 2011 | if (!rc && property_id) { |
Praneeth Paladugu | 92fc3b0 | 2017-05-02 15:35:17 -0700 | [diff] [blame] | 2012 | dprintk(VIDC_DBG, |
| 2013 | "Control: Name = %s, ID = 0x%x Value = %d\n", |
| 2014 | ctrl->name, ctrl->id, ctrl->val); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2015 | rc = call_hfi_op(hdev, session_set_property, |
| 2016 | (void *)inst->session, property_id, pdata); |
| 2017 | } |
| 2018 | |
| 2019 | return rc; |
| 2020 | } |
| 2021 | |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 2022 | int msm_venc_s_ext_ctrl(struct msm_vidc_inst *inst, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2023 | struct v4l2_ext_controls *ctrl) |
| 2024 | { |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2025 | int rc = 0, i; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2026 | struct v4l2_ext_control *control; |
| 2027 | struct hfi_device *hdev; |
| 2028 | struct hal_ltr_mode ltr_mode; |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 2029 | u32 property_id = 0; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2030 | void *pdata = NULL; |
| 2031 | struct msm_vidc_capability *cap = NULL; |
| 2032 | struct hal_aspect_ratio sar; |
| 2033 | struct hal_bitrate bitrate; |
| 2034 | struct hal_frame_size blur_res; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 2035 | struct hal_quantization_range qp_range; |
| 2036 | struct hal_quantization qp; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2037 | |
| 2038 | if (!inst || !inst->core || !inst->core->device || !ctrl) { |
| 2039 | dprintk(VIDC_ERR, "%s invalid parameters\n", __func__); |
| 2040 | return -EINVAL; |
| 2041 | } |
| 2042 | |
Vaibhav Deshu Venkatesh | d0792bc | 2017-03-16 14:55:51 -0700 | [diff] [blame] | 2043 | /* This will check the range for contols and clip if necessary */ |
| 2044 | v4l2_try_ext_ctrls(&inst->ctrl_handler, ctrl); |
| 2045 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2046 | hdev = inst->core->device; |
| 2047 | cap = &inst->capability; |
| 2048 | |
| 2049 | control = ctrl->controls; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 2050 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2051 | for (i = 0; i < ctrl->count; i++) { |
| 2052 | switch (control[i].id) { |
| 2053 | case V4L2_CID_MPEG_VIDC_VIDEO_LTRMODE: |
| 2054 | if (control[i].value != |
| 2055 | V4L2_MPEG_VIDC_VIDEO_LTR_MODE_DISABLE) { |
| 2056 | rc = msm_venc_toggle_hier_p(inst, false); |
| 2057 | if (rc) |
| 2058 | break; |
| 2059 | } |
| 2060 | ltr_mode.mode = control[i].value; |
| 2061 | ltr_mode.trust_mode = 1; |
| 2062 | property_id = HAL_PARAM_VENC_LTRMODE; |
| 2063 | pdata = <r_mode; |
| 2064 | break; |
| 2065 | case V4L2_CID_MPEG_VIDC_VIDEO_LTRCOUNT: |
| 2066 | ltr_mode.count = control[i].value; |
| 2067 | if (ltr_mode.count > cap->ltr_count.max) { |
| 2068 | dprintk(VIDC_ERR, |
| 2069 | "Invalid LTR count %d. Supported max: %d\n", |
| 2070 | ltr_mode.count, |
| 2071 | cap->ltr_count.max); |
| 2072 | /* |
| 2073 | * FIXME: Return an error (-EINVALID) |
| 2074 | * here once VP8 supports LTR count |
| 2075 | * capability |
| 2076 | */ |
| 2077 | ltr_mode.count = 1; |
| 2078 | } |
| 2079 | ltr_mode.trust_mode = 1; |
| 2080 | property_id = HAL_PARAM_VENC_LTRMODE; |
| 2081 | pdata = <r_mode; |
| 2082 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2083 | case V4L2_CID_MPEG_VIDC_VENC_PARAM_SAR_WIDTH: |
| 2084 | sar.aspect_width = control[i].value; |
| 2085 | property_id = HAL_PROPERTY_PARAM_VENC_ASPECT_RATIO; |
| 2086 | pdata = &sar; |
| 2087 | break; |
| 2088 | case V4L2_CID_MPEG_VIDC_VENC_PARAM_SAR_HEIGHT: |
| 2089 | sar.aspect_height = control[i].value; |
| 2090 | property_id = HAL_PROPERTY_PARAM_VENC_ASPECT_RATIO; |
| 2091 | pdata = &sar; |
| 2092 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2093 | case V4L2_CID_MPEG_VIDC_VIDEO_BLUR_WIDTH: |
| 2094 | property_id = HAL_CONFIG_VENC_BLUR_RESOLUTION; |
| 2095 | blur_res.width = control[i].value; |
| 2096 | blur_res.buffer_type = HAL_BUFFER_INPUT; |
| 2097 | property_id = HAL_CONFIG_VENC_BLUR_RESOLUTION; |
| 2098 | pdata = &blur_res; |
| 2099 | break; |
| 2100 | case V4L2_CID_MPEG_VIDC_VIDEO_BLUR_HEIGHT: |
| 2101 | blur_res.height = control[i].value; |
| 2102 | blur_res.buffer_type = HAL_BUFFER_INPUT; |
| 2103 | property_id = HAL_CONFIG_VENC_BLUR_RESOLUTION; |
| 2104 | pdata = &blur_res; |
| 2105 | break; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 2106 | case V4L2_CID_MPEG_VIDC_VIDEO_LAYER_ID: |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 2107 | qp.layer_id = control[i].value; |
| 2108 | /* Enable QP for all frame types by default */ |
| 2109 | qp.enable = 7; |
| 2110 | qp_range.layer_id = control[i].value; |
Vaibhav Deshu Venkatesh | b494b81 | 2017-05-03 16:32:25 -0700 | [diff] [blame] | 2111 | bitrate.layer_id = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2112 | i++; |
| 2113 | while (i < ctrl->count) { |
| 2114 | switch (control[i].id) { |
| 2115 | case V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP: |
| 2116 | qp.qpi = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2117 | property_id = |
| 2118 | HAL_CONFIG_VENC_FRAME_QP; |
| 2119 | pdata = &qp; |
| 2120 | break; |
| 2121 | case V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP: |
| 2122 | qp.qpp = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2123 | property_id = |
| 2124 | HAL_CONFIG_VENC_FRAME_QP; |
| 2125 | pdata = &qp; |
| 2126 | break; |
| 2127 | case V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP: |
| 2128 | qp.qpb = control[i].value; |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 2129 | property_id = |
| 2130 | HAL_CONFIG_VENC_FRAME_QP; |
| 2131 | pdata = &qp; |
| 2132 | break; |
| 2133 | case V4L2_CID_MPEG_VIDC_VIDEO_QP_MASK: |
| 2134 | qp.enable = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2135 | property_id = |
| 2136 | HAL_CONFIG_VENC_FRAME_QP; |
| 2137 | pdata = &qp; |
| 2138 | break; |
| 2139 | case V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP_MIN: |
| 2140 | qp_range.qpi_min = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2141 | property_id = |
| 2142 | HAL_PARAM_VENC_SESSION_QP_RANGE; |
| 2143 | pdata = &qp_range; |
| 2144 | break; |
| 2145 | case V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP_MIN: |
| 2146 | qp_range.qpp_min = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2147 | property_id = |
Vaibhav Deshu Venkatesh | 3a14716 | 2017-04-27 16:21:12 -0700 | [diff] [blame] | 2148 | HAL_PARAM_VENC_SESSION_QP_RANGE; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2149 | pdata = &qp_range; |
| 2150 | break; |
| 2151 | case V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP_MIN: |
| 2152 | qp_range.qpb_min = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2153 | property_id = |
| 2154 | HAL_PARAM_VENC_SESSION_QP_RANGE; |
| 2155 | pdata = &qp_range; |
| 2156 | break; |
| 2157 | case V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP_MAX: |
| 2158 | qp_range.qpi_max = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2159 | property_id = |
| 2160 | HAL_PARAM_VENC_SESSION_QP_RANGE; |
| 2161 | pdata = &qp_range; |
| 2162 | break; |
| 2163 | case V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP_MAX: |
| 2164 | qp_range.qpp_max = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2165 | property_id = |
| 2166 | HAL_PARAM_VENC_SESSION_QP_RANGE; |
| 2167 | pdata = &qp_range; |
| 2168 | break; |
| 2169 | case V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP_MAX: |
| 2170 | qp_range.qpb_max = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2171 | property_id = |
| 2172 | HAL_PARAM_VENC_SESSION_QP_RANGE; |
| 2173 | pdata = &qp_range; |
| 2174 | break; |
| 2175 | case V4L2_CID_MPEG_VIDC_VENC_PARAM_LAYER_BITRATE: |
| 2176 | bitrate.bit_rate = control[i].value; |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2177 | property_id = |
| 2178 | HAL_CONFIG_VENC_TARGET_BITRATE; |
| 2179 | pdata = &bitrate; |
| 2180 | break; |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 2181 | } |
Vaibhav Deshu Venkatesh | 2c07253 | 2017-04-07 17:50:18 -0700 | [diff] [blame] | 2182 | i++; |
| 2183 | } |
Praneeth Paladugu | 7fbd279 | 2017-01-27 13:39:03 -0800 | [diff] [blame] | 2184 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2185 | default: |
| 2186 | dprintk(VIDC_ERR, "Invalid id set: %d\n", |
| 2187 | control[i].id); |
| 2188 | rc = -ENOTSUPP; |
| 2189 | break; |
| 2190 | } |
| 2191 | if (rc) |
| 2192 | break; |
| 2193 | } |
| 2194 | |
| 2195 | if (!rc && property_id) { |
| 2196 | dprintk(VIDC_DBG, "Control: HAL property=%x\n", property_id); |
| 2197 | rc = call_hfi_op(hdev, session_set_property, |
| 2198 | (void *)inst->session, property_id, pdata); |
| 2199 | } |
| 2200 | return rc; |
| 2201 | } |
| 2202 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2203 | int msm_venc_inst_init(struct msm_vidc_inst *inst) |
| 2204 | { |
| 2205 | int rc = 0; |
Praneeth Paladugu | a6b6aa4 | 2017-05-16 13:33:01 -0700 | [diff] [blame] | 2206 | struct msm_vidc_format *fmt = NULL; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2207 | |
| 2208 | if (!inst) { |
| 2209 | dprintk(VIDC_ERR, "Invalid input = %pK\n", inst); |
| 2210 | return -EINVAL; |
| 2211 | } |
| 2212 | inst->prop.height[CAPTURE_PORT] = DEFAULT_HEIGHT; |
| 2213 | inst->prop.width[CAPTURE_PORT] = DEFAULT_WIDTH; |
| 2214 | inst->prop.height[OUTPUT_PORT] = DEFAULT_HEIGHT; |
| 2215 | inst->prop.width[OUTPUT_PORT] = DEFAULT_WIDTH; |
| 2216 | inst->capability.height.min = MIN_SUPPORTED_HEIGHT; |
| 2217 | inst->capability.height.max = DEFAULT_HEIGHT; |
| 2218 | inst->capability.width.min = MIN_SUPPORTED_WIDTH; |
| 2219 | inst->capability.width.max = DEFAULT_WIDTH; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2220 | inst->capability.secure_output2_threshold.min = 0; |
| 2221 | inst->capability.secure_output2_threshold.max = 0; |
Chinmay Sawarkar | 2de3f77 | 2017-02-07 12:03:44 -0800 | [diff] [blame] | 2222 | inst->buffer_mode_set[OUTPUT_PORT] = HAL_BUFFER_MODE_DYNAMIC; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2223 | inst->buffer_mode_set[CAPTURE_PORT] = HAL_BUFFER_MODE_STATIC; |
| 2224 | inst->prop.fps = DEFAULT_FPS; |
| 2225 | inst->capability.pixelprocess_capabilities = 0; |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 2226 | /* To start with, both ports are 1 plane each */ |
| 2227 | inst->bufq[OUTPUT_PORT].num_planes = 1; |
| 2228 | inst->bufq[CAPTURE_PORT].num_planes = 1; |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 2229 | inst->clk_data.operating_rate = 0; |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 2230 | |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 2231 | inst->buff_req.buffer[1].buffer_type = HAL_BUFFER_INPUT; |
| 2232 | inst->buff_req.buffer[1].buffer_count_min_host = |
| 2233 | inst->buff_req.buffer[1].buffer_count_actual = |
| 2234 | MIN_NUM_ENC_OUTPUT_BUFFERS; |
| 2235 | inst->buff_req.buffer[2].buffer_type = HAL_BUFFER_OUTPUT; |
| 2236 | inst->buff_req.buffer[2].buffer_count_min_host = |
| 2237 | inst->buff_req.buffer[2].buffer_count_actual = |
| 2238 | MIN_NUM_ENC_CAPTURE_BUFFERS; |
| 2239 | |
Praneeth Paladugu | a6b6aa4 | 2017-05-16 13:33:01 -0700 | [diff] [blame] | 2240 | /* By default, initialize OUTPUT port to UBWC YUV format */ |
| 2241 | fmt = msm_comm_get_pixel_fmt_fourcc(venc_formats, |
| 2242 | ARRAY_SIZE(venc_formats), V4L2_PIX_FMT_NV12_UBWC, |
| 2243 | OUTPUT_PORT); |
| 2244 | if (!fmt || fmt->type != OUTPUT_PORT) { |
| 2245 | dprintk(VIDC_ERR, |
| 2246 | "venc_formats corrupted\n"); |
| 2247 | return -EINVAL; |
| 2248 | } |
| 2249 | memcpy(&inst->fmts[fmt->type], fmt, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2250 | sizeof(struct msm_vidc_format)); |
Praneeth Paladugu | a6b6aa4 | 2017-05-16 13:33:01 -0700 | [diff] [blame] | 2251 | |
| 2252 | /* By default, initialize CAPTURE port to H264 encoder */ |
| 2253 | fmt = msm_comm_get_pixel_fmt_fourcc(venc_formats, |
| 2254 | ARRAY_SIZE(venc_formats), V4L2_PIX_FMT_H264, |
| 2255 | CAPTURE_PORT); |
| 2256 | if (!fmt || fmt->type != CAPTURE_PORT) { |
| 2257 | dprintk(VIDC_ERR, |
| 2258 | "venc_formats corrupted\n"); |
| 2259 | return -EINVAL; |
| 2260 | } |
| 2261 | memcpy(&inst->fmts[fmt->type], fmt, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2262 | sizeof(struct msm_vidc_format)); |
Praneeth Paladugu | a6b6aa4 | 2017-05-16 13:33:01 -0700 | [diff] [blame] | 2263 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2264 | return rc; |
| 2265 | } |
| 2266 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2267 | int msm_venc_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f) |
| 2268 | { |
| 2269 | const struct msm_vidc_format *fmt = NULL; |
| 2270 | int rc = 0; |
| 2271 | |
| 2272 | if (!inst || !f) { |
| 2273 | dprintk(VIDC_ERR, |
| 2274 | "Invalid input, inst = %pK, f = %pK\n", inst, f); |
| 2275 | return -EINVAL; |
| 2276 | } |
| 2277 | if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { |
| 2278 | fmt = msm_comm_get_pixel_fmt_index(venc_formats, |
| 2279 | ARRAY_SIZE(venc_formats), f->index, CAPTURE_PORT); |
| 2280 | } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { |
| 2281 | fmt = msm_comm_get_pixel_fmt_index(venc_formats, |
| 2282 | ARRAY_SIZE(venc_formats), f->index, OUTPUT_PORT); |
| 2283 | f->flags = V4L2_FMT_FLAG_COMPRESSED; |
| 2284 | } |
| 2285 | |
| 2286 | memset(f->reserved, 0, sizeof(f->reserved)); |
| 2287 | if (fmt) { |
| 2288 | strlcpy(f->description, fmt->description, |
| 2289 | sizeof(f->description)); |
| 2290 | f->pixelformat = fmt->fourcc; |
| 2291 | } else { |
| 2292 | dprintk(VIDC_DBG, "No more formats found\n"); |
| 2293 | rc = -EINVAL; |
| 2294 | } |
| 2295 | return rc; |
| 2296 | } |
| 2297 | |
Chinmay Sawarkar | ddd1d97 | 2017-08-15 10:10:06 -0700 | [diff] [blame] | 2298 | static int msm_venc_set_csc(struct msm_vidc_inst *inst, |
| 2299 | u32 color_primaries, u32 custom_matrix) |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2300 | { |
| 2301 | int rc = 0; |
| 2302 | int count = 0; |
| 2303 | struct hal_vpe_color_space_conversion vpe_csc; |
Chinmay Sawarkar | ddd1d97 | 2017-08-15 10:10:06 -0700 | [diff] [blame] | 2304 | struct msm_vidc_platform_resources *resources; |
| 2305 | u32 *bias_coeff = NULL; |
| 2306 | u32 *csc_limit = NULL; |
| 2307 | u32 *csc_matrix = NULL; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2308 | |
Chinmay Sawarkar | ddd1d97 | 2017-08-15 10:10:06 -0700 | [diff] [blame] | 2309 | resources = &(inst->core->resources); |
| 2310 | bias_coeff = |
| 2311 | resources->csc_coeff_data->vpe_csc_custom_bias_coeff; |
| 2312 | csc_limit = |
| 2313 | resources->csc_coeff_data->vpe_csc_custom_limit_coeff; |
| 2314 | csc_matrix = |
| 2315 | resources->csc_coeff_data->vpe_csc_custom_matrix_coeff; |
| 2316 | |
| 2317 | vpe_csc.input_color_primaries = color_primaries; |
| 2318 | /* Custom bias, matrix & limit */ |
| 2319 | vpe_csc.custom_matrix_enabled = custom_matrix; |
| 2320 | |
| 2321 | if (vpe_csc.custom_matrix_enabled && bias_coeff != NULL |
| 2322 | && csc_limit != NULL && csc_matrix != NULL) { |
| 2323 | while (count < HAL_MAX_MATRIX_COEFFS) { |
| 2324 | if (count < HAL_MAX_BIAS_COEFFS) |
| 2325 | vpe_csc.csc_bias[count] = |
| 2326 | bias_coeff[count]; |
| 2327 | if (count < HAL_MAX_LIMIT_COEFFS) |
| 2328 | vpe_csc.csc_limit[count] = |
| 2329 | csc_limit[count]; |
| 2330 | vpe_csc.csc_matrix[count] = |
| 2331 | csc_matrix[count]; |
| 2332 | count = count + 1; |
| 2333 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2334 | } |
| 2335 | rc = msm_comm_try_set_prop(inst, |
| 2336 | HAL_PARAM_VPE_COLOR_SPACE_CONVERSION, &vpe_csc); |
| 2337 | if (rc) |
| 2338 | dprintk(VIDC_ERR, "Setting VPE coefficients failed\n"); |
| 2339 | |
| 2340 | return rc; |
| 2341 | } |
| 2342 | |
| 2343 | int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) |
| 2344 | { |
| 2345 | struct msm_vidc_format *fmt = NULL; |
| 2346 | int rc = 0; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2347 | struct hfi_device *hdev; |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 2348 | int extra_idx = 0, i = 0; |
| 2349 | struct hal_buffer_requirements *buff_req_buffer; |
Praneeth Paladugu | 1f9d1d9 | 2017-04-11 10:36:16 -0700 | [diff] [blame] | 2350 | struct hal_frame_size frame_sz; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2351 | |
| 2352 | if (!inst || !f) { |
| 2353 | dprintk(VIDC_ERR, |
| 2354 | "Invalid input, inst = %pK, format = %pK\n", inst, f); |
| 2355 | return -EINVAL; |
| 2356 | } |
| 2357 | |
| 2358 | if (!inst->core || !inst->core->device) { |
| 2359 | dprintk(VIDC_ERR, "%s invalid parameters\n", __func__); |
| 2360 | return -EINVAL; |
| 2361 | } |
| 2362 | hdev = inst->core->device; |
| 2363 | |
| 2364 | if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 2365 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2366 | fmt = msm_comm_get_pixel_fmt_fourcc(venc_formats, |
| 2367 | ARRAY_SIZE(venc_formats), f->fmt.pix_mp.pixelformat, |
| 2368 | CAPTURE_PORT); |
| 2369 | if (!fmt || fmt->type != CAPTURE_PORT) { |
| 2370 | dprintk(VIDC_ERR, |
| 2371 | "Format: %d not supported on CAPTURE port\n", |
| 2372 | f->fmt.pix_mp.pixelformat); |
| 2373 | rc = -EINVAL; |
| 2374 | goto exit; |
| 2375 | } |
| 2376 | |
| 2377 | memcpy(&inst->fmts[fmt->type], fmt, |
| 2378 | sizeof(struct msm_vidc_format)); |
| 2379 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2380 | rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE); |
| 2381 | if (rc) { |
| 2382 | dprintk(VIDC_ERR, "Failed to open instance\n"); |
| 2383 | goto exit; |
| 2384 | } |
| 2385 | |
| 2386 | inst->prop.width[CAPTURE_PORT] = f->fmt.pix_mp.width; |
| 2387 | inst->prop.height[CAPTURE_PORT] = f->fmt.pix_mp.height; |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 2388 | |
Praneeth Paladugu | 1f9d1d9 | 2017-04-11 10:36:16 -0700 | [diff] [blame] | 2389 | frame_sz.buffer_type = HAL_BUFFER_OUTPUT; |
| 2390 | frame_sz.width = inst->prop.width[CAPTURE_PORT]; |
| 2391 | frame_sz.height = inst->prop.height[CAPTURE_PORT]; |
| 2392 | dprintk(VIDC_DBG, "CAPTURE port width = %d, height = %d\n", |
| 2393 | frame_sz.width, frame_sz.height); |
| 2394 | rc = call_hfi_op(hdev, session_set_property, (void *) |
| 2395 | inst->session, HAL_PARAM_FRAME_SIZE, &frame_sz); |
| 2396 | if (rc) { |
| 2397 | dprintk(VIDC_ERR, |
| 2398 | "Failed to set framesize for CAPTURE port\n"); |
| 2399 | goto exit; |
| 2400 | } |
| 2401 | |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 2402 | rc = msm_comm_try_get_bufreqs(inst); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2403 | if (rc) { |
| 2404 | dprintk(VIDC_ERR, |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 2405 | "Failed to get buffer requirements: %d\n", rc); |
| 2406 | return rc; |
| 2407 | } |
| 2408 | |
| 2409 | /* |
| 2410 | * Get CAPTURE plane size from HW. This may change based on |
| 2411 | * settings like Slice delivery mode. HW should decide howmuch |
| 2412 | * it needs. |
| 2413 | */ |
| 2414 | |
| 2415 | buff_req_buffer = get_buff_req_buffer(inst, |
| 2416 | HAL_BUFFER_OUTPUT); |
| 2417 | |
| 2418 | f->fmt.pix_mp.plane_fmt[0].sizeimage = buff_req_buffer ? |
| 2419 | buff_req_buffer->buffer_size : 0; |
| 2420 | |
| 2421 | /* |
| 2422 | * Get CAPTURE plane Extradata size from HW. This may change |
| 2423 | * with no of Extradata's enabled. HW should decide howmuch |
| 2424 | * it needs. |
| 2425 | */ |
| 2426 | |
| 2427 | extra_idx = EXTRADATA_IDX(inst->bufq[fmt->type].num_planes); |
| 2428 | if (extra_idx && extra_idx < VIDEO_MAX_PLANES) { |
| 2429 | buff_req_buffer = get_buff_req_buffer(inst, |
| 2430 | HAL_BUFFER_EXTRADATA_OUTPUT); |
| 2431 | f->fmt.pix_mp.plane_fmt[extra_idx].sizeimage = |
| 2432 | buff_req_buffer ? |
| 2433 | buff_req_buffer->buffer_size : 0; |
| 2434 | } |
| 2435 | |
| 2436 | f->fmt.pix_mp.num_planes = inst->bufq[fmt->type].num_planes; |
| 2437 | for (i = 0; i < inst->bufq[fmt->type].num_planes; i++) { |
| 2438 | inst->bufq[fmt->type].plane_sizes[i] = |
| 2439 | f->fmt.pix_mp.plane_fmt[i].sizeimage; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2440 | } |
| 2441 | } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { |
| 2442 | struct hal_frame_size frame_sz; |
| 2443 | |
| 2444 | inst->prop.width[OUTPUT_PORT] = f->fmt.pix_mp.width; |
| 2445 | inst->prop.height[OUTPUT_PORT] = f->fmt.pix_mp.height; |
| 2446 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2447 | frame_sz.buffer_type = HAL_BUFFER_INPUT; |
| 2448 | frame_sz.width = inst->prop.width[OUTPUT_PORT]; |
| 2449 | frame_sz.height = inst->prop.height[OUTPUT_PORT]; |
Praneeth Paladugu | 1f9d1d9 | 2017-04-11 10:36:16 -0700 | [diff] [blame] | 2450 | dprintk(VIDC_DBG, "OUTPUT port width = %d, height = %d\n", |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2451 | frame_sz.width, frame_sz.height); |
| 2452 | rc = call_hfi_op(hdev, session_set_property, (void *) |
| 2453 | inst->session, HAL_PARAM_FRAME_SIZE, &frame_sz); |
| 2454 | if (rc) { |
| 2455 | dprintk(VIDC_ERR, |
| 2456 | "Failed to set framesize for Output port\n"); |
| 2457 | goto exit; |
| 2458 | } |
| 2459 | |
| 2460 | fmt = msm_comm_get_pixel_fmt_fourcc(venc_formats, |
| 2461 | ARRAY_SIZE(venc_formats), f->fmt.pix_mp.pixelformat, |
| 2462 | OUTPUT_PORT); |
| 2463 | if (!fmt || fmt->type != OUTPUT_PORT) { |
| 2464 | dprintk(VIDC_ERR, |
| 2465 | "Format: %d not supported on OUTPUT port\n", |
| 2466 | f->fmt.pix_mp.pixelformat); |
| 2467 | rc = -EINVAL; |
| 2468 | goto exit; |
| 2469 | } |
Praneeth Paladugu | 7722b4e | 2017-07-07 11:01:56 -0700 | [diff] [blame] | 2470 | inst->clk_data.opb_fourcc = f->fmt.pix_mp.pixelformat; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2471 | memcpy(&inst->fmts[fmt->type], fmt, |
| 2472 | sizeof(struct msm_vidc_format)); |
| 2473 | |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 2474 | f->fmt.pix_mp.plane_fmt[0].sizeimage = |
| 2475 | inst->fmts[fmt->type].get_frame_size(0, |
| 2476 | f->fmt.pix_mp.height, f->fmt.pix_mp.width); |
| 2477 | |
| 2478 | rc = msm_comm_try_get_bufreqs(inst); |
| 2479 | if (rc) { |
| 2480 | dprintk(VIDC_ERR, |
| 2481 | "Failed to get buffer requirements: %d\n", rc); |
| 2482 | return rc; |
| 2483 | } |
| 2484 | |
| 2485 | /* |
| 2486 | * Get OUTPUT plane Extradata size from HW. This may change |
| 2487 | * with no of Extradata's enabled. HW should decide howmuch |
| 2488 | * it needs. |
| 2489 | */ |
| 2490 | |
| 2491 | extra_idx = EXTRADATA_IDX(inst->bufq[fmt->type].num_planes); |
| 2492 | if (extra_idx && extra_idx < VIDEO_MAX_PLANES) { |
| 2493 | buff_req_buffer = get_buff_req_buffer(inst, |
| 2494 | HAL_BUFFER_EXTRADATA_INPUT); |
| 2495 | f->fmt.pix_mp.plane_fmt[extra_idx].sizeimage = |
| 2496 | buff_req_buffer ? |
| 2497 | buff_req_buffer->buffer_size : 0; |
| 2498 | } |
| 2499 | |
| 2500 | f->fmt.pix_mp.num_planes = inst->bufq[fmt->type].num_planes; |
| 2501 | |
| 2502 | for (i = 0; i < inst->bufq[fmt->type].num_planes; i++) { |
| 2503 | inst->bufq[fmt->type].plane_sizes[i] = |
| 2504 | f->fmt.pix_mp.plane_fmt[i].sizeimage; |
| 2505 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2506 | |
| 2507 | msm_comm_set_color_format(inst, HAL_BUFFER_INPUT, fmt->fourcc); |
| 2508 | } else { |
| 2509 | dprintk(VIDC_ERR, "%s - Unsupported buf type: %d\n", |
| 2510 | __func__, f->type); |
| 2511 | rc = -EINVAL; |
| 2512 | goto exit; |
| 2513 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2514 | exit: |
| 2515 | return rc; |
| 2516 | } |
| 2517 | |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 2518 | int msm_venc_ctrl_init(struct msm_vidc_inst *inst, |
| 2519 | const struct v4l2_ctrl_ops *ctrl_ops) |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2520 | { |
| 2521 | return msm_comm_ctrl_init(inst, msm_venc_ctrls, |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 2522 | ARRAY_SIZE(msm_venc_ctrls), ctrl_ops); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 2523 | } |