summaryrefslogtreecommitdiff
path: root/package/lqtapi/src/mps/vmmc-port.c
blob: aa620a1e024d3b43aba7730211175397eb956eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <linux/kernel.h>
#include <linux/slab.h>

#include <linux/tapi/tapi.h>

#include "vmmc.h"
#include "vmmc-port.h"
#include "vmmc-alm.h"
#include "vmmc-sig.h"

int vmmc_port_ring(struct tapi_device *tdev, struct tapi_port *port, bool ring)
{
	struct vmmc *vmmc = tdev_to_vmmc(tdev);

	return vmmc_alm_set_state(&vmmc->ports[port->id].alm,
		ring ? VMMC_ALM_STATE_RING : VMMC_ALM_STATE_ONHOOK);
}

int vmmc_port_send_dtmf_event(struct tapi_device *tdev,
	struct tapi_port *port, struct tapi_dtmf_event *event)
{
	return 0;
}

struct vmmc_port *vmmc_port_init(struct vmmc *vmmc, struct vmmc_port *port,
	struct tapi_port *tport, unsigned int id)
{
	vmmc_alm_init(&port->alm, vmmc, id);
	vmmc_sig_init(&port->sig, vmmc, id);

	port->sig_pin = vmmc_module_get_pin(&port->sig.module);
	vmmc_module_set_pin_input(&port->sig.module, port->sig_pin,
		&port->alm.module);

	vmmc_module_sync(&port->sig.module);

	vmmc_alm_set_state(&port->alm, VMMC_ALM_STATE_ONHOOK);

	tport->id = id;
	tapi_endpoint_set_data(&tport->ep, &port->alm.module);

	return port;
}

void vmmc_port_put(struct vmmc *vmmc, struct vmmc_port *port)
{
	vmmc_module_put_pin(&port->sig.module, port->sig_pin);
}