blob: 38a4859376498a88a2f1f73b6f1301682807e419 [file] [log] [blame]
Kyle Swensoncc33c242022-05-16 10:38:04 -06001/*
2 * ./kernel_modules/qcom-adc/adc_averaging.h
3 *
4 * This is the header file for adc_averaging and defines the interface for
5 * users of the averaging logic
6 *
7 * Author: Cradlepoint Technology, Inc. <source@cradlepoint.com>
8 * Kyle Swenson <kswenson@cradlepoint.com>
9 *
10 * Copyright 2017 Cradlepoint Technology, Inc.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License version 2 as published by
14 * the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * more details.
20 *
21 */
22#ifndef __ADC_AVERAGING_H__
23#define __ADC_AVERAGING_H__
24
25#include <linux/kernel.h>
26#include <linux/mutex.h>
27
28#define MAX_SAMPLE_LENGTH 128
29struct adc_channel {
30 uint16_t *samples;
31 uint16_t total_length;
32 uint16_t index;
33 struct mutex lock;
Kyle Swenson89648b22022-05-16 10:56:50 -060034 struct device * parent;
Kyle Swensoncc33c242022-05-16 10:38:04 -060035};
36
37
38
39void free_adc_channel(struct adc_channel *ch);
Kyle Swenson89648b22022-05-16 10:56:50 -060040struct adc_channel *create_adc_channel(struct device * dev, uint16_t fifo_length);
Kyle Swensoncc33c242022-05-16 10:38:04 -060041uint16_t compute_average(struct adc_channel *ch);
42void add_sample(struct adc_channel *ch, uint16_t sample);
43
44void show_data(struct adc_channel *ch);
45int verify_average(struct adc_channel *ch);
46
47
48#endif