+
    Ki  c                   s    R t ^ RIt^ RIt^ RIHtHtHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt Rt]R R	 l4       tR
 R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR# )ztHardware driver related utilities

Everything in this module should rely on /proc or /sys only, no executable calls
N)DictIterableList)cache_single)GlxInfo)logger)read_process_outputi  c                F    V ^8  d   QhR\         \        \        3,          /#    returnr    strZformat   "A/usr/lib/python3.14/site-packages/lutris/util/graphics/drivers.py__annotate__r      s     A AS#X A    c                 s   a RoR V3R llp R R lp V ! 4       pV'       d   V#  V! 4       #   \          d)   p\        P                  ! RST4        Rp?T! 4       # Rp?ii ; i)z'Return information about Nvidia driversz/proc/driver/nvidia/versionc                r   r   r   r   r   r   r   ,get_nvidia_driver_info.<locals>.__annotate__   s     & &DcN &r   c                  s8  <  \         P                  P                  S4      '       g   / # \        SR R7      ;_uu_ 4       p V P	                  4       pRRR4        X^ ,          P                  R4      ^,          P                  4       P                  4       pRT9   d'   RT^ ,          R	T^,          R
T^,          RT^,          /# RT^ ,          R	T^,          R
T^,          RT^,          RRP                  TR,          4      /#   + '       g   i     L; i  \
         d    \        P                  ! RS4       / u # \         d&   p\        P                  ! RSTR7       / u Rp?# Rp?ii ; i  \         d%   p\        P                  ! RST4       / u Rp?# Rp?ii ; i)utf-8ZencodingNz-Could not access %s. Falling back to glxinfo.z<Unexpected error when accessing %s. Falling back to glxinfo.Zexc_infoz: ZOpenvendorplatformarchversionZdateZ :i   NNz/Unable to parse %s. Falling back to glxinfo: %s)ospathexistsopen	readlinesPermissionErrorr   infoOSErrorwarningsplitstripZjoin
IndexError)Zversion_filecontenteZnvrm_versionexversion_file_paths        r   read_from_procZ.get_nvidia_driver_info.<locals>.read_from_proc   si   	77>>"344	''::l&002 ; 	"1:++D1!4::<BBDL%l1oQLO|A	  ,q/LOQ<?b!12 3 ;: 	 KKGIZ[I 	NNN!
 I	0  	NNLN_acdI	su   $D D D C?D A'E* =E* ?D	
D D $E'8E'E'E"E'"E'*F5FFFc                r   r   r   r   r   r   r   r   @   s     
 
DcN 
r   c                  s   \        4       p \        R R.4      p\        R R.4      pV P                  pRVP                  4       9  d   \	        RV,          4      hRVRVRVRV P
                  P                  ^R	7      R
,          /# )Zuname-sz-mZnvidiaz0Expected NVIDIA vendor information, received %s.r   r   r   r   Zmaxspliti)r   r   opengl_vendorZlowerZRuntimeErrorZopengl_versionZrsplit)glx_infor   r   r          r   invoke_glxinfoZ.get_nvidia_driver_info.<locals>.invoke_glxinfo@   s    9&7"GT?3''6<<>)QTZZ[[fDx..55q5A"E	
 	
r   zUnable to read from '%s': %sN)Z	Exceptionr   	exception)r*   r0   Z	from_procr(   r)   s       @r   get_nvidia_driver_infor2      sv     6& &P
P"$	 
   P79JBOOPs   - - A AA c                :    V ^8  d   QhR\         \        ,          /# r   )r   r   r   r   r   r   r   X   s     : :DI :r   c                 sj   Rp  \         P                  ! V 4      #   \         d    \        P                  ! RT 4        M/\
         d#   p\        P                  ! RYR7        Rp?MRp?ii ; i\        . RO4      P                  4       pT Uu. uF  q3P                  ^R7      ^ ,          NK  	  up# u upi )zReturn the list of Nvidia GPUsz/proc/driver/nvidia/gpusz-Permission denied to %s. Using lspci instead.z3Unexpected error accessing %s. Using lspci instead.r   Nr,   )lspciz-Dz-nz-dz
10de::0300)
r   listdirr   r   r    r!   r"   r   
splitlinesr#   )Zgpus_dirr'   Zvaluesliner/   r   get_nvidia_gpu_idsr8   X   s    )Hdzz(## OCXN dLhccd !!JKVVXF289&$JJJ"1%%&999s&    "A*A*A*A%%A*!B0c                R    V ^8  d   QhR\         R\        \         \         3,          /# r	   gpu_idr
   r   r    r   r   r   r   r   f   s"     - - -S#X -r   c                s   RV  R2p \        VRR7      ;_uu_ 4       pVP                  4       pRRR4       / pX F)  pVP                  R^4      w  rgVP                  4       WF&   K+  	  V#   + '       g   i     LC; i  \         d    \
        P                  ! RT4        M0\         d$   p\
        P                  ! RTTR	7        Rp?MRp?ii ; i\        T 4      # )
zReturn details about a GPUz/proc/driver/nvidia/gpus/z/informationr   r   N:z.Permission denied to %s. Detecting with lspci.z3Unexpected error accessing %s. Detecting with lspcir   )
r   r   r#   r$   r   r   r    r!   r"   get_lspci_nvidia_gpu_info)	r;   Zgpu_info_fileZ	info_filer&   r    r7   keyvaluer'   s	   &        r   get_nvidia_gpu_inforA   f   s    /x|DM-'22i))+G 3 DC+JCDI   32 UDmT 
A	
 	

 %V,,s9   A< A)A< )A9	4A< <"C C)C*CCc                r9   r:   r<   r   r   r   r   r   }   s"      c d38n r   c                 s*   \        R RRV .4      p\        P                  ! RV4      pV'       d   VP                  ^4      pM\        P
                  ! R4       Rp\        P                  ! RV4      pV'       d   VP                  ^4      pM\        P
                  ! R4       RpR	R
V 2R\        V4      R\        V 4      /pVP                  4        F@  pRV9  d   K  VP                  R^4      w  rV	P                  4       WhP                  4       &   KB  	  V# )r4   z-vr+   z NVIDIA Corporation \w+ \[(.+?)\]z"Could not detect NVIDIA GPU model.ZUnknownzIRQ ([0-9]+)z%Could not detect GPU IRQ information.NZModelzNVIDIA ZIRQzBus Locationr=   )
r   researchZgroupr   errorr   r6   r#   r$   )
r;   Z
lspci_dataZ
model_infoZmodelZirq_infoZirqr    r7   r?   r@   s
   &         r   r>   r>   }   s    $gtT6%BCJ>
KJ  #9:yy4HnnQ<= 	75'"s3xFD
 %%'d?ZZQ'
!KKMYY[	 (
 Kr   c                $    V ^8  d   QhR\         /# r   boolr   r   r   r   r      s     . .4 .r   c                 s    \         P                  P                  R4      #   \         d    \        P
                  ! R4        Mi ; i \        RRR7      ;_uu_ 4       p T P                  4       pRRR4       M  + '       g   i     M; i\        \        P                  ! RX\        P                  R7      4      #   \         d    \        P                  ! R	4        Mi ; i\        4       pR
TP                  9   # )zxReturn true if the Nvidia drivers are currently in use.

Note: This function may not detect use of the nouveau drivers.
z/proc/driver/nvidiazZCould not determine whether /proc/driver/nvidia exists. Falling back to alternative methodz/proc/modulesr   r   Nz^nvidia )Zflagsz[Could not access /proc/modules to find the Nvidia drivers. Nvidia card may not be detected.ZNVIDIA)r   r   r   r!   r   r    r   ZreadrG   rB   rC   Z	MULTILINErD   r   r-   )ZfZmodulesr.   s      r   	is_nvidiarH      s    rww~~344 rpqrt/G44ffhG 5444BIIk7",,GHH trstyHx----s9   ! !AA	B; A8/	B; 8B	7B; ;!CCc                r3   r   )r   r   r   r   r   r   r      s      x} r   c               #  s^  "   \         P                  P                  R4      '       g   \        P                  ! R4       R#  \         P
                  ! R4      p T  F&  p\        P                  ! RT4      '       g   K"  Tx  K(  	  R#   \         d    \        P                  ! R4        R# i ; i5i)z#Return GPUs connected to the systemz/sys/class/drmz No GPU available on this system!N/sys/class/drm/zHYour system does not allow reading from /sys/class/drm, no GPU detected.z^card\d$)	r   r   r   r   rD   r5   r   rB   Zmatch)ZcardlistZcardnames     r   get_gpu_cardsrJ      s     77>>*++78::/0
 88K**N 	  _`s/   >B-B B-;
B-!B*&B-)B**B-c                r9   )r	   cardr
   r<   r   r   r   r   r      s"      s tCH~ r   c                sT   RRRRRR/p \        RV  R2RR7      ;_uu_ 4       pVP                  4       pR	R	R	4       X F)  pTP                  R^4      w  rVTP                  4       Y&   K+  	  T#   + '       g   i     LA; i  \         d    \        P                  ! R
T 4       Tu # i ; i)zReturn information about a GPUDRIVERZ ZPCI_IDZPCI_SUBSYS_IDrI   z/device/ueventr   r   Nz-Unable to read driver information for card %sZ=)r   r   ZFileNotFoundErrorr   rD   r#   r$   )rK   ZinfosZcard_ueventr&   r7   r?   r@   s   &      r   get_gpu_inforM      s    r8R"=EOD687KK{!++-G L
 ZZQ'
[[]
  L LK DdKs-   B  A-B  -A=	8B  =B   $B'&B'c                rE   r   rF   r   r   r   r   r      s       r   c                 s\    \        4        F  p \        V 4      R,          R8X  g   K   R# 	  R# )z-Return true if the system uses the AMD driverrL   ZamdgpuTF)rJ   rM   )rK   s    r   is_amdrN      s(    h'83   r   c                rE   r   rF   r   r   r   r   r      s     9 9T 9r   c                  sN   \        4       '       g   R # \        4       p V R,          pV'       g   \        P                  ! R4       R#  \	        VP                  R4      ^ ,          4      pV\        8  #   \        \        3 d#   p\        P                  ! RT4        Rp?R# Rp?ii ; i)Fr   zFailed to get Nvidia versionTZ.z"Failed to parse Nvidia version: %sN)
rH   r2   r   rD   Zintr#   r%   Z
ValueErrorr1   MIN_RECOMMENDED_NVIDIA_DRIVER)Zdriver_infoZdriver_versionZmajor_versionr(   r/   r   is_outdatedrP      s    ;;(*K +N34N005a89 888 
# =rBs   !A1 1B$BB$)Z__doc__r   rB   Ztypingr    r   r   Zlutris.utilr   Zlutris.util.graphics.glxinfor   Zlutris.util.logr   Zlutris.util.systemr   rO   r2   r8   rA   r>   rH   rJ   rM   rN   rP   ) r   r   <module>rQ      si   
 
 	 ' ' $ 0 " 2 #  A AH:-.8.("9r   