1 from enigma import eTimer
2 from Components.config import config, ConfigSubsection, ConfigSlider, ConfigSelection,ConfigYesNo
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 def setContrast(config):
22 myval = int(config.value*256)
24 print "--> setting contrast to: %0.8X" % myval
25 open("/proc/stb/vmpeg/0/pep_contrast", "w").write("%0.8X" % myval)
27 print "couldn't write pep_contrast."
29 if VideoEnhancement.firstRun is False:
30 self.setConfiguredValues()
32 config.pep.contrast = ConfigSlider(default=128, limits=(0,256))
33 config.pep.contrast.addNotifier(setContrast)
35 def setSaturation(config):
36 myval = int(config.value*256)
38 print "--> setting saturation to: %0.8X" % myval
39 open("/proc/stb/vmpeg/0/pep_saturation", "w").write("%0.8X" % myval)
41 print "couldn't write pep_saturaion."
43 if VideoEnhancement.firstRun is False:
44 self.setConfiguredValues()
46 config.pep.saturation = ConfigSlider(default=128, limits=(0,256))
47 config.pep.saturation.addNotifier(setSaturation)
50 myval = int(config.value*256)
52 print "--> setting hue to: %0.8X" % myval
53 open("/proc/stb/vmpeg/0/pep_hue", "w").write("%0.8X" % myval)
55 print "couldn't write pep_hue."
57 if VideoEnhancement.firstRun is False:
58 self.setConfiguredValues()
60 config.pep.hue = ConfigSlider(default=128, limits=(0,256))
61 config.pep.hue.addNotifier(setHue)
63 def setBrightness(config):
64 myval = int(config.value*256)
66 print "--> setting brightness to: %0.8X" % myval
67 open("/proc/stb/vmpeg/0/pep_brightness", "w").write("%0.8X" % myval)
69 print "couldn't write pep_brightness."
71 if VideoEnhancement.firstRun is False:
72 self.setConfiguredValues()
74 config.pep.brightness = ConfigSlider(default=128, limits=(0,256))
75 config.pep.brightness.addNotifier(setBrightness)
77 def setBlock_noise_reduction(config):
78 myval = int(config.value)
80 print "--> setting block_noise_reduction to: %0.8X" % myval
81 open("/proc/stb/vmpeg/0/pep_block_noise_reduction", "w").write("%0.8X" % myval)
83 print "couldn't write pep_block_noise_reduction."
85 if VideoEnhancement.firstRun is False:
86 self.setConfiguredValues()
88 config.pep.block_noise_reduction = ConfigSlider(default=0, limits=(0,5))
89 config.pep.block_noise_reduction.addNotifier(setBlock_noise_reduction)
91 def setMosquito_noise_reduction(config):
92 myval = int(config.value)
94 print "--> setting mosquito_noise_reduction to: %0.8X" % myval
95 open("/proc/stb/vmpeg/0/pep_mosquito_noise_reduction", "w").write("%0.8X" % myval)
97 print "couldn't write pep_mosquito_noise_reduction."
99 if VideoEnhancement.firstRun is False:
100 self.setConfiguredValues()
102 config.pep.mosquito_noise_reduction = ConfigSlider(default=0, limits=(0,5))
103 config.pep.mosquito_noise_reduction.addNotifier(setMosquito_noise_reduction)
105 def setDigital_contour_removal(config):
106 myval = int(config.value)
108 print "--> setting digital_contour_removal to: %0.8X" % myval
109 open("/proc/stb/vmpeg/0/pep_digital_contour_removal", "w").write("%0.8X" % myval)
111 print "couldn't write pep_digital_contour_removal."
113 if VideoEnhancement.firstRun is False:
114 self.setConfiguredValues()
116 config.pep.digital_contour_removal = ConfigSlider(default=0, limits=(0,5))
117 config.pep.digital_contour_removal.addNotifier(setDigital_contour_removal)
119 if hw_type == 'dm8000':
120 def setSplitMode(config):
122 print "--> setting splitmode to:",str(config.value)
123 open("/proc/stb/vmpeg/0/pep_split", "w").write(str(config.value))
125 print "couldn't write pep_split."
127 if VideoEnhancement.firstRun is False:
128 self.setConfiguredValues()
130 config.pep.split = ConfigSelection(choices={
133 "right": _("Right")},
135 config.pep.split.addNotifier(setSplitMode)
137 def setSharpness(config):
138 myval = int(config.value*256)
140 print "--> setting sharpness to: %0.8X" % myval
141 open("/proc/stb/vmpeg/0/pep_sharpness", "w").write("%0.8X" % myval)
143 print "couldn't write pep_sharpness."
145 if VideoEnhancement.firstRun is False:
146 self.setConfiguredValues()
148 config.pep.sharpness = ConfigSlider(default=0, limits=(0,256))
149 config.pep.sharpness.addNotifier(setSharpness)
151 def setAutoflesh(config):
152 myval = int(config.value)
154 print "--> setting auto_flesh to: %0.8X" % myval
155 open("/proc/stb/vmpeg/0/pep_auto_flesh", "w").write("%0.8X" % myval)
157 print "couldn't write pep_auto_flesh."
159 if VideoEnhancement.firstRun is False:
160 self.setConfiguredValues()
162 config.pep.auto_flesh = ConfigSlider(default=0, limits=(0,4))
163 config.pep.auto_flesh.addNotifier(setAutoflesh)
165 def setGreenboost(config):
166 myval = int(config.value)
168 print "--> setting green_boost to: %0.8X" % myval
169 open("/proc/stb/vmpeg/0/pep_green_boost", "w").write("%0.8X" % myval)
171 print "couldn't write pep_green_boost."
173 if VideoEnhancement.firstRun is False:
174 self.setConfiguredValues()
176 config.pep.green_boost = ConfigSlider(default=0, limits=(0,4))
177 config.pep.green_boost.addNotifier(setGreenboost)
179 def setBlueboost(config):
180 myval = int(config.value)
182 print "--> setting blue_boost to: %0.8X" % myval
183 open("/proc/stb/vmpeg/0/pep_blue_boost", "w").write("%0.8X" % myval)
185 print "couldn't write pep_blue_boost."
187 if VideoEnhancement.firstRun is False:
188 self.setConfiguredValues()
190 config.pep.blue_boost = ConfigSlider(default=0, limits=(0,4))
191 config.pep.blue_boost.addNotifier(setBlueboost)
193 def setDynamic_contrast(config):
194 myval = int(config.value)
196 print "--> setting dynamic_contrast to: %0.8X" % myval
197 open("/proc/stb/vmpeg/0/pep_dynamic_contrast", "w").write("%0.8X" % myval)
199 print "couldn't write pep_dynamic_contrast."
201 if VideoEnhancement.firstRun is False:
202 self.setConfiguredValues()
204 config.pep.dynamic_contrast = ConfigSlider(default=0, limits=(0,256))
205 config.pep.dynamic_contrast.addNotifier(setDynamic_contrast)
207 VideoEnhancement.firstRun = True
209 def setConfiguredValues(self):
211 print "--> applying pep values"
212 open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
213 VideoEnhancement.firstRun = False
215 print "couldn't apply pep values."
218 if config.usage.setup_level.index >= 2: # expert+
219 hw_type = HardwareInfo().get_device_name()
220 if hw_type == 'dm8000' or hw_type == 'dm800':
221 video_enhancement = VideoEnhancement()
222 if video_enhancement.firstRun == True:
223 video_enhancement.setConfiguredValues()