linux3.8内核下载,linux 3.8内核usbmouse代码注释

linux 3.8.0版本内核usbmouse.c文件代码注释

/* * Copyright (c) 1999-2001 Vojtech Pavlik

* * USB HIDBP Mouse support

*/

/* * This program is free software; you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or

* (at your option) any later version. *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details.

* * You should have received a copy of the GNU General Public License

* along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

* * Should you need to contact me, the author, you can do so either by

* e-mail - mail your message to , or by paper mail: * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic

*/

#include #include

#include #include

#include #include

/* for apple IDs */

#ifdef CONFIG_USB_HID_MODULE#include "../hid-ids.h"

#endif

/* * Version Information

*/#define DRIVER_VERSION "v1.6"

#define DRIVER_AUTHOR "Vojtech Pavlik "#define DRIVER_DESC "USB HID Boot Protocol mouse driver"

#define DRIVER_LICENSE "GPL"

MODULE_AUTHOR(DRIVER_AUTHOR);MODULE_DESCRIPTION(DRIVER_DESC);

MODULE_LICENSE(DRIVER_LICENSE);

struct usb_mouse {char name[128];/* 鼠标设备的名称,包括生产厂商、产品类别、产品等信息 */

char phys[64];/* 设备节点名称 */ struct usb_device *usbdev;/* USB 鼠标是一种 USB 设备,需要内嵌一个 USB 设备结构体来描述其 USB 属性 */ struct input_dev *dev;/* USB 鼠标同时又是一种输入设备,需要内嵌一个输入设备结构体来描述其输入设备的属性 */ struct urb *irq;/* URB 请求包结构体,用于传送数据 */

signed char *data;/* 普通传输用的地址 ,将保存着鼠标的按键和移动坐标信息*/

dma_addr_t data_dma;/* dma 传输用的地址 */ };

/*

* urb 回调函数,在完成提交 urb 后,urb 回调函数将被调用。 * 此函数作为 usb_fill_int_urb 函数的形参,为构建的 urb 制定的回调函数。

*/ static void usb_mouse_irq(struct urb *urb)

{ /*

* urb 中的 context 指针用于为 USB 驱动程序保存一些数据。比如在这个回调函数的形参没有传递在 probe * 中为 mouse 结构体分配的那块内存的地址指针,而又需要用到那块内存区域中的数据,context 指针则帮了 * 大忙了! * 这里的context就是保存了一个usb_mouse结构

* 在填充 urb 时将 context 指针指向 mouse 结构体数据区,在这又创建一个局部 mouse 指针指向在 probe * 函数中为 mouse 申请的那块内存,那块内存保存着非常重要数据。

* 当 urb 通过 USB core 提交给 hc 之后,如果结果正常,mouse->data 指向的内存区域将保存着鼠标的按键 * 和移动坐标信息,系统则依靠这些信息对鼠标的行为作出反应。

* mouse 中内嵌的 dev 指针,指向 input_dev 所属于的内存区域。 */

struct usb_mouse *mouse = urb->context;signed char *data = mouse->data;

struct input_dev *dev = mouse->dev;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值