• Home
  • Raw
  • Download

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

1 // SPDX-License-Identifier: GPL-2.0
3 // tas2781-lib.c -- TAS2781 Common functions for HDA and ASoC Audio drivers
7 // Author: Shenghao Ding <shenghao-ding@ti.com>
49 unsigned short chn, int book) in tasdevice_change_chn_book() argument
51 struct i2c_client *client = (struct i2c_client *)tas_priv->client; in tasdevice_change_chn_book()
54 if (chn < tas_priv->ndev) { in tasdevice_change_chn_book()
55 struct tasdevice *tasdev = &tas_priv->tasdevice[chn]; in tasdevice_change_chn_book()
56 struct regmap *map = tas_priv->regmap; in tasdevice_change_chn_book()
58 if (client->addr != tasdev->dev_addr) { in tasdevice_change_chn_book()
59 client->addr = tasdev->dev_addr; in tasdevice_change_chn_book()
63 * is the same one for page-switching. in tasdevice_change_chn_book()
67 dev_err(tas_priv->dev, "%s, E=%d\n", in tasdevice_change_chn_book()
73 if (tasdev->cur_book != book) { in tasdevice_change_chn_book()
74 ret = regmap_write(map, TASDEVICE_BOOKCTL_REG, book); in tasdevice_change_chn_book()
76 dev_err(tas_priv->dev, "%s, E=%d\n", in tasdevice_change_chn_book()
80 tasdev->cur_book = book; in tasdevice_change_chn_book()
83 ret = -EINVAL; in tasdevice_change_chn_book()
84 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_change_chn_book()
97 if (chn < tas_priv->ndev) { in tasdevice_dev_read()
98 struct regmap *map = tas_priv->regmap; in tasdevice_dev_read()
107 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_read()
109 ret = -EINVAL; in tasdevice_dev_read()
110 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_read()
124 if (chn < tas_priv->ndev) { in tasdevice_dev_write()
125 struct regmap *map = tas_priv->regmap; in tasdevice_dev_write()
135 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_write()
137 ret = -EINVAL; in tasdevice_dev_write()
138 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_write()
154 if (chn < tas_priv->ndev) { in tasdevice_dev_bulk_write()
155 struct regmap *map = tas_priv->regmap; in tasdevice_dev_bulk_write()
165 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_bulk_write()
167 ret = -EINVAL; in tasdevice_dev_bulk_write()
168 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_bulk_write()
183 if (chn < tas_priv->ndev) { in tasdevice_dev_bulk_read()
184 struct regmap *map = tas_priv->regmap; in tasdevice_dev_bulk_read()
193 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_bulk_read()
195 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_bulk_read()
209 if (chn < tas_priv->ndev) { in tasdevice_dev_update_bits()
210 struct regmap *map = tas_priv->regmap; in tasdevice_dev_update_bits()
220 dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret); in tasdevice_dev_update_bits()
222 dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__, in tasdevice_dev_update_bits()
224 ret = -EINVAL; in tasdevice_dev_update_bits()
236 tas_priv = devm_kzalloc(&i2c->dev, sizeof(*tas_priv), GFP_KERNEL); in tasdevice_kzalloc()
239 tas_priv->dev = &i2c->dev; in tasdevice_kzalloc()
240 tas_priv->client = (void *)i2c; in tasdevice_kzalloc()
250 if (tas_dev->reset) { in tas2781_reset()
251 gpiod_set_value_cansleep(tas_dev->reset, 0); in tas2781_reset()
253 gpiod_set_value_cansleep(tas_dev->reset, 1); in tas2781_reset()
255 for (i = 0; i < tas_dev->ndev; i++) { in tas2781_reset()
260 dev_err(tas_dev->dev, in tas2781_reset()
278 mutex_lock(&tas_priv->codec_lock); in tascodec_init()
280 scnprintf(tas_priv->rca_binaryname, 64, "%sRCA%d.bin", in tascodec_init()
281 tas_priv->dev_name, tas_priv->ndev); in tascodec_init()
282 crc8_populate_msb(tas_priv->crc8_lkp_tbl, TASDEVICE_CRC8_POLYNOMIAL); in tascodec_init()
283 tas_priv->codec = codec; in tascodec_init()
285 tas_priv->rca_binaryname, tas_priv->dev, GFP_KERNEL, tas_priv, in tascodec_init()
288 dev_err(tas_priv->dev, "request_firmware_nowait err:0x%08x\n", in tascodec_init()
292 mutex_unlock(&tas_priv->codec_lock); in tascodec_init()
302 tas_priv->regmap = devm_regmap_init_i2c(tas_priv->client, in tasdevice_init()
304 if (IS_ERR(tas_priv->regmap)) { in tasdevice_init()
305 ret = PTR_ERR(tas_priv->regmap); in tasdevice_init()
306 dev_err(tas_priv->dev, "Failed to allocate register map: %d\n", in tasdevice_init()
311 tas_priv->cur_prog = -1; in tasdevice_init()
312 tas_priv->cur_conf = -1; in tasdevice_init()
314 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_init()
315 tas_priv->tasdevice[i].cur_book = -1; in tasdevice_init()
316 tas_priv->tasdevice[i].cur_prog = -1; in tasdevice_init()
317 tas_priv->tasdevice[i].cur_conf = -1; in tasdevice_init()
320 mutex_init(&tas_priv->codec_lock); in tasdevice_init()
336 tas_dt = &(prog->dev_data); in tasdev_dsp_prog_blk_remove()
338 if (!tas_dt->dev_blks) in tasdev_dsp_prog_blk_remove()
341 for (i = 0; i < tas_dt->nr_blk; i++) { in tasdev_dsp_prog_blk_remove()
342 blk = &(tas_dt->dev_blks[i]); in tasdev_dsp_prog_blk_remove()
343 kfree(blk->data); in tasdev_dsp_prog_blk_remove()
345 kfree(tas_dt->dev_blks); in tasdev_dsp_prog_blk_remove()
365 tas_dt = &(cfg->dev_data); in tasdev_dsp_cfg_blk_remove()
367 if (!tas_dt->dev_blks) in tasdev_dsp_cfg_blk_remove()
370 for (i = 0; i < tas_dt->nr_blk; i++) { in tasdev_dsp_cfg_blk_remove()
371 blk = &(tas_dt->dev_blks[i]); in tasdev_dsp_cfg_blk_remove()
372 kfree(blk->data); in tasdev_dsp_cfg_blk_remove()
374 kfree(tas_dt->dev_blks); in tasdev_dsp_cfg_blk_remove()
391 struct tasdevice_fw *tas_fmw = tas_dev->fmw; in tasdevice_dsp_remove()
393 if (!tas_dev->fmw) in tasdevice_dsp_remove()
396 if (tas_fmw->programs) in tasdevice_dsp_remove()
397 tasdev_dsp_prog_remove(tas_fmw->programs, in tasdevice_dsp_remove()
398 tas_fmw->nr_programs); in tasdevice_dsp_remove()
399 if (tas_fmw->configs) in tasdevice_dsp_remove()
400 tasdev_dsp_cfg_remove(tas_fmw->configs, in tasdevice_dsp_remove()
401 tas_fmw->nr_configurations); in tasdevice_dsp_remove()
403 tas_dev->fmw = NULL; in tasdevice_dsp_remove()
409 if (gpio_is_valid(tas_priv->irq_info.irq_gpio)) in tasdevice_remove()
410 gpio_free(tas_priv->irq_info.irq_gpio); in tasdevice_remove()
411 kfree(tas_priv->acpi_subsystem_id); in tasdevice_remove()
412 mutex_destroy(&tas_priv->codec_lock); in tasdevice_remove()
421 val = max - val; in tasdevice_clamp()
430 unsigned int invert = mc->invert; in tasdevice_amp_putvol()
432 int max = mc->max; in tasdevice_amp_putvol()
436 mask = (1 << fls(max)) - 1; in tasdevice_amp_putvol()
437 mask <<= mc->shift; in tasdevice_amp_putvol()
438 val = tasdevice_clamp(ucontrol->value.integer.value[0], max, invert); in tasdevice_amp_putvol()
439 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_amp_putvol()
441 mc->reg, mask, (unsigned int)(val << mc->shift)); in tasdevice_amp_putvol()
445 dev_err(tas_priv->dev, "set AMP vol error in dev %d\n", i); in tasdevice_amp_putvol()
449 return (err_cnt == tas_priv->ndev) ? 0 : 1; in tasdevice_amp_putvol()
456 unsigned int invert = mc->invert; in tasdevice_amp_getvol()
458 int max = mc->max; in tasdevice_amp_getvol()
463 ret = tasdevice_dev_read(tas_priv, 0, mc->reg, &val); in tasdevice_amp_getvol()
465 dev_err(tas_priv->dev, "%s, get AMP vol error\n", __func__); in tasdevice_amp_getvol()
469 mask = (1 << fls(max)) - 1; in tasdevice_amp_getvol()
470 mask <<= mc->shift; in tasdevice_amp_getvol()
471 val = (val & mask) >> mc->shift; in tasdevice_amp_getvol()
473 ucontrol->value.integer.value[0] = val; in tasdevice_amp_getvol()
484 unsigned int invert = mc->invert; in tasdevice_digital_putvol()
485 int max = mc->max; in tasdevice_digital_putvol()
490 val = tasdevice_clamp(ucontrol->value.integer.value[0], max, invert); in tasdevice_digital_putvol()
492 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_digital_putvol()
493 ret = tasdevice_dev_write(tas_priv, i, mc->reg, in tasdevice_digital_putvol()
498 dev_err(tas_priv->dev, in tasdevice_digital_putvol()
503 return (err_cnt == tas_priv->ndev) ? 0 : 1; in tasdevice_digital_putvol()
511 unsigned int invert = mc->invert; in tasdevice_digital_getvol()
512 int max = mc->max; in tasdevice_digital_getvol()
516 ret = tasdevice_dev_read(tas_priv, 0, mc->reg, &val); in tasdevice_digital_getvol()
518 dev_err(tas_priv->dev, "%s, get digital vol error\n", in tasdevice_digital_getvol()
524 ucontrol->value.integer.value[0] = val; in tasdevice_digital_getvol()
533 MODULE_AUTHOR("Shenghao Ding, TI, <shenghao-ding@ti.com>");