CCS PLL fixes and improvements
Subsystems (2)
Sakari Ailus
maintainerv2 cover CCS PLL fixes and improvements
Hi all,
Here are a few fixes and improvements to the CCS PLL calculator.
v1 is <[email protected]>.
since v1:
- Added patches for the following:
- Drop the now-unused LINK_DECOUPLED flag.
- Print missing flags.
- Print PLL calculator flags before running the calculator (earlier version posted separately already).
- Document the CCS PLL flags tersely but still in a way that is useful.
- Rebased other patches to clean up things first.
Sakari Ailus (11):
media: ccs-pll: Start OP pre-PLL multiplier search from correct value
media: ccs-pll: Start VT pre-PLL multiplier search from correct value
media: ccs-pll: Check for too high VT PLL multiplier in dual PLL case
media: ccs-pll: Correctly the upper limit of maximum
op_pre_pll_clk_div
media: ccs-pll: Print a debug message on too high VT PLL OP clock
media: ccs-pll: Drop LINK_DECOUPLED flag
media: ccs-pll: Print missing PLL flags
media: ccs-pll: Add a flag for even PLL multipliers
media: ccs-pll: Better validate VT PLL branch
media: ccs-pll: Print PLL calculator flags in the beginning
media: ccs-pll: Document the CCS PLL flags
drivers/media/i2c/ccs-pll.c | 49 +++++++++++++++++++++++++------ drivers/media/i2c/ccs-pll.h | 29 +++++++++++++++--- drivers/media/i2c/ccs/ccs-core.c | 1 - drivers/media/i2c/ccs/ccs-quirk.c | 3 +- 4 files changed, 66 insertions(+), 16 deletions(-)
Signature · 1 line
2.39.5
Sakari Ailus
maintainerPATCH v2 1/11 media: ccs-pll: Start OP pre-PLL multiplier search from correct value
The ccs_pll_calculate() function does a search over possible PLL configurations to find the "best" one. If the sensor did not support odd pre-PLL divisors and the minimum value (with constraints) wasn't 1, other even values could have errorneously searched (and selected) for the pre-PLL divisor. Fix this.
--- drivers/media/i2c/ccs-pll.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/ccs-pll.c +2 -0
@@ -815,6 +815,8 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,one_or_more (DIV_ROUND_UP (op_lim_fr->max_pll_op_clk_freq_hz, pll->ext_clk_freq_hz)))); +if (!(pll->flags &CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER )) + min_op_pre_pll_clk_div =clk_div_even (min_op_pre_pll_clk_div);dev_dbg (dev,"pll_op check: min / max op_pre_pll_clk_div: %u / %u\n" , min_op_pre_pll_clk_div, max_op_pre_pll_clk_div);
Signature · 1 line
2.39.5
Re: [PATCH v2 01/11] media: ccs-pll: Start OP pre-PLL multiplier search from correct value
Hi Sakari,
Thank you for the patch.
Quoted 2 lines · Sakari Ailus
The
ccs_pll_calculate()function does a search over possible PLL configurations to find the "best" one. If the sensor did not support odd
s/did not/does not/
Quoted 1 line
pre-PLL divisors and the minimum value (with constraints) wasn't 1, other
s/wasn't/isn't/
Quoted 1 line
even values could have errorneously searched (and selected) for the
s/could have errorneously searched/
s/could be erroneously searched/
Do you mean "other odd values" ?
Quoted 14 lines
pre-PLL divisor. Fix this.
Fixes 415ddd993978 ("media: ccs-pll: Split limits and PLL configuration into front and back parts")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/i2c/ccs-pll.c +0
-0
drivers/media/i2c/ccs-pll.c int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim, · line 822
Quoted 8 lines
drivers/media/i2c/ccs-pll.c +2
-0@@ -815,6 +815,8 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,one_or_more (DIV_ROUND_UP (op_lim_fr->max_pll_op_clk_freq_hz, pll->ext_clk_freq_hz)))); +if (!(pll->flags &CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER )) + min_op_pre_pll_clk_div =clk_div_even (min_op_pre_pll_clk_div);dev_dbg (dev,"pll_op check: min / max op_pre_pll_clk_div: %u / %u\n" , min_op_pre_pll_clk_div, max_op_pre_pll_clk_div);
Is my understanding correct that the problem can only occur during the first iteration of the loop just below ? If so, with the commit message fixed,
If not, there's something I don't get :-)
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerRe: [PATCH v2 01/11] media: ccs-pll: Start OP pre-PLL multiplier search from correct value
Hi Laurent,
Thanks for the review.
Quoted 12 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 2 lines · Sakari Ailus
The
ccs_pll_calculate()function does a search over possible PLL configurations to find the "best" one. If the sensor did not support odds/did not/does not/
Quoted 1 line
pre-PLL divisors and the minimum value (with constraints) wasn't 1, other
Quoted 8 lines
s/wasn't/isn't/
Quoted 1 line
even values could have errorneously searched (and selected) for the
s/could have errorneously searched/
s/could be erroneously searched/Do you mean "other odd values" ?
Odd values that aren't 1.
Quoted 19 lines
Quoted 19 lines
pre-PLL divisor. Fix this.
Fixes 415ddd993978 ("media: ccs-pll: Split limits and PLL configuration into front and back parts")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/i2c/ccs-pll.c +1
-0@@ -815,6 +815,8 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,one_or_more (DIV_ROUND_UP (op_lim_fr->max_pll_op_clk_freq_hz, pll->ext_clk_freq_hz)))); +if (!(pll->flags &CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER ))
Quoted 8 lines
drivers/media/i2c/ccs-pll.c int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim, · line 822
Quoted 4 lines
drivers/media/i2c/ccs-pll.c +1
-0+ min_op_pre_pll_clk_div =clk_div_even (min_op_pre_pll_clk_div);dev_dbg (dev,"pll_op check: min / max op_pre_pll_clk_div: %u / %u\n" , min_op_pre_pll_clk_div, max_op_pre_pll_clk_div);Is my understanding correct that the problem can only occur during the first iteration of the loop just below ? If so, with the commit message fixed,
Correct.
Quoted 5 lines
Reviewed-by Laurent Pinchart <[email protected]>If not, there's something I don't get :-)
:-)
Signature · 3 lines
Regards, Sakari Ailus
Re: [PATCH v2 01/11] media: ccs-pll: Start OP pre-PLL multiplier search from correct value
Quoted 11 lines · Sakari Ailus
Quoted 10 lines · Laurent Pinchart
Quoted 2 lines · Sakari Ailus
The
ccs_pll_calculate()function does a search over possible PLL configurations to find the "best" one. If the sensor did not support odds/did not/does not/
Quoted 1 line
pre-PLL divisors and the minimum value (with constraints) wasn't 1, other
s/wasn't/isn't/
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
even values could have errorneously searched (and selected) for the
s/could have errorneously searched/
s/could be erroneously searched/Do you mean "other odd values" ?
Odd values that aren't 1.
You wrote ", other even values could ...". I think s/even/odd/ is what you meant.
Quoted 34 lines
Quoted 18 lines
Quoted 18 lines
pre-PLL divisor. Fix this.
Fixes 415ddd993978 ("media: ccs-pll: Split limits and PLL configuration into front and back parts")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/i2c/ccs-pll.c +1
-0@@ -815,6 +815,8 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,one_or_more (DIV_ROUND_UP (op_lim_fr->max_pll_op_clk_freq_hz, pll->ext_clk_freq_hz)))); +if (!(pll->flags &CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER ))Quoted 8 lines
drivers/media/i2c/ccs-pll.c int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim, · line 822
Quoted 4 lines
drivers/media/i2c/ccs-pll.c +1
-0+ min_op_pre_pll_clk_div =clk_div_even (min_op_pre_pll_clk_div);dev_dbg (dev,"pll_op check: min / max op_pre_pll_clk_div: %u / %u\n" , min_op_pre_pll_clk_div, max_op_pre_pll_clk_div);Is my understanding correct that the problem can only occur during the first iteration of the loop just below ? If so, with the commit message fixed,
Correct.
Quoted 3 lines
Reviewed-by Laurent Pinchart <[email protected]>If not, there's something I don't get :-)
:-)
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerRe: [PATCH v2 01/11] media: ccs-pll: Start OP pre-PLL multiplier search from correct value
Quoted 17 lines · Laurent Pinchart
Quoted 16 lines · Sakari Ailus
Quoted 15 lines · Laurent Pinchart
Quoted 2 lines · Sakari Ailus
The
ccs_pll_calculate()function does a search over possible PLL configurations to find the "best" one. If the sensor did not support odds/did not/does not/
Quoted 1 line
pre-PLL divisors and the minimum value (with constraints) wasn't 1, other
s/wasn't/isn't/
Quoted 1 line
even values could have errorneously searched (and selected) for the
s/could have errorneously searched/
s/could be erroneously searched/
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Do you mean "other odd values" ?
Odd values that aren't 1.
You wrote ", other even values could ...". I think s/even/odd/ is what you meant.
Right, I'll fix that for v3 as well.
Signature · 1 line
Sakari Ailus
Sakari Ailus
maintainerPATCH v2 2/11 media: ccs-pll: Start VT pre-PLL multiplier search from correct value
In reply to Sakari AilusThe ccs_pll_calculate_vt_tree() function does a search over possible VT PLL configurations to find the "best" one. If the sensor did not support odd pre-PLL divisors and the minimum value (with constraints) wasn't 1, other even values could have errorneously searched (and selected) for the pre-PLL divisor. Fix this.
--- drivers/media/i2c/ccs-pll.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/ccs-pll.c +2 -0
@@ -397,6 +397,8 @@ static int ccs_pll_calculate_vt_tree(struct device *dev, min_pre_pll_clk_div =max_t (u16, min_pre_pll_clk_div, pll->ext_clk_freq_hz / lim_fr->max_pll_ip_clk_freq_hz); +if (!(pll->flags &CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER )) + min_pre_pll_clk_div =clk_div_even (min_pre_pll_clk_div);dev_dbg (dev,"vt min/max_pre_pll_clk_div: %u,%u\n" , min_pre_pll_clk_div, max_pre_pll_clk_div);
Signature · 1 line
2.39.5
Re: [PATCH v2 02/11] media: ccs-pll: Start VT pre-PLL multiplier search from correct value
Hi Sakari,
Thank you for the patch.
Quoted 5 lines · Sakari Ailus
The
ccs_pll_calculate_vt_tree()function does a search over possible VT PLL configurations to find the "best" one. If the sensor did not support odd pre-PLL divisors and the minimum value (with constraints) wasn't 1, other even values could have errorneously searched (and selected) for the pre-PLL divisor. Fix this.
Same comments as for 01/11. You can add my R-b tag if you address the issues in the same way.
Quoted 20 lines
Fixes 415ddd993978 ("media: ccs-pll: Split limits and PLL configuration into front and back parts")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/i2c/ccs-pll.c +2
-0@@ -397,6 +397,8 @@ static int ccs_pll_calculate_vt_tree(struct device *dev, min_pre_pll_clk_div =max_t (u16, min_pre_pll_clk_div, pll->ext_clk_freq_hz / lim_fr->max_pll_ip_clk_freq_hz); +if (!(pll->flags &CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER )) + min_pre_pll_clk_div =clk_div_even (min_pre_pll_clk_div);dev_dbg (dev,"vt min/max_pre_pll_clk_div: %u,%u\n" , min_pre_pll_clk_div, max_pre_pll_clk_div);
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerPATCH v2 3/11 media: ccs-pll: Check for too high VT PLL multiplier in dual PLL case
In reply to Sakari AilusThe check for VT PLL upper limit in dual PLL case was missing. Add it now.
--- drivers/media/i2c/ccs-pll.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/i2c/ccs-pll.c +5 -0
@@ -312,6 +312,11 @@ __ccs_pll_calculate_vt_tree(struct device *dev,dev_dbg (dev,"more_mul2: %u\n" , more_mul); pll_fr->pll_multiplier = mul * more_mul; +if (pll_fr->pll_multiplier > lim_fr->max_pll_multiplier) { +dev_dbg (dev,"pll multiplier %u too high\n" , + pll_fr->pll_multiplier); +return -EINVAL ; + }if (pll_fr->pll_multiplier * pll_fr->pll_ip_clk_freq_hz > lim_fr->max_pll_op_clk_freq_hz)
Signature · 1 line
2.39.5
Re: [PATCH v2 03/11] media: ccs-pll: Check for too high VT PLL multiplier in dual PLL case
Hi Sakari,
Thank you for the patch.
Quoted 5 lines · Sakari Ailus
The check for VT PLL upper limit in dual PLL case was missing. Add it now.
Fixes 6c7469e46b60 ("media: ccs-pll: Add trivial dual PLL support")Signed-off-by Sakari Ailus <[email protected]>
Quoted 20 lines
--- drivers/media/i2c/ccs-pll.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/media/i2c/ccs-pll.c +5
-0@@ -312,6 +312,11 @@ __ccs_pll_calculate_vt_tree(struct device *dev,dev_dbg (dev,"more_mul2: %u\n" , more_mul); pll_fr->pll_multiplier = mul * more_mul; +if (pll_fr->pll_multiplier > lim_fr->max_pll_multiplier) { +dev_dbg (dev,"pll multiplier %u too high\n" , + pll_fr->pll_multiplier); +return -EINVAL ; + }if (pll_fr->pll_multiplier * pll_fr->pll_ip_clk_freq_hz > lim_fr->max_pll_op_clk_freq_hz)
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerPATCH v2 4/11 media: ccs-pll: Correctly the upper limit of maximum op_pre_pll_clk_div
In reply to Sakari AilusThe PLL calculator does a search of the PLL configuration space for all valid OP pre-PLL clock dividers. The maximum did not take into account CCS PLL flag CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER in which case also odd PLL dividers (other than 1) are valid. Do that now.
--- drivers/media/i2c/ccs-pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ccs-pll.c +1 -1
@@ -799,7 +799,7 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim, op_lim_fr->min_pre_pll_clk_div, op_lim_fr->max_pre_pll_clk_div); max_op_pre_pll_clk_div =min_t (u16, op_lim_fr->max_pre_pll_clk_div, -clk_div_even (pll->ext_clk_freq_hz / +DIV_ROUND_UP (pll->ext_clk_freq_hz, op_lim_fr->min_pll_ip_clk_freq_hz)); min_op_pre_pll_clk_div = max_t(u16, op_lim_fr->min_pre_pll_clk_div,
Signature · 1 line
2.39.5
Re: [PATCH v2 04/11] media: ccs-pll: Correctly the upper limit of maximum op_pre_pll_clk_div
Hi Sakari,
Thank you for the patch.
In the subject line, s/Correctly/Correct/ (or an equivalent change)
Quoted 2 lines · Sakari Ailus
The PLL calculator does a search of the PLL configuration space for all valid OP pre-PLL clock dividers. The maximum did not take into account CCS
s/CCS/the CCS/
Quoted 15 lines
PLL flag
CCS_PLL_FLAG_EXT_IP_PLL_DIVIDERin which case also odd PLL dividers (other than 1) are valid. Do that now.Fixes 4e1e8d240dff ("media: ccs-pll: Add support for extended input PLL clock divider")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/i2c/ccs-pll.c +0
-0
drivers/media/i2c/ccs-pll.c int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim, · line 803
Quoted 6 lines
drivers/media/i2c/ccs-pll.c +1
-1@@ -799,7 +799,7 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim, op_lim_fr->min_pre_pll_clk_div, op_lim_fr->max_pre_pll_clk_div); max_op_pre_pll_clk_div =min_t (u16, op_lim_fr->max_pre_pll_clk_div, -clk_div_even (pll->ext_clk_freq_hz / +DIV_ROUND_UP (pll->ext_clk_freq_hz, op_lim_fr->min_pll_ip_clk_freq_hz));
This doesn't take the CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER flag into account. If I understand the code right, it's not an issue, as max_op_pre_pll_clk_div is only used as an upper bound for the pre_pll_clk_div loop, which increments by 2 when CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER isn't set.
drivers/media/i2c/ccs-pll.c int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim, · line 805
Quoted 2 lines
drivers/media/i2c/ccs-pll.c +0
-0min_op_pre_pll_clk_div = max_t(u16, op_lim_fr->min_pre_pll_clk_div,
pre_pll_clk_div--
Regards,
Laurent Pinchart
Sakari Ailus
maintainerRe: [PATCH v2 04/11] media: ccs-pll: Correctly the upper limit of maximum op_pre_pll_clk_div
Hi Laurent,
Quoted 31 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
In the subject line, s/Correctly/Correct/ (or an equivalent change)
Quoted 2 lines · Sakari Ailus
The PLL calculator does a search of the PLL configuration space for all valid OP pre-PLL clock dividers. The maximum did not take into account CCS
s/CCS/the CCS/
Quoted 19 lines
PLL flag
CCS_PLL_FLAG_EXT_IP_PLL_DIVIDERin which case also odd PLL dividers (other than 1) are valid. Do that now.Fixes 4e1e8d240dff ("media: ccs-pll: Add support for extended input PLL clock divider")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/i2c/ccs-pll.c +0
-1@@ -799,7 +799,7 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim, op_lim_fr->min_pre_pll_clk_div, op_lim_fr->max_pre_pll_clk_div); max_op_pre_pll_clk_div = min_t(u16, op_lim_fr->max_pre_pll_clk_div, - clk_div_even(pll->ext_clk_freq_hz /
Quoted 8 lines
drivers/media/i2c/ccs-pll.c int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim, · line 803
Quoted 2 lines
drivers/media/i2c/ccs-pll.c +1
-0+DIV_ROUND_UP (pll->ext_clk_freq_hz, op_lim_fr->min_pll_ip_clk_freq_hz));This doesn't take the
CCS_PLL_FLAG_EXT_IP_PLL_DIVIDERflag into account. If I understand the code right, it's not an issue, asmax_op_pre_pll_clk_divis only used as an upper bound for thepre_pll_clk_divloop, which increments by 2 whenCCS_PLL_FLAG_EXT_IP_PLL_DIVIDERisn't set.
Correct.
Quoted 2 lines
Reviewed-by Laurent Pinchart <[email protected]>
Thanks!
Signature · 3 lines
Regards, Sakari Ailus
Sakari Ailus
maintainerPATCH v2 5/11 media: ccs-pll: Print a debug message on too high VT PLL OP clock
In reply to Sakari AilusIn general the CCS PLL calculator prints debugging information on the process to ease debugging. This case was not annotated, do that now.
Remove an extra multiplication while at it.
--- drivers/media/i2c/ccs-pll.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/media/i2c/ccs-pll.c +5 -4
@@ -318,12 +318,13 @@ __ccs_pll_calculate_vt_tree(struct device *dev,return -EINVAL ; } -if (pll_fr->pll_multiplier * pll_fr->pll_ip_clk_freq_hz > - lim_fr->max_pll_op_clk_freq_hz) -return -EINVAL ; - pll_fr->pll_op_clk_freq_hz = pll_fr->pll_ip_clk_freq_hz * pll_fr->pll_multiplier; +if (pll_fr->pll_op_clk_freq_hz > lim_fr->max_pll_op_clk_freq_hz) { +dev_dbg (dev,"too high OP clock %u\n" , + pll_fr->pll_op_clk_freq_hz); +return -EINVAL ; + } vt_div = div * more_mul;
Signature · 1 line
2.39.5
Re: [PATCH v2 05/11] media: ccs-pll: Print a debug message on too high VT PLL OP clock
Hi Sakari,
Thank you for the patch.
Quoted 6 lines · Sakari Ailus
In general the CCS PLL calculator prints debugging information on the process to ease debugging. This case was not annotated, do that now.
Remove an extra multiplication while at it.
Signed-off-by Sakari Ailus <[email protected]>
Quoted 26 lines
--- drivers/media/i2c/ccs-pll.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/media/i2c/ccs-pll.c +5
-4@@ -318,12 +318,13 @@ __ccs_pll_calculate_vt_tree(struct device *dev,return -EINVAL ; } -if (pll_fr->pll_multiplier * pll_fr->pll_ip_clk_freq_hz > - lim_fr->max_pll_op_clk_freq_hz) -return -EINVAL ; - pll_fr->pll_op_clk_freq_hz = pll_fr->pll_ip_clk_freq_hz * pll_fr->pll_multiplier; +if (pll_fr->pll_op_clk_freq_hz > lim_fr->max_pll_op_clk_freq_hz) { +dev_dbg (dev,"too high OP clock %u\n" , + pll_fr->pll_op_clk_freq_hz); +return -EINVAL ; + } vt_div = div * more_mul;
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerPATCH v2 6/11 media: ccs-pll: Drop LINK_DECOUPLED flag
In reply to Sakari AilusThe LINK_DECOUPLED flag wasn't used by the PLL calculator other than printing it. The number of OP/VT lanes are already printed in any case. Thus drop the flag as it has no function.
--- drivers/media/i2c/ccs-pll.c | 3 +-- drivers/media/i2c/ccs-pll.h | 1 - drivers/media/i2c/ccs/ccs-core.c | 1 - drivers/media/i2c/ccs/ccs-quirk.c | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-)
drivers/media/i2c/ccs-pll.c +1 -2
@@ -124,9 +124,8 @@ static void print_pll(struct device *dev, const struct ccs_pll *pll)dev_dbg (dev,"pixel rate on CSI-2 bus:\t%u\n" , pll->pixel_rate_csi); - dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s\n", + dev_dbg(dev, "flags%s%s%s%s%s%s%s%s\n", pll->flags & PLL_FL(LANE_SPEED_MODEL) ? " lane-speed" : "", - pll->flags & PLL_FL(LINK_DECOUPLED) ? " link-decoupled" : "", pll->flags & PLL_FL(EXT_IP_PLL_DIVIDER) ? " ext-ip-pll-divider" : "", pll->flags & PLL_FL(FLEXIBLE_OP_PIX_CLK_DIV) ?
drivers/media/i2c/ccs-pll.h +0 -1
@@ -24,7 +24,6 @@#define CCS_PLL_FLAG_NO_OP_CLOCKS BIT(1)/* CCS PLL flags */ #define CCS_PLL_FLAG_LANE_SPEED_MODEL BIT(2) -#define CCS_PLL_FLAG_LINK_DECOUPLED BIT(3)#define CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER BIT(4)#define CCS_PLL_FLAG_FLEXIBLE_OP_PIX_CLK_DIV BIT(5)#define CCS_PLL_FLAG_FIFO_DERATING BIT(6)
drivers/media/i2c/ccs/ccs-core.c +0 -1
@@ -3451,7 +3451,6 @@ static int ccs_probe(struct i2c_client *client)CCS_LIM (sensor,NUM_OF_VT_LANES ) +1 ; sensor->pll.op_lanes =CCS_LIM (sensor,NUM_OF_OP_LANES ) +1 ; - sensor->pll.flags |=CCS_PLL_FLAG_LINK_DECOUPLED ; }else { sensor->pll.vt_lanes = sensor->pll.csi2.lanes; sensor->pll.op_lanes = sensor->pll.csi2.lanes;
drivers/media/i2c/ccs/ccs-quirk.c +1 -2
@@ -190,8 +190,7 @@ static int jt8ev1_post_streamoff(struct ccs_sensor *sensor)static int jt8ev1_init (struct ccs_sensor *sensor) { - sensor->pll.flags |=CCS_PLL_FLAG_LANE_SPEED_MODEL | -CCS_PLL_FLAG_LINK_DECOUPLED ; + sensor->pll.flags |=CCS_PLL_FLAG_LANE_SPEED_MODEL ; sensor->pll.vt_lanes =1 ; sensor->pll.op_lanes = sensor->pll.csi2.lanes;
Signature · 1 line
2.39.5
Re: [PATCH v2 06/11] media: ccs-pll: Drop LINK_DECOUPLED flag
Hi Sakari,
Thank you for the patch.
Quoted 1 line · Sakari Ailus
The
LINK_DECOUPLEDflag wasn't used by the PLL calculator other than
s/wasn't/isn't/
Quoted 64 lines
printing it. The number of OP/VT lanes are already printed in any case. Thus drop the flag as it has no function.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 3 +-- drivers/media/i2c/ccs-pll.h | 1 - drivers/media/i2c/ccs/ccs-core.c | 1 - drivers/media/i2c/ccs/ccs-quirk.c | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-)drivers/media/i2c/ccs-pll.c +1
-2@@ -124,9 +124,8 @@ static void print_pll(struct device *dev, const struct ccs_pll *pll)dev_dbg (dev,"pixel rate on CSI-2 bus:\t%u\n" , pll->pixel_rate_csi); - dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s\n", + dev_dbg(dev, "flags%s%s%s%s%s%s%s%s\n", pll->flags & PLL_FL(LANE_SPEED_MODEL) ? " lane-speed" : "", - pll->flags & PLL_FL(LINK_DECOUPLED) ? " link-decoupled" : "", pll->flags & PLL_FL(EXT_IP_PLL_DIVIDER) ? " ext-ip-pll-divider" : "", pll->flags & PLL_FL(FLEXIBLE_OP_PIX_CLK_DIV) ?drivers/media/i2c/ccs-pll.h +0
-1@@ -24,7 +24,6 @@#define CCS_PLL_FLAG_NO_OP_CLOCKS BIT(1)/* CCS PLL flags */ #define CCS_PLL_FLAG_LANE_SPEED_MODEL BIT(2) -#define CCS_PLL_FLAG_LINK_DECOUPLED BIT(3)#define CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER BIT(4)#define CCS_PLL_FLAG_FLEXIBLE_OP_PIX_CLK_DIV BIT(5)#define CCS_PLL_FLAG_FIFO_DERATING BIT(6)drivers/media/i2c/ccs/ccs-core.c +0
-1@@ -3451,7 +3451,6 @@ static int ccs_probe(struct i2c_client *client)CCS_LIM (sensor,NUM_OF_VT_LANES ) +1 ; sensor->pll.op_lanes =CCS_LIM (sensor,NUM_OF_OP_LANES ) +1 ; - sensor->pll.flags |=CCS_PLL_FLAG_LINK_DECOUPLED ; }else { sensor->pll.vt_lanes = sensor->pll.csi2.lanes; sensor->pll.op_lanes = sensor->pll.csi2.lanes;drivers/media/i2c/ccs/ccs-quirk.c +1
-2@@ -190,8 +190,7 @@ static int jt8ev1_post_streamoff(struct ccs_sensor *sensor)static int jt8ev1_init (struct ccs_sensor *sensor) { - sensor->pll.flags |=CCS_PLL_FLAG_LANE_SPEED_MODEL | -CCS_PLL_FLAG_LINK_DECOUPLED ; + sensor->pll.flags |=CCS_PLL_FLAG_LANE_SPEED_MODEL ; sensor->pll.vt_lanes =1 ; sensor->pll.op_lanes = sensor->pll.csi2.lanes;
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 06/11] media: ccs-pll: Drop LINK_DECOUPLED flag
Hi Laurent,
Quoted 8 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 1 line · Sakari Ailus
The
LINK_DECOUPLEDflag wasn't used by the PLL calculator other thans/wasn't/isn't/
To be fixed for v3:
I presume:
as there were no other comments. Please let me know if that's not correct.
Signature · 1 line
Sakari Ailus
Re: [PATCH v2 06/11] media: ccs-pll: Drop LINK_DECOUPLED flag
Quoted 12 lines · Sakari Ailus
Hi Laurent,
Quoted 8 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 1 line · Sakari Ailus
The
LINK_DECOUPLEDflag wasn't used by the PLL calculator other thans/wasn't/isn't/
Quoted 7 lines
To be fixed for v3:
I presume:
Reviewed-by Laurent Pinchart <[email protected]>as there were no other comments. Please let me know if that's not correct.
Indeed.
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerPATCH v2 7/11 media: ccs-pll: Print missing PLL flags
In reply to Sakari AilusPrinting the OP_PIX_CLOCK_PER_LANE and NO_OP_CLOCKS CCS PLL flags were missing, add them now.
--- drivers/media/i2c/ccs-pll.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/ccs-pll.c +3 -1
@@ -124,7 +124,9 @@ static void print_pll(struct device *dev, const struct ccs_pll *pll)dev_dbg (dev,"pixel rate on CSI-2 bus:\t%u\n" , pll->pixel_rate_csi); - dev_dbg(dev, "flags%s%s%s%s%s%s%s%s\n", + dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s\n", + pll->flags & PLL_FL(OP_PIX_CLOCK_PER_LANE) ? " op-pix-clock-per-lane" : "", + pll->flags & PLL_FL(NO_OP_CLOCKS) ? " no-op-clocks" : "", pll->flags & PLL_FL(LANE_SPEED_MODEL) ? " lane-speed" : "", pll->flags & PLL_FL(EXT_IP_PLL_DIVIDER) ? " ext-ip-pll-divider" : "",
Signature · 1 line
2.39.5
Re: [PATCH v2 07/11] media: ccs-pll: Print missing PLL flags
Hi Sakari,
Thank you for the patch.
Quoted 1 line · Sakari Ailus
Printing the
OP_PIX_CLOCK_PER_LANEandNO_OP_CLOCKSCCS PLL flags were
s/were/is/
Quoted 3 lines
missing, add them now.
Signed-off-by Sakari Ailus <[email protected]>
Quoted 19 lines
--- drivers/media/i2c/ccs-pll.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/media/i2c/ccs-pll.c +3
-1@@ -124,7 +124,9 @@ static void print_pll(struct device *dev, const struct ccs_pll *pll)dev_dbg (dev,"pixel rate on CSI-2 bus:\t%u\n" , pll->pixel_rate_csi); - dev_dbg(dev, "flags%s%s%s%s%s%s%s%s\n", + dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s\n", + pll->flags & PLL_FL(OP_PIX_CLOCK_PER_LANE) ? " op-pix-clock-per-lane" : "", + pll->flags & PLL_FL(NO_OP_CLOCKS) ? " no-op-clocks" : "", pll->flags & PLL_FL(LANE_SPEED_MODEL) ? " lane-speed" : "", pll->flags & PLL_FL(EXT_IP_PLL_DIVIDER) ? " ext-ip-pll-divider" : "",
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerPATCH v2 8/11 media: ccs-pll: Add a flag for even PLL multipliers
In reply to Sakari AilusSome devices (not entirely CCS compliant) only support even PLL multipliers. Add support for this through a PLL flag.
--- drivers/media/i2c/ccs-pll.c | 11 ++++++++++- drivers/media/i2c/ccs-pll.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/media/i2c/ccs-pll.c +10 -1
@@ -124,9 +124,10 @@ static void print_pll(struct device *dev, const struct ccs_pll *pll)dev_dbg (dev,"pixel rate on CSI-2 bus:\t%u\n" , pll->pixel_rate_csi); - dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s\n", + dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s%s\n", pll->flags & PLL_FL(OP_PIX_CLOCK_PER_LANE) ? " op-pix-clock-per-lane" : "", pll->flags & PLL_FL(NO_OP_CLOCKS) ? " no-op-clocks" : "", + pll->flags & PLL_FL(EVEN_PLL_MULTIPLIER) ? " even-pll-multiplier" : "", pll->flags & PLL_FL(LANE_SPEED_MODEL) ? " lane-speed" : "", pll->flags & PLL_FL(EXT_IP_PLL_DIVIDER) ? " ext-ip-pll-divider" : "",
@@ -312,6 +313,10 @@ __ccs_pll_calculate_vt_tree(struct device *dev, more_mul *=DIV_ROUND_UP (lim_fr->min_pll_multiplier, mul * more_mul);dev_dbg (dev,"more_mul2: %u\n" , more_mul); +if (pll->flags &CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER && + mul &1 && more_mul &1 ) + more_mul <<=1 ; + pll_fr->pll_multiplier = mul * more_mul;if (pll_fr->pll_multiplier > lim_fr->max_pll_multiplier) { dev_dbg(dev, "pll multiplier %u too high\n",
@@ -668,6 +673,10 @@ ccs_pll_calculate_op(struct device *dev, const struct ccs_pll_limits *lim,if (!is_one_or_even (i)) i <<=1 ; +if (pll->flags &CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER && + mul &1 && i &1 ) + i <<=1 ; +dev_dbg (dev,"final more_mul: %u\n" , i);if (i > more_mul_max) {dev_dbg (dev,"final more_mul is bad, max %u\n" , more_mul_max);
drivers/media/i2c/ccs-pll.h +1 -0
@@ -31,6 +31,7 @@#define CCS_PLL_FLAG_DUAL_PLL BIT(8)#define CCS_PLL_FLAG_OP_SYS_DDR BIT(9)#define CCS_PLL_FLAG_OP_PIX_DDR BIT(10) +#define CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER BIT(11)/** * struct ccs_pll_branch_fr - CCS PLL configuration (front)
Signature · 1 line
2.39.5
Re: [PATCH v2 08/11] media: ccs-pll: Add a flag for even PLL multipliers
Hi Sakari,
Thank you for the patch.
Quoted 26 lines · Sakari Ailus
Some devices (not entirely CCS compliant) only support even PLL multipliers. Add support for this through a PLL flag.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 11 ++++++++++- drivers/media/i2c/ccs-pll.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)drivers/media/i2c/ccs-pll.c +2
-1@@ -124,9 +124,10 @@ static void print_pll(struct device *dev, const struct ccs_pll *pll)dev_dbg (dev,"pixel rate on CSI-2 bus:\t%u\n" , pll->pixel_rate_csi); - dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s\n", + dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s%s\n", pll->flags & PLL_FL(OP_PIX_CLOCK_PER_LANE) ? " op-pix-clock-per-lane" : "", pll->flags & PLL_FL(NO_OP_CLOCKS) ? " no-op-clocks" : "", + pll->flags & PLL_FL(EVEN_PLL_MULTIPLIER) ? " even-pll-multiplier" : "", pll->flags & PLL_FL(LANE_SPEED_MODEL) ? " lane-speed" : "", pll->flags & PLL_FL(EXT_IP_PLL_DIVIDER) ? " ext-ip-pll-divider" : "",
drivers/media/i2c/ccs-pll.c __ccs_pll_calculate_vt_tree(struct device *dev, · line 317
Quoted 5 lines
drivers/media/i2c/ccs-pll.c +2
-0@@ -312,6 +313,10 @@ __ccs_pll_calculate_vt_tree(struct device *dev, more_mul *=DIV_ROUND_UP (lim_fr->min_pll_multiplier, mul * more_mul);dev_dbg (dev,"more_mul2: %u\n" , more_mul); +if (pll->flags &CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER && + mul &1 && more_mul &1 )
Even if not mandated by the C standard, I'd write
(mul & 1) && (more_mul & 1))
to make the code easier to read.
drivers/media/i2c/ccs-pll.c __ccs_pll_calculate_vt_tree(struct device *dev, · line 318
Quoted 1 line
drivers/media/i2c/ccs-pll.c +1
-0+ more_mul <<=1 ;
I'm not sure to get the logic behind this :-/
drivers/media/i2c/ccs-pll.c ccs_pll_calculate_op(struct device *dev, const struct ccs_pll_limits *lim, · line 677
Quoted 10 lines
drivers/media/i2c/ccs-pll.c +3
-0+ pll_fr->pll_multiplier = mul * more_mul;if (pll_fr->pll_multiplier > lim_fr->max_pll_multiplier) { dev_dbg(dev, "pll multiplier %u too high\n",@@ -668,6 +673,10 @@ ccs_pll_calculate_op(struct device *dev, const struct ccs_pll_limits *lim,if (!is_one_or_even (i)) i <<=1 ; +if (pll->flags &CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER && + mul &1 && i &1 )
Same here.
Quoted 10 lines
drivers/media/i2c/ccs-pll.c +2
-0+ i <<=1 ; +dev_dbg (dev,"final more_mul: %u\n" , i);if (i > more_mul_max) {dev_dbg (dev,"final more_mul is bad, max %u\n" , more_mul_max);drivers/media/i2c/ccs-pll.h +0
-0
drivers/media/i2c/ccs-pll.h line 34
Quoted 4 lines
drivers/media/i2c/ccs-pll.h +1
-0@@ -31,6 +31,7 @@#define CCS_PLL_FLAG_DUAL_PLL BIT(8)#define CCS_PLL_FLAG_OP_SYS_DDR BIT(9)#define CCS_PLL_FLAG_OP_PIX_DDR BIT(10) +#define CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER BIT(11)
You could reuse bit 3, as it got dropped in patch 06/11.
Quoted 3 lines
drivers/media/i2c/ccs-pll.h +0
-0/** * struct ccs_pll_branch_fr - CCS PLL configuration (front)
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerRe: [PATCH v2 08/11] media: ccs-pll: Add a flag for even PLL multipliers
Hi Laurent,
Quoted 3 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Thank you for the review!
Quoted 31 lines · Sakari Ailus
Quoted 29 lines
Some devices (not entirely CCS compliant) only support even PLL multipliers. Add support for this through a PLL flag.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 11 ++++++++++- drivers/media/i2c/ccs-pll.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)drivers/media/i2c/ccs-pll.c +2
-1@@ -124,9 +124,10 @@ static void print_pll(struct device *dev, const struct ccs_pll *pll)dev_dbg (dev,"pixel rate on CSI-2 bus:\t%u\n" , pll->pixel_rate_csi); - dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s\n", + dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s%s\n", pll->flags & PLL_FL(OP_PIX_CLOCK_PER_LANE) ? " op-pix-clock-per-lane" : "", pll->flags & PLL_FL(NO_OP_CLOCKS) ? " no-op-clocks" : "", + pll->flags & PLL_FL(EVEN_PLL_MULTIPLIER) ? " even-pll-multiplier" : "", pll->flags & PLL_FL(LANE_SPEED_MODEL) ? " lane-speed" : "", pll->flags & PLL_FL(EXT_IP_PLL_DIVIDER) ? " ext-ip-pll-divider" : "",@@ -312,6 +313,10 @@ __ccs_pll_calculate_vt_tree(struct device *dev, more_mul *=DIV_ROUND_UP (lim_fr->min_pll_multiplier, mul * more_mul);dev_dbg (dev,"more_mul2: %u\n" , more_mul);
Quoted 8 lines
drivers/media/i2c/ccs-pll.c __ccs_pll_calculate_vt_tree(struct device *dev, · line 317
Quoted 2 lines
drivers/media/i2c/ccs-pll.c +2
-0+if (pll->flags &CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER && + mul &1 && more_mul &1 )Even if not mandated by the C standard, I'd write
(mul & 1) && (more_mul & 1))to make the code easier to read.
I'll address this in v3.
Quoted 4 lines
drivers/media/i2c/ccs-pll.c __ccs_pll_calculate_vt_tree(struct device *dev, · line 318
Quoted 2 lines
drivers/media/i2c/ccs-pll.c +1
-0+ more_mul <<=1 ;I'm not sure to get the logic behind this :-/
Multiplying an odd number with an even number results in an even number, this is what we need if the above flag is set.
Quoted 14 lines
drivers/media/i2c/ccs-pll.c ccs_pll_calculate_op(struct device *dev, const struct ccs_pll_limits *lim, · line 677
Quoted 11 lines
drivers/media/i2c/ccs-pll.c +3
-0+ pll_fr->pll_multiplier = mul * more_mul;if (pll_fr->pll_multiplier > lim_fr->max_pll_multiplier) { dev_dbg(dev, "pll multiplier %u too high\n",@@ -668,6 +673,10 @@ ccs_pll_calculate_op(struct device *dev, const struct ccs_pll_limits *lim,if (!is_one_or_even (i)) i <<=1 ; +if (pll->flags &CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER && + mul &1 && i &1 )Same here.
Quoted 16 lines
Quoted 10 lines
drivers/media/i2c/ccs-pll.c +2
-0+ i <<=1 ; +dev_dbg (dev,"final more_mul: %u\n" , i);if (i > more_mul_max) {dev_dbg (dev,"final more_mul is bad, max %u\n" , more_mul_max);drivers/media/i2c/ccs-pll.h +0
-0drivers/media/i2c/ccs-pll.h line 34
Quoted 4 lines
drivers/media/i2c/ccs-pll.h +1
-0@@ -31,6 +31,7 @@#define CCS_PLL_FLAG_DUAL_PLL BIT(8)#define CCS_PLL_FLAG_OP_SYS_DDR BIT(9)#define CCS_PLL_FLAG_OP_PIX_DDR BIT(10) +#define CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER BIT(11)You could reuse bit 3, as it got dropped in patch 06/11.
I'll move it there, also for the reason that this isn't a CCS flag.
Quoted 5 lines
Quoted 4 lines
drivers/media/i2c/ccs-pll.h +0
-0/** * struct ccs_pll_branch_fr - CCS PLL configuration (front)
Signature · 3 lines
Regards, Sakari Ailus
Sakari Ailus
maintainerPATCH v2 9/11 media: ccs-pll: Better validate VT PLL branch
In reply to Sakari AilusCheck that the VT PLL dividers are actually found, don't trust they always are even though they should be.
--- drivers/media/i2c/ccs-pll.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/media/i2c/ccs-pll.c +9 -3
@@ -449,7 +449,7 @@ static int ccs_pll_calculate_vt_tree(struct device *dev,return -EINVAL ; } -static void +static int ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim, const struct ccs_pll_branch_limits_bk *op_lim_bk, struct ccs_pll *pll, struct ccs_pll_branch_fr *pll_fr,
@@ -572,6 +572,8 @@ ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim,if (best_pix_div <SHRT_MAX >>1 )break ; } +if (best_pix_div ==SHRT_MAX >>1 ) +return -EINVAL ; pll->vt_bk.sys_clk_div =DIV_ROUND_UP (vt_div, best_pix_div); pll->vt_bk.pix_clk_div = best_pix_div;
@@ -584,6 +586,8 @@ ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim, out_calc_pixel_rate: pll->pixel_rate_pixel_array = pll->vt_bk.pix_clk_freq_hz * pll->vt_lanes; + +return 0 ; }/*
@@ -863,8 +867,10 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,if (pll->flags &CCS_PLL_FLAG_DUAL_PLL )break ; -ccs_pll_calculate_vt (dev, lim, op_lim_bk, pll, op_pll_fr, - op_pll_bk, cphy, phy_const); + rval =ccs_pll_calculate_vt (dev, lim, op_lim_bk, pll, op_pll_fr, + op_pll_bk, cphy, phy_const); +if (rval) +continue ; rval =check_bk_bounds (dev, lim, pll,PLL_VT );if (rval)
Signature · 1 line
2.39.5
Re: [PATCH v2 09/11] media: ccs-pll: Better validate VT PLL branch
Hi Sakari,
Thank you for the patch.
Quoted 22 lines · Sakari Ailus
Check that the VT PLL dividers are actually found, don't trust they always are even though they should be.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/media/i2c/ccs-pll.c +1
-1@@ -449,7 +449,7 @@ static int ccs_pll_calculate_vt_tree(struct device *dev,return -EINVAL ; } -static void +static int ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim, const struct ccs_pll_branch_limits_bk *op_lim_bk, struct ccs_pll *pll, struct ccs_pll_branch_fr *pll_fr,
drivers/media/i2c/ccs-pll.c ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim, · line 576
Quoted 5 lines
drivers/media/i2c/ccs-pll.c +2
-0@@ -572,6 +572,8 @@ ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim,if (best_pix_div <SHRT_MAX >>1 )break ; } +if (best_pix_div ==SHRT_MAX >>1 ) +return -EINVAL ;
I think I would have written
if (vt_div > max_vt_div) return -EINVAL;
to match the for loop condition, this seems a bit more readable to me. The result should be the same though, so either way,
Quoted 25 lines
drivers/media/i2c/ccs-pll.c +6
-2pll->vt_bk.sys_clk_div =DIV_ROUND_UP (vt_div, best_pix_div); pll->vt_bk.pix_clk_div = best_pix_div;@@ -584,6 +586,8 @@ ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim, out_calc_pixel_rate: pll->pixel_rate_pixel_array = pll->vt_bk.pix_clk_freq_hz * pll->vt_lanes; + +return 0 ; }/* @@ -863,8 +867,10 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,if (pll->flags &CCS_PLL_FLAG_DUAL_PLL )break ; -ccs_pll_calculate_vt (dev, lim, op_lim_bk, pll, op_pll_fr, - op_pll_bk, cphy, phy_const); + rval =ccs_pll_calculate_vt (dev, lim, op_lim_bk, pll, op_pll_fr, + op_pll_bk, cphy, phy_const); +if (rval) +continue ; rval =check_bk_bounds (dev, lim, pll,PLL_VT );if (rval)
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerRe: [PATCH v2 09/11] media: ccs-pll: Better validate VT PLL branch
Hi Laurent,
Quoted 35 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 22 lines · Sakari Ailus
Check that the VT PLL dividers are actually found, don't trust they always are even though they should be.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/media/i2c/ccs-pll.c +1
-1@@ -449,7 +449,7 @@ static int ccs_pll_calculate_vt_tree(struct device *dev,return -EINVAL ; } -static void +static int ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim, const struct ccs_pll_branch_limits_bk *op_lim_bk, struct ccs_pll *pll, struct ccs_pll_branch_fr *pll_fr,drivers/media/i2c/ccs-pll.c ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim, · line 576
Quoted 5 lines
drivers/media/i2c/ccs-pll.c +2
-0@@ -572,6 +572,8 @@ ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim,if (best_pix_div <SHRT_MAX >>1 )break ; } +if (best_pix_div ==SHRT_MAX >>1 ) +return -EINVAL ;I think I would have written
Quoted 4 lines
if (vt_div > max_vt_div) return -EINVAL;to match the for loop condition, this seems a bit more readable to me.
Comparing with the value assigned in the variable initialisation seems most straightforward to me. But the value could be U16_MAX, that'd be nicer than SHRT_MAX >> 1. U16_MAX was added before the first instance of this was merged. :-)
I'll add a new patch to change this, after this set.
Quoted 3 lines
The result should be the same though, so either way,
Reviewed-by Laurent Pinchart <[email protected]>
Thank you!
Signature · 3 lines
Regards, Sakari Ailus
Sakari Ailus
maintainerPATCH v2 10/11 media: ccs-pll: Print PLL calculator flags in the beginning
In reply to Sakari AilusPrint the PLL calculator flags right away when the PLL calculator is called. Previously this was done only in a successful case and that didn't really help solving a problem when one happened.
--- drivers/media/i2c/ccs-pll.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/media/i2c/ccs-pll.c +6 -1
@@ -123,8 +123,11 @@ static void print_pll(struct device *dev, const struct ccs_pll *pll) pll->pixel_rate_pixel_array);dev_dbg (dev,"pixel rate on CSI-2 bus:\t%u\n" , pll->pixel_rate_csi); +} - dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s%s\n", +static void print_pll_flags (struct device *dev,struct ccs_pll *pll) +{ + dev_dbg(dev, "PLL flags%s%s%s%s%s%s%s%s%s%s%s\n", pll->flags & PLL_FL(OP_PIX_CLOCK_PER_LANE) ? " op-pix-clock-per-lane" : "", pll->flags & PLL_FL(NO_OP_CLOCKS) ? " no-op-clocks" : "", pll->flags & PLL_FL(EVEN_PLL_MULTIPLIER) ? " even-pll-multiplier" : "",
@@ -738,6 +741,8 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,u32 i;int rval = -EINVAL ; +print_pll_flags (dev, pll); +if (!(pll->flags &CCS_PLL_FLAG_LANE_SPEED_MODEL )) { pll->op_lanes =1 ; pll->vt_lanes =1 ;
Signature · 1 line
2.39.5
Re: [PATCH v2 10/11] media: ccs-pll: Print PLL calculator flags in the beginning
Hi Sakari,
Thank you for the patch.
Quoted 5 lines · Sakari Ailus
Print the PLL calculator flags right away when the PLL calculator is called. Previously this was done only in a successful case and that didn't really help solving a problem when one happened.
Signed-off-by Sakari Ailus <[email protected]>
Quoted 30 lines
--- drivers/media/i2c/ccs-pll.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/media/i2c/ccs-pll.c +6
-1@@ -123,8 +123,11 @@ static void print_pll(struct device *dev, const struct ccs_pll *pll) pll->pixel_rate_pixel_array);dev_dbg (dev,"pixel rate on CSI-2 bus:\t%u\n" , pll->pixel_rate_csi); +} - dev_dbg(dev, "flags%s%s%s%s%s%s%s%s%s%s%s\n", +static void print_pll_flags (struct device *dev,struct ccs_pll *pll) +{ + dev_dbg(dev, "PLL flags%s%s%s%s%s%s%s%s%s%s%s\n", pll->flags & PLL_FL(OP_PIX_CLOCK_PER_LANE) ? " op-pix-clock-per-lane" : "", pll->flags & PLL_FL(NO_OP_CLOCKS) ? " no-op-clocks" : "", pll->flags & PLL_FL(EVEN_PLL_MULTIPLIER) ? " even-pll-multiplier" : "",@@ -738,6 +741,8 @@ int ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,u32 i;int rval = -EINVAL ; +print_pll_flags (dev, pll); +if (!(pll->flags &CCS_PLL_FLAG_LANE_SPEED_MODEL )) { pll->op_lanes =1 ; pll->vt_lanes =1 ;
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerPATCH v2 11/11 media: ccs-pll: Document the CCS PLL flags
In reply to Sakari AilusDocument the CCS PLL flags with short comments. The CCS spec has more information on them while the added documentation helps finding the relevant information in the CCS spec.
--- drivers/media/i2c/ccs-pll.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
drivers/media/i2c/ccs-pll.h +24 -3
@@ -18,19 +18,40 @@#define CCS_PLL_BUS_TYPE_CSI2_DPHY 0x00#define CCS_PLL_BUS_TYPE_CSI2_CPHY 0x01 -/* Old SMIA and implementation specific flags */ -/* op pix clock is for all lanes in total normally */ +/* Old SMIA and implementation specific flags. */ +/* OP PIX clock is for all lanes in total normally. */ #define CCS_PLL_FLAG_OP_PIX_CLOCK_PER_LANE BIT(0) -#define CCS_PLL_FLAG_NO_OP_CLOCKS BIT(1) +/* CCS PLL flags */ + +/* The sensor doesn't have OP clocks at all. */ +#define CCS_PLL_FLAG_NO_OP_CLOCKS BIT(1) +/* System speed model if this flag is unset. */ #define CCS_PLL_FLAG_LANE_SPEED_MODEL BIT(2) +/* If set, the pre-PLL divider may have odd values, too. */ #define CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER BIT(4) +/* +* If set, the OP PIX clock doesn't have to exactly match with data rate, it may +* be higher. See "OP Domain Formulas" in MIPI CCS 1.1 spec. +*/ #define CCS_PLL_FLAG_FLEXIBLE_OP_PIX_CLK_DIV BIT(5) +/* If set, the VT domain may run faster than the OP domain. */ #define CCS_PLL_FLAG_FIFO_DERATING BIT(6) +/* If set, the VT domain may run slower than the OP domain. */ #define CCS_PLL_FLAG_FIFO_OVERRATING BIT(7) +/* If set, the PLL tree has two PLLs instead of one. */ #define CCS_PLL_FLAG_DUAL_PLL BIT(8) +/* +* If set, the OP SYS clock is a dual data rate clock, transferring two bits per +* cycle instead of one. +*/ #define CCS_PLL_FLAG_OP_SYS_DDR BIT(9) +/* +* If set, the OP PIX clock is a dual data rate clock, transferring two bits per +* cycle instead of one. +*/ #define CCS_PLL_FLAG_OP_PIX_DDR BIT(10) +/* If set, the PLL multipliers are required to be even. */ #define CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER BIT(11)/**
Signature · 1 line
2.39.5
Re: [PATCH v2 11/11] media: ccs-pll: Document the CCS PLL flags
Hi Sakari,
Thank you for the patch.
Quoted 3 lines · Sakari Ailus
Document the CCS PLL flags with short comments. The CCS spec has more information on them while the added documentation helps finding the relevant information in the CCS spec.
Oohhhh, documentation, that's nice :-)
Quoted 37 lines
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)drivers/media/i2c/ccs-pll.h +14
-3@@ -18,19 +18,40 @@#define CCS_PLL_BUS_TYPE_CSI2_DPHY 0x00#define CCS_PLL_BUS_TYPE_CSI2_CPHY 0x01 -/* Old SMIA and implementation specific flags */ -/* op pix clock is for all lanes in total normally */ +/* Old SMIA and implementation specific flags. */ +/* OP PIX clock is for all lanes in total normally. */ #define CCS_PLL_FLAG_OP_PIX_CLOCK_PER_LANE BIT(0) -#define CCS_PLL_FLAG_NO_OP_CLOCKS BIT(1) +/* CCS PLL flags */ + +/* The sensor doesn't have OP clocks at all. */ +#define CCS_PLL_FLAG_NO_OP_CLOCKS BIT(1) +/* System speed model if this flag is unset. */ #define CCS_PLL_FLAG_LANE_SPEED_MODEL BIT(2) +/* If set, the pre-PLL divider may have odd values, too. */ #define CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER BIT(4) +/* +* If set, the OP PIX clock doesn't have to exactly match with data rate, it may +* be higher. See "OP Domain Formulas" in MIPI CCS 1.1 spec. +*/ #define CCS_PLL_FLAG_FLEXIBLE_OP_PIX_CLK_DIV BIT(5) +/* If set, the VT domain may run faster than the OP domain. */ #define CCS_PLL_FLAG_FIFO_DERATING BIT(6) +/* If set, the VT domain may run slower than the OP domain. */ #define CCS_PLL_FLAG_FIFO_OVERRATING BIT(7)
drivers/media/i2c/ccs-pll.h line 51
Quoted 10 lines
drivers/media/i2c/ccs-pll.h +8
-0+/* If set, the PLL tree has two PLLs instead of one. */ #define CCS_PLL_FLAG_DUAL_PLL BIT(8) +/* +* If set, the OP SYS clock is a dual data rate clock, transferring two bits per +* cycle instead of one. +*/ #define CCS_PLL_FLAG_OP_SYS_DDR BIT(9) +/* +* If set, the OP PIX clock is a dual data rate clock, transferring two bits per +* cycle instead of one.
Should this be "two pixels per cycle" ?
Quoted 6 lines
drivers/media/i2c/ccs-pll.h +2
-0+*/ #define CCS_PLL_FLAG_OP_PIX_DDR BIT(10) +/* If set, the PLL multipliers are required to be even. */ #define CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER BIT(11)/**
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerRe: [PATCH v2 11/11] media: ccs-pll: Document the CCS PLL flags
Hi Laurent,
Quoted 52 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 3 lines · Sakari Ailus
Document the CCS PLL flags with short comments. The CCS spec has more information on them while the added documentation helps finding the relevant information in the CCS spec.
Oohhhh, documentation, that's nice :-)
Quoted 41 lines
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs-pll.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)drivers/media/i2c/ccs-pll.h +17
-3@@ -18,19 +18,40 @@#define CCS_PLL_BUS_TYPE_CSI2_DPHY 0x00#define CCS_PLL_BUS_TYPE_CSI2_CPHY 0x01 -/* Old SMIA and implementation specific flags */ -/* op pix clock is for all lanes in total normally */ +/* Old SMIA and implementation specific flags. */ +/* OP PIX clock is for all lanes in total normally. */ #define CCS_PLL_FLAG_OP_PIX_CLOCK_PER_LANE BIT(0) -#define CCS_PLL_FLAG_NO_OP_CLOCKS BIT(1) +/* CCS PLL flags */ + +/* The sensor doesn't have OP clocks at all. */ +#define CCS_PLL_FLAG_NO_OP_CLOCKS BIT(1) +/* System speed model if this flag is unset. */ #define CCS_PLL_FLAG_LANE_SPEED_MODEL BIT(2) +/* If set, the pre-PLL divider may have odd values, too. */ #define CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER BIT(4) +/* +* If set, the OP PIX clock doesn't have to exactly match with data rate, it may +* be higher. See "OP Domain Formulas" in MIPI CCS 1.1 spec. +*/ #define CCS_PLL_FLAG_FLEXIBLE_OP_PIX_CLK_DIV BIT(5) +/* If set, the VT domain may run faster than the OP domain. */ #define CCS_PLL_FLAG_FIFO_DERATING BIT(6) +/* If set, the VT domain may run slower than the OP domain. */ #define CCS_PLL_FLAG_FIFO_OVERRATING BIT(7) +/* If set, the PLL tree has two PLLs instead of one. */ #define CCS_PLL_FLAG_DUAL_PLL BIT(8) +/* +* If set, the OP SYS clock is a dual data rate clock, transferring two bits per
Quoted 8 lines
drivers/media/i2c/ccs-pll.h line 51
Quoted 6 lines
drivers/media/i2c/ccs-pll.h +5
-0+* cycle instead of one. +*/ #define CCS_PLL_FLAG_OP_SYS_DDR BIT(9) +/* +* If set, the OP PIX clock is a dual data rate clock, transferring two bits per +* cycle instead of one. Should this be "two pixels per cycle" ?
Good catch. I'll fix that for v3.
Quoted 2 lines
Reviewed-by Laurent Pinchart <[email protected]>
Thank you!
Quoted 8 lines
Quoted 7 lines
drivers/media/i2c/ccs-pll.h +2
-0+*/ #define CCS_PLL_FLAG_OP_PIX_DDR BIT(10) +/* If set, the PLL multipliers are required to be even. */ #define CCS_PLL_FLAG_EVEN_PLL_MULTIPLIER BIT(11)/**
Signature · 3 lines
Kind regards, Sakari Ailus