Lines Matching refs:yld
129 static int setChar(struct yealink_dev *yld, int el, int chr) in setChar() argument
139 yld->lcdMap[el] = chr; in setChar()
145 yld->master.b[a] |= m; in setChar()
147 yld->master.b[a] &= ~m; in setChar()
160 yld->master.b[a] |= m; in setChar()
162 yld->master.b[a] &= ~m; in setChar()
222 static void report_key(struct yealink_dev *yld, int key) in report_key() argument
224 struct input_dev *idev = yld->idev; in report_key()
226 if (yld->key_code >= 0) { in report_key()
228 input_report_key(idev, yld->key_code & 0xff, 0); in report_key()
229 if (yld->key_code >> 8) in report_key()
230 input_report_key(idev, yld->key_code >> 8, 0); in report_key()
233 yld->key_code = key; in report_key()
247 static int yealink_cmd(struct yealink_dev *yld, struct yld_ctl_packet *p) in yealink_cmd() argument
256 return usb_control_msg(yld->udev, in yealink_cmd()
257 usb_sndctrlpipe(yld->udev, 0), in yealink_cmd()
279 static int yealink_set_ringtone(struct yealink_dev *yld, u8 *buf, size_t size) in yealink_set_ringtone() argument
281 struct yld_ctl_packet *p = yld->ctl_data; in yealink_set_ringtone()
288 memset(yld->ctl_data, 0, sizeof(*(yld->ctl_data))); in yealink_set_ringtone()
289 yld->ctl_data->cmd = CMD_RING_VOLUME; in yealink_set_ringtone()
290 yld->ctl_data->size = 1; in yealink_set_ringtone()
291 yld->ctl_data->data[0] = buf[0]; in yealink_set_ringtone()
292 yealink_cmd(yld, p); in yealink_set_ringtone()
306 yealink_cmd(yld, p); in yealink_set_ringtone()
314 static int yealink_do_idle_tasks(struct yealink_dev *yld) in yealink_do_idle_tasks() argument
319 ix = yld->stat_ix; in yealink_do_idle_tasks()
321 memset(yld->ctl_data, 0, sizeof(*(yld->ctl_data))); in yealink_do_idle_tasks()
322 yld->ctl_data->cmd = CMD_KEYPRESS; in yealink_do_idle_tasks()
323 yld->ctl_data->size = 1; in yealink_do_idle_tasks()
324 yld->ctl_data->sum = 0xff - CMD_KEYPRESS; in yealink_do_idle_tasks()
327 if (ix >= sizeof(yld->master)) { in yealink_do_idle_tasks()
328 yld->stat_ix = 0; in yealink_do_idle_tasks()
334 val = yld->master.b[ix]; in yealink_do_idle_tasks()
335 if (val != yld->copy.b[ix]) in yealink_do_idle_tasks()
337 } while (++ix < sizeof(yld->master)); in yealink_do_idle_tasks()
340 yld->stat_ix = 0; in yealink_do_idle_tasks()
349 yld->copy.b[ix] = val; in yealink_do_idle_tasks()
350 yld->ctl_data->data[0] = val; in yealink_do_idle_tasks()
354 yld->ctl_data->cmd = CMD_LED; in yealink_do_idle_tasks()
355 yld->ctl_data->sum = -1 - CMD_LED - val; in yealink_do_idle_tasks()
358 yld->ctl_data->cmd = CMD_DIALTONE; in yealink_do_idle_tasks()
359 yld->ctl_data->sum = -1 - CMD_DIALTONE - val; in yealink_do_idle_tasks()
362 yld->ctl_data->cmd = CMD_RINGTONE; in yealink_do_idle_tasks()
363 yld->ctl_data->sum = -1 - CMD_RINGTONE - val; in yealink_do_idle_tasks()
368 yld->ctl_data->cmd = CMD_SCANCODE; in yealink_do_idle_tasks()
369 yld->ctl_data->offset = cpu_to_be16(val); in yealink_do_idle_tasks()
370 yld->ctl_data->data[0] = 0; in yealink_do_idle_tasks()
371 yld->ctl_data->sum = -1 - CMD_SCANCODE - val; in yealink_do_idle_tasks()
374 len = sizeof(yld->master.s.lcd) - ix; in yealink_do_idle_tasks()
375 if (len > sizeof(yld->ctl_data->data)) in yealink_do_idle_tasks()
376 len = sizeof(yld->ctl_data->data); in yealink_do_idle_tasks()
380 yld->ctl_data->cmd = CMD_LCD; in yealink_do_idle_tasks()
381 yld->ctl_data->offset = cpu_to_be16(ix); in yealink_do_idle_tasks()
382 yld->ctl_data->size = len; in yealink_do_idle_tasks()
383 yld->ctl_data->sum = -CMD_LCD - ix - val - len; in yealink_do_idle_tasks()
386 val = yld->master.b[ix]; in yealink_do_idle_tasks()
387 yld->copy.b[ix] = val; in yealink_do_idle_tasks()
388 yld->ctl_data->data[i] = val; in yealink_do_idle_tasks()
389 yld->ctl_data->sum -= val; in yealink_do_idle_tasks()
392 yld->stat_ix = ix + 1; in yealink_do_idle_tasks()
412 struct yealink_dev *yld = urb->context; in urb_irq_callback() local
416 dev_err(&yld->intf->dev, "%s - urb status %d\n", in urb_irq_callback()
419 switch (yld->irq_data->cmd) { in urb_irq_callback()
422 yld->master.s.keynum = yld->irq_data->data[0]; in urb_irq_callback()
426 dev_dbg(&yld->intf->dev, "get scancode %x\n", in urb_irq_callback()
427 yld->irq_data->data[0]); in urb_irq_callback()
429 report_key(yld, map_p1k_to_key(yld->irq_data->data[0])); in urb_irq_callback()
433 dev_err(&yld->intf->dev, "unexpected response %x\n", in urb_irq_callback()
434 yld->irq_data->cmd); in urb_irq_callback()
437 yealink_do_idle_tasks(yld); in urb_irq_callback()
439 if (!yld->shutdown) { in urb_irq_callback()
440 ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC); in urb_irq_callback()
442 dev_err(&yld->intf->dev, in urb_irq_callback()
450 struct yealink_dev *yld = urb->context; in urb_ctl_callback() local
454 dev_err(&yld->intf->dev, "%s - urb status %d\n", in urb_ctl_callback()
457 switch (yld->ctl_data->cmd) { in urb_ctl_callback()
461 if (!yld->shutdown) in urb_ctl_callback()
462 ret = usb_submit_urb(yld->urb_irq, GFP_ATOMIC); in urb_ctl_callback()
466 yealink_do_idle_tasks(yld); in urb_ctl_callback()
467 if (!yld->shutdown) in urb_ctl_callback()
468 ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC); in urb_ctl_callback()
473 dev_err(&yld->intf->dev, "%s - usb_submit_urb failed %d\n", in urb_ctl_callback()
503 struct yealink_dev *yld = input_get_drvdata(dev); in input_open() local
506 dev_dbg(&yld->intf->dev, "%s\n", __func__); in input_open()
509 for (i = 0; i<sizeof(yld->master); i++) in input_open()
510 yld->copy.b[i] = ~yld->master.b[i]; in input_open()
511 yld->key_code = -1; /* no keys pressed */ in input_open()
513 yealink_set_ringtone(yld, default_ringtone, sizeof(default_ringtone)); in input_open()
516 memset(yld->ctl_data, 0, sizeof(*(yld->ctl_data))); in input_open()
517 yld->ctl_data->cmd = CMD_INIT; in input_open()
518 yld->ctl_data->size = 10; in input_open()
519 yld->ctl_data->sum = 0x100-CMD_INIT-10; in input_open()
520 if ((ret = usb_submit_urb(yld->urb_ctl, GFP_KERNEL)) != 0) { in input_open()
521 dev_dbg(&yld->intf->dev, in input_open()
531 struct yealink_dev *yld = input_get_drvdata(dev); in input_close() local
533 yld->shutdown = 1; in input_close()
540 usb_kill_urb(yld->urb_ctl); in input_close()
541 usb_kill_urb(yld->urb_irq); in input_close()
543 yld->shutdown = 0; in input_close()
583 struct yealink_dev *yld; in show_line() local
587 yld = dev_get_drvdata(dev); in show_line()
588 if (yld == NULL) { in show_line()
597 *buf++ = yld->lcdMap[i]; in show_line()
633 struct yealink_dev *yld; in store_line() local
637 yld = dev_get_drvdata(dev); in store_line()
638 if (yld == NULL) { in store_line()
646 setChar(yld, el++, buf[i]); in store_line()
678 struct yealink_dev *yld; in get_icons() local
682 yld = dev_get_drvdata(dev); in get_icons()
683 if (yld == NULL) { in get_icons()
692 yld->lcdMap[i] == ' ' ? " " : "on", in get_icons()
703 struct yealink_dev *yld; in set_icon() local
707 yld = dev_get_drvdata(dev); in set_icon()
708 if (yld == NULL) { in set_icon()
717 setChar(yld, i, chr); in set_icon()
746 struct yealink_dev *yld; in store_ringtone() local
749 yld = dev_get_drvdata(dev); in store_ringtone()
750 if (yld == NULL) { in store_ringtone()
756 yealink_set_ringtone(yld, (char *)buf, count); in store_ringtone()
816 static int usb_cleanup(struct yealink_dev *yld, int err) in usb_cleanup() argument
818 if (yld == NULL) in usb_cleanup()
821 if (yld->idev) { in usb_cleanup()
823 input_free_device(yld->idev); in usb_cleanup()
825 input_unregister_device(yld->idev); in usb_cleanup()
828 usb_free_urb(yld->urb_irq); in usb_cleanup()
829 usb_free_urb(yld->urb_ctl); in usb_cleanup()
831 kfree(yld->ctl_req); in usb_cleanup()
832 usb_free_coherent(yld->udev, USB_PKT_LEN, yld->ctl_data, yld->ctl_dma); in usb_cleanup()
833 usb_free_coherent(yld->udev, USB_PKT_LEN, yld->irq_data, yld->irq_dma); in usb_cleanup()
835 kfree(yld); in usb_cleanup()
841 struct yealink_dev *yld; in usb_disconnect() local
844 yld = usb_get_intfdata(intf); in usb_disconnect()
849 usb_cleanup(yld, 0); in usb_disconnect()
858 struct yealink_dev *yld; in usb_probe() local
871 yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); in usb_probe()
872 if (!yld) in usb_probe()
875 yld->udev = udev; in usb_probe()
876 yld->intf = intf; in usb_probe()
878 yld->idev = input_dev = input_allocate_device(); in usb_probe()
880 return usb_cleanup(yld, -ENOMEM); in usb_probe()
883 yld->irq_data = usb_alloc_coherent(udev, USB_PKT_LEN, in usb_probe()
884 GFP_KERNEL, &yld->irq_dma); in usb_probe()
885 if (yld->irq_data == NULL) in usb_probe()
886 return usb_cleanup(yld, -ENOMEM); in usb_probe()
888 yld->ctl_data = usb_alloc_coherent(udev, USB_PKT_LEN, in usb_probe()
889 GFP_KERNEL, &yld->ctl_dma); in usb_probe()
890 if (!yld->ctl_data) in usb_probe()
891 return usb_cleanup(yld, -ENOMEM); in usb_probe()
893 yld->ctl_req = kmalloc(sizeof(*(yld->ctl_req)), GFP_KERNEL); in usb_probe()
894 if (yld->ctl_req == NULL) in usb_probe()
895 return usb_cleanup(yld, -ENOMEM); in usb_probe()
898 yld->urb_irq = usb_alloc_urb(0, GFP_KERNEL); in usb_probe()
899 if (yld->urb_irq == NULL) in usb_probe()
900 return usb_cleanup(yld, -ENOMEM); in usb_probe()
902 yld->urb_ctl = usb_alloc_urb(0, GFP_KERNEL); in usb_probe()
903 if (yld->urb_ctl == NULL) in usb_probe()
904 return usb_cleanup(yld, -ENOMEM); in usb_probe()
914 usb_fill_int_urb(yld->urb_irq, udev, pipe, yld->irq_data, in usb_probe()
917 yld, endpoint->bInterval); in usb_probe()
918 yld->urb_irq->transfer_dma = yld->irq_dma; in usb_probe()
919 yld->urb_irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in usb_probe()
920 yld->urb_irq->dev = udev; in usb_probe()
923 yld->ctl_req->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | in usb_probe()
925 yld->ctl_req->bRequest = USB_REQ_SET_CONFIGURATION; in usb_probe()
926 yld->ctl_req->wValue = cpu_to_le16(0x200); in usb_probe()
927 yld->ctl_req->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); in usb_probe()
928 yld->ctl_req->wLength = cpu_to_le16(USB_PKT_LEN); in usb_probe()
930 usb_fill_control_urb(yld->urb_ctl, udev, usb_sndctrlpipe(udev, 0), in usb_probe()
931 (void *)yld->ctl_req, yld->ctl_data, USB_PKT_LEN, in usb_probe()
932 urb_ctl_callback, yld); in usb_probe()
933 yld->urb_ctl->transfer_dma = yld->ctl_dma; in usb_probe()
934 yld->urb_ctl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in usb_probe()
935 yld->urb_ctl->dev = udev; in usb_probe()
938 usb_make_path(udev, yld->phys, sizeof(yld->phys)); in usb_probe()
939 strlcat(yld->phys, "/input0", sizeof(yld->phys)); in usb_probe()
943 input_dev->phys = yld->phys; in usb_probe()
947 input_set_drvdata(input_dev, yld); in usb_probe()
964 ret = input_register_device(yld->idev); in usb_probe()
966 return usb_cleanup(yld, ret); in usb_probe()
968 usb_set_intfdata(intf, yld); in usb_probe()
972 setChar(yld, i, ' '); in usb_probe()