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 | |
| 14 | #include <linux/slab.h> |
| 15 | #include <soc/qcom/scm.h> |
| 16 | #include "msm_vidc_internal.h" |
| 17 | #include "msm_vidc_common.h" |
| 18 | #include "vidc_hfi_api.h" |
| 19 | #include "msm_vidc_debug.h" |
| 20 | #include "msm_vidc_clocks.h" |
| 21 | |
| 22 | #define MSM_VDEC_DVC_NAME "msm_vdec_8974" |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 23 | #define MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS MIN_NUM_OUTPUT_BUFFERS |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 24 | #define MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS MIN_NUM_CAPTURE_BUFFERS |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 25 | #define MIN_NUM_DEC_OUTPUT_BUFFERS 4 |
| 26 | #define MIN_NUM_DEC_CAPTURE_BUFFERS 4 |
Umesh Pandey | 42313a7 | 2017-07-05 18:20:06 -0700 | [diff] [blame] | 27 | // Y=16(0-9bits), Cb(10-19bits)=Cr(20-29bits)=128, black by default |
| 28 | #define DEFAULT_VIDEO_CONCEAL_COLOR_BLACK 0x8020010 |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 29 | #define MB_SIZE_IN_PIXEL (16 * 16) |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 30 | #define OPERATING_FRAME_RATE_STEP (1 << 16) |
| 31 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 32 | static const char *const mpeg_video_stream_format[] = { |
| 33 | "NAL Format Start Codes", |
| 34 | "NAL Format One NAL Per Buffer", |
| 35 | "NAL Format One Byte Length", |
| 36 | "NAL Format Two Byte Length", |
| 37 | "NAL Format Four Byte Length", |
| 38 | NULL |
| 39 | }; |
| 40 | static const char *const mpeg_video_output_order[] = { |
| 41 | "Display Order", |
| 42 | "Decode Order", |
| 43 | NULL |
| 44 | }; |
| 45 | static const char *const mpeg_vidc_video_alloc_mode_type[] = { |
| 46 | "Buffer Allocation Static", |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 47 | "Buffer Allocation Dynamic Buffer" |
| 48 | }; |
| 49 | |
| 50 | static const char *const perf_level[] = { |
| 51 | "Nominal", |
| 52 | "Performance", |
| 53 | "Turbo" |
| 54 | }; |
| 55 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 56 | static const char *const vp8_profile_level[] = { |
| 57 | "Unused", |
| 58 | "0.0", |
| 59 | "1.0", |
| 60 | "2.0", |
| 61 | "3.0", |
| 62 | }; |
| 63 | |
Vaibhav Deshu Venkatesh | b69518e | 2017-08-21 12:22:49 -0700 | [diff] [blame] | 64 | static const char *const vp9_profile[] = { |
| 65 | "Unused", |
| 66 | "0", |
| 67 | "2_10", |
| 68 | }; |
| 69 | |
| 70 | static const char *const vp9_level[] = { |
| 71 | "Unused", |
| 72 | "1.0", |
| 73 | "1.1", |
| 74 | "2.0", |
| 75 | "2.1", |
| 76 | "3.0", |
| 77 | "3.1", |
| 78 | "4.0", |
| 79 | "4.1", |
| 80 | "5.0", |
| 81 | "5.1", |
| 82 | }; |
| 83 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 84 | static const char *const mpeg2_profile[] = { |
| 85 | "Simple", |
| 86 | "Main", |
| 87 | "422", |
| 88 | "Snr Scalable", |
| 89 | "Spatial Scalable", |
| 90 | "High", |
| 91 | }; |
| 92 | |
| 93 | static const char *const mpeg2_level[] = { |
| 94 | "0", |
| 95 | "1", |
| 96 | "2", |
| 97 | "3", |
| 98 | }; |
| 99 | static const char *const mpeg_vidc_video_entropy_mode[] = { |
| 100 | "CAVLC Entropy Mode", |
| 101 | "CABAC Entropy Mode", |
| 102 | }; |
| 103 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 104 | static const char *const mpeg_vidc_video_dpb_color_format[] = { |
| 105 | "DPB Color Format None", |
| 106 | "DPB Color Format UBWC", |
| 107 | "DPB Color Format UBWC TP10", |
| 108 | }; |
| 109 | |
| 110 | static struct msm_vidc_ctrl msm_vdec_ctrls[] = { |
| 111 | { |
| 112 | .id = V4L2_CID_MPEG_VIDC_VIDEO_STREAM_FORMAT, |
| 113 | .name = "NAL Format", |
| 114 | .type = V4L2_CTRL_TYPE_MENU, |
| 115 | .minimum = V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_STARTCODES, |
| 116 | .maximum = V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_FOUR_BYTE_LENGTH, |
| 117 | .default_value = V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_STARTCODES, |
| 118 | .menu_skip_mask = ~( |
| 119 | (1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_STARTCODES) | |
| 120 | (1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_ONE_NAL_PER_BUFFER) | |
| 121 | (1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_ONE_BYTE_LENGTH) | |
| 122 | (1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_TWO_BYTE_LENGTH) | |
| 123 | (1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_FOUR_BYTE_LENGTH) |
| 124 | ), |
| 125 | .qmenu = mpeg_video_stream_format, |
| 126 | }, |
| 127 | { |
| 128 | .id = V4L2_CID_MPEG_VIDC_VIDEO_OUTPUT_ORDER, |
| 129 | .name = "Output Order", |
| 130 | .type = V4L2_CTRL_TYPE_MENU, |
| 131 | .minimum = V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DISPLAY, |
| 132 | .maximum = V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DECODE, |
| 133 | .default_value = V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DISPLAY, |
| 134 | .menu_skip_mask = ~( |
| 135 | (1 << V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DISPLAY) | |
| 136 | (1 << V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DECODE) |
| 137 | ), |
| 138 | .qmenu = mpeg_video_output_order, |
| 139 | }, |
| 140 | { |
| 141 | .id = V4L2_CID_MPEG_VIDC_VIDEO_PICTYPE_DEC_MODE, |
| 142 | .name = "Picture Type Decoding", |
| 143 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 144 | .minimum = 0, |
| 145 | .maximum = 1, |
| 146 | .default_value = 0, |
| 147 | .step = 1, |
| 148 | .menu_skip_mask = 0, |
| 149 | .qmenu = NULL, |
| 150 | }, |
| 151 | { |
| 152 | .id = V4L2_CID_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE, |
| 153 | .name = "Sync Frame Decode", |
| 154 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 155 | .minimum = V4L2_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE_DISABLE, |
| 156 | .maximum = V4L2_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE_ENABLE, |
| 157 | .default_value = V4L2_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE_DISABLE, |
| 158 | .step = 1, |
| 159 | }, |
| 160 | { |
| 161 | .id = V4L2_CID_MPEG_VIDC_VIDEO_SECURE, |
| 162 | .name = "Secure mode", |
| 163 | .type = V4L2_CTRL_TYPE_BUTTON, |
| 164 | .minimum = 0, |
| 165 | .maximum = 0, |
| 166 | .default_value = 0, |
| 167 | .step = 0, |
| 168 | .menu_skip_mask = 0, |
| 169 | .qmenu = NULL, |
| 170 | }, |
| 171 | { |
| 172 | .id = V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA, |
| 173 | .name = "Extradata Type", |
| 174 | .type = V4L2_CTRL_TYPE_MENU, |
| 175 | .minimum = V4L2_MPEG_VIDC_EXTRADATA_NONE, |
Praneeth Paladugu | a51b2c4 | 2017-06-23 12:48:06 -0700 | [diff] [blame] | 176 | .maximum = V4L2_MPEG_VIDC_EXTRADATA_UBWC_CR_STATS_INFO, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 177 | .default_value = V4L2_MPEG_VIDC_EXTRADATA_NONE, |
| 178 | .menu_skip_mask = ~( |
| 179 | (1 << V4L2_MPEG_VIDC_EXTRADATA_NONE) | |
| 180 | (1 << V4L2_MPEG_VIDC_EXTRADATA_MB_QUANTIZATION) | |
| 181 | (1 << V4L2_MPEG_VIDC_EXTRADATA_INTERLACE_VIDEO) | |
| 182 | (1 << V4L2_MPEG_VIDC_EXTRADATA_TIMESTAMP) | |
| 183 | (1 << V4L2_MPEG_VIDC_EXTRADATA_S3D_FRAME_PACKING) | |
| 184 | (1 << V4L2_MPEG_VIDC_EXTRADATA_FRAME_RATE) | |
| 185 | (1 << V4L2_MPEG_VIDC_EXTRADATA_PANSCAN_WINDOW) | |
| 186 | (1 << V4L2_MPEG_VIDC_EXTRADATA_RECOVERY_POINT_SEI) | |
| 187 | (1 << V4L2_MPEG_VIDC_EXTRADATA_MULTISLICE_INFO) | |
| 188 | (1 << V4L2_MPEG_VIDC_EXTRADATA_NUM_CONCEALED_MB) | |
| 189 | (1 << V4L2_MPEG_VIDC_EXTRADATA_METADATA_FILLER) | |
| 190 | (1 << V4L2_MPEG_VIDC_EXTRADATA_INPUT_CROP) | |
| 191 | (1 << V4L2_MPEG_VIDC_EXTRADATA_DIGITAL_ZOOM) | |
| 192 | (1 << V4L2_MPEG_VIDC_EXTRADATA_ASPECT_RATIO) | |
| 193 | (1 << V4L2_MPEG_VIDC_EXTRADATA_MPEG2_SEQDISP) | |
| 194 | (1 << V4L2_MPEG_VIDC_EXTRADATA_STREAM_USERDATA) | |
| 195 | (1 << V4L2_MPEG_VIDC_EXTRADATA_FRAME_QP) | |
| 196 | (1 << V4L2_MPEG_VIDC_EXTRADATA_FRAME_BITS_INFO) | |
| 197 | (1 << V4L2_MPEG_VIDC_EXTRADATA_VQZIP_SEI) | |
| 198 | (1 << V4L2_MPEG_VIDC_EXTRADATA_OUTPUT_CROP) | |
| 199 | (1 << V4L2_MPEG_VIDC_EXTRADATA_DISPLAY_COLOUR_SEI) | |
| 200 | (1 << |
| 201 | V4L2_MPEG_VIDC_EXTRADATA_CONTENT_LIGHT_LEVEL_SEI) | |
| 202 | (1 << V4L2_MPEG_VIDC_EXTRADATA_VUI_DISPLAY) | |
Praneeth Paladugu | a51b2c4 | 2017-06-23 12:48:06 -0700 | [diff] [blame] | 203 | (1 << V4L2_MPEG_VIDC_EXTRADATA_VPX_COLORSPACE) | |
| 204 | (1 << V4L2_MPEG_VIDC_EXTRADATA_UBWC_CR_STATS_INFO) |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 205 | ), |
| 206 | .qmenu = mpeg_video_vidc_extradata, |
| 207 | }, |
| 208 | { |
| 209 | .id = V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_MODE, |
| 210 | .name = "Video decoder multi stream", |
| 211 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 212 | .minimum = |
| 213 | V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_PRIMARY, |
| 214 | .maximum = |
| 215 | V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_SECONDARY, |
| 216 | .default_value = |
| 217 | V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_PRIMARY, |
| 218 | .menu_skip_mask = 0, |
| 219 | .step = 1, |
| 220 | .qmenu = NULL, |
| 221 | }, |
| 222 | { |
| 223 | .id = V4L2_CID_MPEG_VIDEO_H264_PROFILE, |
| 224 | .name = "H264 Profile", |
| 225 | .type = V4L2_CTRL_TYPE_MENU, |
| 226 | .maximum = V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH, |
| 227 | .default_value = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, |
| 228 | .menu_skip_mask = 0, |
| 229 | .flags = V4L2_CTRL_FLAG_VOLATILE, |
| 230 | .qmenu = NULL, |
| 231 | }, |
| 232 | { |
| 233 | .id = V4L2_CID_MPEG_VIDEO_H264_LEVEL, |
| 234 | .name = "H264 Level", |
| 235 | .type = V4L2_CTRL_TYPE_MENU, |
| 236 | .maximum = V4L2_MPEG_VIDEO_H264_LEVEL_5_2, |
| 237 | .default_value = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, |
| 238 | .menu_skip_mask = 0, |
| 239 | .flags = V4L2_CTRL_FLAG_VOLATILE, |
| 240 | .qmenu = NULL, |
| 241 | }, |
| 242 | { |
| 243 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VP8_PROFILE_LEVEL, |
| 244 | .name = "VP8 Profile Level", |
| 245 | .type = V4L2_CTRL_TYPE_MENU, |
| 246 | .minimum = V4L2_MPEG_VIDC_VIDEO_VP8_UNUSED, |
Chinmay Sawarkar | 7f1cc15 | 2017-05-05 18:16:36 -0700 | [diff] [blame] | 247 | .maximum = V4L2_MPEG_VIDC_VIDEO_VP8_VERSION_3, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 248 | .default_value = V4L2_MPEG_VIDC_VIDEO_VP8_VERSION_0, |
Chinmay Sawarkar | 7f1cc15 | 2017-05-05 18:16:36 -0700 | [diff] [blame] | 249 | .menu_skip_mask = 0, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 250 | .qmenu = vp8_profile_level, |
| 251 | .flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY, |
| 252 | }, |
| 253 | { |
Vaibhav Deshu Venkatesh | b69518e | 2017-08-21 12:22:49 -0700 | [diff] [blame] | 254 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VP9_PROFILE, |
| 255 | .name = "VP9 Profile", |
| 256 | .type = V4L2_CTRL_TYPE_MENU, |
| 257 | .minimum = V4L2_MPEG_VIDC_VIDEO_VP9_PROFILE_UNUSED, |
| 258 | .maximum = V4L2_MPEG_VIDC_VIDEO_VP9_PROFILE_P2_10, |
| 259 | .default_value = V4L2_MPEG_VIDC_VIDEO_VP9_PROFILE_P0, |
| 260 | .menu_skip_mask = 0, |
| 261 | .qmenu = vp9_profile, |
| 262 | .flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY, |
| 263 | }, |
| 264 | { |
| 265 | .id = V4L2_CID_MPEG_VIDC_VIDEO_VP9_LEVEL, |
| 266 | .name = "VP9 Level", |
| 267 | .type = V4L2_CTRL_TYPE_MENU, |
| 268 | .minimum = V4L2_MPEG_VIDC_VIDEO_VP9_LEVEL_UNUSED, |
| 269 | .maximum = V4L2_MPEG_VIDC_VIDEO_VP9_LEVEL_51, |
| 270 | .default_value = V4L2_MPEG_VIDC_VIDEO_VP9_LEVEL_51, |
| 271 | .menu_skip_mask = 0, |
| 272 | .qmenu = vp9_level, |
| 273 | .flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY, |
| 274 | }, |
| 275 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 276 | .id = V4L2_CID_MPEG_VIDC_VIDEO_MPEG2_PROFILE, |
| 277 | .name = "MPEG2 Profile", |
| 278 | .type = V4L2_CTRL_TYPE_MENU, |
| 279 | .minimum = V4L2_MPEG_VIDC_VIDEO_MPEG2_PROFILE_SIMPLE, |
| 280 | .maximum = V4L2_MPEG_VIDC_VIDEO_MPEG2_PROFILE_HIGH, |
| 281 | .default_value = V4L2_MPEG_VIDC_VIDEO_MPEG2_PROFILE_SIMPLE, |
| 282 | .menu_skip_mask = ~( |
| 283 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_PROFILE_SIMPLE) | |
| 284 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_PROFILE_MAIN) | |
| 285 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_PROFILE_422) | |
| 286 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_PROFILE_SNR_SCALABLE) | |
| 287 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_PROFILE_SPATIAL_SCALABLE) | |
| 288 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_PROFILE_HIGH) |
| 289 | ), |
| 290 | .qmenu = mpeg2_profile, |
| 291 | .flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY, |
| 292 | }, |
| 293 | { |
| 294 | .id = V4L2_CID_MPEG_VIDC_VIDEO_MPEG2_LEVEL, |
| 295 | .name = "MPEG2 Level", |
| 296 | .type = V4L2_CTRL_TYPE_MENU, |
| 297 | .minimum = V4L2_MPEG_VIDC_VIDEO_MPEG2_LEVEL_0, |
| 298 | .maximum = V4L2_MPEG_VIDC_VIDEO_MPEG2_LEVEL_3, |
| 299 | .default_value = V4L2_MPEG_VIDC_VIDEO_MPEG2_LEVEL_0, |
| 300 | .menu_skip_mask = ~( |
| 301 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_LEVEL_0) | |
| 302 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_LEVEL_1) | |
| 303 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_LEVEL_2) | |
| 304 | (1 << V4L2_MPEG_VIDC_VIDEO_MPEG2_LEVEL_3) |
| 305 | ), |
| 306 | .qmenu = mpeg2_level, |
| 307 | .flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY, |
| 308 | }, |
| 309 | { |
Umesh Pandey | 42313a7 | 2017-07-05 18:20:06 -0700 | [diff] [blame] | 310 | .id = V4L2_CID_MPEG_VIDC_VIDEO_CONCEAL_COLOR_8BIT, |
| 311 | .name = "Picture concealed color 8bit", |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 312 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 313 | .minimum = 0x0, |
Umesh Pandey | 42313a7 | 2017-07-05 18:20:06 -0700 | [diff] [blame] | 314 | .maximum = 0xff3fcff, |
| 315 | .default_value = DEFAULT_VIDEO_CONCEAL_COLOR_BLACK, |
| 316 | .step = 1, |
| 317 | }, |
| 318 | { |
| 319 | .id = V4L2_CID_MPEG_VIDC_VIDEO_CONCEAL_COLOR_10BIT, |
| 320 | .name = "Picture concealed color 10bit", |
| 321 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 322 | .minimum = 0x0, |
| 323 | .maximum = 0x3fffffff, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 324 | .default_value = DEFAULT_VIDEO_CONCEAL_COLOR_BLACK, |
| 325 | .step = 1, |
| 326 | }, |
| 327 | { |
| 328 | .id = V4L2_CID_MPEG_VIDC_VIDEO_BUFFER_SIZE_LIMIT, |
| 329 | .name = "Buffer size limit", |
| 330 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 331 | .minimum = 0, |
| 332 | .maximum = INT_MAX, |
| 333 | .default_value = 0, |
| 334 | .step = 1, |
| 335 | .menu_skip_mask = 0, |
| 336 | .qmenu = NULL, |
| 337 | }, |
| 338 | { |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 339 | .id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, |
| 340 | .name = "CAPTURE Count", |
| 341 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 342 | .minimum = MIN_NUM_CAPTURE_BUFFERS, |
| 343 | .maximum = MAX_NUM_CAPTURE_BUFFERS, |
| 344 | .default_value = MIN_NUM_CAPTURE_BUFFERS, |
| 345 | .step = 1, |
| 346 | .menu_skip_mask = 0, |
| 347 | .qmenu = NULL, |
| 348 | .flags = V4L2_CTRL_FLAG_VOLATILE, |
| 349 | }, |
| 350 | { |
| 351 | .id = V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, |
| 352 | .name = "OUTPUT Count", |
| 353 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 354 | .minimum = MIN_NUM_OUTPUT_BUFFERS, |
| 355 | .maximum = MAX_NUM_OUTPUT_BUFFERS, |
| 356 | .default_value = MIN_NUM_OUTPUT_BUFFERS, |
| 357 | .step = 1, |
| 358 | .menu_skip_mask = 0, |
| 359 | .qmenu = NULL, |
| 360 | .flags = V4L2_CTRL_FLAG_VOLATILE, |
| 361 | }, |
| 362 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 363 | .id = V4L2_CID_MPEG_VIDC_VIDEO_DPB_COLOR_FORMAT, |
| 364 | .name = "Video decoder dpb color format", |
| 365 | .type = V4L2_CTRL_TYPE_MENU, |
| 366 | .minimum = V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_NONE, |
| 367 | .maximum = V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_TP10_UBWC, |
| 368 | .default_value = V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_NONE, |
| 369 | .menu_skip_mask = ~( |
| 370 | (1 << V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_NONE) | |
| 371 | (1 << V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_UBWC) | |
| 372 | (1 << V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_TP10_UBWC) |
| 373 | ), |
| 374 | .qmenu = mpeg_vidc_video_dpb_color_format, |
| 375 | }, |
| 376 | { |
| 377 | .id = V4L2_CID_VIDC_QBUF_MODE, |
| 378 | .name = "Allows batching of buffers for power savings", |
| 379 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 380 | .minimum = V4L2_VIDC_QBUF_STANDARD, |
| 381 | .maximum = V4L2_VIDC_QBUF_BATCHED, |
| 382 | .default_value = V4L2_VIDC_QBUF_STANDARD, |
| 383 | .step = 1, |
| 384 | }, |
| 385 | { |
| 386 | .id = V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE, |
| 387 | .name = "Entropy Mode", |
| 388 | .type = V4L2_CTRL_TYPE_MENU, |
| 389 | .minimum = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, |
| 390 | .maximum = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC, |
| 391 | .default_value = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, |
| 392 | .step = 0, |
| 393 | .menu_skip_mask = ~( |
| 394 | (1 << V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC) | |
| 395 | (1 << V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC) |
| 396 | ), |
| 397 | .qmenu = mpeg_vidc_video_entropy_mode, |
| 398 | .flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY, |
| 399 | }, |
| 400 | { |
| 401 | .id = V4L2_CID_MPEG_VIDC_VIDEO_PRIORITY, |
| 402 | .name = "Session Priority", |
| 403 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 404 | .minimum = V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_ENABLE, |
| 405 | .maximum = V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_DISABLE, |
| 406 | .default_value = V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_DISABLE, |
| 407 | .step = 1, |
| 408 | }, |
| 409 | { |
| 410 | .id = V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE, |
| 411 | .name = "Set Decoder Operating rate", |
| 412 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 413 | .minimum = 0, |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 414 | .maximum = INT_MAX, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 415 | .default_value = 0, |
| 416 | .step = OPERATING_FRAME_RATE_STEP, |
| 417 | }, |
Saurabh Kothawade | c1cffa885 | 2017-08-18 12:20:38 -0700 | [diff] [blame] | 418 | { |
| 419 | .id = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_MODE, |
| 420 | .name = "Low Latency Mode", |
| 421 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 422 | .minimum = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_DISABLE, |
| 423 | .maximum = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_ENABLE, |
| 424 | .default_value = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_DISABLE, |
| 425 | .step = 1, |
| 426 | }, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 427 | }; |
| 428 | |
| 429 | #define NUM_CTRLS ARRAY_SIZE(msm_vdec_ctrls) |
| 430 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 431 | static u32 get_frame_size_compressed_full_yuv(int plane, |
| 432 | u32 max_mbs_per_frame, u32 size_per_mb) |
| 433 | { |
| 434 | return (max_mbs_per_frame * size_per_mb * 3 / 2); |
| 435 | } |
| 436 | |
| 437 | static u32 get_frame_size_compressed(int plane, |
| 438 | u32 max_mbs_per_frame, u32 size_per_mb) |
| 439 | { |
| 440 | return (max_mbs_per_frame * size_per_mb * 3/2)/2; |
| 441 | } |
| 442 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 443 | static u32 get_frame_size(struct msm_vidc_inst *inst, |
| 444 | const struct msm_vidc_format *fmt, |
| 445 | int fmt_type, int plane) |
| 446 | { |
| 447 | u32 frame_size = 0; |
| 448 | |
| 449 | if (fmt_type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { |
| 450 | frame_size = fmt->get_frame_size(plane, |
| 451 | inst->capability.mbs_per_frame.max, |
| 452 | MB_SIZE_IN_PIXEL); |
| 453 | if (inst->buffer_size_limit && |
| 454 | (inst->buffer_size_limit < frame_size)) { |
| 455 | frame_size = inst->buffer_size_limit; |
| 456 | dprintk(VIDC_DBG, "input buffer size limited to %d\n", |
| 457 | frame_size); |
| 458 | } else { |
| 459 | dprintk(VIDC_DBG, "set input buffer size to %d\n", |
| 460 | frame_size); |
| 461 | } |
| 462 | } else if (fmt_type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { |
| 463 | frame_size = fmt->get_frame_size(plane, |
| 464 | inst->capability.height.max, |
| 465 | inst->capability.width.max); |
| 466 | dprintk(VIDC_DBG, "set output buffer size to %d\n", |
| 467 | frame_size); |
| 468 | } else { |
| 469 | dprintk(VIDC_WARN, "Wrong format type\n"); |
| 470 | } |
| 471 | return frame_size; |
| 472 | } |
| 473 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 474 | struct msm_vidc_format vdec_formats[] = { |
| 475 | { |
| 476 | .name = "YCbCr Semiplanar 4:2:0", |
| 477 | .description = "Y/CbCr 4:2:0", |
| 478 | .fourcc = V4L2_PIX_FMT_NV12, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 479 | .get_frame_size = get_frame_size_nv12, |
| 480 | .type = CAPTURE_PORT, |
| 481 | }, |
| 482 | { |
Zhongbo Shi | 6bd5f5f | 2017-08-16 17:20:08 +0800 | [diff] [blame] | 483 | .name = "YCbCr Semiplanar 4:2:0 10bit", |
| 484 | .description = "Y/CbCr 4:2:0 10bit", |
| 485 | .fourcc = V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010, |
| 486 | .get_frame_size = get_frame_size_p010, |
| 487 | .type = CAPTURE_PORT, |
| 488 | }, |
| 489 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 490 | .name = "UBWC YCbCr Semiplanar 4:2:0", |
| 491 | .description = "UBWC Y/CbCr 4:2:0", |
| 492 | .fourcc = V4L2_PIX_FMT_NV12_UBWC, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 493 | .get_frame_size = get_frame_size_nv12_ubwc, |
| 494 | .type = CAPTURE_PORT, |
| 495 | }, |
| 496 | { |
| 497 | .name = "UBWC YCbCr Semiplanar 4:2:0 10bit", |
| 498 | .description = "UBWC Y/CbCr 4:2:0 10bit", |
| 499 | .fourcc = V4L2_PIX_FMT_NV12_TP10_UBWC, |
Umesh Pandey | f2995f8 | 2017-05-01 16:44:45 -0700 | [diff] [blame] | 500 | .get_frame_size = get_frame_size_tp10_ubwc, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 501 | .type = CAPTURE_PORT, |
| 502 | }, |
| 503 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 504 | .name = "Mpeg2", |
| 505 | .description = "Mpeg2 compressed format", |
| 506 | .fourcc = V4L2_PIX_FMT_MPEG2, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 507 | .get_frame_size = get_frame_size_compressed, |
| 508 | .type = OUTPUT_PORT, |
Vaibhav Deshu Venkatesh | 8c9b6db | 2017-02-08 11:22:36 -0800 | [diff] [blame] | 509 | .defer_outputs = false, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 510 | }, |
| 511 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 512 | .name = "H264", |
| 513 | .description = "H264 compressed format", |
| 514 | .fourcc = V4L2_PIX_FMT_H264, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 515 | .get_frame_size = get_frame_size_compressed, |
| 516 | .type = OUTPUT_PORT, |
Vaibhav Deshu Venkatesh | 8c9b6db | 2017-02-08 11:22:36 -0800 | [diff] [blame] | 517 | .defer_outputs = false, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 518 | }, |
| 519 | { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 520 | .name = "HEVC", |
| 521 | .description = "HEVC compressed format", |
| 522 | .fourcc = V4L2_PIX_FMT_HEVC, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 523 | .get_frame_size = get_frame_size_compressed, |
| 524 | .type = OUTPUT_PORT, |
Vaibhav Deshu Venkatesh | 8c9b6db | 2017-02-08 11:22:36 -0800 | [diff] [blame] | 525 | .defer_outputs = false, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 526 | }, |
| 527 | { |
| 528 | .name = "VP8", |
| 529 | .description = "VP8 compressed format", |
| 530 | .fourcc = V4L2_PIX_FMT_VP8, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 531 | .get_frame_size = get_frame_size_compressed, |
| 532 | .type = OUTPUT_PORT, |
Vaibhav Deshu Venkatesh | 8c9b6db | 2017-02-08 11:22:36 -0800 | [diff] [blame] | 533 | .defer_outputs = false, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 534 | }, |
| 535 | { |
| 536 | .name = "VP9", |
| 537 | .description = "VP9 compressed format", |
| 538 | .fourcc = V4L2_PIX_FMT_VP9, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 539 | .get_frame_size = get_frame_size_compressed_full_yuv, |
| 540 | .type = OUTPUT_PORT, |
Vaibhav Deshu Venkatesh | 8c9b6db | 2017-02-08 11:22:36 -0800 | [diff] [blame] | 541 | .defer_outputs = true, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 542 | }, |
| 543 | }; |
| 544 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 545 | int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) |
| 546 | { |
| 547 | struct msm_vidc_format *fmt = NULL; |
| 548 | struct hal_frame_size frame_sz; |
| 549 | unsigned int extra_idx = 0; |
| 550 | int rc = 0; |
| 551 | int ret = 0; |
| 552 | int i; |
| 553 | int max_input_size = 0; |
| 554 | |
| 555 | if (!inst || !f) { |
| 556 | dprintk(VIDC_ERR, "%s invalid parameters\n", __func__); |
| 557 | return -EINVAL; |
| 558 | } |
| 559 | |
| 560 | if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { |
| 561 | fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats, |
| 562 | ARRAY_SIZE(vdec_formats), f->fmt.pix_mp.pixelformat, |
| 563 | CAPTURE_PORT); |
| 564 | if (!fmt || fmt->type != CAPTURE_PORT) { |
| 565 | dprintk(VIDC_ERR, |
| 566 | "Format: %d not supported on CAPTURE port\n", |
| 567 | f->fmt.pix_mp.pixelformat); |
| 568 | rc = -EINVAL; |
| 569 | goto err_invalid_fmt; |
| 570 | } |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 571 | |
| 572 | if (inst->fmts[fmt->type].fourcc == f->fmt.pix_mp.pixelformat && |
| 573 | inst->prop.width[CAPTURE_PORT] == f->fmt.pix_mp.width && |
| 574 | inst->prop.height[CAPTURE_PORT] == |
| 575 | f->fmt.pix_mp.height) { |
Praneeth Paladugu | 1f9d1d9 | 2017-04-11 10:36:16 -0700 | [diff] [blame] | 576 | dprintk(VIDC_DBG, "No change in CAPTURE port params\n"); |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 577 | return 0; |
| 578 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 579 | memcpy(&inst->fmts[fmt->type], fmt, |
| 580 | sizeof(struct msm_vidc_format)); |
| 581 | |
| 582 | inst->prop.width[CAPTURE_PORT] = f->fmt.pix_mp.width; |
| 583 | inst->prop.height[CAPTURE_PORT] = f->fmt.pix_mp.height; |
Maheshwar Ajja | 3cff01f | 2017-09-03 14:22:54 -0700 | [diff] [blame] | 584 | rc = msm_vidc_check_session_supported(inst); |
| 585 | if (rc) { |
| 586 | dprintk(VIDC_ERR, |
| 587 | "%s: session not supported\n", __func__); |
| 588 | goto err_invalid_fmt; |
| 589 | } |
| 590 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 591 | msm_comm_set_color_format(inst, |
| 592 | msm_comm_get_hal_output_buffer(inst), |
| 593 | f->fmt.pix_mp.pixelformat); |
| 594 | |
Praneeth Paladugu | 319e792 | 2017-03-16 11:09:06 -0700 | [diff] [blame] | 595 | inst->clk_data.opb_fourcc = f->fmt.pix_mp.pixelformat; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 596 | if (msm_comm_get_stream_output_mode(inst) == |
| 597 | HAL_VIDEO_DECODER_SECONDARY) { |
| 598 | frame_sz.buffer_type = HAL_BUFFER_OUTPUT2; |
| 599 | frame_sz.width = inst->prop.width[CAPTURE_PORT]; |
| 600 | frame_sz.height = inst->prop.height[CAPTURE_PORT]; |
| 601 | dprintk(VIDC_DBG, |
| 602 | "buffer type = %d width = %d, height = %d\n", |
| 603 | frame_sz.buffer_type, frame_sz.width, |
| 604 | frame_sz.height); |
| 605 | ret = msm_comm_try_set_prop(inst, |
| 606 | HAL_PARAM_FRAME_SIZE, &frame_sz); |
| 607 | } |
| 608 | |
| 609 | f->fmt.pix_mp.plane_fmt[0].sizeimage = |
| 610 | inst->fmts[fmt->type].get_frame_size(0, |
| 611 | f->fmt.pix_mp.height, f->fmt.pix_mp.width); |
| 612 | |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 613 | extra_idx = EXTRADATA_IDX(inst->bufq[fmt->type].num_planes); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 614 | if (extra_idx && extra_idx < VIDEO_MAX_PLANES) { |
| 615 | f->fmt.pix_mp.plane_fmt[extra_idx].sizeimage = |
| 616 | VENUS_EXTRADATA_SIZE( |
| 617 | inst->prop.height[CAPTURE_PORT], |
| 618 | inst->prop.width[CAPTURE_PORT]); |
| 619 | } |
| 620 | |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 621 | f->fmt.pix_mp.num_planes = inst->bufq[fmt->type].num_planes; |
| 622 | for (i = 0; i < inst->bufq[fmt->type].num_planes; i++) { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 623 | inst->bufq[CAPTURE_PORT].plane_sizes[i] = |
| 624 | f->fmt.pix_mp.plane_fmt[i].sizeimage; |
| 625 | } |
Praneeth Paladugu | bdf4a2f | 2017-04-21 13:32:49 -0700 | [diff] [blame] | 626 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 627 | } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 628 | |
| 629 | fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats, |
| 630 | ARRAY_SIZE(vdec_formats), |
| 631 | f->fmt.pix_mp.pixelformat, |
| 632 | OUTPUT_PORT); |
| 633 | if (!fmt || fmt->type != OUTPUT_PORT) { |
| 634 | dprintk(VIDC_ERR, |
| 635 | "Format: %d not supported on OUTPUT port\n", |
| 636 | f->fmt.pix_mp.pixelformat); |
| 637 | rc = -EINVAL; |
| 638 | goto err_invalid_fmt; |
| 639 | } |
| 640 | memcpy(&inst->fmts[fmt->type], fmt, |
| 641 | sizeof(struct msm_vidc_format)); |
| 642 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 643 | rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE); |
| 644 | if (rc) { |
| 645 | dprintk(VIDC_ERR, "Failed to open instance\n"); |
| 646 | goto err_invalid_fmt; |
| 647 | } |
| 648 | |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 649 | if (inst->fmts[fmt->type].fourcc == f->fmt.pix_mp.pixelformat && |
| 650 | inst->prop.width[OUTPUT_PORT] == f->fmt.pix_mp.width && |
| 651 | inst->prop.height[OUTPUT_PORT] == |
| 652 | f->fmt.pix_mp.height) { |
Praneeth Paladugu | 1f9d1d9 | 2017-04-11 10:36:16 -0700 | [diff] [blame] | 653 | dprintk(VIDC_DBG, "No change in OUTPUT port params\n"); |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 654 | return 0; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 655 | } |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 656 | inst->prop.width[OUTPUT_PORT] = f->fmt.pix_mp.width; |
| 657 | inst->prop.height[OUTPUT_PORT] = f->fmt.pix_mp.height; |
Maheshwar Ajja | 3cff01f | 2017-09-03 14:22:54 -0700 | [diff] [blame] | 658 | rc = msm_vidc_check_session_supported(inst); |
| 659 | if (rc) { |
| 660 | dprintk(VIDC_ERR, |
| 661 | "%s: session not supported\n", __func__); |
| 662 | goto err_invalid_fmt; |
| 663 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 664 | |
| 665 | frame_sz.buffer_type = HAL_BUFFER_INPUT; |
| 666 | frame_sz.width = inst->prop.width[OUTPUT_PORT]; |
| 667 | frame_sz.height = inst->prop.height[OUTPUT_PORT]; |
| 668 | dprintk(VIDC_DBG, |
| 669 | "buffer type = %d width = %d, height = %d\n", |
| 670 | frame_sz.buffer_type, frame_sz.width, |
| 671 | frame_sz.height); |
| 672 | msm_comm_try_set_prop(inst, HAL_PARAM_FRAME_SIZE, &frame_sz); |
| 673 | |
| 674 | max_input_size = get_frame_size( |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 675 | inst, &inst->fmts[fmt->type], f->type, 0); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 676 | if (f->fmt.pix_mp.plane_fmt[0].sizeimage > max_input_size || |
| 677 | !f->fmt.pix_mp.plane_fmt[0].sizeimage) { |
| 678 | f->fmt.pix_mp.plane_fmt[0].sizeimage = max_input_size; |
| 679 | } |
| 680 | |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 681 | f->fmt.pix_mp.num_planes = inst->bufq[fmt->type].num_planes; |
| 682 | for (i = 0; i < inst->bufq[fmt->type].num_planes; ++i) { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 683 | inst->bufq[OUTPUT_PORT].plane_sizes[i] = |
| 684 | f->fmt.pix_mp.plane_fmt[i].sizeimage; |
| 685 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 686 | } |
| 687 | err_invalid_fmt: |
| 688 | return rc; |
| 689 | } |
| 690 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 691 | int msm_vdec_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f) |
| 692 | { |
| 693 | const struct msm_vidc_format *fmt = NULL; |
| 694 | int rc = 0; |
| 695 | |
| 696 | if (!inst || !f) { |
| 697 | dprintk(VIDC_ERR, |
| 698 | "Invalid input, inst = %pK, f = %pK\n", inst, f); |
| 699 | return -EINVAL; |
| 700 | } |
| 701 | if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { |
| 702 | fmt = msm_comm_get_pixel_fmt_index(vdec_formats, |
| 703 | ARRAY_SIZE(vdec_formats), f->index, CAPTURE_PORT); |
| 704 | } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { |
| 705 | fmt = msm_comm_get_pixel_fmt_index(vdec_formats, |
| 706 | ARRAY_SIZE(vdec_formats), f->index, OUTPUT_PORT); |
| 707 | f->flags = V4L2_FMT_FLAG_COMPRESSED; |
| 708 | } |
| 709 | |
| 710 | memset(f->reserved, 0, sizeof(f->reserved)); |
| 711 | if (fmt) { |
| 712 | strlcpy(f->description, fmt->description, |
| 713 | sizeof(f->description)); |
| 714 | f->pixelformat = fmt->fourcc; |
| 715 | } else { |
| 716 | dprintk(VIDC_DBG, "No more formats found\n"); |
| 717 | rc = -EINVAL; |
| 718 | } |
| 719 | return rc; |
| 720 | } |
| 721 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 722 | int msm_vdec_inst_init(struct msm_vidc_inst *inst) |
| 723 | { |
| 724 | int rc = 0; |
Praneeth Paladugu | a6b6aa4 | 2017-05-16 13:33:01 -0700 | [diff] [blame] | 725 | struct msm_vidc_format *fmt = NULL; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 726 | |
| 727 | if (!inst) { |
| 728 | dprintk(VIDC_ERR, "Invalid input = %pK\n", inst); |
| 729 | return -EINVAL; |
| 730 | } |
| 731 | inst->prop.height[CAPTURE_PORT] = DEFAULT_HEIGHT; |
| 732 | inst->prop.width[CAPTURE_PORT] = DEFAULT_WIDTH; |
| 733 | inst->prop.height[OUTPUT_PORT] = DEFAULT_HEIGHT; |
| 734 | inst->prop.width[OUTPUT_PORT] = DEFAULT_WIDTH; |
| 735 | inst->capability.height.min = MIN_SUPPORTED_HEIGHT; |
| 736 | inst->capability.height.max = DEFAULT_HEIGHT; |
| 737 | inst->capability.width.min = MIN_SUPPORTED_WIDTH; |
| 738 | inst->capability.width.max = DEFAULT_WIDTH; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 739 | inst->capability.secure_output2_threshold.min = 0; |
| 740 | inst->capability.secure_output2_threshold.max = 0; |
| 741 | inst->buffer_mode_set[OUTPUT_PORT] = HAL_BUFFER_MODE_STATIC; |
Chinmay Sawarkar | 2de3f77 | 2017-02-07 12:03:44 -0800 | [diff] [blame] | 742 | inst->buffer_mode_set[CAPTURE_PORT] = HAL_BUFFER_MODE_DYNAMIC; |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 743 | /* To start with, both ports are 1 plane each */ |
| 744 | inst->bufq[OUTPUT_PORT].num_planes = 1; |
| 745 | inst->bufq[CAPTURE_PORT].num_planes = 1; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 746 | inst->prop.fps = DEFAULT_FPS; |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 747 | inst->clk_data.operating_rate = 0; |
Praneeth Paladugu | a6b6aa4 | 2017-05-16 13:33:01 -0700 | [diff] [blame] | 748 | |
| 749 | /* By default, initialize CAPTURE port to UBWC YUV format */ |
| 750 | fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats, |
| 751 | ARRAY_SIZE(vdec_formats), V4L2_PIX_FMT_NV12_UBWC, |
| 752 | CAPTURE_PORT); |
| 753 | if (!fmt || fmt->type != CAPTURE_PORT) { |
| 754 | dprintk(VIDC_ERR, |
| 755 | "vdec_formats corrupted\n"); |
| 756 | return -EINVAL; |
| 757 | } |
| 758 | memcpy(&inst->fmts[fmt->type], fmt, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 759 | sizeof(struct msm_vidc_format)); |
Praneeth Paladugu | a6b6aa4 | 2017-05-16 13:33:01 -0700 | [diff] [blame] | 760 | |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 761 | inst->buff_req.buffer[1].buffer_type = HAL_BUFFER_INPUT; |
| 762 | inst->buff_req.buffer[1].buffer_count_min_host = |
| 763 | inst->buff_req.buffer[1].buffer_count_actual = |
| 764 | MIN_NUM_DEC_OUTPUT_BUFFERS; |
| 765 | inst->buff_req.buffer[2].buffer_type = HAL_BUFFER_OUTPUT; |
| 766 | inst->buff_req.buffer[2].buffer_count_min_host = |
| 767 | inst->buff_req.buffer[2].buffer_count_actual = |
| 768 | MIN_NUM_DEC_CAPTURE_BUFFERS; |
| 769 | inst->buff_req.buffer[3].buffer_type = HAL_BUFFER_OUTPUT2; |
| 770 | inst->buff_req.buffer[3].buffer_count_min_host = |
| 771 | inst->buff_req.buffer[3].buffer_count_actual = |
| 772 | MIN_NUM_DEC_CAPTURE_BUFFERS; |
| 773 | |
Praneeth Paladugu | a6b6aa4 | 2017-05-16 13:33:01 -0700 | [diff] [blame] | 774 | /* By default, initialize OUTPUT port to H264 decoder */ |
| 775 | fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats, |
| 776 | ARRAY_SIZE(vdec_formats), V4L2_PIX_FMT_H264, |
| 777 | OUTPUT_PORT); |
| 778 | if (!fmt || fmt->type != OUTPUT_PORT) { |
| 779 | dprintk(VIDC_ERR, |
| 780 | "vdec_formats corrupted\n"); |
| 781 | return -EINVAL; |
| 782 | } |
| 783 | memcpy(&inst->fmts[fmt->type], fmt, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 784 | sizeof(struct msm_vidc_format)); |
Praneeth Paladugu | a6b6aa4 | 2017-05-16 13:33:01 -0700 | [diff] [blame] | 785 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 786 | return rc; |
| 787 | } |
| 788 | |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 789 | static struct v4l2_ctrl *get_ctrl_from_cluster(int id, |
| 790 | struct v4l2_ctrl **cluster, int ncontrols) |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 791 | { |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 792 | int c; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 793 | |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 794 | for (c = 0; c < ncontrols; ++c) |
| 795 | if (cluster[c]->id == id) |
| 796 | return cluster[c]; |
| 797 | return NULL; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 798 | } |
| 799 | |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 800 | int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 801 | { |
| 802 | int rc = 0; |
| 803 | struct hal_nal_stream_format_supported stream_format; |
| 804 | struct hal_enable_picture enable_picture; |
| 805 | struct hal_enable hal_property; |
| 806 | enum hal_property property_id = 0; |
| 807 | u32 property_val = 0; |
| 808 | void *pdata = NULL; |
| 809 | struct hfi_device *hdev; |
| 810 | struct hal_extradata_enable extra; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 811 | struct hal_multi_stream multi_stream; |
| 812 | struct v4l2_ctrl *temp_ctrl = NULL; |
| 813 | struct hal_profile_level profile_level; |
| 814 | struct hal_frame_size frame_sz; |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 815 | struct hal_buffer_requirements *bufreq; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 816 | |
| 817 | if (!inst || !inst->core || !inst->core->device) { |
| 818 | dprintk(VIDC_ERR, "%s invalid parameters\n", __func__); |
| 819 | return -EINVAL; |
| 820 | } |
| 821 | hdev = inst->core->device; |
| 822 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 823 | /* Small helper macro for quickly getting a control and err checking */ |
| 824 | #define TRY_GET_CTRL(__ctrl_id) ({ \ |
| 825 | struct v4l2_ctrl *__temp; \ |
| 826 | __temp = get_ctrl_from_cluster( \ |
| 827 | __ctrl_id, \ |
| 828 | ctrl->cluster, ctrl->ncontrols); \ |
| 829 | if (!__temp) { \ |
| 830 | dprintk(VIDC_ERR, "Can't find %s (%x) in cluster\n", \ |
| 831 | #__ctrl_id, __ctrl_id); \ |
| 832 | /* Clusters are hardcoded, if we can't find */ \ |
| 833 | /* something then things are massively screwed up */ \ |
| 834 | MSM_VIDC_ERROR(1); \ |
| 835 | } \ |
| 836 | __temp; \ |
| 837 | }) |
| 838 | |
| 839 | v4l2_ctrl_unlock(ctrl); |
| 840 | |
| 841 | switch (ctrl->id) { |
| 842 | case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_FORMAT: |
| 843 | property_id = HAL_PARAM_NAL_STREAM_FORMAT_SELECT; |
| 844 | stream_format.nal_stream_format_supported = BIT(ctrl->val); |
| 845 | pdata = &stream_format; |
| 846 | break; |
| 847 | case V4L2_CID_MPEG_VIDC_VIDEO_OUTPUT_ORDER: |
| 848 | property_id = HAL_PARAM_VDEC_OUTPUT_ORDER; |
| 849 | property_val = ctrl->val; |
| 850 | pdata = &property_val; |
| 851 | break; |
| 852 | case V4L2_CID_MPEG_VIDC_VIDEO_PICTYPE_DEC_MODE: |
| 853 | property_id = HAL_PARAM_VDEC_PICTURE_TYPE_DECODE; |
| 854 | if (ctrl->val == |
| 855 | V4L2_MPEG_VIDC_VIDEO_PICTYPE_DECODE_ON) |
| 856 | enable_picture.picture_type = HAL_PICTURE_I; |
| 857 | else |
| 858 | enable_picture.picture_type = HAL_PICTURE_I | |
| 859 | HAL_PICTURE_P | HAL_PICTURE_B | |
| 860 | HAL_PICTURE_IDR; |
| 861 | pdata = &enable_picture; |
| 862 | break; |
| 863 | case V4L2_CID_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE: |
| 864 | switch (ctrl->val) { |
| 865 | case V4L2_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE_DISABLE: |
| 866 | inst->flags &= ~VIDC_THUMBNAIL; |
| 867 | break; |
| 868 | case V4L2_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE_ENABLE: |
| 869 | inst->flags |= VIDC_THUMBNAIL; |
| 870 | break; |
| 871 | } |
| 872 | |
| 873 | property_id = HAL_PARAM_VDEC_SYNC_FRAME_DECODE; |
| 874 | hal_property.enable = ctrl->val; |
| 875 | pdata = &hal_property; |
Praneeth Paladugu | 75cf18e | 2016-12-08 16:12:11 -0800 | [diff] [blame] | 876 | msm_dcvs_try_enable(inst); |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 877 | |
| 878 | bufreq = get_buff_req_buffer(inst, |
| 879 | HAL_BUFFER_INPUT); |
| 880 | if (!bufreq) { |
| 881 | dprintk(VIDC_ERR, |
| 882 | "Failed : No buffer requirements : %x\n", |
| 883 | HAL_BUFFER_OUTPUT); |
| 884 | return -EINVAL; |
| 885 | } |
| 886 | bufreq->buffer_count_min = |
| 887 | MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; |
Karthikeyan Periasamy | ec339fd | 2017-07-11 16:45:08 -0700 | [diff] [blame] | 888 | bufreq->buffer_count_min_host = |
| 889 | MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; |
| 890 | bufreq->buffer_count_actual = |
| 891 | MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 892 | |
| 893 | if (msm_comm_get_stream_output_mode(inst) == |
| 894 | HAL_VIDEO_DECODER_SECONDARY) { |
| 895 | |
| 896 | bufreq = get_buff_req_buffer(inst, |
| 897 | HAL_BUFFER_OUTPUT); |
| 898 | if (!bufreq) { |
| 899 | dprintk(VIDC_ERR, |
| 900 | "Failed : No buffer requirements: %x\n", |
| 901 | HAL_BUFFER_OUTPUT); |
| 902 | return -EINVAL; |
| 903 | } |
| 904 | |
| 905 | bufreq->buffer_count_min = |
| 906 | MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS; |
Karthikeyan Periasamy | ec339fd | 2017-07-11 16:45:08 -0700 | [diff] [blame] | 907 | bufreq->buffer_count_min_host = |
| 908 | MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; |
| 909 | bufreq->buffer_count_actual = |
| 910 | MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 911 | |
| 912 | bufreq = get_buff_req_buffer(inst, |
| 913 | HAL_BUFFER_OUTPUT2); |
| 914 | if (!bufreq) { |
| 915 | dprintk(VIDC_ERR, |
| 916 | "Failed : No buffer requirements: %x\n", |
| 917 | HAL_BUFFER_OUTPUT2); |
| 918 | return -EINVAL; |
| 919 | } |
| 920 | |
| 921 | bufreq->buffer_count_min = |
| 922 | MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS; |
Karthikeyan Periasamy | ec339fd | 2017-07-11 16:45:08 -0700 | [diff] [blame] | 923 | bufreq->buffer_count_min_host = |
| 924 | MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; |
| 925 | bufreq->buffer_count_actual = |
| 926 | MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; |
| 927 | |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 928 | } else { |
| 929 | |
| 930 | bufreq = get_buff_req_buffer(inst, |
| 931 | HAL_BUFFER_OUTPUT); |
| 932 | if (!bufreq) { |
| 933 | dprintk(VIDC_ERR, |
| 934 | "Failed : No buffer requirements: %x\n", |
| 935 | HAL_BUFFER_OUTPUT); |
| 936 | return -EINVAL; |
| 937 | } |
| 938 | bufreq->buffer_count_min = |
| 939 | MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS; |
Karthikeyan Periasamy | ec339fd | 2017-07-11 16:45:08 -0700 | [diff] [blame] | 940 | bufreq->buffer_count_min_host = |
| 941 | MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; |
| 942 | bufreq->buffer_count_actual = |
| 943 | MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; |
Praneeth Paladugu | 6e63747 | 2017-05-16 16:06:46 -0700 | [diff] [blame] | 944 | |
| 945 | } |
| 946 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 947 | break; |
| 948 | case V4L2_CID_MPEG_VIDC_VIDEO_SECURE: |
Karthikeyan Periasamy | a0e4bad | 2017-04-26 12:51:10 -0700 | [diff] [blame] | 949 | property_id = HAL_PARAM_SECURE; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 950 | inst->flags |= VIDC_SECURE; |
Karthikeyan Periasamy | a0e4bad | 2017-04-26 12:51:10 -0700 | [diff] [blame] | 951 | property_val = !!(inst->flags & VIDC_SECURE); |
| 952 | pdata = &property_val; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 953 | dprintk(VIDC_DBG, "Setting secure mode to: %d\n", |
| 954 | !!(inst->flags & VIDC_SECURE)); |
| 955 | break; |
| 956 | case V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA: |
| 957 | property_id = HAL_PARAM_INDEX_EXTRADATA; |
| 958 | extra.index = msm_comm_get_hal_extradata_index(ctrl->val); |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 959 | switch (ctrl->val) { |
| 960 | case V4L2_MPEG_VIDC_EXTRADATA_MB_QUANTIZATION: |
| 961 | case V4L2_MPEG_VIDC_EXTRADATA_INTERLACE_VIDEO: |
| 962 | case V4L2_MPEG_VIDC_EXTRADATA_TIMESTAMP: |
| 963 | case V4L2_MPEG_VIDC_EXTRADATA_S3D_FRAME_PACKING: |
| 964 | case V4L2_MPEG_VIDC_EXTRADATA_FRAME_RATE: |
| 965 | case V4L2_MPEG_VIDC_EXTRADATA_PANSCAN_WINDOW: |
| 966 | case V4L2_MPEG_VIDC_EXTRADATA_RECOVERY_POINT_SEI: |
| 967 | case V4L2_MPEG_VIDC_EXTRADATA_NUM_CONCEALED_MB: |
| 968 | case V4L2_MPEG_VIDC_EXTRADATA_ASPECT_RATIO: |
| 969 | case V4L2_MPEG_VIDC_EXTRADATA_MPEG2_SEQDISP: |
| 970 | case V4L2_MPEG_VIDC_EXTRADATA_STREAM_USERDATA: |
| 971 | case V4L2_MPEG_VIDC_EXTRADATA_FRAME_QP: |
| 972 | case V4L2_MPEG_VIDC_EXTRADATA_FRAME_BITS_INFO: |
| 973 | case V4L2_MPEG_VIDC_EXTRADATA_VQZIP_SEI: |
| 974 | case V4L2_MPEG_VIDC_EXTRADATA_OUTPUT_CROP: |
| 975 | case V4L2_MPEG_VIDC_EXTRADATA_DISPLAY_COLOUR_SEI: |
| 976 | case V4L2_MPEG_VIDC_EXTRADATA_CONTENT_LIGHT_LEVEL_SEI: |
| 977 | case V4L2_MPEG_VIDC_EXTRADATA_VUI_DISPLAY: |
| 978 | case V4L2_MPEG_VIDC_EXTRADATA_VPX_COLORSPACE: |
Praneeth Paladugu | a51b2c4 | 2017-06-23 12:48:06 -0700 | [diff] [blame] | 979 | case V4L2_MPEG_VIDC_EXTRADATA_UBWC_CR_STATS_INFO: |
Praneeth Paladugu | defea4e | 2017-02-09 23:44:08 -0800 | [diff] [blame] | 980 | inst->bufq[CAPTURE_PORT].num_planes = 2; |
| 981 | inst->bufq[CAPTURE_PORT].plane_sizes[EXTRADATA_IDX(2)] = |
| 982 | VENUS_EXTRADATA_SIZE( |
| 983 | inst->prop.height[CAPTURE_PORT], |
| 984 | inst->prop.width[CAPTURE_PORT]); |
| 985 | break; |
| 986 | default: |
| 987 | rc = -ENOTSUPP; |
| 988 | break; |
| 989 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 990 | extra.enable = 1; |
| 991 | pdata = &extra; |
| 992 | break; |
| 993 | case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_MODE: |
| 994 | if (ctrl->val && !(inst->capability.pixelprocess_capabilities & |
| 995 | HAL_VIDEO_DECODER_MULTI_STREAM_CAPABILITY)) { |
| 996 | dprintk(VIDC_ERR, "Downscaling not supported: %#x\n", |
| 997 | ctrl->id); |
| 998 | rc = -ENOTSUPP; |
| 999 | break; |
| 1000 | } |
| 1001 | switch (ctrl->val) { |
| 1002 | case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_PRIMARY: |
| 1003 | multi_stream.buffer_type = HAL_BUFFER_OUTPUT; |
| 1004 | multi_stream.enable = true; |
| 1005 | pdata = &multi_stream; |
| 1006 | rc = call_hfi_op(hdev, session_set_property, (void *) |
| 1007 | inst->session, HAL_PARAM_VDEC_MULTI_STREAM, |
| 1008 | pdata); |
| 1009 | if (rc) { |
| 1010 | dprintk(VIDC_ERR, |
| 1011 | "Failed : Enabling OUTPUT port : %d\n", |
| 1012 | rc); |
| 1013 | break; |
| 1014 | } |
| 1015 | multi_stream.buffer_type = HAL_BUFFER_OUTPUT2; |
| 1016 | multi_stream.enable = false; |
| 1017 | pdata = &multi_stream; |
| 1018 | rc = call_hfi_op(hdev, session_set_property, (void *) |
| 1019 | inst->session, HAL_PARAM_VDEC_MULTI_STREAM, |
| 1020 | pdata); |
| 1021 | if (rc) |
| 1022 | dprintk(VIDC_ERR, |
| 1023 | "Failed:Disabling OUTPUT2 port : %d\n", |
| 1024 | rc); |
| 1025 | break; |
| 1026 | case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_SECONDARY: |
| 1027 | multi_stream.buffer_type = HAL_BUFFER_OUTPUT2; |
| 1028 | multi_stream.enable = true; |
| 1029 | pdata = &multi_stream; |
| 1030 | rc = call_hfi_op(hdev, session_set_property, (void *) |
| 1031 | inst->session, HAL_PARAM_VDEC_MULTI_STREAM, |
| 1032 | pdata); |
| 1033 | if (rc) { |
| 1034 | dprintk(VIDC_ERR, |
| 1035 | "Failed :Enabling OUTPUT2 port : %d\n", |
| 1036 | rc); |
| 1037 | break; |
| 1038 | } |
| 1039 | multi_stream.buffer_type = HAL_BUFFER_OUTPUT; |
| 1040 | multi_stream.enable = false; |
| 1041 | pdata = &multi_stream; |
| 1042 | rc = call_hfi_op(hdev, session_set_property, (void *) |
| 1043 | inst->session, HAL_PARAM_VDEC_MULTI_STREAM, |
| 1044 | pdata); |
| 1045 | if (rc) { |
| 1046 | dprintk(VIDC_ERR, |
| 1047 | "Failed disabling OUTPUT port : %d\n", |
| 1048 | rc); |
| 1049 | break; |
| 1050 | } |
| 1051 | |
| 1052 | frame_sz.buffer_type = HAL_BUFFER_OUTPUT2; |
| 1053 | frame_sz.width = inst->prop.width[CAPTURE_PORT]; |
| 1054 | frame_sz.height = inst->prop.height[CAPTURE_PORT]; |
| 1055 | pdata = &frame_sz; |
| 1056 | dprintk(VIDC_DBG, |
| 1057 | "buffer type = %d width = %d, height = %d\n", |
| 1058 | frame_sz.buffer_type, frame_sz.width, |
| 1059 | frame_sz.height); |
| 1060 | rc = call_hfi_op(hdev, session_set_property, (void *) |
| 1061 | inst->session, HAL_PARAM_FRAME_SIZE, pdata); |
| 1062 | if (rc) |
| 1063 | dprintk(VIDC_ERR, |
| 1064 | "Failed setting OUTPUT2 size : %d\n", |
| 1065 | rc); |
| 1066 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1067 | break; |
| 1068 | default: |
| 1069 | dprintk(VIDC_ERR, |
| 1070 | "Failed : Unsupported multi stream setting\n"); |
| 1071 | rc = -ENOTSUPP; |
| 1072 | break; |
| 1073 | } |
| 1074 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1075 | case V4L2_CID_MPEG_VIDEO_H264_PROFILE: |
| 1076 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_H264_LEVEL); |
| 1077 | property_id = |
| 1078 | HAL_PARAM_PROFILE_LEVEL_CURRENT; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1079 | profile_level.profile = msm_comm_v4l2_to_hal(ctrl->id, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1080 | ctrl->val); |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1081 | profile_level.level = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1082 | V4L2_CID_MPEG_VIDEO_H264_LEVEL, |
| 1083 | temp_ctrl->val); |
| 1084 | pdata = &profile_level; |
| 1085 | break; |
| 1086 | case V4L2_CID_MPEG_VIDEO_H264_LEVEL: |
| 1087 | temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_H264_PROFILE); |
| 1088 | property_id = |
| 1089 | HAL_PARAM_PROFILE_LEVEL_CURRENT; |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1090 | profile_level.level = msm_comm_v4l2_to_hal(ctrl->id, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1091 | ctrl->val); |
Chinmay Sawarkar | b3c6ccb | 2017-02-23 18:01:32 -0800 | [diff] [blame] | 1092 | profile_level.profile = msm_comm_v4l2_to_hal( |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1093 | V4L2_CID_MPEG_VIDEO_H264_PROFILE, |
| 1094 | temp_ctrl->val); |
| 1095 | pdata = &profile_level; |
| 1096 | break; |
| 1097 | case V4L2_CID_MPEG_VIDC_VIDEO_BUFFER_SIZE_LIMIT: |
| 1098 | dprintk(VIDC_DBG, |
| 1099 | "Limiting input buffer size from %u to %u\n", |
| 1100 | inst->buffer_size_limit, ctrl->val); |
| 1101 | inst->buffer_size_limit = ctrl->val; |
| 1102 | break; |
| 1103 | case V4L2_CID_VIDC_QBUF_MODE: |
| 1104 | property_id = HAL_PARAM_SYNC_BASED_INTERRUPT; |
| 1105 | hal_property.enable = ctrl->val == V4L2_VIDC_QBUF_BATCHED; |
| 1106 | pdata = &hal_property; |
| 1107 | break; |
| 1108 | case V4L2_CID_MPEG_VIDC_VIDEO_PRIORITY: |
| 1109 | property_id = HAL_CONFIG_REALTIME; |
| 1110 | /* firmware has inverted values for realtime and |
| 1111 | * non-realtime priority |
| 1112 | */ |
| 1113 | hal_property.enable = !(ctrl->val); |
| 1114 | pdata = &hal_property; |
| 1115 | switch (ctrl->val) { |
| 1116 | case V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_DISABLE: |
| 1117 | inst->flags &= ~VIDC_REALTIME; |
| 1118 | break; |
| 1119 | case V4L2_MPEG_VIDC_VIDEO_PRIORITY_REALTIME_ENABLE: |
| 1120 | inst->flags |= VIDC_REALTIME; |
| 1121 | break; |
| 1122 | default: |
| 1123 | dprintk(VIDC_WARN, |
| 1124 | "inst(%pK) invalid priority ctrl value %#x\n", |
| 1125 | inst, ctrl->val); |
| 1126 | break; |
| 1127 | } |
| 1128 | break; |
| 1129 | case V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE: |
| 1130 | dprintk(VIDC_DBG, |
| 1131 | "inst(%pK) operating rate changed from %d to %d\n", |
Praneeth Paladugu | e5fd087 | 2017-04-19 11:24:28 -0700 | [diff] [blame] | 1132 | inst, inst->clk_data.operating_rate >> 16, |
| 1133 | ctrl->val >> 16); |
| 1134 | inst->clk_data.operating_rate = ctrl->val; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1135 | break; |
Saurabh Kothawade | c1cffa885 | 2017-08-18 12:20:38 -0700 | [diff] [blame] | 1136 | case V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_MODE: |
| 1137 | if (ctrl->val == |
| 1138 | V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_ENABLE) |
| 1139 | hal_property.enable = 1; |
| 1140 | else |
| 1141 | hal_property.enable = 0; |
| 1142 | inst->clk_data.low_latency_mode = (bool) hal_property.enable; |
| 1143 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1144 | default: |
| 1145 | break; |
| 1146 | } |
| 1147 | |
| 1148 | v4l2_ctrl_lock(ctrl); |
| 1149 | #undef TRY_GET_CTRL |
| 1150 | |
| 1151 | if (!rc && property_id) { |
| 1152 | dprintk(VIDC_DBG, |
Praneeth Paladugu | 92fc3b0 | 2017-05-02 15:35:17 -0700 | [diff] [blame] | 1153 | "Control: Name = %s, ID = 0x%x Value = %d\n", |
| 1154 | ctrl->name, ctrl->id, ctrl->val); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1155 | rc = call_hfi_op(hdev, session_set_property, (void *) |
| 1156 | inst->session, property_id, pdata); |
| 1157 | } |
| 1158 | |
| 1159 | return rc; |
| 1160 | } |
| 1161 | |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 1162 | int msm_vdec_s_ext_ctrl(struct msm_vidc_inst *inst, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1163 | struct v4l2_ext_controls *ctrl) |
| 1164 | { |
| 1165 | int rc = 0, i = 0, fourcc = 0; |
| 1166 | struct v4l2_ext_control *ext_control; |
| 1167 | struct v4l2_control control; |
Umesh Pandey | 42313a7 | 2017-07-05 18:20:06 -0700 | [diff] [blame] | 1168 | struct hal_conceal_color conceal_color = {0}; |
| 1169 | struct hfi_device *hdev; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1170 | |
Umesh Pandey | 42313a7 | 2017-07-05 18:20:06 -0700 | [diff] [blame] | 1171 | if (!inst || !inst->core || !inst->core->device || !ctrl) { |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1172 | dprintk(VIDC_ERR, |
| 1173 | "%s invalid parameters\n", __func__); |
| 1174 | return -EINVAL; |
| 1175 | } |
| 1176 | |
Umesh Pandey | 42313a7 | 2017-07-05 18:20:06 -0700 | [diff] [blame] | 1177 | hdev = inst->core->device; |
| 1178 | |
| 1179 | v4l2_try_ext_ctrls(&inst->ctrl_handler, ctrl); |
| 1180 | |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1181 | ext_control = ctrl->controls; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1182 | |
| 1183 | for (i = 0; i < ctrl->count; i++) { |
| 1184 | switch (ext_control[i].id) { |
| 1185 | case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_MODE: |
| 1186 | control.value = ext_control[i].value; |
Umesh Pandey | 42313a7 | 2017-07-05 18:20:06 -0700 | [diff] [blame] | 1187 | control.id = |
| 1188 | V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_MODE; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1189 | rc = msm_comm_s_ctrl(inst, &control); |
| 1190 | if (rc) |
| 1191 | dprintk(VIDC_ERR, |
| 1192 | "%s Failed setting stream output mode : %d\n", |
| 1193 | __func__, rc); |
Praneeth Paladugu | 86c7c24 | 2017-07-16 19:44:42 -0700 | [diff] [blame] | 1194 | rc = msm_vidc_update_host_buff_counts(inst); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1195 | break; |
| 1196 | case V4L2_CID_MPEG_VIDC_VIDEO_DPB_COLOR_FORMAT: |
Umesh Pandey | 42313a7 | 2017-07-05 18:20:06 -0700 | [diff] [blame] | 1197 | control.id = |
| 1198 | V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_MODE; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1199 | switch (ext_control[i].value) { |
| 1200 | case V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_NONE: |
| 1201 | if (!msm_comm_g_ctrl_for_id(inst, control.id)) { |
| 1202 | rc = msm_comm_release_output_buffers( |
Vaibhav Deshu Venkatesh | 8c9b6db | 2017-02-08 11:22:36 -0800 | [diff] [blame] | 1203 | inst, false); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1204 | if (rc) |
| 1205 | dprintk(VIDC_ERR, |
| 1206 | "%s Release output buffers failed\n", |
| 1207 | __func__); |
| 1208 | } |
| 1209 | break; |
| 1210 | case V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_UBWC: |
| 1211 | case V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_TP10_UBWC: |
| 1212 | if (ext_control[i].value == |
| 1213 | V4L2_MPEG_VIDC_VIDEO_DPB_COLOR_FMT_UBWC) |
| 1214 | fourcc = V4L2_PIX_FMT_NV12_UBWC; |
| 1215 | else |
| 1216 | fourcc = V4L2_PIX_FMT_NV12_TP10_UBWC; |
| 1217 | if (msm_comm_g_ctrl_for_id(inst, control.id)) { |
| 1218 | rc = msm_comm_set_color_format(inst, |
| 1219 | HAL_BUFFER_OUTPUT, fourcc); |
| 1220 | if (rc) { |
| 1221 | dprintk(VIDC_ERR, |
| 1222 | "%s Failed setting output color format : %d\n", |
| 1223 | __func__, rc); |
| 1224 | break; |
| 1225 | } |
Chinmay Sawarkar | 02f8f85 | 2017-06-26 12:05:38 -0700 | [diff] [blame] | 1226 | rc = msm_comm_try_get_bufreqs(inst); |
| 1227 | if (rc) { |
| 1228 | dprintk(VIDC_ERR, |
| 1229 | "%s Failed to get buffer requirements : %d\n", |
| 1230 | __func__, rc); |
| 1231 | break; |
| 1232 | } |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1233 | } |
Praneeth Paladugu | 86c7c24 | 2017-07-16 19:44:42 -0700 | [diff] [blame] | 1234 | rc = msm_vidc_update_host_buff_counts(inst); |
Praneeth Paladugu | 319e792 | 2017-03-16 11:09:06 -0700 | [diff] [blame] | 1235 | inst->clk_data.dpb_fourcc = fourcc; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1236 | break; |
| 1237 | default: |
| 1238 | dprintk(VIDC_ERR, |
| 1239 | "%s Unsupported output color format\n", |
| 1240 | __func__); |
| 1241 | rc = -ENOTSUPP; |
| 1242 | break; |
| 1243 | } |
| 1244 | break; |
Umesh Pandey | 42313a7 | 2017-07-05 18:20:06 -0700 | [diff] [blame] | 1245 | case V4L2_CID_MPEG_VIDC_VIDEO_CONCEAL_COLOR_8BIT: |
| 1246 | conceal_color.conceal_color_8bit = ext_control[i].value; |
| 1247 | i++; |
| 1248 | switch (ext_control[i].id) { |
| 1249 | case V4L2_CID_MPEG_VIDC_VIDEO_CONCEAL_COLOR_10BIT: |
| 1250 | conceal_color.conceal_color_10bit = |
| 1251 | ext_control[i].value; |
| 1252 | dprintk(VIDC_DBG, |
| 1253 | "conceal color: 8bit=0x%x 10bit=0x%x", |
| 1254 | conceal_color.conceal_color_8bit, |
| 1255 | conceal_color.conceal_color_10bit); |
| 1256 | rc = call_hfi_op(hdev, session_set_property, |
| 1257 | inst->session, |
| 1258 | HAL_PARAM_VDEC_CONCEAL_COLOR, |
| 1259 | &conceal_color); |
| 1260 | if (rc) { |
| 1261 | dprintk(VIDC_ERR, |
| 1262 | "%s Failed setting conceal color", |
| 1263 | __func__); |
| 1264 | } |
| 1265 | break; |
| 1266 | default: |
| 1267 | dprintk(VIDC_ERR, |
| 1268 | "%s Could not find CONCEAL_COLOR_10BIT ext_control", |
| 1269 | __func__); |
| 1270 | rc = -ENOTSUPP; |
| 1271 | break; |
| 1272 | } |
| 1273 | |
| 1274 | break; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1275 | default: |
| 1276 | dprintk(VIDC_ERR |
| 1277 | , "%s Unsupported set control %d", |
| 1278 | __func__, ext_control[i].id); |
| 1279 | rc = -ENOTSUPP; |
| 1280 | break; |
| 1281 | } |
| 1282 | } |
| 1283 | |
| 1284 | return rc; |
| 1285 | } |
| 1286 | |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 1287 | int msm_vdec_ctrl_init(struct msm_vidc_inst *inst, |
| 1288 | const struct v4l2_ctrl_ops *ctrl_ops) |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1289 | { |
| 1290 | return msm_comm_ctrl_init(inst, msm_vdec_ctrls, |
Praneeth Paladugu | be42cb2 | 2016-04-12 22:34:39 -0700 | [diff] [blame] | 1291 | ARRAY_SIZE(msm_vdec_ctrls), ctrl_ops); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1292 | } |