Lines Matching refs:chip
55 static bool check_gran_clock_compatibility(struct lola *chip,
59 if (!chip->granularity)
76 int lola_set_granularity(struct lola *chip, unsigned int val, bool force)
81 if (val == chip->granularity)
85 if (chip->audio_in_alloc_mask || chip->audio_out_alloc_mask)
88 if (!check_gran_clock_compatibility(chip, val,
89 chip->clock.cur_freq))
93 chip->granularity = val;
97 err = lola_codec_write(chip, 1, LOLA_VERB_SET_GRANULARITY_STEPS,
103 return lola_codec_flush(chip);
110 int lola_init_clock_widget(struct lola *chip, int nid)
116 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val);
118 dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid);
123 dev_dbg(chip->card->dev, "No valid clock widget\n");
127 chip->clock.nid = nid;
128 chip->clock.items = val & 0xff;
129 dev_dbg(chip->card->dev, "clock_list nid=%x, entries=%d\n", nid,
130 chip->clock.items);
131 if (chip->clock.items > MAX_SAMPLE_CLOCK_COUNT) {
132 dev_err(chip->card->dev, "CLOCK_LIST too big: %d\n",
133 chip->clock.items);
137 nitems = chip->clock.items;
145 err = lola_codec_read(chip, nid, LOLA_VERB_GET_CLOCK_LIST,
148 dev_err(chip->card->dev, "Can't read CLOCK_LIST\n");
164 if (freq < chip->sample_rate_min)
167 chip->clock.cur_index = idx_list;
168 chip->clock.cur_freq = 48000;
169 chip->clock.cur_valid = true;
173 if (freq < chip->sample_rate_min)
183 sc = &chip->clock.sample_clock[idx_list];
188 chip->clock.idx_lookup[idx_list] = idx;
191 chip->clock.items--;
201 int lola_enable_clock_events(struct lola *chip)
206 err = lola_codec_read(chip, chip->clock.nid,
213 dev_warn(chip->card->dev, "error in enable_clock_events %d\n",
220 int lola_set_clock_index(struct lola *chip, unsigned int idx)
225 err = lola_codec_read(chip, chip->clock.nid,
227 chip->clock.idx_lookup[idx],
232 dev_warn(chip->card->dev, "error in set_clock %d\n", res);
238 bool lola_update_ext_clock_freq(struct lola *chip, unsigned int val)
252 if (chip->clock.sample_clock[chip->clock.cur_index].type !=
254 chip->clock.cur_freq = lola_sample_rate_convert(val & 0x7f);
255 chip->clock.cur_valid = (val & 0x100) != 0;
260 int lola_set_clock(struct lola *chip, int idx)
265 if (idx == chip->clock.cur_index) {
267 freq = chip->clock.cur_freq;
268 valid = chip->clock.cur_valid;
269 } else if (chip->clock.sample_clock[idx].type ==
272 freq = chip->clock.sample_clock[idx].freq;
279 if (!check_gran_clock_compatibility(chip, chip->granularity, freq))
282 if (idx != chip->clock.cur_index) {
283 int err = lola_set_clock_index(chip, idx);
287 chip->clock.cur_index = idx;
288 chip->clock.cur_freq = freq;
289 chip->clock.cur_valid = true;
294 int lola_set_sample_rate(struct lola *chip, int rate)
298 if (chip->clock.cur_freq == rate && chip->clock.cur_valid)
301 for (i = 0; i < chip->clock.items; i++) {
302 if (chip->clock.sample_clock[i].type == LOLA_CLOCK_TYPE_INTERNAL &&
303 chip->clock.sample_clock[i].freq == rate)
306 if (i >= chip->clock.items)
308 return lola_set_clock(chip, i);