Changeset 416 for branches/branch-1-0/src/helpers
- Timestamp:
- Aug 30, 2014, 8:24:36 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1-0/src/helpers/acpih.c
r414 r416 17 17 18 18 /* 19 * Copyright (C) 2006-201 3Paul Ratcliffe.19 * Copyright (C) 2006-2014 Paul Ratcliffe. 20 20 * This file is part of the "XWorkplace helpers" source package. 21 21 * This is free software; you can redistribute it and/or modify … … 79 79 *@@ acpihOpen: 80 80 * resolves the ACPI entrypoints and loads the ACPI DLL. 81 * 82 *@@changed V1.0.10 (2014-08-30) [dazarewicz]: Call ACPI start API func. 81 83 */ 82 84 … … 140 142 G_ulCount++; 141 143 142 // @@added V1.0.9 (2012-12-10) [slevine]: use AcpiTkPrepareToSleep rather than workaround143 /* This function does not exist in older versions of acpi144 * As a result the shutdown attempt will usually hang because145 * the required code has not been committed into memory.146 */147 if (pAcpiTkPrepareToSleep)148 pAcpiTkPrepareToSleep(ACPI_STATE_S5);149 150 144 return(pAcpiStartApi(phACPI)); 151 145 } 146 } 147 148 /* 149 *@@ acpihPrepareToSleep: 150 * Prepares the system to sleep or power off 151 * 152 *@@added V1.0.10 (2014-08-30) [dazarewicz] 153 */ 154 155 VOID acpihPrepareToSleep(UCHAR ucState) 156 { 157 // @@added V1.0.9 (2012-12-10) [slevine]: use AcpiTkPrepareToSleep rather than workaround 158 /* This function does not exist in older versions of acpi 159 * As a result the shutdown attempt will usually hang because 160 * the required code has not been committed into memory. 161 */ 162 if (pAcpiTkPrepareToSleep) 163 pAcpiTkPrepareToSleep(ucState); 152 164 } 153 165 … … 196 208 * Code provided by David Azarewicz 197 209 *@@added V1.0.9 (2012-02-20) [slevine]: code from David Azarewicz 198 */ 199 200 #define AE_DEPTH AE_OK 201 202 ACPI_STATUS AcpiCallbackWidget( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue ) 210 *@@changed V1.0.10 (2014-08-30) [dazarewicz]: release resources correctly 211 */ 212 213 ACPI_STATUS APIENTRY AcpiCallbackWidget( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue ) 203 214 { 204 215 ACPI_DEVICE_INFO *pDevInfo = NULL; 205 ACPI_STATUS Status = pAcpiTkGetObjectInfoAlloc(ObjHandle, &pDevInfo); 206 207 if (Status == AE_OK) 216 217 if (pAcpiTkGetObjectInfoAlloc( ObjHandle, &pDevInfo ) != AE_OK) 218 return AE_OK; 219 220 do 208 221 { 209 222 if (pDevInfo->Type != ACPI_TYPE_DEVICE) 210 return AE_DEPTH;223 break; 211 224 212 225 if (!(pDevInfo->Valid & ACPI_VALID_HID)) 213 return AE_DEPTH;226 break; 214 227 215 228 if (!pDevInfo->HardwareId.String) 216 return AE_DEPTH;229 break; 217 230 218 231 if (strncmp(pDevInfo->HardwareId.String, "ACPI0003", 8) == 0) 219 232 { /* AC Power */ 220 Status = pAcpiTkGetHandle(ObjHandle, "_PSR", &G_ahAC); 221 if (Status) 233 if (pAcpiTkGetHandle(ObjHandle, "_PSR", &G_ahAC)) 222 234 G_ahAC = 0; 223 235 224 return AE_DEPTH;236 break; 225 237 } 226 238 … … 230 242 G_ahBat[G_uiBatteryCount++] = ObjHandle; 231 243 232 return AE_DEPTH;233 } 234 } 244 break; 245 } 246 } while (0); 235 247 236 248 if (pDevInfo) … … 246 258 * Code provided by David Azarewicz 247 259 *@@added V1.0.9 (2012-02-20) [slevine]: code from David Azarewicz 260 *@@changed V1.0.10 (2014-08-30) [dazarewicz]: tidies 248 261 */ 249 262 … … 326 339 Obj = (ACPI_OBJECT *)Obj[0].Package.Elements; // Battery info package 327 340 LastFull = (UINT32)OBJ_VALUE(2); 328 if (LastFull == 0xffffffff)329 {330 G_ahBat[uiI] = 0;331 continue;332 }333 341 334 342 Result.Length = sizeof(Object); … … 344 352 Obj = Result.Pointer; 345 353 Obj = (ACPI_OBJECT *)Obj[0].Package.Elements; // Battery status package 346 347 // If voltage known 348 if ((UINT32)OBJ_VALUE(2) != 0xffffffff) 349 BRemaining = (UINT32)OBJ_VALUE(2); 354 BRemaining = (UINT32)OBJ_VALUE(2); 350 355 351 356 // If battery units are mWh or mAh 352 357 // If not, it is a percentage 353 if ((UINT32)OBJ_VALUE(0) != 0xffffffff) 358 if ( (LastFull != 0xffffffff) 359 && (BRemaining != 0xffffffff) 360 ) 354 361 { 355 362 if (BRemaining > (LastFull >> 1)) // > 50% is high. < 50% is low … … 370 377 fChanged = TRUE; 371 378 } 372 } 373 374 ulTmp = (BRemaining*100) / LastFull;375 if (ulTmp > 100)376 ulTmp = 100; 377 378 if (pApm->bBatteryLife != ulTmp)379 {380 pApm->bBatteryLife = (BYTE) ulTmp;381 fChanged = TRUE;379 380 ulTmp = (BRemaining*100) / LastFull; 381 if (ulTmp > 100) 382 ulTmp = 100; 383 384 if (pApm->bBatteryLife != ulTmp) 385 { 386 pApm->bBatteryLife = (BYTE) ulTmp; 387 fChanged = TRUE; 388 } 382 389 } 383 390 }
Note:
See TracChangeset
for help on using the changeset viewer.