Subject: APM v1.2
To: John Kohl <jtk@netbsd.org>
From: Matthias Drochner <drochner@zel459.zel.kfa-juelich.de>
List: port-i386
Date: 08/03/1999 23:43:06
Our apm driver always attaches as v1.1 driver to the APM BIOS,
even if the BIOS reports to support v1.2.
1.2 has some extensions over 1.1 which we don't use, but I don't
see where our driver is not compliant to 1.2, so we could just attach
as v1.2 driver imho.
The reason is somehow vague: with the 1.1 driver, my ThinkPad
sometimes failed to suspend properly when the lid was closed. It
just kept operating, fan spinning etc. This didn't happen often,
perhaps 3 times a month. Since I applied the trivial patch
below, which only makes the driver attach as v1.2, it didn't happen
again in about 2 weeks.
That's perhaps not much of a proof, at least not statistically
(\sigma=\sqrt{N}:-), but otoh, I don't see a reason not to do it.
Opinions?

best regards
Matthias


Index: arch/i386/i386/apm.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/apm.c,v
retrieving revision 1.39
diff -c -2 -r1.39 apm.c
*** apm.c	1999/06/26 08:25:25	1.39
--- apm.c	1999/08/03 21:16:42
***************
*** 180,185 ****
  int	apm_v11_enabled = 1;
  #endif
! #ifdef APMDEBUG
  int	apm_v12_enabled = 0;
  #endif
  
--- 180,187 ----
  int	apm_v11_enabled = 1;
  #endif
! #ifdef APM_NO_V12
  int	apm_v12_enabled = 0;
+ #else
+ int	apm_v12_enabled = 1;
  #endif
  
***************
*** 696,699 ****
--- 698,711 ----
  #endif /* APMDEBUG */
  
+ 	regs.CX = 0x0102;	/* APM Version 1.2 */
+ 	regs.BX = APM_DEV_APM_BIOS;
+ 	
+ 	if (apm_v12_enabled &&
+ 	    (error = apmcall(APM_DRIVER_VERSION, &regs)) == 0) {
+ 		apm_majver = 1;
+ 		apm_minver = 2;
+ 		goto ok;
+ 	}
+ 
  	regs.CX = 0x0101;	/* APM Version 1.1 */
  	regs.BX = APM_DEV_APM_BIOS;
***************
*** 707,710 ****
--- 719,723 ----
  		apm_minver = 0;
  	}
+ ok:
  	printf("Power Management spec V%d.%d", apm_majver, apm_minver);
  	apm_inited = 1;
***************
*** 898,904 ****
--- 911,919 ----
  			apminfo.apm_data_seg_len = 65536;
  			apm_v11_enabled = 0;
+ 			apm_v12_enabled = 0;
  			break;
  		case 0x0101:
  			apminfo.apm_code16_seg_len = apminfo.apm_code32_seg_len;
+ 			apm_v12_enabled = 0;
  			/* fall through */
  		case 0x0102:
***************
*** 1125,1135 ****
  	    &apminfo.apm_segsel,
  	    apmsc->sc_dev.dv_xname));
- 
- #ifdef APMDEBUG
- 	/* support isn't complete yet */
- 	if (APM_MAJOR_VERS(apminfo.apm_detail) == 0x01 &&
- 	    APM_MINOR_VERS(apminfo.apm_detail) == 0x02)
- 	  apm_v12_enabled = 1;
- #endif
  
  	apm_set_ver(apmsc);		/* prints version info */
--- 1140,1143 ----