Lines Matching +full:e +full:- +full:book

1 // SPDX-License-Identifier: GPL-2.0
5 // Copyright 2023 - 2024 Texas Instruments, Inc.
7 // Author: Shenghao Ding <shenghao-ding@ti.com>
48 unsigned short chn, int book) in tasdevice_change_chn_book() argument
50 struct i2c_client *client = (struct i2c_client *)tas_priv->client; in tasdevice_change_chn_book()
53 if (chn < tas_priv->ndev) { in tasdevice_change_chn_book()
54 struct tasdevice *tasdev = &tas_priv->tasdevice[chn]; in tasdevice_change_chn_book()
55 struct regmap *map = tas_priv->regmap; in tasdevice_change_chn_book()
57 if (client->addr != tasdev->dev_addr) { in tasdevice_change_chn_book()
58 client->addr = tasdev->dev_addr; in tasdevice_change_chn_book()
62 * is the same one for page-switching. in tasdevice_change_chn_book()
66 dev_err(tas_priv->dev, "%s, E=%d channel:%d\n", in tasdevice_change_chn_book()
72 if (tasdev->cur_book != book) { in tasdevice_change_chn_book()
73 ret = regmap_write(map, TASDEVICE_BOOKCTL_REG, book); in tasdevice_change_chn_book()
75 dev_err(tas_priv->dev, "%s, E=%d\n", in tasdevice_change_chn_book()
79 tasdev->cur_book = book; in tasdevice_change_chn_book()
82 ret = -EINVAL; in tasdevice_change_chn_book()
83 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_change_chn_book()
94 struct i2c_client *client = (struct i2c_client *)tas_priv->client; in tasdev_chn_switch()
95 struct tasdevice *tasdev = &tas_priv->tasdevice[chn]; in tasdev_chn_switch()
96 struct regmap *map = tas_priv->regmap; in tasdev_chn_switch()
99 if (client->addr != tasdev->dev_addr) { in tasdev_chn_switch()
100 client->addr = tasdev->dev_addr; in tasdev_chn_switch()
104 * is the same one for page-switching. in tasdev_chn_switch()
108 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdev_chn_switch()
122 if (chn < tas_priv->ndev) { in tasdevice_dev_read()
123 struct regmap *map = tas_priv->regmap; in tasdevice_dev_read()
132 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_read()
134 ret = -EINVAL; in tasdevice_dev_read()
135 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_read()
149 if (chn < tas_priv->ndev) { in tasdevice_dev_write()
150 struct regmap *map = tas_priv->regmap; in tasdevice_dev_write()
160 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_write()
162 ret = -EINVAL; in tasdevice_dev_write()
163 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_write()
179 if (chn < tas_priv->ndev) { in tasdevice_dev_bulk_write()
180 struct regmap *map = tas_priv->regmap; in tasdevice_dev_bulk_write()
190 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_bulk_write()
192 ret = -EINVAL; in tasdevice_dev_bulk_write()
193 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_bulk_write()
208 if (chn < tas_priv->ndev) { in tasdevice_dev_bulk_read()
209 struct regmap *map = tas_priv->regmap; in tasdevice_dev_bulk_read()
218 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_bulk_read()
220 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_bulk_read()
234 if (chn < tas_priv->ndev) { in tasdevice_dev_update_bits()
235 struct regmap *map = tas_priv->regmap; in tasdevice_dev_update_bits()
245 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_update_bits()
247 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_update_bits()
249 ret = -EINVAL; in tasdevice_dev_update_bits()
261 tas_priv = devm_kzalloc(&i2c->dev, sizeof(*tas_priv), GFP_KERNEL); in tasdevice_kzalloc()
264 tas_priv->dev = &i2c->dev; in tasdevice_kzalloc()
265 tas_priv->client = (void *)i2c; in tasdevice_kzalloc()
275 if (tas_dev->reset) { in tasdevice_reset()
276 gpiod_set_value_cansleep(tas_dev->reset, 0); in tasdevice_reset()
278 gpiod_set_value_cansleep(tas_dev->reset, 1); in tasdevice_reset()
280 for (i = 0; i < tas_dev->ndev; i++) { in tasdevice_reset()
285 dev_err(tas_dev->dev, in tasdevice_reset()
303 mutex_lock(&tas_priv->codec_lock); in tascodec_init()
305 if (tas_priv->name_prefix) in tascodec_init()
306 scnprintf(tas_priv->rca_binaryname, 64, "%s-%sRCA%d.bin", in tascodec_init()
307 tas_priv->name_prefix, tas_priv->dev_name, in tascodec_init()
308 tas_priv->ndev); in tascodec_init()
310 scnprintf(tas_priv->rca_binaryname, 64, "%sRCA%d.bin", in tascodec_init()
311 tas_priv->dev_name, tas_priv->ndev); in tascodec_init()
312 crc8_populate_msb(tas_priv->crc8_lkp_tbl, TASDEVICE_CRC8_POLYNOMIAL); in tascodec_init()
313 tas_priv->codec = codec; in tascodec_init()
315 tas_priv->rca_binaryname, tas_priv->dev, GFP_KERNEL, tas_priv, in tascodec_init()
318 dev_err(tas_priv->dev, "request_firmware_nowait err:0x%08x\n", in tascodec_init()
322 mutex_unlock(&tas_priv->codec_lock); in tascodec_init()
332 tas_priv->regmap = devm_regmap_init_i2c(tas_priv->client, in tasdevice_init()
334 if (IS_ERR(tas_priv->regmap)) { in tasdevice_init()
335 ret = PTR_ERR(tas_priv->regmap); in tasdevice_init()
336 dev_err(tas_priv->dev, "Failed to allocate register map: %d\n", in tasdevice_init()
341 tas_priv->cur_prog = -1; in tasdevice_init()
342 tas_priv->cur_conf = -1; in tasdevice_init()
344 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_init()
345 tas_priv->tasdevice[i].cur_book = -1; in tasdevice_init()
346 tas_priv->tasdevice[i].cur_prog = -1; in tasdevice_init()
347 tas_priv->tasdevice[i].cur_conf = -1; in tasdevice_init()
350 mutex_init(&tas_priv->codec_lock); in tasdevice_init()
366 tas_dt = &(prog->dev_data); in tasdev_dsp_prog_blk_remove()
368 if (!tas_dt->dev_blks) in tasdev_dsp_prog_blk_remove()
371 for (i = 0; i < tas_dt->nr_blk; i++) { in tasdev_dsp_prog_blk_remove()
372 blk = &(tas_dt->dev_blks[i]); in tasdev_dsp_prog_blk_remove()
373 kfree(blk->data); in tasdev_dsp_prog_blk_remove()
375 kfree(tas_dt->dev_blks); in tasdev_dsp_prog_blk_remove()
395 tas_dt = &(cfg->dev_data); in tasdev_dsp_cfg_blk_remove()
397 if (!tas_dt->dev_blks) in tasdev_dsp_cfg_blk_remove()
400 for (i = 0; i < tas_dt->nr_blk; i++) { in tasdev_dsp_cfg_blk_remove()
401 blk = &(tas_dt->dev_blks[i]); in tasdev_dsp_cfg_blk_remove()
402 kfree(blk->data); in tasdev_dsp_cfg_blk_remove()
404 kfree(tas_dt->dev_blks); in tasdev_dsp_cfg_blk_remove()
421 struct tasdevice_fw *tas_fmw = tas_dev->fmw; in tasdevice_dsp_remove()
423 if (!tas_dev->fmw) in tasdevice_dsp_remove()
426 if (tas_fmw->programs) in tasdevice_dsp_remove()
427 tasdev_dsp_prog_remove(tas_fmw->programs, in tasdevice_dsp_remove()
428 tas_fmw->nr_programs); in tasdevice_dsp_remove()
429 if (tas_fmw->configs) in tasdevice_dsp_remove()
430 tasdev_dsp_cfg_remove(tas_fmw->configs, in tasdevice_dsp_remove()
431 tas_fmw->nr_configurations); in tasdevice_dsp_remove()
433 tas_dev->fmw = NULL; in tasdevice_dsp_remove()
439 mutex_destroy(&tas_priv->codec_lock); in tasdevice_remove()
445 if (tas_priv->save_calibration) in tasdevice_save_calibration()
446 return tas_priv->save_calibration(tas_priv); in tasdevice_save_calibration()
447 return -EINVAL; in tasdevice_save_calibration()
453 if (tas_priv->apply_calibration && tas_priv->cali_data.total_sz) in tasdevice_apply_calibration()
454 tas_priv->apply_calibration(tas_priv); in tasdevice_apply_calibration()
463 val = max - val; in tasdevice_clamp()
472 unsigned int invert = mc->invert; in tasdevice_amp_putvol()
474 int max = mc->max; in tasdevice_amp_putvol()
478 mask = (1 << fls(max)) - 1; in tasdevice_amp_putvol()
479 mask <<= mc->shift; in tasdevice_amp_putvol()
480 val = tasdevice_clamp(ucontrol->value.integer.value[0], max, invert); in tasdevice_amp_putvol()
481 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_amp_putvol()
483 mc->reg, mask, (unsigned int)(val << mc->shift)); in tasdevice_amp_putvol()
487 dev_err(tas_priv->dev, "set AMP vol error in dev %d\n", i); in tasdevice_amp_putvol()
491 return (err_cnt == tas_priv->ndev) ? 0 : 1; in tasdevice_amp_putvol()
498 unsigned int invert = mc->invert; in tasdevice_amp_getvol()
500 int max = mc->max; in tasdevice_amp_getvol()
505 ret = tasdevice_dev_read(tas_priv, 0, mc->reg, &val); in tasdevice_amp_getvol()
507 dev_err(tas_priv->dev, "%s, get AMP vol error\n", __func__); in tasdevice_amp_getvol()
511 mask = (1 << fls(max)) - 1; in tasdevice_amp_getvol()
512 mask <<= mc->shift; in tasdevice_amp_getvol()
513 val = (val & mask) >> mc->shift; in tasdevice_amp_getvol()
515 ucontrol->value.integer.value[0] = val; in tasdevice_amp_getvol()
526 unsigned int invert = mc->invert; in tasdevice_digital_putvol()
527 int max = mc->max; in tasdevice_digital_putvol()
532 val = tasdevice_clamp(ucontrol->value.integer.value[0], max, invert); in tasdevice_digital_putvol()
534 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_digital_putvol()
535 ret = tasdevice_dev_write(tas_priv, i, mc->reg, in tasdevice_digital_putvol()
540 dev_err(tas_priv->dev, in tasdevice_digital_putvol()
545 return (err_cnt == tas_priv->ndev) ? 0 : 1; in tasdevice_digital_putvol()
553 unsigned int invert = mc->invert; in tasdevice_digital_getvol()
554 int max = mc->max; in tasdevice_digital_getvol()
558 ret = tasdevice_dev_read(tas_priv, 0, mc->reg, &val); in tasdevice_digital_getvol()
560 dev_err(tas_priv->dev, "%s, get digital vol error\n", in tasdevice_digital_getvol()
566 ucontrol->value.integer.value[0] = val; in tasdevice_digital_getvol()
575 MODULE_AUTHOR("Shenghao Ding, TI, <shenghao-ding@ti.com>");