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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*
* Copyright (c) 2012-2015, The Linux Foundation. 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 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "tfa_dsp_fw.h"
#include "tfa_service.h"
#include "tfa_internal.h"
#include "tfa98xx_tfafieldnames.h"
static enum Tfa98xx_Error tfa9897_specific(Tfa98xx_handle_t handle)
{
enum Tfa98xx_Error error = Tfa98xx_Error_Ok;
unsigned short check_value;
if (!tfa98xx_handle_is_open(handle))
return Tfa98xx_Error_NotOpen;
/* all i2C registers must already set to default POR value */
/* $48:[3] - 1 ==> 0; iddqtestbst - default value changed.
* When Iddqtestbst is set to "0", the slewrate is reduced.
* This will lower the overshoot on IN-B to avoid NMOS damage of booster.
*/
error = tfa98xx_write_register16(handle, 0x48, 0x0300); /* POR value = 0x308 */
/* $49:[0] - 1 ==> 0; CLIP - default value changed. 0 means CLIPPER on
*/
error = tfa98xx_read_register16(handle, 0x49, &check_value);
check_value &= ~0x1;
error = tfa98xx_write_register16(handle, 0x49, check_value);
return error;
}
/*
* the int24 values for the vsfw delay table
*/
static unsigned char vsfwdelay_table[] = {
0, 0, 2, /*Index 0 - Current/Volt Fractional Delay for 8KHz */
0, 0, 0, /*Index 1 - Current/Volt Fractional Delay for 11KHz */
0, 0, 0, /*Index 2 - Current/Volt Fractional Delay for 12KHz */
0, 0, 2, /*Index 3 - Current/Volt Fractional Delay for 16KHz */
0, 0, 2, /*Index 4 - Current/Volt Fractional Delay for 22KHz */
0, 0, 2, /*Index 5 - Current/Volt Fractional Delay for 24KHz */
0, 0, 2, /*Index 6 - Current/Volt Fractional Delay for 32KHz */
0, 0, 2, /*Index 7 - Current/Volt Fractional Delay for 44KHz */
0, 0, 3 /*Index 8 - Current/Volt Fractional Delay for 48KHz */
};
/*
* TODO make this tfa98xx
* Note that the former products write this table via the patch
* so moving this to the tfa98xx API requires also updating all patches
*/
static enum Tfa98xx_Error tfa9897_dsp_write_vsfwdelay_table(Tfa98xx_handle_t handle)
{
enum Tfa98xx_Error error;
error = tfa_dsp_cmd_id_write(handle, MODULE_FRAMEWORK,
TFA1_FW_PAR_ID_SET_CURRENT_DELAY,
sizeof(vsfwdelay_table),
vsfwdelay_table);
return error;
}
/*
* The int24 values for the fracdelay table
* For now applicable only for 8 and 48 kHz
*/
static unsigned char cvfracdelay_table[] = {
0, 0, 51, /*Index 0 - Current/Volt Fractional Delay for 8KHz */
0, 0, 0, /*Index 1 - Current/Volt Fractional Delay for 11KHz */
0, 0, 0, /*Index 2 - Current/Volt Fractional Delay for 12KHz */
0, 0, 38, /*Index 3 - Current/Volt Fractional Delay for 16KHz */
0, 0, 34, /*Index 4 - Current/Volt Fractional Delay for 22KHz */
0, 0, 33, /*Index 5 - Current/Volt Fractional Delay for 24KHz */
0, 0, 11, /*Index 6 - Current/Volt Fractional Delay for 32KHz */
0, 0, 2, /*Index 7 - Current/Volt Fractional Delay for 44KHz */
0, 0, 62 /*Index 8 - Current/Volt Fractional Delay for 48KHz */
};
enum Tfa98xx_Error tfa9897_dsp_write_cvfracdelay_table(Tfa98xx_handle_t handle)
{
enum Tfa98xx_Error error;
error = tfa_dsp_cmd_id_write(handle, MODULE_FRAMEWORK,
TFA1_FW_PAR_ID_SET_CURFRAC_DELAY,
sizeof(cvfracdelay_table),
cvfracdelay_table);
return error;
}
static enum Tfa98xx_Error tfa9897_tfa_dsp_write_tables(Tfa98xx_handle_t dev_idx, int sample_rate)
{
enum Tfa98xx_Error error;
error = tfa9897_dsp_write_vsfwdelay_table(dev_idx);
if (error == Tfa98xx_Error_Ok) {
error = tfa9897_dsp_write_cvfracdelay_table(dev_idx);
}
tfa98xx_dsp_reset(dev_idx, 1);
tfa98xx_dsp_reset(dev_idx, 0);
return error;
}
/*
* register device specifics functions
*/
void tfa9897_ops(struct tfa_device_ops *ops)
{
ops->tfa_init = tfa9897_specific;
ops->tfa_dsp_write_tables = tfa9897_tfa_dsp_write_tables;
}
|