linux下的framebuffer的例子(转)
例子实现了直接写屏的功能,即把屏幕清空(变黑),程序的流程大致为:打开一个FrameBuffer设备;通过mmap调用把显卡的物理内存空间映射到用户空间;通过映射关系直接写内存。
头文件
////////////////////////////////////////
///////////// fbtools.h ////////////////
////////////////////////////////////////
#ifndef _FBTOOLS_H_
#define _FBTOOLS_H_
#include <linux/fb.h>
//a framebuffer device structure;
typedef struct fbdev
{
int fb;
unsigned long fb_mem_offset;
unsigned long fb_mem;
struct fb_fix_screeninfo fb_fix;
struct fb_var_screeninfo fb_var;
char dev[20];
} FBDEV, *PFBDEV;
//open & init a frame buffer
//to use this function,
//you must set FBDEV.dev="/dev/fb0"
//or "/dev/fbX"
//it's your frame buffer.
int fb_open(PFBDEV pFbdev);
//close a frame buffer
int fb_close(PFBDEV pFbdev);
//get display depth
int get_display_depth(PFBDEV pFbdev);
//full screen clear
void fb_memset(void *addr, int c, size_t len);
#endif
测试文件,其中深颜色的注释部分为在我机器上测得的结果
///////////////////////////////////////////
/////////////// fbtools.c ///////////////
///////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <asm/page.h>
#include "fbtools.h"
#define TRUE 1
#define FALSE 0
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
//open & init a frame buffer
int fb_open(PFBDEV pFbdev)
{
pFbdev->fb = open(pFbdev->dev, O_RDWR);// pFbdev->fb==3
if(pFbdev->fb < 0)
{
printf("Error opening %s: %m. Check kernel config
", pFbdev->dev);
return FALSE;
}
if (-1 == ioctl(pFbdev->fb,FBIOGET_VSCREENINFO,&(pFbdev->fb_var)))
{
printf("ioctl FBIOGET_VSCRE
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
安装篇
首先获取以下三个安装包 (安装不成功有提示 ,就是bind-libs-9.2.4-16.EL4被bind-9.2.4-16.EL4依赖)
bind-libs-9.2.4-16.EL4.rpm
bind-9.2.4-16.EL4.rpm
bind-devel-9.2.4-16.EL4.rpm
安装完成通过命令查看
rpm -qa|grep bind
结果如下所示就安装成功!
bind-libs-9.2.4-16.EL4
bind-9.2.4-16.EL4
bind- ......
将应用程序加到文件系统中打包后一起下载方法总结如下:
假设ramdisk.gz存放在/home/cvtech/jx2410/root/下面,则操作如下:
$cd /home/cvtech/jx2410/root/
$mkdir rd
$gunzip ramdisk.gz
上述操作后已将ramdisk.gz解压成ramdisk系统映像文件。
$mount -o loop ramdisk rd/
$cd rd/
其中命令mount的-o参数loop表示 ......
http://mirrors.163.com/archlinux/ (网易,公网测试中)
http://mirror.lupaworld.com/archlinux/(LUPA,推荐公网用户使用)
ftp://public.gooth.cn/archlinux/ (Gooth,电信、教育网)
rsync://public.gooth.cn/archlinux/ (Gooth,电信、教育网)
ftp://xde.gooth.cn/archlinux/ (Gooth,网通)
http://ft ......