Merge remote-tracking branches 'asoc/topic/cs42l73', 'asoc/topic/dai' and 'asoc/topic...
authorMark Brown <broonie@kernel.org>
Mon, 9 Feb 2015 07:10:14 +0000 (15:10 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 9 Feb 2015 07:10:14 +0000 (15:10 +0800)
1  2  3  4 
include/sound/soc.h
sound/soc/atmel/sam9g20_wm8731.c
sound/soc/soc-core.c

diff --combined include/sound/soc.h
index ac8b333acb4dd721596db8ddf9bf7fcbc7ab6c1d,b4fca9aed2a2b00296ce040428b830b93095d562,edd4a0a11ccf2a980779530e25ab642eb4972524,b4fca9aed2a2b00296ce040428b830b93095d562..0d1ade19562857c7b65157636ac37b2f0222e202
@@@@@ -429,6 -429,6 -429,9 -429,6 +429,9 @@@@@ bool snd_soc_runtime_ignore_pmdown_time
    void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream);
    void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);
    
++ +int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
++ +    unsigned int dai_fmt);
++ +
    /* Utility functions to get clock rates from various things */
    int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
    int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
@@@@@ -498,7 -498,6 -501,6 -498,6 +501,7 @@@@@ int snd_soc_test_bits(struct snd_soc_co
                                unsigned int mask, unsigned int value);
    
    #ifdef CONFIG_SND_SOC_AC97_BUS
 +++struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec);
    struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec);
    void snd_soc_free_ac97_codec(struct snd_ac97 *ac97);
    
index 531728975bbbf9b5c5e0f2a8b4e2a0dbf1751da4,66b66d0e751474358f6eff03d0a2ae897dddc1ad,98ca6341147b3da79a907c65a595341c412dcf06,66b66d0e751474358f6eff03d0a2ae897dddc1ad..f5ad214663f98b4dbbdc3c2a4180d6142d09688c
    #include <sound/soc.h>
    
    #include <asm/mach-types.h>
 ---#include <mach/hardware.h>
    
    #include "../codecs/wm8731.h"
    #include "atmel-pcm.h"
    
    static struct clk *mclk;
    
-- -static int at91sam9g20ek_hw_params(struct snd_pcm_substream *substream,
-- -    struct snd_pcm_hw_params *params)
-- -{
-- -    struct snd_soc_pcm_runtime *rtd = substream->private_data;
-- -    struct snd_soc_dai *codec_dai = rtd->codec_dai;
-- -    struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-- -    int ret;
-- -
-- -    /* set codec DAI configuration */
-- -    ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-- -            SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-- -    if (ret < 0)
-- -            return ret;
-- -
-- -    /* set cpu DAI configuration */
-- -    ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-- -            SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-- -    if (ret < 0)
-- -            return ret;
-- -
-- -    return 0;
-- -}
-- -
-- -static struct snd_soc_ops at91sam9g20ek_ops = {
-- -    .hw_params = at91sam9g20ek_hw_params,
-- -};
-- -
    static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card,
                                        struct snd_soc_dapm_context *dapm,
                                        enum snd_soc_bias_level level)
@@@@@ -172,7 -173,7 -146,8 -173,7 +145,8 @@@@@ static struct snd_soc_dai_link at91sam9
        .init = at91sam9g20ek_wm8731_init,
        .platform_name = "at91rm9200_ssc.0",
        .codec_name = "wm8731.0-001b",
-- -    .ops = &at91sam9g20ek_ops,
++ +    .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
++ +               SND_SOC_DAIFMT_CBM_CFM,
    };
    
    static struct snd_soc_card snd_soc_at91sam9g20ek = {
diff --combined sound/soc/soc-core.c
index 9f6641bc1e173800685afc58c33663d61594fcca,985052b3fbed375dee764a64b63852998532d5e2,d342ee2ce28bc40b78996c203ec07a5287f01189,985052b3fbed375dee764a64b63852998532d5e2..678823d2e14af7ac6aa7e45f177c350b86aa0ad3
@@@@@ -191,39 -191,6 -191,6 -191,6 +191,39 @@@@@ static ssize_t pmdown_time_set(struct d
    
    static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set);
    
 +++static struct attribute *soc_dev_attrs[] = {
 +++    &dev_attr_codec_reg.attr,
 +++    &dev_attr_pmdown_time.attr,
 +++    NULL
 +++};
 +++
 +++static umode_t soc_dev_attr_is_visible(struct kobject *kobj,
 +++                                   struct attribute *attr, int idx)
 +++{
 +++    struct device *dev = kobj_to_dev(kobj);
 +++    struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
 +++
 +++    if (attr == &dev_attr_pmdown_time.attr)
 +++            return attr->mode; /* always visible */
 +++    return rtd->codec ? attr->mode : 0; /* enabled only with codec */
 +++}
 +++
 +++static const struct attribute_group soc_dapm_dev_group = {
 +++    .attrs = soc_dapm_dev_attrs,
 +++    .is_visible = soc_dev_attr_is_visible,
 +++};
 +++
 +++static const struct attribute_group soc_dev_roup = {
 +++    .attrs = soc_dev_attrs,
 +++    .is_visible = soc_dev_attr_is_visible,
 +++};
 +++
 +++static const struct attribute_group *soc_dev_attr_groups[] = {
 +++    &soc_dapm_dev_group,
 +++    &soc_dev_roup,
 +++    NULL
 +++};
 +++
    #ifdef CONFIG_DEBUG_FS
    static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf,
                                   size_t count, loff_t *ppos)
@@@@@ -982,6 -949,8 -949,8 -949,8 +982,6 @@@@@ static void soc_remove_link_dais(struc
    
        /* unregister the rtd device */
        if (rtd->dev_registered) {
 ---            device_remove_file(rtd->dev, &dev_attr_pmdown_time);
 ---            device_remove_file(rtd->dev, &dev_attr_codec_reg);
                device_unregister(rtd->dev);
                rtd->dev_registered = 0;
        }
@@@@@ -1151,7 -1120,6 -1120,6 -1120,6 +1151,7 @@@@@ static int soc_post_component_init(stru
        device_initialize(rtd->dev);
        rtd->dev->parent = rtd->card->dev;
        rtd->dev->release = rtd_release;
 +++    rtd->dev->groups = soc_dev_attr_groups;
        dev_set_name(rtd->dev, "%s", name);
        dev_set_drvdata(rtd->dev, rtd);
        mutex_init(&rtd->pcm_mutex);
                return ret;
        }
        rtd->dev_registered = 1;
 ---
 ---    if (rtd->codec) {
 ---            /* add DAPM sysfs entries for this codec */
 ---            ret = snd_soc_dapm_sys_add(rtd->dev);
 ---            if (ret < 0)
 ---                    dev_err(rtd->dev,
 ---                            "ASoC: failed to add codec dapm sysfs entries: %d\n",
 ---                            ret);
 ---
 ---            /* add codec sysfs entries */
 ---            ret = device_create_file(rtd->dev, &dev_attr_codec_reg);
 ---            if (ret < 0)
 ---                    dev_err(rtd->dev,
 ---                            "ASoC: failed to add codec sysfs files: %d\n",
 ---                            ret);
 ---    }
 ---
        return 0;
    }
    
@@@@@ -1323,6 -1308,11 -1308,11 -1308,11 +1323,6 @@@@@ static int soc_probe_link_dais(struct s
        }
    #endif
    
 ---    ret = device_create_file(rtd->dev, &dev_attr_pmdown_time);
 ---    if (ret < 0)
 ---            dev_warn(rtd->dev, "ASoC: failed to add pmdown_time sysfs: %d\n",
 ---                    ret);
 ---
        if (cpu_dai->driver->compress_dai) {
                /*create compress_device"*/
                ret = soc_new_compress(rtd, num);
@@@@@ -1437,11 -1427,11 -1427,76 -1427,11 +1437,76 @@@@@ static int snd_soc_init_codec_cache(str
        return 0;
    }
    
++ +/**
++ + * snd_soc_runtime_set_dai_fmt() - Change DAI link format for a ASoC runtime
++ + * @rtd: The runtime for which the DAI link format should be changed
++ + * @dai_fmt: The new DAI link format
++ + *
++ + * This function updates the DAI link format for all DAIs connected to the DAI
++ + * link for the specified runtime.
++ + *
++ + * Note: For setups with a static format set the dai_fmt field in the
++ + * corresponding snd_dai_link struct instead of using this function.
++ + *
++ + * Returns 0 on success, otherwise a negative error code.
++ + */
++ +int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
++ +    unsigned int dai_fmt)
++ +{
++ +    struct snd_soc_dai **codec_dais = rtd->codec_dais;
++ +    struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
++ +    unsigned int i;
++ +    int ret;
++ +
++ +    for (i = 0; i < rtd->num_codecs; i++) {
++ +            struct snd_soc_dai *codec_dai = codec_dais[i];
++ +
++ +            ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
++ +            if (ret != 0 && ret != -ENOTSUPP) {
++ +                    dev_warn(codec_dai->dev,
++ +                             "ASoC: Failed to set DAI format: %d\n", ret);
++ +                    return ret;
++ +            }
++ +    }
++ +
++ +    /* Flip the polarity for the "CPU" end of a CODEC<->CODEC link */
++ +    if (cpu_dai->codec) {
++ +            unsigned int inv_dai_fmt;
++ +
++ +            inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_MASTER_MASK;
++ +            switch (dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) {
++ +            case SND_SOC_DAIFMT_CBM_CFM:
++ +                    inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
++ +                    break;
++ +            case SND_SOC_DAIFMT_CBM_CFS:
++ +                    inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
++ +                    break;
++ +            case SND_SOC_DAIFMT_CBS_CFM:
++ +                    inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
++ +                    break;
++ +            case SND_SOC_DAIFMT_CBS_CFS:
++ +                    inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
++ +                    break;
++ +            }
++ +
++ +            dai_fmt = inv_dai_fmt;
++ +    }
++ +
++ +    ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt);
++ +    if (ret != 0 && ret != -ENOTSUPP) {
++ +            dev_warn(cpu_dai->dev,
++ +                     "ASoC: Failed to set DAI format: %d\n", ret);
++ +            return ret;
++ +    }
++ +
++ +    return 0;
++ +}
++ +EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
++ +
    static int snd_soc_instantiate_card(struct snd_soc_card *card)
    {
        struct snd_soc_codec *codec;
-- -    struct snd_soc_dai_link *dai_link;
-- -    int ret, i, order, dai_fmt;
++ +    int ret, i, order;
    
        mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
    
                                        card->num_dapm_routes);
    
        for (i = 0; i < card->num_links; i++) {
-- -            struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
-- -            dai_link = &card->dai_link[i];
-- -            dai_fmt = dai_link->dai_fmt;
-- -
-- -            if (dai_fmt) {
-- -                    struct snd_soc_dai **codec_dais = rtd->codec_dais;
-- -                    int j;
-- -
-- -                    for (j = 0; j < rtd->num_codecs; j++) {
-- -                            struct snd_soc_dai *codec_dai = codec_dais[j];
-- -
-- -                            ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
-- -                            if (ret != 0 && ret != -ENOTSUPP)
-- -                                    dev_warn(codec_dai->dev,
-- -                                             "ASoC: Failed to set DAI format: %d\n",
-- -                                             ret);
-- -                    }
-- -            }
-- -
-- -            /* If this is a regular CPU link there will be a platform */
-- -            if (dai_fmt &&
-- -                (dai_link->platform_name || dai_link->platform_of_node)) {
-- -                    ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai,
-- -                                              dai_fmt);
-- -                    if (ret != 0 && ret != -ENOTSUPP)
-- -                            dev_warn(card->rtd[i].cpu_dai->dev,
-- -                                     "ASoC: Failed to set DAI format: %d\n",
-- -                                     ret);
-- -            } else if (dai_fmt) {
-- -                    /* Flip the polarity for the "CPU" end */
-- -                    dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
-- -                    switch (dai_link->dai_fmt &
-- -                            SND_SOC_DAIFMT_MASTER_MASK) {
-- -                    case SND_SOC_DAIFMT_CBM_CFM:
-- -                            dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
-- -                            break;
-- -                    case SND_SOC_DAIFMT_CBM_CFS:
-- -                            dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
-- -                            break;
-- -                    case SND_SOC_DAIFMT_CBS_CFM:
-- -                            dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
-- -                            break;
-- -                    case SND_SOC_DAIFMT_CBS_CFS:
-- -                            dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
-- -                            break;
-- -                    }
-- -
-- -                    ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai,
-- -                                              dai_fmt);
-- -                    if (ret != 0 && ret != -ENOTSUPP)
-- -                            dev_warn(card->rtd[i].cpu_dai->dev,
-- -                                     "ASoC: Failed to set DAI format: %d\n",
-- -                                     ret);
-- -            }
++ +            if (card->dai_link[i].dai_fmt)
++ +                    snd_soc_runtime_set_dai_fmt(&card->rtd[i],
++ +                            card->dai_link[i].dai_fmt);
        }
    
        snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
                }
        }
    
 ---    if (card->fully_routed)
 ---            snd_soc_dapm_auto_nc_pins(card);
 ---
        snd_soc_dapm_new_widgets(card);
    
        ret = snd_card_register(card->snd_card);
@@@@@ -2393,8 -2386,8 -2400,8 -2386,8 +2407,8 @@@@@ int snd_soc_unregister_card(struct snd_
                card->instantiated = false;
                snd_soc_dapm_shutdown(card);
                soc_cleanup_card_resources(card);
 +++            dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
        }
 ---    dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
    
        return 0;
    }
@@@@@ -3237,7 -3230,7 -3244,7 -3230,7 +3251,7 @@@@@ int snd_soc_of_parse_audio_routing(stru
                                   const char *propname)
    {
        struct device_node *np = card->dev->of_node;
 ---    int num_routes, old_routes;
 +++    int num_routes;
        struct snd_soc_dapm_route *routes;
        int i, ret;
    
                return -EINVAL;
        }
    
 ---    old_routes = card->num_dapm_routes;
 ---    routes = devm_kzalloc(card->dev,
 ---                          (old_routes + num_routes) * sizeof(*routes),
 +++    routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
                              GFP_KERNEL);
        if (!routes) {
                dev_err(card->dev,
                return -EINVAL;
        }
    
 ---    memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes));
 ---
        for (i = 0; i < num_routes; i++) {
                ret = of_property_read_string_index(np, propname,
 ---                    2 * i, &routes[old_routes + i].sink);
 +++                    2 * i, &routes[i].sink);
                if (ret) {
                        dev_err(card->dev,
                                "ASoC: Property '%s' index %d could not be read: %d\n",
                        return -EINVAL;
                }
                ret = of_property_read_string_index(np, propname,
 ---                    (2 * i) + 1, &routes[old_routes + i].source);
 +++                    (2 * i) + 1, &routes[i].source);
                if (ret) {
                        dev_err(card->dev,
                                "ASoC: Property '%s' index %d could not be read: %d\n",
                }
        }
    
 ---    card->num_dapm_routes += num_routes;
 +++    card->num_dapm_routes = num_routes;
        card->dapm_routes = routes;
    
        return 0;