Chinaunix首页 | 论坛 | 博客
  • 博客访问: 276980
  • 博文数量: 95
  • 博客积分: 2047
  • 博客等级: 大尉
  • 技术积分: 1022
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-14 16:18
文章分类

全部博文(95)

文章存档

2013年(1)

2011年(94)

我的朋友

分类: 嵌入式

2011-08-30 23:06:24

测试了一下S3C6410 LCD控制器提供的Overlay功能,写了一个简单的test,主要用于实现FB0和FB1之间的Overlay操作。
内核选项的Windows至少要为2。

具体支持如下操作:
1 使能OSD
2 关闭OSD
3 增加OSD的Alpha值
4 减少OSD的Alpha值
5 手动设置Alpha值(0-15)
6 上移OSD层
7 下移OSD层
8 左移OSD层
9 右移OSD层
10 设置OSD层

其中设置OSD层最重要,可以重新设置窗口的大小和起始位置,主要设置完后需要重新填充窗口数据,旧的数据将错乱。
///////////////////////////////////////////////////////////////
s3cfb.h
///////////////////////////////////////////////////////////////
#include
#include

typedef struct {
int bpp;
int left_x;
int top_y;
int width;
int height;
} s3c_win_info_t;

typedef struct{
__u32 phy_start_addr;
__u32 xres;
__u32 yres;
__u32 xres_virtual;
__u32 yres_virtual;
__u32 xoffset;
__u32 yoffset;
__u32 lcd_offset_x;
__u32 lcd_offset_y;
} s3c_fb_next_info_t;

#define FBIO_WAITFORVSYNC       _IOW ('F', 32, unsigned int)
#define S3C_FB_OSD_START        _IO  ('F', 201)
#define S3C_FB_OSD_STOP  _IO('F', 202)
#define S3C_FB_OSD_SET_INFO     _IOW ('F', 209, s3c_win_info_t)
#define S3C_FB_CHANGE_REQ       _IOW ('F', 308, int)
#define S3C_FB_GET_CURR_FB_INFO _IOR ('F', 321, s3c_fb_next_info_t)

#define S3C_FB_OSD_ALPHA_UP _IO  ('F', 203)
#define S3C_FB_OSD_ALPHA_DOWN _IO  ('F', 204)
#define S3C_FB_OSD_MOVE_LEFT _IO  ('F', 205)
#define S3C_FB_OSD_MOVE_RIGHT _IO  ('F', 206)
#define S3C_FB_OSD_MOVE_UP _IO  ('F', 207)
#define S3C_FB_OSD_MOVE_DOWN _IO  ('F', 208)
#define S3C_FB_OSD_ALPHA_SET _IOW ('F', 210, unsigned int)
#define S3C_FB_OSD_ALPHA0_SET _IOW ('F', 211, unsigned int)
#define S3C_FB_OSD_ALPHA_MODE _IOW ('F', 212, unsigned int)

////////////////////////////////////////////////////////////////
osd.c
////////////////////////////////////////////////////////////////
#include
#include
#include  
#include

#include "fb.h"
#include "s3cfb.h"

#define DEV_FB0 "/dev/fb0"
#define DEV_FB1 "/dev/fb1"

#define FILE1 "/overlay/1.bin"
#define FILE2 "/overlay/2.bin"

int stat,err;
int fb0,fb1;
s3c_win_info_t osd_info;

void set_osd_info(){
int input;
osd_info.bpp = 16;
printf("please input left x coordinate\n");
scanf("%d",&input);
osd_info.left_x = input;
printf("please input top y coordinate\n");
scanf("%d",&input);
osd_info.top_y = input;
printf("please input ods width\n");
scanf("%d",&input);
osd_info.width = input;
printf("please input osd height\n");
scanf("%d",&input);
osd_info.height = input;
}

int main(int argc, char *argv[])
{
printf("Begin the OSD test!\n");
if(argc < 2){
printf("Usage: ./osd 1\n"); //reserved
return -1;
}
fb0 = open("/dev/fb0",O_RDWR);
if(fb0 < 0) {
printf("open err! fb0 is %d\n",fb0);
return -1;
}
fb1 = open("/dev/fb1",O_RDWR);
if(fb1 < 0) {
printf("open err! fb1 is %d\n",fb1);
return -1;
}

stat = atoi(argv[1]);
printf("stat is %d\n",stat);
switch(stat){
case 1:
sleep(1);
ioctl(fb1,S3C_FB_OSD_START);
break;
default:
printf("err argv!\n");
}

while(1){
printf("Please choose one option:\n");
printf("1. enable the OSD\n");
printf("2. disable the OSD\n");
printf("3. + OSD alpha\n");
printf("4. - OSD alpha\n");
printf("5. set OSD alpha\n");
printf("6. move up OSD\n");
printf("7. move down OSD\n");
printf("8. move left OSD\n");
printf("9. move right OSD\n");
printf("10. SET OSD INFO\n");
printf("0. exit\n");

scanf("%d",&stat);
switch(stat){
case 1:
err = ioctl(fb1,S3C_FB_OSD_START);
if(err < 0) printf("ioctl err =%d",err);
break;
case 2:
err = ioctl(fb1,S3C_FB_OSD_STOP);
if(err < 0) printf("ioctl err =%d",err);
break;
case 3:
err = ioctl(fb1,S3C_FB_OSD_ALPHA_UP);
if(err < 0) printf("ioctl err =%d",err);
break;
case 4:
err = ioctl(fb1,S3C_FB_OSD_ALPHA_DOWN);
if(err < 0) printf("ioctl err =%d",err);
break;
case 5:
printf("please input your alpha level[0~15]\n");
scanf("%d",&stat);
err = ioctl(fb1,S3C_FB_OSD_ALPHA_SET,stat);
if(err < 0) printf("ioctl err =%d",err);
break;
case 6:
err = ioctl(fb1,S3C_FB_OSD_MOVE_UP);
if(err < 0) printf("ioctl err =%d",err);
break;
case 7:
err = ioctl(fb1,S3C_FB_OSD_MOVE_DOWN);
if(err < 0) printf("ioctl err =%d",err);
break;
case 8:
ioctl(fb1,S3C_FB_OSD_MOVE_LEFT);
break;
case 9:
err = ioctl(fb1,S3C_FB_OSD_MOVE_RIGHT);
if(err < 0) printf("ioctl err =%d",err);
break;
case 10:
set_osd_info();
err = ioctl(fb1,S3C_FB_OSD_SET_INFO,&osd_info);
if(err < 0) printf("ioctl err =%d",err);
break;
case 0:
goto exit;
default:
printf("please input number 0~10\n");
}
} //end of while(1)


exit:
sleep(1);
err = ioctl(fb1,S3C_FB_OSD_STOP);
if(err < 0) printf("ioctl err =%d",err);

return 0;
}

///////////////////////////////////////////////////////////////////////
//偷懒直接用脚本cat的图片数据test.sh
///////////////////////////////////////////////////////////////////////

#!/bin/sh
cat ./1.bin > /dev/fb0
cat ./22.bin > /dev/fb1
#cat ./3.bin > /dev/fb2
#cat ./4.bin > /dev/fb3
#cat ./5.bin > /dev/fb4
./osd 1
阅读(891) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~