aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/rme9652/hdspm.c
diff options
context:
space:
mode:
authorAdrian Knoth <adi@drcomp.erfurt.thur.de>2013-03-09 18:37:22 -0500
committerTakashi Iwai <tiwai@suse.de>2013-03-11 05:10:53 -0400
commitfcdc4ba1d8c69847540cb3152f0ca44e238111ee (patch)
treecce5f3a72b6b448b629408868963c8f488634305 /sound/pci/rme9652/hdspm.c
parent3f7bf918bfa2f4b8aa461ae82249e3c187bbff81 (diff)
ALSA: hdspm - Allow the TCO and SYNC-IN to be used in slave mode
When using the additional Time Code Option module in slave mode or the SYNC-In wordclock connector, the sample rate needs to be returned by hdspm_external_sample_rate(). Since this sample rate may contain any value with 1Hz granularity, we need to round it to a common rate as done by the OSX driver. [Fixed missing function declarations by tiwai] Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/rme9652/hdspm.c')
-rw-r--r--sound/pci/rme9652/hdspm.c65
1 files changed, 51 insertions, 14 deletions
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 50cba5ce54fe..c56bfe402234 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -1076,6 +1076,20 @@ static int snd_hdspm_use_is_exclusive(struct hdspm *hdspm)
1076 return ret; 1076 return ret;
1077} 1077}
1078 1078
1079/* round arbitary sample rates to commonly known rates */
1080static int hdspm_round_frequency(int rate)
1081{
1082 if (rate < 38050)
1083 return 32000;
1084 if (rate < 46008)
1085 return 44100;
1086 else
1087 return 48000;
1088}
1089
1090static int hdspm_tco_sync_check(struct hdspm *hdspm);
1091static int hdspm_sync_in_sync_check(struct hdspm *hdspm);
1092
1079/* check for external sample rate */ 1093/* check for external sample rate */
1080static int hdspm_external_sample_rate(struct hdspm *hdspm) 1094static int hdspm_external_sample_rate(struct hdspm *hdspm)
1081{ 1095{
@@ -1217,22 +1231,45 @@ static int hdspm_external_sample_rate(struct hdspm *hdspm)
1217 break; 1231 break;
1218 } 1232 }
1219 1233
1220 /* QS and DS rates normally can not be detected 1234 } /* endif HDSPM_madiLock */
1221 * automatically by the card. Only exception is MADI 1235
1222 * in 96k frame mode. 1236 /* check sample rate from TCO or SYNC_IN */
1223 * 1237 {
1224 * So if we read SS values (32 .. 48k), check for 1238 bool is_valid_input = 0;
1225 * user-provided DS/QS bits in the control register 1239 bool has_sync = 0;
1226 * and multiply the base frequency accordingly. 1240
1227 */ 1241 syncref = hdspm_autosync_ref(hdspm);
1228 if (rate <= 48000) { 1242 if (HDSPM_AUTOSYNC_FROM_TCO == syncref) {
1229 if (hdspm->control_register & HDSPM_QuadSpeed) 1243 is_valid_input = 1;
1230 rate *= 4; 1244 has_sync = (HDSPM_SYNC_CHECK_SYNC ==
1231 else if (hdspm->control_register & 1245 hdspm_tco_sync_check(hdspm));
1232 HDSPM_DoubleSpeed) 1246 } else if (HDSPM_AUTOSYNC_FROM_SYNC_IN == syncref) {
1233 rate *= 2; 1247 is_valid_input = 1;
1248 has_sync = (HDSPM_SYNC_CHECK_SYNC ==
1249 hdspm_sync_in_sync_check(hdspm));
1250 }
1251
1252 if (is_valid_input && has_sync) {
1253 rate = hdspm_round_frequency(
1254 hdspm_get_pll_freq(hdspm));
1234 } 1255 }
1235 } 1256 }
1257
1258 /* QS and DS rates normally can not be detected
1259 * automatically by the card. Only exception is MADI
1260 * in 96k frame mode.
1261 *
1262 * So if we read SS values (32 .. 48k), check for
1263 * user-provided DS/QS bits in the control register
1264 * and multiply the base frequency accordingly.
1265 */
1266 if (rate <= 48000) {
1267 if (hdspm->control_register & HDSPM_QuadSpeed)
1268 rate *= 4;
1269 else if (hdspm->control_register &
1270 HDSPM_DoubleSpeed)
1271 rate *= 2;
1272 }
1236 break; 1273 break;
1237 } 1274 }
1238 1275