Skip to content

Commit b874d95

Browse files
jinxiuxuAlan Carvalho de Assis
authored andcommitted
drivers/audio: fix samp rate conversion issue
Signed-off-by: jinxiuxu <[email protected]>
1 parent 618a51f commit b874d95

File tree

9 files changed

+54
-30
lines changed

9 files changed

+54
-30
lines changed

arch/arm/src/cxd56xx/cxd56_nxaudio.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,6 +2587,8 @@ static int cxd56_getcaps(struct audio_lowerhalf_s *lower, int type,
25872587
{
25882588
DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s));
25892589

2590+
uint16_t *ptr;
2591+
25902592
/* Fill in the caller's structure based on requested info */
25912593

25922594
caps->ac_format.hw = 0;
@@ -2631,8 +2633,8 @@ static int cxd56_getcaps(struct audio_lowerhalf_s *lower, int type,
26312633

26322634
/* Report supported output sample rates */
26332635

2634-
caps->ac_controls.b[0] = CXD56_SUPP_RATES_L;
2635-
caps->ac_controls.b[1] = CXD56_SUPP_RATES_H;
2636+
ptr = (uint16_t *)caps->ac_controls.b;
2637+
*ptr = CXD56_SUPP_RATES_L;
26362638
break;
26372639

26382640
default:
@@ -2652,8 +2654,8 @@ static int cxd56_getcaps(struct audio_lowerhalf_s *lower, int type,
26522654

26532655
/* Report supported input sample rates */
26542656

2655-
caps->ac_controls.b[0] = CXD56_SUPP_RATES_L;
2656-
caps->ac_controls.b[1] = CXD56_SUPP_RATES_H;
2657+
ptr = (uint16_t *)caps->ac_controls.b;
2658+
*ptr = CXD56_SUPP_RATES_L;
26572659
break;
26582660

26592661
default:

drivers/audio/audio_null.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
215215

216216
DEBUGASSERT(caps->ac_len >= sizeof(struct audio_caps_s));
217217

218+
uint16_t *ptr;
219+
218220
/* Fill in the caller's structure based on requested info */
219221

220222
caps->ac_format.hw = 0;
@@ -273,13 +275,14 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
273275

274276
/* Report the Sample rates we support */
275277

276-
caps->ac_controls.b[0] = AUDIO_SAMP_RATE_8K |
277-
AUDIO_SAMP_RATE_11K |
278-
AUDIO_SAMP_RATE_16K |
279-
AUDIO_SAMP_RATE_22K |
280-
AUDIO_SAMP_RATE_32K |
281-
AUDIO_SAMP_RATE_44K |
282-
AUDIO_SAMP_RATE_48K;
278+
ptr = (uint16_t *)caps->ac_controls.b;
279+
*ptr = AUDIO_SAMP_RATE_8K |
280+
AUDIO_SAMP_RATE_11K |
281+
AUDIO_SAMP_RATE_16K |
282+
AUDIO_SAMP_RATE_22K |
283+
AUDIO_SAMP_RATE_32K |
284+
AUDIO_SAMP_RATE_44K |
285+
AUDIO_SAMP_RATE_48K;
283286
break;
284287

285288
case AUDIO_FMT_MP3:

drivers/audio/cs4344.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ static int cs4344_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
358358
DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s));
359359
audinfo("type=%d ac_type=%d\n", type, caps->ac_type);
360360

361+
uint16_t *ptr;
362+
361363
/* Fill in the caller's structure based on requested info */
362364

363365
caps->ac_format.hw = 0;
@@ -416,7 +418,8 @@ static int cs4344_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
416418

417419
/* Report the Sample rates we support */
418420

419-
caps->ac_controls.b[0] =
421+
ptr = (uint16_t *)caps->ac_controls.b;
422+
*ptr =
420423
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
421424
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
422425
AUDIO_SAMP_RATE_48K;

drivers/audio/cs43l22.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@ static int cs43l22_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
522522
DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s));
523523
audinfo("type=%d ac_type=%d\n", type, caps->ac_type);
524524

525+
uint16_t *ptr;
526+
525527
/* Fill in the caller's structure based on requested info */
526528

527529
caps->ac_format.hw = 0;
@@ -580,7 +582,8 @@ static int cs43l22_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
580582

581583
/* Report the Sample rates we support */
582584

583-
caps->ac_controls.b[0] =
585+
ptr = (uint16_t *)caps->ac_controls.b;
586+
*ptr =
584587
AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
585588
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
586589
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |

drivers/audio/es8311.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ static int es8311_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
802802
DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s));
803803
audinfo("getcaps: type=%d ac_type=%d\n", type, caps->ac_type);
804804

805+
uint16_t *ptr;
806+
805807
/* Fill in the caller's structure based on requested info */
806808

807809
caps->ac_format.hw = 0;
@@ -845,11 +847,11 @@ static int es8311_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
845847

846848
/* 8kHz is hardware dependent */
847849

848-
caps->ac_controls.b[0] =
850+
ptr = (uint16_t *)caps->ac_controls.b;
851+
*ptr =
849852
AUDIO_SAMP_RATE_11K | AUDIO_SAMP_RATE_16K |
850853
AUDIO_SAMP_RATE_22K | AUDIO_SAMP_RATE_32K |
851854
AUDIO_SAMP_RATE_44K | AUDIO_SAMP_RATE_48K;
852-
caps->ac_controls.b[1] = 0;
853855
break;
854856
}
855857

@@ -863,11 +865,11 @@ static int es8311_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
863865
{
864866
/* Report supported input sample rates */
865867

866-
caps->ac_controls.b[0] =
868+
ptr = (uint16_t *)caps->ac_controls.b;
869+
*ptr =
867870
AUDIO_SAMP_RATE_11K | AUDIO_SAMP_RATE_16K |
868871
AUDIO_SAMP_RATE_22K | AUDIO_SAMP_RATE_32K |
869872
AUDIO_SAMP_RATE_44K | AUDIO_SAMP_RATE_48K;
870-
caps->ac_controls.b[1] = 0;
871873
break;
872874
}
873875

drivers/audio/es8388.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,8 @@ static int es8388_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
773773
DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s));
774774
audinfo("getcaps: type=%d ac_type=%d\n", type, caps->ac_type);
775775

776+
uint16_t *ptr;
777+
776778
/* Fill in the caller's structure based on requested info */
777779

778780
caps->ac_format.hw = 0;
@@ -828,11 +830,11 @@ static int es8388_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
828830

829831
/* 8kHz is hardware dependent */
830832

831-
caps->ac_controls.b[0] =
833+
ptr = (uint16_t *)caps->ac_controls.b;
834+
*ptr =
832835
AUDIO_SAMP_RATE_11K | AUDIO_SAMP_RATE_16K |
833836
AUDIO_SAMP_RATE_22K | AUDIO_SAMP_RATE_32K |
834837
AUDIO_SAMP_RATE_44K | AUDIO_SAMP_RATE_48K;
835-
caps->ac_controls.b[1] = 0;
836838
break;
837839

838840
default:
@@ -851,11 +853,11 @@ static int es8388_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
851853

852854
/* Report supported input sample rates */
853855

854-
caps->ac_controls.b[0] =
856+
ptr = (uint16_t *)caps->ac_controls.b;
857+
*ptr =
855858
AUDIO_SAMP_RATE_11K | AUDIO_SAMP_RATE_16K |
856859
AUDIO_SAMP_RATE_22K | AUDIO_SAMP_RATE_32K |
857860
AUDIO_SAMP_RATE_44K | AUDIO_SAMP_RATE_48K;
858-
caps->ac_controls.b[1] = 0;
859861
break;
860862

861863
default:

drivers/audio/vs1053.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
564564

565565
DEBUGASSERT(caps->ac_len >= sizeof(struct audio_caps_s));
566566

567+
uint16_t *ptr;
568+
567569
/* Fill in the caller's structure based on requested info */
568570

569571
caps->ac_format.hw = 0;
@@ -647,13 +649,14 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
647649

648650
/* Report the Sample rates we support */
649651

650-
caps->ac_controls.b[0] = AUDIO_SAMP_RATE_8K |
651-
AUDIO_SAMP_RATE_11K |
652-
AUDIO_SAMP_RATE_16K |
653-
AUDIO_SAMP_RATE_22K |
654-
AUDIO_SAMP_RATE_32K |
655-
AUDIO_SAMP_RATE_44K |
656-
AUDIO_SAMP_RATE_48K;
652+
ptr = (uint16_t *)caps->ac_controls.b;
653+
*ptr = AUDIO_SAMP_RATE_8K |
654+
AUDIO_SAMP_RATE_11K |
655+
AUDIO_SAMP_RATE_16K |
656+
AUDIO_SAMP_RATE_22K |
657+
AUDIO_SAMP_RATE_32K |
658+
AUDIO_SAMP_RATE_44K |
659+
AUDIO_SAMP_RATE_48K;
657660
break;
658661

659662
case AUDIO_FMT_MP3:

drivers/audio/wm8904.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,8 @@ static int wm8904_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
957957
DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s));
958958
audinfo("type=%d ac_type=%d\n", type, caps->ac_type);
959959

960+
uint16_t *ptr;
961+
960962
/* Fill in the caller's structure based on requested info */
961963

962964
caps->ac_format.hw = 0;
@@ -1016,7 +1018,8 @@ static int wm8904_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
10161018

10171019
/* Report the Sample rates we support */
10181020

1019-
caps->ac_controls.b[0] =
1021+
ptr = (uint16_t *)caps->ac_controls.b;
1022+
*ptr =
10201023
AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
10211024
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
10221025
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |

drivers/audio/wm8994.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ static int wm8994_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
655655
DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s));
656656
audinfo("type=%d ac_type=%d\n", type, caps->ac_type);
657657

658+
uint16_t *ptr;
659+
658660
/* Fill in the caller's structure based on requested info */
659661

660662
caps->ac_format.hw = 0;
@@ -714,7 +716,8 @@ static int wm8994_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
714716

715717
/* Report the Sample rates we support */
716718

717-
caps->ac_controls.b[0] =
719+
ptr = (uint16_t *)caps->ac_controls.b;
720+
*ptr =
718721
AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
719722
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
720723
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |

0 commit comments

Comments
 (0)