提交 43d782ae 编写于 作者: D David Herrmann 提交者: Jiri Kosina

HID: wiimote: Allow direct DRM debug access

Keep track of current drm and add new debugfs file which reads or writes the
current DRM.
Signed-off-by: NDavid Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 1d3452c6
master alk-4.19.24 alk-4.19.30 alk-4.19.34 alk-4.19.36 alk-4.19.43 alk-4.19.48 alk-4.19.57 ck-4.19.67 ck-4.19.81 ck-4.19.91 github/fork/deepanshu1422/fix-typo-in-comment github/fork/haosdent/fix-typo linux-next v4.19.91 v4.19.90 v4.19.89 v4.19.88 v4.19.87 v4.19.86 v4.19.85 v4.19.84 v4.19.83 v4.19.82 v4.19.81 v4.19.80 v4.19.79 v4.19.78 v4.19.77 v4.19.76 v4.19.75 v4.19.74 v4.19.73 v4.19.72 v4.19.71 v4.19.70 v4.19.69 v4.19.68 v4.19.67 v4.19.66 v4.19.65 v4.19.64 v4.19.63 v4.19.62 v4.19.61 v4.19.60 v4.19.59 v4.19.58 v4.19.57 v4.19.56 v4.19.55 v4.19.54 v4.19.53 v4.19.52 v4.19.51 v4.19.50 v4.19.49 v4.19.48 v4.19.47 v4.19.46 v4.19.45 v4.19.44 v4.19.43 v4.19.42 v4.19.41 v4.19.40 v4.19.39 v4.19.38 v4.19.37 v4.19.36 v4.19.35 v4.19.34 v4.19.33 v4.19.32 v4.19.31 v4.19.30 v4.19.29 v4.19.28 v4.19.27 v4.19.26 v4.19.25 v4.19.24 v4.19.23 v4.19.22 v4.19.21 v4.19.20 v4.19.19 v4.19.18 v4.19.17 v4.19.16 v4.19.15 v4.19.14 v4.19.13 v4.19.12 v4.19.11 v4.19.10 v4.19.9 v4.19.8 v4.19.7 v4.19.6 v4.19.5 v4.19.4 v4.19.3 v4.19.2 v4.19.1 v4.19 v4.19-rc8 v4.19-rc7 v4.19-rc6 v4.19-rc5 v4.19-rc4 v4.19-rc3 v4.19-rc2 v4.19-rc1 ck-release-21 ck-release-20 ck-release-19.2 ck-release-19.1 ck-release-19 ck-release-18 ck-release-17.2 ck-release-17.1 ck-release-17 ck-release-16 ck-release-15.1 ck-release-15 ck-release-14 ck-release-13.2 ck-release-13 ck-release-12 ck-release-11 ck-release-10 ck-release-9 ck-release-7 alk-release-15 alk-release-14 alk-release-13.2 alk-release-13 alk-release-12 alk-release-11 alk-release-10 alk-release-9 alk-release-7
无相关合并请求
......@@ -238,6 +238,7 @@ void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
cmd[1] = 0;
cmd[2] = drm;
wdata->state.drm = drm;
wiiproto_keep_rumble(wdata, &cmd[1]);
wiimote_queue(wdata, cmd, sizeof(cmd));
}
......@@ -1141,6 +1142,7 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
spin_lock_init(&wdata->state.lock);
init_completion(&wdata->state.ready);
mutex_init(&wdata->state.sync);
wdata->state.drm = WIIPROTO_REQ_DRM_K;
return wdata;
......
......@@ -12,6 +12,7 @@
#include <linux/debugfs.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
#include "hid-wiimote.h"
......@@ -19,6 +20,7 @@
struct wiimote_debug {
struct wiimote_data *wdata;
struct dentry *eeprom;
struct dentry *drm;
};
static int wiidebug_eeprom_open(struct inode *i, struct file *f)
......@@ -86,10 +88,97 @@ static const struct file_operations wiidebug_eeprom_fops = {
.llseek = generic_file_llseek,
};
static const char *wiidebug_drmmap[] = {
[WIIPROTO_REQ_NULL] = "NULL",
[WIIPROTO_REQ_DRM_K] = "K",
[WIIPROTO_REQ_DRM_KA] = "KA",
[WIIPROTO_REQ_DRM_KE] = "KE",
[WIIPROTO_REQ_DRM_KAI] = "KAI",
[WIIPROTO_REQ_DRM_KEE] = "KEE",
[WIIPROTO_REQ_DRM_KAE] = "KAE",
[WIIPROTO_REQ_DRM_KIE] = "KIE",
[WIIPROTO_REQ_DRM_KAIE] = "KAIE",
[WIIPROTO_REQ_DRM_E] = "E",
[WIIPROTO_REQ_DRM_SKAI1] = "SKAI1",
[WIIPROTO_REQ_DRM_SKAI2] = "SKAI2",
[WIIPROTO_REQ_MAX] = NULL
};
static int wiidebug_drm_show(struct seq_file *f, void *p)
{
struct wiimote_debug *dbg = f->private;
const char *str = NULL;
unsigned long flags;
__u8 drm;
spin_lock_irqsave(&dbg->wdata->state.lock, flags);
drm = dbg->wdata->state.drm;
spin_unlock_irqrestore(&dbg->wdata->state.lock, flags);
if (drm < WIIPROTO_REQ_MAX)
str = wiidebug_drmmap[drm];
if (!str)
str = "unknown";
seq_printf(f, "%s\n", str);
return 0;
}
static int wiidebug_drm_open(struct inode *i, struct file *f)
{
return single_open(f, wiidebug_drm_show, i->i_private);
}
static ssize_t wiidebug_drm_write(struct file *f, const char __user *u,
size_t s, loff_t *off)
{
struct wiimote_debug *dbg = f->private_data;
unsigned long flags;
char buf[16];
ssize_t len;
int i;
if (s == 0)
return -EINVAL;
len = min((size_t) 15, s);
if (copy_from_user(buf, u, len))
return -EFAULT;
buf[15] = 0;
for (i = 0; i < WIIPROTO_REQ_MAX; ++i) {
if (!wiidebug_drmmap[i])
continue;
if (!strcasecmp(buf, wiidebug_drmmap[i]))
break;
}
if (i == WIIPROTO_REQ_MAX)
i = simple_strtoul(buf, NULL, 10);
spin_lock_irqsave(&dbg->wdata->state.lock, flags);
wiiproto_req_drm(dbg->wdata, (__u8) i);
spin_unlock_irqrestore(&dbg->wdata->state.lock, flags);
return len;
}
static const struct file_operations wiidebug_drm_fops = {
.owner = THIS_MODULE,
.open = wiidebug_drm_open,
.read = seq_read,
.llseek = seq_lseek,
.write = wiidebug_drm_write,
.release = single_release,
};
int wiidebug_init(struct wiimote_data *wdata)
{
struct wiimote_debug *dbg;
unsigned long flags;
int ret = -ENOMEM;
dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
if (!dbg)
......@@ -99,16 +188,25 @@ int wiidebug_init(struct wiimote_data *wdata)
dbg->eeprom = debugfs_create_file("eeprom", S_IRUSR,
dbg->wdata->hdev->debug_dir, dbg, &wiidebug_eeprom_fops);
if (!dbg->eeprom) {
kfree(dbg);
return -ENOMEM;
}
if (!dbg->eeprom)
goto err;
dbg->drm = debugfs_create_file("drm", S_IRUSR,
dbg->wdata->hdev->debug_dir, dbg, &wiidebug_drm_fops);
if (!dbg->drm)
goto err_drm;
spin_lock_irqsave(&wdata->state.lock, flags);
wdata->debug = dbg;
spin_unlock_irqrestore(&wdata->state.lock, flags);
return 0;
err_drm:
debugfs_remove(dbg->eeprom);
err:
kfree(dbg);
return ret;
}
void wiidebug_deinit(struct wiimote_data *wdata)
......@@ -123,6 +221,7 @@ void wiidebug_deinit(struct wiimote_data *wdata)
wdata->debug = NULL;
spin_unlock_irqrestore(&wdata->state.lock, flags);
debugfs_remove(dbg->drm);
debugfs_remove(dbg->eeprom);
kfree(dbg);
}
......@@ -52,6 +52,7 @@ struct wiimote_state {
spinlock_t lock;
__u8 flags;
__u8 accel_split[2];
__u8 drm;
/* synchronous cmd requests */
struct mutex sync;
......@@ -109,6 +110,7 @@ enum wiiproto_reqs {
WIIPROTO_REQ_DRM_E = 0x3d,
WIIPROTO_REQ_DRM_SKAI1 = 0x3e,
WIIPROTO_REQ_DRM_SKAI2 = 0x3f,
WIIPROTO_REQ_MAX
};
#define dev_to_wii(pdev) hid_get_drvdata(container_of(pdev, struct hid_device, \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部