[MPlayer-cvslog] r23925 - in trunk: configure etc/codecs.conf libao2/ao_v4l2.c libao2/audio_out.c libvo/video_out.c libvo/vo_v4l2.c

ben subversion at mplayerhq.hu
Sun Jul 29 21:20:55 CEST 2007


Author: ben
Date: Sun Jul 29 21:20:55 2007
New Revision: 23925

Log:
v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)

Added:
   trunk/libao2/ao_v4l2.c
      - copied, changed from r23866, /trunk/libao2/ao_ivtv.c
   trunk/libvo/vo_v4l2.c
      - copied, changed from r23866, /trunk/libvo/vo_ivtv.c
Modified:
   trunk/configure
   trunk/etc/codecs.conf
   trunk/libao2/audio_out.c
   trunk/libvo/video_out.c

Modified: trunk/configure
==============================================================================
--- trunk/configure	(original)
+++ trunk/configure	Sun Jul 29 21:20:55 2007
@@ -358,6 +358,7 @@ Video output:
   --enable-dxr2            enable DXR2 video output [autodetect]
   --enable-dxr3            enable DXR3/H+ video output [autodetect]
   --enable-ivtv            enable IVTV TV-Out video output [autodetect]
+  --enable-v4l2            enable V4L2 Decoder audio/video output [autodetect]
   --enable-dvb             enable DVB video output [autodetect]
   --enable-dvbhead         enable DVB video output (HEAD version) [autodetect]
   --enable-mga             enable mga_vid video output [disable]
@@ -539,6 +540,7 @@ _dvbhead=auto
 _dxr2=auto
 _dxr3=auto
 _ivtv=auto
+_v4l2=auto
 _iconv=auto
 _langinfo=auto
 _rtc=auto
@@ -846,6 +848,8 @@ for ac_option do
   --disable-dxr3)	_dxr3=no	;;
   --enable-ivtv)        _ivtv=yes       ;;
   --disable-ivtv)       _ivtv=no        ;;
+  --enable-v4l2)        _v4l2=yes       ;;
+  --disable-v4l2)       _v4l2=no        ;;
   --enable-iconv)	_iconv=yes	;;
   --disable-iconv)	_iconv=no	;;
   --enable-langinfo)	_langinfo=yes	;;
@@ -4823,6 +4827,39 @@ fi
 echores "$_ivtv"
 
 
+echocheck "V4L2 MPEG Decoder"
+if test "$_v4l2" = auto ; then
+  cat > $TMPC << EOF
+#include <stdlib.h>
+#include <inttypes.h>
+#include <linux/types.h>
+#include <linux/videodev2.h>
+#include <linux/version.h>
+int main(void) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+  return 0;
+#else
+  return -1;
+#endif
+}
+EOF
+  _v4l2=no
+  cc_check && _v4l2=yes
+fi
+if test "$_v4l2" = yes ; then
+  _def_v4l2='#define HAVE_V4L2_DECODER 1'
+  _vosrc="$_vosrc vo_v4l2.c"
+  _vomodules="v4l2 $_vomodules"
+  _aosrc="$_aosrc ao_v4l2.c"
+  _aomodules="v4l2 $_aomodules"
+else
+  _def_v4l2='#undef HAVE_V4L2_DECODER'
+  _novomodules="v4l2 $_novomodules"
+  _noaomodules="v4l2 $_noaomodules"
+fi
+echores "$_v4l2"
+
+
 
 #########
 # AUDIO #
@@ -8241,6 +8278,7 @@ $_def_fbdev
 $_def_dxr2
 $_def_dxr3
 $_def_ivtv
+$_def_v4l2
 $_def_dvb
 $_def_dvb_in
 $_def_svga

Modified: trunk/etc/codecs.conf
==============================================================================
--- trunk/etc/codecs.conf	(original)
+++ trunk/etc/codecs.conf	Sun Jul 29 21:20:55 2007
@@ -35,7 +35,7 @@ videocodec zmbv
 ; Note: mpegpes is preferred for hw decoders:
 
 videocodec mpegpes
-  info "MPEG-PES output (.mpg or DXR3/IVTV/DVB card)"
+  info "MPEG-PES output (.mpg or DXR3/IVTV/DVB/V4L2 card)"
   comment "for hardware decoding"
   status working
   format 0x10000001  ; mpeg 1

Copied: trunk/libao2/ao_v4l2.c (from r23866, /trunk/libao2/ao_ivtv.c)
==============================================================================
--- /trunk/libao2/ao_ivtv.c	(original)
+++ trunk/libao2/ao_v4l2.c	Sun Jul 29 21:20:55 2007
@@ -1,9 +1,6 @@
 /*
- *  Copyright (C) 2006 Benjamin Zores
- *   Audio output for WinTV PVR-150/250/350 (a.k.a IVTV) cards.
- *    through Connexant hardware MPEG decoder.
- *   See http://ivtvdriver.org/index.php/Main_Page for more details on the
- *    cards supported by the ivtv driver.
+ *  Copyright (C) 2007 Benjamin Zores
+ *   Audio output for V4L2 hardware MPEG decoders.
  *
  *   This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -40,13 +37,13 @@ static int freq = 0;
 
 static ao_info_t info = 
 {
-  "IVTV MPEG Audio Decoder output",
-  "ivtv",
+  "V4L2 MPEG Audio Decoder output",
+  "v4l2",
   "Benjamin Zores",
   ""
 };
 
-LIBAO_EXTERN(ivtv)
+LIBAO_EXTERN (v4l2)
 
 /* to set/get/query special features/parameters */
 static int
@@ -59,15 +56,15 @@ control (int cmd,void *arg)
 static int
 init (int rate, int channels, int format, int flags)
 {
-  extern int ivtv_fd;
+  extern int v4l2_fd;
 
-  if (ivtv_fd < 0)
+  if (v4l2_fd < 0)
     return 0;
 
   if (format != AF_FORMAT_MPEG2)
   {
     mp_msg (MSGT_AO, MSGL_FATAL,
-            "AO: [ivtv] can only handle MPEG audio streams.\n");
+            "AO: [v4l2] can only handle MPEG audio streams.\n");
     return 0;
   }
   
@@ -144,12 +141,12 @@ get_space (void)
 static int
 play (void *data, int len, int flags)
 {
-  extern int ivtv_write (unsigned char *data, int len);
+  extern int v4l2_write (unsigned char *data, int len);
   
   if (ao_data.format != AF_FORMAT_MPEG2)
     return 0;
 
-  send_mpeg_pes_packet (data, len, MPEG_AUDIO_ID, ao_data.pts, 2, ivtv_write);
+  send_mpeg_pes_packet (data, len, MPEG_AUDIO_ID, ao_data.pts, 2, v4l2_write);
 
   return len;
 }

Modified: trunk/libao2/audio_out.c
==============================================================================
--- trunk/libao2/audio_out.c	(original)
+++ trunk/libao2/audio_out.c	Sun Jul 29 21:20:55 2007
@@ -68,6 +68,9 @@ extern ao_functions_t audio_out_dxr2;
 #ifdef HAVE_IVTV
 extern ao_functions_t audio_out_ivtv;
 #endif
+#ifdef HAVE_V4L2_DECODER
+extern ao_functions_t audio_out_v4l2;
+#endif
 extern ao_functions_t audio_out_mpegpes;
 extern ao_functions_t audio_out_pcm;
 extern ao_functions_t audio_out_pss;
@@ -131,6 +134,9 @@ ao_functions_t* audio_out_drivers[] =
 #ifdef HAVE_IVTV
         &audio_out_ivtv,
 #endif
+#ifdef HAVE_V4L2_DECODER
+        &audio_out_v4l2,
+#endif
         &audio_out_null,
 // should not be auto-selected:
 	&audio_out_pcm,

Modified: trunk/libvo/video_out.c
==============================================================================
--- trunk/libvo/video_out.c	(original)
+++ trunk/libvo/video_out.c	Sun Jul 29 21:20:55 2007
@@ -103,6 +103,9 @@ extern vo_functions_t video_out_dxr3;
 #ifdef HAVE_IVTV
 extern vo_functions_t video_out_ivtv;
 #endif
+#ifdef HAVE_V4L2_DECODER
+extern vo_functions_t video_out_v4l2;
+#endif
 #ifdef HAVE_JPEG
 extern vo_functions_t video_out_jpeg;
 #endif
@@ -214,6 +217,9 @@ vo_functions_t* video_out_drivers[] =
 #ifdef HAVE_IVTV
         &video_out_ivtv,
 #endif
+#ifdef HAVE_V4L2_DECODER
+        &video_out_v4l2,
+#endif
 #ifdef HAVE_ZR
 	&video_out_zr,
 	&video_out_zr2,

Copied: trunk/libvo/vo_v4l2.c (from r23866, /trunk/libvo/vo_ivtv.c)
==============================================================================
--- /trunk/libvo/vo_ivtv.c	(original)
+++ trunk/libvo/vo_v4l2.c	Sun Jul 29 21:20:55 2007
@@ -1,10 +1,6 @@
 /*
- *  Copyright (C) 2006 Benjamin Zores
- *   Video output for WinTV PVR-150/250/350 (a.k.a IVTV) cards.
- *   TV-Out through hardware MPEG decoder.
- *   Based on some old code from ivtv driver authors.
- *   See http://ivtvdriver.org/index.php/Main_Page for more details on the
- *    cards supported by the ivtv driver.
+ *  Copyright (C) 2007 Benjamin Zores
+ *   Video output for V4L2 hardware MPEG decoders.
  *
  *   This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -36,7 +32,6 @@
 #include <inttypes.h>
 #include <linux/types.h>
 #include <linux/videodev2.h>
-#include <linux/ivtv.h>
 #include <linux/ioctl.h>
 
 #include "mp_msg.h"
@@ -46,10 +41,9 @@
 #include "libmpdemux/mpeg_packetizer.h"
 
 #define DEFAULT_MPEG_DECODER "/dev/video16"
-#define IVTV_VO_HDR "VO: [ivtv]"
+#define V4L2_VO_HDR "VO: [v4l2]"
 
-/* ivtv private */
-int ivtv_fd = -1;
+int v4l2_fd = -1;
 static vo_mpegpes_t *pes;
 
 /* suboptions */
@@ -64,53 +58,20 @@ static opt_t subopts[] = {
 
 static vo_info_t info = 
 {
-  "IVTV MPEG Video Decoder TV-Out",
-  "ivtv",
+  "V4L2 MPEG Video Decoder Output",
+  "v4l2",
   "Benjamin Zores",
   ""
 };
-LIBVO_EXTERN (ivtv)
-
-/* ivtv internals */
-
-static uint32_t
-ivtv_reset (int blank_screen)
-{
-  struct ivtv_cfg_stop_decode sd;
-  struct ivtv_cfg_start_decode sd1;
-  int flags = 0;
-
-  if (blank_screen)
-    flags |= IVTV_STOP_FL_HIDE_FRAME;
-  sd.flags = flags;
- 
-  if (ioctl (ivtv_fd, IVTV_IOC_STOP_DECODE, &sd) < 0)
-  {
-    mp_msg (MSGT_VO, MSGL_ERR,
-            "IVTV_IOC_STOP_DECODE: %s\n", strerror (errno));
-    return 1;
-  }
-  
-  sd1.gop_offset = 0;
-  sd1.muted_audio_frames = 0;
-  
-  if (ioctl (ivtv_fd, IVTV_IOC_START_DECODE, &sd1) < 0)
-  {
-    mp_msg (MSGT_VO, MSGL_ERR,
-            "IVTV_IOC_START_DECODE: %s\n", strerror (errno));
-    return 1;
-  }
-
-  return 0;
-}
+LIBVO_EXTERN (v4l2)
 
 int
-ivtv_write (unsigned char *data, int len)
+v4l2_write (unsigned char *data, int len)
 {
-  if (ivtv_fd < 0)
+  if (v4l2_fd < 0)
     return 0;
   
-  return write (ivtv_fd, data, len);
+  return write (v4l2_fd, data, len);
 }
 
 /* video out functions */
@@ -127,13 +88,14 @@ static int
 preinit (const char *arg)
 {
   struct v4l2_output vout;
+  struct v4l2_ext_controls ctrls;
   int err;
 
   if (subopt_parse (arg, subopts) != 0)
   {
     mp_msg (MSGT_VO, MSGL_FATAL,
-            "\n-vo ivtv command line help:\n"
-            "Example: mplayer -vo ivtv:device=/dev/video16:output=2\n"
+            "\n-vo v4l2 command line help:\n"
+            "Example: mplayer -vo v4l2:device=/dev/video16:output=2\n"
             "\nOptions:\n"
             "  device=/dev/videoX\n"
             "    Name of the MPEG decoder device file.\n"
@@ -146,19 +108,31 @@ preinit (const char *arg)
   if (!device)
     device = strdup (DEFAULT_MPEG_DECODER);    
   
-  ivtv_fd = open (device, O_RDWR);
-  if (ivtv_fd < 0)
+  v4l2_fd = open (device, O_RDWR);
+  if (v4l2_fd < 0)
   {  
     free (device);
-    mp_msg (MSGT_VO, MSGL_FATAL, "%s %s\n", IVTV_VO_HDR, strerror (errno));
+    mp_msg (MSGT_VO, MSGL_FATAL, "%s %s\n", V4L2_VO_HDR, strerror (errno));
     return -1;
   }
 
+  /* check for device hardware MPEG decoding capability */
+  ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; 
+  ctrls.count = 0; 
+  ctrls.controls = NULL;
+  
+  if (ioctl (v4l2_fd, VIDIOC_G_EXT_CTRLS, &ctrls) < 0)
+  {
+    free (device);
+    mp_msg (MSGT_OPEN, MSGL_FATAL, "%s %s\n", V4L2_VO_HDR, strerror (errno));
+    return -1;
+  }
+  
   /* list available outputs */
   vout.index = 0;
   err = 1;
-  mp_msg (MSGT_VO, MSGL_INFO, "%s Available video outputs: ", IVTV_VO_HDR);
-  while (ioctl (ivtv_fd, VIDIOC_ENUMOUTPUT, &vout) >= 0)
+  mp_msg (MSGT_VO, MSGL_INFO, "%s Available video outputs: ", V4L2_VO_HDR);
+  while (ioctl (v4l2_fd, VIDIOC_ENUMOUTPUT, &vout) >= 0)
   {
     err = 0;
     mp_msg (MSGT_VO, MSGL_INFO, "'#%d, %s' ", vout.index, vout.name);
@@ -176,43 +150,40 @@ preinit (const char *arg)
   /* set user specified output */
   if (output != -1)
   {
-    if (ioctl (ivtv_fd, VIDIOC_S_OUTPUT, &output) < 0)
+    if (ioctl (v4l2_fd, VIDIOC_S_OUTPUT, &output) < 0)
     {
       mp_msg (MSGT_VO, MSGL_ERR,
-              "%s can't set output (%s)\n", IVTV_VO_HDR, strerror (errno));
+              "%s can't set output (%s)\n", V4L2_VO_HDR, strerror (errno));
       free (device);
       return -1;
     }
   }
 
   /* display device name */
-  mp_msg (MSGT_VO, MSGL_INFO, "%s using %s\n", IVTV_VO_HDR, device);
+  mp_msg (MSGT_VO, MSGL_INFO, "%s using %s\n", V4L2_VO_HDR, device);
   free (device);
 
   /* display current video output */
-  if (ioctl (ivtv_fd, VIDIOC_G_OUTPUT, &output) == 0)
+  if (ioctl (v4l2_fd, VIDIOC_G_OUTPUT, &output) == 0)
   {
     vout.index = output;
-    if (ioctl (ivtv_fd, VIDIOC_ENUMOUTPUT, &vout) < 0)
+    if (ioctl (v4l2_fd, VIDIOC_ENUMOUTPUT, &vout) < 0)
     {
       mp_msg (MSGT_VO, MSGL_ERR,
-              "%s can't get output (%s).\n", IVTV_VO_HDR, strerror (errno));
+              "%s can't get output (%s).\n", V4L2_VO_HDR, strerror (errno));
       return -1;
     }
     else
       mp_msg (MSGT_VO, MSGL_INFO,
-              "%s video output: %s\n", IVTV_VO_HDR, vout.name);
+              "%s video output: %s\n", V4L2_VO_HDR, vout.name);
   }
   else
   {
     mp_msg (MSGT_VO, MSGL_ERR,
-            "%s can't get output (%s).\n", IVTV_VO_HDR, strerror (errno));
+            "%s can't get output (%s).\n", V4L2_VO_HDR, strerror (errno));
     return -1;
   }
   
-  /* clear output */
-  ivtv_reset (1);
-
   return 0;
 }
 
@@ -232,15 +203,15 @@ draw_frame (uint8_t * src[])
 static void
 flip_page (void)
 {
-  if (ivtv_fd < 0)
+  if (v4l2_fd < 0)
     return;
 
   if (!pes)
     return;
 
   send_mpeg_pes_packet (pes->data, pes->size, pes->id,
-                         pes->timestamp ? pes->timestamp : vo_pts, 2,
-                         ivtv_write);
+                        pes->timestamp ? pes->timestamp : vo_pts, 2,
+                        v4l2_write);
 
   /* ensure flip_page() won't be called twice */
   pes = NULL;
@@ -255,15 +226,12 @@ draw_slice (uint8_t *image[], int stride
 static void
 uninit (void)
 {
-  if (ivtv_fd < 0)
+  if (v4l2_fd < 0)
     return;
 
-  /* clear output */
-  ivtv_reset (1);
-
   /* close device */
-  close (ivtv_fd);
-  ivtv_fd = -1;
+  close (v4l2_fd);
+  v4l2_fd = -1;
 }
 
 static void
@@ -286,13 +254,6 @@ control (uint32_t request, void *data, .
 {
   switch (request)
   {
-  case VOCTRL_PAUSE: 
-  case VOCTRL_RESUME: 
-    return ivtv_reset (0);
-
-  case VOCTRL_RESET: 
-    return ivtv_reset (1);
-
   case VOCTRL_QUERY_FORMAT:
     return query_format (*((uint32_t*) data));
   }



More information about the MPlayer-cvslog mailing list