ASoC: Intel: Skylake: Update to use instance ids generated
[cascardo/linux.git] / sound / soc / intel / skylake / skl-messages.c
index 44ab595..805b7f2 100644 (file)
@@ -203,32 +203,35 @@ static const struct skl_dsp_ops dsp_ops[] = {
                .id = 0x9d70,
                .loader_ops = skl_get_loader_ops,
                .init = skl_sst_dsp_init,
+               .init_fw = skl_sst_init_fw,
                .cleanup = skl_sst_dsp_cleanup
        },
        {
                .id = 0x9d71,
                .loader_ops = skl_get_loader_ops,
                .init = skl_sst_dsp_init,
+               .init_fw = skl_sst_init_fw,
                .cleanup = skl_sst_dsp_cleanup
        },
        {
                .id = 0x5a98,
                .loader_ops = bxt_get_loader_ops,
                .init = bxt_sst_dsp_init,
+               .init_fw = bxt_sst_init_fw,
                .cleanup = bxt_sst_dsp_cleanup
        },
 };
 
-static int skl_get_dsp_ops(int pci_id)
+const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id)
 {
        int i;
 
        for (i = 0; i < ARRAY_SIZE(dsp_ops); i++) {
                if (dsp_ops[i].id == pci_id)
-                       return i;
+                       return &dsp_ops[i];
        }
 
-       return -EINVAL;
+       return NULL;
 }
 
 int skl_init_dsp(struct skl *skl)
@@ -238,7 +241,8 @@ int skl_init_dsp(struct skl *skl)
        struct hdac_bus *bus = ebus_to_hbus(ebus);
        struct skl_dsp_loader_ops loader_ops;
        int irq = bus->irq;
-       int ret, index;
+       const struct skl_dsp_ops *ops;
+       int ret;
 
        /* enable ppcap interrupt */
        snd_hdac_ext_bus_ppcap_enable(&skl->ebus, true);
@@ -251,18 +255,18 @@ int skl_init_dsp(struct skl *skl)
                return -ENXIO;
        }
 
-       index  = skl_get_dsp_ops(skl->pci->device);
-       if (index  < 0)
-               return -EINVAL;
+       ops = skl_get_dsp_ops(skl->pci->device);
+       if (!ops)
+               return -EIO;
 
-       loader_ops = dsp_ops[index].loader_ops();
-       ret = dsp_ops[index].init(bus->dev, mmio_base, irq,
-                       skl->fw_name, loader_ops, &skl->skl_sst);
+       loader_ops = ops->loader_ops();
+       ret = ops->init(bus->dev, mmio_base, irq,
+                               skl->fw_name, loader_ops,
+                               &skl->skl_sst);
 
        if (ret < 0)
                return ret;
 
-       skl_dsp_enable_notification(skl->skl_sst, false);
        dev_dbg(bus->dev, "dsp registration status=%d\n", ret);
 
        return ret;
@@ -273,16 +277,16 @@ int skl_free_dsp(struct skl *skl)
        struct hdac_ext_bus *ebus = &skl->ebus;
        struct hdac_bus *bus = ebus_to_hbus(ebus);
        struct skl_sst *ctx = skl->skl_sst;
-       int index;
+       const struct skl_dsp_ops *ops;
 
        /* disable  ppcap interrupt */
        snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, false);
 
-       index = skl_get_dsp_ops(skl->pci->device);
-       if (index  < 0)
+       ops = skl_get_dsp_ops(skl->pci->device);
+       if (!ops)
                return -EIO;
 
-       dsp_ops[index].cleanup(bus->dev, ctx);
+       ops->cleanup(bus->dev, ctx);
 
        if (ctx->dsp->addr.lpe)
                iounmap(ctx->dsp->addr.lpe);
@@ -296,7 +300,7 @@ int skl_suspend_dsp(struct skl *skl)
        int ret;
 
        /* if ppcap is not supported return 0 */
-       if (!skl->ebus.ppcap)
+       if (!skl->ebus.bus.ppcap)
                return 0;
 
        ret = skl_dsp_sleep(ctx->dsp);
@@ -316,13 +320,17 @@ int skl_resume_dsp(struct skl *skl)
        int ret;
 
        /* if ppcap is not supported return 0 */
-       if (!skl->ebus.ppcap)
+       if (!skl->ebus.bus.ppcap)
                return 0;
 
        /* enable ppcap interrupt */
        snd_hdac_ext_bus_ppcap_enable(&skl->ebus, true);
        snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, true);
 
+       /* check if DSP 1st boot is done */
+       if (skl->skl_sst->is_first_boot == true)
+               return 0;
+
        ret = skl_dsp_wake(ctx->dsp);
        if (ret < 0)
                return ret;
@@ -672,6 +680,7 @@ static u16 skl_get_module_param_size(struct skl_sst *ctx,
                return param_size;
 
        case SKL_MODULE_TYPE_BASE_OUTFMT:
+       case SKL_MODULE_TYPE_KPB:
                return sizeof(struct skl_base_outfmt_cfg);
 
        default:
@@ -725,6 +734,7 @@ static int skl_set_module_format(struct skl_sst *ctx,
                break;
 
        case SKL_MODULE_TYPE_BASE_OUTFMT:
+       case SKL_MODULE_TYPE_KPB:
                skl_set_base_outfmt_format(ctx, module_config, *param_data);
                break;
 
@@ -779,6 +789,7 @@ static int skl_alloc_queue(struct skl_module_pin *mpin,
                                mpin[i].in_use = true;
                                mpin[i].id.module_id = id.module_id;
                                mpin[i].id.instance_id = id.instance_id;
+                               mpin[i].id.pvt_id = id.pvt_id;
                                mpin[i].tgt_mcfg = tgt_cfg;
                                return i;
                        }
@@ -802,6 +813,7 @@ static void skl_free_queue(struct skl_module_pin *mpin, int q_index)
                mpin[q_index].in_use = false;
                mpin[q_index].id.module_id = 0;
                mpin[q_index].id.instance_id = 0;
+               mpin[q_index].id.pvt_id = 0;
        }
        mpin[q_index].pin_state = SKL_PIN_UNBIND;
        mpin[q_index].tgt_mcfg = NULL;
@@ -842,7 +854,7 @@ int skl_init_module(struct skl_sst *ctx,
        struct skl_ipc_init_instance_msg msg;
 
        dev_dbg(ctx->dev, "%s: module_id = %d instance=%d\n", __func__,
-                mconfig->id.module_id, mconfig->id.instance_id);
+                mconfig->id.module_id, mconfig->id.pvt_id);
 
        if (mconfig->pipe->state != SKL_PIPE_CREATED) {
                dev_err(ctx->dev, "Pipe not created state= %d pipe_id= %d\n",
@@ -858,10 +870,11 @@ int skl_init_module(struct skl_sst *ctx,
        }
 
        msg.module_id = mconfig->id.module_id;
-       msg.instance_id = mconfig->id.instance_id;
+       msg.instance_id = mconfig->id.pvt_id;
        msg.ppl_instance_id = mconfig->pipe->ppl_id;
        msg.param_data_size = module_config_size;
        msg.core_id = mconfig->core_id;
+       msg.domain = mconfig->domain;
 
        ret = skl_ipc_init_instance(&ctx->ipc, &msg, param_data);
        if (ret < 0) {
@@ -878,9 +891,9 @@ static void skl_dump_bind_info(struct skl_sst *ctx, struct skl_module_cfg
        *src_module, struct skl_module_cfg *dst_module)
 {
        dev_dbg(ctx->dev, "%s: src module_id = %d  src_instance=%d\n",
-               __func__, src_module->id.module_id, src_module->id.instance_id);
+               __func__, src_module->id.module_id, src_module->id.pvt_id);
        dev_dbg(ctx->dev, "%s: dst_module=%d dst_instacne=%d\n", __func__,
-                dst_module->id.module_id, dst_module->id.instance_id);
+                dst_module->id.module_id, dst_module->id.pvt_id);
 
        dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n",
                src_module->m_state, dst_module->m_state);
@@ -927,9 +940,9 @@ int skl_unbind_modules(struct skl_sst *ctx,
                return 0;
 
        msg.module_id = src_mcfg->id.module_id;
-       msg.instance_id = src_mcfg->id.instance_id;
+       msg.instance_id = src_mcfg->id.pvt_id;
        msg.dst_module_id = dst_mcfg->id.module_id;
-       msg.dst_instance_id = dst_mcfg->id.instance_id;
+       msg.dst_instance_id = dst_mcfg->id.pvt_id;
        msg.bind = false;
 
        ret = skl_ipc_bind_unbind(&ctx->ipc, &msg);
@@ -988,9 +1001,9 @@ int skl_bind_modules(struct skl_sst *ctx,
                         msg.src_queue, msg.dst_queue);
 
        msg.module_id = src_mcfg->id.module_id;
-       msg.instance_id = src_mcfg->id.instance_id;
+       msg.instance_id = src_mcfg->id.pvt_id;
        msg.dst_module_id = dst_mcfg->id.module_id;
-       msg.dst_instance_id = dst_mcfg->id.instance_id;
+       msg.dst_instance_id = dst_mcfg->id.pvt_id;
        msg.bind = true;
 
        ret = skl_ipc_bind_unbind(&ctx->ipc, &msg);
@@ -1168,7 +1181,7 @@ int skl_set_module_params(struct skl_sst *ctx, u32 *params, int size,
        struct skl_ipc_large_config_msg msg;
 
        msg.module_id = mcfg->id.module_id;
-       msg.instance_id = mcfg->id.instance_id;
+       msg.instance_id = mcfg->id.pvt_id;
        msg.param_data_size = size;
        msg.large_param_id = param_id;
 
@@ -1181,7 +1194,7 @@ int skl_get_module_params(struct skl_sst *ctx, u32 *params, int size,
        struct skl_ipc_large_config_msg msg;
 
        msg.module_id = mcfg->id.module_id;
-       msg.instance_id = mcfg->id.instance_id;
+       msg.instance_id = mcfg->id.pvt_id;
        msg.param_data_size = size;
        msg.large_param_id = param_id;