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);
1011
DBG (1, "sane_start: ioctl VIDIOCMCAPTURE failed: %s\n",
1013
return SANE_STATUS_INVAL;
1015
DBG (3, "sane_start: waiting for frame %x\n", s->mmap.frame);
1016
len = v4l1_ioctl (s->fd, VIDIOCSYNC, &(s->mmap.frame));
1019
DBG (1, "sane_start: call to ioctl(%d, VIDIOCSYNC, ..) failed\n",
1021
return SANE_STATUS_INVAL;
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++)
1014
len = v4l1_ioctl (s->fd, VIDIOCMCAPTURE, &s->mmap);
1017
DBG (1, "sane_start: ioctl VIDIOCMCAPTURE failed: %s\n",
1019
return SANE_STATUS_INVAL;
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));
1025
DBG (1, "sane_start: call to ioctl(%d, VIDIOCSYNC, ..) failed\n",
1027
return SANE_STATUS_INVAL;
1023
1030
DBG (3, "sane_start: frame %x done\n", s->mmap.frame);
1033
/* v4l1 actually returns BGR when we ask for RGB, so convert it */
1034
if (s->pict.palette == VIDEO_PALETTE_RGB24)
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)
1039
data = *(buffer + loop);
1040
*(buffer + loop) = *(buffer + loop + 2);
1041
*(buffer + loop + 2) = data;
1025
1045
DBG (3, "sane_start: done\n");
1026
1046
return SANE_STATUS_GOOD;