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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*
* This file contains the code which performs automatic recalibration of the
* Airoha transceiver.
*
* Copyright (C) 2009 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*/
#ifndef AIROHA_CALIBRATION_H
#define AIROHA_CALIBRATION_H
#include "pipermain.h"
#define MAX_SAMPLES (3)
/*
* Field values used for computing ABS values.
*/
enum {
OUT_POWER,
ADC_VAL,
POWER_INDEX
};
#ifdef WANT_CAL_DEBUG
static const char *fieldDescription[] = {
"OUT_POWER",
"ADC_VAL",
"POWER_INDEX"
};
#endif
/*
* States for the auto calibration thread.
*/
enum {
RESTART_STATE,
COLLECT_SAMPLES_STATE,
GOT_SAMPLE_STATE,
RECALIBRATE_STATE
};
#ifdef WANT_CAL_DEBUG
static const char *stateText[] = {
"RESTART_STATE",
"COLLECT_SAMPLES_STATE",
"GOT_SAMPLE_STATE",
"RECALIBRATE_STATE"
};
#endif
/*
* Slope types accepted by computeSlope().
*/
enum {
POWER_INDEX_OVER_OUT_POWER,
ADC_OVER_OUT_POWER,
OUT_POWER_OVER_ADC,
POWER_INDEX_OVER_ADC
};
typedef struct {
unsigned rate; /* rate packet transmitted at */
unsigned int sample; /* measured sample */
} sampleInfo_t;
struct airohaCalibrationData {
struct task_struct *threadCB;
spinlock_t lock;
volatile unsigned int events;
unsigned int sampleCount;
sampleInfo_t sample[MAX_SAMPLES];
wcd_data_t *nvram;
wcd_curve_t *curve;
int slopeTimes1000;
int adcSlopeTimes1000;
int outPowerSlopeTimes1000;
int powerIndexSlopeTimes1000;
int expectedAdc;
int powerIndex, correctedPowerIndex;
wcd_point_t *p1;
void *priv;
struct calibration_ops *cops;
bool initialized;
};
struct calibration_ops {
u16(*adc_read_peak) (struct airohaCalibrationData *);
void (*adc_clear_peak) (struct airohaCalibrationData *);
u16(*adc_read_last_val) (struct airohaCalibrationData *);
void (*adc_shutdown) (struct airohaCalibrationData *);
};
void digiWifiInitCalibration(struct piper_priv *digi);
void digiWifiDeInitCalibration(struct piper_priv *digi);
int digiWifiCalibrationPowerIndex(struct piper_priv *piperp);
#endif /* AIROHA_CALIBRATION_H */
|