Audioinjector Octo : add extra sample rates, fix rst and use bcm270x regs
authorMatt Flax <flatmax@flatmax.org>
Thu, 30 Mar 2017 00:43:57 +0000 (11:43 +1100)
committerRaspbian kernel package updater <root@raspbian.org>
Sat, 31 Mar 2018 14:53:19 +0000 (15:53 +0100)
This patch adds new sample rates to the Audioinjector Octo sound card. The
new supported rates are (in kHz) :
96, 48, 32, 24, 16, 8, 88.2, 44.1, 29.4, 22.05, 14.7

This patch also replaces the regulators in the device tree overlay with
the ones declared in bcm270x.dtsi include file.

This patch also adds an extra codec reset and delay on probe.

arch/arm/boot/dts/overlays/audioinjector-addons-overlay.dts
sound/soc/bcm/audioinjector-octo-soundcard.c

index a36fa85a61f7eaab35ca481ed1dac621e2342e6d..a40bb1193a4cebc5672709e8db861e1167d3a699 100644 (file)
        };
 
        fragment@1 {
-               target = <&soc>;
-                       __overlay__ {
-                               reg_digital: reg_digital@0 {
-                                 compatible = "regulator-fixed";
-                                 regulator-name = "cs42448_dig_supply";
-                                 regulator-min-microvolt = <3300000>;
-                                 regulator-max-microvolt = <3300000>;
-                                 regulator-always-on;
-                       };
-                               reg_analogue: reg_analogue@0 {
-                                 compatible = "regulator-fixed";
-                                 regulator-name = "cs42448_ana_supply";
-                                 regulator-min-microvolt = <5000000>;
-                                 regulator-max-microvolt = <5000000>;
-                                 regulator-always-on;
-                       };
-               };
-       };
-
-       fragment@2 {
                target = <&i2c1>;
                __overlay__ {
                        #address-cells = <1>;
                                reg = <0x48>;
                                clocks = <&cs42448_mclk>;
                                clock-names = "mclk";
-                               VA-supply = <&reg_analogue>;
-                               VD-supply = <&reg_digital>;
-                               VLS-supply = <&reg_digital>;
-                               VLC-supply = <&reg_digital>;
+                               VA-supply = <&vdd_5v0_reg>;
+                               VD-supply = <&vdd_3v3_reg>;
+                               VLS-supply = <&vdd_3v3_reg>;
+                               VLC-supply = <&vdd_3v3_reg>;
                                status = "okay";
                        };
 
@@ -60,7 +40,7 @@
                };
        };
 
-       fragment@3 {
+       fragment@2 {
                target = <&sound>;
                __overlay__ {
                        compatible = "ai,audioinjector-octo-soundcard";
index 1198c36c4563b8673e5d386d1dfa92d43689e297..dcf403ab37639ba79e38278d7e4b1ade452c292a 100644 (file)
@@ -31,7 +31,7 @@ static struct gpio_desc *codec_rst_gpio;
 static unsigned int audioinjector_octo_rate;
 
 static const unsigned int audioinjector_octo_rates[] = {
-       96000, 48000, 88200, 44100,
+       96000, 48000, 32000, 24000, 16000, 8000, 88200, 44100, 29400, 22050, 14700,
 };
 
 static struct snd_pcm_hw_constraint_list audioinjector_octo_constraints = {
@@ -98,11 +98,33 @@ static int audioinjector_octo_hw_params(struct snd_pcm_substream *substream,
                return snd_soc_dai_set_sysclk(rtd->codec_dai, 0, 49152000,
                                                                        0);
                break;
+       case 24000:
+               return snd_soc_dai_set_sysclk(rtd->codec_dai, 0, 49152000/2,
+                                                                       0);
+               break;
+       case 32000:
+       case 16000:
+               return snd_soc_dai_set_sysclk(rtd->codec_dai, 0, 49152000/3,
+                                                                       0);
+               break;
+       case 8000:
+               return snd_soc_dai_set_sysclk(rtd->codec_dai, 0, 49152000/6,
+                                                                       0);
+               break;
        case 88200:
        case 44100:
                return snd_soc_dai_set_sysclk(rtd->codec_dai, 0, 45185400,
                                                                        0);
                break;
+       case 22050:
+               return snd_soc_dai_set_sysclk(rtd->codec_dai, 0, 45185400/2,
+                                                                       0);
+               break;
+       case 29400:
+       case 14700:
+               return snd_soc_dai_set_sysclk(rtd->codec_dai, 0, 45185400/3,
+                                                                       0);
+               break;
        default:
                return -EINVAL;
        }
@@ -132,6 +154,25 @@ static int audioinjector_octo_trigger(struct snd_pcm_substream *substream,
                case 44100:
                        mult[2] = 1;
                        break;
+               case 32000:
+                       mult[3] = 1;
+               case 29400:
+                       mult[0] = 1;
+                       mult[1] = 1;
+                       break;
+               case 24000:
+                       mult[3] = 1;
+               case 22050:
+                       mult[1] = 1;
+                       break;
+               case 16000:
+                       mult[3] = 1;
+               case 14700:
+                       mult[0] = 1;
+                       break;
+               case 8000:
+                       mult[3] = 1;
+                       break;
                default:
                        return -EINVAL;
                }
@@ -233,12 +274,15 @@ static int audioinjector_octo_probe(struct platform_device *pdev)
                if (IS_ERR(codec_rst_gpio))
                        return PTR_ERR(codec_rst_gpio);
 
+               if (codec_rst_gpio)
+                       gpiod_set_value(codec_rst_gpio, 1);
+               msleep(500);
                if (codec_rst_gpio)
                        gpiod_set_value(codec_rst_gpio, 0);
-               msleep(5);
+               msleep(500);
                if (codec_rst_gpio)
                        gpiod_set_value(codec_rst_gpio, 1);
-               msleep(50);
+               msleep(500);
 
                if (i2s_node && codec_node) {
                        dai->cpu_dai_name = NULL;