~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/codecs/cs-amp-lib-test.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/soc/codecs/cs-amp-lib-test.c (Version linux-6.11-rc3) and /sound/soc/codecs/cs-amp-lib-test.c (Version ccs-tools-1.8.9)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 //                                                
  3 // KUnit test for the Cirrus common amplifier     
  4 //                                                
  5 // Copyright (C) 2024 Cirrus Logic, Inc. and      
  6 //                    Cirrus Logic Internation    
  7                                                   
  8 #include <kunit/test.h>                           
  9 #include <kunit/static_stub.h>                    
 10 #include <linux/firmware/cirrus/cs_dsp.h>         
 11 #include <linux/firmware/cirrus/wmfw.h>           
 12 #include <linux/gpio/driver.h>                    
 13 #include <linux/list.h>                           
 14 #include <linux/module.h>                         
 15 #include <linux/platform_device.h>                
 16 #include <linux/random.h>                         
 17 #include <sound/cs-amp-lib.h>                     
 18                                                   
 19 struct cs_amp_lib_test_priv {                     
 20         struct platform_device amp_pdev;          
 21                                                   
 22         struct cirrus_amp_efi_data *cal_blob;     
 23         struct list_head ctl_write_list;          
 24 };                                                
 25                                                   
 26 struct cs_amp_lib_test_ctl_write_entry {          
 27         struct list_head list;                    
 28         unsigned int value;                       
 29         char name[16];                            
 30 };                                                
 31                                                   
 32 struct cs_amp_lib_test_param {                    
 33         int num_amps;                             
 34         int amp_index;                            
 35 };                                                
 36                                                   
 37 static void cs_amp_lib_test_init_dummy_cal_blo    
 38 {                                                 
 39         struct cs_amp_lib_test_priv *priv = te    
 40         unsigned int blob_size;                   
 41                                                   
 42         blob_size = offsetof(struct cirrus_amp    
 43                     sizeof(struct cirrus_amp_c    
 44                                                   
 45         priv->cal_blob = kunit_kzalloc(test, b    
 46         KUNIT_ASSERT_NOT_NULL(test, priv->cal_    
 47                                                   
 48         priv->cal_blob->size = blob_size;         
 49         priv->cal_blob->count = num_amps;         
 50                                                   
 51         get_random_bytes(priv->cal_blob->data,    
 52 }                                                 
 53                                                   
 54 static u64 cs_amp_lib_test_get_target_uid(stru    
 55 {                                                 
 56         struct cs_amp_lib_test_priv *priv = te    
 57         const struct cs_amp_lib_test_param *pa    
 58         u64 uid;                                  
 59                                                   
 60         uid = priv->cal_blob->data[param->amp_    
 61         uid <<= 32;                               
 62         uid |= priv->cal_blob->data[param->amp    
 63                                                   
 64         return uid;                               
 65 }                                                 
 66                                                   
 67 /* Redirected get_efi_variable to simulate tha    
 68 static efi_status_t cs_amp_lib_test_get_efi_va    
 69                                                   
 70                                                   
 71                                                   
 72 {                                                 
 73         if (!buf) {                               
 74                 *size = offsetof(struct cirrus    
 75                 return EFI_BUFFER_TOO_SMALL;      
 76         }                                         
 77                                                   
 78         return EFI_NOT_FOUND;                     
 79 }                                                 
 80                                                   
 81 /* Should return -EOVERFLOW if the header is l    
 82 static void cs_amp_lib_test_cal_data_too_short    
 83 {                                                 
 84         struct cs_amp_lib_test_priv *priv = te    
 85         struct cirrus_amp_cal_data result_data    
 86         int ret;                                  
 87                                                   
 88         /* Redirect calls to get EFI data */      
 89         kunit_activate_static_stub(test,          
 90                                    cs_amp_test    
 91                                    cs_amp_lib_    
 92                                                   
 93         ret = cs_amp_get_efi_calibration_data(    
 94         KUNIT_EXPECT_EQ(test, ret, -EOVERFLOW)    
 95                                                   
 96         kunit_deactivate_static_stub(test, cs_    
 97 }                                                 
 98                                                   
 99 /* Redirected get_efi_variable to simulate tha    
100 static efi_status_t cs_amp_lib_test_get_efi_va    
101                                                   
102                                                   
103                                                   
104 {                                                 
105         struct kunit *test = kunit_get_current    
106         struct cs_amp_lib_test_priv *priv = te    
107                                                   
108         if (!buf) {                               
109                 /*                                
110                  * Return a size that is short    
111                  * declared number of entries.    
112                  */                               
113                 *size = priv->cal_blob->size -    
114                 return EFI_BUFFER_TOO_SMALL;      
115         }                                         
116                                                   
117         memcpy(buf, priv->cal_blob, priv->cal_    
118                                                   
119         return EFI_SUCCESS;                       
120 }                                                 
121                                                   
122 /* Should return -EOVERFLOW if the entry count    
123 static void cs_amp_lib_test_cal_count_too_big_    
124 {                                                 
125         struct cs_amp_lib_test_priv *priv = te    
126         struct cirrus_amp_cal_data result_data    
127         int ret;                                  
128                                                   
129         cs_amp_lib_test_init_dummy_cal_blob(te    
130                                                   
131         /* Redirect calls to get EFI data */      
132         kunit_activate_static_stub(test,          
133                                    cs_amp_test    
134                                    cs_amp_lib_    
135                                                   
136         ret = cs_amp_get_efi_calibration_data(    
137         KUNIT_EXPECT_EQ(test, ret, -EOVERFLOW)    
138                                                   
139         kunit_deactivate_static_stub(test, cs_    
140 }                                                 
141                                                   
142 /* Redirected get_efi_variable to simulate tha    
143 static efi_status_t cs_amp_lib_test_get_efi_va    
144                                                   
145                                                   
146                                                   
147 {                                                 
148         return EFI_NOT_FOUND;                     
149 }                                                 
150                                                   
151 /* If EFI doesn't contain a cal data variable     
152 static void cs_amp_lib_test_no_cal_data_test(s    
153 {                                                 
154         struct cs_amp_lib_test_priv *priv = te    
155         struct cirrus_amp_cal_data result_data    
156         int ret;                                  
157                                                   
158         /* Redirect calls to get EFI data */      
159         kunit_activate_static_stub(test,          
160                                    cs_amp_test    
161                                    cs_amp_lib_    
162                                                   
163         ret = cs_amp_get_efi_calibration_data(    
164         KUNIT_EXPECT_EQ(test, ret, -ENOENT);      
165                                                   
166         kunit_deactivate_static_stub(test, cs_    
167 }                                                 
168                                                   
169 /* Redirected get_efi_variable to simulate rea    
170 static efi_status_t cs_amp_lib_test_get_efi_va    
171                                                   
172                                                   
173                                                   
174 {                                                 
175         static const efi_char16_t expected_nam    
176         static const efi_guid_t expected_guid     
177                 EFI_GUID(0x02f9af02, 0x7734, 0    
178         struct kunit *test = kunit_get_current    
179         struct cs_amp_lib_test_priv *priv = te    
180                                                   
181         KUNIT_EXPECT_NOT_ERR_OR_NULL(test, nam    
182         KUNIT_EXPECT_NOT_ERR_OR_NULL(test, gui    
183         KUNIT_EXPECT_NOT_ERR_OR_NULL(test, siz    
184                                                   
185         KUNIT_EXPECT_MEMEQ(test, name, expecte    
186         KUNIT_EXPECT_MEMEQ(test, guid, &expect    
187                                                   
188         if (!buf) {                               
189                 *size = priv->cal_blob->size;     
190                 return EFI_BUFFER_TOO_SMALL;      
191         }                                         
192                                                   
193         KUNIT_ASSERT_GE_MSG(test, ksize(buf),     
194                                                   
195         memcpy(buf, priv->cal_blob, priv->cal_    
196                                                   
197         return EFI_SUCCESS;                       
198 }                                                 
199                                                   
200 /* Get cal data block for a given amp, matched    
201 static void cs_amp_lib_test_get_efi_cal_by_uid    
202 {                                                 
203         struct cs_amp_lib_test_priv *priv = te    
204         const struct cs_amp_lib_test_param *pa    
205         struct cirrus_amp_cal_data result_data    
206         u64 target_uid;                           
207         int ret;                                  
208                                                   
209         cs_amp_lib_test_init_dummy_cal_blob(te    
210                                                   
211         /* Redirect calls to get EFI data */      
212         kunit_activate_static_stub(test,          
213                                    cs_amp_test    
214                                    cs_amp_lib_    
215                                                   
216         target_uid = cs_amp_lib_test_get_targe    
217         ret = cs_amp_get_efi_calibration_data(    
218         KUNIT_EXPECT_EQ(test, ret, 0);            
219                                                   
220         kunit_deactivate_static_stub(test, cs_    
221                                                   
222         KUNIT_EXPECT_EQ(test, result_data.calT    
223         KUNIT_EXPECT_EQ(test, result_data.calT    
224         KUNIT_EXPECT_EQ(test, result_data.calT    
225                               priv->cal_blob->    
226         KUNIT_EXPECT_EQ(test, result_data.calT    
227                               priv->cal_blob->    
228         KUNIT_EXPECT_EQ(test, result_data.calA    
229                               priv->cal_blob->    
230         KUNIT_EXPECT_EQ(test, result_data.calS    
231                               priv->cal_blob->    
232         KUNIT_EXPECT_EQ(test, result_data.calR    
233                               priv->cal_blob->    
234 }                                                 
235                                                   
236 /* Get cal data block for a given amp index wi    
237 static void cs_amp_lib_test_get_efi_cal_by_ind    
238 {                                                 
239         struct cs_amp_lib_test_priv *priv = te    
240         const struct cs_amp_lib_test_param *pa    
241         struct cirrus_amp_cal_data result_data    
242         int ret;                                  
243                                                   
244         cs_amp_lib_test_init_dummy_cal_blob(te    
245                                                   
246         /* Redirect calls to get EFI data */      
247         kunit_activate_static_stub(test,          
248                                    cs_amp_test    
249                                    cs_amp_lib_    
250                                                   
251         ret = cs_amp_get_efi_calibration_data(    
252                                                   
253         KUNIT_EXPECT_EQ(test, ret, 0);            
254                                                   
255         kunit_deactivate_static_stub(test, cs_    
256                                                   
257         KUNIT_EXPECT_EQ(test, result_data.calT    
258                               priv->cal_blob->    
259         KUNIT_EXPECT_EQ(test, result_data.calT    
260                               priv->cal_blob->    
261         KUNIT_EXPECT_EQ(test, result_data.calA    
262                               priv->cal_blob->    
263         KUNIT_EXPECT_EQ(test, result_data.calS    
264                               priv->cal_blob->    
265         KUNIT_EXPECT_EQ(test, result_data.calR    
266                               priv->cal_blob->    
267 }                                                 
268                                                   
269 /* Get cal data block for a given amp index wi    
270 static void cs_amp_lib_test_get_efi_cal_by_ind    
271 {                                                 
272         struct cs_amp_lib_test_priv *priv = te    
273         const struct cs_amp_lib_test_param *pa    
274         struct cirrus_amp_cal_data result_data    
275         u64 target_uid;                           
276         int ret;                                  
277                                                   
278         cs_amp_lib_test_init_dummy_cal_blob(te    
279                                                   
280         /* Redirect calls to get EFI data */      
281         kunit_activate_static_stub(test,          
282                                    cs_amp_test    
283                                    cs_amp_lib_    
284                                                   
285         target_uid = cs_amp_lib_test_get_targe    
286         ret = cs_amp_get_efi_calibration_data(    
287                                                   
288         KUNIT_EXPECT_EQ(test, ret, 0);            
289                                                   
290         kunit_deactivate_static_stub(test, cs_    
291                                                   
292         KUNIT_EXPECT_EQ(test, result_data.calT    
293                               priv->cal_blob->    
294         KUNIT_EXPECT_EQ(test, result_data.calT    
295                               priv->cal_blob->    
296         KUNIT_EXPECT_EQ(test, result_data.calA    
297                               priv->cal_blob->    
298         KUNIT_EXPECT_EQ(test, result_data.calS    
299                               priv->cal_blob->    
300         KUNIT_EXPECT_EQ(test, result_data.calR    
301                               priv->cal_blob->    
302 }                                                 
303                                                   
304 /*                                                
305  * Get cal data block for a given amp index wi    
306  * The UID does not match so the result should    
307  */                                               
308 static void cs_amp_lib_test_get_efi_cal_by_ind    
309 {                                                 
310         struct cs_amp_lib_test_priv *priv = te    
311         const struct cs_amp_lib_test_param *pa    
312         struct cirrus_amp_cal_data result_data    
313         u64 target_uid;                           
314         int ret;                                  
315                                                   
316         cs_amp_lib_test_init_dummy_cal_blob(te    
317                                                   
318         /* Redirect calls to get EFI data */      
319         kunit_activate_static_stub(test,          
320                                    cs_amp_test    
321                                    cs_amp_lib_    
322                                                   
323         /* Get a target UID that won't match t    
324         target_uid = ~cs_amp_lib_test_get_targ    
325         ret = cs_amp_get_efi_calibration_data(    
326                                                   
327         KUNIT_EXPECT_EQ(test, ret, -ENOENT);      
328                                                   
329         kunit_deactivate_static_stub(test, cs_    
330 }                                                 
331                                                   
332 /*                                                
333  * Get cal data block for a given amp, where t    
334  * specify calTarget so the lookup falls back     
335  */                                               
336 static void cs_amp_lib_test_get_efi_cal_by_ind    
337 {                                                 
338         struct cs_amp_lib_test_priv *priv = te    
339         const struct cs_amp_lib_test_param *pa    
340         struct cirrus_amp_cal_data result_data    
341         static const u64 bad_target_uid = 0xBA    
342         int i, ret;                               
343                                                   
344         cs_amp_lib_test_init_dummy_cal_blob(te    
345                                                   
346         /* Make all the target values zero so     
347         for (i = 0; i < priv->cal_blob->count;    
348                 priv->cal_blob->data[i].calTar    
349                 priv->cal_blob->data[i].calTar    
350         }                                         
351                                                   
352         /* Redirect calls to get EFI data */      
353         kunit_activate_static_stub(test,          
354                                    cs_amp_test    
355                                    cs_amp_lib_    
356                                                   
357         ret = cs_amp_get_efi_calibration_data(    
358                                                   
359         KUNIT_EXPECT_EQ(test, ret, 0);            
360                                                   
361         kunit_deactivate_static_stub(test, cs_    
362                                                   
363         KUNIT_EXPECT_EQ(test, result_data.calT    
364                               priv->cal_blob->    
365         KUNIT_EXPECT_EQ(test, result_data.calT    
366                               priv->cal_blob->    
367         KUNIT_EXPECT_EQ(test, result_data.calA    
368                               priv->cal_blob->    
369         KUNIT_EXPECT_EQ(test, result_data.calS    
370                               priv->cal_blob->    
371         KUNIT_EXPECT_EQ(test, result_data.calR    
372                               priv->cal_blob->    
373 }                                                 
374                                                   
375 /*                                                
376  * If the target UID isn't present in the cal     
377  * index to fall back do, the result should be    
378  */                                               
379 static void cs_amp_lib_test_get_efi_cal_uid_no    
380 {                                                 
381         struct cs_amp_lib_test_priv *priv = te    
382         struct cirrus_amp_cal_data result_data    
383         static const u64 bad_target_uid = 0xBA    
384         int i, ret;                               
385                                                   
386         cs_amp_lib_test_init_dummy_cal_blob(te    
387                                                   
388         /* Make all the target values != bad_t    
389         for (i = 0; i < priv->cal_blob->count;    
390                 priv->cal_blob->data[i].calTar    
391                 priv->cal_blob->data[i].calTar    
392         }                                         
393                                                   
394         /* Redirect calls to get EFI data */      
395         kunit_activate_static_stub(test,          
396                                    cs_amp_test    
397                                    cs_amp_lib_    
398                                                   
399         ret = cs_amp_get_efi_calibration_data(    
400                                                   
401         KUNIT_EXPECT_EQ(test, ret, -ENOENT);      
402                                                   
403         kunit_deactivate_static_stub(test, cs_    
404 }                                                 
405                                                   
406 /*                                                
407  * If the target UID isn't present in the cal     
408  * out of range, the result should be -ENOENT.    
409  */                                               
410 static void cs_amp_lib_test_get_efi_cal_uid_no    
411 {                                                 
412         struct cs_amp_lib_test_priv *priv = te    
413         struct cirrus_amp_cal_data result_data    
414         static const u64 bad_target_uid = 0xBA    
415         int i, ret;                               
416                                                   
417         cs_amp_lib_test_init_dummy_cal_blob(te    
418                                                   
419         /* Make all the target values != bad_t    
420         for (i = 0; i < priv->cal_blob->count;    
421                 priv->cal_blob->data[i].calTar    
422                 priv->cal_blob->data[i].calTar    
423         }                                         
424                                                   
425         /* Redirect calls to get EFI data */      
426         kunit_activate_static_stub(test,          
427                                    cs_amp_test    
428                                    cs_amp_lib_    
429                                                   
430         ret = cs_amp_get_efi_calibration_data(    
431                                                   
432         KUNIT_EXPECT_EQ(test, ret, -ENOENT);      
433                                                   
434         kunit_deactivate_static_stub(test, cs_    
435 }                                                 
436                                                   
437 /*                                                
438  * If the target UID isn't given, and the inde    
439  * result should be -ENOENT.                      
440  */                                               
441 static void cs_amp_lib_test_get_efi_cal_no_uid    
442 {                                                 
443         struct cs_amp_lib_test_priv *priv = te    
444         struct cirrus_amp_cal_data result_data    
445         int ret;                                  
446                                                   
447         cs_amp_lib_test_init_dummy_cal_blob(te    
448                                                   
449         /* Redirect calls to get EFI data */      
450         kunit_activate_static_stub(test,          
451                                    cs_amp_test    
452                                    cs_amp_lib_    
453                                                   
454         ret = cs_amp_get_efi_calibration_data(    
455         KUNIT_EXPECT_EQ(test, ret, -ENOENT);      
456                                                   
457         kunit_deactivate_static_stub(test, cs_    
458 }                                                 
459                                                   
460 /* If neither the target UID or the index is g    
461 static void cs_amp_lib_test_get_efi_cal_no_uid    
462 {                                                 
463         struct cs_amp_lib_test_priv *priv = te    
464         struct cirrus_amp_cal_data result_data    
465         int ret;                                  
466                                                   
467         cs_amp_lib_test_init_dummy_cal_blob(te    
468                                                   
469         /* Redirect calls to get EFI data */      
470         kunit_activate_static_stub(test,          
471                                    cs_amp_test    
472                                    cs_amp_lib_    
473                                                   
474         ret = cs_amp_get_efi_calibration_data(    
475         KUNIT_EXPECT_EQ(test, ret, -ENOENT);      
476                                                   
477         kunit_deactivate_static_stub(test, cs_    
478 }                                                 
479                                                   
480 /*                                                
481  * If the UID is passed as 0 this must not mat    
482  * unpopulated calTarget                          
483  */                                               
484 static void cs_amp_lib_test_get_efi_cal_zero_n    
485 {                                                 
486         struct cs_amp_lib_test_priv *priv = te    
487         struct cirrus_amp_cal_data result_data    
488         int i, ret;                               
489                                                   
490         cs_amp_lib_test_init_dummy_cal_blob(te    
491                                                   
492         /* Make all the target values zero so     
493         for (i = 0; i < priv->cal_blob->count;    
494                 priv->cal_blob->data[i].calTar    
495                 priv->cal_blob->data[i].calTar    
496         }                                         
497                                                   
498         /* Redirect calls to get EFI data */      
499         kunit_activate_static_stub(test,          
500                                    cs_amp_test    
501                                    cs_amp_lib_    
502                                                   
503         ret = cs_amp_get_efi_calibration_data(    
504         KUNIT_EXPECT_EQ(test, ret, -ENOENT);      
505                                                   
506         kunit_deactivate_static_stub(test, cs_    
507 }                                                 
508                                                   
509 static const struct cirrus_amp_cal_controls cs    
510         .alg_id =       0x9f210,                  
511         .mem_region =   WMFW_ADSP2_YM,            
512         .ambient =      "CAL_AMBIENT",            
513         .calr =         "CAL_R",                  
514         .status =       "CAL_STATUS",             
515         .checksum =     "CAL_CHECKSUM",           
516 };                                                
517                                                   
518 static int cs_amp_lib_test_write_cal_coeff(str    
519                                            con    
520                                            con    
521 {                                                 
522         struct kunit *test = kunit_get_current    
523         struct cs_amp_lib_test_priv *priv = te    
524         struct cs_amp_lib_test_ctl_write_entry    
525                                                   
526         KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctl    
527         KUNIT_EXPECT_PTR_EQ(test, controls, &c    
528                                                   
529         entry = kunit_kzalloc(test, sizeof(*en    
530         KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ent    
531                                                   
532         INIT_LIST_HEAD(&entry->list);             
533         strscpy(entry->name, ctl_name, sizeof(    
534         entry->value = val;                       
535                                                   
536         list_add_tail(&entry->list, &priv->ctl    
537                                                   
538         return 0;                                 
539 }                                                 
540                                                   
541 static void cs_amp_lib_test_write_cal_data_tes    
542 {                                                 
543         struct cs_amp_lib_test_priv *priv = te    
544         struct cs_amp_lib_test_ctl_write_entry    
545         struct cirrus_amp_cal_data data;          
546         struct cs_dsp *dsp;                       
547         int ret;                                  
548                                                   
549         dsp = kunit_kzalloc(test, sizeof(*dsp)    
550         KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dsp    
551         dsp->dev = &priv->amp_pdev.dev;           
552                                                   
553         get_random_bytes(&data, sizeof(data));    
554                                                   
555         /* Redirect calls to write firmware co    
556         kunit_activate_static_stub(test,          
557                                    cs_amp_test    
558                                    cs_amp_lib_    
559                                                   
560         ret = cs_amp_write_cal_coeffs(dsp, &cs    
561         KUNIT_EXPECT_EQ(test, ret, 0);            
562                                                   
563         kunit_deactivate_static_stub(test, cs_    
564                                                   
565         KUNIT_EXPECT_EQ(test, list_count_nodes    
566                                                   
567         /* Checksum control must be written la    
568         entry = list_last_entry(&priv->ctl_wri    
569         KUNIT_EXPECT_STREQ(test, entry->name,     
570         KUNIT_EXPECT_EQ(test, entry->value, da    
571         list_del(&entry->list);                   
572                                                   
573         entry = list_first_entry(&priv->ctl_wr    
574         KUNIT_EXPECT_STREQ(test, entry->name,     
575         KUNIT_EXPECT_EQ(test, entry->value, da    
576         list_del(&entry->list);                   
577                                                   
578         entry = list_first_entry(&priv->ctl_wr    
579         KUNIT_EXPECT_STREQ(test, entry->name,     
580         KUNIT_EXPECT_EQ(test, entry->value, da    
581         list_del(&entry->list);                   
582                                                   
583         entry = list_first_entry(&priv->ctl_wr    
584         KUNIT_EXPECT_STREQ(test, entry->name,     
585         KUNIT_EXPECT_EQ(test, entry->value, da    
586 }                                                 
587                                                   
588 static void cs_amp_lib_test_dev_release(struct    
589 {                                                 
590 }                                                 
591                                                   
592 static int cs_amp_lib_test_case_init(struct ku    
593 {                                                 
594         struct cs_amp_lib_test_priv *priv;        
595         int ret;                                  
596                                                   
597         KUNIT_ASSERT_NOT_NULL(test, cs_amp_tes    
598                                                   
599         priv = kunit_kzalloc(test, sizeof(*pri    
600         if (!priv)                                
601                 return -ENOMEM;                   
602                                                   
603         test->priv = priv;                        
604         INIT_LIST_HEAD(&priv->ctl_write_list);    
605                                                   
606         /* Create dummy amp driver dev */         
607         priv->amp_pdev.name = "cs_amp_lib_test    
608         priv->amp_pdev.id = -1;                   
609         priv->amp_pdev.dev.release = cs_amp_li    
610         ret = platform_device_register(&priv->    
611         KUNIT_ASSERT_GE_MSG(test, ret, 0, "Fai    
612                                                   
613         return 0;                                 
614 }                                                 
615                                                   
616 static void cs_amp_lib_test_case_exit(struct k    
617 {                                                 
618         struct cs_amp_lib_test_priv *priv = te    
619                                                   
620         if (priv->amp_pdev.name)                  
621                 platform_device_unregister(&pr    
622 }                                                 
623                                                   
624 static const struct cs_amp_lib_test_param cs_a    
625         { .num_amps = 2, .amp_index = 0 },        
626         { .num_amps = 2, .amp_index = 1 },        
627                                                   
628         { .num_amps = 3, .amp_index = 0 },        
629         { .num_amps = 3, .amp_index = 1 },        
630         { .num_amps = 3, .amp_index = 2 },        
631                                                   
632         { .num_amps = 4, .amp_index = 0 },        
633         { .num_amps = 4, .amp_index = 1 },        
634         { .num_amps = 4, .amp_index = 2 },        
635         { .num_amps = 4, .amp_index = 3 },        
636                                                   
637         { .num_amps = 5, .amp_index = 0 },        
638         { .num_amps = 5, .amp_index = 1 },        
639         { .num_amps = 5, .amp_index = 2 },        
640         { .num_amps = 5, .amp_index = 3 },        
641         { .num_amps = 5, .amp_index = 4 },        
642                                                   
643         { .num_amps = 6, .amp_index = 0 },        
644         { .num_amps = 6, .amp_index = 1 },        
645         { .num_amps = 6, .amp_index = 2 },        
646         { .num_amps = 6, .amp_index = 3 },        
647         { .num_amps = 6, .amp_index = 4 },        
648         { .num_amps = 6, .amp_index = 5 },        
649                                                   
650         { .num_amps = 8, .amp_index = 0 },        
651         { .num_amps = 8, .amp_index = 1 },        
652         { .num_amps = 8, .amp_index = 2 },        
653         { .num_amps = 8, .amp_index = 3 },        
654         { .num_amps = 8, .amp_index = 4 },        
655         { .num_amps = 8, .amp_index = 5 },        
656         { .num_amps = 8, .amp_index = 6 },        
657         { .num_amps = 8, .amp_index = 7 },        
658 };                                                
659                                                   
660 static void cs_amp_lib_test_get_cal_param_desc    
661                                                   
662 {                                                 
663         snprintf(desc, KUNIT_PARAM_DESC_SIZE,     
664                  param->num_amps, param->amp_i    
665 }                                                 
666                                                   
667 KUNIT_ARRAY_PARAM(cs_amp_lib_test_get_cal, cs_    
668                   cs_amp_lib_test_get_cal_para    
669                                                   
670 static struct kunit_case cs_amp_lib_test_cases    
671         /* Tests for getting calibration data     
672         KUNIT_CASE(cs_amp_lib_test_cal_data_to    
673         KUNIT_CASE(cs_amp_lib_test_cal_count_t    
674         KUNIT_CASE(cs_amp_lib_test_no_cal_data    
675         KUNIT_CASE(cs_amp_lib_test_get_efi_cal    
676         KUNIT_CASE(cs_amp_lib_test_get_efi_cal    
677         KUNIT_CASE(cs_amp_lib_test_get_efi_cal    
678         KUNIT_CASE(cs_amp_lib_test_get_efi_cal    
679         KUNIT_CASE(cs_amp_lib_test_get_efi_cal    
680         KUNIT_CASE_PARAM(cs_amp_lib_test_get_e    
681                          cs_amp_lib_test_get_c    
682         KUNIT_CASE_PARAM(cs_amp_lib_test_get_e    
683                          cs_amp_lib_test_get_c    
684         KUNIT_CASE_PARAM(cs_amp_lib_test_get_e    
685                          cs_amp_lib_test_get_c    
686         KUNIT_CASE_PARAM(cs_amp_lib_test_get_e    
687                          cs_amp_lib_test_get_c    
688         KUNIT_CASE_PARAM(cs_amp_lib_test_get_e    
689                          cs_amp_lib_test_get_c    
690                                                   
691         /* Tests for writing calibration data     
692         KUNIT_CASE(cs_amp_lib_test_write_cal_d    
693                                                   
694         { } /* terminator */                      
695 };                                                
696                                                   
697 static struct kunit_suite cs_amp_lib_test_suit    
698         .name = "snd-soc-cs-amp-lib-test",        
699         .init = cs_amp_lib_test_case_init,        
700         .exit = cs_amp_lib_test_case_exit,        
701         .test_cases = cs_amp_lib_test_cases,      
702 };                                                
703                                                   
704 kunit_test_suite(cs_amp_lib_test_suite);          
705                                                   
706 MODULE_IMPORT_NS(SND_SOC_CS_AMP_LIB);             
707 MODULE_DESCRIPTION("KUnit test for Cirrus Logi    
708 MODULE_AUTHOR("Richard Fitzgerald <rf@opensour    
709 MODULE_LICENSE("GPL");                            
710                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php