Commit 5d498a39 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

v4l2: copy header (with minor changes) from Linux 3.5

As agreed last week with upstream, that's basicailly the least insane
way to deal with the ever changing and expanding V4L2 API. This allows
compiling VLC with old Linux headers and run it well on a new Linux
kernel. This also avoids a pile of backward compatibility hacks.

A few other userspace tool already copy videodev2.h like that.
parent 775d319e
......@@ -1780,14 +1780,6 @@ AS_IF([test "$enable_v4l2" != "no"], [
AC_CHECK_HEADERS([linux/videodev2.h sys/videoio.h], [
have_v4l2="yes"
])
AC_CHECK_DECLS([V4L2_CTRL_TYPE_BITMASK,V4L2_CTRL_TYPE_INTEGER_MENU],,, [
#ifdef HAVE_LINUX_VIDEODEV2_H
# include <linux/videodev2.h>
#endif
#ifdef HAVE_SYS_VIDEOIO_H
# include <sys/videoio.h>
#endif
])
])
AS_IF([test "$have_v4l2" = "yes"], [
AS_IF([test "${enable_pvr}" = "yes"], [
......
......@@ -148,6 +148,7 @@ libaccess_shm_plugin_la_DEPENDENCIES =
libvlc_LTLIBRARIES += $(LTLIBaccess_shm)
libv4l2_plugin_la_SOURCES = \
v4l2/videodev2.h \
v4l2/v4l2.c \
v4l2/video.c \
v4l2/demux.c \
......
......@@ -154,12 +154,8 @@ static int ControlSetCallback (vlc_object_t *obj, const char *var,
{
case V4L2_CTRL_TYPE_INTEGER:
case V4L2_CTRL_TYPE_MENU:
#if HAVE_DECL_V4L2_CTRL_TYPE_BITMASK
case V4L2_CTRL_TYPE_BITMASK:
#endif
#if HAVE_DECL_V4L2_CTRL_TYPE_INTEGER_MENU
case V4L2_CTRL_TYPE_INTEGER_MENU:
#endif
ret = ControlSet (ctrl, cur.i_int);
break;
case V4L2_CTRL_TYPE_BOOLEAN:
......@@ -195,9 +191,7 @@ static void ControlsReset (vlc_object_t *obj, vlc_v4l2_ctrl_t *list)
{
case V4L2_CTRL_TYPE_INTEGER:
case V4L2_CTRL_TYPE_MENU:
#if HAVE_DECL_V4L2_CTRL_TYPE_INTEGER_MENU
case V4L2_CTRL_TYPE_INTEGER_MENU:
#endif
var_SetInteger (obj, list->name, list->default_value);
break;
case V4L2_CTRL_TYPE_BOOLEAN:
......@@ -260,9 +254,7 @@ next:
case V4L2_CTRL_TYPE_INTEGER:
case V4L2_CTRL_TYPE_BOOLEAN:
case V4L2_CTRL_TYPE_MENU:
#if HAVE_DECL_V4L2_CTRL_TYPE_INTEGER_MENU
case V4L2_CTRL_TYPE_INTEGER_MENU:
#endif
{
long val = strtol (value, &end, 0);
if (*end)
......@@ -291,7 +283,7 @@ next:
case V4L2_CTRL_TYPE_STRING:
ControlSetStr (c, value);
break;
#if HAVE_DECL_V4L2_CTRL_TYPE_BITMASK
case V4L2_CTRL_TYPE_BITMASK:
{
unsigned long val = strtoul (value, &end, 0);
......@@ -304,7 +296,7 @@ next:
ControlSet (c, val);
break;
}
#endif
default:
msg_Err (obj, "setting \"%s\" not supported", name);
goto next;
......@@ -610,7 +602,6 @@ static vlc_v4l2_ctrl_t *ControlAddString (vlc_object_t *obj, int fd,
return c;
}
#if HAVE_DECL_V4L2_CTRL_TYPE_BITMASK
static vlc_v4l2_ctrl_t *ControlAddBitMask (vlc_object_t *obj, int fd,
const struct v4l2_queryctrl *query)
{
......@@ -646,9 +637,7 @@ static vlc_v4l2_ctrl_t *ControlAddBitMask (vlc_object_t *obj, int fd,
var_Change (obj, c->name, VLC_VAR_SETDEFAULT, &val, NULL);
return c;
}
#endif
#if HAVE_DECL_V4L2_CTRL_TYPE_INTEGER_MENU
static vlc_v4l2_ctrl_t *ControlAddIntMenu (vlc_object_t *obj, int fd,
const struct v4l2_queryctrl *query)
{
......@@ -704,7 +693,6 @@ static vlc_v4l2_ctrl_t *ControlAddIntMenu (vlc_object_t *obj, int fd,
}
return c;
}
#endif
static vlc_v4l2_ctrl_t *ControlAddUnknown (vlc_object_t *obj, int fd,
const struct v4l2_queryctrl *query)
......@@ -737,12 +725,8 @@ vlc_v4l2_ctrl_t *ControlsInit (vlc_object_t *obj, int fd)
[V4L2_CTRL_TYPE_INTEGER64] = ControlAddInteger64,
[V4L2_CTRL_TYPE_CTRL_CLASS] = ControlAddClass,
[V4L2_CTRL_TYPE_STRING] = ControlAddString,
#if HAVE_DECL_V4L2_CTRL_TYPE_BITMASK
[V4L2_CTRL_TYPE_BITMASK] = ControlAddBitMask,
#endif
#if HAVE_DECL_V4L2_CTRL_TYPE_INTEGER_MENU
[V4L2_CTRL_TYPE_INTEGER_MENU] = ControlAddIntMenu,
#endif
};
vlc_v4l2_ctrl_t *list = NULL;
......
......@@ -190,7 +190,6 @@ static const vlc_v4l2_fmt_t v4l2_fmts[] =
/* Compressed data types */
{ V4L2_PIX_FMT_JPEG, VLC_CODEC_MJPG, 0, 0, 0 },
#ifdef V4L2_PIX_FMT_H264
{ V4L2_PIX_FMT_H264, VLC_CODEC_H264, 0, 0, 0 },
/* FIXME: fill p_extra for avc1... */
// { V4L2_PIX_FMT_H264_NO_SC, VLC_FOURCC('a','v','c','1'), 0, 0, 0 }
......@@ -201,7 +200,6 @@ static const vlc_v4l2_fmt_t v4l2_fmts[] =
{ V4L2_PIX_FMT_MPEG1, VLC_CODEC_MPGV, 0, 0, 0 },
{ V4L2_PIX_FMT_VC1_ANNEX_G, VLC_CODEC_VC1, 0, 0, 0 },
{ V4L2_PIX_FMT_VC1_ANNEX_L, VLC_CODEC_VC1, 0, 0, 0 },
#endif
//V4L2_PIX_FMT_MPEG -> use access
/* Reserved formats */
......
......@@ -487,7 +487,6 @@ int OpenDevice (vlc_object_t *obj, const char *path, uint32_t *restrict caps)
cap.card, cap.driver, (cap.version >> 16) & 0xFF,
(cap.version >> 8) & 0xFF, cap.version & 0xFF, cap.bus_info);
#ifdef V4L2_CAP_DEVICE_CAPS
if (cap.capabilities & V4L2_CAP_DEVICE_CAPS)
{
msg_Dbg (obj, " with capabilities 0x%08"PRIX32" "
......@@ -495,7 +494,6 @@ int OpenDevice (vlc_object_t *obj, const char *path, uint32_t *restrict caps)
*caps = cap.device_caps;
}
else
#endif
{
msg_Dbg (obj, " with unknown capabilities "
"(overall 0x%08"PRIX32")", cap.capabilities);
......
......@@ -18,46 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#if defined (HAVE_LINUX_VIDEODEV2_H)
# include <linux/videodev2.h>
#elif defined (HAVE_SYS_VIDEOIO_H)
# include <sys/videoio.h>
#else
# error "No Video4Linux2 headers found."
#endif
#if !HAVE_DECL_V4L2_CTRL_TYPE_INTEGER_MENU
# warning Please update Video4Linux2 headers!
#endif
/* Hacks to compile with old headers */
#ifndef V4L2_CTRL_FLAG_VOLATILE /* 3.2 */
# define V4L2_CTRL_FLAG_VOLATILE 0x0080
# define V4L2_CID_POWER_LINE_FREQUENCY_AUTO 3
# define V4L2_STD_G (V4L2_STD_PAL_G|V4L2_STD_SECAM_G)
# define V4L2_STD_H (V4L2_STD_PAL_H|V4L2_STD_SECAM_H)
# define V4L2_STD_L (V4L2_STD_SECAM_L|V4L2_STD_SECAM_LC)
# define V4L2_STD_BG (V4L2_STD_B|V4L2_STD_G)
# define V4L2_STD_MTS (V4L2_STD_NTSC_M|V4L2_STD_PAL_M|V4L2_STD_PAL_N|\
V4L2_STD_PAL_Nc)
#endif
#ifndef V4L2_CID_ILLUMINATORS_1 /* 2.6.37 */
# define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+38)
# define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+37)
#endif
#ifndef V4L2_CID_CHROMA_GAIN /* 2.6.35 */
# define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36)
# define V4L2_COLORFX_VIVID 9
# define V4L2_COLORFX_SKIN_WHITEN 8
# define V4L2_COLORFX_GRASS_GREEN 7
# define V4L2_COLORFX_SKY_BLUE 6
# define V4L2_COLORFX_SKETCH 5
# define V4L2_COLORFX_EMBOSS 4
# define V4L2_COLORFX_NEGATIVE 3
#endif
#ifndef V4L2_CID_ROTATE /* 2.6.33 */
# define V4L2_CID_BG_COLOR (V4L2_CID_BASE+35)
# define V4L2_CID_ROTATE (V4L2_CID_BASE+34)
#endif
#include "videodev2.h"
/* libv4l2 functions */
extern int v4l2_fd_open (int, int);
......
......@@ -41,16 +41,12 @@
static int SetupStandard (vlc_object_t *obj, int fd,
const struct v4l2_input *restrict input)
{
#ifdef V4L2_IN_CAP_STD
if (!(input->capabilities & V4L2_IN_CAP_STD))
{
msg_Dbg (obj, "no video standard selection");
return 0;
}
#else
(void) input;
msg_Dbg (obj, "video standard selection unknown");
#endif
v4l2_std_id std = var_InheritStandard (obj, CFG_PREFIX"standard");
if (std == V4L2_STD_UNKNOWN)
{
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment