Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev: sm712fb: use 1024x768 by default on non-MIPS, fix garbled display

Loongson MIPS netbooks use 1024x600 LCD panels, which is the original
target platform of this driver, but nearly all old x86 laptops have
1024x768. Lighting 768 panels using 600's timings would partially
garble the display. Since it's not possible to distinguish them reliably,
we change the default to 768, but keep 600 as-is on MIPS.

Further, earlier laptops, such as IBM Thinkpad 240X, has a 800x600 LCD
panel, this driver would probably garbled those display. As we don't
have one for testing, the original behavior of the driver is kept as-is,
but the problem has been documented is the comments.

Signed-off-by: Yifeng Li <tomli@tomli.me>
Tested-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Teddy Wang <teddy.wang@siliconmotion.com>
Cc: <stable@vger.kernel.org> # v4.4+
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

authored by

Yifeng Li and committed by
Bartlomiej Zolnierkiewicz
4ed7d2cc 6053d3a4

+44 -16
+4 -3
drivers/video/fbdev/sm712.h
··· 15 15 16 16 #define FB_ACCEL_SMI_LYNX 88 17 17 18 - #define SCREEN_X_RES 1024 19 - #define SCREEN_Y_RES 600 20 - #define SCREEN_BPP 16 18 + #define SCREEN_X_RES 1024 19 + #define SCREEN_Y_RES_PC 768 20 + #define SCREEN_Y_RES_NETBOOK 600 21 + #define SCREEN_BPP 16 21 22 22 23 #define dac_reg (0x3c8) 23 24 #define dac_val (0x3c9)
+40 -13
drivers/video/fbdev/sm712fb.c
··· 1475 1475 return 0; /* unknown hardware */ 1476 1476 } 1477 1477 1478 + static void sm7xx_resolution_probe(struct smtcfb_info *sfb) 1479 + { 1480 + /* get mode parameter from smtc_scr_info */ 1481 + if (smtc_scr_info.lfb_width != 0) { 1482 + sfb->fb->var.xres = smtc_scr_info.lfb_width; 1483 + sfb->fb->var.yres = smtc_scr_info.lfb_height; 1484 + sfb->fb->var.bits_per_pixel = smtc_scr_info.lfb_depth; 1485 + goto final; 1486 + } 1487 + 1488 + /* 1489 + * No parameter, default resolution is 1024x768-16. 1490 + * 1491 + * FIXME: earlier laptops, such as IBM Thinkpad 240X, has a 800x600 1492 + * panel, also see the comments about Thinkpad 240X above. 1493 + */ 1494 + sfb->fb->var.xres = SCREEN_X_RES; 1495 + sfb->fb->var.yres = SCREEN_Y_RES_PC; 1496 + sfb->fb->var.bits_per_pixel = SCREEN_BPP; 1497 + 1498 + #ifdef CONFIG_MIPS 1499 + /* 1500 + * Loongson MIPS netbooks use 1024x600 LCD panels, which is the original 1501 + * target platform of this driver, but nearly all old x86 laptops have 1502 + * 1024x768. Lighting 768 panels using 600's timings would partially 1503 + * garble the display, so we don't want that. But it's not possible to 1504 + * distinguish them reliably. 1505 + * 1506 + * So we change the default to 768, but keep 600 as-is on MIPS. 1507 + */ 1508 + sfb->fb->var.yres = SCREEN_Y_RES_NETBOOK; 1509 + #endif 1510 + 1511 + final: 1512 + big_pixel_depth(sfb->fb->var.bits_per_pixel, smtc_scr_info.lfb_depth); 1513 + } 1514 + 1478 1515 static int smtcfb_pci_probe(struct pci_dev *pdev, 1479 1516 const struct pci_device_id *ent) 1480 1517 { ··· 1557 1520 1558 1521 sm7xx_init_hw(); 1559 1522 1560 - /* get mode parameter from smtc_scr_info */ 1561 - if (smtc_scr_info.lfb_width != 0) { 1562 - sfb->fb->var.xres = smtc_scr_info.lfb_width; 1563 - sfb->fb->var.yres = smtc_scr_info.lfb_height; 1564 - sfb->fb->var.bits_per_pixel = smtc_scr_info.lfb_depth; 1565 - } else { 1566 - /* default resolution 1024x600 16bit mode */ 1567 - sfb->fb->var.xres = SCREEN_X_RES; 1568 - sfb->fb->var.yres = SCREEN_Y_RES; 1569 - sfb->fb->var.bits_per_pixel = SCREEN_BPP; 1570 - } 1571 - 1572 - big_pixel_depth(sfb->fb->var.bits_per_pixel, smtc_scr_info.lfb_depth); 1573 1523 /* Map address and memory detection */ 1574 1524 mmio_base = pci_resource_start(pdev, 0); 1575 1525 pci_read_config_byte(pdev, PCI_REVISION_ID, &sfb->chip_rev_id); ··· 1617 1593 1618 1594 goto failed_fb; 1619 1595 } 1596 + 1597 + /* probe and decide resolution */ 1598 + sm7xx_resolution_probe(sfb); 1620 1599 1621 1600 /* can support 32 bpp */ 1622 1601 if (sfb->fb->var.bits_per_pixel == 15)