hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/include/sound/soc.h
....@@ -19,6 +19,7 @@
1919 #include <linux/kernel.h>
2020 #include <linux/regmap.h>
2121 #include <linux/log2.h>
22
+#include <linux/android_kabi.h>
2223 #include <sound/core.h>
2324 #include <sound/pcm.h>
2425 #include <sound/compress_driver.h>
....@@ -307,6 +308,12 @@
307308 .put = snd_soc_bytes_put, .private_value = \
308309 ((unsigned long)&(struct soc_bytes) \
309310 {.base = xbase, .num_regs = xregs }) }
311
+#define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \
312
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
313
+ .info = snd_soc_bytes_info, .get = xhandler_get, \
314
+ .put = xhandler_put, .private_value = \
315
+ ((unsigned long)&(struct soc_bytes) \
316
+ {.base = xbase, .num_regs = xregs }) }
310317
311318 #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask) \
312319 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
....@@ -370,38 +377,6 @@
370377 #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
371378 const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
372379
373
-/*
374
- * Component probe and remove ordering levels for components with runtime
375
- * dependencies.
376
- */
377
-#define SND_SOC_COMP_ORDER_FIRST -2
378
-#define SND_SOC_COMP_ORDER_EARLY -1
379
-#define SND_SOC_COMP_ORDER_NORMAL 0
380
-#define SND_SOC_COMP_ORDER_LATE 1
381
-#define SND_SOC_COMP_ORDER_LAST 2
382
-
383
-/* DAI Link Host Mode Support */
384
-#define SND_SOC_DAI_LINK_NO_HOST 0x1
385
-#define SND_SOC_DAI_LINK_OPT_HOST 0x2
386
-
387
-/*
388
- * Bias levels
389
- *
390
- * @ON: Bias is fully on for audio playback and capture operations.
391
- * @PREPARE: Prepare for audio operations. Called before DAPM switching for
392
- * stream start and stop operations.
393
- * @STANDBY: Low power standby state when no playback/capture operations are
394
- * in progress. NOTE: The transition time between STANDBY and ON
395
- * should be as fast as possible and no longer than 10ms.
396
- * @OFF: Power Off. No restrictions on transition times.
397
- */
398
-enum snd_soc_bias_level {
399
- SND_SOC_BIAS_OFF = 0,
400
- SND_SOC_BIAS_STANDBY = 1,
401
- SND_SOC_BIAS_PREPARE = 2,
402
- SND_SOC_BIAS_ON = 3,
403
-};
404
-
405380 struct device_node;
406381 struct snd_jack;
407382 struct snd_soc_card;
....@@ -430,11 +405,6 @@
430405 SND_SOC_PCM_CLASS_BE = 1,
431406 };
432407
433
-enum snd_soc_card_subclass {
434
- SND_SOC_CARD_CLASS_INIT = 0,
435
- SND_SOC_CARD_CLASS_RUNTIME = 1,
436
-};
437
-
438408 int snd_soc_register_card(struct snd_soc_card *card);
439409 int snd_soc_unregister_card(struct snd_soc_card *card);
440410 int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
....@@ -453,11 +423,12 @@
453423 }
454424 #endif
455425 int snd_soc_poweroff(struct device *dev);
456
-int snd_soc_add_component(struct device *dev,
457
- struct snd_soc_component *component,
458
- const struct snd_soc_component_driver *component_driver,
459
- struct snd_soc_dai_driver *dai_drv,
460
- int num_dai);
426
+int snd_soc_component_initialize(struct snd_soc_component *component,
427
+ const struct snd_soc_component_driver *driver,
428
+ struct device *dev);
429
+int snd_soc_add_component(struct snd_soc_component *component,
430
+ struct snd_soc_dai_driver *dai_drv,
431
+ int num_dai);
461432 int snd_soc_register_component(struct device *dev,
462433 const struct snd_soc_component_driver *component_driver,
463434 struct snd_soc_dai_driver *dai_drv, int num_dai);
....@@ -465,6 +436,10 @@
465436 const struct snd_soc_component_driver *component_driver,
466437 struct snd_soc_dai_driver *dai_drv, int num_dai);
467438 void snd_soc_unregister_component(struct device *dev);
439
+void snd_soc_unregister_component_by_driver(struct device *dev,
440
+ const struct snd_soc_component_driver *component_driver);
441
+struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
442
+ const char *driver_name);
468443 struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
469444 const char *driver_name);
470445
....@@ -480,14 +455,26 @@
480455
481456 void snd_soc_disconnect_sync(struct device *dev);
482457
483
-struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
484
- const char *dai_link, int stream);
485458 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
486
- const char *dai_link);
459
+ struct snd_soc_dai_link *dai_link);
487460
488461 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
489
-void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream);
490
-void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);
462
+
463
+void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
464
+ int stream, int action);
465
+static inline void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd,
466
+ int stream)
467
+{
468
+ snd_soc_runtime_action(rtd, stream, 1);
469
+}
470
+static inline void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd,
471
+ int stream)
472
+{
473
+ snd_soc_runtime_action(rtd, stream, -1);
474
+}
475
+
476
+int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
477
+ struct snd_pcm_hardware *hw, int stream);
491478
492479 int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
493480 unsigned int dai_fmt);
....@@ -512,15 +499,7 @@
512499 int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
513500 const struct snd_pcm_hardware *hw);
514501
515
-int soc_dai_hw_params(struct snd_pcm_substream *substream,
516
- struct snd_pcm_hw_params *params,
517
- struct snd_soc_dai *dai);
518
-
519502 /* Jack reporting */
520
-int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
521
- struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
522
- unsigned int num_pins);
523
-
524503 void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
525504 int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
526505 struct snd_soc_jack_pin *pins);
....@@ -560,8 +539,6 @@
560539 }
561540 #endif
562541
563
-void snd_soc_card_change_online_state(struct snd_soc_card *soc_card,
564
- int online);
565542 struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
566543 struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
567544 unsigned int id, unsigned int id_mask);
....@@ -592,8 +569,6 @@
592569 struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
593570 void *data, const char *long_name,
594571 const char *prefix);
595
-struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
596
- const char *name);
597572 int snd_soc_add_component_controls(struct snd_soc_component *component,
598573 const struct snd_kcontrol_new *controls, unsigned int num_controls);
599574 int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
....@@ -743,7 +718,6 @@
743718 unsigned int channels_min; /* min channels */
744719 unsigned int channels_max; /* max channels */
745720 unsigned int sig_bits; /* number of bits of content */
746
- const char *aif_name; /* DAPM AIF widget name */
747721 };
748722
749723 /* SoC audio ops */
....@@ -763,140 +737,9 @@
763737 int (*trigger)(struct snd_compr_stream *);
764738 };
765739
766
-/* component interface */
767
-struct snd_soc_component_driver {
768
- const char *name;
769
-
770
- /* Default control and setup, added after probe() is run */
771
- const struct snd_kcontrol_new *controls;
772
- unsigned int num_controls;
773
- const struct snd_soc_dapm_widget *dapm_widgets;
774
- unsigned int num_dapm_widgets;
775
- const struct snd_soc_dapm_route *dapm_routes;
776
- unsigned int num_dapm_routes;
777
-
778
- int (*probe)(struct snd_soc_component *);
779
- void (*remove)(struct snd_soc_component *);
780
- int (*suspend)(struct snd_soc_component *);
781
- int (*resume)(struct snd_soc_component *);
782
-
783
- unsigned int (*read)(struct snd_soc_component *, unsigned int);
784
- int (*write)(struct snd_soc_component *, unsigned int, unsigned int);
785
-
786
- /* pcm creation and destruction */
787
- int (*pcm_new)(struct snd_soc_pcm_runtime *);
788
- void (*pcm_free)(struct snd_pcm *);
789
-
790
- /* component wide operations */
791
- int (*set_sysclk)(struct snd_soc_component *component,
792
- int clk_id, int source, unsigned int freq, int dir);
793
- int (*set_pll)(struct snd_soc_component *component, int pll_id,
794
- int source, unsigned int freq_in, unsigned int freq_out);
795
- int (*set_jack)(struct snd_soc_component *component,
796
- struct snd_soc_jack *jack, void *data);
797
-
798
- /* DT */
799
- int (*of_xlate_dai_name)(struct snd_soc_component *component,
800
- struct of_phandle_args *args,
801
- const char **dai_name);
802
- int (*of_xlate_dai_id)(struct snd_soc_component *comment,
803
- struct device_node *endpoint);
804
- void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type,
805
- int subseq);
806
- int (*stream_event)(struct snd_soc_component *, int event);
807
- int (*set_bias_level)(struct snd_soc_component *component,
808
- enum snd_soc_bias_level level);
809
-
810
- /*
811
- * For platform-caused delay reporting, where the thread blocks waiting
812
- * for the delay amount to be determined. Defining this will cause the
813
- * ASoC core to skip calling the delay callbacks for all components in
814
- * the runtime.
815
- * Optional.
816
- */
817
- snd_pcm_sframes_t (*delay_blk)(struct snd_pcm_substream *substream,
818
- struct snd_soc_dai *dai);
819
-
820
- const struct snd_pcm_ops *ops;
821
- const struct snd_compr_ops *compr_ops;
822
-
823
- /* probe ordering - for components with runtime dependencies */
824
- int probe_order;
825
- int remove_order;
826
-
827
- /* bits */
828
- unsigned int idle_bias_on:1;
829
- unsigned int suspend_bias_off:1;
830
- unsigned int use_pmdown_time:1; /* care pmdown_time at stop */
831
- unsigned int endianness:1;
832
- unsigned int non_legacy_dai_naming:1;
833
-
834
- /* this component uses topology and ignore machine driver FEs */
835
- const char *ignore_machine;
836
- const char *topology_name_prefix;
837
- int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
838
- struct snd_pcm_hw_params *params);
839
- bool use_dai_pcm_id; /* use the DAI link PCM ID as PCM device number */
840
- int be_pcm_base; /* base device ID for all BE PCMs */
841
-};
842
-
843
-struct snd_soc_component {
844
- const char *name;
845
- int id;
846
- const char *name_prefix;
847
- struct device *dev;
848
- struct snd_soc_card *card;
849
-
850
- unsigned int active;
851
-
852
- unsigned int suspended:1; /* is in suspend PM state */
853
-
854
- struct list_head list;
855
- struct list_head card_aux_list; /* for auxiliary bound components */
856
- struct list_head card_list;
857
-
858
- const struct snd_soc_component_driver *driver;
859
-
860
- struct list_head dai_list;
861
- int num_dai;
862
-
863
- struct regmap *regmap;
864
- int val_bytes;
865
-
866
- struct mutex io_mutex;
867
-
868
- /* attached dynamic objects */
869
- struct list_head dobj_list;
870
-
871
- /*
872
- * DO NOT use any of the fields below in drivers, they are temporary and
873
- * are going to be removed again soon. If you use them in driver code the
874
- * driver will be marked as BROKEN when these fields are removed.
875
- */
876
-
877
- /* Don't use these, use snd_soc_component_get_dapm() */
878
- struct snd_soc_dapm_context dapm;
879
-
880
- /* machine specific init */
881
- int (*init)(struct snd_soc_component *component);
882
-
883
-#ifdef CONFIG_DEBUG_FS
884
- struct dentry *debugfs_root;
885
- const char *debugfs_prefix;
886
-#endif
887
-};
888
-
889
-struct snd_soc_rtdcom_list {
890
- struct snd_soc_component *component;
891
- struct list_head list; /* rtd::component_list */
892
-};
893740 struct snd_soc_component*
894741 snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
895742 const char *driver_name);
896
-#define for_each_rtdcom(rtd, rtdcom) \
897
- list_for_each_entry(rtdcom, &(rtd)->component_list, list)
898
-#define for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2) \
899
- list_for_each_entry_safe(rtdcom1, rtdcom2, &(rtd)->component_list, list)
900743
901744 struct snd_soc_dai_link_component {
902745 const char *name;
....@@ -904,18 +747,11 @@
904747 const char *dai_name;
905748 };
906749
907
-enum snd_soc_async_ops {
908
- ASYNC_DPCM_SND_SOC_OPEN = 1 << 0,
909
- ASYNC_DPCM_SND_SOC_CLOSE = 1 << 1,
910
- ASYNC_DPCM_SND_SOC_PREPARE = 1 << 2,
911
- ASYNC_DPCM_SND_SOC_HW_PARAMS = 1 << 3,
912
- ASYNC_DPCM_SND_SOC_FREE = 1 << 4,
913
-};
914
-
915750 struct snd_soc_dai_link {
916751 /* config - must be set by machine driver */
917752 const char *name; /* Codec name */
918753 const char *stream_name; /* Stream name */
754
+
919755 /*
920756 * You MAY specify the link's CPU-side device, either by device name,
921757 * or by DT/OF node, but not both. If this information is omitted,
....@@ -923,33 +759,30 @@
923759 * must be globally unique. These fields are currently typically used
924760 * only for codec to codec links, or systems using device tree.
925761 */
926
- const char *cpu_name;
927
- struct device_node *cpu_of_node;
928762 /*
929763 * You MAY specify the DAI name of the CPU DAI. If this information is
930764 * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
931765 * only, which only works well when that device exposes a single DAI.
932766 */
933
- const char *cpu_dai_name;
767
+ struct snd_soc_dai_link_component *cpus;
768
+ unsigned int num_cpus;
769
+
934770 /*
935771 * You MUST specify the link's codec, either by device name, or by
936772 * DT/OF node, but not both.
937773 */
938
- const char *codec_name;
939
- struct device_node *codec_of_node;
940774 /* You MUST specify the DAI name within the codec */
941
- const char *codec_dai_name;
942
-
943775 struct snd_soc_dai_link_component *codecs;
944776 unsigned int num_codecs;
945777
946778 /*
947779 * You MAY specify the link's platform/PCM/DMA driver, either by
948780 * device name, or by DT/OF node, but not both. Some forms of link
949
- * do not need a platform.
781
+ * do not need a platform. In such case, platforms are not mandatory.
950782 */
951
- const char *platform_name;
952
- struct device_node *platform_of_node;
783
+ struct snd_soc_dai_link_component *platforms;
784
+ unsigned int num_platforms;
785
+
953786 int id; /* optional ID for machine driver link identification */
954787
955788 const struct snd_soc_pcm_stream *params;
....@@ -962,6 +795,9 @@
962795 /* codec/machine specific init - e.g. add machine controls */
963796 int (*init)(struct snd_soc_pcm_runtime *rtd);
964797
798
+ /* codec/machine specific exit - dual of init() */
799
+ void (*exit)(struct snd_soc_pcm_runtime *rtd);
800
+
965801 /* optional hw_params re-writing for BE and FE sync */
966802 int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
967803 struct snd_pcm_hw_params *params);
....@@ -971,7 +807,7 @@
971807 const struct snd_soc_compr_ops *compr_ops;
972808
973809 /* Mark this pcm with non atomic ops */
974
- bool nonatomic;
810
+ unsigned int nonatomic:1;
975811
976812 /* For unidirectional dai links */
977813 unsigned int playback_only:1;
....@@ -991,15 +827,6 @@
991827 /* This DAI link can route to other DAI links at runtime (Frontend)*/
992828 unsigned int dynamic:1;
993829
994
- /* This DAI link can be reconfigured at runtime (Backend) */
995
- unsigned int dynamic_be:1;
996
-
997
- /*
998
- * This DAI can support no host IO (no pcm data is
999
- * copied to from host)
1000
- */
1001
- unsigned int no_host_mode:2;
1002
-
1003830 /* DPCM capture and Playback support */
1004831 unsigned int dpcm_capture:1;
1005832 unsigned int dpcm_playback:1;
....@@ -1017,20 +844,124 @@
1017844 /* Do not create a PCM for this DAI link (Backend link) */
1018845 unsigned int ignore:1;
1019846
1020
- struct list_head list; /* DAI link list of the soc card */
847
+#ifdef CONFIG_SND_SOC_TOPOLOGY
1021848 struct snd_soc_dobj dobj; /* For topology */
849
+#endif
1022850
1023
- /* this value determines what all ops can be started asynchronously */
1024
- enum snd_soc_async_ops async_ops;
851
+ ANDROID_KABI_RESERVE(1);
1025852 };
853
+#define for_each_link_codecs(link, i, codec) \
854
+ for ((i) = 0; \
855
+ ((i) < link->num_codecs) && ((codec) = &link->codecs[i]); \
856
+ (i)++)
857
+
858
+#define for_each_link_platforms(link, i, platform) \
859
+ for ((i) = 0; \
860
+ ((i) < link->num_platforms) && \
861
+ ((platform) = &link->platforms[i]); \
862
+ (i)++)
863
+
864
+#define for_each_link_cpus(link, i, cpu) \
865
+ for ((i) = 0; \
866
+ ((i) < link->num_cpus) && ((cpu) = &link->cpus[i]); \
867
+ (i)++)
868
+
869
+/*
870
+ * Sample 1 : Single CPU/Codec/Platform
871
+ *
872
+ * SND_SOC_DAILINK_DEFS(test,
873
+ * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai")),
874
+ * DAILINK_COMP_ARRAY(COMP_CODEC("codec", "codec_dai")),
875
+ * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
876
+ *
877
+ * struct snd_soc_dai_link link = {
878
+ * ...
879
+ * SND_SOC_DAILINK_REG(test),
880
+ * };
881
+ *
882
+ * Sample 2 : Multi CPU/Codec, no Platform
883
+ *
884
+ * SND_SOC_DAILINK_DEFS(test,
885
+ * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
886
+ * COMP_CPU("cpu_dai2")),
887
+ * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
888
+ * COMP_CODEC("codec2", "codec_dai2")));
889
+ *
890
+ * struct snd_soc_dai_link link = {
891
+ * ...
892
+ * SND_SOC_DAILINK_REG(test),
893
+ * };
894
+ *
895
+ * Sample 3 : Define each CPU/Codec/Platform manually
896
+ *
897
+ * SND_SOC_DAILINK_DEF(test_cpu,
898
+ * DAILINK_COMP_ARRAY(COMP_CPU("cpu_dai1"),
899
+ * COMP_CPU("cpu_dai2")));
900
+ * SND_SOC_DAILINK_DEF(test_codec,
901
+ * DAILINK_COMP_ARRAY(COMP_CODEC("codec1", "codec_dai1"),
902
+ * COMP_CODEC("codec2", "codec_dai2")));
903
+ * SND_SOC_DAILINK_DEF(test_platform,
904
+ * DAILINK_COMP_ARRAY(COMP_PLATFORM("platform")));
905
+ *
906
+ * struct snd_soc_dai_link link = {
907
+ * ...
908
+ * SND_SOC_DAILINK_REG(test_cpu,
909
+ * test_codec,
910
+ * test_platform),
911
+ * };
912
+ *
913
+ * Sample 4 : Sample3 without platform
914
+ *
915
+ * struct snd_soc_dai_link link = {
916
+ * ...
917
+ * SND_SOC_DAILINK_REG(test_cpu,
918
+ * test_codec);
919
+ * };
920
+ */
921
+
922
+#define SND_SOC_DAILINK_REG1(name) SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
923
+#define SND_SOC_DAILINK_REG2(cpu, codec) SND_SOC_DAILINK_REG3(cpu, codec, null_dailink_component)
924
+#define SND_SOC_DAILINK_REG3(cpu, codec, platform) \
925
+ .cpus = cpu, \
926
+ .num_cpus = ARRAY_SIZE(cpu), \
927
+ .codecs = codec, \
928
+ .num_codecs = ARRAY_SIZE(codec), \
929
+ .platforms = platform, \
930
+ .num_platforms = ARRAY_SIZE(platform)
931
+
932
+#define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
933
+#define SND_SOC_DAILINK_REG(...) \
934
+ SND_SOC_DAILINK_REGx(__VA_ARGS__, \
935
+ SND_SOC_DAILINK_REG3, \
936
+ SND_SOC_DAILINK_REG2, \
937
+ SND_SOC_DAILINK_REG1)(__VA_ARGS__)
938
+
939
+#define SND_SOC_DAILINK_DEF(name, def...) \
940
+ static struct snd_soc_dai_link_component name[] = { def }
941
+
942
+#define SND_SOC_DAILINK_DEFS(name, cpu, codec, platform...) \
943
+ SND_SOC_DAILINK_DEF(name##_cpus, cpu); \
944
+ SND_SOC_DAILINK_DEF(name##_codecs, codec); \
945
+ SND_SOC_DAILINK_DEF(name##_platforms, platform)
946
+
947
+#define DAILINK_COMP_ARRAY(param...) param
948
+#define COMP_EMPTY() { }
949
+#define COMP_CPU(_dai) { .dai_name = _dai, }
950
+#define COMP_CODEC(_name, _dai) { .name = _name, .dai_name = _dai, }
951
+#define COMP_PLATFORM(_name) { .name = _name }
952
+#define COMP_AUX(_name) { .name = _name }
953
+#define COMP_CODEC_CONF(_name) { .name = _name }
954
+#define COMP_DUMMY() { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }
955
+
956
+extern struct snd_soc_dai_link_component null_dailink_component[0];
957
+
1026958
1027959 struct snd_soc_codec_conf {
1028960 /*
1029961 * specify device either by device name, or by
1030962 * DT/OF node, but not both.
1031963 */
1032
- const char *dev_name;
1033
- struct device_node *of_node;
964
+ struct snd_soc_dai_link_component dlc;
1034965
1035966 /*
1036967 * optional map of kcontrol, widget and path name prefixes that are
....@@ -1040,14 +971,11 @@
1040971 };
1041972
1042973 struct snd_soc_aux_dev {
1043
- const char *name; /* Codec name */
1044
-
1045974 /*
1046975 * specify multi-codec either by device name, or by
1047976 * DT/OF node, but not both.
1048977 */
1049
- const char *codec_name;
1050
- struct device_node *codec_of_node;
978
+ struct snd_soc_dai_link_component dlc;
1051979
1052980 /* codec/machine specific init - e.g. add machine controls */
1053981 int (*init)(struct snd_soc_component *component);
....@@ -1058,7 +986,10 @@
1058986 const char *name;
1059987 const char *long_name;
1060988 const char *driver_name;
989
+ const char *components;
990
+#ifdef CONFIG_DMI
1061991 char dmi_longname[80];
992
+#endif /* CONFIG_DMI */
1062993 char topology_shortname[32];
1063994
1064995 struct device *dev;
....@@ -1067,10 +998,12 @@
1067998
1068999 struct mutex mutex;
10691000 struct mutex dapm_mutex;
1070
- struct mutex dapm_power_mutex;
10711001
1072
- bool instantiated;
1073
- bool topology_shortname_created;
1002
+ /* Mutex for PCM operations */
1003
+ struct mutex pcm_mutex;
1004
+ enum snd_soc_pcm_subclass pcm_subclass;
1005
+
1006
+ spinlock_t dpcm_lock;
10741007
10751008 int (*probe)(struct snd_soc_card *card);
10761009 int (*late_probe)(struct snd_soc_card *card);
....@@ -1101,8 +1034,6 @@
11011034 /* CPU <--> Codec DAI links */
11021035 struct snd_soc_dai_link *dai_link; /* predefined links only */
11031036 int num_links; /* predefined links only */
1104
- struct list_head dai_link_list; /* all links */
1105
- int num_dai_links;
11061037
11071038 struct list_head rtd_list;
11081039 int num_rtd;
....@@ -1134,12 +1065,10 @@
11341065 int num_of_dapm_widgets;
11351066 const struct snd_soc_dapm_route *of_dapm_routes;
11361067 int num_of_dapm_routes;
1137
- bool fully_routed;
1138
-
1139
- struct work_struct deferred_resume_work;
11401068
11411069 /* lists of probed devices belonging to this card */
11421070 struct list_head component_dev_list;
1071
+ struct list_head list;
11431072
11441073 struct list_head widgets;
11451074 struct list_head paths;
....@@ -1156,52 +1085,142 @@
11561085
11571086 #ifdef CONFIG_DEBUG_FS
11581087 struct dentry *debugfs_card_root;
1159
- struct dentry *debugfs_pop_time;
1088
+#endif
1089
+#ifdef CONFIG_PM_SLEEP
1090
+ struct work_struct deferred_resume_work;
11601091 #endif
11611092 u32 pop_time;
11621093
1094
+ /* bit field */
1095
+ unsigned int instantiated:1;
1096
+ unsigned int topology_shortname_created:1;
1097
+ unsigned int fully_routed:1;
1098
+ unsigned int disable_route_checks:1;
1099
+ unsigned int probed:1;
1100
+
11631101 void *drvdata;
1102
+
1103
+ ANDROID_KABI_RESERVE(1);
1104
+ ANDROID_KABI_RESERVE(2);
1105
+ ANDROID_KABI_RESERVE(3);
1106
+ ANDROID_KABI_RESERVE(4);
11641107 };
1108
+#define for_each_card_prelinks(card, i, link) \
1109
+ for ((i) = 0; \
1110
+ ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
1111
+ (i)++)
1112
+#define for_each_card_pre_auxs(card, i, aux) \
1113
+ for ((i) = 0; \
1114
+ ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \
1115
+ (i)++)
1116
+
1117
+#define for_each_card_rtds(card, rtd) \
1118
+ list_for_each_entry(rtd, &(card)->rtd_list, list)
1119
+#define for_each_card_rtds_safe(card, rtd, _rtd) \
1120
+ list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)
1121
+
1122
+#define for_each_card_auxs(card, component) \
1123
+ list_for_each_entry(component, &card->aux_comp_list, card_aux_list)
1124
+#define for_each_card_auxs_safe(card, component, _comp) \
1125
+ list_for_each_entry_safe(component, _comp, \
1126
+ &card->aux_comp_list, card_aux_list)
1127
+
1128
+#define for_each_card_components(card, component) \
1129
+ list_for_each_entry(component, &(card)->component_dev_list, card_list)
1130
+
1131
+#define for_each_card_dapms(card, dapm) \
1132
+ list_for_each_entry(dapm, &card->dapm_list, list)
1133
+
1134
+#define for_each_card_widgets(card, w)\
1135
+ list_for_each_entry(w, &card->widgets, list)
1136
+#define for_each_card_widgets_safe(card, w, _w) \
1137
+ list_for_each_entry_safe(w, _w, &card->widgets, list)
11651138
11661139 /* SoC machine DAI configuration, glues a codec and cpu DAI together */
11671140 struct snd_soc_pcm_runtime {
11681141 struct device *dev;
11691142 struct snd_soc_card *card;
11701143 struct snd_soc_dai_link *dai_link;
1171
- struct mutex pcm_mutex;
1172
- enum snd_soc_pcm_subclass pcm_subclass;
11731144 struct snd_pcm_ops ops;
1145
+
1146
+ unsigned int params_select; /* currently selected param for dai link */
11741147
11751148 /* Dynamic PCM BE runtime data */
11761149 struct snd_soc_dpcm_runtime dpcm[2];
1177
- int fe_compr;
11781150
11791151 long pmdown_time;
11801152
1181
- /* err in case of ops failed */
1182
- int err_ops;
11831153 /* runtime devices */
11841154 struct snd_pcm *pcm;
11851155 struct snd_compr *compr;
1186
- struct snd_soc_dai *codec_dai;
1187
- struct snd_soc_dai *cpu_dai;
11881156
1189
- struct snd_soc_dai **codec_dais;
1157
+ /*
1158
+ * dais = cpu_dai + codec_dai
1159
+ * see
1160
+ * soc_new_pcm_runtime()
1161
+ * asoc_rtd_to_cpu()
1162
+ * asoc_rtd_to_codec()
1163
+ */
1164
+ struct snd_soc_dai **dais;
11901165 unsigned int num_codecs;
1166
+ unsigned int num_cpus;
1167
+
1168
+ struct snd_soc_dapm_widget *playback_widget;
1169
+ struct snd_soc_dapm_widget *capture_widget;
11911170
11921171 struct delayed_work delayed_work;
1172
+ void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
11931173 #ifdef CONFIG_DEBUG_FS
11941174 struct dentry *debugfs_dpcm_root;
11951175 #endif
11961176
11971177 unsigned int num; /* 0-based and monotonic increasing */
11981178 struct list_head list; /* rtd list of the soc card */
1199
- struct list_head component_list; /* list of connected components */
1179
+
1180
+ /* function mark */
1181
+ struct snd_pcm_substream *mark_startup;
12001182
12011183 /* bit field */
1202
- unsigned int dev_registered:1;
12031184 unsigned int pop_wait:1;
1185
+ unsigned int fe_compr:1; /* for Dynamic PCM */
1186
+
1187
+ int num_components;
1188
+
1189
+ ANDROID_KABI_RESERVE(1);
1190
+
1191
+ struct snd_soc_component *components[]; /* CPU/Codec/Platform */
12041192 };
1193
+/* see soc_new_pcm_runtime() */
1194
+#define asoc_rtd_to_cpu(rtd, n) (rtd)->dais[n]
1195
+#define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->num_cpus]
1196
+#define asoc_substream_to_rtd(substream) \
1197
+ (struct snd_soc_pcm_runtime *)snd_pcm_substream_chip(substream)
1198
+
1199
+#define for_each_rtd_components(rtd, i, component) \
1200
+ for ((i) = 0, component = NULL; \
1201
+ ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
1202
+ (i)++)
1203
+#define for_each_rtd_cpu_dais(rtd, i, dai) \
1204
+ for ((i) = 0; \
1205
+ ((i) < rtd->num_cpus) && ((dai) = asoc_rtd_to_cpu(rtd, i)); \
1206
+ (i)++)
1207
+#define for_each_rtd_cpu_dais_rollback(rtd, i, dai) \
1208
+ for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_cpu(rtd, i));)
1209
+#define for_each_rtd_codec_dais(rtd, i, dai) \
1210
+ for ((i) = 0; \
1211
+ ((i) < rtd->num_codecs) && ((dai) = asoc_rtd_to_codec(rtd, i)); \
1212
+ (i)++)
1213
+#define for_each_rtd_codec_dais_rollback(rtd, i, dai) \
1214
+ for (; (--(i) >= 0) && ((dai) = asoc_rtd_to_codec(rtd, i));)
1215
+#define for_each_rtd_dais(rtd, i, dai) \
1216
+ for ((i) = 0; \
1217
+ ((i) < (rtd)->num_cpus + (rtd)->num_codecs) && \
1218
+ ((dai) = (rtd)->dais[i]); \
1219
+ (i)++)
1220
+#define for_each_rtd_dais_rollback(rtd, i, dai) \
1221
+ for (; (--(i) >= 0) && ((dai) = (rtd)->dais[i]);)
1222
+
1223
+void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
12051224
12061225 /* mixer control */
12071226 struct soc_mixer_control {
....@@ -1211,7 +1230,11 @@
12111230 unsigned int sign_bit;
12121231 unsigned int invert:1;
12131232 unsigned int autodisable:1;
1233
+#ifdef CONFIG_SND_SOC_TOPOLOGY
12141234 struct snd_soc_dobj dobj;
1235
+#endif
1236
+
1237
+ ANDROID_KABI_RESERVE(1);
12151238 };
12161239
12171240 struct soc_bytes {
....@@ -1222,8 +1245,9 @@
12221245
12231246 struct soc_bytes_ext {
12241247 int max;
1248
+#ifdef CONFIG_SND_SOC_TOPOLOGY
12251249 struct snd_soc_dobj dobj;
1226
-
1250
+#endif
12271251 /* used for TLV byte control */
12281252 int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
12291253 unsigned int size);
....@@ -1252,182 +1276,23 @@
12521276 const char * const *texts;
12531277 const unsigned int *values;
12541278 unsigned int autodisable:1;
1279
+#ifdef CONFIG_SND_SOC_TOPOLOGY
12551280 struct snd_soc_dobj dobj;
1256
-};
1257
-
1258
-/**
1259
- * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
1260
- * embedded in
1261
- * @dapm: The DAPM context to cast to the component
1262
- *
1263
- * This function must only be used on DAPM contexts that are known to be part of
1264
- * a component (e.g. in a component driver). Otherwise the behavior is
1265
- * undefined.
1266
- */
1267
-static inline struct snd_soc_component *snd_soc_dapm_to_component(
1268
- struct snd_soc_dapm_context *dapm)
1269
-{
1270
- return container_of(dapm, struct snd_soc_component, dapm);
1271
-}
1272
-
1273
-/**
1274
- * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
1275
- * component
1276
- * @component: The component for which to get the DAPM context
1277
- */
1278
-static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
1279
- struct snd_soc_component *component)
1280
-{
1281
- return &component->dapm;
1282
-}
1283
-
1284
-/**
1285
- * snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level
1286
- * @component: The COMPONENT for which to initialize the DAPM bias level
1287
- * @level: The DAPM level to initialize to
1288
- *
1289
- * Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level().
1290
- */
1291
-static inline void
1292
-snd_soc_component_init_bias_level(struct snd_soc_component *component,
1293
- enum snd_soc_bias_level level)
1294
-{
1295
- snd_soc_dapm_init_bias_level(
1296
- snd_soc_component_get_dapm(component), level);
1297
-}
1298
-
1299
-/**
1300
- * snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level
1301
- * @component: The COMPONENT for which to get the DAPM bias level
1302
- *
1303
- * Returns: The current DAPM bias level of the COMPONENT.
1304
- */
1305
-static inline enum snd_soc_bias_level
1306
-snd_soc_component_get_bias_level(struct snd_soc_component *component)
1307
-{
1308
- return snd_soc_dapm_get_bias_level(
1309
- snd_soc_component_get_dapm(component));
1310
-}
1311
-
1312
-/**
1313
- * snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level
1314
- * @component: The COMPONENT for which to set the level
1315
- * @level: The level to set to
1316
- *
1317
- * Forces the COMPONENT bias level to a specific state. See
1318
- * snd_soc_dapm_force_bias_level().
1319
- */
1320
-static inline int
1321
-snd_soc_component_force_bias_level(struct snd_soc_component *component,
1322
- enum snd_soc_bias_level level)
1323
-{
1324
- return snd_soc_dapm_force_bias_level(
1325
- snd_soc_component_get_dapm(component),
1326
- level);
1327
-}
1328
-
1329
-/**
1330
- * snd_soc_dapm_kcontrol_component() - Returns the component associated to a kcontrol
1331
- * @kcontrol: The kcontrol
1332
- *
1333
- * This function must only be used on DAPM contexts that are known to be part of
1334
- * a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined.
1335
- */
1336
-static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component(
1337
- struct snd_kcontrol *kcontrol)
1338
-{
1339
- return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol));
1340
-}
1341
-
1342
-/**
1343
- * snd_soc_component_cache_sync() - Sync the register cache with the hardware
1344
- * @component: COMPONENT to sync
1345
- *
1346
- * Note: This function will call regcache_sync()
1347
- */
1348
-static inline int snd_soc_component_cache_sync(
1349
- struct snd_soc_component *component)
1350
-{
1351
- return regcache_sync(component->regmap);
1352
-}
1353
-
1354
-/* component IO */
1355
-int snd_soc_component_read(struct snd_soc_component *component,
1356
- unsigned int reg, unsigned int *val);
1357
-unsigned int snd_soc_component_read32(struct snd_soc_component *component,
1358
- unsigned int reg);
1359
-int snd_soc_component_write(struct snd_soc_component *component,
1360
- unsigned int reg, unsigned int val);
1361
-int snd_soc_component_update_bits(struct snd_soc_component *component,
1362
- unsigned int reg, unsigned int mask, unsigned int val);
1363
-int snd_soc_component_update_bits_async(struct snd_soc_component *component,
1364
- unsigned int reg, unsigned int mask, unsigned int val);
1365
-void snd_soc_component_async_complete(struct snd_soc_component *component);
1366
-int snd_soc_component_test_bits(struct snd_soc_component *component,
1367
- unsigned int reg, unsigned int mask, unsigned int value);
1368
-struct snd_soc_component *soc_find_component(
1369
- const struct device_node *of_node, const char *name);
1370
-
1371
-/* component wide operations */
1372
-int snd_soc_component_set_sysclk(struct snd_soc_component *component,
1373
- int clk_id, int source, unsigned int freq, int dir);
1374
-int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
1375
- int source, unsigned int freq_in,
1376
- unsigned int freq_out);
1377
-int snd_soc_component_set_jack(struct snd_soc_component *component,
1378
- struct snd_soc_jack *jack, void *data);
1379
-
1380
-#ifdef CONFIG_REGMAP
1381
-
1382
-void snd_soc_component_init_regmap(struct snd_soc_component *component,
1383
- struct regmap *regmap);
1384
-void snd_soc_component_exit_regmap(struct snd_soc_component *component);
1385
-
13861281 #endif
13871282
1388
-/* device driver data */
1389
-
1390
-static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
1391
- void *data)
1392
-{
1393
- card->drvdata = data;
1394
-}
1395
-
1396
-static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
1397
-{
1398
- return card->drvdata;
1399
-}
1400
-
1401
-static inline void snd_soc_component_set_drvdata(struct snd_soc_component *c,
1402
- void *data)
1403
-{
1404
- dev_set_drvdata(c->dev, data);
1405
-}
1406
-
1407
-static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
1408
-{
1409
- return dev_get_drvdata(c->dev);
1410
-}
1411
-
1412
-static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
1413
-{
1414
- INIT_LIST_HEAD(&card->widgets);
1415
- INIT_LIST_HEAD(&card->paths);
1416
- INIT_LIST_HEAD(&card->dapm_list);
1417
- INIT_LIST_HEAD(&card->aux_comp_list);
1418
- INIT_LIST_HEAD(&card->component_dev_list);
1419
-}
1283
+ ANDROID_KABI_RESERVE(1);
1284
+};
14201285
14211286 static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
14221287 {
14231288 if (mc->reg == mc->rreg && mc->shift == mc->rshift)
1424
- return 0;
1289
+ return false;
14251290 /*
14261291 * mc->reg == mc->rreg && mc->shift != mc->rshift, or
14271292 * mc->reg != mc->rreg means that the control is
14281293 * stereo (bits in one register or in two registers)
14291294 */
1430
- return 1;
1295
+ return true;
14311296 }
14321297
14331298 static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
....@@ -1452,12 +1317,6 @@
14521317 return item;
14531318
14541319 return e->values[item];
1455
-}
1456
-
1457
-static inline bool snd_soc_component_is_active(
1458
- struct snd_soc_component *component)
1459
-{
1460
- return component->active != 0;
14611320 }
14621321
14631322 /**
....@@ -1491,12 +1350,23 @@
14911350 unsigned int *rx_mask,
14921351 unsigned int *slots,
14931352 unsigned int *slot_width);
1494
-void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
1353
+void snd_soc_of_parse_node_prefix(struct device_node *np,
14951354 struct snd_soc_codec_conf *codec_conf,
14961355 struct device_node *of_node,
14971356 const char *propname);
1357
+static inline
1358
+void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
1359
+ struct snd_soc_codec_conf *codec_conf,
1360
+ struct device_node *of_node,
1361
+ const char *propname)
1362
+{
1363
+ snd_soc_of_parse_node_prefix(card->dev->of_node,
1364
+ codec_conf, of_node, propname);
1365
+}
1366
+
14981367 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
14991368 const char *propname);
1369
+int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
15001370 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
15011371 const char *prefix,
15021372 struct device_node **bitclkmaster,
....@@ -1511,34 +1381,52 @@
15111381 struct snd_soc_dai_link *dai_link);
15121382 void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
15131383
1514
-int snd_soc_add_dai_link(struct snd_soc_card *card,
1515
- struct snd_soc_dai_link *dai_link);
1516
-void snd_soc_remove_dai_link(struct snd_soc_card *card,
1517
- struct snd_soc_dai_link *dai_link);
1518
-struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
1519
- int id, const char *name,
1520
- const char *stream_name);
1384
+int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
1385
+ struct snd_soc_dai_link *dai_link);
1386
+void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
1387
+ struct snd_soc_pcm_runtime *rtd);
15211388
1522
-int snd_soc_register_dai(struct snd_soc_component *component,
1523
- struct snd_soc_dai_driver *dai_drv);
1389
+struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
1390
+ struct snd_soc_dai_driver *dai_drv,
1391
+ bool legacy_dai_naming);
1392
+struct snd_soc_dai *devm_snd_soc_register_dai(struct device *dev,
1393
+ struct snd_soc_component *component,
1394
+ struct snd_soc_dai_driver *dai_drv,
1395
+ bool legacy_dai_naming);
1396
+void snd_soc_unregister_dai(struct snd_soc_dai *dai);
15241397
15251398 struct snd_soc_dai *snd_soc_find_dai(
1399
+ const struct snd_soc_dai_link_component *dlc);
1400
+struct snd_soc_dai *snd_soc_find_dai_with_mutex(
15261401 const struct snd_soc_dai_link_component *dlc);
15271402
15281403 #include <sound/soc-dai.h>
15291404
15301405 static inline
1531
-struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,
1532
- const char *dai_name)
1406
+int snd_soc_fixup_dai_links_platform_name(struct snd_soc_card *card,
1407
+ const char *platform_name)
15331408 {
1534
- struct snd_soc_pcm_runtime *rtd;
1409
+ struct snd_soc_dai_link *dai_link;
1410
+ const char *name;
1411
+ int i;
15351412
1536
- list_for_each_entry(rtd, &card->rtd_list, list) {
1537
- if (!strcmp(rtd->codec_dai->name, dai_name))
1538
- return rtd->codec_dai;
1413
+ if (!platform_name) /* nothing to do */
1414
+ return 0;
1415
+
1416
+ /* set platform name for each dailink */
1417
+ for_each_card_prelinks(card, i, dai_link) {
1418
+ name = devm_kstrdup(card->dev, platform_name, GFP_KERNEL);
1419
+ if (!name)
1420
+ return -ENOMEM;
1421
+
1422
+ if (!dai_link->platforms)
1423
+ return -EINVAL;
1424
+
1425
+ /* only single platform is supported for now */
1426
+ dai_link->platforms->name = name;
15391427 }
15401428
1541
- return NULL;
1429
+ return 0;
15421430 }
15431431
15441432 #ifdef CONFIG_DEBUG_FS
....@@ -1558,24 +1446,7 @@
15581446 mutex_unlock(&dapm->card->dapm_mutex);
15591447 }
15601448
1561
-int snd_soc_component_enable_pin(struct snd_soc_component *component,
1562
- const char *pin);
1563
-int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
1564
- const char *pin);
1565
-int snd_soc_component_disable_pin(struct snd_soc_component *component,
1566
- const char *pin);
1567
-int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
1568
- const char *pin);
1569
-int snd_soc_component_nc_pin(struct snd_soc_component *component,
1570
- const char *pin);
1571
-int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
1572
- const char *pin);
1573
-int snd_soc_component_get_pin_status(struct snd_soc_component *component,
1574
- const char *pin);
1575
-int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
1576
- const char *pin);
1577
-int snd_soc_component_force_enable_pin_unlocked(
1578
- struct snd_soc_component *component,
1579
- const char *pin);
1449
+#include <sound/soc-component.h>
1450
+#include <sound/soc-card.h>
15801451
15811452 #endif