1 from enigma import eTimer
2 from Components.config import config, ConfigSubsection, ConfigSlider, ConfigSelection, ConfigYesNo, NoSave
3 from Tools.CList import CList
4 from Tools.HardwareInfo import HardwareInfo
6 # The "VideoEnhancement" is the interface to /proc/stb/vmpeg/0.
8 class VideoEnhancement:
13 self.last_modes_preferred = [ ]
14 self.on_hotplug = CList()
17 def createConfig(self, *args):
18 hw_type = HardwareInfo().get_device_name()
19 config.pep = ConfigSubsection()
21 config.pep.configsteps = NoSave(ConfigSelection(choices=[1, 5, 10, 25], default = 1))
23 def setContrast(config):
24 myval = int(config.value*256)
26 print "--> setting contrast to: %0.8X" % myval
27 open("/proc/stb/vmpeg/0/pep_contrast", "w").write("%0.8X" % myval)
29 print "couldn't write pep_contrast."
31 if VideoEnhancement.firstRun is False:
32 self.setConfiguredValues()
34 config.pep.contrast = ConfigSlider(default=128, limits=(0,256))
35 config.pep.contrast.addNotifier(setContrast)
37 def setSaturation(config):
38 myval = int(config.value*256)
40 print "--> setting saturation to: %0.8X" % myval
41 open("/proc/stb/vmpeg/0/pep_saturation", "w").write("%0.8X" % myval)
43 print "couldn't write pep_saturaion."
45 if VideoEnhancement.firstRun is False:
46 self.setConfiguredValues()
48 config.pep.saturation = ConfigSlider(default=128, limits=(0,256))
49 config.pep.saturation.addNotifier(setSaturation)
52 myval = int(config.value*256)
54 print "--> setting hue to: %0.8X" % myval
55 open("/proc/stb/vmpeg/0/pep_hue", "w").write("%0.8X" % myval)
57 print "couldn't write pep_hue."
59 if VideoEnhancement.firstRun is False:
60 self.setConfiguredValues()
62 config.pep.hue = ConfigSlider(default=128, limits=(0,256))
63 config.pep.hue.addNotifier(setHue)
65 def setBrightness(config):
66 myval = int(config.value*256)
68 print "--> setting brightness to: %0.8X" % myval
69 open("/proc/stb/vmpeg/0/pep_brightness", "w").write("%0.8X" % myval)
71 print "couldn't write pep_brightness."
73 if VideoEnhancement.firstRun is False:
74 self.setConfiguredValues()
76 config.pep.brightness = ConfigSlider(default=128, limits=(0,256))
77 config.pep.brightness.addNotifier(setBrightness)
79 def setBlock_noise_reduction(config):
80 myval = int(config.value)
82 print "--> setting block_noise_reduction to: %0.8X" % myval
83 open("/proc/stb/vmpeg/0/pep_block_noise_reduction", "w").write("%0.8X" % myval)
85 print "couldn't write pep_block_noise_reduction."
87 if VideoEnhancement.firstRun is False:
88 self.setConfiguredValues()
90 config.pep.block_noise_reduction = ConfigSlider(default=0, limits=(0,5))
91 config.pep.block_noise_reduction.addNotifier(setBlock_noise_reduction)
93 def setMosquito_noise_reduction(config):
94 myval = int(config.value)
96 print "--> setting mosquito_noise_reduction to: %0.8X" % myval
97 open("/proc/stb/vmpeg/0/pep_mosquito_noise_reduction", "w").write("%0.8X" % myval)
99 print "couldn't write pep_mosquito_noise_reduction."
101 if VideoEnhancement.firstRun is False:
102 self.setConfiguredValues()
104 config.pep.mosquito_noise_reduction = ConfigSlider(default=0, limits=(0,5))
105 config.pep.mosquito_noise_reduction.addNotifier(setMosquito_noise_reduction)
107 def setDigital_contour_removal(config):
108 myval = int(config.value)
110 print "--> setting digital_contour_removal to: %0.8X" % myval
111 open("/proc/stb/vmpeg/0/pep_digital_contour_removal", "w").write("%0.8X" % myval)
113 print "couldn't write pep_digital_contour_removal."
115 if VideoEnhancement.firstRun is False:
116 self.setConfiguredValues()
118 config.pep.digital_contour_removal = ConfigSlider(default=0, limits=(0,5))
119 config.pep.digital_contour_removal.addNotifier(setDigital_contour_removal)
121 if hw_type in ( 'dm8000', 'dm500hd' ):
122 def setSplitMode(config):
124 print "--> setting splitmode to:",str(config.value)
125 open("/proc/stb/vmpeg/0/pep_split", "w").write(str(config.value))
127 print "couldn't write pep_split."
129 if VideoEnhancement.firstRun is False:
130 self.setConfiguredValues()
132 config.pep.split = ConfigSelection(choices={
135 "right": _("Right")},
137 config.pep.split.addNotifier(setSplitMode)
139 def setSharpness(config):
140 myval = int(config.value*256)
142 print "--> setting sharpness to: %0.8X" % myval
143 open("/proc/stb/vmpeg/0/pep_sharpness", "w").write("%0.8X" % myval)
145 print "couldn't write pep_sharpness."
147 if VideoEnhancement.firstRun is False:
148 self.setConfiguredValues()
150 config.pep.sharpness = ConfigSlider(default=0, limits=(0,256))
151 config.pep.sharpness.addNotifier(setSharpness)
153 def setAutoflesh(config):
154 myval = int(config.value)
156 print "--> setting auto_flesh to: %0.8X" % myval
157 open("/proc/stb/vmpeg/0/pep_auto_flesh", "w").write("%0.8X" % myval)
159 print "couldn't write pep_auto_flesh."
161 if VideoEnhancement.firstRun is False:
162 self.setConfiguredValues()
164 config.pep.auto_flesh = ConfigSlider(default=0, limits=(0,4))
165 config.pep.auto_flesh.addNotifier(setAutoflesh)
167 def setGreenboost(config):
168 myval = int(config.value)
170 print "--> setting green_boost to: %0.8X" % myval
171 open("/proc/stb/vmpeg/0/pep_green_boost", "w").write("%0.8X" % myval)
173 print "couldn't write pep_green_boost."
175 if VideoEnhancement.firstRun is False:
176 self.setConfiguredValues()
178 config.pep.green_boost = ConfigSlider(default=0, limits=(0,4))
179 config.pep.green_boost.addNotifier(setGreenboost)
181 def setBlueboost(config):
182 myval = int(config.value)
184 print "--> setting blue_boost to: %0.8X" % myval
185 open("/proc/stb/vmpeg/0/pep_blue_boost", "w").write("%0.8X" % myval)
187 print "couldn't write pep_blue_boost."
189 if VideoEnhancement.firstRun is False:
190 self.setConfiguredValues()
192 config.pep.blue_boost = ConfigSlider(default=0, limits=(0,4))
193 config.pep.blue_boost.addNotifier(setBlueboost)
195 def setDynamic_contrast(config):
196 myval = int(config.value)
198 print "--> setting dynamic_contrast to: %0.8X" % myval
199 open("/proc/stb/vmpeg/0/pep_dynamic_contrast", "w").write("%0.8X" % myval)
201 print "couldn't write pep_dynamic_contrast."
203 if VideoEnhancement.firstRun is False:
204 self.setConfiguredValues()
206 config.pep.dynamic_contrast = ConfigSlider(default=0, limits=(0,256))
207 config.pep.dynamic_contrast.addNotifier(setDynamic_contrast)
209 VideoEnhancement.firstRun = True
211 def setConfiguredValues(self):
213 print "--> applying pep values"
214 open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
215 VideoEnhancement.firstRun = False
217 print "couldn't apply pep values."
220 if config.usage.setup_level.index >= 2: # expert+
221 hw_type = HardwareInfo().get_device_name()
222 if hw_type in ( 'dm8000', 'dm800', 'dm500hd' ):
223 video_enhancement = VideoEnhancement()
224 if video_enhancement.firstRun == True:
225 video_enhancement.setConfiguredValues()