我正在尝试使用可加载的内核模块来修改LCD显示参数.以下是内核的编译代码.
void set_fb_video ()
{
platform_device_unregister(&goldfish_lcd);
((atmel_lcdfb_info*)goldfish_lcd.dev.platform_data)->default_monspecs->modedb->xres = 10;
platform_device_register(&goldfish_lcd);
};
EXPORT_SYMBOL("set_fb_video");
Run Code Online (Sandbox Code Playgroud)
然后我有一个可加载的内核模块lcd_modify.ko
int __init init_module(void)
{
..
..
set_fb_video();
..
..
return;
}
Run Code Online (Sandbox Code Playgroud)
然后使用insmod lcd_modify.ko将模块加载到设备
此时设备挂断了.
题:
感谢您提前的反馈.
动机 - 用C(和装配,如果需要)编写程序,为屏幕红色的矩形区域着色.
STRICT要求 - 在文本/控制台模式下使用最小的实用程序和接口运行GNU/Linux .所以没有X(或类似Wayland/Mir),没有非默认(内核提供的POSIX,LSB等)库或接口,除了监视器的设备驱动程序之外没有其他假设.
实际上,我正在寻找的是有关如何编写程序的信息,该程序最终将通过VGA端口发送信号并通过电缆连接到显示器,以便为屏幕的特定部分着色.
抱歉,如果这听起来很粗鲁,但没有"你为什么要这样做?" 或者"你为什么不使用ABC库?" 回答.我试图了解如何编写X服务器的实现或内核帧缓冲(/ dev/fb0)库.可以提供指向C库源的链接.
我发现以下代码旨在在屏幕上绘制正方形。
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
int main()
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
long int location = 0;
// Open the file for reading and writing
fbfd = open("/dev/fb0", O_RDWR);
if (fbfd == -1) {
perror("Error: cannot open framebuffer device");
exit(1);
}
printf("The framebuffer device was opened successfully.\n");
// …Run Code Online (Sandbox Code Playgroud)