3 Yd @sfddlmZddlTddlZddlmZddlZddlZddl Z ej j Z eZ GdddejZdS))hotplug)*N)commandsc@seZdZdZddZddZddZdd Zed d Z d d Z ddZ e dddddZ eddddZe dddddZeddddZdS) AudioPlugina `audio`:: Sets audio cards power saving options. The plug-in sets the auto suspend timeout for audio codecs to the value specified by the [option]`timeout` option. + Currently, the `snd_hda_intel` and `snd_ac97_codec` codecs are supported and the [option]`timeout` value is in seconds. To disable auto suspend for these codecs, set the [option]`timeout` value to `0`. To enforce the controller reset, set the option [option]`reset_controller` to `true`. Note that power management is supported per module. Hence, the kernel module names are used as device names. + .Set the timeout value to 10s and enforce the controller reset ==== ---- [audio] timeout=10 reset_controller=true ---- ==== cCsTd|_t|_t|_x8|jjdjdD]"}|j|}|dkr*|jj|q*WdS)NTZsoundzcard* snd_hda_intelsnd_ac97_codec)rr) Z_devices_supportedsetZ_assigned_devicesZ _free_devicesZ_hardware_inventoryZ get_devicesZmatch_sys_name_device_module_nameadd)selfdeviceZ module_namer"/usr/lib/python3.6/plugin_audio.py _init_devices's zAudioPlugin._init_devicescCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning)r instancerrr_instance_init1szAudioPlugin._instance_initcCsdS)Nr)r rrrr_instance_cleanup5szAudioPlugin._instance_cleanupc Csy|jjSdSdS)N)parentZdriver)r r rrrr 8szAudioPlugin._device_module_namecCs dddS)NrF)timeoutreset_controllerr)clsrrr_get_config_options>szAudioPlugin._get_config_optionscCsd|S)Nz$/sys/module/%s/parameters/power_saver)r r rrr _timeout_pathEszAudioPlugin._timeout_pathcCsd|S)Nz//sys/module/%s/parameters/power_save_controllerr)r r rrr_reset_controller_pathHsz"AudioPlugin._reset_controller_pathrT)Z per_devicec Csby t|}Wn"tk r.tjd|dSX|dkrZ|j|}|sVtj|d||SdSdS)Nz!timeout value '%s' is not integerrz%d)int ValueErrorlogerrorrcmd write_to_file)r valuer simrsys_filerrr _set_timeoutKs  zAudioPlugin._set_timeoutFcCs,|j|}tj||d}t|dkr(|SdS)N)Zno_errorr)rr read_filelen)r r ignore_missingr#r!rrr _get_timeoutZs   zAudioPlugin._get_timeoutrcCs8tj|}|j|}tjj|r4|s0tj|||SdS)N)rget_boolrospathexistsr )r r!r r"vr#rrr_set_reset_controllerbs    z!AudioPlugin._set_reset_controllercCs:|j|}tjj|r6tj|}t|dkr6tj|SdS)Nr)rr*r+r,rr%r&r))r r r'r#r!rrr_get_reset_controllerls      z!AudioPlugin._get_reset_controllerN)F)F)__name__ __module__ __qualname____doc__rrrr classmethodrrrZ command_setr$Z command_getr(r.r/rrrrr s    r)rZ decoratorsZ tuned.logsZtunedZtuned.utils.commandsrr*structZglobZlogsgetrrZPluginrrrrrs