Lines Matching refs:ctl

461 static int cs_dsp_coeff_base_reg(struct cs_dsp_coeff_ctl *ctl, unsigned int *reg,
467 struct cs_dsp_coeff_ctl *ctl;
470 list_for_each_entry(ctl, &dsp->ctl_list, list) {
471 cs_dsp_coeff_base_reg(ctl, &reg, 0);
473 ctl->subname_len, ctl->subname, ctl->len,
474 cs_dsp_mem_region_name(ctl->alg_region.type),
475 ctl->offset, reg, ctl->fw_name, ctl->alg_region.alg, ctl->type,
476 ctl->flags & WMFW_CTL_FLAG_VOLATILE ? 'V' : '-',
477 ctl->flags & WMFW_CTL_FLAG_SYS ? 'S' : '-',
478 ctl->flags & WMFW_CTL_FLAG_READABLE ? 'R' : '-',
479 ctl->flags & WMFW_CTL_FLAG_WRITEABLE ? 'W' : '-',
480 ctl->enabled ? "enabled" : "disabled",
481 ctl->set ? "dirty" : "clean");
651 static int cs_dsp_coeff_base_reg(struct cs_dsp_coeff_ctl *ctl, unsigned int *reg,
654 const struct cs_dsp_alg_region *alg_region = &ctl->alg_region;
655 struct cs_dsp *dsp = ctl->dsp;
665 *reg = dsp->ops->region_to_reg(mem, ctl->alg_region.base + ctl->offset + off);
672 * @ctl: pointer to acked coefficient control
682 int cs_dsp_coeff_write_acked_control(struct cs_dsp_coeff_ctl *ctl, unsigned int event_id)
684 struct cs_dsp *dsp = ctl->dsp;
694 ret = cs_dsp_coeff_base_reg(ctl, &reg, 0);
699 event_id, ctl->alg_region.alg,
700 cs_dsp_mem_region_name(ctl->alg_region.type), ctl->offset);
739 reg, ctl->alg_region.alg,
740 cs_dsp_mem_region_name(ctl->alg_region.type),
741 ctl->offset);
747 static int cs_dsp_coeff_write_ctrl_raw(struct cs_dsp_coeff_ctl *ctl,
750 struct cs_dsp *dsp = ctl->dsp;
755 ret = cs_dsp_coeff_base_reg(ctl, &reg, off);
780 * @ctl: pointer to coefficient control
789 int cs_dsp_coeff_write_ctrl(struct cs_dsp_coeff_ctl *ctl,
794 if (!ctl)
797 lockdep_assert_held(&ctl->dsp->pwr_lock);
799 if (len + off * sizeof(u32) > ctl->len)
802 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) {
804 } else if (buf != ctl->cache) {
805 if (memcmp(ctl->cache + off * sizeof(u32), buf, len))
806 memcpy(ctl->cache + off * sizeof(u32), buf, len);
811 ctl->set = 1;
812 if (ctl->enabled && ctl->dsp->running)
813 ret = cs_dsp_coeff_write_ctrl_raw(ctl, off, buf, len);
824 * @ctl: pointer to coefficient control
833 int cs_dsp_coeff_lock_and_write_ctrl(struct cs_dsp_coeff_ctl *ctl,
836 struct cs_dsp *dsp = ctl->dsp;
842 ret = cs_dsp_coeff_write_ctrl(ctl, off, buf, len);
849 static int cs_dsp_coeff_read_ctrl_raw(struct cs_dsp_coeff_ctl *ctl,
852 struct cs_dsp *dsp = ctl->dsp;
857 ret = cs_dsp_coeff_base_reg(ctl, &reg, off);
882 * @ctl: pointer to coefficient control
891 int cs_dsp_coeff_read_ctrl(struct cs_dsp_coeff_ctl *ctl,
896 if (!ctl)
899 lockdep_assert_held(&ctl->dsp->pwr_lock);
901 if (len + off * sizeof(u32) > ctl->len)
904 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) {
905 if (ctl->enabled && ctl->dsp->running)
906 return cs_dsp_coeff_read_ctrl_raw(ctl, off, buf, len);
910 if (!ctl->flags && ctl->enabled && ctl->dsp->running)
911 ret = cs_dsp_coeff_read_ctrl_raw(ctl, 0, ctl->cache, ctl->len);
913 if (buf != ctl->cache)
914 memcpy(buf, ctl->cache + off * sizeof(u32), len);
923 * @ctl: pointer to coefficient control
932 int cs_dsp_coeff_lock_and_read_ctrl(struct cs_dsp_coeff_ctl *ctl,
935 struct cs_dsp *dsp = ctl->dsp;
941 ret = cs_dsp_coeff_read_ctrl(ctl, off, buf, len);
950 struct cs_dsp_coeff_ctl *ctl;
953 list_for_each_entry(ctl, &dsp->ctl_list, list) {
954 if (!ctl->enabled || ctl->set)
956 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE)
964 if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) {
965 ret = cs_dsp_coeff_read_ctrl_raw(ctl, 0, ctl->cache, ctl->len);
976 struct cs_dsp_coeff_ctl *ctl;
979 list_for_each_entry(ctl, &dsp->ctl_list, list) {
980 if (!ctl->enabled)
982 if (ctl->set && !(ctl->flags & WMFW_CTL_FLAG_VOLATILE)) {
983 ret = cs_dsp_coeff_write_ctrl_raw(ctl, 0, ctl->cache,
984 ctl->len);
996 struct cs_dsp_coeff_ctl *ctl;
999 list_for_each_entry(ctl, &dsp->ctl_list, list) {
1000 if (ctl->type != WMFW_CTL_TYPE_HOSTEVENT)
1003 if (!ctl->enabled)
1006 ret = cs_dsp_coeff_write_acked_control(ctl, event);
1010 event, ctl->alg_region.alg, ret);
1014 static void cs_dsp_free_ctl_blk(struct cs_dsp_coeff_ctl *ctl)
1016 kfree(ctl->cache);
1017 kfree(ctl->subname);
1018 kfree(ctl);
1027 struct cs_dsp_coeff_ctl *ctl;
1030 list_for_each_entry(ctl, &dsp->ctl_list, list) {
1031 if (ctl->fw_name == dsp->fw_name &&
1032 ctl->alg_region.alg == alg_region->alg &&
1033 ctl->alg_region.type == alg_region->type) {
1034 if ((!subname && !ctl->subname) ||
1035 (subname && (ctl->subname_len == subname_len) &&
1036 !strncmp(ctl->subname, subname, ctl->subname_len))) {
1037 if (!ctl->enabled)
1038 ctl->enabled = 1;
1044 ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
1045 if (!ctl)
1048 ctl->fw_name = dsp->fw_name;
1049 ctl->alg_region = *alg_region;
1051 ctl->subname_len = subname_len;
1052 ctl->subname = kasprintf(GFP_KERNEL, "%.*s", subname_len, subname);
1053 if (!ctl->subname) {
1058 ctl->enabled = 1;
1059 ctl->set = 0;
1060 ctl->dsp = dsp;
1062 ctl->flags = flags;
1063 ctl->type = type;
1064 ctl->offset = offset;
1065 ctl->len = len;
1066 ctl->cache = kzalloc(ctl->len, GFP_KERNEL);
1067 if (!ctl->cache) {
1072 list_add(&ctl->list, &dsp->ctl_list);
1075 ret = dsp->client_ops->control_add(ctl);
1083 list_del(&ctl->list);
1084 kfree(ctl->cache);
1086 kfree(ctl->subname);
1088 kfree(ctl);
1598 struct cs_dsp_coeff_ctl *ctl;
1600 list_for_each_entry(ctl, &dsp->ctl_list, list) {
1601 if (ctl->fw_name == dsp->fw_name &&
1602 alg_region->alg == ctl->alg_region.alg &&
1603 alg_region->type == ctl->alg_region.type) {
1604 ctl->alg_region.base = alg_region->base;
2423 struct cs_dsp_coeff_ctl *ctl;
2440 list_for_each_entry(ctl, &dsp->ctl_list, list)
2441 ctl->enabled = 0;
2700 struct cs_dsp_coeff_ctl *ctl;
2714 list_for_each_entry(ctl, &dsp->ctl_list, list)
2715 ctl->enabled = 0;
2935 struct cs_dsp_coeff_ctl *ctl;
2938 ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
2941 dsp->client_ops->control_remove(ctl);
2943 list_del(&ctl->list);
2944 cs_dsp_free_ctl_blk(ctl);