• Home
  • Raw
  • Download

Lines Matching full:dev

64  * @param dev       Pointer to the device object (GT68xx_Device).
67 #define CHECK_DEV_NOT_NULL(dev, func_name) \ argument
70 if (!(dev)) \
80 * @param dev Pointer to the device object (GT68xx_Device).
83 #define CHECK_DEV_OPEN(dev, func_name) \ argument
86 CHECK_DEV_NOT_NULL ((dev), (func_name)); \
87 if ((dev)->fd == -1) \
90 ((void *) dev)); \
98 * @param dev Pointer to the device (GT68xx_Device).
101 #define CHECK_DEV_ACTIVE(dev, func_name) \ argument
104 CHECK_DEV_OPEN ((dev), (func_name)); \
105 if (!(dev)->active) \
108 ((void *) dev)); \
147 GT68xx_Device *dev; in gt68xx_device_new() local
153 dev = (GT68xx_Device *) malloc (sizeof (GT68xx_Device)); in gt68xx_device_new()
155 if (!dev) in gt68xx_device_new()
162 *dev_return = dev; in gt68xx_device_new()
164 memset (dev, 0, sizeof (GT68xx_Device)); in gt68xx_device_new()
166 dev->fd = -1; in gt68xx_device_new()
167 dev->active = SANE_FALSE; in gt68xx_device_new()
169 dev->model = NULL; in gt68xx_device_new()
170 dev->command_set_private = NULL; in gt68xx_device_new()
172 dev->read_buffer = NULL; in gt68xx_device_new()
173 dev->read_buffer_size = 32768; in gt68xx_device_new()
175 dev->manual_selection = SANE_FALSE; in gt68xx_device_new()
177 dev->scan_started = SANE_FALSE; in gt68xx_device_new()
180 dev->shm_channel = NULL; in gt68xx_device_new()
188 gt68xx_device_free (GT68xx_Device * dev) in gt68xx_device_free() argument
190 DBG (7, "gt68xx_device_free: enter: dev=%p\n", (void *) dev); in gt68xx_device_free()
191 if (dev) in gt68xx_device_free()
193 if (dev->active) in gt68xx_device_free()
194 gt68xx_device_deactivate (dev); in gt68xx_device_free()
196 if (dev->fd != -1) in gt68xx_device_free()
197 gt68xx_device_close (dev); in gt68xx_device_free()
199 if (dev->model && dev->model->allocated) in gt68xx_device_free()
202 (void *) dev->model); in gt68xx_device_free()
203 free (dev->model); in gt68xx_device_free()
206 DBG (7, "gt68xx_device_free: freeing dev\n"); in gt68xx_device_free()
207 free (dev); in gt68xx_device_free()
228 gt68xx_device_identify (GT68xx_Device * dev) in gt68xx_device_identify() argument
234 CHECK_DEV_OPEN (dev, "gt68xx_device_identify"); in gt68xx_device_identify()
236 status = sanei_usb_get_vendor_product (dev->fd, &vendor, &product); in gt68xx_device_identify()
248 dev->model = entry->model; in gt68xx_device_identify()
252 dev->model = NULL; in gt68xx_device_identify()
262 gt68xx_device_open (GT68xx_Device * dev, const char *dev_name) in gt68xx_device_open() argument
267 DBG (7, "gt68xx_device_open: enter: dev=%p\n", (void *) dev); in gt68xx_device_open()
269 CHECK_DEV_NOT_NULL (dev, "gt68xx_device_open"); in gt68xx_device_open()
271 if (dev->fd != -1) in gt68xx_device_open()
285 dev->fd = fd; in gt68xx_device_open()
287 if (!dev->model) in gt68xx_device_open()
288 gt68xx_device_identify (dev); in gt68xx_device_open()
295 gt68xx_device_close (GT68xx_Device * dev) in gt68xx_device_close() argument
297 DBG (7, "gt68xx_device_close: enter: dev=%p\n", (void *) dev); in gt68xx_device_close()
299 CHECK_DEV_OPEN (dev, "gt68xx_device_close"); in gt68xx_device_close()
301 if (dev->active) in gt68xx_device_close()
302 gt68xx_device_deactivate (dev); in gt68xx_device_close()
304 sanei_usb_close (dev->fd); in gt68xx_device_close()
305 dev->fd = -1; in gt68xx_device_close()
312 gt68xx_device_is_configured (GT68xx_Device * dev) in gt68xx_device_is_configured() argument
314 if (dev && dev->model && dev->model->command_set) in gt68xx_device_is_configured()
321 gt68xx_device_set_model (GT68xx_Device * dev, GT68xx_Model * model) in gt68xx_device_set_model() argument
323 if (dev->active) in gt68xx_device_set_model()
329 if (dev->model && dev->model->allocated) in gt68xx_device_set_model()
330 free (dev->model); in gt68xx_device_set_model()
332 dev->model = model; in gt68xx_device_set_model()
355 gt68xx_device_activate (GT68xx_Device * dev) in gt68xx_device_activate() argument
358 CHECK_DEV_OPEN (dev, "gt68xx_device_activate"); in gt68xx_device_activate()
359 if (dev->active) in gt68xx_device_activate()
365 if (!gt68xx_device_is_configured (dev)) in gt68xx_device_activate()
371 DBG (7, "gt68xx_device_activate: model \"%s\"\n", dev->model->name); in gt68xx_device_activate()
372 if (dev->model->command_set->activate) in gt68xx_device_activate()
374 status = (*dev->model->command_set->activate) (dev); in gt68xx_device_activate()
382 dev->afe = malloc (sizeof (*dev->afe)); in gt68xx_device_activate()
383 dev->exposure = malloc (sizeof (*dev->exposure)); in gt68xx_device_activate()
384 if (!dev->afe || !dev->exposure) in gt68xx_device_activate()
386 memcpy (dev->afe, &dev->model->afe_params, sizeof (*dev->afe)); in gt68xx_device_activate()
387 memcpy (dev->exposure, &dev->model->exposure, sizeof (*dev->exposure)); in gt68xx_device_activate()
388 dev->gamma_value = dev->model->default_gamma_value; in gt68xx_device_activate()
389 dev->active = SANE_TRUE; in gt68xx_device_activate()
394 gt68xx_device_deactivate (GT68xx_Device * dev) in gt68xx_device_deactivate() argument
397 CHECK_DEV_ACTIVE (dev, "gt68xx_device_deactivate"); in gt68xx_device_deactivate()
398 if (dev->read_active) in gt68xx_device_deactivate()
399 gt68xx_device_read_finish (dev); in gt68xx_device_deactivate()
400 if (dev->model->command_set->deactivate) in gt68xx_device_deactivate()
402 status = (*dev->model->command_set->deactivate) (dev); in gt68xx_device_deactivate()
411 if (dev->afe) in gt68xx_device_deactivate()
412 free (dev->afe); in gt68xx_device_deactivate()
413 dev->afe = 0; in gt68xx_device_deactivate()
414 if (dev->exposure) in gt68xx_device_deactivate()
415 free (dev->exposure); in gt68xx_device_deactivate()
416 dev->exposure = 0; in gt68xx_device_deactivate()
417 dev->active = SANE_FALSE; in gt68xx_device_deactivate()
422 gt68xx_device_memory_write (GT68xx_Device * dev, in gt68xx_device_memory_write() argument
427 "gt68xx_device_memory_write: dev=%p, addr=0x%x, size=0x%x, data=%p\n", in gt68xx_device_memory_write()
428 (void *) dev, addr, size, (void *) data); in gt68xx_device_memory_write()
429 CHECK_DEV_ACTIVE (dev, "gt68xx_device_memory_write"); in gt68xx_device_memory_write()
431 sanei_usb_control_msg (dev->fd, 0x40, in gt68xx_device_memory_write()
432 dev->model->command_set->request, in gt68xx_device_memory_write()
433 dev->model->command_set->memory_write_value, in gt68xx_device_memory_write()
445 gt68xx_device_memory_read (GT68xx_Device * dev, in gt68xx_device_memory_read() argument
450 "gt68xx_device_memory_read: dev=%p, addr=0x%x, size=0x%x, data=%p\n", in gt68xx_device_memory_read()
451 (void *) dev, addr, size, (void *) data); in gt68xx_device_memory_read()
452 CHECK_DEV_ACTIVE (dev, "gt68xx_device_memory_read"); in gt68xx_device_memory_read()
454 sanei_usb_control_msg (dev->fd, 0xc0, in gt68xx_device_memory_read()
455 dev->model->command_set->request, in gt68xx_device_memory_read()
456 dev->model->command_set->memory_read_value, in gt68xx_device_memory_read()
469 gt68xx_device_generic_req (GT68xx_Device * dev, in gt68xx_device_generic_req() argument
479 CHECK_DEV_ACTIVE (dev, "gt68xx_device_generic_req"); in gt68xx_device_generic_req()
480 status = sanei_usb_control_msg (dev->fd, in gt68xx_device_generic_req()
491 status = sanei_usb_control_msg (dev->fd, in gt68xx_device_generic_req()
506 gt68xx_device_req (GT68xx_Device * dev, GT68xx_Packet cmd, GT68xx_Packet res) in gt68xx_device_req() argument
508 GT68xx_Command_Set *command_set = dev->model->command_set; in gt68xx_device_req()
509 return gt68xx_device_generic_req (dev, in gt68xx_device_req()
520 gt68xx_device_small_req (GT68xx_Device * dev, GT68xx_Packet cmd, in gt68xx_device_small_req() argument
523 GT68xx_Command_Set *command_set = dev->model->command_set; in gt68xx_device_small_req()
528 return gt68xx_device_generic_req (dev, in gt68xx_device_small_req()
540 gt68xx_device_download_firmware (GT68xx_Device * dev, in gt68xx_device_download_firmware() argument
543 CHECK_DEV_ACTIVE (dev, "gt68xx_device_download_firmware"); in gt68xx_device_download_firmware()
544 if (dev->model->command_set->download_firmware) in gt68xx_device_download_firmware()
545 return (*dev->model->command_set->download_firmware) (dev, data, size); in gt68xx_device_download_firmware()
551 gt68xx_device_get_power_status (GT68xx_Device * dev, SANE_Bool * power_ok) in gt68xx_device_get_power_status() argument
553 CHECK_DEV_ACTIVE (dev, "gt68xx_device_get_power_status"); in gt68xx_device_get_power_status()
554 if (dev->model->command_set->get_power_status) in gt68xx_device_get_power_status()
555 return (*dev->model->command_set->get_power_status) (dev, power_ok); in gt68xx_device_get_power_status()
561 gt68xx_device_get_ta_status (GT68xx_Device * dev, SANE_Bool * ta_attached) in gt68xx_device_get_ta_status() argument
563 CHECK_DEV_ACTIVE (dev, "gt68xx_device_get_ta_status"); in gt68xx_device_get_ta_status()
564 if (dev->model->command_set->get_ta_status) in gt68xx_device_get_ta_status()
565 return (*dev->model->command_set->get_ta_status) (dev, ta_attached); in gt68xx_device_get_ta_status()
571 gt68xx_device_lamp_control (GT68xx_Device * dev, SANE_Bool fb_lamp, in gt68xx_device_lamp_control() argument
574 CHECK_DEV_ACTIVE (dev, "gt68xx_device_lamp_control"); in gt68xx_device_lamp_control()
575 if (dev->model->command_set->lamp_control) in gt68xx_device_lamp_control()
576 return (*dev->model->command_set->lamp_control) (dev, fb_lamp, ta_lamp); in gt68xx_device_lamp_control()
582 gt68xx_device_is_moving (GT68xx_Device * dev, SANE_Bool * moving) in gt68xx_device_is_moving() argument
584 CHECK_DEV_ACTIVE (dev, "gt68xx_device_is_moving"); in gt68xx_device_is_moving()
585 if (dev->model->command_set->is_moving) in gt68xx_device_is_moving()
586 return (*dev->model->command_set->is_moving) (dev, moving); in gt68xx_device_is_moving()
594 gt68xx_device_move_relative (GT68xx_Device * dev, SANE_Int distance)
596 CHECK_DEV_ACTIVE (dev, "gt68xx_device_move_relative");
597 if (dev->model->command_set->move_relative)
598 return (*dev->model->command_set->move_relative) (dev, distance);
605 gt68xx_device_carriage_home (GT68xx_Device * dev) in gt68xx_device_carriage_home() argument
607 CHECK_DEV_ACTIVE (dev, "gt68xx_device_carriage_home"); in gt68xx_device_carriage_home()
608 if (dev->model->command_set->carriage_home) in gt68xx_device_carriage_home()
609 return (*dev->model->command_set->carriage_home) (dev); in gt68xx_device_carriage_home()
615 gt68xx_device_paperfeed (GT68xx_Device * dev) in gt68xx_device_paperfeed() argument
617 CHECK_DEV_ACTIVE (dev, "gt68xx_device_paperfeed"); in gt68xx_device_paperfeed()
618 if (dev->model->command_set->paperfeed) in gt68xx_device_paperfeed()
619 return (*dev->model->command_set->paperfeed) (dev); in gt68xx_device_paperfeed()
625 gt68xx_device_start_scan (GT68xx_Device * dev) in gt68xx_device_start_scan() argument
627 CHECK_DEV_ACTIVE (dev, "gt68xx_device_start_scan"); in gt68xx_device_start_scan()
628 if (dev->model->command_set->start_scan) in gt68xx_device_start_scan()
630 if (!dev->scan_started) in gt68xx_device_start_scan()
632 dev->scan_started = SANE_TRUE; in gt68xx_device_start_scan()
633 return (*dev->model->command_set->start_scan) (dev); in gt68xx_device_start_scan()
642 gt68xx_device_read_scanned_data (GT68xx_Device * dev, SANE_Bool * ready) in gt68xx_device_read_scanned_data() argument
644 CHECK_DEV_ACTIVE (dev, "gt68xx_device_read_scanned_data"); in gt68xx_device_read_scanned_data()
645 if (dev->model->command_set->read_scanned_data) in gt68xx_device_read_scanned_data()
646 return (*dev->model->command_set->read_scanned_data) (dev, ready); in gt68xx_device_read_scanned_data()
652 gt68xx_device_setup_scan (GT68xx_Device * dev, in gt68xx_device_setup_scan() argument
657 CHECK_DEV_ACTIVE (dev, "gt68xx_device_setup_scan"); in gt68xx_device_setup_scan()
658 if (dev->model->command_set->setup_scan) in gt68xx_device_setup_scan()
659 return (*dev->model->command_set->setup_scan) (dev, request, action, in gt68xx_device_setup_scan()
666 gt68xx_device_set_afe (GT68xx_Device * dev, GT68xx_AFE_Parameters * params) in gt68xx_device_set_afe() argument
668 CHECK_DEV_ACTIVE (dev, "gt68xx_device_set_afe"); in gt68xx_device_set_afe()
669 if (dev->model->command_set->set_afe) in gt68xx_device_set_afe()
670 return (*dev->model->command_set->set_afe) (dev, params); in gt68xx_device_set_afe()
676 gt68xx_device_set_exposure_time (GT68xx_Device * dev, in gt68xx_device_set_exposure_time() argument
679 CHECK_DEV_ACTIVE (dev, "gt68xx_device_set_exposure_time"); in gt68xx_device_set_exposure_time()
680 if (dev->model->command_set->set_exposure_time) in gt68xx_device_set_exposure_time()
681 return (*dev->model->command_set->set_exposure_time) (dev, params); in gt68xx_device_set_exposure_time()
687 gt68xx_device_stop_scan (GT68xx_Device * dev) in gt68xx_device_stop_scan() argument
689 CHECK_DEV_ACTIVE (dev, "gt68xx_device_stop_scan"); in gt68xx_device_stop_scan()
690 if (dev->model->command_set->stop_scan) in gt68xx_device_stop_scan()
692 if (dev->scan_started) in gt68xx_device_stop_scan()
694 dev->scan_started = SANE_FALSE; in gt68xx_device_stop_scan()
695 return (*dev->model->command_set->stop_scan) (dev); in gt68xx_device_stop_scan()
704 gt68xx_device_read_raw (GT68xx_Device * dev, SANE_Byte * buffer, in gt68xx_device_read_raw() argument
708 CHECK_DEV_ACTIVE (dev, "gt68xx_device_read_raw"); in gt68xx_device_read_raw()
710 status = sanei_usb_read_bulk (dev->fd, buffer, size); in gt68xx_device_read_raw()
722 gt68xx_device_set_read_buffer_size (GT68xx_Device * dev, size_t buffer_size) in gt68xx_device_set_read_buffer_size() argument
724 CHECK_DEV_NOT_NULL (dev, "gt68xx_device_set_read_buffer_size"); in gt68xx_device_set_read_buffer_size()
725 if (dev->read_active) in gt68xx_device_set_read_buffer_size()
735 dev->requested_buffer_size = buffer_size; in gt68xx_device_set_read_buffer_size()
744 gt68xx_device_read_prepare (GT68xx_Device * dev, in gt68xx_device_read_prepare() argument
748 CHECK_DEV_ACTIVE (dev, "gt68xx_device_read_prepare"); in gt68xx_device_read_prepare()
749 if (dev->read_active) in gt68xx_device_read_prepare()
756 buffer_size = dev->requested_buffer_size; in gt68xx_device_read_prepare()
765 dev->read_buffer_size = buffer_size; in gt68xx_device_read_prepare()
766 dev->read_buffer = (SANE_Byte *) malloc (buffer_size); in gt68xx_device_read_prepare()
767 if (!dev->read_buffer) in gt68xx_device_read_prepare()
775 dev->read_active = SANE_TRUE; in gt68xx_device_read_prepare()
776 dev->final_scan = final_scan; in gt68xx_device_read_prepare()
777 dev->read_pos = dev->read_bytes_in_buffer = 0; in gt68xx_device_read_prepare()
778 dev->read_bytes_left = expected_count; in gt68xx_device_read_prepare()
785 gt68xx_reader_process (GT68xx_Device * dev) in gt68xx_reader_process() argument
792 size_t read_bytes_left = dev->read_bytes_left; in gt68xx_reader_process()
793 shm_channel_writer_init (dev->shm_channel); in gt68xx_reader_process()
796 status = shm_channel_writer_get_buffer (dev->shm_channel, in gt68xx_reader_process()
801 size = dev->read_buffer_size; in gt68xx_reader_process()
805 status = gt68xx_device_read_raw (dev, buffer_addr, &size); in gt68xx_reader_process()
812 shm_channel_writer_put_buffer (dev->shm_channel, buffer_id, size); in gt68xx_reader_process()
823 shm_channel_writer_close (dev->shm_channel); in gt68xx_reader_process()
828 gt68xx_device_read_start_fork (GT68xx_Device * dev) in gt68xx_device_read_start_fork() argument
832 if (dev->shm_channel) in gt68xx_device_read_start_fork()
840 shm_channel_new (dev->read_buffer_size, SHM_BUFFERS, &dev->shm_channel); in gt68xx_device_read_start_fork()
846 dev->shm_channel = NULL; in gt68xx_device_read_start_fork()
855 shm_channel_free (dev->shm_channel); in gt68xx_device_read_start_fork()
856 dev->shm_channel = NULL; in gt68xx_device_read_start_fork()
863 status = gt68xx_reader_process (dev); in gt68xx_device_read_start_fork()
869 dev->reader_pid = pid; in gt68xx_device_read_start_fork()
870 shm_channel_reader_init (dev->shm_channel); in gt68xx_device_read_start_fork()
871 shm_channel_reader_start (dev->shm_channel); in gt68xx_device_read_start_fork()
880 gt68xx_device_read_start (GT68xx_Device * dev) in gt68xx_device_read_start() argument
882 CHECK_DEV_ACTIVE (dev, "gt68xx_device_read_start"); in gt68xx_device_read_start()
885 if (dev->final_scan) in gt68xx_device_read_start()
886 return gt68xx_device_read_start_fork (dev); in gt68xx_device_read_start()
892 gt68xx_device_read (GT68xx_Device * dev, SANE_Byte * buffer, size_t * size) in gt68xx_device_read() argument
903 CHECK_DEV_ACTIVE (dev, "gt68xx_device_read"); in gt68xx_device_read()
904 if (!dev->read_active) in gt68xx_device_read()
912 if (dev->read_bytes_in_buffer == 0) in gt68xx_device_read()
914 block_size = dev->read_buffer_size; in gt68xx_device_read()
915 if (block_size > dev->read_bytes_left) in gt68xx_device_read()
916 block_size = dev->read_bytes_left; in gt68xx_device_read()
923 if (dev->shm_channel) in gt68xx_device_read()
925 status = shm_channel_reader_get_buffer (dev->shm_channel, in gt68xx_device_read()
932 memcpy (dev->read_buffer, buffer_addr, buffer_bytes); in gt68xx_device_read()
933 shm_channel_reader_put_buffer (dev->shm_channel, buffer_id); in gt68xx_device_read()
939 status = gt68xx_device_read_raw (dev, dev->read_buffer, in gt68xx_device_read()
946 dev->read_pos = 0; in gt68xx_device_read()
947 dev->read_bytes_in_buffer = block_size; in gt68xx_device_read()
948 dev->read_bytes_left -= block_size; in gt68xx_device_read()
952 if (transfer_size > dev->read_bytes_in_buffer) in gt68xx_device_read()
953 transfer_size = dev->read_bytes_in_buffer; in gt68xx_device_read()
956 memcpy (buffer, dev->read_buffer + dev->read_pos, transfer_size); in gt68xx_device_read()
957 dev->read_pos += transfer_size; in gt68xx_device_read()
958 dev->read_bytes_in_buffer -= transfer_size; in gt68xx_device_read()
973 gt68xx_device_read_finish (GT68xx_Device * dev) in gt68xx_device_read_finish() argument
976 CHECK_DEV_ACTIVE (dev, "gt68xx_device_read_finish"); in gt68xx_device_read_finish()
977 if (!dev->read_active) in gt68xx_device_read_finish()
984 (long) dev->read_bytes_left); in gt68xx_device_read_finish()
986 if (dev->reader_pid != 0) in gt68xx_device_read_finish()
991 kill (dev->reader_pid, SIGKILL); in gt68xx_device_read_finish()
992 waitpid (dev->reader_pid, &pid_status, 0); in gt68xx_device_read_finish()
996 dev->reader_pid = 0; in gt68xx_device_read_finish()
998 if (dev->shm_channel) in gt68xx_device_read_finish()
1000 shm_channel_free (dev->shm_channel); in gt68xx_device_read_finish()
1001 dev->shm_channel = NULL; in gt68xx_device_read_finish()
1006 free (dev->read_buffer); in gt68xx_device_read_finish()
1007 dev->read_buffer = NULL; in gt68xx_device_read_finish()
1008 dev->read_active = SANE_FALSE; in gt68xx_device_read_finish()
1031 gt68xx_device_get_id (GT68xx_Device * dev) in gt68xx_device_get_id() argument
1033 CHECK_DEV_ACTIVE (dev, "gt68xx_device_get_id"); in gt68xx_device_get_id()
1034 if (dev->model->command_set->get_id) in gt68xx_device_get_id()
1035 return (*dev->model->command_set->get_id) (dev); in gt68xx_device_get_id()
1041 gt68xx_device_fix_descriptor (GT68xx_Device * dev) in gt68xx_device_fix_descriptor() argument
1044 sanei_usb_control_msg (dev->fd, 0x80, 0x06, 0x01 << 8, 0, 8, data); in gt68xx_device_fix_descriptor()