[PATCH i-g-t 03/10] intel_backlight: switch to INREG and OUTREG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use INREG and OUTREG instead of using mmio directly.

Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
---
 tools/intel_backlight.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/tools/intel_backlight.c b/tools/intel_backlight.c
index 17deb88d4be8..067fd4180968 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);
 	}
 
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux