测试:
1:make menuconfig去掉原来的驱动程序
    Device Drivers  --->    
        Graphics support  ---> 
           <M> S3C2410 LCD framebuffer support                 
2: make uImage
  make modules
  cp arch/arm/boot/uImage  /work/nfs_root/uImage_nolcd

3.使用新的uImage启动开发板:

insmod cfbcopyarea.ko
insmod cfbfillrect.ko 
insmod cfbimgblt.ko

insmod lcd.ko

4.

ech0 hello > /dev/tty1         //可以看到LCD上有hello

cat lcd.ko > /dev/fb0        //有花屏

5.修改/etc/inittab
  tty1::askfirst:-/bin/sh

insmod cfbcopyarea.ko

insmod cfbfillrect.ko

insmod cfbimgblt.ko

insmod lcd.ko

insmod buttons.ko

通过按键控制另一个sh控制台

 #include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/workqueue.h>
#include <linux/wait.h>
#include <linux/platform_device.h>
#include <linux/clk.h> #include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/div64.h> #include <asm/mach/map.h>
#include <asm/arch/regs-lcd.h>
#include <asm/arch/regs-gpio.h>
#include <asm/arch/fb.h> struct lcd_regs{
unsigned long lcdcon1;
unsigned long lcdcon2;
unsigned long lcdcon3;
unsigned long lcdcon4;
unsigned long lcdcon5;
unsigned long lcdsaddr1;
unsigned long lcdsaddr2;
unsigned long lcdsaddr3;
unsigned long redlut;
unsigned long greenlut;
unsigned long bluelut;
unsigned long reserved[];
unsigned long dithmode;
unsigned long tpal;
unsigned long lcdintpnd;
unsigned long lcdsrcpnd;
unsigned long lcdintmsk;
unsigned long lpcsel; }; static struct fb_info *s3c_lcd;
/* gpbon,gpbdat,c,d,g, */
volatile unsigned long *gpbcon;
volatile unsigned long *gpbdat;
volatile unsigned long *gpccon;
volatile unsigned long *gpdcon;
volatile unsigned long *gpgcon;
static volatile struct lcd_regs* lcd_regs;
static u32 pseudo_palette[]; static inline unsigned int chan_to_field(unsigned int chan, struct fb_bitfield *bf)
{
chan &= 0xffff;
chan >>= - bf->length;
return chan << bf->offset;
} static int s3c_lcdfb_setcolreg(unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue,
unsigned int transp, struct fb_info *info)
{
unsigned int val; if (regno > )
return ; /* 用red,green,blue三原色构造出val */
val = chan_to_field(red, &info->var.red);
val |= chan_to_field(green, &info->var.green);
val |= chan_to_field(blue, &info->var.blue); //((u32 *)(info->pseudo_palette))[regno] = val;
pseudo_palette[regno] = val;
return ;
} static struct fb_ops s3c_lcdfb_ops = {
.owner = THIS_MODULE,
.fb_setcolreg = s3c_lcdfb_setcolreg,
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
}; static int lcd_init(void)
{ /* 1. 分配一个fb_info */
s3c_lcd = framebuffer_alloc(, NULL); /* 2. 设置 */
/* 2.1 设置固定的参数 */
strcpy(s3c_lcd->fix.id, "mylcd");
s3c_lcd->fix.smem_len = * * / ;
s3c_lcd->fix.type = FB_TYPE_PACKED_PIXELS;
s3c_lcd->fix.visual = FB_VISUAL_TRUECOLOR; /*TFT*/
s3c_lcd->fix.line_length = * ; /* 2.2 设置可变的参数 */
s3c_lcd->var.xres = ;
s3c_lcd->var.yres = ;
s3c_lcd->var.xres_virtual = ;
s3c_lcd->var.yres_virtual = ;
s3c_lcd->var.bits_per_pixel = ; /* RGB:565 */
s3c_lcd->var.red.offset = ;
s3c_lcd->var.red.length = ; s3c_lcd->var.green.offset = ;
s3c_lcd->var.green.length = ; s3c_lcd->var.blue.offset = ;
s3c_lcd->var.blue.length = ; s3c_lcd->var.activate = FB_ACTIVATE_NOW; /* 2.3 设置操作函数 */
s3c_lcd->fbops = &s3c_lcdfb_ops; /* 2.4 其他设置 */
s3c_lcd->pseudo_palette = pseudo_palette; //假的调色板 s3c_lcd->screen_size = * * / ; /* 3. 硬件相关的设置 */
/* 3.1 配置GPIO用于LCD */
//0x56000010 ,8
gpbcon = ioremap(0x56000010, );
gpbdat = gpbcon + ;
gpccon = ioremap(0x56000020, );
gpdcon = ioremap(0x56000030, );
gpgcon = ioremap(0x56000060, );
//映射是一页一页映射,不用担心不足
*gpccon = 0xaaaaaaaa; // GPIO管脚用于VD[7:0],LCDVF[2:0],VM,VFRAME,VLINE,VCLK,LEND
*gpdcon = 0xaaaaaaaa; // GPIO管脚用于VD[23:8]
*gpbcon &= ~(); // Power enable pin
*gpbcon |= (0x01);
*gpbdat &= ~(<<); // Power off
*gpgcon |= (<<); // GPG4用作LCD_PWREN /* 3.2 根据LCD手册设置LCD控制器,比如VCLK的频率等 */
lcd_regs = ioremap(0x4D000000, sizeof(struct lcd_regs)); /*
* 设置LCD控制器的控制寄存器LCDCON1~5
* 1. LCDCON1:
* 设置VCLK的频率:VCLK(Hz) = HCLK/[(CLKVAL+1)x2]
* 选择LCD类型: TFT LCD
* 设置显示模式: 16BPP
* 先禁止LCD信号输出
* 2. LCDCON2/3/4:
* 设置控制信号的时间参数
* 设置分辨率,即行数及列数
* 现在,可以根据公式计算出显示器的频率:
* 当HCLK=100MHz时,
* Frame Rate = 1/[{(VSPW+1)+(VBPD+1)+(LIINEVAL+1)+(VFPD+1)}x
* {(HSPW+1)+(HBPD+1)+(HFPD+1)+(HOZVAL+1)}x
* {2x(CLKVAL+1)/(HCLK)}]
* = 60Hz
* 3. LCDCON5:
* 设置显示模式为16BPP时的数据格式: 5:6:5
* 设置HSYNC、VSYNC脉冲的极性(这需要参考具体LCD的接口信号): 反转
* 半字(2字节)交换使能
*/ lcd_regs->lcdcon1 = (<<) | (0x3<<) | \
(0xC<<) | (<<);
lcd_regs->lcdcon2 = (<<) | (<<) | \
(<<) | (-);
lcd_regs->lcdcon3 = (<<) | (<<) | ();
lcd_regs->lcdcon4 = ;
lcd_regs->lcdcon5 = (<<) | (<<) | (<<) | \
(<<);
/* 3.3 分配显存(framebuffer),并把地址告诉LCD控制器 */
s3c_lcd->screen_base = dma_alloc_writecombine(NULL, \
s3c_lcd->fix.smem_len, &s3c_lcd->fix.smem_start, GFP_KERNEL);
lcd_regs->lcdsaddr1 = (s3c_lcd->fix.smem_start>>) & ~( << );
lcd_regs->lcdsaddr2 = ((s3c_lcd->fix.smem_start + s3c_lcd->fix.smem_len) >> ) \
& ( 0X1fffff );
lcd_regs->lcdsaddr3 = (<<) | ( */); /* 启动LCD */
lcd_regs->lcdcon1 |= ( << ); //使能LCD本身
lcd_regs->lcdcon5 |= (<<); // 设置是否输出LCD_PWREN
*gpbdat |= (<<); // Power on /* 4. 注册 */ register_framebuffer(s3c_lcd); return ;
} static int lcd_exit(void)
{
unregister_framebuffer(s3c_lcd);
lcd_regs->lcdcon1 &= ~( << ); //关闭LCD本身
*gpbdat &= ~(<<); // Power off
dma_free_writecombine(NULL, s3c_lcd->fix.smem_len, \
s3c_lcd->screen_base, s3c_lcd->fix.smem_start); iounmap(gpbcon);
iounmap(gpccon);
iounmap(gpdcon);
iounmap(gpgcon); framebuffer_release(&s3c_lcd);
return ;
} module_init(lcd_init);
module_exit(lcd_exit); MODULE_LICENSE("GPL");

LCD驱动 15-3的更多相关文章

  1. LCD驱动 15 -2

    1.分配一个fb_info结构体: framebuffer_alloc 2.设置 3.注册 4.硬件相关操 struct fb_fix_screeninfo { char id[16];   /* i ...

  2. 嵌入式Linux驱动学习之路(十八)LCD驱动

    驱动代码: /************************************************************************* > File Name: lcd ...

  3. FL2440驱动添加(3)LCD驱动添加学习笔记

    FL2440 LCD内置控制器,320*240 TFT型LCD. 自我理解总结的两种添加驱动模式: 非platform方式添加驱动: 加载驱动: 1,硬件初始化,申请内存,并作地址映射 2,分配设备号 ...

  4. Smart210学习-----lcd驱动

    帧缓冲设备 1.1帧缓冲设备:帧缓冲(framebuffer)是 Linux 系统为显示设备提供的一个接口,它将显示缓冲区抽象,屏蔽图像硬件的底层差异,允许上层应用程序在图形模式下直接对显示缓冲区进行 ...

  5. S3C2440 LCD驱动(FrameBuffer)实例开发<一>(转)

    1. 背景知识 在多媒体的推动下,彩色LCD越来越多地应用到嵌入式系统中,PDA和手机等大多都采用LCD作为显示器材,因此学习LCD的应用很有实际意义! LCD工作的硬件需求:要使一块LCD正常的显示 ...

  6. LCD驱动(FrameBuffer)实例开发讲解

    一.开发环境 主  机:VMWare--Fedora 9 开发板:Mini2440--64MB Nand, Kernel:2.6.30.4 编译器:arm-linux-gcc-4.3.2 二.背景知识 ...

  7. LCD驱动移植在在mini2440(linux2.6.29)和FS4412(linux3.14.78)上实现对比(deep dive)

    1.Linux帧缓冲子系统 帧缓冲(FrameBuffer)是Linux为显示设备提供的一个接口,用户可以将帧缓冲看成是显示内存的一种映像,将其映射到进程地址空间之后,就可以直接进行读写操作,而写操作 ...

  8. lcd驱动框架

    目录 lcd驱动框架 框图 程序分析 入口 打开open 读read 初始化registered_fb 注册 小结 程序设计 测试 方式一操作fb0 方式二操作tty 方式三操作终端 完整程序 tit ...

  9. linux 驱动之LCD驱动(有framebuffer)

    <简介> LCD驱动里有个很重要的概念叫帧缓冲(framebuffer),它是Linux系统为显示设备提供的一个接口,应用程序在图形模式允许对显示缓冲区进行读写操作.用户根本不用关心物理显 ...

  10. LCD驱动分析【转】

    转自:http://blog.csdn.net/hanmengaidudu/article/details/21559153 1.S3C2440上LCD驱动 (FrameBuffer)实例开发讲解 其 ...

随机推荐

  1. 线程高级应用-心得6-java5线程并发库中同步工具类(synchronizers),新知识大用途

    1.新知识普及 2. Semaphore工具类的使用案例 package com.java5.thread.newSkill; import java.util.concurrent.Executor ...

  2. Java 13 字符串

    1 String对象不可变 每一个修改String值的方法 实际上都是创建一个全新的String对象 public class Immutable { public static String upc ...

  3. gO语言的安装和环境变量的配置

    一.Go语言下载 go语言官方下载地址:https://golang.org/dl/ 找到适合你系统的版本下载,本人下载的是windows版本.也可以下载Source自己更深层次研究go语言. 二.G ...

  4. 转!!MAC和PHY的区别

    一块以太网网卡包括OSI(开方系统互联)模型的两个层,物理层和数据链路层.物理层定义了数据传送与接收所需要的电与光信号.线路状态.时钟基准.数据编码和电路等,并向数据链路层设备提供标准接口.数据链路层 ...

  5. php ajax json jquery 记录

    php+jquery+ajax+json简单小例子 <html> <title>php+jquery+ajax+json简单小例子</title> <?php ...

  6. sql中charindex

    假如你写过很多程序,你可能偶尔会碰到要确定字符或字符窜串否包含在一段文字中,在这篇文章中,我将讨论使用CHARINDEX和PATINDEX函数来搜索文字列和字符串.我将告诉你这两个函数是如何运转的,解 ...

  7. 微信公共平台php用$GLOBALS["HTTP_RAW_POST_DATA"]收不到信息解决方法

    http://www.cnblogs.com/shendiao/archive/2013/04/24/3041450.html <?php /** * wechat php test */ // ...

  8. Machine Learning - 第4周(Neural Networks: Representation)

    Neural networks is a model inspired by how the brain works. It is widely used today in many applicat ...

  9. 基于SourceTree 下的 Git Flow 模型

    基于SourceTree 下的 Git Flow 模型 1. sourceTree  是一个开源的git 图形管理工具,可下载mac版本,windows版本 2. Git Flow 是一套使用Git进 ...

  10. kubernetes容器编排系统介绍

    版权声明:本文由turboxu原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/152 来源:腾云阁 https://www. ...