minigui1.6-smdk2416 IAL引擎移植

NO IMAGE

 

minigui1.6-smdk2416 IAL引擎移植

Crosstool: arm-linux-gcc-4.4.3硬體環境:

Host:X86PC

Target:smdk2416開發板

軟體環境:

 Host:debian5

 Target:arm-linux kernel:linux-2.6.38.8

Email:[email protected] by 廈門

 

目前網格上比較多的有2各種方案

1.  Singlewolfyu (大漠孤狼)在 MiniGUI 1.3.3 移植詳解中帶螢幕校正功能的 2410 的 IAL

2. 
MiniGUI-1.6.10 tslib-1.4移植到s3c2410 linux2.6.33.2

本人試過第2種方案,編譯之後一直說找不ts_open之類相關庫檔案,由於核心觸控式螢幕的驅動採用input系統與第1種方案有所不同,且我的核心中已經移植好了tslib-1.4,校準方面採用tslib-1.4生成好的/etc/pointercal檔案,因此結合2種方案重新做了個IAL引擎

如何在MiniGUI中新增新的IAL引擎:(假設新的IAL引擎為_NAME_IAL)

1.         在ial.c檔案中新增新引擎的入口:

例如:(ial.c檔案中)

A) #ifdef _NAME _IAL

   #include “NAME.h”

   #endif

B)       在input陣列中新增

       #ifdef _NAME _IAL

       {“NAME “, InitNAMEInput, TermNAMEInput},

       #endif

2.       把新的 .c 新增到 Makefile.am 檔案中即可。

3.       修改配置檔案IAL引擎項,使用這個新的IAL引擎_NAME_IAL.

步驟一:修改SMDK2410源程式2410.c,2410.h

修改後覆蓋src/ial/2410.c 2410.h,程式見附錄

主要改wait_event這個函式

編譯發現個問題,如果是覆蓋形式則要make clean/ make distclean 再重新編譯,要編個10多分鐘,但在原有基礎上作修改,則只需要make /make install即可,不知道為何

步驟二:重新配置編譯libminigui1.6.0

編譯步驟見另一文章

http://blog.csdn.net/hebu007/article/details/6739597

步驟三:改寫配置檔案Minigui.cfg

[system]                                                                    

# GAL engine and default options                                            

gal_engine=fbcon                                                            

#gal_engine=qvfb                                                            

defaultmode=640×480-16bpp                                                   

                               

# IAL engine                   

#ial_engine=console            

ial_engine=SMDK2410        //對應2410.c      

                        

mdev=/dev/input/event0  

mtype=none              

#IMPS2               

                     

[fbcon]              

defaultmode=640×480-16bpp

                        

[qvfb]                  

defaultmode=640×480-16bpp

 

 

附錄一2410.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <fcntl.h>
#include “common.h”

#ifdef _SMDK2410_IAL

#include <sys/select.h>

#include “ial.h”
#include “2410.h”
#include <linux/input.h>

struct input_event ev0;
#define TS_DEVICE  “/dev/input/event0”
#define TS_CALIBFILE “/etc/pointercal”

#define MINX 660
#define MINY 780
#define LCD_MAX_X 640
#define LCD_MAX_Y 480
#define MOUSE_MAX_X 2745
#define MOUSE_MAX_Y 2560

typedef struct {
    unsigned short pressure;
    unsigned short x;
    unsigned short y;
    unsigned short pad;
} TS_EVENT;

static TS_EVENT ts;
static POINT lcd;
static int mouse_fd = -1;
int calibParam[7];
int lcdTimeOut = 0;

 

static int mouse_update(void)
{
 return 1;
}

static void mouse_getxy (int* x, int* y)
{
 if(lcd.x < 0)
  lcd.x = 0;
 if(lcd.x > 640)
  lcd.x = 639;

 if(lcd.y < 0)
  lcd.y = 0;
 if(lcd.y > 480)
  lcd.y = 479;

 *x = lcd.x;
 *y = lcd.y;   
}

void ts_getraw(int *x, int *y)
{
 *x = ts.x;
 *y = ts.y;   
}

static int mouse_getbutton(void)
{
 lcdTimeOut = 0;
 return (ts.pressure? IAL_MOUSE_LEFTBUTTON:0 );
}

static unsigned char pres_state = 0;

#ifdef _LITE_VERSION
static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *
except,
struct timeval *timeout)
#else
static int wait_event (int which, fd_set *in, fd_set *out, fd_set *except,
struct timeval *timeout)
#endif
{
        fd_set rfds;
        int    retvalue = 0;
         int retv;
        int    e;
       
        static int last_pressure=0;
       
        if (!in) {
                in = &rfds;
                FD_ZERO (in);
        }
       
        if ((which & IAL_MOUSEEVENT) && mouse_fd >= 0) {
                FD_SET (mouse_fd, in);
                #ifdef _LITE_VERSION
                if (mouse_fd > maxfd) maxfd = mouse_fd;
                #endif
        }
       
       
        #ifdef _LITE_VERSION
        e = select (maxfd 1, in, out, except, timeout) ;
        #else
        e = select (FD_SETSIZE, in, out, except, timeout) ;
        #endif
 if (e > 0) {
  if (mouse_fd >= 0  && FD_ISSET (mouse_fd, in) ) {
   retv = read(mouse_fd, &ev0, sizeof(struct input_event) );
   if ( retv < sizeof(struct input_event) ) return 0;
   switch(ev0.type)
   {
    case EV_ABS:
     switch(ev0.code)
     {
      case ABS_X:
       ts.x  = ev0.value;
       break;
      case ABS_Y:
       ts.y = ev0.value;
       break;
      case ABS_PRESSURE:
       if(ev0.value == 1)
       {
        pres_state = 1;
       }else
       if(ev0.value == 0)
       {
        if(pres_state == 1)pres_state = 2;
       }
       ts.pressure = ev0.value;
       break;
      default:break;
     }
     break;
    case EV_KEY:
     if(ev0.code== BTN_TOUCH && ev0.value == 0)
     {

     }
     break;
    default:break;
   }
   if(pres_state) {
    if(pres_state == 2) pres_state = 0;
    lcd.x = (calibParam[0] * ts.x calibParam[1] * ts.y calibParam[2]) / calibParam[6];
    lcd.y = (calibParam[3] * ts.x calibParam[4] * ts.y calibParam[5]) / calibParam[6];
    retvalue |= IAL_MOUSEEVENT;
   }
  }
 }
  else if (e < 0) {
                return -1;
        } 

       
        return retvalue;
}
static int wait_event1 (int which, fd_set *in, fd_set *out, fd_set *except,
  struct timeval *timeout)
{
 int retvalue = 0;
 int retv;

 retv = read(mouse_fd, &ev0, sizeof(struct input_event) );
 if ( retv < sizeof(struct input_event) ) return 0;
 switch(ev0.type)
 {
  case EV_ABS:
   switch(ev0.code)
   {
    case ABS_X:
     ts.x  = ev0.value;
     break;
    case ABS_Y:
     ts.y = ev0.value;
     break;
    case ABS_PRESSURE:
     if(ev0.value == 1)
     {
      pres_state = 1;
     }else
     if(ev0.value == 0)
     {
      if(pres_state == 1)pres_state = 2;
     }
     ts.pressure = ev0.value;
     break;
    default:break;
   }
   break;
  case EV_KEY:
   break;
  default:break;
 }
 if(!pres_state) return 0;
 if(pres_state == 2) pres_state = 0;
 lcd.x = (calibParam[0] * ts.x calibParam[1] * ts.y calibParam[2]) / calibParam[6];
 lcd.y = (calibParam[3] * ts.x calibParam[4] * ts.y calibParam[5]) / calibParam[6];
 retvalue |= IAL_MOUSEEVENT;

 return retvalue;
}

BOOL Init2410Input (INPUT* input, const char* mdev, const char* mtype)
{
 int cal_fd;
 int ret;

 mouse_fd = open (mdev, O_RDONLY);
 if (mouse_fd < 0 ) {
  fprintf (stderr, “2410: Can not open Touch Screen!\n”);
  return FALSE;
 }

 cal_fd = open(TS_CALIBFILE, O_RDWR);
 if (cal_fd < 0)
 {
  fprintf (stderr, “2410: Open touch screen calibration file error,use default!\n”);
  calibParam[0] = 354;
  calibParam[1] = -71059;
  calibParam[2] = 57310544;
  calibParam[3] = 62332;
  calibParam[4] =-563;
  calibParam[5] = -16260456;
  calibParam[6] = 65536;
 }
 else
 {
  char pcalbuf[200];
  int index = 0;
  char *tokptr;  
  ret = read(cal_fd,pcalbuf,200);
  calibParam[0] = atoi(strtok(pcalbuf,” “));
  index=1;
  while(index<7) {
   tokptr = strtok(NULL,” “);
   if(*tokptr!=’\0′) {
    calibParam[index] = atoi(tokptr);
    index ;
   }
  }

 }

 for (ret = 0; ret < 7; ret )
 {
  printf(“%d\n”, calibParam[ret]);
 }
 close(cal_fd);

 input->update_mouse = mouse_update;
 input->get_mouse_xy = mouse_getxy;
 input->set_mouse_xy = NULL;
 input->get_mouse_button = mouse_getbutton;
 input->set_mouse_range = NULL;

 input->update_keyboard = NULL;
 input->get_keyboard_state = NULL;
 input->set_leds = NULL;

 input->wait_event = wait_event;

 return TRUE;
}

void Term2410Input (void)
{
 if (mouse_fd >= 0)
  close(mouse_fd);
}

#endif /* _DUMMY_IAL */