手写笔 Notekaker linux驱动代码

/*

  • Pegasus Mobile Notetaker Pen input tablet driver

*/

/*

  • request packet (control endpoint):
  • |-------------------------------------|
  • | Report ID | Nr of bytes | command |
  • | (1 byte) | (1 byte) | (n bytes) |
  • |-------------------------------------|
  • | 0x02 | n | |
  • |-------------------------------------|
  • data packet after set xy mode command, 0x80 0xb5 0x02 0x01
  • and pen is in range:
  • byte byte name value (bits)

  • 0 status 0 1 0 0 0 0 X X
  • 1 color 0 0 0 0 H 0 S T
  • 2 X low
  • 3 X high
  • 4 Y low
  • 5 Y high
  • X X battery state:
  • no state reported 0x00
  • battery low 0x01
  • battery good 0x02
  • H Hovering
  • S Switch 1 (pen button)
  • T Tip
    */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/input.h>
#include <linux/usb/input.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/mutex.h>

/* USB HID defines */
#define USB_REQ_GET_REPORT 0x01
#define USB_REQ_SET_REPORT 0x09

#define USB_VENDOR_ID_PEGASUSTECH 0x0e20
#define USB_DEVICE_ID_PEGASUS_NOTETAKER_EN100 0x0101

/* device specific defines */
#define NOTETAKER_REPORT_ID 0x02
#define NOTETAKER_SET_CMD 0x80
#define NOTETAKER_SET_MODE 0xb5

#define NOTETAKER_LED_MOUSE 0x02
#define PEN_MODE_XY 0x01

#define SPECIAL_COMMAND 0x80
#define BUTTON_PRESSED 0xb5
#define COMMAND_VERSION 0xa9

/* in xy data packet */
#define BATTERY_NO_REPORT 0x40
#define BATTERY_LOW 0x41
#define BATTERY_GOOD 0x42
#define PEN_BUTTON_PRESSED BIT(1)
#define PEN_TIP BIT(0)

struct pegasus {
unsigned char *data;
u8 data_len;
dma_addr_t data_dma;
struct input_dev *dev;
struct usb_device *usbdev;
struct usb_interface *intf;
struct urb *irq;

/* serialize access to open/suspend */
struct mutex pm_mutex;
bool is_open;

char name[128];
char phys[64];
struct work_struct init;

};

static int pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len)
{
const int sizeof_buf = len + 2;
int result;
int error;
u8 *cmd_buf;

cmd_buf = kmalloc(sizeof_buf, GFP_KERNEL);
if (!cmd_buf)
	return -ENOMEM;

cmd_buf[0] = NO
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

baidu_37552881

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值