问题描述:
我的lcd 使用的是spi lcd st7789 的驱动,它是以rgb565 作为色彩输出到 /dev/fb0 的。但是这也导致了我的qt 界面色彩输出无法还原,qt输出的是rgb8888。请问大神们有解决方法嘛???驱动是直接用的内核原有的驱动 设备书描述如下
&spi0{
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
// pinctrl-names = "default";
// pinctrl-0 = <&spi1_pins &spi1_cs_pins>;
// cs-gpios = <&pio 0 11 GPIO_ACTIVE_HIGH>;
ips13: ips13@0{
compatible = "sitronix,st7789v";
reg = <0>;
status = "okay";
spi-max-frequency = <50000000>;
rotate = <0>;
fps = <25>;
buswidth = <8>;
dc-gpios = <&pio 0 11 GPIO_ACTIVE_HIGH>; /* PA11 */
reset-gpios = <&pio 0 12 GPIO_ACTIVE_HIGH>; /* PA12 */
// led-gpios = <&pio 0 0 GPIO_ACTIVE_LOW>; /* PA0 */
debug = <0x0>;
spi-cpha;
spi-cpol;
};
};
测试图片如图
最近编辑记录 wugang0420 (2020-03-31 19:18:12)
离线
?
离线
三原色输出正常吗?
直接通过rgb565 刷fb0 是正常的
离线
也就是说 RGB888 刷 fb0 不正常?
对啊,关键是哪个屏的格式原来就是rgb565的屏,但是qt 往fb0输出的是rgb8888。不知道怎么转换
离线
驱动的lcd配置输出不对,应用层的ioctl程序会查询lcd驱动的液晶屏颜色模式,显然你的驱动返回了rgb888的24位模式,而不是正确的rgb565格式。
是rgb 565 啊,但是系统输出是bgr565 因为我配置为bgr后,开机的企鹅脚才是正常的黄色,rgb 显示的是蓝色,下面是我读的配置信息
the fixed information is as follow:
id=fb_st7789v
sem_start=0
smem_len=115200
type=0
line_length=480
mmio_start=0
mmio_len=0
variable information is as follow:
The xres is :240
The yres is :240
xres_virtual=240
yres_virtual=240
xoffset=0
yoffset=0
bits_per_pixel is :16
red.offset=11
red.length=5
red.msb_right=0
green.offset=5
green.length=6
green.msb_right=0
blue.offset=0
blue.length=5
blue.msb_right=0
transp.offset=0
transp.length=0
transp.msb_right=0
height=0
width=0
buffersize:115200
离线
驱动的lcd配置输出不对,应用层的ioctl程序会查询lcd驱动的液晶屏颜色模式,显然你的驱动返回了rgb888的24位模式,而不是正确的rgb565格式。
配置为bgr 后qt 颜色 红色变为了灰绿色 ,绿色变为了紫色,蓝色变为了浅蓝色,很奇怪,但是自己通过刷fb0 ,显示会正常,系统默认以bgr 输出,很奇怪不知道怎么配置。大神有方法嘛?
离线
你使用qt直接操作的fb0吧?直接操作Framebuffer ?
qt直接操作的fb0 ,还能怎么操作呢??
export LD_LIBRARY_PATH=/opt/qt5.9-install/lib:/lib:/usr/lib:/usr/local/tslib/lib
export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/qt5.9-install/plugins
#export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0
export QT_DEBUG_LUGINS=1
export QT_QPA_PLATFORM=linuxfb:fb=linuxfb:fb=/dev/fb0:size=240x240:mmSize=240x240:offset=0x0:tty=/dev/tty1
export QT_QPA_FONTDIR=/opt/qt5.9-install/fonts
# export QT_QPA_EGLFS_WIDTH=240
# export QT_QPA_EGLFS_HEIGHT=240
#export QT_QPA_EGLFS_DEPTH=16
# export QT_QPA_EGLFS_PHYSICAL_WIDTH=240
# export QT_QPA_EGLFS_PHYSICAL_HEIGHT=240
#export QT_QPA_EGLFS_FORCE888
离线
要修改lcd驱动,直到默认的企鹅颜色和qt的颜色都正常了。
改为bgr 企鹅颜色就正常了,但是qt 眼是就奇怪了 红变为了绿色 绿色变为了紫红色,深蓝变为了浅蓝 ,驱动 后续还应如何改呢??
离线
建议看看qt-everywhere-opensource-src-5.9.8\qtbase\src\plugins\platforms\linuxfb下面qlinuxfbscreen.cpp的源码,
static int determineDepth(const fb_var_screeninfo &vinfo)
{
int depth = vinfo.bits_per_pixel;
if (depth== 24) {
depth = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
if (depth <= 0)
depth = 24; // reset if color component lengths are not reported
} else if (depth == 16) {
depth = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
if (depth <= 0)
depth = 16;
}
return depth;
}static QImage::Format determineFormat(const fb_var_screeninfo &info, int depth)
{
const fb_bitfield rgba[4] = { info.red, info.green,
info.blue, info.transp };QImage::Format format = QImage::Format_Invalid;
switch (depth) {
case 32: {
const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0},
{0, 8, 0}, {24, 8, 0}};
const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0},
{16, 8, 0}, {24, 8, 0}};
if (memcmp(rgba, argb8888, 4 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_ARGB32;
} else if (memcmp(rgba, argb8888, 3 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_RGB32;
} else if (memcmp(rgba, abgr8888, 3 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_RGB32;
// pixeltype = BGRPixel;
}
break;
}
case 24: {
const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0},
{0, 8, 0}, {0, 0, 0}};
const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0},
{16, 8, 0}, {0, 0, 0}};
if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_RGB888;
} else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_RGB888;
// pixeltype = BGRPixel;
}
break;
}
case 18: {
const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0},
{0, 6, 0}, {0, 0, 0}};
if (memcmp(rgba, rgb666, 3 * sizeof(fb_bitfield)) == 0)
format = QImage::Format_RGB666;
break;
}
case 16: {
const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0},
{0, 5, 0}, {0, 0, 0}};
const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0},
{11, 5, 0}, {0, 0, 0}};
if (memcmp(rgba, rgb565, 3 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_RGB16;
} else if (memcmp(rgba, bgr565, 3 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_RGB16;
// pixeltype = BGRPixel;
}
break;
}
case 15: {
const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0},
{0, 5, 0}, {15, 1, 0}};
const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0},
{10, 5, 0}, {15, 1, 0}};
if (memcmp(rgba, rgb1555, 3 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_RGB555;
} else if (memcmp(rgba, bgr1555, 3 * sizeof(fb_bitfield)) == 0) {
format = QImage::Format_RGB555;
// pixeltype = BGRPixel;
}
break;
}
case 12: {
const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0},
{0, 4, 0}, {0, 0, 0}};
if (memcmp(rgba, rgb444, 3 * sizeof(fb_bitfield)) == 0)
format = QImage::Format_RGB444;
break;
}
case 8:
break;
case 1:
format = QImage::Format_Mono; //###: LSB???
break;
default:
break;
}return format;
}
好的我先改改试试
离线
感谢各位大佬的支持,问题终于解决了 linux 5.3.6 insmod fbtft_device.ko 就报错了,降低到 linux 4.16 在搞一次 颜色就正常了。不是qt问题啊。萌新感谢各位大佬的支持
离线