£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
3
<e                 @   sn   d dl mZ d dlT ddlZddlmZ ddlZddlZddl	Z	ddl
Z
ejj Ze ZG dd dejZdS )   )hotplug)*    N)commandsc               @   s   e Zd ZdZdd Zdd Zdd Zdd	 Zed
d Z	dd Z
dd Zeddddd ZeddddZeddddd ZeddddZdS ) 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
	----
	====
	c             C   sT   d| _ t | _t | _x8| jjdjdD ]"}| j|}|dkr*| jj| q*W d S )NTZsoundzcard*snd_hda_intelsnd_ac97_codec)r   r   )	Z_devices_supportedsetZ_assigned_devicesZ_free_devicesZ_hardware_inventoryZget_devicesZmatch_sys_name_device_module_nameadd)selfdeviceZmodule_name r   "/usr/lib/python3.6/plugin_audio.py_init_devices(   s    
zAudioPlugin._init_devicesc             C   s   d|_ d|_d S )NTF)Z_has_static_tuningZ_has_dynamic_tuning)r   instancer   r   r   _instance_init2   s    zAudioPlugin._instance_initc             C   s   d S )Nr   )r   r   r   r   r   _instance_cleanup6   s    zAudioPlugin._instance_cleanupc          	   C   s   y|j jS    d S d S )N)parentZdriver)r   r   r   r   r   r
   9   s    zAudioPlugin._device_module_namec             C   s
   dddS )Nr   F)timeoutreset_controllerr   )clsr   r   r   _get_config_options?   s    zAudioPlugin._get_config_optionsc             C   s   d| S )Nz$/sys/module/%s/parameters/power_saver   )r   r   r   r   r   _timeout_pathF   s    zAudioPlugin._timeout_pathc             C   s   d| S )Nz//sys/module/%s/parameters/power_save_controllerr   )r   r   r   r   r   _reset_controller_pathI   s    z"AudioPlugin._reset_controller_pathr   T)Z
per_devicec             C   sr   yt |}W n" tk
r.   tjd|  d S X |dkrj| j|}|sftj|d| |r^tjgndd |S d S d S )Nz!timeout value '%s' is not integerr   z%dF)no_error)	int
ValueErrorlogerrorr   cmdwrite_to_fileerrnoENOENT)r   valuer   simremover   sys_filer   r   r   _set_timeoutL   s    
zAudioPlugin._set_timeoutFc             C   s,   | j |}tj||d}t|dkr(|S d S )N)r   r   )r   r    	read_filelen)r   r   ignore_missingr'   r$   r   r   r   _get_timeout\   s
    
zAudioPlugin._get_timeoutr   c             C   sH   t j|}| j|}tjj|rD|s@t j|||r8tjgndd |S d S )NF)r   )	r    get_boolr   ospathexistsr!   r"   r#   )r   r$   r   r%   r&   vr'   r   r   r   _set_reset_controllerd   s    

z!AudioPlugin._set_reset_controllerc             C   s:   | j |}tjj|r6tj|}t|dkr6tj|S d S )Nr   )r   r.   r/   r0   r    r)   r*   r-   )r   r   r+   r'   r$   r   r   r   _get_reset_controllero   s    


z!AudioPlugin._get_reset_controllerN)F)F)__name__
__module____qualname____doc__r   r   r   r
   classmethodr   r   r   Zcommand_setr(   Zcommand_getr,   r2   r3   r   r   r   r   r      s   
r   ) r   Z
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsr   r.   r"   structZglobZlogsgetr   r    ZPluginr   r   r   r   r   <module>   s   
