~ubuntu-branches/ubuntu/vivid/sane-backends/vivid

« back to all changes in this revision

Viewing changes to backend/xerox_mfp-usb.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien BLACHE
  • Date: 2011-02-16 19:00:55 UTC
  • mfrom: (1.2.2 upstream) (21.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110216190055-wz0c33eracchkxts
Tags: 1.0.22-1
* New upstream release.
  + epson2: reject scan area settings that would lead to a division by zero
    (closes: #581181).

* debian/control:
  + Bump Standards-Version to 3.9.1 (no changes).
  + Demote libsane-extras-* to Recommends again.
* debian/rules:
  + Add acl (>= 2.2.49-4) to udev substvar for ACL utilities in /bin.
  + Use sane-desc -m udev+acl (closes: #591767, #612815).
* debian/libsane.README.Debian:
  + Update; mention ConsoleKit and the udev rules now using ACLs.

* debian/patches/sane-desc_udev+acl.patch:
  + Added; compared to experimental, setfacl is now in /bin.
* debian/patches/fix_xerox_mfp_color_mode.patch,
  debian/patches/use_libsane_matched_for_scsi.patch,
  debian/patches/allow_dll.d_symlinks.patch,
  debian/patches/saned_exit_avahi_process.patch,
  debian/patches/xerox_mfp_new_ids.patch,
  debian/patches/scsi_perfection_2450.patch,
  debian/patches/scsi_scanjet_4c.patch,
  debian/patches/genesys_disable_raw_data_log.patch,
  debian/patches/fix_epson2_commands.patch,
  debian/patches/fix_epson2_cancel.patch:
  + Removed; merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * SANE backend for Xerox Phaser 3200MFP
 
3
 * Copyright 2008 ABC <abc@telekom.ru>
 
4
 *
 
5
 * This program is licensed under GPL + SANE exception.
 
6
 * More info at http://www.sane-project.org/license.html
 
7
 */
 
8
 
 
9
#undef  BACKEND_NAME
 
10
#define BACKEND_NAME xerox_mfp
 
11
#define DEBUG_DECLARE_ONLY
 
12
#define DEBUG_NOT_STATIC
 
13
#include "sane/config.h"
 
14
#include "sane/saneopts.h"
 
15
#include "sane/sanei_config.h"
 
16
#include "sane/sanei_backend.h"
 
17
#include "sane/sanei_debug.h"
 
18
#include "sane/sanei_usb.h"
 
19
#include "xerox_mfp.h"
 
20
 
 
21
 
 
22
extern int sanei_debug_xerox_mfp;
 
23
 
 
24
int
 
25
usb_dev_request (struct device *dev,
 
26
             SANE_Byte *cmd, size_t cmdlen,
 
27
             SANE_Byte *resp, size_t *resplen)
 
28
{
 
29
  SANE_Status status;
 
30
  size_t len = cmdlen;
 
31
 
 
32
  if (cmd && cmdlen) {
 
33
    status = sanei_usb_write_bulk (dev->dn, cmd, &cmdlen);
 
34
    if (status != SANE_STATUS_GOOD) {
 
35
      DBG (1, "%s: sanei_usb_write_bulk: %s\n", __FUNCTION__,
 
36
           sane_strstatus (status));
 
37
      return SANE_STATUS_IO_ERROR;
 
38
    }
 
39
 
 
40
    if (cmdlen != len) {
 
41
      DBG (1, "%s: sanei_usb_write_bulk: wanted %lu bytes, wrote %lu bytes\n",
 
42
           __FUNCTION__, (size_t)len, (size_t)cmdlen);
 
43
      return SANE_STATUS_IO_ERROR;
 
44
    }
 
45
  }
 
46
 
 
47
  if (resp && resplen) {
 
48
    status = sanei_usb_read_bulk (dev->dn, resp, resplen);
 
49
    if (status != SANE_STATUS_GOOD) {
 
50
      DBG (1, "%s: sanei_usb_read_bulk: %s\n", __FUNCTION__,
 
51
           sane_strstatus (status));
 
52
      return SANE_STATUS_IO_ERROR;
 
53
    }
 
54
  }
 
55
 
 
56
  return SANE_STATUS_GOOD;
 
57
}
 
58
 
 
59
 
 
60
SANE_Status
 
61
usb_dev_open (struct device *dev)
 
62
{
 
63
  SANE_Status status;
 
64
 
 
65
  DBG (3, "%s: open %p\n", __FUNCTION__, (void *)dev);
 
66
  status = sanei_usb_open (dev->sane.name, &dev->dn);
 
67
  if (status != SANE_STATUS_GOOD) {
 
68
      DBG (1, "%s: sanei_usb_open(%s): %s\n", __FUNCTION__,
 
69
           dev->sane.name, sane_strstatus (status));
 
70
      dev->dn = -1;
 
71
      return status;
 
72
    }
 
73
  sanei_usb_clear_halt (dev->dn);
 
74
  return SANE_STATUS_GOOD;
 
75
}
 
76
 
 
77
void
 
78
usb_dev_close (struct device *dev)
 
79
{
 
80
  if (!dev)
 
81
    return;
 
82
  DBG (3, "%s: closing dev %p\n", __FUNCTION__, (void *)dev);
 
83
 
 
84
  /* finish all operations */
 
85
  if (dev->scanning) {
 
86
    dev->cancel = 1;
 
87
    /* flush READ_IMAGE data */
 
88
    if (dev->reading)
 
89
      sane_read(dev, NULL, 1, NULL);
 
90
    /* send cancel if not sent before */
 
91
    if (dev->state != SANE_STATUS_CANCELLED)
 
92
      ret_cancel(dev, 0);
 
93
  }
 
94
 
 
95
  sanei_usb_clear_halt (dev->dn);       /* unstall for next users */
 
96
  sanei_usb_close (dev->dn);
 
97
  dev->dn = -1;
 
98
}
 
99
 
 
100
 
 
101
/* SANE API ignores return code of this callback */
 
102
SANE_Status
 
103
usb_configure_device (const char *devname, SANE_Status (*attach) (const char *dev))
 
104
{
 
105
  sanei_usb_set_timeout (1000);
 
106
  sanei_usb_attach_matching_devices (devname, attach);
 
107
  sanei_usb_set_timeout (30000);
 
108
  return SANE_STATUS_GOOD;
 
109
}
 
110
 
 
111
 
 
112
/* xerox_mfp-usb.c */