Lines Matching +full:spi +full:- +full:present +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0-or-later
57 /* chip address on SPI bus */
65 /* GPIO0 - O - DATA0, def. 0 */
67 /* GPIO1 - I/O - DATA1, Jack Detect Input0 (0:present, 1:missing), def. 1 */
69 /* GPIO2 - I/O - DATA2, Jack Detect Input1 (0:present, 1:missing), def. 1 */
71 /* GPIO3 - I/O - DATA3, def. 1 */
73 /* GPIO4 - I/O - DATA4, SPI CDTO, def. 1 */
75 /* GPIO5 - I/O - DATA5, SPI CCLK, def. 1 */
77 /* GPIO6 - I/O - DATA6, Cable Detect Input (0:detected, 1:not detected */
79 /* GPIO7 - I/O - DATA7, Device Detect Input (0:detected, 1:not detected */
81 /* GPIO8 - O - CPLD Chip Select, def. 1 */
83 /* GPIO9 - O - CPLD register read/write (0:write, 1:read), def. 0 */
85 /* GPIO10 - O - SPI Chip Select for CODEC#0, def. 1 */
87 /* GPIO11 - O - SPI Chip Select for CODEC#1, def. 1 */
89 /* GPIO12 - O - Ex. Register Output Enable (0:enable, 1:disable), def. 1,
92 /* GPIO13 - O - Ex. Register0 Chip Select for System Control Register,
95 /* GPIO14 - O - Ex. Register1 Chip Select for Monitor Control Register,
119 /* Analog input 3/4 Source Select (0:line, 1:hi-z) */
151 /* Coaxial Output Source (IS-Link) (0:SPDIF, 1:I2S) */
169 /* external clock - SPDIF */
171 /* external clock - WordClock 1xfs */
173 /* external clock - WordClock 256xfs */
202 if (value & (1 << (31-(i*8 + j))))
218 * Initial setup of the conversion array GPIO <-> rate
233 .mask = 0,
263 struct snd_ice1712 *ice = ak->private_data[0];
267 /*dev_dbg(ice->card->dev, "Writing to AK4620: chip=%d, addr=0x%x,
269 orig_dir = ice->gpio.get_dir(ice);
270 ice->gpio.set_dir(ice, orig_dir | GPIO_SPI_ALL);
271 /* set mask - only SPI bits */
272 ice->gpio.set_mask(ice, ~GPIO_SPI_ALL);
274 tmp = ice->gpio.get_data(ice);
277 ice->gpio.set_data(ice, tmp);
285 ice->gpio.set_data(ice, tmp);
291 for (idx = 15; idx >= 0; idx--) {
294 ice->gpio.set_data(ice, tmp);
301 ice->gpio.set_data(ice, tmp);
305 ice->gpio.set_data(ice, tmp);
310 ice->gpio.set_data(ice, tmp);
313 /* return all gpios to non-writable */
314 ice->gpio.set_mask(ice, 0xffffff);
316 ice->gpio.set_dir(ice, orig_dir);
320 unsigned char mask, unsigned char value)
324 for (chip = 0; chip < ak->num_chips; chip++) {
327 tmp &= ~mask;
341 if (rate == 0) /* no hint - S/PDIF input is master or the new spdif
345 /* adjust DFS on codecs - see datasheet */
377 .num_dacs = 4, /* DAC1 - Output 12
379 .num_adcs = 4, /* ADC1 - Input 12
399 guard(mutex)(&ice->gpio_mutex);
403 ice->gpio.set_dir(ice, tmp);
404 /* mask - writable bits */
405 ice->gpio.set_mask(ice, ~(tmp));
407 tmp = ice->gpio.get_data(ice);
410 ice->gpio.set_data(ice, tmp);
414 ice->gpio.set_data(ice, tmp);
418 ice->gpio.set_data(ice, tmp);
422 ice->gpio.set_data(ice, tmp);
427 ice->gpio.set_data(ice, tmp);
428 /* mask - immutable bits */
429 ice->gpio.set_mask(ice, 0xffffff);
430 /* outputs only 8-15 */
431 ice->gpio.set_dir(ice, 0x00ff00);
436 struct qtet_spec *spec = ice->spec;
437 return spec->scr;
442 struct qtet_spec *spec = ice->spec;
443 return spec->mcr;
448 struct qtet_spec *spec = ice->spec;
449 return spec->cpld;
454 struct qtet_spec *spec = ice->spec;
456 spec->scr = val;
461 struct qtet_spec *spec = ice->spec;
463 spec->mcr = val;
468 struct qtet_spec *spec = ice->spec;
470 spec->cpld = val;
476 struct snd_ice1712 *ice = entry->private_data;
489 snd_card_ro_proc_new(ice->card, "quartet", ice, proc_regs_read);
498 ucontrol->value.integer.value[0] = (val) ? 0 : 1;
508 if (ucontrol->value.integer.value[0]) {
511 /* un-smuting DAC */
520 struct snd_akm4xxx *ak = ice->akm;
534 {"Line In 1/2", "Mic", "Mic + Low-cut"};
555 /* BUG - no other combinations allowed */
559 ucontrol->value.integer.value[0] = result;
570 tmp = ucontrol->value.integer.value[0];
614 ucontrol->value.integer.value[0] = val ? 1 : 0;
624 if (ucontrol->value.integer.value[0] /* phantom on requested */
633 } else if (!ucontrol->value.integer.value[0] && (old & SCR_PHP_V)) {
662 PRIV_ENUM2(AIN34_SEL, SCR_AIN34_SEL, scr, "Line In 3/4", "Hi-Z"),
676 qtet_privates[kcontrol->private_value];
685 qtet_privates[kcontrol->private_value];
687 ucontrol->value.integer.value[0] =
696 qtet_privates[kcontrol->private_value];
700 if (ucontrol->value.integer.value[0])
766 DECLARE_TLV_DB_SCALE(qtet_master_db_scale, -6350, 50, 1);
770 struct qtet_spec *spec = ice->spec;
777 err = snd_ctl_add(ice->card,
787 return -ENOMEM;
788 err = snd_ctl_add(ice->card, vmaster);
791 err = snd_ctl_add_followers(ice->card, vmaster, follower_vols);
795 return snd_ak4113_build(spec->ak4113,
796 ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
831 /* switching ice1724 to external clock - supplied by ext. circuits */
838 /* dev_dbg(ice->card->dev, "QT - set_rate: old %x, new %x\n",
850 /* setting clock to external - SPDIF */
883 /* checking only rate/clock-related bits */
887 result = -1;
912 struct snd_ice1712 *ice = ak4113->change_callback_private;
918 /* dev_dbg(ice->card->dev, "ak4113 - input rate changed to %d\n",
920 qtet_akm_set_rate_val(ice->akm, rate);
925 * If clock slaved to SPDIF-IN, setting runtime rate
931 struct qtet_spec *spec = ice->spec;
932 struct snd_pcm_runtime *runtime = substream->runtime;
939 rate = snd_ak4113_external_rate(spec->ak4113);
940 if (rate >= runtime->hw.rate_min && rate <= runtime->hw.rate_max) {
941 runtime->hw.rate_min = rate;
942 runtime->hw.rate_max = rate;
968 /* switching ice1724 to external clock - supplied by ext. circuits */
974 return -ENOMEM;
976 ice->hw_rates = &qtet_rates_info;
977 ice->is_spdif_master = qtet_is_spdif_master;
978 ice->get_rate = qtet_get_rate;
979 ice->set_rate = qtet_set_rate;
980 ice->set_mclk = qtet_set_mclk;
981 ice->set_spdif_clock = qtet_set_spdif_clock;
982 ice->get_spdif_master_type = qtet_get_spdif_master_type;
983 ice->ext_clock_names = ext_clock_names;
984 ice->ext_clock_count = ARRAY_SIZE(ext_clock_names);
985 /* since Qtet can detect correct SPDIF-in rate, all streams can be
987 ice->spdif.ops.open = ice->pro_open = qtet_spdif_in_open;
988 ice->spec = spec;
1005 ice->num_total_dacs = 2;
1006 ice->num_total_adcs = 2;
1008 ice->akm = kcalloc(2, sizeof(struct snd_akm4xxx), GFP_KERNEL);
1009 ak = ice->akm;
1011 return -ENOMEM;
1013 ice->akm_codecs = 1;
1017 err = snd_ak4113_create(ice->card,
1021 ice, &spec->ak4113);
1025 spec->ak4113->change_callback = qtet_ak4113_change;
1026 spec->ak4113->change_callback_private = ice;
1029 spec->ak4113->check_flags = 0;
1042 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, in, out-ext */
1043 [ICE_EEP2_GPIO_DIR] = 0x00, /* 0-7 inputs, switched to output
1045 [ICE_EEP2_GPIO_DIR1] = 0xff, /* 8-15 outputs */