linux - fpga-framebuff驱动
* linux/drivers/video/fpga_fb.c --fpga graphics adaptor frame buffer device
* Created 16 Sep2011
* Based on dnfb.c
*
* History:
*
* 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.
*/
#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/interrupt.h>
#include <linux/platform_device.h>
#include <asm/setup.h>
#include <asm/system.h>
#include <asm/irq.h>
#include <linux/clk.h>
#include <linux/fb.h>
#include <linux/module.h>
#define LCD_WIDTH 320
#define LCD_HEIGHT 240
#define DISPRAMBUFLSZ (LCD_WIDTH/8)
#define DISPRAMBUFSIZE (DISPRAMBUFLSZ*LCD_HEIGHT)
/* display_ video definitions */
static void __iomem *io_data=NULL;
static void __iomem *io_cmd=NULL;
static void __iomem *io_ctrl=NULL;
static unsigned long ioo_data=0;
static unsigned char *rambuf_org = NULL;
static unsigned char *rambuf_cur = NULL;
/* frame buffer operations */
// zydzfb_blank控制屏幕开关
static int zydzfb_blank(int blank, struct fb_info *info);
static struct fb_ops zydzfb_ops = {
.owner = THIS_MODULE,
//.fb_blank = zydzfb_blank,
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
};
struct fb_var_screeninfo zydzfb_var __devinitdata = {
.xres = 320,//实际x轴分辨率
.yres = 240,//实际y轴分辨率
.xres_virtual = 320,//虚拟x轴分辨率
.yres_virtual = 240,//虚拟y轴分辨率
.bits_per_pixel= 1, //定义每个点用多少位表示
.height = -1,
.width = -1,
//.vmode = FB_VMODE_NONINTERLACED,
};
static struct fb_fix_screeninfo zydzfb_fix __devinitdata = {
.id = "zydzfb",//设备名称
.type = FB_TYPE_PACKED_PIXELS,
.visual = FB_VISUAL_MONO01 ,/* Monochr. 1=Black 0=White */
.line_length = DISPRAMBUFLSZ,
};
/*
* Initialization
*/
static int __devinit zydzfb_probe(struct platform_device *dev)
{
struct fb_info *info;
int err = 0;
info = framebuffer_alloc(0, &dev->dev);
if (!info)
return -ENOMEM;
info->fbops = &zydzfb_ops;
info->fix = zydzfb_fix;
info->fix.smem_start = virt_to_phys(rambuf_cur);
info->fix.smem_len = DISPRAMBUFSIZE;
info->var = zydzfb_var;
/* Virtual address */
info->screen_base = rambuf_cur;
info->screen_size = DISPRAMBUFSIZE;
err = fb_alloc_cmap(&info->cmap, 2, 0);
if (err < 0) {
framebuffer_release(info);
return err;
}
err = register_framebuffer(info);
if (err < 0) {
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
return err;
}
platform_set_drvdata(dev, info);
/* now we have registered we can safely setup the hardware */
printk("display_ frame buffer alive and kicking !\n");
return err;
}
void disp_init( )
{
static int inited=0;
if(inited)return;
io_data=ioremap_nocache(LCD_DATA_PORT,32);
io_cmd=ioremap_nocache(LCD_CTRL_PORT,32);
io_ctrl=ioremap_nocache(LCD_PERH_PORT,32);
rambuf_org = kmalloc(DISPRAMBUFSIZE,GFP_KERNEL);
rambuf_cur = kmalloc(DISPRAMBUFSIZE,GFP_KERNEL);
lcd_reset();
inited=1;
}
unsigned char re_uc(unsigned char x)
{
x = (x&0x0f)<<4 |(x&0xf0)>>4;
x = (x&0x33)<<2 |(x&0xcc)>>2;
x = (x&0x55)<<1 |(x&0xaa)>>1;
return x;
}
static struct timer_list timer_key;
void fb_timer_func(unsigned long pa)
{
int i;
for(i=0;i<LCD_HEIGHT*DISPRAMBUFLSZ;i++)
{
if(rambuf_org[i]!=rambuf_cur[i])
{
WriteLCDCmd(SRCSET_CMD);
WriteLCDData(i%0x100);
WriteLCDData(i/0x100);
WriteLCDCmd(MEMWRITE_CMD);
WriteLCDData(re_uc(rambuf_cur[i]));
rambuf_org[i]=rambuf_cur[i];
}
}
mod_timer(&timer_key,jiffies+20);
}
static struct platform_driver zydzfb_driver = {
.probe = zydzfb_probe,
.driver = {
.name = "zydzfb",
},
};
static struct platform_device zydzfb_device = {
.name = "zydzfb",
};
int __init zydzfb_init(void)
{
int ret,i,j;
disp_init( );
ret = platform_driver_register(&zydzfb_driver);
if (!ret) {
ret = platform_device_register(&zydzfb_device);
if (ret)
platform_driver_unregister(&zydzfb_driver);
}
init_timer(&timer_key);
timer_key.function=&fb_timer_func;
timer_key.expires=jiffies+10;
timer_key.data = 0;
add_timer(&timer_key);
return ret;
}
static void __exit zydzfb_exit(void)
{
del_timer(&timer_key);
platform_device_unregister(&zydzfb_device);
platform_driver_unregister(&zydzfb_driver);
if (rambuf_org)
kfree(rambuf_org);
if (rambuf_cur)
kfree(rambuf_cur);
}
module_init(zydzfb_init);
module_exit(zydzfb_exit);
MODULE_LICENSE("GPL");
linux - fpga-framebuff驱动的更多相关文章
- (57)Linux驱动开发之三Linux字符设备驱动
1.一般情况下,对每一种设备驱动都会定义一个软件模块,这个工程模块包含.h和.c文件,前者定义该设备驱动的数据结构并声明外部函数,后者进行设备驱动的具体实现. 2.典型的无操作系统下的逻辑开发程序是: ...
- linux块设备驱动之实例
1.注册:向内核注册个块设备驱动,其实就是用主设备号告诉内核这个代表块设备驱动 sbull_major = register_blkdev(sbull_major, "sbull&quo ...
- Linux 视频设备驱动V4L2最常用的控制命令
http://blog.csdn.net/shaolyh/article/details/6583226 Linux 视频设备驱动V4L2最常用的控制命令使用说明(1.02) 命令 功能 VIDIOC ...
- linux 2.6 驱动笔记(一)
本文作为linux 2.6 驱动笔记,记录环境搭建及linux基本内核模块编译加载. 环境搭建: 硬件:OK6410开发板 目标板操作系统:linux 2.6 交叉编译环境:windows 7 + v ...
- 深入理解Linux字符设备驱动
文章从上层应用访问字符设备驱动开始,一步步地深入分析Linux字符设备的软件层次.组成框架和交互.如何编写驱动.设备文件的创建和mdev原理,对Linux字符设备驱动有全面的讲解.本文整合之前发表的& ...
- Linux字符设备驱动结构(一)--cdev结构体、设备号相关知识机械【转】
本文转载自:http://blog.csdn.net/zqixiao_09/article/details/50839042 一.字符设备基础知识 1.设备驱动分类 linux系统将设备分为3类:字符 ...
- Smart210学习记录----beep linux字符设备驱动
今天搞定了beep linux字符设备驱动,心里还是很开心的,哈哈...但在完成的过程中却遇到了一个非常棘手的问题,花费了我大量的时间,,,, 还是把问题描述一下吧,好像这个问题很普遍的,网上许多解决 ...
- s3c6410 linux gadget hid驱动
s3c6410 linux gadget hid驱动调了我一个多星期了今天终于搞定了,来跟大家分享下. 上一个星期纠结了一个星期的寄存器,试了N次,不管把3.1和3.7的hid驱动移植过来也是一样的情 ...
- 调试exynos4412—ARM嵌入式Linux—LEDS/GPIO驱动之二
/** ****************************************************************************** * @author 暴走的小 ...
- 调试exynos4412—ARM嵌入式Linux—LEDS/GPIO驱动之一
/** ****************************************************************************** * @author 暴走的小 ...
随机推荐
- MongoDB 数据迁移 备份 导入(自用)
MongoDB bin文件夹下 备份:mongodump -h IP:PORT -d 库名 -c 集合名 -o 存储路径 恢复:mongorestore -h IP:PORT -d 库名 -c 集合名 ...
- 浅析GitLab Flow的十一个规则
使用 Git 版本控制,是对使用它之前的所有版本控制方式的一种改进.然而,很多组织最终以太过混乱或过于复杂的流程来结束.这个问题对于刚从其他版本控制系统转过来的组织来说特别突出. 在本文中我们会列出 ...
- Cognos清除本地高速缓存的利与弊
场景:在开发报表初期,往往我们遇到过这种问题,我们手工修改了DB中的测试数据,但是返回报表看,数据还没有更新,难道是设计出问题了?NO,不要慌,这是因为Cognos为了查询效率设计了高速缓存的选项. ...
- public类型中internal成员
今天遇到一问题,找到下面的两篇文章,研究比较深入,特转了一下, 最近除了搞ASP.NET MVC之外,我也在思考一些编程实践方面的问题.昨天在回家路上,我忽然对一个问题产生了较为清晰的认识.或者说,原 ...
- css换行缩进
1.换行缩进 <div id="alertiframe"> <span id="closeiframe">×</span> ...
- es5 - array - unshift
/** * 描述:该unshift()方法从数组中添加单个或多个元素,并且返回长度 * 语法:arr.unshift(element1 [,... [,elementN ]]) * 参数:要添加到数组 ...
- GMM高斯混合模型 学习(2)
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHpxMjAwODExMjExMDc=/font/5a6L5L2T/fontsize/400/fill/I0 ...
- 最低位 【杭电-HDOJ-1196】 附题
/* Lowest Bit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- EL函数库
一.EL函数库介绍 由于在JSP页面中显示数据时,经常需要对显示的字符串进行处理,SUN公司针对于一些常见处理定义了一套EL函数库供开发者使用. 这些EL函数在JSTL开发包中进行描述,因此在JSP页 ...
- myeclipse2014安装jad反编译插件
myeclipse上默认不能查看class文件,需要查看的话安装反编译插件 安装步骤: 准备图中框里的两个文件 1. [net.sf.jadclipse_3.3.0.jar]文件拷贝到如下路径([D: ...