* Mouse driver @ 2015-03-07 4:27 Ronit Halder 2015-03-07 4:34 ` nick 0 siblings, 1 reply; 11+ messages in thread From: Ronit Halder @ 2015-03-07 4:27 UTC (permalink / raw) To: kernelnewbies Hi,I want to write mouse driver for linux ( usb mouse). I am reading "Linux device driver" and "Linux kernel development". But i don't how to start writing the driver. So,Please help. Best regards, Ronit. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Mouse driver 2015-03-07 4:27 Mouse driver Ronit Halder @ 2015-03-07 4:34 ` nick [not found] ` <CACeEjSLORnMtw-xHem9kOkVeU9kmXFq=LTC+siOJTDSRXwmc9w@mail.gmail.com> 0 siblings, 1 reply; 11+ messages in thread From: nick @ 2015-03-07 4:34 UTC (permalink / raw) To: kernelnewbies Ronit, What are your reasons for writing this driver? In addition if you have the kernel tree lying around look under drivers/input/mouse for mouse drivers that are in production to help you understand how to write one better. Good Luck, Nick On 2015-03-06 11:27 PM, Ronit Halder wrote: > Hi,I want to write mouse driver for linux ( usb mouse). I am reading > "Linux device driver" and "Linux kernel development". But i don't how > to start writing the driver. > So,Please help. > > Best regards, > Ronit. > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <CACeEjSLORnMtw-xHem9kOkVeU9kmXFq=LTC+siOJTDSRXwmc9w@mail.gmail.com>]
* Mouse driver [not found] ` <CACeEjSLORnMtw-xHem9kOkVeU9kmXFq=LTC+siOJTDSRXwmc9w@mail.gmail.com> @ 2015-03-07 4:39 ` nick 2015-03-08 21:51 ` Maxime Ripard 0 siblings, 1 reply; 11+ messages in thread From: nick @ 2015-03-07 4:39 UTC (permalink / raw) To: kernelnewbies On 2015-03-06 11:36 PM, Ronit Halder wrote: > This is my semester project and Thanks. > Does it have to be a input driver? If you really want to impress your teacher and get a better mark,try writing a basic network or usb driver. Nick > On Sat, Mar 7, 2015 at 10:04 AM, nick <xerofoify@gmail.com> wrote: >> Ronit, >> What are your reasons for writing this driver? In addition if you have >> the kernel tree lying around look under drivers/input/mouse for mouse >> drivers that are in production to help you understand how to write >> one better. >> Good Luck, >> Nick >> >> On 2015-03-06 11:27 PM, Ronit Halder wrote: >>> Hi,I want to write mouse driver for linux ( usb mouse). I am reading >>> "Linux device driver" and "Linux kernel development". But i don't how >>> to start writing the driver. >>> So,Please help. >>> >>> Best regards, >>> Ronit. >>> >>> _______________________________________________ >>> Kernelnewbies mailing list >>> Kernelnewbies at kernelnewbies.org >>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >>> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Mouse driver 2015-03-07 4:39 ` nick @ 2015-03-08 21:51 ` Maxime Ripard 2015-03-08 22:09 ` Nicholas Krause 0 siblings, 1 reply; 11+ messages in thread From: Maxime Ripard @ 2015-03-08 21:51 UTC (permalink / raw) To: kernelnewbies Nick, On Fri, Mar 06, 2015 at 11:39:21PM -0500, nick wrote: > On 2015-03-06 11:36 PM, Ronit Halder wrote: > > This is my semester project and Thanks. > > Does it have to be a input driver? If you really want to impress > your teacher and get a better mark,try writing a basic network or > usb driver. Except that an USB or at networking driver is a few orders of magnitude more difficult than an input driver. While it would certainly be a wonderful achievement, it really is not reasonable to suggest that on this list. Maxime -- Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: Digital signature Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150308/2b9ec150/attachment.bin ^ permalink raw reply [flat|nested] 11+ messages in thread
* Mouse driver 2015-03-08 21:51 ` Maxime Ripard @ 2015-03-08 22:09 ` Nicholas Krause 2015-03-09 1:12 ` Ronit Halder 0 siblings, 1 reply; 11+ messages in thread From: Nicholas Krause @ 2015-03-08 22:09 UTC (permalink / raw) To: kernelnewbies On March 8, 2015 5:51:58 PM EDT, Maxime Ripard <maxime.ripard@free-electrons.com> wrote: >Nick, > >On Fri, Mar 06, 2015 at 11:39:21PM -0500, nick wrote: >> On 2015-03-06 11:36 PM, Ronit Halder wrote: >> > This is my semester project and Thanks. >> >> Does it have to be a input driver? If you really want to impress >> your teacher and get a better mark,try writing a basic network or >> usb driver. > >Except that an USB or at networking driver is a few orders of >magnitude more difficult than an input driver. > >While it would certainly be a wonderful achievement, it really is not >reasonable to suggest that on this list. > >Maxime It was only a suggestion. I didn't realize that was impolite on the list. I was seeing if I could help him get a better mark as sometimes in my experience they get bonus marks for writing more difficult programs in this case, more complex drivers. Sorry, Nick -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Mouse driver 2015-03-08 22:09 ` Nicholas Krause @ 2015-03-09 1:12 ` Ronit Halder 2015-03-09 1:15 ` Nicholas Krause 0 siblings, 1 reply; 11+ messages in thread From: Ronit Halder @ 2015-03-09 1:12 UTC (permalink / raw) To: kernelnewbies How to get the interrupt number for any device. On Mon, Mar 9, 2015 at 3:39 AM, Nicholas Krause <xerofoify@gmail.com> wrote: > > > On March 8, 2015 5:51:58 PM EDT, Maxime Ripard < > maxime.ripard at free-electrons.com> wrote: > >Nick, > > > >On Fri, Mar 06, 2015 at 11:39:21PM -0500, nick wrote: > >> On 2015-03-06 11:36 PM, Ronit Halder wrote: > >> > This is my semester project and Thanks. > >> > >> Does it have to be a input driver? If you really want to impress > >> your teacher and get a better mark,try writing a basic network or > >> usb driver. > > > >Except that an USB or at networking driver is a few orders of > >magnitude more difficult than an input driver. > > > >While it would certainly be a wonderful achievement, it really is not > >reasonable to suggest that on this list. > > > >Maxime > It was only a suggestion. I didn't realize that was impolite on the list. > I was seeing if I could help him get a better mark as sometimes in my > experience they get bonus marks for writing more difficult programs in this > case, more complex drivers. > Sorry, > Nick > -- > Sent from my Android device with K-9 Mail. Please excuse my brevity. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150309/e3ffe2fe/attachment.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Mouse driver 2015-03-09 1:12 ` Ronit Halder @ 2015-03-09 1:15 ` Nicholas Krause 0 siblings, 0 replies; 11+ messages in thread From: Nicholas Krause @ 2015-03-09 1:15 UTC (permalink / raw) To: kernelnewbies On March 8, 2015 9:12:28 PM EDT, Ronit Halder <ronit.linux@gmail.com> wrote: >How to get the interrupt number for any device. The easiest way is to take a look for your device's id in lsusb and see if the interrupt number is there for your device. Nick > >On Mon, Mar 9, 2015 at 3:39 AM, Nicholas Krause <xerofoify@gmail.com> >wrote: > >> >> >> On March 8, 2015 5:51:58 PM EDT, Maxime Ripard < >> maxime.ripard at free-electrons.com> wrote: >> >Nick, >> > >> >On Fri, Mar 06, 2015 at 11:39:21PM -0500, nick wrote: >> >> On 2015-03-06 11:36 PM, Ronit Halder wrote: >> >> > This is my semester project and Thanks. >> >> >> >> Does it have to be a input driver? If you really want to impress >> >> your teacher and get a better mark,try writing a basic network or >> >> usb driver. >> > >> >Except that an USB or at networking driver is a few orders of >> >magnitude more difficult than an input driver. >> > >> >While it would certainly be a wonderful achievement, it really is >not >> >reasonable to suggest that on this list. >> > >> >Maxime >> It was only a suggestion. I didn't realize that was impolite on the >list. >> I was seeing if I could help him get a better mark as sometimes in my >> experience they get bonus marks for writing more difficult programs >in this >> case, more complex drivers. >> Sorry, >> Nick >> -- >> Sent from my Android device with K-9 Mail. Please excuse my brevity. >> -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <757c55c6040712065266e867e5@mail.gmail.com>]
[parent not found: <20040712172844.GA2375@prot.minidns.net>]
[parent not found: <757c55c6040713071814ff655c@mail.gmail.com>]
* Mouse driver [not found] ` <757c55c6040713071814ff655c@mail.gmail.com> @ 2004-07-13 19:10 ` Maikon Bueno 2004-07-13 20:19 ` Vojtech Pavlik 0 siblings, 1 reply; 11+ messages in thread From: Maikon Bueno @ 2004-07-13 19:10 UTC (permalink / raw) To: linux-kernel Hi all... I'm developing a serial mouse driver and I would like to know how can I do to associate a driver with the device. To do this driver code I followed a tutorial by Alan Cox. I used the register_chrdev function to associate the driver with the device, however when I issue "cat /dev/mymouse" (the mymouse device was created using the "mknod" command with the same major number of the driver and the module is already loaded), I got a error message. Is there any way of to do this? When are the open_mouse and ourmouse_interrupt functions called? Thanks!! #define MODULE #include<linux/ioport.h> #include <linux/config.h> #include <linux/module.h> #include<linux/sched.h> #include<linux/poll.h> #include<linux/interrupt.h> #include<linux/miscdevice.h> #include<linux/init.h> #include <linux/kernel.h> // printk() #include <linux/malloc.h> // kmalloc() #include<linux/slab.h> // #include <linux/fs.h> // everything... #include <linux/errno.h> // error codes #include <linux/types.h> // size_t #include <linux/proc_fs.h> #include <linux/fcntl.h> // O_ACCMODE #include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs.h> #include <asm/system.h> #include<asm/segment.h> #include<asm/io.h> #ifdef CONFIG_DEVFS_FS #include <linux/devfs_fs_kernel.h> #else typedef void * devfs_handle_t; #endif /**/ #define OURMOUSE_BASE 0x300 //#define OURMOUSE_BASE 0x23c //#define OURMOUSE_BASE 0x064 #define OURMOUSE_MINOR 0 #define OURMOUSE_MAJOR 250 //#define MOUSE_IRQ 5 #define MOUSE_IRQ 12 static int mouse_users = 0; // User count static int mouse_dx = 0; // Position changes static int mouse_dy = 0; static int mouse_event = 0; // Mouse has moved static int mouse_buttons = 0; static int mouse_intr = MOUSE_IRQ; static struct wait_queue *mouse_wait; static spinlock_t mouse_lock = SPIN_LOCK_UNLOCKED; //Listing 1: File Operations static ssize_t mouse_read(struct file *f, char *buffer,size_t count, loff_t *pos); static ssize_t write_mouse(struct file *file, const char *buffer, size_t count, loff_t *ppos); static unsigned int mouse_poll(struct file *file, poll_table *wait); static int open_mouse(struct inode *inode, struct file *file); static int close_mouse(struct inode *inode,struct file *file); //static devfs_handle_t mydev; struct file_operations our_mouse_fops = { NULL, // Mice don't seek mouse_read, // You can read a mouse write_mouse, // This won't do a lot NULL, // No readdir - not a directory mouse_poll, // Poll NULL, // No ioctl calls NULL, // No mmap open_mouse, // Called on open NULL, // Flush - 2.2 only close_mouse, // Called on close NULL, // No media change on a mouse NULL, // Asynchronous I/O - we will add this later NULL }; static struct miscdevice our_mouse = { OURMOUSE_MINOR, "ourmouse",&our_mouse_fops, &our_mouse_fops }; static int ourmouse_init(void) { printk("estou no ourmouse_init \n"); if(check_region(OURMOUSE_BASE, 3)) return -ENODEV; printk("ourmouse: depois do check_region(OURMOUSE_BASE,3) \n"); request_region(OURMOUSE_BASE, 3,"ourmouse"); register_chrdev(OURMOUSE_MAJOR,"ourmouse",&our_mouse_fops); /* devfs_register(NULL, "ourmouse", 0, OURMOUSE_MAJOR, OURMOUSE_MINOR, S_IFCHR | S_IRUGO | S_IWUGO, &our_mouse_fops, 0); */ //misc_register(&our_mouse); return 0; } int init_module(void) { printk("estou no init_module \n"); if(ourmouse_init()<0) return -ENODEV; printk("init_module: depois de ourmouse_init() \n"); return 0; } void cleanup_module(void) { //misc_deregister(&our_mouse); //deffs_unregister(mydev); unregister_chrdev(OURMOUSE_MAJOR,"ourmouse"); release_region(OURMOUSE_BASE, 3); } static void ourmouse_interrupt(int irq, void *dev_id, struct pt_regs *regs) { char delta_x; char delta_y; unsigned char new_buttons; printk("uma interrupcao foi chamada \n"); delta_x = inb(OURMOUSE_BASE); delta_y = inb(OURMOUSE_BASE+1); new_buttons = inb(OURMOUSE_BASE+2); if(delta_x || delta_y || new_buttons != mouse_buttons) { // Something happened spin_lock(&mouse_lock); mouse_event = 1; mouse_dx += delta_x; mouse_dy += delta_y; mouse_buttons = new_buttons; spin_unlock(&mouse_lock); wake_up_interruptible(&mouse_wait); } } static int open_mouse(struct inode *inode, struct file *file) { printk("estou no open_mouse \n"); if(mouse_users++) return 0; if(request_irq(mouse_intr, ourmouse_interrupt, 0, "ourmouse", NULL)) { printk("request_irq: dentro do IF... algo deu errado \n"); mouse_users--; return -EBUSY; } mouse_dx = 0; mouse_dy = 0; mouse_buttons = 0; mouse_event = 0; MOD_INC_USE_COUNT; return 0; } static int close_mouse(struct inode *inode,struct file *file) { if(--mouse_users) return 0; free_irq(mouse_intr, NULL); MOD_DEC_USE_COUNT; return 0; } static ssize_t write_mouse(struct file *file, const char *buffer, size_t count, loff_t *ppos) { return -EINVAL; } static unsigned int mouse_poll(struct file *file, poll_table *wait) { poll_wait(file, &mouse_wait, wait); if(mouse_event) return POLLIN | POLLRDNORM; return 0; } static ssize_t mouse_read(struct file *f, char *buffer,size_t count, loff_t *pos) { int dx, dy; unsigned char button; unsigned long flags; int n; if(count < 3) return -EINVAL; //Wait for an event //struct task_struct *current; while(!mouse_event) { if(f->f_flags&O_NDELAY) return -EAGAIN; interruptible_sleep_on(&mouse_wait); if(signal_pending(current)) return -ERESTARTSYS; } //Reading the Event // mouse_read continued // Grab the event spin_lock_irqsave(&mouse_lock, flags); dx = mouse_dx; dy = mouse_dy; button = mouse_buttons; if(dx<=-127) dx=-127; if(dx>=127) dx=127; if(dy<=-127) dy=-127; if(dy>=127) dy=127; mouse_dx -= dx; mouse_dy -= dy; if (mouse_dx == 0 && mouse_dy == 0) mouse_event = 0; spin_unlock_irqrestore(&mouse_lock, flags); //================================================= //Copying Results to the Buffer // mouse_read continued if(put_user(button|0x80, buffer)) return -EFAULT; if(put_user((char)dx, buffer+1)) return -EFAULT; if(put_user((char)dy, buffer+2)) return -EFAULT; for(n=3; n < count; n++) if(put_user(0x00, buffer+n)) return -EFAULT; return count; } /**/ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Mouse driver 2004-07-13 19:10 ` Maikon Bueno @ 2004-07-13 20:19 ` Vojtech Pavlik 0 siblings, 0 replies; 11+ messages in thread From: Vojtech Pavlik @ 2004-07-13 20:19 UTC (permalink / raw) To: Maikon Bueno; +Cc: linux-kernel On Tue, Jul 13, 2004 at 04:10:09PM -0300, Maikon Bueno wrote: > Hi all... > I'm developing a serial mouse driver and I would like to know how can > I do to associate a driver with the device. > To do this driver code I followed a tutorial by Alan Cox. I used the > register_chrdev function to associate the driver with the device, > however when I issue "cat /dev/mymouse" (the mymouse device was > created using the "mknod" command with the same major number of the > driver and the module is already loaded), I got a error message. > Is there any way of to do this? > When are the open_mouse and ourmouse_interrupt functions called? > > Thanks!! I think you should take a look at Documentation/input/input-programming.txt -- Vojtech Pavlik SuSE Labs, SuSE CR ^ permalink raw reply [flat|nested] 11+ messages in thread
* mouse driver
@ 2004-01-17 4:18 roshan mulla
0 siblings, 0 replies; 11+ messages in thread
From: roshan mulla @ 2004-01-17 4:18 UTC (permalink / raw)
To: linux-kernel
hello,
I am new to linux and i wish to write a device
driver for mouse using serial port. I have gone
through some basics for writing a module. But i want
to know if there is some special care to taken for
writing a mosue driver.
Can somebody guide me as how i should proceed about
writing a mouse driver.
roshan
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
^ permalink raw reply [flat|nested] 11+ messages in thread* mouse driver
@ 2004-01-15 7:16 roshan mulla
0 siblings, 0 replies; 11+ messages in thread
From: roshan mulla @ 2004-01-15 7:16 UTC (permalink / raw)
To: linux-kernel
hello ,
I am trying to develop a mouse driver on linux red
hat 9 on kernel 2.4.20-8 . I am using mouse driver
code by Alan Cox available on the web. I could
successfully compile the code .
My machine is using PS/2 mouse.i reboot the machine
with mouse removed it asks me for remove
configuration.
After this when i insmod the driver and do mknod .when
i try to open this device it gives me kernel panic
giving messages as interrupt not syncing.
Please can u tell me as to do i test this code . Do i
need to do some special kernel configuration for
testing this code.
I desperately need to test this code for my project.
It would be very kind of u if u could help me in this
matter.
looking forward to ur reply
roshan
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
^ permalink raw reply [flat|nested] 11+ messages in threadend of thread, other threads:[~2015-03-09 1:15 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-07 4:27 Mouse driver Ronit Halder
2015-03-07 4:34 ` nick
[not found] ` <CACeEjSLORnMtw-xHem9kOkVeU9kmXFq=LTC+siOJTDSRXwmc9w@mail.gmail.com>
2015-03-07 4:39 ` nick
2015-03-08 21:51 ` Maxime Ripard
2015-03-08 22:09 ` Nicholas Krause
2015-03-09 1:12 ` Ronit Halder
2015-03-09 1:15 ` Nicholas Krause
[not found] <757c55c6040712065266e867e5@mail.gmail.com>
[not found] ` <20040712172844.GA2375@prot.minidns.net>
[not found] ` <757c55c6040713071814ff655c@mail.gmail.com>
2004-07-13 19:10 ` Maikon Bueno
2004-07-13 20:19 ` Vojtech Pavlik
-- strict thread matches above, loose matches on Subject: below --
2004-01-17 4:18 mouse driver roshan mulla
2004-01-15 7:16 roshan mulla
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.