From 652c032bb5bcd3a26c81160d5c7b5e8bf8c59e14 Mon Sep 17 00:00:00 2001 From: Rakibul Hassan Date: Thu, 14 Nov 2024 01:15:11 +0000 Subject: [PATCH] nvidia-oot: camera: isp: track syncpt threshold This change does the following: - Keep the capture progress syncpt threshold up to date by incrementing it when a capture request is made - Fast forward the syncpoints via host1x api on reset Bug 4882047 Change-Id: If971bf4f248bd7a0be6a79ccb0e124f2768c0af4 Signed-off-by: Rakibul Hassan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3248427 (cherry picked from commit cbac4a12165c2d19f9f5889cbeffffb3b63e54d0) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3253387 Reviewed-by: mobile promotions Reviewed-by: Shiva Dubey Reviewed-by: Justin Kim (SW-TEGRA) GVS: buildbot_gerritrpt Tested-by: mobile promotions --- .../tegra/camera/fusa-capture/capture-isp.c | 39 +++++++++++++++++++ drivers/video/tegra/host/isp/isp5.c | 7 ++++ .../media/fusa-capture/capture-isp-channel.h | 12 ++++++ 3 files changed, 58 insertions(+) diff --git a/drivers/media/platform/tegra/camera/fusa-capture/capture-isp.c b/drivers/media/platform/tegra/camera/fusa-capture/capture-isp.c index 88dda308..89fc621f 100644 --- a/drivers/media/platform/tegra/camera/fusa-capture/capture-isp.c +++ b/drivers/media/platform/tegra/camera/fusa-capture/capture-isp.c @@ -185,6 +185,23 @@ cleanup: return err; } +static void isp_capture_fastforward_syncpt( + struct tegra_isp_channel *chan, + struct syncpoint_info *sp) +{ + if (sp->id) + chan->ops->fast_forward_syncpt(chan->ndev, sp->id, sp->threshold); +} + +static void isp_capture_fastforward_syncpts( + struct tegra_isp_channel *chan) +{ + struct isp_capture *capture = chan->capture_data; + + isp_capture_fastforward_syncpt(chan, &capture->progress_sp); + isp_capture_fastforward_syncpt(chan, &capture->stats_progress_sp); +} + /** * @brief Release an ISP syncpoint and clear its handle. * @@ -1588,6 +1605,8 @@ int isp_capture_reset( goto error; } + isp_capture_fastforward_syncpts(chan); + err = 0; error: @@ -1786,6 +1805,22 @@ fail: return err; } +static uint32_t isp_capture_get_num_progress( + struct tegra_isp_channel *chan, + struct isp_capture_req *req) +{ + struct isp_desc_rec *capture_desc_ctx = + &chan->capture_data->capture_desc_ctx; + struct isp_capture_descriptor *desc = (struct isp_capture_descriptor *) + (capture_desc_ctx->requests.va + + req->buffer_index * capture_desc_ctx->request_size); + + uint16_t sliceHeight = desc->surface_configs.slice_height; + uint16_t height = desc->surface_configs.mr_height; + + return ((height + (sliceHeight - 1U)) / sliceHeight); +} + int isp_capture_request( struct tegra_isp_channel *chan, struct isp_capture_req *req) @@ -1901,6 +1936,10 @@ int isp_capture_request( goto fail; } + // Progress syncpoints + 1 for frame completion + capture->progress_sp.threshold += isp_capture_get_num_progress(chan, req) + 1; + capture->stats_progress_sp.threshold += isp_capture_get_num_progress(chan, req) + 1 + 2; + return 0; fail: diff --git a/drivers/video/tegra/host/isp/isp5.c b/drivers/video/tegra/host/isp/isp5.c index e9d0d7dd..ba5e53eb 100644 --- a/drivers/video/tegra/host/isp/isp5.c +++ b/drivers/video/tegra/host/isp/isp5.c @@ -72,6 +72,12 @@ static void isp5_release_syncpt(struct platform_device *pdev, uint32_t id) nvhost_syncpt_put_ref_ext(pdev, id); } +static void isp5_fast_forward_syncpt(struct platform_device *pdev, uint32_t id, uint32_t threshold) +{ + dev_dbg(&pdev->dev, "%s: id=%u -> thresh=%u\n", __func__, id, threshold); + nvhost_syncpt_set_min_update(pdev, id, threshold); +} + static int isp5_get_syncpt_gos_backing(struct platform_device *pdev, uint32_t id, dma_addr_t *syncpt_addr, @@ -116,6 +122,7 @@ static uint32_t isp5_get_gos_table(struct platform_device *pdev, static struct isp_channel_drv_ops isp5_channel_drv_ops = { .alloc_syncpt = isp5_alloc_syncpt, .release_syncpt = isp5_release_syncpt, + .fast_forward_syncpt = isp5_fast_forward_syncpt, .get_gos_table = isp5_get_gos_table, .get_syncpt_gos_backing = isp5_get_syncpt_gos_backing, }; diff --git a/include/media/fusa-capture/capture-isp-channel.h b/include/media/fusa-capture/capture-isp-channel.h index cae1cf7d..a96cb2e3 100644 --- a/include/media/fusa-capture/capture-isp-channel.h +++ b/include/media/fusa-capture/capture-isp-channel.h @@ -48,6 +48,18 @@ struct isp_channel_drv_ops { struct platform_device *pdev, uint32_t id); + /** + * Fast forward a progres syncpt to Host1x. + * + * @param[in] pdev VI platform_device + * @param[in] id syncpt id to fast forward + * @param[in] threshold value to fast forward to + */ + void (*fast_forward_syncpt)( + struct platform_device *pdev, + uint32_t id, + uint32_t threshold); + /** * @brief Retrieve the GoS table allocated in the ISP-THI carveout. *