static int sst_platform_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime; struct sst_runtime_stream *stream; int ret_val = 0; pr_debug("sst_platform_open called\n"); runtime = substream->runtime; runtime->hw = sst_platform_pcm_hw; stream = kzalloc(sizeof(*stream), GFP_KERNEL); if (!stream) return -ENOMEM; spin_lock_init(&stream->status_lock); stream->stream_info.str_id = 0; sst_set_stream_status(stream, SST_PLATFORM_INIT); stream->stream_info.mad_substream = substream; /* allocate memory for SST API set */ stream->sstdrv_ops = kzalloc(sizeof(*stream->sstdrv_ops), GFP_KERNEL); if (!stream->sstdrv_ops) { pr_err("sst: mem allocation for ops fail\n"); kfree(stream); return -ENOMEM; } stream->sstdrv_ops->vendor_id = MSIC_VENDOR_ID; /* registering with SST driver to get access to SST APIs to use */ ret_val = register_sst_card(stream->sstdrv_ops); if (ret_val) { pr_err("sst: sst card registration failed\n"); return ret_val; } runtime->private_data = stream; return snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); }
static int __devinit snd_intelmad_sst_register( struct snd_intelmad *intelmaddata) { int ret_val = 0; struct snd_pmic_ops *intelmad_vendor_ops[MAX_VENDORS] = { &snd_pmic_ops_fs, &snd_pmic_ops_mx, &snd_pmic_ops_nc, &snd_msic_ops }; struct sc_reg_access vendor_addr = {0x00, 0x00, 0x00}; if (intelmaddata->cpu_id == CPU_CHIP_LINCROFT) { ret_val = sst_sc_reg_access(&vendor_addr, PMIC_READ, 1); if (ret_val) return ret_val; sst_card_vendor_id = (vendor_addr.value & (MASK2|MASK1|MASK0)); pr_debug("original n extrated vendor id = 0x%x %d\n", vendor_addr.value, sst_card_vendor_id); if (sst_card_vendor_id < 0 || sst_card_vendor_id > 2) { pr_err("vendor card not supported!!\n"); return -EIO; } } else sst_card_vendor_id = 0x3; intelmaddata->sstdrv_ops->module_name = SST_CARD_NAMES; intelmaddata->sstdrv_ops->vendor_id = sst_card_vendor_id; BUG_ON(!intelmad_vendor_ops[sst_card_vendor_id]); intelmaddata->sstdrv_ops->scard_ops = intelmad_vendor_ops[sst_card_vendor_id]; if (intelmaddata->cpu_id == CPU_CHIP_PENWELL) { intelmaddata->sstdrv_ops->scard_ops->pb_on = 0; intelmaddata->sstdrv_ops->scard_ops->cap_on = 0; intelmaddata->sstdrv_ops->scard_ops->input_dev_id = DMIC; intelmaddata->sstdrv_ops->scard_ops->output_dev_id = STEREO_HEADPHONE; intelmaddata->sstdrv_ops->scard_ops->lineout_dev_id = NONE; } /* registering with SST driver to get access to SST APIs to use */ ret_val = register_sst_card(intelmaddata->sstdrv_ops); if (ret_val) { pr_err("sst card registration failed\n"); return ret_val; } sst_card_vendor_id = intelmaddata->sstdrv_ops->vendor_id; intelmaddata->pmic_status = PMIC_UNINIT; return ret_val; }