Index: /trunk/libffado/src/dice/dice_eap.h =================================================================== --- /trunk/libffado/src/dice/dice_eap.h (revision 1779) +++ /trunk/libffado/src/dice/dice_eap.h (revision 1780) @@ -203,21 +203,13 @@ RouterConfig(EAP &); RouterConfig(EAP &, enum eRegBase, unsigned int offset); - virtual ~RouterConfig(); + ~RouterConfig(); public: - virtual bool read() {return read(m_base, m_offset);}; - virtual bool write() {return write(m_base, m_offset);}; - virtual bool read(enum eRegBase b, unsigned offset); - virtual bool write(enum eRegBase b, unsigned offset); - virtual void show(); - - /** - @brief map for the routes - - The key is the destination as each destination can only have audio from one source. - Sources can be routed to several destinations though. - */ - typedef std::map RouteVectorV2; + bool read() {return read(m_base, m_offset);}; + bool write() {return write(m_base, m_offset);}; + bool read(enum eRegBase b, unsigned offset); + bool write(enum eRegBase b, unsigned offset); + void show(); /** @@ -254,10 +246,18 @@ unsigned int getNbRoutes() {return m_routes2.size();}; - protected: + private: EAP &m_eap; enum eRegBase m_base; unsigned int m_offset; + + /** + @brief map for the routes + + The key is the destination as each destination can only have audio from one source. + Sources can be routed to several destinations though. + */ + typedef std::map RouteVectorV2; RouteVectorV2 m_routes2; - protected: + private: DECLARE_DEBUG_MODULE_REFERENCE; }; @@ -266,16 +266,29 @@ the peak space is a special version of a router config */ - class PeakSpace : public RouterConfig { + class PeakSpace { private: friend class Dice::EAP; - PeakSpace(EAP &p) : RouterConfig(p, eRT_Peak, 0) {}; - virtual ~PeakSpace() {}; + PeakSpace(EAP &p) : m_eap(p), m_base(eRT_Peak), m_offset(0), m_debugModule(p.m_debugModule) {}; + ~PeakSpace() {}; public: - virtual bool read() {return read(m_base, m_offset);}; - virtual bool write() {return write(m_base, m_offset);}; - virtual bool read(enum eRegBase b, unsigned offset); - virtual bool write(enum eRegBase b, unsigned offset); - virtual void show(); + bool read() {return read(m_base, m_offset);}; + bool read(enum eRegBase b, unsigned offset); + void show(); + + std::map getPeaks(); + int getPeak(unsigned char dest); + + private: + EAP &m_eap; + enum eRegBase m_base; + unsigned int m_offset; + + /** + @brief maps peaks to destinations + */ + std::map m_peaks; + + DECLARE_DEBUG_MODULE_REFERENCE; }; Index: /trunk/libffado/src/dice/dice_eap.cpp =================================================================== --- /trunk/libffado/src/dice/dice_eap.cpp (revision 1779) +++ /trunk/libffado/src/dice/dice_eap.cpp (revision 1780) @@ -35,4 +35,5 @@ // ----------- helper functions ------------- +#if 0 static const char * srcBlockToString(const char id) @@ -69,4 +70,5 @@ } } +#endif IMPL_DEBUG_MODULE( EAP, EAP, DEBUG_LEVEL_NORMAL ); @@ -1203,10 +1205,10 @@ if(rcfg == NULL) { debugError("Could not request active router configuration\n"); - return ""; + return stringlist(); } stringlist ret; - std::vector dests = rcfg->getDestinationsForSource(m_sources[srcname]); - for (int i=0; i dests = rcfg->getDestinationsForSource(m_sources[srcname]); + for (unsigned int i=0; i= m_sources.size()) { - debugWarning("source id out of range (%d)\n", source); - return false; - } - Source s = m_sources.at(source); - - if((unsigned)dest >= m_destinations.size()) { - debugWarning("destination id out of range (%d)\n", dest); - return false; - } - Destination d = m_destinations.at(dest); - - debugOutput(DEBUG_LEVEL_VERBOSE, "getting peak info for [%d] %s => [%d] %s\n", - source, s.name.c_str(), - dest, d.name.c_str()); - - // update the peak information m_peak.read(); - - // construct the routing entry to find - RouterConfig::Route r = {s.src, s.srcChannel, d.dst, d.dstChannel, 0}; - - // find the appropriate entry - int idx = m_peak.getRouteIndex(r); - - if (idx < 0) { - // the route is not present - return -1; - } else { - // the route is present - r = m_peak.getRoute(idx); - return r.peak; - }*/ - return -1; - + unsigned char dst = m_destinations[dest]; + return m_peak.getPeak(dst); } @@ -1359,16 +1328,11 @@ EAP::Router::getPeakValues() { - debugError("TODO: implement getPeakValues()\n"); - /*m_peak.read(); - Control::CrossbarRouter::PeakValues values; - for (unsigned int i=0; i(); + m_peak.read(); + std::map ret; + std::map peaks = m_peak.getPeaks(); + for (std::map::iterator it=peaks.begin(); it!=peaks.end(); ++it) { + ret[getDestinationName(it->first)] = it->second; + } + return ret; } @@ -1549,9 +1513,4 @@ EAP::PeakSpace::read(enum eRegBase base, unsigned offset) { -#warning "Implement me again!" -#if 0 - // first clear the current route vector - m_routes.clear(); - uint32_t nb_routes; // we have to figure out the number of entries through the currently @@ -1564,5 +1523,5 @@ nb_routes = rcfg->getNbRoutes(); - // read the route info + // read the peak/route info uint32_t tmp_entries[nb_routes]; if(!m_eap.readRegBlock(base, offset, tmp_entries, nb_routes*4)) { @@ -1570,37 +1529,40 @@ return false; } - - // decode into the routing vector - for(unsigned int i=0; i < nb_routes; i++) { - m_routes.push_back(decodeRoute(tmp_entries[i])); - } -// show(); -#endif + // parse the peaks into the map + for (unsigned int i=0; i>16; + if (m_peaks.count(dest) == 0 || m_peaks[dest] < peak) { + m_peaks[dest] = peak; + } + } return true; } -bool -EAP::PeakSpace::write(enum eRegBase base, unsigned offset) -{ - debugError("Peak space is read-only\n"); - return true; -} void EAP::PeakSpace::show() { - debugError("PeakSpace::show() is currently not implemented!\n"); -#if 0 - for ( RouteVectorIterator it = m_routes.begin(); - it != m_routes.end(); - ++it ) - { - struct Route r = *it; - printMessage("%s:%02d => %s:%02d : %06d\n", - srcBlockToString(r.src), r.srcChannel, - dstBlockToString(r.dst), r.dstChannel, - r.peak); - } -#endif + printMessage(" %i peaks\n", m_peaks.size()); + for (std::map::iterator it=m_peaks.begin(); it!=m_peaks.end(); ++it) { + printMessage("0x%02x : %i\n", it->first, it->second); + } +} + +int +EAP::PeakSpace::getPeak(unsigned char dst) { + int ret = m_peaks[dst]; + m_peaks.erase(dst); + return ret; +} + +std::map +EAP::PeakSpace::getPeaks() { + // Create a new empty map + std::map ret; + // Swap the peak map with the new and empty one + ret.swap(m_peaks); + // Return the now filled map of the peaks :-) + return ret; } Index: /trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py =================================================================== --- /trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py (revision 1779) +++ /trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py (revision 1780) @@ -20,5 +20,5 @@ from PyQt4 import QtGui, QtCore -import dbus +import dbus, math import logging @@ -46,5 +46,5 @@ value = self.level/4096 r = self.rect() - r.setHeight(r.height() * value) + r.setHeight(r.height() * math.sqrt(value)) r.moveBottom(self.rect().height()) p.fillRect(r, self.palette().highlight()) @@ -91,5 +91,5 @@ def peakValue(self, value): - #self.vu.updateLevel(value) + self.vu.updateLevel(value) pass @@ -132,5 +132,5 @@ self.biglayout.addLayout(self.toplayout) - self.vubtn = QtGui.QPushButton("Switch VU", self) + self.vubtn = QtGui.QPushButton("Switch peak meters", self) self.vubtn.setCheckable(True) self.connect(self.vubtn, QtCore.SIGNAL("toggled(bool)"), self.runVu) @@ -168,5 +168,5 @@ #log.debug("CrossbarRouter.updateLevels()") peakvalues = self.interface.getPeakValues() - log.debug("Got %i peaks" % len(peakvalues)) + #log.debug("Got %i peaks" % len(peakvalues)) for peak in peakvalues: #log.debug("peak = [%s,%s]" % (str(peak[0]),str(peak[1])))