summaryrefslogtreecommitdiff
path: root/community/mythtv/mythtv-v4l2-fix.patch
blob: e26e16615f00424640779095398b71fdd8abbecc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
diff --git a/mythtv/configure b/mythtv/configure
index 1efe803..7bcdf06 100755
--- a/mythtv/configure
+++ b/mythtv/configure
@@ -109,7 +109,8 @@ Advanced options (experts only):
   --disable-iptv           disable support for recording RTSP/UDP/RTP streams
   --disable-hdhomerun      disable support for HDHomeRun boxes
   --disable-v4l            disable Video4Linux support
-  --disable-ivtv           disable ivtv support (PVR-x50) req. v4l support
+  --disable-v4l2           disable Video4Linux2 support
+  --disable-ivtv           disable ivtv support (PVR-x50) req. v4l2 support
   --disable-hdpvr          disable HD-PVR support
   --disable-dvb            disable DVB support
   --dvb-path=HDRLOC        location of directory containing
@@ -1315,6 +1316,7 @@ MYTHTV_CONFIG_LIST='
     qtwebkit
     quartz_video
     v4l
+    v4l2
     valgrind
     x11
     xrandr
@@ -1706,8 +1708,8 @@ audio_oss_deps_any="soundcard_h sys_soundcard_h"
 dvb_deps="backend"
 firewire_deps="backend"
 iptv_deps="backend"
-ivtv_deps="backend v4l"
-hdpvr_deps="backend v4l"
+ivtv_deps="backend v4l2"
+hdpvr_deps="backend v4l2"
 hdhomerun_deps="backend"
 mpegtsraw_demuxer_deps="merge_libavformat_mpegts_c"
 mythtranscode_deps="backend frontend"
@@ -1715,6 +1717,7 @@ opengl_deps_any="agl_h GL_gl_h darwin windows x11"
 opengl_video_deps="opengl"
 opengl_vsync_deps="opengl"
 v4l_deps="backend linux_videodev_h linux_videodev2_h"
+v4l2_deps="backend linux_videodev2_h"
 vdpau_deps="opengl vdpau_vdpau_h vdpau_vdpau_x11_h"
 xrandr_deps="x11"
 xv_deps="x11"
@@ -1933,6 +1936,7 @@ enable opengl_vsync
 enable opengl_video
 enable quartz_video
 enable v4l
+enable v4l2
 enable x11
 enable xrandr
 enable xv
@@ -3062,6 +3066,7 @@ EOF
         fi
         disable opengl_vsync
         disable v4l
+        disable v4l2
         disable x11
         # Workaround compile errors from missing gmtime_r/localtime_r/uint def
         CFLAGS=`echo $CFLAGS | sed 's/-D_POSIX_C_SOURCE=200112//'`
@@ -3106,6 +3111,7 @@ EOF
         fi
         disable symver
         disable v4l
+        disable v4l2
         enable  windows
         disable x11
         ###### Standard ffmpeg configure stuff follows:
@@ -4375,6 +4381,7 @@ enabled stripping || strip="echo skipping strip"
 
 if enabled backend; then
   echo "Video4Linux sup.          ${v4l-no}"
+  echo "Video4Linux2 sup.         ${v4l2-no}"
   echo "ivtv support              ${ivtv-no}"
   echo "HD-PVR support            ${hdpvr-no}"
   echo "FireWire support          ${firewire-no}"
diff --git a/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp b/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
index 739634d..39e5956 100644
--- a/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
+++ b/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
@@ -42,9 +42,13 @@ extern "C" {
 #include "libswscale/swscale.h"
 }
 
+#if defined(USING_V4L) || defined(USING_V4L2)
 #ifdef USING_V4L
 #include <linux/videodev.h>
+#endif
+#ifdef USING_V4L2
 #include <linux/videodev2.h>
+#endif
 
 #include "go7007_myth.h"
 
@@ -55,9 +59,9 @@ extern "C" {
 extern "C" {
 #include "vbitext/vbi.h"
 }
-#else  // USING_V4l
+#else  // USING_V4L || USING_V4L2
 #define VT_WIDTH 0
-#endif // USING_V4l
+#endif // USING_V4l || USING_V4L2
 
 #define KEYFRAMEDIST   30
 
@@ -1019,7 +1023,7 @@ bool NuppelVideoRecorder::Open(void)
 
 void NuppelVideoRecorder::ProbeV4L2(void)
 {
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     usingv4l2 = true;
 
     struct v4l2_capability vcap;
@@ -1049,7 +1053,7 @@ void NuppelVideoRecorder::ProbeV4L2(void)
     QString driver = (char *)vcap.driver;
     if (driver == "go7007")
         go7007 = true;
-#endif // USING_V4L
+#endif // USING_V4L || USING_V4L2
 }
 
 void NuppelVideoRecorder::StartRecording(void)
@@ -2460,7 +2464,7 @@ void NuppelVideoRecorder::doAudioThread(void)
         audio_device->Close();
 }
 
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
 struct VBIData
 {
     NuppelVideoRecorder *nvr;
@@ -2634,9 +2638,9 @@ void NuppelVideoRecorder::FormatTeletextSubtitles(struct VBIData *vbidata)
         act_text_buffer = 0;
     textbuffer[act]->freeToEncode = 1;
 }
-#else  // USING_V4L
+#else  // USING_V4L || USING_V4L2
 void NuppelVideoRecorder::FormatTeletextSubtitles(struct VBIData *vbidata) {}
-#endif // USING_V4L
+#endif // USING_V4L || USING_V4L2
 
 void NuppelVideoRecorder::FormatCC(struct cc *cc)
 {
@@ -2863,7 +2867,7 @@ void NuppelVideoRecorder::doVbiThread(void)
     //VERBOSE(VB_RECORD, LOC + "vbi end");
 }
 
-#else  // USING_V4L
+#else  // USING_V4L 
 void NuppelVideoRecorder::doVbiThread(void) { }
 #endif // USING_V4L
 
diff --git a/mythtv/libs/libmythtv/analogsignalmonitor.cpp b/mythtv/libs/libmythtv/analogsignalmonitor.cpp
index 2a4f4c5..fa5823a 100644
--- a/mythtv/libs/libmythtv/analogsignalmonitor.cpp
+++ b/mythtv/libs/libmythtv/analogsignalmonitor.cpp
@@ -6,7 +6,9 @@
 #include <sys/ioctl.h>
 #include <poll.h>
 
+#ifdef USING_V4L
 #include <linux/videodev.h>
+#endif
 
 #include "mythverbose.h"
 #include "analogsignalmonitor.h"
@@ -151,6 +153,7 @@ void AnalogSignalMonitor::UpdateValues(void)
     }
     else
     {
+#ifdef USING_V4L
         struct video_tuner tuner;
         bzero(&tuner, sizeof(tuner));
 
@@ -163,6 +166,7 @@ void AnalogSignalMonitor::UpdateValues(void)
         {
             isLocked = tuner.signal;
         }
+#endif
     }
 
     {
diff --git a/mythtv/libs/libmythtv/cardutil.cpp b/mythtv/libs/libmythtv/cardutil.cpp
index 8852682..494f48a 100644
--- a/mythtv/libs/libmythtv/cardutil.cpp
+++ b/mythtv/libs/libmythtv/cardutil.cpp
@@ -4,7 +4,7 @@
 
 #include <algorithm>
 
-#if defined(USING_V4L) || defined(USING_DVB)
+#if defined(USING_V4L) || defined(USING_V4L2) || defined(USING_DVB)
 #include <sys/ioctl.h>
 #endif
 
@@ -28,6 +28,8 @@
 
 #ifdef USING_V4L
 #include <linux/videodev.h>
+#endif
+#ifdef USING_V4L2
 #include <linux/videodev2.h>
 #endif
 
@@ -1455,15 +1457,15 @@ uint CardUtil::GetQuickTuning(uint cardid, const QString &input_name)
 bool CardUtil::hasV4L2(int videofd)
 {
     (void) videofd;
-#ifdef USING_V4L
+#ifdef USING_V4L2
     struct v4l2_capability vcap;
     bzero(&vcap, sizeof(vcap));
 
     return ((ioctl(videofd, VIDIOC_QUERYCAP, &vcap) >= 0) &&
             (vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE));
-#else // if !USING_V4L
+#else // if !USING_V4L2
     return false;
-#endif // !USING_V4L
+#endif // !USING_V4L2
 }
 
 bool CardUtil::GetV4LInfo(
@@ -1475,7 +1477,7 @@ bool CardUtil::GetV4LInfo(
     if (videofd < 0)
         return false;
 
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     // First try V4L2 query
     struct v4l2_capability capability;
     bzero(&capability, sizeof(struct v4l2_capability));
@@ -1487,11 +1489,13 @@ bool CardUtil::GetV4LInfo(
     }
     else // Fallback to V4L1 query
     {
+#ifdef USING_V4L
         struct video_capability capability;
         if (ioctl(videofd, VIDIOCGCAP, &capability) >= 0)
             card = QString::fromAscii((const char*)capability.name);
+#endif //USING_V4L
     }
-#endif // !USING_V4L
+#endif // !USING_V4L || USING_V4L2
 
     if (!driver.isEmpty())
         driver.remove( QRegExp("\\[[0-9]\\]$") );
@@ -1506,9 +1510,9 @@ InputNames CardUtil::ProbeV4LVideoInputs(int videofd, bool &ok)
     InputNames list;
     ok = false;
 
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     bool usingv4l2 = hasV4L2(videofd);
-
+#ifdef USING_V4L2
     // V4L v2 query
     struct v4l2_input vin;
     bzero(&vin, sizeof(vin));
@@ -1523,8 +1527,10 @@ InputNames CardUtil::ProbeV4LVideoInputs(int videofd, bool &ok)
         ok = true;
         return list;
     }
+#endif
 
     // V4L v1 query
+#ifdef USING_V4L
     struct video_capability vidcap;
     bzero(&vidcap, sizeof(vidcap));
     if (ioctl(videofd, VIDIOCGCAP, &vidcap) != 0)
@@ -1552,15 +1558,15 @@ InputNames CardUtil::ProbeV4LVideoInputs(int videofd, bool &ok)
 
         list[i] = test.name;
     }
-
+#endif
     // Create an input on single input cards that don't advertise input
     if (!list.size())
         list[0] = "Television";
 
     ok = true;
-#else // if !USING_V4L
+#else // if !USING_V4L || USING_V4L2
     list[-1] += QObject::tr("ERROR, Compile with V4L support to query inputs");
-#endif // !USING_V4L
+#endif // !USING_V4L || USING_V4L2
     return list;
 }
 
diff --git a/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp b/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
index 832d0a8..e35b186 100644
--- a/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
+++ b/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
@@ -1394,7 +1394,7 @@ const DVBChannel *ChannelScanSM::GetDVBChannel(void) const
 
 V4LChannel *ChannelScanSM::GetV4LChannel(void)
 {
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     return dynamic_cast<V4LChannel*>(channel);
 #else
     return NULL;
diff --git a/mythtv/libs/libmythtv/channelscan/channelscanner.cpp b/mythtv/libs/libmythtv/channelscan/channelscanner.cpp
index 1595d6a..4d2b2cf 100644
--- a/mythtv/libs/libmythtv/channelscan/channelscanner.cpp
+++ b/mythtv/libs/libmythtv/channelscan/channelscanner.cpp
@@ -342,7 +342,7 @@ void ChannelScanner::PreScanCommon(
         channel = new DVBChannel(device);
 #endif
 
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     if (("V4L" == card_type) || ("MPEG" == card_type))
         channel = new V4LChannel(NULL, device);
 #endif
diff --git a/mythtv/libs/libmythtv/channelscan/scanwizardconfig.cpp b/mythtv/libs/libmythtv/channelscan/scanwizardconfig.cpp
index 00fd9d3..70e3469 100644
--- a/mythtv/libs/libmythtv/channelscan/scanwizardconfig.cpp
+++ b/mythtv/libs/libmythtv/channelscan/scanwizardconfig.cpp
@@ -27,14 +27,14 @@ static QString card_types(void)
     cardTypes += "'DVB'";
 #endif // USING_DVB
 
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     if (!cardTypes.isEmpty())
         cardTypes += ",";
     cardTypes += "'V4L'";
 # ifdef USING_IVTV
     cardTypes += ",'MPEG'";
 # endif // USING_IVTV
-#endif // USING_V4L
+#endif // USING_V4L || USING_V4L2
 
 #ifdef USING_IPTV
     if (!cardTypes.isEmpty())
diff --git a/mythtv/libs/libmythtv/libmythtv.pro b/mythtv/libs/libmythtv/libmythtv.pro
index 3d26e0a..ea06ee7 100644
--- a/mythtv/libs/libmythtv/libmythtv.pro
+++ b/mythtv/libs/libmythtv/libmythtv.pro
@@ -119,7 +119,7 @@ cygwin:DEFINES += _WIN32
 using_valgrind:DEFINES += USING_VALGRIND
 
 # old libvbitext (Caption decoder)
-using_v4l {
+using_v4l || using_v4l2 {
     HEADERS += vbitext/cc.h vbitext/dllist.h vbitext/hamm.h vbitext/lang.h
     HEADERS += vbitext/vbi.h vbitext/vt.h
     SOURCES += vbitext/cc.cpp vbitext/vbi.c vbitext/hamm.c vbitext/lang.c
@@ -471,11 +471,17 @@ using_backend {
     SOURCES += channelchangemonitor.cpp
 
     # Support for Video4Linux devices
-    using_v4l {
+    using_v4l || using_v4l2 {
         HEADERS += v4lchannel.h                analogsignalmonitor.h
         SOURCES += v4lchannel.cpp              analogsignalmonitor.cpp
 
-        DEFINES += USING_V4L
+        using_v4l {
+            DEFINES += USING_V4L
+        }
+
+        using_v4l2 {
+            DEFINES += USING_V4L2
+        }
     }
 
     # Support for cable boxes that provide Firewire out
diff --git a/mythtv/libs/libmythtv/signalmonitor.cpp b/mythtv/libs/libmythtv/signalmonitor.cpp
index 221efef..c199b3b 100644
--- a/mythtv/libs/libmythtv/signalmonitor.cpp
+++ b/mythtv/libs/libmythtv/signalmonitor.cpp
@@ -23,7 +23,7 @@ extern "C" {
 #   include "dvbchannel.h"
 #endif
 
-#ifdef USING_V4L
+#ifdef USING_V4L2
 #   include "analogsignalmonitor.h"
 #   include "v4lchannel.h"
 #endif
@@ -95,7 +95,7 @@ SignalMonitor *SignalMonitor::Init(QString cardtype, int db_cardnum,
     }
 #endif
 
-#ifdef USING_V4L
+#ifdef USING_V4L2
     if ((cardtype.toUpper() == "HDPVR"))
     {
         V4LChannel *chan = dynamic_cast<V4LChannel*>(channel);
diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp
index b885eaa..3d9c7ad 100644
--- a/mythtv/libs/libmythtv/tv_rec.cpp
+++ b/mythtv/libs/libmythtv/tv_rec.cpp
@@ -57,7 +57,7 @@ using namespace std;
 
 #include "channelgroup.h"
 
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
 #include "v4lchannel.h"
 #endif
 
@@ -206,7 +206,7 @@ bool TVRec::CreateChannel(const QString &startchannel)
     }
     else // "V4L" or "MPEG", ie, analog TV
     {
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
         channel = new V4LChannel(this, genOpt.videodev);
         if (!channel->Open())
             return false;
@@ -1082,11 +1082,11 @@ bool TVRec::SetupRecorder(RecordingProfile &profile)
     }
     else
     {
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
         // V4L/MJPEG/GO7007 from here on
         recorder = new NuppelVideoRecorder(this, channel);
         recorder->SetOption("skipbtaudio", genOpt.skip_btaudio);
-#endif // USING_V4L
+#endif // USING_V4L || USING_V4L2
     }
 
     if (recorder)
@@ -1292,11 +1292,11 @@ FirewireChannel *TVRec::GetFirewireChannel(void)
 
 V4LChannel *TVRec::GetV4LChannel(void)
 {
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     return dynamic_cast<V4LChannel*>(channel);
 #else
     return NULL;
-#endif // USING_V4L
+#endif // USING_V4L || USING_V4L2
 }
 
 /** \fn TVRec::EventThread(void*)
@@ -4137,7 +4137,7 @@ void TVRec::TuningNewRecorder(MPEGStreamData *streamData)
                                   channel->GetCurrentName());
     }
 
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     if (GetV4LChannel())
     {
         channel->InitPictureAttributes();
diff --git a/mythtv/libs/libmythtv/v4lchannel.cpp b/mythtv/libs/libmythtv/v4lchannel.cpp
index bc82b49..7aa47ef 100644
--- a/mythtv/libs/libmythtv/v4lchannel.cpp
+++ b/mythtv/libs/libmythtv/v4lchannel.cpp
@@ -16,8 +16,12 @@
 #include <iostream>
 using namespace std;
 
+#ifdef USING_V4L
 #include <linux/videodev.h>
+#endif
+#ifdef USING_V4L2
 #include <linux/videodev2.h>
+#endif
 
 // MythTV headers
 #include "v4lchannel.h"
@@ -150,8 +154,10 @@ static int format_to_mode(const QString &fmt, int v4l_version)
     {
         if (fmt == "NTSC-JP")
             return 6;
+#ifdef USING_V4L
         else if (fmt.left(5) == "SECAM")
             return VIDEO_MODE_SECAM;
+#endif
         else if (fmt == "PAL-NC")
             return 3;
         else if (fmt == "PAL-M")
@@ -159,6 +165,7 @@ static int format_to_mode(const QString &fmt, int v4l_version)
         else if (fmt == "PAL-N")
             return 5;
         // generics...
+#ifdef USING_V4L
         else if (fmt.left(3) == "PAL")
             return VIDEO_MODE_PAL;
         else if (fmt.left(4) == "NTSC")
@@ -166,6 +173,7 @@ static int format_to_mode(const QString &fmt, int v4l_version)
         else if (fmt.left(4) == "ATSC")
             return VIDEO_MODE_NTSC; // We've dropped V4L ATSC support...
         return VIDEO_MODE_NTSC;
+#endif 
     }
 
     VERBOSE(VB_IMPORTANT,
@@ -237,6 +245,7 @@ static QString mode_to_format(int mode, int v4l_version)
     }
     else if (1 == v4l_version)
     {
+#ifdef USING_V4L    
         if (mode == VIDEO_MODE_NTSC)
             return "NTSC";
         else if (mode == VIDEO_MODE_PAL)
@@ -249,6 +258,7 @@ static QString mode_to_format(int mode, int v4l_version)
             return "PAL-N";
         else if (mode == 6)
             return "NTSC-JP";
+#endif
     }
     else
     {
@@ -676,6 +686,7 @@ bool V4LChannel::Tune(uint frequency, QString inputname,
         return true;
     }
 
+#ifdef USING_V4L
     // Video4Linux version 1 tuning
     uint freq = frequency / 62500;
     ioctlval = ioctl(videofd, VIDIOCSFREQ, &freq);
@@ -687,6 +698,7 @@ bool V4LChannel::Tune(uint frequency, QString inputname,
                 .arg(device).arg(ioctlval).arg(strerror(errno)));
         return false;
     }
+#endif
 
     SetSIStandard(si_std);
 
@@ -858,6 +870,7 @@ bool V4LChannel::SetInputAndFormat(int inputNum, QString newFmt)
 
     if (usingv4l1)
     {
+#ifdef USING_V4L
         VERBOSE(VB_CHANNEL, LOC + msg + "(v4l v1)");
 
         // read in old settings
@@ -875,8 +888,9 @@ bool V4LChannel::SetInputAndFormat(int inputNum, QString newFmt)
         {
             VERBOSE(VB_IMPORTANT, LOC_ERR + msg +
                     "\n\t\t\twhile setting format (v4l v1)" + ENO);
-        }
-        else if (usingv4l2)
+        } else
+#endif
+        if (usingv4l2)
         {
             VERBOSE(VB_IMPORTANT, LOC + msg +
                     "\n\t\t\tSetting video mode with v4l version 1 worked");
@@ -951,6 +965,7 @@ bool V4LChannel::SwitchToInput(int inputnum, bool setstarting)
     return ok;
 }
 
+#ifdef USING_V4L
 static unsigned short *get_v4l1_field(
     int v4l2_attrib, struct video_picture &vid_pic)
 {
@@ -970,6 +985,7 @@ static unsigned short *get_v4l1_field(
     }
     return NULL;
 }
+#endif
 
 static int get_v4l2_attribute(const QString &db_col_name)
 {
@@ -1067,6 +1083,7 @@ bool V4LChannel::InitPictureAttribute(const QString db_col_name)
     }
 
     // V4L1
+#ifdef USING_V4L
     unsigned short *setfield;
     struct video_picture vid_pic;
     bzero(&vid_pic, sizeof(vid_pic));
@@ -1087,7 +1104,7 @@ bool V4LChannel::InitPictureAttribute(const QString db_col_name)
         VERBOSE(VB_IMPORTANT, loc_err + "failed to set controls." + ENO);
         return false;
     }
-
+#endif
     return true;
 }
 
@@ -1154,6 +1171,7 @@ static int get_v4l2_attribute_value(int videofd, int v4l2_attrib)
 
 static int get_v4l1_attribute_value(int videofd, int v4l2_attrib)
 {
+#ifdef USING_V4L
     struct video_picture vid_pic;
     bzero(&vid_pic, sizeof(vid_pic));
 
@@ -1167,6 +1185,7 @@ static int get_v4l1_attribute_value(int videofd, int v4l2_attrib)
     unsigned short *setfield = get_v4l1_field(v4l2_attrib, vid_pic);
     if (setfield)
         return *setfield;
+#endif
 
     return -1;
 }
@@ -1210,6 +1229,7 @@ static int set_v4l2_attribute_value(int videofd, int v4l2_attrib, int newvalue)
 
 static int set_v4l1_attribute_value(int videofd, int v4l2_attrib, int newvalue)
 {
+#ifdef USING_V4L
     unsigned short *setfield;
     struct video_picture vid_pic;
     bzero(&vid_pic, sizeof(vid_pic));
@@ -1236,7 +1256,7 @@ static int set_v4l1_attribute_value(int videofd, int v4l2_attrib, int newvalue)
         // ???
         return -1;
     }
-
+#endif
     return 0;
 }
 
diff --git a/mythtv/libs/libmythtv/v4lchannel.h b/mythtv/libs/libmythtv/v4lchannel.h
index b059c64..aa6d934 100644
--- a/mythtv/libs/libmythtv/v4lchannel.h
+++ b/mythtv/libs/libmythtv/v4lchannel.h
@@ -4,11 +4,11 @@
 #define CHANNEL_H
 
 #include "dtvchannel.h"
-#ifdef USING_V4L
+#ifdef USING_V4L2
 #include <linux/videodev2.h> // needed for v4l2_std_id type
 #else
 typedef uint64_t v4l2_std_id;
-#endif //USING_V4L
+#endif //USING_V4L2
 
 using namespace std;
 
diff --git a/mythtv/libs/libmythtv/vbitext/vbi.c b/mythtv/libs/libmythtv/vbitext/vbi.c
index 15f8d85..4c50e8d 100644
--- a/mythtv/libs/libmythtv/vbitext/vbi.c
+++ b/mythtv/libs/libmythtv/vbitext/vbi.c
@@ -14,8 +14,12 @@
 //       compiling with -std=c99.  We could remove this in the .pro file,
 //       but that would disable it for all .c files.
 #undef __STRICT_ANSI__
+#ifdef USING_V4L
 #include <linux/videodev.h>
+#endif
+#ifdef USING_V4L2
 #include <linux/videodev2.h>
+#endif
 
 // vbitext headers
 #include "vt.h"
@@ -29,8 +33,13 @@ static int rawbuf_size;                // its current size
 
 
 /***** bttv api *****/
+#ifdef USING_V4L
 #define BTTV_VBISIZE           _IOR('v' , BASE_VIDIOCPRIVATE+8, int)
-
+#else // !USING_V4L
+#ifdef USING_V4L2
+#define BTTV_VBISIZE           _IOR('v' , BASE_VIDIOC_PRIVATE+8, int)
+#endif // USING_V4L2
+#endif // !USING_V4L
 
 static void
 error(const char *str, ...)
diff --git a/mythtv/libs/libmythtv/videosource.cpp b/mythtv/libs/libmythtv/videosource.cpp
index 5d7a508..635faeb 100644
--- a/mythtv/libs/libmythtv/videosource.cpp
+++ b/mythtv/libs/libmythtv/videosource.cpp
@@ -45,7 +45,7 @@ using namespace std;
 #include "dvbtypes.h"
 #endif
 
-#ifdef USING_V4L
+#ifdef USING_V4L2
 #include <linux/videodev2.h>
 #endif
 
@@ -2012,7 +2012,7 @@ CaptureCardGroup::CaptureCardGroup(CaptureCard &parent) :
     setTrigger(cardtype);
     setSaveAll(false);
 
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     addTarget("V4L",       new V4LConfigurationGroup(parent));
 # ifdef USING_IVTV
     addTarget("MPEG",      new MPEGConfigurationGroup(parent));
@@ -2020,7 +2020,7 @@ CaptureCardGroup::CaptureCardGroup(CaptureCard &parent) :
 # ifdef USING_HDPVR
     addTarget("HDPVR",     new HDPVRConfigurationGroup(parent));
 # endif // USING_HDPVR
-#endif // USING_V4L
+#endif // USING_V4L || USING_V4L2
 
 #ifdef USING_DVB
     addTarget("DVB",       new DVBConfigurationGroup(parent));
@@ -2201,7 +2201,7 @@ CardType::CardType(const CaptureCard &parent) :
 
 void CardType::fillSelections(SelectSetting* setting)
 {
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     setting->addSelection(
         QObject::tr("Analog V4L capture card"), "V4L");
     setting->addSelection(
@@ -2214,7 +2214,7 @@ void CardType::fillSelections(SelectSetting* setting)
     setting->addSelection(
         QObject::tr("H.264 encoder card (HD-PVR)"), "HDPVR");
 # endif // USING_HDPVR
-#endif // USING_V4L
+#endif // USING_V4L || USING_V4L2
 
 #ifdef USING_DVB
     setting->addSelection(
@@ -2226,11 +2226,11 @@ void CardType::fillSelections(SelectSetting* setting)
         QObject::tr("FireWire cable box"), "FIREWIRE");
 #endif // USING_FIREWIRE
 
-#ifdef USING_V4L
+#if defined(USING_V4L) || defined(USING_V4L2)
     setting->addSelection(
         QObject::tr("USB MPEG-4 encoder box (Plextor ConvertX, etc)"),
         "GO7007");
-#endif // USING_V4L
+#endif // USING_V4L || USING_V4L2
 
 #ifdef USING_HDHOMERUN
     setting->addSelection(