Skip to content

Conversation

@singalsu
Copy link
Collaborator

@singalsu singalsu commented Apr 12, 2021

This patch adds to DMIC driver support for NHLT DMIC blob based
setup. The driver mode is selected in Kconfig.

Signed-off-by: Seppo Ingalsuo seppo.ingalsuo@linux.intel.com

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this looks like a new driver ? I would have expected a new function to load the NHLT register blobs and coeffs and reuse the existing control code ?

@singalsu
Copy link
Collaborator Author

@lgirdwood Please see this PR version that shows the previous outcome as four commits. The last commit is the beef. The Two first commits are moving functions and definitions to other files. I did this because the dmic.c was already thousand something lines.

I have tested this less than previous version, it was quite hard to rewind the work back to steps but I will continue testing and completing features from this. The issue with NHLT blob is that it's not straightforward registers write. Need to decode parts of it to implement a proper start sequence.

@lgirdwood
Copy link
Member

@singalsu I assume you still have to update the commit messages with which ones are code moves etc ?

@RanderWang
Copy link
Collaborator

can you add some description of DMIC blob structure ? I findsome params are missed, .e.g. reuse_fir_from_pdm

@RanderWang
Copy link
Collaborator

@singalsu I will create a PR to set ipc message box with correct size based on different platform, then we can send dmic blob to fw.

@lgirdwood lgirdwood added this to the v1.8 milestone Apr 28, 2021
@lgirdwood lgirdwood modified the milestones: v1.8, v1.9 May 10, 2021
@singalsu
Copy link
Collaborator Author

@lgirdwood @RanderWang This work is not quite yet ready to take NHLT blob from IPC but hopefully soon. I got the rebase version to work finally here with my TGL test device in both configure modes. I pushed this new draft to see CI results for current topology parameters mode.

@lgirdwood
Copy link
Member

@singalsu the macro patch could be merged first in a separate PR ?

@singalsu
Copy link
Collaborator Author

@lgirdwood Done, the PR is #4256

@RanderWang
Copy link
Collaborator

@singalsu please try the following data with this PR. it works on TGL-H.

static uint32_t dmic_blob[] = {
	0x00000000 , 0xffffff10 , 0xffffff10 , 0xffffffff , 0xffffffff , 0x00000003 , 0x00000003 , 0x00300003
	 , 0x00300003 , 0x00000003 , 0x0000c001 , 0x0b001803 , 0x00000000 , 0x00000e03 , 0x00000000 , 0x00000000
	 , 0x00000000 , 0x00000000 , 0x00000091 , 0x00010076 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000
	 , 0x00000000 , 0x00000000 , 0x00000091 , 0x000501e8 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000
	 , 0x00000000 , 0x00000000 , 0x40000049 , 0x40400181 , 0x4080036d , 0x40c00453 , 0x41000278 , 0x414fff19
	 , 0x418ffded , 0x41c00037 , 0x42000245 , 0x4240008c , 0x428ffd9b , 0x42cffe9d , 0x4300026c , 0x43400267
	 , 0x438ffdb1 , 0x43cffc25 , 0x4400016f , 0x44400521 , 0x448ffff3 , 0x44cff9c4 , 0x450ffdf9 , 0x454006bf
	 , 0x4580048e , 0x45cff973 , 0x460ff896 , 0x46400572 , 0x46800a69 , 0x46cffccf , 0x470ff2d1 , 0x474fffa4
	 , 0x47800f25 , 0x47c004fc , 0x480ff013 , 0x484ff593 , 0x48800f33 , 0x48c01068 , 0x490ff375 , 0x494fe999
	 , 0x498007a2 , 0x49c01b90 , 0x4a0fff65 , 0x4a4fe0c2 , 0x4a8ff799 , 0x4ac02092 , 0x4b0012c4 , 0x4b4fe103
	 , 0x4b8fe22c , 0x4bc019f2 , 0x4c0028a3 , 0x4c4feef5 , 0x4c8fce29 , 0x4cc00484 , 0x4d003840 , 0x4d400b2c
	 , 0x4d8fc55e , 0x4dcfe2e9 , 0x4e0037f5 , 0x4e402ff8 , 0x4e8fd092 , 0x4ecfbde1 , 0x4f0020dd , 0x4f405218
	 , 0x4f8ff44f , 0x4fcfa2b2 , 0x500ff04d , 0x50406008 , 0x50802d78 , 0x50cfa580 , 0x510fb354 , 0x51404a82
	 , 0x518069a2 , 0x51cfd000 , 0x520f7ef5 , 0x52400b5c , 0x52808ecf , 0x52c02152 , 0x530f70dc , 0x534fad96
	 , 0x53807f06 , 0x53c082c7 , 0x540fa30a , 0x544f538d , 0x548028c1 , 0x54c0c814 , 0x55001b21 , 0x554f3223
	 , 0x558f9741 , 0x55c0b6f2 , 0x5600b687 , 0x564f8102 , 0x568f0843 , 0x56c02534 , 0x57011c19 , 0x5740507e
	 , 0x578eee24 , 0x57cf2cfd , 0x5800c91c , 0x58414771 , 0x588fc601 , 0x58ce79ba , 0x590f6e6b , 0x59415ebe
	 , 0x59817000 , 0x59cf5b76 , 0x5a0df777 , 0x5a4f51ac , 0x5a81cf09 , 0x5ac23653 , 0x5b0fce37 , 0x5b4d3da8
	 , 0x5b8d65b8 , 0x5bc050ef , 0x5c038e37 , 0x5c44e2b2 , 0x5c8411a5 , 0x5cc259a3 , 0x5d00f248 , 0x5d403f0e
	 , 0x5d800839 , 0x8000001b , 0x80400018 , 0x8080000a , 0x80cfffd7 , 0x810fff67 , 0x814ffea2 , 0x818ffd76
	 , 0x81cffbdd , 0x820ff9e2 , 0x824ff7a8 , 0x828ff567 , 0x82cff36c , 0x830ff20b , 0x834ff197 , 0x838ff24a
	 , 0x83cff43b , 0x840ff751 , 0x844ffb3f , 0x848fff88 , 0x84c00392 , 0x850006c0 , 0x8540088b , 0x858008a2
	 , 0x85c006fd , 0x860003e9 , 0x864ffffc , 0x868ffbff , 0x86cff8c8 , 0x870ff70f , 0x874ff745 , 0x878ff975
	 , 0x87cffd3d , 0x880001da , 0x8840064c , 0x8880098f , 0x88c00ad0 , 0x890009a4 , 0x89400627 , 0x898000ff
	 , 0x89cffb43 , 0x8a0ff63c , 0x8a4ff326 , 0x8a8ff2dd , 0x8acff5a5 , 0x8b0ffb11 , 0x8b40020c , 0x8b80090e
	 , 0x8bc00e72 , 0x8c0010d3 , 0x8c400f69 , 0x8c800a42 , 0x8cc0024f , 0x8d0ff93e , 0x8d4ff120 , 0x8d8febf1
	 , 0x8dcfeb25 , 0x8e0fef3d , 0x8e4ff79d , 0x8e800296 , 0x8ec00dbd , 0x8f00166d , 0x8f401a67 , 0x8f80185f
	 , 0x8fc01061 , 0x900003e4 , 0x904ff58f , 0x908fe8ab , 0x90cfe066 , 0x910fdf12 , 0x914fe583 , 0x918ff2c3
	 , 0x91c00427 , 0x920015d6 , 0x92402399 , 0x928029d9 , 0x92c02684 , 0x930019aa , 0x934005a6 , 0x938feeb6
	 , 0x93cfda21 , 0x940fcd09 , 0x944fcb2c , 0x948fd5e8 , 0x94cfebb1 , 0x95000838 , 0x95402531 , 0x95803baf
	 , 0x95c045b6 , 0x96003fc0 , 0x964029c6 , 0x96800799 , 0x96cfe04c , 0x970fbcdb , 0x974fa63a , 0x978fa339
	 , 0x97cfb6af , 0x980fde6d , 0x98401333 , 0x988049d5 , 0x98c0755a , 0x990089c4 , 0x99407eed , 0x998052d5
	 , 0x99c00ae7 , 0x9a0fb3cc , 0x9a4f5fb8 , 0x9a8f2367 , 0x9acf1259 , 0x9b0f3aea , 0x9b4fa313 , 0x9b804687
	 , 0x9bc1168b , 0x9c01fbbc , 0x9c42d96f , 0x9c839233 , 0x9cc40c98 , 0x9d04376b , 0x9d440c98 , 0x9d839233
	 , 0x9dc2d96f , 0x9e01fbbc , 0x9e41168b , 0x9e804687 , 0x9ecfa313 , 0x9f0f3aea , 0x9f4f1259 , 0x9f8f2367
	 , 0x9fcf5fb8 , 0xa00fb3cc , 0xa0400ae7 , 0xa08052d5 , 0xa0c07eed , 0xa10089c4 , 0xa140755a , 0xa18049d5
	 , 0xa1c01333 , 0xa20fde6d , 0xa24fb6af , 0xa28fa339 , 0xa2cfa63a , 0xa30fbcdb , 0xa34fe04c , 0xa3800799
	 , 0xa3c029c6 , 0xa4003fc0 , 0xa44045b6 , 0xa4803baf , 0xa4c02531 , 0xa5000838 , 0xa54febb1 , 0xa58fd5e8
	 , 0xa5cfcb2c , 0xa60fcd09 , 0xa64fda21 , 0xa68feeb6 , 0xa6c005a6 , 0xa70019aa , 0xa7402684 , 0xa78029d9
	 , 0xa7c02399 , 0xa80015d6 , 0xa8400427 , 0xa88ff2c3 , 0xa8cfe583 , 0xa90fdf12 , 0xa94fe066 , 0xa98fe8ab
	 , 0xa9cff58f , 0xaa0003e4 , 0xaa401061 , 0xaa80185f , 0xaac01a67 , 0xab00166d , 0xab400dbd , 0xab800296
	 , 0xabcff79d , 0xac0fef3d , 0xac4feb25 , 0xac8febf1 , 0xaccff120 , 0xad0ff93e , 0xad40024f , 0xad800a42
	 , 0xadc00f69 , 0xae0010d3 , 0xae400e72 , 0xae80090e , 0xaec0020c , 0xaf0ffb11 , 0xaf4ff5a5 , 0xaf8ff2dd
	 , 0xafcff326 , 0xb00ff63c , 0xb04ffb43 , 0xb08000ff , 0xb0c00627 , 0xb10009a4 , 0xb1400ad0 , 0xb180098f
	 , 0xb1c0064c , 0xb20001da , 0xb24ffd3d , 0xb28ff975 , 0xb2cff745 , 0xb30ff70f , 0xb34ff8c8 , 0xb38ffbff
	 , 0xb3cffffc , 0xb40003e9 , 0xb44006fd , 0xb48008a2 , 0xb4c0088b , 0xb50006c0 , 0xb5400392 , 0xb58fff88
	 , 0xb5cffb3f , 0xb60ff751 , 0xb64ff43b , 0xb68ff24a , 0xb6cff197 , 0xb70ff20b , 0xb74ff36c , 0xb78ff567
	 , 0xb7cff7a8 , 0xb80ff9e2 , 0xb84ffbdd , 0xb88ffd76 , 0xb8cffea2 , 0xb90fff67 , 0xb94fffd7 , 0xb980000a
	 , 0xb9c00018 , 0xba00001b , 0x0000c001 , 0x0b001803 , 0x00000000 , 0x00000e03 , 0x00000000 , 0x00000000
	 , 0x00000000 , 0x00000000 , 0x00000091 , 0x00010076 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000
	 , 0x00000000 , 0x00000000 , 0x00000091 , 0x000501e8 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000
	 , 0x00000000 , 0x00000000 , 0x40000049 , 0x40400181 , 0x4080036d , 0x40c00453 , 0x41000278 , 0x414fff19
	 , 0x418ffded , 0x41c00037 , 0x42000245 , 0x4240008c , 0x428ffd9b , 0x42cffe9d , 0x4300026c , 0x43400267
	 , 0x438ffdb1 , 0x43cffc25 , 0x4400016f , 0x44400521 , 0x448ffff3 , 0x44cff9c4 , 0x450ffdf9 , 0x454006bf
	 , 0x4580048e , 0x45cff973 , 0x460ff896 , 0x46400572 , 0x46800a69 , 0x46cffccf , 0x470ff2d1 , 0x474fffa4
	 , 0x47800f25 , 0x47c004fc , 0x480ff013 , 0x484ff593 , 0x48800f33 , 0x48c01068 , 0x490ff375 , 0x494fe999
	 , 0x498007a2 , 0x49c01b90 , 0x4a0fff65 , 0x4a4fe0c2 , 0x4a8ff799 , 0x4ac02092 , 0x4b0012c4 , 0x4b4fe103
	 , 0x4b8fe22c , 0x4bc019f2 , 0x4c0028a3 , 0x4c4feef5 , 0x4c8fce29 , 0x4cc00484 , 0x4d003840 , 0x4d400b2c
	 , 0x4d8fc55e , 0x4dcfe2e9 , 0x4e0037f5 , 0x4e402ff8 , 0x4e8fd092 , 0x4ecfbde1 , 0x4f0020dd , 0x4f405218
	 , 0x4f8ff44f , 0x4fcfa2b2 , 0x500ff04d , 0x50406008 , 0x50802d78 , 0x50cfa580 , 0x510fb354 , 0x51404a82
	 , 0x518069a2 , 0x51cfd000 , 0x520f7ef5 , 0x52400b5c , 0x52808ecf , 0x52c02152 , 0x530f70dc , 0x534fad96
	 , 0x53807f06 , 0x53c082c7 , 0x540fa30a , 0x544f538d , 0x548028c1 , 0x54c0c814 , 0x55001b21 , 0x554f3223
	 , 0x558f9741 , 0x55c0b6f2 , 0x5600b687 , 0x564f8102 , 0x568f0843 , 0x56c02534 , 0x57011c19 , 0x5740507e
	 , 0x578eee24 , 0x57cf2cfd , 0x5800c91c , 0x58414771 , 0x588fc601 , 0x58ce79ba , 0x590f6e6b , 0x59415ebe
	 , 0x59817000 , 0x59cf5b76 , 0x5a0df777 , 0x5a4f51ac , 0x5a81cf09 , 0x5ac23653 , 0x5b0fce37 , 0x5b4d3da8
	 , 0x5b8d65b8 , 0x5bc050ef , 0x5c038e37 , 0x5c44e2b2 , 0x5c8411a5 , 0x5cc259a3 , 0x5d00f248 , 0x5d403f0e
	 , 0x5d800839 , 0x8000001b , 0x80400018 , 0x8080000a , 0x80cfffd7 , 0x810fff67 , 0x814ffea2 , 0x818ffd76
	 , 0x81cffbdd , 0x820ff9e2 , 0x824ff7a8 , 0x828ff567 , 0x82cff36c , 0x830ff20b , 0x834ff197 , 0x838ff24a
	 , 0x83cff43b , 0x840ff751 , 0x844ffb3f , 0x848fff88 , 0x84c00392 , 0x850006c0 , 0x8540088b , 0x858008a2
	 , 0x85c006fd , 0x860003e9 , 0x864ffffc , 0x868ffbff , 0x86cff8c8 , 0x870ff70f , 0x874ff745 , 0x878ff975
	 , 0x87cffd3d , 0x880001da , 0x8840064c , 0x8880098f , 0x88c00ad0 , 0x890009a4 , 0x89400627 , 0x898000ff
	 , 0x89cffb43 , 0x8a0ff63c , 0x8a4ff326 , 0x8a8ff2dd , 0x8acff5a5 , 0x8b0ffb11 , 0x8b40020c , 0x8b80090e
	 , 0x8bc00e72 , 0x8c0010d3 , 0x8c400f69 , 0x8c800a42 , 0x8cc0024f , 0x8d0ff93e , 0x8d4ff120 , 0x8d8febf1
	 , 0x8dcfeb25 , 0x8e0fef3d , 0x8e4ff79d , 0x8e800296 , 0x8ec00dbd , 0x8f00166d , 0x8f401a67 , 0x8f80185f
	 , 0x8fc01061 , 0x900003e4 , 0x904ff58f , 0x908fe8ab , 0x90cfe066 , 0x910fdf12 , 0x914fe583 , 0x918ff2c3
	 , 0x91c00427 , 0x920015d6 , 0x92402399 , 0x928029d9 , 0x92c02684 , 0x930019aa , 0x934005a6 , 0x938feeb6
	 , 0x93cfda21 , 0x940fcd09 , 0x944fcb2c , 0x948fd5e8 , 0x94cfebb1 , 0x95000838 , 0x95402531 , 0x95803baf
	 , 0x95c045b6 , 0x96003fc0 , 0x964029c6 , 0x96800799 , 0x96cfe04c , 0x970fbcdb , 0x974fa63a , 0x978fa339
	 , 0x97cfb6af , 0x980fde6d , 0x98401333 , 0x988049d5 , 0x98c0755a , 0x990089c4 , 0x99407eed , 0x998052d5
	 , 0x99c00ae7 , 0x9a0fb3cc , 0x9a4f5fb8 , 0x9a8f2367 , 0x9acf1259 , 0x9b0f3aea , 0x9b4fa313 , 0x9b804687
	 , 0x9bc1168b , 0x9c01fbbc , 0x9c42d96f , 0x9c839233 , 0x9cc40c98 , 0x9d04376b , 0x9d440c98 , 0x9d839233
	 , 0x9dc2d96f , 0x9e01fbbc , 0x9e41168b , 0x9e804687 , 0x9ecfa313 , 0x9f0f3aea , 0x9f4f1259 , 0x9f8f2367
	 , 0x9fcf5fb8 , 0xa00fb3cc , 0xa0400ae7 , 0xa08052d5 , 0xa0c07eed , 0xa10089c4 , 0xa140755a , 0xa18049d5
	 , 0xa1c01333 , 0xa20fde6d , 0xa24fb6af , 0xa28fa339 , 0xa2cfa63a , 0xa30fbcdb , 0xa34fe04c , 0xa3800799
	 , 0xa3c029c6 , 0xa4003fc0 , 0xa44045b6 , 0xa4803baf , 0xa4c02531 , 0xa5000838 , 0xa54febb1 , 0xa58fd5e8
	 , 0xa5cfcb2c , 0xa60fcd09 , 0xa64fda21 , 0xa68feeb6 , 0xa6c005a6 , 0xa70019aa , 0xa7402684 , 0xa78029d9
	 , 0xa7c02399 , 0xa80015d6 , 0xa8400427 , 0xa88ff2c3 , 0xa8cfe583 , 0xa90fdf12 , 0xa94fe066 , 0xa98fe8ab
	 , 0xa9cff58f , 0xaa0003e4 , 0xaa401061 , 0xaa80185f , 0xaac01a67 , 0xab00166d , 0xab400dbd , 0xab800296
	 , 0xabcff79d , 0xac0fef3d , 0xac4feb25 , 0xac8febf1 , 0xaccff120 , 0xad0ff93e , 0xad40024f , 0xad800a42
	 , 0xadc00f69 , 0xae0010d3 , 0xae400e72 , 0xae80090e , 0xaec0020c , 0xaf0ffb11 , 0xaf4ff5a5 , 0xaf8ff2dd
	 , 0xafcff326 , 0xb00ff63c , 0xb04ffb43 , 0xb08000ff , 0xb0c00627 , 0xb10009a4 , 0xb1400ad0 , 0xb180098f
	 , 0xb1c0064c , 0xb20001da , 0xb24ffd3d , 0xb28ff975 , 0xb2cff745 , 0xb30ff70f , 0xb34ff8c8 , 0xb38ffbff
	 , 0xb3cffffc , 0xb40003e9 , 0xb44006fd , 0xb48008a2 , 0xb4c0088b , 0xb50006c0 , 0xb5400392 , 0xb58fff88
	 , 0xb5cffb3f , 0xb60ff751 , 0xb64ff43b , 0xb68ff24a , 0xb6cff197 , 0xb70ff20b , 0xb74ff36c , 0xb78ff567
	 , 0xb7cff7a8 , 0xb80ff9e2 , 0xb84ffbdd , 0xb88ffd76 , 0xb8cffea2 , 0xb90fff67 , 0xb94fffd7 , 0xb980000a
	 , 0xb9c00018 , 0xba00001b
};
```

@singalsu
Copy link
Collaborator Author

singalsu commented May 31, 2021

@RanderWang Thanks! I could add it to PR to help your testing. With the #define BLOB_XXX naming scheme in nhlt_dmic_cfg.h, how would you name it?

Did you try if any of the included blobs work? The temporary included blobs are what I've needed for my 24/38.4 MHz test devices. There will be with timer scheduled pipelines xruns if IOclk assumption is not correct. The tplg tool that does the conversions need to know the target platform IOclk rate. I'd assume most (new) systems will be 38.4 MHz.

@singalsu
Copy link
Collaborator Author

@RanderWang What's the purpose of the first zero 32 bit integer in your example? I started the blob from "TsGroup". Those seem to be your next values "0xffffff10 , 0xffffff10 , 0xffffffff , 0xffffffff"

@RanderWang
Copy link
Collaborator

RanderWang commented Jun 1, 2021

@RanderWang What's the purpose of the first zero 32 bit integer in your example? I started the blob from "TsGroup". Those seem to be your next values "0xffffff10 , 0xffffff10 , 0xffffffff , 0xffffffff"

you can ignore it. It is used for gateway attribute. Now only used for lp mode (low power mode) support or not. In my opinion, we will allocate memory from lp memory section if lp mode is set. We can refine it later.

@RanderWang
Copy link
Collaborator

@RanderWang Thanks! I could add it to PR to help your testing. With the #define BLOB_XXX naming scheme in nhlt_dmic_cfg.h, how would you name it?

clk number + sample rate + ch count

Did you try if any of the included blobs work? The temporary included blobs are what I've needed for my 24/38.4 MHz test devices. There will be with timer scheduled pipelines xruns if IOclk assumption is not correct. The tplg tool that does the conversions need to know the target platform IOclk rate. I'd assume most (new) systems will be 38.4 MHz.

38.4MHz is only applied to current devices not feature ones. My blob was for 38.4MHz. We will not use tplg tool to generate dmic blob and I want to reuse BIOS settings (stored in tplg) at least for windows platform. For non-windows platforms, we can reused windows settings or else. what's your opinion ?

I will work with your PR and refine our IPC4 to cooperate with it.

Comment on lines 168 to 187
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu there is no unmute_ramp_time_ms for IPC4, could you help to isolate these code ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This a tricky one. The BIOS does not describe how long it takes for the microphone signal to become valid. It depends on microphone component and our HW version. It needs to come from topology in Linux and ChromeOS. It would be possible to move this function to volume component (add the log ramp type) if there's always volume in the pipeline after DMIC DAI. Can the DMIC DAI new() still pass tokens values in addition to the blob?

@RanderWang
Copy link
Collaborator

@singalsu I did these changes to test IPC4 path. I don't have a device with DMIC device equiped but at least I didn't get any error or XRUN for DMIC capture.

diff --git a/src/drivers/intel/dmic/dmic.c b/src/drivers/intel/dmic/dmic.c
index 17d27752d..f9836c162 100644
--- a/src/drivers/intel/dmic/dmic.c
+++ b/src/drivers/intel/dmic/dmic.c
@@ -153,8 +153,8 @@ static int dmic_set_config(struct dai *dai, struct ipc_config_dai *common_config
 {
 	struct dmic_pdata *dmic = dai_get_drvdata(dai);
 	struct sof_ipc_dai_config *config = spec_config;
-	int32_t unmute_ramp_time_ms;
-	int32_t step_db;
+//	int32_t unmute_ramp_time_ms;
+//	int32_t step_db;
 	size_t size;
 	int i;
 	int ret = 0;
@@ -162,7 +162,6 @@ static int dmic_set_config(struct dai *dai, struct ipc_config_dai *common_config
 
 #if CONFIG_INTEL_DMIC_TPLG_PARAMS
 	int j;
-#endif
 	dai_info(dai, "dmic_set_config()");
 
 	if (config->dmic.driver_ipc_version != DMIC_IPC_VERSION) {
@@ -204,6 +203,7 @@ static int dmic_set_config(struct dai *dai, struct ipc_config_dai *common_config
 	dmic->gain_coef = db2lin_fixed(step_db);
 	dai_info(dai, "dmic_set_config(): unmute_ramp_time_ms = %d", unmute_ramp_time_ms);
 
+#endif
 	/*
 	 * "config" might contain pdm controller params for only
 	 * the active controllers
@@ -262,7 +262,7 @@ static int dmic_set_config(struct dai *dai, struct ipc_config_dai *common_config
 	ret = dmic_set_config_computed(dai);
 
 #elif CONFIG_INTEL_DMIC_NHLT
-	ret = dmic_set_config_nhlt(dai);
+	ret = dmic_set_config_nhlt(dai, spec_config);
 
 #else
 	ret = -EINVAL;
diff --git a/src/drivers/intel/dmic/dmic_nhlt.c b/src/drivers/intel/dmic/dmic_nhlt.c
index f606c881c..15b47e1ad 100644
--- a/src/drivers/intel/dmic/dmic_nhlt.c
+++ b/src/drivers/intel/dmic/dmic_nhlt.c
@@ -12,7 +12,7 @@
 
 #if CONFIG_INTEL_DMIC_NHLT
 
-#include "nhlt_dmic_cfg.h"
+//#include "nhlt_dmic_cfg.h"
 
 /* Base addresses (in PDM scope) of 2ch PDM controllers and coefficient RAM. */
 static const uint32_t base[4] = {PDM0, PDM1, PDM2, PDM3};
@@ -100,7 +100,7 @@ static int nhlt_dmic_dai_params_get(struct dai *dai, uint32_t outcontrol[],
 	return 0;
 }
 
-int dmic_set_config_nhlt(struct dai *dai)
+int dmic_set_config_nhlt(struct dai *dai, void *blob_data)
 {
 	struct dmic_pdata *pdata = dai_get_drvdata(dai);
 	struct nhlt_pdm_ctrl_cfg *pdm_cfg[DMIC_HW_CONTROLLERS_MAX];
@@ -113,7 +113,7 @@ int dmic_set_config_nhlt(struct dai *dai)
 	uint32_t pdm_ctrl_mask;
 	uint32_t val;
 	uint32_t fir_control = 0;
-	const uint8_t *p = &nhlt_dmic_cfg[0]; /* Temporary blob, will be replaced by IPC */
+	const uint8_t *p = blob_data; 
 	int num_fifos = 0;
 	int num_pdm;
 	int fir_length_a;
@@ -131,6 +131,7 @@ int dmic_set_config_nhlt(struct dai *dai)
 	int ret;
 
 	/* Skip not used headers */
+	p += sizeof(union ipc4_gateway_attributes);
 	p += sizeof(struct nhlt_ts_group);
 	p += sizeof(struct nhlt_clock_on_delay);
 
diff --git a/src/include/sof/drivers/dmic.h b/src/include/sof/drivers/dmic.h
index 6f9224cf8..8de15a077 100644
--- a/src/include/sof/drivers/dmic.h
+++ b/src/include/sof/drivers/dmic.h
@@ -530,7 +530,7 @@ struct nhlt_pdm_fir_coeffs {
 
 int dmic_set_config_computed(struct dai *dai);
 int dmic_get_hw_params_computed(struct dai *dai, struct sof_ipc_stream_params *params, int dir);
-int dmic_set_config_nhlt(struct dai *dai);
+int dmic_set_config_nhlt(struct dai *dai, void *blob_data);
 int dmic_get_hw_params_nhlt(struct dai *dai, struct sof_ipc_stream_params *params, int dir);
 
 extern const struct dai_driver dmic_driver;

@singalsu
Copy link
Collaborator Author

singalsu commented Jun 1, 2021

@RanderWang Thanks! I will add your changes proposals and try also here.

@singalsu singalsu force-pushed the dmic_nhlt_blob branch 3 times, most recently from 7a73806 to dc30977 Compare July 14, 2021 15:55
@singalsu
Copy link
Collaborator Author

Found the issue in diagnostic driver based CI. The ramp duration in IPC is zero and check against min (10 ms) failed. I had accidentally dropped from code the handling of zero duration. Hope it passes now!

@singalsu singalsu requested a review from lyakh July 14, 2021 16:00
Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I found one more nit to complain about :-) But should be really simple to fix!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I've traced it down, it's now called popcount(), let's use it

Copy link
Collaborator

@RanderWang RanderWang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@singalsu
Copy link
Collaborator Author

@RanderWang Thanks for your review and tests done!

@lgirdwood How should I proceed, in theory this could be merged (though need to pass all CI). Should I keep this draft until new IPC support is needed or make it ready for review?

singalsu added 4 commits July 16, 2021 19:20
In preparation for more functionality the module is moved
to own directory similarly as other DAI drivers.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch moves the run-time decimation factors search and filter
coefficients scaling code to separate module as preparation to add
more functionality to the driver. There are no changes to
functionality.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch replaces previous constant 400 ms ramp time with
sample rate dependent first order slope. The Slope coefficient -205
as Q15 and offset 500 as Q0 cause 400 ms ramp for 16 kHz and
200 ms ramp for 48 audio. The ramp min and max time are limited to
previously used check values. The default ramp is used when IPC does
not provide it from topology.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds to DMIC driver support for binary data based HW
registers setup. The driver mode is selected in Kconfig.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu marked this pull request as ready for review July 19, 2021 08:23
@lgirdwood
Copy link
Member

@singalsu are we still WIP and RFC ?

@singalsu singalsu changed the title [WIP][RFC] Drivers: Intel: Add support for NHLT blob based configuration Drivers: Intel: Add support for NHLT blob based configuration Jul 19, 2021
@singalsu
Copy link
Collaborator Author

@lgirdwood I just edited and removed [WIP][RFC] for this github page. The patch commit titles were no more with those labels.

@lgirdwood lgirdwood merged commit 4f8cf51 into thesofproject:main Jul 19, 2021
@singalsu singalsu deleted the dmic_nhlt_blob branch July 21, 2021 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants