Lines Matching defs:kingsun
9 * Based on stir4200, mcs7780, kingsun-sir drivers.
36 * unwrapped manually as in stir4200, kingsun-sir, and ks959-sir.
40 * sequence. It seems that sending a single big block (like kingsun-sir does)
49 * kingsun-sir.c) with interrupt URBs. If data is available, it will be returned
51 * a raw IrDA stream that needs to be unwrapped as in stir4200 and kingsun-sir
178 static int ksdazzle_change_speed(struct ksdazzle_cb *kingsun, unsigned speed)
186 if (kingsun->speed_setuprequest == NULL || kingsun->speed_urb == NULL)
194 memset(&(kingsun->speedparams), 0, sizeof(struct ksdazzle_speedparams));
195 kingsun->speedparams.baudrate = cpu_to_le32(speed);
196 kingsun->speedparams.flags = KS_DATA_8_BITS;
199 usb_fill_control_urb(kingsun->speed_urb, kingsun->usbdev,
200 usb_sndctrlpipe(kingsun->usbdev, 0),
201 (unsigned char *)kingsun->speed_setuprequest,
202 &(kingsun->speedparams),
204 ksdazzle_speed_irq, kingsun);
205 kingsun->speed_urb->status = 0;
206 err = usb_submit_urb(kingsun->speed_urb, GFP_ATOMIC);
213 static int ksdazzle_submit_tx_fragment(struct ksdazzle_cb *kingsun)
220 if (wraplen > kingsun->tx_buf_clear_used)
221 wraplen = kingsun->tx_buf_clear_used;
224 memset(kingsun->tx_payload, 0, 8);
225 kingsun->tx_payload[0] = (unsigned char)0xf8 + wraplen;
226 memcpy(kingsun->tx_payload + 1, kingsun->tx_buf_clear, wraplen);
228 usb_fill_int_urb(kingsun->tx_urb, kingsun->usbdev,
229 usb_sndintpipe(kingsun->usbdev, kingsun->ep_out),
230 kingsun->tx_payload, 8, ksdazzle_send_irq, kingsun, 1);
231 kingsun->tx_urb->status = 0;
232 ret = usb_submit_urb(kingsun->tx_urb, GFP_ATOMIC);
235 kingsun->tx_buf_clear_sent = (ret == 0) ? wraplen : 0;
242 struct ksdazzle_cb *kingsun = urb->context;
243 struct net_device *netdev = kingsun->netdev;
247 if (!netif_running(kingsun->netdev)) {
259 if (kingsun->tx_buf_clear_used > 0) {
261 if (kingsun->tx_buf_clear_sent < kingsun->tx_buf_clear_used) {
262 memmove(kingsun->tx_buf_clear,
263 kingsun->tx_buf_clear +
264 kingsun->tx_buf_clear_sent,
265 kingsun->tx_buf_clear_used -
266 kingsun->tx_buf_clear_sent);
268 kingsun->tx_buf_clear_used -= kingsun->tx_buf_clear_sent;
269 kingsun->tx_buf_clear_sent = 0;
271 if (kingsun->tx_buf_clear_used > 0) {
273 if ((ret = ksdazzle_submit_tx_fragment(kingsun)) != 0) {
286 if (kingsun->new_speed != -1 &&
287 cpu_to_le32(kingsun->new_speed) !=
288 kingsun->speedparams.baudrate)
289 ksdazzle_change_speed(kingsun,
290 kingsun->new_speed);
303 struct ksdazzle_cb *kingsun;
312 kingsun = netdev_priv(netdev);
314 spin_lock(&kingsun->lock);
315 kingsun->new_speed = irda_get_next_speed(skb);
319 async_wrap_skb(skb, kingsun->tx_buf_clear, KINGSUN_SND_FIFO_SIZE);
320 kingsun->tx_buf_clear_used = wraplen;
322 if ((ret = ksdazzle_submit_tx_fragment(kingsun)) != 0) {
339 spin_unlock(&kingsun->lock);
347 struct ksdazzle_cb *kingsun = urb->context;
348 struct net_device *netdev = kingsun->netdev;
352 kingsun->receiving = 0;
360 kingsun->receiving = 0;
370 &kingsun->rx_unwrap_buff, bytes[i]);
372 kingsun->receiving =
373 (kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0;
390 struct ksdazzle_cb *kingsun = netdev_priv(netdev);
395 kingsun->receiving = 0;
398 kingsun->rx_unwrap_buff.in_frame = FALSE;
399 kingsun->rx_unwrap_buff.state = OUTSIDE_FRAME;
400 kingsun->rx_unwrap_buff.truesize = IRDA_SKB_MAX_MTU;
401 kingsun->rx_unwrap_buff.skb = dev_alloc_skb(IRDA_SKB_MAX_MTU);
402 if (!kingsun->rx_unwrap_buff.skb)
405 skb_reserve(kingsun->rx_unwrap_buff.skb, 1);
406 kingsun->rx_unwrap_buff.head = kingsun->rx_unwrap_buff.skb->data;
408 kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
409 if (!kingsun->rx_urb)
412 kingsun->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
413 if (!kingsun->tx_urb)
416 kingsun->speed_urb = usb_alloc_urb(0, GFP_KERNEL);
417 if (!kingsun->speed_urb)
421 kingsun->new_speed = 9600;
422 err = ksdazzle_change_speed(kingsun, 9600);
430 sprintf(hwname, "usb#%d", kingsun->usbdev->devnum);
431 kingsun->irlap = irlap_open(netdev, &kingsun->qos, hwname);
432 if (!kingsun->irlap) {
438 usb_fill_int_urb(kingsun->rx_urb, kingsun->usbdev,
439 usb_rcvintpipe(kingsun->usbdev, kingsun->ep_in),
440 kingsun->rx_buf, KINGSUN_RCV_MAX, ksdazzle_rcv_irq,
441 kingsun, 1);
442 kingsun->rx_urb->status = 0;
443 err = usb_submit_urb(kingsun->rx_urb, GFP_KERNEL);
463 irlap_close(kingsun->irlap);
465 usb_free_urb(kingsun->speed_urb);
466 kingsun->speed_urb = NULL;
467 usb_free_urb(kingsun->tx_urb);
468 kingsun->tx_urb = NULL;
469 usb_free_urb(kingsun->rx_urb);
470 kingsun->rx_urb = NULL;
471 if (kingsun->rx_unwrap_buff.skb) {
472 kfree_skb(kingsun->rx_unwrap_buff.skb);
473 kingsun->rx_unwrap_buff.skb = NULL;
474 kingsun->rx_unwrap_buff.head = NULL;
487 struct ksdazzle_cb *kingsun = netdev_priv(netdev);
493 usb_kill_urb(kingsun->tx_urb);
494 usb_free_urb(kingsun->tx_urb);
495 kingsun->tx_urb = NULL;
497 usb_kill_urb(kingsun->speed_urb);
498 usb_free_urb(kingsun->speed_urb);
499 kingsun->speed_urb = NULL;
501 usb_kill_urb(kingsun->rx_urb);
502 usb_free_urb(kingsun->rx_urb);
503 kingsun->rx_urb = NULL;
505 kfree_skb(kingsun->rx_unwrap_buff.skb);
506 kingsun->rx_unwrap_buff.skb = NULL;
507 kingsun->rx_unwrap_buff.head = NULL;
508 kingsun->rx_unwrap_buff.in_frame = FALSE;
509 kingsun->rx_unwrap_buff.state = OUTSIDE_FRAME;
510 kingsun->receiving = 0;
513 irlap_close(kingsun->irlap);
515 kingsun->irlap = NULL;
527 struct ksdazzle_cb *kingsun = netdev_priv(netdev);
536 if (netif_device_present(kingsun->netdev))
537 return ksdazzle_change_speed(kingsun,
546 if (netif_running(kingsun->netdev))
547 irda_device_set_media_busy(kingsun->netdev, TRUE);
552 irq->ifr_receiving = kingsun->receiving;
581 struct ksdazzle_cb *kingsun = NULL;
622 net = alloc_irdadev(sizeof(*kingsun));
627 kingsun = netdev_priv(net);
628 kingsun->netdev = net;
629 kingsun->usbdev = dev;
630 kingsun->ep_in = ep_in;
631 kingsun->ep_out = ep_out;
632 kingsun->irlap = NULL;
633 kingsun->tx_urb = NULL;
634 kingsun->tx_buf_clear = NULL;
635 kingsun->tx_buf_clear_used = 0;
636 kingsun->tx_buf_clear_sent = 0;
638 kingsun->rx_urb = NULL;
639 kingsun->rx_buf = NULL;
640 kingsun->rx_unwrap_buff.in_frame = FALSE;
641 kingsun->rx_unwrap_buff.state = OUTSIDE_FRAME;
642 kingsun->rx_unwrap_buff.skb = NULL;
643 kingsun->receiving = 0;
644 spin_lock_init(&kingsun->lock);
646 kingsun->speed_setuprequest = NULL;
647 kingsun->speed_urb = NULL;
648 kingsun->speedparams.baudrate = 0;
651 kingsun->rx_buf = kmalloc(KINGSUN_RCV_MAX, GFP_KERNEL);
652 if (!kingsun->rx_buf)
656 kingsun->tx_buf_clear = kmalloc(KINGSUN_SND_FIFO_SIZE, GFP_KERNEL);
657 if (!kingsun->tx_buf_clear)
661 kingsun->speed_setuprequest =
663 if (!kingsun->speed_setuprequest)
665 kingsun->speed_setuprequest->bRequestType =
667 kingsun->speed_setuprequest->bRequest = KINGSUN_REQ_SEND;
668 kingsun->speed_setuprequest->wValue = cpu_to_le16(0x0200);
669 kingsun->speed_setuprequest->wIndex = cpu_to_le16(0x0001);
670 kingsun->speed_setuprequest->wLength =
679 irda_init_max_qos_capabilies(&kingsun->qos);
685 kingsun->qos.baud_rate.bits =
687 kingsun->qos.min_turn_time.bits &= KINGSUN_MTT;
688 irda_qos_bits_to_value(&kingsun->qos);
700 usb_set_intfdata(intf, kingsun);
713 kfree(kingsun->speed_setuprequest);
714 kfree(kingsun->tx_buf_clear);
715 kfree(kingsun->rx_buf);
726 struct ksdazzle_cb *kingsun = usb_get_intfdata(intf);
728 if (!kingsun)
731 unregister_netdev(kingsun->netdev);
734 usb_kill_urb(kingsun->speed_urb);
735 usb_free_urb(kingsun->speed_urb);
736 kingsun->speed_urb = NULL;
738 usb_kill_urb(kingsun->tx_urb);
739 usb_free_urb(kingsun->tx_urb);
740 kingsun->tx_urb = NULL;
742 usb_kill_urb(kingsun->rx_urb);
743 usb_free_urb(kingsun->rx_urb);
744 kingsun->rx_urb = NULL;
746 kfree(kingsun->speed_setuprequest);
747 kfree(kingsun->tx_buf_clear);
748 kfree(kingsun->rx_buf);
749 free_netdev(kingsun->netdev);
758 struct ksdazzle_cb *kingsun = usb_get_intfdata(intf);
760 netif_device_detach(kingsun->netdev);
761 if (kingsun->speed_urb != NULL)
762 usb_kill_urb(kingsun->speed_urb);
763 if (kingsun->tx_urb != NULL)
764 usb_kill_urb(kingsun->tx_urb);
765 if (kingsun->rx_urb != NULL)
766 usb_kill_urb(kingsun->rx_urb);
773 struct ksdazzle_cb *kingsun = usb_get_intfdata(intf);
775 if (kingsun->rx_urb != NULL) {
777 usb_submit_urb(kingsun->rx_urb, GFP_KERNEL);
779 netif_device_attach(kingsun->netdev);