This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/xawtv3.git tree:

Subject: Add an option on apps to select between libv4l and v4l2 driver
Author:  Dmitry Butskoy <[email protected]>
Date:    Tue Feb 15 14:12:01 2011 -0300

Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 console/fbtv.c       |   36 +++++-----------
 console/scantv.c     |   22 ++++++----
 console/streamer.c   |   18 +++++---
 console/ttv.c        |   16 ++++---
 console/webcam.c     |   86 +++++++++++++++++++------------------
 libng/devices.c      |   15 ++++---
 libng/devices.h      |    1 +
 libng/grab-ng.c      |   64 +++++++++++++++++-----------
 man/fbtv.1           |    3 +
 man/motv.1           |   10 ++++-
 man/scantv.1         |    3 +
 man/ttv.1            |    3 +
 man/webcam.1         |   11 +++--
 man/xawtv-remote.1   |    3 +
 man/xawtv.1          |   10 ++++-
 todo/tmohan/webcam.c |   10 +++--
 x11/v4lctl.c         |    8 +++-
 x11/xt.c             |  113 ++++++++++++++++++++++++-------------------------
 18 files changed, 238 insertions(+), 194 deletions(-)

---

http://git.linuxtv.org/xawtv3.git?a=commitdiff;h=2c685bb3d7be1f139af8b6973f76afff65640e9f

diff --git a/console/fbtv.c b/console/fbtv.c
index 015abd6..2b63b3b 100644
--- a/console/fbtv.c
+++ b/console/fbtv.c
@@ -48,11 +48,6 @@
 #define MIN(x,y)        ((x)<(y)?(x):(y))
 
 /* ---------------------------------------------------------------------- */
-/* video plugin                                                           */
-static int libv4l = 1;
-static int v4l2 = 0;
-
-/* ---------------------------------------------------------------------- */
 /* framebuffer                                                            */
 
 static char  *fbdev    = NULL;
@@ -240,7 +235,7 @@ fb_initcolors(int fd, int gray)
        if (-1 == ioctl(fd,FBIOGETCMAP,&cmap))
            perror("ioctl FBIOGETCMAP");
     }
-    
+
     switch (fb_var.bits_per_pixel) {
     case 8:
        if (gray) {
@@ -324,10 +319,10 @@ text_init(char *font)
     char   *fonts[2] = { font, NULL };
 
     if (NULL == f)
-        f = fs_consolefont(font ? fonts : NULL);
+       f = fs_consolefont(font ? fonts : NULL);
     if (NULL == f) {
-        fprintf(stderr,"no font available\n");
-        exit(1);
+       fprintf(stderr,"no font available\n");
+       exit(1);
     }
 }
 
@@ -419,7 +414,7 @@ static void do_capture(int from, int to, int tmp_switch)
        }
        dx += (fb_var.xres-24-fmt.width)/2;
        dy += (fb_var.yres-16-fmt.height)/2;
-       
+
        if (f_drv & CAN_CAPTURE)
            drv->startvideo(h_drv,-1,2);
        break;
@@ -531,13 +526,7 @@ grabber_init(void)
     screen.height       = fb_var.yres_virtual;
     screen.bytesperline = fb_fix.line_length;
 
-    if (libv4l)
-       drv = ng_vid_open(ng_dev.video, "libv4l", &screen, 0, &h_drv);
-    if (v4l2 && !drv)
-       drv = ng_vid_open(ng_dev.video, "v4l2", &screen, 0, &h_drv);
-
-    if (!drv)
-       drv = ng_vid_open(ng_dev.video,NULL,&screen,0,&h_drv);
+    drv = ng_vid_open(ng_dev.video, ng_dev.driver, &screen, 0, &h_drv);
     if (NULL == drv) {
        fprintf(stderr,"no grabber device available\n");
        exit(1);
@@ -558,7 +547,7 @@ console_switch(void)
        break;
     case FB_ACQ_REQ:
        switch_last = fb_switch_state;
-        fb_switch_acquire();
+       fb_switch_acquire();
        fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
        ioctl(fb,FBIOPAN_DISPLAY,&fb_var);
        do_va_cmd(2,"capture","on");
@@ -613,14 +602,10 @@ main(int argc, char *argv[])
     ng_init();
     for (;;) {
        double val;
-       c = getopt(argc, argv, "Mgvqxk2d:o:s:c:f:m:z:t:j:");
+       c = getopt(argc, argv, "Mgvqxk2d:o:s:c:f:m:z:t:j:D:");
        if (c == -1)
            break;
        switch (c) {
-       case '2':
-           v4l2 = 1;
-           libv4l = 0;
-           break;
        case 'z':
            if(sscanf(optarg, "%lf", &val) == 1) {
                if(val < 0.1 || val > 10)
@@ -667,6 +652,9 @@ main(int argc, char *argv[])
            strcat(ng_v4l_conf," -c ");
            strcat(ng_v4l_conf,ng_dev.video);
            break;
+       case 'D':
+           ng_dev.driver = optarg;
+           break;
        case 't':
            if (optarg)
                vt = strtoul(optarg, 0, 0);
@@ -695,7 +683,7 @@ main(int argc, char *argv[])
            matrox = 0;
     if (matrox)
        strcat(ng_v4l_conf," -y ");
-    
+
     grabber_init();
     freq_init();
     read_config(NULL,NULL,NULL);
diff --git a/console/scantv.c b/console/scantv.c
index 5d96772..5215102 100644
--- a/console/scantv.c
+++ b/console/scantv.c
@@ -34,7 +34,7 @@ char *tvname;
 static void
 grabber_init(void)
 {
-    drv = ng_vid_open(ng_dev.video,NULL,NULL,0,&h_drv);
+    drv = ng_vid_open(ng_dev.video,ng_dev.driver,NULL,0,&h_drv);
     if (NULL == drv) {
        fprintf(stderr,"no grabber device available\n");
        exit(1);
@@ -68,10 +68,10 @@ get_vbi_name(struct vbi_state *vbi)
     start = time(NULL);
     for (;;) {
        vbi_hasdata(vbi);
-        if (time(NULL) > start+timeout)
-            break;
-        if (tvname)
-            break;
+       if (time(NULL) > start+timeout)
+           break;
+       if (tvname)
+           break;
     }
     return tvname;
 }
@@ -121,12 +121,13 @@ usage(FILE *out, char *prog, char *outfile)
            "   -f table     set frequency table.\n"
            "   -c device    set video device file.  [%s]\n"
            "   -C device    set vbi device file.    [%s]\n"
+           "   -D driver    set video driver.       [%s]\n"
            "   -s           skip channel scan\n"
            "   -a           full scan (all frequencies, not just\n"
            "                the ones from the frequency table)\n",
            prog,
            outfile ? outfile : "stdout",
-           ng_dev.video, ng_dev.vbi);
+           ng_dev.video, ng_dev.vbi, ng_dev.driver);
 }
 
 int
@@ -146,7 +147,7 @@ main(int argc, char **argv)
     /* parse options */
     ng_init();
     for (;;) {
-       if (-1 == (c = getopt(argc, argv, "hsadi:n:f:o:c:C:")))
+       if (-1 == (c = getopt(argc, argv, "hsadi:n:f:o:c:C:D:")))
            break;
        switch (c) {
        case 'd':
@@ -176,6 +177,9 @@ main(int argc, char **argv)
        case 'C':
            ng_dev.vbi = optarg;
            break;
+       case 'D':
+           ng_dev.driver = optarg;
+           break;
        case 'h':
            usage(stdout,argv[0],outfile);
            exit(0);
@@ -239,7 +243,7 @@ main(int argc, char **argv)
        exit(1);
     }
     vbi_event_handler_add(vbi->dec,~0,event,vbi);
-    
+
     if (!fullscan) {
        /* scan channels */
        fprintf(stderr,"\nscanning channel list %s...\n",
@@ -312,7 +316,7 @@ main(int argc, char **argv)
            fprintf(stderr,"=> %6.2f MHz (%-4s): ", fc/16.0,
                    (-1 != fi) ? chanlist[fi].name : "-");
            drv->setfreq(h_drv,fc);
-           
+
            name = get_vbi_name(vbi);
            fprintf(stderr,"%s\n",name ? name : "???");
            if (NULL == name) {
diff --git a/console/streamer.c b/console/streamer.c
index 1759403..4797616 100644
--- a/console/streamer.c
+++ b/console/streamer.c
@@ -69,7 +69,7 @@ list_formats(FILE *out)
     struct list_head *item;
     const struct ng_writer *wr;
     int j;
-    
+
     fprintf(out,"\nmovie writers:\n");
     list_for_each(item,&ng_writers) {
        wr = list_entry(item, struct ng_writer, list);
@@ -116,6 +116,7 @@ usage(FILE *out)
            "  -o file     video/movie file name\n"
            "  -f format   specify video format\n"
            "  -c device   specify video4linux device   [%s]\n"
+           "  -D driver   specify video4linux driver   [%s]\n"
            "  -r fps      frame rate                   [%d.%03d]\n"
            "  -s size     specify size                 [%dx%d]\n"
            "\n"
@@ -132,9 +133,9 @@ usage(FILE *out)
            "  -C device   specify dsp device           [%s]\n"
            "  -R rate     sample rate                  [%d]\n"
            "\n",
-           
+
            parallel,wait_seconds,
-           ng_dev.video, fps/1000, fps%1000,
+           ng_dev.video, ng_dev.driver, fps/1000, fps%1000,
            video.width, video.height,
            absframes, bufcount, ng_jpeg_quality,
            ng_dev.dsp, audio.rate
@@ -333,7 +334,7 @@ main(int argc, char **argv)
     ng_init();
     for (;;) {
        if (-1 == (c = getopt(argc, argv, "haqdp:w:"
-                             "o:c:f:r:s:t:n:i:b:j:" "O:C:F:R:")))
+                             "o:c:f:r:s:t:n:i:b:j:D:" "O:C:F:R:")))
            break;
        switch (c) {
            /* general options */
@@ -364,6 +365,9 @@ main(int argc, char **argv)
        case 'c':
            ng_dev.video = optarg;
            break;
+       case 'D':
+           ng_dev.driver = optarg;
+           break;
        case 'r':
            fps = (int)(atof(optarg) * 1000 + 0.5);
            break;
@@ -371,7 +375,7 @@ main(int argc, char **argv)
            if (2 != sscanf(optarg,"%dx%d",&video.width,&video.height))
                video.width = video.height = 0;
            break;
-           
+
        case 't':
            raw_length = optarg;
            break;
@@ -438,7 +442,7 @@ main(int argc, char **argv)
                ng_vfmt_to_desc[video.fmtid],ng_afmt_to_desc[audio.fmtid]);
 
     if (video.fmtid != VIDEO_NONE) {
-       drv = ng_vid_open(ng_dev.video,NULL,NULL,0,&h_drv);
+       drv = ng_vid_open(ng_dev.video,ng_dev.driver,NULL,0,&h_drv);
        if (NULL == drv) {
            fprintf(stderr,"no grabber device available\n");
            exit(1);
@@ -459,7 +463,7 @@ main(int argc, char **argv)
        if (tvnorm != NULL)
            do_va_cmd(2,"setnorm",tvnorm);
     }
-       
+
     /* init movie writer */
     ng_ratio_x = video.width;
     ng_ratio_y = video.height;
diff --git a/console/ttv.c b/console/ttv.c
index 89ad6e5..41cf308 100644
--- a/console/ttv.c
+++ b/console/ttv.c
@@ -36,7 +36,7 @@ static int fast;
 static void
 grabber_init(void)
 {
-    drv = ng_vid_open(ng_dev.video,NULL,NULL,0,&h_drv);
+    drv = ng_vid_open(ng_dev.video,ng_dev.driver,NULL,0,&h_drv);
     if (NULL == drv) {
        fprintf(stderr,"no grabber device available\n");
        exit(1);
@@ -154,10 +154,11 @@ usage(void)
           "  -h             print this text\n"
           "  -f             use fast aalib render function\n"
           "  -c <device>    video device [%s]\n"
+          "  -D <driver>    video driver [%s]\n"
           "\n"
           "aalib options:\n"
           "%s",
-          ng_dev.video,aa_help);
+          ng_dev.video,ng_dev.driver,aa_help);
     exit(1);
 }
 
@@ -176,7 +177,7 @@ main(int argc, char **argv)
     if (!aa_parseoptions (&params, &render, &argc, argv))
        usage();
     for (;;) {
-       c = getopt(argc, argv, "vfhc:");
+       c = getopt(argc, argv, "vfhc:D:");
        if (c == -1)
            break;
        switch (c) {
@@ -190,6 +191,9 @@ main(int argc, char **argv)
        case 'c':
            ng_dev.video = optarg;
            break;
+       case 'D':
+           ng_dev.driver = optarg;
+           break;
        case 'h':
        default:
            usage();
@@ -234,7 +238,7 @@ main(int argc, char **argv)
     /* build channel list */
     parse_config();
     do_va_cmd(2,"setfreqtab",(-1 != chantab)
-              ? chanlist_names[chantab].str : "europe-west");
+             ? chanlist_names[chantab].str : "europe-west");
     cur_capture = 0;
     do_va_cmd(2,"capture","grabdisplay");
     if (optind+1 == argc) {
@@ -254,7 +258,7 @@ main(int argc, char **argv)
                set_defaults();
        }
     }
-    
+
     /* catch ^C */
     signal(SIGINT,ctrlc);
     signal(SIGTERM,ctrlc);
@@ -273,7 +277,7 @@ main(int argc, char **argv)
            last = now;
            frames = 0;
        }
-       
+
        /* grab + convert frame */
        if (NULL == (buf = ng_grabber_grab_image(0))) {
            fprintf(stderr,"capturing image failed\n");
diff --git a/console/webcam.c b/console/webcam.c
index b66fb07..65d6c9a 100644
--- a/console/webcam.c
+++ b/console/webcam.c
@@ -84,7 +84,7 @@ write_file(int fd, unsigned char *data, int width, int height)
 
     for (i = 0, line = data; i < height; i++, line += width*3)
        jpeg_write_scanlines(&cinfo, &line, 1);
-    
+
     jpeg_finish_compress(&(cinfo));
     jpeg_destroy_compress(&(cinfo));
     fclose(fp);
@@ -142,7 +142,7 @@ static int ftp_xfer(struct xfer_state *s, char *image, int 
width, int height)
 {
     char filename[1024];
     int fh;
-    
+
     sprintf(filename,"%s/webcamXXXXXX",tmpdir);
     if (-1 == (fh = mkstemp(filename))) {
        perror("mkstemp");
@@ -190,7 +190,7 @@ static int ssh_xfer(struct xfer_state *s, char *image, int 
width, int height)
     unsigned char buf[4096];
     FILE *sshp, *imgdata;
     int len,fh;
-    
+
     sprintf(filename,"%s/webcamXXXXXX",tmpdir);
     if (-1 == (fh = mkstemp(filename))) {
        perror("mkstemp");
@@ -235,12 +235,12 @@ static struct xfer_ops ssh_ops = {
 static int local_open(struct xfer_state *s)
 {
     char *t;
-    
+
     if (s->dir != NULL && s->dir[0] != '\0' ) {
        t = malloc(strlen(s->tmpfile)+strlen(s->dir)+2);
        sprintf(t, "%s/%s", s->dir, s->tmpfile);
        s->tmpfile = t;
-       
+
        t = malloc(strlen(s->file)+strlen(s->dir)+2);
        sprintf(t, "%s/%s", s->dir, s->file);
        s->file = t;
@@ -257,7 +257,7 @@ static void local_info(struct xfer_state *s)
 static int local_xfer(struct xfer_state *s, char *image, int width, int height)
 {
     int fh;
-    
+
     if (-1 == (fh = open(s->tmpfile,O_CREAT|O_WRONLY|O_TRUNC,0666))) {
        fprintf(stderr,"open %s: %s\n",s->tmpfile,strerror(errno));
        exit(1);
@@ -296,8 +296,8 @@ grab_init(void)
 {
     struct ng_attribute *attr;
     int val,i;
-    
-    drv = ng_vid_open(ng_dev.video,NULL,NULL,0,&h_drv);
+
+    drv = ng_vid_open(ng_dev.video,ng_dev.driver,NULL,0,&h_drv);
     if (NULL == drv) {
        fprintf(stderr,"no grabber device available\n");
        exit(1);
@@ -332,7 +332,7 @@ grab_init(void)
     fmt.height = grab_height;
     if (0 == drv->setformat(h_drv,&fmt))
        return;
-    
+
     /* check all available conversion functions */
     fmt.bytesperline = fmt.width*ng_vfmt_to_depth[fmt.fmtid]/8;
     for (i = 0;;) {
@@ -366,14 +366,14 @@ grab_one(int *width, int *height)
     }
 
     if (NULL != conv) {
-        buf = ng_malloc_video_buf(&fmt,3*fmt.width*fmt.height);
+       buf = ng_malloc_video_buf(&fmt,3*fmt.width*fmt.height);
        conv->frame(hconv,buf,cap);
        buf->info = cap->info;
        ng_release_video_buf(cap);
     } else {
        buf = cap;
     }
-    
+
     *width  = buf->fmt.width;
     *height = buf->fmt.height;
     return buf->data;
@@ -394,7 +394,7 @@ get_message(void)
     static char buffer[MSG_MAXLEN+1];
     FILE *fp;
     char *p;
-    
+
     if (NULL == grab_infofile)
        return grab_text;
 
@@ -447,9 +447,9 @@ add_text(char *image, int width, int height)
 /* Frederic Helin <[email protected]> - 15/07/2002              */
 /* Correction fonction of stereographic radial distortion                 */
 
-int grab_dist_on = 0; 
+int grab_dist_on = 0;
 int grab_dist_k = 700;
-int grab_dist_cx = -1; 
+int grab_dist_cx = -1;
 int grab_dist_cy = -1;
 int grab_dist_zoom = 50;
 int grab_dist_sensorw = 640;
@@ -461,55 +461,55 @@ correct_distor(unsigned char * in, int width, int height,
               int grab_sensorw, int grab_sensorh)
 {
     static unsigned char * corrimg = NULL;
-    
+
     int i, j, di, dj;
     float dr, cr,ca, sensor_w, sensor_h, sx, zoom, k;
-    
+
     sensor_w = grab_dist_sensorw/100.0;
     sensor_h = grab_dist_sensorh/100.0;
     zoom = grab_zoom / 100.0;
     k = grap_k / 100.0;
-    
+
     if (corrimg == NULL && (corrimg = malloc(width*height*3)) == NULL ) {
        fprintf(stderr, "out of memory\n");
        exit(1);
     }
-    
+
     sensor_w = 6.4;
     sensor_h = 4.8;
-    
+
     // calc ratio x/y
     sx = width * sensor_h / (height * sensor_w);
-    
+
     // calc new value of k in the coordonates systeme of computer
     k = k * height / sensor_h;
-    
+
     // Clear image
     for (i = 0; i < height*width*3; i++) corrimg[i] = 255;
-    
+
     for (j = 0; j < height ; j++) {
-       for (i = 0; i < width ; i++) {  
-           
-           // compute radial distortion / parameters of center of image 
+       for (i = 0; i < width ; i++) {
+
+           // compute radial distortion / parameters of center of image
            cr  = sqrt((i-cx)/sx*(i-cx)/sx+(j-cy)*(j-cy));
            ca  = atan(cr/k/zoom);
-           dr = k * tan(ca/2); 
-           
+           dr = k * tan(ca/2);
+
            if (i == cx && j == cy) {di = cx; dj = cy;}
            else {
                di = (i-cx) * dr / cr + cx;
                dj = (j-cy) * dr / cr + cy;
            }
-           
+
            if (dj<height && di < width && di >= 0  && dj >= 0 &&
                j<height &&  i < width &&  i >= 0  &&  j >= 0 ) {
                corrimg[3*(j*width + i)  ] = in[3*(dj*width + di)  ];
                corrimg[3*(j*width + i)+1] = in[3*(dj*width + di)+1];
-               corrimg[3*(j*width + i)+2] = in[3*(dj*width + di)+2];   
+               corrimg[3*(j*width + i)+2] = in[3*(dj*width + di)+2];
            }
        }
     }
-    return corrimg;    
+    return corrimg;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -606,7 +606,7 @@ rotate_image(unsigned char * in, int *wp, int *hp, int rot,
        *hp = ow;
        break;
     }
-    return rotimg;     
+    return rotimg;
 }
 
 
@@ -629,7 +629,7 @@ static int make_dirs(char *filename)
        if (ENOENT == errno)
            if (0 == make_dirs(dirname))
                retval = mkdir(dirname,0777);
-    
+
  done:
     free(dirname);
     return retval;
@@ -657,6 +657,8 @@ main(int argc, char *argv[])
 
     if (NULL != (val = cfg_get_str("grab","device")))
        ng_dev.video = val;
+    if (NULL != (val = cfg_get_str("grab","driver")))
+       ng_dev.driver = val;
     if (NULL != (val = cfg_get_str("grab","text")))
        grab_text = val;
     if (NULL != (val = cfg_get_str("grab","infofile")))
@@ -711,7 +713,7 @@ main(int argc, char *argv[])
     if (-1 != (i = cfg_get_int("grab","bg_blue")))
        if (i >= 0 && i <= 255)
            grab_bg_b = i;
-    
+
     if (-1 != (i = cfg_get_int("grab","distor")))
       grab_dist_on = i;
     if (-1 != (i = cfg_get_int("grab","distor_k")))
@@ -831,16 +833,16 @@ main(int argc, char *argv[])
 
     /* run as daemon - detach from terminal */
     if (daemonize) {
-        switch (fork()) {
-        case -1:
+       switch (fork()) {
+       case -1:
            perror("fork");
            exit(1);
-        case 0:
-            close(0); close(1); close(2); setsid();
-            break;
-        default:
-            exit(0);
-        }
+       case 0:
+           close(0); close(1); close(2); setsid();
+           break;
+       default:
+           exit(0);
+       }
     }
 
     /* main loop */
@@ -853,7 +855,7 @@ main(int argc, char *argv[])
                                  grab_dist_zoom, grab_dist_k,
                                  grab_dist_cx, grab_dist_cy,
                                  grab_dist_sensorw, grab_dist_sensorh);
-       
+
        image = rotate_image(gimg, &width, &height, grab_rotate,
                             grab_top, grab_left, grab_bottom, grab_right);
 
diff --git a/libng/devices.c b/libng/devices.c
index cbdaa50..ab1f2df 100644
--- a/libng/devices.c
+++ b/libng/devices.c
@@ -12,6 +12,7 @@
 #if defined(__OpenBSD__) || defined(__FreeBSD__) || 
defined(__FreeBSD_kernel__) || defined(__NetBSD__)
 struct ng_device_config ng_dev = {
     video:  "/dev/bktr0",
+    driver: "bktr",
     radio:  NULL,
     vbi:    "/dev/vbi0",
     dsp:    "/dev/dsp",
@@ -25,7 +26,7 @@ struct ng_device_config ng_dev = {
     },
     mixer_scan: {
        "/dev/mixer",
-       "/dev/mixer1", 
+       "/dev/mixer1",
        "/dev/mixer2",
        "/dev/mixer3",
        NULL
@@ -34,10 +35,9 @@ struct ng_device_config ng_dev = {
 #endif
 #if defined(__linux__)
 struct ng_device_config ng_dev = {
-    video:  "/dev/video0", /* <rant>thank you redhat breaking
-                           * /dev/video as symbolic link to the
-                           * default video device ... </rant> */
-    radio:  "/dev/radio",
+    video:  "/dev/video0",
+    driver: "libv4l",
+    radio:  "/dev/radio0",
     vbi:    "/dev/vbi0",
     dsp:    "/dev/dsp",
     mixer:  "/dev/mixer",
@@ -50,7 +50,7 @@ struct ng_device_config ng_dev = {
     },
     mixer_scan: {
        "/dev/mixer",
-       "/dev/mixer1", 
+       "/dev/mixer1",
        "/dev/mixer2",
        "/dev/mixer3",
        NULL
@@ -59,6 +59,7 @@ struct ng_device_config ng_dev = {
 
 struct ng_device_config ng_dev_devfs = {
     video:  "/dev/v4l/video0",
+    driver: "libv4l",
     radio:  "/dev/v4l/radio0",
     vbi:    "/dev/v4l/vbi0",
     dsp:    "/dev/sound/dsp",
@@ -72,7 +73,7 @@ struct ng_device_config ng_dev_devfs = {
     },
     mixer_scan: {
        "/dev/sound/mixer",
-       "/dev/sound/mixer1", 
+       "/dev/sound/mixer1",
        "/dev/sound/mixer2",
        "/dev/sound/mixer3",
        NULL
diff --git a/libng/devices.h b/libng/devices.h
index c4a2959..e413a15 100644
--- a/libng/devices.h
+++ b/libng/devices.h
@@ -1,6 +1,7 @@
 
 struct ng_device_config {
     char *video;
+    char *driver;
     char *radio;
     char *vbi;
     char *dsp;
diff --git a/libng/grab-ng.c b/libng/grab-ng.c
index 5484267..b4f72e2 100644
--- a/libng/grab-ng.c
+++ b/libng/grab-ng.c
@@ -121,7 +121,7 @@ const char* ng_attr_to_desc[] = {
 void ng_init_video_buf(struct ng_video_buf *buf)
 {
     memset(buf,0,sizeof(*buf));
-    pthread_mutex_init(&buf->lock,NULL);    
+    pthread_mutex_init(&buf->lock,NULL);
     pthread_cond_init(&buf->cond,NULL);
 }
 
@@ -226,7 +226,7 @@ const char*
 ng_attr_getstr(struct ng_attribute *attr, int value)
 {
     int i;
-    
+
     if (NULL == attr)
        return NULL;
     if (attr->type != ATTR_TYPE_CHOICE)
@@ -242,7 +242,7 @@ int
 ng_attr_getint(struct ng_attribute *attr, char *value)
 {
     int i,val;
-    
+
     if (NULL == attr)
        return -1;
     if (attr->type != ATTR_TYPE_CHOICE)
@@ -260,7 +260,7 @@ ng_attr_getint(struct ng_attribute *attr, char *value)
        for (i = 0; attr->choices[i].str != NULL; i++)
            if (val == attr->choices[i].nr)
                return attr->choices[i].nr;
-       
+
     }
     return -1;
 }
@@ -269,7 +269,7 @@ void
 ng_attr_listchoices(struct ng_attribute *attr)
 {
     int i;
-    
+
     fprintf(stderr,"valid choices for \"%s\": ",attr->name);
     for (i = 0; attr->choices[i].str != NULL; i++)
        fprintf(stderr,"%s\"%s\"",
@@ -409,7 +409,7 @@ ng_aconv_register(int magic, char *plugname,
                  struct ng_audio_conv *list, int count)
 {
     int n;
-    
+
     if (0 != ng_check_magic(magic,plugname,"audio converters"))
        return -1;
     for (n = 0; n < count; n++)
@@ -504,7 +504,7 @@ ng_conv_find_from(unsigned int in, int *i)
 {
     struct list_head *item;
     struct ng_video_conv *ret;
-    
+
     int j = 0;
 
     list_for_each(item,&ng_conv) {
@@ -531,7 +531,7 @@ ng_conv_find_match(unsigned int in, unsigned int out)
 {
     struct list_head *item;
     struct ng_video_conv *ret = NULL;
-    
+
     list_for_each(item,&ng_conv) {
        ret = list_entry(item, struct ng_video_conv, list);
        if (ret->fmtid_in  == in && ret->fmtid_out == out)
@@ -565,31 +565,43 @@ ng_vid_open(char *device, char *driver, struct 
ng_video_fmt *screen,
     }
 #endif
 
-    if (ng_debug) {
-       if (driver)
-           fprintf(stderr,"vid-open: Seeking for %s plugin.\n", driver);
-       else
-           fprintf(stderr,"vid-open: Seeking for the first available 
driver.\n");
+    if (!driver) {
+       fprintf (stderr, "Video4linux driver is not specified\n");
+       return NULL;
     }
 
     /* check all grabber drivers */
     list_for_each(item,&ng_vid_drivers) {
-        drv = list_entry(item, struct ng_vid_driver, list);
-       if (driver && 0 != strcasecmp(driver, drv->name))
-           continue;
-       if (ng_debug)
-           fprintf(stderr,"vid-open: trying: %s... \n", drv->name);
-       if (NULL != (*handle = (drv->open)(device)))
+       drv = list_entry(item, struct ng_vid_driver, list);
+       if (strcasecmp(driver, drv->name) == 0)
            break;
-       if (ng_debug)
-           fprintf(stderr,"vid-open: failed: %s\n",drv->name);
     }
-    if (item == &ng_vid_drivers)
+
+    if (item == &ng_vid_drivers) {
+       if (strcasecmp(driver, "help") != 0)
+           fprintf (stderr, "Cannot find %s video driver\n", drv->name);
+       fprintf (stderr, "Available drivers:");
+       list_for_each(item,&ng_vid_drivers) {
+           drv = list_entry(item, struct ng_vid_driver, list);
+           fprintf (stderr, " %s", drv->name);
+       }
+       fprintf (stderr, "\n");
+
        return NULL;
+    }
+
+    if (ng_debug)
+       fprintf(stderr,"vid-open: trying: %s... \n", drv->name);
+    if (!(*handle = (drv->open)(device))) {
+       fprintf(stderr,"vid-open: failed: %s\n",drv->name);
+       return NULL;
+    }
     if (ng_debug)
        fprintf(stderr,"vid-open: ok: %s\n",drv->name);
+
     if (NULL != screen && drv->capabilities(*handle) & CAN_OVERLAY)
        drv->setupfb(*handle,screen,base);
+
     return drv;
 }
 
@@ -601,7 +613,7 @@ ng_dsp_open(char *device, struct ng_audio_fmt *fmt, int 
record, void **handle)
 
     /* check all dsp drivers */
     list_for_each(item,&ng_dsp_drivers) {
-        drv = list_entry(item, struct ng_dsp_driver, list);
+       drv = list_entry(item, struct ng_dsp_driver, list);
        if (NULL == drv->name)
            continue;
        if (record && NULL == drv->read)
@@ -629,10 +641,10 @@ ng_mix_init(char *device, char *channel)
     struct ng_mix_driver *drv = NULL;
     struct ng_attribute *attrs = NULL;
     void *handle;
-    
+
     /* check all mixer drivers */
     list_for_each(item, &ng_mix_drivers) {
-        drv = list_entry(item, struct ng_mix_driver, list);
+       drv = list_entry(item, struct ng_mix_driver, list);
        if (ng_debug)
            fprintf(stderr,"mix-init: trying: %s... \n", drv->name);
        if (NULL != (handle = (drv->open)(device))) {
@@ -658,7 +670,7 @@ struct ng_reader* ng_find_reader(char *filename)
 
     if (NULL == (fp = fopen(filename, "r"))) {
        fprintf(stderr,"open %s: %s\n",filename,strerror(errno));
-        return NULL;
+       return NULL;
     }
     memset(blk,0,sizeof(blk));
     fread(blk,1,sizeof(blk),fp);
diff --git a/man/fbtv.1 b/man/fbtv.1
index 711a201..7249aff 100644
--- a/man/fbtv.1
+++ b/man/fbtv.1
@@ -25,6 +25,9 @@ Be verbose.
 .B -c device
 video4linux device (default is /dev/video0).
 .TP
+.B -D driver
+video4linux driver (default is "libv4l").
+.TP
 .B -d device
 framebuffer device (default is $FRAMEBUFFER; /dev/fb0 if unset)
 .TP
diff --git a/man/motv.1 b/man/motv.1
index 455fe06..3737957 100644
--- a/man/motv.1
+++ b/man/motv.1
@@ -43,6 +43,12 @@ disables Xvideo support.
 .br
 Resource: motv.device (string).
 .TP
+\fB-D\fP, \fB-driver\fP name
+set video4linux driver (default is "libv4l").  This option also
+disables Xvideo support.
+.br
+Resource: motv.driver (string).
+.TP
 \fB-C\fP, \fB-dspdev\fP device
 set audio device (default is /dev/dsp).
 .br
@@ -193,9 +199,9 @@ C            Popup \fIC\fPontrol Window
 R            Popup AVI \fIR\fPecording Window
 S            Popup \fIS\fPcale controls
 Z            Channel Hopper (\fIz\fPapping, tune in every
-             station a few seconds)
+            station a few seconds)
 Ctrl+Z       Fast Channel Hopping (grab the images for the
-             Channel Bottons)
+            Channel Bottons)
 
 up/down      tune up/down one channel
 left/right   fine tuning
diff --git a/man/scantv.1 b/man/scantv.1
index ba1ca9c..4a3c2b0 100644
--- a/man/scantv.1
+++ b/man/scantv.1
@@ -28,6 +28,9 @@ to stdout.
 .B -c device
 specify video device file.  Default is /dev/video0.
 .TP
+.B -D driver
+specify video driver name.  Default is "libv4l".
+.TP
 .B -C device
 specify vbi device file.  Default is /dev/vbi.
 .TP
diff --git a/man/ttv.1 b/man/ttv.1
index 9513a92..f65edc9 100644
--- a/man/ttv.1
+++ b/man/ttv.1
@@ -16,6 +16,9 @@ use fast aalib render function.
 .TP
 .B -c device
 video4linux device (default is /dev/video0).
+.TP
+.B -D driver
+video4linux driver (default is "libv4l").
 .P
 There are also lots of options for aalib, check the aalib documentation
 for more details on them.  The help text includes a list.
diff --git a/man/webcam.1 b/man/webcam.1
index 94a5276..228c904 100644
--- a/man/webcam.1
+++ b/man/webcam.1
@@ -26,6 +26,7 @@ Here is an sample config file (the given values are the 
defaults):
 
 [grab]
 device = /dev/video0
+driver = libv4l
 text = "webcam %Y-%m-%d %H:%M:%S"
 infofile = filename
 fg_red = 255
@@ -94,10 +95,10 @@ reasonable quality within the first few seconds ...).
 is the JPEG quality for the stored images.
 .P
 .B top, bottom, left,
-and 
+and
 .B right
 in the grab section allow cropping the image after it is grabbed.
-They should satisfy 0<=top<bottom<=height and 
+They should satisfy 0<=top<bottom<=height and
 0<=left<right<=width.  (0,0 is the top, left corner.)
 If
 .B rotate
@@ -110,7 +111,7 @@ set to a non-zero value webcam will upload the image only 
if the
 content of the image has changed.  It just looks for the maximum
 difference between the last uploaded and current image and if it is
 greater than the specified value the image will be uploaded.
-If 
+If
 .B once
 is set to 1 webcam will upload a single frame and quit.
 .P
@@ -131,7 +132,7 @@ switch, check the ftp(1) man page for more info about the 
~/.netrc file).
 If
 .B local
 in the ftp section is non-zero, files will be stored locally (using
-the 
+the
 .B dir, tmp,
 and
 .B file
@@ -143,7 +144,7 @@ contributed by Frederic Helin, the parameters belong into 
the [grab]
 section of the config file too.
 .TP
 .B distor = 1
-If distor param is set to 1, the correction of distortion works. 
+If distor param is set to 1, the correction of distortion works.
 .TP
 .B distor_k = 700
 This is the coefficient of distortion. This algorithm is based on the
diff --git a/man/xawtv-remote.1 b/man/xawtv-remote.1
index 66bccaa..0b86723 100644
--- a/man/xawtv-remote.1
+++ b/man/xawtv-remote.1
@@ -37,6 +37,9 @@ print a short help text
 .B -c device
 Set video4linux device.
 .TP
+.B -D driver
+Set video4linux driver.
+.TP
 .B -v n
 Set debug level to \fBn\fP, where n = [0..2]
 .SH COMMANDS
diff --git a/man/xawtv.1 b/man/xawtv.1
index 0a9a343..5a318fc 100644
--- a/man/xawtv.1
+++ b/man/xawtv.1
@@ -39,6 +39,12 @@ disables Xvideo support.
 .br
 Resource: xawtv.device (string).
 .TP
+\fB-D\fP, \fB-driver\fP name
+set video4linux driver (default is "libv4l").  This option also
+disables Xvideo support.
+.br
+Resource: xawtv.driver (string).
+.TP
 \fB-C\fP, \fB-dspdev\fP device
 set audio device (default is /dev/dsp).
 .br
@@ -188,9 +194,9 @@ C            Popup \fIC\fPhannels Window
 E            Popup Channel \fIE\fPditor
 R            Popup AVI \fIR\fPecording Window
 Z            Channel Hopper (\fIz\fPapping, tune in every
-             station a few seconds)
+            station a few seconds)
 Ctrl+Z       Fast Channel Hopping (grab the images for the
-             Channel Buttons)
+            Channel Buttons)
 
 up/down      tune up/down one channel
 left/right   fine tuning
diff --git a/todo/tmohan/webcam.c b/todo/tmohan/webcam.c
index 0d1e35e..d11048f 100644
--- a/todo/tmohan/webcam.c
+++ b/todo/tmohan/webcam.c
@@ -379,7 +379,7 @@ grab_init (void)
        struct ng_attribute *attr;
        int val, i;
 
-       drv = ng_vid_open (ng_dev.video, NULL, NULL, 0, &h_drv);
+       drv = ng_vid_open (ng_dev.video, ng_dev.driver, NULL, 0, &h_drv);
        if (NULL == drv)
        {
                fprintf (stderr, "no grabber device available\n");
@@ -597,7 +597,7 @@ correct_distor (unsigned char *in, int width, int height,
                for (i = 0; i < width; i++)
                {
 
-                       // compute radial distortion / parameters of center of 
image 
+                       // compute radial distortion / parameters of center of 
image
                        cr = sqrt ((i - cx) / sx * (i - cx) / sx + (j - cy) * 
(j - cy));
                        ca = atan (cr / k / zoom);
                        dr = k * tan (ca / 2);
@@ -711,14 +711,14 @@ compare_images(unsigned char *saved, unsigned char *last, 
unsigned char *current
                        avg2 += diff2;
                        if (diff2 > max2)
                                max2 = diff2;
-                       
+
     }
 
     avg = avg / width / height;
     avg2 = avg2 / width / height;
     fprintf(stderr,"compare: max=%d,%d,avg=%d,%d\n",max,max2,avg,avg2);
 
- 
+
     return max;
 }*/
 
@@ -1295,6 +1295,8 @@ main (int argc, char *argv[])
 
        if (NULL != (val = cfg_get_str ("grab", "device")))
                ng_dev.video = val;
+       if (NULL != (val = cfg_get_str ("grab", "driver")))
+               ng_dev.driver = val;
        if (NULL != (val = cfg_get_str ("grab", "text")))
                grab_text = val;
        if (NULL != (val = cfg_get_str ("grab", "infofile")))
diff --git a/x11/v4lctl.c b/x11/v4lctl.c
index c6baded..9fc2ccc 100644
--- a/x11/v4lctl.c
+++ b/x11/v4lctl.c
@@ -37,7 +37,7 @@ Display *dpy;
 static void
 grabber_init(void)
 {
-    drv = ng_vid_open(ng_dev.video,NULL,NULL,0,&h_drv);
+    drv = ng_vid_open(ng_dev.video,ng_dev.driver,NULL,0,&h_drv);
     if (NULL == drv) {
        fprintf(stderr,"no grabber device available\n");
        exit(1);
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
 
     ng_init();
     for (;;) {
-       if (-1 == (c = getopt(argc, argv, "hv:c:")))
+       if (-1 == (c = getopt(argc, argv, "hv:c:D:")))
            break;
        switch (c) {
        case 'v':
@@ -76,6 +76,10 @@ int main(int argc, char *argv[])
            ng_dev.video = optarg;
            xvideo = 0;
            break;
+       case 'D':
+           ng_dev.driver = optarg;
+           xvideo = 0;
+           break;
        case 'h':
        default:
            usage();
diff --git a/x11/xt.c b/x11/xt.c
index 4b82ffe..81658a0 100644
--- a/x11/xt.c
+++ b/x11/xt.c
@@ -252,6 +252,7 @@ const int args_count = XtNumber(args_desc);
 XrmOptionDescRec opt_desc[] = {
     { "-c",          "device",      XrmoptionSepArg, NULL },
     { "-device",     "device",      XrmoptionSepArg, NULL },
+    { "-D",          "driver",      XrmoptionSepArg, NULL },
     { "-driver",     "driver",      XrmoptionSepArg, NULL },
     { "-C",          "dspdev",      XrmoptionSepArg, NULL },
     { "-dspdev",     "dspdev",      XrmoptionSepArg, NULL },
@@ -260,7 +261,7 @@ XrmOptionDescRec opt_desc[] = {
     { "-o",          "basename",    XrmoptionSepArg, NULL },
     { "-outfile",    "basename",    XrmoptionSepArg, NULL },
     { "-conffile",   "conffile",    XrmoptionSepArg, NULL },
-    
+
     { "-v",          "debug",       XrmoptionSepArg, NULL },
     { "-debug",      "debug",       XrmoptionSepArg, NULL },
     { "-b",          "bpp",         XrmoptionSepArg, NULL },
@@ -269,7 +270,7 @@ XrmOptionDescRec opt_desc[] = {
     { "-xvport",     "xvport",      XrmoptionSepArg, NULL },
     { "-parallel",   "parallel",    XrmoptionSepArg, NULL },
     { "-bufcount",   "bufcount",    XrmoptionSepArg, NULL },
-    
+
     { "-remote",     "remote",      XrmoptionNoArg,  "1" },
     { "-n",          "readconfig",  XrmoptionNoArg,  "0" },
     { "-noconf",     "readconfig",  XrmoptionNoArg,  "0" },
@@ -277,7 +278,7 @@ XrmOptionDescRec opt_desc[] = {
     { "-fullscreen", "fullscreen",  XrmoptionNoArg,  "1" },
     { "-hwscan",     "hwscan",      XrmoptionNoArg,  "1" },
     { "-fb",         "fbdev",       XrmoptionNoArg,  "1" },
-    
+
     { "-xv",         "xv",          XrmoptionNoArg,  "1" },
     { "-noxv",       "xv",          XrmoptionNoArg,  "0" },
     { "-xv-video",   "xvVideo",     XrmoptionNoArg,  "1" },
@@ -293,7 +294,7 @@ XrmOptionDescRec opt_desc[] = {
     { "-nodga",      "dga",         XrmoptionNoArg,  "0" },
     { "-randr",      "randr",       XrmoptionNoArg,  "1" },
     { "-norandr",    "randr",       XrmoptionNoArg,  "0" },
-    
+
     { "-h",          "help",        XrmoptionNoArg,  "1" },
     { "-help",       "help",        XrmoptionNoArg,  "1" },
     { "--help",      "help",        XrmoptionNoArg,  "1" },
@@ -317,7 +318,7 @@ ExitCB(Widget widget, XtPointer client_data, XtPointer 
calldata)
     static int exit_pending = 0;
 
     if (exit_pending)
-        return;
+       return;
 
     exit_pending = 1;
     audio_off();
@@ -385,9 +386,9 @@ RemoteAction(Widget widget, XEvent * event,
                    argv[argc] = NULL;
                    do_command(argc,argv);
                    argc = 0;
-               } else {
+               } else {
                    argv[argc++] = args+i;
-               }
+               }
            }
            XFree(args);
        }
@@ -446,7 +447,7 @@ static void
 scan_timeout(XtPointer client_data, XtIntervalId *id)
 {
     scan_timer = 0;
-    
+
     /* check */
     if (!(f_drv & CAN_TUNE))
        return;
@@ -474,7 +475,7 @@ RatioAction(Widget widget, XEvent *event,
            String *params, Cardinal *num_params)
 {
     int w,h;
-    
+
     if (2 != *num_params)
        return;
     w = atoi(params[0]);
@@ -647,7 +648,7 @@ exec_player(char *moviefile)
     char *cmd;
     char **argv;
     int  argc;
-    
+
     /* go! */
     cmd = malloc(strlen(command)+strlen(moviefile)+5);
     sprintf(cmd,"%s %s",command,moviefile);
@@ -661,7 +662,7 @@ LaunchAction(Widget widget, XEvent *event,
 {
     char **argv;
     int  i,argc;
-    
+
     if (*num_params != 1)
        return;
     for (i = 0; i < nlaunch; i++) {
@@ -735,7 +736,7 @@ xt_siginit(void)
 
     act.sa_handler  = SIG_IGN;
     sigaction(SIGPIPE,&act,&old);
-    
+
     if (debug) {
        act.sa_handler  = segfault;
        sigaction(SIGSEGV,&act,&old);
@@ -811,7 +812,7 @@ do_vidmode_modeswitch(int fs_state, int *vp_width, int 
*vp_height)
     static XF86VidModeModeInfo  *vm_current    = NULL;
     static XF86VidModeModeInfo  *vm_fullscreen = NULL;
     int i;
-    
+
     if (fs_state) {
        /* enter fullscreen mode */
        XF86VidModeGetModeLine(dpy,XDefaultScreen(dpy),&vm_dot,&vm_line);
@@ -867,7 +868,7 @@ do_randr_modeswitch(int fs_state, int *vp_width, int 
*vp_height)
     XRRScreenConfiguration *sc;
     Rotation rotation;
     SizeID current, new, i;
-    
+
     sc = XRRGetScreenInfo(dpy, root);
     current = XRRConfigCurrentConfiguration(sc, &rotation);
     new = current;
@@ -944,10 +945,10 @@ do_screensaver(int fs_state)
                        &prefer_blanking,&allow_exposures);
        XSetScreenSaver(dpy,0,0,DefaultBlanking,DefaultExposures);
 #ifdef HAVE_LIBXDPMS
-       if ((DPMSQueryExtension(dpy, &dpms_dummy, &dpms_dummy)) && 
+       if ((DPMSQueryExtension(dpy, &dpms_dummy, &dpms_dummy)) &&
            (DPMSCapable(dpy))) {
            DPMSInfo(dpy, &dpms_state, &dpms_on);
-            DPMSDisable(dpy); 
+           DPMSDisable(dpy);
        }
 #endif
        xscreensaver_timer = XtAppAddTimeOut(app_context,60000,
@@ -956,7 +957,7 @@ do_screensaver(int fs_state)
        /* fullscreen off -- enable screensaver */
        XSetScreenSaver(dpy,timeout,interval,prefer_blanking,allow_exposures);
 #ifdef HAVE_LIBXDPMS
-       if ((DPMSQueryExtension(dpy, &dpms_dummy, &dpms_dummy)) && 
+       if ((DPMSQueryExtension(dpy, &dpms_dummy, &dpms_dummy)) &&
            (DPMSCapable(dpy)) && (dpms_on)) {
                DPMSEnable(dpy);
        }
@@ -1000,13 +1001,13 @@ do_fullscreen(void)
        if (debug)
            fprintf(stderr,"turning fs off (%dx%d+%d+%d)\n",w,h,x,y);
        do_modeswitch(0,&vp_width,&vp_height);
-       
+
        if (on_timer) {
            XtPopdown(on_shell);
            XtRemoveTimeOut(on_timer);
            on_timer = 0;
        }
-       
+
        XtVaSetValues(app_shell,
                      XtNwidthInc, WIDTH_INC,
                      XtNheightInc,HEIGHT_INC,
@@ -1017,7 +1018,7 @@ do_fullscreen(void)
                      NULL);
 
        do_screensaver(0);
-       if (warp_pointer)
+       if (warp_pointer)
            XWarpPointer(dpy, None, RootWindowOfScreen(XtScreen(tv)),
                         0, 0, 0, 0, rpx, rpy);
        fs = 0;
@@ -1054,7 +1055,7 @@ do_fullscreen(void)
            int i;
            for (i = 0; i < nxinerama; i++) {
                if (x >= xinerama[i].x_org &&
-                   y >= xinerama[i].y_org && 
+                   y >= xinerama[i].y_org &&
                    x <  xinerama[i].x_org + xinerama[i].width &&
                    y <  xinerama[i].y_org + xinerama[i].height) {
                    vp_x      = xinerama[i].x_org;
@@ -1081,7 +1082,7 @@ do_fullscreen(void)
                      XtNheight,     vp_height,
                      NULL);
 
-        XRaiseWindow(dpy, XtWindow(app_shell));
+       XRaiseWindow(dpy, XtWindow(app_shell));
        do_screensaver(1);
        if (warp_pointer)
            XWarpPointer(dpy, None, XtWindow(tv), 0, 0, 0, 0, 30, 15);
@@ -1178,9 +1179,9 @@ set_property(int freq, char *channel, char *name)
     len += sprintf(line+len,"%s",channel ? channel : "?") +1;
     len += sprintf(line+len,"%s",name    ? name    : "?") +1;
     XChangeProperty(dpy, XtWindow(app_shell),
-                    _XAWTV_STATION, XA_STRING,
-                    8, PropModeReplace,
-                    line, len);
+                   _XAWTV_STATION, XA_STRING,
+                   8, PropModeReplace,
+                   line, len);
 }
 
 void command_cb(Widget widget, XtPointer clientdata, XtPointer call_data)
@@ -1266,7 +1267,7 @@ xfree_dga_init(Display *dpy)
 
     if (!do_overlay)
        return;
-    
+
     if (args.dga) {
        if (XF86DGAQueryExtension(dpy,&foo,&xfree_dga_error_base)) {
            XF86DGAQueryDirectVideo(dpy,XDefaultScreen(dpy),&flags);
@@ -1304,7 +1305,7 @@ xfree_vm_init(Display *dpy)
                    fprintf(stderr," %dx%d",
                            vm_modelines[i]->hdisplay,
                            vm_modelines[i]->vdisplay);
-               }           
+               }
                fprintf(stderr,"\n");
            }
        }
@@ -1317,7 +1318,7 @@ xfree_randr_init(Display *dpy)
 {
 #ifdef HAVE_LIBXRANDR
     int bar,i;
-    
+
     if (args.randr) {
        if (XRRQueryExtension(dpy,&randr_evbase,&bar)) {
            randr = XRRSizes(dpy,DefaultScreen(dpy),&nrandr);
@@ -1342,7 +1343,7 @@ xfree_xinerama_init(Display *dpy)
 {
 #ifdef HAVE_LIBXINERAMA
     int foo,bar,i;
-    
+
     if (XineramaQueryExtension(dpy,&foo,&bar) &&
        XineramaIsActive(dpy)) {
        xinerama = XineramaQueryScreens(dpy,&nxinerama);
@@ -1381,27 +1382,21 @@ grabber_init()
 #ifdef HAVE_LIBXXF86DGA
     if (have_dga) {
        int bar,fred;
-        orig_xfree_error_handler = XSetErrorHandler(xfree_dga_error_handler);
+       orig_xfree_error_handler = XSetErrorHandler(xfree_dga_error_handler);
        if (!XF86DGAGetVideoLL(dpy,XDefaultScreen(dpy),(void*)&base,
                              &screen.bytesperline,&bar,&fred)) {
            have_dga = 0;
            memset(&screen,0,sizeof(screen));   /*  paranoia   */
            base = NULL;                        /*  paranoia   */
        }
-        XSync(dpy, 0);
-        XSetErrorHandler(orig_xfree_error_handler);
+       XSync(dpy, 0);
+       XSetErrorHandler(orig_xfree_error_handler);
     }
 #endif
     if (!do_overlay) {
-       drv = NULL;
-
        if (debug)
            fprintf(stderr,"x11: remote display (overlay disabled)\n");
-
-       if (!args.driver)
-           drv = ng_vid_open(args.device, "libv4l", NULL, base, &h_drv);
-        if (!drv)
-           drv = ng_vid_open(args.device, args.driver, NULL, base, &h_drv);
+       drv = ng_vid_open(args.device, args.driver, NULL, base, &h_drv);
     } else {
        screen.width  = XtScreen(app_shell)->width;
        screen.height = XtScreen(app_shell)->height;
@@ -1484,7 +1479,7 @@ x11_check_remote()
 
     if (debug)
        fprintf(stderr, "check if the X-Server is local ... ");
-    
+
     /* me */
     length = sizeof(ss);
     if (-1 == getsockname(fd,(struct sockaddr*)&ss,&length)) {
@@ -1500,7 +1495,7 @@ x11_check_remote()
            fprintf(stderr, " ok (unix socket)\n");
        return;
     }
-    
+
     getnameinfo((struct sockaddr*)&ss,length,
                me,INET6_ADDRSTRLEN,port,16,
                NI_NUMERICHOST | NI_NUMERICSERV);
@@ -1622,6 +1617,7 @@ usage(void)
            "  -b  -bpp n          color depth of the display is n (n=24,32)\n"
            "  -o  -outfile file   filename base for snapshots\n"
            "  -c  -device file    use <file> as video4linux device\n"
+           "  -D  -driver name    use <name> as video4linux driver\n"
            "  -C  -dspdev file    use <file> as audio (oss) device\n"
            "      -vbidev file    use <file> as vbi device\n"
            "      -joydev file    use <file> as joystick device\n"
@@ -1648,7 +1644,7 @@ hello_world(char *name)
        fprintf(stderr,"%s *must not* be installed suid root\n",name);
        exit(1);
     }
-    
+
     uname(&uts);
     fprintf(stderr,"This is %s-%s, running on %s/%s (%s)\n",
            name,VERSION,uts.sysname,uts.machine,uts.release);
@@ -1676,11 +1672,12 @@ handle_cmdline_args(void)
        args.dspdev = ng_dev.dsp;
     if (NULL == args.vbidev)
        args.vbidev = ng_dev.vbi;
-    if (NULL == args.device) {
-       args.device = ng_dev.video;
-    } else {
+    if (args.device || args.driver)
        args.xv_video = 0;
-    }
+    if (NULL == args.device)
+       args.device = ng_dev.video;
+    if (NULL == args.driver)
+       args.driver = ng_dev.driver;
     if (0 != args.xv_port)
        args.xv_video = 1;
 }
@@ -1752,7 +1749,7 @@ vtx_to_tt(struct vt_page *vtp)
     struct fmt_page pg[1];
     struct fmt_char l[W+2];
 #define L (l+1)
-    
+
     t = 0;
     fmt_page(fmt,pg,vtp);
     memset(tt,0,sizeof(tt));
@@ -1777,21 +1774,21 @@ vtx_to_tt(struct vt_page *vtp)
            }
            L[x] = c;
        }
-       
+
        /* delay fg and attr changes as far as possible */
        for (x = 0; x < W; ++x)
            if (L[x].ch == ' ') {
                L[x].fg = L[x-1].fg;
                L[x].attr = L[x-1].attr;
            }
-       
+
        /* move fg and attr changes to prev bg change point */
        for (x = W-1; x >= 0; x--)
            if (L[x].ch == ' ' && L[x].bg == L[x+1].bg) {
                L[x].fg = L[x+1].fg;
                L[x].attr = L[x+1].attr;
            }
-       
+
        /* now render the line */
        lcolor = -1;
        tt[t].line = y;
@@ -1839,7 +1836,7 @@ tt_pick_subtitle(struct TEXTELEM *tt)
            i--;
        tt[i].len = 0;
     }
-    
+
     return tt;
 }
 
@@ -1868,7 +1865,7 @@ x11_vbi_event(struct vbi_event *ev, void *user)
 {
     struct vbi_page pg;
     struct vbi_rect rect;
-    
+
     switch (ev->type) {
     case VBI_EVENT_NETWORK:
        strcpy(x11_vbi_station,ev->ev.network.name);
@@ -2062,7 +2059,7 @@ void xt_kbd_init(Widget tv)
     list = cfg_list_entries("eventmap");
     if (NULL == list)
        return;
-    
+
     for (; *list != NULL; list++) {
        if (1 != sscanf(*list,"kbd-key-%31s",key))
            continue;
@@ -2092,7 +2089,7 @@ Pixmap bm_no;
 static unsigned char bm_yes_data[] = {
     /* -------- -------- */  0x00,
     /* -------- -------- */  0x00,
-    /* ------xx xx------ */  0x18,                        
+    /* ------xx xx------ */  0x18,
     /* ----xxxx xxxx---- */  0x3c,
     /* ----xxxx xxxx---- */  0x3c,
     /* ------xx xx------ */  0x18,
@@ -2106,7 +2103,7 @@ void
 create_pointers(Widget app_shell)
 {
     XColor white,red,dummy;
-    
+
     left_ptr = XCreateFontCursor(dpy,XC_left_ptr);
     menu_ptr = XCreateFontCursor(dpy,XC_right_ptr);
     qu_ptr   = XCreateFontCursor(dpy,XC_question_arrow);
@@ -2116,7 +2113,7 @@ create_pointers(Widget app_shell)
            XRecolorCursor(dpy,left_ptr,&red,&white);
            XRecolorCursor(dpy,menu_ptr,&red,&white);
            XRecolorCursor(dpy,qu_ptr,&red,&white);
-       } 
+       }
     }
 }
 
@@ -2163,7 +2160,7 @@ int xt_vm_randr_input_init(Display *dpy)
     if (debug)
        fprintf(stderr,"xt: checking for vidmode extention ...\n");
     xfree_vm_init(dpy);
-    
+
     /* input */
     if (debug)
        fprintf(stderr,"xt: checking for lirc ...\n");
@@ -2184,7 +2181,7 @@ int xt_vm_randr_input_init(Display *dpy)
 int xt_main_loop()
 {
     XEvent event;
-    
+
     if (debug)
        fprintf(stderr,"xt: enter main event loop... \n");
     signal(SIGHUP,SIG_IGN); /* don't really need a tty ... */

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to