Skip to content

Commit cc00bb0

Browse files
Evoke Zhangakiernan
authored andcommitted
lcd: driver defect clean up
PD#150465: driver defect clean up: torvalds#71 torvalds#77 torvalds#109 torvalds#127 torvalds#411 torvalds#600 torvalds#602 torvalds#603 torvalds#604 torvalds#611 torvalds#612 Change-Id: I38ac5ed6583bd6e57df9f42eaab04d05ee4ed663 Signed-off-by: Evoke Zhang <[email protected]>
1 parent 225647f commit cc00bb0

File tree

13 files changed

+773
-288
lines changed

13 files changed

+773
-288
lines changed

drivers/amlogic/media/vout/lcd/lcd_clk_config.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,16 @@ void lcd_clk_config_print(void)
229229
"div_sel: %s(index %d)\n"
230230
"xd: %d\n"
231231
"fout: %dkHz\n"
232-
"ss_level: %d\n\n",
232+
"ss_level: %d\n"
233+
"pll_mode: %d\n\n",
233234
clk_conf.pll_m, clk_conf.pll_n,
234235
clk_conf.pll_frac, clk_conf.pll_fvco,
235236
clk_conf.pll_od1_sel, clk_conf.pll_od2_sel,
236237
clk_conf.pll_od3_sel, clk_conf.pll_fout,
237238
lcd_clk_div_sel_table[clk_conf.div_sel],
238239
clk_conf.div_sel, clk_conf.xd,
239-
clk_conf.fout, clk_conf.ss_level);
240+
clk_conf.fout, clk_conf.ss_level,
241+
clk_conf.pll_mode);
240242
break;
241243
}
242244
}
@@ -587,7 +589,10 @@ static void lcd_set_pll_txl(struct lcd_clk_config_s *cConf)
587589
lcd_hiu_write(HHI_HDMI_PLL_CNTL, pll_ctrl);
588590
lcd_hiu_write(HHI_HDMI_PLL_CNTL2, pll_ctrl2);
589591
lcd_hiu_write(HHI_HDMI_PLL_CNTL3, pll_ctrl3);
590-
lcd_hiu_write(HHI_HDMI_PLL_CNTL4, 0x0c8e0000);
592+
if (cConf->pll_mode)
593+
lcd_hiu_write(HHI_HDMI_PLL_CNTL4, 0x0d160000);
594+
else
595+
lcd_hiu_write(HHI_HDMI_PLL_CNTL4, 0x0c8e0000);
591596
lcd_hiu_write(HHI_HDMI_PLL_CNTL5, 0x001fa729);
592597
lcd_hiu_write(HHI_HDMI_PLL_CNTL6, 0x01a31500);
593598
lcd_hiu_setb(HHI_HDMI_PLL_CNTL, 1, LCD_PLL_RST_TXL, 1);
@@ -1286,6 +1291,11 @@ static void lcd_clk_generate_txl(struct lcd_config_s *pconf)
12861291
goto generate_clk_done_txl;
12871292
}
12881293

1294+
if (pconf->lcd_timing.clk_auto == 2)
1295+
cConf->pll_mode = 1;
1296+
else
1297+
cConf->pll_mode = 0;
1298+
12891299
switch (pconf->lcd_basic.lcd_type) {
12901300
case LCD_TTL:
12911301
clk_div_sel = CLK_DIV_SEL_1;

drivers/amlogic/media/vout/lcd/lcd_clk_config.h

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
#include <linux/types.h>
2222
#include <linux/amlogic/media/vout/lcd/lcd_vout.h>
2323

24-
/* clk config */
24+
/* **********************************
25+
* clk config
26+
* **********************************
27+
*/
2528
struct lcd_clk_config_s { /* unit: kHz */
2629
/* IN-OUT parameters */
2730
unsigned int fin;
@@ -69,9 +72,13 @@ struct lcd_clk_config_s { /* unit: kHz */
6972
unsigned int div_out_fmax; /* g9tv, g9bb, gxbb */
7073
unsigned int xd_out_fmax;
7174
unsigned int err_fmin;
75+
unsigned int pll_mode;
7276
};
7377

74-
/* pll & clk parameter */
78+
/* **********************************
79+
* pll & clk parameter
80+
* **********************************
81+
*/
7582
/* ******** clk calculation ******** */
7683
#define PLL_WAIT_LOCK_CNT 200
7784
/* frequency unit: kHz */
@@ -110,7 +117,10 @@ enum div_sel_e {
110117
};
111118

112119

113-
/* GXTVBB */
120+
/* **********************************
121+
* GXTVBB
122+
* **********************************
123+
*/
114124
/* ******** register bit ******** */
115125
/* PLL_CNTL 0x10c8 */
116126
#define LCD_PLL_LOCK_GXTVBB 31
@@ -143,7 +153,10 @@ enum div_sel_e {
143153
#define CRT_VID_CLK_IN_MAX_GXTVBB (3100 * 1000)
144154
#define ENCL_CLK_IN_MAX_GXTVBB (620 * 1000)
145155

146-
/* GXL */
156+
/* **********************************
157+
* GXL
158+
* **********************************
159+
*/
147160
/* ******** register bit ******** */
148161
/* PLL_CNTL 0x10c8 */
149162
#define LCD_PLL_LOCK_GXL 31
@@ -176,7 +189,10 @@ enum div_sel_e {
176189
#define CRT_VID_CLK_IN_MAX_GXL (3100 * 1000)
177190
#define ENCL_CLK_IN_MAX_GXL (620 * 1000)
178191

179-
/* GXM */
192+
/* **********************************
193+
* GXM
194+
* **********************************
195+
*/
180196
/* ******** register bit ******** */
181197
/* PLL_CNTL 0x10c8 */
182198
#define LCD_PLL_LOCK_GXM 31
@@ -209,7 +225,10 @@ enum div_sel_e {
209225
#define CRT_VID_CLK_IN_MAX_GXM (3100 * 1000)
210226
#define ENCL_CLK_IN_MAX_GXM (620 * 1000)
211227

212-
/* TXL */
228+
/* **********************************
229+
* TXL
230+
* **********************************
231+
*/
213232
/* ******** register bit ******** */
214233
/* PLL_CNTL 0x10c8 */
215234
#define LCD_PLL_LOCK_TXL 31
@@ -242,7 +261,10 @@ enum div_sel_e {
242261
#define CRT_VID_CLK_IN_MAX_TXL (3100 * 1000)
243262
#define ENCL_CLK_IN_MAX_TXL (620 * 1000)
244263

245-
/* TXLX */
264+
/* **********************************
265+
* TXLX
266+
* **********************************
267+
*/
246268
/* ******** register bit ******** */
247269
/* PLL_CNTL 0x10c8 */
248270
#define LCD_PLL_LOCK_TXLX 31
@@ -275,7 +297,10 @@ enum div_sel_e {
275297
#define CRT_VID_CLK_IN_MAX_TXLX (3100 * 1000)
276298
#define ENCL_CLK_IN_MAX_TXLX (620 * 1000)
277299

278-
/* AXG */
300+
/* **********************************
301+
* AXG
302+
* **********************************
303+
*/
279304
/* ******** register bit ******** */
280305
/* PLL_CNTL */
281306
#define LCD_PLL_LOCK_AXG 31

drivers/amlogic/media/vout/lcd/lcd_common.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
#include "lcd_common.h"
3939
#include "lcd_reg.h"
4040

41-
/* lcd type */
41+
/* **********************************
42+
* lcd type
43+
* **********************************
44+
*/
4245
struct lcd_type_match_s {
4346
char *name;
4447
enum lcd_type_e type;
@@ -102,7 +105,10 @@ char *lcd_mode_mode_to_str(int mode)
102105
return lcd_mode_table[mode];
103106
}
104107

105-
/* lcd gpio */
108+
/* **********************************
109+
* lcd gpio
110+
* **********************************
111+
*/
106112
#if 0
107113
#define lcd_gpio_request(dev, str) gpiod_get(dev, str)
108114
#define lcd_gpio_free(gdesc) gpiod_put(gdesc)
@@ -780,17 +786,17 @@ int lcd_vmode_change(struct lcd_config_s *pconf)
780786
char str[100];
781787
int len = 0;
782788

783-
pconf->lcd_timing.clk_change = 0; /* clear clk flga */
789+
pconf->lcd_timing.clk_change = 0; /* clear clk flag */
784790
switch (type) {
785791
case 0: /* pixel clk adjust */
786792
pclk = (h_period * v_period) / duration_den * duration_num;
787793
if (pconf->lcd_timing.lcd_clk != pclk)
788794
pconf->lcd_timing.clk_change = LCD_CLK_PLL_CHANGE;
789795
break;
790796
case 1: /* htotal adjust */
791-
h_period = ((pclk / v_period) * duration_den * 10) /
797+
h_period = ((pclk / v_period) * duration_den * 100) /
792798
duration_num;
793-
h_period = (h_period + 5) / 10; /* round off */
799+
h_period = (h_period + 99) / 100; /* round off */
794800
if (pconf->lcd_basic.h_period != h_period) {
795801
/* check clk frac update */
796802
pclk = (h_period * v_period) / duration_den *
@@ -802,9 +808,9 @@ int lcd_vmode_change(struct lcd_config_s *pconf)
802808
}
803809
break;
804810
case 2: /* vtotal adjust */
805-
v_period = ((pclk / h_period) * duration_den * 10) /
811+
v_period = ((pclk / h_period) * duration_den * 100) /
806812
duration_num;
807-
v_period = (v_period + 5) / 10; /* round off */
813+
v_period = (v_period + 99) / 100; /* round off */
808814
if (pconf->lcd_basic.v_period != v_period) {
809815
/* check clk frac update */
810816
pclk = (h_period * v_period) / duration_den *
@@ -817,14 +823,14 @@ int lcd_vmode_change(struct lcd_config_s *pconf)
817823
break;
818824
case 3: /* free adjust, use min/max range to calculate */
819825
default:
820-
v_period = ((pclk / h_period) * duration_den * 10) /
826+
v_period = ((pclk / h_period) * duration_den * 100) /
821827
duration_num;
822-
v_period = (v_period + 5) / 10; /* round off */
828+
v_period = (v_period + 99) / 100; /* round off */
823829
if (v_period > pconf->lcd_basic.v_period_max) {
824830
v_period = pconf->lcd_basic.v_period_max;
825-
h_period = ((pclk / v_period) * duration_den * 10) /
831+
h_period = ((pclk / v_period) * duration_den * 100) /
826832
duration_num;
827-
h_period = (h_period + 5) / 10; /* round off */
833+
h_period = (h_period + 99) / 100; /* round off */
828834
if (h_period > pconf->lcd_basic.h_period_max) {
829835
h_period = pconf->lcd_basic.h_period_max;
830836
pclk = (h_period * v_period) / duration_den *
@@ -841,9 +847,9 @@ int lcd_vmode_change(struct lcd_config_s *pconf)
841847
}
842848
} else if (v_period < pconf->lcd_basic.v_period_min) {
843849
v_period = pconf->lcd_basic.v_period_min;
844-
h_period = ((pclk / v_period) * duration_den * 10) /
850+
h_period = ((pclk / v_period) * duration_den * 100) /
845851
duration_num;
846-
h_period = (h_period + 5) / 10; /* round off */
852+
h_period = (h_period + 99) / 100; /* round off */
847853
if (h_period < pconf->lcd_basic.h_period_min) {
848854
h_period = pconf->lcd_basic.h_period_min;
849855
pclk = (h_period * v_period) / duration_den *

drivers/amlogic/media/vout/lcd/lcd_common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
#include "lcd_clk_config.h"
2424

2525
/* 20170505: add a113 support to linux4.9 */
26-
#define LCD_DRV_VERSION "20170505"
26+
/* 20170905: fix coverity errors */
27+
#define LCD_DRV_VERSION "20170905"
2728

2829
#define VPP_OUT_SATURATE (1 << 0)
2930

0 commit comments

Comments
 (0)