drivers: dmic: Intel PDM digital mic driver

Added an implementation of driver for Intel PDM digital microphone
controller .

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
This commit is contained in:
Sathish Kuttan 2018-05-26 21:49:15 -07:00 committed by Anas Nashif
commit c91faf9008
17 changed files with 3376 additions and 0 deletions

View file

@ -52,3 +52,5 @@ CONFIG_UART_NS16550=y
CONFIG_AUDIO=y
CONFIG_AUDIO_CODEC=y
CONFIG_AUDIO_TLV320DAC=y
CONFIG_AUDIO_DMIC=y
CONFIG_AUDIO_INTEL_DMIC=y

View file

@ -1,3 +1,13 @@
zephyr_library()
zephyr_library_sources_ifdef(CONFIG_AUDIO_TLV320DAC tlv320dac310x.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC intel_dmic.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_int32_02_4288_5100_010_095.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_int32_02_4375_5100_010_095.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_int32_03_3850_5100_010_095.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_int32_03_4375_5100_010_095.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_int32_04_4375_5100_010_095.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_int32_05_4331_5100_010_095.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_int32_06_4156_5100_010_095.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_int32_08_4156_5380_010_090.c)
zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_table.c)

View file

@ -35,4 +35,26 @@ source "subsys/logging/Kconfig.template.log_config"
source "drivers/audio/Kconfig.tlv320dac"
endif # AUDIO_CODEC
menuconfig AUDIO_DMIC
bool "Digital Microphone (Audio) Drivers"
help
Enable Digital Microphone Driver Configuration
if AUDIO_DMIC
config AUDIO_DMIC_INIT_PRIORITY
int "Init priority"
default 60
help
Audio Digital Microphone device driver initialization priority.
module = AUDIO_DMIC
module-str = audio_dmic
source "subsys/logging/Kconfig.template.log_config"
source "drivers/audio/Kconfig.intel_dmic"
endif # AUDIO_DMIC
endif # AUDIO

View file

@ -0,0 +1,11 @@
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
menuconfig AUDIO_INTEL_DMIC
bool "Intel digital PDM microphone driver support"
depends on AUDIO_DMIC
help
Enable Intel digital PDM microphone driver

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __PDM_DECIM_FIR__H__
#define __PDM_DECIM_FIR__H__
#define DMIC_FIR_LIST_LENGTH 8
/* Format for generated coefficients tables */
struct pdm_decim {
int decim_factor;
int length;
int shift;
int relative_passband;
int relative_stopband;
int passband_ripple;
int stopband_ripple;
const s32_t *coef;
};
struct pdm_decim **pdm_decim_get_fir_list(void);
#endif /* __PDM_DECIM_FIR__H__ */

View file

@ -0,0 +1,112 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include "pdm_decim_fir.h"
static const s32_t fir_int32_02_4288_5100_010_095[91] = {
-193886,
104552,
2140521,
5355562,
5945318,
1216991,
-4511367,
-3527243,
3415937,
5526880,
-1935806,
-7515849,
-386524,
9252379,
3862172,
-10093681,
-8251552,
9738620,
13536988,
-7464432,
-19100785,
2935187,
24375729,
4314479,
-28271418,
-14141458,
29999307,
26636531,
-28180625,
-41208987,
21649022,
57264356,
-8757879,
-73520802,
-12043366,
88868414,
43784598,
-101162825,
-91853580,
106519993,
169110273,
-94206010,
-317139630,
5894310,
739661049,
1132200744,
739661049,
5894310,
-317139630,
-94206010,
169110273,
106519993,
-91853580,
-101162825,
43784598,
88868414,
-12043366,
-73520802,
-8757879,
57264356,
21649022,
-41208987,
-28180625,
26636531,
29999307,
-14141458,
-28271418,
4314479,
24375729,
2935187,
-19100785,
-7464432,
13536988,
9738620,
-8251552,
-10093681,
3862172,
9252379,
-386524,
-7515849,
-1935806,
5526880,
3415937,
-3527243,
-4511367,
1216991,
5945318,
5355562,
2140521,
104552,
-193886
};
struct pdm_decim pdm_decim_int32_02_4288_5100_010_095 = {
2, 91, 0, 4288, 5100, 10, 95, fir_int32_02_4288_5100_010_095
};

View file

@ -0,0 +1,122 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include "pdm_decim_fir.h"
static const s32_t fir_int32_02_4375_5100_010_095[101] = {
-587830,
-2653881,
-5154608,
-4845367,
-226473,
4220832,
2571159,
-3184701,
-4043579,
2206821,
5554546,
-750496,
-6923900,
-1268584,
8073360,
4085183,
-8546477,
-7505364,
8176185,
11533751,
-6471060,
-15704256,
3359707,
19852409,
1635593,
-23144509,
-8252640,
25285013,
16574479,
-25723227,
-26663304,
23549736,
38139664,
-17943366,
-50446983,
8141043,
63090267,
7051351,
-75166959,
-29039894,
85772627,
60568979,
-93167356,
-106799776,
94198973,
180962815,
-78385592,
-324820245,
-12243140,
742491441,
1151461281,
742491441,
-12243140,
-324820245,
-78385592,
180962815,
94198973,
-106799776,
-93167356,
60568979,
85772627,
-29039894,
-75166959,
7051351,
63090267,
8141043,
-50446983,
-17943366,
38139664,
23549736,
-26663304,
-25723227,
16574479,
25285013,
-8252640,
-23144509,
1635593,
19852409,
3359707,
-15704256,
-6471060,
11533751,
8176185,
-7505364,
-8546477,
4085183,
8073360,
-1268584,
-6923900,
-750496,
5554546,
2206821,
-4043579,
-3184701,
2571159,
4220832,
-226473,
-4845367,
-5154608,
-2653881,
-587830
};
struct pdm_decim pdm_decim_int32_02_4375_5100_010_095 = {
2, 101, 0, 4375, 5100, 10, 95, fir_int32_02_4375_5100_010_095
};

View file

@ -0,0 +1,114 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include "pdm_decim_fir.h"
static const s32_t fir_int32_03_3850_5100_010_095[93] = {
44212,
-302176,
-1360920,
-3291119,
-5495374,
-6588668,
-5102927,
-753403,
4644861,
7677973,
5490212,
-1618066,
-9302333,
-11445730,
-4732005,
7709057,
17063964,
14699335,
-457541,
-18980508,
-26202607,
-13319132,
13695670,
35545996,
32740745,
1994202,
-37267233,
-54079734,
-29355959,
25448678,
71128406,
67328423,
5964667,
-74773313,
-111583346,
-62643893,
52737606,
154899783,
153311689,
16759099,
-184962926,
-304661987,
-201939017,
160731847,
673585388,
1122541471,
1300561761,
1122541471,
673585388,
160731847,
-201939017,
-304661987,
-184962926,
16759099,
153311689,
154899783,
52737606,
-62643893,
-111583346,
-74773313,
5964667,
67328423,
71128406,
25448678,
-29355959,
-54079734,
-37267233,
1994202,
32740745,
35545996,
13695670,
-13319132,
-26202607,
-18980508,
-457541,
14699335,
17063964,
7709057,
-4732005,
-11445730,
-9302333,
-1618066,
5490212,
7677973,
4644861,
-753403,
-5102927,
-6588668,
-5495374,
-3291119,
-1360920,
-302176,
44212
};
struct pdm_decim pdm_decim_int32_03_3850_5100_010_095 = {
3, 93, 1, 3850, 5100, 10, 95, fir_int32_03_3850_5100_010_095
};

View file

@ -0,0 +1,178 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include "pdm_decim_fir.h"
static const s32_t fir_int32_03_4375_5100_010_095[157] = {
350904,
1127891,
2233546,
3059556,
2752177,
818057,
-2252661,
-4944515,
-5550704,
-3466227,
53089,
2496755,
1904111,
-1421730,
-4818556,
-5204443,
-1721082,
3155305,
5311444,
2454515,
-3518616,
-7589471,
-5713308,
1327821,
7901341,
7958087,
527903,
-8633996,
-11354795,
-4214518,
7627116,
13970242,
8263364,
-5861946,
-16549651,
-13529964,
2213919,
17870757,
19056207,
2854066,
-18029728,
-24979102,
-9860164,
16175117,
30545984,
18605951,
-11894271,
-35172531,
-28918160,
4746528,
38201092,
40590666,
5825429,
-38712951,
-53159148,
-20283384,
35723256,
66120531,
39265868,
-27910967,
-78795928,
-63663750,
13458962,
90416047,
95193346,
10755142,
-99897049,
-137497231,
-51075841,
105457455,
200047804,
124561003,
-101612190,
-313384381,
-297343743,
53701878,
639681661,
1187800564,
1411050887,
1187800564,
639681661,
53701878,
-297343743,
-313384381,
-101612190,
124561003,
200047804,
105457455,
-51075841,
-137497231,
-99897049,
10755142,
95193346,
90416047,
13458962,
-63663750,
-78795928,
-27910967,
39265868,
66120531,
35723256,
-20283384,
-53159148,
-38712951,
5825429,
40590666,
38201092,
4746528,
-28918160,
-35172531,
-11894271,
18605951,
30545984,
16175117,
-9860164,
-24979102,
-18029728,
2854066,
19056207,
17870757,
2213919,
-13529964,
-16549651,
-5861946,
8263364,
13970242,
7627116,
-4214518,
-11354795,
-8633996,
527903,
7958087,
7901341,
1327821,
-5713308,
-7589471,
-3518616,
2454515,
5311444,
3155305,
-1721082,
-5204443,
-4818556,
-1421730,
1904111,
2496755,
53089,
-3466227,
-5550704,
-4944515,
-2252661,
818057,
2752177,
3059556,
2233546,
1127891,
350904
};
struct pdm_decim pdm_decim_int32_03_4375_5100_010_095 = {
3, 157, 1, 4375, 5100, 10, 95, fir_int32_03_4375_5100_010_095
};

View file

@ -0,0 +1,232 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include "pdm_decim_fir.h"
static const s32_t fir_int32_04_4375_5100_010_095[211] = {
126017,
745791,
1735783,
3250059,
4963537,
6400069,
6949502,
6142229,
3902336,
705842,
-2485787,
-4540607,
-4626085,
-2636100,
646448,
3784383,
5275090,
4259502,
1015665,
-3045153,
-5950963,
-6099091,
-3115593,
1807814,
6342508,
8093924,
5838000,
296533,
-6011752,
-9879686,
-9013045,
-3339610,
4700101,
11152288,
12461593,
7387989,
-2085667,
-11448775,
-15769545,
-12252662,
-1940150,
10437445,
18576639,
17768944,
7550319,
-7626200,
-20251921,
-23428157,
-14572076,
2797464,
20329234,
28790530,
22864155,
4330980,
-18201801,
-33211863,
-32081436,
-13923851,
13233081,
35870337,
41620943,
25914222,
-4896316,
-35895437,
-50712381,
-40042952,
-7212823,
32428935,
58525317,
56015029,
23582638,
-24374765,
-63897455,
-73234460,
-44550852,
10604843,
65540282,
91054416,
70624752,
10408242,
-61706258,
-108584856,
-102490195,
-40744453,
50090298,
124919090,
141743373,
84173003,
-26760833,
-138851415,
-191966143,
-148464813,
-16173880,
148695193,
262835505,
254088691,
100293640,
-149816104,
-385869984,
-474827254,
-315628113,
112831849,
731720961,
1381072959,
1872325415,
2055132469,
1872325415,
1381072959,
731720961,
112831849,
-315628113,
-474827254,
-385869984,
-149816104,
100293640,
254088691,
262835505,
148695193,
-16173880,
-148464813,
-191966143,
-138851415,
-26760833,
84173003,
141743373,
124919090,
50090298,
-40744453,
-102490195,
-108584856,
-61706258,
10408242,
70624752,
91054416,
65540282,
10604843,
-44550852,
-73234460,
-63897455,
-24374765,
23582638,
56015029,
58525317,
32428935,
-7212823,
-40042952,
-50712381,
-35895437,
-4896316,
25914222,
41620943,
35870337,
13233081,
-13923851,
-32081436,
-33211863,
-18201801,
4330980,
22864155,
28790530,
20329234,
2797464,
-14572076,
-23428157,
-20251921,
-7626200,
7550319,
17768944,
18576639,
10437445,
-1940150,
-12252662,
-15769545,
-11448775,
-2085667,
7387989,
12461593,
11152288,
4700101,
-3339610,
-9013045,
-9879686,
-6011752,
296533,
5838000,
8093924,
6342508,
1807814,
-3115593,
-6099091,
-5950963,
-3045153,
1015665,
4259502,
5275090,
3784383,
646448,
-2636100,
-4626085,
-4540607,
-2485787,
705842,
3902336,
6142229,
6949502,
6400069,
4963537,
3250059,
1735783,
745791,
126017
};
struct pdm_decim pdm_decim_int32_04_4375_5100_010_095 = {
4, 211, 2, 4375, 5100, 10, 95, fir_int32_04_4375_5100_010_095
};

View file

@ -0,0 +1,272 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include "pdm_decim_fir.h"
static const s32_t fir_int32_05_4331_5100_010_095[251] = {
-250963,
-530472,
-956449,
-1440505,
-1861966,
-2058350,
-1862594,
-1155766,
78930,
1719645,
3501958,
5061143,
6013975,
6066039,
5113131,
3303104,
1032343,
-1135681,
-2614668,
-2968117,
-2057986,
-118896,
2276521,
4363476,
5409644,
4953617,
2982225,
-20415,
-3181416,
-5487913,
-6107986,
-4685208,
-1505051,
2535666,
6167372,
8134966,
7619351,
4554012,
-280001,
-5435156,
-9220394,
-10246686,
-7922490,
-2726786,
3853867,
9734139,
12878468,
11991508,
7020539,
-717311,
-8859727,
-14705610,
-16097433,
-12195790,
-3874308,
6431337,
15415517,
19946809,
18139792,
10093658,
-1980159,
-14334496,
-22829097,
-24298020,
-17696570,
-4621840,
11019276,
24149376,
30144976,
26434112,
13524367,
-4930822,
-23124320,
-34892082,
-35768599,
-24626114,
-4311380,
19011680,
37690383,
45054463,
37744852,
17102968,
-10919933,
-37416293,
-53300866,
-52364722,
-33596881,
-1935268,
32928131,
59438198,
67925581,
54022129,
20569914,
-22737901,
-62048140,
-83661289,
-78659667,
-46330665,
4859442,
59276671,
98707953,
108233225,
81552245,
23955872,
-48257755,
-112070264,
-144691658,
-131171943,
-70276392,
23448172,
122479978,
193637242,
208100323,
151336952,
29895897,
-127299559,
-274102498,
-357874627,
-333256339,
-175377009,
111180608,
490397234,
900786668,
1268179136,
1522305381,
1613059887,
1522305381,
1268179136,
900786668,
490397234,
111180608,
-175377009,
-333256339,
-357874627,
-274102498,
-127299559,
29895897,
151336952,
208100323,
193637242,
122479978,
23448172,
-70276392,
-131171943,
-144691658,
-112070264,
-48257755,
23955872,
81552245,
108233225,
98707953,
59276671,
4859442,
-46330665,
-78659667,
-83661289,
-62048140,
-22737901,
20569914,
54022129,
67925581,
59438198,
32928131,
-1935268,
-33596881,
-52364722,
-53300866,
-37416293,
-10919933,
17102968,
37744852,
45054463,
37690383,
19011680,
-4311380,
-24626114,
-35768599,
-34892082,
-23124320,
-4930822,
13524367,
26434112,
30144976,
24149376,
11019276,
-4621840,
-17696570,
-24298020,
-22829097,
-14334496,
-1980159,
10093658,
18139792,
19946809,
15415517,
6431337,
-3874308,
-12195790,
-16097433,
-14705610,
-8859727,
-717311,
7020539,
11991508,
12878468,
9734139,
3853867,
-2726786,
-7922490,
-10246686,
-9220394,
-5435156,
-280001,
4554012,
7619351,
8134966,
6167372,
2535666,
-1505051,
-4685208,
-6107986,
-5487913,
-3181416,
-20415,
2982225,
4953617,
5409644,
4363476,
2276521,
-118896,
-2057986,
-2968117,
-2614668,
-1135681,
1032343,
3303104,
5113131,
6066039,
6013975,
5061143,
3501958,
1719645,
78930,
-1155766,
-1862594,
-2058350,
-1861966,
-1440505,
-956449,
-530472,
-250963
};
struct pdm_decim pdm_decim_int32_05_4331_5100_010_095 = {
5, 251, 2, 4331, 5100, 10, 95, fir_int32_05_4331_5100_010_095
};

View file

@ -0,0 +1,270 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include "pdm_decim_fir.h"
static const s32_t fir_int32_06_4156_5100_010_095[249] = {
-145670,
-159762,
-183049,
-132077,
40047,
375196,
897258,
1599108,
2433074,
3308273,
4097062,
4651618,
4829700,
4525669,
3700263,
2402258,
776038,
-950161,
-2496541,
-3579851,
-3970442,
-3547641,
-2337956,
-529617,
1547925,
3476297,
4827277,
5253398,
4572039,
2823110,
284249,
-2564887,
-5127174,
-6808166,
-7148614,
-5940791,
-3300873,
324045,
4222816,
7553233,
9518313,
9550081,
7459490,
3515883,
-1570147,
-6764980,
-10915019,
-12995804,
-12355318,
-8895306,
-3143626,
3808819,
10504528,
15416643,
17288185,
15439779,
9973227,
1815303,
-7421871,
-15747713,
-21211963,
-22349384,
-18551421,
-10274491,
976318,
12902423,
22867792,
28468157,
28093650,
21356476,
9275878,
-5840836,
-20818261,
-32262581,
-37311768,
-34324420,
-23346677,
-6234152,
13625405,
31957173,
44495096,
47945809,
40808741,
23856504,
140921,
-25513494,
-47455167,
-60412143,
-60710132,
-47229950,
-21869611,
10631696,
43519737,
69370312,
81696614,
76484113,
53307373,
15747228,
-29042608,
-71597234,
-102026296,
-112167649,
-97565632,
-58831316,
-2036750,
62029440,
119693403,
157031723,
162840122,
131357475,
64171528,
-29147598,
-131921532,
-222701994,
-278742412,
-280032642,
-213184166,
-74440208,
128790505,
378234661,
646928572,
902966510,
1114231037,
1253321369,
1301843153,
1253321369,
1114231037,
902966510,
646928572,
378234661,
128790505,
-74440208,
-213184166,
-280032642,
-278742412,
-222701994,
-131921532,
-29147598,
64171528,
131357475,
162840122,
157031723,
119693403,
62029440,
-2036750,
-58831316,
-97565632,
-112167649,
-102026296,
-71597234,
-29042608,
15747228,
53307373,
76484113,
81696614,
69370312,
43519737,
10631696,
-21869611,
-47229950,
-60710132,
-60412143,
-47455167,
-25513494,
140921,
23856504,
40808741,
47945809,
44495096,
31957173,
13625405,
-6234152,
-23346677,
-34324420,
-37311768,
-32262581,
-20818261,
-5840836,
9275878,
21356476,
28093650,
28468157,
22867792,
12902423,
976318,
-10274491,
-18551421,
-22349384,
-21211963,
-15747713,
-7421871,
1815303,
9973227,
15439779,
17288185,
15416643,
10504528,
3808819,
-3143626,
-8895306,
-12355318,
-12995804,
-10915019,
-6764980,
-1570147,
3515883,
7459490,
9550081,
9518313,
7553233,
4222816,
324045,
-3300873,
-5940791,
-7148614,
-6808166,
-5127174,
-2564887,
284249,
2823110,
4572039,
5253398,
4827277,
3476297,
1547925,
-529617,
-2337956,
-3547641,
-3970442,
-3579851,
-2496541,
-950161,
776038,
2402258,
3700263,
4525669,
4829700,
4651618,
4097062,
3308273,
2433074,
1599108,
897258,
375196,
40047,
-132077,
-183049,
-159762,
-145670
};
struct pdm_decim pdm_decim_int32_06_4156_5100_010_095 = {
6, 249, 2, 4156, 5100, 10, 95, fir_int32_06_4156_5100_010_095
};

View file

@ -0,0 +1,268 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include "pdm_decim_fir.h"
static const s32_t fir_int32_08_4156_5380_010_090[247] = {
-337052,
-90075,
37780,
310298,
762602,
1418014,
2279975,
3324413,
4495298,
5703536,
6831280,
7740936,
8289504,
8346168,
7812523,
6641741,
4854841,
2549644,
-98570,
-2847418,
-5407472,
-7472951,
-8758755,
-9040926,
-8192669,
-6213693,
-3246278,
424677,
4395972,
8180309,
11265189,
13176475,
13545386,
12170147,
9059463,
4454447,
-1180491,
-7196755,
-12830960,
-17296055,
-19885729,
-20077500,
-17621714,
-12601266,
-5452197,
3062539,
11925735,
19980775,
26075722,
29220338,
28734576,
24368837,
16375791,
5519930,
-6982346,
-19587960,
-30609997,
-38433685,
-41741838,
-39718804,
-32202058,
-19758650,
-3667506,
14195787,
31565234,
46060011,
55497992,
58207057,
53292128,
40817642,
21874421,
-1487369,
-26460171,
-49799428,
-68227825,
-78875217,
-79697543,
-69816864,
-49730377,
-21350328,
12143051,
46630130,
77532435,
100390923,
111473843,
108334402,
90240198,
58408793,
16001822,
-32138446,
-79996329,
-121085165,
-149268412,
-159601418,
-149086287,
-117235239,
-66355092,
-1494553,
69965597,
139055884,
196228005,
232526458,
240790250,
216740138,
159811182,
73611998,
-34070591,
-151754583,
-265210746,
-358796902,
-417052464,
-426388521,
-376691518,
-262659116,
-84707915,
150664267,
431125422,
739363099,
1054476937,
1353781691,
1614844650,
1817552687,
1945997296,
1989982406,
1945997296,
1817552687,
1614844650,
1353781691,
1054476937,
739363099,
431125422,
150664267,
-84707915,
-262659116,
-376691518,
-426388521,
-417052464,
-358796902,
-265210746,
-151754583,
-34070591,
73611998,
159811182,
216740138,
240790250,
232526458,
196228005,
139055884,
69965597,
-1494553,
-66355092,
-117235239,
-149086287,
-159601418,
-149268412,
-121085165,
-79996329,
-32138446,
16001822,
58408793,
90240198,
108334402,
111473843,
100390923,
77532435,
46630130,
12143051,
-21350328,
-49730377,
-69816864,
-79697543,
-78875217,
-68227825,
-49799428,
-26460171,
-1487369,
21874421,
40817642,
53292128,
58207057,
55497992,
46060011,
31565234,
14195787,
-3667506,
-19758650,
-32202058,
-39718804,
-41741838,
-38433685,
-30609997,
-19587960,
-6982346,
5519930,
16375791,
24368837,
28734576,
29220338,
26075722,
19980775,
11925735,
3062539,
-5452197,
-12601266,
-17621714,
-20077500,
-19885729,
-17296055,
-12830960,
-7196755,
-1180491,
4454447,
9059463,
12170147,
13545386,
13176475,
11265189,
8180309,
4395972,
424677,
-3246278,
-6213693,
-8192669,
-9040926,
-8758755,
-7472951,
-5407472,
-2847418,
-98570,
2549644,
4854841,
6641741,
7812523,
8346168,
8289504,
7740936,
6831280,
5703536,
4495298,
3324413,
2279975,
1418014,
762602,
310298,
37780,
-90075,
-337052
};
struct pdm_decim pdm_decim_int32_08_4156_5380_010_090 = {
8, 247, 3, 4156, 5380, 10, 90, fir_int32_08_4156_5380_010_090
};

View file

@ -0,0 +1,45 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
/* PDM decimation FIR filters */
#include <zephyr.h>
#include "pdm_decim_fir.h"
extern struct pdm_decim pdm_decim_int32_02_4375_5100_010_095;
extern struct pdm_decim pdm_decim_int32_02_4288_5100_010_095;
extern struct pdm_decim pdm_decim_int32_03_4375_5100_010_095;
extern struct pdm_decim pdm_decim_int32_03_3850_5100_010_095;
extern struct pdm_decim pdm_decim_int32_04_4375_5100_010_095;
extern struct pdm_decim pdm_decim_int32_05_4331_5100_010_095;
extern struct pdm_decim pdm_decim_int32_06_4156_5100_010_095;
extern struct pdm_decim pdm_decim_int32_08_4156_5380_010_090;
/* Note: Higher spec filter must be before lower spec filter
* if there are multiple filters for a decimation factor. The naming
* scheme of coefficients set is:
* <type>_<decim factor>_<rel passband>_<rel stopband>_<ripple>_<attenuation>
*/
static struct pdm_decim *fir_list[DMIC_FIR_LIST_LENGTH] = {
&pdm_decim_int32_02_4375_5100_010_095,
&pdm_decim_int32_02_4288_5100_010_095,
&pdm_decim_int32_03_4375_5100_010_095,
&pdm_decim_int32_03_3850_5100_010_095,
&pdm_decim_int32_04_4375_5100_010_095,
&pdm_decim_int32_05_4331_5100_010_095,
&pdm_decim_int32_06_4156_5100_010_095,
&pdm_decim_int32_08_4156_5380_010_090,
};
struct pdm_decim **pdm_decim_get_fir_list(void)
{
return fir_list;
}

1440
drivers/audio/intel_dmic.c Normal file

File diff suppressed because it is too large Load diff

237
drivers/audio/intel_dmic.h Normal file
View file

@ -0,0 +1,237 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Liam Girdwood <liam.r.girdwood@linux.intel.com>
* Keyon Jie <yang.jie@linux.intel.com>
* Sathish Kuttan <sathish.k.kuttan@intel.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __INTEL_DMIC_H__
#define __INTEL_DMIC_H__
#include <device.h>
#define DMIC_HW_IOCLK 38400000
/* Parameters used in modes computation */
#define DMIC_HW_BITS_CIC 26
#define DMIC_HW_BITS_FIR_COEF 20
#define DMIC_HW_BITS_FIR_GAIN 20
#define DMIC_HW_BITS_FIR_INPUT 22
#define DMIC_HW_BITS_FIR_OUTPUT 24
#define DMIC_HW_BITS_FIR_INTERNAL 26
#define DMIC_HW_BITS_GAIN_OUTPUT 22
#define DMIC_HW_FIR_LENGTH_MAX 250
#define DMIC_HW_CIC_SHIFT_MIN -8
#define DMIC_HW_CIC_SHIFT_MAX 4
#define DMIC_HW_FIR_SHIFT_MIN 0
#define DMIC_HW_FIR_SHIFT_MAX 8
#define DMIC_HW_CIC_DECIM_MIN 5
#define DMIC_HW_CIC_DECIM_MAX 31 /* Note: Limited by BITS_CIC */
#define DMIC_HW_FIR_DECIM_MIN 2
#define DMIC_HW_FIR_DECIM_MAX 20 /* Note: Practical upper limit */
#define DMIC_HW_SENS_Q28 BIT(28) /* 1.0 in Q1.28 format */
#define DMIC_HW_PDM_CLK_MIN 100000 /* Note: Practical min value */
#define DMIC_HW_DUTY_MIN 20 /* Note: Practical min value */
#define DMIC_HW_DUTY_MAX 80 /* Note: Practical max value */
/* DMIC register offsets */
#define PDM_REG_BASE(pdm) (((pdm) + 1) << 12)
#define PDM_COEFF_A(pdm) (PDM_REG_BASE(pdm) + 0x400)
#define PDM_COEFF_B(pdm) (PDM_REG_BASE(pdm) + 0x800)
/* Global registers */
#define OUTCONTROL0 0x0000
#define OUTSTAT0 0x0004
#define OUTDATA0 0x0008
#define OUTCONTROL1 0x0100
#define OUTSTAT1 0x0104
#define OUTDATA1 0x0108
/* Local registers in each PDMx */
#define CIC_CONTROL(pdm) (PDM_REG_BASE(pdm) + 0x000)
#define CIC_CONFIG(pdm) (PDM_REG_BASE(pdm) + 0x004)
#define MIC_CONTROL(pdm) (PDM_REG_BASE(pdm) + 0x00c)
#define FIR_CONTROL_A(pdm) (PDM_REG_BASE(pdm) + 0x020)
#define FIR_CONFIG_A(pdm) (PDM_REG_BASE(pdm) + 0x024)
#define DC_OFFSET_LEFT_A(pdm) (PDM_REG_BASE(pdm) + 0x028)
#define DC_OFFSET_RIGHT_A(pdm) (PDM_REG_BASE(pdm) + 0x02c)
#define OUT_GAIN_LEFT_A(pdm) (PDM_REG_BASE(pdm) + 0x030)
#define OUT_GAIN_RIGHT_A(pdm) (PDM_REG_BASE(pdm) + 0x034)
#define FIR_CONTROL_B(pdm) (PDM_REG_BASE(pdm) + 0x040)
#define FIR_CONFIG_B(pdm) (PDM_REG_BASE(pdm) + 0x044)
#define DC_OFFSET_LEFT_B(pdm) (PDM_REG_BASE(pdm) + 0x048)
#define DC_OFFSET_RIGHT_B(pdm) (PDM_REG_BASE(pdm) + 0x04c)
#define OUT_GAIN_LEFT_B(pdm) (PDM_REG_BASE(pdm) + 0x050)
#define OUT_GAIN_RIGHT_B(pdm) (PDM_REG_BASE(pdm) + 0x054)
/* Register bits */
/* OUTCONTROL0 bits */
#define OUTCONTROL0_TIE_BIT BIT(27)
#define OUTCONTROL0_SIP_BIT BIT(26)
#define OUTCONTROL0_FINIT_BIT BIT(25)
#define OUTCONTROL0_FCI_BIT BIT(24)
#define OUTCONTROL0_TIE(x) SET_BIT(27, x)
#define OUTCONTROL0_SIP(x) SET_BIT(26, x)
#define OUTCONTROL0_FINIT(x) SET_BIT(25, x)
#define OUTCONTROL0_FCI(x) SET_BIT(24, x)
#define OUTCONTROL0_BFTH(x) SET_BITS(23, 20, x)
#define OUTCONTROL0_OF(x) SET_BITS(19, 18, x)
#define OUTCONTROL0_NUMBER_OF_DECIMATORS(x) SET_BITS(17, 15, x)
#define OUTCONTROL0_IPM_SOURCE_1(x) SET_BITS(14, 13, x)
#define OUTCONTROL0_IPM_SOURCE_2(x) SET_BITS(12, 11, x)
#define OUTCONTROL0_IPM_SOURCE_3(x) SET_BITS(10, 9, x)
#define OUTCONTROL0_IPM_SOURCE_4(x) SET_BITS(8, 7, x)
#define OUTCONTROL0_TH(x) SET_BITS(5, 0, x)
/* OUTCONTROL1 bits */
#define OUTCONTROL1_TIE_BIT BIT(27)
#define OUTCONTROL1_SIP_BIT BIT(26)
#define OUTCONTROL1_FINIT_BIT BIT(25)
#define OUTCONTROL1_FCI_BIT BIT(24)
#define OUTCONTROL1_TIE(x) SET_BIT(27, x)
#define OUTCONTROL1_SIP(x) SET_BIT(26, x)
#define OUTCONTROL1_FINIT(x) SET_BIT(25, x)
#define OUTCONTROL1_FCI(x) SET_BIT(24, x)
#define OUTCONTROL1_BFTH(x) SET_BITS(23, 20, x)
#define OUTCONTROL1_OF(x) SET_BITS(19, 18, x)
#define OUTCONTROL1_NUMBER_OF_DECIMATORS(x) SET_BITS(17, 15, x)
#define OUTCONTROL1_IPM_SOURCE_1(x) SET_BITS(14, 13, x)
#define OUTCONTROL1_IPM_SOURCE_2(x) SET_BITS(12, 11, x)
#define OUTCONTROL1_IPM_SOURCE_3(x) SET_BITS(10, 9, x)
#define OUTCONTROL1_IPM_SOURCE_4(x) SET_BITS(8, 7, x)
#define OUTCONTROL1_TH(x) SET_BITS(5, 0, x)
/* OUTSTAT0 bits */
#define OUTSTAT0_AFE_BIT BIT(31)
#define OUTSTAT0_ASNE_BIT BIT(29)
#define OUTSTAT0_RFS_BIT BIT(28)
#define OUTSTAT0_ROR_BIT BIT(27)
#define OUTSTAT0_FL_MASK MASK(6, 0)
/* OUTSTAT1 bits */
#define OUTSTAT1_AFE_BIT BIT(31)
#define OUTSTAT1_ASNE_BIT BIT(29)
#define OUTSTAT1_RFS_BIT BIT(28)
#define OUTSTAT1_ROR_BIT BIT(27)
#define OUTSTAT1_FL_MASK MASK(6, 0)
/* CIC_CONTROL bits */
#define CIC_CONTROL_SOFT_RESET_BIT BIT(16)
#define CIC_CONTROL_CIC_START_B_BIT BIT(15)
#define CIC_CONTROL_CIC_START_A_BIT BIT(14)
#define CIC_CONTROL_MIC_B_POLARITY_BIT BIT(3)
#define CIC_CONTROL_MIC_A_POLARITY_BIT BIT(2)
#define CIC_CONTROL_MIC_MUTE_BIT BIT(1)
#define CIC_CONTROL_STEREO_MODE_BIT BIT(0)
#define CIC_CONTROL_SOFT_RESET(x) SET_BIT(16, x)
#define CIC_CONTROL_CIC_START_B(x) SET_BIT(15, x)
#define CIC_CONTROL_CIC_START_A(x) SET_BIT(14, x)
#define CIC_CONTROL_MIC_B_POLARITY(x) SET_BIT(3, x)
#define CIC_CONTROL_MIC_A_POLARITY(x) SET_BIT(2, x)
#define CIC_CONTROL_MIC_MUTE(x) SET_BIT(1, x)
#define CIC_CONTROL_STEREO_MODE(x) SET_BIT(0, x)
/* CIC_CONFIG bits */
#define CIC_CONFIG_CIC_SHIFT(x) SET_BITS(27, 24, x)
#define CIC_CONFIG_COMB_COUNT(x) SET_BITS(15, 8, x)
/* MIC_CONTROL bits */
#define MIC_CONTROL_PDM_EN_B_BIT BIT(1)
#define MIC_CONTROL_PDM_EN_A_BIT BIT(0)
#define MIC_CONTROL_PDM_CLKDIV(x) SET_BITS(15, 8, x)
#define MIC_CONTROL_PDM_SKEW(x) SET_BITS(7, 4, x)
#define MIC_CONTROL_CLK_EDGE(x) SET_BIT(3, x)
#define MIC_CONTROL_PDM_EN_B(x) SET_BIT(1, x)
#define MIC_CONTROL_PDM_EN_A(x) SET_BIT(0, x)
/* FIR_CONTROL_A bits */
#define FIR_CONTROL_A_START_BIT BIT(7)
#define FIR_CONTROL_A_ARRAY_START_EN_BIT BIT(6)
#define FIR_CONTROL_A_MUTE_BIT BIT(1)
#define FIR_CONTROL_A_START(x) SET_BIT(7, x)
#define FIR_CONTROL_A_ARRAY_START_EN(x) SET_BIT(6, x)
#define FIR_CONTROL_A_DCCOMP(x) SET_BIT(4, x)
#define FIR_CONTROL_A_MUTE(x) SET_BIT(1, x)
#define FIR_CONTROL_A_STEREO(x) SET_BIT(0, x)
/* FIR_CONFIG_A bits */
#define FIR_CONFIG_A_FIR_DECIMATION(x) SET_BITS(20, 16, x)
#define FIR_CONFIG_A_FIR_SHIFT(x) SET_BITS(11, 8, x)
#define FIR_CONFIG_A_FIR_LENGTH(x) SET_BITS(7, 0, x)
/* DC offset compensation time constants */
#define DCCOMP_TC0 0
#define DCCOMP_TC1 1
#define DCCOMP_TC2 2
#define DCCOMP_TC3 3
#define DCCOMP_TC4 4
#define DCCOMP_TC5 5
#define DCCOMP_TC6 6
#define DCCOMP_TC7 7
/* DC_OFFSET_LEFT_A bits */
#define DC_OFFSET_LEFT_A_DC_OFFS(x) SET_BITS(21, 0, x)
/* DC_OFFSET_RIGHT_A bits */
#define DC_OFFSET_RIGHT_A_DC_OFFS(x) SET_BITS(21, 0, x)
/* OUT_GAIN_LEFT_A bits */
#define OUT_GAIN_LEFT_A_GAIN(x) SET_BITS(19, 0, x)
/* OUT_GAIN_RIGHT_A bits */
#define OUT_GAIN_RIGHT_A_GAIN(x) SET_BITS(19, 0, x)
/* FIR_CONTROL_B bits */
#define FIR_CONTROL_B_START_BIT BIT(7)
#define FIR_CONTROL_B_ARRAY_START_EN_BIT BIT(6)
#define FIR_CONTROL_B_MUTE_BIT BIT(1)
#define FIR_CONTROL_B_START(x) SET_BIT(7, x)
#define FIR_CONTROL_B_ARRAY_START_EN(x) SET_BIT(6, x)
#define FIR_CONTROL_B_DCCOMP(x) SET_BIT(4, x)
#define FIR_CONTROL_B_MUTE(x) SET_BIT(1, x)
#define FIR_CONTROL_B_STEREO(x) SET_BIT(0, x)
/* FIR_CONFIG_B bits */
#define FIR_CONFIG_B_FIR_DECIMATION(x) SET_BITS(20, 16, x)
#define FIR_CONFIG_B_FIR_SHIFT(x) SET_BITS(11, 8, x)
#define FIR_CONFIG_B_FIR_LENGTH(x) SET_BITS(7, 0, x)
/* DC_OFFSET_LEFT_B bits */
#define DC_OFFSET_LEFT_B_DC_OFFS(x) SET_BITS(21, 0, x)
/* DC_OFFSET_RIGHT_B bits */
#define DC_OFFSET_RIGHT_B_DC_OFFS(x) SET_BITS(21, 0, x)
/* OUT_GAIN_LEFT_B bits */
#define OUT_GAIN_LEFT_B_GAIN(x) SET_BITS(19, 0, x)
/* OUT_GAIN_RIGHT_B bits */
#define OUT_GAIN_RIGHT_B_GAIN(x) SET_BITS(19, 0, x)
/* FIR coefficients */
#define FIR_COEF_A(x) SET_BITS(19, 0, x)
#define FIR_COEF_B(x) SET_BITS(19, 0, x)
/* max number of streams supported by hardware 2 = Stream A & B */
#define DMIC_MAX_STREAMS 2
#define DMIC_DMA_DEV_NAME CONFIG_DMA_0_NAME
#define DMA_CHANNEL_DMIC_RXA 0
#define DMA_CHANNEL_DMIC_RXB 1
#define DMA_HANDSHAKE_DMIC_RXA 0
#define DMA_HANDSHAKE_DMIC_RXB 1
int dmic_configure_dma(struct pcm_stream_cfg *config, u8_t num_streams);
int dmic_reload_dma(u32_t channel, void *buffer, size_t size);
int dmic_start_dma(u32_t channel);
int dmic_stop_dma(u32_t channel);
#endif /* __INTEL_DMIC_H__ */

View file

@ -62,6 +62,8 @@
#define CAVS_DMA1_OWNERSHIP_REG (0x00071A62)
#define CAVS_DMA2_OWNERSHIP_REG (0x00071A64)
#define DMA_HANDSHAKE_DMIC_RXA 0
#define DMA_HANDSHAKE_DMIC_RXB 1
#define DMA_HANDSHAKE_SSP0_TX 2
#define DMA_HANDSHAKE_SSP0_RX 3
#define DMA_HANDSHAKE_SSP1_TX 4
@ -71,6 +73,14 @@
#define DMA_HANDSHAKE_SSP3_TX 8
#define DMA_HANDSHAKE_SSP3_RX 9
/* DMA Channel Allocation
* FIXME: I2S Driver assigns channel in Kconfig.
* Perhaps DTS is a better option
*/
#define DMIC_DMA_DEV_NAME CONFIG_DMA_0_NAME
#define DMA_CHANNEL_DMIC_RXA 0
#define DMA_CHANNEL_DMIC_RXB 1
/* I2S */
#define I2S0_CAVS_IRQ 0x00000010
#define I2S1_CAVS_IRQ 0x00000110