18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * bebob_terratec.c - a part of driver for BeBoB based devices
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2013-2014 Takashi Sakamoto
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include "./bebob.h"
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cistatic const enum snd_bebob_clock_type phase88_rack_clk_src_types[] = {
118c2ecf20Sopenharmony_ci	SND_BEBOB_CLOCK_TYPE_INTERNAL,
128c2ecf20Sopenharmony_ci	SND_BEBOB_CLOCK_TYPE_EXTERNAL,	/* S/PDIF */
138c2ecf20Sopenharmony_ci	SND_BEBOB_CLOCK_TYPE_EXTERNAL,	/* Word Clock */
148c2ecf20Sopenharmony_ci};
158c2ecf20Sopenharmony_cistatic int
168c2ecf20Sopenharmony_ciphase88_rack_clk_src_get(struct snd_bebob *bebob, unsigned int *id)
178c2ecf20Sopenharmony_ci{
188c2ecf20Sopenharmony_ci	unsigned int enable_ext, enable_word;
198c2ecf20Sopenharmony_ci	int err;
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	err = avc_audio_get_selector(bebob->unit, 0, 9, &enable_ext);
228c2ecf20Sopenharmony_ci	if (err < 0)
238c2ecf20Sopenharmony_ci		goto end;
248c2ecf20Sopenharmony_ci	err = avc_audio_get_selector(bebob->unit, 0, 8, &enable_word);
258c2ecf20Sopenharmony_ci	if (err < 0)
268c2ecf20Sopenharmony_ci		goto end;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	if (enable_ext == 0)
298c2ecf20Sopenharmony_ci		*id = 0;
308c2ecf20Sopenharmony_ci	else if (enable_word == 0)
318c2ecf20Sopenharmony_ci		*id = 1;
328c2ecf20Sopenharmony_ci	else
338c2ecf20Sopenharmony_ci		*id = 2;
348c2ecf20Sopenharmony_ciend:
358c2ecf20Sopenharmony_ci	return err;
368c2ecf20Sopenharmony_ci}
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistatic const struct snd_bebob_rate_spec phase_series_rate_spec = {
398c2ecf20Sopenharmony_ci	.get	= &snd_bebob_stream_get_rate,
408c2ecf20Sopenharmony_ci	.set	= &snd_bebob_stream_set_rate,
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* PHASE 88 Rack FW */
448c2ecf20Sopenharmony_cistatic const struct snd_bebob_clock_spec phase88_rack_clk = {
458c2ecf20Sopenharmony_ci	.num	= ARRAY_SIZE(phase88_rack_clk_src_types),
468c2ecf20Sopenharmony_ci	.types	= phase88_rack_clk_src_types,
478c2ecf20Sopenharmony_ci	.get	= &phase88_rack_clk_src_get,
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ciconst struct snd_bebob_spec phase88_rack_spec = {
508c2ecf20Sopenharmony_ci	.clock	= &phase88_rack_clk,
518c2ecf20Sopenharmony_ci	.rate	= &phase_series_rate_spec,
528c2ecf20Sopenharmony_ci	.meter	= NULL
538c2ecf20Sopenharmony_ci};
54