fbdev: sm712fb: implement 2D acceleration w/ cleanups.
cover fbdev: sm712fb: implement 2D acceleration w/ cleanups.
Previously, in staging/sm7xxfb (now fbdev/sm712fb), 2D acceleration was implemented, but after its submission, a critical bug that causes total system hang was discovered, as a stopgap measure, 2D ops was completele removed in commit 3af805735a25 ("staging: sm7xx: remove the buggy 2D acceleration support") and never implemented again.
It created a massive usability problem - on YeeLoong 8089, a notable MIPS platform which uses SM712 - even scrolling a single line of text on the console required an unaccelerated screen redraw, running "dmesg" typically takes 8-11 seconds, and absurdly, printf(), became a significant performance bottleneck that slows down GCC and "make", make the computer largely unusable.
So I decided to take a look. Most of the my actual development was done in 2014 in a personal out-of-tree driver, I did not mainline it because 2D acceleration was not working properly in 24-bit color. I discovered the solution in early 2019 and now it's ready to be mainlined.
This commit reimplements the 2D acceleration for sm712fb. Unlike the original implementation, which was messy and unnecessarily complicated by calling a 2D acceleration wrapper file with many unneeded functions, this is a minimum and (relatively) clean implementation. My tests have shown that running "dmesg" only takes 0.9 seconds, a performance boost of 950%. System hangs did not occur in my tests.
Currently, 2D acceleration is only supported on SM712 with little-endian CPUs, it's disabled on Big Endian systems and SM720 chips as a safety measure, since I code for myself without any monetary or hardware support from any company or OEMs, I don't have the hardware and it's completely untested. I should be also to purchase a Big Endian test platform and add proper support soon. If you have a Big-Endian platform with SM7xx available for testing, please send an E-mail to me immediately! Thanks!
Also, thanks to Miodrag Vallat and other OpenBSD developers, this work would be impossible without their code, that served as a reference implementation for me.
Finally, during the development and testing of 2D acceleration, the modesetting code of this driver received a minor cleanup, and many issues about issues about the modesetting code and this driver in general have been documented.
Yifeng Li (8):
fbdev: sm712fb: update copyright headers.
fbdev: sm712fb: use type "u8" for 8-bit I/O.
fbdev: sm712fb: add 2D-related I/O headers and functions.
fbdev: sm712fb: support 2D acceleration on SM712 w/ Little-Endian CPU.
fbdev: sm712fb: add 32-bit color modes, drops some other modes.
Documentation: fb: sm712fb: add information mainly about 2D.
fbdev: sm712fb: Kconfig: add information about docs.
MAINTAINERS: sm712fb: list myself as one maintainer.
Documentation/fb/sm712fb.txt | 123 +++++++- MAINTAINERS | 1 + drivers/video/fbdev/Kconfig | 4 + drivers/video/fbdev/sm712.h | 129 +++++++- drivers/video/fbdev/sm712fb.c | 574 ++++++++++++++++++++++++++-------- 5 files changed, 679 insertions(+), 152 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/8 fbdev: sm712fb: update copyright headers.
My implementation of 2D acceleration used the original buggy code in the staging tree (which had been removed due to a critical bug soon after its submission), also, OpenBSD's smfb.c driver written by Miodrag Vallat was another important source of reference, a hunk of hardware register definitions are taken verbatim.
This commit appends my name to the list of authors, and included Miodrag Vallat's name and the ISC license of the original smfb.c driver.
--- drivers/video/fbdev/sm712.h | 20 ++++++++++++++++++++ drivers/video/fbdev/sm712fb.c | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+)
drivers/video/fbdev/sm712.h +20 -0
@@ -8,9 +8,29 @@* Copyright (C) 2009 Lemote, Inc. * Author: Wu Zhangjin, [email protected] * +* Copyright (C) 2014, 2019 Yifeng Li. +* Author: Yifeng Li <[email protected]> +* * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. +* +* This file incorporates work covered by the following copyright and +* permission notice: +* +* Copyright (c) 2009, 2010 Miodrag Vallat. +* +* Permission to use, copy, modify, and distribute this software for any +* purpose with or without fee is hereby granted, provided that the above +* copyright notice and this permission notice appear in all copies. +* +* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define FB_ACCEL_SMI_LYNX 88
drivers/video/fbdev/sm712fb.c +20 -0
@@ -11,11 +11,31 @@* Copyright (C) 2011 Igalia, S.L. * Author: Javier M. Mellid <[email protected]> * +* Copyright (C) 2014, 2019 Yifeng Li. +* Author: Yifeng Li <[email protected]> +* * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. * * Framebuffer driver for Silicon Motion SM710, SM712, SM721 and SM722 chips +* +* This file incorporates work covered by the following copyright and +* permission notice: +* +* Copyright (c) 2009, 2010 Miodrag Vallat. +* +* Permission to use, copy, modify, and distribute this software for any +* purpose with or without fee is hereby granted, provided that the above +* copyright notice and this permission notice appear in all copies. +* +* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/io.h>
Signature · 1 line
2.20.1
PATCH 2/8 fbdev: sm712fb: use type "u8" for 8-bit I/O.
In reply to Yifeng LiThis commit converts "unsigned int" and "int" in I/O wrappers to "u8". It improves readability since it's consistent with the prototypes of readb() and writeb(). More importantly, it reduces readers' confusion, since the upcoming 2D acceleration code will use a different wordsize.
--- drivers/video/fbdev/sm712.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/video/fbdev/sm712.h +5 -5
@@ -63,19 +63,19 @@ extern void __iomem *smtc_regbaseaddress;#define SIZE_CR30_CR4D (0x4D - 0x30 + 1)#define SIZE_CR90_CRA7 (0xA7 - 0x90 + 1) -static inline void smtc_crtcw (int reg,int val) +static inline void smtc_crtcw (u8 reg,u8 val) {smtc_mmiowb (reg,0x3d4 );smtc_mmiowb (val,0x3d5 ); } -static inline void smtc_grphw (int reg,int val) +static inline void smtc_grphw (u8 reg,u8 val) {smtc_mmiowb (reg,0x3ce );smtc_mmiowb (val,0x3cf ); } -static inline void smtc_attrw (int reg,int val) +static inline void smtc_attrw (u8 reg,u8 val) {smtc_mmiorb (0x3da );smtc_mmiowb (reg,0x3c0 );
@@ -83,13 +83,13 @@ static inline void smtc_attrw(int reg, int val)smtc_mmiowb (val,0x3c0 ); } -static inline void smtc_seqw (int reg,int val) +static inline void smtc_seqw (u8 reg,u8 val) {smtc_mmiowb (reg,0x3c4 );smtc_mmiowb (val,0x3c5 ); } -static inline unsigned int smtc_seqr (int reg) +static inline u8 smtc_seqr (u8 reg) {smtc_mmiowb (reg,0x3c4 );return smtc_mmiorb (0x3c5 );
Signature · 1 line
2.20.1
PATCH 3/8 fbdev: sm712fb: add 2D-related I/O headers and functions.
In reply to Yifeng LiThis commit adds I/O macros and functions related to 2D opeartions. A hunk of hardware register definitions are taken verbatim from OpenBSD.
In addition, a utility function pad_to_dword() is added to help padding data for the 2D engine. It accepts 3, 2, or 1 byte(s) of data, and pads it to a 32-bit word suitable for 2D Drawing Engine.
Yes, we can set info->pixmap.scan_align/buf_align = 4 and forget about padding, but it's incompatible with cfb_imageblit() w/ depth == 1. In case we need to fallback (e.g. debugging), it would be inconvenient, so we pad it manually.
--- drivers/video/fbdev/sm712.h | 96 +++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)
drivers/video/fbdev/sm712.h +96 -0
@@ -95,6 +95,102 @@ static inline u8 smtc_seqr(u8 reg)return smtc_mmiorb (0x3c5 ); } +/* +* DPR (2D drawing engine) +*/ +#define DPR_COORDS (x, y) (((x) << 16) | (y)) + +#define SCR_DE_STATUS 0x16 +#define SCR_DE_STATUS_MASK 0x18 +#define SCR_DE_ENGINE_IDLE 0x10 + +#define DPR_BASE 0x00408000 +#define DPR_SRC_COORDS 0x00 +#define DPR_DST_COORDS 0x04 +#define DPR_SPAN_COORDS 0x08 +#define DPR_DE_CTRL 0x0c +#define DPR_PITCH 0x10 +#define DPR_FG_COLOR 0x14 +#define DPR_BG_COLOR 0x18 +#define DPR_STRETCH 0x1c +#define DPR_DE_FORMAT_SELECT 0x1e +#define DPR_COLOR_COMPARE 0x20 +#define DPR_COLOR_COMPARE_MASK 0x24 +#define DPR_BYTE_BIT_MASK 0x28 +#define DPR_CROP_TOPLEFT_COORDS 0x2c +#define DPR_CROP_BOTRIGHT_COORDS 0x30 +#define DPR_MONO_PATTERN_LO32 0x34 +#define DPR_MONO_PATTERN_HI32 0x38 +#define DPR_SRC_WINDOW 0x3c +#define DPR_SRC_BASE 0x40 +#define DPR_DST_BASE 0x44 + +#define DE_CTRL_START 0x80000000 +#define DE_CTRL_RTOL 0x08000000 +#define DE_CTRL_COMMAND_MASK 0x001f0000 +#define DE_CTRL_COMMAND_SHIFT 16 +#define DE_CTRL_COMMAND_BITBLT 0x00 +#define DE_CTRL_COMMAND_SOLIDFILL 0x01 +#define DE_CTRL_COMMAND_HOSTWRITE 0x08 +#define DE_CTRL_ROP2_SELECT 0x00008000 +#define DE_CTRL_ROP2_SRC_IS_PATTERN 0x00004000 +#define DE_CTRL_ROP2_SHIFT 0 +#define DE_CTRL_ROP2_COPY 0x0c +#define DE_CTRL_HOST_SHIFT 22 +#define DE_CTRL_HOST_SRC_IS_MONO 0x01 +#define DE_CTRL_FORMAT_XY 0x00 +#define DE_CTRL_FORMAT_24BIT 0x30 + +/* +* 32-bit I/O for 2D opeartions. +*/ +extern void __iomem *smtc_dprbaseaddress;/* DPR, 2D control registers */ + +static inline u8 smtc_dprr (u8 reg) +{ +return readl (smtc_dprbaseaddress + reg); +} + +static inline void smtc_dprw (u8 reg,u32 val) +{ +writel (val, smtc_dprbaseaddress + reg); +} + +static inline void smtc_dprw_16 (u8 reg,u16 val) +{ +writew (val, smtc_dprbaseaddress + reg); +} + +static inline u32 pad_to_dword (const u8 *bytes,int length) +{ +u32 dword =0 ; + +switch (length) { +#ifdef __BIG_ENDIAN +case 3 : + dword |= bytes[2 ] <<8 ; +/* fallthrough */ +case 2 : + dword |= bytes[1 ] <<16 ; +/* fallthrough */ +case 1 : + dword |= bytes[0 ] <<24 ; +break ; +#else +case 3 : + dword |= bytes[2 ] <<16 ; +/* fallthrough */ +case 2 : + dword |= bytes[1 ] <<8 ; +/* fallthrough */ +case 1 : + dword |= bytes[0 ]; +break ; +#endif + } +return dword; +} +/* The next structure holds all information relevant for a specific video mode. */
Signature · 1 line
2.20.1
PATCH 4/8 fbdev: sm712fb: support 2D acceleration on SM712 w/ Little-Endian CPU.
In reply to Yifeng LiPreviously, in staging/sm7xxfb (now fbdev/sm712fb), 2D acceleration was implemented, but after its submission, a critical bug that causes total system hang was discovered, as a stopgap measure, 2D ops was completele removed in commit 3af805735a25 ("staging: sm7xx: remove the buggy 2D acceleration support") and never implemented again.
It created a massive usability problem - on YeeLoong 8089, a notable MIPS platform which uses SM712 - even scrolling a single line of text on the console required an unaccelerated screen redraw, running "dmesg" typically takes 8-11 seconds, and absurdly, printf(), became a significant performance bottleneck that slows down GCC and "make", make the computer largely unusable.
So I decided to take a look. Most of the my actual development was done in 2014 in a personal out-of-tree driver, I did not mainline it because 2D acceleration was not working properly in 24-bit color. I discovered the solution in early 2019 and now it's ready to be mainlined.
This commit reimplements the 2D acceleration for sm712fb. Unlike the original implementation, which was messy and unnecessarily complicated by calling a 2D acceleration wrapper file with many unneeded functions, this is a minimum and (relatively) clean implementation. My tests have shown that running "dmesg" only takes 0.9 seconds, a performance boost of 950%. System hangs did not occur in my tests.
Currently, 2D acceleration is only supported on SM712 with little-endian CPUs, it's disabled on Big Endian systems and SM720 chips as a safety measure, since I code for myself without any monetary or hardware support from any company or OEMs, I don't have the hardware and it's completely untested. I should be also to purchase a Big Endian test platform and add proper support soon. If you have a Big-Endian platform with SM7xx available for testing, please send an E-mail to me immediately! Thanks!
Finally, thanks to Miodrag Vallat and other OpenBSD developers, this work would be impossible without their code, that served as a reference implementation for me.
As a historical note, though I'm not extremely sure, but I believe the source of the original system hang was a type punning.
unsigned char ajRemain[4];
SMTC_write2Ddataport(0, *(unsigned long *)ajRemain);Type punning is undefined behavior in C, and here it caused an unaligned memory access, which is illegal on MIPS, thus crashing the computer.
--- drivers/video/fbdev/sm712.h | 3 + drivers/video/fbdev/sm712fb.c | 396 +++++++++++++++++++++++++++++++++- 2 files changed, 392 insertions(+), 7 deletions(-)
drivers/video/fbdev/sm712.h +3 -0
@@ -139,7 +139,10 @@ static inline u8 smtc_seqr(u8 reg)#define DE_CTRL_HOST_SHIFT 22#define DE_CTRL_HOST_SRC_IS_MONO 0x01#define DE_CTRL_FORMAT_XY 0x00 +#define DE_CTRL_FORMAT_8BIT 0x00 +#define DE_CTRL_FORMAT_16BIT 0x10#define DE_CTRL_FORMAT_24BIT 0x30 +#define DE_CTRL_FORMAT_32BIT 0x20/* * 32-bit I/O for 2D opeartions.
drivers/video/fbdev/sm712fb.c +389 -7
474 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 5/8 fbdev: sm712fb: add 32-bit color modes, drops some other modes.
In reply to Yifeng LiThe modesetting in sm712fb is an ugly hack. First, all the registers are programmed by hardcoded register arrays, which makes it difficult to support different variations of color depths, refresh rates, CRT/LCD panel, etc of the same resolution. Second, it means the standard fb_find_mode() cannot be used and a confusing non-standard "vga=" parameter is needed. Third, there's only minimum differences between some modes, yet around 70 lines of code and 100 registers are needed to be indepentently specified for each mode. Fourth, the register between some modes are inconsistent: the register configuration of different color depths in 640 x 480 modes are identical, but for 800 x 600 modes it's completely different. Also, some modes can drive the LCD panel properly yet some other modes will only show a white screen of death on the LCD panel. Fifth, there is a specific hack for Lemote Loongson 8089D laptop, the 1024x768, 16-bit color mode was modified to drive its LCD panel and changed to 1024x600, but the original mode was not preserved, so 1024x768 16-bit color mode is completely unsupported. Sixth, some modes, such as 32-bit color modes, are supported but never listed, and some modes are listed, such as 1280x1024 modes, but never supported by the register configuration arrays. And some modes are partially implemented but neither listed nor supported, i.e. the 8-bit color modes.
Fixing these problems requires a complete rewrite of modesetting code, which is well-beyond my motivation. This commit only perform a minimum cleanup:
1. Remove the 320 x 240 register settings, since there are never listed and never actually being used. This resolution is not even supported by vesafb, so it's safe to assume that no one is using such hardware. Future developers who needs them can simply recover them from the git history.
2. Remove 1280x1024 modes and 8-bit color modes. They are listed but never supported by the register array. So it doesn't work in the beginning, and only gives a black screen.
3. Add 32-bit color modes. They are supported but never listed, and are useful to some users.
--- drivers/video/fbdev/sm712fb.c | 158 +++++++--------------------------- 1 file changed, 31 insertions(+), 127 deletions(-)
drivers/video/fbdev/sm712fb.c +31 -127
@@ -118,25 +118,48 @@ struct vesa_mode { };static const struct vesa_mode vesa_mode_table[] = { - {"0x301" ,640 ,480 ,8 }, - {"0x303" ,800 ,600 ,8 }, - {"0x305" ,1024 ,768 ,8 }, - {"0x307" ,1280 ,1024 ,8 }, - {"0x311" ,640 ,480 ,16 }, {"0x314" ,800 ,600 ,16 }, {"0x317" ,1024 ,768 ,16 }, - {"0x31A" ,1280 ,1024 ,16 }, {"0x312" ,640 ,480 ,24 }, {"0x315" ,800 ,600 ,24 }, {"0x318" ,1024 ,768 ,24 }, - {"0x31B" ,1280 ,1024 ,24 }, + + {"0x329" ,640 ,480 ,32 }, + {"0x32e" ,800 ,600 ,32 }, + {"0x338" ,1024 ,768 ,32 }, };/********************************************************************** SM712 Mode table. -**********************************************************************/ + +The modesetting in sm712fb is an ugly hack. First, all the registers +are programmed by hardcoded register arrays, which makes it difficult +to support different variations of color depths, refresh rates, CRT/LCD +panel, etc of the same resolution. Second, it means the standard +fb_find_mode() cannot be used and a confusing non-standard "vga=" +parameter is needed. Third, there's only minimum differences between +some modes, yet around 70 lines of code and 100 registers are needed to +be indepentently specified for each mode. Fourth, the register between +some modes are inconsistent: the register configuration of different +color depths in 640 x 480 modes are identical, but for 800 x 600 modes +it's completely different. Also, some modes can drive the LCD panel +properly yet some other modes will only show a white screen of death on +the LCD panel. Fifth, there is a specific hack for Lemote Loongson 8089D +laptop, the 1024x768, 16-bit color mode was modified to drive its LCD panel +and changed to 1024x600, but the original mode was not preserved, so +1024x768 16-bit color mode is completely unsupported. And previously, +some modes are listed, such as 1280x1024 modes, but never supported by +the register configuration arrays, so they are now removed. And some modes +are partially implemented but neither listed nor supported, i.e. the 8-bit +color modes, so they have been removed from vesa_mode_table, too. + +I'm not the original author of the code, fixing these problems requires a +complete rewrite of modesetting code, which is well-beyond my motivation. + +See Documentation/fb/sm712fb.txt for more information. +**********************************************************************/ static const struct modeinit vgamode[] = { {/* mode#0: 640 x 480 16Bpp 60Hz */
@@ -673,125 +696,6 @@ static const struct modeinit vgamode[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03, }, }, - {/* mode#6: 320 x 240 16Bpp 60Hz */ -320 ,240 ,16 ,60 , -/* Init_MISC */ -0xEB , - { /* Init_SR0_SR4 */ -0x03 ,0x01 ,0x0F ,0x03 ,0x0E , - }, - { /* Init_SR10_SR24 */ -0xF3 ,0xB6 ,0xC0 ,0xDD ,0x00 ,0x0E ,0x17 ,0x2C , -0x99 ,0x02 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0xC4 ,0x32 ,0x02 ,0x01 ,0x01 , - }, - { /* Init_SR30_SR75 */ -0x38 ,0x03 ,0x20 ,0x09 ,0xC0 ,0x3A ,0x3A ,0x3A , -0x3A ,0x3A ,0x3A ,0x3A ,0x00 ,0x00 ,0x03 ,0xFF , -0x00 ,0xFC ,0x00 ,0x00 ,0x20 ,0x18 ,0x00 ,0xFC , -0x20 ,0x0C ,0x44 ,0x20 ,0x00 ,0x00 ,0x00 ,0x3A , -0x06 ,0x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,0x3A ,0x3A , -0x00 ,0x00 ,0x00 ,0x00 , - }, - { /* Init_SRA0_SRAF */ -0x00 ,0xFB ,0x9F ,0x01 ,0x00 ,0xED ,0xED ,0xED , -0x7B ,0xFB ,0xFF ,0xFF ,0x97 ,0xEF ,0xBF ,0xDF , - }, - { /* Init_GR00_GR08 */ -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x40 ,0x05 ,0x0F , -0xFF , - }, - { /* Init_AR00_AR14 */ -0x00 ,0x01 ,0x02 ,0x03 ,0x04 ,0x05 ,0x06 ,0x07 , -0x08 ,0x09 ,0x0A ,0x0B ,0x0C ,0x0D ,0x0E ,0x0F , -0x41 ,0x00 ,0x0F ,0x00 ,0x00 , - }, - { /* Init_CR00_CR18 */ -0xA3 ,0x7F ,0x7F ,0x00 ,0x85 ,0x16 ,0x24 ,0xF5 , -0x00 ,0x60 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0x03 ,0x09 ,0xFF ,0x80 ,0x40 ,0xFF ,0x00 ,0xE3 , -0xFF , - }, - { /* Init_CR30_CR4D */ -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x80 ,0x02 ,0x20 , -0x00 ,0x00 ,0x30 ,0x40 ,0x00 ,0xFF ,0xBF ,0xFF , -0x2E ,0x27 ,0x00 ,0x2b ,0x0c ,0x0F ,0xEF ,0x00 , -0xFe ,0x0f ,0x01 ,0xC0 ,0x27 ,0xEF , - }, - { /* Init_CR90_CRA7 */ -0x55 ,0xD9 ,0x5D ,0xE1 ,0x86 ,0x1B ,0x8E ,0x26 , -0xDA ,0x8D ,0xDE ,0x94 ,0x00 ,0x00 ,0x18 ,0x00 , - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03, - }, - }, };
Signature · 1 line
2.20.1
PATCH 6/8 Documentation: fb: sm712fb: add information mainly about 2D.
In reply to Yifeng LiThis commits add information about 32-bit color, 2D acceleration, as well as adding additional, general information about the hardware and many existing problems of the sm712fb driver.
--- Documentation/fb/sm712fb.txt | 123 +++++++++++++++++++++++++++++++---- 1 file changed, 110 insertions(+), 13 deletions(-)
Documentation/fb/sm712fb.txt +110 -13
@@ -1,31 +1,128 @@ What is sm712fb? ================= -This is a graphics framebuffer driver for Silicon Motion SM712 based processors. +"sm712fb" is a graphics framebuffer driver for Silicon Motion SM710 (LynxEM), +SM712 (LynxEM+), and SM720 (Lynx3DM, Lynx3DM+, aka. LynxEM4+) series of +video controllers. This series of video controller is a legacy from ~1998, +and was used on many classic, "prehistoric" laptops from 1998-2004, such as +IBM Thinkpad S30 and 240X. It was also used on some servers, industrial +computers, x86 and non-x86 embedded devices where only basic graphics was +needed. + +Notably, Lemote YeeLoong 8089, a MIPS laptop based on the Chinese Loongson +2F MIPS processor, is also using this chip because of hardware constraints, +and at a time, somewhat popular in the free software community due the +fact that it was the first laptop powered exclusively by free software, +and it was also an inexpensive platform for non-x86 hobbyists to explore. How to use it? ============== -Switching modes is done using the video=sm712fb:... boot parameter. - -If you want, for example, enable a resolution of 1280x1024x24bpp you should -pass to the kernel this command line: "video=sm712fb:0x31B". +You should not compile-in vesafb, since SM7xx can be used in a VGA +compatible mode, resulting conflicts with this driver. In addition, +the VGA compatible mode was never tested by the maintainers. -You should not compile-in vesafb. +Currently, the driver supports 3 modes: 640x480, 800x600, 1024x768, +at 16, 24 or 32-bit depth. Switching modes is done using the +`video=sm712fb:0x___` boot parameter. If you want, for example, +enable a resolution of 1280x1024x24bpp, you should pass to the kernel +this command line: "video=sm712fb:0x31B". -Currently supported video modes are: +Please consult the following table for the hexadecimal codes of +different modes. [Graphic modes] -bpp | 640x480 800x600 1024x768 1280x1024 -----+-------------------------------------------- - 8 | 0x301 0x303 0x305 0x307 - 16 | 0x311 0x314 0x317 0x31A - 24 | 0x312 0x315 0x318 0x31B +bpp | 640x480 800x600 1024x768 +----+--------------------------- + 16 | 0x311 0x314 0x317 + 24 | 0x312 0x315 0x318 + 32 | 0x329 0x32E 0x338 + +32-bit is really 8:8:8:8, but the final 8-bit number is an "empty" +alpha channel, it's otherwise equal to 24-bit color. However, they +could still be useful. For example, "fbterm" supports 32-bit mode +but not 24-bit mode. + +Notes about Modesetting +======================== + +The modesetting code in sm712fb has major problems. + +* Switching to 8-bit color mode will result in a black screen, so +they are removed from the list of supported graphic modes. But they +can still be switched to on-the-fly, don't do that then! + +* Only a refresh rate of 60 Hz is supported. + +* 1024x768 with 16-bit color is not really supported, because the +registers have been hacked by the original developer to adapt +the 1024x600 screen on Lemote YeeLoong 8089. + +* If you are using a Lemote YeeLoong 8089, please remember that only +the 1024x768 modes are guaranteed to drive the LCD panel properly. +Other modes are meant to drive a CRT, and may drive the LCD incorrectly +and result in a white screen with random garbage. External VGA output is +unaffected. + +Due to the way registers are hardcoded, it's impossible to fix them +without a major code rewrite. If you've been hit by these problems badly +and really need to get them fixed, please contact the driver maintainers. + +2D acceleration +============== + +Without 2D acceleration, the framebuffer suffers from extremely low performance, +even scrolling a single line of text on the console required an unaccelerated +screen redraw. Thus, 2D acceleration is enable by default. However, currently +it's only supported on SM710/712 with Little-Endian CPUs. Big-endian and +SM720 devices are currently not supported. + +2D acceleration can be controlled using the `video=sm712fb:accel:1` parameter. +The default option, "1" activate 2D acceleration. If you have problems, you can +set "0" to disable it. Different options can be separated by a comma, for +example, "video=sm712fb:0x31B,accel:0" set the resolution to 1280x1024x24bpp +while disabling the 2D acceleration. + +Although it has been extensively tested by the maintainer, 2D acceleration +in 24-bit color mode may still have minor issues. If you've encounter any +screen glitches in 24-bit mode in Linux framebuffer the framebuffer, don't +hurry disabling it, you should try switching to 32-bit mode first, normally +it should fix the problem. If you can reliably reproduce the screen glitches, +please report your method to the maintainers. Missing Features ================ (alias TODO list) - * 2D acceleratrion +The following features are not implemented in this driver, + + * 2D acceleration on SM720 and Big-Endian CPUs. + * More VGA modes. * dual-head support + * hardware cursor support + +The first feature is planned to be implemented soon, but the maintainer +does not receive any monetary or hardware support from any company or OEMs, +and he has to purchase a test platform personally. The 1998's hardware +still costs 200 USD+, so don't expected an ETA. If you have a Big-Endian +platform and willing to help testing, please contact the maintainer, thanks! + +Other VGA modes, dual-head, or hardware cursor support should be possible to +implement, but parts of the code must be rewritten, and there's little demand +for them on this legacy (retro?) platform, so there's no plan to implement them. +If you have a genuine need for them, please contact the maintainers. + +Maintainers +================ + +This driver is maintained by + + * Tom Li <[email protected]> + * Sudip Mukherjee <[email protected]> + * Teddy Wang <[email protected]> + +Tom Li was the last contributor of this driver who implemented 2D acceleration, +and is the main author of this documentation, please send any bug reports or +requests to Tom, but don't forget to CC other maintainers as well to make everyone +be informed.
Signature · 1 line
2.20.1
PATCH 7/8 fbdev: sm712fb: Kconfig: add information about docs.
In reply to Yifeng LiThis commits update the Kconfig description of sm712fb, and inform the user about the existence of documentation.
--- drivers/video/fbdev/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)
drivers/video/fbdev/Kconfig +4 -0
@@ -2302,6 +2302,10 @@ config FB_SM712 called sm712fb. If you want to compile it as a module, say M here and read <file:Documentation/kbuild/modules.txt>. + Warning: this driver has many known problems and limitations, + please make sure you've checked the documentation, at + <file:Documentation/fb/sm712fb.txt>. + source "drivers/video/fbdev/omap/Kconfig" source "drivers/video/fbdev/omap2/Kconfig" source "drivers/video/fbdev/mmp/Kconfig"
Signature · 1 line
2.20.1
PATCH 8/8 MAINTAINERS: sm712fb: list myself as one maintainer.
In reply to Yifeng LiI have working on the sm712fb driver for a while and have some familiarity with this hardware, I'll be helping working on and testing problems of this driver, so add myself to the MAINTAINERS file.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -13838,6 +13838,7 @@ F: drivers/input/touchscreen/silead.c F: drivers/platform/x86/touchscreen_dmi.c SILICON MOTION SM712 FRAME BUFFER DRIVER +M: Tom Li <[email protected]> M: Sudip Mukherjee <[email protected]> M: Teddy Wang <[email protected]> M: Sudip Mukherjee <[email protected]>
Signature · 1 line
2.20.1
Quoted 42 lines · Yifeng Li
Previously, in staging/sm7xxfb (now fbdev/sm712fb), 2D acceleration was implemented, but after its submission, a critical bug that causes total system hang was discovered, as a stopgap measure, 2D ops was completele removed in commit
3af805735a25("staging: sm7xx: remove the buggy 2D acceleration support") and never implemented again.It created a massive usability problem - on YeeLoong 8089, a notable MIPS platform which uses SM712 - even scrolling a single line of text on the console required an unaccelerated screen redraw, running "dmesg" typically takes 8-11 seconds, and absurdly,
printf(), became a significant performance bottleneck that slows down GCC and "make", make the computer largely unusable.So I decided to take a look. Most of the my actual development was done in 2014 in a personal out-of-tree driver, I did not mainline it because 2D acceleration was not working properly in 24-bit color. I discovered the solution in early 2019 and now it's ready to be mainlined.
This commit reimplements the 2D acceleration for sm712fb. Unlike the original implementation, which was messy and unnecessarily complicated by calling a 2D acceleration wrapper file with many unneeded functions, this is a minimum and (relatively) clean implementation. My tests have shown that running "dmesg" only takes 0.9 seconds, a performance boost of 950%. System hangs did not occur in my tests.
Currently, 2D acceleration is only supported on SM712 with little-endian CPUs, it's disabled on Big Endian systems and SM720 chips as a safety measure, since I code for myself without any monetary or hardware support from any company or OEMs, I don't have the hardware and it's completely untested. I should be also to purchase a Big Endian test platform and add proper support soon. If you have a Big-Endian platform with SM7xx available for testing, please send an E-mail to me immediately! Thanks!
Also, thanks to Miodrag Vallat and other OpenBSD developers, this work would be impossible without their code, that served as a reference implementation for me.
Finally, during the development and testing of 2D acceleration, the modesetting code of this driver received a minor cleanup, and many issues about issues about the modesetting code and this driver in general have been documented.
Quoted 9 lines
Yifeng Li (8):
fbdev: sm712fb: update copyright headers.
fbdev: sm712fb: use type "u8" for 8-bit I/O.
fbdev: sm712fb: add 2D-related I/O headers and functions.
fbdev: sm712fb: support 2D acceleration on SM712 w/ Little-Endian CPU.
fbdev: sm712fb: add 32-bit color modes, drops some other modes.
Documentation: fb: sm712fb: add information mainly about 2D.
fbdev: sm712fb:Kconfig: add information about docs.
MAINTAINERS: sm712fb: list myself as one maintainer.
Since you care about this driver, considered converting it to a drm display driver? You can still have all the acceleration and stuff, the fbdev compat mode in drm is rather flexible.
-Daniel
Quoted 15 lines
Documentation/fb/sm712fb.txt | 123 +++++++- MAINTAINERS | 1 + drivers/video/fbdev/Kconfig | 4 + drivers/video/fbdev/sm712.h | 129 +++++++- drivers/video/fbdev/sm712fb.c | 574 ++++++++++++++++++++++++++-------- 5 files changed, 679 insertions(+), 152 deletions(-)Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 4 lines
Since you care about this driver, considered converting it to a drm display driver? You can still have all the acceleration and stuff, the fbdev compat mode in drm is rather flexible.
-Daniel
Yes, I know fbdev is now in maintenance-only mode, reimplementing it on top of DRM is on my roadmap, including rewriting a saner version of the modesetting code. The current version is beyond repair. I'll start working on it once I managed to purchase the hardware for testing.
But currently my objectively is to have something usable during the transitional period. The major user of the chipset was Yeeloong 8089D laptop - a choice for many non-x86 and MIPS hobbyists for experimentation. Getting the current version of the patch merged would solve the immediate usability issues, and then trying to get some platform drivers merged. And after completing the preliminary upstreaming process, since then, can start working on a DRM version of the driver, and possibly eventually remove the fbdev version of sm712fb entirely.
The 2D acceleration implementation is strictly no more than 200 lines, the vast majority of the code insertions are comments and documentation changes ranting about the known issues of the driver/hardware, nothing non-trivial is added and I think the changeset is manageable and would not be a burden for the fbdev maintainers, and I can grarantee that I will not add any other new features to this driver.
Cheers,
Tom Li
Quoted 19 lines · Tom Li
Quoted 4 lines
Since you care about this driver, considered converting it to a drm display driver? You can still have all the acceleration and stuff, the fbdev compat mode in drm is rather flexible.
-DanielYes, I know fbdev is now in maintenance-only mode, reimplementing it on top of DRM is on my roadmap, including rewriting a saner version of the modesetting code. The current version is beyond repair. I'll start working on it once I managed to purchase the hardware for testing.
But currently my objectively is to have something usable during the transitional period. The major user of the chipset was Yeeloong 8089D laptop - a choice for many non-x86 and MIPS hobbyists for experimentation. Getting the current version of the patch merged would solve the immediate usability issues, and then trying to get some platform drivers merged. And after completing the preliminary upstreaming process, since then, can start working on a DRM version of the driver, and possibly eventually remove the fbdev version of sm712fb entirely.
Quoted 6 lines
The 2D acceleration implementation is strictly no more than 200 lines, the vast majority of the code insertions are comments and documentation changes ranting about the known issues of the driver/hardware, nothing non-trivial is added and I think the changeset is manageable and would not be a burden for the fbdev maintainers, and I can grarantee that I will not add any other new features to this driver.
Awesome, and I think as a gradual plan this makes tons of sense.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch