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

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

/*
  Copyright (C) 2006 Lennart Poettering <mzxreary (at) 0pointer (dot) de>

 */

/*
 * msi-laptop.c - MSI S270 laptop support. This laptop is sold under
 * various brands, including "Cytron/TCM/Medion/Tchibo MD96100".
 *
 * Driver also supports S271, S420 models.
 *
 * This driver exports a few files in /sys/devices/platform/msi-laptop-pf/:
 *
 *   lcd_level - Screen brightness: contains a single integer in the
 *   range 0..8. (rw)
 *
 *   auto_brightness - Enable automatic brightness control: contains
 *   either 0 or 1. If set to 1 the hardware adjusts the screen
 *   brightness automatically when the power cord is
 *   plugged/unplugged. (rw)
 *
 *   wlan - WLAN subsystem enabled: contains either 0 or 1. (ro)
 *
 *   bluetooth - Bluetooth subsystem enabled: contains either 0 or 1
 *   Please note that this file is constantly 0 if no Bluetooth
 *   hardware is available. (ro)
 *
 * In addition to these platform device attributes the driver
 * registers itself in the Linux backlight control subsystem and is
 * available to userspace under /sys/class/backlight/msi-laptop-bl/.
 *
 * This driver might work on other laptops produced by MSI. If you
 * want to try it you can pass force=1 as argument to the module which
 * will force it to load even when the DMI data doesn't identify the
 * laptop as MSI S270. YMMV.
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/backlight.h>
#include <linux/platform_device.h>
#include <linux/rfkill.h>
#include <linux/i8042.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
#include <acpi/video.h>

#define MSI_LCD_LEVEL_MAX

#define MSI_EC_COMMAND_WIRELESS
#define MSI_EC_COMMAND_LCD_LEVEL

#define MSI_STANDARD_EC_COMMAND_ADDRESS
#define MSI_STANDARD_EC_BLUETOOTH_MASK
#define MSI_STANDARD_EC_WEBCAM_MASK
#define MSI_STANDARD_EC_WLAN_MASK
#define MSI_STANDARD_EC_3G_MASK

/* For set SCM load flag to disable BIOS fn key */
#define MSI_STANDARD_EC_SCM_LOAD_ADDRESS
#define MSI_STANDARD_EC_SCM_LOAD_MASK

#define MSI_STANDARD_EC_FUNCTIONS_ADDRESS
/* Power LED is orange - Turbo mode */
#define MSI_STANDARD_EC_TURBO_MASK
/* Power LED is green - ECO mode */
#define MSI_STANDARD_EC_ECO_MASK
/* Touchpad is turned on */
#define MSI_STANDARD_EC_TOUCHPAD_MASK
/* If this bit != bit 1, turbo mode can't be toggled */
#define MSI_STANDARD_EC_TURBO_COOLDOWN_MASK

#define MSI_STANDARD_EC_FAN_ADDRESS
/* If zero, fan rotates at maximal speed */
#define MSI_STANDARD_EC_AUTOFAN_MASK

#ifdef CONFIG_PM_SLEEP
static int msi_laptop_resume(struct device *device);
#endif
static SIMPLE_DEV_PM_OPS(msi_laptop_pm, NULL, msi_laptop_resume);

#define MSI_STANDARD_EC_DEVICES_EXISTS_ADDRESS

static bool force;
module_param(force, bool, 0);
MODULE_PARM_DESC();

static int auto_brightness;
module_param(auto_brightness, int, 0);
MODULE_PARM_DESC();

static const struct key_entry msi_laptop_keymap[] =;

static struct input_dev *msi_laptop_input_dev;

static int wlan_s, bluetooth_s, threeg_s;
static int threeg_exists;
static struct rfkill *rfk_wlan, *rfk_bluetooth, *rfk_threeg;

/* MSI laptop quirks */
struct quirk_entry {};

static struct quirk_entry *quirks;

/* Hardware access */

static int set_lcd_level(int level)
{}

static int get_lcd_level(void)
{}

static int get_auto_brightness(void)
{}

static int set_auto_brightness(int enable)
{}

static ssize_t set_device_state(const char *buf, size_t count, u8 mask)
{}

static int get_wireless_state(int *wlan, int *bluetooth)
{}

static int get_wireless_state_ec_standard(void)
{}

static int get_threeg_exists(void)
{}

/* 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 msibl_ops =;

static struct backlight_device *msibl_device;

/* Platform device */

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

static ssize_t store_wlan(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{}

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

static ssize_t store_bluetooth(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{}

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

static ssize_t store_threeg(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{}

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

static ssize_t store_lcd_level(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{}

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

static ssize_t store_auto_brightness(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{}

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

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

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

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

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

static ssize_t store_auto_fan(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{}

static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level);
static DEVICE_ATTR(auto_brightness, 0644, show_auto_brightness,
		   store_auto_brightness);
static DEVICE_ATTR(bluetooth, 0444, show_bluetooth, NULL);
static DEVICE_ATTR(wlan, 0444, show_wlan, NULL);
static DEVICE_ATTR(threeg, 0444, show_threeg, NULL);
static DEVICE_ATTR(touchpad, 0444, show_touchpad, NULL);
static DEVICE_ATTR(turbo_mode, 0444, show_turbo, NULL);
static DEVICE_ATTR(eco_mode, 0444, show_eco, NULL);
static DEVICE_ATTR(turbo_cooldown, 0444, show_turbo_cooldown, NULL);
static DEVICE_ATTR(auto_fan, 0644, show_auto_fan, store_auto_fan);

static struct attribute *msipf_attributes[] =;

static struct attribute *msipf_old_attributes[] =;

static const struct attribute_group msipf_attribute_group =;

static const struct attribute_group msipf_old_attribute_group =;

static struct platform_driver msipf_driver =;

static struct platform_device *msipf_device;

/* Initialization */

static struct quirk_entry quirk_old_ec_model =;

static struct quirk_entry quirk_load_scm_model =;

static struct quirk_entry quirk_load_scm_ro_model =;

static int dmi_check_cb(const struct dmi_system_id *dmi)
{}

static unsigned long msi_work_delay(int msecs)
{}

static const struct dmi_system_id msi_dmi_table[] __initconst =;
MODULE_DEVICE_TABLE(dmi, msi_dmi_table);

static int rfkill_bluetooth_set(void *data, bool blocked)
{}

static int rfkill_wlan_set(void *data, bool blocked)
{}

static int rfkill_threeg_set(void *data, bool blocked)
{}

static const struct rfkill_ops rfkill_bluetooth_ops =;

static const struct rfkill_ops rfkill_wlan_ops =;

static const struct rfkill_ops rfkill_threeg_ops =;

static void rfkill_cleanup(void)
{}

static bool msi_rfkill_set_state(struct rfkill *rfkill, bool blocked)
{}

static void msi_update_rfkill(struct work_struct *ignored)
{}
static DECLARE_DELAYED_WORK(msi_rfkill_dwork, msi_update_rfkill);

static void msi_send_touchpad_key(struct work_struct *ignored)
{}
static DECLARE_DELAYED_WORK(msi_touchpad_dwork, msi_send_touchpad_key);

static bool msi_laptop_i8042_filter(unsigned char data, unsigned char str,
				struct serio *port)
{}

static void msi_init_rfkill(struct work_struct *ignored)
{}
static DECLARE_DELAYED_WORK(msi_rfkill_init, msi_init_rfkill);

static int rfkill_init(struct platform_device *sdev)
{}

static int msi_scm_disable_hw_fn_handling(void)
{}

#ifdef CONFIG_PM_SLEEP
static int msi_laptop_resume(struct device *device)
{}
#endif

static int __init msi_laptop_input_setup(void)
{}

static int __init load_scm_model_init(struct platform_device *sdev)
{}

static void msi_scm_model_exit(void)
{}

static int __init msi_init(void)
{}

static void __exit msi_cleanup(void)
{}

module_init();
module_exit(msi_cleanup);

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