From: Ladi Prosek <lprosek@redhat.com>
To: qemu-devel@nongnu.org
Cc: kraxel@redhat.com, lprosek@redhat.com
Subject: [Qemu-devel] [PATCH] virtio-input: support absolute axis config in pass-through
Date: Wed, 13 Apr 2016 16:43:23 +0200 [thread overview]
Message-ID: <1460558603-18331-1-git-send-email-lprosek@redhat.com> (raw)
VIRTIO_INPUT_CFG_ABS_INFO was not implemented for pass-through input
devices. This patch follows the existing design and pre-fetches the
config for all absolute axes using EVIOCGABS at realize time.
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
---
hw/input/virtio-input-host.c | 46 ++++++++++++++++++++++++++++++++++++++--
hw/input/virtio-input.c | 6 +++---
include/hw/virtio/virtio-input.h | 3 +++
3 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/hw/input/virtio-input-host.c b/hw/input/virtio-input-host.c
index 62185d5..58ee83f 100644
--- a/hw/input/virtio-input-host.c
+++ b/hw/input/virtio-input-host.c
@@ -69,13 +69,39 @@ static void virtio_input_bits_config(VirtIOInputHost *vih,
virtio_input_add_config(VIRTIO_INPUT(vih), &bits);
}
+static void virtio_input_abs_config(VirtIOInputHost *vih, int axis)
+{
+ virtio_input_config config;
+ struct input_absinfo absinfo;
+ int rc;
+
+ rc = ioctl(vih->fd, EVIOCGABS(axis), &absinfo);
+ if (rc < 0) {
+ return;
+ }
+
+ memset(&config, 0, sizeof(config));
+ config.select = VIRTIO_INPUT_CFG_ABS_INFO;
+ config.subsel = axis;
+ config.size = sizeof(virtio_input_absinfo);
+
+ config.u.abs.min = cpu_to_le32(absinfo.minimum);
+ config.u.abs.max = cpu_to_le32(absinfo.maximum);
+ config.u.abs.fuzz = cpu_to_le32(absinfo.fuzz);
+ config.u.abs.flat = cpu_to_le32(absinfo.flat);
+ config.u.abs.res = cpu_to_le32(absinfo.resolution);
+
+ virtio_input_add_config(VIRTIO_INPUT(vih), &config);
+}
+
static void virtio_input_host_realize(DeviceState *dev, Error **errp)
{
VirtIOInputHost *vih = VIRTIO_INPUT_HOST(dev);
VirtIOInput *vinput = VIRTIO_INPUT(dev);
- virtio_input_config id;
+ virtio_input_config id, *abs;
struct input_id ids;
- int rc, ver;
+ int rc, ver, i, axis;
+ uint8_t byte;
if (!vih->evdev) {
error_setg(errp, "evdev property is required");
@@ -126,6 +152,22 @@ static void virtio_input_host_realize(DeviceState *dev, Error **errp)
virtio_input_bits_config(vih, EV_SW, SW_CNT);
virtio_input_bits_config(vih, EV_LED, LED_CNT);
+ abs = virtio_input_find_config(VIRTIO_INPUT(vih),
+ VIRTIO_INPUT_CFG_EV_BITS, EV_ABS);
+ if (abs) {
+ for (i = 0; i < abs->size; i++) {
+ byte = abs->u.bitmap[i];
+ axis = 8 * i;
+ while (byte) {
+ if (byte & 1) {
+ virtio_input_abs_config(vih, axis);
+ }
+ axis++;
+ byte >>= 1;
+ }
+ }
+ }
+
qemu_set_fd_handler(vih->fd, virtio_input_host_event, NULL, vih);
return;
diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index 5061f4c..5f036a3 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -96,9 +96,9 @@ static void virtio_input_handle_sts(VirtIODevice *vdev, VirtQueue *vq)
virtio_notify(vdev, vinput->sts);
}
-static virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
- uint8_t select,
- uint8_t subsel)
+virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
+ uint8_t select,
+ uint8_t subsel)
{
VirtIOInputConfig *cfg;
diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h
index af1c207..b4e1b1b 100644
--- a/include/hw/virtio/virtio-input.h
+++ b/include/hw/virtio/virtio-input.h
@@ -111,6 +111,9 @@ struct VirtIOInputHost {
void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
void virtio_input_init_config(VirtIOInput *vinput,
virtio_input_config *config);
+virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
+ uint8_t select,
+ uint8_t subsel);
void virtio_input_add_config(VirtIOInput *vinput,
virtio_input_config *config);
void virtio_input_idstr_config(VirtIOInput *vinput,
--
2.5.5
next reply other threads:[~2016-04-13 14:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 14:43 Ladi Prosek [this message]
2016-04-13 15:45 ` [Qemu-devel] [PATCH] virtio-input: support absolute axis config in pass-through Gerd Hoffmann
2016-04-13 15:50 ` Ladi Prosek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460558603-18331-1-git-send-email-lprosek@redhat.com \
--to=lprosek@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).