Fix APM on Sony Vaio Laptops for 2.5

Fix APM on Sony Vaio Laptops for 2.5

Post by Cort Douga » Fri, 20 Sep 2002 00:20:07



This is the 2.5 version of the patch I sent earlier for 2.4.

Message that went with the 2.4 version and applies to this one as well:

This patch fixes a problem with Sony Vaio laptops where they don't notify
the kernel of power source change events.  That means apmd is never told
and many of the apmd features can't be used.

The Sony Vaio doesn't send APM events to the kernel telling it
about 'going on battery' or 'going on AC power' events.  It will register
them correctly if they're queried but it won't asynchronously send an event
so the kernel never tells apmd about it.

This patch fixes the situation by checking against the last known power
state (and power source) in the check_status() call.

This was tested on a Sony Vaio z505js, model PCG-5201 and it works
beautifully.  I'm told other Vaio notebooks have this same problem and this
fixes it as well.  Now, Vaio users can setup apmd to aggressively try to
save power when on battery or perform other crazy tasks.

You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


  Work around the Sony Vaio APM on-AC/on-battery problem.

  Sony Vaios won't send asynchronous notifies to the kernel
  of on-battery/on-AC events so we have to track the last known
  power source and send events when it changes.

  apmd now functions properly on the Vaio.

 apm.c      |   28 ++++++++++++++++++++++++++++
 dmi_scan.c |   28 ++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff -Nru a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
--- a/arch/i386/kernel/apm.c    Wed Sep 18 08:26:06 2002

 extern spinlock_t i8253_lock;
 extern unsigned long get_cmos_time(void);
 extern void machine_real_restart(unsigned char *, int);
+extern int apm_bios_power_change_bug;

 #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)

                         */
                        (void) suspend(0);
                        break;
+               }
+       }
+
+
+       /*
+        * The Sony Vaio doesn't seem to want to send us a notify
+        * about AC line power status changes.  So, we have to keep track
+        * of it by hand and emulate it here.

+        */
+       if ( apm_bios_power_change_bug ) {
+               static int last_status = 0;
+               u_short status, bat, life;
+
+               /* get the current power state */
+               if ( apm_get_power_status(&status, &bat, &life) !=
+                    APM_SUCCESS ) {
+                       printk("%s:%s error checking power status\n",
+                              __FILE__,__FUNCTION__);
+               }
+              
+               /* has the status changed since we were last here? */
+               if (((status >> 8) & 0xff) != last_status) {
+                       last_status = (status >> 8) & 0xff;
+                      
+                       /* fake a APM_POWER_STATUS_CHANGE event */
+                       queue_event(APM_POWER_STATUS_CHANGE, NULL);
                }
        }
 }
diff -Nru a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c
--- a/arch/i386/kernel/dmi_scan.c       Wed Sep 18 08:26:06 2002

 unsigned long dmi_broken;
 int is_sony_vaio_laptop;
+int apm_bios_power_change_bug;
 int is_unsafe_smbus;


 }

 /*
+ * Some Vaio laptops don't notify the kernel of a power status change
+ * such as on-AC/on-battery.  This detects some of the faulty machines
+ * and sets a variable that lets arch/i386/kernel/apm.c deal with it.
+ *
+ * I've seen this with the Vaio z505js PCG-5201 and PCG-SR33:
+ * model PCG-Z505JS(UC), bios Phoenix Technologies LTD version R0121Z1
+ * model PCG-SR33(UC), bios Phoenix Technologies LTD version R0211D1

+ */
+static __init int sony_vaio_apm_change(struct dmi_blacklist *d)
+{
+       apm_bios_power_change_bug = 1;
+       printk(KERN_WARNING "%s detected: APM power status change workaround enabled\n",
+              d->ident);
+       return 0;
+}
+
+/*
  * The Intel 440GX hall of shame.
  *

                        NO_MATCH, NO_MATCH, NO_MATCH
                        } },

+       /*
+        *      Sony Vaio Asynchronous powerstate notify emulation
+        */
+      
+       { sony_vaio_apm_change, "Sony Vaio", {        /* APM won't send power change events */
+                       MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
+                       MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
+                       NO_MATCH, NO_MATCH
+                       } },
        { NULL, }
 };

===================================================================

This BitKeeper patch contains the following changesets:
1.566
## Wrapped with gzip_uu ##

begin 664 bkpatch31594
`
end
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. Another Sony Vaio laptop with a broken APM...

Hi,

This patch adds yet another Vaio laptop to the list of those
having the APM minutes left swapping problem.

However, the Vaio bioses list is getting bigger and bigger
and I wonder if there is _any_ Vaio laptop that gets this
item right. If not, we could just do a search on SYS_VENDOR /
PRODUCT_NAME strings, like the is_sony_vaio_laptop test...

Comments ?

In the meanwhile, Alan, please apply.

Stelian.

diff -uNr --exclude-from=dontdiff linux-2.4.8-ac5.orig/arch/i386/kernel/dmi_scan.c linux-2.4.8-ac5/arch/i386/kernel/dmi_scan.c
--- linux-2.4.8-ac5.orig/arch/i386/kernel/dmi_scan.c    Thu Aug 16 13:56:37 2001

                        MATCH(DMI_BIOS_VERSION, "R0121Z1"),
                        MATCH(DMI_BIOS_DATE, "05/11/00"), NO_MATCH
                        } },
+       { swab_apm_power_in_minutes, "Sony VAIO", {   /* Handle problems with APM on Sony Vaio PCG-C1VN/C1VE */
+                       MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
+                       MATCH(DMI_BIOS_VERSION, "R0208P1"),
+                       MATCH(DMI_BIOS_DATE, "11/09/00"), NO_MATCH
+                       } },

        /* Problem Intel 440GX bioses */

--

|---------------- Free Software Engineer -----------------|
| Alc?ve - http://www.alcove.com - Tel: +33 1 49 22 68 00 |
|------------- Alc?ve, liberating software ---------------|
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Key strokes for Operating Linux (Mouse won't work)

3. irq handling and APM on new Laptop Sony Vaio GRX 570

4. su problem

5. Linux Laptop APM and Sony Vaio 505

6. What are "Rock Ridge Extensions"?

7. Fix APM for Sony Vaio against v2.4

8. is that possible to specify a logon message

9. Anyone with experience using Solaris on a Sony VAIO laptop?

10. X on Sony Vaio PCG-717C Laptop

11. $2,499 DVD-ROM 14.1"TFT Sony Vaio Laptop!!!

12. USB driver for Sony Vaio laptop?

13. Red Hat 8.0 installation crashes at the very beginning - Sony VAIO PCG-GRV516G, laptop, psyche