a h @snddlmZddlTddlZddlmZddlZddlZddl Z ddl Z ej Z eZGdddejZdS))hotplug)*N)commandsc@seZdZdZddZddZddZdd Zed d Z d d Z ddZ e dddddZ eddddZe dddddZeddddZdS) AudioPlugina Sets audio cards power saving options. The plug-in sets the auto suspend timeout for audio codecs to the value specified by the [option]`timeout` option. Currently, the `snd_hda_intel` and `snd_ac97_codec` codecs are supported and the [option]`timeout` value is in seconds. To disable auto suspend for these codecs, set the [option]`timeout` value to `0`. To enforce the controller reset, set the option [option]`reset_controller` to `true`. Note that power management is supported per module. Hence, the kernel module names are used as device names. .Set the timeout value to 10s and enforce the controller reset ==== ---- [audio] timeout=10 reset_controller=true ---- ==== cCsPd|_t|_t|_|jddD]"}||}|dvr(|j|q(dS)NTZsoundzcard*)Z snd_hda_intelZsnd_ac97_codec) Z_devices_supportedsetZ_assigned_devicesZ _free_devicesZ_hardware_inventoryZ get_devicesZmatch_sys_name_device_module_nameadd)selfdeviceZ module_namer >/usr/lib/python3.9/site-packages/tuned/plugins/plugin_audio.py _init_devices&s zAudioPlugin._init_devicescCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuningr instancer r r _instance_init0szAudioPlugin._instance_initcCsdSNr rr r r _instance_cleanup4szAudioPlugin._instance_cleanupcCsz |jjWSYdS0dSr)parentZdriverr r r r r r7s zAudioPlugin._device_module_namecCs dddS)NrT)timeoutreset_controllerr )clsr r r _get_config_options=szAudioPlugin._get_config_optionscCsd|S)Nz$/sys/module/%s/parameters/power_saver rr r r _timeout_pathDszAudioPlugin._timeout_pathcCsd|S)Nz//sys/module/%s/parameters/power_save_controllerr rr r r _reset_controller_pathGsz"AudioPlugin._reset_controller_pathrT)Z per_devicecCsrz t|}Wn"ty.td|YdS0|dkrj||}|sftj|d||r^tjgndd|SdSdS)Nz!timeout value '%s' is not integerrz%dFZno_error) int ValueErrorlogerrorrcmd write_to_fileerrnoENOENT)r valuer rsimremoversys_filer r r _set_timeoutJs    zAudioPlugin._set_timeoutFcCs,||}tj||d}t|dkr(|SdS)Nrr)rr! read_filelenr r rZignore_missingr(r%r r r _get_timeoutZs   zAudioPlugin._get_timeoutrcCsHt|}||}tj|rD|s@tj|||r8tjgndd|SdS)NFr) r!get_boolrospathexistsr"r#r$)r r%r rr&r'vr(r r r _set_reset_controllerbs   z!AudioPlugin._set_reset_controllercCs:||}tj|r6t|}t|dkr6t|SdS)Nr)rr/r0r1r!r*r+r.r,r r r _get_reset_controllerms      z!AudioPlugin._get_reset_controllerN)F)F)__name__ __module__ __qualname____doc__rrrr classmethodrrrZ command_setr)Z command_getr-r3r4r r r r rs"       r)rZ decoratorsZ tuned.logsZtunedZtuned.utils.commandsrr/r#structglobZlogsgetrr!ZPluginrr r r r s