From 38e80d290923519006e0f4dc954882e9f108d483 Mon Sep 17 00:00:00 2001 From: mocchi Date: Mon, 28 Oct 2013 03:21:16 +0000 Subject: [PATCH] [BeBoB/Yamaha] Add 'GoDevice' class for /BeBoB/Yamaha devices To change the source of clock for Yamaha devices based on BeBoB chipset, the driver can use 'selector function block command' defined in 'AV/C Audio Subunit Specification 1.0 (1394TA Document 1999008)'. git-svn-id: svn+ssh://ffado.org/ffado/trunk@2439 2be59082-3212-0410-8809-b0798e1608f0 --- libffado/src/SConscript | 1 + libffado/src/bebob/yamaha/yamaha_avdevice.cpp | 128 ++++++++++++++++++++++++++ libffado/src/bebob/yamaha/yamaha_avdevice.h | 58 ++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 libffado/src/bebob/yamaha/yamaha_avdevice.cpp create mode 100644 libffado/src/bebob/yamaha/yamaha_avdevice.h diff --git a/libffado/src/SConscript b/libffado/src/SConscript index 4b9243f3..0a544c9b 100644 --- a/libffado/src/SConscript +++ b/libffado/src/SConscript @@ -96,6 +96,7 @@ bebob_source = env.Split( '\ bebob/esi/quatafire610.cpp \ bebob/mackie/onyxmixer.cpp \ bebob/yamaha/yamaha_cmd.cpp \ + bebob/yamaha/yamaha_avdevice.cpp \ ' ) bebob_pkgdata = env.Split( '\ diff --git a/libffado/src/bebob/yamaha/yamaha_avdevice.cpp b/libffado/src/bebob/yamaha/yamaha_avdevice.cpp new file mode 100644 index 00000000..d45ebf84 --- /dev/null +++ b/libffado/src/bebob/yamaha/yamaha_avdevice.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2013 by Takashi Sakamoto + * Copyright (C) 2005-2008 by Pieter Palmers + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "yamaha_avdevice.h" +#include "yamaha_cmd.h" + +namespace BeBoB { +namespace Yamaha { + +GoDevice::GoDevice(DeviceManager& d, std::auto_ptr( configRom )) + : BeBoB::Device( d, configRom) +{ + debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Yamaha::GoDevice (NodeID %d)\n", + getConfigRom().getNodeId() ); + updateClockSources(); +} + +GoDevice::~GoDevice() +{ +} + +void +GoDevice::showDevice() +{ + debugOutput(DEBUG_LEVEL_NORMAL, "This is a BeBoB::Yamaha::GoDevice\n"); + BeBoB::Device::showDevice(); +} + +bool +GoDevice::updateClockSources() +{ + int err; + + m_internal_clocksource.type = FFADODevice::eCT_Internal; + m_internal_clocksource.valid = true; + m_internal_clocksource.active = false; + m_internal_clocksource.locked = true; + m_internal_clocksource.id = 0; + m_internal_clocksource.slipping = false; + m_internal_clocksource.description = "Internal"; + + m_spdif_clocksource.type = FFADODevice::eCT_SPDIF; + m_spdif_clocksource.valid = true; + m_spdif_clocksource.active = false; + m_spdif_clocksource.locked = false; + m_spdif_clocksource.id = 1; + m_spdif_clocksource.slipping = false; + m_spdif_clocksource.description = "S/PDIF"; + + /* detect digital input */ + YamahaDigInDetectCmd cmd ( get1394Service() ); + cmd.setCommandType( AVC::AVCCommand::eCT_Status ); + cmd.setNodeId( getConfigRom().getNodeId() ); + cmd.setVerbose( getDebugLevel() ); + if ( !cmd.fire() ) { + debugError( "YamahaDigInDetectCmd failed\n" ); + return false; + } else if (cmd.m_digin == 0) { + m_spdif_clocksource.locked = true; + } + + /* get current clock source */ + err = getSelectorFBValue(4); + if (err < 0) + return err; + else if (err > 0) { + m_active_clocksource = &m_spdif_clocksource; + m_spdif_clocksource.active = true; + } else { + m_active_clocksource = &m_internal_clocksource; + m_internal_clocksource.active = true; + } + + return true; +} + +FFADODevice::ClockSource +GoDevice::getActiveClockSource() +{ + if (!updateClockSources()) { + ClockSource s; + s.type = eCT_Invalid; + return s; + } + return *m_active_clocksource; +} + +bool +GoDevice::setActiveClockSource(ClockSource s) +{ + if (!updateClockSources()) + return false; + + if ((s.id > 0) || (!m_spdif_clocksource.locked)) + return false; + return setSelectorFBValue(4, s.id); +} + +FFADODevice::ClockSourceVector +GoDevice::getSupportedClockSources() { + FFADODevice::ClockSourceVector r; + r.push_back(m_internal_clocksource); + r.push_back(m_spdif_clocksource); + return r; +} +} // namespace Yamaha +} // namespace BeBoB diff --git a/libffado/src/bebob/yamaha/yamaha_avdevice.h b/libffado/src/bebob/yamaha/yamaha_avdevice.h new file mode 100644 index 00000000..8dca35c2 --- /dev/null +++ b/libffado/src/bebob/yamaha/yamaha_avdevice.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2013 by Takashi Sakamoto + * Copyright (C) 2005-2008 by Daniel Wagner + * Copyright (C) 2005-2008 by Pieter Palmers + * + * This file is part of FFADO + * FFADO = Free Firewire (pro-)audio drivers for linux + * + * FFADO is based upon FreeBoB. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef BEBOB_YAMAHA_DEVICE_H +#define BEBOB_YAMAHA_DEVICE_H + +#include "debugmodule/debugmodule.h" +#include "bebob/bebob_avdevice.h" + +namespace BeBoB { +namespace Yamaha { + +class GoDevice : public BeBoB::Device { +public: + GoDevice( DeviceManager& d, std::auto_ptr( configRom )); + virtual ~GoDevice(); + + virtual void showDevice(); + + // override these since the go series does not support + // the usual clock source selection mechanism + virtual ClockSourceVector getSupportedClockSources(); + virtual bool setActiveClockSource(ClockSource); + virtual ClockSource getActiveClockSource(); + +private: + bool updateClockSources(); + ClockSource m_internal_clocksource; + ClockSource m_spdif_clocksource; + ClockSource *m_active_clocksource; +}; + +} // namespace Yamaha +} // namespace BeBoB + +#endif -- 2.11.4.GIT