summaryrefslogtreecommitdiff
path: root/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c
blob: c0578bc09bc5c284613ce173e96a966c7f652e61 (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
49
50
51
52
53
54
55
56
57
58
59
60
/* Copyright 2017 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
/* FPC Platform Abstraction Layer callbacks */

#include "common.h"
#include "console.h"
#include "fpsensor.h"
#include "fpc_sensor_pal.h"
#include "shared_mem.h"
#include "spi.h"
#include "timer.h"
#include "uart.h"
#include "util.h"

#define CPRINTF(format, args...) cprintf(CC_FP, format, ##args)
#define CPRINTS(format, args...) cprints(CC_FP, format, ##args)

void fpc_pal_log_entry(const char *tag, int log_level, const char *format, ...)
{
	va_list args;

	va_start(args, format);
	uart_puts(tag);
	uart_vprintf(format, args);
	va_end(args);
}

int fpc_pal_delay_us(uint64_t us)
{
	if (us > 250)
		usleep(us);
	else
		udelay(us);
	return 0;
}

int fpc_pal_spi_writeread(fpc_device_t device, uint8_t *tx_buf, uint8_t *rx_buf,
			  uint32_t size)
{
	return spi_transaction(SPI_FP_DEVICE, tx_buf, size, rx_buf,
			       SPI_READBACK_ALL);
}

int fpc_pal_wait_irq(fpc_device_t device, fpc_pal_irq_t irq_type)
{
	/* TODO: b/72360575 */
	return EC_SUCCESS; /* just lie about it, libfpsensor prefers... */
}

int32_t FpcMalloc(void **data, size_t size)
{
	return shared_mem_acquire(size, (char **)data);
}

void FpcFree(void **data)
{
	shared_mem_release(*data);
}