Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
MPlayer libv4l patch
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
M
Guru
Guru


Joined: 12 Dec 2006
Posts: 432

PostPosted: Tue Dec 09, 2008 8:06 pm    Post subject: MPlayer libv4l patch Reply with quote

From version 2.6.27 gspca module is included in kernel and libv4l library is necessary for webcams to work. That also means that many apps has to be patched. There is some progress page about this at http://linuxtv.org/v4lwiki/index.php/Libv4l_Progress , also you can check fedora page about this http://fedoraproject.org/wiki/Features/BetterWebcamSupport , it seems that fedora allready has patches for many apps. I mainly use Mplayer and since it didn't worked with LD_PRELOAD hack I first tried to find one, and there is post at mailing list for rc2 version with patch but devs are not much interested in this because of 3rd party library. Since you mostly have to replace ioctl,open,munmap with v4l1_ioctl or v4l2_close etc. I made a patch for current snapshot in portage p28058 and finaly my webcam works with mplayer, it never did because of stupid cam format. Maybe patch will be of some use for others.


mplayer-1.0_rc2_p28058.patch
Code:

--- mplayer-1.0_rc2_p28058.orig.ebuild   2008-12-02 04:41:26.000000000 +0100
+++ mplayer-1.0_rc2_p28058.ebuild   2008-12-09 19:52:49.000000000 +0100
@@ -120,7 +120,9 @@
    xvid? ( media-libs/xvid )
    X? ( x11-libs/libXxf86vm
       x11-libs/libXext
-   )"
+   )
+   v4l? ( media-libs/libv4l )
+   v4l2? ( media-libs/libv4l )"
 
 DEPEND="${RDEPEND}
    doc? ( dev-libs/libxslt )
@@ -207,6 +209,9 @@
 
    cd "${S}"
 
+   # mplayer libv4l
+   epatch "${FILESDIR}/mplayer-libv4l.patch"
+
    # Fix x264 compilation, bug 240347
    epatch "${FILESDIR}/mplayer-1.0_rc2_p27725-libx264.patch"


mplayer-libv4l.patch
Code:

--- mplayer-1.0_rc2_p28058.orig/configure   2008-12-02 03:56:18.000000000 +0100
+++ mplayer-1.0_rc2_p28058/configure   2008-12-09 19:48:13.000000000 +0100
@@ -5132,6 +5132,8 @@
   _vomodules="v4l2 $_vomodules"
   _aosrc="$_aosrc ao_v4l2.c"
   _aomodules="v4l2 $_aomodules"
+  libs_mplayer="$libs_mplayer `$_pkg_config --libs libv4l2`"
+  libs_mencoder="$libs_mencoder `$_pkg_config --libs libv4l2`" 
 else
   _def_v4l2='#undef CONFIG_V4L2_DECODER'
   _novomodules="v4l2 $_novomodules"
@@ -7224,6 +7226,8 @@
   _def_tv_v4l='#define CONFIG_TV_V4L 1'
   _def_tv_v4l1='#define CONFIG_TV_V4L1 1'
   _inputmodules="tv-v4l $_inputmodules"
+  libs_mplayer="$libs_mplayer `$_pkg_config --libs libv4l1`"
+  libs_mencoder="$libs_mencoder `$_pkg_config --libs libv4l1`" 
 else
   _noinputmodules="tv-v4l1 $_noinputmodules"
   _def_tv_v4l='#undef CONFIG_TV_V4L'
@@ -7250,6 +7254,8 @@
   _def_tv_v4l='#define CONFIG_TV_V4L 1'
   _def_tv_v4l2='#define CONFIG_TV_V4L2 1'
   _inputmodules="tv-v4l2 $_inputmodules"
+  libs_mplayer="$libs_mplayer `$_pkg_config --libs libv4l2`"
+  libs_mencoder="$libs_mencoder `$_pkg_config --libs libv4l2`" 
 else
   _noinputmodules="tv-v4l2 $_noinputmodules"
   _def_tv_v4l2='#undef CONFIG_TV_V4L2'
--- mplayer-1.0_rc2_p28058.orig/stream/tvi_v4l.c   2008-12-02 03:56:23.000000000 +0100
+++ mplayer-1.0_rc2_p28058/stream/tvi_v4l.c   2008-12-09 19:41:58.000000000 +0100
@@ -28,6 +28,7 @@
 #define _LINUX_TIME_H
 
 #include <linux/videodev.h>
+#include <libv4l1.h>
 #include <unistd.h>
 #include <sys/mman.h>
 #include <stdlib.h>
@@ -347,7 +348,7 @@
         }
 
         priv->audio[i].audio = i;
-        if (ioctl(priv->video_fd, VIDIOCGAUDIO, &priv->audio[i]) == -1)
+        if (v4l1_ioctl(priv->video_fd, VIDIOCGAUDIO, &priv->audio[i]) == -1)
         {
             mp_msg(MSGT_TV, MSGL_ERR, "ioctl get audio failed: %s\n", strerror(errno));
             break;
@@ -376,10 +377,10 @@
             }
             if (reqmode >= 0) priv->audio[i].mode = reqmode;
         }
-        ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[i]);
+        v4l1_ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[i]);
 
         // get the parameters back
-        if (ioctl(priv->video_fd, VIDIOCGAUDIO, &priv->audio[i]) == -1)
+        if (v4l1_ioctl(priv->video_fd, VIDIOCGAUDIO, &priv->audio[i]) == -1)
         {
             mp_msg(MSGT_TV, MSGL_ERR, "ioctl get audio failed: %s\n", strerror(errno));
             break;
@@ -458,7 +459,7 @@
     priv->audio_ringbuffer = NULL;
     priv->audio_skew_buffer = NULL;
 
-    priv->video_fd = open(priv->video_device, O_RDWR);
+    priv->video_fd = v4l1_open(priv->video_device, O_RDWR);
     mp_msg(MSGT_TV, MSGL_DBG2, "Video fd: %d, %p\n", priv->video_fd,
         priv->video_device);
     if (priv->video_fd == -1)
@@ -469,7 +470,7 @@
     }
 
     /* check for v4l2 */
-    if (ioctl(priv->video_fd, VIDIOC_QUERYCAP, &priv->capability) == 0) {
+    if (v4l1_ioctl(priv->video_fd, VIDIOC_QUERYCAP, &priv->capability) == 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "=================================================================\n");
         mp_msg(MSGT_TV, MSGL_ERR, " WARNING: YOU ARE USING V4L DEMUXER WITH V4L2 DRIVERS!!!\n");
         mp_msg(MSGT_TV, MSGL_ERR, " As the V4L1 compatibility layer is broken, this may not work.\n");
@@ -479,7 +480,7 @@
     }
 
     /* get capabilities (priv->capability is needed!) */
-    if (ioctl(priv->video_fd, VIDIOCGCAP, &priv->capability) == -1)
+    if (v4l1_ioctl(priv->video_fd, VIDIOCGCAP, &priv->capability) == -1)
     {
         mp_msg(MSGT_TV, MSGL_ERR, "ioctl get capabilites failed: %s\n", strerror(errno));
         goto err;
@@ -508,7 +509,7 @@
         struct mjpeg_params bparm;
         struct mjpeg_requestbuffers breq;          /* buffer requests */
 
-        if (ioctl(priv->video_fd, MJPIOC_G_PARAMS, &bparm) < 0)
+        if (v4l1_ioctl(priv->video_fd, MJPIOC_G_PARAMS, &bparm) < 0)
         {
             mp_msg(MSGT_TV, MSGL_ERR,
                    "  MJP: Error getting video parameters: %s\n", strerror(errno));
@@ -537,14 +538,14 @@
         mp_msg(MSGT_TV, MSGL_INFO, "  MJP: setting params to decimation: %d, quality: %d\n",
                bparm.decimation, bparm.quality);
 
-        if (ioctl(priv->video_fd, MJPIOC_S_PARAMS, &bparm) < 0)
+        if (v4l1_ioctl(priv->video_fd, MJPIOC_S_PARAMS, &bparm) < 0)
         {
             mp_msg(MSGT_TV, MSGL_ERR,
                    "  MJP: Error setting video parameters: %s\n", strerror(errno));
             goto err;
         }
 
-        if (ioctl(priv->video_fd, MJPIOC_G_PARAMS, &bparm) < 0)
+        if (v4l1_ioctl(priv->video_fd, MJPIOC_G_PARAMS, &bparm) < 0)
         {
             mp_msg(MSGT_TV, MSGL_ERR,
                    "  MJP: Error getting video parameters: %s\n", strerror(errno));
@@ -568,7 +569,7 @@
         if (priv->tv_param->buffer_size >= 0)
             priv->mjpeg_bufsize = priv->tv_param->buffer_size*1024;
         breq.size  = priv -> mjpeg_bufsize;
-        if (ioctl(priv->video_fd, MJPIOC_REQBUFS,&(breq)) < 0)
+        if (v4l1_ioctl(priv->video_fd, MJPIOC_REQBUFS,&(breq)) < 0)
         {
            mp_msg (MSGT_TV, MSGL_ERR,
               "  MJP: Error requesting video buffers: %s\n", strerror(errno));
@@ -578,7 +579,7 @@
                "  MJP: Got %ld buffers of size %ld KB\n",
                breq.count, breq.size/1024);
 
-        priv -> mmap = mmap(0, breq.count * breq.size,
+        priv -> mmap = v4l1_mmap(0, breq.count * breq.size,
             PROT_READ|PROT_WRITE, MAP_SHARED, priv->video_fd, 0);
         if (priv -> mmap == MAP_FAILED)
         {
@@ -596,7 +597,7 @@
     for (i = 0; i < priv->capability.channels; i++)
     {
         priv->channels[i].channel = i;
-        if (ioctl(priv->video_fd, VIDIOCGCHAN, &priv->channels[i]) == -1)
+        if (v4l1_ioctl(priv->video_fd, VIDIOCGCHAN, &priv->channels[i]) == -1)
         {
             mp_msg(MSGT_TV, MSGL_ERR, "ioctl get channel failed: %s\n", strerror(errno));
             break;
@@ -667,7 +668,7 @@
         free(priv->buf);
 err:
     if (priv->video_fd != -1)
-        close(priv->video_fd);
+        v4l1_close(priv->video_fd);
     return 0;
 }
 
@@ -684,7 +685,7 @@
     priv->priv_vbi=NULL;
 
     if(priv->vbi_fd){
-        close(priv->vbi_fd);
+        v4l1_close(priv->vbi_fd);
         priv->vbi_fd=0;
     }
 
@@ -711,23 +712,23 @@
 
     if (priv->capability.audios) {
         priv->audio[priv->audio_id].flags |= VIDEO_AUDIO_MUTE;
-        ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
+        v4l1_ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
     }
 
     if ( priv->tv_param->mjpeg )
     {
         num = -1;
-        if (ioctl(priv->video_fd, MJPIOC_QBUF_CAPT, &num) < 0)
+        if (v4l1_ioctl(priv->video_fd, MJPIOC_QBUF_CAPT, &num) < 0)
             mp_msg(MSGT_TV, MSGL_ERR, "\n  MJP: ioctl MJPIOC_QBUF_CAPT failed: %s\n", strerror(errno));
     }
     else
     {
         // We need to munmap as close don't close mem mappings
-        if(munmap(priv->mmap,priv->mbuf.size))
+        if(v4l1_munmap(priv->mmap,priv->mbuf.size))
             mp_msg(MSGT_TV, MSGL_ERR, "Munmap failed: %s\n",strerror(errno));
     }
 
-    if(close(priv->video_fd))
+    if(v4l1_close(priv->video_fd))
         mp_msg(MSGT_TV, MSGL_ERR, "Close tv failed: %s\n",strerror(errno));
 
     audio_in_uninit(&priv->audio_in);
@@ -792,20 +793,20 @@
 
     priv->vbi_dev=strdup(device);
 
-    vbi_fd=open(priv->vbi_dev,O_RDWR);
+    vbi_fd=v4l1_open(priv->vbi_dev,O_RDWR);
     if(vbi_fd<0){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi: could not open device %s\n",priv->vbi_dev);
         return  TVI_CONTROL_FALSE;
     }
     
-    if(ioctl(vbi_fd,VIDIOCGCAP,&cap)<0){
+    if(v4l1_ioctl(vbi_fd,VIDIOCGCAP,&cap)<0){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi: Query capatibilities failed for %s\n",priv->vbi_dev);
-        close(vbi_fd);
+        v4l1_close(vbi_fd);
         return  TVI_CONTROL_FALSE;
     }
     if(!cap.type & VID_TYPE_CAPTURE){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi: %s is not capture device\n",priv->vbi_dev);
-        close(vbi_fd);
+        v4l1_close(vbi_fd);
         return  TVI_CONTROL_FALSE;
     }
 
@@ -822,7 +823,7 @@
         return TVI_CONTROL_FALSE;
 
     memset(&fmt,0,sizeof(struct vbi_format));
-    if((res=ioctl(priv->vbi_fd,VIDIOCGVBIFMT,&fmt))<0){
+    if((res=v4l1_ioctl(priv->vbi_fd,VIDIOCGVBIFMT,&fmt))<0){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi_get_props: Query format failed: %x\n",res);
         return  TVI_CONTROL_FALSE;
     }
@@ -905,7 +906,7 @@
     int bytes_per_sample;
     struct video_window win;
 
-    if (ioctl(priv->video_fd, VIDIOCGPICT, &priv->picture) == -1)
+    if (v4l1_ioctl(priv->video_fd, VIDIOCGPICT, &priv->picture) == -1)
     {
         mp_msg(MSGT_TV, MSGL_ERR, "ioctl get picture failed: %s\n", strerror(errno));
         return 0;
@@ -927,7 +928,7 @@
         priv->picture.brightness, priv->picture.hue,
         priv->picture.colour, priv->picture.contrast);
 
-    if (ioctl(priv->video_fd, VIDIOCSPICT, &priv->picture) == -1)
+    if (v4l1_ioctl(priv->video_fd, VIDIOCSPICT, &priv->picture) == -1)
     {
         mp_msg(MSGT_TV, MSGL_ERR, "ioctl set picture failed: %s\n", strerror(errno));
         mp_msg(MSGT_TV, MSGL_ERR, "The 'outfmt' of '%s' is likely not supported by your card\n",
@@ -943,13 +944,13 @@
     win.chromakey = -1;
     win.flags = 0;
     win.clipcount = 0;
-    if (ioctl(priv->video_fd, VIDIOCSWIN, &win) == -1)
+    if (v4l1_ioctl(priv->video_fd, VIDIOCSWIN, &win) == -1)
         mp_msg(MSGT_TV, MSGL_ERR, "ioctl set window failed: %s\n", strerror(errno));
 
     if ( !priv->tv_param->mjpeg )
     {
         /* map grab buffer */
-        if (ioctl(priv->video_fd, VIDIOCGMBUF, &priv->mbuf) == -1)
+        if (v4l1_ioctl(priv->video_fd, VIDIOCGMBUF, &priv->mbuf) == -1)
         {
             mp_msg(MSGT_TV, MSGL_ERR, "ioctl get mbuf failed: %s\n", strerror(errno));
             return 0;
@@ -957,7 +958,7 @@
 
         mp_msg(MSGT_TV, MSGL_V, "mbuf: size=%d, frames=%d\n",
             priv->mbuf.size, priv->mbuf.frames);
-        priv->mmap = mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE,
+        priv->mmap = v4l1_mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE,
                           MAP_SHARED, priv->video_fd, 0);
         if (priv->mmap == (unsigned char *)-1)
         {
@@ -996,7 +997,7 @@
         pmode.mode = VID_PLAY_NORMAL;
         pmode.p1 = 1;
         pmode.p2 = 0;
-        if (ioctl(priv->video_fd, VIDIOCSPLAYMODE, &pmode) == -1)
+        if (v4l1_ioctl(priv->video_fd, VIDIOCSPLAYMODE, &pmode) == -1)
         {
             mp_msg(MSGT_TV, MSGL_ERR, "ioctl set play mode failed: %s\n", strerror(errno));
 //          return 0;
@@ -1006,7 +1007,7 @@
 
 #if 0
     // initialize video capture
-    if (ioctl(priv->video_fd, VIDIOCCAPTURE, &one) == -1)
+    if (v4l1_ioctl(priv->video_fd, VIDIOCCAPTURE, &one) == -1)
     {
         mp_msg(MSGT_TV, MSGL_ERR, "FATAL: ioctl ccapture failed: %s\n", strerror(errno));
         return 0;
@@ -1108,7 +1109,7 @@
                priv->audio[priv->audio_id].volume, priv->audio[priv->audio_id].bass, priv->audio[priv->audio_id].treble,
                priv->audio[priv->audio_id].balance, audio_mode2name(priv->audio[priv->audio_id].mode));
         mp_msg(MSGT_TV, MSGL_V, " chan=%d\n", priv->audio_channels[priv->audio_id]);
-        ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
+        v4l1_ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
     }
 
 #ifdef CONFIG_TV_TELETEXT
@@ -1233,14 +1234,14 @@
             priv->height = *(int *)arg;
             return TVI_CONTROL_TRUE;
         case TVI_CONTROL_VID_GET_PICTURE:
-            if (ioctl(priv->video_fd, VIDIOCGPICT, &priv->picture) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCGPICT, &priv->picture) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get picture failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
             }
             return TVI_CONTROL_TRUE;
         case TVI_CONTROL_VID_SET_PICTURE:
-            if (ioctl(priv->video_fd, VIDIOCSPICT, &priv->picture) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCSPICT, &priv->picture) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set picture failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
@@ -1283,7 +1284,7 @@
         {
             unsigned long freq;
 
-            if (ioctl(priv->video_fd, VIDIOCGFREQ, &freq) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCGFREQ, &freq) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get freq failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
@@ -1302,7 +1303,7 @@
 
             if (priv->capability.audios) {
                 priv->audio[priv->audio_id].flags |= VIDEO_AUDIO_MUTE;
-                ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
+                v4l1_ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
             }
 
             mp_msg(MSGT_TV, MSGL_V, "requested frequency: %.3f\n", (float)freq/16);
@@ -1311,7 +1312,7 @@
 //          if (priv->tuner.flags & VIDEO_TUNER_LOW)
 //              freq *= 1000;
 //          mp_msg(MSGT_TV, MSGL_V, " requesting from driver: freq=%.3f\n", (float)freq/16);
-            if (ioctl(priv->video_fd, VIDIOCSFREQ, &freq) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCSFREQ, &freq) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set freq failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
@@ -1320,14 +1321,14 @@
 
             if (priv->capability.audios) {
                 priv->audio[priv->audio_id].flags &= ~VIDEO_AUDIO_MUTE;
-                ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
+                v4l1_ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
             }
 
             return TVI_CONTROL_TRUE;
         }
         case TVI_CONTROL_TUN_GET_TUNER:
         {
-            if (ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get tuner failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
@@ -1339,7 +1340,7 @@
         }
         case TVI_CONTROL_TUN_SET_TUNER:
         {
-            if (ioctl(priv->video_fd, VIDIOCSTUNER, &priv->tuner) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCSTUNER, &priv->tuner) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set tuner failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
@@ -1382,13 +1383,13 @@
 
             priv->channels[priv->act_channel].norm = supported_norms[norm_index].input_norm;
 
-            if (ioctl(priv->video_fd, VIDIOCSCHAN, &priv->channels[priv->act_channel]) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCSCHAN, &priv->channels[priv->act_channel]) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set chan failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
             }
 
-            if (ioctl(priv->video_fd, VIDIOCGCAP, &priv->capability) == -1) {
+            if (v4l1_ioctl(priv->video_fd, VIDIOCGCAP, &priv->capability) == -1) {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get capabilites failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
             }
@@ -1413,7 +1414,7 @@
         }
         case TVI_CONTROL_TUN_GET_SIGNAL:
         {
-            if (ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get tuner failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
@@ -1463,7 +1464,7 @@
 
             priv->act_channel = i;
 
-            if (ioctl(priv->video_fd, VIDIOCGCHAN, &priv->channels[i]) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCGCHAN, &priv->channels[i]) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get channel failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
@@ -1490,7 +1491,7 @@
                     chan = priv->channels[i];
             }
 
-            if (ioctl(priv->video_fd, VIDIOCSCHAN, &chan) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCSCHAN, &chan) == -1)
             {
                 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set chan failed: %s\n", strerror(errno));
                 return TVI_CONTROL_FALSE;
@@ -1547,7 +1548,7 @@
     else
         priv->audio[priv->audio_id].flags &= ~VIDEO_AUDIO_MUTE;
     }
-    if(ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id])<0)
+    if(v4l1_ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id])<0)
         return 0;
     return 1;
 }
@@ -1557,7 +1558,7 @@
 static inline void copy_frame(priv_t *priv, unsigned char *dest, unsigned char *source)
 {
     if(priv->tv_param->automute>0){
-        if (ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) >= 0) {
+        if (v4l1_ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) >= 0) {
             if(priv->tv_param->automute<<8>priv->tuner.signal){
                 fill_blank_frame(dest,priv->bytesperline * priv->height,priv->format);
                 set_mute(priv,1);
@@ -1598,7 +1599,7 @@
         mp_msg(MSGT_TV, MSGL_INFO, "  MJP: gonna capture ! \n");
         for (i=0; i < priv->nbuf; i++) {
             num = i;
-            if (ioctl(priv->video_fd, MJPIOC_QBUF_CAPT, &num) < 0)
+            if (v4l1_ioctl(priv->video_fd, MJPIOC_QBUF_CAPT, &num) < 0)
                 mp_msg(MSGT_TV, MSGL_ERR,
                        "\n  MJP: ioctl MJPIOC_QBUF_CAPT b failed: %s\n", strerror(errno));
         }
@@ -1606,7 +1607,7 @@
     else
     {
         for (i=0; i < priv->nbuf; i++) {
-            if (ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[i]) == -1)
+            if (v4l1_ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[i]) == -1)
                 mp_msg(MSGT_TV, MSGL_ERR, "\nioctl mcapture failed: %s\n", strerror(errno));
         }
     }
@@ -1641,12 +1642,12 @@
 
             if ( priv->tv_param->mjpeg )
             {
-                while (ioctl(priv->video_fd, MJPIOC_SYNC, &priv->buf[frame].frame) < 0 &&
+                while (v4l1_ioctl(priv->video_fd, MJPIOC_SYNC, &priv->buf[frame].frame) < 0 &&
                        (errno == EAGAIN || errno == EINTR));
             }
             else
             {
-                while (ioctl(priv->video_fd, VIDIOCSYNC, &priv->buf[frame].frame) < 0 &&
+                while (v4l1_ioctl(priv->video_fd, VIDIOCSYNC, &priv->buf[frame].frame) < 0 &&
                        (errno == EAGAIN || errno == EINTR));
             }
             mp_dbg(MSGT_TV, MSGL_DBG3, "\npicture sync failed\n");
@@ -1764,7 +1765,7 @@
             if ( priv->tv_param->mjpeg )
             {
                 num = frame;
-                if (ioctl(priv->video_fd, MJPIOC_QBUF_CAPT, &num) < 0)
+                if (v4l1_ioctl(priv->video_fd, MJPIOC_QBUF_CAPT, &num) < 0)
                 {
                     mp_msg(MSGT_TV, MSGL_ERR, "\n  MJP: ioctl MJPIOC_QBUF_CAPT end failed: %s\n",
                            strerror(errno));
@@ -1773,7 +1774,7 @@
             }
             else
             {
-                if (ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[frame]) == -1)
+                if (v4l1_ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[frame]) == -1)
                 {
                     mp_msg(MSGT_TV, MSGL_ERR, "\nioctl mcapture failed: %s\n", strerror(errno));
                     continue;
--- mplayer-1.0_rc2_p28058.orig/stream/tvi_v4l2.c   2008-12-02 03:56:23.000000000 +0100
+++ mplayer-1.0_rc2_p28058/stream/tvi_v4l2.c   2008-12-09 19:41:34.000000000 +0100
@@ -41,6 +41,7 @@
 #endif
 #include <linux/types.h>
 #include <linux/videodev2.h>
+#include <libv4l2.h>
 #include "mp_msg.h"
 #include "libmpcodecs/img_format.h"
 #include "libaf/af_format.h"
@@ -432,7 +433,7 @@
     int i;
 
     priv->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-    if ((i = ioctl(priv->video_fd, VIDIOC_G_FMT, &priv->format)) < 0) {
+    if ((i = v4l2_ioctl(priv->video_fd, VIDIOC_G_FMT, &priv->format)) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get format failed: %s\n",
                info.short_name, strerror(errno));
     }
@@ -448,11 +449,11 @@
     v4l2_std_id id;
     int i=0;
 
-    if (ioctl(priv->video_fd, VIDIOC_G_STD, &id) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_G_STD, &id) < 0) {
         struct v4l2_streamparm      parm;
 
         parm.type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
-        if(ioctl(priv->video_fd, VIDIOC_G_PARM, &parm) >= 0) {
+        if(v4l2_ioctl(priv->video_fd, VIDIOC_G_PARM, &parm) >= 0) {
             mp_msg(MSGT_TV, MSGL_WARN, "%s: your device driver does not support VIDIOC_G_STD ioctl,"
                    " VIDIOC_G_PARM was used instead.\n", info.short_name);
             priv->standard.index=0;
@@ -467,7 +468,7 @@
     }
     do {
         priv->standard.index = i++;
-        if (ioctl(priv->video_fd, VIDIOC_ENUMSTD, &priv->standard) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUMSTD, &priv->standard) < 0) {
             return -1;
         }
     } while (priv->standard.id != id);
@@ -487,7 +488,7 @@
     struct v4l2_control control;
     control.id = V4L2_CID_AUDIO_MUTE;
     control.value = value;
-    if (ioctl(priv->video_fd, VIDIOC_S_CTRL, &control) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_S_CTRL, &control) < 0) {
         mp_msg(MSGT_TV,MSGL_ERR,"%s: ioctl set mute failed: %s\n",
                info.short_name, strerror(errno));
         return 0;
@@ -502,7 +503,7 @@
 static int set_control(priv_t *priv, struct v4l2_control *control, int val_signed) {
     struct v4l2_queryctrl        qctrl;
     qctrl.id = control->id;
-    if (ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query control failed: %s\n",
          info.short_name, strerror(errno));
         return TVI_CONTROL_FALSE;
@@ -527,7 +528,7 @@
     }
     
 
-    if (ioctl(priv->video_fd, VIDIOC_S_CTRL, control) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_S_CTRL, control) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR,"%s: ioctl set %s %d failed: %s\n",
          info.short_name, qctrl.name, control->value, strerror(errno));
         return TVI_CONTROL_FALSE;
@@ -546,13 +547,13 @@
     struct v4l2_queryctrl        qctrl;
 
     qctrl.id = control->id;
-    if (ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query control failed: %s\n",
          info.short_name, strerror(errno));
         return TVI_CONTROL_FALSE;
     }
 
-    if (ioctl(priv->video_fd, VIDIOC_G_CTRL, control) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_G_CTRL, control) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR,"%s: ioctl get %s failed: %s\n",
          info.short_name, qctrl.name, strerror(errno));
         return TVI_CONTROL_FALSE;
@@ -594,33 +595,33 @@
 
     priv->vbi_dev=strdup(device);
 
-    vbi_fd=open(priv->vbi_dev,O_RDWR);
+    vbi_fd=v4l2_open(priv->vbi_dev,O_RDWR);
     if(vbi_fd<0){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi: could not open device %s\n",priv->vbi_dev);
         return  TVI_CONTROL_FALSE;
     }
     
-    if(ioctl(vbi_fd,VIDIOC_QUERYCAP,&cap)<0){
+    if(v4l2_ioctl(vbi_fd,VIDIOC_QUERYCAP,&cap)<0){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi: Query capatibilities failed for %s\n",priv->vbi_dev);
-        close(vbi_fd);
+        v4l2_close(vbi_fd);
         return  TVI_CONTROL_FALSE;
     }
     if(!cap.capabilities & V4L2_CAP_VBI_CAPTURE){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi: %s does not support VBI capture\n",priv->vbi_dev);
-        close(vbi_fd);
+        v4l2_close(vbi_fd);
         return  TVI_CONTROL_FALSE;
     }
 
     memset(&fmt,0,sizeof(struct v4l2_format));
     fmt.type=V4L2_BUF_TYPE_VBI_CAPTURE;
-    if((res=ioctl(vbi_fd,VIDIOC_G_FMT,&fmt))<0){
+    if((res=v4l2_ioctl(vbi_fd,VIDIOC_G_FMT,&fmt))<0){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi: Query format failed: %x\n",res);
-        close(vbi_fd);
+        v4l2_close(vbi_fd);
         return  TVI_CONTROL_FALSE;
     }
     if(fmt.fmt.vbi.sample_format!=V4L2_PIX_FMT_GREY){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi: format 0x%x is not supported\n",fmt.fmt.vbi.sample_format);
-        close(vbi_fd);
+        v4l2_close(vbi_fd);
         return TVI_CONTROL_FALSE;
     }
     priv->vbi_fd=vbi_fd;
@@ -637,7 +638,7 @@
 
     memset(&fmt,0,sizeof(struct v4l2_format));
     fmt.type=V4L2_BUF_TYPE_VBI_CAPTURE;
-    if((res=ioctl(priv->vbi_fd,VIDIOC_G_FMT,&fmt))<0){
+    if((res=v4l2_ioctl(priv->vbi_fd,VIDIOC_G_FMT,&fmt))<0){
         mp_msg(MSGT_TV,MSGL_ERR,"vbi_get_props: Query format failed: %x\n",res);
         return  TVI_CONTROL_FALSE;
     }
@@ -753,7 +754,7 @@
         priv->mp_format = *(int *)arg;
         mp_msg(MSGT_TV, MSGL_V, "%s: set format: %s\n", info.short_name,
                pixfmt2name(priv->format.fmt.pix.pixelformat));
-        if (ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set format failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -775,7 +776,7 @@
         priv->format.fmt.pix.width = *(int *)arg;
         mp_msg(MSGT_TV, MSGL_V, "%s: set width: %d\n", info.short_name,
                *(int *)arg);
-        if (ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set width failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -795,7 +796,7 @@
         priv->format.fmt.pix.field = V4L2_FIELD_ANY;
         mp_msg(MSGT_TV, MSGL_V, "%s: set height: %d\n", info.short_name,
                *(int *)arg);
-        if (ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set height failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -882,7 +883,7 @@
     case TVI_CONTROL_TUN_GET_FREQ:
         frequency.tuner = 0;
         frequency.type  = V4L2_TUNER_ANALOG_TV;
-        if (ioctl(priv->video_fd, VIDIOC_G_FREQUENCY, &frequency) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_G_FREQUENCY, &frequency) < 0) {
             mp_msg(MSGT_TV,MSGL_ERR,"%s: ioctl get frequency failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -897,7 +898,7 @@
         frequency.tuner = 0;
         frequency.type  = V4L2_TUNER_ANALOG_TV;
         frequency.frequency = *(int *)arg;
-        if (ioctl(priv->video_fd, VIDIOC_S_FREQUENCY, &frequency) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FREQUENCY, &frequency) < 0) {
             mp_msg(MSGT_TV,MSGL_ERR,"%s: ioctl set frequency failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -909,7 +910,7 @@
         return TVI_CONTROL_TRUE;
     case TVI_CONTROL_TUN_GET_TUNER:
         mp_msg(MSGT_TV, MSGL_V, "%s: get tuner\n",info.short_name);
-        if (ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get tuner failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -917,7 +918,7 @@
         return TVI_CONTROL_TRUE;
     case TVI_CONTROL_TUN_SET_TUNER:
         mp_msg(MSGT_TV, MSGL_V, "%s: set tuner\n",info.short_name);
-        if (ioctl(priv->video_fd, VIDIOC_S_TUNER, &priv->tuner) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_S_TUNER, &priv->tuner) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set tuner failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -927,7 +928,7 @@
         *(int *)arg = priv->standard.index;
         return TVI_CONTROL_TRUE;
     case TVI_CONTROL_TUN_GET_SIGNAL:
-        if (ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get tuner failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -936,13 +937,13 @@
         return TVI_CONTROL_TRUE;
     case TVI_CONTROL_TUN_SET_NORM:
         priv->standard.index = *(int *)arg;
-        if (ioctl(priv->video_fd, VIDIOC_ENUMSTD, &priv->standard) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUMSTD, &priv->standard) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl enum norm failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
         }
         mp_msg(MSGT_TV, MSGL_V, "%s: set norm: %s\n", info.short_name, priv->standard.name);
-        if (ioctl(priv->video_fd, VIDIOC_S_STD, &priv->standard.id) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_S_STD, &priv->standard.id) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set norm failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -955,7 +956,7 @@
                 struct v4l2_standard standard;
                 memset(&standard, 0, sizeof(standard));
                 standard.index = i;
-                if (-1 == ioctl(priv->video_fd, VIDIOC_ENUMSTD, &standard))
+                if (-1 == v4l2_ioctl(priv->video_fd, VIDIOC_ENUMSTD, &standard))
                     return TVI_CONTROL_FALSE;
                 if (!strcasecmp(standard.name, (char *)arg)) {
                     *(int *)arg = i;
@@ -965,7 +966,7 @@
             return TVI_CONTROL_FALSE;
         }
     case TVI_CONTROL_SPC_GET_INPUT:
-        if (ioctl(priv->video_fd, VIDIOC_G_INPUT, (int *)arg) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_G_INPUT, (int *)arg) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get input failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -974,12 +975,12 @@
     case TVI_CONTROL_SPC_SET_INPUT:
         mp_msg(MSGT_TV, MSGL_V, "%s: set input: %d\n", info.short_name, *(int *)arg);
         priv->input.index = *(int *)arg;
-        if (ioctl(priv->video_fd, VIDIOC_ENUMINPUT, &priv->input) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUMINPUT, &priv->input) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl enum input failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
         }
-        if (ioctl(priv->video_fd, VIDIOC_S_INPUT, (int *)arg) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_S_INPUT, (int *)arg) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set input failed: %s\n",
                    info.short_name, strerror(errno));
             return TVI_CONTROL_FALSE;
@@ -1096,7 +1097,7 @@
     priv->priv_vbi=NULL;
 
     if(priv->vbi_fd){
-        close(priv->vbi_fd);
+        v4l2_close(priv->vbi_fd);
         priv->vbi_fd=0;
     }
 
@@ -1120,7 +1121,7 @@
         dropped = frames - priv->frames;
 
         /* turn off streaming */
-        if (ioctl(priv->video_fd, VIDIOC_STREAMOFF, &(priv->map[0].buf.type)) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_STREAMOFF, &(priv->map[0].buf.type)) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl streamoff failed: %s\n",
                    info.short_name, strerror(errno));
         }
@@ -1130,12 +1131,12 @@
         memset(&buf,0,sizeof(buf));
         buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
         buf.memory = V4L2_MEMORY_MMAP;
-        while (!ioctl(priv->video_fd, VIDIOC_DQBUF, &buf));
+        while (!v4l2_ioctl(priv->video_fd, VIDIOC_DQBUF, &buf));
     }
 
     /* unmap all buffers */
     for (i = 0; i < priv->mapcount; i++) {
-        if (munmap(priv->map[i].addr, priv->map[i].len) < 0) {
+        if (v4l2_munmap(priv->map[i].addr, priv->map[i].len) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: munmap capture buffer failed: %s\n",
                    info.short_name, strerror(errno));
         }
@@ -1153,7 +1154,7 @@
     /* free memory and close device */
     free(priv->map);                priv->map = NULL;
     priv->mapcount = 0;
-    if(priv->video_fd!=-1)close(priv->video_fd);        priv->video_fd  = -1;
+    if(priv->video_fd!=-1)v4l2_close(priv->video_fd);        priv->video_fd  = -1;
     free(priv->video_dev);        priv->video_dev = NULL;
 
     if (priv->video_ringbuffer) {
@@ -1196,7 +1197,7 @@
     priv->audio_initialized = 0;
 
     /* Open the video device. */
-    priv->video_fd = open(priv->video_dev, O_RDWR);
+    priv->video_fd = v4l2_open(priv->video_dev, O_RDWR);
     if (priv->video_fd < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: unable to open '%s': %s\n",
                info.short_name, priv->video_dev, strerror(errno));
@@ -1210,7 +1211,7 @@
     ** Query the video capabilities and current settings
     ** for further control calls.
     */
-    if (ioctl(priv->video_fd, VIDIOC_QUERYCAP, &priv->capability) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYCAP, &priv->capability) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query capabilities failed: %s\n",
                info.short_name, strerror(errno));
         uninit(priv);
@@ -1234,7 +1235,7 @@
     ** otherwise set some nice defaults
     */
     if (priv->capability.capabilities & V4L2_CAP_TUNER) {
-        if (ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get tuner failed: %s\n",
                    info.short_name, strerror(errno));
             uninit(priv);
@@ -1281,7 +1282,7 @@
         struct v4l2_standard standard;
         memset(&standard, 0, sizeof(standard));
         standard.index = i;
-        if (-1 == ioctl(priv->video_fd, VIDIOC_ENUMSTD, &standard))
+        if (-1 == v4l2_ioctl(priv->video_fd, VIDIOC_ENUMSTD, &standard))
             break;
         mp_msg(MSGT_TV, MSGL_INFO, " %d = %s;", i, standard.name);
     }
@@ -1290,12 +1291,12 @@
         struct v4l2_input input;
 
         input.index = i;
-        if (ioctl(priv->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
             break;
         }
         mp_msg(MSGT_TV, MSGL_INFO, " %d = %s;", i, input.name);
     }
-    if (ioctl(priv->video_fd, VIDIOC_G_INPUT, &i) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_G_INPUT, &i) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get input failed: %s\n",
                info.short_name, strerror(errno));
     }
@@ -1305,7 +1306,7 @@
 
         fmtdesc.index = i;
         fmtdesc.type  = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-        if (ioctl(priv->video_fd, VIDIOC_ENUM_FMT, &fmtdesc) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_ENUM_FMT, &fmtdesc) < 0) {
             break;
         }
         mp_msg(MSGT_TV, MSGL_V, " Format %-6s (%2d bits, %s): %s\n",
@@ -1319,7 +1320,7 @@
     if (getfmt(priv) < 0) return 0;
     priv->format.fmt.pix.width  = 640;
     priv->format.fmt.pix.height = 480;
-    if (ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_S_FMT, &priv->format) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set format failed: %s\n",
                info.short_name, strerror(errno));
         uninit(priv);
@@ -1333,7 +1334,7 @@
         if (priv->tv_param->amode >= 0) {
             mp_msg(MSGT_TV, MSGL_V, "%s: setting audio mode\n", info.short_name);
             priv->tuner.audmode = amode2v4l(priv->tv_param->amode);
-            if (ioctl(priv->video_fd, VIDIOC_S_TUNER, &priv->tuner) < 0) {
+            if (v4l2_ioctl(priv->video_fd, VIDIOC_S_TUNER, &priv->tuner) < 0) {
                 mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl set tuner failed: %s\n",
                        info.short_name, strerror(errno));
                 return TVI_CONTROL_FALSE;
@@ -1496,7 +1497,7 @@
     
     request.type  = V4L2_BUF_TYPE_VIDEO_CAPTURE;
     request.memory = V4L2_MEMORY_MMAP;
-    if (ioctl(priv->video_fd, VIDIOC_REQBUFS, &request) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_REQBUFS, &request) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl request buffers failed: %s\n",
                info.short_name, strerror(errno));
         return 0;
@@ -1515,14 +1516,14 @@
         priv->map[i].buf.index = i;
         priv->map[i].buf.type  = V4L2_BUF_TYPE_VIDEO_CAPTURE;
         priv->map[i].buf.memory  = V4L2_MEMORY_MMAP;
-        if (ioctl(priv->video_fd, VIDIOC_QUERYBUF, &(priv->map[i].buf)) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_QUERYBUF, &(priv->map[i].buf)) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query buffer failed: %s\n",
                    info.short_name, strerror(errno));
             free(priv->map);
             priv->map = NULL;
             return 0;
         }
-        priv->map[i].addr = mmap (0, priv->map[i].buf.length, PROT_READ |
+        priv->map[i].addr = v4l2_mmap (0, priv->map[i].buf.length, PROT_READ |
                                   PROT_WRITE, MAP_SHARED, priv->video_fd, priv->map[i].buf.m.offset);
         if (priv->map[i].addr == MAP_FAILED) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: mmap capture buffer failed: %s\n",
@@ -1534,7 +1535,7 @@
         /* count up to make sure this is correct everytime */
         priv->mapcount++;
 
-        if (ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl queue buffer failed: %s\n",
                    info.short_name, strerror(errno));
             return 0;
@@ -1565,7 +1566,7 @@
 {
     dest->framesize=len;
     if(priv->tv_param->automute>0){
-        if (ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) >= 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_G_TUNER, &priv->tuner) >= 0) {
             if(priv->tv_param->automute<<8>priv->tuner.signal){
            fill_blank_frame(dest->data,dest->framesize,fcc_vl2mp(priv->format.fmt.pix.pixelformat));
            set_mute(priv,1);
@@ -1596,7 +1597,7 @@
     prev_skew = 0;
 
     mp_msg(MSGT_TV, MSGL_V, "%s: going to capture\n", info.short_name);
-    if (ioctl(priv->video_fd, VIDIOC_STREAMON, &(priv->format.type)) < 0) {
+    if (v4l2_ioctl(priv->video_fd, VIDIOC_STREAMON, &(priv->format.type)) < 0) {
         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl streamon failed: %s\n",
                info.short_name, strerror(errno));
         return 0;
@@ -1643,7 +1644,7 @@
         memset(&buf,0,sizeof(buf));
         buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
         buf.memory = V4L2_MEMORY_MMAP;
-        ret = ioctl(priv->video_fd, VIDIOC_DQBUF, &buf);
+        ret = v4l2_ioctl(priv->video_fd, VIDIOC_DQBUF, &buf);
 
         if (ret < 0) {
             /*
@@ -1661,14 +1662,14 @@
                 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
                 buf.memory = V4L2_MEMORY_MMAP;
                 buf.index = i;
-                ret = ioctl(priv->video_fd, VIDIOC_QUERYBUF, &buf);
+                ret = v4l2_ioctl(priv->video_fd, VIDIOC_QUERYBUF, &buf);
                 if (ret < 0) {
                     mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query buffer failed: %s, idx = %d\n",
                            info.short_name, strerror(errno), buf.index);
                     return 0;
                 }
                 if ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE)) == V4L2_BUF_FLAG_MAPPED) {
-                    if (ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
+                    if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
                         mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl queue buffer failed: %s\n",
                                info.short_name, strerror(errno));
                         return 0;
@@ -1759,7 +1760,7 @@
             priv->video_tail = (priv->video_tail+1)%priv->video_buffer_size_current;
             priv->video_cnt++;
         }
-        if (ioctl(priv->video_fd, VIDIOC_QBUF, &buf) < 0) {
+        if (v4l2_ioctl(priv->video_fd, VIDIOC_QBUF, &buf) < 0) {
             mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl queue buffer failed: %s\n",
                    info.short_name, strerror(errno));
             return 0;


Last edited by M on Sat Apr 11, 2009 2:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
no4b
Bodhisattva
Bodhisattva


Joined: 18 Jan 2004
Posts: 774
Location: Tarnów, Poland

PostPosted: Wed Dec 10, 2008 6:16 pm    Post subject: Reply with quote

Quote:
+ )
+ v4l? ( media-libs/libv4l )
+ v4l2? ( media-libs/libv4l )"


What about people that don't use mplayer for webcams? I don't need libv4l for watching TV therefore I don't want to have this library installed.
_________________
GTK2/GNOME - The weakest link!
Back to top
View user's profile Send private message
M
Guru
Guru


Joined: 12 Dec 2006
Posts: 432

PostPosted: Wed Dec 10, 2008 7:58 pm    Post subject: Reply with quote

Than that people shouldn't use this patch, this was not sugested for inclusion in portage you know, it was quick edit so I can try and use it with my webcam.
Back to top
View user's profile Send private message
no4b
Bodhisattva
Bodhisattva


Joined: 18 Jan 2004
Posts: 774
Location: Tarnów, Poland

PostPosted: Wed Dec 10, 2008 9:14 pm    Post subject: Reply with quote

Ok, I thought that you will be interested in inclusion in portage.
_________________
GTK2/GNOME - The weakest link!
Back to top
View user's profile Send private message
M
Guru
Guru


Joined: 12 Dec 2006
Posts: 432

PostPosted: Thu Dec 11, 2008 8:16 am    Post subject: Reply with quote

Well, I don't think devs will be interested in maintaining this patch since mplayer devs do not show interest yet, maybe we need bug that will track all apps that needs to be patched, xawtv, gstreamer etc. I know that vlc upstream has allready solved this... And than maybe introduce libv4l use flag or something like that. Fedora has patches for a lot of apps so we can start collecting them on one place. I don't know how many users are affected with this but sooner or later gentoo will need to adapt too.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum