Changeset 1779

Show
Ignore:
Timestamp:
01/04/10 13:10:45 (11 years ago)
Author:
arnonym
Message:

Rewrite the RouterConfig? and save lots of code.

Plus, it seems I fixed a "bug" where the device would output a high pitched sound when an output was disconnected. Now this seems gone...

Next stop: PeakSpace?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/dice/dice_eap.cpp

    r1776 r1779  
    875875EAP::Mixer::updateNameCache() 
    876876{ 
     877    debugWarning("What is this function about?\n"); 
     878#if 0 
    877879    // figure out the number of i/o's 
    878880    int nb_inputs = m_eap.m_mixer_nb_tx; 
     
    953955        #endif 
    954956    } 
     957#endif 
    955958} 
    956959 
     
    973976    printMessage("%s\n", tmp); 
    974977 
    975     cnt = 0; 
     978    /*cnt = 0; 
    976979    for(int j=0; j < nb_inputs; j++) { 
    977980        cnt += snprintf(tmp+cnt, bufflen-cnt, "%s:%02d ", 
     
    979982                        m_input_route_map[j].srcChannel); 
    980983    } 
    981     printMessage("%s\n", tmp); 
     984    printMessage("%s\n", tmp);*/ 
    982985 
    983986    // display coefficients 
     
    990993        // construct the set of destinations 
    991994        std::string destinations; 
    992         for ( RouterConfig::RouteVectorIterator it = m_output_route_map[i].begin(); 
     995        /*for ( RouterConfig::RouteVectorIterator it = m_output_route_map[i].begin(); 
    993996            it != m_output_route_map[i].end(); 
    994997            ++it ) 
     
    10011004                destinations += tmp; 
    10021005            } 
    1003         } 
     1006        }*/ 
    10041007 
    10051008        cnt += snprintf(tmp+cnt, bufflen-cnt, "=[%02d]=> %s ", i, destinations.c_str()); 
     
    10761079 
    10771080// Names 
     1081#if 0 
    10781082std::string 
    10791083EAP::Mixer::getColName(const int col) { 
     
    10951099    return tmp; 
    10961100} 
     1101#endif 
    10971102 
    10981103// 
     
    11511156EAP::Router::getDestinationName(const int dstid) 
    11521157{ 
    1153     debugWarning("TODO: Implement getDestinationName(0x%02x)\n", dstid); 
    11541158    for (std::map<std::string, int>::iterator it=m_destinations.begin(); it!=m_destinations.end(); ++it) { 
    11551159        if (it->second == dstid) { 
     
    11961200stringlist 
    11971201EAP::Router::getDestinationsForSource(const std::string& srcname) { 
    1198     debugWarning("TODO: Implement getDestinationsForSource(%s)\n", srcname.c_str()); 
    1199     return stringlist(); 
     1202    RouterConfig* rcfg = m_eap.getActiveRouterConfig(); 
     1203    if(rcfg == NULL) { 
     1204        debugError("Could not request active router configuration\n"); 
     1205        return ""; 
     1206    } 
     1207    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]]); 
     1211    } 
     1212    return ret; 
    12001213} 
    12011214std::string 
     
    12061219        return ""; 
    12071220    } 
    1208     eRouteDestination dst = eRouteDestination(m_destinations[dstname]>>4); 
    1209     int dstChannel = m_destinations[dstname]&0xf; 
    1210     RouterConfig::Route r = rcfg->getRouteForDestination(dst, dstChannel); 
    1211     if (r.src == eRS_Invalid) { 
    1212         return ""; 
    1213     } 
    1214     return getSourceName((r.src<<4)+r.srcChannel); 
     1221    int source = rcfg->getSourceForDestination(m_destinations[dstname]); 
     1222    return getSourceName(source); 
    12151223} 
    12161224 
     
    12201228{ 
    12211229    debugWarning("TODO: Implement canConnect(0x%02x, 0x%02x)\n", source, dest); 
    1222     /*if((unsigned)source >= m_sources.size()) { 
    1223         debugWarning("source id out of range (%d)\n", source); 
    1224         return false; 
    1225     } 
    1226     Source s = m_sources.at(source); 
    1227  
    1228     if((unsigned)dest >= m_destinations.size()) { 
    1229         debugWarning("destination id out of range (%d)\n", dest); 
    1230         return false; 
    1231     } 
    1232     Destination d = m_destinations.at(dest);*/ 
    12331230 
    12341231    // we can connect anything 
     
    12401237EAP::Router::setConnectionState(const int source, const int dest, const bool enable) 
    12411238{ 
     1239    debugOutput(DEBUG_LEVEL_VERBOSE,"Router::setConnectionState(0x%02x -> 0x%02x ? %i)\n", source, dest, enable); 
    12421240    // get the routing configuration 
    12431241    RouterConfig *rcfg = m_eap.getActiveRouterConfig(); 
     
    12471245    } 
    12481246 
    1249     RouterConfig::Route r = rcfg->getRouteForDestination(eRouteDestination(dest>>4), dest&0xf); 
    1250     if ( r.srcChannel == -1 && r.dstChannel == -1 && enable ) { 
    1251         r.src = eRouteSource(source>>4); 
    1252         r.srcChannel = source&0xf; 
    1253         r.dst = eRouteDestination(dest>>4); 
    1254         r.dstChannel = dest&0xf; 
    1255         int ret = rcfg->insertRoute(r); 
    1256         m_eap.updateCurrentRouterConfig(*rcfg); 
    1257         return ret; 
    1258     } 
    1259     if ( r.dst != (dest>>4) || r.dstChannel != (dest&0xf) ) { 
    1260         debugError("Route exists but isn't correct? strange...\n"); 
    1261         debugError(" wanted: 0x%02x got: 0x%02x\n", dest, (r.dst<<4)+r.dstChannel); 
    1262         return false; 
    1263     } 
    1264     if ( !enable ) { 
    1265         int ret = rcfg->removeRoute(r); 
    1266         m_eap.updateCurrentRouterConfig(*rcfg); 
    1267         return ret; 
    1268     } 
    1269     if ( enable ) { 
    1270         int index = rcfg->getRouteIndex(r); 
    1271         r.src = eRouteSource(source>>4); 
    1272         r.srcChannel = (source&0xf); 
    1273         int ret = rcfg->replaceRoute(index, r); 
    1274         m_eap.updateCurrentRouterConfig(*rcfg); 
    1275         return ret; 
    1276     } 
    1277  
    1278     // When we reach this point, something went wrong. Return false by default... 
    1279     return false; 
     1247    bool ret = false; 
     1248    if (enable) { 
     1249        ret = rcfg->setupRoute(source, dest); 
     1250    } else { 
     1251        ret = rcfg->removeRoute(source, dest); 
     1252    } 
     1253    m_eap.updateCurrentRouterConfig(*rcfg); 
     1254    return ret; 
    12801255} 
    12811256 
     
    12891264        return false; 
    12901265    } 
    1291     // Construct a route 
    1292     RouterConfig::Route r = { eRouteSource(source>>4), source&0xf, eRouteDestination(dest>>4), dest&0xf }; 
    1293     // get the routes index... 
    1294     int idx = rcfg->getRouteIndex(r); 
    1295     // ...and return true if it exists 
    1296     return (idx>=0); 
     1266    if (rcfg->getSourceForDestination(dest) == source) { 
     1267        return true; 
     1268    } 
     1269    return false; 
    12971270} 
    12981271 
     
    14221395        } 
    14231396    } 
    1424     //printMessage("Active router config:\n"); 
    1425     //m_peak.read(); 
    1426     //m_peak.show(); 
     1397    printMessage("Active router config:\n"); 
     1398    m_eap.getActiveRouterConfig()->show(); 
     1399    printMessage("Active peak config:\n"); 
     1400    m_peak.read(); 
     1401    m_peak.show(); 
    14271402} 
    14281403 
     
    14471422{ 
    14481423    // first clear the current route vector 
    1449     m_routes.clear(); 
     1424    m_routes2.clear(); 
    14501425 
    14511426    uint32_t nb_routes; 
     
    14651440    } 
    14661441 
    1467     // decode into the routing vector 
     1442    // decode into the routing map 
    14681443    for(unsigned int i=0; i < nb_routes; i++) { 
    1469         m_routes.push_back(decodeRoute(tmp_entries[i]))
     1444        m_routes2[tmp_entries[i]&0xff] = (tmp_entries[i]>>8)&0xff
    14701445    } 
    14711446    return true; 
     
    14751450EAP::RouterConfig::write(enum eRegBase base, unsigned offset) 
    14761451{ 
    1477     uint32_t nb_routes = m_routes.size(); 
     1452    uint32_t nb_routes = m_routes2.size(); 
    14781453    if(nb_routes == 0) { 
    1479         debugWarning("Writing 0 routes?\n"); 
     1454        debugWarning("Writing 0 routes? This will deactivate routing and make the device very silent...\n"); 
     1455    } 
     1456    if (nb_routes > 128) { 
     1457        debugError("More then 128 are not possible, only the first 128 routes will get saved!\n"); 
     1458        nb_routes = 128; 
    14801459    } 
    14811460    uint32_t tmp_entries[nb_routes]; 
     
    14831462    // encode from the routing vector 
    14841463    int i=0; 
    1485     for ( RouteVectorIterator it = m_routes.begin(); 
    1486         it != m_routes.end(); 
    1487         ++it ) 
    1488     { 
    1489         tmp_entries[i] = encodeRoute( *it ); 
    1490         i++; 
     1464    for (RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it) { 
     1465        tmp_entries[i] = ((it->second<<8) + it->first)&0xffff; 
     1466        ++i; 
     1467    } 
     1468 
     1469    uint32_t zeros[129]; 
     1470    for (int i=0; i<129; ++i) zeros[i] = 0; 
     1471    if(!m_eap.writeRegBlock(base, offset, zeros, 129*4)) { 
     1472        debugError("Failed to write zeros to router config block\n"); 
     1473        return false; 
    14911474    } 
    14921475 
     
    15041487 
    15051488bool 
    1506 EAP::RouterConfig::insertRoute(struct Route r, unsigned int index) 
    1507 
    1508     unsigned int nb_routes = getNbRoutes(); 
    1509     if(index > nb_routes) { 
    1510         debugError("Index out of range\n"); 
    1511         return false; 
    1512     } 
    1513     if (index == nb_routes) { // append 
    1514         m_routes.push_back(r); 
    1515         return true; 
    1516     } 
    1517     // insert 
    1518     RouteVectorIterator pos = m_routes.begin() + index; 
    1519     m_routes.insert(pos, r); 
     1489EAP::RouterConfig::setupRoute(unsigned char src, unsigned char dest) { 
     1490    debugOutput(DEBUG_LEVEL_VERBOSE,"RouterConfig::setupRoute( 0x%02x, 0x%02x )\n", src, dest); 
     1491    m_routes2[dest] = src; 
    15201492    return true; 
    15211493} 
    15221494 
    15231495bool 
    1524 EAP::RouterConfig::replaceRoute(unsigned int old_index, struct Route new_route) 
    1525 
    1526     if(old_index >= getNbRoutes()) { 
    1527         debugError("Index out of range\n"); 
    1528         return false; 
    1529     } 
    1530     if(!removeRoute(old_index)) { 
    1531         debugError("Could not remove old route\n"); 
    1532         return false; 
    1533     } 
    1534     return insertRoute(new_route, old_index); 
    1535 
    1536  
    1537 bool 
    1538 EAP::RouterConfig::replaceRoute(struct Route old_route, struct Route new_route) 
    1539 
    1540     int idx = getRouteIndex(old_route); 
    1541     if(idx < 0) { 
    1542         debugWarning("Route not found\n"); 
    1543         return false; 
    1544     } 
    1545     return replaceRoute((unsigned int)idx, new_route); 
    1546 
    1547  
    1548 bool 
    1549 EAP::RouterConfig::removeRoute(struct Route r) 
    1550 
    1551     int idx = getRouteIndex(r); 
    1552     if(idx < 0) { 
    1553         debugWarning("Route not found\n"); 
    1554         return false; 
    1555     } 
    1556     return removeRoute((unsigned int)idx); 
    1557 
    1558  
    1559 bool 
    1560 EAP::RouterConfig::removeRoute(unsigned int index) 
    1561 
    1562     if(index >= getNbRoutes()) { 
    1563         debugError("Index out of range\n"); 
    1564         return false; 
    1565     } 
    1566     RouteVectorIterator pos = m_routes.begin() + index; 
    1567     m_routes.erase(pos); 
     1496EAP::RouterConfig::removeRoute(unsigned char src, unsigned char dest) { 
     1497    debugOutput(DEBUG_LEVEL_VERBOSE,"RouterConfig::removeRoute( 0x%02x, 0x%02x )\n", src, dest); 
     1498    if (m_routes2.count(dest) > 0) { 
     1499        if (src != m_routes2[dest]) { 
     1500            return false; 
     1501        } 
     1502        return removeRoute(dest); 
     1503    } 
    15681504    return true; 
    15691505} 
    15701506 
    1571 int 
    1572 EAP::RouterConfig::getRouteIndex(struct Route r) 
    1573 
    1574     int i = 0; 
    1575     for ( RouteVectorIterator it = m_routes.begin(); 
    1576         it != m_routes.end(); 
    1577         ++it ) 
    1578     { 
    1579         struct Route t = *it; 
    1580         if ((t.src == r.src) && (t.srcChannel == r.srcChannel) && (t.dst == r.dst) && (t.dstChannel == r.dstChannel)) return i; 
    1581         i++; 
     1507bool 
     1508EAP::RouterConfig::removeRoute(unsigned char dest) { 
     1509    debugOutput(DEBUG_LEVEL_VERBOSE,"RouterConfig::removeRoute( 0x%02x )\n", dest); 
     1510    m_routes2.erase(dest); 
     1511    if (m_routes2.count(dest) < 1) { 
     1512        return false; 
     1513    } 
     1514    return true; 
     1515
     1516 
     1517unsigned char 
     1518EAP::RouterConfig::getSourceForDestination(unsigned char dest) { 
     1519    if (m_routes2.count(dest) > 0) { 
     1520        return m_routes2[dest]; 
    15821521    } 
    15831522    return -1; 
    15841523} 
    15851524 
    1586 struct EAP::RouterConfig::Route 
    1587 EAP::RouterConfig::getRoute(unsigned int idx) 
    1588 
    1589     if( (idx < 0) || (idx >= m_routes.size()) ) { 
    1590         debugWarning("Route index out of range (%d)\n", idx); 
    1591         Route r = {eRS_Invalid, -1, eRD_Invalid, -1, 0}; 
    1592         return r; 
    1593     } 
    1594     return m_routes.at(idx); 
    1595 
    1596  
    1597 #define CASE_INT_EQUAL_RETURN(_x) case (int)(_x): return _x; 
    1598 enum eRouteDestination 
    1599 EAP::RouterConfig::intToRouteDestination(int dst) 
    1600 
    1601     switch(dst) { 
    1602         CASE_INT_EQUAL_RETURN(eRD_AES); 
    1603         CASE_INT_EQUAL_RETURN(eRD_ADAT); 
    1604         CASE_INT_EQUAL_RETURN(eRD_Mixer0); 
    1605         CASE_INT_EQUAL_RETURN(eRD_Mixer1); 
    1606         CASE_INT_EQUAL_RETURN(eRD_InS0); 
    1607         CASE_INT_EQUAL_RETURN(eRD_InS1); 
    1608         CASE_INT_EQUAL_RETURN(eRD_ARM); 
    1609         CASE_INT_EQUAL_RETURN(eRD_ATX0); 
    1610         CASE_INT_EQUAL_RETURN(eRD_ATX1); 
    1611         CASE_INT_EQUAL_RETURN(eRD_Muted); 
    1612         default: return eRD_Invalid; 
    1613     } 
    1614 
    1615  
    1616 enum eRouteSource 
    1617 EAP::RouterConfig::intToRouteSource(int src) 
    1618 
    1619     switch(src) { 
    1620         CASE_INT_EQUAL_RETURN(eRS_AES); 
    1621         CASE_INT_EQUAL_RETURN(eRS_ADAT); 
    1622         CASE_INT_EQUAL_RETURN(eRS_Mixer); 
    1623         CASE_INT_EQUAL_RETURN(eRS_InS0); 
    1624         CASE_INT_EQUAL_RETURN(eRS_InS1); 
    1625         CASE_INT_EQUAL_RETURN(eRS_ARM); 
    1626         CASE_INT_EQUAL_RETURN(eRS_ARX0); 
    1627         CASE_INT_EQUAL_RETURN(eRS_ARX1); 
    1628         CASE_INT_EQUAL_RETURN(eRS_Muted); 
    1629         default: return eRS_Invalid; 
    1630     } 
    1631 
    1632  
    1633 struct EAP::RouterConfig::Route 
    1634 EAP::RouterConfig::decodeRoute(uint32_t val) { 
    1635     int routerval = val & 0xFFFF; 
    1636     int peak = (val >> 16) & 0x0FFF; 
    1637     int src_blk = (routerval >> 12) & 0xF; 
    1638     int src_ch = (routerval >> 8) & 0xF; 
    1639     int dst_blk = (routerval >> 4) & 0xF; 
    1640     int dst_ch = (routerval >> 0) & 0xF; 
    1641     struct Route r = {intToRouteSource(src_blk), src_ch, intToRouteDestination(dst_blk), dst_ch, peak}; 
    1642     return r; 
    1643 
    1644  
    1645 uint32_t 
    1646 EAP::RouterConfig::encodeRoute(struct Route r) { 
    1647     if(r.src == eRS_Invalid || r.dst == eRD_Invalid) { 
    1648         debugWarning("Encoding invalid source/dest (%d/%d)\n", r.src, r.dst); 
    1649 //         return 0xFFFFFFFF; 
    1650     } 
    1651     unsigned int src_blk = ((unsigned int)r.src) & 0xF; 
    1652     unsigned int src_ch = ((unsigned int)r.srcChannel) & 0xF; 
    1653     unsigned int dst_blk = ((unsigned int)r.dst) & 0xF; 
    1654     unsigned int dst_ch = ((unsigned int)r.dstChannel) & 0xF; 
    1655     uint32_t routerval = 0; 
    1656     routerval |= (src_blk << 12); 
    1657     routerval |= (src_ch << 8); 
    1658     routerval |= (dst_blk << 4); 
    1659     routerval |= (dst_ch << 0); 
    1660     return routerval; 
    1661 
    1662  
    1663 struct EAP::RouterConfig::Route 
    1664 EAP::RouterConfig::getRouteForDestination(enum eRouteDestination dst, int channel) 
    1665 
    1666     for ( RouteVectorIterator it = m_routes.begin(); 
    1667         it != m_routes.end(); 
    1668         ++it ) 
    1669     { 
    1670         struct Route r = *it; 
    1671         if((r.dst == (int)dst) && (r.dstChannel == channel)) { 
    1672             debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "%s:%02d comes from %s:%02d\n", 
    1673                                                   dstBlockToString(r.dst), r.dstChannel, 
    1674                                                   srcBlockToString(r.src), r.srcChannel); 
    1675             return r; 
    1676         } 
    1677     } 
    1678     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "%s:%02d source can't be found\n", 
    1679                                           dstBlockToString((int)dst), channel); 
    1680     struct Route r = {eRS_Invalid, -1, eRD_Invalid, -1, 0}; 
    1681     return r; 
    1682 
    1683  
    1684 std::vector<struct EAP::RouterConfig::Route> 
    1685 EAP::RouterConfig::getRoutesForSource(enum eRouteSource src, int channel) 
    1686 
    1687     std::vector<struct Route>routes; 
    1688     for ( RouteVectorIterator it = m_routes.begin(); 
    1689         it != m_routes.end(); 
    1690         ++it ) 
    1691     { 
    1692         struct Route r = *it; 
    1693         if((r.src == (int)src) && (r.srcChannel == channel)) { 
    1694             debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "%s:%02d goes to %s:%02d\n", 
    1695                                                   srcBlockToString(r.src), r.srcChannel, 
    1696                                                   dstBlockToString(r.dst), r.dstChannel); 
    1697             routes.push_back(r); 
    1698         } 
    1699     } 
    1700     return routes; 
     1525std::vector<unsigned char> 
     1526EAP::RouterConfig::getDestinationsForSource(unsigned char source) { 
     1527    std::vector<unsigned char> ret; 
     1528    for (RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it) { 
     1529        if (it->second == source) { 
     1530            ret.push_back(it->first); 
     1531        } 
     1532    } 
     1533    return ret; 
    17011534} 
    17021535 
     
    17041537EAP::RouterConfig::show() 
    17051538{ 
    1706     for ( RouteVectorIterator it = m_routes.begin(); 
    1707         it != m_routes.end(); 
    1708         ++it ) 
    1709     { 
    1710         struct Route r = *it; 
    1711         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "%s:%02d => %s:%02d\n", 
    1712                                               srcBlockToString(r.src), r.srcChannel, 
    1713                                               dstBlockToString(r.dst), r.dstChannel); 
    1714     } 
    1715 
    1716  
    1717  
     1539    for ( RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it ) { 
     1540        printMessage("0x%02x -> 0x%02x\n", it->second, it->first); 
     1541    } 
     1542
     1543 
     1544// 
    17181545// ----------- peak space ------------- 
     1546// 
    17191547 
    17201548bool 
    17211549EAP::PeakSpace::read(enum eRegBase base, unsigned offset) 
    17221550{ 
     1551#warning "Implement me again!" 
     1552#if 0 
    17231553    // first clear the current route vector 
    17241554    m_routes.clear(); 
     
    17461576    } 
    17471577//     show(); 
     1578#endif 
    17481579    return true; 
    17491580} 
     
    17591590EAP::PeakSpace::show() 
    17601591{ 
     1592    debugError("PeakSpace::show() is currently not implemented!\n"); 
     1593#if 0 
    17611594    for ( RouteVectorIterator it = m_routes.begin(); 
    17621595        it != m_routes.end(); 
     
    17641597    { 
    17651598        struct Route r = *it; 
    1766         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "%s:%02d => %s:%02d : %06d\n", 
    1767                                               srcBlockToString(r.src), r.srcChannel, 
    1768                                               dstBlockToString(r.dst), r.dstChannel, 
    1769                                               r.peak); 
    1770     } 
     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 
    17711605} 
    17721606 
  • trunk/libffado/src/dice/dice_eap.h

    r1776 r1779  
    206206 
    207207    public: 
    208         struct Route 
    209         { 
    210             enum eRouteSource src; 
    211             int srcChannel; 
    212             enum eRouteDestination dst; 
    213             int dstChannel; 
    214             int peak; 
    215         }; 
    216         typedef std::vector<RouterConfig::Route> RouteVector; 
    217         typedef std::vector<RouterConfig::Route>::iterator RouteVectorIterator; 
    218208 
    219209        virtual bool read() {return read(m_base, m_offset);}; 
     
    223213        virtual void show(); 
    224214 
    225         bool insertRoute(struct Route r) 
    226             {return insertRoute(r, m_routes.size());}; 
    227         bool insertRoute(struct Route r, unsigned int index); 
    228         bool replaceRoute(unsigned int old_index, struct Route new_route); 
    229         bool replaceRoute(struct Route old_route, struct Route new_route); 
    230         bool removeRoute(struct Route r); 
    231         bool removeRoute(unsigned int index); 
    232         int getRouteIndex(struct Route r); 
    233         struct Route getRoute(unsigned int index); 
    234  
    235         unsigned int getNbRoutes() {return m_routes.size();}; 
    236  
    237         struct Route getRouteForDestination(enum eRouteDestination dst, int channel); 
    238         RouteVector getRoutesForSource(enum eRouteSource src, int channel); 
    239  
    240         struct Route decodeRoute(uint32_t val); 
    241         uint32_t encodeRoute(struct Route r); 
    242     public: 
    243         static enum eRouteDestination intToRouteDestination(int); 
    244         static enum eRouteSource intToRouteSource(int); 
     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; 
     222 
     223        /** 
     224          @brief Set up a route between src and dest 
     225 
     226          If a route with that destination exists, it will be replaced. If no route to that 
     227          destination exists, a new route will be established. 
     228          */ 
     229        bool setupRoute(unsigned char src, unsigned char dest); 
     230        /** 
     231          @brief Remove a route 
     232 
     233          @todo is this really necessary? 
     234          */ 
     235        bool removeRoute(unsigned char src, unsigned char dest); 
     236        /** 
     237          @brief Remove the destinations route 
     238          */ 
     239        bool removeRoute(unsigned char dest); 
     240 
     241        /** 
     242          @brief Return the source for the given destination 
     243 
     244          Returns -1 if the destination is not connected. 
     245          */ 
     246        unsigned char getSourceForDestination(unsigned char dest); 
     247        /** 
     248          @brief Return a list of destinations for a given source 
     249 
     250          Returns an empty list if no destination is connected to this source. 
     251          */ 
     252        std::vector<unsigned char> getDestinationsForSource(unsigned char src); 
     253 
     254        unsigned int getNbRoutes() {return m_routes2.size();}; 
     255 
    245256    protected: 
    246257        EAP &m_eap; 
    247258        enum eRegBase m_base; 
    248259        unsigned int m_offset; 
    249         RouteVector m_routes
     260        RouteVectorV2 m_routes2
    250261    protected: 
    251262        DECLARE_DEBUG_MODULE_REFERENCE; 
     
    341352        virtual double getValue( const int, const int ); 
    342353 
    343         bool hasNames() const { return true; } 
    344         std::string getRowName( const int ); 
    345         std::string getColName( const int ); 
     354        // @TODO: re-implement names 
     355        bool hasNames() const { return false; } 
     356        //std::string getRowName( const int ); 
     357        //std::string getColName( const int ); 
    346358 
    347359        // TODO: implement connections. 
     
    356368        fb_quadlet_t *m_coeff; 
    357369 
    358         std::map<int, RouterConfig::Route> m_input_route_map; 
    359         std::map<int, RouterConfig::RouteVector> m_output_route_map; 
     370        //std::map<int, RouterConfig::Route> m_input_route_map; 
     371        //std::map<int, RouterConfig::RouteVector> m_output_route_map; 
    360372 
    361373        DECLARE_DEBUG_MODULE_REFERENCE; 
  • trunk/libffado/src/dice/focusrite/saffire_pro24.cpp

    r1776 r1779  
    5050    addSource("Mixer",  0, 16, eRS_Mixer); 
    5151    addSource("1394",   0, 8, eRS_ARX0); 
     52    addSource("Mute",   0, 1, eRS_Muted); 
    5253} 
    5354void SaffirePro24::SaffirePro24EAP::setupDestinations() { 
     
    5758    addDestination("Mixer",  0, 2, eRD_Mixer1, 16); 
    5859    addDestination("1394",   0, 16, eRD_ATX0); 
     60    addDestination("Mute",   0, 1, eRD_Muted); 
    5961} 
    6062 
  • trunk/libffado/support/dbus/controlserver.cpp

    r1776 r1779  
    942942CrossbarRouter::getPeakValues() 
    943943{ 
    944     return std::vector< DBus::Struct<DBus::String, double> >(); 
     944    std::map<std::string, double> peakvalues = m_Slave.getPeakValues(); 
     945    std::vector< DBus::Struct<DBus::String, double> > ret; 
     946    for (std::map<std::string, double>::iterator it=peakvalues.begin(); it!=peakvalues.end(); ++it) { 
     947        DBus::Struct<DBus::String, double> tmp; 
     948        tmp._1 = it->first; 
     949        tmp._2 = it->second; 
     950        ret.push_back(tmp); 
     951    } 
     952    return ret; 
    945953    /*std::vector< DBus::Struct<int, double> > out; 
    946954    Control::CrossbarRouter::PeakValues values = m_Slave.getPeakValues(); 
  • trunk/libffado/support/mixer-qt4/ffado/widgets/crossbarrouter.py

    r1776 r1779  
    3737 
    3838        self.output = output 
    39         if input is None: 
    40             input = int(self.interface.getSourceForDestination(output)) 
    41         self.setInput(input) 
    42  
    43     def setInput(self, input): 
    44         #log.debug("VuMeter.setInput() %i->%i" % (self.output, input)) 
    45         self.input = input 
    4639 
    4740    def updateLevel(self, value): 
     
    8073        self.layout.addWidget(self.lbl, 0, 0) 
    8174 
    82         #self.vu = VuMeter(self.interface, self.interface.getDestinationIndex(outname), parent=self) 
    83         #self.layout.addWidget(self.vu, 0, 1) 
     75        self.vu = VuMeter(self.interface, outname, parent=self) 
     76        self.layout.addWidget(self.vu, 0, 1) 
    8477 
    8578        sources = self.interface.getSourceNames() 
     
    175168        #log.debug("CrossbarRouter.updateLevels()") 
    176169        peakvalues = self.interface.getPeakValues() 
    177         #log.debug("Got %i peaks" % len(peakvalues)) 
     170        log.debug("Got %i peaks" % len(peakvalues)) 
    178171        for peak in peakvalues: 
    179172            #log.debug("peak = [%s,%s]" % (str(peak[0]),str(peak[1])))