linux/drivers/platform/surface/surfacepro3_button.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * power/home/volume button support for
 * Microsoft Surface Pro 3/4 tablet.
 *
 * Copyright (c) 2015 Intel Corporation.
 * All rights reserved.
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/input.h>
#include <linux/acpi.h>
#include <acpi/button.h>

#define SURFACE_PRO3_BUTTON_HID
#define SURFACE_PRO4_BUTTON_HID
#define SURFACE_BUTTON_OBJ_NAME
#define SURFACE_BUTTON_DEVICE_NAME

#define MSHW0040_DSM_REVISION
#define MSHW0040_DSM_GET_OMPR
static const guid_t MSHW0040_DSM_UUID =;

#define SURFACE_BUTTON_NOTIFY_TABLET_MODE

#define SURFACE_BUTTON_NOTIFY_PRESS_POWER
#define SURFACE_BUTTON_NOTIFY_RELEASE_POWER

#define SURFACE_BUTTON_NOTIFY_PRESS_HOME
#define SURFACE_BUTTON_NOTIFY_RELEASE_HOME

#define SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_UP
#define SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_UP

#define SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_DOWN
#define SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_DOWN

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

/*
 * Power button, Home button, Volume buttons support is supposed to
 * be covered by drivers/input/misc/soc_button_array.c, which is implemented
 * according to "Windows ACPI Design Guide for SoC Platforms".
 * However surface pro3 seems not to obey the specs, instead it uses
 * device VGBI(MSHW0028) for dispatching the events.
 * We choose acpi_driver rather than platform_driver/i2c_driver because
 * although VGBI has an i2c resource connected to i2c controller, it
 * is not embedded in any i2c controller's scope, thus neither platform_device
 * will be created, nor i2c_client will be enumerated, we have to use
 * acpi_driver.
 */
static const struct acpi_device_id surface_button_device_ids[] =;
MODULE_DEVICE_TABLE(acpi, surface_button_device_ids);

struct surface_button {};

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

#ifdef CONFIG_PM_SLEEP
static int surface_button_suspend(struct device *dev)
{}

static int surface_button_resume(struct device *dev)
{}
#endif

/*
 * Surface Pro 4 and Surface Book 2 / Surface Pro 2017 use the same device
 * ID (MSHW0040) for the power/volume buttons. Make sure this is the right
 * device by checking for the _DSM method and OEM Platform Revision.
 *
 * Returns true if the driver should bind to this device, i.e. the device is
 * either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1.
 */
static bool surface_button_check_MSHW0040(struct acpi_device *dev)
{}


static int surface_button_add(struct acpi_device *device)
{}

static void surface_button_remove(struct acpi_device *device)
{}

static SIMPLE_DEV_PM_OPS(surface_button_pm,
		surface_button_suspend, surface_button_resume);

static struct acpi_driver surface_button_driver =;

module_acpi_driver();