Пример #1
0
def smbus_init():
    # Accessing ports < 0x400 needs special privileges    
    ioport.iopl(3)
    # Try to identify whether there's "something" at 0x400 with the status register
    ioport.outb(0xff, SMBHSTSTS)
    if ioport.inb(SMBHSTSTS) & 0x01:
        return False
    return True
Пример #2
0
    def __init__(self, conn, manu, model, acpi_base, brn_path, bt_path, wlan_path, hwkey_control, obj_path="/org/eee/Eee/EeePc"):
        dbus.service.Object.__init__(self, conn, obj_path)
        self.fakekey_dev = open(glob.glob("/dev/input/by-path/platform-*-kbd")[0], "w")
        
        # Configuration
        self._config = ConfigParser.ConfigParser()
        self._config.read(config.CONFIG_FILE)
        # Insert default values for all non-specified fields
        for name, section in config.DEFAULTS.iteritems():
            if not self._config.has_section(name):
                self._config.add_section(name)
            for k, v in section.iteritems():
                if not self._config.has_option(name, k):
                    self._config.set(name, k, v)
        
        self.fan_control = self._config.getboolean("general", "fan-control")
        method = self._config.get("general", "fsb-method").strip()
        # for autodetection, always use she
        if model == "AUTODETECT" and method not in ("she", "she-uv"):
            method = "she"
        if (method in she.METHOD) and she.METHOD[method].validate():
                self.fsb = she.METHOD[method](model, self.fsb_changed)
        else:
                log("FSB control method not found or invalid, using dummy fallback")
                self.fsb = she.Dummy(model, self.fsb_changed)
        
        self.fan_max_speed = self._config.getint("fan", "max-speed")
        self.fan_interval = self._config.getint("fan", "interval")
        self.fan_critical = self._config.getint("fan", "critical-temperature")
        self._fc = EeeFanControlHW();
        
        # Set up EC address space
        #ioport.ioperm(utils.EC_BASE, 4, 1)
        ioport.iopl(3)
    
        # We don't need to deal with the sound/brightness keys anymore
        # when eeepc_laptop is used
        self.hwkey_control = hwkey_control

        self.acpi_base = acpi_base
        self.brn_path = brn_path
        self.bt_path = bt_path
        self.wlan_path = wlan_path

        # The wlan module and device are populated by the model definitions
        self.wlan_module = ""
        self.wlan_interface = ""

        self.model_string = model
        self.manufacturer_string = manu
        # Initialize model
        my_model = models.MODEL_MAP[self.model_string]
        self.model = my_model(self)
        self.model.wlan_path = self.wlan_path

        # WiFi overrides
        if self._config.has_option("general", "wlan-module"):
            log("overriding WiFi module")
            self.model.wlan_module = self._config.get("general", "wlan-module").strip()
        if self._config.has_option("general", "wlan-device"):
            log("overriding WiFi device")
            self.model.wlan_dev = self._config.get("general", "wlan-device").strip()

        # Extended brightness overrides
        if (self.model.extended_brightness and not
        self._config.getboolean("brightness", "extended-brightness")):
            log("disabling brightness overdrive")
            self.model.extended_brightness = False

        if self._config.has_option("brightness", "minimum"):
            br = self._config.get("brightness", "minimum")
            self.model.brightness_superlow = int(br, 0) 
        if self._config.has_option("brightness", "maximum"):
            br = self._config.get("brightness", "maximum")
            self.model.brightness_superhigh = int(br, 0)

        # Does the bluetooth path really exist?
        # Some model variants do not have bluetooth...
        if not self.bt_path:
            self.model.features = filter(lambda x: x != "bt", self.model.features)
            self.bt_path = "/dev/null"

        # Initialize state
        self.brn_state = self.get_brightness() + 0x20
        self.brn_ext_state = 0
        self.fan_timeout = False
        self.last_fsb = None
        
        # Fan control?
        if self.fan_control: self.start_fan_control()