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='
|
| 1316 | 1316 | qtwebkit |
| 1317 | 1317 | quartz_video |
| 1318 | 1318 | v4l |
| | 1319 | v4l1 |
| 1319 | 1320 | valgrind |
| 1320 | 1321 | x11 |
| 1321 | 1322 | xrandr |
| … |
… |
mythtranscode_deps="backend frontend"
|
| 1715 | 1716 | opengl_deps_any="agl_h GL_gl_h darwin windows x11" |
| 1716 | 1717 | opengl_video_deps="opengl" |
| 1717 | 1718 | opengl_vsync_deps="opengl" |
| 1718 | | v4l_deps="backend linux_videodev_h linux_videodev2_h" |
| | 1719 | v4l_deps="backend linux_videodev2_h" |
| | 1720 | v4l1_deps="backend linux_videodev_h" |
| 1719 | 1721 | vdpau_deps="opengl vdpau_vdpau_h vdpau_vdpau_x11_h" |
| 1720 | 1722 | xrandr_deps="x11" |
| 1721 | 1723 | xv_deps="x11" |
| … |
… |
enable opengl_vsync
|
| 1935 | 1937 | enable opengl_video |
| 1936 | 1938 | enable quartz_video |
| 1937 | 1939 | enable v4l |
| | 1940 | enable v4l1 |
| 1938 | 1941 | enable x11 |
| 1939 | 1942 | enable xrandr |
| 1940 | 1943 | enable xv |
diff --git a/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp b/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
index 739634d..b592fbe 100644
|
a
|
b
|
extern "C" {
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | #ifdef USING_V4L |
| | 46 | #ifdef USING_V4L1 |
| 46 | 47 | #include <linux/videodev.h> |
| | 48 | #endif |
| 47 | 49 | #include <linux/videodev2.h> |
| 48 | 50 | |
| 49 | 51 | #include "go7007_myth.h" |
| … |
… |
int NuppelVideoRecorder::AudioInit(bool skipdevice)
|
| 829 | 831 | */ |
| 830 | 832 | bool NuppelVideoRecorder::MJPEGInit(void) |
| 831 | 833 | { |
| 832 | | #ifdef USING_V4L |
| | 834 | #ifdef USING_V4L1 |
| 833 | 835 | bool we_opened_fd = false; |
| 834 | 836 | int init_fd = fd; |
| 835 | 837 | if (init_fd < 0) |
| … |
… |
void NuppelVideoRecorder::StartRecording(void)
|
| 1130 | 1132 | DoV4L2(); |
| 1131 | 1133 | return; |
| 1132 | 1134 | } |
| | 1135 | #ifdef USING_V4L1 |
| 1133 | 1136 | else |
| 1134 | 1137 | DoV4L(); |
| | 1138 | #endif |
| 1135 | 1139 | } |
| 1136 | 1140 | |
| 1137 | | #ifdef USING_V4L |
| | 1141 | #ifdef USING_V4L1 |
| 1138 | 1142 | void NuppelVideoRecorder::DoV4L(void) |
| 1139 | 1143 | { |
| 1140 | 1144 | struct video_capability vc; |
| … |
… |
void NuppelVideoRecorder::DoV4L(void)
|
| 1320 | 1324 | recording = false; |
| 1321 | 1325 | close(fd); |
| 1322 | 1326 | } |
| | 1327 | #else |
| | 1328 | void NuppelVideoRecorder::DoV4L(void) {} |
| | 1329 | #endif |
| 1323 | 1330 | |
| | 1331 | |
| | 1332 | #ifdef USING_V4L |
| 1324 | 1333 | bool NuppelVideoRecorder::SetFormatV4L2(void) |
| 1325 | 1334 | { |
| 1326 | 1335 | struct v4l2_format vfmt; |
| … |
… |
again:
|
| 1720 | 1729 | close(channelfd); |
| 1721 | 1730 | } |
| 1722 | 1731 | |
| | 1732 | #ifdef USING_V4L1 |
| 1723 | 1733 | void NuppelVideoRecorder::DoMJPEG(void) |
| 1724 | 1734 | { |
| 1725 | 1735 | struct mjpeg_params bparm; |
| … |
… |
void NuppelVideoRecorder::DoMJPEG(void)
|
| 1855 | 1865 | recording = false; |
| 1856 | 1866 | close(fd); |
| 1857 | 1867 | } |
| | 1868 | #else |
| | 1869 | void NuppelVideoRecorder::DoMJPEG(void) {} |
| | 1870 | #endif |
| 1858 | 1871 | |
| 1859 | 1872 | #else // USING_V4L |
| 1860 | 1873 | void NuppelVideoRecorder::DoV4L(void) {} |
| … |
… |
void NuppelVideoRecorder::doVbiThread(void)
|
| 2732 | 2745 | vbi_add_handler(pal_tt, (void*) vbi_event, &vbicallbackdata); |
| 2733 | 2746 | } |
| 2734 | 2747 | } |
| | 2748 | #ifdef USING_V4L1 |
| 2735 | 2749 | else if (VBIMode::NTSC_CC == vbimode) |
| 2736 | 2750 | { |
| 2737 | 2751 | ntsc_cc = new struct cc; |
| … |
… |
void NuppelVideoRecorder::doVbiThread(void)
|
| 2746 | 2760 | if (vbifd < 0) |
| 2747 | 2761 | delete ntsc_cc; |
| 2748 | 2762 | } |
| | 2763 | #endif |
| 2749 | 2764 | else |
| 2750 | 2765 | { |
| 2751 | 2766 | VERBOSE(VB_IMPORTANT, LOC_ERR + "Invalid CC/Teletext mode"); |
| … |
… |
void NuppelVideoRecorder::doVbiThread(void)
|
| 2759 | 2774 | return; |
| 2760 | 2775 | } |
| 2761 | 2776 | |
| | 2777 | #ifdef USING_V4L1 |
| 2762 | 2778 | if (VBIMode::NTSC_CC == vbimode) |
| 2763 | 2779 | { |
| 2764 | 2780 | // V4L v1 VBI ioctls |
| … |
… |
void NuppelVideoRecorder::doVbiThread(void)
|
| 2794 | 2810 | return; |
| 2795 | 2811 | } |
| 2796 | 2812 | } |
| | 2813 | #endif |
| 2797 | 2814 | |
| 2798 | 2815 | // Qt4 requires a QMutex as a parameter... |
| 2799 | 2816 | // not sure if this is the best solution. Mutex Must be locked before wait. |
diff --git a/mythtv/libs/libmythtv/analogsignalmonitor.cpp b/mythtv/libs/libmythtv/analogsignalmonitor.cpp
index 2a4f4c5..acdf74d 100644
|
a
|
b
|
|
| 6 | 6 | #include <sys/ioctl.h> |
| 7 | 7 | #include <poll.h> |
| 8 | 8 | |
| | 9 | #ifdef USING_V4L1 |
| 9 | 10 | #include <linux/videodev.h> |
| | 11 | #endif |
| | 12 | #include <linux/videodev2.h> |
| 10 | 13 | |
| 11 | 14 | #include "mythverbose.h" |
| 12 | 15 | #include "analogsignalmonitor.h" |
| … |
… |
void AnalogSignalMonitor::UpdateValues(void)
|
| 149 | 152 | } |
| 150 | 153 | } |
| 151 | 154 | } |
| | 155 | #ifdef USING_V4L1 |
| 152 | 156 | else |
| 153 | 157 | { |
| 154 | 158 | struct video_tuner tuner; |
| … |
… |
void AnalogSignalMonitor::UpdateValues(void)
|
| 164 | 168 | isLocked = tuner.signal; |
| 165 | 169 | } |
| 166 | 170 | } |
| | 171 | #endif |
| 167 | 172 | |
| 168 | 173 | { |
| 169 | 174 | QMutexLocker locker(&statusLock); |
diff --git a/mythtv/libs/libmythtv/cardutil.cpp b/mythtv/libs/libmythtv/cardutil.cpp
index 8852682..566aa4d 100644
|
a
|
b
|
|
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | #ifdef USING_V4L |
| | 30 | #ifdef USING_V4L1 |
| 30 | 31 | #include <linux/videodev.h> |
| | 32 | #endif |
| 31 | 33 | #include <linux/videodev2.h> |
| 32 | 34 | #endif |
| 33 | 35 | |
| … |
… |
bool CardUtil::GetV4LInfo(
|
| 1485 | 1487 | driver = QString::fromAscii((const char*)capability.driver); |
| 1486 | 1488 | version = capability.version; |
| 1487 | 1489 | } |
| | 1490 | #ifdef USING_V4L1 |
| 1488 | 1491 | else // Fallback to V4L1 query |
| 1489 | 1492 | { |
| 1490 | 1493 | struct video_capability capability; |
| 1491 | 1494 | if (ioctl(videofd, VIDIOCGCAP, &capability) >= 0) |
| 1492 | 1495 | card = QString::fromAscii((const char*)capability.name); |
| 1493 | 1496 | } |
| | 1497 | #endif |
| 1494 | 1498 | #endif // !USING_V4L |
| 1495 | 1499 | |
| 1496 | 1500 | if (!driver.isEmpty()) |
| … |
… |
InputNames CardUtil::ProbeV4LVideoInputs(int videofd, bool &ok)
|
| 1524 | 1528 | return list; |
| 1525 | 1529 | } |
| 1526 | 1530 | |
| | 1531 | #ifdef USING_V4L1 |
| 1527 | 1532 | // V4L v1 query |
| 1528 | 1533 | struct video_capability vidcap; |
| 1529 | 1534 | bzero(&vidcap, sizeof(vidcap)); |
| … |
… |
InputNames CardUtil::ProbeV4LVideoInputs(int videofd, bool &ok)
|
| 1558 | 1563 | list[0] = "Television"; |
| 1559 | 1564 | |
| 1560 | 1565 | ok = true; |
| | 1566 | #endif |
| 1561 | 1567 | #else // if !USING_V4L |
| 1562 | 1568 | list[-1] += QObject::tr("ERROR, Compile with V4L support to query inputs"); |
| 1563 | 1569 | #endif // !USING_V4L |
diff --git a/mythtv/libs/libmythtv/libmythtv.pro b/mythtv/libs/libmythtv/libmythtv.pro
index 662587b..53a48e1 100644
|
a
|
b
|
using_backend {
|
| 477 | 477 | |
| 478 | 478 | DEFINES += USING_V4L |
| 479 | 479 | } |
| | 480 | using_v4l1:DEFINES += USING_V4L1 |
| 480 | 481 | |
| 481 | 482 | # Support for cable boxes that provide Firewire out |
| 482 | 483 | using_firewire { |
diff --git a/mythtv/libs/libmythtv/v4lchannel.cpp b/mythtv/libs/libmythtv/v4lchannel.cpp
index bc82b49..b24f6c6 100644
|
a
|
b
|
|
| 16 | 16 | #include <iostream> |
| 17 | 17 | using namespace std; |
| 18 | 18 | |
| | 19 | #ifdef USING_V4L1 |
| 19 | 20 | #include <linux/videodev.h> |
| | 21 | #endif |
| 20 | 22 | #include <linux/videodev2.h> |
| 21 | 23 | |
| 22 | 24 | // MythTV headers |
| … |
… |
static int format_to_mode(const QString &fmt, int v4l_version)
|
| 146 | 148 | return V4L2_STD_PAL; |
| 147 | 149 | return V4L2_STD_NTSC; |
| 148 | 150 | } |
| | 151 | #ifdef USING_V4L1 |
| 149 | 152 | else if (1 == v4l_version) |
| 150 | 153 | { |
| 151 | 154 | if (fmt == "NTSC-JP") |
| … |
… |
static int format_to_mode(const QString &fmt, int v4l_version)
|
| 167 | 170 | return VIDEO_MODE_NTSC; // We've dropped V4L ATSC support... |
| 168 | 171 | return VIDEO_MODE_NTSC; |
| 169 | 172 | } |
| | 173 | #endif |
| 170 | 174 | |
| 171 | 175 | VERBOSE(VB_IMPORTANT, |
| 172 | 176 | "format_to_mode() does not recognize V4L" << v4l_version); |
| … |
… |
static QString mode_to_format(int mode, int v4l_version)
|
| 235 | 239 | return "ATSC"; |
| 236 | 240 | } |
| 237 | 241 | } |
| | 242 | #ifdef USING_V4L1 |
| 238 | 243 | else if (1 == v4l_version) |
| 239 | 244 | { |
| 240 | 245 | if (mode == VIDEO_MODE_NTSC) |
| … |
… |
static QString mode_to_format(int mode, int v4l_version)
|
| 250 | 255 | else if (mode == 6) |
| 251 | 256 | return "NTSC-JP"; |
| 252 | 257 | } |
| | 258 | #endif |
| 253 | 259 | else |
| 254 | 260 | { |
| 255 | 261 | VERBOSE(VB_IMPORTANT, |
| … |
… |
bool V4LChannel::Tune(uint frequency, QString inputname,
|
| 676 | 682 | return true; |
| 677 | 683 | } |
| 678 | 684 | |
| | 685 | #ifdef USING_V4L1 |
| 679 | 686 | // Video4Linux version 1 tuning |
| 680 | 687 | uint freq = frequency / 62500; |
| 681 | 688 | ioctlval = ioctl(videofd, VIDIOCSFREQ, &freq); |
| … |
… |
bool V4LChannel::Tune(uint frequency, QString inputname,
|
| 691 | 698 | SetSIStandard(si_std); |
| 692 | 699 | |
| 693 | 700 | return true; |
| | 701 | #else |
| | 702 | return false; |
| | 703 | #endif |
| 694 | 704 | } |
| 695 | 705 | |
| 696 | 706 | /** \fn V4LChannel::Retune(void) |
| … |
… |
bool V4LChannel::SetInputAndFormat(int inputNum, QString newFmt)
|
| 787 | 797 | return false; |
| 788 | 798 | |
| 789 | 799 | int inputNumV4L = (*it)->inputNumV4L; |
| | 800 | #ifdef USING_V4L1 |
| 790 | 801 | bool usingv4l1 = !usingv4l2; |
| | 802 | #endif |
| 791 | 803 | bool ok = true; |
| 792 | 804 | |
| 793 | 805 | QString msg = |
| … |
… |
bool V4LChannel::SetInputAndFormat(int inputNum, QString newFmt)
|
| 856 | 868 | } |
| 857 | 869 | } |
| 858 | 870 | |
| | 871 | #ifdef USING_V4L1 |
| 859 | 872 | if (usingv4l1) |
| 860 | 873 | { |
| 861 | 874 | VERBOSE(VB_CHANNEL, LOC + msg + "(v4l v1)"); |
| … |
… |
bool V4LChannel::SetInputAndFormat(int inputNum, QString newFmt)
|
| 883 | 896 | } |
| 884 | 897 | } |
| 885 | 898 | return ok; |
| | 899 | #else |
| | 900 | return false; |
| | 901 | #endif |
| 886 | 902 | } |
| 887 | 903 | |
| 888 | 904 | bool V4LChannel::SwitchToInput(int inputnum, bool setstarting) |
| … |
… |
bool V4LChannel::SwitchToInput(int inputnum, bool setstarting)
|
| 951 | 967 | return ok; |
| 952 | 968 | } |
| 953 | 969 | |
| | 970 | #ifdef USING_V4L1 |
| 954 | 971 | static unsigned short *get_v4l1_field( |
| 955 | 972 | int v4l2_attrib, struct video_picture &vid_pic) |
| 956 | 973 | { |
| … |
… |
static unsigned short *get_v4l1_field(
|
| 970 | 987 | } |
| 971 | 988 | return NULL; |
| 972 | 989 | } |
| | 990 | #endif |
| 973 | 991 | |
| 974 | 992 | static int get_v4l2_attribute(const QString &db_col_name) |
| 975 | 993 | { |
| … |
… |
bool V4LChannel::InitPictureAttribute(const QString db_col_name)
|
| 1066 | 1084 | return true; |
| 1067 | 1085 | } |
| 1068 | 1086 | |
| | 1087 | #ifdef USING_V4L1 |
| 1069 | 1088 | // V4L1 |
| 1070 | 1089 | unsigned short *setfield; |
| 1071 | 1090 | struct video_picture vid_pic; |
| … |
… |
bool V4LChannel::InitPictureAttribute(const QString db_col_name)
|
| 1087 | 1106 | VERBOSE(VB_IMPORTANT, loc_err + "failed to set controls." + ENO); |
| 1088 | 1107 | return false; |
| 1089 | 1108 | } |
| | 1109 | #else |
| | 1110 | return false; |
| | 1111 | #endif |
| 1090 | 1112 | |
| 1091 | 1113 | return true; |
| 1092 | 1114 | } |
| … |
… |
static int get_v4l2_attribute_value(int videofd, int v4l2_attrib)
|
| 1152 | 1174 | return min(max((int)(mult * (ctrl.value - qctrl.minimum)), 0), 65525); |
| 1153 | 1175 | } |
| 1154 | 1176 | |
| | 1177 | #ifdef USING_V4L1 |
| 1155 | 1178 | static int get_v4l1_attribute_value(int videofd, int v4l2_attrib) |
| 1156 | 1179 | { |
| 1157 | 1180 | struct video_picture vid_pic; |
| … |
… |
static int get_v4l1_attribute_value(int videofd, int v4l2_attrib)
|
| 1170 | 1193 | |
| 1171 | 1194 | return -1; |
| 1172 | 1195 | } |
| | 1196 | #endif |
| 1173 | 1197 | |
| 1174 | 1198 | static int get_attribute_value(bool usingv4l2, int videofd, int v4l2_attrib) |
| 1175 | 1199 | { |
| 1176 | 1200 | if (usingv4l2) |
| 1177 | 1201 | return get_v4l2_attribute_value(videofd, v4l2_attrib); |
| | 1202 | #ifdef USING_V4L1 |
| 1178 | 1203 | return get_v4l1_attribute_value(videofd, v4l2_attrib); |
| | 1204 | #else |
| | 1205 | return -1; |
| | 1206 | #endif |
| 1179 | 1207 | } |
| 1180 | 1208 | |
| 1181 | 1209 | static 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)
|
| 1208 | 1236 | return 0; |
| 1209 | 1237 | } |
| 1210 | 1238 | |
| | 1239 | #ifdef USING_V4L1 |
| 1211 | 1240 | static int set_v4l1_attribute_value(int videofd, int v4l2_attrib, int newvalue) |
| 1212 | 1241 | { |
| 1213 | 1242 | unsigned short *setfield; |
| … |
… |
static int set_v4l1_attribute_value(int videofd, int v4l2_attrib, int newvalue)
|
| 1239 | 1268 | |
| 1240 | 1269 | return 0; |
| 1241 | 1270 | } |
| | 1271 | #endif |
| 1242 | 1272 | |
| 1243 | 1273 | static int set_attribute_value(bool usingv4l2, int videofd, |
| 1244 | 1274 | int v4l2_attrib, int newvalue) |
| 1245 | 1275 | { |
| 1246 | 1276 | if (usingv4l2) |
| 1247 | 1277 | return set_v4l2_attribute_value(videofd, v4l2_attrib, newvalue); |
| | 1278 | #ifdef USING_V4L1 |
| 1248 | 1279 | return set_v4l1_attribute_value(videofd, v4l2_attrib, newvalue); |
| | 1280 | #else |
| | 1281 | return -1; |
| | 1282 | #endif |
| 1249 | 1283 | } |
| 1250 | 1284 | |
| 1251 | 1285 | int V4LChannel::ChangePictureAttribute( |
diff --git a/mythtv/libs/libmythtv/vbitext/vbi.c b/mythtv/libs/libmythtv/vbitext/vbi.c
index 15f8d85..65942d0 100644
|
a
|
b
|
|
| 14 | 14 | // compiling with -std=c99. We could remove this in the .pro file, |
| 15 | 15 | // but that would disable it for all .c files. |
| 16 | 16 | #undef __STRICT_ANSI__ |
| | 17 | #ifdef USING_V4L1 |
| 17 | 18 | #include <linux/videodev.h> |
| | 19 | #endif |
| 18 | 20 | #include <linux/videodev2.h> |
| 19 | 21 | |
| 20 | 22 | // vbitext headers |
| … |
… |
setup_dev(struct vbi *vbi)
|
| 539 | 541 | v4l2_format.type = V4L2_BUF_TYPE_VBI_CAPTURE; |
| 540 | 542 | if (ioctl(vbi->fd, VIDIOC_G_FMT, &v4l2_format) == -1) |
| 541 | 543 | { |
| | 544 | #ifdef USING_V4L1 |
| 542 | 545 | // not a v4l2 device. assume bttv and create a standard fmt-struct. |
| 543 | 546 | int size; |
| 544 | 547 | perror("ioctl VIDIOC_G_FMT"); |
| … |
… |
setup_dev(struct vbi *vbi)
|
| 564 | 567 | vbifmt->count[0] = size/2; |
| 565 | 568 | vbifmt->count[1] = size - size/2; |
| 566 | 569 | } |
| | 570 | #else |
| | 571 | perror("ioctl VIDIOC_G_FMT"); |
| | 572 | return -1; |
| | 573 | #endif |
| 567 | 574 | } |
| 568 | 575 | |
| 569 | 576 | if (set_decode_parms(vbi, vbifmt) == -1) |