Hi Torsten, Daniel,

To Daniel Alejandro:
Good news. Just keep trying reinserting the module and relaunching the 
application.

I attached a small file called v4l2dumper.c which is the first program i wrote to test the driver on a remote machine. Just compile it and run it as following:

$ v4l2dumper test

where test will be the prefix for all the pictures captured. So just insert the kernel driver and run this small shell program. The program will capture images for 5 seconds and write them to separate files. Those will be raw pictures (i.e without headers) and you'll have to open them using a special tool (I used Paint Shop Pro on Windows) where you'll have to specify also the pitch. It should be something between 640 and 670.

To Torsten Spindler:
It means you actually got something and LiveCam wasn't able to display it. Could you debug it? Could you check the buffer size as returned by the VIDIOC_DQBUF ioctl call?

BR,
Ilyes Gouta.

Dan¡el Alejandro Fuentes wrote:
Hi!,

here I again!
Finally, I was able to resolve my problems with the Qt libraries.
Donwload and install the kernel 2.6.24-rc3.

Rebuilding the module's branch m5602-ov9650-2 is inserted perfectly to the kernel,. But after running livecam (using stream bayer capturing) this apparently did not catch anything. The status bar displays momentarily 'Ready', and then stands displaying 'Bison Cam @ 0 FPS.'

I do not think that this will be of great help, is there any other test that may do more?

Daniel Fuentes

PD: with the kernel 2.6.18, i have the same results.


Ilyes Gouta escribió:

Hi Daniel,
Yes I suspected it. So it's a conflict between Qt versions.

Well unfortunately no, I'm not aware of any other application that's able to display raw bayer streams. Could you get access to a Fedora machine and test the stuff on it? There is another point. The driver is supposed to be compiled for 2.6.24-rc kernels and not for the old 2.6.18. I think the developers have also updated the V4L2 API meanwhile along with a hefty bunch of fixes for the USB stack.

BR,
Ilyes Gouta.

Dan¡el Alejandro Fuentes wrote:
Hi,

my system is a Debian etch, with kernel 2.6.18.
I am not entirely sure, but I think my version of Qt is 4.2 (at least, is the version are be showing in the Qt's libraries in /usr/lib).
However, livecam appears to be compiled and linked with qt 3.3.7.

I installed libraries (from the repositories of Debian) with debugging symbols, and gdb throws me:
     35          QApplication App(argc, argv);
   (gdb) next

   Program received signal SIGFPE, Arithmetic exception.
   0xb795dd05 in create_dpis () at kernel/qpaintdevice_x11.cpp:531
531 kernel/qpaintdevice_x11.cpp: No existe el fichero o el directorio.
           in kernel/qpaintdevice_x11.cpp

So you reason, the problem is in my Qt libraries.
I will continue to seek a solution, meanwhile
Is this the driver in a position to be tested with another application? (for instance: xawtv)

Daniel

Ilyes Gouta escribió:

Hi Daniel,

I've never seen this kind of errors in Qt or LiveCam. Can you provide me with more details concerning your machine, OS, etc. Can you get exactly the instruction where the program crashes? (for example in gdb, you can do: disass 0xb78ebd00 0xb78ebd10 to disassemble the machine code). 0xb78ebd05 is in the destructor of QPaintDevice and that's rather strange... Could you try to update your Qt library?

BR,
Ilyes Gouta.

Dan¡el Alejandro Fuentes wrote:
Hi,

after updating and compiling (configure && make && make install),
I can't execute livecam (Exception floating point).
I do't have experience using gdb, he give me:

   (gdb) start -dograb
   Breakpoint 1 at 0x804e566: file main.cpp, line 36.
Starting program: /home/daniel/proyectos/livecam/trunk/livecam -dograb
   [Thread debugging using libthread_db enabled]
   [New Thread -1233844544 (LWP 15859)]
   [Switching to Thread -1233844544 (LWP 15859)]
   main (argc=2, argv=0xbfe0b5b4) at main.cpp:36
   36          V4L2Viewer Viewer;
   (gdb) next
   33      int main(int argc, char **argv)
   (gdb) next
   35          QApplication App(argc, argv);
    gdb) next
   33      int main(int argc, char **argv)
   (gdb) next
   35          QApplication App(argc, argv);
   (gdb) next
     Program received signal SIGFPE, Arithmetic exception.
0xb78ebd05 in QPaintDevice::~QPaintDevice () from /usr/lib/libqt-mt.so.3
   (gdb) info line
Line 35 of "main.cpp" starts at address 0x804e56f <main+31> and ends at 0x804e572 <main+34>.

Moreover, the branch m5602-ov9560-2, compiles and inserted correctly.
Runing dmesg:

m560x/branches/m5602-ov9650-2/m5602.c: usb_m5602_init - WebCam driver startup
   m560x/branches/m5602-ov9650-2/m5602.c: BisonCam webcam found.
m560x/branches/m5602-ov9650-2/m5602.c: [usb_m5602_probe:871] cam cc788000 m560x/branches/m5602-ov9650-2/m5602.c: [m5602_initialize_camera:253] m5602_initialize_camera m560x/branches/m5602-ov9650-2/m5602.c: m5602_probe - m5602 WebCam driver is now controlling video device 0
   usbcore: registered new driver m5602
   m560x/branches/m5602-ov9650-2/m5602.c: 0.1.0:M5602 Webcam Driver

Daniel Fuentes

Ilyes Gouta escribió:
Hi Fellow,

I updated the m5602-ov9560-2 and livecam branches yesterday and I was wondering if you guys could give it a shot just to see if you can get something (using livecam, bayer stream only) from your sensors.

Just to recall it a bit, you can check out your livecam from the following URL:

https://livecam.svn.sourceforge.net/svnroot/livecam/trunk

LiveCam has the ability to alter the pitch of the pictures on the fly. The option is available through Debug | Adjust Pitch, from the application's menu.

Waiting for your reports.

BR,
Ilyes Gouta.

------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
M560x-driver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/m560x-driver-devel



__________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas




__________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas




__________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas


/***************************************************************************
 *   Copyright (C) 2006 by Ilyes Gouta                                     *
 *   [EMAIL PROTECTED]                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>

#include <sys/time.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>

#undef __STRICT_ANSI__
#include <linux/types.h>
#include <linux/videodev2.h>

#include <pthread.h>

#define CAPTURE_BUFFERS 32

static int fd;
static volatile int bCapture;
static pthread_t hThread;

static struct v4l2_buffer *pBuffers;
static struct v4l2_format fmt;
static unsigned char **pRawData;

static char* pFNPrefix;

void* WorkerThread(void* pData)
{
    struct v4l2_buffer buffer;
    struct timespec req, rem;
    char filename[256];
    int count = 0;
    FILE *hFile;

    while (bCapture)
    {
        buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        if (ioctl(fd, VIDIOC_DQBUF, &buffer) >= 0)
        {
            sprintf(filename, "%s%d.raw", pFNPrefix, count);
            printf("dumping frame %d (buffer index: %d) in %s\n", count, 
buffer.index, filename);
        
            hFile = fopen(filename, "wb");
            fwrite(pRawData[buffer.index], 1, fmt.fmt.pix.sizeimage, hFile);
            fclose(hFile);
        
            count++;
            if (!bCapture) break;
        
            buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
            ioctl(fd, VIDIOC_QBUF, &buffer);
        } else {
            printf("VIDIOC_DQBUF failed.\n");
        }

        /* wait for 30 ms */
        req.tv_sec = 0;
        req.tv_nsec = 33000000;
        nanosleep(&req, &rem);
    }

    return NULL;
}

void initialize()
{
    fd = -1;
    pBuffers = (struct v4l2_buffer*)malloc(CAPTURE_BUFFERS * sizeof(struct 
v4l2_buffer));
    pRawData = (unsigned char**)malloc(CAPTURE_BUFFERS * sizeof(unsigned 
char*));
}

void finalize()
{
    if (pBuffers) free(pBuffers);
    if (pRawData) free(pRawData);
    
    pBuffers = NULL;
    pRawData = NULL;
}

int start(char* devname)
{
    struct v4l2_capability caps;
    struct v4l2_requestbuffers request;
    int i, type, result;

    fd = open(devname, O_RDWR);
    if (fd == -1) return 0;

    if (ioctl(fd, VIDIOC_QUERYCAP, &caps) == -1) {
        close(fd); fd = -1;
        return 0;
    }

    printf("device name: %s\n", (char*)caps.card);

    if (!(caps.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
        close(fd); fd = -1;
        printf("device doesn't support V4L2.\n");
        return 0;
    }

    fcntl(fd, F_SETFD, FD_CLOEXEC);
    
    fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    fmt.fmt.pix.width = 640;
    fmt.fmt.pix.height = 480;
    fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SBGGR8;
        
    result = ioctl(fd, VIDIOC_TRY_FMT, &fmt);
    if (result < 0) {
        printf("VIDIOC_TRY_FMT failed.\n");
    }
    
    printf("picture size: %d\n", fmt.fmt.pix.sizeimage);

    /* set the capture format */
    if (ioctl(fd, VIDIOC_S_FMT, &fmt) == -1) {
        close(fd); fd = -1;
        printf("device doesn't support this capture format.\n");
        return 0;
    }

    memset(&request, 0, sizeof(struct v4l2_requestbuffers));

    request.count = CAPTURE_BUFFERS;
    request.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    request.memory = V4L2_MEMORY_MMAP;

    /* set the type of the capture */
    if (ioctl(fd, VIDIOC_REQBUFS, &request) == -1) {
        close(fd); fd = -1;
        printf("VIDIOC_REQBUFS failed.\n");
        return 0;
    }

    for (i = 0; i < CAPTURE_BUFFERS; i++)
    {
        memset(&pBuffers[i], 0, sizeof(struct v4l2_buffer));

        pBuffers[i].index  = i;
        pBuffers[i].type   = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        pBuffers[i].memory = V4L2_MEMORY_MMAP;

        if (ioctl(fd, VIDIOC_QUERYBUF, &pBuffers[i], 0)) {
            close(fd); fd = -1;
            printf("VIDIOC_QUERYBUF failed.\n");
            return 0;
        }

        /* obtain a userspace pointer on the capture buffer */
        void *pData = mmap(NULL, pBuffers[i].length, PROT_READ | PROT_WRITE, 
MAP_SHARED, fd, pBuffers[i].m.offset);
        if (pData == (void*)-1) {
            close(fd); fd = -1;
            printf("mmap failed. buffer length: %d, offset:0x%x\n", 
pBuffers[i].length, pBuffers[i].m.offset);
            return 0;
        }

        pRawData[i] = (unsigned char*)pData;
    }

    /* queue the buffers for capture*/
    for (i = 0; i < CAPTURE_BUFFERS; i++) {
        ioctl(fd, VIDIOC_QBUF, &pBuffers[i]);
    }
    
    /* start the capture */
    type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    if (ioctl(fd, VIDIOC_STREAMON, &type) == -1) {
        close(fd); fd = -1;
        printf("failed starting capture.\n");
        return 0;
    }

    bCapture = 1;
    if (pthread_create(&hThread, NULL, WorkerThread, NULL)) {
        close(fd); fd = -1;
        return 0;
    }

    return 1;
}

void stop()
{
    if (fd == -1) return;

    bCapture = 0;

    /* stop the capture */
    int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    ioctl(fd, VIDIOC_STREAMOFF, &type);

    pthread_join(hThread, NULL);
    close(fd); fd = -1;
}

int main(int argc, char** argv)
{
   if (argc != 2) {
      printf("usage:\n\t$ v4l2dumper <filename prefix>\n");
      return 0;
   }
   
   pFNPrefix = argv[1];
   
   initialize();
   
   if (start("/dev/video0")) {
        sleep(3);
        stop();
   }
   
   finalize();
   return 0;
}
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
M560x-driver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/m560x-driver-devel

Reply via email to