]> git.karo-electronics.de Git - linux-beck.git/blobdiff - include/sound/soc.h
ASoC: Dynamically allocate the rtd device for a non-empty release()
[linux-beck.git] / include / sound / soc.h
index aa19f5a32ba8774a085a085d52866ede8d63fd3f..0992dff559593d7015fcef0e5a58dd42134539d6 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/regmap.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/control.h>
 /*
  * Convenience kcontrol builders
  */
-#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \
+#define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert) \
        ((unsigned long)&(struct soc_mixer_control) \
-       {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \
-       .platform_max = xmax, .invert = xinvert})
+       {.reg = xreg, .rreg = xreg, .shift = shift_left, \
+       .rshift = shift_right, .max = xmax, .platform_max = xmax, \
+       .invert = xinvert})
+#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \
+       SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert)
 #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
        ((unsigned long)&(struct soc_mixer_control) \
        {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
+#define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
+       ((unsigned long)&(struct soc_mixer_control) \
+       {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
+       .max = xmax, .platform_max = xmax, .invert = xinvert})
 #define SOC_SINGLE(xname, reg, shift, max, invert) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
        .put = snd_soc_put_volsw, \
        .private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) }
-#define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \
+#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
        .put = snd_soc_put_volsw, \
-       .private_value = (unsigned long)&(struct soc_mixer_control) \
-               {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
-                .max = xmax, .platform_max = xmax, .invert = xinvert} }
+       .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
+                                         max, invert) }
 #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
-       .info = snd_soc_info_volsw_2r, \
-       .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
-       .private_value = (unsigned long)&(struct soc_mixer_control) \
-               {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
-               .max = xmax, .platform_max = xmax, .invert = xinvert} }
-#define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \
+       .info = snd_soc_info_volsw, \
+       .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
+       .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
+                                           xmax, xinvert) }
+#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
        .tlv.p = (tlv_array), \
        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
        .put = snd_soc_put_volsw, \
-       .private_value = (unsigned long)&(struct soc_mixer_control) \
-               {.reg = xreg, .shift = shift_left, .rshift = shift_right,\
-                .max = xmax, .platform_max = xmax, .invert = xinvert} }
+       .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
+                                         max, invert) }
 #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
        .tlv.p = (tlv_array), \
-       .info = snd_soc_info_volsw_2r, \
-       .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
-       .private_value = (unsigned long)&(struct soc_mixer_control) \
-               {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
-               .max = xmax, .platform_max = xmax, .invert = xinvert} }
+       .info = snd_soc_info_volsw, \
+       .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
+       .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
+                                           xmax, xinvert) }
 #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
 {      .iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
        .info = snd_soc_info_volsw, \
        .get = xhandler_get, .put = xhandler_put, \
        .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
-#define SOC_DOUBLE_EXT(xname, xreg, shift_left, shift_right, xmax, xinvert,\
+#define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
         xhandler_get, xhandler_put) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
        .info = snd_soc_info_volsw, \
        .get = xhandler_get, .put = xhandler_put, \
-       .private_value = (unsigned long)&(struct soc_mixer_control) \
-               {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
-                .max = xmax, .platform_max = xmax, .invert = xinvert} }
+       .private_value = \
+               SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert) }
 #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
         xhandler_get, xhandler_put, tlv_array) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
        .tlv.p = (tlv_array), \
        .info = snd_soc_info_volsw, \
        .get = xhandler_get, .put = xhandler_put, \
-       .private_value = (unsigned long)&(struct soc_mixer_control) \
-               {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
-               .max = xmax, .platform_max = xmax, .invert = xinvert} }
+       .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
+                                         xmax, xinvert) }
 #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
         xhandler_get, xhandler_put, tlv_array) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
                 SNDRV_CTL_ELEM_ACCESS_READWRITE, \
        .tlv.p = (tlv_array), \
-       .info = snd_soc_info_volsw_2r, \
+       .info = snd_soc_info_volsw, \
        .get = xhandler_get, .put = xhandler_put, \
-       .private_value = (unsigned long)&(struct soc_mixer_control) \
-               {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
-               .max = xmax, .platform_max = xmax, .invert = xinvert} }
+       .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
+                                           xmax, xinvert) }
 #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
        .info = snd_soc_info_bool_ext, \
@@ -230,6 +231,7 @@ enum snd_soc_bias_level {
        SND_SOC_BIAS_ON = 3,
 };
 
+struct device_node;
 struct snd_jack;
 struct snd_soc_card;
 struct snd_soc_pcm_stream;
@@ -260,12 +262,11 @@ extern struct snd_ac97_bus_ops soc_ac97_ops;
 enum snd_soc_control_type {
        SND_SOC_I2C = 1,
        SND_SOC_SPI,
+       SND_SOC_REGMAP,
 };
 
 enum snd_soc_compress_type {
        SND_SOC_FLAT_COMPRESSION = 1,
-       SND_SOC_LZO_COMPRESSION,
-       SND_SOC_RBTREE_COMPRESSION
 };
 
 enum snd_soc_pcm_subclass {
@@ -274,7 +275,7 @@ enum snd_soc_pcm_subclass {
 };
 
 int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
-                            unsigned int freq, int dir);
+                            int source, unsigned int freq, int dir);
 int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
                          unsigned int freq_in, unsigned int freq_out);
 
@@ -316,6 +317,7 @@ int snd_soc_platform_read(struct snd_soc_platform *platform,
                                        unsigned int reg);
 int snd_soc_platform_write(struct snd_soc_platform *platform,
                                        unsigned int reg, unsigned int val);
+int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
 
 /* Utility functions to get clock rates from various things */
 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
@@ -391,12 +393,8 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol);
 int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol);
-int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
-       struct snd_ctl_elem_info *uinfo);
-int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
-       struct snd_ctl_elem_value *ucontrol);
-int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
-       struct snd_ctl_elem_value *ucontrol);
+#define snd_soc_get_volsw_2r snd_soc_get_volsw
+#define snd_soc_put_volsw_2r snd_soc_put_volsw
 int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_info *uinfo);
 int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
@@ -576,9 +574,11 @@ struct snd_soc_codec {
        const void *reg_def_copy;
        const struct snd_soc_cache_ops *cache_ops;
        struct mutex cache_rw_mutex;
+       int val_bytes;
 
        /* dapm */
        struct snd_soc_dapm_context dapm;
+       unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
 
 #ifdef CONFIG_DEBUG_FS
        struct dentry *debugfs_codec_root;
@@ -593,8 +593,7 @@ struct snd_soc_codec_driver {
        /* driver ops */
        int (*probe)(struct snd_soc_codec *);
        int (*remove)(struct snd_soc_codec *);
-       int (*suspend)(struct snd_soc_codec *,
-                       pm_message_t state);
+       int (*suspend)(struct snd_soc_codec *);
        int (*resume)(struct snd_soc_codec *);
 
        /* Default control and setup, added after probe() is run */
@@ -607,7 +606,7 @@ struct snd_soc_codec_driver {
 
        /* codec wide operations */
        int (*set_sysclk)(struct snd_soc_codec *codec,
-                         int clk_id, unsigned int freq, int dir);
+                         int clk_id, int source, unsigned int freq, int dir);
        int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source,
                unsigned int freq_in, unsigned int freq_out);
 
@@ -619,7 +618,7 @@ struct snd_soc_codec_driver {
        int (*volatile_register)(struct snd_soc_codec *, unsigned int);
        int (*readable_register)(struct snd_soc_codec *, unsigned int);
        int (*writable_register)(struct snd_soc_codec *, unsigned int);
-       short reg_cache_size;
+       unsigned int reg_cache_size;
        short reg_cache_step;
        short reg_word_size;
        const void *reg_cache_default;
@@ -630,10 +629,14 @@ struct snd_soc_codec_driver {
        /* codec bias level */
        int (*set_bias_level)(struct snd_soc_codec *,
                              enum snd_soc_bias_level level);
+       bool idle_bias_off;
 
        void (*seq_notifier)(struct snd_soc_dapm_context *,
                             enum snd_soc_dapm_type, int);
 
+       /* codec stream completion event */
+       int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
+
        /* probe ordering - for components with runtime dependencies */
        int probe_order;
        int remove_order;
@@ -669,6 +672,9 @@ struct snd_soc_platform_driver {
        /* platform stream ops */
        struct snd_pcm_ops *ops;
 
+       /* platform stream completion event */
+       int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
+
        /* probe ordering - for components with runtime dependencies */
        int probe_order;
        int remove_order;
@@ -699,16 +705,24 @@ struct snd_soc_dai_link {
        const char *name;                       /* Codec name */
        const char *stream_name;                /* Stream name */
        const char *codec_name;         /* for multi-codec */
+       const struct device_node *codec_of_node;
        const char *platform_name;      /* for multi-platform */
+       const struct device_node *platform_of_node;
        const char *cpu_dai_name;
+       const struct device_node *cpu_dai_of_node;
        const char *codec_dai_name;
 
+       unsigned int dai_fmt;           /* format to set on init */
+
        /* Keep DAI active over suspend */
        unsigned int ignore_suspend:1;
 
        /* Symmetry requirements */
        unsigned int symmetric_rates:1;
 
+       /* pmdown_time is ignored at stop */
+       unsigned int ignore_pmdown_time:1;
+
        /* codec/machine specific init - e.g. add machine controls */
        int (*init)(struct snd_soc_pcm_runtime *rtd);
 
@@ -804,6 +818,7 @@ struct snd_soc_card {
        int num_dapm_widgets;
        const struct snd_soc_dapm_route *dapm_routes;
        int num_dapm_routes;
+       bool fully_routed;
 
        struct work_struct deferred_resume_work;
 
@@ -815,9 +830,11 @@ struct snd_soc_card {
        struct list_head widgets;
        struct list_head paths;
        struct list_head dapm_list;
+       struct list_head dapm_dirty;
 
        /* Generic DAPM context for the card */
        struct snd_soc_dapm_context dapm;
+       struct snd_soc_dapm_stats dapm_stats;
 
 #ifdef CONFIG_DEBUG_FS
        struct dentry *debugfs_card_root;
@@ -829,8 +846,8 @@ struct snd_soc_card {
 };
 
 /* SoC machine DAI configuration, glues a codec and cpu DAI together */
-struct snd_soc_pcm_runtime  {
-       struct device dev;
+struct snd_soc_pcm_runtime {
+       struct device *dev;
        struct snd_soc_card *card;
        struct snd_soc_dai_link *dai_link;
        struct mutex pcm_mutex;
@@ -840,8 +857,6 @@ struct snd_soc_pcm_runtime  {
        unsigned int complete:1;
        unsigned int dev_registered:1;
 
-       /* Symmetry data - only valid if symmetry is being enforced */
-       unsigned int rate;
        long pmdown_time;
 
        /* runtime devices */
@@ -918,12 +933,12 @@ static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platfo
 static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
                void *data)
 {
-       dev_set_drvdata(&rtd->dev, data);
+       dev_set_drvdata(rtd->dev, data);
 }
 
 static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
 {
-       return dev_get_drvdata(&rtd->dev);
+       return dev_get_drvdata(rtd->dev);
 }
 
 static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
@@ -936,9 +951,26 @@ static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
        INIT_LIST_HEAD(&card->dapm_list);
 }
 
+static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
+{
+       if (mc->reg == mc->rreg && mc->shift == mc->rshift)
+               return 0;
+       /*
+        * mc->reg == mc->rreg && mc->shift != mc->rshift, or
+        * mc->reg != mc->rreg means that the control is
+        * stereo (bits in one register or in two registers)
+        */
+       return 1;
+}
+
 int snd_soc_util_init(void);
 void snd_soc_util_exit(void);
 
+int snd_soc_of_parse_card_name(struct snd_soc_card *card,
+                              const char *propname);
+int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
+                                  const char *propname);
+
 #include <sound/soc-dai.h>
 
 #ifdef CONFIG_DEBUG_FS