Lines Matching refs:qdev

246     qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device;  in fingerprint_get_auth_id()  local
249 pthread_mutex_lock(&qdev->lock); in fingerprint_get_auth_id()
250 authenticator_id = qdev->authenticator_id; in fingerprint_get_auth_id()
251 pthread_mutex_unlock(&qdev->lock); in fingerprint_get_auth_id()
260 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; in fingerprint_set_active_group() local
261 pthread_mutex_lock(&qdev->lock); in fingerprint_set_active_group()
262 qdev->group_id = gid; in fingerprint_set_active_group()
263 snprintf(qdev->listener.fp_filename, sizeof(qdev->listener.fp_filename), in fingerprint_set_active_group()
265 snprintf(qdev->listener.authid_filename, sizeof(qdev->listener.authid_filename), in fingerprint_set_active_group()
268 loadFingerprints(&qdev->listener); in fingerprint_set_active_group()
269 loadAuthenticatorId(qdev->listener.authid_filename, &authenticator_id); in fingerprint_set_active_group()
274 saveAuthenticatorId(qdev->listener.authid_filename, authenticator_id); in fingerprint_set_active_group()
277 qdev->authenticator_id = authenticator_id; in fingerprint_set_active_group()
278 pthread_mutex_unlock(&qdev->lock); in fingerprint_set_active_group()
292 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; in fingerprint_authenticate() local
294 pthread_mutex_lock(&qdev->lock); in fingerprint_authenticate()
295 qdev->op_id = operation_id; in fingerprint_authenticate()
296 qdev->listener.state = STATE_SCAN; in fingerprint_authenticate()
297 pthread_mutex_unlock(&qdev->lock); in fingerprint_authenticate()
366 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; in fingerprint_pre_enroll() local
373 pthread_mutex_lock(&qdev->lock); in fingerprint_pre_enroll()
374 qdev->challenge = challenge; in fingerprint_pre_enroll()
375 pthread_mutex_unlock(&qdev->lock); in fingerprint_pre_enroll()
382 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; in fingerprint_post_enroll() local
384 pthread_mutex_lock(&qdev->lock); in fingerprint_post_enroll()
385 qdev->challenge = 0; in fingerprint_post_enroll()
386 pthread_mutex_unlock(&qdev->lock); in fingerprint_post_enroll()
397 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; in fingerprint_cancel() local
399 pthread_mutex_lock(&qdev->lock); in fingerprint_cancel()
400 qdev->listener.state = STATE_IDLE; in fingerprint_cancel()
401 pthread_mutex_unlock(&qdev->lock); in fingerprint_cancel()
406 qdev->device.notify(&msg); in fingerprint_cancel()
418 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; in fingerprint_enumerate() local
421 if (qdev->listener.secureid[i] != 0 || in fingerprint_enumerate()
422 qdev->listener.fingerid[i] != 0) { in fingerprint_enumerate()
424 qdev->listener.secureid[i], qdev->listener.fingerid[i]); in fingerprint_enumerate()
430 message.data.enumerated.finger.gid = qdev->group_id; in fingerprint_enumerate()
435 qdev->device.notify(&message); in fingerprint_enumerate()
439 if (qdev->listener.secureid[i] != 0 || in fingerprint_enumerate()
440 qdev->listener.fingerid[i] != 0) { in fingerprint_enumerate()
443 message.data.enumerated.finger.fid = qdev->listener.fingerid[i]; in fingerprint_enumerate()
444 qdev->device.notify(&message); in fingerprint_enumerate()
464 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; in fingerprint_remove() local
472 pthread_mutex_lock(&qdev->lock); in fingerprint_remove()
475 uint32_t theFid = qdev->listener.fingerid[idx]; in fingerprint_remove()
478 qdev->listener.secureid[idx] = 0; in fingerprint_remove()
479 qdev->listener.fingerid[idx] = 0; in fingerprint_remove()
480 saveFingerprint(&qdev->listener, idx); in fingerprint_remove()
483 pthread_mutex_unlock(&qdev->lock); in fingerprint_remove()
486 msg.data.removed.finger.gid = qdev->group_id; in fingerprint_remove()
497 qdev->listener.state = STATE_IDLE; in fingerprint_remove()
498 pthread_mutex_unlock(&qdev->lock); in fingerprint_remove()
501 msg.data.removed.finger.gid = qdev->group_id; in fingerprint_remove()
506 pthread_mutex_lock(&qdev->lock); in fingerprint_remove()
508 if (qdev->listener.fingerid[idx] == fid && in fingerprint_remove()
509 qdev->listener.secureid[idx] != 0) { in fingerprint_remove()
515 qdev->listener.state = STATE_IDLE; in fingerprint_remove()
516 pthread_mutex_unlock(&qdev->lock); in fingerprint_remove()
523 msg.data.removed.finger.gid = qdev->group_id; in fingerprint_remove()
529 qdev->listener.secureid[idx] = 0; in fingerprint_remove()
530 qdev->listener.fingerid[idx] = 0; in fingerprint_remove()
531 saveFingerprint(&qdev->listener, idx); in fingerprint_remove()
533 qdev->listener.state = STATE_IDLE; in fingerprint_remove()
534 pthread_mutex_unlock(&qdev->lock); in fingerprint_remove()
553 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; in set_notify_callback() local
554 pthread_mutex_lock(&qdev->lock); in set_notify_callback()
555 qdev->listener.state = STATE_IDLE; in set_notify_callback()
557 pthread_mutex_unlock(&qdev->lock); in set_notify_callback()
563 static bool is_valid_fid(qemu_fingerprint_device_t* qdev, uint64_t fid) { in is_valid_fid() argument
567 if (qdev->listener.fingerid[idx] == fid) { in is_valid_fid()
574 static void send_scan_notice(qemu_fingerprint_device_t* qdev, int fid) { in send_scan_notice() argument
585 auth_msg.data.authenticated.finger.fid = is_valid_fid(qdev, fid) ? fid : 0; in send_scan_notice()
590 auth_msg.data.authenticated.hat.challenge = qdev->op_id; in send_scan_notice()
591 auth_msg.data.authenticated.hat.authenticator_id = qdev->authenticator_id; in send_scan_notice()
592 auth_msg.data.authenticated.hat.user_id = qdev->secure_user_id; in send_scan_notice()
599 qdev->device.notify(&acqu_msg); in send_scan_notice()
600 qdev->device.notify(&auth_msg); in send_scan_notice()
606 static void send_enroll_notice(qemu_fingerprint_device_t* qdev, int fid) { in send_enroll_notice() argument
613 if (qdev->secure_user_id == 0) { in send_enroll_notice()
619 pthread_mutex_lock(&qdev->lock); in send_enroll_notice()
622 if (qdev->listener.secureid[idx] == 0 || in send_enroll_notice()
623 qdev->listener.fingerid[idx] == 0) { in send_enroll_notice()
629 qdev->listener.state = STATE_IDLE; in send_enroll_notice()
630 pthread_mutex_unlock(&qdev->lock); in send_enroll_notice()
634 qdev->listener.samples_remaining--; in send_enroll_notice()
635 int samples_remaining = qdev->listener.samples_remaining; in send_enroll_notice()
637 qdev->listener.secureid[idx] = qdev->secure_user_id; in send_enroll_notice()
638 qdev->listener.fingerid[idx] = fid; in send_enroll_notice()
639 saveFingerprint(&qdev->listener, idx); in send_enroll_notice()
640 qdev->listener.state = STATE_IDLE; in send_enroll_notice()
642 pthread_mutex_unlock(&qdev->lock); in send_enroll_notice()
648 qdev->device.notify(&msg); in send_enroll_notice()
688 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)data; in listenerFunction() local
691 pthread_mutex_lock(&qdev->lock); in listenerFunction()
692 qdev->qchanfd = fd; in listenerFunction()
693 if (qdev->qchanfd < 0) { in listenerFunction()
695 pthread_mutex_unlock(&qdev->lock); in listenerFunction()
698 qdev->listener.state = STATE_IDLE; in listenerFunction()
699 pthread_mutex_unlock(&qdev->lock); in listenerFunction()
702 if (qemud_channel_send(qdev->qchanfd, cmd, strlen(cmd)) < 0) { in listenerFunction()
709 .fd = qdev->qchanfd, in listenerFunction()
718 if (getListenerState(qdev) == STATE_EXIT) { in listenerFunction()
757 if ((size = qemud_channel_recv(qdev->qchanfd, buffer, in listenerFunction()
762 switch (qdev->listener.state) { in listenerFunction()
764 send_enroll_notice(qdev, fid); in listenerFunction()
767 send_scan_notice(qdev, fid); in listenerFunction()
772 qdev->listener.state); in listenerFunction()
802 close(qdev->qchanfd); in listenerFunction()
813 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; in fingerprint_close() local
814 pthread_mutex_lock(&qdev->lock); in fingerprint_close()
816 qdev->listener.state = STATE_EXIT; in fingerprint_close()
817 pthread_mutex_unlock(&qdev->lock); in fingerprint_close()
819 pthread_join(qdev->listener.thread, NULL); in fingerprint_close()
820 pthread_mutex_destroy(&qdev->lock); in fingerprint_close()
821 free(qdev); in fingerprint_close()
836 qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)calloc( in fingerprint_open() local
838 if (qdev == NULL) { in fingerprint_open()
844 qdev->device.common.tag = HARDWARE_DEVICE_TAG; in fingerprint_open()
845 qdev->device.common.version = HARDWARE_MODULE_API_VERSION(2, 1); in fingerprint_open()
846 qdev->device.common.module = (struct hw_module_t*)module; in fingerprint_open()
847 qdev->device.common.close = fingerprint_close; in fingerprint_open()
849 qdev->device.pre_enroll = fingerprint_pre_enroll; in fingerprint_open()
850 qdev->device.enroll = fingerprint_enroll; in fingerprint_open()
851 qdev->device.post_enroll = fingerprint_post_enroll; in fingerprint_open()
852 qdev->device.get_authenticator_id = fingerprint_get_auth_id; in fingerprint_open()
853 qdev->device.set_active_group = fingerprint_set_active_group; in fingerprint_open()
854 qdev->device.authenticate = fingerprint_authenticate; in fingerprint_open()
855 qdev->device.cancel = fingerprint_cancel; in fingerprint_open()
856 qdev->device.enumerate = fingerprint_enumerate; in fingerprint_open()
857 qdev->device.remove = fingerprint_remove; in fingerprint_open()
858 qdev->device.set_notify = set_notify_callback; in fingerprint_open()
859 qdev->device.notify = NULL; in fingerprint_open()
862 pthread_mutex_init(&qdev->lock, NULL); in fingerprint_open()
863 if (pthread_create(&qdev->listener.thread, NULL, listenerFunction, qdev) != in fingerprint_open()
868 *device = &qdev->device.common; in fingerprint_open()