Deleted Added
full compact
usb_serial.c (242126) usb_serial.c (242619)
1/* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */
2
3/*-
4 * Copyright (c) 2001-2003, 2005, 2008
5 * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */
2
3/*-
4 * Copyright (c) 2001-2003, 2005, 2008
5 * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 242126 2012-10-26 06:04:47Z hselasky $");
31__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 242619 2012-11-05 17:50:40Z hselasky $");
32
33/*-
34 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
35 * All rights reserved.
36 *
37 * This code is derived from software contributed to The NetBSD Foundation
38 * by Lennart Augustsson (lennart@augustsson.net) at
39 * Carlstedt Research & Technology.

--- 117 unchanged lines hidden (view full) ---

157static void ucom_rts(struct ucom_softc *, uint8_t);
158
159static tsw_open_t ucom_open;
160static tsw_close_t ucom_close;
161static tsw_ioctl_t ucom_ioctl;
162static tsw_modem_t ucom_modem;
163static tsw_param_t ucom_param;
164static tsw_outwakeup_t ucom_outwakeup;
32
33/*-
34 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
35 * All rights reserved.
36 *
37 * This code is derived from software contributed to The NetBSD Foundation
38 * by Lennart Augustsson (lennart@augustsson.net) at
39 * Carlstedt Research & Technology.

--- 117 unchanged lines hidden (view full) ---

157static void ucom_rts(struct ucom_softc *, uint8_t);
158
159static tsw_open_t ucom_open;
160static tsw_close_t ucom_close;
161static tsw_ioctl_t ucom_ioctl;
162static tsw_modem_t ucom_modem;
163static tsw_param_t ucom_param;
164static tsw_outwakeup_t ucom_outwakeup;
165static tsw_inwakeup_t ucom_inwakeup;
165static tsw_free_t ucom_free;
166
167static struct ttydevsw ucom_class = {
168 .tsw_flags = TF_INITLOCK | TF_CALLOUT,
169 .tsw_open = ucom_open,
170 .tsw_close = ucom_close,
171 .tsw_outwakeup = ucom_outwakeup,
166static tsw_free_t ucom_free;
167
168static struct ttydevsw ucom_class = {
169 .tsw_flags = TF_INITLOCK | TF_CALLOUT,
170 .tsw_open = ucom_open,
171 .tsw_close = ucom_close,
172 .tsw_outwakeup = ucom_outwakeup,
173 .tsw_inwakeup = ucom_inwakeup,
172 .tsw_ioctl = ucom_ioctl,
173 .tsw_param = ucom_param,
174 .tsw_modem = ucom_modem,
175 .tsw_free = ucom_free,
176};
177
178MODULE_DEPEND(ucom, usb, 1, 1, 1);
179MODULE_VERSION(ucom, 1);

--- 531 unchanged lines hidden (view full) ---

711 sc->sc_msr = 0;
712 sc->sc_mcr = 0;
713
714 /* reset programmed line state */
715 sc->sc_pls_curr = 0;
716 sc->sc_pls_set = 0;
717 sc->sc_pls_clr = 0;
718
174 .tsw_ioctl = ucom_ioctl,
175 .tsw_param = ucom_param,
176 .tsw_modem = ucom_modem,
177 .tsw_free = ucom_free,
178};
179
180MODULE_DEPEND(ucom, usb, 1, 1, 1);
181MODULE_VERSION(ucom, 1);

--- 531 unchanged lines hidden (view full) ---

713 sc->sc_msr = 0;
714 sc->sc_mcr = 0;
715
716 /* reset programmed line state */
717 sc->sc_pls_curr = 0;
718 sc->sc_pls_set = 0;
719 sc->sc_pls_clr = 0;
720
721 /* reset jitter buffer */
722 sc->sc_jitterbuf_in = 0;
723 sc->sc_jitterbuf_out = 0;
724
719 ucom_queue_command(sc, ucom_cfg_open, NULL,
720 &sc->sc_open_task[0].hdr,
721 &sc->sc_open_task[1].hdr);
722
723 /* Queue transfer enable command last */
724 ucom_queue_command(sc, ucom_cfg_start_transfers, NULL,
725 &sc->sc_start_task[0].hdr,
726 &sc->sc_start_task[1].hdr);

--- 48 unchanged lines hidden (view full) ---

775
776 sc->sc_flag &= ~(UCOM_FLAG_HL_READY | UCOM_FLAG_RTS_IFLOW);
777
778 if (sc->sc_callback->ucom_stop_read) {
779 (sc->sc_callback->ucom_stop_read) (sc);
780 }
781}
782
725 ucom_queue_command(sc, ucom_cfg_open, NULL,
726 &sc->sc_open_task[0].hdr,
727 &sc->sc_open_task[1].hdr);
728
729 /* Queue transfer enable command last */
730 ucom_queue_command(sc, ucom_cfg_start_transfers, NULL,
731 &sc->sc_start_task[0].hdr,
732 &sc->sc_start_task[1].hdr);

--- 48 unchanged lines hidden (view full) ---

781
782 sc->sc_flag &= ~(UCOM_FLAG_HL_READY | UCOM_FLAG_RTS_IFLOW);
783
784 if (sc->sc_callback->ucom_stop_read) {
785 (sc->sc_callback->ucom_stop_read) (sc);
786 }
787}
788
789static void
790ucom_inwakeup(struct tty *tp)
791{
792 struct ucom_softc *sc = tty_softc(tp);
793 uint16_t pos;
794
795 if (sc == NULL)
796 return;
797
798 tty_lock(tp);
799
800 if (ttydisc_can_bypass(tp) != 0 ||
801 (sc->sc_flag & UCOM_FLAG_HL_READY) == 0) {
802 tty_unlock(tp);
803 return;
804 }
805
806 pos = sc->sc_jitterbuf_out;
807
808 while (sc->sc_jitterbuf_in != pos) {
809 int c;
810
811 c = (char)sc->sc_jitterbuf[pos];
812
813 if (ttydisc_rint(tp, c, 0) == -1)
814 break;
815 pos++;
816 if (pos >= UCOM_JITTERBUF_SIZE)
817 pos -= UCOM_JITTERBUF_SIZE;
818 }
819
820 sc->sc_jitterbuf_out = pos;
821
822 /* clear RTS in async fashion */
823 if ((sc->sc_jitterbuf_in == pos) &&
824 (sc->sc_flag & UCOM_FLAG_RTS_IFLOW))
825 ucom_rts(sc, 0);
826
827 tty_unlock(tp);
828}
829
783static int
784ucom_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
785{
786 struct ucom_softc *sc = tty_softc(tp);
787 int error;
788
789 UCOM_MTX_ASSERT(sc, MA_OWNED);
790

--- 564 unchanged lines hidden (view full) ---

1355 /* pass characters to tty layer */
1356
1357 buf = res.buffer;
1358 cnt = res.length;
1359
1360 /* first check if we can pass the buffer directly */
1361
1362 if (ttydisc_can_bypass(tp)) {
830static int
831ucom_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
832{
833 struct ucom_softc *sc = tty_softc(tp);
834 int error;
835
836 UCOM_MTX_ASSERT(sc, MA_OWNED);
837

--- 564 unchanged lines hidden (view full) ---

1402 /* pass characters to tty layer */
1403
1404 buf = res.buffer;
1405 cnt = res.length;
1406
1407 /* first check if we can pass the buffer directly */
1408
1409 if (ttydisc_can_bypass(tp)) {
1410
1411 /* clear any jitter buffer */
1412 sc->sc_jitterbuf_in = 0;
1413 sc->sc_jitterbuf_out = 0;
1414
1363 if (ttydisc_rint_bypass(tp, buf, cnt) != cnt) {
1364 DPRINTF("tp=%p, data lost\n", tp);
1365 }
1366 continue;
1367 }
1368 /* need to loop */
1369
1370 for (cnt = 0; cnt != res.length; cnt++) {
1415 if (ttydisc_rint_bypass(tp, buf, cnt) != cnt) {
1416 DPRINTF("tp=%p, data lost\n", tp);
1417 }
1418 continue;
1419 }
1420 /* need to loop */
1421
1422 for (cnt = 0; cnt != res.length; cnt++) {
1371 if (ttydisc_rint(tp, buf[cnt], 0) == -1) {
1372 /* XXX what should we do? */
1423 if (sc->sc_jitterbuf_in != sc->sc_jitterbuf_out ||
1424 ttydisc_rint(tp, buf[cnt], 0) == -1) {
1425 uint16_t end;
1426 uint16_t pos;
1373
1427
1428 pos = sc->sc_jitterbuf_in;
1429 end = sc->sc_jitterbuf_out +
1430 UCOM_JITTERBUF_SIZE - 1;
1431 if (end >= UCOM_JITTERBUF_SIZE)
1432 end -= UCOM_JITTERBUF_SIZE;
1433
1434 for (; cnt != res.length; cnt++) {
1435 if (pos == end)
1436 break;
1437 sc->sc_jitterbuf[pos] = buf[cnt];
1438 pos++;
1439 if (pos >= UCOM_JITTERBUF_SIZE)
1440 pos -= UCOM_JITTERBUF_SIZE;
1441 }
1442
1443 sc->sc_jitterbuf_in = pos;
1444
1445 /* set RTS in async fashion */
1446 if (sc->sc_flag & UCOM_FLAG_RTS_IFLOW)
1447 ucom_rts(sc, 1);
1448
1374 DPRINTF("tp=%p, lost %d "
1375 "chars\n", tp, res.length - cnt);
1376 break;
1377 }
1378 }
1379 }
1380 ttydisc_rint_done(tp);
1381}

--- 223 unchanged lines hidden ---
1449 DPRINTF("tp=%p, lost %d "
1450 "chars\n", tp, res.length - cnt);
1451 break;
1452 }
1453 }
1454 }
1455 ttydisc_rint_done(tp);
1456}

--- 223 unchanged lines hidden ---