]>
Commit | Line | Data |
---|---|---|
53722911 GKH |
1 | From 4ed7d2ccb7684510ec5f7a8f7ef534bc6a3d55b2 Mon Sep 17 00:00:00 2001 |
2 | From: Yifeng Li <tomli@tomli.me> | |
3 | Date: Mon, 1 Apr 2019 17:46:59 +0200 | |
4 | Subject: fbdev: sm712fb: use 1024x768 by default on non-MIPS, fix garbled display | |
5 | ||
6 | From: Yifeng Li <tomli@tomli.me> | |
7 | ||
8 | commit 4ed7d2ccb7684510ec5f7a8f7ef534bc6a3d55b2 upstream. | |
9 | ||
10 | Loongson MIPS netbooks use 1024x600 LCD panels, which is the original | |
11 | target platform of this driver, but nearly all old x86 laptops have | |
12 | 1024x768. Lighting 768 panels using 600's timings would partially | |
13 | garble the display. Since it's not possible to distinguish them reliably, | |
14 | we change the default to 768, but keep 600 as-is on MIPS. | |
15 | ||
16 | Further, earlier laptops, such as IBM Thinkpad 240X, has a 800x600 LCD | |
17 | panel, this driver would probably garbled those display. As we don't | |
18 | have one for testing, the original behavior of the driver is kept as-is, | |
19 | but the problem has been documented is the comments. | |
20 | ||
21 | Signed-off-by: Yifeng Li <tomli@tomli.me> | |
22 | Tested-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com> | |
23 | Cc: Teddy Wang <teddy.wang@siliconmotion.com> | |
24 | Cc: <stable@vger.kernel.org> # v4.4+ | |
25 | Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | |
26 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
27 | ||
28 | --- | |
29 | drivers/video/fbdev/sm712.h | 7 +++-- | |
30 | drivers/video/fbdev/sm712fb.c | 53 +++++++++++++++++++++++++++++++----------- | |
31 | 2 files changed, 44 insertions(+), 16 deletions(-) | |
32 | ||
33 | --- a/drivers/video/fbdev/sm712.h | |
34 | +++ b/drivers/video/fbdev/sm712.h | |
35 | @@ -15,9 +15,10 @@ | |
36 | ||
37 | #define FB_ACCEL_SMI_LYNX 88 | |
38 | ||
39 | -#define SCREEN_X_RES 1024 | |
40 | -#define SCREEN_Y_RES 600 | |
41 | -#define SCREEN_BPP 16 | |
42 | +#define SCREEN_X_RES 1024 | |
43 | +#define SCREEN_Y_RES_PC 768 | |
44 | +#define SCREEN_Y_RES_NETBOOK 600 | |
45 | +#define SCREEN_BPP 16 | |
46 | ||
47 | #define dac_reg (0x3c8) | |
48 | #define dac_val (0x3c9) | |
49 | --- a/drivers/video/fbdev/sm712fb.c | |
50 | +++ b/drivers/video/fbdev/sm712fb.c | |
51 | @@ -1462,6 +1462,43 @@ static u_long sm7xx_vram_probe(struct sm | |
52 | return 0; /* unknown hardware */ | |
53 | } | |
54 | ||
55 | +static void sm7xx_resolution_probe(struct smtcfb_info *sfb) | |
56 | +{ | |
57 | + /* get mode parameter from smtc_scr_info */ | |
58 | + if (smtc_scr_info.lfb_width != 0) { | |
59 | + sfb->fb->var.xres = smtc_scr_info.lfb_width; | |
60 | + sfb->fb->var.yres = smtc_scr_info.lfb_height; | |
61 | + sfb->fb->var.bits_per_pixel = smtc_scr_info.lfb_depth; | |
62 | + goto final; | |
63 | + } | |
64 | + | |
65 | + /* | |
66 | + * No parameter, default resolution is 1024x768-16. | |
67 | + * | |
68 | + * FIXME: earlier laptops, such as IBM Thinkpad 240X, has a 800x600 | |
69 | + * panel, also see the comments about Thinkpad 240X above. | |
70 | + */ | |
71 | + sfb->fb->var.xres = SCREEN_X_RES; | |
72 | + sfb->fb->var.yres = SCREEN_Y_RES_PC; | |
73 | + sfb->fb->var.bits_per_pixel = SCREEN_BPP; | |
74 | + | |
75 | +#ifdef CONFIG_MIPS | |
76 | + /* | |
77 | + * Loongson MIPS netbooks use 1024x600 LCD panels, which is the original | |
78 | + * target platform of this driver, but nearly all old x86 laptops have | |
79 | + * 1024x768. Lighting 768 panels using 600's timings would partially | |
80 | + * garble the display, so we don't want that. But it's not possible to | |
81 | + * distinguish them reliably. | |
82 | + * | |
83 | + * So we change the default to 768, but keep 600 as-is on MIPS. | |
84 | + */ | |
85 | + sfb->fb->var.yres = SCREEN_Y_RES_NETBOOK; | |
86 | +#endif | |
87 | + | |
88 | +final: | |
89 | + big_pixel_depth(sfb->fb->var.bits_per_pixel, smtc_scr_info.lfb_depth); | |
90 | +} | |
91 | + | |
92 | static int smtcfb_pci_probe(struct pci_dev *pdev, | |
93 | const struct pci_device_id *ent) | |
94 | { | |
95 | @@ -1507,19 +1544,6 @@ static int smtcfb_pci_probe(struct pci_d | |
96 | ||
97 | sm7xx_init_hw(); | |
98 | ||
99 | - /* get mode parameter from smtc_scr_info */ | |
100 | - if (smtc_scr_info.lfb_width != 0) { | |
101 | - sfb->fb->var.xres = smtc_scr_info.lfb_width; | |
102 | - sfb->fb->var.yres = smtc_scr_info.lfb_height; | |
103 | - sfb->fb->var.bits_per_pixel = smtc_scr_info.lfb_depth; | |
104 | - } else { | |
105 | - /* default resolution 1024x600 16bit mode */ | |
106 | - sfb->fb->var.xres = SCREEN_X_RES; | |
107 | - sfb->fb->var.yres = SCREEN_Y_RES; | |
108 | - sfb->fb->var.bits_per_pixel = SCREEN_BPP; | |
109 | - } | |
110 | - | |
111 | - big_pixel_depth(sfb->fb->var.bits_per_pixel, smtc_scr_info.lfb_depth); | |
112 | /* Map address and memory detection */ | |
113 | mmio_base = pci_resource_start(pdev, 0); | |
114 | pci_read_config_byte(pdev, PCI_REVISION_ID, &sfb->chip_rev_id); | |
115 | @@ -1581,6 +1605,9 @@ static int smtcfb_pci_probe(struct pci_d | |
116 | goto failed_fb; | |
117 | } | |
118 | ||
119 | + /* probe and decide resolution */ | |
120 | + sm7xx_resolution_probe(sfb); | |
121 | + | |
122 | /* can support 32 bpp */ | |
123 | if (15 == sfb->fb->var.bits_per_pixel) | |
124 | sfb->fb->var.bits_per_pixel = 16; |