Changeset 1780
- Timestamp:
- 01/04/10 14:10:14 (13 years ago)
- Files:
-
- trunk/libffado/src/dice/dice_eap.cpp (modified) (8 diffs)
- trunk/libffado/src/dice/dice_eap.h (modified) (3 diffs)
- trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/dice/dice_eap.cpp
r1779 r1780 35 35 // ----------- helper functions ------------- 36 36 37 #if 0 37 38 static const char * 38 39 srcBlockToString(const char id) … … 69 70 } 70 71 } 72 #endif 71 73 72 74 IMPL_DEBUG_MODULE( EAP, EAP, DEBUG_LEVEL_NORMAL ); … … 1203 1205 if(rcfg == NULL) { 1204 1206 debugError("Could not request active router configuration\n"); 1205 return "";1207 return stringlist(); 1206 1208 } 1207 1209 stringlist ret; 1208 std::vector< int> dests = rcfg->getDestinationsForSource(m_sources[srcname]);1209 for ( int i=0; i<dests.size(); ++i) {1210 ret.push_back( m_destinations[dests[i]]);1210 std::vector<unsigned char> dests = rcfg->getDestinationsForSource(m_sources[srcname]); 1211 for (unsigned int i=0; i<dests.size(); ++i) { 1212 ret.push_back(getDestinationName(dests[i])); 1211 1213 } 1212 1214 return ret; … … 1318 1320 EAP::Router::getPeakValue(const std::string& dest) 1319 1321 { 1320 debugError("TODO: Implement getPeakValue(%s)\n", dest.c_str());1321 /*if((unsigned)source >= m_sources.size()) {1322 debugWarning("source id out of range (%d)\n", source);1323 return false;1324 }1325 Source s = m_sources.at(source);1326 1327 if((unsigned)dest >= m_destinations.size()) {1328 debugWarning("destination id out of range (%d)\n", dest);1329 return false;1330 }1331 Destination d = m_destinations.at(dest);1332 1333 debugOutput(DEBUG_LEVEL_VERBOSE, "getting peak info for [%d] %s => [%d] %s\n",1334 source, s.name.c_str(),1335 dest, d.name.c_str());1336 1337 // update the peak information1338 1322 m_peak.read(); 1339 1340 // construct the routing entry to find 1341 RouterConfig::Route r = {s.src, s.srcChannel, d.dst, d.dstChannel, 0}; 1342 1343 // find the appropriate entry 1344 int idx = m_peak.getRouteIndex(r); 1345 1346 if (idx < 0) { 1347 // the route is not present 1348 return -1; 1349 } else { 1350 // the route is present 1351 r = m_peak.getRoute(idx); 1352 return r.peak; 1353 }*/ 1354 return -1; 1355 1323 unsigned char dst = m_destinations[dest]; 1324 return m_peak.getPeak(dst); 1356 1325 } 1357 1326 … … 1359 1328 EAP::Router::getPeakValues() 1360 1329 { 1361 debugError("TODO: implement getPeakValues()\n"); 1362 /*m_peak.read(); 1363 Control::CrossbarRouter::PeakValues values; 1364 for (unsigned int i=0; i<m_peak.getNbRoutes(); ++i) { 1365 Control::CrossbarRouter::PeakValue tmp; 1366 RouterConfig::Route route = m_peak.getRoute(i); 1367 tmp.destination = getDestinationIndex(route.dst, route.dstChannel); 1368 tmp.peakvalue = route.peak; 1369 values.push_back(tmp); 1370 } 1371 return values;*/ 1372 return std::map<std::string, double>(); 1330 m_peak.read(); 1331 std::map<std::string, double> ret; 1332 std::map<unsigned char, int> peaks = m_peak.getPeaks(); 1333 for (std::map<unsigned char, int>::iterator it=peaks.begin(); it!=peaks.end(); ++it) { 1334 ret[getDestinationName(it->first)] = it->second; 1335 } 1336 return ret; 1373 1337 } 1374 1338 … … 1549 1513 EAP::PeakSpace::read(enum eRegBase base, unsigned offset) 1550 1514 { 1551 #warning "Implement me again!"1552 #if 01553 // first clear the current route vector1554 m_routes.clear();1555 1556 1515 uint32_t nb_routes; 1557 1516 // we have to figure out the number of entries through the currently … … 1564 1523 nb_routes = rcfg->getNbRoutes(); 1565 1524 1566 // read the route info1525 // read the peak/route info 1567 1526 uint32_t tmp_entries[nb_routes]; 1568 1527 if(!m_eap.readRegBlock(base, offset, tmp_entries, nb_routes*4)) { … … 1570 1529 return false; 1571 1530 } 1572 1573 // decode into the routing vector 1574 for(unsigned int i=0; i < nb_routes; i++) { 1575 m_routes.push_back(decodeRoute(tmp_entries[i])); 1576 } 1577 // show(); 1578 #endif 1531 // parse the peaks into the map 1532 for (unsigned int i=0; i<nb_routes; ++i) { 1533 unsigned char dest = tmp_entries[i]&0xff; 1534 int peak = (tmp_entries[i]&0xfff0000)>>16; 1535 if (m_peaks.count(dest) == 0 || m_peaks[dest] < peak) { 1536 m_peaks[dest] = peak; 1537 } 1538 } 1579 1539 return true; 1580 1540 } 1581 1541 1582 bool1583 EAP::PeakSpace::write(enum eRegBase base, unsigned offset)1584 {1585 debugError("Peak space is read-only\n");1586 return true;1587 }1588 1542 1589 1543 void 1590 1544 EAP::PeakSpace::show() 1591 1545 { 1592 debugError("PeakSpace::show() is currently not implemented!\n"); 1593 #if 0 1594 for ( RouteVectorIterator it = m_routes.begin(); 1595 it != m_routes.end(); 1596 ++it ) 1597 { 1598 struct Route r = *it; 1599 printMessage("%s:%02d => %s:%02d : %06d\n", 1600 srcBlockToString(r.src), r.srcChannel, 1601 dstBlockToString(r.dst), r.dstChannel, 1602 r.peak); 1603 } 1604 #endif 1546 printMessage(" %i peaks\n", m_peaks.size()); 1547 for (std::map<unsigned char, int>::iterator it=m_peaks.begin(); it!=m_peaks.end(); ++it) { 1548 printMessage("0x%02x : %i\n", it->first, it->second); 1549 } 1550 } 1551 1552 int 1553 EAP::PeakSpace::getPeak(unsigned char dst) { 1554 int ret = m_peaks[dst]; 1555 m_peaks.erase(dst); 1556 return ret; 1557 } 1558 1559 std::map<unsigned char, int> 1560 EAP::PeakSpace::getPeaks() { 1561 // Create a new empty map 1562 std::map<unsigned char, int> ret; 1563 // Swap the peak map with the new and empty one 1564 ret.swap(m_peaks); 1565 // Return the now filled map of the peaks :-) 1566 return ret; 1605 1567 } 1606 1568 trunk/libffado/src/dice/dice_eap.h
r1779 r1780 203 203 RouterConfig(EAP &); 204 204 RouterConfig(EAP &, enum eRegBase, unsigned int offset); 205 virtual~RouterConfig();205 ~RouterConfig(); 206 206 207 207 public: 208 208 209 virtual bool read() {return read(m_base, m_offset);}; 210 virtual bool write() {return write(m_base, m_offset);}; 211 virtual bool read(enum eRegBase b, unsigned offset); 212 virtual bool write(enum eRegBase b, unsigned offset); 213 virtual void show(); 214 215 /** 216 @brief map for the routes 217 218 The key is the destination as each destination can only have audio from one source. 219 Sources can be routed to several destinations though. 220 */ 221 typedef std::map<unsigned char,unsigned char> RouteVectorV2; 209 bool read() {return read(m_base, m_offset);}; 210 bool write() {return write(m_base, m_offset);}; 211 bool read(enum eRegBase b, unsigned offset); 212 bool write(enum eRegBase b, unsigned offset); 213 void show(); 222 214 223 215 /** … … 254 246 unsigned int getNbRoutes() {return m_routes2.size();}; 255 247 256 pr otected:248 private: 257 249 EAP &m_eap; 258 250 enum eRegBase m_base; 259 251 unsigned int m_offset; 252 253 /** 254 @brief map for the routes 255 256 The key is the destination as each destination can only have audio from one source. 257 Sources can be routed to several destinations though. 258 */ 259 typedef std::map<unsigned char,unsigned char> RouteVectorV2; 260 260 RouteVectorV2 m_routes2; 261 pr otected:261 private: 262 262 DECLARE_DEBUG_MODULE_REFERENCE; 263 263 }; … … 266 266 the peak space is a special version of a router config 267 267 */ 268 class PeakSpace : public RouterConfig{268 class PeakSpace { 269 269 private: 270 270 friend class Dice::EAP; 271 PeakSpace(EAP &p) : RouterConfig(p, eRT_Peak, 0) {};272 virtual~PeakSpace() {};271 PeakSpace(EAP &p) : m_eap(p), m_base(eRT_Peak), m_offset(0), m_debugModule(p.m_debugModule) {}; 272 ~PeakSpace() {}; 273 273 274 274 public: 275 virtual bool read() {return read(m_base, m_offset);}; 276 virtual bool write() {return write(m_base, m_offset);}; 277 virtual bool read(enum eRegBase b, unsigned offset); 278 virtual bool write(enum eRegBase b, unsigned offset); 279 virtual void show(); 275 bool read() {return read(m_base, m_offset);}; 276 bool read(enum eRegBase b, unsigned offset); 277 void show(); 278 279 std::map<unsigned char, int> getPeaks(); 280 int getPeak(unsigned char dest); 281 282 private: 283 EAP &m_eap; 284 enum eRegBase m_base; 285 unsigned int m_offset; 286 287 /** 288 @brief maps peaks to destinations 289 */ 290 std::map<unsigned char, int> m_peaks; 291 292 DECLARE_DEBUG_MODULE_REFERENCE; 280 293 }; 281 294 trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py
r1779 r1780 20 20 21 21 from PyQt4 import QtGui, QtCore 22 import dbus 22 import dbus, math 23 23 24 24 import logging … … 46 46 value = self.level/4096 47 47 r = self.rect() 48 r.setHeight(r.height() * value)48 r.setHeight(r.height() * math.sqrt(value)) 49 49 r.moveBottom(self.rect().height()) 50 50 p.fillRect(r, self.palette().highlight()) … … 91 91 92 92 def peakValue(self, value): 93 #self.vu.updateLevel(value)93 self.vu.updateLevel(value) 94 94 pass 95 95 … … 132 132 self.biglayout.addLayout(self.toplayout) 133 133 134 self.vubtn = QtGui.QPushButton("Switch VU", self)134 self.vubtn = QtGui.QPushButton("Switch peak meters", self) 135 135 self.vubtn.setCheckable(True) 136 136 self.connect(self.vubtn, QtCore.SIGNAL("toggled(bool)"), self.runVu) … … 168 168 #log.debug("CrossbarRouter.updateLevels()") 169 169 peakvalues = self.interface.getPeakValues() 170 log.debug("Got %i peaks" % len(peakvalues))170 #log.debug("Got %i peaks" % len(peakvalues)) 171 171 for peak in peakvalues: 172 172 #log.debug("peak = [%s,%s]" % (str(peak[0]),str(peak[1])))