1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. 4 * Copyright (C) 2017 Linaro Ltd. 5 */ 6 #include <linux/errno.h> 7 #include <linux/hash.h> 8 9 #include "hfi_cmds.h" 10 11 static enum hfi_version hfi_ver; 12 13 void pkt_sys_init(struct hfi_sys_init_pkt *pkt, u32 arch_type) 14 { 15 pkt->hdr.size = sizeof(*pkt); 16 pkt->hdr.pkt_type = HFI_CMD_SYS_INIT; 17 pkt->arch_type = arch_type; 18 } 19 20 void pkt_sys_pc_prep(struct hfi_sys_pc_prep_pkt *pkt) 21 { 22 pkt->hdr.size = sizeof(*pkt); 23 pkt->hdr.pkt_type = HFI_CMD_SYS_PC_PREP; 24 } 25 26 void pkt_sys_idle_indicator(struct hfi_sys_set_property_pkt *pkt, u32 enable) 27 { 28 struct hfi_enable *hfi = (struct hfi_enable *)&pkt->data[1]; 29 30 pkt->hdr.size = sizeof(*pkt) + sizeof(*hfi) + sizeof(u32); 31 pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY; 32 pkt->num_properties = 1; 33 pkt->data[0] = HFI_PROPERTY_SYS_IDLE_INDICATOR; 34 hfi->enable = enable; 35 } 36 37 void pkt_sys_debug_config(struct hfi_sys_set_property_pkt *pkt, u32 mode, 38 u32 config) 39 { 40 struct hfi_debug_config *hfi; 41 42 pkt->hdr.size = sizeof(*pkt) + sizeof(*hfi) + sizeof(u32); 43 pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY; 44 pkt->num_properties = 1; 45 pkt->data[0] = HFI_PROPERTY_SYS_DEBUG_CONFIG; 46 hfi = (struct hfi_debug_config *)&pkt->data[1]; 47 hfi->config = config; 48 hfi->mode = mode; 49 } 50 51 void pkt_sys_coverage_config(struct hfi_sys_set_property_pkt *pkt, u32 mode) 52 { 53 pkt->hdr.size = sizeof(*pkt) + sizeof(u32); 54 pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY; 55 pkt->num_properties = 1; 56 pkt->data[0] = HFI_PROPERTY_SYS_CONFIG_COVERAGE; 57 pkt->data[1] = mode; 58 } 59 60 int pkt_sys_set_resource(struct hfi_sys_set_resource_pkt *pkt, u32 id, u32 size, 61 u32 addr, void *cookie) 62 { 63 pkt->hdr.size = sizeof(*pkt); 64 pkt->hdr.pkt_type = HFI_CMD_SYS_SET_RESOURCE; 65 pkt->resource_handle = hash32_ptr(cookie); 66 67 switch (id) { 68 case VIDC_RESOURCE_OCMEM: 69 case VIDC_RESOURCE_VMEM: { 70 struct hfi_resource_ocmem *res = 71 (struct hfi_resource_ocmem *)&pkt->resource_data[0]; 72 73 res->size = size; 74 res->mem = addr; 75 pkt->resource_type = HFI_RESOURCE_OCMEM; 76 pkt->hdr.size += sizeof(*res) - sizeof(u32); 77 break; 78 } 79 case VIDC_RESOURCE_NONE: 80 default: 81 return -ENOTSUPP; 82 } 83 84 return 0; 85 } 86 87 int pkt_sys_unset_resource(struct hfi_sys_release_resource_pkt *pkt, u32 id, 88 u32 size, void *cookie) 89 { 90 pkt->hdr.size = sizeof(*pkt); 91 pkt->hdr.pkt_type = HFI_CMD_SYS_RELEASE_RESOURCE; 92 pkt->resource_handle = hash32_ptr(cookie); 93 94 switch (id) { 95 case VIDC_RESOURCE_OCMEM: 96 case VIDC_RESOURCE_VMEM: 97 pkt->resource_type = HFI_RESOURCE_OCMEM; 98 break; 99 case VIDC_RESOURCE_NONE: 100 break; 101 default: 102 return -ENOTSUPP; 103 } 104 105 return 0; 106 } 107 108 void pkt_sys_ping(struct hfi_sys_ping_pkt *pkt, u32 cookie) 109 { 110 pkt->hdr.size = sizeof(*pkt); 111 pkt->hdr.pkt_type = HFI_CMD_SYS_PING; 112 pkt->client_data = cookie; 113 } 114 115 void pkt_sys_power_control(struct hfi_sys_set_property_pkt *pkt, u32 enable) 116 { 117 struct hfi_enable *hfi = (struct hfi_enable *)&pkt->data[1]; 118 119 pkt->hdr.size = sizeof(*pkt) + sizeof(*hfi) + sizeof(u32); 120 pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY; 121 pkt->num_properties = 1; 122 pkt->data[0] = HFI_PROPERTY_SYS_CODEC_POWER_PLANE_CTRL; 123 hfi->enable = enable; 124 } 125 126 int pkt_sys_ssr_cmd(struct hfi_sys_test_ssr_pkt *pkt, u32 trigger_type) 127 { 128 switch (trigger_type) { 129 case HFI_TEST_SSR_SW_ERR_FATAL: 130 case HFI_TEST_SSR_SW_DIV_BY_ZERO: 131 case HFI_TEST_SSR_HW_WDOG_IRQ: 132 break; 133 default: 134 return -EINVAL; 135 } 136 137 pkt->hdr.size = sizeof(*pkt); 138 pkt->hdr.pkt_type = HFI_CMD_SYS_TEST_SSR; 139 pkt->trigger_type = trigger_type; 140 141 return 0; 142 } 143 144 void pkt_sys_image_version(struct hfi_sys_get_property_pkt *pkt) 145 { 146 pkt->hdr.size = sizeof(*pkt); 147 pkt->hdr.pkt_type = HFI_CMD_SYS_GET_PROPERTY; 148 pkt->num_properties = 1; 149 pkt->data[0] = HFI_PROPERTY_SYS_IMAGE_VERSION; 150 } 151 152 int pkt_session_init(struct hfi_session_init_pkt *pkt, void *cookie, 153 u32 session_type, u32 codec) 154 { 155 if (!pkt || !cookie || !codec) 156 return -EINVAL; 157 158 pkt->shdr.hdr.size = sizeof(*pkt); 159 pkt->shdr.hdr.pkt_type = HFI_CMD_SYS_SESSION_INIT; 160 pkt->shdr.session_id = hash32_ptr(cookie); 161 pkt->session_domain = session_type; 162 pkt->session_codec = codec; 163 164 return 0; 165 } 166 167 void pkt_session_cmd(struct hfi_session_pkt *pkt, u32 pkt_type, void *cookie) 168 { 169 pkt->shdr.hdr.size = sizeof(*pkt); 170 pkt->shdr.hdr.pkt_type = pkt_type; 171 pkt->shdr.session_id = hash32_ptr(cookie); 172 } 173 174 int pkt_session_set_buffers(struct hfi_session_set_buffers_pkt *pkt, 175 void *cookie, struct hfi_buffer_desc *bd) 176 { 177 unsigned int i; 178 179 if (!cookie || !pkt || !bd) 180 return -EINVAL; 181 182 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_BUFFERS; 183 pkt->shdr.session_id = hash32_ptr(cookie); 184 pkt->buffer_size = bd->buffer_size; 185 pkt->min_buffer_size = bd->buffer_size; 186 pkt->num_buffers = bd->num_buffers; 187 188 if (bd->buffer_type == HFI_BUFFER_OUTPUT || 189 bd->buffer_type == HFI_BUFFER_OUTPUT2) { 190 struct hfi_buffer_info *bi; 191 192 pkt->extradata_size = bd->extradata_size; 193 pkt->shdr.hdr.size = sizeof(*pkt) - sizeof(u32) + 194 (bd->num_buffers * sizeof(*bi)); 195 bi = (struct hfi_buffer_info *)pkt->buffer_info; 196 for (i = 0; i < pkt->num_buffers; i++) { 197 bi->buffer_addr = bd->device_addr; 198 bi->extradata_addr = bd->extradata_addr; 199 } 200 } else { 201 pkt->extradata_size = 0; 202 pkt->shdr.hdr.size = sizeof(*pkt) + 203 ((bd->num_buffers - 1) * sizeof(u32)); 204 for (i = 0; i < pkt->num_buffers; i++) 205 pkt->buffer_info[i] = bd->device_addr; 206 } 207 208 pkt->buffer_type = bd->buffer_type; 209 210 return 0; 211 } 212 213 int pkt_session_unset_buffers(struct hfi_session_release_buffer_pkt *pkt, 214 void *cookie, struct hfi_buffer_desc *bd) 215 { 216 unsigned int i; 217 218 if (!cookie || !pkt || !bd) 219 return -EINVAL; 220 221 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_RELEASE_BUFFERS; 222 pkt->shdr.session_id = hash32_ptr(cookie); 223 pkt->buffer_size = bd->buffer_size; 224 pkt->num_buffers = bd->num_buffers; 225 226 if (bd->buffer_type == HFI_BUFFER_OUTPUT || 227 bd->buffer_type == HFI_BUFFER_OUTPUT2) { 228 struct hfi_buffer_info *bi; 229 230 bi = (struct hfi_buffer_info *)pkt->buffer_info; 231 for (i = 0; i < pkt->num_buffers; i++) { 232 bi->buffer_addr = bd->device_addr; 233 bi->extradata_addr = bd->extradata_addr; 234 } 235 pkt->shdr.hdr.size = 236 sizeof(struct hfi_session_set_buffers_pkt) - 237 sizeof(u32) + (bd->num_buffers * sizeof(*bi)); 238 } else { 239 for (i = 0; i < pkt->num_buffers; i++) 240 pkt->buffer_info[i] = bd->device_addr; 241 242 pkt->extradata_size = 0; 243 pkt->shdr.hdr.size = 244 sizeof(struct hfi_session_set_buffers_pkt) + 245 ((bd->num_buffers - 1) * sizeof(u32)); 246 } 247 248 pkt->response_req = bd->response_required; 249 pkt->buffer_type = bd->buffer_type; 250 251 return 0; 252 } 253 254 int pkt_session_etb_decoder(struct hfi_session_empty_buffer_compressed_pkt *pkt, 255 void *cookie, struct hfi_frame_data *in_frame) 256 { 257 if (!cookie) 258 return -EINVAL; 259 260 pkt->shdr.hdr.size = sizeof(*pkt); 261 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_EMPTY_BUFFER; 262 pkt->shdr.session_id = hash32_ptr(cookie); 263 pkt->time_stamp_hi = upper_32_bits(in_frame->timestamp); 264 pkt->time_stamp_lo = lower_32_bits(in_frame->timestamp); 265 pkt->flags = in_frame->flags; 266 pkt->mark_target = in_frame->mark_target; 267 pkt->mark_data = in_frame->mark_data; 268 pkt->offset = in_frame->offset; 269 pkt->alloc_len = in_frame->alloc_len; 270 pkt->filled_len = in_frame->filled_len; 271 pkt->input_tag = in_frame->clnt_data; 272 pkt->packet_buffer = in_frame->device_addr; 273 274 return 0; 275 } 276 277 int pkt_session_etb_encoder( 278 struct hfi_session_empty_buffer_uncompressed_plane0_pkt *pkt, 279 void *cookie, struct hfi_frame_data *in_frame) 280 { 281 if (!cookie || !in_frame->device_addr) 282 return -EINVAL; 283 284 pkt->shdr.hdr.size = sizeof(*pkt); 285 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_EMPTY_BUFFER; 286 pkt->shdr.session_id = hash32_ptr(cookie); 287 pkt->view_id = 0; 288 pkt->time_stamp_hi = upper_32_bits(in_frame->timestamp); 289 pkt->time_stamp_lo = lower_32_bits(in_frame->timestamp); 290 pkt->flags = in_frame->flags; 291 pkt->mark_target = in_frame->mark_target; 292 pkt->mark_data = in_frame->mark_data; 293 pkt->offset = in_frame->offset; 294 pkt->alloc_len = in_frame->alloc_len; 295 pkt->filled_len = in_frame->filled_len; 296 pkt->input_tag = in_frame->clnt_data; 297 pkt->packet_buffer = in_frame->device_addr; 298 pkt->extradata_buffer = in_frame->extradata_addr; 299 300 return 0; 301 } 302 303 int pkt_session_ftb(struct hfi_session_fill_buffer_pkt *pkt, void *cookie, 304 struct hfi_frame_data *out_frame) 305 { 306 if (!cookie || !out_frame || !out_frame->device_addr) 307 return -EINVAL; 308 309 pkt->shdr.hdr.size = sizeof(*pkt); 310 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_FILL_BUFFER; 311 pkt->shdr.session_id = hash32_ptr(cookie); 312 313 if (out_frame->buffer_type == HFI_BUFFER_OUTPUT) 314 pkt->stream_id = 0; 315 else if (out_frame->buffer_type == HFI_BUFFER_OUTPUT2) 316 pkt->stream_id = 1; 317 318 pkt->output_tag = out_frame->clnt_data; 319 pkt->packet_buffer = out_frame->device_addr; 320 pkt->extradata_buffer = out_frame->extradata_addr; 321 pkt->alloc_len = out_frame->alloc_len; 322 pkt->filled_len = out_frame->filled_len; 323 pkt->offset = out_frame->offset; 324 pkt->data[0] = out_frame->extradata_size; 325 326 return 0; 327 } 328 329 int pkt_session_parse_seq_header( 330 struct hfi_session_parse_sequence_header_pkt *pkt, 331 void *cookie, u32 seq_hdr, u32 seq_hdr_len) 332 { 333 if (!cookie || !seq_hdr || !seq_hdr_len) 334 return -EINVAL; 335 336 pkt->shdr.hdr.size = sizeof(*pkt); 337 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_PARSE_SEQUENCE_HEADER; 338 pkt->shdr.session_id = hash32_ptr(cookie); 339 pkt->header_len = seq_hdr_len; 340 pkt->packet_buffer = seq_hdr; 341 342 return 0; 343 } 344 345 int pkt_session_get_seq_hdr(struct hfi_session_get_sequence_header_pkt *pkt, 346 void *cookie, u32 seq_hdr, u32 seq_hdr_len) 347 { 348 if (!cookie || !seq_hdr || !seq_hdr_len) 349 return -EINVAL; 350 351 pkt->shdr.hdr.size = sizeof(*pkt); 352 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_GET_SEQUENCE_HEADER; 353 pkt->shdr.session_id = hash32_ptr(cookie); 354 pkt->buffer_len = seq_hdr_len; 355 pkt->packet_buffer = seq_hdr; 356 357 return 0; 358 } 359 360 int pkt_session_flush(struct hfi_session_flush_pkt *pkt, void *cookie, u32 type) 361 { 362 switch (type) { 363 case HFI_FLUSH_INPUT: 364 case HFI_FLUSH_OUTPUT: 365 case HFI_FLUSH_OUTPUT2: 366 case HFI_FLUSH_ALL: 367 break; 368 default: 369 return -EINVAL; 370 } 371 372 pkt->shdr.hdr.size = sizeof(*pkt); 373 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_FLUSH; 374 pkt->shdr.session_id = hash32_ptr(cookie); 375 pkt->flush_type = type; 376 377 return 0; 378 } 379 380 static int pkt_session_get_property_1x(struct hfi_session_get_property_pkt *pkt, 381 void *cookie, u32 ptype) 382 { 383 switch (ptype) { 384 case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT: 385 case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS: 386 break; 387 default: 388 return -EINVAL; 389 } 390 391 pkt->shdr.hdr.size = sizeof(*pkt); 392 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_GET_PROPERTY; 393 pkt->shdr.session_id = hash32_ptr(cookie); 394 pkt->num_properties = 1; 395 pkt->data[0] = ptype; 396 397 return 0; 398 } 399 400 static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, 401 void *cookie, u32 ptype, void *pdata) 402 { 403 void *prop_data; 404 int ret = 0; 405 406 if (!pkt || !cookie || !pdata) 407 return -EINVAL; 408 409 prop_data = &pkt->data[1]; 410 411 pkt->shdr.hdr.size = sizeof(*pkt); 412 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; 413 pkt->shdr.session_id = hash32_ptr(cookie); 414 pkt->num_properties = 1; 415 pkt->data[0] = ptype; 416 417 switch (ptype) { 418 case HFI_PROPERTY_CONFIG_FRAME_RATE: { 419 struct hfi_framerate *in = pdata, *frate = prop_data; 420 421 frate->buffer_type = in->buffer_type; 422 frate->framerate = in->framerate; 423 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*frate); 424 break; 425 } 426 case HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT: { 427 struct hfi_uncompressed_format_select *in = pdata; 428 struct hfi_uncompressed_format_select *hfi = prop_data; 429 430 hfi->buffer_type = in->buffer_type; 431 hfi->format = in->format; 432 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hfi); 433 break; 434 } 435 case HFI_PROPERTY_PARAM_FRAME_SIZE: { 436 struct hfi_framesize *in = pdata, *fsize = prop_data; 437 438 fsize->buffer_type = in->buffer_type; 439 fsize->height = in->height; 440 fsize->width = in->width; 441 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*fsize); 442 break; 443 } 444 case HFI_PROPERTY_CONFIG_REALTIME: { 445 struct hfi_enable *in = pdata, *en = prop_data; 446 447 en->enable = in->enable; 448 pkt->shdr.hdr.size += sizeof(u32) * 2; 449 break; 450 } 451 case HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL: { 452 struct hfi_buffer_count_actual *in = pdata, *count = prop_data; 453 454 count->count_actual = in->count_actual; 455 count->type = in->type; 456 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count); 457 break; 458 } 459 case HFI_PROPERTY_PARAM_BUFFER_SIZE_ACTUAL: { 460 struct hfi_buffer_size_actual *in = pdata, *sz = prop_data; 461 462 sz->size = in->size; 463 sz->type = in->type; 464 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*sz); 465 break; 466 } 467 case HFI_PROPERTY_PARAM_BUFFER_DISPLAY_HOLD_COUNT_ACTUAL: { 468 struct hfi_buffer_display_hold_count_actual *in = pdata; 469 struct hfi_buffer_display_hold_count_actual *count = prop_data; 470 471 count->hold_count = in->hold_count; 472 count->type = in->type; 473 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count); 474 break; 475 } 476 case HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SELECT: { 477 struct hfi_nal_stream_format_select *in = pdata; 478 struct hfi_nal_stream_format_select *fmt = prop_data; 479 480 fmt->format = in->format; 481 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*fmt); 482 break; 483 } 484 case HFI_PROPERTY_PARAM_VDEC_OUTPUT_ORDER: { 485 u32 *in = pdata; 486 487 switch (*in) { 488 case HFI_OUTPUT_ORDER_DECODE: 489 case HFI_OUTPUT_ORDER_DISPLAY: 490 break; 491 default: 492 ret = -EINVAL; 493 break; 494 } 495 496 pkt->data[1] = *in; 497 pkt->shdr.hdr.size += sizeof(u32) * 2; 498 break; 499 } 500 case HFI_PROPERTY_PARAM_VDEC_PICTURE_TYPE_DECODE: { 501 struct hfi_enable_picture *in = pdata, *en = prop_data; 502 503 en->picture_type = in->picture_type; 504 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 505 break; 506 } 507 case HFI_PROPERTY_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO: { 508 struct hfi_enable *in = pdata, *en = prop_data; 509 510 en->enable = in->enable; 511 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 512 break; 513 } 514 case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER: { 515 struct hfi_enable *in = pdata; 516 struct hfi_enable *en = prop_data; 517 518 en->enable = in->enable; 519 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 520 break; 521 } 522 case HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM: { 523 struct hfi_multi_stream *in = pdata, *multi = prop_data; 524 525 multi->buffer_type = in->buffer_type; 526 multi->enable = in->enable; 527 multi->width = in->width; 528 multi->height = in->height; 529 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*multi); 530 break; 531 } 532 case HFI_PROPERTY_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT: { 533 struct hfi_display_picture_buffer_count *in = pdata; 534 struct hfi_display_picture_buffer_count *count = prop_data; 535 536 count->count = in->count; 537 count->enable = in->enable; 538 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count); 539 break; 540 } 541 case HFI_PROPERTY_PARAM_DIVX_FORMAT: { 542 u32 *in = pdata; 543 544 switch (*in) { 545 case HFI_DIVX_FORMAT_4: 546 case HFI_DIVX_FORMAT_5: 547 case HFI_DIVX_FORMAT_6: 548 break; 549 default: 550 ret = -EINVAL; 551 break; 552 } 553 554 pkt->data[1] = *in; 555 pkt->shdr.hdr.size += sizeof(u32) * 2; 556 break; 557 } 558 case HFI_PROPERTY_CONFIG_VDEC_MB_ERROR_MAP_REPORTING: { 559 struct hfi_enable *in = pdata, *en = prop_data; 560 561 en->enable = in->enable; 562 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 563 break; 564 } 565 case HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER: { 566 struct hfi_enable *in = pdata, *en = prop_data; 567 568 en->enable = in->enable; 569 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 570 break; 571 } 572 case HFI_PROPERTY_PARAM_VDEC_THUMBNAIL_MODE: { 573 struct hfi_enable *in = pdata, *en = prop_data; 574 575 en->enable = in->enable; 576 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 577 break; 578 } 579 case HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER: { 580 struct hfi_enable *in = pdata, *en = prop_data; 581 582 en->enable = in->enable; 583 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 584 break; 585 } 586 case HFI_PROPERTY_CONFIG_VENC_REQUEST_SYNC_FRAME: 587 pkt->shdr.hdr.size += sizeof(u32); 588 break; 589 case HFI_PROPERTY_PARAM_VENC_MPEG4_SHORT_HEADER: 590 break; 591 case HFI_PROPERTY_PARAM_VENC_MPEG4_AC_PREDICTION: 592 break; 593 case HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE: { 594 struct hfi_bitrate *in = pdata, *brate = prop_data; 595 596 brate->bitrate = in->bitrate; 597 brate->layer_id = in->layer_id; 598 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*brate); 599 break; 600 } 601 case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE: { 602 struct hfi_bitrate *in = pdata, *hfi = prop_data; 603 604 hfi->bitrate = in->bitrate; 605 hfi->layer_id = in->layer_id; 606 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hfi); 607 break; 608 } 609 case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT: { 610 struct hfi_profile_level *in = pdata, *pl = prop_data; 611 612 pl->level = in->level; 613 pl->profile = in->profile; 614 if (pl->profile <= 0) 615 /* Profile not supported, falling back to high */ 616 pl->profile = HFI_H264_PROFILE_HIGH; 617 618 if (!pl->level) 619 /* Level not supported, falling back to 1 */ 620 pl->level = 1; 621 622 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*pl); 623 break; 624 } 625 case HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL: { 626 struct hfi_h264_entropy_control *in = pdata, *hfi = prop_data; 627 628 hfi->entropy_mode = in->entropy_mode; 629 if (hfi->entropy_mode == HFI_H264_ENTROPY_CABAC) 630 hfi->cabac_model = in->cabac_model; 631 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hfi); 632 break; 633 } 634 case HFI_PROPERTY_PARAM_VENC_RATE_CONTROL: { 635 u32 *in = pdata; 636 637 switch (*in) { 638 case HFI_RATE_CONTROL_OFF: 639 case HFI_RATE_CONTROL_CBR_CFR: 640 case HFI_RATE_CONTROL_CBR_VFR: 641 case HFI_RATE_CONTROL_VBR_CFR: 642 case HFI_RATE_CONTROL_VBR_VFR: 643 case HFI_RATE_CONTROL_CQ: 644 break; 645 default: 646 ret = -EINVAL; 647 break; 648 } 649 650 pkt->data[1] = *in; 651 pkt->shdr.hdr.size += sizeof(u32) * 2; 652 break; 653 } 654 case HFI_PROPERTY_PARAM_VENC_MPEG4_TIME_RESOLUTION: { 655 struct hfi_mpeg4_time_resolution *in = pdata, *res = prop_data; 656 657 res->time_increment_resolution = in->time_increment_resolution; 658 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*res); 659 break; 660 } 661 case HFI_PROPERTY_PARAM_VENC_MPEG4_HEADER_EXTENSION: { 662 struct hfi_mpeg4_header_extension *in = pdata, *ext = prop_data; 663 664 ext->header_extension = in->header_extension; 665 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ext); 666 break; 667 } 668 case HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL: { 669 struct hfi_h264_db_control *in = pdata, *db = prop_data; 670 671 switch (in->mode) { 672 case HFI_H264_DB_MODE_DISABLE: 673 case HFI_H264_DB_MODE_SKIP_SLICE_BOUNDARY: 674 case HFI_H264_DB_MODE_ALL_BOUNDARY: 675 break; 676 default: 677 ret = -EINVAL; 678 break; 679 } 680 681 db->mode = in->mode; 682 db->slice_alpha_offset = in->slice_alpha_offset; 683 db->slice_beta_offset = in->slice_beta_offset; 684 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*db); 685 break; 686 } 687 case HFI_PROPERTY_PARAM_VENC_SESSION_QP: { 688 struct hfi_quantization *in = pdata, *quant = prop_data; 689 690 quant->qp_i = in->qp_i; 691 quant->qp_p = in->qp_p; 692 quant->qp_b = in->qp_b; 693 quant->layer_id = in->layer_id; 694 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*quant); 695 break; 696 } 697 case HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE: { 698 struct hfi_quantization_range *in = pdata, *range = prop_data; 699 u32 min_qp, max_qp; 700 701 min_qp = in->min_qp; 702 max_qp = in->max_qp; 703 704 /* We'll be packing in the qp, so make sure we 705 * won't be losing data when masking 706 */ 707 if (min_qp > 0xff || max_qp > 0xff) { 708 ret = -ERANGE; 709 break; 710 } 711 712 /* When creating the packet, pack the qp value as 713 * 0xiippbb, where ii = qp range for I-frames, 714 * pp = qp range for P-frames, etc. 715 */ 716 range->min_qp = min_qp | min_qp << 8 | min_qp << 16; 717 range->max_qp = max_qp | max_qp << 8 | max_qp << 16; 718 range->layer_id = in->layer_id; 719 720 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*range); 721 break; 722 } 723 case HFI_PROPERTY_PARAM_VENC_VC1_PERF_CFG: { 724 struct hfi_vc1e_perf_cfg_type *in = pdata, *perf = prop_data; 725 726 memcpy(perf->search_range_x_subsampled, 727 in->search_range_x_subsampled, 728 sizeof(perf->search_range_x_subsampled)); 729 memcpy(perf->search_range_y_subsampled, 730 in->search_range_y_subsampled, 731 sizeof(perf->search_range_y_subsampled)); 732 733 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*perf); 734 break; 735 } 736 case HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES: { 737 struct hfi_max_num_b_frames *bframes = prop_data; 738 u32 *in = pdata; 739 740 bframes->max_num_b_frames = *in; 741 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*bframes); 742 break; 743 } 744 case HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD: { 745 struct hfi_intra_period *in = pdata, *intra = prop_data; 746 747 intra->pframes = in->pframes; 748 intra->bframes = in->bframes; 749 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*intra); 750 break; 751 } 752 case HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD: { 753 struct hfi_idr_period *in = pdata, *idr = prop_data; 754 755 idr->idr_period = in->idr_period; 756 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*idr); 757 break; 758 } 759 case HFI_PROPERTY_PARAM_VDEC_CONCEAL_COLOR: { 760 struct hfi_conceal_color *color = prop_data; 761 u32 *in = pdata; 762 763 color->conceal_color = *in & 0xff; 764 color->conceal_color |= ((*in >> 10) & 0xff) << 8; 765 color->conceal_color |= ((*in >> 20) & 0xff) << 16; 766 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*color); 767 break; 768 } 769 case HFI_PROPERTY_CONFIG_VPE_OPERATIONS: { 770 struct hfi_operations_type *in = pdata, *ops = prop_data; 771 772 switch (in->rotation) { 773 case HFI_ROTATE_NONE: 774 case HFI_ROTATE_90: 775 case HFI_ROTATE_180: 776 case HFI_ROTATE_270: 777 break; 778 default: 779 ret = -EINVAL; 780 break; 781 } 782 783 switch (in->flip) { 784 case HFI_FLIP_NONE: 785 case HFI_FLIP_HORIZONTAL: 786 case HFI_FLIP_VERTICAL: 787 break; 788 default: 789 ret = -EINVAL; 790 break; 791 } 792 793 ops->rotation = in->rotation; 794 ops->flip = in->flip; 795 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ops); 796 break; 797 } 798 case HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH: { 799 struct hfi_intra_refresh *in = pdata, *intra = prop_data; 800 801 switch (in->mode) { 802 case HFI_INTRA_REFRESH_NONE: 803 case HFI_INTRA_REFRESH_ADAPTIVE: 804 case HFI_INTRA_REFRESH_CYCLIC: 805 case HFI_INTRA_REFRESH_CYCLIC_ADAPTIVE: 806 case HFI_INTRA_REFRESH_RANDOM: 807 break; 808 default: 809 ret = -EINVAL; 810 break; 811 } 812 813 intra->mode = in->mode; 814 intra->air_mbs = in->air_mbs; 815 intra->air_ref = in->air_ref; 816 intra->cir_mbs = in->cir_mbs; 817 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*intra); 818 break; 819 } 820 case HFI_PROPERTY_PARAM_VENC_MULTI_SLICE_CONTROL: { 821 struct hfi_multi_slice_control *in = pdata, *multi = prop_data; 822 823 switch (in->multi_slice) { 824 case HFI_MULTI_SLICE_OFF: 825 case HFI_MULTI_SLICE_GOB: 826 case HFI_MULTI_SLICE_BY_MB_COUNT: 827 case HFI_MULTI_SLICE_BY_BYTE_COUNT: 828 break; 829 default: 830 ret = -EINVAL; 831 break; 832 } 833 834 multi->multi_slice = in->multi_slice; 835 multi->slice_size = in->slice_size; 836 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*multi); 837 break; 838 } 839 case HFI_PROPERTY_PARAM_VENC_SLICE_DELIVERY_MODE: { 840 struct hfi_enable *in = pdata, *en = prop_data; 841 842 en->enable = in->enable; 843 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 844 break; 845 } 846 case HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO: { 847 struct hfi_h264_vui_timing_info *in = pdata, *vui = prop_data; 848 849 vui->enable = in->enable; 850 vui->fixed_framerate = in->fixed_framerate; 851 vui->time_scale = in->time_scale; 852 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*vui); 853 break; 854 } 855 case HFI_PROPERTY_CONFIG_VPE_DEINTERLACE: { 856 struct hfi_enable *in = pdata, *en = prop_data; 857 858 en->enable = in->enable; 859 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 860 break; 861 } 862 case HFI_PROPERTY_PARAM_VENC_H264_GENERATE_AUDNAL: { 863 struct hfi_enable *in = pdata, *en = prop_data; 864 865 en->enable = in->enable; 866 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 867 break; 868 } 869 case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE: { 870 struct hfi_buffer_alloc_mode *in = pdata, *mode = prop_data; 871 872 mode->type = in->type; 873 mode->mode = in->mode; 874 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*mode); 875 break; 876 } 877 case HFI_PROPERTY_PARAM_VDEC_FRAME_ASSEMBLY: { 878 struct hfi_enable *in = pdata, *en = prop_data; 879 880 en->enable = in->enable; 881 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 882 break; 883 } 884 case HFI_PROPERTY_PARAM_VENC_H264_VUI_BITSTREAM_RESTRC: { 885 struct hfi_enable *in = pdata, *en = prop_data; 886 887 en->enable = in->enable; 888 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 889 break; 890 } 891 case HFI_PROPERTY_PARAM_VENC_PRESERVE_TEXT_QUALITY: { 892 struct hfi_enable *in = pdata, *en = prop_data; 893 894 en->enable = in->enable; 895 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 896 break; 897 } 898 case HFI_PROPERTY_PARAM_VDEC_SCS_THRESHOLD: { 899 struct hfi_scs_threshold *thres = prop_data; 900 u32 *in = pdata; 901 902 thres->threshold_value = *in; 903 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*thres); 904 break; 905 } 906 case HFI_PROPERTY_PARAM_MVC_BUFFER_LAYOUT: { 907 struct hfi_mvc_buffer_layout_descp_type *in = pdata; 908 struct hfi_mvc_buffer_layout_descp_type *mvc = prop_data; 909 910 switch (in->layout_type) { 911 case HFI_MVC_BUFFER_LAYOUT_TOP_BOTTOM: 912 case HFI_MVC_BUFFER_LAYOUT_SEQ: 913 break; 914 default: 915 ret = -EINVAL; 916 break; 917 } 918 919 mvc->layout_type = in->layout_type; 920 mvc->bright_view_first = in->bright_view_first; 921 mvc->ngap = in->ngap; 922 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*mvc); 923 break; 924 } 925 case HFI_PROPERTY_PARAM_VENC_LTRMODE: { 926 struct hfi_ltr_mode *in = pdata, *ltr = prop_data; 927 928 switch (in->ltr_mode) { 929 case HFI_LTR_MODE_DISABLE: 930 case HFI_LTR_MODE_MANUAL: 931 case HFI_LTR_MODE_PERIODIC: 932 break; 933 default: 934 ret = -EINVAL; 935 break; 936 } 937 938 ltr->ltr_mode = in->ltr_mode; 939 ltr->ltr_count = in->ltr_count; 940 ltr->trust_mode = in->trust_mode; 941 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ltr); 942 break; 943 } 944 case HFI_PROPERTY_CONFIG_VENC_USELTRFRAME: { 945 struct hfi_ltr_use *in = pdata, *ltr_use = prop_data; 946 947 ltr_use->frames = in->frames; 948 ltr_use->ref_ltr = in->ref_ltr; 949 ltr_use->use_constrnt = in->use_constrnt; 950 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ltr_use); 951 break; 952 } 953 case HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME: { 954 struct hfi_ltr_mark *in = pdata, *ltr_mark = prop_data; 955 956 ltr_mark->mark_frame = in->mark_frame; 957 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ltr_mark); 958 break; 959 } 960 case HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER: { 961 u32 *in = pdata; 962 963 pkt->data[1] = *in; 964 pkt->shdr.hdr.size += sizeof(u32) * 2; 965 break; 966 } 967 case HFI_PROPERTY_CONFIG_VENC_HIER_P_ENH_LAYER: { 968 u32 *in = pdata; 969 970 pkt->data[1] = *in; 971 pkt->shdr.hdr.size += sizeof(u32) * 2; 972 break; 973 } 974 case HFI_PROPERTY_PARAM_VENC_DISABLE_RC_TIMESTAMP: { 975 struct hfi_enable *in = pdata, *en = prop_data; 976 977 en->enable = in->enable; 978 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 979 break; 980 } 981 case HFI_PROPERTY_PARAM_VENC_INITIAL_QP: { 982 struct hfi_initial_quantization *in = pdata, *quant = prop_data; 983 984 quant->init_qp_enable = in->init_qp_enable; 985 quant->qp_i = in->qp_i; 986 quant->qp_p = in->qp_p; 987 quant->qp_b = in->qp_b; 988 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*quant); 989 break; 990 } 991 case HFI_PROPERTY_PARAM_VPE_COLOR_SPACE_CONVERSION: { 992 struct hfi_vpe_color_space_conversion *in = pdata; 993 struct hfi_vpe_color_space_conversion *csc = prop_data; 994 995 memcpy(csc->csc_matrix, in->csc_matrix, 996 sizeof(csc->csc_matrix)); 997 memcpy(csc->csc_bias, in->csc_bias, sizeof(csc->csc_bias)); 998 memcpy(csc->csc_limit, in->csc_limit, sizeof(csc->csc_limit)); 999 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*csc); 1000 break; 1001 } 1002 case HFI_PROPERTY_PARAM_VENC_VPX_ERROR_RESILIENCE_MODE: { 1003 struct hfi_enable *in = pdata, *en = prop_data; 1004 1005 en->enable = in->enable; 1006 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 1007 break; 1008 } 1009 case HFI_PROPERTY_PARAM_VENC_H264_NAL_SVC_EXT: { 1010 struct hfi_enable *in = pdata, *en = prop_data; 1011 1012 en->enable = in->enable; 1013 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 1014 break; 1015 } 1016 case HFI_PROPERTY_CONFIG_VENC_PERF_MODE: { 1017 u32 *in = pdata; 1018 1019 pkt->data[1] = *in; 1020 pkt->shdr.hdr.size += sizeof(u32) * 2; 1021 break; 1022 } 1023 case HFI_PROPERTY_PARAM_VENC_HIER_B_MAX_NUM_ENH_LAYER: { 1024 u32 *in = pdata; 1025 1026 pkt->data[1] = *in; 1027 pkt->shdr.hdr.size += sizeof(u32) * 2; 1028 break; 1029 } 1030 case HFI_PROPERTY_PARAM_VDEC_NONCP_OUTPUT2: { 1031 struct hfi_enable *in = pdata, *en = prop_data; 1032 1033 en->enable = in->enable; 1034 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en); 1035 break; 1036 } 1037 case HFI_PROPERTY_PARAM_VENC_HIER_P_HYBRID_MODE: { 1038 struct hfi_hybrid_hierp *in = pdata, *hierp = prop_data; 1039 1040 hierp->layers = in->layers; 1041 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hierp); 1042 break; 1043 } 1044 case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: { 1045 struct hfi_uncompressed_plane_actual_info *in = pdata; 1046 struct hfi_uncompressed_plane_actual_info *info = prop_data; 1047 1048 info->buffer_type = in->buffer_type; 1049 info->num_planes = in->num_planes; 1050 info->plane_format[0] = in->plane_format[0]; 1051 if (in->num_planes > 1) 1052 info->plane_format[1] = in->plane_format[1]; 1053 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*info); 1054 break; 1055 } 1056 1057 /* FOLLOWING PROPERTIES ARE NOT IMPLEMENTED IN CORE YET */ 1058 case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS: 1059 case HFI_PROPERTY_CONFIG_PRIORITY: 1060 case HFI_PROPERTY_CONFIG_BATCH_INFO: 1061 case HFI_PROPERTY_SYS_IDLE_INDICATOR: 1062 case HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED: 1063 case HFI_PROPERTY_PARAM_INTERLACE_FORMAT_SUPPORTED: 1064 case HFI_PROPERTY_PARAM_CHROMA_SITE: 1065 case HFI_PROPERTY_PARAM_PROPERTIES_SUPPORTED: 1066 case HFI_PROPERTY_PARAM_PROFILE_LEVEL_SUPPORTED: 1067 case HFI_PROPERTY_PARAM_CAPABILITY_SUPPORTED: 1068 case HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SUPPORTED: 1069 case HFI_PROPERTY_PARAM_MULTI_VIEW_FORMAT: 1070 case HFI_PROPERTY_PARAM_MAX_SEQUENCE_HEADER_SIZE: 1071 case HFI_PROPERTY_PARAM_CODEC_SUPPORTED: 1072 case HFI_PROPERTY_PARAM_VDEC_MULTI_VIEW_SELECT: 1073 case HFI_PROPERTY_PARAM_VDEC_MB_QUANTIZATION: 1074 case HFI_PROPERTY_PARAM_VDEC_NUM_CONCEALED_MB: 1075 case HFI_PROPERTY_PARAM_VDEC_H264_ENTROPY_SWITCHING: 1076 case HFI_PROPERTY_PARAM_VENC_MULTI_SLICE_INFO: 1077 default: 1078 return -EINVAL; 1079 } 1080 1081 return ret; 1082 } 1083 1084 static int 1085 pkt_session_get_property_3xx(struct hfi_session_get_property_pkt *pkt, 1086 void *cookie, u32 ptype) 1087 { 1088 int ret = 0; 1089 1090 if (!pkt || !cookie) 1091 return -EINVAL; 1092 1093 pkt->shdr.hdr.size = sizeof(struct hfi_session_get_property_pkt); 1094 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_GET_PROPERTY; 1095 pkt->shdr.session_id = hash32_ptr(cookie); 1096 pkt->num_properties = 1; 1097 1098 switch (ptype) { 1099 case HFI_PROPERTY_CONFIG_VDEC_ENTROPY: 1100 pkt->data[0] = HFI_PROPERTY_CONFIG_VDEC_ENTROPY; 1101 break; 1102 default: 1103 ret = pkt_session_get_property_1x(pkt, cookie, ptype); 1104 break; 1105 } 1106 1107 return ret; 1108 } 1109 1110 static int 1111 pkt_session_set_property_3xx(struct hfi_session_set_property_pkt *pkt, 1112 void *cookie, u32 ptype, void *pdata) 1113 { 1114 void *prop_data; 1115 int ret = 0; 1116 1117 if (!pkt || !cookie || !pdata) 1118 return -EINVAL; 1119 1120 prop_data = &pkt->data[1]; 1121 1122 pkt->shdr.hdr.size = sizeof(*pkt); 1123 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; 1124 pkt->shdr.session_id = hash32_ptr(cookie); 1125 pkt->num_properties = 1; 1126 pkt->data[0] = ptype; 1127 1128 /* 1129 * Any session set property which is different in 3XX packetization 1130 * should be added as a new case below. All unchanged session set 1131 * properties will be handled in the default case. 1132 */ 1133 switch (ptype) { 1134 case HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM: { 1135 struct hfi_multi_stream *in = pdata; 1136 struct hfi_multi_stream_3x *multi = prop_data; 1137 1138 multi->buffer_type = in->buffer_type; 1139 multi->enable = in->enable; 1140 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*multi); 1141 break; 1142 } 1143 case HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH: { 1144 struct hfi_intra_refresh *in = pdata; 1145 struct hfi_intra_refresh_3x *intra = prop_data; 1146 1147 switch (in->mode) { 1148 case HFI_INTRA_REFRESH_NONE: 1149 case HFI_INTRA_REFRESH_ADAPTIVE: 1150 case HFI_INTRA_REFRESH_CYCLIC: 1151 case HFI_INTRA_REFRESH_CYCLIC_ADAPTIVE: 1152 case HFI_INTRA_REFRESH_RANDOM: 1153 break; 1154 default: 1155 ret = -EINVAL; 1156 break; 1157 } 1158 1159 intra->mode = in->mode; 1160 intra->mbs = in->cir_mbs; 1161 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*intra); 1162 break; 1163 } 1164 case HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER: 1165 /* for 3xx fw version session_continue is used */ 1166 break; 1167 default: 1168 ret = pkt_session_set_property_1x(pkt, cookie, ptype, pdata); 1169 break; 1170 } 1171 1172 return ret; 1173 } 1174 1175 static int 1176 pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt, 1177 void *cookie, u32 ptype, void *pdata) 1178 { 1179 void *prop_data; 1180 1181 if (!pkt || !cookie || !pdata) 1182 return -EINVAL; 1183 1184 prop_data = &pkt->data[1]; 1185 1186 pkt->shdr.hdr.size = sizeof(*pkt); 1187 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; 1188 pkt->shdr.session_id = hash32_ptr(cookie); 1189 pkt->num_properties = 1; 1190 pkt->data[0] = ptype; 1191 1192 /* 1193 * Any session set property which is different in 3XX packetization 1194 * should be added as a new case below. All unchanged session set 1195 * properties will be handled in the default case. 1196 */ 1197 switch (ptype) { 1198 case HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL: { 1199 struct hfi_buffer_count_actual *in = pdata; 1200 struct hfi_buffer_count_actual_4xx *count = prop_data; 1201 1202 count->count_actual = in->count_actual; 1203 count->type = in->type; 1204 count->count_min_host = in->count_actual; 1205 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count); 1206 break; 1207 } 1208 case HFI_PROPERTY_PARAM_WORK_MODE: { 1209 struct hfi_video_work_mode *in = pdata, *wm = prop_data; 1210 1211 wm->video_work_mode = in->video_work_mode; 1212 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*wm); 1213 break; 1214 } 1215 case HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE: { 1216 struct hfi_videocores_usage_type *in = pdata, *cu = prop_data; 1217 1218 cu->video_core_enable_mask = in->video_core_enable_mask; 1219 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cu); 1220 break; 1221 } 1222 case HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI: { 1223 struct hfi_hdr10_pq_sei *in = pdata, *hdr10 = prop_data; 1224 1225 memcpy(hdr10, in, sizeof(*hdr10)); 1226 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hdr10); 1227 break; 1228 } 1229 1230 case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE: 1231 case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER: 1232 case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE: 1233 case HFI_PROPERTY_PARAM_VENC_SESSION_QP: 1234 case HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE: 1235 /* not implemented on Venus 4xx */ 1236 return -ENOTSUPP; 1237 default: 1238 return pkt_session_set_property_3xx(pkt, cookie, ptype, pdata); 1239 } 1240 1241 return 0; 1242 } 1243 1244 static int 1245 pkt_session_set_property_6xx(struct hfi_session_set_property_pkt *pkt, 1246 void *cookie, u32 ptype, void *pdata) 1247 { 1248 void *prop_data; 1249 1250 if (!pkt || !cookie || !pdata) 1251 return -EINVAL; 1252 1253 prop_data = &pkt->data[1]; 1254 1255 pkt->shdr.hdr.size = sizeof(*pkt); 1256 pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; 1257 pkt->shdr.session_id = hash32_ptr(cookie); 1258 pkt->num_properties = 1; 1259 pkt->data[0] = ptype; 1260 1261 switch (ptype) { 1262 case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO: { 1263 struct hfi_uncompressed_plane_actual_constraints_info *in = pdata; 1264 struct hfi_uncompressed_plane_actual_constraints_info *info = prop_data; 1265 1266 info->buffer_type = in->buffer_type; 1267 info->num_planes = in->num_planes; 1268 info->plane_format[0] = in->plane_format[0]; 1269 if (in->num_planes > 1) 1270 info->plane_format[1] = in->plane_format[1]; 1271 1272 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*info); 1273 break; 1274 } 1275 case HFI_PROPERTY_CONFIG_HEIC_FRAME_QUALITY: { 1276 struct hfi_heic_frame_quality *in = pdata, *cq = prop_data; 1277 1278 cq->frame_quality = in->frame_quality; 1279 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cq); 1280 break; 1281 } 1282 case HFI_PROPERTY_PARAM_VDEC_CONCEAL_COLOR: { 1283 struct hfi_conceal_color_v4 *color = prop_data; 1284 u32 *in = pdata; 1285 1286 color->conceal_color_8bit = *in & 0xff; 1287 color->conceal_color_8bit |= ((*in >> 10) & 0xff) << 8; 1288 color->conceal_color_8bit |= ((*in >> 20) & 0xff) << 16; 1289 color->conceal_color_10bit = *in; 1290 pkt->shdr.hdr.size += sizeof(u32) + sizeof(*color); 1291 break; 1292 } 1293 default: 1294 return pkt_session_set_property_4xx(pkt, cookie, ptype, pdata); 1295 } 1296 1297 return 0; 1298 } 1299 1300 int pkt_session_get_property(struct hfi_session_get_property_pkt *pkt, 1301 void *cookie, u32 ptype) 1302 { 1303 if (hfi_ver == HFI_VERSION_1XX) 1304 return pkt_session_get_property_1x(pkt, cookie, ptype); 1305 1306 return pkt_session_get_property_3xx(pkt, cookie, ptype); 1307 } 1308 1309 int pkt_session_set_property(struct hfi_session_set_property_pkt *pkt, 1310 void *cookie, u32 ptype, void *pdata) 1311 { 1312 if (hfi_ver == HFI_VERSION_1XX) 1313 return pkt_session_set_property_1x(pkt, cookie, ptype, pdata); 1314 1315 if (hfi_ver == HFI_VERSION_3XX) 1316 return pkt_session_set_property_3xx(pkt, cookie, ptype, pdata); 1317 1318 if (hfi_ver == HFI_VERSION_4XX) 1319 return pkt_session_set_property_4xx(pkt, cookie, ptype, pdata); 1320 1321 return pkt_session_set_property_6xx(pkt, cookie, ptype, pdata); 1322 } 1323 1324 void pkt_set_version(enum hfi_version version) 1325 { 1326 hfi_ver = version; 1327 } 1328