HEX
Server: Apache
System: Linux nc-ph-4101.simplemoneygoals.com 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 12 09:45:05 EST 2025 x86_64
User: dailygoldindex (1004)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_video.cpython-39.opt-1.pyc
a

,�g��@s`ddlmZddlTddlZddlmZddlZddlZddl	Z	ej
��ZGdd�dej
�ZdS)�)�base)�*�N)�commandscs�eZdZdZ�fdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zddd�Ze
ddd�dd��Zed�d dd��Ze
ddd�dd��Zed�d!dd��Z�ZS)"�VideoPluginaf
	Sets various power saving features on video cards.
	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.

	.Setting powersave level for the Radeon video card to high
	====
	----
	[video]
	radeon_powersave=high
	----
	====

	Mobile hardware with amdgpu driven eDP panels can be configured
	with the [option]`panel_power_savings` option.
	This accepts a value range from 0 to 4, where 4 is the highest power savings
	but will trade off color accuracy.
	cstt|�j|i|��dS�N)�superr�__init__)�self�args�kwargs��	__class__��>/usr/lib/python3.9/site-packages/tuned/plugins/plugin_video.pyr	/szVideoPlugin.__init__cCsnd|_t�|_t�|_|j�d��d�D]8}|�|j�}|D]"}t	j
�||�r<|j�|j�q<q(t
�|_dS)NT�drmzcard*-*)Z_devices_supported�setZ
_free_devicesZ_assigned_devices�_hardware_inventoryZget_devicesZmatch_sys_name�_filesZsys_name�os�path�exists�addr�_cmd)r
�device�attrs�attrrrr�
_init_devices2szVideoPlugin._init_devicescs�fdd�|D�S)Ncsg|]}�j�d|��qS)r)rZ
get_device)�.0�x�r
rr�
<listcomp>@�z3VideoPlugin._get_device_objects.<locals>.<listcomp>r)r
Zdevicesrr r�_get_device_objects?szVideoPlugin._get_device_objectscCs
ddd�S)N)�radeon_powersave�panel_power_savingsrr rrr�_get_config_optionsBs�zVideoPlugin._get_config_optionscCsd|_d|_dS)NFT)Z_has_dynamic_tuningZ_has_static_tuning�r
�instancerrr�_instance_initIszVideoPlugin._instance_initcCsdSrrr'rrr�_instance_cleanupMszVideoPlugin._instance_cleanupcCsd|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_statez,/sys/class/drm/%s/amdgpu/panel_power_savings)�method�profile�	dpm_stater%r)r
rrrrrPs
�zVideoPlugin._filesFcCs~tj�|�|�d�sdSt|�||��}||krHt�d||f�|St�d||f�|sv|j�	|�|�d|�rz|SdS)zTApply the target value to the panel_power_savings file if it doesn't already have itr%Nz%panel_power_savings for %s already %sz%s panel_power_savings -> %s)
rrrr�int�_get_panel_power_savings�log�infor�
write_to_file)r
r�targetr(�sim�currentrrr�apply_panel_power_saving_targetXs
�z+VideoPlugin.apply_panel_power_saving_targetr$T)Z
per_devicec
Csr|�|�}tt�dd|����}tj�|d�sF|sFt�	d|�dS|D�] }|dvr�|s�|j
j|dd|rvtj
gndd�r�|j
j|d||r�tj
gndd�r�|SqJ|d	kr�|s�|j
j|dd	|r�tj
gndd�r�d	SqJ|d
v�rV|�sl|td�d�}	|j
j|dd|�rtj
gndd��rl|j
j|d
|	|�rBtj
gndd��rl|SqJ|�sft�d�dSqJdS)Nz#(\s*:\s*)|(\s+)|(\s*;\s*)|(\s*,\s*)� r+�)radeon_powersave is not supported on '%s')�default�autoZlowZmidZhighr,F�Zno_error�dynpm)zdpm-batteryzdpm-balancedzdpm-performance�dpm-�dpmr-z$Invalid option for radeon_powersave.)r�str�re�sub�splitrrrr0�debugrr2�errno�ENOENT�len�warning)
r
�valuerr(r4�remove�	sys_files�va�v�staterrr�_set_radeon_powersavemsL

���
�
���

z!VideoPlugin._set_radeon_powersavecCs�|�|�}tj�|d�s,t�d|�dS|jj|d|d���}|dkr`|j�|d���S|dkrl|S|dkr�d|j�|d���SdSdS)	Nr+r8r;r,r<r>r=r-)	rrrrr0rCr�	read_file�strip)r
rr(�ignore_missingrJr+rrr�_get_radeon_powersave�s
z!VideoPlugin._get_radeon_powersaver%cCsbzt|d�}Wn"ty0t�d|�YdS0|tdd�vrP|�||||�St�d|�dS)z!Set the panel_power_savings value�
z(Invalid value %s for panel_power_savingsNr�)r.�
ValueErrorr0rG�ranger6)r
rHrr(r4rIrrr�_set_panel_power_savings�sz$VideoPlugin._set_panel_power_savingscCsJtj�|�|�d�s(t�d|�dS|�|�d}|jj||d���S)z)Get the current panel_power_savings valuer%z,panel_power_savings is not supported on '%s'Nr;)	rrrrr0rCrrOrP)r
rr(rQ�fnamerrrr/�s
z$VideoPlugin._get_panel_power_savings)F)F)F)�__name__�
__module__�__qualname__�__doc__r	rr#�classmethodr&r)r*rr6Zcommand_setrNZcommand_getrRrWr/�
__classcell__rrr
rrs$#




#


r)�rZ
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsrrrDr@Zlogs�getr0ZPluginrrrrr�<module>s