1 #include <lib/driver/streamwd.h>
9 #if HAVE_DVB_API_VERSION < 3
10 #include "ost/video.h"
12 #include "linux/dvb/video.h"
15 #include <dbox/event.h>
17 #include <lib/base/eerror.h>
18 #include <lib/driver/eavswitch.h>
19 #include <lib/dvb/edvb.h>
20 #include <lib/dvb/decoder.h>
21 #include <lib/system/info.h>
22 #include <lib/system/init.h>
23 #include <lib/system/init_num.h>
24 #include <lib/system/econfig.h>
26 #define EVENT_DEVICE "/dev/dbox/event0"
28 #ifndef EVENT_FRATE_CHANGE
29 #define EVENT_FRATE_CHANGE 64 /* framerate has changed */
32 eStreamWatchdog
*eStreamWatchdog::instance
;
34 eStreamWatchdog::eStreamWatchdog()
37 handle
=open( EVENT_DEVICE
, O_RDONLY
| O_NONBLOCK
);
41 eDebug("failed to open %s", EVENT_DEVICE
);
46 if ( ioctl(handle
, EVENT_SET_FILTER
, EVENT_ARATIO_CHANGE
| EVENT_VCR_CHANGED
| EVENT_FRATE_CHANGE
) < 0 )
53 sn
=new eSocketNotifier(eApp
, handle
, eSocketNotifier::Read
);
54 CONNECT(sn
->activated
, eStreamWatchdog::check
);
63 eStreamWatchdog
*eStreamWatchdog::getInstance()
68 void eStreamWatchdog::check(int)
71 int eventSize
= sizeof (event
);
73 while ( (status
= read(handle
, &event
, eventSize
)) == eventSize
)
75 if (event
.event
& (EVENT_ARATIO_CHANGE
|EVENT_FRATE_CHANGE
|EVENT_VCR_CHANGED
))
80 #define FP_IOCTL_GET_VCR 7
82 int eStreamWatchdog::getVCRActivity()
85 int fp
= open("/dev/dbox/fp0",O_RDWR
);
87 ioctl(fp
, FP_IOCTL_GET_VCR
, &val
);
94 void eStreamWatchdog::reloadSettings(int override_aspect
)
96 static int prevVcrSlbVlt
=-1;
97 int VcrSlbVlt
= getVCRActivity();
98 if (eAVSwitch::getInstance()->getInput() && VcrSlbVlt
&& VcrSlbVlt
!= prevVcrSlbVlt
) // VCR selected
100 prevVcrSlbVlt
=VcrSlbVlt
;
101 // Loop through VCR Slowblanking values to TV Slowblanking
102 if ( eSystemInfo::getInstance()->getHwType() >= eSystemInfo::DM7000
)
103 eAVSwitch::getInstance()->setTVPin8(VcrSlbVlt
==2?12:6);
107 FILE *bitstream
=fopen("/proc/bus/bitstream", "rt");
113 while (fgets(buffer
, 100, bitstream
))
115 if (!strncmp(buffer
, "A_RATIO: ", 9))
116 aspect
=atoi(buffer
+9);
117 if (!strncmp(buffer
, "F_RATE: ", 8))
118 frate
=atoi(buffer
+8);
121 if (override_aspect
!= -1)
122 aspect
= override_aspect
;
135 /*emit*/ AspectRatioChanged(isanamorph
);
137 int videoDisplayFormat
=VIDEO_LETTER_BOX
;
139 unsigned int pin8
; // Letterbox
140 eConfig::getInstance()->getKey("/elitedvb/video/pin8", pin8
);
145 videoDisplayFormat
=isanamorph
?VIDEO_LETTER_BOX
:VIDEO_PAN_SCAN
;
149 videoDisplayFormat
=VIDEO_PAN_SCAN
;
152 doanamorph
=isanamorph
;
153 videoDisplayFormat
=isanamorph
?VIDEO_CENTER_CUT_OUT
:VIDEO_PAN_SCAN
;
157 videoDisplayFormat
=VIDEO_CENTER_CUT_OUT
;
160 eAVSwitch::getInstance()->setVideoFormat( videoDisplayFormat
);
161 eAVSwitch::getInstance()->setAspectRatio(doanamorph
?r169
:r43
);
169 eAVSwitch::getInstance()->setVSystem(vsPAL
);
175 eAVSwitch::getInstance()->setVSystem(vsNTSC
);
178 unsigned int auto_vcr_switching
=1;
179 eConfig::getInstance()->getKey("/elitedvb/video/vcr_switching", auto_vcr_switching
);
180 if ( auto_vcr_switching
&& VcrSlbVlt
!= prevVcrSlbVlt
)
182 prevVcrSlbVlt
=VcrSlbVlt
;
183 /*emit*/VCRActivityChanged( VcrSlbVlt
);
187 int eStreamWatchdog::isAnamorph()
192 eStreamWatchdog::~eStreamWatchdog()
204 eAutoInitP0
<eStreamWatchdog
> eStreamWatchdog_init(eAutoInitNumbers::dvb
-1, "stream watchdog");