<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</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   
