Lines Matching +full:data +full:- +full:rates

1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2001-2002 Greg Kroah-Hartman (greg@kroah.com)
12 * please use the usb-irda driver, as it contains the proper error checking and
15 * Portions of this driver were taken from drivers/net/irda/irda-usb.c, which
19 * See Documentation/usb/usb-serial.rst for more information on using this
37 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Johan Hovold <jhovold@gmail.com>"
45 static int xbof = -1;
63 { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */
65 { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */
75 .name = "ir-usb",
97 struct device *dev = &serial->dev->dev; in irda_usb_dump_class_desc()
99 dev_dbg(dev, "bLength=%x\n", desc->bLength); in irda_usb_dump_class_desc()
100 dev_dbg(dev, "bDescriptorType=%x\n", desc->bDescriptorType); in irda_usb_dump_class_desc()
101 dev_dbg(dev, "bcdSpecRevision=%x\n", __le16_to_cpu(desc->bcdSpecRevision)); in irda_usb_dump_class_desc()
102 dev_dbg(dev, "bmDataSize=%x\n", desc->bmDataSize); in irda_usb_dump_class_desc()
103 dev_dbg(dev, "bmWindowSize=%x\n", desc->bmWindowSize); in irda_usb_dump_class_desc()
104 dev_dbg(dev, "bmMinTurnaroundTime=%d\n", desc->bmMinTurnaroundTime); in irda_usb_dump_class_desc()
105 dev_dbg(dev, "wBaudRate=%x\n", __le16_to_cpu(desc->wBaudRate)); in irda_usb_dump_class_desc()
106 dev_dbg(dev, "bmAdditionalBOFs=%x\n", desc->bmAdditionalBOFs); in irda_usb_dump_class_desc()
107 dev_dbg(dev, "bIrdaRateSniff=%x\n", desc->bIrdaRateSniff); in irda_usb_dump_class_desc()
108 dev_dbg(dev, "bMaxUnicastList=%x\n", desc->bMaxUnicastList); in irda_usb_dump_class_desc()
111 /*------------------------------------------------------------------*/
121 * Based on the same function in drivers/net/irda/irda-usb.c
126 struct usb_device *dev = serial->dev; in irda_usb_find_class_desc()
139 dev_dbg(&serial->dev->dev, "%s - ret=%d\n", __func__, ret); in irda_usb_find_class_desc()
141 dev_dbg(&serial->dev->dev, in irda_usb_find_class_desc()
142 "%s - class descriptor read %s (%d)\n", __func__, in irda_usb_find_class_desc()
146 if (desc->bDescriptorType != USB_DT_CS_IRDA) { in irda_usb_find_class_desc()
147 dev_dbg(&serial->dev->dev, "%s - bad class descriptor type\n", in irda_usb_find_class_desc()
164 /* reference irda-usb.c */ in ir_xbof_change()
201 int rates; in ir_startup() local
205 dev_err(&serial->dev->dev, in ir_startup()
207 return -ENODEV; in ir_startup()
210 rates = le16_to_cpu(irda_desc->wBaudRate); in ir_startup()
212 dev_dbg(&serial->dev->dev, in ir_startup()
213 "%s - Baud rates supported:%s%s%s%s%s%s%s%s%s\n", in ir_startup()
215 (rates & USB_IRDA_BR_2400) ? " 2400" : "", in ir_startup()
216 (rates & USB_IRDA_BR_9600) ? " 9600" : "", in ir_startup()
217 (rates & USB_IRDA_BR_19200) ? " 19200" : "", in ir_startup()
218 (rates & USB_IRDA_BR_38400) ? " 38400" : "", in ir_startup()
219 (rates & USB_IRDA_BR_57600) ? " 57600" : "", in ir_startup()
220 (rates & USB_IRDA_BR_115200) ? " 115200" : "", in ir_startup()
221 (rates & USB_IRDA_BR_576000) ? " 576000" : "", in ir_startup()
222 (rates & USB_IRDA_BR_1152000) ? " 1152000" : "", in ir_startup()
223 (rates & USB_IRDA_BR_4000000) ? " 4000000" : ""); in ir_startup()
225 switch (irda_desc->bmAdditionalBOFs) { in ir_startup()
266 if (port->bulk_out_size == 0) in ir_write()
267 return -EINVAL; in ir_write()
272 count = min(count, port->bulk_out_size - 1); in ir_write()
274 spin_lock_irqsave(&port->lock, flags); in ir_write()
275 if (__test_and_clear_bit(0, &port->write_urbs_free)) { in ir_write()
276 urb = port->write_urbs[0]; in ir_write()
277 port->tx_bytes += count; in ir_write()
279 spin_unlock_irqrestore(&port->lock, flags); in ir_write()
291 *(u8 *)urb->transfer_buffer = ir_xbof | ir_baud; in ir_write()
293 memcpy(urb->transfer_buffer + 1, buf, count); in ir_write()
295 urb->transfer_buffer_length = count + 1; in ir_write()
296 urb->transfer_flags = URB_ZERO_PACKET; in ir_write()
300 dev_err(&port->dev, "failed to submit write urb: %d\n", ret); in ir_write()
302 spin_lock_irqsave(&port->lock, flags); in ir_write()
303 __set_bit(0, &port->write_urbs_free); in ir_write()
304 port->tx_bytes -= count; in ir_write()
305 spin_unlock_irqrestore(&port->lock, flags); in ir_write()
315 struct usb_serial_port *port = urb->context; in ir_write_bulk_callback()
316 int status = urb->status; in ir_write_bulk_callback()
319 spin_lock_irqsave(&port->lock, flags); in ir_write_bulk_callback()
320 __set_bit(0, &port->write_urbs_free); in ir_write_bulk_callback()
321 port->tx_bytes -= urb->transfer_buffer_length - 1; in ir_write_bulk_callback()
322 spin_unlock_irqrestore(&port->lock, flags); in ir_write_bulk_callback()
327 case -ENOENT: in ir_write_bulk_callback()
328 case -ECONNRESET: in ir_write_bulk_callback()
329 case -ESHUTDOWN: in ir_write_bulk_callback()
330 dev_dbg(&port->dev, "write urb stopped: %d\n", status); in ir_write_bulk_callback()
332 case -EPIPE: in ir_write_bulk_callback()
333 dev_err(&port->dev, "write urb stopped: %d\n", status); in ir_write_bulk_callback()
336 dev_err(&port->dev, "nonzero write-urb status: %d\n", status); in ir_write_bulk_callback()
345 struct usb_serial_port *port = tty->driver_data; in ir_write_room()
348 if (port->bulk_out_size == 0) in ir_write_room()
351 if (test_bit(0, &port->write_urbs_free)) in ir_write_room()
352 count = port->bulk_out_size - 1; in ir_write_room()
359 struct usb_serial_port *port = urb->context; in ir_process_read_urb()
360 unsigned char *data = urb->transfer_buffer; in ir_process_read_urb() local
362 if (!urb->actual_length) in ir_process_read_urb()
369 if (*data & 0x0f) in ir_process_read_urb()
370 ir_baud = *data & 0x0f; in ir_process_read_urb()
372 if (urb->actual_length == 1) in ir_process_read_urb()
375 tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); in ir_process_read_urb()
376 tty_flip_buffer_push(&port->port); in ir_process_read_urb()
383 struct usb_device *udev = port->serial->dev; in ir_set_termios()
431 if (xbof == -1) in ir_set_termios()
437 tty_termios_copy_hw(&tty->termios, old_termios); in ir_set_termios()
441 * send the baud change out on an "empty" data packet in ir_set_termios()
450 usb_sndbulkpipe(udev, port->bulk_out_endpointAddress), in ir_set_termios()
454 ret = -EIO; in ir_set_termios()
455 dev_err(&port->dev, "failed to change line speed: %d\n", ret); in ir_set_termios()