Your SlideShare is downloading. ×
0
Linux mouse
Linux mouse
Linux mouse
Linux mouse
Linux mouse
Linux mouse
Linux mouse
Linux mouse
Linux mouse
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Linux mouse

2,441

Published on

Linux mouse driver

Linux mouse driver

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,441
On Slideshare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
28
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Linux Mouse Driver /PS2 By Sean Chen 2010/04/30
  • 2. Agenda
    • How and How to do it ?
    • Input sub System 4 Mouse
    • Flow Chart 4 Mouse
    • Trace code
      • main();
        • module_init();
          • mousedev_create();
          • input_register_handler();
    • Append References
  • 3. How and How to do it ?
    • Mouse
      • Event
        • Mouse location (x,y)
        • Mouse key (Left, Right, Wheel)
      • Event handle
        • Display(X,Y);
        • Left_Pros();
    • How to do it ?
      • … Driver .
    • Driver
      • Linux2.6.X/ drivers/input
        • Input sub system call
  • 4. Input sub System 4 Mouse
    • Input sub System 4 Mouse
      • Driver
        • Mouse detected (Physical)
      • Input Core
        • Input Layer
          • Event ( Event Handler)
          • Connect ( set bit, .flags ….)
      • Event Handler
        • Mouse location
          • X, Y
        • Key function (process)
          • Left, Right , Wheel
    • Sequence
      • Driver -> InputCore -> Eventhandler -> userspace (user application)
  • 5. Flow Chart 4 Mouse Input sub System 4 Mouse Device Driver input_handler . event = mousedev_event, . connect = mousedev_connect , .disconnect = mousedev_disconnect, .fops = &mousedev_fops, .minor = MOUSEDEV_MINOR_BASE, .name = "mousedev", .id_table = mousedev_ids, mousedev_event case EV_ABS: case EV_REL: case EV_KEY: case EV_SYN: mousedev_connect .flags : .evbit : .keybit : .relbit : .absbit : … Create_mouse_device User Application
  • 6. Trace code/main()
    • Linux Kernel 2.6.X
      • Path /linux-2.6.33.3/drivers/input/mousedev.c
    • Include
      • #include <linux/init.h>
        • 宣告一些 macro 供 Linux 處理 initial function || section
      • #include <linux/input.h>
        • subsystem for “ 鍵盤與滑鼠的輸入”
        • event define
      • #include <linux/device.h>
        • Register device 2 Linux
      • #include <linux/smp_lock.h>
        • Lock processor
    • Define
      • CONFIG_INPUT_MOUSEDEV_SCREEN_ X
      • CONFIG_INPUT_MOUSEDEV_SCREEN_ Y
    • module_init(mousedev_init)
    • module_exit(mousedev_exit);
    X Y
  • 7. Trace code/module_init();
    • module_init(mousedev_init);
      • mousedev_create(& mousedev_handler );
        • kzalloc(); // 動態產生記憶體位置給 mouse_dev
        • INIT_LIST_HEAD(); // 加入 List_head 中 , 讓 Linux kernel 能 handle
        • spin_lock_init(); // lock_init, 避免中斷
        • mutex_init(); // 同步處理 , 判斷是否 lock
        • init_waitqueue_head(); // 設定 wait time
        • mousedev->handle.dev
        • mousedev->handle.handler
        • … .
        • Error handle
      • input_register_handler (&mousedev_handler );
        • 註冊滑鼠的 Handler
        • Event
      • Error Handle
  • 8. Trace code /mousedev_event()
    • Event type
      • EV_ABS: Absolute axes (絕對座標)。
      • EV_REL: Relative axes (相對座標)。
      • EV_KEY: Keys and buttons (按鍵與按鈕)。
      • EV_SYN:
        • Sample
          • case REL_X:
            • mousedev->packet.dx += value;
    • Set
      • set_bit(index, &mousedev->packet.buttons);
  • 9. Append References
    • Linux Input Device 介紹 : APIs
      • http://www.jollen.org/blog/2009/04/linux_input_device_apis.html
    • Linux mutex
      • http://blog.csdn.net/David_Henry/archive/2010/03/22/5404799.aspx
    • Linux Mouse Driver Sample
      • http://fred-zone.blogspot.com/2010/01/mouse-linux-kernel-driver.html
    • linux 输入子系统分析
      • http://blog.chinaunix.net/u3/108121/showart_2122577.html

×