Skip to content

Commit 575c9b1

Browse files
jinxiuxuxiaoxiang781216
authored andcommitted
drivers/audio: fix samp rate conversion issue
use ac_controls.hw to get the correct sample rate intead of ac_controls.b Signed-off-by: jinxiuxu <[email protected]>
1 parent ec4d315 commit 575c9b1

File tree

10 files changed

+39
-75
lines changed

10 files changed

+39
-75
lines changed

arch/arm/src/cxd56xx/cxd56_nxaudio.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,14 @@
8181
/* Samplerates field is split into low and high byte */
8282

8383
#ifdef CONFIG_AUDIO_CXD56_SRC
84-
#define CXD56_SUPP_RATES_L (AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K | \
85-
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K | \
86-
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K | \
87-
AUDIO_SAMP_RATE_48K)
88-
#define CXD56_SUPP_RATES_H ((AUDIO_SAMP_RATE_96K | AUDIO_SAMP_RATE_128K | \
89-
AUDIO_SAMP_RATE_192K) >> 8)
90-
#define CXD56_SUPP_RATES (CXD56_SUPP_RATES_L | CXD56_SUPP_RATES_H)
84+
#define CXD56_SUPP_RATES (AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K | \
85+
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K | \
86+
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K | \
87+
AUDIO_SAMP_RATE_48K | AUDIO_SAMP_RATE_96K | \
88+
AUDIO_SAMP_RATE_128K | AUDIO_SAMP_RATE_192K)
9189
#else
9290
/* No sample rate converter, only support system rate of 48kHz */
93-
#define CXD56_SUPP_RATES_L AUDIO_SAMP_RATE_48K
94-
#define CXD56_SUPP_RATES_H 0x0
95-
#define CXD56_SUPP_RATES (CXD56_SUPP_RATES_L | CXD56_SUPP_RATES_H)
91+
#define CXD56_SUPP_RATES AUDIO_SAMP_RATE_48K
9692
#endif
9793

9894
/* Mic setting definitions */
@@ -2587,8 +2583,6 @@ static int cxd56_getcaps(struct audio_lowerhalf_s *lower, int type,
25872583
{
25882584
DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s));
25892585

2590-
uint16_t *ptr;
2591-
25922586
/* Fill in the caller's structure based on requested info */
25932587

25942588
caps->ac_format.hw = 0;
@@ -2633,8 +2627,7 @@ static int cxd56_getcaps(struct audio_lowerhalf_s *lower, int type,
26332627

26342628
/* Report supported output sample rates */
26352629

2636-
ptr = (uint16_t *)caps->ac_controls.b;
2637-
*ptr = CXD56_SUPP_RATES_L;
2630+
caps->ac_controls.hw[0] = CXD56_SUPP_RATES;
26382631
break;
26392632

26402633
default:
@@ -2654,8 +2647,7 @@ static int cxd56_getcaps(struct audio_lowerhalf_s *lower, int type,
26542647

26552648
/* Report supported input sample rates */
26562649

2657-
ptr = (uint16_t *)caps->ac_controls.b;
2658-
*ptr = CXD56_SUPP_RATES_L;
2650+
caps->ac_controls.hw[0] = CXD56_SUPP_RATES;
26592651
break;
26602652

26612653
default:

arch/sim/src/sim/posix/sim_alsa.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ static int sim_audio_getcaps(struct audio_lowerhalf_s *dev, int type,
309309
struct audio_caps_s *caps)
310310
{
311311
struct sim_audio_s *priv = (struct sim_audio_s *)dev;
312-
uint16_t *ptr;
313312
long val;
314313

315314
caps->ac_format.hw = 0;
@@ -370,16 +369,15 @@ static int sim_audio_getcaps(struct audio_lowerhalf_s *dev, int type,
370369

371370
/* Report the Sample rates we support */
372371

373-
ptr = (uint16_t *)caps->ac_controls.b;
374-
*ptr = AUDIO_SAMP_RATE_8K |
375-
AUDIO_SAMP_RATE_11K |
376-
AUDIO_SAMP_RATE_12K |
377-
AUDIO_SAMP_RATE_16K |
378-
AUDIO_SAMP_RATE_22K |
379-
AUDIO_SAMP_RATE_24K |
380-
AUDIO_SAMP_RATE_32K |
381-
AUDIO_SAMP_RATE_44K |
382-
AUDIO_SAMP_RATE_48K;
372+
caps->ac_controls.hw[0] = AUDIO_SAMP_RATE_8K |
373+
AUDIO_SAMP_RATE_11K |
374+
AUDIO_SAMP_RATE_12K |
375+
AUDIO_SAMP_RATE_16K |
376+
AUDIO_SAMP_RATE_22K |
377+
AUDIO_SAMP_RATE_24K |
378+
AUDIO_SAMP_RATE_32K |
379+
AUDIO_SAMP_RATE_44K |
380+
AUDIO_SAMP_RATE_48K;
383381
break;
384382

385383
default:

drivers/audio/audio_null.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ 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-
220218
/* Fill in the caller's structure based on requested info */
221219

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

276274
/* Report the Sample rates we support */
277275

278-
ptr = (FAR 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;
276+
caps->ac_controls.hw[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;
286283
break;
287284

288285
case AUDIO_FMT_MP3:

drivers/audio/cs4344.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ 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-
363361
/* Fill in the caller's structure based on requested info */
364362

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

419417
/* Report the Sample rates we support */
420418

421-
ptr = (FAR uint16_t *)caps->ac_controls.b;
422-
*ptr =
419+
caps->ac_controls.hw[0] =
423420
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
424421
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
425422
AUDIO_SAMP_RATE_48K;

drivers/audio/cs43l22.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,6 @@ 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-
527525
/* Fill in the caller's structure based on requested info */
528526

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

583581
/* Report the Sample rates we support */
584582

585-
ptr = (FAR uint16_t *)caps->ac_controls.b;
586-
*ptr =
583+
caps->ac_controls.hw[0] =
587584
AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
588585
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
589586
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |

drivers/audio/es8311.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,6 @@ 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-
807805
/* Fill in the caller's structure based on requested info */
808806

809807
caps->ac_format.hw = 0;
@@ -847,8 +845,7 @@ static int es8311_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
847845

848846
/* 8kHz is hardware dependent */
849847

850-
ptr = (FAR uint16_t *)caps->ac_controls.b;
851-
*ptr =
848+
caps->ac_controls.hw[0] =
852849
AUDIO_SAMP_RATE_11K | AUDIO_SAMP_RATE_16K |
853850
AUDIO_SAMP_RATE_22K | AUDIO_SAMP_RATE_32K |
854851
AUDIO_SAMP_RATE_44K | AUDIO_SAMP_RATE_48K;
@@ -865,8 +862,7 @@ static int es8311_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
865862
{
866863
/* Report supported input sample rates */
867864

868-
ptr = (FAR uint16_t *)caps->ac_controls.b;
869-
*ptr =
865+
caps->ac_controls.hw[0] =
870866
AUDIO_SAMP_RATE_11K | AUDIO_SAMP_RATE_16K |
871867
AUDIO_SAMP_RATE_22K | AUDIO_SAMP_RATE_32K |
872868
AUDIO_SAMP_RATE_44K | AUDIO_SAMP_RATE_48K;

drivers/audio/es8388.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,6 @@ 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-
778776
/* Fill in the caller's structure based on requested info */
779777

780778
caps->ac_format.hw = 0;
@@ -830,8 +828,7 @@ static int es8388_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
830828

831829
/* 8kHz is hardware dependent */
832830

833-
ptr = (FAR uint16_t *)caps->ac_controls.b;
834-
*ptr =
831+
caps->ac_controls.hw[0] =
835832
AUDIO_SAMP_RATE_11K | AUDIO_SAMP_RATE_16K |
836833
AUDIO_SAMP_RATE_22K | AUDIO_SAMP_RATE_32K |
837834
AUDIO_SAMP_RATE_44K | AUDIO_SAMP_RATE_48K;
@@ -853,8 +850,7 @@ static int es8388_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
853850

854851
/* Report supported input sample rates */
855852

856-
ptr = (FAR uint16_t *)caps->ac_controls.b;
857-
*ptr =
853+
caps->ac_controls.hw[0] =
858854
AUDIO_SAMP_RATE_11K | AUDIO_SAMP_RATE_16K |
859855
AUDIO_SAMP_RATE_22K | AUDIO_SAMP_RATE_32K |
860856
AUDIO_SAMP_RATE_44K | AUDIO_SAMP_RATE_48K;

drivers/audio/vs1053.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,6 @@ 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-
569567
/* Fill in the caller's structure based on requested info */
570568

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

650648
/* Report the Sample rates we support */
651649

652-
ptr = (FAR 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;
650+
caps->ac_controls.hw[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;
660657
break;
661658

662659
case AUDIO_FMT_MP3:

drivers/audio/wm8904.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,6 @@ 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-
962960
/* Fill in the caller's structure based on requested info */
963961

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

10191017
/* Report the Sample rates we support */
10201018

1021-
ptr = (FAR uint16_t *)caps->ac_controls.b;
1022-
*ptr =
1019+
caps->ac_controls.hw[0] =
10231020
AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
10241021
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
10251022
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |

drivers/audio/wm8994.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,6 @@ 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-
660658
/* Fill in the caller's structure based on requested info */
661659

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

717715
/* Report the Sample rates we support */
718716

719-
ptr = (FAR uint16_t *)caps->ac_controls.b;
720-
*ptr =
717+
caps->ac_controls.hw[0] =
721718
AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
722719
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
723720
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |

0 commit comments

Comments
 (0)