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 暴走的小 ...
随机推荐
- windows下读取Linux分区软件
导读 ext3等日志型文件系统是Linux中被广泛应用的,通常是许多流行Linux发行版默认的文件系统.etx4也是Linux下的日志型文件系统,被设计作为ext3的继任者.他消除了64位存储限制,是 ...
- SVM 总结
SVM有一个核心函数SMO,也就是序列最小最优化算法.SMO基本是最快的二次规划优化算法,其核心就是找到最优参数α,计算超平面后进行分类.SMO方法可以将大优化问题分解为多个小优化问题求解,大大简化求 ...
- C#应用视频教程3.1 USB工业相机测试
图像处理是工控很有价值的一个领域,比如人脸识别,车牌识别,还有产品的位置识别,瑕疵检测,对于个人学习来说,我们无法直接上手几万块的成熟工业相机(高端的康耐视要6万左右,而且是黑白的,要测试一些带颜色的 ...
- 论文笔记《Feedforward semantic segmentation with zoom-out features》
[论文信息] <Feedforward semantic segmentation with zoom-out features> CVPR 2015 superpixel-level,f ...
- STL - 算法 - 普通拷贝
list<, , , , , , , , }; vector<int> coll2; cout << "** collection 1: **" &l ...
- IIS 之 功能详解
IIS (Internet Information Services)信息服务管理器,本文以Windows10环境下的IIS为例,主要包含:FTP 服务器.Web 管理工具.万维网服务三大部分,如下表 ...
- iOS子线程操作检测版本更新,有新版本通知用户更新, CheckVersion
iOS子线程操作检测版本更新,有新版本通知用户更新 CheckVersion 一:如何使用: #import "CheckVersion.h" //输入你的app在appStore ...
- Python3.2官方文档翻译--迭代器
6.9 迭代器 到眼下为止.你可能已注意到很多容器对象都能够用for语句进行循环: 这样的訪问风格清楚简洁方便. 迭代器的应用是python遍历统一.在这样的场景背后.for语句调用容器对象iter( ...
- 算法笔记_026:折半查找(Java)
目录 1 问题描述 2 解决方案 2.1 递归法 2.2 迭代法 1 问题描述 首先,了解一下何为折半查找?此处,借用<算法设计与分析基础>第三版上一段文字介绍: 2 解决方案 2.1 递 ...
- 父元素没有设置定位 position absolute 解析
1.示例代码 <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UT ...