2 #include <linux/tapi/tapi.h>
4 #include <linux/input.h>
6 static unsigned short tapi_keycodes
[] = {
17 [10] = KEY_NUMERIC_STAR
,
18 [11] = KEY_NUMERIC_POUND
,
23 static int tapi_input_event(struct input_dev
*input
, unsigned int type
,
24 unsigned int code
, int value
)
26 struct tapi_device
*tdev
= dev_to_tapi(input
->dev
.parent
);
27 struct tapi_port
*port
= input_get_drvdata(input
);
30 if (type
!= EV_SND
|| code
!= SND_BELL
)
33 tapi_port_set_ring(tdev
, port
, value
);
38 void tapi_alloc_input(struct tapi_device
*tdev
, struct tapi_port
*port
)
40 struct input_dev
*input
;
44 input
= input_allocate_device();
46 phys
= kzalloc(sizeof("tapi/input000"), GFP_KERNEL
);
47 sprintf(phys
, "tapi/input%d", port
->id
);
51 input
->id
.bustype
= BUS_HOST
;
52 input
->dev
.parent
= &tdev
->dev
;
53 input
->evbit
[0] = BIT(EV_KEY
) | BIT(EV_SND
);
54 input
->sndbit
[0] = BIT(SND_BELL
);
56 input
->event
= tapi_input_event
;
58 input
->keycodesize
= sizeof(unsigned short);
59 input
->keycodemax
= ARRAY_SIZE(tapi_keycodes
);
60 input
->keycode
= tapi_keycodes
;
64 for (i
= 0; i
< ARRAY_SIZE(tapi_keycodes
); ++i
)
65 __set_bit(tapi_keycodes
[i
], input
->keybit
);
67 input_set_drvdata(input
, port
);
68 input_register_device(input
);
71 void tapi_report_event(struct tapi_device
*tdev
,
72 struct tapi_event
*event
)
74 unsigned short key_code
;
75 struct input_dev
*input
;
77 if (!tdev
|| !tdev
->ports
)
80 switch (event
->type
) {
81 case TAPI_EVENT_TYPE_HOOK
:
87 case TAPI_EVENT_TYPE_DTMF
:
88 key_code
= tapi_keycodes
[event
->dtmf
.code
];
94 input
= tdev
->ports
[event
->port
].input
;
95 input_report_key(input
, key_code
, 1);
97 input_report_key(input
, key_code
, 0);
This page took 0.048205 seconds and 5 git commands to generate.