Lines Matching +full:trackpad +full:- +full:3 +full:x

1 // SPDX-License-Identifier: GPL-2.0
14 * - /sys/bus/adb to list the devices and infos
15 * - more /dev/adb to allow userland to receive the
16 * flow of auto-polling datas from a given device.
17 * - move bus probe to a kernel thread
119 printk("adb reply (%d)", req->reply_len);
120 for(i = 0; i < req->reply_len; i++)
121 printk(" %x", req->reply[i]);
151 * Send a "talk register 3" command to address i in adb_scan_bus()
162 adb_request(&req, NULL, ADBREQ_SYNC, 3, in adb_scan_bus()
190 highFree--; in adb_scan_bus()
200 adb_request(&req, NULL, ADBREQ_SYNC, 3, in adb_scan_bus()
214 printk(KERN_DEBUG "adb device [%d]: %d 0x%X\n", i, in adb_scan_bus()
227 adb_probe_task(void *x) in adb_probe_task() argument
269 if (adb_controller->autopoll) in __adb_suspend()
270 adb_controller->autopoll(0); in __adb_suspend()
323 /* xmon may do early-init */ in adb_init()
332 if (!driver->probe()) { in adb_init()
337 if (adb_controller != NULL && adb_controller->init && in adb_init()
338 adb_controller->init()) in adb_init()
363 return -ENXIO; in do_adb_reset_bus()
365 if (adb_controller->autopoll) in do_adb_reset_bus()
366 adb_controller->autopoll(0); in do_adb_reset_bus()
372 /* Let the trackpad settle down */ in do_adb_reset_bus()
382 if (adb_controller->reset_bus) in do_adb_reset_bus()
383 ret = adb_controller->reset_bus(); in do_adb_reset_bus()
388 /* Let the trackpad settle down */ in do_adb_reset_bus()
394 if (adb_controller->autopoll) in do_adb_reset_bus()
395 adb_controller->autopoll(autopoll_devs); in do_adb_reset_bus()
408 if ((adb_controller == NULL)||(adb_controller->poll == NULL)) in adb_poll()
410 adb_controller->poll(); in adb_poll()
416 struct completion *comp = req->arg; in adb_sync_req_done()
430 if ((adb_controller == NULL) || (adb_controller->send_request == NULL)) in adb_request()
431 return -ENXIO; in adb_request()
433 return -EINVAL; in adb_request()
435 req->nbytes = nbytes+1; in adb_request()
436 req->done = done; in adb_request()
437 req->reply_expected = flags & ADBREQ_REPLY; in adb_request()
438 req->data[0] = ADB_PACKET; in adb_request()
441 req->data[i+1] = va_arg(list, int); in adb_request()
447 /* Synchronous requests block using an on-stack completion */ in adb_request()
450 req->done = adb_sync_req_done; in adb_request()
451 req->arg = &comp; in adb_request()
455 rc = adb_controller->send_request(req, 0); in adb_request()
457 if ((flags & ADBREQ_SYNC) && !rc && !req->complete) in adb_request()
478 ids->nids = 0; in adb_register()
491 ids->id[ids->nids++] = i; in adb_register()
495 return ids->nids; in adb_register()
502 int ret = -ENODEV; in adb_unregister()
540 pr_cont(" %x", buf[i]); in adb_input()
563 adb_request(&req, NULL, ADBREQ_SYNC, 3, in try_handler_change()
564 ADB_WRITEREG(address, 3), address | 0x20, new_id); in try_handler_change()
566 ADB_READREG(address, 3)); in try_handler_change()
585 pr_debug("adb handler change: [%d] 0x%X\n", address, new_id); in adb_try_handler_change()
618 struct adbdev_state *state = (struct adbdev_state *) req->arg; in adb_write_done()
621 if (!req->complete) { in adb_write_done()
622 req->reply_len = 0; in adb_write_done()
623 req->complete = 1; in adb_write_done()
625 spin_lock_irqsave(&state->lock, flags); in adb_write_done()
626 atomic_dec(&state->n_pending); in adb_write_done()
627 if (!state->inuse) { in adb_write_done()
629 if (atomic_read(&state->n_pending) == 0) { in adb_write_done()
630 spin_unlock_irqrestore(&state->lock, flags); in adb_write_done()
635 struct adb_request **ap = &state->completed; in adb_write_done()
637 ap = &(*ap)->next; in adb_write_done()
638 req->next = NULL; in adb_write_done()
640 wake_up_interruptible(&state->wait_queue); in adb_write_done()
642 spin_unlock_irqrestore(&state->lock, flags); in adb_write_done()
648 int ret = -EINVAL; in do_adb_query()
650 switch(req->data[1]) { in do_adb_query()
652 if (req->nbytes < 3 || req->data[2] >= 16) in do_adb_query()
655 req->reply[0] = adb_handler[req->data[2]].original_address; in do_adb_query()
656 req->reply[1] = adb_handler[req->data[2]].handler_id; in do_adb_query()
658 req->complete = 1; in do_adb_query()
659 req->reply_len = 2; in do_adb_query()
674 ret = -ENXIO; in adb_open()
679 ret = -ENOMEM; in adb_open()
682 file->private_data = state; in adb_open()
683 spin_lock_init(&state->lock); in adb_open()
684 atomic_set(&state->n_pending, 0); in adb_open()
685 state->completed = NULL; in adb_open()
686 init_waitqueue_head(&state->wait_queue); in adb_open()
687 state->inuse = 1; in adb_open()
696 struct adbdev_state *state = file->private_data; in adb_release()
701 file->private_data = NULL; in adb_release()
702 spin_lock_irqsave(&state->lock, flags); in adb_release()
703 if (atomic_read(&state->n_pending) == 0 in adb_release()
704 && state->completed == NULL) { in adb_release()
705 spin_unlock_irqrestore(&state->lock, flags); in adb_release()
708 state->inuse = 0; in adb_release()
709 spin_unlock_irqrestore(&state->lock, flags); in adb_release()
720 struct adbdev_state *state = file->private_data; in adb_read()
726 return -EINVAL; in adb_read()
727 if (count > sizeof(req->reply)) in adb_read()
728 count = sizeof(req->reply); in adb_read()
731 spin_lock_irqsave(&state->lock, flags); in adb_read()
732 add_wait_queue(&state->wait_queue, &wait); in adb_read()
736 req = state->completed; in adb_read()
738 state->completed = req->next; in adb_read()
739 else if (atomic_read(&state->n_pending) == 0) in adb_read()
740 ret = -EIO; in adb_read()
744 if (file->f_flags & O_NONBLOCK) { in adb_read()
745 ret = -EAGAIN; in adb_read()
749 ret = -ERESTARTSYS; in adb_read()
752 spin_unlock_irqrestore(&state->lock, flags); in adb_read()
754 spin_lock_irqsave(&state->lock, flags); in adb_read()
758 remove_wait_queue(&state->wait_queue, &wait); in adb_read()
759 spin_unlock_irqrestore(&state->lock, flags); in adb_read()
764 ret = req->reply_len; in adb_read()
767 if (ret > 0 && copy_to_user(buf, req->reply, ret)) in adb_read()
768 ret = -EFAULT; in adb_read()
778 struct adbdev_state *state = file->private_data; in adb_write()
781 if (count < 2 || count > sizeof(req->data)) in adb_write()
782 return -EINVAL; in adb_write()
784 return -ENXIO; in adb_write()
789 return -ENOMEM; in adb_write()
791 req->nbytes = count; in adb_write()
792 req->done = adb_write_done; in adb_write()
793 req->arg = (void *) state; in adb_write()
794 req->complete = 0; in adb_write()
796 ret = -EFAULT; in adb_write()
797 if (copy_from_user(req->data, buf, count)) in adb_write()
800 atomic_inc(&state->n_pending); in adb_write()
806 if (req->data[0] == ADB_QUERY) { in adb_write()
810 ret = -EINVAL; in adb_write()
815 else if ((req->data[0] == ADB_PACKET) && (count > 1) in adb_write()
816 && (req->data[1] == ADB_BUSRESET)) { in adb_write()
819 atomic_dec(&state->n_pending); in adb_write()
824 req->reply_expected = ((req->data[1] & 0xc) == 0xc); in adb_write()
825 if (adb_controller && adb_controller->send_request) in adb_write()
826 ret = adb_controller->send_request(req, 0); in adb_write()
828 ret = -ENXIO; in adb_write()
833 atomic_dec(&state->n_pending); in adb_write()
881 return -ENODEV; in adb_dummy_probe()