From 5bf834b78e77dcf2d9cc0e832b20ad6aa142fb96 Mon Sep 17 00:00:00 2001 From: Priyanka Gujjula Date: Tue, 20 Oct 2020 14:36:32 +0530 Subject: [PATCH 1/9] msm: vidc: Update num_ref calc and limit max_layer Limit max number of temporal layers to 4 if hybrid_hp is not enabled as per POR. Also, inline num_ref calculations with FW. Change-Id: Iad1deaf757a8aa3715b2dce861b1454faeed7a39 Signed-off-by: Priyanka Gujjula --- msm/vidc/msm_venc.c | 6 ++++++ msm/vidc/msm_vidc_buffer_calculations.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/msm/vidc/msm_venc.c b/msm/vidc/msm_venc.c index 55e05e41e5a6..b13866942db4 100644 --- a/msm/vidc/msm_venc.c +++ b/msm/vidc/msm_venc.c @@ -3809,6 +3809,12 @@ int msm_venc_set_hp_max_layer(struct msm_vidc_inst *inst) __func__); return rc; } + if (!inst->hybrid_hp && max_layer->val > 4) { + update_ctrl(max_layer, 0, inst->sid); + s_vpr_h(inst->sid, + "%s: Hier-P requested beyond max capability\n", __func__); + return 0; + } /* * We send enhancement layer count to FW, diff --git a/msm/vidc/msm_vidc_buffer_calculations.c b/msm/vidc/msm_vidc_buffer_calculations.c index 0d63bca7395d..d19ed2b32cf1 100644 --- a/msm/vidc/msm_vidc_buffer_calculations.c +++ b/msm/vidc/msm_vidc_buffer_calculations.c @@ -497,13 +497,13 @@ int msm_vidc_get_num_ref_frames(struct msm_vidc_inst *inst) codec = get_v4l2_codec(inst); /* LTR and B - frame not supported with hybrid HP */ if (inst->hybrid_hp) - num_ref = (max_layer->val - 1); + num_ref = max_layer->val >> 1; else if (codec == V4L2_PIX_FMT_HEVC) num_ref = ((max_layer->val + 1) / 2) + ltr_count; - else if ((codec == V4L2_PIX_FMT_H264) && (max_layer->val <= 4)) - num_ref = ((1 << (max_layer->val - 1)) - 1) + ltr_count; + else if ((codec == V4L2_PIX_FMT_H264) && (max_layer->val < 4)) + num_ref = (max_layer->val - 1) + ltr_count; else - num_ref = ((max_layer->val + 1) / 2) + ltr_count; + num_ref = max_layer->val + ltr_count; } if (is_hier_b_session(inst)) { From 1fc8b2829c24d295861479f0e979afb8fc644a02 Mon Sep 17 00:00:00 2001 From: Chandrakant I Viraktamath Date: Wed, 10 Jun 2020 10:26:51 +0530 Subject: [PATCH 2/9] msm: vidc: Fix mbpf calculation for active session Fix macro block per frame calculation by not considering sessions which have state greater than or equal to MSM_VIDC_STOP_DONE. Change-Id: Ie25e52e946386fcf226b0f9c073c1b022cf1ac0c Signed-off-by: Chandrakant I Viraktamath --- msm/vidc/msm_vidc_common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index 3bab57959bb5..d1e8cdf99715 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -5768,8 +5768,9 @@ static int msm_vidc_check_mbpf_supported(struct msm_vidc_inst *inst) mutex_lock(&core->lock); list_for_each_entry(temp, &core->instances, list) { - /* ignore invalid session */ - if (temp->state == MSM_VIDC_CORE_INVALID) + /* ignore invalid and completed session */ + if (temp->state == MSM_VIDC_CORE_INVALID || + temp->state >= MSM_VIDC_STOP_DONE) continue; /* ignore thumbnail session */ if (is_thumbnail_session(temp)) From 3cd260e651a0878563c1582e6152d0511f1fd29e Mon Sep 17 00:00:00 2001 From: Govindaraj Rajagopal Date: Wed, 2 Dec 2020 20:07:32 +0530 Subject: [PATCH 3/9] msm: vidc: return appropriate error code for overload errors Return -ENOMEM instead of -EBUSY for hardware overload errors. Change-Id: I3b1c54e2035969c929bb2fdaea9e981e9c43ab32 Signed-off-by: Govindaraj Rajagopal --- msm/vidc/msm_vidc_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index eccec057b747..cf2c71b06be4 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -1777,7 +1777,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data) } else if (rc == -ENOTSUPP) { msm_vidc_queue_v4l2_event(inst, V4L2_EVENT_MSM_VIDC_HW_UNSUPPORTED); - } else if (rc == -EBUSY) { + } else if (rc == -ENOMEM) { msm_vidc_queue_v4l2_event(inst, V4L2_EVENT_MSM_VIDC_HW_OVERLOAD); } @@ -5782,7 +5782,7 @@ static int msm_vidc_check_mbpf_supported(struct msm_vidc_inst *inst) if (mbpf > core->resources.max_mbpf) { msm_vidc_print_running_insts(inst->core); - return -EBUSY; + return -ENOMEM; } return 0; @@ -5933,7 +5933,7 @@ static int msm_vidc_check_mbps_supported(struct msm_vidc_inst *inst) "H/W is overloaded. needed: %d max: %d\n", video_load, max_video_load); msm_vidc_print_running_insts(inst->core); - return -EBUSY; + return -ENOMEM; } if (video_load + image_load > max_video_load + max_image_load) { @@ -5942,7 +5942,7 @@ static int msm_vidc_check_mbps_supported(struct msm_vidc_inst *inst) video_load, image_load, max_video_load, max_image_load); msm_vidc_print_running_insts(inst->core); - return -EBUSY; + return -ENOMEM; } } return 0; From ae4c88ee646856098027615985d38c758d15d3e0 Mon Sep 17 00:00:00 2001 From: Vikash Garodia Date: Thu, 3 Dec 2020 13:51:24 +0530 Subject: [PATCH 4/9] msm: vidc: update all intra to allow more than 30 fps Certain clients enables all intra tests for 720p @42 fps. To allow such configuration, which is within the allowed specification, extend the capability. Change-Id: I0a0247e95bb040635c92404c5a342c92c340154c Signed-off-by: Vikash Garodia --- msm/vidc/msm_vidc_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msm/vidc/msm_vidc_platform.c b/msm/vidc/msm_vidc_platform.c index 7c5f1a2b1ce5..be9fad4f1300 100644 --- a/msm/vidc/msm_vidc_platform.c +++ b/msm/vidc/msm_vidc_platform.c @@ -289,7 +289,7 @@ static struct msm_vidc_codec_capability holi_capabilities[] = { {CAP_SECURE_BITRATE, DOMAINS_ALL, CODECS_ALL, 1, 35000000, 1, 20000000}, /* All intra encoding usecase specific */ - {CAP_ALLINTRA_MAX_FPS, ENC, H264|HEVC, 1, 30, 1, 30}, + {CAP_ALLINTRA_MAX_FPS, ENC, H264|HEVC, 1, 60, 1, 30}, /* Image specific */ {CAP_HEVC_IMAGE_FRAME_WIDTH, ENC, HEVC, 128, 512, 2, 512}, From a30dfea1551316cb9ee5cac1e385de2c33010fd6 Mon Sep 17 00:00:00 2001 From: Vikash Garodia Date: Thu, 3 Dec 2020 14:11:43 +0530 Subject: [PATCH 5/9] msm: vidc: avoid access to unwanted register While processing the response from video hardware, video driver is accessing a register which does not exist. It is even not needed for functionality purpose. Removing the access for the same. Change-Id: Ib4fec718d2f057860878bf8928b96fb46be47b13 Signed-off-by: Vikash Garodia --- msm/vidc/hfi_ar50_lt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/msm/vidc/hfi_ar50_lt.c b/msm/vidc/hfi_ar50_lt.c index f883cdfc8d26..85b4909342e7 100644 --- a/msm/vidc/hfi_ar50_lt.c +++ b/msm/vidc/hfi_ar50_lt.c @@ -87,7 +87,6 @@ #define VIDC_WRAPPER_INTR_MASK_A2HCPU_BMSK_AR50_LT 0x4 #define VIDC_WRAPPER_INTR_MASK_A2HCPU_SHFT_AR50_LT 0x2 -#define VIDC_WRAPPER_INTR_CLEAR_AR50_LT (VIDC_WRAPPER_BASE_OFFS_AR50_LT + 0x14) #define VIDC_WRAPPER_INTR_CLEAR_A2HWD_BMSK_AR50_LT 0x10 #define VIDC_WRAPPER_INTR_CLEAR_A2HWD_SHFT_AR50_LT 0x4 #define VIDC_WRAPPER_INTR_CLEAR_A2H_BMSK_AR50_LT 0x4 @@ -246,7 +245,6 @@ void __core_clear_interrupt_ar50_lt(struct venus_hfi_device *device) } __write_register(device, VIDC_CPU_CS_A2HSOFTINTCLR_AR50_LT, 1, DEFAULT_SID); - __write_register(device, VIDC_WRAPPER_INTR_CLEAR_AR50_LT, intr_status, DEFAULT_SID); } int __boot_firmware_ar50_lt(struct venus_hfi_device *device, u32 sid) From 8929fa4bcc4283e54e4b05d71b387857c168a02a Mon Sep 17 00:00:00 2001 From: Shi Zhongbo Date: Tue, 8 Dec 2020 14:15:21 +0800 Subject: [PATCH 6/9] msm: vidc: limit max and min auto frame rate Limit auto frame rate to [1,platform frame rate capability] before sending to firmware. Change-Id: I96dc4b8d76b7752a76f6c15dcb6b20817857372f Signed-off-by: Shi Zhongbo --- msm/vidc/msm_vidc_common.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index cf2c71b06be4..088f46acec9f 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -7768,6 +7768,8 @@ u32 msm_comm_calc_framerate(struct msm_vidc_inst *inst, { u32 framerate = inst->clk_data.frame_rate; u32 interval; + struct msm_vidc_capability *capability; + capability = &inst->capability; if (timestamp_us <= prev_ts) { s_vpr_e(inst->sid, "%s: invalid ts %lld, prev ts %lld\n", @@ -7775,8 +7777,12 @@ u32 msm_comm_calc_framerate(struct msm_vidc_inst *inst, return framerate; } interval = (u32)(timestamp_us - prev_ts); - framerate = ((1000000 + interval / 2) / interval) << 16; - return framerate; + framerate = (1000000 + interval / 2) / interval; + if (framerate > capability->cap[CAP_FRAMERATE].max) + framerate = capability->cap[CAP_FRAMERATE].max; + if (framerate < 1) + framerate = 1; + return framerate << 16; } u32 msm_comm_get_max_framerate(struct msm_vidc_inst *inst) From 9aa7ae0ed15c4c3b04f95cb7104cc621179d31c8 Mon Sep 17 00:00:00 2001 From: Priyanka Gujjula Date: Thu, 10 Dec 2020 20:40:12 +0530 Subject: [PATCH 7/9] msm: vidc: Update encoder o/p buffer size calc Update enc o/p buffer size calc inline with FW calculations. Change-Id: Ie5aae40cb51909446430b7b8d5ff9405bbcd7f8b Signed-off-by: Priyanka Gujjula --- msm/vidc/msm_vidc_buffer_calculations.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/msm/vidc/msm_vidc_buffer_calculations.c b/msm/vidc/msm_vidc_buffer_calculations.c index ed1d23c84e20..8c849bc7d162 100644 --- a/msm/vidc/msm_vidc_buffer_calculations.c +++ b/msm/vidc/msm_vidc_buffer_calculations.c @@ -264,6 +264,7 @@ #define HFI_VENUS_HEIGHT_ALIGNMENT 32 #define SYSTEM_LAL_TILE10 192 +#define NUM_MBS_360P (((480 + 15) >> 4) * ((360 + 15) >> 4)) #define NUM_MBS_720P (((1280 + 15) >> 4) * ((720 + 15) >> 4)) #define NUM_MBS_4k (((4096 + 15) >> 4) * ((2304 + 15) >> 4)) #define MB_SIZE_IN_PIXEL (16 * 16) @@ -985,8 +986,8 @@ u32 msm_vidc_calculate_enc_output_frame_size(struct msm_vidc_inst *inst) /* * Encoder output size calculation: 32 Align width/height * For CQ or heic session : YUVsize * 2 - * For resolution < 720p : YUVsize * 4 - * For resolution > 720p & <= 4K : YUVsize / 2 + * For resolution <= 480x360p : YUVsize * 2 + * For resolution > 360p & <= 4K : YUVsize / 2 * For resolution > 4k : YUVsize / 4 * Initially frame_size = YUVsize * 2; */ @@ -1003,8 +1004,8 @@ u32 msm_vidc_calculate_enc_output_frame_size(struct msm_vidc_inst *inst) is_grid_session(inst) || is_image_session(inst)) goto calc_done; - if (mbs_per_frame < NUM_MBS_720P) - frame_size = frame_size << 1; + if (mbs_per_frame <= NUM_MBS_360P) + goto calc_done; /* Default frame_size = YUVsize * 2 */ else if (mbs_per_frame <= NUM_MBS_4k) frame_size = frame_size >> 2; else From e8004219db5dfc8cfa0bf082ccf0352c29888f19 Mon Sep 17 00:00:00 2001 From: Priyanka Gujjula Date: Tue, 15 Dec 2020 13:18:59 +0530 Subject: [PATCH 8/9] msm: vidc: Fix criteria for hierp num_ref calc [1] num_ref for hierp has to be calculated only if max_layer value is > 1. Since max_layer value 0/1 indicates absence of layer encoding. [2] Fix hybrid_hp num_ref calculation inline with FW calc. Change-Id: I507d58c33529e5976974cc2d5a6e2d3fd8c55026 --- msm/vidc/msm_vidc_buffer_calculations.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/msm/vidc/msm_vidc_buffer_calculations.c b/msm/vidc/msm_vidc_buffer_calculations.c index ed1d23c84e20..973eff400d71 100644 --- a/msm/vidc/msm_vidc_buffer_calculations.c +++ b/msm/vidc/msm_vidc_buffer_calculations.c @@ -493,11 +493,11 @@ int msm_vidc_get_num_ref_frames(struct msm_vidc_inst *inst) max_layer = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VIDEO_HEVC_MAX_HIER_CODING_LAYER); if (frame_t->val == V4L2_MPEG_VIDEO_HEVC_HIERARCHICAL_CODING_P && - max_layer->val > 0) { + max_layer->val > 1) { codec = get_v4l2_codec(inst); /* LTR and B - frame not supported with hybrid HP */ if (inst->hybrid_hp) - num_ref = max_layer->val >> 1; + num_ref = (max_layer->val + 1) >> 1; else if (codec == V4L2_PIX_FMT_HEVC) num_ref = ((max_layer->val + 1) / 2) + ltr_count; else if ((codec == V4L2_PIX_FMT_H264) && (max_layer->val < 4)) From cf15569f3dfef16f94a38e5f27a4795c12f02a8a Mon Sep 17 00:00:00 2001 From: Shi Zhongbo Date: Thu, 17 Dec 2020 13:03:39 +0800 Subject: [PATCH 9/9] msm: vdec: update clock data frame rate Update clock data frame rate to client's set value for mbps calculation so as to reject sessions out of mbps capability. Change-Id: I62559172b71fb4d2e911c16be7f07110e53f23a1 Signed-off-by: Shi Zhongbo --- msm/vidc/msm_vdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/msm/vidc/msm_vdec.c b/msm/vidc/msm_vdec.c index 7d4b1de3b252..2e9780442231 100644 --- a/msm/vidc/msm_vdec.c +++ b/msm/vidc/msm_vdec.c @@ -904,7 +904,9 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDC_VIDEO_DECODE_ORDER: case V4L2_CID_MPEG_VIDC_VIDEO_CONCEAL_COLOR_8BIT: case V4L2_CID_MPEG_VIDC_VIDEO_CONCEAL_COLOR_10BIT: + break; case V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE: + inst->clk_data.frame_rate = ctrl->val; break; case V4L2_CID_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE: inst->flags &= ~VIDC_THUMBNAIL;