Lines Matching defs:dev

479       name = strdup("/dev/parport0");
632 build_correction (P5_Device * dev, unsigned int dpi, unsigned int mode,
642 while (dev->calibration_data[j]->dpi != dpi)
652 if (dev->gain != NULL)
654 free (dev->gain);
655 dev->gain = NULL;
657 if (dev->offset != NULL)
659 free (dev->offset);
660 dev->offset = NULL;
662 dev->gain = (float *) malloc (width * sizeof (float));
663 if (dev->gain == NULL)
669 dev->offset = (uint8_t *) malloc (width);
670 if (dev->offset == NULL)
688 if (dev->calibration_data[j]->white_data[shift + i] -
689 dev->calibration_data[0]->black_data[shift + i] > BLACK_LEVEL)
691 dev->gain[i] =
694 (dev->calibration_data[j]->white_data[shift + i] -
695 dev->calibration_data[j]->black_data[shift + i]));
696 dev->offset[i] = dev->calibration_data[j]->black_data[shift + i];
700 dev->gain[i] = 1.0;
701 dev->offset[i] = 0;
710 * @param dev device describing hardware
720 start_scan (P5_Device * dev, int mode, unsigned int dpi, unsigned int startx,
793 write_reg (dev->fd, REG1, 0x01);
794 write_reg (dev->fd, REG7, 0x00);
795 write_reg (dev->fd, REG0, reg0);
796 write_reg (dev->fd, REG1, 0x00);
797 write_reg (dev->fd, REGF, regF);
801 memtest (dev->fd, addr);
820 if (dev->calibrated)
822 build_correction (dev, xdpi, mode, start, width);
825 setadresses (dev->fd, start, end);
827 write_reg (dev->fd, REG1, addr >> 8);
828 write_reg (dev->fd, REG2, reg2);
830 write_reg (dev->fd, REGF, regF);
831 write_reg (dev->fd, REG0, reg0);
834 write_reg (dev->fd, 0x07, 0x04);
838 write_reg (dev->fd, 0x07, 0x00);
840 write_reg (dev->fd, REG1, addr >> 8);
841 write_reg2 (dev->fd, REG1, addr);
842 write_reg (dev->fd, REGF, regF | 0x01);
843 write_reg (dev->fd, REG0, reg0 | 0x0C);
846 write_reg (dev->fd, REG1, 0x19);
850 write_reg (dev->fd, REG1, 0x11);
857 * @param dev device to read
867 read_line (P5_Device * dev, uint8_t * data, size_t length, int ltr,
878 counter = read_reg (dev->fd, REG9);
897 read_data (dev->fd, inbuffer, length / factor + 2);
904 val = inbuffer[i + 1] - dev->offset[i];
907 val = val * dev->gain[i];
951 read_reg (dev->fd, REGF);
952 read_reg (dev->fd, REGA);
953 read_reg (dev->fd, REG9);
954 counter = read_reg (dev->fd, REG9);
955 read_reg (dev->fd, REGA);
961 counter = read_reg (dev->fd, REG9);
964 read_reg (dev->fd, REGF);
965 read_reg (dev->fd, REGA);
966 read_reg (dev->fd, REG9);
967 counter = read_reg (dev->fd, REG9);
968 read_reg (dev->fd, REGA);
1036 * @params dev pointer to the device structure
1039 move (P5_Device * dev)
1048 skip = dev->ystart;
1051 if (dev->ydpi > 300)
1054 DBG (DBG_io, "move: skipping %d lines at %d dpi\n", skip, dev->ydpi);
1058 status = start_scan (dev, MODE_GRAY, dev->ydpi, 0, 256);
1068 status = test_document (dev->fd);
1076 count = available_bytes (dev->fd);
1080 read_line (dev, buffer, 256, 1, SANE_FALSE, SANE_FALSE,
1093 write_reg2 (dev->fd, REG1, 0x1110);
1094 count = read_reg (dev->fd, REGE);
1095 count = read_reg (dev->fd, REGE);
1096 write_reg (dev->fd, REG0, 0x00);
1097 write_reg (dev->fd, REG1, 0x00);
1098 write_reg (dev->fd, REGF, 0x82);
1099 write_reg (dev->fd, REG7, 0x00);
1106 * @param dev device to clean up
1109 cleanup_calibration (P5_Device * dev)
1115 if (dev->calibration_data[i] != NULL)
1117 free (dev->calibration_data[i]);
1118 dev->calibration_data[i] = NULL;
1121 dev->calibrated = SANE_FALSE;
1290 * @param dev device to restore
1294 restore_calibration (P5_Device * dev)
1303 cleanup_calibration (dev);
1304 fname = calibration_file (dev->model->name);
1317 dev->calibration_data[i] = malloc (sizeof (P5_Calibration_Data));
1318 if (dev->calibration_data[i] == NULL)
1320 cleanup_calibration (dev);
1328 fread (dev->calibration_data[i], 1, sizeof (P5_Calibration_Data),
1332 free (dev->calibration_data[i]);
1333 dev->calibration_data[i] = NULL;
1337 cleanup_calibration (dev);
1348 dev->calibrated = SANE_TRUE;
1358 * @param dev device calibration to save
1362 save_calibration (P5_Device * dev)
1371 fname = calibration_file (dev->model->name);
1382 while (dev->calibration_data[i] != NULL && (i < 2 * MAX_RESOLUTIONS))
1385 fwrite (dev->calibration_data[i], sizeof (P5_Calibration_Data), 1,
1412 * @param dev device to calibrate
1415 sheetfed_calibration (P5_Device * dev)
1434 status = test_document (dev->fd);
1443 cleanup_calibration (dev);
1448 dpi = dev->model->max_xdpi;
1450 dev->calibration_data[i] =
1452 if (dev->calibration_data[i] == NULL)
1454 cleanup_calibration (dev);
1459 dev->calibration_data[i]->dpi = dpi;
1462 status = start_scan (dev, MODE_COLOR, dpi, 0, pixels);
1465 cleanup_calibration (dev);
1484 status = test_document (dev->fd);
1487 cleanup_calibration (dev);
1494 read_line (dev, buffer, pixels * 3, 1, SANE_FALSE, SANE_FALSE,
1527 while (test_document (dev->fd) != SANE_STATUS_NO_DOCS);
1534 dev->calibration_data[i]->white_data[j] = white_data[j] / white;
1535 dev->calibration_data[i]->black_data[j] = black_data[j] / black;
1544 red += dev->calibration_data[i]->black_data[j];
1545 green += dev->calibration_data[i]->black_data[j + 1];
1546 blue += dev->calibration_data[i]->black_data[j + 2];
1550 dev->calibration_data[i]->black_data[j] = red / pixels;
1551 dev->calibration_data[i]->black_data[j + 1] = green / pixels;
1552 dev->calibration_data[i]->black_data[j + 2] = blue / pixels;
1559 dev->calibration_data[i]->dpi);
1560 write_rgb_data (title, dev->calibration_data[i]->white_data, pixels, 1);
1562 dev->calibration_data[i]->dpi);
1563 write_rgb_data (title, dev->calibration_data[i]->black_data, pixels, 1);
1567 for (i = 1; i < MAX_RESOLUTIONS && dev->model->xdpi_values[i] > 0; i++)
1569 dev->calibration_data[i] =
1571 if (dev->calibration_data[i] == NULL)
1573 cleanup_calibration (dev);
1578 dev->calibration_data[i]->dpi = dev->model->xdpi_values[i];
1580 coeff = ((float) dev->model->xdpi_values[i]) / (float) dpi;
1586 dev->calibration_data[i]->white_data[j] =
1587 dev->calibration_data[0]->white_data[k];
1588 dev->calibration_data[i]->white_data[j + 1] =
1589 dev->calibration_data[0]->white_data[k + 1];
1590 dev->calibration_data[i]->white_data[j + 2] =
1591 dev->calibration_data[0]->white_data[k + 2];
1592 dev->calibration_data[i]->black_data[j] =
1593 dev->calibration_data[0]->black_data[k];
1594 dev->calibration_data[i]->black_data[j + 1] =
1595 dev->calibration_data[0]->black_data[k + 1];
1596 dev->calibration_data[i]->black_data[j + 2] =
1597 dev->calibration_data[0]->black_data[k + 2];
1602 dev->calibrated = SANE_TRUE;
1605 eject (dev->fd);