linux/drivers/hid/hid-wiimote-core.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * HID driver for Nintendo Wii / Wii U peripherals
 * Copyright (c) 2011-2013 David Herrmann <[email protected]>
 */

/*
 */

#include <linux/completion.h>
#include <linux/device.h>
#include <linux/hid.h>
#include <linux/input.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include "hid-ids.h"
#include "hid-wiimote.h"

/* output queue handling */

static int wiimote_hid_send(struct hid_device *hdev, __u8 *buffer,
			    size_t count)
{}

static void wiimote_queue_worker(struct work_struct *work)
{}

static void wiimote_queue(struct wiimote_data *wdata, const __u8 *buffer,
								size_t count)
{}

/*
 * This sets the rumble bit on the given output report if rumble is
 * currently enabled.
 * \cmd1 must point to the second byte in the output report => &cmd[1]
 * This must be called on nearly every output report before passing it
 * into the output queue!
 */
static inline void wiiproto_keep_rumble(struct wiimote_data *wdata, __u8 *cmd1)
{}

void wiiproto_req_rumble(struct wiimote_data *wdata, __u8 rumble)
{}

void wiiproto_req_leds(struct wiimote_data *wdata, int leds)
{}

/*
 * Check what peripherals of the wiimote are currently
 * active and select a proper DRM that supports all of
 * the requested data inputs.
 *
 * Not all combinations are actually supported. The following
 * combinations work only with limitations:
 *  - IR cam in extended or full mode disables any data transmission
 *    of extension controllers. There is no DRM mode that supports
 *    extension bytes plus extended/full IR.
 *  - IR cam with accelerometer and extension *_EXT8 is not supported.
 *    However, all extensions that need *_EXT8 are devices that don't
 *    support IR cameras. Hence, this shouldn't happen under normal
 *    operation.
 *  - *_EXT16 is only supported in combination with buttons and
 *    accelerometer. No IR or similar can be active simultaneously. As
 *    above, all modules that require it are mutually exclusive with
 *    IR/etc. so this doesn't matter.
 */
static __u8 select_drm(struct wiimote_data *wdata)
{}

void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
{}

void wiiproto_req_status(struct wiimote_data *wdata)
{}

void wiiproto_req_accel(struct wiimote_data *wdata, __u8 accel)
{}

void wiiproto_req_ir1(struct wiimote_data *wdata, __u8 flags)
{}

void wiiproto_req_ir2(struct wiimote_data *wdata, __u8 flags)
{}

#define wiiproto_req_wreg(wdata, os, buf, sz)

#define wiiproto_req_weeprom(wdata, os, buf, sz)

static void wiiproto_req_wmem(struct wiimote_data *wdata, bool eeprom,
				__u32 offset, const __u8 *buf, __u8 size)
{}

void wiiproto_req_rmem(struct wiimote_data *wdata, bool eeprom, __u32 offset,
								__u16 size)
{}

/* requries the cmd-mutex to be held */
int wiimote_cmd_write(struct wiimote_data *wdata, __u32 offset,
						const __u8 *wmem, __u8 size)
{}

/* requries the cmd-mutex to be held */
ssize_t wiimote_cmd_read(struct wiimote_data *wdata, __u32 offset, __u8 *rmem,
								__u8 size)
{}

/* requires the cmd-mutex to be held */
static int wiimote_cmd_init_ext(struct wiimote_data *wdata)
{}

/* requires the cmd-mutex to be held */
static __u8 wiimote_cmd_read_ext(struct wiimote_data *wdata, __u8 *rmem)
{}

/* requires the cmd-mutex to be held */
static int wiimote_cmd_init_mp(struct wiimote_data *wdata)
{}

/* requires the cmd-mutex to be held */
static bool wiimote_cmd_map_mp(struct wiimote_data *wdata, __u8 exttype)
{}

/* requires the cmd-mutex to be held */
static bool wiimote_cmd_read_mp(struct wiimote_data *wdata, __u8 *rmem)
{}

/* requires the cmd-mutex to be held */
static __u8 wiimote_cmd_read_mp_mapped(struct wiimote_data *wdata)
{}

/* device module handling */

static const __u8 * const wiimote_devtype_mods[WIIMOTE_DEV_NUM] =;

static void wiimote_modules_load(struct wiimote_data *wdata,
				 unsigned int devtype)
{}

static void wiimote_modules_unload(struct wiimote_data *wdata)
{}

/* device extension handling */

static void wiimote_ext_load(struct wiimote_data *wdata, unsigned int ext)
{}

static void wiimote_ext_unload(struct wiimote_data *wdata)
{}

static void wiimote_mp_load(struct wiimote_data *wdata)
{}

static void wiimote_mp_unload(struct wiimote_data *wdata)
{}

/* device (re-)initialization and detection */

static const char *wiimote_devtype_names[WIIMOTE_DEV_NUM] =;

/* Try to guess the device type based on all collected information. We
 * first try to detect by static extension types, then VID/PID and the
 * device name. If we cannot detect the device, we use
 * WIIMOTE_DEV_GENERIC so all modules will get probed on the device. */
static void wiimote_init_set_type(struct wiimote_data *wdata,
				  __u8 exttype)
{}

static void wiimote_init_detect(struct wiimote_data *wdata)
{}

/*
 * MP hotplug events are not generated by the wiimote. Therefore, we need
 * polling to detect it. We use a 4s interval for polling MP registers. This
 * seems reasonable considering applications can trigger it manually via
 * sysfs requests.
 */
static void wiimote_init_poll_mp(struct wiimote_data *wdata)
{}

/*
 * Check whether the wiimote is in the expected state. The extension registers
 * may change during hotplug and initialization so we might get hotplug events
 * that we caused by remapping some memory.
 * We use some heuristics here to check known states. If the wiimote is in the
 * expected state, we can ignore the hotplug event.
 *
 * Returns "true" if the device is in expected state, "false" if we should
 * redo hotplug handling and extension initialization.
 */
static bool wiimote_init_check(struct wiimote_data *wdata)
{}

static const char *wiimote_exttype_names[WIIMOTE_EXT_NUM] =;

/*
 * Handle hotplug events
 * If we receive an hotplug event and the device-check failed, we deinitialize
 * the extension ports, re-read all extension IDs and set the device into
 * the desired state. This involves mapping MP into the main extension
 * registers, setting up extension passthrough modes and initializing the
 * requested extensions.
 */
static void wiimote_init_hotplug(struct wiimote_data *wdata)
{}

static void wiimote_init_worker(struct work_struct *work)
{}

void __wiimote_schedule(struct wiimote_data *wdata)
{}

static void wiimote_schedule(struct wiimote_data *wdata)
{}

static void wiimote_init_timeout(struct timer_list *t)
{}

/* protocol handlers */

static void handler_keys(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_accel(struct wiimote_data *wdata, const __u8 *payload)
{}

static bool valid_ext_handler(const struct wiimod_ops *ops, size_t len)
{}

static void handler_ext(struct wiimote_data *wdata, const __u8 *payload,
			size_t len)
{}

#define ir_to_input0(wdata, ir, packed)
#define ir_to_input1(wdata, ir, packed)
#define ir_to_input2(wdata, ir, packed)
#define ir_to_input3(wdata, ir, packed)

static void handler_ir(struct wiimote_data *wdata, const __u8 *payload,
		       bool packed, unsigned int id)
{}

/* reduced status report with "BB BB" key data only */
static void handler_status_K(struct wiimote_data *wdata,
			     const __u8 *payload)
{}

/* extended status report with "BB BB LF 00 00 VV" data */
static void handler_status(struct wiimote_data *wdata, const __u8 *payload)
{}

/* reduced generic report with "BB BB" key data only */
static void handler_generic_K(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_data(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_return(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_KA(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_KE(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_KAI(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_KEE(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_KIE(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_KAE(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_KAIE(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_E(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_SKAI1(struct wiimote_data *wdata, const __u8 *payload)
{}

static void handler_drm_SKAI2(struct wiimote_data *wdata, const __u8 *payload)
{}

struct wiiproto_handler {};

static const struct wiiproto_handler handlers[] =;

static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
							u8 *raw_data, int size)
{}

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

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

static DEVICE_ATTR(extension, S_IRUGO | S_IWUSR | S_IWGRP, wiimote_ext_show,
		   wiimote_ext_store);

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

static DEVICE_ATTR(devtype, S_IRUGO, wiimote_dev_show, NULL);

static struct wiimote_data *wiimote_create(struct hid_device *hdev)
{}

static void wiimote_destroy(struct wiimote_data *wdata)
{}

static int wiimote_hid_probe(struct hid_device *hdev,
				const struct hid_device_id *id)
{}

static void wiimote_hid_remove(struct hid_device *hdev)
{}

static const struct hid_device_id wiimote_hid_devices[] =;

bool wiimote_dpad_as_analog =;
module_param_named(dpad_as_analog, wiimote_dpad_as_analog, bool, 0644);
MODULE_PARM_DESC();

MODULE_DEVICE_TABLE(hid, wiimote_hid_devices);

static struct hid_driver wiimote_hid_driver =;
module_hid_driver();

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