From ace9429bb58fd418f0c81d4c2835699bddf6bde6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:27:49 +0200 Subject: Adding upstream version 6.6.15. Signed-off-by: Daniel Baumann --- drivers/video/backlight/ipaq_micro_bl.c | 76 +++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 drivers/video/backlight/ipaq_micro_bl.c (limited to 'drivers/video/backlight/ipaq_micro_bl.c') diff --git a/drivers/video/backlight/ipaq_micro_bl.c b/drivers/video/backlight/ipaq_micro_bl.c new file mode 100644 index 0000000000..f595b8c8cb --- /dev/null +++ b/drivers/video/backlight/ipaq_micro_bl.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * + * iPAQ microcontroller backlight support + * Author : Linus Walleij + */ + +#include +#include +#include +#include +#include +#include +#include + +static int micro_bl_update_status(struct backlight_device *bd) +{ + struct ipaq_micro *micro = dev_get_drvdata(&bd->dev); + int intensity = backlight_get_brightness(bd); + struct ipaq_micro_msg msg = { + .id = MSG_BACKLIGHT, + .tx_len = 3, + }; + + /* + * Message format: + * Byte 0: backlight instance (usually 1) + * Byte 1: on/off + * Byte 2: intensity, 0-255 + */ + msg.tx_data[0] = 0x01; + msg.tx_data[1] = intensity > 0 ? 1 : 0; + msg.tx_data[2] = intensity; + return ipaq_micro_tx_msg_sync(micro, &msg); +} + +static const struct backlight_ops micro_bl_ops = { + .options = BL_CORE_SUSPENDRESUME, + .update_status = micro_bl_update_status, +}; + +static const struct backlight_properties micro_bl_props = { + .type = BACKLIGHT_RAW, + .max_brightness = 255, + .power = FB_BLANK_UNBLANK, + .brightness = 64, +}; + +static int micro_backlight_probe(struct platform_device *pdev) +{ + struct backlight_device *bd; + struct ipaq_micro *micro = dev_get_drvdata(pdev->dev.parent); + + bd = devm_backlight_device_register(&pdev->dev, "ipaq-micro-backlight", + &pdev->dev, micro, µ_bl_ops, + µ_bl_props); + if (IS_ERR(bd)) + return PTR_ERR(bd); + + platform_set_drvdata(pdev, bd); + backlight_update_status(bd); + + return 0; +} + +static struct platform_driver micro_backlight_device_driver = { + .driver = { + .name = "ipaq-micro-backlight", + }, + .probe = micro_backlight_probe, +}; +module_platform_driver(micro_backlight_device_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("driver for iPAQ Atmel micro backlight"); +MODULE_ALIAS("platform:ipaq-micro-backlight"); -- cgit v1.2.3