3 Replies Latest reply: May 4, 2013 5:53 PM by JimReese RSS

    Need help controlling SigmaDSP parameters within the Linux driver.

    JimReese

      Has anyone on the list ever modified the Linux driver for the adau1761 to provide adjustments for the SigmaDSP modules?  I'm looking for some guidance on how best to implement this.

       

      I want the user to be able to adjust parameters on EQ and Compressor modules within the Sigma DSP using ALSA kcontrols. 

       

      Jim Reese

      FlexRadio Systems

        • 1. Re: Need help controlling SigmaDSP parameters within the Linux driver.

          I moved this to the Linux forum since Linux drivers are supported by a separate group within Analog Devices.

          • 2. Re: Need help controlling SigmaDSP parameters within the Linux driver.
            larsc

            Hi,

             

            Sorry for the delay. You can write parameters at runtime using the safeload feature. The following snippet should do:

             

            #define ADAU1761_SAFELOAD_DATA(x) (0x1 + (x))
            #define ADAU1761_SAFELOAD_ADDR 0x6
            #define ADAU1761_SAFELOAD_SIZE 0x7
            
            
            static int adau1761_safeload(struct adau *adau, uint16_t addr, uint16_t *data,
                      unsigned int size)
            {
                      unsigned int i;
                      int ret;
            
            
                      if (size > 5)
                                return -EINVAL;
            
            
                      for (i = 0; i < size; i++) {
                                ret = regmap_write(adau->regmap, ADAU1761_SAFELOAD_DATA(i), data[i]);
                                if (ret)
                                          return ret;
                      }
            
            
                      ret = regmap_write(adau->regmap, ADAU1761_SAFELOAD_ADDR, addr - 1);
                      if (ret)
                                return ret;
                      ret = regmap_write(adau->regmap, ADAU1761_SAFELOAD_SIZE, size);
                      if (ret)
                                return ret;
            
            
                      /* Wait for the operation to finish */
                      udelay(30);
            
            
                      return 0;
            }
            
            
            static int compressor_threshold_set(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol)
            {
                      struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
                      struct adau *adau = snd_soc_codec_get_drvdata(codec);
            
            
                      ucontrol->value.integer.value[0] = adau->compressor_threshold;
            
            
                      return 0;
            }
            
            
            static int compressor_threshold_get(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol)
            {
                      struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
                      struct adau *adau = snd_soc_codec_get_drvdata(codec);
                      uint16_t safe_load_args[5];
            
            
                      adau->compressor_threshold = ucontrol->value.integer.value[0];
                      /* calculate parameters based on the value */
                      safe_load_args[0] = 123;
            
            
                      adau1761_safeload(adau, THRESHOLD_REG_ADDR, safe_load_args,
                                ARRAY_SIZE(safe_load_args));
                      return 1;
            }
            
            
            static const struct snd_kcontrol_new compressor_controls[] = {
            SOC_SINGLE_EXT("Compressor Threshold", 0x00, 0x00, 0xff, 0, 
                      compressor_threshold_set, compressor_threshold_get),
            };
            
            

            The tricky part is to figure out how the registers need to be programmed for a certain value. You need to talk to the SigmaDSP guys for that.

             

            - Lars

            • 3. Re: Need help controlling SigmaDSP parameters within the Linux driver.
              JimReese

              Hi Lars.

               

              I wanted to let you know that your answer was very helpful.  I'm making good progress now.  Thank you very much for your help.

               

              Jim Reese

              FlexRadio Systems