Your IP : 18.216.57.57


Current Path : /usr/lib/python3.6/site-packages/tuned/plugins/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/tuned/plugins/__pycache__/plugin_video.cpython-36.pyc

3

�<�e��@s`ddlmZddlTddlZddlmZddlZddlZddl	Z	ej
j�ZGdd�dej
�ZdS)�)�base)�*�N)�commandsc@sjeZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
eddd�dd��Ze
d�ddd��ZdS)�VideoPlugina�
	`video`::
	
	Sets various powersave levels on video cards. Currently, only the
	Radeon cards are supported. The powersave level can be specified
	by using the [option]`radeon_powersave` option. Supported values are:
	+
	--
	* `default`
	* `auto`
	* `low`
	* `mid`
	* `high`
	* `dynpm`
	* `dpm-battery`
	* `dpm-balanced`
	* `dpm-perfomance`
	--
	+
	For additional detail, see
	link:https://www.x.org/wiki/RadeonFeature/#kmspowermanagementoptions[KMS Power Management Options].
	+
	NOTE: This plug-in is experimental and the option might change in future releases.
	+
	.To set the powersave level for the Radeon video card to high
	====
	----
	[video]
	radeon_powersave=high
	----
	====
	cCsTd|_t�|_t�|_x0|jjd�jd�jdd�D]}|jj|j	�q2Wt
�|_dS)NT�drmzcard*ZDEVTYPEZ	drm_minor)Z_devices_supported�setZ
_free_devicesZ_assigned_devices�_hardware_inventoryZget_devicesZmatch_sys_nameZmatch_property�addZsys_namer�_cmd)�self�device�r�"/usr/lib/python3.6/plugin_video.py�
_init_devices-s zVideoPlugin._init_devicescs�fdd�|D�S)Ncsg|]}�jjd|��qS)r)r	Z
get_device)�.0�x)rrr�
<listcomp>9sz3VideoPlugin._get_device_objects.<locals>.<listcomp>r)rZdevicesr)rr�_get_device_objects8szVideoPlugin._get_device_objectscCsddiS)N�radeon_powersaver)rrrr�_get_config_options;szVideoPlugin._get_config_optionscCsd|_d|_dS)NFT)Z_has_dynamic_tuningZ_has_static_tuning)r�instancerrr�_instance_initAszVideoPlugin._instance_initcCsdS)Nr)rrrrr�_instance_cleanupEszVideoPlugin._instance_cleanupcCsd|d|d|d�S)Nz%/sys/class/drm/%s/device/power_methodz&/sys/class/drm/%s/device/power_profilez(/sys/class/drm/%s/device/power_dpm_state)�method�profile�	dpm_stater)rr
rrr�_radeon_powersave_filesHsz#VideoPlugin._radeon_powersave_filesrT)Z
per_devicec	Csl|j|�}ttjdd|��j�}tjj|d�sF|sFtj	d|�dS�x|D�]}|dkr�|s�|j
j|dd
|rztj
gndd�r�|j
j|d
||r�tj
gndd�r�|SqN|d
kr�|s�|j
j|dd
|r�tj
gndd�r�d
SqN|dk�rP|�sd|td�d�}|j
j|dd|�rtj
gndd��rd|j
j|d||�r@tj
gndd��rd|SqN|�s`tj	d�dSqNWdS)Nz#(\s*:\s*)|(\s+)|(\s*;\s*)|(\s*,\s*)� rz)radeon_powersave is not supported on '%s'�default�auto�low�mid�highrF)�no_error�dynpm�dpm-battery�dpm-balanced�dpm-performancezdpm-�dpmrz$Invalid option for radeon_powersave.)rr r!r"r#)r&r'r()r�str�re�sub�split�os�path�exists�log�warnrZ
write_to_file�errno�ENOENT�len)	r�valuer
Zsim�remove�	sys_filesZva�v�staterrr�_set_radeon_powersaveOs>


z!VideoPlugin._set_radeon_powersaveFcCsr|j|�}|jj|d|d�j�}|dkr>|jj|d�j�S|dkrJ|S|dkrjd|jj|d�j�SdSdS)Nr)r$rr%r)zdpm-r)rrZ	read_file�strip)rr
Zignore_missingr8rrrr�_get_radeon_powersavess
z!VideoPlugin._get_radeon_powersaveN)F)�__name__�
__module__�__qualname__�__doc__rr�classmethodrrrrZcommand_setr;Zcommand_getr=rrrrrs $r)�rZ
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsrr.r3r+Zlogs�getr1ZPluginrrrrr�<module>s


?>