Ignore:
Timestamp:
Apr 3, 2017, 4:51:56 PM (8 years ago)
Author:
David Azarewicz
Message:

Merged/reintegrated v2 branch into trunk. Trunk is now v2

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/include/sound/soc.h

    r464 r598  
    1616#include <linux/platform_device.h>
    1717#include <linux/types.h>
     18#include <linux/notifier.h>
    1819#include <linux/workqueue.h>
    1920#include <linux/interrupt.h>
     
    3031        ((unsigned long)&(struct soc_mixer_control) \
    3132        {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \
    32         .invert = xinvert})
     33        .platform_max = xmax, .invert = xinvert})
    3334#define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
    3435        ((unsigned long)&(struct soc_mixer_control) \
    35         {.reg = xreg, .max = xmax, .invert = xinvert})
     36        {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
    3637#define SOC_SINGLE(xname, reg, shift, max, invert) \
    3738{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     
    5354        .private_value = (unsigned long)&(struct soc_mixer_control) \
    5455                {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
    55                  .max = xmax, .invert = xinvert} }
     56                 .max = xmax, .platform_max = xmax, .invert = xinvert} }
    5657#define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
    5758{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
     
    6061        .private_value = (unsigned long)&(struct soc_mixer_control) \
    6162                {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
    62                 .max = xmax, .invert = xinvert} }
     63                .max = xmax, .platform_max = xmax, .invert = xinvert} }
    6364#define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \
    6465{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
     
    7071        .private_value = (unsigned long)&(struct soc_mixer_control) \
    7172                {.reg = xreg, .shift = shift_left, .rshift = shift_right,\
    72                  .max = xmax, .invert = xinvert} }
     73                 .max = xmax, .platform_max = xmax, .invert = xinvert} }
    7374#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
    7475{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
     
    8081        .private_value = (unsigned long)&(struct soc_mixer_control) \
    8182                {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
    82                 .max = xmax, .invert = xinvert} }
     83                .max = xmax, .platform_max = xmax, .invert = xinvert} }
    8384#define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
    8485{       .iface  = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
     
    8990        .put    = snd_soc_put_volsw_s8, \
    9091        .private_value = (unsigned long)&(struct soc_mixer_control) \
    91                 {.reg = xreg, .min = xmin, .max = xmax} }
     92                {.reg = xreg, .min = xmin, .max = xmax, \
     93                 .platform_max = xmax} }
    9294#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \
    9395{       .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
     
    126128        .private_value = (unsigned long)&(struct soc_mixer_control) \
    127129                {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
    128                  .max = xmax, .invert = xinvert} }
     130                 .max = xmax, .platform_max = xmax, .invert = xinvert} }
    129131#define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
    130132         xhandler_get, xhandler_put, tlv_array) \
     
    146148        .private_value = (unsigned long)&(struct soc_mixer_control) \
    147149                {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
    148                 .max = xmax, .invert = xinvert} }
     150                .max = xmax, .platform_max = xmax, .invert = xinvert} }
    149151#define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
    150152         xhandler_get, xhandler_put, tlv_array) \
     
    157159        .private_value = (unsigned long)&(struct soc_mixer_control) \
    158160                {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
    159                 .max = xmax, .invert = xinvert} }
     161                .max = xmax, .platform_max = xmax, .invert = xinvert} }
    160162#define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
    161163{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
     
    168170        .get = xhandler_get, .put = xhandler_put, \
    169171        .private_value = (unsigned long)&xenum }
     172
     173#define SOC_DOUBLE_R_SX_TLV(xname, xreg_left, xreg_right, xshift,\
     174                xmin, xmax, tlv_array) \
     175{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
     176        .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
     177                  SNDRV_CTL_ELEM_ACCESS_READWRITE, \
     178        .tlv.p = (tlv_array), \
     179        .info = snd_soc_info_volsw_2r_sx, \
     180        .get = snd_soc_get_volsw_2r_sx, \
     181        .put = snd_soc_put_volsw_2r_sx, \
     182        .private_value = (unsigned long)&(struct soc_mixer_control) \
     183                {.reg = xreg_left, \
     184                 .rreg = xreg_right, .shift = xshift, \
     185                 .min = xmin, .max = xmax} }
     186
     187
     188/*
     189 * Simplified versions of above macros, declaring a struct and calculating
     190 * ARRAY_SIZE internally
     191 */
     192#define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
     193        struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
     194                                                ARRAY_SIZE(xtexts), xtexts)
     195#define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
     196        SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
     197#define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
     198        struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
     199#define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
     200        struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
     201                                                        ARRAY_SIZE(xtexts), xtexts, xvalues)
     202#define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
     203        SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
    170204
    171205/*
     
    181215 */
    182216enum snd_soc_bias_level {
     217        SND_SOC_BIAS_OFF,
     218        SND_SOC_BIAS_STANDBY,
     219        SND_SOC_BIAS_PREPARE,
    183220        SND_SOC_BIAS_ON,
    184         SND_SOC_BIAS_PREPARE,
    185         SND_SOC_BIAS_STANDBY,
    186         SND_SOC_BIAS_OFF,
    187221};
    188222
    189223struct snd_jack;
    190224struct snd_soc_card;
    191 struct snd_soc_device;
    192225struct snd_soc_pcm_stream;
    193226struct snd_soc_ops;
    194 struct snd_soc_dai_mode;
    195227struct snd_soc_pcm_runtime;
    196228struct snd_soc_dai;
     229struct snd_soc_dai_driver;
    197230struct snd_soc_platform;
     231struct snd_soc_dai_link;
     232struct snd_soc_platform_driver;
    198233struct snd_soc_codec;
     234struct snd_soc_codec_driver;
    199235struct soc_enum;
    200 struct snd_soc_ac97_ops;
    201236struct snd_soc_jack;
    202237struct snd_soc_jack_pin;
     238struct snd_soc_cache_ops;
     239#include <sound/soc-dapm.h>
     240
    203241#ifdef CONFIG_GPIOLIB
    204242struct snd_soc_jack_gpio;
     
    206244
    207245typedef int (*hw_write_t)(void *,const char* ,int);
    208 typedef int (*hw_read_t)(void *,char* ,int);
    209246
    210247extern struct snd_ac97_bus_ops soc_ac97_ops;
     
    216253};
    217254
    218 int snd_soc_register_platform(struct snd_soc_platform *platform);
    219 void snd_soc_unregister_platform(struct snd_soc_platform *platform);
    220 int snd_soc_register_codec(struct snd_soc_codec *codec);
    221 void snd_soc_unregister_codec(struct snd_soc_codec *codec);
     255enum snd_soc_compress_type {
     256        SND_SOC_FLAT_COMPRESSION = 1,
     257        SND_SOC_LZO_COMPRESSION,
     258        SND_SOC_RBTREE_COMPRESSION
     259};
     260
     261int snd_soc_register_card(struct snd_soc_card *card);
     262int snd_soc_unregister_card(struct snd_soc_card *card);
     263int snd_soc_register_platform(struct device *dev,
     264                struct snd_soc_platform_driver *platform_drv);
     265void snd_soc_unregister_platform(struct device *dev);
     266int snd_soc_register_codec(struct device *dev,
     267                const struct snd_soc_codec_driver *codec_drv,
     268                struct snd_soc_dai_driver *dai_drv, int num_dai);
     269void snd_soc_unregister_codec(struct device *dev);
    222270int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg);
    223271int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
    224272                               int addr_bits, int data_bits,
    225273                               enum snd_soc_control_type control);
    226 
    227 #ifdef CONFIG_PM
    228 int snd_soc_suspend_device(struct device *dev);
    229 int snd_soc_resume_device(struct device *dev);
    230 #endif
    231 
    232 /* pcm <-> DAI connect */
    233 void snd_soc_free_pcms(struct snd_soc_device *socdev);
    234 int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
    235 int snd_soc_init_card(struct snd_soc_device *socdev);
     274int snd_soc_cache_sync(struct snd_soc_codec *codec);
     275int snd_soc_cache_init(struct snd_soc_codec *codec);
     276int snd_soc_cache_exit(struct snd_soc_codec *codec);
     277int snd_soc_cache_write(struct snd_soc_codec *codec,
     278                        unsigned int reg, unsigned int value);
     279int snd_soc_cache_read(struct snd_soc_codec *codec,
     280                       unsigned int reg, unsigned int *value);
     281int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
     282                                      unsigned int reg);
     283int snd_soc_default_readable_register(struct snd_soc_codec *codec,
     284                                      unsigned int reg);
     285
     286/* Utility functions to get clock rates from various things */
     287int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
     288int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
     289int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
     290int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
    236291
    237292/* set runtime hw params */
     
    240295
    241296/* Jack reporting */
    242 int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type,
     297int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
    243298                     struct snd_soc_jack *jack);
    244299void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
    245300int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
    246301                          struct snd_soc_jack_pin *pins);
     302void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
     303                                    struct notifier_block *nb);
     304void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
     305                                      struct notifier_block *nb);
    247306#ifdef CONFIG_GPIOLIB
    248307int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
     
    255314int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
    256315                                unsigned int mask, unsigned int value);
     316int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
     317                               unsigned short reg, unsigned int mask,
     318                               unsigned int value);
    257319int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
    258320                                unsigned int mask, unsigned int value);
     
    302364int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
    303365        struct snd_ctl_elem_value *ucontrol);
     366int snd_soc_limit_volume(struct snd_soc_codec *codec,
     367        const char *name, int max);
     368int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol,
     369        struct snd_ctl_elem_info *uinfo);
     370int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
     371        struct snd_ctl_elem_value *ucontrol);
     372int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
     373        struct snd_ctl_elem_value *ucontrol);
     374
     375/**
     376 * struct snd_soc_reg_access - Describes whether a given register is
     377 * readable, writable or volatile.
     378 *
     379 * @reg: the register number
     380 * @read: whether this register is readable
     381 * @write: whether this register is writable
     382 * @vol: whether this register is volatile
     383 */
     384struct snd_soc_reg_access {
     385        u16 reg;
     386        u16 read;
     387        u16 write;
     388        u16 vol;
     389};
    304390
    305391/**
     
    334420        int debounce_time;
    335421        struct snd_soc_jack *jack;
    336         struct work_struct work;
     422        struct delayed_work work;
     423
     424        int (*jack_status_check)(void);
    337425};
    338426#endif
     
    340428struct snd_soc_jack {
    341429        struct snd_jack *jack;
    342         struct snd_soc_card *card;
     430        struct snd_soc_codec *codec;
    343431        struct list_head pins;
    344432        int status;
     433        struct blocking_notifier_head notifier;
    345434};
    346435
    347436/* SoC PCM stream information */
    348437struct snd_soc_pcm_stream {
    349         char *stream_name;
     438        const char *stream_name;
    350439        u64 formats;                    /* SNDRV_PCM_FMTBIT_* */
    351440        unsigned int rates;             /* SNDRV_PCM_RATE_* */
     
    354443        unsigned int channels_min;      /* min channels */
    355444        unsigned int channels_max;      /* max channels */
    356         unsigned int active:1;          /* stream is in use */
    357445};
    358446
     
    367455};
    368456
    369 /* SoC Audio Codec */
     457/* SoC cache ops */
     458struct snd_soc_cache_ops {
     459        const char *name;
     460        enum snd_soc_compress_type id;
     461        int (*init)(struct snd_soc_codec *codec);
     462        int (*exit)(struct snd_soc_codec *codec);
     463        int (*read)(struct snd_soc_codec *codec, unsigned int reg,
     464                unsigned int *value);
     465        int (*write)(struct snd_soc_codec *codec, unsigned int reg,
     466                unsigned int value);
     467        int (*sync)(struct snd_soc_codec *codec);
     468};
     469
     470/* SoC Audio Codec device */
    370471struct snd_soc_codec {
    371         char *name;
    372         struct module *owner;
     472        const char *name;
     473        const char *name_prefix;
     474        int id;
     475        struct device *dev;
     476        const struct snd_soc_codec_driver *driver;
     477
    373478        struct mutex mutex;
    374         struct device *dev;
    375         struct snd_soc_device *socdev;
    376 
     479        struct snd_soc_card *card;
    377480        struct list_head list;
    378 
    379         /* callbacks */
    380         int (*set_bias_level)(struct snd_soc_codec *,
    381                               enum snd_soc_bias_level level);
     481        struct list_head card_list;
     482        int num_dai;
     483        enum snd_soc_compress_type compress_type;
     484        size_t reg_size;        /* reg_cache_size * reg_word_size */
     485        int (*volatile_register)(struct snd_soc_codec *, unsigned int);
     486        int (*readable_register)(struct snd_soc_codec *, unsigned int);
    382487
    383488        /* runtime */
    384         struct snd_card *card;
    385489        struct snd_ac97 *ac97;  /* for ad-hoc ac97 devices */
    386490        unsigned int active;
    387         unsigned int pcm_devs;
    388         void *private_data;
     491        unsigned int cache_only:1;  /* Suppress writes to hardware */
     492        unsigned int cache_sync:1; /* Cache needs to be synced to hardware */
     493        unsigned int suspended:1; /* Codec is in suspend PM state */
     494        unsigned int probed:1; /* Codec has been probed */
     495        unsigned int ac97_registered:1; /* Codec has been AC97 registered */
     496        unsigned int ac97_created:1; /* Codec has been created by SoC */
     497        unsigned int sysfs_registered:1; /* codec has been sysfs registered */
     498        unsigned int cache_init:1; /* codec cache has been initialized */
    389499
    390500        /* codec IO */
    391501        void *control_data; /* codec control (i2c/3wire) data */
     502        hw_write_t hw_write;
     503        unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
     504        unsigned int (*read)(struct snd_soc_codec *, unsigned int);
     505        int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
     506        void *reg_cache;
     507        const void *reg_def_copy;
     508        const struct snd_soc_cache_ops *cache_ops;
     509        struct mutex cache_rw_mutex;
     510
     511        /* dapm */
     512        struct snd_soc_dapm_context dapm;
     513
     514#ifdef CONFIG_DEBUG_FS
     515        struct dentry *debugfs_codec_root;
     516        struct dentry *debugfs_reg;
     517        struct dentry *debugfs_dapm;
     518#endif
     519};
     520
     521/* codec driver */
     522struct snd_soc_codec_driver {
     523
     524        /* driver ops */
     525        int (*probe)(struct snd_soc_codec *);
     526        int (*remove)(struct snd_soc_codec *);
     527        int (*suspend)(struct snd_soc_codec *,
     528                        pm_message_t state);
     529        int (*resume)(struct snd_soc_codec *);
     530
     531        /* codec IO */
    392532        unsigned int (*read)(struct snd_soc_codec *, unsigned int);
    393533        int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
    394534        int (*display_register)(struct snd_soc_codec *, char *,
    395535                                size_t, unsigned int);
    396         int (*volatile_register)(unsigned int);
    397         int (*readable_register)(unsigned int);
    398         hw_write_t hw_write;
    399         unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
    400         void *reg_cache;
     536        int (*volatile_register)(struct snd_soc_codec *, unsigned int);
     537        int (*readable_register)(struct snd_soc_codec *, unsigned int);
    401538        short reg_cache_size;
    402539        short reg_cache_step;
    403 
    404         /* dapm */
    405         u32 pop_time;
    406         struct list_head dapm_widgets;
    407         struct list_head dapm_paths;
    408         enum snd_soc_bias_level bias_level;
    409         enum snd_soc_bias_level suspend_bias_level;
    410         struct delayed_work delayed_work;
    411 
    412         /* codec DAI's */
    413         struct snd_soc_dai *dai;
    414         unsigned int num_dai;
    415 
    416 #ifdef CONFIG_DEBUG_FS
    417         struct dentry *debugfs_reg;
    418         struct dentry *debugfs_pop_time;
    419         struct dentry *debugfs_dapm;
    420 #endif
    421 };
    422 
    423 /* codec device */
    424 struct snd_soc_codec_device {
    425         int (*probe)(struct platform_device *pdev);
    426         int (*remove)(struct platform_device *pdev);
    427         int (*suspend)(struct platform_device *pdev, pm_message_t state);
    428         int (*resume)(struct platform_device *pdev);
     540        short reg_word_size;
     541        const void *reg_cache_default;
     542        short reg_access_size;
     543        const struct snd_soc_reg_access *reg_access_default;
     544        enum snd_soc_compress_type compress_type;
     545
     546        /* codec bias level */
     547        int (*set_bias_level)(struct snd_soc_codec *,
     548                              enum snd_soc_bias_level level);
    429549};
    430550
    431551/* SoC platform interface */
    432 struct snd_soc_platform {
    433         char *name;
    434         struct list_head list;
    435 
    436         int (*probe)(struct platform_device *pdev);
    437         int (*remove)(struct platform_device *pdev);
     552struct snd_soc_platform_driver {
     553
     554        int (*probe)(struct snd_soc_platform *);
     555        int (*remove)(struct snd_soc_platform *);
    438556        int (*suspend)(struct snd_soc_dai *dai);
    439557        int (*resume)(struct snd_soc_dai *dai);
     
    444562        void (*pcm_free)(struct snd_pcm *);
    445563
     564        /*
     565         * For platform caused delay reporting.
     566         * Optional.
     567         */
     568        snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
     569                struct snd_soc_dai *);
     570
    446571        /* platform stream ops */
    447         struct snd_pcm_ops *pcm_ops;
    448 };
    449 
    450 /* SoC machine DAI configuration, glues a codec and cpu DAI together */
    451 struct snd_soc_dai_link  {
    452         char *name;                     /* Codec name */
    453         char *stream_name;              /* Stream name */
    454 
    455         /* DAI */
    456         struct snd_soc_dai *codec_dai;
    457         struct snd_soc_dai *cpu_dai;
     572        struct snd_pcm_ops *ops;
     573};
     574
     575struct snd_soc_platform {
     576        const char *name;
     577        int id;
     578        struct device *dev;
     579        struct snd_soc_platform_driver *driver;
     580
     581        unsigned int suspended:1; /* platform is suspended */
     582        unsigned int probed:1;
     583
     584        struct snd_soc_card *card;
     585        struct list_head list;
     586        struct list_head card_list;
     587};
     588
     589struct snd_soc_dai_link {
     590        /* config - must be set by machine driver */
     591        const char *name;                       /* Codec name */
     592        const char *stream_name;                /* Stream name */
     593        const char *codec_name;         /* for multi-codec */
     594        const char *platform_name;      /* for multi-platform */
     595        const char *cpu_dai_name;
     596        const char *codec_dai_name;
     597
     598        /* Keep DAI active over suspend */
     599        unsigned int ignore_suspend:1;
     600
     601        /* Symmetry requirements */
     602        unsigned int symmetric_rates:1;
     603
     604        /* codec/machine specific init - e.g. add machine controls */
     605        int (*init)(struct snd_soc_pcm_runtime *rtd);
    458606
    459607        /* machine stream operations */
    460608        struct snd_soc_ops *ops;
     609};
     610
     611struct snd_soc_codec_conf {
     612        const char *dev_name;
     613
     614        /*
     615         * optional map of kcontrol, widget and path name prefixes that are
     616         * associated per device
     617         */
     618        const char *name_prefix;
     619
     620        /*
     621         * set this to the desired compression type if you want to
     622         * override the one supplied in codec->driver->compress_type
     623         */
     624        enum snd_soc_compress_type compress_type;
     625};
     626
     627struct snd_soc_aux_dev {
     628        const char *name;               /* Codec name */
     629        const char *codec_name;         /* for multi-codec */
    461630
    462631        /* codec/machine specific init - e.g. add machine controls */
    463         int (*init)(struct snd_soc_codec *codec);
    464 
    465         /* Symmetry requirements */
    466         unsigned int symmetric_rates:1;
    467 
    468         /* Symmetry data - only valid if symmetry is being enforced */
    469         unsigned int rate;
    470 
    471         /* DAI pcm */
    472         struct snd_pcm *pcm;
     632        int (*init)(struct snd_soc_dapm_context *dapm);
    473633};
    474634
    475635/* SoC card */
    476636struct snd_soc_card {
    477         char *name;
     637        const char *name;
    478638        struct device *dev;
     639        struct snd_card *snd_card;
     640        struct module *owner;
    479641
    480642        struct list_head list;
    481 
    482         int instantiated;
     643        struct mutex mutex;
     644
     645        bool instantiated;
    483646
    484647        int (*probe)(struct platform_device *pdev);
     
    495658        int (*set_bias_level)(struct snd_soc_card *,
    496659                              enum snd_soc_bias_level level);
     660        int (*set_bias_level_post)(struct snd_soc_card *,
     661                                   enum snd_soc_bias_level level);
     662
     663        long pmdown_time;
    497664
    498665        /* CPU <--> Codec DAI links  */
    499666        struct snd_soc_dai_link *dai_link;
    500667        int num_links;
    501 
    502         struct snd_soc_device *socdev;
    503 
     668        struct snd_soc_pcm_runtime *rtd;
     669        int num_rtd;
     670
     671        /* optional codec specific configuration */
     672        struct snd_soc_codec_conf *codec_conf;
     673        int num_configs;
     674
     675        /*
     676         * optional auxiliary devices such as amplifiers or codecs with DAI
     677         * link unused
     678         */
     679        struct snd_soc_aux_dev *aux_dev;
     680        int num_aux_devs;
     681        struct snd_soc_pcm_runtime *rtd_aux;
     682        int num_aux_rtd;
     683
     684        struct work_struct deferred_resume_work;
     685
     686        /* lists of probed devices belonging to this card */
     687        struct list_head codec_dev_list;
     688        struct list_head platform_dev_list;
     689        struct list_head dai_dev_list;
     690
     691        struct list_head widgets;
     692        struct list_head paths;
     693        struct list_head dapm_list;
     694
     695#ifdef CONFIG_DEBUG_FS
     696        struct dentry *debugfs_card_root;
     697        struct dentry *debugfs_pop_time;
     698#endif
     699        u32 pop_time;
     700};
     701
     702/* SoC machine DAI configuration, glues a codec and cpu DAI together */
     703struct snd_soc_pcm_runtime  {
     704        struct device dev;
     705        struct snd_soc_card *card;
     706        struct snd_soc_dai_link *dai_link;
     707
     708        unsigned int complete:1;
     709        unsigned int dev_registered:1;
     710
     711        /* Symmetry data - only valid if symmetry is being enforced */
     712        unsigned int rate;
     713        long pmdown_time;
     714
     715        /* runtime devices */
     716        struct snd_pcm *pcm;
    504717        struct snd_soc_codec *codec;
    505 
    506718        struct snd_soc_platform *platform;
     719        struct snd_soc_dai *codec_dai;
     720        struct snd_soc_dai *cpu_dai;
     721
    507722        struct delayed_work delayed_work;
    508         struct work_struct deferred_resume_work;
    509 };
    510 
    511 /* SoC Device - the audio subsystem */
    512 struct snd_soc_device {
    513         struct device *dev;
    514         struct snd_soc_card *card;
    515         struct snd_soc_codec_device *codec_dev;
    516         void *codec_data;
    517 };
    518 
    519 /* runtime channel data */
    520 struct snd_soc_pcm_runtime {
    521         struct snd_soc_dai_link *dai;
    522         struct snd_soc_device *socdev;
    523723};
    524724
    525725/* mixer control */
    526726struct soc_mixer_control {
    527         int min, max;
     727        int min, max, platform_max;
    528728        unsigned int reg, rreg, shift, rshift, invert;
    529729};
     
    543743
    544744/* codec IO */
    545 static inline unsigned int snd_soc_read(struct snd_soc_codec *codec,
    546                                         unsigned int reg)
     745unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
     746unsigned int snd_soc_write(struct snd_soc_codec *codec,
     747                           unsigned int reg, unsigned int val);
     748
     749/* device driver data */
     750
     751static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
     752                void *data)
    547753{
    548         return codec->read(codec, reg);
     754        dev_set_drvdata(codec->dev, data);
    549755}
    550756
    551 static inline unsigned int snd_soc_write(struct snd_soc_codec *codec,
    552                                          unsigned int reg, unsigned int val)
     757static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
    553758{
    554         return codec->write(codec, reg, val);
     759        return dev_get_drvdata(codec->dev);
    555760}
    556761
     762static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
     763                void *data)
     764{
     765        dev_set_drvdata(platform->dev, data);
     766}
     767
     768static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform)
     769{
     770        return dev_get_drvdata(platform->dev);
     771}
     772
     773static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
     774                void *data)
     775{
     776        dev_set_drvdata(&rtd->dev, data);
     777}
     778
     779static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
     780{
     781        return dev_get_drvdata(&rtd->dev);
     782}
     783
     784static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
     785{
     786        INIT_LIST_HEAD(&card->dai_dev_list);
     787        INIT_LIST_HEAD(&card->codec_dev_list);
     788        INIT_LIST_HEAD(&card->platform_dev_list);
     789        INIT_LIST_HEAD(&card->widgets);
     790        INIT_LIST_HEAD(&card->paths);
     791        INIT_LIST_HEAD(&card->dapm_list);
     792}
     793
    557794#include <sound/soc-dai.h>
    558795
     796#ifdef CONFIG_DEBUG_FS
     797extern struct dentry *snd_soc_debugfs_root;
    559798#endif
     799
     800#endif
Note: See TracChangeset for help on using the changeset viewer.