summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-06 20:36:40 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-07-19 10:38:43 +0200
commit399b0a3d54b695def41a77a05ad8221c0e9ffc29 (patch)
tree35130caf488f988d8eb013c0b54e861f6034211d /drivers/media
parent49b184a0dae93b7eaa3dbd09c0287db9a471c9da (diff)
downloadlwn-399b0a3d54b695def41a77a05ad8221c0e9ffc29.tar.gz
lwn-399b0a3d54b695def41a77a05ad8221c0e9ffc29.zip
media: ti-vpe: cal: Don't store external rate in cal_camerarx
The external pixel rate is retrieved when starting the camerarx and only used then. There's no need to store it in the cal_camerarx structure, it can be returned by cal_camerarx_get_external_info() and explicitly passed to cal_camerarx_config(). While at it, rename cal_camerarx_get_external_info() to cal_camerarx_get_external_rate() to better reflect the function's purpose. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/ti-vpe/cal.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 50fe6c19c417..8b1815bbf1a7 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -272,7 +272,6 @@ struct cal_camerarx {
struct v4l2_fwnode_endpoint endpoint;
struct device_node *sensor_node;
struct v4l2_subdev *sensor;
- unsigned int external_rate;
};
struct cal_dev {
@@ -481,9 +480,10 @@ static void cal_quickdump_regs(struct cal_dev *cal)
* ------------------------------------------------------------------
*/
-static int cal_camerarx_get_external_info(struct cal_camerarx *phy)
+static s64 cal_camerarx_get_external_rate(struct cal_camerarx *phy)
{
struct v4l2_ctrl *ctrl;
+ s64 rate;
if (!phy->sensor)
return -ENODEV;
@@ -495,10 +495,10 @@ static int cal_camerarx_get_external_info(struct cal_camerarx *phy)
return -EPIPE;
}
- phy->external_rate = v4l2_ctrl_g_ctrl_int64(ctrl);
- phy_dbg(3, phy, "sensor Pixel Rate: %u\n", phy->external_rate);
+ rate = v4l2_ctrl_g_ctrl_int64(ctrl);
+ phy_dbg(3, phy, "sensor Pixel Rate: %llu\n", rate);
- return 0;
+ return rate;
}
static void cal_camerarx_lane_config(struct cal_camerarx *phy)
@@ -554,7 +554,7 @@ static void cal_camerarx_disable(struct cal_camerarx *phy)
#define TCLK_MISS 1
#define TCLK_SETTLE 14
-static void cal_camerarx_config(struct cal_camerarx *phy,
+static void cal_camerarx_config(struct cal_camerarx *phy, s64 external_rate,
const struct cal_fmt *fmt)
{
unsigned int reg0, reg1;
@@ -565,9 +565,16 @@ static void cal_camerarx_config(struct cal_camerarx *phy,
u32 num_lanes = mipi_csi2->num_data_lanes;
/* DPHY timing configuration */
- /* CSI-2 is DDR and we only count used lanes. */
- csi2_ddrclk_khz = phy->external_rate / 1000
- / (2 * num_lanes) * fmt->bpp;
+
+ /*
+ * CSI-2 is DDR and we only count used lanes.
+ *
+ * csi2_ddrclk_khz = external_rate / 1000
+ * / (2 * num_lanes) * fmt->bpp;
+ */
+ csi2_ddrclk_khz = div_s64(external_rate * fmt->bpp,
+ 2 * num_lanes * 1000);
+
phy_dbg(1, phy, "csi2_ddrclk_khz: %d\n", csi2_ddrclk_khz);
/* THS_TERM: Programmed value = floor(20 ns/DDRClk period) */
@@ -667,13 +674,14 @@ static void cal_camerarx_wait_stop_state(struct cal_camerarx *phy)
static int cal_camerarx_start(struct cal_camerarx *phy,
const struct cal_fmt *fmt)
{
+ s64 external_rate;
u32 sscounter;
u32 val;
int ret;
- ret = cal_camerarx_get_external_info(phy);
- if (ret < 0)
- return ret;
+ external_rate = cal_camerarx_get_external_rate(phy);
+ if (external_rate < 0)
+ return external_rate;
ret = v4l2_subdev_call(phy->sensor, core, s_power, 1);
if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) {
@@ -719,7 +727,7 @@ static int cal_camerarx_start(struct cal_camerarx *phy,
reg_read(phy, CAL_CSI2_PHY_REG0);
/* Program the PHY timing parameters. */
- cal_camerarx_config(phy, fmt);
+ cal_camerarx_config(phy, external_rate, fmt);
/*
* b. Assert the FORCERXMODE signal.
@@ -1039,7 +1047,6 @@ static struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,
phy->cal = cal;
phy->instance = instance;
- phy->external_rate = 192000000;
phy->res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
(instance == 0) ?