<!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                 @   sX   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ej	j
 ZG dd dejZdS )   )base)*    N)commandsc               @   sj   e Zd ZdZdd Zdd Zedd Zdd	 Zd
d Z	dd Z
eddddd ZeddddZdS )	USBPlugina  
	`usb`::
	
	Sets autosuspend timeout of USB devices to the value specified by the
	[option]`autosuspend` option in seconds. If the [option]`devices`
	option is specified, the [option]`autosuspend` option applies to only
	the USB devices specified, otherwise it applies to all USB devices.
	+
	The value `0` means that autosuspend is disabled.
	+
	.To turn off USB autosuspend for USB devices `1-1` and `1-2`
	====
	----
	[usb]
	devices=1-1,1-2
	autosuspend=0
	----
	====
	c             C   sN   d| _ t | _t | _x*| jjdjddD ]}| jj|j q,W t	 | _
d S )NTusbZDEVTYPEZ
usb_device)Z_devices_supportedsetZ_free_devicesZ_assigned_devices_hardware_inventoryZget_devicesZmatch_propertyaddZsys_namer   _cmd)selfdevice r    /usr/lib/python3.6/plugin_usb.py_init_devices   s    zUSBPlugin._init_devicesc                s    fdd|D S )Nc                s   g | ]} j jd |qS )r   )r	   Z
get_device).0x)r   r   r   
<listcomp>*   s    z1USBPlugin._get_device_objects.<locals>.<listcomp>r   )r   Zdevicesr   )r   r   _get_device_objects)   s    zUSBPlugin._get_device_objectsc             C   s   dd iS )Nautosuspendr   )r   r   r   r   _get_config_options,   s    zUSBPlugin._get_config_optionsc             C   s   d|_ d|_d S )NTF)Z_has_static_tuningZ_has_dynamic_tuning)r   instancer   r   r   _instance_init2   s    zUSBPlugin._instance_initc             C   s   d S )Nr   )r   r   r   r   r   _instance_cleanup6   s    zUSBPlugin._instance_cleanupc             C   s   d| S )Nz)/sys/bus/usb/devices/%s/power/autosuspendr   )r   r   r   r   r   _autosuspend_sysfile9   s    zUSBPlugin._autosuspend_sysfiler   T)Z
per_devicec             C   sR   | j |}|d krd S |rdnd}|sN| j|}| jj|||rFtjgndd |S )N10F)no_error)Z_option_boolr   r   Zwrite_to_fileerrnoENOENT)r   valuer   Zsimremoveenablevalsys_filer   r   r   _set_autosuspend<   s    


zUSBPlugin._set_autosuspendFc             C   s   | j |}| jj||dj S )N)r   )r   r   Z	read_filestrip)r   r   Zignore_missingr$   r   r   r   _get_autosuspendI   s    
zUSBPlugin._get_autosuspendN)F)__name__
__module____qualname____doc__r   r   classmethodr   r   r   r   Zcommand_setr%   Zcommand_getr'   r   r   r   r   r   
   s   
r   ) r   Z
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsr   Zglobr   ZlogsgetlogZPluginr   r   r   r   r   <module>   s   
