[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: F2 get power and date off (Re: iBook/sleep ?)
たぶんこんな感じでいいと思いますが、このコードどこに入れれば
いいのだろう…。(ここでは埋め込んでる)R128_BASE というアドレスは
ofb なんですが、ofb は建前上はハードウェアに直接さわらないことに
なっているので行き場所がなくなってしまったのでした。
*** abtn.c~ Fri Mar 30 02:44:50 2001
--- abtn.c Mon Apr 9 00:24:05 2001
***************
*** 30,40 ****
--- 30,48 ----
#include <sys/device.h>
#include <sys/systm.h>
+ #include <machine/pio.h>
#include <macppc/dev/adbvar.h>
#define NVRAM_BRIGHTNESS 0x140e
#define ABTN_HANDLER_ID 31
+ #define R128_BASE 0xa0000000 /* XXX */
+ #define LVDS_GEN_CNTL 0x02d0
+ #define LVDS_BL_MOD_LEVEL_MASK 0x0000ff00
+ #define LVDS_BL_MOD_EN 0x00010000
+ #define LVDS_DIGION 0x00040000
+ #define LVDS_BLON 0x00080000
+
struct abtn_softc {
struct device sc_dev;
***************
*** 81,90 ****
printf("brightness/volume button\n");
! bright = pm_read_nvram(NVRAM_BRIGHTNESS);
! if (bright != 0)
! pm_set_brightness(bright);
! sc->brightness = bright;
sc->origaddr = aa->origaddr;
sc->adbaddr = aa->adbaddr;
--- 89,96 ----
printf("brightness/volume button\n");
! sc->brightness =
! (in32rb(R128_BASE + LVDS_GEN_CNTL) & LVDS_BL_MOD_LEVEL_MASK) >> 8;
sc->origaddr = aa->origaddr;
sc->adbaddr = aa->adbaddr;
***************
*** 103,126 ****
{
struct abtn_softc *sc = (struct abtn_softc *)data;
u_int cmd;
cmd = buffer[1];
switch (cmd) {
case 0x0a:
! sc->brightness -= 8;
! if (sc->brightness < 8)
! sc->brightness = 8;
! pm_set_brightness(sc->brightness);
! pm_write_nvram(NVRAM_BRIGHTNESS, sc->brightness);
break;
case 0x09:
! sc->brightness += 8;
! if (sc->brightness > 0x78)
! sc->brightness = 0x78;
! pm_set_brightness(sc->brightness);
! pm_write_nvram(NVRAM_BRIGHTNESS, sc->brightness);
break;
}
}
--- 109,137 ----
{
struct abtn_softc *sc = (struct abtn_softc *)data;
u_int cmd;
+ u_int x;
cmd = buffer[1];
+ x = in32rb(R128_BASE + LVDS_GEN_CNTL);
+ x &= ~LVDS_BL_MOD_LEVEL_MASK;
+ x |= LVDS_BL_MOD_EN | LVDS_BLON;
+
switch (cmd) {
case 0x0a:
! sc->brightness += 8;
! if (sc->brightness > 0xe0)
! sc->brightness = 0xe0;
! x |= sc->brightness << 8;
! out32rb(R128_BASE + LVDS_GEN_CNTL, x);
break;
case 0x09:
! sc->brightness -= 8;
! if (sc->brightness < 0)
! sc->brightness = 0;
! x |= sc->brightness << 8;
! out32rb(R128_BASE + LVDS_GEN_CNTL, x);
break;
}
}