33 #include <linux/sched.h>
49 static void ircomm_tty_ias_register(
struct ircomm_tty_cb *
self);
50 static void ircomm_tty_discovery_indication(
discinfo_t *discovery,
53 static void ircomm_tty_getvalue_confirm(
int result,
__u16 obj_id,
55 static void ircomm_tty_start_watchdog_timer(
struct ircomm_tty_cb *
self,
57 static void ircomm_tty_watchdog_timer_expired(
void *
data);
63 static int ircomm_tty_state_search(
struct ircomm_tty_cb *
self,
67 static int ircomm_tty_state_query_parameters(
struct ircomm_tty_cb *
self,
71 static int ircomm_tty_state_query_lsap_sel(
struct ircomm_tty_cb *
self,
87 "IRCOMM_TTY_QUERY_PARAMETERS",
88 "IRCOMM_TTY_QUERY_LSAP_SEL",
94 #ifdef CONFIG_IRDA_DEBUG
95 static const char *
const ircomm_tty_event[] = {
96 "IRCOMM_TTY_ATTACH_CABLE",
97 "IRCOMM_TTY_DETACH_CABLE",
98 "IRCOMM_TTY_DATA_REQUEST",
99 "IRCOMM_TTY_DATA_INDICATION",
100 "IRCOMM_TTY_DISCOVERY_REQUEST",
101 "IRCOMM_TTY_DISCOVERY_INDICATION",
102 "IRCOMM_TTY_CONNECT_CONFIRM",
103 "IRCOMM_TTY_CONNECT_INDICATION",
104 "IRCOMM_TTY_DISCONNECT_REQUEST",
105 "IRCOMM_TTY_DISCONNECT_INDICATION",
106 "IRCOMM_TTY_WD_TIMER_EXPIRED",
107 "IRCOMM_TTY_GOT_PARAMETERS",
108 "IRCOMM_TTY_GOT_LSAPSEL",
116 ircomm_tty_state_idle,
117 ircomm_tty_state_search,
118 ircomm_tty_state_query_parameters,
119 ircomm_tty_state_query_lsap_sel,
120 ircomm_tty_state_setup,
121 ircomm_tty_state_ready,
142 IRDA_DEBUG(0,
"%s(), already connected!\n", __func__ );
153 ircomm_tty_ias_register(
self);
200 self->daddr =
self->saddr = 0;
201 self->dlsap_sel =
self->slsap_sel = 0;
212 static void ircomm_tty_ias_register(
struct ircomm_tty_cb *
self)
233 ircomm_tty_discovery_indication,
234 NULL, (
void *)
self);
269 static void ircomm_tty_ias_unregister(
struct ircomm_tty_cb *
self)
318 IRDA_DEBUG(2,
"%s(), data-rate = %d\n", __func__ ,
319 self->settings.data_rate);
320 if (!self->settings.data_rate)
321 self->settings.data_rate = 9600;
322 IRDA_DEBUG(2,
"%s(), data-format = %d\n", __func__ ,
323 self->settings.data_format);
324 if (!self->settings.data_format)
327 IRDA_DEBUG(2,
"%s(), flow-control = %d\n", __func__ ,
328 self->settings.flow_control);
365 static void ircomm_tty_discovery_indication(
discinfo_t *discovery,
435 static void ircomm_tty_getvalue_confirm(
int result,
__u16 obj_id,
452 IRDA_DEBUG(4,
"%s(), got NULL value!\n", __func__ );
456 switch (value->
type) {
458 IRDA_DEBUG(2,
"%s(), got octet sequence\n", __func__ );
468 IRDA_DEBUG(2,
"%s(), got lsapsel = %d\n", __func__ ,
472 IRDA_DEBUG(0,
"%s(), invalid value!\n", __func__ );
479 IRDA_DEBUG(0,
"%s(), got IAS_MISSING\n", __func__ );
482 IRDA_DEBUG(0,
"%s(), got unknown type!\n", __func__ );
538 self->client =
FALSE;
581 if (tty_port_cts_enabled(&self->port) &&
583 IRDA_DEBUG(0,
"%s(), waiting for CTS ...\n", __func__ );
586 IRDA_DEBUG(1,
"%s(), starting hardware!\n", __func__ );
606 static void ircomm_tty_start_watchdog_timer(
struct ircomm_tty_cb *
self,
612 irda_start_timer(&self->watchdog_timer, timeout, (
void *)
self,
613 ircomm_tty_watchdog_timer_expired);
622 static void ircomm_tty_watchdog_timer_expired(
void *
data)
647 IRDA_DEBUG(2,
"%s: state=%s, event=%s\n", __func__ ,
684 IRDA_DEBUG(2,
"%s: state=%s, event=%s\n", __func__ ,
689 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
695 self->daddr = info->
daddr;
696 self->saddr = info->
saddr;
705 ircomm_tty_getvalue_confirm);
708 self->saddr, self->daddr,
709 "IrDA:IrCOMM",
"Parameters");
711 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
728 IRDA_DEBUG(2,
"%s(), unknown event: %s\n", __func__ ,
729 ircomm_tty_event[event]);
741 static int ircomm_tty_state_search(
struct ircomm_tty_cb *
self,
748 IRDA_DEBUG(2,
"%s: state=%s, event=%s\n", __func__ ,
753 self->daddr = info->
daddr;
754 self->saddr = info->
saddr;
763 ircomm_tty_getvalue_confirm);
767 self->daddr,
"IrLPT",
768 "IrDA:IrLMP:LsapSel");
778 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
782 ircomm_tty_ias_unregister(
self);
793 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
801 IRDA_DEBUG(2,
"%s(), unknown event: %s\n", __func__ ,
802 ircomm_tty_event[event]);
814 static int ircomm_tty_state_query_parameters(
struct ircomm_tty_cb *
self,
821 IRDA_DEBUG(2,
"%s: state=%s, event=%s\n", __func__ ,
833 ircomm_tty_getvalue_confirm);
836 self->daddr,
"IrDA:IrCOMM",
837 "IrDA:TinyTP:LsapSel");
839 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
845 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
849 ircomm_tty_ias_unregister(
self);
859 IRDA_DEBUG(2,
"%s(), unknown event: %s\n", __func__ ,
860 ircomm_tty_event[event]);
872 static int ircomm_tty_state_query_lsap_sel(
struct ircomm_tty_cb *
self,
879 IRDA_DEBUG(2,
"%s: state=%s, event=%s\n", __func__ ,
886 self->saddr, self->daddr,
887 NULL, self->service_type);
888 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
894 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
898 ircomm_tty_ias_unregister(
self);
908 IRDA_DEBUG(2,
"%s(), unknown event: %s\n", __func__ ,
909 ircomm_tty_event[event]);
921 static int ircomm_tty_state_setup(
struct ircomm_tty_cb *
self,
928 IRDA_DEBUG(2,
"%s: state=%s, event=%s\n", __func__ ,
934 ircomm_tty_ias_unregister(
self);
946 ircomm_tty_ias_unregister(
self);
955 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
962 IRDA_DEBUG(2,
"%s(), unknown event: %s\n", __func__ ,
963 ircomm_tty_event[event]);
975 static int ircomm_tty_state_ready(
struct ircomm_tty_cb *
self,
991 ircomm_tty_ias_register(
self);
993 ircomm_tty_start_watchdog_timer(
self, 3*
HZ);
1001 IRDA_DEBUG(0,
"%s(), hanging up!\n", __func__ );
1009 IRDA_DEBUG(2,
"%s(), unknown event: %s\n", __func__ ,
1010 ircomm_tty_event[event]);