21 #include <linux/kernel.h>
33 switch (coded & 0x3) {
34 case 0: freq = 48000;
break;
35 case 1: freq = 44100;
break;
36 case 2: freq = 32000;
break;
41 switch (coded & 0x1c) {
44 case (1 << 2): freq *= 2;
break;
45 case (2 << 2): freq *= 4;
break;
46 case (5 << 2): freq /= 2;
break;
47 case (6 << 2): freq /= 4;
break;
52 switch (coded & 0x60) {
54 case (1 << 5): freq = (freq * 999) / 1000;
break;
55 case (2 << 5): freq = (freq * 1001) / 1000;
break;
65 #define LOLA_MAXFREQ_AT_GRANULARITY_MIN 48000
66 #define LOLA_MAXFREQ_AT_GRANULARITY_BELOW_MAX 96000
68 static bool check_gran_clock_compatibility(
struct lola *
chip,
98 if (chip->audio_in_alloc_mask || chip->audio_out_alloc_mask)
101 if (!check_gran_clock_compatibility(chip, val,
102 chip->
clock.cur_freq))
126 int i,
j, nitems, nb_verbs,
idx, idx_list;
135 if ((val & 0xfff00000) != 0x01f00000) {
141 chip->
clock.items = val & 0xff;
142 snd_printdd(
"clock_list nid=%x, entries=%d\n", nid,
150 nitems = chip->
clock.items;
151 nb_verbs = (nitems + 3) / 4;
154 for (i = 0; i < nb_verbs; i++) {
156 unsigned short items[4];
159 idx, 0, &val, &res_ex);
165 items[0] = val & 0xfff;
166 items[1] = (val >> 16) & 0xfff;
167 items[2] = res_ex & 0xfff;
168 items[3] = (res_ex >> 16) & 0xfff;
170 for (j = 0; j < 4; j++) {
171 unsigned char type = items[
j] >> 8;
172 unsigned int freq = items[
j] & 0xff;
174 bool add_clock =
true;
177 if (freq < chip->sample_rate_min)
179 else if (freq == 48000) {
180 chip->
clock.cur_index = idx_list;
181 chip->
clock.cur_freq = 48000;
182 chip->
clock.cur_valid =
true;
186 if (freq < chip->sample_rate_min)
196 sc = &chip->
clock.sample_clock[idx_list];
201 chip->
clock.idx_lookup[idx_list] =
idx;
240 chip->
clock.idx_lookup[idx],
265 if (chip->
clock.sample_clock[chip->
clock.cur_index].type !=
268 chip->
clock.cur_valid = (val & 0x100) != 0;
278 if (idx == chip->
clock.cur_index) {
280 freq = chip->
clock.cur_freq;
281 valid = chip->
clock.cur_valid;
282 }
else if (chip->
clock.sample_clock[idx].type ==
285 freq = chip->
clock.sample_clock[
idx].freq;
292 if (!check_gran_clock_compatibility(chip, chip->
granularity, freq))
295 if (idx != chip->
clock.cur_index) {
302 chip->
clock.cur_valid =
true;
311 if (chip->
clock.cur_freq == rate && chip->
clock.cur_valid)
314 for (i = 0; i < chip->
clock.items; i++) {
316 chip->
clock.sample_clock[i].freq == rate)
319 if (i >= chip->
clock.items)