blob: 1744d1ac47ba0582f282a9d5193c2af4ece1bca4 [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;
34};
35
36
37
38void free_adc_channel(struct adc_channel *ch);
39struct adc_channel *create_adc_channel(uint16_t fifo_length);
40uint16_t compute_average(struct adc_channel *ch);
41void add_sample(struct adc_channel *ch, uint16_t sample);
42
43void show_data(struct adc_channel *ch);
44int verify_average(struct adc_channel *ch);
45
46
47#endif