From 0018354fcfe4474e3874efbba13e629bf573cef7 Mon Sep 17 00:00:00 2001 From: Ankur Pawar Date: Thu, 29 Feb 2024 04:50:04 -0800 Subject: [PATCH] media:i2c: fix imx477 partial frame output Fix imx477 partial frame issue and wrong frame-length /exposure time calculations. Uses hardcoded sensor internal clock frequency instead of clock values from sensor device tree. Adding clock frequency to device tree also require deskew_initial_enable = "true". Setting deskew in device tree is causing kernel panic in function nvcsi_deskew_setup(). For unblocking the IMX477 use case, set hardcoded clock in driver for now. Bug 4384649 Change-Id: Iedb02673c6f4da140aee22adc991805b6aa1eb7e Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3086503 cherry-picked from <4d4e68569911d4424073a3b39f5b2642346a077a> Signed-off-by: Ankur Pawar Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3087470 Reviewed-by: Praveen AC Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- drivers/media/i2c/nv_imx477.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/nv_imx477.c b/drivers/media/i2c/nv_imx477.c index a57cdf75..8e8c9a29 100644 --- a/drivers/media/i2c/nv_imx477.c +++ b/drivers/media/i2c/nv_imx477.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. /* * Copyright (c) 2020, RidgeRun. All rights reserved. - * Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * * Contact us: support@ridgerun.com * @@ -26,6 +26,8 @@ #include "../platform/tegra/camera/camera_gpio.h" #include "imx477_mode_tbls.h" +#define IMX477_SENSOR_INTERNAL_CLK_FREQ 840000000 + static const struct of_device_id imx477_of_match[] = { {.compatible = "ridgerun,imx477",}, {}, @@ -228,7 +230,7 @@ static int imx477_set_frame_rate(struct tegracam_device *tc_dev, s64 val) if (val == 0 || mode->image_properties.line_length == 0) return -EINVAL; - frame_length = (u32) (mode->signal_properties.pixel_clock.val * + frame_length = (u32) (IMX477_SENSOR_INTERNAL_CLK_FREQ * (u64) mode->control_properties.framerate_factor / mode->image_properties.line_length / val); @@ -279,12 +281,12 @@ static int imx477_set_exposure(struct tegracam_device *tc_dev, s64 val) fine_integ_time_factor = priv->fine_integ_time * mode->control_properties.exposure_factor / - mode->signal_properties.pixel_clock.val; + IMX477_SENSOR_INTERNAL_CLK_FREQ; dev_dbg(dev, "%s: Setting exposure control to: %lld\n", __func__, val); coarse_time = (val - fine_integ_time_factor) - * mode->signal_properties.pixel_clock.val + * IMX477_SENSOR_INTERNAL_CLK_FREQ / mode->control_properties.exposure_factor / mode->image_properties.line_length;