~ubuntu-branches/ubuntu/intrepid/amsn/intrepid

« back to all changes in this revision

Viewing changes to utils/linux/capture/libng/plugins/drv0-v4l2.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2008-01-10 04:59:52 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080110045952-qc023vcuh3t40omr
Tags: 0.97+final-0ubuntu1
* Fake sync with debian due to version issue (LP: #179008)
  - Use Tcl8.5 and antialiased text (LP: #157839)
* Modify Maintainer value to match the DebianMaintainerField
  specification.
* debian/rules: .desktop file already moved in the correct path

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <sys/mman.h>
23
23
#include <pthread.h>
24
24
 
 
25
#ifdef HAVE_SYS_VIDEODEV2_H /* Solaris */
 
26
#include <sys/videodev2.h>
 
27
#define MAJOR_NUM 188
 
28
#else /* Linux */
25
29
#include <asm/types.h>          /* XXX glibc */
26
30
#include "videodev2.h"
 
31
#define MAJOR_NUM 81
 
32
#endif
27
33
 
28
34
#include "grab-ng.h"
29
35
 
173
179
    [ VIDEO_JPEG ]     = V4L2_PIX_FMT_JPEG,
174
180
    [ VIDEO_MJPEG ]    = V4L2_PIX_FMT_MJPEG,
175
181
//    [ VIDEO_MPEG ]     = V4L2_PIX_FMT_MPEG, // MPEG is supported in a different way
 
182
#ifdef V4L2_PIX_FMT_BA81
176
183
        [ VIDEO_BAYER ]         = V4L2_PIX_FMT_BA81,
 
184
#endif
 
185
#ifdef V4L2_PIX_FMT_S910
177
186
        [ VIDEO_S910 ]          = V4L2_PIX_FMT_S910,
 
187
#endif
178
188
};
179
189
 
180
190
static struct STRTAB stereo[] = {
236
246
        if (-1 == xioctl(h->fd, VIDIOC_ENUMINPUT, &h->inp[h->ninputs], EINVAL))
237
247
            break;
238
248
    }
 
249
/* This crashes on Solaris for an unknown reason. */
 
250
#ifndef __sun
239
251
    for (h->nstds = 0; h->nstds < MAX_NORM; h->nstds++) {
240
252
        h->std[h->nstds].index = h->nstds;
241
253
        if (-1 == xioctl(h->fd, VIDIOC_ENUMSTD, &h->std[h->nstds], EINVAL))
242
254
            break;
243
255
    }
 
256
#endif
244
257
    for (h->nfmts = 0; h->nfmts < MAX_FORMAT; h->nfmts++) {
245
258
        h->fmt[h->nfmts].index = h->nfmts;
246
259
        h->fmt[h->nfmts].type  = V4L2_BUF_TYPE_VIDEO_CAPTURE;
481
494
    if (ng_debug)
482
495
        fprintf(stderr, "v4l2: open\n");
483
496
    BUG_ON(h->fd != -1,"device is open");
484
 
    h->fd = ng_chardev_open(h->device, O_RDWR, 81, 1);
 
497
    h->fd = ng_chardev_open(h->device, O_RDWR, MAJOR_NUM, 1);
485
498
    if (-1 == h->fd)
486
499
        return -1;
487
500
    if (-1 == xioctl(h->fd,VIDIOC_QUERYCAP,&h->cap,EINVAL)) {
609
622
    n = 0;
610
623
    for (i = 0; NULL != ng_dev.video_scan[i]; i++) {
611
624
        fd = ng_chardev_open(ng_dev.video_scan[i], O_RDONLY | O_NONBLOCK,
612
 
                             81, verbose);
 
625
                             MAJOR_NUM, verbose);
613
626
        if (-1 == fd)
614
627
            continue;
615
628
        if (-1 == xioctl(fd,VIDIOC_QUERYCAP,&cap,EINVAL)) {
867
880
    /* PWC doesn't respect V4L2 standard and modifies length field we must keep it */
868
881
    __u32 length;
869
882
    
 
883
/*
 
884
 * Do not call select() on Solaris.  This code can likely be removed for
 
885
 * all systems, as the V4L2 specification states that VIDIOC_DQBUF will block
 
886
 * unless O_NONBLOCK was used in open().  We do not use O_NONBLOCK.
 
887
 */
 
888
#ifndef __sun
870
889
    /* wait for the next frame */
871
890
 again:
872
891
    tv.tv_sec  = 5;
883
902
        fprintf(stderr,"v4l2: oops: select timeout\n");
884
903
        return -1;
885
904
    }
 
905
#endif
886
906
 
887
907
    /* get it */
888
908
    memset(&buf,0,sizeof(buf));
1099
1119
    } else {
1100
1120
        buf = ng_malloc_video_buf(NULL, &h->fmt_me);
1101
1121
        rc = read(h->fd,buf->data,buf->size);
1102
 
        if (rc != buf->size) {
1103
 
            if (-1 == rc) {
1104
 
                perror("v4l2: read");
1105
 
            } else {
1106
 
                fprintf(stderr, "v4l2: read: rc=%d/size=%ld\n",rc,buf->size);
1107
 
            }
1108
 
            ng_release_video_buf(buf);
1109
 
            return NULL;
 
1122
        if (rc < 0) {
 
1123
          perror("v4l2: read");
 
1124
          ng_release_video_buf(buf);
 
1125
          return NULL;
1110
1126
        }
1111
1127
        memset(&buf->info,0,sizeof(buf->info));
1112
1128
        buf->info.ts = ng_get_timestamp();