Lines Matching +full:abs +full:- +full:flat
1 // SPDX-License-Identifier: GPL-2.0-only
30 virtqueue_add_inbuf(vi->evt, sg, 1, evtbuf, GFP_ATOMIC); in virtinput_queue_evtbuf()
35 struct virtio_input *vi = vq->vdev->priv; in virtinput_recv_events()
40 spin_lock_irqsave(&vi->lock, flags); in virtinput_recv_events()
41 if (vi->ready) { in virtinput_recv_events()
42 while ((event = virtqueue_get_buf(vi->evt, &len)) != NULL) { in virtinput_recv_events()
43 spin_unlock_irqrestore(&vi->lock, flags); in virtinput_recv_events()
44 input_event(vi->idev, in virtinput_recv_events()
45 le16_to_cpu(event->type), in virtinput_recv_events()
46 le16_to_cpu(event->code), in virtinput_recv_events()
47 le32_to_cpu(event->value)); in virtinput_recv_events()
48 spin_lock_irqsave(&vi->lock, flags); in virtinput_recv_events()
53 spin_unlock_irqrestore(&vi->lock, flags); in virtinput_recv_events()
69 * Since 29cc309d8bf1 (HID: hid-multitouch: forward MSC_TIMESTAMP), in virtinput_send_status()
80 if (vi->idev->mt && type == EV_MSC && code == MSC_TIMESTAMP) in virtinput_send_status()
85 return -ENOMEM; in virtinput_send_status()
87 stsbuf->type = cpu_to_le16(type); in virtinput_send_status()
88 stsbuf->code = cpu_to_le16(code); in virtinput_send_status()
89 stsbuf->value = cpu_to_le32(value); in virtinput_send_status()
92 spin_lock_irqsave(&vi->lock, flags); in virtinput_send_status()
93 if (vi->ready) { in virtinput_send_status()
94 rc = virtqueue_add_outbuf(vi->sts, sg, 1, stsbuf, GFP_ATOMIC); in virtinput_send_status()
95 virtqueue_kick(vi->sts); in virtinput_send_status()
97 rc = -ENODEV; in virtinput_send_status()
99 spin_unlock_irqrestore(&vi->lock, flags); in virtinput_send_status()
108 struct virtio_input *vi = vq->vdev->priv; in virtinput_recv_status()
113 spin_lock_irqsave(&vi->lock, flags); in virtinput_recv_status()
114 while ((stsbuf = virtqueue_get_buf(vi->sts, &len)) != NULL) in virtinput_recv_status()
116 spin_unlock_irqrestore(&vi->lock, flags); in virtinput_recv_status()
132 virtio_cwrite_le(vi->vdev, struct virtio_input_config, select, &select); in virtinput_cfg_select()
133 virtio_cwrite_le(vi->vdev, struct virtio_input_config, subsel, &subsel); in virtinput_cfg_select()
134 virtio_cread_le(vi->vdev, struct virtio_input_config, size, &size); in virtinput_cfg_select()
153 * with the first byte carrying bits 0-7, second bits 8-15 and in virtinput_cfg_bits()
159 virtio_cread_bytes(vi->vdev, offsetof(struct virtio_input_config, in virtinput_cfg_bits()
169 __set_bit(subsel, vi->idev->evbit); in virtinput_cfg_bits()
172 static void virtinput_cfg_abs(struct virtio_input *vi, int abs) in virtinput_cfg_abs() argument
176 virtinput_cfg_select(vi, VIRTIO_INPUT_CFG_ABS_INFO, abs); in virtinput_cfg_abs()
177 virtio_cread_le(vi->vdev, struct virtio_input_config, u.abs.min, &mi); in virtinput_cfg_abs()
178 virtio_cread_le(vi->vdev, struct virtio_input_config, u.abs.max, &ma); in virtinput_cfg_abs()
179 virtio_cread_le(vi->vdev, struct virtio_input_config, u.abs.res, &re); in virtinput_cfg_abs()
180 virtio_cread_le(vi->vdev, struct virtio_input_config, u.abs.fuzz, &fu); in virtinput_cfg_abs()
181 virtio_cread_le(vi->vdev, struct virtio_input_config, u.abs.flat, &fl); in virtinput_cfg_abs()
182 input_set_abs_params(vi->idev, abs, mi, ma, fu, fl); in virtinput_cfg_abs()
183 input_abs_set_res(vi->idev, abs, re); in virtinput_cfg_abs()
195 err = virtio_find_vqs(vi->vdev, 2, vqs, vqs_info, NULL); in virtinput_init_vqs()
198 vi->evt = vqs[0]; in virtinput_init_vqs()
199 vi->sts = vqs[1]; in virtinput_init_vqs()
209 spin_lock_irqsave(&vi->lock, flags); in virtinput_fill_evt()
210 size = virtqueue_get_vring_size(vi->evt); in virtinput_fill_evt()
211 if (size > ARRAY_SIZE(vi->evts)) in virtinput_fill_evt()
212 size = ARRAY_SIZE(vi->evts); in virtinput_fill_evt()
214 virtinput_queue_evtbuf(vi, &vi->evts[i]); in virtinput_fill_evt()
215 virtqueue_kick(vi->evt); in virtinput_fill_evt()
216 spin_unlock_irqrestore(&vi->lock, flags); in virtinput_fill_evt()
224 int abs, err, nslots; in virtinput_probe() local
227 return -ENODEV; in virtinput_probe()
231 return -ENOMEM; in virtinput_probe()
233 vdev->priv = vi; in virtinput_probe()
234 vi->vdev = vdev; in virtinput_probe()
235 spin_lock_init(&vi->lock); in virtinput_probe()
241 vi->idev = input_allocate_device(); in virtinput_probe()
242 if (!vi->idev) { in virtinput_probe()
243 err = -ENOMEM; in virtinput_probe()
246 input_set_drvdata(vi->idev, vi); in virtinput_probe()
249 virtio_cread_bytes(vi->vdev, offsetof(struct virtio_input_config, in virtinput_probe()
251 vi->name, min(size, sizeof(vi->name))); in virtinput_probe()
253 virtio_cread_bytes(vi->vdev, offsetof(struct virtio_input_config, in virtinput_probe()
255 vi->serial, min(size, sizeof(vi->serial))); in virtinput_probe()
256 snprintf(vi->phys, sizeof(vi->phys), in virtinput_probe()
257 "virtio%d/input0", vdev->index); in virtinput_probe()
258 vi->idev->name = vi->name; in virtinput_probe()
259 vi->idev->phys = vi->phys; in virtinput_probe()
260 vi->idev->uniq = vi->serial; in virtinput_probe()
264 virtio_cread_le(vi->vdev, struct virtio_input_config, in virtinput_probe()
265 u.ids.bustype, &vi->idev->id.bustype); in virtinput_probe()
266 virtio_cread_le(vi->vdev, struct virtio_input_config, in virtinput_probe()
267 u.ids.vendor, &vi->idev->id.vendor); in virtinput_probe()
268 virtio_cread_le(vi->vdev, struct virtio_input_config, in virtinput_probe()
269 u.ids.product, &vi->idev->id.product); in virtinput_probe()
270 virtio_cread_le(vi->vdev, struct virtio_input_config, in virtinput_probe()
271 u.ids.version, &vi->idev->id.version); in virtinput_probe()
273 vi->idev->id.bustype = BUS_VIRTUAL; in virtinput_probe()
277 vi->idev->propbit, INPUT_PROP_CNT); in virtinput_probe()
280 __set_bit(EV_REP, vi->idev->evbit); in virtinput_probe()
282 vi->idev->dev.parent = &vdev->dev; in virtinput_probe()
283 vi->idev->event = virtinput_status; in virtinput_probe()
285 /* device -> kernel */ in virtinput_probe()
287 vi->idev->keybit, KEY_CNT); in virtinput_probe()
289 vi->idev->relbit, REL_CNT); in virtinput_probe()
291 vi->idev->absbit, ABS_CNT); in virtinput_probe()
293 vi->idev->mscbit, MSC_CNT); in virtinput_probe()
295 vi->idev->swbit, SW_CNT); in virtinput_probe()
297 /* kernel -> device */ in virtinput_probe()
299 vi->idev->ledbit, LED_CNT); in virtinput_probe()
301 vi->idev->sndbit, SND_CNT); in virtinput_probe()
303 if (test_bit(EV_ABS, vi->idev->evbit)) { in virtinput_probe()
304 for (abs = 0; abs < ABS_CNT; abs++) { in virtinput_probe()
305 if (!test_bit(abs, vi->idev->absbit)) in virtinput_probe()
307 virtinput_cfg_abs(vi, abs); in virtinput_probe()
310 if (test_bit(ABS_MT_SLOT, vi->idev->absbit)) { in virtinput_probe()
311 nslots = input_abs_get_max(vi->idev, ABS_MT_SLOT) + 1; in virtinput_probe()
312 err = input_mt_init_slots(vi->idev, nslots, 0); in virtinput_probe()
319 vi->ready = true; in virtinput_probe()
320 err = input_register_device(vi->idev); in virtinput_probe()
328 spin_lock_irqsave(&vi->lock, flags); in virtinput_probe()
329 vi->ready = false; in virtinput_probe()
330 spin_unlock_irqrestore(&vi->lock, flags); in virtinput_probe()
332 input_free_device(vi->idev); in virtinput_probe()
334 vdev->config->del_vqs(vdev); in virtinput_probe()
342 struct virtio_input *vi = vdev->priv; in virtinput_remove()
346 spin_lock_irqsave(&vi->lock, flags); in virtinput_remove()
347 vi->ready = false; in virtinput_remove()
348 spin_unlock_irqrestore(&vi->lock, flags); in virtinput_remove()
350 input_unregister_device(vi->idev); in virtinput_remove()
352 while ((buf = virtqueue_detach_unused_buf(vi->sts)) != NULL) in virtinput_remove()
354 vdev->config->del_vqs(vdev); in virtinput_remove()
361 struct virtio_input *vi = vdev->priv; in virtinput_freeze()
364 spin_lock_irqsave(&vi->lock, flags); in virtinput_freeze()
365 vi->ready = false; in virtinput_freeze()
366 spin_unlock_irqrestore(&vi->lock, flags); in virtinput_freeze()
368 vdev->config->del_vqs(vdev); in virtinput_freeze()
374 struct virtio_input *vi = vdev->priv; in virtinput_restore()
382 vi->ready = true; in virtinput_restore()