[PATCH v2 2/3] media: ccs-pll: Support optional input for VT pixel rate
Jai Luthra <[email protected]>
| Newsgroups | org.kernel.vger.linux-media,org.kernel.vger.linux-devicetree |
|---|---|
| Message-ID | <[email protected]> |
When the PLL is configured in DUAL_MODE (separate VT and OP trees) and the sensor's FIFOs allow derating and/or overrating, the VT pixel rate might be higher or lower than OP pixel rate. Support such usecases by allowing an optional input for the target VT pixel rate. Signed-off-by: Jai Luthra <[email protected]> --- drivers/media/i2c/ccs-pll.c | 13 +++++++++++-- drivers/media/i2c/ccs-pll.h | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ccs-pll.c b/drivers/media/i2c/ccs-pll.c index 1605cfa5db19..9aa164994cc7 100644 --- a/drivers/media/i2c/ccs-pll.c +++ b/drivers/media/i2c/ccs-pll.c @@ -388,6 +388,14 @@ __ccs_pll_calculate_vt_tree(struct device *dev, return 0; } +static inline u32 ccs_pll_vt_pixel_rate(const struct ccs_pll *pll) +{ + if (pll->pixel_rate_pixel_array) + return pll->pixel_rate_pixel_array; + + return pll->pixel_rate_csi; +} + static int ccs_pll_calculate_vt_tree(struct device *dev, const struct ccs_pll_limits *lim, struct ccs_pll *pll) @@ -396,11 +404,12 @@ static int ccs_pll_calculate_vt_tree(struct device *dev, struct ccs_pll_branch_fr *pll_fr = &pll->vt_fr; u16 min_pre_pll_clk_div = lim_fr->min_pre_pll_clk_div; u16 max_pre_pll_clk_div = lim_fr->max_pre_pll_clk_div; + u32 vt_pixel_rate = ccs_pll_vt_pixel_rate(pll); u32 pre_mul, pre_div; - pre_div = gcd(pll->pixel_rate_csi, + pre_div = gcd(vt_pixel_rate, pll->ext_clk_freq_hz * pll->vt_lanes); - pre_mul = pll->pixel_rate_csi / pre_div; + pre_mul = vt_pixel_rate / pre_div; pre_div = pll->ext_clk_freq_hz * pll->vt_lanes / pre_div; /* Make sure PLL input frequency is within limits */ diff --git a/drivers/media/i2c/ccs-pll.h b/drivers/media/i2c/ccs-pll.h index e22903931e72..5c00a72c41df 100644 --- a/drivers/media/i2c/ccs-pll.h +++ b/drivers/media/i2c/ccs-pll.h @@ -114,7 +114,9 @@ struct ccs_pll_branch_bk { * @op_bk: Operational timing back-end configuration (output) * @pixel_rate_csi: Pixel rate on the output data bus (output) * @pixel_rate_pixel_array: Nominal pixel rate in the sensor's pixel array - * (output) + * (input/output). It is a valid input only when + * FLAG_DUAL_PLL is set, serving as a target rate + * for the VT tree. */ struct ccs_pll { /* input values */ -- 2.54.0