Lines Matching defs:kingsun
10 * Based on stir4200, mcs7780, kingsun-sir drivers.
66 * kingsun-sir.c) with control URBs and the following as a setup packet:
256 static int ks959_change_speed(struct ks959_cb *kingsun, unsigned speed)
264 if (kingsun->speed_setuprequest == NULL || kingsun->speed_urb == NULL)
272 memset(&(kingsun->speedparams), 0, sizeof(struct ks959_speedparams));
273 kingsun->speedparams.baudrate = cpu_to_le32(speed);
274 kingsun->speedparams.flags = KS_DATA_8_BITS;
277 usb_fill_control_urb(kingsun->speed_urb, kingsun->usbdev,
278 usb_sndctrlpipe(kingsun->usbdev, 0),
279 (unsigned char *)kingsun->speed_setuprequest,
280 &(kingsun->speedparams),
282 kingsun);
283 kingsun->speed_urb->status = 0;
284 err = usb_submit_urb(kingsun->speed_urb, GFP_ATOMIC);
291 static int ks959_submit_tx_fragment(struct ks959_cb *kingsun)
300 if (wraplen > kingsun->tx_buf_clear_used)
301 wraplen = kingsun->tx_buf_clear_used;
305 padlen = obfuscate_tx_buffer(kingsun->tx_buf_clear, wraplen,
306 kingsun->tx_buf_xored,
310 kingsun->tx_setuprequest->wValue = cpu_to_le16(wraplen);
311 kingsun->tx_setuprequest->wLength = cpu_to_le16(padlen);
313 usb_fill_control_urb(kingsun->tx_urb, kingsun->usbdev,
314 usb_sndctrlpipe(kingsun->usbdev, 0),
315 (unsigned char *)kingsun->tx_setuprequest,
316 kingsun->tx_buf_xored, padlen,
317 ks959_send_irq, kingsun);
318 kingsun->tx_urb->status = 0;
319 ret = usb_submit_urb(kingsun->tx_urb, GFP_ATOMIC);
322 kingsun->tx_buf_clear_sent = (ret == 0) ? wraplen : 0;
329 struct ks959_cb *kingsun = urb->context;
330 struct net_device *netdev = kingsun->netdev;
334 if (!netif_running(kingsun->netdev)) {
346 if (kingsun->tx_buf_clear_used > 0) {
348 if (kingsun->tx_buf_clear_sent < kingsun->tx_buf_clear_used) {
349 memmove(kingsun->tx_buf_clear,
350 kingsun->tx_buf_clear +
351 kingsun->tx_buf_clear_sent,
352 kingsun->tx_buf_clear_used -
353 kingsun->tx_buf_clear_sent);
355 kingsun->tx_buf_clear_used -= kingsun->tx_buf_clear_sent;
356 kingsun->tx_buf_clear_sent = 0;
358 if (kingsun->tx_buf_clear_used > 0) {
360 if ((ret = ks959_submit_tx_fragment(kingsun)) != 0) {
374 if (kingsun->new_speed != -1 &&
375 cpu_to_le32(kingsun->new_speed) !=
376 kingsun->speedparams.baudrate)
377 ks959_change_speed(kingsun, kingsun->new_speed);
390 struct ks959_cb *kingsun;
399 kingsun = netdev_priv(netdev);
401 spin_lock(&kingsun->lock);
402 kingsun->new_speed = irda_get_next_speed(skb);
406 async_wrap_skb(skb, kingsun->tx_buf_clear, KINGSUN_SND_FIFO_SIZE);
407 kingsun->tx_buf_clear_used = wraplen;
409 if ((ret = ks959_submit_tx_fragment(kingsun)) != 0) {
426 spin_unlock(&kingsun->lock);
434 struct ks959_cb *kingsun = urb->context;
438 if (!netif_running(kingsun->netdev)) {
439 kingsun->receiving = 0;
447 kingsun->receiving = 0;
460 kingsun->rx_variable_xormask++;
462 bytes[i] ^ kingsun->rx_variable_xormask ^ 0x55u;
467 if (kingsun->rx_variable_xormask != 0) {
468 async_unwrap_char(kingsun->netdev,
469 &kingsun->netdev->stats,
470 &kingsun->rx_unwrap_buff,
474 do_gettimeofday(&kingsun->rx_time);
475 kingsun->receiving =
476 (kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0;
495 struct ks959_cb *kingsun = netdev_priv(netdev);
500 kingsun->receiving = 0;
503 kingsun->rx_unwrap_buff.in_frame = FALSE;
504 kingsun->rx_unwrap_buff.state = OUTSIDE_FRAME;
505 kingsun->rx_unwrap_buff.truesize = IRDA_SKB_MAX_MTU;
506 kingsun->rx_unwrap_buff.skb = dev_alloc_skb(IRDA_SKB_MAX_MTU);
507 if (!kingsun->rx_unwrap_buff.skb)
510 skb_reserve(kingsun->rx_unwrap_buff.skb, 1);
511 kingsun->rx_unwrap_buff.head = kingsun->rx_unwrap_buff.skb->data;
512 do_gettimeofday(&kingsun->rx_time);
514 kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
515 if (!kingsun->rx_urb)
518 kingsun->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
519 if (!kingsun->tx_urb)
522 kingsun->speed_urb = usb_alloc_urb(0, GFP_KERNEL);
523 if (!kingsun->speed_urb)
527 kingsun->new_speed = 9600;
528 err = ks959_change_speed(kingsun, 9600);
536 sprintf(hwname, "usb#%d", kingsun->usbdev->devnum);
537 kingsun->irlap = irlap_open(netdev, &kingsun->qos, hwname);
538 if (!kingsun->irlap) {
544 usb_fill_control_urb(kingsun->rx_urb, kingsun->usbdev,
545 usb_rcvctrlpipe(kingsun->usbdev, 0),
546 (unsigned char *)kingsun->rx_setuprequest,
547 kingsun->rx_buf, KINGSUN_RCV_FIFO_SIZE,
548 ks959_rcv_irq, kingsun);
549 kingsun->rx_urb->status = 0;
550 err = usb_submit_urb(kingsun->rx_urb, GFP_KERNEL);
570 irlap_close(kingsun->irlap);
572 usb_free_urb(kingsun->speed_urb);
573 kingsun->speed_urb = NULL;
574 usb_free_urb(kingsun->tx_urb);
575 kingsun->tx_urb = NULL;
576 usb_free_urb(kingsun->rx_urb);
577 kingsun->rx_urb = NULL;
578 if (kingsun->rx_unwrap_buff.skb) {
579 kfree_skb(kingsun->rx_unwrap_buff.skb);
580 kingsun->rx_unwrap_buff.skb = NULL;
581 kingsun->rx_unwrap_buff.head = NULL;
587 * Function kingsun_net_close (kingsun)
594 struct ks959_cb *kingsun = netdev_priv(netdev);
600 usb_kill_urb(kingsun->tx_urb);
601 usb_free_urb(kingsun->tx_urb);
602 kingsun->tx_urb = NULL;
604 usb_kill_urb(kingsun->speed_urb);
605 usb_free_urb(kingsun->speed_urb);
606 kingsun->speed_urb = NULL;
608 usb_kill_urb(kingsun->rx_urb);
609 usb_free_urb(kingsun->rx_urb);
610 kingsun->rx_urb = NULL;
612 kfree_skb(kingsun->rx_unwrap_buff.skb);
613 kingsun->rx_unwrap_buff.skb = NULL;
614 kingsun->rx_unwrap_buff.head = NULL;
615 kingsun->rx_unwrap_buff.in_frame = FALSE;
616 kingsun->rx_unwrap_buff.state = OUTSIDE_FRAME;
617 kingsun->receiving = 0;
620 if (kingsun->irlap)
621 irlap_close(kingsun->irlap);
623 kingsun->irlap = NULL;
634 struct ks959_cb *kingsun = netdev_priv(netdev);
643 if (netif_device_present(kingsun->netdev))
644 return ks959_change_speed(kingsun, irq->ifr_baudrate);
652 if (netif_running(kingsun->netdev))
653 irda_device_set_media_busy(kingsun->netdev, TRUE);
658 irq->ifr_receiving = kingsun->receiving;
683 struct ks959_cb *kingsun = NULL;
688 net = alloc_irdadev(sizeof(*kingsun));
693 kingsun = netdev_priv(net);
694 kingsun->netdev = net;
695 kingsun->usbdev = dev;
696 kingsun->irlap = NULL;
697 kingsun->tx_setuprequest = NULL;
698 kingsun->tx_urb = NULL;
699 kingsun->tx_buf_clear = NULL;
700 kingsun->tx_buf_xored = NULL;
701 kingsun->tx_buf_clear_used = 0;
702 kingsun->tx_buf_clear_sent = 0;
704 kingsun->rx_setuprequest = NULL;
705 kingsun->rx_urb = NULL;
706 kingsun->rx_buf = NULL;
707 kingsun->rx_variable_xormask = 0;
708 kingsun->rx_unwrap_buff.in_frame = FALSE;
709 kingsun->rx_unwrap_buff.state = OUTSIDE_FRAME;
710 kingsun->rx_unwrap_buff.skb = NULL;
711 kingsun->receiving = 0;
712 spin_lock_init(&kingsun->lock);
714 kingsun->speed_setuprequest = NULL;
715 kingsun->speed_urb = NULL;
716 kingsun->speedparams.baudrate = 0;
719 kingsun->rx_buf = kmalloc(KINGSUN_RCV_FIFO_SIZE, GFP_KERNEL);
720 if (!kingsun->rx_buf)
724 kingsun->rx_setuprequest =
726 if (!kingsun->rx_setuprequest)
728 kingsun->rx_setuprequest->bRequestType =
730 kingsun->rx_setuprequest->bRequest = KINGSUN_REQ_RECV;
731 kingsun->rx_setuprequest->wValue = cpu_to_le16(0x0200);
732 kingsun->rx_setuprequest->wIndex = 0;
733 kingsun->rx_setuprequest->wLength = cpu_to_le16(KINGSUN_RCV_FIFO_SIZE);
736 kingsun->tx_buf_clear = kmalloc(KINGSUN_SND_FIFO_SIZE, GFP_KERNEL);
737 if (!kingsun->tx_buf_clear)
739 kingsun->tx_buf_xored = kmalloc(KINGSUN_SND_PACKET_SIZE, GFP_KERNEL);
740 if (!kingsun->tx_buf_xored)
744 kingsun->tx_setuprequest =
746 if (!kingsun->tx_setuprequest)
748 kingsun->tx_setuprequest->bRequestType =
750 kingsun->tx_setuprequest->bRequest = KINGSUN_REQ_SEND;
751 kingsun->tx_setuprequest->wValue = 0;
752 kingsun->tx_setuprequest->wIndex = 0;
753 kingsun->tx_setuprequest->wLength = 0;
756 kingsun->speed_setuprequest =
758 if (!kingsun->speed_setuprequest)
760 kingsun->speed_setuprequest->bRequestType =
762 kingsun->speed_setuprequest->bRequest = KINGSUN_REQ_SEND;
763 kingsun->speed_setuprequest->wValue = cpu_to_le16(0x0200);
764 kingsun->speed_setuprequest->wIndex = cpu_to_le16(0x0001);
765 kingsun->speed_setuprequest->wLength =
774 irda_init_max_qos_capabilies(&kingsun->qos);
780 kingsun->qos.baud_rate.bits =
782 kingsun->qos.min_turn_time.bits &= KINGSUN_MTT;
783 irda_qos_bits_to_value(&kingsun->qos);
795 usb_set_intfdata(intf, kingsun);
808 kfree(kingsun->speed_setuprequest);
809 kfree(kingsun->tx_setuprequest);
810 kfree(kingsun->tx_buf_xored);
811 kfree(kingsun->tx_buf_clear);
812 kfree(kingsun->rx_setuprequest);
813 kfree(kingsun->rx_buf);
824 struct ks959_cb *kingsun = usb_get_intfdata(intf);
826 if (!kingsun)
829 unregister_netdev(kingsun->netdev);
832 if (kingsun->speed_urb != NULL) {
833 usb_kill_urb(kingsun->speed_urb);
834 usb_free_urb(kingsun->speed_urb);
835 kingsun->speed_urb = NULL;
837 if (kingsun->tx_urb != NULL) {
838 usb_kill_urb(kingsun->tx_urb);
839 usb_free_urb(kingsun->tx_urb);
840 kingsun->tx_urb = NULL;
842 if (kingsun->rx_urb != NULL) {
843 usb_kill_urb(kingsun->rx_urb);
844 usb_free_urb(kingsun->rx_urb);
845 kingsun->rx_urb = NULL;
848 kfree(kingsun->speed_setuprequest);
849 kfree(kingsun->tx_setuprequest);
850 kfree(kingsun->tx_buf_xored);
851 kfree(kingsun->tx_buf_clear);
852 kfree(kingsun->rx_setuprequest);
853 kfree(kingsun->rx_buf);
854 free_netdev(kingsun->netdev);
863 struct ks959_cb *kingsun = usb_get_intfdata(intf);
865 netif_device_detach(kingsun->netdev);
866 if (kingsun->speed_urb != NULL)
867 usb_kill_urb(kingsun->speed_urb);
868 if (kingsun->tx_urb != NULL)
869 usb_kill_urb(kingsun->tx_urb);
870 if (kingsun->rx_urb != NULL)
871 usb_kill_urb(kingsun->rx_urb);
878 struct ks959_cb *kingsun = usb_get_intfdata(intf);
880 if (kingsun->rx_urb != NULL) {
882 usb_submit_urb(kingsun->rx_urb, GFP_KERNEL);
884 netif_device_attach(kingsun->netdev);