drm/i915: clean up dsi pll calculation
Subsystems (2)
PATCH 1/1 drm/i915: clean up dsi pll calculation
Improve readability. No functional changes.
---
Cleaning up old branches... :)
--- drivers/gpu/drm/i915/intel_dsi_pll.c | 52 ++++++++++++------------------------ 1 file changed, 17 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/intel_dsi_pll.c +17 -35
@@ -162,53 +162,35 @@ static u32 dsi_clk_from_pclk(u32 pclk, int pixel_format, int lane_count)#endif -static int dsi_calc_mnp (u32 dsi_clk,struct dsi_mnp *dsi_mnp) +static int dsi_calc_mnp (u32 target_dsi_clk,struct dsi_mnp *dsi_mnp) {u32 m, n, p; -u32 ref_clk; -u32 error; -u32 tmp_error; -int target_dsi_clk; -int calc_dsi_clk; -u32 calc_m; -u32 calc_p; +u32 ref_clk =25000 ; +u32 delta = target_dsi_clk; +u32 calc_m =0 ; +u32 calc_p =0 ;u32 m_seed; -/* dsi_clk is expected in KHZ */ -if (dsi_clk <300000 || dsi_clk >1150000 ) { +/* target_dsi_clk is expected in KHZ */ +if (target_dsi_clk <300000 || target_dsi_clk >1150000 ) {DRM_ERROR ("DSI CLK Out of Range\n" );return -ECHRNG ; } - ref_clk =25000 ; - target_dsi_clk = dsi_clk; - error =0xFFFFFFFF ; - tmp_error =0xFFFFFFFF ; - calc_m =0 ; - calc_p =0 ; - -for (m =62 ; m <=92 ; m++) { -for (p =2 ; p <=6 ; p++) { -/* Find the optimal m and p divisors -with minimal error +/- the required clock */ - calc_dsi_clk = (m * ref_clk) / p; -if (calc_dsi_clk == target_dsi_clk) { - calc_m = m; - calc_p = p; - error =0 ; -break ; - }else - tmp_error =abs (target_dsi_clk - calc_dsi_clk); - -if (tmp_error < error) { - error = tmp_error; +for (m =62 ; m <=92 && delta; m++) { +for (p =2 ; p <=6 && delta; p++) { +/* +* Find the optimal m and p divisors with minimal delta +* +/- the required clock +*/ +int calc_dsi_clk = (m * ref_clk) / p; +u32 d =abs (target_dsi_clk - calc_dsi_clk); +if (d < delta) { + delta = d; calc_m = m; calc_p = p; } } - -if (error ==0 ) -break ; } m_seed = lfsr_converts[calc_m -62 ];
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Task id: 6346 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
PNV 276/276 276/276 ILK 282/282 282/282 SNB 316/316 316/316 IVB 342/342 342/342 BYT 286/286 286/286 BDW 321/321 321/321
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 64 lines · Jani Nikula
Improve readability. No functional changes.
Signed-off-by Jani Nikula <[email protected]>---
Cleaning up old branches... :)
--- drivers/gpu/drm/i915/intel_dsi_pll.c | 52 ++++++++++++------------------------ 1 file changed, 17 insertions(+), 35 deletions(-)drivers/gpu/drm/i915/intel_dsi_pll.c +7
-30@@ -162,53 +162,35 @@ static u32 dsi_clk_from_pclk(u32 pclk, int pixel_format, int lane_count)#endif -static int dsi_calc_mnp (u32 dsi_clk,struct dsi_mnp *dsi_mnp) +static int dsi_calc_mnp (u32 target_dsi_clk,struct dsi_mnp *dsi_mnp) {u32 m, n, p; -u32 ref_clk; -u32 error; -u32 tmp_error; -int target_dsi_clk; -int calc_dsi_clk; -u32 calc_m; -u32 calc_p; +u32 ref_clk =25000 ; +u32 delta = target_dsi_clk; +u32 calc_m =0 ; +u32 calc_p =0 ;u32 m_seed; -/* dsi_clk is expected in KHZ */ -if (dsi_clk <300000 || dsi_clk >1150000 ) { +/* target_dsi_clk is expected in KHZ */ +if (target_dsi_clk <300000 || target_dsi_clk >1150000 ) {DRM_ERROR ("DSI CLK Out of Range\n" );return -ECHRNG ; } - ref_clk =25000 ; - target_dsi_clk = dsi_clk; - error =0xFFFFFFFF ; - tmp_error =0xFFFFFFFF ; - calc_m =0 ; - calc_p =0 ; - -for (m =62 ; m <=92 ; m++) { -for (p =2 ; p <=6 ; p++) { -/* Find the optimal m and p divisors -with minimal error +/- the required clock */ - calc_dsi_clk = (m * ref_clk) / p; -if (calc_dsi_clk == target_dsi_clk) { - calc_m = m; - calc_p = p; - error =0 ; -break ; - }else - tmp_error =abs (target_dsi_clk - calc_dsi_clk); -
drivers/gpu/drm/i915/intel_dsi_pll.c static u32 dsi_clk_from_pclk(u32 pclk, int pixel_format, int lane_count) · line 187
Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_pll.c +8
-2-if (tmp_error < error) { - error = tmp_error; +for (m =62 ; m <=92 && delta; m++) { +for (p =2 ; p <=6 && delta; p++) { +/* +* Find the optimal m and p divisors with minimal delta +* +/- the required clock +*/ +int calc_dsi_clk = (m * ref_clk) / p; +u32 d =abs (target_dsi_clk - calc_dsi_clk);
'target_dsi_clk - calc_dsi_clk' is going to be unsigned, so this is still a bit confusing. abs() does stick that into a signed int before comparing it, so it should just work, but still might be sensible to make target_dsi_clk signed.
Also perhaps s/u32/unsigned int/ (or maybe just use int) all over?
Quoted 19 lines
drivers/gpu/drm/i915/intel_dsi_pll.c +2
-3+if (d < delta) { + delta = d; calc_m = m; calc_p = p; } } - -if (error ==0 ) -break ; } m_seed = lfsr_converts[calc_m -62 ];Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: clean up dsi pll calculation
Improve readability. No functional changes.
v2: use more rational types (Ville)
--- drivers/gpu/drm/i915/intel_dsi_pll.c | 53 ++++++++++++------------------------ 1 file changed, 17 insertions(+), 36 deletions(-)
drivers/gpu/drm/i915/intel_dsi_pll.c +17 -36
@@ -162,53 +162,34 @@ static u32 dsi_clk_from_pclk(u32 pclk, int pixel_format, int lane_count)#endif -static int dsi_calc_mnp (u32 dsi_clk,struct dsi_mnp *dsi_mnp) +static int dsi_calc_mnp (int target_dsi_clk,struct dsi_mnp *dsi_mnp) { -u32 m, n, p; -u32 ref_clk; -u32 error; -u32 tmp_error; -int target_dsi_clk; -int calc_dsi_clk; -u32 calc_m; -u32 calc_p; +unsigned int calc_m =0 , calc_p =0 ; +unsigned int m, n, p; +int ref_clk =25000 ; +int delta = target_dsi_clk;u32 m_seed; -/* dsi_clk is expected in KHZ */ -if (dsi_clk <300000 || dsi_clk >1150000 ) { +/* target_dsi_clk is expected in kHz */ +if (target_dsi_clk <300000 || target_dsi_clk >1150000 ) {DRM_ERROR ("DSI CLK Out of Range\n" );return -ECHRNG ; } - ref_clk =25000 ; - target_dsi_clk = dsi_clk; - error =0xFFFFFFFF ; - tmp_error =0xFFFFFFFF ; - calc_m =0 ; - calc_p =0 ; - -for (m =62 ; m <=92 ; m++) { -for (p =2 ; p <=6 ; p++) { -/* Find the optimal m and p divisors -with minimal error +/- the required clock */ - calc_dsi_clk = (m * ref_clk) / p; -if (calc_dsi_clk == target_dsi_clk) { - calc_m = m; - calc_p = p; - error =0 ; -break ; - }else - tmp_error =abs (target_dsi_clk - calc_dsi_clk); - -if (tmp_error < error) { - error = tmp_error; +for (m =62 ; m <=92 && delta; m++) { +for (p =2 ; p <=6 && delta; p++) { +/* +* Find the optimal m and p divisors with minimal delta +* +/- the required clock +*/ +int calc_dsi_clk = (m * ref_clk) / p; +int d =abs (target_dsi_clk - calc_dsi_clk); +if (d < delta) { + delta = d; calc_m = m; calc_p = p; } } - -if (error ==0 ) -break ; } m_seed = lfsr_converts[calc_m -62 ];
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 5 lines · Jani Nikula
Improve readability. No functional changes.
v2: use more rational types (Ville)
Signed-off-by Jani Nikula <[email protected]>
Looks OK to me.
Quoted 81 lines
--- drivers/gpu/drm/i915/intel_dsi_pll.c | 53 ++++++++++++------------------------ 1 file changed, 17 insertions(+), 36 deletions(-)drivers/gpu/drm/i915/intel_dsi_pll.c +17
-36@@ -162,53 +162,34 @@ static u32 dsi_clk_from_pclk(u32 pclk, int pixel_format, int lane_count)#endif -static int dsi_calc_mnp (u32 dsi_clk,struct dsi_mnp *dsi_mnp) +static int dsi_calc_mnp (int target_dsi_clk,struct dsi_mnp *dsi_mnp) { -u32 m, n, p; -u32 ref_clk; -u32 error; -u32 tmp_error; -int target_dsi_clk; -int calc_dsi_clk; -u32 calc_m; -u32 calc_p; +unsigned int calc_m =0 , calc_p =0 ; +unsigned int m, n, p; +int ref_clk =25000 ; +int delta = target_dsi_clk;u32 m_seed; -/* dsi_clk is expected in KHZ */ -if (dsi_clk <300000 || dsi_clk >1150000 ) { +/* target_dsi_clk is expected in kHz */ +if (target_dsi_clk <300000 || target_dsi_clk >1150000 ) {DRM_ERROR ("DSI CLK Out of Range\n" );return -ECHRNG ; } - ref_clk =25000 ; - target_dsi_clk = dsi_clk; - error =0xFFFFFFFF ; - tmp_error =0xFFFFFFFF ; - calc_m =0 ; - calc_p =0 ; - -for (m =62 ; m <=92 ; m++) { -for (p =2 ; p <=6 ; p++) { -/* Find the optimal m and p divisors -with minimal error +/- the required clock */ - calc_dsi_clk = (m * ref_clk) / p; -if (calc_dsi_clk == target_dsi_clk) { - calc_m = m; - calc_p = p; - error =0 ; -break ; - }else - tmp_error =abs (target_dsi_clk - calc_dsi_clk); - -if (tmp_error < error) { - error = tmp_error; +for (m =62 ; m <=92 && delta; m++) { +for (p =2 ; p <=6 && delta; p++) { +/* +* Find the optimal m and p divisors with minimal delta +* +/- the required clock +*/ +int calc_dsi_clk = (m * ref_clk) / p; +int d =abs (target_dsi_clk - calc_dsi_clk); +if (d < delta) { + delta = d; calc_m = m; calc_p = p; } } - -if (error ==0 ) -break ; } m_seed = lfsr_converts[calc_m -62 ];Signature · 1 line
2.1.4
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedQuoted 9 lines · Ville Syrjälä
Quoted 5 lines · Jani Nikula
Improve readability. No functional changes.
v2: use more rational types (Ville)
Signed-off-by Jani Nikula <[email protected]>Looks OK to me.
Reviewed-by Ville Syrjälä <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx