Lines Matching +full:lower +full:- +full:cal

1 // SPDX-License-Identifier: GPL-2.0
3 // tas2781-fmwlib.c -- TASDEVICE firmware support
5 // Copyright 2023 - 2024 Texas Instruments, Inc.
7 // Author: Shenghao Ding <shenghao-ding@ti.com>
43 /*should not include B0_P53_R44-R47 */
158 * receiver, games, audio-to-haptics, PMIC record, bypass mode, in tasdevice_add_config()
161 * ultrasonic application. In order to support these variable-numbers in tasdevice_add_config()
167 *status = -ENOMEM; in tasdevice_add_config()
171 if (tas_priv->rcabin.fw_hdr.binary_version_num >= 0x105) { in tasdevice_add_config()
173 *status = -EINVAL; in tasdevice_add_config()
174 dev_err(tas_priv->dev, "add conf: Out of boundary\n"); in tasdevice_add_config()
181 *status = -EINVAL; in tasdevice_add_config()
182 dev_err(tas_priv->dev, "add config: Out of boundary\n"); in tasdevice_add_config()
189 cfg_info->nblocks = get_unaligned_be32(&config_data[config_offset]); in tasdevice_add_config()
196 bk_da = cfg_info->blk_data = kcalloc(cfg_info->nblocks, in tasdevice_add_config()
199 *status = -ENOMEM; in tasdevice_add_config()
202 cfg_info->real_nblocks = 0; in tasdevice_add_config()
203 for (i = 0; i < cfg_info->nblocks; i++) { in tasdevice_add_config()
205 *status = -EINVAL; in tasdevice_add_config()
206 dev_err(tas_priv->dev, in tasdevice_add_config()
208 __func__, i, cfg_info->nblocks); in tasdevice_add_config()
213 *status = -ENOMEM; in tasdevice_add_config()
217 bk_da[i]->dev_idx = config_data[config_offset]; in tasdevice_add_config()
220 bk_da[i]->block_type = config_data[config_offset]; in tasdevice_add_config()
223 if (bk_da[i]->block_type == TASDEVICE_BIN_BLK_PRE_POWER_UP) { in tasdevice_add_config()
224 if (bk_da[i]->dev_idx == 0) in tasdevice_add_config()
225 cfg_info->active_dev = in tasdevice_add_config()
226 (1 << tas_priv->ndev) - 1; in tasdevice_add_config()
228 cfg_info->active_dev |= 1 << in tasdevice_add_config()
229 (bk_da[i]->dev_idx - 1); in tasdevice_add_config()
232 bk_da[i]->yram_checksum = in tasdevice_add_config()
235 bk_da[i]->block_size = in tasdevice_add_config()
239 bk_da[i]->n_subblks = in tasdevice_add_config()
244 if (config_offset + bk_da[i]->block_size > config_size) { in tasdevice_add_config()
245 *status = -EINVAL; in tasdevice_add_config()
246 dev_err(tas_priv->dev, in tasdevice_add_config()
248 __func__, i, cfg_info->nblocks); in tasdevice_add_config()
252 bk_da[i]->regdata = kmemdup(&config_data[config_offset], in tasdevice_add_config()
253 bk_da[i]->block_size, GFP_KERNEL); in tasdevice_add_config()
254 if (!bk_da[i]->regdata) { in tasdevice_add_config()
255 *status = -ENOMEM; in tasdevice_add_config()
259 config_offset += bk_da[i]->block_size; in tasdevice_add_config()
260 cfg_info->real_nblocks += 1; in tasdevice_add_config()
279 rca = &(tas_priv->rcabin); in tasdevice_rca_parser()
280 fw_hdr = &(rca->fw_hdr); in tasdevice_rca_parser()
281 if (!fmw || !fmw->data) { in tasdevice_rca_parser()
282 dev_err(tas_priv->dev, "Failed to read %s\n", in tasdevice_rca_parser()
283 tas_priv->rca_binaryname); in tasdevice_rca_parser()
284 tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL; in tasdevice_rca_parser()
285 ret = -EINVAL; in tasdevice_rca_parser()
288 buf = (unsigned char *)fmw->data; in tasdevice_rca_parser()
290 fw_hdr->img_sz = get_unaligned_be32(&buf[offset]); in tasdevice_rca_parser()
292 if (fw_hdr->img_sz != fmw->size) { in tasdevice_rca_parser()
293 dev_err(tas_priv->dev, in tasdevice_rca_parser()
294 "File size not match, %d %u", (int)fmw->size, in tasdevice_rca_parser()
295 fw_hdr->img_sz); in tasdevice_rca_parser()
296 tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL; in tasdevice_rca_parser()
297 ret = -EINVAL; in tasdevice_rca_parser()
301 fw_hdr->checksum = get_unaligned_be32(&buf[offset]); in tasdevice_rca_parser()
303 fw_hdr->binary_version_num = get_unaligned_be32(&buf[offset]); in tasdevice_rca_parser()
304 if (fw_hdr->binary_version_num < 0x103) { in tasdevice_rca_parser()
305 dev_err(tas_priv->dev, "File version 0x%04x is too low", in tasdevice_rca_parser()
306 fw_hdr->binary_version_num); in tasdevice_rca_parser()
307 tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL; in tasdevice_rca_parser()
308 ret = -EINVAL; in tasdevice_rca_parser()
312 fw_hdr->drv_fw_version = get_unaligned_be32(&buf[offset]); in tasdevice_rca_parser()
314 fw_hdr->plat_type = buf[offset]; in tasdevice_rca_parser()
316 fw_hdr->dev_family = buf[offset]; in tasdevice_rca_parser()
318 fw_hdr->reserve = buf[offset]; in tasdevice_rca_parser()
320 fw_hdr->ndev = buf[offset]; in tasdevice_rca_parser()
322 if (fw_hdr->ndev != tas_priv->ndev) { in tasdevice_rca_parser()
323 dev_err(tas_priv->dev, in tasdevice_rca_parser()
325 fw_hdr->ndev, tas_priv->ndev); in tasdevice_rca_parser()
326 tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL; in tasdevice_rca_parser()
327 ret = -EINVAL; in tasdevice_rca_parser()
330 if (offset + TASDEVICE_DEVICE_SUM > fw_hdr->img_sz) { in tasdevice_rca_parser()
331 dev_err(tas_priv->dev, "rca_ready: Out of boundary!\n"); in tasdevice_rca_parser()
332 ret = -EINVAL; in tasdevice_rca_parser()
333 tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL; in tasdevice_rca_parser()
338 fw_hdr->devs[i] = buf[offset]; in tasdevice_rca_parser()
340 fw_hdr->nconfig = get_unaligned_be32(&buf[offset]); in tasdevice_rca_parser()
344 fw_hdr->config_size[i] = get_unaligned_be32(&buf[offset]); in tasdevice_rca_parser()
346 total_config_sz += fw_hdr->config_size[i]; in tasdevice_rca_parser()
349 if (fw_hdr->img_sz - total_config_sz != (unsigned int)offset) { in tasdevice_rca_parser()
350 dev_err(tas_priv->dev, "Bin file error!\n"); in tasdevice_rca_parser()
351 ret = -EINVAL; in tasdevice_rca_parser()
352 tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL; in tasdevice_rca_parser()
356 cfg_info = kcalloc(fw_hdr->nconfig, sizeof(*cfg_info), GFP_KERNEL); in tasdevice_rca_parser()
358 ret = -ENOMEM; in tasdevice_rca_parser()
359 tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL; in tasdevice_rca_parser()
362 rca->cfg_info = cfg_info; in tasdevice_rca_parser()
363 rca->ncfgs = 0; in tasdevice_rca_parser()
364 for (i = 0; i < (int)fw_hdr->nconfig; i++) { in tasdevice_rca_parser()
365 rca->ncfgs += 1; in tasdevice_rca_parser()
367 fw_hdr->config_size[i], &ret); in tasdevice_rca_parser()
369 tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL; in tasdevice_rca_parser()
372 offset += (int)fw_hdr->config_size[i]; in tasdevice_rca_parser()
386 struct tasdevice_dspfw_hdr *fw_hdr = &(tas_fmw->fw_hdr); in map_dev_idx()
387 struct tasdevice_fw_fixed_hdr *fw_fixed_hdr = &(fw_hdr->fixed_hdr); in map_dev_idx()
392 if (fw_fixed_hdr->ppcver >= PPC3_VERSION_TAS2781) { in map_dev_idx()
395 } else if (fw_fixed_hdr->ppcver >= PPC3_VERSION) { in map_dev_idx()
401 if (block->type == p[i].blktyp) { in map_dev_idx()
413 const unsigned char *data = fmw->data; in fw_parse_block_data_kernel()
415 if (offset + 16 > fmw->size) { in fw_parse_block_data_kernel()
416 dev_err(tas_fmw->dev, "%s: File Size error\n", __func__); in fw_parse_block_data_kernel()
417 offset = -EINVAL; in fw_parse_block_data_kernel()
424 block->type = get_unaligned_be32(&data[offset]); in fw_parse_block_data_kernel()
427 block->is_pchksum_present = data[offset]; in fw_parse_block_data_kernel()
430 block->pchksum = data[offset]; in fw_parse_block_data_kernel()
433 block->is_ychksum_present = data[offset]; in fw_parse_block_data_kernel()
436 block->ychksum = data[offset]; in fw_parse_block_data_kernel()
439 block->blk_size = get_unaligned_be32(&data[offset]); in fw_parse_block_data_kernel()
442 block->nr_subblocks = get_unaligned_be32(&data[offset]); in fw_parse_block_data_kernel()
451 block->dev_idx = map_dev_idx(tas_fmw, block); in fw_parse_block_data_kernel()
453 if (offset + block->blk_size > fmw->size) { in fw_parse_block_data_kernel()
454 dev_err(tas_fmw->dev, "%s: nSublocks error\n", __func__); in fw_parse_block_data_kernel()
455 offset = -EINVAL; in fw_parse_block_data_kernel()
459 block->data = kmemdup(&data[offset], block->blk_size, GFP_KERNEL); in fw_parse_block_data_kernel()
460 if (!block->data) { in fw_parse_block_data_kernel()
461 offset = -ENOMEM; in fw_parse_block_data_kernel()
464 offset += block->blk_size; in fw_parse_block_data_kernel()
474 const unsigned char *data = fmw->data; in fw_parse_data_kernel()
478 if (offset + 4 > fmw->size) { in fw_parse_data_kernel()
479 dev_err(tas_fmw->dev, "%s: File Size error\n", __func__); in fw_parse_data_kernel()
480 offset = -EINVAL; in fw_parse_data_kernel()
483 img_data->nr_blk = get_unaligned_be32(&data[offset]); in fw_parse_data_kernel()
486 img_data->dev_blks = kcalloc(img_data->nr_blk, in fw_parse_data_kernel()
488 if (!img_data->dev_blks) { in fw_parse_data_kernel()
489 offset = -ENOMEM; in fw_parse_data_kernel()
493 for (i = 0; i < img_data->nr_blk; i++) { in fw_parse_data_kernel()
494 blk = &(img_data->dev_blks[i]); in fw_parse_data_kernel()
497 offset = -EINVAL; in fw_parse_data_kernel()
513 for (i = 0; i < tas_fmw->nr_programs; i++) { in fw_parse_program_data_kernel()
514 program = &(tas_fmw->programs[i]); in fw_parse_program_data_kernel()
515 if (offset + 72 > fmw->size) { in fw_parse_program_data_kernel()
516 dev_err(tas_priv->dev, "%s: mpName error\n", __func__); in fw_parse_program_data_kernel()
517 offset = -EINVAL; in fw_parse_program_data_kernel()
523 offset = fw_parse_data_kernel(tas_fmw, &(program->dev_data), in fw_parse_program_data_kernel()
537 const unsigned char *data = fmw->data; in fw_parse_configuration_data_kernel()
541 for (i = 0; i < tas_fmw->nr_configurations; i++) { in fw_parse_configuration_data_kernel()
542 config = &(tas_fmw->configs[i]); in fw_parse_configuration_data_kernel()
543 if (offset + 80 > fmw->size) { in fw_parse_configuration_data_kernel()
544 dev_err(tas_priv->dev, "%s: mpName error\n", __func__); in fw_parse_configuration_data_kernel()
545 offset = -EINVAL; in fw_parse_configuration_data_kernel()
548 memcpy(config->name, &data[offset], 64); in fw_parse_configuration_data_kernel()
552 offset = fw_parse_data_kernel(tas_fmw, &(config->dev_data), in fw_parse_configuration_data_kernel()
566 struct tasdevice_fw *tas_fmw = tas_priv->fmw; in fw_parse_variable_header_kernel()
567 struct tasdevice_dspfw_hdr *fw_hdr = &(tas_fmw->fw_hdr); in fw_parse_variable_header_kernel()
570 const unsigned char *buf = fmw->data; in fw_parse_variable_header_kernel()
574 if (offset + 12 + 4 * TASDEVICE_MAXPROGRAM_NUM_KERNEL > fmw->size) { in fw_parse_variable_header_kernel()
575 dev_err(tas_priv->dev, "%s: File Size error\n", __func__); in fw_parse_variable_header_kernel()
576 offset = -EINVAL; in fw_parse_variable_header_kernel()
579 fw_hdr->device_family = get_unaligned_be16(&buf[offset]); in fw_parse_variable_header_kernel()
580 if (fw_hdr->device_family != 0) { in fw_parse_variable_header_kernel()
581 dev_err(tas_priv->dev, "%s:not TAS device\n", __func__); in fw_parse_variable_header_kernel()
582 offset = -EINVAL; in fw_parse_variable_header_kernel()
586 fw_hdr->device = get_unaligned_be16(&buf[offset]); in fw_parse_variable_header_kernel()
587 if (fw_hdr->device >= TASDEVICE_DSP_TAS_MAX_DEVICE || in fw_parse_variable_header_kernel()
588 fw_hdr->device == 6) { in fw_parse_variable_header_kernel()
589 dev_err(tas_priv->dev, "Unsupported dev %d\n", fw_hdr->device); in fw_parse_variable_header_kernel()
590 offset = -EINVAL; in fw_parse_variable_header_kernel()
594 fw_hdr->ndev = deviceNumber[fw_hdr->device]; in fw_parse_variable_header_kernel()
596 if (fw_hdr->ndev != tas_priv->ndev) { in fw_parse_variable_header_kernel()
597 dev_err(tas_priv->dev, in fw_parse_variable_header_kernel()
599 __func__, fw_hdr->ndev, tas_priv->ndev); in fw_parse_variable_header_kernel()
600 offset = -EINVAL; in fw_parse_variable_header_kernel()
604 tas_fmw->nr_programs = get_unaligned_be32(&buf[offset]); in fw_parse_variable_header_kernel()
607 if (tas_fmw->nr_programs == 0 || tas_fmw->nr_programs > in fw_parse_variable_header_kernel()
609 dev_err(tas_priv->dev, "mnPrograms is invalid\n"); in fw_parse_variable_header_kernel()
610 offset = -EINVAL; in fw_parse_variable_header_kernel()
614 tas_fmw->programs = kcalloc(tas_fmw->nr_programs, in fw_parse_variable_header_kernel()
616 if (!tas_fmw->programs) { in fw_parse_variable_header_kernel()
617 offset = -ENOMEM; in fw_parse_variable_header_kernel()
621 for (i = 0; i < tas_fmw->nr_programs; i++) { in fw_parse_variable_header_kernel()
622 program = &(tas_fmw->programs[i]); in fw_parse_variable_header_kernel()
623 program->prog_size = get_unaligned_be32(&buf[offset]); in fw_parse_variable_header_kernel()
628 offset += 4 * (TASDEVICE_MAXPROGRAM_NUM_KERNEL - tas_fmw->nr_programs); in fw_parse_variable_header_kernel()
630 tas_fmw->nr_configurations = get_unaligned_be32(&buf[offset]); in fw_parse_variable_header_kernel()
634 * tas2781s is different from the one lower than 4 pieces of in fw_parse_variable_header_kernel()
637 max_confs = (fw_hdr->ndev >= 4) ? in fw_parse_variable_header_kernel()
640 if (tas_fmw->nr_configurations == 0 || in fw_parse_variable_header_kernel()
641 tas_fmw->nr_configurations > max_confs) { in fw_parse_variable_header_kernel()
642 dev_err(tas_priv->dev, "%s: Conf is invalid\n", __func__); in fw_parse_variable_header_kernel()
643 offset = -EINVAL; in fw_parse_variable_header_kernel()
647 if (offset + 4 * max_confs > fmw->size) { in fw_parse_variable_header_kernel()
648 dev_err(tas_priv->dev, "%s: mpConfigurations err\n", __func__); in fw_parse_variable_header_kernel()
649 offset = -EINVAL; in fw_parse_variable_header_kernel()
653 tas_fmw->configs = kcalloc(tas_fmw->nr_configurations, in fw_parse_variable_header_kernel()
655 if (!tas_fmw->configs) { in fw_parse_variable_header_kernel()
656 offset = -ENOMEM; in fw_parse_variable_header_kernel()
660 for (i = 0; i < tas_fmw->nr_programs; i++) { in fw_parse_variable_header_kernel()
661 config = &(tas_fmw->configs[i]); in fw_parse_variable_header_kernel()
662 config->cfg_size = get_unaligned_be32(&buf[offset]); in fw_parse_variable_header_kernel()
667 offset += 4 * (max_confs - tas_fmw->nr_programs); in fw_parse_variable_header_kernel()
684 chn = idx - 1; in tasdevice_process_block()
688 chnend = tas_priv->ndev; in tasdevice_process_block()
692 if (tas_priv->tasdevice[chn].is_loading == false) in tasdevice_process_block()
704 dev_err(tas_priv->dev, in tasdevice_process_block()
718 dev_err(tas_priv->dev, in tasdevice_process_block()
730 dev_err(tas_priv->dev, in tasdevice_process_block()
737 dev_err(tas_priv->dev, in tasdevice_process_block()
738 "%s:Bst-len(%u)not div by 4\n", in tasdevice_process_block()
750 dev_err(tas_priv->dev, in tasdevice_process_block()
761 dev_err(tas_priv->dev, in tasdevice_process_block()
774 dev_err(tas_priv->dev, in tasdevice_process_block()
788 dev_err(tas_priv->dev, in tasdevice_process_block()
799 tas_priv->tasdevice[chn].cur_prog = -1; in tasdevice_process_block()
800 tas_priv->tasdevice[chn].cur_conf = -1; in tasdevice_process_block()
802 tas_priv->tasdevice[chn].cur_conf = -1; in tasdevice_process_block()
813 struct tasdevice_rca *rca = &(tas_priv->rcabin); in tasdevice_select_cfg_blk()
814 struct tasdevice_config_info **cfg_info = rca->cfg_info; in tasdevice_select_cfg_blk()
818 if (conf_no >= rca->ncfgs || conf_no < 0 || !cfg_info) { in tasdevice_select_cfg_blk()
819 dev_err(tas_priv->dev, "conf_no should be not more than %u\n", in tasdevice_select_cfg_blk()
820 rca->ncfgs); in tasdevice_select_cfg_blk()
823 blk_data = cfg_info[conf_no]->blk_data; in tasdevice_select_cfg_blk()
825 for (j = 0; j < (int)cfg_info[conf_no]->real_nblocks; j++) { in tasdevice_select_cfg_blk()
829 dev_err(tas_priv->dev, in tasdevice_select_cfg_blk()
833 if (block_type != blk_data[j]->block_type) in tasdevice_select_cfg_blk()
836 for (k = 0; k < (int)blk_data[j]->n_subblks; k++) { in tasdevice_select_cfg_blk()
837 if (blk_data[j]->dev_idx) { in tasdevice_select_cfg_blk()
838 chn = blk_data[j]->dev_idx - 1; in tasdevice_select_cfg_blk()
839 chnend = blk_data[j]->dev_idx; in tasdevice_select_cfg_blk()
842 chnend = tas_priv->ndev; in tasdevice_select_cfg_blk()
845 tas_priv->tasdevice[chn].is_loading = true; in tasdevice_select_cfg_blk()
848 blk_data[j]->regdata + length, in tasdevice_select_cfg_blk()
849 blk_data[j]->dev_idx, in tasdevice_select_cfg_blk()
850 blk_data[j]->block_size - length); in tasdevice_select_cfg_blk()
852 if (blk_data[j]->block_size < length) { in tasdevice_select_cfg_blk()
853 dev_err(tas_priv->dev, in tasdevice_select_cfg_blk()
856 blk_data[j]->block_size); in tasdevice_select_cfg_blk()
860 if (length != blk_data[j]->block_size) in tasdevice_select_cfg_blk()
861 dev_err(tas_priv->dev, "%s: %u %u size is not same\n", in tasdevice_select_cfg_blk()
862 __func__, length, blk_data[j]->block_size); in tasdevice_select_cfg_blk()
870 const unsigned int blk_size = block->blk_size; in tasdevice_load_block_kernel()
872 unsigned char *data = block->data; in tasdevice_load_block_kernel()
874 for (i = 0, length = 0; i < block->nr_subblocks; i++) { in tasdevice_load_block_kernel()
876 block->dev_idx, blk_size - length); in tasdevice_load_block_kernel()
878 dev_err(tasdevice->dev, in tasdevice_load_block_kernel()
885 dev_err(tasdevice->dev, "%s: %u %u out of boundary\n", in tasdevice_load_block_kernel()
898 const unsigned char *buf = fmw->data; in fw_parse_variable_hdr()
903 if (offset + len + 8 > fmw->size) { in fw_parse_variable_hdr()
904 dev_err(tas_priv->dev, "%s: File Size error\n", __func__); in fw_parse_variable_hdr()
905 offset = -EINVAL; in fw_parse_variable_hdr()
911 fw_hdr->device_family = get_unaligned_be32(&buf[offset]); in fw_parse_variable_hdr()
912 if (fw_hdr->device_family != 0) { in fw_parse_variable_hdr()
913 dev_err(tas_priv->dev, "%s: not TAS device\n", __func__); in fw_parse_variable_hdr()
914 offset = -EINVAL; in fw_parse_variable_hdr()
919 fw_hdr->device = get_unaligned_be32(&buf[offset]); in fw_parse_variable_hdr()
920 if (fw_hdr->device >= TASDEVICE_DSP_TAS_MAX_DEVICE || in fw_parse_variable_hdr()
921 fw_hdr->device == 6) { in fw_parse_variable_hdr()
922 dev_err(tas_priv->dev, "Unsupported dev %d\n", fw_hdr->device); in fw_parse_variable_hdr()
923 offset = -EINVAL; in fw_parse_variable_hdr()
927 fw_hdr->ndev = deviceNumber[fw_hdr->device]; in fw_parse_variable_hdr()
936 struct tasdevice_fw *tas_fmw = tas_priv->fmw; in fw_parse_variable_header_git()
937 struct tasdevice_dspfw_hdr *fw_hdr = &(tas_fmw->fw_hdr); in fw_parse_variable_header_git()
942 if (fw_hdr->ndev != tas_priv->ndev) { in fw_parse_variable_header_git()
943 dev_err(tas_priv->dev, in fw_parse_variable_header_git()
945 __func__, fw_hdr->ndev, tas_priv->ndev); in fw_parse_variable_header_git()
946 offset = -EINVAL; in fw_parse_variable_header_git()
956 unsigned char *data = (unsigned char *)fmw->data; in fw_parse_block_data()
959 if (offset + 8 > fmw->size) { in fw_parse_block_data()
960 dev_err(tas_fmw->dev, "%s: Type error\n", __func__); in fw_parse_block_data()
961 offset = -EINVAL; in fw_parse_block_data()
964 block->type = get_unaligned_be32(&data[offset]); in fw_parse_block_data()
967 if (tas_fmw->fw_hdr.fixed_hdr.drv_ver >= PPC_DRIVER_CRCCHK) { in fw_parse_block_data()
968 if (offset + 8 > fmw->size) { in fw_parse_block_data()
969 dev_err(tas_fmw->dev, "PChkSumPresent error\n"); in fw_parse_block_data()
970 offset = -EINVAL; in fw_parse_block_data()
973 block->is_pchksum_present = data[offset]; in fw_parse_block_data()
976 block->pchksum = data[offset]; in fw_parse_block_data()
979 block->is_ychksum_present = data[offset]; in fw_parse_block_data()
982 block->ychksum = data[offset]; in fw_parse_block_data()
985 block->is_pchksum_present = 0; in fw_parse_block_data()
986 block->is_ychksum_present = 0; in fw_parse_block_data()
989 block->nr_cmds = get_unaligned_be32(&data[offset]); in fw_parse_block_data()
992 n = block->nr_cmds * 4; in fw_parse_block_data()
993 if (offset + n > fmw->size) { in fw_parse_block_data()
994 dev_err(tas_fmw->dev, in fw_parse_block_data()
996 __func__, (unsigned long)fmw->size, offset, n); in fw_parse_block_data()
997 offset = -EINVAL; in fw_parse_block_data()
1001 block->data = kmemdup(&data[offset], n, GFP_KERNEL); in fw_parse_block_data()
1002 if (!block->data) { in fw_parse_block_data()
1003 offset = -ENOMEM; in fw_parse_block_data()
1019 const unsigned char *data = (unsigned char *)fmw->data; in fw_parse_data()
1024 if (offset + 64 > fmw->size) { in fw_parse_data()
1025 dev_err(tas_fmw->dev, "%s: Name error\n", __func__); in fw_parse_data()
1026 offset = -EINVAL; in fw_parse_data()
1029 memcpy(img_data->name, &data[offset], 64); in fw_parse_data()
1034 if (offset + n + 2 > fmw->size) { in fw_parse_data()
1035 dev_err(tas_fmw->dev, "%s: Description error\n", __func__); in fw_parse_data()
1036 offset = -EINVAL; in fw_parse_data()
1040 img_data->nr_blk = get_unaligned_be16(&data[offset]); in fw_parse_data()
1043 img_data->dev_blks = kcalloc(img_data->nr_blk, in fw_parse_data()
1045 if (!img_data->dev_blks) { in fw_parse_data()
1046 offset = -ENOMEM; in fw_parse_data()
1049 for (i = 0; i < img_data->nr_blk; i++) { in fw_parse_data()
1050 blk = &(img_data->dev_blks[i]); in fw_parse_data()
1053 offset = -EINVAL; in fw_parse_data()
1068 unsigned char *buf = (unsigned char *)fmw->data; in fw_parse_program_data()
1072 if (offset + 2 > fmw->size) { in fw_parse_program_data()
1073 dev_err(tas_priv->dev, "%s: File Size error\n", __func__); in fw_parse_program_data()
1074 offset = -EINVAL; in fw_parse_program_data()
1077 tas_fmw->nr_programs = get_unaligned_be16(&buf[offset]); in fw_parse_program_data()
1080 if (tas_fmw->nr_programs == 0) { in fw_parse_program_data()
1082 dev_info(tas_priv->dev, "%s: No Programs data, maybe calbin\n", in fw_parse_program_data()
1087 tas_fmw->programs = in fw_parse_program_data()
1088 kcalloc(tas_fmw->nr_programs, sizeof(struct tasdevice_prog), in fw_parse_program_data()
1090 if (!tas_fmw->programs) { in fw_parse_program_data()
1091 offset = -ENOMEM; in fw_parse_program_data()
1094 for (i = 0; i < tas_fmw->nr_programs; i++) { in fw_parse_program_data()
1097 program = &(tas_fmw->programs[i]); in fw_parse_program_data()
1098 if (offset + 64 > fmw->size) { in fw_parse_program_data()
1099 dev_err(tas_priv->dev, "%s: mpName error\n", __func__); in fw_parse_program_data()
1100 offset = -EINVAL; in fw_parse_program_data()
1108 if (offset + n > fmw->size) { in fw_parse_program_data()
1109 dev_err(tas_priv->dev, "Description err\n"); in fw_parse_program_data()
1110 offset = -EINVAL; in fw_parse_program_data()
1116 offset = fw_parse_data(tas_fmw, &(program->dev_data), fmw, in fw_parse_program_data()
1134 unsigned char *data = (unsigned char *)fmw->data; in fw_parse_configuration_data()
1139 if (offset + 2 > fmw->size) { in fw_parse_configuration_data()
1140 dev_err(tas_priv->dev, "%s: File Size error\n", __func__); in fw_parse_configuration_data()
1141 offset = -EINVAL; in fw_parse_configuration_data()
1144 tas_fmw->nr_configurations = get_unaligned_be16(&data[offset]); in fw_parse_configuration_data()
1147 if (tas_fmw->nr_configurations == 0) { in fw_parse_configuration_data()
1148 dev_err(tas_priv->dev, "%s: Conf is zero\n", __func__); in fw_parse_configuration_data()
1152 tas_fmw->configs = kcalloc(tas_fmw->nr_configurations, in fw_parse_configuration_data()
1154 if (!tas_fmw->configs) { in fw_parse_configuration_data()
1155 offset = -ENOMEM; in fw_parse_configuration_data()
1158 for (i = 0; i < tas_fmw->nr_configurations; i++) { in fw_parse_configuration_data()
1159 config = &(tas_fmw->configs[i]); in fw_parse_configuration_data()
1160 if (offset + 64 > fmw->size) { in fw_parse_configuration_data()
1161 dev_err(tas_priv->dev, "File Size err\n"); in fw_parse_configuration_data()
1162 offset = -EINVAL; in fw_parse_configuration_data()
1165 memcpy(config->name, &data[offset], 64); in fw_parse_configuration_data()
1170 if (offset + n > fmw->size) { in fw_parse_configuration_data()
1171 dev_err(tas_priv->dev, "Description err\n"); in fw_parse_configuration_data()
1172 offset = -EINVAL; in fw_parse_configuration_data()
1178 offset = fw_parse_data(tas_fmw, &(config->dev_data), in fw_parse_configuration_data()
1197 cd->len = TAS2781_YRAM5_END_REG - reg + 1; in check_inpage_yram_rg()
1199 cd->len = len; in check_inpage_yram_rg()
1200 cd->offset = reg; in check_inpage_yram_rg()
1204 cd->offset = TAS2781_YRAM5_START_REG; in check_inpage_yram_rg()
1205 cd->len = len - TAS2781_YRAM5_START_REG + reg; in check_inpage_yram_rg()
1220 cd->offset = reg; in check_inpage_yram_bk1()
1221 cd->len = len; in check_inpage_yram_bk1()
1224 cd->offset = TAS2781_YRAM1_START_REG; in check_inpage_yram_bk1()
1225 cd->len = len - TAS2781_YRAM1_START_REG + reg; in check_inpage_yram_bk1()
1235 * true -- the registers are in the inpage yram
1236 * false -- the registers are NOT in the inpage yram
1265 cd->offset = reg; in check_inblock_yram_bk()
1266 cd->len = len; in check_inblock_yram_bk()
1269 if (reg + len - 1 >= TAS2781_YRAM2_START_REG) { in check_inblock_yram_bk()
1270 cd->offset = TAS2781_YRAM2_START_REG; in check_inblock_yram_bk()
1271 cd->len = reg + len - TAS2781_YRAM2_START_REG; in check_inblock_yram_bk()
1281 * true -- the registers are in the inblock yram
1282 * false -- the registers are NOT in the inblock yram
1320 if ((reg + len - 1) > 127) { in tasdev_multibytes_chksum()
1321 ret = -EINVAL; in tasdev_multibytes_chksum()
1322 dev_err(tasdevice->dev, "firmware error\n"); in tasdev_multibytes_chksum()
1340 dev_err(tasdevice->dev, "firmware error\n"); in tasdev_multibytes_chksum()
1341 ret = -EINVAL; in tasdev_multibytes_chksum()
1363 crc_chksum += crc8(tasdevice->crc8_lkp_tbl, &nBuf1[i], in tasdev_multibytes_chksum()
1401 dev_err(tasdevice->dev, in do_singlereg_checksum()
1404 tasdevice->tasdevice[chl].err_code |= ERROR_YRAM_CRCCHK; in do_singlereg_checksum()
1405 ret = -EAGAIN; in do_singlereg_checksum()
1409 ret = crc8(tasdevice->crc8_lkp_tbl, &val, 1, 0); in do_singlereg_checksum()
1420 dev->cur_prog = -1; in set_err_prg_cfg()
1422 dev->cur_conf = -1; in set_err_prg_cfg()
1444 if (ret != -EAGAIN) in tasdev_bytes_chksum()
1447 block->nr_retry--; in tasdev_bytes_chksum()
1448 if (block->nr_retry > 0) in tasdev_bytes_chksum()
1451 set_err_prg_cfg(block->type, &tas_priv->tasdevice[chn]); in tasdev_bytes_chksum()
1470 if (block->is_ychksum_present) in tasdev_multibytes_wr()
1478 if (block->is_ychksum_present) in tasdev_multibytes_wr()
1483 if (!block->is_ychksum_present || ret >= 0) { in tasdev_multibytes_wr()
1486 *nr_cmds += ((len - 2) / 4) + 1; in tasdev_multibytes_wr()
1502 dev_err(tas_priv->dev, "%s: Chn %d\n", __func__, chn); in tasdev_block_chksum()
1503 set_err_prg_cfg(block->type, &tas_priv->tasdevice[chn]); in tasdev_block_chksum()
1507 if ((nr_value & 0xff) != block->pchksum) { in tasdev_block_chksum()
1508 dev_err(tas_priv->dev, "%s: Blk PChkSum Chn %d ", __func__, in tasdev_block_chksum()
1510 dev_err(tas_priv->dev, "PChkSum = 0x%x, Reg = 0x%x\n", in tasdev_block_chksum()
1511 block->pchksum, (nr_value & 0xff)); in tasdev_block_chksum()
1512 tas_priv->tasdevice[chn].err_code |= ERROR_PRAM_CRCCHK; in tasdev_block_chksum()
1513 ret = -EAGAIN; in tasdev_block_chksum()
1514 block->nr_retry--; in tasdev_block_chksum()
1516 if (block->nr_retry <= 0) in tasdev_block_chksum()
1517 set_err_prg_cfg(block->type, in tasdev_block_chksum()
1518 &tas_priv->tasdevice[chn]); in tasdev_block_chksum()
1520 tas_priv->tasdevice[chn].err_code &= ~ERROR_PRAM_CRCCHK; in tasdev_block_chksum()
1540 while (block->nr_retry > 0) { in tasdev_load_blk()
1541 if (block->is_pchksum_present) { in tasdev_load_blk()
1548 if (block->is_ychksum_present) in tasdev_load_blk()
1553 while (nr_cmds < block->nr_cmds) { in tasdev_load_blk()
1554 data = block->data + nr_cmds * 4; in tasdev_load_blk()
1569 if (block->is_ychksum_present) { in tasdev_load_blk()
1580 /*book -- data[0] page -- data[1]*/ in tasdev_load_blk()
1599 if (ret == -EAGAIN) { in tasdev_load_blk()
1600 if (block->nr_retry > 0) in tasdev_load_blk()
1605 if (block->is_pchksum_present) { in tasdev_load_blk()
1607 if (ret == -EAGAIN) { in tasdev_load_blk()
1608 if (block->nr_retry > 0) in tasdev_load_blk()
1614 if (block->is_ychksum_present) { in tasdev_load_blk()
1616 dev_err(tas_priv->dev, in tasdev_load_blk()
1618 block->ychksum, crc_chksum); in tasdev_load_blk()
1620 tas_priv->tasdevice[chn].err_code &= in tasdev_load_blk()
1640 switch (block->type) { in tasdevice_load_block()
1643 chnend = tas_priv->ndev; in tasdevice_load_block()
1670 dev_dbg(tas_priv->dev, "load blk: Other Type = 0x%02x\n", in tasdevice_load_block()
1671 block->type); in tasdevice_load_block()
1676 block->nr_retry = 6; in tasdevice_load_block()
1677 if (tas_priv->tasdevice[chn].is_loading == false) in tasdevice_load_block()
1681 dev_err(tas_priv->dev, "dev %d, Blk (%d) load error\n", in tasdevice_load_block()
1682 chn, block->type); in tasdevice_load_block()
1696 tas_priv->fw_parse_variable_header = in dspfw_default_callback()
1698 tas_priv->fw_parse_program_data = in dspfw_default_callback()
1700 tas_priv->fw_parse_configuration_data = in dspfw_default_callback()
1702 tas_priv->tasdevice_load_block = in dspfw_default_callback()
1707 tas_priv->fw_parse_variable_header = in dspfw_default_callback()
1709 tas_priv->fw_parse_program_data = in dspfw_default_callback()
1711 tas_priv->fw_parse_configuration_data = in dspfw_default_callback()
1713 tas_priv->tasdevice_load_block = in dspfw_default_callback()
1717 dev_err(tas_priv->dev, in dspfw_default_callback()
1720 dev_err(tas_priv->dev, " Current:0x%02x\n", in dspfw_default_callback()
1722 rc = -EINVAL; in dspfw_default_callback()
1727 dev_err(tas_priv->dev, in dspfw_default_callback()
1729 dev_err(tas_priv->dev, "current is 0x%02x\n", drv_ver); in dspfw_default_callback()
1730 rc = -EINVAL; in dspfw_default_callback()
1743 for (i = 0; i < dev_data->nr_blk; i++) { in load_calib_data()
1744 block = &(dev_data->dev_blks[i]); in load_calib_data()
1756 struct tasdevice_dspfw_hdr *fw_hdr = &(tas_fmw->fw_hdr); in fw_parse_header()
1757 struct tasdevice_fw_fixed_hdr *fw_fixed_hdr = &(fw_hdr->fixed_hdr); in fw_parse_header()
1759 const unsigned char *buf = (unsigned char *)fmw->data; in fw_parse_header()
1761 if (offset + 92 > fmw->size) { in fw_parse_header()
1762 dev_err(tas_priv->dev, "%s: File Size error\n", __func__); in fw_parse_header()
1763 offset = -EINVAL; in fw_parse_header()
1767 dev_err(tas_priv->dev, "%s: Magic num NOT match\n", __func__); in fw_parse_header()
1768 offset = -EINVAL; in fw_parse_header()
1776 fw_fixed_hdr->fwsize = get_unaligned_be32(&buf[offset]); in fw_parse_header()
1778 if (fw_fixed_hdr->fwsize != fmw->size) { in fw_parse_header()
1779 dev_err(tas_priv->dev, "File size not match, %lu %u", in fw_parse_header()
1780 (unsigned long)fmw->size, fw_fixed_hdr->fwsize); in fw_parse_header()
1781 offset = -EINVAL; in fw_parse_header()
1785 fw_fixed_hdr->ppcver = get_unaligned_be32(&buf[offset]); in fw_parse_header()
1787 fw_fixed_hdr->drv_ver = get_unaligned_be32(&buf[offset]); in fw_parse_header()
1797 struct tasdevice_dspfw_hdr *fw_hdr = &(tas_fmw->fw_hdr); in fw_parse_variable_hdr_cal()
1802 if (fw_hdr->ndev != 1) { in fw_parse_variable_hdr_cal()
1803 dev_err(tas_priv->dev, in fw_parse_variable_hdr_cal()
1805 __func__, fw_hdr->ndev); in fw_parse_variable_hdr_cal()
1806 offset = -EINVAL; in fw_parse_variable_hdr_cal()
1821 unsigned char *data = (unsigned char *)fmw->data; in fw_parse_calibration_data()
1824 if (offset + 2 > fmw->size) { in fw_parse_calibration_data()
1825 dev_err(tas_priv->dev, "%s: Calibrations error\n", __func__); in fw_parse_calibration_data()
1826 offset = -EINVAL; in fw_parse_calibration_data()
1829 tas_fmw->nr_calibrations = get_unaligned_be16(&data[offset]); in fw_parse_calibration_data()
1832 if (tas_fmw->nr_calibrations != 1) { in fw_parse_calibration_data()
1833 dev_err(tas_priv->dev, in fw_parse_calibration_data()
1835 __func__, tas_fmw->nr_calibrations); in fw_parse_calibration_data()
1839 tas_fmw->calibrations = kcalloc(tas_fmw->nr_calibrations, in fw_parse_calibration_data()
1841 if (!tas_fmw->calibrations) { in fw_parse_calibration_data()
1842 offset = -ENOMEM; in fw_parse_calibration_data()
1845 for (i = 0; i < tas_fmw->nr_calibrations; i++) { in fw_parse_calibration_data()
1846 if (offset + 64 > fmw->size) { in fw_parse_calibration_data()
1847 dev_err(tas_priv->dev, "Calibrations error\n"); in fw_parse_calibration_data()
1848 offset = -EINVAL; in fw_parse_calibration_data()
1851 calibration = &(tas_fmw->calibrations[i]); in fw_parse_calibration_data()
1857 if (offset + n > fmw->size) { in fw_parse_calibration_data()
1858 dev_err(tas_priv->dev, "Description err\n"); in fw_parse_calibration_data()
1859 offset = -EINVAL; in fw_parse_calibration_data()
1864 offset = fw_parse_data(tas_fmw, &(calibration->dev_data), fmw, in fw_parse_calibration_data()
1878 struct tasdevice *tasdev = &(tas_priv->tasdevice[i]); in tas2781_load_calibration()
1885 ret = request_firmware(&fw_entry, file_name, tas_priv->dev); in tas2781_load_calibration()
1887 dev_err(tas_priv->dev, "%s: Request firmware %s failed\n", in tas2781_load_calibration()
1892 if (!fw_entry->size) { in tas2781_load_calibration()
1893 dev_err(tas_priv->dev, "%s: file read error: size = %lu\n", in tas2781_load_calibration()
1894 __func__, (unsigned long)fw_entry->size); in tas2781_load_calibration()
1895 ret = -EINVAL; in tas2781_load_calibration()
1898 fmw.size = fw_entry->size; in tas2781_load_calibration()
1899 fmw.data = fw_entry->data; in tas2781_load_calibration()
1901 tas_fmw = tasdev->cali_data_fmw = kzalloc(sizeof(struct tasdevice_fw), in tas2781_load_calibration()
1903 if (!tasdev->cali_data_fmw) { in tas2781_load_calibration()
1904 ret = -ENOMEM; in tas2781_load_calibration()
1907 tas_fmw->dev = tas_priv->dev; in tas2781_load_calibration()
1909 if (offset == -EINVAL) { in tas2781_load_calibration()
1910 dev_err(tas_priv->dev, "fw_parse_header EXIT!\n"); in tas2781_load_calibration()
1915 if (offset == -EINVAL) { in tas2781_load_calibration()
1916 dev_err(tas_priv->dev, in tas2781_load_calibration()
1923 dev_err(tas_priv->dev, "fw_parse_program_data EXIT!\n"); in tas2781_load_calibration()
1929 dev_err(tas_priv->dev, "fw_parse_configuration_data EXIT!\n"); in tas2781_load_calibration()
1935 dev_err(tas_priv->dev, "fw_parse_calibration_data EXIT!\n"); in tas2781_load_calibration()
1957 if (!fmw || !fmw->data) { in tasdevice_dspfw_ready()
1958 dev_err(tas_priv->dev, "%s: Failed to read firmware %s\n", in tasdevice_dspfw_ready()
1959 __func__, tas_priv->coef_binaryname); in tasdevice_dspfw_ready()
1960 ret = -EINVAL; in tasdevice_dspfw_ready()
1964 tas_priv->fmw = kzalloc(sizeof(struct tasdevice_fw), GFP_KERNEL); in tasdevice_dspfw_ready()
1965 if (!tas_priv->fmw) { in tasdevice_dspfw_ready()
1966 ret = -ENOMEM; in tasdevice_dspfw_ready()
1969 tas_fmw = tas_priv->fmw; in tasdevice_dspfw_ready()
1970 tas_fmw->dev = tas_priv->dev; in tasdevice_dspfw_ready()
1973 if (offset == -EINVAL) { in tasdevice_dspfw_ready()
1974 ret = -EINVAL; in tasdevice_dspfw_ready()
1977 fw_fixed_hdr = &(tas_fmw->fw_hdr.fixed_hdr); in tasdevice_dspfw_ready()
1979 switch (fw_fixed_hdr->drv_ver) { in tasdevice_dspfw_ready()
1984 tas_priv->fw_parse_variable_header = in tasdevice_dspfw_ready()
1986 tas_priv->fw_parse_program_data = in tasdevice_dspfw_ready()
1988 tas_priv->fw_parse_configuration_data = in tasdevice_dspfw_ready()
1990 tas_priv->tasdevice_load_block = in tasdevice_dspfw_ready()
1996 tas_priv->fw_parse_variable_header = in tasdevice_dspfw_ready()
1998 tas_priv->fw_parse_program_data = in tasdevice_dspfw_ready()
2000 tas_priv->fw_parse_configuration_data = in tasdevice_dspfw_ready()
2002 tas_priv->tasdevice_load_block = in tasdevice_dspfw_ready()
2007 fw_fixed_hdr->drv_ver, fw_fixed_hdr->ppcver); in tasdevice_dspfw_ready()
2013 offset = tas_priv->fw_parse_variable_header(tas_priv, fmw, offset); in tasdevice_dspfw_ready()
2018 offset = tas_priv->fw_parse_program_data(tas_priv, tas_fmw, fmw, in tasdevice_dspfw_ready()
2024 offset = tas_priv->fw_parse_configuration_data(tas_priv, in tasdevice_dspfw_ready()
2039 ret = request_firmware(&fw_entry, tas_priv->coef_binaryname, in tasdevice_dsp_parser()
2040 tas_priv->dev); in tasdevice_dsp_parser()
2042 dev_err(tas_priv->dev, "%s: load %s error\n", __func__, in tasdevice_dsp_parser()
2043 tas_priv->coef_binaryname); in tasdevice_dsp_parser()
2064 if (!tas_fmw->calibrations) in tas2781_clear_calfirmware()
2067 for (i = 0; i < tas_fmw->nr_calibrations; i++) { in tas2781_clear_calfirmware()
2068 calibration = &(tas_fmw->calibrations[i]); in tas2781_clear_calfirmware()
2072 im = &(calibration->dev_data); in tas2781_clear_calfirmware()
2074 if (!im->dev_blks) in tas2781_clear_calfirmware()
2077 for (blks = 0; blks < im->nr_blk; blks++) { in tas2781_clear_calfirmware()
2078 block = &(im->dev_blks[blks]); in tas2781_clear_calfirmware()
2081 kfree(block->data); in tas2781_clear_calfirmware()
2083 kfree(im->dev_blks); in tas2781_clear_calfirmware()
2085 kfree(tas_fmw->calibrations); in tas2781_clear_calfirmware()
2099 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_calbin_remove()
2100 tasdev = &(tas_priv->tasdevice[i]); in tasdevice_calbin_remove()
2101 if (!tasdev->cali_data_fmw) in tasdevice_calbin_remove()
2103 tas2781_clear_calfirmware(tasdev->cali_data_fmw); in tasdevice_calbin_remove()
2104 tasdev->cali_data_fmw = NULL; in tasdevice_calbin_remove()
2112 struct tasdevice_rca *rca = &(tas_priv->rcabin); in tasdevice_config_info_remove()
2113 struct tasdevice_config_info **ci = rca->cfg_info; in tasdevice_config_info_remove()
2118 for (i = 0; i < rca->ncfgs; i++) { in tasdevice_config_info_remove()
2121 if (ci[i]->blk_data) { in tasdevice_config_info_remove()
2122 for (j = 0; j < (int)ci[i]->real_nblocks; j++) { in tasdevice_config_info_remove()
2123 if (!ci[i]->blk_data[j]) in tasdevice_config_info_remove()
2125 kfree(ci[i]->blk_data[j]->regdata); in tasdevice_config_info_remove()
2126 kfree(ci[i]->blk_data[j]); in tasdevice_config_info_remove()
2128 kfree(ci[i]->blk_data); in tasdevice_config_info_remove()
2143 for (i = 0; i < dev_data->nr_blk; i++) { in tasdevice_load_data()
2144 block = &(dev_data->dev_blks[i]); in tasdevice_load_data()
2145 ret = tas_priv->tasdevice_load_block(tas_priv, block); in tasdevice_load_data()
2155 struct tasdevice_fw *cal_fmw = priv->tasdevice[i].cali_data_fmw; in tasdev_load_calibrated_data()
2156 struct calidata *cali_data = &priv->cali_data; in tasdev_load_calibrated_data()
2157 struct cali_reg *p = &cali_data->cali_reg_array; in tasdev_load_calibrated_data()
2158 unsigned char *data = cali_data->data; in tasdev_load_calibrated_data()
2159 struct tasdevice_calibration *cal; in tasdev_load_calibrated_data() local
2160 int k = i * (cali_data->cali_dat_sz_per_dev + 1); in tasdev_load_calibrated_data()
2163 /* Load the calibrated data from cal bin file */ in tasdev_load_calibrated_data()
2164 if (!priv->is_user_space_calidata && cal_fmw) { in tasdev_load_calibrated_data()
2165 cal = cal_fmw->calibrations; in tasdev_load_calibrated_data()
2167 if (cal) in tasdev_load_calibrated_data()
2168 load_calib_data(priv, &cal->dev_data); in tasdev_load_calibrated_data()
2171 if (!priv->is_user_space_calidata) in tasdev_load_calibrated_data()
2175 dev_err(priv->dev, "%s: no cal-data for dev %d from usr-spc\n", in tasdev_load_calibrated_data()
2181 rc = tasdevice_dev_bulk_write(priv, i, p->r0_reg, &(data[k]), 4); in tasdev_load_calibrated_data()
2183 dev_err(priv->dev, "chn %d r0_reg bulk_wr err = %d\n", i, rc); in tasdev_load_calibrated_data()
2187 rc = tasdevice_dev_bulk_write(priv, i, p->r0_low_reg, &(data[k]), 4); in tasdev_load_calibrated_data()
2189 dev_err(priv->dev, "chn %d r0_low_reg err = %d\n", i, rc); in tasdev_load_calibrated_data()
2193 rc = tasdevice_dev_bulk_write(priv, i, p->invr0_reg, &(data[k]), 4); in tasdev_load_calibrated_data()
2195 dev_err(priv->dev, "chn %d invr0_reg err = %d\n", i, rc); in tasdev_load_calibrated_data()
2199 rc = tasdevice_dev_bulk_write(priv, i, p->pow_reg, &(data[k]), 4); in tasdev_load_calibrated_data()
2201 dev_err(priv->dev, "chn %d pow_reg bulk_wr err = %d\n", i, rc); in tasdev_load_calibrated_data()
2205 rc = tasdevice_dev_bulk_write(priv, i, p->tlimit_reg, &(data[k]), 4); in tasdev_load_calibrated_data()
2207 dev_err(priv->dev, "chn %d tlimit_reg err = %d\n", i, rc); in tasdev_load_calibrated_data()
2216 struct tasdevice_rca *rca = &(tas_priv->rcabin); in tasdevice_select_tuningprm_cfg()
2217 struct tasdevice_config_info **cfg_info = rca->cfg_info; in tasdevice_select_tuningprm_cfg()
2218 struct tasdevice_fw *tas_fmw = tas_priv->fmw; in tasdevice_select_tuningprm_cfg()
2225 dev_err(tas_priv->dev, "%s: Firmware is NULL\n", __func__); in tasdevice_select_tuningprm_cfg()
2229 if (cfg_no >= tas_fmw->nr_configurations) { in tasdevice_select_tuningprm_cfg()
2230 dev_err(tas_priv->dev, in tasdevice_select_tuningprm_cfg()
2232 __func__, cfg_no, tas_fmw->nr_configurations); in tasdevice_select_tuningprm_cfg()
2236 if (prm_no >= tas_fmw->nr_programs) { in tasdevice_select_tuningprm_cfg()
2237 dev_err(tas_priv->dev, in tasdevice_select_tuningprm_cfg()
2239 __func__, prm_no, tas_fmw->nr_programs); in tasdevice_select_tuningprm_cfg()
2243 if (rca_conf_no >= rca->ncfgs || rca_conf_no < 0 || in tasdevice_select_tuningprm_cfg()
2245 dev_err(tas_priv->dev, in tasdevice_select_tuningprm_cfg()
2247 rca_conf_no, rca->ncfgs-1); in tasdevice_select_tuningprm_cfg()
2251 for (i = 0, prog_status = 0; i < tas_priv->ndev; i++) { in tasdevice_select_tuningprm_cfg()
2252 if (cfg_info[rca_conf_no]->active_dev & (1 << i)) { in tasdevice_select_tuningprm_cfg()
2254 && (tas_priv->tasdevice[i].cur_prog != prm_no in tasdevice_select_tuningprm_cfg()
2255 || tas_priv->force_fwload_status)) { in tasdevice_select_tuningprm_cfg()
2256 tas_priv->tasdevice[i].cur_conf = -1; in tasdevice_select_tuningprm_cfg()
2257 tas_priv->tasdevice[i].is_loading = true; in tasdevice_select_tuningprm_cfg()
2261 tas_priv->tasdevice[i].is_loading = false; in tasdevice_select_tuningprm_cfg()
2262 tas_priv->tasdevice[i].is_loaderr = false; in tasdevice_select_tuningprm_cfg()
2266 program = &(tas_fmw->programs[prm_no]); in tasdevice_select_tuningprm_cfg()
2267 tasdevice_load_data(tas_priv, &(program->dev_data)); in tasdevice_select_tuningprm_cfg()
2268 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_select_tuningprm_cfg()
2269 if (tas_priv->tasdevice[i].is_loaderr == true) in tasdevice_select_tuningprm_cfg()
2271 if (tas_priv->tasdevice[i].is_loaderr == false && in tasdevice_select_tuningprm_cfg()
2272 tas_priv->tasdevice[i].is_loading == true) in tasdevice_select_tuningprm_cfg()
2273 tas_priv->tasdevice[i].cur_prog = prm_no; in tasdevice_select_tuningprm_cfg()
2277 for (i = 0, status = 0; i < tas_priv->ndev; i++) { in tasdevice_select_tuningprm_cfg()
2279 && tas_priv->tasdevice[i].cur_conf != cfg_no in tasdevice_select_tuningprm_cfg()
2280 && (cfg_info[rca_conf_no]->active_dev & (1 << i)) in tasdevice_select_tuningprm_cfg()
2281 && (tas_priv->tasdevice[i].is_loaderr == false)) { in tasdevice_select_tuningprm_cfg()
2283 tas_priv->tasdevice[i].is_loading = true; in tasdevice_select_tuningprm_cfg()
2285 tas_priv->tasdevice[i].is_loading = false; in tasdevice_select_tuningprm_cfg()
2289 conf = &(tas_fmw->configs[cfg_no]); in tasdevice_select_tuningprm_cfg()
2291 tasdevice_load_data(tas_priv, &(conf->dev_data)); in tasdevice_select_tuningprm_cfg()
2292 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_select_tuningprm_cfg()
2293 if (tas_priv->tasdevice[i].is_loaderr == true) { in tasdevice_select_tuningprm_cfg()
2298 if (tas_priv->tasdevice[i].is_loaderr == false && in tasdevice_select_tuningprm_cfg()
2299 tas_priv->tasdevice[i].is_loading == true) { in tasdevice_select_tuningprm_cfg()
2301 tas_priv->tasdevice[i].cur_conf = cfg_no; in tasdevice_select_tuningprm_cfg()
2305 dev_dbg(tas_priv->dev, "%s: Unneeded loading dsp conf %d\n", in tasdevice_select_tuningprm_cfg()
2309 status |= cfg_info[rca_conf_no]->active_dev; in tasdevice_select_tuningprm_cfg()
2319 struct tasdevice_fw *tas_fmw = tas_priv->fmw; in tasdevice_prmg_load()
2325 dev_err(tas_priv->dev, "%s: Firmware is NULL\n", __func__); in tasdevice_prmg_load()
2329 if (prm_no >= tas_fmw->nr_programs) { in tasdevice_prmg_load()
2330 dev_err(tas_priv->dev, in tasdevice_prmg_load()
2332 __func__, prm_no, tas_fmw->nr_programs); in tasdevice_prmg_load()
2336 for (i = 0, prog_status = 0; i < tas_priv->ndev; i++) { in tasdevice_prmg_load()
2337 if (prm_no >= 0 && tas_priv->tasdevice[i].cur_prog != prm_no) { in tasdevice_prmg_load()
2338 tas_priv->tasdevice[i].cur_conf = -1; in tasdevice_prmg_load()
2339 tas_priv->tasdevice[i].is_loading = true; in tasdevice_prmg_load()
2345 program = &(tas_fmw->programs[prm_no]); in tasdevice_prmg_load()
2346 tasdevice_load_data(tas_priv, &(program->dev_data)); in tasdevice_prmg_load()
2347 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_prmg_load()
2348 if (tas_priv->tasdevice[i].is_loaderr == true) in tasdevice_prmg_load()
2350 else if (tas_priv->tasdevice[i].is_loaderr == false in tasdevice_prmg_load()
2351 && tas_priv->tasdevice[i].is_loading == true) in tasdevice_prmg_load()
2352 tas_priv->tasdevice[i].cur_prog = prm_no; in tasdevice_prmg_load()
2364 struct tasdevice_fw *tas_fmw = tas_priv->fmw; in tasdevice_tuning_switch()
2365 int profile_cfg_id = tas_priv->rcabin.profile_cfg_id; in tasdevice_tuning_switch()
2368 * Only RCA-based Playback can still work with no dsp program running in tasdevice_tuning_switch()
2371 switch (tas_priv->fw_state) { in tasdevice_tuning_switch()
2380 if (tas_fmw && tas_priv->cur_prog < tas_fmw->nr_programs) { in tasdevice_tuning_switch()
2382 profile_cfg_id = tas_priv->rcabin.profile_cfg_id; in tasdevice_tuning_switch()
2384 tas_priv->cur_prog, tas_priv->cur_conf, in tasdevice_tuning_switch()
2398 MODULE_AUTHOR("Shenghao Ding, TI, <shenghao-ding@ti.com>");