@@ -435,157 +435,6 @@ static void eep_5416_dump_modal_header(struct atheepmgr *aem)
435
435
#undef PR_LINE
436
436
}
437
437
438
- static void
439
- eep_5416_dump_closeloop_item (const uint8_t * pwr , const uint8_t * vpd ,
440
- int maxicepts , int maxstoredgains , int gainmask ,
441
- int power_table_offset )
442
- {
443
- const char * const gains [AR5416_NUM_PD_GAINS ] = {"4" , "2" , "1" , "0.5" };
444
- uint8_t mpwr [maxicepts * maxstoredgains ];
445
- uint8_t mvpd [ARRAY_SIZE (mpwr ) * maxstoredgains ];
446
- /* Map of Mask Gain bit Index to Calibrated per-Gain icepts set Index */
447
- int mgi2cgi [ARRAY_SIZE (gains )];
448
- int cgii [maxstoredgains ]; /* Array of indexes for merge */
449
- int gainidx , ngains , pwridx , npwr ; /* Indexes and index limits */
450
- uint8_t pwrmin ;
451
-
452
- /**
453
- * Index of bits in the gains mask is not the same as gain index in the
454
- * calibration data. Calibration data are stored without gaps. And non
455
- * available per-gain sets are skipped if gain is not enabled via the
456
- * gains mask. E.g. if the gains mask have a value of 0x06 then you
457
- * should use sets #0 and #1 from the calibration data. Where set #0 is
458
- * corespond to gains mask bit #1 and set #1 coresponds to gains mask
459
- * bit #3.
460
- *
461
- * To simplify further code we build a map of gain indexes to
462
- * calibration data sets indexes using the gains mask. Also count a
463
- * number of gains mask bit that are set aka number of configured
464
- * gains.
465
- */
466
- ngains = 0 ;
467
- for (gainidx = 0 ; gainidx < ARRAY_SIZE (gains ); ++ gainidx ) {
468
- if (gainmask & (1 << gainidx )) {
469
- mgi2cgi [gainidx ] = ngains ;
470
- ngains ++ ;
471
- } else {
472
- mgi2cgi [gainidx ] = -1 ;
473
- }
474
- }
475
- if (ngains > maxstoredgains ) {
476
- printf (" PD gain mask activates more gains then possible to store -- %d > %d\n" ,
477
- ngains , maxstoredgains );
478
- return ;
479
- }
480
-
481
- /* Merge calibration per-gain power lists to filter duplicates */
482
- memset (mpwr , 0xff , sizeof (mpwr ));
483
- memset (mvpd , 0xff , sizeof (mvpd ));
484
- memset (cgii , 0x00 , sizeof (cgii ));
485
- for (pwridx = 0 ; pwridx < ARRAY_SIZE (mpwr ); ++ pwridx ) {
486
- pwrmin = 0xff ;
487
- /* Looking for unmerged yet power value */
488
- for (gainidx = 0 ; gainidx < ngains ; ++ gainidx ) {
489
- if (cgii [gainidx ] >= maxicepts )
490
- continue ;
491
- if (pwr [gainidx * maxicepts + cgii [gainidx ]] < pwrmin )
492
- pwrmin = pwr [gainidx * maxicepts + cgii [gainidx ]];
493
- }
494
- if (pwrmin == 0xff )
495
- break ;
496
- mpwr [pwridx ] = pwrmin ;
497
- /* Copy Vpd of all gains for this power */
498
- for (gainidx = 0 ; gainidx < ngains ; ++ gainidx ) {
499
- if (cgii [gainidx ] >= AR5416_PD_GAIN_ICEPTS ||
500
- pwr [gainidx * maxicepts + cgii [gainidx ]] != pwrmin )
501
- continue ;
502
- mvpd [pwridx * maxstoredgains + gainidx ] =
503
- vpd [gainidx * maxicepts + cgii [gainidx ]];
504
- cgii [gainidx ]++ ;
505
- }
506
- }
507
- npwr = pwridx ;
508
-
509
- /* Print merged data */
510
- printf (" Tx Power, dBm:" );
511
- for (pwridx = 0 ; pwridx < npwr ; ++ pwridx )
512
- printf (" %5.2f" , (double )mpwr [pwridx ] / 4 +
513
- power_table_offset );
514
- printf ("\n" );
515
- printf (" --------------" );
516
- for (pwridx = 0 ; pwridx < npwr ; ++ pwridx )
517
- printf (" -----" );
518
- printf ("\n" );
519
- for (gainidx = 0 ; gainidx < ARRAY_SIZE (gains ); ++ gainidx ) {
520
- if (!(gainmask & (1 << gainidx )))
521
- continue ;
522
- printf (" Gain x%-3s VPD:" , gains [gainidx ]);
523
- for (pwridx = 0 ; pwridx < npwr ; ++ pwridx ) {
524
- uint8_t vpd = mvpd [pwridx * maxstoredgains + mgi2cgi [gainidx ]];
525
-
526
- if (vpd == 0xff )
527
- printf (" " );
528
- else
529
- printf (" %3u" , vpd );
530
- }
531
- printf ("\n" );
532
- }
533
- }
534
-
535
- /**
536
- * Data is an array of per-chain & per-frequency sets of calibrations.
537
- * Each set calibrations consists of two parts: first part contains a set of
538
- * output power values, while the second part contains a corresponding power
539
- * detector values. Each part (power and detector) has a similar structure, it
540
- * is an array of per PD gain sets of measurements (icepts). Each type of
541
- * values (power and detector) has the similar size of one octet.
542
- *
543
- * So to calculate position of per-chain & per-frequency data we should know
544
- * size of this data. Such data block size is a sum of its parts, i.e. sum of
545
- * output power data size and power detector data size. The size of each part
546
- * is a multiplication of a number of PD gains (maxstoredgains) and of a number
547
- * of calibration points (maxicepts).
548
- *
549
- * So having all this numbers we are able to easly calculate size of various
550
- * elements and their positions.
551
- */
552
- static void eep_5416_dump_closeloop (const uint8_t * freqs , int maxfreq ,
553
- int is_2g , int maxchains , int chainmask ,
554
- const void * data , int maxicepts ,
555
- int maxstoredgains , int gainmask ,
556
- int power_table_offset )
557
- {
558
- /* Sizes of TxPower and Detector sets of data */
559
- const int fpwrdatasz = maxicepts * maxstoredgains * sizeof (uint8_t );
560
- const int fvpddatasz = maxicepts * maxstoredgains * sizeof (uint8_t );
561
- const int fdatasz = fpwrdatasz + fvpddatasz ; /* Per-chain & per-freq data sz */
562
- const uint8_t * fdata , * fpwrdata , * fvpddata ;
563
- int chain , freq ; /* Indexes */
564
-
565
- for (chain = 0 ; chain < maxchains ; ++ chain ) {
566
- if (!(chainmask & (1 << chain )))
567
- continue ;
568
- printf (" Chain %d:\n" , chain );
569
- printf ("\n" );
570
- for (freq = 0 ; freq < maxfreq ; ++ freq ) {
571
- if (freqs [freq ] == AR5416_BCHAN_UNUSED )
572
- break ;
573
-
574
- printf (" %4u MHz:\n" , FBIN2FREQ (freqs [freq ], is_2g ));
575
-
576
- fdata = data + fdatasz * (chain * maxfreq + freq );
577
- fpwrdata = fdata + 0 ;/* Power data begins immediatly */
578
- fvpddata = fdata + fpwrdatasz ; /* Skip power data */
579
-
580
- eep_5416_dump_closeloop_item (fpwrdata , fvpddata ,
581
- maxicepts , maxstoredgains ,
582
- gainmask , power_table_offset );
583
-
584
- printf ("\n" );
585
- }
586
- }
587
- }
588
-
589
438
static void eep_5416_dump_pd_cal (const uint8_t * freq , int maxfreq ,
590
439
const void * caldata , int is_openloop ,
591
440
int is_2g , int chainmask , int gainmask ,
@@ -594,11 +443,11 @@ static void eep_5416_dump_pd_cal(const uint8_t *freq, int maxfreq,
594
443
if (is_openloop ) {
595
444
printf (" Open-loop PD calibration dumping is not supported\n" );
596
445
} else {
597
- eep_5416_dump_closeloop (freq , maxfreq , is_2g , AR5416_MAX_CHAINS ,
598
- chainmask , caldata ,
599
- AR5416_PD_GAIN_ICEPTS ,
600
- AR5416_NUM_PD_GAINS ,
601
- gainmask , power_table_offset );
446
+ ar5416_dump_pwrctl_closeloop (freq , maxfreq , is_2g ,
447
+ AR5416_MAX_CHAINS , chainmask ,
448
+ caldata , AR5416_PD_GAIN_ICEPTS ,
449
+ AR5416_NUM_PD_GAINS , gainmask ,
450
+ power_table_offset );
602
451
}
603
452
}
604
453
0 commit comments