Skip to contentSkip to conversation

Elo touchpad 10 bytes emulator v2

PATCH In review Ricardo Ribalda Delgado 3 participants 7 messages Mar 29, 2010 – Mar 30, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Elo touchpad 10 bytes emulator v2

New char device emulating an Elo serial touchpad.

-Emulate id and touch packets
-Absolute Output limited to 96-4000

---
 Makefile.objs   |    2 +-
 hw/elo.c        |  153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/elo.h        |    2 +
 hw/serial.c     |    2 +-
 qemu-char.c     |    3 +
 qemu-options.hx |    5 ++-
 6 files changed, 164 insertions(+), 3 deletions(-)
 create mode 100644 hw/elo.c
 create mode 100644 hw/elo.h
Makefile.objs +1 -1
index b73e2cb..07c2e68 100644
@@ -75,7 +75,7 @@ common-obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o u
 common-obj-y += bt-hci-csr.o
 common-obj-y += buffered_file.o migration.o migration-tcp.o qemu-sockets.o
 common-obj-y += qemu-char.o savevm.o #aio.o
-common-obj-y += msmouse.o ps2.o
+common-obj-y += msmouse.o ps2.o elo.o
 common-obj-y += qdev.o qdev-properties.o
 common-obj-y += qemu-config.o block-migration.o
 
hw/elo.c new file +153 -0

153 lines not on this page · raw message

hw/elo.h new file +2 -0
new file mode 100644
index 0000000..4b4e09a
@@ -0,0 +1,2 @@
+/* elo.c */
+CharDriverState *qemu_chr_open_elo(QemuOpts *opts);
hw/serial.c +1 -1
index f3ec36a..39c708f 100644
@@ -92,7 +92,7 @@
 #define UART_FCR_RFR        0x02    /* RCVR Fifo Reset */
 #define UART_FCR_FE         0x01    /* FIFO Enable */
 
-#define UART_FIFO_LENGTH    16      /* 16550A Fifo Length */
+#define UART_FIFO_LENGTH    32      /* 16550A Fifo Length */
 
 #define XMIT_FIFO           0
 #define RECV_FIFO           1
qemu-char.c +3 -0
index 40cfefa..2f95767 100644
@@ -32,6 +32,7 @@
 #include "hw/usb.h"
 #include "hw/baum.h"
 #include "hw/msmouse.h"
+#include "hw/elo.h"
 #include "qemu-objects.h"
 
 #include <unistd.h>
@@ -2278,6 +2279,7 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
     if (strcmp(filename, "null")    == 0 ||
         strcmp(filename, "pty")     == 0 ||
         strcmp(filename, "msmouse") == 0 ||
+        strcmp(filename, "elo") == 0 ||
         strcmp(filename, "braille") == 0 ||
         strcmp(filename, "stdio")   == 0) {
         qemu_opt_set(opts, "backend", filename);
@@ -2391,6 +2393,7 @@ static const struct {
     { .name = "socket",    .open = qemu_chr_open_socket },
     { .name = "udp",       .open = qemu_chr_open_udp },
     { .name = "msmouse",   .open = qemu_chr_open_msmouse },
+    { .name = "elo",       .open = qemu_chr_open_elo },
     { .name = "vc",        .open = text_console_init },
 #ifdef _WIN32
     { .name = "file",      .open = qemu_chr_open_win_file_out },
qemu-options.hx +4 -1
index 7c33736..7ee62cb 100644
@@ -1183,7 +1183,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
     "-chardev socket,id=id,path=path[,server][,nowait][,telnet] (unix)\n"
     "-chardev udp,id=id[,host=host],port=port[,localaddr=localaddr]\n"
     "         [,localport=localport][,ipv4][,ipv6]\n"
-    "-chardev msmouse,id=id\n"
+    "-chardev elo,id=id\n"
     "-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n"
     "-chardev file,id=id,path=path\n"
     "-chardev pipe,id=id,path=path\n"
@@ -1650,6 +1650,9 @@ or fake device.
 
 @item msmouse
 Three button serial mouse. Configure the guest to use Microsoft protocol.
+
+@item elo
+Elo Touchpad 10bytes emulator.
 @end table
 ETEXI
 
Signature · 1 line
1.7.0.3
#1 lore raw

Review

Quoted 4 lines · Ricardo Ribalda Delgado

New char device emulating an Elo serial touchpad.

(quoted diff) +0 -2
-Emulate id and touch packets
-Absolute Output limited to 96-4000

It misses a SOB line.

hw/elo.c line 27

Quoted 10 lines
hw/elo.c new file +4 -0
new file mode 100644
index 0000000..359333d
 
+#include <stdlib.h>
+#include "../qemu-common.h"
+#include "../qemu-char.h"
+#include "../console.h"

You can remove the "../" from those, Makefile sets correct include paths for this to work.

hw/elo.c line 51

Quoted 3 lines
hw/elo.c new file +3 -0
+    /*Move event*/
+    if (is_down&&buttons_state){
+	    bytes[2]=0x2;

Can we use some constant from that bytes[2] values? 0x1, 0x2 and 0x4 don't look specially descriptive.

hw/elo.c line 140

Quoted 4 lines
hw/elo.c new file +4 -0
+static void elo_chr_close (struct CharDriverState *chr)
+{
+    qemu_free (chr);
+}

Use coherent indentation. You are ussing here function (args) and in the rest of the file function(args) without space.

hw/serial.c line 98

Quoted 13 lines
hw/serial.c +1 -1
index f3ec36a..39c708f 100644
@@ -92,7 +92,7 @@
 #define UART_FCR_RFR        0x02    /* RCVR Fifo Reset */
 #define UART_FCR_FE         0x01    /* FIFO Enable */
 
-#define UART_FIFO_LENGTH    16      /* 16550A Fifo Length */
+#define UART_FIFO_LENGTH    32      /* 16550A Fifo Length */
 
 #define XMIT_FIFO           0
 #define RECV_FIFO           1

Why does the lenght of the FIFO changes here? I think this change in independent of the rest of the patch (no knowledge about the 16550A to know if it should be 16 or 32).

Later, Juan.

#2 lore raw

Hello Juan

Thanks for your comments. About the indentation error... Do you have
some kind of auto indent script(like the kernel code has). It is making me crazy trying to collaborate with a lot of projects an all of them with different styles.

Quoted 8 lines

hw/elo.c line 27

Quoted 5 lines
hw/elo.c new file +4 -0
+#include <stdlib.h>
+#include "../qemu-common.h"
+#include "../qemu-char.h"
+#include "../console.h"

You can remove the "../" from those, Makefile sets correct include paths for this to work.

Ok. I used the mssmouse.c as reference. I can change that. (I guess that I should also replace "" with <>)

Quoted 7 lines
Quoted 4 lines

+    /*Move event*/
+    if (is_down&&buttons_state){
+         bytes[2]=0x2;

Can we use some constant from that bytes[2] values? 0x1, 0x2 and 0x4 don't look specially descriptive.

ok

Quoted 3 lines

Why does the lenght of the FIFO changes here?  I think this change in independent of the rest of the patch (no knowledge about the 16550A to know if it should be 16 or 32).

I have to send a 2x10 bytes package, and it does not fit the the 16 bytes buffer.... Any other suggestion about how to do it?

Quoted 3 lines

Later, Juan.

Thanks again for your comments

Signature · 2 lines
Ricardo Ribalda
http://www.eps.uam.es/~rribalda/
#3 lore raw
Quoted 6 lines · Ricardo Ribalda Delgado

Hello Juan

Thanks for your comments. About the indentation error... Do you have
some kind of auto indent script(like the kernel code has). It is making me crazy trying to collaborate with a lot of projects an all of them with different styles.

Don't even start this discussion yet again :)
Short answer: we don't have.
Long answer: any indenter that would pass qemu code style will be turing
complete (at least) and possibly will also pass the Turing test.

Quoted 11 lines
Quoted 7 lines

hw/elo.c line 27

Quoted 4 lines
hw/elo.c new file +4 -0
+#include <stdlib.h>
+#include "../qemu-common.h"
+#include "../qemu-char.h"
+#include "../console.h"

You can remove the "../" from those, Makefile sets correct include paths for this to work.

Ok. I used the mssmouse.c as reference. I can change that. (I guess that I should also replace "" with <>)

Everything uses "". I just looked when reviewing this patch at msmouse, and that one could also take some cleanup. This happens a lot in qemu, you search for another driver for inspiration, and Murphy gets just the one with the wrong examples.

Quoted 6 lines
Quoted 3 lines

Why does the lenght of the FIFO changes here?  I think this change in independent of the rest of the patch (no knowledge about the 16550A to know if it should be 16 or 32).

I have to send a 2x10 bytes package, and it does not fit the the 16 bytes buffer.... Any other suggestion about how to do it?

Nope, I am not a 16550A guru at all. No sure if your change will break anything else or no, that is why I asked.

Quoted 5 lines
Quoted 3 lines

Later, Juan.

Thanks again for your comments

You are welcome.

Later, Juan.

#4 lore raw
Quoted 8 lines · Juan Quintela
Quoted 6 lines · Ricardo Ribalda Delgado

Hello Juan

Thanks for your comments. About the indentation error... Do you have
some kind of auto indent script(like the kernel code has). It is making me crazy trying to collaborate with a lot of projects an all of them with different styles.

Quoted 4 lines

Don't even start this discussion yet again :)
Short answer: we don't have.
Long answer: any indenter that would pass qemu code style will be turing
complete (at least) and possibly will also pass the Turing test.

Among the things I'm paid for is tolerating ugly code.

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

hw/elo.c line 27

Quoted 4 lines
hw/elo.c new file +4 -0
+#include <stdlib.h>
+#include "../qemu-common.h"
+#include "../qemu-char.h"
+#include "../console.h"

You can remove the "../" from those, Makefile sets correct include paths for this to work.

Ok. I used the mssmouse.c as reference. I can change that. (I guess that I should also replace "" with <>)

Use #include "name.h" for includes that come with the source or are generated by the build.

Quoted 9 lines

Everything uses "". I just looked when reviewing this patch at msmouse, and that one could also take some cleanup. This happens a lot in qemu, you search for another driver for inspiration, and Murphy gets just the one with the wrong examples.

Quoted 4 lines
Quoted 3 lines

Why does the lenght of the FIFO changes here?  I think this change in independent of the rest of the patch (no knowledge about the 16550A to know if it should be 16 or 32).

Quoted 5 lines
Quoted 2 lines

I have to send a 2x10 bytes package, and it does not fit the the 16 bytes buffer.... Any other suggestion about how to do it?

Nope, I am not a 16550A guru at all. No sure if your change will break anything else or no, that is why I asked.

The 16550 FIFOs are 16 bytes. The chips with larger FIFOs have different model numbers, e.g. 16650 with 32 byte FIFOs.

I can't see how the FIFO length limits your packet size. Could you explain?

#5 lore raw
Quoted 11 lines · Markus Armbruster
Quoted 5 lines
Quoted 2 lines

I have to send a 2x10 bytes package, and it does not fit the the 16 bytes buffer.... Any other suggestion about how to do it?

Nope, I am not a 16550A guru at all. No sure if your change will break anything else or no, that is why I asked.

The 16550 FIFOs are 16 bytes. The chips with larger FIFOs have different model numbers, e.g. 16650 with 32 byte FIFOs.

I can't see how the FIFO length limits your packet size. Could you explain?

Ah, I found it. Please look at hw/baum.c to see how to handle bigger packets. You can't write 10 + 10 bytes into 16 bytes in one go, you need to wait for the guest to consume some bits before you sent something more.

see how baum_accept_input()
handle qemu_chr_can_read() output. Something like that should fix your problems.

Later, Juan.

#6 lore raw
In reply to Juan Quintela

Hello Juan

New patch is on the mail.

Quoted 1 line

It misses a SOB line.

Sorry, I don't understand what you mean here, do you mean the sing off?

Quoted 2 lines

You can remove the "../" from those, Makefile sets correct include paths for this to work.

Done

Quoted 8 lines
Quoted 4 lines

+    /*Move event*/
+    if (is_down&&buttons_state){
+         bytes[2]=0x2;

Can we use some constant from that bytes[2] values? 0x1, 0x2 and 0x4 don't look specially descriptive.

Done

Quoted 4 lines

Why does the lenght of the FIFO changes here?  I think this change in independent of the rest of the patch (no knowledge about the 16550A to know if it should be 16 or 32).

Fixed using qemu_chr_can_read(). Thanks for your help!

Quoted 3 lines

Later, Juan.

Hope this time the patch is better.

Regards

Signature · 2 lines
Ricardo Ribalda
http://www.eps.uam.es/~rribalda/