linux/drivers/platform/x86/fujitsu-laptop.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*-*-linux-c-*-*/

/*
  Copyright (C) 2007,2008 Jonathan Woithe <[email protected]>
  Copyright (C) 2008 Peter Gruber <[email protected]>
  Copyright (C) 2008 Tony Vroon <[email protected]>
  Based on earlier work:
    Copyright (C) 2003 Shane Spencer <[email protected]>
    Adrian Yee <[email protected]>

  Templated from msi-laptop.c and thinkpad_acpi.c which is copyright
  by its respective authors.

 */

/*
 * fujitsu-laptop.c - Fujitsu laptop support, providing access to additional
 * features made available on a range of Fujitsu laptops including the
 * P2xxx/P5xxx/S6xxx/S7xxx series.
 *
 * This driver implements a vendor-specific backlight control interface for
 * Fujitsu laptops and provides support for hotkeys present on certain Fujitsu
 * laptops.
 *
 * This driver has been tested on a Fujitsu Lifebook S6410, S7020 and
 * P8010.  It should work on most P-series and S-series Lifebooks, but
 * YMMV.
 *
 * The module parameter use_alt_lcd_levels switches between different ACPI
 * brightness controls which are used by different Fujitsu laptops.  In most
 * cases the correct method is automatically detected. "use_alt_lcd_levels=1"
 * is applicable for a Fujitsu Lifebook S6410 if autodetection fails.
 *
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/acpi.h>
#include <linux/bitops.h>
#include <linux/dmi.h>
#include <linux/backlight.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
#include <linux/kfifo.h>
#include <linux/leds.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <acpi/battery.h>
#include <acpi/video.h>

#define FUJITSU_DRIVER_VERSION

#define FUJITSU_LCD_N_LEVELS

#define ACPI_FUJITSU_CLASS
#define ACPI_FUJITSU_BL_HID
#define ACPI_FUJITSU_BL_DRIVER_NAME
#define ACPI_FUJITSU_BL_DEVICE_NAME
#define ACPI_FUJITSU_LAPTOP_HID
#define ACPI_FUJITSU_LAPTOP_DRIVER_NAME
#define ACPI_FUJITSU_LAPTOP_DEVICE_NAME

#define ACPI_FUJITSU_NOTIFY_CODE

/* FUNC interface - command values */
#define FUNC_FLAGS
#define FUNC_LEDS
#define FUNC_BUTTONS
#define FUNC_BACKLIGHT

/* FUNC interface - responses */
#define UNSUPPORTED_CMD

/* FUNC interface - status flags */
#define FLAG_RFKILL
#define FLAG_LID
#define FLAG_DOCK
#define FLAG_TOUCHPAD_TOGGLE
#define FLAG_MICMUTE
#define FLAG_SOFTKEYS

/* FUNC interface - LED control */
#define FUNC_LED_OFF
#define FUNC_LED_ON
#define LOGOLAMP_POWERON
#define LOGOLAMP_ALWAYS
#define KEYBOARD_LAMPS
#define RADIO_LED_ON
#define ECO_LED
#define ECO_LED_ON

/* FUNC interface - backlight power control */
#define BACKLIGHT_PARAM_POWER
#define BACKLIGHT_OFF
#define BACKLIGHT_ON

/* FUNC interface - battery control interface */
#define FUNC_S006_METHOD
#define CHARGE_CONTROL_RW

/* Scancodes read from the GIRB register */
#define KEY1_CODE
#define KEY2_CODE
#define KEY3_CODE
#define KEY4_CODE
#define KEY5_CODE

/* Hotkey ringbuffer limits */
#define MAX_HOTKEY_RINGBUFFER_SIZE
#define RINGBUFFERSIZE

/* Module parameters */
static int use_alt_lcd_levels =;
static bool disable_brightness_adjust;

/* Device controlling the backlight and associated keys */
struct fujitsu_bl {};

static struct fujitsu_bl *fujitsu_bl;

/* Device used to access hotkeys and other features on the laptop */
struct fujitsu_laptop {};

static struct acpi_device *fext;

/* Fujitsu ACPI interface function */

static int call_fext_func(struct acpi_device *device,
			  int func, int op, int feature, int state)
{}

/* Battery charge control code */
static ssize_t charge_control_end_threshold_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{}

static ssize_t charge_control_end_threshold_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{}

static DEVICE_ATTR_RW(charge_control_end_threshold);

/* ACPI battery hook */
static int fujitsu_battery_add_hook(struct power_supply *battery,
			       struct acpi_battery_hook *hook)
{}

static int fujitsu_battery_remove_hook(struct power_supply *battery,
				  struct acpi_battery_hook *hook)
{}

static struct acpi_battery_hook battery_hook =;

/*
 * These functions are intended to be called from acpi_fujitsu_laptop_add and
 * acpi_fujitsu_laptop_remove.
 */
static int fujitsu_battery_charge_control_add(struct acpi_device *device)
{}

static void fujitsu_battery_charge_control_remove(struct acpi_device *device)
{}

/* Hardware access for LCD brightness control */

static int set_lcd_level(struct acpi_device *device, int level)
{}

static int get_lcd_level(struct acpi_device *device)
{}

static int get_max_brightness(struct acpi_device *device)
{}

/* Backlight device stuff */

static int bl_get_brightness(struct backlight_device *b)
{}

static int bl_update_status(struct backlight_device *b)
{}

static const struct backlight_ops fujitsu_bl_ops =;

static ssize_t lid_show(struct device *dev, struct device_attribute *attr,
			char *buf)
{}

static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}

static ssize_t radios_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}

static DEVICE_ATTR_RO(lid);
static DEVICE_ATTR_RO(dock);
static DEVICE_ATTR_RO(radios);

static struct attribute *fujitsu_pf_attributes[] =;

static const struct attribute_group fujitsu_pf_attribute_group =;

static struct platform_driver fujitsu_pf_driver =;

/* ACPI device for LCD brightness control */

static const struct key_entry keymap_backlight[] =;

static int acpi_fujitsu_bl_input_setup(struct acpi_device *device)
{}

static int fujitsu_backlight_register(struct acpi_device *device)
{}

static int acpi_fujitsu_bl_add(struct acpi_device *device)
{}

/* Brightness notify */

static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
{}

/* ACPI device for hotkey handling */

static const struct key_entry keymap_default[] =;

static const struct key_entry keymap_s64x0[] =;

static const struct key_entry keymap_p8010[] =;

static const struct key_entry *keymap =;

static int fujitsu_laptop_dmi_keymap_override(const struct dmi_system_id *id)
{}

static const struct dmi_system_id fujitsu_laptop_dmi_table[] =;

static int acpi_fujitsu_laptop_input_setup(struct acpi_device *device)
{}

static int fujitsu_laptop_platform_add(struct acpi_device *device)
{}

static void fujitsu_laptop_platform_remove(struct acpi_device *device)
{}

static int logolamp_set(struct led_classdev *cdev,
			enum led_brightness brightness)
{}

static enum led_brightness logolamp_get(struct led_classdev *cdev)
{}

static int kblamps_set(struct led_classdev *cdev,
		       enum led_brightness brightness)
{}

static enum led_brightness kblamps_get(struct led_classdev *cdev)
{}

static int radio_led_set(struct led_classdev *cdev,
			 enum led_brightness brightness)
{}

static enum led_brightness radio_led_get(struct led_classdev *cdev)
{}

static int eco_led_set(struct led_classdev *cdev,
		       enum led_brightness brightness)
{}

static enum led_brightness eco_led_get(struct led_classdev *cdev)
{}

static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device)
{}

static int acpi_fujitsu_laptop_add(struct acpi_device *device)
{}

static void acpi_fujitsu_laptop_remove(struct acpi_device *device)
{}

static void acpi_fujitsu_laptop_press(struct acpi_device *device, int scancode)
{}

static void acpi_fujitsu_laptop_release(struct acpi_device *device)
{}

static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event)
{}

/* Initialization */

static const struct acpi_device_id fujitsu_bl_device_ids[] =;

static struct acpi_driver acpi_fujitsu_bl_driver =;

static const struct acpi_device_id fujitsu_laptop_device_ids[] =;

static struct acpi_driver acpi_fujitsu_laptop_driver =;

static const struct acpi_device_id fujitsu_ids[] __used =;
MODULE_DEVICE_TABLE(acpi, fujitsu_ids);

static int __init fujitsu_init(void)
{}

static void __exit fujitsu_cleanup(void)
{}

module_init();
module_exit(fujitsu_cleanup);

module_param(use_alt_lcd_levels, int, 0644);
MODULE_PARM_DESC();
module_param(disable_brightness_adjust, bool, 0644);
MODULE_PARM_DESC();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_VERSION();
MODULE_LICENSE();