Ticket #9789: 0036-Fix-building-video4linux-without-using-v1-headers.patch

File 0036-Fix-building-video4linux-without-using-v1-headers.patch, 12.4 KB (added by lvr@…, 10 years ago)
  • mythtv/configure

    From 5d8b1e2f1127f16f36a093ddb24f248c5968865e Mon Sep 17 00:00:00 2001
    From: Lawrence Rust <lvr@softsystem.co.uk>
    Date: Tue, 17 May 2011 22:53:28 +0200
    Subject: [PATCH 36/36] Fix building video4linux without using v1 headers
    
    Linux >= 2.6.38 doesn't support v4l v1 and distributions using it don't ship
    the <linux/videodev.h> header.  This patch enables building with v4l2 only.
    
    Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
    ---
     mythtv/configure                              |    5 +++-
     mythtv/libs/libmythtv/NuppelVideoRecorder.cpp |   21 ++++++++++++++-
     mythtv/libs/libmythtv/analogsignalmonitor.cpp |    5 +++
     mythtv/libs/libmythtv/cardutil.cpp            |    6 ++++
     mythtv/libs/libmythtv/libmythtv.pro           |    1 +
     mythtv/libs/libmythtv/v4lchannel.cpp          |   34 +++++++++++++++++++++++++
     mythtv/libs/libmythtv/vbitext/vbi.c           |    7 +++++
     7 files changed, 76 insertions(+), 3 deletions(-)
    
    diff --git a/mythtv/configure b/mythtv/configure
    index db4f661..6dfc445 100755
    a b MYTHTV_CONFIG_LIST=' 
    13161316    qtwebkit
    13171317    quartz_video
    13181318    v4l
     1319    v4l1
    13191320    valgrind
    13201321    x11
    13211322    xrandr
    mythtranscode_deps="backend frontend" 
    17151716opengl_deps_any="agl_h GL_gl_h darwin windows x11"
    17161717opengl_video_deps="opengl"
    17171718opengl_vsync_deps="opengl"
    1718 v4l_deps="backend linux_videodev_h linux_videodev2_h"
     1719v4l_deps="backend linux_videodev2_h"
     1720v4l1_deps="backend linux_videodev_h"
    17191721vdpau_deps="opengl vdpau_vdpau_h vdpau_vdpau_x11_h"
    17201722xrandr_deps="x11"
    17211723xv_deps="x11"
    enable opengl_vsync 
    19351937enable opengl_video
    19361938enable quartz_video
    19371939enable v4l
     1940enable v4l1
    19381941enable x11
    19391942enable xrandr
    19401943enable xv
  • mythtv/libs/libmythtv/NuppelVideoRecorder.cpp

    diff --git a/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp b/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
    index 739634d..b592fbe 100644
    a b extern "C" { 
    4343}
    4444
    4545#ifdef USING_V4L
     46#ifdef USING_V4L1
    4647#include <linux/videodev.h>
     48#endif
    4749#include <linux/videodev2.h>
    4850
    4951#include "go7007_myth.h"
    int NuppelVideoRecorder::AudioInit(bool skipdevice) 
    829831 */
    830832bool NuppelVideoRecorder::MJPEGInit(void)
    831833{
    832 #ifdef USING_V4L
     834#ifdef USING_V4L1
    833835    bool we_opened_fd = false;
    834836    int init_fd = fd;
    835837    if (init_fd < 0)
    void NuppelVideoRecorder::StartRecording(void) 
    11301132        DoV4L2();
    11311133        return;
    11321134    }
     1135#ifdef USING_V4L1
    11331136    else
    11341137        DoV4L();
     1138#endif
    11351139}
    11361140
    1137 #ifdef USING_V4L
     1141#ifdef USING_V4L1
    11381142void NuppelVideoRecorder::DoV4L(void)
    11391143{
    11401144    struct video_capability vc;
    void NuppelVideoRecorder::DoV4L(void) 
    13201324    recording = false;
    13211325    close(fd);
    13221326}
     1327#else
     1328void NuppelVideoRecorder::DoV4L(void)         {}
     1329#endif
    13231330
     1331
     1332#ifdef USING_V4L
    13241333bool NuppelVideoRecorder::SetFormatV4L2(void)
    13251334{
    13261335    struct v4l2_format     vfmt;
    again: 
    17201729    close(channelfd);
    17211730}
    17221731
     1732#ifdef USING_V4L1
    17231733void NuppelVideoRecorder::DoMJPEG(void)
    17241734{
    17251735    struct mjpeg_params bparm;
    void NuppelVideoRecorder::DoMJPEG(void) 
    18551865    recording = false;
    18561866    close(fd);
    18571867}
     1868#else
     1869void NuppelVideoRecorder::DoMJPEG(void)       {}
     1870#endif
    18581871
    18591872#else  // USING_V4L
    18601873void NuppelVideoRecorder::DoV4L(void)         {}
    void NuppelVideoRecorder::doVbiThread(void) 
    27322745            vbi_add_handler(pal_tt, (void*) vbi_event, &vbicallbackdata);
    27332746        }
    27342747    }
     2748#ifdef USING_V4L1
    27352749    else if (VBIMode::NTSC_CC == vbimode)
    27362750    {
    27372751        ntsc_cc = new struct cc;
    void NuppelVideoRecorder::doVbiThread(void) 
    27462760        if (vbifd < 0)
    27472761            delete ntsc_cc;
    27482762    }
     2763#endif
    27492764    else
    27502765    {
    27512766        VERBOSE(VB_IMPORTANT, LOC_ERR + "Invalid CC/Teletext mode");
    void NuppelVideoRecorder::doVbiThread(void) 
    27592774        return;
    27602775    }
    27612776
     2777#ifdef USING_V4L1
    27622778    if (VBIMode::NTSC_CC == vbimode)
    27632779    {
    27642780        // V4L v1 VBI ioctls
    void NuppelVideoRecorder::doVbiThread(void) 
    27942810            return;
    27952811        }
    27962812    }
     2813#endif
    27972814
    27982815    // Qt4 requires a QMutex as a parameter...
    27992816    // not sure if this is the best solution.  Mutex Must be locked before wait.
  • mythtv/libs/libmythtv/analogsignalmonitor.cpp

    diff --git a/mythtv/libs/libmythtv/analogsignalmonitor.cpp b/mythtv/libs/libmythtv/analogsignalmonitor.cpp
    index 2a4f4c5..acdf74d 100644
    a b  
    66#include <sys/ioctl.h>
    77#include <poll.h>
    88
     9#ifdef USING_V4L1
    910#include <linux/videodev.h>
     11#endif
     12#include <linux/videodev2.h>
    1013
    1114#include "mythverbose.h"
    1215#include "analogsignalmonitor.h"
    void AnalogSignalMonitor::UpdateValues(void) 
    149152            }
    150153        }
    151154    }
     155#ifdef USING_V4L1
    152156    else
    153157    {
    154158        struct video_tuner tuner;
    void AnalogSignalMonitor::UpdateValues(void) 
    164168            isLocked = tuner.signal;
    165169        }
    166170    }
     171#endif
    167172
    168173    {
    169174        QMutexLocker locker(&statusLock);
  • mythtv/libs/libmythtv/cardutil.cpp

    diff --git a/mythtv/libs/libmythtv/cardutil.cpp b/mythtv/libs/libmythtv/cardutil.cpp
    index 8852682..566aa4d 100644
    a b  
    2727#endif
    2828
    2929#ifdef USING_V4L
     30#ifdef USING_V4L1
    3031#include <linux/videodev.h>
     32#endif
    3133#include <linux/videodev2.h>
    3234#endif
    3335
    bool CardUtil::GetV4LInfo( 
    14851487        driver = QString::fromAscii((const char*)capability.driver);
    14861488        version = capability.version;
    14871489    }
     1490#ifdef USING_V4L1
    14881491    else // Fallback to V4L1 query
    14891492    {
    14901493        struct video_capability capability;
    14911494        if (ioctl(videofd, VIDIOCGCAP, &capability) >= 0)
    14921495            card = QString::fromAscii((const char*)capability.name);
    14931496    }
     1497#endif
    14941498#endif // !USING_V4L
    14951499
    14961500    if (!driver.isEmpty())
    InputNames CardUtil::ProbeV4LVideoInputs(int videofd, bool &ok) 
    15241528        return list;
    15251529    }
    15261530
     1531#ifdef USING_V4L1
    15271532    // V4L v1 query
    15281533    struct video_capability vidcap;
    15291534    bzero(&vidcap, sizeof(vidcap));
    InputNames CardUtil::ProbeV4LVideoInputs(int videofd, bool &ok) 
    15581563        list[0] = "Television";
    15591564
    15601565    ok = true;
     1566#endif
    15611567#else // if !USING_V4L
    15621568    list[-1] += QObject::tr("ERROR, Compile with V4L support to query inputs");
    15631569#endif // !USING_V4L
  • mythtv/libs/libmythtv/libmythtv.pro

    diff --git a/mythtv/libs/libmythtv/libmythtv.pro b/mythtv/libs/libmythtv/libmythtv.pro
    index 662587b..53a48e1 100644
    a b using_backend { 
    477477
    478478        DEFINES += USING_V4L
    479479    }
     480    using_v4l1:DEFINES += USING_V4L1
    480481
    481482    # Support for cable boxes that provide Firewire out
    482483    using_firewire {
  • mythtv/libs/libmythtv/v4lchannel.cpp

    diff --git a/mythtv/libs/libmythtv/v4lchannel.cpp b/mythtv/libs/libmythtv/v4lchannel.cpp
    index bc82b49..b24f6c6 100644
    a b  
    1616#include <iostream>
    1717using namespace std;
    1818
     19#ifdef USING_V4L1
    1920#include <linux/videodev.h>
     21#endif
    2022#include <linux/videodev2.h>
    2123
    2224// MythTV headers
    static int format_to_mode(const QString &fmt, int v4l_version) 
    146148            return V4L2_STD_PAL;
    147149        return V4L2_STD_NTSC;
    148150    }
     151#ifdef USING_V4L1
    149152    else if (1 == v4l_version)
    150153    {
    151154        if (fmt == "NTSC-JP")
    static int format_to_mode(const QString &fmt, int v4l_version) 
    167170            return VIDEO_MODE_NTSC; // We've dropped V4L ATSC support...
    168171        return VIDEO_MODE_NTSC;
    169172    }
     173#endif
    170174
    171175    VERBOSE(VB_IMPORTANT,
    172176            "format_to_mode() does not recognize V4L" << v4l_version);
    static QString mode_to_format(int mode, int v4l_version) 
    235239            return "ATSC";
    236240        }
    237241    }
     242#ifdef USING_V4L1
    238243    else if (1 == v4l_version)
    239244    {
    240245        if (mode == VIDEO_MODE_NTSC)
    static QString mode_to_format(int mode, int v4l_version) 
    250255        else if (mode == 6)
    251256            return "NTSC-JP";
    252257    }
     258#endif
    253259    else
    254260    {
    255261        VERBOSE(VB_IMPORTANT,
    bool V4LChannel::Tune(uint frequency, QString inputname, 
    676682        return true;
    677683    }
    678684
     685#ifdef USING_V4L1
    679686    // Video4Linux version 1 tuning
    680687    uint freq = frequency / 62500;
    681688    ioctlval = ioctl(videofd, VIDIOCSFREQ, &freq);
    bool V4LChannel::Tune(uint frequency, QString inputname, 
    691698    SetSIStandard(si_std);
    692699
    693700    return true;
     701#else
     702    return false;
     703#endif
    694704}
    695705
    696706/** \fn V4LChannel::Retune(void)
    bool V4LChannel::SetInputAndFormat(int inputNum, QString newFmt) 
    787797        return false;
    788798
    789799    int inputNumV4L = (*it)->inputNumV4L;
     800#ifdef USING_V4L1
    790801    bool usingv4l1 = !usingv4l2;
     802#endif
    791803    bool ok = true;
    792804
    793805    QString msg =
    bool V4LChannel::SetInputAndFormat(int inputNum, QString newFmt) 
    856868        }
    857869    }
    858870
     871#ifdef USING_V4L1
    859872    if (usingv4l1)
    860873    {
    861874        VERBOSE(VB_CHANNEL, LOC + msg + "(v4l v1)");
    bool V4LChannel::SetInputAndFormat(int inputNum, QString newFmt) 
    883896        }
    884897    }
    885898    return ok;
     899#else
     900    return false;
     901#endif
    886902}
    887903
    888904bool V4LChannel::SwitchToInput(int inputnum, bool setstarting)
    bool V4LChannel::SwitchToInput(int inputnum, bool setstarting) 
    951967    return ok;
    952968}
    953969
     970#ifdef USING_V4L1
    954971static unsigned short *get_v4l1_field(
    955972    int v4l2_attrib, struct video_picture &vid_pic)
    956973{
    static unsigned short *get_v4l1_field( 
    970987    }
    971988    return NULL;
    972989}
     990#endif
    973991
    974992static int get_v4l2_attribute(const QString &db_col_name)
    975993{
    bool V4LChannel::InitPictureAttribute(const QString db_col_name) 
    10661084        return true;
    10671085    }
    10681086
     1087#ifdef USING_V4L1
    10691088    // V4L1
    10701089    unsigned short *setfield;
    10711090    struct video_picture vid_pic;
    bool V4LChannel::InitPictureAttribute(const QString db_col_name) 
    10871106        VERBOSE(VB_IMPORTANT, loc_err + "failed to set controls." + ENO);
    10881107        return false;
    10891108    }
     1109#else
     1110    return false;
     1111#endif
    10901112
    10911113    return true;
    10921114}
    static int get_v4l2_attribute_value(int videofd, int v4l2_attrib) 
    11521174    return min(max((int)(mult * (ctrl.value - qctrl.minimum)), 0), 65525);
    11531175}
    11541176
     1177#ifdef USING_V4L1
    11551178static int get_v4l1_attribute_value(int videofd, int v4l2_attrib)
    11561179{
    11571180    struct video_picture vid_pic;
    static int get_v4l1_attribute_value(int videofd, int v4l2_attrib) 
    11701193
    11711194    return -1;
    11721195}
     1196#endif
    11731197
    11741198static int get_attribute_value(bool usingv4l2, int videofd, int v4l2_attrib)
    11751199{
    11761200    if (usingv4l2)
    11771201        return get_v4l2_attribute_value(videofd, v4l2_attrib);
     1202#ifdef USING_V4L1
    11781203    return get_v4l1_attribute_value(videofd, v4l2_attrib);
     1204#else
     1205    return -1;
     1206#endif
    11791207}
    11801208
    11811209static int set_v4l2_attribute_value(int videofd, int v4l2_attrib, int newvalue)
    static int set_v4l2_attribute_value(int videofd, int v4l2_attrib, int newvalue) 
    12081236    return 0;
    12091237}
    12101238
     1239#ifdef USING_V4L1
    12111240static int set_v4l1_attribute_value(int videofd, int v4l2_attrib, int newvalue)
    12121241{
    12131242    unsigned short *setfield;
    static int set_v4l1_attribute_value(int videofd, int v4l2_attrib, int newvalue) 
    12391268
    12401269    return 0;
    12411270}
     1271#endif
    12421272
    12431273static int set_attribute_value(bool usingv4l2, int videofd,
    12441274                               int v4l2_attrib, int newvalue)
    12451275{
    12461276    if (usingv4l2)
    12471277        return set_v4l2_attribute_value(videofd, v4l2_attrib, newvalue);
     1278#ifdef USING_V4L1
    12481279    return set_v4l1_attribute_value(videofd, v4l2_attrib, newvalue);
     1280#else
     1281    return -1;
     1282#endif
    12491283}
    12501284
    12511285int V4LChannel::ChangePictureAttribute(
  • mythtv/libs/libmythtv/vbitext/vbi.c

    diff --git a/mythtv/libs/libmythtv/vbitext/vbi.c b/mythtv/libs/libmythtv/vbitext/vbi.c
    index 15f8d85..65942d0 100644
    a b  
    1414//       compiling with -std=c99.  We could remove this in the .pro file,
    1515//       but that would disable it for all .c files.
    1616#undef __STRICT_ANSI__
     17#ifdef USING_V4L1
    1718#include <linux/videodev.h>
     19#endif
    1820#include <linux/videodev2.h>
    1921
    2022// vbitext headers
    setup_dev(struct vbi *vbi) 
    539541    v4l2_format.type = V4L2_BUF_TYPE_VBI_CAPTURE;
    540542    if (ioctl(vbi->fd, VIDIOC_G_FMT, &v4l2_format) == -1)
    541543    {
     544#ifdef USING_V4L1
    542545       // not a v4l2 device.  assume bttv and create a standard fmt-struct.
    543546       int size;
    544547       perror("ioctl VIDIOC_G_FMT");
    setup_dev(struct vbi *vbi) 
    564567           vbifmt->count[0] = size/2;
    565568           vbifmt->count[1] = size - size/2;
    566569       }
     570#else
     571       perror("ioctl VIDIOC_G_FMT");
     572       return -1;
     573#endif
    567574    }
    568575
    569576    if (set_decode_parms(vbi, vbifmt) == -1)