3 À<×e‰ ã@snddlmZddlTddlZddlmZddlZddlZddl Z ddl Z ej j ƒZ eƒZGdd„dejƒZdS)é)Úhotplug)Ú*éN)Úcommandsc@s˜eZdZdZdd„Zdd„Zdd„Zdd „Zed d „ƒZ d d „Z dd„Z e ddddd„ƒZ edƒddd„ƒZe ddddd„ƒZedƒddd„ƒZdS) Ú 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|jjdƒjdƒD]"}|j|ƒ}|dkr*|jj|ƒq*WdS)NTZsoundzcard*Ú snd_hda_intelÚsnd_ac97_codec)rr) Z_devices_supportedÚsetZ_assigned_devicesZ _free_devicesZ_hardware_inventoryZ get_devicesZmatch_sys_nameÚ_device_module_nameÚadd)ÚselfÚdeviceZ module_name©rú"/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_init2szAudioPlugin._instance_initcCsdS)Nr)r rrrrÚ_instance_cleanup6szAudioPlugin._instance_cleanupc Csy|jjSdSdS)N)ÚparentZdriver)r r rrrr 9szAudioPlugin._device_module_namecCs dddœS)NrF)ÚtimeoutÚreset_controllerr)ÚclsrrrÚ_get_config_options?szAudioPlugin._get_config_optionscCsd|S)Nz$/sys/module/%s/parameters/power_saver)r r rrrÚ _timeout_pathFszAudioPlugin._timeout_pathcCsd|S)Nz//sys/module/%s/parameters/power_save_controllerr)r r rrrÚ_reset_controller_pathIsz"AudioPlugin._reset_controller_pathrT)Z per_devicec Csry t|ƒ}Wn"tk r.tjd|ƒdSX|dkrj|j|ƒ}|sftj|d||r^tjgndd|SdSdS)Nz!timeout value '%s' is not integerrz%dF)Úno_error) ÚintÚ ValueErrorÚlogÚerrorrÚcmdÚ write_to_fileÚerrnoÚENOENT)r Úvaluer ÚsimÚremoverÚsys_filerrrÚ _set_timeoutLs   zAudioPlugin._set_timeoutFcCs,|j|ƒ}tj||d}t|ƒdkr(|SdS)N)rr)rr Ú read_fileÚlen)r r Úignore_missingr'r$rrrÚ _get_timeout\s   zAudioPlugin._get_timeoutrcCsHtj|ƒ}|j|ƒ}tjj|ƒrD|s@tj|||r8tjgndd|SdS)NF)r) r Úget_boolrÚosÚpathÚexistsr!r"r#)r r$r r%r&Úvr'rrrÚ_set_reset_controllerds   z!AudioPlugin._set_reset_controllercCs:|j|ƒ}tjj|ƒr6tj|ƒ}t|ƒdkr6tj|ƒSdS)Nr)rr.r/r0r r)r*r-)r r r+r'r$rrrÚ_get_reset_controlleros      z!AudioPlugin._get_reset_controllerN)F)F)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrr Ú classmethodrrrZ command_setr(Z command_getr,r2r3rrrrrs    r)ÚrZ decoratorsZ tuned.logsZtunedZtuned.utils.commandsrr.r"ÚstructZglobZlogsÚgetrr ZPluginrrrrrÚs