+
     vi3  c                   s    R t ^ RIt^ RIt^ RIHt ^ RIHtHt ^ RIH	t	 ^ RI
HtHtHt ^ RIHtHtHt ]P$                  ! ]4      t ! R R4      t ! R	 R
]	4      t ! R R]4      tR# )zvliquidctl drivers for DDR4 memory.

Copyright Jonas Malaco and contributors
SPDX-License-Identifier: GPL-3.0-or-later
N)
namedtuple)Enumunique)SmbusDriver)ExpectationNotMetNotSupportedByDeviceNotSupportedByDriver)RelaxedNamesEnumcheck_unsafeclampc                   s"  a  ] tR t^t o Rt ! R R]4      t ! R R]4      t^^,R^R^R/^^R	/^^R
/^^R^R/^^R^R//tR t	]
R 4       t]
R 4       t]
R 4       t]
R 4       t]
R 4       t]
R 4       t]
R 4       t]
R 4       t]
R 4       tRtV tR# )Ddr4SpdzPartial decoding of DDR4 Serial Presence Detect (SPD) information.

Properties will raise on data they are not yet prepared to handle, but what
is implemented attempts to comply with JEDEC 21-C 4.1.2 Annex L.
c                   s6   a  ] tR t^t o Rt^t^t^tR tRt	V t
R# )Ddr4Spd.DramDeviceTypez"DRAM device type (not exhaustive).c                :    V P                   P                  R R4      # Z_ nameZreplaceself   &:/usr/lib/python3.14/site-packages/liquidctl/driver/ddr4.py__str__ZDdr4Spd.DramDeviceType.__str__        99$$S#..     N)__name__
__module____qualname____firstlineno____doc__
DDR4_SDRAMLPDDR4_SDRAMLPDDR4X_SDRAMr   __static_attributes____classdictcell____classdict__   @r   DramDeviceTyper      s!     0
	/ 	/r   r&   c                   s:   a  ] tR t^#t o Rt^t^t^tRtR t	Rt
V tR# )Ddr4Spd.BaseModuleTypez"Base module type (not exhaustive).   c                r   r   r   r   r   r   r   ZDdr4Spd.BaseModuleType.__str__+   r   r   r   N)r   r   r   r   r   ZRDIMMUDIMMZSO_DIMMZLRDIMMr   r!   r"   r#   r%   r   BaseModuleTyper'   #   s&     0	/ 	/r   r*   ZMicronzSK HynixZSamsungZKingstonCorsairzG.SKILLz
Team GroupZPatriotZCrucialc                s    Wn         V P                  V P                  P                  V P                  P                  V P                  P
                  39  d   \        R 4      hR# )znot a DDR4 SPD EEPROMN)_eepromdram_device_typer&   r   r   r    
ValueError)r   eeprom   &&r   __init__ZDdr4Spd.__init__B   s\      )<)<)G)G)-)<)<)I)I)-)<)<)J)J)L L 455Lr   c                sd    V P                   ^ ,          ^,          pV^8:  g   Q R4       hV^,          # )    reservedr,   r   Znibble   & r   spd_bytes_usedZDdr4Spd.spd_bytes_usedJ   s2    d#d*++|r   c                sr    V P                   ^ ,          ^,	          ^,          pV^8:  g   Q R4       hVR,          # )r2   r3   r(   r4   r5   r6   r   spd_bytes_totalZDdr4Spd.spd_bytes_totalP   s5    ,,t$)U2*
*|r   c                sp    V P                   ^,          ^,	          pV P                   ^,          ^,          pW3# )   r4   )r   Z	enc_levelZ	add_level   &  r   spd_revisionZDdr4Spd.spd_revisionV   s1    LL&!+	LL&-	%%r   c                sF    V P                  V P                  ^,          4      # )   )r&   r,   r   r   r   r-   ZDdr4Spd.dram_device_type\   s    ""4<<#566r   c                s    V P                   ^,          ^,          pV P                   ^,          ^,	          pV'       d   Q hV P                  V4      R3# )i   N)r,   r*   )r   baseZhybridr:   r   module_typeZDdr4Spd.module_type`   sF    ||D!D(d#q(z##D)400r   c                sL    V P                   ^,          ^,	          p\        V4      # )i   )r,   Zbool)r   Zpresentr6   r   module_thermal_sensorZDdr4Spd.module_thermal_sensorg   s    ,,t$)G}r   c                    ^V P                   R,          ,           ^,          pV P                   R,          pV P                  V,          V,          # )r9   i@  iA  r,   _JEP106r   ZbankZmidr:   r   module_manufacturerZDdr4Spd.module_manufacturerl   <    4<<&&-ll5!||D!#&&r   c                sd    V P                   R ,          P                  RR7      P                  4       # ):iI  i]  NZascii)Zencoding)r,   ZdecodeZrstripr   r   r   module_part_numberZDdr4Spd.module_part_numberr   s(    ||K(///AHHJJr   c                r@   )r9   i^  i_  rA   rC   r:   r   dram_manufacturerZDdr4Spd.dram_manufacturerv   rE   r   r4   N)r   r   r   r   r   r   r&   r*   rB   r1   propertyr7   r8   r;   r-   r>   r?   rD   rF   rG   r!   r"   r#   r%   r   r
   r
      s9    / /	/ 	/ 	
(*)

 	
D*	D)	),
 	
))
G$6  
  
 & &
 7 7 1 1   ' '
 K K ' 'r   r
   c                   s   a a ] tR t^}t oRt^Pt^t^t^ t^t	RR.t
]RR l4       t]R 4       tV 3R lt]R 4       tR tR	 tR
 tR tR tR tR tRtVtV ;t# )Ddr4TemperaturezFDDR4 module with TSE2004-compatible SPD EEPROM and temperature sensor.smbusZddr4_temperaturec              +  sN  "   R .p	VP                   V	9  g   \        W#Wg.4      '       d   R# \        V P                  ^,           4       EFM  p
V P                  V
,          p\
        P                  RV P                  V4       VP                  V4      pV'       d   VP                  R8w  d   Kd   \        VP                  4      pVP                  \        P                  P                  8w  d   K  V P                  V4      pT'       g   K  TRT
^,            2,          pT'       d   \!        T^R7      T8w  g,   T'       d'   TP#                  4       TP#                  4       9  d   EK  T ! YRRT3R7      p\
        P                  RT P                  T4       Tx  EKP  	  R#     EKZ  ; i5i)Z
i801_smbusNz%s checking address: %xZee1004z DIMM)r=   )addressz%s identified: %s)Zparent_driverZanyrange_SA_MASK	_SPD_DTIC_LOGGERdebugr   Zload_eepromr   r
   Zdatar-   r&   r   _matchZintlower)clsrJ   ZvendorZproductrK   ZmatchZreleaseZserialkwargsZ_SMBUS_DRIVERSZdimmZspd_addrr/   spdZdescZdevs   &&&&&&&&,       r   probeZDdr4Temperature.probe   sH     'n49::#,,*+D}}t+HMM3S\\8L&&x0FV[[H4fkk*''7+A+A+L+LLzz# eD1H:&&DCb1X=%++-tzz|"C
 eD$+ABCMM-s||TBIC , s=   B*F%->F+F%-F>F%F%#F%=AF%F"F%c                s    VP                   '       g   R #  VP                  pTP                  '       d   T RTP                   2# T#     R# ; i)NZDDR4r   )r?   rD   rF   )rS   rU   Zmanufacturers   && r   rQ   ZDdr4Temperature._match   sW    (((	22L !!!"^1S%;%;$<==	s   A Ac                s   < \         SV `  ! V/ VB  V P                  V P                  ^,          V P                  ,          ,          V n        R# )r<   N)superr1   _TS_DTIC_addressrM   _ts_addressr   ZargsrT   	__class__   &*,r   r1   ZDdr4Temperature.__init__   s8    $)&)==DMM!,<t}},LMr   c                s,    V P                   ^,          R # )r<   #04x)rY   r   r   r   rK   ZDdr4Temperature.address   s    --"4()r   c                s@   \        V P                  / VB '       g=   \        P                  RV P                  RP                  V P                  4      4       . # V P                  4       pVR,          pVR8  d
   VR,          pR^
rCV^V,
          ,	          pRW5,          R3.# )	zJGet a status report.

Returns a list of `(property, value, unit)` tuples.
z+%s: disabled, requires unsafe features '%s'Z,i  i  i    g      ?ZTemperatureu   °C)r   _UNSAFErO   ZwarningZdescriptionZjoin_read_temperature_register)r   rT   tregZ
resolutionZbitsZ
multipliers   &,    r   
get_statusZDdr4Temperature.get_status   s     T\\4V44OOI ,,chht||.DFI..0 f}&=FND  Db4i(
 J3U;
 	
r   c                s    V P                   P                  V P                  V P                  4      pV^,          ^,          V^,	          ,          # )i   )_smbusZread_word_datarZ   _REG_TEMPERATURE)r   ra   r6   r   r`   Z*Ddr4Temperature._read_temperature_register   s@     {{))$*:*:D<Q<QR "tqy11r   c                s    R# )zInitialize the device.Nr   )r   rT   s   &,r   
initializeZDdr4Temperature.initialize   s    r   c                    \        4       h)zNot supported by this driver.)r   )r   channelmodecolorsrT      &&&&,r   	set_colorZDdr4Temperature.set_color       "$$r   c                rf   zNot supported by this device.r   )r   rg   ZprofilerT      &&&,r   set_speed_profileZ!Ddr4Temperature.set_speed_profile  rl   r   c                rf   rm   rn   )r   rg   ZdutyrT   ro   r   set_fixed_speedZDdr4Temperature.set_fixed_speed  rl   r   c                rf   rm   rn   )r   rg   rh   valuerT   rj   r   
set_screenZDdr4Temperature.set_screen
  rl   r   )rZ   )NNNNNN)r   r   r   r   r   rN   rX   rM   Z_REG_CAPABILITIESrd   r_   classmethodrV   rQ   r1   rH   rK   rb   r`   re   rk   rp   rq   rs   r!   r"   __classcell__r\   r$      @@r   rI   rI   }   s     PIHH*+G. .`    N * *
62%%%% %r   rI   c                   s   a a ] tR tRt oRt^Xt^t^t^t^t	^t
^tRR.t] ! R R]]4      4       t] ! R R]4      4       tV 3R	 lt]R
 4       tRR ltR tRtVtV ;t# )VengeanceRgbi  z"Corsair Vengeance RGB DDR4 module.rJ   Zvengeance_rgbc                   s<   a  ] tR tRt o R tRtRtRtR	tR t	Rt
V tR# )
VengeanceRgb.Modei  c                sV    \         P                  W.4      pWn        W$n        W4n        V# N)bytes__new__Z_value_
min_colors
max_colors)rS   rr   r}   r~   Zobjs   &&&& r   r|   ZVengeanceRgb.Mode.__new__  s&    --W-CK'N'NJr   c                s6    V P                   P                  4       # rz   )r   rR   r   r   r   r   ZVengeanceRgb.Mode.__str__+  s    99??$$r   r   N)r2   r9   r9   )r9   r<      )r<   r9   r   )i   r2   r2   )r   r   r   r   r|   FIXEDZFADING	BREATHINGOFFr   r!   r"   r#   r%   r   Modery     s*     	  		% 	%r   r   c                   s*    ] tR tRt^?t^0t^ t^t^tRt	R# )VengeanceRgb.SpeedTimingsi.  r   N)
r   r   r   r   ZSLOWESTZSLOWERZNORMALZFASTERZFASTESTr!   r   r   r   SpeedTimingsr   .  s    r   r   c                s6   < \         SV `  ! V/ VB  R V n        R # rz   )rW   r1   _rgb_addressr[   r]   r   r1   ZVengeanceRgb.__init__6  s    $)&) r   c                s    VP                   \        P                  P                  R 38w  g3   VP                  R8w  g"   VP
                  P                  R4      '       g   R # R# )Nr+   ZCMRzCorsair Vengeance RGB)r>   r
   r*   r)   rD   rF   Z
startswith)rS   rU   r0   r   rQ   ZVengeanceRgb._match:  sJ    ??w55;;TBB**i7--88??&r   c                s  a  \        S P                  RR/VB   S P                  V,          P                  pT;rTe   \        T^ ^?4      p	Te   \        T^ ^?4      p
\        T4      p S P                  T,          p\        T4      TP                  8  d   \        T RTP                   R24      h\        T4      TP                  8  d0   \        P                  RTP                  4       TRTP                   pS P                  4        TS P                  P                  8X  d   S P                  P                   p. R
O.pT 3R	 lpTS P                  P                   8X  d   T! S P"                  ^ 4       M&T! S P"                  T	4       T! S P$                  T
4       \'        S P(                  S P*                  4      p\,        P.                  ! T!  p\1        Y4       F  w  rT! Y4       K  	  T! S P2                  \        T4      4       TS P                  P4                  8X  dD   \        T4      ^8X  d4   T! S P6                  S P                  P                   P                  4       R# T! S P6                  TP                  4       R#   \         d    \        RT: 24      Rhi ; i  \         d    \        RT: 24      Rhi ; i)u  Set the RGB lighting mode and, when applicable, color.

The table bellow summarizes the available channels, modes and their
associated number of required colors.

| Channel  | Mode      | Colors |
| -------- | --------- | ------ |
| led      | off       |      0 |
| led      | fixed     |      1 |
| led      | breathing |    1–7 |
| led      | fading    |    2–7 |

The speed of the breathing and fading animations can be adjusted with
`speed`; the allowed values are 'slowest', 'slower', 'normal'
(default), 'faster' and 'fastest'.

It is also possible to override the raw timing parameters through
`transition_ticks` and `stable_ticks`; these should be integer values
in the range 0–63.
ZerrorTzinvalid speed preset: Nzinvalid mode: z mode requires z colorsztoo many colors, dropping to %dc                 sT   < SP                   P                  SP                  W4       R # rz   )rc   Zwrite_byte_datar   )registerrr   r   s   &&r   	rgb_writeZ)VengeanceRgb.set_color.<locals>.rgb_write|  s    KK''(9(98Kr   )r2   r2   r2   )r   r_   r   rr   ZKeyErrorr.   r	   Zlistr   Zlenr}   r~   rO   rP   _compute_rgb_addressr   r   _REG_RGB_TIMING1_REG_RGB_TIMING2rL   _REG_RGB_COLOR_START_REG_RGB_COLOR_END	itertoolsZchainZzip_REG_RGB_COLOR_COUNTr   _REG_RGB_MODE)r   rg   rh   ri   ZspeedZtransition_ticksZstable_ticksrT   ZcommonZtp1Ztp2r   Zcolor_registersZcolor_componentsr   Z	components   f&&&&&&,        r   rk   ZVengeanceRgb.set_colorD  sX   . 	dll9$9&9	K&&u-33FC '(!R0C#a,Cf	B99T?D v;(v_T__4EWMNNv;(MM;T__M,T__-F!!#499== 99??D()F	L 499??"d++T2d++S1d++S1 9 94;R;RS$??F3#&#IHh* $J 	$++S[9499&&&3v;!+;d(($))//*?*?@d(($**5a  	K5eY?@dJ	K  	B~dX67TA	Bs    J (J" J"J>c                s0   V P                   '       d   R # V P                  V P                  ^,          V P                  ,          ,          pV P                  P                  WP                  4      ^8w  d   \        V P                   RVR R24      hWn         R # )NZ:r^   z is not the RGB controller)	r   	_RGB_DTICrY   rM   rc   Zread_byte_datar   r   Zbus)r   Z	candidater6   r   r   Z!VengeanceRgb._compute_rgb_address  sx     NNdmmA&6&FG	 ;;%%i1C1CDL#txxj)D1AA[$\]]%r   )r   )ZnormalNN)r   r   r   r   r   r   r   r   r   r   r   r   r_   r   r{   r   r   r   r1   rt   rQ   rk   r   r!   r"   ru   rv   rw   r   rx   rx     s     ,IM(G%u& % %" '  ! ' 'L6\& &r   rx   )r   r   ZloggingZcollectionsr    Zenumr   r   Zliquidctl.driver.smbusr   Zliquidctl.errorr   r   r   Zliquidctl.utilr   r   r	   Z	getLoggerr   rO   r
   rI   rx   r   r   r   <module>r      sa      "  . Y Y @ @


H
%g' g'TO%k O%dN&? N&r   