Lines Matching refs:fd

104 gl640WriteControl (int fd, GL640_Request req, byte * data, unsigned int size)
107 status = sanei_usb_control_msg (fd,
123 gl640ReadControl (int fd, GL640_Request req, byte * data, unsigned int size)
126 status = sanei_usb_control_msg (fd,
142 gl640WriteReq (int fd, GL640_Request req, byte data)
144 return gl640WriteControl (fd, req, &data, 1);
148 gl640ReadReq (int fd, GL640_Request req, byte * data)
150 return gl640ReadControl (fd, req, data, 1);
161 gl640WriteBulk (int fd, byte * setup, byte * data, size_t size)
168 CHK (gl640WriteControl (fd, GL640_BULK_SETUP, setup, 8));
170 status = sanei_usb_write_bulk (fd, data, &size);
184 gl640ReadBulk (int fd, byte * setup, byte * data, size_t size)
191 CHK (gl640WriteControl (fd, GL640_BULK_SETUP, setup, 8));
193 status = sanei_usb_read_bulk (fd, data, &size);
208 write_byte (int fd, byte addr, byte val)
211 DBG (14, "write_byte(fd, 0x%02x, 0x%02x);\n", addr, val);
212 CHK (gl640WriteReq (fd, GL640_EPP_ADDR, addr));
213 CHK (gl640WriteReq (fd, GL640_EPP_DATA_WRITE, val));
220 read_byte (int fd, byte addr, byte * val)
223 CHK (gl640WriteReq (fd, GL640_EPP_ADDR, addr));
224 CHK (gl640ReadReq (fd, GL640_EPP_DATA_READ, val));
225 DBG (14, "read_byte(fd, 0x%02x, &result); /* got %02x */\n", addr, *val);
234 write_bulk (int fd, unsigned int addr, void *src, size_t count)
238 DBG (13, "write_bulk(fd, 0x%02x, buf, 0x%04lx);\n", addr, (u_long) count);
247 CHK (gl640WriteReq (fd, GL640_EPP_ADDR, addr));
249 CHK (gl640WriteBulk (fd, bulk_setup_data, src, count));
256 read_bulk (int fd, unsigned int addr, void *dst, size_t count)
260 DBG (13, "read_bulk(fd, 0x%02x, buf, 0x%04lx);\n", addr, (u_long) count);
269 CHK (gl640WriteReq (fd, GL640_EPP_ADDR, addr));
271 CHK (gl640ReadBulk (fd, bulk_setup_data, dst, count));
283 write_word (int fd, unsigned int addr, unsigned int data)
287 CHK (write_byte (fd, addr, (data >> 8) & 0xff));
289 CHK (write_byte (fd, addr + 1, data & 0xff));
296 write_many (int fd, unsigned int addr, const byte *src, size_t count)
305 status = write_byte (fd, addr + i, src[i]);
319 read_many (int fd, unsigned int addr, void *dst, size_t count)
328 status = read_byte (fd, addr + i, &val);
345 read_poll_flag (int fd,
355 status = read_byte (fd, addr, &result);
373 read_poll_min (int fd, unsigned int addr, unsigned int min)
382 status = read_byte (fd, addr, &result);
401 read_bulk_size (int fd, int ks, int remainder, byte * dest, int destsize)
430 read_bulk (fd, 0x00, buf, bytes);
449 int fd; /* scanner fd */
498 init (int fd)
502 if (gl640WriteReq (fd, GL640_GPIO_OE, 0x71) != SANE_STATUS_GOOD) {
507 if (gl640ReadReq (fd, GL640_GPIO_READ, &rv) != SANE_STATUS_GOOD) {
511 gl640WriteReq (fd, GL640_GPIO_OE, 0x70);
516 gl640WriteReq (fd, GL640_GPIO_WRITE, 0x00);
517 gl640WriteReq (fd, GL640_GPIO_WRITE, 0x40);
520 gl640WriteReq (fd, GL640_SPP_DATA, 0x99);
521 gl640WriteReq (fd, GL640_SPP_DATA, 0x66);
522 gl640WriteReq (fd, GL640_SPP_DATA, 0xcc);
523 gl640WriteReq (fd, GL640_SPP_DATA, 0x33);
525 write_byte (fd, PARALLEL_PORT, 0x06);
527 write_byte (fd, 0x0b, 0x0d);
528 write_byte (fd, 0x0c, 0x4c);
529 write_byte (fd, 0x0d, 0x2f);
530 read_byte (fd, 0x0b, &result); /* wants 0d */
531 read_byte (fd, 0x0c, &result); /* wants 4c */
532 read_byte (fd, 0x0d, &result); /* wants 2f */
534 write_byte (fd, 0x70, 0x73);
544 lights_out (int fd)
546 write_word (fd, LAMP_R_ON, 0x3fff);
547 write_word (fd, LAMP_R_OFF, 0x0001);
548 write_word (fd, LAMP_G_ON, 0x3fff);
549 write_word (fd, LAMP_G_OFF, 0x0001);
550 write_word (fd, LAMP_B_ON, 0x3fff);
551 write_word (fd, LAMP_B_OFF, 0x0001);
593 write_byte (s->fd, COMMAND, 0x08);
595 write_byte (s->fd, COMMAND, 0x00);
597 write_byte (s->fd, COMMAND, 0x03);
602 datasize = read_poll_min (s->fd, IMAGE_DATA_AVAIL, 2);
610 numbytes = read_bulk_size (s->fd, datasize, 0, ptr, BUFSIZE - level);
704 write_byte (s->fd, COMMAND, 0x00);
711 wait_for_return (int fd)
713 return read_poll_flag (fd, STATUS, STATUS_HOME, STATUS_HOME);
732 int fd = s->fd;
737 read_byte (fd, 0x69, &result); /* wants 02 */
740 write_byte (fd, PARALLEL_PORT, 0x06);
742 write_many (fd, 0x08, seq002, sizeof (seq002));
744 write_many (fd, 0x29, seq003, sizeof (seq003));
747 read_many (fd, 0x08, buf, sizeof (seq002));
751 read_many (fd, 0x29, buf, sizeof (seq003));
756 write_byte (fd, 0x70, 0x73);
758 lights_out (fd);
761 read_byte (fd, STATUS, &result); /* wants 2f or 2d */
763 write_byte (fd, COMMAND, 0x02);
765 wait_for_return (fd);
768 write_byte (fd, COMMAND, 0x01);
770 read_byte (fd, STATUS, &result); /* wants 0c or 2c */
771 read_byte (fd, STATUS, &result); /* wants 0c */
773 write_byte (fd, COMMAND, 0x02);
780 write_byte (fd, DATAPORT_TARGET, DP_R | DP_GAMMA);
781 write_word (fd, DATAPORT_ADDR, DP_WRITE);
782 write_bulk (fd, DATAPORT, buf, 0x0400);
784 write_byte (fd, DATAPORT_TARGET, DP_G | DP_GAMMA);
785 write_word (fd, DATAPORT_ADDR, DP_WRITE);
786 write_bulk (fd, DATAPORT, buf, 0x0400);
788 write_byte (fd, DATAPORT_TARGET, DP_B | DP_GAMMA);
789 write_word (fd, DATAPORT_ADDR, DP_WRITE);
790 write_bulk (fd, DATAPORT, buf, 0x0400);
794 write_byte (fd, DATAPORT_TARGET, DP_R | DP_GAMMA);
795 write_word (fd, DATAPORT_ADDR, DP_READ);
796 read_bulk (fd, DATAPORT, buf, 0x0400);
798 write_byte (fd, DATAPORT_TARGET, DP_G | DP_GAMMA);
799 write_word (fd, DATAPORT_ADDR, DP_READ);
800 read_bulk (fd, DATAPORT, buf, 0x0400);
802 write_byte (fd, DATAPORT_TARGET, DP_B | DP_GAMMA);
803 write_word (fd, DATAPORT_ADDR, DP_READ);
804 read_bulk (fd, DATAPORT, buf, 0x0400);
808 read_byte (fd, STATUS, &result); /* wants 0e */
810 write_byte (fd, COMMAND, 0x01);
811 read_byte (fd, STATUS, &result); /* wants 0c */
813 read_byte (fd, CLOCK_DIV, &result); /* wants 04 */
814 write_byte (fd, CLOCK_DIV, 0x04);
815 read_byte (fd, STEP_SIZE, &result); /* wants 04 */
816 write_byte (fd, STEP_SIZE, 0x3f);
817 read_byte (fd, 0x47, &result); /* wants 1a */
818 write_byte (fd, 0x47, 0xff);
819 read_byte (fd, FAST_STEP, &result); /* wants 01 */
820 write_byte (fd, FAST_STEP, 0x01);
821 read_byte (fd, 0x49, &result); /* wants 04 */
822 write_byte (fd, 0x49, 0x04);
823 read_byte (fd, SKIP_STEPS, &result); /* wants 00 */
824 write_byte (fd, SKIP_STEPS, 0x00);
825 read_byte (fd, 0x4b, &result); /* wants 00 */
826 write_byte (fd, 0x4b, 0xc8);
827 read_byte (fd, BUFFER_LIMIT, &result); /* wants 57 */
828 write_byte (fd, BUFFER_LIMIT, 0x04);
829 read_byte (fd, BUFFER_RESUME, &result); /* wants 02 */
830 write_byte (fd, BUFFER_RESUME, 0x02);
831 read_byte (fd, REVERSE_STEPS, &result); /* wants 00 */
832 write_byte (fd, REVERSE_STEPS, 0x00);
833 write_byte (fd, STEP_PWM, 0x1f);
836 write_byte (fd, COMMAND, 0x08);
837 write_byte (fd, COMMAND, 0x00);
839 write_byte (fd, COMMAND, 0x03);
841 read_poll_min (fd, IMAGE_DATA_AVAIL, 2);
842 write_byte (fd, COMMAND, 0x00);
844 write_byte (fd, STEP_PWM, 0x3f);
845 write_byte (fd, CLOCK_DIV, 0x04);
847 write_word (fd, STEP_SIZE, 0x041a);
848 write_word (fd, FAST_STEP, 0x0104);
851 write_word (fd, SKIP_STEPS, 0x0000);
852 write_byte (fd, BUFFER_LIMIT, 0x57);
853 write_byte (fd, BUFFER_RESUME, 0x02);
854 write_byte (fd, REVERSE_STEPS, 0x00);
855 write_byte (fd, BUFFER_LIMIT, 0x09);
856 write_byte (fd, STEP_PWM, 0x1f);
857 read_byte (fd, MICROSTEP, &result); /* wants 13, active */
858 write_byte (fd, MICROSTEP, 0x03 /* tristate */ );
862 write_word (fd, LAMP_R_ON, 0x0017);
863 write_word (fd, LAMP_R_OFF, 0x0100);
864 write_word (fd, LAMP_G_ON, 0x0017);
865 write_word (fd, LAMP_G_OFF, 0x0100);
866 write_word (fd, LAMP_B_ON, 0x0017);
867 write_word (fd, LAMP_B_OFF, 0x0100);
883 write_word (fd, LAMP_R_ON, 0x0017);
884 write_word (fd, LAMP_R_OFF, 0x0200);
885 write_word (fd, LAMP_G_ON, 0x0017);
886 write_word (fd, LAMP_G_OFF, 0x01d7 /* also 01db */ );
887 write_word (fd, LAMP_B_ON, 0x0017);
888 write_word (fd, LAMP_B_OFF, 0x01af /* also 01b2 */ );
894 write_word (fd, LAMP_R_ON, 0x0017);
895 write_word (fd, LAMP_R_OFF, 0x0e8e /* also 1040 */ );
896 write_word (fd, LAMP_G_ON, 0x0017);
897 write_word (fd, LAMP_G_OFF, 0x0753 /* also 0718 */ );
898 write_word (fd, LAMP_B_ON, 0x0017);
899 write_word (fd, LAMP_B_OFF, 0x03f8 /* also 040d */ );
909 write_byte (fd, MICROSTEP, 0x13 /* pins active */ );
910 write_byte (fd, STEP_PWM, 0x3f);
911 read_byte (fd, STATUS, &result); /* wants 0c */
914 write_byte (fd, COMMAND, 0x02);
916 write_word (fd, STEP_SIZE, 0x041a /* 300 dpi */ );
918 write_word (fd, SKIP_STEPS, 0x0000);
920 write_byte (fd, BUFFER_LIMIT, 0x57);
922 write_byte (fd, BUFFER_RESUME, 0x02);
924 wait_for_return (fd);
926 write_byte (fd, COMMAND, 0x01);
927 read_byte (fd, STATUS, &result); /* wants 0c */
929 write_byte (fd, STEP_PWM, 0x1f);
941 /* FIXME: we should be using fd, not discarding it, and also checking for error! */
942 int fd = mkstemp (s->fname);
943 close(fd);
952 write_byte (fd, STEP_PWM, 0x3f);
954 write_byte (fd, COMMAND, 0x02);
957 read_byte (fd, IMAGE_DATA_AVAIL, &result); /* wants 42,4c */
960 read_bulk_size (fd, result, 0, 0, 0);
963 read_byte (fd, 0x69, &result); /* wants 02 */
964 write_byte (fd, 0x69, 0x0a);
966 lights_out (fd);
967 init (fd);
971 gl640ReadReq (fd, GL640_GPIO_READ, &result); /* wants 00 */
1192 install_ogn (int fd)
1220 write_byte (fd, DATAPORT_TARGET, DP_R | DP_OFFSET);
1221 write_word (fd, DATAPORT_ADDR, DP_WRITE);
1222 write_bulk (fd, DATAPORT, buf, 10208);
1225 write_byte (fd, DATAPORT_TARGET, DP_G | DP_OFFSET);
1226 write_word (fd, DATAPORT_ADDR, DP_WRITE);
1227 write_bulk (fd, DATAPORT, buf, 10208);
1233 write_byte (fd, DATAPORT_TARGET, DP_B | DP_OFFSET);
1234 write_word (fd, DATAPORT_ADDR, DP_WRITE);
1235 write_bulk (fd, DATAPORT, buf, 10208);
1252 int fd = opt->fd;
1257 read_byte (fd, STATUS, &result); /* wants 2f or 2d */
1261 write_byte(fd, COMMAND, 0x02);
1262 wait_for_return(fd);
1266 read_byte (fd, 0x69, &result); /* wants 0a */
1268 read_byte (fd, STATUS, &result); /* wants 0e */
1269 read_byte (fd, PAPER_SENSOR, &result); /* wants 2b */
1270 write_byte (fd, PAPER_SENSOR, 0x2b);
1274 write_byte (fd, COLOR_MODE, 0x15);
1277 install_ogn (fd);
1279 read_byte (fd, STATUS, &result); /* wants 0e */
1281 write_byte (fd, COMMAND, 0x01);
1282 read_byte (fd, STATUS, &result); /* wants 0c */
1292 write_byte (fd, DATAPORT_TARGET, DP_R | DP_GAMMA);
1293 write_word (fd, DATAPORT_ADDR, DP_WRITE);
1294 write_bulk (fd, DATAPORT, buf, 0x0400);
1295 write_byte (fd, DATAPORT_TARGET, DP_R | DP_GAMMA);
1296 write_word (fd, DATAPORT_ADDR, DP_READ);
1297 read_bulk (fd, DATAPORT, buf, 0x0400);
1299 write_byte (fd, DATAPORT_TARGET, DP_G | DP_GAMMA);
1300 write_word (fd, DATAPORT_ADDR, DP_WRITE);
1301 write_bulk (fd, DATAPORT, buf, 0x0400);
1302 write_byte (fd, DATAPORT_TARGET, DP_G | DP_GAMMA);
1303 write_word (fd, DATAPORT_ADDR, DP_READ);
1304 read_bulk (fd, DATAPORT, buf, 0x0400);
1306 write_byte (fd, DATAPORT_TARGET, DP_B | DP_GAMMA);
1307 write_word (fd, DATAPORT_ADDR, DP_WRITE);
1308 write_bulk (fd, DATAPORT, buf, 0x0400);
1309 write_byte (fd, DATAPORT_TARGET, DP_B | DP_GAMMA);
1310 write_word (fd, DATAPORT_ADDR, DP_READ);
1311 read_bulk (fd, DATAPORT, buf, 0x0400);
1314 write_byte (fd, CLOCK_DIV, 0x04);
1319 write_byte (fd, 0x09, 0x1c);
1322 write_byte (fd, 0x09, 0x1a);
1327 write_byte (fd, 0x09, 0x18);
1330 write_byte (fd, 0x09, 0x1e);
1334 write_word (fd, ACTIVE_PX_START, left_edge);
1337 write_word (fd, DATA_PX_START, left_edge + opt->x1);
1340 write_word (fd, DATA_PX_END, left_edge + opt->x2);
1342 write_byte (fd, COLOR_MODE, 0x15);
1343 write_byte (fd, 0x29, 0x02);
1345 write_word (fd, LAMP_R_ON, 0x0017);
1347 write_word (fd, LAMP_R_OFF, 0x1437);
1348 write_word (fd, LAMP_G_ON, 0x0017);
1349 write_word (fd, LAMP_G_OFF, 0x094e);
1350 write_word (fd, LAMP_B_ON, 0x0017);
1351 write_word (fd, LAMP_B_OFF, 0x0543);
1354 write_byte (fd, 0x38, 0x3f);
1355 write_byte (fd, 0x39, 0x3f);
1356 write_byte (fd, 0x3a, 0x3f);
1358 write_byte (fd, 0x3b, opt->gain);
1359 write_byte (fd, 0x3c, opt->gain);
1360 write_byte (fd, 0x3d, opt->gain);
1362 write_byte (fd, 0x3e, 0x1a);
1398 write_word (fd, STEP_SIZE, stepsize);
1399 write_word (fd, FAST_STEP, faststep);
1404 write_word (fd, SKIP_STEPS, 0x017a /* cal strip */ + opt->y1 * 2);
1406 write_byte (fd, BUFFER_LIMIT, 0x20);
1407 write_byte (fd, BUFFER_RESUME, 0x02);
1408 write_byte (fd, REVERSE_STEPS, reverse);
1410 write_word (fd, 0x52, phase);
1411 write_byte (fd, STEP_PWM, pwm);
1414 read_byte (fd, PAPER_SENSOR, &result); /* wants 2b */
1415 write_byte (fd, PAPER_SENSOR, 0x0b);
1424 read_byte (fd, PAPER_SENSOR, &result); /* wants 0b */
1425 write_byte (fd, PAPER_SENSOR, 0x2b);
1426 write_byte (fd, STEP_PWM, 0x3f);
1428 lights_out (fd);
1430 write_byte (fd, COMMAND, 0x02);
1496 sanei_usb_close (scan->fd);
1514 res = sanei_usb_open (dev, &scan->fd);
1524 if (sanei_usb_get_vendor_product (scan->fd, &vendor, &product) !=
1529 sanei_usb_close (scan->fd);
1530 scan->fd = -1;
1539 sanei_usb_close (scan->fd);
1540 scan->fd = -1;
1588 /* FIXME: we should be using fd, not discarding it! */
1589 int fd = mkstemp (scanner->fname);
1590 if (fd == -1)
1592 close(fd);
1595 rv = init (scanner->fd);
1604 wait_for_return (scanner->fd);