+
     viE  c                   s   R t ^ RIt^ RIt^ RIt^ RIHtHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHtHtHtHtHt ]P(                  ! ]4      t^@t^?t^ t^t^t^tRt^t^t^t ]^,
          t!. ROt"^^.t#]# U u. uF  q ^,           NK  	  up t$^^).t%]&! ]'! ]#]$]%4      4      t(^t)^t*^t+^<t,] ! R R]4      4       t-] ! R	 R
]4      4       t.R t/R t0R t1 ! R R]4      t2R# u up i )a  liquidctl drivers for Corsair Hydro Platinum and Pro XT liquid coolers.

Supported devices:

- Corsair Hydro H100i Platinum
- Corsair Hydro H100i Platinum SE
- Corsair Hydro H115i Platinum
- Corsair Hydro H60i Pro XT
- Corsair Hydro H100i Pro XT
- Corsair Hydro H115i Pro XT
- Corsair Hydro H150i Pro XT
- Corsair iCUE H100i Elite RGB
- Corsair iCUE H115i Elite RGB
- Corsair iCUE H150i Elite RGB

Copyright Jonas Malaco and contributors
SPDX-License-Identifier: GPL-3.0-or-later
N)Enumunique)UsbHidDriverNotSupportedByDevice)RuntimeStorage)RelaxedNamesEnumclampfraction_of_byte
u16le_fromnormalize_profilemkCrcFunc                   s@   a  ] tR t^;t o ^ t^t^t^t]R 4       t	Rt
V tR# )_FanModec                N    \         P                  R V4       \        P                  # )z+falling back to FIXED_DUTY for _FanMode(%s))_LOGGERdebugr   
FIXED_DUTYclsvalue   &&D/usr/lib/python3.14/site-packages/liquidctl/driver/hydro_platinum.py	_missing_Z_FanMode._missing_B   s    CUK"""     N)__name__
__module____qualname____firstlineno__CUSTOM_PROFILEZ#CUSTOM_PROFILE_WITH_EXTERNAL_SENSORr   Z	FIXED_RPMclassmethodr   __static_attributes____classdictcell____classdict__   @r   r   r   ;   s,     N*-'JI# #r   r   c                   s<   a  ] tR t^Ht o ^ t^t^t]R 4       tRt	V t
R# )	_PumpModec                r   )z*falling back to BALANCED for _PumpMode(%s))r   r   r$   BALANCEDr   r   r   r   Z_PumpMode._missing_N   s    BEJ!!!r   r   N)r   r   r   r   ZQUIETr%   ZEXTREMEr   r   r   r    r!   r#   r   r$   r$   H   s&     EHG" "r   r$   c              #  sZ   "    V P                  RR \        ^ R7      pV^,          x  K(  5i)aj  Return a generator that produces valid protocol sequence numbers.

Sequence numbers increment across successful invocations of liquidctl, but
are not atomic.  The sequence is: 1, 2, 3... 29, 30, 31, 1, 2, 3...

In the protocol the sequence number is usually shifted left by 3 bits, and
a shifted sequence will look like: 8, 16, 24... 232, 240, 248, 8, 16, 24...
Zsequencec                 s"    V ^,          ^,           # )i   r   )Zxs   &r   Z<lambda>Z_sequence.<locals>.<lambda>_   s    B
r   of_typeZdefault)Z
load_storeint)ZstorageZseqs   & r   	_sequencer)   T   s.        -BCYZ [!fs   )+c                 s    R  V  4       p\        V\        4      p\        \        V4      ,
          pV^ 8  d   \	        RV)  R24      hV^ 8  d   W#\        ^d3.,          ,          pV# )c              3   sD   "   T F  w  rV\        V^ ^d4      3x  K  	  R# 5i)    N)r   .0Ztempduty   &  r   	<genexpr>Z#_prepare_profile.<locals>.<genexpr>d   s      FXzteD!S)*Xs    z#too many points in profile (remove Z))r
   _CRITICAL_TEMPERATURE_PROFILE_LENGTHlen
ValueError)ZoriginalZclampedZnormalZmissing   &   r   _prepare_profiler5   c   sg    FXFGw(=>FF+G{>xjJKK{3S9:::Mr   c                  s@    R P                  \        \        V 4      4      # )z, )joinZmapZrepr)Znamess   *r   _quotedr7   n   s    99Su%&&r   c                   s  a a ] tR t^rt oRtRRRR^R^/3RRRR^R^/3RR	R
R^R^/3RRRR^R^ /3RRRR^R^ /3RRRR^R^ /3RRRR^R^ /3RRRR^R^ /3RRRR^R^ /3RRRR^R^ /3RRRR^R^ /3RRRR^R^ /3.t]R,R l4       tV 3R ltR-V 3R llt	R.R  lt
R! tR" tR# tR$ tR% tR& tR-R' ltR( tR) tR* tR+tVtV ;t# )/HydroPlatinumz/Corsair Hydro Platinum or Pro XT liquid cooler.i  i  zCorsair Hydro H100i Platinum	fan_countfan_ledsi  zCorsair Hydro H100i Platinum SEi  zCorsair Hydro H115i Platinumi)  zCorsair Hydro H60i Pro XTi   zCorsair Hydro H100i Pro XTi!  zCorsair Hydro H115i Pro XTi"  zCorsair Hydro H150i Pro XTi5  zCorsair iCUE H100i Elite RGBi6  zCorsair iCUE H115i Elite RGBi7  zCorsair iCUE H150i Elite RGBi@  z$Corsair iCUE H100i Elite RGB (White)iA  z$Corsair iCUE H150i Elite RGB (White)c              +  sX  "   V P                    EF  w  rrV'       d   W(8w  g   VP                  V8w  d   K(  V'       d   W98w  g   VP                  V	8w  d   KI  V'       d   VP                  V8w  d   Kd  V'       d   VP                  V8w  d   K  V'       d?   VP                  4       pV
P                  4       pWl9   g   WlP                  RR4      9   g   K  VP                  4       pVP                  V4       V ! W3/ VB p\        P                  RV P                  V
4       Vx  EK  	  R# 5i)z8Probe `handle` and yield corresponding driver instances.zhydro  z%s identified: %sN)_MATCHES	vendor_id
product_idZrelease_numberZserial_numberlowerZreplaceZcopyZupdater   r   r   )r   ZhandleZvendorZproductZreleaseZserialZmatchkwargsvidZpidZdescZdevargsZdescrZconsargsZdevs   &&&&&&&,       r   probeZHydroPlatinum.probe   s      (+||#Cd6=V-=-=-DGNv/@/@C/G600G;&..&8

%==23N*N||~HOOF#f/h/CMM-s||TBI% (4s   <D* D* D*;D*BD*c                s  < \         SV `  ! W3/ VB  ^W4,          ,           V n        \        V4       Uu. uF  pRV^,            2NK  	  upV n        R^R^R^ /V n        RV P                  R^R^ /V n        RV n        RV n        R# u upi )i   fanNledzsuper-fixedrE   Zfixed)rE   off)	super__init__
_led_countZrange
_fan_names
_mincolors
_maxcolors_datar)   )selfdeviceZdescriptionr9   r:   r@   Zi	__class__s   &&&&&, r   rI   ZHydroPlatinum.__init__   s    77y3327	2BC2BQSQ=2BC"AaA
 #DOOaA
 
 Ds   Bc                sH  < \         SV `  ! R/ VB pV'       d   Wn        MgRV P                  R RV P                  R 2pRRP                  \        P                  ! RV P                  4      4      ,           p\        WE.R7      V n        \        V P                  4      V n
        V# )	zConnect to the device.rA   Z04xZ_pidlocZ_z\d+)Zkey_prefixesr   )rH   connectrN   r=   r>   r6   reZfindallZaddressr   r)   )rO   Zruntime_storager@   ZretZidsrR   rQ   s   &&,   r   rS   ZHydroPlatinum.connect   s    go''(Js+4/DEC
 #((2::fdll#CDDC'cZ@DJ"4::.
r   c                sl   V P                   P                  R^ 4       V P                   P                  R\        V,          P                  4       V P	                  4       pV^,          ^,	          V^,          ^,          V^,          3pVR8  d   \
        P                  R4       RRP                  ! V!  R3.# )a  Initialize the device and set the pump mode.

The device should be initialized every time it is powered on, including when
the system resumes from suspending to memory.

Valid values for `pump_mode` are 'quiet', 'balanced' and 'extreme'.
Unconfigured fan channels may default to 100% duty.  Subsequent calls
should leave the fan speeds unaffected.

Returns a list of `(property, value, unit)` tuples.
leds_enabled	pump_modez2outdated and possibly unsupported firmware versionzFirmware versionz{}.{}.{}r;   )   rW   r*   )rN   storer$   r   _send_set_coolingr   warningZformat)rO   rV   r@   resZ
fw_versions   &&,  r   
initializeZHydroPlatinum.initialize   s     	

+

i	&:&@&@A$$&!fk3q6C<Q8
	!OOPQ#Z%6%6
%CRHIIr   c           	     s   V P                  \        \        4      pRV^,          V^,          ^,          ,           R3.p. R	OR\        V P                  4       pVP                  R
4       V Fa  w  rVVP                  V R2\        W&^,           R7      R34       VP                  V R2\        W&,          ^,          ^d,          4      R34       Kc  	  V# )zJGet a status report.

Returns a list of `(property, value, unit)` tuples.
zLiquid temperatureu   °CNz speedZoffsetZrpmz dutyZ%))zFan 1i   )zFan 2i   )zFan 3i*   )ZPumpi   )_send_command_FEATURE_COOLING_CMD_GET_STATUSr2   rK   Zappendr	   Zround)rO   r@   r[   infoZchannelsnameZbases   &,     r   
get_statusZHydroPlatinum.get_status   s       !1?C "3q6CFSL#8%@
 AAV#dooBVW%"JDKKD6*S*JERSKKD6sy3/D)EsKL # r   c                s   V P                  V4       FY  pV P                  P                  V R2\        P                  P
                  4       V P                  P                  V R2V4       K[  	  V P                  4        R# )zSet fan or fans to a fixed speed duty.

Valid channel values are 'fanN', where N >= 1 is the fan number, and
'fan', to simultaneously configure all fans.  Unconfigured fan channels
may default to 100% duty.
_mode_dutyN)_get_hw_fan_channelsrN   rX   r   r   r   rY   )rO   channelr-   r@   
hw_channel   &&&, r   set_fixed_speedZHydroPlatinum.set_fixed_speed   si     33G<JJJ
|5183F3F3L3LMJJ
|5148 = 	 r   c                s   \        V4      pV P                  V4       FY  pV P                  P                  V R2\        P
                  P                  4       V P                  P                  V R2V4       K[  	  V P                  4        R# )u  Set fan or fans to follow a speed duty profile.

Valid channel values are 'fanN', where N >= 1 is the fan number, and
'fan', to simultaneously configure all fans.  Unconfigured fan channels
may default to 100% duty.

Up to seven (temperature, duty) pairs can be supplied in `profile`,
with temperatures in Celsius and duty values in percentage.  The last
point should set the fan to 100% duty cycle, or be omitted; in the
latter case the fan will be set to max out at 60°C.
rd   _profileN)listrf   rN   rX   r   r   r   rY   )rO   rg   profiler@   rh   ri   r   set_speed_profileZHydroPlatinum.set_speed_profile  sr     w-33G<JJJ
|5183J3J3P3PQJJ
|84g> = 	 r   c                s`  a  \        V4      pS P                  WV4       VR8X  d   . pMNW3R8X  d   VRS P                   pM6W3R8X  d/   \        \        P                  ! V 3R lVR,           4       !  4      pS P
                  P                  R\        ^ R7      ^ 8X  d   \        P                  R4      p\        P                  R4      p\        P                  R	4      pS P                  R^VR
7       S P                  R^VR
7       S P                  R^VR
7       S P
                  P                  R^4       \        \        P                  ! R XR,           4       !  4      p	\        \        P                  ! R VR,           4       !  4      p
\        \        P                  ! R VR,           4       !  4      pS P                  \        \        V	R
7       S P                  ^8  d   S P                  \        \        V
R
7       S P                  ^(8  d   S P                  \        \        VR
7       R# R# )u  Set the color of each LED.

In reality the device does not have the concept of different channels
or modes, but this driver provides a few for convenience.  Animations
still require successive calls to this API.

The 'led' channel can be used to address individual LEDs, and supports
the 'super-fixed', 'fixed' and 'off' modes.

In 'super-fixed' mode, each color in `colors` is applied to one
individual LED, successively.  LEDs for which no color has been
specified default to off/solid black.  This is closest to how the
device works.

In 'fixed' mode, all LEDs are set to the first color taken from
`colors`.  The `off` mode is equivalent to calling this function with
'fixed' and a single solid black color in `colors`.

The `colors` argument should be an iterable of one or more `[red, blue,
green]` triples, where each red/blue/green component is a value in the
range 0–255.

The table bellow summarizes the available channels, modes, and their
associated maximum number of colors for each device family.

| Channel  | Mode        | LEDs         | Platinum | Pro XT/Elite RGB | Platinum SE |
| -------- | ----------- | ------------ | -------- | ---------------- | ----------- |
| led      | off         | synchronized |        0 |                0 |           0 |
| led      | fixed       | synchronized |        1 |                1 |           1 |
| led      | super-fixed | independent  |       24 |               16 |          48 |
rG   Nc              3   sJ   <"   T F  q.SP                   ,          x  K  	  R # 5iN)rJ   )r,   ZcolorrO   s   & r   r/   *HydroPlatinum.set_color.<locals>.<genexpr>G  s     -`U_Eg.G.GU_s    #:NrW   NrU   r&   Zz0101ffffffffffffffffffffffffff7f7f7f7fff00ffffffff00ffffffff00ffffffff00ffffffff00ffffffff00ffffffffffffffffffffffffffffffZz000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627ffffffffffffffffffffffffffffffffffffffffffZz28292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4fffffffffffffffffffffffffffffffffffffffffffdatac              3   .   "   T F  w  rq3W!3x  K  	  R # 5iro   r   r,   ZrZgZbr4   r   r/   rp   W  s     'PgaAA	   :r*      Nc              3   rs   ro   r   rt   r4   r   r/   rp   X  s     'QgaAA	ru   :rv   (   Nc              3   rs   ro   r   rt   r4   r   r/   rp   Y  s     'OgaAA	ru   :rw   NNrD   rF   )rl   _check_color_argsrJ   	itertoolschainrN   loadr(   bytesZfromhexr^   rX   _FEATURE_LIGHTING_CMD_SET_LIGHTING1_CMD_SET_LIGHTING2_CMD_SET_LIGHTING3)rO   rg   modecolorsr@   ZexpandedZd1Zd2Zd3Zdata1data2Zdata3s   f&&&,       r   	set_colorZHydroPlatinum.set_color  s   B fwf55=H_ 66.t/H_ 00IOO-`U[\^U_-`abH ::??>3?BaG   \  ]B   \  ]B   \  ]B tU4tU4tU4JJ^Q/ioo'P$'PQRioo'Q%'QRSioo'O#'OPQ,.@uM??R02D5Q??R02D5Q  r   c           	     sl    V P                   W3,          pV P                  W3,          p\        T4      T8  d   \        RT R\	        Y4       24      h\        T4      T8  d   \        P                  RT4       T# \        T4      #   \         d"    \        R \	        T P                   !   24      Rhi ; i)z4unsupported (channel, mode) pair, should be one of: Nz	at least z required for ztoo many colors, dropping to %d)rL   rM   ZKeyErrorr3   r7   r2   r   rZ   )rO   rg   r   r   Z	mincolorsZ	maxcolors   &&&&  r   rx   ZHydroPlatinum._check_color_argsc  s    	Y8I8I v;"y>''BXAYZ[[v;"OO=yI6{  	Y  2294??2K1LN OTXY	Ys   (B ,B3c                s    VR 8X  d   V P                   # WP                   9   d   V.# \        R\        R .V P                   O5!   24      h)rC   z#unknown channel, should be one of: )rK   r3   r7   )rO   rg   r   r   rf   Z"HydroPlatinum._get_hw_fan_channelsq  sH    e??"oo%9>wu?_t?_>`abbr   c                st   \        \        ^,           4      p\        V^&   \        V P                  4      ^,          V^&   Ve   V^;;,          V,          uu&   W$^&   ^pMV^;;,          V,          uu&   ^pV'       d   W4WU\        V4      ,           % \        R4      ! V^R 4      VR&   V P                  P                  4        V P                  P                  V4       \        V P                  P                  \        4      4      p\        R4      ! VR,          4      '       d   \        P                  R4       V# )rW   zcrc-8:rW   NNz%response checksum does not match datai)	bytearray_REPORT_LENGTH_WRITE_PREFIXZnextr)   r2   r   rP   Zclear_enqueued_reportsZwriter|   Zreadr   rZ   )rO   ZfeatureZcommandrr   ZbufZstart_atr   r   r^   ZHydroPlatinum._send_commandx  s    *+Adnn%*AFgFFHFgFH26SY./7#C"I.B**,#DKK$$^45GSW%%OOCD
r   c                s(   \        \        4      p\        V^ \        \        4      % \        V\
        &   \        V\        4       EFJ  w  pw  rEp\        V P                  P                  V R2\        R7      4      pV\        P                  J dX   V P                  P                  V R2\        ^dR7      p\        V^ ^d4      p	\        V	R7      W%&   \        P!                  RW94       MV\        P"                  J dy   V P                  P                  V R2\$        . R7      p\'        V4      p
R V
 4       p\(        P*                  ! V!  W&V\        ^,          ,           % \        P!                  R	W:4       M\-        R
V 24      hVP.                  W$&   EKM  	  V# )r*   rd   r'   re   r&   Z
percentagezsetting %s to %d%% duty cyclerk   c              3   sB   "   T F  w  rV\        VR 7      3x  K  	  R# 5i)r   N)r   r+   r.   r   r/   Z:HydroPlatinum._generate_cooling_payload.<locals>.<genexpr>  s     ]U\zt$ 0D ABU\s   zsetting %s to follow profile %rzunsupported fan )r   _SET_COOLING_DATA_LENGTH_SET_COOLING_DATA_PREFIXr2   r1   _PROFILE_LENGTH_OFFSETzip_FAN_OFFSETSr   rN   r{   r(   r   r   r   r   ra   r   rl   r5   ry   rz   r3   r   )rO   Z	fan_namesrr   rC   ZimodeZidutyZiprofiler   Zstoredr-   rm   Zpairss   &&          r   _generate_cooling_payloadZ'HydroPlatinum._generate_cooling_payload  sQ   121IQ,-.'6#$-0L-I)C)%DJJOOse5M3OGHDx***C5SQVQ,.$?<cH000C5)94QST*62]U\]AJRWAXx/A*==>>M #3D6!:;;**DK .J" r   c                s   \        V P                  P                  R \        R7      4      pV P	                  V P
                  R,          4      pVP                  V\        &   \        P                  RVP                  P                  4       4       \        V P
                  4      ^8X  dH   V P	                  V P
                  R,          4      p^V\        &   V P                  \        \        VR7       V P                  \         \        VR7      # )rV   r   :r*      Nzsetting pump mode to %s:r   NNrq   )r$   rN   r{   r(   r   rK   r   _PUMP_MODE_OFFSETr   ra   rb   r?   r2   r^   _FEATURE_COOLING2_CMD_SET_COOLINGr_   )rO   rV   rr   r   r4   r   rY   ZHydroPlatinum._send_set_cooling  s    djjook3oGH	--dooc.BC"+//.	0D0D0FGt1$224??23FGE'+E#$02BO!!"24D4!PPr   c                s    \        4       h)zNot supported by this device.r   )rO   rg   r   r   r@   s   &&&&,r   
set_screenZHydroPlatinum.set_screen  s    "$$r   )rN   rK   rJ   rM   rL   r)   )NNNNNro   )Zbalanced)r   r   r   r   __doc__r<   r   rB   rI   rS   r\   rc   rj   rn   r   rx   rf   r^   r   rY   r   r   r    Z__classcell__)rQ   r"   s   @@r   r8   r8   r   s    9 
7!Z+	-	:!Z,	.	7!Z+	-	4!Z+	-	5!Z+	-	5!Z+	-	5!Z+	-	7!Z+	-	7!Z+	-	7!Z+	-	?!Z+	-	?!Z+	-/H6  8&$J0*!!&BRHc,2Q% %r   r8   )r*      i   r   r   r   r   r   )3r   ry   ZloggingrT   Zenumr    r   Zliquidctl.driver.usbr   Zliquidctl.errorr   Zliquidctl.keyvalr   Zliquidctl.utilr   r   r   r	   r
   r   Z	getLoggerr   r   r   r   r_   r   r`   r   r}   r~   r   r   r   r   Z_FAN_MODE_OFFSETSZ_FAN_DUTY_OFFSETSZ_FAN_PROFILE_OFFSETSrl   r   r   r   r   r1   r0   r   r$   r)   r5   r7   r8   r]   s   0r   <module>r      sD  &   	  - 0 +C C 

H
%        *A- I x( .?@.?FaZZ.?@  (+ C)+<>RST !   	#t 	# 	# "  " "'E%L E%A As   4C