5 Replies Latest reply on Jun 13, 2017 5:54 PM by Intel Corporation

    Change bitrate for dummy audio driver

    FSchroeder

      Hi,

       

      I tried to change the bits per channel of the dummy alsa driver from 24 to 16 bit. According to the Audio Guide (http://download.intel.com/support/edison/sb/edisonaudio_332434001.pdf) does the DSP support 16 bit. I did so by modifying snd_mask_set(ms>masks[SNDRV_PCM_HW_PARAM_FORMAT - SNDRV_PCM_HW_PARAM_FIRST_MASK], SNDRV_PCM_FORMAT_S24_LE); in /sound/soc/intel/board/merr_dpcm_dummy.c and replacing SNDRV_PCM_FORMAT_S16_LE.

       

      But when looking at the SSP2 output on a scope, especially inspecting WS and CLK, it still appears there are four channel each 24 bit. Either I am misreading the output or the change has no effect.

       

      What is the proper way to modify the sampling rate, bits per channel and number of channels for the SSP2 output in the dummy driver?

       

      Best regards

      Florian

        • 1. Re: Change bitrate for dummy audio driver
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi Florian,

          Let me investigate on this. Even if it appears as supported in the Audio Hardware Guide, it might not have been tested yet, so there’s a chance it will fail. Let me look a little bit more on this matter.
          I’ll contact you soon with more updates.

          Regards,
          Pablo M.

          • 2. Re: Change bitrate for dummy audio driver
            FSchroeder

            Hi Pablo,

             

            a little update on my try and error runs. After reading through more and more kernel code I found in sound/soc/intel/platform-libs/controls_v2_dpcm.c a structure SST_SSP2 where I can set values like fs_frequency or bits_per_slot. It seems to effect the output on the I2S interface in the desired direction. But I am not there yet. The audio codec I would like to use does only support 8 or 16 bit per channel. When I set bits_per_slot to 16 I get a recognizable signal, but there is an offset, so I guess the slot mapping is not right.

            Some hints on how to get the slot mapping correct would be great.

             

            Thanks a lot

            Florian

            • 3. Re: Change bitrate for dummy audio driver
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hi Florian,

              I’m wondering if you could share your steps with us so we can replicate the issue. I would also like to check the signal that you’re getting when editing structure SST_SSP2.
              If you’re using any code/sketch that you can share I would also appreciate it.

              Regards,
              Pablo M. 

              • 4. Re: Change bitrate for dummy audio driver
                FSchroeder

                Hi Pablo,

                 

                to recap my setup: I have a custom build Edison image based on the edison-3.10.17 kernel. The Edison module is put on an Arduino board where the I2S Pins (IO10 to IO13) and GND is connected to the according pins on the evaluation board for a MicroSemi ZL38060. The audio codec is configured to PCM slave mode with 16 bit per channel (it does not support 24 bit). The pins on the Arduino board are put to I2S mode according to the manual and the default alsa pcm device is set to the dummy device. Further I put a scope to the four I2S lines.

                 

                So I started patching this kernel.

                 

                First, I tried to modify the function merr_codec_fixup in merr_dpcm_dummy.c.

                diff --git a/sound/soc/intel/board/merr_dpcm_dummy.c b/sound/soc/intel/board/merr_dpcm_dummy.c
                index 5603b21..709d740 100644
                --- a/sound/soc/intel/board/merr_dpcm_dummy.c
                +++ b/sound/soc/intel/board/merr_dpcm_dummy.c
                @@ -93,7 +93,7 @@ static int merr_codec_fixup(struct snd_soc_pcm_runtime *rtd,
                        /* set SSP2 to 24-bit */
                        snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
                                                SNDRV_PCM_HW_PARAM_FIRST_MASK],
                -                               SNDRV_PCM_FORMAT_S24_LE);
                +                               SNDRV_PCM_FORMAT_S16_LE);
                        return 0;
                }

                 

                But I could not detect any changes. What does this fixup function do and when do I need it?

                 

                Second, I modified a struct in controls_v2_dpcm.c.

                diff --git a/sound/soc/intel/platform-libs/controls_v2_dpcm.c b/sound/soc/intel/platform-libs/controls_v2_dpcm.c
                index 311c043..a9ee256 100644
                --- a/sound/soc/intel/platform-libs/controls_v2_dpcm.c
                +++ b/sound/soc/intel/platform-libs/controls_v2_dpcm.c
                @@ -1106,7 +1106,7 @@ sst_ssp_configs[SST_NUM_SSPS][SST_MAX_SSP_MUX][SST_MAX_SSP_DOMAINS] = {
                                [SST_SSP_CODEC_MUX] = {
                                        [SST_SSP_CODEC_DOMAIN] = {
                                                .ssp_id = SSP_CODEC,
                -                               .bits_per_slot = 24,
                +                               .bits_per_slot = 16,
                                                .slots = 4,
                                                .ssp_mode = SSP_MODE_MASTER,
                                                .pcm_mode = SSP_PCM_MODE_NETWORK,

                 

                Changing these values has an effect on the signals on the I2S lines. When I change bits_per_slot, as shown above, the clock cycles per frame sync reduce. My observations showed that the clock cycles between two frame sysnc pulses are roughly slots x bits_per_slot which makes perfectly sense. Changing fs_frequency changes the measured frequency, which also makes perfect sense.

                My problem is that I cannot transfer a decent audio signal. When I play a wav file with aplay I get a decent output. When I record with arecord it is only due to the amazing capabilities of the human ear that I can recognize anything, but it is mostly noise. Hence my guess is that the data bits are not interpreted correctly but are also not completely off. Assigning the microphone channel from the audio codec to different slots shows clearly a shift in the transferred data, still I do not get the settings on the Edison side right.

                 

                Is there any further documentation how slots for the Edison DSP are configured? What is the meaning of active_slot_map and how is the mapping between channels and slots configured? Or could someone give an detailed example, how I the kernel and alsa should be configured to transfer a 16 bit mono audio signal with 16 kHz? The most important part is the 16 bit.

                 

                Thanks and regards

                Florian

                 

                P.S. I have a custom board with a Ti TLV320Aic3107 running on 24 bit, but sadly it does not fit my needs. But from this I draw that my software setup should be fine.

                • 5. Re: Change bitrate for dummy audio driver
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hi Florian,

                  Thank you very much for the detailed reply. Let me review this information to see if I can reproduce the issue with my Edison, will contact you soon with updates.

                  Regards,
                  Pablo M.