ALSA: hda/tas2781: select program 0, conf 0 by default
[platform/kernel/linux-rpi.git] / sound / pci / hda / tas2781_hda_i2c.c
index fb80280..2fb1a70 100644 (file)
@@ -455,9 +455,9 @@ static int tas2781_save_calibration(struct tasdevice_priv *tas_priv)
                status = efi.get_variable(efi_name, &efi_guid, &attr,
                        &tas_priv->cali_data.total_sz,
                        tas_priv->cali_data.data);
-               if (status != EFI_SUCCESS)
-                       return -EINVAL;
        }
+       if (status != EFI_SUCCESS)
+               return -EINVAL;
 
        tmp_val = (unsigned int *)tas_priv->cali_data.data;
 
@@ -543,6 +543,10 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)
 
        tas_priv->fw_state = TASDEVICE_DSP_FW_ALL_OK;
        tasdevice_prmg_load(tas_priv, 0);
+       if (tas_priv->fmw->nr_programs > 0)
+               tas_priv->cur_prog = 0;
+       if (tas_priv->fmw->nr_configurations > 0)
+               tas_priv->cur_conf = 0;
 
        /* If calibrated data occurs error, dsp will still works with default
         * calibrated data inside algo.
@@ -550,11 +554,6 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)
        tas2781_save_calibration(tas_priv);
 
 out:
-       if (tas_priv->fw_state == TASDEVICE_DSP_FW_FAIL) {
-               /*If DSP FW fail, kcontrol won't be created */
-               tasdevice_config_info_remove(tas_priv);
-               tasdevice_dsp_remove(tas_priv);
-       }
        mutex_unlock(&tas_priv->codec_lock);
        if (fmw)
                release_firmware(fmw);
@@ -612,9 +611,13 @@ static void tas2781_hda_unbind(struct device *dev,
 {
        struct tasdevice_priv *tas_priv = dev_get_drvdata(dev);
        struct hda_component *comps = master_data;
+       comps = &comps[tas_priv->index];
 
-       if (comps[tas_priv->index].dev == dev)
-               memset(&comps[tas_priv->index], 0, sizeof(*comps));
+       if (comps->dev == dev) {
+               comps->dev = NULL;
+               memset(comps->name, 0, sizeof(comps->name));
+               comps->playback_hook = NULL;
+       }
 
        tasdevice_config_info_remove(tas_priv);
        tasdevice_dsp_remove(tas_priv);
@@ -675,14 +678,14 @@ static int tas2781_hda_i2c_probe(struct i2c_client *clt)
 
        pm_runtime_put_autosuspend(tas_priv->dev);
 
+       tas2781_reset(tas_priv);
+
        ret = component_add(tas_priv->dev, &tas2781_hda_comp_ops);
        if (ret) {
                dev_err(tas_priv->dev, "Register component failed: %d\n", ret);
                pm_runtime_disable(tas_priv->dev);
-               goto err;
        }
 
-       tas2781_reset(tas_priv);
 err:
        if (ret)
                tas2781_hda_remove(&clt->dev);