diff -rupN linux-5.10.100-orig/drivers/video/backlight/Kconfig linux-5.10.100/drivers/video/backlight/Kconfig --- linux-5.10.100-orig/drivers/video/backlight/Kconfig 2022-02-11 08:09:03.000000000 +0000 +++ linux-5.10.100/drivers/video/backlight/Kconfig 2022-02-12 21:52:54.561179953 +0000 @@ -386,6 +386,13 @@ config BACKLIGHT_LP8788 help This supports TI LP8788 backlight driver. +config BACKLIGHT_OPENFRAME + tristate "Openframe Backlight Driver" + depends on BACKLIGHT_CLASS_DEVICE && PCI && X86 + help + If you have an OpenFrame device say Y to enable the + backlight driver. + config BACKLIGHT_PANDORA tristate "Backlight driver for Pandora console" depends on TWL4030_CORE diff -rupN linux-5.10.100-orig/drivers/video/backlight/Makefile linux-5.10.100/drivers/video/backlight/Makefile --- linux-5.10.100-orig/drivers/video/backlight/Makefile 2022-02-11 08:09:03.000000000 +0000 +++ linux-5.10.100/drivers/video/backlight/Makefile 2022-02-12 21:53:21.357585032 +0000 @@ -45,6 +45,7 @@ obj-$(CONFIG_BACKLIGHT_LP8788) += lp878 obj-$(CONFIG_BACKLIGHT_LV5207LP) += lv5207lp.o obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o +obj-$(CONFIG_BACKLIGHT_OPENFRAME) += openframe_bl.o obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o diff -rupN linux-5.10.100-orig/drivers/video/backlight/openframe_bl.c linux-5.10.100/drivers/video/backlight/openframe_bl.c --- linux-5.10.100-orig/drivers/video/backlight/openframe_bl.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-5.10.100/drivers/video/backlight/openframe_bl.c 2022-02-12 21:54:07.241431420 +0000 @@ -0,0 +1,143 @@ +/* + * Backlight Driver for Openframe devices + * + * Copyright (c) 2010 Andrew de Quincey + * + * Based onprogear_bl.c driver by Marcin Juszkiewicz + * + * + * Based on Progear LCD driver by M Schacht + * + * + * Based on Sharp's Corgi Backlight Driver + * Based on Backlight Driver for HP Jornada 680 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static struct pci_dev *gfx_dev = NULL; +static u32 *bl_baseptr = NULL; + +static int openframe_set_intensity(struct backlight_device *bd) +{ + int intensity = bd->props.brightness; + + if (bd->props.power != FB_BLANK_UNBLANK) + intensity = 0; + if (bd->props.fb_blank != FB_BLANK_UNBLANK) + intensity = 0; + + *bl_baseptr = (intensity << 1) | 0x400000; + + return 0; +} + +static int openframe_get_intensity(struct backlight_device *bd) +{ + int intensity; + + intensity = (*bl_baseptr >> 1) & 0x2f; + + return intensity; +} + +static struct backlight_ops openframe_ops = { + .get_brightness = openframe_get_intensity, + .update_status = openframe_set_intensity, +}; + +static int openframe_probe(struct platform_device *pdev) +{ + u32 temp; + struct backlight_device *openframe_backlight_device; + struct backlight_properties props; + + gfx_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x8108, NULL); + if (!gfx_dev) { + printk("Intel SCH Poulsbo graphics controller not found.\n"); + return -ENODEV; + } + + pci_read_config_dword(gfx_dev, 16, &temp); + bl_baseptr = ioremap(temp + 0x61254, 4); + memset(&props, 0, sizeof(struct backlight_properties)); + props.max_brightness = 32; + props.power = FB_BLANK_UNBLANK; + props.type = BACKLIGHT_PLATFORM; + props.brightness = 32; + openframe_backlight_device = backlight_device_register("openframe-bl", + &pdev->dev, NULL, + &openframe_ops, &props); + if (IS_ERR(openframe_backlight_device)) { + iounmap(bl_baseptr); + pci_dev_put(gfx_dev); + return PTR_ERR(openframe_backlight_device); + } + platform_set_drvdata(pdev, openframe_backlight_device); + + openframe_set_intensity(openframe_backlight_device); + + return 0; +} + +static int openframe_remove(struct platform_device *pdev) +{ + struct backlight_device *bd = platform_get_drvdata(pdev); + backlight_device_unregister(bd); + + iounmap(bl_baseptr); + pci_dev_put(gfx_dev); + + return 0; +} + +static struct platform_driver openframe_driver = { + .probe = openframe_probe, + .remove = openframe_remove, + .driver = { + .name = "openframe-bl", + }, +}; + +static struct platform_device *openframe_device; + +static int __init openframe_init(void) +{ + int ret = platform_driver_register(&openframe_driver); + + if (ret) + return ret; + openframe_device = platform_device_register_simple("openframe-bl", -1, + NULL, 0); + if (IS_ERR(openframe_device)) { + platform_driver_unregister(&openframe_driver); + return PTR_ERR(openframe_device); + } + + return 0; +} + +static void __exit openframe_exit(void) +{ + platform_device_unregister(openframe_device); + platform_driver_unregister(&openframe_driver); +} + +module_init(openframe_init); +module_exit(openframe_exit); + +MODULE_AUTHOR("Andrew de Quincey "); +MODULE_DESCRIPTION("Openframe Backlight Driver"); +MODULE_LICENSE("GPL");