Your IP : 18.216.57.57
3
�<�e� � @ s` d dl mZ d dlT ddlZddlmZ ddlZddlZddl Z ej
j� ZG dd� dej
�ZdS )� )�base)�*� N)�commandsc @ sj e Zd ZdZdd� Zdd� Zedd� �Zdd � Zd
d� Z dd
� Z
eddd�dd� �Ze
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
----
====
c C sT d| _ t� | _t� | _x0| jjd�jd�jdd�D ]}| jj|j � q2W t
� | _d S )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_devicesc s � fdd�|D �S )Nc s g | ]}� j jd |��qS )r )r Z
get_device)�.0�x)r r r �
<listcomp>9 s z3VideoPlugin._get_device_objects.<locals>.<listcomp>r )r Zdevicesr )r r �_get_device_objects8 s zVideoPlugin._get_device_objectsc C s dd iS )N�radeon_powersaver )r r r r �_get_config_options; s zVideoPlugin._get_config_optionsc C s d|_ d|_d S )NFT)Z_has_dynamic_tuningZ_has_static_tuning)r �instancer r r �_instance_initA s zVideoPlugin._instance_initc C s d S )Nr )r r r r r �_instance_cleanupE s zVideoPlugin._instance_cleanupc C s d| 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
r r r �_radeon_powersave_filesH s z#VideoPlugin._radeon_powersave_filesr T)Z
per_devicec C sl | j |�}ttjdd|��j� }tjj|d �sF|sFtj d| � d S �x|D �]}|dkr�|s�| j
j|d d
|rztj
gndd�r�| j
j|d
||r�tj
gndd�r�|S qN|d
kr�|s�| j
j|d d
|r�tj
gndd�r�d
S qN|dk�rP|�sd|td�d � }| j
j|d d|�rtj
gndd��rd| j
j|d ||�r@tj
gndd��rd|S qN|�s`tj d� d S qNW d S )Nz#(\s*:\s*)|(\s+)|(\s*;\s*)|(\s*,\s*)� r z)radeon_powersave is not supported on '%s'�default�auto�low�mid�highr F)�no_error�dynpm�dpm-battery�dpm-balanced�dpm-performancezdpm-�dpmr z$Invalid option for radeon_powersave.)r r r! r"