Index: /trunk/lib/FlairSensorActuator/src/V4LCamera.cpp
===================================================================
--- /trunk/lib/FlairSensorActuator/src/V4LCamera.cpp	(revision 350)
+++ /trunk/lib/FlairSensorActuator/src/V4LCamera.cpp	(revision 351)
@@ -24,5 +24,5 @@
 #include <FrameworkManager.h>
 #include <fcntl.h>
-#include <linux/videodev2.h>
+//#include <linux/videodev2.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
@@ -40,5 +40,5 @@
 V4LCamera::V4LCamera(string name,uint8_t camera_index, uint16_t width, uint16_t height,
                      Image::Type::Format format, uint8_t priority)
-    : Thread(getFrameworkManager(), name, priority,1024*1024),
+    : Thread(getFrameworkManager(), name, priority),
       Camera(name, width, height, format) {
   
@@ -63,6 +63,11 @@
   }
   
-  dQueuedBuffer.index=-1;//mark current buffer not valid for initialisation
+  //todo: better handling of detection, only neeeded for omap/dm
+  //also in run, copy from v4l to cmem is not necessary if not using cmem...
+#ifdef ARMV7A
+  useMemoryUsrPtr=true;
+#else
   useMemoryUsrPtr=false;
+#endif
   if(useMemoryUsrPtr) {
     AllocUserBuffers();
@@ -153,96 +158,4 @@
 }
 
-/*
-void V4LCamera::Run(void) {
-  Time cam_time, new_time, fpsNow, fpsPrev;
-  int fpsCounter = 0;
-
-  // init image old
-  GrabFrame();
-  cam_time = GetTime();
-  fpsPrev = cam_time;
-
-  while (!ToBeStopped()) {
-    //check for ps3eye deconnection in hds uav
-    if(hasProblems==false) {
-      struct v4l2_format form;
-      form.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-      xioctl(device, VIDIOC_G_FMT,&form);
-      if(xioctl (device, VIDIOC_G_FMT,&form)<0) {
-        Thread::Warn("camera disconnected\n");
-        hasProblems=true;
-      }
-    }
-    
-    // fps counter
-    fpsCounter++;
-    if (GetTime() > (fpsPrev + 5 * (Time)1000000000)) {
-      // every 5 secondes
-      fpsNow = GetTime();
-      fps->SetText("fps: %.1f",
-      fpsCounter / ((float)(fpsNow - fpsPrev) / 1000000000.));
-      fpsCounter = 0;
-      fpsPrev = fpsNow;
-    } 
-    
-    // cam properties
-    if (gain->ValueChanged() == true && autogain->Value() == false)
-      SetGain(gain->Value());
-    if (exposure->ValueChanged() == true && autoexposure->Value() == false)
-      SetExposure(exposure->Value());
-    if (bright->ValueChanged() == true)
-      SetBrightness(bright->Value());
-    if (sat->ValueChanged() == true)
-      SetSaturation(sat->Value());
-    if (contrast->ValueChanged() == true)
-      SetContrast(contrast->Value());
-    if (hue->ValueChanged() == true)
-      SetHue(hue->Value());
-    if (sharpness->ValueChanged() == true)
-      SetProperty(V4L2_CID_SHARPNESS, sharpness->Value());
-    if (autogain->ValueChanged() == true) {
-      if (autogain->Value() == true) {
-        gain->setEnabled(false);
-      } else {
-        gain->setEnabled(true);
-        SetGain(gain->Value());
-      }
-      SetAutoGain(autogain->Value());
-    }
-    if (autoexposure->ValueChanged() == true) {
-      if (autoexposure->Value() == true) {
-        exposure->setEnabled(false);
-      } else {
-        exposure->setEnabled(true);
-        SetExposure(exposure->Value());
-      }
-      SetAutoExposure(autoexposure->Value());
-    }
-    if (awb->ValueChanged() == true)
-      SetProperty(V4L2_CID_AUTO_WHITE_BALANCE, awb->Value());
-
-    // get picture
-    GrabFrame();
-    new_time = GetTime();
-    
-    //check for ps3eye deconnection in hds uav
-    if(new_time-cam_time>100*1000*1000) {
-      Thread::Warn("delta trop grand\n");
-      hasProblems=true;
-    }
-
-    output->GetMutex();
-    output->buffer=(char*)buffers[bufferIndex].start;
-    output->ReleaseMutex();
-
-    output->SetDataTime(cam_time);
-    ProcessUpdate(output);
-
-    cam_time = new_time;
-  }
-
-  close(device);
-}
-*/
 int V4LCamera::AllocV4LBuffers() {
   struct v4l2_requestbuffers req;
@@ -304,5 +217,5 @@
   //allocate output data
   imageData = AllocFunction(output->GetDataType().GetSize());
-  Printf("cmem allocated %i at %x\n",output->GetDataType().GetSize(),imageData);
+  //Printf("cmem allocated %i at %x\n",output->GetDataType().GetSize(),imageData);
 
   return 1;
@@ -333,65 +246,6 @@
   return 1;
 };
-/*
+
 int V4LCamera::GrabFrame(void) {
-    //queue previous buffer
-    if(QueueBuffer(bufferIndex)<0) return -1;
-   
-    fd_set fds;
-    struct timeval tv;
-    FD_ZERO (&fds);
-    FD_SET (device, &fds);
-
-    tv.tv_sec = 0;
-    tv.tv_usec = 100000;
-
-    int r = select (device+1, &fds, NULL, NULL, &tv);
-
-    if (-1 == r) {
-        char errorMsg[256];
-        Thread::Err("select (%s)\n", strerror_r(-r, errorMsg, sizeof(errorMsg)));
-        return -1;
-    }
-
-    if (0 == r) {
-        Thread::Err("select timeout\n");
-        return -1;
-    }
-
-    struct v4l2_buffer buf;
-    memset(&buf, 0, sizeof (v4l2_buffer));
-    buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-    buf.memory = V4L2_MEMORY_USERPTR;//V4L2_MEMORY_MMAP;
-
-    //get last captured image
-    int prevDQbuf=-1;
-    for(int i=0;i<nbBuffers;i++) {
-        if (xioctl (device, VIDIOC_DQBUF, &buf)==-1) {
-            if (errno==EAGAIN) {
-                break;
-            } else {
-                Thread::Err("VIDIOC_DQBUF xioctl\n");
-                return -1;
-            }
-       } else {
-           if(prevDQbuf!=-1) {
-               QueueBuffer(prevDQbuf);
-           }
-           for (int i=0; i<nbBuffers; i++) {
-               if((void*)(buf.m.userptr)==buffers[i]) {
-                   prevDQbuf=i;
-                   bufferIndex=i;
-                   break;
-               }
-           }
-       }
-    }
-   
-   return 1;
-}
-*/
-int V4LCamera::cvGrabFrame(void) {
-  if(QueueBuffer(&dQueuedBuffer)<0) return -1;
-    
   fd_set fds;
   struct timeval tv;
@@ -424,5 +278,5 @@
   }
 
-   //get last captured image
+   //get last captured buffer
   dQueuedBuffer.index=-1;
   for(int i=0;i<nbBuffers;i++) {
@@ -505,11 +359,6 @@
    
     // cam pictures
-    if (!cvGrabFrame()) {
+    if (!GrabFrame()) {
       Printf("Could not grab a frame\n");
-    }
-    
-    //copy to CMEM allocated buffer if necessary
-    if(!useMemoryUsrPtr) {
-      memcpy(imageData,(char *)buffers[dQueuedBuffer.index],output->GetDataType().GetSize());
     }
         
@@ -530,4 +379,13 @@
     }*/
 
+    //select buffer
+    if(useMemoryUsrPtr) {//buffers are already in CMEM
+      imageData=(char*)buffers[dQueuedBuffer.index];
+      //dequeue it latter (buffer used by ProcessUpdate)
+    } else {//copy to CMEM allocated buffer 
+      memcpy(imageData,(char *)buffers[dQueuedBuffer.index],output->GetDataType().GetSize());
+      QueueBuffer(&dQueuedBuffer);//we can do it right now
+    }
+    
     output->GetMutex();
     output->buffer=imageData;
@@ -537,4 +395,8 @@
     ProcessUpdate(output);
     cam_time = new_time;
+    
+    if(useMemoryUsrPtr) {
+      QueueBuffer(&dQueuedBuffer);//now it is possible to dequeue
+    }
   }
 }
Index: /trunk/lib/FlairSensorActuator/src/V4LCamera.h
===================================================================
--- /trunk/lib/FlairSensorActuator/src/V4LCamera.h	(revision 350)
+++ /trunk/lib/FlairSensorActuator/src/V4LCamera.h	(revision 351)
@@ -157,5 +157,5 @@
   void SetProperty(int property,float value);
   float GetProperty(int property);
-  //int GrabFrame(void);
+  int GrabFrame(void);
   int AllocV4LBuffers(void);
   int AllocUserBuffers(void);
@@ -163,10 +163,4 @@
   int QueueBuffer(struct v4l2_buffer *buf);
   struct v4l2_buffer dQueuedBuffer;
-  
-
-int cvGrabFrame(void);
-
-
-
 };
 } // end namespace sensor
