Пример #1
0
static int
send_scan_param (pixma_t * s)
{
  mp730_t *mp = (mp730_t *) s->subdriver;
  uint8_t *data;

  data = pixma_newcmd (&mp->cb, cmd_scan_param, 0x2e, 0);
  pixma_set_be16 (s->param->xdpi | 0x1000, data + 0x04);
  pixma_set_be16 (s->param->ydpi | 0x1000, data + 0x06);
  pixma_set_be32 (s->param->x, data + 0x08);
  pixma_set_be32 (s->param->y, data + 0x0c);
  pixma_set_be32 (mp->raw_width, data + 0x10);
  pixma_set_be32 (s->param->h, data + 0x14);

  if (s->param->channels == 1)
    {
      if (s->param->depth == 1)
        data[0x18] = 0x01;
      else
        data[0x18] = 0x04;
    }
  else
    data[0x18] = 0x08;

  data[0x19] = s->param->channels * s->param->depth;  /* bits per pixel, for lineart should be 0x01 */
  data[0x1e] = (s->param->depth == 1) ? 0x80 : 0x00;  /* modify for lineart: 0x80 NEW */
  data[0x1f] = (s->param->depth == 1) ? 0x80 : 0x7f;  /* modify for lineart: 0x80 */
  data[0x20] = (s->param->depth == 1) ? 0x01 : 0xff;  /* modify for lineart: 0x01 */
  data[0x23] = 0x81;

  return pixma_exec (s, &mp->cb);
}
Пример #2
0
static int
send_scan_param (pixma_t * s)
{
  iclass_t *mf = (iclass_t *) s->subdriver;
  uint8_t *data;

  data = pixma_newcmd (&mf->cb, cmd_scan_param, 0x2e, 0);
  pixma_set_be16 (s->param->xdpi | 0x1000, data + 0x04);
  pixma_set_be16 (s->param->ydpi | 0x1000, data + 0x06);
  pixma_set_be32 (s->param->x, data + 0x08);
  pixma_set_be32 (s->param->y, data + 0x0c);
  pixma_set_be32 (mf->raw_width, data + 0x10);
  pixma_set_be32 (s->param->h, data + 0x14);
  data[0x18] = (s->param->channels == 1) ? 0x04 : 0x08;
  data[0x19] = s->param->channels * s->param->depth;	/* bits per pixel */
  data[0x1f] = 0x7f;
  data[0x20] = 0xff;
  data[0x23] = 0x81;
  switch (s->cfg->pid)
    {
    case MF4200_PID:
    case MF4600_PID:
    case MF6500_PID:
    case D480_PID:
    case D420_PID:
    case MF4360_PID:
    case MF4100_PID:
      return iclass_exec (s, &mf->cb, 0);
      break;
    default:
      return pixma_exec (s, &mf->cb);
    }
}
Пример #3
0
static int
request_image_block_ex (pixma_t * s, unsigned *size, uint8_t * info,
			unsigned flag)
{
  mp750_t *mp = (mp750_t *) s->subdriver;
  int error;

  memset (mp->cb.buf, 0, 10);
  pixma_set_be16 (cmd_read_image, mp->cb.buf);
  mp->cb.buf[7] = *size >> 8;
  mp->cb.buf[8] = 4 | flag;
  mp->cb.reslen = pixma_cmd_transaction (s, mp->cb.buf, 10, mp->cb.buf, 6);
  mp->cb.expected_reslen = 0;
  error = pixma_check_result (&mp->cb);
  if (error >= 0)
    {
      if (mp->cb.reslen == 6)
        {
          *info = mp->cb.buf[2];
          *size = pixma_get_be16 (mp->cb.buf + 4);
        }
      else
        {
          error = PIXMA_EPROTO;
        }
    }
  return error;
}
Пример #4
0
static int
request_image_block (pixma_t * s, unsigned flag, uint8_t * info,
		     unsigned * size, uint8_t * data, unsigned * datalen)
{
  iclass_t *mf = (iclass_t *) s->subdriver;
  int error;
  unsigned expected_len;
  const int hlen = 2 + 6;

  memset (mf->cb.buf, 0, 11);
  pixma_set_be16 (((s->cfg->pid == MF3010_PID ||
                    s->cfg->pid == MF4410_PID ||
                    s->cfg->pid == MF4770_PID ||
                    s->cfg->pid == MF4550_PID) ? cmd_read_image2 : cmd_read_image), mf->cb.buf);
  mf->cb.buf[8] = flag;
  mf->cb.buf[10] = 0x06;
  expected_len = (s->cfg->pid == MF3010_PID ||
                  s->cfg->pid == MF4410_PID ||
                  s->cfg->pid == MF4770_PID ||
                  s->cfg->pid == MF4550_PID ||
                  s->cfg->pid == MF4600_PID ||
                  s->cfg->pid == MF6500_PID ||
                  s->cfg->pid == MF8030_PID) ? 512 : hlen;
  mf->cb.reslen = pixma_cmd_transaction (s, mf->cb.buf, 11, mf->cb.buf, expected_len);
  if (mf->cb.reslen >= hlen)
    {
      *info = mf->cb.buf[2];
      *size = pixma_get_be16 (mf->cb.buf + 6);    /* 16bit size */
      error = 0;

      if (s->cfg->pid == MF3010_PID ||
          s->cfg->pid == MF4410_PID ||
          s->cfg->pid == MF4770_PID ||
          s->cfg->pid == MF4550_PID ||
          s->cfg->pid == MF4600_PID ||
          s->cfg->pid == MF6500_PID ||
          s->cfg->pid == MF8030_PID)
        {                                         /* 32bit size */
          *datalen = mf->cb.reslen - hlen;
          *size = (*datalen + hlen == 512) ? pixma_get_be32 (mf->cb.buf + 4) - *datalen : 0;
          memcpy (data, mf->cb.buf + hlen, *datalen);
        }
    }
  else
    {
       error = PIXMA_EPROTO;
    }
  return error;
}
Пример #5
0
static int
send_scan_param (pixma_t * s)
{
  mp750_t *mp = (mp750_t *) s->subdriver;
  uint8_t *data;

  data = pixma_newcmd (&mp->cb, cmd_scan_param, 0x2e, 0);
  pixma_set_be16 (s->param->xdpi | 0x8000, data + 0x04);
  pixma_set_be16 (s->param->ydpi | 0x8000, data + 0x06);
  pixma_set_be32 (s->param->x, data + 0x08);
  pixma_set_be32 (s->param->y, data + 0x0c);
  pixma_set_be32 (mp->raw_width, data + 0x10);
  pixma_set_be32 (mp->raw_height, data + 0x14);
  data[0x18] = 8;		/* 8 = color, 4 = grayscale(?) */
  /* GH: No, there is no grayscale for CCD devices, Windows shows same  */
  data[0x19] = s->param->depth * ((is_ccd_grayscale (s)) ? 3 : s->param->channels);	/* bits per pixel */
  data[0x20] = 0xff;
  data[0x23] = 0x81;
  data[0x26] = 0x02;
  data[0x27] = 0x01;
  data[0x29] = mp->monochrome ? 0 : 1;

  return pixma_exec (s, &mp->cb);
}
Пример #6
0
static void
workaround_first_command (pixma_t * s)
{
  /* FIXME: Send a dummy command because the device doesn't response to the
     first command that is sent directly after the USB interface has been
     set up. Why? USB isn't set up properly? */
  uint8_t cmd[10];
  int error;

  if (s->cfg->pid == MP750_PID)
    return;			/* MP750 doesn't have this problem(?) */

  PDBG (pixma_dbg
	(1,
	 "Work-around for the problem: device doesn't response to the first command.\n"));
  memset (cmd, 0, sizeof (cmd));
  pixma_set_be16 (cmd_calibrate, cmd);
  error = pixma_write (s->io, cmd, 10);
  if (error != 10)
    {
      if (error < 0)
	{
	  PDBG (pixma_dbg
		(1, "  Sending a dummy command failed: %s\n",
		 pixma_strerror (error)));
	}
      else
	{
	  PDBG (pixma_dbg
		(1, "  Sending a dummy command failed: count = %d\n", error));
	}
      return;
    }
  error = pixma_read (s->io, cmd, sizeof (cmd));
  if (error >= 0)
    {
      PDBG (pixma_dbg
	    (1, "  Got %d bytes response from a dummy command.\n", error));
    }
  else
    {
      PDBG (pixma_dbg
	    (1, "  Reading response of a dummy command failed: %s\n",
	     pixma_strerror (error)));
    }
}