~ubuntu-branches/ubuntu/saucy/sane-backends/saucy

« back to all changes in this revision

Viewing changes to backend/v4l.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-02-14 14:28:56 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110214142856-6gxjetg88q9zctid
Tags: 1.0.22-0ubuntu1
* New upstream release
* debian/control:
  - Use standards version 3.9.1
* debian/patches/allow_dll.d_symlinks.patch:
* debian/patches/fix_epson2_cancel.patch:
* debian/patches/fix_epson2_commands.patch:
* debian/patches/fix_xerox_mfp_color_mode.patch:
* debian/patches/genesys_disable_raw_data_log.patch:
* debian/patches/no_translations.patch:
* debian/patches/saned_exit_avahi_process.patch:
* debian/patches/scsi_perfection_2450.patch:
* debian/patches/scsi_scanjet_4c.patch:
* debian/patches/xerox_mfp_new_ids.patch:
  - Applied upstream
* debian/watch:
  - Dropped, the URL is not consistent between releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
949
949
SANE_Status
950
950
sane_start (SANE_Handle handle)
951
951
{
952
 
  int len;
 
952
  int len, loop;
953
953
  V4L_Scanner *s;
 
954
  char data;
954
955
 
955
956
  DBG (2, "sane_start\n");
956
957
  for (s = first_handle; s; s = s->next)
1005
1006
      s->mmap.format = s->pict.palette;
1006
1007
      DBG (2, "sane_start: mmapped frame %d x %d with palette %d\n",
1007
1008
           s->mmap.width, s->mmap.height, s->mmap.format);
1008
 
      len = v4l1_ioctl (s->fd, VIDIOCMCAPTURE, &s->mmap);
1009
 
      if (len == -1)
1010
 
        {
1011
 
          DBG (1, "sane_start: ioctl VIDIOCMCAPTURE failed: %s\n",
1012
 
               strerror (errno));
1013
 
          return SANE_STATUS_INVAL;
1014
 
        }
1015
 
      DBG (3, "sane_start: waiting for frame %x\n", s->mmap.frame);
1016
 
      len = v4l1_ioctl (s->fd, VIDIOCSYNC, &(s->mmap.frame));
1017
 
      if (-1 == len)
1018
 
        {
1019
 
          DBG (1, "sane_start: call to ioctl(%d, VIDIOCSYNC, ..) failed\n",
1020
 
               s->fd);
1021
 
          return SANE_STATUS_INVAL;
1022
 
        }
 
1009
 
 
1010
      /* We need to loop here to empty the read buffers, so we don't
 
1011
         get a stale image */
 
1012
      for (loop = 0; loop <= s->mbuf.frames; loop++)
 
1013
        {
 
1014
          len = v4l1_ioctl (s->fd, VIDIOCMCAPTURE, &s->mmap);
 
1015
          if (len == -1)
 
1016
            {
 
1017
              DBG (1, "sane_start: ioctl VIDIOCMCAPTURE failed: %s\n",
 
1018
                   strerror (errno));
 
1019
              return SANE_STATUS_INVAL;
 
1020
            }
 
1021
          DBG (3, "sane_start: waiting for frame %x, loop %d\n", s->mmap.frame, loop);
 
1022
          len = v4l1_ioctl (s->fd, VIDIOCSYNC, &(s->mmap.frame));
 
1023
          if (-1 == len)
 
1024
            {
 
1025
              DBG (1, "sane_start: call to ioctl(%d, VIDIOCSYNC, ..) failed\n",
 
1026
                   s->fd);
 
1027
              return SANE_STATUS_INVAL;
 
1028
            }
 
1029
        }
1023
1030
      DBG (3, "sane_start: frame %x done\n", s->mmap.frame);
1024
1031
    }
 
1032
 
 
1033
  /* v4l1 actually returns BGR when we ask for RGB, so convert it */
 
1034
  if (s->pict.palette == VIDEO_PALETTE_RGB24)
 
1035
    {
 
1036
      DBG (3, "sane_start: converting from BGR to RGB\n");
 
1037
      for (loop = 0; loop < (s->window.width * s->window.height * 3); loop += 3)
 
1038
        {
 
1039
          data = *(buffer + loop);
 
1040
          *(buffer + loop) = *(buffer + loop + 2);
 
1041
          *(buffer + loop + 2) = data;
 
1042
        }
 
1043
    }
 
1044
 
1025
1045
  DBG (3, "sane_start: done\n");
1026
1046
  return SANE_STATUS_GOOD;
1027
1047
}