| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ucycom.c,v 1.26 2009/07/24 06:50:40 skrll Exp $ */ | | 1 | /* $NetBSD: ucycom.c,v 1.27 2009/07/24 06:54:10 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2005 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2005 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Nick Hudson | | 8 | * by Nick Hudson |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | /* | | 31 | /* |
32 | * This code is based on the ucom driver. | | 32 | * This code is based on the ucom driver. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | /* | | 35 | /* |
36 | * Device driver for Cypress CY7C637xx and CY7C640/1xx series USB to | | 36 | * Device driver for Cypress CY7C637xx and CY7C640/1xx series USB to |
37 | * RS232 bridges. | | 37 | * RS232 bridges. |
38 | */ | | 38 | */ |
39 | | | 39 | |
40 | #include <sys/cdefs.h> | | 40 | #include <sys/cdefs.h> |
41 | __KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1.26 2009/07/24 06:50:40 skrll Exp $"); | | 41 | __KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1.27 2009/07/24 06:54:10 skrll Exp $"); |
42 | | | 42 | |
43 | #include <sys/param.h> | | 43 | #include <sys/param.h> |
44 | #include <sys/systm.h> | | 44 | #include <sys/systm.h> |
45 | #include <sys/conf.h> | | 45 | #include <sys/conf.h> |
46 | #include <sys/kernel.h> | | 46 | #include <sys/kernel.h> |
47 | #include <sys/malloc.h> | | 47 | #include <sys/malloc.h> |
48 | #include <sys/device.h> | | 48 | #include <sys/device.h> |
49 | #include <sys/sysctl.h> | | 49 | #include <sys/sysctl.h> |
50 | #include <sys/tty.h> | | 50 | #include <sys/tty.h> |
51 | #include <sys/file.h> | | 51 | #include <sys/file.h> |
52 | #include <sys/vnode.h> | | 52 | #include <sys/vnode.h> |
53 | #include <sys/kauth.h> | | 53 | #include <sys/kauth.h> |
54 | | | 54 | |
| @@ -342,38 +342,38 @@ ucycomopen(dev_t dev, int flag, int mode | | | @@ -342,38 +342,38 @@ ucycomopen(dev_t dev, int flag, int mode |
342 | /* | | 342 | /* |
343 | * Initialize the termios status to the defaults. Add in the | | 343 | * Initialize the termios status to the defaults. Add in the |
344 | * sticky bits from TIOCSFLAGS. | | 344 | * sticky bits from TIOCSFLAGS. |
345 | */ | | 345 | */ |
346 | t.c_ispeed = 0; | | 346 | t.c_ispeed = 0; |
347 | t.c_ospeed = TTYDEF_SPEED; | | 347 | t.c_ospeed = TTYDEF_SPEED; |
348 | t.c_cflag = TTYDEF_CFLAG; | | 348 | t.c_cflag = TTYDEF_CFLAG; |
349 | if (ISSET(sc->sc_swflags, TIOCFLAG_CLOCAL)) | | 349 | if (ISSET(sc->sc_swflags, TIOCFLAG_CLOCAL)) |
350 | SET(t.c_cflag, CLOCAL); | | 350 | SET(t.c_cflag, CLOCAL); |
351 | if (ISSET(sc->sc_swflags, TIOCFLAG_CRTSCTS)) | | 351 | if (ISSET(sc->sc_swflags, TIOCFLAG_CRTSCTS)) |
352 | SET(t.c_cflag, CRTSCTS); | | 352 | SET(t.c_cflag, CRTSCTS); |
353 | if (ISSET(sc->sc_swflags, TIOCFLAG_MDMBUF)) | | 353 | if (ISSET(sc->sc_swflags, TIOCFLAG_MDMBUF)) |
354 | SET(t.c_cflag, MDMBUF); | | 354 | SET(t.c_cflag, MDMBUF); |
355 | | | 355 | |
356 | tp->t_ospeed = 0; | | 356 | tp->t_ospeed = 0; |
357 | (void) ucycomparam(tp, &t); | | 357 | (void) ucycomparam(tp, &t); |
358 | tp->t_iflag = TTYDEF_IFLAG; | | 358 | tp->t_iflag = TTYDEF_IFLAG; |
359 | tp->t_oflag = TTYDEF_OFLAG; | | 359 | tp->t_oflag = TTYDEF_OFLAG; |
360 | tp->t_lflag = TTYDEF_LFLAG; | | 360 | tp->t_lflag = TTYDEF_LFLAG; |
361 | ttychars(tp); | | 361 | ttychars(tp); |
362 | ttsetwater(tp); | | 362 | ttsetwater(tp); |
363 | | | 363 | |
364 | /* Allocate an output report buffer */ | | 364 | /* Allocate an output report buffer */ |
365 | sc->sc_obuf = malloc(sc->sc_olen, M_USBDEV, M_WAITOK); | | 365 | sc->sc_obuf = malloc(sc->sc_olen, M_USBDEV, M_WAITOK); |
366 | | | 366 | |
367 | DPRINTF(("ucycomopen: sc->sc_obuf=%p\n", sc->sc_obuf)); | | 367 | DPRINTF(("ucycomopen: sc->sc_obuf=%p\n", sc->sc_obuf)); |
368 | | | 368 | |
369 | #if 0 | | 369 | #if 0 |
370 | /* XXX Don't do this as for some reason trying to do an | | 370 | /* XXX Don't do this as for some reason trying to do an |
371 | * XXX interrupt out transfer at this point means everything | | 371 | * XXX interrupt out transfer at this point means everything |
372 | * XXX gets stuck!?! | | 372 | * XXX gets stuck!?! |
373 | */ | | 373 | */ |
374 | /* | | 374 | /* |
375 | * Turn on DTR. We must always do this, even if carrier is not | | 375 | * Turn on DTR. We must always do this, even if carrier is not |
376 | * present, because otherwise we'd have to use TIOCSDTR | | 376 | * present, because otherwise we'd have to use TIOCSDTR |
377 | * immediately after setting CLOCAL, which applications do not | | 377 | * immediately after setting CLOCAL, which applications do not |
378 | * expect. We always assert DTR while the device is open | | 378 | * expect. We always assert DTR while the device is open |
379 | * unless explicitly requested to deassert it. | | 379 | * unless explicitly requested to deassert it. |
| @@ -465,86 +465,86 @@ ucycomstart(struct tty *tp) | | | @@ -465,86 +465,86 @@ ucycomstart(struct tty *tp) |
465 | if (ttypull(tp) == 0) | | 465 | if (ttypull(tp) == 0) |
466 | goto out; | | 466 | goto out; |
467 | | | 467 | |
468 | /* Grab the first contiguous region of buffer space. */ | | 468 | /* Grab the first contiguous region of buffer space. */ |
469 | data = tp->t_outq.c_cf; | | 469 | data = tp->t_outq.c_cf; |
470 | cnt = ndqb(&tp->t_outq, 0); | | 470 | cnt = ndqb(&tp->t_outq, 0); |
471 | | | 471 | |
472 | if (cnt == 0) { | | 472 | if (cnt == 0) { |
473 | DPRINTF(("ucycomstart: cnt == 0\n")); | | 473 | DPRINTF(("ucycomstart: cnt == 0\n")); |
474 | goto out; | | 474 | goto out; |
475 | } | | 475 | } |
476 | | | 476 | |
477 | SET(tp->t_state, TS_BUSY); | | 477 | SET(tp->t_state, TS_BUSY); |
478 | | | 478 | |
479 | /* | | 479 | /* |
480 | * The 8 byte output report uses byte 0 for control and byte | | 480 | * The 8 byte output report uses byte 0 for control and byte |
481 | * count. | | 481 | * count. |
482 | * | | 482 | * |
483 | * The 32 byte output report uses byte 0 for control. Byte 1 | | 483 | * The 32 byte output report uses byte 0 for control. Byte 1 |
484 | * is used for byte count. | | 484 | * is used for byte count. |
485 | */ | | 485 | */ |
486 | memset(sc->sc_obuf, 0, sc->sc_olen); | | 486 | memset(sc->sc_obuf, 0, sc->sc_olen); |
487 | len = cnt; | | 487 | len = cnt; |
488 | switch (sc->sc_olen) { | | 488 | switch (sc->sc_olen) { |
489 | case 8: | | 489 | case 8: |
490 | if (cnt > sc->sc_olen - 1) { | | 490 | if (cnt > sc->sc_olen - 1) { |
491 | DPRINTF(("ucycomstart(8): big buffer %d chars\n", len)); | | 491 | DPRINTF(("ucycomstart(8): big buffer %d chars\n", len)); |
492 | len = sc->sc_olen - 1; | | 492 | len = sc->sc_olen - 1; |
493 | } | | 493 | } |
494 | | | 494 | |
495 | memcpy(sc->sc_obuf + 1, data, len); | | 495 | memcpy(sc->sc_obuf + 1, data, len); |
496 | sc->sc_obuf[0] = len | sc->sc_mcr; | | 496 | sc->sc_obuf[0] = len | sc->sc_mcr; |
497 | | | 497 | |
498 | DPRINTF(("ucycomstart(8): sc->sc_obuf[0] = %d | %d = %d\n", len, | | 498 | DPRINTF(("ucycomstart(8): sc->sc_obuf[0] = %d | %d = %d\n", len, |
499 | sc->sc_mcr, sc->sc_obuf[0])); | | 499 | sc->sc_mcr, sc->sc_obuf[0])); |
500 | #ifdef UCYCOM_DEBUG | | 500 | #ifdef UCYCOM_DEBUG |
501 | if (ucycomdebug > 10) { | | 501 | if (ucycomdebug > 10) { |
502 | u_int32_t i; | | 502 | u_int32_t i; |
503 | u_int8_t *d = data; | | 503 | u_int8_t *d = data; |
504 | | | 504 | |
505 | DPRINTF(("ucycomstart(8): data =")); | | 505 | DPRINTF(("ucycomstart(8): data =")); |
506 | for (i = 0; i < len; i++) | | 506 | for (i = 0; i < len; i++) |
507 | DPRINTF((" %02x", d[i])); | | 507 | DPRINTF((" %02x", d[i])); |
508 | DPRINTF(("\n")); | | 508 | DPRINTF(("\n")); |
509 | } | | 509 | } |
510 | #endif | | 510 | #endif |
511 | break; | | 511 | break; |
512 | | | 512 | |
513 | case 32: | | 513 | case 32: |
514 | if (cnt > sc->sc_olen - 2) { | | 514 | if (cnt > sc->sc_olen - 2) { |
515 | DPRINTF(("ucycomstart(32): big buffer %d chars\n", | | 515 | DPRINTF(("ucycomstart(32): big buffer %d chars\n", |
516 | len)); | | 516 | len)); |
517 | len = sc->sc_olen - 2; | | 517 | len = sc->sc_olen - 2; |
518 | } | | 518 | } |
519 | | | 519 | |
520 | memcpy(sc->sc_obuf + 2, data, len); | | 520 | memcpy(sc->sc_obuf + 2, data, len); |
521 | sc->sc_obuf[0] = sc->sc_mcr; | | 521 | sc->sc_obuf[0] = sc->sc_mcr; |
522 | sc->sc_obuf[1] = len; | | 522 | sc->sc_obuf[1] = len; |
523 | DPRINTF(("ucycomstart(32): sc->sc_obuf[0] = %d\n" | | 523 | DPRINTF(("ucycomstart(32): sc->sc_obuf[0] = %d\n" |
524 | "sc->sc_obuf[1] = %d\n", sc->sc_obuf[0], sc->sc_obuf[1])); | | 524 | "sc->sc_obuf[1] = %d\n", sc->sc_obuf[0], sc->sc_obuf[1])); |
525 | #ifdef UCYCOM_DEBUG | | 525 | #ifdef UCYCOM_DEBUG |
526 | if (ucycomdebug > 10) { | | 526 | if (ucycomdebug > 10) { |
527 | u_int32_t i; | | 527 | u_int32_t i; |
528 | u_int8_t *d = data; | | 528 | u_int8_t *d = data; |
529 | | | 529 | |
530 | DPRINTF(("ucycomstart(32): data =")); | | 530 | DPRINTF(("ucycomstart(32): data =")); |
531 | for (i = 0; i < len; i++) | | 531 | for (i = 0; i < len; i++) |
532 | DPRINTF((" %02x", d[i])); | | 532 | DPRINTF((" %02x", d[i])); |
533 | DPRINTF(("\n")); | | 533 | DPRINTF(("\n")); |
534 | } | | 534 | } |
535 | #endif | | 535 | #endif |
536 | break; | | 536 | break; |
537 | | | 537 | |
538 | default: | | 538 | default: |
539 | DPRINTFN(2,("ucycomstart: unknown output report size (%zd)\n", | | 539 | DPRINTFN(2,("ucycomstart: unknown output report size (%zd)\n", |
540 | sc->sc_olen)); | | 540 | sc->sc_olen)); |
541 | goto out; | | 541 | goto out; |
542 | } | | 542 | } |
543 | splx(s); | | 543 | splx(s); |
544 | | | 544 | |
545 | #ifdef UCYCOM_DEBUG | | 545 | #ifdef UCYCOM_DEBUG |
546 | if (ucycomdebug > 5) { | | 546 | if (ucycomdebug > 5) { |
547 | int i; | | 547 | int i; |
548 | | | 548 | |
549 | if (len != 0) { | | 549 | if (len != 0) { |
550 | DPRINTF(("ucycomstart: sc->sc_obuf[0..%zd) =", | | 550 | DPRINTF(("ucycomstart: sc->sc_obuf[0..%zd) =", |
| @@ -789,27 +789,27 @@ ucycomioctl(dev_t dev, u_long cmd, void | | | @@ -789,27 +789,27 @@ ucycomioctl(dev_t dev, u_long cmd, void |
789 | | | 789 | |
790 | splx(s); | | 790 | splx(s); |
791 | | | 791 | |
792 | return (err); | | 792 | return (err); |
793 | } | | 793 | } |
794 | | | 794 | |
795 | int | | 795 | int |
796 | ucycompoll(dev_t dev, int events, struct lwp *l) | | 796 | ucycompoll(dev_t dev, int events, struct lwp *l) |
797 | { | | 797 | { |
798 | struct ucycom_softc *sc = | | 798 | struct ucycom_softc *sc = |
799 | device_lookup_private(&ucycom_cd, UCYCOMUNIT(dev)); | | 799 | device_lookup_private(&ucycom_cd, UCYCOMUNIT(dev)); |
800 | struct tty *tp = sc->sc_tty; | | 800 | struct tty *tp = sc->sc_tty; |
801 | int err; | | 801 | int err; |
802 | | | 802 | |
803 | DPRINTF(("ucycompoll: sc=%p, tp=%p, events=%d, lwp=%p\n", sc, tp, | | 803 | DPRINTF(("ucycompoll: sc=%p, tp=%p, events=%d, lwp=%p\n", sc, tp, |
804 | events, l)); | | 804 | events, l)); |
805 | | | 805 | |
806 | if (sc->sc_dying) | | 806 | if (sc->sc_dying) |
807 | return (EIO); | | 807 | return (EIO); |
808 | | | 808 | |
809 | err = ((*tp->t_linesw->l_poll)(tp, events, l)); | | 809 | err = ((*tp->t_linesw->l_poll)(tp, events, l)); |
810 | return (err); | | 810 | return (err); |
811 | } | | 811 | } |
812 | | | 812 | |
813 | Static int | | 813 | Static int |
814 | ucycom_configure(struct ucycom_softc *sc, uint32_t baud, uint8_t cfg) | | 814 | ucycom_configure(struct ucycom_softc *sc, uint32_t baud, uint8_t cfg) |
815 | { | | 815 | { |
| @@ -860,27 +860,27 @@ ucycom_configure(struct ucycom_softc *sc | | | @@ -860,27 +860,27 @@ ucycom_configure(struct ucycom_softc *sc |
860 | sc->sc_cfg = cfg; | | 860 | sc->sc_cfg = cfg; |
861 | | | 861 | |
862 | return 0; | | 862 | return 0; |
863 | } | | 863 | } |
864 | | | 864 | |
865 | Static void | | 865 | Static void |
866 | ucycom_intr(struct uhidev *addr, void *ibuf, u_int len) | | 866 | ucycom_intr(struct uhidev *addr, void *ibuf, u_int len) |
867 | { | | 867 | { |
868 | struct ucycom_softc *sc = (struct ucycom_softc *)addr; | | 868 | struct ucycom_softc *sc = (struct ucycom_softc *)addr; |
869 | struct tty *tp = sc->sc_tty; | | 869 | struct tty *tp = sc->sc_tty; |
870 | int (*rint)(int , struct tty *) = tp->t_linesw->l_rint; | | 870 | int (*rint)(int , struct tty *) = tp->t_linesw->l_rint; |
871 | uint8_t *cp = ibuf; | | 871 | uint8_t *cp = ibuf; |
872 | int s, n, st, chg; | | 872 | int s, n, st, chg; |
873 | | | 873 | |
874 | /* We understand 8 byte and 32 byte input records */ | | 874 | /* We understand 8 byte and 32 byte input records */ |
875 | switch (len) { | | 875 | switch (len) { |
876 | case 8: | | 876 | case 8: |
877 | n = cp[0] & UCYCOM_LMASK; | | 877 | n = cp[0] & UCYCOM_LMASK; |
878 | st = cp[0] & ~UCYCOM_LMASK; | | 878 | st = cp[0] & ~UCYCOM_LMASK; |
879 | cp++; | | 879 | cp++; |
880 | break; | | 880 | break; |
881 | | | 881 | |
882 | case 32: | | 882 | case 32: |
883 | st = cp[0]; | | 883 | st = cp[0]; |
884 | n = cp[1]; | | 884 | n = cp[1]; |
885 | cp += 2; | | 885 | cp += 2; |
886 | break; | | 886 | break; |
| @@ -974,83 +974,83 @@ ucycom_to_tiocm(struct ucycom_softc *sc) | | | @@ -974,83 +974,83 @@ ucycom_to_tiocm(struct ucycom_softc *sc) |
974 | SET(ttybits, TIOCM_CTS); | | 974 | SET(ttybits, TIOCM_CTS); |
975 | if (ISSET(combits, UCYCOM_DSR)) | | 975 | if (ISSET(combits, UCYCOM_DSR)) |
976 | SET(ttybits, TIOCM_DSR); | | 976 | SET(ttybits, TIOCM_DSR); |
977 | if (ISSET(combits, UCYCOM_RI)) | | 977 | if (ISSET(combits, UCYCOM_RI)) |
978 | SET(ttybits, TIOCM_RI); | | 978 | SET(ttybits, TIOCM_RI); |
979 | | | 979 | |
980 | return (ttybits); | | 980 | return (ttybits); |
981 | } | | 981 | } |
982 | | | 982 | |
983 | Static void | | 983 | Static void |
984 | ucycom_dtr(struct ucycom_softc *sc, int set) | | 984 | ucycom_dtr(struct ucycom_softc *sc, int set) |
985 | { | | 985 | { |
986 | uint8_t old; | | 986 | uint8_t old; |
987 | | | 987 | |
988 | old = sc->sc_mcr; | | 988 | old = sc->sc_mcr; |
989 | if (set) | | 989 | if (set) |
990 | SET(sc->sc_mcr, UCYCOM_DTR); | | 990 | SET(sc->sc_mcr, UCYCOM_DTR); |
991 | else | | 991 | else |
992 | CLR(sc->sc_mcr, UCYCOM_DTR); | | 992 | CLR(sc->sc_mcr, UCYCOM_DTR); |
993 | | | 993 | |
994 | if (old ^ sc->sc_mcr) | | 994 | if (old ^ sc->sc_mcr) |
995 | ucycom_set_status(sc); | | 995 | ucycom_set_status(sc); |
996 | } | | 996 | } |
997 | | | 997 | |
998 | #if 0 | | 998 | #if 0 |
999 | Static void | | 999 | Static void |
1000 | ucycom_rts(struct ucycom_softc *sc, int set) | | 1000 | ucycom_rts(struct ucycom_softc *sc, int set) |
1001 | { | | 1001 | { |
1002 | uint8_t old; | | 1002 | uint8_t old; |
1003 | | | 1003 | |
1004 | old = sc->sc_msr; | | 1004 | old = sc->sc_msr; |
1005 | if (set) | | 1005 | if (set) |
1006 | SET(sc->sc_mcr, UCYCOM_RTS); | | 1006 | SET(sc->sc_mcr, UCYCOM_RTS); |
1007 | else | | 1007 | else |
1008 | CLR(sc->sc_mcr, UCYCOM_RTS); | | 1008 | CLR(sc->sc_mcr, UCYCOM_RTS); |
1009 | | | 1009 | |
1010 | if (old ^ sc->sc_mcr) | | 1010 | if (old ^ sc->sc_mcr) |
1011 | ucycom_set_status(sc); | | 1011 | ucycom_set_status(sc); |
1012 | } | | 1012 | } |
1013 | #endif | | 1013 | #endif |
1014 | | | 1014 | |
1015 | Static void | | 1015 | Static void |
1016 | ucycom_set_status(struct ucycom_softc *sc) | | 1016 | ucycom_set_status(struct ucycom_softc *sc) |
1017 | { | | 1017 | { |
1018 | int err; | | 1018 | int err; |
1019 | | | 1019 | |
1020 | if (sc->sc_olen != 8 && sc->sc_olen != 32) { | | 1020 | if (sc->sc_olen != 8 && sc->sc_olen != 32) { |
1021 | DPRINTFN(2,("ucycom_set_status: unknown output report " | | 1021 | DPRINTFN(2,("ucycom_set_status: unknown output report " |
1022 | "size (%zd)\n", sc->sc_olen)); | | 1022 | "size (%zd)\n", sc->sc_olen)); |
1023 | return; | | 1023 | return; |
1024 | } | | 1024 | } |
1025 | | | 1025 | |
1026 | DPRINTF(("ucycom_set_status: %d\n", sc->sc_mcr)); | | 1026 | DPRINTF(("ucycom_set_status: %d\n", sc->sc_mcr)); |
1027 | | | 1027 | |
1028 | memset(sc->sc_obuf, 0, sc->sc_olen); | | 1028 | memset(sc->sc_obuf, 0, sc->sc_olen); |
1029 | sc->sc_obuf[0] = sc->sc_mcr; | | 1029 | sc->sc_obuf[0] = sc->sc_mcr; |
1030 | | | 1030 | |
1031 | err = uhidev_write(sc->sc_hdev.sc_parent, sc->sc_obuf, sc->sc_olen); | | 1031 | err = uhidev_write(sc->sc_hdev.sc_parent, sc->sc_obuf, sc->sc_olen); |
1032 | if (err) { | | 1032 | if (err) { |
1033 | DPRINTF(("ucycom_set_status: err=%d\n", err)); | | 1033 | DPRINTF(("ucycom_set_status: err=%d\n", err)); |
1034 | } | | 1034 | } |
1035 | } | | 1035 | } |
1036 | | | 1036 | |
1037 | #ifdef UCYCOM_DEBUG | | 1037 | #ifdef UCYCOM_DEBUG |
1038 | Static void | | 1038 | Static void |
1039 | ucycom_get_cfg(struct ucycom_softc *sc) | | 1039 | ucycom_get_cfg(struct ucycom_softc *sc) |
1040 | { | | 1040 | { |
1041 | int err, cfg, baud; | | 1041 | int err, cfg, baud; |
1042 | uint8_t report[5]; | | 1042 | uint8_t report[5]; |
1043 | | | 1043 | |
1044 | err = uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, | | 1044 | err = uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, |
1045 | report, sc->sc_flen); | | 1045 | report, sc->sc_flen); |
1046 | cfg = report[4]; | | 1046 | cfg = report[4]; |
1047 | baud = (report[3] << 24) + (report[2] << 16) + (report[1] << 8) + | | 1047 | baud = (report[3] << 24) + (report[2] << 16) + (report[1] << 8) + |
1048 | report[0]; | | 1048 | report[0]; |
1049 | DPRINTF(("ucycom_configure: device reports %d baud, %d-%c-%d (%d)\n", | | 1049 | DPRINTF(("ucycom_configure: device reports %d baud, %d-%c-%d (%d)\n", |
1050 | baud, 5 + (cfg & UCYCOM_DATA_MASK), | | 1050 | baud, 5 + (cfg & UCYCOM_DATA_MASK), |
1051 | (cfg & UCYCOM_PARITY_MASK) ? | | 1051 | (cfg & UCYCOM_PARITY_MASK) ? |
1052 | ((cfg & UCYCOM_PARITY_TYPE_MASK) ? 'O' : 'E') : 'N', | | 1052 | ((cfg & UCYCOM_PARITY_TYPE_MASK) ? 'O' : 'E') : 'N', |
1053 | (cfg & UCYCOM_STOP_MASK) ? 2 : 1, cfg)); | | 1053 | (cfg & UCYCOM_STOP_MASK) ? 2 : 1, cfg)); |
1054 | } | | 1054 | } |
1055 | #endif | | 1055 | #endif |
1056 | | | 1056 | |