X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fv4l2%2Fv4l2.c;h=e06c80d3514e114a3b719f3fe3b1fda7d0c84770;hb=8ea8856cfdf4e4e3599799a2ce6d8b44553232e2;hp=14419bc757ac9c3623716275e4f0e41a8f0b86f3;hpb=2ced1b142c63be49320ec6f6d0513a007fa76171;p=vlc diff --git a/modules/access/v4l2/v4l2.c b/modules/access/v4l2/v4l2.c index 14419bc757..e06c80d351 100644 --- a/modules/access/v4l2/v4l2.c +++ b/modules/access/v4l2/v4l2.c @@ -1,7 +1,7 @@ /***************************************************************************** * v4l2.c : Video4Linux2 input module for VLC ***************************************************************************** - * Copyright (C) 2002-2009 the VideoLAN team + * Copyright (C) 2002-2009 VLC authors and VideoLAN * Copyright (C) 2011-2012 Rémi Denis-Courmont * * Authors: Benjamin Pracht @@ -9,14 +9,14 @@ * Antoine Cellerier * Dennis Lou * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License @@ -32,13 +32,21 @@ #include #include +#include +#include + #include #include +#include #include "v4l2.h" -#define DEVICE_TEXT N_( "Device" ) -#define DEVICE_LONGTEXT N_("Video device node." ) +#define VIDEO_DEVICE_TEXT N_( "Video capture device" ) +#define VIDEO_DEVICE_LONGTEXT N_("Video capture device node." ) +#define VBI_DEVICE_TEXT N_("VBI capture device") +#define VBI_DEVICE_LONGTEXT N_( \ + "The device node where VBI data can be read " \ + " (for closed captions) " ) #define STANDARD_TEXT N_( "Standard" ) #define STANDARD_LONGTEXT N_( \ "Video standard (Default, SECAM, PAL, or NTSC)." ) @@ -62,6 +70,15 @@ /*#define FPS_TEXT N_( "Frame rate" ) #define FPS_LONGTEXT N_( "Maximum frame rate to use (0 = no limits)." )*/ +#define RADIO_DEVICE_TEXT N_( "Radio device" ) +#define RADIO_DEVICE_LONGTEXT N_("Radio tuner device node." ) +#define FREQUENCY_TEXT N_("Frequency") +#define FREQUENCY_LONGTEXT N_( \ + "Tuner frequency in Hz or kHz (see debug output)" ) +#define TUNER_AUDIO_MODE_TEXT N_("Audio mode") +#define TUNER_AUDIO_MODE_LONGTEXT N_( \ + "Tuner audio mono/stereo and track selection." ) + #define CTRL_RESET_TEXT N_( "Reset controls" ) #define CTRL_RESET_LONGTEXT N_( "Reset controls to defaults." ) #define BRIGHTNESS_TEXT N_( "Brightness" ) @@ -120,7 +137,7 @@ static const char *const power_freq_user[] = { N_("Unspecified"), N_("Off"), N_("50 Hz"), N_("60 Hz"), N_("Automatic"), }; #define BKLT_COMPENSATE_TEXT N_( "Backlight compensation" ) -#define BKLT_COMPENSATE_LONGTEXT N_( "Backlight compensation." ) +#define BKLT_COMPENSATE_LONGTEXT BKLT_COMPENSATE_TEXT #define BAND_STOP_FILTER_TEXT N_( "Band-stop filter" ) #define BAND_STOP_FILTER_LONGTEXT N_( \ "Cut a light band induced by fluorescent lighting (unit undocumented)." ) @@ -176,13 +193,6 @@ static const char *const colorfx_user[] = { N_("Unspecified"), N_("None"), "To list available controls, increase verbosity (-vvv) " \ "or use the v4l2-ctl application." ) -#define FREQUENCY_TEXT N_("Frequency") -#define FREQUENCY_LONGTEXT N_( \ - "Tuner frequency in Hz or kHz (see debug output)" ) -#define TUNER_AUDIO_MODE_TEXT N_("Audio mode") -#define TUNER_AUDIO_MODE_LONGTEXT N_( \ - "Tuner audio mono/stereo and track selection." ) - #define ASPECT_TEXT N_("Picture aspect-ratio n:m") #define ASPECT_LONGTEXT N_("Define input picture aspect-ratio to use. Default is 4:3" ) @@ -262,15 +272,19 @@ static const char *const psz_tuner_audio_modes_list_text[] = { }; vlc_module_begin () - set_shortname( N_("Video4Linux2") ) - set_description( N_("Video4Linux2 input") ) + set_shortname( N_("V4L") ) + set_description( N_("Video4Linux input") ) set_category( CAT_INPUT ) set_subcategory( SUBCAT_INPUT_ACCESS ) set_section( N_( "Video input" ), NULL ) add_loadfile( CFG_PREFIX "dev", "/dev/video0", - DEVICE_TEXT, DEVICE_LONGTEXT, false ) + VIDEO_DEVICE_TEXT, VIDEO_DEVICE_LONGTEXT, false ) change_safe() +#ifdef ZVBI_COMPILED + add_loadfile( CFG_PREFIX "vbidev", NULL, + VBI_DEVICE_TEXT, VBI_DEVICE_LONGTEXT, false ) +#endif add_string( CFG_PREFIX "standard", "", STANDARD_TEXT, STANDARD_LONGTEXT, false ) change_string_list( standards_vlc, standards_user ) @@ -302,6 +316,9 @@ vlc_module_begin () add_obsolete_bool( CFG_PREFIX "use-libv4l2" ) /* since 2.1.0 */ set_section( N_( "Tuner" ), NULL ) + add_loadfile( CFG_PREFIX "radio-dev", "/dev/radio0", + RADIO_DEVICE_TEXT, RADIO_DEVICE_LONGTEXT, false ) + change_safe() add_obsolete_integer( CFG_PREFIX "tuner" ) /* since 2.1.0 */ add_integer( CFG_PREFIX "tuner-frequency", -1, FREQUENCY_TEXT, FREQUENCY_LONGTEXT, true ) @@ -405,11 +422,17 @@ vlc_module_begin () add_submodule () add_shortcut( "v4l", "v4l2", "v4l2c" ) - set_description( N_("Video4Linux2 Compressed A/V") ) + set_description( N_("Video4Linux compressed A/V input") ) set_capability( "access", 0 ) /* use these when open as access_demux fails; VLC will use another demux */ set_callbacks( AccessOpen, AccessClose ) + add_submodule () + add_shortcut ("radio" /*, "fm", "am" */) + set_description (N_("Video4Linux radio tuner")) + set_capability ("access_demux", 0) + set_callbacks (RadioOpen, RadioClose) + vlc_module_end () /** @@ -440,6 +463,53 @@ void ParseMRL( vlc_object_t *obj, const char *mrl ) } } +int OpenDevice (vlc_object_t *obj, const char *path, uint32_t *restrict caps) +{ + msg_Dbg (obj, "opening device '%s'", path); + + int rawfd = vlc_open (path, O_RDWR); + if (rawfd == -1) + { + msg_Err (obj, "cannot open device '%s': %m", path); + return -1; + } + + int fd = v4l2_fd_open (rawfd, 0); + if (fd == -1) + { + msg_Warn (obj, "cannot initialize user-space library: %m"); + /* fallback to direct kernel mode anyway */ + fd = rawfd; + } + + /* Get device capabilites */ + struct v4l2_capability cap; + if (v4l2_ioctl (fd, VIDIOC_QUERYCAP, &cap) < 0) + { + msg_Err (obj, "cannot get device capabilities: %m"); + v4l2_close (fd); + return -1; + } + + msg_Dbg (obj, "device %s using driver %s (version %u.%u.%u) on %s", + cap.card, cap.driver, (cap.version >> 16) & 0xFF, + (cap.version >> 8) & 0xFF, cap.version & 0xFF, cap.bus_info); + + if (cap.capabilities & V4L2_CAP_DEVICE_CAPS) + { + msg_Dbg (obj, " with capabilities 0x%08"PRIX32" " + "(overall 0x%08"PRIX32")", cap.device_caps, cap.capabilities); + *caps = cap.device_caps; + } + else + { + msg_Dbg (obj, " with unknown capabilities " + "(overall 0x%08"PRIX32")", cap.capabilities); + *caps = cap.capabilities; + } + return fd; +} + v4l2_std_id var_InheritStandard (vlc_object_t *obj, const char *varname) { char *name = var_InheritString (obj, varname);