Edit File: plugin_video.cpython-36.pyc
3 ��c� � @ sX d dl mZ d dlT ddlZddlmZ ddlZddlZej j � ZG dd� dej�Z dS )� )�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>8 s z3VideoPlugin._get_device_objects.<locals>.<listcomp>r )r Zdevicesr )r r �_get_device_objects7 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_init@ s zVideoPlugin._instance_initc C s d S )Nr )r r r r r �_instance_cleanupD 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_filesG s z#VideoPlugin._radeon_powersave_filesr T)Z per_devicec C s | j |�}ttjdd|��j� }tjj|d �sF|sFtj d| � d S x�|D ]�}|dkr�|s�| j j|d d �r�| j j|d |�r�|S qL|dkr�|s�| j j|d d�r�dS qL|dk� r�|�s|td�d � }| j j|d d��r| j j|d |��r|S qL|�stj d� d S qLW d S )Nz#(\s*:\s*)|(\s+)|(\s*;\s*)|(\s*,\s*)� r z)radeon_powersave is not supported on '%s'�default�auto�low�mid�highr �dynpm�dpm-battery�dpm-balanced�dpm-performancezdpm-�dpmr z$Invalid option for radeon_powersave.)r r r! r"