From b560c7a295076b2bde60e2b7cfdc28fa2c44771d Mon Sep 17 00:00:00 2001 From: Vikash Garodia Date: Mon, 17 Aug 2020 17:49:35 +0530 Subject: [PATCH 1/7] msm: vidc: Restrict dynamic low latency for h264 and hevc In existing approach, dynamic low latency i.e low latency hint is restricted via specific low latency components in userspace. This change adds one more checkpoint to ensure that video firmware is configured for low latency only for desired codecs. Change-Id: Iad36c3b84ddc3b94033c4bf5f0afdd3a18600111 Signed-off-by: Vikash Garodia --- msm/vidc/msm_vdec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/msm/vidc/msm_vdec.c b/msm/vidc/msm_vdec.c index 685f56e6c17b..a05c28d11f89 100644 --- a/msm/vidc/msm_vdec.c +++ b/msm/vidc/msm_vdec.c @@ -1326,6 +1326,7 @@ int msm_vdec_set_priority(struct msm_vidc_inst *inst) int msm_vdec_set_seqchng_at_syncframe(struct msm_vidc_inst *inst) { int rc = 0; + u32 codec; struct hfi_device *hdev; struct hfi_enable hfi_property; @@ -1339,6 +1340,13 @@ int msm_vdec_set_seqchng_at_syncframe(struct msm_vidc_inst *inst) if (!hfi_property.enable) return 0; + codec = get_v4l2_codec(inst); + if (!(codec == V4L2_PIX_FMT_HEVC || codec == V4L2_PIX_FMT_H264)) { + s_vpr_e(inst->sid, + "%s: low latency hint supported for HEVC/H264\n", + __func__); + return -EINVAL; + } s_vpr_h(inst->sid, "%s: %#x\n", __func__, hfi_property.enable); rc = call_hfi_op(hdev, session_set_property, inst->session, HFI_PROPERTY_PARAM_VDEC_SEQCHNG_AT_SYNCFRM, &hfi_property, From 0e570d90fa28e843d8b375202b054100256b4e71 Mon Sep 17 00:00:00 2001 From: Qiwei Liu Date: Wed, 10 Jun 2020 15:09:10 +0800 Subject: [PATCH 2/7] msm: vidc: improve heif decoder performance Add V4L2 interface to indicate heif decoder, and use below configurations to improve performance. 1. Set turbo session 2. Disable DCVS and batch 3. Increase input and output buffer count to 12 4. Modify input buffer size calculation 5. Avoid framerate calc and ts list maintenance 6. Skip setting bse-vpp delay Change-Id: I9a47a88154238db3ac4285462c6030114546d333 Signed-off-by: Qiwei Liu --- include/uapi/vidc/media/msm_vidc_utils.h | 2 ++ msm/vidc/msm_vdec.c | 18 ++++++++++++++++++ msm/vidc/msm_vidc.c | 6 ++++-- msm/vidc/msm_vidc_buffer_calculations.c | 17 ++++++++++++++++- msm/vidc/msm_vidc_clocks.c | 1 + msm/vidc/msm_vidc_common.c | 1 + msm/vidc/msm_vidc_common.h | 11 +++++++++++ 7 files changed, 53 insertions(+), 3 deletions(-) diff --git a/include/uapi/vidc/media/msm_vidc_utils.h b/include/uapi/vidc/media/msm_vidc_utils.h index 2e4f351c4927..a20d4816841a 100644 --- a/include/uapi/vidc/media/msm_vidc_utils.h +++ b/include/uapi/vidc/media/msm_vidc_utils.h @@ -252,6 +252,8 @@ enum v4l2_mpeg_vidc_video_bitrate_savings_type { (V4L2_CID_MPEG_MSM_VIDC_BASE + 132) #define V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_HINT \ (V4L2_CID_MPEG_MSM_VIDC_BASE + 133) +#define V4L2_CID_MPEG_VIDC_VDEC_HEIF_MODE \ + (V4L2_CID_MPEG_MSM_VIDC_BASE + 134) #define V4L2_CID_MPEG_VIDC_VIDEO_UNKNOWN \ (V4L2_CID_MPEG_MSM_VIDC_BASE + 0xFFF) diff --git a/msm/vidc/msm_vdec.c b/msm/vidc/msm_vdec.c index 685f56e6c17b..5a2b8a348978 100644 --- a/msm/vidc/msm_vdec.c +++ b/msm/vidc/msm_vdec.c @@ -434,6 +434,15 @@ static struct msm_vidc_ctrl msm_vdec_ctrls[] = { .default_value = 0, .step = 1, }, + { + .id = V4L2_CID_MPEG_VIDC_VDEC_HEIF_MODE, + .name = "HEIF Decoder", + .type = V4L2_CTRL_TYPE_BOOLEAN, + .minimum = V4L2_MPEG_MSM_VIDC_DISABLE, + .maximum = V4L2_MPEG_MSM_VIDC_ENABLE, + .default_value = V4L2_MPEG_MSM_VIDC_DISABLE, + .step = 1, + }, }; #define NUM_CTRLS ARRAY_SIZE(msm_vdec_ctrls) @@ -948,6 +957,15 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) break; case V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_HINT: break; + case V4L2_CID_MPEG_VIDC_VDEC_HEIF_MODE: + if(get_v4l2_codec(inst) != V4L2_PIX_FMT_HEVC) + break; + inst->flags &= ~VIDC_TURBO; + if (ctrl->val) + inst->flags |= VIDC_TURBO; + if (inst->state < MSM_VIDC_LOAD_RESOURCES) + msm_vidc_calculate_buffer_counts(inst); + break; default: s_vpr_e(inst->sid, "Unknown control %#x\n", ctrl->id); break; diff --git a/msm/vidc/msm_vidc.c b/msm/vidc/msm_vidc.c index 7f78071d585d..499abc4f5ad8 100644 --- a/msm/vidc/msm_vidc.c +++ b/msm/vidc/msm_vidc.c @@ -432,7 +432,8 @@ int msm_vidc_qbuf(void *instance, struct media_device *mdev, timestamp_us = (s64)((b->timestamp.tv_sec * 1000000) + b->timestamp.tv_usec); - if (is_decode_session(inst) && b->type == INPUT_MPLANE) { + if (is_decode_session(inst) && b->type == INPUT_MPLANE && + !is_heif_decoder(inst)) { if (inst->flush_timestamps) msm_comm_release_timestamps(inst); inst->flush_timestamps = false; @@ -513,7 +514,8 @@ int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b) } if (is_decode_session(inst) && b->type == OUTPUT_MPLANE && - !(b->flags & V4L2_BUF_FLAG_CODECCONFIG)) + !(b->flags & V4L2_BUF_FLAG_CODECCONFIG) && + !is_heif_decoder(inst)) msm_comm_fetch_ts_framerate(inst, b); return rc; diff --git a/msm/vidc/msm_vidc_buffer_calculations.c b/msm/vidc/msm_vidc_buffer_calculations.c index 03079a37ee35..4b1a2bd287d9 100644 --- a/msm/vidc/msm_vidc_buffer_calculations.c +++ b/msm/vidc/msm_vidc_buffer_calculations.c @@ -27,6 +27,10 @@ /* extra output buffers for encoder HEIF usecase */ #define HEIF_ENC_TOTAL_OUTPUT_BUFFERS 12 +/* extra buffer count for heif decoder */ +#define HEIF_DEC_TOTAL_INPUT_BUFFERS 12 +#define HEIF_DEC_EXTRA_OUTPUT_BUFFERS 8 + #define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_WIDTH 32 #define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_HEIGHT 8 #define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_WIDTH 16 @@ -789,6 +793,9 @@ static int msm_vidc_get_extra_input_buff_count(struct msm_vidc_inst *inst) core = inst->core; + if (is_heif_decoder(inst)) + return (HEIF_DEC_TOTAL_INPUT_BUFFERS - MIN_INPUT_BUFFERS); + /* * For thumbnail session, extra buffers are not required as * neither dcvs nor batching will be enabled. @@ -821,6 +828,9 @@ static int msm_vidc_get_extra_output_buff_count(struct msm_vidc_inst *inst) core = inst->core; + if (is_heif_decoder(inst)) + return HEIF_DEC_EXTRA_OUTPUT_BUFFERS; + /* * For a non-realtime session, extra buffers are not required. * For thumbnail session, extra buffers are not required as @@ -829,7 +839,7 @@ static int msm_vidc_get_extra_output_buff_count(struct msm_vidc_inst *inst) if (!is_realtime_session(inst) || is_thumbnail_session(inst)) return extra_output_count; - /* For HEIF, we are increasing buffer count */ + /* For HEIF encoder, we are increasing buffer count */ if (is_image_session(inst)) { extra_output_count = (HEIF_ENC_TOTAL_OUTPUT_BUFFERS - MIN_ENC_OUTPUT_BUFFERS); @@ -889,6 +899,11 @@ u32 msm_vidc_calculate_dec_input_frame_size(struct msm_vidc_inst *inst) base_res_mbs = inst->capability.cap[CAP_MBS_PER_FRAME].max; div_factor = 1; } + /* For HEIF image, use the actual resolution to calc buffer size */ + if (is_heif_decoder(inst)) { + base_res_mbs = num_mbs; + div_factor = 1; + } frame_size = base_res_mbs * MB_SIZE_IN_PIXEL * 3 / 2 / div_factor; diff --git a/msm/vidc/msm_vidc_clocks.c b/msm/vidc/msm_vidc_clocks.c index 0af709fe2d36..64b5f95408f9 100644 --- a/msm/vidc/msm_vidc_clocks.c +++ b/msm/vidc/msm_vidc_clocks.c @@ -1293,6 +1293,7 @@ int msm_vidc_set_bse_vpp_delay(struct msm_vidc_inst *inst) if (!inst->core->resources.has_vpp_delay || !is_decode_session(inst) || is_thumbnail_session(inst) || + is_heif_decoder(inst) || inst->clk_data.work_mode != HFI_WORKMODE_2) { s_vpr_hp(inst->sid, "%s: Skip bse-vpp\n", __func__); return 0; diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index 652334c646c4..0cab94351d95 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -2839,6 +2839,7 @@ bool is_batching_allowed(struct msm_vidc_inst *inst) is_decode_session(inst) && !is_thumbnail_session(inst) && is_realtime_session(inst) && + !is_heif_decoder(inst) && !inst->clk_data.low_latency_mode && (op_pixelformat == V4L2_PIX_FMT_NV12_UBWC || op_pixelformat == V4L2_PIX_FMT_NV12_TP10_UBWC) && diff --git a/msm/vidc/msm_vidc_common.h b/msm/vidc/msm_vidc_common.h index e46c5bbd9f62..24a04dd0a257 100644 --- a/msm/vidc/msm_vidc_common.h +++ b/msm/vidc/msm_vidc_common.h @@ -121,6 +121,17 @@ static inline bool is_grid_session(struct msm_vidc_inst *inst) return 0; } +static inline bool is_heif_decoder(struct msm_vidc_inst *inst) +{ + struct v4l2_ctrl *ctrl = NULL; + if (inst->session_type == MSM_VIDC_DECODER && + get_v4l2_codec(inst) == V4L2_PIX_FMT_HEVC) { + ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VDEC_HEIF_MODE); + return (ctrl->val > 0); + } + return 0; +} + static inline bool is_video_session(struct msm_vidc_inst *inst) { return !is_grid_session(inst); From c24265be5ce3e7150ba5cd0dec22a8c8aa90b2c0 Mon Sep 17 00:00:00 2001 From: Govindaraj Rajagopal Date: Tue, 18 Aug 2020 18:42:47 +0530 Subject: [PATCH 3/7] msm: vidc: Update VP9 decoder capabilities for shima Update VP9 decoder capabilities for shima to be inline with lahaina. Change-Id: Ieab73987d92bb093fd06391086935900b5e01768 Signed-off-by: Govindaraj Rajagopal --- msm/vidc/msm_vidc_platform.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/msm/vidc/msm_vidc_platform.c b/msm/vidc/msm_vidc_platform.c index 259c13747682..1d42b06aced4 100644 --- a/msm/vidc/msm_vidc_platform.c +++ b/msm/vidc/msm_vidc_platform.c @@ -448,7 +448,7 @@ static struct msm_vidc_codec_capability shima_capabilities_v0[] = { {CAP_SCALE_Y, DEC, CODECS_ALL, 65536, 65536, 1, 65536}, {CAP_BFRAME, ENC, H264|HEVC, 0, 1, 1, 0}, {CAP_HIER_P_NUM_ENH_LAYERS, ENC, H264|HEVC, 0, 6, 1, 0}, - {CAP_LTR_COUNT, ENC, H264|HEVC, 0, 4, 1, 0}, + {CAP_LTR_COUNT, ENC, H264|HEVC, 0, 2, 1, 0}, /* ((1920 * 1088) / 256) * 60 fps */ {CAP_MBS_PER_SECOND_POWER_SAVE, ENC, CODECS_ALL, 0, 489600, 1, 489600}, @@ -470,6 +470,16 @@ static struct msm_vidc_codec_capability shima_capabilities_v0[] = { {CAP_FRAMERATE, DEC, MPEG2, 1, 30, 1, 30}, {CAP_BITRATE, DEC, MPEG2, 1, 40000000, 1, 20000000}, + /* VP9 decoder-specific */ + {CAP_FRAME_WIDTH, DEC, VP9, 96, 4096, 1, 1920}, + {CAP_FRAME_HEIGHT, DEC, VP9, 96, 4096, 1, 1080}, + /* (4096 * 2304) / 256 */ + {CAP_MBS_PER_FRAME, DEC, VP9, 36, 36864, 1, 36864}, + /* ((4096 * 2304) / 256) * 60 */ + {CAP_MBS_PER_SECOND, DEC, VP9, 36, 2211840, 1, 2211840}, + {CAP_FRAMERATE, DEC, VP9, 1, 60, 1, 60}, + {CAP_BITRATE, DEC, VP9, 1, 100000000, 1, 20000000}, + /* Secure usecase specific */ {CAP_SECURE_FRAME_WIDTH, DEC, CODECS_ALL, 96, 4096, 1, 1920}, {CAP_SECURE_FRAME_HEIGHT, DEC, CODECS_ALL, 96, 4096, 1, 1080}, @@ -545,7 +555,7 @@ static struct msm_vidc_codec_capability shima_capabilities_v1[] = { {CAP_SCALE_Y, DEC, CODECS_ALL, 65536, 65536, 1, 65536}, {CAP_BFRAME, ENC, H264|HEVC, 0, 1, 1, 0}, {CAP_HIER_P_NUM_ENH_LAYERS, ENC, H264|HEVC, 0, 6, 1, 0}, - {CAP_LTR_COUNT, ENC, H264|HEVC, 0, 4, 1, 0}, + {CAP_LTR_COUNT, ENC, H264|HEVC, 0, 2, 1, 0}, /* ((1920 * 1088) / 256) * 30 fps */ {CAP_MBS_PER_SECOND_POWER_SAVE, ENC, CODECS_ALL, 0, 244800, 1, 244800}, @@ -567,6 +577,16 @@ static struct msm_vidc_codec_capability shima_capabilities_v1[] = { {CAP_FRAMERATE, DEC, MPEG2, 1, 30, 1, 30}, {CAP_BITRATE, DEC, MPEG2, 1, 40000000, 1, 20000000}, + /* VP9 decoder-specific */ + {CAP_FRAME_WIDTH, DEC, VP9, 96, 4096, 1, 1920}, + {CAP_FRAME_HEIGHT, DEC, VP9, 96, 4096, 1, 1080}, + /* (4096 * 2304) / 256 */ + {CAP_MBS_PER_FRAME, DEC, VP9, 36, 36864, 1, 36864}, + /* ((4096 * 2304) / 256) * 60 */ + {CAP_MBS_PER_SECOND, DEC, VP9, 36, 2211840, 1, 2211840}, + {CAP_FRAMERATE, DEC, VP9, 1, 60, 1, 60}, + {CAP_BITRATE, DEC, VP9, 1, 100000000, 1, 20000000}, + /* Secure usecase specific */ {CAP_SECURE_FRAME_WIDTH, DEC, CODECS_ALL, 96, 4096, 1, 1920}, {CAP_SECURE_FRAME_HEIGHT, DEC, CODECS_ALL, 96, 4096, 1, 1080}, @@ -663,6 +683,16 @@ static struct msm_vidc_codec_capability shima_capabilities_v2[] = { {CAP_FRAMERATE, DEC, MPEG2, 1, 30, 1, 30}, {CAP_BITRATE, DEC, MPEG2, 1, 40000000, 1, 20000000}, + /* VP9 decoder-specific */ + {CAP_FRAME_WIDTH, DEC, VP9, 96, 4096, 1, 1920}, + {CAP_FRAME_HEIGHT, DEC, VP9, 96, 4096, 1, 1080}, + /* (4096 * 2304) / 256 */ + {CAP_MBS_PER_FRAME, DEC, VP9, 36, 36864, 1, 36864}, + /* ((4096 * 2304) / 256) * 30 */ + {CAP_MBS_PER_SECOND, DEC, VP9, 36, 1105920, 1, 1105920}, + {CAP_FRAMERATE, DEC, VP9, 1, 60, 1, 60}, + {CAP_BITRATE, DEC, VP9, 1, 100000000, 1, 20000000}, + /* Secure usecase specific */ {CAP_SECURE_FRAME_WIDTH, DEC, CODECS_ALL, 96, 4096, 1, 1920}, {CAP_SECURE_FRAME_HEIGHT, DEC, CODECS_ALL, 96, 4096, 1, 1080}, From 2686a86b947226d8a63b439e40569d9162af9a46 Mon Sep 17 00:00:00 2001 From: Priyanka Gujjula Date: Tue, 18 Aug 2020 12:10:57 +0530 Subject: [PATCH 4/7] msm: vidc: Include uapi header files from techpack Currently uapi header files are included from core kernel include path since core kernel makefile also includes them. Hence making changes to include path in techpack makefile such that uapi header files are included from techpack project. Change-Id: I604b8bbb3058473b3e301cbbce112c8c93a0e963 Signed-off-by: Priyanka Gujjula --- Makefile | 3 +-- msm/vidc/msm_vidc.h | 2 +- msm/vidc/msm_vidc_internal.h | 2 +- msm/vidc/vidc_hfi.h | 2 +- msm/vidc/vidc_hfi_helper.h | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3fdadb733a2e..dfbd2d489355 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,7 @@ endif endif LINUXINCLUDE += -I$(srctree)/techpack/video/include \ - -I$(srctree)/techpack/video/include/uapi \ - -I$(srctree)/techpack/video/include/uapi/vidc + -I$(srctree)/techpack/video/include/uapi USERINCLUDE += -I$(srctree)/techpack/video/include/uapi diff --git a/msm/vidc/msm_vidc.h b/msm/vidc/msm_vidc.h index cea3b470f408..136cea68a7e9 100644 --- a/msm/vidc/msm_vidc.h +++ b/msm/vidc/msm_vidc.h @@ -8,7 +8,7 @@ #include #include -#include +#include "vidc/media/msm_vidc_utils.h" #include #define HAL_BUFFER_MAX 0xe diff --git a/msm/vidc/msm_vidc_internal.h b/msm/vidc/msm_vidc_internal.h index e04ac940ace2..7df2afb76eb1 100644 --- a/msm/vidc/msm_vidc_internal.h +++ b/msm/vidc/msm_vidc_internal.h @@ -15,7 +15,7 @@ #include #include #include "msm_vidc.h" -#include +#include "vidc/media/msm_media_info.h" #include "vidc_hfi_api.h" #include "vidc_hfi_helper.h" diff --git a/msm/vidc/vidc_hfi.h b/msm/vidc/vidc_hfi.h index ed078af401b5..29c6c85b699c 100644 --- a/msm/vidc/vidc_hfi.h +++ b/msm/vidc/vidc_hfi.h @@ -5,7 +5,7 @@ #ifndef __H_VIDC_HFI_H__ #define __H_VIDC_HFI_H__ -#include +#include "vidc/media/msm_media_info.h" #include "vidc_hfi_helper.h" #include "vidc_hfi_api.h" diff --git a/msm/vidc/vidc_hfi_helper.h b/msm/vidc/vidc_hfi_helper.h index 65e1f0e486e3..dd64a6ae9866 100644 --- a/msm/vidc/vidc_hfi_helper.h +++ b/msm/vidc/vidc_hfi_helper.h @@ -6,7 +6,7 @@ #ifndef __H_VIDC_HFI_HELPER_H__ #define __H_VIDC_HFI_HELPER_H__ -#include +#include "vidc/media/msm_vidc_utils.h" #define HFI_COMMON_BASE (0) #define HFI_OX_BASE (0x01000000) From b28387c5c427f17e3cd6c8d5504f72b4b925b2ef Mon Sep 17 00:00:00 2001 From: Dikshita Agarwal Date: Fri, 14 Aug 2020 14:35:15 +0530 Subject: [PATCH 5/7] msm-vidc: update bw calculation for ar50LT Update bw calculation formulas for ar50LT. Change-Id: Ife2342304947f4108f908f7a5c56de24ad088b23 Signed-off-by: Dikshita Agarwal --- msm/vidc/msm_vidc_bus_ar50lite.c | 199 +++++++++++++++++-------------- 1 file changed, 109 insertions(+), 90 deletions(-) diff --git a/msm/vidc/msm_vidc_bus_ar50lite.c b/msm/vidc/msm_vidc_bus_ar50lite.c index d98592703d6c..496e379083fb 100644 --- a/msm/vidc/msm_vidc_bus_ar50lite.c +++ b/msm/vidc/msm_vidc_bus_ar50lite.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. */ #include "msm_vidc_bus.h" @@ -9,33 +9,35 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d) { /* Encoder Parameters */ - int width, height, fps, bitrate, lcu_size; + int width, height, fps, bitrate, lcu_size, lcu_per_frame, + collocated_bytes_per_lcu, search_range_v, search_range_h, + vertical_tile_size, num_tiles; - /* Derived Parameter */ - int search_range, lcu_per_frame; + unsigned int bins_to_bit_factor; fp_t y_bw; bool is_h264_category = true; fp_t orig_read_factor, recon_write_factor, - ref_y_read_factor, ref_c_read_factor, lb_factor, - rest_factor, total_read_factor, total_write_factor, - total_factor, overhead_factor; + ref_y_read_factor, ref_c_read_factor, overhead_factor; /* Output parameters */ fp_t orig_read, recon_write, - ref_y_read, ref_c_read, - lb_read, lb_write, - bse_read, bse_write, - total_read, total_write, - total; + ref_y_read, ref_c_read, + bse_lb_read, bse_lb_write, + collocated_read, collocated_write, + bitstream_read, bitstream_write, + total_read, total_write, + total; unsigned long ret = 0; - /* Encoder Fixed Parameters */ + /* Encoder Fixed Parameters setup */ + search_range_h = 96; + search_range_v = 48; + bins_to_bit_factor = 4; overhead_factor = FP(1, 3, 100); orig_read_factor = FP(1, 50, 100); /* L + C */ recon_write_factor = FP(1, 50, 100); /* L + C */ ref_c_read_factor = FP(0, 75, 100); /* 1.5/2 ( 1.5 Cache efficiency )*/ - lb_factor = FP(1, 25, 100); /* Worst case : HEVC 720p = 1.25 */ fps = d->fps; width = max(d->output_width, BASELINE_DIMENSIONS.width); @@ -55,40 +57,46 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d) is_h264_category = false; } - search_range = 48; + collocated_bytes_per_lcu = lcu_size == 16 ? 16 : + lcu_size == 32 ? 64 : 256; + if (width >= 1296 && width <= 1536) + vertical_tile_size = 768; + else + vertical_tile_size = 640; + + num_tiles = DIV_ROUND_UP(width, vertical_tile_size); y_bw = fp_mult(fp_mult(FP_INT(width), FP_INT(height)), FP_INT(fps)); - y_bw = fp_div(y_bw, FP_INT(1000000)); + y_bw = fp_div(y_bw, FP_INT(bps(1))); - ref_y_read_factor = fp_div(FP_INT(search_range * 2), FP_INT(lcu_size)); + /* -1 for 1 less tile boundary penalty */ + ref_y_read_factor = (num_tiles - 1) * 2; + ref_y_read_factor = fp_div(fp_mult(FP_INT(ref_y_read_factor), + FP_INT(search_range_h)), FP_INT(width)); ref_y_read_factor = ref_y_read_factor + FP_INT(1); - rest_factor = FP_INT(bitrate) + fp_div(FP_INT(bitrate), FP_INT(8)); - rest_factor = fp_div(rest_factor, y_bw); - - total_read_factor = fp_div(rest_factor, FP_INT(2)) + - fp_div(lb_factor, FP_INT(2)); - total_read_factor = total_read_factor + orig_read_factor + - ref_y_read_factor + ref_c_read_factor; - - total_write_factor = fp_div(rest_factor, FP_INT(2)) + - fp_div(lb_factor, FP_INT(2)); - total_write_factor = total_write_factor + recon_write_factor; - - total_factor = total_read_factor + total_write_factor; - orig_read = fp_mult(y_bw, orig_read_factor); recon_write = fp_mult(y_bw, recon_write_factor); ref_y_read = fp_mult(y_bw, ref_y_read_factor); ref_c_read = fp_mult(y_bw, ref_c_read_factor); - lb_read = fp_div(fp_mult(y_bw, lb_factor), FP_INT(2)); - lb_write = lb_read; - bse_read = fp_mult(y_bw, fp_div(rest_factor, FP_INT(2))); - bse_write = bse_read; + + bse_lb_read = fp_div(FP_INT(16 * fps * lcu_per_frame), + FP_INT(bps(1))); + bse_lb_write = bse_lb_read; + + collocated_read = fp_div(FP_INT(lcu_per_frame * + collocated_bytes_per_lcu * fps), FP_INT(bps(1))); + collocated_write = collocated_read; + + bitstream_read = fp_mult(fp_div(FP_INT(bitrate), FP_INT(8)), + FP_INT(bins_to_bit_factor)); + bitstream_write = fp_div(FP_INT(bitrate), FP_INT(8)); + bitstream_write = bitstream_write + bitstream_read; total_read = orig_read + ref_y_read + ref_c_read + - lb_read + bse_read; - total_write = recon_write + lb_write + bse_write; + bse_lb_read + collocated_read + bitstream_read; + total_write = recon_write + bse_lb_write + + collocated_write + bitstream_write; total = total_read + total_write; total = fp_mult(total, overhead_factor); @@ -101,20 +109,21 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d) {"fps", "%d", fps}, {"bitrate (Mbit/sec)", "%lu", bitrate}, {"lcu size", "%d", lcu_size}, + {"collocated byter per lcu", "%d", collocated_bytes_per_lcu}, + {"horizontal search range", "%d", search_range_h}, + {"vertical search range", "%d", search_range_v}, + {"bins to bit factor", "%d", bins_to_bit_factor}, {"DERIVED PARAMETERS", "", DUMP_HEADER_MAGIC}, {"lcu/frame", "%d", lcu_per_frame}, + {"vertical tile size", "%d", vertical_tile_size}, + {"number of tiles", "%d", num_tiles}, {"Y BW", DUMP_FP_FMT, y_bw}, - {"search range", "%d", search_range}, + {"original read factor", DUMP_FP_FMT, orig_read_factor}, {"recon write factor", DUMP_FP_FMT, recon_write_factor}, {"ref read Y factor", DUMP_FP_FMT, ref_y_read_factor}, {"ref read C factor", DUMP_FP_FMT, ref_c_read_factor}, - {"lb factor", DUMP_FP_FMT, lb_factor}, - {"rest factor", DUMP_FP_FMT, rest_factor}, - {"total_read_factor", DUMP_FP_FMT, total_read_factor}, - {"total_write_factor", DUMP_FP_FMT, total_write_factor}, - {"total_factor", DUMP_FP_FMT, total_factor}, {"overhead_factor", DUMP_FP_FMT, overhead_factor}, {"INTERMEDIATE B/W DDR", "", DUMP_HEADER_MAGIC}, @@ -122,10 +131,12 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d) {"recon write", DUMP_FP_FMT, recon_write}, {"ref read Y", DUMP_FP_FMT, ref_y_read}, {"ref read C", DUMP_FP_FMT, ref_c_read}, - {"lb read", DUMP_FP_FMT, lb_read}, - {"lb write", DUMP_FP_FMT, lb_write}, - {"bse read", DUMP_FP_FMT, bse_read}, - {"bse write", DUMP_FP_FMT, bse_write}, + {"BSE lb read", DUMP_FP_FMT, bse_lb_read}, + {"BSE lb write", DUMP_FP_FMT, bse_lb_write}, + {"collocated read", DUMP_FP_FMT, collocated_read}, + {"collocated write", DUMP_FP_FMT, collocated_write}, + {"bitstream read", DUMP_FP_FMT, bitstream_read}, + {"bitstream write", DUMP_FP_FMT, bitstream_write}, {"total read", DUMP_FP_FMT, total_read}, {"total write", DUMP_FP_FMT, total_write}, {"total", DUMP_FP_FMT, total}, @@ -142,24 +153,24 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d) static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d) { /* Decoder parameters */ - int width, height, fps, bitrate, lcu_size; + int width, height, fps, bitrate, lcu_size, + lcu_per_frame, collocated_bytes_per_lcu, + motion_complexity; - /* Derived parameters */ - int lcu_per_frame, motion_complexity; + unsigned int bins_to_bits_factor, vsp_read_factor; fp_t y_bw; bool is_h264_category = true; - fp_t recon_write_factor, ref_read_factor, lb_factor, - rest_factor, opb_factor, - total_read_factor, total_write_factor, - total_factor, overhead_factor; + fp_t recon_write_factor, ref_read_factor, + opb_factor, overhead_factor; /* Output parameters */ fp_t opb_write, recon_write, - ref_read, - lb_read, lb_write, - bse_read, bse_write, - total_read, total_write, - total; + ref_read, + bse_lb_read, bse_lb_write, + collocated_read, collocated_write, + bitstream_read, bitstream_write, + total_read, total_write, + total; unsigned long ret = 0; @@ -167,8 +178,9 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d) overhead_factor = FP(1, 3, 100); recon_write_factor = FP(1, 50, 100); /* L + C */ opb_factor = FP(1, 50, 100); /* L + C */ - lb_factor = FP(1, 13, 100); /* Worst case : H264 1080p = 1.125 */ motion_complexity = 5; /* worst case complexity */ + bins_to_bits_factor = 4; + vsp_read_factor = 6; fps = d->fps; width = max(d->output_width, BASELINE_DIMENSIONS.width); @@ -188,35 +200,42 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d) is_h264_category = false; } + collocated_bytes_per_lcu = lcu_size == 16 ? 16 : + lcu_size == 32 ? 64 : 256; + y_bw = fp_mult(fp_mult(FP_INT(width), FP_INT(height)), FP_INT(fps)); - y_bw = fp_div(y_bw, FP_INT(1000000)); + y_bw = fp_div(y_bw, FP_INT(bps(1))); ref_read_factor = FP(1, 50, 100); /* L + C */ ref_read_factor = fp_mult(ref_read_factor, FP_INT(motion_complexity)); - rest_factor = FP_INT(bitrate) + fp_div(FP_INT(bitrate), FP_INT(8)); - rest_factor = fp_div(rest_factor, y_bw); - - total_read_factor = fp_div(rest_factor, FP_INT(2)) + - fp_div(lb_factor, FP_INT(2)); - total_read_factor = total_read_factor + ref_read_factor; - - total_write_factor = fp_div(rest_factor, FP_INT(2)); - total_write_factor = total_write_factor + - recon_write_factor + opb_factor; - - total_factor = total_read_factor + total_write_factor; - recon_write = fp_mult(y_bw, recon_write_factor); ref_read = fp_mult(y_bw, ref_read_factor); - lb_read = fp_div(fp_mult(y_bw, lb_factor), FP_INT(2)); - lb_write = lb_read; - bse_read = fp_div(fp_mult(y_bw, rest_factor), FP_INT(2)); - bse_write = bse_read; + + if (d->codec == HAL_VIDEO_CODEC_HEVC) + bse_lb_read = FP_INT(lcu_size == 32 ? 64 : + lcu_size == 16 ? 32 : 128); + else + bse_lb_read = FP_INT(128); + bse_lb_read = fp_div(fp_mult(FP_INT(lcu_per_frame * fps), bse_lb_read), + FP_INT(bps(1))); + bse_lb_write = bse_lb_read; + + collocated_read = fp_div(FP_INT(lcu_per_frame * + collocated_bytes_per_lcu * fps), FP_INT(bps(1))); + collocated_write = collocated_read; + + bitstream_read = fp_mult(fp_div(FP_INT(bitrate), FP_INT(8)), + FP_INT(vsp_read_factor)); + bitstream_write = fp_mult(fp_div(FP_INT(bitrate), FP_INT(8)), + FP_INT(bins_to_bits_factor)); + opb_write = fp_mult(y_bw, opb_factor); - total_read = ref_read + lb_read + bse_read; - total_write = recon_write + lb_write + bse_write + opb_write; + total_read = ref_read + bse_lb_read + collocated_read + + bitstream_read; + total_write = recon_write + bse_lb_write + bitstream_write + + opb_write; total = total_read + total_write; total = fp_mult(total, overhead_factor); @@ -229,28 +248,28 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d) {"fps", "%d", fps}, {"bitrate (Mbit/sec)", "%lu", bitrate}, {"lcu size", "%d", lcu_size}, + {"collocated byter per lcu", "%d", collocated_bytes_per_lcu}, + {"vsp read factor", "%d", vsp_read_factor}, + {"bins to bits factor", "%d", bins_to_bits_factor}, + {"motion complexity", "%d", motion_complexity}, {"DERIVED PARAMETERS", "", DUMP_HEADER_MAGIC}, {"lcu/frame", "%d", lcu_per_frame}, {"Y BW", DUMP_FP_FMT, y_bw}, - {"motion complexity", "%d", motion_complexity}, {"recon write factor", DUMP_FP_FMT, recon_write_factor}, {"ref_read_factor", DUMP_FP_FMT, ref_read_factor}, - {"lb factor", DUMP_FP_FMT, lb_factor}, - {"rest factor", DUMP_FP_FMT, rest_factor}, {"opb factor", DUMP_FP_FMT, opb_factor}, - {"total_read_factor", DUMP_FP_FMT, total_read_factor}, - {"total_write_factor", DUMP_FP_FMT, total_write_factor}, - {"total_factor", DUMP_FP_FMT, total_factor}, {"overhead_factor", DUMP_FP_FMT, overhead_factor}, {"INTERMEDIATE B/W DDR", "", DUMP_HEADER_MAGIC}, {"recon write", DUMP_FP_FMT, recon_write}, {"ref read", DUMP_FP_FMT, ref_read}, - {"lb read", DUMP_FP_FMT, lb_read}, - {"lb write", DUMP_FP_FMT, lb_write}, - {"bse read", DUMP_FP_FMT, bse_read}, - {"bse write", DUMP_FP_FMT, bse_write}, + {"BSE lb read", DUMP_FP_FMT, bse_lb_read}, + {"BSE lb write", DUMP_FP_FMT, bse_lb_write}, + {"collocated read", DUMP_FP_FMT, collocated_read}, + {"collocated write", DUMP_FP_FMT, collocated_write}, + {"bitstream read", DUMP_FP_FMT, bitstream_read}, + {"bitstream write", DUMP_FP_FMT, bitstream_write}, {"opb write", DUMP_FP_FMT, opb_write}, {"total read", DUMP_FP_FMT, total_read}, {"total write", DUMP_FP_FMT, total_write}, From 0bca035ef74fcce443ef372aa0d8061b44f77942 Mon Sep 17 00:00:00 2001 From: Chinmay Sawarkar Date: Mon, 17 Aug 2020 13:24:28 -0700 Subject: [PATCH 6/7] msm: vidc: Update cycle count requirement of B frames. Decoder base cycle requirement of B frames has increased to 80. Also, updated cycle count requirement for Encoder HIER B usecase. Change-Id: Iec1bee89be6bb6c18235c2903080025c312bef2d Signed-off-by: Chinmay Sawarkar --- msm/vidc/msm_vidc.c | 1 + msm/vidc/msm_vidc_clocks.c | 12 +++++++++--- msm/vidc/msm_vidc_common.c | 1 + msm/vidc/msm_vidc_internal.h | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/msm/vidc/msm_vidc.c b/msm/vidc/msm_vidc.c index 7f78071d585d..fc479e961e64 100644 --- a/msm/vidc/msm_vidc.c +++ b/msm/vidc/msm_vidc.c @@ -1534,6 +1534,7 @@ void *msm_vidc_open(int core_id, int session_type) inst->bse_vpp_delay = DEFAULT_BSE_VPP_DELAY; inst->first_reconfig_done = 0; inst->active = true; + inst->has_bframe = 0; for (i = SESSION_MSG_INDEX(SESSION_MSG_START); i <= SESSION_MSG_INDEX(SESSION_MSG_END); i++) { diff --git a/msm/vidc/msm_vidc_clocks.c b/msm/vidc/msm_vidc_clocks.c index 0af709fe2d36..7fab1d9ab821 100644 --- a/msm/vidc/msm_vidc_clocks.c +++ b/msm/vidc/msm_vidc_clocks.c @@ -701,9 +701,14 @@ static unsigned long msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst, vpp_cycles = mbs_per_second * vpp_cycles_per_mb / inst->clk_data.work_route; - /* 1.25 factor for IbP GOP structure */ - if (msm_comm_g_ctrl_for_id(inst, V4L2_CID_MPEG_VIDEO_B_FRAMES)) + /* Factor 1.25 for IbP and 1.375 for I1B2b1P GOP structure */ + if (is_hier_b_session(inst)) { + vpp_cycles += (vpp_cycles / 4) + (vpp_cycles / 8); + } else if (msm_comm_g_ctrl_for_id(inst, + V4L2_CID_MPEG_VIDEO_B_FRAMES)) { vpp_cycles += vpp_cycles / 4; + } + /* 21 / 20 is minimum overhead factor */ vpp_cycles += max(div_u64(vpp_cycles, 20), fw_vpp_cycles); /* 1.01 is multi-pipe overhead */ @@ -758,7 +763,8 @@ static unsigned long msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst, /* VSP */ codec = get_v4l2_codec(inst); - base_cycles = inst->clk_data.entry->vsp_cycles; + base_cycles = inst->has_bframe ? + 80 : inst->clk_data.entry->vsp_cycles; vsp_cycles = fps * filled_len * 8; if (codec == V4L2_PIX_FMT_VP9) { diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index 652334c646c4..7b4602af6d92 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -2650,6 +2650,7 @@ static void handle_fbd(enum hal_command_response cmd, void *data) break; case HFI_PICTURE_TYPE_B: mbuf->vvb.flags |= V4L2_BUF_FLAG_BFRAME; + inst->has_bframe = 1; break; case HFI_FRAME_NOTCODED: case HFI_UNUSED_PICT: diff --git a/msm/vidc/msm_vidc_internal.h b/msm/vidc/msm_vidc_internal.h index e04ac940ace2..f2ba25f90463 100644 --- a/msm/vidc/msm_vidc_internal.h +++ b/msm/vidc/msm_vidc_internal.h @@ -574,6 +574,7 @@ struct msm_vidc_inst { u32 first_reconfig_done; u64 last_qbuf_time_ns; bool active; + bool has_bframe; }; extern struct msm_vidc_drv *vidc_driver; From 372b7136f5aaf04b29aa491085573116ee8101ac Mon Sep 17 00:00:00 2001 From: Priyanka Gujjula Date: Wed, 26 Aug 2020 20:48:01 +0530 Subject: [PATCH 7/7] msm: vidc: Add support for 128x32 alignment of NV12 Introduce new internal driver color format V4L2_PIX_FMT_NV12_128 and uapi color format COLOR_FMT_NV12_128 to map with NV12 128x32 alignment. Also, clean up intermediate HAL color formats. Change-Id: Ia28d0f422f2777bda865c2fc6c7499cce9dabb54 Signed-off-by: Priyanka Gujjula --- include/uapi/vidc/media/msm_media_info.h | 42 +++++++++++++++++++++++- include/uapi/vidc/media/msm_vidc_utils.h | 2 ++ msm/vidc/msm_venc.c | 13 ++++++++ msm/vidc/msm_vidc_bus.h | 28 ++++++++-------- msm/vidc/msm_vidc_bus_iris2.c | 4 +-- msm/vidc/msm_vidc_clocks.c | 12 +++---- msm/vidc/msm_vidc_common.c | 39 ++-------------------- msm/vidc/msm_vidc_common.h | 1 - msm/vidc/msm_vidc_internal.h | 2 +- msm/vidc/vidc_hfi_api.h | 23 ------------- 10 files changed, 82 insertions(+), 84 deletions(-) diff --git a/include/uapi/vidc/media/msm_media_info.h b/include/uapi/vidc/media/msm_media_info.h index 309a17bde02d..f9487c93ebeb 100644 --- a/include/uapi/vidc/media/msm_media_info.h +++ b/include/uapi/vidc/media/msm_media_info.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* - * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. */ #ifndef __MSM_MEDIA_INFO_H__ @@ -57,6 +57,41 @@ enum color_fmts { * + UV_Stride * UV_Scanlines, 4096) */ COLOR_FMT_NV12, + /* Venus NV12: + * YUV 4:2:0 image with a plane of 8 bit Y samples followed + * by an interleaved U/V plane containing 8 bit 2x2 subsampled + * colour difference samples. + * + * <-------- Y/UV_Stride --------> + * <------- Width -------> + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^ + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . | | + * Y Y Y Y Y Y Y Y Y Y Y Y . . . . V | + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . V + * U V U V U V U V U V U V . . . . ^ + * U V U V U V U V U V U V . . . . | + * U V U V U V U V U V U V . . . . | + * U V U V U V U V U V U V . . . . UV_Scanlines + * . . . . . . . . . . . . . . . . | + * . . . . . . . . . . . . . . . . V + * . . . . . . . . . . . . . . . . --> Buffer size alignment + * + * Y_Stride : Width aligned to 128 + * UV_Stride : Width aligned to 128 + * Y_Scanlines: Height aligned to 32 + * UV_Scanlines: Height/2 aligned to 16 + * Total size = align(Y_Stride * Y_Scanlines + * + UV_Stride * UV_Scanlines, 4096) + */ + COLOR_FMT_NV12_128, /* Venus NV21: * YUV 4:2:0 image with a plane of 8 bit Y samples followed * by an interleaved V/U plane containing 8 bit 2x2 subsampled @@ -790,6 +825,7 @@ static inline unsigned int VENUS_Y_STRIDE(unsigned int color_fmt, alignment = 512; stride = MSM_MEDIA_ALIGN(width, alignment); break; + case COLOR_FMT_NV12_128: case COLOR_FMT_NV12_UBWC: alignment = 128; stride = MSM_MEDIA_ALIGN(width, alignment); @@ -833,6 +869,7 @@ static inline unsigned int VENUS_UV_STRIDE(unsigned int color_fmt, alignment = 512; stride = MSM_MEDIA_ALIGN(width, alignment); break; + case COLOR_FMT_NV12_128: case COLOR_FMT_NV12_UBWC: alignment = 128; stride = MSM_MEDIA_ALIGN(width, alignment); @@ -875,6 +912,7 @@ static inline unsigned int VENUS_Y_SCANLINES(unsigned int color_fmt, case COLOR_FMT_NV12_512: alignment = 512; break; + case COLOR_FMT_NV12_128: case COLOR_FMT_NV12_UBWC: case COLOR_FMT_P010: alignment = 32; @@ -912,6 +950,7 @@ static inline unsigned int VENUS_UV_SCANLINES(unsigned int color_fmt, case COLOR_FMT_NV12_512: alignment = 256; break; + case COLOR_FMT_NV12_128: case COLOR_FMT_NV12_BPP10_UBWC: case COLOR_FMT_P010_UBWC: case COLOR_FMT_P010: @@ -1212,6 +1251,7 @@ static inline unsigned int VENUS_BUFFER_SIZE(unsigned int color_fmt, case COLOR_FMT_NV12: case COLOR_FMT_P010: case COLOR_FMT_NV12_512: + case COLOR_FMT_NV12_128: y_plane = y_stride * y_sclines; uv_plane = uv_stride * uv_sclines; size = y_plane + uv_plane; diff --git a/include/uapi/vidc/media/msm_vidc_utils.h b/include/uapi/vidc/media/msm_vidc_utils.h index a20d4816841a..0bca1dad6153 100644 --- a/include/uapi/vidc/media/msm_vidc_utils.h +++ b/include/uapi/vidc/media/msm_vidc_utils.h @@ -14,6 +14,8 @@ #define V4L2_PIX_FMT_NV12_UBWC v4l2_fourcc('Q', '1', '2', '8') /* NV12_512 8-bit Y/CbCr 4:2:0 */ #define V4L2_PIX_FMT_NV12_512 v4l2_fourcc('Q', '5', '1', '2') +/* NV12_128 8-bit Y/CbCr 4:2:0 */ +#define V4L2_PIX_FMT_NV12_128 v4l2_fourcc('N', '1', '2', '8') /* NV12 10-bit Y/CbCr 4:2:0 */ #define V4L2_PIX_FMT_NV12_P010_UBWC v4l2_fourcc('Q', '1', '2', 'B') /* UBWC 10-bit Y/CbCr 4:2:0 */ diff --git a/msm/vidc/msm_venc.c b/msm/vidc/msm_venc.c index bf3184fe1040..7808b90810d9 100644 --- a/msm/vidc/msm_venc.c +++ b/msm/vidc/msm_venc.c @@ -1036,6 +1036,11 @@ static struct msm_vidc_format_desc venc_input_formats[] = { .description = "Y/CbCr 4:2:0 10bit", .fourcc = V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS, }, + { + .name = "YCbCr Semiplanar 4:2:0 128 aligned", + .description = "Y/CbCr 4:2:0 128 aligned", + .fourcc = V4L2_PIX_FMT_NV12_128, + }, { .name = "YCbCr Semiplanar 4:2:0 512 aligned", .description = "Y/CbCr 4:2:0 512 aligned", @@ -1070,6 +1075,14 @@ struct msm_vidc_format_constraint enc_pix_format_constraints[] = { .uv_max_stride = 8192, .uv_buffer_alignment = 256, }, + { + .fourcc = V4L2_PIX_FMT_NV12_128, + .num_planes = 2, + .y_max_stride = 8192, + .y_buffer_alignment = 128, + .uv_max_stride = 8192, + .uv_buffer_alignment = 32, + }, { .fourcc = V4L2_PIX_FMT_NV12_512, .num_planes = 2, diff --git a/msm/vidc/msm_vidc_bus.h b/msm/vidc/msm_vidc_bus.h index fb7ab82e5c5c..43dc76ea9ed6 100644 --- a/msm/vidc/msm_vidc_bus.h +++ b/msm/vidc/msm_vidc_bus.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. */ #ifndef __H_MSM_VIDC_BUS_DEFS_H__ @@ -228,30 +228,30 @@ struct lut const *__lut(int width, int height, int fps); fp_t __compression_ratio(struct lut const *entry, int bpp); void __dump(struct dump dump[], int len, u32 sid); -static inline bool __ubwc(enum hal_uncompressed_format f) +static inline bool __ubwc(u32 format) { - switch (f) { - case HAL_COLOR_FORMAT_NV12_UBWC: - case HAL_COLOR_FORMAT_NV12_TP10_UBWC: + switch (format) { + case HFI_COLOR_FORMAT_NV12_UBWC: + case HFI_COLOR_FORMAT_YUV420_TP10_UBWC: return true; default: return false; } } -static inline int __bpp(enum hal_uncompressed_format f, u32 sid) +static inline int __bpp(u32 format, u32 sid) { - switch (f) { - case HAL_COLOR_FORMAT_NV12: - case HAL_COLOR_FORMAT_NV21: - case HAL_COLOR_FORMAT_NV12_UBWC: - case HAL_COLOR_FORMAT_RGBA8888_UBWC: + switch (format) { + case HFI_COLOR_FORMAT_NV12: + case HFI_COLOR_FORMAT_NV21: + case HFI_COLOR_FORMAT_NV12_UBWC: + case HFI_COLOR_FORMAT_RGBA8888_UBWC: return 8; - case HAL_COLOR_FORMAT_NV12_TP10_UBWC: - case HAL_COLOR_FORMAT_P010: + case HFI_COLOR_FORMAT_YUV420_TP10_UBWC: + case HFI_COLOR_FORMAT_P010: return 10; default: - s_vpr_e(sid, "Unsupported colorformat (%x)", f); + s_vpr_e(sid, "Unsupported colorformat (%x)", format); return INT_MAX; } } diff --git a/msm/vidc/msm_vidc_bus_iris2.c b/msm/vidc/msm_vidc_bus_iris2.c index a197bda82b1f..6252fd3ddf27 100644 --- a/msm/vidc/msm_vidc_bus_iris2.c +++ b/msm/vidc/msm_vidc_bus_iris2.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. */ #include "msm_vidc_bus.h" @@ -337,7 +337,7 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d) b_frames_enabled = d->b_frames_enabled; original_color_format = d->num_formats >= 1 ? - d->color_formats[0] : HAL_UNUSED_COLOR; + d->color_formats[0] : HFI_COLOR_FORMAT_NV12_UBWC; original_compression_enabled = __ubwc(original_color_format); diff --git a/msm/vidc/msm_vidc_clocks.c b/msm/vidc/msm_vidc_clocks.c index 64b5f95408f9..bba5b936cc78 100644 --- a/msm/vidc/msm_vidc_clocks.c +++ b/msm/vidc/msm_vidc_clocks.c @@ -438,16 +438,16 @@ int msm_comm_vote_bus(struct msm_vidc_inst *inst) if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_PRIMARY) { vote_data->color_formats[0] = - msm_comm_get_hal_uncompressed( - inst->clk_data.opb_fourcc); + msm_comm_get_hfi_uncompressed( + inst->clk_data.opb_fourcc, inst->sid); vote_data->num_formats = 1; } else { vote_data->color_formats[0] = - msm_comm_get_hal_uncompressed( - inst->clk_data.dpb_fourcc); + msm_comm_get_hfi_uncompressed( + inst->clk_data.dpb_fourcc, inst->sid); vote_data->color_formats[1] = - msm_comm_get_hal_uncompressed( - inst->clk_data.opb_fourcc); + msm_comm_get_hfi_uncompressed( + inst->clk_data.opb_fourcc, inst->sid); vote_data->num_formats = 2; } vote_data->work_mode = inst->clk_data.work_mode; diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index 0cab94351d95..c3ef773a44e5 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -852,48 +852,13 @@ enum hal_video_codec get_hal_codec(int fourcc, u32 sid) return codec; } -enum hal_uncompressed_format msm_comm_get_hal_uncompressed(int fourcc) -{ - enum hal_uncompressed_format format = HAL_UNUSED_COLOR; - - switch (fourcc) { - case V4L2_PIX_FMT_NV12: - format = HAL_COLOR_FORMAT_NV12; - break; - case V4L2_PIX_FMT_NV12_512: - format = HAL_COLOR_FORMAT_NV12_512; - break; - case V4L2_PIX_FMT_NV21: - format = HAL_COLOR_FORMAT_NV21; - break; - case V4L2_PIX_FMT_NV12_UBWC: - format = HAL_COLOR_FORMAT_NV12_UBWC; - break; - case V4L2_PIX_FMT_NV12_TP10_UBWC: - format = HAL_COLOR_FORMAT_NV12_TP10_UBWC; - break; - case V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS: - format = HAL_COLOR_FORMAT_P010; - break; - case V4L2_PIX_FMT_RGBA8888_UBWC: - format = HAL_COLOR_FORMAT_RGBA8888_UBWC; - break; - default: - format = HAL_UNUSED_COLOR; - break; - } - - return format; -} - u32 msm_comm_get_hfi_uncompressed(int fourcc, u32 sid) { u32 format; switch (fourcc) { case V4L2_PIX_FMT_NV12: - format = HFI_COLOR_FORMAT_NV12; - break; + case V4L2_PIX_FMT_NV12_128: case V4L2_PIX_FMT_NV12_512: format = HFI_COLOR_FORMAT_NV12; break; @@ -3718,6 +3683,8 @@ u32 msm_comm_convert_color_fmt(u32 v4l2_fmt, u32 sid) return COLOR_FMT_NV12; case V4L2_PIX_FMT_NV21: return COLOR_FMT_NV21; + case V4L2_PIX_FMT_NV12_128: + return COLOR_FMT_NV12_128; case V4L2_PIX_FMT_NV12_512: return COLOR_FMT_NV12_512; case V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS: diff --git a/msm/vidc/msm_vidc_common.h b/msm/vidc/msm_vidc_common.h index 24a04dd0a257..42467096c2f3 100644 --- a/msm/vidc/msm_vidc_common.h +++ b/msm/vidc/msm_vidc_common.h @@ -344,7 +344,6 @@ int msm_comm_get_v4l2_profile(int fourcc, int profile, u32 sid); int msm_comm_get_v4l2_level(int fourcc, int level, u32 sid); int msm_comm_session_continue(void *instance); int msm_vidc_send_pending_eos_buffers(struct msm_vidc_inst *inst); -enum hal_uncompressed_format msm_comm_get_hal_uncompressed(int fourcc); u32 msm_comm_get_hfi_uncompressed(int fourcc, u32 sid); u32 msm_comm_convert_color_fmt(u32 v4l2_fmt, u32 sid); struct vb2_buffer *msm_comm_get_vb_using_vidc_buffer( diff --git a/msm/vidc/msm_vidc_internal.h b/msm/vidc/msm_vidc_internal.h index 7df2afb76eb1..d4169575060b 100644 --- a/msm/vidc/msm_vidc_internal.h +++ b/msm/vidc/msm_vidc_internal.h @@ -411,7 +411,7 @@ struct vidc_bus_vote_data { u32 sid; enum hal_domain domain; enum hal_video_codec codec; - enum hal_uncompressed_format color_formats[2]; + u32 color_formats[2]; int num_formats; /* 1 = DPB-OPB unified; 2 = split */ int input_height, input_width, bitrate; int output_height, output_width; diff --git a/msm/vidc/vidc_hfi_api.h b/msm/vidc/vidc_hfi_api.h index 84b277520ac8..1193b227ca9f 100644 --- a/msm/vidc/vidc_hfi_api.h +++ b/msm/vidc/vidc_hfi_api.h @@ -129,29 +129,6 @@ enum hal_video_codec { HAL_UNUSED_CODEC = 0x10000000, }; -enum hal_uncompressed_format { - HAL_COLOR_FORMAT_MONOCHROME = 0x00000001, - HAL_COLOR_FORMAT_NV12 = 0x00000002, - HAL_COLOR_FORMAT_NV21 = 0x00000004, - HAL_COLOR_FORMAT_NV12_4x4TILE = 0x00000008, - HAL_COLOR_FORMAT_NV21_4x4TILE = 0x00000010, - HAL_COLOR_FORMAT_YUYV = 0x00000020, - HAL_COLOR_FORMAT_YVYU = 0x00000040, - HAL_COLOR_FORMAT_UYVY = 0x00000080, - HAL_COLOR_FORMAT_VYUY = 0x00000100, - HAL_COLOR_FORMAT_RGB565 = 0x00000200, - HAL_COLOR_FORMAT_BGR565 = 0x00000400, - HAL_COLOR_FORMAT_RGB888 = 0x00000800, - HAL_COLOR_FORMAT_BGR888 = 0x00001000, - HAL_COLOR_FORMAT_NV12_UBWC = 0x00002000, - HAL_COLOR_FORMAT_NV12_TP10_UBWC = 0x00004000, - HAL_COLOR_FORMAT_RGBA8888 = 0x00008000, - HAL_COLOR_FORMAT_RGBA8888_UBWC = 0x00010000, - HAL_COLOR_FORMAT_P010 = 0x00020000, - HAL_COLOR_FORMAT_NV12_512 = 0x00040000, - HAL_UNUSED_COLOR = 0x10000000, -}; - enum hal_ssr_trigger_type { SSR_ERR_FATAL = 1, SSR_SW_DIV_BY_ZERO,