All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu
@ 2020-08-12 15:21 Michael Trimarchi
  2020-08-17  6:47 ` Gerd Hoffmann
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Trimarchi @ 2020-08-12 15:21 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Linux need to fill up the hid descriptor in order to let
the driver be emulated. This patch was tested on top of
qemu 4.2.0 and recent linux kernel.

modprobe wacom.ko
evtest tool

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 hw/usb/dev-wacom.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c
index 8aba44b8bc..fe95699672 100644
--- a/hw/usb/dev-wacom.c
+++ b/hw/usb/dev-wacom.c
@@ -259,6 +259,64 @@ static void usb_wacom_handle_reset(USBDevice *dev)
     s->mode = WACOM_MODE_HID;
 }
 
+static const uint8_t qemu_wacom_hid_report_descriptor[] = {
+	0x05, 0x01,
+	0x09, 0x02,
+	0xa1, 0x01,
+	0x85, 0x01,
+	0x09, 0x01,
+	0xa1, 0x00,
+	0x05, 0x09,
+	0x19, 0x01,
+	0x29, 0x03,
+	0x15, 0x00,
+	0x25, 0x01,
+	0x95, 0x03,
+	0x75, 0x01,
+	0x81, 0x02,
+	0x95, 0x01,
+	0x75, 0x05,
+	0x81, 0x01,
+	0x05, 0x01,
+	0x09, 0x30,
+	0x09, 0x31,
+	0x09, 0x38,
+	0x15, 0x81,
+	0x25, 0x7f,
+	0x75, 0x08,
+	0x95, 0x03,
+	0x81, 0x06,
+	0x95, 0x03,
+	0x81, 0x01,
+	0xc0, 0xc0,
+	0x05, 0x0d,
+	0x09, 0x01,
+	0xa1, 0x01,
+	0x85, 0x02,
+	0xa1, 0x00,
+	0x06, 0x00,
+	0xff, 0x09,
+	0x01, 0x15,
+	0x00, 0x26,
+	0xff, 0x00,
+	0x75, 0x08,
+	0x95, 0x07,
+	0x81, 0x02,
+	0xc0, 0x09,
+	0x01, 0x85,
+	0x63, 0x95,
+	0x07, 0x81,
+	0x02, 0x09,
+	0x01, 0x85,
+	0x02, 0x95,
+	0x01, 0xb1,
+	0x02, 0x09,
+	0x01, 0x85,
+	0x03, 0x95,
+	0x01, 0xb1,
+	0x02, 0xc0,
+};
+
 static void usb_wacom_handle_control(USBDevice *dev, USBPacket *p,
                int request, int value, int index, int length, uint8_t *data)
 {
@@ -271,6 +329,18 @@ static void usb_wacom_handle_control(USBDevice *dev, USBPacket *p,
     }
 
     switch (request) {
+    case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
+        switch (value >> 8) {
+        case 0x22:
+                memcpy(data, qemu_wacom_hid_report_descriptor,
+                       sizeof(qemu_wacom_hid_report_descriptor));
+                p->actual_length = sizeof(qemu_wacom_hid_report_descriptor);
+            break;
+        default:
+            goto fail;
+        }
+        break;
+
     case WACOM_SET_REPORT:
         if (s->mouse_grabbed) {
             qemu_remove_mouse_event_handler(s->eh_entry);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu
  2020-08-12 15:21 [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu Michael Trimarchi
@ 2020-08-17  6:47 ` Gerd Hoffmann
  2020-08-17  6:48   ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 9+ messages in thread
From: Gerd Hoffmann @ 2020-08-17  6:47 UTC (permalink / raw)
  To: Michael Trimarchi; +Cc: qemu-devel

On Wed, Aug 12, 2020 at 05:21:49PM +0200, Michael Trimarchi wrote:
> Linux need to fill up the hid descriptor in order to let
> the driver be emulated. This patch was tested on top of
> qemu 4.2.0 and recent linux kernel.
> 
> modprobe wacom.ko
> evtest tool
> 
> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> ---
>  hw/usb/dev-wacom.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 70 insertions(+)
> 
> diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c
> index 8aba44b8bc..fe95699672 100644
> --- a/hw/usb/dev-wacom.c
> +++ b/hw/usb/dev-wacom.c
> @@ -259,6 +259,64 @@ static void usb_wacom_handle_reset(USBDevice *dev)
>      s->mode = WACOM_MODE_HID;
>  }
>  
> +static const uint8_t qemu_wacom_hid_report_descriptor[] = {
> +	0x05, 0x01,
> +	0x09, 0x02,

Where does this come from?  Created from scratch?  Copied from real
wacom tablet?  Any chance this can get descriptive comments like the
other report descriptors (see dev-hid.c)?

thanks,
  Gerd



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu
  2020-08-17  6:47 ` Gerd Hoffmann
@ 2020-08-17  6:48   ` Michael Nazzareno Trimarchi
  2020-08-17  7:28     ` Gerd Hoffmann
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Nazzareno Trimarchi @ 2020-08-17  6:48 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Hi Gerd

On Mon, Aug 17, 2020 at 8:47 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> On Wed, Aug 12, 2020 at 05:21:49PM +0200, Michael Trimarchi wrote:
> > Linux need to fill up the hid descriptor in order to let
> > the driver be emulated. This patch was tested on top of
> > qemu 4.2.0 and recent linux kernel.
> >
> > modprobe wacom.ko
> > evtest tool
> >
> > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> > ---
> >  hw/usb/dev-wacom.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 70 insertions(+)
> >
> > diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c
> > index 8aba44b8bc..fe95699672 100644
> > --- a/hw/usb/dev-wacom.c
> > +++ b/hw/usb/dev-wacom.c
> > @@ -259,6 +259,64 @@ static void usb_wacom_handle_reset(USBDevice *dev)
> >      s->mode = WACOM_MODE_HID;
> >  }
> >
> > +static const uint8_t qemu_wacom_hid_report_descriptor[] = {
> > +     0x05, 0x01,
> > +     0x09, 0x02,
>
> Where does this come from?  Created from scratch?  Copied from real

No, there are dump of several descriptor on github. I will put in the
commit message

> wacom tablet?  Any chance this can get descriptive comments like the
> other report descriptors (see dev-hid.c)?

Yes, no problem. I will study a bit more. How was working before?

Michael

>
> thanks,
>   Gerd
>


-- 
Michael Nazzareno Trimarchi
Amarula Solutions BV
COO Co-Founder
Cruquiuskade 47 Amsterdam 1018 AM NL
T. +31(0)851119172
M. +39(0)3479132170
[`as] https://www.amarulasolutions.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu
  2020-08-17  6:48   ` Michael Nazzareno Trimarchi
@ 2020-08-17  7:28     ` Gerd Hoffmann
  2020-08-17 16:42       ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 9+ messages in thread
From: Gerd Hoffmann @ 2020-08-17  7:28 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi; +Cc: qemu-devel

  Hi,

> > > +static const uint8_t qemu_wacom_hid_report_descriptor[] = {
> > > +     0x05, 0x01,
> > > +     0x09, 0x02,
> >
> > Where does this come from?  Created from scratch?  Copied from real
> 
> No, there are dump of several descriptor on github. I will put in the
> commit message

A comment with a link would be good too.

> > wacom tablet?  Any chance this can get descriptive comments like the
> > other report descriptors (see dev-hid.c)?
> 
> Yes, no problem. I will study a bit more. How was working before?

I suspect in the past the linux driver simply checked the device id and
went with that without fetching the report descriptor.

Also note qemu has a generic tablet (-device usb-tablet), so there are
probably very few users using the wacom emulation.  Possibly it is
broken for quite a while already but nobody noticed ...

take care,
  Gerd



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu
  2020-08-17  7:28     ` Gerd Hoffmann
@ 2020-08-17 16:42       ` Michael Nazzareno Trimarchi
  2020-08-18  6:02         ` Gerd Hoffmann
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Nazzareno Trimarchi @ 2020-08-17 16:42 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Hi Gerd

Have another small question. Do you know how force show cursor working
in this case?

Michael

On Mon, Aug 17, 2020 at 9:28 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
>   Hi,
>
> > > > +static const uint8_t qemu_wacom_hid_report_descriptor[] = {
> > > > +     0x05, 0x01,
> > > > +     0x09, 0x02,
> > >
> > > Where does this come from?  Created from scratch?  Copied from real
> >
> > No, there are dump of several descriptor on github. I will put in the
> > commit message
>
> A comment with a link would be good too.
>
> > > wacom tablet?  Any chance this can get descriptive comments like the
> > > other report descriptors (see dev-hid.c)?
> >
> > Yes, no problem. I will study a bit more. How was working before?
>
> I suspect in the past the linux driver simply checked the device id and
> went with that without fetching the report descriptor.
>
> Also note qemu has a generic tablet (-device usb-tablet), so there are
> probably very few users using the wacom emulation.  Possibly it is
> broken for quite a while already but nobody noticed ...
>
> take care,
>   Gerd
>


-- 
Michael Nazzareno Trimarchi
Amarula Solutions BV
COO Co-Founder
Cruquiuskade 47 Amsterdam 1018 AM NL
T. +31(0)851119172
M. +39(0)3479132170
[`as] https://www.amarulasolutions.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu
  2020-08-17 16:42       ` Michael Nazzareno Trimarchi
@ 2020-08-18  6:02         ` Gerd Hoffmann
  2020-08-18  8:23           ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 9+ messages in thread
From: Gerd Hoffmann @ 2020-08-18  6:02 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi; +Cc: qemu-devel

On Mon, Aug 17, 2020 at 06:42:02PM +0200, Michael Nazzareno Trimarchi wrote:
> Hi Gerd
> 
> Have another small question. Do you know how force show cursor working
> in this case?

Which display and which vga do you use?

take care,
  Gerd



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu
  2020-08-18  6:02         ` Gerd Hoffmann
@ 2020-08-18  8:23           ` Michael Nazzareno Trimarchi
  2020-08-19  5:52             ` Gerd Hoffmann
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Nazzareno Trimarchi @ 2020-08-18  8:23 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Hi

On Tue, Aug 18, 2020 at 8:02 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> On Mon, Aug 17, 2020 at 06:42:02PM +0200, Michael Nazzareno Trimarchi wrote:
> > Hi Gerd
> >
> > Have another small question. Do you know how force show cursor working
> > in this case?
>
> Which display and which vga do you use?

/usr/bin/qemu-system-i386 -M pc \
-enable-kvm -cpu host \
-m 1024 \
-vga std \
-global VGA.vgamem_mb=4 \
-kernel out/w_and_h_emulator/images/bzImage \
-drive file=out/w_and_h_emulator/images/rootfs.ext2,if=virtio,format=raw \
-append "root=/dev/vda console=" \
-net nic,model=virtio \
-net user,hostfwd=tcp::22222-:22,hostfwd=tcp::10000-:10000,hostfwd=tcp::10001-:10001
\
-usb -device usb-wacom-tablet \
-usb -device usb-host,vendorid=0x04d8,productid=0x000a -show-cursor

But I need to use the framebuffer. So what happens for instance in
software like ts_calibrate you can not see the cursor

Michael
>
> take care,
>   Gerd
>


-- 
Michael Nazzareno Trimarchi
Amarula Solutions BV
COO Co-Founder
Cruquiuskade 47 Amsterdam 1018 AM NL
T. +31(0)851119172
M. +39(0)3479132170
[`as] https://www.amarulasolutions.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu
  2020-08-18  8:23           ` Michael Nazzareno Trimarchi
@ 2020-08-19  5:52             ` Gerd Hoffmann
  2020-08-21 16:24               ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 9+ messages in thread
From: Gerd Hoffmann @ 2020-08-19  5:52 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi; +Cc: qemu-devel

  Hi,

> > > Have another small question. Do you know how force show cursor working
> > > in this case?
> >
> > Which display and which vga do you use?
> 
> -vga std \

So stdvga (has no hardware cursor support).

display not specified, so it is the default.
i.e. gtk or sdl depending on what configure finds.

> But I need to use the framebuffer. So what happens for instance in
> software like ts_calibrate you can not see the cursor

Does -vga virtio work better?

take care,
  Gerd



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu
  2020-08-19  5:52             ` Gerd Hoffmann
@ 2020-08-21 16:24               ` Michael Nazzareno Trimarchi
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Nazzareno Trimarchi @ 2020-08-21 16:24 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Hi


On Wed, Aug 19, 2020 at 7:52 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
>   Hi,
>
> > > > Have another small question. Do you know how force show cursor working
> > > > in this case?
> > >
> > > Which display and which vga do you use?
> >
> > -vga std \
>
> So stdvga (has no hardware cursor support).
>
> display not specified, so it is the default.
> i.e. gtk or sdl depending on what configure finds.
>
> > But I need to use the framebuffer. So what happens for instance in
> > software like ts_calibrate you can not see the cursor
>
> Does -vga virtio work better?

pen("/dev/fb0", O_RDWR|O_LARGEFILE)    = 5
ioctl(5, FBIOGET_FSCREENINFO, 0x8055e40) = 0
ioctl(5, FBIOGET_VSCREENINFO, 0x8055da0) = 0
mmap2(NULL, 0, PROT_READ|PROT_WRITE, MAP_SHARED, 5, 0) = -1 EINVAL
(Invalid argument)
write(2, "mmap framebuffer", 16mmap framebuffer)        = 16
write(2, ": ", 2: )                       = 2
write(2, "Invalid argument", 16Invalid argument)        = 16
write(2, "\n", 1
)                       = 1

Michael

>
> take care,
>   Gerd
>


--
Michael Nazzareno Trimarchi
Amarula Solutions BV
COO Co-Founder
Cruquiuskade 47 Amsterdam 1018 AM NL
T. +31(0)851119172
M. +39(0)3479132170
[`as] https://www.amarulasolutions.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-08-21 16:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12 15:21 [PATCH] hw: dev-wacom: Support wacom tablet emulation in linux qemu Michael Trimarchi
2020-08-17  6:47 ` Gerd Hoffmann
2020-08-17  6:48   ` Michael Nazzareno Trimarchi
2020-08-17  7:28     ` Gerd Hoffmann
2020-08-17 16:42       ` Michael Nazzareno Trimarchi
2020-08-18  6:02         ` Gerd Hoffmann
2020-08-18  8:23           ` Michael Nazzareno Trimarchi
2020-08-19  5:52             ` Gerd Hoffmann
2020-08-21 16:24               ` Michael Nazzareno Trimarchi

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.