Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: iris: Set platform capabilities to firmware for encoder video device

Initialize and configure platform-specific capabilities for the encoder
in the firmware during stream-on, to tailor encoding behavior to the
current session's requirements. Some of these capabilities can also be
updated dynamically when V4L2 controls are modified by the client after
stream-on.

Tested-by: Vikash Garodia <quic_vgarodia@quicinc.com> # X1E80100
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-HDK
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # x1e80100-crd
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Dikshita Agarwal and committed by
Hans Verkuil
d22037f3 92e007ca

+737 -30
+8
drivers/media/platform/qcom/iris/iris_buffer.c
··· 227 227 static u32 iris_enc_bitstream_buffer_size(struct iris_inst *inst) 228 228 { 229 229 u32 aligned_width, aligned_height, bitstream_size, yuv_size; 230 + int bitrate_mode, frame_rc; 230 231 struct v4l2_format *f; 231 232 232 233 f = inst->fmt_dst; 234 + 235 + bitrate_mode = inst->fw_caps[BITRATE_MODE].value; 236 + frame_rc = inst->fw_caps[FRAME_RC_ENABLE].value; 233 237 234 238 aligned_width = ALIGN(f->fmt.pix_mp.width, 32); 235 239 aligned_height = ALIGN(f->fmt.pix_mp.height, 32); ··· 245 241 else if (aligned_width * aligned_height > (1280 * 720)) 246 242 /* bitstream_size = 0.5 * yuv_size; */ 247 243 bitstream_size = (bitstream_size >> 2); 244 + 245 + if ((!frame_rc || bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) && 246 + bitstream_size < yuv_size) 247 + bitstream_size = (bitstream_size << 1); 248 248 249 249 return ALIGN(bitstream_size, 4096); 250 250 }
+492 -8
drivers/media/platform/qcom/iris/iris_ctrls.c
··· 7 7 #include <media/v4l2-mem2mem.h> 8 8 9 9 #include "iris_ctrls.h" 10 + #include "iris_hfi_gen1_defines.h" 11 + #include "iris_hfi_gen2_defines.h" 10 12 #include "iris_instance.h" 13 + 14 + #define CABAC_MAX_BITRATE 160000000 15 + #define CAVLC_MAX_BITRATE 220000000 11 16 12 17 static inline bool iris_valid_cap_id(enum platform_inst_fw_cap_type cap_id) 13 18 { ··· 190 185 } 191 186 } 192 187 193 - static int iris_vdec_op_s_ctrl(struct v4l2_ctrl *ctrl) 188 + static int iris_op_s_ctrl(struct v4l2_ctrl *ctrl) 194 189 { 195 190 struct iris_inst *inst = container_of(ctrl->handler, struct iris_inst, ctrl_handler); 196 191 enum platform_inst_fw_cap_type cap_id; ··· 211 206 212 207 inst->fw_caps[cap_id].value = ctrl->val; 213 208 209 + if (vb2_is_streaming(q)) { 210 + if (cap[cap_id].set) 211 + cap[cap_id].set(inst, cap_id); 212 + } 213 + 214 214 return 0; 215 215 } 216 216 217 217 static const struct v4l2_ctrl_ops iris_ctrl_ops = { 218 - .s_ctrl = iris_vdec_op_s_ctrl, 218 + .s_ctrl = iris_op_s_ctrl, 219 219 }; 220 220 221 221 int iris_ctrls_init(struct iris_inst *inst) ··· 337 327 core->inst_fw_caps_enc[cap_id].value = caps[i].value; 338 328 core->inst_fw_caps_enc[cap_id].flags = caps[i].flags; 339 329 core->inst_fw_caps_enc[cap_id].hfi_id = caps[i].hfi_id; 330 + core->inst_fw_caps_enc[cap_id].set = caps[i].set; 340 331 } 341 332 } 342 333 343 334 static u32 iris_get_port_info(struct iris_inst *inst, 344 335 enum platform_inst_fw_cap_type cap_id) 345 336 { 346 - if (inst->fw_caps[cap_id].flags & CAP_FLAG_INPUT_PORT) 347 - return HFI_PORT_BITSTREAM; 348 - else if (inst->fw_caps[cap_id].flags & CAP_FLAG_OUTPUT_PORT) 349 - return HFI_PORT_RAW; 337 + if (inst->domain == DECODER) { 338 + if (inst->fw_caps[cap_id].flags & CAP_FLAG_INPUT_PORT) 339 + return HFI_PORT_BITSTREAM; 340 + else if (inst->fw_caps[cap_id].flags & CAP_FLAG_OUTPUT_PORT) 341 + return HFI_PORT_RAW; 342 + } else { 343 + if (inst->fw_caps[cap_id].flags & CAP_FLAG_INPUT_PORT) 344 + return HFI_PORT_RAW; 345 + else if (inst->fw_caps[cap_id].flags & CAP_FLAG_OUTPUT_PORT) 346 + return HFI_PORT_BITSTREAM; 347 + } 350 348 351 349 return HFI_PORT_NONE; 352 350 } ··· 394 376 u32 width = inp_f->fmt.pix_mp.width; 395 377 u32 work_mode = STAGE_2; 396 378 397 - if (iris_res_is_less_than(width, height, 1280, 720)) 398 - work_mode = STAGE_1; 379 + if (inst->domain == DECODER) { 380 + if (iris_res_is_less_than(width, height, 1280, 720)) 381 + work_mode = STAGE_1; 382 + } 399 383 400 384 return hfi_ops->session_set_property(inst, hfi_id, 401 385 HFI_HOST_FLAGS_NONE, ··· 417 397 iris_get_port_info(inst, cap_id), 418 398 HFI_PAYLOAD_U32, 419 399 &work_route, sizeof(u32)); 400 + } 401 + 402 + int iris_set_profile(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 403 + { 404 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 405 + u32 hfi_id, hfi_value; 406 + 407 + if (inst->codec == V4L2_PIX_FMT_H264) { 408 + hfi_id = inst->fw_caps[PROFILE_H264].hfi_id; 409 + hfi_value = inst->fw_caps[PROFILE_H264].value; 410 + } else { 411 + hfi_id = inst->fw_caps[PROFILE_HEVC].hfi_id; 412 + hfi_value = inst->fw_caps[PROFILE_HEVC].value; 413 + } 414 + 415 + return hfi_ops->session_set_property(inst, hfi_id, 416 + HFI_HOST_FLAGS_NONE, 417 + iris_get_port_info(inst, cap_id), 418 + HFI_PAYLOAD_U32_ENUM, 419 + &hfi_value, sizeof(u32)); 420 + } 421 + 422 + int iris_set_level(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 423 + { 424 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 425 + u32 hfi_id, hfi_value; 426 + 427 + if (inst->codec == V4L2_PIX_FMT_H264) { 428 + hfi_id = inst->fw_caps[LEVEL_H264].hfi_id; 429 + hfi_value = inst->fw_caps[LEVEL_H264].value; 430 + } else { 431 + hfi_id = inst->fw_caps[LEVEL_HEVC].hfi_id; 432 + hfi_value = inst->fw_caps[LEVEL_HEVC].value; 433 + } 434 + 435 + return hfi_ops->session_set_property(inst, hfi_id, 436 + HFI_HOST_FLAGS_NONE, 437 + iris_get_port_info(inst, cap_id), 438 + HFI_PAYLOAD_U32_ENUM, 439 + &hfi_value, sizeof(u32)); 440 + } 441 + 442 + int iris_set_profile_level_gen1(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 443 + { 444 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 445 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 446 + struct hfi_profile_level pl; 447 + 448 + if (inst->codec == V4L2_PIX_FMT_H264) { 449 + pl.profile = inst->fw_caps[PROFILE_H264].value; 450 + pl.level = inst->fw_caps[LEVEL_H264].value; 451 + } else { 452 + pl.profile = inst->fw_caps[PROFILE_HEVC].value; 453 + pl.level = inst->fw_caps[LEVEL_HEVC].value; 454 + } 455 + 456 + return hfi_ops->session_set_property(inst, hfi_id, 457 + HFI_HOST_FLAGS_NONE, 458 + iris_get_port_info(inst, cap_id), 459 + HFI_PAYLOAD_U32_ENUM, 460 + &pl, sizeof(u32)); 461 + } 462 + 463 + int iris_set_header_mode_gen1(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 464 + { 465 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 466 + u32 header_mode = inst->fw_caps[cap_id].value; 467 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 468 + u32 hfi_val; 469 + 470 + if (header_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) 471 + hfi_val = 0; 472 + else 473 + hfi_val = 1; 474 + 475 + return hfi_ops->session_set_property(inst, hfi_id, 476 + HFI_HOST_FLAGS_NONE, 477 + iris_get_port_info(inst, cap_id), 478 + HFI_PAYLOAD_U32, 479 + &hfi_val, sizeof(u32)); 480 + } 481 + 482 + int iris_set_header_mode_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 483 + { 484 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 485 + u32 prepend_sps_pps = inst->fw_caps[PREPEND_SPSPPS_TO_IDR].value; 486 + u32 header_mode = inst->fw_caps[cap_id].value; 487 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 488 + u32 hfi_val; 489 + 490 + if (prepend_sps_pps) 491 + hfi_val = HFI_SEQ_HEADER_PREFIX_WITH_SYNC_FRAME; 492 + else if (header_mode == V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME) 493 + hfi_val = HFI_SEQ_HEADER_JOINED_WITH_1ST_FRAME; 494 + else 495 + hfi_val = HFI_SEQ_HEADER_SEPERATE_FRAME; 496 + 497 + return hfi_ops->session_set_property(inst, hfi_id, 498 + HFI_HOST_FLAGS_NONE, 499 + iris_get_port_info(inst, cap_id), 500 + HFI_PAYLOAD_U32_ENUM, 501 + &hfi_val, sizeof(u32)); 502 + } 503 + 504 + int iris_set_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 505 + { 506 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 507 + u32 entropy_mode = inst->fw_caps[ENTROPY_MODE].value; 508 + u32 bitrate = inst->fw_caps[cap_id].value; 509 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 510 + u32 max_bitrate; 511 + 512 + if (inst->codec == V4L2_PIX_FMT_HEVC) 513 + max_bitrate = CABAC_MAX_BITRATE; 514 + 515 + if (entropy_mode == V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC) 516 + max_bitrate = CABAC_MAX_BITRATE; 517 + else 518 + max_bitrate = CAVLC_MAX_BITRATE; 519 + 520 + bitrate = min(bitrate, max_bitrate); 521 + 522 + return hfi_ops->session_set_property(inst, hfi_id, 523 + HFI_HOST_FLAGS_NONE, 524 + iris_get_port_info(inst, cap_id), 525 + HFI_PAYLOAD_U32, 526 + &bitrate, sizeof(u32)); 527 + } 528 + 529 + int iris_set_peak_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 530 + { 531 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 532 + u32 rc_mode = inst->fw_caps[BITRATE_MODE].value; 533 + u32 peak_bitrate = inst->fw_caps[cap_id].value; 534 + u32 bitrate = inst->fw_caps[BITRATE].value; 535 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 536 + 537 + if (rc_mode != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) 538 + return 0; 539 + 540 + if (inst->fw_caps[cap_id].flags & CAP_FLAG_CLIENT_SET) { 541 + if (peak_bitrate < bitrate) 542 + peak_bitrate = bitrate; 543 + } else { 544 + peak_bitrate = bitrate; 545 + } 546 + 547 + inst->fw_caps[cap_id].value = peak_bitrate; 548 + 549 + return hfi_ops->session_set_property(inst, hfi_id, 550 + HFI_HOST_FLAGS_NONE, 551 + iris_get_port_info(inst, cap_id), 552 + HFI_PAYLOAD_U32, 553 + &peak_bitrate, sizeof(u32)); 554 + } 555 + 556 + int iris_set_bitrate_mode_gen1(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 557 + { 558 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 559 + u32 bitrate_mode = inst->fw_caps[BITRATE_MODE].value; 560 + u32 frame_rc = inst->fw_caps[FRAME_RC_ENABLE].value; 561 + u32 frame_skip = inst->fw_caps[FRAME_SKIP_MODE].value; 562 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 563 + u32 rc_mode = 0; 564 + 565 + if (!frame_rc) 566 + rc_mode = HFI_RATE_CONTROL_OFF; 567 + else if (bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) 568 + rc_mode = frame_skip ? HFI_RATE_CONTROL_VBR_VFR : HFI_RATE_CONTROL_VBR_CFR; 569 + else if (bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) 570 + rc_mode = frame_skip ? HFI_RATE_CONTROL_CBR_VFR : HFI_RATE_CONTROL_CBR_CFR; 571 + else if (bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) 572 + rc_mode = HFI_RATE_CONTROL_CQ; 573 + 574 + inst->hfi_rc_type = rc_mode; 575 + 576 + return hfi_ops->session_set_property(inst, hfi_id, 577 + HFI_HOST_FLAGS_NONE, 578 + iris_get_port_info(inst, cap_id), 579 + HFI_PAYLOAD_U32_ENUM, 580 + &rc_mode, sizeof(u32)); 581 + } 582 + 583 + int iris_set_bitrate_mode_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 584 + { 585 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 586 + u32 bitrate_mode = inst->fw_caps[BITRATE_MODE].value; 587 + u32 frame_rc = inst->fw_caps[FRAME_RC_ENABLE].value; 588 + u32 frame_skip = inst->fw_caps[FRAME_SKIP_MODE].value; 589 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 590 + u32 rc_mode = 0; 591 + 592 + if (!frame_rc) 593 + rc_mode = HFI_RC_OFF; 594 + else if (bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) 595 + rc_mode = HFI_RC_VBR_CFR; 596 + else if (bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) 597 + rc_mode = frame_skip ? HFI_RC_CBR_VFR : HFI_RC_CBR_CFR; 598 + else if (bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) 599 + rc_mode = HFI_RC_CQ; 600 + 601 + inst->hfi_rc_type = rc_mode; 602 + 603 + return hfi_ops->session_set_property(inst, hfi_id, 604 + HFI_HOST_FLAGS_NONE, 605 + iris_get_port_info(inst, cap_id), 606 + HFI_PAYLOAD_U32_ENUM, 607 + &rc_mode, sizeof(u32)); 608 + } 609 + 610 + int iris_set_entropy_mode_gen1(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 611 + { 612 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 613 + u32 entropy_mode = inst->fw_caps[cap_id].value; 614 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 615 + u32 hfi_val; 616 + 617 + if (inst->codec != V4L2_PIX_FMT_H264) 618 + return 0; 619 + 620 + hfi_val = (entropy_mode == V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC) ? 621 + HFI_H264_ENTROPY_CAVLC : HFI_H264_ENTROPY_CABAC; 622 + 623 + return hfi_ops->session_set_property(inst, hfi_id, 624 + HFI_HOST_FLAGS_NONE, 625 + iris_get_port_info(inst, cap_id), 626 + HFI_PAYLOAD_U32, 627 + &hfi_val, sizeof(u32)); 628 + } 629 + 630 + int iris_set_entropy_mode_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 631 + { 632 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 633 + u32 entropy_mode = inst->fw_caps[cap_id].value; 634 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 635 + u32 profile; 636 + 637 + if (inst->codec != V4L2_PIX_FMT_H264) 638 + return 0; 639 + 640 + profile = inst->fw_caps[PROFILE_H264].value; 641 + 642 + if (profile == V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE || 643 + profile == V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE) 644 + entropy_mode = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC; 645 + 646 + inst->fw_caps[cap_id].value = entropy_mode; 647 + 648 + return hfi_ops->session_set_property(inst, hfi_id, 649 + HFI_HOST_FLAGS_NONE, 650 + iris_get_port_info(inst, cap_id), 651 + HFI_PAYLOAD_U32, 652 + &entropy_mode, sizeof(u32)); 653 + } 654 + 655 + int iris_set_min_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 656 + { 657 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 658 + u32 i_qp_enable = 0, p_qp_enable = 0, b_qp_enable = 0; 659 + u32 i_frame_qp = 0, p_frame_qp = 0, b_frame_qp = 0; 660 + u32 min_qp_enable = 0, client_qp_enable = 0; 661 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 662 + u32 hfi_val; 663 + 664 + if (inst->codec == V4L2_PIX_FMT_H264) { 665 + if (inst->fw_caps[MIN_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) 666 + min_qp_enable = 1; 667 + if (min_qp_enable || 668 + (inst->fw_caps[I_FRAME_MIN_QP_H264].flags & CAP_FLAG_CLIENT_SET)) 669 + i_qp_enable = 1; 670 + if (min_qp_enable || 671 + (inst->fw_caps[P_FRAME_MIN_QP_H264].flags & CAP_FLAG_CLIENT_SET)) 672 + p_qp_enable = 1; 673 + if (min_qp_enable || 674 + (inst->fw_caps[B_FRAME_MIN_QP_H264].flags & CAP_FLAG_CLIENT_SET)) 675 + b_qp_enable = 1; 676 + } else { 677 + if (inst->fw_caps[MIN_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) 678 + min_qp_enable = 1; 679 + if (min_qp_enable || 680 + (inst->fw_caps[I_FRAME_MIN_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) 681 + i_qp_enable = 1; 682 + if (min_qp_enable || 683 + (inst->fw_caps[P_FRAME_MIN_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) 684 + p_qp_enable = 1; 685 + if (min_qp_enable || 686 + (inst->fw_caps[B_FRAME_MIN_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) 687 + b_qp_enable = 1; 688 + } 689 + 690 + client_qp_enable = i_qp_enable | p_qp_enable << 1 | b_qp_enable << 2; 691 + if (!client_qp_enable) 692 + return 0; 693 + 694 + if (inst->codec == V4L2_PIX_FMT_H264) { 695 + i_frame_qp = max(inst->fw_caps[I_FRAME_MIN_QP_H264].value, 696 + inst->fw_caps[MIN_FRAME_QP_H264].value); 697 + p_frame_qp = max(inst->fw_caps[P_FRAME_MIN_QP_H264].value, 698 + inst->fw_caps[MIN_FRAME_QP_H264].value); 699 + b_frame_qp = max(inst->fw_caps[B_FRAME_MIN_QP_H264].value, 700 + inst->fw_caps[MIN_FRAME_QP_H264].value); 701 + } else { 702 + i_frame_qp = max(inst->fw_caps[I_FRAME_MIN_QP_HEVC].value, 703 + inst->fw_caps[MIN_FRAME_QP_HEVC].value); 704 + p_frame_qp = max(inst->fw_caps[P_FRAME_MIN_QP_HEVC].value, 705 + inst->fw_caps[MIN_FRAME_QP_HEVC].value); 706 + b_frame_qp = max(inst->fw_caps[B_FRAME_MIN_QP_HEVC].value, 707 + inst->fw_caps[MIN_FRAME_QP_HEVC].value); 708 + } 709 + 710 + hfi_val = i_frame_qp | p_frame_qp << 8 | b_frame_qp << 16 | client_qp_enable << 24; 711 + 712 + return hfi_ops->session_set_property(inst, hfi_id, 713 + HFI_HOST_FLAGS_NONE, 714 + iris_get_port_info(inst, cap_id), 715 + HFI_PAYLOAD_32_PACKED, 716 + &hfi_val, sizeof(u32)); 717 + } 718 + 719 + int iris_set_max_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 720 + { 721 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 722 + u32 i_qp_enable = 0, p_qp_enable = 0, b_qp_enable = 0; 723 + u32 max_qp_enable = 0, client_qp_enable; 724 + u32 i_frame_qp, p_frame_qp, b_frame_qp; 725 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 726 + u32 hfi_val; 727 + 728 + if (inst->codec == V4L2_PIX_FMT_H264) { 729 + if (inst->fw_caps[MAX_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) 730 + max_qp_enable = 1; 731 + if (max_qp_enable || 732 + (inst->fw_caps[I_FRAME_MAX_QP_H264].flags & CAP_FLAG_CLIENT_SET)) 733 + i_qp_enable = 1; 734 + if (max_qp_enable || 735 + (inst->fw_caps[P_FRAME_MAX_QP_H264].flags & CAP_FLAG_CLIENT_SET)) 736 + p_qp_enable = 1; 737 + if (max_qp_enable || 738 + (inst->fw_caps[B_FRAME_MAX_QP_H264].flags & CAP_FLAG_CLIENT_SET)) 739 + b_qp_enable = 1; 740 + } else { 741 + if (inst->fw_caps[MAX_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) 742 + max_qp_enable = 1; 743 + if (max_qp_enable || 744 + (inst->fw_caps[I_FRAME_MAX_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) 745 + i_qp_enable = 1; 746 + if (max_qp_enable || 747 + (inst->fw_caps[P_FRAME_MAX_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) 748 + p_qp_enable = 1; 749 + if (max_qp_enable || 750 + (inst->fw_caps[B_FRAME_MAX_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) 751 + b_qp_enable = 1; 752 + } 753 + 754 + client_qp_enable = i_qp_enable | p_qp_enable << 1 | b_qp_enable << 2; 755 + if (!client_qp_enable) 756 + return 0; 757 + 758 + if (inst->codec == V4L2_PIX_FMT_H264) { 759 + i_frame_qp = min(inst->fw_caps[I_FRAME_MAX_QP_H264].value, 760 + inst->fw_caps[MAX_FRAME_QP_H264].value); 761 + p_frame_qp = min(inst->fw_caps[P_FRAME_MAX_QP_H264].value, 762 + inst->fw_caps[MAX_FRAME_QP_H264].value); 763 + b_frame_qp = min(inst->fw_caps[B_FRAME_MAX_QP_H264].value, 764 + inst->fw_caps[MAX_FRAME_QP_H264].value); 765 + } else { 766 + i_frame_qp = min(inst->fw_caps[I_FRAME_MAX_QP_HEVC].value, 767 + inst->fw_caps[MAX_FRAME_QP_HEVC].value); 768 + p_frame_qp = min(inst->fw_caps[P_FRAME_MAX_QP_HEVC].value, 769 + inst->fw_caps[MAX_FRAME_QP_HEVC].value); 770 + b_frame_qp = min(inst->fw_caps[B_FRAME_MAX_QP_HEVC].value, 771 + inst->fw_caps[MAX_FRAME_QP_HEVC].value); 772 + } 773 + 774 + hfi_val = i_frame_qp | p_frame_qp << 8 | b_frame_qp << 16 | 775 + client_qp_enable << 24; 776 + 777 + return hfi_ops->session_set_property(inst, hfi_id, 778 + HFI_HOST_FLAGS_NONE, 779 + iris_get_port_info(inst, cap_id), 780 + HFI_PAYLOAD_32_PACKED, 781 + &hfi_val, sizeof(u32)); 782 + } 783 + 784 + int iris_set_frame_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 785 + { 786 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 787 + u32 i_qp_enable = 0, p_qp_enable = 0, b_qp_enable = 0, client_qp_enable; 788 + u32 i_frame_qp, p_frame_qp, b_frame_qp; 789 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 790 + struct vb2_queue *q; 791 + u32 hfi_val; 792 + 793 + q = v4l2_m2m_get_dst_vq(inst->m2m_ctx); 794 + if (vb2_is_streaming(q)) { 795 + if (inst->hfi_rc_type != HFI_RC_OFF) 796 + return 0; 797 + } 798 + 799 + if (inst->hfi_rc_type == HFI_RC_OFF) { 800 + i_qp_enable = 1; 801 + p_qp_enable = 1; 802 + b_qp_enable = 1; 803 + } else { 804 + if (inst->codec == V4L2_PIX_FMT_H264) { 805 + if (inst->fw_caps[I_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) 806 + i_qp_enable = 1; 807 + if (inst->fw_caps[P_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) 808 + p_qp_enable = 1; 809 + if (inst->fw_caps[B_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) 810 + b_qp_enable = 1; 811 + } else { 812 + if (inst->fw_caps[I_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) 813 + i_qp_enable = 1; 814 + if (inst->fw_caps[P_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) 815 + p_qp_enable = 1; 816 + if (inst->fw_caps[B_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) 817 + b_qp_enable = 1; 818 + } 819 + } 820 + 821 + client_qp_enable = i_qp_enable | p_qp_enable << 1 | b_qp_enable << 2; 822 + if (!client_qp_enable) 823 + return 0; 824 + 825 + if (inst->codec == V4L2_PIX_FMT_H264) { 826 + i_frame_qp = inst->fw_caps[I_FRAME_QP_H264].value; 827 + p_frame_qp = inst->fw_caps[P_FRAME_QP_H264].value; 828 + b_frame_qp = inst->fw_caps[B_FRAME_QP_H264].value; 829 + } else { 830 + i_frame_qp = inst->fw_caps[I_FRAME_QP_HEVC].value; 831 + p_frame_qp = inst->fw_caps[P_FRAME_QP_HEVC].value; 832 + b_frame_qp = inst->fw_caps[B_FRAME_QP_HEVC].value; 833 + } 834 + 835 + hfi_val = i_frame_qp | p_frame_qp << 8 | b_frame_qp << 16 | 836 + client_qp_enable << 24; 837 + 838 + return hfi_ops->session_set_property(inst, hfi_id, 839 + HFI_HOST_FLAGS_NONE, 840 + iris_get_port_info(inst, cap_id), 841 + HFI_PAYLOAD_32_PACKED, 842 + &hfi_val, sizeof(u32)); 843 + } 844 + 845 + int iris_set_qp_range(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) 846 + { 847 + const struct iris_hfi_command_ops *hfi_ops = inst->core->hfi_ops; 848 + struct hfi_quantization_range_v2 range; 849 + u32 hfi_id = inst->fw_caps[cap_id].hfi_id; 850 + 851 + if (inst->codec == V4L2_PIX_FMT_HEVC) { 852 + range.min_qp.qp_packed = inst->fw_caps[MIN_FRAME_QP_HEVC].value; 853 + range.max_qp.qp_packed = inst->fw_caps[MAX_FRAME_QP_HEVC].value; 854 + } else { 855 + range.min_qp.qp_packed = inst->fw_caps[MIN_FRAME_QP_H264].value; 856 + range.max_qp.qp_packed = inst->fw_caps[MAX_FRAME_QP_H264].value; 857 + } 858 + 859 + return hfi_ops->session_set_property(inst, hfi_id, 860 + HFI_HOST_FLAGS_NONE, 861 + iris_get_port_info(inst, cap_id), 862 + HFI_PAYLOAD_32_PACKED, 863 + &range, sizeof(range)); 420 864 } 421 865 422 866 int iris_set_properties(struct iris_inst *inst, u32 plane)
+15
drivers/media/platform/qcom/iris/iris_ctrls.h
··· 17 17 int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 18 18 int iris_set_pipe(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 19 19 int iris_set_u32(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 20 + int iris_set_profile(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 21 + int iris_set_level(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 22 + int iris_set_profile_level_gen1(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 23 + int iris_set_header_mode_gen1(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 24 + int iris_set_header_mode_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 25 + int iris_set_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 26 + int iris_set_peak_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 27 + int iris_set_bitrate_mode_gen1(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 28 + int iris_set_bitrate_mode_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 29 + int iris_set_entropy_mode_gen1(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 30 + int iris_set_entropy_mode_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 31 + int iris_set_min_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 32 + int iris_set_max_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 33 + int iris_set_frame_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 34 + int iris_set_qp_range(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id); 20 35 int iris_set_properties(struct iris_inst *inst, u32 plane); 21 36 22 37 #endif
+108
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
··· 534 534 packet->shdr.hdr.size += sizeof(u32) + sizeof(*wm); 535 535 break; 536 536 } 537 + case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT: { 538 + struct hfi_profile_level *in = pdata, *pl = prop_data; 539 + 540 + pl->level = in->level; 541 + pl->profile = in->profile; 542 + if (pl->profile <= 0) 543 + /* Profile not supported, falling back to high */ 544 + pl->profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH; 545 + 546 + if (!pl->level) 547 + /* Level not supported, falling back to 1 */ 548 + pl->level = 1; 549 + 550 + packet->shdr.hdr.size += sizeof(u32) + sizeof(*pl); 551 + break; 552 + } 553 + case HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER: { 554 + struct hfi_enable *en = prop_data; 555 + u32 *in = pdata; 556 + 557 + en->enable = *in; 558 + packet->shdr.hdr.size += sizeof(u32) + sizeof(*en); 559 + break; 560 + } 561 + case HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE: { 562 + struct hfi_bitrate *brate = prop_data; 563 + u32 *in = pdata; 564 + 565 + brate->bitrate = *in; 566 + brate->layer_id = 0; 567 + packet->shdr.hdr.size += sizeof(u32) + sizeof(*brate); 568 + break; 569 + } 570 + case HFI_PROPERTY_PARAM_VENC_RATE_CONTROL: { 571 + u32 *in = pdata; 572 + 573 + switch (*in) { 574 + case HFI_RATE_CONTROL_OFF: 575 + case HFI_RATE_CONTROL_CBR_CFR: 576 + case HFI_RATE_CONTROL_CBR_VFR: 577 + case HFI_RATE_CONTROL_VBR_CFR: 578 + case HFI_RATE_CONTROL_VBR_VFR: 579 + case HFI_RATE_CONTROL_CQ: 580 + break; 581 + default: 582 + return -EINVAL; 583 + } 584 + 585 + packet->data[1] = *in; 586 + packet->shdr.hdr.size += sizeof(u32) * 2; 587 + break; 588 + } 589 + case HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL: { 590 + struct hfi_h264_entropy_control *entropy = prop_data; 591 + u32 *in = pdata; 592 + 593 + entropy->entropy_mode = *in; 594 + if (entropy->entropy_mode == HFI_H264_ENTROPY_CABAC) 595 + entropy->cabac_model = HFI_H264_CABAC_MODEL_0; 596 + packet->shdr.hdr.size += sizeof(u32) + sizeof(*entropy); 597 + break; 598 + } 599 + case HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2: { 600 + struct hfi_quantization_range_v2 *range = prop_data; 601 + struct hfi_quantization_range_v2 *in = pdata; 602 + u32 min_qp, max_qp; 603 + 604 + min_qp = in->min_qp.qp_packed; 605 + max_qp = in->max_qp.qp_packed; 606 + 607 + /* We'll be packing in the qp, so make sure we 608 + * won't be losing data when masking 609 + */ 610 + if (min_qp > 0xff || max_qp > 0xff) 611 + return -ERANGE; 612 + 613 + range->min_qp.layer_id = 0xFF; 614 + range->max_qp.layer_id = 0xFF; 615 + range->min_qp.qp_packed = (min_qp & 0xFF) | ((min_qp & 0xFF) << 8) | 616 + ((min_qp & 0xFF) << 16); 617 + range->max_qp.qp_packed = (max_qp & 0xFF) | ((max_qp & 0xFF) << 8) | 618 + ((max_qp & 0xFF) << 16); 619 + range->min_qp.enable = 7; 620 + range->max_qp.enable = 7; 621 + packet->shdr.hdr.size += sizeof(u32) + sizeof(*range); 622 + break; 623 + } 624 + case HFI_PROPERTY_CONFIG_FRAME_RATE: { 625 + struct hfi_framerate *frate = prop_data; 626 + struct hfi_framerate *in = pdata; 627 + 628 + frate->buffer_type = in->buffer_type; 629 + frate->framerate = in->framerate; 630 + packet->shdr.hdr.size += sizeof(u32) + sizeof(*frate); 631 + break; 632 + } 633 + case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: { 634 + struct hfi_uncompressed_plane_actual_info *plane_actual_info = prop_data; 635 + struct hfi_uncompressed_plane_actual_info *in = pdata; 636 + 637 + plane_actual_info->buffer_type = in->buffer_type; 638 + plane_actual_info->num_planes = in->num_planes; 639 + plane_actual_info->plane_format[0] = in->plane_format[0]; 640 + if (in->num_planes > 1) 641 + plane_actual_info->plane_format[1] = in->plane_format[1]; 642 + packet->shdr.hdr.size += sizeof(u32) + sizeof(*plane_actual_info); 643 + break; 644 + } 537 645 default: 538 646 return -EINVAL; 539 647 }
+41 -6
drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h
··· 114 114 #define HFI_MSG_SESSION_RELEASE_RESOURCES 0x22100a 115 115 #define HFI_MSG_SESSION_RELEASE_BUFFERS 0x22100c 116 116 117 - #define HFI_PICTURE_I 0x00000001 118 - #define HFI_PICTURE_P 0x00000002 119 - #define HFI_PICTURE_B 0x00000004 120 - #define HFI_PICTURE_IDR 0x00000008 117 + #define HFI_GEN1_PICTURE_I 0x00000001 118 + #define HFI_GEN1_PICTURE_P 0x00000002 119 + #define HFI_GEN1_PICTURE_B 0x00000004 120 + #define HFI_GEN1_PICTURE_IDR 0x00000008 121 121 #define HFI_FRAME_NOTCODED 0x7f002000 122 122 #define HFI_FRAME_YUV 0x7f004000 123 123 #define HFI_UNUSED_PICT 0x10000000 124 - #define HFI_BUFFERFLAG_DATACORRUPT 0x00000008 125 - #define HFI_BUFFERFLAG_DROP_FRAME 0x20000000 124 + #define HFI_BUFFERFLAG_DATACORRUPT 0x00000008 125 + #define HFI_BUFFERFLAG_DROP_FRAME 0x20000000 126 + #define HFI_RATE_CONTROL_OFF 0x1000001 127 + #define HFI_RATE_CONTROL_VBR_VFR 0x1000002 128 + #define HFI_RATE_CONTROL_VBR_CFR 0x1000003 129 + #define HFI_RATE_CONTROL_CBR_VFR 0x1000004 130 + #define HFI_RATE_CONTROL_CBR_CFR 0x1000005 131 + #define HFI_RATE_CONTROL_CQ 0x1000008 132 + 133 + #define HFI_H264_ENTROPY_CAVLC 0x1 134 + #define HFI_H264_ENTROPY_CABAC 0x2 135 + 126 136 #define HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL 0x2005002 127 137 #define HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL 0x2005003 128 138 #define HFI_PROPERTY_PARAM_VENC_RATE_CONTROL 0x2005004 ··· 396 386 u32 count_actual; 397 387 u32 contiguous; 398 388 u32 alignment; 389 + }; 390 + 391 + struct hfi_bitrate { 392 + u32 bitrate; 393 + u32 layer_id; 394 + }; 395 + 396 + #define HFI_H264_CABAC_MODEL_0 0x1 397 + 398 + struct hfi_h264_entropy_control { 399 + u32 entropy_mode; 400 + u32 cabac_model; 401 + }; 402 + 403 + struct hfi_quantization_v2 { 404 + u32 qp_packed; 405 + u32 layer_id; 406 + u32 enable; 407 + u32 reserved[3]; 408 + }; 409 + 410 + struct hfi_quantization_range_v2 { 411 + struct hfi_quantization_v2 min_qp; 412 + struct hfi_quantization_v2 max_qp; 413 + u32 reserved[4]; 399 414 }; 400 415 401 416 struct hfi_framerate {
+4 -4
drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
··· 469 469 buf->timestamp = timestamp_us; 470 470 471 471 switch (pic_type) { 472 - case HFI_PICTURE_IDR: 473 - case HFI_PICTURE_I: 472 + case HFI_GEN1_PICTURE_IDR: 473 + case HFI_GEN1_PICTURE_I: 474 474 flags |= V4L2_BUF_FLAG_KEYFRAME; 475 475 break; 476 - case HFI_PICTURE_P: 476 + case HFI_GEN1_PICTURE_P: 477 477 flags |= V4L2_BUF_FLAG_PFRAME; 478 478 break; 479 - case HFI_PICTURE_B: 479 + case HFI_GEN1_PICTURE_B: 480 480 flags |= V4L2_BUF_FLAG_BFRAME; 481 481 break; 482 482 case HFI_FRAME_NOTCODED:
+25 -7
drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h
··· 56 56 #define HFI_PROP_BUFFER_HOST_MAX_COUNT 0x03000123 57 57 #define HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT 0x03000124 58 58 #define HFI_PROP_PIC_ORDER_CNT_TYPE 0x03000128 59 + 60 + enum hfi_rate_control { 61 + HFI_RC_VBR_CFR = 0x00000000, 62 + HFI_RC_CBR_CFR = 0x00000001, 63 + HFI_RC_CQ = 0x00000002, 64 + HFI_RC_OFF = 0x00000003, 65 + HFI_RC_CBR_VFR = 0x00000004, 66 + HFI_RC_LOSSLESS = 0x00000005, 67 + }; 68 + 59 69 #define HFI_PROP_RATE_CONTROL 0x0300012a 60 70 #define HFI_PROP_QP_PACKED 0x0300012e 61 71 #define HFI_PROP_MIN_QP_PACKED 0x0300012f ··· 74 64 #define HFI_PROP_MAX_GOP_FRAMES 0x03000146 75 65 #define HFI_PROP_MAX_B_FRAMES 0x03000147 76 66 #define HFI_PROP_QUALITY_MODE 0x03000148 67 + 68 + enum hfi_seq_header_mode { 69 + HFI_SEQ_HEADER_SEPERATE_FRAME = 0x00000001, 70 + HFI_SEQ_HEADER_JOINED_WITH_1ST_FRAME = 0x00000002, 71 + HFI_SEQ_HEADER_PREFIX_WITH_SYNC_FRAME = 0x00000004, 72 + HFI_SEQ_HEADER_METADATA = 0x00000008, 73 + }; 74 + 77 75 #define HFI_PROP_SEQ_HEADER_MODE 0x03000149 78 76 #define HFI_PROP_SIGNAL_COLOR_INFO 0x03000155 79 77 #define HFI_PROP_PICTURE_TYPE 0x03000162 ··· 141 123 }; 142 124 143 125 enum hfi_picture_type { 144 - HFI_PICTURE_IDR = 0x00000001, 145 - HFI_PICTURE_P = 0x00000002, 146 - HFI_PICTURE_B = 0x00000004, 147 - HFI_PICTURE_I = 0x00000008, 148 - HFI_PICTURE_CRA = 0x00000010, 149 - HFI_PICTURE_BLA = 0x00000020, 150 - HFI_PICTURE_NOSHOW = 0x00000040, 126 + HFI_GEN2_PICTURE_IDR = 0x00000001, 127 + HFI_GEN2_PICTURE_P = 0x00000002, 128 + HFI_GEN2_PICTURE_B = 0x00000004, 129 + HFI_GEN2_PICTURE_I = 0x00000008, 130 + HFI_GEN2_PICTURE_CRA = 0x00000010, 131 + HFI_GEN2_PICTURE_BLA = 0x00000020, 132 + HFI_GEN2_PICTURE_NOSHOW = 0x00000040, 151 133 }; 152 134 153 135 enum hfi_buffer_type {
+5 -4
drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
··· 87 87 88 88 static int iris_hfi_gen2_get_driver_buffer_flags(struct iris_inst *inst, u32 hfi_flags) 89 89 { 90 - u32 keyframe = HFI_PICTURE_IDR | HFI_PICTURE_I | HFI_PICTURE_CRA | HFI_PICTURE_BLA; 91 90 struct iris_inst_hfi_gen2 *inst_hfi_gen2 = to_iris_inst_hfi_gen2(inst); 91 + u32 keyframe = HFI_GEN2_PICTURE_IDR | HFI_GEN2_PICTURE_I | 92 + HFI_GEN2_PICTURE_CRA | HFI_GEN2_PICTURE_BLA; 92 93 u32 driver_flags = 0; 93 94 94 - if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_PICTURE_NOSHOW) 95 + if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_NOSHOW) 95 96 driver_flags |= V4L2_BUF_FLAG_ERROR; 96 97 else if (inst_hfi_gen2->hfi_frame_info.picture_type & keyframe) 97 98 driver_flags |= V4L2_BUF_FLAG_KEYFRAME; 98 - else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_PICTURE_P) 99 + else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_P) 99 100 driver_flags |= V4L2_BUF_FLAG_PFRAME; 100 - else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_PICTURE_B) 101 + else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_B) 101 102 driver_flags |= V4L2_BUF_FLAG_BFRAME; 102 103 103 104 if (inst_hfi_gen2->hfi_frame_info.data_corrupt || inst_hfi_gen2->hfi_frame_info.overflow)
+2 -1
drivers/media/platform/qcom/iris/iris_instance.h
··· 63 63 * @last_buffer_dequeued: a flag to indicate that last buffer is sent by driver 64 64 * @frame_rate: frame rate of current instance 65 65 * @operating_rate: operating rate of current instance 66 - 66 + * @hfi_rc_type: rate control type 67 67 */ 68 68 69 69 struct iris_inst { ··· 101 101 bool last_buffer_dequeued; 102 102 u32 frame_rate; 103 103 u32 operating_rate; 104 + u32 hfi_rc_type; 104 105 }; 105 106 106 107 #endif
+23
drivers/media/platform/qcom/iris/iris_platform_gen2.c
··· 215 215 .value = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, 216 216 .hfi_id = HFI_PROP_PROFILE, 217 217 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 218 + .set = iris_set_profile, 218 219 }, 219 220 { 220 221 .cap_id = PROFILE_HEVC, ··· 227 226 .value = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, 228 227 .hfi_id = HFI_PROP_PROFILE, 229 228 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 229 + .set = iris_set_profile, 230 230 }, 231 231 { 232 232 .cap_id = LEVEL_H264, ··· 254 252 .value = V4L2_MPEG_VIDEO_H264_LEVEL_5_0, 255 253 .hfi_id = HFI_PROP_LEVEL, 256 254 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 255 + .set = iris_set_level, 257 256 }, 258 257 { 259 258 .cap_id = LEVEL_HEVC, ··· 276 273 .value = V4L2_MPEG_VIDEO_HEVC_LEVEL_5, 277 274 .hfi_id = HFI_PROP_LEVEL, 278 275 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 276 + .set = iris_set_level, 279 277 }, 280 278 { 281 279 .cap_id = STAGE, ··· 285 281 .step_or_mask = 1, 286 282 .value = STAGE_2, 287 283 .hfi_id = HFI_PROP_STAGE, 284 + .set = iris_set_stage, 288 285 }, 289 286 { 290 287 .cap_id = HEADER_MODE, ··· 296 291 .value = V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, 297 292 .hfi_id = HFI_PROP_SEQ_HEADER_MODE, 298 293 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 294 + .set = iris_set_header_mode_gen2, 299 295 }, 300 296 { 301 297 .cap_id = PREPEND_SPSPPS_TO_IDR, ··· 314 308 .hfi_id = HFI_PROP_TOTAL_BITRATE, 315 309 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 316 310 CAP_FLAG_DYNAMIC_ALLOWED, 311 + .set = iris_set_bitrate, 317 312 }, 318 313 { 319 314 .cap_id = BITRATE_PEAK, ··· 325 318 .hfi_id = HFI_PROP_TOTAL_PEAK_BITRATE, 326 319 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 327 320 CAP_FLAG_DYNAMIC_ALLOWED, 321 + .set = iris_set_peak_bitrate, 328 322 }, 329 323 { 330 324 .cap_id = BITRATE_MODE, ··· 336 328 .value = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, 337 329 .hfi_id = HFI_PROP_RATE_CONTROL, 338 330 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 331 + .set = iris_set_bitrate_mode_gen2, 339 332 }, 340 333 { 341 334 .cap_id = FRAME_SKIP_MODE, ··· 364 355 .hfi_id = HFI_PROP_MAX_GOP_FRAMES, 365 356 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 366 357 CAP_FLAG_DYNAMIC_ALLOWED, 358 + .set = iris_set_u32, 367 359 }, 368 360 { 369 361 .cap_id = ENTROPY_MODE, ··· 375 365 .value = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC, 376 366 .hfi_id = HFI_PROP_CABAC_SESSION, 377 367 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 368 + .set = iris_set_entropy_mode_gen2, 378 369 }, 379 370 { 380 371 .cap_id = MIN_FRAME_QP_H264, ··· 385 374 .value = MIN_QP_8BIT, 386 375 .hfi_id = HFI_PROP_MIN_QP_PACKED, 387 376 .flags = CAP_FLAG_OUTPUT_PORT, 377 + .set = iris_set_min_qp, 388 378 }, 389 379 { 390 380 .cap_id = MIN_FRAME_QP_HEVC, ··· 395 383 .value = MIN_QP_8BIT, 396 384 .hfi_id = HFI_PROP_MIN_QP_PACKED, 397 385 .flags = CAP_FLAG_OUTPUT_PORT, 386 + .set = iris_set_min_qp, 398 387 }, 399 388 { 400 389 .cap_id = MAX_FRAME_QP_H264, ··· 405 392 .value = MAX_QP, 406 393 .hfi_id = HFI_PROP_MAX_QP_PACKED, 407 394 .flags = CAP_FLAG_OUTPUT_PORT, 395 + .set = iris_set_max_qp, 408 396 }, 409 397 { 410 398 .cap_id = MAX_FRAME_QP_HEVC, ··· 415 401 .value = MAX_QP, 416 402 .hfi_id = HFI_PROP_MAX_QP_PACKED, 417 403 .flags = CAP_FLAG_OUTPUT_PORT, 404 + .set = iris_set_max_qp, 418 405 }, 419 406 { 420 407 .cap_id = I_FRAME_MIN_QP_H264, ··· 510 495 .hfi_id = HFI_PROP_QP_PACKED, 511 496 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 512 497 CAP_FLAG_DYNAMIC_ALLOWED, 498 + .set = iris_set_frame_qp, 513 499 }, 514 500 { 515 501 .cap_id = I_FRAME_QP_HEVC, ··· 521 505 .hfi_id = HFI_PROP_QP_PACKED, 522 506 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 523 507 CAP_FLAG_DYNAMIC_ALLOWED, 508 + .set = iris_set_frame_qp, 524 509 }, 525 510 { 526 511 .cap_id = P_FRAME_QP_H264, ··· 532 515 .hfi_id = HFI_PROP_QP_PACKED, 533 516 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 534 517 CAP_FLAG_DYNAMIC_ALLOWED, 518 + .set = iris_set_frame_qp, 535 519 }, 536 520 { 537 521 .cap_id = P_FRAME_QP_HEVC, ··· 543 525 .hfi_id = HFI_PROP_QP_PACKED, 544 526 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 545 527 CAP_FLAG_DYNAMIC_ALLOWED, 528 + .set = iris_set_frame_qp, 546 529 }, 547 530 { 548 531 .cap_id = B_FRAME_QP_H264, ··· 554 535 .hfi_id = HFI_PROP_QP_PACKED, 555 536 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 556 537 CAP_FLAG_DYNAMIC_ALLOWED, 538 + .set = iris_set_frame_qp, 557 539 }, 558 540 { 559 541 .cap_id = B_FRAME_QP_HEVC, ··· 565 545 .hfi_id = HFI_PROP_QP_PACKED, 566 546 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 567 547 CAP_FLAG_DYNAMIC_ALLOWED, 548 + .set = iris_set_frame_qp, 568 549 }, 569 550 { 570 551 .cap_id = INPUT_BUF_HOST_MAX_COUNT, ··· 575 554 .value = DEFAULT_MAX_HOST_BUF_COUNT, 576 555 .hfi_id = HFI_PROP_BUFFER_HOST_MAX_COUNT, 577 556 .flags = CAP_FLAG_INPUT_PORT, 557 + .set = iris_set_u32, 578 558 }, 579 559 { 580 560 .cap_id = OUTPUT_BUF_HOST_MAX_COUNT, ··· 585 563 .value = DEFAULT_MAX_HOST_BUF_COUNT, 586 564 .hfi_id = HFI_PROP_BUFFER_HOST_MAX_COUNT, 587 565 .flags = CAP_FLAG_OUTPUT_PORT, 566 + .set = iris_set_u32, 588 567 }, 589 568 }; 590 569
+14
drivers/media/platform/qcom/iris/iris_platform_sm8250.c
··· 45 45 .step_or_mask = 1, 46 46 .value = STAGE_2, 47 47 .hfi_id = HFI_PROPERTY_PARAM_WORK_MODE, 48 + .set = iris_set_stage, 48 49 }, 49 50 { 50 51 .cap_id = PROFILE_H264, ··· 60 59 .value = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, 61 60 .hfi_id = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, 62 61 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 62 + .set = iris_set_profile_level_gen1, 63 63 }, 64 64 { 65 65 .cap_id = PROFILE_HEVC, ··· 72 70 .value = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, 73 71 .hfi_id = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, 74 72 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 73 + .set = iris_set_profile_level_gen1, 75 74 }, 76 75 { 77 76 .cap_id = LEVEL_H264, ··· 97 94 .value = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, 98 95 .hfi_id = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, 99 96 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 97 + .set = iris_set_profile_level_gen1, 100 98 }, 101 99 { 102 100 .cap_id = LEVEL_HEVC, ··· 119 115 .value = V4L2_MPEG_VIDEO_HEVC_LEVEL_1, 120 116 .hfi_id = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, 121 117 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 118 + .set = iris_set_profile_level_gen1, 122 119 }, 123 120 { 124 121 .cap_id = HEADER_MODE, ··· 130 125 .value = V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, 131 126 .hfi_id = HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER, 132 127 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 128 + .set = iris_set_header_mode_gen1, 133 129 }, 134 130 { 135 131 .cap_id = BITRATE, ··· 141 135 .hfi_id = HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE, 142 136 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | 143 137 CAP_FLAG_DYNAMIC_ALLOWED, 138 + .set = iris_set_bitrate, 144 139 }, 145 140 { 146 141 .cap_id = BITRATE_MODE, ··· 152 145 .value = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, 153 146 .hfi_id = HFI_PROPERTY_PARAM_VENC_RATE_CONTROL, 154 147 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 148 + .set = iris_set_bitrate_mode_gen1, 155 149 }, 156 150 { 157 151 .cap_id = FRAME_SKIP_MODE, ··· 176 168 .max = (1 << 16) - 1, 177 169 .step_or_mask = 1, 178 170 .value = 30, 171 + .set = iris_set_u32 179 172 }, 180 173 { 181 174 .cap_id = ENTROPY_MODE, ··· 187 178 .value = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, 188 179 .hfi_id = HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL, 189 180 .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, 181 + .set = iris_set_entropy_mode_gen1, 190 182 }, 191 183 { 192 184 .cap_id = MIN_FRAME_QP_H264, ··· 197 187 .value = MIN_QP_8BIT, 198 188 .hfi_id = HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, 199 189 .flags = CAP_FLAG_OUTPUT_PORT, 190 + .set = iris_set_qp_range, 200 191 }, 201 192 { 202 193 .cap_id = MIN_FRAME_QP_HEVC, ··· 207 196 .value = MIN_QP_8BIT, 208 197 .hfi_id = HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, 209 198 .flags = CAP_FLAG_OUTPUT_PORT, 199 + .set = iris_set_qp_range, 210 200 }, 211 201 { 212 202 .cap_id = MAX_FRAME_QP_H264, ··· 217 205 .value = MAX_QP, 218 206 .hfi_id = HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, 219 207 .flags = CAP_FLAG_OUTPUT_PORT, 208 + .set = iris_set_qp_range, 220 209 }, 221 210 { 222 211 .cap_id = MAX_FRAME_QP_HEVC, ··· 227 214 .value = MAX_QP_HEVC, 228 215 .hfi_id = HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, 229 216 .flags = CAP_FLAG_OUTPUT_PORT, 217 + .set = iris_set_qp_range, 230 218 }, 231 219 }; 232 220