示例#1
0
	def setColorFormat(self, value):
		if not self.current_port:
			self.current_port = config.av.videoport.value
		if self.current_port in ("YPbPr", "Scart-YPbPr"):
			eAVSwitch.getInstance().setColorFormat(3)
		else:
			eAVSwitch.getInstance().setColorFormat(value)
示例#2
0
	def __init__(self, session):
		self.force = False
		self.current_vcr_sb = eAVSwitch.getInstance().getVCRSlowBlanking()
		if self.current_vcr_sb and config.av.vcrswitch.value:
			self.scartDialog = session.instantiateDialog(Scart, True)
		else:
			self.scartDialog = session.instantiateDialog(Scart, False)
		config.av.vcrswitch.addNotifier(self.recheckVCRSb)
		eAVSwitch.getInstance().vcr_sb_notifier.get().append(self.VCRSbChanged)
示例#3
0
	def updateColor(self, port):
		print "updateColor: ", port
		if port == "HDMI":
			self.setHDMIColor(config.av.colorformat_hdmi)
		elif port == "Component":
			self.setYUVColor(config.av.colorformat_yuv)
		elif port == "Scart":
			map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
			from enigma import eAVSwitch
			eAVSwitch.getInstance().setColorFormat(map[config.av.colorformat.value])
示例#4
0
	def updateColor(self, port):
		if about.getCPUString().startswith('STx'):
			print "updateColor: ", port
			if port == "DVI":
				self.setHDMIColor(config.av.colorformat_hdmi)
			elif port == "YPbPr":
				self.setYUVColor(config.av.colorformat_yuv)
			elif port == "Scart":
				map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
				from enigma import eAVSwitch
				eAVSwitch.getInstance().setColorFormat(map[config.av.colorformat.value])
示例#5
0
	def updateAspect(self, cfgelement):
		# based on;
		#   config.av.videoport.value: current video output device
		#     Scart: 
		#   config.av.aspect:
		#     4_3:            use policy_169
		#     16_9,16_10:     use policy_43
		#     auto            always "bestfit"
		#   config.av.policy_169
		#     letterbox       use letterbox
		#     panscan         use panscan
		#     scale           use bestfit
		#   config.av.policy_43
		#     pillarbox       use panscan
		#     panscan         use letterbox  ("panscan" is just a bad term, it's inverse-panscan)
		#     nonlinear       use nonlinear
		#     scale           use bestfit

		valstr = config.av.aspect.value
		if valstr == "auto":
			val = 0
		elif valstr == "4_3":
			val = 2
		elif valstr == "16_9":
			val = 3
		elif valstr == "16_10":
			val = 3
		eAVSwitch.getInstance().setAspectRatio(val)

		valstr = config.av.policy_43.value
		if valstr == "zoom":
			val = 4
		elif valstr == "pillarbox":
			val = 3
		elif valstr == "panscan":
			val = 2
		elif valstr == "nonlinear":
			val = 1
		else:
			val = 0
		eAVSwitch.getInstance().setPolicy43(val)
		
		valstr = config.av.policy_169.value
		if valstr == "zoom":
			val = 3
		elif valstr == "letterbox":
			val = 2
		elif valstr == "panscan":
			val = 1
		else:
			val = 0
		eAVSwitch.getInstance().setPolicy169(val)
		eAVSwitch.getInstance().setZoom(int(config.pc.image4_3_zoom_x.value), int(config.pc.image4_3_zoom_y.value), int(config.pc.image16_9_zoom_x.value), int(config.pc.image16_9_zoom_y.value))
		eAVSwitch.getInstance().updateScreen()
 def change_ratio(self):
     print "change ratio by np"
     policy_input = open("/proc/stb/video/policy", "r")
     policy = policy_input.read()
     policy_input.close()
     print "VideoModeLight policy current", policy
     global tmppolicy
     print "VideoModeLight tmppolicy current", tmppolicy
     if tmppolicy == "None":
         tmppolicy = policy
     if tmppolicy.find("letterbox") != -1:
         print "VideoModeLight set policy letterbox"
         tmppolicy = "non"
         eAVSwitch.getInstance().setAspectRatio(0)
         self.session.open(MessageBox, "LETTERBOX", MessageBox.TYPE_WARNING, timeout=2)
     elif tmppolicy.find("non") != -1:
         print "VideoModeLight set policy non"
         tmppolicy = "panscan"
         eAVSwitch.getInstance().setAspectRatio(3)
         self.session.open(MessageBox, "NONLINEAR", MessageBox.TYPE_WARNING, timeout=2)
     elif tmppolicy.find("panscan") != -1:
         print "VideoModeLight set policy panscan"
         tmppolicy = "bestfit"
         eAVSwitch.getInstance().setAspectRatio(1)
         self.session.open(MessageBox, "PANSCAN", MessageBox.TYPE_WARNING, timeout=2)
     elif tmppolicy.find("bestfit") != -1:
         print "VideoModeLight set policy bestfit"
         tmppolicy = "letterbox"
         eAVSwitch.getInstance().setAspectRatio(2)
         self.session.open(MessageBox, "BESTFIT", MessageBox.TYPE_WARNING, timeout=2)
示例#7
0
	def aspectChange(self):
		print "Aspect Ratio"
		global aspectratiomode
		print  aspectratiomode
		if aspectratiomode == "1": #letterbox
			eAVSwitch.getInstance().setAspectRatio(0)
			aspectratiomode = "2"
		elif aspectratiomode == "2": #nonlinear
			eAVSwitch.getInstance().setAspectRatio(4)
			aspectratiomode = "3"
		elif aspectratiomode == "2": #nonlinear
			eAVSwitch.getInstance().setAspectRatio(2)
			aspectratiomode = "3"
		elif aspectratiomode == "3": #panscan
			eAVSwitch.getInstance().setAspectRatio(3)
			aspectratiomode = "1"		
示例#8
0
 def setColorFormat(self, value):
     if not self.current_port:
         self.current_port = config.av.videoport.value
     if self.current_port in ('YPbPr', 'Scart-YPbPr'):
         eAVSwitch.getInstance().setColorFormat(3)
     elif self.current_port in 'RCA':
         eAVSwitch.getInstance().setColorFormat(0)
     else:
         eAVSwitch.getInstance().setColorFormat(value)
示例#9
0
def InitAVSwitch():
    config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}

    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
    config.av.aspectratio = ConfigSelection(
        choices={
            "4_3_letterbox": _("4:3 Letterbox"),
            "4_3_panscan": _("4:3 PanScan"),
            "16_9": _("16:9"),
            "16_9_always": _("16:9 always"),
            "16_10_letterbox": _("16:10 Letterbox"),
            "16_10_panscan": _("16:10 PanScan"),
            "16_9_letterbox": _("16:9 Letterbox"),
        },
        default="16_9",
    )
    config.av.aspect = ConfigSelection(
        choices={"4_3": _("4:3"), "16_9": _("16:9"), "16_10": _("16:10"), "auto": _("Automatic")}, default="auto"
    )
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "scale": _("Just scale"),
    }
    if (
        os.path.exists("/proc/stb/video/policy2_choices")
        and "auto" in open("/proc/stb/video/policy2_choices").readline()
    ):
        # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
        policy2_choices.update({"auto": _("Auto")})
    config.av.policy_169 = ConfigSelection(choices=policy2_choices, default="letterbox")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "pillarbox": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
        "nonlinear": _("Nonlinear"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "scale": _("Just scale"),
    }
    if os.path.exists("/proc/stb/video/policy_choices") and "auto" in open("/proc/stb/video/policy_choices").readline():
        # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
        policy_choices.update({"auto": _("Auto")})
    config.av.policy_43 = ConfigSelection(choices=policy_choices, default="pillarbox")
    config.av.tvsystem = ConfigSelection(
        choices={"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal"
    )
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        if getBoxType() == "gbquad" or getBoxType() == "gbquadplus":
            map = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
        else:
            map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6,
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

        # this will call the "setup-val" initial

    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

    if os.path.exists("/proc/stb/audio/3d_surround_choices"):
        f = open("/proc/stb/audio/3d_surround_choices", "r")
        can_3dsurround = f.read().strip().split(" ")
        f.close()
    else:
        can_3dsurround = False

    SystemInfo["Can3DSurround"] = can_3dsurround

    if can_3dsurround:

        def set3DSurround(configElement):
            f = open("/proc/stb/audio/3d_surround", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.surround_3d = ConfigSelection(choices=choice_list, default="none")
        config.av.surround_3d.addNotifier(set3DSurround)
    else:
        config.av.surround_3d = ConfigNothing()

    if os.path.exists("/proc/stb/audio/avl_choices"):
        f = open("/proc/stb/audio/avl_choices", "r")
        can_autovolume = f.read().strip().split(" ")
        f.close()
    else:
        can_autovolume = False

    SystemInfo["CanAutoVolume"] = can_autovolume

    if can_autovolume:

        def setAutoVulume(configElement):
            f = open("/proc/stb/audio/avl", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.autovolume = ConfigSelection(choices=choice_list, default="none")
        config.av.autovolume.addNotifier(setAutoVulume)
    else:
        config.av.autovolume = ConfigNothing()
    try:
        can_downmix = "downmix" in open("/proc/stb/audio/ac3_choices", "r").read()
    except:
        can_downmix = False

    SystemInfo["CanDownmixAC3"] = can_downmix
    if can_downmix:

        def setAC3Downmix(configElement):
            open("/proc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    try:
        can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
    except:
        can_osd_alpha = False

    SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha

    def setAlpha(config):
        open("/proc/stb/video/alpha", "w").write(str(config.value))

    if can_osd_alpha:
        config.av.osd_alpha = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "--> setting scaler_sharpness to: %0.8X" % myval
                open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval)
                open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        if getBoxType() == "gbquad" or getBoxType() == "gbquadplus":
            config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
        else:
            config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())
示例#10
0
	def updateSDfeatures(self, cfgelement):
		print "-> update SD features !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		eAVSwitch.getInstance().setSDfeatures(int(config.pc.sd_sharpness.value), int(config.pc.sd_noise.value))
示例#11
0
def InitAVSwitch():
	config.av = ConfigSubsection()
	config.av.yuvenabled = ConfigBoolean(default=True)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}

	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4_3": _("4:3"),
			"16_9": _("16:9"),
			"16_10": _("16:10"),
			"auto": _("Automatic")},
			default = "auto")
	policy2_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
	"letterbox": _("Letterbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	try:
		if "auto" in open("/proc/stb/video/policy2_choices").read():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy2_choices.update({"auto": _("Auto")})
	except:
		pass
	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default = "letterbox")
	policy_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
	"pillarbox": _("Pillarbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
	"nonlinear": _("Nonlinear"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	try:
		if "auto" in open("/proc/stb/video/policy_choices").read():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy_choices.update({"auto": _("Auto")})
	except:
		pass
	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "pillarbox")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	iAVSwitch = AVSwitch()

	def setColorFormat(configElement):
		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		iAVSwitch.setColorFormat(map[configElement.value])

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])

	def setSystem(configElement):
		map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
		iAVSwitch.setSystem(map[configElement.value])

	def setWSS(configElement):
		iAVSwitch.setAspectWSS()

	# this will call the "setup-val" initial
	config.av.colorformat.addNotifier(setColorFormat)
	config.av.aspectratio.addNotifier(setAspectRatio)
	config.av.tvsystem.addNotifier(setSystem)
	config.av.wss.addNotifier(setWSS)

	iAVSwitch.setInput("ENCODER") # init on startup
	SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

	try:
		SystemInfo["CanDownmixAC3"] = "downmix" in open("/proc/stb/audio/ac3_choices", "r").read()
	except:
		SystemInfo["CanDownmixAC3"] = False

	if SystemInfo["CanDownmixAC3"]:
		def setAC3Downmix(configElement):
			open("/proc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	try:
		SystemInfo["CanDownmixDTS"] = "downmix" in open("/proc/stb/audio/dts_choices", "r").read()
	except:
		SystemInfo["CanDownmixDTS"] = False

	if SystemInfo["CanDownmixDTS"]:
		def setDTSDownmix(configElement):
			open("/proc/stb/audio/dts", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_dts = ConfigYesNo(default = True)
		config.av.downmix_dts.addNotifier(setDTSDownmix)

	try:
		SystemInfo["CanDownmixAAC"] = "downmix" in open("/proc/stb/audio/aac_choices", "r").read()
	except:
		SystemInfo["CanDownmixAAC"] = False

	if SystemInfo["CanDownmixAAC"]:
		def setAACDownmix(configElement):
			open("/proc/stb/audio/aac", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_aac = ConfigYesNo(default = True)
		config.av.downmix_aac.addNotifier(setAACDownmix)

	try:
		SystemInfo["CanChangeOsdAlpha"] = open("/proc/stb/video/alpha", "r") and True or False
	except:
		SystemInfo["CanChangeOsdAlpha"] = False

	if SystemInfo["CanChangeOsdAlpha"]:
		def setAlpha(config):
			open("/proc/stb/video/alpha", "w").write(str(config.value))
		config.av.osd_alpha = ConfigSlider(default=255, limits=(0,255))
		config.av.osd_alpha.addNotifier(setAlpha)

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print "--> setting scaler_sharpness to: %0.8X" % myval
				open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval)
				open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())

	if SystemInfo["HasMultichannelPCM"]:
		def setMultichannelPCM(configElement):
			open(SystemInfo["HasMultichannelPCM"], "w").write(configElement.value and "enable" or "disable")
		config.av.multichannel_pcm = ConfigYesNo(default = False)
		config.av.multichannel_pcm.addNotifier(setMultichannelPCM)

	if SystemInfo["HasAutoVolume"]:
		def setAutoVolume(configElement):
			open(SystemInfo["HasAutoVolume"], "w").write(configElement.value)
		config.av.autovolume = ConfigSelection(default = "none", choices = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))])
		config.av.autovolume.addNotifier(setAutoVolume)

	if SystemInfo["HasAutoVolumeLevel"]:
		def setAutoVolumeLevel(configElement):
			open(SystemInfo["HasAutoVolumeLevel"], "w").write(configElement.value and "enabled" or "disabled")
		config.av.autovolumelevel = ConfigYesNo(default = False)
		config.av.autovolumelevel.addNotifier(setAutoVolumeLevel)

	if SystemInfo["Has3DSurround"]:
		def set3DSurround(configElement):
			open(SystemInfo["Has3DSurround"], "w").write(configElement.value)
		config.av.surround_3d = ConfigSelection(default = "none", choices = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))])
		config.av.surround_3d.addNotifier(set3DSurround)

	if SystemInfo["Has3DSpeaker"]:
		def set3DSpeaker(configElement):
			open(SystemInfo["Has3DSpeaker"], "w").write(configElement.value)
		config.av.speaker_3d = ConfigSelection(default = "center", choices = [("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))])
		config.av.speaker_3d.addNotifier(set3DSpeaker)

	if SystemInfo["Has3DSurroundSpeaker"]:
		def set3DSurroundSpeaker(configElement):
			open(SystemInfo["Has3DSurroundSpeaker"], "w").write(configElement.value)
		config.av.surround_3d_speaker = ConfigSelection(default = "disabled", choices = [("disabled", _("off")), ("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))])
		config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)

	if SystemInfo["Has3DSurroundSoftLimiter"]:
		def set3DSurroundSoftLimiter(configElement):
			open(SystemInfo["Has3DSurroundSoftLimiter"], "w").write(configElement.value and "enabled" or "disabled")
		config.av.surround_softlimiter_3d = ConfigYesNo(default = False)
		config.av.surround_softlimiter_3d.addNotifier(set3DSurroundSoftLimiter)

	def setVolumeStepsize(configElement):
		eDVBVolumecontrol.getInstance().setVolumeSteps(int(configElement.value))
	config.av.volume_stepsize = ConfigSelectionNumber(1, 10, 1, default = 5)
	config.av.volume_stepsize.addNotifier(setVolumeStepsize)
示例#12
0
def InitAVSwitch():
    if getBoxType() == 'vuduo' or getBoxType().startswith('ixuss'):
        config.av.yuvenabled = ConfigBoolean(default=False)
    else:
        config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {'cvbs': _('CVBS'),
     'rgb': _('RGB'),
     'svideo': _('S-Video')}
    if config.av.yuvenabled.getValue():
        colorformat_choices['yuv'] = _('YPbPr')
    config.av.colorformat = ConfigSelection(choices=colorformat_choices, default='rgb')
    config.av.aspectratio = ConfigSelection(choices={'4_3_letterbox': _('4:3 Letterbox'),
     '4_3_panscan': _('4:3 PanScan'),
     '16_9': _('16:9'),
     '16_9_always': _('16:9 always'),
     '16_10_letterbox': _('16:10 Letterbox'),
     '16_10_panscan': _('16:10 PanScan'),
     '16_9_letterbox': _('16:9 Letterbox')}, default='16_9')
    config.av.aspect = ConfigSelection(choices={'4_3': _('4:3'),
     '16_9': _('16:9'),
     '16_10': _('16:10'),
     'auto': _('Automatic')}, default='auto')
    policy2_choices = {'letterbox': _('Letterbox'),
     'panscan': _('Pan&scan'),
     'scale': _('Just scale')}
    if os.path.exists('/proc/stb/video/policy2_choices') and 'auto' in open('/proc/stb/video/policy2_choices').readline():
        policy2_choices.update({'auto': _('Auto')})
    config.av.policy_169 = ConfigSelection(choices=policy2_choices, default='scale')
    policy_choices = {'pillarbox': _('Pillarbox'),
     'panscan': _('Pan&scan'),
     'nonlinear': _('Nonlinear'),
     'scale': _('Just scale')}
    if os.path.exists('/proc/stb/video/policy_choices') and 'auto' in open('/proc/stb/video/policy_choices').readline():
        policy_choices.update({'auto': _('Auto')})
    config.av.policy_43 = ConfigSelection(choices=policy_choices, default='scale')
    config.av.tvsystem = ConfigSelection(choices={'pal': _('PAL'),
     'ntsc': _('NTSC'),
     'multinorm': _('multinorm')}, default='pal')
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    def setColorFormat(configElement):
        if getBoxType() == 'et6x00':
            map = {'cvbs': 3,
             'rgb': 3,
             'svideo': 2,
             'yuv': 3}
        elif getBoxType() == 'gbquad' or getBoxType() == 'gbquadplus' or getBoxType().startswith('et'):
            map = {'cvbs': 0,
             'rgb': 3,
             'svideo': 2,
             'yuv': 3}
        else:
            map = {'cvbs': 0,
             'rgb': 1,
             'svideo': 2,
             'yuv': 3}
        iAVSwitch.setColorFormat(map[configElement.getValue()])

    def setAspectRatio(configElement):
        map = {'4_3_letterbox': 0,
         '4_3_panscan': 1,
         '16_9': 2,
         '16_9_always': 3,
         '16_10_letterbox': 4,
         '16_10_panscan': 5,
         '16_9_letterbox': 6}
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {'pal': 0,
         'ntsc': 1,
         'multinorm': 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)
    iAVSwitch.setInput('ENCODER')
    if getBoxType() in ('gbquad', 'gbquadplus', 'et5x00', 'ixussone', 'ixusszero', 'omtimussos1', 'omtimussos2', 'gb800seplus', 'gb800ueplus') or getHardwareTypeString() == 'et6000':
        detected = False
    else:
        detected = eAVSwitch.getInstance().haveScartSwitch()
    SystemInfo['ScartSwitch'] = detected
    if os.path.exists('/proc/stb/hdmi/bypass_edid_checking'):
        f = open('/proc/stb/hdmi/bypass_edid_checking', 'r')
        can_edidchecking = f.read().strip().split(' ')
        f.close()
    else:
        can_edidchecking = False
    SystemInfo['Canedidchecking'] = can_edidchecking
    if can_edidchecking:

        def setEDIDBypass(configElement):
            try:
                f = open('/proc/stb/hdmi/bypass_edid_checking', 'w')
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.bypass_edid_checking = ConfigSelection(choices={'00000000': _('off'),
         '00000001': _('on')}, default='00000000')
        config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
    else:
        config.av.bypass_edid_checking = ConfigNothing()
    if os.path.exists('/proc/stb/audio/3d_surround_choices'):
        f = open('/proc/stb/audio/3d_surround_choices', 'r')
        can_3dsurround = f.read().strip().split(' ')
        f.close()
    else:
        can_3dsurround = False
    SystemInfo['Can3DSurround'] = can_3dsurround
    if can_3dsurround:

        def set3DSurround(configElement):
            f = open('/proc/stb/audio/3d_surround', 'w')
            f.write(configElement.value)
            f.close()

        choice_list = [('none', _('off')),
         ('hdmi', _('HDMI')),
         ('spdif', _('SPDIF')),
         ('dac', _('DAC'))]
        config.av.surround_3d = ConfigSelection(choices=choice_list, default='none')
        config.av.surround_3d.addNotifier(set3DSurround)
    else:
        config.av.surround_3d = ConfigNothing()
    try:
        can_pcm_multichannel = os.access('/proc/stb/audio/multichannel_pcm', os.W_OK)
    except:
        can_pcm_multichannel = False

    SystemInfo['supportPcmMultichannel'] = can_pcm_multichannel
    if can_pcm_multichannel:

        def setPCMMultichannel(configElement):
            open('/proc/stb/audio/multichannel_pcm', 'w').write(configElement.value and 'enable' or 'disable')

        config.av.pcm_multichannel = ConfigYesNo(default=False)
        config.av.pcm_multichannel.addNotifier(setPCMMultichannel)
    try:
        f = open('/proc/stb/audio/ac3_choices', 'r')
        file = f.read()[:-1]
        f.close()
        can_downmix_ac3 = 'downmix' in file
    except:
        can_downmix_ac3 = False

    SystemInfo['CanDownmixAC3'] = can_downmix_ac3
    if can_downmix_ac3:

        def setAC3Downmix(configElement):
            f = open('/proc/stb/audio/ac3', 'w')
            f.write(configElement.value and 'downmix' or 'passthrough')
            f.close()
            if SystemInfo.get('supportPcmMultichannel', False) and not configElement.value:
                SystemInfo['CanPcmMultichannel'] = True
            else:
                SystemInfo['CanPcmMultichannel'] = False
                if can_pcm_multichannel:
                    config.av.pcm_multichannel.setValue(False)

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)
    try:
        f = open('/proc/stb/audio/aac_choices', 'r')
        file = f.read()[:-1]
        f.close()
        can_downmix_aac = 'downmix' in file
    except:
        can_downmix_aac = False

    SystemInfo['CanDownmixAAC'] = can_downmix_aac
    if can_downmix_aac:

        def setAACDownmix(configElement):
            f = open('/proc/stb/audio/aac', 'w')
            f.write(configElement.value and 'downmix' or 'passthrough')
            f.close()

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)
    if os.path.exists('/proc/stb/audio/avl_choices'):
        f = open('/proc/stb/audio/avl_choices', 'r')
        can_autovolume = f.read().strip().split(' ')
        f.close()
    else:
        can_autovolume = False
    SystemInfo['CanAutoVolume'] = can_autovolume
    if can_autovolume:

        def setAutoVulume(configElement):
            f = open('/proc/stb/audio/avl', 'w')
            f.write(configElement.value)
            f.close()

        choice_list = [('none', _('off')),
         ('hdmi', _('HDMI')),
         ('spdif', _('SPDIF')),
         ('dac', _('DAC'))]
        config.av.autovolume = ConfigSelection(choices=choice_list, default='none')
        config.av.autovolume.addNotifier(setAutoVulume)
    else:
        config.av.autovolume = ConfigNothing()
    try:
        can_osd_alpha = open('/proc/stb/video/alpha', 'r') and True or False
    except:
        can_osd_alpha = False

    SystemInfo['CanChangeOsdAlpha'] = can_osd_alpha

    def setAlpha(config):
        open('/proc/stb/video/alpha', 'w').write(str(config.value))

    if can_osd_alpha:
        config.av.osd_alpha = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha.addNotifier(setAlpha)
    if os.path.exists('/proc/stb/vmpeg/0/pep_scaler_sharpness'):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print '--> setting scaler_sharpness to: %0.8X' % myval
                f = open('/proc/stb/vmpeg/0/pep_scaler_sharpness', 'w')
                f.write('%0.8X' % myval)
                f.close()
                f = open('/proc/stb/vmpeg/0/pep_apply', 'w')
                f.write('1')
                f.close()
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())
示例#13
0
def InitAVSwitch():
    config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {"cvbs": _("CVBS")}

    # when YUV, Scart or S-Video is not support by HW, don't let the user select it
    if SystemInfo["HasYPbPr"]:
        colorformat_choices["yuv"] = _("YPbPr")
    if SystemInfo["HasScart"]:
        colorformat_choices["rgb"] = _("RGB")
    if SystemInfo["HasSVideo"]:
        colorformat_choices["svideo"] = _("S-Video")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="cvbs")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4_3": _("4:3"),
        "16_9": _("16:9"),
        "16_10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="auto")
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: scale as close to fullscreen as possible)
        "scale": _("Just scale")
    }
    try:
        if "full" in open("/proc/stb/video/policy2_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if the content aspect ratio does not match the screen ratio)
            policy2_choices.update({"full": _("Full screen")})
    except:
        pass
    try:
        if "auto" in open("/proc/stb/video/policy2_choices").read():
            # TRANSLATORS: (aspect ratio policy: automatically select the best aspect ratio mode)
            policy2_choices.update({"auto": _("Auto")})
    except:
        pass
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="letterbox")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "pillarbox": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: scale as close to fullscreen as possible)
        "scale": _("Just scale")
    }
    try:
        if "nonlinear" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
            policy_choices.update({"nonlinear": _("Nonlinear")})
    except:
        pass
    try:
        if "full" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if the content aspect ratio does not match the screen ratio)
            policy_choices.update({"full": _("Full screen")})
    except:
        pass
    try:
        if "auto" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: automatically select the best aspect ratio mode)
            policy_choices.update({"auto": _("Auto")})
    except:
        pass
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="pillarbox")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    # this will call the "setup-val" initial
    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup

    if getMachineBuild() in ('gb7325'):
        detected = eAVSwitch.getInstance().haveScartSwitch()
    else:
        detected = False

    SystemInfo["ScartSwitch"] = detected

    if SystemInfo["HasMultichannelPCM"]:

        def setPCMMultichannel(configElement):
            open(SystemInfo["HasMultichannelPCM"],
                 "w").write(configElement.value and "enable" or "disable")

        config.av.pcm_multichannel = ConfigYesNo(default=False)
        config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

    if SystemInfo["CanDownmixAC3"]:

        def setAC3Downmix(configElement):
            open("/proc/stb/audio/ac3",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    if SystemInfo["CanDownmixDTS"]:

        def setDTSDownmix(configElement):
            open("/proc/stb/audio/dts",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_dts = ConfigYesNo(default=True)
        config.av.downmix_dts.addNotifier(setDTSDownmix)

    if SystemInfo["CanDownmixAAC"]:

        def setAACDownmix(configElement):
            open("/proc/stb/audio/aac",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    if SystemInfo["CanDownmixDTSHD"]:

        def setDTSHDDownmix(configElement):
            open("/proc/stb/audio/dtshd", "w").write(configElement.value)

        config.av.downmix_dtshd = ConfigSelection(
            default="downmix",
            choices=[("downmix", _("Downmix")),
                     ("force_dts", _("convert to DTS")),
                     ("use_hdmi_caps", _("controlled by HDMI")),
                     ("multichannel", _("convert to multi channel PCM")),
                     ("hdmi_best", _("use best, controlled by HDMI"))])
        config.av.downmix_dtshd.addNotifier(setDTSHDDownmix)

    if SystemInfo["CanDownmixWMApro"]:

        def setWMAproDownmix(configElement):
            open("/proc/stb/audio/wmapro", "w").write(configElement.value)

        config.av.downmix_wmapro = ConfigSelection(
            default="downmix",
            choices=[("downmix", _("Downmix")),
                     ("passthrough", _("Passthrough")),
                     ("multichannel", _("convert to multi channel PCM")),
                     ("hdmi_best", _("use best, controlled by HDMI"))])
        config.av.downmix_wmapro.addNotifier(setWMAproDownmix)

    if SystemInfo["CanAC3plusTranscode"]:

        def setAC3plusTranscode(configElement):
            open("/proc/stb/audio/ac3plus", "w").write(configElement.value)

        config.av.transcode_ac3plus = ConfigSelection(
            default="force_ac3",
            choices=[("use_hdmi_caps", _("controlled by HDMI")),
                     ("force_ac3", _("convert to AC3")),
                     ("multichannel", _("convert to multi channel PCM")),
                     ("hdmi_best", _("use best, controlled by HDMI")),
                     ("force_ddp", _("force AC3 plus"))])
        config.av.transcode_ac3plus.addNotifier(setAC3plusTranscode)

    if SystemInfo["CanAACTranscode"]:

        def setAACTranscode(configElement):
            open("/proc/stb/audio/aac_transcode",
                 "w").write(configElement.value)

        config.av.transcode_aac = ConfigSelection(default="off",
                                                  choices=[("off", _("off")),
                                                           ("ac3", _("AC3")),
                                                           ("dts", _("DTS"))])
        config.av.transcode_aac.addNotifier(setAACTranscode)

    try:
        SystemInfo["CanChangeOsdAlpha"] = open("/proc/stb/video/alpha",
                                               "r") and True or False
    except:
        SystemInfo["CanChangeOsdAlpha"] = False

    if SystemInfo["CanChangeOsdAlpha"]:

        def setAlpha(config):
            open("/proc/stb/video/alpha", "w").write(str(config.value))

        config.av.osd_alpha = ConfigSlider(default=255,
                                           increment=5,
                                           limits=(20, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "--> setting scaler_sharpness to: %0.8X" % myval
                open("/proc/stb/vmpeg/0/pep_scaler_sharpness",
                     "w").write("%0.8X" % myval)
                open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        if getBoxType() in ('gbquad', 'gbquadplus'):
            config.av.scaler_sharpness = ConfigSlider(default=5,
                                                      limits=(0, 26))
        else:
            config.av.scaler_sharpness = ConfigSlider(default=13,
                                                      limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    if SystemInfo["HasMultichannelPCM"]:

        def setMultichannelPCM(configElement):
            open(SystemInfo["HasMultichannelPCM"],
                 "w").write(configElement.value and "enable" or "disable")

        config.av.multichannel_pcm = ConfigYesNo(default=False)
        config.av.multichannel_pcm.addNotifier(setMultichannelPCM)

    if SystemInfo["HasAutoVolume"]:

        def setAutoVolume(configElement):
            open(SystemInfo["HasAutoVolume"], "w").write(configElement.value)

        config.av.autovolume = ConfigSelection(default="none",
                                               choices=[("none", _("off")),
                                                        ("hdmi", _("HDMI")),
                                                        ("spdif", _("SPDIF")),
                                                        ("dac", _("DAC"))])
        config.av.autovolume.addNotifier(setAutoVolume)

    if SystemInfo["HasAutoVolumeLevel"]:

        def setAutoVolumeLevel(configElement):
            open(SystemInfo["HasAutoVolumeLevel"],
                 "w").write(configElement.value and "enabled" or "disabled")

        config.av.autovolumelevel = ConfigYesNo(default=False)
        config.av.autovolumelevel.addNotifier(setAutoVolumeLevel)

    if SystemInfo["Has3DSurround"]:

        def set3DSurround(configElement):
            open(SystemInfo["Has3DSurround"], "w").write(configElement.value)

        config.av.surround_3d = ConfigSelection(default="none",
                                                choices=[("none", _("off")),
                                                         ("hdmi", _("HDMI")),
                                                         ("spdif", _("SPDIF")),
                                                         ("dac", _("DAC"))])
        config.av.surround_3d.addNotifier(set3DSurround)

    if SystemInfo["Has3DSpeaker"]:

        def set3DSpeaker(configElement):
            open(SystemInfo["Has3DSpeaker"], "w").write(configElement.value)

        config.av.speaker_3d = ConfigSelection(default="center",
                                               choices=[("center",
                                                         _("center")),
                                                        ("wide", _("wide")),
                                                        ("extrawide",
                                                         _("extra wide"))])
        config.av.speaker_3d.addNotifier(set3DSpeaker)

    if SystemInfo["Has3DSurroundSpeaker"]:

        def set3DSurroundSpeaker(configElement):
            open(SystemInfo["Has3DSurroundSpeaker"],
                 "w").write(configElement.value)

        config.av.surround_3d_speaker = ConfigSelection(
            default="disabled",
            choices=[("disabled", _("off")), ("center", _("center")),
                     ("wide", _("wide")), ("extrawide", _("extra wide"))])
        config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)

    if SystemInfo["Has3DSurroundSoftLimiter"]:

        def set3DSurroundSoftLimiter(configElement):
            open(SystemInfo["Has3DSurroundSoftLimiter"],
                 "w").write(configElement.value and "enabled" or "disabled")

        config.av.surround_softlimiter_3d = ConfigYesNo(default=False)
        config.av.surround_softlimiter_3d.addNotifier(set3DSurroundSoftLimiter)

    if SystemInfo["HDMIAudioSource"]:

        def setHDMIAudioSource(configElement):
            open(SystemInfo["HDMIAudioSource"], "w").write(configElement.value)

        config.av.hdmi_audio_source = ConfigSelection(default="pcm",
                                                      choices=[
                                                          ("pcm", _("PCM")),
                                                          ("spdif", _("SPDIF"))
                                                      ])
        config.av.hdmi_audio_source.addNotifier(setHDMIAudioSource)
示例#14
0
文件: AVSwitch.py 项目: 1198s/enigma2
def InitAVSwitch():
	config.av.yuvenabled = ConfigBoolean(default=True)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.autores = ConfigSelection(choices={"disabled": _("Disabled"), "all": _("All resolutions"), "hd": _("only HD")}, default="disabled")
	choicelist = []
	for i in range(5, 16):
		choicelist.append(("%d" % i, ngettext("%d second", "%d seconds", i) % i))
	config.av.autores_label_timeout = ConfigSelection(default = "5", choices = [("0", _("Not Shown"))] + choicelist)
	config.av.autores_delay = ConfigSelectionNumber(min = 200, max = 3000, stepwidth = 200, default = 400, wraparound = True)
	config.av.autores_deinterlace = ConfigYesNo(default=False)
	config.av.autores_sd = ConfigSelection(choices={"720p": _("720p"), "1080i": _("1080i")}, default="720p")
	config.av.autores_720p24 = ConfigSelection(choices={"720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz")}, default="720p24")
	config.av.autores_1080p24 = ConfigSelection(choices={"1080p24": _("1080p 24Hz"), "1080p25": _("1080p 25Hz")}, default="1080p24")
	config.av.autores_1080p25 = ConfigSelection(choices={"1080p25": _("1080p 25Hz"), "1080p50": _("1080p 50Hz")}, default="1080p25")
	config.av.autores_1080p30 = ConfigSelection(choices={"1080p30": _("1080p 30Hz"), "1080p60": _("1080p 60Hz")}, default="1080p30")
	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4:3": _("4:3"),
			"16:9": _("16:9"),
			"16:10": _("16:10"),
			"auto": _("Automatic")},
			default = "16:9")
	policy2_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
	"letterbox": _("Letterbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy2_choices"):
		f = open("/proc/stb/video/policy2_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy2_choices.update({"auto": _("Auto")})
		f.close()	
	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default = "letterbox")
	policy_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
	"panscan": _("Pillarbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"letterbox": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
	# "nonlinear": _("Nonlinear"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"bestfit": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy_choices"):
		f = open("/proc/stb/video/policy_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy_choices.update({"auto": _("Auto")})
		f.close()
	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "panscan")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	config.av.aspect.setValue('16:9')
	config.av.aspect.addNotifier(iAVSwitch.setAspect)
	config.av.wss.addNotifier(iAVSwitch.setWss)
	config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
	config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

	def setColorFormat(configElement):
		if config.av.videoport and config.av.videoport.value == "Scart-YPbPr":
			iAVSwitch.setColorFormat(3)
		else:
			map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
			iAVSwitch.setColorFormat(map[configElement.value])

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])
	
	config.av.colorformat.addNotifier(setColorFormat)
	
	iAVSwitch.setInput("ENCODER") # init on startup
	SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

	if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
		f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
		can_edidchecking = f.read().strip().split(" ")
		f.close()
	else:
		can_edidchecking = False

	SystemInfo["Canedidchecking"] = can_edidchecking

	if can_edidchecking:
		def setEDIDBypass(configElement):
			try:
				f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.bypass_edid_checking = ConfigSelection(choices={
				"00000000": _("off"),
				"00000001": _("on")},
				default = "00000000")
		config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
	else:
		config.av.bypass_edid_checking = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_choices"):
		f = open("/proc/stb/audio/3d_surround_choices", "r")
		can_3dsurround = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround = False

	SystemInfo["Can3DSurround"] = can_3dsurround

	if can_3dsurround:
		def set3DSurround(configElement):
			f = open("/proc/stb/audio/3d_surround", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.surround_3d = ConfigSelection(choices = choice_list, default = "none")
		config.av.surround_3d.addNotifier(set3DSurround)
	else:
		config.av.surround_3d = ConfigNothing()

	try:
		can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm", os.W_OK)
	except:
		can_pcm_multichannel = False

	SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
	if can_pcm_multichannel:
		def setPCMMultichannel(configElement):
			open("/proc/stb/audio/multichannel_pcm", "w").write(configElement.value and "enable" or "disable")
		config.av.pcm_multichannel = ConfigYesNo(default = False)
		config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

	try:
		f = open("/proc/stb/audio/ac3_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_ac3 = "downmix" in file
	except:
		can_downmix_ac3 = False

	SystemInfo["CanDownmixAC3"] = can_downmix_ac3
	if can_downmix_ac3:
		def setAC3Downmix(configElement):
			f = open("/proc/stb/audio/ac3", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
			if SystemInfo.get("supportPcmMultichannel", False) and not configElement.value:
				SystemInfo["CanPcmMultichannel"] = True
			else:
				SystemInfo["CanPcmMultichannel"] = False
				if can_pcm_multichannel:
					config.av.pcm_multichannel.setValue(False)
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	try:
		f = open("/proc/stb/audio/aac_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_aac = "downmix" in file
	except:
		can_downmix_aac = False

	SystemInfo["CanDownmixAAC"] = can_downmix_aac
	if can_downmix_aac:
		def setAACDownmix(configElement):
			f = open("/proc/stb/audio/aac", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		config.av.downmix_aac = ConfigYesNo(default = True)
		config.av.downmix_aac.addNotifier(setAACDownmix)

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print "[VideoMode] setting scaler_sharpness to: %0.8X" % myval
				f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
				f.write("%0.8X" % myval)
				f.close()
				f = open("/proc/stb/vmpeg/0/pep_apply", "w")
				f.write("1")
				f.close()
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		if getBoxType() == 'gbquad':
			config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0,26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())

	config.av.edid_override = ConfigYesNo(default = False)

	iAVSwitch.setConfiguredMode()
示例#15
0
 def setInput(self, input):
     INPUT = {'ENCODER': 0,
      'SCART': 1,
      'AUX': 2}
     eAVSwitch.getInstance().setInput(INPUT[input])
示例#16
0
def InitAVSwitch():
	config.av = ConfigSubsection()
	config.av.yuvenabled = ConfigBoolean(default=True)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}

	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4_3": _("4:3"),
			"16_9": _("16:9"),
			"16_10": _("16:10"),
			"auto": _("Automatic")},
			default = "auto")
	policy2_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
	"letterbox": _("Letterbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	try:
		if "auto" in open("/proc/stb/video/policy2_choices").read():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy2_choices.update({"auto": _("Auto")})
	except:
		pass
	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default = "letterbox")
	policy_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
	"pillarbox": _("Pillarbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
	"nonlinear": _("Nonlinear"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	try:
		if "auto" in open("/proc/stb/video/policy_choices").read():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy_choices.update({"auto": _("Auto")})
	except:
		pass
	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "pillarbox")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	iAVSwitch = AVSwitch()

	def setColorFormat(configElement):
		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		iAVSwitch.setColorFormat(map[configElement.value])

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])

	def setSystem(configElement):
		map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
		iAVSwitch.setSystem(map[configElement.value])

	def setWSS(configElement):
		iAVSwitch.setAspectWSS()

	# this will call the "setup-val" initial
	config.av.colorformat.addNotifier(setColorFormat)
	config.av.aspectratio.addNotifier(setAspectRatio)
	config.av.tvsystem.addNotifier(setSystem)
	config.av.wss.addNotifier(setWSS)

	iAVSwitch.setInput("ENCODER") # init on startup
	if getBoxType() in ('gbquad4k', 'gbquad', 'gbquadplus', 'gb800seplus', 'gb800ueplus', 'gbipbox', 'gbultra', 'gbultraue', 'gbultraueh', 'gbultrase', 'spycat', 'gbx1', 'gbx2', 'gbx3', 'gbx3h'):
		detected = False
	else:
		detected = eAVSwitch.getInstance().haveScartSwitch()
	
	SystemInfo["ScartSwitch"] = detected

	if SystemInfo["HasMultichannelPCM"]:
		def setPCMMultichannel(configElement):
			open(SystemInfo["HasMultichannelPCM"], "w").write(configElement.value and "enable" or "disable")
		config.av.pcm_multichannel = ConfigYesNo(default = False)
		config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

	try:
		SystemInfo["CanDownmixAC3"] = "downmix" in open("/proc/stb/audio/ac3_choices", "r").read()
	except:
		SystemInfo["CanDownmixAC3"] = False

	if SystemInfo["CanDownmixAC3"]:
		def setAC3Downmix(configElement):
			open("/proc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	try:
		SystemInfo["CanDownmixDTS"] = "downmix" in open("/proc/stb/audio/dts_choices", "r").read()
	except:
		SystemInfo["CanDownmixDTS"] = False

	if SystemInfo["CanDownmixDTS"]:
		def setDTSDownmix(configElement):
			open("/proc/stb/audio/dts", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_dts = ConfigYesNo(default = True)
		config.av.downmix_dts.addNotifier(setDTSDownmix)

	try:
		SystemInfo["CanDownmixAAC"] = "downmix" in open("/proc/stb/audio/aac_choices", "r").read()
	except:
		SystemInfo["CanDownmixAAC"] = False

	if SystemInfo["CanDownmixAAC"]:
		def setAACDownmix(configElement):
			open("/proc/stb/audio/aac", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_aac = ConfigYesNo(default = True)
		config.av.downmix_aac.addNotifier(setAACDownmix)

	if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
		f = open("/proc/stb/audio/aac_transcode_choices", "r")
		can_aactranscode = f.read().strip().split(" ")
		f.close()
	else:
		can_aactranscode = False

	SystemInfo["CanAACTranscode"] = can_aactranscode

	if can_aactranscode:
		def setAACTranscode(configElement):
			f = open("/proc/stb/audio/aac_transcode", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
		config.av.transcodeaac = ConfigSelection(choices = choice_list, default = "off")
		config.av.transcodeaac.addNotifier(setAACTranscode)
	else:
		config.av.transcodeaac = ConfigNothing()

	try:
		SystemInfo["CanChangeOsdAlpha"] = open("/proc/stb/video/alpha", "r") and True or False
	except:
		SystemInfo["CanChangeOsdAlpha"] = False

	if SystemInfo["CanChangeOsdAlpha"]:
		def setAlpha(config):
			open("/proc/stb/video/alpha", "w").write(str(config.value))
		config.av.osd_alpha = ConfigSlider(default=255, increment = 5, limits=(20,255))
		config.av.osd_alpha.addNotifier(setAlpha)

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print "--> setting scaler_sharpness to: %0.8X" % myval
				open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval)
				open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		if getBoxType() in ('gbquad4k', 'gbquad', 'gbquadplus'):
			config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0,26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())

	config.av.edid_override = ConfigYesNo(default = True)

	if SystemInfo["HasMultichannelPCM"]:
		def setMultichannelPCM(configElement):
			open(SystemInfo["HasMultichannelPCM"], "w").write(configElement.value and "enable" or "disable")
		config.av.multichannel_pcm = ConfigYesNo(default = False)
		config.av.multichannel_pcm.addNotifier(setMultichannelPCM)

	if SystemInfo["HasAutoVolume"]:
		def setAutoVolume(configElement):
			open(SystemInfo["HasAutoVolume"], "w").write(configElement.value)
		config.av.autovolume = ConfigSelection(default = "none", choices = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))])
		config.av.autovolume.addNotifier(setAutoVolume)

	if SystemInfo["HasAutoVolumeLevel"]:
		def setAutoVolumeLevel(configElement):
			open(SystemInfo["HasAutoVolumeLevel"], "w").write(configElement.value and "enabled" or "disabled")
		config.av.autovolumelevel = ConfigYesNo(default = False)
		config.av.autovolumelevel.addNotifier(setAutoVolumeLevel)

	if SystemInfo["Has3DSurround"]:
		def set3DSurround(configElement):
			open(SystemInfo["Has3DSurround"], "w").write(configElement.value)
		config.av.surround_3d = ConfigSelection(default = "none", choices = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))])
		config.av.surround_3d.addNotifier(set3DSurround)

	if SystemInfo["Has3DSpeaker"]:
		def set3DSpeaker(configElement):
			open(SystemInfo["Has3DSpeaker"], "w").write(configElement.value)
		config.av.speaker_3d = ConfigSelection(default = "center", choices = [("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))])
		config.av.speaker_3d.addNotifier(set3DSpeaker)

	if SystemInfo["Has3DSurroundSpeaker"]:
		def set3DSurroundSpeaker(configElement):
			open(SystemInfo["Has3DSurroundSpeaker"], "w").write(configElement.value)
		config.av.surround_3d_speaker = ConfigSelection(default = "disabled", choices = [("disabled", _("off")), ("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))])
		config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)

	if SystemInfo["Has3DSurroundSoftLimiter"]:
		def set3DSurroundSoftLimiter(configElement):
			open(SystemInfo["Has3DSurroundSoftLimiter"], "w").write(configElement.value and "enabled" or "disabled")
		config.av.surround_softlimiter_3d = ConfigYesNo(default = False)
		config.av.surround_softlimiter_3d.addNotifier(set3DSurroundSoftLimiter)
示例#17
0
 def setAspectRatio(self, value):
     eAVSwitch.getInstance().setAspectRatio(value)
示例#18
0
 def updateDeinterlace(self, cfgelement):
     print "-> update deinterlace !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
     eAVSwitch.getInstance().setDeinterlace(
         int(config.av.deinterlace.value),
         int(config.av.deinterlace_sd.value),
         int(config.av.deinterlace_hd.value))
示例#19
0
	def setAspectWSS(self, aspect=None):
		if not config.av.wss.value:
			value = 2 # auto(4:3_off)
		else:
			value = 1 # auto
		eAVSwitch.getInstance().setWSS(value)
示例#20
0
 def updateSDfeatures(self, cfgelement):
     print "-> update SD features !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
     eAVSwitch.getInstance().setSDfeatures(
         int(config.pc.sd_sharpness.value), int(config.pc.sd_noise.value))
示例#21
0
def InitAVSwitch():
    config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {
        "cvbs": _("CVBS"),
        "rgb": _("RGB"),
        "svideo": _("S-Video")
    }

    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="rgb")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4_3": _("4:3"),
        "16_9": _("16:9"),
        "16_10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="auto")

    # Some boxes have a redundant proc entry for policy2 choices, but some don't (The choices are from a 16:9 point of view anyways)
    if os.path.exists("/proc/stb/video/policy2_choices"):
        policy2_choices_proc = "/proc/stb/video/policy2_choices"
    else:
        policy2_choices_proc = "/proc/stb/video/policy_choices"

    try:
        policy2_choices_raw = open(policy2_choices_proc, "r").read()
    except:
        policy2_choices_raw = "letterbox"

    policy2_choices = {}

    if "letterbox" in policy2_choices_raw:
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        policy2_choices.update({"letterbox": _("Letterbox")})

    if "panscan" in policy2_choices_raw:
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        policy2_choices.update({"panscan": _("Pan&scan")})

    if "nonliner" in policy2_choices_raw and not "nonlinear" in policy2_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the top/bottom (Center of picture maintains aspect, top/bottom lose aspect heaver than on linear stretch))
        policy2_choices.update({"nonliner": _("Stretch nonlinear")})
    if "nonlinear" in policy2_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the top/bottom (Center of picture maintains aspect, top/bottom lose aspect heaver than on linear stretch))
        policy2_choices.update({"nonlinear": _("Stretch nonlinear")})

    if "scale" in policy2_choices_raw and not "auto" in policy2_choices_raw and not "bestfit" in policy2_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
        policy2_choices.update({"scale": _("Stretch linear")})
    if "auto" in policy2_choices_raw and not "bestfit" in policy2_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
        policy2_choices.update({"auto": _("Stretch linear")})
    if "bestfit" in policy2_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
        policy2_choices.update({"bestfit": _("Stretch linear")})

    # print "AVSWITCH - policy2_choices: ", policy2_choices
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="letterbox")

    policy_choices_proc = "/proc/stb/video/policy_choices"
    try:
        policy_choices_raw = open(policy_choices_proc, "r").read()
    except:
        policy_choices_raw = "panscan"

    policy_choices = {}

    if "pillarbox" in policy_choices_raw and not "panscan" in policy_choices_raw:
        # Very few boxes support "pillarbox" as an alias for "panscan" (Which in fact does pillarbox)
        # So only add "pillarbox" if "panscan" is not listed in choices

        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        policy_choices.update({"pillarbox": _("Pillarbox")})

    if "panscan" in policy_choices_raw:
        # DRIVER BUG:	"panscan" in /proc actually does "pillarbox" (That's probably why an alias to it named "pillarbox" existed)!
        #		Interpret "panscan" setting with a "Pillarbox" text in order to show the correct value in GUI

        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        policy_choices.update({"panscan": _("Pillarbox")})

    if "letterbox" in policy_choices_raw:
        # DRIVER BUG:	"letterbox" in /proc actually does pan&scan
        #		"letterbox" and 4:3 content on 16:9 TVs is mutually exclusive, as "letterbox" is the method to show wide content on narrow TVs
        #		Probably the bug arose as the driver actually does the same here as it would for wide content on narrow TVs (It stretches the picture to fit width)

        # TRANSLATORS: (aspect ratio policy: Fit width, cut/crop top and bottom (Maintain aspect ratio))
        policy_choices.update({"letterbox": _("Pan&scan")})

    if "nonliner" in policy_choices_raw and not "nonlinear" in policy_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right (Center 50% of picture maintain aspect, left/right 25% lose aspect heaver than on linear stretch))
        policy_choices.update({"nonliner": _("Stretch nonlinear")})
    if "nonlinear" in policy_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right (Center 50% of picture maintain aspect, left/right 25% lose aspect heaver than on linear stretch))
        policy_choices.update({"nonlinear": _("Stretch nonlinear")})

    # "auto", "bestfit" and "scale" are aliasses for the same: Stretch linear
    if "scale" in policy_choices_raw and not "auto" in policy_choices_raw and not "bestfit" in policy_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
        policy_choices.update({"scale": _("Stretch linear")})
    if "auto" in policy_choices_raw and not "bestfit" in policy_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
        policy_choices.update({"auto": _("Stretch linear")})
    if "bestfit" in policy_choices_raw:
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
        policy_choices.update({"bestfit": _("Stretch linear")})

    # print "AVSWITCH - policy_choices: ", policy_choices
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="letterbox")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    # this will call the "setup-val" initial
    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    if getBoxType() in ('gbquad4k', 'gbue4k', 'gbquad', 'gbquadplus',
                        'gb800seplus', 'gb800ueplus', 'gbipbox', 'gbultra',
                        'gbultraue', 'gbultraueh', 'gbultrase', 'spycat',
                        'gbx1', 'gbx2', 'gbx3', 'gbx3h'):
        detected = False
    else:
        detected = eAVSwitch.getInstance().haveScartSwitch()

    SystemInfo["ScartSwitch"] = detected

    if SystemInfo["HasMultichannelPCM"]:

        def setPCMMultichannel(configElement):
            open(SystemInfo["HasMultichannelPCM"],
                 "w").write(configElement.value and "enable" or "disable")

        config.av.pcm_multichannel = ConfigYesNo(default=False)
        config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

    try:
        SystemInfo["CanDownmixAC3"] = "downmix" in open(
            "/proc/stb/audio/ac3_choices", "r").read()
    except:
        SystemInfo["CanDownmixAC3"] = False

    if SystemInfo["CanDownmixAC3"]:

        def setAC3Downmix(configElement):
            open("/proc/stb/audio/ac3",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    try:
        SystemInfo["CanDownmixDTS"] = "downmix" in open(
            "/proc/stb/audio/dts_choices", "r").read()
    except:
        SystemInfo["CanDownmixDTS"] = False

    if SystemInfo["CanDownmixDTS"]:

        def setDTSDownmix(configElement):
            open("/proc/stb/audio/dts",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_dts = ConfigYesNo(default=True)
        config.av.downmix_dts.addNotifier(setDTSDownmix)

    try:
        SystemInfo["CanDownmixAAC"] = "downmix" in open(
            "/proc/stb/audio/aac_choices", "r").read()
    except:
        SystemInfo["CanDownmixAAC"] = False

    if SystemInfo["CanDownmixAAC"]:

        def setAACDownmix(configElement):
            open("/proc/stb/audio/aac",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
        f = open("/proc/stb/audio/aac_transcode_choices", "r")
        can_aactranscode = f.read().strip().split(" ")
        f.close()
    else:
        can_aactranscode = False

    SystemInfo["CanAACTranscode"] = can_aactranscode

    if can_aactranscode:

        def setAACTranscode(configElement):
            f = open("/proc/stb/audio/aac_transcode", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
        config.av.transcodeaac = ConfigSelection(choices=choice_list,
                                                 default="off")
        config.av.transcodeaac.addNotifier(setAACTranscode)
    else:
        config.av.transcodeaac = ConfigNothing()

    try:
        SystemInfo["CanChangeOsdAlpha"] = open("/proc/stb/video/alpha",
                                               "r") and True or False
    except:
        SystemInfo["CanChangeOsdAlpha"] = False

    if SystemInfo["CanChangeOsdAlpha"]:

        def setAlpha(config):
            open("/proc/stb/video/alpha", "w").write(str(config.value))

        config.av.osd_alpha = ConfigSlider(default=255,
                                           increment=5,
                                           limits=(20, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "--> setting scaler_sharpness to: %0.8X" % myval
                open("/proc/stb/vmpeg/0/pep_scaler_sharpness",
                     "w").write("%0.8X" % myval)
                open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        if getBoxType() in ('gbquad4k', 'gbquad', 'gbquadplus'):
            config.av.scaler_sharpness = ConfigSlider(default=5,
                                                      limits=(0, 26))
        else:
            config.av.scaler_sharpness = ConfigSlider(default=13,
                                                      limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    config.av.edid_override = ConfigYesNo(default=True)

    if SystemInfo["HasMultichannelPCM"]:

        def setMultichannelPCM(configElement):
            open(SystemInfo["HasMultichannelPCM"],
                 "w").write(configElement.value and "enable" or "disable")

        config.av.multichannel_pcm = ConfigYesNo(default=False)
        config.av.multichannel_pcm.addNotifier(setMultichannelPCM)

    if SystemInfo["HasAutoVolume"]:

        def setAutoVolume(configElement):
            open(SystemInfo["HasAutoVolume"], "w").write(configElement.value)

        config.av.autovolume = ConfigSelection(default="none",
                                               choices=[("none", _("off")),
                                                        ("hdmi", _("HDMI")),
                                                        ("spdif", _("SPDIF")),
                                                        ("dac", _("DAC"))])
        config.av.autovolume.addNotifier(setAutoVolume)

    if SystemInfo["HasAutoVolumeLevel"]:

        def setAutoVolumeLevel(configElement):
            open(SystemInfo["HasAutoVolumeLevel"],
                 "w").write(configElement.value and "enabled" or "disabled")

        config.av.autovolumelevel = ConfigYesNo(default=False)
        config.av.autovolumelevel.addNotifier(setAutoVolumeLevel)

    if SystemInfo["Has3DSurround"]:

        def set3DSurround(configElement):
            open(SystemInfo["Has3DSurround"], "w").write(configElement.value)

        config.av.surround_3d = ConfigSelection(default="none",
                                                choices=[("none", _("off")),
                                                         ("hdmi", _("HDMI")),
                                                         ("spdif", _("SPDIF")),
                                                         ("dac", _("DAC"))])
        config.av.surround_3d.addNotifier(set3DSurround)

    if SystemInfo["Has3DSpeaker"]:

        def set3DSpeaker(configElement):
            open(SystemInfo["Has3DSpeaker"], "w").write(configElement.value)

        config.av.speaker_3d = ConfigSelection(default="center",
                                               choices=[("center",
                                                         _("center")),
                                                        ("wide", _("wide")),
                                                        ("extrawide",
                                                         _("extra wide"))])
        config.av.speaker_3d.addNotifier(set3DSpeaker)

    if SystemInfo["Has3DSurroundSpeaker"]:

        def set3DSurroundSpeaker(configElement):
            open(SystemInfo["Has3DSurroundSpeaker"],
                 "w").write(configElement.value)

        config.av.surround_3d_speaker = ConfigSelection(
            default="disabled",
            choices=[("disabled", _("off")), ("center", _("center")),
                     ("wide", _("wide")), ("extrawide", _("extra wide"))])
        config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)

    if SystemInfo["Has3DSurroundSoftLimiter"]:

        def set3DSurroundSoftLimiter(configElement):
            open(SystemInfo["Has3DSurroundSoftLimiter"],
                 "w").write(configElement.value and "enabled" or "disabled")

        config.av.surround_softlimiter_3d = ConfigYesNo(default=False)
        config.av.surround_softlimiter_3d.addNotifier(set3DSurroundSoftLimiter)
示例#22
0
def InitAVSwitch():
	config.av = ConfigSubsection()
	config.av.yuvenabled = ConfigBoolean(default=True)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}

	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.getValue():
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4_3": _("4:3"),
			"16_9": _("16:9"),
			"16_10": _("16:10"),
			"auto": _("Automatic")},
			default = "auto")
	policy2_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
	"letterbox": _("Letterbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy2_choices"):
		f = open("/proc/stb/video/policy2_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy2_choices.update({"auto": _("Auto")})
		f.close()	
	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default = "letterbox")
	policy_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
	"pillarbox": _("Pillarbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
	"nonlinear": _("Nonlinear"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy_choices"):
		f = open("/proc/stb/video/policy_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy_choices.update({"auto": _("Auto")})
		f.close()
	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "pillarbox")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	iAVSwitch = AVSwitch()

	def setColorFormat(configElement):
		if getBoxType() == 'et6x00':
			map = {"cvbs": 3, "rgb": 3, "svideo": 2, "yuv": 3}	
		elif getBoxType() == 'gbquad' or getBoxType().startswith('et'):
			map = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
		else:
			map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		iAVSwitch.setColorFormat(map[configElement.getValue()])

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.getValue()])

	def setSystem(configElement):
		map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
		iAVSwitch.setSystem(map[configElement.getValue()])

	def setWSS(configElement):
		iAVSwitch.setAspectWSS()

	# this will call the "setup-val" initial
	config.av.colorformat.addNotifier(setColorFormat)
	config.av.aspectratio.addNotifier(setAspectRatio)
	config.av.tvsystem.addNotifier(setSystem)
	config.av.wss.addNotifier(setWSS)

	iAVSwitch.setInput("ENCODER") # init on startup
	if getBoxType() == 'gbquad' or getBoxType() == 'et5x00' or getBoxType() == 'ixussone' or getBoxType() == 'ixusszero' or model == 'et6000' or getBoxType() == 'e3hd':
		detected = False
	else:
		detected = eAVSwitch.getInstance().haveScartSwitch()
	
	SystemInfo["ScartSwitch"] = detected

	if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
		f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
		can_edidchecking = f.read().strip().split(" ")
		f.close()
	else:
		can_edidchecking = False

	SystemInfo["Canedidchecking"] = can_edidchecking

	if can_edidchecking:
		def setEDIDBypass(configElement):
			try:
				f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.bypass_edid_checking = ConfigSelection(choices={
				"00000000": _("off"),
				"00000001": _("on")},
				default = "00000000")
		config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
	else:
		config.av.bypass_edid_checking = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_choices"):
		f = open("/proc/stb/audio/3d_surround_choices", "r")
		can_3dsurround = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround = False

	SystemInfo["Can3DSurround"] = can_3dsurround

	if can_3dsurround:
		def set3DSurround(configElement):
			f = open("/proc/stb/audio/3d_surround", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.surround_3d = ConfigSelection(choices = choice_list, default = "none")
		config.av.surround_3d.addNotifier(set3DSurround)
	else:
		config.av.surround_3d = ConfigNothing()

	try:
		f = open("/proc/stb/audio/ac3_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix = file.find("downmix") != -1
	except:
		can_downmix = False

	SystemInfo["CanDownmixAC3"] = can_downmix
	if can_downmix:
		def setAC3Downmix(configElement):
			f = open("/proc/stb/audio/ac3", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.getValue())
			try:
				print "--> setting scaler_sharpness to: %0.8X" % myval
				f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
				f.write("%0.8X" % myval)
				f.close()
				f = open("/proc/stb/vmpeg/0/pep_apply", "w")
				f.write("1")
				f.close()
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		if getBoxType() == 'gbquad':
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())
示例#23
0
def InitAVSwitch():
    config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=False)
    colorformat_choices = {
        "cvbs": _("CVBS"),
        "rgb": _("RGB"),
        "svideo": _("S-Video")
    }

    try:
        have_analog_output = open("/proc/stb/video/mode_choices",
                                  "r").read()[:-1].find("PAL") != -1
    except:
        have_analog_output = False

    SystemInfo["AnalogOutput"] = have_analog_output

    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value and have_analog_output:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="rgb")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="4_3_letterbox")

    config.av.aspect = ConfigSelection(choices={
        "4_3": _("4:3"),
        "16_9": _("16:9"),
        "16_10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="auto")
    config.av.policy_169 = ConfigSelection(
        choices={
            # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
            "letterbox": _("Letterbox"),
            # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
            "panscan": _("Pan&Scan"),
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
            "scale": _("Just Scale")
        },
        default="letterbox")
    config.av.policy_43 = ConfigSelection(
        choices={
            # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
            "pillarbox": _("Pillarbox"),
            # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
            "panscan": _("Pan&Scan"),
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
            "nonlinear": _("Nonlinear"),
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
            "scale": _("Just Scale")
        },
        default="pillarbox")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigOnOff(default=True)
    config.av.defaultac3 = ConfigYesNo(default=False)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      25,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      25,
                                                      default=0)
    config.av.vcrswitch = ConfigOnOff(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    try:
        have_analog_output = open("/proc/stb/video/mode_choices",
                                  "r").read()[:-1].find("PAL") != -1
    except:
        have_analog_output = False

    SystemInfo["AnalogOutput"] = have_analog_output

    if have_analog_output:
        # this will call the "setup-val" initial
        config.av.colorformat.addNotifier(setColorFormat)
        config.av.aspectratio.addNotifier(setAspectRatio)
        config.av.tvsystem.addNotifier(setSystem)
        config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

    try:
        can_downmix = open("/proc/stb/audio/ac3_choices",
                           "r").read()[:-1].find("downmix") != -1
    except:
        can_downmix = False

    SystemInfo["CanDownmixAC3"] = can_downmix
    if can_downmix:

        def setAC3Downmix(configElement):
            open("/proc/stb/audio/ac3",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    try:
        can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
    except:
        can_osd_alpha = False

    ac3plus_support = False

    try:
        ac3plus_choices = open("/proc/stb/audio/ac3plus_choices", "r").read()
        if ac3plus_choices.find("use_hdmi_caps") != -1:
            eDVBServicePMTHandler.setDDPSupport(True)
        if ac3plus_choices.find("force_ac3") != -1:
            ac3plus_support = True
    except:
        pass

    SystemInfo["SupportsAC3PlusTranscode"] = ac3plus_support
    if ac3plus_support:

        def setAC3PlusConvert(configElement):
            open("/proc/stb/audio/ac3plus", "w").write(configElement.value)

        config.av.convert_ac3plus = ConfigSelection(choices=[
            ("use_hdmi_caps", _("controlled by HDMI")),
            ("force_ac3", _("always"))
        ],
                                                    default="use_hdmi_caps")
        config.av.convert_ac3plus.addNotifier(setAC3PlusConvert)

    SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha

    def setAlpha(config):
        open("/proc/stb/video/alpha", "w").write(str(config.value))

    if can_osd_alpha:
        config.av.osd_alpha = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if os_path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "--> setting scaler_sharpness to: %0.8X" % myval
                open("/proc/stb/vmpeg/0/pep_scaler_sharpness",
                     "w").write("%0.8X" % myval)
                open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    try:
        hlg_choices = open("/proc/stb/hdmi/hlg_support_choices", "r").read()

        def setHlgSupport(configElement):
            open("/proc/stb/hdmi/hlg_support", "w").write(configElement.value)

        config.av.hlg_support = ConfigSelection(
            default="auto(EDID)",
            choices=[("auto(EDID)", _("controlled by HDMI")),
                     ("yes", _("force enabled")), ("no", _("force disabled"))])
        config.av.hlg_support.addNotifier(setHlgSupport)

        def setHdr10Support(configElement):
            open("/proc/stb/hdmi/hdr10_support",
                 "w").write(configElement.value)

        config.av.hdr10_support = ConfigSelection(
            default="auto(EDID)",
            choices=[("auto(EDID)", _("controlled by HDMI")),
                     ("yes", _("force enabled")), ("no", _("force disabled"))])
        config.av.hdr10_support.addNotifier(setHdr10Support)

        def setDisable12Bit(configElement):
            open("/proc/stb/video/disable_12bit",
                 "w").write(configElement.value)

        config.av.allow_12bit = ConfigSelection(default="0",
                                                choices=[("0", _("yes")),
                                                         ("1", _("no"))])
        config.av.allow_12bit.addNotifier(setDisable12Bit)

        def setDisable10Bit(configElement):
            open("/proc/stb/video/disable_10bit",
                 "w").write(configElement.value)

        config.av.allow_10bit = ConfigSelection(default="0",
                                                choices=[("0", _("yes")),
                                                         ("1", _("no"))])
        config.av.allow_10bit.addNotifier(setDisable10Bit)
        SystemInfo["HDRSupport"] = True
    except:
        SystemInfo["HDRSupport"] = False
示例#24
0
 def updateBufMetronom(self, cfgelement):
     print "-> update Prebuffer Metronom !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
     eAVSwitch.getInstance().setBufMetronom(
         int(config.pc.prebuffer_metronom_hd.value),
         int(config.pc.prebuffer_metronom_sd.value))
示例#25
0
文件: AVSwitch.py 项目: ostende/test2
def InitAVSwitch():
    config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=False)
    colorformat_choices = {
        "cvbs": _("CVBS"),
        "rgb": _("RGB"),
        "svideo": _("S-Video")
    }

    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="cvbs")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="4_3_letterbox")

    config.av.aspect = ConfigSelection(choices={
        "4_3": _("4:3"),
        "16_9": _("16:9"),
        "16_10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="auto")
    config.av.policy_169 = ConfigSelection(
        choices={
            # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
            "letterbox": _("Letterbox"),
            # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
            "panscan": _("Pan&Scan"),
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
            "scale": _("Just Scale")
        },
        default="letterbox")
    config.av.policy_43 = ConfigSelection(
        choices={
            # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
            "pillarbox": _("Pillarbox"),
            # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
            "panscan": _("Pan&Scan"),
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
            "nonlinear": _("Nonlinear"),
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
            "scale": _("Just Scale")
        },
        default="pillarbox")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.defaultac3 = ConfigYesNo(default=False)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      25,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      25,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    # this will call the "setup-val" initial
    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

    config.av.bypass_edid_checking = ConfigSelection(choices={
        "00000000": _("off"),
        "00000001": _("on")
    },
                                                     default="00000000")

    def setEDIDBypass(configElement):
        f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
        f.write(configElement.value)
        f.close()

    config.av.bypass_edid_checking.addNotifier(setEDIDBypass)

    can_pcm_multichannel = False
    if SystemInfo["CanMultiChannelPCM"]:
        config.av.multichannel_pcm = ConfigYesNo(default=False)
        can_pcm_multichannel = True
        if config.av.multichannel_pcm.value:
            try:
                can_pcm_multichannel = access(
                    "/proc/stb/audio/multichannel_pcm", W_OK) and True or False
            except:
                can_pcm_multichannel = False
    SystemInfo["supportMultiChannelPCM"] = can_pcm_multichannel

    can_speaker_position = False
    if os_path.exists("/proc/stb/audio/3d_surround_speaker_position_choices"):
        can_speaker_position = True
    SystemInfo["supportSpeakerPosition"] = can_speaker_position
    if SystemInfo["CanSpeakerPosition"]:
        choice_list = [("center", _("center")), ("wide", _("wide")),
                       ("extrawide", _("extrawide"))]
        config.av.surround_speaker_position = ConfigSelection(
            choices=choice_list, default="wide")

    if SystemInfo["Can3DSurround"]:

        def set3DSurround(configElement):
            f = open("/proc/stb/audio/3d_surround", "w")
            f.write(configElement.value)
            f.close()
            if SystemInfo[
                    "supportSpeakerPosition"] and config.av.surround_3d.value == "none":
                config.av.surround_speaker_position.value = "wide"
                config.av.surround_speaker_position.save()
                SystemInfo["CanSpeakerPosition"] = False
            elif SystemInfo[
                    "supportSpeakerPosition"] and config.av.surround_3d.value != "none":
                SystemInfo["CanSpeakerPosition"] = True

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.surround_3d = ConfigSelection(choices=choice_list,
                                                default="none")
        config.av.surround_3d.addNotifier(set3DSurround)

    if SystemInfo["supportSpeakerPosition"]:

        def setSpeakerPosition(configElement):
            f = open("/proc/stb/audio/3d_surround_speaker_position", "w")
            f.write(configElement.value)
            f.close()

        config.av.surround_speaker_position.addNotifier(setSpeakerPosition)

    if SystemInfo["CanAVL"]:

        def setAVL(configElement):
            f = open("/proc/stb/audio/avl", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.avl = ConfigSelection(choices=choice_list, default="none")
        config.av.avl.addNotifier(setAVL)

    if SystemInfo["CanDownmixAC3"]:

        def setAC3Downmix(configElement):
            open("/proc/stb/audio/ac3",
                 "w").write(configElement.value and "downmix" or "passthrough")
            if SystemInfo["supportMultiChannelPCM"] and (
                    not config.av.downmix_ac3.value):
                SystemInfo["CanMultiChannelPCM"] = True
            elif SystemInfo[
                    "supportMultiChannelPCM"] and config.av.downmix_ac3.value:
                SystemInfo["CanMultiChannelPCM"] = False
                config.av.multichannel_pcm.value = False
                config.av.multichannel_pcm.save()

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    if SystemInfo["CanDownmixAAC"]:

        def setAACDownmix(configElement):
            open("/proc/stb/audio/aac",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    def setMultiChannelPCM(configElement):
        open("/proc/stb/audio/multichannel_pcm",
             "w").write(configElement.value and "enable" or "disable")

    if SystemInfo["supportMultiChannelPCM"]:
        config.av.multichannel_pcm.addNotifier(
            setMultiChannelPCM, initial_call=config.av.multichannel_pcm.value)

    try:
        can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
    except:
        can_osd_alpha = False

    SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha

    def setAlpha(config):
        open("/proc/stb/video/alpha", "w").write(str(config.value))

    if can_osd_alpha:
        config.av.osd_alpha = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if os_path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "--> setting scaler_sharpness to: %0.8X" % myval
                open("/proc/stb/vmpeg/0/pep_scaler_sharpness",
                     "w").write("%0.8X" % myval)
                open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        config.av.scaler_sharpness = ConfigSlider(default=0, limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())
示例#26
0
文件: AVSwitch.py 项目: vuteam/bh-vu1
def InitAVSwitch():
	if getBoxType() == 'vuduo' or getBoxType().startswith('ixuss'):	
		config.av.yuvenabled = ConfigBoolean(default=False)
	else:
		config.av.yuvenabled = ConfigBoolean(default=True)
	config.av.osd_alpha = ConfigSlider(default=255, increment = 5, limits=(20,255))
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.autores = ConfigSelection(choices={"disabled": _("Disabled"), "simple": _("Simple"), "native": _("Native"), "all": _("All resolutions"), "hd": _("only HD")}, default="disabled")
	config.av.autores_preview = NoSave(ConfigYesNo(default=False))
	config.av.autores_1080i_deinterlace = ConfigYesNo(default=False)
	choicelist = {
			"24,24": _("24p/24p"),
			"24,25": _("24p/25p"),
			"24,30": _("24p/30p"),
			"24,50": _("24p/50p"),
			"24,60": _("24p/60p"),
			"25,24": _("25p/24p"),
			"30,24": _("30p/24p"),
			"50,24": _("50p/24p"),
			"60,24": _("60p/24p"),
			"25,25": _("25p/25p"),
			"25,30": _("25p/30p"),
			"25,50": _("25p/50p"),
			"25,60": _("25p/60p"),
			"30,25": _("30p/25p"),
			"50,25": _("50p/25p"),
			"60,25": _("60p/25p"),
			"30,30": _("30p/30p"),
			"30,50": _("30p/50p"),
			"30,60": _("30p/60p"),
			"50,30": _("50p/30p"),
			"60,30": _("60p/30p"),
			"50,50": _("50p/50p"),
			"50,60": _("50p/60p"),
			"60,50": _("60p/50p"),
			"60,60": _("60p/60p")
				}  # first value <=720p , second value > 720p
	config.av.autores_24p =  ConfigSelection(choices=choicelist, default="50,24")
	config.av.autores_25p =  ConfigSelection(choices=choicelist, default="50,25")
	config.av.autores_30p =  ConfigSelection(choices=choicelist, default="60,30")
	config.av.autores_unknownres =  ConfigSelection(choices={"next": _("next higher Resolution"), "highest": _("highest Resolution")}, default="next")
	choicelist = []
	for i in range(5, 16):
		choicelist.append(("%d" % i, ngettext("%d second", "%d seconds", i) % i))
	config.av.autores_label_timeout = ConfigSelection(default = "5", choices = [("0", _("Not Shown"))] + choicelist)
	config.av.autores_delay = ConfigSelectionNumber(min = 0, max = 3000, stepwidth = 50, default = 400, wraparound = True)
	config.av.autores_deinterlace = ConfigYesNo(default=False)
	config.av.autores_sd = ConfigSelection(choices={"720p50": _("720p50"), "720p": _("720p"), "1080i50": _("1080i50"), "1080i": _("1080i")}, default="720p50")
	config.av.autores_480p24 = ConfigSelection(choices={"480p24": _("480p 24Hz"), "720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz")}, default="1080p24")
	config.av.autores_720p24 = ConfigSelection(choices={"720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz"), "1080i50": _("1080i 50Hz"), "1080i": _("1080i 60Hz")}, default="720p24")
	config.av.autores_1080p24 = ConfigSelection(choices={"1080p24": _("1080p 24Hz"), "1080p25": _("1080p 25Hz"), "1080i50": _("1080p 50Hz"), "1080i": _("1080i 60Hz")}, default="1080p24")
	config.av.autores_1080p25 = ConfigSelection(choices={"1080p25": _("1080p 25Hz"), "1080p50": _("1080p 50Hz"), "1080i50": _("1080i 50Hz")}, default="1080p25")
	config.av.autores_1080p30 = ConfigSelection(choices={"1080p30": _("1080p 30Hz"), "1080p60": _("1080p 60Hz"), "1080i": _("1080i 60Hz")}, default="1080p30")
	config.av.smart1080p = ConfigSelection(choices={"false": _("off"), "true": _("1080p50: 24p/50p/60p"), "2160p50": _("2160p50: 24p/50p/60p"), "1080i50": _("1080i50: 24p/50i/60i"), "720p50": _("720p50: 24p/50p/60p")}, default="false")
	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4:3": _("4:3"),
			"16:9": _("16:9"),
			"16:10": _("16:10"),
			"auto": _("Automatic")},
			default = "16:9")
	policy2_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
	"letterbox": _("Letterbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy2_choices"):
		f = open("/proc/stb/video/policy2_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy2_choices.update({"auto": _("Auto")})
		f.close()	
	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default = "letterbox")
	policy_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
	"panscan": _("Pillarbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"letterbox": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
	# "nonlinear": _("Nonlinear"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"bestfit": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy_choices"):
		f = open("/proc/stb/video/policy_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy_choices.update({"auto": _("Auto")})
		f.close()
	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "panscan")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	#config.av.aspect.setValue('16:9')
	config.av.aspect.addNotifier(iAVSwitch.setAspect)
	config.av.wss.addNotifier(iAVSwitch.setWss)
	config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
	config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

	def setColorFormat(configElement):
		if config.av.videoport and config.av.videoport.value in ("YPbPr", "Scart-YPbPr"):
			iAVSwitch.setColorFormat(3)
		elif config.av.videoport and config.av.videoport.value in ("RCA"):
			iAVSwitch.setColorFormat(0)
		else:
			if getBoxType() == 'et6x00':
				map = {"cvbs": 3, "rgb": 3, "svideo": 2, "yuv": 3}	
			elif getBoxType() == 'gbquad' or getBoxType() == 'gbquadplus' or getBoxType().startswith('et'):
				map = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
			else:
				map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
			iAVSwitch.setColorFormat(map[configElement.value])
	config.av.colorformat.addNotifier(setColorFormat)

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])

	iAVSwitch.setInput("ENCODER") # init on startup
	if (getBoxType() in ('gbquad', 'gbquadplus', 'et5x00', 'ixussone', 'ixusszero', 'axodin', 'axodinc', 'starsatlx', 'galaxym6', 'geniuse3hd', 'evoe3hd', 'axase3', 'axase3c', 'omtimussos1', 'omtimussos2', 'gb800seplus', 'gb800ueplus', 'gbultrase', 'gbultraue', 'gbultraueh' , 'twinboxlcd' )) or about.getModelString() == 'et6000':
		detected = False
	else:
		detected = eAVSwitch.getInstance().haveScartSwitch()

	SystemInfo["ScartSwitch"] = detected

	if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
		f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
		can_edidchecking = f.read().strip().split(" ")
		f.close()
	else:
		can_edidchecking = False

	SystemInfo["Canedidchecking"] = can_edidchecking

	if can_edidchecking:
		def setEDIDBypass(configElement):
			try:
				f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.bypass_edid_checking = ConfigSelection(choices={
				"00000000": _("off"),
				"00000001": _("on")},
				default = "00000001")
		config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
	else:
		config.av.bypass_edid_checking = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_colorspace"):
		f = open("/proc/stb/video/hdmi_colorspace", "r")
		have_colorspace = f.read().strip().split(" ")
		f.close()
	else:
		have_colorspace = False

	SystemInfo["havecolorspace"] = have_colorspace

	if have_colorspace:
		def setHDMIColorspace(configElement):
			try:
				f = open("/proc/stb/video/hdmi_colorspace", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		if getBoxType() in ('vusolo4k','vuuno4k','vuultimo4k'):
			config.av.hdmicolorspace = ConfigSelection(choices={
					"Edid(Auto)": _("Auto"),
					"Hdmi_Rgb": _("RGB"),
					"444": _("YCbCr444"),
					"422": _("YCbCr422"),
					"420": _("YCbCr420")},
					default = "Edid(Auto)")
		elif getBoxType() in ('dm900'):
			config.av.hdmicolorspace = ConfigSelection(choices={
					"Edid(Auto)": _("Auto"),
					"Hdmi_Rgb": _("RGB"),
					"Itu_R_BT_709": _("BT709"),
					"DVI_Full_Range_RGB": _("Full Range RGB"),
					"FCC": _("FCC 1953"),
					"Itu_R_BT_470_2_BG": _("BT470 BG"),
					"Smpte_170M": _("Smpte 170M"),
					"Smpte_240M": _("Smpte 240M"),
					"Itu_R_BT_2020_NCL": _("BT2020 NCL"),
					"Itu_R_BT_2020_CL": _("BT2020 CL"),
					"XvYCC_709": _("BT709 XvYCC"),
					"XvYCC_601": _("BT601 XvYCC")},
					default = "Edid(Auto)")
		else:
			config.av.hdmicolorspace = ConfigSelection(choices={
					"auto": _("auto"),
					"rgb": _("rgb"),
					"420": _("420"),
					"422": _("422"),
					"444": _("444")},
					default = "auto")
		config.av.hdmicolorspace.addNotifier(setHDMIColorspace)
	else:
		config.av.hdmicolorspace = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_colorimetry"):
		f = open("/proc/stb/video/hdmi_colorimetry", "r")
		have_colorimetry = f.read().strip().split(" ")
		f.close()
	else:
		have_colorimetry = False

	SystemInfo["havecolorimetry"] = have_colorimetry

	if have_colorimetry:
		def setHDMIColorimetry(configElement):
			sleep(0.1)
			try:
				f = open("/proc/stb/video/hdmi_colorimetry", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.hdmicolorimetry = ConfigSelection(choices={
				"auto": _("auto"),
				"bt2020ncl": _("BT 2020 NCL"),
				"bt2020cl": _("BT 2020 CL"),
				"bt709": _("BT 709")},
				default = "auto")
		config.av.hdmicolorimetry.addNotifier(setHDMIColorimetry)
	else:
		config.av.hdmicolorimetry = ConfigNothing()

	if os.path.exists("/proc/stb/info/boxmode"):
		f = open("/proc/stb/info/boxmode", "r")
		have_boxmode = f.read().strip().split(" ")
		f.close()
	else:
		have_boxmode = False

	SystemInfo["haveboxmode"] = have_boxmode

	if have_boxmode:
		def setBoxmode(configElement):
			try:
				f = open("/proc/stb/info/boxmode", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.boxmode = ConfigSelection(choices={
				"12": _("enable PIP no HDR"),
				"1": _("12bit 4:2:0/4:2:2 no PIP")},
				default = "12")
		config.av.boxmode.addNotifier(setBoxmode)
	else:
		config.av.boxmode = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_colordepth"):
		f = open("/proc/stb/video/hdmi_colordepth", "r")
		have_HdmiColordepth = f.read().strip().split(" ")
		f.close()
	else:
		have_HdmiColordepth = False

	SystemInfo["havehdmicolordepth"] = have_HdmiColordepth

	if have_HdmiColordepth:
		def setHdmiColordepth(configElement):
			try:
				f = open("/proc/stb/video/hdmi_colordepth", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.hdmicolordepth = ConfigSelection(choices={
				"auto": _("Auto"),
				"8bit": _("8bit"),
				"10bit": _("10bit"),
				"12bit": _("12bit")},
				default = "auto")
		config.av.hdmicolordepth.addNotifier(setHdmiColordepth)
	else:
		config.av.hdmicolordepth = ConfigNothing()

	if os.path.exists("/proc/stb/hdmi/audio_source"):
		f = open("/proc/stb/hdmi/audio_source", "r")
		can_audiosource = f.read().strip().split(" ")
		f.close()
	else:
		can_audiosource = False

	SystemInfo["Canaudiosource"] = can_audiosource

	if can_audiosource:
		def setAudioSource(configElement):
			try:
				f = open("/proc/stb/hdmi/audio_source", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.audio_source = ConfigSelection(choices={
				"pcm": _("PCM"),
				"spdif": _("SPDIF")},
				default="pcm")
		config.av.audio_source.addNotifier(setAudioSource)
	else:
		config.av.audio_source = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_choices"):
		f = open("/proc/stb/audio/3d_surround_choices", "r")
		can_3dsurround = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround = False

	SystemInfo["Can3DSurround"] = can_3dsurround

	if can_3dsurround:
		def set3DSurround(configElement):
			f = open("/proc/stb/audio/3d_surround", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.surround_3d = ConfigSelection(choices = choice_list, default = "none")
		config.av.surround_3d.addNotifier(set3DSurround)
	else:
		config.av.surround_3d = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_speaker_position_choices"):
		f = open("/proc/stb/audio/3d_surround_speaker_position_choices", "r")
		can_3dsurround_speaker = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround_speaker = False

	SystemInfo["Can3DSpeaker"] = can_3dsurround_speaker

	if can_3dsurround_speaker:
		def set3DSurroundSpeaker(configElement):
			f = open("/proc/stb/audio/3d_surround_speaker_position", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))]
		config.av.surround_3d_speaker = ConfigSelection(choices = choice_list, default = "center")
		config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)
	else:
		config.av.surround_3d_speaker = ConfigNothing()

	if os.path.exists("/proc/stb/audio/avl_choices"):
		f = open("/proc/stb/audio/avl_choices", "r")
		can_autovolume = f.read().strip().split(" ")
		f.close()
	else:
		can_autovolume = False

	SystemInfo["CanAutoVolume"] = can_autovolume

	if can_autovolume:
		def setAutoVolume(configElement):
			f = open("/proc/stb/audio/avl", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.autovolume = ConfigSelection(choices = choice_list, default = "none")
		config.av.autovolume.addNotifier(setAutoVolume)
	else:
		config.av.autovolume = ConfigNothing()

	try:
		can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm", os.W_OK)
	except:
		can_pcm_multichannel = False

	SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
	if can_pcm_multichannel:
		def setPCMMultichannel(configElement):
			open("/proc/stb/audio/multichannel_pcm", "w").write(configElement.value and "enable" or "disable")
		config.av.pcm_multichannel = ConfigYesNo(default = False)
		config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

	try:
		f = open("/proc/stb/audio/ac3_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_ac3 = "downmix" in file
	except:
		can_downmix_ac3 = False
		SystemInfo["CanPcmMultichannel"] = False

	SystemInfo["CanDownmixAC3"] = can_downmix_ac3
	if can_downmix_ac3:
		def setAC3Downmix(configElement):
			f = open("/proc/stb/audio/ac3", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
			if SystemInfo.get("supportPcmMultichannel", False) and not configElement.value:
				SystemInfo["CanPcmMultichannel"] = True
			else:
				SystemInfo["CanPcmMultichannel"] = False
				if can_pcm_multichannel:
					config.av.pcm_multichannel.setValue(False)
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	if os.path.exists("/proc/stb/audio/ac3plus_choices"):
		f = open("/proc/stb/audio/ac3plus_choices", "r")
		can_ac3plustranscode = f.read().strip().split(" ")
		f.close()
	else:
		can_ac3plustranscode = False

	SystemInfo["CanAC3plusTranscode"] = can_ac3plustranscode

	if can_ac3plustranscode:
		def setAC3plusTranscode(configElement):
			f = open("/proc/stb/audio/ac3plus", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("use_hdmi_caps", _("controlled by HDMI")), ("force_ac3", _("always"))]
		config.av.transcodeac3plus = ConfigSelection(choices = choice_list, default = "use_hdmi_caps")
		config.av.transcodeac3plus.addNotifier(setAC3plusTranscode)

	try:
		f = open("/proc/stb/audio/dts_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_dts = "downmix" in file
	except:
		can_downmix_dts = False

	SystemInfo["CanDownmixDTS"] = can_downmix_dts
	if can_downmix_dts:
		def setDTSDownmix(configElement):
			f = open("/proc/stb/audio/dts", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		config.av.downmix_dts = ConfigYesNo(default = True)
		config.av.downmix_dts.addNotifier(setDTSDownmix)

	try:
		f = open("/proc/stb/audio/aac_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_aac = "downmix" in file
	except:
		can_downmix_aac = False

	SystemInfo["CanDownmixAAC"] = can_downmix_aac
	if can_downmix_aac:
		def setAACDownmix(configElement):
			f = open("/proc/stb/audio/aac", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		config.av.downmix_aac = ConfigYesNo(default = True)
		config.av.downmix_aac.addNotifier(setAACDownmix)

	if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
		f = open("/proc/stb/audio/aac_transcode_choices", "r")
		can_aactranscode = f.read().strip().split(" ")
		f.close()
	else:
		can_aactranscode = False

	SystemInfo["CanAACTranscode"] = can_aactranscode

	if can_aactranscode:
		def setAACTranscode(configElement):
			f = open("/proc/stb/audio/aac_transcode", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
		config.av.transcodeaac = ConfigSelection(choices = choice_list, default = "off")
		config.av.transcodeaac.addNotifier(setAACTranscode)
	else:
		config.av.transcodeaac = ConfigNothing()

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print "[VideoMode] setting scaler_sharpness to: %0.8X" % myval
				f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
				f.write("%0.8X\n" % myval)
				f.close()
				f = open("/proc/stb/vmpeg/0/pep_apply", "w")
				f.write("1")
				f.close()
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		if getBoxType() in ('gbquad', 'gbquadplus'):
			config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0,26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())

	config.av.edid_override = ConfigYesNo(default = False)

	iAVSwitch.setConfiguredMode()
示例#27
0
	def setInput(self, input):
		INPUT = { "ENCODER": 0, "SCART": 1, "AUX": 2 }
		eAVSwitch.getInstance().setInput(INPUT[input])
示例#28
0
def InitAVSwitch():
    if getBoxType() == 'vuduo' or getBoxType().startswith('ixuss'):
        config.av.yuvenabled = ConfigBoolean(default=False)
    else:
        config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {'cvbs': _('CVBS'),
     'rgb': _('RGB'),
     'svideo': _('S-Video')}
    if config.av.yuvenabled.value:
        colorformat_choices['yuv'] = _('YPbPr')
    config.av.autores = ConfigSelection(choices={'disabled': _('Disabled'),
     'all': _('All resolutions'),
     'hd': _('only HD'),
     '4k': _('only 4K')}, default='disabled')
    choicelist = []
    for i in range(5, 16):
        choicelist.append(('%d' % i, ngettext('%d second', '%d seconds', i) % i))

    config.av.autores_label_timeout = ConfigSelection(default='5', choices=[('0', _('Not Shown'))] + choicelist)
    config.av.autores_delay = ConfigSelectionNumber(min=50, max=3000, stepwidth=50, default=400, wraparound=True)
    config.av.autores_deinterlace = ConfigYesNo(default=False)
    config.av.autores_sd = ConfigSelection(choices={'720p50': _('720p50'),
     '720p': _('720p'),
     '1080i50': _('1080i50'),
     '1080i': _('1080i')}, default='720p50')
    config.av.autores_480p24 = ConfigSelection(choices={'480p24': _('480p 24Hz'),
     '720p24': _('720p 24Hz'),
     '1080p24': _('1080p 24Hz')}, default='1080p24')
    config.av.autores_720p24 = ConfigSelection(choices={'720p24': _('720p 24Hz'),
     '1080p24': _('1080p 24Hz'),
     '1080i50': _('1080i 50Hz'),
     '1080i': _('1080i 60Hz')}, default='720p24')
    config.av.autores_1080p24 = ConfigSelection(choices={'1080p24': _('1080p 24Hz'),
     '1080p25': _('1080p 25Hz'),
     '1080i50': _('1080p 50Hz'),
     '1080i': _('1080i 60Hz')}, default='1080p24')
    config.av.autores_1080p25 = ConfigSelection(choices={'1080p25': _('1080p 25Hz'),
     '1080p50': _('1080p 50Hz'),
     '1080i50': _('1080i 50Hz')}, default='1080p25')
    config.av.autores_1080p30 = ConfigSelection(choices={'1080p30': _('1080p 30Hz'),
     '1080p60': _('1080p 60Hz'),
     '1080i': _('1080i 60Hz')}, default='1080p30')
    config.av.smart1080p = ConfigSelection(choices={'false': _('off'),
     'true': _('1080p50: 24p/50p/60p'),
     '1080i50': _('1080i50: 24p/50i/60i'),
     '720p50': _('720p50: 24p/50p/60p')}, default='false')
    config.av.colorformat = ConfigSelection(choices=colorformat_choices, default='rgb')
    config.av.aspectratio = ConfigSelection(choices={'4_3_letterbox': _('4:3 Letterbox'),
     '4_3_panscan': _('4:3 PanScan'),
     '16_9': _('16:9'),
     '16_9_always': _('16:9 always'),
     '16_10_letterbox': _('16:10 Letterbox'),
     '16_10_panscan': _('16:10 PanScan'),
     '16_9_letterbox': _('16:9 Letterbox')}, default='16_9')
    config.av.aspect = ConfigSelection(choices={'4:3': _('4:3'),
     '16:9': _('16:9'),
     '16:10': _('16:10'),
     'auto': _('Automatic')}, default='16:9')
    policy2_choices = {'letterbox': _('Letterbox'),
     'panscan': _('Pan&scan'),
     'scale': _('Just scale')}
    if os.path.exists('/proc/stb/video/policy2_choices'):
        f = open('/proc/stb/video/policy2_choices')
        if 'auto' in f.readline():
            policy2_choices.update({'auto': _('Auto')})
        f.close()
    config.av.policy_169 = ConfigSelection(choices=policy2_choices, default='letterbox')
    policy_choices = {'panscan': _('Pillarbox'),
     'letterbox': _('Pan&scan'),
     'bestfit': _('Just scale')}
    if os.path.exists('/proc/stb/video/policy_choices'):
        f = open('/proc/stb/video/policy_choices')
        if 'auto' in f.readline():
            policy_choices.update({'auto': _('Auto')})
        f.close()
    config.av.policy_43 = ConfigSelection(choices=policy_choices, default='panscan')
    config.av.tvsystem = ConfigSelection(choices={'pal': _('PAL'),
     'ntsc': _('NTSC'),
     'multinorm': _('multinorm')}, default='pal')
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)
    config.av.aspect.addNotifier(iAVSwitch.setAspect)
    config.av.wss.addNotifier(iAVSwitch.setWss)
    config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
    config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

    def setColorFormat(configElement):
        if config.av.videoport and config.av.videoport.value in ('YPbPr', 'Scart-YPbPr'):
            iAVSwitch.setColorFormat(3)
        elif config.av.videoport and config.av.videoport.value in 'RCA':
            iAVSwitch.setColorFormat(0)
        else:
            if getBoxType() == 'et6x00':
                map = {'cvbs': 3,
                 'rgb': 3,
                 'svideo': 2,
                 'yuv': 3}
            elif getBoxType() == 'gbquad' or getBoxType() == 'gbquadplus' or getBoxType().startswith('et'):
                map = {'cvbs': 0,
                 'rgb': 3,
                 'svideo': 2,
                 'yuv': 3}
            else:
                map = {'cvbs': 0,
                 'rgb': 1,
                 'svideo': 2,
                 'yuv': 3}
            iAVSwitch.setColorFormat(map[configElement.value])

    config.av.colorformat.addNotifier(setColorFormat)

    def setAspectRatio(configElement):
        map = {'4_3_letterbox': 0,
         '4_3_panscan': 1,
         '16_9': 2,
         '16_9_always': 3,
         '16_10_letterbox': 4,
         '16_10_panscan': 5,
         '16_9_letterbox': 6}
        iAVSwitch.setAspectRatio(map[configElement.value])

    iAVSwitch.setInput('ENCODER')
    if getBoxType() in ('gbquad', 'gbquadplus', 'et5x00', 'ixussone', 'ixusszero', 'axodin', 'axodinc', 'starsatlx', 'galaxym6', 'geniuse3hd', 'evoe3hd', 'axase3', 'axase3c', 'omtimussos1', 'omtimussos2', 'gb800seplus', 'gb800ueplus', 'gbultrase', 'gbultraue', 'twinboxlcd') or about.getModelString() == 'et6000':
        detected = False
    else:
        detected = eAVSwitch.getInstance().haveScartSwitch()
    SystemInfo['ScartSwitch'] = detected
    if os.path.exists('/proc/stb/hdmi/bypass_edid_checking'):
        f = open('/proc/stb/hdmi/bypass_edid_checking', 'r')
        can_edidchecking = f.read().strip().split(' ')
        f.close()
    else:
        can_edidchecking = False
    SystemInfo['Canedidchecking'] = can_edidchecking
    if can_edidchecking:

        def setEDIDBypass(configElement):
            try:
                f = open('/proc/stb/hdmi/bypass_edid_checking', 'w')
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.bypass_edid_checking = ConfigSelection(choices={'00000000': _('off'),
         '00000001': _('on')}, default='00000001')
        config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
    else:
        config.av.bypass_edid_checking = ConfigNothing()
    if os.path.exists('/proc/stb/video/hdmi_colorspace'):
        f = open('/proc/stb/video/hdmi_colorspace', 'r')
        have_colorspace = f.read().strip().split(' ')
        f.close()
    else:
        have_colorspace = False
    SystemInfo['havecolorspace'] = have_colorspace
    if have_colorspace:

        def setHDMIColorspace(configElement):
            try:
                f = open('/proc/stb/video/hdmi_colorspace', 'w')
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.hdmicolorspace = ConfigSelection(choices={'Edid(Auto)': _('Auto'),
         'Hdmi_Rgb': _('RGB')}, default='Edid(Auto)')
        config.av.hdmicolorspace.addNotifier(setHDMIColorspace)
    else:
        config.av.hdmicolorspace = ConfigNothing()
    if os.path.exists('/proc/stb/hdmi/audio_source'):
        f = open('/proc/stb/hdmi/audio_source', 'r')
        can_audiosource = f.read().strip().split(' ')
        f.close()
    else:
        can_audiosource = False
    SystemInfo['Canaudiosource'] = can_audiosource
    if can_audiosource:

        def setAudioSource(configElement):
            try:
                f = open('/proc/stb/hdmi/audio_source', 'w')
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.audio_source = ConfigSelection(choices={'pcm': _('PCM'),
         'spdif': _('SPDIF')}, default='pcm')
        config.av.audio_source.addNotifier(setAudioSource)
    else:
        config.av.audio_source = ConfigNothing()
    if os.path.exists('/proc/stb/audio/3d_surround_choices'):
        f = open('/proc/stb/audio/3d_surround_choices', 'r')
        can_3dsurround = f.read().strip().split(' ')
        f.close()
    else:
        can_3dsurround = False
    SystemInfo['Can3DSurround'] = can_3dsurround
    if can_3dsurround:

        def set3DSurround(configElement):
            f = open('/proc/stb/audio/3d_surround', 'w')
            f.write(configElement.value)
            f.close()

        choice_list = [('none', _('off')),
         ('hdmi', _('HDMI')),
         ('spdif', _('SPDIF')),
         ('dac', _('DAC'))]
        config.av.surround_3d = ConfigSelection(choices=choice_list, default='none')
        config.av.surround_3d.addNotifier(set3DSurround)
    else:
        config.av.surround_3d = ConfigNothing()
    if os.path.exists('/proc/stb/audio/avl_choices'):
        f = open('/proc/stb/audio/avl_choices', 'r')
        can_autovolume = f.read().strip().split(' ')
        f.close()
    else:
        can_autovolume = False
    SystemInfo['CanAutoVolume'] = can_autovolume
    if can_autovolume:

        def setAutoVulume(configElement):
            f = open('/proc/stb/audio/avl', 'w')
            f.write(configElement.value)
            f.close()

        choice_list = [('none', _('off')),
         ('hdmi', _('HDMI')),
         ('spdif', _('SPDIF')),
         ('dac', _('DAC'))]
        config.av.autovolume = ConfigSelection(choices=choice_list, default='none')
        config.av.autovolume.addNotifier(setAutoVulume)
    else:
        config.av.autovolume = ConfigNothing()
    if os.path.exists('/proc/stb/audio/3d_surround_speaker_position_choices'):
        f = open('/proc/stb/audio/3d_surround_speaker_position_choices', 'r')
        can_3dsurround_speaker = f.read().strip().split(' ')
        f.close()
    else:
        can_3dsurround_speaker = False
    SystemInfo['Can3DSpeaker'] = can_3dsurround_speaker
    if can_3dsurround_speaker:

        def set3DSurroundSpeaker(configElement):
            f = open('/proc/stb/audio/3d_surround_speaker_position', 'w')
            f.write(configElement.value)
            f.close()

        choice_list = [('center', _('center')), ('wide', _('wide')), ('extrawide', _('extra wide'))]
        config.av.surround_3d_speaker = ConfigSelection(choices=choice_list, default='center')
        config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)
    else:
        config.av.surround_3d_speaker = ConfigNothing()
    if os.path.exists('/proc/stb/audio/avl_choices'):
        f = open('/proc/stb/audio/avl_choices', 'r')
        can_autovolume = f.read().strip().split(' ')
        f.close()
    else:
        can_autovolume = False
    SystemInfo['CanAutoVolume'] = can_autovolume
    if can_autovolume:

        def setAutoVolume(configElement):
            f = open('/proc/stb/audio/avl', 'w')
            f.write(configElement.value)
            f.close()

        choice_list = [('none', _('off')),
         ('hdmi', _('HDMI')),
         ('spdif', _('SPDIF')),
         ('dac', _('DAC'))]
        config.av.autovolume = ConfigSelection(choices=choice_list, default='none')
        config.av.autovolume.addNotifier(setAutoVolume)
    else:
        config.av.autovolume = ConfigNothing()
    try:
        can_pcm_multichannel = os.access('/proc/stb/audio/multichannel_pcm', os.W_OK)
    except:
        can_pcm_multichannel = False

    SystemInfo['supportPcmMultichannel'] = can_pcm_multichannel
    if can_pcm_multichannel:

        def setPCMMultichannel(configElement):
            open('/proc/stb/audio/multichannel_pcm', 'w').write(configElement.value and 'enable' or 'disable')

        config.av.pcm_multichannel = ConfigYesNo(default=False)
        config.av.pcm_multichannel.addNotifier(setPCMMultichannel)
    try:
        f = open('/proc/stb/audio/ac3_choices', 'r')
        file = f.read()[:-1]
        f.close()
        can_downmix_ac3 = 'downmix' in file
    except:
        can_downmix_ac3 = False
        SystemInfo['CanPcmMultichannel'] = False

    SystemInfo['CanDownmixAC3'] = can_downmix_ac3
    if can_downmix_ac3:

        def setAC3Downmix(configElement):
            f = open('/proc/stb/audio/ac3', 'w')
            f.write(configElement.value and 'downmix' or 'passthrough')
            f.close()
            if SystemInfo.get('supportPcmMultichannel', False) and not configElement.value:
                SystemInfo['CanPcmMultichannel'] = True
            else:
                SystemInfo['CanPcmMultichannel'] = False
                if can_pcm_multichannel:
                    config.av.pcm_multichannel.setValue(False)

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)
    try:
        f = open('/proc/stb/audio/aac_choices', 'r')
        file = f.read()[:-1]
        f.close()
        can_downmix_aac = 'downmix' in file
    except:
        can_downmix_aac = False

    SystemInfo['CanDownmixAAC'] = can_downmix_aac
    if can_downmix_aac:

        def setAACDownmix(configElement):
            f = open('/proc/stb/audio/aac', 'w')
            f.write(configElement.value and 'downmix' or 'passthrough')
            f.close()

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)
    if os.path.exists('/proc/stb/audio/aac_transcode_choices'):
        f = open('/proc/stb/audio/aac_transcode_choices', 'r')
        can_aactranscode = f.read().strip().split(' ')
        f.close()
    else:
        can_aactranscode = False
    SystemInfo['CanAACTranscode'] = can_aactranscode
    if can_aactranscode:

        def setAACTranscode(configElement):
            f = open('/proc/stb/audio/aac_transcode', 'w')
            f.write(configElement.value)
            f.close()

        choice_list = [('off', _('off')), ('ac3', _('AC3')), ('dts', _('DTS'))]
        config.av.transcodeaac = ConfigSelection(choices=choice_list, default='off')
        config.av.transcodeaac.addNotifier(setAACTranscode)
    else:
        config.av.transcodeaac = ConfigNothing()
    try:
        SystemInfo['CanChangeOsdAlpha'] = open('/proc/stb/video/alpha', 'r') and True or False
    except:
        SystemInfo['CanChangeOsdAlpha'] = False

    if SystemInfo['CanChangeOsdAlpha']:

        def setAlpha(config):
            open('/proc/stb/video/alpha', 'w').write(str(config.value))

        config.av.osd_alpha2 = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha2.addNotifier(setAlpha)
    if os.path.exists('/proc/stb/vmpeg/0/pep_scaler_sharpness'):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print '[VideoHardware] setting scaler_sharpness to: %0.8X' % myval
                f = open('/proc/stb/vmpeg/0/pep_scaler_sharpness', 'w')
                f.write('%0.8X' % myval)
                f.close()
                f = open('/proc/stb/vmpeg/0/pep_apply', 'w')
                f.write('1')
                f.close()
            except IOError:
                print "[VideoHardware] couldn't write pep_scaler_sharpness"

        if getBoxType() in ('gbquad', 'gbquadplus'):
            config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0, 26))
        else:
            config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())
    config.av.edid_override = ConfigYesNo(default=False)
    iAVSwitch.setConfiguredMode()
示例#29
0
 def setColorFormat(self, value):
     eAVSwitch.getInstance().setColorFormat(value)
示例#30
0
文件: AVSwitch.py 项目: popazerty/12
def InitAVSwitch():
	config.av = ConfigSubsection()
	config.av.yuvenabled = ConfigBoolean(default=False)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}

	try:
		have_analog_output = open("/proc/stb/video/mode_choices", "r").read()[:-1].find("PAL") != -1
	except:
		have_analog_output = False

	SystemInfo["AnalogOutput"] = have_analog_output

	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value and have_analog_output:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"), 
			"16_9": _("16:9"), 
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"), 
			"16_9_letterbox": _("16:9 Letterbox")}, 
			default = "4_3_letterbox")

	config.av.aspect = ConfigSelection(choices={
			"4_3": _("4:3"),
			"16_9": _("16:9"), 
			"16_10": _("16:10"),
			"auto": _("Automatic")},
			default = "auto")
	config.av.policy_169 = ConfigSelection(choices={
				# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
			"letterbox": _("Letterbox"), 
				# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
			"panscan": _("Pan&Scan"),  
				# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
			"scale": _("Just Scale")},
			default = "letterbox")
	config.av.policy_43 = ConfigSelection(choices={
				# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
			"pillarbox": _("Pillarbox"), 
				# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
			"panscan": _("Pan&Scan"),  
				# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
			"nonlinear": _("Nonlinear"),  
				# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
			"scale": _("Just Scale")},
			default = "pillarbox")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.defaultac3 = ConfigYesNo(default = False)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 25, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 25, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	iAVSwitch = AVSwitch()

	def setColorFormat(configElement):
		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		iAVSwitch.setColorFormat(map[configElement.value])

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])

	def setSystem(configElement):
		map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
		iAVSwitch.setSystem(map[configElement.value])

	def setWSS(configElement):
		iAVSwitch.setAspectWSS()

	try:
		have_analog_output = open("/proc/stb/video/mode_choices", "r").read()[:-1].find("PAL") != -1
	except:
		have_analog_output = False

	SystemInfo["AnalogOutput"] = have_analog_output

	if have_analog_output:
		# this will call the "setup-val" initial
		config.av.colorformat.addNotifier(setColorFormat)
		config.av.aspectratio.addNotifier(setAspectRatio)
		config.av.tvsystem.addNotifier(setSystem)
		config.av.wss.addNotifier(setWSS)

	iAVSwitch.setInput("ENCODER") # init on startup
	SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

	try:
		can_downmix = open("/proc/stb/audio/ac3_choices", "r").read()[:-1].find("downmix") != -1
	except:
		can_downmix = False

	SystemInfo["CanDownmixAC3"] = can_downmix
	if can_downmix:
		def setAC3Downmix(configElement):
			open("/proc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	try:
		can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
	except:
		can_osd_alpha = False

	ac3plus_support = False

	try:
		ac3plus_choices = open("/proc/stb/audio/ac3plus_choices", "r").read()
		if ac3plus_choices.find("use_hdmi_caps") != -1:
			eDVBServicePMTHandler.setDDPSupport(True)
		if ac3plus_choices.find("force_ac3") != -1:
			ac3plus_support = True
	except:
		pass

	SystemInfo["SupportsAC3PlusTranscode"] = ac3plus_support
	if ac3plus_support:
		def setAC3PlusConvert(configElement):
			open("/proc/stb/audio/ac3plus", "w").write(configElement.value)
		config.av.convert_ac3plus = ConfigSelection(choices = [ ("use_hdmi_caps",  _("controlled by HDMI")), ("force_ac3", _("always")) ], default = "use_hdmi_caps")
		config.av.convert_ac3plus.addNotifier(setAC3PlusConvert)

	SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha

	def setAlpha(config):
		open("/proc/stb/video/alpha", "w").write(str(config.value))

	if can_osd_alpha:
		config.av.osd_alpha = ConfigSlider(default=255, limits=(0,255))
		config.av.osd_alpha.addNotifier(setAlpha)

	if os_path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print "--> setting scaler_sharpness to: %0.8X" % myval
				open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval)
				open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())
示例#31
0
 def setSystem(self, value):
     eAVSwitch.getInstance().setVideomode(value)
示例#32
0
def InitAVSwitch():
	if getBoxType() == 'vuduo' or getBoxType().startswith('ixuss'):
		config.av.yuvenabled = ConfigBoolean(default=False)
	else:
		config.av.yuvenabled = ConfigBoolean(default=True)
	config.av.osd_alpha = ConfigSlider(default=255, increment=5, limits=(20, 255)) # Make openHDF compatible with some plugins who still use config.av.osd_alpha
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.autores = ConfigSelection(choices={"disabled": _("Disabled"), "simple": _("Simple"), "native": _("Native"), "all": _("All resolutions"), "hd": _("only HD")}, default="disabled")
	config.av.autores_preview = NoSave(ConfigYesNo(default=False))
	config.av.autores_1080i_deinterlace = ConfigYesNo(default=False)
	choicelist = {
			"24,24": _("24p/24p"),
			"24,25": _("24p/25p"),
			"24,30": _("24p/30p"),
			"24,50": _("24p/50p"),
			"24,60": _("24p/60p"),
			"25,24": _("25p/24p"),
			"30,24": _("30p/24p"),
			"50,24": _("50p/24p"),
			"60,24": _("60p/24p"),
			"25,25": _("25p/25p"),
			"25,30": _("25p/30p"),
			"25,50": _("25p/50p"),
			"25,60": _("25p/60p"),
			"30,25": _("30p/25p"),
			"50,25": _("50p/25p"),
			"60,25": _("60p/25p"),
			"30,30": _("30p/30p"),
			"30,50": _("30p/50p"),
			"30,60": _("30p/60p"),
			"50,30": _("50p/30p"),
			"60,30": _("60p/30p"),
			"50,50": _("50p/50p"),
			"50,60": _("50p/60p"),
			"60,50": _("60p/50p"),
			"60,60": _("60p/60p")
				}  # first value <=720p , second value > 720p
	config.av.autores_24p = ConfigSelection(choices=choicelist, default="50,24")
	config.av.autores_25p = ConfigSelection(choices=choicelist, default="50,25")
	config.av.autores_30p = ConfigSelection(choices=choicelist, default="60,30")
	config.av.autores_unknownres = ConfigSelection(choices={"next": _("next higher Resolution"), "highest": _("highest Resolution")}, default="next")
	choicelist = []
	for i in list(range(5, 16)):
		choicelist.append(("%d" % i, ngettext("%d second", "%d seconds", i) % i))
	config.av.autores_label_timeout = ConfigSelection(default="5", choices=[("0", _("Not Shown"))] + choicelist)
	config.av.autores_delay = ConfigSelectionNumber(min=0, max=3000, stepwidth=50, default=400, wraparound=True)
	config.av.autores_deinterlace = ConfigYesNo(default=False)
	config.av.autores_sd = ConfigSelection(choices={"720p50": _("720p50"), "720p": _("720p"), "1080i50": _("1080i50"), "1080i": _("1080i")}, default="720p50")
	config.av.autores_480p24 = ConfigSelection(choices={"480p24": _("480p 24Hz"), "720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz")}, default="1080p24")
	config.av.autores_720p24 = ConfigSelection(choices={"720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz"), "1080i50": _("1080i 50Hz"), "1080i": _("1080i 60Hz")}, default="720p24")
	config.av.autores_1080p24 = ConfigSelection(choices={"1080p24": _("1080p 24Hz"), "1080p25": _("1080p 25Hz"), "1080i50": _("1080p 50Hz"), "1080i": _("1080i 60Hz")}, default="1080p24")
	config.av.autores_1080p25 = ConfigSelection(choices={"1080p25": _("1080p 25Hz"), "1080p50": _("1080p 50Hz"), "1080i50": _("1080i 50Hz")}, default="1080p25")
	config.av.autores_1080p30 = ConfigSelection(choices={"1080p30": _("1080p 30Hz"), "1080p60": _("1080p 60Hz"), "1080i": _("1080i 60Hz")}, default="1080p30")
	config.av.autores_2160p24 = ConfigSelection(choices={"2160p24": _("2160p 24Hz"), "2160p25": _("2160p 25Hz"), "2160p30": _("2160p 30Hz")}, default="2160p24")
	config.av.autores_2160p25 = ConfigSelection(choices={"2160p25": _("2160p 25Hz"), "2160p50": _("2160p 50Hz")}, default="2160p25")
	config.av.autores_2160p30 = ConfigSelection(choices={"2160p30": _("2160p 30Hz"), "2160p60": _("2160p 60Hz")}, default="2160p30")
	config.av.smart1080p = ConfigSelection(choices={"false": _("off"), "true": _("1080p50: 24p/50p/60p"), "2160p50": _("2160p50: 24p/50p/60p"), "1080i50": _("1080i50: 24p/50i/60i"), "720p50": _("720p50: 24p/50p/60p")}, default="false")
	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default="16_9")
	config.av.aspect = ConfigSelection(choices={
			"4:3": _("4:3"),
			"16:9": _("16:9"),
			"16:10": _("16:10"),
			"auto": _("Automatic")},
			default="16:9")

	# Some boxes have a redundant proc entry for policy2 choices, but some don't (The choices are from a 16:9 point of view anyways)
	if os.path.exists("/proc/stb/video/policy2_choices"):
		policy2_choices_proc = "/proc/stb/video/policy2_choices"
	else:
		policy2_choices_proc = "/proc/stb/video/policy_choices"

	try:
		policy2_choices_raw = open(policy2_choices_proc, "r").read()
	except:
		policy2_choices_raw = "letterbox"

	policy2_choices = {}

	if "letterbox" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
		policy2_choices.update({"letterbox": _("Letterbox")})

	if "panscan" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
		policy2_choices.update({"panscan": _("Pan&scan")})

	if "nonliner" in policy2_choices_raw and not "nonlinear" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the top/bottom (Center of picture maintains aspect, top/bottom lose aspect heaver than on linear stretch))
		policy2_choices.update({"nonliner": _("Stretch nonlinear")})
	if "nonlinear" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the top/bottom (Center of picture maintains aspect, top/bottom lose aspect heaver than on linear stretch))
		policy2_choices.update({"nonlinear": _("Stretch nonlinear")})

	if "scale" in policy2_choices_raw and not "auto" in policy2_choices_raw and not "bestfit" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy2_choices.update({"scale": _("Stretch linear")})
	if "full" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (force aspect))
		policy2_choices.update({"full": _("Stretch full")})
	if "auto" in policy2_choices_raw and not "bestfit" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy2_choices.update({"auto": _("Stretch linear")})
	if "bestfit" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy2_choices.update({"bestfit": _("Stretch linear")})

	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default="letterbox")

	policy_choices_proc = "/proc/stb/video/policy_choices"
	try:
		policy_choices_raw = open(policy_choices_proc, "r").read()
	except:
		policy_choices_raw = "panscan"

	policy_choices = {}

	if "pillarbox" in policy_choices_raw and not "panscan" in policy_choices_raw:
		# Very few boxes support "pillarbox" as an alias for "panscan" (Which in fact does pillarbox)
		# So only add "pillarbox" if "panscan" is not listed in choices

		# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
		policy_choices.update({"pillarbox": _("Pillarbox")})

	if "panscan" in policy_choices_raw:
		# DRIVER BUG:	"panscan" in /proc actually does "pillarbox" (That's probably why an alias to it named "pillarbox" existed)!
		#		Interpret "panscan" setting with a "Pillarbox" text in order to show the correct value in GUI

		# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
		policy_choices.update({"panscan": _("Pillarbox")})

	if "letterbox" in policy_choices_raw:
		# DRIVER BUG:	"letterbox" in /proc actually does pan&scan
		#		"letterbox" and 4:3 content on 16:9 TVs is mutually exclusive, as "letterbox" is the method to show wide content on narrow TVs
		#		Probably the bug arose as the driver actually does the same here as it would for wide content on narrow TVs (It stretches the picture to fit width)

		# TRANSLATORS: (aspect ratio policy: Fit width, cut/crop top and bottom (Maintain aspect ratio))
		policy_choices.update({"letterbox": _("Pan&scan")})

	if "nonliner" in policy_choices_raw and not "nonlinear" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right (Center 50% of picture maintain aspect, left/right 25% lose aspect heaver than on linear stretch))
		policy_choices.update({"nonliner": _("Stretch nonlinear")})
	if "nonlinear" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right (Center 50% of picture maintain aspect, left/right 25% lose aspect heaver than on linear stretch))
		policy_choices.update({"nonlinear": _("Stretch nonlinear")})

	# "auto", "bestfit" and "scale" are aliasses for the same: Stretch linear
	if "scale" in policy_choices_raw and not "auto" in policy_choices_raw and not "bestfit" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy_choices.update({"scale": _("Stretch linear")})
	if "full" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (force aspect))
		policy_choices.update({"full": _("Stretch full")})
	if "auto" in policy_choices_raw and not "bestfit" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy_choices.update({"auto": _("Stretch linear")})
	if "bestfit" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy_choices.update({"bestfit": _("Stretch linear")})

	config.av.policy_43 = ConfigSelection(choices=policy_choices, default="panscan")
	config.av.tvsystem = ConfigSelection(choices={"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default=True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default=0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default=0)
	config.av.vcrswitch = ConfigEnableDisable(default=False)

	#config.av.aspect.setValue('16:9')
	config.av.aspect.addNotifier(iAVSwitch.setAspect)
	config.av.wss.addNotifier(iAVSwitch.setWss)
	config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
	config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

	def setColorFormat(configElement):
		if config.av.videoport and config.av.videoport.value in ("YPbPr", "Scart-YPbPr"):
			iAVSwitch.setColorFormat(3)
		elif config.av.videoport and config.av.videoport.value in ("RCA"):
			iAVSwitch.setColorFormat(0)
		else:
			if getBoxType() == 'et6x00':
				map = {"cvbs": 3, "rgb": 3, "svideo": 2, "yuv": 3}
			elif getBoxType() == 'gbquad' or getBoxType() == 'gbquadplus' or getBoxType().startswith('et'):
				map = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
			else:
				map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
			iAVSwitch.setColorFormat(map[configElement.value])
	config.av.colorformat.addNotifier(setColorFormat)

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox": 6}
		iAVSwitch.setAspectRatio(map[configElement.value])

	iAVSwitch.setInput("ENCODER") # init on startup
	if (getBoxType() in ('gbquad', 'gbquadplus', 'et5x00', 'ixussone', 'ixusszero', 'axodin', 'axodinc', 'starsatlx', 'galaxym6', 'geniuse3hd', 'evoe3hd', 'axase3', 'axase3c', 'omtimussos1', 'omtimussos2', 'gb800seplus', 'gb800ueplus', 'gbultrase', 'gbultraue', 'gbultraueh', 'twinboxlcd')) or about.getModelString() == 'et6000':
		detected = False
	else:
		detected = eAVSwitch.getInstance().haveScartSwitch()

	SystemInfo["ScartSwitch"] = detected

	if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
		f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
		can_edidchecking = f.read().strip().split(" ")
		f.close()
	else:
		can_edidchecking = False

	SystemInfo["Canedidchecking"] = can_edidchecking

	if can_edidchecking:
		def setEDIDBypass(configElement):
			try:
				f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
				if configElement.value:
					f.write("00000001")
				else:
					f.write("00000000")
				f.close()
			except:
				pass
		config.av.bypass_edid_checking = ConfigYesNo(default=True)
		config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
	else:
		config.av.bypass_edid_checking = ConfigNothing()

	def setUnsupportModes(configElement):
		iAVSwitch.readPreferredModes()
		iAVSwitch.createConfig()

	config.av.edid_override.addNotifier(setUnsupportModes)

	if os.path.exists("/proc/stb/video/hdmi_colorspace"):
		f = open("/proc/stb/video/hdmi_colorspace", "r")
		have_colorspace = f.read().strip().split(" ")
		f.close()
	else:
		have_colorspace = False

	SystemInfo["havecolorspace"] = have_colorspace

	if have_colorspace:
		def setHDMIColorspace(configElement):
			try:
				f = open("/proc/stb/video/hdmi_colorspace", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		if getBoxType() in ('vusolo4k', 'vuuno4k', 'vuuno4kse', 'vuultimo4k'):
			config.av.hdmicolorspace = ConfigSelection(choices={
					"Edid(Auto)": _("Auto"),
					"Hdmi_Rgb": _("RGB"),
					"444": _("YCbCr444"),
					"422": _("YCbCr422"),
					"420": _("YCbCr420")},
					default="Edid(Auto)")
		elif getBoxType() in ('dm900', 'dm920', 'vuzero4k'):
			config.av.hdmicolorspace = ConfigSelection(choices={
					"Edid(Auto)": _("Auto"),
					"Hdmi_Rgb": _("RGB"),
					"Itu_R_BT_709": _("BT709"),
					"DVI_Full_Range_RGB": _("Full Range RGB"),
					"FCC": _("FCC 1953"),
					"Itu_R_BT_470_2_BG": _("BT470 BG"),
					"Smpte_170M": _("Smpte 170M"),
					"Smpte_240M": _("Smpte 240M"),
					"Itu_R_BT_2020_NCL": _("BT2020 NCL"),
					"Itu_R_BT_2020_CL": _("BT2020 CL"),
					"XvYCC_709": _("BT709 XvYCC"),
					"XvYCC_601": _("BT601 XvYCC")},
					default="Edid(Auto)")
		else:
			config.av.hdmicolorspace = ConfigSelection(choices={
					"auto": _("auto"),
					"rgb": _("rgb"),
					"420": _("420"),
					"422": _("422"),
					"444": _("444")},
					default="auto")
		config.av.hdmicolorspace.addNotifier(setHDMIColorspace)
	else:
		config.av.hdmicolorspace = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_colorimetry"):
		f = open("/proc/stb/video/hdmi_colorimetry", "r")
		have_colorimetry = f.read().strip().split(" ")
		f.close()
	else:
		have_colorimetry = False

	SystemInfo["havecolorimetry"] = have_colorimetry

	if have_colorimetry:
		def setHDMIColorimetry(configElement):
			sleep(0.1)
			try:
				f = open("/proc/stb/video/hdmi_colorimetry", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.hdmicolorimetry = ConfigSelection(choices={
				"auto": _("auto"),
				"bt2020ncl": _("BT 2020 NCL"),
				"bt2020cl": _("BT 2020 CL"),
				"bt709": _("BT 709")},
				default="auto")
		config.av.hdmicolorimetry.addNotifier(setHDMIColorimetry)
	else:
		config.av.hdmicolorimetry = ConfigNothing()

	if os.path.exists("/proc/stb/info/boxmode"):
		f = open("/proc/stb/info/boxmode", "r")
		have_boxmode = f.read().strip().split(" ")
		f.close()
	else:
		have_boxmode = False

	SystemInfo["haveboxmode"] = have_boxmode

	if have_boxmode:
		def setBoxmode(configElement):
			try:
				f = open("/proc/stb/info/boxmode", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.boxmode = ConfigSelection(choices={
				"12": _("enable PIP no HDR"),
				"1": _("12bit 4:2:0/4:2:2 no PIP")},
				default="12")
		config.av.boxmode.addNotifier(setBoxmode)
	else:
		config.av.boxmode = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_colordepth"):
		f = open("/proc/stb/video/hdmi_colordepth", "r")
		have_HdmiColordepth = f.read().strip().split(" ")
		f.close()
	else:
		have_HdmiColordepth = False

	SystemInfo["havehdmicolordepth"] = have_HdmiColordepth

	if have_HdmiColordepth:
		def setHdmiColordepth(configElement):
			try:
				f = open("/proc/stb/video/hdmi_colordepth", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.hdmicolordepth = ConfigSelection(choices={
				"auto": _("Auto"),
				"8bit": _("8bit"),
				"10bit": _("10bit"),
				"12bit": _("12bit")},
				default="auto")
		config.av.hdmicolordepth.addNotifier(setHdmiColordepth)
	else:
		config.av.hdmicolordepth = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_hdrtype"):
		f = open("/proc/stb/video/hdmi_hdrtype", "r")
		have_HdmiHdrType = f.read().strip().split(" ")
		f.close()
	else:
		have_HdmiHdrType = False

	SystemInfo["havehdmihdrtype"] = have_HdmiHdrType

	if have_HdmiHdrType:
		def setHdmiHdrType(configElement):
			try:
				f = open("/proc/stb/video/hdmi_hdrtype", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.hdmihdrtype = ConfigSelection(choices={
				"auto": _("Auto"),
				"dolby": _("dolby"),
				"none": _("sdr"),
				"hdr10": _("hdr10"),
				"hlg": _("hlg")},
				default="auto")
		config.av.hdmihdrtype.addNotifier(setHdmiHdrType)
	else:
		config.av.hdmihdrtype = ConfigNothing()

	if os.path.exists("/proc/stb/hdmi/hlg_support_choices"):
		f = open("/proc/stb/hdmi/hlg_support_choices", "r")
		have_HDRSupport = f.read().strip().split(" ")
		f.close()
	else:
		have_HDRSupport = False

	SystemInfo["HDRSupport"] = have_HDRSupport

	if have_HDRSupport:
		def setHlgSupport(configElement):
			open("/proc/stb/hdmi/hlg_support", "w").write(configElement.value)
		config.av.hlg_support = ConfigSelection(default="auto(EDID)",
			choices=[("auto(EDID)", _("controlled by HDMI")), ("yes", _("force enabled")), ("no", _("force disabled"))])
		config.av.hlg_support.addNotifier(setHlgSupport)

		def setHdr10Support(configElement):
			open("/proc/stb/hdmi/hdr10_support", "w").write(configElement.value)
		config.av.hdr10_support = ConfigSelection(default="auto(EDID)",
			choices=[("auto(EDID)", _("controlled by HDMI")), ("yes", _("force enabled")), ("no", _("force disabled"))])
		config.av.hdr10_support.addNotifier(setHdr10Support)

		def setDisable12Bit(configElement):
			open("/proc/stb/video/disable_12bit", "w").write(configElement.value)
		config.av.allow_12bit = ConfigSelection(default="0", choices=[("0", _("yes")), ("1", _("no"))])
		config.av.allow_12bit.addNotifier(setDisable12Bit)

		def setDisable10Bit(configElement):
			open("/proc/stb/video/disable_10bit", "w").write(configElement.value)
		config.av.allow_10bit = ConfigSelection(default="0", choices=[("0", _("yes")), ("1", _("no"))])
		config.av.allow_10bit.addNotifier(setDisable10Bit)

	if os.path.exists("/proc/stb/hdmi/audio_source"):
		f = open("/proc/stb/hdmi/audio_source", "r")
		can_audiosource = f.read().strip().split(" ")
		f.close()
	else:
		can_audiosource = False

	SystemInfo["Canaudiosource"] = can_audiosource

	if can_audiosource:
		def setAudioSource(configElement):
			try:
				f = open("/proc/stb/hdmi/audio_source", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.audio_source = ConfigSelection(choices={
				"pcm": _("PCM"),
				"spdif": _("SPDIF")},
				default="pcm")
		config.av.audio_source.addNotifier(setAudioSource)
	else:
		config.av.audio_source = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_choices"):
		f = open("/proc/stb/audio/3d_surround_choices", "r")
		can_3dsurround = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround = False

	SystemInfo["Can3DSurround"] = can_3dsurround

	if can_3dsurround:
		def set3DSurround(configElement):
			f = open("/proc/stb/audio/3d_surround", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.surround_3d = ConfigSelection(choices=choice_list, default="none")
		config.av.surround_3d.addNotifier(set3DSurround)
	else:
		config.av.surround_3d = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_speaker_position_choices"):
		f = open("/proc/stb/audio/3d_surround_speaker_position_choices", "r")
		can_3dsurround_speaker = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround_speaker = False

	SystemInfo["Can3DSpeaker"] = can_3dsurround_speaker

	if can_3dsurround_speaker:
		def set3DSurroundSpeaker(configElement):
			f = open("/proc/stb/audio/3d_surround_speaker_position", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))]
		config.av.surround_3d_speaker = ConfigSelection(choices=choice_list, default="center")
		config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)
	else:
		config.av.surround_3d_speaker = ConfigNothing()

	if os.path.exists("/proc/stb/audio/avl_choices"):
		f = open("/proc/stb/audio/avl_choices", "r")
		can_autovolume = f.read().strip().split(" ")
		f.close()
	else:
		can_autovolume = False

	SystemInfo["CanAutoVolume"] = can_autovolume

	if can_autovolume:
		def setAutoVolume(configElement):
			f = open("/proc/stb/audio/avl", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.autovolume = ConfigSelection(choices=choice_list, default="none")
		config.av.autovolume.addNotifier(setAutoVolume)
	else:
		config.av.autovolume = ConfigNothing()

	try:
		can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm", os.W_OK)
	except:
		can_pcm_multichannel = False

	SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
	if can_pcm_multichannel:
		def setPCMMultichannel(configElement):
			open("/proc/stb/audio/multichannel_pcm", "w").write(configElement.value and "enable" or "disable")
		config.av.pcm_multichannel = ConfigYesNo(default=False)
		config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

	try:
		f = open("/proc/stb/audio/ac3_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_ac3 = "downmix" in file
	except:
		can_downmix_ac3 = False
		SystemInfo["CanPcmMultichannel"] = False

	SystemInfo["CanDownmixAC3"] = can_downmix_ac3
	if can_downmix_ac3:
		def setAC3Downmix(configElement):
			f = open("/proc/stb/audio/ac3", "w")
			if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800'):
				f.write(configElement.value)
			else:
				f.write(configElement.value and "downmix" or "passthrough")
			f.close()
			if SystemInfo.get("supportPcmMultichannel", False) and not configElement.value:
				SystemInfo["CanPcmMultichannel"] = True
			else:
				SystemInfo["CanPcmMultichannel"] = False
				if can_pcm_multichannel:
					config.av.pcm_multichannel.setValue(False)
		if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800'):
			choice_list = [("downmix", _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel", _("convert to multi-channel PCM")), ("hdmi_best", _("use best / controlled by HDMI"))]
			config.av.downmix_ac3 = ConfigSelection(choices=choice_list, default="downmix")
		else:
			config.av.downmix_ac3 = ConfigYesNo(default=True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	if os.path.exists("/proc/stb/audio/ac3plus_choices"):
		f = open("/proc/stb/audio/ac3plus_choices", "r")
		can_ac3plustranscode = f.read().strip().split(" ")
		f.close()
	else:
		can_ac3plustranscode = False

	SystemInfo["CanAC3plusTranscode"] = can_ac3plustranscode

	if can_ac3plustranscode:
		def setAC3plusTranscode(configElement):
			f = open("/proc/stb/audio/ac3plus", "w")
			f.write(configElement.value)
			f.close()
		if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800'):
			choice_list = [("use_hdmi_caps", _("controlled by HDMI")), ("force_ac3", _("convert to AC3")), ("multichannel", _("convert to multi-channel PCM")), ("hdmi_best", _("use best / controlled by HDMI")), ("force_ddp", _("force AC3plus"))]
			config.av.transcodeac3plus = ConfigSelection(choices=choice_list, default="force_ac3")
		elif getBoxType() in ('gbquad4k', 'gbue4k', 'gbx34k'):
			choice_list = [("downmix", _("Downmix")), ("passthrough", _("Passthrough")), ("force_ac3", _("convert to AC3")), ("multichannel", _("convert to multi-channel PCM")), ("force_dts", _("convert to DTS"))]
			config.av.transcodeac3plus = ConfigSelection(choices=choice_list, default="force_ac3")
		else:
			choice_list = [("use_hdmi_caps", _("controlled by HDMI")), ("force_ac3", _("convert to AC3"))]
			config.av.transcodeac3plus = ConfigSelection(choices=choice_list, default="force_ac3")
		config.av.transcodeac3plus.addNotifier(setAC3plusTranscode)

	try:
		f = open("/proc/stb/audio/dtshd_choices", "r")
		file = f.read()[:-1]
		can_dtshd = f.read().strip().split(" ")
		f.close()
	except:
		can_dtshd = False

	SystemInfo["CanDTSHD"] = can_dtshd
	if can_dtshd:
		def setDTSHD(configElement):
			f = open("/proc/stb/audio/dtshd", "w")
			f.write(configElement.value)
			f.close()
		if getBoxType() in ("dm7080", "dm820"):
			choice_list = [("use_hdmi_caps", _("controlled by HDMI")), ("force_dts", _("convert to DTS"))]
			config.av.dtshd = ConfigSelection(choices=choice_list, default="use_hdmi_caps")
		else:
			choice_list = [("downmix", _("Downmix")), ("force_dts", _("convert to DTS")), ("use_hdmi_caps", _("controlled by HDMI")), ("multichannel", _("convert to multi-channel PCM")), ("hdmi_best", _("use best / controlled by HDMI"))]
			config.av.dtshd = ConfigSelection(choices=choice_list, default="downmix")
		config.av.dtshd.addNotifier(setDTSHD)

	try:
		f = open("/proc/stb/audio/wmapro_choices", "r")
		file = f.read()[:-1]
		can_wmapro = f.read().strip().split(" ")
		f.close()
	except:
		can_wmapro = False

	SystemInfo["CanWMAPRO"] = can_wmapro
	if can_wmapro:
		def setWMAPRO(configElement):
			f = open("/proc/stb/audio/wmapro", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("downmix", _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel", _("convert to multi-channel PCM")), ("hdmi_best", _("use best / controlled by HDMI"))]
		config.av.wmapro = ConfigSelection(choices=choice_list, default="downmix")
		config.av.wmapro.addNotifier(setWMAPRO)

	try:
		f = open("/proc/stb/audio/dts_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_dts = "downmix" in file
	except:
		can_downmix_dts = False

	SystemInfo["CanDownmixDTS"] = can_downmix_dts
	if can_downmix_dts:
		def setDTSDownmix(configElement):
			f = open("/proc/stb/audio/dts", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		config.av.downmix_dts = ConfigYesNo(default=True)
		config.av.downmix_dts.addNotifier(setDTSDownmix)

	try:
		f = open("/proc/stb/audio/aac_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_aac = "downmix" in file
	except:
		can_downmix_aac = False

	SystemInfo["CanDownmixAAC"] = can_downmix_aac
	if can_downmix_aac:
		def setAACDownmix(configElement):
			f = open("/proc/stb/audio/aac", "w")
			if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800', 'gbquad4k', 'gbue4k', 'gbx34k'):
				f.write(configElement.value)
			else:
				f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800'):
			choice_list = [("downmix", _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel", _("convert to multi-channel PCM")), ("hdmi_best", _("use best / controlled by HDMI"))]
			config.av.downmix_aac = ConfigSelection(choices=choice_list, default="downmix")
		elif getBoxType() in ('gbquad4k', 'gbue4k', 'gbx34k'):
			choice_list = [("downmix", _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel", _("convert to multi-channel PCM")), ("force_ac3", _("convert to AC3")), ("force_dts", _("convert to DTS")), ("use_hdmi_cacenter", _("use_hdmi_cacenter")), ("wide", _("wide")), ("extrawide", _("extrawide"))]
			config.av.downmix_aac = ConfigSelection(choices=choice_list, default="downmix")
		else:
			config.av.downmix_aac = ConfigYesNo(default=True)
		config.av.downmix_aac.addNotifier(setAACDownmix)

	try:
		f = open("/proc/stb/audio/aacplus_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_aacplus = "downmix" in file
	except:
		can_downmix_aacplus = False

	SystemInfo["CanDownmixAACPlus"] = can_downmix_aacplus
	if can_downmix_aacplus:
		def setAACDownmixPlus(configElement):
			f = open("/proc/stb/audio/aacplus", "w")
			f.write(configElement.value)
			f.close()

		choice_list = [("downmix", _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel", _("convert to multi-channel PCM")), ("force_ac3", _("convert to AC3")), ("force_dts", _("convert to DTS")), ("use_hdmi_cacenter", _("use_hdmi_cacenter")), ("wide", _("wide")), ("extrawide", _("extrawide"))]
		config.av.downmix_aacplus = ConfigSelection(choices=choice_list, default="downmix")
		config.av.downmix_aacplus.addNotifier(setAACDownmixPlus)

	if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
		f = open("/proc/stb/audio/aac_transcode_choices", "r")
		can_aactranscode = f.read().strip().split(" ")
		f.close()
	else:
		can_aactranscode = False

	SystemInfo["CanAACTranscode"] = can_aactranscode

	if can_aactranscode:
		def setAACTranscode(configElement):
			f = open("/proc/stb/audio/aac_transcode", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
		config.av.transcodeaac = ConfigSelection(choices=choice_list, default="off")
		config.av.transcodeaac.addNotifier(setAACTranscode)
	else:
		config.av.transcodeaac = ConfigNothing()

	if os.path.exists("/proc/stb/audio/btaudio"):
		f = open("/proc/stb/audio/btaudio", "r")
		can_btaudio = f.read().strip().split(" ")
		f.close()
	else:
		can_btaudio = False

	SystemInfo["CanBTAudio"] = can_btaudio

	if can_btaudio:
		def setBTAudio(configElement):
			f = open("/proc/stb/audio/btaudio", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("off", _("off")), ("on", _("on"))]
		config.av.btaudio = ConfigSelection(choices=choice_list, default="off")
		config.av.btaudio.addNotifier(setBTAudio)
	else:
		config.av.btaudio = ConfigNothing()

	if os.path.exists("/proc/stb/audio/btaudio_delay"):
		f = open("/proc/stb/audio/btaudio_delay", "r")
		can_btaudio_delay = f.read().strip().split(" ")
		f.close()
	else:
		can_btaudio_delay = False

	SystemInfo["CanBTAudioDelay"] = can_btaudio_delay

	if can_btaudio_delay:
		def setBTAudioDelay(configElement):
			f = open("/proc/stb/audio/btaudio_delay", "w")
			f.write(format(configElement.value * 90, "x"))
			f.close()
		config.av.btaudiodelay = ConfigSelectionNumber(-1000, 1000, 5, default=0)
		config.av.btaudiodelay.addNotifier(setBTAudioDelay)
	else:
		config.av.btaudiodelay = ConfigNothing()

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print("[AVSwitch] setting scaler_sharpness to: %0.8X" % myval)
				f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
				f.write("%0.8X\n" % myval)
				f.close()
				f = open("/proc/stb/vmpeg/0/pep_apply", "w")
				f.write("1")
				f.close()
			except IOError:
				print("[AVSwitch] couldn't write pep_scaler_sharpness")

		if getBoxType() in ('gbquad', 'gbquadplus'):
			config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0, 26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())

	iAVSwitch.setConfiguredMode()
示例#33
0
文件: AVSwitch.py 项目: OpenESI/Gui
def InitAVSwitch():
	if getBoxType() == 'vuduo' or getBoxType().startswith('ixuss'):	
		config.av.yuvenabled = ConfigBoolean(default=False)
	else:
		config.av.yuvenabled = ConfigBoolean(default=True)
	config.av.osd_alpha = ConfigSlider(default=255, increment = 5, limits=(20,255))
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.autores = ConfigSelection(choices={"disabled": _("Disabled"), "simple": _("Simple"), "native": _("Native"), "all": _("All resolutions"), "hd": _("only HD")}, default="disabled")
	config.av.autores_preview = NoSave(ConfigYesNo(default=False))
	config.av.autores_1080i_deinterlace = ConfigYesNo(default=False)
	choicelist = {
			"24,24": _("24p/24p"),
			"24,25": _("24p/25p"),
			"24,30": _("24p/30p"),
			"24,50": _("24p/50p"),
			"24,60": _("24p/60p"),
			"25,24": _("25p/24p"),
			"30,24": _("30p/24p"),
			"50,24": _("50p/24p"),
			"60,24": _("60p/24p"),
			"25,25": _("25p/25p"),
			"25,30": _("25p/30p"),
			"25,50": _("25p/50p"),
			"25,60": _("25p/60p"),
			"30,25": _("30p/25p"),
			"50,25": _("50p/25p"),
			"60,25": _("60p/25p"),
			"30,30": _("30p/30p"),
			"30,50": _("30p/50p"),
			"30,60": _("30p/60p"),
			"50,30": _("50p/30p"),
			"60,30": _("60p/30p"),
			"50,50": _("50p/50p"),
			"50,60": _("50p/60p"),
			"60,50": _("60p/50p"),
			"60,60": _("60p/60p")
				}  # first value <=720p , second value > 720p
	config.av.autores_24p =  ConfigSelection(choices=choicelist, default="50,24")
	config.av.autores_25p =  ConfigSelection(choices=choicelist, default="50,25")
	config.av.autores_30p =  ConfigSelection(choices=choicelist, default="60,30")
	config.av.autores_unknownres =  ConfigSelection(choices={"next": _("next higher Resolution"), "highest": _("highest Resolution")}, default="next")
	choicelist = []
	for i in range(5, 16):
		choicelist.append(("%d" % i, ngettext("%d second", "%d seconds", i) % i))
	config.av.autores_label_timeout = ConfigSelection(default = "5", choices = [("0", _("Not Shown"))] + choicelist)
	config.av.autores_delay = ConfigSelectionNumber(min = 0, max = 3000, stepwidth = 50, default = 400, wraparound = True)
	config.av.autores_deinterlace = ConfigYesNo(default=False)
	config.av.autores_sd = ConfigSelection(choices={"720p50": _("720p50"), "720p": _("720p"), "1080i50": _("1080i50"), "1080i": _("1080i")}, default="720p50")
	config.av.autores_480p24 = ConfigSelection(choices={"480p24": _("480p 24Hz"), "720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz")}, default="1080p24")
	config.av.autores_720p24 = ConfigSelection(choices={"720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz"), "1080i50": _("1080i 50Hz"), "1080i": _("1080i 60Hz")}, default="720p24")
	config.av.autores_1080p24 = ConfigSelection(choices={"1080p24": _("1080p 24Hz"), "1080p25": _("1080p 25Hz"), "1080i50": _("1080p 50Hz"), "1080i": _("1080i 60Hz")}, default="1080p24")
	config.av.autores_1080p25 = ConfigSelection(choices={"1080p25": _("1080p 25Hz"), "1080p50": _("1080p 50Hz"), "1080i50": _("1080i 50Hz")}, default="1080p25")
	config.av.autores_1080p30 = ConfigSelection(choices={"1080p30": _("1080p 30Hz"), "1080p60": _("1080p 60Hz"), "1080i": _("1080i 60Hz")}, default="1080p30")
	config.av.smart1080p = ConfigSelection(choices={"false": _("off"), "true": _("1080p50: 24p/50p/60p"), "2160p50": _("2160p50: 24p/50p/60p"), "1080i50": _("1080i50: 24p/50i/60i"), "720p50": _("720p50: 24p/50p/60p")}, default="false")
	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4:3": _("4:3"),
			"16:9": _("16:9"),
			"16:10": _("16:10"),
			"auto": _("Automatic")},
			default = "16:9")

	# Some boxes have a redundant proc entry for policy2 choices, but some don't (The choices are from a 16:9 point of view anyways)
	if os.path.exists("/proc/stb/video/policy2_choices"):
		policy2_choices_proc="/proc/stb/video/policy2_choices"
	else:
		policy2_choices_proc="/proc/stb/video/policy_choices"

	try:
		policy2_choices_raw=open(policy2_choices_proc, "r").read()
	except:
		policy2_choices_raw="letterbox"
	
	policy2_choices = {}

	if "letterbox" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
		policy2_choices.update({"letterbox": _("Letterbox")})

	if "panscan" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
		policy2_choices.update({"panscan": _("Pan&scan")})

	if "nonliner" in policy2_choices_raw and not "nonlinear" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the top/bottom (Center of picture maintains aspect, top/bottom lose aspect heaver than on linear stretch))
		policy2_choices.update({"nonliner": _("Stretch nonlinear")})
	if "nonlinear" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the top/bottom (Center of picture maintains aspect, top/bottom lose aspect heaver than on linear stretch))
		policy2_choices.update({"nonlinear": _("Stretch nonlinear")})

	if "scale" in policy2_choices_raw and not "auto" in policy2_choices_raw and not "bestfit" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy2_choices.update({"scale": _("Stretch linear")})
	if "auto" in policy2_choices_raw and not "bestfit" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy2_choices.update({"auto": _("Stretch linear")})
	if "bestfit" in policy2_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy2_choices.update({"bestfit": _("Stretch linear")})

	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default =	"letterbox")

	policy_choices_proc="/proc/stb/video/policy_choices"
	try:
		policy_choices_raw=open(policy_choices_proc, "r").read()
	except:
		policy_choices_raw="panscan"
	
	policy_choices = {}

	if "pillarbox" in policy_choices_raw and not "panscan" in policy_choices_raw:
		# Very few boxes support "pillarbox" as an alias for "panscan" (Which in fact does pillarbox)
		# So only add "pillarbox" if "panscan" is not listed in choices
		
		# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
		policy_choices.update({"pillarbox": _("Pillarbox")})

	if "panscan" in policy_choices_raw:
		# DRIVER BUG:	"panscan" in /proc actually does "pillarbox" (That's probably why an alias to it named "pillarbox" existed)!
		#		Interpret "panscan" setting with a "Pillarbox" text in order to show the correct value in GUI

		# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
		policy_choices.update({"panscan": _("Pillarbox")})

	if "letterbox" in policy_choices_raw:
		# DRIVER BUG:	"letterbox" in /proc actually does pan&scan
		#		"letterbox" and 4:3 content on 16:9 TVs is mutually exclusive, as "letterbox" is the method to show wide content on narrow TVs
		#		Probably the bug arose as the driver actually does the same here as it would for wide content on narrow TVs (It stretches the picture to fit width)
		
		# TRANSLATORS: (aspect ratio policy: Fit width, cut/crop top and bottom (Maintain aspect ratio))
		policy_choices.update({"letterbox": _("Pan&scan")})

	if "nonliner" in policy_choices_raw and not "nonlinear" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right (Center 50% of picture maintain aspect, left/right 25% lose aspect heaver than on linear stretch))
		policy_choices.update({"nonliner": _("Stretch nonlinear")})
	if "nonlinear" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right (Center 50% of picture maintain aspect, left/right 25% lose aspect heaver than on linear stretch))
		policy_choices.update({"nonlinear": _("Stretch nonlinear")})

	# "auto", "bestfit" and "scale" are aliasses for the same: Stretch linear
	if "scale" in policy_choices_raw and not "auto" in policy_choices_raw and not "bestfit" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy_choices.update({"scale": _("Stretch linear")})
	if "auto" in policy_choices_raw and not "bestfit" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy_choices.update({"auto": _("Stretch linear")})
	if "bestfit" in policy_choices_raw:
		# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching all parts of the picture with the same factor (All parts lose aspect))
		policy_choices.update({"bestfit": _("Stretch linear")})

	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "panscan")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	#config.av.aspect.setValue('16:9')
	config.av.aspect.addNotifier(iAVSwitch.setAspect)
	config.av.wss.addNotifier(iAVSwitch.setWss)
	config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
	config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

	def setColorFormat(configElement):
		if config.av.videoport and config.av.videoport.value in ("YPbPr", "Scart-YPbPr"):
			iAVSwitch.setColorFormat(3)
		elif config.av.videoport and config.av.videoport.value in ("RCA"):
			iAVSwitch.setColorFormat(0)
		else:
			if getBoxType() == 'et6x00':
				map = {"cvbs": 3, "rgb": 3, "svideo": 2, "yuv": 3}	
			elif getBoxType() == 'gbquad' or getBoxType() == 'gbquadplus' or getBoxType().startswith('et'):
				map = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
			else:
				map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
			iAVSwitch.setColorFormat(map[configElement.value])
	config.av.colorformat.addNotifier(setColorFormat)

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])

	iAVSwitch.setInput("ENCODER") # init on startup
	if (getBoxType() in ('gbquad', 'gbquadplus', 'et5x00', 'ixussone', 'ixusszero', 'axodin', 'axodinc', 'starsatlx', 'galaxym6', 'geniuse3hd', 'evoe3hd', 'axase3', 'axase3c', 'omtimussos1', 'omtimussos2', 'gb800seplus', 'gb800ueplus', 'gbultrase', 'gbultraue', 'gbultraueh' , 'twinboxlcd' )) or about.getModelString() == 'et6000':
		detected = False
	else:
		detected = eAVSwitch.getInstance().haveScartSwitch()

	SystemInfo["ScartSwitch"] = detected

	if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
		f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
		can_edidchecking = f.read().strip().split(" ")
		f.close()
	else:
		can_edidchecking = False

	SystemInfo["Canedidchecking"] = can_edidchecking

	if can_edidchecking:
		def setEDIDBypass(configElement):
			try:
				f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.bypass_edid_checking = ConfigSelection(choices={
				"00000000": _("off"),
				"00000001": _("on")},
				default = "00000001")
		config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
	else:
		config.av.bypass_edid_checking = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_colorspace"):
		f = open("/proc/stb/video/hdmi_colorspace", "r")
		have_colorspace = f.read().strip().split(" ")
		f.close()
	else:
		have_colorspace = False

	SystemInfo["havecolorspace"] = have_colorspace

	if have_colorspace:
		def setHDMIColorspace(configElement):
			try:
				f = open("/proc/stb/video/hdmi_colorspace", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		if getBoxType() in ('vusolo4k','vuuno4k','vuuno4kse','vuultimo4k'):
			config.av.hdmicolorspace = ConfigSelection(choices={
					"Edid(Auto)": _("Auto"),
					"Hdmi_Rgb": _("RGB"),
					"444": _("YCbCr444"),
					"422": _("YCbCr422"),
					"420": _("YCbCr420")},
					default = "Edid(Auto)")
		elif getBoxType() in ('dm900','dm920','vuzero4k'):
			config.av.hdmicolorspace = ConfigSelection(choices={
					"Edid(Auto)": _("Auto"),
					"Hdmi_Rgb": _("RGB"),
					"Itu_R_BT_709": _("BT709"),
					"DVI_Full_Range_RGB": _("Full Range RGB"),
					"FCC": _("FCC 1953"),
					"Itu_R_BT_470_2_BG": _("BT470 BG"),
					"Smpte_170M": _("Smpte 170M"),
					"Smpte_240M": _("Smpte 240M"),
					"Itu_R_BT_2020_NCL": _("BT2020 NCL"),
					"Itu_R_BT_2020_CL": _("BT2020 CL"),
					"XvYCC_709": _("BT709 XvYCC"),
					"XvYCC_601": _("BT601 XvYCC")},
					default = "Edid(Auto)")
		else:
			config.av.hdmicolorspace = ConfigSelection(choices={
					"auto": _("auto"),
					"rgb": _("rgb"),
					"420": _("420"),
					"422": _("422"),
					"444": _("444")},
					default = "auto")
		config.av.hdmicolorspace.addNotifier(setHDMIColorspace)
	else:
		config.av.hdmicolorspace = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_colorimetry"):
		f = open("/proc/stb/video/hdmi_colorimetry", "r")
		have_colorimetry = f.read().strip().split(" ")
		f.close()
	else:
		have_colorimetry = False

	SystemInfo["havecolorimetry"] = have_colorimetry

	if have_colorimetry:
		def setHDMIColorimetry(configElement):
			sleep(0.1)
			try:
				f = open("/proc/stb/video/hdmi_colorimetry", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.hdmicolorimetry = ConfigSelection(choices={
				"auto": _("auto"),
				"bt2020ncl": _("BT 2020 NCL"),
				"bt2020cl": _("BT 2020 CL"),
				"bt709": _("BT 709")},
				default = "auto")
		config.av.hdmicolorimetry.addNotifier(setHDMIColorimetry)
	else:
		config.av.hdmicolorimetry = ConfigNothing()

	if os.path.exists("/proc/stb/info/boxmode"):
		f = open("/proc/stb/info/boxmode", "r")
		have_boxmode = f.read().strip().split(" ")
		f.close()
	else:
		have_boxmode = False

	SystemInfo["haveboxmode"] = have_boxmode

	if have_boxmode:
		def setBoxmode(configElement):
			try:
				f = open("/proc/stb/info/boxmode", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.boxmode = ConfigSelection(choices={
				"12": _("enable PIP no HDR"),
				"1": _("12bit 4:2:0/4:2:2 no PIP")},
				default = "12")
		config.av.boxmode.addNotifier(setBoxmode)
	else:
		config.av.boxmode = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_colordepth"):
		f = open("/proc/stb/video/hdmi_colordepth", "r")
		have_HdmiColordepth = f.read().strip().split(" ")
		f.close()
	else:
		have_HdmiColordepth = False

	SystemInfo["havehdmicolordepth"] = have_HdmiColordepth

	if have_HdmiColordepth:
		def setHdmiColordepth(configElement):
			try:
				f = open("/proc/stb/video/hdmi_colordepth", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.hdmicolordepth = ConfigSelection(choices={
				"auto": _("Auto"),
				"8bit": _("8bit"),
				"10bit": _("10bit"),
				"12bit": _("12bit")},
				default = "auto")
		config.av.hdmicolordepth.addNotifier(setHdmiColordepth)
	else:
		config.av.hdmicolordepth = ConfigNothing()

	if os.path.exists("/proc/stb/hdmi/audio_source"):
		f = open("/proc/stb/hdmi/audio_source", "r")
		can_audiosource = f.read().strip().split(" ")
		f.close()
	else:
		can_audiosource = False

	SystemInfo["Canaudiosource"] = can_audiosource

	if can_audiosource:
		def setAudioSource(configElement):
			try:
				f = open("/proc/stb/hdmi/audio_source", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.audio_source = ConfigSelection(choices={
				"pcm": _("PCM"),
				"spdif": _("SPDIF")},
				default="pcm")
		config.av.audio_source.addNotifier(setAudioSource)
	else:
		config.av.audio_source = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_choices"):
		f = open("/proc/stb/audio/3d_surround_choices", "r")
		can_3dsurround = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround = False

	SystemInfo["Can3DSurround"] = can_3dsurround

	if can_3dsurround:
		def set3DSurround(configElement):
			f = open("/proc/stb/audio/3d_surround", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.surround_3d = ConfigSelection(choices = choice_list, default = "none")
		config.av.surround_3d.addNotifier(set3DSurround)
	else:
		config.av.surround_3d = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_speaker_position_choices"):
		f = open("/proc/stb/audio/3d_surround_speaker_position_choices", "r")
		can_3dsurround_speaker = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround_speaker = False

	SystemInfo["Can3DSpeaker"] = can_3dsurround_speaker

	if can_3dsurround_speaker:
		def set3DSurroundSpeaker(configElement):
			f = open("/proc/stb/audio/3d_surround_speaker_position", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))]
		config.av.surround_3d_speaker = ConfigSelection(choices = choice_list, default = "center")
		config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)
	else:
		config.av.surround_3d_speaker = ConfigNothing()

	if os.path.exists("/proc/stb/audio/avl_choices"):
		f = open("/proc/stb/audio/avl_choices", "r")
		can_autovolume = f.read().strip().split(" ")
		f.close()
	else:
		can_autovolume = False

	SystemInfo["CanAutoVolume"] = can_autovolume

	if can_autovolume:
		def setAutoVolume(configElement):
			f = open("/proc/stb/audio/avl", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.autovolume = ConfigSelection(choices = choice_list, default = "none")
		config.av.autovolume.addNotifier(setAutoVolume)
	else:
		config.av.autovolume = ConfigNothing()

	try:
		can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm", os.W_OK)
	except:
		can_pcm_multichannel = False

	SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
	if can_pcm_multichannel:
		def setPCMMultichannel(configElement):
			open("/proc/stb/audio/multichannel_pcm", "w").write(configElement.value and "enable" or "disable")
		config.av.pcm_multichannel = ConfigYesNo(default = False)
		config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

	def setVolumeStepsize(configElement):
		eDVBVolumecontrol.getInstance().setVolumeSteps(int(configElement.value))
	config.av.volume_stepsize = ConfigSelectionNumber(1, 10, 1, default = 5)
	config.av.volume_stepsize_fastmode = ConfigSelectionNumber(1, 10, 1, default = 5)
	config.av.volume_stepsize.addNotifier(setVolumeStepsize)

	try:
		f = open("/proc/stb/audio/ac3_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_ac3 = "downmix" in file
	except:
		can_downmix_ac3 = False
		SystemInfo["CanPcmMultichannel"] = False

	SystemInfo["CanDownmixAC3"] = can_downmix_ac3
	if can_downmix_ac3:
		def setAC3Downmix(configElement):
			f = open("/proc/stb/audio/ac3", "w")
			if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800'):
				f.write(configElement.value)
			else:
				f.write(configElement.value and "downmix" or "passthrough")
			f.close()
			if SystemInfo.get("supportPcmMultichannel", False) and not configElement.value:
				SystemInfo["CanPcmMultichannel"] = True
			else:
				SystemInfo["CanPcmMultichannel"] = False
				if can_pcm_multichannel:
					config.av.pcm_multichannel.setValue(False)
		if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800'):
			config.av.downmix_ac3 = ConfigSelection(choices = [("downmix",  _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel",  _("convert to multi-channel PCM")), ("hdmi_best",  _("use best / controlled by HDMI"))], default = "downmix")
		else:
			config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	if os.path.exists("/proc/stb/audio/ac3plus_choices"):
		f = open("/proc/stb/audio/ac3plus_choices", "r")
		can_ac3plustranscode = f.read().strip().split(" ")
		f.close()
	else:
		can_ac3plustranscode = False

	SystemInfo["CanAC3plusTranscode"] = can_ac3plustranscode

	if can_ac3plustranscode:
		def setAC3plusTranscode(configElement):
			f = open("/proc/stb/audio/ac3plus", "w")
			f.write(configElement.value)
			f.close()
		if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800'):
			choice_list = [("use_hdmi_caps", _("controlled by HDMI")), ("force_ac3", _("convert to AC3")), ("multichannel",  _("convert to multi-channel PCM")), ("hdmi_best",  _("use best / controlled by HDMI")), ("force_ddp",  _("force AC3plus"))]
			config.av.transcodeac3plus = ConfigSelection(choices = choice_list, default = "force_ac3")
		else:
			choice_list = [("use_hdmi_caps", _("controlled by HDMI")), ("force_ac3", _("convert to AC3"))]
			config.av.transcodeac3plus = ConfigSelection(choices = choice_list, default = "force_ac3")
		config.av.transcodeac3plus.addNotifier(setAC3plusTranscode)

	try:
		f = open("/proc/stb/audio/dtshd_choices", "r")
		file = f.read()[:-1]
		can_dtshd = f.read().strip().split(" ")
		f.close()
	except:
		can_dtshd = False

	SystemInfo["CanDTSHD"] = can_dtshd
	if can_dtshd:
		def setDTSHD(configElement):
			f = open("/proc/stb/audio/dtshd", "w")
			f.write(configElement.value)
			f.close()
		if getBoxType() in ("dm7080" , "dm820"):
			choice_list = [("use_hdmi_caps",  _("controlled by HDMI")), ("force_dts", _("convert to DTS"))]
			config.av.dtshd = ConfigSelection(choices = choice_list, default = "use_hdmi_caps")
		else:
			choice_list = [("downmix",  _("Downmix")), ("force_dts", _("convert to DTS")), ("use_hdmi_caps",  _("controlled by HDMI")), ("multichannel",  _("convert to multi-channel PCM")), ("hdmi_best",  _("use best / controlled by HDMI"))]
			config.av.dtshd = ConfigSelection(choices = choice_list, default = "downmix")
		config.av.dtshd.addNotifier(setDTSHD)

	try:
		f = open("/proc/stb/audio/wmapro_choices", "r")
		file = f.read()[:-1]
		can_wmapro = f.read().strip().split(" ")
		f.close()
	except:
		can_wmapro = False

	SystemInfo["CanWMAPRO"] = can_wmapro
	if can_wmapro:
		def setWMAPRO(configElement):
			f = open("/proc/stb/audio/wmapro", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("downmix",  _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel",  _("convert to multi-channel PCM")), ("hdmi_best",  _("use best / controlled by HDMI"))]
		config.av.wmapro = ConfigSelection(choices = choice_list, default = "downmix")
		config.av.wmapro.addNotifier(setWMAPRO)

	try:
		f = open("/proc/stb/audio/dts_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_dts = "downmix" in file
	except:
		can_downmix_dts = False

	SystemInfo["CanDownmixDTS"] = can_downmix_dts
	if can_downmix_dts:
		def setDTSDownmix(configElement):
			f = open("/proc/stb/audio/dts", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		config.av.downmix_dts = ConfigYesNo(default = True)
		config.av.downmix_dts.addNotifier(setDTSDownmix)

	try:
		f = open("/proc/stb/audio/aac_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_aac = "downmix" in file
	except:
		can_downmix_aac = False

	SystemInfo["CanDownmixAAC"] = can_downmix_aac
	if can_downmix_aac:
		def setAACDownmix(configElement):
			f = open("/proc/stb/audio/aac", "w")
			if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800'):
				f.write(configElement.value)
			else:
				f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		if getBoxType() in ('dm900', 'dm920', 'dm7080', 'dm800'):
			choice_list = [("downmix",  _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel",  _("convert to multi-channel PCM")), ("hdmi_best",  _("use best / controlled by HDMI"))]
			config.av.downmix_aac = ConfigSelection(choices = choice_list, default = "downmix")
		else:
			config.av.downmix_aac = ConfigYesNo(default = True)
		config.av.downmix_aac.addNotifier(setAACDownmix)

	if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
		f = open("/proc/stb/audio/aac_transcode_choices", "r")
		can_aactranscode = f.read().strip().split(" ")
		f.close()
	else:
		can_aactranscode = False

	SystemInfo["CanAACTranscode"] = can_aactranscode

	if can_aactranscode:
		def setAACTranscode(configElement):
			f = open("/proc/stb/audio/aac_transcode", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
		config.av.transcodeaac = ConfigSelection(choices = choice_list, default = "off")
		config.av.transcodeaac.addNotifier(setAACTranscode)
	else:
		config.av.transcodeaac = ConfigNothing()

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print "[VideoMode] setting scaler_sharpness to: %0.8X" % myval
				f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
				f.write("%0.8X\n" % myval)
				f.close()
				f = open("/proc/stb/vmpeg/0/pep_apply", "w")
				f.write("1")
				f.close()
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		if getBoxType() in ('gbquad', 'gbquadplus'):
			config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0,26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())

	config.av.edid_override = ConfigYesNo(default = False)

	iAVSwitch.setConfiguredMode()
示例#34
0
def InitAVSwitch():
    try:
        x = config.av
    except AttributeError:
        config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=False)
    colorformat_choices = {
        "cvbs": _("CVBS"),
        "rgb": _("RGB"),
        "svideo": _("S-Video")
    }

    try:
        have_analog_output = open("/proc/stb/video/mode_choices",
                                  "r").read()[:-1].find("PAL") != -1
    except:
        have_analog_output = False

    SystemInfo["AnalogOutput"] = have_analog_output

    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value and have_analog_output:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="rgb")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="4_3_letterbox")

    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigOnOff(default=True)
    config.av.vcrswitch = ConfigOnOff(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    try:
        have_analog_output = open("/proc/stb/video/mode_choices",
                                  "r").read()[:-1].find("PAL") != -1
    except:
        have_analog_output = False

    SystemInfo["AnalogOutput"] = have_analog_output

    if have_analog_output:
        # this will call the "setup-val" initial
        config.av.colorformat.addNotifier(setColorFormat)
        config.av.aspectratio.addNotifier(setAspectRatio)
        config.av.tvsystem.addNotifier(setSystem)
        config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()
示例#35
0
 def setAspectWSS(self, aspect = None):
     if not config.av.wss.value:
         value = 2
     else:
         value = 1
     eAVSwitch.getInstance().setWSS(value)
示例#36
0
def InitAVSwitch():
    config.av = ConfigSubsection()
    if model == "vuduo" or getBoxBrand() == "ixuss":
        config.av.yuvenabled = ConfigBoolean(default=False)
    else:
        config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {"cvbs": _("CVBS")}

    # when YUV, Scart or S-Video is not support by HW, don't let the user select it
    if SystemInfo["HasYPbPr"]:
        colorformat_choices["yuv"] = _("YPbPr")
    if SystemInfo["HasScart"]:
        colorformat_choices["rgb"] = _("RGB")
    if SystemInfo["HasSVideo"]:
        colorformat_choices["svideo"] = _("S-Video")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="cvbs")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4_3": _("4:3"),
        "16_9": _("16:9"),
        "16_10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="auto")
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: scale as close to fullscreen as possible)
        "scale": _("Just scale")
    }
    try:
        print("[AVSwitch] Read /proc/stb/video/policy2_choices")
        if "full" in open("/proc/stb/video/policy2_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if the content aspect ratio does not match the screen ratio)
            policy2_choices.update({"full": _("Full screen")})
    except:
        print("[AVSwitch] Read /proc/stb/video/policy2_choices failed.")
    try:
        print("[AVSwitch] Read /proc/stb/video/policy2_choices")
        if "auto" in open("/proc/stb/video/policy2_choices").read():
            # TRANSLATORS: (aspect ratio policy: automatically select the best aspect ratio mode)
            policy2_choices.update({"auto": _("Auto")})
    except:
        print("[AVSwitch] Read /proc/stb/video/policy2_choices failed.")
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="scale")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "pillarbox": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: scale as close to fullscreen as possible)
        "scale": _("Just scale")
    }
    try:
        print("[AVSwitch] Read /proc/stb/video/policy_choices")
        if "nonlinear" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
            policy_choices.update({"nonlinear": _("Nonlinear")})
    except:
        print("[AVSwitch] Read /proc/stb/video/policy_choices failed.")
    try:
        print("[AVSwitch] Read /proc/stb/video/policy_choices")
        if "full" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if the content aspect ratio does not match the screen ratio)
            policy_choices.update({"full": _("Full screen")})
    except:
        print("[AVSwitch] Read /proc/stb/video/policy_choices failed.")
    try:
        print("[AVSwitch] Read /proc/stb/video/policy_choices")
        if "auto" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: automatically select the best aspect ratio mode)
            policy_choices.update({"auto": _("Auto")})
    except:
        print("[AVSwitch] Read /proc/stb/video/policy_choices failed.")
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="scale")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        if model == "et6x00":
            map = {"cvbs": 3, "rgb": 3, "svideo": 2, "yuv": 3}
        elif platform == "gb7356" or model.startswith('et'):
            map = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
        else:
            map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    # this will call the "setup-val" initial
    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    if platform == "gb7356" or model in (
            "et5x00", "et6x00", "ixussone", "ixusszero", "axodin", "axase3",
            "optimussos1", "optimussos2", "gb800seplus", "gb800ueplus",
            "gbultrase", "gbultraue", "gbultraueh", "twinboxlcd"):
        detected = False
    else:
        detected = eAVSwitch.getInstance().haveScartSwitch()

    SystemInfo["ScartSwitch"] = detected

    if SystemInfo["CanDownmixAC3"]:

        def setAC3Downmix(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/ac3")
            if SystemInfo["DreamBoxAudio"]:
                open("/proc/stb/audio/ac3", "w").write(configElement.value)
            else:
                open("/proc/stb/audio/ac3",
                     "w").write(configElement.value and "downmix"
                                or "passthrough")

        if SystemInfo["DreamBoxAudio"]:
            choice_list = [("downmix", _("Downmix")),
                           ("passthrough", _("Passthrough")),
                           ("multichannel", _("convert to multi-channel PCM")),
                           ("hdmi_best", _("use best / controlled by HDMI"))]
            config.av.downmix_ac3 = ConfigSelection(choices=choice_list,
                                                    default="downmix")
        else:
            config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    if SystemInfo["CanAC3plusTranscode"]:

        def setAC3plusTranscode(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/ac3plus")
            open("/proc/stb/audio/ac3plus", "w").write(configElement.value)

        if SystemInfo["DreamBoxAudio"]:
            choice_list = [("use_hdmi_caps", _("controlled by HDMI")),
                           ("force_ac3", _("convert to AC3")),
                           ("multichannel", _("convert to multi-channel PCM")),
                           ("hdmi_best", _("use best / controlled by HDMI")),
                           ("force_ddp", _("force AC3plus"))]
            config.av.transcodeac3plus = ConfigSelection(choices=choice_list,
                                                         default="force_ac3")
        elif platform in ("gb7252", "gb72604"):
            choice_list = [("downmix", _("Downmix")),
                           ("passthrough", _("Passthrough")),
                           ("force_ac3", _("convert to AC3")),
                           ("multichannel", _("convert to multi-channel PCM")),
                           ("force_dts", _("convert to DTS"))]
            config.av.transcodeac3plus = ConfigSelection(choices=choice_list,
                                                         default="force_ac3")
        else:
            choice_list = [("use_hdmi_caps", _("controlled by HDMI")),
                           ("force_ac3", _("convert to AC3"))]
            config.av.transcodeac3plus = ConfigSelection(choices=choice_list,
                                                         default="force_ac3")
        config.av.transcodeac3plus.addNotifier(setAC3plusTranscode)

    if SystemInfo["CanDownmixDTS"]:

        def setDTSDownmix(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/dts")
            open("/proc/stb/audio/dts",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_dts = ConfigYesNo(default=True)
        config.av.downmix_dts.addNotifier(setDTSDownmix)

    if SystemInfo["CanDTSHD"]:

        def setDTSHD(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/dtshd")
            open("/proc/stb/audio/dtshd", "w").write(configElement.value)

        if model in ("dm7080", "dm820"):
            choice_list = [("use_hdmi_caps", _("controlled by HDMI")),
                           ("force_dts", _("convert to DTS"))]
            config.av.dtshd = ConfigSelection(choices=choice_list,
                                              default="use_hdmi_caps")
        else:
            choice_list = [("downmix", _("Downmix")),
                           ("force_dts", _("convert to DTS")),
                           ("use_hdmi_caps", _("controlled by HDMI")),
                           ("multichannel", _("convert to multi-channel PCM")),
                           ("hdmi_best", _("use best / controlled by HDMI"))]
            config.av.dtshd = ConfigSelection(choices=choice_list,
                                              default="downmix")
        config.av.dtshd.addNotifier(setDTSHD)

    if SystemInfo["CanWMAPRO"]:

        def setWMAPRO(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/wmapro")
            open("/proc/stb/audio/wmapro", "w").write(configElement.value)

        choice_list = [("downmix", _("Downmix")),
                       ("passthrough", _("Passthrough")),
                       ("multichannel", _("convert to multi-channel PCM")),
                       ("hdmi_best", _("use best / controlled by HDMI"))]
        config.av.wmapro = ConfigSelection(choices=choice_list,
                                           default="downmix")
        config.av.wmapro.addNotifier(setWMAPRO)

    if SystemInfo["CanDownmixAAC"]:

        def setAACDownmix(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/aac")
            if SystemInfo["DreamBoxAudio"] or platform in ("gb7252",
                                                           "gb72604"):
                open("/proc/stb/audio/aac", "w").write(configElement.value)
            else:
                open("/proc/stb/audio/aac",
                     "w").write(configElement.value and "downmix"
                                or "passthrough")

        if SystemInfo["DreamBoxAudio"]:
            choice_list = [("downmix", _("Downmix")),
                           ("passthrough", _("Passthrough")),
                           ("multichannel", _("convert to multi-channel PCM")),
                           ("hdmi_best", _("use best / controlled by HDMI"))]
            config.av.downmix_aac = ConfigSelection(choices=choice_list,
                                                    default="downmix")
        elif platform in ("gb7252", "gb72604"):
            choice_list = [("downmix", _("Downmix")),
                           ("passthrough", _("Passthrough")),
                           ("multichannel", _("convert to multi-channel PCM")),
                           ("force_ac3", _("convert to AC3")),
                           ("force_dts", _("convert to DTS")),
                           ("use_hdmi_cacenter", _("use_hdmi_cacenter")),
                           ("wide", _("wide")), ("extrawide", _("extrawide"))]
            config.av.downmix_aac = ConfigSelection(choices=choice_list,
                                                    default="downmix")
        else:
            config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    if SystemInfo["CanDownmixAACPlus"]:

        def setAACDownmixPlus(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/aacplus")
            open("/proc/stb/audio/aacplus", "w").write(configElement.value)

        choice_list = [("downmix", _("Downmix")),
                       ("passthrough", _("Passthrough")),
                       ("multichannel", _("convert to multi-channel PCM")),
                       ("force_ac3", _("convert to AC3")),
                       ("force_dts", _("convert to DTS")),
                       ("use_hdmi_cacenter", _("use_hdmi_cacenter")),
                       ("wide", _("wide")), ("extrawide", _("extrawide"))]
        config.av.downmix_aacplus = ConfigSelection(choices=choice_list,
                                                    default="downmix")
        config.av.downmix_aacplus.addNotifier(setAACDownmixPlus)

    if SystemInfo["CanAACTranscode"]:

        def setAACTranscode(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/aac_transcode")
            open("/proc/stb/audio/aac_transcode",
                 "w").write(configElement.value)

        choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
        config.av.transcodeaac = ConfigSelection(choices=choice_list,
                                                 default="off")
        config.av.transcodeaac.addNotifier(setAACTranscode)
    else:
        config.av.transcodeaac = ConfigNothing()

    if SystemInfo["CanBTAudio"]:

        def setBTAudio(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/btaudio")
            open("/proc/stb/audio/btaudio", "w").write(configElement.value)

        choice_list = [("off", _("off")), ("on", _("on"))]
        config.av.btaudio = ConfigSelection(choices=choice_list, default="off")
        config.av.btaudio.addNotifier(setBTAudio)
    else:
        config.av.btaudio = ConfigNothing()

    if SystemInfo["CanBTAudioDelay"]:

        def setBTAudioDelay(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/btaudio_delay")
            open("/proc/stb/audio/btaudio_delay",
                 "w").write(format(configElement.value * 90))

        config.av.btaudiodelay = ConfigSelectionNumber(-1000,
                                                       1000,
                                                       5,
                                                       default=0)
        config.av.btaudiodelay.addNotifier(setBTAudioDelay)
    else:
        config.av.btaudiodelay = ConfigNothing()

    if SystemInfo["CanChangeOsdAlpha"]:

        def setAlpha(config):
            print("[AVSwitch] Write to /proc/stb/video/alpha")
            open("/proc/stb/video/alpha", "w").write(str(config.value))

        config.av.osd_alpha = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if SystemInfo["ScalerSharpness"]:

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print("--> setting scaler_sharpness to: %0.8X" % myval)
                print(
                    "[AVSwitch] Write to /proc/stb/vmpeg/0/pep_scaler_sharpness"
                )
                open("/proc/stb/vmpeg/0/pep_scaler_sharpness",
                     "w").write("%0.8X" % myval)
                print("[AVSwitch] Write to /proc/stb/vmpeg/0/pep_apply")
                open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
            except IOError:
                print("[AVSwitch] couldn't write pep_scaler_sharpness")

        if platform == "gb7356":
            config.av.scaler_sharpness = ConfigSlider(default=5,
                                                      limits=(0, 26))
        else:
            config.av.scaler_sharpness = ConfigSlider(default=13,
                                                      limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    if SystemInfo["HasMultichannelPCM"]:

        def setMultichannelPCM(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/multichannel_pcm")
            open(SystemInfo["HasMultichannelPCM"],
                 "w").write(configElement.value and "enable" or "disable")

        config.av.multichannel_pcm = ConfigYesNo(default=False)
        config.av.multichannel_pcm.addNotifier(setMultichannelPCM)

    if SystemInfo["HasAutoVolume"]:

        def setAutoVolume(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/avl")
            open("/proc/stb/audio/avl", "w").write(configElement.value)

        config.av.autovolume = ConfigSelection(default="none",
                                               choices=[("none", _("off")),
                                                        ("hdmi", _("HDMI")),
                                                        ("spdif", _("SPDIF")),
                                                        ("dac", _("DAC"))])
        config.av.autovolume.addNotifier(setAutoVolume)

    if SystemInfo["HasAutoVolumeLevel"]:

        def setAutoVolumeLevel(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/autovolumelevel")
            open("/proc/stb/audio/autovolumelevel",
                 "w").write(configElement.value and "enabled" or "disabled")

        config.av.autovolumelevel = ConfigYesNo(default=False)
        config.av.autovolumelevel.addNotifier(setAutoVolumeLevel)

    if SystemInfo["Has3DSurround"]:

        def set3DSurround(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/3d_surround")
            open("/proc/stb/audio/3d_surround", "w").write(configElement.value)

        config.av.surround_3d = ConfigSelection(default="none",
                                                choices=[("none", _("off")),
                                                         ("hdmi", _("HDMI")),
                                                         ("spdif", _("SPDIF")),
                                                         ("dac", _("DAC"))])
        config.av.surround_3d.addNotifier(set3DSurround)

    if SystemInfo["Has3DSpeaker"]:

        def set3DSpeaker(configElement):
            print(
                "[AVSwitch] Write to /proc/stb/audio/3d_surround_speaker_position"
            )
            open("/proc/stb/audio/3d_surround_speaker_position",
                 "w").write(configElement.value)

        config.av.speaker_3d = ConfigSelection(default="center",
                                               choices=[("center",
                                                         _("center")),
                                                        ("wide", _("wide")),
                                                        ("extrawide",
                                                         _("extra wide"))])
        config.av.speaker_3d.addNotifier(set3DSpeaker)

    if SystemInfo["Has3DSurroundSpeaker"]:

        def set3DSurroundSpeaker(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/3dsurround")
            open("/proc/stb/audio/3dsurround", "w").write(configElement.value)

        config.av.surround_3d_speaker = ConfigSelection(
            default="disabled",
            choices=[("disabled", _("off")), ("center", _("center")),
                     ("wide", _("wide")), ("extrawide", _("extra wide"))])
        config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)

    if SystemInfo["Has3DSurroundSoftLimiter"]:

        def set3DSurroundSoftLimiter(configElement):
            print("[AVSwitch] Write to /proc/stb/audio/3dsurround_softlimiter")
            open("/proc/stb/audio/3dsurround_softlimiter",
                 "w").write(configElement.value and "enabled" or "disabled")

        config.av.surround_softlimiter_3d = ConfigYesNo(default=False)
        config.av.surround_softlimiter_3d.addNotifier(set3DSurroundSoftLimiter)

    if SystemInfo["HDMIAudioSource"]:

        def setHDMIAudioSource(configElement):
            print("[AVSwitch] Write to /proc/stb/hdmi/audio_source")
            open(SystemInfo["HDMIAudioSource"], "w").write(configElement.value)

        config.av.hdmi_audio_source = ConfigSelection(default="pcm",
                                                      choices=[
                                                          ("pcm", _("PCM")),
                                                          ("spdif", _("SPDIF"))
                                                      ])
        config.av.hdmi_audio_source.addNotifier(setHDMIAudioSource)

    def setVolumeStepsize(configElement):
        eDVBVolumecontrol.getInstance().setVolumeSteps(int(
            configElement.value))

    config.av.volume_stepsize = ConfigSelectionNumber(1, 10, 1, default=5)
    config.av.volume_stepsize.addNotifier(setVolumeStepsize)
示例#37
0
def InitAVSwitch():
	config.av = ConfigSubsection()
	config.av.yuvenabled = ConfigBoolean(default=True)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}

	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.getValue():
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4_3": _("4:3"),
			"16_9": _("16:9"),
			"16_10": _("16:10"),
			"auto": _("Automatic")},
			default = "auto")
	policy2_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
	"letterbox": _("Letterbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy2_choices"):
		f = open("/proc/stb/video/policy2_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy2_choices.update({"auto": _("Auto")})
		f.close()	
	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default = "letterbox")
	policy_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
	"pillarbox": _("Pillarbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
	"nonlinear": _("Nonlinear"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy_choices"):
		f = open("/proc/stb/video/policy_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy_choices.update({"auto": _("Auto")})
		f.close()
	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "pillarbox")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	iAVSwitch = AVSwitch()

	def setColorFormat(configElement):
		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		iAVSwitch.setColorFormat(map[configElement.getValue()])

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.getValue()])

	def setSystem(configElement):
		map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
		iAVSwitch.setSystem(map[configElement.getValue()])

	def setWSS(configElement):
		iAVSwitch.setAspectWSS()
	
	config.av.colorformat.addNotifier(setColorFormat)
	if not os.path.exists('/usr/lib/enigma2/python/Plugins/SystemPlugins/Videomode/VideoHardware.pyo'):
		# this will call the "setup-val" initial
		config.av.aspectratio.addNotifier(setAspectRatio)
		config.av.tvsystem.addNotifier(setSystem)
		config.av.wss.addNotifier(setWSS)
	
	iAVSwitch.setInput("ENCODER") # init on startup
	SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

	if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
		f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
		can_edidchecking = f.read().strip().split(" ")
		f.close()
	else:
		can_edidchecking = False

	SystemInfo["Canedidchecking"] = can_edidchecking

	if can_edidchecking:
		def setEDIDBypass(configElement):
			try:
				f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.bypass_edid_checking = ConfigSelection(choices={
				"00000000": _("off"),
				"00000001": _("on")},
				default = "00000000")
		config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
	else:
		config.av.bypass_edid_checking = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_choices"):
		f = open("/proc/stb/audio/3d_surround_choices", "r")
		can_3dsurround = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround = False

	SystemInfo["Can3DSurround"] = can_3dsurround

	if can_3dsurround:
		def set3DSurround(configElement):
			f = open("/proc/stb/audio/3d_surround", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.surround_3d = ConfigSelection(choices = choice_list, default = "none")
		config.av.surround_3d.addNotifier(set3DSurround)
	else:
		config.av.surround_3d = ConfigNothing()

	try:
		f = open("/proc/stb/audio/ac3_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix = file.find("downmix") != -1
	except:
		can_downmix = False

	SystemInfo["CanDownmixAC3"] = can_downmix
	if can_downmix:
		def setAC3Downmix(configElement):
			f = open("/proc/stb/audio/ac3", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.getValue())
			try:
				print "--> setting scaler_sharpness to: %0.8X" % myval
				f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
				f.write("%0.8X" % myval)
				f.close()
				f = open("/proc/stb/vmpeg/0/pep_apply", "w")
				f.write("1")
				f.close()
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		if getBoxType() == 'gbquad':
			config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0,26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())
示例#38
0
def InitAVSwitch():
    config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {
        "cvbs": _("CVBS"),
        "rgb": _("RGB"),
        "svideo": _("S-Video")
    }

    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="rgb")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4_3": _("4:3"),
        "16_9": _("16:9"),
        "16_10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="auto")
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "scale": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy2_choices") and "auto" in open(
            "/proc/stb/video/policy2_choices").readline():
        # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
        policy2_choices.update({"auto": _("Auto")})
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="letterbox")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "pillarbox": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
        "nonlinear": _("Nonlinear"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "scale": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy_choices") and "auto" in open(
            "/proc/stb/video/policy_choices").readline():
        # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
        policy_choices.update({"auto": _("Auto")})
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="pillarbox")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        if getBoxType() == 'gbquad' or getBoxType() == 'gbquadplus':
            map = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
        else:
            map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    # this will call the "setup-val" initial
    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    if (getBoxType()
            in ('gbquad', 'gbquadplus', 'gb800seplus', 'gb800ueplus')):
        detected = False
    else:
        detected = eAVSwitch.getInstance().haveScartSwitch()

    SystemInfo["ScartSwitch"] = detected

    if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
        f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
        can_edidchecking = f.read().strip().split(" ")
        f.close()
    else:
        can_edidchecking = False

    SystemInfo["Canedidchecking"] = can_edidchecking

    if can_edidchecking:

        def setEDIDBypass(configElement):
            try:
                f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.bypass_edid_checking = ConfigSelection(choices={
            "00000000": _("off"),
            "00000001": _("on")
        },
                                                         default="00000000")
        config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
    else:
        config.av.bypass_edid_checking = ConfigNothing()

    if os.path.exists("/proc/stb/audio/3d_surround_choices"):
        f = open("/proc/stb/audio/3d_surround_choices", "r")
        can_3dsurround = f.read().strip().split(" ")
        f.close()
    else:
        can_3dsurround = False

    SystemInfo["Can3DSurround"] = can_3dsurround

    if can_3dsurround:

        def set3DSurround(configElement):
            f = open("/proc/stb/audio/3d_surround", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.surround_3d = ConfigSelection(choices=choice_list,
                                                default="none")
        config.av.surround_3d.addNotifier(set3DSurround)
    else:
        config.av.surround_3d = ConfigNothing()

    if os.path.exists("/proc/stb/audio/avl_choices"):
        f = open("/proc/stb/audio/avl_choices", "r")
        can_autovolume = f.read().strip().split(" ")
        f.close()
    else:
        can_autovolume = False

    SystemInfo["CanAutoVolume"] = can_autovolume

    if can_autovolume:

        def setAutoVulume(configElement):
            f = open("/proc/stb/audio/avl", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.autovolume = ConfigSelection(choices=choice_list,
                                               default="none")
        config.av.autovolume.addNotifier(setAutoVulume)
    else:
        config.av.autovolume = ConfigNothing()

    try:
        can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm",
                                         os.W_OK)
    except:
        can_pcm_multichannel = False

    SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
    if can_pcm_multichannel:

        def setPCMMultichannel(configElement):
            open("/proc/stb/audio/multichannel_pcm",
                 "w").write(configElement.value and "enable" or "disable")

        config.av.pcm_multichannel = ConfigYesNo(default=False)
        config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

    try:
        f = open("/proc/stb/audio/ac3_choices", "r")
        file = f.read()[:-1]
        f.close()
        can_downmix_ac3 = "downmix" in file
    except:
        can_downmix_ac3 = False

    SystemInfo["CanDownmixAC3"] = can_downmix_ac3
    if can_downmix_ac3:

        def setAC3Downmix(configElement):
            f = open("/proc/stb/audio/ac3", "w")
            f.write(configElement.value and "downmix" or "passthrough")
            f.close()
            if SystemInfo.get("supportPcmMultichannel",
                              False) and not configElement.value:
                SystemInfo["CanPcmMultichannel"] = True
            else:
                SystemInfo["CanPcmMultichannel"] = False
                if can_pcm_multichannel:
                    config.av.pcm_multichannel.setValue(False)

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    try:
        f = open("/proc/stb/audio/aac_choices", "r")
        file = f.read()[:-1]
        f.close()
        can_downmix_aac = "downmix" in file
    except:
        can_downmix_aac = False

    SystemInfo["CanDownmixAAC"] = can_downmix_aac
    if can_downmix_aac:

        def setAACDownmix(configElement):
            f = open("/proc/stb/audio/aac", "w")
            f.write(configElement.value and "downmix" or "passthrough")
            f.close()

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
        f = open("/proc/stb/audio/aac_transcode_choices", "r")
        can_aactranscode = f.read().strip().split(" ")
        f.close()
    else:
        can_aactranscode = False

    SystemInfo["CanAACTranscode"] = can_aactranscode

    if can_aactranscode:

        def setAACTranscode(configElement):
            f = open("/proc/stb/audio/aac_transcode", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
        config.av.transcodeaac = ConfigSelection(choices=choice_list,
                                                 default="off")
        config.av.transcodeaac.addNotifier(setAACTranscode)
    else:
        config.av.transcodeaac = ConfigNothing()

    try:
        can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
    except:
        can_osd_alpha = False

    SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha

    def setAlpha(config):
        open("/proc/stb/video/alpha", "w").write(str(config.value))

    if can_osd_alpha:
        config.av.osd_alpha = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "[VideoMode] setting scaler_sharpness to: %0.8X" % myval
                f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
                f.write("%0.8X" % myval)
                f.close()
                f = open("/proc/stb/vmpeg/0/pep_apply", "w")
                f.write("1")
                f.close()
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        if getBoxType() in ('gbquad', 'gbquadplus'):
            config.av.scaler_sharpness = ConfigSlider(default=5,
                                                      limits=(0, 26))
        else:
            config.av.scaler_sharpness = ConfigSlider(default=13,
                                                      limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    config.av.edid_override = ConfigYesNo(default=False)
示例#39
0
	def updateDeinterlace(self, cfgelement):
		print "-> update deinterlace !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		eAVSwitch.getInstance().setDeinterlace(int(config.av.deinterlace.value), int(config.av.deinterlace_sd.value), int(config.av.deinterlace_hd.value))
示例#40
0
def InitAVSwitch():
    config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {
        "cvbs": _("CVBS"),
        "rgb": _("RGB"),
        "svideo": _("S-Video")
    }
    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.autores = ConfigSelection(choices={
        "disabled": _("Disabled"),
        "all": _("All resolutions"),
        "hd": _("only HD")
    },
                                        default="disabled")
    choicelist = []
    for i in range(5, 16):
        choicelist.append(
            ("%d" % i, ngettext("%d second", "%d seconds", i) % i))
    config.av.autores_label_timeout = ConfigSelection(
        default="5", choices=[("0", _("Not Shown"))] + choicelist)
    config.av.autores_delay = ConfigSelectionNumber(min=0,
                                                    max=15000,
                                                    stepwidth=500,
                                                    default=500,
                                                    wraparound=True)
    config.av.autores_deinterlace = ConfigYesNo(default=False)
    config.av.autores_sd = ConfigSelection(choices={
        "720p": _("720p"),
        "1080i": _("1080i")
    },
                                           default="720p")
    config.av.autores_480p24 = ConfigSelection(choices={
        "480p24": _("480p 24Hz"),
        "720p24": _("720p 24Hz"),
        "1080p24": _("1080p 24Hz")
    },
                                               default="1080p24")
    config.av.autores_720p24 = ConfigSelection(choices={
        "720p24": _("720p 24Hz"),
        "1080p24": _("1080p 24Hz")
    },
                                               default="1080p24")
    config.av.autores_1080p24 = ConfigSelection(choices={
        "1080p24": _("1080p 24Hz"),
        "1080p25": _("1080p 25Hz")
    },
                                                default="1080p24")
    config.av.autores_1080p25 = ConfigSelection(choices={
        "1080p25": _("1080p 25Hz"),
        "1080p50": _("1080p 50Hz")
    },
                                                default="1080p25")
    config.av.autores_1080p30 = ConfigSelection(choices={
        "1080p30": _("1080p 30Hz"),
        "1080p60": _("1080p 60Hz")
    },
                                                default="1080p30")
    config.av.autores_2160p24 = ConfigSelection(choices={
        "2160p24": _("2160p 24Hz"),
        "2160p25": _("2160p 25Hz")
    },
                                                default="2160p24")
    config.av.autores_2160p25 = ConfigSelection(choices={
        "2160p25": _("2160p 25Hz"),
        "2160p50": _("2160p 50Hz")
    },
                                                default="2160p25")
    config.av.autores_2160p30 = ConfigSelection(choices={
        "2160p30": _("2160p 30Hz"),
        "2160p60": _("2160p 60Hz")
    },
                                                default="2160p30")
    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="rgb")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4:3": _("4:3"),
        "16:9": _("16:9"),
        "16:10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="16:9")
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "scale": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy2_choices"):
        f = open("/proc/stb/video/policy2_choices")
        if "auto" in f.readline():
            # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
            policy2_choices.update({"auto": _("Auto")})
        f.close()
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="letterbox")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "panscan": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "letterbox": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
        # "nonlinear": _("Nonlinear"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "bestfit": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy_choices"):
        f = open("/proc/stb/video/policy_choices")
        if "auto" in f.readline():
            # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
            policy_choices.update({"auto": _("Auto")})
        f.close()
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="panscan")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    config.av.aspect.setValue('16:9')
    config.av.aspect.addNotifier(iAVSwitch.setAspect)
    config.av.wss.addNotifier(iAVSwitch.setWss)
    config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
    config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

    def setColorFormat(configElement):
        if config.av.videoport and config.av.videoport.value in (
                "YPbPr", "Scart-YPbPr"):
            iAVSwitch.setColorFormat(3)
        elif config.av.videoport and config.av.videoport.value in ("RCA"):
            iAVSwitch.setColorFormat(0)
        else:
            map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
            iAVSwitch.setColorFormat(map[configElement.value])

    config.av.colorformat.addNotifier(setColorFormat)

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    iAVSwitch.setInput("ENCODER")  # init on startup
    SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

    if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
        f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
        can_edidchecking = f.read().strip().split(" ")
        f.close()
    else:
        can_edidchecking = False

    SystemInfo["Canedidchecking"] = can_edidchecking

    if can_edidchecking:

        def setEDIDBypass(configElement):
            try:
                f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.bypass_edid_checking = ConfigSelection(choices={
            "00000000": _("off"),
            "00000001": _("on")
        },
                                                         default="00000000")
        config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
    else:
        config.av.bypass_edid_checking = ConfigNothing()

    if os.path.exists("/proc/stb/video/hdmi_colorspace"):
        f = open("/proc/stb/video/hdmi_colorspace", "r")
        have_colorspace = f.read().strip().split(" ")
        f.close()
    else:
        have_colorspace = False

    SystemInfo["havecolorspace"] = have_colorspace

    if have_colorspace:

        def setHDMIColorspace(configElement):
            try:
                f = open("/proc/stb/video/hdmi_colorspace", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        if getBoxType() in ('vusolo4k', 'vuuno4k', 'vuultimo4k'):
            config.av.hdmicolorspace = ConfigSelection(choices={
                "Edid(Auto)": _("Auto"),
                "Hdmi_Rgb": _("RGB"),
                "444": _("YCbCr444"),
                "422": _("YCbCr422"),
                "420": _("YCbCr420")
            },
                                                       default="Edid(Auto)")
        else:
            config.av.hdmicolorspace = ConfigSelection(choices={
                "auto": _("auto"),
                "rgb": _("rgb"),
                "420": _("420"),
                "422": _("422"),
                "444": _("444")
            },
                                                       default="auto")
        config.av.hdmicolorspace.addNotifier(setHDMIColorspace)
    else:
        config.av.hdmicolorspace = ConfigNothing()

    if os.path.exists("/proc/stb/video/hdmi_colorimetry"):
        f = open("/proc/stb/video/hdmi_colorimetry", "r")
        have_colorimetry = f.read().strip().split(" ")
        f.close()
    else:
        have_colorimetry = False

    SystemInfo["havecolorimetry"] = have_colorimetry

    if have_colorimetry:

        def setHDMIColorimetry(configElement):
            try:
                f = open("/proc/stb/video/hdmi_colorimetry", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.hdmicolorimetry = ConfigSelection(choices={
            "Auto":
            _("Auto"),
            "bt2020ncl":
            _("BT 2020 NCL"),
            "bt2020cl":
            _("BT 2020 CL"),
            "bt709":
            _("BT 709")
        },
                                                    default="Auto")
        config.av.hdmicolorimetry.addNotifier(setHDMIColorimetry)
    else:
        config.av.hdmicolorimetry = ConfigNothing()

    if os.path.exists("/proc/stb/info/boxmode"):
        f = open("/proc/stb/info/boxmode", "r")
        have_boxmode = f.read().strip().split(" ")
        f.close()
    else:
        have_boxmode = False

    SystemInfo["haveboxmode"] = have_boxmode

    if have_boxmode:

        def setBoxmode(configElement):
            try:
                f = open("/proc/stb/info/boxmode", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.boxmode = ConfigSelection(choices={
            "12":
            _("PIP enabled, no HDR"),
            "1":
            _("HDR, 12bit 4:2:0/4:2:2, no PIP")
        },
                                            default="12")
        config.av.boxmode.addNotifier(setBoxmode)
    else:
        config.av.boxmode = ConfigNothing()

    if os.path.exists("/proc/stb/video/hdmi_colordepth"):
        f = open("/proc/stb/video/hdmi_colordepth", "r")
        have_HdmiColordepth = f.read().strip().split(" ")
        f.close()
    else:
        have_HdmiColordepth = False

    SystemInfo["havehdmicolordepth"] = have_HdmiColordepth

    if have_HdmiColordepth:

        def setHdmiColordepth(configElement):
            try:
                f = open("/proc/stb/video/hdmi_colordepth", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.hdmicolordepth = ConfigSelection(choices={
            "auto": _("Auto"),
            "8bit": _("8bit"),
            "10bit": _("10bit"),
            "12bit": _("12bit")
        },
                                                   default="auto")
        config.av.hdmicolordepth.addNotifier(setHdmiColordepth)
    else:
        config.av.hdmicolordepth = ConfigNothing()

    if os.path.exists("/proc/stb/hdmi/audio_source"):
        f = open("/proc/stb/hdmi/audio_source", "r")
        can_audiosource = f.read().strip().split(" ")
        f.close()
    else:
        can_audiosource = False

    SystemInfo["Canaudiosource"] = can_audiosource

    if can_audiosource:

        def setAudioSource(configElement):
            try:
                f = open("/proc/stb/hdmi/audio_source", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.audio_source = ConfigSelection(choices={
            "pcm": _("PCM"),
            "spdif": _("SPDIF")
        },
                                                 default="pcm")
        config.av.audio_source.addNotifier(setAudioSource)
    else:
        config.av.audio_source = ConfigNothing()

    if os.path.exists("/proc/stb/audio/3d_surround_choices"):
        f = open("/proc/stb/audio/3d_surround_choices", "r")
        can_3dsurround = f.read().strip().split(" ")
        f.close()
    else:
        can_3dsurround = False

    SystemInfo["Can3DSurround"] = can_3dsurround

    if can_3dsurround:

        def set3DSurround(configElement):
            f = open("/proc/stb/audio/3d_surround", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.surround_3d = ConfigSelection(choices=choice_list,
                                                default="none")
        config.av.surround_3d.addNotifier(set3DSurround)
    else:
        config.av.surround_3d = ConfigNothing()

    if os.path.exists("/proc/stb/audio/3d_surround_speaker_position_choices"):
        f = open("/proc/stb/audio/3d_surround_speaker_position_choices", "r")
        can_3dsurround_speaker = f.read().strip().split(" ")
        f.close()
    else:
        can_3dsurround_speaker = False

    SystemInfo["Can3DSpeaker"] = can_3dsurround_speaker

    if can_3dsurround_speaker:

        def set3DSurroundSpeaker(configElement):
            f = open("/proc/stb/audio/3d_surround_speaker_position", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("center", _("center")), ("wide", _("wide")),
                       ("extrawide", _("extra wide"))]
        config.av.surround_3d_speaker = ConfigSelection(choices=choice_list,
                                                        default="center")
        config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)
    else:
        config.av.surround_3d_speaker = ConfigNothing()

    if os.path.exists("/proc/stb/audio/avl_choices"):
        f = open("/proc/stb/audio/avl_choices", "r")
        can_autovolume = f.read().strip().split(" ")
        f.close()
    else:
        can_autovolume = False

    SystemInfo["CanAutoVolume"] = can_autovolume

    if can_autovolume:

        def setAutoVolume(configElement):
            f = open("/proc/stb/audio/avl", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.autovolume = ConfigSelection(choices=choice_list,
                                               default="none")
        config.av.autovolume.addNotifier(setAutoVolume)
    else:
        config.av.autovolume = ConfigNothing()

    try:
        can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm",
                                         os.W_OK)
    except:
        can_pcm_multichannel = False

    SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
    if can_pcm_multichannel:

        def setPCMMultichannel(configElement):
            open("/proc/stb/audio/multichannel_pcm",
                 "w").write(configElement.value and "enable" or "disable")

        config.av.pcm_multichannel = ConfigYesNo(default=False)
        config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

    try:
        f = open("/proc/stb/audio/ac3_choices", "r")
        file = f.read()[:-1]
        f.close()
        can_downmix_ac3 = "downmix" in file
    except:
        can_downmix_ac3 = False

    SystemInfo["CanDownmixAC3"] = can_downmix_ac3
    if can_downmix_ac3:

        def setAC3Downmix(configElement):
            f = open("/proc/stb/audio/ac3", "w")
            f.write(configElement.value and "downmix" or "passthrough")
            f.close()
            if SystemInfo.get("supportPcmMultichannel",
                              False) and not configElement.value:
                SystemInfo["CanPcmMultichannel"] = True
            else:
                SystemInfo["CanPcmMultichannel"] = False
                if can_pcm_multichannel:
                    config.av.pcm_multichannel.setValue(False)

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    try:
        f = open("/proc/stb/audio/dts_choices", "r")
        file = f.read()[:-1]
        f.close()
        can_downmix_dts = "downmix" in file
    except:
        can_downmix_dts = False

    SystemInfo["CanDownmixDTS"] = can_downmix_dts
    if can_downmix_dts:

        def setDTSDownmix(configElement):
            f = open("/proc/stb/audio/dts", "w")
            f.write(configElement.value and "downmix" or "passthrough")
            f.close()

        config.av.downmix_dts = ConfigYesNo(default=True)
        config.av.downmix_dts.addNotifier(setDTSDownmix)

    try:
        f = open("/proc/stb/audio/aac_choices", "r")
        file = f.read()[:-1]
        f.close()
        can_downmix_aac = "downmix" in file
    except:
        can_downmix_aac = False

    SystemInfo["CanDownmixAAC"] = can_downmix_aac
    if can_downmix_aac:

        def setAACDownmix(configElement):
            f = open("/proc/stb/audio/aac", "w")
            f.write(configElement.value and "downmix" or "passthrough")
            f.close()

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
        f = open("/proc/stb/audio/aac_transcode_choices", "r")
        can_aactranscode = f.read().strip().split(" ")
        f.close()
    else:
        can_aactranscode = False

    SystemInfo["CanAACTranscode"] = can_aactranscode

    if can_aactranscode:

        def setAACTranscode(configElement):
            f = open("/proc/stb/audio/aac_transcode", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
        config.av.transcodeaac = ConfigSelection(choices=choice_list,
                                                 default="off")
        config.av.transcodeaac.addNotifier(setAACTranscode)
    else:
        config.av.transcodeaac = ConfigNothing()

    if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "[VideoHardware] setting scaler_sharpness to: %0.8X" % myval
                f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
                f.write("%0.8X" % myval)
                f.close()
                f = open("/proc/stb/vmpeg/0/pep_apply", "w")
                f.write("1")
                f.close()
            except IOError:
                print "[VideoHardware] couldn't write pep_scaler_sharpness"

        if getBoxType() in ('gbquad', 'gbquadplus'):
            config.av.scaler_sharpness = ConfigSlider(default=5,
                                                      limits=(0, 26))
        else:
            config.av.scaler_sharpness = ConfigSlider(default=13,
                                                      limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    config.av.edid_override = ConfigYesNo(default=False)

    iAVSwitch.setConfiguredMode()
示例#41
0
	def updateBufMetronom(self, cfgelement):
		print "-> update Prebuffer Metronom !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		eAVSwitch.getInstance().setBufMetronom(int(config.pc.prebuffer_metronom_hd.value), int(config.pc.prebuffer_metronom_sd.value))
示例#42
0
def InitAVSwitch():
    config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {"cvbs": _("CVBS")}

    # when YUV, Scart or S-Video is not support by HW, don't let the user select it
    if SystemInfo["HasYPbPr"]:
        colorformat_choices["yuv"] = _("YPbPr")
    if SystemInfo["HasScart"]:
        colorformat_choices["rgb"] = _("RGB")
    if SystemInfo["HasSVideo"]:
        colorformat_choices["svideo"] = _("S-Video")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="cvbs")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4_3": _("4:3"),
        "16_9": _("16:9"),
        "16_10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="auto")
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: scale as close to fullscreen as possible)
        "scale": _("Just scale")
    }
    try:
        if "full" in open("/proc/stb/video/policy2_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if the content aspect ratio does not match the screen ratio)
            policy2_choices.update({"full": _("Full screen")})
    except:
        pass
    try:
        if "auto" in open("/proc/stb/video/policy2_choices").read():
            # TRANSLATORS: (aspect ratio policy: automatically select the best aspect ratio mode)
            policy2_choices.update({"auto": _("Auto")})
    except:
        pass
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="letterbox")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "pillarbox": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
        "nonlinear": _("Nonlinear"),
        # TRANSLATORS: (aspect ratio policy: scale as close to fullscreen as possible)
        "scale": _("Just scale")
    }
    try:
        if "full" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if the content aspect ratio does not match the screen ratio)
            policy_choices.update({"full": _("Full screen")})
    except:
        pass
    try:
        if "auto" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: automatically select the best aspect ratio mode)
            policy_choices.update({"auto": _("Auto")})
    except:
        pass
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="pillarbox")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    # this will call the "setup-val" initial
    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

    try:
        SystemInfo["CanDownmixAC3"] = "downmix" in open(
            "/proc/stb/audio/ac3_choices", "r").read()
    except:
        SystemInfo["CanDownmixAC3"] = False

    if SystemInfo["CanDownmixAC3"]:

        def setAC3Downmix(configElement):
            open("/proc/stb/audio/ac3",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    try:
        SystemInfo["CanDownmixDTS"] = "downmix" in open(
            "/proc/stb/audio/dts_choices", "r").read()
    except:
        SystemInfo["CanDownmixDTS"] = False

    if SystemInfo["CanDownmixDTS"]:

        def setDTSDownmix(configElement):
            open("/proc/stb/audio/dts",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_dts = ConfigYesNo(default=True)
        config.av.downmix_dts.addNotifier(setDTSDownmix)

    try:
        SystemInfo["CanDownmixAAC"] = "downmix" in open(
            "/proc/stb/audio/aac_choices", "r").read()
    except:
        SystemInfo["CanDownmixAAC"] = False

    if SystemInfo["CanDownmixAAC"]:

        def setAACDownmix(configElement):
            open("/proc/stb/audio/aac",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    try:
        SystemInfo["CanChangeOsdAlpha"] = open("/proc/stb/video/alpha",
                                               "r") and True or False
    except:
        SystemInfo["CanChangeOsdAlpha"] = False

    if SystemInfo["CanChangeOsdAlpha"]:

        def setAlpha(config):
            open("/proc/stb/video/alpha", "w").write(str(config.value))

        config.av.osd_alpha = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "--> setting scaler_sharpness to: %0.8X" % myval
                open("/proc/stb/vmpeg/0/pep_scaler_sharpness",
                     "w").write("%0.8X" % myval)
                open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    if SystemInfo["HasMultichannelPCM"]:

        def setMultichannelPCM(configElement):
            open(SystemInfo["HasMultichannelPCM"],
                 "w").write(configElement.value and "enable" or "disable")

        config.av.multichannel_pcm = ConfigYesNo(default=False)
        config.av.multichannel_pcm.addNotifier(setMultichannelPCM)

    def setVolumeStepsize(configElement):
        eDVBVolumecontrol.getInstance().setVolumeSteps(int(
            configElement.value))

    config.av.volume_stepsize = ConfigSelectionNumber(1, 10, 1, default=2)
    config.av.volume_stepsize.addNotifier(setVolumeStepsize)
示例#43
0
文件: AVSwitch.py 项目: TitanNit/tdt
def InitAVSwitch():
	config.av = ConfigSubsection()
	config.av.yuvenabled = ConfigBoolean(default=False)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
	
	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"), 
			"16_9": _("16:9"), 
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"), 
			"16_9_letterbox": _("16:9 Letterbox")}, 
			default = "4_3_letterbox")

	config.av.aspect = ConfigSelection(choices={
			"4_3": _("4:3"),
			"16_9": _("16:9"), 
			"16_10": _("16:10"),
			"auto": _("Automatic")},
			default = "auto")
	config.av.policy_169 = ConfigSelection(choices={
				# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
			"letterbox": _("Letterbox"), 
				# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
			"panscan": _("Pan&Scan"),  
				# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
			"scale": _("Just Scale")},
			default = "letterbox")
	config.av.policy_43 = ConfigSelection(choices={
				# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
			"pillarbox": _("Pillarbox"), 
				# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
			"panscan": _("Pan&Scan"),  
				# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
			"nonlinear": _("Nonlinear"),  
				# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
			"scale": _("Just Scale")},
			default = "pillarbox")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.defaultac3 = ConfigYesNo(default = False)
	config.av.generalAC3delay = ConfigNumber(default = 0)
	config.av.generalPCMdelay = ConfigNumber(default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	iAVSwitch = AVSwitch()

	def setColorFormat(configElement):
		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		iAVSwitch.setColorFormat(map[configElement.value])

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])

	def setSystem(configElement):
		map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
		iAVSwitch.setSystem(map[configElement.value])

	def setWSS(configElement):
		iAVSwitch.setAspectWSS()

	# this will call the "setup-val" initial
	config.av.colorformat.addNotifier(setColorFormat)
	config.av.aspectratio.addNotifier(setAspectRatio)
	config.av.tvsystem.addNotifier(setSystem)
	config.av.wss.addNotifier(setWSS)

	iAVSwitch.setInput("ENCODER") # init on startup
	SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

	try:
		can_downmix = open("/proc/stb/audio/ac3_choices", "r").read()[:-1].find("downmix") != -1
	except:
		can_downmix = False

	SystemInfo["CanDownmixAC3"] = can_downmix
	if can_downmix:
		def setAC3Downmix(configElement):
			open("/proc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	try:
		can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
	except:
		can_osd_alpha = False

	SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha

	def setAlpha(config):
		open("/proc/stb/video/alpha", "w").write(str(config.value))

	if can_osd_alpha:
		config.av.osd_alpha = ConfigSlider(default=255, limits=(0,255))
		config.av.osd_alpha.addNotifier(setAlpha)
示例#44
0
def InitAVSwitch():
	if getBoxType() == 'vuduo' or getBoxType().startswith('ixuss'):	
		config.av.yuvenabled = ConfigBoolean(default=False)
	else:	
		config.av.yuvenabled = ConfigBoolean(default=True)
	config.av.osd_alpha = ConfigSlider(default=255, increment = 5, limits=(20,255)) # Make openATV compatible with some plugins who still use config.av.osd_alpha
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.autores = ConfigSelection(choices={"disabled": _("Disabled"), "all": _("All resolutions"), "hd": _("only HD")}, default="disabled")
	choicelist = []
	for i in range(5, 16):
		choicelist.append(("%d" % i, ngettext("%d second", "%d seconds", i) % i))
	config.av.autores_label_timeout = ConfigSelection(default = "5", choices = [("0", _("Not Shown"))] + choicelist)
	config.av.autores_delay = ConfigSelectionNumber(min = 50, max = 3000, stepwidth = 50, default = 400, wraparound = True)
	config.av.autores_deinterlace = ConfigYesNo(default=False)
	config.av.autores_sd = ConfigSelection(choices={"720p50": _("720p50"), "720p": _("720p"), "1080i50": _("1080i50"), "1080i": _("1080i")}, default="720p50")
	config.av.autores_480p24 = ConfigSelection(choices={"480p24": _("480p 24Hz"), "720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz")}, default="1080p24")
	config.av.autores_720p24 = ConfigSelection(choices={"720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz"), "1080i50": _("1080i 50Hz"), "1080i": _("1080i 60Hz")}, default="720p24")
	config.av.autores_1080p24 = ConfigSelection(choices={"1080p24": _("1080p 24Hz"), "1080p25": _("1080p 25Hz"), "1080i50": _("1080p 50Hz"), "1080i": _("1080i 60Hz")}, default="1080p24")
	config.av.autores_1080p25 = ConfigSelection(choices={"1080p25": _("1080p 25Hz"), "1080p50": _("1080p 50Hz"), "1080i50": _("1080i 50Hz")}, default="1080p25")
	config.av.autores_1080p30 = ConfigSelection(choices={"1080p30": _("1080p 30Hz"), "1080p60": _("1080p 60Hz"), "1080i": _("1080i 60Hz")}, default="1080p30")
	config.av.smart1080p = ConfigSelection(choices={"false": _("off"), "true": _("1080p50: 24p/50p/60p"), "2160p50": _("2160p50: 24p/50p/60p"), "1080i50": _("1080i50: 24p/50i/60i"), "720p50": _("720p50: 24p/50p/60p")}, default="false")
	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4:3": _("4:3"),
			"16:9": _("16:9"),
			"16:10": _("16:10"),
			"auto": _("Automatic")},
			default = "16:9")
	policy2_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
	"letterbox": _("Letterbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy2_choices"):
		f = open("/proc/stb/video/policy2_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy2_choices.update({"auto": _("Auto")})
		f.close()	
	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default = "letterbox")
	policy_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
	"panscan": _("Pillarbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"letterbox": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
	# "nonlinear": _("Nonlinear"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"bestfit": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy_choices"):
		f = open("/proc/stb/video/policy_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy_choices.update({"auto": _("Auto")})
		f.close()
	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "panscan")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	#config.av.aspect.setValue('16:9')
	config.av.aspect.addNotifier(iAVSwitch.setAspect)
	config.av.wss.addNotifier(iAVSwitch.setWss)
	config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
	config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

	def setColorFormat(configElement):
		if config.av.videoport and config.av.videoport.value in ("YPbPr", "Scart-YPbPr"):
			iAVSwitch.setColorFormat(3)
		elif config.av.videoport and config.av.videoport.value in ("RCA"):
			iAVSwitch.setColorFormat(0)
		else:
			if getBoxType() == 'et6x00':
				map = {"cvbs": 3, "rgb": 3, "svideo": 2, "yuv": 3}	
			elif getBoxType() == 'gbquad' or getBoxType() == 'gbquadplus' or getBoxType().startswith('et'):
				map = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
			else:
				map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
			iAVSwitch.setColorFormat(map[configElement.value])
	config.av.colorformat.addNotifier(setColorFormat)

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])
	
	iAVSwitch.setInput("ENCODER") # init on startup
	if (getBoxType() in ('gbquad', 'gbquadplus', 'et5x00', 'ixussone', 'ixusszero', 'axodin', 'axodinc', 'starsatlx', 'galaxym6', 'geniuse3hd', 'evoe3hd', 'axase3', 'axase3c', 'omtimussos1', 'omtimussos2', 'gb800seplus', 'gb800ueplus', 'gbultrase', 'gbultraue' , 'twinboxlcd' )) or about.getModelString() == 'et6000':
		detected = False
	else:
		detected = eAVSwitch.getInstance().haveScartSwitch()
	
	SystemInfo["ScartSwitch"] = detected

	if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
		f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
		can_edidchecking = f.read().strip().split(" ")
		f.close()
	else:
		can_edidchecking = False

	SystemInfo["Canedidchecking"] = can_edidchecking

	if can_edidchecking:
		def setEDIDBypass(configElement):
			try:
				f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.bypass_edid_checking = ConfigSelection(choices={
				"00000000": _("off"),
				"00000001": _("on")},
				default = "00000001")
		config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
	else:
		config.av.bypass_edid_checking = ConfigNothing()

	if os.path.exists("/proc/stb/video/hdmi_colorspace"):
		f = open("/proc/stb/video/hdmi_colorspace", "r")
		have_colorspace = f.read().strip().split(" ")
		f.close()
	else:
		have_colorspace = False

	SystemInfo["havecolorspace"] = have_colorspace

	if have_colorspace:
		def setHDMIColorspace(configElement):
			try:
				f = open("/proc/stb/video/hdmi_colorspace", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.hdmicolorspace = ConfigSelection(choices={
				"Edid(Auto)": _("Auto"),
				"Hdmi_Rgb": _("RGB")},
				default = "Edid(Auto)")
		config.av.hdmicolorspace.addNotifier(setHDMIColorspace)
	else:
		config.av.hdmicolorspace = ConfigNothing()

	if os.path.exists("/proc/stb/hdmi/audio_source"):
		f = open("/proc/stb/hdmi/audio_source", "r")
		can_audiosource = f.read().strip().split(" ")
		f.close()
	else:
		can_audiosource = False

	SystemInfo["Canaudiosource"] = can_audiosource

	if can_audiosource:
		def setAudioSource(configElement):
			try:
				f = open("/proc/stb/hdmi/audio_source", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.audio_source = ConfigSelection(choices={
				"pcm": _("PCM"),
				"spdif": _("SPDIF")},
				default="pcm")
		config.av.audio_source.addNotifier(setAudioSource)
	else:
		config.av.audio_source = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_choices"):
		f = open("/proc/stb/audio/3d_surround_choices", "r")
		can_3dsurround = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround = False

	SystemInfo["Can3DSurround"] = can_3dsurround

	if can_3dsurround:
		def set3DSurround(configElement):
			f = open("/proc/stb/audio/3d_surround", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.surround_3d = ConfigSelection(choices = choice_list, default = "none")
		config.av.surround_3d.addNotifier(set3DSurround)
	else:
		config.av.surround_3d = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_speaker_position_choices"):
		f = open("/proc/stb/audio/3d_surround_speaker_position_choices", "r")
		can_3dsurround_speaker = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround_speaker = False

	SystemInfo["Can3DSpeaker"] = can_3dsurround_speaker

	if can_3dsurround_speaker:
		def set3DSurroundSpeaker(configElement):
			f = open("/proc/stb/audio/3d_surround_speaker_position", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))]
		config.av.surround_3d_speaker = ConfigSelection(choices = choice_list, default = "center")
		config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)
	else:
		config.av.surround_3d_speaker = ConfigNothing()

	if os.path.exists("/proc/stb/audio/avl_choices"):
		f = open("/proc/stb/audio/avl_choices", "r")
		can_autovolume = f.read().strip().split(" ")
		f.close()
	else:
		can_autovolume = False

	SystemInfo["CanAutoVolume"] = can_autovolume

	if can_autovolume:
		def setAutoVolume(configElement):
			f = open("/proc/stb/audio/avl", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.autovolume = ConfigSelection(choices = choice_list, default = "none")
		config.av.autovolume.addNotifier(setAutoVolume)
	else:
		config.av.autovolume = ConfigNothing()

	try:
		can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm", os.W_OK)
	except:
		can_pcm_multichannel = False

	SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
	if can_pcm_multichannel:
		def setPCMMultichannel(configElement):
			open("/proc/stb/audio/multichannel_pcm", "w").write(configElement.value and "enable" or "disable")
		config.av.pcm_multichannel = ConfigYesNo(default = False)
		config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

	try:
		f = open("/proc/stb/audio/ac3_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_ac3 = "downmix" in file
	except:
		can_downmix_ac3 = False
		SystemInfo["CanPcmMultichannel"] = False

	SystemInfo["CanDownmixAC3"] = can_downmix_ac3
	if can_downmix_ac3:
		def setAC3Downmix(configElement):
			f = open("/proc/stb/audio/ac3", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
			if SystemInfo.get("supportPcmMultichannel", False) and not configElement.value:
				SystemInfo["CanPcmMultichannel"] = True
			else:
				SystemInfo["CanPcmMultichannel"] = False
				if can_pcm_multichannel:
					config.av.pcm_multichannel.setValue(False)
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	try:
		f = open("/proc/stb/audio/aac_choices", "r")
		file = f.read()[:-1]
		f.close()
		can_downmix_aac = "downmix" in file
	except:
		can_downmix_aac = False

	SystemInfo["CanDownmixAAC"] = can_downmix_aac
	if can_downmix_aac:
		def setAACDownmix(configElement):
			f = open("/proc/stb/audio/aac", "w")
			f.write(configElement.value and "downmix" or "passthrough")
			f.close()
		config.av.downmix_aac = ConfigYesNo(default = True)
		config.av.downmix_aac.addNotifier(setAACDownmix)

	if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
		f = open("/proc/stb/audio/aac_transcode_choices", "r")
		can_aactranscode = f.read().strip().split(" ")
		f.close()
	else:
		can_aactranscode = False

	SystemInfo["CanAACTranscode"] = can_aactranscode

	if can_aactranscode:
		def setAACTranscode(configElement):
			f = open("/proc/stb/audio/aac_transcode", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
		config.av.transcodeaac = ConfigSelection(choices = choice_list, default = "off")
		config.av.transcodeaac.addNotifier(setAACTranscode)
	else:
		config.av.transcodeaac = ConfigNothing()

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print "[VideoMode] setting scaler_sharpness to: %0.8X" % myval
				f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
				f.write("%0.8X" % myval)
				f.close()
				f = open("/proc/stb/vmpeg/0/pep_apply", "w")
				f.write("1")
				f.close()
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		if getBoxType() in ('gbquad', 'gbquadplus'):
			config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0,26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())

	config.av.edid_override = ConfigYesNo(default = False)

	iAVSwitch.setConfiguredMode()
示例#45
0
文件: AVSwitch.py 项目: kajgan/e2
def InitAVSwitch():
	config.av = ConfigSubsection()
	config.av.yuvenabled = ConfigBoolean(default=True)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}

	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4_3": _("4:3"),
			"16_9": _("16:9"),
			"16_10": _("16:10"),
			"auto": _("Automatic")},
			default = "auto")
	policy2_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
	"letterbox": _("Letterbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	try:
		if "auto" in open("/proc/stb/video/policy2_choices").read():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy2_choices.update({"auto": _("Auto")})
	except:
		pass
	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default = "letterbox")
	policy_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
	"pillarbox": _("Pillarbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
	"nonlinear": _("Nonlinear"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	try:
		if "auto" in open("/proc/stb/video/policy_choices").read():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy_choices.update({"auto": _("Auto")})
	except:
		pass
	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "pillarbox")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	iAVSwitch = AVSwitch()

	def setColorFormat(configElement):
		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		iAVSwitch.setColorFormat(map[configElement.value])

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])

	def setSystem(configElement):
		map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
		iAVSwitch.setSystem(map[configElement.value])

	def setWSS(configElement):
		iAVSwitch.setAspectWSS()

	# this will call the "setup-val" initial
	config.av.colorformat.addNotifier(setColorFormat)
	config.av.aspectratio.addNotifier(setAspectRatio)
	config.av.tvsystem.addNotifier(setSystem)
	config.av.wss.addNotifier(setWSS)

	iAVSwitch.setInput("ENCODER") # init on startup
	if getBoxType() in ('gbquad', 'gbquadplus', 'gb800seplus', 'gb800ueplus', 'gbipbox', 'gbultra', 'gbultraue', 'gbultrase', 'spycat', 'gbx1', 'gbx3'):
		detected = False
	else:
		detected = eAVSwitch.getInstance().haveScartSwitch()
	
	SystemInfo["ScartSwitch"] = detected

	if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
		f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
		can_edidchecking = f.read().strip().split(" ")
		f.close()
	else:
		can_edidchecking = False

	SystemInfo["Canedidchecking"] = can_edidchecking

	if can_edidchecking:
		def setEDIDBypass(configElement):
			try:
				f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.bypass_edid_checking = ConfigSelection(choices={
				"00000000": _("off"),
				"00000001": _("on")},
				default = "00000000")
		config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
	else:
		config.av.bypass_edid_checking = ConfigNothing()

	if os.path.exists("/proc/stb/audio/3d_surround_choices"):
		f = open("/proc/stb/audio/3d_surround_choices", "r")
		can_3dsurround = f.read().strip().split(" ")
		f.close()
	else:
		can_3dsurround = False

	SystemInfo["Can3DSurround"] = can_3dsurround

	if can_3dsurround:
		def set3DSurround(configElement):
			f = open("/proc/stb/audio/3d_surround", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.surround_3d = ConfigSelection(choices = choice_list, default = "none")
		config.av.surround_3d.addNotifier(set3DSurround)
	else:
		config.av.surround_3d = ConfigNothing()
		
	if os.path.exists("/proc/stb/audio/avl_choices"):
		f = open("/proc/stb/audio/avl_choices", "r")
		can_autovolume = f.read().strip().split(" ")
		f.close()
	else:
		can_autovolume = False

	SystemInfo["CanAutoVolume"] = can_autovolume

	if can_autovolume:
		def setAutoVulume(configElement):
			f = open("/proc/stb/audio/avl", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		config.av.autovolume = ConfigSelection(choices = choice_list, default = "none")
		config.av.autovolume.addNotifier(setAutoVulume)
	else:
		config.av.autovolume = ConfigNothing()

	try:
		can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm", os.W_OK)
	except:
		can_pcm_multichannel = False

	SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
	if can_pcm_multichannel:
		def setPCMMultichannel(configElement):
			open("/proc/stb/audio/multichannel_pcm", "w").write(configElement.value and "enable" or "disable")
		config.av.pcm_multichannel = ConfigYesNo(default = False)
		config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

	try:
		SystemInfo["CanDownmixAC3"] = "downmix" in open("/proc/stb/audio/ac3_choices", "r").read()
	except:
		SystemInfo["CanDownmixAC3"] = False

	if SystemInfo["CanDownmixAC3"]:
		def setAC3Downmix(configElement):
			open("/proc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough")
			if SystemInfo.get("supportPcmMultichannel", False) and not configElement.value:
				SystemInfo["CanPcmMultichannel"] = True
			else:
				SystemInfo["CanPcmMultichannel"] = False
				if can_pcm_multichannel:
					config.av.pcm_multichannel.setValue(False)
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	try:
		SystemInfo["CanDownmixDTS"] = "downmix" in open("/proc/stb/audio/dts_choices", "r").read()
	except:
		SystemInfo["CanDownmixDTS"] = False

	if SystemInfo["CanDownmixDTS"]:
		def setDTSDownmix(configElement):
			open("/proc/stb/audio/dts", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_dts = ConfigYesNo(default = True)
		config.av.downmix_dts.addNotifier(setDTSDownmix)

	try:
		SystemInfo["CanDownmixAAC"] = "downmix" in open("/proc/stb/audio/aac_choices", "r").read()
	except:
		SystemInfo["CanDownmixAAC"] = False

	if SystemInfo["CanDownmixAAC"]:
		def setAACDownmix(configElement):
			open("/proc/stb/audio/aac", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_aac = ConfigYesNo(default = True)
		config.av.downmix_aac.addNotifier(setAACDownmix)

	if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
		f = open("/proc/stb/audio/aac_transcode_choices", "r")
		can_aactranscode = f.read().strip().split(" ")
		f.close()
	else:
		can_aactranscode = False

	SystemInfo["CanAACTranscode"] = can_aactranscode

	if can_aactranscode:
		def setAACTranscode(configElement):
			f = open("/proc/stb/audio/aac_transcode", "w")
			f.write(configElement.value)
			f.close()
		choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
		config.av.transcodeaac = ConfigSelection(choices = choice_list, default = "off")
		config.av.transcodeaac.addNotifier(setAACTranscode)
	else:
		config.av.transcodeaac = ConfigNothing()

	try:
		SystemInfo["CanChangeOsdAlpha"] = open("/proc/stb/video/alpha", "r") and True or False
	except:
		SystemInfo["CanChangeOsdAlpha"] = False

	if SystemInfo["CanChangeOsdAlpha"]:
		def setAlpha(config):
			open("/proc/stb/video/alpha", "w").write(str(config.value))
		config.av.osd_alpha = ConfigSlider(default=255, increment = 5, limits=(20,255))
		config.av.osd_alpha.addNotifier(setAlpha)

	if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print "--> setting scaler_sharpness to: %0.8X" % myval
				open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval)
				open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		if getBoxType() in ('gbquad', 'gbquadplus'):
			config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0,26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())

	config.av.edid_override = ConfigYesNo(default = True)
示例#46
0
	def setAspectRatio(self, value):
		eAVSwitch.getInstance().setAspectRatio(value)
示例#47
0
 def setAspectWSS(self, aspect=None):
     if not config.av.wss.value:
         value = 2  # auto(4:3_off)
     else:
         value = 1  # auto
     eAVSwitch.getInstance().setWSS(value)
示例#48
0
def InitAVSwitch():
    if getBoxType() == 'vuduo' or getBoxType().startswith('ixuss'):
        config.av.yuvenabled = ConfigBoolean(default=False)
    else:
        config.av.yuvenabled = ConfigBoolean(default=True)
    config.av.osd_alpha = ConfigSlider(
        default=255, limits=(0, 255)
    )  # Make openATV compatible with some plugins who still use config.av.osd_alpha
    colorformat_choices = {
        "cvbs": _("CVBS"),
        "rgb": _("RGB"),
        "svideo": _("S-Video")
    }
    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.autores = ConfigEnableDisable()
    choicelist = []
    for i in range(5, 16):
        choicelist.append(
            ("%d" % i, ngettext("%d second", "%d seconds", i) % i))
    config.av.autores_label_timeout = ConfigSelection(
        default="5", choices=[("0", _("Not Shown"))] + choicelist)
    config.av.autores_delay = ConfigSelectionNumber(min=500,
                                                    max=15000,
                                                    stepwidth=500,
                                                    default=1000,
                                                    wraparound=True)

    # SD - 480 / 576, standard definition
    # ED - 720, enhanced definition
    # HD - 1080, high definition

    # Supported conversions:
    #    * -> 1080i60, 720p60, 480i60, 480p60
    # *?50 -> 1080i50, 720p50, 576i50, 576p50
    # *p25 -> 1080i50, 720p50, 576i50, 576p50 (1080p25 ?)
    # *p30 -> 1080p30
    # *p24 -> 1080p24

    if iAVSwitch.supports2160p:
        conv_60 = ["2160p", "1080p", "1080i", "720p", "480p", "480i"]
        conv_50 = ["2160p50", "1080p50", "1080i50", "720p50", "576p", "576i"
                   ] + conv_60
        conv_30 = ["2160p30", "1080p30"] + conv_60
        conv_24 = ["2160p24", "1080p24"] + conv_60
    elif iAVSwitch.supports1080p:
        conv_60 = ["1080p", "1080i", "720p", "480p", "480i"]
        conv_50 = ["1080p50", "1080i50", "720p50", "576p", "576i"] + conv_60
        conv_30 = ["1080p30"] + conv_60
        conv_24 = ["1080p24"] + conv_60
    else:
        conv_60 = ["1080i", "720p", "480p", "480i"]
        conv_50 = ["1080i50", "720p50", "576p", "576i"] + conv_60
        conv_30 = ["1080p30"] + conv_60
        conv_24 = ["1080p24"] + conv_60

    config.av.autores_sd24 = ConfigSelection(choices=conv_24)
    config.av.autores_sd25 = ConfigSelection(choices=conv_50)
    config.av.autores_sd30 = ConfigSelection(choices=conv_30)
    config.av.autores_sd50i = ConfigSelection(choices=conv_50)
    config.av.autores_sd50p = ConfigSelection(choices=conv_50)
    config.av.autores_sd60i = ConfigSelection(choices=conv_60)
    config.av.autores_sd60p = ConfigSelection(choices=conv_60)
    config.av.autores_ed24 = ConfigSelection(choices=conv_24)
    config.av.autores_ed25 = ConfigSelection(choices=conv_50)
    config.av.autores_ed30 = ConfigSelection(choices=conv_30)
    config.av.autores_ed50 = ConfigSelection(choices=conv_50)
    config.av.autores_ed60 = ConfigSelection(choices=conv_60)
    config.av.autores_hd24 = ConfigSelection(choices=conv_24)
    config.av.autores_hd25 = ConfigSelection(choices=conv_50)
    config.av.autores_hd30 = ConfigSelection(choices=conv_30)
    config.av.autores_hd50 = ConfigSelection(choices=conv_50)
    config.av.autores_hd60 = ConfigSelection(choices=conv_60)
    config.av.autores_uhd24 = ConfigSelection(choices=conv_24)
    config.av.autores_uhd25 = ConfigSelection(choices=conv_50)
    config.av.autores_uhd30 = ConfigSelection(choices=conv_30)
    config.av.autores_uhd50 = ConfigSelection(choices=conv_50)
    config.av.autores_uhd60 = ConfigSelection(choices=conv_60)

    # some boxes do not support YPbPr
    try:
        config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                                default="yuv")
    except:
        config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                                default="cvbs")

    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4:3": _("4:3"),
        "16:9": _("16:9"),
        "16:10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="16:9")
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "scale": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy2_choices"):
        f = open("/proc/stb/video/policy2_choices")
        if "auto" in f.readline():
            # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
            policy2_choices.update({"auto": _("Auto")})
        f.close()
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="letterbox")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "panscan": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "letterbox": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
        # "nonlinear": _("Nonlinear"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "bestfit": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy_choices"):
        f = open("/proc/stb/video/policy_choices")
        if "auto" in f.readline():
            # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
            policy_choices.update({"auto": _("Auto")})
        f.close()
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="panscan")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    # config.av.aspect.setValue('16:9')
    config.av.aspect.addNotifier(iAVSwitch.setAspect)
    config.av.wss.addNotifier(iAVSwitch.setWss)
    config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
    config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

    def setColorFormat(configElement):
        if config.av.videoport and config.av.videoport.value in (
                "YPbPr", "Scart-YPbPr"):
            iAVSwitch.setColorFormat(3)
        elif config.av.videoport and config.av.videoport.value in ("RCA", ):
            iAVSwitch.setColorFormat(0)
        else:
            if getBoxType() == 'et6x00':
                colmap = {"cvbs": 3, "rgb": 3, "svideo": 2, "yuv": 3}
            elif getBoxType() == 'gbquad' or getBoxType(
            ) == 'gbquadplus' or getBoxType().startswith('et'):
                colmap = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
            else:
                colmap = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
            iAVSwitch.setColorFormat(colmap[configElement.value])

    config.av.colorformat.addNotifier(setColorFormat)

    def setAspectRatio(configElement):
        iAVSwitch.setAspectRatio({
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }[configElement.value])

    iAVSwitch.setInput("ENCODER")  # init on startup
    if (getBoxType() in ('gbquad', 'gbquadplus', 'et5x00', 'ixussone',
                         'ixusszero', 'axodin', 'axodinc', 'starsatlx',
                         'geniuse3hd', 'evoe3hd', 'axase3', 'axase3c',
                         'omtimussos1', 'omtimussos2', 'gb800seplus',
                         'gb800ueplus')) or about.getModelString() == 'et6000':
        detected = False
    else:
        detected = eAVSwitch.getInstance().haveScartSwitch()

    SystemInfo["ScartSwitch"] = detected

    if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
        f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
        can_edidchecking = f.read().strip().split(" ")
        f.close()
    else:
        can_edidchecking = False

    SystemInfo["Canedidchecking"] = can_edidchecking

    if can_edidchecking:

        def setEDIDBypass(configElement):
            try:
                f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.bypass_edid_checking = ConfigSelection(choices={
            "00000000": _("off"),
            "00000001": _("on")
        },
                                                         default="00000000")
        config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
    else:
        config.av.bypass_edid_checking = ConfigNothing()

    if os.path.exists("/proc/stb/video/hdmi_colorspace"):
        f = open("/proc/stb/video/hdmi_colorspace", "r")
        have_colorspace = f.read().strip().split(" ")
        f.close()
    else:
        have_colorspace = False

    SystemInfo["havecolorspace"] = have_colorspace

    if have_colorspace:

        def setHDMIColorspace(configElement):
            try:
                f = open("/proc/stb/video/hdmi_colorspace", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        if getBoxType() in ('vusolo4k', 'vuuno4k', 'vuultimo4k'):
            config.av.hdmicolorspace = ConfigSelection(choices={
                "Edid(Auto)": _("Auto"),
                "Hdmi_Rgb": _("RGB"),
                "444": _("YCbCr444"),
                "422": _("YCbCr422"),
                "420": _("YCbCr420")
            },
                                                       default="Edid(Auto)")
        else:
            config.av.hdmicolorspace = ConfigSelection(choices={
                "auto": _("auto"),
                "rgb": _("rgb"),
                "420": _("420"),
                "422": _("422"),
                "444": _("444")
            },
                                                       default="auto")
        config.av.hdmicolorspace.addNotifier(setHDMIColorspace)
    else:
        config.av.hdmicolorspace = ConfigNothing()

    if os.path.exists("/proc/stb/video/hdmi_colorimetry"):
        f = open("/proc/stb/video/hdmi_colorimetry", "r")
        have_colorimetry = f.read().strip().split(" ")
        f.close()
    else:
        have_colorimetry = False

    SystemInfo["havecolorimetry"] = have_colorimetry

    if have_colorimetry:

        def setHDMIColorimetry(configElement):
            try:
                f = open("/proc/stb/video/hdmi_colorimetry", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.hdmicolorimetry = ConfigSelection(choices={
            "Auto":
            _("Auto"),
            "bt2020ncl":
            _("BT 2020 NCL"),
            "bt2020cl":
            _("BT 2020 CL"),
            "bt709":
            _("BT 709")
        },
                                                    default="Auto")
        config.av.hdmicolorimetry.addNotifier(setHDMIColorimetry)
    else:
        config.av.hdmicolorimetry = ConfigNothing()

    if os.path.exists("/proc/stb/info/boxmode"):
        f = open("/proc/stb/info/boxmode", "r")
        have_boxmode = f.read().strip().split(" ")
        f.close()
    else:
        have_boxmode = False

    SystemInfo["haveboxmode"] = have_boxmode

    if have_boxmode:

        def setBoxmode(configElement):
            try:
                f = open("/proc/stb/info/boxmode", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.boxmode = ConfigSelection(choices={
            "12":
            _("PIP enabled, no HDR"),
            "1":
            _("HDR, 12bit 4:2:0/4:2:2, no PIP")
        },
                                            default="12")
        config.av.boxmode.addNotifier(setBoxmode)
    else:
        config.av.boxmode = ConfigNothing()

    if os.path.exists("/proc/stb/video/hdmi_colordepth"):
        f = open("/proc/stb/video/hdmi_colordepth", "r")
        have_HdmiColordepth = f.read().strip().split(" ")
        f.close()
    else:
        have_HdmiColordepth = False

    SystemInfo["havehdmicolordepth"] = have_HdmiColordepth

    if have_HdmiColordepth:

        def setHdmiColordepth(configElement):
            try:
                f = open("/proc/stb/video/hdmi_colordepth", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.hdmicolordepth = ConfigSelection(choices={
            "auto": _("Auto"),
            "8bit": _("8bit"),
            "10bit": _("10bit"),
            "12bit": _("12bit")
        },
                                                   default="auto")
        config.av.hdmicolordepth.addNotifier(setHdmiColordepth)
    else:
        config.av.hdmicolordepth = ConfigNothing()

    if os.path.exists("/proc/stb/video/hdmi_hdrtype"):
        f = open("/proc/stb/video/hdmi_hdrtype", "r")
        have_HdmiHdrType = f.read().strip().split(" ")
        f.close()
    else:
        have_HdmiHdrType = False

    SystemInfo["havehdmihdrtype"] = have_HdmiHdrType

    if have_HdmiHdrType:

        def setHdmiHdrType(configElement):
            try:
                f = open("/proc/stb/video/hdmi_hdrtype", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.hdmihdrtype = ConfigSelection(choices={
            "auto": _("Auto"),
            "dolby": _("Dolby Vision"),
            "hdr10": _("HDR10"),
            "hlg": _("HLG"),
            "none": _("Off")
        },
                                                default="auto")
        config.av.hdmihdrtype.addNotifier(setHdmiHdrType)
    else:
        config.av.hdmihdrtype = ConfigNothing()

    if os.path.exists("/proc/stb/hdmi/audio_source"):
        f = open("/proc/stb/hdmi/audio_source", "r")
        can_audiosource = f.read().strip().split(" ")
        f.close()
    else:
        can_audiosource = False

    SystemInfo["Canaudiosource"] = can_audiosource

    if can_audiosource:

        def setAudioSource(configElement):
            try:
                f = open("/proc/stb/hdmi/audio_source", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.audio_source = ConfigSelection(choices={
            "pcm": _("PCM"),
            "spdif": _("SPDIF")
        },
                                                 default="pcm")
        config.av.audio_source.addNotifier(setAudioSource)
    else:
        config.av.audio_source = ConfigNothing()

    if os.path.exists("/proc/stb/audio/3d_surround_choices"):
        f = open("/proc/stb/audio/3d_surround_choices", "r")
        can_3dsurround = f.read().strip().split(" ")
        f.close()
    else:
        can_3dsurround = False

    SystemInfo["Can3DSurround"] = can_3dsurround

    if can_3dsurround:

        def set3DSurround(configElement):
            f = open("/proc/stb/audio/3d_surround", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.surround_3d = ConfigSelection(choices=choice_list,
                                                default="none")
        config.av.surround_3d.addNotifier(set3DSurround)
    else:
        config.av.surround_3d = ConfigNothing()

    if os.path.exists("/proc/stb/audio/3d_surround_speaker_position_choices"):
        f = open("/proc/stb/audio/3d_surround_speaker_position_choices", "r")
        can_3dsurround_speaker = f.read().strip().split(" ")
        f.close()
    else:
        can_3dsurround_speaker = False

    SystemInfo["Can3DSpeaker"] = can_3dsurround_speaker

    if can_3dsurround_speaker:

        def set3DSurroundSpeaker(configElement):
            f = open("/proc/stb/audio/3d_surround_speaker_position", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("center", _("center")), ("wide", _("wide")),
                       ("extrawide", _("extra wide"))]
        config.av.surround_3d_speaker = ConfigSelection(choices=choice_list,
                                                        default="center")
        config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)
    else:
        config.av.surround_3d_speaker = ConfigNothing()

    if os.path.exists("/proc/stb/audio/avl_choices"):
        f = open("/proc/stb/audio/avl_choices", "r")
        can_autovolume = f.read().strip().split(" ")
        f.close()
    else:
        can_autovolume = False

    SystemInfo["CanAutoVolume"] = can_autovolume

    if can_autovolume:

        def setAutoVolume(configElement):
            f = open("/proc/stb/audio/avl", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.autovolume = ConfigSelection(choices=choice_list,
                                               default="none")
        config.av.autovolume.addNotifier(setAutoVolume)
    else:
        config.av.autovolume = ConfigNothing()

    try:
        can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm",
                                         os.W_OK)
    except:
        can_pcm_multichannel = False

    SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
    if can_pcm_multichannel:

        def setPCMMultichannel(configElement):
            open("/proc/stb/audio/multichannel_pcm",
                 "w").write(configElement.value and "enable" or "disable")

        config.av.pcm_multichannel = ConfigYesNo(default=False)
        config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

    def hasDownmix(target):
        try:
            f = open(os.path.join("/proc/stb/audio", target + "_choices"), "r")
            choices = f.read().strip()
            f.close()
            return "downmix" in choices
        except:
            return False

    def setDownmix(target, value):
        f = open(os.path.join("/proc/stb/audio", target), "w")
        textval = value and "downmix" or "passthrough"
        print "[AVSwitch] setting %s to %s" % (target.upper(), textval)
        f.write(textval)
        f.close()

    can_downmix_ac3 = hasDownmix("ac3")

    SystemInfo["CanDownmixAC3"] = can_downmix_ac3
    if can_downmix_ac3:

        def setAC3Downmix(configElement):
            setDownmix("ac3", configElement.value)
            if SystemInfo.get("supportPcmMultichannel",
                              False) and not configElement.value:
                SystemInfo["CanPcmMultichannel"] = True
            else:
                SystemInfo["CanPcmMultichannel"] = False
                if can_pcm_multichannel:
                    config.av.pcm_multichannel.setValue(False)

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    can_downmix_dts = hasDownmix("dts")

    defective_dts_downmix = getBoxType() == "beyonwizu4"

    SystemInfo["CanDownmixDTS"] = can_downmix_dts and not defective_dts_downmix
    if can_downmix_dts:
        if not defective_dts_downmix:

            def setDTSDownmix(configElement):
                setDownmix("dts", configElement.value)

            config.av.downmix_dts = ConfigYesNo(default=True)
            config.av.downmix_dts.addNotifier(setDTSDownmix)
        else:
            setDownmix("dts", False)

    can_downmix_aac = hasDownmix("aac")

    SystemInfo["CanDownmixAAC"] = can_downmix_aac
    if can_downmix_aac:

        def setAACDownmix(configElement):
            setDownmix("aac", configElement.value)

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
        f = open("/proc/stb/audio/aac_transcode_choices", "r")
        can_aactranscode = f.read().strip().split(" ")
        f.close()
    else:
        can_aactranscode = False

    SystemInfo["CanAACTranscode"] = can_aactranscode

    if can_aactranscode:

        def setAACTranscode(configElement):
            f = open("/proc/stb/audio/aac_transcode", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
        config.av.transcodeaac = ConfigSelection(choices=choice_list,
                                                 default="off")
        config.av.transcodeaac.addNotifier(setAACTranscode)
    else:
        config.av.transcodeaac = ConfigNothing()

    if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "[VideoHardware] setting scaler_sharpness to: %0.8X" % myval
                f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
                f.write("%0.8X" % myval)
                f.close()
                f = open("/proc/stb/vmpeg/0/pep_apply", "w")
                f.write("1")
                f.close()
            except IOError:
                print "[VideoHardware] couldn't write pep_scaler_sharpness"

        if getBoxType() in ('gbquad', 'gbquadplus'):
            config.av.scaler_sharpness = ConfigSlider(default=5,
                                                      limits=(0, 26))
        else:
            config.av.scaler_sharpness = ConfigSlider(default=13,
                                                      limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    config.av.edid_override = ConfigYesNo(default=False)

    iAVSwitch.setConfiguredMode()
示例#49
0
	def setColorFormat(self, value):
		eAVSwitch.getInstance().setColorFormat(value)
示例#50
0
def InitAVSwitch():
    config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {
        "cvbs": _("CVBS"),
        "rgb": _("RGB"),
        "svideo": _("S-Video")
    }

    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="rgb")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4_3": _("4:3"),
        "16_9": _("16:9"),
        "16_10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="auto")
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "scale": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy2_choices") and "auto" in open(
            "/proc/stb/video/policy2_choices").readline():
        # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
        policy2_choices.update({"auto": _("Auto")})
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="letterbox")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "pillarbox": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
        "nonlinear": _("Nonlinear"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "scale": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy_choices") and "auto" in open(
            "/proc/stb/video/policy_choices").readline():
        # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
        policy_choices.update({"auto": _("Auto")})
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="pillarbox")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    # this will call the "setup-val" initial
    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

    try:
        can_downmix = open("/proc/stb/audio/ac3_choices",
                           "r").read()[:-1].find("downmix") != -1
    except:
        can_downmix = False

    SystemInfo["CanDownmixAC3"] = can_downmix
    if can_downmix:

        def setAC3Downmix(configElement):
            open("/proc/stb/audio/ac3",
                 "w").write(configElement.value and "downmix" or "passthrough")

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    try:
        can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
    except:
        can_osd_alpha = False

    SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha

    def setAlpha(config):
        open("/proc/stb/video/alpha", "w").write(str(config.value))

    if can_osd_alpha:
        config.av.osd_alpha = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "--> setting scaler_sharpness to: %0.8X" % myval
                open("/proc/stb/vmpeg/0/pep_scaler_sharpness",
                     "w").write("%0.8X" % myval)
                open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())
示例#51
0
	def setSystem(self, value):
		eAVSwitch.getInstance().setVideomode(value)
示例#52
0
文件: AVSwitch.py 项目: mat12/mytest
def InitAVSwitch():
    if getBoxType() == 'vuduo' or getBoxType().startswith('ixuss'):
        config.av.yuvenabled = ConfigBoolean(default=False)
    else:
        config.av.yuvenabled = ConfigBoolean(default=True)
    config.av.osd_alpha = ConfigSlider(
        default=255, increment=5, limits=(20, 255)
    )  # Make Opendroid compatible with some plugins who still use config.av.osd_alpha
    colorformat_choices = {
        "cvbs": _("CVBS"),
        "rgb": _("RGB"),
        "svideo": _("S-Video")
    }
    # when YUV is not enabled, don't let the user select it
    if config.av.yuvenabled.value:
        colorformat_choices["yuv"] = _("YPbPr")

    config.av.autores = ConfigSelection(choices={
        "disabled": _("Disabled"),
        "all": _("All resolutions"),
        "hd": _("only HD")
    },
                                        default="disabled")
    choicelist = []
    for i in range(5, 16):
        choicelist.append(
            ("%d" % i, ngettext("%d second", "%d seconds", i) % i))
    config.av.autores_label_timeout = ConfigSelection(
        default="5", choices=[("0", _("Not Shown"))] + choicelist)
    config.av.autores_delay = ConfigSelectionNumber(min=50,
                                                    max=3000,
                                                    stepwidth=50,
                                                    default=400,
                                                    wraparound=True)
    config.av.autores_deinterlace = ConfigYesNo(default=False)
    config.av.autores_sd = ConfigSelection(choices={
        "720p50": _("720p50"),
        "720p": _("720p"),
        "1080i50": _("1080i50"),
        "1080i": _("1080i")
    },
                                           default="720p50")
    config.av.autores_480p24 = ConfigSelection(choices={
        "480p24": _("480p 24Hz"),
        "720p24": _("720p 24Hz"),
        "1080p24": _("1080p 24Hz")
    },
                                               default="1080p24")
    config.av.autores_720p24 = ConfigSelection(choices={
        "720p24": _("720p 24Hz"),
        "1080p24": _("1080p 24Hz"),
        "1080i50": _("1080i 50Hz"),
        "1080i": _("1080i 60Hz")
    },
                                               default="720p24")
    config.av.autores_1080p24 = ConfigSelection(choices={
        "1080p24": _("1080p 24Hz"),
        "1080p25": _("1080p 25Hz"),
        "1080i50": _("1080p 50Hz"),
        "1080i": _("1080i 60Hz")
    },
                                                default="1080p24")
    config.av.autores_1080p25 = ConfigSelection(choices={
        "1080p25": _("1080p 25Hz"),
        "1080p50": _("1080p 50Hz"),
        "1080i50": _("1080i 50Hz")
    },
                                                default="1080p25")
    config.av.autores_1080p30 = ConfigSelection(choices={
        "1080p30": _("1080p 30Hz"),
        "1080p60": _("1080p 60Hz"),
        "1080i": _("1080i 60Hz")
    },
                                                default="1080p30")
    config.av.smart1080p = ConfigSelection(choices={
        "false": _("off"),
        "true": _("1080p50: 24/50/60Hz"),
        "1080i50": _("1080i50: 24/50/60Hz"),
        "720p50": _("720p50: 24/50/60Hz")
    },
                                           default="false")
    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="rgb")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        _("16:9"),
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4:3": _("4:3"),
        "16:9": _("16:9"),
        "16:10": _("16:10"),
        "auto": _("Automatic")
    },
                                       default="16:9")
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "scale": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy2_choices"):
        f = open("/proc/stb/video/policy2_choices")
        if "auto" in f.readline():
            # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
            policy2_choices.update({"auto": _("Auto")})
        f.close()
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="letterbox")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "panscan": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "letterbox": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
        # "nonlinear": _("Nonlinear"),
        # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
        "bestfit": _("Just scale")
    }
    if os.path.exists("/proc/stb/video/policy_choices"):
        f = open("/proc/stb/video/policy_choices")
        if "auto" in f.readline():
            # TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
            policy_choices.update({"auto": _("Auto")})
        f.close()
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="panscan")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": _("PAL"),
        "ntsc": _("NTSC"),
        "multinorm": _("multinorm")
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    #config.av.aspect.setValue('16:9')
    config.av.aspect.addNotifier(iAVSwitch.setAspect)
    config.av.wss.addNotifier(iAVSwitch.setWss)
    config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
    config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

    def setColorFormat(configElement):
        if config.av.videoport and config.av.videoport.value in (
                "YPbPr", "Scart-YPbPr"):
            iAVSwitch.setColorFormat(3)
        else:
            if getBoxType() == 'et6x00':
                map = {"cvbs": 3, "rgb": 3, "svideo": 2, "yuv": 3}
            elif getBoxType() == 'gbquad' or getBoxType(
            ) == 'gbquadplus' or getBoxType().startswith('et'):
                map = {"cvbs": 0, "rgb": 3, "svideo": 2, "yuv": 3}
            else:
                map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
            iAVSwitch.setColorFormat(map[configElement.value])

    config.av.colorformat.addNotifier(setColorFormat)

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    iAVSwitch.setInput("ENCODER")  # init on startup
    if (getBoxType()
            in ('gbquad', 'gbquadplus', 'et5x00', 'ixussone', 'ixusszero',
                'axodin', 'axodinc', 'starsatlx', 'galaxym6', 'geniuse3hd',
                'evoe3hd', 'axase3', 'axase3c', 'omtimussos1', 'omtimussos2',
                'gb800seplus', 'gb800ueplus', 'gbultrase', 'gbultraue',
                'twinboxlcd')) or about.getModelString() == 'et6000':
        detected = False
    else:
        detected = eAVSwitch.getInstance().haveScartSwitch()

    SystemInfo["ScartSwitch"] = detected

    if os.path.exists("/proc/stb/hdmi/bypass_edid_checking"):
        f = open("/proc/stb/hdmi/bypass_edid_checking", "r")
        can_edidchecking = f.read().strip().split(" ")
        f.close()
    else:
        can_edidchecking = False

    SystemInfo["Canedidchecking"] = can_edidchecking

    if can_edidchecking:

        def setEDIDBypass(configElement):
            try:
                f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.bypass_edid_checking = ConfigSelection(choices={
            "00000000": _("off"),
            "00000001": _("on")
        },
                                                         default="00000001")
        config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
    else:
        config.av.bypass_edid_checking = ConfigNothing()

    if os.path.exists("/proc/stb/hdmi/audio_source"):
        f = open("/proc/stb/hdmi/audio_source", "r")
        can_audiosource = f.read().strip().split(" ")
        f.close()
    else:
        can_audiosource = False

    SystemInfo["Canaudiosource"] = can_audiosource

    if can_audiosource:

        def setAudioSource(configElement):
            try:
                f = open("/proc/stb/hdmi/audio_source", "w")
                f.write(configElement.value)
                f.close()
            except:
                pass

        config.av.audio_source = ConfigSelection(choices={
            "pcm": _("PCM"),
            "spdif": _("SPDIF")
        },
                                                 default="pcm")
        config.av.audio_source.addNotifier(setAudioSource)
    else:
        config.av.audio_source = ConfigNothing()

    if os.path.exists("/proc/stb/audio/3d_surround_choices"):
        f = open("/proc/stb/audio/3d_surround_choices", "r")
        can_3dsurround = f.read().strip().split(" ")
        f.close()
    else:
        can_3dsurround = False

    SystemInfo["Can3DSurround"] = can_3dsurround

    if can_3dsurround:

        def set3DSurround(configElement):
            f = open("/proc/stb/audio/3d_surround", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.surround_3d = ConfigSelection(choices=choice_list,
                                                default="none")
        config.av.surround_3d.addNotifier(set3DSurround)
    else:
        config.av.surround_3d = ConfigNothing()

    if os.path.exists("/proc/stb/audio/3d_surround_speaker_position_choices"):
        f = open("/proc/stb/audio/3d_surround_speaker_position_choices", "r")
        can_3dsurround_speaker = f.read().strip().split(" ")
        f.close()
    else:
        can_3dsurround_speaker = False

    SystemInfo["Can3DSpeaker"] = can_3dsurround_speaker

    if can_3dsurround_speaker:

        def set3DSurroundSpeaker(configElement):
            f = open("/proc/stb/audio/3d_surround_speaker_position", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("center", _("center")), ("wide", _("wide")),
                       ("extrawide", _("extra wide"))]
        config.av.surround_3d_speaker = ConfigSelection(choices=choice_list,
                                                        default="center")
        config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)
    else:
        config.av.surround_3d_speaker = ConfigNothing()

    if os.path.exists("/proc/stb/audio/avl_choices"):
        f = open("/proc/stb/audio/avl_choices", "r")
        can_autovolume = f.read().strip().split(" ")
        f.close()
    else:
        can_autovolume = False

    SystemInfo["CanAutoVolume"] = can_autovolume

    if can_autovolume:

        def setAutoVolume(configElement):
            f = open("/proc/stb/audio/avl", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("none", _("off")), ("hdmi", _("HDMI")),
                       ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        config.av.autovolume = ConfigSelection(choices=choice_list,
                                               default="none")
        config.av.autovolume.addNotifier(setAutoVolume)
    else:
        config.av.autovolume = ConfigNothing()

    try:
        can_pcm_multichannel = os.access("/proc/stb/audio/multichannel_pcm",
                                         os.W_OK)
    except:
        can_pcm_multichannel = False

    SystemInfo["supportPcmMultichannel"] = can_pcm_multichannel
    if can_pcm_multichannel:

        def setPCMMultichannel(configElement):
            open("/proc/stb/audio/multichannel_pcm",
                 "w").write(configElement.value and "enable" or "disable")

        config.av.pcm_multichannel = ConfigYesNo(default=False)
        config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

    try:
        f = open("/proc/stb/audio/ac3_choices", "r")
        file = f.read()[:-1]
        f.close()
        can_downmix_ac3 = "downmix" in file
    except:
        can_downmix_ac3 = False

    SystemInfo["CanDownmixAC3"] = can_downmix_ac3
    if can_downmix_ac3:

        def setAC3Downmix(configElement):
            f = open("/proc/stb/audio/ac3", "w")
            f.write(configElement.value and "downmix" or "passthrough")
            f.close()
            if SystemInfo.get("supportPcmMultichannel",
                              False) and not configElement.value:
                SystemInfo["CanPcmMultichannel"] = True
            else:
                SystemInfo["CanPcmMultichannel"] = False
                if can_pcm_multichannel:
                    config.av.pcm_multichannel.setValue(False)

        config.av.downmix_ac3 = ConfigYesNo(default=True)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    try:
        f = open("/proc/stb/audio/aac_choices", "r")
        file = f.read()[:-1]
        f.close()
        can_downmix_aac = "downmix" in file
    except:
        can_downmix_aac = False

    SystemInfo["CanDownmixAAC"] = can_downmix_aac
    if can_downmix_aac:

        def setAACDownmix(configElement):
            f = open("/proc/stb/audio/aac", "w")
            f.write(configElement.value and "downmix" or "passthrough")
            f.close()

        config.av.downmix_aac = ConfigYesNo(default=True)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    if os.path.exists("/proc/stb/audio/aac_transcode_choices"):
        f = open("/proc/stb/audio/aac_transcode_choices", "r")
        can_aactranscode = f.read().strip().split(" ")
        f.close()
    else:
        can_aactranscode = False

    SystemInfo["CanAACTranscode"] = can_aactranscode

    if can_aactranscode:

        def setAACTranscode(configElement):
            f = open("/proc/stb/audio/aac_transcode", "w")
            f.write(configElement.value)
            f.close()

        choice_list = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
        config.av.transcodeaac = ConfigSelection(choices=choice_list,
                                                 default="off")
        config.av.transcodeaac.addNotifier(setAACTranscode)
    else:
        config.av.transcodeaac = ConfigNothing()

    if os.path.exists("/proc/stb/vmpeg/0/pep_scaler_sharpness"):

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "[VideoMode] setting scaler_sharpness to: %0.8X" % myval
                f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
                f.write("%0.8X" % myval)
                f.close()
                f = open("/proc/stb/vmpeg/0/pep_apply", "w")
                f.write("1")
                f.close()
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        if getBoxType() in ('gbquad', 'gbquadplus'):
            config.av.scaler_sharpness = ConfigSlider(default=5,
                                                      limits=(0, 26))
        else:
            config.av.scaler_sharpness = ConfigSlider(default=13,
                                                      limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    config.av.edid_override = ConfigYesNo(default=False)

    iAVSwitch.setConfiguredMode()
示例#53
0
def InitAVSwitch():
	config.av = ConfigSubsection()
	config.av.yuvenabled = ConfigBoolean(default=True)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
	
	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"), 
			"16_9": _("16:9"), 
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"), 
			"16_9_letterbox": _("16:9 Letterbox")}, 
			default = "16_9")

	config.av.aspect = ConfigSelection(choices={
			"4_3": _("4:3"),
			"16_9": _("16:9"), 
			"16_10": _("16:10"),
			"auto": _("Automatic")},
			default = "auto")
	config.av.policy_169 = ConfigSelection(choices={
				# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
			"letterbox": _("Letterbox"), 
				# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
			"panscan": _("Pan&Scan"),  
				# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
			"scale": _("Just Scale"),

			"zoom": _("Zoom")},
			default = "letterbox")
	config.av.policy_43 = ConfigSelection(choices={
				# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
			"pillarbox": _("Pillarbox"), 
				# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
			"panscan": _("Pan&Scan"),  
				# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
			#"nonlinear": _("Nonlinear"),  
				# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
			"scale": _("Just Scale"),

			"zoom": _("Zoom")},
			default = "pillarbox")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 25, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 25, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	iAVSwitch = AVSwitch()

	def setColorFormat(configElement):
		map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
		iAVSwitch.setColorFormat(map[configElement.value])

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])

	def setSystem(configElement):
		map = {"pal": 0, "ntsc": 1, "multinorm" : 2}
		iAVSwitch.setSystem(map[configElement.value])

	def setWSS(configElement):
		iAVSwitch.setAspectWSS()

	# this will call the "setup-val" initial
	config.av.colorformat.addNotifier(setColorFormat)
	config.av.aspectratio.addNotifier(setAspectRatio)
	config.av.tvsystem.addNotifier(setSystem)
	config.av.wss.addNotifier(setWSS)

	iAVSwitch.setInput("ENCODER") # init on startup
	SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

	try:
		can_downmix = open("/usr/local/e2/etc/stb/audio/ac3_choices", "r").read()[:-1].find("downmix") != -1
	except:
		can_downmix = False

	SystemInfo["CanDownmixAC3"] = can_downmix
	if can_downmix:
		def setAC3Downmix(configElement):
			open("/usr/local/e2/etc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough")
		config.av.downmix_ac3 = ConfigYesNo(default = True)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	can_downmix = os.path.exists("/usr/lib/gstreamer-0.10/libgstdtsdec.so")
	SystemInfo["CanDownmixDTS"] = can_downmix
	if can_downmix:
		def setDTSDownmix(configElement):
			open("/var/run/dts_mode", "w").write(configElement.value and "downmix" or "passthrough")
			try:
				os.unlink('/home/root/.gstreamer-0.10/registry.mipsel.bin')
			except:
				pass
		config.av.downmix_dts = ConfigYesNo(default = False)
		config.av.downmix_dts.addNotifier(setDTSDownmix)

	try:
		can_osd_alpha = open("/usr/local/e2/etc/stb/video/alpha", "r") and True or False
	except:
		can_osd_alpha = False

	SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha

	def setAlpha(config):
		open("/usr/local/e2/etc/stb/video/alpha", "w").write(str(config.value))

	if can_osd_alpha:
		config.av.osd_alpha = ConfigSlider(default=255, limits=(0,255))
		config.av.osd_alpha.addNotifier(setAlpha)

	if os.path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_scaler_sharpness"):
		def setScaler_sharpness(config):
			myval = int(config.value)
			try:
				print "--> setting scaler_sharpness to: %0.8X" % myval
				open("/usr/local/e2/etc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval)
				open("/usr/local/e2/etc/stb/vmpeg/0/pep_apply", "w").write("1")
			except IOError:
				print "couldn't write pep_scaler_sharpness"

		config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())
示例#54
0
文件: AVSwitch.py 项目: bbbuk/enigma2
	def setInput(self, input):
		INPUT = { "ENCODER": 0, "SCART": 1, "AUX": 2 }
		eAVSwitch.getInstance().setInput(INPUT[input])
示例#55
0
文件: AVSwitch.py 项目: bbbuk/enigma2
def InitAVSwitch():
	config.av.yuvenabled = ConfigBoolean(default=True)
	colorformat_choices = {"cvbs": _("CVBS"), "rgb": _("RGB"), "svideo": _("S-Video")}
	# when YUV is not enabled, don't let the user select it
	if config.av.yuvenabled.value:
		colorformat_choices["yuv"] = _("YPbPr")

	config.av.autores = ConfigSelection(choices={"disabled": _("Disabled"), "all": _("All resolutions"), "hd": _("only HD")}, default="disabled")
	choicelist = []
	for i in range(5, 16):
		choicelist.append(("%d" % i, ngettext("%d second", "%d seconds", i) % i))
	config.av.autores_label_timeout = ConfigSelection(default = "5", choices = [("0", _("Not Shown"))] + choicelist)
	config.av.autores_delay = ConfigSelectionNumber(min = 0, max = 15000, stepwidth = 500, default = 500, wraparound = True)
	config.av.autores_deinterlace = ConfigYesNo(default=False)
	config.av.autores_sd = ConfigSelection(choices={"720p": _("720p"), "1080i": _("1080i")}, default="720p")
	config.av.autores_480p24 = ConfigSelection(choices={"480p24": _("480p 24Hz"), "720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz")}, default="1080p24")
	config.av.autores_720p24 = ConfigSelection(choices={"720p24": _("720p 24Hz"), "1080p24": _("1080p 24Hz")}, default="1080p24")
	config.av.autores_1080p24 = ConfigSelection(choices={"1080p24": _("1080p 24Hz"), "1080p25": _("1080p 25Hz")}, default="1080p24")
	config.av.autores_1080p25 = ConfigSelection(choices={"1080p25": _("1080p 25Hz"), "1080p50": _("1080p 50Hz")}, default="1080p25")
	config.av.autores_1080p30 = ConfigSelection(choices={"1080p30": _("1080p 30Hz"), "1080p60": _("1080p 60Hz")}, default="1080p30")
	config.av.autores_2160p24 = ConfigSelection(choices={"2160p24": _("2160p 24Hz"), "2160p25": _("2160p 25Hz"), "2160p30": _("2160p 30Hz")}, default="2160p24")
	config.av.autores_2160p25 = ConfigSelection(choices={"2160p25": _("2160p 25Hz"), "2160p50": _("2160p 50Hz")}, default="2160p25")
	config.av.autores_2160p30 = ConfigSelection(choices={"2160p30": _("2160p 30Hz"), "2160p60": _("2160p 60Hz")}, default="2160p30")
	config.av.colorformat = ConfigSelection(choices=colorformat_choices, default="rgb")
	config.av.aspectratio = ConfigSelection(choices={
			"4_3_letterbox": _("4:3 Letterbox"),
			"4_3_panscan": _("4:3 PanScan"),
			"16_9": _("16:9"),
			"16_9_always": _("16:9 always"),
			"16_10_letterbox": _("16:10 Letterbox"),
			"16_10_panscan": _("16:10 PanScan"),
			"16_9_letterbox": _("16:9 Letterbox")},
			default = "16_9")
	config.av.aspect = ConfigSelection(choices={
			"4:3": _("4:3"),
			"16:9": _("16:9"),
			"16:10": _("16:10"),
			"auto": _("Automatic")},
			default = "16:9")
	policy2_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
	"letterbox": _("Letterbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"panscan": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"scale": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy2_choices"):
		f = open("/proc/stb/video/policy2_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy2_choices.update({"auto": _("Auto")})
		f.close()
	config.av.policy_169 = ConfigSelection(choices=policy2_choices, default = "letterbox")
	policy_choices = {
	# TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
	"panscan": _("Pillarbox"),
	# TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
	"letterbox": _("Pan&scan"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
	# "nonlinear": _("Nonlinear"),
	# TRANSLATORS: (aspect ratio policy: display as fullscreen, even if this breaks the aspect)
	"bestfit": _("Just scale")}
	if os.path.exists("/proc/stb/video/policy_choices"):
		f = open("/proc/stb/video/policy_choices")
		if "auto" in f.readline():
			# TRANSLATORS: (aspect ratio policy: always try to display as fullscreen, when there is no content (black bars) on left/right, even if this breaks the aspect.
			policy_choices.update({"auto": _("Auto")})
		f.close()
	config.av.policy_43 = ConfigSelection(choices=policy_choices, default = "panscan")
	config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal")
	config.av.wss = ConfigEnableDisable(default = True)
	config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 5, default = 0)
	config.av.vcrswitch = ConfigEnableDisable(default = False)

	config.av.aspect.setValue('16:9')
	config.av.aspect.addNotifier(iAVSwitch.setAspect)
	config.av.wss.addNotifier(iAVSwitch.setWss)
	config.av.policy_43.addNotifier(iAVSwitch.setPolicy43)
	config.av.policy_169.addNotifier(iAVSwitch.setPolicy169)

	def setHDMIColorspace(configElement):
		try:
			f = open(SystemInfo["havecolorspace"], "w")
			f.write(configElement.value)
			f.close()
		except:
			pass

	def setHDMIColorimetry(configElement):
		try:
			f = open(SystemInfo["havecolorimetry"], "w")
			f.write(configElement.value)
			f.close()
		except:
			pass

	def setHdmiColordepth(configElement):
		try:
			f = open(SystemInfo["havehdmicolordepth"], "w")
			f.write(configElement.value)
			f.close()
		except:
			pass

	def set3DSurround(configElement):
		f = open("/proc/stb/audio/3d_surround", "w")
		f.write(configElement.value)
		f.close()

	def set3DPosition(configElement):
		f = open("/proc/stb/audio/3d_surround_speaker_position", "w")
		f.write(configElement.value)
		f.close()

	def setAutoVolume(configElement):
		f = open("/proc/stb/audio/avl", "w")
		f.write(configElement.value)
		f.close()

	def setAC3Downmix(configElement):
		f = open("/proc/stb/audio/ac3", "w")
		f.write(configElement.value)
		f.close()
		if SystemInfo.get("supportPcmMultichannel", False) and not configElement.value:
			SystemInfo["CanPcmMultichannel"] = True
		else:
			SystemInfo["CanPcmMultichannel"] = False
			if SystemInfo["supportPcmMultichannel"]:
				config.av.pcm_multichannel.setValue(False)

	def setAC3plusTranscode(configElement):
		f = open("/proc/stb/audio/ac3plus", "w")
		f.write(configElement.value)
		f.close()

	def setDTSDownmix(configElement):
		f = open("/proc/stb/audio/dts", "w")
		f.write(configElement.value)
		f.close()

	def setDTSHD(configElement):
		f = open("/proc/stb/audio/dtshd", "w")
		f.write(configElement.value)
		f.close()

	def setAACDownmix(configElement):
		f = open("/proc/stb/audio/aac", "w")
		f.write(configElement.value)
		f.close()

	def setAACDownmixPlus(configElement):
		f = open("/proc/stb/audio/aacplus", "w")
		f.write(configElement.value)
		f.close()


	def setAACTranscode(configElement):
		f = open("/proc/stb/audio/aac_transcode", "w")
		f.write(configElement.value)
		f.close()

	def setWMAPRO(configElement):
		f = open("/proc/stb/audio/wmapro", "w")
		f.write(configElement.value)
		f.close()

	def setBoxmode(configElement):
		try:
			f = open("/proc/stb/info/boxmode", "w")
			f.write(configElement.value)
			f.close()
		except:
			pass

	def setScaler_sharpness(config):
		myval = int(config.value)
		try:
			print "[VideoHardware] setting scaler_sharpness to: %0.8X" % myval
			f = open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w")
			f.write("%0.8X" % myval)
			f.close()
			f = open("/proc/stb/vmpeg/0/pep_apply", "w")
			f.write("1")
			f.close()
		except IOError:
			print "[VideoHardware] couldn't write pep_scaler_sharpness"

	def setColorFormat(configElement):
		if config.av.videoport and config.av.videoport.value in ("YPbPr", "Scart-YPbPr"):
			iAVSwitch.setColorFormat(3)
		elif config.av.videoport and config.av.videoport.value in ("RCA"):
			iAVSwitch.setColorFormat(0)
		else:
			map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
			iAVSwitch.setColorFormat(map[configElement.value])
	config.av.colorformat.addNotifier(setColorFormat)

	def setAspectRatio(configElement):
		map = {"4_3_letterbox": 0, "4_3_panscan": 1, "16_9": 2, "16_9_always": 3, "16_10_letterbox": 4, "16_10_panscan": 5, "16_9_letterbox" : 6}
		iAVSwitch.setAspectRatio(map[configElement.value])


	def read_choices(procx, defchoice):
		with open(procx, 'r') as myfile:
			choices = myfile.read().strip()
		myfile.close()
		if choices:
			choiceslist = choices.split(" ")
			choicesx = [(item, _("%s") % item) for item in choiceslist]
			defaultx = choiceslist[0]
			for item in choiceslist:
				if "%s" %defchoice.upper in item.upper():
					defaultx = item
					break
		return (choicesx, defaultx)

	iAVSwitch.setInput("ENCODER") # init on startup
	SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

	if SystemInfo["Canedidchecking"]:
		def setEDIDBypass(configElement):
			try:
				f = open("/proc/stb/hdmi/bypass_edid_checking", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.bypass_edid_checking = ConfigSelection(choices={
				"00000000": _("off"),
				"00000001": _("on")},
				default = "00000000")
		config.av.bypass_edid_checking.addNotifier(setEDIDBypass)
	else:
		config.av.bypass_edid_checking = ConfigNothing()

	if SystemInfo["havecolorspace"]:

		if getBrandOEM() == "vuplus" and SystemInfo["HasMMC"]:
			choices = [("Edid(Auto)", _("Auto")),
						("Hdmi_Rgb", _("RGB")),
						("444", _("YCbCr444")),
						("422", _("YCbCr422")),
						("420", _("YCbCr420"))]
			default = "Edid(Auto)"
		else:
				
			choices = [("auto", _("Auto")),
						("rgb", _("RGB")),
						("420", _("420")),
						("422", _("422")),
						("444", _("444"))]
			default = "auto"

		if SystemInfo["havecolorspacechoices"] and SystemInfo["CanProc"]:
			f = "/proc/stb/video/hdmi_colorspace_choices"
			(choices, default) = read_choices(f, default) 

		config.av.hdmicolorspace = ConfigSelection(choices=choices, default=default)
		config.av.hdmicolorspace.addNotifier(setHDMIColorspace)
	else:
		config.av.hdmicolorspace = ConfigNothing()

	if SystemInfo["havecolorimetry"]:

		choices = [("auto", _("auto")),
					("bt2020ncl", _("BT 2020 NCL")),
					("bt2020cl", _("BT 2020 CL")),
					("bt709", _("BT 709"))]
		default = "auto"

		if SystemInfo["havecolorimetrychoices"] and SystemInfo["CanProc"]:
			f = "/proc/stb/video/hdmi_colorimetry_choices"
			(choices, default) = read_choices(f, default)

		config.av.hdmicolorimetry = ConfigSelection(choices=choices, default=default)
		config.av.hdmicolorimetry.addNotifier(setHDMIColorimetry)
	else:
		config.av.hdmicolorimetry = ConfigNothing()

	if SystemInfo["havehdmicolordepth"]:

		choices = [("auto", _("Auto")),
					("8bit", _("8bit")),
					("10bit", _("10bit")),
					("12bit", _("12bit"))]	
		default = "auto"

		if SystemInfo["havehdmicolordepthchoices"] and SystemInfo["CanProc"]:
			f = "/proc/stb/video/hdmi_colordepth_choices"
			(choices, default) = read_choices(f, default)

		config.av.hdmicolordepth = ConfigSelection(choices=choices, default=default)
		config.av.hdmicolordepth.addNotifier(setHdmiColordepth)
	else:
		config.av.hdmicolordepth = ConfigNothing()

	if SystemInfo["havehdmihdrtype"] :
		def setHdmiHdrType(configElement):
			try:
				f = open("/proc/stb/video/hdmi_hdrtype", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass
		config.av.hdmihdrtype = ConfigSelection(choices={
				"auto": _("Auto"),
				"dolby": _("dolby"),
				"none": _("sdr"),
				"hdr10": _("hdr10"),
				"hlg": _("hlg")},
				default = "auto")
		config.av.hdmihdrtype.addNotifier(setHdmiHdrType)
	else:
		config.av.hdmihdrtype = ConfigNothing()

	if SystemInfo["HDRSupport"]:
		def setHlgSupport(configElement):
			open("/proc/stb/hdmi/hlg_support", "w").write(configElement.value)
		config.av.hlg_support = ConfigSelection(default = "auto(EDID)", 
			choices = [ ("auto(EDID)", _("controlled by HDMI")), ("yes", _("force enabled")), ("no", _("force disabled")) ])
		config.av.hlg_support.addNotifier(setHlgSupport)

		def setHdr10Support(configElement):
			open("/proc/stb/hdmi/hdr10_support", "w").write(configElement.value)
		config.av.hdr10_support = ConfigSelection(default = "auto(EDID)", 
			choices = [ ("auto(EDID)", _("controlled by HDMI")), ("yes", _("force enabled")), ("no", _("force disabled")) ])
		config.av.hdr10_support.addNotifier(setHdr10Support)

		def setDisable12Bit(configElement):
			open("/proc/stb/video/disable_12bit", "w").write(configElement.value)
		config.av.allow_12bit = ConfigSelection(default = "0", choices = [ ("0", _("yes")), ("1", _("no")) ]);
		config.av.allow_12bit.addNotifier(setDisable12Bit)

		def setDisable10Bit(configElement):
			open("/proc/stb/video/disable_10bit", "w").write(configElement.value)
		config.av.allow_10bit = ConfigSelection(default = "0", choices = [ ("0", _("yes")), ("1", _("no")) ]);
		config.av.allow_10bit.addNotifier(setDisable10Bit)

	if SystemInfo["Canaudiosource"]:
		def setAudioSource(configElement):
			try:
				f = open("/proc/stb/hdmi/audio_source", "w")
				f.write(configElement.value)
				f.close()
			except:
				pass

		config.av.audio_source = ConfigSelection(choices={
				"pcm": _("PCM"),
				"spdif": _("SPDIF")},
				default="pcm")
		config.av.audio_source.addNotifier(setAudioSource)
	else:
		config.av.audio_source = ConfigNothing()

	if SystemInfo["Can3DSurround"]:

		choices = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		default = "none"
		
		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/3d_surround_choices"
			(choices, default) = read_choices(f, default)

		config.av.surround_3d = ConfigSelection(choices = choices, default = "none")
		config.av.surround_3d.addNotifier(set3DSurround)
	else:
		config.av.surround_3d = ConfigNothing()

	if SystemInfo["Can3DSpeaker"]:

		choices = [("center", _("center")), ("wide", _("wide")), ("extrawide", _("extra wide"))]
		default = "center"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/3d_surround_speaker_position_choices"
			(choices, default) = read_choices(f, default)

		config.av.surround_3d_speaker = ConfigSelection(choices=choices, default=default)
		config.av.surround_3d_speaker.addNotifier(set3DPosition)
	else:
		config.av.surround_3d_speaker = ConfigNothing()

	if SystemInfo["CanAutoVolume"]:

		choices = [("none", _("off")), ("hdmi", _("HDMI")), ("spdif", _("SPDIF")), ("dac", _("DAC"))]
		default = "none"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/avl_choices"
			(choices, default) = read_choices(f, default)
		config.av.autovolume = ConfigSelection(choices = choices, default = default)
		config.av.autovolume.addNotifier(setAutoVolume)
	else:
		config.av.autovolume = ConfigNothing()

	if SystemInfo["supportPcmMultichannel"]:
		def setPCMMultichannel(configElement):
			open("/proc/stb/audio/multichannel_pcm", "w").write(configElement.value and "enable" or "disable")
		config.av.pcm_multichannel = ConfigYesNo(default = False)
		config.av.pcm_multichannel.addNotifier(setPCMMultichannel)

	if SystemInfo["CanDownmixAC3"]:

		choices = [("downmix", _("Downmix")), ("passthrough", _("Passthrough"))]
		default = "downmix"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/ac3_choices"
			(choices, default) = read_choices(f, default)
		config.av.downmix_ac3 = ConfigSelection(choices = choices, default = default)
		config.av.downmix_ac3.addNotifier(setAC3Downmix)

	if SystemInfo["CanAC3Transcode"]:

		choices = [("use_hdmi_caps", _("controlled by HDMI")), ("force_ac3", _("convert to AC3"))]
		default = "force_ac3"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/ac3plus_choices"
			(choices, default) = read_choices(f, default)
		config.av.transcodeac3plus = ConfigSelection(choices = choices, default = default)
		config.av.transcodeac3plus.addNotifier(setAC3plusTranscode)

	if SystemInfo["CanDownmixDTS"]:

		choice_list = [("downmix", _("Downmix")), ("passthrough", _("Passthrough"))]
		default = "downmix"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/dts_choices"
			(choices, default) = read_choices(f, default)

		config.av.downmix_dts = ConfigSelection(choices = choices, default = default)
		config.av.downmix_dts.addNotifier(setDTSDownmix)

	if SystemInfo["CanDTSHD"]:

		choices = [("downmix",  _("Downmix")), ("force_dts", _("convert to DTS")), ("use_hdmi_caps",  _("controlled by HDMI")), ("multichannel",  _("convert to multi-channel PCM")), ("hdmi_best",  _("use best / controlled by HDMI"))]
		default = "downmix"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/dtshd_choices"
			(choices, default) = read_choices(f, default)

		config.av.dtshd = ConfigSelection(choices = choices, default = default)
		config.av.dtshd.addNotifier(setDTSHD)

	if SystemInfo["CanDownmixAAC"]:

		choices = [("downmix",  _("Downmix")), ("passthrough", _("Passthrough"))]
		default = "downmix"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/aac_choices"
			(choices, default) = read_choices(f, default)

		config.av.downmix_aac = ConfigSelection(choices = choices, default = default)
		config.av.downmix_aac.addNotifier(setAACDownmix)

	if SystemInfo["CanDownmixAACPlus"]:

		choices = [("downmix",  _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel",  _("convert to multi-channel PCM")), ("force_ac3", _("convert to AC3")), ("force_dts",  _("convert to DTS")), ("use_hdmi_cacenter",  _("use_hdmi_cacenter")), ("wide",  _("wide")), ("extrawide",  _("extrawide"))]
		default = "downmix"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/aacplus_choices"
			(choices, default) = read_choices(f, default)

		config.av.downmix_aacplus = ConfigSelection(choices = choices, default = default)
		config.av.downmix_aacplus.addNotifier(setAACDownmixPlus)

	if SystemInfo["CanAACTranscode"]:

		choices = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
		default = "off"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/aac_transcode_choices"
			(choices, default) = read_choices(f, default)

		config.av.transcodeaac = ConfigSelection( choices = choices, default = default)
		config.av.transcodeaac.addNotifier(setAACTranscode)
	else:
		config.av.transcodeaac = ConfigNothing()

	if SystemInfo["CanWMAPRO"]:
		choices = [("downmix",  _("Downmix")), ("passthrough", _("Passthrough")), ("multichannel",  _("convert to multi-channel PCM")), ("hdmi_best",  _("use best / controlled by HDMI"))]
		default = "downmix"

		if SystemInfo["CanProc"]:
			f = "/proc/stb/audio/wmapro_choices"
			(choices, default) = read_choices(f, default)

		config.av.wmapro = ConfigSelection(choices = choices, default = default)
		config.av.wmapro.addNotifier(setWMAPRO)

	if SystemInfo["haveboxmode"]:
		config.av.boxmode = ConfigSelection(choices={
				"12": _("PIP enabled, no HDR"),
				"1": _("HDR, 12bit 4:2:0/4:2:2, no PIP")},
				default = "12")

		config.av.boxmode.addNotifier(setBoxmode)
	else:
		config.av.boxmode = ConfigNothing()

	if SystemInfo["HasScaler_sharpness"]:
		if getBoxType() in ('gbquad', 'gbquadplus'):
			config.av.scaler_sharpness = ConfigSlider(default=5, limits=(0,26))
		else:
			config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0,26))
		config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
	else:
		config.av.scaler_sharpness = NoSave(ConfigNothing())

	config.av.edid_override = ConfigYesNo(default = False)

	iAVSwitch.setConfiguredMode()
示例#56
0
def InitAVSwitch():
    config.av = ConfigSubsection()
    config.av.yuvenabled = ConfigBoolean(default=True)
    colorformat_choices = {"cvbs": "CVBS"}

    # when YUV, Scart or S-Video is not support by HW, don't let the user select it
    if SystemInfo["HasYPbPr"]:
        colorformat_choices["yuv"] = "YPbPr"
    if SystemInfo["HasScart"]:
        colorformat_choices["rgb"] = "RGB"
    if SystemInfo["HasSVideo"]:
        colorformat_choices["svideo"] = "S-Video"

    config.av.colorformat = ConfigSelection(choices=colorformat_choices,
                                            default="cvbs")
    config.av.aspectratio = ConfigSelection(choices={
        "4_3_letterbox":
        _("4:3 Letterbox"),
        "4_3_panscan":
        _("4:3 PanScan"),
        "16_9":
        "16:9",
        "16_9_always":
        _("16:9 always"),
        "16_10_letterbox":
        _("16:10 Letterbox"),
        "16_10_panscan":
        _("16:10 PanScan"),
        "16_9_letterbox":
        _("16:9 Letterbox")
    },
                                            default="16_9")
    config.av.aspect = ConfigSelection(choices={
        "4_3": "4:3",
        "16_9": "16:9",
        "16_10": "16:10",
        "auto": _("automatic")
    },
                                       default="auto")
    policy2_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on top/bottom) in doubt, keep english term.
        "letterbox": _("Letterbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: scale as close to fullscreen as possible)
        "scale": _("Just scale")
    }
    try:
        if "full" in open("/proc/stb/video/policy2_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if the content aspect ratio does not match the screen ratio)
            policy2_choices.update({"full": _("Full screen")})
    except:
        pass
    try:
        if "auto" in open("/proc/stb/video/policy2_choices").read():
            # TRANSLATORS: (aspect ratio policy: automatically select the best aspect ratio mode)
            policy2_choices.update({"auto": _("Auto")})
    except:
        pass
    config.av.policy_169 = ConfigSelection(choices=policy2_choices,
                                           default="letterbox")
    policy_choices = {
        # TRANSLATORS: (aspect ratio policy: black bars on left/right) in doubt, keep english term.
        "pillarbox": _("Pillarbox"),
        # TRANSLATORS: (aspect ratio policy: cropped content on left/right) in doubt, keep english term
        "panscan": _("Pan&scan"),
        # TRANSLATORS: (aspect ratio policy: scale as close to fullscreen as possible)
        "scale": _("Just scale")
    }
    try:
        if "nonlinear" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, with stretching the left/right)
            policy_choices.update({"nonlinear": _("Nonlinear")})
    except:
        pass
    try:
        if "full" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: display as fullscreen, even if the content aspect ratio does not match the screen ratio)
            policy_choices.update({"full": _("Full screen")})
    except:
        pass
    try:
        if "auto" in open("/proc/stb/video/policy_choices").read():
            # TRANSLATORS: (aspect ratio policy: automatically select the best aspect ratio mode)
            policy_choices.update({"auto": _("Auto")})
    except:
        pass
    config.av.policy_43 = ConfigSelection(choices=policy_choices,
                                          default="pillarbox")
    config.av.tvsystem = ConfigSelection(choices={
        "pal": "PAL",
        "ntsc": "NTSC",
        "multinorm": "multinorm"
    },
                                         default="pal")
    config.av.wss = ConfigEnableDisable(default=True)
    config.av.generalAC3delay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.generalPCMdelay = ConfigSelectionNumber(-1000,
                                                      1000,
                                                      5,
                                                      default=0)
    config.av.vcrswitch = ConfigEnableDisable(default=False)

    iAVSwitch = AVSwitch()

    def setColorFormat(configElement):
        map = {"cvbs": 0, "rgb": 1, "svideo": 2, "yuv": 3}
        iAVSwitch.setColorFormat(map[configElement.value])

    def setAspectRatio(configElement):
        map = {
            "4_3_letterbox": 0,
            "4_3_panscan": 1,
            "16_9": 2,
            "16_9_always": 3,
            "16_10_letterbox": 4,
            "16_10_panscan": 5,
            "16_9_letterbox": 6
        }
        iAVSwitch.setAspectRatio(map[configElement.value])

    def setSystem(configElement):
        map = {"pal": 0, "ntsc": 1, "multinorm": 2}
        iAVSwitch.setSystem(map[configElement.value])

    def setWSS(configElement):
        iAVSwitch.setAspectWSS()

    # this will call the "setup-val" initial
    config.av.colorformat.addNotifier(setColorFormat)
    config.av.aspectratio.addNotifier(setAspectRatio)
    config.av.tvsystem.addNotifier(setSystem)
    config.av.wss.addNotifier(setWSS)

    iAVSwitch.setInput("ENCODER")  # init on startup
    SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()

    def readChoices(procx, choices, default):
        try:
            with open(procx, "r") as myfile:
                procChoices = myfile.read().strip()
        except:
            procChoices = ""
        if procChoices:
            choiceslist = procChoices.split(" ")
            choices = [(item, _(item)) for item in choiceslist]
            default = choiceslist[0]
        return (choices, default)

    if SystemInfo["HasMultichannelPCM"]:

        def setMultichannelPCM(configElement):
            open(SystemInfo["HasMultichannelPCM"],
                 "w").write(configElement.value and "enable" or "disable")

        config.av.multichannel_pcm = ConfigYesNo(default=False)
        config.av.multichannel_pcm.addNotifier(setMultichannelPCM)

    if SystemInfo["CanDownmixAC3"]:

        def setAC3Downmix(configElement):
            open("/proc/stb/audio/ac3", "w").write(configElement.value)

        choices = [("downmix", _("Downmix")),
                   ("passthrough", _("Passthrough"))]
        default = "downmix"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/ac3_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.downmix_ac3 = ConfigSelection(choices=choices,
                                                default=default)
        config.av.downmix_ac3.addNotifier(setAC3Downmix)

    if SystemInfo["CanAC3Transcode"]:

        def setAC3plusTranscode(configElement):
            open("/proc/stb/audio/ac3plus", "w").write(configElement.value)

        choices = [("use_hdmi_caps", _("controlled by HDMI")),
                   ("force_ac3", _("convert to AC3"))]
        default = "force_ac3"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/ac3plus_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.transcodeac3plus = ConfigSelection(choices=choices,
                                                     default=default)
        config.av.transcodeac3plus.addNotifier(setAC3plusTranscode)

    if SystemInfo["CanDownmixDTS"]:

        def setDTSDownmix(configElement):
            open("/proc/stb/audio/dts", "w").write(configElement.value)

        choices = [("downmix", _("Downmix")),
                   ("passthrough", _("Passthrough"))]
        default = "downmix"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/dts_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.downmix_dts = ConfigSelection(choices=choices,
                                                default=default)
        config.av.downmix_dts.addNotifier(setDTSDownmix)

    if SystemInfo["CanDTSHD"]:

        def setDTSHD(configElement):
            open("/proc/stb/audio/dtshd", "w").write(configElement.value)

        choices = [("downmix", _("Downmix")),
                   ("force_dts", _("convert to DTS")),
                   ("use_hdmi_caps", _("controlled by HDMI")),
                   ("multichannel", _("convert to multi-channel PCM")),
                   ("hdmi_best", _("use best / controlled by HDMI"))]
        default = "downmix"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/dtshd_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.dtshd = ConfigSelection(choices=choices, default=default)
        config.av.dtshd.addNotifier(setDTSHD)

    if SystemInfo["CanDownmixAAC"]:

        def setAACDownmix(configElement):
            open("/proc/stb/audio/aac", "w").write(configElement.value)

        choices = [("downmix", _("Downmix")),
                   ("passthrough", _("Passthrough"))]
        default = "downmix"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/aac_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.downmix_aac = ConfigSelection(choices=choices,
                                                default=default)
        config.av.downmix_aac.addNotifier(setAACDownmix)

    if SystemInfo["CanDownmixAACPlus"]:

        def setAACDownmixPlus(configElement):
            open("/proc/stb/audio/aacplus", "w").write(configElement.value)

        choices = [("downmix", _("Downmix")),
                   ("passthrough", _("Passthrough")),
                   ("multichannel", _("convert to multi-channel PCM")),
                   ("force_ac3", _("convert to AC3")),
                   ("force_dts", _("convert to DTS")),
                   ("use_hdmi_cacenter", _("use_hdmi_cacenter")),
                   ("wide", _("wide")), ("extrawide", _("extrawide"))]
        default = "downmix"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/aacplus_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.downmix_aacplus = ConfigSelection(choices=choices,
                                                    default=default)
        config.av.downmix_aacplus.addNotifier(setAACDownmixPlus)

    if SystemInfo["CanAACTranscode"]:

        def setAACTranscode(configElement):
            open("/proc/stb/audio/aac_transcode",
                 "w").write(configElement.value)

        choices = [("off", _("off")), ("ac3", _("AC3")), ("dts", _("DTS"))]
        default = "off"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/aac_transcode_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.transcodeaac = ConfigSelection(choices=choices,
                                                 default=default)
        config.av.transcodeaac.addNotifier(setAACTranscode)

    if SystemInfo["CanWMAPRO"]:

        def setWMAPRO(configElement):
            open("/proc/stb/audio/wmapro", "w").write(configElement.value)

        choices = [("downmix", _("Downmix")),
                   ("passthrough", _("Passthrough")),
                   ("multichannel", _("convert to multi-channel PCM")),
                   ("hdmi_best", _("use best / controlled by HDMI"))]
        default = "downmix"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/wmapro_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.wmapro = ConfigSelection(choices=choices, default=default)
        config.av.wmapro.addNotifier(setWMAPRO)

    if SystemInfo["CanBTAudio"]:

        def setBTAudio(configElement):
            open("/proc/stb/audio/btaudio", "w").write(configElement.value)

        choices = [("off", _("Off")), ("on", _("On"))]
        default = "off"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/btaudio_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.btaudio = ConfigSelection(choices=choices, default="off")
        config.av.btaudio.addNotifier(setBTAudio)

    if SystemInfo["CanBTAudioDelay"]:

        def setBTAudioDelay(configElement):
            try:
                with open(SystemInfo["CanBTAudioDelay"], "w") as fd:
                    fd.write(format(configElement.value * 90, "x"))
            except:
                SystemInfo["CanBTAudioDelay"] = False

        config.av.btaudiodelay = ConfigSelectionNumber(-1000,
                                                       1000,
                                                       5,
                                                       default=0)
        config.av.btaudiodelay.addNotifier(setBTAudioDelay)

    try:
        SystemInfo["CanChangeOsdAlpha"] = open("/proc/stb/video/alpha",
                                               "r") and True or False
    except:
        SystemInfo["CanChangeOsdAlpha"] = False

    if SystemInfo["CanChangeOsdAlpha"]:

        def setAlpha(config):
            open("/proc/stb/video/alpha", "w").write(str(config.value))

        config.av.osd_alpha = ConfigSlider(default=255, limits=(0, 255))
        config.av.osd_alpha.addNotifier(setAlpha)

    if SystemInfo["HasScaler_sharpness"]:

        def setScaler_sharpness(config):
            myval = int(config.value)
            try:
                print "--> setting scaler_sharpness to: %0.8X" % myval
                open("/proc/stb/vmpeg/0/pep_scaler_sharpness",
                     "w").write("%0.8X" % myval)
                open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
            except IOError:
                print "couldn't write pep_scaler_sharpness"

        config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
        config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
    else:
        config.av.scaler_sharpness = NoSave(ConfigNothing())

    if SystemInfo["HasAutoVolume"]:

        def setAutoVolume(configElement):
            open(SystemInfo["HasAutoVolume"], "w").write(configElement.value)

        choices = [("none", _("off")), ("hdmi", "HDMI"), ("spdif", "SPDIF"),
                   ("dac", "DAC")]
        default = "none"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/avl_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.autovolume = ConfigSelection(choices=choices,
                                               default=default)
        config.av.autovolume.addNotifier(setAutoVolume)

    if SystemInfo["HasAutoVolumeLevel"]:

        def setAutoVolumeLevel(configElement):
            open(SystemInfo["HasAutoVolumeLevel"],
                 "w").write(configElement.value and "enabled" or "disabled")

        config.av.autovolumelevel = ConfigYesNo(default=False)
        config.av.autovolumelevel.addNotifier(setAutoVolumeLevel)

    if SystemInfo["Has3DSurround"]:

        def set3DSurround(configElement):
            open(SystemInfo["Has3DSurround"], "w").write(configElement.value)

        choices = [("none", _("off")), ("hdmi", _("HDMI")),
                   ("spdif", _("SPDIF")), ("dac", _("DAC"))]
        default = "none"
        if SystemInfo["CanProc"]:
            f = "/proc/stb/audio/3d_surround_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.surround_3d = ConfigSelection(choices=choices,
                                                default=default)
        config.av.surround_3d.addNotifier(set3DSurround)

    if SystemInfo["Has3DSpeaker"]:

        def set3DSpeaker(configElement):
            open(SystemInfo["Has3DSpeaker"], "w").write(configElement.value)

        config.av.speaker_3d = ConfigSelection(default="center",
                                               choices=[("center",
                                                         _("center")),
                                                        ("wide", _("wide")),
                                                        ("extrawide",
                                                         _("extra wide"))])
        config.av.speaker_3d.addNotifier(set3DSpeaker)

    if SystemInfo["Has3DSurroundSpeaker"]:

        def set3DSurroundSpeaker(configElement):
            open(SystemInfo["Has3DSurroundSpeaker"],
                 "w").write(configElement.value)

        config.av.surround_3d_speaker = ConfigSelection(
            default="center",
            choices=[("center", _("center")), ("wide", _("wide")),
                     ("extrawide", _("extra wide"))])
        config.av.surround_3d_speaker.addNotifier(set3DSurroundSpeaker)

    if SystemInfo["Has3DSurroundSoftLimiter"]:

        def set3DSurroundSoftLimiter(configElement):
            open(SystemInfo["Has3DSurroundSoftLimiter"],
                 "w").write(configElement.value and "enabled" or "disabled")

        config.av.surround_softlimiter_3d = ConfigYesNo(default=False)
        config.av.surround_softlimiter_3d.addNotifier(set3DSurroundSoftLimiter)

    if SystemInfo["HDMIAudioSource"]:

        def setHDMIAudioSource(configElement):
            open(SystemInfo["HDMIAudioSource"], "w").write(configElement.value)

        config.av.hdmi_audio_source = ConfigSelection(default="pcm",
                                                      choices=[("pcm", "PCM"),
                                                               ("spdif",
                                                                "SPDIF")])
        config.av.hdmi_audio_source.addNotifier(setHDMIAudioSource)

    def setVolumeStepsize(configElement):
        eDVBVolumecontrol.getInstance().setVolumeSteps(int(
            configElement.value))

    config.av.volume_stepsize = ConfigSelectionNumber(1, 10, 1, default=5)
    config.av.volume_stepsize.addNotifier(setVolumeStepsize)

    if SystemInfo["HasBypassEdidChecking"]:

        def setHasBypassEdidChecking(configElement):
            open(SystemInfo["HasBypassEdidChecking"],
                 "w").write("00000001" if configElement.value else "00000000")

        config.av.bypassEdidChecking = ConfigYesNo(default=False)
        config.av.bypassEdidChecking.addNotifier(setHasBypassEdidChecking)

    if SystemInfo["HasColorspace"]:

        def setHaveColorspace(configElement):
            open(SystemInfo["HasColorspace"], "w").write(configElement.value)

        if SystemInfo["HasColorspaceSimple"]:
            choices = [("Edid(Auto)", "auto"), ("Hdmi_Rgb", "RGB"),
                       ("444", "YCbCr 4:4:4"), ("422", "YCbCr 4:2:2"),
                       ("420", "YCbCr 4:2:0")]
            default = "Edid(Auto)"
        else:
            choices = [("auto", "auto"), ("rgb", "RGB"), ("420", "4:2:0"),
                       ("422", "4:2:2"), ("444", "4:4:4")]
            default = "auto"
        if os.path.exists("/proc/stb/video/hdmi_colorspace_choices"
                          ) and SystemInfo["CanProc"]:
            f = "/proc/stb/video/hdmi_colorspace_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.hdmicolorspace = ConfigSelection(choices=choices,
                                                   default=default)
        config.av.hdmicolorspace.addNotifier(setHaveColorspace)

    if SystemInfo["HasColordepth"]:

        def setHaveColordepth(configElement):
            open(SystemInfo["HasColordepth"], "w").write(configElement.value)

        choices = [("auto", "auto"), ("8bit", "8bit"), ("10bit", "10bit"),
                   ("12bit", "12bit")]
        default = "auto"
        if os.path.exists("/proc/stb/video/hdmi_colordepth_choices"
                          ) and SystemInfo["CanProc"]:
            f = "/proc/stb/video/hdmi_colordepth_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.hdmicolordepth = ConfigSelection(choices=choices,
                                                   default=default)
        config.av.hdmicolordepth.addNotifier(setHaveColordepth)

    if SystemInfo["HasHDMIpreemphasis"]:

        def setHDMIpreemphasis(configElement):
            open(SystemInfo["HasHDMIpreemphasis"],
                 "w").write("on" if configElement.value else "off")

        config.av.hdmipreemphasis = ConfigYesNo(default=False)
        config.av.hdmipreemphasis.addNotifier(setHDMIpreemphasis)

    if SystemInfo["HasColorimetry"]:

        def setColorimetry(configElement):
            open(SystemInfo["HasColorimetry"], "w").write(configElement.value)

        choices = [("auto", "auto"), ("bt2020ncl", "BT 2020 NCL"),
                   ("bt2020cl", "BT 2020 CL"), ("bt709", "BT 709")]
        default = "auto"
        if os.path.exists("/proc/stb/video/hdmi_colorimetry_choices"
                          ) and SystemInfo["CanProc"]:
            f = "/proc/stb/video/hdmi_colorimetry_choices"
            (choices, default) = readChoices(f, choices, default)
        config.av.hdmicolorimetry = ConfigSelection(choices=choices,
                                                    default=default)
        config.av.hdmicolorimetry.addNotifier(setColorimetry)

    if SystemInfo["HasHdrType"]:

        def setHdmiHdrType(configElement):
            open(SystemInfo["HasHdrType"], "w").write(configElement.value)

        config.av.hdmihdrtype = ConfigSelection(default="auto",
                                                choices={
                                                    "auto": _("auto"),
                                                    "none": "SDR",
                                                    "hdr10": "HDR10",
                                                    "hlg": "HLG",
                                                    "dolby": "Dolby Vision"
                                                })
        config.av.hdmihdrtype.addNotifier(setHdmiHdrType)

    if SystemInfo["HDRSupport"]:

        def setHlgSupport(configElement):
            open("/proc/stb/hdmi/hlg_support", "w").write(configElement.value)

        config.av.hlg_support = ConfigSelection(
            default="auto(EDID)",
            choices=[("auto(EDID)", _("controlled by HDMI")),
                     ("yes", _("force enabled")), ("no", _("force disabled"))])
        config.av.hlg_support.addNotifier(setHlgSupport)

        def setHdr10Support(configElement):
            open("/proc/stb/hdmi/hdr10_support",
                 "w").write(configElement.value)

        config.av.hdr10_support = ConfigSelection(
            default="auto(EDID)",
            choices=[("auto(EDID)", _("controlled by HDMI")),
                     ("yes", _("force enabled")), ("no", _("force disabled"))])
        config.av.hdr10_support.addNotifier(setHdr10Support)

        def setDisable12Bit(configElement):
            open("/proc/stb/video/disable_12bit",
                 "w").write("1" if configElement.value else "0")

        config.av.allow_12bit = ConfigYesNo(default=False)
        config.av.allow_12bit.addNotifier(setDisable12Bit)

        def setDisable10Bit(configElement):
            open("/proc/stb/video/disable_10bit",
                 "w").write("1" if configElement.value else "0")

        config.av.allow_10bit = ConfigYesNo(default=False)
        config.av.allow_10bit.addNotifier(setDisable10Bit)