嵌入式驱动编写-LCD驱动程序

本文介绍了如何编写S3C2440芯片的LCD驱动程序,包括查阅开发手册和原理图,分配并设置fb_info结构体,注册framebuffer,以及在内核中去除原有驱动并重新编译加载。在开发过程中,遇到屏幕不亮的问题,并通过insmod加载模块进行调试。
摘要由CSDN通过智能技术生成


如何来写LCD的驱动程序,首先 看芯片开发手册和原理图















根据原理图,找到s3c2440的GPIO控制管脚,gpb   gpc  gpd  gpg管脚控制

需要设置寄存器

以及设置LCD控制寄存器

查看内核中的fbmem.c (drivers\video) 文件

registered_fb数组中根据次设备号得到一个fb_info结构体

register_framebuffer中设置registered_fb结构体.

static ssize_t
fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
	unsigned long p = *ppos;
	struct inode *inode = file->f_path.dentry->d_inode;
	int fbidx = iminor(inode);
	struct fb_info *info = registered_fb[fbidx];
	u32 *buffer, *dst;
	u32 __iomem *src;
	int c, i, cnt = 0, err = 0;
	unsigned long total_size;

	if (!info || ! info->screen_base)
		return -ENODEV;

	if (info->state != FBINFO_STATE_RUNNING)
		return -EPERM;

	if (info->fbops->fb_read)
		return info->fbops->fb_read(info, buf, count, ppos);
	
	total_size = info->screen_size;

	if (total_size == 0)
		total_size = info->fix.smem_len;

	if (p >= total_size)
		return 0;

	if (count >= total_size)
		count = total_size;

	if (count + p > total_size)
		count = total_size - p;

	buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
			 GFP_KERNEL);
	if (!buffer)
		return -ENOMEM;

	src = (u32 __iomem *) (info
  • 3
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值