Lines Matching +full:dai +full:- +full:tdm +full:- +full:slot +full:- +full:rx +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0-only
104 return -EINVAL; in rtq9128_i2c_write()
108 return i2c_smbus_write_i2c_block_data(i2c, reg, rg_size, data + count - rg_size); in rtq9128_i2c_write()
123 return -EINVAL; in rtq9128_i2c_read()
131 return -EIO; in rtq9128_i2c_read()
133 memset(val_buf, 0, val_size - rg_size); in rtq9128_i2c_read()
134 memcpy(val_buf + val_size - rg_size, data_tmp, rg_size); in rtq9128_i2c_read()
218 static const DECLARE_TLV_DB_SCALE(dig_tlv, -10375, 25, 0);
221 0, 3, TLV_DB_SCALE_ITEM(-600, 600, 0),
289 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in rtq9128_dac_power_event()
290 unsigned int shift, mask; in rtq9128_dac_power_event() local
293 dev_dbg(comp->dev, "%s: %s event %d\n", __func__, w->name, event); in rtq9128_dac_power_event()
304 mask = RTQ9128_CHSTAT_VAL_MASK << shift; in rtq9128_dac_power_event()
307 ret = snd_soc_component_write_field(comp, RTQ9128_REG_STATE_CTRL, mask, in rtq9128_dac_power_event()
395 ret = pm_runtime_resume_and_get(comp->dev); in rtq9128_component_probe()
397 dev_err(comp->dev, "Failed to resume device (%d)\n", ret); in rtq9128_component_probe()
419 ret = snd_soc_component_write(comp, curr->reg, curr->val); in rtq9128_component_probe()
424 pm_runtime_mark_last_busy(comp->dev); in rtq9128_component_probe()
425 pm_runtime_put(comp->dev); in rtq9128_component_probe()
442 static int rtq9128_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) in rtq9128_dai_set_fmt() argument
444 struct rtq9128_data *data = snd_soc_dai_get_drvdata(dai); in rtq9128_dai_set_fmt()
445 struct device *dev = dai->dev; in rtq9128_dai_set_fmt()
452 return -EINVAL; in rtq9128_dai_set_fmt()
455 /* Store here and will be used in runtime hw_params for DAI format setting */ in rtq9128_dai_set_fmt()
456 data->daifmt = fmt; in rtq9128_dai_set_fmt()
461 static int rtq9128_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, in rtq9128_dai_set_tdm_slot() argument
464 struct rtq9128_data *data = snd_soc_dai_get_drvdata(dai); in rtq9128_dai_set_tdm_slot()
465 struct snd_soc_component *comp = dai->component; in rtq9128_dai_set_tdm_slot()
466 struct device *dev = dai->dev; in rtq9128_dai_set_tdm_slot()
467 unsigned int mask, start_loc, srcin_select; in rtq9128_dai_set_tdm_slot() local
470 dev_dbg(dev, "%s: slot %d slot_width %d, tx/rx mask 0x%x 0x%x\n", __func__, slots, in rtq9128_dai_set_tdm_slot()
474 dev_err(dev, "Invalid slot numbers (%d) or width (%d)\n", slots, slot_width); in rtq9128_dai_set_tdm_slot()
475 return -EINVAL; in rtq9128_dai_set_tdm_slot()
482 return -EINVAL; in rtq9128_dai_set_tdm_slot()
487 dev_err(dev, "Invalid tx/rx mask (0x%x/0x%x)\n", tx_mask, rx_mask); in rtq9128_dai_set_tdm_slot()
488 return -EINVAL; in rtq9128_dai_set_tdm_slot()
491 for (mask = tx_mask, i = 0; i < 4 && mask; i++) { in rtq9128_dai_set_tdm_slot()
492 start_loc = (ffs(mask) - 1) * slot_width / 8; in rtq9128_dai_set_tdm_slot()
493 mask &= ~BIT(ffs(mask) - 1); in rtq9128_dai_set_tdm_slot()
502 for (mask = rx_mask, i = 0; i < 4 && mask; i++) { in rtq9128_dai_set_tdm_slot()
503 start_loc = (ffs(mask) - 1) * slot_width / 8; in rtq9128_dai_set_tdm_slot()
504 mask &= ~BIT(ffs(mask) - 1); in rtq9128_dai_set_tdm_slot()
513 srcin_select = data->tdm_input_data2_select ? RTQ9128_TDMSRCIN_MASK : 0; in rtq9128_dai_set_tdm_slot()
517 dev_err(dev, "Failed to configure TDM source input select\n"); in rtq9128_dai_set_tdm_slot()
521 data->tdm_slots = slots; in rtq9128_dai_set_tdm_slot()
522 data->tdm_slot_width = slot_width; in rtq9128_dai_set_tdm_slot()
528 struct snd_soc_dai *dai) in rtq9128_dai_hw_params() argument
530 struct rtq9128_data *data = snd_soc_dai_get_drvdata(dai); in rtq9128_dai_hw_params()
532 struct snd_soc_component *comp = dai->component; in rtq9128_dai_hw_params()
533 struct device *dev = dai->dev; in rtq9128_dai_hw_params()
539 fmtval = FIELD_GET(SND_SOC_DAIFMT_FORMAT_MASK, data->daifmt); in rtq9128_dai_hw_params()
540 if (data->tdm_slots && fmtval != SND_SOC_DAIFMT_DSP_A && fmtval != SND_SOC_DAIFMT_DSP_B) { in rtq9128_dai_hw_params()
541 dev_err(dev, "TDM is used, format only support DSP_A or DSP_B\n"); in rtq9128_dai_hw_params()
542 return -EINVAL; in rtq9128_dai_hw_params()
556 audfmt = data->tdm_slots ? 12 : 11; in rtq9128_dai_hw_params()
559 audfmt = data->tdm_slots ? 4 : 3; in rtq9128_dai_hw_params()
563 return -EINVAL; in rtq9128_dai_hw_params()
582 return -EINVAL; in rtq9128_dai_hw_params()
587 if (data->tdm_slots) { in rtq9128_dai_hw_params()
588 if (slot_width > data->tdm_slot_width) { in rtq9128_dai_hw_params()
589 dev_err(dev, "slot width is larger than TDM slot width\n"); in rtq9128_dai_hw_params()
590 return -EINVAL; in rtq9128_dai_hw_params()
594 bitrate = data->tdm_slots * data->tdm_slot_width * params_rate(param); in rtq9128_dai_hw_params()
597 return -EINVAL; in rtq9128_dai_hw_params()
600 /* If TDM is used, configure slot width as TDM slot witdh */ in rtq9128_dai_hw_params()
601 slot_width = data->tdm_slot_width; in rtq9128_dai_hw_params()
615 dev_err(dev, "Unsupported slot width (%d)\n", slot_width); in rtq9128_dai_hw_params()
616 return -EINVAL; in rtq9128_dai_hw_params()
631 static int rtq9128_dai_mute_stream(struct snd_soc_dai *dai, int mute, int stream) in rtq9128_dai_mute_stream() argument
633 struct snd_soc_component *comp = dai->component; in rtq9128_dai_mute_stream()
634 struct device *dev = dai->dev; in rtq9128_dai_mute_stream()
657 .name = "rtq9128-aif",
679 struct device *dev = &i2c->dev; in rtq9128_probe()
687 return -ENOMEM; in rtq9128_probe()
689 data->enable = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH); in rtq9128_probe()
690 if (IS_ERR(data->enable)) in rtq9128_probe()
691 return dev_err_probe(dev, PTR_ERR(data->enable), "Failed to get 'enable' gpio\n"); in rtq9128_probe()
692 else if (data->enable) in rtq9128_probe()
695 data->tdm_input_data2_select = device_property_read_bool(dev, in rtq9128_probe()
696 "richtek,tdm-input-data2-select"); in rtq9128_probe()
721 return dev_err_probe(dev, -ENODEV, "Vendor ID not match (0x%x)\n", venid); in rtq9128_probe()
738 if (!data->enable) in rtq9128_pm_runtime_suspend()
741 gpiod_set_value_cansleep(data->enable, 0); in rtq9128_pm_runtime_suspend()
754 /* If 'enable' gpio not specified, change all channels to default Hi-Z */ in rtq9128_pm_runtime_resume()
755 if (!data->enable) in rtq9128_pm_runtime_resume()
758 gpiod_set_value_cansleep(data->enable, 1); in rtq9128_pm_runtime_resume()