diff options
author | JohnnLee <johnnlee@google.com> | 2022-01-05 18:37:47 +0800 |
---|---|---|
committer | JohnnLee <johnnlee@google.com> | 2022-01-05 18:38:26 +0800 |
commit | cd1450cf06f28a48883526cd660d58f37480123b (patch) | |
tree | 02521ee8f1c1fa43ad7dbcfa5d6ec3cb523e757e | |
parent | caba428914d8efa19ee397d0c6464e1032eb0b08 (diff) | |
parent | 6beff9c0a18a58b37773d759cb3b380c8eb7998e (diff) | |
download | video-driver-cd1450cf06f28a48883526cd660d58f37480123b.tar.gz |
Merge branch 'LA.UM.9.12.C10.11.00.00.840.201' via branch 'qcom-msm-4.19-7250' into android-msm-pixel-4.19android-t-beta-2_r0.3android-msm-redbull-4.19-t-beta-2
Bug: 210578498
Signed-off-by: JohnnLee <johnnlee@google.com>
Change-Id: I99bbe71e6ccce56296068bb45df6cb49df89033a
-rw-r--r-- | msm/vidc/hfi_common.c | 49 | ||||
-rw-r--r-- | msm/vidc/msm_cvp_internal.c | 6 | ||||
-rw-r--r-- | msm/vidc/msm_v4l2_vidc.c | 16 | ||||
-rw-r--r-- | msm/vidc/msm_vdec.c | 11 | ||||
-rw-r--r-- | msm/vidc/msm_venc.c | 11 | ||||
-rw-r--r-- | msm/vidc/msm_vidc_buffer_calculations.c | 4 | ||||
-rw-r--r-- | msm/vidc/msm_vidc_clocks.c | 45 | ||||
-rw-r--r-- | msm/vidc/msm_vidc_clocks.h | 7 | ||||
-rw-r--r-- | msm/vidc/msm_vidc_common.c | 19 | ||||
-rw-r--r-- | msm/vidc/msm_vidc_debug.c | 24 | ||||
-rw-r--r-- | msm/vidc/msm_vidc_debug.h | 24 | ||||
-rw-r--r-- | msm/vidc/msm_vidc_internal.h | 15 | ||||
-rw-r--r-- | msm/vidc/msm_vidc_platform.c | 31 | ||||
-rw-r--r-- | msm/vidc/msm_vidc_res_parse.c | 3 |
14 files changed, 180 insertions, 85 deletions
diff --git a/msm/vidc/hfi_common.c b/msm/vidc/hfi_common.c index 6cdceac..3c19b8f 100644 --- a/msm/vidc/hfi_common.c +++ b/msm/vidc/hfi_common.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include <asm/dma-iommu.h> @@ -990,20 +990,22 @@ static void __set_registers(struct venus_hfi_device *device, u32 sid) } } -static int __vote_bandwidth(struct bus_info *bus, - unsigned long bw_kbps, u32 sid) +static int __vote_bandwidth(struct bus_info *bus, unsigned long ab_kbps, + unsigned long ib_kbps, u32 sid) { int rc = 0; - uint64_t ab = 0; + uint64_t ab = 0, ib = 0; /* Bus Driver expects values in Bps */ - ab = bw_kbps * 1000; - s_vpr_p(sid, "Voting bus %s to ab %llu bps\n", bus->name, ab); - rc = msm_bus_scale_update_bw(bus->client, ab, 0); + ab = ab_kbps * 1000; + ib = ib_kbps * 1000; + s_vpr_p(sid, "Voting bus %s to ab %llu ib %llu bps\n", + bus->name, ab, ib); + rc = msm_bus_scale_update_bw(bus->client, ab, ib); if (rc) - s_vpr_e(sid, "Failed voting bus %s to ab %llu, rc=%d\n", - bus->name, ab, rc); - + s_vpr_e(sid, + "Failed voting bus %s to ab %llu ib %llu bps rc=%d\n", + bus->name, ab, ib, rc); return rc; } @@ -1015,7 +1017,7 @@ int __unvote_buses(struct venus_hfi_device *device, u32 sid) device->bus_vote = DEFAULT_BUS_VOTE; venus_hfi_for_each_bus(device, bus) { - rc = __vote_bandwidth(bus, 0, sid); + rc = __vote_bandwidth(bus, 0, 0, sid); if (rc) goto err_unknown_device; } @@ -1029,7 +1031,7 @@ static int __vote_buses(struct venus_hfi_device *device, { int rc = 0; struct bus_info *bus = NULL; - unsigned long bw_kbps = 0, bw_prev = 0; + unsigned long ab_kbps = 0, ib_kbps = 0, bw_prev = 0; enum vidc_bus_type type; venus_hfi_for_each_bus(device, bus) { @@ -1037,33 +1039,36 @@ static int __vote_buses(struct venus_hfi_device *device, type = get_type_frm_name(bus->name); if (type == DDR) { - bw_kbps = bw_ddr; + ab_kbps = bw_ddr; bw_prev = device->bus_vote.total_bw_ddr; } else if (type == LLCC) { - bw_kbps = bw_llcc; + ab_kbps = bw_llcc; bw_prev = device->bus_vote.total_bw_llcc; } else { - bw_kbps = bus->range[1]; + ab_kbps = bus->range[1]; bw_prev = device->bus_vote.total_bw_ddr ? - bw_kbps : 0; + ab_kbps : 0; } /* ensure freq is within limits */ - bw_kbps = clamp_t(typeof(bw_kbps), bw_kbps, + ab_kbps = clamp_t(typeof(ab_kbps), ab_kbps, bus->range[0], bus->range[1]); - if (TRIVIAL_BW_CHANGE(bw_kbps, bw_prev) && bw_prev) { + if (TRIVIAL_BW_CHANGE(ab_kbps, bw_prev) && bw_prev) { s_vpr_l(sid, "Skip voting bus %s to %llu bps", - bus->name, bw_kbps * 1000); + bus->name, ab_kbps * 1000); continue; } - rc = __vote_bandwidth(bus, bw_kbps, sid); + if (device->res->vpu_ver == VPU_VERSION_AR50_LITE) + ib_kbps = 2 * ab_kbps; + + rc = __vote_bandwidth(bus, ab_kbps, ib_kbps, sid); if (type == DDR) - device->bus_vote.total_bw_ddr = bw_kbps; + device->bus_vote.total_bw_ddr = ab_kbps; else if (type == LLCC) - device->bus_vote.total_bw_llcc = bw_kbps; + device->bus_vote.total_bw_llcc = ab_kbps; } else { s_vpr_e(sid, "No BUS to Vote\n"); } diff --git a/msm/vidc/msm_cvp_internal.c b/msm/vidc/msm_cvp_internal.c index 3432484..82fc710 100644 --- a/msm/vidc/msm_cvp_internal.c +++ b/msm/vidc/msm_cvp_internal.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. */ #include "msm_cvp_internal.h" @@ -233,14 +233,14 @@ static int msm_cvp_scale_clocks_and_bus(struct msm_vidc_inst *inst) return -EINVAL; } - rc = msm_vidc_set_clocks(inst->core, inst->sid); + rc = msm_vidc_set_clocks(inst->core, inst->sid, false); if (rc) { s_vpr_e(inst->sid, "%s: failed set_clocks for inst %pK\n", __func__, inst); goto exit; } - rc = msm_comm_vote_bus(inst); + rc = msm_comm_vote_bus(inst, false); if (rc) { s_vpr_e(inst->sid, "%s: failed vote_bus for inst %pK\n", __func__, inst); diff --git a/msm/vidc/msm_v4l2_vidc.c b/msm/vidc/msm_v4l2_vidc.c index 3beb77c..250b480 100644 --- a/msm/vidc/msm_v4l2_vidc.c +++ b/msm/vidc/msm_v4l2_vidc.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include <linux/debugfs.h> @@ -491,6 +491,11 @@ static int msm_vidc_probe_vidc_device(struct platform_device *pdev) return -ENOMEM; core->platform_data = vidc_get_drv_data(&pdev->dev); + if(!core->platform_data) { + d_vpr_e("Failed to get platform data\n"); + rc = -EINVAL; + goto err_core_init; + } dev_set_drvdata(&pdev->dev, core); /* If the sku_version != the DT node's sku-index, then return as a successful @@ -515,6 +520,12 @@ static int msm_vidc_probe_vidc_device(struct platform_device *pdev) core->id = MSM_VIDC_CORE_VENUS; + vidc_driver->ctxt = kcalloc(core->platform_data->max_inst_count, + sizeof(*vidc_driver->ctxt), GFP_KERNEL); + if (!vidc_driver->ctxt) + goto err_vidc_context; + vidc_driver->num_ctxt = core->platform_data->max_inst_count; + rc = v4l2_device_register(&pdev->dev, &core->v4l2_dev); if (rc) { d_vpr_e("Failed to register v4l2 device\n"); @@ -627,6 +638,8 @@ err_enc: err_dec: v4l2_device_unregister(&core->v4l2_dev); err_v4l2_register: + kfree(vidc_driver->ctxt); +err_vidc_context: sysfs_remove_group(&pdev->dev.kobj, &msm_vidc_core_attr_group); err_core_init: dev_set_drvdata(&pdev->dev, NULL); @@ -712,6 +725,7 @@ static int msm_vidc_remove(struct platform_device *pdev) mutex_destroy(&core->resources.cb_lock); mutex_destroy(&core->lock); kfree(core); + kfree(vidc_driver->ctxt); return rc; } diff --git a/msm/vidc/msm_vdec.c b/msm/vidc/msm_vdec.c index 54923e1..7b7b52c 100644 --- a/msm/vidc/msm_vdec.c +++ b/msm/vidc/msm_vdec.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include <linux/slab.h> @@ -927,6 +927,15 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE: if (!is_valid_operating_rate(inst, ctrl->val)) break; + /* + * reset the resources like clock and bus as per the updated + * flag. When switch from TURBO to normal, need not wait for + * next qbuf to scale down the resources. + */ + if ((inst->flags & VIDC_TURBO) && (ctrl->val != INT_MAX)) { + inst->flags &= ~VIDC_TURBO; + msm_comm_reset_clocks_and_bus(inst); + } inst->flags &= ~VIDC_TURBO; if (ctrl->val == INT_MAX) inst->flags |= VIDC_TURBO; diff --git a/msm/vidc/msm_venc.c b/msm/vidc/msm_venc.c index 1d1c606..cab9a56 100644 --- a/msm/vidc/msm_venc.c +++ b/msm/vidc/msm_venc.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include <linux/slab.h> #include "msm_venc.h" @@ -1205,6 +1205,7 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst) inst->buff_req.buffer[13].buffer_type = HAL_BUFFER_INTERNAL_RECON; msm_vidc_init_buffer_size_calculators(inst); inst->static_rotation_flip_enabled = false; + inst->hdr10_sei_enabled = false; return rc; } @@ -1699,6 +1700,7 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) u32 info_type = ((u32)ctrl->val >> 28) & 0xF; u32 val = (ctrl->val & 0xFFFFFFF); + inst->hdr10_sei_enabled = true; s_vpr_h(sid, "Ctrl:%d, HDR Info with value %u (%#X)", info_type, val, ctrl->val); switch (info_type) { @@ -3206,6 +3208,10 @@ int msm_venc_set_slice_control_mode(struct msm_vidc_inst *inst) /* Update Slice Config */ mb_per_frame = NUM_MBS_PER_FRAME(output_height, output_width); + if (codec == V4L2_PIX_FMT_HEVC) + mb_per_frame = + NUM_MBS_PER_FRAME_HEVC(output_height, output_width); + mbps = NUM_MBS_PER_SEC(output_height, output_width, fps); if (slice_mode == HFI_MULTI_SLICE_BY_MB_COUNT) { @@ -4383,7 +4389,8 @@ int msm_venc_set_hdr_info(struct msm_vidc_inst *inst) } hdev = inst->core->device; - if (get_v4l2_codec(inst) != V4L2_PIX_FMT_HEVC) + if (get_v4l2_codec(inst) != V4L2_PIX_FMT_HEVC || + !inst->hdr10_sei_enabled) return 0; profile = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_HEVC_PROFILE); diff --git a/msm/vidc/msm_vidc_buffer_calculations.c b/msm/vidc/msm_vidc_buffer_calculations.c index a2d2aa3..1382255 100644 --- a/msm/vidc/msm_vidc_buffer_calculations.c +++ b/msm/vidc/msm_vidc_buffer_calculations.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. */ #include "msm_vidc_debug.h" @@ -1043,7 +1043,7 @@ u32 msm_vidc_calculate_enc_output_frame_size(struct msm_vidc_inst *inst) goto calc_done; if (mbs_per_frame <= NUM_MBS_480P) - goto calc_done; /* Default frame_size = YUVsize * 2 */ + (void)frame_size; /* Default frame_size = YUVsize * 2 */ else if (mbs_per_frame <= NUM_MBS_4k) frame_size = frame_size >> 2; else diff --git a/msm/vidc/msm_vidc_clocks.c b/msm/vidc/msm_vidc_clocks.c index f7797ea..af0fd9a 100644 --- a/msm/vidc/msm_vidc_clocks.c +++ b/msm/vidc/msm_vidc_clocks.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. */ #include "msm_vidc_common.h" @@ -274,7 +274,7 @@ static int fill_dynamic_stats(struct msm_vidc_inst *inst, return 0; } -int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid) +int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid, bool force_reset) { int rc = 0; struct msm_vidc_inst *inst = NULL; @@ -306,7 +306,7 @@ int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid) } mutex_unlock(&inst->registeredbufs.lock); - if ((!filled_len || !device_addr) && + if ((!filled_len || !device_addr) && !force_reset && (inst->session_type != MSM_VIDC_CVP)) { s_vpr_l(sid, "%s: no input\n", __func__); continue; @@ -333,7 +333,7 @@ int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid) return rc; } -int msm_comm_vote_bus(struct msm_vidc_inst *inst) +int msm_comm_vote_bus(struct msm_vidc_inst *inst, bool force_reset) { int rc = 0; struct msm_vidc_core *core; @@ -368,7 +368,7 @@ int msm_comm_vote_bus(struct msm_vidc_inst *inst) } mutex_unlock(&inst->registeredbufs.lock); - if ((!filled_len || !device_addr) && + if ((!filled_len || !device_addr) && !force_reset && (inst->session_type != MSM_VIDC_CVP)) { s_vpr_l(inst->sid, "%s: no input\n", __func__); return 0; @@ -457,7 +457,7 @@ int msm_comm_vote_bus(struct msm_vidc_inst *inst) call_core_op(core, calc_bw, vote_data); } - rc = msm_comm_set_buses(core, inst->sid); + rc = msm_comm_set_buses(core, inst->sid, force_reset); return rc; } @@ -877,7 +877,7 @@ static unsigned long msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst, return (unsigned long) freq; } -int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid) +int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid, bool force_reset) { struct hfi_device *hdev; unsigned long freq_core_1 = 0, freq_core_2 = 0, rate = 0; @@ -915,7 +915,7 @@ int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid) } mutex_unlock(&inst->registeredbufs.lock); - if (!filled_len || !device_addr) { + if ((!filled_len || !device_addr) && !force_reset) { s_vpr_l(sid, "%s: no input\n", __func__); continue; } @@ -988,7 +988,7 @@ int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid) return rc; } -int msm_comm_scale_clocks(struct msm_vidc_inst *inst) +int msm_comm_scale_clocks(struct msm_vidc_inst *inst, bool force_reset) { struct msm_vidc_buffer *temp, *next; unsigned long freq = 0; @@ -1013,7 +1013,7 @@ int msm_comm_scale_clocks(struct msm_vidc_inst *inst) } mutex_unlock(&inst->registeredbufs.lock); - if (!filled_len || !device_addr) { + if ((!filled_len || !device_addr) && !force_reset) { s_vpr_l(inst->sid, "%s: no input\n", __func__); return 0; } @@ -1032,7 +1032,7 @@ int msm_comm_scale_clocks(struct msm_vidc_inst *inst) msm_dcvs_scale_clocks(inst, freq); } - msm_vidc_set_clocks(inst->core, inst->sid); + msm_vidc_set_clocks(inst->core, inst->sid, force_reset); return 0; } @@ -1055,13 +1055,13 @@ int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst, bool do_bw_calc) inst->active = true; } - if (msm_comm_scale_clocks(inst)) { + if (msm_comm_scale_clocks(inst, false)) { s_vpr_e(inst->sid, "Failed to scale clocks. May impact performance\n"); } if (do_bw_calc) { - if (msm_comm_vote_bus(inst)) { + if (msm_comm_vote_bus(inst, false)) { s_vpr_e(inst->sid, "Failed to scale DDR bus. May impact perf\n"); } @@ -1070,6 +1070,25 @@ int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst, bool do_bw_calc) return 0; } +int msm_comm_reset_clocks_and_bus(struct msm_vidc_inst *inst) +{ + if (!inst) { + d_vpr_e("%s: invalid params %pK\n", __func__, inst); + return -EINVAL; + } + + if (msm_comm_scale_clocks(inst, true)) { + s_vpr_e(inst->sid, + "Failed to reset clocks. May impact performance\n"); + } + + if (msm_comm_vote_bus(inst, true)) { + s_vpr_e(inst->sid, + "Failed to reset DDR bus. May impact perf\n"); + } + return 0; +} + int msm_dcvs_try_enable(struct msm_vidc_inst *inst) { bool disable_hfr_dcvs = false; diff --git a/msm/vidc/msm_vidc_clocks.h b/msm/vidc/msm_vidc_clocks.h index 7515a4b..0cb3037 100644 --- a/msm/vidc/msm_vidc_clocks.h +++ b/msm/vidc/msm_vidc_clocks.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. */ #ifndef _MSM_VIDC_CLOCKS_H_ @@ -9,8 +9,8 @@ void msm_clock_data_reset(struct msm_vidc_inst *inst); void msm_dcvs_reset(struct msm_vidc_inst *inst); -int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid); -int msm_comm_vote_bus(struct msm_vidc_inst *inst); +int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid, bool force_reset); +int msm_comm_vote_bus(struct msm_vidc_inst *inst, bool force_reset); int msm_dcvs_try_enable(struct msm_vidc_inst *inst); bool res_is_less_than(u32 width, u32 height, u32 ref_width, u32 ref_height); bool res_is_greater_than(u32 width, u32 height, u32 ref_width, u32 ref_height); @@ -21,6 +21,7 @@ bool res_is_greater_than_or_equal_to(u32 width, u32 height, int msm_vidc_get_mbs_per_frame(struct msm_vidc_inst *inst); int msm_vidc_get_fps(struct msm_vidc_inst *inst); int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst, bool do_bw_calc); +int msm_comm_reset_clocks_and_bus(struct msm_vidc_inst *inst); int msm_comm_init_clocks_and_bus_data(struct msm_vidc_inst *inst); int msm_vidc_decide_work_route_iris1(struct msm_vidc_inst *inst); int msm_vidc_decide_work_mode_iris1(struct msm_vidc_inst *inst); diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index 79c0c4d..785fa9c 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include <linux/jiffies.h> @@ -3081,7 +3081,6 @@ static int msm_comm_init_core(struct msm_vidc_inst *inst) core->state = VIDC_CORE_INIT; core->smmu_fault_handled = false; core->trigger_ssr = false; - core->resources.max_inst_count = MAX_SUPPORTED_INSTANCES; core->resources.max_secure_inst_count = core->resources.max_secure_inst_count ? core->resources.max_secure_inst_count : @@ -4834,6 +4833,7 @@ int msm_comm_qbufs_batch(struct msm_vidc_inst *inst, int rc = 0; struct msm_vidc_buffer *buf; int do_bw_calc = 0; + int num_buffers_queued = 0; do_bw_calc = mbuf ? mbuf->vvb.vb2_buf.type == INPUT_MPLANE : 0; rc = msm_comm_scale_clocks_and_bus(inst, do_bw_calc); @@ -4859,10 +4859,13 @@ int msm_comm_qbufs_batch(struct msm_vidc_inst *inst, __func__, rc); break; } + num_buffers_queued++; loop_end: - /* Queue pending buffers till the current buffer only */ - if (buf == mbuf) + /* Queue pending buffers till batch size */ + if (num_buffers_queued == inst->batch.size) { + s_vpr_e(inst->sid, "%s: Queue buffers till batch size\n"); break; + } } mutex_unlock(&inst->registeredbufs.lock); @@ -6193,10 +6196,12 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst) width_min, height_min); rc = -ENOTSUPP; } - if (!rc && output_width > width_max) { + if (!rc && (output_width > width_max || + output_height > height_max)) { s_vpr_e(sid, - "Unsupported width = %u supported max width = %u\n", - output_width, width_max); + "Unsupported WxH (%u)x(%u), max supported is (%u)x(%u)\n", + output_width, output_height, + width_max, height_max); rc = -ENOTSUPP; } diff --git a/msm/vidc/msm_vidc_debug.c b/msm/vidc/msm_vidc_debug.c index aa1de10..aea6398 100644 --- a/msm/vidc/msm_vidc_debug.c +++ b/msm/vidc/msm_vidc_debug.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #define CREATE_TRACE_POINTS @@ -31,8 +31,6 @@ int msm_vidc_err_recovery_disable = !1; atomic_read(&__binfo->ref_count) >= 2 ? "video driver" : "firmware";\ }) -struct log_cookie ctxt[MAX_SUPPORTED_INSTANCES]; - struct core_inst_pair { struct msm_vidc_core *core; struct msm_vidc_inst *inst; @@ -611,16 +609,16 @@ int get_sid(u32 *sid, u32 session_type) { int i; - for (i = 0; i < MAX_SUPPORTED_INSTANCES; i++) { - if (!ctxt[i].used) { - ctxt[i].used = 1; + for (i = 0; i < vidc_driver->num_ctxt; i++) { + if (!vidc_driver->ctxt[i].used) { + vidc_driver->ctxt[i].used = 1; *sid = i+1; update_log_ctxt(*sid, session_type, 0); break; } } - return (i == MAX_SUPPORTED_INSTANCES); + return (i == vidc_driver->num_ctxt); } inline void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc) @@ -629,7 +627,7 @@ inline void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc) char type; u32 s_type = 0; - if (!sid || sid > MAX_SUPPORTED_INSTANCES) { + if (!sid || sid > vidc_driver->num_ctxt) { d_vpr_e("%s: invalid sid %#x\n", __func__, sid); } @@ -685,10 +683,10 @@ inline void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc) break; } - ctxt[sid-1].session_type = s_type; - ctxt[sid-1].codec_type = fourcc; - memcpy(&ctxt[sid-1].name, codec, 4); - ctxt[sid-1].name[4] = type; - ctxt[sid-1].name[5] = '\0'; + vidc_driver->ctxt[sid-1].session_type = s_type; + vidc_driver->ctxt[sid-1].codec_type = fourcc; + memcpy(&vidc_driver->ctxt[sid-1].name, codec, 4); + vidc_driver->ctxt[sid-1].name[4] = type; + vidc_driver->ctxt[sid-1].name[5] = '\0'; } diff --git a/msm/vidc/msm_vidc_debug.h b/msm/vidc/msm_vidc_debug.h index 7ddc7be..080b7f6 100644 --- a/msm/vidc/msm_vidc_debug.h +++ b/msm/vidc/msm_vidc_debug.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #ifndef __MSM_VIDC_DEBUG__ @@ -69,13 +69,6 @@ enum vidc_err_recovery_disable { VIDC_DISABLE_NON_NOC_ERR_RECOV = 0x0002 }; -struct log_cookie { - u32 used; - u32 session_type; - u32 codec_type; - char name[20]; -}; - extern int msm_vidc_debug; extern int msm_vidc_fw_debug_mode; extern bool msm_vidc_fw_coverage; @@ -85,7 +78,6 @@ extern bool msm_vidc_syscache_disable; extern bool msm_vidc_lossless_encode; extern bool msm_vidc_cvp_usage; extern int msm_vidc_err_recovery_disable; -extern struct log_cookie ctxt[MAX_SUPPORTED_INSTANCES]; #define dprintk(__level, sid, __fmt, ...) \ do { \ @@ -213,10 +205,10 @@ static inline bool is_print_allowed(u32 sid, u32 level) if (!((msm_vidc_debug >> 8) & 0xF)) return true; - if (!sid || sid > MAX_SUPPORTED_INSTANCES) + if (!sid || sid > vidc_driver->num_ctxt) return true; - if (ctxt[sid-1].session_type & msm_vidc_debug) + if (vidc_driver->ctxt[sid-1].session_type & msm_vidc_debug) return true; return false; @@ -224,21 +216,21 @@ static inline bool is_print_allowed(u32 sid, u32 level) static inline char *get_codec_name(u32 sid) { - if (!sid || sid > MAX_SUPPORTED_INSTANCES) + if (!sid || sid > vidc_driver->num_ctxt) return "....."; - return ctxt[sid-1].name; + return vidc_driver->ctxt[sid-1].name; } static inline void put_sid(u32 sid) { - if (!sid || sid > MAX_SUPPORTED_INSTANCES) { + if (!sid || sid > vidc_driver->num_ctxt) { d_vpr_e("%s: invalid sid %#x\n", __func__, sid); return; } - if (ctxt[sid-1].used) - ctxt[sid-1].used = 0; + if (vidc_driver->ctxt[sid-1].used) + vidc_driver->ctxt[sid-1].used = 0; } static inline void tic(struct msm_vidc_inst *i, enum profiling_points p, diff --git a/msm/vidc/msm_vidc_internal.h b/msm/vidc/msm_vidc_internal.h index 8fdbf34..8439da7 100644 --- a/msm/vidc/msm_vidc_internal.h +++ b/msm/vidc/msm_vidc_internal.h @@ -48,6 +48,7 @@ #define MAX_NUM_OUTPUT_BUFFERS VIDEO_MAX_FRAME // same as VB2_MAX_FRAME #define MAX_SUPPORTED_INSTANCES 16 +#define MAX_SUPPORTED_INSTANCES_24 24 /* Maintains the number of FTB's between each FBD over a window */ #define DCVS_FTB_WINDOW 16 @@ -79,6 +80,9 @@ #define NUM_MBS_PER_FRAME(__height, __width) \ ((ALIGN(__height, 16) / 16) * (ALIGN(__width, 16) / 16)) +#define NUM_MBS_PER_FRAME_HEVC(__height, __width) \ + ((ALIGN(__height, 32) / 32) * (ALIGN(__width, 32) / 32)) + #define call_core_op(c, op, ...) \ (((c) && (c)->core_ops && (c)->core_ops->op) ? \ ((c)->core_ops->op(__VA_ARGS__)) : 0) @@ -300,6 +304,7 @@ struct msm_vidc_platform_data { uint32_t vpu_ver; uint32_t num_vpp_pipes; struct msm_vidc_ubwc_config_data *ubwc_config; + uint32_t max_inst_count; }; struct msm_vidc_format_desc { @@ -326,6 +331,13 @@ struct msm_vidc_format_constraint { u32 uv_buffer_alignment; }; +struct log_cookie { + u32 used; + u32 session_type; + u32 codec_type; + char name[20]; +}; + struct msm_vidc_drv { struct mutex lock; struct list_head cores; @@ -333,6 +345,8 @@ struct msm_vidc_drv { struct dentry *debugfs_root; int thermal_level; u32 sku_version; + struct log_cookie *ctxt; + u32 num_ctxt; }; struct msm_video_device { @@ -551,6 +565,7 @@ struct msm_vidc_inst { bool static_rotation_flip_enabled; struct internal_buf *dpb_extra_binfo; struct msm_vidc_codec_data *codec_data; + bool hdr10_sei_enabled; struct hal_hdr10_pq_sei hdr10_sei_params; struct batch_mode batch; struct delayed_work batch_work; diff --git a/msm/vidc/msm_vidc_platform.c b/msm/vidc/msm_vidc_platform.c index a704b9c..b788cce 100644 --- a/msm/vidc/msm_vidc_platform.c +++ b/msm/vidc/msm_vidc_platform.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. */ #include <linux/debugfs.h> @@ -1882,6 +1882,7 @@ static struct msm_vidc_platform_data default_data = { .vpu_ver = VPU_VERSION_IRIS2, .num_vpp_pipes = 0x4, .ubwc_config = 0x0, + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data lito_data = { @@ -1902,6 +1903,7 @@ static struct msm_vidc_platform_data lito_data = { .codecs_count = ARRAY_SIZE(default_codecs), .codec_caps = lito_capabilities_v0, .codec_caps_count = ARRAY_SIZE(lito_capabilities_v0), + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data kona_data = { @@ -1922,6 +1924,7 @@ static struct msm_vidc_platform_data kona_data = { .codecs_count = ARRAY_SIZE(default_codecs), .codec_caps = kona_capabilities, .codec_caps_count = ARRAY_SIZE(kona_capabilities), + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data lagoon_data = { @@ -1942,6 +1945,7 @@ static struct msm_vidc_platform_data lagoon_data = { .codecs_count = ARRAY_SIZE(lagoon_codecs), .codec_caps = lagoon_capabilities_v0, .codec_caps_count = ARRAY_SIZE(lagoon_capabilities_v0), + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data sm6150_data = { @@ -1958,6 +1962,7 @@ static struct msm_vidc_platform_data sm6150_data = { .vpu_ver = VPU_VERSION_AR50, .num_vpp_pipes = 0x1, .ubwc_config = 0x0, + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data bengal_data = { @@ -1978,6 +1983,7 @@ static struct msm_vidc_platform_data bengal_data = { .codecs_count = ARRAY_SIZE(bengal_codecs), .codec_caps = bengal_capabilities_v0, .codec_caps_count = ARRAY_SIZE(bengal_capabilities_v0), + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data scuba_data = { @@ -1998,6 +2004,7 @@ static struct msm_vidc_platform_data scuba_data = { .codecs_count = ARRAY_SIZE(scuba_codecs), .codec_caps = scuba_capabilities, .codec_caps_count = ARRAY_SIZE(scuba_capabilities), + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data sm8150_data = { @@ -2014,6 +2021,7 @@ static struct msm_vidc_platform_data sm8150_data = { .vpu_ver = VPU_VERSION_IRIS1, .num_vpp_pipes = 0x2, .ubwc_config = 0x0, + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data sdm845_data = { @@ -2030,6 +2038,7 @@ static struct msm_vidc_platform_data sdm845_data = { .vpu_ver = VPU_VERSION_AR50, .num_vpp_pipes = 0x1, .ubwc_config = 0x0, + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data sdm670_data = { @@ -2046,6 +2055,7 @@ static struct msm_vidc_platform_data sdm670_data = { .vpu_ver = VPU_VERSION_AR50, .num_vpp_pipes = 0x1, .ubwc_config = 0x0, + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static const struct of_device_id msm_vidc_dt_match[] = { @@ -2058,6 +2068,10 @@ static const struct of_device_id msm_vidc_dt_match[] = { .data = &kona_data, }, { + .compatible = "qcom,qcs8250-vidc", + .data = &kona_data, + }, + { .compatible = "qcom,sm6150-vidc", .data = &sm6150_data, }, @@ -2208,6 +2222,21 @@ void *vidc_get_drv_data(struct device *dev) d_vpr_h("DDR Type 0x%x hbb 0x%x\n", ddr_type, driver_data->ubwc_config ? driver_data->ubwc_config->highest_bank_bit : -1); + } else if (!strcmp(match->compatible, "qcom,qcs8250-vidc")) { + ddr_type = of_fdt_get_ddrtype(); + if (ddr_type == -ENOENT) + d_vpr_e("Failed to get ddr type, use LPDDR5\n"); + + if (driver_data->ubwc_config && + (ddr_type == DDR_TYPE_LPDDR4 || + ddr_type == DDR_TYPE_LPDDR4X)) + driver_data->ubwc_config->highest_bank_bit = 0xf; + + d_vpr_h("DDR Type 0x%x hbb 0x%x\n", + ddr_type, driver_data->ubwc_config ? + driver_data->ubwc_config->highest_bank_bit : -1); + + driver_data->max_inst_count = MAX_SUPPORTED_INSTANCES_24; } else if (!strcmp(match->compatible, "qcom,bengal-vidc")) { rc = msm_vidc_read_rank(driver_data, dev); if (rc) { diff --git a/msm/vidc/msm_vidc_res_parse.c b/msm/vidc/msm_vidc_res_parse.c index 1b9e994..2f84f96 100644 --- a/msm/vidc/msm_vidc_res_parse.c +++ b/msm/vidc/msm_vidc_res_parse.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include <asm/dma-iommu.h> @@ -846,6 +846,7 @@ int read_platform_resources_from_drv_data( res->vpu_ver = platform_data->vpu_ver; res->ubwc_config = platform_data->ubwc_config; + res->max_inst_count = platform_data->max_inst_count; return rc; |