⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_test.c

📁 这是一个基于S3C2440 的VGA 驱动程序, 其中fc.c 是驱动程序,fc_test.c 是测试代码. 这是一个在LINUX frame buffer基础上利用 DMA 实现的高效驱动, 绝
💻 C
📖 第 1 页 / 共 5 页
字号:
};static char digitfont24x16[480]={0x00,0x00,0x07,0xc0,0x0c,0x30,0x18,0x30,0x18,0x18,0x18,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,
0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x18,0x18,0x18,0x10,0x18,0x30,0x0c,0x60,0x07,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x80,0x1f,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x1f,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xe0,0x18,0x38,0x30,0x1c,0x30,0x1c,0x38,0x1c,0x38,0x1c,0x00,0x1c,0x00,0x1c,0x00,0x38,0x00,0x30,0x00,0x60,
0x00,0xc0,0x01,0x80,0x03,0x00,0x02,0x00,0x04,0x00,0x08,0x04,0x10,0x04,0x30,0x08,0x3f,0xf8,0x3f,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xc0,0x18,0x70,0x30,0x38,0x38,0x38,0x38,0x18,0x00,0x18,0x00,0x38,0x00,0x30,0x00,0xe0,0x03,0x80,0x04,0xe0,
0x00,0x38,0x00,0x1c,0x00,0x0c,0x00,0x0c,0x30,0x0c,0x70,0x0c,0x70,0x0c,0x30,0x18,0x1c,0x70,0x07,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x60,0x00,0x60,0x00,0xe0,0x01,0xe0,0x01,0x60,0x02,0x60,0x04,0x60,0x0c,0x60,0x08,0x60,0x10,0x60,
0x30,0x60,0x20,0x60,0x40,0x60,0x80,0x60,0xff,0xfe,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xf0,0x03,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xfc,0x1b,0xf8,0x18,0x00,0x18,0x00,0x18,0x00,0x10,0x00,0x10,0x00,0x11,0xc0,0x16,0xf0,0x18,0x38,0x10,0x1c,
0x00,0x1c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x10,0x0c,0x38,0x1c,0x38,0x18,0x38,0x38,0x1c,0x70,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xc0,0x07,0x78,0x0e,0x18,0x1c,0x1c,0x18,0x18,0x38,0x00,0x38,0x00,0x30,0x00,0x31,0xc0,0x36,0x30,0x38,0x18,
0x38,0x1c,0x30,0x0c,0x30,0x0c,0x30,0x0c,0x30,0x0c,0x30,0x1c,0x18,0x18,0x18,0x38,0x0c,0x70,0x03,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xfe,0x20,0x06,0x20,0x0c,0x40,0x18,0x40,0x30,0x00,0x60,0x00,0x40,0x00,0xc0,0x00,0x80,0x01,0x80,
0x01,0x80,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xe0,0x0c,0x10,0x18,0x08,0x18,0x08,0x38,0x0c,0x38,0x08,0x18,0x18,0x1c,0x10,0x0f,0x60,0x07,0xc0,0x07,0xe0,
0x0c,0x78,0x18,0x3c,0x30,0x1c,0x20,0x0c,0x20,0x0c,0x20,0x0c,0x30,0x0c,0x18,0x18,0x0e,0x30,0x03,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xe0,0x0c,0x30,0x18,0x18,0x30,0x18,0x30,0x1c,0x30,0x0c,0x30,0x0c,0x30,0x0c,0x30,0x0c,0x30,0x1c,0x18,0x1c,
0x0e,0xec,0x03,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x1c,0x18,0x18,0x38,0x18,0x18,0x30,0x0f,0xe0,0x01,0x00,0x00,0x00,0x00,0x00};
 int Current_Node;unsigned char* fbp;struct fb_var_screeninfo vinfo; 
struct fb_fix_screeninfo finfo; 
long int screensize = 0; int sw,sh;int key_number=0;int key_input=0;unsigned int UserID;unsigned int Password;unsigned int d_count=0;char Run_Flag=1;///static wait_queue_head_t wt;//static int write_count=0;int fmd,fk,fl;int main(void){    int ret=6,fd,i,buf,sc=0;    unsigned char FMCbuf[100];    unsigned char KBCbuf[100];    static int ret_cnt=0;    int status,pi,inx;    unsigned char recvbuf[MAXLEN];    int slogo=0;    pid_t pid;    printf("hello!\n");    pi=0;    inx=0;    while((pi==0)&&(inx<10))    {        Load_Keyboard_Driver();        for(i=0;i<8888888;i++) fd=ret*i;        Make_Keyboard_DevFile();        for(i=0;i<8888888;i++) fd=ret*i;        fk=open("/dev/Keyboard",O_RDWR);        if(fk<0)        {            printf("Erorr in open Keyboard\n");            close(fk);            Remove_Keyboard_DevFile();            for(i=0;i<8888;i++) fd=ret*i;            Remove_Keyboard_File();            for(i=0;i<8888;i++) fd=ret*i;            sleep(1);            inx++;        }        else            pi=1;    }//    buf[0]=0x55;    Load_FM_Driver();    for(i=0;i<8888888;i++)  fd=ret*i;    Make_FM_DevFile();    for(i=0;i<8888888;i++) fd=ret*i;    fd=open("/dev/fm",O_WRONLY);    if(fd<0)    {        printf("Erorr in open_FM\n");        return -1;    }    FMCbuf[0]=0;    ret=write(fd,FMCbuf,1);        close(fd);    for(i=0;i<888;i++)  fmd=ret*i;        fmd = open("/dev/fb0", O_RDWR);    if(fmd<0)    printf("Open error\n");    ioctl(fmd, FBIOGET_FSCREENINFO, &finfo); 
    ioctl(fmd, FBIOGET_VSCREENINFO, &vinfo);     screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;     printf("x=%d''''y=%d\n",vinfo.xres,vinfo.yres);    fbp=(char*)mmap(0,screensize,PROT_READ|PROT_WRITE,MAP_SHARED,fmd, 0);   //    memset (fbp, 0, screensize);    sw=vinfo.xres;    sh=vinfo.yres;//    Paint_Ico(0,180,278);    Clean_Info();    Paint_String(0,230,278);    Run_Flag=1;    Paint_Ico(6,ICON_X1,ICON_Y1);    Paint_Info(0,INFO_X1,INFO_Y1);       Load_MLG_Driver();    for(i=0;i<8888888;i++)  fd=ret*i;    Make_MLG_DevFile();    for(i=0;i<8888888;i++) fd=ret*i;    fl=open("/dev/mlg",O_WRONLY);    if(fl<0)    {        printf("Erorr in open_mlg\n");        return -1;    }    while(Run_Flag)//    printf("File ID=%d\n",fd);//    for(i=0;i<10;i++)    {        sc=ret;        //PaintBitmap_sin(mlogo,240,50,165,45,slogo);        //if((slogo%100)==0) Free_memory();        slogo=(slogo+1)%180;        ret=read(fk,&KBCbuf,(size_t)1);        if(ret<0)        {            printf("Error in keyboard_read \n");        }        else if(ret>0)        {            if((sc!=ret)&&(ret!=0))            {                key_input=KBCbuf[0];                printf("Key_code=%d\n",key_input);                sc=FSM[Current_Node].Screen_No;                FS_machine(KBCbuf[0]);                if(FSM[Current_Node].Screen_No!=sc)                {/*                    close(fmd);                    fd=open("/dev/fm",O_WRONLY);                    if(fd<0)                    {                         printf("Erorr in open_fm\n");                         return -1;                    }                    FMCbuf[0]=FSM[Current_Node].Screen_No;                    ret=write(fd,FMCbuf,1);                    close(fd);                    fmd = open("/dev/fb0", O_RDWR);                    if(fmd<0)                        printf("Open error\n");                    fbp=(char*)mmap(0,screensize,PROT_READ|PROT_WRITE,MAP_SHARED,fmd, 0);                       for(i=0;i<88888;i++) fd=ret*i;                    if(FSM[Current_Node].Screen_No==1)                        Paint_Ico(4,480,95);*///                    close(fd);                    printf("Wait a bit\n");                }//if(FSM[Current_Node].Screen_No!=sc)            }//if((sc!=ret)&&(ret!=0))        }  //else if(ret>0)        //sleep(3);    } //while(Run_Flag)    close(fl);    for(i=0;i<888888;i++) fd=ret*i;    PaintBi_ValueBitmap(waitpromc_1,0,0,640,480,0x87ff,0x1f);    close(fk);    close(fmd);    close(fl);    for(i=0;i<8888;i++) fd=ret*i;    Remove_MLG_DevFile();    for(i=0;i<8888;i++) fd=ret*i;    Remove_MLG_File();    for(i=0;i<8888;i++) fd=ret*i;    Remove_Keyboard_DevFile();    for(i=0;i<8888;i++) fd=ret*i;    printf("remove keyboard ok\n");    close(fd);    sleep(1);    Remove_FM_DevFile();    for(i=0;i<8888;i++) fd=ret*i;    Remove_Keyboard_File();    for(i=0;i<8888;i++) fd=ret*i;    Remove_FM_File();    for(i=0;i<8888;i++) fd=ret*i;/*    printf("switch a new screen\n");    fd=open("/dev/fm",O_WRONLY);    if(fd<0)    {        printf("Erorr in open\n");        return -1;    }    FMCbuf[0]=2;    ret=write(fd,FMCbuf,1);        close(fd);    for(i=0;i<888888;i++)  fmd=ret*i;    printf("Paint a title\n");    PaintBi_ValueBitmap(&t2[0],0,0,640,32,0x07ff,0x1f);*//*    while(1)    {        printf("XYMain start=%d\n",ret_cnt);        if((pid=vfork())<0)
        {
            perror("fork");            return 0;
            exit(1);
        }
        else if (pid==0)
        {
            printf("Xykey start\n");            execl("/tmp/t1.o",NULL);            printf("Execl____OK\n");            return 1;
            exit(1);
        }            else        {                sleep(1);            printf("PID=%d\n",pid);            if(ret_cnt>0)            {                                   fd=open("/proc/rw_test",O_WRONLY|O_SYNC);                if(fd<0)                {                    printf("Erorr in open2\n");                }                printf("Proc is opened_write1\n");                sprintf(recvbuf,"RST %2d",ret_cnt);                ret=write(fd,&recvbuf,(size_t)6);                close(fd);                printf("Proc is wroten1\n");                if(ret==-1) printf("Erorr in write\n");               }            if(wait(&status)!=pid)            {                printf("wait_error!\n");                exit(0);            }            printf("subprocessor is aborted\n");            ret_cnt++;            fd=open("/proc/rw_test",O_WRONLY|O_SYNC);            if(fd<0)            {                printf("Erorr in open_restart\n");            }            printf("Proc is opened_write_restart\n");            sprintf(recvbuf,"RES %2d",ret_cnt);            ret=write(fd,&recvbuf,(size_t)6);            close(fd);            printf("Proc is wroten_restart\n");            if(ret==-1) printf("Erorr in write_restart\n");//            sleep(2);        }    }*///    Paint_Ico(0,120,320);/*    printf("Node_ID=%d.....SName=%s.....Key_ID(3)=%d\n",FSM[2].Node_ID,FSM[2].SName,FSM[5].Key_List[3].Key_ID);    FSM[0].Key_List[46].Func();*///    ret=write(fd,RTCbuf,6);}/*    while(1)    {        sleep(3);    }    close(fd);        return 1;//    ret=write(fd,RTCbuf,6);}*/void DrawPoint(int x,int y,int color){    *(fbp+2*(sw*y+x))=color%256;    *(fbp+2*(sw*y+x)+1)=color/256;}void DrawLine(int x1,int y1,int x2,int y2,int color){    int i,j,k;    if(x1>x2)    {        i=x1;        j=y1;        x1=x2;        y1=y2;        x2=i;        y2=j;    }    if(abs(x1-x2)>=abs(y1-y2))    {        if(y1!=y2)        {            k=(x2-x1)/(y2-y1);        }        else k=x2-x1+1;        for(i=x1;i<x2;i++)        {            j=y1+i/k;            DrawPoint(i,j,color);        }    }    else     {        if(y1>y2)        {            i=x1;            j=y1;            x1=x2;            y1=y2;            x2=i;            y2=j;        }        if(x1!=x2)        {            k=(y2-y1)/(x2-x1);        }        else k=y2-y1+1;        for(j=y1;j<y2;j++)        {            i=x1+j/k;            DrawPoint(i,j,color);        }    }}void FullRectangle(int x1,int y1,int x2,int y2,int color){    int i;    for(i=y1;i<y2;i++)    {        DrawLine(x1,i,x2,i,color);    }}void PaintBitmap(unsigned char* pp,int x,int y,int width,int high){    int i,j,k;    printf("In PaintBitmap\n");    for(j=0;j<high;j++)    {        for(i=0;i<width;i++)        {            k=*(pp+(j*width+i)*2)<<8;            DrawPoint(i+x,j+y,k+(*(pp+(j*width+i)*2+1)));        }    }}/*void PaintBitmap_sin(unsigned char* pp,int x,int y,int width,int high,int start){    int i,j,k,l;    float ss;    printf("In PaintBitmap_sing\n");    for(j=0;j<high;j++)    {        for(i=0;i<width;i++)        {            ss=20*sin(2*(start+i)*3.1416/180);            l=ceil(ss);            k=*(pp+(j*width+i)*2)<<8;            DrawPoint(i+x,j+y+l,k+(*(pp+(j*width+i)*2+1)));        }    }}*/void Paint_Ico(int Ico_id,int x,int y){        switch(Ico_id)    {        case 0: PaintBitmap(blank,x,y,ICOWIDE,ICOHIGH);   //blue                break;        case 1: PaintBitmap(what,x,y,ICOWIDE,ICOHIGH);    //question mark                break;        case 2: PaintBitmap(warning,x,y,ICOWIDE,ICOHIGH); //Warning mark                break;        case 3: PaintBitmap(refuse,x,y,ICOWIDE,ICOHIGH);  //                break;        case 4: PaintBitmap(pen,x,y,ICOWIDE,ICOHIGH);     //pen mark                break;        case 5: PaintBitmap(wblank,x,y,ICOWIDE,ICOHIGH);   //white                break;        case 6: PaintBitmap(info,x,y,ICOWIDE,ICOHIGH);   //white                break;        default: printf("Paint ico fail\n");                 break;    }}extern void Paint_Info(int Info_id,int x,int y){     switch(Info_id)    {        case 0: PaintBitmap(enter_info,x,y,INFOWIDE,INFOHIGH);   //Too many digitals input!                break;        default: printf("Paint ico fail\n");                 break;    }}void Clean_Info(void){    FullRectangle(ICON_X1,ICON_Y1,ICON_X1+ICOWIDE+INFOWIDE+5,ICON_Y1+INFOHIGH+5,0x87ff);}void Paint_String(int String_id,int x,int y){        switch(String_id)    {        case 0: PaintBitmap(sblank,x,y,STRWIDE,STRHIGH);                break;        case 1: PaintBitmap(istr1,x,y,STRWIDE,STRHIGH);                break;        case 2: PaintBitmap(swarning,x,y,STRWIDE,STRHIGH);                break;        default: printf("Paint String fail\n");                 break;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -