From e9f4c5f9b92ade8465414d3a461d490bf7861476 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 15 Apr 2015 15:39:55 +0300 Subject: intel_backlight: switch to INREG and OUTREG Use INREG and OUTREG instead of using mmio directly. Signed-off-by: Jani Nikula --- tools/intel_backlight.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'tools/intel_backlight.c') diff --git a/tools/intel_backlight.c b/tools/intel_backlight.c index 17deb88d..067fd418 100644 --- a/tools/intel_backlight.c +++ b/tools/intel_backlight.c @@ -36,24 +36,14 @@ /* XXX PCH only today */ -static uint32_t reg_read(uint32_t reg) -{ - return *(volatile uint32_t *)((volatile char*)mmio + reg); -} - -static void reg_write(uint32_t reg, uint32_t val) -{ - *(volatile uint32_t *)((volatile char*)mmio + reg) = val; -} - int main(int argc, char** argv) { uint32_t current, max; intel_mmio_use_pci_bar(intel_get_pci_device()); - current = reg_read(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK; - max = reg_read(BLC_PWM_PCH_CTL2) >> 16; + current = INREG(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK; + max = INREG(BLC_PWM_PCH_CTL2) >> 16; printf ("current backlight value: %d%%\n", current * 100 / max); @@ -61,9 +51,9 @@ int main(int argc, char** argv) uint32_t v = atoi (argv[1]) * max / 100; if (v > max) v = max; - reg_write(BLC_PWM_CPU_CTL, - (reg_read(BLC_PWM_CPU_CTL) &~ BACKLIGHT_DUTY_CYCLE_MASK) | v); - (void) reg_read(BLC_PWM_CPU_CTL); + OUTREG(BLC_PWM_CPU_CTL, + (INREG(BLC_PWM_CPU_CTL) &~ BACKLIGHT_DUTY_CYCLE_MASK) | v); + (void) INREG(BLC_PWM_CPU_CTL); printf ("set backlight to %d%%\n", v * 100 / max); } -- cgit v1.2.3